From python-checkins at python.org Mon May 1 05:03:10 2006 From: python-checkins at python.org (barry.warsaw) Date: Mon, 1 May 2006 05:03:10 +0200 (CEST) Subject: [Python-checkins] r45830 - in python/trunk/Lib: email/_parseaddr.py email/test/test_email.py email/test/test_email_renamed.py rfc822.py test/test_rfc822.py Message-ID: <20060501030310.767DB1E4011@bag.python.org> Author: barry.warsaw Date: Mon May 1 05:03:02 2006 New Revision: 45830 Modified: python/trunk/Lib/email/_parseaddr.py python/trunk/Lib/email/test/test_email.py python/trunk/Lib/email/test/test_email_renamed.py python/trunk/Lib/rfc822.py python/trunk/Lib/test/test_rfc822.py Log: Port forward from 2.4 branch: Patch #1464708 from William McVey: fixed handling of nested comments in mail addresses. E.g. "Foo ((Foo Bar)) " Fixes for both rfc822.py and email package. This patch needs to be back ported to Python 2.3 for email 2.5. Modified: python/trunk/Lib/email/_parseaddr.py ============================================================================== --- python/trunk/Lib/email/_parseaddr.py (original) +++ python/trunk/Lib/email/_parseaddr.py Mon May 1 05:03:02 2006 @@ -367,6 +367,7 @@ break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) + continue # have already advanced pos from getcomment elif self.field[self.pos] == '\\': quote = True else: Modified: python/trunk/Lib/email/test/test_email.py ============================================================================== --- python/trunk/Lib/email/test/test_email.py (original) +++ python/trunk/Lib/email/test/test_email.py Mon May 1 05:03:02 2006 @@ -2215,6 +2215,12 @@ ['foo: ;', '"Jason R. Mastaler" ']), [('', ''), ('Jason R. Mastaler', 'jason at dom.ain')]) + def test_getaddresses_embedded_comment(self): + """Test proper handling of a nested comment""" + eq = self.assertEqual + addrs = Utils.getaddresses(['User ((nested comment)) ']) + eq(addrs[0][1], 'foo at bar.com') + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() Modified: python/trunk/Lib/email/test/test_email_renamed.py ============================================================================== --- python/trunk/Lib/email/test/test_email_renamed.py (original) +++ python/trunk/Lib/email/test/test_email_renamed.py Mon May 1 05:03:02 2006 @@ -2221,6 +2221,12 @@ ['foo: ;', '"Jason R. Mastaler" ']), [('', ''), ('Jason R. Mastaler', 'jason at dom.ain')]) + def test_getaddresses_embedded_comment(self): + """Test proper handling of a nested comment""" + eq = self.assertEqual + addrs = utils.getaddresses(['User ((nested comment)) ']) + eq(addrs[0][1], 'foo at bar.com') + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() Modified: python/trunk/Lib/rfc822.py ============================================================================== --- python/trunk/Lib/rfc822.py (original) +++ python/trunk/Lib/rfc822.py Mon May 1 05:03:02 2006 @@ -700,6 +700,7 @@ break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) + continue # have already advanced pos from getcomment elif self.field[self.pos] == '\\': quote = 1 else: Modified: python/trunk/Lib/test/test_rfc822.py ============================================================================== --- python/trunk/Lib/test/test_rfc822.py (original) +++ python/trunk/Lib/test/test_rfc822.py Mon May 1 05:03:02 2006 @@ -45,6 +45,10 @@ print 'extra parsed address:', repr(n), repr(a) continue i = i + 1 + self.assertEqual(mn, n, + "Un-expected name: %s != %s" % (`mn`, `n`)) + self.assertEqual(ma, a, + "Un-expected address: %s != %s" % (`ma`, `a`)) if mn == n and ma == a: pass else: @@ -129,6 +133,12 @@ 'To: person at dom.ain (User J. Person)\n\n', [('User J. Person', 'person at dom.ain')]) + def test_doublecomment(self): + # The RFC allows comments within comments in an email addr + self.check( + 'To: person at dom.ain ((User J. Person)), John Doe \n\n', + [('User J. Person', 'person at dom.ain'), ('John Doe', 'foo at bar.com')]) + def test_twisted(self): # This one is just twisted. I don't know what the proper # result should be, but it shouldn't be to infloop, which is From python-checkins at python.org Mon May 1 05:21:31 2006 From: python-checkins at python.org (barry.warsaw) Date: Mon, 1 May 2006 05:21:31 +0200 (CEST) Subject: [Python-checkins] r45831 - in python/branches/release23-maint/Lib: email/_parseaddr.py email/test/test_email.py rfc822.py test/test_rfc822.py Message-ID: <20060501032131.8E6181E4009@bag.python.org> Author: barry.warsaw Date: Mon May 1 05:21:25 2006 New Revision: 45831 Modified: python/branches/release23-maint/Lib/email/_parseaddr.py python/branches/release23-maint/Lib/email/test/test_email.py python/branches/release23-maint/Lib/rfc822.py python/branches/release23-maint/Lib/test/test_rfc822.py Log: Back port from 2.4 branch: Patch #1464708 from William McVey: fixed handling of nested comments in mail addresses. E.g. "Foo ((Foo Bar)) " Fixes for both rfc822.py and email package. Modified: python/branches/release23-maint/Lib/email/_parseaddr.py ============================================================================== --- python/branches/release23-maint/Lib/email/_parseaddr.py (original) +++ python/branches/release23-maint/Lib/email/_parseaddr.py Mon May 1 05:21:25 2006 @@ -365,6 +365,7 @@ break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) + continue # have already advanced pos from getcomment elif self.field[self.pos] == '\\': quote = True else: Modified: python/branches/release23-maint/Lib/email/test/test_email.py ============================================================================== --- python/branches/release23-maint/Lib/email/test/test_email.py (original) +++ python/branches/release23-maint/Lib/email/test/test_email.py Mon May 1 05:21:25 2006 @@ -2064,6 +2064,12 @@ ['foo: ;', '"Jason R. Mastaler" ']), [('', ''), ('Jason R. Mastaler', 'jason at dom.ain')]) + def test_getaddresses_embedded_comment(self): + """Test proper handling of a nested comment""" + eq = self.assertEqual + addrs = Utils.getaddresses(['User ((nested comment)) ']) + eq(addrs[0][1], 'foo at bar.com') + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() Modified: python/branches/release23-maint/Lib/rfc822.py ============================================================================== --- python/branches/release23-maint/Lib/rfc822.py (original) +++ python/branches/release23-maint/Lib/rfc822.py Mon May 1 05:21:25 2006 @@ -712,6 +712,7 @@ break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) + continue # have already advanced pos from getcomment elif self.field[self.pos] == '\\': quote = 1 else: Modified: python/branches/release23-maint/Lib/test/test_rfc822.py ============================================================================== --- python/branches/release23-maint/Lib/test/test_rfc822.py (original) +++ python/branches/release23-maint/Lib/test/test_rfc822.py Mon May 1 05:21:25 2006 @@ -45,6 +45,10 @@ print 'extra parsed address:', repr(n), repr(a) continue i = i + 1 + self.assertEqual(mn, n, + "Un-expected name: %s != %s" % (`mn`, `n`)) + self.assertEqual(ma, a, + "Un-expected address: %s != %s" % (`ma`, `a`)) if mn == n and ma == a: pass else: @@ -129,6 +133,12 @@ 'To: person at dom.ain (User J. Person)\n\n', [('User J. Person', 'person at dom.ain')]) + def test_doublecomment(self): + # The RFC allows comments within comments in an email addr + self.check( + 'To: person at dom.ain ((User J. Person)), John Doe \n\n', + [('User J. Person', 'person at dom.ain'), ('John Doe', 'foo at bar.com')]) + def test_twisted(self): # This one is just twisted. I don't know what the proper # result should be, but it shouldn't be to infloop, which is From buildbot at python.org Mon May 1 05:51:25 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 03:51:25 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060501035125.836E91E400E@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/395 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: barry.warsaw Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 1 08:26:00 2006 From: python-checkins at python.org (fred.drake) Date: Mon, 1 May 2006 08:26:00 +0200 (CEST) Subject: [Python-checkins] r45832 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060501062600.58AD61E400E@bag.python.org> Author: fred.drake Date: Mon May 1 08:25:58 2006 New Revision: 45832 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: - minor clarification in section title - markup adjustments (there is clearly much to be done in this section) Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Mon May 1 08:25:58 2006 @@ -2,7 +2,7 @@ DB-API 2.0 interface for SQLite databases} \declaremodule{builtin}{sqlite3} -\modulesynopsis{A DB-API 2.0 interface based on SQLite 3.x.} +\modulesynopsis{A DB-API 2.0 implementation using SQLite 3.x.} @@ -20,7 +20,6 @@ \begin{datadesc}{PARSE_COLNAMES} - Setting this makes pysqlite parse the column name for each column it returns. It will look for a string formed [mytype] in there, and then decide that 'mytype' is the type of the column. It will try to find an entry of 'mytype' in @@ -67,7 +66,6 @@ \end{funcdesc} \begin{funcdesc}{register_converter}{typename, callable} - Registers a callable to convert a bytestring from the database into a custom Python type. The callable will be invoked for all database values that are of the type \var{typename}. Confer the parameter **detect_types** of the @@ -83,23 +81,19 @@ \end{funcdesc} - - - - -\subsection{Connection Objects \label{Connection-Objects}} +\subsection{Connection Objects \label{sqlite3-Connection-Objects}} A \class{Connection} instance has the following attributes and methods: -\member{isolation_level} - Get or set the current isolation level. None for autocommit mode or one - of "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See `5. Controlling - Transactions`_ for a more detailed explanation. +\begin{memberdesc}{isolation_level} + Get or set the current isolation level. None for autocommit mode or one + of "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See `5. Controlling + Transactions`_ for a more detailed explanation. +\end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} - The cursor method accepts a single optional parameter \var{cursorClass}. - This is a custom cursor class which must extend sqlite3.Cursor. + The cursor method accepts a single optional parameter \var{cursorClass}. + This is a custom cursor class which must extend \class{sqlite3.Cursor}. \end{methoddesc} TODO: execute* - From python-checkins at python.org Mon May 1 08:28:02 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 1 May 2006 08:28:02 +0200 (CEST) Subject: [Python-checkins] r45833 - in python/trunk: Misc/NEWS Modules/_tkinter.c Message-ID: <20060501062802.DC0241E400E@bag.python.org> Author: martin.v.loewis Date: Mon May 1 08:28:01 2006 New Revision: 45833 Modified: python/trunk/Misc/NEWS python/trunk/Modules/_tkinter.c Log: Work around deadlock risk. Will backport. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 1 08:28:01 2006 @@ -63,6 +63,9 @@ Extension Modules ----------------- +- Calling Tk_Init twice is refused if the first call failed as that + may deadlock. + - Patch #1191065: Fix preprocessor problems on systems where recvfrom is a macro. Modified: python/trunk/Modules/_tkinter.c ============================================================================== --- python/trunk/Modules/_tkinter.c (original) +++ python/trunk/Modules/_tkinter.c Mon May 1 08:28:01 2006 @@ -2619,21 +2619,32 @@ static PyObject * Tkapp_TkInit(PyObject *self, PyObject *args) { + static int has_failed; Tcl_Interp *interp = Tkapp_Interp(self); Tk_Window main_window; const char * _tk_exists = NULL; - PyObject *res = NULL; int err; main_window = Tk_MainWindow(interp); + /* In all current versions of Tk (including 8.4.13), Tk_Init + deadlocks on the second call when the first call failed. + To avoid the deadlock, we just refuse the second call through + a static variable. */ + if (has_failed) { + PyErr_SetString(Tkinter_TclError, + "Calling Tk_Init again after a previous call failed might deadlock"); + return NULL; + } + /* We want to guard against calling Tk_Init() multiple times */ CHECK_TCL_APPARTMENT; ENTER_TCL err = Tcl_Eval(Tkapp_Interp(self), "info exists tk_version"); ENTER_OVERLAP if (err == TCL_ERROR) { - /* XXX: shouldn't we do something with res? */ - res = Tkinter_Error(self); + /* This sets an exception, but we cannot return right + away because we need to exit the overlap first. */ + Tkinter_Error(self); } else { _tk_exists = Tkapp_Result(self); } @@ -2644,6 +2655,7 @@ if (_tk_exists == NULL || strcmp(_tk_exists, "1") != 0) { if (Tk_Init(interp) == TCL_ERROR) { PyErr_SetString(Tkinter_TclError, Tcl_GetStringResult(Tkapp_Interp(self))); + has_failed = 1; return NULL; } } From python-checkins at python.org Mon May 1 08:29:07 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 1 May 2006 08:29:07 +0200 (CEST) Subject: [Python-checkins] r45834 - in python/branches/release24-maint: Misc/NEWS Modules/_tkinter.c Message-ID: <20060501062907.D773B1E400E@bag.python.org> Author: martin.v.loewis Date: Mon May 1 08:29:06 2006 New Revision: 45834 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/_tkinter.c Log: Work around deadlock risk. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Mon May 1 08:29:06 2006 @@ -15,6 +15,9 @@ Extension Modules ----------------- +- Calling Tk_Init twice is refused if the first call failed as that + may deadlock. + - Patch #1191065: Fix preprocessor problems on systems where recvfrom is a macro. Modified: python/branches/release24-maint/Modules/_tkinter.c ============================================================================== --- python/branches/release24-maint/Modules/_tkinter.c (original) +++ python/branches/release24-maint/Modules/_tkinter.c Mon May 1 08:29:06 2006 @@ -2609,20 +2609,32 @@ static PyObject * Tkapp_TkInit(PyObject *self, PyObject *args) { + static int has_failed; Tcl_Interp *interp = Tkapp_Interp(self); Tk_Window main_window; const char * _tk_exists = NULL; - PyObject *res = NULL; int err; main_window = Tk_MainWindow(interp); + /* In all current versions of Tk (including 8.4.13), Tk_Init + deadlocks on the second call when the first call failed. + To avoid the deadlock, we just refuse the second call through + a static variable. */ + if (has_failed) { + PyErr_SetString(Tkinter_TclError, + "Calling Tk_Init again after a previous call failed might deadlock"); + return NULL; + } + /* We want to guard against calling Tk_Init() multiple times */ CHECK_TCL_APPARTMENT; ENTER_TCL err = Tcl_Eval(Tkapp_Interp(self), "info exists tk_version"); ENTER_OVERLAP if (err == TCL_ERROR) { - res = Tkinter_Error(self); + /* This sets an exception, but we cannot return right + away because we need to exit the overlap first. */ + Tkinter_Error(self); } else { _tk_exists = Tkapp_Result(self); } @@ -2633,6 +2645,7 @@ if (_tk_exists == NULL || strcmp(_tk_exists, "1") != 0) { if (Tk_Init(interp) == TCL_ERROR) { PyErr_SetString(Tkinter_TclError, Tcl_GetStringResult(Tkapp_Interp(self))); + has_failed = 1; return NULL; } } From fdrake at acm.org Mon May 1 08:34:09 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 1 May 2006 02:34:09 -0400 Subject: [Python-checkins] r45810 - in python/trunk/Doc: Makefile.deps lib/lib.tex lib/libsqlite3.tex In-Reply-To: References: <20060429231242.6CAEC1E400D@bag.python.org> Message-ID: <200605010234.10000.fdrake@acm.org> On Sunday 30 April 2006 01:00, Georg Brandl wrote: > > +\declaremodule{builtin}{sqlite3} > > +\modulesynopsis{A DB-API 2.0 interface based on SQLite 3.x.} > > I find that confusing -- isn't it a DB-API interface to SQLite? I've adjusted that description; hopefully that's more clear now. The state of that section of the documentation is very sad. Hopefully someone in the know can at least add a link to the original documentation in a comment at the top of that file; if there's a related issue on SF, or if one of the volunteer LaTeXifers is already on it, that would be good to note as well. In the current state, I don't know where to look for documentation on the module, or whether I should even attempt to work on it any myself. -Fred -- Fred L. Drake, Jr. From buildbot at python.org Mon May 1 11:20:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 09:20:15 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060501092015.BD8781E4012@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/12 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 1 11:40:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 09:40:49 +0000 Subject: [Python-checkins] buildbot failure in sparc Ubuntu dapper 2.4 Message-ID: <20060501094049.B177D1E4015@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%25202.4/builds/46 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Mon May 1 13:18:19 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 13:18:19 +0200 (CEST) Subject: [Python-checkins] r45835 - peps/trunk/pep-0000.txt peps/trunk/pep-0314.txt peps/trunk/pep-0356.txt Message-ID: <20060501111819.3360D1E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 13:18:18 2006 New Revision: 45835 Modified: peps/trunk/pep-0000.txt peps/trunk/pep-0314.txt peps/trunk/pep-0356.txt Log: Mark PEP 314 as final Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Mon May 1 13:18:18 2006 @@ -86,7 +86,6 @@ I 287 reStructuredText Docstring Format Goodger S 297 Support for System Upgrades Lemburg S 302 New Import Hooks JvR, Moore - S 314 Metadata for Python Software Packages v1.1 Kuchling, Jones S 323 Copyable Iterators Martelli S 331 Locale-Independent Float/String Conversions Reis S 334 Simple Coroutines via SuspendIteration Evans @@ -155,6 +154,7 @@ SF 308 Conditional Expressions GvR, Hettinger SF 309 Partial Function Application Harris SF 311 Simplified GIL Acquisition for Extensions Hammond + SF 314 Metadata for Python Software Packages v1.1 Kuchling, Jones SF 318 Decorators for Functions and Methods Smith, et al IF 320 Python 2.4 Release Schedule Warsaw, et al SF 322 Reverse Iteration Hettinger @@ -374,7 +374,7 @@ SF 311 Simplified GIL Acquisition for Extensions Hammond SD 312 Simple Implicit Lambda Suzi, Martelli SR 313 Adding Roman Numeral Literals to Python Meyer - S 314 Metadata for Python Software Packages v1.1 Kuchling, Jones + SF 314 Metadata for Python Software Packages v1.1 Kuchling, Jones SD 315 Enhanced While Loop Carroll, Hettinger SD 316 Programming by Contract for Python Way SR 317 Eliminate Implicit Exception Instantiation Taschuk Modified: peps/trunk/pep-0314.txt ============================================================================== --- peps/trunk/pep-0314.txt (original) +++ peps/trunk/pep-0314.txt Mon May 1 13:18:18 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: A.M. Kuchling , Richard Jones -Status: Draft +Status: Final Type: Standards Track Content-type: text/plain Created: 12-Apr-2003 Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Mon May 1 13:18:18 2006 @@ -52,7 +52,6 @@ PEP 308: Conditional Expressions PEP 309: Partial Function Application PEP 314: Metadata for Python Software Packages v1.1 - (should PEP 314 be marked final?) PEP 328: Absolute/Relative Imports PEP 338: Executing Modules as Scripts PEP 341: Unified try-except/try-finally to try-except-finally From python-checkins at python.org Mon May 1 14:45:03 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 14:45:03 +0200 (CEST) Subject: [Python-checkins] r45836 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060501124503.A0FBC1E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 14:45:02 2006 New Revision: 45836 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Some ElementTree fixes: import from xml, not xmlcore; fix case of module name; mention list() instead of getchildren() Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Mon May 1 14:45:02 2006 @@ -1633,7 +1633,7 @@ \subsection{The ElementTree package\label{module-etree}} A subset of Fredrik Lundh's ElementTree library for processing XML has -been added to the standard library as \module{xmlcore.etree}. The +been added to the standard library as \module{xml.etree}. The available modules are \module{ElementTree}, \module{ElementPath}, and \module{ElementInclude} from ElementTree 1.2.6. @@ -1655,7 +1655,7 @@ object and returns an \class{ElementTree} instance: \begin{verbatim} -from xmlcore.etree import ElementTree as ET +from xml.etree import ElementTree as ET tree = ET.parse('ex-1.xml') @@ -1673,7 +1673,7 @@ approaching the convenience of an XML literal: \begin{verbatim} -svg = et.XML(""" +svg = ET.XML(""" """) svg.set('height', '320px') svg.append(elem1) @@ -1687,7 +1687,7 @@ \lineii{elem[n]}{Returns n'th child element.} \lineii{elem[m:n]}{Returns list of m'th through n'th child elements.} \lineii{len(elem)}{Returns number of child elements.} - \lineii{elem.getchildren()}{Returns list of child elements.} + \lineii{list(elem)}{Returns list of child elements.} \lineii{elem.append(elem2)}{Adds \var{elem2} as a child.} \lineii{elem.insert(index, elem2)}{Inserts \var{elem2} at the specified location.} \lineii{del elem[n]}{Deletes n'th child element.} @@ -2096,7 +2096,7 @@ The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this -article: Phillip J. Eby, Kent Johnson, Martin von~L\"owis, Gustavo -Niemeyer, James Pryor, Mike Rovner, Thomas Wouters. +article: Phillip J. Eby, Kent Johnson, Martin von~L\"owis, Fredrik Lundh, +Gustavo Niemeyer, James Pryor, Mike Rovner, Thomas Wouters. \end{document} From jimjjewett at gmail.com Mon May 1 15:19:49 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Mon, 1 May 2006 09:19:49 -0400 Subject: [Python-checkins] r45794 - peps/trunk/pep-3099.txt In-Reply-To: <20060428200600.27E9E1E400F@bag.python.org> References: <20060428200600.27E9E1E400F@bag.python.org> Message-ID: I assume this doesn't really mean a separate ASCII-String type, or even using bytes; just that everything except comments and string literals is restricted to the code points that appear in ASCII. -jJ On 4/28/06, guido.van.rossum wrote: > Author: guido.van.rossum > Date: Fri Apr 28 22:05:59 2006 > New Revision: 45794 > > Modified: > peps/trunk/pep-3099.txt > Log: > No Unicode for operators or names. > > > Modified: peps/trunk/pep-3099.txt > ============================================================================== > --- peps/trunk/pep-3099.txt (original) > +++ peps/trunk/pep-3099.txt Fri Apr 28 22:05:59 2006 > @@ -47,6 +47,12 @@ > Thread: "Adding sorting to generator comprehension", > http://mail.python.org/pipermail/python-3000/2006-April/001295.html > > +* Python won't use Unicode characters for anything except string > + literals or comments. > + > + Thread: sets in P3K? > + http://mail.python.org/pipermail/python-3000/2006-April/01474.html > + > > Builtins > ======== > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Mon May 1 17:14:50 2006 From: python-checkins at python.org (gerhard.haering) Date: Mon, 1 May 2006 17:14:50 +0200 (CEST) Subject: [Python-checkins] r45837 - in python/trunk/Doc/lib: libsqlite3.tex sqlite3 sqlite3/adapter_datetime.py sqlite3/adapter_point_1.py sqlite3/adapter_point_2.py sqlite3/collation_reverse.py sqlite3/complete_statement.py sqlite3/connect_db_1.py sqlite3/connect_db_2.py sqlite3/converter_point.py sqlite3/countcursors.py sqlite3/createdb.py sqlite3/execsql_fetchonerow.py sqlite3/execsql_printall_1.py sqlite3/execute_1.py sqlite3/execute_2.py sqlite3/execute_3.py sqlite3/executemany_1.py sqlite3/executemany_2.py sqlite3/executescript.py sqlite3/insert_more_people.py sqlite3/md5func.py sqlite3/mysumaggr.py sqlite3/parse_colnames.py sqlite3/pysqlite_datetime.py sqlite3/row_factory.py sqlite3/rowclass.py sqlite3/shared_cache.py sqlite3/shortcut_methods.py sqlite3/simple_tableprinter.py sqlite3/text_factory.py Message-ID: <20060501151450.4E2811E4010@bag.python.org> Author: gerhard.haering Date: Mon May 1 17:14:48 2006 New Revision: 45837 Added: python/trunk/Doc/lib/sqlite3/ python/trunk/Doc/lib/sqlite3/adapter_datetime.py python/trunk/Doc/lib/sqlite3/adapter_point_1.py python/trunk/Doc/lib/sqlite3/adapter_point_2.py python/trunk/Doc/lib/sqlite3/collation_reverse.py python/trunk/Doc/lib/sqlite3/complete_statement.py python/trunk/Doc/lib/sqlite3/connect_db_1.py python/trunk/Doc/lib/sqlite3/connect_db_2.py python/trunk/Doc/lib/sqlite3/converter_point.py python/trunk/Doc/lib/sqlite3/countcursors.py python/trunk/Doc/lib/sqlite3/createdb.py python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py python/trunk/Doc/lib/sqlite3/execsql_printall_1.py python/trunk/Doc/lib/sqlite3/execute_1.py python/trunk/Doc/lib/sqlite3/execute_2.py python/trunk/Doc/lib/sqlite3/execute_3.py python/trunk/Doc/lib/sqlite3/executemany_1.py python/trunk/Doc/lib/sqlite3/executemany_2.py python/trunk/Doc/lib/sqlite3/executescript.py python/trunk/Doc/lib/sqlite3/insert_more_people.py python/trunk/Doc/lib/sqlite3/md5func.py python/trunk/Doc/lib/sqlite3/mysumaggr.py python/trunk/Doc/lib/sqlite3/parse_colnames.py python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py python/trunk/Doc/lib/sqlite3/row_factory.py python/trunk/Doc/lib/sqlite3/rowclass.py python/trunk/Doc/lib/sqlite3/shared_cache.py python/trunk/Doc/lib/sqlite3/shortcut_methods.py python/trunk/Doc/lib/sqlite3/simple_tableprinter.py python/trunk/Doc/lib/sqlite3/text_factory.py Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Further integration of the documentation for the sqlite3 module. There's still quite some content to move over from the pysqlite manual, but it's a start now. Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Mon May 1 17:14:48 2006 @@ -86,8 +86,8 @@ A \class{Connection} instance has the following attributes and methods: \begin{memberdesc}{isolation_level} - Get or set the current isolation level. None for autocommit mode or one - of "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See `5. Controlling + Get or set the current isolation level. None for autocommit mode or one + of "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See `5. Controlling Transactions`_ for a more detailed explanation. \end{memberdesc} @@ -96,4 +96,136 @@ This is a custom cursor class which must extend \class{sqlite3.Cursor}. \end{methoddesc} -TODO: execute* +\begin{methoddesc}{execute}{sql, \optional{parameters}} +This is a nonstandard shortcut that creates an intermediate cursor object by +calling the cursor method, then calls the cursor's execute method with the +parameters given. +\end{methoddesc} + +\begin{methoddesc}{executemany}{sql, \optional{parameters}} +This is a nonstandard shortcut that creates an intermediate cursor object by +calling the cursor method, then calls the cursor's executemany method with the +parameters given. +\end{methoddesc} + +\begin{methoddesc}{executescript}{sql_script} +This is a nonstandard shortcut that creates an intermediate cursor object by +calling the cursor method, then calls the cursor's executescript method with the +parameters given. +\end{methoddesc} + +\begin{memberdesc}{row_factory} + You can change this attribute to a callable that accepts the cursor and + the original row as tuple and will return the real result row. This + way, you can implement more advanced ways of returning results, like + ones that can also access columns by name. + + Example: + + \verbatiminput{sqlite3/row_factory.py} + + If the standard tuple types don't suffice for you, and you want name-based + access to columns, you should consider setting \member{row_factory} to the + highly-optimized pysqlite2.dbapi2.Row type. It provides both + index-based and case-insensitive name-based access to columns with almost + no memory overhead. Much better than your own custom dictionary-based + approach or even a db_row based solution. +\end{memberdesc} + +\begin{memberdesc}{text_factory} + Using this attribute you can control what objects pysqlite returns for the + TEXT data type. By default, this attribute is set to ``unicode`` and + pysqlite will return Unicode objects for TEXT. If you want to return + bytestrings instead, you can set it to ``str``. + + For efficiency reasons, there's also a way to return Unicode objects only + for non-ASCII data, and bytestrings otherwise. To activate it, set this + attribute to ``pysqlite2.dbapi2.OptimizedUnicode``. + + You can also set it to any other callable that accepts a single bytestring + parameter and returns the result object. + + See the following example code for illustration: + + \verbatiminput{sqlite3/text_factory.py} +\end{memberdesc} + +\begin{memberdesc}{total_changes} + Returns the total number of database rows that have be modified, inserted, + or deleted since the database connection was opened. +\end{memberdesc} + + + + + +\subsection{Cursor Objects \label{Cursor-Objects}} + +A \class{Cursor} instance has the following attributes and methods: + +\begin{methoddesc}{execute}{sql, \optional{parameters}} + +Executes a SQL statement. The SQL statement may be parametrized (i. e. +placeholders instead of SQL literals). The sqlite3 module supports two kinds of +placeholders: question marks (qmark style) and named placeholders (named +style). + +This example shows how to use parameters with qmark style: + + \verbatiminput{sqlite3/execute_1.py} + +This example shows how to use the named style: + + \verbatiminput{sqlite3/execute_2.py} + + \method{execute} will only execute a single SQL statement. If you try to + execute more than one statement with it, it will raise a Warning. Use + \method{executescript} if want to execute multiple SQL statements with one + call. +\end{methoddesc} + + +\begin{methoddesc}{executemany}{sql, seq_of_parameters} +Executes a SQL command against all parameter sequences or mappings found in the +sequence \var{sql}. The \module{sqlite3} module also allows +to use an iterator yielding parameters instead of a sequence. + +\verbatiminput{sqlite3/executemany_1.py} + +Here's a shorter example using a generator: + +\verbatiminput{sqlite3/executemany_2.py} +\end{methoddesc} + +\begin{methoddesc}{executescript}{sql_script} + +This is a nonstandard convenience method for executing multiple SQL statements +at once. It issues a COMMIT statement before, then executes the SQL script it +gets as a parameter. + +\var{sql_script} can be a bytestring or a Unicode string. + +Example: + +\verbatiminput{sqlite3/executescript.py} +\end{methoddesc} + +\begin{memberdesc}{rowcount} + Although the Cursors of the \module{sqlite3} module implement this + attribute, the database engine's own support for the determination of "rows + affected"/"rows selected" is quirky. + + For \code{SELECT} statements, \member{rowcount} is always None because we cannot + determine the number of rows a query produced until all rows were fetched. + + For \code{DELETE} statements, SQLite reports \member{rowcount} as 0 if you make a + \code{DELETE FROM table} without any condition. + + For \method{executemany} statements, pysqlite sums up the number of + modifications into \member{rowcount}. + + As required by the Python DB API Spec, the \member{rowcount} attribute "is -1 + in case no executeXX() has been performed on the cursor or the rowcount + of the last operation is not determinable by the interface". +\end{memberdesc} + Added: python/trunk/Doc/lib/sqlite3/adapter_datetime.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/adapter_datetime.py Mon May 1 17:14:48 2006 @@ -0,0 +1,14 @@ +import sqlite3 +import datetime, time + +def adapt_datetime(ts): + return time.mktime(ts.timetuple()) + +sqlite3.register_adapter(datetime.datetime, adapt_datetime) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +now = datetime.datetime.now() +cur.execute("select ?", (now,)) +print cur.fetchone()[0] Added: python/trunk/Doc/lib/sqlite3/adapter_point_1.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/adapter_point_1.py Mon May 1 17:14:48 2006 @@ -0,0 +1,17 @@ +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + + def __conform__(self, protocol): + if protocol is sqlite3.PrepareProtocol: + return "%f;%f" % (self.x, self.y) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +p = Point(4.0, -3.2) +cur.execute("select ?", (p,)) +print cur.fetchone()[0] + Added: python/trunk/Doc/lib/sqlite3/adapter_point_2.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/adapter_point_2.py Mon May 1 17:14:48 2006 @@ -0,0 +1,18 @@ +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + +def adapt_point(point): + return "%f;%f" % (point.x, point.y) + +sqlite3.register_adapter(Point, adapt_point) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +p = Point(4.0, -3.2) +cur.execute("select ?", (p,)) +print cur.fetchone()[0] + Added: python/trunk/Doc/lib/sqlite3/collation_reverse.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/collation_reverse.py Mon May 1 17:14:48 2006 @@ -0,0 +1,15 @@ +import sqlite3 + +def collate_reverse(string1, string2): + return -cmp(string1, string2) + +con = sqlite3.connect(":memory:") +con.create_collation("reverse", collate_reverse) + +cur = con.cursor() +cur.execute("create table test(x)") +cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]) +cur.execute("select x from test order by x collate reverse") +for row in cur: + print row +con.close() Added: python/trunk/Doc/lib/sqlite3/complete_statement.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/complete_statement.py Mon May 1 17:14:48 2006 @@ -0,0 +1,30 @@ +# A minimal SQLite shell for experiments + +import sqlite3 + +con = sqlite3.connect(":memory:") +con.isolation_level = None +cur = con.cursor() + +buffer = "" + +print "Enter your SQL commands to execute in sqlite3." +print "Enter a blank line to exit." + +while True: + line = raw_input() + if line == "": + break + buffer += line + if sqlite3.complete_statement(buffer): + try: + buffer = buffer.strip() + cur.execute(buffer) + + if buffer.lstrip().upper().startswith("SELECT"): + print cur.fetchall() + except sqlite3.Error, e: + print "An error occured:", e.args[0] + buffer = "" + +con.close() Added: python/trunk/Doc/lib/sqlite3/connect_db_1.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/connect_db_1.py Mon May 1 17:14:48 2006 @@ -0,0 +1,3 @@ +import sqlite3 + +con = sqlite3.connect("mydb") Added: python/trunk/Doc/lib/sqlite3/connect_db_2.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/connect_db_2.py Mon May 1 17:14:48 2006 @@ -0,0 +1,3 @@ +import sqlite3 + +con = sqlite3.connect(":memory:") Added: python/trunk/Doc/lib/sqlite3/converter_point.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/converter_point.py Mon May 1 17:14:48 2006 @@ -0,0 +1,47 @@ +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + + def __repr__(self): + return "(%f;%f)" % (self.x, self.y) + +def adapt_point(point): + return "%f;%f" % (point.x, point.y) + +def convert_point(s): + x, y = map(float, s.split(";")) + return Point(x, y) + +# Register the adapter +sqlite3.register_adapter(Point, adapt_point) + +# Register the converter +sqlite3.register_converter("point", convert_point) + +p = Point(4.0, -3.2) + +######################### +# 1) Using declared types +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) +cur = con.cursor() +cur.execute("create table test(p point)") + +cur.execute("insert into test(p) values (?)", (p,)) +cur.execute("select p from test") +print "with declared types:", cur.fetchone()[0] +cur.close() +con.close() + +####################### +# 1) Using column names +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute("create table test(p)") + +cur.execute("insert into test(p) values (?)", (p,)) +cur.execute('select p as "p [point]" from test') +print "with column names:", cur.fetchone()[0] +cur.close() +con.close() Added: python/trunk/Doc/lib/sqlite3/countcursors.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/countcursors.py Mon May 1 17:14:48 2006 @@ -0,0 +1,15 @@ +import sqlite3 + +class CountCursorsConnection(sqlite3.Connection): + def __init__(self, *args, **kwargs): + sqlite3.Connection.__init__(self, *args, **kwargs) + self.numcursors = 0 + + def cursor(self, *args, **kwargs): + self.numcursors += 1 + return sqlite3.Connection.cursor(self, *args, **kwargs) + +con = sqlite3.connect(":memory:", factory=CountCursorsConnection) +cur1 = con.cursor() +cur2 = con.cursor() +print con.numcursors Added: python/trunk/Doc/lib/sqlite3/createdb.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/createdb.py Mon May 1 17:14:48 2006 @@ -0,0 +1,28 @@ +# Not referenced from the documentation, but builds the database file the other +# code snippets expect. + +import sqlite3 +import os + +DB_FILE = "mydb" + +if os.path.exists(DB_FILE): + os.remove(DB_FILE) + +con = sqlite3.connect(DB_FILE) +cur = con.cursor() +cur.execute(""" + create table people + ( + name_last varchar(20), + age integer + ) + """) + +cur.execute("insert into people (name_last, age) values ('Yeltsin', 72)") +cur.execute("insert into people (name_last, age) values ('Putin', 51)") + +con.commit() + +cur.close() +con.close() Added: python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py Mon May 1 17:14:48 2006 @@ -0,0 +1,17 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() +SELECT = "select name_last, age from people order by age, name_last" + +# 1. Iterate over the rows available from the cursor, unpacking the +# resulting sequences to yield their elements (name_last, age): +cur.execute(SELECT) +for (name_last, age) in cur: + print '%s is %d years old.' % (name_last, age) + +# 2. Equivalently: +cur.execute(SELECT) +for row in cur: + print '%s is %d years old.' % (row[0], row[1]) Added: python/trunk/Doc/lib/sqlite3/execsql_printall_1.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/execsql_printall_1.py Mon May 1 17:14:48 2006 @@ -0,0 +1,13 @@ +import sqlite3 + +# Create a connection to the database file "mydb": +con = sqlite3.connect("mydb") + +# Get a Cursor object that operates in the context of Connection con: +cur = con.cursor() + +# Execute the SELECT statement: +cur.execute("select * from people order by age") + +# Retrieve all rows as a sequence and print that sequence: +print cur.fetchall() Added: python/trunk/Doc/lib/sqlite3/execute_1.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/execute_1.py Mon May 1 17:14:48 2006 @@ -0,0 +1,11 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) +print cur.fetchone() Added: python/trunk/Doc/lib/sqlite3/execute_2.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/execute_2.py Mon May 1 17:14:48 2006 @@ -0,0 +1,13 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=:who and age=:age", + {"who": who, "age": age}) +print cur.fetchone() + Added: python/trunk/Doc/lib/sqlite3/execute_3.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/execute_3.py Mon May 1 17:14:48 2006 @@ -0,0 +1,14 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=:who and age=:age", + locals()) +print cur.fetchone() + + Added: python/trunk/Doc/lib/sqlite3/executemany_1.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/executemany_1.py Mon May 1 17:14:48 2006 @@ -0,0 +1,24 @@ +import sqlite3 + +class IterChars: + def __init__(self): + self.count = ord('a') + + def __iter__(self): + return self + + def next(self): + if self.count > ord('z'): + raise StopIteration + self.count += 1 + return (chr(self.count - 1),) # this is a 1-tuple + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.execute("create table characters(c)") + +theIter = IterChars() +cur.executemany("insert into characters(c) values (?)", theIter) + +cur.execute("select c from characters") +print cur.fetchall() Added: python/trunk/Doc/lib/sqlite3/executemany_2.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/executemany_2.py Mon May 1 17:14:48 2006 @@ -0,0 +1,15 @@ +import sqlite3 + +def char_generator(): + import string + for c in string.letters[:26]: + yield (c,) + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.execute("create table characters(c)") + +cur.executemany("insert into characters(c) values (?)", char_generator()) + +cur.execute("select c from characters") +print cur.fetchall() Added: python/trunk/Doc/lib/sqlite3/executescript.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/executescript.py Mon May 1 17:14:48 2006 @@ -0,0 +1,24 @@ +import sqlite3 + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.executescript(""" + create table person( + firstname, + lastname, + age + ); + + create table book( + title, + author, + published + ); + + insert into book(title, author, published) + values ( + 'Dirk Gently''s Holistic Detective Agency + 'Douglas Adams', + 1987 + ); + """) Added: python/trunk/Doc/lib/sqlite3/insert_more_people.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/insert_more_people.py Mon May 1 17:14:48 2006 @@ -0,0 +1,17 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +newPeople = ( + ('Lebed' , 53), + ('Zhirinovsky' , 57), + ) + +for person in newPeople: + cur.execute("insert into people (name_last, age) values (?, ?)", person) + +# The changes will not be saved unless the transaction is committed explicitly: +con.commit() + Added: python/trunk/Doc/lib/sqlite3/md5func.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/md5func.py Mon May 1 17:14:48 2006 @@ -0,0 +1,11 @@ +import sqlite3 +import md5 + +def md5sum(t): + return md5.md5(t).hexdigest() + +con = sqlite3.connect(":memory:") +con.create_function("md5", 1, md5sum) +cur = con.cursor() +cur.execute("select md5(?)", ("foo",)) +print cur.fetchone()[0] Added: python/trunk/Doc/lib/sqlite3/mysumaggr.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/mysumaggr.py Mon May 1 17:14:48 2006 @@ -0,0 +1,20 @@ +import sqlite3 + +class MySum: + def __init__(self): + self.count = 0 + + def step(self, value): + self.count += value + + def finalize(self): + return self.count + +con = sqlite3.connect(":memory:") +con.create_aggregate("mysum", 1, MySum) +cur = con.cursor() +cur.execute("create table test(i)") +cur.execute("insert into test(i) values (1)") +cur.execute("insert into test(i) values (2)") +cur.execute("select mysum(i) from test") +print cur.fetchone()[0] Added: python/trunk/Doc/lib/sqlite3/parse_colnames.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/parse_colnames.py Mon May 1 17:14:48 2006 @@ -0,0 +1,8 @@ +import sqlite3 +import datetime + +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) +dt = cur.fetchone()[0] +print dt, type(dt) Added: python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py Mon May 1 17:14:48 2006 @@ -0,0 +1,20 @@ +import sqlite3 +import datetime + +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute("create table test(d date, ts timestamp)") + +today = datetime.date.today() +now = datetime.datetime.now() + +cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) +cur.execute("select d, ts from test") +row = cur.fetchone() +print today, "=>", row[0], type(row[0]) +print now, "=>", row[1], type(row[1]) + +cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') +row = cur.fetchone() +print "current_date", row[0], type(row[0]) +print "current_timestamp", row[1], type(row[1]) Added: python/trunk/Doc/lib/sqlite3/row_factory.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/row_factory.py Mon May 1 17:14:48 2006 @@ -0,0 +1,13 @@ +import sqlite3 + +def dict_factory(cursor, row): + d = {} + for idx, col in enumerate(cursor.description): + d[col[0]] = row[idx] + return d + +con = sqlite3.connect(":memory:") +con.row_factory = dict_factory +cur = con.cursor() +cur.execute("select 1 as a") +print cur.fetchone()["a"] Added: python/trunk/Doc/lib/sqlite3/rowclass.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/rowclass.py Mon May 1 17:14:48 2006 @@ -0,0 +1,12 @@ +import sqlite3 + +con = sqlite3.connect("mydb") +con.row_factory = sqlite3.Row + +cur = con.cursor() +cur.execute("select name_last, age from people") +for row in cur: + assert row[0] == row["name_last"] + assert row["name_last"] == row["nAmE_lAsT"] + assert row[1] == row["age"] + assert row[1] == row["AgE"] Added: python/trunk/Doc/lib/sqlite3/shared_cache.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/shared_cache.py Mon May 1 17:14:48 2006 @@ -0,0 +1,6 @@ +import sqlite3 + +# The shared cache is only available in SQLite versions 3.3.3 or later +# See the SQLite documentaton for details. + +sqlite3.enable_shared_cache(True) Added: python/trunk/Doc/lib/sqlite3/shortcut_methods.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/shortcut_methods.py Mon May 1 17:14:48 2006 @@ -0,0 +1,22 @@ +import sqlite3 + +persons = [ + ("Hugo", "Boss"), + ("Calvin", "Klein") + ] + +con = sqlite3.connect(":memory:") + +# Create the table +con.execute("create table person(firstname, lastname)") + +# Fill the table +con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) + +# Print the table contents +for row in con.execute("select firstname, lastname from person"): + print row + +# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. +print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" + Added: python/trunk/Doc/lib/sqlite3/simple_tableprinter.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/simple_tableprinter.py Mon May 1 17:14:48 2006 @@ -0,0 +1,26 @@ +import sqlite3 + +FIELD_MAX_WIDTH = 20 +TABLE_NAME = 'people' +SELECT = 'select * from %s order by age, name_last' % TABLE_NAME + +con = sqlite3.connect("mydb") + +cur = con.cursor() +cur.execute(SELECT) + +# Print a header. +for fieldDesc in cur.description: + print fieldDesc[0].ljust(FIELD_MAX_WIDTH) , +print # Finish the header with a newline. +print '-' * 78 + +# For each row, print the value of each field left-justified within +# the maximum possible width of that field. +fieldIndices = range(len(cur.description)) +for row in cur: + for fieldIndex in fieldIndices: + fieldValue = str(row[fieldIndex]) + print fieldValue.ljust(FIELD_MAX_WIDTH) , + + print # Finish the row with a newline. Added: python/trunk/Doc/lib/sqlite3/text_factory.py ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/sqlite3/text_factory.py Mon May 1 17:14:48 2006 @@ -0,0 +1,43 @@ +import sqlite3 + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +# Create the table +con.execute("create table person(lastname, firstname)") + +AUSTRIA = u"\xd6sterreich" + +# by default, rows are returned as Unicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert row[0] == AUSTRIA + +# but we can make pysqlite always return bytestrings ... +con.text_factory = str +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == str +# the bytestrings will be encoded in UTF-8, unless you stored garbage in the +# database ... +assert row[0] == AUSTRIA.encode("utf-8") + +# we can also implement a custom text_factory ... +# here we implement one that will ignore Unicode characters that cannot be +# decoded from UTF-8 +con.text_factory = lambda x: unicode(x, "utf-8", "ignore") +cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) +row = cur.fetchone() +assert type(row[0]) == unicode + +# pysqlite offers a builtin optimized text_factory that will return bytestring +# objects, if the data is in ASCII only, and otherwise return unicode objects +con.text_factory = sqlite3.OptimizedUnicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == unicode + +cur.execute("select ?", ("Germany",)) +row = cur.fetchone() +assert type(row[0]) == str + From anthony at interlink.com.au Mon May 1 17:28:43 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Tue, 2 May 2006 01:28:43 +1000 Subject: [Python-checkins] r45837 - in python/trunk/Doc/lib: libsqlite3.tex sqlite3 sqlite3/adapter_datetime.py sqlite3/adapter_point_1.py sqlite3/adapter_point_2.py sqlite3/collation_reverse.py sqlite3/complete_statement.py sqlite3/connect_db_1.py sq In-Reply-To: <20060501151450.4E2811E4010@bag.python.org> References: <20060501151450.4E2811E4010@bag.python.org> Message-ID: <200605020128.46791.anthony@interlink.com.au> On Tuesday 02 May 2006 01:14, gerhard.haering wrote: > Author: gerhard.haering > Date: Mon May 1 17:14:48 2006 > New Revision: 45837 The example code in this should go into a directory in Demo/, surely, rather than in the standard library? -- Anthony Baxter It's never too late to have a happy childhood. From gh at ghaering.de Mon May 1 17:55:26 2006 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Mon, 01 May 2006 17:55:26 +0200 Subject: [Python-checkins] r45837 - in python/trunk/Doc/lib: libsqlite3.tex sqlite3 sqlite3/adapter_datetime.py sqlite3/adapter_point_1.py sqlite3/adapter_point_2.py sqlite3/collation_reverse.py sqlite3/complete_statement.py sqlite3/connect_db_1.py sq In-Reply-To: <200605020128.46791.anthony@interlink.com.au> References: <20060501151450.4E2811E4010@bag.python.org> <200605020128.46791.anthony@interlink.com.au> Message-ID: <44562F6E.9020908@ghaering.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Anthony Baxter wrote: > On Tuesday 02 May 2006 01:14, gerhard.haering wrote: > >>Author: gerhard.haering >>Date: Mon May 1 17:14:48 2006 >>New Revision: 45837 > > The example code in this should go into a directory in Demo/, surely, > rather than in the standard library? I checked it in in a subdirectory of Docs/lib because it is referenced from the module documentation. Moving everything into Demo/ is another possibility. As you can see, it's a currently a kind of "porting" of the pysqlite docs. I'm of course open to other and better approaches (but I like examples in documentation. And the reason for moving the examples to external .py files in pysqlite was so that they can be tested if they actually work). - -- Gerhard -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEVi9udIO4ozGCH14RAngeAJ9Kf7D/si6S9gDMFjbaJm0fDVFZUwCdHIcc Qoz6ccJ/TLZsZgHoKJNVFSk= =NTxj -----END PGP SIGNATURE----- From python-checkins at python.org Mon May 1 17:56:05 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 1 May 2006 17:56:05 +0200 (CEST) Subject: [Python-checkins] r45838 - python/trunk/Lib/msilib/text.py python/trunk/Lib/msilib/uisample.py Message-ID: <20060501155605.8B1861E4014@bag.python.org> Author: martin.v.loewis Date: Mon May 1 17:56:03 2006 New Revision: 45838 Added: python/trunk/Lib/msilib/text.py - copied, changed from r45823, python/trunk/Lib/msilib/uisample.py Removed: python/trunk/Lib/msilib/uisample.py Log: Rename uisample to text, drop all non-text tables. Copied: python/trunk/Lib/msilib/text.py (from r45823, python/trunk/Lib/msilib/uisample.py) ============================================================================== --- python/trunk/Lib/msilib/uisample.py (original) +++ python/trunk/Lib/msilib/text.py Mon May 1 17:56:03 2006 @@ -1,398 +1,4 @@ import msilib,os;dirname=os.path.dirname(__file__) -AdminExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'InstallFiles', None, 4000), -(u'InstallAdminPackage', None, 3900), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -] - -AdminUISequence = [ -(u'AdminWelcomeDlg', None, 1230), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'ExecuteAction', None, 1300), -(u'ExitDialog', None, -1), -(u'FatalError', None, -3), -(u'PrepareDlg', None, 140), -(u'ProgressDlg', None, 1280), -(u'UserExit', None, -2), -] - -AdvtExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'CreateShortcuts', None, 4500), -(u'PublishComponents', None, 6200), -(u'PublishFeatures', None, 6300), -(u'PublishProduct', None, 6400), -(u'RegisterClassInfo', None, 4600), -(u'RegisterExtensionInfo', None, 4700), -(u'RegisterMIMEInfo', None, 4900), -(u'RegisterProgIdInfo', None, 4800), -] - -BBControl = [ -] - -Billboard = [ -] - -Binary = [ -(u'bannrbmp', msilib.Binary(os.path.join(dirname,"bannrbmp.bin"))), -(u'completi', msilib.Binary(os.path.join(dirname,"completi.bin"))), -(u'custicon', msilib.Binary(os.path.join(dirname,"custicon.bin"))), -(u'dlgbmp', msilib.Binary(os.path.join(dirname,"dlgbmp.bin"))), -(u'exclamic', msilib.Binary(os.path.join(dirname,"exclamic.bin"))), -(u'info', msilib.Binary(os.path.join(dirname,"info.bin"))), -(u'insticon', msilib.Binary(os.path.join(dirname,"insticon.bin"))), -(u'New', msilib.Binary(os.path.join(dirname,"New.bin"))), -(u'removico', msilib.Binary(os.path.join(dirname,"removico.bin"))), -(u'repairic', msilib.Binary(os.path.join(dirname,"repairic.bin"))), -(u'Up', msilib.Binary(os.path.join(dirname,"Up.bin"))), -] - -CheckBox = [ -] - -Property = [ -(u'BannerBitmap', u'bannrbmp'), -(u'IAgree', u'No'), -(u'ProductID', u'none'), -(u'ARPHELPLINK', u'http://www.microsoft.com/management'), -(u'ButtonText_Back', u'< &Back'), -(u'ButtonText_Browse', u'Br&owse'), -(u'ButtonText_Cancel', u'Cancel'), -(u'ButtonText_Exit', u'&Exit'), -(u'ButtonText_Finish', u'&Finish'), -(u'ButtonText_Ignore', u'&Ignore'), -(u'ButtonText_Install', u'&Install'), -(u'ButtonText_Next', u'&Next >'), -(u'ButtonText_No', u'&No'), -(u'ButtonText_OK', u'OK'), -(u'ButtonText_Remove', u'&Remove'), -(u'ButtonText_Repair', u'&Repair'), -(u'ButtonText_Reset', u'&Reset'), -(u'ButtonText_Resume', u'&Resume'), -(u'ButtonText_Retry', u'&Retry'), -(u'ButtonText_Return', u'&Return'), -(u'ButtonText_Yes', u'&Yes'), -(u'CompleteSetupIcon', u'completi'), -(u'ComponentDownload', u'ftp://anonymous at microsoft.com/components/'), -(u'CustomSetupIcon', u'custicon'), -(u'DefaultUIFont', u'DlgFont8'), -(u'DialogBitmap', u'dlgbmp'), -(u'DlgTitleFont', u'{&DlgFontBold8}'), -(u'ErrorDialog', u'ErrorDlg'), -(u'ExclamationIcon', u'exclamic'), -(u'InfoIcon', u'info'), -(u'InstallerIcon', u'insticon'), -(u'INSTALLLEVEL', u'3'), -(u'InstallMode', u'Typical'), -(u'PIDTemplate', u'12345<###-%%%%%%%>@@@@@'), -#(u'ProductLanguage', u'1033'), -(u'Progress1', u'Installing'), -(u'Progress2', u'installs'), -(u'PROMPTROLLBACKCOST', u'P'), -(u'RemoveIcon', u'removico'), -(u'RepairIcon', u'repairic'), -(u'Setup', u'Setup'), -(u'ShowUserRegistrationDlg', u'1'), -(u'Wizard', u'Setup Wizard'), -] - -ComboBox = [ -] - -Control = [ -(u'AdminWelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'AdminWelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminWelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'AdminWelcomeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will create a server image of [ProductName], at a specified network location. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'AdminWelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'AdminWelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminWelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'ExitDialog', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'ExitDialog', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ExitDialog', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'ExitDialog', u'Description', u'Text', 135, 70, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'ExitDialog', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Completing the [ProductName] [Wizard]', None, None), -(u'ExitDialog', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'ExitDialog', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'FatalError', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'FatalError', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'FatalError', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'FatalError', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}[ProductName] [Wizard] ended prematurely', None, None), -(u'FatalError', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'FatalError', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'FatalError', u'Description1', u'Text', 135, 70, 220, 40, 196611, None, u'[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.', None, None), -(u'FatalError', u'Description2', u'Text', 135, 115, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'PrepareDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Cancel', None), -(u'PrepareDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'PrepareDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'PrepareDlg', u'Description', u'Text', 135, 70, 220, 20, 196611, None, u'Please wait while the [Wizard] prepares to guide you through the installation.', None, None), -(u'PrepareDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'PrepareDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', None, None), -(u'PrepareDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', None, None), -(u'PrepareDlg', u'ActionData', u'Text', 135, 125, 220, 30, 196611, None, None, None, None), -(u'PrepareDlg', u'ActionText', u'Text', 135, 100, 220, 20, 196611, None, None, None, None), -(u'ProgressDlg', u'Text', u'Text', 35, 65, 300, 20, 3, None, u'Please wait while the [Wizard] [Progress2] [ProductName]. This may take several minutes.', None, None), -(u'ProgressDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'ProgressDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'ProgressDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ProgressDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'ProgressDlg', u'Title', u'Text', 20, 15, 200, 15, 196611, None, u'[DlgTitleFont][Progress1] [ProductName]', None, None), -(u'ProgressDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'ProgressDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'ProgressDlg', u'ActionText', u'Text', 70, 100, 265, 10, 3, None, None, None, None), -(u'ProgressDlg', u'ProgressBar', u'ProgressBar', 35, 115, 300, 10, 65537, None, u'Progress done', None, None), -(u'ProgressDlg', u'StatusLabel', u'Text', 35, 100, 35, 10, 3, None, u'Status:', None, None), -(u'UserExit', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'UserExit', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'UserExit', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'UserExit', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}[ProductName] [Wizard] was interrupted', None, None), -(u'UserExit', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'UserExit', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'UserExit', u'Description1', u'Text', 135, 70, 220, 40, 196611, None, u'[ProductName] setup was interrupted. Your system has not been modified. To install this program at a later time, please run the installation again.', None, None), -(u'UserExit', u'Description2', u'Text', 135, 115, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'AdminBrowseDlg', u'Up', u'PushButton', 298, 55, 19, 19, 3670019, None, u'Up', u'NewFolder', u'Up One Level|'), -(u'AdminBrowseDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'PathEdit', None), -(u'AdminBrowseDlg', u'PathEdit', u'PathEdit', 84, 202, 261, 17, 3, u'TARGETDIR', None, u'OK', None), -(u'AdminBrowseDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminBrowseDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminBrowseDlg', u'Cancel', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'ComboLabel', None), -(u'AdminBrowseDlg', u'ComboLabel', u'Text', 25, 58, 44, 10, 3, None, u'&Look in:', u'DirectoryCombo', None), -(u'AdminBrowseDlg', u'DirectoryCombo', u'DirectoryCombo', 70, 55, 220, 80, 458755, u'TARGETDIR', None, u'Up', None), -(u'AdminBrowseDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Browse to the destination folder', None, None), -(u'AdminBrowseDlg', u'DirectoryList', u'DirectoryList', 25, 83, 320, 110, 7, u'TARGETDIR', None, u'PathLabel', None), -(u'AdminBrowseDlg', u'PathLabel', u'Text', 25, 205, 59, 10, 3, None, u'&Folder name:', u'BannerBitmap', None), -(u'AdminBrowseDlg', u'NewFolder', u'PushButton', 325, 55, 19, 19, 3670019, None, u'New', u'DirectoryList', u'Create A New Folder|'), -(u'AdminBrowseDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'Cancel', None), -(u'AdminBrowseDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Change current destination folder', None, None), -(u'AdminInstallPointDlg', u'Text', u'Text', 25, 80, 320, 10, 3, None, u'&Enter a new network location or click Browse to browse to one.', u'PathEdit', None), -(u'AdminInstallPointDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Text', None), -(u'AdminInstallPointDlg', u'PathEdit', u'PathEdit', 25, 93, 320, 18, 3, u'TARGETDIR', None, u'Browse', None), -(u'AdminInstallPointDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminInstallPointDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminInstallPointDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'AdminInstallPointDlg', u'Description', u'Text', 25, 20, 280, 20, 196611, None, u'Please specify a network location for the server image of [ProductName] product', None, None), -(u'AdminInstallPointDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Network Location', None, None), -(u'AdminInstallPointDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminInstallPointDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'AdminInstallPointDlg', u'Browse', u'PushButton', 289, 119, 56, 17, 3, None, u'[ButtonText_Browse]', u'Back', None), -(u'AdminRegistrationDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OrganizationLabel', None), -(u'AdminRegistrationDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminRegistrationDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminRegistrationDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'AdminRegistrationDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please enter your company information', None, None), -(u'AdminRegistrationDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Company Information', None, None), -(u'AdminRegistrationDlg', u'Back', u'PushButton', 180, 243, 56, 17, 65539, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminRegistrationDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'AdminRegistrationDlg', u'OrganizationLabel', u'Text', 45, 71, 285, 30, 3, None, u'&Please enter the name of your organization in the box below. This will be used as default company name for subsequent installations of [ProductName]:', u'OrganizationEdit', None), -(u'AdminRegistrationDlg', u'CDKeyEdit', u'MaskedEdit', 45, 143, 250, 16, 3, u'PIDKEY', u'[PIDTemplate]', u'Back', None), -(u'AdminRegistrationDlg', u'CDKeyLabel', u'Text', 45, 130, 50, 10, 3, None, u'CD &Key:', u'CDKeyEdit', None), -(u'AdminRegistrationDlg', u'OrganizationEdit', u'Edit', 45, 105, 220, 18, 3, u'COMPANYNAME', u'{80}', u'CDKeyLabel', None), -(u'BrowseDlg', u'Up', u'PushButton', 298, 55, 19, 19, 3670019, None, u'Up', u'NewFolder', u'Up One Level|'), -(u'BrowseDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'PathEdit', None), -(u'BrowseDlg', u'PathEdit', u'PathEdit', 84, 202, 261, 18, 11, u'_BrowseProperty', None, u'OK', None), -(u'BrowseDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'BrowseDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'BrowseDlg', u'Cancel', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'ComboLabel', None), -(u'BrowseDlg', u'ComboLabel', u'Text', 25, 58, 44, 10, 3, None, u'&Look in:', u'DirectoryCombo', None), -(u'BrowseDlg', u'DirectoryCombo', u'DirectoryCombo', 70, 55, 220, 80, 393227, u'_BrowseProperty', None, u'Up', None), -(u'BrowseDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Browse to the destination folder', None, None), -(u'BrowseDlg', u'DirectoryList', u'DirectoryList', 25, 83, 320, 110, 15, u'_BrowseProperty', None, u'PathLabel', None), -(u'BrowseDlg', u'PathLabel', u'Text', 25, 205, 59, 10, 3, None, u'&Folder name:', u'BannerBitmap', None), -(u'BrowseDlg', u'NewFolder', u'PushButton', 325, 55, 19, 19, 3670019, None, u'New', u'DirectoryList', u'Create A New Folder|'), -(u'BrowseDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'Cancel', None), -(u'BrowseDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Change current destination folder', None, None), -(u'CancelDlg', u'Text', u'Text', 48, 15, 194, 30, 3, None, u'Are you sure you want to cancel [ProductName] installation?', None, None), -(u'CancelDlg', u'Icon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[InfoIcon]', None, u'Information icon|'), -(u'CancelDlg', u'No', u'PushButton', 132, 57, 56, 17, 3, None, u'[ButtonText_No]', u'Yes', None), -(u'CancelDlg', u'Yes', u'PushButton', 72, 57, 56, 17, 3, None, u'[ButtonText_Yes]', u'No', None), -(u'CustomizeDlg', u'Text', u'Text', 25, 55, 320, 20, 3, None, u'Click on the icons in the tree below to change the way features will be installed.', None, None), -(u'CustomizeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Tree', None), -(u'CustomizeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'CustomizeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'CustomizeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'CustomizeDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Select the way you want features to be installed.', None, None), -(u'CustomizeDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Custom Setup', None, None), -(u'CustomizeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'CustomizeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'CustomizeDlg', u'Browse', u'PushButton', 304, 200, 56, 17, 3, None, u'[ButtonText_Browse]', u'Reset', None), -(u'CustomizeDlg', u'Tree', u'SelectionTree', 25, 85, 175, 95, 7, u'_BrowseProperty', u'Tree of selections', u'Browse', None), -(u'CustomizeDlg', u'Box', u'GroupBox', 210, 81, 140, 98, 1, None, None, None, None), -(u'CustomizeDlg', u'Reset', u'PushButton', 42, 243, 56, 17, 3, None, u'[ButtonText_Reset]', u'DiskCost', None), -(u'CustomizeDlg', u'DiskCost', u'PushButton', 111, 243, 56, 17, 3, None, u'Disk &Usage', u'Back', None), -(u'CustomizeDlg', u'ItemDescription', u'Text', 215, 90, 131, 30, 3, None, u'Multiline description of the currently selected item.', None, None), -(u'CustomizeDlg', u'ItemSize', u'Text', 215, 130, 131, 45, 3, None, u'The size of the currently selected item.', None, None), -(u'CustomizeDlg', u'Location', u'Text', 75, 200, 215, 20, 3, None, u"", None, None), -(u'CustomizeDlg', u'LocationLabel', u'Text', 25, 200, 50, 10, 3, None, u'Location:', None, None), -(u'DiskCostDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes (if any) do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'DiskCostDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OK', None), -(u'DiskCostDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'DiskCostDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'DiskCostDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'The disk space required for the installation of the selected features.', None, None), -(u'DiskCostDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'BannerBitmap', None), -(u'DiskCostDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Disk Space Requirements', None, None), -(u'DiskCostDlg', u'VolumeList', u'VolumeCostList', 20, 100, 330, 120, 393223, None, u'{120}{70}{70}{70}{70}', None, None), -(u'ErrorDlg', u'Y', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Yes]', None, None), -(u'ErrorDlg', u'A', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Cancel]', None, None), -(u'ErrorDlg', u'C', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Cancel]', None, None), -(u'ErrorDlg', u'ErrorIcon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[InfoIcon]', None, u'Information icon|'), -(u'ErrorDlg', u'ErrorText', u'Text', 48, 15, 205, 60, 3, None, u'Information text', None, None), -(u'ErrorDlg', u'I', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Ignore]', None, None), -(u'ErrorDlg', u'N', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_No]', None, None), -(u'ErrorDlg', u'O', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_OK]', None, None), -(u'ErrorDlg', u'R', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Retry]', None, None), -(u'FilesInUse', u'Text', u'Text', 20, 55, 330, 30, 3, None, u'The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.', None, None), -(u'FilesInUse', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Retry', None), -(u'FilesInUse', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'FilesInUse', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'FilesInUse', u'Description', u'Text', 20, 23, 280, 20, 196611, None, u'Some files that need to be updated are currently in use.', None, None), -(u'FilesInUse', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Files in Use', None, None), -(u'FilesInUse', u'Retry', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Retry]', u'Ignore', None), -(u'FilesInUse', u'Exit', u'PushButton', 166, 243, 56, 17, 3, None, u'[ButtonText_Exit]', u'BannerBitmap', None), -(u'FilesInUse', u'Ignore', u'PushButton', 235, 243, 56, 17, 3, None, u'[ButtonText_Ignore]', u'Exit', None), -(u'FilesInUse', u'List', u'ListBox', 20, 87, 330, 130, 7, u'FileInUseProcess', None, None, None), -(u'LicenseAgreementDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'AgreementText', None), -(u'LicenseAgreementDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'LicenseAgreementDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'LicenseAgreementDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'LicenseAgreementDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please read the following license agreement carefully', None, None), -(u'LicenseAgreementDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]End-User License Agreement', None, None), -(u'LicenseAgreementDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'LicenseAgreementDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'LicenseAgreementDlg', u'AgreementText', u'ScrollableText', 20, 60, 330, 120, 7, None, u'{\\rtf1\\ansi\\ansicpg1252\\deff0\\deftab720{\\fonttbl{\\f0\\froman\\fprq2 Times New Roman;}}{\\colortbl\\red0\\green0\\blue0;} \\deflang1033\\horzdoc{\\*\\fchars }{\\*\\lchars }\\pard\\plain\\f0\\fs20 \\par }', u'Buttons', None), -(u'LicenseAgreementDlg', u'Buttons', u'RadioButtonGroup', 20, 187, 330, 40, 3, u'IAgree', None, u'Back', None), -(u'MaintenanceTypeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'ChangeLabel', None), -(u'MaintenanceTypeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'MaintenanceTypeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'MaintenanceTypeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'MaintenanceTypeDlg', u'Description', u'Text', 25, 23, 280, 20, 196611, None, u'Select the operation you wish to perform.', None, None), -(u'MaintenanceTypeDlg', u'Title', u'Text', 15, 6, 240, 15, 196611, None, u'[DlgTitleFont]Modify, Repair or Remove installation', None, None), -(u'MaintenanceTypeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'MaintenanceTypeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'MaintenanceTypeDlg', u'ChangeLabel', u'Text', 105, 65, 100, 10, 3, None, u'[DlgTitleFont]&Modify', u'ChangeButton', None), -(u'MaintenanceTypeDlg', u'ChangeButton', u'PushButton', 50, 65, 38, 38, 5767171, None, u'[CustomSetupIcon]', u'RepairLabel', u'Modify Installation|'), -(u'MaintenanceTypeDlg', u'RepairLabel', u'Text', 105, 114, 100, 10, 3, None, u'[DlgTitleFont]Re&pair', u'RepairButton', None), -(u'MaintenanceTypeDlg', u'ChangeText', u'Text', 105, 78, 230, 20, 3, None, u'Allows users to change the way features are installed.', None, None), -(u'MaintenanceTypeDlg', u'RemoveButton', u'PushButton', 50, 163, 38, 38, 5767171, None, u'[RemoveIcon]', u'Back', u'Remove Installation|'), -(u'MaintenanceTypeDlg', u'RemoveLabel', u'Text', 105, 163, 100, 10, 3, None, u'[DlgTitleFont]&Remove', u'RemoveButton', None), -(u'MaintenanceTypeDlg', u'RemoveText', u'Text', 105, 176, 230, 20, 3, None, u'Removes [ProductName] from your computer.', None, None), -(u'MaintenanceTypeDlg', u'RepairButton', u'PushButton', 50, 114, 38, 38, 5767171, None, u'[RepairIcon]', u'RemoveLabel', u'Repair Installation|'), -(u'MaintenanceTypeDlg', u'RepairText', u'Text', 105, 127, 230, 30, 3, None, u'Repairs errors in the most recent installation state - fixes missing or corrupt files, shortcuts and registry entries.', None, None), -(u'MaintenanceWelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'MaintenanceWelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'MaintenanceWelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'MaintenanceWelcomeDlg', u'Description', u'Text', 135, 70, 220, 60, 196611, None, u'The [Wizard] will allow you to change the way [ProductName] features are installed on your computer or even to remove [ProductName] from your computer. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'MaintenanceWelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'MaintenanceWelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'MaintenanceWelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'OutOfDiskDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'OutOfDiskDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OK', None), -(u'OutOfDiskDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'OutOfDiskDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'OutOfDiskDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'Disk space required for the installation exceeds available disk space.', None, None), -(u'OutOfDiskDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'BannerBitmap', None), -(u'OutOfDiskDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Out of Disk Space', None, None), -(u'OutOfDiskDlg', u'VolumeList', u'VolumeCostList', 20, 100, 330, 120, 393223, None, u'{120}{70}{70}{70}{70}', None, None), -(u'OutOfRbDiskDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'OutOfRbDiskDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'No', None), -(u'OutOfRbDiskDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'OutOfRbDiskDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'OutOfRbDiskDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'Disk space required for the installation exceeds available disk space.', None, None), -(u'OutOfRbDiskDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Out of Disk Space', None, None), -(u'OutOfRbDiskDlg', u'No', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_No]', u'Yes', None), -(u'OutOfRbDiskDlg', u'Yes', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Yes]', u'BannerBitmap', None), -(u'OutOfRbDiskDlg', u'VolumeList', u'VolumeCostList', 20, 140, 330, 80, 4587527, None, u'{120}{70}{70}{70}{70}', None, None), -(u'OutOfRbDiskDlg', u'Text2', u'Text', 20, 94, 330, 40, 3, None, u"Alternatively, you may choose to disable the installer's rollback functionality. This allows the installer to restore your computer's original state should the installation be interrupted in any way. Click Yes if you wish to take the risk to disable rollback.", None, None), -(u'ResumeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'ResumeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ResumeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'ResumeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will complete the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the [Wizard].', None, None), -(u'ResumeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Resuming the [ProductName] [Wizard]', None, None), -(u'ResumeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Install', None), -(u'ResumeDlg', u'Install', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Install]', u'Cancel', None), -(u'SetupTypeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'TypicalLabel', None), -(u'SetupTypeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'SetupTypeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'SetupTypeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'SetupTypeDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Choose the setup type that best suits your needs', None, None), -(u'SetupTypeDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Choose Setup Type', None, None), -(u'SetupTypeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'SetupTypeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'SetupTypeDlg', u'TypicalLabel', u'Text', 105, 65, 100, 10, 3, None, u'[DlgTitleFont]&Typical', u'TypicalButton', None), -(u'SetupTypeDlg', u'CompleteButton', u'PushButton', 50, 171, 38, 38, 5767171, None, u'[CompleteSetupIcon]', u'Back', u'Complete Installation|'), -(u'SetupTypeDlg', u'CompleteLabel', u'Text', 105, 171, 100, 10, 3, None, u'[DlgTitleFont]C&omplete', u'CompleteButton', None), -(u'SetupTypeDlg', u'CompleteText', u'Text', 105, 184, 230, 20, 3, None, u'All program features will be installed. (Requires most disk space)', None, None), -(u'SetupTypeDlg', u'CustomButton', u'PushButton', 50, 118, 38, 38, 5767171, None, u'[CustomSetupIcon]', u'CompleteLabel', u'Custom Installation|'), -(u'SetupTypeDlg', u'CustomLabel', u'Text', 105, 118, 100, 10, 3, None, u'[DlgTitleFont]C&ustom', u'CustomButton', None), -(u'SetupTypeDlg', u'CustomText', u'Text', 105, 131, 230, 30, 3, None, u'Allows users to choose which program features will be installed and where they will be installed. Recommended for advanced users.', None, None), -(u'SetupTypeDlg', u'TypicalButton', u'PushButton', 50, 65, 38, 38, 5767171, None, u'[InstallerIcon]', u'CustomLabel', u'Typical Installation|'), -(u'SetupTypeDlg', u'TypicalText', u'Text', 105, 78, 230, 20, 3, None, u'Installs the most common program features. Recommended for most users.', None, None), -(u'UserRegistrationDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'NameLabel', None), -(u'UserRegistrationDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'UserRegistrationDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'UserRegistrationDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'UserRegistrationDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please enter your customer information', None, None), -(u'UserRegistrationDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Customer Information', None, None), -(u'UserRegistrationDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'UserRegistrationDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'UserRegistrationDlg', u'OrganizationLabel', u'Text', 45, 110, 100, 15, 3, None, u'&Organization:', u'OrganizationEdit', None), -(u'UserRegistrationDlg', u'CDKeyEdit', u'MaskedEdit', 45, 159, 250, 16, 3, u'PIDKEY', u'[PIDTemplate]', u'Back', None), -(u'UserRegistrationDlg', u'CDKeyLabel', u'Text', 45, 147, 50, 10, 3, None, u'CD &Key:', u'CDKeyEdit', None), -(u'UserRegistrationDlg', u'OrganizationEdit', u'Edit', 45, 122, 220, 18, 3, u'COMPANYNAME', u'{80}', u'CDKeyLabel', None), -(u'UserRegistrationDlg', u'NameLabel', u'Text', 45, 73, 100, 15, 3, None, u'&User Name:', u'NameEdit', None), -(u'UserRegistrationDlg', u'NameEdit', u'Edit', 45, 85, 220, 18, 3, u'USERNAME', u'{80}', u'OrganizationLabel', None), -(u'VerifyReadyDlg', u'Text', u'Text', 25, 70, 320, 20, 3, None, u'Click Install to begin the installation. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyReadyDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyReadyDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyReadyDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyReadyDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyReadyDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'The [Wizard] is ready to begin the [InstallMode] installation', None, None), -(u'VerifyReadyDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Ready to Install', None, None), -(u'VerifyReadyDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Install', None), -(u'VerifyReadyDlg', u'Install', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Install]', u'Cancel', None), -(u'VerifyRemoveDlg', u'Text', u'Text', 25, 70, 320, 30, 3, None, u'Click Remove to remove [ProductName] from your computer. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyRemoveDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyRemoveDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyRemoveDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyRemoveDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyRemoveDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'You have chosen to remove the program from your computer.', None, None), -(u'VerifyRemoveDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Remove [ProductName]', None, None), -(u'VerifyRemoveDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Remove', None), -(u'VerifyRemoveDlg', u'Remove', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Remove]', u'Cancel', None), -(u'VerifyRepairDlg', u'Text', u'Text', 25, 70, 320, 30, 3, None, u'Click Repair to repair the installation of [ProductName]. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyRepairDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyRepairDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyRepairDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyRepairDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyRepairDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'The [Wizard] is ready to begin the repair of [ProductName].', None, None), -(u'VerifyRepairDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Repair [ProductName]', None, None), -(u'VerifyRepairDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Repair', None), -(u'VerifyRepairDlg', u'Repair', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Repair]', u'Cancel', None), -(u'WaitForCostingDlg', u'Text', u'Text', 48, 15, 194, 30, 3, None, u'Please wait while the installer finishes determining your disk space requirements.', None, None), -(u'WaitForCostingDlg', u'Icon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[ExclamationIcon]', None, u'Exclamation icon|'), -(u'WaitForCostingDlg', u'Return', u'PushButton', 102, 57, 56, 17, 3, None, u'[ButtonText_Return]', None, None), -(u'WelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'WelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'WelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'WelcomeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will install [ProductName] on your computer. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'WelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'WelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'WelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -] - -ListBox = [ -] ActionText = [ (u'InstallValidate', u'Validating install', None), @@ -467,294 +73,6 @@ (u'UnpublishProduct', u'Unpublishing product information', None), ] -ControlCondition = [ -(u'CustomizeDlg', u'Browse', u'Hide', u'Installed'), -(u'CustomizeDlg', u'Location', u'Hide', u'Installed'), -(u'CustomizeDlg', u'LocationLabel', u'Hide', u'Installed'), -(u'LicenseAgreementDlg', u'Next', u'Disable', u'IAgree <> "Yes"'), -(u'LicenseAgreementDlg', u'Next', u'Enable', u'IAgree = "Yes"'), -] - -ControlEvent = [ -(u'AdminWelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminWelcomeDlg', u'Next', u'NewDialog', u'AdminRegistrationDlg', u'1', 2), -(u'AdminWelcomeDlg', u'Next', u'[InstallMode]', u'Server Image', u'1', 1), -(u'ExitDialog', u'Finish', u'EndDialog', u'Return', u'1', None), -(u'FatalError', u'Finish', u'EndDialog', u'Exit', u'1', None), -(u'PrepareDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'ProgressDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'UserExit', u'Finish', u'EndDialog', u'Exit', u'1', None), -(u'AdminBrowseDlg', u'Up', u'DirectoryListUp', u'0', u'1', None), -(u'AdminBrowseDlg', u'Cancel', u'Reset', u'0', u'1', 1), -(u'AdminBrowseDlg', u'Cancel', u'EndDialog', u'Return', u'1', 2), -(u'AdminBrowseDlg', u'NewFolder', u'DirectoryListNew', u'0', u'1', None), -(u'AdminBrowseDlg', u'OK', u'EndDialog', u'Return', u'1', 2), -(u'AdminBrowseDlg', u'OK', u'SetTargetPath', u'TARGETDIR', u'1', 1), -(u'AdminInstallPointDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminInstallPointDlg', u'Back', u'NewDialog', u'AdminRegistrationDlg', u'1', None), -(u'AdminInstallPointDlg', u'Next', u'SetTargetPath', u'TARGETDIR', u'1', 1), -(u'AdminInstallPointDlg', u'Next', u'NewDialog', u'VerifyReadyDlg', u'1', 2), -(u'AdminInstallPointDlg', u'Browse', u'SpawnDialog', u'AdminBrowseDlg', u'1', None), -(u'AdminRegistrationDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminRegistrationDlg', u'Back', u'NewDialog', u'AdminWelcomeDlg', u'1', None), -(u'AdminRegistrationDlg', u'Next', u'NewDialog', u'AdminInstallPointDlg', u'ProductID', 2), -(u'AdminRegistrationDlg', u'Next', u'ValidateProductID', u'0', u'0', 1), -(u'BrowseDlg', u'Up', u'DirectoryListUp', u'0', u'1', None), -(u'BrowseDlg', u'Cancel', u'Reset', u'0', u'1', 1), -(u'BrowseDlg', u'Cancel', u'EndDialog', u'Return', u'1', 2), -(u'BrowseDlg', u'NewFolder', u'DirectoryListNew', u'0', u'1', None), -(u'BrowseDlg', u'OK', u'EndDialog', u'Return', u'1', 2), -(u'BrowseDlg', u'OK', u'SetTargetPath', u'[_BrowseProperty]', u'1', 1), -(u'CancelDlg', u'No', u'EndDialog', u'Return', u'1', None), -(u'CancelDlg', u'Yes', u'EndDialog', u'Exit', u'1', None), -(u'CustomizeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'CustomizeDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'InstallMode = "Change"', None), -(u'CustomizeDlg', u'Back', u'NewDialog', u'SetupTypeDlg', u'InstallMode = "Custom"', None), -(u'CustomizeDlg', u'Next', u'NewDialog', u'VerifyReadyDlg', u'1', None), -(u'CustomizeDlg', u'Browse', u'SelectionBrowse', u'BrowseDlg', u'1', None), -(u'CustomizeDlg', u'Reset', u'Reset', u'0', u'1', None), -(u'CustomizeDlg', u'DiskCost', u'SpawnDialog', u'DiskCostDlg', u'1', 2), -(u'DiskCostDlg', u'OK', u'EndDialog', u'Return', u'1', None), -(u'ErrorDlg', u'Y', u'EndDialog', u'ErrorYes', u'1', None), -(u'ErrorDlg', u'A', u'EndDialog', u'ErrorAbort', u'1', None), -(u'ErrorDlg', u'C', u'EndDialog', u'ErrorCancel', u'1', None), -(u'ErrorDlg', u'I', u'EndDialog', u'ErrorIgnore', u'1', None), -(u'ErrorDlg', u'N', u'EndDialog', u'ErrorNo', u'1', None), -(u'ErrorDlg', u'O', u'EndDialog', u'ErrorOk', u'1', None), -(u'ErrorDlg', u'R', u'EndDialog', u'ErrorRetry', u'1', None), -(u'FilesInUse', u'Retry', u'EndDialog', u'Retry', u'1', None), -(u'FilesInUse', u'Exit', u'EndDialog', u'Exit', u'1', None), -(u'FilesInUse', u'Ignore', u'EndDialog', u'Ignore', u'1', None), -(u'LicenseAgreementDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'LicenseAgreementDlg', u'Back', u'NewDialog', u'WelcomeDlg', u'1', None), -(u'LicenseAgreementDlg', u'Next', u'NewDialog', u'SetupTypeDlg', u'IAgree = "Yes" AND ShowUserRegistrationDlg <> 1', 3), -(u'LicenseAgreementDlg', u'Next', u'NewDialog', u'UserRegistrationDlg', u'IAgree = "Yes" AND ShowUserRegistrationDlg = 1', 1), -(u'LicenseAgreementDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 2), -(u'MaintenanceTypeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'MaintenanceTypeDlg', u'Back', u'NewDialog', u'MaintenanceWelcomeDlg', u'1', None), -(u'MaintenanceTypeDlg', u'ChangeButton', u'NewDialog', u'CustomizeDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[InstallMode]', u'Change', u'1', 1), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[Progress1]', u'Changing', u'1', 2), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[Progress2]', u'changes', u'1', 3), -(u'MaintenanceTypeDlg', u'RemoveButton', u'NewDialog', u'VerifyRemoveDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[InstallMode]', u'Remove', u'1', 1), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[Progress1]', u'Removing', u'1', 2), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[Progress2]', u'removes', u'1', 3), -(u'MaintenanceTypeDlg', u'RepairButton', u'NewDialog', u'VerifyRepairDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'RepairButton', u'[InstallMode]', u'Repair', u'1', 1), -(u'MaintenanceTypeDlg', u'RepairButton', u'[Progress1]', u'Repairing', u'1', 2), -(u'MaintenanceTypeDlg', u'RepairButton', u'[Progress2]', u'repairs', u'1', 3), -(u'MaintenanceWelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'MaintenanceWelcomeDlg', u'Next', u'NewDialog', u'MaintenanceTypeDlg', u'1', 2), -(u'MaintenanceWelcomeDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 1), -(u'OutOfDiskDlg', u'OK', u'EndDialog', u'Return', u'1', None), -(u'OutOfRbDiskDlg', u'No', u'EndDialog', u'Return', u'1', None), -(u'OutOfRbDiskDlg', u'Yes', u'EndDialog', u'Return', u'1', 2), -(u'OutOfRbDiskDlg', u'Yes', u'EnableRollback', u'False', u'1', 1), -(u'ResumeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'ResumeDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'ResumeDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 2), -(u'ResumeDlg', u'Install', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 6), -(u'ResumeDlg', u'Install', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 3), -(u'ResumeDlg', u'Install', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 1), -(u'ResumeDlg', u'Install', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'SetupTypeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'SetupTypeDlg', u'Back', u'NewDialog', u'LicenseAgreementDlg', u'ShowUserRegistrationDlg <> 1', None), -(u'SetupTypeDlg', u'Back', u'NewDialog', u'UserRegistrationDlg', u'ShowUserRegistrationDlg = 1', None), -(u'SetupTypeDlg', u'CompleteButton', u'NewDialog', u'VerifyReadyDlg', u'1', 3), -(u'SetupTypeDlg', u'CompleteButton', u'[InstallMode]', u'Complete', u'1', 1), -(u'SetupTypeDlg', u'CompleteButton', u'SetInstallLevel', u'1000', u'1', 2), -(u'SetupTypeDlg', u'CustomButton', u'NewDialog', u'CustomizeDlg', u'1', 2), -(u'SetupTypeDlg', u'CustomButton', u'[InstallMode]', u'Custom', u'1', 1), -(u'SetupTypeDlg', u'TypicalButton', u'NewDialog', u'VerifyReadyDlg', u'1', 3), -(u'SetupTypeDlg', u'TypicalButton', u'[InstallMode]', u'Typical', u'1', 1), -(u'SetupTypeDlg', u'TypicalButton', u'SetInstallLevel', u'3', u'1', 2), -(u'UserRegistrationDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'UserRegistrationDlg', u'Back', u'NewDialog', u'LicenseAgreementDlg', u'1', None), -(u'UserRegistrationDlg', u'Next', u'NewDialog', u'SetupTypeDlg', u'ProductID', 3), -(u'UserRegistrationDlg', u'Next', u'ValidateProductID', u'0', u'0', 1), -(u'UserRegistrationDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 2), -(u'VerifyReadyDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'AdminInstallPointDlg', u'InstallMode = "Server Image"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'CustomizeDlg', u'InstallMode = "Custom" OR InstallMode = "Change"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'InstallMode = "Repair"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'SetupTypeDlg', u'InstallMode = "Typical" OR InstallMode = "Complete"', None), -(u'VerifyReadyDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 3), -(u'VerifyReadyDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 1), -(u'VerifyReadyDlg', u'Install', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 5), -(u'VerifyReadyDlg', u'Install', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 2), -(u'VerifyReadyDlg', u'Install', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'VerifyRemoveDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyRemoveDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'1', None), -(u'VerifyRemoveDlg', u'Remove', u'Remove', u'All', u'OutOfDiskSpace <> 1', 1), -(u'VerifyRemoveDlg', u'Remove', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'VerifyRemoveDlg', u'Remove', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 2), -(u'VerifyRemoveDlg', u'Remove', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 6), -(u'VerifyRemoveDlg', u'Remove', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 3), -(u'VerifyRemoveDlg', u'Remove', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'VerifyRepairDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyRepairDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'1', None), -(u'VerifyRepairDlg', u'Repair', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'VerifyRepairDlg', u'Repair', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 3), -(u'VerifyRepairDlg', u'Repair', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 7), -(u'VerifyRepairDlg', u'Repair', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 4), -(u'VerifyRepairDlg', u'Repair', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 6), -(u'VerifyRepairDlg', u'Repair', u'Reinstall', u'All', u'OutOfDiskSpace <> 1', 2), -(u'VerifyRepairDlg', u'Repair', u'ReinstallMode', u'ecmus', u'OutOfDiskSpace <> 1', 1), -(u'WaitForCostingDlg', u'Return', u'EndDialog', u'Exit', u'1', None), -(u'WelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'WelcomeDlg', u'Next', u'NewDialog', u'LicenseAgreementDlg', u'1', None), -] - -Dialog = [ -(u'AdminWelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -(u'ExitDialog', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'FatalError', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'PrepareDlg', 50, 50, 370, 270, 1, u'[ProductName] [Setup]', u'Cancel', u'Cancel', u'Cancel'), -(u'ProgressDlg', 50, 50, 370, 270, 1, u'[ProductName] [Setup]', u'Cancel', u'Cancel', u'Cancel'), -(u'UserExit', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'AdminBrowseDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'PathEdit', u'OK', u'Cancel'), -(u'AdminInstallPointDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Text', u'Next', u'Cancel'), -(u'AdminRegistrationDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OrganizationLabel', u'Next', u'Cancel'), -(u'BrowseDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'PathEdit', u'OK', u'Cancel'), -(u'CancelDlg', 50, 10, 260, 85, 3, u'[ProductName] [Setup]', u'No', u'No', u'No'), -(u'CustomizeDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Tree', u'Next', u'Cancel'), -(u'DiskCostDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OK', u'OK', u'OK'), -(u'ErrorDlg', 50, 10, 270, 105, 65539, u'Installer Information', u'ErrorText', None, None), -(u'FilesInUse', 50, 50, 370, 270, 19, u'[ProductName] [Setup]', u'Retry', u'Retry', u'Retry'), -(u'LicenseAgreementDlg', 50, 50, 370, 270, 3, u'[ProductName] License Agreement', u'Buttons', u'Next', u'Cancel'), -(u'MaintenanceTypeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'ChangeLabel', u'ChangeButton', u'Cancel'), -(u'MaintenanceWelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -(u'OutOfDiskDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OK', u'OK', u'OK'), -(u'OutOfRbDiskDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'No', u'No', u'No'), -(u'ResumeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Install', u'Install', u'Cancel'), -(u'SetupTypeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'TypicalLabel', u'TypicalButton', u'Cancel'), -(u'UserRegistrationDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'NameLabel', u'Next', u'Cancel'), -(u'VerifyReadyDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Install', u'Install', u'Cancel'), -(u'VerifyRemoveDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Back', u'Back', u'Cancel'), -(u'VerifyRepairDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Repair', u'Repair', u'Cancel'), -(u'WaitForCostingDlg', 50, 10, 260, 85, 3, u'[ProductName] [Setup]', u'Return', u'Return', u'Return'), -(u'WelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -] - -EventMapping = [ -(u'PrepareDlg', u'ActionData', u'ActionData', u'Text'), -(u'PrepareDlg', u'ActionText', u'ActionText', u'Text'), -(u'ProgressDlg', u'ActionText', u'ActionText', u'Text'), -(u'ProgressDlg', u'ProgressBar', u'SetProgress', u'Progress'), -(u'AdminBrowseDlg', u'DirectoryCombo', u'IgnoreChange', u'IgnoreChange'), -(u'BrowseDlg', u'DirectoryCombo', u'IgnoreChange', u'IgnoreChange'), -(u'CustomizeDlg', u'Next', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'Reset', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'DiskCost', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'ItemDescription', u'SelectionDescription', u'Text'), -(u'CustomizeDlg', u'ItemSize', u'SelectionSize', u'Text'), -(u'CustomizeDlg', u'Location', u'SelectionPath', u'Text'), -(u'CustomizeDlg', u'Location', u'SelectionPathOn', u'Visible'), -(u'CustomizeDlg', u'LocationLabel', u'SelectionPathOn', u'Visible'), -] - -InstallExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'InstallFiles', None, 4000), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'CreateShortcuts', None, 4500), -(u'PublishComponents', None, 6200), -(u'PublishFeatures', None, 6300), -(u'PublishProduct', None, 6400), -(u'RegisterClassInfo', None, 4600), -(u'RegisterExtensionInfo', None, 4700), -(u'RegisterMIMEInfo', None, 4900), -(u'RegisterProgIdInfo', None, 4800), -(u'ValidateProductID', None, 700), -(u'AllocateRegistrySpace', u'NOT Installed', 1550), -(u'AppSearch', None, 400), -(u'BindImage', None, 4300), -(u'CCPSearch', u'NOT Installed', 500), -(u'CreateFolders', None, 3700), -(u'DeleteServices', u'VersionNT', 2000), -(u'DuplicateFiles', None, 4210), -(u'FindRelatedProducts', None, 200), -(u'InstallODBC', None, 5400), -(u'InstallServices', u'VersionNT', 5800), -(u'LaunchConditions', None, 100), -(u'MigrateFeatureStates', None, 1200), -(u'MoveFiles', None, 3800), -(u'PatchFiles', None, 4090), -(u'ProcessComponents', None, 1600), -(u'RegisterComPlus', None, 5700), -(u'RegisterFonts', None, 5300), -(u'RegisterProduct', None, 6100), -(u'RegisterTypeLibraries', None, 5500), -(u'RegisterUser', None, 6000), -(u'RemoveDuplicateFiles', None, 3400), -(u'RemoveEnvironmentStrings', None, 3300), -(u'RemoveExistingProducts', None, 6700), -(u'RemoveFiles', None, 3500), -(u'RemoveFolders', None, 3600), -(u'RemoveIniValues', None, 3100), -(u'RemoveODBC', None, 2400), -(u'RemoveRegistryValues', None, 2600), -(u'RemoveShortcuts', None, 3200), -(u'RMCCPSearch', u'NOT Installed', 600), -(u'SelfRegModules', None, 5600), -(u'SelfUnregModules', None, 2200), -(u'SetODBCFolders', None, 1100), -(u'StartServices', u'VersionNT', 5900), -(u'StopServices', u'VersionNT', 1900), -(u'UnpublishComponents', None, 1700), -(u'UnpublishFeatures', None, 1800), -(u'UnregisterClassInfo', None, 2700), -(u'UnregisterComPlus', None, 2100), -(u'UnregisterExtensionInfo', None, 2800), -(u'UnregisterFonts', None, 2500), -(u'UnregisterMIMEInfo', None, 3000), -(u'UnregisterProgIdInfo', None, 2900), -(u'UnregisterTypeLibraries', None, 2300), -(u'WriteEnvironmentStrings', None, 5200), -(u'WriteIniValues', None, 5100), -(u'WriteRegistryValues', None, 5000), -] - -InstallUISequence = [ -#(u'FileCost', None, 900), -#(u'CostInitialize', None, 800), -#(u'CostFinalize', None, 1000), -#(u'ExecuteAction', None, 1300), -#(u'ExitDialog', None, -1), -#(u'FatalError', None, -3), -(u'PrepareDlg', None, 140), -(u'ProgressDlg', None, 1280), -#(u'UserExit', None, -2), -(u'MaintenanceWelcomeDlg', u'Installed AND NOT RESUME AND NOT Preselected', 1250), -(u'ResumeDlg', u'Installed AND (RESUME OR Preselected)', 1240), -(u'WelcomeDlg', u'NOT Installed', 1230), -#(u'AppSearch', None, 400), -#(u'CCPSearch', u'NOT Installed', 500), -#(u'FindRelatedProducts', None, 200), -#(u'LaunchConditions', None, 100), -#(u'MigrateFeatureStates', None, 1200), -#(u'RMCCPSearch', u'NOT Installed', 600), -] - -ListView = [ -] - -RadioButton = [ -(u'IAgree', 1, u'Yes', 5, 0, 250, 15, u'{\\DlgFont8}I &accept the terms in the License Agreement', None), -(u'IAgree', 2, u'No', 5, 20, 250, 15, u'{\\DlgFont8}I &do not accept the terms in the License Agreement', None), -] - -TextStyle = [ -(u'DlgFont8', u'Tahoma', 8, None, 0), -(u'DlgFontBold8', u'Tahoma', 8, None, 1), -(u'VerdanaBold13', u'Verdana', 13, None, 1), -] - UIText = [ (u'AbsentPath', None), (u'bytes', u'bytes'), @@ -808,592 +126,4 @@ (u'VolumeCostVolume', u'Volume'), ] -_Validation = [ -(u'AdminExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdminExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdminExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AdminUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdminUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdminUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'Condition', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Expression evaluated to determine if Level in the Feature table is to change.'), -(u'Condition', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Reference to a Feature entry in Feature table.'), -(u'Condition', u'Level', u'N', 0, 32767, None, None, None, None, u'New selection Level to set in Feature table if Condition evaluates to TRUE.'), -(u'AdvtExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdvtExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdvtExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'BBControl', u'Type', u'N', None, None, None, None, u'Identifier', None, u'The type of the control.'), -(u'BBControl', u'BBControl', u'N', None, None, None, None, u'Identifier', None, u'Name of the control. This name must be unique within a billboard, but can repeat on different billboard.'), -(u'BBControl', u'Billboard_', u'N', None, None, u'Billboard', 1, u'Identifier', None, u'External key to the Billboard table, name of the billboard.'), -(u'BBControl', u'X', u'N', 0, 32767, None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'BBControl', u'Y', u'N', 0, 32767, None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'BBControl', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the control.'), -(u'BBControl', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the control.'), -(u'BBControl', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.'), -(u'BBControl', u'Text', u'Y', None, None, None, None, u'Text', None, u'A string used to set the initial text contained within a control (if appropriate).'), -(u'Billboard', u'Action', u'Y', None, None, None, None, u'Identifier', None, u'The name of an action. The billboard is displayed during the progress messages received from this action.'), -(u'Billboard', u'Billboard', u'N', None, None, None, None, u'Identifier', None, u'Name of the billboard.'), -(u'Billboard', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'An external key to the Feature Table. The billboard is shown only if this feature is being installed.'), -(u'Billboard', u'Ordering', u'Y', 0, 32767, None, None, None, None, u'A positive integer. If there is more than one billboard corresponding to an action they will be shown in the order defined by this column.'), -(u'Binary', u'Name', u'N', None, None, None, None, u'Identifier', None, u'Unique key identifying the binary data.'), -(u'Binary', u'Data', u'N', None, None, None, None, u'Binary', None, u'The unformatted binary data.'), -(u'CheckBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to the item.'), -(u'CheckBox', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value string associated with the item.'), -(u'Property', u'Property', u'N', None, None, None, None, u'Identifier', None, u'Name of property, uppercase if settable by launcher or loader.'), -(u'Property', u'Value', u'N', None, None, None, None, u'Text', None, u'String value for property. Never null or empty.'), -(u'ComboBox', u'Text', u'Y', None, None, None, None, u'Formatted', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ComboBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same combobox.'), -(u'ComboBox', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ComboBox', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list.\tThe integers do not have to be consecutive.'), -(u'Control', u'Type', u'N', None, None, None, None, u'Identifier', None, u'The type of the control.'), -(u'Control', u'X', u'N', 0, 32767, None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'Control', u'Y', u'N', 0, 32767, None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'Control', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the control.'), -(u'Control', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the control.'), -(u'Control', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.'), -(u'Control', u'Text', u'Y', None, None, None, None, u'Formatted', None, u'A string used to set the initial text contained within a control (if appropriate).'), -(u'Control', u'Property', u'Y', None, None, None, None, u'Identifier', None, u'The name of a defined property to be linked to this control. '), -(u'Control', u'Control', u'N', None, None, None, None, u'Identifier', None, u'Name of the control. This name must be unique within a dialog, but can repeat on different dialogs. '), -(u'Control', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'External key to the Dialog table, name of the dialog.'), -(u'Control', u'Control_Next', u'Y', None, None, u'Control', 2, u'Identifier', None, u'The name of an other control on the same dialog. This link defines the tab order of the controls. The links have to form one or more cycles!'), -(u'Control', u'Help', u'Y', None, None, None, None, u'Text', None, u'The help strings used with the button. The text is optional. '), -(u'Icon', u'Name', u'N', None, None, None, None, u'Identifier', None, u'Primary key. Name of the icon file.'), -(u'Icon', u'Data', u'N', None, None, None, None, u'Binary', None, u'Binary stream. The binary icon data in PE (.DLL or .EXE) or icon (.ICO) format.'), -(u'ListBox', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ListBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listbox.'), -(u'ListBox', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ListBox', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'ActionText', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to be described.'), -(u'ActionText', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description displayed in progress dialog and log when action is executing.'), -(u'ActionText', u'Template', u'Y', None, None, None, None, u'Template', None, u'Optional localized format template used to format action data records for display during action execution.'), -(u'ControlCondition', u'Action', u'N', None, None, None, None, None, u'Default;Disable;Enable;Hide;Show', u'The desired action to be taken on the specified control.'), -(u'ControlCondition', u'Condition', u'N', None, None, None, None, u'Condition', None, u'A standard conditional statement that specifies under which conditions the action should be triggered.'), -(u'ControlCondition', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the dialog.'), -(u'ControlCondition', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control.'), -(u'ControlEvent', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'A standard conditional statement that specifies under which conditions an event should be triggered.'), -(u'ControlEvent', u'Ordering', u'Y', 0, 2147483647, None, None, None, None, u'An integer used to order several events tied to the same control. Can be left blank.'), -(u'ControlEvent', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the dialog.'), -(u'ControlEvent', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control'), -(u'ControlEvent', u'Event', u'N', None, None, None, None, u'Formatted', None, u'An identifier that specifies the type of the event that should take place when the user interacts with control specified by the first two entries.'), -(u'ControlEvent', u'Argument', u'N', None, None, None, None, u'Formatted', None, u'A value to be used as a modifier when triggering a particular event.'), -(u'Dialog', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the dialog.'), -(u'Dialog', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the dialog.'), -(u'Dialog', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this dialog.'), -(u'Dialog', u'Title', u'Y', None, None, None, None, u'Formatted', None, u"A text string specifying the title to be displayed in the title bar of the dialog's window."), -(u'Dialog', u'Dialog', u'N', None, None, None, None, u'Identifier', None, u'Name of the dialog.'), -(u'Dialog', u'HCentering', u'N', 0, 100, None, None, None, None, u'Horizontal position of the dialog on a 0-100 scale. 0 means left end, 100 means right end of the screen, 50 center.'), -(u'Dialog', u'VCentering', u'N', 0, 100, None, None, None, None, u'Vertical position of the dialog on a 0-100 scale. 0 means top end, 100 means bottom end of the screen, 50 center.'), -(u'Dialog', u'Control_First', u'N', None, None, u'Control', 2, u'Identifier', None, u'Defines the control that has the focus when the dialog is created.'), -(u'Dialog', u'Control_Default', u'Y', None, None, u'Control', 2, u'Identifier', None, u'Defines the default control. Hitting return is equivalent to pushing this button.'), -(u'Dialog', u'Control_Cancel', u'Y', None, None, u'Control', 2, u'Identifier', None, u'Defines the cancel control. Hitting escape or clicking on the close icon on the dialog is equivalent to pushing this button.'), -(u'EventMapping', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the Dialog.'), -(u'EventMapping', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control.'), -(u'EventMapping', u'Event', u'N', None, None, None, None, u'Identifier', None, u'An identifier that specifies the type of the event that the control subscribes to.'), -(u'EventMapping', u'Attribute', u'N', None, None, None, None, u'Identifier', None, u'The name of the control attribute, that is set when this event is received.'), -(u'InstallExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'InstallExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'InstallExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AppSearch', u'Property', u'N', None, None, None, None, u'Identifier', None, u'The property associated with a Signature'), -(u'AppSearch', u'Signature_', u'N', None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator', 1, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.'), -(u'BindImage', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'The index into the File table. This must be an executable file.'), -(u'BindImage', u'Path', u'Y', None, None, None, None, u'Paths', None, u'A list of ; delimited paths that represent the paths to be searched for the import DLLS. The list is usually a list of properties each enclosed within square brackets [] .'), -(u'CCPSearch', u'Signature_', u'N', None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator', 1, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.'), -(u'InstallUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'InstallUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'InstallUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'ListView', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ListView', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listview.'), -(u'ListView', u'Value', u'N', None, None, None, None, u'Identifier', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ListView', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'ListView', u'Binary_', u'Y', None, None, u'Binary', 1, u'Identifier', None, u'The name of the icon to be displayed with the icon. The binary information is looked up from the Binary Table.'), -(u'RadioButton', u'X', u'N', 0, 32767, None, None, None, None, u'The horizontal coordinate of the upper left corner of the bounding rectangle of the radio button.'), -(u'RadioButton', u'Y', u'N', 0, 32767, None, None, None, None, u'The vertical coordinate of the upper left corner of the bounding rectangle of the radio button.'), -(u'RadioButton', u'Width', u'N', 0, 32767, None, None, None, None, u'The width of the button.'), -(u'RadioButton', u'Height', u'N', 0, 32767, None, None, None, None, u'The height of the button.'), -(u'RadioButton', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible title to be assigned to the radio button.'), -(u'RadioButton', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this radio button. All the buttons tied to the same property become part of the same group.'), -(u'RadioButton', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this button. Selecting the button will set the associated property to this value.'), -(u'RadioButton', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'RadioButton', u'Help', u'Y', None, None, None, None, u'Text', None, u'The help strings used with the button. The text is optional.'), -(u'TextStyle', u'TextStyle', u'N', None, None, None, None, u'Identifier', None, u'Name of the style. The primary key of this table. This name is embedded in the texts to indicate a style change.'), -(u'TextStyle', u'FaceName', u'N', None, None, None, None, u'Text', None, u'A string indicating the name of the font used. Required. The string must be at most 31 characters long.'), -(u'TextStyle', u'Size', u'N', 0, 32767, None, None, None, None, u'The size of the font used. This size is given in our units (1/12 of the system font height). Assuming that the system font is set to 12 point size, this is equivalent to the point size.'), -(u'TextStyle', u'Color', u'Y', 0, 16777215, None, None, None, None, u'A long integer indicating the color of the string in the RGB format (Red, Green, Blue each 0-255, RGB = R + 256*G + 256^2*B).'), -(u'TextStyle', u'StyleBits', u'Y', 0, 15, None, None, None, None, u'A combination of style bits.'), -(u'UIText', u'Text', u'Y', None, None, None, None, u'Text', None, u'The localized version of the string.'), -(u'UIText', u'Key', u'N', None, None, None, None, u'Identifier', None, u'A unique key that identifies the particular string.'), -(u'_Validation', u'Table', u'N', None, None, None, None, u'Identifier', None, u'Name of table'), -(u'_Validation', u'Description', u'Y', None, None, None, None, u'Text', None, u'Description of column'), -(u'_Validation', u'Column', u'N', None, None, None, None, u'Identifier', None, u'Name of column'), -(u'_Validation', u'Nullable', u'N', None, None, None, None, None, u'Y;N;@', u'Whether the column is nullable'), -(u'_Validation', u'MinValue', u'Y', -2147483647, 2147483647, None, None, None, None, u'Minimum value allowed'), -(u'_Validation', u'MaxValue', u'Y', -2147483647, 2147483647, None, None, None, None, u'Maximum value allowed'), -(u'_Validation', u'KeyTable', u'Y', None, None, None, None, u'Identifier', None, u'For foreign key, Name of table to which data must link'), -(u'_Validation', u'KeyColumn', u'Y', 1, 32, None, None, None, None, u'Column to which foreign key connects'), -(u'_Validation', u'Category', u'Y', None, None, None, None, None, u'Text;Formatted;Template;Condition;Guid;Path;Version;Language;Identifier;Binary;UpperCase;LowerCase;Filename;Paths;AnyPath;WildCardFilename;RegPath;KeyFormatted;CustomSource;Property;Cabinet;Shortcut;URL', u'String category'), -(u'_Validation', u'Set', u'Y', None, None, None, None, u'Text', None, u'Set of values that are permitted'), -(u'AdvtUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdvtUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdvtUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AppId', u'AppId', u'N', None, None, None, None, u'Guid', None, None), -(u'AppId', u'ActivateAtStorage', u'Y', 0, 1, None, None, None, None, None), -(u'AppId', u'DllSurrogate', u'Y', None, None, None, None, u'Text', None, None), -(u'AppId', u'LocalService', u'Y', None, None, None, None, u'Text', None, None), -(u'AppId', u'RemoteServerName', u'Y', None, None, None, None, u'Formatted', None, None), -(u'AppId', u'RunAsInteractiveUser', u'Y', 0, 1, None, None, None, None, None), -(u'AppId', u'ServiceParameters', u'Y', None, None, None, None, u'Text', None, None), -(u'Feature', u'Attributes', u'N', None, None, None, None, None, u'0;1;2;4;5;6;8;9;10;16;17;18;20;21;22;24;25;26;32;33;34;36;37;38;48;49;50;52;53;54', u'Feature attributes'), -(u'Feature', u'Description', u'Y', None, None, None, None, u'Text', None, u'Longer descriptive text describing a visible feature item.'), -(u'Feature', u'Title', u'Y', None, None, None, None, u'Text', None, u'Short text identifying a visible feature item.'), -(u'Feature', u'Feature', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular feature record.'), -(u'Feature', u'Directory_', u'Y', None, None, u'Directory', 1, u'UpperCase', None, u'The name of the Directory that can be configured by the UI. A non-null value will enable the browse button.'), -(u'Feature', u'Level', u'N', 0, 32767, None, None, None, None, u'The install level at which record will be initially selected. An install level of 0 will disable an item and prevent its display.'), -(u'Feature', u'Display', u'Y', 0, 32767, None, None, None, None, u'Numeric sort order, used to force a specific display ordering.'), -(u'Feature', u'Feature_Parent', u'Y', None, None, u'Feature', 1, u'Identifier', None, u'Optional key of a parent record in the same table. If the parent is not selected, then the record will not be installed. Null indicates a root item.'), -(u'File', u'Sequence', u'N', 1, 32767, None, None, None, None, u'Sequence with respect to the media images; order must track cabinet order.'), -(u'File', u'Attributes', u'Y', 0, 32767, None, None, None, None, u'Integer containing bit flags representing file attributes (with the decimal value of each bit position in parentheses)'), -(u'File', u'File', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token, must match identifier in cabinet. For uncompressed files, this field is ignored.'), -(u'File', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the file.'), -(u'File', u'FileName', u'N', None, None, None, None, u'Filename', None, u'File name used for installation, may be localized. This may contain a "short name|long name" pair.'), -(u'File', u'FileSize', u'N', 0, 2147483647, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'File', u'Language', u'Y', None, None, None, None, u'Language', None, u'List of decimal language Ids, comma-separated if more than one.'), -(u'File', u'Version', u'Y', None, None, u'File', 1, u'Version', None, u'Version string for versioned files; Blank for unversioned files.'), -(u'Class', u'Attributes', u'Y', None, 32767, None, None, None, None, u'Class registration attributes.'), -(u'Class', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.'), -(u'Class', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description for the Class.'), -(u'Class', u'Argument', u'Y', None, None, None, None, u'Formatted', None, u'optional argument for LocalServers.'), -(u'Class', u'AppId_', u'Y', None, None, u'AppId', 1, u'Guid', None, u'Optional AppID containing DCOM information for associated application (string GUID).'), -(u'Class', u'CLSID', u'N', None, None, None, None, u'Guid', None, u'The CLSID of an OLE factory.'), -(u'Class', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'Class', u'Context', u'N', None, None, None, None, u'Identifier', None, u'The numeric server context for this server. CLSCTX_xxxx'), -(u'Class', u'DefInprocHandler', u'Y', None, None, None, None, u'Filename', u'1;2;3', u'Optional default inproc handler. Only optionally provided if Context=CLSCTX_LOCAL_SERVER. Typically "ole32.dll" or "mapi32.dll"'), -(u'Class', u'FileTypeMask', u'Y', None, None, None, None, u'Text', None, u'Optional string containing information for the HKCRthis CLSID) key. If multiple patterns exist, they must be delimited by a semicolon, and numeric subkeys will be generated: 0,1,2...'), -(u'Class', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this CLSID. Will be written under the DefaultIcon key.'), -(u'Class', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'Optional icon index.'), -(u'Class', u'ProgId_Default', u'Y', None, None, u'ProgId', 1, u'Text', None, u'Optional ProgId associated with this CLSID.'), -(u'Component', u'Condition', u'Y', None, None, None, None, u'Condition', None, u"A conditional statement that will disable this component if the specified condition evaluates to the 'True' state. If a component is disabled, it will not be installed, regardless of the 'Action' state associated with the component."), -(u'Component', u'Attributes', u'N', None, None, None, None, None, None, u'Remote execution option, one of irsEnum'), -(u'Component', u'Component', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular component record.'), -(u'Component', u'ComponentId', u'Y', None, None, None, None, u'Guid', None, u'A string GUID unique to this component, version, and language.'), -(u'Component', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Required key of a Directory table record. This is actually a property name whose value contains the actual path, set either by the AppSearch action or with the default setting obtained from the Directory table.'), -(u'Component', u'KeyPath', u'Y', None, None, u'File;Registry;ODBCDataSource', 1, u'Identifier', None, u'Either the primary key into the File table, Registry table, or ODBCDataSource table. This extract path is stored when the component is installed, and is used to detect the presence of the component and to return the path to it.'), -(u'ProgId', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description for the Program identifier.'), -(u'ProgId', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this ProgId. Will be written under the DefaultIcon key.'), -(u'ProgId', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'Optional icon index.'), -(u'ProgId', u'ProgId', u'N', None, None, None, None, u'Text', None, u'The Program Identifier. Primary key.'), -(u'ProgId', u'Class_', u'Y', None, None, u'Class', 1, u'Guid', None, u'The CLSID of an OLE factory corresponding to the ProgId.'), -(u'ProgId', u'ProgId_Parent', u'Y', None, None, u'ProgId', 1, u'Text', None, u'The Parent Program Identifier. If specified, the ProgId column becomes a version independent prog id.'), -(u'CompLocator', u'Type', u'Y', 0, 1, None, None, None, None, u'A boolean value that determines if the registry value is a filename or a directory location.'), -(u'CompLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'CompLocator', u'ComponentId', u'N', None, None, None, None, u'Guid', None, u'A string GUID unique to this component, version, and language.'), -(u'Complus', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the ComPlus component.'), -(u'Complus', u'ExpType', u'Y', 0, 32767, None, None, None, None, u'ComPlus component attributes.'), -(u'Directory', u'Directory', u'N', None, None, None, None, u'Identifier', None, u'Unique identifier for directory entry, primary key. If a property by this name is defined, it contains the full path to the directory.'), -(u'Directory', u'DefaultDir', u'N', None, None, None, None, u'DefaultDir', None, u"The default sub-path under parent's path."), -(u'Directory', u'Directory_Parent', u'Y', None, None, u'Directory', 1, u'Identifier', None, u'Reference to the entry in this table specifying the default parent directory. A record parented to itself or with a Null parent represents a root of the install tree.'), -(u'CreateFolder', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table.'), -(u'CreateFolder', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Primary key, could be foreign key into the Directory table.'), -(u'CustomAction', u'Type', u'N', 1, 16383, None, None, None, None, u'The numeric custom action type, consisting of source location, code type, entry, option flags.'), -(u'CustomAction', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Primary key, name of action, normally appears in sequence table unless private use.'), -(u'CustomAction', u'Source', u'Y', None, None, None, None, u'CustomSource', None, u'The table reference of the source of the code.'), -(u'CustomAction', u'Target', u'Y', None, None, None, None, u'Formatted', None, u'Excecution parameter, depends on the type of custom action'), -(u'DrLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'DrLocator', u'Path', u'Y', None, None, None, None, u'AnyPath', None, u'The path on the user system. This is a either a subpath below the value of the Parent or a full path. The path may contain properties enclosed within [ ] that will be expanded.'), -(u'DrLocator', u'Depth', u'Y', 0, 32767, None, None, None, None, u'The depth below the path to which the Signature_ is recursively searched. If absent, the depth is assumed to be 0.'), -(u'DrLocator', u'Parent', u'Y', None, None, None, None, u'Identifier', None, u'The parent file signature. It is also a foreign key in the Signature table. If null and the Path column does not expand to a full path, then all the fixed drives of the user system are searched using the Path.'), -(u'DuplicateFile', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Foreign key referencing the source file to be duplicated.'), -(u'DuplicateFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the duplicate file.'), -(u'DuplicateFile', u'DestFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full pathname to a destination folder.'), -(u'DuplicateFile', u'DestName', u'Y', None, None, None, None, u'Filename', None, u'Filename to be given to the duplicate file.'), -(u'DuplicateFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular file entry'), -(u'Environment', u'Name', u'N', None, None, None, None, u'Text', None, u'The name of the environmental value.'), -(u'Environment', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value to set in the environmental settings.'), -(u'Environment', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the environmental value.'), -(u'Environment', u'Environment', u'N', None, None, None, None, u'Identifier', None, u'Unique identifier for the environmental variable setting'), -(u'Error', u'Error', u'N', 0, 32767, None, None, None, None, u'Integer error number, obtained from header file IError(...) macros.'), -(u'Error', u'Message', u'Y', None, None, None, None, u'Template', None, u'Error formatting template, obtained from user ed. or localizers.'), -(u'Extension', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.'), -(u'Extension', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'Extension', u'Extension', u'N', None, None, None, None, u'Text', None, u'The extension associated with the table row.'), -(u'Extension', u'MIME_', u'Y', None, None, u'MIME', 1, u'Text', None, u'Optional Context identifier, typically "type/format" associated with the extension'), -(u'Extension', u'ProgId_', u'Y', None, None, u'ProgId', 1, u'Text', None, u'Optional ProgId associated with this extension.'), -(u'MIME', u'CLSID', u'Y', None, None, None, None, u'Guid', None, u'Optional associated CLSID.'), -(u'MIME', u'ContentType', u'N', None, None, None, None, u'Text', None, u'Primary key. Context identifier, typically "type/format".'), -(u'MIME', u'Extension_', u'N', None, None, u'Extension', 1, u'Text', None, u'Optional associated extension (without dot)'), -(u'FeatureComponents', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into Feature table.'), -(u'FeatureComponents', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'FileSFPCatalog', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'File associated with the catalog'), -(u'FileSFPCatalog', u'SFPCatalog_', u'N', None, None, u'SFPCatalog', 1, u'Filename', None, u'Catalog associated with the file'), -(u'SFPCatalog', u'SFPCatalog', u'N', None, None, None, None, u'Filename', None, u'File name for the catalog.'), -(u'SFPCatalog', u'Catalog', u'N', None, None, None, None, u'Binary', None, u'SFP Catalog'), -(u'SFPCatalog', u'Dependency', u'Y', None, None, None, None, u'Formatted', None, u'Parent catalog - only used by SFP'), -(u'Font', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Primary key, foreign key into File table referencing font file.'), -(u'Font', u'FontTitle', u'Y', None, None, None, None, u'Text', None, u'Font name.'), -(u'IniFile', u'Action', u'N', None, None, None, None, None, u'0;1;3', u'The type of modification to be made, one of iifEnum'), -(u'IniFile', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value to be written.'), -(u'IniFile', u'Key', u'N', None, None, None, None, u'Formatted', None, u'The .INI file key below Section.'), -(u'IniFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the .INI value.'), -(u'IniFile', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name in which to write the information'), -(u'IniFile', u'IniFile', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'IniFile', u'DirProperty', u'Y', None, None, None, None, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the .INI file is.'), -(u'IniFile', u'Section', u'N', None, None, None, None, u'Formatted', None, u'The .INI file Section.'), -(u'IniLocator', u'Type', u'Y', 0, 2, None, None, None, None, u'An integer value that determines if the .INI value read is a filename or a directory location or to be used as is w/o interpretation.'), -(u'IniLocator', u'Key', u'N', None, None, None, None, u'Text', None, u'Key value (followed by an equals sign in INI file).'), -(u'IniLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'IniLocator', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name.'), -(u'IniLocator', u'Section', u'N', None, None, None, None, u'Text', None, u'Section name within in file (within square brackets in INI file).'), -(u'IniLocator', u'Field', u'Y', 0, 32767, None, None, None, None, u'The field in the .INI line. If Field is null or 0 the entire line is read.'), -(u'IsolatedComponent', u'Component_Application', u'N', None, None, u'Component', 1, u'Identifier', None, u'Key to Component table item for application'), -(u'IsolatedComponent', u'Component_Shared', u'N', None, None, u'Component', 1, u'Identifier', None, u'Key to Component table item to be isolated'), -(u'LaunchCondition', u'Condition', u'N', None, None, None, None, u'Condition', None, u'Expression which must evaluate to TRUE in order for install to commence.'), -(u'LaunchCondition', u'Description', u'N', None, None, None, None, u'Formatted', None, u'Localizable text to display when condition fails and install must abort.'), -(u'LockPermissions', u'Table', u'N', None, None, None, None, u'Identifier', u'Directory;File;Registry', u'Reference to another table name'), -(u'LockPermissions', u'Domain', u'Y', None, None, None, None, u'Formatted', None, u'Domain name for user whose permissions are being set. (usually a property)'), -(u'LockPermissions', u'LockObject', u'N', None, None, None, None, u'Identifier', None, u'Foreign key into Registry or File table'), -(u'LockPermissions', u'Permission', u'Y', -2147483647, 2147483647, None, None, None, None, u'Permission Access mask. Full Control = 268435456 (GENERIC_ALL = 0x10000000)'), -(u'LockPermissions', u'User', u'N', None, None, None, None, u'Formatted', None, u'User for permissions to be set. (usually a property)'), -(u'Media', u'Source', u'Y', None, None, None, None, u'Property', None, u'The property defining the location of the cabinet file.'), -(u'Media', u'Cabinet', u'Y', None, None, None, None, u'Cabinet', None, u'If some or all of the files stored on the media are compressed in a cabinet, the name of that cabinet.'), -(u'Media', u'DiskId', u'N', 1, 32767, None, None, None, None, u'Primary key, integer to determine sort order for table.'), -(u'Media', u'DiskPrompt', u'Y', None, None, None, None, u'Text', None, u'Disk name: the visible text actually printed on the disk. This will be used to prompt the user when this disk needs to be inserted.'), -(u'Media', u'LastSequence', u'N', 0, 32767, None, None, None, None, u'File sequence number for the last file for this media.'), -(u'Media', u'VolumeLabel', u'Y', None, None, None, None, u'Text', None, u'The label attributed to the volume.'), -(u'ModuleComponents', u'Component', u'N', None, None, u'Component', 1, u'Identifier', None, u'Component contained in the module.'), -(u'ModuleComponents', u'Language', u'N', None, None, u'ModuleSignature', 2, None, None, u'Default language ID for module (may be changed by transform).'), -(u'ModuleComponents', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'Module containing the component.'), -(u'ModuleSignature', u'Language', u'N', None, None, None, None, None, None, u'Default decimal language of module.'), -(u'ModuleSignature', u'Version', u'N', None, None, None, None, u'Version', None, u'Version of the module.'), -(u'ModuleSignature', u'ModuleID', u'N', None, None, None, None, u'Identifier', None, u'Module identifier (String.GUID).'), -(u'ModuleDependency', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'Module requiring the dependency.'), -(u'ModuleDependency', u'ModuleLanguage', u'N', None, None, u'ModuleSignature', 2, None, None, u'Language of module requiring the dependency.'), -(u'ModuleDependency', u'RequiredID', u'N', None, None, None, None, None, None, u'String.GUID of required module.'), -(u'ModuleDependency', u'RequiredLanguage', u'N', None, None, None, None, None, None, u'LanguageID of the required module.'), -(u'ModuleDependency', u'RequiredVersion', u'Y', None, None, None, None, u'Version', None, u'Version of the required version.'), -(u'ModuleExclusion', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'String.GUID of module with exclusion requirement.'), -(u'ModuleExclusion', u'ModuleLanguage', u'N', None, None, u'ModuleSignature', 2, None, None, u'LanguageID of module with exclusion requirement.'), -(u'ModuleExclusion', u'ExcludedID', u'N', None, None, None, None, None, None, u'String.GUID of excluded module.'), -(u'ModuleExclusion', u'ExcludedLanguage', u'N', None, None, None, None, None, None, u'Language of excluded module.'), -(u'ModuleExclusion', u'ExcludedMaxVersion', u'Y', None, None, None, None, u'Version', None, u'Maximum version of excluded module.'), -(u'ModuleExclusion', u'ExcludedMinVersion', u'Y', None, None, None, None, u'Version', None, u'Minimum version of excluded module.'), -(u'MoveFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'If this component is not "selected" for installation or removal, no action will be taken on the associated MoveFile entry'), -(u'MoveFile', u'DestFolder', u'N', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory'), -(u'MoveFile', u'DestName', u'Y', None, None, None, None, u'Filename', None, u'Name to be given to the original file after it is moved or copied. If blank, the destination file will be given the same name as the source file'), -(u'MoveFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key that uniquely identifies a particular MoveFile record'), -(u'MoveFile', u'Options', u'N', 0, 1, None, None, None, None, u'Integer value specifying the MoveFile operating mode, one of imfoEnum'), -(u'MoveFile', u'SourceFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the source directory'), -(u'MoveFile', u'SourceName', u'Y', None, None, None, None, u'Text', None, u"Name of the source file(s) to be moved or copied. Can contain the '*' or '?' wildcards."), -(u'MsiAssembly', u'Attributes', u'Y', None, None, None, None, None, None, u'Assembly attributes'), -(u'MsiAssembly', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into Feature table.'), -(u'MsiAssembly', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'MsiAssembly', u'File_Application', u'Y', None, None, u'File', 1, u'Identifier', None, u'Foreign key into File table, denoting the application context for private assemblies. Null for global assemblies.'), -(u'MsiAssembly', u'File_Manifest', u'Y', None, None, u'File', 1, u'Identifier', None, u'Foreign key into the File table denoting the manifest file for the assembly.'), -(u'MsiAssemblyName', u'Name', u'N', None, None, None, None, u'Text', None, u'The name part of the name-value pairs for the assembly name.'), -(u'MsiAssemblyName', u'Value', u'N', None, None, None, None, u'Text', None, u'The value part of the name-value pairs for the assembly name.'), -(u'MsiAssemblyName', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'MsiDigitalCertificate', u'CertData', u'N', None, None, None, None, u'Binary', None, u'A certificate context blob for a signer certificate'), -(u'MsiDigitalCertificate', u'DigitalCertificate', u'N', None, None, None, None, u'Identifier', None, u'A unique identifier for the row'), -(u'MsiDigitalSignature', u'Table', u'N', None, None, None, None, None, u'Media', u'Reference to another table name (only Media table is supported)'), -(u'MsiDigitalSignature', u'DigitalCertificate_', u'N', None, None, u'MsiDigitalCertificate', 1, u'Identifier', None, u'Foreign key to MsiDigitalCertificate table identifying the signer certificate'), -(u'MsiDigitalSignature', u'Hash', u'Y', None, None, None, None, u'Binary', None, u'The encoded hash blob from the digital signature'), -(u'MsiDigitalSignature', u'SignObject', u'N', None, None, None, None, u'Text', None, u'Foreign key to Media table'), -(u'MsiFileHash', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Primary key, foreign key into File table referencing file with this hash'), -(u'MsiFileHash', u'Options', u'N', 0, 32767, None, None, None, None, u'Various options and attributes for this hash.'), -(u'MsiFileHash', u'HashPart1', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart2', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart3', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart4', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiPatchHeaders', u'StreamRef', u'N', None, None, None, None, u'Identifier', None, u'Primary key. A unique identifier for the row.'), -(u'MsiPatchHeaders', u'Header', u'N', None, None, None, None, u'Binary', None, u'Binary stream. The patch header, used for patch validation.'), -(u'ODBCAttribute', u'Value', u'Y', None, None, None, None, u'Text', None, u'Value for ODBC driver attribute'), -(u'ODBCAttribute', u'Attribute', u'N', None, None, None, None, u'Text', None, u'Name of ODBC driver attribute'), -(u'ODBCAttribute', u'Driver_', u'N', None, None, u'ODBCDriver', 1, u'Identifier', None, u'Reference to ODBC driver in ODBCDriver table'), -(u'ODBCDriver', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for driver, non-localized'), -(u'ODBCDriver', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Reference to key driver file'), -(u'ODBCDriver', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCDriver', u'Driver', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for driver'), -(u'ODBCDriver', u'File_Setup', u'Y', None, None, u'File', 1, u'Identifier', None, u'Optional reference to key driver setup DLL'), -(u'ODBCDataSource', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for data source'), -(u'ODBCDataSource', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCDataSource', u'DataSource', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for data source'), -(u'ODBCDataSource', u'DriverDescription', u'N', None, None, None, None, u'Text', None, u'Reference to driver description, may be existing driver'), -(u'ODBCDataSource', u'Registration', u'N', 0, 1, None, None, None, None, u'Registration option: 0=machine, 1=user, others t.b.d.'), -(u'ODBCSourceAttribute', u'Value', u'Y', None, None, None, None, u'Text', None, u'Value for ODBC data source attribute'), -(u'ODBCSourceAttribute', u'Attribute', u'N', None, None, None, None, u'Text', None, u'Name of ODBC data source attribute'), -(u'ODBCSourceAttribute', u'DataSource_', u'N', None, None, u'ODBCDataSource', 1, u'Identifier', None, u'Reference to ODBC data source in ODBCDataSource table'), -(u'ODBCTranslator', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for translator'), -(u'ODBCTranslator', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Reference to key translator file'), -(u'ODBCTranslator', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCTranslator', u'File_Setup', u'Y', None, None, u'File', 1, u'Identifier', None, u'Optional reference to key translator setup DLL'), -(u'ODBCTranslator', u'Translator', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for translator'), -(u'Patch', u'Sequence', u'N', 0, 32767, None, None, None, None, u'Primary key, sequence with respect to the media images; order must track cabinet order.'), -(u'Patch', u'Attributes', u'N', 0, 32767, None, None, None, None, u'Integer containing bit flags representing patch attributes'), -(u'Patch', u'File_', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token, foreign key to File table, must match identifier in cabinet.'), -(u'Patch', u'Header', u'Y', None, None, None, None, u'Binary', None, u'Binary stream. The patch header, used for patch validation.'), -(u'Patch', u'PatchSize', u'N', 0, 2147483647, None, None, None, None, u'Size of patch in bytes (long integer).'), -(u'Patch', u'StreamRef_', u'Y', None, None, None, None, u'Identifier', None, u'Identifier. Foreign key to the StreamRef column of the MsiPatchHeaders table.'), -(u'PatchPackage', u'Media_', u'N', 0, 32767, None, None, None, None, u'Foreign key to DiskId column of Media table. Indicates the disk containing the patch package.'), -(u'PatchPackage', u'PatchId', u'N', None, None, None, None, u'Guid', None, u'A unique string GUID representing this patch.'), -(u'PublishComponent', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into the Feature table.'), -(u'PublishComponent', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table.'), -(u'PublishComponent', u'ComponentId', u'N', None, None, None, None, u'Guid', None, u'A string GUID that represents the component id that will be requested by the alien product.'), -(u'PublishComponent', u'AppData', u'Y', None, None, None, None, u'Text', None, u'This is localisable Application specific data that can be associated with a Qualified Component.'), -(u'PublishComponent', u'Qualifier', u'N', None, None, None, None, u'Text', None, u'This is defined only when the ComponentId column is an Qualified Component Id. This is the Qualifier for ProvideComponentIndirect.'), -(u'Registry', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'Registry', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The registry value.'), -(u'Registry', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'Registry', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the registry value.'), -(u'Registry', u'Registry', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'Registry', u'Root', u'N', -1, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.'), -(u'RegLocator', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'RegLocator', u'Type', u'Y', 0, 18, None, None, None, None, u'An integer value that determines if the registry value is a filename or a directory location or to be used as is w/o interpretation.'), -(u'RegLocator', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'RegLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table. If the type is 0, the registry values refers a directory, and _Signature is not a foreign key.'), -(u'RegLocator', u'Root', u'N', 0, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.'), -(u'RemoveFile', u'InstallMode', u'N', None, None, None, None, None, u'1;2;3', u'Installation option, one of iimEnum.'), -(u'RemoveFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the file to be removed.'), -(u'RemoveFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular file entry'), -(u'RemoveFile', u'FileName', u'Y', None, None, None, None, u'WildCardFilename', None, u'Name of the file to be removed.'), -(u'RemoveFile', u'DirProperty', u'N', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full pathname to the folder of the file to be removed.'), -(u'RemoveIniFile', u'Action', u'N', None, None, None, None, None, u'2;4', u'The type of modification to be made, one of iifEnum.'), -(u'RemoveIniFile', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value to be deleted. The value is required when Action is iifIniRemoveTag'), -(u'RemoveIniFile', u'Key', u'N', None, None, None, None, u'Formatted', None, u'The .INI file key below Section.'), -(u'RemoveIniFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the deletion of the .INI value.'), -(u'RemoveIniFile', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name in which to delete the information'), -(u'RemoveIniFile', u'DirProperty', u'Y', None, None, None, None, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the .INI file is.'), -(u'RemoveIniFile', u'Section', u'N', None, None, None, None, u'Formatted', None, u'The .INI file Section.'), -(u'RemoveIniFile', u'RemoveIniFile', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'RemoveRegistry', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'RemoveRegistry', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'RemoveRegistry', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the deletion of the registry value.'), -(u'RemoveRegistry', u'Root', u'N', -1, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum'), -(u'RemoveRegistry', u'RemoveRegistry', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ReserveCost', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reserve a specified amount of space if this component is to be installed.'), -(u'ReserveCost', u'ReserveFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory'), -(u'ReserveCost', u'ReserveKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key that uniquely identifies a particular ReserveCost record'), -(u'ReserveCost', u'ReserveLocal', u'N', 0, 2147483647, None, None, None, None, u'Disk space to reserve if linked component is installed locally.'), -(u'ReserveCost', u'ReserveSource', u'N', 0, 2147483647, None, None, None, None, u'Disk space to reserve if linked component is installed to run from the source location.'), -(u'SelfReg', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Foreign key into the File table denoting the module that needs to be registered.'), -(u'SelfReg', u'Cost', u'Y', 0, 32767, None, None, None, None, u'The cost of registering the module.'), -(u'ServiceControl', u'Name', u'N', None, None, None, None, u'Formatted', None, u'Name of a service. /, \\, comma and space are invalid'), -(u'ServiceControl', u'Event', u'N', 0, 187, None, None, None, None, u'Bit field: Install: 0x1 = Start, 0x2 = Stop, 0x8 = Delete, Uninstall: 0x10 = Start, 0x20 = Stop, 0x80 = Delete'), -(u'ServiceControl', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table that controls the startup of the service'), -(u'ServiceControl', u'ServiceControl', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ServiceControl', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'Arguments for the service. Separate by [~].'), -(u'ServiceControl', u'Wait', u'Y', 0, 1, None, None, None, None, u'Boolean for whether to wait for the service to fully start'), -(u'ServiceInstall', u'Name', u'N', None, None, None, None, u'Formatted', None, u'Internal Name of the Service'), -(u'ServiceInstall', u'Description', u'Y', None, None, None, None, u'Text', None, u'Description of service.'), -(u'ServiceInstall', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table that controls the startup of the service'), -(u'ServiceInstall', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'Arguments to include in every start of the service, passed to WinMain'), -(u'ServiceInstall', u'ServiceInstall', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ServiceInstall', u'Dependencies', u'Y', None, None, None, None, u'Formatted', None, u'Other services this depends on to start. Separate by [~], and end with [~][~]'), -(u'ServiceInstall', u'DisplayName', u'Y', None, None, None, None, u'Formatted', None, u'External Name of the Service'), -(u'ServiceInstall', u'ErrorControl', u'N', -2147483647, 2147483647, None, None, None, None, u'Severity of error if service fails to start'), -(u'ServiceInstall', u'LoadOrderGroup', u'Y', None, None, None, None, u'Formatted', None, u'LoadOrderGroup'), -(u'ServiceInstall', u'Password', u'Y', None, None, None, None, u'Formatted', None, u'password to run service with. (with StartName)'), -(u'ServiceInstall', u'ServiceType', u'N', -2147483647, 2147483647, None, None, None, None, u'Type of the service'), -(u'ServiceInstall', u'StartName', u'Y', None, None, None, None, u'Formatted', None, u'User or object name to run service as'), -(u'ServiceInstall', u'StartType', u'N', 0, 4, None, None, None, None, u'Type of the service'), -(u'Shortcut', u'Name', u'N', None, None, None, None, u'Filename', None, u'The name of the shortcut to be created.'), -(u'Shortcut', u'Description', u'Y', None, None, None, None, u'Text', None, u'The description for the shortcut.'), -(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.'), -(u'Shortcut', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Foreign key into the File table denoting the external icon file for the shortcut.'), -(u'Shortcut', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'The icon index for the shortcut.'), -(u'Shortcut', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.'), -(u'Shortcut', u'Target', u'N', None, None, None, None, u'Shortcut', None, u'The shortcut target. This is usually a property that is expanded to a file or a folder that the shortcut points to.'), -(u'Shortcut', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'The command-line arguments for the shortcut.'), -(u'Shortcut', u'Shortcut', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'Shortcut', u'Hotkey', u'Y', 0, 32767, None, None, None, None, u'The hotkey for the shortcut. It has the virtual-key code for the key in the low-order byte, and the modifier flags in the high-order byte. '), -(u'Shortcut', u'ShowCmd', u'Y', None, None, None, None, None, u'1;3;7', u'The show command for the application window.The following values may be used.'), -(u'Shortcut', u'WkDir', u'Y', None, None, None, None, u'Identifier', None, u'Name of property defining location of working directory.'), -(u'Signature', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The name of the file. This may contain a "short name|long name" pair.'), -(u'Signature', u'Signature', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature represents a unique file signature.'), -(u'Signature', u'Languages', u'Y', None, None, None, None, u'Language', None, u'The languages supported by the file.'), -(u'Signature', u'MaxDate', u'Y', 0, 2147483647, None, None, None, None, u'The maximum creation date of the file.'), -(u'Signature', u'MaxSize', u'Y', 0, 2147483647, None, None, None, None, u'The maximum size of the file. '), -(u'Signature', u'MaxVersion', u'Y', None, None, None, None, u'Text', None, u'The maximum version of the file.'), -(u'Signature', u'MinDate', u'Y', 0, 2147483647, None, None, None, None, u'The minimum creation date of the file.'), -(u'Signature', u'MinSize', u'Y', 0, 2147483647, None, None, None, None, u'The minimum size of the file.'), -(u'Signature', u'MinVersion', u'Y', None, None, None, None, u'Text', None, u'The minimum version of the file.'), -(u'TypeLib', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the type library to be operational.'), -(u'TypeLib', u'Description', u'Y', None, None, None, None, u'Text', None, None), -(u'TypeLib', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'TypeLib', u'Directory_', u'Y', None, None, u'Directory', 1, u'Identifier', None, u'Optional. The foreign key into the Directory table denoting the path to the help file for the type library.'), -(u'TypeLib', u'Language', u'N', 0, 32767, None, None, None, None, u'The language of the library.'), -(u'TypeLib', u'Version', u'Y', 0, 16777215, None, None, None, None, u'The version of the library. The minor version is in the lower 8 bits of the integer. The major version is in the next 16 bits. '), -(u'TypeLib', u'Cost', u'Y', 0, 2147483647, None, None, None, None, u'The cost associated with the registration of the typelib. This column is currently optional.'), -(u'TypeLib', u'LibID', u'N', None, None, None, None, u'Guid', None, u'The GUID that represents the library.'), -(u'Upgrade', u'Attributes', u'N', 0, 2147483647, None, None, None, None, u'The attributes of this product set.'), -(u'Upgrade', u'Remove', u'Y', None, None, None, None, u'Formatted', None, u'The list of features to remove when uninstalling a product from this set. The default is "ALL".'), -(u'Upgrade', u'Language', u'Y', None, None, None, None, u'Language', None, u'A comma-separated list of languages for either products in this set or products not in this set.'), -(u'Upgrade', u'ActionProperty', u'N', None, None, None, None, u'UpperCase', None, u'The property to set when a product in this set is found.'), -(u'Upgrade', u'UpgradeCode', u'N', None, None, None, None, u'Guid', None, u'The UpgradeCode GUID belonging to the products in this set.'), -(u'Upgrade', u'VersionMax', u'Y', None, None, None, None, u'Text', None, u'The maximum ProductVersion of the products in this set. The set may or may not include products with this particular version.'), -(u'Upgrade', u'VersionMin', u'Y', None, None, None, None, u'Text', None, u'The minimum ProductVersion of the products in this set. The set may or may not include products with this particular version.'), -(u'Verb', u'Sequence', u'Y', 0, 32767, None, None, None, None, u'Order within the verbs for a particular extension. Also used simply to specify the default verb.'), -(u'Verb', u'Argument', u'Y', None, None, None, None, u'Formatted', None, u'Optional value for the command arguments.'), -(u'Verb', u'Extension_', u'N', None, None, u'Extension', 1, u'Text', None, u'The extension associated with the table row.'), -(u'Verb', u'Verb', u'N', None, None, None, None, u'Text', None, u'The verb for the command.'), -(u'Verb', u'Command', u'Y', None, None, None, None, u'Formatted', None, u'The command text.'), -] - -Error = [ -(0, u'{{Fatal error: }}'), -(1, u'{{Error [1]. }}'), -(2, u'Warning [1]. '), -(3, None), -(4, u'Info [1]. '), -(5, u'The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is [1]. {{The arguments are: [2], [3], [4]}}'), -(6, None), -(7, u'{{Disk full: }}'), -(8, u'Action [Time]: [1]. [2]'), -(9, u'[ProductName]'), -(10, u'{[2]}{, [3]}{, [4]}'), -(11, u'Message type: [1], Argument: [2]'), -(12, u'=== Logging started: [Date] [Time] ==='), -(13, u'=== Logging stopped: [Date] [Time] ==='), -(14, u'Action start [Time]: [1].'), -(15, u'Action ended [Time]: [1]. Return value [2].'), -(16, u'Time remaining: {[1] minutes }{[2] seconds}'), -(17, u'Out of memory. Shut down other applications before retrying.'), -(18, u'Installer is no longer responding.'), -(19, u'Installer stopped prematurely.'), -(20, u'Please wait while Windows configures [ProductName]'), -(21, u'Gathering required information...'), -(22, u'Removing older versions of this application...'), -(23, u'Preparing to remove older versions of this application...'), -(32, u'{[ProductName] }Setup completed successfully.'), -(33, u'{[ProductName] }Setup failed.'), -(1101, u'Error reading from file: [2]. {{ System error [3].}} Verify that the file exists and that you can access it.'), -(1301, u"Cannot create the file '[2]'. A directory with this name already exists. Cancel the install and try installing to a different location."), -(1302, u'Please insert the disk: [2]'), -(1303, u'The installer has insufficient privileges to access this directory: [2]. The installation cannot continue. Log on as administrator or contact your system administrator.'), -(1304, u'Error writing to file: [2]. Verify that you have access to that directory.'), -(1305, u'Error reading from file [2]. {{ System error [3].}} Verify that the file exists and that you can access it.'), -(1306, u"Another application has exclusive access to the file '[2]'. Please shut down all other applications, then click Retry."), -(1307, u'There is not enough disk space to install this file: [2]. Free some disk space and click Retry, or click Cancel to exit.'), -(1308, u'Source file not found: [2]. Verify that the file exists and that you can access it.'), -(1309, u'Error reading from file: [3]. {{ System error [2].}} Verify that the file exists and that you can access it.'), -(1310, u'Error writing to file: [3]. {{ System error [2].}} Verify that you have access to that directory.'), -(1311, u'Source file not found{{(cabinet)}}: [2]. Verify that the file exists and that you can access it.'), -(1312, u"Cannot create the directory '[2]'. A file with this name already exists. Please rename or remove the file and click retry, or click Cancel to exit."), -(1313, u'The volume [2] is currently unavailable. Please select another.'), -(1314, u"The specified path '[2]' is unavailable."), -(1315, u'Unable to write to the specified folder: [2].'), -(1316, u'A network error occurred while attempting to read from the file: [2]'), -(1317, u'An error occurred while attempting to create the directory: [2]'), -(1318, u'A network error occurred while attempting to create the directory: [2]'), -(1319, u'A network error occurred while attempting to open the source file cabinet: [2]'), -(1320, u'The specified path is too long: [2]'), -(1321, u'The Installer has insufficient privileges to modify this file: [2].'), -(1322, u"A portion of the folder path '[2]' is invalid. It is either empty or exceeds the length allowed by the system."), -(1323, u"The folder path '[2]' contains words that are not valid in folder paths."), -(1324, u"The folder path '[2]' contains an invalid character."), -(1325, u"'[2]' is not a valid short file name."), -(1326, u'Error getting file security: [3] GetLastError: [2]'), -(1327, u'Invalid Drive: [2]'), -(1328, u'Error applying patch to file [2]. It has probably been updated by other means, and can no longer be modified by this patch. For more information contact your patch vendor. {{System Error: [3]}}'), -(1329, u'A file that is required cannot be installed because the cabinet file [2] is not digitally signed. This may indicate that the cabinet file is corrupt.'), -(1330, u'A file that is required cannot be installed because the cabinet file [2] has an invalid digital signature. This may indicate that the cabinet file is corrupt.{{ Error [3] was returned by WinVerifyTrust.}}'), -(1331, u'Failed to correctly copy [2] file: CRC error.'), -(1332, u'Failed to correctly move [2] file: CRC error.'), -(1333, u'Failed to correctly patch [2] file: CRC error.'), -(1334, u"The file '[2]' cannot be installed because the file cannot be found in cabinet file '[3]'. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package."), -(1335, u"The cabinet file '[2]' required for this installation is corrupt and cannot be used. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package."), -(1336, u'There was an error creating a temporary file that is needed to complete this installation.{{ Folder: [3]. System error code: [2]}}'), -(1401, u'Could not create key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1402, u'Could not open key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1403, u'Could not delete value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1404, u'Could not delete key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1405, u'Could not read value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1406, u'Could not write value [2] to key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1407, u'Could not get value names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1408, u'Could not get sub key names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1409, u'Could not read security information for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1410, u'Could not increase the available registry space. [2] KB of free registry space is required for the installation of this application.'), -(1500, u'Another installation is in progress. You must complete that installation before continuing this one.'), -(1501, u'Error accessing secured data. Please make sure the Windows Installer is configured properly and try the install again.'), -(1502, u"User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. Your current install will now continue."), -(1503, u"User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product."), -(1601, u"Out of disk space -- Volume: '[2]'; required space: [3] KB; available space: [4] KB. Free some disk space and retry."), -(1602, u'Are you sure you want to cancel?'), -(1603, u"The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}. Close that application and retry."), -(1604, u"The product '[2]' is already installed, preventing the installation of this product. The two products are incompatible."), -(1605, u"There is not enough disk space on the volume '[2]' to continue the install with recovery enabled. [3] KB are required, but only [4] KB are available. Click Ignore to continue the install without saving recovery information, click Retry to check for available space again, or click Cancel to quit the installation."), -(1606, u'Could not access network location [2].'), -(1607, u'The following applications should be closed before continuing the install:'), -(1608, u'Could not find any previously installed compliant products on the machine for installing this product.'), -(1609, u"An error occurred while applying security settings. [2] is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. {{Unable to locate the user's SID, system error [3]}}"), -(1701, u'The key [2] is not valid. Verify that you entered the correct key.'), -(1702, u'The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to manually restart later.'), -(1703, u'You must restart your system for the configuration changes made to [2] to take effect. Click Yes to restart now or No if you plan to manually restart later.'), -(1704, u'An installation for [2] is currently suspended. You must undo the changes made by that installation to continue. Do you want to undo those changes?'), -(1705, u'A previous installation for this product is in progress. You must undo the changes made by that installation to continue. Do you want to undo those changes?'), -(1706, u"An installation package for the product [2] cannot be found. Try the installation again using a valid copy of the installation package '[3]'."), -(1707, u'Installation completed successfully.'), -(1708, u'Installation failed.'), -(1709, u'Product: [2] -- [3]'), -(1710, u'You may either restore your computer to its previous state or continue the install later. Would you like to restore?'), -(1711, u'An error occurred while writing installation information to disk. Check to make sure enough disk space is available, and click Retry, or Cancel to end the install.'), -(1712, u'One or more of the files required to restore your computer to its previous state could not be found. Restoration will not be possible.'), -(1713, u'[2] cannot install one of its required products. Contact your technical support group. {{System Error: [3].}}'), -(1714, u'The older version of [2] cannot be removed. Contact your technical support group. {{System Error [3].}}'), -(1715, u'Installed [2]'), -(1716, u'Configured [2]'), -(1717, u'Removed [2]'), -(1718, u'File [2] was rejected by digital signature policy.'), -(1719, u'The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance.'), -(1720, u'There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. {{Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] }}'), -(1721, u'There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action: [2], location: [3], command: [4] }}'), -(1722, u'There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. {{Action [2], location: [3], command: [4] }}'), -(1723, u'There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action [2], entry: [3], library: [4] }}'), -(1724, u'Removal completed successfully.'), -(1725, u'Removal failed.'), -(1726, u'Advertisement completed successfully.'), -(1727, u'Advertisement failed.'), -(1728, u'Configuration completed successfully.'), -(1729, u'Configuration failed.'), -(1730, u'You must be an Administrator to remove this application. To remove this application, you can log on as an Administrator, or contact your technical support group for assistance.'), -(1801, u'The path [2] is not valid. Please specify a valid path.'), -(1802, u'Out of memory. Shut down other applications before retrying.'), -(1803, u'There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to go back to the previously selected volume.'), -(1804, u'There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to return to the browse dialog and select a different volume.'), -(1805, u'The folder [2] does not exist. Please enter a path to an existing folder.'), -(1806, u'You have insufficient privileges to read this folder.'), -(1807, u'A valid destination folder for the install could not be determined.'), -(1901, u'Error attempting to read from the source install database: [2].'), -(1902, u'Scheduling reboot operation: Renaming file [2] to [3]. Must reboot to complete operation.'), -(1903, u'Scheduling reboot operation: Deleting file [2]. Must reboot to complete operation.'), -(1904, u'Module [2] failed to register. HRESULT [3]. Contact your support personnel.'), -(1905, u'Module [2] failed to unregister. HRESULT [3]. Contact your support personnel.'), -(1906, u'Failed to cache package [2]. Error: [3]. Contact your support personnel.'), -(1907, u'Could not register font [2]. Verify that you have sufficient permissions to install fonts, and that the system supports this font.'), -(1908, u'Could not unregister font [2]. Verify that you that you have sufficient permissions to remove fonts.'), -(1909, u'Could not create Shortcut [2]. Verify that the destination folder exists and that you can access it.'), -(1910, u'Could not remove Shortcut [2]. Verify that the shortcut file exists and that you can access it.'), -(1911, u'Could not register type library for file [2]. Contact your support personnel.'), -(1912, u'Could not unregister type library for file [2]. Contact your support personnel.'), -(1913, u'Could not update the ini file [2][3]. Verify that the file exists and that you can access it.'), -(1914, u'Could not schedule file [2] to replace file [3] on reboot. Verify that you have write permissions to file [3].'), -(1915, u'Error removing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.'), -(1916, u'Error installing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.'), -(1917, u'Error removing ODBC driver: [4], ODBC error [2]: [3]. Verify that you have sufficient privileges to remove ODBC drivers.'), -(1918, u'Error installing ODBC driver: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.'), -(1919, u'Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.'), -(1920, u"Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services."), -(1921, u"Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services."), -(1922, u"Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services."), -(1923, u"Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services."), -(1924, u"Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables."), -(1925, u'You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.'), -(1926, u"Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file."), -(1927, u'Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000.'), -(1928, u'Error registering COM+ Application. Contact your support personnel for more information.'), -(1929, u'Error unregistering COM+ Application. Contact your support personnel for more information.'), -(1930, u"The description for service '[2]' ([3]) could not be changed."), -(1931, u'The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}}'), -(1932, u'The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}}'), -(1933, u'The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\\r\\n[3]}}'), -(1934, u'User installations are disabled via policy on the machine.'), -(1935, u'An error occured during the installation of assembly component [2]. HRESULT: [3]. {{assembly interface: [4], function: [5], assembly name: [6]}}'), -] - -tables=['AdminExecuteSequence', 'AdminUISequence', 'AdvtExecuteSequence', 'BBControl', 'Billboard', 'Binary', 'CheckBox', 'Property', 'ComboBox', 'Control', 'ListBox', 'ActionText', 'ControlCondition', 'ControlEvent', 'Dialog', 'EventMapping', 'InstallExecuteSequence', 'InstallUISequence', 'ListView', 'RadioButton', 'TextStyle', 'UIText', '_Validation', 'Error'] +tables=['ActionText', 'UIText'] Deleted: /python/trunk/Lib/msilib/uisample.py ============================================================================== --- /python/trunk/Lib/msilib/uisample.py Mon May 1 17:56:03 2006 +++ (empty file) @@ -1,1399 +0,0 @@ -import msilib,os;dirname=os.path.dirname(__file__) -AdminExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'InstallFiles', None, 4000), -(u'InstallAdminPackage', None, 3900), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -] - -AdminUISequence = [ -(u'AdminWelcomeDlg', None, 1230), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'ExecuteAction', None, 1300), -(u'ExitDialog', None, -1), -(u'FatalError', None, -3), -(u'PrepareDlg', None, 140), -(u'ProgressDlg', None, 1280), -(u'UserExit', None, -2), -] - -AdvtExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'CreateShortcuts', None, 4500), -(u'PublishComponents', None, 6200), -(u'PublishFeatures', None, 6300), -(u'PublishProduct', None, 6400), -(u'RegisterClassInfo', None, 4600), -(u'RegisterExtensionInfo', None, 4700), -(u'RegisterMIMEInfo', None, 4900), -(u'RegisterProgIdInfo', None, 4800), -] - -BBControl = [ -] - -Billboard = [ -] - -Binary = [ -(u'bannrbmp', msilib.Binary(os.path.join(dirname,"bannrbmp.bin"))), -(u'completi', msilib.Binary(os.path.join(dirname,"completi.bin"))), -(u'custicon', msilib.Binary(os.path.join(dirname,"custicon.bin"))), -(u'dlgbmp', msilib.Binary(os.path.join(dirname,"dlgbmp.bin"))), -(u'exclamic', msilib.Binary(os.path.join(dirname,"exclamic.bin"))), -(u'info', msilib.Binary(os.path.join(dirname,"info.bin"))), -(u'insticon', msilib.Binary(os.path.join(dirname,"insticon.bin"))), -(u'New', msilib.Binary(os.path.join(dirname,"New.bin"))), -(u'removico', msilib.Binary(os.path.join(dirname,"removico.bin"))), -(u'repairic', msilib.Binary(os.path.join(dirname,"repairic.bin"))), -(u'Up', msilib.Binary(os.path.join(dirname,"Up.bin"))), -] - -CheckBox = [ -] - -Property = [ -(u'BannerBitmap', u'bannrbmp'), -(u'IAgree', u'No'), -(u'ProductID', u'none'), -(u'ARPHELPLINK', u'http://www.microsoft.com/management'), -(u'ButtonText_Back', u'< &Back'), -(u'ButtonText_Browse', u'Br&owse'), -(u'ButtonText_Cancel', u'Cancel'), -(u'ButtonText_Exit', u'&Exit'), -(u'ButtonText_Finish', u'&Finish'), -(u'ButtonText_Ignore', u'&Ignore'), -(u'ButtonText_Install', u'&Install'), -(u'ButtonText_Next', u'&Next >'), -(u'ButtonText_No', u'&No'), -(u'ButtonText_OK', u'OK'), -(u'ButtonText_Remove', u'&Remove'), -(u'ButtonText_Repair', u'&Repair'), -(u'ButtonText_Reset', u'&Reset'), -(u'ButtonText_Resume', u'&Resume'), -(u'ButtonText_Retry', u'&Retry'), -(u'ButtonText_Return', u'&Return'), -(u'ButtonText_Yes', u'&Yes'), -(u'CompleteSetupIcon', u'completi'), -(u'ComponentDownload', u'ftp://anonymous at microsoft.com/components/'), -(u'CustomSetupIcon', u'custicon'), -(u'DefaultUIFont', u'DlgFont8'), -(u'DialogBitmap', u'dlgbmp'), -(u'DlgTitleFont', u'{&DlgFontBold8}'), -(u'ErrorDialog', u'ErrorDlg'), -(u'ExclamationIcon', u'exclamic'), -(u'InfoIcon', u'info'), -(u'InstallerIcon', u'insticon'), -(u'INSTALLLEVEL', u'3'), -(u'InstallMode', u'Typical'), -(u'PIDTemplate', u'12345<###-%%%%%%%>@@@@@'), -#(u'ProductLanguage', u'1033'), -(u'Progress1', u'Installing'), -(u'Progress2', u'installs'), -(u'PROMPTROLLBACKCOST', u'P'), -(u'RemoveIcon', u'removico'), -(u'RepairIcon', u'repairic'), -(u'Setup', u'Setup'), -(u'ShowUserRegistrationDlg', u'1'), -(u'Wizard', u'Setup Wizard'), -] - -ComboBox = [ -] - -Control = [ -(u'AdminWelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'AdminWelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminWelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'AdminWelcomeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will create a server image of [ProductName], at a specified network location. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'AdminWelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'AdminWelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminWelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'ExitDialog', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'ExitDialog', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ExitDialog', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'ExitDialog', u'Description', u'Text', 135, 70, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'ExitDialog', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Completing the [ProductName] [Wizard]', None, None), -(u'ExitDialog', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'ExitDialog', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'FatalError', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'FatalError', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'FatalError', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'FatalError', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}[ProductName] [Wizard] ended prematurely', None, None), -(u'FatalError', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'FatalError', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'FatalError', u'Description1', u'Text', 135, 70, 220, 40, 196611, None, u'[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.', None, None), -(u'FatalError', u'Description2', u'Text', 135, 115, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'PrepareDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Cancel', None), -(u'PrepareDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'PrepareDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'PrepareDlg', u'Description', u'Text', 135, 70, 220, 20, 196611, None, u'Please wait while the [Wizard] prepares to guide you through the installation.', None, None), -(u'PrepareDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'PrepareDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', None, None), -(u'PrepareDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', None, None), -(u'PrepareDlg', u'ActionData', u'Text', 135, 125, 220, 30, 196611, None, None, None, None), -(u'PrepareDlg', u'ActionText', u'Text', 135, 100, 220, 20, 196611, None, None, None, None), -(u'ProgressDlg', u'Text', u'Text', 35, 65, 300, 20, 3, None, u'Please wait while the [Wizard] [Progress2] [ProductName]. This may take several minutes.', None, None), -(u'ProgressDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'ProgressDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'ProgressDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ProgressDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'ProgressDlg', u'Title', u'Text', 20, 15, 200, 15, 196611, None, u'[DlgTitleFont][Progress1] [ProductName]', None, None), -(u'ProgressDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'ProgressDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'ProgressDlg', u'ActionText', u'Text', 70, 100, 265, 10, 3, None, None, None, None), -(u'ProgressDlg', u'ProgressBar', u'ProgressBar', 35, 115, 300, 10, 65537, None, u'Progress done', None, None), -(u'ProgressDlg', u'StatusLabel', u'Text', 35, 100, 35, 10, 3, None, u'Status:', None, None), -(u'UserExit', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'UserExit', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'UserExit', u'Cancel', u'PushButton', 304, 243, 56, 17, 1, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'UserExit', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}[ProductName] [Wizard] was interrupted', None, None), -(u'UserExit', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Finish', None), -(u'UserExit', u'Finish', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Finish]', u'Cancel', None), -(u'UserExit', u'Description1', u'Text', 135, 70, 220, 40, 196611, None, u'[ProductName] setup was interrupted. Your system has not been modified. To install this program at a later time, please run the installation again.', None, None), -(u'UserExit', u'Description2', u'Text', 135, 115, 220, 20, 196611, None, u'Click the Finish button to exit the [Wizard].', None, None), -(u'AdminBrowseDlg', u'Up', u'PushButton', 298, 55, 19, 19, 3670019, None, u'Up', u'NewFolder', u'Up One Level|'), -(u'AdminBrowseDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'PathEdit', None), -(u'AdminBrowseDlg', u'PathEdit', u'PathEdit', 84, 202, 261, 17, 3, u'TARGETDIR', None, u'OK', None), -(u'AdminBrowseDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminBrowseDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminBrowseDlg', u'Cancel', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'ComboLabel', None), -(u'AdminBrowseDlg', u'ComboLabel', u'Text', 25, 58, 44, 10, 3, None, u'&Look in:', u'DirectoryCombo', None), -(u'AdminBrowseDlg', u'DirectoryCombo', u'DirectoryCombo', 70, 55, 220, 80, 458755, u'TARGETDIR', None, u'Up', None), -(u'AdminBrowseDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Browse to the destination folder', None, None), -(u'AdminBrowseDlg', u'DirectoryList', u'DirectoryList', 25, 83, 320, 110, 7, u'TARGETDIR', None, u'PathLabel', None), -(u'AdminBrowseDlg', u'PathLabel', u'Text', 25, 205, 59, 10, 3, None, u'&Folder name:', u'BannerBitmap', None), -(u'AdminBrowseDlg', u'NewFolder', u'PushButton', 325, 55, 19, 19, 3670019, None, u'New', u'DirectoryList', u'Create A New Folder|'), -(u'AdminBrowseDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'Cancel', None), -(u'AdminBrowseDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Change current destination folder', None, None), -(u'AdminInstallPointDlg', u'Text', u'Text', 25, 80, 320, 10, 3, None, u'&Enter a new network location or click Browse to browse to one.', u'PathEdit', None), -(u'AdminInstallPointDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Text', None), -(u'AdminInstallPointDlg', u'PathEdit', u'PathEdit', 25, 93, 320, 18, 3, u'TARGETDIR', None, u'Browse', None), -(u'AdminInstallPointDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminInstallPointDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminInstallPointDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'AdminInstallPointDlg', u'Description', u'Text', 25, 20, 280, 20, 196611, None, u'Please specify a network location for the server image of [ProductName] product', None, None), -(u'AdminInstallPointDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Network Location', None, None), -(u'AdminInstallPointDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminInstallPointDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'AdminInstallPointDlg', u'Browse', u'PushButton', 289, 119, 56, 17, 3, None, u'[ButtonText_Browse]', u'Back', None), -(u'AdminRegistrationDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OrganizationLabel', None), -(u'AdminRegistrationDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'AdminRegistrationDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'AdminRegistrationDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'AdminRegistrationDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please enter your company information', None, None), -(u'AdminRegistrationDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Company Information', None, None), -(u'AdminRegistrationDlg', u'Back', u'PushButton', 180, 243, 56, 17, 65539, None, u'[ButtonText_Back]', u'Next', None), -(u'AdminRegistrationDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'AdminRegistrationDlg', u'OrganizationLabel', u'Text', 45, 71, 285, 30, 3, None, u'&Please enter the name of your organization in the box below. This will be used as default company name for subsequent installations of [ProductName]:', u'OrganizationEdit', None), -(u'AdminRegistrationDlg', u'CDKeyEdit', u'MaskedEdit', 45, 143, 250, 16, 3, u'PIDKEY', u'[PIDTemplate]', u'Back', None), -(u'AdminRegistrationDlg', u'CDKeyLabel', u'Text', 45, 130, 50, 10, 3, None, u'CD &Key:', u'CDKeyEdit', None), -(u'AdminRegistrationDlg', u'OrganizationEdit', u'Edit', 45, 105, 220, 18, 3, u'COMPANYNAME', u'{80}', u'CDKeyLabel', None), -(u'BrowseDlg', u'Up', u'PushButton', 298, 55, 19, 19, 3670019, None, u'Up', u'NewFolder', u'Up One Level|'), -(u'BrowseDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'PathEdit', None), -(u'BrowseDlg', u'PathEdit', u'PathEdit', 84, 202, 261, 18, 11, u'_BrowseProperty', None, u'OK', None), -(u'BrowseDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'BrowseDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'BrowseDlg', u'Cancel', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'ComboLabel', None), -(u'BrowseDlg', u'ComboLabel', u'Text', 25, 58, 44, 10, 3, None, u'&Look in:', u'DirectoryCombo', None), -(u'BrowseDlg', u'DirectoryCombo', u'DirectoryCombo', 70, 55, 220, 80, 393227, u'_BrowseProperty', None, u'Up', None), -(u'BrowseDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Browse to the destination folder', None, None), -(u'BrowseDlg', u'DirectoryList', u'DirectoryList', 25, 83, 320, 110, 15, u'_BrowseProperty', None, u'PathLabel', None), -(u'BrowseDlg', u'PathLabel', u'Text', 25, 205, 59, 10, 3, None, u'&Folder name:', u'BannerBitmap', None), -(u'BrowseDlg', u'NewFolder', u'PushButton', 325, 55, 19, 19, 3670019, None, u'New', u'DirectoryList', u'Create A New Folder|'), -(u'BrowseDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'Cancel', None), -(u'BrowseDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Change current destination folder', None, None), -(u'CancelDlg', u'Text', u'Text', 48, 15, 194, 30, 3, None, u'Are you sure you want to cancel [ProductName] installation?', None, None), -(u'CancelDlg', u'Icon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[InfoIcon]', None, u'Information icon|'), -(u'CancelDlg', u'No', u'PushButton', 132, 57, 56, 17, 3, None, u'[ButtonText_No]', u'Yes', None), -(u'CancelDlg', u'Yes', u'PushButton', 72, 57, 56, 17, 3, None, u'[ButtonText_Yes]', u'No', None), -(u'CustomizeDlg', u'Text', u'Text', 25, 55, 320, 20, 3, None, u'Click on the icons in the tree below to change the way features will be installed.', None, None), -(u'CustomizeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Tree', None), -(u'CustomizeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'CustomizeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'CustomizeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'CustomizeDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Select the way you want features to be installed.', None, None), -(u'CustomizeDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Custom Setup', None, None), -(u'CustomizeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'CustomizeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'CustomizeDlg', u'Browse', u'PushButton', 304, 200, 56, 17, 3, None, u'[ButtonText_Browse]', u'Reset', None), -(u'CustomizeDlg', u'Tree', u'SelectionTree', 25, 85, 175, 95, 7, u'_BrowseProperty', u'Tree of selections', u'Browse', None), -(u'CustomizeDlg', u'Box', u'GroupBox', 210, 81, 140, 98, 1, None, None, None, None), -(u'CustomizeDlg', u'Reset', u'PushButton', 42, 243, 56, 17, 3, None, u'[ButtonText_Reset]', u'DiskCost', None), -(u'CustomizeDlg', u'DiskCost', u'PushButton', 111, 243, 56, 17, 3, None, u'Disk &Usage', u'Back', None), -(u'CustomizeDlg', u'ItemDescription', u'Text', 215, 90, 131, 30, 3, None, u'Multiline description of the currently selected item.', None, None), -(u'CustomizeDlg', u'ItemSize', u'Text', 215, 130, 131, 45, 3, None, u'The size of the currently selected item.', None, None), -(u'CustomizeDlg', u'Location', u'Text', 75, 200, 215, 20, 3, None, u"", None, None), -(u'CustomizeDlg', u'LocationLabel', u'Text', 25, 200, 50, 10, 3, None, u'Location:', None, None), -(u'DiskCostDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes (if any) do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'DiskCostDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OK', None), -(u'DiskCostDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'DiskCostDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'DiskCostDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'The disk space required for the installation of the selected features.', None, None), -(u'DiskCostDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'BannerBitmap', None), -(u'DiskCostDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Disk Space Requirements', None, None), -(u'DiskCostDlg', u'VolumeList', u'VolumeCostList', 20, 100, 330, 120, 393223, None, u'{120}{70}{70}{70}{70}', None, None), -(u'ErrorDlg', u'Y', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Yes]', None, None), -(u'ErrorDlg', u'A', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Cancel]', None, None), -(u'ErrorDlg', u'C', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Cancel]', None, None), -(u'ErrorDlg', u'ErrorIcon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[InfoIcon]', None, u'Information icon|'), -(u'ErrorDlg', u'ErrorText', u'Text', 48, 15, 205, 60, 3, None, u'Information text', None, None), -(u'ErrorDlg', u'I', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Ignore]', None, None), -(u'ErrorDlg', u'N', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_No]', None, None), -(u'ErrorDlg', u'O', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_OK]', None, None), -(u'ErrorDlg', u'R', u'PushButton', 100, 80, 56, 17, 3, None, u'[ButtonText_Retry]', None, None), -(u'FilesInUse', u'Text', u'Text', 20, 55, 330, 30, 3, None, u'The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.', None, None), -(u'FilesInUse', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Retry', None), -(u'FilesInUse', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'FilesInUse', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'FilesInUse', u'Description', u'Text', 20, 23, 280, 20, 196611, None, u'Some files that need to be updated are currently in use.', None, None), -(u'FilesInUse', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Files in Use', None, None), -(u'FilesInUse', u'Retry', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Retry]', u'Ignore', None), -(u'FilesInUse', u'Exit', u'PushButton', 166, 243, 56, 17, 3, None, u'[ButtonText_Exit]', u'BannerBitmap', None), -(u'FilesInUse', u'Ignore', u'PushButton', 235, 243, 56, 17, 3, None, u'[ButtonText_Ignore]', u'Exit', None), -(u'FilesInUse', u'List', u'ListBox', 20, 87, 330, 130, 7, u'FileInUseProcess', None, None, None), -(u'LicenseAgreementDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'AgreementText', None), -(u'LicenseAgreementDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'LicenseAgreementDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'LicenseAgreementDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'LicenseAgreementDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please read the following license agreement carefully', None, None), -(u'LicenseAgreementDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]End-User License Agreement', None, None), -(u'LicenseAgreementDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'LicenseAgreementDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'LicenseAgreementDlg', u'AgreementText', u'ScrollableText', 20, 60, 330, 120, 7, None, u'{\\rtf1\\ansi\\ansicpg1252\\deff0\\deftab720{\\fonttbl{\\f0\\froman\\fprq2 Times New Roman;}}{\\colortbl\\red0\\green0\\blue0;} \\deflang1033\\horzdoc{\\*\\fchars }{\\*\\lchars }\\pard\\plain\\f0\\fs20 \\par }', u'Buttons', None), -(u'LicenseAgreementDlg', u'Buttons', u'RadioButtonGroup', 20, 187, 330, 40, 3, u'IAgree', None, u'Back', None), -(u'MaintenanceTypeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'ChangeLabel', None), -(u'MaintenanceTypeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'MaintenanceTypeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'MaintenanceTypeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'MaintenanceTypeDlg', u'Description', u'Text', 25, 23, 280, 20, 196611, None, u'Select the operation you wish to perform.', None, None), -(u'MaintenanceTypeDlg', u'Title', u'Text', 15, 6, 240, 15, 196611, None, u'[DlgTitleFont]Modify, Repair or Remove installation', None, None), -(u'MaintenanceTypeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'MaintenanceTypeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'MaintenanceTypeDlg', u'ChangeLabel', u'Text', 105, 65, 100, 10, 3, None, u'[DlgTitleFont]&Modify', u'ChangeButton', None), -(u'MaintenanceTypeDlg', u'ChangeButton', u'PushButton', 50, 65, 38, 38, 5767171, None, u'[CustomSetupIcon]', u'RepairLabel', u'Modify Installation|'), -(u'MaintenanceTypeDlg', u'RepairLabel', u'Text', 105, 114, 100, 10, 3, None, u'[DlgTitleFont]Re&pair', u'RepairButton', None), -(u'MaintenanceTypeDlg', u'ChangeText', u'Text', 105, 78, 230, 20, 3, None, u'Allows users to change the way features are installed.', None, None), -(u'MaintenanceTypeDlg', u'RemoveButton', u'PushButton', 50, 163, 38, 38, 5767171, None, u'[RemoveIcon]', u'Back', u'Remove Installation|'), -(u'MaintenanceTypeDlg', u'RemoveLabel', u'Text', 105, 163, 100, 10, 3, None, u'[DlgTitleFont]&Remove', u'RemoveButton', None), -(u'MaintenanceTypeDlg', u'RemoveText', u'Text', 105, 176, 230, 20, 3, None, u'Removes [ProductName] from your computer.', None, None), -(u'MaintenanceTypeDlg', u'RepairButton', u'PushButton', 50, 114, 38, 38, 5767171, None, u'[RepairIcon]', u'RemoveLabel', u'Repair Installation|'), -(u'MaintenanceTypeDlg', u'RepairText', u'Text', 105, 127, 230, 30, 3, None, u'Repairs errors in the most recent installation state - fixes missing or corrupt files, shortcuts and registry entries.', None, None), -(u'MaintenanceWelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'MaintenanceWelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'MaintenanceWelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'MaintenanceWelcomeDlg', u'Description', u'Text', 135, 70, 220, 60, 196611, None, u'The [Wizard] will allow you to change the way [ProductName] features are installed on your computer or even to remove [ProductName] from your computer. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'MaintenanceWelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'MaintenanceWelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'MaintenanceWelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'OutOfDiskDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'OutOfDiskDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'OK', None), -(u'OutOfDiskDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'OutOfDiskDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'OutOfDiskDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'Disk space required for the installation exceeds available disk space.', None, None), -(u'OutOfDiskDlg', u'OK', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_OK]', u'BannerBitmap', None), -(u'OutOfDiskDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Out of Disk Space', None, None), -(u'OutOfDiskDlg', u'VolumeList', u'VolumeCostList', 20, 100, 330, 120, 393223, None, u'{120}{70}{70}{70}{70}', None, None), -(u'OutOfRbDiskDlg', u'Text', u'Text', 20, 53, 330, 40, 3, None, u'The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).', None, None), -(u'OutOfRbDiskDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'No', None), -(u'OutOfRbDiskDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'OutOfRbDiskDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'OutOfRbDiskDlg', u'Description', u'Text', 20, 20, 280, 20, 196611, None, u'Disk space required for the installation exceeds available disk space.', None, None), -(u'OutOfRbDiskDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Out of Disk Space', None, None), -(u'OutOfRbDiskDlg', u'No', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_No]', u'Yes', None), -(u'OutOfRbDiskDlg', u'Yes', u'PushButton', 240, 243, 56, 17, 3, None, u'[ButtonText_Yes]', u'BannerBitmap', None), -(u'OutOfRbDiskDlg', u'VolumeList', u'VolumeCostList', 20, 140, 330, 80, 4587527, None, u'{120}{70}{70}{70}{70}', None, None), -(u'OutOfRbDiskDlg', u'Text2', u'Text', 20, 94, 330, 40, 3, None, u"Alternatively, you may choose to disable the installer's rollback functionality. This allows the installer to restore your computer's original state should the installation be interrupted in any way. Click Yes if you wish to take the risk to disable rollback.", None, None), -(u'ResumeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'ResumeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'ResumeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'ResumeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will complete the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the [Wizard].', None, None), -(u'ResumeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Resuming the [ProductName] [Wizard]', None, None), -(u'ResumeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Install', None), -(u'ResumeDlg', u'Install', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Install]', u'Cancel', None), -(u'SetupTypeDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'TypicalLabel', None), -(u'SetupTypeDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'SetupTypeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'SetupTypeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'SetupTypeDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Choose the setup type that best suits your needs', None, None), -(u'SetupTypeDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Choose Setup Type', None, None), -(u'SetupTypeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'SetupTypeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 1, None, u'[ButtonText_Next]', u'Cancel', None), -(u'SetupTypeDlg', u'TypicalLabel', u'Text', 105, 65, 100, 10, 3, None, u'[DlgTitleFont]&Typical', u'TypicalButton', None), -(u'SetupTypeDlg', u'CompleteButton', u'PushButton', 50, 171, 38, 38, 5767171, None, u'[CompleteSetupIcon]', u'Back', u'Complete Installation|'), -(u'SetupTypeDlg', u'CompleteLabel', u'Text', 105, 171, 100, 10, 3, None, u'[DlgTitleFont]C&omplete', u'CompleteButton', None), -(u'SetupTypeDlg', u'CompleteText', u'Text', 105, 184, 230, 20, 3, None, u'All program features will be installed. (Requires most disk space)', None, None), -(u'SetupTypeDlg', u'CustomButton', u'PushButton', 50, 118, 38, 38, 5767171, None, u'[CustomSetupIcon]', u'CompleteLabel', u'Custom Installation|'), -(u'SetupTypeDlg', u'CustomLabel', u'Text', 105, 118, 100, 10, 3, None, u'[DlgTitleFont]C&ustom', u'CustomButton', None), -(u'SetupTypeDlg', u'CustomText', u'Text', 105, 131, 230, 30, 3, None, u'Allows users to choose which program features will be installed and where they will be installed. Recommended for advanced users.', None, None), -(u'SetupTypeDlg', u'TypicalButton', u'PushButton', 50, 65, 38, 38, 5767171, None, u'[InstallerIcon]', u'CustomLabel', u'Typical Installation|'), -(u'SetupTypeDlg', u'TypicalText', u'Text', 105, 78, 230, 20, 3, None, u'Installs the most common program features. Recommended for most users.', None, None), -(u'UserRegistrationDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'NameLabel', None), -(u'UserRegistrationDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'UserRegistrationDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'UserRegistrationDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'UserRegistrationDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'Please enter your customer information', None, None), -(u'UserRegistrationDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Customer Information', None, None), -(u'UserRegistrationDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Next', None), -(u'UserRegistrationDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -(u'UserRegistrationDlg', u'OrganizationLabel', u'Text', 45, 110, 100, 15, 3, None, u'&Organization:', u'OrganizationEdit', None), -(u'UserRegistrationDlg', u'CDKeyEdit', u'MaskedEdit', 45, 159, 250, 16, 3, u'PIDKEY', u'[PIDTemplate]', u'Back', None), -(u'UserRegistrationDlg', u'CDKeyLabel', u'Text', 45, 147, 50, 10, 3, None, u'CD &Key:', u'CDKeyEdit', None), -(u'UserRegistrationDlg', u'OrganizationEdit', u'Edit', 45, 122, 220, 18, 3, u'COMPANYNAME', u'{80}', u'CDKeyLabel', None), -(u'UserRegistrationDlg', u'NameLabel', u'Text', 45, 73, 100, 15, 3, None, u'&User Name:', u'NameEdit', None), -(u'UserRegistrationDlg', u'NameEdit', u'Edit', 45, 85, 220, 18, 3, u'USERNAME', u'{80}', u'OrganizationLabel', None), -(u'VerifyReadyDlg', u'Text', u'Text', 25, 70, 320, 20, 3, None, u'Click Install to begin the installation. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyReadyDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyReadyDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyReadyDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyReadyDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyReadyDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'The [Wizard] is ready to begin the [InstallMode] installation', None, None), -(u'VerifyReadyDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Ready to Install', None, None), -(u'VerifyReadyDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Install', None), -(u'VerifyReadyDlg', u'Install', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Install]', u'Cancel', None), -(u'VerifyRemoveDlg', u'Text', u'Text', 25, 70, 320, 30, 3, None, u'Click Remove to remove [ProductName] from your computer. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyRemoveDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyRemoveDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyRemoveDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyRemoveDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyRemoveDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'You have chosen to remove the program from your computer.', None, None), -(u'VerifyRemoveDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Remove [ProductName]', None, None), -(u'VerifyRemoveDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Remove', None), -(u'VerifyRemoveDlg', u'Remove', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Remove]', u'Cancel', None), -(u'VerifyRepairDlg', u'Text', u'Text', 25, 70, 320, 30, 3, None, u'Click Repair to repair the installation of [ProductName]. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard.', None, None), -(u'VerifyRepairDlg', u'BannerBitmap', u'Bitmap', 0, 0, 374, 44, 1, None, u'[BannerBitmap]', u'Back', None), -(u'VerifyRepairDlg', u'BannerLine', u'Line', 0, 44, 374, 0, 1, None, None, None, None), -(u'VerifyRepairDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'VerifyRepairDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'BannerBitmap', None), -(u'VerifyRepairDlg', u'Description', u'Text', 25, 23, 280, 15, 196611, None, u'The [Wizard] is ready to begin the repair of [ProductName].', None, None), -(u'VerifyRepairDlg', u'Title', u'Text', 15, 6, 200, 15, 196611, None, u'[DlgTitleFont]Repair [ProductName]', None, None), -(u'VerifyRepairDlg', u'Back', u'PushButton', 180, 243, 56, 17, 3, None, u'[ButtonText_Back]', u'Repair', None), -(u'VerifyRepairDlg', u'Repair', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Repair]', u'Cancel', None), -(u'WaitForCostingDlg', u'Text', u'Text', 48, 15, 194, 30, 3, None, u'Please wait while the installer finishes determining your disk space requirements.', None, None), -(u'WaitForCostingDlg', u'Icon', u'Icon', 15, 15, 24, 24, 5242881, None, u'[ExclamationIcon]', None, u'Exclamation icon|'), -(u'WaitForCostingDlg', u'Return', u'PushButton', 102, 57, 56, 17, 3, None, u'[ButtonText_Return]', None, None), -(u'WelcomeDlg', u'Bitmap', u'Bitmap', 0, 0, 370, 234, 1, None, u'[DialogBitmap]', u'Back', None), -(u'WelcomeDlg', u'BottomLine', u'Line', 0, 234, 374, 0, 1, None, None, None, None), -(u'WelcomeDlg', u'Cancel', u'PushButton', 304, 243, 56, 17, 3, None, u'[ButtonText_Cancel]', u'Bitmap', None), -(u'WelcomeDlg', u'Description', u'Text', 135, 70, 220, 30, 196611, None, u'The [Wizard] will install [ProductName] on your computer. Click Next to continue or Cancel to exit the [Wizard].', None, None), -(u'WelcomeDlg', u'Title', u'Text', 135, 20, 220, 60, 196611, None, u'{\\VerdanaBold13}Welcome to the [ProductName] [Wizard]', None, None), -(u'WelcomeDlg', u'Back', u'PushButton', 180, 243, 56, 17, 1, None, u'[ButtonText_Back]', u'Next', None), -(u'WelcomeDlg', u'Next', u'PushButton', 236, 243, 56, 17, 3, None, u'[ButtonText_Next]', u'Cancel', None), -] - -ListBox = [ -] - -ActionText = [ -(u'InstallValidate', u'Validating install', None), -(u'InstallFiles', u'Copying new files', u'File: [1], Directory: [9], Size: [6]'), -(u'InstallAdminPackage', u'Copying network install files', u'File: [1], Directory: [9], Size: [6]'), -(u'FileCost', u'Computing space requirements', None), -(u'CostInitialize', u'Computing space requirements', None), -(u'CostFinalize', u'Computing space requirements', None), -(u'CreateShortcuts', u'Creating shortcuts', u'Shortcut: [1]'), -(u'PublishComponents', u'Publishing Qualified Components', u'Component ID: [1], Qualifier: [2]'), -(u'PublishFeatures', u'Publishing Product Features', u'Feature: [1]'), -(u'PublishProduct', u'Publishing product information', None), -(u'RegisterClassInfo', u'Registering Class servers', u'Class Id: [1]'), -(u'RegisterExtensionInfo', u'Registering extension servers', u'Extension: [1]'), -(u'RegisterMIMEInfo', u'Registering MIME info', u'MIME Content Type: [1], Extension: [2]'), -(u'RegisterProgIdInfo', u'Registering program identifiers', u'ProgId: [1]'), -(u'AllocateRegistrySpace', u'Allocating registry space', u'Free space: [1]'), -(u'AppSearch', u'Searching for installed applications', u'Property: [1], Signature: [2]'), -(u'BindImage', u'Binding executables', u'File: [1]'), -(u'CCPSearch', u'Searching for qualifying products', None), -(u'CreateFolders', u'Creating folders', u'Folder: [1]'), -(u'DeleteServices', u'Deleting services', u'Service: [1]'), -(u'DuplicateFiles', u'Creating duplicate files', u'File: [1], Directory: [9], Size: [6]'), -(u'FindRelatedProducts', u'Searching for related applications', u'Found application: [1]'), -(u'InstallODBC', u'Installing ODBC components', None), -(u'InstallServices', u'Installing new services', u'Service: [2]'), -(u'LaunchConditions', u'Evaluating launch conditions', None), -(u'MigrateFeatureStates', u'Migrating feature states from related applications', u'Application: [1]'), -(u'MoveFiles', u'Moving files', u'File: [1], Directory: [9], Size: [6]'), -(u'PatchFiles', u'Patching files', u'File: [1], Directory: [2], Size: [3]'), -(u'ProcessComponents', u'Updating component registration', None), -(u'RegisterComPlus', u'Registering COM+ Applications and Components', u'AppId: [1]{{, AppType: [2], Users: [3], RSN: [4]}}'), -(u'RegisterFonts', u'Registering fonts', u'Font: [1]'), -(u'RegisterProduct', u'Registering product', u'[1]'), -(u'RegisterTypeLibraries', u'Registering type libraries', u'LibID: [1]'), -(u'RegisterUser', u'Registering user', u'[1]'), -(u'RemoveDuplicateFiles', u'Removing duplicated files', u'File: [1], Directory: [9]'), -(u'RemoveEnvironmentStrings', u'Updating environment strings', u'Name: [1], Value: [2], Action [3]'), -(u'RemoveExistingProducts', u'Removing applications', u'Application: [1], Command line: [2]'), -(u'RemoveFiles', u'Removing files', u'File: [1], Directory: [9]'), -(u'RemoveFolders', u'Removing folders', u'Folder: [1]'), -(u'RemoveIniValues', u'Removing INI files entries', u'File: [1], Section: [2], Key: [3], Value: [4]'), -(u'RemoveODBC', u'Removing ODBC components', None), -(u'RemoveRegistryValues', u'Removing system registry values', u'Key: [1], Name: [2]'), -(u'RemoveShortcuts', u'Removing shortcuts', u'Shortcut: [1]'), -(u'RMCCPSearch', u'Searching for qualifying products', None), -(u'SelfRegModules', u'Registering modules', u'File: [1], Folder: [2]'), -(u'SelfUnregModules', u'Unregistering modules', u'File: [1], Folder: [2]'), -(u'SetODBCFolders', u'Initializing ODBC directories', None), -(u'StartServices', u'Starting services', u'Service: [1]'), -(u'StopServices', u'Stopping services', u'Service: [1]'), -(u'UnpublishComponents', u'Unpublishing Qualified Components', u'Component ID: [1], Qualifier: [2]'), -(u'UnpublishFeatures', u'Unpublishing Product Features', u'Feature: [1]'), -(u'UnregisterClassInfo', u'Unregister Class servers', u'Class Id: [1]'), -(u'UnregisterComPlus', u'Unregistering COM+ Applications and Components', u'AppId: [1]{{, AppType: [2]}}'), -(u'UnregisterExtensionInfo', u'Unregistering extension servers', u'Extension: [1]'), -(u'UnregisterFonts', u'Unregistering fonts', u'Font: [1]'), -(u'UnregisterMIMEInfo', u'Unregistering MIME info', u'MIME Content Type: [1], Extension: [2]'), -(u'UnregisterProgIdInfo', u'Unregistering program identifiers', u'ProgId: [1]'), -(u'UnregisterTypeLibraries', u'Unregistering type libraries', u'LibID: [1]'), -(u'WriteEnvironmentStrings', u'Updating environment strings', u'Name: [1], Value: [2], Action [3]'), -(u'WriteIniValues', u'Writing INI files values', u'File: [1], Section: [2], Key: [3], Value: [4]'), -(u'WriteRegistryValues', u'Writing system registry values', u'Key: [1], Name: [2], Value: [3]'), -(u'Advertise', u'Advertising application', None), -(u'GenerateScript', u'Generating script operations for action:', u'[1]'), -(u'InstallSFPCatalogFile', u'Installing system catalog', u'File: [1], Dependencies: [2]'), -(u'MsiPublishAssemblies', u'Publishing assembly information', u'Application Context:[1], Assembly Name:[2]'), -(u'MsiUnpublishAssemblies', u'Unpublishing assembly information', u'Application Context:[1], Assembly Name:[2]'), -(u'Rollback', u'Rolling back action:', u'[1]'), -(u'RollbackCleanup', u'Removing backup files', u'File: [1]'), -(u'UnmoveFiles', u'Removing moved files', u'File: [1], Directory: [9]'), -(u'UnpublishProduct', u'Unpublishing product information', None), -] - -ControlCondition = [ -(u'CustomizeDlg', u'Browse', u'Hide', u'Installed'), -(u'CustomizeDlg', u'Location', u'Hide', u'Installed'), -(u'CustomizeDlg', u'LocationLabel', u'Hide', u'Installed'), -(u'LicenseAgreementDlg', u'Next', u'Disable', u'IAgree <> "Yes"'), -(u'LicenseAgreementDlg', u'Next', u'Enable', u'IAgree = "Yes"'), -] - -ControlEvent = [ -(u'AdminWelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminWelcomeDlg', u'Next', u'NewDialog', u'AdminRegistrationDlg', u'1', 2), -(u'AdminWelcomeDlg', u'Next', u'[InstallMode]', u'Server Image', u'1', 1), -(u'ExitDialog', u'Finish', u'EndDialog', u'Return', u'1', None), -(u'FatalError', u'Finish', u'EndDialog', u'Exit', u'1', None), -(u'PrepareDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'ProgressDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'UserExit', u'Finish', u'EndDialog', u'Exit', u'1', None), -(u'AdminBrowseDlg', u'Up', u'DirectoryListUp', u'0', u'1', None), -(u'AdminBrowseDlg', u'Cancel', u'Reset', u'0', u'1', 1), -(u'AdminBrowseDlg', u'Cancel', u'EndDialog', u'Return', u'1', 2), -(u'AdminBrowseDlg', u'NewFolder', u'DirectoryListNew', u'0', u'1', None), -(u'AdminBrowseDlg', u'OK', u'EndDialog', u'Return', u'1', 2), -(u'AdminBrowseDlg', u'OK', u'SetTargetPath', u'TARGETDIR', u'1', 1), -(u'AdminInstallPointDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminInstallPointDlg', u'Back', u'NewDialog', u'AdminRegistrationDlg', u'1', None), -(u'AdminInstallPointDlg', u'Next', u'SetTargetPath', u'TARGETDIR', u'1', 1), -(u'AdminInstallPointDlg', u'Next', u'NewDialog', u'VerifyReadyDlg', u'1', 2), -(u'AdminInstallPointDlg', u'Browse', u'SpawnDialog', u'AdminBrowseDlg', u'1', None), -(u'AdminRegistrationDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'AdminRegistrationDlg', u'Back', u'NewDialog', u'AdminWelcomeDlg', u'1', None), -(u'AdminRegistrationDlg', u'Next', u'NewDialog', u'AdminInstallPointDlg', u'ProductID', 2), -(u'AdminRegistrationDlg', u'Next', u'ValidateProductID', u'0', u'0', 1), -(u'BrowseDlg', u'Up', u'DirectoryListUp', u'0', u'1', None), -(u'BrowseDlg', u'Cancel', u'Reset', u'0', u'1', 1), -(u'BrowseDlg', u'Cancel', u'EndDialog', u'Return', u'1', 2), -(u'BrowseDlg', u'NewFolder', u'DirectoryListNew', u'0', u'1', None), -(u'BrowseDlg', u'OK', u'EndDialog', u'Return', u'1', 2), -(u'BrowseDlg', u'OK', u'SetTargetPath', u'[_BrowseProperty]', u'1', 1), -(u'CancelDlg', u'No', u'EndDialog', u'Return', u'1', None), -(u'CancelDlg', u'Yes', u'EndDialog', u'Exit', u'1', None), -(u'CustomizeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'CustomizeDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'InstallMode = "Change"', None), -(u'CustomizeDlg', u'Back', u'NewDialog', u'SetupTypeDlg', u'InstallMode = "Custom"', None), -(u'CustomizeDlg', u'Next', u'NewDialog', u'VerifyReadyDlg', u'1', None), -(u'CustomizeDlg', u'Browse', u'SelectionBrowse', u'BrowseDlg', u'1', None), -(u'CustomizeDlg', u'Reset', u'Reset', u'0', u'1', None), -(u'CustomizeDlg', u'DiskCost', u'SpawnDialog', u'DiskCostDlg', u'1', 2), -(u'DiskCostDlg', u'OK', u'EndDialog', u'Return', u'1', None), -(u'ErrorDlg', u'Y', u'EndDialog', u'ErrorYes', u'1', None), -(u'ErrorDlg', u'A', u'EndDialog', u'ErrorAbort', u'1', None), -(u'ErrorDlg', u'C', u'EndDialog', u'ErrorCancel', u'1', None), -(u'ErrorDlg', u'I', u'EndDialog', u'ErrorIgnore', u'1', None), -(u'ErrorDlg', u'N', u'EndDialog', u'ErrorNo', u'1', None), -(u'ErrorDlg', u'O', u'EndDialog', u'ErrorOk', u'1', None), -(u'ErrorDlg', u'R', u'EndDialog', u'ErrorRetry', u'1', None), -(u'FilesInUse', u'Retry', u'EndDialog', u'Retry', u'1', None), -(u'FilesInUse', u'Exit', u'EndDialog', u'Exit', u'1', None), -(u'FilesInUse', u'Ignore', u'EndDialog', u'Ignore', u'1', None), -(u'LicenseAgreementDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'LicenseAgreementDlg', u'Back', u'NewDialog', u'WelcomeDlg', u'1', None), -(u'LicenseAgreementDlg', u'Next', u'NewDialog', u'SetupTypeDlg', u'IAgree = "Yes" AND ShowUserRegistrationDlg <> 1', 3), -(u'LicenseAgreementDlg', u'Next', u'NewDialog', u'UserRegistrationDlg', u'IAgree = "Yes" AND ShowUserRegistrationDlg = 1', 1), -(u'LicenseAgreementDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 2), -(u'MaintenanceTypeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'MaintenanceTypeDlg', u'Back', u'NewDialog', u'MaintenanceWelcomeDlg', u'1', None), -(u'MaintenanceTypeDlg', u'ChangeButton', u'NewDialog', u'CustomizeDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[InstallMode]', u'Change', u'1', 1), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[Progress1]', u'Changing', u'1', 2), -(u'MaintenanceTypeDlg', u'ChangeButton', u'[Progress2]', u'changes', u'1', 3), -(u'MaintenanceTypeDlg', u'RemoveButton', u'NewDialog', u'VerifyRemoveDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[InstallMode]', u'Remove', u'1', 1), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[Progress1]', u'Removing', u'1', 2), -(u'MaintenanceTypeDlg', u'RemoveButton', u'[Progress2]', u'removes', u'1', 3), -(u'MaintenanceTypeDlg', u'RepairButton', u'NewDialog', u'VerifyRepairDlg', u'1', 4), -(u'MaintenanceTypeDlg', u'RepairButton', u'[InstallMode]', u'Repair', u'1', 1), -(u'MaintenanceTypeDlg', u'RepairButton', u'[Progress1]', u'Repairing', u'1', 2), -(u'MaintenanceTypeDlg', u'RepairButton', u'[Progress2]', u'repairs', u'1', 3), -(u'MaintenanceWelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'MaintenanceWelcomeDlg', u'Next', u'NewDialog', u'MaintenanceTypeDlg', u'1', 2), -(u'MaintenanceWelcomeDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 1), -(u'OutOfDiskDlg', u'OK', u'EndDialog', u'Return', u'1', None), -(u'OutOfRbDiskDlg', u'No', u'EndDialog', u'Return', u'1', None), -(u'OutOfRbDiskDlg', u'Yes', u'EndDialog', u'Return', u'1', 2), -(u'OutOfRbDiskDlg', u'Yes', u'EnableRollback', u'False', u'1', 1), -(u'ResumeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'ResumeDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'ResumeDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 2), -(u'ResumeDlg', u'Install', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 6), -(u'ResumeDlg', u'Install', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 3), -(u'ResumeDlg', u'Install', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 1), -(u'ResumeDlg', u'Install', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'SetupTypeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'SetupTypeDlg', u'Back', u'NewDialog', u'LicenseAgreementDlg', u'ShowUserRegistrationDlg <> 1', None), -(u'SetupTypeDlg', u'Back', u'NewDialog', u'UserRegistrationDlg', u'ShowUserRegistrationDlg = 1', None), -(u'SetupTypeDlg', u'CompleteButton', u'NewDialog', u'VerifyReadyDlg', u'1', 3), -(u'SetupTypeDlg', u'CompleteButton', u'[InstallMode]', u'Complete', u'1', 1), -(u'SetupTypeDlg', u'CompleteButton', u'SetInstallLevel', u'1000', u'1', 2), -(u'SetupTypeDlg', u'CustomButton', u'NewDialog', u'CustomizeDlg', u'1', 2), -(u'SetupTypeDlg', u'CustomButton', u'[InstallMode]', u'Custom', u'1', 1), -(u'SetupTypeDlg', u'TypicalButton', u'NewDialog', u'VerifyReadyDlg', u'1', 3), -(u'SetupTypeDlg', u'TypicalButton', u'[InstallMode]', u'Typical', u'1', 1), -(u'SetupTypeDlg', u'TypicalButton', u'SetInstallLevel', u'3', u'1', 2), -(u'UserRegistrationDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'UserRegistrationDlg', u'Back', u'NewDialog', u'LicenseAgreementDlg', u'1', None), -(u'UserRegistrationDlg', u'Next', u'NewDialog', u'SetupTypeDlg', u'ProductID', 3), -(u'UserRegistrationDlg', u'Next', u'ValidateProductID', u'0', u'0', 1), -(u'UserRegistrationDlg', u'Next', u'SpawnWaitDialog', u'WaitForCostingDlg', u'CostingComplete = 1', 2), -(u'VerifyReadyDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'AdminInstallPointDlg', u'InstallMode = "Server Image"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'CustomizeDlg', u'InstallMode = "Custom" OR InstallMode = "Change"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'InstallMode = "Repair"', None), -(u'VerifyReadyDlg', u'Back', u'NewDialog', u'SetupTypeDlg', u'InstallMode = "Typical" OR InstallMode = "Complete"', None), -(u'VerifyReadyDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 3), -(u'VerifyReadyDlg', u'Install', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 1), -(u'VerifyReadyDlg', u'Install', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 5), -(u'VerifyReadyDlg', u'Install', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 2), -(u'VerifyReadyDlg', u'Install', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'VerifyRemoveDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyRemoveDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'1', None), -(u'VerifyRemoveDlg', u'Remove', u'Remove', u'All', u'OutOfDiskSpace <> 1', 1), -(u'VerifyRemoveDlg', u'Remove', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 4), -(u'VerifyRemoveDlg', u'Remove', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 2), -(u'VerifyRemoveDlg', u'Remove', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 6), -(u'VerifyRemoveDlg', u'Remove', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 3), -(u'VerifyRemoveDlg', u'Remove', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'VerifyRepairDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'VerifyRepairDlg', u'Back', u'NewDialog', u'MaintenanceTypeDlg', u'1', None), -(u'VerifyRepairDlg', u'Repair', u'EndDialog', u'Return', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 5), -(u'VerifyRepairDlg', u'Repair', u'EndDialog', u'Return', u'OutOfDiskSpace <> 1', 3), -(u'VerifyRepairDlg', u'Repair', u'SpawnDialog', u'OutOfDiskDlg', u'(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")', 7), -(u'VerifyRepairDlg', u'Repair', u'SpawnDialog', u'OutOfRbDiskDlg', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)', 4), -(u'VerifyRepairDlg', u'Repair', u'EnableRollback', u'False', u'OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"', 6), -(u'VerifyRepairDlg', u'Repair', u'Reinstall', u'All', u'OutOfDiskSpace <> 1', 2), -(u'VerifyRepairDlg', u'Repair', u'ReinstallMode', u'ecmus', u'OutOfDiskSpace <> 1', 1), -(u'WaitForCostingDlg', u'Return', u'EndDialog', u'Exit', u'1', None), -(u'WelcomeDlg', u'Cancel', u'SpawnDialog', u'CancelDlg', u'1', None), -(u'WelcomeDlg', u'Next', u'NewDialog', u'LicenseAgreementDlg', u'1', None), -] - -Dialog = [ -(u'AdminWelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -(u'ExitDialog', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'FatalError', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'PrepareDlg', 50, 50, 370, 270, 1, u'[ProductName] [Setup]', u'Cancel', u'Cancel', u'Cancel'), -(u'ProgressDlg', 50, 50, 370, 270, 1, u'[ProductName] [Setup]', u'Cancel', u'Cancel', u'Cancel'), -(u'UserExit', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Finish', u'Finish', u'Finish'), -(u'AdminBrowseDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'PathEdit', u'OK', u'Cancel'), -(u'AdminInstallPointDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Text', u'Next', u'Cancel'), -(u'AdminRegistrationDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OrganizationLabel', u'Next', u'Cancel'), -(u'BrowseDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'PathEdit', u'OK', u'Cancel'), -(u'CancelDlg', 50, 10, 260, 85, 3, u'[ProductName] [Setup]', u'No', u'No', u'No'), -(u'CustomizeDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Tree', u'Next', u'Cancel'), -(u'DiskCostDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OK', u'OK', u'OK'), -(u'ErrorDlg', 50, 10, 270, 105, 65539, u'Installer Information', u'ErrorText', None, None), -(u'FilesInUse', 50, 50, 370, 270, 19, u'[ProductName] [Setup]', u'Retry', u'Retry', u'Retry'), -(u'LicenseAgreementDlg', 50, 50, 370, 270, 3, u'[ProductName] License Agreement', u'Buttons', u'Next', u'Cancel'), -(u'MaintenanceTypeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'ChangeLabel', u'ChangeButton', u'Cancel'), -(u'MaintenanceWelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -(u'OutOfDiskDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'OK', u'OK', u'OK'), -(u'OutOfRbDiskDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'No', u'No', u'No'), -(u'ResumeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Install', u'Install', u'Cancel'), -(u'SetupTypeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'TypicalLabel', u'TypicalButton', u'Cancel'), -(u'UserRegistrationDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'NameLabel', u'Next', u'Cancel'), -(u'VerifyReadyDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Install', u'Install', u'Cancel'), -(u'VerifyRemoveDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Back', u'Back', u'Cancel'), -(u'VerifyRepairDlg', 50, 50, 370, 270, 35, u'[ProductName] [Setup]', u'Repair', u'Repair', u'Cancel'), -(u'WaitForCostingDlg', 50, 10, 260, 85, 3, u'[ProductName] [Setup]', u'Return', u'Return', u'Return'), -(u'WelcomeDlg', 50, 50, 370, 270, 3, u'[ProductName] [Setup]', u'Next', u'Next', u'Cancel'), -] - -EventMapping = [ -(u'PrepareDlg', u'ActionData', u'ActionData', u'Text'), -(u'PrepareDlg', u'ActionText', u'ActionText', u'Text'), -(u'ProgressDlg', u'ActionText', u'ActionText', u'Text'), -(u'ProgressDlg', u'ProgressBar', u'SetProgress', u'Progress'), -(u'AdminBrowseDlg', u'DirectoryCombo', u'IgnoreChange', u'IgnoreChange'), -(u'BrowseDlg', u'DirectoryCombo', u'IgnoreChange', u'IgnoreChange'), -(u'CustomizeDlg', u'Next', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'Reset', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'DiskCost', u'SelectionNoItems', u'Enabled'), -(u'CustomizeDlg', u'ItemDescription', u'SelectionDescription', u'Text'), -(u'CustomizeDlg', u'ItemSize', u'SelectionSize', u'Text'), -(u'CustomizeDlg', u'Location', u'SelectionPath', u'Text'), -(u'CustomizeDlg', u'Location', u'SelectionPathOn', u'Visible'), -(u'CustomizeDlg', u'LocationLabel', u'SelectionPathOn', u'Visible'), -] - -InstallExecuteSequence = [ -(u'InstallValidate', None, 1400), -(u'InstallInitialize', None, 1500), -(u'InstallFinalize', None, 6600), -(u'InstallFiles', None, 4000), -(u'FileCost', None, 900), -(u'CostInitialize', None, 800), -(u'CostFinalize', None, 1000), -(u'CreateShortcuts', None, 4500), -(u'PublishComponents', None, 6200), -(u'PublishFeatures', None, 6300), -(u'PublishProduct', None, 6400), -(u'RegisterClassInfo', None, 4600), -(u'RegisterExtensionInfo', None, 4700), -(u'RegisterMIMEInfo', None, 4900), -(u'RegisterProgIdInfo', None, 4800), -(u'ValidateProductID', None, 700), -(u'AllocateRegistrySpace', u'NOT Installed', 1550), -(u'AppSearch', None, 400), -(u'BindImage', None, 4300), -(u'CCPSearch', u'NOT Installed', 500), -(u'CreateFolders', None, 3700), -(u'DeleteServices', u'VersionNT', 2000), -(u'DuplicateFiles', None, 4210), -(u'FindRelatedProducts', None, 200), -(u'InstallODBC', None, 5400), -(u'InstallServices', u'VersionNT', 5800), -(u'LaunchConditions', None, 100), -(u'MigrateFeatureStates', None, 1200), -(u'MoveFiles', None, 3800), -(u'PatchFiles', None, 4090), -(u'ProcessComponents', None, 1600), -(u'RegisterComPlus', None, 5700), -(u'RegisterFonts', None, 5300), -(u'RegisterProduct', None, 6100), -(u'RegisterTypeLibraries', None, 5500), -(u'RegisterUser', None, 6000), -(u'RemoveDuplicateFiles', None, 3400), -(u'RemoveEnvironmentStrings', None, 3300), -(u'RemoveExistingProducts', None, 6700), -(u'RemoveFiles', None, 3500), -(u'RemoveFolders', None, 3600), -(u'RemoveIniValues', None, 3100), -(u'RemoveODBC', None, 2400), -(u'RemoveRegistryValues', None, 2600), -(u'RemoveShortcuts', None, 3200), -(u'RMCCPSearch', u'NOT Installed', 600), -(u'SelfRegModules', None, 5600), -(u'SelfUnregModules', None, 2200), -(u'SetODBCFolders', None, 1100), -(u'StartServices', u'VersionNT', 5900), -(u'StopServices', u'VersionNT', 1900), -(u'UnpublishComponents', None, 1700), -(u'UnpublishFeatures', None, 1800), -(u'UnregisterClassInfo', None, 2700), -(u'UnregisterComPlus', None, 2100), -(u'UnregisterExtensionInfo', None, 2800), -(u'UnregisterFonts', None, 2500), -(u'UnregisterMIMEInfo', None, 3000), -(u'UnregisterProgIdInfo', None, 2900), -(u'UnregisterTypeLibraries', None, 2300), -(u'WriteEnvironmentStrings', None, 5200), -(u'WriteIniValues', None, 5100), -(u'WriteRegistryValues', None, 5000), -] - -InstallUISequence = [ -#(u'FileCost', None, 900), -#(u'CostInitialize', None, 800), -#(u'CostFinalize', None, 1000), -#(u'ExecuteAction', None, 1300), -#(u'ExitDialog', None, -1), -#(u'FatalError', None, -3), -(u'PrepareDlg', None, 140), -(u'ProgressDlg', None, 1280), -#(u'UserExit', None, -2), -(u'MaintenanceWelcomeDlg', u'Installed AND NOT RESUME AND NOT Preselected', 1250), -(u'ResumeDlg', u'Installed AND (RESUME OR Preselected)', 1240), -(u'WelcomeDlg', u'NOT Installed', 1230), -#(u'AppSearch', None, 400), -#(u'CCPSearch', u'NOT Installed', 500), -#(u'FindRelatedProducts', None, 200), -#(u'LaunchConditions', None, 100), -#(u'MigrateFeatureStates', None, 1200), -#(u'RMCCPSearch', u'NOT Installed', 600), -] - -ListView = [ -] - -RadioButton = [ -(u'IAgree', 1, u'Yes', 5, 0, 250, 15, u'{\\DlgFont8}I &accept the terms in the License Agreement', None), -(u'IAgree', 2, u'No', 5, 20, 250, 15, u'{\\DlgFont8}I &do not accept the terms in the License Agreement', None), -] - -TextStyle = [ -(u'DlgFont8', u'Tahoma', 8, None, 0), -(u'DlgFontBold8', u'Tahoma', 8, None, 1), -(u'VerdanaBold13', u'Verdana', 13, None, 1), -] - -UIText = [ -(u'AbsentPath', None), -(u'bytes', u'bytes'), -(u'GB', u'GB'), -(u'KB', u'KB'), -(u'MB', u'MB'), -(u'MenuAbsent', u'Entire feature will be unavailable'), -(u'MenuAdvertise', u'Feature will be installed when required'), -(u'MenuAllCD', u'Entire feature will be installed to run from CD'), -(u'MenuAllLocal', u'Entire feature will be installed on local hard drive'), -(u'MenuAllNetwork', u'Entire feature will be installed to run from network'), -(u'MenuCD', u'Will be installed to run from CD'), -(u'MenuLocal', u'Will be installed on local hard drive'), -(u'MenuNetwork', u'Will be installed to run from network'), -(u'ScriptInProgress', u'Gathering required information...'), -(u'SelAbsentAbsent', u'This feature will remain uninstalled'), -(u'SelAbsentAdvertise', u'This feature will be set to be installed when required'), -(u'SelAbsentCD', u'This feature will be installed to run from CD'), -(u'SelAbsentLocal', u'This feature will be installed on the local hard drive'), -(u'SelAbsentNetwork', u'This feature will be installed to run from the network'), -(u'SelAdvertiseAbsent', u'This feature will become unavailable'), -(u'SelAdvertiseAdvertise', u'Will be installed when required'), -(u'SelAdvertiseCD', u'This feature will be available to run from CD'), -(u'SelAdvertiseLocal', u'This feature will be installed on your local hard drive'), -(u'SelAdvertiseNetwork', u'This feature will be available to run from the network'), -(u'SelCDAbsent', u"This feature will be uninstalled completely, you won't be able to run it from CD"), -(u'SelCDAdvertise', u'This feature will change from run from CD state to set to be installed when required'), -(u'SelCDCD', u'This feature will remain to be run from CD'), -(u'SelCDLocal', u'This feature will change from run from CD state to be installed on the local hard drive'), -(u'SelChildCostNeg', u'This feature frees up [1] on your hard drive.'), -(u'SelChildCostPos', u'This feature requires [1] on your hard drive.'), -(u'SelCostPending', u'Compiling cost for this feature...'), -(u'SelLocalAbsent', u'This feature will be completely removed'), -(u'SelLocalAdvertise', u'This feature will be removed from your local hard drive, but will be set to be installed when required'), -(u'SelLocalCD', u'This feature will be removed from your local hard drive, but will be still available to run from CD'), -(u'SelLocalLocal', u'This feature will remain on you local hard drive'), -(u'SelLocalNetwork', u'This feature will be removed from your local hard drive, but will be still available to run from the network'), -(u'SelNetworkAbsent', u"This feature will be uninstalled completely, you won't be able to run it from the network"), -(u'SelNetworkAdvertise', u'This feature will change from run from network state to set to be installed when required'), -(u'SelNetworkLocal', u'This feature will change from run from network state to be installed on the local hard drive'), -(u'SelNetworkNetwork', u'This feature will remain to be run from the network'), -(u'SelParentCostNegNeg', u'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'), -(u'SelParentCostNegPos', u'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'), -(u'SelParentCostPosNeg', u'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'), -(u'SelParentCostPosPos', u'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'), -(u'TimeRemaining', u'Time remaining: {[1] minutes }{[2] seconds}'), -(u'VolumeCostAvailable', u'Available'), -(u'VolumeCostDifference', u'Difference'), -(u'VolumeCostRequired', u'Required'), -(u'VolumeCostSize', u'Disk Size'), -(u'VolumeCostVolume', u'Volume'), -] - -_Validation = [ -(u'AdminExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdminExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdminExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AdminUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdminUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdminUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'Condition', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Expression evaluated to determine if Level in the Feature table is to change.'), -(u'Condition', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Reference to a Feature entry in Feature table.'), -(u'Condition', u'Level', u'N', 0, 32767, None, None, None, None, u'New selection Level to set in Feature table if Condition evaluates to TRUE.'), -(u'AdvtExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdvtExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdvtExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'BBControl', u'Type', u'N', None, None, None, None, u'Identifier', None, u'The type of the control.'), -(u'BBControl', u'BBControl', u'N', None, None, None, None, u'Identifier', None, u'Name of the control. This name must be unique within a billboard, but can repeat on different billboard.'), -(u'BBControl', u'Billboard_', u'N', None, None, u'Billboard', 1, u'Identifier', None, u'External key to the Billboard table, name of the billboard.'), -(u'BBControl', u'X', u'N', 0, 32767, None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'BBControl', u'Y', u'N', 0, 32767, None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'BBControl', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the control.'), -(u'BBControl', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the control.'), -(u'BBControl', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.'), -(u'BBControl', u'Text', u'Y', None, None, None, None, u'Text', None, u'A string used to set the initial text contained within a control (if appropriate).'), -(u'Billboard', u'Action', u'Y', None, None, None, None, u'Identifier', None, u'The name of an action. The billboard is displayed during the progress messages received from this action.'), -(u'Billboard', u'Billboard', u'N', None, None, None, None, u'Identifier', None, u'Name of the billboard.'), -(u'Billboard', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'An external key to the Feature Table. The billboard is shown only if this feature is being installed.'), -(u'Billboard', u'Ordering', u'Y', 0, 32767, None, None, None, None, u'A positive integer. If there is more than one billboard corresponding to an action they will be shown in the order defined by this column.'), -(u'Binary', u'Name', u'N', None, None, None, None, u'Identifier', None, u'Unique key identifying the binary data.'), -(u'Binary', u'Data', u'N', None, None, None, None, u'Binary', None, u'The unformatted binary data.'), -(u'CheckBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to the item.'), -(u'CheckBox', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value string associated with the item.'), -(u'Property', u'Property', u'N', None, None, None, None, u'Identifier', None, u'Name of property, uppercase if settable by launcher or loader.'), -(u'Property', u'Value', u'N', None, None, None, None, u'Text', None, u'String value for property. Never null or empty.'), -(u'ComboBox', u'Text', u'Y', None, None, None, None, u'Formatted', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ComboBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same combobox.'), -(u'ComboBox', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ComboBox', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list.\tThe integers do not have to be consecutive.'), -(u'Control', u'Type', u'N', None, None, None, None, u'Identifier', None, u'The type of the control.'), -(u'Control', u'X', u'N', 0, 32767, None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'Control', u'Y', u'N', 0, 32767, None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.'), -(u'Control', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the control.'), -(u'Control', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the control.'), -(u'Control', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.'), -(u'Control', u'Text', u'Y', None, None, None, None, u'Formatted', None, u'A string used to set the initial text contained within a control (if appropriate).'), -(u'Control', u'Property', u'Y', None, None, None, None, u'Identifier', None, u'The name of a defined property to be linked to this control. '), -(u'Control', u'Control', u'N', None, None, None, None, u'Identifier', None, u'Name of the control. This name must be unique within a dialog, but can repeat on different dialogs. '), -(u'Control', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'External key to the Dialog table, name of the dialog.'), -(u'Control', u'Control_Next', u'Y', None, None, u'Control', 2, u'Identifier', None, u'The name of an other control on the same dialog. This link defines the tab order of the controls. The links have to form one or more cycles!'), -(u'Control', u'Help', u'Y', None, None, None, None, u'Text', None, u'The help strings used with the button. The text is optional. '), -(u'Icon', u'Name', u'N', None, None, None, None, u'Identifier', None, u'Primary key. Name of the icon file.'), -(u'Icon', u'Data', u'N', None, None, None, None, u'Binary', None, u'Binary stream. The binary icon data in PE (.DLL or .EXE) or icon (.ICO) format.'), -(u'ListBox', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ListBox', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listbox.'), -(u'ListBox', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ListBox', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'ActionText', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to be described.'), -(u'ActionText', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description displayed in progress dialog and log when action is executing.'), -(u'ActionText', u'Template', u'Y', None, None, None, None, u'Template', None, u'Optional localized format template used to format action data records for display during action execution.'), -(u'ControlCondition', u'Action', u'N', None, None, None, None, None, u'Default;Disable;Enable;Hide;Show', u'The desired action to be taken on the specified control.'), -(u'ControlCondition', u'Condition', u'N', None, None, None, None, u'Condition', None, u'A standard conditional statement that specifies under which conditions the action should be triggered.'), -(u'ControlCondition', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the dialog.'), -(u'ControlCondition', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control.'), -(u'ControlEvent', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'A standard conditional statement that specifies under which conditions an event should be triggered.'), -(u'ControlEvent', u'Ordering', u'Y', 0, 2147483647, None, None, None, None, u'An integer used to order several events tied to the same control. Can be left blank.'), -(u'ControlEvent', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the dialog.'), -(u'ControlEvent', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control'), -(u'ControlEvent', u'Event', u'N', None, None, None, None, u'Formatted', None, u'An identifier that specifies the type of the event that should take place when the user interacts with control specified by the first two entries.'), -(u'ControlEvent', u'Argument', u'N', None, None, None, None, u'Formatted', None, u'A value to be used as a modifier when triggering a particular event.'), -(u'Dialog', u'Width', u'N', 0, 32767, None, None, None, None, u'Width of the bounding rectangle of the dialog.'), -(u'Dialog', u'Height', u'N', 0, 32767, None, None, None, None, u'Height of the bounding rectangle of the dialog.'), -(u'Dialog', u'Attributes', u'Y', 0, 2147483647, None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this dialog.'), -(u'Dialog', u'Title', u'Y', None, None, None, None, u'Formatted', None, u"A text string specifying the title to be displayed in the title bar of the dialog's window."), -(u'Dialog', u'Dialog', u'N', None, None, None, None, u'Identifier', None, u'Name of the dialog.'), -(u'Dialog', u'HCentering', u'N', 0, 100, None, None, None, None, u'Horizontal position of the dialog on a 0-100 scale. 0 means left end, 100 means right end of the screen, 50 center.'), -(u'Dialog', u'VCentering', u'N', 0, 100, None, None, None, None, u'Vertical position of the dialog on a 0-100 scale. 0 means top end, 100 means bottom end of the screen, 50 center.'), -(u'Dialog', u'Control_First', u'N', None, None, u'Control', 2, u'Identifier', None, u'Defines the control that has the focus when the dialog is created.'), -(u'Dialog', u'Control_Default', u'Y', None, None, u'Control', 2, u'Identifier', None, u'Defines the default control. Hitting return is equivalent to pushing this button.'), -(u'Dialog', u'Control_Cancel', u'Y', None, None, u'Control', 2, u'Identifier', None, u'Defines the cancel control. Hitting escape or clicking on the close icon on the dialog is equivalent to pushing this button.'), -(u'EventMapping', u'Dialog_', u'N', None, None, u'Dialog', 1, u'Identifier', None, u'A foreign key to the Dialog table, name of the Dialog.'), -(u'EventMapping', u'Control_', u'N', None, None, u'Control', 2, u'Identifier', None, u'A foreign key to the Control table, name of the control.'), -(u'EventMapping', u'Event', u'N', None, None, None, None, u'Identifier', None, u'An identifier that specifies the type of the event that the control subscribes to.'), -(u'EventMapping', u'Attribute', u'N', None, None, None, None, u'Identifier', None, u'The name of the control attribute, that is set when this event is received.'), -(u'InstallExecuteSequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'InstallExecuteSequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'InstallExecuteSequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AppSearch', u'Property', u'N', None, None, None, None, u'Identifier', None, u'The property associated with a Signature'), -(u'AppSearch', u'Signature_', u'N', None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator', 1, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.'), -(u'BindImage', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'The index into the File table. This must be an executable file.'), -(u'BindImage', u'Path', u'Y', None, None, None, None, u'Paths', None, u'A list of ; delimited paths that represent the paths to be searched for the import DLLS. The list is usually a list of properties each enclosed within square brackets [] .'), -(u'CCPSearch', u'Signature_', u'N', None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator', 1, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.'), -(u'InstallUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'InstallUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'InstallUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'ListView', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.'), -(u'ListView', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listview.'), -(u'ListView', u'Value', u'N', None, None, None, None, u'Identifier', None, u'The value string associated with this item. Selecting the line will set the associated property to this value.'), -(u'ListView', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'ListView', u'Binary_', u'Y', None, None, u'Binary', 1, u'Identifier', None, u'The name of the icon to be displayed with the icon. The binary information is looked up from the Binary Table.'), -(u'RadioButton', u'X', u'N', 0, 32767, None, None, None, None, u'The horizontal coordinate of the upper left corner of the bounding rectangle of the radio button.'), -(u'RadioButton', u'Y', u'N', 0, 32767, None, None, None, None, u'The vertical coordinate of the upper left corner of the bounding rectangle of the radio button.'), -(u'RadioButton', u'Width', u'N', 0, 32767, None, None, None, None, u'The width of the button.'), -(u'RadioButton', u'Height', u'N', 0, 32767, None, None, None, None, u'The height of the button.'), -(u'RadioButton', u'Text', u'Y', None, None, None, None, u'Text', None, u'The visible title to be assigned to the radio button.'), -(u'RadioButton', u'Property', u'N', None, None, None, None, u'Identifier', None, u'A named property to be tied to this radio button. All the buttons tied to the same property become part of the same group.'), -(u'RadioButton', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value string associated with this button. Selecting the button will set the associated property to this value.'), -(u'RadioButton', u'Order', u'N', 1, 32767, None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.'), -(u'RadioButton', u'Help', u'Y', None, None, None, None, u'Text', None, u'The help strings used with the button. The text is optional.'), -(u'TextStyle', u'TextStyle', u'N', None, None, None, None, u'Identifier', None, u'Name of the style. The primary key of this table. This name is embedded in the texts to indicate a style change.'), -(u'TextStyle', u'FaceName', u'N', None, None, None, None, u'Text', None, u'A string indicating the name of the font used. Required. The string must be at most 31 characters long.'), -(u'TextStyle', u'Size', u'N', 0, 32767, None, None, None, None, u'The size of the font used. This size is given in our units (1/12 of the system font height). Assuming that the system font is set to 12 point size, this is equivalent to the point size.'), -(u'TextStyle', u'Color', u'Y', 0, 16777215, None, None, None, None, u'A long integer indicating the color of the string in the RGB format (Red, Green, Blue each 0-255, RGB = R + 256*G + 256^2*B).'), -(u'TextStyle', u'StyleBits', u'Y', 0, 15, None, None, None, None, u'A combination of style bits.'), -(u'UIText', u'Text', u'Y', None, None, None, None, u'Text', None, u'The localized version of the string.'), -(u'UIText', u'Key', u'N', None, None, None, None, u'Identifier', None, u'A unique key that identifies the particular string.'), -(u'_Validation', u'Table', u'N', None, None, None, None, u'Identifier', None, u'Name of table'), -(u'_Validation', u'Description', u'Y', None, None, None, None, u'Text', None, u'Description of column'), -(u'_Validation', u'Column', u'N', None, None, None, None, u'Identifier', None, u'Name of column'), -(u'_Validation', u'Nullable', u'N', None, None, None, None, None, u'Y;N;@', u'Whether the column is nullable'), -(u'_Validation', u'MinValue', u'Y', -2147483647, 2147483647, None, None, None, None, u'Minimum value allowed'), -(u'_Validation', u'MaxValue', u'Y', -2147483647, 2147483647, None, None, None, None, u'Maximum value allowed'), -(u'_Validation', u'KeyTable', u'Y', None, None, None, None, u'Identifier', None, u'For foreign key, Name of table to which data must link'), -(u'_Validation', u'KeyColumn', u'Y', 1, 32, None, None, None, None, u'Column to which foreign key connects'), -(u'_Validation', u'Category', u'Y', None, None, None, None, None, u'Text;Formatted;Template;Condition;Guid;Path;Version;Language;Identifier;Binary;UpperCase;LowerCase;Filename;Paths;AnyPath;WildCardFilename;RegPath;KeyFormatted;CustomSource;Property;Cabinet;Shortcut;URL', u'String category'), -(u'_Validation', u'Set', u'Y', None, None, None, None, u'Text', None, u'Set of values that are permitted'), -(u'AdvtUISequence', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Name of action to invoke, either in the engine or the handler DLL.'), -(u'AdvtUISequence', u'Sequence', u'Y', -4, 32767, None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.'), -(u'AdvtUISequence', u'Condition', u'Y', None, None, None, None, u'Condition', None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.'), -(u'AppId', u'AppId', u'N', None, None, None, None, u'Guid', None, None), -(u'AppId', u'ActivateAtStorage', u'Y', 0, 1, None, None, None, None, None), -(u'AppId', u'DllSurrogate', u'Y', None, None, None, None, u'Text', None, None), -(u'AppId', u'LocalService', u'Y', None, None, None, None, u'Text', None, None), -(u'AppId', u'RemoteServerName', u'Y', None, None, None, None, u'Formatted', None, None), -(u'AppId', u'RunAsInteractiveUser', u'Y', 0, 1, None, None, None, None, None), -(u'AppId', u'ServiceParameters', u'Y', None, None, None, None, u'Text', None, None), -(u'Feature', u'Attributes', u'N', None, None, None, None, None, u'0;1;2;4;5;6;8;9;10;16;17;18;20;21;22;24;25;26;32;33;34;36;37;38;48;49;50;52;53;54', u'Feature attributes'), -(u'Feature', u'Description', u'Y', None, None, None, None, u'Text', None, u'Longer descriptive text describing a visible feature item.'), -(u'Feature', u'Title', u'Y', None, None, None, None, u'Text', None, u'Short text identifying a visible feature item.'), -(u'Feature', u'Feature', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular feature record.'), -(u'Feature', u'Directory_', u'Y', None, None, u'Directory', 1, u'UpperCase', None, u'The name of the Directory that can be configured by the UI. A non-null value will enable the browse button.'), -(u'Feature', u'Level', u'N', 0, 32767, None, None, None, None, u'The install level at which record will be initially selected. An install level of 0 will disable an item and prevent its display.'), -(u'Feature', u'Display', u'Y', 0, 32767, None, None, None, None, u'Numeric sort order, used to force a specific display ordering.'), -(u'Feature', u'Feature_Parent', u'Y', None, None, u'Feature', 1, u'Identifier', None, u'Optional key of a parent record in the same table. If the parent is not selected, then the record will not be installed. Null indicates a root item.'), -(u'File', u'Sequence', u'N', 1, 32767, None, None, None, None, u'Sequence with respect to the media images; order must track cabinet order.'), -(u'File', u'Attributes', u'Y', 0, 32767, None, None, None, None, u'Integer containing bit flags representing file attributes (with the decimal value of each bit position in parentheses)'), -(u'File', u'File', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token, must match identifier in cabinet. For uncompressed files, this field is ignored.'), -(u'File', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the file.'), -(u'File', u'FileName', u'N', None, None, None, None, u'Filename', None, u'File name used for installation, may be localized. This may contain a "short name|long name" pair.'), -(u'File', u'FileSize', u'N', 0, 2147483647, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'File', u'Language', u'Y', None, None, None, None, u'Language', None, u'List of decimal language Ids, comma-separated if more than one.'), -(u'File', u'Version', u'Y', None, None, u'File', 1, u'Version', None, u'Version string for versioned files; Blank for unversioned files.'), -(u'Class', u'Attributes', u'Y', None, 32767, None, None, None, None, u'Class registration attributes.'), -(u'Class', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.'), -(u'Class', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description for the Class.'), -(u'Class', u'Argument', u'Y', None, None, None, None, u'Formatted', None, u'optional argument for LocalServers.'), -(u'Class', u'AppId_', u'Y', None, None, u'AppId', 1, u'Guid', None, u'Optional AppID containing DCOM information for associated application (string GUID).'), -(u'Class', u'CLSID', u'N', None, None, None, None, u'Guid', None, u'The CLSID of an OLE factory.'), -(u'Class', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'Class', u'Context', u'N', None, None, None, None, u'Identifier', None, u'The numeric server context for this server. CLSCTX_xxxx'), -(u'Class', u'DefInprocHandler', u'Y', None, None, None, None, u'Filename', u'1;2;3', u'Optional default inproc handler. Only optionally provided if Context=CLSCTX_LOCAL_SERVER. Typically "ole32.dll" or "mapi32.dll"'), -(u'Class', u'FileTypeMask', u'Y', None, None, None, None, u'Text', None, u'Optional string containing information for the HKCRthis CLSID) key. If multiple patterns exist, they must be delimited by a semicolon, and numeric subkeys will be generated: 0,1,2...'), -(u'Class', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this CLSID. Will be written under the DefaultIcon key.'), -(u'Class', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'Optional icon index.'), -(u'Class', u'ProgId_Default', u'Y', None, None, u'ProgId', 1, u'Text', None, u'Optional ProgId associated with this CLSID.'), -(u'Component', u'Condition', u'Y', None, None, None, None, u'Condition', None, u"A conditional statement that will disable this component if the specified condition evaluates to the 'True' state. If a component is disabled, it will not be installed, regardless of the 'Action' state associated with the component."), -(u'Component', u'Attributes', u'N', None, None, None, None, None, None, u'Remote execution option, one of irsEnum'), -(u'Component', u'Component', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular component record.'), -(u'Component', u'ComponentId', u'Y', None, None, None, None, u'Guid', None, u'A string GUID unique to this component, version, and language.'), -(u'Component', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Required key of a Directory table record. This is actually a property name whose value contains the actual path, set either by the AppSearch action or with the default setting obtained from the Directory table.'), -(u'Component', u'KeyPath', u'Y', None, None, u'File;Registry;ODBCDataSource', 1, u'Identifier', None, u'Either the primary key into the File table, Registry table, or ODBCDataSource table. This extract path is stored when the component is installed, and is used to detect the presence of the component and to return the path to it.'), -(u'ProgId', u'Description', u'Y', None, None, None, None, u'Text', None, u'Localized description for the Program identifier.'), -(u'ProgId', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this ProgId. Will be written under the DefaultIcon key.'), -(u'ProgId', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'Optional icon index.'), -(u'ProgId', u'ProgId', u'N', None, None, None, None, u'Text', None, u'The Program Identifier. Primary key.'), -(u'ProgId', u'Class_', u'Y', None, None, u'Class', 1, u'Guid', None, u'The CLSID of an OLE factory corresponding to the ProgId.'), -(u'ProgId', u'ProgId_Parent', u'Y', None, None, u'ProgId', 1, u'Text', None, u'The Parent Program Identifier. If specified, the ProgId column becomes a version independent prog id.'), -(u'CompLocator', u'Type', u'Y', 0, 1, None, None, None, None, u'A boolean value that determines if the registry value is a filename or a directory location.'), -(u'CompLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'CompLocator', u'ComponentId', u'N', None, None, None, None, u'Guid', None, u'A string GUID unique to this component, version, and language.'), -(u'Complus', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the ComPlus component.'), -(u'Complus', u'ExpType', u'Y', 0, 32767, None, None, None, None, u'ComPlus component attributes.'), -(u'Directory', u'Directory', u'N', None, None, None, None, u'Identifier', None, u'Unique identifier for directory entry, primary key. If a property by this name is defined, it contains the full path to the directory.'), -(u'Directory', u'DefaultDir', u'N', None, None, None, None, u'DefaultDir', None, u"The default sub-path under parent's path."), -(u'Directory', u'Directory_Parent', u'Y', None, None, u'Directory', 1, u'Identifier', None, u'Reference to the entry in this table specifying the default parent directory. A record parented to itself or with a Null parent represents a root of the install tree.'), -(u'CreateFolder', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table.'), -(u'CreateFolder', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Primary key, could be foreign key into the Directory table.'), -(u'CustomAction', u'Type', u'N', 1, 16383, None, None, None, None, u'The numeric custom action type, consisting of source location, code type, entry, option flags.'), -(u'CustomAction', u'Action', u'N', None, None, None, None, u'Identifier', None, u'Primary key, name of action, normally appears in sequence table unless private use.'), -(u'CustomAction', u'Source', u'Y', None, None, None, None, u'CustomSource', None, u'The table reference of the source of the code.'), -(u'CustomAction', u'Target', u'Y', None, None, None, None, u'Formatted', None, u'Excecution parameter, depends on the type of custom action'), -(u'DrLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'DrLocator', u'Path', u'Y', None, None, None, None, u'AnyPath', None, u'The path on the user system. This is a either a subpath below the value of the Parent or a full path. The path may contain properties enclosed within [ ] that will be expanded.'), -(u'DrLocator', u'Depth', u'Y', 0, 32767, None, None, None, None, u'The depth below the path to which the Signature_ is recursively searched. If absent, the depth is assumed to be 0.'), -(u'DrLocator', u'Parent', u'Y', None, None, None, None, u'Identifier', None, u'The parent file signature. It is also a foreign key in the Signature table. If null and the Path column does not expand to a full path, then all the fixed drives of the user system are searched using the Path.'), -(u'DuplicateFile', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Foreign key referencing the source file to be duplicated.'), -(u'DuplicateFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the duplicate file.'), -(u'DuplicateFile', u'DestFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full pathname to a destination folder.'), -(u'DuplicateFile', u'DestName', u'Y', None, None, None, None, u'Filename', None, u'Filename to be given to the duplicate file.'), -(u'DuplicateFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular file entry'), -(u'Environment', u'Name', u'N', None, None, None, None, u'Text', None, u'The name of the environmental value.'), -(u'Environment', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value to set in the environmental settings.'), -(u'Environment', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the environmental value.'), -(u'Environment', u'Environment', u'N', None, None, None, None, u'Identifier', None, u'Unique identifier for the environmental variable setting'), -(u'Error', u'Error', u'N', 0, 32767, None, None, None, None, u'Integer error number, obtained from header file IError(...) macros.'), -(u'Error', u'Message', u'Y', None, None, None, None, u'Template', None, u'Error formatting template, obtained from user ed. or localizers.'), -(u'Extension', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.'), -(u'Extension', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'Extension', u'Extension', u'N', None, None, None, None, u'Text', None, u'The extension associated with the table row.'), -(u'Extension', u'MIME_', u'Y', None, None, u'MIME', 1, u'Text', None, u'Optional Context identifier, typically "type/format" associated with the extension'), -(u'Extension', u'ProgId_', u'Y', None, None, u'ProgId', 1, u'Text', None, u'Optional ProgId associated with this extension.'), -(u'MIME', u'CLSID', u'Y', None, None, None, None, u'Guid', None, u'Optional associated CLSID.'), -(u'MIME', u'ContentType', u'N', None, None, None, None, u'Text', None, u'Primary key. Context identifier, typically "type/format".'), -(u'MIME', u'Extension_', u'N', None, None, u'Extension', 1, u'Text', None, u'Optional associated extension (without dot)'), -(u'FeatureComponents', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into Feature table.'), -(u'FeatureComponents', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'FileSFPCatalog', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'File associated with the catalog'), -(u'FileSFPCatalog', u'SFPCatalog_', u'N', None, None, u'SFPCatalog', 1, u'Filename', None, u'Catalog associated with the file'), -(u'SFPCatalog', u'SFPCatalog', u'N', None, None, None, None, u'Filename', None, u'File name for the catalog.'), -(u'SFPCatalog', u'Catalog', u'N', None, None, None, None, u'Binary', None, u'SFP Catalog'), -(u'SFPCatalog', u'Dependency', u'Y', None, None, None, None, u'Formatted', None, u'Parent catalog - only used by SFP'), -(u'Font', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Primary key, foreign key into File table referencing font file.'), -(u'Font', u'FontTitle', u'Y', None, None, None, None, u'Text', None, u'Font name.'), -(u'IniFile', u'Action', u'N', None, None, None, None, None, u'0;1;3', u'The type of modification to be made, one of iifEnum'), -(u'IniFile', u'Value', u'N', None, None, None, None, u'Formatted', None, u'The value to be written.'), -(u'IniFile', u'Key', u'N', None, None, None, None, u'Formatted', None, u'The .INI file key below Section.'), -(u'IniFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the .INI value.'), -(u'IniFile', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name in which to write the information'), -(u'IniFile', u'IniFile', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'IniFile', u'DirProperty', u'Y', None, None, None, None, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the .INI file is.'), -(u'IniFile', u'Section', u'N', None, None, None, None, u'Formatted', None, u'The .INI file Section.'), -(u'IniLocator', u'Type', u'Y', 0, 2, None, None, None, None, u'An integer value that determines if the .INI value read is a filename or a directory location or to be used as is w/o interpretation.'), -(u'IniLocator', u'Key', u'N', None, None, None, None, u'Text', None, u'Key value (followed by an equals sign in INI file).'), -(u'IniLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.'), -(u'IniLocator', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name.'), -(u'IniLocator', u'Section', u'N', None, None, None, None, u'Text', None, u'Section name within in file (within square brackets in INI file).'), -(u'IniLocator', u'Field', u'Y', 0, 32767, None, None, None, None, u'The field in the .INI line. If Field is null or 0 the entire line is read.'), -(u'IsolatedComponent', u'Component_Application', u'N', None, None, u'Component', 1, u'Identifier', None, u'Key to Component table item for application'), -(u'IsolatedComponent', u'Component_Shared', u'N', None, None, u'Component', 1, u'Identifier', None, u'Key to Component table item to be isolated'), -(u'LaunchCondition', u'Condition', u'N', None, None, None, None, u'Condition', None, u'Expression which must evaluate to TRUE in order for install to commence.'), -(u'LaunchCondition', u'Description', u'N', None, None, None, None, u'Formatted', None, u'Localizable text to display when condition fails and install must abort.'), -(u'LockPermissions', u'Table', u'N', None, None, None, None, u'Identifier', u'Directory;File;Registry', u'Reference to another table name'), -(u'LockPermissions', u'Domain', u'Y', None, None, None, None, u'Formatted', None, u'Domain name for user whose permissions are being set. (usually a property)'), -(u'LockPermissions', u'LockObject', u'N', None, None, None, None, u'Identifier', None, u'Foreign key into Registry or File table'), -(u'LockPermissions', u'Permission', u'Y', -2147483647, 2147483647, None, None, None, None, u'Permission Access mask. Full Control = 268435456 (GENERIC_ALL = 0x10000000)'), -(u'LockPermissions', u'User', u'N', None, None, None, None, u'Formatted', None, u'User for permissions to be set. (usually a property)'), -(u'Media', u'Source', u'Y', None, None, None, None, u'Property', None, u'The property defining the location of the cabinet file.'), -(u'Media', u'Cabinet', u'Y', None, None, None, None, u'Cabinet', None, u'If some or all of the files stored on the media are compressed in a cabinet, the name of that cabinet.'), -(u'Media', u'DiskId', u'N', 1, 32767, None, None, None, None, u'Primary key, integer to determine sort order for table.'), -(u'Media', u'DiskPrompt', u'Y', None, None, None, None, u'Text', None, u'Disk name: the visible text actually printed on the disk. This will be used to prompt the user when this disk needs to be inserted.'), -(u'Media', u'LastSequence', u'N', 0, 32767, None, None, None, None, u'File sequence number for the last file for this media.'), -(u'Media', u'VolumeLabel', u'Y', None, None, None, None, u'Text', None, u'The label attributed to the volume.'), -(u'ModuleComponents', u'Component', u'N', None, None, u'Component', 1, u'Identifier', None, u'Component contained in the module.'), -(u'ModuleComponents', u'Language', u'N', None, None, u'ModuleSignature', 2, None, None, u'Default language ID for module (may be changed by transform).'), -(u'ModuleComponents', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'Module containing the component.'), -(u'ModuleSignature', u'Language', u'N', None, None, None, None, None, None, u'Default decimal language of module.'), -(u'ModuleSignature', u'Version', u'N', None, None, None, None, u'Version', None, u'Version of the module.'), -(u'ModuleSignature', u'ModuleID', u'N', None, None, None, None, u'Identifier', None, u'Module identifier (String.GUID).'), -(u'ModuleDependency', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'Module requiring the dependency.'), -(u'ModuleDependency', u'ModuleLanguage', u'N', None, None, u'ModuleSignature', 2, None, None, u'Language of module requiring the dependency.'), -(u'ModuleDependency', u'RequiredID', u'N', None, None, None, None, None, None, u'String.GUID of required module.'), -(u'ModuleDependency', u'RequiredLanguage', u'N', None, None, None, None, None, None, u'LanguageID of the required module.'), -(u'ModuleDependency', u'RequiredVersion', u'Y', None, None, None, None, u'Version', None, u'Version of the required version.'), -(u'ModuleExclusion', u'ModuleID', u'N', None, None, u'ModuleSignature', 1, u'Identifier', None, u'String.GUID of module with exclusion requirement.'), -(u'ModuleExclusion', u'ModuleLanguage', u'N', None, None, u'ModuleSignature', 2, None, None, u'LanguageID of module with exclusion requirement.'), -(u'ModuleExclusion', u'ExcludedID', u'N', None, None, None, None, None, None, u'String.GUID of excluded module.'), -(u'ModuleExclusion', u'ExcludedLanguage', u'N', None, None, None, None, None, None, u'Language of excluded module.'), -(u'ModuleExclusion', u'ExcludedMaxVersion', u'Y', None, None, None, None, u'Version', None, u'Maximum version of excluded module.'), -(u'ModuleExclusion', u'ExcludedMinVersion', u'Y', None, None, None, None, u'Version', None, u'Minimum version of excluded module.'), -(u'MoveFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'If this component is not "selected" for installation or removal, no action will be taken on the associated MoveFile entry'), -(u'MoveFile', u'DestFolder', u'N', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory'), -(u'MoveFile', u'DestName', u'Y', None, None, None, None, u'Filename', None, u'Name to be given to the original file after it is moved or copied. If blank, the destination file will be given the same name as the source file'), -(u'MoveFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key that uniquely identifies a particular MoveFile record'), -(u'MoveFile', u'Options', u'N', 0, 1, None, None, None, None, u'Integer value specifying the MoveFile operating mode, one of imfoEnum'), -(u'MoveFile', u'SourceFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the source directory'), -(u'MoveFile', u'SourceName', u'Y', None, None, None, None, u'Text', None, u"Name of the source file(s) to be moved or copied. Can contain the '*' or '?' wildcards."), -(u'MsiAssembly', u'Attributes', u'Y', None, None, None, None, None, None, u'Assembly attributes'), -(u'MsiAssembly', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into Feature table.'), -(u'MsiAssembly', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'MsiAssembly', u'File_Application', u'Y', None, None, u'File', 1, u'Identifier', None, u'Foreign key into File table, denoting the application context for private assemblies. Null for global assemblies.'), -(u'MsiAssembly', u'File_Manifest', u'Y', None, None, u'File', 1, u'Identifier', None, u'Foreign key into the File table denoting the manifest file for the assembly.'), -(u'MsiAssemblyName', u'Name', u'N', None, None, None, None, u'Text', None, u'The name part of the name-value pairs for the assembly name.'), -(u'MsiAssemblyName', u'Value', u'N', None, None, None, None, u'Text', None, u'The value part of the name-value pairs for the assembly name.'), -(u'MsiAssemblyName', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into Component table.'), -(u'MsiDigitalCertificate', u'CertData', u'N', None, None, None, None, u'Binary', None, u'A certificate context blob for a signer certificate'), -(u'MsiDigitalCertificate', u'DigitalCertificate', u'N', None, None, None, None, u'Identifier', None, u'A unique identifier for the row'), -(u'MsiDigitalSignature', u'Table', u'N', None, None, None, None, None, u'Media', u'Reference to another table name (only Media table is supported)'), -(u'MsiDigitalSignature', u'DigitalCertificate_', u'N', None, None, u'MsiDigitalCertificate', 1, u'Identifier', None, u'Foreign key to MsiDigitalCertificate table identifying the signer certificate'), -(u'MsiDigitalSignature', u'Hash', u'Y', None, None, None, None, u'Binary', None, u'The encoded hash blob from the digital signature'), -(u'MsiDigitalSignature', u'SignObject', u'N', None, None, None, None, u'Text', None, u'Foreign key to Media table'), -(u'MsiFileHash', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Primary key, foreign key into File table referencing file with this hash'), -(u'MsiFileHash', u'Options', u'N', 0, 32767, None, None, None, None, u'Various options and attributes for this hash.'), -(u'MsiFileHash', u'HashPart1', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart2', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart3', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiFileHash', u'HashPart4', u'N', None, None, None, None, None, None, u'Size of file in bytes (long integer).'), -(u'MsiPatchHeaders', u'StreamRef', u'N', None, None, None, None, u'Identifier', None, u'Primary key. A unique identifier for the row.'), -(u'MsiPatchHeaders', u'Header', u'N', None, None, None, None, u'Binary', None, u'Binary stream. The patch header, used for patch validation.'), -(u'ODBCAttribute', u'Value', u'Y', None, None, None, None, u'Text', None, u'Value for ODBC driver attribute'), -(u'ODBCAttribute', u'Attribute', u'N', None, None, None, None, u'Text', None, u'Name of ODBC driver attribute'), -(u'ODBCAttribute', u'Driver_', u'N', None, None, u'ODBCDriver', 1, u'Identifier', None, u'Reference to ODBC driver in ODBCDriver table'), -(u'ODBCDriver', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for driver, non-localized'), -(u'ODBCDriver', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Reference to key driver file'), -(u'ODBCDriver', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCDriver', u'Driver', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for driver'), -(u'ODBCDriver', u'File_Setup', u'Y', None, None, u'File', 1, u'Identifier', None, u'Optional reference to key driver setup DLL'), -(u'ODBCDataSource', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for data source'), -(u'ODBCDataSource', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCDataSource', u'DataSource', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for data source'), -(u'ODBCDataSource', u'DriverDescription', u'N', None, None, None, None, u'Text', None, u'Reference to driver description, may be existing driver'), -(u'ODBCDataSource', u'Registration', u'N', 0, 1, None, None, None, None, u'Registration option: 0=machine, 1=user, others t.b.d.'), -(u'ODBCSourceAttribute', u'Value', u'Y', None, None, None, None, u'Text', None, u'Value for ODBC data source attribute'), -(u'ODBCSourceAttribute', u'Attribute', u'N', None, None, None, None, u'Text', None, u'Name of ODBC data source attribute'), -(u'ODBCSourceAttribute', u'DataSource_', u'N', None, None, u'ODBCDataSource', 1, u'Identifier', None, u'Reference to ODBC data source in ODBCDataSource table'), -(u'ODBCTranslator', u'Description', u'N', None, None, None, None, u'Text', None, u'Text used as registered name for translator'), -(u'ODBCTranslator', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Reference to key translator file'), -(u'ODBCTranslator', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reference to associated component'), -(u'ODBCTranslator', u'File_Setup', u'Y', None, None, u'File', 1, u'Identifier', None, u'Optional reference to key translator setup DLL'), -(u'ODBCTranslator', u'Translator', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized.internal token for translator'), -(u'Patch', u'Sequence', u'N', 0, 32767, None, None, None, None, u'Primary key, sequence with respect to the media images; order must track cabinet order.'), -(u'Patch', u'Attributes', u'N', 0, 32767, None, None, None, None, u'Integer containing bit flags representing patch attributes'), -(u'Patch', u'File_', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token, foreign key to File table, must match identifier in cabinet.'), -(u'Patch', u'Header', u'Y', None, None, None, None, u'Binary', None, u'Binary stream. The patch header, used for patch validation.'), -(u'Patch', u'PatchSize', u'N', 0, 2147483647, None, None, None, None, u'Size of patch in bytes (long integer).'), -(u'Patch', u'StreamRef_', u'Y', None, None, None, None, u'Identifier', None, u'Identifier. Foreign key to the StreamRef column of the MsiPatchHeaders table.'), -(u'PatchPackage', u'Media_', u'N', 0, 32767, None, None, None, None, u'Foreign key to DiskId column of Media table. Indicates the disk containing the patch package.'), -(u'PatchPackage', u'PatchId', u'N', None, None, None, None, u'Guid', None, u'A unique string GUID representing this patch.'), -(u'PublishComponent', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Foreign key into the Feature table.'), -(u'PublishComponent', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table.'), -(u'PublishComponent', u'ComponentId', u'N', None, None, None, None, u'Guid', None, u'A string GUID that represents the component id that will be requested by the alien product.'), -(u'PublishComponent', u'AppData', u'Y', None, None, None, None, u'Text', None, u'This is localisable Application specific data that can be associated with a Qualified Component.'), -(u'PublishComponent', u'Qualifier', u'N', None, None, None, None, u'Text', None, u'This is defined only when the ComponentId column is an Qualified Component Id. This is the Qualifier for ProvideComponentIndirect.'), -(u'Registry', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'Registry', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The registry value.'), -(u'Registry', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'Registry', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the installing of the registry value.'), -(u'Registry', u'Registry', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'Registry', u'Root', u'N', -1, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.'), -(u'RegLocator', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'RegLocator', u'Type', u'Y', 0, 18, None, None, None, None, u'An integer value that determines if the registry value is a filename or a directory location or to be used as is w/o interpretation.'), -(u'RegLocator', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'RegLocator', u'Signature_', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table. If the type is 0, the registry values refers a directory, and _Signature is not a foreign key.'), -(u'RegLocator', u'Root', u'N', 0, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.'), -(u'RemoveFile', u'InstallMode', u'N', None, None, None, None, None, u'1;2;3', u'Installation option, one of iimEnum.'), -(u'RemoveFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key referencing Component that controls the file to be removed.'), -(u'RemoveFile', u'FileKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key used to identify a particular file entry'), -(u'RemoveFile', u'FileName', u'Y', None, None, None, None, u'WildCardFilename', None, u'Name of the file to be removed.'), -(u'RemoveFile', u'DirProperty', u'N', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full pathname to the folder of the file to be removed.'), -(u'RemoveIniFile', u'Action', u'N', None, None, None, None, None, u'2;4', u'The type of modification to be made, one of iifEnum.'), -(u'RemoveIniFile', u'Value', u'Y', None, None, None, None, u'Formatted', None, u'The value to be deleted. The value is required when Action is iifIniRemoveTag'), -(u'RemoveIniFile', u'Key', u'N', None, None, None, None, u'Formatted', None, u'The .INI file key below Section.'), -(u'RemoveIniFile', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the deletion of the .INI value.'), -(u'RemoveIniFile', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The .INI file name in which to delete the information'), -(u'RemoveIniFile', u'DirProperty', u'Y', None, None, None, None, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the .INI file is.'), -(u'RemoveIniFile', u'Section', u'N', None, None, None, None, u'Formatted', None, u'The .INI file Section.'), -(u'RemoveIniFile', u'RemoveIniFile', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'RemoveRegistry', u'Name', u'Y', None, None, None, None, u'Formatted', None, u'The registry value name.'), -(u'RemoveRegistry', u'Key', u'N', None, None, None, None, u'RegPath', None, u'The key for the registry value.'), -(u'RemoveRegistry', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table referencing component that controls the deletion of the registry value.'), -(u'RemoveRegistry', u'Root', u'N', -1, 3, None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum'), -(u'RemoveRegistry', u'RemoveRegistry', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ReserveCost', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Reserve a specified amount of space if this component is to be installed.'), -(u'ReserveCost', u'ReserveFolder', u'Y', None, None, None, None, u'Identifier', None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory'), -(u'ReserveCost', u'ReserveKey', u'N', None, None, None, None, u'Identifier', None, u'Primary key that uniquely identifies a particular ReserveCost record'), -(u'ReserveCost', u'ReserveLocal', u'N', 0, 2147483647, None, None, None, None, u'Disk space to reserve if linked component is installed locally.'), -(u'ReserveCost', u'ReserveSource', u'N', 0, 2147483647, None, None, None, None, u'Disk space to reserve if linked component is installed to run from the source location.'), -(u'SelfReg', u'File_', u'N', None, None, u'File', 1, u'Identifier', None, u'Foreign key into the File table denoting the module that needs to be registered.'), -(u'SelfReg', u'Cost', u'Y', 0, 32767, None, None, None, None, u'The cost of registering the module.'), -(u'ServiceControl', u'Name', u'N', None, None, None, None, u'Formatted', None, u'Name of a service. /, \\, comma and space are invalid'), -(u'ServiceControl', u'Event', u'N', 0, 187, None, None, None, None, u'Bit field: Install: 0x1 = Start, 0x2 = Stop, 0x8 = Delete, Uninstall: 0x10 = Start, 0x20 = Stop, 0x80 = Delete'), -(u'ServiceControl', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table that controls the startup of the service'), -(u'ServiceControl', u'ServiceControl', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ServiceControl', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'Arguments for the service. Separate by [~].'), -(u'ServiceControl', u'Wait', u'Y', 0, 1, None, None, None, None, u'Boolean for whether to wait for the service to fully start'), -(u'ServiceInstall', u'Name', u'N', None, None, None, None, u'Formatted', None, u'Internal Name of the Service'), -(u'ServiceInstall', u'Description', u'Y', None, None, None, None, u'Text', None, u'Description of service.'), -(u'ServiceInstall', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table that controls the startup of the service'), -(u'ServiceInstall', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'Arguments to include in every start of the service, passed to WinMain'), -(u'ServiceInstall', u'ServiceInstall', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'ServiceInstall', u'Dependencies', u'Y', None, None, None, None, u'Formatted', None, u'Other services this depends on to start. Separate by [~], and end with [~][~]'), -(u'ServiceInstall', u'DisplayName', u'Y', None, None, None, None, u'Formatted', None, u'External Name of the Service'), -(u'ServiceInstall', u'ErrorControl', u'N', -2147483647, 2147483647, None, None, None, None, u'Severity of error if service fails to start'), -(u'ServiceInstall', u'LoadOrderGroup', u'Y', None, None, None, None, u'Formatted', None, u'LoadOrderGroup'), -(u'ServiceInstall', u'Password', u'Y', None, None, None, None, u'Formatted', None, u'password to run service with. (with StartName)'), -(u'ServiceInstall', u'ServiceType', u'N', -2147483647, 2147483647, None, None, None, None, u'Type of the service'), -(u'ServiceInstall', u'StartName', u'Y', None, None, None, None, u'Formatted', None, u'User or object name to run service as'), -(u'ServiceInstall', u'StartType', u'N', 0, 4, None, None, None, None, u'Type of the service'), -(u'Shortcut', u'Name', u'N', None, None, None, None, u'Filename', None, u'The name of the shortcut to be created.'), -(u'Shortcut', u'Description', u'Y', None, None, None, None, u'Text', None, u'The description for the shortcut.'), -(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.'), -(u'Shortcut', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Foreign key into the File table denoting the external icon file for the shortcut.'), -(u'Shortcut', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'The icon index for the shortcut.'), -(u'Shortcut', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.'), -(u'Shortcut', u'Target', u'N', None, None, None, None, u'Shortcut', None, u'The shortcut target. This is usually a property that is expanded to a file or a folder that the shortcut points to.'), -(u'Shortcut', u'Arguments', u'Y', None, None, None, None, u'Formatted', None, u'The command-line arguments for the shortcut.'), -(u'Shortcut', u'Shortcut', u'N', None, None, None, None, u'Identifier', None, u'Primary key, non-localized token.'), -(u'Shortcut', u'Hotkey', u'Y', 0, 32767, None, None, None, None, u'The hotkey for the shortcut. It has the virtual-key code for the key in the low-order byte, and the modifier flags in the high-order byte. '), -(u'Shortcut', u'ShowCmd', u'Y', None, None, None, None, None, u'1;3;7', u'The show command for the application window.The following values may be used.'), -(u'Shortcut', u'WkDir', u'Y', None, None, None, None, u'Identifier', None, u'Name of property defining location of working directory.'), -(u'Signature', u'FileName', u'N', None, None, None, None, u'Filename', None, u'The name of the file. This may contain a "short name|long name" pair.'), -(u'Signature', u'Signature', u'N', None, None, None, None, u'Identifier', None, u'The table key. The Signature represents a unique file signature.'), -(u'Signature', u'Languages', u'Y', None, None, None, None, u'Language', None, u'The languages supported by the file.'), -(u'Signature', u'MaxDate', u'Y', 0, 2147483647, None, None, None, None, u'The maximum creation date of the file.'), -(u'Signature', u'MaxSize', u'Y', 0, 2147483647, None, None, None, None, u'The maximum size of the file. '), -(u'Signature', u'MaxVersion', u'Y', None, None, None, None, u'Text', None, u'The maximum version of the file.'), -(u'Signature', u'MinDate', u'Y', 0, 2147483647, None, None, None, None, u'The minimum creation date of the file.'), -(u'Signature', u'MinSize', u'Y', 0, 2147483647, None, None, None, None, u'The minimum size of the file.'), -(u'Signature', u'MinVersion', u'Y', None, None, None, None, u'Text', None, u'The minimum version of the file.'), -(u'TypeLib', u'Feature_', u'N', None, None, u'Feature', 1, u'Identifier', None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the type library to be operational.'), -(u'TypeLib', u'Description', u'Y', None, None, None, None, u'Text', None, None), -(u'TypeLib', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.'), -(u'TypeLib', u'Directory_', u'Y', None, None, u'Directory', 1, u'Identifier', None, u'Optional. The foreign key into the Directory table denoting the path to the help file for the type library.'), -(u'TypeLib', u'Language', u'N', 0, 32767, None, None, None, None, u'The language of the library.'), -(u'TypeLib', u'Version', u'Y', 0, 16777215, None, None, None, None, u'The version of the library. The minor version is in the lower 8 bits of the integer. The major version is in the next 16 bits. '), -(u'TypeLib', u'Cost', u'Y', 0, 2147483647, None, None, None, None, u'The cost associated with the registration of the typelib. This column is currently optional.'), -(u'TypeLib', u'LibID', u'N', None, None, None, None, u'Guid', None, u'The GUID that represents the library.'), -(u'Upgrade', u'Attributes', u'N', 0, 2147483647, None, None, None, None, u'The attributes of this product set.'), -(u'Upgrade', u'Remove', u'Y', None, None, None, None, u'Formatted', None, u'The list of features to remove when uninstalling a product from this set. The default is "ALL".'), -(u'Upgrade', u'Language', u'Y', None, None, None, None, u'Language', None, u'A comma-separated list of languages for either products in this set or products not in this set.'), -(u'Upgrade', u'ActionProperty', u'N', None, None, None, None, u'UpperCase', None, u'The property to set when a product in this set is found.'), -(u'Upgrade', u'UpgradeCode', u'N', None, None, None, None, u'Guid', None, u'The UpgradeCode GUID belonging to the products in this set.'), -(u'Upgrade', u'VersionMax', u'Y', None, None, None, None, u'Text', None, u'The maximum ProductVersion of the products in this set. The set may or may not include products with this particular version.'), -(u'Upgrade', u'VersionMin', u'Y', None, None, None, None, u'Text', None, u'The minimum ProductVersion of the products in this set. The set may or may not include products with this particular version.'), -(u'Verb', u'Sequence', u'Y', 0, 32767, None, None, None, None, u'Order within the verbs for a particular extension. Also used simply to specify the default verb.'), -(u'Verb', u'Argument', u'Y', None, None, None, None, u'Formatted', None, u'Optional value for the command arguments.'), -(u'Verb', u'Extension_', u'N', None, None, u'Extension', 1, u'Text', None, u'The extension associated with the table row.'), -(u'Verb', u'Verb', u'N', None, None, None, None, u'Text', None, u'The verb for the command.'), -(u'Verb', u'Command', u'Y', None, None, None, None, u'Formatted', None, u'The command text.'), -] - -Error = [ -(0, u'{{Fatal error: }}'), -(1, u'{{Error [1]. }}'), -(2, u'Warning [1]. '), -(3, None), -(4, u'Info [1]. '), -(5, u'The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is [1]. {{The arguments are: [2], [3], [4]}}'), -(6, None), -(7, u'{{Disk full: }}'), -(8, u'Action [Time]: [1]. [2]'), -(9, u'[ProductName]'), -(10, u'{[2]}{, [3]}{, [4]}'), -(11, u'Message type: [1], Argument: [2]'), -(12, u'=== Logging started: [Date] [Time] ==='), -(13, u'=== Logging stopped: [Date] [Time] ==='), -(14, u'Action start [Time]: [1].'), -(15, u'Action ended [Time]: [1]. Return value [2].'), -(16, u'Time remaining: {[1] minutes }{[2] seconds}'), -(17, u'Out of memory. Shut down other applications before retrying.'), -(18, u'Installer is no longer responding.'), -(19, u'Installer stopped prematurely.'), -(20, u'Please wait while Windows configures [ProductName]'), -(21, u'Gathering required information...'), -(22, u'Removing older versions of this application...'), -(23, u'Preparing to remove older versions of this application...'), -(32, u'{[ProductName] }Setup completed successfully.'), -(33, u'{[ProductName] }Setup failed.'), -(1101, u'Error reading from file: [2]. {{ System error [3].}} Verify that the file exists and that you can access it.'), -(1301, u"Cannot create the file '[2]'. A directory with this name already exists. Cancel the install and try installing to a different location."), -(1302, u'Please insert the disk: [2]'), -(1303, u'The installer has insufficient privileges to access this directory: [2]. The installation cannot continue. Log on as administrator or contact your system administrator.'), -(1304, u'Error writing to file: [2]. Verify that you have access to that directory.'), -(1305, u'Error reading from file [2]. {{ System error [3].}} Verify that the file exists and that you can access it.'), -(1306, u"Another application has exclusive access to the file '[2]'. Please shut down all other applications, then click Retry."), -(1307, u'There is not enough disk space to install this file: [2]. Free some disk space and click Retry, or click Cancel to exit.'), -(1308, u'Source file not found: [2]. Verify that the file exists and that you can access it.'), -(1309, u'Error reading from file: [3]. {{ System error [2].}} Verify that the file exists and that you can access it.'), -(1310, u'Error writing to file: [3]. {{ System error [2].}} Verify that you have access to that directory.'), -(1311, u'Source file not found{{(cabinet)}}: [2]. Verify that the file exists and that you can access it.'), -(1312, u"Cannot create the directory '[2]'. A file with this name already exists. Please rename or remove the file and click retry, or click Cancel to exit."), -(1313, u'The volume [2] is currently unavailable. Please select another.'), -(1314, u"The specified path '[2]' is unavailable."), -(1315, u'Unable to write to the specified folder: [2].'), -(1316, u'A network error occurred while attempting to read from the file: [2]'), -(1317, u'An error occurred while attempting to create the directory: [2]'), -(1318, u'A network error occurred while attempting to create the directory: [2]'), -(1319, u'A network error occurred while attempting to open the source file cabinet: [2]'), -(1320, u'The specified path is too long: [2]'), -(1321, u'The Installer has insufficient privileges to modify this file: [2].'), -(1322, u"A portion of the folder path '[2]' is invalid. It is either empty or exceeds the length allowed by the system."), -(1323, u"The folder path '[2]' contains words that are not valid in folder paths."), -(1324, u"The folder path '[2]' contains an invalid character."), -(1325, u"'[2]' is not a valid short file name."), -(1326, u'Error getting file security: [3] GetLastError: [2]'), -(1327, u'Invalid Drive: [2]'), -(1328, u'Error applying patch to file [2]. It has probably been updated by other means, and can no longer be modified by this patch. For more information contact your patch vendor. {{System Error: [3]}}'), -(1329, u'A file that is required cannot be installed because the cabinet file [2] is not digitally signed. This may indicate that the cabinet file is corrupt.'), -(1330, u'A file that is required cannot be installed because the cabinet file [2] has an invalid digital signature. This may indicate that the cabinet file is corrupt.{{ Error [3] was returned by WinVerifyTrust.}}'), -(1331, u'Failed to correctly copy [2] file: CRC error.'), -(1332, u'Failed to correctly move [2] file: CRC error.'), -(1333, u'Failed to correctly patch [2] file: CRC error.'), -(1334, u"The file '[2]' cannot be installed because the file cannot be found in cabinet file '[3]'. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package."), -(1335, u"The cabinet file '[2]' required for this installation is corrupt and cannot be used. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package."), -(1336, u'There was an error creating a temporary file that is needed to complete this installation.{{ Folder: [3]. System error code: [2]}}'), -(1401, u'Could not create key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1402, u'Could not open key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1403, u'Could not delete value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1404, u'Could not delete key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1405, u'Could not read value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. '), -(1406, u'Could not write value [2] to key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1407, u'Could not get value names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1408, u'Could not get sub key names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1409, u'Could not read security information for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.'), -(1410, u'Could not increase the available registry space. [2] KB of free registry space is required for the installation of this application.'), -(1500, u'Another installation is in progress. You must complete that installation before continuing this one.'), -(1501, u'Error accessing secured data. Please make sure the Windows Installer is configured properly and try the install again.'), -(1502, u"User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. Your current install will now continue."), -(1503, u"User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product."), -(1601, u"Out of disk space -- Volume: '[2]'; required space: [3] KB; available space: [4] KB. Free some disk space and retry."), -(1602, u'Are you sure you want to cancel?'), -(1603, u"The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}. Close that application and retry."), -(1604, u"The product '[2]' is already installed, preventing the installation of this product. The two products are incompatible."), -(1605, u"There is not enough disk space on the volume '[2]' to continue the install with recovery enabled. [3] KB are required, but only [4] KB are available. Click Ignore to continue the install without saving recovery information, click Retry to check for available space again, or click Cancel to quit the installation."), -(1606, u'Could not access network location [2].'), -(1607, u'The following applications should be closed before continuing the install:'), -(1608, u'Could not find any previously installed compliant products on the machine for installing this product.'), -(1609, u"An error occurred while applying security settings. [2] is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. {{Unable to locate the user's SID, system error [3]}}"), -(1701, u'The key [2] is not valid. Verify that you entered the correct key.'), -(1702, u'The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to manually restart later.'), -(1703, u'You must restart your system for the configuration changes made to [2] to take effect. Click Yes to restart now or No if you plan to manually restart later.'), -(1704, u'An installation for [2] is currently suspended. You must undo the changes made by that installation to continue. Do you want to undo those changes?'), -(1705, u'A previous installation for this product is in progress. You must undo the changes made by that installation to continue. Do you want to undo those changes?'), -(1706, u"An installation package for the product [2] cannot be found. Try the installation again using a valid copy of the installation package '[3]'."), -(1707, u'Installation completed successfully.'), -(1708, u'Installation failed.'), -(1709, u'Product: [2] -- [3]'), -(1710, u'You may either restore your computer to its previous state or continue the install later. Would you like to restore?'), -(1711, u'An error occurred while writing installation information to disk. Check to make sure enough disk space is available, and click Retry, or Cancel to end the install.'), -(1712, u'One or more of the files required to restore your computer to its previous state could not be found. Restoration will not be possible.'), -(1713, u'[2] cannot install one of its required products. Contact your technical support group. {{System Error: [3].}}'), -(1714, u'The older version of [2] cannot be removed. Contact your technical support group. {{System Error [3].}}'), -(1715, u'Installed [2]'), -(1716, u'Configured [2]'), -(1717, u'Removed [2]'), -(1718, u'File [2] was rejected by digital signature policy.'), -(1719, u'The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance.'), -(1720, u'There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. {{Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] }}'), -(1721, u'There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action: [2], location: [3], command: [4] }}'), -(1722, u'There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. {{Action [2], location: [3], command: [4] }}'), -(1723, u'There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action [2], entry: [3], library: [4] }}'), -(1724, u'Removal completed successfully.'), -(1725, u'Removal failed.'), -(1726, u'Advertisement completed successfully.'), -(1727, u'Advertisement failed.'), -(1728, u'Configuration completed successfully.'), -(1729, u'Configuration failed.'), -(1730, u'You must be an Administrator to remove this application. To remove this application, you can log on as an Administrator, or contact your technical support group for assistance.'), -(1801, u'The path [2] is not valid. Please specify a valid path.'), -(1802, u'Out of memory. Shut down other applications before retrying.'), -(1803, u'There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to go back to the previously selected volume.'), -(1804, u'There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to return to the browse dialog and select a different volume.'), -(1805, u'The folder [2] does not exist. Please enter a path to an existing folder.'), -(1806, u'You have insufficient privileges to read this folder.'), -(1807, u'A valid destination folder for the install could not be determined.'), -(1901, u'Error attempting to read from the source install database: [2].'), -(1902, u'Scheduling reboot operation: Renaming file [2] to [3]. Must reboot to complete operation.'), -(1903, u'Scheduling reboot operation: Deleting file [2]. Must reboot to complete operation.'), -(1904, u'Module [2] failed to register. HRESULT [3]. Contact your support personnel.'), -(1905, u'Module [2] failed to unregister. HRESULT [3]. Contact your support personnel.'), -(1906, u'Failed to cache package [2]. Error: [3]. Contact your support personnel.'), -(1907, u'Could not register font [2]. Verify that you have sufficient permissions to install fonts, and that the system supports this font.'), -(1908, u'Could not unregister font [2]. Verify that you that you have sufficient permissions to remove fonts.'), -(1909, u'Could not create Shortcut [2]. Verify that the destination folder exists and that you can access it.'), -(1910, u'Could not remove Shortcut [2]. Verify that the shortcut file exists and that you can access it.'), -(1911, u'Could not register type library for file [2]. Contact your support personnel.'), -(1912, u'Could not unregister type library for file [2]. Contact your support personnel.'), -(1913, u'Could not update the ini file [2][3]. Verify that the file exists and that you can access it.'), -(1914, u'Could not schedule file [2] to replace file [3] on reboot. Verify that you have write permissions to file [3].'), -(1915, u'Error removing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.'), -(1916, u'Error installing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.'), -(1917, u'Error removing ODBC driver: [4], ODBC error [2]: [3]. Verify that you have sufficient privileges to remove ODBC drivers.'), -(1918, u'Error installing ODBC driver: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.'), -(1919, u'Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.'), -(1920, u"Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services."), -(1921, u"Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services."), -(1922, u"Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services."), -(1923, u"Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services."), -(1924, u"Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables."), -(1925, u'You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.'), -(1926, u"Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file."), -(1927, u'Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000.'), -(1928, u'Error registering COM+ Application. Contact your support personnel for more information.'), -(1929, u'Error unregistering COM+ Application. Contact your support personnel for more information.'), -(1930, u"The description for service '[2]' ([3]) could not be changed."), -(1931, u'The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}}'), -(1932, u'The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}}'), -(1933, u'The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\\r\\n[3]}}'), -(1934, u'User installations are disabled via policy on the machine.'), -(1935, u'An error occured during the installation of assembly component [2]. HRESULT: [3]. {{assembly interface: [4], function: [5], assembly name: [6]}}'), -] - -tables=['AdminExecuteSequence', 'AdminUISequence', 'AdvtExecuteSequence', 'BBControl', 'Billboard', 'Binary', 'CheckBox', 'Property', 'ComboBox', 'Control', 'ListBox', 'ActionText', 'ControlCondition', 'ControlEvent', 'Dialog', 'EventMapping', 'InstallExecuteSequence', 'InstallUISequence', 'ListView', 'RadioButton', 'TextStyle', 'UIText', '_Validation', 'Error'] From python-checkins at python.org Mon May 1 18:12:45 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 1 May 2006 18:12:45 +0200 (CEST) Subject: [Python-checkins] r45839 - python/trunk/Doc/lib/lib.tex python/trunk/Doc/lib/libmsilib.tex Message-ID: <20060501161245.7AF361E4011@bag.python.org> Author: martin.v.loewis Date: Mon May 1 18:12:44 2006 New Revision: 45839 Added: python/trunk/Doc/lib/libmsilib.tex (contents, props changed) Modified: python/trunk/Doc/lib/lib.tex Log: Add msilib documentation. Modified: python/trunk/Doc/lib/lib.tex ============================================================================== --- python/trunk/Doc/lib/lib.tex (original) +++ python/trunk/Doc/lib/lib.tex Mon May 1 18:12:44 2006 @@ -446,6 +446,7 @@ \input{libsunaudio} \input{windows} % MS Windows ONLY +\input{libmsilib} \input{libmsvcrt} \input{libwinreg} \input{libwinsound} Added: python/trunk/Doc/lib/libmsilib.tex ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/libmsilib.tex Mon May 1 18:12:44 2006 @@ -0,0 +1,485 @@ +\section{\module{msilib} --- + Read and write Microsoft Installer files} + +\declaremodule{standard}{msilib} + \platform{Windows} +\modulesynopsis{Creation of Microsoft Installer files, and CAB files.} +\moduleauthor{Martin v. L\"owis}{martin at v.loewis.de} +\sectionauthor{Martin v. L\"owis}{martin at v.loewis.de} + +\index{msi} + +\versionadded{2.5} + +The \module{msilib} supports the creation of Microsoft Installer +(\code{.msi}) files. Because these files often contain an embedded +``cabinet'' file (\code{.cab}), it also exposes an API to create +CAB files. Support for reading \code{.cab} files is currently not +implemented; read support for the \code{.msi} database is possible. + +This package aims to provide complete access to all tables in an +\code{.msi} file, therefore, it is a fairly low-level API. Two +primary applications of this package are the \module{distutils} +command \code{bdist_msi}, and the creation of Python installer +package itself (although that currently uses a different version +of \code{msilib}). + +The package contents can be roughly split into four parts: +low-level CAB routines, low-level MSI routines, higher-level +MSI routines, and standard table structures. + +\begin{funcdesc}{FCICreate}{cabname, files} + Create a new CAB file named \var{cabname}. \var{files} must + be a list of tuples, each containing the name of the file on + disk, and the name of the file inside the CAB file. + + The files are added to the CAB file in the order they have + in the list. All files are added into a single CAB file, + using the MSZIP compression algorithm. + + Callbacks to Python for the various steps of MSI creation + are currently not exposed. +\end{funcdesc} + +\begin{funcdesc}{UUIDCreate}{} + Return the string representation of a new unique identifier. + This wraps the Windows API functions \code{UuidCreate} and + \code{UuidToString}. +\end{funcdesc} + +\begin{funcdesc}{OpenDatabase}{path, persist} + Return a new database object by calling MsiOpenDatabase. + \var{path} is the file name of the + MSI file; persist can be one of the constants + \code{MSIDBOPEN_CREATEDIRECT}, \code{MSIDBOPEN_CREATE}, + \code{MSIDBOPEN_DIRECT}, \code{MSIDBOPEN_READONLY}, or + \code{MSIDBOPEN_TRANSACT}, and may include the flag + \code{MSIDBOPEN_PATCHFILE}. See the Microsoft documentation for + the meaning of these flags; depending on the flags, + an existing database is opened, or a new one created. +\end{funcdesc} + +\begin{funcdesc}{CreateRecord}{count} + Return a new record object by calling MSICreateRecord. + \var{count} is the number of fields of the record. +\end{funcdesc} + +\begin{funcdesc}{init_database}{name, schema, ProductName, ProductCode, ProductVersion, Manufacturer} + Create and return a new database \var{name}, initialize it + with \var{schema}, and set the properties \var{ProductName}, + \var{ProductCode}, \var{ProductVersion}, and \var{Manufacturer}. + + \var{schema} must be a module object containing \code{tables} and + \code{_Validation_records} attributes; typically, + \module{msilib.schema} should be used. + + The database will contain just the schema and the validation + records when this function returns. +\end{funcdesc} + +\begin{funcdesc}{add_data}{database, records} + Add all \var{records} to \var{database}. \var{records} should + be a list of tuples, each one containing all fields of a record + according to the schema of the table. For optional fields, + \code{None} can be passed. + + Field values can be int or long numbers, strings, or instances + of the Binary class. +\end{funcdesc} + +\begin{classdesc}{Binary}{filename} + Represents entries into the Binary table; inserting such + an object using \function{add_data} reads the file named + \var{filename} into the table. +\end{classdesc} + +\begin{funcdesc}{add_tables}{database, module} + Add all table content from \var{module} to \var{database}. + \var{module} must contain an attribute \var{tables} + listing all tables for which content should be added, + and one attribute per table that has the actual content. + + This is typically used to install the sequence +\end{funcdesc} + +\begin{funcdesc}{add_stream}{database, name, path} + Add the file \var{path} into the \code{_Stream} table + of \var{database}, with the stream name \var{name}. +\end{funcdesc} + +\begin{funcdesc}{gen_uuid}{} + Return a new UUID, in the format that MSI typically + requires (i.e. in curly braces, and with all hexdigits + in upper-case). +\end{funcdesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devnotes/winprog/fcicreate.asp]{FCICreateFile}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/uuidcreate.asp]{UuidCreate}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/uuidtostring.asp]{UuidToString}{} +\end{seealso} + +\subsection{Database Objects\label{database-objects}} + +\begin{methoddesc}{OpenView}{sql} + Return a view object, by calling MSIDatabaseOpenView. + \var{sql} is the SQL statement to execute. +\end{methoddesc} + +\begin{methoddesc}{Commit}{} + Commit the changes pending in the current transaction, + by calling MSIDatabaseCommit. +\end{methoddesc} + +\begin{methoddesc}{GetSummaryInformation}{count} + Return a new summary information object, by calling + MsiGetSummaryInformation. \var{count} is the maximum number of + updated values. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiopenview.asp]{MSIOpenView}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabasecommit.asp]{MSIDatabaseCommit}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msigetsummaryinformation.asp]{MSIGetSummaryInformation}{} +\end{seealso} + +\subsection{View Objects\label{view-objects}} + +\begin{methoddesc}{Execute}{\optional{params=None}} + Execute the SQL query of the view, through MSIViewExecute. + \var{params} is an optional record describing actual values + of the parameter tokens in the query. +\end{methoddesc} + +\begin{methoddesc}{GetColumnInfo}{kind} + Return a record describing the columns of the view, through + calling MsiViewGetColumnInfo. \var{kind} can be either + \code{MSICOLINFO_NAMES} or \code{MSICOLINFO_TYPES} +\end{methoddesc} + +\begin{methoddesc}{Fetch}{} + Return a result record of the query, through calling + MsiViewFetch. +\end{methoddesc} + +\begin{methoddesc}{Modify}{kind, data} + Modify the view, by calling MsiViewModify. \var{kind} + can be one of \code{MSIMODIFY_SEEK}, \code{MSIMODIFY_REFRESH}, + \code{MSIMODIFY_INSERT}, \code{MSIMODIFY_UPDATE}, \code{MSIMODIFY_ASSIGN}, + \code{MSIMODIFY_REPLACE}, \code{MSIMODIFY_MERGE}, \code{MSIMODIFY_DELETE}, + \code{MSIMODIFY_INSERT_TEMPORARY}, \code{MSIMODIFY_VALIDATE}, + \code{MSIMODIFY_VALIDATE_NEW}, \code{MSIMODIFY_VALIDATE_FIELD}, or + \code{MSIMODIFY_VALIDATE_DELETE}. + + \var{data} must be a record describing the new data. +\end{methoddesc} + +\begin{methoddesc}{Close}{} + Close the view, through MsiViewClose. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewexecute.asp]{MsiViewExecute}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewgetcolumninfo.asp]{MSIViewGetColumnInfo}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewfetch.asp]{MsiViewFetch}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewmodify.asp]{MsiViewModify}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewclose.asp]{MsiViewClose}{} +\end{seealso} + +\subsection{Summary Information Objects\label{summary-objects}} + +\begin{methoddesc}{GetProperty}{field} + Return a property of the summary, through MsiSummaryInfoGetProperty. + \var{field} is the name of the property, and can be one of the + constants + \code{PID_CODEPAGE}, \code{PID_TITLE}, \code{PID_SUBJECT}, + \code{PID_AUTHOR}, \code{PID_KEYWORDS}, \code{PID_COMMENTS}, + \code{PID_TEMPLATE}, \code{PID_LASTAUTHOR}, \code{PID_REVNUMBER}, + \code{PID_LASTPRINTED}, \code{PID_CREATE_DTM}, \code{PID_LASTSAVE_DTM}, + \code{PID_PAGECOUNT}, \code{PID_WORDCOUNT}, \code{PID_CHARCOUNT}, + \code{PID_APPNAME}, or \code{PID_SECURITY}. +\end{methoddesc} + +\begin{methoddesc}{GetPropertyCount}{} + Return the number of summary properties, through + MsiSummaryInfoGetPropertyCount. +\end{methoddesc} + +\begin{methoddesc}{SetProperty}{field, value} + Set a property through MsiSummaryInfoSetProperty. \var{field} + can have the same values as in \method{GetProperty}, \var{value} + is the new value of the property. Possible value types are integer + and string. +\end{methoddesc} + +\begin{methoddesc}{Persist}{} + Write the modified properties to the summary information stream, + using MsiSummaryInfoPersist. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfogetproperty.asp]{MsiSummaryInfoGetProperty}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfogetpropertycount.asp]{MsiSummaryInfoGetPropertyCount}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfosetproperty.asp]{MsiSummaryInfoSetProperty}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfopersist.asp]{MsiSummaryInfoPersist}{} +\end{seealso} + +\subsection{Record Objects\label{record-objects}} + +\begin{methoddesc}{GetFieldCount}{} + Return the number of fields of the record, through MsiRecordGetFieldCount. +\end{methoddesc} + +\begin{methoddesc}{SetString}{field, value} + Set \var{field} to \var{value} through MsiRecordSetString. + \var{field} must be an integer; \var{value} a string. +\end{methoddesc} + +\begin{methoddesc}{SetStream}{field, value} + Set \var{field} to the contents of the file named \var{value}, + through MsiRecordSetStream. + \var{field} must be an integer; \var{value} a string. +\end{methoddesc} + +\begin{methoddesc}{SetInteger}{field, value} + Set \var{field} to \var{value} through MsiRecordSetInteger. + Both \var{field} and \var{value} must be an integers. +\end{methoddesc} + +\begin{methoddesc}{ClearData}{} + Set all fields of the record to 0, through MsiRecordClearData. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordgetfieldcount.asp]{MsiRecordGetFieldCount}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetstring.asp]{MsiRecordSetString}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetstream.asp]{MsiRecordSetStream}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetinteger.asp]{MsiRecordSetInteger}{} + \seetitle[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordclear.asp]{MsiRecordClear}{} +\end{seealso} + +\subsection{Errors\label{msi-errors}} + +All wrappers around MSI functions raise \exception{MsiError}; +the string inside the exception will contain more detail. + +\subsection{CAB Objects\label{cab}} + +\begin{classdesc}{CAB}{name} + The class \class{CAB} represents a CAB file. During MSI construction, + files will be added simultaneously to the \code{Files} table, and + to a CAB file. Then, when all files have been added, the CAB file + can be written, then added to the MSI file. + + \var{name} is the name of the CAB file in the MSI file. +\end{classdesc} + +\begin{methoddesc}[CAB]{append}{full, logical} + Add the file with the pathname \var{full} to the CAB file, + under the name \var{logical}. If there is already a file + named \var{logical}, a new file name is created. + + Return the index of the file in the CAB file, and the + new name of the file inside the CAB file. +\end{methoddesc} + +\begin{methoddesc}[CAB]{append}{database} + Generate a CAB file, add it as a stream to the MSI file, + put it into the \code{Media} table, and remove the generated + file from the disk. +\end{methoddesc} + +\subsection{Directory Objects\label{msi-directory}} + +\begin{classdesc}{Directory}{database, cab, basedir, physical, + logical, default, component, \optional{flags}} + Create a new directory in the Directory table. There is a current + component at each point in time for the directory, which is either + explicitly created through start_component, or implicitly when files + are added for the first time. Files are added into the current + component, and into the cab file. To create a directory, a base + directory object needs to be specified (can be None), the path to + the physical directory, and a logical directory name. Default + specifies the DefaultDir slot in the directory table. componentflags + specifies the default flags that new components get. +\end{classdesc} + +\begin{methoddesc}[Directory]{start_component}{\optional{component\optional{, + feature\optional{, flags\optional{, keyfile\optional{, uuid}}}}}} + 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 flags are + used. If no keyfile is given, the KeyPath is left null in the + Component table. +\end{methoddesc} + +\begin{methoddesc}[Directory]{add_file}{file\optional{, src\optional{, + version\optional{, language}}}} + Add a file to the current component of the directory, starting a new + one one if there is no current component. By default, the file name + in the source and the file table will be identical. If the src file + is specified, it is interpreted relative to the current + directory. Optionally, a version and a language can be specified for + the entry in the File table. +\end{methoddesc} + +\begin{methoddesc}[Directory]{glob}{pattern\optional{, exclude}} + Add a list of files to the current component as specified in the glob + pattern. Individual files can be excluded in the exclude list. +\end{methoddesc} + +\begin{methoddesc}[Directory]{remove_pyc}{} + Remove .pyc/.pyo files on uninstall +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/directory_table.asp]{Directory Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/file_table.asp]{File Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/component_table.asp]{Component Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/featurecomponents_table.asp]{FeatureComponents Table}{} +\end{seealso} + + +\subsection{Features\label{features}} + +\begin{classdesc}{Feature}{database, id, title, desc, display\optional{, + level=1\optional{, parent\optional\{, directory\optional{, + attributes=0}}}} + + Add a new record to the \code{Feature} table, using the values + \var{id}, \var{parent.id}, \var{title}, \var{desc}, \var{display}, + \var{level}, \var{directory}, and \var{attributes}. The resulting + feature object can be passed to the \method{start_component} method + of \class{Directory}. +\end{classdesc} + +\begin{methoddesc}[Feature]{set_current}{} + Make this feature the current feature of \module{msilib}. + New components are automatically added to the default feature, + unless a feature is explicitly specified. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/feature_table.asp]{Feature Table}{} +\end{seealso} + +\subsection{GUI classes\label{msi-gui}} + +\module{msilib} provides several classes that wrap the GUI tables in +an MSI database. However, no standard user interface is provided; use +\module{bdist_msi} to create MSI files with a user-interface for +installing Python packages. + +\begin{classdesc}{Control}{dlg, name} + Base class of the dialog controls. \var{dlg} is the dialog object + the control belongs to, and \var{name} is the control's name. +\end{classdesc} + +\begin{methoddesc}[Control]{event}{event, argument\optional{, + condition = ``1''\optional{, ordering}}} + + Make an entry into the \code{ControlEvent} table for this control. +\end{methoddesc} + +\begin{methoddesc}[Control]{mapping}{event, attribute} + Make an entry into the \code{EventMapping} table for this control. +\end{methoddesc} + +\begin{methoddesc}[Control]{condition}{action, condition} + Make an entry into the \code{ControlCondition} table for this control. +\end{methoddesc} + + +\begin{classdesc}{RadioButtonGroup}{dlg, name, property} + Create a radio button control named \var{name}. \var{property} + is the installer property that gets set when a radio button + is selected. +\end{classdesc} + +\begin{methoddesc}[RadioButtonGroup]{add}{name, x, y, width, height, text + \optional{, value}} + Add a radio button named \var{name} to the group, at the + coordinates \var{x}, \var{y}, \var{width}, \var{height}, and + with the label \var{text}. If \var{value} is omitted, it + defaults to \var{name}. +\end{methoddesc} + +\begin{classdesc}{Dialog}{db, name, x, y, w, h, attr, title, first, + default, cancel} + Return a new Dialog object. An entry in the \code{Dialog} table + is made, with the specified coordinates, dialog attributes, title, + name of the first, default, and cancel controls. +\end{classdesc} + +\begin{methoddesc}[Dialog]{control}{name, type, x, y, width, height, + attributes, property, text, control_next, help} + Return a new Control object. An entry in the \code{Control} table + is made with the specified parameters. + + This is a generic method; for specific types, specialized methods + are provided. +\end{methoddesc} + + +\begin{methoddesc}[Dialog]{text}{name, x, y, width, height, attributes, text} + Add and return a \code{Text} control. +\end{methoddesc} + +\begin{methoddesc}[Dialog]{bitmap}{name, x, y, width, height, text} + Add and return a \code{Bitmap} control. +\end{methoddesc} + +\begin{methoddesc}[Dialog]{line}{name, x, y, width, height} + Add and return a \code{Line} control. +\end{methoddesc} + +\begin{methoddesc}[Dialog]{pushbutton}{name, x, y, width, height, attributes, + text, next_control} + Add and return a \code{PushButton} control. +\end{methoddesc} + +\begin{methoddesc}[Dialog]{radiogroup}{name, x, y, width, height, + attributes, property, text, next_control} + Add and return a \code{RadioButtonGroup} control. +\end{methoddesc} + +\begin{methoddesc}[Dialog]{checkbox}{name, x, y, width, height, + attributes, property, text, next_control} + Add and return a \code{CheckBox} control. +\end{methoddesc} + +\begin{seealso} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/dialog_table.asp]{Dialog Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/control_table.asp]{Control Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/controls.asp]{Control Types}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/controlcondition_table.asp]{ControlCondition Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/controlevent_table.asp]{ControlEvent Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/eventmapping_table.asp]{EventMapping Table}{} + \seetitle[http://msdn.microsoft.com/library/en-us/msi/setup/radiobutton_table.asp]{RadioButton Table}{} +\end{seealso} + +\subsection{Precomputed tables\label{msi-tables}} + +\module{msilib} provides a few subpackages that contain +only schema and table definitions. Currently, these definitions +are based on MSI version 2.0. + +\begin{datadesc}{schema} + This is the standard MSI schema for MSI 2.0, with the + \var{tables} variable providing a list of table definitions, + and \var{_Validation_records} providing the data for + MSI validation. +\end{datadesc} + +\begin{datadesc}{sequence} + This module contains table contents for the standard sequence + tables: \var{AdminExecuteSequence}, \var{AdminUISequence}, + \var{AdvtExecuteSequence}, \var{InstallExecuteSequence}, and + \var{InstallUISequence}. +\end{datadesc} + +\begin{datadesc}{text} + This module contains definitions for the UIText and ActionText + tables, for the standard installer actions. +\end{datadesc} \ No newline at end of file From python-checkins at python.org Mon May 1 18:14:16 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 1 May 2006 18:14:16 +0200 (CEST) Subject: [Python-checkins] r45840 - in python/trunk/Lib: distutils/command/bdist_msi.py msilib/__init__.py Message-ID: <20060501161416.D25401E4010@bag.python.org> Author: martin.v.loewis Date: Mon May 1 18:14:16 2006 New Revision: 45840 Modified: python/trunk/Lib/distutils/command/bdist_msi.py python/trunk/Lib/msilib/__init__.py Log: Rename parameters to match the documentation (which in turn matches Microsoft's documentation). Drop unused parameter in CAB.append. Modified: python/trunk/Lib/distutils/command/bdist_msi.py ============================================================================== --- python/trunk/Lib/distutils/command/bdist_msi.py (original) +++ python/trunk/Lib/distutils/command/bdist_msi.py Mon May 1 18:14:16 2006 @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005 Martin v. Löwis +# Copyright (C) 2005, 2006 Martin v. Löwis # Licensed to PSF under a Contributor Agreement. # The bdist_wininst command proper # based on bdist_wininst @@ -16,7 +16,7 @@ from distutils.errors import DistutilsOptionError from distutils import log import msilib -from msilib import schema, sequence, uisample +from msilib import schema, sequence, text from msilib import Directory, Feature, Dialog, add_data class PyDialog(Dialog): @@ -374,8 +374,8 @@ ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250), ("ProgressDlg", None, 1280)]) - add_data(db, 'ActionText', uisample.ActionText) - add_data(db, 'UIText', uisample.UIText) + add_data(db, 'ActionText', text.ActionText) + add_data(db, 'UIText', text.UIText) ##################################################################### # Standard dialogs: FatalError, UserExit, ExitDialog fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title, @@ -502,9 +502,9 @@ seldlg.back("< Back", None, active=0) c = seldlg.next("Next >", "Cancel") - c.event("SetTargetPath", "TARGETDIR", order=1) - c.event("SpawnWaitDialog", "WaitForCostingDlg", order=2) - c.event("EndDialog", "Return", order=3) + c.event("SetTargetPath", "TARGETDIR", ordering=1) + c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=2) + c.event("EndDialog", "Return", ordering=3) c = seldlg.cancel("Cancel", "DirectoryCombo") c.event("SpawnDialog", "CancelDlg") @@ -561,7 +561,7 @@ c = whichusers.next("Next >", "Cancel") c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1) - c.event("EndDialog", "Return", order = 2) + c.event("EndDialog", "Return", ordering = 2) c = whichusers.cancel("Cancel", "AdminInstall") c.event("SpawnDialog", "CancelDlg") Modified: python/trunk/Lib/msilib/__init__.py ============================================================================== --- python/trunk/Lib/msilib/__init__.py (original) +++ python/trunk/Lib/msilib/__init__.py Mon May 1 18:14:16 2006 @@ -196,11 +196,9 @@ self.filenames.add(logical) return logical - def append(self, full, file, logical = None): + def append(self, full, logical): if os.path.isdir(full): return - if not logical: - logical = self.gen_id(dir, file) self.index += 1 self.files.append((full, logical)) return self.index, logical @@ -330,7 +328,7 @@ logical = self.keyfiles[file] else: logical = None - sequence, logical = self.cab.append(absolute, file, logical) + sequence, logical = self.cab.append(absolute, logical) assert logical not in self.ids self.ids.add(logical) short = self.make_short(file) @@ -400,13 +398,14 @@ self.dlg = dlg self.name = name - def event(self, ev, arg, cond = "1", order = None): + def event(self, event, argument, condition = "1", ordering = None): add_data(self.dlg.db, "ControlEvent", - [(self.dlg.name, self.name, ev, arg, cond, order)]) + [(self.dlg.name, self.name, event, argument, + condition, ordering)]) - def mapping(self, ev, attr): + def mapping(self, mapping, attribute): add_data(self.dlg.db, "EventMapping", - [(self.dlg.name, self.name, ev, attr)]) + [(self.dlg.name, self.name, event, attribute)]) def condition(self, action, condition): add_data(self.dlg.db, "ControlCondition", From buildbot at python.org Mon May 1 18:26:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 16:26:27 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060501162628.18DA31E400F@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/299 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gerhard.haering Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 1 18:28:54 2006 From: python-checkins at python.org (fred.drake) Date: Mon, 1 May 2006 18:28:54 +0200 (CEST) Subject: [Python-checkins] r45841 - python/trunk/Doc/Makefile.deps Message-ID: <20060501162854.A86E51E400F@bag.python.org> Author: fred.drake Date: Mon May 1 18:28:54 2006 New Revision: 45841 Modified: python/trunk/Doc/Makefile.deps Log: add dependency Modified: python/trunk/Doc/Makefile.deps ============================================================================== --- python/trunk/Doc/Makefile.deps (original) +++ python/trunk/Doc/Makefile.deps Mon May 1 18:28:54 2006 @@ -308,6 +308,7 @@ lib/libgetpass.tex \ lib/libshutil.tex \ lib/librepr.tex \ + lib/libmsilib.tex \ lib/libmsvcrt.tex \ lib/libwinreg.tex \ lib/libwinsound.tex \ From python-checkins at python.org Mon May 1 18:30:26 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 18:30:26 +0200 (CEST) Subject: [Python-checkins] r45842 - python/trunk/Doc/lib/libmsilib.tex Message-ID: <20060501163026.6D7001E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 18:30:25 2006 New Revision: 45842 Modified: python/trunk/Doc/lib/libmsilib.tex Log: Markup fixes; add some XXX comments noting problems Modified: python/trunk/Doc/lib/libmsilib.tex ============================================================================== --- python/trunk/Doc/lib/libmsilib.tex (original) +++ python/trunk/Doc/lib/libmsilib.tex Mon May 1 18:30:25 2006 @@ -43,14 +43,14 @@ \begin{funcdesc}{UUIDCreate}{} Return the string representation of a new unique identifier. - This wraps the Windows API functions \code{UuidCreate} and - \code{UuidToString}. + This wraps the Windows API functions \cfunction{UuidCreate} and + \cfunction{UuidToString}. \end{funcdesc} \begin{funcdesc}{OpenDatabase}{path, persist} Return a new database object by calling MsiOpenDatabase. \var{path} is the file name of the - MSI file; persist can be one of the constants + MSI file; \var{persist} can be one of the constants \code{MSIDBOPEN_CREATEDIRECT}, \code{MSIDBOPEN_CREATE}, \code{MSIDBOPEN_DIRECT}, \code{MSIDBOPEN_READONLY}, or \code{MSIDBOPEN_TRANSACT}, and may include the flag @@ -60,7 +60,7 @@ \end{funcdesc} \begin{funcdesc}{CreateRecord}{count} - Return a new record object by calling MSICreateRecord. + Return a new record object by calling \cfunction{MSICreateRecord}. \var{count} is the number of fields of the record. \end{funcdesc} @@ -88,7 +88,7 @@ \end{funcdesc} \begin{classdesc}{Binary}{filename} - Represents entries into the Binary table; inserting such + Represents entries in the Binary table; inserting such an object using \function{add_data} reads the file named \var{filename} into the table. \end{classdesc} @@ -100,6 +100,7 @@ and one attribute per table that has the actual content. This is typically used to install the sequence + % XXX unfinished sentence \end{funcdesc} \begin{funcdesc}{add_stream}{database, name, path} @@ -122,18 +123,18 @@ \subsection{Database Objects\label{database-objects}} \begin{methoddesc}{OpenView}{sql} - Return a view object, by calling MSIDatabaseOpenView. + Return a view object, by calling \cfunction{MSIDatabaseOpenView}. \var{sql} is the SQL statement to execute. \end{methoddesc} \begin{methoddesc}{Commit}{} Commit the changes pending in the current transaction, - by calling MSIDatabaseCommit. + by calling \cfunction{MSIDatabaseCommit}. \end{methoddesc} \begin{methoddesc}{GetSummaryInformation}{count} Return a new summary information object, by calling - MsiGetSummaryInformation. \var{count} is the maximum number of + \cfunction{MsiGetSummaryInformation}. \var{count} is the maximum number of updated values. \end{methoddesc} @@ -146,24 +147,24 @@ \subsection{View Objects\label{view-objects}} \begin{methoddesc}{Execute}{\optional{params=None}} - Execute the SQL query of the view, through MSIViewExecute. + Execute the SQL query of the view, through \cfunction{MSIViewExecute}. \var{params} is an optional record describing actual values of the parameter tokens in the query. \end{methoddesc} \begin{methoddesc}{GetColumnInfo}{kind} Return a record describing the columns of the view, through - calling MsiViewGetColumnInfo. \var{kind} can be either - \code{MSICOLINFO_NAMES} or \code{MSICOLINFO_TYPES} + calling \cfunction{MsiViewGetColumnInfo}. \var{kind} can be either + \code{MSICOLINFO_NAMES} or \code{MSICOLINFO_TYPES}. \end{methoddesc} \begin{methoddesc}{Fetch}{} Return a result record of the query, through calling - MsiViewFetch. + \cfunction{MsiViewFetch}. \end{methoddesc} \begin{methoddesc}{Modify}{kind, data} - Modify the view, by calling MsiViewModify. \var{kind} + Modify the view, by calling \cfunction{MsiViewModify}. \var{kind} can be one of \code{MSIMODIFY_SEEK}, \code{MSIMODIFY_REFRESH}, \code{MSIMODIFY_INSERT}, \code{MSIMODIFY_UPDATE}, \code{MSIMODIFY_ASSIGN}, \code{MSIMODIFY_REPLACE}, \code{MSIMODIFY_MERGE}, \code{MSIMODIFY_DELETE}, @@ -175,7 +176,7 @@ \end{methoddesc} \begin{methoddesc}{Close}{} - Close the view, through MsiViewClose. + Close the view, through \cfunction{MsiViewClose}. \end{methoddesc} \begin{seealso} @@ -189,7 +190,7 @@ \subsection{Summary Information Objects\label{summary-objects}} \begin{methoddesc}{GetProperty}{field} - Return a property of the summary, through MsiSummaryInfoGetProperty. + Return a property of the summary, through \cfunction{MsiSummaryInfoGetProperty}. \var{field} is the name of the property, and can be one of the constants \code{PID_CODEPAGE}, \code{PID_TITLE}, \code{PID_SUBJECT}, @@ -202,11 +203,11 @@ \begin{methoddesc}{GetPropertyCount}{} Return the number of summary properties, through - MsiSummaryInfoGetPropertyCount. + \cfunction{MsiSummaryInfoGetPropertyCount}. \end{methoddesc} \begin{methoddesc}{SetProperty}{field, value} - Set a property through MsiSummaryInfoSetProperty. \var{field} + Set a property through \cfunction{MsiSummaryInfoSetProperty}. \var{field} can have the same values as in \method{GetProperty}, \var{value} is the new value of the property. Possible value types are integer and string. @@ -214,7 +215,7 @@ \begin{methoddesc}{Persist}{} Write the modified properties to the summary information stream, - using MsiSummaryInfoPersist. + using \cfunction{MsiSummaryInfoPersist}. \end{methoddesc} \begin{seealso} @@ -227,27 +228,27 @@ \subsection{Record Objects\label{record-objects}} \begin{methoddesc}{GetFieldCount}{} - Return the number of fields of the record, through MsiRecordGetFieldCount. + Return the number of fields of the record, through \cfunction{MsiRecordGetFieldCount}. \end{methoddesc} \begin{methoddesc}{SetString}{field, value} - Set \var{field} to \var{value} through MsiRecordSetString. + Set \var{field} to \var{value} through \cfunction{MsiRecordSetString}. \var{field} must be an integer; \var{value} a string. \end{methoddesc} \begin{methoddesc}{SetStream}{field, value} Set \var{field} to the contents of the file named \var{value}, - through MsiRecordSetStream. + through \cfunction{MsiRecordSetStream}. \var{field} must be an integer; \var{value} a string. \end{methoddesc} \begin{methoddesc}{SetInteger}{field, value} - Set \var{field} to \var{value} through MsiRecordSetInteger. - Both \var{field} and \var{value} must be an integers. + Set \var{field} to \var{value} through \cfunction{MsiRecordSetInteger}. + Both \var{field} and \var{value} must be an integer. \end{methoddesc} \begin{methoddesc}{ClearData}{} - Set all fields of the record to 0, through MsiRecordClearData. + Set all fields of the record to 0, through \cfunction{MsiRecordClearData}. \end{methoddesc} \begin{seealso} @@ -295,13 +296,14 @@ logical, default, component, \optional{flags}} Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either - explicitly created through start_component, or implicitly when files + explicitly created through \function{start_component}, or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base - directory object needs to be specified (can be None), the path to - the physical directory, and a logical directory name. Default + directory object needs to be specified (can be \code{None}), the path to + the physical directory, and a logical directory name. \var{default} specifies the DefaultDir slot in the directory table. componentflags specifies the default flags that new components get. + % XXX signature says 'component', 'flags'; text says 'componentflags'. \end{classdesc} \begin{methoddesc}[Directory]{start_component}{\optional{component\optional{, From python-checkins at python.org Mon May 1 18:32:49 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 18:32:49 +0200 (CEST) Subject: [Python-checkins] r45843 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060501163249.C7FCA1E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 18:32:49 2006 New Revision: 45843 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add item Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Mon May 1 18:32:49 2006 @@ -1378,6 +1378,11 @@ (Contributed by Gregory K. Johnson. Funding was provided by Google's 2005 Summer of Code.) +\item New module: the \module{msilib} module allows creating +Microsoft Installer \file{.msi} files and CAB files. Some support +for reading the \file{.msi} database is also included. +(Contributed by Martin von~L\"owis.) + \item The \module{nis} module now supports accessing domains other than the system default domain by supplying a \var{domain} argument to the \function{nis.match()} and \function{nis.maps()} functions. From buildbot at python.org Mon May 1 18:44:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 16:44:10 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060501164410.C84091E400F@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/341 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gerhard.haering Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 1 19:06:54 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 19:06:54 +0200 (CEST) Subject: [Python-checkins] r45844 - python/trunk/Doc/lib/libmsilib.tex Message-ID: <20060501170654.F39881E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 19:06:54 2006 New Revision: 45844 Modified: python/trunk/Doc/lib/libmsilib.tex Log: Markup fixes Modified: python/trunk/Doc/lib/libmsilib.tex ============================================================================== --- python/trunk/Doc/lib/libmsilib.tex (original) +++ python/trunk/Doc/lib/libmsilib.tex Mon May 1 19:06:54 2006 @@ -296,7 +296,7 @@ logical, default, component, \optional{flags}} Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either - explicitly created through \function{start_component}, or implicitly when files + explicitly created through \method{start_component}, or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base directory object needs to be specified (can be \code{None}), the path to @@ -309,30 +309,30 @@ \begin{methoddesc}[Directory]{start_component}{\optional{component\optional{, feature\optional{, flags\optional{, keyfile\optional{, uuid}}}}}} 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 flags are - used. If no keyfile is given, the KeyPath is left null in the + current component for this directory. If no component name is given, the + directory name is used. If no \var{feature} is given, the current feature + is used. If no \var{flags} are given, the directory's default flags are + used. If no \var{keyfile} is given, the KeyPath is left null in the Component table. \end{methoddesc} \begin{methoddesc}[Directory]{add_file}{file\optional{, src\optional{, version\optional{, language}}}} Add a file to the current component of the directory, starting a new - one one if there is no current component. By default, the file name - in the source and the file table will be identical. If the src file + one if there is no current component. By default, the file name + in the source and the file table will be identical. If the \var{src} file is specified, it is interpreted relative to the current - directory. Optionally, a version and a language can be specified for + directory. Optionally, a \var{version} and a \var{language} can be specified for the entry in the File table. \end{methoddesc} \begin{methoddesc}[Directory]{glob}{pattern\optional{, exclude}} Add a list of files to the current component as specified in the glob - pattern. Individual files can be excluded in the exclude list. + pattern. Individual files can be excluded in the \var{exclude} list. \end{methoddesc} \begin{methoddesc}[Directory]{remove_pyc}{} - Remove .pyc/.pyo files on uninstall + Remove \code{.pyc}/\code{.pyo} files on uninstall. \end{methoddesc} \begin{seealso} @@ -409,14 +409,14 @@ \begin{classdesc}{Dialog}{db, name, x, y, w, h, attr, title, first, default, cancel} - Return a new Dialog object. An entry in the \code{Dialog} table + Return a new \class{Dialog} object. An entry in the \code{Dialog} table is made, with the specified coordinates, dialog attributes, title, name of the first, default, and cancel controls. \end{classdesc} \begin{methoddesc}[Dialog]{control}{name, type, x, y, width, height, attributes, property, text, control_next, help} - Return a new Control object. An entry in the \code{Control} table + Return a new \class{Control} object. An entry in the \code{Control} table is made with the specified parameters. This is a generic method; for specific types, specialized methods From python-checkins at python.org Mon May 1 19:26:22 2006 From: python-checkins at python.org (guido.van.rossum) Date: Mon, 1 May 2006 19:26:22 +0200 (CEST) Subject: [Python-checkins] r45845 - peps/trunk/pep-3099.txt Message-ID: <20060501172622.E94981E400F@bag.python.org> Author: guido.van.rossum Date: Mon May 1 19:26:22 2006 New Revision: 45845 Modified: peps/trunk/pep-3099.txt Log: Clarify the sentence "python won't be unicode" which could be interpreted too broadly. Modified: peps/trunk/pep-3099.txt ============================================================================== --- peps/trunk/pep-3099.txt (original) +++ peps/trunk/pep-3099.txt Mon May 1 19:26:22 2006 @@ -47,8 +47,8 @@ Thread: "Adding sorting to generator comprehension", http://mail.python.org/pipermail/python-3000/2006-April/001295.html -* Python won't use Unicode characters for anything except string - literals or comments. +* Python 3000 source code won't use non-ASCII Unicode characters for + anything except string literals or comments. Thread: sets in P3K? http://mail.python.org/pipermail/python-3000/2006-April/01474.html From jimjjewett at gmail.com Mon May 1 19:42:13 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Mon, 1 May 2006 13:42:13 -0400 Subject: [Python-checkins] r45845 - peps/trunk/pep-3099.txt In-Reply-To: <20060501172622.E94981E400F@bag.python.org> References: <20060501172622.E94981E400F@bag.python.org> Message-ID: thank you. On 5/1/06, guido.van.rossum wrote: > Author: guido.van.rossum > Date: Mon May 1 19:26:22 2006 > New Revision: 45845 > > Modified: > peps/trunk/pep-3099.txt > Log: > Clarify the sentence "python won't be unicode" which could be interpreted > too broadly. > > > Modified: peps/trunk/pep-3099.txt > ============================================================================== > --- peps/trunk/pep-3099.txt (original) > +++ peps/trunk/pep-3099.txt Mon May 1 19:26:22 2006 > @@ -47,8 +47,8 @@ > Thread: "Adding sorting to generator comprehension", > http://mail.python.org/pipermail/python-3000/2006-April/001295.html > > -* Python won't use Unicode characters for anything except string > - literals or comments. > +* Python 3000 source code won't use non-ASCII Unicode characters for > + anything except string literals or comments. > > Thread: sets in P3K? > http://mail.python.org/pipermail/python-3000/2006-April/01474.html > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From buildbot at python.org Mon May 1 19:54:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 01 May 2006 17:54:19 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060501175419.AD7741E400F@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/343 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 1 21:59:50 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 21:59:50 +0200 (CEST) Subject: [Python-checkins] r45846 - peps/trunk/pep-0230.txt Message-ID: <20060501195950.904841E4010@bag.python.org> Author: andrew.kuchling Date: Mon May 1 21:59:50 2006 New Revision: 45846 Modified: peps/trunk/pep-0230.txt Log: Remove duplicate Status header; mark as Final to match statue in PEP 0 Modified: peps/trunk/pep-0230.txt ============================================================================== --- peps/trunk/pep-0230.txt (original) +++ peps/trunk/pep-0230.txt Mon May 1 21:59:50 2006 @@ -3,10 +3,9 @@ Version: $Revision$ Last-Modified: $Date$ Author: guido at python.org (Guido van Rossum) -Status: Draft Type: Standards Track Python-Version: 2.1 -Status: Incomplete +Status: Final Post-History: 05-Nov-2000 From python-checkins at python.org Mon May 1 22:00:15 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 22:00:15 +0200 (CEST) Subject: [Python-checkins] r45847 - peps/trunk/pep-0231.txt Message-ID: <20060501200015.40BB01E4023@bag.python.org> Author: andrew.kuchling Date: Mon May 1 22:00:14 2006 New Revision: 45847 Modified: peps/trunk/pep-0231.txt Log: Mark as Rejected to match statue in PEP 0 Modified: peps/trunk/pep-0231.txt ============================================================================== --- peps/trunk/pep-0231.txt (original) +++ peps/trunk/pep-0231.txt Mon May 1 22:00:14 2006 @@ -4,7 +4,7 @@ Last-Modified: $Date$ Author: barry at python.org (Barry A. Warsaw) Python-Version: 2.1 -Status: Draft +Status: Rejected Type: Standards Created: 30-Nov-2000 Post-History: From python-checkins at python.org Mon May 1 22:03:46 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 1 May 2006 22:03:46 +0200 (CEST) Subject: [Python-checkins] r45848 - peps/trunk/pep-0211.txt peps/trunk/pep-0212.txt peps/trunk/pep-0213.txt peps/trunk/pep-0219.txt peps/trunk/pep-0225.txt peps/trunk/pep-0262.txt Message-ID: <20060501200346.AC5771E400F@bag.python.org> Author: andrew.kuchling Date: Mon May 1 22:03:44 2006 New Revision: 45848 Modified: peps/trunk/pep-0211.txt peps/trunk/pep-0212.txt peps/trunk/pep-0213.txt peps/trunk/pep-0219.txt peps/trunk/pep-0225.txt peps/trunk/pep-0262.txt Log: Mark as Deferred to match status in PEP 0 Modified: peps/trunk/pep-0211.txt ============================================================================== --- peps/trunk/pep-0211.txt (original) +++ peps/trunk/pep-0211.txt Mon May 1 22:03:44 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: gvwilson at ddj.com (Greg Wilson) -Status: Draft +Status: Deferred Type: Standards Track Python-Version: 2.1 Created: 15-Jul-2000 Modified: peps/trunk/pep-0212.txt ============================================================================== --- peps/trunk/pep-0212.txt (original) +++ peps/trunk/pep-0212.txt Mon May 1 22:03:44 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: nowonder at nowonder.de (Peter Schneider-Kamp) -Status: Draft +Status: Deferred Type: Standards Track Created: 22-Aug-2000 Python-Version: 2.1 Modified: peps/trunk/pep-0213.txt ============================================================================== --- peps/trunk/pep-0213.txt (original) +++ peps/trunk/pep-0213.txt Mon May 1 22:03:44 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: paul at prescod.net (Paul Prescod) -Status: Draft +Status: Deferred Type: Standards Track Python-Version: 2.1 Created: 21-Jul-2000 Modified: peps/trunk/pep-0219.txt ============================================================================== --- peps/trunk/pep-0219.txt (original) +++ peps/trunk/pep-0219.txt Mon May 1 22:03:44 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: gmcm at hypernet.com (Gordon McMillan) -Status: Draft +Status: Deferred Type: Standards Track Created: 14-Aug-2000 Python-Version: 2.1 Modified: peps/trunk/pep-0225.txt ============================================================================== --- peps/trunk/pep-0225.txt (original) +++ peps/trunk/pep-0225.txt Mon May 1 22:03:44 2006 @@ -4,7 +4,7 @@ Last-Modified: $Date$ Author: hzhu at users.sourceforge.net (Huaiyu Zhu), gregory.lielens at fft.be (Gregory Lielens) -Status: Draft +Status: Deferred Type: Standards Track Python-Version: 2.1 Created: 19-Sep-2000 Modified: peps/trunk/pep-0262.txt ============================================================================== --- peps/trunk/pep-0262.txt (original) +++ peps/trunk/pep-0262.txt Mon May 1 22:03:44 2006 @@ -5,7 +5,7 @@ Author: A.M. Kuchling Type: Standards Track Created: 08-Jul-2001 -Status: Draft +Status: Deferred Post-History: 27-Mar-2002 Introduction From python-checkins at python.org Mon May 1 22:04:27 2006 From: python-checkins at python.org (guido.van.rossum) Date: Mon, 1 May 2006 22:04:27 +0200 (CEST) Subject: [Python-checkins] r45849 - peps/trunk/pep-3099.txt Message-ID: <20060501200427.58D601E4024@bag.python.org> Author: guido.van.rossum Date: Mon May 1 22:04:27 2006 New Revision: 45849 Modified: peps/trunk/pep-3099.txt Log: Slices won't go away. Modified: peps/trunk/pep-3099.txt ============================================================================== --- peps/trunk/pep-3099.txt (original) +++ peps/trunk/pep-3099.txt Mon May 1 22:04:27 2006 @@ -53,6 +53,13 @@ Thread: sets in P3K? http://mail.python.org/pipermail/python-3000/2006-April/01474.html +* Slices and extended slices won't go away (even if the __getslice__ + and __setslice__ APIs may be replaced) nor will they return views + for the standard object types. + + Thread: Future of slices + http://mail.python.org/pipermail/python-3000/2006-May/001563.html + Builtins ======== From neal at metaslash.com Mon May 1 22:12:21 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 1 May 2006 16:12:21 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060501201221.GA31661@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33709 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8459 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8464 refs] [8464 refs] [8464 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8800 refs] [8800 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8675 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] this bit of output is from a test of stdout in a different process ... [8459 refs] [8459 refs] [8675 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8459 refs] [8459 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8459 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421880 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8464 refs] [8464 refs] [8464 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8800 refs] [8800 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8675 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] this bit of output is from a test of stdout in a different process ... [8459 refs] [8459 refs] [8675 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8459 refs] [8459 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8459 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421313 refs] From python-checkins at python.org Tue May 2 06:43:16 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 2 May 2006 06:43:16 +0200 (CEST) Subject: [Python-checkins] r45850 - in python/trunk: Doc/lib/libfuncs.tex Lib/test/test_subprocess.py Misc/NEWS Objects/fileobject.c Python/bltinmodule.c Message-ID: <20060502044316.408951E4010@bag.python.org> Author: neal.norwitz Date: Tue May 2 06:43:14 2006 New Revision: 45850 Modified: python/trunk/Doc/lib/libfuncs.tex python/trunk/Lib/test/test_subprocess.py python/trunk/Misc/NEWS python/trunk/Objects/fileobject.c python/trunk/Python/bltinmodule.c Log: SF #1479181: split open() and file() from being aliases for each other. Modified: python/trunk/Doc/lib/libfuncs.tex ============================================================================== --- python/trunk/Doc/lib/libfuncs.tex (original) +++ python/trunk/Doc/lib/libfuncs.tex Tue May 2 06:43:14 2006 @@ -455,12 +455,7 @@ after any I/O has been performed, and there's no reliable way to determine whether this is the case.} - The \function{file()} constructor is new in Python 2.2 and is an - alias for \function{open()}. Both spellings are equivalent. The - intent is for \function{open()} to continue to be preferred for use - as a factory function which returns a new \class{file} object. The - spelling, \class{file} is more suited to type testing (for example, - writing \samp{isinstance(f, file)}). + \versionadded{2.2} \end{funcdesc} \begin{funcdesc}{filter}{function, list} @@ -725,7 +720,10 @@ \end{funcdesc} \begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}} - An alias for the \function{file()} function above. + A wrapper for the \function{file()} function above. The intent is + for \function{open()} to be preferred for use as a factory function + returning a new \class{file} object. \class{file} is more suited to + type testing (for example, writing \samp{isinstance(f, file)}). \end{funcdesc} \begin{funcdesc}{ord}{c} Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Tue May 2 06:43:14 2006 @@ -347,7 +347,7 @@ stdout=subprocess.PIPE, universal_newlines=1) stdout = p.stdout.read() - if hasattr(open, 'newlines'): + if hasattr(p.stdout, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") @@ -374,7 +374,7 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate() - if hasattr(open, 'newlines'): + if hasattr(stdout, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 2 06:43:14 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1479181: split open() and file() from being aliases for each other. + - Bug #1465834: 'bdist_wininst preinstall script support' was fixed by converting these apis from macros into exported functions again: Modified: python/trunk/Objects/fileobject.c ============================================================================== --- python/trunk/Objects/fileobject.c (original) +++ python/trunk/Objects/fileobject.c Tue May 2 06:43:14 2006 @@ -2025,10 +2025,6 @@ "'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" "\n" "'U' cannot be combined with 'w' or '+' mode.\n" -) -PyDoc_STR( -"\n" -"Note: open() is an alias for file()." ); PyTypeObject PyFile_Type = { Modified: python/trunk/Python/bltinmodule.c ============================================================================== --- python/trunk/Python/bltinmodule.c (original) +++ python/trunk/Python/bltinmodule.c Tue May 2 06:43:14 2006 @@ -1342,6 +1342,18 @@ static PyObject * +builtin_open(PyObject *self, PyObject *args, PyObject *kwds) +{ + return PyObject_Call((PyObject*)&PyFile_Type, args, kwds); +} + +PyDoc_STRVAR(open_doc, +"open(name[, mode[, buffering]]) -> file object\n\ +\n\ +Open a file using the file() type, returns a file object."); + + +static PyObject * builtin_ord(PyObject *self, PyObject* obj) { long ord; @@ -2247,6 +2259,7 @@ {"max", (PyCFunction)builtin_max, METH_VARARGS | METH_KEYWORDS, max_doc}, {"min", (PyCFunction)builtin_min, METH_VARARGS | METH_KEYWORDS, min_doc}, {"oct", builtin_oct, METH_O, oct_doc}, + {"open", (PyCFunction)builtin_open, METH_VARARGS | METH_KEYWORDS, open_doc}, {"ord", builtin_ord, METH_O, ord_doc}, {"pow", builtin_pow, METH_VARARGS, pow_doc}, {"range", builtin_range, METH_VARARGS, range_doc}, @@ -2313,6 +2326,7 @@ #endif SETBUILTIN("dict", &PyDict_Type); SETBUILTIN("enumerate", &PyEnum_Type); + SETBUILTIN("file", &PyFile_Type); SETBUILTIN("float", &PyFloat_Type); SETBUILTIN("frozenset", &PyFrozenSet_Type); SETBUILTIN("property", &PyProperty_Type); @@ -2329,10 +2343,6 @@ SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); SETBUILTIN("xrange", &PyRange_Type); - - /* Note that open() is just an alias of file(). */ - SETBUILTIN("open", &PyFile_Type); - SETBUILTIN("file", &PyFile_Type); #ifdef Py_USING_UNICODE SETBUILTIN("unicode", &PyUnicode_Type); #endif From python-checkins at python.org Tue May 2 06:57:06 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 2 May 2006 06:57:06 +0200 (CEST) Subject: [Python-checkins] r45851 - peps/trunk/pep-0356.txt Message-ID: <20060502045706.760611E4010@bag.python.org> Author: neal.norwitz Date: Tue May 2 06:57:06 2006 New Revision: 45851 Modified: peps/trunk/pep-0356.txt Log: I just checked this in Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Tue May 2 06:57:06 2006 @@ -131,10 +131,6 @@ remove the ones that don't. (Owner: Anthony) - - file() vs. open(), round 7 - http://mail.python.org/pipermail/python-dev/2005-December/thread.html#59073 - (Owner: Aahz) - - All modules in Modules/ should be updated to be ssize_t clean. (Owner: Neal) From buildbot at python.org Tue May 2 07:04:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 05:04:51 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060502050451.9508E1E4010@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/415 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 2 07:11:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 05:11:51 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060502051151.259CB1E4010@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/621 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 2 07:19:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 05:19:11 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060502051911.C04D41E4010@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/632 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 2 07:31:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 05:31:24 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060502053124.457361E4010@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/402 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From tim.peters at gmail.com Tue May 2 07:52:57 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 2 May 2006 01:52:57 -0400 Subject: [Python-checkins] r45850 - in python/trunk: Doc/lib/libfuncs.tex Lib/test/test_subprocess.py Misc/NEWS Objects/fileobject.c Python/bltinmodule.c In-Reply-To: <20060502044316.408951E4010@bag.python.org> References: <20060502044316.408951E4010@bag.python.org> Message-ID: <1f7befae0605012252s1c563b04o8ed6a797d2861f87@mail.gmail.com> > Author: neal.norwitz > Date: Tue May 2 06:43:14 2006 > New Revision: 45850 > > Modified: > python/trunk/Doc/lib/libfuncs.tex > python/trunk/Lib/test/test_subprocess.py > python/trunk/Misc/NEWS > python/trunk/Objects/fileobject.c > python/trunk/Python/bltinmodule.c > Log: > SF #1479181: split open() and file() from being aliases for each other. Umm ... why? I suppose I wouldn't care, except it left test_subprocess failing on all the Windows buildbots, and I don't feel like figuring out why. To a first approximation, test_universal_newlines_communicate() now takes the # Interpreter without universal newline support branch on Windows, but shouldn't. From python-checkins at python.org Tue May 2 08:23:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 2 May 2006 08:23:23 +0200 (CEST) Subject: [Python-checkins] r45852 - in python/trunk/Lib: subprocess.py test/test_subprocess.py Message-ID: <20060502062323.7F02A1E4010@bag.python.org> Author: neal.norwitz Date: Tue May 2 08:23:22 2006 New Revision: 45852 Modified: python/trunk/Lib/subprocess.py python/trunk/Lib/test/test_subprocess.py Log: Try to fix breakage caused by patch #1479181, r45850 Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Tue May 2 08:23:22 2006 @@ -872,7 +872,7 @@ # object do the translation: It is based on stdio, which is # impossible to combine with select (unless forcing no # buffering). - if self.universal_newlines and hasattr(open, 'newlines'): + if self.universal_newlines and hasattr(file, 'newlines'): if stdout: stdout = self._translate_newlines(stdout) if stderr: @@ -1141,7 +1141,7 @@ # object do the translation: It is based on stdio, which is # impossible to combine with select (unless forcing no # buffering). - if self.universal_newlines and hasattr(open, 'newlines'): + if self.universal_newlines and hasattr(file, 'newlines'): if stdout: stdout = self._translate_newlines(stdout) if stderr: Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Tue May 2 08:23:22 2006 @@ -347,7 +347,7 @@ stdout=subprocess.PIPE, universal_newlines=1) stdout = p.stdout.read() - if hasattr(p.stdout, 'newlines'): + if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") @@ -374,7 +374,7 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate() - if hasattr(stdout, 'newlines'): + if hasattr(file, 'newlines'): # Interpreter with universal newline support self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6") From nnorwitz at gmail.com Tue May 2 08:25:47 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 1 May 2006 23:25:47 -0700 Subject: [Python-checkins] [Python-Dev] r45850 - in python/trunk: Doc/lib/libfuncs.tex Lib/test/test_subprocess.py Misc/NEWS Objects/fileobject.c Python/bltinmodule.c In-Reply-To: <1f7befae0605012252s1c563b04o8ed6a797d2861f87@mail.gmail.com> References: <20060502044316.408951E4010@bag.python.org> <1f7befae0605012252s1c563b04o8ed6a797d2861f87@mail.gmail.com> Message-ID: On 5/1/06, Tim Peters wrote: > > Author: neal.norwitz > > Date: Tue May 2 06:43:14 2006 > > New Revision: 45850 > > > > Modified: > > python/trunk/Doc/lib/libfuncs.tex > > python/trunk/Lib/test/test_subprocess.py > > python/trunk/Misc/NEWS > > python/trunk/Objects/fileobject.c > > python/trunk/Python/bltinmodule.c > > Log: > > SF #1479181: split open() and file() from being aliases for each other. > > Umm ... why? I suppose I wouldn't care, except it left I'll let Aahz answer that, it's his patch. > test_subprocess failing on all the Windows buildbots, and I don't feel > like figuring out why. To a first approximation, > test_universal_newlines_communicate() now takes the > > # Interpreter without universal newline support > > branch on Windows, but shouldn't. I tried to fix that breakage. n From python-checkins at python.org Tue May 2 08:54:00 2006 From: python-checkins at python.org (fred.drake) Date: Tue, 2 May 2006 08:54:00 +0200 (CEST) Subject: [Python-checkins] r45853 - in python/trunk: Doc/lib/libweakref.tex Lib/test/test_weakref.py Lib/weakref.py Message-ID: <20060502065400.33AD41E4010@bag.python.org> Author: fred.drake Date: Tue May 2 08:53:59 2006 New Revision: 45853 Modified: python/trunk/Doc/lib/libweakref.tex python/trunk/Lib/test/test_weakref.py python/trunk/Lib/weakref.py Log: SF #1479988: add methods to allow access to weakrefs for the weakref.WeakKeyDictionary and weakref.WeakValueDictionary Modified: python/trunk/Doc/lib/libweakref.tex ============================================================================== --- python/trunk/Doc/lib/libweakref.tex (original) +++ python/trunk/Doc/lib/libweakref.tex Tue May 2 08:53:59 2006 @@ -147,6 +147,24 @@ to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} +\class{WeakKeyDictionary} objects have the following additional +methods. These expose the internal references directly. The +references are not guaranteed to be ``live'' at the time they are +used, so the result of calling the references needs to be checked +before being used. This can be used to avoid creating references that +will cause the garbage collector to keep the keys around longer than +needed. + +\begin{methoddesc}{iterkeyrefs}{} + Return an iterator that yields the weak references to the keys. + \versionadded{2.5} +\end{methoddesc} + +\begin{methoddesc}{keyrefs}{} + Return a list of weak references to the keys. + \versionadded{2.5} +\end{methoddesc} + \begin{classdesc}{WeakValueDictionary}{\optional{dict}} Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value @@ -160,6 +178,21 @@ to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} +\class{WeakValueDictionary} objects have the following additional +methods. These method have the same issues as the +\method{iterkeyrefs()} and \method{keyrefs()} methods of +\class{WeakKeyDictionary} objects. + +\begin{methoddesc}{itervaluerefs}{} + Return an iterator that yields the weak references to the values. + \versionadded{2.5} +\end{methoddesc} + +\begin{methoddesc}{valuerefs}{} + Return a list of weak references to the values. + \versionadded{2.5} +\end{methoddesc} + \begin{datadesc}{ReferenceType} The type object for weak references objects. \end{datadesc} Modified: python/trunk/Lib/test/test_weakref.py ============================================================================== --- python/trunk/Lib/test/test_weakref.py (original) +++ python/trunk/Lib/test/test_weakref.py Tue May 2 08:53:59 2006 @@ -769,10 +769,54 @@ dict, objects = self.make_weak_keyed_dict() self.check_iters(dict) + # Test keyrefs() + refs = dict.keyrefs() + self.assertEqual(len(refs), len(objects)) + objects2 = list(objects) + for wr in refs: + ob = wr() + self.assert_(dict.has_key(ob)) + self.assert_(ob in dict) + self.assertEqual(ob.arg, dict[ob]) + objects2.remove(ob) + self.assertEqual(len(objects2), 0) + + # Test iterkeyrefs() + objects2 = list(objects) + self.assertEqual(len(list(dict.iterkeyrefs())), len(objects)) + for wr in dict.iterkeyrefs(): + ob = wr() + self.assert_(dict.has_key(ob)) + self.assert_(ob in dict) + self.assertEqual(ob.arg, dict[ob]) + objects2.remove(ob) + self.assertEqual(len(objects2), 0) + def test_weak_valued_iters(self): dict, objects = self.make_weak_valued_dict() self.check_iters(dict) + # Test valuerefs() + refs = dict.valuerefs() + self.assertEqual(len(refs), len(objects)) + objects2 = list(objects) + for wr in refs: + ob = wr() + self.assertEqual(ob, dict[ob.arg]) + self.assertEqual(ob.arg, dict[ob.arg].arg) + objects2.remove(ob) + self.assertEqual(len(objects2), 0) + + # Test itervaluerefs() + objects2 = list(objects) + self.assertEqual(len(list(dict.itervaluerefs())), len(objects)) + for wr in dict.itervaluerefs(): + ob = wr() + self.assertEqual(ob, dict[ob.arg]) + self.assertEqual(ob.arg, dict[ob.arg].arg) + objects2.remove(ob) + self.assertEqual(len(objects2), 0) + def check_iters(self, dict): # item iterator: items = dict.items() Modified: python/trunk/Lib/weakref.py ============================================================================== --- python/trunk/Lib/weakref.py (original) +++ python/trunk/Lib/weakref.py Tue May 2 08:53:59 2006 @@ -118,6 +118,18 @@ def __iter__(self): return self.data.iterkeys() + def itervaluerefs(self): + """Return an iterator that yields the weak references to the values. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the values around longer than needed. + + """ + return self.data.itervalues() + def itervalues(self): for wr in self.data.itervalues(): obj = wr() @@ -162,6 +174,18 @@ if len(kwargs): self.update(kwargs) + def valuerefs(self): + """Return a list of weak references to the values. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the values around longer than needed. + + """ + return self.data.values() + def values(self): L = [] for wr in self.data.values(): @@ -263,6 +287,18 @@ if key is not None: yield key, value + def iterkeyrefs(self): + """Return an iterator that yields the weak references to the keys. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the keys around longer than needed. + + """ + return self.data.iterkeys() + def iterkeys(self): for wr in self.data.iterkeys(): obj = wr() @@ -275,6 +311,18 @@ def itervalues(self): return self.data.itervalues() + def keyrefs(self): + """Return a list of weak references to the keys. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the keys around longer than needed. + + """ + return self.data.keys() + def keys(self): L = [] for wr in self.data.keys(): From fredrik at pythonware.com Tue May 2 08:59:12 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 May 2006 08:59:12 +0200 Subject: [Python-checkins] r45850 - in python/trunk:Doc/lib/libfuncs.tex Lib/test/test_subprocess.py Misc/NEWSObjects/fileobject.c Python/bltinmodule.c References: <20060502044316.408951E4010@bag.python.org> <1f7befae0605012252s1c563b04o8ed6a797d2861f87@mail.gmail.com> Message-ID: Tim Peters wrote: > > SF #1479181: split open() and file() from being aliases for each other. > > Umm ... why? so that introspection tools can support GvR's pronouncement that "open" should be used to open files, and "file" should be used as a type representing standard (current stdio-based) file handles. From buildbot at python.org Tue May 2 09:11:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 07:11:59 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060502071159.BB2481E4010@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/345 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 2 09:27:48 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 2 May 2006 09:27:48 +0200 (CEST) Subject: [Python-checkins] r45854 - python/trunk/Modules/expat/xmlparse.c python/trunk/Modules/expat/xmlrole.c python/trunk/Modules/expat/xmltok.c Message-ID: <20060502072748.E45801E4010@bag.python.org> Author: neal.norwitz Date: Tue May 2 09:27:47 2006 New Revision: 45854 Modified: python/trunk/Modules/expat/xmlparse.c python/trunk/Modules/expat/xmlrole.c python/trunk/Modules/expat/xmltok.c Log: Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1. The problem was that pyconfig.h was being included before some system headers which caused redefinitions and other breakage. This moves system headers after expat_config.h which includes pyconfig.h. Modified: python/trunk/Modules/expat/xmlparse.c ============================================================================== --- python/trunk/Modules/expat/xmlparse.c (original) +++ python/trunk/Modules/expat/xmlparse.c Tue May 2 09:27:47 2006 @@ -2,10 +2,6 @@ See the file COPYING for copying permission. */ -#include -#include /* memset(), memcpy() */ -#include - #define XML_BUILDING_EXPAT 1 #ifdef COMPILED_FROM_DSP @@ -16,6 +12,10 @@ #include #endif /* ndef COMPILED_FROM_DSP */ +#include +#include /* memset(), memcpy() */ +#include + #include "expat.h" #ifdef XML_UNICODE Modified: python/trunk/Modules/expat/xmlrole.c ============================================================================== --- python/trunk/Modules/expat/xmlrole.c (original) +++ python/trunk/Modules/expat/xmlrole.c Tue May 2 09:27:47 2006 @@ -2,8 +2,6 @@ See the file COPYING for copying permission. */ -#include - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) @@ -14,6 +12,8 @@ #endif #endif /* ndef COMPILED_FROM_DSP */ +#include + #include "expat_external.h" #include "internal.h" #include "xmlrole.h" Modified: python/trunk/Modules/expat/xmltok.c ============================================================================== --- python/trunk/Modules/expat/xmltok.c (original) +++ python/trunk/Modules/expat/xmltok.c Tue May 2 09:27:47 2006 @@ -2,8 +2,6 @@ See the file COPYING for copying permission. */ -#include - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) @@ -14,6 +12,8 @@ #endif #endif /* ndef COMPILED_FROM_DSP */ +#include + #include "expat_external.h" #include "internal.h" #include "xmltok.h" From tim.peters at gmail.com Tue May 2 09:47:42 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 2 May 2006 03:47:42 -0400 Subject: [Python-checkins] r45850 - in python/trunk:Doc/lib/libfuncs.tex Lib/test/test_subprocess.py Misc/NEWSObjects/fileobject.c Python/bltinmodule.c In-Reply-To: References: <20060502044316.408951E4010@bag.python.org> <1f7befae0605012252s1c563b04o8ed6a797d2861f87@mail.gmail.com> Message-ID: <1f7befae0605020047o4c138450vd4dbc1385fa422a9@mail.gmail.com> >>> SF #1479181: split open() and file() from being aliases for each other. >> Umm ... why? [/F] > so that introspection tools can support GvR's pronouncement that "open" > should be used to open files, and "file" should be used as a type representing > standard (current stdio-based) file handles. Maybe some of the intended changes are missing? The post-patch docstrings don't draw this distinction, and I'm lost about what else introspection tools could be looking at to make the distinction (special-casing the names? but they could have done that before): """ >>> print open.__doc__ open(name[, mode[, buffering]]) -> file object Open a file using the file() type, returns a file object. >>> print file.__doc__ file(name[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. Add a 'U' to mode to open the file for input with universal newline support. Any line ending in the input file will be seen as a '\n' in Python. Also, a file so opened gains the attribute 'newlines'; the value for this attribute is one of None (no newline read yet), '\r', '\n', '\r\n' or a tuple containing all the newline types seen. 'U' cannot be combined with 'w' or '+' mode. >>> """ In Python 2.4, the docstrings were of course the same (the current trunk's file.__doc__ except for a line at the end). Since all useful info about how to open a file has been purged from open()'s docstring, if you've got the intent right, looks like the implementation got it backwards ;-) OK, maybe this is what you have in mind: >>> type(open) >>> type(file) Fine, if that's all there really is to this, but I think it's a net loss if open()'s docstring regression stands -- someone should finish this job, or it should be reverted. From neal at metaslash.com Tue May 2 10:12:24 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 2 May 2006 04:12:24 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060502081224.GA8539@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33709 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8459 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8464 refs] [8464 refs] [8464 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8800 refs] [8800 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8675 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] this bit of output is from a test of stdout in a different process ... [8459 refs] [8459 refs] [8675 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8459 refs] [8459 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8459 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [422013 refs] ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8464 refs] [8464 refs] [8464 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8800 refs] [8800 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8675 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] [8459 refs] this bit of output is from a test of stdout in a different process ... [8459 refs] [8459 refs] [8675 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8459 refs] [8459 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8459 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421412 refs] make: *** [test] Error 1 From python-checkins at python.org Tue May 2 10:35:37 2006 From: python-checkins at python.org (vinay.sajip) Date: Tue, 2 May 2006 10:35:37 +0200 (CEST) Subject: [Python-checkins] r45855 - python/trunk/Lib/logging/handlers.py Message-ID: <20060502083537.8AAB61E4012@bag.python.org> Author: vinay.sajip Date: Tue May 2 10:35:36 2006 New Revision: 45855 Modified: python/trunk/Lib/logging/handlers.py Log: Replaced my dumb way of calculating seconds to midnight with Tim Peters' much more sensible suggestion. What was I thinking ?!? Modified: python/trunk/Lib/logging/handlers.py ============================================================================== --- python/trunk/Lib/logging/handlers.py (original) +++ python/trunk/Lib/logging/handlers.py Tue May 2 10:35:36 2006 @@ -44,6 +44,8 @@ DEFAULT_SOAP_LOGGING_PORT = 9023 SYSLOG_UDP_PORT = 514 +_MIDNIGHT = 24 * 60 * 60 # number of seconds in a day + class BaseRotatingHandler(logging.FileHandler): """ Base class for handlers that rotate log files at a certain point. @@ -217,12 +219,8 @@ currentMinute = t[4] currentSecond = t[5] # r is the number of seconds left between now and midnight - if (currentMinute == 0) and (currentSecond == 0): - r = (24 - currentHour) * 60 * 60 # number of hours in seconds - else: - r = (23 - currentHour) * 60 * 60 - r = r + (59 - currentMinute) * 60 # plus the number of minutes (in secs) - r = r + (60 - currentSecond) # plus the number of seconds + r = _MIDNIGHT - ((currentHour * 60 + currentMinute) * 60 + + currentSecond) self.rolloverAt = currentTime + r # If we are rolling over on a certain day, add in the number of days until # the next rollover, but offset by 1 since we just calculated the time From buildbot at python.org Tue May 2 10:55:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 08:55:02 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060502085502.9A98E1E4012@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/347 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 2 12:35:23 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 10:35:23 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060502103523.2D6BA1E4012@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/67 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: vinay.sajip Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 2 13:30:04 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 2 May 2006 13:30:04 +0200 (CEST) Subject: [Python-checkins] r45856 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060502113004.BF2C51E4017@bag.python.org> Author: andrew.kuchling Date: Tue May 2 13:30:03 2006 New Revision: 45856 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Provide encoding as keyword argument; soften warning paragraph about encodings Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 2 13:30:03 2006 @@ -1724,14 +1724,15 @@ # Encoding is UTF-8 f = open('output.xml', 'w') -tree.write(f, 'utf-8') +tree.write(f, encoding='utf-8') \end{verbatim} -(Caution: the default encoding used for output is ASCII, which isn't -very useful for general XML work, raising an exception if there are -any characters with values greater than 127. You should always -specify a different encoding such as UTF-8 that can handle any Unicode -character.) +(Caution: the default encoding used for output is ASCII. For general +XML work, where an element's name may contain arbitrary Unicode +characters, ASCII isn't a very useful encoding because it will raise +an exception if an element's name contains any characters with values +greater than 127. Therefore, it's best to specify a different +encoding such as UTF-8 that can handle any Unicode character.) This section is only a partial description of the ElementTree interfaces. Please read the package's official documentation for more details. From buildbot at python.org Tue May 2 14:42:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 12:42:28 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060502124228.C1BD21E4012@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/349 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 2 16:28:50 2006 From: python-checkins at python.org (nick.coghlan) Date: Tue, 2 May 2006 16:28:50 +0200 (CEST) Subject: [Python-checkins] r45857 - peps/trunk/pep-0343.txt Message-ID: <20060502142850.4F5D51E4012@bag.python.org> Author: nick.coghlan Date: Tue May 2 16:28:47 2006 New Revision: 45857 Modified: peps/trunk/pep-0343.txt Log: Remove the __context__ method from PEP 343, and update the terminology section (again). Record a couple of remaining open issues, and try to clarify the resolved issues sections by only giving a very brief overview of all the rejected options that aren't relevant any more. Modified: peps/trunk/pep-0343.txt ============================================================================== --- peps/trunk/pep-0343.txt (original) +++ peps/trunk/pep-0343.txt Tue May 2 16:28:47 2006 @@ -7,18 +7,16 @@ Type: Standards Track Content-Type: text/plain Created: 13-May-2005 -Post-History: 2-Jun-2005, 16-Oct-2005, 29-Oct-2005, 23-Apr-2006 +Post-History: 2-Jun-2005, 16-Oct-2005, 29-Oct-2005, 23-Apr-2006, 1-May-2006 Abstract This PEP adds a new statement "with" to the Python language to make it possible to factor out standard uses of try/finally statements. - The PEP was approved in principle by the BDFL, but there were - still a couple of implementation details to be worked out (see the - section on Resolved Issues). It's still at Draft status until - Guido gives a final blessing to the updated PEP. - + In this PEP, context managers provide __enter__() and __exit__() + methods that are invoked on entry to and exit from the managed + context that forms the body of the with statement. Author's Note @@ -29,13 +27,17 @@ Python's alpha release cycle revealed terminology problems in this PEP and in the associated documentation and implementation [14]. - So while the PEP is already accepted, this refers to the - implementation rather than the exact terminology. + So while the PEP is already accepted in principle, it won't really + be considered stable until the status becomes Final. - The current version of the PEP reflects the implementation and - documentation as at Python 2.5a2. The PEP will be updated to - reflect any changes made to the terminology prior to the final - Python 2.5 release. + The current version of the PEP reflects the discussions that + occurred on python-dev shortly after the release of Python 2.5a2. + The PEP will continue to be updated to reflect any changes made to + the details of the feature prior to the final Python 2.5 release. + + Yes, the verb tense is messed up in a few places. We've been + working on this PEP for nearly a year now, so things that were + originally in the future are now in the past :) Introduction @@ -48,11 +50,8 @@ [2] and universally approved of. I'm also changing the keyword to 'with'. - On-line discussion of this PEP should take place in the Python - Wiki [3]. - - If this PEP is approved, the following PEPs will be rejected due - to overlap: + Following acceptance of this PEP, the following PEPs have been + rejected due to overlap: - PEP 310, Reliable Acquisition/Release Pairs. This is the original with-statement proposal. @@ -66,7 +65,11 @@ important; in fact it may be better to always be explicit about the mutex being used. - (PEP 340 and PEP 346 have already been withdrawn.) + PEP 340 and PEP 346 also overlapped with this PEP, but were + voluntarily withdrawn when this PEP was submitted. + + Some discussion of earlier incarnations of this PEP took place on + the Python Wiki [3]. Motivation and Summary @@ -92,7 +95,7 @@ control flow, in the end, the control flow resumes as if the finally-suite wasn't there at all. - Remember, PEP 310 proposes rougly this syntax (the "VAR =" part is + Remember, PEP 310 proposes roughly this syntax (the "VAR =" part is optional): with VAR = EXPR: @@ -213,6 +216,9 @@ not make the same guarantee. This applies to Jython, IronPython, and probably to Python running on Parrot. + (The details of the changes made to generators can now be found in + PEP 342 rather than in the current PEP) + Use Cases See the Examples section near the end. @@ -236,7 +242,7 @@ The translation of the above statement is: - mgr = (EXPR).__context__() + mgr = (EXPR) exit = mgr.__exit__ # Not calling it yet value = mgr.__enter__() exc = True @@ -260,9 +266,9 @@ implemented as special registers or stack positions. The details of the above translation are intended to prescribe the - exact semantics. If any of the relevant methods are not found as - expected, the interpreter will raise AttributeError, in the order - that they are tried (__context__, __exit__, __enter__). + exact semantics. If either of the relevant methods are not found + as expected, the interpreter will raise AttributeError, in the + order that they are tried (__exit__, __enter__). Similarly, if any of the calls raises an exception, the effect is exactly as it would be in the above code. Finally, if BLOCK contains a break, continue or return statement, the __exit__() @@ -270,15 +276,6 @@ completed normally. (I.e. these "pseudo-exceptions" are not seen as exceptions by __exit__().) - The call to the __context__() method serves a similar purpose to - that of the __iter__() method of iterator and iterables. A context - specifier with simple state requirements (such as - threading.RLock) may provide its own __enter__() and __exit__() - methods, and simply return 'self' from its __context__ method. On - the other hand, a context specifier with more complex state - requirements (such as decimal.Context) may return a distinct - context manager each time its __context__ method is invoked. - If the "as VAR" part of the syntax is omitted, the "VAR =" part of the translation is omitted (but mgr.__enter__() is still called). @@ -324,38 +321,25 @@ of a database transaction roll-back decision. To facilitate chaining of contexts in Python code that directly - manipulates context specifiers and managers, __exit__() methods - should *not* re-raise the error that is passed in to them, because - it is always the responsibility of the *caller* to do any reraising - in that case. + manipulates context managers, __exit__() methods should *not* + re-raise the error that is passed in to them. It is always the + responsibility of the *caller* of the __exit__() method to do any + reraising in that case. That way, if the caller needs to tell whether the __exit__() invocation *failed* (as opposed to successfully cleaning up before propagating the original error), it can do so. If __exit__() returns without an error, this can then be - interpreted as success of the __exit__() method itself (whether the - original error is to be propagated or suppressed). + interpreted as success of the __exit__() method itself (regardless + of whether or not the original error is to be propagated or + suppressed). However, if __exit__() propagates an exception to its caller, this means that __exit__() *itself* has failed. Thus, __exit__() methods should avoid raising errors unless they have actually failed. (And allowing the original error to proceed isn't a failure.) - - Objects returned by __context__() methods should also provide a - __context__() method that returns self. This allows a program to - retrieve the context manager directly without breaking anything. - For example, the following should work just as well as the normal - case where the extra variable isn't used: - - mgr = (EXPR).__context__() - with mgr as VAR: - BLOCK - - The with statement implementation and examples like the nested() - function require this behaviour in order to be able to deal - transparently with both context specifiers and context managers. Transition Plan @@ -382,9 +366,6 @@ def __init__(self, gen): self.gen = gen - def __context__(self): - return self - def __enter__(self): try: return self.gen.next() @@ -435,17 +416,7 @@ A robust implementation of this decorator will be made part of the standard library. - Just as generator-iterator functions are very useful for writing - __iter__() methods for iterables, generator context functions will - be very useful for writing __context__() methods for context - specifiers. These methods will still need to be decorated using the - contextmanager decorator. To ensure an obvious error message if the - decorator is left out, generator-iterator objects will NOT be given - a native context - if you want to ensure a generator is closed - promptly, use something similar to the duck-typed "closing" context - manager in the examples. - -Optional Extensions +Context Managers in the Standard Library It would be possible to endow certain objects, like files, sockets, and locks, with __enter__() and __exit__() methods so @@ -476,133 +447,110 @@ second with-statement calls f.__enter__() again. A similar error can be raised if __enter__ is invoked on a closed file object. - For Python 2.5, the following candidates have been identified for - native context managers: + For Python 2.5, the following types have been identified as + context managers: - file - - decimal.Context - thread.LockType - threading.Lock - threading.RLock - threading.Condition - - threading.Semaphore and threading.BoundedSemaphore + - threading.Semaphore + - threading.BoundedSemaphore -Standard Terminology + A context manager will also be added to the decimal module to + support using a local decimal arithmetic context within the body + of a with statement, automatically restoring the original context + when the with statement is exited. - Discussions about iterators and iterables are aided by the standard - terminology used to discuss them. The protocol used by the for - statement is called the iterator protocol and an iterator is any - object that properly implements that protocol. The term "iterable" - then encompasses all objects with an __iter__() method that - returns an iterator. +Standard Terminology This PEP proposes that the protocol consisting of the __enter__() - and __exit__() methods, and a __context__() method that returns - self be known as the "context management protocol", and that - objects that implement that protocol be known as "context - managers". - - The term "context specifier" then encompasses all objects with a - __context__() method that returns a context manager. The protocol - these objects implement is called the "context specification - protocol". This means that all context managers are context - specifiers, but not all context specifiers are context managers, - just as all iterators are iterables, but not all iterables are - iterators. - - These terms are based on the concept that the context specifier - defines a context of execution for the code that forms the body of - the with statement. The role of the context manager is to - translate the context specifier's stored state into an active - manipulation of the runtime environment to setup and tear down the - desired runtime context for the duration of the with statement. - For example, a synchronisation lock's context manager acquires the - lock when entering the with statement, and releases the lock when - leaving it. The runtime context established within the body of the - with statement is that the synchronisation lock is currently held. + and __exit__() methods be known as the "context management protocol", + and that objects that implement that protocol be known as "context + managers". [4] + + The code in the body of the with statement is a "managed context". + This term refers primarily to the code location, rather than to the + runtime environment established by the context manager. + + The expression immediately following the with keyword in the + statement is a "context expression" as that expression provides the + main clue as to the runtime environment the context manager + establishes for the duration of the managed context. + + The value assigned to the target list after the as keyword is the + "context entry value", as that value is returned as the result of + entering the context. + + These terms are based on the idea that the context expression + provides a context manager to appropriately handle entry into the + managed context. The context manager may also provide a meaningful + context entry value and perform clean up operations on exit from + the managed context. The general term "context" is unfortunately ambiguous. If necessary, - it can be made more explicit by using the terms "context specifier" - for objects providing a __context__() method and "runtime context" - for the runtime environment modifications made by the context - manager. When solely discussing use of the with statement, the - distinction between the two shouldn't matter as the context - specifier fully defines the changes made to the runtime context. - The distinction is more important when discussing the process of - implementing context specifiers and context managers. + it can be made more explicit by using the terms "context manager" + for the concrete object created by the context expression, + "managed context" for the code in the body of the with statement, + and "runtime context" or (preferebly) "runtime environment" for the + actual state modifications made by the context manager. When solely + discussing use of the with statement, the distinction between these + shouldn't matter too much as the context manager fully defines the + changes made to the runtime environment, and those changes apply for + the duration of the managed context. The distinction is more + important when discussing the process of implementing context + managers and the mechanics of the with statement itself. + +Caching Context Managers + + Many context managers (such as files and generator-based contexts) + will be single-use objects. Once the __exit__() method has been + called, the context manager will no longer be in a usable state + (e.g. the file has been closed, or the underlying generator has + finished execution). + + Requiring a fresh manager object for each with statement is the + easiest way to avoid problems with multi-threaded code and nested + with statements trying to use the same context manager. It isn't + coincidental that all of the standard library context managers + that support reuse come from the threading module - they're all + already designed to deal with the problems created by threaded + and nested usage. + + This means that in order to save a context manager with particular + initialisation arguments to be used in multiple with statements, it + will typically be necessary to store it in a zero-argument callable + that is then called in the context expression of each statement + rather than caching the context manager directly. + + When this restriction does not apply, the documentation of the + affected context manager should make that clear. + Open Issues - 1. After this PEP was originally approved, a subsequent discussion - on python-dev [4] settled on the term "context manager" for - objects which provide __enter__ and __exit__ methods, and - "context management protocol" for the protocol itself. With the - addition of the __context__ method to the protocol, the natural - adjustment is to call all objects which provide a __context__ - method "context managers", and the objects with __enter__ and - __exit__ methods "contexts" (or "manageable contexts" in - situations where the general term "context" would be ambiguous). - - As noted above, the Python 2.5 release cycle revealed problems - with the previously agreed terminology. The updated standard - terminology section has not yet met with consensus on - python-dev. It will be refined throughout the Python 2.5 release - cycle based on user feedback on the usability of the - documentation. - The first change made as a result of the current discussion is - replacement of the term "context object" with - "context specifier". - - 2. The original resolution was for the decorator to make a context - manager from a generator to be a builtin called "contextmanager". - The shorter term "context" was considered too ambiguous and - potentially confusing [9]. - The different flavours of generators could then be described as: - - A "generator function" is an undecorated function containing - the 'yield' keyword, and the objects produced by - such functions are "generator-iterators". The term - "generator" may refer to either a generator function or a - generator-iterator depending on the situation. - - A "generator context function" is a generator function to - which the "contextmanager" decorator is applied and the - objects produced by such functions are "generator-context- - managers". The term "generator context" may refer to either - a generator context function or a generator-context-manager - depending on the situation. - - In the Python 2.5 implementation, the decorator is actually part - of the standard library module contextlib. The ongoing - terminology review may lead to it being renamed - "contextlib.context" (with the existence of the underlying context - manager being an implementation detail). + 1. Greg Ewing raised the question of whether or not the term + "context manager" was too generic and suggested "context guard" + as an alternative name. + + 2. In Python 2.5a2, the decorator in contextlib to create a + context manager from a generator function is called + @contextfactory. This made sense when the __context__() + method existed and the result of the factory function was + a managed context object. + With the elimination of the __context__() method, the + result of the factory function is once again a context + manager, suggesting the decorator should be renamed to + either @contextmanager or @managerfactory. + The PEP currently uses @contextmanager. Resolved Issues - The following issues were resolved either by BDFL approval, - consensus on python-dev, or a simple lack of objection to - proposals in the original version of this PEP. - - 1. The __exit__() method of the GeneratorContextManager class - catches StopIteration and considers it equivalent to re-raising - the exception passed to throw(). Is allowing StopIteration - right here? - - This is so that a generator doing cleanup depending on the - exception thrown (like the transactional() example below) can - *catch* the exception thrown if it wants to and doesn't have to - worry about re-raising it. I find this more convenient for the - generator writer. Against this was brought in that the - generator *appears* to suppress an exception that it cannot - suppress: the transactional() example would be more clear - according to this view if it re-raised the original exception - after the call to db.rollback(). I personally would find the - requirement to re-raise the exception an annoyance in a - generator used as a with-template, since all the code after - yield is used for is cleanup, and it is invoked from a - finally-clause (the one implicit in the with-statement) which - re-raises the original exception anyway. + The following issues were resolved by BDFL approval (and a lack + of any major objections on python-dev). - 2. What exception should GeneratorContextManager raise when the + 1. What exception should GeneratorContextManager raise when the underlying generator-iterator misbehaves? The following quote is the reason behind Guido's choice of RuntimeError for both this and for the generator close() method in PEP 342 (from [8]): @@ -617,61 +565,32 @@ and for uninitialized objects (and for a variety of miscellaneous conditions)." - 3. See item 1 in open issues :) - - - 4. The originally approved version of this PEP did not include a - __context__ method - the method was only added to the PEP after - Jason Orendorff pointed out the difficulty of writing - appropriate __enter__ and __exit__ methods for decimal.Context - [5]. This approach allows a class to define a native context - manager using generator syntax. It also allows a class to use an - existing independent context as its native context object by - applying the independent context to 'self' in its __context__ - method. It even allows a class written in C to - use a generator context manager written in Python. - The __context__ method parallels the __iter__ method which forms - part of the iterator protocol. - An earlier version of this PEP called this the __with__ method. - This was later changed to match the name of the protocol rather - than the keyword for the statement [9]. - - 5. The suggestion was made by Jason Orendorff that the __enter__ - and __exit__ methods could be removed from the context - management protocol, and the protocol instead defined directly - in terms of the enhanced generator interface described in PEP - 342 [6]. - Guido rejected this idea [7]. The following are some of benefits - of keeping the __enter__ and __exit__ methods: - - it makes it easy to implement a simple context in C - without having to rely on a separate coroutine builder - - it makes it easy to provide a low-overhead implementation - for contexts that don't need to maintain any - special state between the __enter__ and __exit__ methods - (having to use a generator for these would impose - unnecessary overhead without any compensating benefit) - - it makes it possible to understand how the with statement - works without having to first understand the mechanics of - how generator context managers are implemented. - - 6. See item 2 in open issues :) - - 7. A generator function used to implement a __context__ method will - need to be decorated with the contextmanager decorator in order - to have the correct behaviour. Otherwise, you will get an - AttributeError when using the class in a with statement, as - normal generator-iterators will NOT have __enter__ or __exit__ - methods. - Getting deterministic closure of generators will require a - separate context manager such as the closing example below. - As Guido put it, "too much magic is bad for your health" [10]. - - 8. It is fine to raise AttributeError instead of TypeError if the + 2. It is fine to raise AttributeError instead of TypeError if the relevant methods aren't present on a class involved in a with statement. The fact that the abstract object C API raises TypeError rather than AttributeError is an accident of history, rather than a deliberate design decision [11]. +Rejected Options + + For several months, the PEP prohibited suppression of exceptions + in order to avoid hidden flow control. Implementation + revealed this to be a right royal pain, so Guido restored the + ability [13]. + + Another aspect of the PEP that caused no end of questions and + terminology debates was providing a __context__() method that + was analogous to an iterable's __iter__() method [5, 7, 9]. + The ongoing problems [10, 13] with explaining what it was and why + it was and how it was meant to work eventually lead to Guido + killing the concept outright [15] (and there was much rejoicing!). + + The notion of using the PEP 342 generator API directly to define + the with statement was also briefly entertained [6], but quickly + dismissed as making it too difficult to write non-generator + based context managers. + + Examples The generator based examples rely on PEP 342. Also, some of the @@ -703,10 +622,6 @@ # guaranteed to be released when the block is left (even # if via return or by an uncaught exception). - PEP 319 gives a use case for also having an unlocked() - context; this can be written very similarly (just swap the - acquire() and release() calls). - 2. A template for opening a file that ensures the file is closed when the block is left: @@ -743,14 +658,10 @@ class locked: def __init__(self, lock): self.lock = lock - def __context__(self): - return self def __enter__(self): self.lock.acquire() def __exit__(self, type, value, tb): self.lock.release() - if type is not None: - raise type, value, tb (This example is easily modified to implement the other relatively stateless examples; it shows that it is easy to avoid @@ -844,52 +755,59 @@ # so this must be outside the with-statement: return +s - 9. Here's a proposed native context manager for decimal.Context: + 9. Here's a proposed context manager for the decimal module: # This would be a new decimal.Context method @contextmanager - def __context__(self): + def localcontext(ctx=None): + """Set a new local decimal context for the block""" + # Default to using the current context + if ctx is None: + ctx = getcontext() # We set the thread context to a copy of this context # to ensure that changes within the block are kept - # local to the block. This also gives us thread safety - # and supports nested usage of a given context. - newctx = self.copy() + # local to the block. + newctx = ctx.copy() oldctx = decimal.getcontext() decimal.setcontext(newctx) try: yield newctx finally: + # Always restore the original context decimal.setcontext(oldctx) Sample usage: + from decimal import localcontext, ExtendedContext + def sin(x): - with decimal.getcontext() as ctx: + with localcontext() as ctx: ctx.prec += 2 # Rest of sin calculation algorithm # uses a precision 2 greater than normal return +s # Convert result to normal precision def sin(x): - with decimal.ExtendedContext: + with localcontext(ExtendedContext): # Rest of sin calculation algorithm # uses the Extended Context from the # General Decimal Arithmetic Specification return +s # Convert result to normal context - 10. A generic "object-closing" template: + 10. A generic "object-closing" context manager: - @contextmanager - def closing(obj): - try: - yield obj - finally: + class closing(object): + def __init__(self, obj): + self.obj = obj + def __enter__(self): + return self.obj + def __exit__(self, *exc_info): try: - close = obj.close + close_it = self.obj.close except AttributeError: pass else: - close() + close_it() This can be used to deterministically close anything with a close method, be it file, generator, or something else. It @@ -907,20 +825,27 @@ for datum in data: process(datum) - 11. Native contexts for objects with acquire/release methods: + (Python 2.5's contextlib module contains a version + of this context manager) - # This would be a new method of e.g., threading.RLock - def __context__(self): - return locked(self) + 11. PEP 319 gives a use case for also having a released() + context to temporarily release a previously acquired lock; + this can be written very similarly to the locked context + manager above by swapping the acquire() and release() calls. - def released(self): - return unlocked(self) + class released: + def __init__(self, lock): + self.lock = lock + def __enter__(self): + self.lock.release() + def __exit__(self, type, value, tb): + self.lock.acquire() Sample usage: with my_lock: # Operations with the lock held - with my_lock.released(): + with released(my_lock): # Operations without the lock # e.g. blocking I/O # Lock is held again here @@ -973,56 +898,81 @@ with c as z: # Perform operation + (Python 2.5's contextlib module contains a version + of this context manager) Reference Implementation This PEP was first accepted by Guido at his EuroPython keynote, 27 June 2005. It was accepted again later, with the __context__ method added. - The PEP was implemented for Python 2.5a1 + The PEP was implemented in subversion for Python 2.5a1 + The __context__() method will be removed in Python 2.5a3 + + +Ackowledgements + + Many people contributed to the ideas and concepts in this PEP, + including all those mentioned in the acknowledgements for PEP 340 + and PEP 346. + + Additional thanks goes to (in no meaningful order): Paul Moore, + Phillip J. Eby, Greg Ewing, Jason Orendorff, Michael Hudson, + Raymond Hettinger, Walter Dörwald, Aahz, Georg Brandl, Terry Reedy, + A.M. Kuchling, Brett Cannon, and all those that participated in the + discussions on python-dev. References - [1] http://blogs.msdn.com/oldnewthing/archive/2005/01/06/347666.aspx + [1] Raymond Chen's article on hidden flow control + http://blogs.msdn.com/oldnewthing/archive/2005/01/06/347666.aspx - [2] http://mail.python.org/pipermail/python-dev/2005-May/053885.html + [2] Guido suggests some generator changes that ended up in PEP 342 + http://mail.python.org/pipermail/python-dev/2005-May/053885.html - [3] http://wiki.python.org/moin/WithStatement + [3] Wiki discussion of PEP 343 + http://wiki.python.org/moin/WithStatement - [4] + [4] Early draft of some documentation for the with statement http://mail.python.org/pipermail/python-dev/2005-July/054658.html - [5] + [5] Proposal to add the __with__ method http://mail.python.org/pipermail/python-dev/2005-October/056947.html - [6] + [6] Proposal to use the PEP 342 enhanced generator API directly http://mail.python.org/pipermail/python-dev/2005-October/056969.html - [7] + [7] Guido lets me (Nick Coghlan) talk him into a bad idea ;) http://mail.python.org/pipermail/python-dev/2005-October/057018.html - [8] + [8] Guido raises some exception handling questions http://mail.python.org/pipermail/python-dev/2005-June/054064.html - [9] + [9] Guido answers some questions about the __context__ method http://mail.python.org/pipermail/python-dev/2005-October/057520.html - [10] + [10] Guido answers more questions about the __context__ method http://mail.python.org/pipermail/python-dev/2005-October/057535.html - [11] + [11] Guido says AttributeError is fine for missing special methods http://mail.python.org/pipermail/python-dev/2005-October/057625.html - [12] + [12] Original PEP 342 implementation patch http://sourceforge.net/tracker/index.php?func=detail&aid=1223381&group_id=5470&atid=305470 - [13] - http://mail.python.org/pipermail/python-dev/2006-February/061903.html + [13] Guido restores the ability to suppress exceptions + http://mail.python.org/pipermail/python-dev/2006-February/061909.html - [14] + [14] A simple question kickstarts a thorough review of PEP 343 http://mail.python.org/pipermail/python-dev/2006-April/063859.html + [15] Guido kills the __context__() method + http://mail.python.org/pipermail/python-dev/2006-April/064632.html + + [16] Greg propose 'context guard' instead of 'context manager' + http://mail.python.org/pipermail/python-dev/2006-May/064676.html + Copyright This document has been placed in the public domain. From jimjjewett at gmail.com Tue May 2 16:51:12 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Tue, 2 May 2006 10:51:12 -0400 Subject: [Python-checkins] r45839 - python/trunk/Doc/lib/lib.tex python/trunk/Doc/lib/libmsilib.tex In-Reply-To: <20060501161245.7AF361E4011@bag.python.org> References: <20060501161245.7AF361E4011@bag.python.org> Message-ID: a few nitpicks On 5/1/06, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Mon May 1 18:12:44 2006 > New Revision: 45839 > > Added: > python/trunk/Doc/lib/libmsilib.tex (contents, props changed) > Log: > Add msilib documentation. ============================================================================== > --- (empty file) > +++ python/trunk/Doc/lib/libmsilib.tex Mon May 1 18:12:44 2006 > +\index{msi} > + > +\versionadded{2.5} > + > +The \module{msilib} supports the creation of Microsoft Installer > +(\code{.msi}) files. Because these files often contain an embedded > +``cabinet'' file (\code{.cab}), it also exposes an API to create > +CAB files. Support for reading \code{.cab} files is currently not > +implemented; read support for the \code{.msi} database is possible. Is there an URL describing these formats? [Note: I apologize if it should have been obvious from the seealso urls; for some reason I get only a top level table of contents on any of them; I suspect this is a local problem, though, since I'm not using MSIE and it seems to apply to all of MSDN.] > +\begin{funcdesc}{FCICreate}{cabname, files} > + Create a new CAB file named \var{cabname}. \var{files} must > + be a list of tuples, each containing the name of the file on > + disk, and the name of the file inside the CAB file. > + > + The files are added to the CAB file in the order they have > + in the list. All files are added into a single CAB file, > + using the MSZIP compression algorithm. Should that be "in the order that they appear in the list"/ Is there a good URL for the MSZIP format? google pointed at non-MS sources, though one suggested http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp > +\begin{funcdesc}{OpenDatabase}{path, persist} > + Return a new database object by calling MsiOpenDatabase. > + \var{path} is the file name of the > + MSI file; persist can be one of the constants > + \code{MSIDBOPEN_CREATEDIRECT}, \code{MSIDBOPEN_CREATE}, > + \code{MSIDBOPEN_DIRECT}, \code{MSIDBOPEN_READONLY}, or > + \code{MSIDBOPEN_TRANSACT}, and may include the flag > + \code{MSIDBOPEN_PATCHFILE}. See the Microsoft documentation for > + the meaning of these flags; depending on the flags, > + an existing database is opened, or a new one created. > +\end{funcdesc} Any particular place in the documentation? Preferably an URL > +\begin{funcdesc}{add_tables}{database, module} > + Add all table content from \var{module} to \var{database}. > + \var{module} must contain an attribute \var{tables} > + listing all tables for which content should be added, > + and one attribute per table that has the actual content. > + > + This is typically used to install the sequence > +\end{funcdesc} Is that last sentence complete? -jJ From python-checkins at python.org Tue May 2 19:36:10 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 2 May 2006 19:36:10 +0200 (CEST) Subject: [Python-checkins] r45858 - in python/trunk/Lib: test/test_traceback.py traceback.py Message-ID: <20060502173610.7F9501E4012@bag.python.org> Author: guido.van.rossum Date: Tue May 2 19:36:09 2006 New Revision: 45858 Modified: python/trunk/Lib/test/test_traceback.py python/trunk/Lib/traceback.py Log: Fix the formatting of KeyboardInterrupt -- a bad issubclass() call. Modified: python/trunk/Lib/test/test_traceback.py ============================================================================== --- python/trunk/Lib/test/test_traceback.py (original) +++ python/trunk/Lib/test/test_traceback.py Tue May 2 19:36:09 2006 @@ -103,6 +103,12 @@ import sys sys.exc_traceback.__members__ + def test_base_exception(self): + # Test that exceptions derived from BaseException are formatted right + e = KeyboardInterrupt() + lst = traceback.format_exception_only(e.__class__, e) + self.assertEqual(lst, ['KeyboardInterrupt\n']) + def test_main(): run_unittest(TracebackCases) Modified: python/trunk/Lib/traceback.py ============================================================================== --- python/trunk/Lib/traceback.py (original) +++ python/trunk/Lib/traceback.py Tue May 2 19:36:09 2006 @@ -158,7 +158,7 @@ """ list = [] if (type(etype) == types.ClassType - or (isinstance(etype, type) and issubclass(etype, Exception))): + or (isinstance(etype, type) and issubclass(etype, BaseException))): stype = etype.__name__ else: stype = etype From python-checkins at python.org Tue May 2 20:01:36 2006 From: python-checkins at python.org (david.goodger) Date: Tue, 2 May 2006 20:01:36 +0200 (CEST) Subject: [Python-checkins] r45859 - peps/trunk/pep-0343.txt Message-ID: <20060502180136.58D491E4013@bag.python.org> Author: david.goodger Date: Tue May 2 20:01:35 2006 New Revision: 45859 Modified: peps/trunk/pep-0343.txt Log: changed encoding to UTF-8; added emacs stanza Modified: peps/trunk/pep-0343.txt ============================================================================== --- peps/trunk/pep-0343.txt (original) +++ peps/trunk/pep-0343.txt Tue May 2 20:01:35 2006 @@ -918,7 +918,7 @@ Additional thanks goes to (in no meaningful order): Paul Moore, Phillip J. Eby, Greg Ewing, Jason Orendorff, Michael Hudson, - Raymond Hettinger, Walter Dörwald, Aahz, Georg Brandl, Terry Reedy, + Raymond Hettinger, Walter Dörwald, Aahz, Georg Brandl, Terry Reedy, A.M. Kuchling, Brett Cannon, and all those that participated in the discussions on python-dev. @@ -976,3 +976,13 @@ Copyright This document has been placed in the public domain. + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: From python-checkins at python.org Tue May 2 20:32:40 2006 From: python-checkins at python.org (david.goodger) Date: Tue, 2 May 2006 20:32:40 +0200 (CEST) Subject: [Python-checkins] r45860 - peps/trunk/pep-3100.txt Message-ID: <20060502183240.5145A1E4012@bag.python.org> Author: david.goodger Date: Tue May 2 20:32:39 2006 New Revision: 45860 Modified: peps/trunk/pep-3100.txt Log: markup fix Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Tue May 2 20:32:39 2006 @@ -314,7 +314,7 @@ .. [26] python-3000 email ("More wishful thinking") http://mail.python.org/pipermail/python-3000/2006-April/000810.html - [27] python-3000 email ("sets in P3K?") +.. [27] python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-April/001286.html .. [#pep238] PEP 238 (Changing the Division Operator) @@ -329,8 +329,8 @@ .. [#pep352] PEP 352 (Required Superclass for Exceptions) http://www.python.org/dev/peps/pep-0352 -.. [#pep3001] PEP 3001 (Process for reviewing and improving standard library modules) - http://www.python.org/dev/peps/pep-3001 +.. [#pep3001] PEP 3001 (Process for reviewing and improving standard + library modules) http://www.python.org/dev/peps/pep-3001 .. [#pep3099] PEP 3099 (Things that will Not Change in Python 3000) http://www.python.org/dev/peps/pep-3099 From python-checkins at python.org Tue May 2 20:34:23 2006 From: python-checkins at python.org (david.goodger) Date: Tue, 2 May 2006 20:34:23 +0200 (CEST) Subject: [Python-checkins] r45861 - peps/trunk/pep2pyramid.py Message-ID: <20060502183423.279471E4012@bag.python.org> Author: david.goodger Date: Tue May 2 20:34:22 2006 New Revision: 45861 Modified: peps/trunk/pep2pyramid.py Log: create destdir & ancestors Modified: peps/trunk/pep2pyramid.py ============================================================================== --- peps/trunk/pep2pyramid.py (original) +++ peps/trunk/pep2pyramid.py Tue May 2 20:34:22 2006 @@ -409,7 +409,7 @@ needSvn = 0 if not os.path.exists(destDir): needSvn = 1 - os.mkdir(destDir) + os.makedirs(destDir) # write content.html foofilename = os.path.join(destDir, 'content.html') From python-checkins at python.org Tue May 2 21:47:56 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 2 May 2006 21:47:56 +0200 (CEST) Subject: [Python-checkins] r45862 - in python/trunk: Doc/lib/libcontextlib.tex Doc/ref/ref3.tex Doc/ref/ref7.tex Lib/calendar.py Lib/compiler/pycodegen.py Lib/contextlib.py Lib/decimal.py Lib/dummy_thread.py Lib/test/test_contextlib.py Lib/test/test_with.py Lib/threading.py Misc/Vim/syntax_test.py Modules/threadmodule.c Objects/fileobject.c Python/compile.c Message-ID: <20060502194756.4450C1E4025@bag.python.org> Author: guido.van.rossum Date: Tue May 2 21:47:52 2006 New Revision: 45862 Modified: python/trunk/Doc/lib/libcontextlib.tex python/trunk/Doc/ref/ref3.tex python/trunk/Doc/ref/ref7.tex python/trunk/Lib/calendar.py python/trunk/Lib/compiler/pycodegen.py python/trunk/Lib/contextlib.py python/trunk/Lib/decimal.py python/trunk/Lib/dummy_thread.py python/trunk/Lib/test/test_contextlib.py python/trunk/Lib/test/test_with.py python/trunk/Lib/threading.py python/trunk/Misc/Vim/syntax_test.py python/trunk/Modules/threadmodule.c python/trunk/Objects/fileobject.c python/trunk/Python/compile.c Log: Get rid of __context__, per the latest changes to PEP 343 and python-dev discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself. Modified: python/trunk/Doc/lib/libcontextlib.tex ============================================================================== --- python/trunk/Doc/lib/libcontextlib.tex (original) +++ python/trunk/Doc/lib/libcontextlib.tex Tue May 2 21:47:52 2006 @@ -54,34 +54,6 @@ reraise that exception. Otherwise the \keyword{with} statement will treat the exception as having been handled, and resume execution with the statement immediately following the \keyword{with} statement. - -Note that you can use \code{@contextfactory} to define a context -manager's \method{__context__} method. This is usually more -convenient than creating another class just to serve as a context -object. For example: - -\begin{verbatim} -from __future__ import with_statement -from contextlib import contextfactory - -class Tag: - def __init__(self, name): - self.name = name - - @contextfactory - def __context__(self): - print "<%s>" % self.name - yield self - print "" % self.name - -h1 = Tag("h1") - ->>> with h1 as me: -... print "hello from", me -

-hello from <__main__.Tag instance at 0x402ce8ec> -

-\end{verbatim} \end{funcdesc} \begin{funcdesc}{nested}{ctx1\optional{, ctx2\optional{, ...}}} @@ -147,25 +119,6 @@ without needing to explicitly close \code{page}. Even if an error occurs, \code{page.close()} will be called when the \keyword{with} block is exited. - -Context managers with a close method can use this context factory -to easily implement their own \method{__context__()} method. -\begin{verbatim} -from __future__ import with_statement -from contextlib import closing - -class MyClass: - def close(self): - print "Closing", self - def __context__(self): - return closing(self) - ->>> with MyClass() as x: -... print "Hello from", x -... -Hello from <__main__.MyClass instance at 0xb7df02ec> -Closing <__main__.MyClass instance at 0xb7df02ec> -\end{verbatim} \end{funcdesc} \begin{seealso} Modified: python/trunk/Doc/ref/ref3.tex ============================================================================== --- python/trunk/Doc/ref/ref3.tex (original) +++ python/trunk/Doc/ref/ref3.tex Tue May 2 21:47:52 2006 @@ -2138,22 +2138,6 @@ see ``\ulink{Context Types}{../lib/typecontext.html}'' in the \citetitle[../lib/lib.html]{Python Library Reference}. -\begin{methoddesc}[context manager]{__context__}{self} -Invoked when the object is used as the context expression of a -\keyword{with} statement. The returned object must implement -\method{__enter__()} and \method{__exit__()} methods. - -Context managers written in Python can also implement this method -using a generator function decorated with the -\function{contextlib.contextfactory} decorator, as this can be simpler -than writing individual \method{__enter__()} and \method{__exit__()} -methods on a separate object when the state to be managed is complex. - -\keyword{with} statement context objects also need to implement this -method; they are required to return themselves (that is, this method -will simply return \var{self}). -\end{methoddesc} - \begin{methoddesc}[with statement context]{__enter__}{self} Enter the runtime context related to this object. The \keyword{with} statement will bind this method's return value to the target(s) Modified: python/trunk/Doc/ref/ref7.tex ============================================================================== --- python/trunk/Doc/ref/ref7.tex (original) +++ python/trunk/Doc/ref/ref7.tex Tue May 2 21:47:52 2006 @@ -322,21 +322,18 @@ \begin{productionlist} \production{with_stmt} - {"with" \token{expression} ["as" target_list] ":" \token{suite}} + {"with" \token{expression} ["as" target] ":" \token{suite}} \end{productionlist} The execution of the \keyword{with} statement proceeds as follows: \begin{enumerate} -\item The context expression is evaluated, to obtain a context manager. +\item The context expression is evaluated to obtain a context manager. -\item The context manger's \method{__context__()} method is -invoked to obtain a \keyword{with} statement context object. +\item The context manager's \method{__enter__()} method is invoked. -\item The context object's \method{__enter__()} method is invoked. - -\item If a target list was included in the \keyword{with} +\item If a target was included in the \keyword{with} statement, the return value from \method{__enter__()} is assigned to it. \note{The \keyword{with} statement guarantees that if the @@ -347,7 +344,7 @@ \item The suite is executed. -\item The context object's \method{__exit__()} method is invoked. If +\item The context manager's \method{__exit__()} method is invoked. If an exception caused the suite to be exited, its type, value, and traceback are passed as arguments to \method{__exit__()}. Otherwise, three \constant{None} arguments are supplied. Modified: python/trunk/Lib/calendar.py ============================================================================== --- python/trunk/Lib/calendar.py (original) +++ python/trunk/Lib/calendar.py Tue May 2 21:47:52 2006 @@ -484,9 +484,6 @@ def __init__(self, locale): self.locale = locale - def __context__(self): - return self - def __enter__(self): self.oldlocale = locale.setlocale(locale.LC_TIME, self.locale) return locale.getlocale(locale.LC_TIME)[1] Modified: python/trunk/Lib/compiler/pycodegen.py ============================================================================== --- python/trunk/Lib/compiler/pycodegen.py (original) +++ python/trunk/Lib/compiler/pycodegen.py Tue May 2 21:47:52 2006 @@ -833,8 +833,6 @@ self.__with_count += 1 self.set_lineno(node) self.visit(node.expr) - self.emit('LOAD_ATTR', '__context__') - self.emit('CALL_FUNCTION', 0) self.emit('DUP_TOP') self.emit('LOAD_ATTR', '__exit__') self._implicitNameOp('STORE', exitvar) Modified: python/trunk/Lib/contextlib.py ============================================================================== --- python/trunk/Lib/contextlib.py (original) +++ python/trunk/Lib/contextlib.py Tue May 2 21:47:52 2006 @@ -10,9 +10,6 @@ def __init__(self, gen): self.gen = gen - def __context__(self): - return self - def __enter__(self): try: return self.gen.next() @@ -88,7 +85,7 @@ @contextfactory -def nested(*contexts): +def nested(*managers): """Support multiple context managers in a single with-statement. Code like this: @@ -109,8 +106,7 @@ exc = (None, None, None) try: try: - for context in contexts: - mgr = context.__context__() + for mgr in managers: exit = mgr.__exit__ enter = mgr.__enter__ vars.append(enter()) @@ -152,8 +148,6 @@ """ def __init__(self, thing): self.thing = thing - def __context__(self): - return self def __enter__(self): return self.thing def __exit__(self, *exc_info): Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Tue May 2 21:47:52 2006 @@ -2248,7 +2248,7 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def __context__(self): + def context_manager(self): return WithStatementContext(self.copy()) def clear_flags(self): Modified: python/trunk/Lib/dummy_thread.py ============================================================================== --- python/trunk/Lib/dummy_thread.py (original) +++ python/trunk/Lib/dummy_thread.py Tue May 2 21:47:52 2006 @@ -118,9 +118,6 @@ def __exit__(self, typ, val, tb): self.release() - def __context__(self): - return self - def release(self): """Release the dummy lock.""" # XXX Perhaps shouldn't actually bother to test? Could lead Modified: python/trunk/Lib/test/test_contextlib.py ============================================================================== --- python/trunk/Lib/test/test_contextlib.py (original) +++ python/trunk/Lib/test/test_contextlib.py Tue May 2 21:47:52 2006 @@ -51,7 +51,7 @@ @contextfactory def whee(): yield - ctx = whee().__context__() + ctx = whee() ctx.__enter__() # Calling __exit__ should not result in an exception self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None)) @@ -63,7 +63,7 @@ yield except: yield - ctx = whoo().__context__() + ctx = whoo() ctx.__enter__() self.assertRaises( RuntimeError, ctx.__exit__, TypeError, TypeError("foo"), None @@ -152,8 +152,6 @@ def a(): yield 1 class b(object): - def __context__(self): - return self def __enter__(self): return 2 def __exit__(self, *exc_info): @@ -341,12 +339,12 @@ orig_context = ctx.copy() try: ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext: + with decimal.ExtendedContext.context_manager(): self.assertEqual(decimal.getcontext().prec, decimal.ExtendedContext.prec) self.assertEqual(decimal.getcontext().prec, save_prec) try: - with decimal.ExtendedContext: + with decimal.ExtendedContext.context_manager(): self.assertEqual(decimal.getcontext().prec, decimal.ExtendedContext.prec) 1/0 Modified: python/trunk/Lib/test/test_with.py ============================================================================== --- python/trunk/Lib/test/test_with.py (original) +++ python/trunk/Lib/test/test_with.py Tue May 2 21:47:52 2006 @@ -17,15 +17,10 @@ class MockContextManager(GeneratorContext): def __init__(self, gen): GeneratorContext.__init__(self, gen) - self.context_called = False self.enter_called = False self.exit_called = False self.exit_args = None - def __context__(self): - self.context_called = True - return GeneratorContext.__context__(self) - def __enter__(self): self.enter_called = True return GeneratorContext.__enter__(self) @@ -60,21 +55,17 @@ class Nested(object): - def __init__(self, *contexts): - self.contexts = contexts + def __init__(self, *managers): + self.managers = managers self.entered = None - def __context__(self): - return self - def __enter__(self): if self.entered is not None: raise RuntimeError("Context is not reentrant") self.entered = deque() vars = [] try: - for context in self.contexts: - mgr = context.__context__() + for mgr in self.managers: vars.append(mgr.__enter__()) self.entered.appendleft(mgr) except: @@ -99,17 +90,12 @@ class MockNested(Nested): - def __init__(self, *contexts): - Nested.__init__(self, *contexts) - self.context_called = False + def __init__(self, *managers): + Nested.__init__(self, *managers) self.enter_called = False self.exit_called = False self.exit_args = None - def __context__(self): - self.context_called = True - return Nested.__context__(self) - def __enter__(self): self.enter_called = True return Nested.__enter__(self) @@ -126,24 +112,8 @@ with foo: pass self.assertRaises(NameError, fooNotDeclared) - def testContextAttributeError(self): - class LacksContext(object): - def __enter__(self): - pass - - def __exit__(self, type, value, traceback): - pass - - def fooLacksContext(): - foo = LacksContext() - with foo: pass - self.assertRaises(AttributeError, fooLacksContext) - def testEnterAttributeError(self): class LacksEnter(object): - def __context__(self): - pass - def __exit__(self, type, value, traceback): pass @@ -154,9 +124,6 @@ def testExitAttributeError(self): class LacksExit(object): - def __context__(self): - pass - def __enter__(self): pass @@ -192,27 +159,10 @@ 'with mock as (foo, None, bar):\n' ' pass') - def testContextThrows(self): - class ContextThrows(object): - def __context__(self): - raise RuntimeError("Context threw") - - def shouldThrow(): - ct = ContextThrows() - self.foo = None - with ct as self.foo: - pass - self.assertRaises(RuntimeError, shouldThrow) - self.assertEqual(self.foo, None) - def testEnterThrows(self): class EnterThrows(object): - def __context__(self): - return self - def __enter__(self): - raise RuntimeError("Context threw") - + raise RuntimeError("Enter threw") def __exit__(self, *args): pass @@ -226,8 +176,6 @@ def testExitThrows(self): class ExitThrows(object): - def __context__(self): - return self def __enter__(self): return def __exit__(self, *args): @@ -241,13 +189,11 @@ TEST_EXCEPTION = RuntimeError("test exception") def assertInWithManagerInvariants(self, mock_manager): - self.assertTrue(mock_manager.context_called) self.assertTrue(mock_manager.enter_called) self.assertFalse(mock_manager.exit_called) self.assertEqual(mock_manager.exit_args, None) def assertAfterWithManagerInvariants(self, mock_manager, exit_args): - self.assertTrue(mock_manager.context_called) self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) self.assertEqual(mock_manager.exit_args, exit_args) @@ -268,7 +214,6 @@ raise self.TEST_EXCEPTION def assertAfterWithManagerInvariantsWithError(self, mock_manager): - self.assertTrue(mock_manager.context_called) self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) self.assertEqual(mock_manager.exit_args[0], RuntimeError) @@ -472,7 +417,6 @@ # The inner statement stuff should never have been touched self.assertEqual(self.bar, None) - self.assertFalse(mock_b.context_called) self.assertFalse(mock_b.enter_called) self.assertFalse(mock_b.exit_called) self.assertEqual(mock_b.exit_args, None) @@ -506,13 +450,9 @@ self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration2(self): - class cm (object): - def __context__(self): - return self - + class cm(object): def __enter__(self): pass - def __exit__(self, type, value, traceback): pass @@ -535,12 +475,8 @@ def testRaisedGeneratorExit2(self): class cm (object): - def __context__(self): - return self - def __enter__(self): pass - def __exit__(self, type, value, traceback): pass @@ -629,7 +565,6 @@ def testMultipleComplexTargets(self): class C: - def __context__(self): return self def __enter__(self): return 1, 2, 3 def __exit__(self, t, v, tb): pass targets = {1: [0, 1, 2]} @@ -651,7 +586,6 @@ def testExitTrueSwallowsException(self): class AfricanSwallow: - def __context__(self): return self def __enter__(self): pass def __exit__(self, t, v, tb): return True try: @@ -662,7 +596,6 @@ def testExitFalseDoesntSwallowException(self): class EuropeanSwallow: - def __context__(self): return self def __enter__(self): pass def __exit__(self, t, v, tb): return False try: Modified: python/trunk/Lib/threading.py ============================================================================== --- python/trunk/Lib/threading.py (original) +++ python/trunk/Lib/threading.py Tue May 2 21:47:52 2006 @@ -90,9 +90,6 @@ self.__owner and self.__owner.getName(), self.__count) - def __context__(self): - return self - def acquire(self, blocking=1): me = currentThread() if self.__owner is me: @@ -182,8 +179,11 @@ pass self.__waiters = [] - def __context__(self): - return self.__lock.__context__() + def __enter__(self): + return self.__lock.__enter__() + + def __exit__(self, *args): + return self.__lock.__exit__(*args) def __repr__(self): return "" % (self.__lock, len(self.__waiters)) @@ -278,9 +278,6 @@ self.__cond = Condition(Lock()) self.__value = value - def __context__(self): - return self - def acquire(self, blocking=1): rc = False self.__cond.acquire() Modified: python/trunk/Misc/Vim/syntax_test.py ============================================================================== --- python/trunk/Misc/Vim/syntax_test.py (original) +++ python/trunk/Misc/Vim/syntax_test.py Tue May 2 21:47:52 2006 @@ -19,8 +19,6 @@ def foo(): # function definition return [] class Bar(object): # Class definition - def __context__(self): - return self def __enter__(self): pass def __exit__(self, *args): Modified: python/trunk/Modules/threadmodule.c ============================================================================== --- python/trunk/Modules/threadmodule.c (original) +++ python/trunk/Modules/threadmodule.c Tue May 2 21:47:52 2006 @@ -98,13 +98,6 @@ \n\ Return whether the lock is in the locked state."); -static PyObject * -lock_context(lockobject *self) -{ - Py_INCREF(self); - return (PyObject *)self; -} - static PyMethodDef lock_methods[] = { {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, METH_VARARGS, acquire_doc}, @@ -118,8 +111,6 @@ METH_NOARGS, locked_doc}, {"locked", (PyCFunction)lock_locked_lock, METH_NOARGS, locked_doc}, - {"__context__", (PyCFunction)lock_context, - METH_NOARGS, PyDoc_STR("__context__() -> self.")}, {"__enter__", (PyCFunction)lock_PyThread_acquire_lock, METH_VARARGS, acquire_doc}, {"__exit__", (PyCFunction)lock_PyThread_release_lock, Modified: python/trunk/Objects/fileobject.c ============================================================================== --- python/trunk/Objects/fileobject.c (original) +++ python/trunk/Objects/fileobject.c Tue May 2 21:47:52 2006 @@ -1706,9 +1706,6 @@ PyDoc_STRVAR(isatty_doc, "isatty() -> true or false. True if the file is connected to a tty device."); -PyDoc_STRVAR(context_doc, - "__context__() -> self."); - PyDoc_STRVAR(enter_doc, "__enter__() -> self."); @@ -1729,7 +1726,6 @@ {"flush", (PyCFunction)file_flush, METH_NOARGS, flush_doc}, {"close", (PyCFunction)file_close, METH_NOARGS, close_doc}, {"isatty", (PyCFunction)file_isatty, METH_NOARGS, isatty_doc}, - {"__context__", (PyCFunction)file_self, METH_NOARGS, context_doc}, {"__enter__", (PyCFunction)file_self, METH_NOARGS, enter_doc}, {"__exit__", (PyCFunction)file_close, METH_VARARGS, close_doc}, {NULL, NULL} /* sentinel */ @@ -2445,4 +2441,3 @@ #ifdef __cplusplus } #endif - Modified: python/trunk/Python/compile.c ============================================================================== --- python/trunk/Python/compile.c (original) +++ python/trunk/Python/compile.c Tue May 2 21:47:52 2006 @@ -3371,7 +3371,7 @@ It is implemented roughly as: - context = (EXPR).__context__() + context = EXPR exit = context.__exit__ # not calling it value = context.__enter__() try: @@ -3387,17 +3387,12 @@ static int compiler_with(struct compiler *c, stmt_ty s) { - static identifier context_attr, enter_attr, exit_attr; + static identifier enter_attr, exit_attr; basicblock *block, *finally; identifier tmpexit, tmpvalue = NULL; assert(s->kind == With_kind); - if (!context_attr) { - context_attr = PyString_InternFromString("__context__"); - if (!context_attr) - return 0; - } if (!enter_attr) { enter_attr = PyString_InternFromString("__enter__"); if (!enter_attr) @@ -3436,10 +3431,8 @@ PyArena_AddPyObject(c->c_arena, tmpvalue); } - /* Evaluate (EXPR).__context__() */ + /* Evaluate EXPR */ VISIT(c, expr, s->v.With.context_expr); - ADDOP_O(c, LOAD_ATTR, context_attr, names); - ADDOP_I(c, CALL_FUNCTION, 0); /* Squirrel away context.__exit__ */ ADDOP(c, DUP_TOP); From python-checkins at python.org Tue May 2 21:52:33 2006 From: python-checkins at python.org (armin.rigo) Date: Tue, 2 May 2006 21:52:33 +0200 (CEST) Subject: [Python-checkins] r45863 - python/trunk/Doc/api/refcounts.dat Message-ID: <20060502195233.25D2C1E4012@bag.python.org> Author: armin.rigo Date: Tue May 2 21:52:32 2006 New Revision: 45863 Modified: python/trunk/Doc/api/refcounts.dat Log: Documentation bug: PySet_Pop() returns a new reference (because the caller becomes the owner of that reference). Modified: python/trunk/Doc/api/refcounts.dat ============================================================================== --- python/trunk/Doc/api/refcounts.dat (original) +++ python/trunk/Doc/api/refcounts.dat Tue May 2 21:52:32 2006 @@ -1147,7 +1147,7 @@ PySet_New:PyObject*::+1: PySet_New:PyObject*:iterable:0: -PySet_Pop:PyObject*::0:or returns NULL and raises KeyError if set is empty +PySet_Pop:PyObject*::+1:or returns NULL and raises KeyError if set is empty PySet_Pop:PyObject*:set:0: PySet_Size:int::: From python-checkins at python.org Tue May 2 22:47:36 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 2 May 2006 22:47:36 +0200 (CEST) Subject: [Python-checkins] r45864 - python/trunk/Lib/test/test_mailbox.py Message-ID: <20060502204736.DAE871E4013@bag.python.org> Author: guido.van.rossum Date: Tue May 2 22:47:36 2006 New Revision: 45864 Modified: python/trunk/Lib/test/test_mailbox.py Log: Hopefully this will fix the spurious failures of test_mailbox.py that I'm experiencing. (This code and mailbox.py itself are full of calls to file() that should be calls to open() -- but I'm not fixing those.) Modified: python/trunk/Lib/test/test_mailbox.py ============================================================================== --- python/trunk/Lib/test/test_mailbox.py (original) +++ python/trunk/Lib/test/test_mailbox.py Tue May 2 22:47:36 2006 @@ -577,14 +577,18 @@ # Remove old files from 'tmp' foo_path = os.path.join(self._path, 'tmp', 'foo') bar_path = os.path.join(self._path, 'tmp', 'bar') - file(foo_path, 'w').close() - file(bar_path, 'w').close() + f = open(foo_path, 'w') + f.write("@") + f.close() + f = open(bar_path, 'w') + f.write("@") + f.close() self._box.clean() self.assert_(os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) foo_stat = os.stat(foo_path) - os.utime(os.path.join(foo_path), (time.time() - 129600 - 2, - foo_stat.st_mtime)) + os.utime(foo_path, (time.time() - 129600 - 2, + foo_stat.st_mtime)) self._box.clean() self.assert_(not os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) From martin at v.loewis.de Tue May 2 23:28:25 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 02 May 2006 23:28:25 +0200 Subject: [Python-checkins] r45839 - python/trunk/Doc/lib/lib.tex python/trunk/Doc/lib/libmsilib.tex In-Reply-To: References: <20060501161245.7AF361E4011@bag.python.org> Message-ID: <4457CEF9.4000307@v.loewis.de> Jim Jewett wrote: > Is there an URL describing these formats? Not to my knowledge: they are both undocumented (MSI probably more so than CAB, for which third-party tools exist). >> +\begin{funcdesc}{FCICreate}{cabname, files} >> + Create a new CAB file named \var{cabname}. \var{files} must >> + be a list of tuples, each containing the name of the file on >> + disk, and the name of the file inside the CAB file. >> + >> + The files are added to the CAB file in the order they have >> + in the list. All files are added into a single CAB file, >> + using the MSZIP compression algorithm. > > Should that be "in the order that they appear in the list"/ If that is better English: sure. > Is there a good URL for the MSZIP format? > > google pointed at non-MS sources, though one suggested > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp That's only the SDK, though, and it only has API specs; these are the ones that _msi.c uses. In any case, I want to replace MSZIP with LZX:21 before the release (not that this is better documented). >> +\begin{funcdesc}{OpenDatabase}{path, persist} >> + Return a new database object by calling MsiOpenDatabase. >> + \var{path} is the file name of the >> + MSI file; persist can be one of the constants >> + \code{MSIDBOPEN_CREATEDIRECT}, \code{MSIDBOPEN_CREATE}, >> + \code{MSIDBOPEN_DIRECT}, \code{MSIDBOPEN_READONLY}, or >> + \code{MSIDBOPEN_TRANSACT}, and may include the flag >> + \code{MSIDBOPEN_PATCHFILE}. See the Microsoft documentation for >> + the meaning of these flags; depending on the flags, >> + an existing database is opened, or a new one created. >> +\end{funcdesc} > > Any particular place in the documentation? Preferably an URL That's in the see-also section already, for MsiOpenDatabase. >> + This is typically used to install the sequence >> +\end{funcdesc} > > Is that last sentence complete? Ah, no. It should end with "tables." Thanks, Martin From python-checkins at python.org Tue May 2 23:44:34 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 2 May 2006 23:44:34 +0200 (CEST) Subject: [Python-checkins] r45865 - in python/trunk/Lib: mailbox.py test/test_mailbox.py Message-ID: <20060502214434.0ED891E4005@bag.python.org> Author: andrew.kuchling Date: Tue May 2 23:44:33 2006 New Revision: 45865 Modified: python/trunk/Lib/mailbox.py python/trunk/Lib/test/test_mailbox.py Log: Use open() instead of file() Modified: python/trunk/Lib/mailbox.py ============================================================================== --- python/trunk/Lib/mailbox.py (original) +++ python/trunk/Lib/mailbox.py Tue May 2 23:44:33 2006 @@ -294,7 +294,7 @@ def get_message(self, key): """Return a Message representation or raise a KeyError.""" subpath = self._lookup(key) - f = file(os.path.join(self._path, subpath), 'r') + f = open(os.path.join(self._path, subpath), 'r') try: msg = MaildirMessage(f) finally: @@ -308,7 +308,7 @@ def get_string(self, key): """Return a string representation or raise a KeyError.""" - f = file(os.path.join(self._path, self._lookup(key)), 'r') + f = open(os.path.join(self._path, self._lookup(key)), 'r') try: return f.read() finally: @@ -316,7 +316,7 @@ def get_file(self, key): """Return a file-like representation or raise a KeyError.""" - f = file(os.path.join(self._path, self._lookup(key)), 'rb') + f = open(os.path.join(self._path, self._lookup(key)), 'rb') return _ProxyFile(f) def iterkeys(self): @@ -422,7 +422,7 @@ except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 - return file(path, 'wb+') + return open(path, 'wb+') else: raise else: @@ -471,15 +471,15 @@ """Initialize a single-file mailbox.""" Mailbox.__init__(self, path, factory, create) try: - f = file(self._path, 'rb+') + f = open(self._path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: if create: - f = file(self._path, 'wb+') + f = open(self._path, 'wb+') else: raise NoSuchMailboxError(self._path) elif e.errno == errno.EACCES: - f = file(self._path, 'rb') + f = open(self._path, 'rb') else: raise self._file = f @@ -572,7 +572,7 @@ os.rename(new_file.name, self._path) else: raise - self._file = file(self._path, 'rb+') + self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: @@ -792,7 +792,7 @@ """Remove the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: - f = file(path, 'rb+') + f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) @@ -814,7 +814,7 @@ """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: - f = file(path, 'rb+') + f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) @@ -838,9 +838,9 @@ """Return a Message representation or raise a KeyError.""" try: if self._locked: - f = file(os.path.join(self._path, str(key)), 'r+') + f = open(os.path.join(self._path, str(key)), 'r+') else: - f = file(os.path.join(self._path, str(key)), 'r') + f = open(os.path.join(self._path, str(key)), 'r') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) @@ -865,9 +865,9 @@ """Return a string representation or raise a KeyError.""" try: if self._locked: - f = file(os.path.join(self._path, str(key)), 'r+') + f = open(os.path.join(self._path, str(key)), 'r+') else: - f = file(os.path.join(self._path, str(key)), 'r') + f = open(os.path.join(self._path, str(key)), 'r') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) @@ -887,7 +887,7 @@ def get_file(self, key): """Return a file-like representation or raise a KeyError.""" try: - f = file(os.path.join(self._path, str(key)), 'rb') + f = open(os.path.join(self._path, str(key)), 'rb') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) @@ -911,7 +911,7 @@ def lock(self): """Lock the mailbox.""" if not self._locked: - self._file = file(os.path.join(self._path, '.mh_sequences'), 'rb+') + self._file = open(os.path.join(self._path, '.mh_sequences'), 'rb+') _lock_file(self._file) self._locked = True @@ -963,7 +963,7 @@ def get_sequences(self): """Return a name-to-key-list dictionary to define each sequence.""" results = {} - f = file(os.path.join(self._path, '.mh_sequences'), 'r') + f = open(os.path.join(self._path, '.mh_sequences'), 'r') try: all_keys = set(self.keys()) for line in f: @@ -989,7 +989,7 @@ def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary.""" - f = file(os.path.join(self._path, '.mh_sequences'), 'r+') + f = open(os.path.join(self._path, '.mh_sequences'), 'r+') try: os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) for name, keys in sequences.iteritems(): @@ -1024,7 +1024,7 @@ for key in self.iterkeys(): if key - 1 != prev: changes.append((key, prev + 1)) - f = file(os.path.join(self._path, str(key)), 'r+') + f = open(os.path.join(self._path, str(key)), 'r+') try: if self._locked: _lock_file(f) @@ -1864,7 +1864,7 @@ """Create a file if it doesn't exist and open for reading and writing.""" fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR) try: - return file(path, 'rb+') + return open(path, 'rb+') finally: os.close(fd) Modified: python/trunk/Lib/test/test_mailbox.py ============================================================================== --- python/trunk/Lib/test/test_mailbox.py (original) +++ python/trunk/Lib/test/test_mailbox.py Tue May 2 23:44:33 2006 @@ -717,7 +717,7 @@ self._box._file.seek(0) contents = self._box._file.read() self._box.close() - self.assert_(contents == file(self._path, 'rb').read()) + self.assert_(contents == open(self._path, 'rb').read()) self._box = self._factory(self._path) @@ -1473,7 +1473,7 @@ def setUp(self): self._path = test_support.TESTFN - self._file = file(self._path, 'wb+') + self._file = open(self._path, 'wb+') def tearDown(self): self._file.close() @@ -1522,7 +1522,7 @@ def setUp(self): self._path = test_support.TESTFN - self._file = file(self._path, 'wb+') + self._file = open(self._path, 'wb+') def tearDown(self): self._file.close() From python-checkins at python.org Wed May 3 00:47:50 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 3 May 2006 00:47:50 +0200 (CEST) Subject: [Python-checkins] r45866 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060502224750.6819B1E401F@bag.python.org> Author: andrew.kuchling Date: Wed May 3 00:47:49 2006 New Revision: 45866 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Update context manager section for removal of __context__ Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Wed May 3 00:47:49 2006 @@ -638,7 +638,8 @@ the block is complete. The \module{decimal} module's contexts, which encapsulate the desired -precision and rounding characteristics for computations, also work. +precision and rounding characteristics for computations, provide a +\method{context_manager()} method for getting a context manager: \begin{verbatim} import decimal @@ -647,7 +648,8 @@ v1 = decimal.Decimal('578') print v1.sqrt() -with decimal.Context(prec=16): +ctx = decimal.Context(prec=16) +with ctx.context_manager(): # All code in this block uses a precision of 16 digits. # The original context is restored on exiting the block. print v1.sqrt() @@ -665,14 +667,12 @@ A high-level explanation of the context management protocol is: \begin{itemize} -\item The expression is evaluated and should result in an object -with a \method{__context__()} method (called a ``context manager''). -\item The context specifier's \method{__context__()} method is called, -and must return another object (called a ``with-statement context object'') that has +\item The expression is evaluated and should result in an object +called a ``context manager''. The context manager must have \method{__enter__()} and \method{__exit__()} methods. -\item The context object's \method{__enter__()} method is called. The value +\item The context manager's \method{__enter__()} method is called. The value returned is assigned to \var{VAR}. If no \code{'as \var{VAR}'} clause is present, the value is simply discarded. @@ -680,7 +680,7 @@ \item If \var{BLOCK} raises an exception, the \method{__exit__(\var{type}, \var{value}, \var{traceback})} is called -with the exception's information, the same values returned by +with the exception details, the same values returned by \function{sys.exc_info()}. The method's return value controls whether the exception is re-raised: any false value re-raises the exception, and \code{True} will result in suppressing it. You'll only rarely @@ -719,20 +719,11 @@ The transaction should be committed if the code in the block runs flawlessly or rolled back if there's an exception. - -First, the \class{DatabaseConnection} needs a \method{__context__()} -method. Sometimes an object can simply return \code{self}; the -\module{threading} module's lock objects do this, for example. For -our database example, though, we need to create a new object; I'll -call this class \class{DatabaseContext}. Our \method{__context__()} -method must therefore look like this: +Here's the basic interface +for \class{DatabaseConnection} that I'll assume: \begin{verbatim} class DatabaseConnection: - ... - def __context__ (self): - return DatabaseContext(self) - # Database interface def cursor (self): "Returns a cursor object and starts a new transaction" @@ -742,16 +733,6 @@ "Rolls back current transaction" \end{verbatim} -Instances of \class{DatabaseContext} need the connection object so that -the connection object's \method{commit()} or \method{rollback()} -methods can be called: - -\begin{verbatim} -class DatabaseContext: - def __init__ (self, connection): - self.connection = connection -\end{verbatim} - The \method {__enter__()} method is pretty easy, having only to start a new transaction. For this application the resulting cursor object would be a useful result, so the method will return it. The user can @@ -759,11 +740,11 @@ the cursor to a variable name. \begin{verbatim} -class DatabaseContext: +class DatabaseConnection: ... def __enter__ (self): # Code to start a new transaction - cursor = self.connection.cursor() + cursor = self.cursor() return cursor \end{verbatim} @@ -779,15 +760,15 @@ statement at the marked location. \begin{verbatim} -class DatabaseContext: +class DatabaseConnection: ... def __exit__ (self, type, value, tb): if tb is None: # No exception, so commit - self.connection.commit() + self.commit() else: # Exception occurred, so rollback. - self.connection.rollback() + self.rollback() # return False \end{verbatim} @@ -830,27 +811,8 @@ ... \end{verbatim} -You can also use this decorator to write the \method{__context__()} -method for a class: - -\begin{verbatim} -class DatabaseConnection: - - @contextfactory - def __context__ (self): - cursor = self.cursor() - try: - yield cursor - except: - self.rollback() - raise - else: - self.commit() -\end{verbatim} - - The \module{contextlib} module also has a \function{nested(\var{mgr1}, -\var{mgr2}, ...)} function that combines a number of contexts so you +\var{mgr2}, ...)} function that combines a number of context managers so you don't need to write nested '\keyword{with}' statements. In this example, the single '\keyword{with}' statement both starts a database transaction and acquires a thread lock: From buildbot at python.org Wed May 3 01:31:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 02 May 2006 23:31:45 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Debian unstable trunk Message-ID: <20060502233145.CEAF61E4005@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/340 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 3 03:46:52 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 03:46:52 +0200 (CEST) Subject: [Python-checkins] r45867 - python/trunk/Doc/perl/python.perl Message-ID: <20060503014652.DE6B01E4005@bag.python.org> Author: fred.drake Date: Wed May 3 03:46:52 2006 New Revision: 45867 Modified: python/trunk/Doc/perl/python.perl Log: remove unnecessary assignment Modified: python/trunk/Doc/perl/python.perl ============================================================================== --- python/trunk/Doc/perl/python.perl (original) +++ python/trunk/Doc/perl/python.perl Wed May 3 03:46:52 2006 @@ -530,7 +530,6 @@ sub new_link_name_info(){ my $name = "l2h-" . ++$globals{'max_id'}; - my $aname = ""; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $ahref); } From python-checkins at python.org Wed May 3 03:48:24 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 03:48:24 +0200 (CEST) Subject: [Python-checkins] r45868 - python/trunk/Doc/perl/l2hinit.perl Message-ID: <20060503014824.BBB601E4005@bag.python.org> Author: fred.drake Date: Wed May 3 03:48:24 2006 New Revision: 45868 Modified: python/trunk/Doc/perl/l2hinit.perl Log: tell LaTeX2HTML to: - use UTF-8 output - not mess with the >>> prompt! Modified: python/trunk/Doc/perl/l2hinit.perl ============================================================================== --- python/trunk/Doc/perl/l2hinit.perl (original) +++ python/trunk/Doc/perl/l2hinit.perl Wed May 3 03:48:24 2006 @@ -4,7 +4,14 @@ use L2hos; -$HTML_VERSION = 4.0; +$HTML_VERSION = 4.01; +$LOWER_CASE_TAGS = 1; +$NO_FRENCH_QUOTES = 1; + +# Force Unicode support to be loaded; request UTF-8 output. +do_require_extension('unicode'); +do_require_extension('utf8'); +$HTML_OPTIONS = 'utf8'; $MAX_LINK_DEPTH = 2; $ADDRESS = ''; @@ -106,6 +113,13 @@ $ENV{'TEXINPUTS'} = undef; } print "\nSetting \$TEXINPUTS to $TEXINPUTS\n"; + + # Not sure why we need to deal with this both here and at the top, + # but this is needed to actually make it work. + do_require_extension('utf8'); + $charset = $utf8_str; + $CHARSET = $utf8_str; + $USE_UTF = 1; } From buildbot at python.org Wed May 3 04:03:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 02:03:16 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060503020316.3A3EA1E4023@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/423 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fred.drake Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed May 3 04:04:48 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 04:04:48 +0200 (CEST) Subject: [Python-checkins] r45869 - in python/trunk/Doc: api/abstract.tex ext/windows.tex lib/libcodeop.tex lib/libdoctest.tex lib/libhtmlparser.tex lib/liboperator.tex lib/libsys.tex lib/libtrace.tex ref/ref3.tex ref/ref5.tex ref/ref6.tex tut/glossary.tex tut/tut.tex whatsnew/whatsnew20.tex Message-ID: <20060503020448.36B981E4012@bag.python.org> Author: fred.drake Date: Wed May 3 04:04:40 2006 New Revision: 45869 Modified: python/trunk/Doc/api/abstract.tex python/trunk/Doc/ext/windows.tex python/trunk/Doc/lib/libcodeop.tex python/trunk/Doc/lib/libdoctest.tex python/trunk/Doc/lib/libhtmlparser.tex python/trunk/Doc/lib/liboperator.tex python/trunk/Doc/lib/libsys.tex python/trunk/Doc/lib/libtrace.tex python/trunk/Doc/ref/ref3.tex python/trunk/Doc/ref/ref5.tex python/trunk/Doc/ref/ref6.tex python/trunk/Doc/tut/glossary.tex python/trunk/Doc/tut/tut.tex python/trunk/Doc/whatsnew/whatsnew20.tex Log: avoid ugly markup based on the unfortunate conversions of ">>" and "<<" to guillemets; no need for magic here Modified: python/trunk/Doc/api/abstract.tex ============================================================================== --- python/trunk/Doc/api/abstract.tex (original) +++ python/trunk/Doc/api/abstract.tex Wed May 3 04:04:40 2006 @@ -630,7 +630,7 @@ Returns the result of right shifting \var{o1} by \var{o2} on success, or \NULL{} on failure. The operation is done \emph{in-place} when \var{o1} supports it. This is the equivalent - of the Python statement \samp{\var{o1} >\code{>=} \var{o2}}. + of the Python statement \samp{\var{o1} >>= \var{o2}}. \end{cfuncdesc} Modified: python/trunk/Doc/ext/windows.tex ============================================================================== --- python/trunk/Doc/ext/windows.tex (original) +++ python/trunk/Doc/ext/windows.tex Wed May 3 04:04:40 2006 @@ -88,7 +88,7 @@ Once the Debug build has succeeded, bring up a DOS box, and change to the \file{example_nt\textbackslash Debug} directory. You should now be able to repeat the following session (\code{C>} is - the DOS prompt, \code{>\code{>}>} is the Python prompt; note that + the DOS prompt, \code{>>>} is the Python prompt; note that build information and various debug output from Python may not match this screen dump exactly): Modified: python/trunk/Doc/lib/libcodeop.tex ============================================================================== --- python/trunk/Doc/lib/libcodeop.tex (original) +++ python/trunk/Doc/lib/libcodeop.tex Wed May 3 04:04:40 2006 @@ -19,7 +19,7 @@ \begin{enumerate} \item Being able to tell if a line of input completes a Python statement: in short, telling whether to print - `\code{>\code{>}>~}' or `\code{...~}' next. + `\code{>>>~}' or `\code{...~}' next. \item Remembering which future statements the user has entered, so subsequent input can be compiled with these in effect. \end{enumerate} Modified: python/trunk/Doc/lib/libdoctest.tex ============================================================================== --- python/trunk/Doc/lib/libdoctest.tex (original) +++ python/trunk/Doc/lib/libdoctest.tex Wed May 3 04:04:40 2006 @@ -333,8 +333,8 @@ \end{verbatim} Any expected output must immediately follow the final -\code{'>\code{>}>~'} or \code{'...~'} line containing the code, and -the expected output (if any) extends to the next \code{'>\code{>}>~'} +\code{'>>>~'} or \code{'...~'} line containing the code, and +the expected output (if any) extends to the next \code{'>>>~'} or all-whitespace line. The fine print: @@ -386,7 +386,7 @@ \end{verbatim} and as many leading whitespace characters are stripped from the -expected output as appeared in the initial \code{'>\code{>}>~'} line +expected output as appeared in the initial \code{'>>>~'} line that started the example. \end{itemize} Modified: python/trunk/Doc/lib/libhtmlparser.tex ============================================================================== --- python/trunk/Doc/lib/libhtmlparser.tex (original) +++ python/trunk/Doc/lib/libhtmlparser.tex Wed May 3 04:04:40 2006 @@ -132,7 +132,7 @@ \begin{methoddesc}{handle_decl}{decl} Method called when an SGML declaration is read by the parser. The \var{decl} parameter will be the entire contents of the declaration -inside the \code{} markup.It is intended to be overridden +inside the \code{} markup. It is intended to be overridden by a derived class; the base class implementation does nothing. \end{methoddesc} Modified: python/trunk/Doc/lib/liboperator.tex ============================================================================== --- python/trunk/Doc/lib/liboperator.tex (original) +++ python/trunk/Doc/lib/liboperator.tex Wed May 3 04:04:40 2006 @@ -320,7 +320,7 @@ \begin{funcdesc}{irshift}{a, b} \funcline{__irshift__}{a, b} -\code{a = irshift(a, b)} is equivalent to \code{a >}\code{>= b}. +\code{a = irshift(a, b)} is equivalent to \code{a >>= b}. \versionadded{2.5} \end{funcdesc} @@ -499,7 +499,7 @@ {\code{neg(\var{a})}} \lineiii{Negation (Logical)}{\code{not \var{a}}} {\code{not_(\var{a})}} - \lineiii{Right Shift}{\code{\var{a} >\code{>} \var{b}}} + \lineiii{Right Shift}{\code{\var{a} >> \var{b}}} {\code{rshift(\var{a}, \var{b})}} \lineiii{Sequence Repitition}{\code{\var{seq} * \var{i}}} {\code{repeat(\var{seq}, \var{i})}} Modified: python/trunk/Doc/lib/libsys.tex ============================================================================== --- python/trunk/Doc/lib/libsys.tex (original) +++ python/trunk/Doc/lib/libsys.tex Wed May 3 04:04:40 2006 @@ -410,7 +410,7 @@ Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are - \code{'>\code{>}> '} and \code{'... '}. If a non-string object is + \code{'>>>~'} and \code{'... '}. If a non-string object is assigned to either variable, its \function{str()} is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt. Modified: python/trunk/Doc/lib/libtrace.tex ============================================================================== --- python/trunk/Doc/lib/libtrace.tex (original) +++ python/trunk/Doc/lib/libtrace.tex Wed May 3 04:04:40 2006 @@ -54,7 +54,7 @@ \item[\longprogramopt{missing}, \programopt{-m}] When generating annotated listings, mark lines which -were not executed with \code{>}\code{>}\code{>}\code{>}\code{>}\code{>}. +were not executed with `\code{>>>>>>}'. \item[\longprogramopt{summary}, \programopt{-s}] When using \longprogramopt{count} or \longprogramopt{report}, write a Modified: python/trunk/Doc/ref/ref3.tex ============================================================================== --- python/trunk/Doc/ref/ref3.tex (original) +++ python/trunk/Doc/ref/ref3.tex Wed May 3 04:04:40 2006 @@ -1875,8 +1875,8 @@ called to implement the binary arithmetic operations (\code{+}, \code{-}, \code{*}, \code{//}, \code{\%}, \function{divmod()}\bifuncindex{divmod}, -\function{pow()}\bifuncindex{pow}, \code{**}, \code{<}\code{<}, -\code{>}\code{>}, \code{\&}, \code{\^}, \code{|}). For instance, to +\function{pow()}\bifuncindex{pow}, \code{**}, \code{<<}, +\code{>>}, \code{\&}, \code{\^}, \code{|}). For instance, to evaluate the expression \var{x}\code{+}\var{y}, where \var{x} is an instance of a class that has an \method{__add__()} method, \code{\var{x}.__add__(\var{y})} is called. The \method{__divmod__()} @@ -1915,8 +1915,8 @@ called to implement the binary arithmetic operations (\code{+}, \code{-}, \code{*}, \code{/}, \code{\%}, \function{divmod()}\bifuncindex{divmod}, -\function{pow()}\bifuncindex{pow}, \code{**}, \code{<}\code{<}, -\code{>}\code{>}, \code{\&}, \code{\^}, \code{|}) with reflected +\function{pow()}\bifuncindex{pow}, \code{**}, \code{<<}, +\code{>>}, \code{\&}, \code{\^}, \code{|}) with reflected (swapped) operands. These functions are only called if the left operand does not support the corresponding operation. For instance, to evaluate the expression \var{x}\code{-}\var{y}, where \var{y} is an @@ -1942,7 +1942,7 @@ \methodline[numeric object]{__ior__}{self, other} These methods are called to implement the augmented arithmetic operations (\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=}, -\code{**=}, \code{<}\code{<=}, \code{>}\code{>=}, \code{\&=}, +\code{**=}, \code{<<=}, \code{>>=}, \code{\&=}, \code{\textasciicircum=}, \code{|=}). These methods should attempt to do the operation in-place (modifying \var{self}) and return the result (which could be, but does not have to be, \var{self}). If a specific method Modified: python/trunk/Doc/ref/ref5.tex ============================================================================== --- python/trunk/Doc/ref/ref5.tex (original) +++ python/trunk/Doc/ref/ref5.tex Wed May 3 04:04:40 2006 @@ -1158,7 +1158,7 @@ \hline \lineii{\code{\&}} {Bitwise AND} \hline - \lineii{\code{<}\code{<}, \code{>}\code{>}} {Shifts} + \lineii{\code{<<}, \code{>>}} {Shifts} \hline \lineii{\code{+}, \code{-}}{Addition and subtraction} \hline Modified: python/trunk/Doc/ref/ref6.tex ============================================================================== --- python/trunk/Doc/ref/ref6.tex (original) +++ python/trunk/Doc/ref/ref6.tex Wed May 3 04:04:40 2006 @@ -377,7 +377,7 @@ \begin{productionlist} \production{print_stmt} {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}}} - \productioncont{| ">\code{>}" \token{expression} + \productioncont{| ">>" \token{expression} \optional{("," \token{expression})+ \optional{","}} )} \end{productionlist} Modified: python/trunk/Doc/tut/glossary.tex ============================================================================== --- python/trunk/Doc/tut/glossary.tex (original) +++ python/trunk/Doc/tut/glossary.tex Wed May 3 04:04:40 2006 @@ -7,7 +7,7 @@ \index{>>>} -\item[\code{>\code{>}>}] +\item[\code{>>>}] The typical Python prompt of the interactive shell. Often seen for code examples that can be tried right away in the interpreter. Modified: python/trunk/Doc/tut/tut.tex ============================================================================== --- python/trunk/Doc/tut/tut.tex (original) +++ python/trunk/Doc/tut/tut.tex Wed May 3 04:04:40 2006 @@ -264,7 +264,7 @@ When commands are read from a tty, the interpreter is said to be in \emph{interactive mode}. In this mode it prompts for the next command with the \emph{primary prompt}, usually three greater-than signs -(\samp{>\code{>}>~}); for continuation lines it prompts with the +(\samp{>>>~}); for continuation lines it prompts with the \emph{secondary prompt}, by default three dots (\samp{...~}). The interpreter prints a welcome message stating its version number and a copyright notice before printing the first prompt: @@ -423,7 +423,7 @@ \chapter{An Informal Introduction to Python \label{informal}} In the following examples, input and output are distinguished by the -presence or absence of prompts (\samp{>\code{>}>~} and \samp{...~}): to repeat +presence or absence of prompts (\samp{>>>~} and \samp{...~}): to repeat the example, you must type everything after the prompt, when the prompt appears; lines that do not begin with a prompt are output from the interpreter. % @@ -455,7 +455,7 @@ \section{Using Python as a Calculator \label{calculator}} Let's try some simple Python commands. Start the interpreter and wait -for the primary prompt, \samp{>\code{>}>~}. (It shouldn't take long.) +for the primary prompt, \samp{>>>~}. (It shouldn't take long.) \subsection{Numbers \label{numbers}} Modified: python/trunk/Doc/whatsnew/whatsnew20.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew20.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew20.tex Wed May 3 04:04:40 2006 @@ -400,7 +400,7 @@ % The empty groups below prevent conversion to guillemets. The full list of supported assignment operators is \code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=}, \code{**=}, \code{\&=}, -\code{|=}, \verb|^=|, \code{>{}>=}, and \code{<{}<=}. Python classes can +\code{|=}, \verb|^=|, \code{>>=}, and \code{<<=}. Python classes can override the augmented assignment operators by defining methods named \method{__iadd__}, \method{__isub__}, etc. For example, the following \class{Number} class stores a number and supports using += to create a From python-checkins at python.org Wed May 3 04:12:49 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 04:12:49 +0200 (CEST) Subject: [Python-checkins] r45870 - python/trunk/Doc/perl/l2hinit.perl Message-ID: <20060503021249.F19CF1E4012@bag.python.org> Author: fred.drake Date: Wed May 3 04:12:47 2006 New Revision: 45870 Modified: python/trunk/Doc/perl/l2hinit.perl Log: at least comment on why curly-quotes are not enabled Modified: python/trunk/Doc/perl/l2hinit.perl ============================================================================== --- python/trunk/Doc/perl/l2hinit.perl (original) +++ python/trunk/Doc/perl/l2hinit.perl Wed May 3 04:12:47 2006 @@ -8,6 +8,9 @@ $LOWER_CASE_TAGS = 1; $NO_FRENCH_QUOTES = 1; +# '' in \code{...} is still converted, so we can't use this yet. +#$USE_CURLY_QUOTES = 1; + # Force Unicode support to be loaded; request UTF-8 output. do_require_extension('unicode'); do_require_extension('utf8'); From python-checkins at python.org Wed May 3 04:27:42 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 04:27:42 +0200 (CEST) Subject: [Python-checkins] r45871 - python/trunk/Doc/ref/ref6.tex Message-ID: <20060503022742.1ECC61E4005@bag.python.org> Author: fred.drake Date: Wed May 3 04:27:40 2006 New Revision: 45871 Modified: python/trunk/Doc/ref/ref6.tex Log: one more place to avoid extra markup Modified: python/trunk/Doc/ref/ref6.tex ============================================================================== --- python/trunk/Doc/ref/ref6.tex (original) +++ python/trunk/Doc/ref/ref6.tex Wed May 3 04:27:40 2006 @@ -417,7 +417,7 @@ \keyword{print} also has an extended\index{extended print statement} form, defined by the second portion of the syntax described above. This form is sometimes referred to as ``\keyword{print} chevron.'' -In this form, the first expression after the \code{>}\code{>} must +In this form, the first expression after the \code{>>} must evaluate to a ``file-like'' object, specifically an object that has a \method{write()} method as described above. With this extended form, the subsequent expressions are printed to this file object. If the From python-checkins at python.org Wed May 3 04:29:10 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 04:29:10 +0200 (CEST) Subject: [Python-checkins] r45872 - python/trunk/Doc/lib/libdis.tex Message-ID: <20060503022910.5738C1E4005@bag.python.org> Author: fred.drake Date: Wed May 3 04:29:09 2006 New Revision: 45872 Modified: python/trunk/Doc/lib/libdis.tex Log: one more place to avoid extra markup (how many will there be?) Modified: python/trunk/Doc/lib/libdis.tex ============================================================================== --- python/trunk/Doc/lib/libdis.tex (original) +++ python/trunk/Doc/lib/libdis.tex Wed May 3 04:29:09 2006 @@ -55,7 +55,7 @@ \begin{enumerate} \item the line number, for the first instruction of each line \item the current instruction, indicated as \samp{-->}, -\item a labelled instruction, indicated with \samp{>\code{>}}, +\item a labelled instruction, indicated with \samp{>>}, \item the address of the instruction, \item the operation code name, \item operation parameters, and From python-checkins at python.org Wed May 3 04:29:40 2006 From: python-checkins at python.org (fred.drake) Date: Wed, 3 May 2006 04:29:40 +0200 (CEST) Subject: [Python-checkins] r45873 - python/trunk/Doc/lib/libsys.tex Message-ID: <20060503022940.42CDC1E4005@bag.python.org> Author: fred.drake Date: Wed May 3 04:29:39 2006 New Revision: 45873 Modified: python/trunk/Doc/lib/libsys.tex Log: fix up whitespace in prompt strings Modified: python/trunk/Doc/lib/libsys.tex ============================================================================== --- python/trunk/Doc/lib/libsys.tex (original) +++ python/trunk/Doc/lib/libsys.tex Wed May 3 04:29:39 2006 @@ -410,7 +410,7 @@ Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are - \code{'>>>~'} and \code{'... '}. If a non-string object is + \code{'>>>~'} and \code{'...~'}. If a non-string object is assigned to either variable, its \function{str()} is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt. From buildbot at python.org Wed May 3 05:07:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 03:07:19 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060503030719.A26AB1E4005@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/355 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fred.drake Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 3 05:52:48 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 3 May 2006 05:52:48 +0200 (CEST) Subject: [Python-checkins] r45874 - peps/trunk/pep-0243.txt Message-ID: <20060503035248.BE19B1E4005@bag.python.org> Author: sean.reifschneider Date: Wed May 3 05:52:47 2006 New Revision: 45874 Modified: peps/trunk/pep-0243.txt Log: Withdrawing. Modified: peps/trunk/pep-0243.txt ============================================================================== --- peps/trunk/pep-0243.txt (original) +++ peps/trunk/pep-0243.txt Wed May 3 05:52:47 2006 @@ -4,7 +4,7 @@ Last-Modified: $Date$ Author: jafo-pep at tummy.com (Sean Reifschneider) Discussions-To: distutils-sig at python.org -Status: Draft +Status: Withdrawn Type: Standards Track Created: 18-Mar-2001 Python-Version: 2.1 From python-checkins at python.org Wed May 3 06:44:17 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 3 May 2006 06:44:17 +0200 (CEST) Subject: [Python-checkins] r45875 - peps/trunk/pep-0000.txt Message-ID: <20060503044417.B109E1E4005@bag.python.org> Author: neal.norwitz Date: Wed May 3 06:44:17 2006 New Revision: 45875 Modified: peps/trunk/pep-0000.txt Log: 243 was withdrawn Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Wed May 3 06:44:17 2006 @@ -75,7 +75,6 @@ S 228 Reworking Python's Numeric Model Zadka, GvR S 237 Unifying Long Integers and Integers Zadka, GvR - S 243 Module Repository Upload Mechanism Reifschneider S 256 Docstring Processing System Framework Goodger S 258 Docutils Design Specification Goodger S 267 Optimized Access to Module Namespaces Hylton @@ -192,6 +191,7 @@ SR 239 Adding a Rational Type to Python Craig, Zadka SR 240 Adding a Rational Literal to Python Craig, Zadka SR 242 Numeric Kinds Dubois + SW 243 Module Repository Upload Mechanism Reifschneider SR 244 The `directive' Statement von Loewis SR 245 Python Interface Syntax Pelletier SR 246 Object Adaptation Evans @@ -304,7 +304,7 @@ SR 240 Adding a Rational Literal to Python Craig, Zadka SF 241 Metadata for Python Software Packages Kuchling SR 242 Numeric Kinds Dubois - S 243 Module Repository Upload Mechanism Reifschneider + SW 243 Module Repository Upload Mechanism Reifschneider SR 244 The `directive' Statement von Loewis SR 245 Python Interface Syntax Pelletier SR 246 Object Adaptation Evans From python-checkins at python.org Wed May 3 06:46:15 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 3 May 2006 06:46:15 +0200 (CEST) Subject: [Python-checkins] r45876 - in python/trunk: Doc/lib/sqlite3/adapter_point_1.py Doc/lib/sqlite3/adapter_point_2.py Doc/lib/sqlite3/execute_2.py Doc/lib/sqlite3/execute_3.py Doc/lib/sqlite3/insert_more_people.py Doc/lib/sqlite3/shortcut_methods.py Doc/lib/sqlite3/text_factory.py Lib/test/test_unicode.py Message-ID: <20060503044615.BEABD1E4005@bag.python.org> Author: tim.peters Date: Wed May 3 06:46:14 2006 New Revision: 45876 Modified: python/trunk/Doc/lib/sqlite3/adapter_point_1.py python/trunk/Doc/lib/sqlite3/adapter_point_2.py python/trunk/Doc/lib/sqlite3/execute_2.py python/trunk/Doc/lib/sqlite3/execute_3.py python/trunk/Doc/lib/sqlite3/insert_more_people.py python/trunk/Doc/lib/sqlite3/shortcut_methods.py python/trunk/Doc/lib/sqlite3/text_factory.py python/trunk/Lib/test/test_unicode.py Log: Whitespace normalization. Modified: python/trunk/Doc/lib/sqlite3/adapter_point_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/adapter_point_1.py (original) +++ python/trunk/Doc/lib/sqlite3/adapter_point_1.py Wed May 3 06:46:14 2006 @@ -14,4 +14,3 @@ p = Point(4.0, -3.2) cur.execute("select ?", (p,)) print cur.fetchone()[0] - Modified: python/trunk/Doc/lib/sqlite3/adapter_point_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/adapter_point_2.py (original) +++ python/trunk/Doc/lib/sqlite3/adapter_point_2.py Wed May 3 06:46:14 2006 @@ -15,4 +15,3 @@ p = Point(4.0, -3.2) cur.execute("select ?", (p,)) print cur.fetchone()[0] - Modified: python/trunk/Doc/lib/sqlite3/execute_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execute_2.py (original) +++ python/trunk/Doc/lib/sqlite3/execute_2.py Wed May 3 06:46:14 2006 @@ -10,4 +10,3 @@ cur.execute("select name_last, age from people where name_last=:who and age=:age", {"who": who, "age": age}) print cur.fetchone() - Modified: python/trunk/Doc/lib/sqlite3/execute_3.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execute_3.py (original) +++ python/trunk/Doc/lib/sqlite3/execute_3.py Wed May 3 06:46:14 2006 @@ -10,5 +10,3 @@ cur.execute("select name_last, age from people where name_last=:who and age=:age", locals()) print cur.fetchone() - - Modified: python/trunk/Doc/lib/sqlite3/insert_more_people.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/insert_more_people.py (original) +++ python/trunk/Doc/lib/sqlite3/insert_more_people.py Wed May 3 06:46:14 2006 @@ -14,4 +14,3 @@ # The changes will not be saved unless the transaction is committed explicitly: con.commit() - Modified: python/trunk/Doc/lib/sqlite3/shortcut_methods.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/shortcut_methods.py (original) +++ python/trunk/Doc/lib/sqlite3/shortcut_methods.py Wed May 3 06:46:14 2006 @@ -1,22 +1,21 @@ -import sqlite3 - -persons = [ - ("Hugo", "Boss"), - ("Calvin", "Klein") - ] - -con = sqlite3.connect(":memory:") - -# Create the table -con.execute("create table person(firstname, lastname)") - -# Fill the table -con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) - -# Print the table contents -for row in con.execute("select firstname, lastname from person"): - print row - -# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. -print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" - +import sqlite3 + +persons = [ + ("Hugo", "Boss"), + ("Calvin", "Klein") + ] + +con = sqlite3.connect(":memory:") + +# Create the table +con.execute("create table person(firstname, lastname)") + +# Fill the table +con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) + +# Print the table contents +for row in con.execute("select firstname, lastname from person"): + print row + +# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. +print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" Modified: python/trunk/Doc/lib/sqlite3/text_factory.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/text_factory.py (original) +++ python/trunk/Doc/lib/sqlite3/text_factory.py Wed May 3 06:46:14 2006 @@ -1,43 +1,42 @@ -import sqlite3 - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -# Create the table -con.execute("create table person(lastname, firstname)") - -AUSTRIA = u"\xd6sterreich" - -# by default, rows are returned as Unicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert row[0] == AUSTRIA - -# but we can make pysqlite always return bytestrings ... -con.text_factory = str -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == str -# the bytestrings will be encoded in UTF-8, unless you stored garbage in the -# database ... -assert row[0] == AUSTRIA.encode("utf-8") - -# we can also implement a custom text_factory ... -# here we implement one that will ignore Unicode characters that cannot be -# decoded from UTF-8 -con.text_factory = lambda x: unicode(x, "utf-8", "ignore") -cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) -row = cur.fetchone() -assert type(row[0]) == unicode - -# pysqlite offers a builtin optimized text_factory that will return bytestring -# objects, if the data is in ASCII only, and otherwise return unicode objects -con.text_factory = sqlite3.OptimizedUnicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == unicode - -cur.execute("select ?", ("Germany",)) -row = cur.fetchone() -assert type(row[0]) == str - +import sqlite3 + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +# Create the table +con.execute("create table person(lastname, firstname)") + +AUSTRIA = u"\xd6sterreich" + +# by default, rows are returned as Unicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert row[0] == AUSTRIA + +# but we can make pysqlite always return bytestrings ... +con.text_factory = str +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == str +# the bytestrings will be encoded in UTF-8, unless you stored garbage in the +# database ... +assert row[0] == AUSTRIA.encode("utf-8") + +# we can also implement a custom text_factory ... +# here we implement one that will ignore Unicode characters that cannot be +# decoded from UTF-8 +con.text_factory = lambda x: unicode(x, "utf-8", "ignore") +cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) +row = cur.fetchone() +assert type(row[0]) == unicode + +# pysqlite offers a builtin optimized text_factory that will return bytestring +# objects, if the data is in ASCII only, and otherwise return unicode objects +con.text_factory = sqlite3.OptimizedUnicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == unicode + +cur.execute("select ?", ("Germany",)) +row = cur.fetchone() +assert type(row[0]) == str Modified: python/trunk/Lib/test/test_unicode.py ============================================================================== --- python/trunk/Lib/test/test_unicode.py (original) +++ python/trunk/Lib/test/test_unicode.py Wed May 3 06:46:14 2006 @@ -410,7 +410,7 @@ def __str__(self): return u'\u1234' self.assertEqual('%s' % Wrapper(), u'\u1234') - + @test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') def test_format_float(self): # should not format with a comma, but always with C locale From python-checkins at python.org Wed May 3 06:52:06 2006 From: python-checkins at python.org (martin.v.loewis) Date: Wed, 3 May 2006 06:52:06 +0200 (CEST) Subject: [Python-checkins] r45877 - python/trunk/Doc/lib/libmsilib.tex Message-ID: <20060503045206.37D3C1E4005@bag.python.org> Author: martin.v.loewis Date: Wed May 3 06:52:04 2006 New Revision: 45877 Modified: python/trunk/Doc/lib/libmsilib.tex Log: Correct some formulations, fix XXX comments. Modified: python/trunk/Doc/lib/libmsilib.tex ============================================================================== --- python/trunk/Doc/lib/libmsilib.tex (original) +++ python/trunk/Doc/lib/libmsilib.tex Wed May 3 06:52:04 2006 @@ -33,7 +33,7 @@ be a list of tuples, each containing the name of the file on disk, and the name of the file inside the CAB file. - The files are added to the CAB file in the order they have + The files are added to the CAB file in the order they appear in the list. All files are added into a single CAB file, using the MSZIP compression algorithm. @@ -99,8 +99,7 @@ listing all tables for which content should be added, and one attribute per table that has the actual content. - This is typically used to install the sequence - % XXX unfinished sentence + This is typically used to install the sequence tables. \end{funcdesc} \begin{funcdesc}{add_stream}{database, name, path} @@ -293,7 +292,7 @@ \subsection{Directory Objects\label{msi-directory}} \begin{classdesc}{Directory}{database, cab, basedir, physical, - logical, default, component, \optional{flags}} + logical, default, component, \optional{componentflags}} Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either explicitly created through \method{start_component}, or implicitly when files @@ -301,9 +300,8 @@ component, and into the cab file. To create a directory, a base directory object needs to be specified (can be \code{None}), the path to the physical directory, and a logical directory name. \var{default} - specifies the DefaultDir slot in the directory table. componentflags + specifies the DefaultDir slot in the directory table. \var{componentflags} specifies the default flags that new components get. - % XXX signature says 'component', 'flags'; text says 'componentflags'. \end{classdesc} \begin{methoddesc}[Directory]{start_component}{\optional{component\optional{, @@ -484,4 +482,4 @@ \begin{datadesc}{text} This module contains definitions for the UIText and ActionText tables, for the standard installer actions. -\end{datadesc} \ No newline at end of file +\end{datadesc} From python-checkins at python.org Wed May 3 06:59:03 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 06:59:03 +0200 (CEST) Subject: [Python-checkins] r45878 - peps/trunk/pep-3099.txt Message-ID: <20060503045903.2D4371E4005@bag.python.org> Author: georg.brandl Date: Wed May 3 06:58:59 2006 New Revision: 45878 Modified: peps/trunk/pep-3099.txt Log: No no reusing loop variables. Modified: peps/trunk/pep-3099.txt ============================================================================== --- peps/trunk/pep-3099.txt (original) +++ peps/trunk/pep-3099.txt Wed May 3 06:58:59 2006 @@ -60,6 +60,12 @@ Thread: Future of slices http://mail.python.org/pipermail/python-3000/2006-May/001563.html +* It will not be forbidden to reuse a loop variable inside the loop's + suite. + + Thread: elimination of scope bleeding of iteration variables + http://mail.python.org/pipermail/python-dev/2006-May/064761.html + Builtins ======== From python-checkins at python.org Wed May 3 07:05:03 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 07:05:03 +0200 (CEST) Subject: [Python-checkins] r45879 - python/trunk/Lib/urllib2.py Message-ID: <20060503050503.A1E611E4005@bag.python.org> Author: georg.brandl Date: Wed May 3 07:05:02 2006 New Revision: 45879 Modified: python/trunk/Lib/urllib2.py Log: Patch #1480067: don't redirect HTTP digest auth in urllib2 Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Wed May 3 07:05:02 2006 @@ -858,7 +858,7 @@ auth_val = 'Digest %s' % auth if req.headers.get(self.auth_header, None) == auth_val: return None - req.add_header(self.auth_header, auth_val) + req.add_unredirected_header(self.auth_header, auth_val) resp = self.parent.open(req) return resp From python-checkins at python.org Wed May 3 07:05:09 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 07:05:09 +0200 (CEST) Subject: [Python-checkins] r45880 - python/branches/release24-maint/Lib/urllib2.py Message-ID: <20060503050509.09B4A1E4012@bag.python.org> Author: georg.brandl Date: Wed May 3 07:05:08 2006 New Revision: 45880 Modified: python/branches/release24-maint/Lib/urllib2.py Log: Patch #1480067: don't redirect HTTP digest auth in urllib2 (backport from rev. 45879) Modified: python/branches/release24-maint/Lib/urllib2.py ============================================================================== --- python/branches/release24-maint/Lib/urllib2.py (original) +++ python/branches/release24-maint/Lib/urllib2.py Wed May 3 07:05:08 2006 @@ -815,7 +815,7 @@ auth_val = 'Digest %s' % auth if req.headers.get(self.auth_header, None) == auth_val: return None - req.add_header(self.auth_header, auth_val) + req.add_unredirected_header(self.auth_header, auth_val) resp = self.parent.open(req) return resp From python-checkins at python.org Wed May 3 07:15:12 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 07:15:12 +0200 (CEST) Subject: [Python-checkins] r45881 - python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/test/test_urllib2net.py Message-ID: <20060503051512.17EF31E4005@bag.python.org> Author: georg.brandl Date: Wed May 3 07:15:10 2006 New Revision: 45881 Modified: python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/test/test_urllib2net.py Log: Move network tests from test_urllib2 to test_urllib2net. Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Wed May 3 07:15:10 2006 @@ -857,138 +857,6 @@ else: self.assert_(False) -class NetworkTests(unittest.TestCase): - def setUp(self): - if 0: # for debugging - import logging - logger = logging.getLogger("test_urllib2") - logger.addHandler(logging.StreamHandler()) - - def test_range (self): - req = urllib2.Request("http://www.python.org", - headers={'Range': 'bytes=20-39'}) - result = urllib2.urlopen(req) - data = result.read() - self.assertEqual(len(data), 20) - - # XXX The rest of these tests aren't very good -- they don't check much. - # They do sometimes catch some major disasters, though. - - def test_ftp(self): - urls = [ - 'ftp://www.python.org/pub/python/misc/sousa.au', - 'ftp://www.python.org/pub/tmp/blat', - 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC' - '/research-reports/00README-Legal-Rules-Regs', - ] - self._test_urls(urls, self._extra_handlers()) - - def test_gopher(self): - import warnings - warnings.filterwarnings("ignore", - "the gopherlib module is deprecated", - DeprecationWarning, - "urllib2$") - urls = [ - # Thanks to Fred for finding these! - 'gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex', - 'gopher://gopher.vt.edu:10010/10/33', - ] - self._test_urls(urls, self._extra_handlers()) - - def test_file(self): - TESTFN = test_support.TESTFN - f = open(TESTFN, 'w') - try: - f.write('hi there\n') - f.close() - urls = [ - 'file:'+sanepathname2url(os.path.abspath(TESTFN)), - - # XXX bug, should raise URLError - #('file://nonsensename/etc/passwd', None, urllib2.URLError) - ('file://nonsensename/etc/passwd', None, (OSError, socket.error)) - ] - self._test_urls(urls, self._extra_handlers()) - finally: - os.remove(TESTFN) - - def test_http(self): - urls = [ - 'http://www.espn.com/', # redirect - 'http://www.python.org/Spanish/Inquistion/', - ('http://www.python.org/cgi-bin/faqw.py', - 'query=pythonistas&querytype=simple&casefold=yes&req=search', None), - 'http://www.python.org/', - ] - self._test_urls(urls, self._extra_handlers()) - - # XXX Following test depends on machine configurations that are internal - # to CNRI. Need to set up a public server with the right authentication - # configuration for test purposes. - -## def test_cnri(self): -## if socket.gethostname() == 'bitdiddle': -## localhost = 'bitdiddle.cnri.reston.va.us' -## elif socket.gethostname() == 'bitdiddle.concentric.net': -## localhost = 'localhost' -## else: -## localhost = None -## if localhost is not None: -## urls = [ -## 'file://%s/etc/passwd' % localhost, -## 'http://%s/simple/' % localhost, -## 'http://%s/digest/' % localhost, -## 'http://%s/not/found.h' % localhost, -## ] - -## bauth = HTTPBasicAuthHandler() -## bauth.add_password('basic_test_realm', localhost, 'jhylton', -## 'password') -## dauth = HTTPDigestAuthHandler() -## dauth.add_password('digest_test_realm', localhost, 'jhylton', -## 'password') - -## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) - - def _test_urls(self, urls, handlers): - import socket - import time - import logging - debug = logging.getLogger("test_urllib2").debug - - urllib2.install_opener(urllib2.build_opener(*handlers)) - - for url in urls: - if isinstance(url, tuple): - url, req, expected_err = url - else: - req = expected_err = None - debug(url) - try: - f = urllib2.urlopen(url, req) - except (IOError, socket.error, OSError), err: - debug(err) - if expected_err: - self.assert_(isinstance(err, expected_err)) - else: - buf = f.read() - f.close() - debug("read %d bytes" % len(buf)) - debug("******** next url coming up...") - time.sleep(0.1) - - def _extra_handlers(self): - handlers = [] - - handlers.append(urllib2.GopherHandler) - - cfh = urllib2.CacheFTPHandler() - cfh.setTimeout(1) - handlers.append(cfh) - - return handlers - def test_main(verbose=None): from test import test_urllib2 @@ -998,8 +866,6 @@ OpenerDirectorTests, HandlerTests, MiscTests) - if test_support.is_resource_enabled('network'): - tests += (NetworkTests,) test_support.run_unittest(*tests) if __name__ == "__main__": Modified: python/trunk/Lib/test/test_urllib2net.py ============================================================================== --- python/trunk/Lib/test/test_urllib2net.py (original) +++ python/trunk/Lib/test/test_urllib2net.py Wed May 3 07:15:10 2006 @@ -2,6 +2,7 @@ import unittest from test import test_support +from test.test_urllib2 import sanepathname2url import socket import urllib2 @@ -124,10 +125,145 @@ # urllib2.urlopen, "http://www.sadflkjsasadf.com/") urllib2.urlopen, "http://www.python.invalid/") + +class OtherNetworkTests(unittest.TestCase): + def setUp(self): + if 0: # for debugging + import logging + logger = logging.getLogger("test_urllib2net") + logger.addHandler(logging.StreamHandler()) + + def test_range (self): + req = urllib2.Request("http://www.python.org", + headers={'Range': 'bytes=20-39'}) + result = urllib2.urlopen(req) + data = result.read() + self.assertEqual(len(data), 20) + + # XXX The rest of these tests aren't very good -- they don't check much. + # They do sometimes catch some major disasters, though. + + def test_ftp(self): + urls = [ + 'ftp://www.python.org/pub/python/misc/sousa.au', + 'ftp://www.python.org/pub/tmp/blat', + 'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC' + '/research-reports/00README-Legal-Rules-Regs', + ] + self._test_urls(urls, self._extra_handlers()) + + def test_gopher(self): + import warnings + warnings.filterwarnings("ignore", + "the gopherlib module is deprecated", + DeprecationWarning, + "urllib2$") + urls = [ + # Thanks to Fred for finding these! + 'gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex', + 'gopher://gopher.vt.edu:10010/10/33', + ] + self._test_urls(urls, self._extra_handlers()) + + def test_file(self): + TESTFN = test_support.TESTFN + f = open(TESTFN, 'w') + try: + f.write('hi there\n') + f.close() + urls = [ + 'file:'+sanepathname2url(os.path.abspath(TESTFN)), + + # XXX bug, should raise URLError + #('file://nonsensename/etc/passwd', None, urllib2.URLError) + ('file://nonsensename/etc/passwd', None, (OSError, socket.error)) + ] + self._test_urls(urls, self._extra_handlers()) + finally: + os.remove(TESTFN) + + def test_http(self): + urls = [ + 'http://www.espn.com/', # redirect + 'http://www.python.org/Spanish/Inquistion/', + ('http://www.python.org/cgi-bin/faqw.py', + 'query=pythonistas&querytype=simple&casefold=yes&req=search', None), + 'http://www.python.org/', + ] + self._test_urls(urls, self._extra_handlers()) + + # XXX Following test depends on machine configurations that are internal + # to CNRI. Need to set up a public server with the right authentication + # configuration for test purposes. + +## def test_cnri(self): +## if socket.gethostname() == 'bitdiddle': +## localhost = 'bitdiddle.cnri.reston.va.us' +## elif socket.gethostname() == 'bitdiddle.concentric.net': +## localhost = 'localhost' +## else: +## localhost = None +## if localhost is not None: +## urls = [ +## 'file://%s/etc/passwd' % localhost, +## 'http://%s/simple/' % localhost, +## 'http://%s/digest/' % localhost, +## 'http://%s/not/found.h' % localhost, +## ] + +## bauth = HTTPBasicAuthHandler() +## bauth.add_password('basic_test_realm', localhost, 'jhylton', +## 'password') +## dauth = HTTPDigestAuthHandler() +## dauth.add_password('digest_test_realm', localhost, 'jhylton', +## 'password') + +## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) + + def _test_urls(self, urls, handlers): + import socket + import time + import logging + debug = logging.getLogger("test_urllib2").debug + + urllib2.install_opener(urllib2.build_opener(*handlers)) + + for url in urls: + if isinstance(url, tuple): + url, req, expected_err = url + else: + req = expected_err = None + debug(url) + try: + f = urllib2.urlopen(url, req) + except (IOError, socket.error, OSError), err: + debug(err) + if expected_err: + self.assert_(isinstance(err, expected_err)) + else: + buf = f.read() + f.close() + debug("read %d bytes" % len(buf)) + debug("******** next url coming up...") + time.sleep(0.1) + + def _extra_handlers(self): + handlers = [] + + handlers.append(urllib2.GopherHandler) + + cfh = urllib2.CacheFTPHandler() + cfh.setTimeout(1) + handlers.append(cfh) + + return handlers + + + def test_main(): test_support.requires("network") test_support.run_unittest(URLTimeoutTest, urlopenNetworkTests, - AuthTests) + AuthTests, OtherNetworkTests) if __name__ == "__main__": test_main() From python-checkins at python.org Wed May 3 07:17:37 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 3 May 2006 07:17:37 +0200 (CEST) Subject: [Python-checkins] r45882 - sandbox/trunk/sio/io.py sandbox/trunk/sio/test_io.py Message-ID: <20060503051737.7E9D41E4005@bag.python.org> Author: guido.van.rossum Date: Wed May 3 07:17:37 2006 New Revision: 45882 Added: sandbox/trunk/sio/test_io.py (contents, props changed) Modified: sandbox/trunk/sio/io.py Log: Some progress -- now using TDD. Modified: sandbox/trunk/sio/io.py ============================================================================== --- sandbox/trunk/sio/io.py (original) +++ sandbox/trunk/sio/io.py Wed May 3 07:17:37 2006 @@ -93,20 +93,34 @@ """A binary file using I/O on Unix file descriptors.""" - def __init__(self, fd): + def __init__(self, fd, __more=None, + readable=True, writable=False, + seekable=False, truncatable=False): + if __more is not None: + raise TypeError("only one positional argument is allowed") self._fd = fd + self._readable = readable + self._writable = writable + self._seekable = seekable + self._truncatable = truncatable + + def close(self): + fd = self._fd + self._fd = None + if fd is not None: + os.close(fd) def readable(self): - return True # May be a lie -- but how to tell the mode? + return self._readable def writable(self): - return True # May be a lie -- but how to tell the mode? + return self._writable def seekable(self): - return True # May be a lie -- but how to tell the mode? + return self._seekable def truncatable(self): - return True # May be a lie -- but how to tell the mode? + return self._truncatable def read(self, n): b = os.read(self._fd, n) @@ -128,7 +142,7 @@ os.ftruncate(self._fd, offset) return os.lseek(self._fd, 0, 2) - # XXX ioctl, fcntl? What else? + # XXX ioctl? fcntl? isatty? fileno? What else? class BufferingBinaryFileWrapper: @@ -164,13 +178,32 @@ # else: # self._buffer[self._bufptr : ] = data to be read + def close(self): + file = self._file + if file is not None: + self.flush() + self._file = None + file.close() + + def readable(self): + return self._file.readable() + + def writable(self): + return self._file.writable() + + def seekable(self): + return self._file.seekable() + + def truncatable(self): + return self._file.truncatable() + def flush(self): if self._writing: start = 0 while start < self._bufptr: start += self._file.write(self._buffer[start : self._bufptr]) self._bufptr = 0 - elif self._bufptr < len(self._buffer): + elif self._bufptr < len(self._buffer) and self._file.seekable(): self._file.seek(self._bufptr - len(self._buffer), 1) self._buffer = bytes() self._bufptr = 0 @@ -224,22 +257,66 @@ self._buffer = bytes(self._bufsize) if self._bufptr + len(b) < len(self._buffer): self._buffer[self._bufptr : self._bufptr + len(b)] = b + self._bufptr += len(b) elif self._bufptr + len(b) == len(self._buffer): self._buffer[self._bufptr : ] = b + self._bufptr = len(self._buffer) self.flush() else: n = len(self._buffer) - self._bufptr self._buffer[self._bufptr : ] = b[ : n] + self._bufptr = len(self._buffer) self.flush() - self._bufptr[ : len(b) - n] = b[n : ] + self._buffer[ : len(b) - n] = b[n : ] self._bufptr = len(b) - n + def seek(self, pos, whence=0): + if not self._file.seekable(): + raise IOError("file is not seekable") + # XXX Optimize this for seeks while reading within the buffer? + self.flush() + self._file.seek(pos, whence) + + def tell(self): + if not self._file.seekable(): + raise IOError("file is not seekable") + pos = self._file.tell() + if self._writing: + pos += self._bufptr + else: + pos += self._bufptr - len(self._buffer) + return pos -def main(): - import sys - fd = sys.stdout.fileno() - f = OSBinaryFile(fd) - f.write(bytes(u"hello world\n", "ascii")) + def truncate(self, pos): + if not self._file.truncatable(): + raise IOError("file is not truncatable") + self.flush() + return self._file.truncate(pos) -if __name__ == "__main__": - main() + +def open(filename, mode, bufsize=DEFAULT_BUFSIZE): + """Return an open file object. + + This is a versatile factory function that can open binary and text + files for reading and writing. + + """ + if mode not in ("rb", "wb"): + raise ValueError("unrecognized mode: %r" % (mode,)) + flags = getattr(os, "O_BINARY", 0) + readable = writable = False + if mode == "rb": + flags |= os.O_RDONLY + readable = True + else: + flags |= os.O_WRONLY | os.O_TRUNC | os.O_CREAT + writable = True + fd = os.open(filename, flags, 0666) + file = OSBinaryFile(fd, + readable=readable, + writable=writable, + seekable=True, + truncatable=hasattr(os, "ftruncate")) + if bufsize != 0: + file = BufferingBinaryFileWrapper(file, bufsize) + return file Added: sandbox/trunk/sio/test_io.py ============================================================================== --- (empty file) +++ sandbox/trunk/sio/test_io.py Wed May 3 07:17:37 2006 @@ -0,0 +1,92 @@ +#!/usr/bin/env python3.0 + +"""Unit tests for io.py.""" + +import os +import shutil +import tempfile +import unittest + +import io # Local + + +class IOTestCase(unittest.TestCase): + + def setUp(self): + self.tfn = tempfile.mktemp() + + def tearDown(self): + if os.path.exists(self.tfn): + os.remove(self.tfn) + + def test_unbuffered(self): + sample1 = bytes("hello ") + sample2 = bytes("world\n") + f = io.open(self.tfn, "wb", 0) + try: + f.write(sample1) + f.write(sample2) + finally: + f.close() + + f = open(self.tfn) # Classic open! + try: + data = f.read() + finally: + f.close() + self.assertEquals(bytes(data), sample1+sample2) + + f = io.open(self.tfn, "rb", 0) + try: + data = f.read(1) + self.assertEquals(data, sample1[:1]) + self.assertEquals(f.tell(), 1) + f.seek(0) + self.assertEquals(f.tell(), 0) + data = f.read(len(sample1)) + self.assertEquals(data, sample1) + data += f.read(100) + self.assertEquals(data, sample1+sample2) + finally: + f.close() + + def test_buffered_read(self): + sample1 = bytes("hello ") + sample2 = bytes("world\n") + for bufsize in 1, 2, 3, 4, 5, 6, 7, 8, 16, 8*1024: + f = io.open(self.tfn, "wb", bufsize) + try: + f.write(sample1) + f.write(sample2) + finally: + f.close() + + f = open(self.tfn) # Classic open! + try: + data = f.read() + finally: + f.close() + self.assertEquals(bytes(data), sample1+sample2, + "%r != %r, bufsize=%s" % (bytes(data), + sample1+sample2, + bufsize)) + + f = io.open(self.tfn, "rb", bufsize) + try: + data = f.read(1) + self.assertEquals(data, sample1[:1]) + self.assertEquals(f.tell(), 1) + f.seek(0) + self.assertEquals(f.tell(), 0) + data = f.read(len(sample1)) + self.assertEquals(data, sample1) + data += f.read(100) + self.assertEquals(data, sample1+sample2) + finally: + f.close() + + os.remove(self.tfn) + + +if __name__ == "__main__": + unittest.main() From nnorwitz at gmail.com Wed May 3 07:56:26 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 2 May 2006 22:56:26 -0700 Subject: [Python-checkins] r45862 - in python/trunk: Doc/lib/libcontextlib.tex Doc/ref/ref3.tex Doc/ref/ref7.tex Lib/calendar.py Lib/compiler/pycodegen.py Lib/contextlib.py Lib/decimal.py Lib/dummy_thread.py Lib/test/test_contextlib.py Lib/test/test_with. Message-ID: I wonder if get_manager() would be a better method name. At least this: with decimal.ExtendedContext.get_manager(): reads better to me since context is not duplicated. n -- > Modified: python/trunk/Lib/decimal.py > ============================================================================== > --- python/trunk/Lib/decimal.py (original) > +++ python/trunk/Lib/decimal.py Tue May 2 21:47:52 2006 > @@ -2248,7 +2248,7 @@ > s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') > return ', '.join(s) + ')' > > - def __context__(self): > + def context_manager(self): > return WithStatementContext(self.copy()) > > def clear_flags(self): > > Modified: python/trunk/Lib/test/test_contextlib.py > ============================================================================== > --- python/trunk/Lib/test/test_contextlib.py (original) > +++ python/trunk/Lib/test/test_contextlib.py Tue May 2 21:47:52 2006 > @@ -341,12 +339,12 @@ > orig_context = ctx.copy() > try: > ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 > - with decimal.ExtendedContext: > + with decimal.ExtendedContext.context_manager(): > self.assertEqual(decimal.getcontext().prec, > decimal.ExtendedContext.prec) > self.assertEqual(decimal.getcontext().prec, save_prec) > try: > - with decimal.ExtendedContext: > + with decimal.ExtendedContext.context_manager(): > self.assertEqual(decimal.getcontext().prec, > decimal.ExtendedContext.prec) > 1/0 > From python-checkins at python.org Wed May 3 09:45:57 2006 From: python-checkins at python.org (richard.tew) Date: Wed, 3 May 2006 09:45:57 +0200 (CEST) Subject: [Python-checkins] r45883 - stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Message-ID: <20060503074557.C4AB51E4005@bag.python.org> Author: richard.tew Date: Wed May 3 09:45:56 2006 New Revision: 45883 Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Log: Fixed the MASM __return definition. I am adapting this #ifdef block for the arm assembler slp_switch I am writing, and noticed that the two statements in the __return define were not enclosed in a block, so polluted where they were expanded so the code would always return after that point. Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c (original) +++ stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Wed May 3 09:45:56 2006 @@ -47,7 +47,7 @@ #define STACK_MAGIC 0 #undef __return -#define __return(x) exitcode = x; goto exit; +#define __return(x) { exitcode = x; goto exit; } int slp_save_state(intptr_t *stack){ int exitcode; From python-checkins at python.org Wed May 3 11:41:55 2006 From: python-checkins at python.org (nick.coghlan) Date: Wed, 3 May 2006 11:41:55 +0200 (CEST) Subject: [Python-checkins] r45884 - peps/trunk/pep-0343.txt Message-ID: <20060503094155.730071E400B@bag.python.org> Author: nick.coghlan Date: Wed May 3 11:41:53 2006 New Revision: 45884 Modified: peps/trunk/pep-0343.txt Log: Address some comments from Guido by cutting back on the overengineering in the terminology section. Also a few minor grammar cleanups and fixes I missed last night. Modified: peps/trunk/pep-0343.txt ============================================================================== --- peps/trunk/pep-0343.txt (original) +++ peps/trunk/pep-0343.txt Wed May 3 11:41:53 2006 @@ -15,8 +15,8 @@ it possible to factor out standard uses of try/finally statements. In this PEP, context managers provide __enter__() and __exit__() - methods that are invoked on entry to and exit from the managed - context that forms the body of the with statement. + methods that are invoked on entry to and exit from the body of the + with statement. Author's Note @@ -50,8 +50,8 @@ [2] and universally approved of. I'm also changing the keyword to 'with'. - Following acceptance of this PEP, the following PEPs have been - rejected due to overlap: + After acceptance of this PEP, the following PEPs were rejected due + to overlap: - PEP 310, Reliable Acquisition/Release Pairs. This is the original with-statement proposal. @@ -469,37 +469,29 @@ and that objects that implement that protocol be known as "context managers". [4] - The code in the body of the with statement is a "managed context". - This term refers primarily to the code location, rather than to the - runtime environment established by the context manager. - The expression immediately following the with keyword in the statement is a "context expression" as that expression provides the main clue as to the runtime environment the context manager - establishes for the duration of the managed context. + establishes for the duration of the statement body. - The value assigned to the target list after the as keyword is the - "context entry value", as that value is returned as the result of - entering the context. - - These terms are based on the idea that the context expression - provides a context manager to appropriately handle entry into the - managed context. The context manager may also provide a meaningful - context entry value and perform clean up operations on exit from - the managed context. - - The general term "context" is unfortunately ambiguous. If necessary, - it can be made more explicit by using the terms "context manager" - for the concrete object created by the context expression, - "managed context" for the code in the body of the with statement, - and "runtime context" or (preferebly) "runtime environment" for the - actual state modifications made by the context manager. When solely - discussing use of the with statement, the distinction between these - shouldn't matter too much as the context manager fully defines the - changes made to the runtime environment, and those changes apply for - the duration of the managed context. The distinction is more - important when discussing the process of implementing context - managers and the mechanics of the with statement itself. + The code in the body of the with statement and the variable name + (or names) after the as keyword don't really have special terms at + this point in time. The general terms "statement body" and "target + list" can be used, prefixing with "with" or "with statement" if the + terms would otherwise be unclear. + + Given the existence of objects such as the decimal module's + arithmetic context, a term "context" is unfortunately ambiguous. + If necessary, it can be made more specific by using the terms + "context manager" for the concrete object created by the context + expression and "runtime context" or (preferably) "runtime + environment" for the actual state modifications made by the context + manager. When simply discussing use of the with statement, the + ambiguity shouldn't matter too much as the context expression fully + defines the changes made to the runtime environment. + The distinction is more important when discussing the mechanics of + the with statement itself and how to go about actually implementing + context managers. Caching Context Managers @@ -531,7 +523,7 @@ 1. Greg Ewing raised the question of whether or not the term "context manager" was too generic and suggested "context guard" - as an alternative name. + as an alternative name. [16] 2. In Python 2.5a2, the decorator in contextlib to create a context manager from a generator function is called @@ -594,9 +586,9 @@ Examples The generator based examples rely on PEP 342. Also, some of the - examples are likely to be unnecessary in practice, as the - appropriate objects, such as threading.RLock, will be able to be - used directly in with statements. + examples are unnecessary in practice, as the appropriate objects, + such as threading.RLock, are able to be used directly in with + statements. The tense used in the names of the example contexts is not arbitrary. Past tense ("-ed") is used when the name refers to an @@ -755,9 +747,8 @@ # so this must be outside the with-statement: return +s - 9. Here's a proposed context manager for the decimal module: + 9. Here's a simple context manager for the decimal module: - # This would be a new decimal.Context method @contextmanager def localcontext(ctx=None): """Set a new local decimal context for the block""" @@ -906,7 +897,7 @@ This PEP was first accepted by Guido at his EuroPython keynote, 27 June 2005. It was accepted again later, with the __context__ method added. - The PEP was implemented in subversion for Python 2.5a1 + The PEP was implemented in Subversion for Python 2.5a1 The __context__() method will be removed in Python 2.5a3 @@ -970,7 +961,7 @@ [15] Guido kills the __context__() method http://mail.python.org/pipermail/python-dev/2006-April/064632.html - [16] Greg propose 'context guard' instead of 'context manager' + [16] Proposal to use 'context guard' instead of 'context manager' http://mail.python.org/pipermail/python-dev/2006-May/064676.html Copyright From python-checkins at python.org Wed May 3 13:55:31 2006 From: python-checkins at python.org (richard.tew) Date: Wed, 3 May 2006 13:55:31 +0200 (CEST) Subject: [Python-checkins] r45885 - in stackless/Python-2.4.3/dev/Stackless: core/slp_transfer.c platf/slp_platformselect.h platf/switch_arm_thumb_gas.s platf/switch_arm_thumb_gcc.h platf/switch_x64_msvc.h Message-ID: <20060503115531.C4A3F1E400B@bag.python.org> Author: richard.tew Date: Wed May 3 13:55:27 2006 New Revision: 45885 Added: stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gas.s (contents, props changed) stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gcc.h (contents, props changed) Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c stackless/Python-2.4.3/dev/Stackless/platf/slp_platformselect.h stackless/Python-2.4.3/dev/Stackless/platf/switch_x64_msvc.h Log: There were CCP x64/masm specific changes to slp_transfer.c which exposed wrapped versions of the SLP_SAVE_STATE and SLP_RESTORE_STATE macros for the masm assembler version of slp_switch to call. They are now no longer masm specific, and should work for other platform's which have assembler versions of slp_switch (like the arm thumb version which is also added in this change). Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c (original) +++ stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Wed May 3 13:55:27 2006 @@ -41,11 +41,24 @@ slp_cstack_restore(_cst); \ } -// #define USE_MASM // CCP addition, define to use masm code -#ifdef USE_MASM -//ccp addition: make these functions, to be called from assembler -#define STACK_MAGIC 0 +/* This define is no longer needed now? */ +#define SLP_EVAL +#include "platf/slp_platformselect.h" +#ifdef EXTERNAL_ASM +/* CCP addition: Make these functions, to be called from assembler. + * The token include file for the given platform should enable the + * EXTERNAL_ASM define so that this is included. + */ + +/* There are two cases where slp_save_state would return 0, the + * first where there is no difference in where the stack pointer + * should be from where it is now. And the second where + * SLP_SAVE_STATE returns without restoring because we are only + * here to save. The assembler routine needs to differentiate + * between these, which is why we override the returns and flag + * the low bit of the return value on early exit. + */ #undef __return #define __return(x) { exitcode = x; goto exit; } @@ -65,11 +78,6 @@ extern int slp_switch(void); -#else - -#define SLP_EVAL -#include "platf/slp_platformselect.h" - #endif static int Modified: stackless/Python-2.4.3/dev/Stackless/platf/slp_platformselect.h ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/platf/slp_platformselect.h (original) +++ stackless/Python-2.4.3/dev/Stackless/platf/slp_platformselect.h Wed May 3 13:55:27 2006 @@ -20,6 +20,8 @@ #include "switch_s390_unix.h" /* Linux/S390 */ #elif defined(__GNUC__) && defined(__s390x__) && defined(__linux__) #include "switch_s390_unix.h" /* Linux/S390 zSeries (identical) */ +#elif defined(__GNUC__) && defined(__arm__) && defined(__thumb__) +#include "switch_arm_thumb_gcc.h" /* gcc using arm thumb */ #endif /* default definitions if not defined in above files */ Added: stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gas.s ============================================================================== --- (empty file) +++ stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gas.s Wed May 3 13:55:27 2006 @@ -0,0 +1,70 @@ +@ The stack switching logic for the arm thumb instruction set. +@ Written by Richard Tew, 2nd May 2006. +@ +@ It is not possible to do this as inline assembler as gcc generates functions +@ where the stack register is preserved, so any changes we make to it will be +@ discarded. However, any stack copying we have done is left in place, which +@ results in corrupt state. +@ +@ This adapts the MASM approach written by Kristjan Jonsson, where early +@ returns from SLP_SAVE_STATE (within slp_save_state) are flagged by setting +@ the low bit of the return value. This either indicates that there was an +@ error (-1) or that we do not need to restore the stack (1) as we are only +@ here to save the current one. +@ +@ I know little arm thumb assembly, so in case anyone else wants to know the +@ approach I took, I will document it here. The first uncertainty was which +@ registers should be saved. I took this section of code from the assembler +@ generated by gcc with a command line of: +@ gcc -mthumb -S slp_transfer.c +@ where slp_transfer included the inline version of slp_switch for the arm +@ thumb. Another initial uncertainty were the instructions needed to: +@ a) obtain the stack pointer. (mov r0, sp) +@ b) restore the stack pointer. (add sp, sp, r0) +@ which were used in the original inlined assembly. The rest of the code was +@ just patched together based on Kristjan's existing masm source code. + +@ (int) slp_switch (void); + .thumb + .align 2 + .global slp_switch + .type slp_switch, %function @ Apparently useful for .map files. + .thumb_func + +slp_switch: + push {r4, r5, r6, r7, lr} + mov r7, fp + mov r6, sl + mov r5, r9 + mov r4, r8 + push {r4, r5, r6, r7} + + mov r0, sp + bl slp_save_state @ diff = slp_save_state([r0]stackref) + + mov r1, #0 @ r1 = -1 + mvn r1, r1 + + cmp r0, r1 @ if (diff == -1) + beq .exit @ return -1; + + cmp r0, #1 @ if (diff == 1) + beq .no_restore @ return 0; + +.restore: + add sp, sp, r0 @ Adjust the stack pointer for the state we are restoring. + + bl slp_restore_state @ slp_restore_state() + +.no_restore: + mov r0, #0 @ Switch successful (whether we restored or not). + +.exit: + pop {r2, r3, r4, r5} + mov r8, r2 + mov r9, r3 + mov sl, r4 + mov fp, r5 + pop {r4, r5, r6, r7, pc} + + .size slp_switch, .-slp_switch @ Apparently useful for .map files. Added: stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gcc.h ============================================================================== --- (empty file) +++ stackless/Python-2.4.3/dev/Stackless/platf/switch_arm_thumb_gcc.h Wed May 3 13:55:27 2006 @@ -0,0 +1,10 @@ + +#define STACK_REFPLUS 1 +#define STACK_MAGIC 0 + +/* Use the generic support for an external assembly language slp_switch function. */ +#define EXTERNAL_ASM + +#ifdef SLP_EVAL +/* This always uses the external masm assembly file. */ +#endif Modified: stackless/Python-2.4.3/dev/Stackless/platf/switch_x64_msvc.h ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/platf/switch_x64_msvc.h (original) +++ stackless/Python-2.4.3/dev/Stackless/platf/switch_x64_msvc.h Wed May 3 13:55:27 2006 @@ -25,25 +25,13 @@ #define alloca _alloca #define STACK_REFPLUS 1 - -#ifdef SLP_EVAL - #define STACK_MAGIC 0 -extern int slp_switch(void); /* defined in masm assembler */ - -/* These two are called from the assembler module */ -SSIZE_T slp_save_state(intptr_t *ref) { - SSIZE_T diff; - SLP_SAVE_STATE(ref, diff); - return diff; -} - -void slp_restore_state(void) -{ - SLP_RESTORE_STATE(); -} +/* Use the generic support for an external assembly language slp_switch function. */ +#define EXTERNAL_ASM +#ifdef SLP_EVAL +/* This always uses the external masm assembly file. */ #endif /* @@ -62,6 +50,6 @@ int stackref; intptr_t stackbase = ((intptr_t)&stackref) & 0xfffff000; return (intptr_t)p >= stackbase && (intptr_t)p < stackbase + 0x00100000; -} +} #endif From python-checkins at python.org Wed May 3 14:58:00 2006 From: python-checkins at python.org (richard.tew) Date: Wed, 3 May 2006 14:58:00 +0200 (CEST) Subject: [Python-checkins] r45886 - stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Message-ID: <20060503125800.6C1B71E400B@bag.python.org> Author: richard.tew Date: Wed May 3 14:57:59 2006 New Revision: 45886 Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Log: The external asm code handling used SSIZE_T, which is Windows specific. Where this is not defined, int is used instead. Modified: stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c (original) +++ stackless/Python-2.4.3/dev/Stackless/core/slp_transfer.c Wed May 3 14:57:59 2006 @@ -64,7 +64,13 @@ int slp_save_state(intptr_t *stack){ int exitcode; +#ifdef SSIZE_T + /* Only on Windows apparently. */ SSIZE_T diff; +#else + /* Py_ssize_t when we port to 2.5? */ + int diff; +#endif SLP_SAVE_STATE(stack, diff); return diff; exit: From python-checkins at python.org Wed May 3 15:02:57 2006 From: python-checkins at python.org (nick.coghlan) Date: Wed, 3 May 2006 15:02:57 +0200 (CEST) Subject: [Python-checkins] r45887 - in python/trunk: Doc/lib/libcontextlib.tex Doc/lib/libstdtypes.tex Doc/ref/ref3.tex Doc/ref/ref7.tex Lib/contextlib.py Lib/decimal.py Lib/test/test_contextlib.py Lib/test/test_with.py Message-ID: <20060503130257.36FD91E400B@bag.python.org> Author: nick.coghlan Date: Wed May 3 15:02:47 2006 New Revision: 45887 Modified: python/trunk/Doc/lib/libcontextlib.tex python/trunk/Doc/lib/libstdtypes.tex python/trunk/Doc/ref/ref3.tex python/trunk/Doc/ref/ref7.tex python/trunk/Lib/contextlib.py python/trunk/Lib/decimal.py python/trunk/Lib/test/test_contextlib.py python/trunk/Lib/test/test_with.py Log: Finish bringing SVN into line with latest version of PEP 343 by getting rid of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager() Modified: python/trunk/Doc/lib/libcontextlib.tex ============================================================================== --- python/trunk/Doc/lib/libcontextlib.tex (original) +++ python/trunk/Doc/lib/libcontextlib.tex Wed May 3 15:02:47 2006 @@ -11,19 +11,20 @@ Functions provided: -\begin{funcdesc}{context}{func} +\begin{funcdesc}{contextmanager}{func} This function is a decorator that can be used to define a factory function for \keyword{with} statement context objects, without needing to create a class or separate \method{__enter__()} and \method{__exit__()} methods. -A simple example: +A simple example (this is not recommended as a real way of +generating HTML!): \begin{verbatim} from __future__ import with_statement -from contextlib import contextfactory +from contextlib import contextmanager - at contextfactory + at contextmanager def tag(name): print "<%s>" % name yield @@ -56,7 +57,7 @@ the statement immediately following the \keyword{with} statement. \end{funcdesc} -\begin{funcdesc}{nested}{ctx1\optional{, ctx2\optional{, ...}}} +\begin{funcdesc}{nested}{mgr1\optional{, mgr2\optional{, ...}}} Combine multiple context managers into a single nested context manager. Code like this: @@ -78,12 +79,12 @@ \end{verbatim} Note that if the \method{__exit__()} method of one of the nested -context objects indicates an exception should be suppressed, no +context managers indicates an exception should be suppressed, no exception information will be passed to any remaining outer context objects. Similarly, if the \method{__exit__()} method of one of the -nested context objects raises an exception, any previous exception +nested context managers raises an exception, any previous exception state will be lost; the new exception will be passed to the -\method{__exit__()} methods of any remaining outer context objects. +\method{__exit__()} methods of any remaining outer context managers. In general, \method{__exit__()} methods should avoid raising exceptions, and in particular they should not re-raise a passed-in exception. @@ -91,13 +92,13 @@ \label{context-closing} \begin{funcdesc}{closing}{thing} -Return a context that closes \var{thing} upon completion of the -block. This is basically equivalent to: +Return a context manager that closes \var{thing} upon completion of +the block. This is basically equivalent to: \begin{verbatim} -from contextlib import contextfactory +from contextlib import contextmanager - at contextfactory + at contextmanager def closing(thing): try: yield thing Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Wed May 3 15:02:47 2006 @@ -1753,67 +1753,50 @@ \end{memberdesc} -\subsection{Context Types \label{typecontext}} +\subsection{Context Manager Types \label{typecontextmanager}} \versionadded{2.5} -\index{with statement context protocol} +\index{context manager} \index{context management protocol} -\index{protocol!with statement context} \index{protocol!context management} Python's \keyword{with} statement supports the concept of a runtime context defined by a context manager. This is implemented using -three distinct methods; these are used to allow user-defined -classes to define a runtime context. +two separate methods that allow user-defined classes to define +a runtime context that is entered before the statement body is +executed and exited when the statement ends. -The \dfn{context management protocol} consists of a single -method that needs to be provided for a context manager object to +The \dfn{context management protocol} consists of a pair of +methods that need to be provided for a context manager object to define a runtime context: -\begin{methoddesc}[context manager]{__context__}{} - Return a with statement context object. The object is required to - support the with statement context protocol described below. If an - object supports different kinds of runtime context, additional - methods can be provided to specifically request context objects for - those kinds of runtime context. (An example of an object supporting - multiple kinds of context would be a synchronisation object which - supported both a locked context for normal thread synchronisation - and an unlocked context to temporarily release a held lock while - performing a potentially long running operation) -\end{methoddesc} - -The with statement context objects themselves are required to support the -following three methods, which together form the -\dfn{with statement context protocol}: - -\begin{methoddesc}[with statement context]{__context__}{} - Return the context object itself. This is required to allow both - context objects and context managers to be used in a \keyword{with} +\begin{methoddesc}[context manager]{__enter__}{} + Enter the runtime context and return either this object or another + object related to the runtime context. The value returned by this + method is bound to the identifier in the \keyword{as} clause of + \keyword{with} statements using this context manager. + + An example of a context manager that returns itself is a file object. + File objects return themselves from __enter__() to allow + \function{open()} to be used as the context expression in a with statement. -\end{methoddesc} -\begin{methoddesc}[with statement context]{__enter__}{} - Enter the runtime context and return either the defining context - manager or another object related to the runtime context. The value - returned by this method is bound to the identifier in the - \keyword{as} clause of \keyword{with} statements using this context. - (An example of a context object that returns the original context - manager is file objects, which are returned from __enter__() to - allow \function{open()} to be used directly in a with - statement. An example of a context object that returns a related - object is \code{decimal.Context} which sets the active decimal - context to a copy of the context manager and then returns the copy. - This allows changes to be made to the current decimal context in the - body of the \keyword{with} statement without affecting code outside - the \keyword{with} statement). + An example of a context manager that returns a related + object is the one returned by \code{decimal.Context.get_manager()}. + These managers set the active decimal context to a copy of the + original decimal context and then return the copy. This allows + changes to be made to the current decimal context in the body of + the \keyword{with} statement without affecting code outside + the \keyword{with} statement. \end{methoddesc} -\begin{methoddesc}[with statement context]{__exit__}{exc_type, exc_val, exc_tb} +\begin{methoddesc}[context manager]{__exit__}{exc_type, exc_val, exc_tb} Exit the runtime context and return a Boolean flag indicating if any expection that occurred should be suppressed. If an exception occurred while executing the body of the \keyword{with} statement, the arguments contain the exception type, value and traceback information. Otherwise, all three arguments are \var{None}. + Returning a true value from this method will cause the \keyword{with} statement to suppress the exception and continue execution with the statement immediately following the \keyword{with} statement. Otherwise @@ -1821,6 +1804,7 @@ executing. Exceptions that occur during execution of this method will replace any exception that occurred in the body of the \keyword{with} statement. + The exception passed in should never be reraised explicitly - instead, this method should return a false value to indicate that the method completed successfully and does not want to suppress the raised @@ -1829,20 +1813,18 @@ \method{__exit__()} method has actually failed. \end{methoddesc} -Python defines several context objects and managers to support -easy thread synchronisation, prompt closure of files or other -objects, and thread-safe manipulation of the decimal arithmetic -context. The specific types are not important beyond their -implementation of the context management and with statement context -protocols. +Python defines several context managers to support easy thread +synchronisation, prompt closure of files or other objects, and +simpler manipulation of the active decimal arithmetic +context. The specific types are not treated specially beyond +their implementation of the context management protocol. Python's generators and the \code{contextlib.contextfactory} decorator -provide a convenient way to implement these protocols. If a context -manager's \method{__context__()} method is implemented as a -generator decorated with the \code{contextlib.contextfactory} -decorator, it will automatically return a with statement context -object supplying the necessary \method{__context__()}, -\method{__enter__()} and \method{__exit__()} methods. +provide a convenient way to implement these protocols. If a generator +function is decorated with the \code{contextlib.contextfactory} +decorator, it will return a context manager implementing the necessary +\method{__enter__()} and \method{__exit__()} methods, rather than the +iterator produced by an undecorated generator function. Note that there is no specific slot for any of these methods in the type structure for Python objects in the Python/C API. Extension Modified: python/trunk/Doc/ref/ref3.tex ============================================================================== --- python/trunk/Doc/ref/ref3.tex (original) +++ python/trunk/Doc/ref/ref3.tex Wed May 3 15:02:47 2006 @@ -2112,14 +2112,13 @@ \end{itemize} -\subsection{With Statement Contexts and Context Managers\label{context-managers}} +\subsection{With Statement Context Managers\label{context-managers}} \versionadded{2.5} A \dfn{context manager} is an object that defines the runtime context to be established when executing a \keyword{with} -statement. The context manager provides a -\dfn{with statement context object} which manages the entry into, +statement. The context manager handles the entry into, and the exit from, the desired runtime context for the execution of the block of code. Context managers are normally invoked using the \keyword{with} statement (described in section~\ref{with}), but @@ -2127,18 +2126,16 @@ \stindex{with} \index{context manager} -\index{context (with statement)} -\index{with statement context} -Typical uses of context managers and contexts include saving and +Typical uses of context managers include saving and restoring various kinds of global state, locking and unlocking resources, closing opened files, etc. -For more information on context managers and context objects, -see ``\ulink{Context Types}{../lib/typecontext.html}'' in the +For more information on context managers, see +``\ulink{Context Types}{../lib/typecontextmanager.html}'' in the \citetitle[../lib/lib.html]{Python Library Reference}. -\begin{methoddesc}[with statement context]{__enter__}{self} +\begin{methoddesc}[context manager]{__enter__}{self} Enter the runtime context related to this object. The \keyword{with} statement will bind this method's return value to the target(s) specified in the \keyword{as} clause of the statement, if any. Modified: python/trunk/Doc/ref/ref7.tex ============================================================================== --- python/trunk/Doc/ref/ref7.tex (original) +++ python/trunk/Doc/ref/ref7.tex Wed May 3 15:02:47 2006 @@ -315,8 +315,8 @@ \versionadded{2.5} The \keyword{with} statement is used to wrap the execution of a block -with methods defined by a context manager or \keyword{with} statement context -object (see section~\ref{context-managers}). This allows common +with methods defined by a context manager (see +section~\ref{context-managers}). This allows common \keyword{try}...\keyword{except}...\keyword{finally} usage patterns to be encapsulated for convenient reuse. Modified: python/trunk/Lib/contextlib.py ============================================================================== --- python/trunk/Lib/contextlib.py (original) +++ python/trunk/Lib/contextlib.py Wed May 3 15:02:47 2006 @@ -2,10 +2,10 @@ import sys -__all__ = ["contextfactory", "nested", "closing"] +__all__ = ["contextmanager", "nested", "closing"] -class GeneratorContext(object): - """Helper for @contextfactory decorator.""" +class GeneratorContextManager(object): + """Helper for @contextmanager decorator.""" def __init__(self, gen): self.gen = gen @@ -45,12 +45,12 @@ raise -def contextfactory(func): - """@contextfactory decorator. +def contextmanager(func): + """@contextmanager decorator. Typical usage: - @contextfactory + @contextmanager def some_generator(): try: @@ -74,7 +74,7 @@ """ def helper(*args, **kwds): - return GeneratorContext(func(*args, **kwds)) + return GeneratorContextManager(func(*args, **kwds)) try: helper.__name__ = func.__name__ helper.__doc__ = func.__doc__ @@ -84,7 +84,7 @@ return helper - at contextfactory + at contextmanager def nested(*managers): """Support multiple context managers in a single with-statement. Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Wed May 3 15:02:47 2006 @@ -2173,7 +2173,7 @@ del name, val, globalname, rounding_functions -class WithStatementContext(object): +class ContextManager(object): """Helper class to simplify Context management. Sample usage: @@ -2248,8 +2248,8 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def context_manager(self): - return WithStatementContext(self.copy()) + def get_manager(self): + return ContextManager(self.copy()) def clear_flags(self): """Reset all flags to zero""" Modified: python/trunk/Lib/test/test_contextlib.py ============================================================================== --- python/trunk/Lib/test/test_contextlib.py (original) +++ python/trunk/Lib/test/test_contextlib.py Wed May 3 15:02:47 2006 @@ -13,9 +13,9 @@ class ContextManagerTestCase(unittest.TestCase): - def test_contextfactory_plain(self): + def test_contextmanager_plain(self): state = [] - @contextfactory + @contextmanager def woohoo(): state.append(1) yield 42 @@ -26,9 +26,9 @@ state.append(x) self.assertEqual(state, [1, 42, 999]) - def test_contextfactory_finally(self): + def test_contextmanager_finally(self): state = [] - @contextfactory + @contextmanager def woohoo(): state.append(1) try: @@ -47,8 +47,8 @@ self.fail("Expected ZeroDivisionError") self.assertEqual(state, [1, 42, 999]) - def test_contextfactory_no_reraise(self): - @contextfactory + def test_contextmanager_no_reraise(self): + @contextmanager def whee(): yield ctx = whee() @@ -56,8 +56,8 @@ # Calling __exit__ should not result in an exception self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None)) - def test_contextfactory_trap_yield_after_throw(self): - @contextfactory + def test_contextmanager_trap_yield_after_throw(self): + @contextmanager def whoo(): try: yield @@ -69,9 +69,9 @@ RuntimeError, ctx.__exit__, TypeError, TypeError("foo"), None ) - def test_contextfactory_except(self): + def test_contextmanager_except(self): state = [] - @contextfactory + @contextmanager def woohoo(): state.append(1) try: @@ -86,14 +86,14 @@ raise ZeroDivisionError(999) self.assertEqual(state, [1, 42, 999]) - def test_contextfactory_attribs(self): + def test_contextmanager_attribs(self): def attribs(**kw): def decorate(func): for k,v in kw.items(): setattr(func,k,v) return func return decorate - @contextfactory + @contextmanager @attribs(foo='bar') def baz(spam): """Whee!""" @@ -106,13 +106,13 @@ # XXX This needs more work def test_nested(self): - @contextfactory + @contextmanager def a(): yield 1 - @contextfactory + @contextmanager def b(): yield 2 - @contextfactory + @contextmanager def c(): yield 3 with nested(a(), b(), c()) as (x, y, z): @@ -122,14 +122,14 @@ def test_nested_cleanup(self): state = [] - @contextfactory + @contextmanager def a(): state.append(1) try: yield 2 finally: state.append(3) - @contextfactory + @contextmanager def b(): state.append(4) try: @@ -148,7 +148,7 @@ def test_nested_right_exception(self): state = [] - @contextfactory + @contextmanager def a(): yield 1 class b(object): @@ -170,10 +170,10 @@ self.fail("Didn't raise ZeroDivisionError") def test_nested_b_swallows(self): - @contextfactory + @contextmanager def a(): yield - @contextfactory + @contextmanager def b(): try: yield @@ -187,7 +187,7 @@ self.fail("Didn't swallow ZeroDivisionError") def test_nested_break(self): - @contextfactory + @contextmanager def a(): yield state = 0 @@ -199,7 +199,7 @@ self.assertEqual(state, 1) def test_nested_continue(self): - @contextfactory + @contextmanager def a(): yield state = 0 @@ -211,7 +211,7 @@ self.assertEqual(state, 3) def test_nested_return(self): - @contextfactory + @contextmanager def a(): try: yield @@ -339,12 +339,12 @@ orig_context = ctx.copy() try: ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext.context_manager(): + with decimal.ExtendedContext.get_manager(): self.assertEqual(decimal.getcontext().prec, decimal.ExtendedContext.prec) self.assertEqual(decimal.getcontext().prec, save_prec) try: - with decimal.ExtendedContext.context_manager(): + with decimal.ExtendedContext.get_manager(): self.assertEqual(decimal.getcontext().prec, decimal.ExtendedContext.prec) 1/0 Modified: python/trunk/Lib/test/test_with.py ============================================================================== --- python/trunk/Lib/test/test_with.py (original) +++ python/trunk/Lib/test/test_with.py Wed May 3 15:02:47 2006 @@ -10,25 +10,26 @@ import sys import unittest from collections import deque -from contextlib import GeneratorContext, contextfactory +from contextlib import GeneratorContextManager, contextmanager from test.test_support import run_unittest -class MockContextManager(GeneratorContext): +class MockContextManager(GeneratorContextManager): def __init__(self, gen): - GeneratorContext.__init__(self, gen) + GeneratorContextManager.__init__(self, gen) self.enter_called = False self.exit_called = False self.exit_args = None def __enter__(self): self.enter_called = True - return GeneratorContext.__enter__(self) + return GeneratorContextManager.__enter__(self) def __exit__(self, type, value, traceback): self.exit_called = True self.exit_args = (type, value, traceback) - return GeneratorContext.__exit__(self, type, value, traceback) + return GeneratorContextManager.__exit__(self, type, + value, traceback) def mock_contextmanager(func): @@ -439,7 +440,7 @@ self.assertAfterWithGeneratorInvariantsNoError(self.bar) def testRaisedStopIteration1(self): - @contextfactory + @contextmanager def cm(): yield @@ -463,7 +464,7 @@ self.assertRaises(StopIteration, shouldThrow) def testRaisedGeneratorExit1(self): - @contextfactory + @contextmanager def cm(): yield From python-checkins at python.org Wed May 3 15:17:50 2006 From: python-checkins at python.org (nick.coghlan) Date: Wed, 3 May 2006 15:17:50 +0200 (CEST) Subject: [Python-checkins] r45888 - python/trunk/Doc/lib/libcontextlib.tex python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060503131750.0CD471E4019@bag.python.org> Author: nick.coghlan Date: Wed May 3 15:17:49 2006 New Revision: 45888 Modified: python/trunk/Doc/lib/libcontextlib.tex python/trunk/Doc/lib/libstdtypes.tex Log: Get rid of a couple more context object references, fix some markup and clarify what happens when a generator context function swallows an exception. Modified: python/trunk/Doc/lib/libcontextlib.tex ============================================================================== --- python/trunk/Doc/lib/libcontextlib.tex (original) +++ python/trunk/Doc/lib/libcontextlib.tex Wed May 3 15:17:49 2006 @@ -13,7 +13,7 @@ \begin{funcdesc}{contextmanager}{func} This function is a decorator that can be used to define a factory -function for \keyword{with} statement context objects, without +function for \keyword{with} statement context managers, without needing to create a class or separate \method{__enter__()} and \method{__exit__()} methods. @@ -52,9 +52,10 @@ the error (if any), or ensure that some cleanup takes place. If an exception is trapped merely in order to log it or to perform some action (rather than to suppress it entirely), the generator must -reraise that exception. Otherwise the \keyword{with} statement will -treat the exception as having been handled, and resume execution with -the statement immediately following the \keyword{with} statement. +reraise that exception. Otherwise the generator context manager will +indicate to the \keyword{with} statement that the exception has been +handled, and execution will resume with the statement immediately +following the \keyword{with} statement. \end{funcdesc} \begin{funcdesc}{nested}{mgr1\optional{, mgr2\optional{, ...}}} @@ -81,9 +82,9 @@ Note that if the \method{__exit__()} method of one of the nested context managers indicates an exception should be suppressed, no exception information will be passed to any remaining outer context -objects. Similarly, if the \method{__exit__()} method of one of the -nested context managers raises an exception, any previous exception -state will be lost; the new exception will be passed to the +managers. Similarly, if the \method{__exit__()} method of one of the +nested managers raises an exception, any previous exception state will +be lost; the new exception will be passed to the \method{__exit__()} methods of any remaining outer context managers. In general, \method{__exit__()} methods should avoid raising exceptions, and in particular they should not re-raise a Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Wed May 3 15:17:49 2006 @@ -1778,8 +1778,8 @@ An example of a context manager that returns itself is a file object. File objects return themselves from __enter__() to allow - \function{open()} to be used as the context expression in a with - statement. + \function{open()} to be used as the context expression in a + \keyword{with} statement. An example of a context manager that returns a related object is the one returned by \code{decimal.Context.get_manager()}. From buildbot at python.org Wed May 3 15:22:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 13:22:14 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060503132214.DA48D1E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/359 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 3 15:51:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 13:51:43 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Debian unstable trunk Message-ID: <20060503135143.D12491E400B@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/347 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Wed May 3 16:35:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 14:35:24 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) trunk Message-ID: <20060503143524.AC8BF1E401C@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/318 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed May 3 19:46:14 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 19:46:14 +0200 (CEST) Subject: [Python-checkins] r45889 - python/trunk/Lib/webbrowser.py Message-ID: <20060503174614.58BEE1E4013@bag.python.org> Author: georg.brandl Date: Wed May 3 19:46:13 2006 New Revision: 45889 Modified: python/trunk/Lib/webbrowser.py Log: Add seamonkey to list of Windows browsers too. Modified: python/trunk/Lib/webbrowser.py ============================================================================== --- python/trunk/Lib/webbrowser.py (original) +++ python/trunk/Lib/webbrowser.py Wed May 3 19:46:13 2006 @@ -509,7 +509,8 @@ _tryorder = [] _browsers = {} # Prefer mozilla/netscape/opera if present - for browser in ("firefox", "firebird", "mozilla", "netscape", "opera"): + for browser in ("firefox", "firebird", "seamonkey", "mozilla", + "netscape", "opera"): if _iscommand(browser): register(browser, None, BackgroundBrowser(browser)) register("windows-default", WindowsDefault) From python-checkins at python.org Wed May 3 20:03:23 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 20:03:23 +0200 (CEST) Subject: [Python-checkins] r45890 - python/trunk/Lib/httplib.py Message-ID: <20060503180323.939D51E4013@bag.python.org> Author: georg.brandl Date: Wed May 3 20:03:22 2006 New Revision: 45890 Modified: python/trunk/Lib/httplib.py Log: RFE #1472176: In httplib, don't encode the netloc and hostname with "idna" if not necessary. Modified: python/trunk/Lib/httplib.py ============================================================================== --- python/trunk/Lib/httplib.py (original) +++ python/trunk/Lib/httplib.py Wed May 3 20:03:22 2006 @@ -796,11 +796,20 @@ nil, netloc, nil, nil, nil = urlsplit(url) if netloc: - self.putheader('Host', netloc.encode("idna")) - elif self.port == HTTP_PORT: - self.putheader('Host', self.host.encode("idna")) + try: + netloc_enc = netloc.encode("ascii") + except UnicodeEncodeError: + netloc_enc = netloc.encode("idna") + self.putheader('Host', netloc_enc) else: - self.putheader('Host', "%s:%s" % (self.host.encode("idna"), self.port)) + try: + host_enc = self.host.encode("ascii") + except UnicodeEncodeError: + host_enc = self.host.encode("idna") + if self.port == HTTP_PORT: + self.putheader('Host', host_enc) + else: + self.putheader('Host', "%s:%s" % (host_enc, self.port)) # note: we are assuming that clients will not attempt to set these # headers since *this* library must deal with the From python-checkins at python.org Wed May 3 20:12:34 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 20:12:34 +0200 (CEST) Subject: [Python-checkins] r45891 - python/trunk/Lib/pdb.py Message-ID: <20060503181234.2D8D71E400B@bag.python.org> Author: georg.brandl Date: Wed May 3 20:12:33 2006 New Revision: 45891 Modified: python/trunk/Lib/pdb.py Log: Bug #1472191: convert breakpoint indices to ints before comparing them to ints Modified: python/trunk/Lib/pdb.py ============================================================================== --- python/trunk/Lib/pdb.py (original) +++ python/trunk/Lib/pdb.py Wed May 3 20:12:33 2006 @@ -527,7 +527,7 @@ arg = arg[i+1:] try: lineno = int(arg) - except: + except ValueError: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) @@ -535,6 +535,12 @@ return numberlist = arg.split() for i in numberlist: + try: + i = int(i) + except ValueError: + print 'Breakpoint index %r is not a number' % i + continue + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print 'No breakpoint numbered', i continue From python-checkins at python.org Wed May 3 20:12:37 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 20:12:37 +0200 (CEST) Subject: [Python-checkins] r45892 - python/branches/release24-maint/Lib/pdb.py Message-ID: <20060503181237.01CE51E400B@bag.python.org> Author: georg.brandl Date: Wed May 3 20:12:36 2006 New Revision: 45892 Modified: python/branches/release24-maint/Lib/pdb.py Log: Bug #1472191: convert breakpoint indices to ints before comparing them to ints (backport from rev. 45891) Modified: python/branches/release24-maint/Lib/pdb.py ============================================================================== --- python/branches/release24-maint/Lib/pdb.py (original) +++ python/branches/release24-maint/Lib/pdb.py Wed May 3 20:12:36 2006 @@ -442,7 +442,7 @@ arg = arg[i+1:] try: lineno = int(arg) - except: + except ValueError: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) @@ -450,6 +450,12 @@ return numberlist = arg.split() for i in numberlist: + try: + i = int(i) + except ValueError: + print 'Breakpoint index %r is not a number' % i + continue + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print 'No breakpoint numbered', i continue From python-checkins at python.org Wed May 3 20:18:33 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 3 May 2006 20:18:33 +0200 (CEST) Subject: [Python-checkins] r45893 - in python/trunk: Lib/compiler/transformer.py Lib/test/test_compiler.py Misc/NEWS Message-ID: <20060503181833.0DF721E400B@bag.python.org> Author: georg.brandl Date: Wed May 3 20:18:32 2006 New Revision: 45893 Modified: python/trunk/Lib/compiler/transformer.py python/trunk/Lib/test/test_compiler.py python/trunk/Misc/NEWS Log: Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package. Modified: python/trunk/Lib/compiler/transformer.py ============================================================================== --- python/trunk/Lib/compiler/transformer.py (original) +++ python/trunk/Lib/compiler/transformer.py Wed May 3 20:18:32 2006 @@ -841,17 +841,15 @@ names.append(self.com_fpdef(node)) i = i + 1 - if i >= len(nodelist): - break - - if nodelist[i][0] == token.EQUAL: + if i < len(nodelist) and nodelist[i][0] == token.EQUAL: defaults.append(self.com_node(nodelist[i + 1])) i = i + 2 elif len(defaults): - # XXX This should be a syntax error. - # Treat "(a=1, b)" as "(a=1, b=None)" - defaults.append(Const(None)) + # we have already seen an argument with default, but here + # came one without + raise SyntaxError, "non-default argument follows default argument" + # skip the comma i = i + 1 return names, defaults, flags Modified: python/trunk/Lib/test/test_compiler.py ============================================================================== --- python/trunk/Lib/test/test_compiler.py (original) +++ python/trunk/Lib/test/test_compiler.py Wed May 3 20:18:32 2006 @@ -56,6 +56,9 @@ def testYieldExpr(self): compiler.compile("def g(): yield\n\n", "", "exec") + def testDefaultArgs(self): + self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass") + def testLineNo(self): # Test that all nodes except Module have a correct lineno attribute. filename = __file__ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 3 20:18:32 2006 @@ -91,6 +91,9 @@ Library ------- +- Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler + package. + - Patch #1472854: make the rlcompleter.Completer class usable on non- UNIX platforms. From buildbot at python.org Wed May 3 20:33:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 18:33:36 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060503183336.ABC831E400B@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/641 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed May 3 20:35:39 2006 From: python-checkins at python.org (thomas.heller) Date: Wed, 3 May 2006 20:35:39 +0200 (CEST) Subject: [Python-checkins] r45894 - python/trunk/Lib/ctypes/test/test_find.py Message-ID: <20060503183539.E3C391E4050@bag.python.org> Author: thomas.heller Date: Wed May 3 20:35:39 2006 New Revision: 45894 Modified: python/trunk/Lib/ctypes/test/test_find.py Log: Don't fail the tests when libglut.so or libgle.so cannot be loaded. Modified: python/trunk/Lib/ctypes/test/test_find.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_find.py (original) +++ python/trunk/Lib/ctypes/test/test_find.py Wed May 3 20:35:39 2006 @@ -39,9 +39,23 @@ if lib_glu: self.glu = CDLL(lib_glu, RTLD_GLOBAL) if lib_glut: - self.glut = CDLL(lib_glut) + # On some systems, additional libraries seem to be + # required, loading glut fails with + # "OSError: /usr/lib/libglut.so.3: undefined symbol: XGetExtensionVersion" + # I cannot figure out how to repair the test on these + # systems (red hat), so we ignore it when the glut or gle + # libraries cannot be loaded. See also: + # https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1478253&group_id=5470 + # http://mail.python.org/pipermail/python-dev/2006-May/064789.html + try: + self.glut = CDLL(lib_glut) + except OSError: + pass if lib_gle: - self.gle = CDLL(lib_gle) + try: + self.gle = CDLL(lib_gle) + except OSError: + pass if lib_gl: def test_gl(self): From buildbot at python.org Wed May 3 20:54:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 18:54:51 +0000 Subject: [Python-checkins] buildbot failure in x86 cygwin trunk Message-ID: <20060503185451.EC4951E4012@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/358 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,thomas.heller BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Wed May 3 21:15:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 19:15:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060503191534.4567A1E400B@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/319 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 3 22:20:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 03 May 2006 20:20:02 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060503202003.0395D1E400B@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/55 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From neal at metaslash.com Wed May 3 22:12:22 2006 From: neal at metaslash.com (Neal Norwitz) Date: Wed, 3 May 2006 16:12:22 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060503201222.GA1399@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33703 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421533 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [420988 refs] From python-checkins at python.org Thu May 4 07:08:12 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 4 May 2006 07:08:12 +0200 (CEST) Subject: [Python-checkins] r45895 - python/trunk/Lib/imputil.py Message-ID: <20060504050812.03A751E4006@bag.python.org> Author: georg.brandl Date: Thu May 4 07:08:10 2006 New Revision: 45895 Modified: python/trunk/Lib/imputil.py Log: Bug #1481530: allow "from os.path import ..." with imputil Modified: python/trunk/Lib/imputil.py ============================================================================== --- python/trunk/Lib/imputil.py (original) +++ python/trunk/Lib/imputil.py Thu May 4 07:08:10 2006 @@ -131,9 +131,12 @@ if importer: return importer._finish_import(top_module, parts[1:], fromlist) - # Grrr, some people "import os.path" + # Grrr, some people "import os.path" or do "from os.path import ..." if len(parts) == 2 and hasattr(top_module, parts[1]): - return top_module + if fromlist: + return getattr(top_module, parts[1]) + else: + return top_module # If the importer does not exist, then we have to bail. A missing # importer means that something else imported the module, and we have From python-checkins at python.org Thu May 4 07:08:19 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 4 May 2006 07:08:19 +0200 (CEST) Subject: [Python-checkins] r45896 - python/branches/release24-maint/Lib/imputil.py Message-ID: <20060504050819.53A4B1E4006@bag.python.org> Author: georg.brandl Date: Thu May 4 07:08:19 2006 New Revision: 45896 Modified: python/branches/release24-maint/Lib/imputil.py Log: Bug #1481530: allow "from os.path import ..." with imputil (backport from rev. 45895) Modified: python/branches/release24-maint/Lib/imputil.py ============================================================================== --- python/branches/release24-maint/Lib/imputil.py (original) +++ python/branches/release24-maint/Lib/imputil.py Thu May 4 07:08:19 2006 @@ -131,9 +131,12 @@ if importer: return importer._finish_import(top_module, parts[1:], fromlist) - # Grrr, some people "import os.path" + # Grrr, some people "import os.path" or do "from os.path import ..." if len(parts) == 2 and hasattr(top_module, parts[1]): - return top_module + if fromlist: + return getattr(top_module, parts[1]) + else: + return top_module # If the importer does not exist, then we have to bail. A missing # importer means that something else imported the module, and we have From buildbot at python.org Thu May 4 07:38:03 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 05:38:03 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060504053803.E408C1E4006@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.4/builds/51 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 4 07:41:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 05:41:41 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin trunk Message-ID: <20060504054141.35C421E4006@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/359 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 4 07:45:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 05:45:05 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060504054505.410C21E4006@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/89 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 4 07:51:05 2006 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 4 May 2006 07:51:05 +0200 (CEST) Subject: [Python-checkins] r45897 - in python/trunk: Lib/test/test_syntax.py Misc/NEWS Parser/parsetok.c Message-ID: <20060504055105.033A41E4006@bag.python.org> Author: martin.v.loewis Date: Thu May 4 07:51:03 2006 New Revision: 45897 Modified: python/trunk/Lib/test/test_syntax.py python/trunk/Misc/NEWS python/trunk/Parser/parsetok.c Log: Patch #1475845: Raise IndentationError for unexpected indent. Modified: python/trunk/Lib/test/test_syntax.py ============================================================================== --- python/trunk/Lib/test/test_syntax.py (original) +++ python/trunk/Lib/test/test_syntax.py Thu May 4 07:51:03 2006 @@ -243,15 +243,18 @@ class SyntaxTestCase(unittest.TestCase): def _check_error(self, code, errtext, - filename="", mode="exec"): + filename="", mode="exec", subclass=None): """Check that compiling code raises SyntaxError with errtext. errtest is a regular expression that must be present in the - test of the exception raised. + test of the exception raised. If subclass is specified it + is the expected subclass of SyntaxError (e.g. IndentationError). """ try: compile(code, filename, mode) except SyntaxError, err: + if subclass and not isinstance(err, subclass): + self.fail("SyntaxError is not a %s" % subclass.__name__) mo = re.search(errtext, str(err)) if mo is None: self.fail("SyntaxError did not contain '%r'" % (errtext,)) @@ -290,6 +293,19 @@ :""") self._check_error(source, "nested scope") + def test_unexpected_indent(self): + self._check_error("foo()\n bar()\n", "unexpected indent", + subclass=IndentationError) + + def test_no_indent(self): + self._check_error("if 1:\nfoo()", "expected an indented block", + subclass=IndentationError) + + def test_bad_outdent(self): + self._check_error("if 1:\n foo()\n bar()", + "unindent does not match .* level", + subclass=IndentationError) + def test_main(): test_support.run_unittest(SyntaxTestCase) from test import test_syntax Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu May 4 07:51:03 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1475845: Raise IndentationError for unexpected indent. + - Patch #1479181: split open() and file() from being aliases for each other. - Bug #1465834: 'bdist_wininst preinstall script support' was fixed Modified: python/trunk/Parser/parsetok.c ============================================================================== --- python/trunk/Parser/parsetok.c (original) +++ python/trunk/Parser/parsetok.c Thu May 4 07:51:03 2006 @@ -194,8 +194,10 @@ if ((err_ret->error = PyParser_AddToken(ps, (int)type, str, tok->lineno, col_offset, &(err_ret->expected))) != E_OK) { - if (err_ret->error != E_DONE) + if (err_ret->error != E_DONE) { PyObject_FREE(str); + err_ret->token = type; + } break; } } From buildbot at python.org Thu May 4 07:56:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 05:56:16 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo 2.4 Message-ID: <20060504055616.21C001E4006@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%25202.4/builds/124 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Thu May 4 08:44:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 06:44:57 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin 2.4 Message-ID: <20060504064457.91FF51E4007@bag.python.org> The Buildbot has detected a new failure of x86 cygwin 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%25202.4/builds/61 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 4 12:08:44 2006 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 4 May 2006 12:08:44 +0200 (CEST) Subject: [Python-checkins] r45898 - in python/trunk: Lib/test/test_os.py Lib/test/test_shutil.py Misc/NEWS Modules/posixmodule.c Message-ID: <20060504100844.5C1691E4007@bag.python.org> Author: martin.v.loewis Date: Thu May 4 12:08:42 2006 New Revision: 45898 Modified: python/trunk/Lib/test/test_os.py python/trunk/Lib/test/test_shutil.py python/trunk/Misc/NEWS python/trunk/Modules/posixmodule.c Log: Implement os.{chdir,rename,rmdir,remove} using Win32 directly. Modified: python/trunk/Lib/test/test_os.py ============================================================================== --- python/trunk/Lib/test/test_os.py (original) +++ python/trunk/Lib/test/test_os.py Thu May 4 12:08:42 2006 @@ -5,6 +5,7 @@ import os import unittest import warnings +import sys from test import test_support warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__) @@ -364,6 +365,20 @@ except NotImplementedError: pass +class Win32ErrorTests(unittest.TestCase): + def test_rename(self): + self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") + + def test_remove(self): + self.assertRaises(WindowsError, os.remove, test_support.TESTFN) + + def test_chdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + +if sys.platform != 'win32': + class Win32ErrorTests(unittest.TestCase): + pass + def test_main(): test_support.run_unittest( TemporaryFileTests, @@ -372,7 +387,8 @@ WalkTests, MakedirTests, DevNullTests, - URandomTests + URandomTests, + Win32ErrorTests ) if __name__ == "__main__": Modified: python/trunk/Lib/test/test_shutil.py ============================================================================== --- python/trunk/Lib/test/test_shutil.py (original) +++ python/trunk/Lib/test/test_shutil.py Thu May 4 12:08:42 2006 @@ -48,12 +48,12 @@ if self.errorState == 0: self.assertEqual(func, os.remove) self.assertEqual(arg, self.childpath) - self.assertEqual(exc[0], OSError) + self.failUnless(issubclass(exc[0], OSError)) self.errorState = 1 else: self.assertEqual(func, os.rmdir) self.assertEqual(arg, TESTFN) - self.assertEqual(exc[0], OSError) + self.failUnless(issubclass(exc[0], OSError)) self.errorState = 2 def test_rmtree_dont_delete_file(self): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu May 4 12:08:42 2006 @@ -67,6 +67,9 @@ Extension Modules ----------------- +- Use Win32 API to implement os.{chdir,rename,rmdir,remove}. As a result, + these functions now raise WindowsError instead of OSError. + - Calling Tk_Init twice is refused if the first call failed as that may deadlock. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Thu May 4 12:08:42 2006 @@ -458,21 +458,29 @@ static PyObject *_PyUnicode_FromFileSystemEncodedObject(register PyObject *obj) { - /* XXX Perhaps we should make this API an alias of - PyObject_Unicode() instead ?! */ - if (PyUnicode_CheckExact(obj)) { - Py_INCREF(obj); - return obj; - } - if (PyUnicode_Check(obj)) { +} + +/* Function suitable for O& conversion */ +static int +convert_to_unicode(PyObject *arg, void* _param) +{ + PyObject **param = (PyObject**)_param; + if (PyUnicode_CheckExact(arg)) { + Py_INCREF(arg); + *param = arg; + } + else if (PyUnicode_Check(arg)) { /* For a Unicode subtype that's not a Unicode object, return a true Unicode object with the same data. */ - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj), - PyUnicode_GET_SIZE(obj)); + *param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(arg), + PyUnicode_GET_SIZE(arg)); + return *param != NULL; } - return PyUnicode_FromEncodedObject(obj, - Py_FileSystemDefaultEncoding, - "strict"); + else + *param = PyUnicode_FromEncodedObject(arg, + Py_FileSystemDefaultEncoding, + "strict"); + return (*param) != NULL; } #endif /* Py_WIN_WIDE_FILENAMES */ @@ -589,35 +597,10 @@ #endif static PyObject * -posix_1str(PyObject *args, char *format, int (*func)(const char*), - char *wformat, int (*wfunc)(const Py_UNICODE*)) +posix_1str(PyObject *args, char *format, int (*func)(const char*)) { char *path1 = NULL; int res; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, wformat, &po)) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - res = (*wfunc)(PyUnicode_AS_UNICODE(po)); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_unicode_filename(PyUnicode_AS_UNICODE(po)); - Py_INCREF(Py_None); - return Py_None; - } - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } -#else - /* Platforms that don't support Unicode filenames - shouldn't be passing these extra params */ - assert(wformat==NULL && wfunc == NULL); -#endif - if (!PyArg_ParseTuple(args, format, Py_FileSystemDefaultEncoding, &path1)) return NULL; @@ -634,52 +617,10 @@ static PyObject * posix_2str(PyObject *args, char *format, - int (*func)(const char *, const char *), - char *wformat, - int (*wfunc)(const Py_UNICODE *, const Py_UNICODE *)) + int (*func)(const char *, const char *)) { char *path1 = NULL, *path2 = NULL; int res; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyObject *po1; - PyObject *po2; - if (PyArg_ParseTuple(args, wformat, &po1, &po2)) { - if (PyUnicode_Check(po1) || PyUnicode_Check(po2)) { - PyObject *wpath1; - PyObject *wpath2; - wpath1 = _PyUnicode_FromFileSystemEncodedObject(po1); - wpath2 = _PyUnicode_FromFileSystemEncodedObject(po2); - if (!wpath1 || !wpath2) { - Py_XDECREF(wpath1); - Py_XDECREF(wpath2); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - res = (*wfunc)(PyUnicode_AS_UNICODE(wpath1), - PyUnicode_AS_UNICODE(wpath2)); - Py_END_ALLOW_THREADS - Py_XDECREF(wpath1); - Py_XDECREF(wpath2); - if (res != 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; - } - /* Else flow through as neither is Unicode. */ - } - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } -#else - /* Platforms that don't support Unicode filenames - shouldn't be passing these extra params */ - assert(wformat==NULL && wfunc == NULL); -#endif - if (!PyArg_ParseTuple(args, format, Py_FileSystemDefaultEncoding, &path1, Py_FileSystemDefaultEncoding, &path2)) @@ -696,6 +637,101 @@ return Py_None; } +#ifdef Py_WIN_WIDE_FILENAMES +static PyObject* +win32_1str(PyObject* args, char* func, + char* format, BOOL (__stdcall *funcA)(LPCSTR), + char* wformat, BOOL (__stdcall *funcW)(LPWSTR)) +{ + PyObject *uni; + char *ansi; + BOOL result; + if (unicode_file_names()) { + if (!PyArg_ParseTuple(args, wformat, &uni)) + PyErr_Clear(); + else { + Py_BEGIN_ALLOW_THREADS + result = funcW(PyUnicode_AsUnicode(uni)); + Py_END_ALLOW_THREADS + if (!result) + return win32_error_unicode(func, PyUnicode_AsUnicode(uni)); + Py_INCREF(Py_None); + return Py_None; + } + } + if (!PyArg_ParseTuple(args, format, &ansi)) + return NULL; + Py_BEGIN_ALLOW_THREADS + result = funcA(ansi); + Py_END_ALLOW_THREADS + if (!result) + return win32_error(func, ansi); + Py_INCREF(Py_None); + return Py_None; + +} + +/* This is a reimplementation of the C library's chdir function, + but one that produces Win32 errors instead of DOS error codes. + chdir is essentially a wrapper around SetCurrentDirectory; however, + it also needs to set "magic" environment variables indicating + the per-drive current directory, which are of the form =: */ +BOOL __stdcall +win32_chdir(LPCSTR path) +{ + char new_path[MAX_PATH+1]; + int result; + char env[4] = "=x:"; + + if(!SetCurrentDirectoryA(path)) + return FALSE; + result = GetCurrentDirectoryA(MAX_PATH+1, new_path); + if (!result) + return FALSE; + /* In the ANSI API, there should not be any paths longer + than MAX_PATH. */ + assert(result <= MAX_PATH+1); + if (strncmp(new_path, "\\\\", 2) == 0 || + strncmp(new_path, "//", 2) == 0) + /* UNC path, nothing to do. */ + return TRUE; + env[1] = new_path[0]; + return SetEnvironmentVariableA(env, new_path); +} + +/* The Unicode version differs from the ANSI version + since the current directory might exceed MAX_PATH characters */ +BOOL __stdcall +win32_wchdir(LPCWSTR path) +{ + wchar_t _new_path[MAX_PATH+1], *new_path = _new_path; + int result; + wchar_t env[4] = L"=x:"; + + if(!SetCurrentDirectoryW(path)) + return FALSE; + result = GetCurrentDirectoryW(MAX_PATH+1, new_path); + if (!result) + return FALSE; + if (result > MAX_PATH+1) { + new_path = malloc(result); + if (!new_path) { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + } + if (wcsncmp(new_path, L"\\\\", 2) == 0 || + wcsncmp(new_path, L"//", 2) == 0) + /* UNC path, nothing to do. */ + return TRUE; + env[1] = new_path[0]; + result = SetEnvironmentVariableW(env, new_path); + if (new_path != _new_path) + free(new_path); + return result; +} +#endif + #ifdef MS_WINDOWS /* The CRT of Windows has a number of flaws wrt. its stat() implementation: - time stamps are restricted to second resolution @@ -1410,14 +1446,13 @@ posix_chdir(PyObject *self, PyObject *args) { #ifdef MS_WINDOWS - return posix_1str(args, "et:chdir", chdir, "U:chdir", _wchdir); + return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir); #elif defined(PYOS_OS2) && defined(PYCC_GCC) - return posix_1str(args, "et:chdir", _chdir2, NULL, NULL); + return posix_1str(args, "et:chdir", _chdir2); #elif defined(__VMS) - return posix_1str(args, "et:chdir", (int (*)(const char *))chdir, - NULL, NULL); + return posix_1str(args, "et:chdir", (int (*)(const char *))chdir); #else - return posix_1str(args, "et:chdir", chdir, NULL, NULL); + return posix_1str(args, "et:chdir", chdir); #endif } @@ -1485,7 +1520,7 @@ static PyObject * posix_chroot(PyObject *self, PyObject *args) { - return posix_1str(args, "et:chroot", chroot, NULL, NULL); + return posix_1str(args, "et:chroot", chroot); } #endif @@ -2071,7 +2106,6 @@ } #endif /* HAVE_NICE */ - PyDoc_STRVAR(posix_rename__doc__, "rename(old, new)\n\n\ Rename a file or directory."); @@ -2080,7 +2114,36 @@ posix_rename(PyObject *self, PyObject *args) { #ifdef MS_WINDOWS - return posix_2str(args, "etet:rename", rename, "OO:rename", _wrename); + PyObject *o1, *o2; + char *p1, *p2; + BOOL result; + if (unicode_file_names()) { + if (!PyArg_ParseTuple(args, "O&O&:rename", + convert_to_unicode, &o1, + convert_to_unicode, &o2)) + PyErr_Clear(); + else { + Py_BEGIN_ALLOW_THREADS + result = MoveFileW(PyUnicode_AsUnicode(o1), + PyUnicode_AsUnicode(o2)); + Py_END_ALLOW_THREADS + Py_DECREF(o1); + Py_DECREF(o2); + if (!result) + return win32_error("rename", NULL); + Py_INCREF(Py_None); + return Py_None; + } + } + if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2)) + return NULL; + Py_BEGIN_ALLOW_THREADS + result = MoveFileA(p1, p2); + Py_END_ALLOW_THREADS + if (!result) + return win32_error("rename", NULL); + Py_INCREF(Py_None); + return Py_None; #else return posix_2str(args, "etet:rename", rename, NULL, NULL); #endif @@ -2095,9 +2158,9 @@ posix_rmdir(PyObject *self, PyObject *args) { #ifdef MS_WINDOWS - return posix_1str(args, "et:rmdir", rmdir, "U:rmdir", _wrmdir); + return win32_1str(args, "rmdir", "s:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW); #else - return posix_1str(args, "et:rmdir", rmdir, NULL, NULL); + return posix_1str(args, "et:rmdir", rmdir); #endif } @@ -2166,9 +2229,9 @@ posix_unlink(PyObject *self, PyObject *args) { #ifdef MS_WINDOWS - return posix_1str(args, "et:remove", unlink, "U:remove", _wunlink); + return win32_1str(args, "remove", "s:remove", DeleteFileA, "U:remove", DeleteFileW); #else - return posix_1str(args, "et:remove", unlink, NULL, NULL); + return posix_1str(args, "et:remove", unlink); #endif } From buildbot at python.org Thu May 4 12:14:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:14:39 +0000 Subject: [Python-checkins] buildbot failure in ia64 Debian unstable trunk Message-ID: <20060504101439.228B21E4007@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/351 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:14:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:14:43 +0000 Subject: [Python-checkins] buildbot failure in ppc Debian unstable trunk Message-ID: <20060504101443.B96451E4007@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/369 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:14:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:14:45 +0000 Subject: [Python-checkins] buildbot failure in x86 gentoo trunk Message-ID: <20060504101445.3D9BF1E4019@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/710 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:15:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:15:09 +0000 Subject: [Python-checkins] buildbot failure in x86 OpenBSD trunk Message-ID: <20060504101509.305D81E4007@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/543 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:15:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:15:14 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo trunk Message-ID: <20060504101514.746C71E4007@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/729 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:15:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:15:48 +0000 Subject: [Python-checkins] buildbot failure in g4 osx.4 trunk Message-ID: <20060504101548.BD08C1E4007@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/630 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:16:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:16:05 +0000 Subject: [Python-checkins] buildbot failure in alpha Debian trunk Message-ID: <20060504101605.E82651E4007@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/84 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:16:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:16:19 +0000 Subject: [Python-checkins] buildbot failure in sparc solaris10 gcc trunk Message-ID: <20060504101619.713FB1E4007@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/635 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:16:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:16:22 +0000 Subject: [Python-checkins] buildbot failure in hppa Ubuntu dapper trunk Message-ID: <20060504101622.B5C241E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/364 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:16:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:16:37 +0000 Subject: [Python-checkins] buildbot failure in alpha Tru64 5.1 trunk Message-ID: <20060504101637.6232D1E4007@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/425 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:20:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:20:16 +0000 Subject: [Python-checkins] buildbot failure in x86 cygwin trunk Message-ID: <20060504102016.807331E4007@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/361 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:20:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:20:21 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) trunk Message-ID: <20060504102021.2D2641E4007@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/323 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:36:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:36:36 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060504103636.7DD171E4007@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/646 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 4 12:43:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 10:43:19 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060504104319.3AE2F1E4007@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/655 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 4 14:04:28 2006 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 4 May 2006 14:04:28 +0200 (CEST) Subject: [Python-checkins] r45899 - python/trunk/Modules/posixmodule.c Message-ID: <20060504120428.932661E4015@bag.python.org> Author: martin.v.loewis Date: Thu May 4 14:04:27 2006 New Revision: 45899 Modified: python/trunk/Modules/posixmodule.c Log: Drop now-unnecessary arguments to posix_2str. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Thu May 4 14:04:27 2006 @@ -1679,7 +1679,7 @@ static PyObject * posix_link(PyObject *self, PyObject *args) { - return posix_2str(args, "etet:link", link, NULL, NULL); + return posix_2str(args, "etet:link", link); } #endif /* HAVE_LINK */ @@ -2145,7 +2145,7 @@ Py_INCREF(Py_None); return Py_None; #else - return posix_2str(args, "etet:rename", rename, NULL, NULL); + return posix_2str(args, "etet:rename", rename); #endif } @@ -5420,7 +5420,7 @@ static PyObject * posix_symlink(PyObject *self, PyObject *args) { - return posix_2str(args, "etet:symlink", symlink, NULL, NULL); + return posix_2str(args, "etet:symlink", symlink); } #endif /* HAVE_SYMLINK */ From buildbot at python.org Thu May 4 14:22:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 12:22:42 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin trunk Message-ID: <20060504122242.2D6691E4007@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/362 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 4 15:11:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 13:11:09 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060504131109.639161E4015@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/324 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 4 15:14:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 04 May 2006 13:14:45 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060504131445.49C261E4002@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/365 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 4 16:27:52 2006 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 4 May 2006 16:27:52 +0200 (CEST) Subject: [Python-checkins] r45900 - python/trunk/Lib/mailbox.py Message-ID: <20060504142752.9D7CC1E4002@bag.python.org> Author: martin.v.loewis Date: Thu May 4 16:27:52 2006 New Revision: 45900 Modified: python/trunk/Lib/mailbox.py Log: Update checks to consider Windows error numbers. Modified: python/trunk/Lib/mailbox.py ============================================================================== --- python/trunk/Lib/mailbox.py (original) +++ python/trunk/Lib/mailbox.py Thu May 4 16:27:52 2006 @@ -2,6 +2,7 @@ """Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.""" +import sys import os import time import calendar @@ -23,6 +24,11 @@ 'BabylMessage', 'MMDFMessage', 'UnixMailbox', 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ] +if sys.platform != 'win32': + # Define WindowsError so that we can use it in an except statement + # even on non-Windows systems + class WindowsError: + pass class Mailbox: """A group of messages in a particular place.""" @@ -262,10 +268,11 @@ self.remove(key) except KeyError: pass + except WindowsError, e: + if e.errno != 2: # ERROR_FILE_NOT_FOUND + raise except OSError, e: - if e.errno == errno.ENOENT: - pass - else: + if e.errno != errno.ENOENT: raise def __setitem__(self, key, message): @@ -419,6 +426,12 @@ path = os.path.join(self._path, 'tmp', uniq) try: os.stat(path) + except WindowsError, e: + if e.errno == 2: # ERROR_FILE_NOT_FOUND + Maildir._count += 1 + return open(path, 'wb+') + else: + raise except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 @@ -566,6 +579,12 @@ self._file.close() try: os.rename(new_file.name, self._path) + except WindowsError, e: + if e.errno == 183: # ERROR_ALREADY_EXISTS + os.remove(self._path) + os.rename(new_file.name, self._path) + else: + raise except OSError, e: if e.errno == errno.EEXIST: os.remove(self._path) @@ -1837,6 +1856,13 @@ else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True + except WindowsError, e: + if e.errno == 183: # ERROR_ALREADY_EXISTS + os.remove(pre_lock.name) + raise ExternalClashError('dot lock unavailable: %s' % + f.name) + else: + raise except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) From python-checkins at python.org Thu May 4 18:52:46 2006 From: python-checkins at python.org (richard.tew) Date: Thu, 4 May 2006 18:52:46 +0200 (CEST) Subject: [Python-checkins] r45901 - stackless/Python-2.4.3/dev/Stackless/pickling/prickelpit.c Message-ID: <20060504165246.4BD7B1E4007@bag.python.org> Author: richard.tew Date: Thu May 4 18:52:45 2006 New Revision: 45901 Modified: stackless/Python-2.4.3/dev/Stackless/pickling/prickelpit.c Log: Fix for the failing Stackless unittest TestConcretePickledTasklets. The problem was the new dictionary iterator reduce functions I had written badly wrapped the sequence iterator (they used the iterator itself, rather than the wrapped stackless version). Modified: stackless/Python-2.4.3/dev/Stackless/pickling/prickelpit.c ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/pickling/prickelpit.c (original) +++ stackless/Python-2.4.3/dev/Stackless/pickling/prickelpit.c Thu May 4 18:52:45 2006 @@ -1415,11 +1415,11 @@ } } /* masquerade as a PySeqIter */ - tup = Py_BuildValue("(O(lO))", - &PySeqIter_Type, - 0, - list - ); + tup = Py_BuildValue("(O(Ol)())", + &wrap_PySeqIter_Type, + list, + 0 + ); Py_DECREF(list); return tup; } @@ -1455,11 +1455,11 @@ } } /* masquerade as a PySeqIter */ - tup = Py_BuildValue("(O(lO))", - &PySeqIter_Type, - 0, - list - ); + tup = Py_BuildValue("(O(Ol)())", + &wrap_PySeqIter_Type, + list, + 0 + ); Py_DECREF(list); return tup; } @@ -1502,60 +1502,15 @@ } } /* masquerade as a PySeqIter */ - tup = Py_BuildValue("(O(lO))", - &PySeqIter_Type, - 0, - list - ); + tup = Py_BuildValue("(O(Ol)())", + &wrap_PySeqIter_Type, + list, + 0 + ); Py_DECREF(list); return tup; } -#if 0 -static PyObject * -dictiter_reduce(dictiterobject *di) -{ - PyObject *tup, *list, *key, *value, *res; - int i; - - /* Make a list big enough to exhaust the dict */ - list = PyList_New(0); - if (list == NULL) - return PyErr_NoMemory(); - - /* is this dictiter is already exhausted? */ - if (di->di_dict != NULL) { - if (di->di_used != di->di_dict->ma_used) { - PyErr_SetString(PyExc_RuntimeError, - "dictionary changed size during iteration"); - di->di_used = -1; /* Make this state sticky */ - return NULL; - } - i = di->di_pos; - while (PyDict_Next((PyObject *)di->di_dict, &i, &key, - &value)) { - res = (*di->di_select)(key, value); - if (res == NULL) { - Py_DECREF(list); - return NULL; - } - if (PyList_Append(list, res) == -1) { - return NULL; - } - Py_DECREF(res); - } - } - /* masquerade as a PySeqIter */ - tup = Py_BuildValue("(O(Ol)())", - &wrap_PySeqIter_Type, - list, - 0 - ); - Py_DECREF(list); - return tup; -} -#endif - static PyTypeObject wrap_PyDictIterKey_Type; MAKE_WRAPPERTYPE(PyDictIterKey_Type, dictiterkey, "dictionary-keyiterator", From guido at python.org Thu May 4 19:00:04 2006 From: guido at python.org (Guido van Rossum) Date: Thu, 4 May 2006 10:00:04 -0700 Subject: [Python-checkins] r45898 - in python/trunk: Lib/test/test_os.py Lib/test/test_shutil.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <20060504100844.5C1691E4007@bag.python.org> References: <20060504100844.5C1691E4007@bag.python.org> Message-ID: I wonder if it's time to move the Win32 code out of posixmodule.c? It seems the current mess of #ifdefs can't be very maintainable. On 5/4/06, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Thu May 4 12:08:42 2006 > New Revision: 45898 > > Modified: > python/trunk/Lib/test/test_os.py > python/trunk/Lib/test/test_shutil.py > python/trunk/Misc/NEWS > python/trunk/Modules/posixmodule.c > Log: > Implement os.{chdir,rename,rmdir,remove} using Win32 directly. > > Modified: python/trunk/Lib/test/test_os.py > ============================================================================== > --- python/trunk/Lib/test/test_os.py (original) > +++ python/trunk/Lib/test/test_os.py Thu May 4 12:08:42 2006 > @@ -5,6 +5,7 @@ > import os > import unittest > import warnings > +import sys > from test import test_support > > warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__) > @@ -364,6 +365,20 @@ > except NotImplementedError: > pass > > +class Win32ErrorTests(unittest.TestCase): > + def test_rename(self): > + self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") > + > + def test_remove(self): > + self.assertRaises(WindowsError, os.remove, test_support.TESTFN) > + > + def test_chdir(self): > + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) > + > +if sys.platform != 'win32': > + class Win32ErrorTests(unittest.TestCase): > + pass > + > def test_main(): > test_support.run_unittest( > TemporaryFileTests, > @@ -372,7 +387,8 @@ > WalkTests, > MakedirTests, > DevNullTests, > - URandomTests > + URandomTests, > + Win32ErrorTests > ) > > if __name__ == "__main__": > > Modified: python/trunk/Lib/test/test_shutil.py > ============================================================================== > --- python/trunk/Lib/test/test_shutil.py (original) > +++ python/trunk/Lib/test/test_shutil.py Thu May 4 12:08:42 2006 > @@ -48,12 +48,12 @@ > if self.errorState == 0: > self.assertEqual(func, os.remove) > self.assertEqual(arg, self.childpath) > - self.assertEqual(exc[0], OSError) > + self.failUnless(issubclass(exc[0], OSError)) > self.errorState = 1 > else: > self.assertEqual(func, os.rmdir) > self.assertEqual(arg, TESTFN) > - self.assertEqual(exc[0], OSError) > + self.failUnless(issubclass(exc[0], OSError)) > self.errorState = 2 > > def test_rmtree_dont_delete_file(self): > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Thu May 4 12:08:42 2006 > @@ -67,6 +67,9 @@ > Extension Modules > ----------------- > > +- Use Win32 API to implement os.{chdir,rename,rmdir,remove}. As a result, > + these functions now raise WindowsError instead of OSError. > + > - Calling Tk_Init twice is refused if the first call failed as that > may deadlock. > > > Modified: python/trunk/Modules/posixmodule.c > ============================================================================== > --- python/trunk/Modules/posixmodule.c (original) > +++ python/trunk/Modules/posixmodule.c Thu May 4 12:08:42 2006 > @@ -458,21 +458,29 @@ > > static PyObject *_PyUnicode_FromFileSystemEncodedObject(register PyObject *obj) > { > - /* XXX Perhaps we should make this API an alias of > - PyObject_Unicode() instead ?! */ > - if (PyUnicode_CheckExact(obj)) { > - Py_INCREF(obj); > - return obj; > - } > - if (PyUnicode_Check(obj)) { > +} > + > +/* Function suitable for O& conversion */ > +static int > +convert_to_unicode(PyObject *arg, void* _param) > +{ > + PyObject **param = (PyObject**)_param; > + if (PyUnicode_CheckExact(arg)) { > + Py_INCREF(arg); > + *param = arg; > + } > + else if (PyUnicode_Check(arg)) { > /* For a Unicode subtype that's not a Unicode object, > return a true Unicode object with the same data. */ > - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj), > - PyUnicode_GET_SIZE(obj)); > + *param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(arg), > + PyUnicode_GET_SIZE(arg)); > + return *param != NULL; > } > - return PyUnicode_FromEncodedObject(obj, > - Py_FileSystemDefaultEncoding, > - "strict"); > + else > + *param = PyUnicode_FromEncodedObject(arg, > + Py_FileSystemDefaultEncoding, > + "strict"); > + return (*param) != NULL; > } > > #endif /* Py_WIN_WIDE_FILENAMES */ > @@ -589,35 +597,10 @@ > #endif > > static PyObject * > -posix_1str(PyObject *args, char *format, int (*func)(const char*), > - char *wformat, int (*wfunc)(const Py_UNICODE*)) > +posix_1str(PyObject *args, char *format, int (*func)(const char*)) > { > char *path1 = NULL; > int res; > -#ifdef Py_WIN_WIDE_FILENAMES > - if (unicode_file_names()) { > - PyUnicodeObject *po; > - if (PyArg_ParseTuple(args, wformat, &po)) { > - Py_BEGIN_ALLOW_THREADS > - /* PyUnicode_AS_UNICODE OK without thread > - lock as it is a simple dereference. */ > - res = (*wfunc)(PyUnicode_AS_UNICODE(po)); > - Py_END_ALLOW_THREADS > - if (res < 0) > - return posix_error_with_unicode_filename(PyUnicode_AS_UNICODE(po)); > - Py_INCREF(Py_None); > - return Py_None; > - } > - /* Drop the argument parsing error as narrow > - strings are also valid. */ > - PyErr_Clear(); > - } > -#else > - /* Platforms that don't support Unicode filenames > - shouldn't be passing these extra params */ > - assert(wformat==NULL && wfunc == NULL); > -#endif > - > if (!PyArg_ParseTuple(args, format, > Py_FileSystemDefaultEncoding, &path1)) > return NULL; > @@ -634,52 +617,10 @@ > static PyObject * > posix_2str(PyObject *args, > char *format, > - int (*func)(const char *, const char *), > - char *wformat, > - int (*wfunc)(const Py_UNICODE *, const Py_UNICODE *)) > + int (*func)(const char *, const char *)) > { > char *path1 = NULL, *path2 = NULL; > int res; > -#ifdef Py_WIN_WIDE_FILENAMES > - if (unicode_file_names()) { > - PyObject *po1; > - PyObject *po2; > - if (PyArg_ParseTuple(args, wformat, &po1, &po2)) { > - if (PyUnicode_Check(po1) || PyUnicode_Check(po2)) { > - PyObject *wpath1; > - PyObject *wpath2; > - wpath1 = _PyUnicode_FromFileSystemEncodedObject(po1); > - wpath2 = _PyUnicode_FromFileSystemEncodedObject(po2); > - if (!wpath1 || !wpath2) { > - Py_XDECREF(wpath1); > - Py_XDECREF(wpath2); > - return NULL; > - } > - Py_BEGIN_ALLOW_THREADS > - /* PyUnicode_AS_UNICODE OK without thread > - lock as it is a simple dereference. */ > - res = (*wfunc)(PyUnicode_AS_UNICODE(wpath1), > - PyUnicode_AS_UNICODE(wpath2)); > - Py_END_ALLOW_THREADS > - Py_XDECREF(wpath1); > - Py_XDECREF(wpath2); > - if (res != 0) > - return posix_error(); > - Py_INCREF(Py_None); > - return Py_None; > - } > - /* Else flow through as neither is Unicode. */ > - } > - /* Drop the argument parsing error as narrow > - strings are also valid. */ > - PyErr_Clear(); > - } > -#else > - /* Platforms that don't support Unicode filenames > - shouldn't be passing these extra params */ > - assert(wformat==NULL && wfunc == NULL); > -#endif > - > if (!PyArg_ParseTuple(args, format, > Py_FileSystemDefaultEncoding, &path1, > Py_FileSystemDefaultEncoding, &path2)) > @@ -696,6 +637,101 @@ > return Py_None; > } > > +#ifdef Py_WIN_WIDE_FILENAMES > +static PyObject* > +win32_1str(PyObject* args, char* func, > + char* format, BOOL (__stdcall *funcA)(LPCSTR), > + char* wformat, BOOL (__stdcall *funcW)(LPWSTR)) > +{ > + PyObject *uni; > + char *ansi; > + BOOL result; > + if (unicode_file_names()) { > + if (!PyArg_ParseTuple(args, wformat, &uni)) > + PyErr_Clear(); > + else { > + Py_BEGIN_ALLOW_THREADS > + result = funcW(PyUnicode_AsUnicode(uni)); > + Py_END_ALLOW_THREADS > + if (!result) > + return win32_error_unicode(func, PyUnicode_AsUnicode(uni)); > + Py_INCREF(Py_None); > + return Py_None; > + } > + } > + if (!PyArg_ParseTuple(args, format, &ansi)) > + return NULL; > + Py_BEGIN_ALLOW_THREADS > + result = funcA(ansi); > + Py_END_ALLOW_THREADS > + if (!result) > + return win32_error(func, ansi); > + Py_INCREF(Py_None); > + return Py_None; > + > +} > + > +/* This is a reimplementation of the C library's chdir function, > + but one that produces Win32 errors instead of DOS error codes. > + chdir is essentially a wrapper around SetCurrentDirectory; however, > + it also needs to set "magic" environment variables indicating > + the per-drive current directory, which are of the form =: */ > +BOOL __stdcall > +win32_chdir(LPCSTR path) > +{ > + char new_path[MAX_PATH+1]; > + int result; > + char env[4] = "=x:"; > + > + if(!SetCurrentDirectoryA(path)) > + return FALSE; > + result = GetCurrentDirectoryA(MAX_PATH+1, new_path); > + if (!result) > + return FALSE; > + /* In the ANSI API, there should not be any paths longer > + than MAX_PATH. */ > + assert(result <= MAX_PATH+1); > + if (strncmp(new_path, "\\\\", 2) == 0 || > + strncmp(new_path, "//", 2) == 0) > + /* UNC path, nothing to do. */ > + return TRUE; > + env[1] = new_path[0]; > + return SetEnvironmentVariableA(env, new_path); > +} > + > +/* The Unicode version differs from the ANSI version > + since the current directory might exceed MAX_PATH characters */ > +BOOL __stdcall > +win32_wchdir(LPCWSTR path) > +{ > + wchar_t _new_path[MAX_PATH+1], *new_path = _new_path; > + int result; > + wchar_t env[4] = L"=x:"; > + > + if(!SetCurrentDirectoryW(path)) > + return FALSE; > + result = GetCurrentDirectoryW(MAX_PATH+1, new_path); > + if (!result) > + return FALSE; > + if (result > MAX_PATH+1) { > + new_path = malloc(result); > + if (!new_path) { > + SetLastError(ERROR_OUTOFMEMORY); > + return FALSE; > + } > + } > + if (wcsncmp(new_path, L"\\\\", 2) == 0 || > + wcsncmp(new_path, L"//", 2) == 0) > + /* UNC path, nothing to do. */ > + return TRUE; > + env[1] = new_path[0]; > + result = SetEnvironmentVariableW(env, new_path); > + if (new_path != _new_path) > + free(new_path); > + return result; > +} > +#endif > + > #ifdef MS_WINDOWS > /* The CRT of Windows has a number of flaws wrt. its stat() implementation: > - time stamps are restricted to second resolution > @@ -1410,14 +1446,13 @@ > posix_chdir(PyObject *self, PyObject *args) > { > #ifdef MS_WINDOWS > - return posix_1str(args, "et:chdir", chdir, "U:chdir", _wchdir); > + return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir); > #elif defined(PYOS_OS2) && defined(PYCC_GCC) > - return posix_1str(args, "et:chdir", _chdir2, NULL, NULL); > + return posix_1str(args, "et:chdir", _chdir2); > #elif defined(__VMS) > - return posix_1str(args, "et:chdir", (int (*)(const char *))chdir, > - NULL, NULL); > + return posix_1str(args, "et:chdir", (int (*)(const char *))chdir); > #else > - return posix_1str(args, "et:chdir", chdir, NULL, NULL); > + return posix_1str(args, "et:chdir", chdir); > #endif > } > > @@ -1485,7 +1520,7 @@ > static PyObject * > posix_chroot(PyObject *self, PyObject *args) > { > - return posix_1str(args, "et:chroot", chroot, NULL, NULL); > + return posix_1str(args, "et:chroot", chroot); > } > #endif > > @@ -2071,7 +2106,6 @@ > } > #endif /* HAVE_NICE */ > > - > PyDoc_STRVAR(posix_rename__doc__, > "rename(old, new)\n\n\ > Rename a file or directory."); > @@ -2080,7 +2114,36 @@ > posix_rename(PyObject *self, PyObject *args) > { > #ifdef MS_WINDOWS > - return posix_2str(args, "etet:rename", rename, "OO:rename", _wrename); > + PyObject *o1, *o2; > + char *p1, *p2; > + BOOL result; > + if (unicode_file_names()) { > + if (!PyArg_ParseTuple(args, "O&O&:rename", > + convert_to_unicode, &o1, > + convert_to_unicode, &o2)) > + PyErr_Clear(); > + else { > + Py_BEGIN_ALLOW_THREADS > + result = MoveFileW(PyUnicode_AsUnicode(o1), > + PyUnicode_AsUnicode(o2)); > + Py_END_ALLOW_THREADS > + Py_DECREF(o1); > + Py_DECREF(o2); > + if (!result) > + return win32_error("rename", NULL); > + Py_INCREF(Py_None); > + return Py_None; > + } > + } > + if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2)) > + return NULL; > + Py_BEGIN_ALLOW_THREADS > + result = MoveFileA(p1, p2); > + Py_END_ALLOW_THREADS > + if (!result) > + return win32_error("rename", NULL); > + Py_INCREF(Py_None); > + return Py_None; > #else > return posix_2str(args, "etet:rename", rename, NULL, NULL); > #endif > @@ -2095,9 +2158,9 @@ > posix_rmdir(PyObject *self, PyObject *args) > { > #ifdef MS_WINDOWS > - return posix_1str(args, "et:rmdir", rmdir, "U:rmdir", _wrmdir); > + return win32_1str(args, "rmdir", "s:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW); > #else > - return posix_1str(args, "et:rmdir", rmdir, NULL, NULL); > + return posix_1str(args, "et:rmdir", rmdir); > #endif > } > > @@ -2166,9 +2229,9 @@ > posix_unlink(PyObject *self, PyObject *args) > { > #ifdef MS_WINDOWS > - return posix_1str(args, "et:remove", unlink, "U:remove", _wunlink); > + return win32_1str(args, "remove", "s:remove", DeleteFileA, "U:remove", DeleteFileW); > #else > - return posix_1str(args, "et:remove", unlink, NULL, NULL); > + return posix_1str(args, "et:remove", unlink); > #endif > } > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Thu May 4 19:08:03 2006 From: python-checkins at python.org (richard.tew) Date: Thu, 4 May 2006 19:08:03 +0200 (CEST) Subject: [Python-checkins] r45902 - stackless/Python-2.4.3/dev/Stackless/module/taskletobject.c Message-ID: <20060504170803.E5B531E4002@bag.python.org> Author: richard.tew Date: Thu May 4 19:08:03 2006 New Revision: 45902 Modified: stackless/Python-2.4.3/dev/Stackless/module/taskletobject.c Log: There is a unpickling race condition. While it is rare, sometimes tasklets get their setstate call after the channel they are blocked on. If this happens and we do not account for it, they will be left in a broken state where they are on the channels chain, but have cleared their blocked flag. We will assume that the presence of a chain, can only mean that the chain is that of a channel, rather than that of the main tasklet/scheduler. And therefore they can leave their blocked flag in place because the channel would have set it. Modified: stackless/Python-2.4.3/dev/Stackless/module/taskletobject.c ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/module/taskletobject.c (original) +++ stackless/Python-2.4.3/dev/Stackless/module/taskletobject.c Thu May 4 19:08:03 2006 @@ -315,9 +315,28 @@ nframes = PyList_GET_SIZE(lis); TASKLET_SETVAL(t, tempval); + + /* There is a unpickling race condition. While it is rare, + * sometimes tasklets get their setstate call after the + * channel they are blocked on. If this happens and we + * do not account for it, they will be left in a broken + * state where they are on the channels chain, but have + * cleared their blocked flag. + * + * We will assume that the presence of a chain, can only + * mean that the chain is that of a channel, rather than + * that of the main tasklet/scheduler. And therefore + * they can leave their blocked flag in place because the + * channel would have set it. + */ + i = t->flags.blocked; *(int *)&t->flags = flags; - /* we cannot restore blocked, must be done by a channel */ - t->flags.blocked = 0; + if (t->next == NULL) { + t->flags.blocked = 0; + } else { + t->flags.blocked = i; + } + /* t->nesting_level = nesting_level; XXX how do we handle this? XXX to be done: pickle the cstate without a ref to the task. From martin at v.loewis.de Thu May 4 19:47:54 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 04 May 2006 19:47:54 +0200 Subject: [Python-checkins] r45898 - in python/trunk: Lib/test/test_os.py Lib/test/test_shutil.py Misc/NEWS Modules/posixmodule.c In-Reply-To: References: <20060504100844.5C1691E4007@bag.python.org> Message-ID: <445A3E4A.8060402@v.loewis.de> Guido van Rossum wrote: > I wonder if it's time to move the Win32 code out of posixmodule.c? It > seems the current mess of #ifdefs can't be very maintainable. I vaguely recall that we had considered that before, and rejected it, for some reason. Not sure what the reason was, but one might have been that there still is OS/2 code in there, also. Regards, Martin From guido at python.org Thu May 4 20:08:40 2006 From: guido at python.org (Guido van Rossum) Date: Thu, 4 May 2006 11:08:40 -0700 Subject: [Python-checkins] r45898 - in python/trunk: Lib/test/test_os.py Lib/test/test_shutil.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445A3E4A.8060402@v.loewis.de> References: <20060504100844.5C1691E4007@bag.python.org> <445A3E4A.8060402@v.loewis.de> Message-ID: Maybe it's time to look again? Perhaps a refactoring could be used so that there are multiple files -- code shared across all OS'es, and code specifically to one OS. On 5/4/06, "Martin v. L?wis" wrote: > Guido van Rossum wrote: > > I wonder if it's time to move the Win32 code out of posixmodule.c? It > > seems the current mess of #ifdefs can't be very maintainable. > > I vaguely recall that we had considered that before, and rejected it, > for some reason. Not sure what the reason was, but one might have been > that there still is OS/2 code in there, also. > > Regards, > Martin > -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Thu May 4 20:15:11 2006 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 4 May 2006 20:15:11 +0200 (CEST) Subject: [Python-checkins] r45903 - peps/trunk/pep-3100.txt Message-ID: <20060504181511.796DF1E401F@bag.python.org> Author: guido.van.rossum Date: Thu May 4 20:15:10 2006 New Revision: 45903 Modified: peps/trunk/pep-3100.txt Log: Third time trying to commit the new pronouncement about set literals. :-( Also mention removing __mod__ and __divmod__ from float. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Thu May 4 20:15:10 2006 @@ -104,12 +104,12 @@ and semantics is evil. * Attributes on functions of the form ``func_whatever`` will be renamed ``__whatever__`` [25]_ -* Set literals and comprehensions [27]_ - {/} means set(); {x} means set([x]); {x, y} means set([x, y]). +* Set literals and comprehensions [27]_ [28]_ + {x} means set([x]); {x, y} means set([x, y]). {F(x) for x in S if P(x)} means set(F(x) for x in S if P(x)). NB. {range(x)} means set([range(x)]), NOT set(range(x)). + There's no literal for an empty set; use set() (or {1}&{2} :-). There's no frozenset literal; they are too rarely needed. - The {/} part is still controversial. To be removed: @@ -117,6 +117,7 @@ * ``raise Exception, "message"``: use ``raise Exception("message")`` [14]_ * ```x```: use ``repr(x)`` [2]_ * The ``<>`` operator: use ``!=`` instead [3]_ +* The __mod__ and __divmod__ special methods on float. [29]_ * Unbound methods [7]_ * METH_OLDARGS, WITH_CYCLE_GC * __getslice__, __setslice__, __delslice__ [17]_ @@ -317,6 +318,12 @@ .. [27] python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-April/001286.html + [28] python-3000 email ("sets in P3K?") + http://mail.python.org/pipermail/python-3000/2006-May/001666.html + + [29] python-3000 email ("bug in modulus?") + http://mail.python.org/pipermail/python-3000/2006-May/001735.html + .. [#pep238] PEP 238 (Changing the Division Operator) http://www.python.org/dev/peps/pep-0238 From python-checkins at python.org Thu May 4 20:31:11 2006 From: python-checkins at python.org (richard.tew) Date: Thu, 4 May 2006 20:31:11 +0200 (CEST) Subject: [Python-checkins] r45904 - stackless/binaries-pc/python24.zip stackless/binaries-pc/python24.zip.md5.py Message-ID: <20060504183111.157E61E4002@bag.python.org> Author: richard.tew Date: Thu May 4 20:27:22 2006 New Revision: 45904 Added: stackless/binaries-pc/python24.zip (contents, props changed) stackless/binaries-pc/python24.zip.md5.py Log: Zip archive based install of Python 2.4.3, includes all the bits and pieces needed to just extract over your Python installation directory. e.g. I extracted it into my Python 2.4.3 installation in 'C:\Program Files\Python243'. Added: stackless/binaries-pc/python24.zip ============================================================================== Binary file. No diff available. Added: stackless/binaries-pc/python24.zip.md5.py ============================================================================== --- (empty file) +++ stackless/binaries-pc/python24.zip.md5.py Thu May 4 20:27:22 2006 @@ -0,0 +1,8 @@ + +import md5 +expected = "a25a5cc5bd1bec37dda1a542e9a52cec" +fname = r"python24.zip" +print "expected digest", expected +received = md5.md5(file(fname, "rb").read()).hexdigest() +print ("matched", "NOT MATCHED!!") [received != expected] +raw_input("press enter to continue") From nnorwitz at gmail.com Fri May 5 06:16:14 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 May 2006 21:16:14 -0700 Subject: [Python-checkins] r45900 - python/trunk/Lib/mailbox.py In-Reply-To: <20060504142752.9D7CC1E4002@bag.python.org> References: <20060504142752.9D7CC1E4002@bag.python.org> Message-ID: Two questions, 1) shouldn't the class be: class WindowsError(Exception): pass Does the ernno module exist on Windows and if so, do 2 and 183 exist in it? If not it might be easier to make your own local ENOTFOUND or whatever, then you wouldn't need comments. n -- On 5/4/06, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Thu May 4 16:27:52 2006 > New Revision: 45900 > > Modified: > python/trunk/Lib/mailbox.py > Log: > Update checks to consider Windows error numbers. > > Modified: python/trunk/Lib/mailbox.py > ============================================================================== > --- python/trunk/Lib/mailbox.py (original) > +++ python/trunk/Lib/mailbox.py Thu May 4 16:27:52 2006 > @@ -2,6 +2,7 @@ > > """Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.""" > > +import sys > import os > import time > import calendar > @@ -23,6 +24,11 @@ > 'BabylMessage', 'MMDFMessage', 'UnixMailbox', > 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ] > > +if sys.platform != 'win32': > + # Define WindowsError so that we can use it in an except statement > + # even on non-Windows systems > + class WindowsError: > + pass > > class Mailbox: > """A group of messages in a particular place.""" > @@ -262,10 +268,11 @@ > self.remove(key) > except KeyError: > pass > + except WindowsError, e: > + if e.errno != 2: # ERROR_FILE_NOT_FOUND > + raise > except OSError, e: > - if e.errno == errno.ENOENT: > - pass > - else: > + if e.errno != errno.ENOENT: > raise > > def __setitem__(self, key, message): > @@ -419,6 +426,12 @@ > path = os.path.join(self._path, 'tmp', uniq) > try: > os.stat(path) > + except WindowsError, e: > + if e.errno == 2: # ERROR_FILE_NOT_FOUND > + Maildir._count += 1 > + return open(path, 'wb+') > + else: > + raise > except OSError, e: > if e.errno == errno.ENOENT: > Maildir._count += 1 > @@ -566,6 +579,12 @@ > self._file.close() > try: > os.rename(new_file.name, self._path) > + except WindowsError, e: > + if e.errno == 183: # ERROR_ALREADY_EXISTS > + os.remove(self._path) > + os.rename(new_file.name, self._path) > + else: > + raise > except OSError, e: > if e.errno == errno.EEXIST: > os.remove(self._path) > @@ -1837,6 +1856,13 @@ > else: > os.rename(pre_lock.name, f.name + '.lock') > dotlock_done = True > + except WindowsError, e: > + if e.errno == 183: # ERROR_ALREADY_EXISTS > + os.remove(pre_lock.name) > + raise ExternalClashError('dot lock unavailable: %s' % > + f.name) > + else: > + raise > except OSError, e: > if e.errno == errno.EEXIST: > os.remove(pre_lock.name) > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From nnorwitz at gmail.com Fri May 5 06:17:43 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 May 2006 21:17:43 -0700 Subject: [Python-checkins] r45824 - python/trunk/Lib/inspect.py In-Reply-To: <20060430174227.455D91E400D@bag.python.org> References: <20060430174227.455D91E400D@bag.python.org> Message-ID: Can we get a test case for this? -- n On 4/30/06, georg.brandl wrote: > Author: georg.brandl > Date: Sun Apr 30 19:42:26 2006 > New Revision: 45824 > > Modified: > python/trunk/Lib/inspect.py > Log: > Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache. > > > > Modified: python/trunk/Lib/inspect.py > ============================================================================== > --- python/trunk/Lib/inspect.py (original) > +++ python/trunk/Lib/inspect.py Sun Apr 30 19:42:26 2006 > @@ -412,7 +412,11 @@ > in the file and the line number indexes a line in that list. An IOError > is raised if the source code cannot be retrieved.""" > file = getsourcefile(object) or getfile(object) > - lines = linecache.getlines(file, getmodule(object).__dict__) > + module = getmodule(object) > + if module: > + lines = linecache.getlines(file, module.__dict__) > + else: > + lines = linecache.getlines(file) > if not lines: > raise IOError('could not get source code') > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From nnorwitz at gmail.com Fri May 5 06:17:56 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 May 2006 21:17:56 -0700 Subject: [Python-checkins] r45895 - python/trunk/Lib/imputil.py In-Reply-To: <20060504050812.03A751E4006@bag.python.org> References: <20060504050812.03A751E4006@bag.python.org> Message-ID: Can we get a test case for this? -- n On 5/3/06, georg.brandl wrote: > Author: georg.brandl > Date: Thu May 4 07:08:10 2006 > New Revision: 45895 > > Modified: > python/trunk/Lib/imputil.py > Log: > Bug #1481530: allow "from os.path import ..." with imputil > > > Modified: python/trunk/Lib/imputil.py > ============================================================================== > --- python/trunk/Lib/imputil.py (original) > +++ python/trunk/Lib/imputil.py Thu May 4 07:08:10 2006 > @@ -131,9 +131,12 @@ > if importer: > return importer._finish_import(top_module, parts[1:], fromlist) > > - # Grrr, some people "import os.path" > + # Grrr, some people "import os.path" or do "from os.path import ..." > if len(parts) == 2 and hasattr(top_module, parts[1]): > - return top_module > + if fromlist: > + return getattr(top_module, parts[1]) > + else: > + return top_module > > # If the importer does not exist, then we have to bail. A missing > # importer means that something else imported the module, and we have > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From nnorwitz at gmail.com Fri May 5 06:18:49 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 May 2006 21:18:49 -0700 Subject: [Python-checkins] r45822 - python/trunk/Lib/inspect.py In-Reply-To: <20060430155926.ADE981E400D@bag.python.org> References: <20060430155926.ADE981E400D@bag.python.org> Message-ID: Can we get a test case for this? Docs should probably be updated with the limitation too. -- n On 4/30/06, phillip.eby wrote: > Author: phillip.eby > Date: Sun Apr 30 17:59:26 2006 > New Revision: 45822 > > Modified: > python/trunk/Lib/inspect.py > Log: > Fix infinite regress when inspecting or frames. > > > Modified: python/trunk/Lib/inspect.py > ============================================================================== > --- python/trunk/Lib/inspect.py (original) > +++ python/trunk/Lib/inspect.py Sun Apr 30 17:59:26 2006 > @@ -353,7 +353,13 @@ > if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: > # Looks like a binary file. We want to only return a text file. > return None > - if os.path.exists(filename) or hasattr(getmodule(object), '__loader__'): > + if os.path.exists(filename): > + return filename > + # Ugly but necessary - '' and '' mean that getmodule() > + # would infinitely recurse, because they're not real files nor loadable > + # Note that this means that writing a PEP 302 loader that uses '<' > + # at the start of a filename is now not a good idea. :( > + if filename[:1]!='<' and hasattr(getmodule(object), '__loader__'): > return filename > > def getabsfile(object): > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From g.brandl at gmx.net Fri May 5 06:46:19 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Fri, 05 May 2006 06:46:19 +0200 Subject: [Python-checkins] r45895 - python/trunk/Lib/imputil.py In-Reply-To: References: <20060504050812.03A751E4006@bag.python.org> Message-ID: Neal Norwitz wrote: > Can we get a test case for this? -- n > > On 5/3/06, georg.brandl wrote: >> Author: georg.brandl >> Date: Thu May 4 07:08:10 2006 >> New Revision: 45895 >> >> Modified: >> python/trunk/Lib/imputil.py >> Log: >> Bug #1481530: allow "from os.path import ..." with imputil As there is no test suite for imputil at all, I don't think so... Georg From python-checkins at python.org Fri May 5 06:49:34 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 5 May 2006 06:49:34 +0200 (CEST) Subject: [Python-checkins] r45906 - sandbox/trunk/sio/bench_cat.py sandbox/trunk/sio/bench_io.py Message-ID: <20060505044934.4468B1E4007@bag.python.org> Author: guido.van.rossum Date: Fri May 5 06:49:34 2006 New Revision: 45906 Added: sandbox/trunk/sio/bench_cat.py (contents, props changed) sandbox/trunk/sio/bench_io.py (contents, props changed) Log: Add some simple benchmarks. Added: sandbox/trunk/sio/bench_cat.py ============================================================================== --- (empty file) +++ sandbox/trunk/sio/bench_cat.py Fri May 5 06:49:34 2006 @@ -0,0 +1,20 @@ +import timeit + +for size in [10, 20, 50, 100, 200, 500, 1000]: + print "------ size = %d ------" % size + strings = [] + byteses = [] + for i in range(100000): + n = size + s = "x"*n + b = bytes(s) + strings.append(s) + byteses.append(b) + + timer = timeit.Timer("bbb = bytes()\nfor b in byteses: bbb += b", + "from __main__ import strings, byteses") + print "byteses %.3f" % min(timer.repeat(3, 10)) + + timer = timeit.Timer("sss = ''.join(strings)", + "from __main__ import strings, byteses") + print "strings %.3f" % min(timer.repeat(3, 10)) Added: sandbox/trunk/sio/bench_io.py ============================================================================== --- (empty file) +++ sandbox/trunk/sio/bench_io.py Fri May 5 06:49:34 2006 @@ -0,0 +1,74 @@ +"""A silly I/O benchmark.""" + +import io +import os +import time + +TFN = "@bench" # Test filename +N = 64*1024*1024 # Number of bytes to read/write + +def writer(): + buffer = bytes("X")*(8*1024) + bufsize = len(buffer) + file = io.open(TFN, "wb", bufsize=0) + try: + size = 0 + while size < N: + file.write(buffer) + size += bufsize + finally: + file.close() + assert os.path.getsize(TFN) == N + +def oldwriter(): + buffer = "X"*(8*1024) + bufsize = len(buffer) + file = open(TFN, "wb", bufsize) + try: + size = 0 + while size < N: + file.write(buffer) + size += bufsize + finally: + file.close() + assert os.path.getsize(TFN) == N + +def reader(): + buffer = bytes() + bufsize = 32*1024 + file = io.open(TFN, "rb", 32*1024) + try: + while len(buffer) < N: + buffer += file.read(bufsize) + finally: + file.close() + assert len(buffer) == os.path.getsize(TFN) == N + +def oldreader(): + bufsize = 32*1024 + f = open(TFN, "rb", 8*1024) + try: + buffer = "" + while len(buffer) < N: + buffer += f.read(bufsize) + finally: + f.close() + assert len(buffer) == os.path.getsize(TFN) == N + +def timeit(func): + t0, c0 = time.time(), time.clock() + func() + t1, c1 = time.time(), time.clock() + print "%s: %6.3f time, %6.3f clock" % (func.__name__, t1-t0, c1-c0) + +def main(): + for i in range(1): + timeit(writer) + timeit(reader) + os.remove(TFN) + timeit(oldwriter) + timeit(oldreader) + os.remove(TFN) + +if __name__ == "__main__": + main() From nnorwitz at gmail.com Fri May 5 06:49:59 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 4 May 2006 21:49:59 -0700 Subject: [Python-checkins] r45895 - python/trunk/Lib/imputil.py In-Reply-To: References: <20060504050812.03A751E4006@bag.python.org> Message-ID: On 5/4/06, Georg Brandl wrote: > Neal Norwitz wrote: > > Can we get a test case for this? -- n > > > > On 5/3/06, georg.brandl wrote: > > >> Bug #1481530: allow "from os.path import ..." with imputil > > As there is no test suite for imputil at all, I don't think so... You could start one even if it only tests this small change. It builds character and will put hair on your chest. :-) n From g.brandl at gmx.net Fri May 5 06:47:33 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Fri, 05 May 2006 06:47:33 +0200 Subject: [Python-checkins] r45824 - python/trunk/Lib/inspect.py In-Reply-To: References: <20060430174227.455D91E400D@bag.python.org> Message-ID: Neal Norwitz wrote: > Can we get a test case for this? -- n > > On 4/30/06, georg.brandl wrote: >> Author: georg.brandl >> Date: Sun Apr 30 19:42:26 2006 >> New Revision: 45824 >> >> Modified: >> python/trunk/Lib/inspect.py >> Log: >> Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache. A test case for the other problem fixed by PJE would cover this as well, I think. Georg From martin at v.loewis.de Fri May 5 07:18:32 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 05 May 2006 07:18:32 +0200 Subject: [Python-checkins] r45900 - python/trunk/Lib/mailbox.py In-Reply-To: References: <20060504142752.9D7CC1E4002@bag.python.org> Message-ID: <445AE028.6000605@v.loewis.de> Neal Norwitz wrote: > Two questions, 1) shouldn't the class be: > > class WindowsError(Exception): pass For correctness, no: actual exceptions will never be of that class, so the except clause will never match. While Python will enforce some day that the exceptions raised inherit from exception, it won't enforce that the exceptions caught inherit from exception - it only requires that the names are bound. So in principle, WindowsError = None would have worked as well. For clarity, it is certainly better to inherit from exception > Does the ernno module exist on Windows and if so, do 2 and 183 exist in it? It exists, but it (currently) doesn't define symbolic values for the winerror.h constants. Perhaps it should. > If not it might be easier to make your own local ENOTFOUND or whatever, > then you wouldn't need comments. I hesitate to define global things in a module if I don't mean them to be imported (so I feel guilt about defining WindowsError as well). Of course, _ERROR_FILE_NOT_FOUND would be harmless. Regards, Martin From python-checkins at python.org Fri May 5 09:27:46 2006 From: python-checkins at python.org (richard.tew) Date: Fri, 5 May 2006 09:27:46 +0200 (CEST) Subject: [Python-checkins] r45907 - stackless/Python-2.4.3/dev/Stackless/stackless_version.h Message-ID: <20060505072746.6AC6B1E401A@bag.python.org> Author: richard.tew Date: Fri May 5 09:27:45 2006 New Revision: 45907 Modified: stackless/Python-2.4.3/dev/Stackless/stackless_version.h Log: Updated Stackless version. Modified: stackless/Python-2.4.3/dev/Stackless/stackless_version.h ============================================================================== --- stackless/Python-2.4.3/dev/Stackless/stackless_version.h (original) +++ stackless/Python-2.4.3/dev/Stackless/stackless_version.h Fri May 5 09:27:45 2006 @@ -1,7 +1,7 @@ /* * Stackless Python version string - * created at Thu Sep 29 03:37:53 2005 by mkversion.py + * created at Thu May 04 18:28:57 2006 by mkversion.py */ /* keep this entry up-to-date */ -#define STACKLESS_VERSION "3.1b3 050929" +#define STACKLESS_VERSION "3.1b3 060504" From python-checkins at python.org Fri May 5 11:14:12 2006 From: python-checkins at python.org (richard.tew) Date: Fri, 5 May 2006 11:14:12 +0200 (CEST) Subject: [Python-checkins] r45908 - stackless/Python-2.4.3/dev/PCbuild/publish_binaries.py Message-ID: <20060505091412.6BC4C1E4007@bag.python.org> Author: richard.tew Date: Fri May 5 11:14:11 2006 New Revision: 45908 Modified: stackless/Python-2.4.3/dev/PCbuild/publish_binaries.py Log: Updated build publishing script. No longer packages the dynamic and static libraries in separate release and debug archives. Instead it packages them in one archive with the scripts that have custom Stackless modifications, in a directory structure that can be extracted over the top of an existing PYthon installation. Modified: stackless/Python-2.4.3/dev/PCbuild/publish_binaries.py ============================================================================== --- stackless/Python-2.4.3/dev/PCbuild/publish_binaries.py (original) +++ stackless/Python-2.4.3/dev/PCbuild/publish_binaries.py Fri May 5 11:14:11 2006 @@ -1,7 +1,7 @@ from zipfile import * import os, sys, md5 -exp_path = r"..\..\..\binaries-pc" +exp_path = r"..\..\binaries-pc" prog = """ import md5 @@ -13,25 +13,36 @@ raw_input("press enter to continue") """ -filenames = "python24 stackless _tkinter".split() -# no longer needed -filenames = "python24".split() +fileList = [ r"..\Lib\copy_reg.py", r"..\Lib\pickle.py" ] for debug in ("", "_d"): - zname = os.path.join(exp_path, "python24%s.dll.zip" % debug) - z = ZipFile(zname, "w", ZIP_DEFLATED) - for name in filenames: - name += debug - for ext in ".dll .exp .lib .pyd".split(): - export = name + ext - if os.path.exists(export): - z.write(export) - z.close() - expected = md5.md5(file(zname, "rb").read()).hexdigest() - signame = zname+".md5.py" - shortname = os.path.split(zname)[-1] - file(signame, "w").write(prog % (expected, shortname)) + for suffix in ("dll", "lib", "exp"): + fileList.append("python24%s.%s" % (debug, suffix)) + +pathBySuffix = { + "dll": "", + "lib": "libs/", + "exp": "libs/", + "py": "Lib/", +} + + +zname = os.path.join(exp_path, "python24.zip") +z = ZipFile(zname, "w", ZIP_DEFLATED) +for fileName in fileList: + if os.path.exists(fileName): + suffix = fileName[fileName.rfind(".")+1:] + s = open(fileName, "rb").read() + z.writestr(pathBySuffix[suffix] + os.path.basename(fileName), s) + else: + print "File not found:", fileName +z.close() + +signame = zname+".md5.py" +expected = md5.md5(file(zname, "rb").read()).hexdigest() +shortname = os.path.split(zname)[-1] +file(signame, "w").write(prog % (expected, shortname)) # generate a reST include for upload time. -import time -txt = ".. |uploaded| replace:: " + time.ctime() -print >> file(os.path.join(exp_path, "uploaded.txt"), "w"), txt +#import time +#txt = ".. |uploaded| replace:: " + time.ctime() +#print >> file(os.path.join(exp_path, "uploaded.txt"), "w"), txt From python-checkins at python.org Fri May 5 12:52:44 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 5 May 2006 12:52:44 +0200 (CEST) Subject: [Python-checkins] r45909 - in python/branches/release24-maint: Lib/test/test_pty.py Misc/ACKS Modules/fcntlmodule.c Message-ID: <20060505105244.9250A1E4008@bag.python.org> Author: thomas.wouters Date: Fri May 5 12:52:43 2006 New Revision: 45909 Modified: python/branches/release24-maint/Lib/test/test_pty.py python/branches/release24-maint/Misc/ACKS python/branches/release24-maint/Modules/fcntlmodule.c Log: Backport SF bug/patch #1433877: string parameter to ioctl not null terminated The new char-array used in ioctl calls wasn't explicitly NUL-terminated; quite probably the cause for the test_pty failures on Solaris that we circumvented earlier. Modified: python/branches/release24-maint/Lib/test/test_pty.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_pty.py (original) +++ python/branches/release24-maint/Lib/test/test_pty.py Fri May 5 12:52:43 2006 @@ -4,13 +4,6 @@ TEST_STRING_1 = "I wish to buy a fish license.\n" TEST_STRING_2 = "For my pet fish, Eric.\n" -# Solaris (at least 2.9 and 2.10) seem to have a fickle isatty(). The first -# test below, testing the result of os.openpty() for tty-ness, sometimes -# (but not always) fails. The second isatty test, in the sub-process, always -# works. Allow that fickle first test to fail on these platforms, since it -# doesn't actually affect functionality. -fickle_isatty = ["sunos5"] - if verbose: def debug(msg): print msg @@ -54,7 +47,7 @@ # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." - if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: + if not os.isatty(slave_fd): raise TestFailed, "slave_fd is not a tty" debug("Writing to slave_fd") Modified: python/branches/release24-maint/Misc/ACKS ============================================================================== --- python/branches/release24-maint/Misc/ACKS (original) +++ python/branches/release24-maint/Misc/ACKS Fri May 5 12:52:43 2006 @@ -33,6 +33,7 @@ Luigi Ballabio Michael J. Barber Chris Barker +Quentin Barnes Cesar Eduardo Barros Des Barry Ulf Bartelt Modified: python/branches/release24-maint/Modules/fcntlmodule.c ============================================================================== --- python/branches/release24-maint/Modules/fcntlmodule.c (original) +++ python/branches/release24-maint/Modules/fcntlmodule.c Fri May 5 12:52:43 2006 @@ -93,6 +93,7 @@ static PyObject * fcntl_ioctl(PyObject *self, PyObject *args) { +#define IOCTL_BUFSZ 1024 int fd; int code; int arg; @@ -100,7 +101,7 @@ char *str; int len; int mutate_arg = 0; - char buf[1024]; + char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */ if (PyArg_ParseTuple(args, "O&iw#|i:ioctl", conv_descriptor, &fd, &code, @@ -118,8 +119,9 @@ mutate_arg = 0; } if (mutate_arg) { - if (len <= sizeof buf) { + if (len <= IOCTL_BUFSZ) { memcpy(buf, str, len); + buf[len] = '\0'; arg = buf; } else { @@ -127,13 +129,14 @@ } } else { - if (len > sizeof buf) { + if (len > IOCTL_BUFSZ) { PyErr_SetString(PyExc_ValueError, "ioctl string arg too long"); return NULL; } else { memcpy(buf, str, len); + buf[len] = '\0'; arg = buf; } } @@ -145,7 +148,7 @@ else { ret = ioctl(fd, code, arg); } - if (mutate_arg && (len < sizeof buf)) { + if (mutate_arg && (len < IOCTL_BUFSZ)) { memcpy(str, buf, len); } if (ret < 0) { @@ -163,12 +166,13 @@ PyErr_Clear(); if (PyArg_ParseTuple(args, "O&is#:ioctl", conv_descriptor, &fd, &code, &str, &len)) { - if (len > sizeof buf) { + if (len > IOCTL_BUFSZ) { PyErr_SetString(PyExc_ValueError, "ioctl string arg too long"); return NULL; } memcpy(buf, str, len); + buf[len] = '\0'; Py_BEGIN_ALLOW_THREADS ret = ioctl(fd, code, buf); Py_END_ALLOW_THREADS @@ -199,6 +203,7 @@ return NULL; } return PyInt_FromLong((long)ret); +#undef IOCTL_BUFSZ } PyDoc_STRVAR(ioctl_doc, From buildbot at python.org Fri May 5 13:27:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 05 May 2006 11:27:02 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.4 Message-ID: <20060505112702.4546B1E4008@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%25202.4/builds/119 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: thomas.wouters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 5 14:26:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 05 May 2006 12:26:51 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060505122651.D9DEB1E400A@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/16 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: thomas.wouters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 5 19:50:06 2006 From: python-checkins at python.org (richard.tew) Date: Fri, 5 May 2006 19:50:06 +0200 (CEST) Subject: [Python-checkins] r45911 - stackless/Python-2.4.3/dev/Modules/Setup.config.in stackless/Python-2.4.3/dev/Modules/Setup.dist stackless/Python-2.4.3/dev/Modules/config.c.in stackless/Python-2.4.3/dev/Modules/makesetup Message-ID: <20060505175006.A7D761E400A@bag.python.org> Author: richard.tew Date: Fri May 5 19:50:05 2006 New Revision: 45911 Modified: stackless/Python-2.4.3/dev/Modules/Setup.config.in (contents, props changed) stackless/Python-2.4.3/dev/Modules/Setup.dist (contents, props changed) stackless/Python-2.4.3/dev/Modules/config.c.in (contents, props changed) stackless/Python-2.4.3/dev/Modules/makesetup (contents, props changed) Log: Fixed up the mime types (text/plain) and eol styles (native) so that compilation will work on unix os'. Modified: stackless/Python-2.4.3/dev/Modules/Setup.config.in ============================================================================== Binary files. No diff available. Modified: stackless/Python-2.4.3/dev/Modules/Setup.dist ============================================================================== --- stackless/Python-2.4.3/dev/Modules/Setup.dist (original) +++ stackless/Python-2.4.3/dev/Modules/Setup.dist Fri May 5 19:50:05 2006 @@ -1,488 +1,488 @@ -# -*- makefile -*- -# The file Setup is used by the makesetup script to construct the files -# Makefile and config.c, from Makefile.pre and config.c.in, -# respectively. The file Setup itself is initially copied from -# Setup.dist; once it exists it will not be overwritten, so you can edit -# Setup to your heart's content. Note that Makefile.pre is created -# from Makefile.pre.in by the toplevel configure script. - -# (VPATH notes: Setup and Makefile.pre are in the build directory, as -# are Makefile and config.c; the *.in and *.dist files are in the source -# directory.) - -# Each line in this file describes one or more optional modules. -# Modules enabled here will not be compiled by the setup.py script, -# so the file can be used to override setup.py's behavior. - -# Lines have the following structure: -# -# ... [ ...] [ ...] [ ...] -# -# is anything ending in .c (.C, .cc, .c++ are C++ files) -# is anything starting with -I, -D, -U or -C -# is anything ending in .a or beginning with -l or -L -# is anything else but should be a valid Python -# identifier (letters, digits, underscores, beginning with non-digit) -# -# (As the makesetup script changes, it may recognize some other -# arguments as well, e.g. *.so and *.sl as libraries. See the big -# case statement in the makesetup script.) -# -# Lines can also have the form -# -# = -# -# which defines a Make variable definition inserted into Makefile.in -# -# Finally, if a line contains just the word "*shared*" (without the -# quotes but with the stars), then the following modules will not be -# built statically. The build process works like this: -# -# 1. Build all modules that are declared as static in Modules/Setup, -# combine them into libpythonxy.a, combine that into python. -# 2. Build all modules that are listed as shared in Modules/Setup. -# 3. Invoke setup.py. That builds all modules that -# a) are not builtin, and -# b) are not listed in Modules/Setup, and -# c) can be build on the target -# -# Therefore, modules declared to be shared will not be -# included in the config.c file, nor in the list of objects to be -# added to the library archive, and their linker options won't be -# added to the linker options. Rules to create their .o files and -# their shared libraries will still be added to the Makefile, and -# their names will be collected in the Make variable SHAREDMODS. This -# is used to build modules as shared libraries. (They can be -# installed using "make sharedinstall", which is implied by the -# toplevel "make install" target.) (For compatibility, -# *noconfig* has the same effect as *shared*.) -# -# In addition, *static* explicitly declares the following modules to -# be static. Lines containing "*static*" and "*shared*" may thus -# alternate thoughout this file. - -# NOTE: As a standard policy, as many modules as can be supported by a -# platform should be present. The distribution comes with all modules -# enabled that are supported by most platforms and don't require you -# to ftp sources from elsewhere. - - -# Some special rules to define PYTHONPATH. -# Edit the definitions below to indicate which options you are using. -# Don't add any whitespace or comments! - -# Directories where library files get installed. -# DESTLIB is for Python modules; MACHDESTLIB for shared libraries. -DESTLIB=$(LIBDEST) -MACHDESTLIB=$(BINLIBDEST) - -# NOTE: all the paths are now relative to the prefix that is computed -# at run time! - -# Standard path -- don't edit. -# No leading colon since this is the first entry. -# Empty since this is now just the runtime prefix. -DESTPATH= - -# Site specific path components -- should begin with : if non-empty -SITEPATH= - -# Standard path components for test modules -TESTPATH= - -# Path components for machine- or system-dependent modules and shared libraries -MACHDEPPATH=:plat-$(MACHDEP) -EXTRAMACHDEPPATH= - -# Path component for the Tkinter-related modules -# The TKPATH variable is always enabled, to save you the effort. -TKPATH=:lib-tk - -COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH) -PYTHONPATH=$(COREPYTHONPATH) - - -# The modules listed here can't be built as shared libraries for -# various reasons; therefore they are listed here instead of in the -# normal order. - -# This only contains the minimal set of modules required to run the -# setup.py script in the root of the Python source tree. - -posix posixmodule.c # posix (UNIX) system calls -errno errnomodule.c # posix (UNIX) errno values -pwd pwdmodule.c # this is needed to find out the user's home dir - # if $HOME is not set -_sre _sre.c # Fredrik Lundh's new regular expressions -_codecs _codecsmodule.c # access to the builtin codecs and codec registry - -# The zipimport module is always imported at startup. Having it as a -# builtin module avoids some bootstrapping problems and reduces overhead. -zipimport zipimport.c - -# The rest of the modules listed in this file are all commented out by -# default. Usually they can be detected and built as dynamically -# loaded modules by the new setup.py script added in Python 2.1. If -# you're on a platform that doesn't support dynamic loading, want to -# compile modules statically into the Python binary, or need to -# specify some odd set of compiler switches, you can uncomment the -# appropriate lines below. - -# ====================================================================== - -# The Python symtable module depends on .h files that setup.py doesn't track -_symtable symtablemodule.c - -# The SGI specific GL module: - -GLHACK=-Dclear=__GLclear -#gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 - -# Pure module. Cannot be linked dynamically. -# -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE -#WHICH_PURE_PRODUCTS=-DWITH_ALL_PURE -#PURE_INCLS=-I/usr/local/include -#PURE_STUBLIBS=-L/usr/local/lib -lpurify_stubs -lquantify_stubs -#pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS) $(PURE_STUBLIBS) - -# Uncommenting the following line tells makesetup that all following -# modules are to be built as shared libraries (see above for more -# detail; also note that *static* reverses this effect): - -#*shared* - -# GNU readline. Unlike previous Python incarnations, GNU readline is -# now incorporated in an optional module, configured in the Setup file -# instead of by a configure script switch. You may have to insert a -# -L option pointing to the directory where libreadline.* lives, -# and you may have to change -ltermcap to -ltermlib or perhaps remove -# it, depending on your system -- see the GNU readline instructions. -# It's okay for this to be a shared library, too. - -#readline readline.c -lreadline -ltermcap - - -# Modules that should always be present (non UNIX dependent): - -#array arraymodule.c # array objects -#cmath cmathmodule.c # -lm # complex math library functions -#math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking -#time timemodule.c # -lm # time operations and variables -#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 - -# access to ISO C locale support -#_locale _localemodule.c # -lintl - - -# Modules with some UNIX dependencies -- on by default: -# (If you have a really backward UNIX, select and socket may not be -# supported...) - -#fcntl fcntlmodule.c # fcntl(2) and ioctl(2) -#grp grpmodule.c # grp(3) -#select selectmodule.c # select(2); not on ancient System V - -# Memory-mapped files (also works on Win32). -#mmap mmapmodule.c - -# CSV file helper -#_csv _csv.c - -# Socket module helper for socket(2) -#_socket socketmodule.c - -# Socket module helper for SSL support; you must comment out the other -# socket line above, and possibly edit the SSL variable: -#SSL=/usr/local/ssl -#_ssl _ssl.c \ -# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -# -L$(SSL)/lib -lssl -lcrypto - -# The crypt module is now disabled by default because it breaks builds -# on many systems (where -lcrypt is needed), e.g. Linux (I believe). -# -# First, look at Setup.config; configure may have set this for you. - -#crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems - - -# Some more UNIX dependent modules -- off by default, since these -# are not supported by all UNIX systems: - -#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere -#termios termios.c # Steen Lumholt's termios module -#resource resource.c # Jeremy Hylton's rlimit interface - - -# Multimedia modules -- off by default. -# These don't work for 64-bit platforms!!! -# #993173 says audioop works on 64-bit platforms, though. -# These represent audio samples or images as strings: - -#audioop audioop.c # Operations on audio samples -#imageop imageop.c # Operations on images -#rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) - - -# The md5 module implements the RSA Data Security, Inc. MD5 -# Message-Digest Algorithm, described in RFC 1321. The necessary files -# md5c.c and md5.h are included here. - -#md5 md5module.c md5c.c - - -# The sha module implements the SHA checksum algorithm. -# (NIST's Secure Hash Algorithm.) -#sha shamodule.c - - -# SGI IRIX specific modules -- off by default. - -# These module work on any SGI machine: - -# *** gl must be enabled higher up in this file *** -#fm fmmodule.c $(GLHACK) -lfm -lgl # Font Manager -#sgi sgimodule.c # sgi.nap() and a few more - -# This module requires the header file -# /usr/people/4Dgifts/iristools/include/izoom.h: -#imgfile imgfile.c -limage -lgutil -lgl -lm # Image Processing Utilities - - -# These modules require the Multimedia Development Option (I think): - -#al almodule.c -laudio # Audio Library -#cd cdmodule.c -lcdaudio -lds -lmediad # CD Audio Library -#cl clmodule.c -lcl -lawareaudio # Compression Library -#sv svmodule.c yuvconvert.c -lsvideo -lXext -lX11 # Starter Video - - -# The FORMS library, by Mark Overmars, implements user interface -# components such as dialogs and buttons using SGI's GL and FM -# libraries. You must ftp the FORMS library separately from -# ftp://ftp.cs.ruu.nl/pub/SGI/FORMS. It was tested with FORMS 2.2a. -# NOTE: if you want to be able to use FORMS and curses simultaneously -# (or both link them statically into the same binary), you must -# compile all of FORMS with the cc option "-Dclear=__GLclear". - -# The FORMS variable must point to the FORMS subdirectory of the forms -# toplevel directory: - -#FORMS=/ufs/guido/src/forms/FORMS -#fl flmodule.c -I$(FORMS) $(GLHACK) $(FORMS)/libforms.a -lfm -lgl - - -# SunOS specific modules -- off by default: - -#sunaudiodev sunaudiodev.c - - -# A Linux specific module -- off by default; this may also work on -# some *BSDs. - -#linuxaudiodev linuxaudiodev.c - - -# George Neville-Neil's timing module: - -#timing timingmodule.c - - -# The _tkinter module. -# -# The command for _tkinter is long and site specific. Please -# uncomment and/or edit those parts as indicated. If you don't have a -# specific extension (e.g. Tix or BLT), leave the corresponding line -# commented out. (Leave the trailing backslashes in! If you -# experience strange errors, you may want to join all uncommented -# lines and remove the backslashes -- the backslash interpretation is -# done by the shell's "read" command and it may not be implemented on -# every system. - -# *** Always uncomment this (leave the leading underscore in!): -# _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -# *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -# -L/usr/local/lib \ -# *** Uncomment and edit to reflect where your Tcl/Tk headers are: -# -I/usr/local/include \ -# *** Uncomment and edit to reflect where your X11 header files are: -# -I/usr/X11R6/include \ -# *** Or uncomment this for Solaris: -# -I/usr/openwin/include \ -# *** Uncomment and edit for Tix extension only: -# -DWITH_TIX -ltix8.1.8.2 \ -# *** Uncomment and edit for BLT extension only: -# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ -# *** Uncomment and edit for PIL (TkImaging) extension only: -# (See http://www.pythonware.com/products/pil/ for more info) -# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ -# *** Uncomment and edit for TOGL extension only: -# -DWITH_TOGL togl.c \ -# *** Uncomment and edit to reflect your Tcl/Tk versions: -# -ltk8.2 -ltcl8.2 \ -# *** Uncomment and edit to reflect where your X11 libraries are: -# -L/usr/X11R6/lib \ -# *** Or uncomment this for Solaris: -# -L/usr/openwin/lib \ -# *** Uncomment these for TOGL extension only: -# -lGL -lGLU -lXext -lXmu \ -# *** Uncomment for AIX: -# -lld \ -# *** Always uncomment this; X11 libraries to link with: -# -lX11 - -# Lance Ellinghaus's syslog module -#syslog syslogmodule.c # syslog daemon interface - - -# Curses support, requring the System V version of curses, often -# provided by the ncurses library. e.g. on Linux, link with -lncurses -# instead of -lcurses). -# -# First, look at Setup.config; configure may have set this for you. - -#_curses _cursesmodule.c -lcurses -ltermcap -# Wrapper for the panel library that's part of ncurses and SYSV curses. -#_curses_panel _curses_panel.c -lpanel -lncurses - - -# Generic (SunOS / SVR4) dynamic loading module. -# This is not needed for dynamic loading of Python modules -- -# it is a highly experimental and dangerous device for calling -# *arbitrary* C functions in *arbitrary* shared libraries: - -#dl dlmodule.c - - -# Modules that provide persistent dictionary-like semantics. You will -# probably want to arrange for at least one of them to be available on -# your machine, though none are defined by default because of library -# dependencies. The Python module anydbm.py provides an -# implementation independent wrapper for these; dumbdbm.py provides -# similar functionality (but slower of course) implemented in Python. - -# The standard Unix dbm module has been moved to Setup.config so that -# it will be compiled as a shared library by default. Compiling it as -# a built-in module causes conflicts with the pybsddb3 module since it -# creates a static dependency on an out-of-date version of db.so. -# -# First, look at Setup.config; configure may have set this for you. - -#dbm dbmmodule.c # dbm(3) may require -lndbm or similar - -# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: -# -# First, look at Setup.config; configure may have set this for you. - -#gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm - - -# Sleepycat Berkeley DB interface. -# -# This requires the Sleepycat DB code, see http://www.sleepycat.com/ -# The earliest supported version of that library is 3.0, the latest -# supported version is 4.0 (4.1 is specifically not supported, as that -# changes the semantics of transactional databases). A list of available -# releases can be found at -# -# http://www.sleepycat.com/update/index.html -# -# Edit the variables DB and DBLIBVERto point to the db top directory -# and the subdirectory of PORT where you built it. -#DB=/usr/local/BerkeleyDB.4.0 -#DBLIBVER=4.0 -#DBINC=$(DB)/include -#DBLIB=$(DB)/lib -#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) - -# Historical Berkeley DB 1.85 -# -# This module is deprecated; the 1.85 version of the Berkeley DB library has -# bugs that can cause data corruption. If you can, use later versions of the -# library instead, available from . - -#DB=/depot/sundry/src/berkeley-db/db.1.85 -#DBPORT=$(DB)/PORT/irix.5.3 -#bsddb185 bsddbmodule.c -I$(DBPORT)/include -I$(DBPORT) $(DBPORT)/libdb.a - - - -# Helper module for various ascii-encoders -#binascii binascii.c - -# Fred Drake's interface to the Python parser -#parser parsermodule.c - -# cStringIO and cPickle -#cStringIO cStringIO.c -#cPickle cPickle.c - - -# Lee Busby's SIGFPE modules. -# The library to link fpectl with is platform specific. -# Choose *one* of the options below for fpectl: - -# For SGI IRIX (tested on 5.3): -#fpectl fpectlmodule.c -lfpe - -# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): -# (Without the compiler you don't have -lsunmath.) -#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm - -# For other systems: see instructions in fpectlmodule.c. -#fpectl fpectlmodule.c ... - -# Test module for fpectl. No extra libraries needed. -#fpetest fpetestmodule.c - -# Andrew Kuchling's zlib module. -# This require zlib 1.1.3 (or later). -# See http://www.gzip.org/zlib/ -#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz - -# Interface to the Expat XML parser -# -# Expat was written by James Clark and is now maintained by a group of -# developers on SourceForge; see www.libexpat.org for more -# information. The pyexpat module was written by Paul Prescod after a -# prototype by Jack Jansen. Source of Expat 1.95.2 is included in -# Modules/expat/. Usage of a system shared libexpat.so/expat.dll is -# not advised. -# -# More information on Expat can be found at www.libexpat.org. -# -#EXPAT_DIR=/usr/local/src/expat-1.95.2 -#pyexpat pyexpat.c -DHAVE_EXPAT_H -I$(EXPAT_DIR)/lib -L$(EXPAT_DIR) -lexpat - - -# Hye-Shik Chang's CJKCodecs - -# multibytecodec is required for all the other CJK codec modules -#_multibytecodec cjkcodecs/multibytecodec.c - -#_codecs_cn cjkcodecs/_codecs_cn.c -#_codecs_hk cjkcodecs/_codecs_hk.c -#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c -#_codecs_jp cjkcodecs/_codecs_jp.c -#_codecs_kr cjkcodecs/_codecs_kr.c -#_codecs_tw cjkcodecs/_codecs_tw.c - -# Example -- included for reference only: -# xx xxmodule.c - -# Another example -- the 'xxsubtype' module shows C-level subtyping in action -xxsubtype xxsubtype.c - -# uncomment if you'd like to compile stackless statically. -# Note that the static build puts the .o files into Modules. -#SLP=./Stackless -#stackless $(SLP)/stacklessmodule.c $(SLP)/atomicobject.c $(SLP)/cframeobject.c $(SLP)/channelobject.c $(SLP)/flextype.c $(SLP)/scheduling.c $(SLP)/schedulerobject.c $(SLP)/stackless_debug.c $(SLP)/stackless_util.c $(SLP)/taskletobject.c +# -*- makefile -*- +# The file Setup is used by the makesetup script to construct the files +# Makefile and config.c, from Makefile.pre and config.c.in, +# respectively. The file Setup itself is initially copied from +# Setup.dist; once it exists it will not be overwritten, so you can edit +# Setup to your heart's content. Note that Makefile.pre is created +# from Makefile.pre.in by the toplevel configure script. + +# (VPATH notes: Setup and Makefile.pre are in the build directory, as +# are Makefile and config.c; the *.in and *.dist files are in the source +# directory.) + +# Each line in this file describes one or more optional modules. +# Modules enabled here will not be compiled by the setup.py script, +# so the file can be used to override setup.py's behavior. + +# Lines have the following structure: +# +# ... [ ...] [ ...] [ ...] +# +# is anything ending in .c (.C, .cc, .c++ are C++ files) +# is anything starting with -I, -D, -U or -C +# is anything ending in .a or beginning with -l or -L +# is anything else but should be a valid Python +# identifier (letters, digits, underscores, beginning with non-digit) +# +# (As the makesetup script changes, it may recognize some other +# arguments as well, e.g. *.so and *.sl as libraries. See the big +# case statement in the makesetup script.) +# +# Lines can also have the form +# +# = +# +# which defines a Make variable definition inserted into Makefile.in +# +# Finally, if a line contains just the word "*shared*" (without the +# quotes but with the stars), then the following modules will not be +# built statically. The build process works like this: +# +# 1. Build all modules that are declared as static in Modules/Setup, +# combine them into libpythonxy.a, combine that into python. +# 2. Build all modules that are listed as shared in Modules/Setup. +# 3. Invoke setup.py. That builds all modules that +# a) are not builtin, and +# b) are not listed in Modules/Setup, and +# c) can be build on the target +# +# Therefore, modules declared to be shared will not be +# included in the config.c file, nor in the list of objects to be +# added to the library archive, and their linker options won't be +# added to the linker options. Rules to create their .o files and +# their shared libraries will still be added to the Makefile, and +# their names will be collected in the Make variable SHAREDMODS. This +# is used to build modules as shared libraries. (They can be +# installed using "make sharedinstall", which is implied by the +# toplevel "make install" target.) (For compatibility, +# *noconfig* has the same effect as *shared*.) +# +# In addition, *static* explicitly declares the following modules to +# be static. Lines containing "*static*" and "*shared*" may thus +# alternate thoughout this file. + +# NOTE: As a standard policy, as many modules as can be supported by a +# platform should be present. The distribution comes with all modules +# enabled that are supported by most platforms and don't require you +# to ftp sources from elsewhere. + + +# Some special rules to define PYTHONPATH. +# Edit the definitions below to indicate which options you are using. +# Don't add any whitespace or comments! + +# Directories where library files get installed. +# DESTLIB is for Python modules; MACHDESTLIB for shared libraries. +DESTLIB=$(LIBDEST) +MACHDESTLIB=$(BINLIBDEST) + +# NOTE: all the paths are now relative to the prefix that is computed +# at run time! + +# Standard path -- don't edit. +# No leading colon since this is the first entry. +# Empty since this is now just the runtime prefix. +DESTPATH= + +# Site specific path components -- should begin with : if non-empty +SITEPATH= + +# Standard path components for test modules +TESTPATH= + +# Path components for machine- or system-dependent modules and shared libraries +MACHDEPPATH=:plat-$(MACHDEP) +EXTRAMACHDEPPATH= + +# Path component for the Tkinter-related modules +# The TKPATH variable is always enabled, to save you the effort. +TKPATH=:lib-tk + +COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH) +PYTHONPATH=$(COREPYTHONPATH) + + +# The modules listed here can't be built as shared libraries for +# various reasons; therefore they are listed here instead of in the +# normal order. + +# This only contains the minimal set of modules required to run the +# setup.py script in the root of the Python source tree. + +posix posixmodule.c # posix (UNIX) system calls +errno errnomodule.c # posix (UNIX) errno values +pwd pwdmodule.c # this is needed to find out the user's home dir + # if $HOME is not set +_sre _sre.c # Fredrik Lundh's new regular expressions +_codecs _codecsmodule.c # access to the builtin codecs and codec registry + +# The zipimport module is always imported at startup. Having it as a +# builtin module avoids some bootstrapping problems and reduces overhead. +zipimport zipimport.c + +# The rest of the modules listed in this file are all commented out by +# default. Usually they can be detected and built as dynamically +# loaded modules by the new setup.py script added in Python 2.1. If +# you're on a platform that doesn't support dynamic loading, want to +# compile modules statically into the Python binary, or need to +# specify some odd set of compiler switches, you can uncomment the +# appropriate lines below. + +# ====================================================================== + +# The Python symtable module depends on .h files that setup.py doesn't track +_symtable symtablemodule.c + +# The SGI specific GL module: + +GLHACK=-Dclear=__GLclear +#gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 + +# Pure module. Cannot be linked dynamically. +# -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE +#WHICH_PURE_PRODUCTS=-DWITH_ALL_PURE +#PURE_INCLS=-I/usr/local/include +#PURE_STUBLIBS=-L/usr/local/lib -lpurify_stubs -lquantify_stubs +#pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS) $(PURE_STUBLIBS) + +# Uncommenting the following line tells makesetup that all following +# modules are to be built as shared libraries (see above for more +# detail; also note that *static* reverses this effect): + +#*shared* + +# GNU readline. Unlike previous Python incarnations, GNU readline is +# now incorporated in an optional module, configured in the Setup file +# instead of by a configure script switch. You may have to insert a +# -L option pointing to the directory where libreadline.* lives, +# and you may have to change -ltermcap to -ltermlib or perhaps remove +# it, depending on your system -- see the GNU readline instructions. +# It's okay for this to be a shared library, too. + +#readline readline.c -lreadline -ltermcap + + +# Modules that should always be present (non UNIX dependent): + +#array arraymodule.c # array objects +#cmath cmathmodule.c # -lm # complex math library functions +#math mathmodule.c # -lm # math library functions, e.g. sin() +#struct structmodule.c # binary structure packing/unpacking +#time timemodule.c # -lm # time operations and variables +#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 + +# access to ISO C locale support +#_locale _localemodule.c # -lintl + + +# Modules with some UNIX dependencies -- on by default: +# (If you have a really backward UNIX, select and socket may not be +# supported...) + +#fcntl fcntlmodule.c # fcntl(2) and ioctl(2) +#grp grpmodule.c # grp(3) +#select selectmodule.c # select(2); not on ancient System V + +# Memory-mapped files (also works on Win32). +#mmap mmapmodule.c + +# CSV file helper +#_csv _csv.c + +# Socket module helper for socket(2) +#_socket socketmodule.c + +# Socket module helper for SSL support; you must comment out the other +# socket line above, and possibly edit the SSL variable: +#SSL=/usr/local/ssl +#_ssl _ssl.c \ +# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ +# -L$(SSL)/lib -lssl -lcrypto + +# The crypt module is now disabled by default because it breaks builds +# on many systems (where -lcrypt is needed), e.g. Linux (I believe). +# +# First, look at Setup.config; configure may have set this for you. + +#crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems + + +# Some more UNIX dependent modules -- off by default, since these +# are not supported by all UNIX systems: + +#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere +#termios termios.c # Steen Lumholt's termios module +#resource resource.c # Jeremy Hylton's rlimit interface + + +# Multimedia modules -- off by default. +# These don't work for 64-bit platforms!!! +# #993173 says audioop works on 64-bit platforms, though. +# These represent audio samples or images as strings: + +#audioop audioop.c # Operations on audio samples +#imageop imageop.c # Operations on images +#rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) + + +# The md5 module implements the RSA Data Security, Inc. MD5 +# Message-Digest Algorithm, described in RFC 1321. The necessary files +# md5c.c and md5.h are included here. + +#md5 md5module.c md5c.c + + +# The sha module implements the SHA checksum algorithm. +# (NIST's Secure Hash Algorithm.) +#sha shamodule.c + + +# SGI IRIX specific modules -- off by default. + +# These module work on any SGI machine: + +# *** gl must be enabled higher up in this file *** +#fm fmmodule.c $(GLHACK) -lfm -lgl # Font Manager +#sgi sgimodule.c # sgi.nap() and a few more + +# This module requires the header file +# /usr/people/4Dgifts/iristools/include/izoom.h: +#imgfile imgfile.c -limage -lgutil -lgl -lm # Image Processing Utilities + + +# These modules require the Multimedia Development Option (I think): + +#al almodule.c -laudio # Audio Library +#cd cdmodule.c -lcdaudio -lds -lmediad # CD Audio Library +#cl clmodule.c -lcl -lawareaudio # Compression Library +#sv svmodule.c yuvconvert.c -lsvideo -lXext -lX11 # Starter Video + + +# The FORMS library, by Mark Overmars, implements user interface +# components such as dialogs and buttons using SGI's GL and FM +# libraries. You must ftp the FORMS library separately from +# ftp://ftp.cs.ruu.nl/pub/SGI/FORMS. It was tested with FORMS 2.2a. +# NOTE: if you want to be able to use FORMS and curses simultaneously +# (or both link them statically into the same binary), you must +# compile all of FORMS with the cc option "-Dclear=__GLclear". + +# The FORMS variable must point to the FORMS subdirectory of the forms +# toplevel directory: + +#FORMS=/ufs/guido/src/forms/FORMS +#fl flmodule.c -I$(FORMS) $(GLHACK) $(FORMS)/libforms.a -lfm -lgl + + +# SunOS specific modules -- off by default: + +#sunaudiodev sunaudiodev.c + + +# A Linux specific module -- off by default; this may also work on +# some *BSDs. + +#linuxaudiodev linuxaudiodev.c + + +# George Neville-Neil's timing module: + +#timing timingmodule.c + + +# The _tkinter module. +# +# The command for _tkinter is long and site specific. Please +# uncomment and/or edit those parts as indicated. If you don't have a +# specific extension (e.g. Tix or BLT), leave the corresponding line +# commented out. (Leave the trailing backslashes in! If you +# experience strange errors, you may want to join all uncommented +# lines and remove the backslashes -- the backslash interpretation is +# done by the shell's "read" command and it may not be implemented on +# every system. + +# *** Always uncomment this (leave the leading underscore in!): +# _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ +# *** Uncomment and edit to reflect where your Tcl/Tk libraries are: +# -L/usr/local/lib \ +# *** Uncomment and edit to reflect where your Tcl/Tk headers are: +# -I/usr/local/include \ +# *** Uncomment and edit to reflect where your X11 header files are: +# -I/usr/X11R6/include \ +# *** Or uncomment this for Solaris: +# -I/usr/openwin/include \ +# *** Uncomment and edit for Tix extension only: +# -DWITH_TIX -ltix8.1.8.2 \ +# *** Uncomment and edit for BLT extension only: +# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ +# *** Uncomment and edit for PIL (TkImaging) extension only: +# (See http://www.pythonware.com/products/pil/ for more info) +# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ +# *** Uncomment and edit for TOGL extension only: +# -DWITH_TOGL togl.c \ +# *** Uncomment and edit to reflect your Tcl/Tk versions: +# -ltk8.2 -ltcl8.2 \ +# *** Uncomment and edit to reflect where your X11 libraries are: +# -L/usr/X11R6/lib \ +# *** Or uncomment this for Solaris: +# -L/usr/openwin/lib \ +# *** Uncomment these for TOGL extension only: +# -lGL -lGLU -lXext -lXmu \ +# *** Uncomment for AIX: +# -lld \ +# *** Always uncomment this; X11 libraries to link with: +# -lX11 + +# Lance Ellinghaus's syslog module +#syslog syslogmodule.c # syslog daemon interface + + +# Curses support, requring the System V version of curses, often +# provided by the ncurses library. e.g. on Linux, link with -lncurses +# instead of -lcurses). +# +# First, look at Setup.config; configure may have set this for you. + +#_curses _cursesmodule.c -lcurses -ltermcap +# Wrapper for the panel library that's part of ncurses and SYSV curses. +#_curses_panel _curses_panel.c -lpanel -lncurses + + +# Generic (SunOS / SVR4) dynamic loading module. +# This is not needed for dynamic loading of Python modules -- +# it is a highly experimental and dangerous device for calling +# *arbitrary* C functions in *arbitrary* shared libraries: + +#dl dlmodule.c + + +# Modules that provide persistent dictionary-like semantics. You will +# probably want to arrange for at least one of them to be available on +# your machine, though none are defined by default because of library +# dependencies. The Python module anydbm.py provides an +# implementation independent wrapper for these; dumbdbm.py provides +# similar functionality (but slower of course) implemented in Python. + +# The standard Unix dbm module has been moved to Setup.config so that +# it will be compiled as a shared library by default. Compiling it as +# a built-in module causes conflicts with the pybsddb3 module since it +# creates a static dependency on an out-of-date version of db.so. +# +# First, look at Setup.config; configure may have set this for you. + +#dbm dbmmodule.c # dbm(3) may require -lndbm or similar + +# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: +# +# First, look at Setup.config; configure may have set this for you. + +#gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm + + +# Sleepycat Berkeley DB interface. +# +# This requires the Sleepycat DB code, see http://www.sleepycat.com/ +# The earliest supported version of that library is 3.0, the latest +# supported version is 4.0 (4.1 is specifically not supported, as that +# changes the semantics of transactional databases). A list of available +# releases can be found at +# +# http://www.sleepycat.com/update/index.html +# +# Edit the variables DB and DBLIBVERto point to the db top directory +# and the subdirectory of PORT where you built it. +#DB=/usr/local/BerkeleyDB.4.0 +#DBLIBVER=4.0 +#DBINC=$(DB)/include +#DBLIB=$(DB)/lib +#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) + +# Historical Berkeley DB 1.85 +# +# This module is deprecated; the 1.85 version of the Berkeley DB library has +# bugs that can cause data corruption. If you can, use later versions of the +# library instead, available from . + +#DB=/depot/sundry/src/berkeley-db/db.1.85 +#DBPORT=$(DB)/PORT/irix.5.3 +#bsddb185 bsddbmodule.c -I$(DBPORT)/include -I$(DBPORT) $(DBPORT)/libdb.a + + + +# Helper module for various ascii-encoders +#binascii binascii.c + +# Fred Drake's interface to the Python parser +#parser parsermodule.c + +# cStringIO and cPickle +#cStringIO cStringIO.c +#cPickle cPickle.c + + +# Lee Busby's SIGFPE modules. +# The library to link fpectl with is platform specific. +# Choose *one* of the options below for fpectl: + +# For SGI IRIX (tested on 5.3): +#fpectl fpectlmodule.c -lfpe + +# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): +# (Without the compiler you don't have -lsunmath.) +#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm + +# For other systems: see instructions in fpectlmodule.c. +#fpectl fpectlmodule.c ... + +# Test module for fpectl. No extra libraries needed. +#fpetest fpetestmodule.c + +# Andrew Kuchling's zlib module. +# This require zlib 1.1.3 (or later). +# See http://www.gzip.org/zlib/ +#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz + +# Interface to the Expat XML parser +# +# Expat was written by James Clark and is now maintained by a group of +# developers on SourceForge; see www.libexpat.org for more +# information. The pyexpat module was written by Paul Prescod after a +# prototype by Jack Jansen. Source of Expat 1.95.2 is included in +# Modules/expat/. Usage of a system shared libexpat.so/expat.dll is +# not advised. +# +# More information on Expat can be found at www.libexpat.org. +# +#EXPAT_DIR=/usr/local/src/expat-1.95.2 +#pyexpat pyexpat.c -DHAVE_EXPAT_H -I$(EXPAT_DIR)/lib -L$(EXPAT_DIR) -lexpat + + +# Hye-Shik Chang's CJKCodecs + +# multibytecodec is required for all the other CJK codec modules +#_multibytecodec cjkcodecs/multibytecodec.c + +#_codecs_cn cjkcodecs/_codecs_cn.c +#_codecs_hk cjkcodecs/_codecs_hk.c +#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c +#_codecs_jp cjkcodecs/_codecs_jp.c +#_codecs_kr cjkcodecs/_codecs_kr.c +#_codecs_tw cjkcodecs/_codecs_tw.c + +# Example -- included for reference only: +# xx xxmodule.c + +# Another example -- the 'xxsubtype' module shows C-level subtyping in action +xxsubtype xxsubtype.c + +# uncomment if you'd like to compile stackless statically. +# Note that the static build puts the .o files into Modules. +#SLP=./Stackless +#stackless $(SLP)/stacklessmodule.c $(SLP)/atomicobject.c $(SLP)/cframeobject.c $(SLP)/channelobject.c $(SLP)/flextype.c $(SLP)/scheduling.c $(SLP)/schedulerobject.c $(SLP)/stackless_debug.c $(SLP)/stackless_util.c $(SLP)/taskletobject.c Modified: stackless/Python-2.4.3/dev/Modules/config.c.in ============================================================================== --- stackless/Python-2.4.3/dev/Modules/config.c.in (original) +++ stackless/Python-2.4.3/dev/Modules/config.c.in Fri May 5 19:50:05 2006 @@ -1,48 +1,48 @@ -/* -*- C -*- *********************************************** -Copyright (c) 2000, BeOpen.com. -Copyright (c) 1995-2000, Corporation for National Research Initiatives. -Copyright (c) 1990-1995, Stichting Mathematisch Centrum. -All rights reserved. - -See the file "Misc/COPYRIGHT" for information on usage and -redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. -******************************************************************/ - -/* Module configuration */ - -/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */ - -/* This file contains the table of built-in modules. - See init_builtin() in import.c. */ - -#include "Python.h" - - -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(void); -extern void initimp(void); -extern void initgc(void); - -struct _inittab _PyImport_Inittab[] = { - -/* -- ADDMODULE MARKER 2 -- */ - - /* This module lives in marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives in import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - {"exceptions", NULL}, - - /* This lives in gcmodule.c */ - {"gc", initgc}, - - /* Sentinel */ - {0, 0} -}; +/* -*- C -*- *********************************************** +Copyright (c) 2000, BeOpen.com. +Copyright (c) 1995-2000, Corporation for National Research Initiatives. +Copyright (c) 1990-1995, Stichting Mathematisch Centrum. +All rights reserved. + +See the file "Misc/COPYRIGHT" for information on usage and +redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. +******************************************************************/ + +/* Module configuration */ + +/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */ + +/* This file contains the table of built-in modules. + See init_builtin() in import.c. */ + +#include "Python.h" + + +/* -- ADDMODULE MARKER 1 -- */ + +extern void PyMarshal_Init(void); +extern void initimp(void); +extern void initgc(void); + +struct _inittab _PyImport_Inittab[] = { + +/* -- ADDMODULE MARKER 2 -- */ + + /* This module lives in marshal.c */ + {"marshal", PyMarshal_Init}, + + /* This lives in import.c */ + {"imp", initimp}, + + /* These entries are here for sys.builtin_module_names */ + {"__main__", NULL}, + {"__builtin__", NULL}, + {"sys", NULL}, + {"exceptions", NULL}, + + /* This lives in gcmodule.c */ + {"gc", initgc}, + + /* Sentinel */ + {0, 0} +}; Modified: stackless/Python-2.4.3/dev/Modules/makesetup ============================================================================== --- stackless/Python-2.4.3/dev/Modules/makesetup (original) +++ stackless/Python-2.4.3/dev/Modules/makesetup Fri May 5 19:50:05 2006 @@ -1,297 +1,297 @@ -#! /bin/sh - -# Convert templates into Makefile and config.c, based on the module -# definitions found in the file Setup. -# -# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] -# -# Options: -# -s directory: alternative source directory (default .) -# -l directory: library source directory (default derived from $0) -# -c file: alternative config.c template (default $libdir/config.c.in) -# -c -: don't write config.c -# -m file: alternative Makefile template (default ./Makefile.pre) -# -m -: don't write Makefile -# -# Remaining arguments are one or more Setup files (default ./Setup). -# Setup files after a -n option are used for their variables, modules -# and libraries but not for their .o files. -# -# See Setup.dist for a description of the format of the Setup file. -# -# The following edits are made: -# -# Copying config.c.in to config.c: -# - insert an identifying comment at the start -# - for each mentioned in Setup before *noconfig*: -# + insert 'extern void init(void);' before MARKER 1 -# + insert '{"", initmodule},' before MARKER 2 -# -# Copying Makefile.pre to Makefile: -# - insert an identifying comment at the start -# - replace _MODOBJS_ by the list of objects from Setup (except for -# Setup files after a -n option) -# - replace _MODLIBS_ by the list of libraries from Setup -# - for each object file mentioned in Setup, append a rule -# '.o: .c; ' to the end of the Makefile -# - for each module mentioned in Setup, append a rule -# which creates a shared library version to the end of the Makefile -# - for each variable definition found in Setup, insert the definition -# before the comment 'Definitions added by makesetup' - -# Loop over command line options -usage=' -usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] - [Setup] ... [-n [Setup] ...]' -srcdir='.' -libdir='' -config='' -makepre='' -noobjects='' -doconfig=yes -while : -do - case $1 in - -s) shift; srcdir=$1; shift;; - -l) shift; libdir=$1; shift;; - -c) shift; config=$1; shift;; - -m) shift; makepre=$1; shift;; - --) shift; break;; - -n) noobjects=yes;; - -*) echo "$usage" 1>&2; exit 2;; - *) break;; - esac -done - -# Set default libdir and config if not set by command line -# (Not all systems have dirname) -case $libdir in -'') case $0 in - */*) libdir=`echo $0 | sed 's,/[^/]*$,,'`;; - *) libdir=.;; - esac;; -esac -case $config in -'') config=$libdir/config.c.in;; -esac -case $makepre in -'') makepre=Makefile.pre;; -esac - -# Newline for sed i and a commands -NL='\ -' - -# Setup to link with extra libraries when makeing shared extensions. -# Currently, only Cygwin needs this baggage. -case `uname -s` in -CYGWIN*) if test $libdir = . - then - ExtraLibDir=. - else - ExtraLibDir='$(LIBPL)' - fi - ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";; -esac - -# Main loop -for i in ${*-Setup} -do - case $i in - -n) echo '*noobjects*';; - *) echo '*doconfig*'; cat "$i";; - esac -done | -sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | -( - rulesf="@rules.$$" - trap 'rm -f $rulesf' 0 1 2 3 - echo " -# Rules appended by makedepend -" >$rulesf - DEFS= - MODS= - SHAREDMODS= - OBJS= - LIBS= - LOCALLIBS= - BASELIBS= - while read line - do - # to handle backslashes for sh's that don't automatically - # continue a read when the last char is a backslash - while echo $line | grep '\\$' > /dev/null - do - read extraline - line=`echo $line| sed s/.$//`$extraline - done - - # Output DEFS in reverse order so first definition overrides - case $line in - *=*) DEFS="$line$NL$DEFS"; continue;; - 'include '*) DEFS="$line$NL$DEFS"; continue;; - '*noobjects*') - case $noobjects in - yes) ;; - *) LOCALLIBS=$LIBS; LIBS=;; - esac - noobjects=yes; - continue;; - '*doconfig*') doconfig=yes; continue;; - '*static*') doconfig=yes; continue;; - '*noconfig*') doconfig=no; continue;; - '*shared*') doconfig=no; continue;; - esac - srcs= - cpps= - libs= - mods= - skip= - for arg in $line - do - case $skip in - libs) libs="$libs $arg"; skip=; continue;; - cpps) cpps="$cpps $arg"; skip=; continue;; - srcs) srcs="$srcs $arg"; skip=; continue;; - esac - case $arg in - -framework) libs="$libs $arg"; skip=libs; - # OSX/OSXS/Darwin framework link cmd - ;; - -[IDUCfF]*) cpps="$cpps $arg";; - -Xcompiler) skip=cpps;; - -Xlinker) libs="$libs $arg"; skip=libs;; - -rpath) libs="$libs $arg"; skip=libs;; - --rpath) libs="$libs $arg"; skip=libs;; - -[A-Zl]*) libs="$libs $arg";; - *.a) libs="$libs $arg";; - *.so) libs="$libs $arg";; - *.sl) libs="$libs $arg";; - /*.o) libs="$libs $arg";; - *.def) libs="$libs $arg";; - *.o) srcs="$srcs `basename $arg .o`.c";; - *.[cC]) srcs="$srcs $arg";; - *.m) srcs="$srcs $arg";; # Objective-C src - *.cc) srcs="$srcs $arg";; - *.c++) srcs="$srcs $arg";; - *.cxx) srcs="$srcs $arg";; - *.cpp) srcs="$srcs $arg";; - \$*) libs="$libs $arg" - cpps="$cpps $arg";; - *.*) echo 1>&2 "bad word $arg in $line" - exit 1;; - -u) skip=libs; libs="$libs -u";; - [a-zA-Z_]*) mods="$mods $arg";; - *) echo 1>&2 "bad word $arg in $line" - exit 1;; - esac - done - case $doconfig in - yes) - LIBS="$LIBS $libs" - MODS="$MODS $mods" - ;; - esac - case $noobjects in - yes) continue;; - esac - objs='' - for src in $srcs - do - case $src in - *.c) obj=`basename $src .c`.o; cc='$(CC)';; - *.cc) obj=`basename $src .cc`.o; cc='$(CXX)';; - *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';; - *.C) obj=`basename $src .C`.o; cc='$(CXX)';; - *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';; - *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';; - *.m) obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C - *) continue;; - esac - obj="$srcdir/$obj" - objs="$objs $obj" - case $src in - glmodule.c) ;; - /*) ;; - \$*) ;; - *) src='$(srcdir)/'"$srcdir/$src";; - esac - case $doconfig in - no) cc="$cc \$(CCSHARED) \$(CFLAGS) \$(CPPFLAGS)";; - *) - cc="$cc \$(PY_CFLAGS)";; - esac - rule="$obj: $src; $cc $cpps -c $src -o $obj" - echo "$rule" >>$rulesf - done - case $doconfig in - yes) OBJS="$OBJS $objs";; - esac - for mod in $mods - do - case $objs in - *$mod.o*) base=$mod;; - *) base=${mod}module;; - esac - file="$srcdir/$base\$(SO)" - case $doconfig in - no) SHAREDMODS="$SHAREDMODS $file";; - esac - rule="$file: $objs" - rule="$rule; \$(LDSHARED) $objs $libs $ExtraLibs -o $file" - echo "$rule" >>$rulesf - done - done - - case $SHAREDMODS in - '') ;; - *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; - esac - - case $noobjects in - yes) BASELIBS=$LIBS;; - *) LOCALLIBS=$LIBS;; - esac - LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' - DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" - DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" - - EXTDECLS= - INITBITS= - for mod in $MODS - do - EXTDECLS="${EXTDECLS}extern void init$mod(void);$NL" - INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" - done - - - case $config in - -) ;; - *) sed -e " - 1i$NL/* Generated automatically from $config by makesetup. */ - /MARKER 1/i$NL$EXTDECLS - - /MARKER 2/i$NL$INITBITS - - " $config >config.c - ;; - esac - - case $makepre in - -) ;; - *) sedf="@sed.in.$$" - trap 'rm -f $sedf' 0 1 2 3 - echo "1i\\" >$sedf - str="# Generated automatically from $makepre by makesetup." - echo "$str" >>$sedf - echo "s%_MODOBJS_%$OBJS%" >>$sedf - echo "s%_MODLIBS_%$LIBS%" >>$sedf - echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf - sed -f $sedf $makepre >Makefile - cat $rulesf >>Makefile - rm -f $sedf - ;; - esac - - rm -f $rulesf -) +#! /bin/sh + +# Convert templates into Makefile and config.c, based on the module +# definitions found in the file Setup. +# +# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] +# +# Options: +# -s directory: alternative source directory (default .) +# -l directory: library source directory (default derived from $0) +# -c file: alternative config.c template (default $libdir/config.c.in) +# -c -: don't write config.c +# -m file: alternative Makefile template (default ./Makefile.pre) +# -m -: don't write Makefile +# +# Remaining arguments are one or more Setup files (default ./Setup). +# Setup files after a -n option are used for their variables, modules +# and libraries but not for their .o files. +# +# See Setup.dist for a description of the format of the Setup file. +# +# The following edits are made: +# +# Copying config.c.in to config.c: +# - insert an identifying comment at the start +# - for each mentioned in Setup before *noconfig*: +# + insert 'extern void init(void);' before MARKER 1 +# + insert '{"", initmodule},' before MARKER 2 +# +# Copying Makefile.pre to Makefile: +# - insert an identifying comment at the start +# - replace _MODOBJS_ by the list of objects from Setup (except for +# Setup files after a -n option) +# - replace _MODLIBS_ by the list of libraries from Setup +# - for each object file mentioned in Setup, append a rule +# '.o: .c; ' to the end of the Makefile +# - for each module mentioned in Setup, append a rule +# which creates a shared library version to the end of the Makefile +# - for each variable definition found in Setup, insert the definition +# before the comment 'Definitions added by makesetup' + +# Loop over command line options +usage=' +usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] + [Setup] ... [-n [Setup] ...]' +srcdir='.' +libdir='' +config='' +makepre='' +noobjects='' +doconfig=yes +while : +do + case $1 in + -s) shift; srcdir=$1; shift;; + -l) shift; libdir=$1; shift;; + -c) shift; config=$1; shift;; + -m) shift; makepre=$1; shift;; + --) shift; break;; + -n) noobjects=yes;; + -*) echo "$usage" 1>&2; exit 2;; + *) break;; + esac +done + +# Set default libdir and config if not set by command line +# (Not all systems have dirname) +case $libdir in +'') case $0 in + */*) libdir=`echo $0 | sed 's,/[^/]*$,,'`;; + *) libdir=.;; + esac;; +esac +case $config in +'') config=$libdir/config.c.in;; +esac +case $makepre in +'') makepre=Makefile.pre;; +esac + +# Newline for sed i and a commands +NL='\ +' + +# Setup to link with extra libraries when makeing shared extensions. +# Currently, only Cygwin needs this baggage. +case `uname -s` in +CYGWIN*) if test $libdir = . + then + ExtraLibDir=. + else + ExtraLibDir='$(LIBPL)' + fi + ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";; +esac + +# Main loop +for i in ${*-Setup} +do + case $i in + -n) echo '*noobjects*';; + *) echo '*doconfig*'; cat "$i";; + esac +done | +sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | +( + rulesf="@rules.$$" + trap 'rm -f $rulesf' 0 1 2 3 + echo " +# Rules appended by makedepend +" >$rulesf + DEFS= + MODS= + SHAREDMODS= + OBJS= + LIBS= + LOCALLIBS= + BASELIBS= + while read line + do + # to handle backslashes for sh's that don't automatically + # continue a read when the last char is a backslash + while echo $line | grep '\\$' > /dev/null + do + read extraline + line=`echo $line| sed s/.$//`$extraline + done + + # Output DEFS in reverse order so first definition overrides + case $line in + *=*) DEFS="$line$NL$DEFS"; continue;; + 'include '*) DEFS="$line$NL$DEFS"; continue;; + '*noobjects*') + case $noobjects in + yes) ;; + *) LOCALLIBS=$LIBS; LIBS=;; + esac + noobjects=yes; + continue;; + '*doconfig*') doconfig=yes; continue;; + '*static*') doconfig=yes; continue;; + '*noconfig*') doconfig=no; continue;; + '*shared*') doconfig=no; continue;; + esac + srcs= + cpps= + libs= + mods= + skip= + for arg in $line + do + case $skip in + libs) libs="$libs $arg"; skip=; continue;; + cpps) cpps="$cpps $arg"; skip=; continue;; + srcs) srcs="$srcs $arg"; skip=; continue;; + esac + case $arg in + -framework) libs="$libs $arg"; skip=libs; + # OSX/OSXS/Darwin framework link cmd + ;; + -[IDUCfF]*) cpps="$cpps $arg";; + -Xcompiler) skip=cpps;; + -Xlinker) libs="$libs $arg"; skip=libs;; + -rpath) libs="$libs $arg"; skip=libs;; + --rpath) libs="$libs $arg"; skip=libs;; + -[A-Zl]*) libs="$libs $arg";; + *.a) libs="$libs $arg";; + *.so) libs="$libs $arg";; + *.sl) libs="$libs $arg";; + /*.o) libs="$libs $arg";; + *.def) libs="$libs $arg";; + *.o) srcs="$srcs `basename $arg .o`.c";; + *.[cC]) srcs="$srcs $arg";; + *.m) srcs="$srcs $arg";; # Objective-C src + *.cc) srcs="$srcs $arg";; + *.c++) srcs="$srcs $arg";; + *.cxx) srcs="$srcs $arg";; + *.cpp) srcs="$srcs $arg";; + \$*) libs="$libs $arg" + cpps="$cpps $arg";; + *.*) echo 1>&2 "bad word $arg in $line" + exit 1;; + -u) skip=libs; libs="$libs -u";; + [a-zA-Z_]*) mods="$mods $arg";; + *) echo 1>&2 "bad word $arg in $line" + exit 1;; + esac + done + case $doconfig in + yes) + LIBS="$LIBS $libs" + MODS="$MODS $mods" + ;; + esac + case $noobjects in + yes) continue;; + esac + objs='' + for src in $srcs + do + case $src in + *.c) obj=`basename $src .c`.o; cc='$(CC)';; + *.cc) obj=`basename $src .cc`.o; cc='$(CXX)';; + *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';; + *.C) obj=`basename $src .C`.o; cc='$(CXX)';; + *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';; + *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';; + *.m) obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C + *) continue;; + esac + obj="$srcdir/$obj" + objs="$objs $obj" + case $src in + glmodule.c) ;; + /*) ;; + \$*) ;; + *) src='$(srcdir)/'"$srcdir/$src";; + esac + case $doconfig in + no) cc="$cc \$(CCSHARED) \$(CFLAGS) \$(CPPFLAGS)";; + *) + cc="$cc \$(PY_CFLAGS)";; + esac + rule="$obj: $src; $cc $cpps -c $src -o $obj" + echo "$rule" >>$rulesf + done + case $doconfig in + yes) OBJS="$OBJS $objs";; + esac + for mod in $mods + do + case $objs in + *$mod.o*) base=$mod;; + *) base=${mod}module;; + esac + file="$srcdir/$base\$(SO)" + case $doconfig in + no) SHAREDMODS="$SHAREDMODS $file";; + esac + rule="$file: $objs" + rule="$rule; \$(LDSHARED) $objs $libs $ExtraLibs -o $file" + echo "$rule" >>$rulesf + done + done + + case $SHAREDMODS in + '') ;; + *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; + esac + + case $noobjects in + yes) BASELIBS=$LIBS;; + *) LOCALLIBS=$LIBS;; + esac + LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' + DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" + DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" + + EXTDECLS= + INITBITS= + for mod in $MODS + do + EXTDECLS="${EXTDECLS}extern void init$mod(void);$NL" + INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" + done + + + case $config in + -) ;; + *) sed -e " + 1i$NL/* Generated automatically from $config by makesetup. */ + /MARKER 1/i$NL$EXTDECLS + + /MARKER 2/i$NL$INITBITS + + " $config >config.c + ;; + esac + + case $makepre in + -) ;; + *) sedf="@sed.in.$$" + trap 'rm -f $sedf' 0 1 2 3 + echo "1i\\" >$sedf + str="# Generated automatically from $makepre by makesetup." + echo "$str" >>$sedf + echo "s%_MODOBJS_%$OBJS%" >>$sedf + echo "s%_MODLIBS_%$LIBS%" >>$sedf + echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf + sed -f $sedf $makepre >Makefile + cat $rulesf >>Makefile + rm -f $sedf + ;; + esac + + rm -f $rulesf +) From python-checkins at python.org Fri May 5 20:00:16 2006 From: python-checkins at python.org (richard.tew) Date: Fri, 5 May 2006 20:00:16 +0200 (CEST) Subject: [Python-checkins] r45912 - stackless/Python-2.4.3/dev/configure Message-ID: <20060505180016.389501E4017@bag.python.org> Author: richard.tew Date: Fri May 5 20:00:15 2006 New Revision: 45912 Modified: stackless/Python-2.4.3/dev/configure (props changed) Log: Made it executable. From python-checkins at python.org Fri May 5 20:42:14 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 5 May 2006 20:42:14 +0200 (CEST) Subject: [Python-checkins] r45913 - python/trunk/Modules/_ctypes/_ctypes_test.c Message-ID: <20060505184214.EF9F91E4008@bag.python.org> Author: thomas.heller Date: Fri May 5 20:42:14 2006 New Revision: 45913 Modified: python/trunk/Modules/_ctypes/_ctypes_test.c Log: Export the 'free' standard C function for use in the test suite. Modified: python/trunk/Modules/_ctypes/_ctypes_test.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes_test.c (original) +++ python/trunk/Modules/_ctypes/_ctypes_test.c Fri May 5 20:42:14 2006 @@ -96,6 +96,11 @@ return dst; } +EXPORT(void) free(void *ptr) +{ + free(ptr); +} + #ifdef HAVE_WCHAR_H EXPORT(wchar_t *) my_wcsdup(wchar_t *src) { From python-checkins at python.org Fri May 5 20:43:24 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 5 May 2006 20:43:24 +0200 (CEST) Subject: [Python-checkins] r45914 - python/trunk/Lib/ctypes/test/test_slicing.py Message-ID: <20060505184324.EB7CD1E400C@bag.python.org> Author: thomas.heller Date: Fri May 5 20:43:24 2006 New Revision: 45914 Modified: python/trunk/Lib/ctypes/test/test_slicing.py Log: Fix memory leaks in the ctypes test suite, reported by valgrind, by free()ing the memory we allocate. Modified: python/trunk/Lib/ctypes/test/test_slicing.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_slicing.py (original) +++ python/trunk/Lib/ctypes/test/test_slicing.py Fri May 5 20:43:24 2006 @@ -39,16 +39,19 @@ dll = CDLL(_ctypes_test.__file__) dll.my_strdup.restype = POINTER(c_char) + dll.my_free.restype = None res = dll.my_strdup(s) self.failUnlessEqual(res[:len(s)], s) import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") + dll.free(res) dll.my_strdup.restype = POINTER(c_byte) res = dll.my_strdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) + dll.free(res) def test_char_array(self): s = "abcdefghijklmnopqrstuvwxyz\0" @@ -68,12 +71,14 @@ dll = CDLL(_ctypes_test.__file__) dll.my_wcsdup.restype = POINTER(c_wchar) dll.my_wcsdup.argtypes = POINTER(c_wchar), + dll.my_free.restype = None res = dll.my_wcsdup(s) self.failUnlessEqual(res[:len(s)], s) import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") + dll.free(res) if sizeof(c_wchar) == sizeof(c_short): dll.my_wcsdup.restype = POINTER(c_short) @@ -81,8 +86,11 @@ dll.my_wcsdup.restype = POINTER(c_int) elif sizeof(c_wchar) == sizeof(c_long): dll.my_wcsdup.restype = POINTER(c_long) + else: + return res = dll.my_wcsdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) + dll.free(res) ################################################################ From python-checkins at python.org Fri May 5 20:46:28 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 5 May 2006 20:46:28 +0200 (CEST) Subject: [Python-checkins] r45915 - python/trunk/Lib/ctypes/test/test_slicing.py Message-ID: <20060505184628.5ED141E400C@bag.python.org> Author: thomas.heller Date: Fri May 5 20:46:27 2006 New Revision: 45915 Modified: python/trunk/Lib/ctypes/test/test_slicing.py Log: oops - the function is exported as 'my_free', not 'free'. Modified: python/trunk/Lib/ctypes/test/test_slicing.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_slicing.py (original) +++ python/trunk/Lib/ctypes/test/test_slicing.py Fri May 5 20:46:27 2006 @@ -46,12 +46,12 @@ import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") - dll.free(res) + dll.my_free(res) dll.my_strdup.restype = POINTER(c_byte) res = dll.my_strdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) - dll.free(res) + dll.my_free(res) def test_char_array(self): s = "abcdefghijklmnopqrstuvwxyz\0" @@ -78,7 +78,7 @@ import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") - dll.free(res) + dll.my_free(res) if sizeof(c_wchar) == sizeof(c_short): dll.my_wcsdup.restype = POINTER(c_short) @@ -90,7 +90,7 @@ return res = dll.my_wcsdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) - dll.free(res) + dll.my_free(res) ################################################################ From python-checkins at python.org Fri May 5 21:14:24 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 5 May 2006 21:14:24 +0200 (CEST) Subject: [Python-checkins] r45916 - python/trunk/Modules/_ctypes/_ctypes_test.c Message-ID: <20060505191424.CD2C41E400B@bag.python.org> Author: thomas.heller Date: Fri May 5 21:14:24 2006 New Revision: 45916 Modified: python/trunk/Modules/_ctypes/_ctypes_test.c Log: Clean up. Modified: python/trunk/Modules/_ctypes/_ctypes_test.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes_test.c (original) +++ python/trunk/Modules/_ctypes/_ctypes_test.c Fri May 5 21:14:24 2006 @@ -96,7 +96,7 @@ return dst; } -EXPORT(void) free(void *ptr) +EXPORT(void)my_free(void *ptr) { free(ptr); } @@ -204,11 +204,6 @@ return 0; } -EXPORT(void) my_free(void *p) -{ - printf("my_free got %p\n", p); -} - typedef struct { char *name; char *value; From python-checkins at python.org Fri May 5 21:26:02 2006 From: python-checkins at python.org (richard.tew) Date: Fri, 5 May 2006 21:26:02 +0200 (CEST) Subject: [Python-checkins] r45917 - stackless/Python-2.4.3/dev/Lib/test/output/test_MimeWriter stackless/Python-2.4.3/dev/Lib/test/output/test_asynchat stackless/Python-2.4.3/dev/Lib/test/output/test_augassign stackless/Python-2.4.3/dev/Lib/test/output/test_cgi stackless/Python-2.4.3/dev/Lib/test/output/test_class stackless/Python-2.4.3/dev/Lib/test/output/test_coercion stackless/Python-2.4.3/dev/Lib/test/output/test_compare stackless/Python-2.4.3/dev/Lib/test/output/test_cookie stackless/Python-2.4.3/dev/Lib/test/output/test_exceptions stackless/Python-2.4.3/dev/Lib/test/output/test_extcall stackless/Python-2.4.3/dev/Lib/test/output/test_frozen stackless/Python-2.4.3/dev/Lib/test/output/test_global stackless/Python-2.4.3/dev/Lib/test/output/test_grammar stackless/Python-2.4.3/dev/Lib/test/output/test_httplib stackless/Python-2.4.3/dev/Lib/test/output/test_linuxaudiodev stackless/Python-2.4.3/dev/Lib/test/output/test_logging stackless/Python-2.4.3/dev/Lib/test/output/test_math stackless/Python-2.4.3/dev/Lib/test/output/test_mmap stackless/Python-2.4.3/dev/Lib/test/output/test_new stackless/Python-2.4.3/dev/Lib/test/output/test_nis stackless/Python-2.4.3/dev/Lib/test/output/test_opcodes stackless/Python-2.4.3/dev/Lib/test/output/test_openpty stackless/Python-2.4.3/dev/Lib/test/output/test_operations stackless/Python-2.4.3/dev/Lib/test/output/test_ossaudiodev stackless/Python-2.4.3/dev/Lib/test/output/test_pep277 stackless/Python-2.4.3/dev/Lib/test/output/test_pkg stackless/Python-2.4.3/dev/Lib/test/output/test_poll stackless/Python-2.4.3/dev/Lib/test/output/test_popen stackless/Python-2.4.3/dev/Lib/test/output/test_popen2 stackless/Python-2.4.3/dev/Lib/test/output/test_profile stackless/Python-2.4.3/dev/Lib/test/output/test_pty stackless/Python-2.4.3/dev/Lib/test/output/test_pyexpat stackless/Python-2.4.3/dev/Lib/test/output/test_regex stackless/Python-2.4.3/dev/Lib/test/output/test_resource stackless/Python-2.4.3/dev/Lib/test/output/test_rgbimg stackless/Python-2.4.3/dev/Lib/test/output/test_scope stackless/Python-2.4.3/dev/Lib/test/output/test_signal stackless/Python-2.4.3/dev/Lib/test/output/test_thread stackless/Python-2.4.3/dev/Lib/test/output/test_threadedtempfile stackless/Python-2.4.3/dev/Lib/test/output/test_tokenize stackless/Python-2.4.3/dev/Lib/test/output/test_types stackless/Python-2.4.3/dev/Lib/test/output/test_winreg stackless/Python-2.4.3/dev/Lib/test/output/xmltests Message-ID: <20060505192602.6ECE11E401A@bag.python.org> Author: richard.tew Date: Fri May 5 21:25:58 2006 New Revision: 45917 Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_MimeWriter (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_asynchat (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_augassign (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_cgi (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_class (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_coercion (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_compare (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_cookie (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_exceptions (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_extcall (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_frozen (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_global (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_grammar (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_httplib (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_linuxaudiodev (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_logging (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_math (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_mmap (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_new (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_nis (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_opcodes (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_openpty (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_operations (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_ossaudiodev (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_pep277 (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_pkg (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_poll (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_popen (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_popen2 (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_profile (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_pty (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_pyexpat (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_regex (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_resource (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_rgbimg (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_scope (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_signal (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_thread (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_threadedtempfile (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_tokenize (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_types (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/test_winreg (contents, props changed) stackless/Python-2.4.3/dev/Lib/test/output/xmltests (contents, props changed) Log: Fixed up SVN properties for Python test output files. Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_MimeWriter ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_MimeWriter (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_MimeWriter Fri May 5 21:25:58 2006 @@ -1,110 +1,110 @@ -test_MimeWriter -From: bwarsaw at cnri.reston.va.us -Date: Mon Feb 12 17:21:48 EST 1996 -To: kss-submit at cnri.reston.va.us -MIME-Version: 1.0 -Content-Type: multipart/knowbot; - boundary="801spam999"; - version="0.1" - -This is a multi-part message in MIME format. - ---801spam999 -Content-Type: multipart/knowbot-metadata; - boundary="802spam999" - - ---802spam999 -Content-Type: message/rfc822 -KP-Metadata-Type: simple -KP-Access: read-only - -KPMD-Interpreter: python -KPMD-Interpreter-Version: 1.3 -KPMD-Owner-Name: Barry Warsaw -KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us -KPMD-Home-KSS: kss.cnri.reston.va.us -KPMD-Identifier: hdl://cnri.kss/my_first_knowbot -KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 - ---802spam999 -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: connection -KP-Access: read-only -KP-Connection-Description: Barry's Big Bass Business -KP-Connection-Id: B4 -KP-Connection-Direction: client - -INTERFACE Seller-1; - -TYPE Seller = OBJECT - DOCUMENTATION "A simple Seller interface to test ILU" - METHODS - price():INTEGER, - END; - ---802spam999 -Content-Type: message/external-body; - access-type="URL"; - URL="hdl://cnri.kss/generic-knowbot" - -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: generic-interface -KP-Access: read-only -KP-Connection-Description: Generic Interface for All Knowbots -KP-Connection-Id: generic-kp -KP-Connection-Direction: client - - ---802spam999-- - ---801spam999 -Content-Type: multipart/knowbot-code; - boundary="803spam999" - - ---803spam999 -Content-Type: text/plain -KP-Module-Name: BuyerKP - -class Buyer: - def __setup__(self, maxprice): - self._maxprice = maxprice - - def __main__(self, kos): - """Entry point upon arrival at a new KOS.""" - broker = kos.broker() - # B4 == Barry's Big Bass Business :-) - seller = broker.lookup('Seller_1.Seller', 'B4') - if seller: - price = seller.price() - print 'Seller wants $', price, '... ' - if price > self._maxprice: - print 'too much!' - else: - print "I'll take it!" - else: - print 'no seller found here' - ---803spam999-- - ---801spam999 -Content-Type: multipart/knowbot-state; - boundary="804spam999" -KP-Main-Module: main - - ---804spam999 -Content-Type: text/plain -KP-Module-Name: main - -# instantiate a buyer instance and put it in a magic place for the KOS -# to find. -__kp__ = Buyer() -__kp__.__setup__(500) - ---804spam999-- - ---801spam999-- +test_MimeWriter +From: bwarsaw at cnri.reston.va.us +Date: Mon Feb 12 17:21:48 EST 1996 +To: kss-submit at cnri.reston.va.us +MIME-Version: 1.0 +Content-Type: multipart/knowbot; + boundary="801spam999"; + version="0.1" + +This is a multi-part message in MIME format. + +--801spam999 +Content-Type: multipart/knowbot-metadata; + boundary="802spam999" + + +--802spam999 +Content-Type: message/rfc822 +KP-Metadata-Type: simple +KP-Access: read-only + +KPMD-Interpreter: python +KPMD-Interpreter-Version: 1.3 +KPMD-Owner-Name: Barry Warsaw +KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us +KPMD-Home-KSS: kss.cnri.reston.va.us +KPMD-Identifier: hdl://cnri.kss/my_first_knowbot +KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 + +--802spam999 +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: connection +KP-Access: read-only +KP-Connection-Description: Barry's Big Bass Business +KP-Connection-Id: B4 +KP-Connection-Direction: client + +INTERFACE Seller-1; + +TYPE Seller = OBJECT + DOCUMENTATION "A simple Seller interface to test ILU" + METHODS + price():INTEGER, + END; + +--802spam999 +Content-Type: message/external-body; + access-type="URL"; + URL="hdl://cnri.kss/generic-knowbot" + +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: generic-interface +KP-Access: read-only +KP-Connection-Description: Generic Interface for All Knowbots +KP-Connection-Id: generic-kp +KP-Connection-Direction: client + + +--802spam999-- + +--801spam999 +Content-Type: multipart/knowbot-code; + boundary="803spam999" + + +--803spam999 +Content-Type: text/plain +KP-Module-Name: BuyerKP + +class Buyer: + def __setup__(self, maxprice): + self._maxprice = maxprice + + def __main__(self, kos): + """Entry point upon arrival at a new KOS.""" + broker = kos.broker() + # B4 == Barry's Big Bass Business :-) + seller = broker.lookup('Seller_1.Seller', 'B4') + if seller: + price = seller.price() + print 'Seller wants $', price, '... ' + if price > self._maxprice: + print 'too much!' + else: + print "I'll take it!" + else: + print 'no seller found here' + +--803spam999-- + +--801spam999 +Content-Type: multipart/knowbot-state; + boundary="804spam999" +KP-Main-Module: main + + +--804spam999 +Content-Type: text/plain +KP-Module-Name: main + +# instantiate a buyer instance and put it in a magic place for the KOS +# to find. +__kp__ = Buyer() +__kp__.__setup__(500) + +--804spam999-- + +--801spam999-- Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_asynchat ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_asynchat (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_asynchat Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_asynchat -Connected -Received: 'hello world' +test_asynchat +Connected +Received: 'hello world' Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_augassign ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_augassign (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_augassign Fri May 5 21:25:58 2006 @@ -1,51 +1,51 @@ -test_augassign -6 -[6] -6 -[1, 2, 3, 4, 1, 2, 3, 4] -[1, 2, 1, 2, 3] -True -True -True -11 -True -12 -True -True -13 -__add__ called -__radd__ called -__iadd__ called -__sub__ called -__rsub__ called -__isub__ called -__mul__ called -__rmul__ called -__imul__ called -__div__ called -__rdiv__ called -__idiv__ called -__floordiv__ called -__rfloordiv__ called -__ifloordiv__ called -__mod__ called -__rmod__ called -__imod__ called -__pow__ called -__rpow__ called -__ipow__ called -__or__ called -__ror__ called -__ior__ called -__and__ called -__rand__ called -__iand__ called -__xor__ called -__rxor__ called -__ixor__ called -__rshift__ called -__rrshift__ called -__irshift__ called -__lshift__ called -__rlshift__ called -__ilshift__ called +test_augassign +6 +[6] +6 +[1, 2, 3, 4, 1, 2, 3, 4] +[1, 2, 1, 2, 3] +True +True +True +11 +True +12 +True +True +13 +__add__ called +__radd__ called +__iadd__ called +__sub__ called +__rsub__ called +__isub__ called +__mul__ called +__rmul__ called +__imul__ called +__div__ called +__rdiv__ called +__idiv__ called +__floordiv__ called +__rfloordiv__ called +__ifloordiv__ called +__mod__ called +__rmod__ called +__imod__ called +__pow__ called +__rpow__ called +__ipow__ called +__or__ called +__ror__ called +__ior__ called +__and__ called +__rand__ called +__iand__ called +__xor__ called +__rxor__ called +__ixor__ called +__rshift__ called +__rrshift__ called +__irshift__ called +__lshift__ called +__rlshift__ called +__ilshift__ called Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_cgi ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_cgi (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_cgi Fri May 5 21:25:58 2006 @@ -1,40 +1,40 @@ -test_cgi -'' => [] -'&' => [] -'&&' => [] -'=' => [('', '')] -'=a' => [('', 'a')] -'a' => [('a', '')] -'a=' => [('a', '')] -'a=' => [('a', '')] -'&a=b' => [('a', 'b')] -'a=a+b&b=b+c' => [('a', 'a b'), ('b', 'b c')] -'a=1&a=2' => [('a', '1'), ('a', '2')] -'' -'&' -'&&' -';' -';&;' -'=' -'=&=' -'=;=' -'=a' -'&=a' -'=a&' -'=&a' -'b=a' -'b+=a' -'a=b=a' -'a=+b=a' -'&b=a' -'b&=a' -'a=a+b&b=b+c' -'a=a+b&a=b+a' -'x=1&y=2.0&z=2-3.%2b0' -'x=1;y=2.0&z=2-3.%2b0' -'x=1;y=2.0;z=2-3.%2b0' -'Hbc5161168c542333633315dee1182227:key_store_seqid=400006&cuyer=r&view=bustomer&order_id=0bb2e248638833d48cb7fed300000f1b&expire=964546263&lobale=en-US&kid=130003.300038&ss=env' -'group_id=5470&set=custom&_assigned_to=31392&_status=1&_category=100&SUBMIT=Browse' -Testing log -Testing initlog 1 -Testing log 2 +test_cgi +'' => [] +'&' => [] +'&&' => [] +'=' => [('', '')] +'=a' => [('', 'a')] +'a' => [('a', '')] +'a=' => [('a', '')] +'a=' => [('a', '')] +'&a=b' => [('a', 'b')] +'a=a+b&b=b+c' => [('a', 'a b'), ('b', 'b c')] +'a=1&a=2' => [('a', '1'), ('a', '2')] +'' +'&' +'&&' +';' +';&;' +'=' +'=&=' +'=;=' +'=a' +'&=a' +'=a&' +'=&a' +'b=a' +'b+=a' +'a=b=a' +'a=+b=a' +'&b=a' +'b&=a' +'a=a+b&b=b+c' +'a=a+b&a=b+a' +'x=1&y=2.0&z=2-3.%2b0' +'x=1;y=2.0&z=2-3.%2b0' +'x=1;y=2.0;z=2-3.%2b0' +'Hbc5161168c542333633315dee1182227:key_store_seqid=400006&cuyer=r&view=bustomer&order_id=0bb2e248638833d48cb7fed300000f1b&expire=964546263&lobale=en-US&kid=130003.300038&ss=env' +'group_id=5470&set=custom&_assigned_to=31392&_status=1&_category=100&SUBMIT=Browse' +Testing log +Testing initlog 1 +Testing log 2 Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_class ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_class (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_class Fri May 5 21:25:58 2006 @@ -1,101 +1,101 @@ -test_class -__init__: () -__coerce__: (1,) -__add__: (1,) -__coerce__: (1,) -__radd__: (1,) -__coerce__: (1,) -__sub__: (1,) -__coerce__: (1,) -__rsub__: (1,) -__coerce__: (1,) -__mul__: (1,) -__coerce__: (1,) -__rmul__: (1,) -__coerce__: (1,) -__div__: (1,) -__coerce__: (1,) -__rdiv__: (1,) -__coerce__: (1,) -__mod__: (1,) -__coerce__: (1,) -__rmod__: (1,) -__coerce__: (1,) -__divmod__: (1,) -__coerce__: (1,) -__rdivmod__: (1,) -__coerce__: (1,) -__pow__: (1,) -__coerce__: (1,) -__rpow__: (1,) -__coerce__: (1,) -__rshift__: (1,) -__coerce__: (1,) -__rrshift__: (1,) -__coerce__: (1,) -__lshift__: (1,) -__coerce__: (1,) -__rlshift__: (1,) -__coerce__: (1,) -__and__: (1,) -__coerce__: (1,) -__rand__: (1,) -__coerce__: (1,) -__or__: (1,) -__coerce__: (1,) -__ror__: (1,) -__coerce__: (1,) -__xor__: (1,) -__coerce__: (1,) -__rxor__: (1,) -__contains__: (1,) -__getitem__: (1,) -__setitem__: (1, 1) -__delitem__: (1,) -__getslice__: (0, 42) -__setslice__: (0, 42, 'The Answer') -__delslice__: (0, 42) -__getitem__: (slice(2, 1024, 10),) -__setitem__: (slice(2, 1024, 10), 'A lot') -__delitem__: (slice(2, 1024, 10),) -__getitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100),) -__setitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100), 'Strange') -__delitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100),) -__getitem__: (slice(0, 42, None),) -__setitem__: (slice(0, 42, None), 'The Answer') -__delitem__: (slice(0, 42, None),) -__neg__: () -__pos__: () -__abs__: () -__int__: () -__long__: () -__float__: () -__oct__: () -__hex__: () -__hash__: () -__repr__: () -__str__: () -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__coerce__: (1,) -__cmp__: (1,) -__del__: () -__getattr__: ('spam',) -__setattr__: ('eggs', 'spam, spam, spam and ham') -__delattr__: ('cardinal',) +test_class +__init__: () +__coerce__: (1,) +__add__: (1,) +__coerce__: (1,) +__radd__: (1,) +__coerce__: (1,) +__sub__: (1,) +__coerce__: (1,) +__rsub__: (1,) +__coerce__: (1,) +__mul__: (1,) +__coerce__: (1,) +__rmul__: (1,) +__coerce__: (1,) +__div__: (1,) +__coerce__: (1,) +__rdiv__: (1,) +__coerce__: (1,) +__mod__: (1,) +__coerce__: (1,) +__rmod__: (1,) +__coerce__: (1,) +__divmod__: (1,) +__coerce__: (1,) +__rdivmod__: (1,) +__coerce__: (1,) +__pow__: (1,) +__coerce__: (1,) +__rpow__: (1,) +__coerce__: (1,) +__rshift__: (1,) +__coerce__: (1,) +__rrshift__: (1,) +__coerce__: (1,) +__lshift__: (1,) +__coerce__: (1,) +__rlshift__: (1,) +__coerce__: (1,) +__and__: (1,) +__coerce__: (1,) +__rand__: (1,) +__coerce__: (1,) +__or__: (1,) +__coerce__: (1,) +__ror__: (1,) +__coerce__: (1,) +__xor__: (1,) +__coerce__: (1,) +__rxor__: (1,) +__contains__: (1,) +__getitem__: (1,) +__setitem__: (1, 1) +__delitem__: (1,) +__getslice__: (0, 42) +__setslice__: (0, 42, 'The Answer') +__delslice__: (0, 42) +__getitem__: (slice(2, 1024, 10),) +__setitem__: (slice(2, 1024, 10), 'A lot') +__delitem__: (slice(2, 1024, 10),) +__getitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100),) +__setitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100), 'Strange') +__delitem__: ((slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100),) +__getitem__: (slice(0, 42, None),) +__setitem__: (slice(0, 42, None), 'The Answer') +__delitem__: (slice(0, 42, None),) +__neg__: () +__pos__: () +__abs__: () +__int__: () +__long__: () +__float__: () +__oct__: () +__hex__: () +__hash__: () +__repr__: () +__str__: () +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__coerce__: (1,) +__cmp__: (1,) +__del__: () +__getattr__: ('spam',) +__setattr__: ('eggs', 'spam, spam, spam and ham') +__delattr__: ('cardinal',) Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_coercion ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_coercion (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_coercion Fri May 5 21:25:58 2006 @@ -1,1054 +1,1054 @@ -test_coercion -2 + 2 = 4 -2 += 2 => 4 -2 - 2 = 0 -2 -= 2 => 0 -2 * 2 = 4 -2 *= 2 => 4 -2 / 2 = 1 -2 /= 2 => 1 -2 ** 2 = 4 -2 **= 2 => 4 -2 % 2 = 0 -2 %= 2 => 0 -2 + 4.0 = 6.0 -2 += 4.0 => 6.0 -2 - 4.0 = -2.0 -2 -= 4.0 => -2.0 -2 * 4.0 = 8.0 -2 *= 4.0 => 8.0 -2 / 4.0 = 0.5 -2 /= 4.0 => 0.5 -2 ** 4.0 = 16.0 -2 **= 4.0 => 16.0 -2 % 4.0 = 2.0 -2 %= 4.0 => 2.0 -2 + 2 = 4 -2 += 2 => 4 -2 - 2 = 0 -2 -= 2 => 0 -2 * 2 = 4 -2 *= 2 => 4 -2 / 2 = 1 -2 /= 2 => 1 -2 ** 2 = 4 -2 **= 2 => 4 -2 % 2 = 0 -2 %= 2 => 0 -2 + (2+0j) = (4.0 + 0.0j) -2 += (2+0j) => (4.0 + 0.0j) -2 - (2+0j) = (0.0 + 0.0j) -2 -= (2+0j) => (0.0 + 0.0j) -2 * (2+0j) = (4.0 + 0.0j) -2 *= (2+0j) => (4.0 + 0.0j) -2 / (2+0j) = (1.0 + 0.0j) -2 /= (2+0j) => (1.0 + 0.0j) -2 ** (2+0j) = (4.0 + 0.0j) -2 **= (2+0j) => (4.0 + 0.0j) -2 % (2+0j) = (0.0 + 0.0j) -2 %= (2+0j) => (0.0 + 0.0j) -2 + [1] ... exceptions.TypeError -2 += [1] ... exceptions.TypeError -2 - [1] ... exceptions.TypeError -2 -= [1] ... exceptions.TypeError -2 * [1] = [1, 1] -2 *= [1] => [1, 1] -2 / [1] ... exceptions.TypeError -2 /= [1] ... exceptions.TypeError -2 ** [1] ... exceptions.TypeError -2 **= [1] ... exceptions.TypeError -2 % [1] ... exceptions.TypeError -2 %= [1] ... exceptions.TypeError -2 + (2,) ... exceptions.TypeError -2 += (2,) ... exceptions.TypeError -2 - (2,) ... exceptions.TypeError -2 -= (2,) ... exceptions.TypeError -2 * (2,) = (2, 2) -2 *= (2,) => (2, 2) -2 / (2,) ... exceptions.TypeError -2 /= (2,) ... exceptions.TypeError -2 ** (2,) ... exceptions.TypeError -2 **= (2,) ... exceptions.TypeError -2 % (2,) ... exceptions.TypeError -2 %= (2,) ... exceptions.TypeError -2 + None ... exceptions.TypeError -2 += None ... exceptions.TypeError -2 - None ... exceptions.TypeError -2 -= None ... exceptions.TypeError -2 * None ... exceptions.TypeError -2 *= None ... exceptions.TypeError -2 / None ... exceptions.TypeError -2 /= None ... exceptions.TypeError -2 ** None ... exceptions.TypeError -2 **= None ... exceptions.TypeError -2 % None ... exceptions.TypeError -2 %= None ... exceptions.TypeError -2 + = 4 -2 += => 4 -2 - = 0 -2 -= => 0 -2 * = 4 -2 *= => 4 -2 / = 1 -2 /= => 1 -2 ** = 4 -2 **= => 4 -2 % = 0 -2 %= => 0 -2 + = 4 -2 += => 4 -2 - = 0 -2 -= => 0 -2 * = 4 -2 *= => 4 -2 / = 1 -2 /= => 1 -2 ** = 4 -2 **= => 4 -2 % = 0 -2 %= => 0 -4.0 + 2 = 6.0 -4.0 += 2 => 6.0 -4.0 - 2 = 2.0 -4.0 -= 2 => 2.0 -4.0 * 2 = 8.0 -4.0 *= 2 => 8.0 -4.0 / 2 = 2.0 -4.0 /= 2 => 2.0 -4.0 ** 2 = 16.0 -4.0 **= 2 => 16.0 -4.0 % 2 = 0.0 -4.0 %= 2 => 0.0 -4.0 + 4.0 = 8.0 -4.0 += 4.0 => 8.0 -4.0 - 4.0 = 0.0 -4.0 -= 4.0 => 0.0 -4.0 * 4.0 = 16.0 -4.0 *= 4.0 => 16.0 -4.0 / 4.0 = 1.0 -4.0 /= 4.0 => 1.0 -4.0 ** 4.0 = 256.0 -4.0 **= 4.0 => 256.0 -4.0 % 4.0 = 0.0 -4.0 %= 4.0 => 0.0 -4.0 + 2 = 6.0 -4.0 += 2 => 6.0 -4.0 - 2 = 2.0 -4.0 -= 2 => 2.0 -4.0 * 2 = 8.0 -4.0 *= 2 => 8.0 -4.0 / 2 = 2.0 -4.0 /= 2 => 2.0 -4.0 ** 2 = 16.0 -4.0 **= 2 => 16.0 -4.0 % 2 = 0.0 -4.0 %= 2 => 0.0 -4.0 + (2+0j) = (6.0 + 0.0j) -4.0 += (2+0j) => (6.0 + 0.0j) -4.0 - (2+0j) = (2.0 + 0.0j) -4.0 -= (2+0j) => (2.0 + 0.0j) -4.0 * (2+0j) = (8.0 + 0.0j) -4.0 *= (2+0j) => (8.0 + 0.0j) -4.0 / (2+0j) = (2.0 + 0.0j) -4.0 /= (2+0j) => (2.0 + 0.0j) -4.0 ** (2+0j) = (16.0 + 0.0j) -4.0 **= (2+0j) => (16.0 + 0.0j) -4.0 % (2+0j) = (0.0 + 0.0j) -4.0 %= (2+0j) => (0.0 + 0.0j) -4.0 + [1] ... exceptions.TypeError -4.0 += [1] ... exceptions.TypeError -4.0 - [1] ... exceptions.TypeError -4.0 -= [1] ... exceptions.TypeError -4.0 * [1] ... exceptions.TypeError -4.0 *= [1] ... exceptions.TypeError -4.0 / [1] ... exceptions.TypeError -4.0 /= [1] ... exceptions.TypeError -4.0 ** [1] ... exceptions.TypeError -4.0 **= [1] ... exceptions.TypeError -4.0 % [1] ... exceptions.TypeError -4.0 %= [1] ... exceptions.TypeError -4.0 + (2,) ... exceptions.TypeError -4.0 += (2,) ... exceptions.TypeError -4.0 - (2,) ... exceptions.TypeError -4.0 -= (2,) ... exceptions.TypeError -4.0 * (2,) ... exceptions.TypeError -4.0 *= (2,) ... exceptions.TypeError -4.0 / (2,) ... exceptions.TypeError -4.0 /= (2,) ... exceptions.TypeError -4.0 ** (2,) ... exceptions.TypeError -4.0 **= (2,) ... exceptions.TypeError -4.0 % (2,) ... exceptions.TypeError -4.0 %= (2,) ... exceptions.TypeError -4.0 + None ... exceptions.TypeError -4.0 += None ... exceptions.TypeError -4.0 - None ... exceptions.TypeError -4.0 -= None ... exceptions.TypeError -4.0 * None ... exceptions.TypeError -4.0 *= None ... exceptions.TypeError -4.0 / None ... exceptions.TypeError -4.0 /= None ... exceptions.TypeError -4.0 ** None ... exceptions.TypeError -4.0 **= None ... exceptions.TypeError -4.0 % None ... exceptions.TypeError -4.0 %= None ... exceptions.TypeError -4.0 + = 6.0 -4.0 += => 6.0 -4.0 - = 2.0 -4.0 -= => 2.0 -4.0 * = 8.0 -4.0 *= => 8.0 -4.0 / = 2.0 -4.0 /= => 2.0 -4.0 ** = 16.0 -4.0 **= => 16.0 -4.0 % = 0.0 -4.0 %= => 0.0 -4.0 + = 6.0 -4.0 += => 6.0 -4.0 - = 2.0 -4.0 -= => 2.0 -4.0 * = 8.0 -4.0 *= => 8.0 -4.0 / = 2.0 -4.0 /= => 2.0 -4.0 ** = 16.0 -4.0 **= => 16.0 -4.0 % = 0.0 -4.0 %= => 0.0 -2 + 2 = 4 -2 += 2 => 4 -2 - 2 = 0 -2 -= 2 => 0 -2 * 2 = 4 -2 *= 2 => 4 -2 / 2 = 1 -2 /= 2 => 1 -2 ** 2 = 4 -2 **= 2 => 4 -2 % 2 = 0 -2 %= 2 => 0 -2 + 4.0 = 6.0 -2 += 4.0 => 6.0 -2 - 4.0 = -2.0 -2 -= 4.0 => -2.0 -2 * 4.0 = 8.0 -2 *= 4.0 => 8.0 -2 / 4.0 = 0.5 -2 /= 4.0 => 0.5 -2 ** 4.0 = 16.0 -2 **= 4.0 => 16.0 -2 % 4.0 = 2.0 -2 %= 4.0 => 2.0 -2 + 2 = 4 -2 += 2 => 4 -2 - 2 = 0 -2 -= 2 => 0 -2 * 2 = 4 -2 *= 2 => 4 -2 / 2 = 1 -2 /= 2 => 1 -2 ** 2 = 4 -2 **= 2 => 4 -2 % 2 = 0 -2 %= 2 => 0 -2 + (2+0j) = (4.0 + 0.0j) -2 += (2+0j) => (4.0 + 0.0j) -2 - (2+0j) = (0.0 + 0.0j) -2 -= (2+0j) => (0.0 + 0.0j) -2 * (2+0j) = (4.0 + 0.0j) -2 *= (2+0j) => (4.0 + 0.0j) -2 / (2+0j) = (1.0 + 0.0j) -2 /= (2+0j) => (1.0 + 0.0j) -2 ** (2+0j) = (4.0 + 0.0j) -2 **= (2+0j) => (4.0 + 0.0j) -2 % (2+0j) = (0.0 + 0.0j) -2 %= (2+0j) => (0.0 + 0.0j) -2 + [1] ... exceptions.TypeError -2 += [1] ... exceptions.TypeError -2 - [1] ... exceptions.TypeError -2 -= [1] ... exceptions.TypeError -2 * [1] = [1, 1] -2 *= [1] => [1, 1] -2 / [1] ... exceptions.TypeError -2 /= [1] ... exceptions.TypeError -2 ** [1] ... exceptions.TypeError -2 **= [1] ... exceptions.TypeError -2 % [1] ... exceptions.TypeError -2 %= [1] ... exceptions.TypeError -2 + (2,) ... exceptions.TypeError -2 += (2,) ... exceptions.TypeError -2 - (2,) ... exceptions.TypeError -2 -= (2,) ... exceptions.TypeError -2 * (2,) = (2, 2) -2 *= (2,) => (2, 2) -2 / (2,) ... exceptions.TypeError -2 /= (2,) ... exceptions.TypeError -2 ** (2,) ... exceptions.TypeError -2 **= (2,) ... exceptions.TypeError -2 % (2,) ... exceptions.TypeError -2 %= (2,) ... exceptions.TypeError -2 + None ... exceptions.TypeError -2 += None ... exceptions.TypeError -2 - None ... exceptions.TypeError -2 -= None ... exceptions.TypeError -2 * None ... exceptions.TypeError -2 *= None ... exceptions.TypeError -2 / None ... exceptions.TypeError -2 /= None ... exceptions.TypeError -2 ** None ... exceptions.TypeError -2 **= None ... exceptions.TypeError -2 % None ... exceptions.TypeError -2 %= None ... exceptions.TypeError -2 + = 4 -2 += => 4 -2 - = 0 -2 -= => 0 -2 * = 4 -2 *= => 4 -2 / = 1 -2 /= => 1 -2 ** = 4 -2 **= => 4 -2 % = 0 -2 %= => 0 -2 + = 4 -2 += => 4 -2 - = 0 -2 -= => 0 -2 * = 4 -2 *= => 4 -2 / = 1 -2 /= => 1 -2 ** = 4 -2 **= => 4 -2 % = 0 -2 %= => 0 -(2+0j) + 2 = (4.0 + 0.0j) -(2+0j) += 2 => (4.0 + 0.0j) -(2+0j) - 2 = (0.0 + 0.0j) -(2+0j) -= 2 => (0.0 + 0.0j) -(2+0j) * 2 = (4.0 + 0.0j) -(2+0j) *= 2 => (4.0 + 0.0j) -(2+0j) / 2 = (1.0 + 0.0j) -(2+0j) /= 2 => (1.0 + 0.0j) -(2+0j) ** 2 = (4.0 + 0.0j) -(2+0j) **= 2 => (4.0 + 0.0j) -(2+0j) % 2 = (0.0 + 0.0j) -(2+0j) %= 2 => (0.0 + 0.0j) -(2+0j) + 4.0 = (6.0 + 0.0j) -(2+0j) += 4.0 => (6.0 + 0.0j) -(2+0j) - 4.0 = (-2.0 + 0.0j) -(2+0j) -= 4.0 => (-2.0 + 0.0j) -(2+0j) * 4.0 = (8.0 + 0.0j) -(2+0j) *= 4.0 => (8.0 + 0.0j) -(2+0j) / 4.0 = (0.5 + 0.0j) -(2+0j) /= 4.0 => (0.5 + 0.0j) -(2+0j) ** 4.0 = (16.0 + 0.0j) -(2+0j) **= 4.0 => (16.0 + 0.0j) -(2+0j) % 4.0 = (2.0 + 0.0j) -(2+0j) %= 4.0 => (2.0 + 0.0j) -(2+0j) + 2 = (4.0 + 0.0j) -(2+0j) += 2 => (4.0 + 0.0j) -(2+0j) - 2 = (0.0 + 0.0j) -(2+0j) -= 2 => (0.0 + 0.0j) -(2+0j) * 2 = (4.0 + 0.0j) -(2+0j) *= 2 => (4.0 + 0.0j) -(2+0j) / 2 = (1.0 + 0.0j) -(2+0j) /= 2 => (1.0 + 0.0j) -(2+0j) ** 2 = (4.0 + 0.0j) -(2+0j) **= 2 => (4.0 + 0.0j) -(2+0j) % 2 = (0.0 + 0.0j) -(2+0j) %= 2 => (0.0 + 0.0j) -(2+0j) + (2+0j) = (4.0 + 0.0j) -(2+0j) += (2+0j) => (4.0 + 0.0j) -(2+0j) - (2+0j) = (0.0 + 0.0j) -(2+0j) -= (2+0j) => (0.0 + 0.0j) -(2+0j) * (2+0j) = (4.0 + 0.0j) -(2+0j) *= (2+0j) => (4.0 + 0.0j) -(2+0j) / (2+0j) = (1.0 + 0.0j) -(2+0j) /= (2+0j) => (1.0 + 0.0j) -(2+0j) ** (2+0j) = (4.0 + 0.0j) -(2+0j) **= (2+0j) => (4.0 + 0.0j) -(2+0j) % (2+0j) = (0.0 + 0.0j) -(2+0j) %= (2+0j) => (0.0 + 0.0j) -(2+0j) + [1] ... exceptions.TypeError -(2+0j) += [1] ... exceptions.TypeError -(2+0j) - [1] ... exceptions.TypeError -(2+0j) -= [1] ... exceptions.TypeError -(2+0j) * [1] ... exceptions.TypeError -(2+0j) *= [1] ... exceptions.TypeError -(2+0j) / [1] ... exceptions.TypeError -(2+0j) /= [1] ... exceptions.TypeError -(2+0j) ** [1] ... exceptions.TypeError -(2+0j) **= [1] ... exceptions.TypeError -(2+0j) % [1] ... exceptions.TypeError -(2+0j) %= [1] ... exceptions.TypeError -(2+0j) + (2,) ... exceptions.TypeError -(2+0j) += (2,) ... exceptions.TypeError -(2+0j) - (2,) ... exceptions.TypeError -(2+0j) -= (2,) ... exceptions.TypeError -(2+0j) * (2,) ... exceptions.TypeError -(2+0j) *= (2,) ... exceptions.TypeError -(2+0j) / (2,) ... exceptions.TypeError -(2+0j) /= (2,) ... exceptions.TypeError -(2+0j) ** (2,) ... exceptions.TypeError -(2+0j) **= (2,) ... exceptions.TypeError -(2+0j) % (2,) ... exceptions.TypeError -(2+0j) %= (2,) ... exceptions.TypeError -(2+0j) + None ... exceptions.TypeError -(2+0j) += None ... exceptions.TypeError -(2+0j) - None ... exceptions.TypeError -(2+0j) -= None ... exceptions.TypeError -(2+0j) * None ... exceptions.TypeError -(2+0j) *= None ... exceptions.TypeError -(2+0j) / None ... exceptions.TypeError -(2+0j) /= None ... exceptions.TypeError -(2+0j) ** None ... exceptions.TypeError -(2+0j) **= None ... exceptions.TypeError -(2+0j) % None ... exceptions.TypeError -(2+0j) %= None ... exceptions.TypeError -(2+0j) + = (4.0 + 0.0j) -(2+0j) += => (4.0 + 0.0j) -(2+0j) - = (0.0 + 0.0j) -(2+0j) -= => (0.0 + 0.0j) -(2+0j) * = (4.0 + 0.0j) -(2+0j) *= => (4.0 + 0.0j) -(2+0j) / = (1.0 + 0.0j) -(2+0j) /= => (1.0 + 0.0j) -(2+0j) ** = (4.0 + 0.0j) -(2+0j) **= => (4.0 + 0.0j) -(2+0j) % = (0.0 + 0.0j) -(2+0j) %= => (0.0 + 0.0j) -(2+0j) + = (4.0 + 0.0j) -(2+0j) += => (4.0 + 0.0j) -(2+0j) - = (0.0 + 0.0j) -(2+0j) -= => (0.0 + 0.0j) -(2+0j) * = (4.0 + 0.0j) -(2+0j) *= => (4.0 + 0.0j) -(2+0j) / = (1.0 + 0.0j) -(2+0j) /= => (1.0 + 0.0j) -(2+0j) ** = (4.0 + 0.0j) -(2+0j) **= => (4.0 + 0.0j) -(2+0j) % = (0.0 + 0.0j) -(2+0j) %= => (0.0 + 0.0j) -[1] + 2 ... exceptions.TypeError -[1] += 2 ... exceptions.TypeError -[1] - 2 ... exceptions.TypeError -[1] -= 2 ... exceptions.TypeError -[1] * 2 = [1, 1] -[1] *= 2 => [1, 1] -[1] / 2 ... exceptions.TypeError -[1] /= 2 ... exceptions.TypeError -[1] ** 2 ... exceptions.TypeError -[1] **= 2 ... exceptions.TypeError -[1] % 2 ... exceptions.TypeError -[1] %= 2 ... exceptions.TypeError -[1] + 4.0 ... exceptions.TypeError -[1] += 4.0 ... exceptions.TypeError -[1] - 4.0 ... exceptions.TypeError -[1] -= 4.0 ... exceptions.TypeError -[1] * 4.0 ... exceptions.TypeError -[1] *= 4.0 ... exceptions.TypeError -[1] / 4.0 ... exceptions.TypeError -[1] /= 4.0 ... exceptions.TypeError -[1] ** 4.0 ... exceptions.TypeError -[1] **= 4.0 ... exceptions.TypeError -[1] % 4.0 ... exceptions.TypeError -[1] %= 4.0 ... exceptions.TypeError -[1] + 2 ... exceptions.TypeError -[1] += 2 ... exceptions.TypeError -[1] - 2 ... exceptions.TypeError -[1] -= 2 ... exceptions.TypeError -[1] * 2 = [1, 1] -[1] *= 2 => [1, 1] -[1] / 2 ... exceptions.TypeError -[1] /= 2 ... exceptions.TypeError -[1] ** 2 ... exceptions.TypeError -[1] **= 2 ... exceptions.TypeError -[1] % 2 ... exceptions.TypeError -[1] %= 2 ... exceptions.TypeError -[1] + (2+0j) ... exceptions.TypeError -[1] += (2+0j) ... exceptions.TypeError -[1] - (2+0j) ... exceptions.TypeError -[1] -= (2+0j) ... exceptions.TypeError -[1] * (2+0j) ... exceptions.TypeError -[1] *= (2+0j) ... exceptions.TypeError -[1] / (2+0j) ... exceptions.TypeError -[1] /= (2+0j) ... exceptions.TypeError -[1] ** (2+0j) ... exceptions.TypeError -[1] **= (2+0j) ... exceptions.TypeError -[1] % (2+0j) ... exceptions.TypeError -[1] %= (2+0j) ... exceptions.TypeError -[1] + [1] = [1, 1] -[1] += [1] => [1, 1] -[1] - [1] ... exceptions.TypeError -[1] -= [1] ... exceptions.TypeError -[1] * [1] ... exceptions.TypeError -[1] *= [1] ... exceptions.TypeError -[1] / [1] ... exceptions.TypeError -[1] /= [1] ... exceptions.TypeError -[1] ** [1] ... exceptions.TypeError -[1] **= [1] ... exceptions.TypeError -[1] % [1] ... exceptions.TypeError -[1] %= [1] ... exceptions.TypeError -[1] + (2,) ... exceptions.TypeError -[1] += (2,) => [1, 2] -[1] - (2,) ... exceptions.TypeError -[1] -= (2,) ... exceptions.TypeError -[1] * (2,) ... exceptions.TypeError -[1] *= (2,) ... exceptions.TypeError -[1] / (2,) ... exceptions.TypeError -[1] /= (2,) ... exceptions.TypeError -[1] ** (2,) ... exceptions.TypeError -[1] **= (2,) ... exceptions.TypeError -[1] % (2,) ... exceptions.TypeError -[1] %= (2,) ... exceptions.TypeError -[1] + None ... exceptions.TypeError -[1] += None ... exceptions.TypeError -[1] - None ... exceptions.TypeError -[1] -= None ... exceptions.TypeError -[1] * None ... exceptions.TypeError -[1] *= None ... exceptions.TypeError -[1] / None ... exceptions.TypeError -[1] /= None ... exceptions.TypeError -[1] ** None ... exceptions.TypeError -[1] **= None ... exceptions.TypeError -[1] % None ... exceptions.TypeError -[1] %= None ... exceptions.TypeError -[1] + ... exceptions.TypeError -[1] += ... exceptions.TypeError -[1] - ... exceptions.TypeError -[1] -= ... exceptions.TypeError -[1] * = [1, 1] -[1] *= => [1, 1] -[1] / ... exceptions.TypeError -[1] /= ... exceptions.TypeError -[1] ** ... exceptions.TypeError -[1] **= ... exceptions.TypeError -[1] % ... exceptions.TypeError -[1] %= ... exceptions.TypeError -[1] + ... exceptions.TypeError -[1] += ... exceptions.TypeError -[1] - ... exceptions.TypeError -[1] -= ... exceptions.TypeError -[1] * = [1, 1] -[1] *= => [1, 1] -[1] / ... exceptions.TypeError -[1] /= ... exceptions.TypeError -[1] ** ... exceptions.TypeError -[1] **= ... exceptions.TypeError -[1] % ... exceptions.TypeError -[1] %= ... exceptions.TypeError -(2,) + 2 ... exceptions.TypeError -(2,) += 2 ... exceptions.TypeError -(2,) - 2 ... exceptions.TypeError -(2,) -= 2 ... exceptions.TypeError -(2,) * 2 = (2, 2) -(2,) *= 2 => (2, 2) -(2,) / 2 ... exceptions.TypeError -(2,) /= 2 ... exceptions.TypeError -(2,) ** 2 ... exceptions.TypeError -(2,) **= 2 ... exceptions.TypeError -(2,) % 2 ... exceptions.TypeError -(2,) %= 2 ... exceptions.TypeError -(2,) + 4.0 ... exceptions.TypeError -(2,) += 4.0 ... exceptions.TypeError -(2,) - 4.0 ... exceptions.TypeError -(2,) -= 4.0 ... exceptions.TypeError -(2,) * 4.0 ... exceptions.TypeError -(2,) *= 4.0 ... exceptions.TypeError -(2,) / 4.0 ... exceptions.TypeError -(2,) /= 4.0 ... exceptions.TypeError -(2,) ** 4.0 ... exceptions.TypeError -(2,) **= 4.0 ... exceptions.TypeError -(2,) % 4.0 ... exceptions.TypeError -(2,) %= 4.0 ... exceptions.TypeError -(2,) + 2 ... exceptions.TypeError -(2,) += 2 ... exceptions.TypeError -(2,) - 2 ... exceptions.TypeError -(2,) -= 2 ... exceptions.TypeError -(2,) * 2 = (2, 2) -(2,) *= 2 => (2, 2) -(2,) / 2 ... exceptions.TypeError -(2,) /= 2 ... exceptions.TypeError -(2,) ** 2 ... exceptions.TypeError -(2,) **= 2 ... exceptions.TypeError -(2,) % 2 ... exceptions.TypeError -(2,) %= 2 ... exceptions.TypeError -(2,) + (2+0j) ... exceptions.TypeError -(2,) += (2+0j) ... exceptions.TypeError -(2,) - (2+0j) ... exceptions.TypeError -(2,) -= (2+0j) ... exceptions.TypeError -(2,) * (2+0j) ... exceptions.TypeError -(2,) *= (2+0j) ... exceptions.TypeError -(2,) / (2+0j) ... exceptions.TypeError -(2,) /= (2+0j) ... exceptions.TypeError -(2,) ** (2+0j) ... exceptions.TypeError -(2,) **= (2+0j) ... exceptions.TypeError -(2,) % (2+0j) ... exceptions.TypeError -(2,) %= (2+0j) ... exceptions.TypeError -(2,) + [1] ... exceptions.TypeError -(2,) += [1] ... exceptions.TypeError -(2,) - [1] ... exceptions.TypeError -(2,) -= [1] ... exceptions.TypeError -(2,) * [1] ... exceptions.TypeError -(2,) *= [1] ... exceptions.TypeError -(2,) / [1] ... exceptions.TypeError -(2,) /= [1] ... exceptions.TypeError -(2,) ** [1] ... exceptions.TypeError -(2,) **= [1] ... exceptions.TypeError -(2,) % [1] ... exceptions.TypeError -(2,) %= [1] ... exceptions.TypeError -(2,) + (2,) = (2, 2) -(2,) += (2,) => (2, 2) -(2,) - (2,) ... exceptions.TypeError -(2,) -= (2,) ... exceptions.TypeError -(2,) * (2,) ... exceptions.TypeError -(2,) *= (2,) ... exceptions.TypeError -(2,) / (2,) ... exceptions.TypeError -(2,) /= (2,) ... exceptions.TypeError -(2,) ** (2,) ... exceptions.TypeError -(2,) **= (2,) ... exceptions.TypeError -(2,) % (2,) ... exceptions.TypeError -(2,) %= (2,) ... exceptions.TypeError -(2,) + None ... exceptions.TypeError -(2,) += None ... exceptions.TypeError -(2,) - None ... exceptions.TypeError -(2,) -= None ... exceptions.TypeError -(2,) * None ... exceptions.TypeError -(2,) *= None ... exceptions.TypeError -(2,) / None ... exceptions.TypeError -(2,) /= None ... exceptions.TypeError -(2,) ** None ... exceptions.TypeError -(2,) **= None ... exceptions.TypeError -(2,) % None ... exceptions.TypeError -(2,) %= None ... exceptions.TypeError -(2,) + ... exceptions.TypeError -(2,) += ... exceptions.TypeError -(2,) - ... exceptions.TypeError -(2,) -= ... exceptions.TypeError -(2,) * = (2, 2) -(2,) *= => (2, 2) -(2,) / ... exceptions.TypeError -(2,) /= ... exceptions.TypeError -(2,) ** ... exceptions.TypeError -(2,) **= ... exceptions.TypeError -(2,) % ... exceptions.TypeError -(2,) %= ... exceptions.TypeError -(2,) + ... exceptions.TypeError -(2,) += ... exceptions.TypeError -(2,) - ... exceptions.TypeError -(2,) -= ... exceptions.TypeError -(2,) * = (2, 2) -(2,) *= => (2, 2) -(2,) / ... exceptions.TypeError -(2,) /= ... exceptions.TypeError -(2,) ** ... exceptions.TypeError -(2,) **= ... exceptions.TypeError -(2,) % ... exceptions.TypeError -(2,) %= ... exceptions.TypeError -None + 2 ... exceptions.TypeError -None += 2 ... exceptions.TypeError -None - 2 ... exceptions.TypeError -None -= 2 ... exceptions.TypeError -None * 2 ... exceptions.TypeError -None *= 2 ... exceptions.TypeError -None / 2 ... exceptions.TypeError -None /= 2 ... exceptions.TypeError -None ** 2 ... exceptions.TypeError -None **= 2 ... exceptions.TypeError -None % 2 ... exceptions.TypeError -None %= 2 ... exceptions.TypeError -None + 4.0 ... exceptions.TypeError -None += 4.0 ... exceptions.TypeError -None - 4.0 ... exceptions.TypeError -None -= 4.0 ... exceptions.TypeError -None * 4.0 ... exceptions.TypeError -None *= 4.0 ... exceptions.TypeError -None / 4.0 ... exceptions.TypeError -None /= 4.0 ... exceptions.TypeError -None ** 4.0 ... exceptions.TypeError -None **= 4.0 ... exceptions.TypeError -None % 4.0 ... exceptions.TypeError -None %= 4.0 ... exceptions.TypeError -None + 2 ... exceptions.TypeError -None += 2 ... exceptions.TypeError -None - 2 ... exceptions.TypeError -None -= 2 ... exceptions.TypeError -None * 2 ... exceptions.TypeError -None *= 2 ... exceptions.TypeError -None / 2 ... exceptions.TypeError -None /= 2 ... exceptions.TypeError -None ** 2 ... exceptions.TypeError -None **= 2 ... exceptions.TypeError -None % 2 ... exceptions.TypeError -None %= 2 ... exceptions.TypeError -None + (2+0j) ... exceptions.TypeError -None += (2+0j) ... exceptions.TypeError -None - (2+0j) ... exceptions.TypeError -None -= (2+0j) ... exceptions.TypeError -None * (2+0j) ... exceptions.TypeError -None *= (2+0j) ... exceptions.TypeError -None / (2+0j) ... exceptions.TypeError -None /= (2+0j) ... exceptions.TypeError -None ** (2+0j) ... exceptions.TypeError -None **= (2+0j) ... exceptions.TypeError -None % (2+0j) ... exceptions.TypeError -None %= (2+0j) ... exceptions.TypeError -None + [1] ... exceptions.TypeError -None += [1] ... exceptions.TypeError -None - [1] ... exceptions.TypeError -None -= [1] ... exceptions.TypeError -None * [1] ... exceptions.TypeError -None *= [1] ... exceptions.TypeError -None / [1] ... exceptions.TypeError -None /= [1] ... exceptions.TypeError -None ** [1] ... exceptions.TypeError -None **= [1] ... exceptions.TypeError -None % [1] ... exceptions.TypeError -None %= [1] ... exceptions.TypeError -None + (2,) ... exceptions.TypeError -None += (2,) ... exceptions.TypeError -None - (2,) ... exceptions.TypeError -None -= (2,) ... exceptions.TypeError -None * (2,) ... exceptions.TypeError -None *= (2,) ... exceptions.TypeError -None / (2,) ... exceptions.TypeError -None /= (2,) ... exceptions.TypeError -None ** (2,) ... exceptions.TypeError -None **= (2,) ... exceptions.TypeError -None % (2,) ... exceptions.TypeError -None %= (2,) ... exceptions.TypeError -None + None ... exceptions.TypeError -None += None ... exceptions.TypeError -None - None ... exceptions.TypeError -None -= None ... exceptions.TypeError -None * None ... exceptions.TypeError -None *= None ... exceptions.TypeError -None / None ... exceptions.TypeError -None /= None ... exceptions.TypeError -None ** None ... exceptions.TypeError -None **= None ... exceptions.TypeError -None % None ... exceptions.TypeError -None %= None ... exceptions.TypeError -None + ... exceptions.TypeError -None += ... exceptions.TypeError -None - ... exceptions.TypeError -None -= ... exceptions.TypeError -None * ... exceptions.TypeError -None *= ... exceptions.TypeError -None / ... exceptions.TypeError -None /= ... exceptions.TypeError -None ** ... exceptions.TypeError -None **= ... exceptions.TypeError -None % ... exceptions.TypeError -None %= ... exceptions.TypeError -None + ... exceptions.TypeError -None += ... exceptions.TypeError -None - ... exceptions.TypeError -None -= ... exceptions.TypeError -None * ... exceptions.TypeError -None *= ... exceptions.TypeError -None / ... exceptions.TypeError -None /= ... exceptions.TypeError -None ** ... exceptions.TypeError -None **= ... exceptions.TypeError -None % ... exceptions.TypeError -None %= ... exceptions.TypeError - + 2 = 4 - += 2 => 4 - - 2 = 0 - -= 2 => 0 - * 2 = 4 - *= 2 => 4 - / 2 = 1 - /= 2 => 1 - ** 2 = 4 - **= 2 => 4 - % 2 = 0 - %= 2 => 0 - + 4.0 = 6.0 - += 4.0 => 6.0 - - 4.0 = -2.0 - -= 4.0 => -2.0 - * 4.0 = 8.0 - *= 4.0 => 8.0 - / 4.0 = 0.5 - /= 4.0 => 0.5 - ** 4.0 = 16.0 - **= 4.0 => 16.0 - % 4.0 = 2.0 - %= 4.0 => 2.0 - + 2 = 4 - += 2 => 4 - - 2 = 0 - -= 2 => 0 - * 2 = 4 - *= 2 => 4 - / 2 = 1 - /= 2 => 1 - ** 2 = 4 - **= 2 => 4 - % 2 = 0 - %= 2 => 0 - + (2+0j) = (4.0 + 0.0j) - += (2+0j) => (4.0 + 0.0j) - - (2+0j) = (0.0 + 0.0j) - -= (2+0j) => (0.0 + 0.0j) - * (2+0j) = (4.0 + 0.0j) - *= (2+0j) => (4.0 + 0.0j) - / (2+0j) = (1.0 + 0.0j) - /= (2+0j) => (1.0 + 0.0j) - ** (2+0j) = (4.0 + 0.0j) - **= (2+0j) => (4.0 + 0.0j) - % (2+0j) = (0.0 + 0.0j) - %= (2+0j) => (0.0 + 0.0j) - + [1] ... exceptions.TypeError - += [1] ... exceptions.TypeError - - [1] ... exceptions.TypeError - -= [1] ... exceptions.TypeError - * [1] = [1, 1] - *= [1] => [1, 1] - / [1] ... exceptions.TypeError - /= [1] ... exceptions.TypeError - ** [1] ... exceptions.TypeError - **= [1] ... exceptions.TypeError - % [1] ... exceptions.TypeError - %= [1] ... exceptions.TypeError - + (2,) ... exceptions.TypeError - += (2,) ... exceptions.TypeError - - (2,) ... exceptions.TypeError - -= (2,) ... exceptions.TypeError - * (2,) = (2, 2) - *= (2,) => (2, 2) - / (2,) ... exceptions.TypeError - /= (2,) ... exceptions.TypeError - ** (2,) ... exceptions.TypeError - **= (2,) ... exceptions.TypeError - % (2,) ... exceptions.TypeError - %= (2,) ... exceptions.TypeError - + None ... exceptions.TypeError - += None ... exceptions.TypeError - - None ... exceptions.TypeError - -= None ... exceptions.TypeError - * None ... exceptions.TypeError - *= None ... exceptions.TypeError - / None ... exceptions.TypeError - /= None ... exceptions.TypeError - ** None ... exceptions.TypeError - **= None ... exceptions.TypeError - % None ... exceptions.TypeError - %= None ... exceptions.TypeError - + = 4 - += => 4 - - = 0 - -= => 0 - * = 4 - *= => 4 - / = 1 - /= => 1 - ** = 4 - **= => 4 - % = 0 - %= => 0 - + = 4 - += => 4 - - = 0 - -= => 0 - * = 4 - *= => 4 - / = 1 - /= => 1 - ** = 4 - **= => 4 - % = 0 - %= => 0 - + 2 = 4 - += 2 => 4 - - 2 = 0 - -= 2 => 0 - * 2 = 4 - *= 2 => 4 - / 2 = 1 - /= 2 => 1 - ** 2 = 4 - **= 2 => 4 - % 2 = 0 - %= 2 => 0 - + 4.0 = 6.0 - += 4.0 => 6.0 - - 4.0 = -2.0 - -= 4.0 => -2.0 - * 4.0 = 8.0 - *= 4.0 => 8.0 - / 4.0 = 0.5 - /= 4.0 => 0.5 - ** 4.0 = 16.0 - **= 4.0 => 16.0 - % 4.0 = 2.0 - %= 4.0 => 2.0 - + 2 = 4 - += 2 => 4 - - 2 = 0 - -= 2 => 0 - * 2 = 4 - *= 2 => 4 - / 2 = 1 - /= 2 => 1 - ** 2 = 4 - **= 2 => 4 - % 2 = 0 - %= 2 => 0 - + (2+0j) = (4.0 + 0.0j) - += (2+0j) => (4.0 + 0.0j) - - (2+0j) = (0.0 + 0.0j) - -= (2+0j) => (0.0 + 0.0j) - * (2+0j) = (4.0 + 0.0j) - *= (2+0j) => (4.0 + 0.0j) - / (2+0j) = (1.0 + 0.0j) - /= (2+0j) => (1.0 + 0.0j) - ** (2+0j) = (4.0 + 0.0j) - **= (2+0j) => (4.0 + 0.0j) - % (2+0j) = (0.0 + 0.0j) - %= (2+0j) => (0.0 + 0.0j) - + [1] ... exceptions.TypeError - += [1] ... exceptions.TypeError - - [1] ... exceptions.TypeError - -= [1] ... exceptions.TypeError - * [1] = [1, 1] - *= [1] => [1, 1] - / [1] ... exceptions.TypeError - /= [1] ... exceptions.TypeError - ** [1] ... exceptions.TypeError - **= [1] ... exceptions.TypeError - % [1] ... exceptions.TypeError - %= [1] ... exceptions.TypeError - + (2,) ... exceptions.TypeError - += (2,) ... exceptions.TypeError - - (2,) ... exceptions.TypeError - -= (2,) ... exceptions.TypeError - * (2,) = (2, 2) - *= (2,) => (2, 2) - / (2,) ... exceptions.TypeError - /= (2,) ... exceptions.TypeError - ** (2,) ... exceptions.TypeError - **= (2,) ... exceptions.TypeError - % (2,) ... exceptions.TypeError - %= (2,) ... exceptions.TypeError - + None ... exceptions.TypeError - += None ... exceptions.TypeError - - None ... exceptions.TypeError - -= None ... exceptions.TypeError - * None ... exceptions.TypeError - *= None ... exceptions.TypeError - / None ... exceptions.TypeError - /= None ... exceptions.TypeError - ** None ... exceptions.TypeError - **= None ... exceptions.TypeError - % None ... exceptions.TypeError - %= None ... exceptions.TypeError - + = 4 - += => 4 - - = 0 - -= => 0 - * = 4 - *= => 4 - / = 1 - /= => 1 - ** = 4 - **= => 4 - % = 0 - %= => 0 - + = 4 - += => 4 - - = 0 - -= => 0 - * = 4 - *= => 4 - / = 1 - /= => 1 - ** = 4 - **= => 4 - % = 0 - %= => 0 -divmod(2, 2) = (1, 0) -divmod(2, 4.0) = (0.0, 2.0) -divmod(2, 2) = (1L, 0L) -divmod(2, (2+0j)) = ((1+0j), 0j) -divmod(2, [1]) ... exceptions.TypeError -divmod(2, (2,)) ... exceptions.TypeError -divmod(2, None) ... exceptions.TypeError -divmod(2, ) ... exceptions.TypeError -divmod(2, ) = (1, 0) -divmod(4.0, 2) = (2.0, 0.0) -divmod(4.0, 4.0) = (1.0, 0.0) -divmod(4.0, 2) = (2.0, 0.0) -divmod(4.0, (2+0j)) = ((2+0j), 0j) -divmod(4.0, [1]) ... exceptions.TypeError -divmod(4.0, (2,)) ... exceptions.TypeError -divmod(4.0, None) ... exceptions.TypeError -divmod(4.0, ) ... exceptions.TypeError -divmod(4.0, ) = (2.0, 0.0) -divmod(2, 2) = (1L, 0L) -divmod(2, 4.0) = (0.0, 2.0) -divmod(2, 2) = (1L, 0L) -divmod(2, (2+0j)) = ((1+0j), 0j) -divmod(2, [1]) ... exceptions.TypeError -divmod(2, (2,)) ... exceptions.TypeError -divmod(2, None) ... exceptions.TypeError -divmod(2, ) ... exceptions.TypeError -divmod(2, ) = (1L, 0L) -divmod((2+0j), 2) = ((1+0j), 0j) -divmod((2+0j), 4.0) = (0j, (2+0j)) -divmod((2+0j), 2) = ((1+0j), 0j) -divmod((2+0j), (2+0j)) = ((1+0j), 0j) -divmod((2+0j), [1]) ... exceptions.TypeError -divmod((2+0j), (2,)) ... exceptions.TypeError -divmod((2+0j), None) ... exceptions.TypeError -divmod((2+0j), ) ... exceptions.TypeError -divmod((2+0j), ) = ((1+0j), 0j) -divmod([1], 2) ... exceptions.TypeError -divmod([1], 4.0) ... exceptions.TypeError -divmod([1], 2) ... exceptions.TypeError -divmod([1], (2+0j)) ... exceptions.TypeError -divmod([1], [1]) ... exceptions.TypeError -divmod([1], (2,)) ... exceptions.TypeError -divmod([1], None) ... exceptions.TypeError -divmod([1], ) ... exceptions.TypeError -divmod([1], ) ... exceptions.TypeError -divmod((2,), 2) ... exceptions.TypeError -divmod((2,), 4.0) ... exceptions.TypeError -divmod((2,), 2) ... exceptions.TypeError -divmod((2,), (2+0j)) ... exceptions.TypeError -divmod((2,), [1]) ... exceptions.TypeError -divmod((2,), (2,)) ... exceptions.TypeError -divmod((2,), None) ... exceptions.TypeError -divmod((2,), ) ... exceptions.TypeError -divmod((2,), ) ... exceptions.TypeError -divmod(None, 2) ... exceptions.TypeError -divmod(None, 4.0) ... exceptions.TypeError -divmod(None, 2) ... exceptions.TypeError -divmod(None, (2+0j)) ... exceptions.TypeError -divmod(None, [1]) ... exceptions.TypeError -divmod(None, (2,)) ... exceptions.TypeError -divmod(None, None) ... exceptions.TypeError -divmod(None, ) ... exceptions.TypeError -divmod(None, ) ... exceptions.TypeError -divmod(, 2) ... exceptions.TypeError -divmod(, 4.0) ... exceptions.TypeError -divmod(, 2) ... exceptions.TypeError -divmod(, (2+0j)) ... exceptions.TypeError -divmod(, [1]) ... exceptions.TypeError -divmod(, (2,)) ... exceptions.TypeError -divmod(, None) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError -divmod(, 2) = (1, 0) -divmod(, 4.0) = (0.0, 2.0) -divmod(, 2) = (1L, 0L) -divmod(, (2+0j)) = ((1+0j), 0j) -divmod(, [1]) ... exceptions.TypeError -divmod(, (2,)) ... exceptions.TypeError -divmod(, None) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError -divmod(, ) = (1, 0) +test_coercion +2 + 2 = 4 +2 += 2 => 4 +2 - 2 = 0 +2 -= 2 => 0 +2 * 2 = 4 +2 *= 2 => 4 +2 / 2 = 1 +2 /= 2 => 1 +2 ** 2 = 4 +2 **= 2 => 4 +2 % 2 = 0 +2 %= 2 => 0 +2 + 4.0 = 6.0 +2 += 4.0 => 6.0 +2 - 4.0 = -2.0 +2 -= 4.0 => -2.0 +2 * 4.0 = 8.0 +2 *= 4.0 => 8.0 +2 / 4.0 = 0.5 +2 /= 4.0 => 0.5 +2 ** 4.0 = 16.0 +2 **= 4.0 => 16.0 +2 % 4.0 = 2.0 +2 %= 4.0 => 2.0 +2 + 2 = 4 +2 += 2 => 4 +2 - 2 = 0 +2 -= 2 => 0 +2 * 2 = 4 +2 *= 2 => 4 +2 / 2 = 1 +2 /= 2 => 1 +2 ** 2 = 4 +2 **= 2 => 4 +2 % 2 = 0 +2 %= 2 => 0 +2 + (2+0j) = (4.0 + 0.0j) +2 += (2+0j) => (4.0 + 0.0j) +2 - (2+0j) = (0.0 + 0.0j) +2 -= (2+0j) => (0.0 + 0.0j) +2 * (2+0j) = (4.0 + 0.0j) +2 *= (2+0j) => (4.0 + 0.0j) +2 / (2+0j) = (1.0 + 0.0j) +2 /= (2+0j) => (1.0 + 0.0j) +2 ** (2+0j) = (4.0 + 0.0j) +2 **= (2+0j) => (4.0 + 0.0j) +2 % (2+0j) = (0.0 + 0.0j) +2 %= (2+0j) => (0.0 + 0.0j) +2 + [1] ... exceptions.TypeError +2 += [1] ... exceptions.TypeError +2 - [1] ... exceptions.TypeError +2 -= [1] ... exceptions.TypeError +2 * [1] = [1, 1] +2 *= [1] => [1, 1] +2 / [1] ... exceptions.TypeError +2 /= [1] ... exceptions.TypeError +2 ** [1] ... exceptions.TypeError +2 **= [1] ... exceptions.TypeError +2 % [1] ... exceptions.TypeError +2 %= [1] ... exceptions.TypeError +2 + (2,) ... exceptions.TypeError +2 += (2,) ... exceptions.TypeError +2 - (2,) ... exceptions.TypeError +2 -= (2,) ... exceptions.TypeError +2 * (2,) = (2, 2) +2 *= (2,) => (2, 2) +2 / (2,) ... exceptions.TypeError +2 /= (2,) ... exceptions.TypeError +2 ** (2,) ... exceptions.TypeError +2 **= (2,) ... exceptions.TypeError +2 % (2,) ... exceptions.TypeError +2 %= (2,) ... exceptions.TypeError +2 + None ... exceptions.TypeError +2 += None ... exceptions.TypeError +2 - None ... exceptions.TypeError +2 -= None ... exceptions.TypeError +2 * None ... exceptions.TypeError +2 *= None ... exceptions.TypeError +2 / None ... exceptions.TypeError +2 /= None ... exceptions.TypeError +2 ** None ... exceptions.TypeError +2 **= None ... exceptions.TypeError +2 % None ... exceptions.TypeError +2 %= None ... exceptions.TypeError +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 +4.0 + 2 = 6.0 +4.0 += 2 => 6.0 +4.0 - 2 = 2.0 +4.0 -= 2 => 2.0 +4.0 * 2 = 8.0 +4.0 *= 2 => 8.0 +4.0 / 2 = 2.0 +4.0 /= 2 => 2.0 +4.0 ** 2 = 16.0 +4.0 **= 2 => 16.0 +4.0 % 2 = 0.0 +4.0 %= 2 => 0.0 +4.0 + 4.0 = 8.0 +4.0 += 4.0 => 8.0 +4.0 - 4.0 = 0.0 +4.0 -= 4.0 => 0.0 +4.0 * 4.0 = 16.0 +4.0 *= 4.0 => 16.0 +4.0 / 4.0 = 1.0 +4.0 /= 4.0 => 1.0 +4.0 ** 4.0 = 256.0 +4.0 **= 4.0 => 256.0 +4.0 % 4.0 = 0.0 +4.0 %= 4.0 => 0.0 +4.0 + 2 = 6.0 +4.0 += 2 => 6.0 +4.0 - 2 = 2.0 +4.0 -= 2 => 2.0 +4.0 * 2 = 8.0 +4.0 *= 2 => 8.0 +4.0 / 2 = 2.0 +4.0 /= 2 => 2.0 +4.0 ** 2 = 16.0 +4.0 **= 2 => 16.0 +4.0 % 2 = 0.0 +4.0 %= 2 => 0.0 +4.0 + (2+0j) = (6.0 + 0.0j) +4.0 += (2+0j) => (6.0 + 0.0j) +4.0 - (2+0j) = (2.0 + 0.0j) +4.0 -= (2+0j) => (2.0 + 0.0j) +4.0 * (2+0j) = (8.0 + 0.0j) +4.0 *= (2+0j) => (8.0 + 0.0j) +4.0 / (2+0j) = (2.0 + 0.0j) +4.0 /= (2+0j) => (2.0 + 0.0j) +4.0 ** (2+0j) = (16.0 + 0.0j) +4.0 **= (2+0j) => (16.0 + 0.0j) +4.0 % (2+0j) = (0.0 + 0.0j) +4.0 %= (2+0j) => (0.0 + 0.0j) +4.0 + [1] ... exceptions.TypeError +4.0 += [1] ... exceptions.TypeError +4.0 - [1] ... exceptions.TypeError +4.0 -= [1] ... exceptions.TypeError +4.0 * [1] ... exceptions.TypeError +4.0 *= [1] ... exceptions.TypeError +4.0 / [1] ... exceptions.TypeError +4.0 /= [1] ... exceptions.TypeError +4.0 ** [1] ... exceptions.TypeError +4.0 **= [1] ... exceptions.TypeError +4.0 % [1] ... exceptions.TypeError +4.0 %= [1] ... exceptions.TypeError +4.0 + (2,) ... exceptions.TypeError +4.0 += (2,) ... exceptions.TypeError +4.0 - (2,) ... exceptions.TypeError +4.0 -= (2,) ... exceptions.TypeError +4.0 * (2,) ... exceptions.TypeError +4.0 *= (2,) ... exceptions.TypeError +4.0 / (2,) ... exceptions.TypeError +4.0 /= (2,) ... exceptions.TypeError +4.0 ** (2,) ... exceptions.TypeError +4.0 **= (2,) ... exceptions.TypeError +4.0 % (2,) ... exceptions.TypeError +4.0 %= (2,) ... exceptions.TypeError +4.0 + None ... exceptions.TypeError +4.0 += None ... exceptions.TypeError +4.0 - None ... exceptions.TypeError +4.0 -= None ... exceptions.TypeError +4.0 * None ... exceptions.TypeError +4.0 *= None ... exceptions.TypeError +4.0 / None ... exceptions.TypeError +4.0 /= None ... exceptions.TypeError +4.0 ** None ... exceptions.TypeError +4.0 **= None ... exceptions.TypeError +4.0 % None ... exceptions.TypeError +4.0 %= None ... exceptions.TypeError +4.0 + = 6.0 +4.0 += => 6.0 +4.0 - = 2.0 +4.0 -= => 2.0 +4.0 * = 8.0 +4.0 *= => 8.0 +4.0 / = 2.0 +4.0 /= => 2.0 +4.0 ** = 16.0 +4.0 **= => 16.0 +4.0 % = 0.0 +4.0 %= => 0.0 +4.0 + = 6.0 +4.0 += => 6.0 +4.0 - = 2.0 +4.0 -= => 2.0 +4.0 * = 8.0 +4.0 *= => 8.0 +4.0 / = 2.0 +4.0 /= => 2.0 +4.0 ** = 16.0 +4.0 **= => 16.0 +4.0 % = 0.0 +4.0 %= => 0.0 +2 + 2 = 4 +2 += 2 => 4 +2 - 2 = 0 +2 -= 2 => 0 +2 * 2 = 4 +2 *= 2 => 4 +2 / 2 = 1 +2 /= 2 => 1 +2 ** 2 = 4 +2 **= 2 => 4 +2 % 2 = 0 +2 %= 2 => 0 +2 + 4.0 = 6.0 +2 += 4.0 => 6.0 +2 - 4.0 = -2.0 +2 -= 4.0 => -2.0 +2 * 4.0 = 8.0 +2 *= 4.0 => 8.0 +2 / 4.0 = 0.5 +2 /= 4.0 => 0.5 +2 ** 4.0 = 16.0 +2 **= 4.0 => 16.0 +2 % 4.0 = 2.0 +2 %= 4.0 => 2.0 +2 + 2 = 4 +2 += 2 => 4 +2 - 2 = 0 +2 -= 2 => 0 +2 * 2 = 4 +2 *= 2 => 4 +2 / 2 = 1 +2 /= 2 => 1 +2 ** 2 = 4 +2 **= 2 => 4 +2 % 2 = 0 +2 %= 2 => 0 +2 + (2+0j) = (4.0 + 0.0j) +2 += (2+0j) => (4.0 + 0.0j) +2 - (2+0j) = (0.0 + 0.0j) +2 -= (2+0j) => (0.0 + 0.0j) +2 * (2+0j) = (4.0 + 0.0j) +2 *= (2+0j) => (4.0 + 0.0j) +2 / (2+0j) = (1.0 + 0.0j) +2 /= (2+0j) => (1.0 + 0.0j) +2 ** (2+0j) = (4.0 + 0.0j) +2 **= (2+0j) => (4.0 + 0.0j) +2 % (2+0j) = (0.0 + 0.0j) +2 %= (2+0j) => (0.0 + 0.0j) +2 + [1] ... exceptions.TypeError +2 += [1] ... exceptions.TypeError +2 - [1] ... exceptions.TypeError +2 -= [1] ... exceptions.TypeError +2 * [1] = [1, 1] +2 *= [1] => [1, 1] +2 / [1] ... exceptions.TypeError +2 /= [1] ... exceptions.TypeError +2 ** [1] ... exceptions.TypeError +2 **= [1] ... exceptions.TypeError +2 % [1] ... exceptions.TypeError +2 %= [1] ... exceptions.TypeError +2 + (2,) ... exceptions.TypeError +2 += (2,) ... exceptions.TypeError +2 - (2,) ... exceptions.TypeError +2 -= (2,) ... exceptions.TypeError +2 * (2,) = (2, 2) +2 *= (2,) => (2, 2) +2 / (2,) ... exceptions.TypeError +2 /= (2,) ... exceptions.TypeError +2 ** (2,) ... exceptions.TypeError +2 **= (2,) ... exceptions.TypeError +2 % (2,) ... exceptions.TypeError +2 %= (2,) ... exceptions.TypeError +2 + None ... exceptions.TypeError +2 += None ... exceptions.TypeError +2 - None ... exceptions.TypeError +2 -= None ... exceptions.TypeError +2 * None ... exceptions.TypeError +2 *= None ... exceptions.TypeError +2 / None ... exceptions.TypeError +2 /= None ... exceptions.TypeError +2 ** None ... exceptions.TypeError +2 **= None ... exceptions.TypeError +2 % None ... exceptions.TypeError +2 %= None ... exceptions.TypeError +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 +(2+0j) + 2 = (4.0 + 0.0j) +(2+0j) += 2 => (4.0 + 0.0j) +(2+0j) - 2 = (0.0 + 0.0j) +(2+0j) -= 2 => (0.0 + 0.0j) +(2+0j) * 2 = (4.0 + 0.0j) +(2+0j) *= 2 => (4.0 + 0.0j) +(2+0j) / 2 = (1.0 + 0.0j) +(2+0j) /= 2 => (1.0 + 0.0j) +(2+0j) ** 2 = (4.0 + 0.0j) +(2+0j) **= 2 => (4.0 + 0.0j) +(2+0j) % 2 = (0.0 + 0.0j) +(2+0j) %= 2 => (0.0 + 0.0j) +(2+0j) + 4.0 = (6.0 + 0.0j) +(2+0j) += 4.0 => (6.0 + 0.0j) +(2+0j) - 4.0 = (-2.0 + 0.0j) +(2+0j) -= 4.0 => (-2.0 + 0.0j) +(2+0j) * 4.0 = (8.0 + 0.0j) +(2+0j) *= 4.0 => (8.0 + 0.0j) +(2+0j) / 4.0 = (0.5 + 0.0j) +(2+0j) /= 4.0 => (0.5 + 0.0j) +(2+0j) ** 4.0 = (16.0 + 0.0j) +(2+0j) **= 4.0 => (16.0 + 0.0j) +(2+0j) % 4.0 = (2.0 + 0.0j) +(2+0j) %= 4.0 => (2.0 + 0.0j) +(2+0j) + 2 = (4.0 + 0.0j) +(2+0j) += 2 => (4.0 + 0.0j) +(2+0j) - 2 = (0.0 + 0.0j) +(2+0j) -= 2 => (0.0 + 0.0j) +(2+0j) * 2 = (4.0 + 0.0j) +(2+0j) *= 2 => (4.0 + 0.0j) +(2+0j) / 2 = (1.0 + 0.0j) +(2+0j) /= 2 => (1.0 + 0.0j) +(2+0j) ** 2 = (4.0 + 0.0j) +(2+0j) **= 2 => (4.0 + 0.0j) +(2+0j) % 2 = (0.0 + 0.0j) +(2+0j) %= 2 => (0.0 + 0.0j) +(2+0j) + (2+0j) = (4.0 + 0.0j) +(2+0j) += (2+0j) => (4.0 + 0.0j) +(2+0j) - (2+0j) = (0.0 + 0.0j) +(2+0j) -= (2+0j) => (0.0 + 0.0j) +(2+0j) * (2+0j) = (4.0 + 0.0j) +(2+0j) *= (2+0j) => (4.0 + 0.0j) +(2+0j) / (2+0j) = (1.0 + 0.0j) +(2+0j) /= (2+0j) => (1.0 + 0.0j) +(2+0j) ** (2+0j) = (4.0 + 0.0j) +(2+0j) **= (2+0j) => (4.0 + 0.0j) +(2+0j) % (2+0j) = (0.0 + 0.0j) +(2+0j) %= (2+0j) => (0.0 + 0.0j) +(2+0j) + [1] ... exceptions.TypeError +(2+0j) += [1] ... exceptions.TypeError +(2+0j) - [1] ... exceptions.TypeError +(2+0j) -= [1] ... exceptions.TypeError +(2+0j) * [1] ... exceptions.TypeError +(2+0j) *= [1] ... exceptions.TypeError +(2+0j) / [1] ... exceptions.TypeError +(2+0j) /= [1] ... exceptions.TypeError +(2+0j) ** [1] ... exceptions.TypeError +(2+0j) **= [1] ... exceptions.TypeError +(2+0j) % [1] ... exceptions.TypeError +(2+0j) %= [1] ... exceptions.TypeError +(2+0j) + (2,) ... exceptions.TypeError +(2+0j) += (2,) ... exceptions.TypeError +(2+0j) - (2,) ... exceptions.TypeError +(2+0j) -= (2,) ... exceptions.TypeError +(2+0j) * (2,) ... exceptions.TypeError +(2+0j) *= (2,) ... exceptions.TypeError +(2+0j) / (2,) ... exceptions.TypeError +(2+0j) /= (2,) ... exceptions.TypeError +(2+0j) ** (2,) ... exceptions.TypeError +(2+0j) **= (2,) ... exceptions.TypeError +(2+0j) % (2,) ... exceptions.TypeError +(2+0j) %= (2,) ... exceptions.TypeError +(2+0j) + None ... exceptions.TypeError +(2+0j) += None ... exceptions.TypeError +(2+0j) - None ... exceptions.TypeError +(2+0j) -= None ... exceptions.TypeError +(2+0j) * None ... exceptions.TypeError +(2+0j) *= None ... exceptions.TypeError +(2+0j) / None ... exceptions.TypeError +(2+0j) /= None ... exceptions.TypeError +(2+0j) ** None ... exceptions.TypeError +(2+0j) **= None ... exceptions.TypeError +(2+0j) % None ... exceptions.TypeError +(2+0j) %= None ... exceptions.TypeError +(2+0j) + = (4.0 + 0.0j) +(2+0j) += => (4.0 + 0.0j) +(2+0j) - = (0.0 + 0.0j) +(2+0j) -= => (0.0 + 0.0j) +(2+0j) * = (4.0 + 0.0j) +(2+0j) *= => (4.0 + 0.0j) +(2+0j) / = (1.0 + 0.0j) +(2+0j) /= => (1.0 + 0.0j) +(2+0j) ** = (4.0 + 0.0j) +(2+0j) **= => (4.0 + 0.0j) +(2+0j) % = (0.0 + 0.0j) +(2+0j) %= => (0.0 + 0.0j) +(2+0j) + = (4.0 + 0.0j) +(2+0j) += => (4.0 + 0.0j) +(2+0j) - = (0.0 + 0.0j) +(2+0j) -= => (0.0 + 0.0j) +(2+0j) * = (4.0 + 0.0j) +(2+0j) *= => (4.0 + 0.0j) +(2+0j) / = (1.0 + 0.0j) +(2+0j) /= => (1.0 + 0.0j) +(2+0j) ** = (4.0 + 0.0j) +(2+0j) **= => (4.0 + 0.0j) +(2+0j) % = (0.0 + 0.0j) +(2+0j) %= => (0.0 + 0.0j) +[1] + 2 ... exceptions.TypeError +[1] += 2 ... exceptions.TypeError +[1] - 2 ... exceptions.TypeError +[1] -= 2 ... exceptions.TypeError +[1] * 2 = [1, 1] +[1] *= 2 => [1, 1] +[1] / 2 ... exceptions.TypeError +[1] /= 2 ... exceptions.TypeError +[1] ** 2 ... exceptions.TypeError +[1] **= 2 ... exceptions.TypeError +[1] % 2 ... exceptions.TypeError +[1] %= 2 ... exceptions.TypeError +[1] + 4.0 ... exceptions.TypeError +[1] += 4.0 ... exceptions.TypeError +[1] - 4.0 ... exceptions.TypeError +[1] -= 4.0 ... exceptions.TypeError +[1] * 4.0 ... exceptions.TypeError +[1] *= 4.0 ... exceptions.TypeError +[1] / 4.0 ... exceptions.TypeError +[1] /= 4.0 ... exceptions.TypeError +[1] ** 4.0 ... exceptions.TypeError +[1] **= 4.0 ... exceptions.TypeError +[1] % 4.0 ... exceptions.TypeError +[1] %= 4.0 ... exceptions.TypeError +[1] + 2 ... exceptions.TypeError +[1] += 2 ... exceptions.TypeError +[1] - 2 ... exceptions.TypeError +[1] -= 2 ... exceptions.TypeError +[1] * 2 = [1, 1] +[1] *= 2 => [1, 1] +[1] / 2 ... exceptions.TypeError +[1] /= 2 ... exceptions.TypeError +[1] ** 2 ... exceptions.TypeError +[1] **= 2 ... exceptions.TypeError +[1] % 2 ... exceptions.TypeError +[1] %= 2 ... exceptions.TypeError +[1] + (2+0j) ... exceptions.TypeError +[1] += (2+0j) ... exceptions.TypeError +[1] - (2+0j) ... exceptions.TypeError +[1] -= (2+0j) ... exceptions.TypeError +[1] * (2+0j) ... exceptions.TypeError +[1] *= (2+0j) ... exceptions.TypeError +[1] / (2+0j) ... exceptions.TypeError +[1] /= (2+0j) ... exceptions.TypeError +[1] ** (2+0j) ... exceptions.TypeError +[1] **= (2+0j) ... exceptions.TypeError +[1] % (2+0j) ... exceptions.TypeError +[1] %= (2+0j) ... exceptions.TypeError +[1] + [1] = [1, 1] +[1] += [1] => [1, 1] +[1] - [1] ... exceptions.TypeError +[1] -= [1] ... exceptions.TypeError +[1] * [1] ... exceptions.TypeError +[1] *= [1] ... exceptions.TypeError +[1] / [1] ... exceptions.TypeError +[1] /= [1] ... exceptions.TypeError +[1] ** [1] ... exceptions.TypeError +[1] **= [1] ... exceptions.TypeError +[1] % [1] ... exceptions.TypeError +[1] %= [1] ... exceptions.TypeError +[1] + (2,) ... exceptions.TypeError +[1] += (2,) => [1, 2] +[1] - (2,) ... exceptions.TypeError +[1] -= (2,) ... exceptions.TypeError +[1] * (2,) ... exceptions.TypeError +[1] *= (2,) ... exceptions.TypeError +[1] / (2,) ... exceptions.TypeError +[1] /= (2,) ... exceptions.TypeError +[1] ** (2,) ... exceptions.TypeError +[1] **= (2,) ... exceptions.TypeError +[1] % (2,) ... exceptions.TypeError +[1] %= (2,) ... exceptions.TypeError +[1] + None ... exceptions.TypeError +[1] += None ... exceptions.TypeError +[1] - None ... exceptions.TypeError +[1] -= None ... exceptions.TypeError +[1] * None ... exceptions.TypeError +[1] *= None ... exceptions.TypeError +[1] / None ... exceptions.TypeError +[1] /= None ... exceptions.TypeError +[1] ** None ... exceptions.TypeError +[1] **= None ... exceptions.TypeError +[1] % None ... exceptions.TypeError +[1] %= None ... exceptions.TypeError +[1] + ... exceptions.TypeError +[1] += ... exceptions.TypeError +[1] - ... exceptions.TypeError +[1] -= ... exceptions.TypeError +[1] * = [1, 1] +[1] *= => [1, 1] +[1] / ... exceptions.TypeError +[1] /= ... exceptions.TypeError +[1] ** ... exceptions.TypeError +[1] **= ... exceptions.TypeError +[1] % ... exceptions.TypeError +[1] %= ... exceptions.TypeError +[1] + ... exceptions.TypeError +[1] += ... exceptions.TypeError +[1] - ... exceptions.TypeError +[1] -= ... exceptions.TypeError +[1] * = [1, 1] +[1] *= => [1, 1] +[1] / ... exceptions.TypeError +[1] /= ... exceptions.TypeError +[1] ** ... exceptions.TypeError +[1] **= ... exceptions.TypeError +[1] % ... exceptions.TypeError +[1] %= ... exceptions.TypeError +(2,) + 2 ... exceptions.TypeError +(2,) += 2 ... exceptions.TypeError +(2,) - 2 ... exceptions.TypeError +(2,) -= 2 ... exceptions.TypeError +(2,) * 2 = (2, 2) +(2,) *= 2 => (2, 2) +(2,) / 2 ... exceptions.TypeError +(2,) /= 2 ... exceptions.TypeError +(2,) ** 2 ... exceptions.TypeError +(2,) **= 2 ... exceptions.TypeError +(2,) % 2 ... exceptions.TypeError +(2,) %= 2 ... exceptions.TypeError +(2,) + 4.0 ... exceptions.TypeError +(2,) += 4.0 ... exceptions.TypeError +(2,) - 4.0 ... exceptions.TypeError +(2,) -= 4.0 ... exceptions.TypeError +(2,) * 4.0 ... exceptions.TypeError +(2,) *= 4.0 ... exceptions.TypeError +(2,) / 4.0 ... exceptions.TypeError +(2,) /= 4.0 ... exceptions.TypeError +(2,) ** 4.0 ... exceptions.TypeError +(2,) **= 4.0 ... exceptions.TypeError +(2,) % 4.0 ... exceptions.TypeError +(2,) %= 4.0 ... exceptions.TypeError +(2,) + 2 ... exceptions.TypeError +(2,) += 2 ... exceptions.TypeError +(2,) - 2 ... exceptions.TypeError +(2,) -= 2 ... exceptions.TypeError +(2,) * 2 = (2, 2) +(2,) *= 2 => (2, 2) +(2,) / 2 ... exceptions.TypeError +(2,) /= 2 ... exceptions.TypeError +(2,) ** 2 ... exceptions.TypeError +(2,) **= 2 ... exceptions.TypeError +(2,) % 2 ... exceptions.TypeError +(2,) %= 2 ... exceptions.TypeError +(2,) + (2+0j) ... exceptions.TypeError +(2,) += (2+0j) ... exceptions.TypeError +(2,) - (2+0j) ... exceptions.TypeError +(2,) -= (2+0j) ... exceptions.TypeError +(2,) * (2+0j) ... exceptions.TypeError +(2,) *= (2+0j) ... exceptions.TypeError +(2,) / (2+0j) ... exceptions.TypeError +(2,) /= (2+0j) ... exceptions.TypeError +(2,) ** (2+0j) ... exceptions.TypeError +(2,) **= (2+0j) ... exceptions.TypeError +(2,) % (2+0j) ... exceptions.TypeError +(2,) %= (2+0j) ... exceptions.TypeError +(2,) + [1] ... exceptions.TypeError +(2,) += [1] ... exceptions.TypeError +(2,) - [1] ... exceptions.TypeError +(2,) -= [1] ... exceptions.TypeError +(2,) * [1] ... exceptions.TypeError +(2,) *= [1] ... exceptions.TypeError +(2,) / [1] ... exceptions.TypeError +(2,) /= [1] ... exceptions.TypeError +(2,) ** [1] ... exceptions.TypeError +(2,) **= [1] ... exceptions.TypeError +(2,) % [1] ... exceptions.TypeError +(2,) %= [1] ... exceptions.TypeError +(2,) + (2,) = (2, 2) +(2,) += (2,) => (2, 2) +(2,) - (2,) ... exceptions.TypeError +(2,) -= (2,) ... exceptions.TypeError +(2,) * (2,) ... exceptions.TypeError +(2,) *= (2,) ... exceptions.TypeError +(2,) / (2,) ... exceptions.TypeError +(2,) /= (2,) ... exceptions.TypeError +(2,) ** (2,) ... exceptions.TypeError +(2,) **= (2,) ... exceptions.TypeError +(2,) % (2,) ... exceptions.TypeError +(2,) %= (2,) ... exceptions.TypeError +(2,) + None ... exceptions.TypeError +(2,) += None ... exceptions.TypeError +(2,) - None ... exceptions.TypeError +(2,) -= None ... exceptions.TypeError +(2,) * None ... exceptions.TypeError +(2,) *= None ... exceptions.TypeError +(2,) / None ... exceptions.TypeError +(2,) /= None ... exceptions.TypeError +(2,) ** None ... exceptions.TypeError +(2,) **= None ... exceptions.TypeError +(2,) % None ... exceptions.TypeError +(2,) %= None ... exceptions.TypeError +(2,) + ... exceptions.TypeError +(2,) += ... exceptions.TypeError +(2,) - ... exceptions.TypeError +(2,) -= ... exceptions.TypeError +(2,) * = (2, 2) +(2,) *= => (2, 2) +(2,) / ... exceptions.TypeError +(2,) /= ... exceptions.TypeError +(2,) ** ... exceptions.TypeError +(2,) **= ... exceptions.TypeError +(2,) % ... exceptions.TypeError +(2,) %= ... exceptions.TypeError +(2,) + ... exceptions.TypeError +(2,) += ... exceptions.TypeError +(2,) - ... exceptions.TypeError +(2,) -= ... exceptions.TypeError +(2,) * = (2, 2) +(2,) *= => (2, 2) +(2,) / ... exceptions.TypeError +(2,) /= ... exceptions.TypeError +(2,) ** ... exceptions.TypeError +(2,) **= ... exceptions.TypeError +(2,) % ... exceptions.TypeError +(2,) %= ... exceptions.TypeError +None + 2 ... exceptions.TypeError +None += 2 ... exceptions.TypeError +None - 2 ... exceptions.TypeError +None -= 2 ... exceptions.TypeError +None * 2 ... exceptions.TypeError +None *= 2 ... exceptions.TypeError +None / 2 ... exceptions.TypeError +None /= 2 ... exceptions.TypeError +None ** 2 ... exceptions.TypeError +None **= 2 ... exceptions.TypeError +None % 2 ... exceptions.TypeError +None %= 2 ... exceptions.TypeError +None + 4.0 ... exceptions.TypeError +None += 4.0 ... exceptions.TypeError +None - 4.0 ... exceptions.TypeError +None -= 4.0 ... exceptions.TypeError +None * 4.0 ... exceptions.TypeError +None *= 4.0 ... exceptions.TypeError +None / 4.0 ... exceptions.TypeError +None /= 4.0 ... exceptions.TypeError +None ** 4.0 ... exceptions.TypeError +None **= 4.0 ... exceptions.TypeError +None % 4.0 ... exceptions.TypeError +None %= 4.0 ... exceptions.TypeError +None + 2 ... exceptions.TypeError +None += 2 ... exceptions.TypeError +None - 2 ... exceptions.TypeError +None -= 2 ... exceptions.TypeError +None * 2 ... exceptions.TypeError +None *= 2 ... exceptions.TypeError +None / 2 ... exceptions.TypeError +None /= 2 ... exceptions.TypeError +None ** 2 ... exceptions.TypeError +None **= 2 ... exceptions.TypeError +None % 2 ... exceptions.TypeError +None %= 2 ... exceptions.TypeError +None + (2+0j) ... exceptions.TypeError +None += (2+0j) ... exceptions.TypeError +None - (2+0j) ... exceptions.TypeError +None -= (2+0j) ... exceptions.TypeError +None * (2+0j) ... exceptions.TypeError +None *= (2+0j) ... exceptions.TypeError +None / (2+0j) ... exceptions.TypeError +None /= (2+0j) ... exceptions.TypeError +None ** (2+0j) ... exceptions.TypeError +None **= (2+0j) ... exceptions.TypeError +None % (2+0j) ... exceptions.TypeError +None %= (2+0j) ... exceptions.TypeError +None + [1] ... exceptions.TypeError +None += [1] ... exceptions.TypeError +None - [1] ... exceptions.TypeError +None -= [1] ... exceptions.TypeError +None * [1] ... exceptions.TypeError +None *= [1] ... exceptions.TypeError +None / [1] ... exceptions.TypeError +None /= [1] ... exceptions.TypeError +None ** [1] ... exceptions.TypeError +None **= [1] ... exceptions.TypeError +None % [1] ... exceptions.TypeError +None %= [1] ... exceptions.TypeError +None + (2,) ... exceptions.TypeError +None += (2,) ... exceptions.TypeError +None - (2,) ... exceptions.TypeError +None -= (2,) ... exceptions.TypeError +None * (2,) ... exceptions.TypeError +None *= (2,) ... exceptions.TypeError +None / (2,) ... exceptions.TypeError +None /= (2,) ... exceptions.TypeError +None ** (2,) ... exceptions.TypeError +None **= (2,) ... exceptions.TypeError +None % (2,) ... exceptions.TypeError +None %= (2,) ... exceptions.TypeError +None + None ... exceptions.TypeError +None += None ... exceptions.TypeError +None - None ... exceptions.TypeError +None -= None ... exceptions.TypeError +None * None ... exceptions.TypeError +None *= None ... exceptions.TypeError +None / None ... exceptions.TypeError +None /= None ... exceptions.TypeError +None ** None ... exceptions.TypeError +None **= None ... exceptions.TypeError +None % None ... exceptions.TypeError +None %= None ... exceptions.TypeError +None + ... exceptions.TypeError +None += ... exceptions.TypeError +None - ... exceptions.TypeError +None -= ... exceptions.TypeError +None * ... exceptions.TypeError +None *= ... exceptions.TypeError +None / ... exceptions.TypeError +None /= ... exceptions.TypeError +None ** ... exceptions.TypeError +None **= ... exceptions.TypeError +None % ... exceptions.TypeError +None %= ... exceptions.TypeError +None + ... exceptions.TypeError +None += ... exceptions.TypeError +None - ... exceptions.TypeError +None -= ... exceptions.TypeError +None * ... exceptions.TypeError +None *= ... exceptions.TypeError +None / ... exceptions.TypeError +None /= ... exceptions.TypeError +None ** ... exceptions.TypeError +None **= ... exceptions.TypeError +None % ... exceptions.TypeError +None %= ... exceptions.TypeError + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + 4.0 = 6.0 + += 4.0 => 6.0 + - 4.0 = -2.0 + -= 4.0 => -2.0 + * 4.0 = 8.0 + *= 4.0 => 8.0 + / 4.0 = 0.5 + /= 4.0 => 0.5 + ** 4.0 = 16.0 + **= 4.0 => 16.0 + % 4.0 = 2.0 + %= 4.0 => 2.0 + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + (2+0j) = (4.0 + 0.0j) + += (2+0j) => (4.0 + 0.0j) + - (2+0j) = (0.0 + 0.0j) + -= (2+0j) => (0.0 + 0.0j) + * (2+0j) = (4.0 + 0.0j) + *= (2+0j) => (4.0 + 0.0j) + / (2+0j) = (1.0 + 0.0j) + /= (2+0j) => (1.0 + 0.0j) + ** (2+0j) = (4.0 + 0.0j) + **= (2+0j) => (4.0 + 0.0j) + % (2+0j) = (0.0 + 0.0j) + %= (2+0j) => (0.0 + 0.0j) + + [1] ... exceptions.TypeError + += [1] ... exceptions.TypeError + - [1] ... exceptions.TypeError + -= [1] ... exceptions.TypeError + * [1] = [1, 1] + *= [1] => [1, 1] + / [1] ... exceptions.TypeError + /= [1] ... exceptions.TypeError + ** [1] ... exceptions.TypeError + **= [1] ... exceptions.TypeError + % [1] ... exceptions.TypeError + %= [1] ... exceptions.TypeError + + (2,) ... exceptions.TypeError + += (2,) ... exceptions.TypeError + - (2,) ... exceptions.TypeError + -= (2,) ... exceptions.TypeError + * (2,) = (2, 2) + *= (2,) => (2, 2) + / (2,) ... exceptions.TypeError + /= (2,) ... exceptions.TypeError + ** (2,) ... exceptions.TypeError + **= (2,) ... exceptions.TypeError + % (2,) ... exceptions.TypeError + %= (2,) ... exceptions.TypeError + + None ... exceptions.TypeError + += None ... exceptions.TypeError + - None ... exceptions.TypeError + -= None ... exceptions.TypeError + * None ... exceptions.TypeError + *= None ... exceptions.TypeError + / None ... exceptions.TypeError + /= None ... exceptions.TypeError + ** None ... exceptions.TypeError + **= None ... exceptions.TypeError + % None ... exceptions.TypeError + %= None ... exceptions.TypeError + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + 4.0 = 6.0 + += 4.0 => 6.0 + - 4.0 = -2.0 + -= 4.0 => -2.0 + * 4.0 = 8.0 + *= 4.0 => 8.0 + / 4.0 = 0.5 + /= 4.0 => 0.5 + ** 4.0 = 16.0 + **= 4.0 => 16.0 + % 4.0 = 2.0 + %= 4.0 => 2.0 + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + (2+0j) = (4.0 + 0.0j) + += (2+0j) => (4.0 + 0.0j) + - (2+0j) = (0.0 + 0.0j) + -= (2+0j) => (0.0 + 0.0j) + * (2+0j) = (4.0 + 0.0j) + *= (2+0j) => (4.0 + 0.0j) + / (2+0j) = (1.0 + 0.0j) + /= (2+0j) => (1.0 + 0.0j) + ** (2+0j) = (4.0 + 0.0j) + **= (2+0j) => (4.0 + 0.0j) + % (2+0j) = (0.0 + 0.0j) + %= (2+0j) => (0.0 + 0.0j) + + [1] ... exceptions.TypeError + += [1] ... exceptions.TypeError + - [1] ... exceptions.TypeError + -= [1] ... exceptions.TypeError + * [1] = [1, 1] + *= [1] => [1, 1] + / [1] ... exceptions.TypeError + /= [1] ... exceptions.TypeError + ** [1] ... exceptions.TypeError + **= [1] ... exceptions.TypeError + % [1] ... exceptions.TypeError + %= [1] ... exceptions.TypeError + + (2,) ... exceptions.TypeError + += (2,) ... exceptions.TypeError + - (2,) ... exceptions.TypeError + -= (2,) ... exceptions.TypeError + * (2,) = (2, 2) + *= (2,) => (2, 2) + / (2,) ... exceptions.TypeError + /= (2,) ... exceptions.TypeError + ** (2,) ... exceptions.TypeError + **= (2,) ... exceptions.TypeError + % (2,) ... exceptions.TypeError + %= (2,) ... exceptions.TypeError + + None ... exceptions.TypeError + += None ... exceptions.TypeError + - None ... exceptions.TypeError + -= None ... exceptions.TypeError + * None ... exceptions.TypeError + *= None ... exceptions.TypeError + / None ... exceptions.TypeError + /= None ... exceptions.TypeError + ** None ... exceptions.TypeError + **= None ... exceptions.TypeError + % None ... exceptions.TypeError + %= None ... exceptions.TypeError + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 +divmod(2, 2) = (1, 0) +divmod(2, 4.0) = (0.0, 2.0) +divmod(2, 2) = (1L, 0L) +divmod(2, (2+0j)) = ((1+0j), 0j) +divmod(2, [1]) ... exceptions.TypeError +divmod(2, (2,)) ... exceptions.TypeError +divmod(2, None) ... exceptions.TypeError +divmod(2, ) ... exceptions.TypeError +divmod(2, ) = (1, 0) +divmod(4.0, 2) = (2.0, 0.0) +divmod(4.0, 4.0) = (1.0, 0.0) +divmod(4.0, 2) = (2.0, 0.0) +divmod(4.0, (2+0j)) = ((2+0j), 0j) +divmod(4.0, [1]) ... exceptions.TypeError +divmod(4.0, (2,)) ... exceptions.TypeError +divmod(4.0, None) ... exceptions.TypeError +divmod(4.0, ) ... exceptions.TypeError +divmod(4.0, ) = (2.0, 0.0) +divmod(2, 2) = (1L, 0L) +divmod(2, 4.0) = (0.0, 2.0) +divmod(2, 2) = (1L, 0L) +divmod(2, (2+0j)) = ((1+0j), 0j) +divmod(2, [1]) ... exceptions.TypeError +divmod(2, (2,)) ... exceptions.TypeError +divmod(2, None) ... exceptions.TypeError +divmod(2, ) ... exceptions.TypeError +divmod(2, ) = (1L, 0L) +divmod((2+0j), 2) = ((1+0j), 0j) +divmod((2+0j), 4.0) = (0j, (2+0j)) +divmod((2+0j), 2) = ((1+0j), 0j) +divmod((2+0j), (2+0j)) = ((1+0j), 0j) +divmod((2+0j), [1]) ... exceptions.TypeError +divmod((2+0j), (2,)) ... exceptions.TypeError +divmod((2+0j), None) ... exceptions.TypeError +divmod((2+0j), ) ... exceptions.TypeError +divmod((2+0j), ) = ((1+0j), 0j) +divmod([1], 2) ... exceptions.TypeError +divmod([1], 4.0) ... exceptions.TypeError +divmod([1], 2) ... exceptions.TypeError +divmod([1], (2+0j)) ... exceptions.TypeError +divmod([1], [1]) ... exceptions.TypeError +divmod([1], (2,)) ... exceptions.TypeError +divmod([1], None) ... exceptions.TypeError +divmod([1], ) ... exceptions.TypeError +divmod([1], ) ... exceptions.TypeError +divmod((2,), 2) ... exceptions.TypeError +divmod((2,), 4.0) ... exceptions.TypeError +divmod((2,), 2) ... exceptions.TypeError +divmod((2,), (2+0j)) ... exceptions.TypeError +divmod((2,), [1]) ... exceptions.TypeError +divmod((2,), (2,)) ... exceptions.TypeError +divmod((2,), None) ... exceptions.TypeError +divmod((2,), ) ... exceptions.TypeError +divmod((2,), ) ... exceptions.TypeError +divmod(None, 2) ... exceptions.TypeError +divmod(None, 4.0) ... exceptions.TypeError +divmod(None, 2) ... exceptions.TypeError +divmod(None, (2+0j)) ... exceptions.TypeError +divmod(None, [1]) ... exceptions.TypeError +divmod(None, (2,)) ... exceptions.TypeError +divmod(None, None) ... exceptions.TypeError +divmod(None, ) ... exceptions.TypeError +divmod(None, ) ... exceptions.TypeError +divmod(, 2) ... exceptions.TypeError +divmod(, 4.0) ... exceptions.TypeError +divmod(, 2) ... exceptions.TypeError +divmod(, (2+0j)) ... exceptions.TypeError +divmod(, [1]) ... exceptions.TypeError +divmod(, (2,)) ... exceptions.TypeError +divmod(, None) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError +divmod(, 2) = (1, 0) +divmod(, 4.0) = (0.0, 2.0) +divmod(, 2) = (1L, 0L) +divmod(, (2+0j)) = ((1+0j), 0j) +divmod(, [1]) ... exceptions.TypeError +divmod(, (2,)) ... exceptions.TypeError +divmod(, None) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError +divmod(, ) = (1, 0) Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_compare ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_compare (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_compare Fri May 5 21:25:58 2006 @@ -1,101 +1,101 @@ -test_compare -2 == 2 -2 == 2.0 -2 == 2 -2 == (2+0j) -2 != [1] -2 != (3,) -2 != None -2 != -2 == -2 == -2.0 == 2 -2.0 == 2.0 -2.0 == 2 -2.0 == (2+0j) -2.0 != [1] -2.0 != (3,) -2.0 != None -2.0 != -2.0 == -2.0 == -2 == 2 -2 == 2.0 -2 == 2 -2 == (2+0j) -2 != [1] -2 != (3,) -2 != None -2 != -2 == -2 == -(2+0j) == 2 -(2+0j) == 2.0 -(2+0j) == 2 -(2+0j) == (2+0j) -(2+0j) != [1] -(2+0j) != (3,) -(2+0j) != None -(2+0j) != -(2+0j) == -(2+0j) == -[1] != 2 -[1] != 2.0 -[1] != 2 -[1] != (2+0j) -[1] == [1] -[1] != (3,) -[1] != None -[1] != -[1] != -[1] != -(3,) != 2 -(3,) != 2.0 -(3,) != 2 -(3,) != (2+0j) -(3,) != [1] -(3,) == (3,) -(3,) != None -(3,) != -(3,) != -(3,) != -None != 2 -None != 2.0 -None != 2 -None != (2+0j) -None != [1] -None != (3,) -None == None -None != -None != -None != - != 2 - != 2.0 - != 2 - != (2+0j) - != [1] - != (3,) - != None - == - != - != - == 2 - == 2.0 - == 2 - == (2+0j) - != [1] - != (3,) - != None - != - == - == - == 2 - == 2.0 - == 2 - == (2+0j) - != [1] - != (3,) - != None - != - == - == +test_compare +2 == 2 +2 == 2.0 +2 == 2 +2 == (2+0j) +2 != [1] +2 != (3,) +2 != None +2 != +2 == +2 == +2.0 == 2 +2.0 == 2.0 +2.0 == 2 +2.0 == (2+0j) +2.0 != [1] +2.0 != (3,) +2.0 != None +2.0 != +2.0 == +2.0 == +2 == 2 +2 == 2.0 +2 == 2 +2 == (2+0j) +2 != [1] +2 != (3,) +2 != None +2 != +2 == +2 == +(2+0j) == 2 +(2+0j) == 2.0 +(2+0j) == 2 +(2+0j) == (2+0j) +(2+0j) != [1] +(2+0j) != (3,) +(2+0j) != None +(2+0j) != +(2+0j) == +(2+0j) == +[1] != 2 +[1] != 2.0 +[1] != 2 +[1] != (2+0j) +[1] == [1] +[1] != (3,) +[1] != None +[1] != +[1] != +[1] != +(3,) != 2 +(3,) != 2.0 +(3,) != 2 +(3,) != (2+0j) +(3,) != [1] +(3,) == (3,) +(3,) != None +(3,) != +(3,) != +(3,) != +None != 2 +None != 2.0 +None != 2 +None != (2+0j) +None != [1] +None != (3,) +None == None +None != +None != +None != + != 2 + != 2.0 + != 2 + != (2+0j) + != [1] + != (3,) + != None + == + != + != + == 2 + == 2.0 + == 2 + == (2+0j) + != [1] + != (3,) + != None + != + == + == + == 2 + == 2.0 + == 2 + == (2+0j) + != [1] + != (3,) + != None + != + == + == Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_cookie ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_cookie (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_cookie Fri May 5 21:25:58 2006 @@ -1,32 +1,32 @@ -test_cookie - -Set-Cookie: chips=ahoy; -Set-Cookie: vienna=finger; - chips 'ahoy' 'ahoy' -Set-Cookie: chips=ahoy; - vienna 'finger' 'finger' -Set-Cookie: vienna=finger; - -Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"; - keebler 'E=mc2; L="Loves"; fudge=\n;' 'E=mc2; L="Loves"; fudge=\n;' -Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"; - -Set-Cookie: keebler=E=mc2; - keebler 'E=mc2' 'E=mc2' -Set-Cookie: keebler=E=mc2; -Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme; - - - - - - -If anything blows up after this line, it's from Cookie's doctest. +test_cookie + +Set-Cookie: chips=ahoy; +Set-Cookie: vienna=finger; + chips 'ahoy' 'ahoy' +Set-Cookie: chips=ahoy; + vienna 'finger' 'finger' +Set-Cookie: vienna=finger; + +Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"; + keebler 'E=mc2; L="Loves"; fudge=\n;' 'E=mc2; L="Loves"; fudge=\n;' +Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"; + +Set-Cookie: keebler=E=mc2; + keebler 'E=mc2' 'E=mc2' +Set-Cookie: keebler=E=mc2; +Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme; + + + + + + +If anything blows up after this line, it's from Cookie's doctest. Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_exceptions ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_exceptions (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_exceptions Fri May 5 21:25:58 2006 @@ -1,52 +1,52 @@ -test_exceptions -5. Built-in exceptions -spam -AttributeError -spam -EOFError -spam -IOError -spam -ImportError -spam -IndexError -'spam' -KeyError -spam -KeyboardInterrupt -(not testable in a script) -spam -MemoryError -(not safe to test) -spam -NameError -spam -OverflowError -spam -RuntimeError -(not used any more?) -spam -SyntaxError -'continue' not supported inside 'finally' clause -ok -'continue' not properly in loop -ok -'continue' not properly in loop -ok -spam -IndentationError -spam -TabError -spam -SystemError -(hard to reproduce) -spam -SystemExit -spam -TypeError -spam -ValueError -spam -ZeroDivisionError -spam -Exception +test_exceptions +5. Built-in exceptions +spam +AttributeError +spam +EOFError +spam +IOError +spam +ImportError +spam +IndexError +'spam' +KeyError +spam +KeyboardInterrupt +(not testable in a script) +spam +MemoryError +(not safe to test) +spam +NameError +spam +OverflowError +spam +RuntimeError +(not used any more?) +spam +SyntaxError +'continue' not supported inside 'finally' clause +ok +'continue' not properly in loop +ok +'continue' not properly in loop +ok +spam +IndentationError +spam +TabError +spam +SystemError +(hard to reproduce) +spam +SystemExit +spam +TypeError +spam +ValueError +spam +ZeroDivisionError +spam +Exception Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_extcall ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_extcall (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_extcall Fri May 5 21:25:58 2006 @@ -1,112 +1,112 @@ -test_extcall -() {} -(1,) {} -(1, 2) {} -(1, 2, 3) {} -(1, 2, 3, 4, 5) {} -(1, 2, 3, 4, 5) {} -(1, 2, 3, 4, 5) {} -(1, 2, 3) {'a': 4, 'b': 5} -(1, 2, 3, 4, 5) {'a': 6, 'b': 7} -(1, 2, 3, 6, 7) {'a': 8, 'b': 9, 'x': 4, 'y': 5} -TypeError: g() takes at least 1 argument (0 given) -TypeError: g() takes at least 1 argument (0 given) -TypeError: g() takes at least 1 argument (0 given) -1 () {} -1 (2,) {} -1 (2, 3) {} -1 (2, 3, 4, 5) {} -0 (1, 2) {} -0 (1, 2, 3) {} -1 () {'a': 1, 'b': 2, 'c': 3, 'd': 4} -{'a': 1, 'b': 2, 'c': 3} -{'a': 1, 'b': 2, 'c': 3} -g() got multiple values for keyword argument 'x' -g() got multiple values for keyword argument 'b' -f() keywords must be strings -h() got an unexpected keyword argument 'e' -h() argument after * must be a sequence -dir() argument after * must be a sequence -NoneType object argument after * must be a sequence -h() argument after ** must be a dictionary -dir() argument after ** must be a dictionary -NoneType object argument after ** must be a dictionary -dir() got multiple values for keyword argument 'b' -3 512 True -3 -3 -za () {} -> za() takes exactly 1 argument (0 given) -za () {'a': 'aa'} -> ok za aa B D E V a -za () {'d': 'dd'} -> za() got an unexpected keyword argument 'd' -za () {'a': 'aa', 'd': 'dd'} -> za() got an unexpected keyword argument 'd' -za () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() got an unexpected keyword argument 'b' -za (1, 2) {} -> za() takes exactly 1 argument (2 given) -za (1, 2) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2, 3, 4, 5) {} -> za() takes exactly 1 argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (5 given) -zade () {} -> zade() takes at least 1 argument (0 given) -zade () {'a': 'aa'} -> ok zade aa B d e V a -zade () {'d': 'dd'} -> zade() takes at least 1 non-keyword argument (0 given) -zade () {'a': 'aa', 'd': 'dd'} -> ok zade aa B dd e V d -zade () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got an unexpected keyword argument 'b' -zade (1, 2) {} -> ok zade 1 B 2 e V e -zade (1, 2) {'a': 'aa'} -> zade() got multiple values for keyword argument 'a' -zade (1, 2) {'d': 'dd'} -> zade() got multiple values for keyword argument 'd' -zade (1, 2) {'a': 'aa', 'd': 'dd'} -> zade() got multiple values for keyword argument 'a' -zade (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got multiple values for keyword argument 'a' -zade (1, 2, 3, 4, 5) {} -> zade() takes at most 3 arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'d': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() takes at most 3 non-keyword arguments (5 given) -zabk () {} -> zabk() takes exactly 2 arguments (0 given) -zabk () {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (1 given) -zabk () {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (0 given) -zabk () {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (1 given) -zabk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabk aa bb D E V {'d': 'dd', 'e': 'ee'} -zabk (1, 2) {} -> ok zabk 1 2 D E V {} -zabk (1, 2) {'a': 'aa'} -> zabk() got multiple values for keyword argument 'a' -zabk (1, 2) {'d': 'dd'} -> ok zabk 1 2 D E V {'d': 'dd'} -zabk (1, 2) {'a': 'aa', 'd': 'dd'} -> zabk() got multiple values for keyword argument 'a' -zabk (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() got multiple values for keyword argument 'a' -zabk (1, 2, 3, 4, 5) {} -> zabk() takes exactly 2 arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabdv () {} -> zabdv() takes at least 2 arguments (0 given) -zabdv () {'a': 'aa'} -> zabdv() takes at least 2 non-keyword arguments (1 given) -zabdv () {'d': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (0 given) -zabdv () {'a': 'aa', 'd': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (1 given) -zabdv () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got an unexpected keyword argument 'e' -zabdv (1, 2) {} -> ok zabdv 1 2 d E () e -zabdv (1, 2) {'a': 'aa'} -> zabdv() got multiple values for keyword argument 'a' -zabdv (1, 2) {'d': 'dd'} -> ok zabdv 1 2 dd E () d -zabdv (1, 2) {'a': 'aa', 'd': 'dd'} -> zabdv() got multiple values for keyword argument 'a' -zabdv (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got multiple values for keyword argument 'a' -zabdv (1, 2, 3, 4, 5) {} -> ok zabdv 1 2 3 E (4, 5) e -zabdv (1, 2, 3, 4, 5) {'a': 'aa'} -> zabdv() got multiple values for keyword argument 'a' -zabdv (1, 2, 3, 4, 5) {'d': 'dd'} -> zabdv() got multiple values for keyword argument 'd' -zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabdv() got multiple values for keyword argument 'a' -zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got multiple values for keyword argument 'a' -zabdevk () {} -> zabdevk() takes at least 2 arguments (0 given) -zabdevk () {'a': 'aa'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) -zabdevk () {'d': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (0 given) -zabdevk () {'a': 'aa', 'd': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) -zabdevk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabdevk aa bb dd ee () {} -zabdevk (1, 2) {} -> ok zabdevk 1 2 d e () {} -zabdevk (1, 2) {'a': 'aa'} -> zabdevk() got multiple values for keyword argument 'a' -zabdevk (1, 2) {'d': 'dd'} -> ok zabdevk 1 2 dd e () {} -zabdevk (1, 2) {'a': 'aa', 'd': 'dd'} -> zabdevk() got multiple values for keyword argument 'a' -zabdevk (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdevk() got multiple values for keyword argument 'a' -zabdevk (1, 2, 3, 4, 5) {} -> ok zabdevk 1 2 3 4 (5,) {} -zabdevk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabdevk() got multiple values for keyword argument 'a' -zabdevk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabdevk() got multiple values for keyword argument 'd' -zabdevk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabdevk() got multiple values for keyword argument 'a' -zabdevk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdevk() got multiple values for keyword argument 'a' +test_extcall +() {} +(1,) {} +(1, 2) {} +(1, 2, 3) {} +(1, 2, 3, 4, 5) {} +(1, 2, 3, 4, 5) {} +(1, 2, 3, 4, 5) {} +(1, 2, 3) {'a': 4, 'b': 5} +(1, 2, 3, 4, 5) {'a': 6, 'b': 7} +(1, 2, 3, 6, 7) {'a': 8, 'b': 9, 'x': 4, 'y': 5} +TypeError: g() takes at least 1 argument (0 given) +TypeError: g() takes at least 1 argument (0 given) +TypeError: g() takes at least 1 argument (0 given) +1 () {} +1 (2,) {} +1 (2, 3) {} +1 (2, 3, 4, 5) {} +0 (1, 2) {} +0 (1, 2, 3) {} +1 () {'a': 1, 'b': 2, 'c': 3, 'd': 4} +{'a': 1, 'b': 2, 'c': 3} +{'a': 1, 'b': 2, 'c': 3} +g() got multiple values for keyword argument 'x' +g() got multiple values for keyword argument 'b' +f() keywords must be strings +h() got an unexpected keyword argument 'e' +h() argument after * must be a sequence +dir() argument after * must be a sequence +NoneType object argument after * must be a sequence +h() argument after ** must be a dictionary +dir() argument after ** must be a dictionary +NoneType object argument after ** must be a dictionary +dir() got multiple values for keyword argument 'b' +3 512 True +3 +3 +za () {} -> za() takes exactly 1 argument (0 given) +za () {'a': 'aa'} -> ok za aa B D E V a +za () {'d': 'dd'} -> za() got an unexpected keyword argument 'd' +za () {'a': 'aa', 'd': 'dd'} -> za() got an unexpected keyword argument 'd' +za () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() got an unexpected keyword argument 'b' +za (1, 2) {} -> za() takes exactly 1 argument (2 given) +za (1, 2) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (2 given) +za (1, 2) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) +za (1, 2) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) +za (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (2 given) +za (1, 2, 3, 4, 5) {} -> za() takes exactly 1 argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (5 given) +za (1, 2, 3, 4, 5) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (5 given) +zade () {} -> zade() takes at least 1 argument (0 given) +zade () {'a': 'aa'} -> ok zade aa B d e V a +zade () {'d': 'dd'} -> zade() takes at least 1 non-keyword argument (0 given) +zade () {'a': 'aa', 'd': 'dd'} -> ok zade aa B dd e V d +zade () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got an unexpected keyword argument 'b' +zade (1, 2) {} -> ok zade 1 B 2 e V e +zade (1, 2) {'a': 'aa'} -> zade() got multiple values for keyword argument 'a' +zade (1, 2) {'d': 'dd'} -> zade() got multiple values for keyword argument 'd' +zade (1, 2) {'a': 'aa', 'd': 'dd'} -> zade() got multiple values for keyword argument 'a' +zade (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got multiple values for keyword argument 'a' +zade (1, 2, 3, 4, 5) {} -> zade() takes at most 3 arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa'} -> zade() takes at most 3 non-keyword arguments (5 given) +zade (1, 2, 3, 4, 5) {'d': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() takes at most 3 non-keyword arguments (5 given) +zabk () {} -> zabk() takes exactly 2 arguments (0 given) +zabk () {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (1 given) +zabk () {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (0 given) +zabk () {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (1 given) +zabk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabk aa bb D E V {'d': 'dd', 'e': 'ee'} +zabk (1, 2) {} -> ok zabk 1 2 D E V {} +zabk (1, 2) {'a': 'aa'} -> zabk() got multiple values for keyword argument 'a' +zabk (1, 2) {'d': 'dd'} -> ok zabk 1 2 D E V {'d': 'dd'} +zabk (1, 2) {'a': 'aa', 'd': 'dd'} -> zabk() got multiple values for keyword argument 'a' +zabk (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() got multiple values for keyword argument 'a' +zabk (1, 2, 3, 4, 5) {} -> zabk() takes exactly 2 arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (5 given) +zabk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() takes exactly 2 non-keyword arguments (5 given) +zabdv () {} -> zabdv() takes at least 2 arguments (0 given) +zabdv () {'a': 'aa'} -> zabdv() takes at least 2 non-keyword arguments (1 given) +zabdv () {'d': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (0 given) +zabdv () {'a': 'aa', 'd': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (1 given) +zabdv () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got an unexpected keyword argument 'e' +zabdv (1, 2) {} -> ok zabdv 1 2 d E () e +zabdv (1, 2) {'a': 'aa'} -> zabdv() got multiple values for keyword argument 'a' +zabdv (1, 2) {'d': 'dd'} -> ok zabdv 1 2 dd E () d +zabdv (1, 2) {'a': 'aa', 'd': 'dd'} -> zabdv() got multiple values for keyword argument 'a' +zabdv (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got multiple values for keyword argument 'a' +zabdv (1, 2, 3, 4, 5) {} -> ok zabdv 1 2 3 E (4, 5) e +zabdv (1, 2, 3, 4, 5) {'a': 'aa'} -> zabdv() got multiple values for keyword argument 'a' +zabdv (1, 2, 3, 4, 5) {'d': 'dd'} -> zabdv() got multiple values for keyword argument 'd' +zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabdv() got multiple values for keyword argument 'a' +zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got multiple values for keyword argument 'a' +zabdevk () {} -> zabdevk() takes at least 2 arguments (0 given) +zabdevk () {'a': 'aa'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) +zabdevk () {'d': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (0 given) +zabdevk () {'a': 'aa', 'd': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) +zabdevk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabdevk aa bb dd ee () {} +zabdevk (1, 2) {} -> ok zabdevk 1 2 d e () {} +zabdevk (1, 2) {'a': 'aa'} -> zabdevk() got multiple values for keyword argument 'a' +zabdevk (1, 2) {'d': 'dd'} -> ok zabdevk 1 2 dd e () {} +zabdevk (1, 2) {'a': 'aa', 'd': 'dd'} -> zabdevk() got multiple values for keyword argument 'a' +zabdevk (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdevk() got multiple values for keyword argument 'a' +zabdevk (1, 2, 3, 4, 5) {} -> ok zabdevk 1 2 3 4 (5,) {} +zabdevk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabdevk() got multiple values for keyword argument 'a' +zabdevk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabdevk() got multiple values for keyword argument 'd' +zabdevk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabdevk() got multiple values for keyword argument 'a' +zabdevk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdevk() got multiple values for keyword argument 'a' Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_frozen ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_frozen (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_frozen Fri May 5 21:25:58 2006 @@ -1,4 +1,4 @@ -test_frozen -Hello world... -Hello world... -Hello world... +test_frozen +Hello world... +Hello world... +Hello world... Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_global ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_global (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_global Fri May 5 21:25:58 2006 @@ -1,5 +1,5 @@ -test_global -got SyntaxError as expected -got SyntaxError as expected -got SyntaxError as expected -as expected, no SyntaxError +test_global +got SyntaxError as expected +got SyntaxError as expected +got SyntaxError as expected +as expected, no SyntaxError Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_grammar ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_grammar (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_grammar Fri May 5 21:25:58 2006 @@ -1,67 +1,67 @@ -test_grammar -1. Parser -1.1 Tokens -1.1.1 Backslashes -1.1.2 Numeric literals -1.1.2.1 Plain integers -1.1.2.2 Long integers -1.1.2.3 Floating point -1.1.3 String literals -1.2 Grammar -single_input -file_input -expr_input -eval_input -funcdef -lambdef -simple_stmt -expr_stmt -print_stmt -1 2 3 -1 2 3 -1 1 1 -extended print_stmt -1 2 3 -1 2 3 -1 1 1 -hello world -del_stmt -pass_stmt -flow_stmt -break_stmt -continue_stmt -continue + try/except ok -continue + try/finally ok -testing continue and break in try/except in loop -return_stmt -raise_stmt -import_name -import_from -global_stmt -exec_stmt -assert_stmt -if_stmt -while_stmt -for_stmt -try_stmt -suite -test -comparison -binary mask ops -shift ops -additive ops -multiplicative ops -unary ops -selectors - -atoms -classdef -['Apple', 'Banana', 'Coco nut'] -[3, 6, 9, 12, 15] -[3, 4, 5] -[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')] -[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')] -[[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]] -[False, False, False] -[[1, 2], [3, 4], [5, 6]] -[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')] +test_grammar +1. Parser +1.1 Tokens +1.1.1 Backslashes +1.1.2 Numeric literals +1.1.2.1 Plain integers +1.1.2.2 Long integers +1.1.2.3 Floating point +1.1.3 String literals +1.2 Grammar +single_input +file_input +expr_input +eval_input +funcdef +lambdef +simple_stmt +expr_stmt +print_stmt +1 2 3 +1 2 3 +1 1 1 +extended print_stmt +1 2 3 +1 2 3 +1 1 1 +hello world +del_stmt +pass_stmt +flow_stmt +break_stmt +continue_stmt +continue + try/except ok +continue + try/finally ok +testing continue and break in try/except in loop +return_stmt +raise_stmt +import_name +import_from +global_stmt +exec_stmt +assert_stmt +if_stmt +while_stmt +for_stmt +try_stmt +suite +test +comparison +binary mask ops +shift ops +additive ops +multiplicative ops +unary ops +selectors + +atoms +classdef +['Apple', 'Banana', 'Coco nut'] +[3, 6, 9, 12, 15] +[3, 4, 5] +[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')] +[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')] +[[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]] +[False, False, False] +[[1, 2], [3, 4], [5, 6]] +[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')] Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_httplib ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_httplib (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_httplib Fri May 5 21:25:58 2006 @@ -1,13 +1,13 @@ -test_httplib -reply: 'HTTP/1.1 200 Ok\r\n' -Text -reply: 'HTTP/1.1 400.100 Not Ok\r\n' -BadStatusLine raised as expected -InvalidURL raised as expected -InvalidURL raised as expected -reply: 'HTTP/1.1 200 OK\r\n' -header: Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme" -header: Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme" -reply: 'HTTP/1.1 200 OK\r\n' -header: Content-Length: 14432 - +test_httplib +reply: 'HTTP/1.1 200 Ok\r\n' +Text +reply: 'HTTP/1.1 400.100 Not Ok\r\n' +BadStatusLine raised as expected +InvalidURL raised as expected +InvalidURL raised as expected +reply: 'HTTP/1.1 200 OK\r\n' +header: Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme" +header: Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme" +reply: 'HTTP/1.1 200 OK\r\n' +header: Content-Length: 14432 + Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_linuxaudiodev ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_linuxaudiodev (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_linuxaudiodev Fri May 5 21:25:58 2006 @@ -1,7 +1,7 @@ -test_linuxaudiodev -expected rate >= 0, not -1 -expected sample size >= 0, not -2 -nchannels must be 1 or 2, not 3 -unknown audio encoding: 177 -for linear unsigned 16-bit little-endian audio, expected sample size 16, not 8 -for linear unsigned 8-bit audio, expected sample size 8, not 16 +test_linuxaudiodev +expected rate >= 0, not -1 +expected sample size >= 0, not -2 +nchannels must be 1 or 2, not 3 +unknown audio encoding: 177 +for linear unsigned 16-bit little-endian audio, expected sample size 16, not 8 +for linear unsigned 8-bit audio, expected sample size 8, not 16 Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_logging ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_logging (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_logging Fri May 5 21:25:58 2006 @@ -1,515 +1,515 @@ -test_logging --- log_test0 begin --------------------------------------------------- -CRITICAL:ERR:Message 0 -ERROR:ERR:Message 1 -CRITICAL:INF:Message 2 -ERROR:INF:Message 3 -WARNING:INF:Message 4 -INFO:INF:Message 5 -CRITICAL:INF.UNDEF:Message 6 -ERROR:INF.UNDEF:Message 7 -WARNING:INF.UNDEF:Message 8 -INFO:INF.UNDEF:Message 9 -CRITICAL:INF.ERR:Message 10 -ERROR:INF.ERR:Message 11 -CRITICAL:INF.ERR.UNDEF:Message 12 -ERROR:INF.ERR.UNDEF:Message 13 -CRITICAL:DEB:Message 14 -ERROR:DEB:Message 15 -WARNING:DEB:Message 16 -INFO:DEB:Message 17 -DEBUG:DEB:Message 18 -CRITICAL:UNDEF:Message 19 -ERROR:UNDEF:Message 20 -WARNING:UNDEF:Message 21 -INFO:UNDEF:Message 22 -CRITICAL:INF.BADPARENT.UNDEF:Message 23 -CRITICAL:INF.BADPARENT:Message 24 -INFO:INF:Finish up, it's closing time. Messages should bear numbers 0 through 24. --- log_test0 end --------------------------------------------------- --- log_test1 begin --------------------------------------------------- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering at handler level to SOCIABLE -- --- setting logging level to 'Boring' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering using GARRULOUS filter -- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- Filtering using specific filter for SOCIABLE, TACITURN -- --- setting logging level to 'Boring' ----- -Boring:root:This should only be seen at the 'Boring' logging level (or lower) -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Chatterbox' ----- -Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Garrulous' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Talkative' ----- -Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Verbose' ----- -Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Sociable' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Effusive' ----- -Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Terse' ----- -Terse:root:This should only be seen at the 'Terse' logging level (or lower) -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Taciturn' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- setting logging level to 'Silent' ----- -Silent:root:This should only be seen at the 'Silent' logging level (or lower) --- log_test1 end --------------------------------------------------- --- log_test2 begin --------------------------------------------------- --- logging at DEBUG, nothing should be seen yet -- --- logging at INFO, nothing should be seen yet -- --- logging at WARNING, 3 messages should be seen -- -DEBUG:root:Debug message -INFO:root:Info message -WARNING:root:Warn message --- logging 0 at INFO, messages should be seen every 10 events -- --- logging 1 at INFO, messages should be seen every 10 events -- --- logging 2 at INFO, messages should be seen every 10 events -- --- logging 3 at INFO, messages should be seen every 10 events -- --- logging 4 at INFO, messages should be seen every 10 events -- --- logging 5 at INFO, messages should be seen every 10 events -- --- logging 6 at INFO, messages should be seen every 10 events -- --- logging 7 at INFO, messages should be seen every 10 events -- --- logging 8 at INFO, messages should be seen every 10 events -- --- logging 9 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 0 -INFO:root:Info index = 1 -INFO:root:Info index = 2 -INFO:root:Info index = 3 -INFO:root:Info index = 4 -INFO:root:Info index = 5 -INFO:root:Info index = 6 -INFO:root:Info index = 7 -INFO:root:Info index = 8 -INFO:root:Info index = 9 --- logging 10 at INFO, messages should be seen every 10 events -- --- logging 11 at INFO, messages should be seen every 10 events -- --- logging 12 at INFO, messages should be seen every 10 events -- --- logging 13 at INFO, messages should be seen every 10 events -- --- logging 14 at INFO, messages should be seen every 10 events -- --- logging 15 at INFO, messages should be seen every 10 events -- --- logging 16 at INFO, messages should be seen every 10 events -- --- logging 17 at INFO, messages should be seen every 10 events -- --- logging 18 at INFO, messages should be seen every 10 events -- --- logging 19 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 10 -INFO:root:Info index = 11 -INFO:root:Info index = 12 -INFO:root:Info index = 13 -INFO:root:Info index = 14 -INFO:root:Info index = 15 -INFO:root:Info index = 16 -INFO:root:Info index = 17 -INFO:root:Info index = 18 -INFO:root:Info index = 19 --- logging 20 at INFO, messages should be seen every 10 events -- --- logging 21 at INFO, messages should be seen every 10 events -- --- logging 22 at INFO, messages should be seen every 10 events -- --- logging 23 at INFO, messages should be seen every 10 events -- --- logging 24 at INFO, messages should be seen every 10 events -- --- logging 25 at INFO, messages should be seen every 10 events -- --- logging 26 at INFO, messages should be seen every 10 events -- --- logging 27 at INFO, messages should be seen every 10 events -- --- logging 28 at INFO, messages should be seen every 10 events -- --- logging 29 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 20 -INFO:root:Info index = 21 -INFO:root:Info index = 22 -INFO:root:Info index = 23 -INFO:root:Info index = 24 -INFO:root:Info index = 25 -INFO:root:Info index = 26 -INFO:root:Info index = 27 -INFO:root:Info index = 28 -INFO:root:Info index = 29 --- logging 30 at INFO, messages should be seen every 10 events -- --- logging 31 at INFO, messages should be seen every 10 events -- --- logging 32 at INFO, messages should be seen every 10 events -- --- logging 33 at INFO, messages should be seen every 10 events -- --- logging 34 at INFO, messages should be seen every 10 events -- --- logging 35 at INFO, messages should be seen every 10 events -- --- logging 36 at INFO, messages should be seen every 10 events -- --- logging 37 at INFO, messages should be seen every 10 events -- --- logging 38 at INFO, messages should be seen every 10 events -- --- logging 39 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 30 -INFO:root:Info index = 31 -INFO:root:Info index = 32 -INFO:root:Info index = 33 -INFO:root:Info index = 34 -INFO:root:Info index = 35 -INFO:root:Info index = 36 -INFO:root:Info index = 37 -INFO:root:Info index = 38 -INFO:root:Info index = 39 --- logging 40 at INFO, messages should be seen every 10 events -- --- logging 41 at INFO, messages should be seen every 10 events -- --- logging 42 at INFO, messages should be seen every 10 events -- --- logging 43 at INFO, messages should be seen every 10 events -- --- logging 44 at INFO, messages should be seen every 10 events -- --- logging 45 at INFO, messages should be seen every 10 events -- --- logging 46 at INFO, messages should be seen every 10 events -- --- logging 47 at INFO, messages should be seen every 10 events -- --- logging 48 at INFO, messages should be seen every 10 events -- --- logging 49 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 40 -INFO:root:Info index = 41 -INFO:root:Info index = 42 -INFO:root:Info index = 43 -INFO:root:Info index = 44 -INFO:root:Info index = 45 -INFO:root:Info index = 46 -INFO:root:Info index = 47 -INFO:root:Info index = 48 -INFO:root:Info index = 49 --- logging 50 at INFO, messages should be seen every 10 events -- --- logging 51 at INFO, messages should be seen every 10 events -- --- logging 52 at INFO, messages should be seen every 10 events -- --- logging 53 at INFO, messages should be seen every 10 events -- --- logging 54 at INFO, messages should be seen every 10 events -- --- logging 55 at INFO, messages should be seen every 10 events -- --- logging 56 at INFO, messages should be seen every 10 events -- --- logging 57 at INFO, messages should be seen every 10 events -- --- logging 58 at INFO, messages should be seen every 10 events -- --- logging 59 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 50 -INFO:root:Info index = 51 -INFO:root:Info index = 52 -INFO:root:Info index = 53 -INFO:root:Info index = 54 -INFO:root:Info index = 55 -INFO:root:Info index = 56 -INFO:root:Info index = 57 -INFO:root:Info index = 58 -INFO:root:Info index = 59 --- logging 60 at INFO, messages should be seen every 10 events -- --- logging 61 at INFO, messages should be seen every 10 events -- --- logging 62 at INFO, messages should be seen every 10 events -- --- logging 63 at INFO, messages should be seen every 10 events -- --- logging 64 at INFO, messages should be seen every 10 events -- --- logging 65 at INFO, messages should be seen every 10 events -- --- logging 66 at INFO, messages should be seen every 10 events -- --- logging 67 at INFO, messages should be seen every 10 events -- --- logging 68 at INFO, messages should be seen every 10 events -- --- logging 69 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 60 -INFO:root:Info index = 61 -INFO:root:Info index = 62 -INFO:root:Info index = 63 -INFO:root:Info index = 64 -INFO:root:Info index = 65 -INFO:root:Info index = 66 -INFO:root:Info index = 67 -INFO:root:Info index = 68 -INFO:root:Info index = 69 --- logging 70 at INFO, messages should be seen every 10 events -- --- logging 71 at INFO, messages should be seen every 10 events -- --- logging 72 at INFO, messages should be seen every 10 events -- --- logging 73 at INFO, messages should be seen every 10 events -- --- logging 74 at INFO, messages should be seen every 10 events -- --- logging 75 at INFO, messages should be seen every 10 events -- --- logging 76 at INFO, messages should be seen every 10 events -- --- logging 77 at INFO, messages should be seen every 10 events -- --- logging 78 at INFO, messages should be seen every 10 events -- --- logging 79 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 70 -INFO:root:Info index = 71 -INFO:root:Info index = 72 -INFO:root:Info index = 73 -INFO:root:Info index = 74 -INFO:root:Info index = 75 -INFO:root:Info index = 76 -INFO:root:Info index = 77 -INFO:root:Info index = 78 -INFO:root:Info index = 79 --- logging 80 at INFO, messages should be seen every 10 events -- --- logging 81 at INFO, messages should be seen every 10 events -- --- logging 82 at INFO, messages should be seen every 10 events -- --- logging 83 at INFO, messages should be seen every 10 events -- --- logging 84 at INFO, messages should be seen every 10 events -- --- logging 85 at INFO, messages should be seen every 10 events -- --- logging 86 at INFO, messages should be seen every 10 events -- --- logging 87 at INFO, messages should be seen every 10 events -- --- logging 88 at INFO, messages should be seen every 10 events -- --- logging 89 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 80 -INFO:root:Info index = 81 -INFO:root:Info index = 82 -INFO:root:Info index = 83 -INFO:root:Info index = 84 -INFO:root:Info index = 85 -INFO:root:Info index = 86 -INFO:root:Info index = 87 -INFO:root:Info index = 88 -INFO:root:Info index = 89 --- logging 90 at INFO, messages should be seen every 10 events -- --- logging 91 at INFO, messages should be seen every 10 events -- --- logging 92 at INFO, messages should be seen every 10 events -- --- logging 93 at INFO, messages should be seen every 10 events -- --- logging 94 at INFO, messages should be seen every 10 events -- --- logging 95 at INFO, messages should be seen every 10 events -- --- logging 96 at INFO, messages should be seen every 10 events -- --- logging 97 at INFO, messages should be seen every 10 events -- --- logging 98 at INFO, messages should be seen every 10 events -- --- logging 99 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 90 -INFO:root:Info index = 91 -INFO:root:Info index = 92 -INFO:root:Info index = 93 -INFO:root:Info index = 94 -INFO:root:Info index = 95 -INFO:root:Info index = 96 -INFO:root:Info index = 97 -INFO:root:Info index = 98 -INFO:root:Info index = 99 --- logging 100 at INFO, messages should be seen every 10 events -- --- logging 101 at INFO, messages should be seen every 10 events -- -INFO:root:Info index = 100 -INFO:root:Info index = 101 --- log_test2 end --------------------------------------------------- --- log_test3 begin --------------------------------------------------- -Unfiltered... -INFO:a:Info 1 -INFO:a.b:Info 2 -INFO:a.c:Info 3 -INFO:a.b.c:Info 4 -INFO:a.b.c.d:Info 5 -INFO:a.bb.c:Info 6 -INFO:b:Info 7 -INFO:b.a:Info 8 -INFO:c.a.b:Info 9 -INFO:a.bb:Info 10 -Filtered with 'a.b'... -INFO:a.b:Info 2 -INFO:a.b.c:Info 4 -INFO:a.b.c.d:Info 5 --- log_test3 end --------------------------------------------------- --- logrecv output begin --------------------------------------------------- -ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) -ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) -INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) -INF -> ERROR: Message 3 (via logrecv.tcp.INF) -INF -> WARNING: Message 4 (via logrecv.tcp.INF) -INF -> INFO: Message 5 (via logrecv.tcp.INF) -INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> WARNING: Message 8 (via logrecv.tcp.INF.UNDEF) -INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF) -INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR) -INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR) -INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF) -INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF) -DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB) -DEB -> ERROR: Message 15 (via logrecv.tcp.DEB) -DEB -> WARNING: Message 16 (via logrecv.tcp.DEB) -DEB -> INFO: Message 17 (via logrecv.tcp.DEB) -DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB) -UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF) -UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF) -UNDEF -> WARNING: Message 21 (via logrecv.tcp.UNDEF) -UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF) -INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF) -INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT) -INF -> INFO: Finish up, it's closing time. Messages should bear numbers 0 through 24. (via logrecv.tcp.INF) --- logrecv output end --------------------------------------------------- +test_logging +-- log_test0 begin --------------------------------------------------- +CRITICAL:ERR:Message 0 +ERROR:ERR:Message 1 +CRITICAL:INF:Message 2 +ERROR:INF:Message 3 +WARNING:INF:Message 4 +INFO:INF:Message 5 +CRITICAL:INF.UNDEF:Message 6 +ERROR:INF.UNDEF:Message 7 +WARNING:INF.UNDEF:Message 8 +INFO:INF.UNDEF:Message 9 +CRITICAL:INF.ERR:Message 10 +ERROR:INF.ERR:Message 11 +CRITICAL:INF.ERR.UNDEF:Message 12 +ERROR:INF.ERR.UNDEF:Message 13 +CRITICAL:DEB:Message 14 +ERROR:DEB:Message 15 +WARNING:DEB:Message 16 +INFO:DEB:Message 17 +DEBUG:DEB:Message 18 +CRITICAL:UNDEF:Message 19 +ERROR:UNDEF:Message 20 +WARNING:UNDEF:Message 21 +INFO:UNDEF:Message 22 +CRITICAL:INF.BADPARENT.UNDEF:Message 23 +CRITICAL:INF.BADPARENT:Message 24 +INFO:INF:Finish up, it's closing time. Messages should bear numbers 0 through 24. +-- log_test0 end --------------------------------------------------- +-- log_test1 begin --------------------------------------------------- +-- setting logging level to 'Boring' ----- +Boring:root:This should only be seen at the 'Boring' logging level (or lower) +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Chatterbox' ----- +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Garrulous' ----- +Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Talkative' ----- +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Verbose' ----- +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Sociable' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Effusive' ----- +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Terse' ----- +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Taciturn' ----- +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Silent' ----- +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- Filtering at handler level to SOCIABLE -- +-- setting logging level to 'Boring' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Chatterbox' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Garrulous' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Talkative' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Verbose' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Sociable' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Effusive' ----- +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Terse' ----- +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Taciturn' ----- +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Silent' ----- +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- Filtering using GARRULOUS filter -- +-- setting logging level to 'Boring' ----- +Boring:root:This should only be seen at the 'Boring' logging level (or lower) +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Chatterbox' ----- +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Garrulous' ----- +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Talkative' ----- +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Verbose' ----- +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Sociable' ----- +Sociable:root:This should only be seen at the 'Sociable' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Effusive' ----- +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Terse' ----- +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Taciturn' ----- +Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Silent' ----- +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- Filtering using specific filter for SOCIABLE, TACITURN -- +-- setting logging level to 'Boring' ----- +Boring:root:This should only be seen at the 'Boring' logging level (or lower) +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Chatterbox' ----- +Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower) +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Garrulous' ----- +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Talkative' ----- +Talkative:root:This should only be seen at the 'Talkative' logging level (or lower) +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Verbose' ----- +Verbose:root:This should only be seen at the 'Verbose' logging level (or lower) +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Sociable' ----- +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Effusive' ----- +Effusive:root:This should only be seen at the 'Effusive' logging level (or lower) +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Terse' ----- +Terse:root:This should only be seen at the 'Terse' logging level (or lower) +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Taciturn' ----- +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- setting logging level to 'Silent' ----- +Silent:root:This should only be seen at the 'Silent' logging level (or lower) +-- log_test1 end --------------------------------------------------- +-- log_test2 begin --------------------------------------------------- +-- logging at DEBUG, nothing should be seen yet -- +-- logging at INFO, nothing should be seen yet -- +-- logging at WARNING, 3 messages should be seen -- +DEBUG:root:Debug message +INFO:root:Info message +WARNING:root:Warn message +-- logging 0 at INFO, messages should be seen every 10 events -- +-- logging 1 at INFO, messages should be seen every 10 events -- +-- logging 2 at INFO, messages should be seen every 10 events -- +-- logging 3 at INFO, messages should be seen every 10 events -- +-- logging 4 at INFO, messages should be seen every 10 events -- +-- logging 5 at INFO, messages should be seen every 10 events -- +-- logging 6 at INFO, messages should be seen every 10 events -- +-- logging 7 at INFO, messages should be seen every 10 events -- +-- logging 8 at INFO, messages should be seen every 10 events -- +-- logging 9 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 0 +INFO:root:Info index = 1 +INFO:root:Info index = 2 +INFO:root:Info index = 3 +INFO:root:Info index = 4 +INFO:root:Info index = 5 +INFO:root:Info index = 6 +INFO:root:Info index = 7 +INFO:root:Info index = 8 +INFO:root:Info index = 9 +-- logging 10 at INFO, messages should be seen every 10 events -- +-- logging 11 at INFO, messages should be seen every 10 events -- +-- logging 12 at INFO, messages should be seen every 10 events -- +-- logging 13 at INFO, messages should be seen every 10 events -- +-- logging 14 at INFO, messages should be seen every 10 events -- +-- logging 15 at INFO, messages should be seen every 10 events -- +-- logging 16 at INFO, messages should be seen every 10 events -- +-- logging 17 at INFO, messages should be seen every 10 events -- +-- logging 18 at INFO, messages should be seen every 10 events -- +-- logging 19 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 10 +INFO:root:Info index = 11 +INFO:root:Info index = 12 +INFO:root:Info index = 13 +INFO:root:Info index = 14 +INFO:root:Info index = 15 +INFO:root:Info index = 16 +INFO:root:Info index = 17 +INFO:root:Info index = 18 +INFO:root:Info index = 19 +-- logging 20 at INFO, messages should be seen every 10 events -- +-- logging 21 at INFO, messages should be seen every 10 events -- +-- logging 22 at INFO, messages should be seen every 10 events -- +-- logging 23 at INFO, messages should be seen every 10 events -- +-- logging 24 at INFO, messages should be seen every 10 events -- +-- logging 25 at INFO, messages should be seen every 10 events -- +-- logging 26 at INFO, messages should be seen every 10 events -- +-- logging 27 at INFO, messages should be seen every 10 events -- +-- logging 28 at INFO, messages should be seen every 10 events -- +-- logging 29 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 20 +INFO:root:Info index = 21 +INFO:root:Info index = 22 +INFO:root:Info index = 23 +INFO:root:Info index = 24 +INFO:root:Info index = 25 +INFO:root:Info index = 26 +INFO:root:Info index = 27 +INFO:root:Info index = 28 +INFO:root:Info index = 29 +-- logging 30 at INFO, messages should be seen every 10 events -- +-- logging 31 at INFO, messages should be seen every 10 events -- +-- logging 32 at INFO, messages should be seen every 10 events -- +-- logging 33 at INFO, messages should be seen every 10 events -- +-- logging 34 at INFO, messages should be seen every 10 events -- +-- logging 35 at INFO, messages should be seen every 10 events -- +-- logging 36 at INFO, messages should be seen every 10 events -- +-- logging 37 at INFO, messages should be seen every 10 events -- +-- logging 38 at INFO, messages should be seen every 10 events -- +-- logging 39 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 30 +INFO:root:Info index = 31 +INFO:root:Info index = 32 +INFO:root:Info index = 33 +INFO:root:Info index = 34 +INFO:root:Info index = 35 +INFO:root:Info index = 36 +INFO:root:Info index = 37 +INFO:root:Info index = 38 +INFO:root:Info index = 39 +-- logging 40 at INFO, messages should be seen every 10 events -- +-- logging 41 at INFO, messages should be seen every 10 events -- +-- logging 42 at INFO, messages should be seen every 10 events -- +-- logging 43 at INFO, messages should be seen every 10 events -- +-- logging 44 at INFO, messages should be seen every 10 events -- +-- logging 45 at INFO, messages should be seen every 10 events -- +-- logging 46 at INFO, messages should be seen every 10 events -- +-- logging 47 at INFO, messages should be seen every 10 events -- +-- logging 48 at INFO, messages should be seen every 10 events -- +-- logging 49 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 40 +INFO:root:Info index = 41 +INFO:root:Info index = 42 +INFO:root:Info index = 43 +INFO:root:Info index = 44 +INFO:root:Info index = 45 +INFO:root:Info index = 46 +INFO:root:Info index = 47 +INFO:root:Info index = 48 +INFO:root:Info index = 49 +-- logging 50 at INFO, messages should be seen every 10 events -- +-- logging 51 at INFO, messages should be seen every 10 events -- +-- logging 52 at INFO, messages should be seen every 10 events -- +-- logging 53 at INFO, messages should be seen every 10 events -- +-- logging 54 at INFO, messages should be seen every 10 events -- +-- logging 55 at INFO, messages should be seen every 10 events -- +-- logging 56 at INFO, messages should be seen every 10 events -- +-- logging 57 at INFO, messages should be seen every 10 events -- +-- logging 58 at INFO, messages should be seen every 10 events -- +-- logging 59 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 50 +INFO:root:Info index = 51 +INFO:root:Info index = 52 +INFO:root:Info index = 53 +INFO:root:Info index = 54 +INFO:root:Info index = 55 +INFO:root:Info index = 56 +INFO:root:Info index = 57 +INFO:root:Info index = 58 +INFO:root:Info index = 59 +-- logging 60 at INFO, messages should be seen every 10 events -- +-- logging 61 at INFO, messages should be seen every 10 events -- +-- logging 62 at INFO, messages should be seen every 10 events -- +-- logging 63 at INFO, messages should be seen every 10 events -- +-- logging 64 at INFO, messages should be seen every 10 events -- +-- logging 65 at INFO, messages should be seen every 10 events -- +-- logging 66 at INFO, messages should be seen every 10 events -- +-- logging 67 at INFO, messages should be seen every 10 events -- +-- logging 68 at INFO, messages should be seen every 10 events -- +-- logging 69 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 60 +INFO:root:Info index = 61 +INFO:root:Info index = 62 +INFO:root:Info index = 63 +INFO:root:Info index = 64 +INFO:root:Info index = 65 +INFO:root:Info index = 66 +INFO:root:Info index = 67 +INFO:root:Info index = 68 +INFO:root:Info index = 69 +-- logging 70 at INFO, messages should be seen every 10 events -- +-- logging 71 at INFO, messages should be seen every 10 events -- +-- logging 72 at INFO, messages should be seen every 10 events -- +-- logging 73 at INFO, messages should be seen every 10 events -- +-- logging 74 at INFO, messages should be seen every 10 events -- +-- logging 75 at INFO, messages should be seen every 10 events -- +-- logging 76 at INFO, messages should be seen every 10 events -- +-- logging 77 at INFO, messages should be seen every 10 events -- +-- logging 78 at INFO, messages should be seen every 10 events -- +-- logging 79 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 70 +INFO:root:Info index = 71 +INFO:root:Info index = 72 +INFO:root:Info index = 73 +INFO:root:Info index = 74 +INFO:root:Info index = 75 +INFO:root:Info index = 76 +INFO:root:Info index = 77 +INFO:root:Info index = 78 +INFO:root:Info index = 79 +-- logging 80 at INFO, messages should be seen every 10 events -- +-- logging 81 at INFO, messages should be seen every 10 events -- +-- logging 82 at INFO, messages should be seen every 10 events -- +-- logging 83 at INFO, messages should be seen every 10 events -- +-- logging 84 at INFO, messages should be seen every 10 events -- +-- logging 85 at INFO, messages should be seen every 10 events -- +-- logging 86 at INFO, messages should be seen every 10 events -- +-- logging 87 at INFO, messages should be seen every 10 events -- +-- logging 88 at INFO, messages should be seen every 10 events -- +-- logging 89 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 80 +INFO:root:Info index = 81 +INFO:root:Info index = 82 +INFO:root:Info index = 83 +INFO:root:Info index = 84 +INFO:root:Info index = 85 +INFO:root:Info index = 86 +INFO:root:Info index = 87 +INFO:root:Info index = 88 +INFO:root:Info index = 89 +-- logging 90 at INFO, messages should be seen every 10 events -- +-- logging 91 at INFO, messages should be seen every 10 events -- +-- logging 92 at INFO, messages should be seen every 10 events -- +-- logging 93 at INFO, messages should be seen every 10 events -- +-- logging 94 at INFO, messages should be seen every 10 events -- +-- logging 95 at INFO, messages should be seen every 10 events -- +-- logging 96 at INFO, messages should be seen every 10 events -- +-- logging 97 at INFO, messages should be seen every 10 events -- +-- logging 98 at INFO, messages should be seen every 10 events -- +-- logging 99 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 90 +INFO:root:Info index = 91 +INFO:root:Info index = 92 +INFO:root:Info index = 93 +INFO:root:Info index = 94 +INFO:root:Info index = 95 +INFO:root:Info index = 96 +INFO:root:Info index = 97 +INFO:root:Info index = 98 +INFO:root:Info index = 99 +-- logging 100 at INFO, messages should be seen every 10 events -- +-- logging 101 at INFO, messages should be seen every 10 events -- +INFO:root:Info index = 100 +INFO:root:Info index = 101 +-- log_test2 end --------------------------------------------------- +-- log_test3 begin --------------------------------------------------- +Unfiltered... +INFO:a:Info 1 +INFO:a.b:Info 2 +INFO:a.c:Info 3 +INFO:a.b.c:Info 4 +INFO:a.b.c.d:Info 5 +INFO:a.bb.c:Info 6 +INFO:b:Info 7 +INFO:b.a:Info 8 +INFO:c.a.b:Info 9 +INFO:a.bb:Info 10 +Filtered with 'a.b'... +INFO:a.b:Info 2 +INFO:a.b.c:Info 4 +INFO:a.b.c.d:Info 5 +-- log_test3 end --------------------------------------------------- +-- logrecv output begin --------------------------------------------------- +ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) +ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) +INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) +INF -> ERROR: Message 3 (via logrecv.tcp.INF) +INF -> WARNING: Message 4 (via logrecv.tcp.INF) +INF -> INFO: Message 5 (via logrecv.tcp.INF) +INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> WARNING: Message 8 (via logrecv.tcp.INF.UNDEF) +INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF) +INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR) +INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR) +INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF) +INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF) +DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB) +DEB -> ERROR: Message 15 (via logrecv.tcp.DEB) +DEB -> WARNING: Message 16 (via logrecv.tcp.DEB) +DEB -> INFO: Message 17 (via logrecv.tcp.DEB) +DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB) +UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF) +UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF) +UNDEF -> WARNING: Message 21 (via logrecv.tcp.UNDEF) +UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF) +INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF) +INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT) +INF -> INFO: Finish up, it's closing time. Messages should bear numbers 0 through 24. (via logrecv.tcp.INF) +-- logrecv output end --------------------------------------------------- Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_math ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_math (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_math Fri May 5 21:25:58 2006 @@ -1,28 +1,28 @@ -test_math -math module, testing with eps 1e-05 -constants -acos -asin -atan -atan2 -ceil -cos -cosh -degrees -exp -fabs -floor -fmod -frexp -hypot -ldexp -log -log10 -modf -pow -radians -sin -sinh -sqrt -tan -tanh +test_math +math module, testing with eps 1e-05 +constants +acos +asin +atan +atan2 +ceil +cos +cosh +degrees +exp +fabs +floor +fmod +frexp +hypot +ldexp +log +log10 +modf +pow +radians +sin +sinh +sqrt +tan +tanh Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_mmap ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_mmap (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_mmap Fri May 5 21:25:58 2006 @@ -1,35 +1,35 @@ -test_mmap - - Position of foo: 1.0 pages - Length of file: 2.0 pages - Contents of byte 0: '\x00' - Contents of first 3 bytes: '\x00\x00\x00' - - Modifying file's content... - Contents of byte 0: '3' - Contents of first 3 bytes: '3\x00\x00' - Contents of second page: '\x00foobar\x00' - Regex match on mmap (page start, length of match): 1.0 6 - Seek to zeroth byte - Seek to 42nd byte - Seek to last byte - Try to seek to negative position... - Try to seek beyond end of mmap... - Try to seek to negative position... - Attempting resize() - Creating 10 byte test data file. - Opening mmap with access=ACCESS_READ - Ensuring that readonly mmap can't be slice assigned. - Ensuring that readonly mmap can't be item assigned. - Ensuring that readonly mmap can't be write() to. - Ensuring that readonly mmap can't be write_byte() to. - Ensuring that readonly mmap can't be resized. - Opening mmap with size too big - Opening mmap with access=ACCESS_WRITE - Modifying write-through memory map. - Opening mmap with access=ACCESS_COPY - Modifying copy-on-write memory map. - Ensuring copy-on-write maps cannot be resized. - Ensuring invalid access parameter raises exception. - Try opening a bad file descriptor... - Test passed +test_mmap + + Position of foo: 1.0 pages + Length of file: 2.0 pages + Contents of byte 0: '\x00' + Contents of first 3 bytes: '\x00\x00\x00' + + Modifying file's content... + Contents of byte 0: '3' + Contents of first 3 bytes: '3\x00\x00' + Contents of second page: '\x00foobar\x00' + Regex match on mmap (page start, length of match): 1.0 6 + Seek to zeroth byte + Seek to 42nd byte + Seek to last byte + Try to seek to negative position... + Try to seek beyond end of mmap... + Try to seek to negative position... + Attempting resize() + Creating 10 byte test data file. + Opening mmap with access=ACCESS_READ + Ensuring that readonly mmap can't be slice assigned. + Ensuring that readonly mmap can't be item assigned. + Ensuring that readonly mmap can't be write() to. + Ensuring that readonly mmap can't be write_byte() to. + Ensuring that readonly mmap can't be resized. + Opening mmap with size too big + Opening mmap with access=ACCESS_WRITE + Modifying write-through memory map. + Opening mmap with access=ACCESS_COPY + Modifying copy-on-write memory map. + Ensuring copy-on-write maps cannot be resized. + Ensuring invalid access parameter raises exception. + Try opening a bad file descriptor... + Test passed Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_new ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_new (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_new Fri May 5 21:25:58 2006 @@ -1,7 +1,7 @@ -test_new -new.module() -new.classobj() -new.instance() -new.instancemethod() -new.function() -new.code() +test_new +new.module() +new.classobj() +new.instance() +new.instancemethod() +new.function() +new.code() Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_nis ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_nis (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_nis Fri May 5 21:25:58 2006 @@ -1,2 +1,2 @@ -test_nis -nis.maps() +test_nis +nis.maps() Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_opcodes ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_opcodes (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_opcodes Fri May 5 21:25:58 2006 @@ -1,6 +1,6 @@ -test_opcodes -2. Opcodes -XXX Not yet fully implemented -2.1 try inside for loop -2.2 raise class exceptions -2.3 comparing function objects +test_opcodes +2. Opcodes +XXX Not yet fully implemented +2.1 try inside for loop +2.2 raise class exceptions +2.3 comparing function objects Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_openpty ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_openpty (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_openpty Fri May 5 21:25:58 2006 @@ -1,2 +1,2 @@ -test_openpty -Ping! +test_openpty +Ping! Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_operations ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_operations (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_operations Fri May 5 21:25:58 2006 @@ -1,6 +1,6 @@ -test_operations -3. Operations -XXX Mostly not yet implemented -3.1 Dictionary lookups succeed even if __cmp__() raises an exception -raising error -No exception passed through. +test_operations +3. Operations +XXX Mostly not yet implemented +3.1 Dictionary lookups succeed even if __cmp__() raises an exception +raising error +No exception passed through. Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_ossaudiodev ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_ossaudiodev (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_ossaudiodev Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_ossaudiodev -playing test sound file... -elapsed time: 3.1 sec +test_ossaudiodev +playing test sound file... +elapsed time: 3.1 sec Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_pep277 ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_pep277 (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_pep277 Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_pep277 -u'\xdf-\u66e8\u66e9\u66eb' -[u'Gr\xfc\xdf-Gott', u'abc', u'ascii', u'\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', u'\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', u'\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', u'\u306b\u307d\u3093', u'\u66e8\u05e9\u3093\u0434\u0393\xdf', u'\u66e8\u66e9\u66eb'] +test_pep277 +u'\xdf-\u66e8\u66e9\u66eb' +[u'Gr\xfc\xdf-Gott', u'abc', u'ascii', u'\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', u'\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', u'\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', u'\u306b\u307d\u3093', u'\u66e8\u05e9\u3093\u0434\u0393\xdf', u'\u66e8\u66e9\u66eb'] Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_pkg ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_pkg (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_pkg Fri May 5 21:25:58 2006 @@ -1,45 +1,45 @@ -test_pkg -running test t1 -running test t2 -t2 loading -doc for t2 -t2.sub.subsub loading -t2 t2.sub t2.sub.subsub -['sub', 't2'] -t2.sub t2.sub.subsub -t2.sub.subsub -['spam', 'sub', 'subsub', 't2'] -t2 t2.sub t2.sub.subsub -['spam', 'sub', 'subsub', 't2'] -running test t3 -t3 loading -t3.sub.subsub loading -t3 t3.sub t3.sub.subsub -t3 loading -t3.sub.subsub loading -running test t4 -t4 loading -t4.sub.subsub loading -t4.sub.subsub.spam = 1 -running test t5 -t5.foo loading -t5.string loading -1 -['foo', 'string', 't5'] -['__doc__', '__file__', '__name__', '__path__', 'foo', 'string', 't5'] -['__doc__', '__file__', '__name__', 'string'] -['__doc__', '__file__', '__name__', 'spam'] -running test t6 -['__all__', '__doc__', '__file__', '__name__', '__path__'] -t6.spam loading -t6.ham loading -t6.eggs loading -['__all__', '__doc__', '__file__', '__name__', '__path__', 'eggs', 'ham', 'spam'] -['eggs', 'ham', 'spam', 't6'] -running test t7 -t7 loading -['__doc__', '__file__', '__name__', '__path__'] -['__doc__', '__file__', '__name__', '__path__'] -t7.sub.subsub loading -['__doc__', '__file__', '__name__', '__path__', 'spam'] -t7.sub.subsub.spam = 1 +test_pkg +running test t1 +running test t2 +t2 loading +doc for t2 +t2.sub.subsub loading +t2 t2.sub t2.sub.subsub +['sub', 't2'] +t2.sub t2.sub.subsub +t2.sub.subsub +['spam', 'sub', 'subsub', 't2'] +t2 t2.sub t2.sub.subsub +['spam', 'sub', 'subsub', 't2'] +running test t3 +t3 loading +t3.sub.subsub loading +t3 t3.sub t3.sub.subsub +t3 loading +t3.sub.subsub loading +running test t4 +t4 loading +t4.sub.subsub loading +t4.sub.subsub.spam = 1 +running test t5 +t5.foo loading +t5.string loading +1 +['foo', 'string', 't5'] +['__doc__', '__file__', '__name__', '__path__', 'foo', 'string', 't5'] +['__doc__', '__file__', '__name__', 'string'] +['__doc__', '__file__', '__name__', 'spam'] +running test t6 +['__all__', '__doc__', '__file__', '__name__', '__path__'] +t6.spam loading +t6.ham loading +t6.eggs loading +['__all__', '__doc__', '__file__', '__name__', '__path__', 'eggs', 'ham', 'spam'] +['eggs', 'ham', 'spam', 't6'] +running test t7 +t7 loading +['__doc__', '__file__', '__name__', '__path__'] +['__doc__', '__file__', '__name__', '__path__'] +t7.sub.subsub loading +['__doc__', '__file__', '__name__', '__path__', 'spam'] +t7.sub.subsub.spam = 1 Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_poll ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_poll (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_poll Fri May 5 21:25:58 2006 @@ -1,19 +1,19 @@ -test_poll -Running poll test 1 - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. -Poll test 1 complete -Running poll test 2 -Poll test 2 complete -Running poll test 3 -Poll test 3 complete +test_poll +Running poll test 1 + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. + This is a test. +Poll test 1 complete +Running poll test 2 +Poll test 2 complete +Running poll test 3 +Poll test 3 complete Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_popen ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_popen (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_popen Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_popen -Test popen: -popen seemed to process the command-line correctly +test_popen +Test popen: +popen seemed to process the command-line correctly Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_popen2 ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_popen2 (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_popen2 Fri May 5 21:25:58 2006 @@ -1,9 +1,9 @@ -test_popen2 -Test popen2 module: -testing popen2... -testing popen3... -All OK -Testing os module: -testing popen2... -testing popen3... -All OK +test_popen2 +Test popen2 module: +testing popen2... +testing popen3... +All OK +Testing os module: +testing popen2... +testing popen3... +All OK Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_profile ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_profile (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_profile Fri May 5 21:25:58 2006 @@ -1,20 +1,20 @@ -test_profile - 74 function calls in 1.000 CPU seconds - - Ordered by: standard name - - ncalls tottime percall cumtime percall filename:lineno(function) - 12 0.000 0.000 0.012 0.001 :0(hasattr) - 8 0.000 0.000 0.000 0.000 :0(range) - 1 0.000 0.000 0.000 0.000 :0(setprofile) - 1 0.000 0.000 1.000 1.000 :1(?) - 0 0.000 0.000 profile:0(profiler) - 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) - 1 0.400 0.400 1.000 1.000 test_profile.py:23(testfunc) - 2 0.080 0.040 0.600 0.300 test_profile.py:32(helper) - 4 0.116 0.029 0.120 0.030 test_profile.py:50(helper1) - 8 0.312 0.039 0.400 0.050 test_profile.py:58(helper2) - 8 0.064 0.008 0.080 0.010 test_profile.py:68(subhelper) - 28 0.028 0.001 0.028 0.001 test_profile.py:80(__getattr__) - - +test_profile + 74 function calls in 1.000 CPU seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 12 0.000 0.000 0.012 0.001 :0(hasattr) + 8 0.000 0.000 0.000 0.000 :0(range) + 1 0.000 0.000 0.000 0.000 :0(setprofile) + 1 0.000 0.000 1.000 1.000 :1(?) + 0 0.000 0.000 profile:0(profiler) + 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) + 1 0.400 0.400 1.000 1.000 test_profile.py:23(testfunc) + 2 0.080 0.040 0.600 0.300 test_profile.py:32(helper) + 4 0.116 0.029 0.120 0.030 test_profile.py:50(helper1) + 8 0.312 0.039 0.400 0.050 test_profile.py:58(helper2) + 8 0.064 0.008 0.080 0.010 test_profile.py:68(subhelper) + 28 0.028 0.001 0.028 0.001 test_profile.py:80(__getattr__) + + Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_pty ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_pty (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_pty Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_pty -I wish to buy a fish license. -For my pet fish, Eric. +test_pty +I wish to buy a fish license. +For my pet fish, Eric. Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_pyexpat ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_pyexpat (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_pyexpat Fri May 5 21:25:58 2006 @@ -1,110 +1,110 @@ -test_pyexpat -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -PI: - 'xml-stylesheet' 'href="stylesheet.css"' -Comment: - ' comment data ' -Notation declared: ('notation', None, 'notation.jpeg', None) -Unparsed entity decl: - ('unparsed_entity', None, 'entity.file', None, 'notation') -Start element: - 'root' {'attr1': 'value1', 'attr2': 'value2\xe1\xbd\x80'} -NS decl: - 'myns' 'http://www.python.org/namespace' -Start element: - 'http://www.python.org/namespace!subelement' {} -Character data: - 'Contents of subelements' -End element: - 'http://www.python.org/namespace!subelement' -End of NS decl: - 'myns' -Start element: - 'sub2' {} -Start of CDATA section -Character data: - 'contents of CDATA section' -End of CDATA section -End element: - 'sub2' -External entity ref: (None, 'entity.file', None) -End element: - 'root' -PI: - u'xml-stylesheet' u'href="stylesheet.css"' -Comment: - u' comment data ' -Notation declared: (u'notation', None, u'notation.jpeg', None) -Unparsed entity decl: - (u'unparsed_entity', None, u'entity.file', None, u'notation') -Start element: - u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} -NS decl: - u'myns' u'http://www.python.org/namespace' -Start element: - u'http://www.python.org/namespace!subelement' {} -Character data: - u'Contents of subelements' -End element: - u'http://www.python.org/namespace!subelement' -End of NS decl: - u'myns' -Start element: - u'sub2' {} -Start of CDATA section -Character data: - u'contents of CDATA section' -End of CDATA section -End element: - u'sub2' -External entity ref: (None, u'entity.file', None) -End element: - u'root' -PI: - u'xml-stylesheet' u'href="stylesheet.css"' -Comment: - u' comment data ' -Notation declared: (u'notation', None, u'notation.jpeg', None) -Unparsed entity decl: - (u'unparsed_entity', None, u'entity.file', None, u'notation') -Start element: - u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} -NS decl: - u'myns' u'http://www.python.org/namespace' -Start element: - u'http://www.python.org/namespace!subelement' {} -Character data: - u'Contents of subelements' -End element: - u'http://www.python.org/namespace!subelement' -End of NS decl: - u'myns' -Start element: - u'sub2' {} -Start of CDATA section -Character data: - u'contents of CDATA section' -End of CDATA section -End element: - u'sub2' -External entity ref: (None, u'entity.file', None) -End element: - u'root' - -Testing constructor for proper handling of namespace_separator values: -Legal values tested o.k. -Caught expected TypeError: -ParserCreate() argument 2 must be string or None, not int -Caught expected ValueError: -namespace_separator must be at most one character, omitted, or None +test_pyexpat +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +PI: + 'xml-stylesheet' 'href="stylesheet.css"' +Comment: + ' comment data ' +Notation declared: ('notation', None, 'notation.jpeg', None) +Unparsed entity decl: + ('unparsed_entity', None, 'entity.file', None, 'notation') +Start element: + 'root' {'attr1': 'value1', 'attr2': 'value2\xe1\xbd\x80'} +NS decl: + 'myns' 'http://www.python.org/namespace' +Start element: + 'http://www.python.org/namespace!subelement' {} +Character data: + 'Contents of subelements' +End element: + 'http://www.python.org/namespace!subelement' +End of NS decl: + 'myns' +Start element: + 'sub2' {} +Start of CDATA section +Character data: + 'contents of CDATA section' +End of CDATA section +End element: + 'sub2' +External entity ref: (None, 'entity.file', None) +End element: + 'root' +PI: + u'xml-stylesheet' u'href="stylesheet.css"' +Comment: + u' comment data ' +Notation declared: (u'notation', None, u'notation.jpeg', None) +Unparsed entity decl: + (u'unparsed_entity', None, u'entity.file', None, u'notation') +Start element: + u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} +NS decl: + u'myns' u'http://www.python.org/namespace' +Start element: + u'http://www.python.org/namespace!subelement' {} +Character data: + u'Contents of subelements' +End element: + u'http://www.python.org/namespace!subelement' +End of NS decl: + u'myns' +Start element: + u'sub2' {} +Start of CDATA section +Character data: + u'contents of CDATA section' +End of CDATA section +End element: + u'sub2' +External entity ref: (None, u'entity.file', None) +End element: + u'root' +PI: + u'xml-stylesheet' u'href="stylesheet.css"' +Comment: + u' comment data ' +Notation declared: (u'notation', None, u'notation.jpeg', None) +Unparsed entity decl: + (u'unparsed_entity', None, u'entity.file', None, u'notation') +Start element: + u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} +NS decl: + u'myns' u'http://www.python.org/namespace' +Start element: + u'http://www.python.org/namespace!subelement' {} +Character data: + u'Contents of subelements' +End element: + u'http://www.python.org/namespace!subelement' +End of NS decl: + u'myns' +Start element: + u'sub2' {} +Start of CDATA section +Character data: + u'contents of CDATA section' +End of CDATA section +End element: + u'sub2' +External entity ref: (None, u'entity.file', None) +End element: + u'root' + +Testing constructor for proper handling of namespace_separator values: +Legal values tested o.k. +Caught expected TypeError: +ParserCreate() argument 2 must be string or None, not int +Caught expected ValueError: +namespace_separator must be at most one character, omitted, or None Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_regex ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_regex (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_regex Fri May 5 21:25:58 2006 @@ -1,29 +1,29 @@ -test_regex -no match: -1 -successful search: 6 -caught expected exception -failed awk syntax: -1 -successful awk syntax: 2 -failed awk syntax: -1 -matching with group names and compile() --1 -caught expected exception -matching with group names and symcomp() -7 -801 999 -801 -('801', '999') -('801', '999') -realpat: \([0-9]+\) *\([0-9]+\) -groupindex: {'one': 1, 'two': 2} -not case folded search: -1 -case folded search: 6 -__members__: ['last', 'regs', 'translate', 'groupindex', 'realpat', 'givenpat'] -regs: ((6, 11), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1)) -last: HELLO WORLD -translate: 256 -givenpat: world -match with pos: -1 -search with pos: 18 -bogus group: ('world', None, None) -no name: caught expected exception +test_regex +no match: -1 +successful search: 6 +caught expected exception +failed awk syntax: -1 +successful awk syntax: 2 +failed awk syntax: -1 +matching with group names and compile() +-1 +caught expected exception +matching with group names and symcomp() +7 +801 999 +801 +('801', '999') +('801', '999') +realpat: \([0-9]+\) *\([0-9]+\) +groupindex: {'one': 1, 'two': 2} +not case folded search: -1 +case folded search: 6 +__members__: ['last', 'regs', 'translate', 'groupindex', 'realpat', 'givenpat'] +regs: ((6, 11), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1)) +last: HELLO WORLD +translate: 256 +givenpat: world +match with pos: -1 +search with pos: 18 +bogus group: ('world', None, None) +no name: caught expected exception Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_resource ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_resource (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_resource Fri May 5 21:25:58 2006 @@ -1,2 +1,2 @@ -test_resource -True +test_resource +True Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_rgbimg ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_rgbimg (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_rgbimg Fri May 5 21:25:58 2006 @@ -1,2 +1,2 @@ -test_rgbimg -RGBimg test suite: +test_rgbimg +RGBimg test suite: Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_scope ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_scope (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_scope Fri May 5 21:25:58 2006 @@ -1,24 +1,24 @@ -test_scope -1. simple nesting -2. extra nesting -3. simple nesting + rebinding -4. nesting with global but no free -5. nesting through class -6. nesting plus free ref to global -7. nearest enclosing scope -8. mixed freevars and cellvars -9. free variable in method -10. recursion -11. unoptimized namespaces -12. lambdas -13. UnboundLocal -14. complex definitions -15. scope of global statements -16. check leaks -17. class and global -18. verify that locals() works -19. var is bound and free in class -20. interaction with trace function -20. eval and exec with free variables -21. list comprehension with local variables -22. eval with free variables +test_scope +1. simple nesting +2. extra nesting +3. simple nesting + rebinding +4. nesting with global but no free +5. nesting through class +6. nesting plus free ref to global +7. nearest enclosing scope +8. mixed freevars and cellvars +9. free variable in method +10. recursion +11. unoptimized namespaces +12. lambdas +13. UnboundLocal +14. complex definitions +15. scope of global statements +16. check leaks +17. class and global +18. verify that locals() works +19. var is bound and free in class +20. interaction with trace function +20. eval and exec with free variables +21. list comprehension with local variables +22. eval with free variables Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_signal ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_signal (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_signal Fri May 5 21:25:58 2006 @@ -1,2 +1,2 @@ -test_signal -starting pause() loop... +test_signal +starting pause() loop... Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_thread ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_thread (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_thread Fri May 5 21:25:58 2006 @@ -1,6 +1,6 @@ -test_thread -waiting for all tasks to complete -all tasks done - -*** Barrier Test *** -all tasks done +test_thread +waiting for all tasks to complete +all tasks done + +*** Barrier Test *** +all tasks done Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_threadedtempfile ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_threadedtempfile (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_threadedtempfile Fri May 5 21:25:58 2006 @@ -1,5 +1,5 @@ -test_threadedtempfile -Creating -Starting -Reaping -Done: errors 0 ok 1000 +test_threadedtempfile +Creating +Starting +Reaping +Done: errors 0 ok 1000 Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_tokenize ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_tokenize (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_tokenize Fri May 5 21:25:58 2006 @@ -1,659 +1,659 @@ -test_tokenize -1,0-1,35: COMMENT "# Tests for the 'tokenize' module.\n" -2,0-2,43: COMMENT '# Large bits stolen from test_grammar.py. \n' -3,0-3,1: NL '\n' -4,0-4,11: COMMENT '# Comments\n' -5,0-5,3: STRING '"#"' -5,3-5,4: NEWLINE '\n' -6,0-6,3: COMMENT "#'\n" -7,0-7,3: COMMENT '#"\n' -8,0-8,3: COMMENT '#\\\n' -9,7-9,9: COMMENT '#\n' -10,4-10,10: COMMENT '# abc\n' -11,0-12,4: STRING "'''#\n#'''" -12,4-12,5: NEWLINE '\n' -13,0-13,1: NL '\n' -14,0-14,1: NAME 'x' -14,2-14,3: OP '=' -14,4-14,5: NUMBER '1' -14,7-14,8: COMMENT '#' -14,8-14,9: NEWLINE '\n' -15,0-15,1: NL '\n' -16,0-16,25: COMMENT '# Balancing continuation\n' -17,0-17,1: NL '\n' -18,0-18,1: NAME 'a' -18,2-18,3: OP '=' -18,4-18,5: OP '(' -18,5-18,6: NUMBER '3' -18,6-18,7: OP ',' -18,8-18,9: NUMBER '4' -18,9-18,10: OP ',' -18,10-18,11: NL '\n' -19,2-19,3: NUMBER '5' -19,3-19,4: OP ',' -19,5-19,6: NUMBER '6' -19,6-19,7: OP ')' -19,7-19,8: NEWLINE '\n' -20,0-20,1: NAME 'y' -20,2-20,3: OP '=' -20,4-20,5: OP '[' -20,5-20,6: NUMBER '3' -20,6-20,7: OP ',' -20,8-20,9: NUMBER '4' -20,9-20,10: OP ',' -20,10-20,11: NL '\n' -21,2-21,3: NUMBER '5' -21,3-21,4: OP ']' -21,4-21,5: NEWLINE '\n' -22,0-22,1: NAME 'z' -22,2-22,3: OP '=' -22,4-22,5: OP '{' -22,5-22,8: STRING "'a'" -22,8-22,9: OP ':' -22,9-22,10: NUMBER '5' -22,10-22,11: OP ',' -22,11-22,12: NL '\n' -23,2-23,5: STRING "'b'" -23,5-23,6: OP ':' -23,6-23,7: NUMBER '6' -23,7-23,8: OP '}' -23,8-23,9: NEWLINE '\n' -24,0-24,1: NAME 'x' -24,2-24,3: OP '=' -24,4-24,5: OP '(' -24,5-24,8: NAME 'len' -24,8-24,9: OP '(' -24,9-24,10: OP '`' -24,10-24,11: NAME 'y' -24,11-24,12: OP '`' -24,12-24,13: OP ')' -24,14-24,15: OP '+' -24,16-24,17: NUMBER '5' -24,17-24,18: OP '*' -24,18-24,19: NAME 'x' -24,20-24,21: OP '-' -24,22-24,23: NAME 'a' -24,23-24,24: OP '[' -24,24-24,25: NL '\n' -25,3-25,4: NUMBER '3' -25,5-25,6: OP ']' -25,6-25,7: NL '\n' -26,3-26,4: OP '-' -26,5-26,6: NAME 'x' -26,7-26,8: OP '+' -26,9-26,12: NAME 'len' -26,12-26,13: OP '(' -26,13-26,14: OP '{' -26,14-26,15: NL '\n' -27,3-27,4: OP '}' -27,4-27,5: NL '\n' -28,4-28,5: OP ')' -28,5-28,6: NL '\n' -29,2-29,3: OP ')' -29,3-29,4: NEWLINE '\n' -30,0-30,1: NL '\n' -31,0-31,37: COMMENT '# Backslash means line continuation:\n' -32,0-32,1: NAME 'x' -32,2-32,3: OP '=' -32,4-32,5: NUMBER '1' -33,0-33,1: OP '+' -33,2-33,3: NUMBER '1' -33,3-33,4: NEWLINE '\n' -34,0-34,1: NL '\n' -35,0-35,55: COMMENT '# Backslash does not means continuation in comments :\\\n' -36,0-36,1: NAME 'x' -36,2-36,3: OP '=' -36,4-36,5: NUMBER '0' -36,5-36,6: NEWLINE '\n' -37,0-37,1: NL '\n' -38,0-38,20: COMMENT '# Ordinary integers\n' -39,0-39,4: NUMBER '0xff' -39,5-39,7: OP '<>' -39,8-39,11: NUMBER '255' -39,11-39,12: NEWLINE '\n' -40,0-40,4: NUMBER '0377' -40,5-40,7: OP '<>' -40,8-40,11: NUMBER '255' -40,11-40,12: NEWLINE '\n' -41,0-41,10: NUMBER '2147483647' -41,13-41,15: OP '!=' -41,16-41,28: NUMBER '017777777777' -41,28-41,29: NEWLINE '\n' -42,0-42,1: OP '-' -42,1-42,11: NUMBER '2147483647' -42,11-42,12: OP '-' -42,12-42,13: NUMBER '1' -42,14-42,16: OP '!=' -42,17-42,29: NUMBER '020000000000' -42,29-42,30: NEWLINE '\n' -43,0-43,12: NUMBER '037777777777' -43,13-43,15: OP '!=' -43,16-43,17: OP '-' -43,17-43,18: NUMBER '1' -43,18-43,19: NEWLINE '\n' -44,0-44,10: NUMBER '0xffffffff' -44,11-44,13: OP '!=' -44,14-44,15: OP '-' -44,15-44,16: NUMBER '1' -44,16-44,17: NEWLINE '\n' -45,0-45,1: NL '\n' -46,0-46,16: COMMENT '# Long integers\n' -47,0-47,1: NAME 'x' -47,2-47,3: OP '=' -47,4-47,6: NUMBER '0L' -47,6-47,7: NEWLINE '\n' -48,0-48,1: NAME 'x' -48,2-48,3: OP '=' -48,4-48,6: NUMBER '0l' -48,6-48,7: NEWLINE '\n' -49,0-49,1: NAME 'x' -49,2-49,3: OP '=' -49,4-49,23: NUMBER '0xffffffffffffffffL' -49,23-49,24: NEWLINE '\n' -50,0-50,1: NAME 'x' -50,2-50,3: OP '=' -50,4-50,23: NUMBER '0xffffffffffffffffl' -50,23-50,24: NEWLINE '\n' -51,0-51,1: NAME 'x' -51,2-51,3: OP '=' -51,4-51,23: NUMBER '077777777777777777L' -51,23-51,24: NEWLINE '\n' -52,0-52,1: NAME 'x' -52,2-52,3: OP '=' -52,4-52,23: NUMBER '077777777777777777l' -52,23-52,24: NEWLINE '\n' -53,0-53,1: NAME 'x' -53,2-53,3: OP '=' -53,4-53,35: NUMBER '123456789012345678901234567890L' -53,35-53,36: NEWLINE '\n' -54,0-54,1: NAME 'x' -54,2-54,3: OP '=' -54,4-54,35: NUMBER '123456789012345678901234567890l' -54,35-54,36: NEWLINE '\n' -55,0-55,1: NL '\n' -56,0-56,25: COMMENT '# Floating-point numbers\n' -57,0-57,1: NAME 'x' -57,2-57,3: OP '=' -57,4-57,8: NUMBER '3.14' -57,8-57,9: NEWLINE '\n' -58,0-58,1: NAME 'x' -58,2-58,3: OP '=' -58,4-58,8: NUMBER '314.' -58,8-58,9: NEWLINE '\n' -59,0-59,1: NAME 'x' -59,2-59,3: OP '=' -59,4-59,9: NUMBER '0.314' -59,9-59,10: NEWLINE '\n' -60,0-60,18: COMMENT '# XXX x = 000.314\n' -61,0-61,1: NAME 'x' -61,2-61,3: OP '=' -61,4-61,8: NUMBER '.314' -61,8-61,9: NEWLINE '\n' -62,0-62,1: NAME 'x' -62,2-62,3: OP '=' -62,4-62,8: NUMBER '3e14' -62,8-62,9: NEWLINE '\n' -63,0-63,1: NAME 'x' -63,2-63,3: OP '=' -63,4-63,8: NUMBER '3E14' -63,8-63,9: NEWLINE '\n' -64,0-64,1: NAME 'x' -64,2-64,3: OP '=' -64,4-64,9: NUMBER '3e-14' -64,9-64,10: NEWLINE '\n' -65,0-65,1: NAME 'x' -65,2-65,3: OP '=' -65,4-65,9: NUMBER '3e+14' -65,9-65,10: NEWLINE '\n' -66,0-66,1: NAME 'x' -66,2-66,3: OP '=' -66,4-66,9: NUMBER '3.e14' -66,9-66,10: NEWLINE '\n' -67,0-67,1: NAME 'x' -67,2-67,3: OP '=' -67,4-67,9: NUMBER '.3e14' -67,9-67,10: NEWLINE '\n' -68,0-68,1: NAME 'x' -68,2-68,3: OP '=' -68,4-68,9: NUMBER '3.1e4' -68,9-68,10: NEWLINE '\n' -69,0-69,1: NL '\n' -70,0-70,18: COMMENT '# String literals\n' -71,0-71,1: NAME 'x' -71,2-71,3: OP '=' -71,4-71,6: STRING "''" -71,6-71,7: OP ';' -71,8-71,9: NAME 'y' -71,10-71,11: OP '=' -71,12-71,14: STRING '""' -71,14-71,15: OP ';' -71,15-71,16: NEWLINE '\n' -72,0-72,1: NAME 'x' -72,2-72,3: OP '=' -72,4-72,8: STRING "'\\''" -72,8-72,9: OP ';' -72,10-72,11: NAME 'y' -72,12-72,13: OP '=' -72,14-72,17: STRING '"\'"' -72,17-72,18: OP ';' -72,18-72,19: NEWLINE '\n' -73,0-73,1: NAME 'x' -73,2-73,3: OP '=' -73,4-73,7: STRING '\'"\'' -73,7-73,8: OP ';' -73,9-73,10: NAME 'y' -73,11-73,12: OP '=' -73,13-73,17: STRING '"\\""' -73,17-73,18: OP ';' -73,18-73,19: NEWLINE '\n' -74,0-74,1: NAME 'x' -74,2-74,3: OP '=' -74,4-74,32: STRING '"doesn\'t \\"shrink\\" does it"' -74,32-74,33: NEWLINE '\n' -75,0-75,1: NAME 'y' -75,2-75,3: OP '=' -75,4-75,31: STRING '\'doesn\\\'t "shrink" does it\'' -75,31-75,32: NEWLINE '\n' -76,0-76,1: NAME 'x' -76,2-76,3: OP '=' -76,4-76,32: STRING '"does \\"shrink\\" doesn\'t it"' -76,32-76,33: NEWLINE '\n' -77,0-77,1: NAME 'y' -77,2-77,3: OP '=' -77,4-77,31: STRING '\'does "shrink" doesn\\\'t it\'' -77,31-77,32: NEWLINE '\n' -78,0-78,1: NAME 'x' -78,2-78,3: OP '=' -78,4-83,3: STRING '"""\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n"""' -83,3-83,4: NEWLINE '\n' -84,0-84,1: NAME 'y' -84,2-84,3: OP '=' -84,4-84,63: STRING '\'\\nThe "quick"\\nbrown fox\\njumps over\\nthe \\\'lazy\\\' dog.\\n\'' -84,63-84,64: NEWLINE '\n' -85,0-85,1: NAME 'y' -85,2-85,3: OP '=' -85,4-90,3: STRING '\'\'\'\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n\'\'\'' -90,3-90,4: OP ';' -90,4-90,5: NEWLINE '\n' -91,0-91,1: NAME 'y' -91,2-91,3: OP '=' -91,4-96,1: STRING '"\\n\\\nThe \\"quick\\"\\n\\\nbrown fox\\n\\\njumps over\\n\\\nthe \'lazy\' dog.\\n\\\n"' -96,1-96,2: OP ';' -96,2-96,3: NEWLINE '\n' -97,0-97,1: NAME 'y' -97,2-97,3: OP '=' -97,4-102,1: STRING '\'\\n\\\nThe \\"quick\\"\\n\\\nbrown fox\\n\\\njumps over\\n\\\nthe \\\'lazy\\\' dog.\\n\\\n\'' -102,1-102,2: OP ';' -102,2-102,3: NEWLINE '\n' -103,0-103,1: NAME 'x' -103,2-103,3: OP '=' -103,4-103,9: STRING "r'\\\\'" -103,10-103,11: OP '+' -103,12-103,17: STRING "R'\\\\'" -103,17-103,18: NEWLINE '\n' -104,0-104,1: NAME 'x' -104,2-104,3: OP '=' -104,4-104,9: STRING "r'\\''" -104,10-104,11: OP '+' -104,12-104,14: STRING "''" -104,14-104,15: NEWLINE '\n' -105,0-105,1: NAME 'y' -105,2-105,3: OP '=' -105,4-107,6: STRING "r'''\nfoo bar \\\\\nbaz'''" -107,7-107,8: OP '+' -107,9-108,6: STRING "R'''\nfoo'''" -108,6-108,7: NEWLINE '\n' -109,0-109,1: NAME 'y' -109,2-109,3: OP '=' -109,4-111,3: STRING 'r"""foo\nbar \\\\ baz\n"""' -111,4-111,5: OP '+' -111,6-112,3: STRING "R'''spam\n'''" -112,3-112,4: NEWLINE '\n' -113,0-113,1: NAME 'x' -113,2-113,3: OP '=' -113,4-113,10: STRING "u'abc'" -113,11-113,12: OP '+' -113,13-113,19: STRING "U'ABC'" -113,19-113,20: NEWLINE '\n' -114,0-114,1: NAME 'y' -114,2-114,3: OP '=' -114,4-114,10: STRING 'u"abc"' -114,11-114,12: OP '+' -114,13-114,19: STRING 'U"ABC"' -114,19-114,20: NEWLINE '\n' -115,0-115,1: NAME 'x' -115,2-115,3: OP '=' -115,4-115,11: STRING "ur'abc'" -115,12-115,13: OP '+' -115,14-115,21: STRING "Ur'ABC'" -115,22-115,23: OP '+' -115,24-115,31: STRING "uR'ABC'" -115,32-115,33: OP '+' -115,34-115,41: STRING "UR'ABC'" -115,41-115,42: NEWLINE '\n' -116,0-116,1: NAME 'y' -116,2-116,3: OP '=' -116,4-116,11: STRING 'ur"abc"' -116,12-116,13: OP '+' -116,14-116,21: STRING 'Ur"ABC"' -116,22-116,23: OP '+' -116,24-116,31: STRING 'uR"ABC"' -116,32-116,33: OP '+' -116,34-116,41: STRING 'UR"ABC"' -116,41-116,42: NEWLINE '\n' -117,0-117,1: NAME 'x' -117,2-117,3: OP '=' -117,4-117,10: STRING "ur'\\\\'" -117,11-117,12: OP '+' -117,13-117,19: STRING "UR'\\\\'" -117,19-117,20: NEWLINE '\n' -118,0-118,1: NAME 'x' -118,2-118,3: OP '=' -118,4-118,10: STRING "ur'\\''" -118,11-118,12: OP '+' -118,13-118,15: STRING "''" -118,15-118,16: NEWLINE '\n' -119,0-119,1: NAME 'y' -119,2-119,3: OP '=' -119,4-121,6: STRING "ur'''\nfoo bar \\\\\nbaz'''" -121,7-121,8: OP '+' -121,9-122,6: STRING "UR'''\nfoo'''" -122,6-122,7: NEWLINE '\n' -123,0-123,1: NAME 'y' -123,2-123,3: OP '=' -123,4-125,3: STRING 'Ur"""foo\nbar \\\\ baz\n"""' -125,4-125,5: OP '+' -125,6-126,3: STRING "uR'''spam\n'''" -126,3-126,4: NEWLINE '\n' -127,0-127,1: NL '\n' -128,0-128,14: COMMENT '# Indentation\n' -129,0-129,2: NAME 'if' -129,3-129,4: NUMBER '1' -129,4-129,5: OP ':' -129,5-129,6: NEWLINE '\n' -130,0-130,4: INDENT ' ' -130,4-130,5: NAME 'x' -130,6-130,7: OP '=' -130,8-130,9: NUMBER '2' -130,9-130,10: NEWLINE '\n' -131,0-131,0: DEDENT '' -131,0-131,2: NAME 'if' -131,3-131,4: NUMBER '1' -131,4-131,5: OP ':' -131,5-131,6: NEWLINE '\n' -132,0-132,8: INDENT ' ' -132,8-132,9: NAME 'x' -132,10-132,11: OP '=' -132,12-132,13: NUMBER '2' -132,13-132,14: NEWLINE '\n' -133,0-133,0: DEDENT '' -133,0-133,2: NAME 'if' -133,3-133,4: NUMBER '1' -133,4-133,5: OP ':' -133,5-133,6: NEWLINE '\n' -134,0-134,4: INDENT ' ' -134,4-134,9: NAME 'while' -134,10-134,11: NUMBER '0' -134,11-134,12: OP ':' -134,12-134,13: NEWLINE '\n' -135,0-135,5: INDENT ' ' -135,5-135,7: NAME 'if' -135,8-135,9: NUMBER '0' -135,9-135,10: OP ':' -135,10-135,11: NEWLINE '\n' -136,0-136,11: INDENT ' ' -136,11-136,12: NAME 'x' -136,13-136,14: OP '=' -136,15-136,16: NUMBER '2' -136,16-136,17: NEWLINE '\n' -137,5-137,5: DEDENT '' -137,5-137,6: NAME 'x' -137,7-137,8: OP '=' -137,9-137,10: NUMBER '2' -137,10-137,11: NEWLINE '\n' -138,0-138,0: DEDENT '' -138,0-138,0: DEDENT '' -138,0-138,2: NAME 'if' -138,3-138,4: NUMBER '0' -138,4-138,5: OP ':' -138,5-138,6: NEWLINE '\n' -139,0-139,2: INDENT ' ' -139,2-139,4: NAME 'if' -139,5-139,6: NUMBER '2' -139,6-139,7: OP ':' -139,7-139,8: NEWLINE '\n' -140,0-140,3: INDENT ' ' -140,3-140,8: NAME 'while' -140,9-140,10: NUMBER '0' -140,10-140,11: OP ':' -140,11-140,12: NEWLINE '\n' -141,0-141,8: INDENT ' ' -141,8-141,10: NAME 'if' -141,11-141,12: NUMBER '1' -141,12-141,13: OP ':' -141,13-141,14: NEWLINE '\n' -142,0-142,10: INDENT ' ' -142,10-142,11: NAME 'x' -142,12-142,13: OP '=' -142,14-142,15: NUMBER '2' -142,15-142,16: NEWLINE '\n' -143,0-143,1: NL '\n' -144,0-144,12: COMMENT '# Operators\n' -145,0-145,1: NL '\n' -146,0-146,0: DEDENT '' -146,0-146,0: DEDENT '' -146,0-146,0: DEDENT '' -146,0-146,0: DEDENT '' -146,0-146,3: NAME 'def' -146,4-146,7: NAME 'd22' -146,7-146,8: OP '(' -146,8-146,9: NAME 'a' -146,9-146,10: OP ',' -146,11-146,12: NAME 'b' -146,12-146,13: OP ',' -146,14-146,15: NAME 'c' -146,15-146,16: OP '=' -146,16-146,17: NUMBER '1' -146,17-146,18: OP ',' -146,19-146,20: NAME 'd' -146,20-146,21: OP '=' -146,21-146,22: NUMBER '2' -146,22-146,23: OP ')' -146,23-146,24: OP ':' -146,25-146,29: NAME 'pass' -146,29-146,30: NEWLINE '\n' -147,0-147,3: NAME 'def' -147,4-147,8: NAME 'd01v' -147,8-147,9: OP '(' -147,9-147,10: NAME 'a' -147,10-147,11: OP '=' -147,11-147,12: NUMBER '1' -147,12-147,13: OP ',' -147,14-147,15: OP '*' -147,15-147,20: NAME 'restt' -147,20-147,21: OP ',' -147,22-147,24: OP '**' -147,24-147,29: NAME 'restd' -147,29-147,30: OP ')' -147,30-147,31: OP ':' -147,32-147,36: NAME 'pass' -147,36-147,37: NEWLINE '\n' -148,0-148,1: NL '\n' -149,0-149,1: OP '(' -149,1-149,2: NAME 'x' -149,2-149,3: OP ',' -149,4-149,5: NAME 'y' -149,5-149,6: OP ')' -149,7-149,9: OP '<>' -149,10-149,11: OP '(' -149,11-149,12: OP '{' -149,12-149,15: STRING "'a'" -149,15-149,16: OP ':' -149,16-149,17: NUMBER '1' -149,17-149,18: OP '}' -149,18-149,19: OP ',' -149,20-149,21: OP '{' -149,21-149,24: STRING "'b'" -149,24-149,25: OP ':' -149,25-149,26: NUMBER '2' -149,26-149,27: OP '}' -149,27-149,28: OP ')' -149,28-149,29: NEWLINE '\n' -150,0-150,1: NL '\n' -151,0-151,13: COMMENT '# comparison\n' -152,0-152,2: NAME 'if' -152,3-152,4: NUMBER '1' -152,5-152,6: OP '<' -152,7-152,8: NUMBER '1' -152,9-152,10: OP '>' -152,11-152,12: NUMBER '1' -152,13-152,15: OP '==' -152,16-152,17: NUMBER '1' -152,18-152,20: OP '>=' -152,21-152,22: NUMBER '1' -152,23-152,25: OP '<=' -152,26-152,27: NUMBER '1' -152,28-152,30: OP '<>' -152,31-152,32: NUMBER '1' -152,33-152,35: OP '!=' -152,36-152,37: NUMBER '1' -152,38-152,40: NAME 'in' -152,41-152,42: NUMBER '1' -152,43-152,46: NAME 'not' -152,47-152,49: NAME 'in' -152,50-152,51: NUMBER '1' -152,52-152,54: NAME 'is' -152,55-152,56: NUMBER '1' -152,57-152,59: NAME 'is' -152,60-152,63: NAME 'not' -152,64-152,65: NUMBER '1' -152,65-152,66: OP ':' -152,67-152,71: NAME 'pass' -152,71-152,72: NEWLINE '\n' -153,0-153,1: NL '\n' -154,0-154,9: COMMENT '# binary\n' -155,0-155,1: NAME 'x' -155,2-155,3: OP '=' -155,4-155,5: NUMBER '1' -155,6-155,7: OP '&' -155,8-155,9: NUMBER '1' -155,9-155,10: NEWLINE '\n' -156,0-156,1: NAME 'x' -156,2-156,3: OP '=' -156,4-156,5: NUMBER '1' -156,6-156,7: OP '^' -156,8-156,9: NUMBER '1' -156,9-156,10: NEWLINE '\n' -157,0-157,1: NAME 'x' -157,2-157,3: OP '=' -157,4-157,5: NUMBER '1' -157,6-157,7: OP '|' -157,8-157,9: NUMBER '1' -157,9-157,10: NEWLINE '\n' -158,0-158,1: NL '\n' -159,0-159,8: COMMENT '# shift\n' -160,0-160,1: NAME 'x' -160,2-160,3: OP '=' -160,4-160,5: NUMBER '1' -160,6-160,8: OP '<<' -160,9-160,10: NUMBER '1' -160,11-160,13: OP '>>' -160,14-160,15: NUMBER '1' -160,15-160,16: NEWLINE '\n' -161,0-161,1: NL '\n' -162,0-162,11: COMMENT '# additive\n' -163,0-163,1: NAME 'x' -163,2-163,3: OP '=' -163,4-163,5: NUMBER '1' -163,6-163,7: OP '-' -163,8-163,9: NUMBER '1' -163,10-163,11: OP '+' -163,12-163,13: NUMBER '1' -163,14-163,15: OP '-' -163,16-163,17: NUMBER '1' -163,18-163,19: OP '+' -163,20-163,21: NUMBER '1' -163,21-163,22: NEWLINE '\n' -164,0-164,1: NL '\n' -165,0-165,17: COMMENT '# multiplicative\n' -166,0-166,1: NAME 'x' -166,2-166,3: OP '=' -166,4-166,5: NUMBER '1' -166,6-166,7: OP '/' -166,8-166,9: NUMBER '1' -166,10-166,11: OP '*' -166,12-166,13: NUMBER '1' -166,14-166,15: OP '%' -166,16-166,17: NUMBER '1' -166,17-166,18: NEWLINE '\n' -167,0-167,1: NL '\n' -168,0-168,8: COMMENT '# unary\n' -169,0-169,1: NAME 'x' -169,2-169,3: OP '=' -169,4-169,5: OP '~' -169,5-169,6: NUMBER '1' -169,7-169,8: OP '^' -169,9-169,10: NUMBER '1' -169,11-169,12: OP '&' -169,13-169,14: NUMBER '1' -169,15-169,16: OP '|' -169,17-169,18: NUMBER '1' -169,19-169,20: OP '&' -169,21-169,22: NUMBER '1' -169,23-169,24: OP '^' -169,25-169,26: OP '-' -169,26-169,27: NUMBER '1' -169,27-169,28: NEWLINE '\n' -170,0-170,1: NAME 'x' -170,2-170,3: OP '=' -170,4-170,5: OP '-' -170,5-170,6: NUMBER '1' -170,6-170,7: OP '*' -170,7-170,8: NUMBER '1' -170,8-170,9: OP '/' -170,9-170,10: NUMBER '1' -170,11-170,12: OP '+' -170,13-170,14: NUMBER '1' -170,14-170,15: OP '*' -170,15-170,16: NUMBER '1' -170,17-170,18: OP '-' -170,19-170,20: OP '-' -170,20-170,21: OP '-' -170,21-170,22: OP '-' -170,22-170,23: NUMBER '1' -170,23-170,24: OP '*' -170,24-170,25: NUMBER '1' -170,25-170,26: NEWLINE '\n' -171,0-171,1: NL '\n' -172,0-172,11: COMMENT '# selector\n' -173,0-173,6: NAME 'import' -173,7-173,10: NAME 'sys' -173,10-173,11: OP ',' -173,12-173,16: NAME 'time' -173,16-173,17: NEWLINE '\n' -174,0-174,1: NAME 'x' -174,2-174,3: OP '=' -174,4-174,7: NAME 'sys' -174,7-174,8: OP '.' -174,8-174,15: NAME 'modules' -174,15-174,16: OP '[' -174,16-174,22: STRING "'time'" -174,22-174,23: OP ']' -174,23-174,24: OP '.' -174,24-174,28: NAME 'time' -174,28-174,29: OP '(' -174,29-174,30: OP ')' -174,30-174,31: NEWLINE '\n' -175,0-175,1: NL '\n' -176,0-176,1: OP '@' -176,1-176,13: NAME 'staticmethod' -176,13-176,14: NEWLINE '\n' -177,0-177,3: NAME 'def' -177,4-177,7: NAME 'foo' -177,7-177,8: OP '(' -177,8-177,9: OP ')' -177,9-177,10: OP ':' -177,11-177,15: NAME 'pass' -177,15-177,16: NEWLINE '\n' -178,0-178,1: NL '\n' -179,0-179,0: ENDMARKER '' +test_tokenize +1,0-1,35: COMMENT "# Tests for the 'tokenize' module.\n" +2,0-2,43: COMMENT '# Large bits stolen from test_grammar.py. \n' +3,0-3,1: NL '\n' +4,0-4,11: COMMENT '# Comments\n' +5,0-5,3: STRING '"#"' +5,3-5,4: NEWLINE '\n' +6,0-6,3: COMMENT "#'\n" +7,0-7,3: COMMENT '#"\n' +8,0-8,3: COMMENT '#\\\n' +9,7-9,9: COMMENT '#\n' +10,4-10,10: COMMENT '# abc\n' +11,0-12,4: STRING "'''#\n#'''" +12,4-12,5: NEWLINE '\n' +13,0-13,1: NL '\n' +14,0-14,1: NAME 'x' +14,2-14,3: OP '=' +14,4-14,5: NUMBER '1' +14,7-14,8: COMMENT '#' +14,8-14,9: NEWLINE '\n' +15,0-15,1: NL '\n' +16,0-16,25: COMMENT '# Balancing continuation\n' +17,0-17,1: NL '\n' +18,0-18,1: NAME 'a' +18,2-18,3: OP '=' +18,4-18,5: OP '(' +18,5-18,6: NUMBER '3' +18,6-18,7: OP ',' +18,8-18,9: NUMBER '4' +18,9-18,10: OP ',' +18,10-18,11: NL '\n' +19,2-19,3: NUMBER '5' +19,3-19,4: OP ',' +19,5-19,6: NUMBER '6' +19,6-19,7: OP ')' +19,7-19,8: NEWLINE '\n' +20,0-20,1: NAME 'y' +20,2-20,3: OP '=' +20,4-20,5: OP '[' +20,5-20,6: NUMBER '3' +20,6-20,7: OP ',' +20,8-20,9: NUMBER '4' +20,9-20,10: OP ',' +20,10-20,11: NL '\n' +21,2-21,3: NUMBER '5' +21,3-21,4: OP ']' +21,4-21,5: NEWLINE '\n' +22,0-22,1: NAME 'z' +22,2-22,3: OP '=' +22,4-22,5: OP '{' +22,5-22,8: STRING "'a'" +22,8-22,9: OP ':' +22,9-22,10: NUMBER '5' +22,10-22,11: OP ',' +22,11-22,12: NL '\n' +23,2-23,5: STRING "'b'" +23,5-23,6: OP ':' +23,6-23,7: NUMBER '6' +23,7-23,8: OP '}' +23,8-23,9: NEWLINE '\n' +24,0-24,1: NAME 'x' +24,2-24,3: OP '=' +24,4-24,5: OP '(' +24,5-24,8: NAME 'len' +24,8-24,9: OP '(' +24,9-24,10: OP '`' +24,10-24,11: NAME 'y' +24,11-24,12: OP '`' +24,12-24,13: OP ')' +24,14-24,15: OP '+' +24,16-24,17: NUMBER '5' +24,17-24,18: OP '*' +24,18-24,19: NAME 'x' +24,20-24,21: OP '-' +24,22-24,23: NAME 'a' +24,23-24,24: OP '[' +24,24-24,25: NL '\n' +25,3-25,4: NUMBER '3' +25,5-25,6: OP ']' +25,6-25,7: NL '\n' +26,3-26,4: OP '-' +26,5-26,6: NAME 'x' +26,7-26,8: OP '+' +26,9-26,12: NAME 'len' +26,12-26,13: OP '(' +26,13-26,14: OP '{' +26,14-26,15: NL '\n' +27,3-27,4: OP '}' +27,4-27,5: NL '\n' +28,4-28,5: OP ')' +28,5-28,6: NL '\n' +29,2-29,3: OP ')' +29,3-29,4: NEWLINE '\n' +30,0-30,1: NL '\n' +31,0-31,37: COMMENT '# Backslash means line continuation:\n' +32,0-32,1: NAME 'x' +32,2-32,3: OP '=' +32,4-32,5: NUMBER '1' +33,0-33,1: OP '+' +33,2-33,3: NUMBER '1' +33,3-33,4: NEWLINE '\n' +34,0-34,1: NL '\n' +35,0-35,55: COMMENT '# Backslash does not means continuation in comments :\\\n' +36,0-36,1: NAME 'x' +36,2-36,3: OP '=' +36,4-36,5: NUMBER '0' +36,5-36,6: NEWLINE '\n' +37,0-37,1: NL '\n' +38,0-38,20: COMMENT '# Ordinary integers\n' +39,0-39,4: NUMBER '0xff' +39,5-39,7: OP '<>' +39,8-39,11: NUMBER '255' +39,11-39,12: NEWLINE '\n' +40,0-40,4: NUMBER '0377' +40,5-40,7: OP '<>' +40,8-40,11: NUMBER '255' +40,11-40,12: NEWLINE '\n' +41,0-41,10: NUMBER '2147483647' +41,13-41,15: OP '!=' +41,16-41,28: NUMBER '017777777777' +41,28-41,29: NEWLINE '\n' +42,0-42,1: OP '-' +42,1-42,11: NUMBER '2147483647' +42,11-42,12: OP '-' +42,12-42,13: NUMBER '1' +42,14-42,16: OP '!=' +42,17-42,29: NUMBER '020000000000' +42,29-42,30: NEWLINE '\n' +43,0-43,12: NUMBER '037777777777' +43,13-43,15: OP '!=' +43,16-43,17: OP '-' +43,17-43,18: NUMBER '1' +43,18-43,19: NEWLINE '\n' +44,0-44,10: NUMBER '0xffffffff' +44,11-44,13: OP '!=' +44,14-44,15: OP '-' +44,15-44,16: NUMBER '1' +44,16-44,17: NEWLINE '\n' +45,0-45,1: NL '\n' +46,0-46,16: COMMENT '# Long integers\n' +47,0-47,1: NAME 'x' +47,2-47,3: OP '=' +47,4-47,6: NUMBER '0L' +47,6-47,7: NEWLINE '\n' +48,0-48,1: NAME 'x' +48,2-48,3: OP '=' +48,4-48,6: NUMBER '0l' +48,6-48,7: NEWLINE '\n' +49,0-49,1: NAME 'x' +49,2-49,3: OP '=' +49,4-49,23: NUMBER '0xffffffffffffffffL' +49,23-49,24: NEWLINE '\n' +50,0-50,1: NAME 'x' +50,2-50,3: OP '=' +50,4-50,23: NUMBER '0xffffffffffffffffl' +50,23-50,24: NEWLINE '\n' +51,0-51,1: NAME 'x' +51,2-51,3: OP '=' +51,4-51,23: NUMBER '077777777777777777L' +51,23-51,24: NEWLINE '\n' +52,0-52,1: NAME 'x' +52,2-52,3: OP '=' +52,4-52,23: NUMBER '077777777777777777l' +52,23-52,24: NEWLINE '\n' +53,0-53,1: NAME 'x' +53,2-53,3: OP '=' +53,4-53,35: NUMBER '123456789012345678901234567890L' +53,35-53,36: NEWLINE '\n' +54,0-54,1: NAME 'x' +54,2-54,3: OP '=' +54,4-54,35: NUMBER '123456789012345678901234567890l' +54,35-54,36: NEWLINE '\n' +55,0-55,1: NL '\n' +56,0-56,25: COMMENT '# Floating-point numbers\n' +57,0-57,1: NAME 'x' +57,2-57,3: OP '=' +57,4-57,8: NUMBER '3.14' +57,8-57,9: NEWLINE '\n' +58,0-58,1: NAME 'x' +58,2-58,3: OP '=' +58,4-58,8: NUMBER '314.' +58,8-58,9: NEWLINE '\n' +59,0-59,1: NAME 'x' +59,2-59,3: OP '=' +59,4-59,9: NUMBER '0.314' +59,9-59,10: NEWLINE '\n' +60,0-60,18: COMMENT '# XXX x = 000.314\n' +61,0-61,1: NAME 'x' +61,2-61,3: OP '=' +61,4-61,8: NUMBER '.314' +61,8-61,9: NEWLINE '\n' +62,0-62,1: NAME 'x' +62,2-62,3: OP '=' +62,4-62,8: NUMBER '3e14' +62,8-62,9: NEWLINE '\n' +63,0-63,1: NAME 'x' +63,2-63,3: OP '=' +63,4-63,8: NUMBER '3E14' +63,8-63,9: NEWLINE '\n' +64,0-64,1: NAME 'x' +64,2-64,3: OP '=' +64,4-64,9: NUMBER '3e-14' +64,9-64,10: NEWLINE '\n' +65,0-65,1: NAME 'x' +65,2-65,3: OP '=' +65,4-65,9: NUMBER '3e+14' +65,9-65,10: NEWLINE '\n' +66,0-66,1: NAME 'x' +66,2-66,3: OP '=' +66,4-66,9: NUMBER '3.e14' +66,9-66,10: NEWLINE '\n' +67,0-67,1: NAME 'x' +67,2-67,3: OP '=' +67,4-67,9: NUMBER '.3e14' +67,9-67,10: NEWLINE '\n' +68,0-68,1: NAME 'x' +68,2-68,3: OP '=' +68,4-68,9: NUMBER '3.1e4' +68,9-68,10: NEWLINE '\n' +69,0-69,1: NL '\n' +70,0-70,18: COMMENT '# String literals\n' +71,0-71,1: NAME 'x' +71,2-71,3: OP '=' +71,4-71,6: STRING "''" +71,6-71,7: OP ';' +71,8-71,9: NAME 'y' +71,10-71,11: OP '=' +71,12-71,14: STRING '""' +71,14-71,15: OP ';' +71,15-71,16: NEWLINE '\n' +72,0-72,1: NAME 'x' +72,2-72,3: OP '=' +72,4-72,8: STRING "'\\''" +72,8-72,9: OP ';' +72,10-72,11: NAME 'y' +72,12-72,13: OP '=' +72,14-72,17: STRING '"\'"' +72,17-72,18: OP ';' +72,18-72,19: NEWLINE '\n' +73,0-73,1: NAME 'x' +73,2-73,3: OP '=' +73,4-73,7: STRING '\'"\'' +73,7-73,8: OP ';' +73,9-73,10: NAME 'y' +73,11-73,12: OP '=' +73,13-73,17: STRING '"\\""' +73,17-73,18: OP ';' +73,18-73,19: NEWLINE '\n' +74,0-74,1: NAME 'x' +74,2-74,3: OP '=' +74,4-74,32: STRING '"doesn\'t \\"shrink\\" does it"' +74,32-74,33: NEWLINE '\n' +75,0-75,1: NAME 'y' +75,2-75,3: OP '=' +75,4-75,31: STRING '\'doesn\\\'t "shrink" does it\'' +75,31-75,32: NEWLINE '\n' +76,0-76,1: NAME 'x' +76,2-76,3: OP '=' +76,4-76,32: STRING '"does \\"shrink\\" doesn\'t it"' +76,32-76,33: NEWLINE '\n' +77,0-77,1: NAME 'y' +77,2-77,3: OP '=' +77,4-77,31: STRING '\'does "shrink" doesn\\\'t it\'' +77,31-77,32: NEWLINE '\n' +78,0-78,1: NAME 'x' +78,2-78,3: OP '=' +78,4-83,3: STRING '"""\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n"""' +83,3-83,4: NEWLINE '\n' +84,0-84,1: NAME 'y' +84,2-84,3: OP '=' +84,4-84,63: STRING '\'\\nThe "quick"\\nbrown fox\\njumps over\\nthe \\\'lazy\\\' dog.\\n\'' +84,63-84,64: NEWLINE '\n' +85,0-85,1: NAME 'y' +85,2-85,3: OP '=' +85,4-90,3: STRING '\'\'\'\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n\'\'\'' +90,3-90,4: OP ';' +90,4-90,5: NEWLINE '\n' +91,0-91,1: NAME 'y' +91,2-91,3: OP '=' +91,4-96,1: STRING '"\\n\\\nThe \\"quick\\"\\n\\\nbrown fox\\n\\\njumps over\\n\\\nthe \'lazy\' dog.\\n\\\n"' +96,1-96,2: OP ';' +96,2-96,3: NEWLINE '\n' +97,0-97,1: NAME 'y' +97,2-97,3: OP '=' +97,4-102,1: STRING '\'\\n\\\nThe \\"quick\\"\\n\\\nbrown fox\\n\\\njumps over\\n\\\nthe \\\'lazy\\\' dog.\\n\\\n\'' +102,1-102,2: OP ';' +102,2-102,3: NEWLINE '\n' +103,0-103,1: NAME 'x' +103,2-103,3: OP '=' +103,4-103,9: STRING "r'\\\\'" +103,10-103,11: OP '+' +103,12-103,17: STRING "R'\\\\'" +103,17-103,18: NEWLINE '\n' +104,0-104,1: NAME 'x' +104,2-104,3: OP '=' +104,4-104,9: STRING "r'\\''" +104,10-104,11: OP '+' +104,12-104,14: STRING "''" +104,14-104,15: NEWLINE '\n' +105,0-105,1: NAME 'y' +105,2-105,3: OP '=' +105,4-107,6: STRING "r'''\nfoo bar \\\\\nbaz'''" +107,7-107,8: OP '+' +107,9-108,6: STRING "R'''\nfoo'''" +108,6-108,7: NEWLINE '\n' +109,0-109,1: NAME 'y' +109,2-109,3: OP '=' +109,4-111,3: STRING 'r"""foo\nbar \\\\ baz\n"""' +111,4-111,5: OP '+' +111,6-112,3: STRING "R'''spam\n'''" +112,3-112,4: NEWLINE '\n' +113,0-113,1: NAME 'x' +113,2-113,3: OP '=' +113,4-113,10: STRING "u'abc'" +113,11-113,12: OP '+' +113,13-113,19: STRING "U'ABC'" +113,19-113,20: NEWLINE '\n' +114,0-114,1: NAME 'y' +114,2-114,3: OP '=' +114,4-114,10: STRING 'u"abc"' +114,11-114,12: OP '+' +114,13-114,19: STRING 'U"ABC"' +114,19-114,20: NEWLINE '\n' +115,0-115,1: NAME 'x' +115,2-115,3: OP '=' +115,4-115,11: STRING "ur'abc'" +115,12-115,13: OP '+' +115,14-115,21: STRING "Ur'ABC'" +115,22-115,23: OP '+' +115,24-115,31: STRING "uR'ABC'" +115,32-115,33: OP '+' +115,34-115,41: STRING "UR'ABC'" +115,41-115,42: NEWLINE '\n' +116,0-116,1: NAME 'y' +116,2-116,3: OP '=' +116,4-116,11: STRING 'ur"abc"' +116,12-116,13: OP '+' +116,14-116,21: STRING 'Ur"ABC"' +116,22-116,23: OP '+' +116,24-116,31: STRING 'uR"ABC"' +116,32-116,33: OP '+' +116,34-116,41: STRING 'UR"ABC"' +116,41-116,42: NEWLINE '\n' +117,0-117,1: NAME 'x' +117,2-117,3: OP '=' +117,4-117,10: STRING "ur'\\\\'" +117,11-117,12: OP '+' +117,13-117,19: STRING "UR'\\\\'" +117,19-117,20: NEWLINE '\n' +118,0-118,1: NAME 'x' +118,2-118,3: OP '=' +118,4-118,10: STRING "ur'\\''" +118,11-118,12: OP '+' +118,13-118,15: STRING "''" +118,15-118,16: NEWLINE '\n' +119,0-119,1: NAME 'y' +119,2-119,3: OP '=' +119,4-121,6: STRING "ur'''\nfoo bar \\\\\nbaz'''" +121,7-121,8: OP '+' +121,9-122,6: STRING "UR'''\nfoo'''" +122,6-122,7: NEWLINE '\n' +123,0-123,1: NAME 'y' +123,2-123,3: OP '=' +123,4-125,3: STRING 'Ur"""foo\nbar \\\\ baz\n"""' +125,4-125,5: OP '+' +125,6-126,3: STRING "uR'''spam\n'''" +126,3-126,4: NEWLINE '\n' +127,0-127,1: NL '\n' +128,0-128,14: COMMENT '# Indentation\n' +129,0-129,2: NAME 'if' +129,3-129,4: NUMBER '1' +129,4-129,5: OP ':' +129,5-129,6: NEWLINE '\n' +130,0-130,4: INDENT ' ' +130,4-130,5: NAME 'x' +130,6-130,7: OP '=' +130,8-130,9: NUMBER '2' +130,9-130,10: NEWLINE '\n' +131,0-131,0: DEDENT '' +131,0-131,2: NAME 'if' +131,3-131,4: NUMBER '1' +131,4-131,5: OP ':' +131,5-131,6: NEWLINE '\n' +132,0-132,8: INDENT ' ' +132,8-132,9: NAME 'x' +132,10-132,11: OP '=' +132,12-132,13: NUMBER '2' +132,13-132,14: NEWLINE '\n' +133,0-133,0: DEDENT '' +133,0-133,2: NAME 'if' +133,3-133,4: NUMBER '1' +133,4-133,5: OP ':' +133,5-133,6: NEWLINE '\n' +134,0-134,4: INDENT ' ' +134,4-134,9: NAME 'while' +134,10-134,11: NUMBER '0' +134,11-134,12: OP ':' +134,12-134,13: NEWLINE '\n' +135,0-135,5: INDENT ' ' +135,5-135,7: NAME 'if' +135,8-135,9: NUMBER '0' +135,9-135,10: OP ':' +135,10-135,11: NEWLINE '\n' +136,0-136,11: INDENT ' ' +136,11-136,12: NAME 'x' +136,13-136,14: OP '=' +136,15-136,16: NUMBER '2' +136,16-136,17: NEWLINE '\n' +137,5-137,5: DEDENT '' +137,5-137,6: NAME 'x' +137,7-137,8: OP '=' +137,9-137,10: NUMBER '2' +137,10-137,11: NEWLINE '\n' +138,0-138,0: DEDENT '' +138,0-138,0: DEDENT '' +138,0-138,2: NAME 'if' +138,3-138,4: NUMBER '0' +138,4-138,5: OP ':' +138,5-138,6: NEWLINE '\n' +139,0-139,2: INDENT ' ' +139,2-139,4: NAME 'if' +139,5-139,6: NUMBER '2' +139,6-139,7: OP ':' +139,7-139,8: NEWLINE '\n' +140,0-140,3: INDENT ' ' +140,3-140,8: NAME 'while' +140,9-140,10: NUMBER '0' +140,10-140,11: OP ':' +140,11-140,12: NEWLINE '\n' +141,0-141,8: INDENT ' ' +141,8-141,10: NAME 'if' +141,11-141,12: NUMBER '1' +141,12-141,13: OP ':' +141,13-141,14: NEWLINE '\n' +142,0-142,10: INDENT ' ' +142,10-142,11: NAME 'x' +142,12-142,13: OP '=' +142,14-142,15: NUMBER '2' +142,15-142,16: NEWLINE '\n' +143,0-143,1: NL '\n' +144,0-144,12: COMMENT '# Operators\n' +145,0-145,1: NL '\n' +146,0-146,0: DEDENT '' +146,0-146,0: DEDENT '' +146,0-146,0: DEDENT '' +146,0-146,0: DEDENT '' +146,0-146,3: NAME 'def' +146,4-146,7: NAME 'd22' +146,7-146,8: OP '(' +146,8-146,9: NAME 'a' +146,9-146,10: OP ',' +146,11-146,12: NAME 'b' +146,12-146,13: OP ',' +146,14-146,15: NAME 'c' +146,15-146,16: OP '=' +146,16-146,17: NUMBER '1' +146,17-146,18: OP ',' +146,19-146,20: NAME 'd' +146,20-146,21: OP '=' +146,21-146,22: NUMBER '2' +146,22-146,23: OP ')' +146,23-146,24: OP ':' +146,25-146,29: NAME 'pass' +146,29-146,30: NEWLINE '\n' +147,0-147,3: NAME 'def' +147,4-147,8: NAME 'd01v' +147,8-147,9: OP '(' +147,9-147,10: NAME 'a' +147,10-147,11: OP '=' +147,11-147,12: NUMBER '1' +147,12-147,13: OP ',' +147,14-147,15: OP '*' +147,15-147,20: NAME 'restt' +147,20-147,21: OP ',' +147,22-147,24: OP '**' +147,24-147,29: NAME 'restd' +147,29-147,30: OP ')' +147,30-147,31: OP ':' +147,32-147,36: NAME 'pass' +147,36-147,37: NEWLINE '\n' +148,0-148,1: NL '\n' +149,0-149,1: OP '(' +149,1-149,2: NAME 'x' +149,2-149,3: OP ',' +149,4-149,5: NAME 'y' +149,5-149,6: OP ')' +149,7-149,9: OP '<>' +149,10-149,11: OP '(' +149,11-149,12: OP '{' +149,12-149,15: STRING "'a'" +149,15-149,16: OP ':' +149,16-149,17: NUMBER '1' +149,17-149,18: OP '}' +149,18-149,19: OP ',' +149,20-149,21: OP '{' +149,21-149,24: STRING "'b'" +149,24-149,25: OP ':' +149,25-149,26: NUMBER '2' +149,26-149,27: OP '}' +149,27-149,28: OP ')' +149,28-149,29: NEWLINE '\n' +150,0-150,1: NL '\n' +151,0-151,13: COMMENT '# comparison\n' +152,0-152,2: NAME 'if' +152,3-152,4: NUMBER '1' +152,5-152,6: OP '<' +152,7-152,8: NUMBER '1' +152,9-152,10: OP '>' +152,11-152,12: NUMBER '1' +152,13-152,15: OP '==' +152,16-152,17: NUMBER '1' +152,18-152,20: OP '>=' +152,21-152,22: NUMBER '1' +152,23-152,25: OP '<=' +152,26-152,27: NUMBER '1' +152,28-152,30: OP '<>' +152,31-152,32: NUMBER '1' +152,33-152,35: OP '!=' +152,36-152,37: NUMBER '1' +152,38-152,40: NAME 'in' +152,41-152,42: NUMBER '1' +152,43-152,46: NAME 'not' +152,47-152,49: NAME 'in' +152,50-152,51: NUMBER '1' +152,52-152,54: NAME 'is' +152,55-152,56: NUMBER '1' +152,57-152,59: NAME 'is' +152,60-152,63: NAME 'not' +152,64-152,65: NUMBER '1' +152,65-152,66: OP ':' +152,67-152,71: NAME 'pass' +152,71-152,72: NEWLINE '\n' +153,0-153,1: NL '\n' +154,0-154,9: COMMENT '# binary\n' +155,0-155,1: NAME 'x' +155,2-155,3: OP '=' +155,4-155,5: NUMBER '1' +155,6-155,7: OP '&' +155,8-155,9: NUMBER '1' +155,9-155,10: NEWLINE '\n' +156,0-156,1: NAME 'x' +156,2-156,3: OP '=' +156,4-156,5: NUMBER '1' +156,6-156,7: OP '^' +156,8-156,9: NUMBER '1' +156,9-156,10: NEWLINE '\n' +157,0-157,1: NAME 'x' +157,2-157,3: OP '=' +157,4-157,5: NUMBER '1' +157,6-157,7: OP '|' +157,8-157,9: NUMBER '1' +157,9-157,10: NEWLINE '\n' +158,0-158,1: NL '\n' +159,0-159,8: COMMENT '# shift\n' +160,0-160,1: NAME 'x' +160,2-160,3: OP '=' +160,4-160,5: NUMBER '1' +160,6-160,8: OP '<<' +160,9-160,10: NUMBER '1' +160,11-160,13: OP '>>' +160,14-160,15: NUMBER '1' +160,15-160,16: NEWLINE '\n' +161,0-161,1: NL '\n' +162,0-162,11: COMMENT '# additive\n' +163,0-163,1: NAME 'x' +163,2-163,3: OP '=' +163,4-163,5: NUMBER '1' +163,6-163,7: OP '-' +163,8-163,9: NUMBER '1' +163,10-163,11: OP '+' +163,12-163,13: NUMBER '1' +163,14-163,15: OP '-' +163,16-163,17: NUMBER '1' +163,18-163,19: OP '+' +163,20-163,21: NUMBER '1' +163,21-163,22: NEWLINE '\n' +164,0-164,1: NL '\n' +165,0-165,17: COMMENT '# multiplicative\n' +166,0-166,1: NAME 'x' +166,2-166,3: OP '=' +166,4-166,5: NUMBER '1' +166,6-166,7: OP '/' +166,8-166,9: NUMBER '1' +166,10-166,11: OP '*' +166,12-166,13: NUMBER '1' +166,14-166,15: OP '%' +166,16-166,17: NUMBER '1' +166,17-166,18: NEWLINE '\n' +167,0-167,1: NL '\n' +168,0-168,8: COMMENT '# unary\n' +169,0-169,1: NAME 'x' +169,2-169,3: OP '=' +169,4-169,5: OP '~' +169,5-169,6: NUMBER '1' +169,7-169,8: OP '^' +169,9-169,10: NUMBER '1' +169,11-169,12: OP '&' +169,13-169,14: NUMBER '1' +169,15-169,16: OP '|' +169,17-169,18: NUMBER '1' +169,19-169,20: OP '&' +169,21-169,22: NUMBER '1' +169,23-169,24: OP '^' +169,25-169,26: OP '-' +169,26-169,27: NUMBER '1' +169,27-169,28: NEWLINE '\n' +170,0-170,1: NAME 'x' +170,2-170,3: OP '=' +170,4-170,5: OP '-' +170,5-170,6: NUMBER '1' +170,6-170,7: OP '*' +170,7-170,8: NUMBER '1' +170,8-170,9: OP '/' +170,9-170,10: NUMBER '1' +170,11-170,12: OP '+' +170,13-170,14: NUMBER '1' +170,14-170,15: OP '*' +170,15-170,16: NUMBER '1' +170,17-170,18: OP '-' +170,19-170,20: OP '-' +170,20-170,21: OP '-' +170,21-170,22: OP '-' +170,22-170,23: NUMBER '1' +170,23-170,24: OP '*' +170,24-170,25: NUMBER '1' +170,25-170,26: NEWLINE '\n' +171,0-171,1: NL '\n' +172,0-172,11: COMMENT '# selector\n' +173,0-173,6: NAME 'import' +173,7-173,10: NAME 'sys' +173,10-173,11: OP ',' +173,12-173,16: NAME 'time' +173,16-173,17: NEWLINE '\n' +174,0-174,1: NAME 'x' +174,2-174,3: OP '=' +174,4-174,7: NAME 'sys' +174,7-174,8: OP '.' +174,8-174,15: NAME 'modules' +174,15-174,16: OP '[' +174,16-174,22: STRING "'time'" +174,22-174,23: OP ']' +174,23-174,24: OP '.' +174,24-174,28: NAME 'time' +174,28-174,29: OP '(' +174,29-174,30: OP ')' +174,30-174,31: NEWLINE '\n' +175,0-175,1: NL '\n' +176,0-176,1: OP '@' +176,1-176,13: NAME 'staticmethod' +176,13-176,14: NEWLINE '\n' +177,0-177,3: NAME 'def' +177,4-177,7: NAME 'foo' +177,7-177,8: OP '(' +177,8-177,9: OP ')' +177,9-177,10: OP ':' +177,11-177,15: NAME 'pass' +177,15-177,16: NEWLINE '\n' +178,0-178,1: NL '\n' +179,0-179,0: ENDMARKER '' Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_types ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_types (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_types Fri May 5 21:25:58 2006 @@ -1,15 +1,15 @@ -test_types -6. Built-in types -6.1 Truth value testing -6.2 Boolean operations -6.3 Comparisons -6.4 Numeric types (mostly conversions) -6.4.1 32-bit integers -6.4.2 Long integers -6.4.3 Floating point numbers -6.5 Sequence types -6.5.1 Strings -6.5.2 Tuples [see test_tuple.py] -6.5.3 Lists [see test_list.py] -6.6 Mappings == Dictionaries [see test_dict.py] -Buffers +test_types +6. Built-in types +6.1 Truth value testing +6.2 Boolean operations +6.3 Comparisons +6.4 Numeric types (mostly conversions) +6.4.1 32-bit integers +6.4.2 Long integers +6.4.3 Floating point numbers +6.5 Sequence types +6.5.1 Strings +6.5.2 Tuples [see test_tuple.py] +6.5.3 Lists [see test_list.py] +6.6 Mappings == Dictionaries [see test_dict.py] +Buffers Modified: stackless/Python-2.4.3/dev/Lib/test/output/test_winreg ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/test_winreg (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/test_winreg Fri May 5 21:25:58 2006 @@ -1,3 +1,3 @@ -test_winreg -Local registry tests worked -Remote registry calls can be tested using 'test_winreg.py --remote \\machine_name' +test_winreg +Local registry tests worked +Remote registry calls can be tested using 'test_winreg.py --remote \\machine_name' Modified: stackless/Python-2.4.3/dev/Lib/test/output/xmltests ============================================================================== --- stackless/Python-2.4.3/dev/Lib/test/output/xmltests (original) +++ stackless/Python-2.4.3/dev/Lib/test/output/xmltests Fri May 5 21:25:58 2006 @@ -1,364 +1,364 @@ -xmltests -Passed testAAA -Passed setAttribute() sets ownerDocument -Passed setAttribute() sets ownerElement -Test Succeeded testAAA -Passed assertion: len(Node.allnodes) == 0 -Passed testAAB -Test Succeeded testAAB -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Passed Test -Passed Test -Passed Test -Passed Test -Passed Test -Passed Test -Test Succeeded testAddAttr -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testAppendChild -Passed assertion: len(Node.allnodes) == 0 -Passed appendChild() -Test Succeeded testAppendChildFragment -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListItem -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListItemNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListItems -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListKeys -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListKeysNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListLength -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrListValues -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrList__getitem__ -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testAttrList__setitem__ -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testAttributeRepr -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Passed Test -Passed Test -Passed Test -Test Succeeded testChangeAttr -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testChildNodes -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCloneAttributeDeep -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCloneAttributeShallow -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCloneDocumentDeep -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCloneDocumentShallow -Passed assertion: len(Node.allnodes) == 0 -Passed clone of element has same attribute keys -Passed clone of attribute node has proper attribute values -Passed clone of attribute node correctly owned -Passed testCloneElementDeep -Test Succeeded testCloneElementDeep -Passed assertion: len(Node.allnodes) == 0 -Passed clone of element has same attribute keys -Passed clone of attribute node has proper attribute values -Passed clone of attribute node correctly owned -Passed testCloneElementShallow -Test Succeeded testCloneElementShallow -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testClonePIDeep -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testClonePIShallow -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testComment -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCreateAttributeNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testCreateElementNS -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Passed Test -Test Succeeded testDeleteAttr -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testDocumentElement -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Test Succeeded testElement -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Test Succeeded testElementReprAndStr -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testFirstChild -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttrLength -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttrList -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttrValues -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttribute -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttributeNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetAttributeNode -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Test Succeeded testGetElementsByTagName -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Test Succeeded testGetElementsByTagNameNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testGetEmptyNodeListFromElementsByTagNameNS -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testHasChildNodes -Passed assertion: len(Node.allnodes) == 0 -Passed testInsertBefore -- node properly placed in tree -Passed testInsertBefore -- node properly placed in tree -Passed testInsertBefore -- node properly placed in tree -Test Succeeded testInsertBefore -Passed assertion: len(Node.allnodes) == 0 -Passed insertBefore(, None) -Passed insertBefore(, orig) -Test Succeeded testInsertBeforeFragment -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testLegalChildren -Passed assertion: len(Node.allnodes) == 0 -Passed NamedNodeMap.__setitem__() sets ownerDocument -Passed NamedNodeMap.__setitem__() sets ownerElement -Passed NamedNodeMap.__setitem__() sets value -Passed NamedNodeMap.__setitem__() sets nodeValue -Test Succeeded testNamedNodeMapSetItem -Passed assertion: len(Node.allnodes) == 0 -Passed test NodeList.item() -Test Succeeded testNodeListItem -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testNonZero -Passed assertion: len(Node.allnodes) == 0 -Passed testNormalize -- preparation -Passed testNormalize -- result -Passed testNormalize -- single empty node removed -Test Succeeded testNormalize -Passed assertion: len(Node.allnodes) == 0 -Passed testParents -Test Succeeded testParents -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParse -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseAttributeNamespaces -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseAttributes -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseElement -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseElementNamespaces -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Test Succeeded testParseFromFile -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseProcessingInstructions -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testParseString -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testProcessingInstruction -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testProcessingInstructionRepr -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testRemoveAttr -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testRemoveAttrNS -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testRemoveAttributeNode -Passed assertion: len(Node.allnodes) == 0 -Passed replaceChild() -Test Succeeded testReplaceChildFragment -Passed assertion: len(Node.allnodes) == 0 -Passed testSAX2DOM - siblings -Passed testSAX2DOM - parents -Test Succeeded testSAX2DOM -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testSetAttrValueandNodeValue -Passed assertion: len(Node.allnodes) == 0 -Passed testSiblings -Test Succeeded testSiblings -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testTextNodeRepr -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testTextRepr -Passed assertion: len(Node.allnodes) == 0 -Caught expected exception when adding extra document element. -Test Succeeded testTooManyDocumentElements -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testUnlink -Passed assertion: len(Node.allnodes) == 0 -Test Succeeded testWriteText -Passed assertion: len(Node.allnodes) == 0 -Passed Test -Passed Test -Test Succeeded testWriteXML -Passed assertion: len(Node.allnodes) == 0 -All tests succeeded -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -OK. -PI: - 'xml-stylesheet' 'href="stylesheet.css"' -Comment: - ' comment data ' -Notation declared: ('notation', None, 'notation.jpeg', None) -Unparsed entity decl: - ('unparsed_entity', None, 'entity.file', None, 'notation') -Start element: - 'root' {'attr1': 'value1', 'attr2': 'value2\xe1\xbd\x80'} -NS decl: - 'myns' 'http://www.python.org/namespace' -Start element: - 'http://www.python.org/namespace!subelement' {} -Character data: - 'Contents of subelements' -End element: - 'http://www.python.org/namespace!subelement' -End of NS decl: - 'myns' -Start element: - 'sub2' {} -Start of CDATA section -Character data: - 'contents of CDATA section' -End of CDATA section -End element: - 'sub2' -External entity ref: (None, 'entity.file', None) -End element: - 'root' -PI: - u'xml-stylesheet' u'href="stylesheet.css"' -Comment: - u' comment data ' -Notation declared: (u'notation', None, u'notation.jpeg', None) -Unparsed entity decl: - (u'unparsed_entity', None, u'entity.file', None, u'notation') -Start element: - u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} -NS decl: - u'myns' u'http://www.python.org/namespace' -Start element: - u'http://www.python.org/namespace!subelement' {} -Character data: - u'Contents of subelements' -End element: - u'http://www.python.org/namespace!subelement' -End of NS decl: - u'myns' -Start element: - u'sub2' {} -Start of CDATA section -Character data: - u'contents of CDATA section' -End of CDATA section -End element: - u'sub2' -External entity ref: (None, u'entity.file', None) -End element: - u'root' -PI: - u'xml-stylesheet' u'href="stylesheet.css"' -Comment: - u' comment data ' -Notation declared: (u'notation', None, u'notation.jpeg', None) -Unparsed entity decl: - (u'unparsed_entity', None, u'entity.file', None, u'notation') -Start element: - u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} -NS decl: - u'myns' u'http://www.python.org/namespace' -Start element: - u'http://www.python.org/namespace!subelement' {} -Character data: - u'Contents of subelements' -End element: - u'http://www.python.org/namespace!subelement' -End of NS decl: - u'myns' -Start element: - u'sub2' {} -Start of CDATA section -Character data: - u'contents of CDATA section' -End of CDATA section -End element: - u'sub2' -External entity ref: (None, u'entity.file', None) -End element: - u'root' - -Testing constructor for proper handling of namespace_separator values: -Legal values tested o.k. -Caught expected TypeError: -ParserCreate() argument 2 must be string or None, not int -Caught expected ValueError: -namespace_separator must be at most one character, omitted, or None -Passed test_attrs_empty -Passed test_attrs_wattr -Passed test_double_quoteattr -Passed test_escape_all -Passed test_escape_basic -Passed test_escape_extra -Passed test_expat_attrs_empty -Passed test_expat_attrs_wattr -Passed test_expat_dtdhandler -Passed test_expat_entityresolver -Passed test_expat_file -Passed test_expat_incomplete -Passed test_expat_incremental -Passed test_expat_incremental_reset -Passed test_expat_inpsource_filename -Passed test_expat_inpsource_location -Passed test_expat_inpsource_stream -Passed test_expat_inpsource_sysid -Passed test_expat_locator_noinfo -Passed test_expat_locator_withinfo -Passed test_expat_nsattrs_empty -Passed test_expat_nsattrs_wattr -Passed test_filter_basic -Passed test_make_parser -Passed test_make_parser2 -Passed test_nsattrs_empty -Passed test_nsattrs_wattr -Passed test_quoteattr_basic -Passed test_single_double_quoteattr -Passed test_single_quoteattr -Passed test_xmlgen_attr_escape -Passed test_xmlgen_basic -Passed test_xmlgen_content -Passed test_xmlgen_content_escape -Passed test_xmlgen_ignorable -Passed test_xmlgen_ns -Passed test_xmlgen_pi -37 tests, 0 failures +xmltests +Passed testAAA +Passed setAttribute() sets ownerDocument +Passed setAttribute() sets ownerElement +Test Succeeded testAAA +Passed assertion: len(Node.allnodes) == 0 +Passed testAAB +Test Succeeded testAAB +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Passed Test +Passed Test +Passed Test +Passed Test +Passed Test +Passed Test +Test Succeeded testAddAttr +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testAppendChild +Passed assertion: len(Node.allnodes) == 0 +Passed appendChild() +Test Succeeded testAppendChildFragment +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListItem +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListItemNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListItems +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListKeys +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListKeysNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListLength +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrListValues +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrList__getitem__ +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testAttrList__setitem__ +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testAttributeRepr +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Passed Test +Passed Test +Passed Test +Test Succeeded testChangeAttr +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testChildNodes +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCloneAttributeDeep +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCloneAttributeShallow +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCloneDocumentDeep +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCloneDocumentShallow +Passed assertion: len(Node.allnodes) == 0 +Passed clone of element has same attribute keys +Passed clone of attribute node has proper attribute values +Passed clone of attribute node correctly owned +Passed testCloneElementDeep +Test Succeeded testCloneElementDeep +Passed assertion: len(Node.allnodes) == 0 +Passed clone of element has same attribute keys +Passed clone of attribute node has proper attribute values +Passed clone of attribute node correctly owned +Passed testCloneElementShallow +Test Succeeded testCloneElementShallow +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testClonePIDeep +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testClonePIShallow +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testComment +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCreateAttributeNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testCreateElementNS +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Passed Test +Test Succeeded testDeleteAttr +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testDocumentElement +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Test Succeeded testElement +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Test Succeeded testElementReprAndStr +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testFirstChild +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttrLength +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttrList +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttrValues +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttribute +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttributeNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetAttributeNode +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Test Succeeded testGetElementsByTagName +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Test Succeeded testGetElementsByTagNameNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testGetEmptyNodeListFromElementsByTagNameNS +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testHasChildNodes +Passed assertion: len(Node.allnodes) == 0 +Passed testInsertBefore -- node properly placed in tree +Passed testInsertBefore -- node properly placed in tree +Passed testInsertBefore -- node properly placed in tree +Test Succeeded testInsertBefore +Passed assertion: len(Node.allnodes) == 0 +Passed insertBefore(, None) +Passed insertBefore(, orig) +Test Succeeded testInsertBeforeFragment +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testLegalChildren +Passed assertion: len(Node.allnodes) == 0 +Passed NamedNodeMap.__setitem__() sets ownerDocument +Passed NamedNodeMap.__setitem__() sets ownerElement +Passed NamedNodeMap.__setitem__() sets value +Passed NamedNodeMap.__setitem__() sets nodeValue +Test Succeeded testNamedNodeMapSetItem +Passed assertion: len(Node.allnodes) == 0 +Passed test NodeList.item() +Test Succeeded testNodeListItem +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testNonZero +Passed assertion: len(Node.allnodes) == 0 +Passed testNormalize -- preparation +Passed testNormalize -- result +Passed testNormalize -- single empty node removed +Test Succeeded testNormalize +Passed assertion: len(Node.allnodes) == 0 +Passed testParents +Test Succeeded testParents +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParse +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseAttributeNamespaces +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseAttributes +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseElement +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseElementNamespaces +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Test Succeeded testParseFromFile +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseProcessingInstructions +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testParseString +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testProcessingInstruction +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testProcessingInstructionRepr +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testRemoveAttr +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testRemoveAttrNS +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testRemoveAttributeNode +Passed assertion: len(Node.allnodes) == 0 +Passed replaceChild() +Test Succeeded testReplaceChildFragment +Passed assertion: len(Node.allnodes) == 0 +Passed testSAX2DOM - siblings +Passed testSAX2DOM - parents +Test Succeeded testSAX2DOM +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testSetAttrValueandNodeValue +Passed assertion: len(Node.allnodes) == 0 +Passed testSiblings +Test Succeeded testSiblings +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testTextNodeRepr +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testTextRepr +Passed assertion: len(Node.allnodes) == 0 +Caught expected exception when adding extra document element. +Test Succeeded testTooManyDocumentElements +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testUnlink +Passed assertion: len(Node.allnodes) == 0 +Test Succeeded testWriteText +Passed assertion: len(Node.allnodes) == 0 +Passed Test +Passed Test +Test Succeeded testWriteXML +Passed assertion: len(Node.allnodes) == 0 +All tests succeeded +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +OK. +PI: + 'xml-stylesheet' 'href="stylesheet.css"' +Comment: + ' comment data ' +Notation declared: ('notation', None, 'notation.jpeg', None) +Unparsed entity decl: + ('unparsed_entity', None, 'entity.file', None, 'notation') +Start element: + 'root' {'attr1': 'value1', 'attr2': 'value2\xe1\xbd\x80'} +NS decl: + 'myns' 'http://www.python.org/namespace' +Start element: + 'http://www.python.org/namespace!subelement' {} +Character data: + 'Contents of subelements' +End element: + 'http://www.python.org/namespace!subelement' +End of NS decl: + 'myns' +Start element: + 'sub2' {} +Start of CDATA section +Character data: + 'contents of CDATA section' +End of CDATA section +End element: + 'sub2' +External entity ref: (None, 'entity.file', None) +End element: + 'root' +PI: + u'xml-stylesheet' u'href="stylesheet.css"' +Comment: + u' comment data ' +Notation declared: (u'notation', None, u'notation.jpeg', None) +Unparsed entity decl: + (u'unparsed_entity', None, u'entity.file', None, u'notation') +Start element: + u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} +NS decl: + u'myns' u'http://www.python.org/namespace' +Start element: + u'http://www.python.org/namespace!subelement' {} +Character data: + u'Contents of subelements' +End element: + u'http://www.python.org/namespace!subelement' +End of NS decl: + u'myns' +Start element: + u'sub2' {} +Start of CDATA section +Character data: + u'contents of CDATA section' +End of CDATA section +End element: + u'sub2' +External entity ref: (None, u'entity.file', None) +End element: + u'root' +PI: + u'xml-stylesheet' u'href="stylesheet.css"' +Comment: + u' comment data ' +Notation declared: (u'notation', None, u'notation.jpeg', None) +Unparsed entity decl: + (u'unparsed_entity', None, u'entity.file', None, u'notation') +Start element: + u'root' {u'attr1': u'value1', u'attr2': u'value2\u1f40'} +NS decl: + u'myns' u'http://www.python.org/namespace' +Start element: + u'http://www.python.org/namespace!subelement' {} +Character data: + u'Contents of subelements' +End element: + u'http://www.python.org/namespace!subelement' +End of NS decl: + u'myns' +Start element: + u'sub2' {} +Start of CDATA section +Character data: + u'contents of CDATA section' +End of CDATA section +End element: + u'sub2' +External entity ref: (None, u'entity.file', None) +End element: + u'root' + +Testing constructor for proper handling of namespace_separator values: +Legal values tested o.k. +Caught expected TypeError: +ParserCreate() argument 2 must be string or None, not int +Caught expected ValueError: +namespace_separator must be at most one character, omitted, or None +Passed test_attrs_empty +Passed test_attrs_wattr +Passed test_double_quoteattr +Passed test_escape_all +Passed test_escape_basic +Passed test_escape_extra +Passed test_expat_attrs_empty +Passed test_expat_attrs_wattr +Passed test_expat_dtdhandler +Passed test_expat_entityresolver +Passed test_expat_file +Passed test_expat_incomplete +Passed test_expat_incremental +Passed test_expat_incremental_reset +Passed test_expat_inpsource_filename +Passed test_expat_inpsource_location +Passed test_expat_inpsource_stream +Passed test_expat_inpsource_sysid +Passed test_expat_locator_noinfo +Passed test_expat_locator_withinfo +Passed test_expat_nsattrs_empty +Passed test_expat_nsattrs_wattr +Passed test_filter_basic +Passed test_make_parser +Passed test_make_parser2 +Passed test_nsattrs_empty +Passed test_nsattrs_wattr +Passed test_quoteattr_basic +Passed test_single_double_quoteattr +Passed test_single_quoteattr +Passed test_xmlgen_attr_escape +Passed test_xmlgen_basic +Passed test_xmlgen_content +Passed test_xmlgen_content_escape +Passed test_xmlgen_ignorable +Passed test_xmlgen_ns +Passed test_xmlgen_pi +37 tests, 0 failures From python-checkins at python.org Sat May 6 02:29:31 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 6 May 2006 02:29:31 +0200 (CEST) Subject: [Python-checkins] r45918 - sandbox/trunk/sio/bench_cat.py Message-ID: <20060506002931.8665B1E4008@bag.python.org> Author: guido.van.rossum Date: Sat May 6 02:29:30 2006 New Revision: 45918 Modified: sandbox/trunk/sio/bench_cat.py Log: Add more benchmarks. We now compare str and bytes, for the join and += idioms. Conclusion: bytes win; and join wins. bytes+= is slower than str.join but not all that much. Modified: sandbox/trunk/sio/bench_cat.py ============================================================================== --- sandbox/trunk/sio/bench_cat.py (original) +++ sandbox/trunk/sio/bench_cat.py Sat May 6 02:29:30 2006 @@ -13,8 +13,16 @@ timer = timeit.Timer("bbb = bytes()\nfor b in byteses: bbb += b", "from __main__ import strings, byteses") - print "byteses %.3f" % min(timer.repeat(3, 10)) + print "bytes+= %.3f" % min(timer.repeat(3, 10)) + + timer = timeit.Timer("bbb = bytes.join(byteses)", + "from __main__ import strings, byteses") + print "bytes.join %.3f" % min(timer.repeat(3, 10)) + + timer = timeit.Timer("sss = ''\nfor s in strings: sss += s", + "from __main__ import strings, byteses") + print "str+= %.3f" % min(timer.repeat(3, 10)) timer = timeit.Timer("sss = ''.join(strings)", "from __main__ import strings, byteses") - print "strings %.3f" % min(timer.repeat(3, 10)) + print "str.join %.3f" % min(timer.repeat(3, 10)) From python-checkins at python.org Sat May 6 02:39:04 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 6 May 2006 02:39:04 +0200 (CEST) Subject: [Python-checkins] r45919 - sandbox/trunk/sio/bench_cat.py Message-ID: <20060506003904.BAEC01E4008@bag.python.org> Author: guido.van.rossum Date: Sat May 6 02:39:04 2006 New Revision: 45919 Modified: sandbox/trunk/sio/bench_cat.py Log: Reinstate randomness in the input strings. Modified: sandbox/trunk/sio/bench_cat.py ============================================================================== --- sandbox/trunk/sio/bench_cat.py (original) +++ sandbox/trunk/sio/bench_cat.py Sat May 6 02:39:04 2006 @@ -1,3 +1,4 @@ +import random import timeit for size in [10, 20, 50, 100, 200, 500, 1000]: @@ -5,7 +6,7 @@ strings = [] byteses = [] for i in range(100000): - n = size + n = random.randrange(0, size) s = "x"*n b = bytes(s) strings.append(s) From python-checkins at python.org Sat May 6 15:09:46 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 6 May 2006 15:09:46 +0200 (CEST) Subject: [Python-checkins] r45920 - python/trunk/Doc/lib/libdoctest.tex Message-ID: <20060506130946.5200C1E4004@bag.python.org> Author: george.yoshida Date: Sat May 6 15:09:45 2006 New Revision: 45920 Modified: python/trunk/Doc/lib/libdoctest.tex Log: describe optional arguments for DocFileSuite Modified: python/trunk/Doc/lib/libdoctest.tex ============================================================================== --- python/trunk/Doc/lib/libdoctest.tex (original) +++ python/trunk/Doc/lib/libdoctest.tex Sat May 6 15:09:45 2006 @@ -1058,7 +1058,11 @@ There are two main functions for creating \class{\refmodule{unittest}.TestSuite} instances from text files and modules with doctests: -\begin{funcdesc}{DocFileSuite}{*paths, **kw} +\begin{funcdesc}{DocFileSuite}{\optional{module_relative}\optional{, + package}\optional{, setUp}\optional{, + tearDown}\optional{, globs}\optional{, + optionflags}\optional{, parser}} + Convert doctest tests from one or more text files to a \class{\refmodule{unittest}.TestSuite}. From python-checkins at python.org Sat May 6 15:15:34 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 6 May 2006 15:15:34 +0200 (CEST) Subject: [Python-checkins] r45921 - python/branches/release24-maint/Doc/lib/libdoctest.tex Message-ID: <20060506131534.126BA1E401E@bag.python.org> Author: george.yoshida Date: Sat May 6 15:15:33 2006 New Revision: 45921 Modified: python/branches/release24-maint/Doc/lib/libdoctest.tex Log: backport r45920 Modified: python/branches/release24-maint/Doc/lib/libdoctest.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libdoctest.tex (original) +++ python/branches/release24-maint/Doc/lib/libdoctest.tex Sat May 6 15:15:33 2006 @@ -1043,7 +1043,10 @@ There are two main functions for creating \class{\refmodule{unittest}.TestSuite} instances from text files and modules with doctests: -\begin{funcdesc}{DocFileSuite}{*paths, **kw} +\begin{funcdesc}{DocFileSuite}{\optional{module_relative}\optional{, + package}\optional{, setUp}\optional{, + tearDown}\optional{, globs}\optional{, + optionflags}\optional{, parser}} Convert doctest tests from one or more text files to a \class{\refmodule{unittest}.TestSuite}. From python-checkins at python.org Sat May 6 15:22:10 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 6 May 2006 15:22:10 +0200 (CEST) Subject: [Python-checkins] r45922 - peps/trunk/pep-0236.txt Message-ID: <20060506132210.E6EA31E4004@bag.python.org> Author: george.yoshida Date: Sat May 6 15:22:09 2006 New Revision: 45922 Modified: peps/trunk/pep-0236.txt Log: Typo fixes Modified: peps/trunk/pep-0236.txt ============================================================================== --- peps/trunk/pep-0236.txt (original) +++ peps/trunk/pep-0236.txt Sat May 6 15:22:09 2006 @@ -164,7 +164,7 @@ documentation, and can be inspected programatically via importing __future__ and examining its contents. - Each statment in __future__.py is of the form: + Each statement in __future__.py is of the form: FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ")" @@ -284,14 +284,14 @@ A: Outside the scope of this PEP. Seems unlikely to the author, though. Write a PEP if you want to pursue it. - Q: What about incompatibilites due to changes in the Python virtual + Q: What about incompatibilities due to changes in the Python virtual machine? A: Outside the scope of this PEP, although PEP 5 [1] suggests a grace period there too, and the future_statement may also have a role to play there. - Q: What about incompatibilites due to changes in Python's C API? + Q: What about incompatibilities due to changes in Python's C API? A: Outside the scope of this PEP. @@ -332,7 +332,7 @@ introduce a new keyword, we can't introduce an entirely new statement. But if we introduce a new keyword, that in itself would break old code. That would be too ironic to bear. Yes, - overloading "import" does suck, but not as energeticallly as the + overloading "import" does suck, but not as energetically as the alternatives -- as is, future_statements are 100% backward compatible. From python-checkins at python.org Sat May 6 15:30:38 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 6 May 2006 15:30:38 +0200 (CEST) Subject: [Python-checkins] r45923 - peps/trunk/pep-0289.txt Message-ID: <20060506133038.DD9171E401A@bag.python.org> Author: george.yoshida Date: Sat May 6 15:30:38 2006 New Revision: 45923 Modified: peps/trunk/pep-0289.txt Log: Typo fix Modified: peps/trunk/pep-0289.txt ============================================================================== --- peps/trunk/pep-0289.txt (original) +++ peps/trunk/pep-0289.txt Sat May 6 15:30:38 2006 @@ -33,7 +33,7 @@ sum([x*x for x in range(10)]) -Memory is conserved by using a generator expession instead:: +Memory is conserved by using a generator expression instead:: sum(x*x for x in range(10)) From python-checkins at python.org Sat May 6 16:16:52 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 6 May 2006 16:16:52 +0200 (CEST) Subject: [Python-checkins] r45924 - python/trunk/Doc/lib/libdoctest.tex Message-ID: <20060506141652.2FC191E4004@bag.python.org> Author: george.yoshida Date: Sat May 6 16:16:51 2006 New Revision: 45924 Modified: python/trunk/Doc/lib/libdoctest.tex Log: Use \versionchanged for the feature change Modified: python/trunk/Doc/lib/libdoctest.tex ============================================================================== --- python/trunk/Doc/lib/libdoctest.tex (original) +++ python/trunk/Doc/lib/libdoctest.tex Sat May 6 16:16:51 2006 @@ -1061,7 +1061,7 @@ \begin{funcdesc}{DocFileSuite}{\optional{module_relative}\optional{, package}\optional{, setUp}\optional{, tearDown}\optional{, globs}\optional{, - optionflags}\optional{, parser}} + optionflags}\optional{, parser}} Convert doctest tests from one or more text files to a \class{\refmodule{unittest}.TestSuite}. @@ -1130,9 +1130,9 @@ \versionadded{2.4} - Starting in Python 2.5, the global \code{__file__} was added to the + \versionchanged[The global \code{__file__} was added to the globals provided to doctests loaded from a text file using - \function{DocFileSuite()}. + \function{DocFileSuite()}]{2.5} \end{funcdesc} \begin{funcdesc}{DocTestSuite}{\optional{module}\optional{, From python-checkins at python.org Sat May 6 18:33:02 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 6 May 2006 18:33:02 +0200 (CEST) Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c Message-ID: <20060506163302.CA3D71E4004@bag.python.org> Author: martin.v.loewis Date: Sat May 6 18:32:54 2006 New Revision: 45925 Modified: python/trunk/Lib/tempfile.py python/trunk/Lib/test/test_os.py python/trunk/Misc/NEWS python/trunk/Modules/posixmodule.c Log: Port access, chmod, parts of getcwdu, mkdir, and utime to direct Win32 API. Modified: python/trunk/Lib/tempfile.py ============================================================================== --- python/trunk/Lib/tempfile.py (original) +++ python/trunk/Lib/tempfile.py Sat May 6 18:32:54 2006 @@ -327,6 +327,10 @@ try: _os.mkdir(file, 0700) return file + except WindowsError, e: + if e.errno == 183: # ERROR_ALREADY_EXISTS + continue # try again + raise except OSError, e: if e.errno == _errno.EEXIST: continue # try again Modified: python/trunk/Lib/test/test_os.py ============================================================================== --- python/trunk/Lib/test/test_os.py (original) +++ python/trunk/Lib/test/test_os.py Sat May 6 18:32:54 2006 @@ -375,6 +375,18 @@ def test_chdir(self): self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + def test_mkdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + + def test_utime(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None) + + def test_access(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + + def test_chmod(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + if sys.platform != 'win32': class Win32ErrorTests(unittest.TestCase): pass Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat May 6 18:32:54 2006 @@ -67,8 +67,8 @@ Extension Modules ----------------- -- Use Win32 API to implement os.{chdir,rename,rmdir,remove}. As a result, - these functions now raise WindowsError instead of OSError. +- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. + As a result, these functions now raise WindowsError instead of OSError. - Calling Tk_Init twice is refused if the first call failed as that may deadlock. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Sat May 6 18:32:54 2006 @@ -770,6 +770,16 @@ *time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, int); } +static void +time_t_to_FILE_TIME(int time_in, int nsec_in, FILETIME *out_ptr) +{ + /* XXX endianness */ + __int64 out; + out = time_in + secs_between_epochs; + out = out * 10000000 + nsec_in; + *(__int64*)out_ptr = out; +} + /* Below, we *know* that ugo+r is 0444 */ #if _S_IREAD != 0400 #error Unsupported C library @@ -1344,24 +1354,39 @@ { char *path; int mode; - int res; - + #ifdef Py_WIN_WIDE_FILENAMES + DWORD attr; if (unicode_file_names()) { PyUnicodeObject *po; if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) { Py_BEGIN_ALLOW_THREADS /* PyUnicode_AS_UNICODE OK without thread lock as it is a simple dereference. */ - res = _waccess(PyUnicode_AS_UNICODE(po), mode); + attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po)); Py_END_ALLOW_THREADS - return PyBool_FromLong(res == 0); + goto finish; } /* Drop the argument parsing error as narrow strings are also valid. */ PyErr_Clear(); } -#endif + if (!PyArg_ParseTuple(args, "eti:access", + Py_FileSystemDefaultEncoding, &path, &mode)) + return 0; + Py_BEGIN_ALLOW_THREADS + attr = GetFileAttributesA(path); + Py_END_ALLOW_THREADS + PyMem_Free(path); +finish: + if (attr == 0xFFFFFFFF) + /* File does not exist, or cannot read attributes */ + return PyBool_FromLong(0); + /* Access is possible if either write access wasn't requested, or + the file isn't read-only. */ + return PyBool_FromLong(!(mode & 2) || !(attr && FILE_ATTRIBUTE_READONLY)); +#else + int res; if (!PyArg_ParseTuple(args, "eti:access", Py_FileSystemDefaultEncoding, &path, &mode)) return NULL; @@ -1370,6 +1395,7 @@ Py_END_ALLOW_THREADS PyMem_Free(path); return PyBool_FromLong(res == 0); +#endif } #ifndef F_OK @@ -1481,14 +1507,24 @@ int i; int res; #ifdef Py_WIN_WIDE_FILENAMES + DWORD attr; if (unicode_file_names()) { PyUnicodeObject *po; if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) { Py_BEGIN_ALLOW_THREADS - res = _wchmod(PyUnicode_AS_UNICODE(po), i); + attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po)); + if (attr != 0xFFFFFFFF) { + if (i & _S_IWRITE) + attr &= ~FILE_ATTRIBUTE_READONLY; + else + attr |= FILE_ATTRIBUTE_READONLY; + res = SetFileAttributesW(PyUnicode_AS_UNICODE(po), attr); + } + else + res = 0; Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_unicode_filename( + if (!res) + return win32_error_unicode("chmod", PyUnicode_AS_UNICODE(po)); Py_INCREF(Py_None); return Py_None; @@ -1497,7 +1533,29 @@ are also valid. */ PyErr_Clear(); } -#endif /* Py_WIN_WIDE_FILENAMES */ + if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding, + &path, &i)) + return NULL; + Py_BEGIN_ALLOW_THREADS + attr = GetFileAttributesA(path); + if (attr != 0xFFFFFFFF) { + if (i & _S_IWRITE) + attr &= ~FILE_ATTRIBUTE_READONLY; + else + attr |= FILE_ATTRIBUTE_READONLY; + res = SetFileAttributesA(path, attr); + } + else + res = 0; + Py_END_ALLOW_THREADS + if (!res) { + win32_error("chmod", path); + PyMem_Free(path); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; +#else /* Py_WIN_WIDE_FILENAMES */ if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding, &path, &i)) return NULL; @@ -1509,6 +1567,7 @@ PyMem_Free(path); Py_INCREF(Py_None); return Py_None; +#endif } @@ -1644,15 +1703,33 @@ char *res; #ifdef Py_WIN_WIDE_FILENAMES + DWORD len; if (unicode_file_names()) { - wchar_t *wres; wchar_t wbuf[1026]; + wchar_t *wbuf2 = wbuf; + PyObject *resobj; Py_BEGIN_ALLOW_THREADS - wres = _wgetcwd(wbuf, sizeof wbuf/ sizeof wbuf[0]); + len = GetCurrentDirectoryW(sizeof wbuf/ sizeof wbuf[0], wbuf); + /* If the buffer is large enough, len does not include the + terminating \0. If the buffer is too small, len includes + the space needed for the terminator. */ + if (len >= sizeof wbuf/ sizeof wbuf[0]) { + wbuf2 = malloc(len * sizeof(wchar_t)); + if (wbuf2) + len = GetCurrentDirectoryW(len, wbuf2); + } Py_END_ALLOW_THREADS - if (wres == NULL) - return posix_error(); - return PyUnicode_FromWideChar(wbuf, wcslen(wbuf)); + if (!wbuf2) { + PyErr_NoMemory(); + return NULL; + } + if (!len) { + if (wbuf2 != wbuf) free(wbuf2); + return win32_error("getcwdu", NULL); + } + resobj = PyUnicode_FromWideChar(wbuf2, len); + if (wbuf2 != wbuf) free(wbuf2); + return resobj; } #endif @@ -2033,10 +2110,10 @@ Py_BEGIN_ALLOW_THREADS /* PyUnicode_AS_UNICODE OK without thread lock as it is a simple dereference. */ - res = _wmkdir(PyUnicode_AS_UNICODE(po)); + res = CreateDirectoryW(PyUnicode_AS_UNICODE(po), NULL); Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); + if (!res) + return win32_error_unicode("mkdir", PyUnicode_AS_UNICODE(po)); Py_INCREF(Py_None); return Py_None; } @@ -2044,13 +2121,29 @@ are also valid. */ PyErr_Clear(); } -#endif + if (!PyArg_ParseTuple(args, "et|i:mkdir", + Py_FileSystemDefaultEncoding, &path, &mode)) + return NULL; + Py_BEGIN_ALLOW_THREADS + /* PyUnicode_AS_UNICODE OK without thread lock as + it is a simple dereference. */ + res = CreateDirectoryA(path, NULL); + Py_END_ALLOW_THREADS + if (!res) { + win32_error("mkdir", path); + PyMem_Free(path); + return NULL; + } + PyMem_Free(path); + Py_INCREF(Py_None); + return Py_None; +#else if (!PyArg_ParseTuple(args, "et|i:mkdir", Py_FileSystemDefaultEncoding, &path, &mode)) return NULL; Py_BEGIN_ALLOW_THREADS -#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) ) && !defined(__QNX__) +#if ( defined(__WATCOMC__) || defined(PYCC_VACPP) ) && !defined(__QNX__) res = mkdir(path); #else res = mkdir(path, mode); @@ -2061,6 +2154,7 @@ PyMem_Free(path); Py_INCREF(Py_None); return Py_None; +#endif } @@ -2299,6 +2393,84 @@ static PyObject * posix_utime(PyObject *self, PyObject *args) { +#ifdef Py_WIN_WIDE_FILENAMES + PyObject *arg; + PyUnicodeObject *obwpath; + wchar_t *wpath = NULL; + char *apath = NULL; + HANDLE hFile; + long atimesec, mtimesec, ausec, musec; + FILETIME atime, mtime; + PyObject *result = NULL; + + if (unicode_file_names()) { + if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) { + wpath = PyUnicode_AS_UNICODE(obwpath); + Py_BEGIN_ALLOW_THREADS + hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0, + NULL, OPEN_EXISTING, 0, NULL); + Py_END_ALLOW_THREADS + if (hFile == INVALID_HANDLE_VALUE) + return win32_error_unicode("utime", wpath); + } else + /* Drop the argument parsing error as narrow strings + are also valid. */ + PyErr_Clear(); + } + if (!wpath) { + if (!PyArg_ParseTuple(args, "etO:utime", + Py_FileSystemDefaultEncoding, &apath, &arg)) + return NULL; + Py_BEGIN_ALLOW_THREADS + hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0, + NULL, OPEN_EXISTING, 0, NULL); + Py_END_ALLOW_THREADS + if (hFile == INVALID_HANDLE_VALUE) { + win32_error("utime", apath); + PyMem_Free(apath); + return NULL; + } + PyMem_Free(apath); + } + + if (arg == Py_None) { + SYSTEMTIME now; + GetSystemTime(&now); + if (!SystemTimeToFileTime(&now, &mtime) || + !SystemTimeToFileTime(&now, &atime)) { + win32_error("utime", NULL); + goto done; + } + } + else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) { + PyErr_SetString(PyExc_TypeError, + "utime() arg 2 must be a tuple (atime, mtime)"); + goto done; + } + else { + if (extract_time(PyTuple_GET_ITEM(arg, 0), + &atimesec, &ausec) == -1) + goto done; + time_t_to_FILE_TIME(atimesec, ausec, &atime); + if (extract_time(PyTuple_GET_ITEM(arg, 1), + &mtimesec, &musec) == -1) + goto done; + time_t_to_FILE_TIME(mtimesec, musec, &mtime); + } + if (!SetFileTime(hFile, NULL, &atime, &mtime)) { + /* Avoid putting the file name into the error here, + as that may confuse the user into believing that + something is wrong with the file, when it also + could be the time stamp that gives a problem. */ + win32_error("utime", NULL); + } + Py_INCREF(Py_None); + result = Py_None; +done: + CloseHandle(hFile); + return result; +#else /* Py_WIN_WIDE_FILENAMES */ + char *path = NULL; long atime, mtime, ausec, musec; int res; @@ -2321,33 +2493,13 @@ #define UTIME_ARG buf #endif /* HAVE_UTIMES */ - int have_unicode_filename = 0; -#ifdef Py_WIN_WIDE_FILENAMES - PyUnicodeObject *obwpath; - wchar_t *wpath; - if (unicode_file_names()) { - if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) { - wpath = PyUnicode_AS_UNICODE(obwpath); - have_unicode_filename = 1; - } else - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif /* Py_WIN_WIDE_FILENAMES */ - if (!have_unicode_filename && \ - !PyArg_ParseTuple(args, "etO:utime", + if (!PyArg_ParseTuple(args, "etO:utime", Py_FileSystemDefaultEncoding, &path, &arg)) return NULL; if (arg == Py_None) { /* optional time values not given */ Py_BEGIN_ALLOW_THREADS -#ifdef Py_WIN_WIDE_FILENAMES - if (have_unicode_filename) - res = _wutime(wpath, NULL); - else -#endif /* Py_WIN_WIDE_FILENAMES */ res = utime(path, NULL); Py_END_ALLOW_THREADS } @@ -2378,23 +2530,11 @@ Py_END_ALLOW_THREADS #else Py_BEGIN_ALLOW_THREADS -#ifdef Py_WIN_WIDE_FILENAMES - if (have_unicode_filename) - /* utime is OK with utimbuf, but _wutime insists - on _utimbuf (the msvc headers assert the - underscore version is ansi) */ - res = _wutime(wpath, (struct _utimbuf *)UTIME_ARG); - else -#endif /* Py_WIN_WIDE_FILENAMES */ res = utime(path, UTIME_ARG); Py_END_ALLOW_THREADS #endif /* HAVE_UTIMES */ } if (res < 0) { -#ifdef Py_WIN_WIDE_FILENAMES - if (have_unicode_filename) - return posix_error_with_unicode_filename(wpath); -#endif /* Py_WIN_WIDE_FILENAMES */ return posix_error_with_allocated_filename(path); } PyMem_Free(path); @@ -2403,6 +2543,7 @@ #undef UTIME_ARG #undef ATIME #undef MTIME +#endif /* Py_WIN_WIDE_FILENAMES */ } From buildbot at python.org Sat May 6 19:01:18 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 06 May 2006 17:01:18 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060506170118.31A501E4004@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/653 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat May 6 19:09:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 06 May 2006 17:09:26 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060506170927.11B121E4004@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/662 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Sat May 6 19:42:48 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Sat, 06 May 2006 19:42:48 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <20060506163302.CA3D71E4004@bag.python.org> References: <20060506163302.CA3D71E4004@bag.python.org> Message-ID: <445CE018.7040609@egenix.com> martin.v.loewis wrote: > Author: martin.v.loewis > Date: Sat May 6 18:32:54 2006 > New Revision: 45925 > > Modified: > python/trunk/Lib/tempfile.py > python/trunk/Lib/test/test_os.py > python/trunk/Misc/NEWS > python/trunk/Modules/posixmodule.c > Log: > Port access, chmod, parts of getcwdu, mkdir, and utime to direct Win32 API. > > Modified: python/trunk/Lib/tempfile.py > ============================================================================== > --- python/trunk/Lib/tempfile.py (original) > +++ python/trunk/Lib/tempfile.py Sat May 6 18:32:54 2006 > @@ -327,6 +327,10 @@ > try: > _os.mkdir(file, 0700) > return file > + except WindowsError, e: > + if e.errno == 183: # ERROR_ALREADY_EXISTS > + continue # try again > + raise > except OSError, e: > if e.errno == _errno.EEXIST: > continue # try again Rather than adding new cases for the changed error codes, wouldn't it be better and more backwards compatible to add aliases to the errno module for e.g. ERROR_ALREADY_EXISTS ?! The errno module currently only has this entry: #ifdef EEXIST inscode(d, ds, de, "EEXIST", EEXIST, "File exists"); #endif Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 06 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Sat May 6 22:04:09 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 6 May 2006 22:04:09 +0200 (CEST) Subject: [Python-checkins] r45926 - python/trunk/Lib/bsddb/test/test_thread.py Message-ID: <20060506200409.1C5431E4004@bag.python.org> Author: martin.v.loewis Date: Sat May 6 22:04:08 2006 New Revision: 45926 Modified: python/trunk/Lib/bsddb/test/test_thread.py Log: Handle ERROR_ALREADY_EXISTS. Modified: python/trunk/Lib/bsddb/test/test_thread.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_thread.py (original) +++ python/trunk/Lib/bsddb/test/test_thread.py Sat May 6 22:04:08 2006 @@ -24,6 +24,12 @@ except ImportError: have_threads = False +try: + WindowsError +except NameError: + class WindowsError(Exception): + pass + import unittest from test_all import verbose @@ -51,6 +57,8 @@ self.homeDir = homeDir try: os.mkdir(homeDir) + except WindowsError, e: + if e.errno <> 183: raise # ERROR_ALREADY_EXISTS except OSError, e: if e.errno <> errno.EEXIST: raise self.env = db.DBEnv() From python-checkins at python.org Sun May 7 03:49:44 2006 From: python-checkins at python.org (talin) Date: Sun, 7 May 2006 03:49:44 +0200 (CEST) Subject: [Python-checkins] r45928 - peps/trunk/pep-3101.txt Message-ID: <20060507014944.9A4951E4009@bag.python.org> Author: talin Date: Sun May 7 03:49:43 2006 New Revision: 45928 Modified: peps/trunk/pep-3101.txt Log: Updated based on collected feedback. Modified: peps/trunk/pep-3101.txt ============================================================================== --- peps/trunk/pep-3101.txt (original) +++ peps/trunk/pep-3101.txt Sun May 7 03:49:43 2006 @@ -8,7 +8,7 @@ Content-Type: text/plain Created: 16-Apr-2006 Python-Version: 3.0 -Post-History: +Post-History: 28-Apr-2006 Abstract @@ -50,8 +50,8 @@ The specification will consist of 4 parts: - - Specification of a set of methods to be added to the built-in - string class. + - Specification of a new formatting method to be added to the + built-in string class. - Specification of a new syntax for format strings. @@ -99,13 +99,13 @@ "My name is Fred :-{}" The element within the braces is called a 'field'. Fields consist - of a name, which can either be simple or compound, and an optional - 'conversion specifier'. + of a 'field name', which can either be simple or compound, and an + optional 'conversion specifier'. - Simple names are either names or numbers. If numbers, they must - be valid decimal numbers; if names, they must be valid Python - identifiers. A number is used to identify a positional argument, - while a name is used to identify a keyword argument. + Simple field names are either names or numbers. If numbers, they + must be valid base-10 integers; if names, they must be valid + Python identifiers. A number is used to identify a positional + argument, while a name is used to identify a keyword argument. Compound names are a sequence of simple names seperated by periods: @@ -118,8 +118,9 @@ positional argument 0. Each field can also specify an optional set of 'conversion - specifiers'. Conversion specifiers follow the field name, with a - colon (':') character separating the two: + specifiers' which can be used to adjust the format of that field. + Conversion specifiers follow the field name, with a colon (':') + character separating the two: "My name is {0:8}".format('Fred') @@ -130,11 +131,15 @@ The conversion specifier consists of a sequence of zero or more characters, each of which can consist of any printable character - except for a non-escaped '}'. The format() method does not - attempt to intepret the conversion specifiers in any way; it - merely passes all of the characters between the first colon ':' - and the matching right brace ('}') to the various underlying - formatters (described later.) + except for a non-escaped '}'. + + Conversion specifiers can themselves contain replacement fields; + this will be described in a later section. Except for this + replacement, the format() method does not attempt to intepret the + conversion specifiers in any way; it merely passes all of the + characters between the first colon ':' and the matching right + brace ('}') to the various underlying formatters (described + later.) Standard Conversion Specifiers @@ -142,16 +147,19 @@ For most built-in types, the conversion specifiers will be the same or similar to the existing conversion specifiers used with the '%' operator. Thus, instead of '%02.2x", you will say - '{0:2.2x}'. + '{0:02.2x}'. There are a few differences however: - The trailing letter is optional - you don't need to say '2.2d', - you can instead just say '2.2'. If the letter is omitted, the - value will be converted into its 'natural' form (that is, the - form that it take if str() or unicode() were called on it) - subject to the field length and precision specifiers (if - supplied). + you can instead just say '2.2'. If the letter is omitted, a + default will be assumed based on the type of the argument. + The defaults will be as follows: + + string or unicode object: 's' + integer: 'd' + floating-point number: 'f' + all other types: 's' - Variable field width specifiers use a nested version of the {} syntax, allowing the width specifier to be either a positional @@ -159,10 +167,6 @@ "{0:{1}.{2}d}".format(a, b, c) - (Note: It might be easier to parse if these used a different - type of delimiter, such as parens - avoiding the need to create - a regex that handles the recursive case.) - - The support for length modifiers (which are ignored by Python anyway) is dropped. @@ -171,7 +175,7 @@ conversion specifiers are identical to the arguments to the strftime() function: - "Today is: {0:%x}".format(datetime.now()) + "Today is: {0:%a %b %d %H:%M:%S %Y}".format(datetime.now()) Controlling Formatting @@ -203,19 +207,37 @@ User-Defined Formatting Classes - The code that interprets format strings can be called explicitly - from user code. This allows the creation of custom formatter - classes that can override the normal formatting rules. - - The string and unicode classes will have a class method called - 'cformat' that does all the actual work of formatting; The - format() method is just a wrapper that calls cformat. + There will be times when customizing the formatting of fields + on a per-type basis is not enough. An example might be an + accounting application, which displays negative numbers in + parentheses rather than using a negative sign. + + The string formatting system facilitates this kind of application- + specific formatting by allowing user code to directly invoke + the code that interprets format strings and fields. User-written + code can intercept the normal formatting operations on a per-field + basis, substituting their own formatting methods. + + For example, in the aforementioned accounting application, there + could be an application-specific number formatter, which reuses + the string.format templating code to do most of the work. The + API for such an application-specific formatter is up to the + application; here are several possible examples: + + cell_format( "The total is: {0}", total ) + + TemplateString( "The total is: {0}" ).format( total ) + + Creating an application-specific formatter is relatively straight- + forward. The string and unicode classes will have a class method + called 'cformat' that does all the actual work of formatting; The + built-in format() method is just a wrapper that calls cformat. The parameters to the cformat function are: -- The format string (or unicode; the same function handles both.) - -- A field format hook (see below) + -- A callable 'format hook', which is called once per field -- A tuple containing the positional arguments -- A dict containing the keyword arguments @@ -223,15 +245,16 @@ string, and return a new string (or unicode) with all of the fields replaced with their formatted values. - For each field, the cformat function will attempt to call the - field format hook with the following arguments: + The format hook is a callable object supplied by the user, which + is invoked once per field, and which can override the normal + formatting for that field. For each field, the cformat function + will attempt to call the field format hook with the following + arguments: - field_hook(value, conversion, buffer) + format_hook(value, conversion, buffer) The 'value' field corresponds to the value being formatted, which - was retrieved from the arguments using the field name. (The - field_hook has no control over the selection of values, only - how they are formatted.) + was retrieved from the arguments using the field name. The 'conversion' argument is the conversion spec part of the field, which will be either a string or unicode object, depending @@ -299,11 +322,34 @@ - Other variations include Ruby's #{}, PHP's {$name}, and so on. - + + Some specific aspects of the syntax warrant additional comments: + + 1) The use of the backslash character for escapes. A few people + suggested doubling the brace characters to indicate a literal + brace rather than using backslash as an escape character. This is + also the convention used in the .Net libraries. Here's how the + previously-given example would look with this convention: + + "My name is {0} :-{{}}".format('Fred') + + One problem with this syntax is that it conflicts with the use of + nested braces to allow parameterization of the conversion + specifiers: + + "{0:{1}.{2}}".format(a, b, c) + + (There are alternative solutions, but they are too long to go + into here.) + + 2) The use of the colon character (':') as a separator for + conversion specifiers. This was chosen simply because that's + what .Net uses. + Sample Implementation - A rought prototype of the underlying 'cformat' function has been + A rough prototype of the underlying 'cformat' function has been coded in Python, however it needs much refinement before being submitted. From python-checkins at python.org Sun May 7 05:45:28 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 7 May 2006 05:45:28 +0200 (CEST) Subject: [Python-checkins] r45929 - sandbox/trunk/sio/bench_io.py sandbox/trunk/sio/io.py Message-ID: <20060507034528.C91A61E4009@bag.python.org> Author: guido.van.rossum Date: Sun May 7 05:45:27 2006 New Revision: 45929 Modified: sandbox/trunk/sio/bench_io.py sandbox/trunk/sio/io.py Log: Add an essential optimization to buffered read() -- bypass the buffer if there's no buffered data and the read size is >= bufsize. Also tweak the I/O benchmark to show that this is now faster than classic I/O. Modified: sandbox/trunk/sio/bench_io.py ============================================================================== --- sandbox/trunk/sio/bench_io.py (original) +++ sandbox/trunk/sio/bench_io.py Sun May 7 05:45:27 2006 @@ -36,7 +36,7 @@ def reader(): buffer = bytes() bufsize = 32*1024 - file = io.open(TFN, "rb", 32*1024) + file = io.open(TFN, "rb", 8*1024) try: while len(buffer) < N: buffer += file.read(bufsize) Modified: sandbox/trunk/sio/io.py ============================================================================== --- sandbox/trunk/sio/io.py (original) +++ sandbox/trunk/sio/io.py Sun May 7 05:45:27 2006 @@ -225,6 +225,13 @@ result = data else: result += data + elif n >= self._bufsize: + data = self._file.read(n) + n -= len(data) + if result is None: + result = data + else: + result += data else: self._buffer = self._file.read(max(n, self._bufsize)) self._bufptr = 0 From martin at v.loewis.de Sun May 7 09:00:28 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 07 May 2006 09:00:28 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445CE018.7040609@egenix.com> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> Message-ID: <445D9B0C.5080808@v.loewis.de> M.-A. Lemburg wrote: >> + except WindowsError, e: >> + if e.errno == 183: # ERROR_ALREADY_EXISTS >> + continue # try again >> + raise >> except OSError, e: >> if e.errno == _errno.EEXIST: >> continue # try again > > Rather than adding new cases for the changed error codes, > wouldn't it be better and more backwards compatible to > add aliases to the errno module for e.g. ERROR_ALREADY_EXISTS ?! It might be better for some reason, but I cannot see how it would be more backwards compatible to define symbolic constant ERROR_ALREADY_EXISTS, with the value 183. In what sense would the backwards compatibility be improved ?! Regards, Martin From mal at egenix.com Sun May 7 15:30:00 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Sun, 07 May 2006 15:30:00 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445D9B0C.5080808@v.loewis.de> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> Message-ID: <445DF658.7050609@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >>> + except WindowsError, e: >>> + if e.errno == 183: # ERROR_ALREADY_EXISTS >>> + continue # try again >>> + raise >>> except OSError, e: >>> if e.errno == _errno.EEXIST: >>> continue # try again >> Rather than adding new cases for the changed error codes, >> wouldn't it be better and more backwards compatible to >> add aliases to the errno module for e.g. ERROR_ALREADY_EXISTS ?! > > It might be better for some reason, but I cannot see how > it would be more backwards compatible to define symbolic > constant ERROR_ALREADY_EXISTS, with the value 183. That's not what I meant: in errno, many WSA windows error codes are aliased to their corresponding Unix error codes to enhance portability across platforms. I don't know where ERROR_ALREADY_EXISTS is defined and how it relates to the WSA codes, but since EEXIST doesn't have a corresponding, it's probably a good idea to alias EEXIST to ERROR_ALREADY_EXISTS and use that in tempfile.py for both Windows and Unix instead of adding another except clause. > In what sense would the backwards compatibility be improved ?! I suppose that the code used to raise an OSError with EEXIST error code before the change to use Win32 APIs on Windows. With the alias, existing code looking for EEXIST on Windows will continue to work without change. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 07 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From martin at v.loewis.de Sun May 7 18:19:21 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 07 May 2006 18:19:21 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445DF658.7050609@egenix.com> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> Message-ID: <445E1E09.1040908@v.loewis.de> M.-A. Lemburg wrote: > That's not what I meant: in errno, many WSA windows error codes > are aliased to their corresponding Unix error codes to > enhance portability across platforms. Can you please explain how such aliasing could work? errno can only have one value: either 183, or 17, but not both. > I don't know where ERROR_ALREADY_EXISTS is defined and > how it relates to the WSA codes, but since EEXIST doesn't > have a corresponding, it's probably a good idea to alias > EEXIST to ERROR_ALREADY_EXISTS and use that in tempfile.py > for both Windows and Unix instead of adding another except > clause. ERROR_ALREADY_EXISTS is defined in winerror.h, and it is possible result of the GetLastError system call. I don't understand the fragment "but since EEXIST doesn't have a corresponding": A corresponding what? You mean, I should define EEXIST to have the value of 183, instead of having the value 17? That's certainly not a good idea. First, EEXIST should map to either ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183), depending on context. Furthermore, the C library will still put its own value (17) into errno. >> In what sense would the backwards compatibility be improved ?! > > I suppose that the code used to raise an OSError with > EEXIST error code before the change to use Win32 APIs > on Windows. Correct. It now raises WindowsError instead. > With the alias, existing code looking for EEXIST on Windows > will continue to work without change. I still cannot see how this could work, at least not in a way that wouldn't break something else. Regards, Martin From python-checkins at python.org Sun May 7 19:12:14 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sun, 7 May 2006 19:12:14 +0200 (CEST) Subject: [Python-checkins] r45931 - python/trunk/Doc/howto/urllib2.rst Message-ID: <20060507171214.040251E400A@bag.python.org> Author: andrew.kuchling Date: Sun May 7 19:12:12 2006 New Revision: 45931 Modified: python/trunk/Doc/howto/urllib2.rst Log: [Patch #1479977] Revised version of urllib2 HOWTO, edited by John J. Lee Modified: python/trunk/Doc/howto/urllib2.rst ============================================================================== --- python/trunk/Doc/howto/urllib2.rst (original) +++ python/trunk/Doc/howto/urllib2.rst Sun May 7 19:12:12 2006 @@ -8,7 +8,9 @@ .. note:: - There is an French translation of this HOWTO, available at `urllib2 - Le Manuel manquant `_. + There is an French translation of an earlier revision of this + HOWTO, available at `urllib2 - Le Manuel manquant + `_. .. contents:: urllib2 Tutorial @@ -18,56 +20,143 @@ .. sidebar:: Related Articles - You may also find useful the following articles on fetching web resources with Python : + You may also find useful the following article on fetching web + resources with Python : * `Basic Authentication `_ - A tutorial on *Basic Authentication*, with exampels in Python. + A tutorial on *Basic Authentication*, with examples in Python. - * `cookielib and ClientCookie `_ - - How to handle cookies, when fetching web pages with Python. - - This HOWTO is written by `Michael Foord `_. - -**urllib2** is a Python_ module for fetching URLs (Uniform Resource Locators). It offers a very simple interface, in the form of the *urlopen* function. This is capable of fetching URLs using a variety of different protocols. It also offers a slightly more complex interface for handling common situations - like basic authentication, cookies, proxies, and so on. These are provided by objects called handlers and openers. + This HOWTO is written by `Michael Foord + `_. -For straightforward situations *urlopen* is very easy to use. But as soon as you encounter errors, or non-trivial cases, you will need some understanding of the HyperText Transfer Protocol. The most comprehensive reference to HTTP is :RFC:`2616`. This is a technical document and not intended to be easy to read. This HOWTO aims to illustrate using *urllib2*, with enough detail about HTTP to help you through. It is not intended to replace the `urllib2 docs`_ [#]_, but is supplementary to them. +**urllib2** is a Python_ module for fetching URLs (Uniform Resource +Locators). It offers a very simple interface, in the form of the +*urlopen* function. This is capable of fetching URLs using a variety +of different protocols. It also offers a slightly more complex +interface for handling common situations - like basic authentication, +cookies, proxies, and so on. These are provided by objects called +handlers and openers. + +While urllib2 supports fetching URLs for many "URL schemes" +(identified by the string before the ":" in URL - e.g. "ftp" is the +URL scheme of "ftp://python.org/") using their associated network +protocols (e.g. FTP, HTTP), this tutorial focuses on the most common +case, HTTP. + +For straightforward situations *urlopen* is very easy to use. But as +soon as you encounter errors or non-trivial cases when opening HTTP +URLs, you will need some understanding of the HyperText Transfer +Protocol. The most comprehensive and authoritative reference to HTTP +is :RFC:`2616`. This is a technical document and not intended to be +easy to read. This HOWTO aims to illustrate using *urllib2*, with +enough detail about HTTP to help you through. It is not intended to +replace the `urllib2 docs`_ , but is supplementary to them. Fetching URLs ============= -HTTP is based on requests and responses - the client makes requests and servers send responses. Python mirrors this by having you form a ``Request`` object which represents the request you are making. In it's simplest form you create a Request object that specifies the URL you want to fetch [#]_. Calling ``urlopen`` with this Request object returns a handle on the page requested. This handle is a file like object : :: +The simplest way to use urllib2 is as follows : :: + + import urllib2 + response = urllib2.urlopen('http://python.org/') + html = response.read() + +Many uses of urllib2 will be that simple (note that instead of an +'http:' URL we could have used an URL starting with 'ftp:', 'file:', +etc.). However, it's the purpose of this tutorial to explain the more +complicated cases, concentrating on HTTP. + +HTTP is based on requests and responses - the client makes requests +and servers send responses. urllib2 mirrors this with a ``Request`` +object which represents the HTTP request you are making. In its +simplest form you create a Request object that specifies the URL you +want to fetch. Calling ``urlopen`` with this Request object returns a +response object for the URL requested. This response is a file-like +object, which means you can for example call .read() on the response : +:: import urllib2 - - the_url = 'http://www.voidspace.org.uk' - req = urllib2.Request(the_url) - handle = urllib2.urlopen(req) - the_page = handle.read() - -There are two extra things that Request objects allow you to do. Sometimes you want to **POST** data to a CGI (Common Gateway Interface) [#]_ or other web application. This is what your browser does when you fill in a FORM on the web. You may be mimicking a FORM submission, or transmitting data to your own application. In either case the data needs to be encoded for safe transmission over HTTP, and then passed to the Request object as the ``data`` argument. The encoding is done using a function from the ``urllib`` library *not* from ``urllib2``. :: + + req = urllib2.Request('http://www.voidspace.org.uk') + response = urllib2.urlopen(req) + the_page = response.read() + +Note that urllib2 makes use of the same Request interface to handle +all URL schemes. For example, you can make an FTP request like so: :: + + req = urllib2.Request('ftp://example.com/') + +In the case of HTTP, there are two extra things that Request objects +allow you to do: First, you can pass data to be sent to the server. +Second, you can pass extra information ("metadata") *about* the data +or the about request itself, to the server - this information is sent +as HTTP "headers". Let's look at each of these in turn. + +Data +---- + +Sometimes you want to send data to a URL (often the URL will refer to +a CGI (Common Gateway Interface) script [#]_ or other web +application). With HTTP, this is often done using what's known as a +**POST** request. This is often what your browser does when you submit +a HTML form that you filled in on the web. Not all POSTs have to come +from forms: you can use a POST to transmit arbitrary data to your own +application. In the common case of HTML forms, the data needs to be +encoded in a standard way, and then passed to the Request object as +the ``data`` argument. The encoding is done using a function from the +``urllib`` library *not* from ``urllib2``. :: import urllib import urllib2 - - the_url = 'http://www.someserver.com/cgi-bin/register.cgi' + + url = 'http://www.someserver.com/cgi-bin/register.cgi' values = {'name' : 'Michael Foord', 'location' : 'Northampton', 'language' : 'Python' } - + data = urllib.urlencode(values) - req = urllib2.Request(the_url, data) - handle = urllib2.urlopen(req) - the_page = handle.read() + req = urllib2.Request(url, data) + response = urllib2.urlopen(req) + the_page = response.read() + +Note that other encodings are sometimes required (e.g. for file upload +from HTML forms - see `HTML Specification, Form Submission`_ for more +details). + +If you do not pass the ``data`` argument, urllib2 uses a **GET** +request. One way in which GET and POST requests differ is that POST +requests often have "side-effects": they change the state of the +system in some way (for example by placing an order with the website +for a hundredweight of tinned spam to be delivered to your door). +Though the HTTP standard makes it clear that POSTs are intended to +*always* cause side-effects, and GET requests *never* to cause +side-effects, nothing prevents a GET request from having side-effects, +nor a POST requests from having no side-effects. Data can also be +passed in an HTTP request by encoding it in the URL itself. + +Headers +------- -Some websites [#]_ dislike being browsed by programs, or send different versions to different browsers [#]_ . By default urllib2 identifies itself as ``Python-urllib/2.4``, which may confuse the site, or just plain not work. The way a browser identifies itself is through the ``User-Agent`` header [#]_. When you create a Request object you can pass a dictionary of headers in. The following example makes the same request as above, but identifies itself as a version of Internet Explorer [#]_. :: +We'll discuss here one particular HTTP header, to illustrate how to +add headers to your HTTP request. + +Some websites [#]_ dislike being browsed by programs, or send +different versions to different browsers [#]_ . By default urllib2 +identifies itself as ``Python-urllib/x.y`` (where ``x`` and ``y`` are +the major and minor version numbers of the Python release, +e.g. ``Python-urllib/2.5``), which may confuse the site, or just plain +not work. The way a browser identifies itself is through the +``User-Agent`` header [#]_. When you create a Request object you can +pass a dictionary of headers in. The following example makes the same +request as above, but identifies itself as a version of Internet +Explorer [#]_. :: import urllib import urllib2 - the_url = 'http://www.someserver.com/cgi-bin/register.cgi' + url = 'http://www.someserver.com/cgi-bin/register.cgi' user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' values = {'name' : 'Michael Foord', 'location' : 'Northampton', @@ -75,38 +164,38 @@ headers = { 'User-Agent' : user_agent } data = urllib.urlencode(values) - req = urllib2.Request(the_url, data, headers) - handle = urllib2.urlopen(req) - the_page = handle.read() + req = urllib2.Request(url, data, headers) + response = urllib2.urlopen(req) + the_page = response.read() -The handle also has two useful methods. See the section on `info and geturl`_ which comes after we have a look at what happens when things go wrong. +The response also has two useful methods. See the section on `info and +geturl`_ which comes after we have a look at what happens when things +go wrong. -Coping With Errors -================== +Handling Exceptions +=================== -*urlopen* raises ``URLError`` or ``HTTPError`` in the event of an error. ``HTTPError`` is a subclass of ``URLError``, which is a subclass of ``IOError``. This means you can trap for ``IOError`` if you want. :: +*urlopen* raises ``URLError`` when it cannot handle a response (though +as usual with Python APIs, builtin exceptions such as ValueError, +TypeError etc. may also be raised). - req = urllib2.Request(some_url) - try: - handle = urllib2.urlopen(req) - except IOError: - print 'Something went wrong' - else: - print handle.read() +``HTTPError`` is the subclass of ``URLError`` raised in the specific +case of HTTP URLs. URLError -------- -If the request fails to reach a server then urlopen will raise a ``URLError``. This will usually be because there is no network connection (no route to the specified server), or the specified server doesn't exist. - -In this case, the exception raised will have a 'reason' attribute, which is a tuple containing an error code and a text error message. +Often, URLError is raised because there is no network connection (no +route to the specified server), or the specified server doesn't exist. +In this case, the exception raised will have a 'reason' attribute, +which is a tuple containing an error code and a text error message. e.g. :: >>> req = urllib2.Request('http://www.pretend_server.org') >>> try: urllib2.urlopen(req) - >>> except IOError, e: + >>> except URLError, e: >>> print e.reason >>> (4, 'getaddrinfo failed') @@ -115,26 +204,36 @@ HTTPError --------- -If the request reaches a server, but the server is unable to fulfil the request, it returns an error code. The default handlers will hande some of these errors for you. For those it can't handle, urlopen will raise an ``HTTPError``. Typical errors include '404' (page not found), '403' (request forbidden), and '401' (authentication required). +Every HTTP response from the server contains a numeric "status +code". Sometimes the status code indicates that the server is unable +to fulfil the request. The default handlers will handle some of these +responses for you (for example, if the response is a "redirection" +that requests the client fetch the document from a different URL, +urllib2 will handle that for you). For those it can't handle, urlopen +will raise an ``HTTPError``. Typical errors include '404' (page not +found), '403' (request forbidden), and '401' (authentication +required). -See http://www.w3.org/Protocols/HTTP/HTRESP.html for a reference on all the http error codes. +See section 10 of RFC 2616 for a reference on all the HTTP error +codes. -The ``HTTPError`` instance raised will have an integer 'code' attribute, which corresponds to the error sent by the server. - -There is a useful dictionary of response codes in ``HTTPBaseServer``, that shows all the defined response codes. Because the default handlers handle redirects (codes in the 300 range), and codes in the 100-299 range indicate success, you will usually only see error codes in the 400-599 range. +The ``HTTPError`` instance raised will have an integer 'code' +attribute, which corresponds to the error sent by the server. Error Codes ~~~~~~~~~~~ -.. note:: - - As of Python 2.5 a dictionary like this one has become part of ``urllib2``. - -:: +Because the default handlers handle redirects (codes in the 300 +range), and codes in the 100-299 range indicate success, you will +usually only see error codes in the 400-599 range. + +``BaseHTTPServer.BaseHTTPRequestHandler.responses`` is a useful +dictionary of response codes in that shows all the response codes used +by RFC 2616. The dictionary is reproduced here for convenience :: # Table mapping response codes to messages; entries have the # form {code: (shortmessage, longmessage)}. - httpresponses = { + responses = { 100: ('Continue', 'Request received, please continue'), 101: ('Switching Protocols', 'Switching to new protocol; obey Upgrade header'), @@ -143,78 +242,72 @@ 201: ('Created', 'Document created, URL follows'), 202: ('Accepted', 'Request accepted, processing continues off-line'), - 203: ('Non-Authoritative Information', - 'Request fulfilled from cache'), - 204: ('No response', 'Request fulfilled, nothing follows'), + 203: ('Non-Authoritative Information', 'Request fulfilled from cache'), + 204: ('No Content', 'Request fulfilled, nothing follows'), 205: ('Reset Content', 'Clear input form for further input.'), 206: ('Partial Content', 'Partial content follows.'), 300: ('Multiple Choices', 'Object has several resources -- see URI list'), - 301: ('Moved Permanently', - 'Object moved permanently -- see URI list'), + 301: ('Moved Permanently', 'Object moved permanently -- see URI list'), 302: ('Found', 'Object moved temporarily -- see URI list'), 303: ('See Other', 'Object moved -- see Method and URL list'), - 304: ('Not modified', + 304: ('Not Modified', 'Document has not changed since given time'), 305: ('Use Proxy', - 'You must use proxy specified in Location' - ' to access this resource.'), + 'You must use proxy specified in Location to access this ' + 'resource.'), 307: ('Temporary Redirect', 'Object moved temporarily -- see URI list'), - - 400: ('Bad request', + + 400: ('Bad Request', 'Bad request syntax or unsupported method'), 401: ('Unauthorized', 'No permission -- see authorization schemes'), - 402: ('Payment required', + 402: ('Payment Required', 'No payment -- see charging schemes'), 403: ('Forbidden', 'Request forbidden -- authorization will not help'), 404: ('Not Found', 'Nothing matches the given URI'), 405: ('Method Not Allowed', 'Specified method is invalid for this server.'), - 406: ('Not Acceptable', - 'URI not available in preferred format.'), - 407: ('Proxy Authentication Required', - 'You must authenticate with ' - 'this proxy before proceeding.'), - 408: ('Request Time-out', - 'Request timed out; try again later.'), + 406: ('Not Acceptable', 'URI not available in preferred format.'), + 407: ('Proxy Authentication Required', 'You must authenticate with ' + 'this proxy before proceeding.'), + 408: ('Request Timeout', 'Request timed out; try again later.'), 409: ('Conflict', 'Request conflict.'), 410: ('Gone', 'URI no longer exists and has been permanently removed.'), 411: ('Length Required', 'Client must specify Content-Length.'), - 412: ('Precondition Failed', - 'Precondition in headers is false.'), + 412: ('Precondition Failed', 'Precondition in headers is false.'), 413: ('Request Entity Too Large', 'Entity is too large.'), 414: ('Request-URI Too Long', 'URI is too long.'), - 415: ('Unsupported Media Type', - 'Entity body in unsupported format.'), + 415: ('Unsupported Media Type', 'Entity body in unsupported format.'), 416: ('Requested Range Not Satisfiable', 'Cannot satisfy request range.'), 417: ('Expectation Failed', 'Expect condition could not be satisfied.'), - 500: ('Internal error', 'Server got itself in trouble'), + 500: ('Internal Server Error', 'Server got itself in trouble'), 501: ('Not Implemented', 'Server does not support this operation'), - 502: ('Bad Gateway', - 'Invalid responses from another server/proxy.'), - 503: ('Service temporarily overloaded', - 'The server cannot ' - 'process the request due to a high load'), - 504: ('Gateway timeout', + 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'), + 503: ('Service Unavailable', + 'The server cannot process the request due to a high load'), + 504: ('Gateway Timeout', 'The gateway server did not receive a timely response'), - 505: ('HTTP Version not supported', 'Cannot fulfill request.'), + 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'), } -When an error is raised the server responds by returning an http error code *and* an error page. You can use the ``HTTPError`` instance as a handle on the page returned. This means that as well as the code attribute, it also has read, geturl, and info, methods. :: +When an error is raised the server responds by returning an HTTP error +code *and* an error page. You can use the ``HTTPError`` instance as a +response on the page returned. This means that as well as the code +attribute, it also has read, geturl, and info, methods. :: >>> req = urllib2.Request('http://www.python.org/fish.html') >>> try: >>> urllib2.urlopen(req) - >>> except IOError, e: + >>> except URLError, e: >>> print e.code >>> print e.read() >>> @@ -229,8 +322,8 @@ Wrapping it Up -------------- -So if you want to be prepared for ``HTTPError`` *or* ``URLError`` there are two -basic approaches. I prefer the second approach. +So if you want to be prepared for ``HTTPError`` *or* ``URLError`` +there are two basic approaches. I prefer the second approach. Number 1 ~~~~~~~~ @@ -241,7 +334,7 @@ from urllib2 import Request, urlopen, URLError, HTTPError req = Request(someurl) try: - handle = urlopen(req) + response = urlopen(req) except HTTPError, e: print 'The server couldn\'t fulfill the request.' print 'Error code: ', e.code @@ -254,7 +347,8 @@ .. note:: - The ``except HTTPError`` *must* come first, otherwise ``except URLError`` will *also* catch an ``HTTPError``. + The ``except HTTPError`` *must* come first, otherwise ``except URLError`` + will *also* catch an ``HTTPError``. Number 2 ~~~~~~~~ @@ -264,8 +358,8 @@ from urllib2 import Request, urlopen req = Request(someurl) try: - handle = urlopen(req) - except IOError, e: + response = urlopen(req) + except URLError, e: if hasattr(e, 'reason'): print 'We failed to reach a server.' print 'Reason: ', e.reason @@ -279,110 +373,180 @@ info and geturl =============== -The handle returned by urlopen (or the ``HTTPError`` instance) has two useful methods ``info`` and ``geturl``. - -**geturl** - this returns the real url of the page fetched. This is useful because ``urlopen`` (or the openener object used) may have followed a redirect. The url of the page fetched may not be the same as the url requested. - -**info** - this returns a dictionary like object that describes the page fetched, particularly the headers sent by the server. It is actually an ``httplib.HTTPMessage`` instance. In versions of Python prior to 2.3.4 it wasn't safe to iterate over the object directly, so you should iterate over the list returned by ``msg.keys()`` instead. +The response returned by urlopen (or the ``HTTPError`` instance) has +two useful methods ``info`` and ``geturl``. -Typical headers include 'content-length', 'content-type', and so on. See the `Quick Reference to HTTP Headers`_ for a useful reference on the different sort of headers. +**geturl** - this returns the real URL of the page fetched. This is +useful because ``urlopen`` (or the opener object used) may have +followed a redirect. The URL of the page fetched may not be the same +as the URL requested. + +**info** - this returns a dictionary-like object that describes the +page fetched, particularly the headers sent by the server. It is +currently an ``httplib.HTTPMessage`` instance. + +Typical headers include 'Content-length', 'Content-type', and so +on. See the `Quick Reference to HTTP Headers`_ for a useful listing of +HTTP headers with brief explanations of their meaning and use. Openers and Handlers ==================== -Openers and handlers are slightly esoteric parts of **urllib2**. When you fetch a URL you use an opener. Normally we have been using the default opener - via ``urlopen`` - but you can create custom openers. Openers use handlers. - -``build_opener`` is used to create ``opener`` objects - for fetching URLs with specific handlers installed. Handlers can handle cookies, authentication, and other common but slightly specialised situations. Opener objects have an ``open`` method, which can be called directly to fetch urls in the same way as the ``urlopen`` function. - -``install_opener`` can be used to make an ``opener`` object the default opener. This means that calls to ``urlopen`` will use the opener you have installed. +When you fetch a URL you use an opener (an instance of the perhaps +confusingly-named urllib2.OpenerDirector). Normally we have been using +the default opener - via ``urlopen`` - but you can create custom +openers. Openers use handlers. All the "heavy lifting" is done by the +handlers. Each handler knows how to open URLs for a particular URL +scheme (http, ftp, etc.), or how to handle an aspect of URL opening, +for example HTTP redirections or HTTP cookies. + +You will want to create openers if you want to fetch URLs with +specific handlers installed, for example to get an opener that handles +cookies, or to get an opener that does not handle redirections. + +To create an opener, instantiate an OpenerDirector, and then call +.add_handler(some_handler_instance) repeatedly. + +Alternatively, you can use ``build_opener``, which is a convenience +function for creating opener objects with a single function call. +``build_opener`` adds several handlers by default, but provides a +quick way to add more and/or override the default handlers. + +Other sorts of handlers you might want to can handle proxies, +authentication, and other common but slightly specialised +situations. + +``install_opener`` can be used to make an ``opener`` object the +(global) default opener. This means that calls to ``urlopen`` will use +the opener you have installed. + +Opener objects have an ``open`` method, which can be called directly +to fetch urls in the same way as the ``urlopen`` function: there's no +need to call ``install_opener``, except as a convenience. Basic Authentication ==================== -To illustrate creating and installing a handler we will use the ``HTTPBasicAuthHandler``. For a more detailed discussion of this subject - including an explanation of how Basic Authentication works - see the `Basic Authentication Tutorial`_. - -When authentication is required, the server sends a header (as well as the 401 error code) requesting authentication. This specifies the authentication scheme and a 'realm'. The header looks like : ``www-authenticate: SCHEME realm="REALM"``. +To illustrate creating and installing a handler we will use the +``HTTPBasicAuthHandler``. For a more detailed discussion of this +subject - including an explanation of how Basic Authentication works - +see the `Basic Authentication Tutorial`_. + +When authentication is required, the server sends a header (as well as +the 401 error code) requesting authentication. This specifies the +authentication scheme and a 'realm'. The header looks like : +``Www-authenticate: SCHEME realm="REALM"``. e.g. :: - www-authenticate: Basic realm="cPanel" + Www-authenticate: Basic realm="cPanel Users" -The client should then retry the request with the appropriate name and password for the realm included as a header in the request. This is 'basic authentication'. In order to simplify this process we can create an instance of ``HTTPBasicAuthHandler`` and an opener to use this handler. +The client should then retry the request with the appropriate name and +password for the realm included as a header in the request. This is +'basic authentication'. In order to simplify this process we can +create an instance of ``HTTPBasicAuthHandler`` and an opener to use +this handler. + +The ``HTTPBasicAuthHandler`` uses an object called a password manager +to handle the mapping of URLs and realms to passwords and +usernames. If you know what the realm is (from the authentication +header sent by the server), then you can use a +``HTTPPasswordMgr``. Frequently one doesn't care what the realm is. In +that case, it is convenient to use +``HTTPPasswordMgrWithDefaultRealm``. This allows you to specify a +default username and password for a URL. This will be supplied in the +absence of yoou providing an alternative combination for a specific +realm. We indicate this by providing ``None`` as the realm argument to +the ``add_password`` method. -The ``HTTPBasicAuthHandler`` uses an object called a password manager to handle the mapping of URIs and realms to passwords and usernames. If you know what the realm is (from the authentication header sent by the server), then you can use a ``HTTPPasswordMgr``. Generally there is only one realm per URI, so it is possible to use ``HTTPPasswordMgrWithDefaultRealm``. This allows you to specify a default username and password for a URI. This will be supplied in the absence of yoou providing an alternative combination for a specific realm. We signify this by providing ``None`` as the realm argument to the ``add_password`` method. +The top-level URL is the first URL that requires authentication. URLs +"deeper" than the URL you pass to .add_password() will also match. :: -The toplevelurl is the first url that requires authentication. This is usually a 'super-url' of any others in the same realm. :: - - password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() # create a password manager - - password_mgr.add_password(None, - top_level_url, username, password) - # add the username and password - # if we knew the realm, we could - # use it instead of ``None`` - + password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() + + # Add the username and password. + # If we knew the realm, we could use it instead of ``None``. + top_level_url = "http://example.com/foo/" + password_mgr.add_password(None, top_level_url, username, password) + handler = urllib2.HTTPBasicAuthHandler(password_mgr) - # create the handler - + + # create "opener" (OpenerDirector instance) opener = urllib2.build_opener(handler) - # from handler to opener - opener.open(a_url) # use the opener to fetch a URL + opener.open(a_url) + # Install the opener. + # Now all calls to urllib2.urlopen use our opener. urllib2.install_opener(opener) - # install the opener - # now all calls to urllib2.urlopen use our opener .. note:: - In the above example we only supplied our ``HHTPBasicAuthHandler`` to ``build_opener``. By default openers have the handlers for normal situations - ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``, ``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``, ``FileHandler``, ``HTTPErrorProcessor``. The only reason to explicitly supply these to ``build_opener`` (which chains handlers provided as a list), would be to change the order they appear in the chain. - -One thing not to get bitten by is that the ``top_level_url`` in the code above *must not* contain the protocol - the ``http://`` part. So if the URL we are trying to access is ``http://www.someserver.com/path/page.html``, then we set : :: - - top_level_url = "www.someserver.com/path/page.html" - # *no* http:// !! - -It took me a long time to track that down the first time I tried to use handlers. + In the above example we only supplied our ``HHTPBasicAuthHandler`` + to ``build_opener``. By default openers have the handlers for + normal situations - ``ProxyHandler``, ``UnknownHandler``, + ``HTTPHandler``, ``HTTPDefaultErrorHandler``, + ``HTTPRedirectHandler``, ``FTPHandler``, ``FileHandler``, + ``HTTPErrorProcessor``. + +top_level_url is in fact *either* a full URL (including the 'http:' +scheme component and the hostname and optionally the port number) +e.g. "http://example.com/" *or* an "authority" (i.e. the hostname, +optionally including the port number) e.g. "example.com" or +"example.com:8080" (the latter example includes a port number). The +authority, if present, must NOT contain the "userinfo" component - for +example "joe at password:example.com" is not correct. Proxies ======= -**urllib2** will auto-detect your proxy settings and use those. This is through the ``ProxyHandler`` which is part of the normal handler chain. Normally that's a good thing, but there are occasions when it may not be helpful [#]_. In order to do this we need to setup our own ``ProxyHandler``, with no proxies defined. This is done using similar steps to setting up a `Basic Authentication`_ handler : :: +**urllib2** will auto-detect your proxy settings and use those. This +is through the ``ProxyHandler`` which is part of the normal handler +chain. Normally that's a good thing, but there are occasions when it +may not be helpful [#]_. One way to do this is to setup our own +``ProxyHandler``, with no proxies defined. This is done using similar +steps to setting up a `Basic Authentication`_ handler : :: >>> proxy_support = urllib2.ProxyHandler({}) >>> opener = urllib2.build_opener(proxy_support) >>> urllib2.install_opener(opener) -.. caution:: +.. note:: - Currently ``urllib2`` *does not* support fetching of ``https`` locations through - a proxy. This can be a problem. + Currently ``urllib2`` *does not* support fetching of ``https`` + locations through a proxy. This can be a problem. Sockets and Layers ================== -The Python support for fetching resources from the web is layered. urllib2 uses the httplib library, which in turn uses the socket library. - -As of Python 2.3 you can specify how long a socket should wait for a response before timing out. This can be useful in applications which have to fetch web pages. By default the socket module has *no timeout* and can hang. To set the timeout use : :: +The Python support for fetching resources from the web is +layered. urllib2 uses the httplib library, which in turn uses the +socket library. + +As of Python 2.3 you can specify how long a socket should wait for a +response before timing out. This can be useful in applications which +have to fetch web pages. By default the socket module has *no timeout* +and can hang. Currently, the socket timeout is not exposed at the +httplib or urllib2 levels. However, you can set the default timeout +globally for all sockets using : :: import socket import urllib2 - - timeout = 10 + # timeout in seconds + timeout = 10 socket.setdefaulttimeout(timeout) + # this call to urllib2.urlopen now uses the default timeout + # we have set in the socket module req = urllib2.Request('http://www.voidspace.org.uk') - handle = urllib2.urlopen(req) - # this call to urllib2.urlopen - # now uses the default timeout - # we have set in the socket module + response = urllib2.urlopen(req) ------- @@ -391,8 +555,8 @@ Footnotes =========== -.. [#] Possibly some of this tutorial will make it into the standard library docs for versions of Python after 2.4.1. -.. [#] You *can* fetch URLs directly with urlopen, without using a request object. It's more explicit, and therefore more Pythonic, to use ``urllib2.Request`` though. It also makes it easier to add headers to your request. +This document was reviewed and revised by John Lee. + .. [#] For an introduction to the CGI protocol see `Writing Web Applications in Python`_. .. [#] Like Google for example. The *proper* way to use google from a program is to use PyGoogle_ of course. See `Voidspace Google`_ for some examples of using the Google API. .. [#] Browser sniffing is a very bad practise for website design - building sites using web standards is much more sensible. Unfortunately a lot of sites still send different versions to different browsers. @@ -403,8 +567,9 @@ .. _Python: http://www.python.org .. _urllib2 docs: http://docs.python.org/lib/module-urllib2.html +.. _HTML Specification, Form Submission: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13 .. _Quick Reference to HTTP Headers: http://www.cs.tut.fi/~jkorpela/http.html .. _PyGoogle: http://pygoogle.sourceforge.net .. _Voidspace Google: http://www.voidspace.org.uk/python/recipebook.shtml#google .. _Writing Web Applications in Python: http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html -.. _Basic Authentication Tutorial: http://www.voidspace.org.uk/python/articles/authentication.shtml \ No newline at end of file +.. _Basic Authentication Tutorial: http://www.voidspace.org.uk/python/articles/authentication.shtml From python-checkins at python.org Sun May 7 19:14:53 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sun, 7 May 2006 19:14:53 +0200 (CEST) Subject: [Python-checkins] r45932 - python/trunk/Doc/lib/libmailbox.tex Message-ID: <20060507171453.B1DDB1E400A@bag.python.org> Author: andrew.kuchling Date: Sun May 7 19:14:53 2006 New Revision: 45932 Modified: python/trunk/Doc/lib/libmailbox.tex Log: Minor language edit Modified: python/trunk/Doc/lib/libmailbox.tex ============================================================================== --- python/trunk/Doc/lib/libmailbox.tex (original) +++ python/trunk/Doc/lib/libmailbox.tex Sun May 7 19:14:53 2006 @@ -230,7 +230,7 @@ create=True}}} A subclass of \class{Mailbox} for mailboxes in Maildir format. Parameter \var{factory} is a callable object that accepts a file-like message -representation (which behaves as if open in binary mode) and returns a custom +representation (which behaves as if opened in binary mode) and returns a custom representation. If \var{factory} is \code{None}, \class{MaildirMessage} is used as the default message representation. If \var{create} is \code{True}, the mailbox is created if it does not exist. @@ -356,7 +356,7 @@ \begin{classdesc}{mbox}{path\optional{, factory=None\optional{, create=True}}} A subclass of \class{Mailbox} for mailboxes in mbox format. Parameter \var{factory} is a callable object that accepts a file-like message -representation (which behaves as if open in binary mode) and returns a custom +representation (which behaves as if opened in binary mode) and returns a custom representation. If \var{factory} is \code{None}, \class{mboxMessage} is used as the default message representation. If \var{create} is \code{True}, the mailbox is created if it does not exist. @@ -409,7 +409,7 @@ \begin{classdesc}{MH}{path\optional{, factory=None\optional{, create=True}}} A subclass of \class{Mailbox} for mailboxes in MH format. Parameter \var{factory} is a callable object that accepts a file-like message -representation (which behaves as if open in binary mode) and returns a custom +representation (which behaves as if opened in binary mode) and returns a custom representation. If \var{factory} is \code{None}, \class{MHMessage} is used as the default message representation. If \var{create} is \code{True}, the mailbox is created if it does not exist. @@ -516,7 +516,7 @@ \begin{classdesc}{Babyl}{path\optional{, factory=None\optional{, create=True}}} A subclass of \class{Mailbox} for mailboxes in Babyl format. Parameter \var{factory} is a callable object that accepts a file-like message -representation (which behaves as if open in binary mode) and returns a custom +representation (which behaves as if opened in binary mode) and returns a custom representation. If \var{factory} is \code{None}, \class{BabylMessage} is used as the default message representation. If \var{create} is \code{True}, the mailbox is created if it does not exist. @@ -579,7 +579,7 @@ \begin{classdesc}{MMDF}{path\optional{, factory=None\optional{, create=True}}} A subclass of \class{Mailbox} for mailboxes in MMDF format. Parameter \var{factory} is a callable object that accepts a file-like message -representation (which behaves as if open in binary mode) and returns a custom +representation (which behaves as if opened in binary mode) and returns a custom representation. If \var{factory} is \code{None}, \class{MMDFMessage} is used as the default message representation. If \var{create} is \code{True}, the mailbox is created if it does not exist. From buildbot at python.org Sun May 7 19:47:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 07 May 2006 17:47:49 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060507174749.230721E400A@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/378 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Sun May 7 20:01:57 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Sun, 07 May 2006 20:01:57 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445E1E09.1040908@v.loewis.de> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> Message-ID: <445E3615.7000108@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >> That's not what I meant: in errno, many WSA windows error codes >> are aliased to their corresponding Unix error codes to >> enhance portability across platforms. > > Can you please explain how such aliasing could work? errno can > only have one value: either 183, or 17, but not both. Right. The idea used in errno is to let the Windows error code override the value possibly defined in the C lib (that's why the order of the inscode() in errno matters). This is based on: http://msdn.microsoft.com/library/en-us/winsock/winsock/error_codes_errno_h_errno_and_wsagetlasterror_2.asp?frame=true >> I don't know where ERROR_ALREADY_EXISTS is defined and >> how it relates to the WSA codes, but since EEXIST doesn't >> have a corresponding, it's probably a good idea to alias >> EEXIST to ERROR_ALREADY_EXISTS and use that in tempfile.py >> for both Windows and Unix instead of adding another except >> clause. > > ERROR_ALREADY_EXISTS is defined in winerror.h, and it is possible > result of the GetLastError system call. > > I don't understand the fragment "but since EEXIST doesn't have a > corresponding": A corresponding what? Sorry, it should read "corresponding WSA alias", ie. there's no WSAEEXIST, probably because Windows sockets don't support domain sockets. > You mean, I should define EEXIST to have the value of 183, instead > of having the value 17? That's certainly not a good idea. First, > EEXIST should map to either ERROR_FILE_EXISTS (80) or > ERROR_ALREADY_EXISTS (183), depending on context. Furthermore, > the C library will still put its own value (17) into errno. Ah, ok. I didn't know that they use different error values. That makes things complicated. >>> In what sense would the backwards compatibility be improved ?! >> I suppose that the code used to raise an OSError with >> EEXIST error code before the change to use Win32 APIs >> on Windows. > > Correct. It now raises WindowsError instead. > >> With the alias, existing code looking for EEXIST on Windows >> will continue to work without change. > > I still cannot see how this could work, at least not in a way > that wouldn't break something else. Indeed. Perhaps we should have hybrid error code objects that compare equal to more than one integer code, but otherwise behave like integers ?! E.g. # Error code objects class ErrorCode(int): values = () def __new__(cls, basevalue, *aliasvalues): return int.__new__(cls, basevalue) def __init__(self, basevalue, *aliasvalues): self.values = (basevalue,) + aliasvalues def __cmp__(self, other): if other in self.values: return 0 if other < self.values: return 1 else: return -1 EEXISTS = ErrorCode(17, 183, 80) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 07 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From martin at v.loewis.de Sun May 7 20:58:04 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 07 May 2006 20:58:04 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445E3615.7000108@egenix.com> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> Message-ID: <445E433C.10908@v.loewis.de> M.-A. Lemburg wrote: > Right. The idea used in errno is to let the Windows > error code override the value possibly defined in the > C lib (that's why the order of the inscode() in errno > matters). This is based on: > > http://msdn.microsoft.com/library/en-us/winsock/winsock/error_codes_errno_h_errno_and_wsagetlasterror_2.asp?frame=true You mean, "The idea used in WSA"? If I understand this correctly, the idea is to define #define errno WSAGetLastError() (the article actually defines that as "WSAGetLastError", but that is wrong, as WSAGetLastError is a function, and errno is not) I can't see how it would help to define such a macro. We are talking about Python code here, not C code. Can you please provide a specific patch implementing your proposal? I don't get the idea. > Perhaps we should have hybrid error code objects that compare > equal to more than one integer code, but otherwise behave like > integers ?! That would be very hacky. One thing I could imagine implementing is to put two values into WindowsError: - errno, with possible values from errno.h (which Microsoft calls "DOS error codes") - winerror, with possible values from winerror.h. That way, on creating a directory that already exists, you would get a WindowsError with errno==EEXIST (17) and winerror==ERROR_ALREADY_EXISTS (183). That would make my recent library changes unnecessary, and also not require changes to applications that currently check OSError.errno. It would have two problems: - somebody would have to provide the mapping table from Win32 error codes to "DOS error codes". Microsoft has that in the function _dosmaperr, however, that function is not exported from the CRT. - code that currently catches WindowsError and looks into the errno value would break, as that would not contain Win32 error codes anymore. Regards, Martin From python-checkins at python.org Sun May 7 22:44:35 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 7 May 2006 22:44:35 +0200 (CEST) Subject: [Python-checkins] r45934 - python/trunk/Lib/cookielib.py Message-ID: <20060507204435.3D3A01E400A@bag.python.org> Author: georg.brandl Date: Sun May 7 22:44:34 2006 New Revision: 45934 Modified: python/trunk/Lib/cookielib.py Log: Patch #1483395: add new TLDs to cookielib Modified: python/trunk/Lib/cookielib.py ============================================================================== --- python/trunk/Lib/cookielib.py (original) +++ python/trunk/Lib/cookielib.py Sun May 7 22:44:34 2006 @@ -974,15 +974,18 @@ req_host, erhn = eff_request_host(request) domain = cookie.domain if self.strict_domain and (domain.count(".") >= 2): + # XXX This should probably be compared with the Konqueror + # (kcookiejar.cpp) and Mozilla implementations, but it's a + # losing battle. i = domain.rfind(".") j = domain.rfind(".", 0, i) if j == 0: # domain like .foo.bar tld = domain[i+1:] sld = domain[j+1:i] - if (sld.lower() in ( - "co", "ac", - "com", "edu", "org", "net", "gov", "mil", "int") and - len(tld) == 2): + if sld.lower() in ("co", "ac", "com", "edu", "org", "net", + "gov", "mil", "int", "aero", "biz", "cat", "coop", + "info", "jobs", "mobi", "museum", "name", "pro", + "travel", "eu") and len(tld) == 2: # domain like .co.uk debug(" country-code second level domain %s", domain) return False From python-checkins at python.org Mon May 8 04:20:02 2006 From: python-checkins at python.org (steven.bethard) Date: Mon, 8 May 2006 04:20:02 +0200 (CEST) Subject: [Python-checkins] r45935 - peps/trunk/pep-0359.txt peps/trunk/pep-3002.txt Message-ID: <20060508022002.E32791E4003@bag.python.org> Author: steven.bethard Date: Mon May 8 04:20:01 2006 New Revision: 45935 Modified: peps/trunk/pep-0359.txt peps/trunk/pep-3002.txt Log: PEP 359 withdrawn at Guido's request. PEP 3002 to require that all backwards incompatible changes be accompanied by a patch to Python 2.X that issues appropriate warnings when --python3 is specified. Modified: peps/trunk/pep-0359.txt ============================================================================== --- peps/trunk/pep-0359.txt (original) +++ peps/trunk/pep-0359.txt Mon May 8 04:20:01 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Steven Bethard -Status: Draft +Status: Withdrawn Type: Standards Track Content-Type: text/x-rst Created: 05-Apr-2006 @@ -43,6 +43,15 @@ python-dev list. +Withdrawal Notice +================= + +This PEP was withdrawn at Guido's request [2]_. Guido didn't like it, +and in particular didn't like how the property use-case puts the +instance methods of a property at a different level than other +instance methods and requires fixed names for the property functions. + + Motivation ========== @@ -170,7 +179,7 @@ Since descriptors are used to customize access to an attribute, it's often useful to know the name of that attribute. Current Python doesn't give an easy way to find this name and so a lot of custom -descriptors, like Ian Bicking's setonce descriptor [2]_, have to hack +descriptors, like Ian Bicking's setonce descriptor [3]_, have to hack around this somehow. With the make-statement, you could create a ``setonce`` attribute like:: @@ -227,7 +236,7 @@ ... x = property(get_x, set_x, "the x of the frobulation") -This issue has been brought up before, and Guido [3]_ and others [4]_ +This issue has been brought up before, and Guido [4]_ and others [5]_ have briefly mused over alternate property syntaxes to make declaring properties easier. With the make-statement, the following syntax could be supported:: @@ -255,7 +264,7 @@ Example: interfaces ------------------- -Guido [5]_ and others have occasionally suggested introducing +Guido [6]_ and others have occasionally suggested introducing interfaces into python. Most suggestions have offered syntax along the lines of:: @@ -304,7 +313,7 @@ The ```` expression is optional; if not present, an empty tuple will be assumed. -A patch is available implementing these semantics [6]_. +A patch is available implementing these semantics [7]_. The make-statement introduces a new keyword, ``make``. Thus in Python 2.6, the make-statement will have to be enabled using ``from @@ -319,8 +328,8 @@ Does the ``make`` keyword break too much code? Originally, the make statement used the keyword ``create`` (a suggestion due to Nick -Coghlan). However, investigations into the standard library [7]_ and -Zope+Plone code [8]_ revealed that ``create`` would break a lot more +Coghlan). However, investigations into the standard library [8]_ and +Zope+Plone code [9]_ revealed that ``create`` would break a lot more code, so ``make`` was adopted as the keyword instead. However, there are still a few instances where ``make`` would break code. Is there a better keyword for the statement? @@ -464,7 +473,7 @@ And if the repetition of the element names here is too much of a DRY violoation, it is also possible to eliminate all as-clauses except for -the first by adding a few methods to Element. [9]_ +the first by adding a few methods to Element. [10]_ So are there real use-cases for executing the block in a dict of a different type? And if so, should the make-statement be extended to @@ -530,28 +539,31 @@ .. [1] Michele Simionato's original suggestion (http://mail.python.org/pipermail/python-dev/2005-October/057435.html) -.. [2] Ian Bicking's setonce descriptor +.. [2] Guido requests withdrawal + (http://mail.python.org/pipermail/python-3000/2006-April/000936.html) + +.. [3] Ian Bicking's setonce descriptor (http://blog.ianbicking.org/easy-readonly-attributes.html) -.. [3] Guido ponders property syntax +.. [4] Guido ponders property syntax (http://mail.python.org/pipermail/python-dev/2005-October/057404.html) -.. [4] Namespace-based property recipe +.. [5] Namespace-based property recipe (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442418) -.. [5] Python interfaces +.. [6] Python interfaces (http://www.artima.com/weblogs/viewpost.jsp?thread=86641) -.. [6] Make Statement patch +.. [7] Make Statement patch (http://ucsu.colorado.edu/~bethard/py/make_statement.patch) -.. [7] Instances of create in the stdlib +.. [8] Instances of create in the stdlib (http://mail.python.org/pipermail/python-list/2006-April/335159.html) -.. [8] Instances of create in Zope+Plone +.. [9] Instances of create in Zope+Plone (http://mail.python.org/pipermail/python-list/2006-April/335284.html) -.. [9] Eliminate as-clauses in with-statement XML +.. [10] Eliminate as-clauses in with-statement XML (http://mail.python.org/pipermail/python-list/2006-April/336774.html) Modified: peps/trunk/pep-3002.txt ============================================================================== --- peps/trunk/pep-3002.txt (original) +++ peps/trunk/pep-3002.txt Mon May 8 04:20:01 2006 @@ -86,60 +86,25 @@ ============================ In addition to the PEP requirement, backwards incompatible changes to -Python must also be accompanied by code that can identify pieces of -Python 2.X code that may be problematic in Python 3.0. - -This PEP proposes to house this code in tools/scripts/python3warn.py. -Thus PEPs for backwards incompatible changes should include a patch to -this file that produces the appropriate warnings. Code in -python3warn.py should be written to the latest version of Python 2.X -(not Python 3000) so that Python 2.X users will be able to run the -program without having Python 3000 installed. - -Currently, it seems too stringent to require that the code in -python3warn.py identify all changes perfectly. Thus it is permissable -if a backwards-incompatible PEP's python3warn.py code produces a -number of false-positives (warning that a piece of code might be -invalid in Python 3000 when it's actually still okay). However, -false-negatives (not issuing a warning for code that will do the -wrong thing in Python 3000) should be avoided whenever possible -- -users of python3warn.py should be reasonably confident that they have -been warned about the vast majority of incompatibilities. - -So for example, a PEP proposing that ``dict.items()`` be modified to -return an iterator instead of a list might add code like the following -to python3warn.py:: - - items_in_for = re.compile(r'for\s+\w+\s+in\s+\w+\.items\(\):') - ... - for i, line in enumerate(file_lines): - ... - if '.items()' in line and not items_in_for.search(line): - message = 'dict.items() call may expect list at line %i' - warnings.warn(message % i) - -This would issue a warning any time a ``.items()`` method was called -and not immediately iterated over in a for-loop. Clearly this will -issue a number of false-positive warnings (e.g. ``d2 = -dict(d.items())``), but the number of false-negative warnings should -be relatively low. - - -Optional Extensions -=================== - -Instead of the python3warn.py script, a branch of Python 3000 could be -maintained that added warnings at all the appropriate points in the -code-base. PEPs proposing backwards-incompatible changes would then -provide patches to the Python-3000-warn branch instead of to -python3warn.py. With such a branch, the warnings issued could be -near-perfect and Python users could be confident that their code was -correct Python 3000 code by first running it on the Python-3000-warn -branch and fixing all the warnings. - -At the moment, however, this PEP opts for the weaker measure -(python3warn.py) as it is expected that maintaining a Python-3000-warn -branch will be too much of a time drain. +Python must also be accompanied by code to issue warnings for pieces +of Python 2.X code that will behave differently in Python 3000. Such +warnings will be enabled in Python 2.X using a new command-line +switch: --python3. All backwards incompatible changes should be +accompanied by a patch for Python 2.X that, when --python3 is +specified, issues warnings for each construct that is being changed. + +For example, if ``dict.keys()`` returns an iterator in Python 3000, +the patch to the Python 2.X branch should do something like: + + If --python3 was specified, change ``dict.keys()`` to return a + subclass of ``list`` that issues warnings whenever you use any + methods other than ``__iter__()``. + +Such a patch would mean that warnings are only issued when features +that will not be present in Python 3000 are used, and almost all +existing code should continue to work. (Code that relies on +``dict.keys()`` always returning a ``list`` and not a subclass should +be pretty much non-existent.) References From nnorwitz at gmail.com Mon May 8 05:58:07 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 7 May 2006 20:58:07 -0700 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <20060506163302.CA3D71E4004@bag.python.org> References: <20060506163302.CA3D71E4004@bag.python.org> Message-ID: On 5/6/06, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Sat May 6 18:32:54 2006 > New Revision: 45925 > > Modified: python/trunk/Lib/tempfile.py > ============================================================================== > --- python/trunk/Lib/tempfile.py (original) > +++ python/trunk/Lib/tempfile.py Sat May 6 18:32:54 2006 > @@ -1497,7 +1533,29 @@ > are also valid. */ > PyErr_Clear(); > } > -#endif /* Py_WIN_WIDE_FILENAMES */ > + if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding, > + &path, &i)) > + return NULL; > + Py_BEGIN_ALLOW_THREADS > + attr = GetFileAttributesA(path); > + if (attr != 0xFFFFFFFF) { > + if (i & _S_IWRITE) > + attr &= ~FILE_ATTRIBUTE_READONLY; > + else > + attr |= FILE_ATTRIBUTE_READONLY; > + res = SetFileAttributesA(path, attr); > + } > + else > + res = 0; > + Py_END_ALLOW_THREADS > + if (!res) { > + win32_error("chmod", path); > + PyMem_Free(path); > + return NULL; > + } > + Py_INCREF(Py_None); > + return Py_None; PyMem_Free(path); is needed before returning None to prevent a leak, isn't it? n From python-checkins at python.org Mon May 8 07:25:57 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 8 May 2006 07:25:57 +0200 (CEST) Subject: [Python-checkins] r45936 - python/trunk/Modules/posixmodule.c Message-ID: <20060508052557.D62141E4003@bag.python.org> Author: martin.v.loewis Date: Mon May 8 07:25:56 2006 New Revision: 45936 Modified: python/trunk/Modules/posixmodule.c Log: Add missing PyMem_Free. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Mon May 8 07:25:56 2006 @@ -1553,6 +1553,7 @@ PyMem_Free(path); return NULL; } + PyMem_Free(path); Py_INCREF(Py_None); return Py_None; #else /* Py_WIN_WIDE_FILENAMES */ From martin at v.loewis.de Mon May 8 07:26:31 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 08 May 2006 07:26:31 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: References: <20060506163302.CA3D71E4004@bag.python.org> Message-ID: <445ED687.7080801@v.loewis.de> Neal Norwitz wrote: > PyMem_Free(path); > > is needed before returning None to prevent a leak, isn't it? Thanks for pointing that out; fixed in 45936. Regards, Martin From buildbot at python.org Mon May 8 07:53:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 08 May 2006 05:53:30 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo trunk Message-ID: <20060508055330.83C351E4003@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/740 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From neal at metaslash.com Mon May 8 10:12:15 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 8 May 2006 04:12:15 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060508081215.GA27563@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33703 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421649 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421084 refs] From mal at egenix.com Mon May 8 12:55:57 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 08 May 2006 12:55:57 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445E433C.10908@v.loewis.de> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> <445E433C.10908@v.loewis.de> Message-ID: <445F23BD.5040906@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >> Right. The idea used in errno is to let the Windows >> error code override the value possibly defined in the >> C lib (that's why the order of the inscode() in errno >> matters). This is based on: >> >> http://msdn.microsoft.com/library/en-us/winsock/winsock/error_codes_errno_h_errno_and_wsagetlasterror_2.asp?frame=true > > You mean, "The idea used in WSA"? No, the idea used in errno. A long while ago, we added the WSA error codes and aliased them to the standard BSD errno value constants as suggested in the above document. > If I understand this correctly, the idea is to define > > #define errno WSAGetLastError() > > (the article actually defines that as "WSAGetLastError", > but that is wrong, as WSAGetLastError is a function, and > errno is not) > > I can't see how it would help to define such a macro. > We are talking about Python code here, not C code. No, this is not what I meant. We should continue to use WSAGetLastError() explicitly and only for socket related code. > Can you please provide a specific patch implementing > your proposal? I don't get the idea. It's just a misunderstanding. The code is already there in the errno module. >> Perhaps we should have hybrid error code objects that compare >> equal to more than one integer code, but otherwise behave like >> integers ?! > > That would be very hacky. Not really: you often have the situation where you would like to match a set of values rather than just one value. Of course, the clean approach would be to use tuples and __contains__. Maybe we should have a separate errorcode module that implements error categories rather than just plain errno values. > One thing I could imagine implementing > is to put two values into WindowsError: > - errno, with possible values from errno.h (which Microsoft > calls "DOS error codes") > - winerror, with possible values from winerror.h. > > That way, on creating a directory that already exists, you > would get a WindowsError with errno==EEXIST (17) and > winerror==ERROR_ALREADY_EXISTS (183). > > That would make my recent library changes unnecessary, and also > not require changes to applications that currently check > OSError.errno. Sounds like a plan. >It would have two problems: > - somebody would have to provide the mapping table from > Win32 error codes to "DOS error codes". Microsoft has > that in the function _dosmaperr, however, that function > is not exported from the CRT. I don't understand this part. Couldn't we write a small tool that extracts the mapping from the Windows APIs ? Or just use this mapping from ReactOS which was probably created by doing just that: http://www.reactos.org/generated/doxygen/de/d02/doserrmap_8h-source.html > - code that currently catches WindowsError and looks into > the errno value would break, as that would not contain > Win32 error codes anymore. I don't think that there is any such code, since the APIs you changed used to raise OSErrors. What I'm after is that code relying on the usage of OSError will continue to work and at the same time improve the portability of code using e.g. os.mkdir(). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 08 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Mon May 8 18:11:40 2006 From: python-checkins at python.org (george.yoshida) Date: Mon, 8 May 2006 18:11:40 +0200 (CEST) Subject: [Python-checkins] r45937 - peps/trunk/pep-0352.txt Message-ID: <20060508161140.95DA51E400B@bag.python.org> Author: george.yoshida Date: Mon May 8 18:11:39 2006 New Revision: 45937 Modified: peps/trunk/pep-0352.txt Log: Typo fixes Modified: peps/trunk/pep-0352.txt ============================================================================== --- peps/trunk/pep-0352.txt (original) +++ peps/trunk/pep-0352.txt Mon May 8 18:11:39 2006 @@ -40,7 +40,7 @@ from Exception. This is a problem since this includes two exceptions (KeyboardInterrupt and SystemExit) that often need to be excepted from the application's exception handling: the default behavior of shutting -the interpreter down with resp. without a traceback is usually more +the interpreter down with resp. Without a traceback is usually more desirable than whatever the application might do (with the possible exception of applications that emulate Python's interactive command loop with ``>>>`` prompt). Changing it so that these two exceptions @@ -94,7 +94,7 @@ with the exception that goes beyond the location of the exception within the exception hierarchy and the exception's type. -No restriction is placed upon what may be passed in for ``messsage``. +No restriction is placed upon what may be passed in for ``message``. This provides backwards-compatibility with how the arguments passed into Exception have no restrictions. @@ -148,7 +148,7 @@ Doing this makes catching Exception more reasonable. It would catch only exceptions that signify errors. Exceptions that signal that the -intepreter should exit will not be caught and thus be allowed to +interpreter should exit will not be caught and thus be allowed to propagate up and allow the interpreter to terminate. KeyboardInterrupt has been moved since users typically expect an From python-checkins at python.org Mon May 8 19:28:48 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 8 May 2006 19:28:48 +0200 (CEST) Subject: [Python-checkins] r45938 - python/trunk/Lib/test/test_cookielib.py Message-ID: <20060508172848.281531E400C@bag.python.org> Author: georg.brandl Date: Mon May 8 19:28:47 2006 New Revision: 45938 Modified: python/trunk/Lib/test/test_cookielib.py Log: Add test for rev. 45934. Modified: python/trunk/Lib/test/test_cookielib.py ============================================================================== --- python/trunk/Lib/test/test_cookielib.py (original) +++ python/trunk/Lib/test/test_cookielib.py Mon May 8 19:28:47 2006 @@ -695,6 +695,22 @@ 'foo=bar; domain=friendly.org; Version="1"') self.assertEquals(len(c), 0) + def test_strict_domain(self): + # Cookies whose domain is a country-code tld like .co.uk should + # not be set if CookiePolicy.strict_domain is true. + from cookielib import CookieJar, DefaultCookiePolicy + + cp = DefaultCookiePolicy(strict_domain=True) + cj = CookieJar(policy=cp) + interact_netscape(cj, "http://example.co.uk/", 'no=problemo') + interact_netscape(cj, "http://example.co.uk/", + 'okey=dokey; Domain=.example.co.uk') + self.assertEquals(len(cj), 2) + for pseudo_tld in [".co.uk", ".org.za", ".tx.us", ".name.us"]: + interact_netscape(cj, "http://example.%s/" % pseudo_tld, + 'spam=eggs; Domain=.co.uk') + self.assertEquals(len(cj), 2) + def test_two_component_domain_ns(self): # Netscape: .www.bar.com, www.bar.com, .bar.com, bar.com, no domain # should all get accepted, as should .acme.com, acme.com and no domain From python-checkins at python.org Mon May 8 19:36:09 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 8 May 2006 19:36:09 +0200 (CEST) Subject: [Python-checkins] r45939 - in python/trunk/Lib: test/test_urllib2.py urllib2.py Message-ID: <20060508173609.228CE1E400C@bag.python.org> Author: georg.brandl Date: Mon May 8 19:36:08 2006 New Revision: 45939 Modified: python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/urllib2.py Log: Patch #1479302: Make urllib2 digest auth and basic auth play together. Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Mon May 8 19:36:08 2006 @@ -779,6 +779,27 @@ "proxy.example.com:3128", ) + def test_basic_and_digest_auth_handlers(self): + # HTTPDigestAuthHandler threw an exception if it couldn't handle a 40* + # response (http://python.org/sf/1479302), where it should instead + # return None to allow another handler (especially + # HTTPBasicAuthHandler) to handle the response. + class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler): + handler_order = 400 # strictly before HTTPBasicAuthHandler + opener = OpenerDirector() + password_manager = MockPasswordManager() + digest_handler = TestDigestAuthHandler(password_manager) + basic_handler = urllib2.HTTPBasicAuthHandler(password_manager) + opener.add_handler(digest_handler) + realm = "ACME Networks" + http_handler = MockHTTPHandler( + 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) + self._test_basic_auth(opener, basic_handler, "Authorization", + realm, http_handler, password_manager, + "http://acme.example.com/protected", + "http://acme.example.com/protected", + ) + def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Mon May 8 19:36:08 2006 @@ -846,9 +846,6 @@ scheme = authreq.split()[0] if scheme.lower() == 'digest': return self.retry_http_digest_auth(req, authreq) - else: - raise ValueError("AbstractDigestAuthHandler doesn't know " - "about %s"%(scheme)) def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1) From python-checkins at python.org Mon May 8 19:48:02 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 8 May 2006 19:48:02 +0200 (CEST) Subject: [Python-checkins] r45940 - python/trunk/Lib/_LWPCookieJar.py python/trunk/Lib/_MozillaCookieJar.py python/trunk/Lib/cookielib.py Message-ID: <20060508174802.18D7B1E400C@bag.python.org> Author: georg.brandl Date: Mon May 8 19:48:01 2006 New Revision: 45940 Modified: python/trunk/Lib/_LWPCookieJar.py python/trunk/Lib/_MozillaCookieJar.py python/trunk/Lib/cookielib.py Log: Patch #1478993: take advantage of BaseException/Exception split in cookielib Modified: python/trunk/Lib/_LWPCookieJar.py ============================================================================== --- python/trunk/Lib/_LWPCookieJar.py (original) +++ python/trunk/Lib/_LWPCookieJar.py Mon May 8 19:48:01 2006 @@ -12,9 +12,10 @@ """ import time, re, logging -from cookielib import (reraise_unmasked_exceptions, FileCookieJar, LoadError, - Cookie, MISSING_FILENAME_TEXT, join_header_words, split_header_words, - iso2time, time2isoz) +from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError, + Cookie, MISSING_FILENAME_TEXT, + join_header_words, split_header_words, + iso2time, time2isoz) def lwp_cookie_str(cookie): """Return string representation of Cookie in an the LWP cookie file format. @@ -92,7 +93,8 @@ def _really_load(self, f, filename, ignore_discard, ignore_expires): magic = f.readline() if not re.search(self.magic_re, magic): - msg = "%s does not seem to contain cookies" % filename + msg = ("%r does not look like a Set-Cookie3 (LWP) format " + "file" % filename) raise LoadError(msg) now = time.time() @@ -159,6 +161,10 @@ if not ignore_expires and c.is_expired(now): continue self.set_cookie(c) - except: - reraise_unmasked_exceptions((IOError,)) - raise LoadError("invalid Set-Cookie3 format file %s" % filename) + + except IOError: + raise + except Exception: + _warn_unhandled_exception() + raise LoadError("invalid Set-Cookie3 format file %r: %r" % + (filename, line)) Modified: python/trunk/Lib/_MozillaCookieJar.py ============================================================================== --- python/trunk/Lib/_MozillaCookieJar.py (original) +++ python/trunk/Lib/_MozillaCookieJar.py Mon May 8 19:48:01 2006 @@ -2,8 +2,8 @@ import re, time, logging -from cookielib import (reraise_unmasked_exceptions, FileCookieJar, LoadError, - Cookie, MISSING_FILENAME_TEXT) +from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError, + Cookie, MISSING_FILENAME_TEXT) class MozillaCookieJar(FileCookieJar): """ @@ -51,7 +51,7 @@ if not re.search(self.magic_re, magic): f.close() raise LoadError( - "%s does not look like a Netscape format cookies file" % + "%r does not look like a Netscape format cookies file" % filename) try: @@ -104,9 +104,11 @@ continue self.set_cookie(c) - except: - reraise_unmasked_exceptions((IOError,)) - raise LoadError("invalid Netscape format file %s: %s" % + except IOError: + raise + except Exception: + _warn_unhandled_exception() + raise LoadError("invalid Netscape format cookies file %r: %r" % (filename, line)) def save(self, filename=None, ignore_discard=False, ignore_expires=False): Modified: python/trunk/Lib/cookielib.py ============================================================================== --- python/trunk/Lib/cookielib.py (original) +++ python/trunk/Lib/cookielib.py Mon May 8 19:48:01 2006 @@ -7,9 +7,9 @@ attributes of the HTTP cookie system as cookie-attributes, to distinguish them clearly from Python attributes. -Class diagram (note that the classes which do not derive from -FileCookieJar are not distributed with the Python standard library, but -are available from http://wwwsearch.sf.net/): +Class diagram (note that BSDDBCookieJar and the MSIE* classes are not +distributed with the Python standard library, but are available from +http://wwwsearch.sf.net/): CookieJar____ / \ \ @@ -25,7 +25,10 @@ """ -import sys, re, urlparse, copy, time, urllib, logging +__all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy', + 'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar'] + +import re, urlparse, copy, time, urllib, logging try: import threading as _threading except ImportError: @@ -39,15 +42,10 @@ MISSING_FILENAME_TEXT = ("a filename was not supplied (nor was the CookieJar " "instance initialised with one)") -def reraise_unmasked_exceptions(unmasked=()): +def _warn_unhandled_exception(): # There are a few catch-all except: statements in this module, for - # catching input that's bad in unexpected ways. - # This function re-raises some exceptions we don't want to trap. - unmasked = unmasked + (KeyboardInterrupt, SystemExit, MemoryError) - etype = sys.exc_info()[0] - if issubclass(etype, unmasked): - raise - # swallowed an exception + # catching input that's bad in unexpected ways. Warn if any + # exceptions are caught there. import warnings, traceback, StringIO f = StringIO.StringIO() traceback.print_exc(None, f) @@ -1555,8 +1553,8 @@ try: cookies = self._cookies_from_attrs_set( split_header_words(rfc2965_hdrs), request) - except: - reraise_unmasked_exceptions() + except Exception: + _warn_unhandled_exception() cookies = [] if ns_hdrs and netscape: @@ -1564,8 +1562,8 @@ # RFC 2109 and Netscape cookies ns_cookies = self._cookies_from_attrs_set( parse_ns_headers(ns_hdrs), request) - except: - reraise_unmasked_exceptions() + except Exception: + _warn_unhandled_exception() ns_cookies = [] self._process_rfc2109_cookies(ns_cookies) From neal at metaslash.com Mon May 8 22:12:17 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 8 May 2006 16:12:17 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060508201217.GA23430@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33703 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421790 refs] ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421181 refs] make: *** [test] Error 1 From martin at v.loewis.de Tue May 9 00:12:53 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 09 May 2006 00:12:53 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445F23BD.5040906@egenix.com> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> <445E433C.10908@v.loewis.de> <445F23BD.5040906@egenix.com> Message-ID: <445FC265.6060508@v.loewis.de> M.-A. Lemburg wrote: > I don't understand this part. > > Couldn't we write a small tool that extracts the mapping > from the Windows APIs ? That would be possible, yes. > > Or just use this mapping from ReactOS which was probably > created by doing just that: > > http://www.reactos.org/generated/doxygen/de/d02/doserrmap_8h-source.html I don't know how this table was generated (although I doubt it was generated that way); in any case, there are many such tables to chose from, e.g. the MKS table: http://www.mkssoftware.com/docs/man3/api_intro.3.asp or the Microsoft table: http://pool.cern.ch/coral/currentReleaseDoc/doxygen/dosmap_8cpp-source.html or the Tcl table http://www.openmash.org/lxr/source/win/tclWinError.c?c=tcl8.3 or the PostgreSQL table http://projects.commandprompt.com/public/pgsql/browser/trunk/pgsql/src/backend/port/win32/error.c?rev=23279 I haven't checked how they differ, however, we have to create one such table as the "official" Python table on how to map Win32 errors to "DOS errors". >> - code that currently catches WindowsError and looks into >> the errno value would break, as that would not contain >> Win32 error codes anymore. > > I don't think that there is any such code, since the APIs > you changed used to raise OSErrors. WindowsError was added in r14422, with this: r14422 | guido | 2000-02-17 16:12:01 +0100 (Do, 17 Feb 2000) | 2 lines Ge?nderte Pfade: M /python/trunk/Lib/exceptions.py Added WindowsError, for Mark Hammond's extensions. It had been using this other definition of errno (i.e. Win32 error codes) since day 1. Previous releases of Python had raised WindowsError under various circumstances. For example, PC/_winreg.c raises WindowsError since r14820 (when _winreg was imported into Python). > What I'm after is that code relying on the usage of OSError > will continue to work and at the same time improve the > portability of code using e.g. os.mkdir(). That would be possible with my proposed change. The only breakage would occur with code that catches WindowsError and expects errno to contain Win32 error codes. As something will break no matter what approach is taken, I think that might be the solution that causes the least damage. Regards, Martin From buildbot at python.org Tue May 9 01:13:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 08 May 2006 23:13:44 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060508231344.39EC21E400C@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/225 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 9 07:38:57 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 9 May 2006 07:38:57 +0200 (CEST) Subject: [Python-checkins] r45941 - python/trunk/Python/ceval.c Message-ID: <20060509053857.7E8D41E400C@bag.python.org> Author: neal.norwitz Date: Tue May 9 07:38:56 2006 New Revision: 45941 Modified: python/trunk/Python/ceval.c Log: Micro optimization. In the first case, we know that frame->f_exc_type is NULL, so there's no reason to do anything with it. In the second case, we know frame->f_exc_type is not NULL, so we can just do an INCREF. Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Tue May 9 07:38:56 2006 @@ -2899,7 +2899,6 @@ Py_INCREF(Py_None); tstate->exc_type = Py_None; } - tmp_type = frame->f_exc_type; tmp_value = frame->f_exc_value; tmp_tb = frame->f_exc_traceback; Py_XINCREF(tstate->exc_type); @@ -2908,7 +2907,6 @@ frame->f_exc_type = tstate->exc_type; frame->f_exc_value = tstate->exc_value; frame->f_exc_traceback = tstate->exc_traceback; - Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } @@ -2942,7 +2940,7 @@ tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; - Py_XINCREF(frame->f_exc_type); + Py_INCREF(frame->f_exc_type); Py_XINCREF(frame->f_exc_value); Py_XINCREF(frame->f_exc_traceback); tstate->exc_type = frame->f_exc_type; From buildbot at python.org Tue May 9 08:00:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 09 May 2006 06:00:58 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo trunk Message-ID: <20060509060058.967AB1E4017@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/744 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Tue May 9 08:27:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 09 May 2006 06:27:32 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060509062732.A232E1E400C@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/373 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From neal at metaslash.com Tue May 9 10:12:25 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 9 May 2006 04:12:25 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (1) Message-ID: <20060509081225.GA24805@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33703 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test test_ctypes failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/ctypes/test/test_python_api.py", line 41, in test_PyInt_Long self.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337 test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_ctypes 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421761 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 285 tests OK. 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [421215 refs] From python-checkins at python.org Tue May 9 22:19:37 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 9 May 2006 22:19:37 +0200 (CEST) Subject: [Python-checkins] r45942 - python/branches/stdlib-cleanup Message-ID: <20060509201937.B38A31E4006@bag.python.org> Author: georg.brandl Date: Tue May 9 22:19:37 2006 New Revision: 45942 Removed: python/branches/stdlib-cleanup/ Log: Remove unused branch. From python-checkins at python.org Tue May 9 22:20:15 2006 From: python-checkins at python.org (thomas.heller) Date: Tue, 9 May 2006 22:20:15 +0200 (CEST) Subject: [Python-checkins] r45943 - python/trunk/Lib/ctypes/test/test_python_api.py Message-ID: <20060509202015.97A591E4014@bag.python.org> Author: thomas.heller Date: Tue May 9 22:20:15 2006 New Revision: 45943 Modified: python/trunk/Lib/ctypes/test/test_python_api.py Log: Disable a test that is unreliable. Modified: python/trunk/Lib/ctypes/test/test_python_api.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_python_api.py (original) +++ python/trunk/Lib/ctypes/test/test_python_api.py Tue May 9 22:20:15 2006 @@ -1,5 +1,6 @@ from ctypes import * import unittest, sys +from ctypes.test import is_resource_enabled ################################################################ # This section should be moved into ctypes\__init__.py, when it's ready. @@ -33,20 +34,24 @@ del pyob self.failUnlessEqual(grc(s), refcnt) - def test_PyInt_Long(self): - ref42 = grc(42) - pythonapi.PyInt_FromLong.restype = py_object - self.failUnlessEqual(pythonapi.PyInt_FromLong(42), 42) - - self.failUnlessEqual(grc(42), ref42) - - pythonapi.PyInt_AsLong.argtypes = (py_object,) - pythonapi.PyInt_AsLong.restype = c_long - - res = pythonapi.PyInt_AsLong(42) - self.failUnlessEqual(grc(res), ref42 + 1) - del res - self.failUnlessEqual(grc(42), ref42) + if is_resource_enabled("refcount"): + # This test is unreliable, because it is possible that code in + # unittest changes the refcount of the '42' integer. So, it + # is disabled by default. + def test_PyInt_Long(self): + ref42 = grc(42) + pythonapi.PyInt_FromLong.restype = py_object + self.failUnlessEqual(pythonapi.PyInt_FromLong(42), 42) + + self.failUnlessEqual(grc(42), ref42) + + pythonapi.PyInt_AsLong.argtypes = (py_object,) + pythonapi.PyInt_AsLong.restype = c_long + + res = pythonapi.PyInt_AsLong(42) + self.failUnlessEqual(grc(res), ref42 + 1) + del res + self.failUnlessEqual(grc(42), ref42) def test_PyObj_FromPtr(self): s = "abc def ghi jkl" From python-checkins at python.org Wed May 10 04:43:02 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 10 May 2006 04:43:02 +0200 (CEST) Subject: [Python-checkins] r45944 - in python/trunk: Lib/doctest.py Lib/test/test_doctest.py Misc/NEWS Message-ID: <20060510024302.8DA071E4006@bag.python.org> Author: tim.peters Date: Wed May 10 04:43:01 2006 New Revision: 45944 Modified: python/trunk/Lib/doctest.py python/trunk/Lib/test/test_doctest.py python/trunk/Misc/NEWS Log: Variant of patch #1478292. doctest.register_optionflag(name) shouldn't create a new flag when `name` is already the name of an option flag. Modified: python/trunk/Lib/doctest.py ============================================================================== --- python/trunk/Lib/doctest.py (original) +++ python/trunk/Lib/doctest.py Wed May 10 04:43:01 2006 @@ -129,9 +129,8 @@ OPTIONFLAGS_BY_NAME = {} def register_optionflag(name): - flag = 1 << len(OPTIONFLAGS_BY_NAME) - OPTIONFLAGS_BY_NAME[name] = flag - return flag + # Create a new flag unless `name` is already known. + return OPTIONFLAGS_BY_NAME.setdefault(name, 1 << len(OPTIONFLAGS_BY_NAME)) DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1') DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') Modified: python/trunk/Lib/test/test_doctest.py ============================================================================== --- python/trunk/Lib/test/test_doctest.py (original) +++ python/trunk/Lib/test/test_doctest.py Wed May 10 04:43:01 2006 @@ -1300,6 +1300,26 @@ ValueError: 2 (3, 5) +New option flags can also be registered, via register_optionflag(). Here +we reach into doctest's internals a bit. + + >>> unlikely = "UNLIKELY_OPTION_NAME" + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + False + >>> new_flag_value = doctest.register_optionflag(unlikely) + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + True + +Before 2.4.4/2.5, registering a name more than once erroneously created +more than one flag value. Here we verify that's fixed: + + >>> redundant_flag_value = doctest.register_optionflag(unlikely) + >>> redundant_flag_value == new_flag_value + True + +Clean up. + >>> del doctest.OPTIONFLAGS_BY_NAME[unlikely] + """ def option_directives(): r""" Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 10 04:43:01 2006 @@ -67,7 +67,7 @@ Extension Modules ----------------- -- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. +- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. As a result, these functions now raise WindowsError instead of OSError. - Calling Tk_Init twice is refused if the first call failed as that @@ -96,6 +96,9 @@ Library ------- +- Patch #1478292. ``doctest.register_optionflag(name)`` shouldn't create a + new flag when ``name`` is already the name of an option flag. + - Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package. From python-checkins at python.org Wed May 10 04:46:50 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 10 May 2006 04:46:50 +0200 (CEST) Subject: [Python-checkins] r45945 - in python/branches/release24-maint: Lib/doctest.py Lib/test/test_doctest.py Misc/NEWS Message-ID: <20060510024650.31E8D1E4006@bag.python.org> Author: tim.peters Date: Wed May 10 04:46:48 2006 New Revision: 45945 Modified: python/branches/release24-maint/Lib/doctest.py python/branches/release24-maint/Lib/test/test_doctest.py python/branches/release24-maint/Misc/NEWS Log: Merge rev 45944 from trunk. Variant of patch #1478292. doctest.register_optionflag(name) shouldn't create a new flag when `name` is already the name of an option flag. Modified: python/branches/release24-maint/Lib/doctest.py ============================================================================== --- python/branches/release24-maint/Lib/doctest.py (original) +++ python/branches/release24-maint/Lib/doctest.py Wed May 10 04:46:48 2006 @@ -128,9 +128,8 @@ OPTIONFLAGS_BY_NAME = {} def register_optionflag(name): - flag = 1 << len(OPTIONFLAGS_BY_NAME) - OPTIONFLAGS_BY_NAME[name] = flag - return flag + # Create a new flag unless `name` is already known. + return OPTIONFLAGS_BY_NAME.setdefault(name, 1 << len(OPTIONFLAGS_BY_NAME)) DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1') DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') Modified: python/branches/release24-maint/Lib/test/test_doctest.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_doctest.py (original) +++ python/branches/release24-maint/Lib/test/test_doctest.py Wed May 10 04:46:48 2006 @@ -1281,6 +1281,26 @@ ValueError: 2 (3, 5) +New option flags can also be registered, via register_optionflag(). Here +we reach into doctest's internals a bit. + + >>> unlikely = "UNLIKELY_OPTION_NAME" + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + False + >>> new_flag_value = doctest.register_optionflag(unlikely) + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + True + +Before 2.4.4/2.5, registering a name more than once erroneously created +more than one flag value. Here we verify that's fixed: + + >>> redundant_flag_value = doctest.register_optionflag(unlikely) + >>> redundant_flag_value == new_flag_value + True + +Clean up. + >>> del doctest.OPTIONFLAGS_BY_NAME[unlikely] + """ def option_directives(): r""" Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed May 10 04:46:48 2006 @@ -32,6 +32,9 @@ Library ------- +- Patch #1478292. ``doctest.register_optionflag(name)`` shouldn't create a + new flag when ``name`` is already the name of an option flag. + - Bug #1473760: ``tempfile.TemporaryFile()`` could hang on Windows, when called from a thread spawned as a side effect of importing a module. From buildbot at python.org Wed May 10 05:20:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 03:20:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060510032005.55A101E400F@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/92 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 10 05:59:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 03:59:05 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.4 Message-ID: <20060510035905.4A0B71E4006@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%25202.4/builds/122 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 10 06:08:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 04:08:15 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060510040815.599F41E4006@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/59 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: tim.peters BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed May 10 06:33:25 2006 From: python-checkins at python.org (martin.v.loewis) Date: Wed, 10 May 2006 06:33:25 +0200 (CEST) Subject: [Python-checkins] r45946 - python/branches/release24-maint/README Message-ID: <20060510043325.65E141E4006@bag.python.org> Author: martin.v.loewis Date: Wed May 10 06:33:22 2006 New Revision: 45946 Modified: python/branches/release24-maint/README Log: Document C++ as a build requirement. Modified: python/branches/release24-maint/README ============================================================================== --- python/branches/release24-maint/README (original) +++ python/branches/release24-maint/README Wed May 10 06:33:22 2006 @@ -166,6 +166,13 @@ configure script -- see the section below on configuration options and variables. When it's done, you are ready to run make. +As a prerequisite, you need at least a C compiler on your system, +along with header files for the standard C library. You also need +a C++ compiler, unless you pass --without-cxx to configure. In +addition, you need header files and libraries for various optional +extension modules; if these are missing, the build process will +skip building these modules. + To build Python, you normally type "make" in the toplevel directory. If you have changed the configuration, the Makefile may have to be rebuilt. In this case you may have to run make again to correctly From buildbot at python.org Wed May 10 07:35:29 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 05:35:29 +0000 Subject: [Python-checkins] buildbot failure in sparc Ubuntu dapper 2.4 Message-ID: <20060510053529.F16C71E4002@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%25202.4/builds/52 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: tim.peters BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Wed May 10 07:38:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 05:38:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin 2.4 Message-ID: <20060510053844.7C8881E4002@bag.python.org> The Buildbot has detected a new failure of x86 cygwin 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%25202.4/builds/65 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 10 08:35:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 06:35:50 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060510063550.E1C8F1E402A@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/19 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 10 08:58:00 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 10 May 2006 08:58:00 +0200 (CEST) Subject: [Python-checkins] r45947 - in python/trunk: Modules/_csv.c Modules/_elementtree.c Modules/_ssl.c Objects/longobject.c Message-ID: <20060510065800.511AB1E4002@bag.python.org> Author: neal.norwitz Date: Wed May 10 08:57:58 2006 New Revision: 45947 Modified: python/trunk/Modules/_csv.c python/trunk/Modules/_elementtree.c python/trunk/Modules/_ssl.c python/trunk/Objects/longobject.c Log: Fix problems found by Coverity. longobject.c: also fix an ssize_t problem could have been NULL, so hoist the size calc to not use . _ssl.c: under fail: self is DECREF'd, but it would have been NULL. _elementtree.c: delete self if there was an error. _csv.c: I'm not sure if lineterminator could have been anything other than a string. However, other string method calls are checked, so check this one too. Modified: python/trunk/Modules/_csv.c ============================================================================== --- python/trunk/Modules/_csv.c (original) +++ python/trunk/Modules/_csv.c Wed May 10 08:57:58 2006 @@ -1104,6 +1104,8 @@ char *terminator; terminator_len = PyString_Size(self->dialect->lineterminator); + if (terminator_len == -1) + return 0; /* grow record buffer if necessary */ if (!join_check_rec_size(self, self->rec_len + terminator_len)) Modified: python/trunk/Modules/_elementtree.c ============================================================================== --- python/trunk/Modules/_elementtree.c (original) +++ python/trunk/Modules/_elementtree.c Wed May 10 08:57:58 2006 @@ -327,8 +327,10 @@ if (attrib != Py_None) { - if (element_new_extra(self, attrib) < 0) + if (element_new_extra(self, attrib) < 0) { + PyObject_Del(self); return NULL; + } self->extra->length = 0; self->extra->allocated = STATIC_CHILDREN; Modified: python/trunk/Modules/_ssl.c ============================================================================== --- python/trunk/Modules/_ssl.c (original) +++ python/trunk/Modules/_ssl.c Wed May 10 08:57:58 2006 @@ -183,9 +183,9 @@ int sockstate; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ - if (self == NULL){ - errstr = "newPySSLObject error"; - goto fail; + if (self == NULL) { + PyErr_SetString(PySSLErrorObject, "newPySSLObject error"); + return NULL; } memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Wed May 10 08:57:58 2006 @@ -66,8 +66,7 @@ PyLongObject * _PyLong_New(Py_ssize_t size) { - if (size > INT_MAX) { - /* XXX: Fix this check when ob_size becomes ssize_t */ + if (size > PY_SSIZE_T_MAX) { PyErr_NoMemory(); return NULL; } @@ -1580,9 +1579,10 @@ assert(size_w == ABS(w->ob_size)); /* That's how d was calculated */ size_v = ABS(v->ob_size); - a = _PyLong_New(size_v - size_w + 1); + k = size_v - size_w; + a = _PyLong_New(k + 1); - for (j = size_v, k = a->ob_size-1; a != NULL && k >= 0; --j, --k) { + for (j = size_v; a != NULL && k >= 0; --j, --k) { digit vj = (j >= size_v) ? 0 : v->ob_digit[j]; twodigits q; stwodigits carry = 0; From buildbot at python.org Wed May 10 09:09:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 07:09:39 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060510070939.62AD11E4002@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/672 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From thomas at python.org Wed May 10 10:14:49 2006 From: thomas at python.org (Thomas Wouters) Date: Wed, 10 May 2006 10:14:49 +0200 Subject: [Python-checkins] r45947 - in python/trunk: Modules/_csv.c Modules/_elementtree.c Modules/_ssl.c Objects/longobject.c In-Reply-To: <20060510065800.511AB1E4002@bag.python.org> References: <20060510065800.511AB1E4002@bag.python.org> Message-ID: <9e804ac0605100114q70cbeb0ao75855b28172e687c@mail.gmail.com> On 5/10/06, neal.norwitz wrote: > Modified: python/trunk/Modules/_ssl.c > > ============================================================================== > --- python/trunk/Modules/_ssl.c (original) > +++ python/trunk/Modules/_ssl.c Wed May 10 08:57:58 2006 > @@ -183,9 +183,9 @@ > int sockstate; > > self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new > object */ > - if (self == NULL){ > - errstr = "newPySSLObject error"; > - goto fail; > + if (self == NULL) { > + PyErr_SetString(PySSLErrorObject, "newPySSLObject error"); > + return NULL; > } > memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); > memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); Is there a reason this clobbers the exception set by PyObject_New()? (Especially considering the useless error message the new exception contains :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060510/7ac6da55/attachment.html From buildbot at python.org Wed May 10 10:22:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 08:22:24 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060510082224.BEC8B1E4002@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/376 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Wed May 10 10:44:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 08:44:50 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060510084450.4C2311E4002@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/101 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Wed May 10 15:30:50 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 10 May 2006 15:30:50 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445FC265.6060508@v.loewis.de> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> <445E433C.10908@v.loewis.de> <445F23BD.5040906@egenix.com> <445FC265.6060508@v.loewis.de> Message-ID: <4461EB0A.5000800@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >> I don't understand this part. >> >> Couldn't we write a small tool that extracts the mapping >> from the Windows APIs ? > > That would be possible, yes. > >> Or just use this mapping from ReactOS which was probably >> created by doing just that: >> >> http://www.reactos.org/generated/doxygen/de/d02/doserrmap_8h-source.html > > I don't know how this table was generated (although I doubt it was > generated that way); in any case, there are many such tables > to chose from, e.g. the MKS table: > > http://www.mkssoftware.com/docs/man3/api_intro.3.asp > > or the Microsoft table: > > http://pool.cern.ch/coral/currentReleaseDoc/doxygen/dosmap_8cpp-source.html > > or the Tcl table > > http://www.openmash.org/lxr/source/win/tclWinError.c?c=tcl8.3 > > or the PostgreSQL table > > http://projects.commandprompt.com/public/pgsql/browser/trunk/pgsql/src/backend/port/win32/error.c?rev=23279 > > I haven't checked how they differ, however, we have to create > one such table as the "official" Python table on how to map > Win32 errors to "DOS errors". I've tried to find documentation on _dosmaperr() but there's nothing on MSDN. Is this an official API ? FWIW, this is the official system error code table: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp A complete table would be quite large... >>> - code that currently catches WindowsError and looks into >>> the errno value would break, as that would not contain >>> Win32 error codes anymore. >> I don't think that there is any such code, since the APIs >> you changed used to raise OSErrors. > > WindowsError was added in r14422, with this: > > r14422 | guido | 2000-02-17 16:12:01 +0100 (Do, 17 Feb 2000) | 2 lines > Ge?nderte Pfade: > M /python/trunk/Lib/exceptions.py > > Added WindowsError, for Mark Hammond's extensions. > > It had been using this other definition of errno (i.e. Win32 error > codes) since day 1. Previous releases of Python had raised WindowsError > under various circumstances. For example, PC/_winreg.c raises > WindowsError since r14820 (when _winreg was imported into Python). Right, but the APIs you changed used to raise IOError using the DOS error codes - this is where there's an incompatibility, since they now raise WindowsErrors with completely different error codes. The discussion http://mail.python.org/pipermail/python-dev/2006-January/060243.html suggests that you are aware of this. >> What I'm after is that code relying on the usage of OSError >> will continue to work and at the same time improve the >> portability of code using e.g. os.mkdir(). > > That would be possible with my proposed change. The only breakage > would occur with code that catches WindowsError and expects errno > to contain Win32 error codes. > > As something will break no matter what approach is taken, I think > that might be the solution that causes the least damage. Since code catching IOError will also see any WindowsError exception, I'd opt for making .errno always return the DOS/BSD error codes and have WindowsError grow an additional .winerrno attribute which contains the more fine-grained Win32 error code. This would make it easier to write portable code. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 10 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Wed May 10 17:04:16 2006 From: python-checkins at python.org (thomas.wouters) Date: Wed, 10 May 2006 17:04:16 +0200 (CEST) Subject: [Python-checkins] r45948 - python/trunk Message-ID: <20060510150416.649161E4002@bag.python.org> Author: thomas.wouters Date: Wed May 10 17:04:11 2006 New Revision: 45948 Modified: python/trunk/ (props changed) Log: Ignore reflog.txt, too. From python-checkins at python.org Wed May 10 17:59:06 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 17:59:06 +0200 (CEST) Subject: [Python-checkins] r45949 - python/trunk/Doc/lib/libprofile.tex Message-ID: <20060510155906.D38F61E4002@bag.python.org> Author: georg.brandl Date: Wed May 10 17:59:06 2006 New Revision: 45949 Modified: python/trunk/Doc/lib/libprofile.tex Log: Bug #1482988: indicate more prominently that the Stats class is in the pstats module. Modified: python/trunk/Doc/lib/libprofile.tex ============================================================================== --- python/trunk/Doc/lib/libprofile.tex (original) +++ python/trunk/Doc/lib/libprofile.tex Wed May 10 17:59:06 2006 @@ -384,8 +384,9 @@ \var{command} string. \end{funcdesc} -Analysis of the profiler data is done using this class from the -\module{pstats} module: +Analysis of the profiler data is done using the \class{Stats} class. + +\note{The \class{Stats} class is defined in the \module{pstats} module.} % now switch modules.... % (This \stmodindex use may be hard to change ;-( ) From python-checkins at python.org Wed May 10 18:09:03 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 18:09:03 +0200 (CEST) Subject: [Python-checkins] r45950 - python/trunk/Doc/lib/libsubprocess.tex Message-ID: <20060510160903.7EAA11E4002@bag.python.org> Author: georg.brandl Date: Wed May 10 18:09:03 2006 New Revision: 45950 Modified: python/trunk/Doc/lib/libsubprocess.tex Log: Bug #1485447: subprocess: document that the "cwd" parameter isn't used to find the executable. Misc. other markup fixes. Modified: python/trunk/Doc/lib/libsubprocess.tex ============================================================================== --- python/trunk/Doc/lib/libsubprocess.tex (original) +++ python/trunk/Doc/lib/libsubprocess.tex Wed May 10 18:09:03 2006 @@ -70,10 +70,10 @@ The \var{executable} argument specifies the program to execute. It is very seldom needed: Usually, the program to execute is defined by the -\var{args} argument. If \var{shell=True}, the \var{executable} +\var{args} argument. If \code{shell=True}, the \var{executable} argument specifies which shell to use. On \UNIX{}, the default shell -is /bin/sh. On Windows, the default shell is specified by the COMSPEC -environment variable. +is \file{/bin/sh}. On Windows, the default shell is specified by the +\envvar{COMSPEC} environment variable. \var{stdin}, \var{stdout} and \var{stderr} specify the executed programs' standard input, standard output and standard error file @@ -88,16 +88,19 @@ If \var{preexec_fn} is set to a callable object, this object will be called in the child process just before the child is executed. +(\UNIX{} only) If \var{close_fds} is true, all file descriptors except \constant{0}, \constant{1} and \constant{2} will be closed before the child process is -executed. +executed. (\UNIX{} only) If \var{shell} is \constant{True}, the specified command will be executed through the shell. -If \var{cwd} is not \code{None}, the current directory will be changed -to cwd before the child is executed. +If \var{cwd} is not \code{None}, the child's current directory will be +changed to \var{cwd} before it is executed. Note that this directory +is not considered when searching the executable, so you can't specify +the program's path relative to \var{cwd}. If \var{env} is not \code{None}, it defines the environment variables for the new process. From python-checkins at python.org Wed May 10 18:09:05 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 18:09:05 +0200 (CEST) Subject: [Python-checkins] r45951 - python/branches/release24-maint/Doc/lib/libsubprocess.tex Message-ID: <20060510160905.DA1B11E400C@bag.python.org> Author: georg.brandl Date: Wed May 10 18:09:05 2006 New Revision: 45951 Modified: python/branches/release24-maint/Doc/lib/libsubprocess.tex Log: Bug #1485447: subprocess: document that the "cwd" parameter isn't used to find the executable. Misc. other markup fixes. (backport from rev. 45950) Modified: python/branches/release24-maint/Doc/lib/libsubprocess.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libsubprocess.tex (original) +++ python/branches/release24-maint/Doc/lib/libsubprocess.tex Wed May 10 18:09:05 2006 @@ -70,10 +70,10 @@ The \var{executable} argument specifies the program to execute. It is very seldom needed: Usually, the program to execute is defined by the -\var{args} argument. If \var{shell=True}, the \var{executable} +\var{args} argument. If \code{shell=True}, the \var{executable} argument specifies which shell to use. On \UNIX{}, the default shell -is /bin/sh. On Windows, the default shell is specified by the COMSPEC -environment variable. +is \file{/bin/sh}. On Windows, the default shell is specified by the +\envvar{COMSPEC} environment variable. \var{stdin}, \var{stdout} and \var{stderr} specify the executed programs' standard input, standard output and standard error file @@ -88,16 +88,19 @@ If \var{preexec_fn} is set to a callable object, this object will be called in the child process just before the child is executed. +(\UNIX{} only) If \var{close_fds} is true, all file descriptors except \constant{0}, \constant{1} and \constant{2} will be closed before the child process is -executed. +executed. (\UNIX{} only) If \var{shell} is \constant{True}, the specified command will be executed through the shell. -If \var{cwd} is not \code{None}, the current directory will be changed -to cwd before the child is executed. +If \var{cwd} is not \code{None}, the child's current directory will be +changed to \var{cwd} before it is executed. Note that this directory +is not considered when searching the executable, so you can't specify +the program's path relative to \var{cwd}. If \var{env} is not \code{None}, it defines the environment variables for the new process. From python-checkins at python.org Wed May 10 18:11:45 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 18:11:45 +0200 (CEST) Subject: [Python-checkins] r45952 - python/trunk/Doc/lib/libcursespanel.tex Message-ID: <20060510161145.BD6B81E400E@bag.python.org> Author: georg.brandl Date: Wed May 10 18:11:44 2006 New Revision: 45952 Modified: python/trunk/Doc/lib/libcursespanel.tex Log: Bug #1484978: curses.panel: clarify that Panel objects are destroyed on garbage collection. Modified: python/trunk/Doc/lib/libcursespanel.tex ============================================================================== --- python/trunk/Doc/lib/libcursespanel.tex (original) +++ python/trunk/Doc/lib/libcursespanel.tex Wed May 10 18:11:44 2006 @@ -22,6 +22,9 @@ \begin{funcdesc}{new_panel}{win} Returns a panel object, associating it with the given window \var{win}. +Be aware that you need to keep the returned panel object referenced +explicitly. If you don't, the panel object is garbage collected and +removed from the panel stack. \end{funcdesc} \begin{funcdesc}{top_panel}{} From python-checkins at python.org Wed May 10 18:11:48 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 18:11:48 +0200 (CEST) Subject: [Python-checkins] r45953 - python/branches/release24-maint/Doc/lib/libcursespanel.tex Message-ID: <20060510161148.8BEFB1E400B@bag.python.org> Author: georg.brandl Date: Wed May 10 18:11:48 2006 New Revision: 45953 Modified: python/branches/release24-maint/Doc/lib/libcursespanel.tex Log: Bug #1484978: curses.panel: clarify that Panel objects are destroyed on garbage collection. (backport from rev. 45952) Modified: python/branches/release24-maint/Doc/lib/libcursespanel.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libcursespanel.tex (original) +++ python/branches/release24-maint/Doc/lib/libcursespanel.tex Wed May 10 18:11:48 2006 @@ -22,6 +22,9 @@ \begin{funcdesc}{new_panel}{win} Returns a panel object, associating it with the given window \var{win}. +Be aware that you need to keep the returned panel object referenced +explicitly. If you don't, the panel object is garbage collected and +removed from the panel stack. \end{funcdesc} \begin{funcdesc}{top_panel}{} From buildbot at python.org Wed May 10 18:12:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 16:12:58 +0000 Subject: [Python-checkins] buildbot failure in x86 cygwin trunk Message-ID: <20060510161258.39A031E4006@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/379 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl BUILD FAILED: failed compile sincerely, -The Buildbot From mal at egenix.com Wed May 10 18:22:32 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 10 May 2006 18:22:32 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <445FC265.6060508@v.loewis.de> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> <445E433C.10908@v.loewis.de> <445F23BD.5040906@egenix.com> <445FC265.6060508@v.loewis.de> Message-ID: <44621348.2020506@egenix.com> Martin v. L?wis wrote: >> Or just use this mapping from ReactOS which was probably >> created by doing just that: >> >> http://www.reactos.org/generated/doxygen/de/d02/doserrmap_8h-source.html > > I don't know how this table was generated (although I doubt it was > generated that way); At the top of the file it says: /* doserrmap.h: auto-generated from winerror.h and errno.h using undoc'd _dosmaperr. */ That's good enough for me. I tried to find a DLL that has the _dosmaperr API on my Windows XP box and couldn't find it. It's probably inlined in the C lib, so doesn't appear as symbol. There is such a function in the source code of the VC7 CRT (in a file called dosmap.c). Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 10 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From buildbot at python.org Wed May 10 19:05:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 17:05:27 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060510170527.D3DA51E4011@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/341 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 10 19:13:22 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 19:13:22 +0200 (CEST) Subject: [Python-checkins] r45955 - in python/trunk: Lib/bdb.py Lib/doctest.py Lib/pdb.py Misc/NEWS Message-ID: <20060510171322.F08AE1E400B@bag.python.org> Author: georg.brandl Date: Wed May 10 19:13:20 2006 New Revision: 45955 Modified: python/trunk/Lib/bdb.py python/trunk/Lib/doctest.py python/trunk/Lib/pdb.py python/trunk/Misc/NEWS Log: Patch #721464: pdb.Pdb instances can now be given explicit stdin and stdout arguments, making it possible to redirect input and output for remote debugging. Modified: python/trunk/Lib/bdb.py ============================================================================== --- python/trunk/Lib/bdb.py (original) +++ python/trunk/Lib/bdb.py Wed May 10 19:13:20 2006 @@ -473,7 +473,9 @@ def disable(self): self.enabled = 0 - def bpprint(self): + def bpprint(self, out=None): + if out is None: + out = sys.stdout if self.temporary: disp = 'del ' else: @@ -482,17 +484,17 @@ disp = disp + 'yes ' else: disp = disp + 'no ' - print '%-4dbreakpoint %s at %s:%d' % (self.number, disp, - self.file, self.line) + print >>out, '%-4dbreakpoint %s at %s:%d' % (self.number, disp, + self.file, self.line) if self.cond: - print '\tstop only if %s' % (self.cond,) + print >>out, '\tstop only if %s' % (self.cond,) if self.ignore: - print '\tignore next %d hits' % (self.ignore) + print >>out, '\tignore next %d hits' % (self.ignore) if (self.hits): if (self.hits > 1): ss = 's' else: ss = '' - print ('\tbreakpoint already hit %d time%s' % - (self.hits, ss)) + print >>out, ('\tbreakpoint already hit %d time%s' % + (self.hits, ss)) # -----------end of Breakpoint class---------- Modified: python/trunk/Lib/doctest.py ============================================================================== --- python/trunk/Lib/doctest.py (original) +++ python/trunk/Lib/doctest.py Wed May 10 19:13:20 2006 @@ -352,7 +352,7 @@ """ def __init__(self, out): self.__out = out - pdb.Pdb.__init__(self) + pdb.Pdb.__init__(self, stdout=out) def trace_dispatch(self, *args): # Redirect stdout to the given stream. Modified: python/trunk/Lib/pdb.py ============================================================================== --- python/trunk/Lib/pdb.py (original) +++ python/trunk/Lib/pdb.py Wed May 10 19:13:20 2006 @@ -52,9 +52,11 @@ class Pdb(bdb.Bdb, cmd.Cmd): - def __init__(self): + def __init__(self, completekey='tab', stdin=None, stdout=None): bdb.Bdb.__init__(self) - cmd.Cmd.__init__(self) + cmd.Cmd.__init__(self, completekey, stdin, stdout) + if stdout: + self.use_rawinput = 0 self.prompt = '(Pdb) ' self.aliases = {} self.mainpyfile = '' @@ -128,7 +130,7 @@ if self._wait_for_mainpyfile: return if self.stop_here(frame): - print '--Call--' + print >>self.stdout, '--Call--' self.interaction(frame, None) def user_line(self, frame): @@ -164,7 +166,7 @@ def user_return(self, frame, return_value): """This function is called when a return trap is set here.""" frame.f_locals['__return__'] = return_value - print '--Return--' + print >>self.stdout, '--Return--' self.interaction(frame, None) def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): @@ -174,7 +176,7 @@ if type(exc_type) == type(''): exc_type_name = exc_type else: exc_type_name = exc_type.__name__ - print exc_type_name + ':', _saferepr(exc_value) + print >>self.stdout, exc_type_name + ':', _saferepr(exc_value) self.interaction(frame, exc_traceback) # General interaction function @@ -197,7 +199,7 @@ if type(t) == type(''): exc_type_name = t else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', v + print >>self.stdout, '***', exc_type_name + ':', v def precmd(self, line): """Handle alias expansion and ';;' separator.""" @@ -275,7 +277,7 @@ try: bnum = int(arg) except: - print "Usage : commands [bnum]\n ...\n end" + print >>self.stdout, "Usage : commands [bnum]\n ...\n end" return self.commands_bnum = bnum self.commands[bnum] = [] @@ -292,10 +294,10 @@ # break [ ([filename:]lineno | function) [, "condition"] ] if not arg: if self.breaks: # There's at least one - print "Num Type Disp Enb Where" + print >>self.stdout, "Num Type Disp Enb Where" for bp in bdb.Breakpoint.bpbynumber: if bp: - bp.bpprint() + bp.bpprint(self.stdout) return # parse arguments; comma has lowest precedence # and cannot occur in filename @@ -314,8 +316,8 @@ filename = arg[:colon].rstrip() f = self.lookupmodule(filename) if not f: - print '*** ', repr(filename), - print 'not found from sys.path' + print >>self.stdout, '*** ', repr(filename), + print >>self.stdout, 'not found from sys.path' return else: filename = f @@ -323,7 +325,7 @@ try: lineno = int(arg) except ValueError, msg: - print '*** Bad lineno:', arg + print >>self.stdout, '*** Bad lineno:', arg return else: # no colon; can be lineno or function @@ -349,11 +351,10 @@ # last thing to try (ok, filename, ln) = self.lineinfo(arg) if not ok: - print '*** The specified object', - print repr(arg), - print 'is not a function' - print ('or was not found ' - 'along sys.path.') + print >>self.stdout, '*** The specified object', + print >>self.stdout, repr(arg), + print >>self.stdout, 'is not a function' + print >>self.stdout, 'or was not found along sys.path.' return funcname = ok # ok contains a function name lineno = int(ln) @@ -364,12 +365,12 @@ if line: # now set the break point err = self.set_break(filename, line, temporary, cond, funcname) - if err: print '***', err + if err: print >>self.stdout, '***', err else: bp = self.get_breaks(filename, line)[-1] - print "Breakpoint %d at %s:%d" % (bp.number, - bp.file, - bp.line) + print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number, + bp.file, + bp.line) # To be overridden in derived debuggers def defaultFile(self): @@ -425,13 +426,13 @@ """ line = linecache.getline(filename, lineno) if not line: - print 'End of file' + print >>self.stdout, 'End of file' return 0 line = line.strip() # Don't allow setting breakpoint at a blank line if (not line or (line[0] == '#') or (line[:3] == '"""') or line[:3] == "'''"): - print '*** Blank or comment' + print >>self.stdout, '*** Blank or comment' return 0 return lineno @@ -441,11 +442,11 @@ try: i = int(i) except ValueError: - print 'Breakpoint index %r is not a number' % i + print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print 'No breakpoint numbered', i + print >>self.stdout, 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] @@ -458,11 +459,11 @@ try: i = int(i) except ValueError: - print 'Breakpoint index %r is not a number' % i + print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print 'No breakpoint numbered', i + print >>self.stdout, 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] @@ -481,8 +482,8 @@ if bp: bp.cond = cond if not cond: - print 'Breakpoint', bpnum, - print 'is now unconditional.' + print >>self.stdout, 'Breakpoint', bpnum, + print >>self.stdout, 'is now unconditional.' def do_ignore(self,arg): """arg is bp number followed by ignore count.""" @@ -501,10 +502,10 @@ reply = reply + '%d crossings' % count else: reply = reply + '1 crossing' - print reply + ' of breakpoint %d.' % bpnum + print >>self.stdout, reply + ' of breakpoint %d.' % bpnum else: - print 'Will stop next time breakpoint', - print bpnum, 'is reached.' + print >>self.stdout, 'Will stop next time breakpoint', + print >>self.stdout, bpnum, 'is reached.' def do_clear(self, arg): """Three possibilities, tried in this order: @@ -531,24 +532,24 @@ err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) - if err: print '***', err + if err: print >>self.stdout, '***', err return numberlist = arg.split() for i in numberlist: try: i = int(i) except ValueError: - print 'Breakpoint index %r is not a number' % i + print >>self.stdout, 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print 'No breakpoint numbered', i + print >>self.stdout, 'No breakpoint numbered', i continue err = self.clear_bpbynumber(i) if err: - print '***', err + print >>self.stdout, '***', err else: - print 'Deleted breakpoint', i + print >>self.stdout, 'Deleted breakpoint', i do_cl = do_clear # 'c' is already an abbreviation for 'continue' def do_where(self, arg): @@ -558,7 +559,7 @@ def do_up(self, arg): if self.curindex == 0: - print '*** Oldest frame' + print >>self.stdout, '*** Oldest frame' else: self.curindex = self.curindex - 1 self.curframe = self.stack[self.curindex][0] @@ -568,7 +569,7 @@ def do_down(self, arg): if self.curindex + 1 == len(self.stack): - print '*** Newest frame' + print >>self.stdout, '*** Newest frame' else: self.curindex = self.curindex + 1 self.curframe = self.stack[self.curindex][0] @@ -598,12 +599,12 @@ def do_jump(self, arg): if self.curindex + 1 != len(self.stack): - print "*** You can only jump within the bottom frame" + print >>self.stdout, "*** You can only jump within the bottom frame" return try: arg = int(arg) except ValueError: - print "*** The 'jump' command requires a line number." + print >>self.stdout, "*** The 'jump' command requires a line number." else: try: # Do the jump, fix up our copy of the stack, and display the @@ -612,7 +613,7 @@ self.stack[self.curindex] = self.stack[self.curindex][0], arg self.print_stack_entry(self.stack[self.curindex]) except ValueError, e: - print '*** Jump failed:', e + print >>self.stdout, '*** Jump failed:', e do_j = do_jump def do_debug(self, arg): @@ -621,9 +622,9 @@ locals = self.curframe.f_locals p = Pdb() p.prompt = "(%s) " % self.prompt.strip() - print "ENTERING RECURSIVE DEBUGGER" + print >>self.stdout, "ENTERING RECURSIVE DEBUGGER" sys.call_tracing(p.run, (arg, globals, locals)) - print "LEAVING RECURSIVE DEBUGGER" + print >>self.stdout, "LEAVING RECURSIVE DEBUGGER" sys.settrace(self.trace_dispatch) self.lastcmd = p.lastcmd @@ -636,7 +637,7 @@ do_exit = do_quit def do_EOF(self, arg): - print + print >>self.stdout self._user_requested_quit = 1 self.set_quit() return 1 @@ -650,16 +651,16 @@ if co.co_flags & 8: n = n+1 for i in range(n): name = co.co_varnames[i] - print name, '=', - if name in dict: print dict[name] - else: print "*** undefined ***" + print >>self.stdout, name, '=', + if name in dict: print >>self.stdout, dict[name] + else: print >>self.stdout, "*** undefined ***" do_a = do_args def do_retval(self, arg): if '__return__' in self.curframe.f_locals: - print self.curframe.f_locals['__return__'] + print >>self.stdout, self.curframe.f_locals['__return__'] else: - print '*** Not yet returned!' + print >>self.stdout, '*** Not yet returned!' do_rv = do_retval def _getval(self, arg): @@ -671,18 +672,18 @@ if isinstance(t, str): exc_type_name = t else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', repr(v) + print >>self.stdout, '***', exc_type_name + ':', repr(v) raise def do_p(self, arg): try: - print repr(self._getval(arg)) + print >>self.stdout, repr(self._getval(arg)) except: pass def do_pp(self, arg): try: - pprint.pprint(self._getval(arg)) + pprint.pprint(self._getval(arg), self.stdout) except: pass @@ -702,7 +703,7 @@ else: first = max(1, int(x) - 5) except: - print '*** Error in argument:', repr(arg) + print >>self.stdout, '*** Error in argument:', repr(arg) return elif self.lineno is None: first = max(1, self.curframe.f_lineno - 5) @@ -716,7 +717,7 @@ for lineno in range(first, last+1): line = linecache.getline(filename, lineno) if not line: - print '[EOF]' + print >>self.stdout, '[EOF]' break else: s = repr(lineno).rjust(3) @@ -725,7 +726,7 @@ else: s = s + ' ' if lineno == self.curframe.f_lineno: s = s + '->' - print s + '\t' + line, + print >>self.stdout, s + '\t' + line, self.lineno = lineno except KeyboardInterrupt: pass @@ -740,23 +741,23 @@ if type(t) == type(''): exc_type_name = t else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', repr(v) + print >>self.stdout, '***', exc_type_name + ':', repr(v) return code = None # Is it a function? try: code = value.func_code except: pass if code: - print 'Function', code.co_name + print >>self.stdout, 'Function', code.co_name return # Is it an instance method? try: code = value.im_func.func_code except: pass if code: - print 'Method', code.co_name + print >>self.stdout, 'Method', code.co_name return # None of the above... - print type(value) + print >>self.stdout, type(value) def do_alias(self, arg): args = arg.split() @@ -764,10 +765,10 @@ keys = self.aliases.keys() keys.sort() for alias in keys: - print "%s = %s" % (alias, self.aliases[alias]) + print >>self.stdout, "%s = %s" % (alias, self.aliases[alias]) return if args[0] in self.aliases and len(args) == 1: - print "%s = %s" % (args[0], self.aliases[args[0]]) + print >>self.stdout, "%s = %s" % (args[0], self.aliases[args[0]]) else: self.aliases[args[0]] = ' '.join(args[1:]) @@ -778,7 +779,8 @@ del self.aliases[args[0]] #list of all the commands making the program resume execution. - commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return', 'do_quit', 'do_jump'] + commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return', + 'do_quit', 'do_jump'] # Print a traceback starting at the top stack frame. # The most recently entered frame is printed last; @@ -798,10 +800,11 @@ def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix): frame, lineno = frame_lineno if frame is self.curframe: - print '>', + print >>self.stdout, '>', else: - print ' ', - print self.format_stack_entry(frame_lineno, prompt_prefix) + print >>self.stdout, ' ', + print >>self.stdout, self.format_stack_entry(frame_lineno, + prompt_prefix) # Help methods (derived from pdb.doc) @@ -810,7 +813,7 @@ self.help_h() def help_h(self): - print """h(elp) + print >>self.stdout, """h(elp) Without argument, print the list of available commands. With a command name as argument, print help about that command "help pdb" pipes the full documentation file to the $PAGER @@ -820,7 +823,7 @@ self.help_w() def help_w(self): - print """w(here) + print >>self.stdout, """w(here) Print a stack trace, with the most recent frame at the bottom. An arrow indicates the "current frame", which determines the context of most commands. 'bt' is an alias for this command.""" @@ -831,7 +834,7 @@ self.help_d() def help_d(self): - print """d(own) + print >>self.stdout, """d(own) Move the current frame one level down in the stack trace (to a newer frame).""" @@ -839,7 +842,7 @@ self.help_u() def help_u(self): - print """u(p) + print >>self.stdout, """u(p) Move the current frame one level up in the stack trace (to an older frame).""" @@ -847,7 +850,7 @@ self.help_b() def help_b(self): - print """b(reak) ([file:]lineno | function) [, condition] + print >>self.stdout, """b(reak) ([file:]lineno | function) [, condition] With a line number argument, set a break there in the current file. With a function name, set a break at first executable line of that function. Without argument, list all breaks. If a second @@ -863,8 +866,8 @@ self.help_cl() def help_cl(self): - print "cl(ear) filename:lineno" - print """cl(ear) [bpnumber [bpnumber...]] + print >>self.stdout, "cl(ear) filename:lineno" + print >>self.stdout, """cl(ear) [bpnumber [bpnumber...]] With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation). With a filename:lineno argument, @@ -876,21 +879,21 @@ breakpoint numbers.""" def help_tbreak(self): - print """tbreak same arguments as break, but breakpoint is + print >>self.stdout, """tbreak same arguments as break, but breakpoint is removed when first hit.""" def help_enable(self): - print """enable bpnumber [bpnumber ...] + print >>self.stdout, """enable bpnumber [bpnumber ...] Enables the breakpoints given as a space separated list of bp numbers.""" def help_disable(self): - print """disable bpnumber [bpnumber ...] + print >>self.stdout, """disable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of bp numbers.""" def help_ignore(self): - print """ignore bpnumber count + print >>self.stdout, """ignore bpnumber count Sets the ignore count for the given breakpoint number. A breakpoint becomes active when the ignore count is zero. When non-zero, the count is decremented each time the breakpoint is reached and the @@ -898,7 +901,7 @@ to true.""" def help_condition(self): - print """condition bpnumber str_condition + print >>self.stdout, """condition bpnumber str_condition str_condition is a string specifying an expression which must evaluate to true before the breakpoint is honored. If str_condition is absent, any existing condition is removed; @@ -908,7 +911,7 @@ self.help_s() def help_s(self): - print """s(tep) + print >>self.stdout, """s(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or in the current function).""" @@ -916,7 +919,7 @@ self.help_n() def help_n(self): - print """n(ext) + print >>self.stdout, """n(ext) Continue execution until the next line in the current function is reached or it returns.""" @@ -924,7 +927,7 @@ self.help_r() def help_r(self): - print """r(eturn) + print >>self.stdout, """r(eturn) Continue execution until the current function returns.""" def help_continue(self): @@ -934,18 +937,18 @@ self.help_c() def help_c(self): - print """c(ont(inue)) + print >>self.stdout, """c(ont(inue)) Continue execution, only stop when a breakpoint is encountered.""" def help_jump(self): self.help_j() def help_j(self): - print """j(ump) lineno + print >>self.stdout, """j(ump) lineno Set the next line that will be executed.""" def help_debug(self): - print """debug code + print >>self.stdout, """debug code Enter a recursive debugger that steps through the code argument (which is an arbitrary expression or statement to be executed in the current environment).""" @@ -954,7 +957,7 @@ self.help_l() def help_l(self): - print """l(ist) [first [,last]] + print >>self.stdout, """l(ist) [first [,last]] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. @@ -966,19 +969,19 @@ self.help_a() def help_a(self): - print """a(rgs) + print >>self.stdout, """a(rgs) Print the arguments of the current function.""" def help_p(self): - print """p expression + print >>self.stdout, """p expression Print the value of the expression.""" def help_pp(self): - print """pp expression + print >>self.stdout, """pp expression Pretty-print the value of the expression.""" def help_exec(self): - print """(!) statement + print >>self.stdout, """(!) statement Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word @@ -992,21 +995,21 @@ self.help_q() def help_q(self): - print """q(uit) or exit - Quit from the debugger. + print >>self.stdout, """q(uit) or exit - Quit from the debugger. The program being executed is aborted.""" help_exit = help_q def help_whatis(self): - print """whatis arg + print >>self.stdout, """whatis arg Prints the type of the argument.""" def help_EOF(self): - print """EOF + print >>self.stdout, """EOF Handles the receipt of EOF as a command.""" def help_alias(self): - print """alias [name [command [parameter parameter ...] ]] + print >>self.stdout, """alias [name [command [parameter parameter ...] ]] Creates an alias called 'name' the executes 'command'. The command must *not* be enclosed in quotes. Replaceable parameters are indicated by %1, %2, and so on, while %* is replaced by all the @@ -1030,11 +1033,11 @@ """ def help_unalias(self): - print """unalias name + print >>self.stdout, """unalias name Deletes the specified alias.""" def help_commands(self): - print """commands [bpnumber] + print >>self.stdout, """commands [bpnumber] (com) ... (com) end (Pdb) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 10 19:13:20 2006 @@ -96,6 +96,10 @@ Library ------- +- Patch #721464: pdb.Pdb instances can now be given explicit stdin and + stdout arguments, making it possible to redirect input and output + for remote debugging. + - Patch #1484695: Update the tarfile module to version 0.8. This fixes a couple of issues, notably handling of long file names using the GNU LONGNAME extension. From python-checkins at python.org Wed May 10 19:19:05 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 10 May 2006 19:19:05 +0200 (CEST) Subject: [Python-checkins] r45956 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060510171905.80D7B1E4006@bag.python.org> Author: andrew.kuchling Date: Wed May 10 19:19:04 2006 New Revision: 45956 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Clarify description of exception handling Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Wed May 10 19:19:04 2006 @@ -392,13 +392,17 @@ \end{verbatim} The code in \var{block-1} is executed. If the code raises an -exception, the handlers are tried in order: \var{handler-1}, -\var{handler-2}, ... If no exception is raised, the \var{else-block} -is executed. No matter what happened previously, the -\var{final-block} is executed once the code block is complete and any -raised exceptions handled. Even if there's an error in an exception -handler or the \var{else-block} and a new exception is raised, the -\var{final-block} is still executed. +exception, the various \keyword{except} blocks are tested: if the +exception is of class \class{Exception1}, \var{handler-1} is executed; +otherwise if it's of class \class{Exception2}, \var{handler-2} is +executed, and so forth. If no exception is raised, the +\var{else-block} is executed. + +No matter what happened previously, the \var{final-block} is executed +once the code block is complete and any raised exceptions handled. +Even if there's an error in an exception handler or the +\var{else-block} and a new exception is raised, the +code in the \var{final-block} is still run. \begin{seealso} @@ -2065,6 +2069,6 @@ The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this article: Phillip J. Eby, Kent Johnson, Martin von~L\"owis, Fredrik Lundh, -Gustavo Niemeyer, James Pryor, Mike Rovner, Thomas Wouters. +Gustavo Niemeyer, James Pryor, Mike Rovner, Scott Weikart, Thomas Wouters. \end{document} From buildbot at python.org Wed May 10 20:03:29 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 18:03:29 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060510180330.19EF21E4002@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/61 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Wed May 10 21:26:46 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 10 May 2006 21:26:46 +0200 Subject: [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c In-Reply-To: <44621348.2020506@egenix.com> References: <20060506163302.CA3D71E4004@bag.python.org> <445CE018.7040609@egenix.com> <445D9B0C.5080808@v.loewis.de> <445DF658.7050609@egenix.com> <445E1E09.1040908@v.loewis.de> <445E3615.7000108@egenix.com> <445E433C.10908@v.loewis.de> <445F23BD.5040906@egenix.com> <445FC265.6060508@v.loewis.de> <44621348.2020506@egenix.com> Message-ID: <44623E76.8010505@v.loewis.de> M.-A. Lemburg wrote: >> I don't know how this table was generated (although I doubt it was >> generated that way); > > At the top of the file it says: > > /* doserrmap.h: auto-generated from winerror.h and errno.h using undoc'd > _dosmaperr. */ > > That's good enough for me. Ah, I see. > I tried to find a DLL that has the _dosmaperr API on my > Windows XP box and couldn't find it. It's probably inlined > in the C lib, so doesn't appear as symbol. > > There is such a function in the source code of the VC7 CRT > (in a file called dosmap.c). It's not inlined - it just isn't exported. Regards, Martin From python-checkins at python.org Wed May 10 22:09:24 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 22:09:24 +0200 (CEST) Subject: [Python-checkins] r45957 - python/trunk/Doc/lib/libdecimal.tex Message-ID: <20060510200924.66DC61E4002@bag.python.org> Author: georg.brandl Date: Wed May 10 22:09:23 2006 New Revision: 45957 Modified: python/trunk/Doc/lib/libdecimal.tex Log: Fix two small errors in argument lists. Modified: python/trunk/Doc/lib/libdecimal.tex ============================================================================== --- python/trunk/Doc/lib/libdecimal.tex (original) +++ python/trunk/Doc/lib/libdecimal.tex Wed May 10 22:09:23 2006 @@ -713,8 +713,8 @@ \constant{NaN}. \end{methoddesc} -\begin{methoddesc}{sqrt}{} - Return the square root to full precision. +\begin{methoddesc}{sqrt}{x} + Return the square root of \var{x} to full precision. \end{methoddesc} \begin{methoddesc}{subtract}{x, y} @@ -734,7 +734,7 @@ or \constant{Rounded}. \end{methoddesc} -\begin{methoddesc}{to_sci_string}{} +\begin{methoddesc}{to_sci_string}{x} Converts a number to a string using scientific notation. \end{methoddesc} From python-checkins at python.org Wed May 10 22:09:36 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 May 2006 22:09:36 +0200 (CEST) Subject: [Python-checkins] r45958 - python/branches/release24-maint/Doc/lib/libdecimal.tex Message-ID: <20060510200936.AD7391E4002@bag.python.org> Author: georg.brandl Date: Wed May 10 22:09:36 2006 New Revision: 45958 Modified: python/branches/release24-maint/Doc/lib/libdecimal.tex Log: Fix two small errors in argument lists. (backport from rev. 45957) Modified: python/branches/release24-maint/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libdecimal.tex (original) +++ python/branches/release24-maint/Doc/lib/libdecimal.tex Wed May 10 22:09:36 2006 @@ -689,8 +689,8 @@ \constant{NaN}. \end{methoddesc} -\begin{methoddesc}{sqrt}{} - Return the square root to full precision. +\begin{methoddesc}{sqrt}{x} + Return the square root of \var{x} to full precision. \end{methoddesc} \begin{methoddesc}{subtract}{x, y} @@ -710,7 +710,7 @@ or \constant{Rounded}. \end{methoddesc} -\begin{methoddesc}{to_sci_string}{} +\begin{methoddesc}{to_sci_string}{x} Converts a number to a string using scientific notation. \end{methoddesc} From buildbot at python.org Wed May 10 23:26:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 21:26:41 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060510212641.32ACC1E4002@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/95 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 10 23:42:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 10 May 2006 21:42:37 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060510214237.2BA971E4002@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.4/builds/58 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 11 05:55:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 03:55:28 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian trunk Message-ID: <20060511035528.A33991E4006@bag.python.org> The Buildbot has detected a new failure of MIPS Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%2520trunk/builds/89 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,georg.brandl Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Thu May 11 06:34:04 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 11 May 2006 06:34:04 +0200 (CEST) Subject: [Python-checkins] r45959 - peps/trunk/pep-0356.txt Message-ID: <20060511043404.3404E1E4007@bag.python.org> Author: neal.norwitz Date: Thu May 11 06:34:02 2006 New Revision: 45959 Modified: peps/trunk/pep-0356.txt Log: Anthony has done a fine job and doesn\'t seem to need any help. mwh wants to defer removing fpectl per py-dev mail. Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Thu May 11 06:34:02 2006 @@ -23,8 +23,6 @@ Release Manager Anthony Baxter has volunteered to be Release Manager. - Martin von Loewis, Barry Warsaw, and Neal Norwitz volunteered - to assist Anthony as Release Manager. Martin von Loewis is building the Windows installers, Ronald Oussoren is building the Mac installers, @@ -112,8 +110,6 @@ - Add @decorator decorator to functional, rename to functools? - - Remove the fpectl module? - - Modules under consideration for inclusion: - wsgiref to the standard library @@ -149,6 +145,8 @@ - pure python pgen module (Owner: Guido) + - Remove the fpectl module? + Open issues From nnorwitz at gmail.com Thu May 11 06:38:46 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 10 May 2006 21:38:46 -0700 Subject: [Python-checkins] r45947 - in python/trunk: Modules/_csv.c Modules/_elementtree.c Modules/_ssl.c Objects/longobject.c In-Reply-To: <9e804ac0605100114q70cbeb0ao75855b28172e687c@mail.gmail.com> References: <20060510065800.511AB1E4002@bag.python.org> <9e804ac0605100114q70cbeb0ao75855b28172e687c@mail.gmail.com> Message-ID: On 5/10/06, Thomas Wouters wrote: > > > On 5/10/06, neal.norwitz wrote: > > Modified: python/trunk/Modules/_ssl.c > > > ============================================================================== > > --- python/trunk/Modules/_ssl.c (original) > > +++ python/trunk/Modules/_ssl.c Wed May 10 08:57:58 2006 > > @@ -183,9 +183,9 @@ > > int sockstate; > > > > self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new > object */ > > - if (self == NULL){ > > - errstr = "newPySSLObject error"; > > - goto fail; > > + if (self == NULL) { > > + PyErr_SetString(PySSLErrorObject, > "newPySSLObject error"); > > + return NULL; > > } > > memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); > > memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); > > > Is there a reason this clobbers the exception set by PyObject_New()? > (Especially considering the useless error message the new exception contains > :) Good point. I didn't even think about changing the code, I was just fixing the Coverity warnings. I think MAL originally wrote this code. It doesn't seem like we should set the error here. MAL? n From python-checkins at python.org Thu May 11 07:11:34 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 11 May 2006 07:11:34 +0200 (CEST) Subject: [Python-checkins] r45960 - python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Message-ID: <20060511051134.B6A291E4009@bag.python.org> Author: brett.cannon Date: Thu May 11 07:11:33 2006 New Revision: 45960 Modified: python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Log: Detect if %zd is supported by printf() during configure and sets PY_SIZE_FORMAT_T appropriately. Removes warnings on OS X under gcc 4.0.1 when PY_SIZE_FORMAT_T is set to "" instead of "z" as is needed. Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Thu May 11 07:11:33 2006 @@ -21732,6 +21732,68 @@ echo "${ECHO_T}no" >&6 fi +echo "$as_me:$LINENO: checking for %zd printf() format support" >&5 +echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6 +if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int main() +{ + char buffer[4]; + + if(sprintf(buffer, "%zd", (size_t)123) < 0) + return 1; + + if (strncmp(buffer, "123", 3)) + return 1; + + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define PY_FORMAT_SIZE_T "z" +_ACEOF + +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + echo "$as_me:$LINENO: checking for socklen_t" >&5 echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 if test "${ac_cv_type_socklen_t+set}" = set; then Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Thu May 11 07:11:33 2006 @@ -3247,6 +3247,27 @@ AC_MSG_RESULT(no) fi +AC_MSG_CHECKING(for %zd printf() format support) +AC_TRY_RUN([#include +#include +#include + +int main() +{ + char buffer[4]; + + if(sprintf(buffer, "%zd", (size_t)123) < 0) + return 1; + + if (strncmp(buffer, "123", 3)) + return 1; + + return 0; +}], +[AC_MSG_RESULT(yes) + AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])], + AC_MSG_RESULT(no)) + AC_CHECK_TYPE(socklen_t,, AC_DEFINE(socklen_t,int, Define to `int' if does not define.),[ Modified: python/trunk/pyconfig.h.in ============================================================================== --- python/trunk/pyconfig.h.in (original) +++ python/trunk/pyconfig.h.in Thu May 11 07:11:33 2006 @@ -727,6 +727,9 @@ /* Defined if PTHREAD_SCOPE_SYSTEM supported. */ #undef PTHREAD_SYSTEM_SCHED_SUPPORTED +/* Define to printf format modifier for Py_ssize_t */ +#undef PY_FORMAT_SIZE_T + /* Define as the integral type used for Unicode representation. */ #undef PY_UNICODE_TYPE From python-checkins at python.org Thu May 11 07:14:36 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 11 May 2006 07:14:36 +0200 (CEST) Subject: [Python-checkins] r45960 - svn:log Message-ID: <20060511051436.437A01E4009@bag.python.org> Author: brett.cannon Revision: 45960 Property Name: svn:log New Property Value: Detect if %zd is supported by printf() during configure and sets PY_FORMAT_SIZE_T appropriately. Removes warnings on OS X under gcc 4.0.1 when PY_FORMAT_SIZE_T is set to "" instead of "z" as is needed. From python-checkins at python.org Thu May 11 08:59:29 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 11 May 2006 08:59:29 +0200 (CEST) Subject: [Python-checkins] r45961 - peps/trunk/pep-0000.txt Message-ID: <20060511065929.6AACA1E4007@bag.python.org> Author: neal.norwitz Date: Thu May 11 08:59:28 2006 New Revision: 45961 Modified: peps/trunk/pep-0000.txt Log: 359 was withdrawn Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Thu May 11 08:59:28 2006 @@ -96,7 +96,6 @@ S 354 Enumerations in Python Finney S 355 Path - Object oriented filesystem paths Lindqvist S 358 The "bytes" Object Schemenauer - S 359 The "make" Statement Bethard S 754 IEEE 754 Floating Point Special Values Warnes S 3101 Advanced String Formatting Talin S 3102 Keyword-Only Arguments Talin @@ -233,6 +232,7 @@ SR 348 Exception Reorganization for Python 3.0 Cannon SD 349 Allow str() to return unicode strings Schemenauer SR 351 The freeze protocol Warsaw + SW 359 The "make" Statement Bethard SR 666 Reject Foolish Indentation Creighton @@ -419,7 +419,7 @@ I 356 Python 2.5 Release Schedule Norwitz, et al SF 357 Allowing Any Object to be Used for Slicing Oliphant S 358 The "bytes" Object Schemenauer - S 359 The "make" Statement Bethard + SW 359 The "make" Statement Bethard SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes P 3000 Python 3000 GvR From mal at egenix.com Thu May 11 09:36:30 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 11 May 2006 09:36:30 +0200 Subject: [Python-checkins] r45947 - in python/trunk: Modules/_csv.c Modules/_elementtree.c Modules/_ssl.c Objects/longobject.c In-Reply-To: References: <20060510065800.511AB1E4002@bag.python.org> <9e804ac0605100114q70cbeb0ao75855b28172e687c@mail.gmail.com> Message-ID: <4462E97E.8050407@egenix.com> Neal Norwitz wrote: > On 5/10/06, Thomas Wouters wrote: >> >> >> On 5/10/06, neal.norwitz wrote: >> > Modified: python/trunk/Modules/_ssl.c >> > >> ============================================================================== >> >> > --- python/trunk/Modules/_ssl.c (original) >> > +++ python/trunk/Modules/_ssl.c Wed May 10 08:57:58 2006 >> > @@ -183,9 +183,9 @@ >> > int sockstate; >> > >> > self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new >> object */ >> > - if (self == NULL){ >> > - errstr = "newPySSLObject error"; >> > - goto fail; >> > + if (self == NULL) { >> > + PyErr_SetString(PySSLErrorObject, >> "newPySSLObject error"); >> > + return NULL; >> > } >> > memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); >> > memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); >> >> >> Is there a reason this clobbers the exception set by PyObject_New()? >> (Especially considering the useless error message the new exception >> contains >> :) > > Good point. I didn't even think about changing the code, I was just > fixing the Coverity warnings. I think MAL originally wrote this code. > It doesn't seem like we should set the error here. MAL? This is not my code - I only remember that it was contributed by some 3rd party. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 11 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From nnorwitz at gmail.com Thu May 11 09:45:42 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 11 May 2006 00:45:42 -0700 Subject: [Python-checkins] r45947 - in python/trunk: Modules/_csv.c Modules/_elementtree.c Modules/_ssl.c Objects/longobject.c In-Reply-To: <4462E97E.8050407@egenix.com> References: <20060510065800.511AB1E4002@bag.python.org> <9e804ac0605100114q70cbeb0ao75855b28172e687c@mail.gmail.com> <4462E97E.8050407@egenix.com> Message-ID: On 5/11/06, M.-A. Lemburg wrote: > Neal Norwitz wrote: > > On 5/10/06, Thomas Wouters wrote: > >> > >> > >> On 5/10/06, neal.norwitz wrote: > >> > Modified: python/trunk/Modules/_ssl.c > >> > > >> ============================================================================== > >> > >> > --- python/trunk/Modules/_ssl.c (original) > >> > +++ python/trunk/Modules/_ssl.c Wed May 10 08:57:58 2006 > >> > @@ -183,9 +183,9 @@ > >> > int sockstate; > >> > > >> > self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new > >> object */ > >> > - if (self == NULL){ > >> > - errstr = "newPySSLObject error"; > >> > - goto fail; > >> > + if (self == NULL) { > >> > + PyErr_SetString(PySSLErrorObject, > >> "newPySSLObject error"); > >> > + return NULL; > >> > } > >> > memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); > >> > memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); > >> > >> > >> Is there a reason this clobbers the exception set by PyObject_New()? > >> (Especially considering the useless error message the new exception > >> contains > >> :) > > > > Good point. I didn't even think about changing the code, I was just > > fixing the Coverity warnings. I think MAL originally wrote this code. > > It doesn't seem like we should set the error here. MAL? > > This is not my code - I only remember that it was contributed > by some 3rd party. Good enough for me. Fixing... n From python-checkins at python.org Thu May 11 09:50:33 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 11 May 2006 09:50:33 +0200 (CEST) Subject: [Python-checkins] r45962 - peps/trunk/pep-0000.txt peps/trunk/pep-0334.txt Message-ID: <20060511075033.4AB9B1E400B@bag.python.org> Author: neal.norwitz Date: Thu May 11 09:50:27 2006 New Revision: 45962 Modified: peps/trunk/pep-0000.txt peps/trunk/pep-0334.txt Log: 334 was withdrawn by author. move 298 where it belongs Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Thu May 11 09:50:27 2006 @@ -87,7 +87,6 @@ S 302 New Import Hooks JvR, Moore S 323 Copyable Iterators Martelli S 331 Locale-Independent Float/String Conversions Reis - S 334 Simple Coroutines via SuspendIteration Evans S 335 Overloadable Boolean Operators Ewing S 337 Logging Usage in the Standard Library Dubner S 344 Exception Chaining and Embedded Tracebacks Yee @@ -145,7 +144,6 @@ SF 289 Generator Expressions Hettinger SF 292 Simpler String Substitutions Warsaw SF 293 Codec Error Handling Callbacks D?rwald - SW 298 The Locked Buffer Interface Heller 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 @@ -210,6 +208,7 @@ SR 294 Type Names in the types Module Tirosh SR 295 Interpretation of multiline string constants Koltsov SR 296 Adding a bytes Object Type Gilbert + SW 298 The Locked Buffer Interface Heller SR 299 Special __main__() function in modules Epler SR 303 Extend divmod() for Multiple Divisors Bellman SW 304 Controlling Generation of Bytecode Files Montanaro @@ -226,6 +225,7 @@ SR 329 Treating Builtins as Constants in the Standard Library Hettinger SR 330 Python Bytecode Verification Pelletier SR 332 Byte vectors and String/Unicode Unification Montanaro + SW 334 Simple Coroutines via SuspendIteration Evans SR 336 Make None Callable McClelland SR 340 Anonymous Block Statements GvR SW 346 User Defined ("with") Statements Coghlan @@ -394,7 +394,7 @@ S 331 Locale-Independent Float/String Conversions Reis SR 332 Byte vectors and String/Unicode Unification Montanaro I 333 Python Web Server Gateway Interface v1.0 Eby - S 334 Simple Coroutines via SuspendIteration Evans + SW 334 Simple Coroutines via SuspendIteration Evans S 335 Overloadable Boolean Operators Ewing SR 336 Make None Callable McClelland S 337 Logging Usage in the Standard Library Dubner Modified: peps/trunk/pep-0334.txt ============================================================================== --- peps/trunk/pep-0334.txt (original) +++ peps/trunk/pep-0334.txt Thu May 11 09:50:27 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Clark C. Evans -Status: Draft +Status: Withdrawn Type: Standards Track Python-Version: 3.0 Content-Type: text/x-rst From python-checkins at python.org Thu May 11 09:51:59 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 11 May 2006 09:51:59 +0200 (CEST) Subject: [Python-checkins] r45963 - python/trunk/Modules/_ssl.c Message-ID: <20060511075159.592E81E400B@bag.python.org> Author: neal.norwitz Date: Thu May 11 09:51:59 2006 New Revision: 45963 Modified: python/trunk/Modules/_ssl.c Log: Don't mask a no memory error with a less meaningful one as discussed on python-checkins Modified: python/trunk/Modules/_ssl.c ============================================================================== --- python/trunk/Modules/_ssl.c (original) +++ python/trunk/Modules/_ssl.c Thu May 11 09:51:59 2006 @@ -183,10 +183,8 @@ int sockstate; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ - if (self == NULL) { - PyErr_SetString(PySSLErrorObject, "newPySSLObject error"); + if (self == NULL) return NULL; - } memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); self->server_cert = NULL; From buildbot at python.org Thu May 11 10:04:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 08:04:01 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060511080401.B61891E4007@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/233 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 11 15:28:44 2006 From: python-checkins at python.org (martin.v.loewis) Date: Thu, 11 May 2006 15:28:44 +0200 (CEST) Subject: [Python-checkins] r45964 - in python/trunk: Doc/lib/libexcs.tex Lib/mailbox.py Lib/tempfile.py Misc/NEWS PC/errmap.h PC/errmap.mak PC/generrmap.c Python/exceptions.c Message-ID: <20060511132844.C94AD1E4008@bag.python.org> Author: martin.v.loewis Date: Thu May 11 15:28:43 2006 New Revision: 45964 Added: python/trunk/PC/errmap.h (contents, props changed) python/trunk/PC/errmap.mak (contents, props changed) python/trunk/PC/generrmap.c (contents, props changed) Modified: python/trunk/Doc/lib/libexcs.tex python/trunk/Lib/mailbox.py python/trunk/Lib/tempfile.py python/trunk/Misc/NEWS python/trunk/Python/exceptions.c Log: Change WindowsError to carry the Win32 error code in winerror, and the DOS error code in errno. Revert changes where WindowsError catch blocks unnecessarily special-case OSError. Modified: python/trunk/Doc/lib/libexcs.tex ============================================================================== --- python/trunk/Doc/lib/libexcs.tex (original) +++ python/trunk/Doc/lib/libexcs.tex Thu May 11 15:28:43 2006 @@ -399,11 +399,15 @@ \begin{excdesc}{WindowsError} Raised when a Windows-specific error occurs or when the error number does not correspond to an \cdata{errno} value. The - \member{errno} and \member{strerror} values are created from the + \member{winerror} and \member{strerror} values are created from the return values of the \cfunction{GetLastError()} and \cfunction{FormatMessage()} functions from the Windows Platform API. + The \member{errno} value maps the \member{winerror} value to + corresponding \code{errno.h} values. This is a subclass of \exception{OSError}. \versionadded{2.0} +\versionchanged[Previous versions put the \cfunction{GetLastError()} +codes into \member{errno}]{2.5} \end{excdesc} \begin{excdesc}{ZeroDivisionError} Modified: python/trunk/Lib/mailbox.py ============================================================================== --- python/trunk/Lib/mailbox.py (original) +++ python/trunk/Lib/mailbox.py Thu May 11 15:28:43 2006 @@ -24,12 +24,6 @@ 'BabylMessage', 'MMDFMessage', 'UnixMailbox', 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ] -if sys.platform != 'win32': - # Define WindowsError so that we can use it in an except statement - # even on non-Windows systems - class WindowsError: - pass - class Mailbox: """A group of messages in a particular place.""" @@ -268,9 +262,6 @@ self.remove(key) except KeyError: pass - except WindowsError, e: - if e.errno != 2: # ERROR_FILE_NOT_FOUND - raise except OSError, e: if e.errno != errno.ENOENT: raise @@ -426,12 +417,6 @@ path = os.path.join(self._path, 'tmp', uniq) try: os.stat(path) - except WindowsError, e: - if e.errno == 2: # ERROR_FILE_NOT_FOUND - Maildir._count += 1 - return open(path, 'wb+') - else: - raise except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 @@ -579,12 +564,6 @@ self._file.close() try: os.rename(new_file.name, self._path) - except WindowsError, e: - if e.errno == 183: # ERROR_ALREADY_EXISTS - os.remove(self._path) - os.rename(new_file.name, self._path) - else: - raise except OSError, e: if e.errno == errno.EEXIST: os.remove(self._path) @@ -1856,13 +1835,6 @@ else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True - except WindowsError, e: - if e.errno == 183: # ERROR_ALREADY_EXISTS - os.remove(pre_lock.name) - raise ExternalClashError('dot lock unavailable: %s' % - f.name) - else: - raise except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) Modified: python/trunk/Lib/tempfile.py ============================================================================== --- python/trunk/Lib/tempfile.py (original) +++ python/trunk/Lib/tempfile.py Thu May 11 15:28:43 2006 @@ -327,10 +327,6 @@ try: _os.mkdir(file, 0700) return file - except WindowsError, e: - if e.errno == 183: # ERROR_ALREADY_EXISTS - continue # try again - raise except OSError, e: if e.errno == _errno.EEXIST: continue # try again Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu May 11 15:28:43 2006 @@ -12,6 +12,11 @@ Core and builtins ----------------- +- WindowsError now has two error code attributes: errno, which carries + the error values from errno.h, and winerror, which carries the error + values from winerror.h. Previous versions put the winerror.h values + (from GetLastError()) into the errno attribute. + - Patch #1475845: Raise IndentationError for unexpected indent. - Patch #1479181: split open() and file() from being aliases for each other. Added: python/trunk/PC/errmap.h ============================================================================== --- (empty file) +++ python/trunk/PC/errmap.h Thu May 11 15:28:43 2006 @@ -0,0 +1,78 @@ +/* Generated file. Do not edit. */ +int winerror_to_errno(int winerror) +{ + switch(winerror) { + case 2: return 2; + case 3: return 2; + case 4: return 24; + case 5: return 13; + case 6: return 9; + case 7: return 12; + case 8: return 12; + case 9: return 12; + case 10: return 7; + case 11: return 8; + case 15: return 2; + case 16: return 13; + case 17: return 18; + case 18: return 2; + case 19: return 13; + case 20: return 13; + case 21: return 13; + case 22: return 13; + case 23: return 13; + case 24: return 13; + case 25: return 13; + case 26: return 13; + case 27: return 13; + case 28: return 13; + case 29: return 13; + case 30: return 13; + case 31: return 13; + case 32: return 13; + case 33: return 13; + case 34: return 13; + case 35: return 13; + case 36: return 13; + case 53: return 2; + case 65: return 13; + case 67: return 2; + case 80: return 17; + case 82: return 13; + case 83: return 13; + case 89: return 11; + case 108: return 13; + case 109: return 32; + case 112: return 28; + case 114: return 9; + case 128: return 10; + case 129: return 10; + case 130: return 9; + case 132: return 13; + case 145: return 41; + case 158: return 13; + case 161: return 2; + case 164: return 11; + case 167: return 13; + case 183: return 17; + case 188: return 8; + case 189: return 8; + case 190: return 8; + case 191: return 8; + case 192: return 8; + case 193: return 8; + case 194: return 8; + case 195: return 8; + case 196: return 8; + case 197: return 8; + case 198: return 8; + case 199: return 8; + case 200: return 8; + case 201: return 8; + case 202: return 8; + case 206: return 2; + case 215: return 11; + case 1816: return 12; + default: return EINVAL; + } +} Added: python/trunk/PC/errmap.mak ============================================================================== --- (empty file) +++ python/trunk/PC/errmap.mak Thu May 11 15:28:43 2006 @@ -0,0 +1,5 @@ +errmap.h: generrmap.exe + .\generrmap.exe > errmap.h + +genermap.exe: generrmap.c + cl generrmap.c Added: python/trunk/PC/generrmap.c ============================================================================== --- (empty file) +++ python/trunk/PC/generrmap.c Thu May 11 15:28:43 2006 @@ -0,0 +1,20 @@ +#include +#include + +/* Extract the mapping of Win32 error codes to errno */ + +int main() +{ + int i; + printf("/* Generated file. Do not edit. */\n"); + printf("int winerror_to_errno(int winerror)\n"); + printf("{\n\tswitch(winerror) {\n"); + for(i=1; i < 65000; i++) { + _dosmaperr(i); + if (errno == EINVAL) + continue; + printf("\t\tcase %d: return %d;\n", i, errno); + } + printf("\t\tdefault: return EINVAL;\n"); + printf("\t}\n}\n"); +} Modified: python/trunk/Python/exceptions.c ============================================================================== --- python/trunk/Python/exceptions.c (original) +++ python/trunk/Python/exceptions.c Thu May 11 15:28:43 2006 @@ -704,15 +704,132 @@ {NULL, NULL} }; - - - PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); PyDoc_STRVAR(OSError__doc__, "OS system call failed."); #ifdef MS_WINDOWS +#include "errmap.h" + PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); + +static PyObject * +WindowsError__init__(PyObject *self, PyObject *args) +{ + PyObject *o_errcode, *result; + long errcode, posix_errno; + result = EnvironmentError__init__(self, args); + if (!result) + return NULL; + self = get_self(args); + if (!self) + goto failed; + /* Set errno to the POSIX errno, and winerror to the Win32 + error code. */ + o_errcode = PyObject_GetAttrString(self, "errno"); + if (!o_errcode) + goto failed; + errcode = PyInt_AsLong(o_errcode); + if (!errcode == -1 && PyErr_Occurred()) + goto failed; + posix_errno = winerror_to_errno(errcode); + if (PyObject_SetAttrString(self, "winerror", o_errcode) < 0) + goto failed; + Py_DECREF(o_errcode); + o_errcode = PyInt_FromLong(posix_errno); + if (!o_errcode) + goto failed; + if (PyObject_SetAttrString(self, "errno", o_errcode) < 0) + goto failed; + Py_DECREF(o_errcode); + return result; +failed: + /* Could not set errno. */ + Py_XDECREF(o_errcode); + Py_DECREF(self); + Py_DECREF(result); + return NULL; +} + +static PyObject * +WindowsError__str__(PyObject *self, PyObject *args) +{ + PyObject *originalself = self; + PyObject *filename; + PyObject *serrno; + PyObject *strerror; + PyObject *rtnval = NULL; + + if (!PyArg_ParseTuple(args, "O:__str__", &self)) + return NULL; + + filename = PyObject_GetAttrString(self, "filename"); + serrno = PyObject_GetAttrString(self, "winerror"); + strerror = PyObject_GetAttrString(self, "strerror"); + if (!filename || !serrno || !strerror) + goto finally; + + if (filename != Py_None) { + PyObject *fmt = PyString_FromString("[Error %s] %s: %s"); + PyObject *repr = PyObject_Repr(filename); + PyObject *tuple = PyTuple_New(3); + + if (!fmt || !repr || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(repr); + Py_XDECREF(tuple); + goto finally; + } + + PyTuple_SET_ITEM(tuple, 0, serrno); + PyTuple_SET_ITEM(tuple, 1, strerror); + PyTuple_SET_ITEM(tuple, 2, repr); + + rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); + Py_DECREF(tuple); + /* already freed because tuple owned only reference */ + serrno = NULL; + strerror = NULL; + } + else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { + PyObject *fmt = PyString_FromString("[Error %s] %s"); + PyObject *tuple = PyTuple_New(2); + + if (!fmt || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(tuple); + goto finally; + } + + PyTuple_SET_ITEM(tuple, 0, serrno); + PyTuple_SET_ITEM(tuple, 1, strerror); + + rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); + Py_DECREF(tuple); + /* already freed because tuple owned only reference */ + serrno = NULL; + strerror = NULL; + } + else + rtnval = EnvironmentError__str__(originalself, args); + + finally: + Py_XDECREF(filename); + Py_XDECREF(serrno); + Py_XDECREF(strerror); + return rtnval; +} + +static +PyMethodDef WindowsError_methods[] = { + {"__init__", WindowsError__init__, METH_VARARGS}, + {"__str__", WindowsError__str__, METH_VARARGS}, + {NULL, NULL} +}; #endif /* MS_WINDOWS */ #ifdef __VMS @@ -1760,7 +1877,7 @@ {"OSError", &PyExc_OSError, &PyExc_EnvironmentError, OSError__doc__}, #ifdef MS_WINDOWS {"WindowsError", &PyExc_WindowsError, &PyExc_OSError, - WindowsError__doc__}, +WindowsError__doc__, WindowsError_methods}, #endif /* MS_WINDOWS */ #ifdef __VMS {"VMSError", &PyExc_VMSError, &PyExc_OSError, From buildbot at python.org Thu May 11 15:57:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 13:57:19 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060511135719.E92481E400C@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/671 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 11 16:05:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 14:05:00 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060511140500.861A81E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/678 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 11 16:45:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 14:45:50 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060511144550.BF67A1E4009@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/347 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 11 17:53:29 2006 From: python-checkins at python.org (george.yoshida) Date: Thu, 11 May 2006 17:53:29 +0200 (CEST) Subject: [Python-checkins] r45965 - python/trunk/Doc/lib/libpdb.tex Message-ID: <20060511155329.AA3141E4008@bag.python.org> Author: george.yoshida Date: Thu May 11 17:53:27 2006 New Revision: 45965 Modified: python/trunk/Doc/lib/libpdb.tex Log: Grammar fix Modified: python/trunk/Doc/lib/libpdb.tex ============================================================================== --- python/trunk/Doc/lib/libpdb.tex (original) +++ python/trunk/Doc/lib/libpdb.tex Thu May 11 17:53:27 2006 @@ -178,12 +178,12 @@ \item[d(own)] Move the current frame one level down in the stack trace -(to an newer frame). +(to a newer frame). \item[u(p)] Move the current frame one level up in the stack trace -(to a older frame). +(to an older frame). \item[b(reak) \optional{\optional{\var{filename}:}\var{lineno}\code{\Large{|}}\var{function}\optional{, \var{condition}}}] From python-checkins at python.org Thu May 11 17:54:42 2006 From: python-checkins at python.org (george.yoshida) Date: Thu, 11 May 2006 17:54:42 +0200 (CEST) Subject: [Python-checkins] r45966 - python/branches/release24-maint/Doc/lib/libpdb.tex Message-ID: <20060511155442.15F0D1E4008@bag.python.org> Author: george.yoshida Date: Thu May 11 17:54:41 2006 New Revision: 45966 Modified: python/branches/release24-maint/Doc/lib/libpdb.tex Log: Grammar fix(backport r45965) Modified: python/branches/release24-maint/Doc/lib/libpdb.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libpdb.tex (original) +++ python/branches/release24-maint/Doc/lib/libpdb.tex Thu May 11 17:54:41 2006 @@ -178,12 +178,12 @@ \item[d(own)] Move the current frame one level down in the stack trace -(to an newer frame). +(to a newer frame). \item[u(p)] Move the current frame one level up in the stack trace -(to a older frame). +(to an older frame). \item[b(reak) \optional{\optional{\var{filename}:}\var{lineno}\code{\Large{|}}\var{function}\optional{, \var{condition}}}] From buildbot at python.org Thu May 11 18:01:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 16:01:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060511160104.B0C601E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/457 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,martin.v.loewis,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 11 18:32:25 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 11 May 2006 18:32:25 +0200 (CEST) Subject: [Python-checkins] r45967 - python/trunk/Doc/howto/unicode.rst Message-ID: <20060511163225.4611C1E4008@bag.python.org> Author: andrew.kuchling Date: Thu May 11 18:32:24 2006 New Revision: 45967 Modified: python/trunk/Doc/howto/unicode.rst Log: typo fix Modified: python/trunk/Doc/howto/unicode.rst ============================================================================== --- python/trunk/Doc/howto/unicode.rst (original) +++ python/trunk/Doc/howto/unicode.rst Thu May 11 18:32:24 2006 @@ -158,7 +158,7 @@ Encodings don't have to handle every possible Unicode character, and most encodings don't. For example, Python's default encoding is the 'ascii' encoding. The rules for converting a Unicode string into the -ASCII encoding are are simple; for each code point: +ASCII encoding are simple; for each code point: 1. If the code point is <128, each byte is the same as the value of the code point. @@ -721,7 +721,7 @@ Thanks to the following people who have noted errors or offered suggestions on this article: Nicholas Bastin, Marius Gedminas, Kent Johnson, Ken Krugler, -Marc-Andr? Lemburg, Martin von L?wis. +Marc-Andr? Lemburg, Martin von L?wis, Chad Whitacre. Version 1.0: posted August 5 2005. From buildbot at python.org Thu May 11 18:37:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 16:37:36 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo 2.4 Message-ID: <20060511163737.1F96F1E4008@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%25202.4/builds/131 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: george.yoshida BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From python-checkins at python.org Thu May 11 18:37:47 2006 From: python-checkins at python.org (tim.peters) Date: Thu, 11 May 2006 18:37:47 +0200 (CEST) Subject: [Python-checkins] r45968 - python/trunk/Lib/bsddb/test/test_thread.py Message-ID: <20060511163747.767601E4008@bag.python.org> Author: tim.peters Date: Thu May 11 18:37:42 2006 New Revision: 45968 Modified: python/trunk/Lib/bsddb/test/test_thread.py Log: BaseThreadedTestCase.setup(): stop special-casing WindowsError. Rev 45964 fiddled with WindowsError, and broke test_bsddb3 on all the Windows buildbot slaves as a result. This should repair it. Modified: python/trunk/Lib/bsddb/test/test_thread.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_thread.py (original) +++ python/trunk/Lib/bsddb/test/test_thread.py Thu May 11 18:37:42 2006 @@ -57,8 +57,6 @@ self.homeDir = homeDir try: os.mkdir(homeDir) - except WindowsError, e: - if e.errno <> 183: raise # ERROR_ALREADY_EXISTS except OSError, e: if e.errno <> errno.EEXIST: raise self.env = db.DBEnv() From python-checkins at python.org Thu May 11 21:57:12 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 May 2006 21:57:12 +0200 (CEST) Subject: [Python-checkins] r45969 - python/trunk/Lib/decimal.py Message-ID: <20060511195712.C1C241E4008@bag.python.org> Author: georg.brandl Date: Thu May 11 21:57:09 2006 New Revision: 45969 Modified: python/trunk/Lib/decimal.py Log: Typo fix. Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Thu May 11 21:57:09 2006 @@ -731,7 +731,7 @@ """x.__hash__() <==> hash(x)""" # 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) + # Normalization assures that hash(100E-1) == hash(10) if self._is_special: if self._isnan(): raise TypeError('Cannot hash a NaN value.') From buildbot at python.org Fri May 12 01:52:54 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 11 May 2006 23:52:54 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian 2.4 Message-ID: <20060511235254.BF3F61E4004@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.4/builds/0 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl,george.yoshida,martin.v.loewis,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 12 03:26:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 12 May 2006 01:26:20 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060512012620.B70031E4004@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/0 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,brett.cannon,georg.brandl,george.yoshida,martin.v.loewis,neal.norwitz,thomas.heller,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 12 03:58:01 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 12 May 2006 03:58:01 +0200 (CEST) Subject: [Python-checkins] r45970 - in python/trunk: Doc/api/newtypes.tex Misc/ACKS Misc/NEWS Message-ID: <20060512015801.089681E4004@bag.python.org> Author: tim.peters Date: Fri May 12 03:57:59 2006 New Revision: 45970 Modified: python/trunk/Doc/api/newtypes.tex python/trunk/Misc/ACKS python/trunk/Misc/NEWS Log: SF patch #1473132: Improve docs for tp_clear and tp_traverse, by Collin Winter. Bugfix candidate (but I'm not going to bother). Modified: python/trunk/Doc/api/newtypes.tex ============================================================================== --- python/trunk/Doc/api/newtypes.tex (original) +++ python/trunk/Doc/api/newtypes.tex Fri May 12 03:57:59 2006 @@ -883,8 +883,39 @@ \begin{cmemberdesc}{PyTypeObject}{traverseproc}{tp_traverse} An optional pointer to a traversal function for the garbage collector. This is only used if the \constant{Py_TPFLAGS_HAVE_GC} - flag bit is set. More information in section - \ref{supporting-cycle-detection} about garbage collection. + flag bit is set. More information about Python's garbage collection + scheme can be found in section \ref{supporting-cycle-detection}. + + The \member{tp_traverse} pointer is used by the garbage collector + to detect reference cycles. A typical implementation of a + \member{tp_traverse} function simply calls \cfunction{Py_VISIT()} on + each of the instance's members that are Python objects. For exampe, this + is function \cfunction{local_traverse} from the \module{thread} extension + module: + + \begin{verbatim} + static int + local_traverse(localobject *self, visitproc visit, void *arg) + { + Py_VISIT(self->args); + Py_VISIT(self->kw); + Py_VISIT(self->dict); + return 0; + } + \end{verbatim} + + Note that \cfunction{Py_VISIT()} is called only on those members that can + participate in reference cycles. Although there is also a + \samp{self->key} member, it can only be \NULL{} or a Python string and + therefore cannot be part of a reference cycle. + + On the other hand, even if you know a member can never be part of a cycle, + as a debugging aid you may want to visit it anyway just so the + \module{gc} module's \function{get_referents()} function will include it. + + Note that \cfunction{Py_VISIT()} requires the \var{visit} and \var{arg} + parameters to \cfunction{local_traverse} to have these specific names; + don't name them just anything. This field is inherited by subtypes together with \member{tp_clear} and the \constant{Py_TPFLAGS_HAVE_GC} flag bit: the flag bit, @@ -896,8 +927,57 @@ \begin{cmemberdesc}{PyTypeObject}{inquiry}{tp_clear} An optional pointer to a clear function for the garbage collector. This is only used if the \constant{Py_TPFLAGS_HAVE_GC} flag bit is - set. More information in section - \ref{supporting-cycle-detection} about garbage collection. + set. + + The \member{tp_clear} member function is used to break reference + cycles in cyclic garbage detected by the garbage collector. Taken + together, all \member{tp_clear} functions in the system must combine to + break all reference cycles. This is subtle, and if in any doubt supply a + \member{tp_clear} function. For example, the tuple type does not + implement a \member{tp_clear} function, because it's possible to prove + that no reference cycle can be composed entirely of tuples. Therefore + the \member{tp_clear} functions of other types must be sufficient to + break any cycle containing a tuple. This isn't immediately obvious, and + there's rarely a good reason to avoid implementing \member{tp_clear}. + + Implementations of \member{tp_clear} should drop the instance's + references to those of its members that may be Python objects, and set + its pointers to those members to \NULL{}, as in the following example: + + \begin{verbatim} + static int + local_clear(localobject *self) + { + Py_CLEAR(self->key); + Py_CLEAR(self->args); + Py_CLEAR(self->kw); + Py_CLEAR(self->dict); + return 0; + } + \end{verbatim} + + The \cfunction{Py_CLEAR()} macro should be used, because clearing + references is delicate: the reference to the contained object must not be + decremented until after the pointer to the contained object is set to + \NULL{}. This is because decrementing the reference count may cause + the contained object to become trash, triggering a chain of reclamation + activity that may include invoking arbitrary Python code (due to + finalizers, or weakref callbacks, associated with the contained object). + If it's possible for such code to reference \var{self} again, it's + important that the pointer to the contained object be \NULL{} at that + time, so that \var{self} knows the contained object can no longer be + used. The \cfunction{Py_CLEAR()} macro performs the operations in a + safe order. + + Because the goal of \member{tp_clear} functions is to break reference + cycles, it's not necessary to clear contained objects like Python strings + or Python integers, which can't participate in reference cycles. + On the other hand, it may be convenient to clear all contained Python + objects, and write the type's \member{tp_dealloc} function to + invoke \member{tp_clear}. + + More information about Python's garbage collection + scheme can be found in section \ref{supporting-cycle-detection}. This field is inherited by subtypes together with \member{tp_clear} and the \constant{Py_TPFLAGS_HAVE_GC} flag bit: the flag bit, Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Fri May 12 03:57:59 2006 @@ -658,6 +658,7 @@ Frank Willison Greg V. Wilson Jody Winston +Collin Winter Dik Winter Blake Winton Jean-Claude Wippler Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri May 12 03:57:59 2006 @@ -223,6 +223,8 @@ Documentation ------------- +- Patch #1473132: Improve docs for ``tp_clear`` and ``tp_traverse``. + - PEP 343: Added Context Types section to the library reference and attempted to bring other PEP 343 related documentation into line with the implementation and/or python-dev discussions. From python-checkins at python.org Fri May 12 05:25:16 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 12 May 2006 05:25:16 +0200 (CEST) Subject: [Python-checkins] r45971 - in sandbox/trunk/Overload3K: Overload3K.egg-info Overload3K.egg-info/PKG-INFO Overload3K.egg-info/SOURCES.txt Overload3K.egg-info/top_level.txt overloading.py overloading.txt setup.py Message-ID: <20060512032516.5C5471E4004@bag.python.org> Author: phillip.eby Date: Fri May 12 05:25:14 2006 New Revision: 45971 Added: sandbox/trunk/Overload3K/ sandbox/trunk/Overload3K/Overload3K.egg-info/ sandbox/trunk/Overload3K/Overload3K.egg-info/PKG-INFO (contents, props changed) sandbox/trunk/Overload3K/Overload3K.egg-info/SOURCES.txt (contents, props changed) sandbox/trunk/Overload3K/Overload3K.egg-info/top_level.txt (contents, props changed) sandbox/trunk/Overload3K/overloading.py (contents, props changed) sandbox/trunk/Overload3K/overloading.txt (contents, props changed) sandbox/trunk/Overload3K/setup.py (contents, props changed) Log: Proof-of-concept overloading with @defop for Py3K Added: sandbox/trunk/Overload3K/Overload3K.egg-info/PKG-INFO ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/Overload3K.egg-info/PKG-INFO Fri May 12 05:25:14 2006 @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: Overload3K +Version: 0.1 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN Added: sandbox/trunk/Overload3K/Overload3K.egg-info/SOURCES.txt ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/Overload3K.egg-info/SOURCES.txt Fri May 12 05:25:14 2006 @@ -0,0 +1,5 @@ +overloading.py +setup.py +Overload3K.egg-info/PKG-INFO +Overload3K.egg-info/SOURCES.txt +Overload3K.egg-info/top_level.txt Added: sandbox/trunk/Overload3K/Overload3K.egg-info/top_level.txt ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/Overload3K.egg-info/top_level.txt Fri May 12 05:25:14 2006 @@ -0,0 +1 @@ +overloading Added: sandbox/trunk/Overload3K/overloading.py ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/overloading.py Fri May 12 05:25:14 2006 @@ -0,0 +1,176 @@ +__all__ = ['signature', 'defop', 'overloaded', 'overload'] + +def signature(*args, **kw): + """Decorator to set a function's __signature__ + + In Py3K (or sooner), this would happen automatically done from argument + annotations + """ + def decorate(f): + f.__signature__ = args, kw + return f + return decorate + + +def defop(gf): + """Decorator to register a method with a generic function + + In Py3K, this would be replaced by a 'defop' statement. (Maybe in 2.x if + a ``__future__`` is used.) + """ + def decorate(f): + overload(gf, f) + return f + return decorate + + +class overloaded(object): + """A simple multi-dispatch implementation, w/caching""" + + def __init__(self, default=None): + self.registry = {} + if default: + self.__name__ = getattr(default,'__name__',None) + self.__signature__ = getattr(default,'__signature__',None) + self[None] = default + + def __call__(self, *args): + """Call the overloaded function.""" + types = tuple(map(type, args)) + func = self.cache.get(types) + if func is None: + self.cache[types] = func = self[types] + return func(*args) + + def __setitem__(self, signature, func): + self.registry[signature] = func + self.cache = self.registry.copy() + + def __getitem__(self, types): + registry = self.registry + if types in registry: + return registry[types] + best = [] + for sig in registry: + if not implies(types, sig): + continue # skip inapplicable signatures + to_remove = [] + for other in best: + if implies(other, sig): + if not implies(sig,other): + break # other dominates us, so don't include + # else we are overlapping, so add both + elif implies(sig,other): + # we dominate other, so it has to be removed + to_remove.append(other) + # else we are disjoint, so add both + else: + best.append(sig) + for other in to_remove: + best.remove(other) + if len(best)==1: + return registry[best[0]] + + # Perhaps these multiple candidates all have the + # same implementation? + funcs = set(self.registry[sig] for sig in best) + if len(funcs) == 1: + return funcs.pop() + + raise TypeError("ambigous methods; types=%r; candidates=%r" % + (types, best)) + + + at overloaded +def overload(gf, f): + """Add a method to an overloaded function""" + signature,kw = getattr(f,'__signature__',(None,None)) + gf[signature] = f + + + at overloaded +def implies(types, sig): + """Do `types` imply `sig`?""" + return False + +# Manually bootstrap tuple/None and anything/None comparisons; this +# has to be done before the first call of any overloaded functions, including +# overload() itself, which is called by @defop. So these bootstraps have to +# happen before we can use @defop. +# +implies[object, type(None)] = lambda s,t: True +implies[tuple, type(None)] = lambda s,t: True + + +# Now that that's taken care of, we can use @defop to define everything else + +# defop implies(s1:tuple, s2:tuple) +# + at defop(implies) + at signature(tuple, tuple) +def tuple_implies(sig, types): + if len(sig)!=len(types): + return False + for s,t in zip(sig,types): + if not type_matches(s,t): + return False + return True + + + at overloaded +def type_matches(t1,t2): + """Does `t1` match an argument of type `t2`?""" + return False + +type_matches[type, type] = issubclass + + + +# Now we can implement a kind of poor-man's typeclass, wherein we can treat +# a 1-argument generic function as if it were a type. This implementation is +# pretty crude, as a complete typeclass system should allow more sophisticated +# ways to specify the signature(s). But that will be left as an exercise for +# the reader at this point. ;) Note that with appropriate overloads of +# ``overload()``, ``type_matches()``, and ``implies()``, you can totally +# define your own framework for how overloads are chosen, so e.g. RuleDispatch +# could just provide overloads for these operations that work with its own +# generic function implementation and provide some extra decorators and +# type annotation objects to plug into the base system. + + +# defop type_matches(g1:type, g2:overloaded) +# + at defop(type_matches) + at signature(type, overloaded) +def type_implies_gf(t,gf): + """Here we implement the equivalent of issubclass(cls,genericfunction)""" + try: + return gf[t,] is not None + except TypeError: + return False + + +# defop type_matches(g1:overloaded, g2:overloaded) +# + at defop(type_matches) + at signature(overloaded, overloaded) +def gf_implies_gf(g1,g2): + """Here we implement the equivalent of issubclass(g1,g2)""" + for s in g1.registry: + try: + if g2[s] is None: + return False + except TypeError: + return False + else: + return True # g1 implies g2 if g2 has methods for all of g1's sigs + + +# Doctest suite here, picked up by "setup.py test" + +def additional_tests(): + import doctest + return doctest.DocFileSuite( + 'overloading.txt', optionflags=doctest.ELLIPSIS, package=__name__, + ) + Added: sandbox/trunk/Overload3K/overloading.txt ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/overloading.txt Fri May 12 05:25:14 2006 @@ -0,0 +1,117 @@ +Function/Operator Overloading Demo for Py3K +=========================================== + +Signature Definition +-------------------- + +Because existing versions of Python don't support argument type annotations, +we'll use a ``@signature`` decorator to tack a ``__signature__`` attribute on +to functions. Because the final format for ``__signature__`` isn't decided, +we'll use a very ad-hoc approach for now:: + + >>> from overloading import signature + + >>> @signature(int, int) + ... def intadd(a, b): + ... return a+b + + >>> intadd.__signature__ + ((, ), {}) + +We'll assume that it's straightforward to change code based on this ad-hoc +approach to use whatever is finally decided on for the ``__signature__`` +format. + + +Simple Overloading +------------------ + +We now need to be able to create overloaded function objects and add methods +to them. We'll use Guido's simple timing test cases:: + + >>> from overloading import overloaded, defop + + >>> class A(object): pass + >>> class B(object): pass + >>> class C(A, B): pass + + >>> def default(x, y): return "default" + + >>> @overloaded + ... def automatic(x, y): + ... return default(x, y) + + >>> automatic(1,2) + 'default' + + >>> @defop(automatic) + ... @signature(A, B) + ... def methodAB(x, y): return "AB" + + >>> @defop(automatic) + ... @signature(A, C) + ... def methodAC(x, y): return "AC" + + >>> @defop(automatic) + ... @signature(B, A) + ... def methodBA(x, y): return "BA" + + >>> @defop(automatic) + ... @signature(C, B) + ... def methodCB(x, y): return "CB" + + >>> automatic(A(), B()) + 'AB' + + >>> automatic(B(), C()) + 'BA' + + +Operation-based Overloading +--------------------------- + +We can define a signature by reference to an existing overloaded function. For +our example, we'll define a generic function for ``iter()``, registering the +built-in ``iter()`` function for various types. (Since we don't have a +built-in generic function type in Python yet.):: + + >>> my_iter = overloaded() + >>> my_iter[list] = my_iter[str] = my_iter[tuple] = iter + + >>> @defop(my_iter) + ... @signature(list) + ... def iter_list(ob): + ... return iter(ob) + + >>> @overloaded + ... def flatten(ob): + ... yield ob + + >>> @defop(flatten) + ... @signature(my_iter) + ... def flatten_iterable(ob): + ... for item in ob: + ... for item in flatten(item): + ... yield item + + >>> @defop(flatten) + ... @signature(basestring) + ... def flatten_stringlike(ob): + ... yield ob + + >>> list(flatten(None)) + [None] + + >>> list(flatten(["x", ["y", 1]])) + ['x', 'y', 1] + + + +Creating Custom Overloading +--------------------------- + +By overloading the ``type_matches()``, ``implies()``, and ``overloads()`` +functions, you can create your own specialized versions of @overloaded that use +custom dispatch rules. + + Added: sandbox/trunk/Overload3K/setup.py ============================================================================== --- (empty file) +++ sandbox/trunk/Overload3K/setup.py Fri May 12 05:25:14 2006 @@ -0,0 +1,9 @@ +from setuptools import setup + +setup( + name = "Overload3K", + version = "0.1", + py_modules = ['overloading'], + test_suite = 'overloading', +) + From python-checkins at python.org Fri May 12 05:26:15 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 12 May 2006 05:26:15 +0200 (CEST) Subject: [Python-checkins] r45972 - sandbox/trunk/Overload3K/Overload3K.egg-info Message-ID: <20060512032615.1F3391E4004@bag.python.org> Author: phillip.eby Date: Fri May 12 05:26:14 2006 New Revision: 45972 Removed: sandbox/trunk/Overload3K/Overload3K.egg-info/ Log: Remove unneeded .egg-info added during svn import From nnorwitz at gmail.com Fri May 12 05:34:23 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 11 May 2006 20:34:23 -0700 Subject: [Python-checkins] r45964 - in python/trunk: Doc/lib/libexcs.tex Lib/mailbox.py Lib/tempfile.py Misc/NEWS PC/errmap.h PC/errmap.mak PC/generrmap.c Python/exceptions.c In-Reply-To: <20060511132844.C94AD1E4008@bag.python.org> References: <20060511132844.C94AD1E4008@bag.python.org> Message-ID: On 5/11/06, martin.v.loewis wrote: > Modified: python/trunk/Python/exceptions.c > ============================================================================== > --- python/trunk/Python/exceptions.c (original) > +++ python/trunk/Python/exceptions.c Thu May 11 15:28:43 2006 > @@ -704,15 +704,132 @@ > {NULL, NULL} > }; > > - > - > - > PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); > > PyDoc_STRVAR(OSError__doc__, "OS system call failed."); > > #ifdef MS_WINDOWS > +#include "errmap.h" > + > PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); > + > +static PyObject * > +WindowsError__init__(PyObject *self, PyObject *args) > +{ > + PyObject *o_errcode, *result; > + long errcode, posix_errno; > + result = EnvironmentError__init__(self, args); > + if (!result) > + return NULL; > + self = get_self(args); > + if (!self) > + goto failed; ... > +failed: > + /* Could not set errno. */ > + Py_XDECREF(o_errcode); > + Py_DECREF(self); > + Py_DECREF(result); > + return NULL; > +} self needs an XDECREF. > +static PyObject * > +WindowsError__str__(PyObject *self, PyObject *args) > +{ > + PyObject *originalself = self; > + PyObject *filename; > + PyObject *serrno; > + PyObject *strerror; > + PyObject *rtnval = NULL; > + > + if (!PyArg_ParseTuple(args, "O:__str__", &self)) > + return NULL; > + > + filename = PyObject_GetAttrString(self, "filename"); > + serrno = PyObject_GetAttrString(self, "winerror"); > + strerror = PyObject_GetAttrString(self, "strerror"); > + if (!filename || !serrno || !strerror) > + goto finally; > + > + if (filename != Py_None) { > + PyObject *fmt = PyString_FromString("[Error %s] %s: %s"); > + PyObject *repr = PyObject_Repr(filename); > + PyObject *tuple = PyTuple_New(3); > + > + if (!fmt || !repr || !tuple) { > + Py_XDECREF(fmt); > + Py_XDECREF(repr); > + Py_XDECREF(tuple); > + goto finally; > + } > + > + PyTuple_SET_ITEM(tuple, 0, serrno); > + PyTuple_SET_ITEM(tuple, 1, strerror); > + PyTuple_SET_ITEM(tuple, 2, repr); > + > + rtnval = PyString_Format(fmt, tuple); > + > + Py_DECREF(fmt); Doesn't repr need to be DECREF'd here? You could use PyTuple_Pack() insead of _New() and SET_ITEM (above and below). It would be a bit shorter I think. > + Py_DECREF(tuple); > + /* already freed because tuple owned only reference */ > + serrno = NULL; > + strerror = NULL; > + } > +static > +PyMethodDef WindowsError_methods[] = { > + {"__init__", WindowsError__init__, METH_VARARGS}, > + {"__str__", WindowsError__str__, METH_VARARGS}, > + {NULL, NULL} > +}; You could use METH_O for __str__. n From python-checkins at python.org Fri May 12 08:59:15 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 12 May 2006 08:59:15 +0200 (CEST) Subject: [Python-checkins] r45973 - peps/trunk/pep-0356.txt Message-ID: <20060512065915.D057A1E4004@bag.python.org> Author: neal.norwitz Date: Fri May 12 08:59:14 2006 New Revision: 45973 Modified: peps/trunk/pep-0356.txt Log: msilib docs are done Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Fri May 12 08:59:14 2006 @@ -153,7 +153,6 @@ - Missing documentation * ctypes (Thomas Heller) * ElementTree/cElementTree (Fredrik Lundh) - * msilib (Martin von Loewis) * pysqlite (Gerhard Haering) * setuptools (written, needs conversion to proper format) From python-checkins at python.org Fri May 12 14:27:29 2006 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 12 May 2006 14:27:29 +0200 (CEST) Subject: [Python-checkins] r45974 - in python/trunk: Misc/NEWS Modules/posixmodule.c Message-ID: <20060512122729.B08551E4004@bag.python.org> Author: martin.v.loewis Date: Fri May 12 14:27:28 2006 New Revision: 45974 Modified: python/trunk/Misc/NEWS python/trunk/Modules/posixmodule.c Log: Dynamically allocate path name buffer for Unicode path name in listdir. Fixes #1431582. Stop overallocating MAX_PATH characters for ANSI path names. Stop assigning to errno. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri May 12 14:27:28 2006 @@ -72,6 +72,9 @@ Extension Modules ----------------- +- On Win32, os.listdir now supports arbitrarily-long Unicode path names + (up to the system limit of 32K characters). + - Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. As a result, these functions now raise WindowsError instead of OSError. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Fri May 12 14:27:28 2006 @@ -1782,37 +1782,46 @@ HANDLE hFindFile; BOOL result; WIN32_FIND_DATA FileData; - /* MAX_PATH characters could mean a bigger encoded string */ - char namebuf[MAX_PATH*2+5]; + char namebuf[MAX_PATH+5]; /* Overallocate for \\*.*\0 */ char *bufptr = namebuf; - Py_ssize_t len = sizeof(namebuf)/sizeof(namebuf[0]); + Py_ssize_t len = sizeof(namebuf)-5; /* only claim to have space for MAX_PATH */ #ifdef Py_WIN_WIDE_FILENAMES /* If on wide-character-capable OS see if argument is Unicode and if so use wide API. */ if (unicode_file_names()) { - PyUnicodeObject *po; + PyObject *po; if (PyArg_ParseTuple(args, "U:listdir", &po)) { WIN32_FIND_DATAW wFileData; - Py_UNICODE wnamebuf[MAX_PATH*2+5]; + Py_UNICODE *wnamebuf; Py_UNICODE wch; - wcsncpy(wnamebuf, PyUnicode_AS_UNICODE(po), MAX_PATH); - wnamebuf[MAX_PATH] = L'\0'; - len = wcslen(wnamebuf); - wch = (len > 0) ? wnamebuf[len-1] : L'\0'; + /* Overallocate for \\*.*\0 */ + len = PyUnicode_GET_SIZE(po); + wnamebuf = malloc((len + 5) * sizeof(wchar_t)); + if (!wnamebuf) { + PyErr_NoMemory(); + return NULL; + } + wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po)); + wch = len > 0 ? wnamebuf[len-1] : '\0'; if (wch != L'/' && wch != L'\\' && wch != L':') - wnamebuf[len++] = L'/'; + wnamebuf[len++] = L'\\'; wcscpy(wnamebuf + len, L"*.*"); - if ((d = PyList_New(0)) == NULL) + if ((d = PyList_New(0)) == NULL) { + free(wnamebuf); return NULL; + } hFindFile = FindFirstFileW(wnamebuf, &wFileData); if (hFindFile == INVALID_HANDLE_VALUE) { - errno = GetLastError(); - if (errno == ERROR_FILE_NOT_FOUND) { + int error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) { + free(wnamebuf); return d; } Py_DECREF(d); - return win32_error_unicode("FindFirstFileW", wnamebuf); + win32_error_unicode("FindFirstFileW", wnamebuf); + free(wnamebuf); + return NULL; } do { /* Skip over . and .. */ @@ -1839,7 +1848,9 @@ if (FindClose(hFindFile) == FALSE) { Py_DECREF(d); - return win32_error_unicode("FindClose", wnamebuf); + win32_error_unicode("FindClose", wnamebuf); + free(wnamebuf); + return NULL; } return d; } @@ -1864,8 +1875,8 @@ hFindFile = FindFirstFile(namebuf, &FileData); if (hFindFile == INVALID_HANDLE_VALUE) { - errno = GetLastError(); - if (errno == ERROR_FILE_NOT_FOUND) + int error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) return d; Py_DECREF(d); return win32_error("FindFirstFile", namebuf); From python-checkins at python.org Fri May 12 15:57:37 2006 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 12 May 2006 15:57:37 +0200 (CEST) Subject: [Python-checkins] r45975 - python/trunk/Tools/msi/msi.py Message-ID: <20060512135737.93E921E4004@bag.python.org> Author: martin.v.loewis Date: Fri May 12 15:57:36 2006 New Revision: 45975 Modified: python/trunk/Tools/msi/msi.py Log: Move icon files into DLLs dir. Fixes #1477968. Modified: python/trunk/Tools/msi/msi.py ============================================================================== --- python/trunk/Tools/msi/msi.py (original) +++ python/trunk/Tools/msi/msi.py Fri May 12 15:57:36 2006 @@ -846,8 +846,6 @@ default_feature.set_current() if not msilib.Win64: root.add_file("PCBuild/w9xpopen.exe") - root.add_file("PC/py.ico") - root.add_file("PC/pyc.ico") root.add_file("README.txt", src="README") root.add_file("NEWS.txt", src="Misc/NEWS") root.add_file("LICENSE.txt", src="LICENSE") @@ -956,6 +954,8 @@ # Add DLLs default_feature.set_current() lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs") + lib.add_file("py.ico", src="../PC/py.ico") + lib.add_file("pyc.ico", src="../PC/pyc.ico") dlls = [] tclfiles = [] for f in extensions: @@ -1124,11 +1124,11 @@ ] + tcl_verbs + [ #Icons ("py.icon", -1, pat2 % (testprefix, ""), "", - r'[TARGETDIR]py.ico', "REGISTRY.def"), + r'[DLLs]py.ico', "REGISTRY.def"), ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "", - r'[TARGETDIR]py.ico', "REGISTRY.def"), + r'[DLLs]py.ico', "REGISTRY.def"), ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "", - r'[TARGETDIR]pyc.ico', "REGISTRY.def"), + r'[DLLs]pyc.ico', "REGISTRY.def"), # Descriptions ("py.txt", -1, pat3 % (testprefix, ""), "", "Python File", "REGISTRY.def"), From buildbot at python.org Fri May 12 17:45:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 12 May 2006 15:45:10 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060512154510.66C761E400E@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/113 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 12 18:40:12 2006 From: python-checkins at python.org (george.yoshida) Date: Fri, 12 May 2006 18:40:12 +0200 (CEST) Subject: [Python-checkins] r45976 - python/trunk/Doc/ref/ref7.tex Message-ID: <20060512164012.195241E4009@bag.python.org> Author: george.yoshida Date: Fri May 12 18:40:11 2006 New Revision: 45976 Modified: python/trunk/Doc/ref/ref7.tex Log: At first there were 6 steps, but one was removed after that. Modified: python/trunk/Doc/ref/ref7.tex ============================================================================== --- python/trunk/Doc/ref/ref7.tex (original) +++ python/trunk/Doc/ref/ref7.tex Fri May 12 18:40:11 2006 @@ -340,7 +340,7 @@ \method{__enter__()} method returns without an error, then \method{__exit__()} will always be called. Thus, if an error occurs during the assignment to the target list, it will be treated the same as -an error occurring within the suite would be. See step 6 below.} +an error occurring within the suite would be. See step 5 below.} \item The suite is executed. From python-checkins at python.org Fri May 12 19:22:05 2006 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 12 May 2006 19:22:05 +0200 (CEST) Subject: [Python-checkins] r45977 - python/trunk/Modules/posixmodule.c Message-ID: <20060512172205.3D92C1E4009@bag.python.org> Author: martin.v.loewis Date: Fri May 12 19:22:04 2006 New Revision: 45977 Modified: python/trunk/Modules/posixmodule.c Log: Fix alignment error on Itanium. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Fri May 12 19:22:04 2006 @@ -763,8 +763,11 @@ static void FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out) { - /* XXX endianness */ - __int64 in = *(__int64*)in_ptr; + /* XXX endianness. Shouldn't matter, as all Windows implementations are little-endian */ + /* Cannot simply cast and dereference in_ptr, + since it might not be aligned properly */ + __int64 in; + memcpy(&in, in_ptr, sizeof(in)); *nsec_out = (int)(in % 10000000) * 100; /* FILETIME is in units of 100 nsec. */ /* XXX Win32 supports time stamps past 2038; we currently don't */ *time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, int); @@ -777,7 +780,7 @@ __int64 out; out = time_in + secs_between_epochs; out = out * 10000000 + nsec_in; - *(__int64*)out_ptr = out; + memcpy(out_ptr, &out, sizeof(out)); } /* Below, we *know* that ugo+r is 0444 */ From python-checkins at python.org Fri May 12 19:25:26 2006 From: python-checkins at python.org (george.yoshida) Date: Fri, 12 May 2006 19:25:26 +0200 (CEST) Subject: [Python-checkins] r45978 - python/trunk/Doc/ref/ref7.tex Message-ID: <20060512172526.B97081E4009@bag.python.org> Author: george.yoshida Date: Fri May 12 19:25:26 2006 New Revision: 45978 Modified: python/trunk/Doc/ref/ref7.tex Log: Duplicated description about the illegal continue usage can be found in nearly the same place. They are same, so keep the original one and remove the later-added one. Modified: python/trunk/Doc/ref/ref7.tex ============================================================================== --- python/trunk/Doc/ref/ref7.tex (original) +++ python/trunk/Doc/ref/ref7.tex Fri May 12 19:25:26 2006 @@ -287,11 +287,8 @@ it is re-raised at the end of the \keyword{finally} clause. If the \keyword{finally} clause raises another exception or executes a \keyword{return} or \keyword{break} statement, the saved -exception is lost. A \keyword{continue} statement is illegal in the -\keyword{finally} clause. (The reason is a problem with the current -implementation -- this restriction may be lifted in the future). The -exception information is not available to the program during execution of -the \keyword{finally} clause. +exception is lost. The exception information is not available to the +program during execution of the \keyword{finally} clause. \kwindex{finally} When a \keyword{return}, \keyword{break} or \keyword{continue} statement is From python-checkins at python.org Fri May 12 19:26:56 2006 From: python-checkins at python.org (george.yoshida) Date: Fri, 12 May 2006 19:26:56 +0200 (CEST) Subject: [Python-checkins] r45979 - python/branches/release24-maint/Doc/ref/ref7.tex Message-ID: <20060512172656.819911E4009@bag.python.org> Author: george.yoshida Date: Fri May 12 19:26:56 2006 New Revision: 45979 Modified: python/branches/release24-maint/Doc/ref/ref7.tex Log: Duplicated description about the illegal continue usage can be found in nearly the same place. They are same, so keep the original one and remove the later-added one. (backport r45978) Modified: python/branches/release24-maint/Doc/ref/ref7.tex ============================================================================== --- python/branches/release24-maint/Doc/ref/ref7.tex (original) +++ python/branches/release24-maint/Doc/ref/ref7.tex Fri May 12 19:26:56 2006 @@ -284,11 +284,8 @@ \keyword{finally} clause is executed, and then the saved exception is re-raised. If the \keyword{finally} clause raises another exception or executes a \keyword{return} or \keyword{break} statement, the saved -exception is lost. A \keyword{continue} statement is illegal in the -\keyword{finally} clause. (The reason is a problem with the current -implementation -- this restriction may be lifted in the future). The -exception information is not available to the program during execution of -the \keyword{finally} clause. +exception is lost. The exception information is not available to the +program during execution of the \keyword{finally} clause. \kwindex{finally} When a \keyword{return}, \keyword{break} or \keyword{continue} statement is From python-checkins at python.org Fri May 12 20:16:04 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 12 May 2006 20:16:04 +0200 (CEST) Subject: [Python-checkins] r45980 - python/trunk/Lib/ctypes/util.py Message-ID: <20060512181604.232E41E4015@bag.python.org> Author: thomas.heller Date: Fri May 12 20:16:03 2006 New Revision: 45980 Modified: python/trunk/Lib/ctypes/util.py (contents, props changed) Log: Add missing svn properties. Modified: python/trunk/Lib/ctypes/util.py ============================================================================== --- python/trunk/Lib/ctypes/util.py (original) +++ python/trunk/Lib/ctypes/util.py Fri May 12 20:16:03 2006 @@ -1,122 +1,122 @@ -import sys, os -import ctypes - -# find_library(name) returns the pathname of a library, or None. -if os.name == "nt": - def find_library(name): - # See MSDN for the REAL search order. - for directory in os.environ['PATH'].split(os.pathsep): - fname = os.path.join(directory, name) - if os.path.exists(fname): - return fname - if fname.lower().endswith(".dll"): - continue - fname = fname + ".dll" - if os.path.exists(fname): - return fname - return None - -if os.name == "ce": - # search path according to MSDN: - # - absolute path specified by filename - # - The .exe launch directory - # - the Windows directory - # - ROM dll files (where are they?) - # - OEM specified search path: HKLM\Loader\SystemPath - def find_library(name): - return name - -if os.name == "posix" and sys.platform == "darwin": - from ctypes.macholib.dyld import dyld_find as _dyld_find - def find_library(name): - possible = ['lib%s.dylib' % name, - '%s.dylib' % name, - '%s.framework/%s' % (name, name)] - for name in possible: - try: - return _dyld_find(name) - except ValueError: - continue - return None - -elif os.name == "posix": - # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump - import re, tempfile - - def _findLib_gcc(name): - expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name - cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ - '$CC -Wl,-t -o /dev/null 2>&1 -l' + name - try: - fdout, outfile = tempfile.mkstemp() - fd = os.popen(cmd) - trace = fd.read() - err = fd.close() - finally: - try: - os.unlink(outfile) - except OSError, e: - if e.errno != errno.ENOENT: - raise - res = re.search(expr, trace) - if not res: - return None - return res.group(0) - - def _findLib_ld(name): - expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name - res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) - if not res: - # Hm, this works only for libs needed by the python executable. - cmd = 'ldd %s 2>/dev/null' % sys.executable - res = re.search(expr, os.popen(cmd).read()) - if not res: - return None - return res.group(0) - - def _get_soname(f): - cmd = "objdump -p -j .dynamic 2>/dev/null " + f - res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) - if not res: - return None - return res.group(1) - - def find_library(name): - lib = _findLib_ld(name) or _findLib_gcc(name) - if not lib: - return None - return _get_soname(lib) - -################################################################ -# test code - -def test(): - from ctypes import cdll - if os.name == "nt": - print cdll.msvcrt - print cdll.load("msvcrt") - print find_library("msvcrt") - - if os.name == "posix": - # find and load_version - print find_library("m") - print find_library("c") - print find_library("bz2") - - # getattr -## print cdll.m -## print cdll.bz2 - - # load - if sys.platform == "darwin": - print cdll.LoadLibrary("libm.dylib") - print cdll.LoadLibrary("libcrypto.dylib") - print cdll.LoadLibrary("libSystem.dylib") - print cdll.LoadLibrary("System.framework/System") - else: - print cdll.LoadLibrary("libm.so") - print cdll.LoadLibrary("libcrypt.so") - print find_library("crypt") - -if __name__ == "__main__": - test() +import sys, os +import ctypes + +# find_library(name) returns the pathname of a library, or None. +if os.name == "nt": + def find_library(name): + # See MSDN for the REAL search order. + for directory in os.environ['PATH'].split(os.pathsep): + fname = os.path.join(directory, name) + if os.path.exists(fname): + return fname + if fname.lower().endswith(".dll"): + continue + fname = fname + ".dll" + if os.path.exists(fname): + return fname + return None + +if os.name == "ce": + # search path according to MSDN: + # - absolute path specified by filename + # - The .exe launch directory + # - the Windows directory + # - ROM dll files (where are they?) + # - OEM specified search path: HKLM\Loader\SystemPath + def find_library(name): + return name + +if os.name == "posix" and sys.platform == "darwin": + from ctypes.macholib.dyld import dyld_find as _dyld_find + def find_library(name): + possible = ['lib%s.dylib' % name, + '%s.dylib' % name, + '%s.framework/%s' % (name, name)] + for name in possible: + try: + return _dyld_find(name) + except ValueError: + continue + return None + +elif os.name == "posix": + # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump + import re, tempfile + + def _findLib_gcc(name): + expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name + cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ + '$CC -Wl,-t -o /dev/null 2>&1 -l' + name + try: + fdout, outfile = tempfile.mkstemp() + fd = os.popen(cmd) + trace = fd.read() + err = fd.close() + finally: + try: + os.unlink(outfile) + except OSError, e: + if e.errno != errno.ENOENT: + raise + res = re.search(expr, trace) + if not res: + return None + return res.group(0) + + def _findLib_ld(name): + expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name + res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) + if not res: + # Hm, this works only for libs needed by the python executable. + cmd = 'ldd %s 2>/dev/null' % sys.executable + res = re.search(expr, os.popen(cmd).read()) + if not res: + return None + return res.group(0) + + def _get_soname(f): + cmd = "objdump -p -j .dynamic 2>/dev/null " + f + res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) + if not res: + return None + return res.group(1) + + def find_library(name): + lib = _findLib_ld(name) or _findLib_gcc(name) + if not lib: + return None + return _get_soname(lib) + +################################################################ +# test code + +def test(): + from ctypes import cdll + if os.name == "nt": + print cdll.msvcrt + print cdll.load("msvcrt") + print find_library("msvcrt") + + if os.name == "posix": + # find and load_version + print find_library("m") + print find_library("c") + print find_library("bz2") + + # getattr +## print cdll.m +## print cdll.bz2 + + # load + if sys.platform == "darwin": + print cdll.LoadLibrary("libm.dylib") + print cdll.LoadLibrary("libcrypto.dylib") + print cdll.LoadLibrary("libSystem.dylib") + print cdll.LoadLibrary("System.framework/System") + else: + print cdll.LoadLibrary("libm.so") + print cdll.LoadLibrary("libcrypt.so") + print find_library("crypt") + +if __name__ == "__main__": + test() From python-checkins at python.org Fri May 12 20:47:36 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 12 May 2006 20:47:36 +0200 (CEST) Subject: [Python-checkins] r45981 - python/trunk/Lib/ctypes/test/test_unaligned_structures.py Message-ID: <20060512184736.B18991E400C@bag.python.org> Author: thomas.heller Date: Fri May 12 20:47:35 2006 New Revision: 45981 Modified: python/trunk/Lib/ctypes/test/test_unaligned_structures.py (props changed) Log: set svn properties From buildbot at python.org Fri May 12 21:19:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 12 May 2006 19:19:36 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060512191936.BACF51E400B@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/23 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 12 21:31:46 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 12 May 2006 21:31:46 +0200 (CEST) Subject: [Python-checkins] r45982 - python/trunk/Lib/ctypes/test/test_find.py Message-ID: <20060512193146.B90501E400B@bag.python.org> Author: thomas.heller Date: Fri May 12 21:31:46 2006 New Revision: 45982 Modified: python/trunk/Lib/ctypes/test/test_find.py (contents, props changed) Log: add svn:eol-style native svn:keywords Id Modified: python/trunk/Lib/ctypes/test/test_find.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_find.py (original) +++ python/trunk/Lib/ctypes/test/test_find.py Fri May 12 21:31:46 2006 @@ -1,104 +1,104 @@ -import unittest -import os, sys -from ctypes import * -from ctypes.util import find_library -from ctypes.test import is_resource_enabled - -if sys.platform == "win32": - lib_gl = find_library("OpenGL32") - lib_glu = find_library("Glu32") - lib_glut = find_library("glut32") - lib_gle = None -elif sys.platform == "darwin": - lib_gl = lib_glu = find_library("OpenGL") - lib_glut = find_library("GLUT") - lib_gle = None -else: - lib_gl = find_library("GL") - lib_glu = find_library("GLU") - lib_glut = find_library("glut") - lib_gle = find_library("gle") - -## print, for debugging -if is_resource_enabled("printing"): - if lib_gl or lib_glu or lib_glut or lib_gle: - print "OpenGL libraries:" - for item in (("GL", lib_gl), - ("GLU", lib_glu), - ("glut", lib_glut), - ("gle", lib_gle)): - print "\t", item - - -# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. -class Test_OpenGL_libs(unittest.TestCase): - def setUp(self): - self.gl = self.glu = self.gle = self.glut = None - if lib_gl: - self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL) - if lib_glu: - self.glu = CDLL(lib_glu, RTLD_GLOBAL) - if lib_glut: - # On some systems, additional libraries seem to be - # required, loading glut fails with - # "OSError: /usr/lib/libglut.so.3: undefined symbol: XGetExtensionVersion" - # I cannot figure out how to repair the test on these - # systems (red hat), so we ignore it when the glut or gle - # libraries cannot be loaded. See also: - # https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1478253&group_id=5470 - # http://mail.python.org/pipermail/python-dev/2006-May/064789.html - try: - self.glut = CDLL(lib_glut) - except OSError: - pass - if lib_gle: - try: - self.gle = CDLL(lib_gle) - except OSError: - pass - - if lib_gl: - def test_gl(self): - if self.gl: - self.gl.glClearIndex - - if lib_glu: - def test_glu(self): - if self.glu: - self.glu.gluBeginCurve - - if lib_glut: - def test_glut(self): - if self.glut: - self.glut.glutWireTetrahedron - - if lib_gle: - def test_gle(self): - if self.gle: - self.gle.gleGetJoinStyle - -##if os.name == "posix" and sys.platform != "darwin": - -## # On platforms where the default shared library suffix is '.so', -## # at least some libraries can be loaded as attributes of the cdll -## # object, since ctypes now tries loading the lib again -## # with '.so' appended of the first try fails. -## # -## # Won't work for libc, unfortunately. OTOH, it isn't -## # needed for libc since this is already mapped into the current -## # process (?) -## # -## # On MAC OSX, it won't work either, because dlopen() needs a full path, -## # and the default suffix is either none or '.dylib'. - -## class LoadLibs(unittest.TestCase): -## def test_libm(self): -## import math -## libm = cdll.libm -## sqrt = libm.sqrt -## sqrt.argtypes = (c_double,) -## sqrt.restype = c_double -## self.failUnlessEqual(sqrt(2), math.sqrt(2)) - -if __name__ == "__main__": - unittest.main() +import unittest +import os, sys +from ctypes import * +from ctypes.util import find_library +from ctypes.test import is_resource_enabled + +if sys.platform == "win32": + lib_gl = find_library("OpenGL32") + lib_glu = find_library("Glu32") + lib_glut = find_library("glut32") + lib_gle = None +elif sys.platform == "darwin": + lib_gl = lib_glu = find_library("OpenGL") + lib_glut = find_library("GLUT") + lib_gle = None +else: + lib_gl = find_library("GL") + lib_glu = find_library("GLU") + lib_glut = find_library("glut") + lib_gle = find_library("gle") + +## print, for debugging +if is_resource_enabled("printing"): + if lib_gl or lib_glu or lib_glut or lib_gle: + print "OpenGL libraries:" + for item in (("GL", lib_gl), + ("GLU", lib_glu), + ("glut", lib_glut), + ("gle", lib_gle)): + print "\t", item + + +# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. +class Test_OpenGL_libs(unittest.TestCase): + def setUp(self): + self.gl = self.glu = self.gle = self.glut = None + if lib_gl: + self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL) + if lib_glu: + self.glu = CDLL(lib_glu, RTLD_GLOBAL) + if lib_glut: + # On some systems, additional libraries seem to be + # required, loading glut fails with + # "OSError: /usr/lib/libglut.so.3: undefined symbol: XGetExtensionVersion" + # I cannot figure out how to repair the test on these + # systems (red hat), so we ignore it when the glut or gle + # libraries cannot be loaded. See also: + # https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1478253&group_id=5470 + # http://mail.python.org/pipermail/python-dev/2006-May/064789.html + try: + self.glut = CDLL(lib_glut) + except OSError: + pass + if lib_gle: + try: + self.gle = CDLL(lib_gle) + except OSError: + pass + + if lib_gl: + def test_gl(self): + if self.gl: + self.gl.glClearIndex + + if lib_glu: + def test_glu(self): + if self.glu: + self.glu.gluBeginCurve + + if lib_glut: + def test_glut(self): + if self.glut: + self.glut.glutWireTetrahedron + + if lib_gle: + def test_gle(self): + if self.gle: + self.gle.gleGetJoinStyle + +##if os.name == "posix" and sys.platform != "darwin": + +## # On platforms where the default shared library suffix is '.so', +## # at least some libraries can be loaded as attributes of the cdll +## # object, since ctypes now tries loading the lib again +## # with '.so' appended of the first try fails. +## # +## # Won't work for libc, unfortunately. OTOH, it isn't +## # needed for libc since this is already mapped into the current +## # process (?) +## # +## # On MAC OSX, it won't work either, because dlopen() needs a full path, +## # and the default suffix is either none or '.dylib'. + +## class LoadLibs(unittest.TestCase): +## def test_libm(self): +## import math +## libm = cdll.libm +## sqrt = libm.sqrt +## sqrt.argtypes = (c_double,) +## sqrt.restype = c_double +## self.failUnlessEqual(sqrt(2), math.sqrt(2)) + +if __name__ == "__main__": + unittest.main() From buildbot at python.org Fri May 12 22:04:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 12 May 2006 20:04:14 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060512200414.F196F1E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/386 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida,martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 13 00:16:20 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 13 May 2006 00:16:20 +0200 (CEST) Subject: [Python-checkins] r45983 - sandbox/trunk/setuptools/setuptools/package_index.py Message-ID: <20060512221620.23EAE1E400B@bag.python.org> Author: phillip.eby Date: Sat May 13 00:16:19 2006 New Revision: 45983 Modified: sandbox/trunk/setuptools/setuptools/package_index.py Log: Better ambiguity management: accept #egg name/version even if processing what appears to be a correctly-named distutils file, and ignore .egg files with no '-', since valid Python .egg files always have a version number (but Scheme eggs often don't). Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Sat May 13 00:16:19 2006 @@ -48,20 +48,21 @@ def distros_for_url(url, metadata=None): """Yield egg or source distribution objects that might be found at a URL""" base, fragment = egg_info_for_url(url) - dists = distros_for_location(url, base, metadata) - if fragment and not dists: + for dist in distros_for_location(url, base, metadata): yield dist + if fragment: match = EGG_FRAGMENT.match(fragment) if match: - return interpret_distro_name( + for dist in interpret_distro_name( url, match.group(1), metadata, precedence = CHECKOUT_DIST - ) - return dists + ): + yield dist def distros_for_location(location, basename, metadata=None): """Yield egg or source distribution objects based on basename""" if basename.endswith('.egg.zip'): basename = basename[:-4] # strip the .zip - if basename.endswith('.egg'): # only one, unambiguous interpretation + if basename.endswith('.egg') and '-' in basename: + # only one, unambiguous interpretation return [Distribution.from_location(location, basename, metadata)] if basename.endswith('.exe'): @@ -79,7 +80,6 @@ return interpret_distro_name(location, basename, metadata) return [] # no extension matched - def distros_for_filename(filename, metadata=None): """Yield possible egg or source distribution objects based on a filename""" return distros_for_location( From python-checkins at python.org Sat May 13 00:17:31 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 13 May 2006 00:17:31 +0200 (CEST) Subject: [Python-checkins] r45984 - sandbox/branches/setuptools-0.6/setuptools/package_index.py Message-ID: <20060512221731.BC16D1E400B@bag.python.org> Author: phillip.eby Date: Sat May 13 00:17:31 2006 New Revision: 45984 Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py Log: Better ambiguity management: accept #egg name/version even if processing what appears to be a correctly-named distutils file, and ignore .egg files with no '-', since valid Python .egg files always have a version number (but Scheme eggs often don't). Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Sat May 13 00:17:31 2006 @@ -48,20 +48,21 @@ def distros_for_url(url, metadata=None): """Yield egg or source distribution objects that might be found at a URL""" base, fragment = egg_info_for_url(url) - dists = distros_for_location(url, base, metadata) - if fragment and not dists: + for dist in distros_for_location(url, base, metadata): yield dist + if fragment: match = EGG_FRAGMENT.match(fragment) if match: - return interpret_distro_name( + for dist in interpret_distro_name( url, match.group(1), metadata, precedence = CHECKOUT_DIST - ) - return dists + ): + yield dist def distros_for_location(location, basename, metadata=None): """Yield egg or source distribution objects based on basename""" if basename.endswith('.egg.zip'): basename = basename[:-4] # strip the .zip - if basename.endswith('.egg'): # only one, unambiguous interpretation + if basename.endswith('.egg') and '-' in basename: + # only one, unambiguous interpretation return [Distribution.from_location(location, basename, metadata)] if basename.endswith('.exe'): @@ -79,7 +80,6 @@ return interpret_distro_name(location, basename, metadata) return [] # no extension matched - def distros_for_filename(filename, metadata=None): """Yield possible egg or source distribution objects based on a filename""" return distros_for_location( From python-checkins at python.org Sat May 13 00:40:07 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 13 May 2006 00:40:07 +0200 (CEST) Subject: [Python-checkins] r45985 - sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/pkg_resources.txt sandbox/branches/setuptools-0.6/setuptools.txt Message-ID: <20060512224007.149261E400B@bag.python.org> Author: phillip.eby Date: Sat May 13 00:40:05 2006 New Revision: 45985 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/pkg_resources.txt sandbox/branches/setuptools-0.6/setuptools.txt Log: Document 0.6b1 fixes Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Sat May 13 00:40:05 2006 @@ -1096,11 +1096,21 @@ ============================ 0.6b1 + * Better ambiguity management: accept ``#egg`` name/version even if processing + what appears to be a correctly-named distutils file, and ignore ``.egg`` + files with no ``-``, since valid Python ``.egg`` files always have a version + number (but Scheme eggs often don't). + + * Support ``file://`` links to directories in ``--find-links``, so that + easy_install can build packages from local source checkouts. + * Added automatic retry for Sourceforge mirrors. The new download process is to first just try dl.sourceforge.net, then randomly select mirror IPs and remove ones that fail, until something works. The removed IPs stay removed for the remainder of the run. + * Ignore bdist_dumb distributions when looking at download URLs. + 0.6a11 * Process ``dependency_links.txt`` if found in a distribution, by adding the URLs to the list for scanning. @@ -1187,7 +1197,7 @@ 0.6a8 * Update for changed SourceForge mirror format - + * Fixed not installing dependencies for some packages fetched via Subversion * Fixed dependency installation with ``--always-copy`` not using the same @@ -1232,7 +1242,7 @@ needed package as the default version of that package. * Fixed a problem parsing version numbers in ``#egg=`` links. - + 0.6a2 * EasyInstall can now install "console_scripts" defined by packages that use ``setuptools`` and define appropriate entry points. On Windows, console Modified: sandbox/branches/setuptools-0.6/pkg_resources.txt ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.txt (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.txt Sat May 13 00:40:05 2006 @@ -1667,6 +1667,9 @@ ``get_build_platform()`` to work around a Mac versioning problem that caused the behavior of ``compatible_platforms()`` to be platform specific. + * Fix entry point parsing when a standalone module name has whitespace + between it and the extras. + 0.6a11 * Added ``ExtractionError`` and ``ResourceManager.extraction_error()`` so that cache permission problems get a more user-friendly explanation of the Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Sat May 13 00:40:05 2006 @@ -349,7 +349,7 @@ has an ``additional_tests()`` function, it is called and the results are added to the tests to be run. If the named suite is a package, any submodules and subpackages are recursively added to the overall test suite. - + Specifying this argument enables use of the `test`_ command to run the specified test suite, e.g. via ``setup.py test``. See the section on the `test`_ command below for more details. @@ -1041,7 +1041,7 @@ Note that you can also apply setuptools commands to non-setuptools projects, using commands like this:: - + python -c "import setuptools; execfile('setup.py')" develop That is, you can simply list the normal setup commands and options following @@ -2454,7 +2454,7 @@ with the absence of needed programs (i.e., ones belonging to the revision control system itself. It *may*, however, use ``distutils.log.warn()`` to inform the user of the missing program(s). - + Subclassing ``Command`` ----------------------- @@ -2498,6 +2498,11 @@ Release Notes/Change History ---------------------------- +0.6b1 + * Strip ``module`` from the end of compiled extension modules when computing + the name of a ``.py`` loader/wrapper. (Python's import machinery ignores + this suffix when searching for an extension module.) + 0.6a11 * Added ``test_loader`` keyword to support custom test loaders From python-checkins at python.org Sat May 13 00:43:08 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 13 May 2006 00:43:08 +0200 (CEST) Subject: [Python-checkins] r45986 - sandbox/branches/setuptools-0.6/ez_setup.py Message-ID: <20060512224308.964CD1E400B@bag.python.org> Author: phillip.eby Date: Sat May 13 00:43:08 2006 New Revision: 45986 Modified: sandbox/branches/setuptools-0.6/ez_setup.py Log: Updated for 0.6b1 release MD5 signatures Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Sat May 13 00:43:08 2006 @@ -18,32 +18,12 @@ DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { - 'setuptools-0.6a1-py2.3.egg': 'ee819a13b924d9696b0d6ca6d1c5833d', - 'setuptools-0.6a1-py2.4.egg': '8256b5f1cd9e348ea6877b5ddd56257d', 'setuptools-0.6a10-py2.3.egg': '162d8357f1aff2b0349c6c247ee62987', 'setuptools-0.6a10-py2.4.egg': '803a2d8db501c1ac3b5b6fb4e907f788', 'setuptools-0.6a11-py2.3.egg': 'd12bf8e13aaeb25c91350c8d77f01a71', 'setuptools-0.6a11-py2.4.egg': 'a95d5bc7a070aa1028bc4dcb5270b133', - 'setuptools-0.6a11dev_r43177-py2.3.egg': '068ef7c8522539af12f5fb14b4a8cf21', - 'setuptools-0.6a11dev_r43295-py2.3.egg': 'eb78390e6beac3694342b5629cc6653f', - 'setuptools-0.6a11dev_r43403-py2.3.egg': 'ba1a6b00f5c1fdd482284a7df3d8bd19', - 'setuptools-0.6a11dev_r43417-py2.3.egg': 'c6014183afd9fd167d7d82eee78db2c6', - 'setuptools-0.6a2-py2.3.egg': 'b98da449da411267c37a738f0ab625ba', - 'setuptools-0.6a2-py2.4.egg': 'be5b88bc30aed63fdefd2683be135c3b', - 'setuptools-0.6a3-py2.3.egg': 'ee0e325de78f23aab79d33106dc2a8c8', - 'setuptools-0.6a3-py2.4.egg': 'd95453d525a456d6c23e7a5eea89a063', - 'setuptools-0.6a4-py2.3.egg': 'e958cbed4623bbf47dd1f268b99d7784', - 'setuptools-0.6a4-py2.4.egg': '7f33c3ac2ef1296f0ab4fac1de4767d8', - 'setuptools-0.6a5-py2.3.egg': '748408389c49bcd2d84f6ae0b01695b1', - 'setuptools-0.6a5-py2.4.egg': '999bacde623f4284bfb3ea77941d2627', - 'setuptools-0.6a6-py2.3.egg': '7858139f06ed0600b0d9383f36aca24c', - 'setuptools-0.6a6-py2.4.egg': 'c10d20d29acebce0dc76219dc578d058', - 'setuptools-0.6a7-py2.3.egg': 'cfc4125ddb95c07f9500adc5d6abef6f', - 'setuptools-0.6a7-py2.4.egg': 'c6d62dab4461f71aed943caea89e6f20', - 'setuptools-0.6a8-py2.3.egg': '2f18eaaa3f544f5543ead4a68f3b2e1a', - 'setuptools-0.6a8-py2.4.egg': '799018f2894f14c9f8bcb2b34e69b391', - 'setuptools-0.6a9-py2.3.egg': '8e438ad70438b07b0d8f82cae42b278f', - 'setuptools-0.6a9-py2.4.egg': '8f6e01fc12fb1cd006dc0d6c04327ec1', + 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', + 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', } import sys, os @@ -58,7 +38,7 @@ % egg_name ) sys.exit(2) - return data + return data def use_setuptools( @@ -74,7 +54,7 @@ be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in - an attempt to abort the calling script. + an attempt to abort the calling script. """ try: import setuptools @@ -189,7 +169,7 @@ print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' - + def update_md5(filenames): """Update our built-in md5 registry""" @@ -198,7 +178,7 @@ for name in filenames: base = os.path.basename(name) - f = open(name,'rb') + f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() From python-checkins at python.org Sat May 13 01:49:50 2006 From: python-checkins at python.org (gerhard.haering) Date: Sat, 13 May 2006 01:49:50 +0200 (CEST) Subject: [Python-checkins] r45987 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060512234950.A986F1E400C@bag.python.org> Author: gerhard.haering Date: Sat May 13 01:49:49 2006 New Revision: 45987 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Integrated the rest of the pysqlite reference manual into the Python documentation. Ready to be reviewed and improved upon. Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Sat May 13 01:49:49 2006 @@ -3,34 +3,38 @@ \declaremodule{builtin}{sqlite3} \modulesynopsis{A DB-API 2.0 implementation using SQLite 3.x.} +\sectionauthor{Gerhard H?ring}{gh at ghaering.de} +\versionadded{2.5} - - -The module defines the following: +\subsection{Module functions and constants\label{sqlite3-Module-Contents}} \begin{datadesc}{PARSE_DECLTYPES} -This constant is meant to be used with the detect_types parameter of the connect function. +This constant is meant to be used with the \var{detect_types} parameter of the +\function{connect} function. -Setting it makes the sqlite3 module parse the declared type for each column it +Setting it makes the \module{sqlite3} module parse the declared type for each column it returns. It will parse out the first word of the declared type, i. e. for "integer primary key", it will parse out "integer". Then for that column, it -will look into pysqlite's converters dictionary and use the converter function +will look into the converters dictionary and use the converter function registered for that type there. Converter names are case-sensitive! \end{datadesc} \begin{datadesc}{PARSE_COLNAMES} -Setting this makes pysqlite parse the column name for each column it returns. -It will look for a string formed [mytype] in there, and then decide that -'mytype' is the type of the column. It will try to find an entry of 'mytype' in -the converters dictionary and then use the converter function found there to -return the value. The column name found in cursor.description is only the first -word of the column name, i. e. if you use something like 'as "x [datetime]"' -in your SQL, then pysqlite will parse out everything until the first blank for -the column name: the column name would simply be "x". +This constant is meant to be used with the \var{detect_types} parameter of the +\function{connect} function. + +Setting this makes the SQLite interface parse the column name for each column +it returns. It will look for a string formed [mytype] in there, and then +decide that 'mytype' is the type of the column. It will try to find an entry of +'mytype' in the converters dictionary and then use the converter function found +there to return the value. The column name found in \member{cursor.description} is only +the first word of the column name, i. e. if you use something like +\code{'as "x [datetime]"'} in your SQL, then we will parse out everything until the +first blank for the column name: the column name would simply be "x". \end{datadesc} -\begin{funcdesc}{connect}{database\optional{, timeout, isolation_level, detect_types, check_same_thread, factory}} +\begin{funcdesc}{connect}{database\optional{, timeout, isolation_level, detect_types, factory}} Opens a connection to the SQLite database file \var{database}. You can use \code{":memory:"} to open a database connection to a database that resides in RAM instead of on disk. @@ -41,25 +45,26 @@ wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). -For the \var{isolation_level} parameter, please see TODO: link property of -Connection objects. +For the \var{isolation_level} parameter, please see \member{isolation_level} +\ref{sqlite3-Connection-IsolationLevel} property of \class{Connection} objects. SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If you want to use other types, like you have to add support for them yourself. -The \var{detect_types} parameter and the using custom *converters* registered with -the module-level *register_converter* function allow you to easily do that. +The \var{detect_types} parameter and the using custom \strong{converters} registered with +the module-level \function{register_converter} function allow you to easily do that. \var{detect_types} defaults to 0 (i. e. off, no type detection), you can set it -to any combination of *PARSE_DECLTYPES* and *PARSE_COLNAMES* to turn type +to any combination of \constant{PARSE_DECLTYPES} and \constant{PARSE_COLNAMES} to turn type detection on. -By default, the sqlite3 module uses its Connection class for the connect call. -You can, however, subclass the Connection class and make .connect() use your -class instead by providing your class for the \var{factory} parameter. +By default, the \module{sqlite3} module uses its \class{Connection} class for the +connect call. You can, however, subclass the \class{Connection} class and make +\function{connect} use your class instead by providing your class for the +\var{factory} parameter. -Consult the section `4. SQLite and Python types`_ of this manual for details. +Consult the section \ref{sqlite3-Types} of this manual for details. -The sqlite3 module internally uses a statement cache to avoid SQL parsing +The \module{sqlite3} module internally uses a statement cache to avoid SQL parsing overhead. If you want to explicitly set the number of statements that are cached for the connection, you can set the \var{cached_statements} parameter. The currently implemented default is to cache 100 statements. @@ -68,8 +73,8 @@ \begin{funcdesc}{register_converter}{typename, callable} Registers a callable to convert a bytestring from the database into a custom Python type. The callable will be invoked for all database values that are of -the type \var{typename}. Confer the parameter **detect_types** of the -**connect** method for how the type detection works. Note that the case of +the type \var{typename}. Confer the parameter \var{detect_types} of the +\function{connect} function for how the type detection works. Note that the case of \var{typename} and the name of the type in your query must match! \end{funcdesc} @@ -80,15 +85,26 @@ int, long, float, str (UTF-8 encoded), unicode or buffer. \end{funcdesc} +\begin{funcdesc}{complete_statement}{sql} +Returns \constant{True} if the string \var{sql} one or more complete SQL +statements terminated by semicolons. It does not verify if the SQL is +syntactically correct, only if there are no unclosed string literals and if the +statement is terminated by a semicolon. + +This can be used to build a shell for SQLite, like in the following example: + + \verbatiminput{sqlite3/complete_statement.py} +\end{funcdesc} \subsection{Connection Objects \label{sqlite3-Connection-Objects}} A \class{Connection} instance has the following attributes and methods: +\label{sqlite3-Connection-IsolationLevel} \begin{memberdesc}{isolation_level} - Get or set the current isolation level. None for autocommit mode or one - of "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See `5. Controlling - Transactions`_ for a more detailed explanation. + Get or set the current isolation level. None for autocommit mode or one of + "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See Controlling Transactions + \ref{sqlite3-Controlling-Transactions} for a more detailed explanation. \end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} @@ -98,22 +114,77 @@ \begin{methoddesc}{execute}{sql, \optional{parameters}} This is a nonstandard shortcut that creates an intermediate cursor object by -calling the cursor method, then calls the cursor's execute method with the +calling the cursor method, then calls the cursor's \method{execute} method with the parameters given. \end{methoddesc} \begin{methoddesc}{executemany}{sql, \optional{parameters}} This is a nonstandard shortcut that creates an intermediate cursor object by -calling the cursor method, then calls the cursor's executemany method with the +calling the cursor method, then calls the cursor's \method{executemany} method with the parameters given. \end{methoddesc} \begin{methoddesc}{executescript}{sql_script} This is a nonstandard shortcut that creates an intermediate cursor object by -calling the cursor method, then calls the cursor's executescript method with the +calling the cursor method, then calls the cursor's \method{executescript} method with the parameters given. \end{methoddesc} +\begin{methoddesc}{create_function}{name, num_params, func} + +Creates a user-defined function that you can later use from within SQL +statements under the function name \var{name}. \var{num_params} is the number +of parameters the function accepts, and \var{func} is a Python callable that is +called as SQL function. + +The function can return any of the types supported by SQLite: unicode, str, +int, long, float, buffer and None. Exceptions in the function are ignored and +they are handled as if the function returned None. + +Example: + + \verbatiminput{sqlite3/md5func.py} +\end{methoddesc} + +\begin{methoddesc}{create_aggregate}{name, num_params, aggregate_class} + +Creates a user-defined aggregate function. + +The aggregate class must implement a \code{step} method, which accepts the +number of parameters \var{num_params}, and a \code{finalize} method which +will return the final result of the aggregate. + +The \code{finalize} method can return any of the types supported by SQLite: +unicode, str, int, long, float, buffer and None. Any exceptions are ignored. + +Example: + + \verbatiminput{sqlite3/mysumaggr.py} +\end{methoddesc} + +\begin{methoddesc}{create_collation}{name, callable} + +Creates a collation with the specified \var{name} and \var{callable}. The +callable will be passed two string arguments. It should return -1 if the first +is ordered lower than the second, 0 if they are ordered equal and 1 and if the +first is ordered higher than the second. Note that this controls sorting +(ORDER BY in SQL) so your comparisons don't affect other SQL operations. + +Note that the callable will get its parameters as Python bytestrings, which +will normally be encoded in UTF-8. + +The following example shows a custom collation that sorts "the wrong way": + + \verbatiminput{sqlite3/collation_reverse.py} + +To remove a collation, call \code{create_collation} with None as callable: + +\begin{verbatim} + con.create_collation("reverse", None) +\end{verbatim} +\end{methoddesc} + + \begin{memberdesc}{row_factory} You can change this attribute to a callable that accepts the cursor and the original row as tuple and will return the real result row. This @@ -126,21 +197,21 @@ If the standard tuple types don't suffice for you, and you want name-based access to columns, you should consider setting \member{row_factory} to the - highly-optimized pysqlite2.dbapi2.Row type. It provides both + highly-optimized sqlite3.Row type. It provides both index-based and case-insensitive name-based access to columns with almost no memory overhead. Much better than your own custom dictionary-based approach or even a db_row based solution. \end{memberdesc} \begin{memberdesc}{text_factory} - Using this attribute you can control what objects pysqlite returns for the - TEXT data type. By default, this attribute is set to ``unicode`` and - pysqlite will return Unicode objects for TEXT. If you want to return - bytestrings instead, you can set it to ``str``. + Using this attribute you can control what objects are returned for the + TEXT data type. By default, this attribute is set to \class{unicode} and + the \module{sqlite3} module will return Unicode objects for TEXT. If you want to return + bytestrings instead, you can set it to \class{str}. For efficiency reasons, there's also a way to return Unicode objects only for non-ASCII data, and bytestrings otherwise. To activate it, set this - attribute to ``pysqlite2.dbapi2.OptimizedUnicode``. + attribute to \constant{sqlite3.OptimizedUnicode}. You can also set it to any other callable that accepts a single bytestring parameter and returns the result object. @@ -159,14 +230,14 @@ -\subsection{Cursor Objects \label{Cursor-Objects}} +\subsection{Cursor Objects \label{sqlite3-Cursor-Objects}} A \class{Cursor} instance has the following attributes and methods: \begin{methoddesc}{execute}{sql, \optional{parameters}} Executes a SQL statement. The SQL statement may be parametrized (i. e. -placeholders instead of SQL literals). The sqlite3 module supports two kinds of +placeholders instead of SQL literals). The \module{sqlite3} module supports two kinds of placeholders: question marks (qmark style) and named placeholders (named style). @@ -211,7 +282,7 @@ \end{methoddesc} \begin{memberdesc}{rowcount} - Although the Cursors of the \module{sqlite3} module implement this + Although the \class{Cursor} class of the \module{sqlite3} module implements this attribute, the database engine's own support for the determination of "rows affected"/"rows selected" is quirky. @@ -221,11 +292,212 @@ For \code{DELETE} statements, SQLite reports \member{rowcount} as 0 if you make a \code{DELETE FROM table} without any condition. - For \method{executemany} statements, pysqlite sums up the number of - modifications into \member{rowcount}. + For \method{executemany} statements, the number of modifications are summed + up into \member{rowcount}. As required by the Python DB API Spec, the \member{rowcount} attribute "is -1 in case no executeXX() has been performed on the cursor or the rowcount of the last operation is not determinable by the interface". \end{memberdesc} +\subsection{SQLite and Python types\label{sqlite3-Types}} + +\subsubsection{Introduction} + +SQLite natively supports the following types: NULL, INTEGER, REAL, TEXT, BLOB. + +The following Python types can thus be sent to SQLite without any problem: + +\begin{tableii} {c|l}{code}{Python type}{SQLite type} +\lineii{None}{NULL} +\lineii{int}{INTEGER} +\lineii{long}{INTEGER} +\lineii{float}{REAL} +\lineii{str (UTF8-encoded)}{TEXT} +\lineii{unicode}{TEXT} +\lineii{buffer}{BLOB} +\end{tableii} + +This is how SQLite types are converted to Python types by default: + +\begin{tableii} {c|l}{code}{SQLite type}{Python type} +\lineii{NULL}{None} +\lineii{INTEGER}{int or long, depending on size} +\lineii{REAL}{float} +\lineii{TEXT}{depends on text_factory, unicode by default} +\lineii{BLOB}{buffer} +\end{tableii} + +The type system of the \module{sqlite3} module is extensible in both ways: you can store +additional Python types in a SQLite database via object adaptation, and you can +let the \module{sqlite3} module convert SQLite types to different Python types via +converters. + +\subsubsection{Using adapters to store additional Python types in SQLite databases} + +Like described before, SQLite supports only a limited set of types natively. To +use other Python types with SQLite, you must \strong{adapt} them to one of the sqlite3 +module's supported types for SQLite. So, one of NoneType, int, long, float, +str, unicode, buffer. + +The \module{sqlite3} module uses the Python object adaptation, like described in PEP 246 +for this. The protocol to use is \class{PrepareProtocol}. + +There are two ways to enable the \module{sqlite3} module to adapt a custom Python type +to one of the supported ones. + +\paragraph{Letting your object adapt itself} + +This is a good approach if you write the class yourself. Let's suppose you have +a class like this: + +\begin{verbatim} +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y +\end{verbatim} + +Now you want to store the point in a single SQLite column. You'll have to +choose one of the supported types first that you use to represent the point in. +Let's just use str and separate the coordinates using a semicolon. Then you +need to give your class a method \code{__conform__(self, protocol)} which must +return the converted value. The parameter \var{protocol} will be +\class{PrepareProtocol}. + +\verbatiminput{sqlite3/adapter_point_1.py} + +\paragraph{Registering an adapter callable} + +The other possibility is to create a function that converts the type to the +string representation and register the function with \method{register_adapter}. + + \verbatiminput{sqlite3/adapter_point_2.py} + +\begin{notice} +The type/class to adapt must be a new-style class, i. e. it must have +\class{object} as one of its bases. +\end{notice} + +The \module{sqlite3} module has two default adapters for Python's builtin +\class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we +want to store \class{datetime.datetime} objects not in ISO representation, but +as Unix timestamp. + + \verbatiminput{sqlite3/adapter_datetime.py} + +\subsubsection{Converting SQLite values to custom Python types} + +Now that's all nice and dandy that you can send custom Python types to SQLite. +But to make it really useful we need to make the Python to SQLite to Python +roundtrip work. + +Enter converters. + +Let's go back to the Point class. We stored the x and y coordinates separated +via semicolons as strings in SQLite. + +Let's first define a converter function that accepts the string as a parameter and constructs a Point object from it. + +\begin{notice} +Converter functions \strong{always} get called with a string, no matter +under which data type you sent the value to SQLite. +\end{notice} + +\begin{notice} +Converter names are looked up in a case-sensitive manner. +\end{notice} + + +\begin{verbatim} + def convert_point(s): + x, y = map(float, s.split(";")) + return Point(x, y) +\end{verbatim} + +Now you need to make the \module{sqlite3} module know that what you select from the +database is actually a point. There are two ways of doing this: + +\begin{itemize} + \item Implicitly via the declared type + \item Explicitly via the column name +\end{itemize} + +Both ways are described at \ref{sqlite3-Module-Contents} in the text explaining +the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COlNAMES}. + + +The following example illustrates both ways. + + \verbatiminput{sqlite3/converter_point.py} + +\subsubsection{Default adapters and converters} + +There are default adapters for the date and datetime types in the datetime +module. They will be sent as ISO dates/ISO timestamps to SQLite. + +The default converters are registered under the name "date" for datetime.date +and under the name "timestamp" for datetime.datetime. + +This way, you can use date/timestamps from Python without any additional +fiddling in most cases. The format of the adapters is also compatible with the +experimental SQLite date/time functions. + +The following example demonstrates this. + + \verbatiminput{sqlite3/pysqlite_datetime.py} + +\subsection{Controlling Transactions \label{sqlite3-Controlling-Transactions}} + +By default, the \module{sqlite3} module opens transactions implicitly before a DML +statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly +before a non-DML, non-DQL statement (i. e. anything other than +SELECT/INSERT/UPDATE/DELETE/REPLACE). + +So if you are within a transaction, and issue a command like \code{CREATE TABLE +...}, \code{VACUUM}, \code{PRAGMA}, the \module{sqlite3} module will commit implicitly +before executing that command. There are two reasons for doing that. The first +is that some of these commands don't work within transactions. The other reason +is that pysqlite needs to keep track of the transaction state (if a transaction +is active or not). + +You can control which kind of "BEGIN" statements pysqlite implicitly executes +(or none at all) via the \var{isolation_level} parameter to the +\function{connect} call, or via the \member{isolation_level} property of +connections. + +If you want \strong{autocommit mode}, then set \member{isolation_level} to None. + +Otherwise leave it at it's default, which will result in a plain "BEGIN" +statement, or set it to one of SQLite's supported isolation levels: DEFERRED, +IMMEDIATE or EXCLUSIVE. + +As the \module{sqlite3} module needs to keep track of the transaction state, you should +not use \code{OR ROLLBACK} or \code{ON CONFLICT ROLLBACK} in your SQL. Instead, +catch the \exception{IntegrityError} and call the \method{rollback} method of +the connection yourself. + +\subsection{Using pysqlite efficiently} + +\subsubsection{Using shortcut methods} + +Using the nonstandard \method{execute}, \method{executemany} and +\method{executescript} methods of the \class{Connection} object, your code can +be written more concisely, because you don't have to create the - often +superfluous \class{Cursor} objects explicitly. Instead, the \class{Cursor} +objects are created implicitly and these shortcut methods return the cursor +objects. This way, you can for example execute a SELECT statement and iterate +over it directly using only a single call on the \class{Connection} object. + + \verbatiminput{sqlite3/shortcut_methods.py} + +\subsubsection{Accessing columns by name instead of by index} + +One cool feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class +designed to be used as a row factory. + +Rows wrapped with this class can be accessed both by index (like tuples) and +case-insensitively by name: + + \verbatiminput{sqlite3/rowclass.py} + + From python-checkins at python.org Sat May 13 08:53:32 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 13 May 2006 08:53:32 +0200 (CEST) Subject: [Python-checkins] r45988 - python/trunk/Doc/lib/libthread.tex python/trunk/Doc/lib/libtokenize.tex Message-ID: <20060513065332.91C541E4003@bag.python.org> Author: george.yoshida Date: Sat May 13 08:53:31 2006 New Revision: 45988 Modified: python/trunk/Doc/lib/libthread.tex python/trunk/Doc/lib/libtokenize.tex Log: Add \exception markup Modified: python/trunk/Doc/lib/libthread.tex ============================================================================== --- python/trunk/Doc/lib/libthread.tex (original) +++ python/trunk/Doc/lib/libthread.tex Sat May 13 08:53:31 2006 @@ -44,8 +44,8 @@ \end{funcdesc} \begin{funcdesc}{interrupt_main}{} -Raise a KeyboardInterrupt in the main thread. A subthread can use this -function to interrupt the main thread. +Raise a \exception{KeyboardInterrupt} exception in the main thread. A subthread +can use this function to interrupt the main thread. \versionadded{2.3} \end{funcdesc} Modified: python/trunk/Doc/lib/libtokenize.tex ============================================================================== --- python/trunk/Doc/lib/libtokenize.tex (original) +++ python/trunk/Doc/lib/libtokenize.tex Sat May 13 08:53:31 2006 @@ -47,7 +47,7 @@ call to the function should return one line of input as a string. Alternately, \var{readline} may be a callable object that signals completion by raising \exception{StopIteration}. - \versionchanged[Added StopIteration support]{2.5} + \versionchanged[Added \exception{StopIteration} support]{2.5} The second parameter, \var{tokeneater}, must also be a callable object. It is called once for each token, with five arguments, From python-checkins at python.org Sat May 13 08:56:39 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 13 May 2006 08:56:39 +0200 (CEST) Subject: [Python-checkins] r45989 - python/branches/release24-maint/Doc/lib/libthread.tex Message-ID: <20060513065639.1211D1E4003@bag.python.org> Author: george.yoshida Date: Sat May 13 08:56:38 2006 New Revision: 45989 Modified: python/branches/release24-maint/Doc/lib/libthread.tex Log: Add \exception markup Modified: python/branches/release24-maint/Doc/lib/libthread.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libthread.tex (original) +++ python/branches/release24-maint/Doc/lib/libthread.tex Sat May 13 08:56:38 2006 @@ -44,8 +44,8 @@ \end{funcdesc} \begin{funcdesc}{interrupt_main}{} -Raise a KeyboardInterrupt in the main thread. A subthread can use this -function to interrupt the main thread. +Raise a \exception{KeyboardInterrupt} exception in the main thread. A subthread +can use this function to interrupt the main thread. \versionadded{2.3} \end{funcdesc} From buildbot at python.org Sat May 13 09:01:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 13 May 2006 07:01:50 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060513070150.3A5511E4003@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/768 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Sat May 13 09:11:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 13 May 2006 07:11:42 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060513071142.36F8E1E4003@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/388 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat May 13 10:02:47 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 13 May 2006 08:02:47 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060513080247.EAA491E4003@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/357 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat May 13 10:51:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 13 May 2006 08:51:09 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060513085109.EB0FD1E4003@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/65 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 13 15:34:05 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 13 May 2006 15:34:05 +0200 (CEST) Subject: [Python-checkins] r45990 - python/trunk/Objects/stringobject.c Message-ID: <20060513133405.0A29B1E4005@bag.python.org> Author: martin.v.loewis Date: Sat May 13 15:34:04 2006 New Revision: 45990 Modified: python/trunk/Objects/stringobject.c Log: Revert 43315: Printing of %zd must be signed. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 13 15:34:04 2006 @@ -275,8 +275,8 @@ if (longflag) sprintf(s, "%ld", va_arg(vargs, long)); else if (size_tflag) - sprintf(s, "%" PY_FORMAT_SIZE_T "u", - va_arg(vargs, size_t)); + sprintf(s, "%" PY_FORMAT_SIZE_T "d", + va_arg(vargs, Py_ssize_t)); else sprintf(s, "%d", va_arg(vargs, int)); s += strlen(s); From python-checkins at python.org Sat May 13 15:40:53 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 13 May 2006 15:40:53 +0200 (CEST) Subject: [Python-checkins] r45991 - sandbox/trunk/Overload3K/overloading.py Message-ID: <20060513134053.C5EB81E4005@bag.python.org> Author: phillip.eby Date: Sat May 13 15:40:53 2006 New Revision: 45991 Modified: sandbox/trunk/Overload3K/overloading.py Log: Simplify by merging type_matches into implies(). Modified: sandbox/trunk/Overload3K/overloading.py ============================================================================== --- sandbox/trunk/Overload3K/overloading.py (original) +++ sandbox/trunk/Overload3K/overloading.py Sat May 13 15:40:53 2006 @@ -77,7 +77,7 @@ if len(funcs) == 1: return funcs.pop() - raise TypeError("ambigous methods; types=%r; candidates=%r" % + raise TypeError("ambiguous methods; types=%r; candidates=%r" % (types, best)) @@ -93,14 +93,15 @@ """Do `types` imply `sig`?""" return False -# Manually bootstrap tuple/None and anything/None comparisons; this +# Manually bootstrap tuple/None, anything/None, and type/type comparisons; this # has to be done before the first call of any overloaded functions, including # overload() itself, which is called by @defop. So these bootstraps have to -# happen before we can use @defop. +# happen before we can use @defop. (Technically, the type/type one doesn't +# *need* to happen until later, but this is a convenient place to put it.) # implies[object, type(None)] = lambda s,t: True -implies[tuple, type(None)] = lambda s,t: True - +implies[tuple, type(None)] = lambda s,t: True +implies[type, type] = issubclass # Now that that's taken care of, we can use @defop to define everything else @@ -112,35 +113,26 @@ if len(sig)!=len(types): return False for s,t in zip(sig,types): - if not type_matches(s,t): + if not implies(s,t): return False return True - at overloaded -def type_matches(t1,t2): - """Does `t1` match an argument of type `t2`?""" - return False - -type_matches[type, type] = issubclass - - - # Now we can implement a kind of poor-man's typeclass, wherein we can treat # a 1-argument generic function as if it were a type. This implementation is # pretty crude, as a complete typeclass system should allow more sophisticated # ways to specify the signature(s). But that will be left as an exercise for # the reader at this point. ;) Note that with appropriate overloads of -# ``overload()``, ``type_matches()``, and ``implies()``, you can totally -# define your own framework for how overloads are chosen, so e.g. RuleDispatch -# could just provide overloads for these operations that work with its own -# generic function implementation and provide some extra decorators and -# type annotation objects to plug into the base system. +# ``overload()`` and ``implies()``, you can totally define your own framework +# for how overloads are chosen, so e.g. RuleDispatch could just provide +# overloads for these operations that work with its own generic function +# implementation and provide some extra decorators and type annotation objects +# to plug into the base system. -# defop type_matches(g1:type, g2:overloaded) +# defop implies(g1:type, g2:overloaded) # - at defop(type_matches) + at defop(implies) @signature(type, overloaded) def type_implies_gf(t,gf): """Here we implement the equivalent of issubclass(cls,genericfunction)""" @@ -150,9 +142,9 @@ return False -# defop type_matches(g1:overloaded, g2:overloaded) +# defop implies(g1:overloaded, g2:overloaded) # - at defop(type_matches) + at defop(implies) @signature(overloaded, overloaded) def gf_implies_gf(g1,g2): """Here we implement the equivalent of issubclass(g1,g2)""" @@ -173,4 +165,3 @@ return doctest.DocFileSuite( 'overloading.txt', optionflags=doctest.ELLIPSIS, package=__name__, ) - From python-checkins at python.org Sun May 14 01:28:21 2006 From: python-checkins at python.org (tim.peters) Date: Sun, 14 May 2006 01:28:21 +0200 (CEST) Subject: [Python-checkins] r45992 - in python/trunk: Doc/api/concrete.tex Doc/api/exceptions.tex Misc/NEWS Modules/_testcapimodule.c Objects/stringobject.c Message-ID: <20060513232821.524F41E4011@bag.python.org> Author: tim.peters Date: Sun May 14 01:28:20 2006 New Revision: 45992 Modified: python/trunk/Doc/api/concrete.tex python/trunk/Doc/api/exceptions.tex python/trunk/Misc/NEWS python/trunk/Modules/_testcapimodule.c python/trunk/Objects/stringobject.c Log: Teach PyString_FromFormat, PyErr_Format, and PyString_FromFormatV about "%u", "%lu" and "%zu" formats. Since PyString_FromFormat and PyErr_Format have exactly the same rules (both inherited from PyString_FromFormatV), it would be good if someone with more LaTeX Fu changed one of them to just point to the other. Their docs were way out of synch before this patch, and I just did a mass copy+paste to repair that. Not a backport candidate (this is a new feature). Modified: python/trunk/Doc/api/concrete.tex ============================================================================== --- python/trunk/Doc/api/concrete.tex (original) +++ python/trunk/Doc/api/concrete.tex Sun May 14 01:28:20 2006 @@ -245,7 +245,7 @@ \end{csimplemacrodesc} \begin{cfuncdesc}{PyObject*}{PyBool_FromLong}{long v} - Return a new reference to \constant{Py_True} or \constant{Py_False} + Return a new reference to \constant{Py_True} or \constant{Py_False} depending on the truth value of \var{v}. \versionadded{2.3} \end{cfuncdesc} @@ -618,12 +618,24 @@ exactly to the format characters in the \var{format} string. The following format characters are allowed: + % This should be exactly the same as the table in PyErr_Format. + % One should just refer to the other. + + % The descriptions for %zd and %zu are wrong, but the truth is complicated + % because not all compilers support the %z width modifier -- we fake it + % when necessary via interpolating PY_FORMAT_SIZE_T. + + % %u, %lu, %zu should have "new in Python 2.5" blurbs. + \begin{tableiii}{l|l|l}{member}{Format Characters}{Type}{Comment} \lineiii{\%\%}{\emph{n/a}}{The literal \% character.} \lineiii{\%c}{int}{A single character, represented as an C int.} \lineiii{\%d}{int}{Exactly equivalent to \code{printf("\%d")}.} + \lineiii{\%u}{unsigned int}{Exactly equivalent to \code{printf("\%u")}.} \lineiii{\%ld}{long}{Exactly equivalent to \code{printf("\%ld")}.} - \lineiii{\%zd}{long}{Exactly equivalent to \code{printf("\%zd")}.} + \lineiii{\%lu}{unsigned long}{Exactly equivalent to \code{printf("\%lu")}.} + \lineiii{\%zd}{Py_ssize_t}{Exactly equivalent to \code{printf("\%zd")}.} + \lineiii{\%zu}{ssize_t}{Exactly equivalent to \code{printf("\%zu")}.} \lineiii{\%i}{int}{Exactly equivalent to \code{printf("\%i")}.} \lineiii{\%x}{int}{Exactly equivalent to \code{printf("\%x")}.} \lineiii{\%s}{char*}{A null-terminated C character array.} @@ -632,6 +644,10 @@ guaranteed to start with the literal \code{0x} regardless of what the platform's \code{printf} yields.} \end{tableiii} + + An unrecognized format character causes all the rest of the format + string to be copied as-is to the result string, and any extra + arguments discarded. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromFormatV}{const char *format, @@ -687,7 +703,7 @@ \var{size})}. It must not be deallocated. If \var{string} is a Unicode object, this function computes the default encoding of \var{string} and operates on that. If \var{string} is not a string - object at all, \cfunction{PyString_AsStringAndSize()} returns + object at all, \cfunction{PyString_AsStringAndSize()} returns \code{-1} and raises \exception{TypeError}. \end{cfuncdesc} @@ -1494,7 +1510,7 @@ Return 1 if \var{substr} matches \var{str}[\var{start}:\var{end}] at the given tail end (\var{direction} == -1 means to do a prefix match, \var{direction} == 1 a suffix match), 0 otherwise. - Return \code{-1} if an error occurred. + Return \code{-1} if an error occurred. \end{cfuncdesc} \begin{cfuncdesc}{Py_ssize_t}{PyUnicode_Find}{PyObject *str, @@ -3013,7 +3029,7 @@ \subsection{Set Objects \label{setObjects}} -\sectionauthor{Raymond D. Hettinger}{python at rcn.com} +\sectionauthor{Raymond D. Hettinger}{python at rcn.com} \obindex{set} \obindex{frozenset} @@ -3022,8 +3038,8 @@ This section details the public API for \class{set} and \class{frozenset} objects. Any functionality not listed below is best accessed using the either the abstract object protocol (including -\cfunction{PyObject_CallMethod()}, \cfunction{PyObject_RichCompareBool()}, -\cfunction{PyObject_Hash()}, \cfunction{PyObject_Repr()}, +\cfunction{PyObject_CallMethod()}, \cfunction{PyObject_RichCompareBool()}, +\cfunction{PyObject_Hash()}, \cfunction{PyObject_Repr()}, \cfunction{PyObject_IsTrue()}, \cfunction{PyObject_Print()}, and \cfunction{PyObject_GetIter()}) or the abstract number protocol (including @@ -3040,7 +3056,7 @@ block of memory for medium and large sized sets (much like list storage). None of the fields of this structure should be considered public and are subject to change. All access should be done through the - documented API rather than by manipulating the values in the structure. + documented API rather than by manipulating the values in the structure. \end{ctypedesc} @@ -3059,7 +3075,7 @@ Likewise, the constructor functions work with any iterable Python object. \begin{cfuncdesc}{int}{PyAnySet_Check}{PyObject *p} - Return true if \var{p} is a \class{set} object, a \class{frozenset} + Return true if \var{p} is a \class{set} object, a \class{frozenset} object, or an instance of a subtype. \end{cfuncdesc} @@ -3112,7 +3128,7 @@ function does not automatically convert unhashable sets into temporary frozensets. Raise a \exception{TypeError} if the \var{key} is unhashable. Raise \exception{PyExc_SystemError} if \var{anyset} is not a \class{set}, - \class{frozenset}, or an instance of a subtype. + \class{frozenset}, or an instance of a subtype. \end{cfuncdesc} The following functions are available for instances of \class{set} or @@ -3134,7 +3150,7 @@ unhashable. Unlike the Python \method{discard()} method, this function does not automatically convert unhashable sets into temporary frozensets. Raise \exception{PyExc_SystemError} if \var{set} is an not an instance - of \class{set} or its subtype. + of \class{set} or its subtype. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PySet_Pop}{PyObject *set} @@ -3142,7 +3158,7 @@ and removes the object from the \var{set}. Return \NULL{} on failure. Raise \exception{KeyError} if the set is empty. Raise a \exception{SystemError} if \var{set} is an not an instance - of \class{set} or its subtype. + of \class{set} or its subtype. \end{cfuncdesc} \begin{cfuncdesc}{int}{PySet_Clear}{PyObject *set} Modified: python/trunk/Doc/api/exceptions.tex ============================================================================== --- python/trunk/Doc/api/exceptions.tex (original) +++ python/trunk/Doc/api/exceptions.tex Sun May 14 01:28:20 2006 @@ -135,13 +135,32 @@ codes, similar to \cfunction{printf()}. The \code{width.precision} before a format code is parsed, but the width part is ignored. - \begin{tableii}{c|l}{character}{Character}{Meaning} - \lineii{c}{Character, as an \ctype{int} parameter} - \lineii{d}{Number in decimal, as an \ctype{int} parameter} - \lineii{x}{Number in hexadecimal, as an \ctype{int} parameter} - \lineii{s}{A string, as a \ctype{char *} parameter} - \lineii{p}{A hex pointer, as a \ctype{void *} parameter} - \end{tableii} + % This should be exactly the same as the table in PyString_FromFormat. + % One should just refer to the other. + + % The descriptions for %zd and %zu are wrong, but the truth is complicated + % because not all compilers support the %z width modifier -- we fake it + % when necessary via interpolating PY_FORMAT_SIZE_T. + + % %u, %lu, %zu should have "new in Python 2.5" blurbs. + + \begin{tableiii}{l|l|l}{member}{Format Characters}{Type}{Comment} + \lineiii{\%\%}{\emph{n/a}}{The literal \% character.} + \lineiii{\%c}{int}{A single character, represented as an C int.} + \lineiii{\%d}{int}{Exactly equivalent to \code{printf("\%d")}.} + \lineiii{\%u}{unsigned int}{Exactly equivalent to \code{printf("\%u")}.} + \lineiii{\%ld}{long}{Exactly equivalent to \code{printf("\%ld")}.} + \lineiii{\%lu}{unsigned long}{Exactly equivalent to \code{printf("\%lu")}.} + \lineiii{\%zd}{Py_ssize_t}{Exactly equivalent to \code{printf("\%zd")}.} + \lineiii{\%zu}{ssize_t}{Exactly equivalent to \code{printf("\%zu")}.} + \lineiii{\%i}{int}{Exactly equivalent to \code{printf("\%i")}.} + \lineiii{\%x}{int}{Exactly equivalent to \code{printf("\%x")}.} + \lineiii{\%s}{char*}{A null-terminated C character array.} + \lineiii{\%p}{void*}{The hex representation of a C pointer. + Mostly equivalent to \code{printf("\%p")} except that it is + guaranteed to start with the literal \code{0x} regardless of + what the platform's \code{printf} yields.} + \end{tableiii} An unrecognized format character causes all the rest of the format string to be copied as-is to the result string, and any extra @@ -275,8 +294,8 @@ command line documentation. There is no C API for warning control. \end{cfuncdesc} -\begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category, - const char *message, const char *filename, int lineno, +\begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category, + const char *message, const char *filename, int lineno, const char *module, PyObject *registry} Issue a warning message with explicit control over all warning attributes. This is a straightforward wrapper around the Python @@ -402,5 +421,5 @@ \withsubitem{(built-in exception)}{\ttindex{BaseException}} String exceptions are still supported in the interpreter to allow -existing code to run unmodified, but this will also change in a future +existing code to run unmodified, but this will also change in a future release. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun May 14 01:28:20 2006 @@ -72,7 +72,7 @@ Extension Modules ----------------- -- On Win32, os.listdir now supports arbitrarily-long Unicode path names +- On Win32, os.listdir now supports arbitrarily-long Unicode path names (up to the system limit of 32K characters). - Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. @@ -200,6 +200,10 @@ C API ----- +- ``PyString_FromFormat``, ``PyErr_Format``, and ``PyString_FromFormatV`` + now accept formats "%u" for unsigned ints, "%lu" for unsigned longs, + and "%zu" for unsigned integers of type ``size_t``. + Tests ----- Modified: python/trunk/Modules/_testcapimodule.c ============================================================================== --- python/trunk/Modules/_testcapimodule.c (original) +++ python/trunk/Modules/_testcapimodule.c Sun May 14 01:28:20 2006 @@ -486,8 +486,8 @@ return Py_None; } -static -PyObject *codec_incrementalencoder(PyObject *self, PyObject *args) +static PyObject * +codec_incrementalencoder(PyObject *self, PyObject *args) { const char *encoding, *errors = NULL; if (!PyArg_ParseTuple(args, "s|s:test_incrementalencoder", @@ -496,8 +496,8 @@ return PyCodec_IncrementalEncoder(encoding, errors); } -static -PyObject *codec_incrementaldecoder(PyObject *self, PyObject *args) +static PyObject * +codec_incrementaldecoder(PyObject *self, PyObject *args) { const char *encoding, *errors = NULL; if (!PyArg_ParseTuple(args, "s|s:test_incrementaldecoder", @@ -660,6 +660,44 @@ } #endif +/* Some tests of PyString_FromFormat(). This needs more tests. + * PyString_FromFormat() also needs docs. + */ +static PyObject * +test_string_from_format(PyObject *self, PyObject *args) +{ + PyObject *result; + char *msg; + +#define CHECK_1_FORMAT(FORMAT, TYPE) \ + result = PyString_FromFormat(FORMAT, (TYPE)1); \ + if (result == NULL) \ + return NULL; \ + if (strcmp(PyString_AsString(result), "1")) { \ + msg = FORMAT " failed at 1"; \ + goto Fail; \ + } \ + Py_DECREF(result) + + CHECK_1_FORMAT("%d", int); + CHECK_1_FORMAT("%ld", long); + /* The z width modifier was added in Python 2.5. */ + CHECK_1_FORMAT("%zd", Py_ssize_t); + + /* The u type code was added in Python 2.5. */ + CHECK_1_FORMAT("%u", unsigned int); + CHECK_1_FORMAT("%lu", unsigned long); + CHECK_1_FORMAT("%zu", size_t); + + Py_RETURN_NONE; + + Fail: + Py_XDECREF(result); + return raiseTestError("test_string_from_format", msg); + +#undef CHECK_1_FORMAT +} + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"test_config", (PyCFunction)test_config, METH_NOARGS}, @@ -669,6 +707,7 @@ {"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS}, {"test_k_code", (PyCFunction)test_k_code, METH_NOARGS}, {"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS}, + {"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS}, {"getargs_b", getargs_b, METH_VARARGS}, {"getargs_B", getargs_B, METH_VARARGS}, Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sun May 14 01:28:20 2006 @@ -176,14 +176,11 @@ while (*++f && *f != '%' && !isalpha(Py_CHARMASK(*f))) ; - /* skip the 'l' in %ld, since it doesn't change the - width. although only %d is supported (see - "expand" section below), others can be easily - added */ - if (*f == 'l' && *(f+1) == 'd') - ++f; - /* likewise for %zd */ - if (*f == 'z' && *(f+1) == 'd') + /* skip the 'l' or 'z' in {%ld, %zd, %lu, %zu} since + * they don't affect the amount of space we reserve. + */ + if ((*f == 'l' || *f == 'z') && + (f[1] == 'd' || f[1] == 'u')) ++f; switch (*f) { @@ -193,7 +190,7 @@ case '%': n++; break; - case 'd': case 'i': case 'x': + case 'd': case 'u': case 'i': case 'x': (void) va_arg(count, int); /* 20 bytes is enough to hold a 64-bit integer. Decimal takes the most space. @@ -255,14 +252,14 @@ } while (*f && *f != '%' && !isalpha(Py_CHARMASK(*f))) f++; - /* handle the long flag, but only for %ld. others - can be added when necessary. */ - if (*f == 'l' && *(f+1) == 'd') { + /* handle the long flag, but only for %ld and %lu. + others can be added when necessary. */ + if (*f == 'l' && (f[1] == 'd' || f[1] == 'u')) { longflag = 1; ++f; } /* handle the size_t flag. */ - if (*f == 'z' && *(f+1) == 'd') { + if (*f == 'z' && (f[1] == 'd' || f[1] == 'u')) { size_tflag = 1; ++f; } @@ -281,6 +278,18 @@ sprintf(s, "%d", va_arg(vargs, int)); s += strlen(s); break; + case 'u': + if (longflag) + sprintf(s, "%lu", + va_arg(vargs, unsigned long)); + else if (size_tflag) + sprintf(s, "%" PY_FORMAT_SIZE_T "u", + va_arg(vargs, size_t)); + else + sprintf(s, "%u", + va_arg(vargs, unsigned int)); + s += strlen(s); + break; case 'i': sprintf(s, "%i", va_arg(vargs, int)); s += strlen(s); From python-checkins at python.org Sun May 14 01:31:05 2006 From: python-checkins at python.org (tim.peters) Date: Sun, 14 May 2006 01:31:05 +0200 (CEST) Subject: [Python-checkins] r45993 - python/trunk/Doc/api/concrete.tex python/trunk/Doc/api/exceptions.tex Message-ID: <20060513233105.79B811E4012@bag.python.org> Author: tim.peters Date: Sun May 14 01:31:05 2006 New Revision: 45993 Modified: python/trunk/Doc/api/concrete.tex python/trunk/Doc/api/exceptions.tex Log: Typo repair. Modified: python/trunk/Doc/api/concrete.tex ============================================================================== --- python/trunk/Doc/api/concrete.tex (original) +++ python/trunk/Doc/api/concrete.tex Sun May 14 01:31:05 2006 @@ -635,7 +635,7 @@ \lineiii{\%ld}{long}{Exactly equivalent to \code{printf("\%ld")}.} \lineiii{\%lu}{unsigned long}{Exactly equivalent to \code{printf("\%lu")}.} \lineiii{\%zd}{Py_ssize_t}{Exactly equivalent to \code{printf("\%zd")}.} - \lineiii{\%zu}{ssize_t}{Exactly equivalent to \code{printf("\%zu")}.} + \lineiii{\%zu}{size_t}{Exactly equivalent to \code{printf("\%zu")}.} \lineiii{\%i}{int}{Exactly equivalent to \code{printf("\%i")}.} \lineiii{\%x}{int}{Exactly equivalent to \code{printf("\%x")}.} \lineiii{\%s}{char*}{A null-terminated C character array.} Modified: python/trunk/Doc/api/exceptions.tex ============================================================================== --- python/trunk/Doc/api/exceptions.tex (original) +++ python/trunk/Doc/api/exceptions.tex Sun May 14 01:31:05 2006 @@ -152,7 +152,7 @@ \lineiii{\%ld}{long}{Exactly equivalent to \code{printf("\%ld")}.} \lineiii{\%lu}{unsigned long}{Exactly equivalent to \code{printf("\%lu")}.} \lineiii{\%zd}{Py_ssize_t}{Exactly equivalent to \code{printf("\%zd")}.} - \lineiii{\%zu}{ssize_t}{Exactly equivalent to \code{printf("\%zu")}.} + \lineiii{\%zu}{size_t}{Exactly equivalent to \code{printf("\%zu")}.} \lineiii{\%i}{int}{Exactly equivalent to \code{printf("\%i")}.} \lineiii{\%x}{int}{Exactly equivalent to \code{printf("\%x")}.} \lineiii{\%s}{char*}{A null-terminated C character array.} From python-checkins at python.org Sun May 14 01:33:19 2006 From: python-checkins at python.org (tim.peters) Date: Sun, 14 May 2006 01:33:19 +0200 (CEST) Subject: [Python-checkins] r45994 - python/trunk/Modules/_testcapimodule.c Message-ID: <20060513233319.740471E4011@bag.python.org> Author: tim.peters Date: Sun May 14 01:33:19 2006 New Revision: 45994 Modified: python/trunk/Modules/_testcapimodule.c Log: Remove lie in new comment. Modified: python/trunk/Modules/_testcapimodule.c ============================================================================== --- python/trunk/Modules/_testcapimodule.c (original) +++ python/trunk/Modules/_testcapimodule.c Sun May 14 01:33:19 2006 @@ -660,9 +660,7 @@ } #endif -/* Some tests of PyString_FromFormat(). This needs more tests. - * PyString_FromFormat() also needs docs. - */ +/* Some tests of PyString_FromFormat(). This needs more tests. */ static PyObject * test_string_from_format(PyObject *self, PyObject *args) { From buildbot at python.org Sun May 14 02:49:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 14 May 2006 00:49:11 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060514004911.9DC5C1E4011@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/359 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sun May 14 21:56:37 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 14 May 2006 21:56:37 +0200 (CEST) Subject: [Python-checkins] r45995 - in python/trunk: Lib/plat-mac/bundlebuilder.py Mac/OSX/IDLE Mac/OSX/IDLE/Makefile.in Mac/OSX/IDLE/idlemain.py Mac/OSX/Icons Mac/OSX/Icons/IDLE.icns Mac/OSX/Icons/PythonCompiled.icns Mac/OSX/Icons/PythonLauncher.icns Mac/OSX/Icons/PythonSource.icns Mac/OSX/Makefile Mac/OSX/Makefile.in Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib Mac/OSX/PythonLauncher/Info.plist Mac/OSX/PythonLauncher/Makefile.in Mac/OSX/PythonLauncher/PythonCompiled.icns Mac/OSX/PythonLauncher/PythonInterpreter.icns Mac/OSX/PythonLauncher/PythonLauncher.pbproj Mac/OSX/PythonLauncher/PythonSource.icns Mac/OSX/PythonLauncher/PythonWSource.icns Mac/OSX/Tools Mac/OSX/Tools/pythonw.c Mac/OSXResources/framework/Info.plist Makefile.pre.in configure configure.in Message-ID: <20060514195637.03D321E4012@bag.python.org> Author: ronald.oussoren Date: Sun May 14 21:56:34 2006 New Revision: 45995 Added: python/trunk/Mac/OSX/IDLE/ python/trunk/Mac/OSX/IDLE/Makefile.in python/trunk/Mac/OSX/IDLE/idlemain.py (contents, props changed) python/trunk/Mac/OSX/Icons/ python/trunk/Mac/OSX/Icons/IDLE.icns (contents, props changed) python/trunk/Mac/OSX/Icons/PythonCompiled.icns (contents, props changed) python/trunk/Mac/OSX/Icons/PythonLauncher.icns (contents, props changed) python/trunk/Mac/OSX/Icons/PythonSource.icns (contents, props changed) python/trunk/Mac/OSX/Makefile.in python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/ python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib (contents, props changed) python/trunk/Mac/OSX/PythonLauncher/Info.plist python/trunk/Mac/OSX/PythonLauncher/Makefile.in python/trunk/Mac/OSX/Tools/ python/trunk/Mac/OSX/Tools/pythonw.c (contents, props changed) Removed: python/trunk/Mac/OSX/Makefile python/trunk/Mac/OSX/PythonLauncher/PythonCompiled.icns python/trunk/Mac/OSX/PythonLauncher/PythonInterpreter.icns python/trunk/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/ python/trunk/Mac/OSX/PythonLauncher/PythonSource.icns python/trunk/Mac/OSX/PythonLauncher/PythonWSource.icns Modified: python/trunk/Lib/plat-mac/bundlebuilder.py python/trunk/Mac/OSXResources/framework/Info.plist python/trunk/Makefile.pre.in python/trunk/configure python/trunk/configure.in Log: Rework the build system for osx applications: * Don't use xcodebuild for building PythonLauncher, but use a normal unix makefile. This makes it a lot easier to use the same build flags as for the rest of python (e.g. make a universal version of python launcher) * Convert the mac makefile-s to makefile.in-s and use configure to set makefile variables instead of forwarding them as command-line arguments * Add a C version of pythonw, that we you can use '#!/usr/local/bin/pythonw' * Build IDLE.app using bundlebuilder instead of BuildApplet, that will allow easier modification of the bundle contents later on. Modified: python/trunk/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/trunk/Lib/plat-mac/bundlebuilder.py (original) +++ python/trunk/Lib/plat-mac/bundlebuilder.py Sun May 14 21:56:34 2006 @@ -145,11 +145,24 @@ self.message("Building %s" % repr(self.bundlepath), 1) if os.path.exists(self.bundlepath): shutil.rmtree(self.bundlepath) - os.mkdir(self.bundlepath) - self.preProcess() - self._copyFiles() - self._addMetaFiles() - self.postProcess() + if os.path.exists(self.bundlepath + '~'): + shutil.rmtree(self.bundlepath + '~') + bp = self.bundlepath + + # Create the app bundle in a temporary location and then + # rename the completed bundle. This way the Finder will + # never see an incomplete bundle (where it might pick up + # and cache the wrong meta data) + self.bundlepath = bp + '~' + try: + os.mkdir(self.bundlepath) + self.preProcess() + self._copyFiles() + self._addMetaFiles() + self.postProcess() + os.rename(self.bundlepath, bp) + finally: + self.bundlepath = bp self.message("Done.", 1) def preProcess(self): Added: python/trunk/Mac/OSX/IDLE/Makefile.in ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/IDLE/Makefile.in Sun May 14 21:56:34 2006 @@ -0,0 +1,48 @@ +CC=@CC@ +LD=@CC@ +BASECFLAGS=@BASECFLAGS@ +OPT=@OPT@ +CFLAGS=$(BASECFLAGS) $(OPT) +LDFLAGS=@LDFLAGS@ +srcdir= @srcdir@ +VERSION= @VERSION@ +UNIVERSALSDK=@UNIVERSALSDK@ +builddir= ../../.. + +RUNSHARED= @RUNSHARED@ +BUILDEXE= @BUILDEXEEXT@ +BUILDPYTHON= ../../../python$(BUILDEXE) + +# Deployment target selected during configure, to be checked +# by distutils +MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ + at EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET + +BUNDLEBULDER=$(srcdir)/../../../Lib/plat-mac/bundlebuilder.py + +PYTHONAPPSDIR=/Applications/MacPython $(VERSION) + +all: IDLE.app + +install: IDLE.app + test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)" + -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" + cp -r IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)" + +clean: + rm -rf IDLE.app + +IDLE.app: \ + $(srcdir)/../Icons/IDLE.icns $(srcdir)/idlemain.py \ + $(srcdir)/../Icons/PythonSource.icns \ + $(srcdir)/../Icons/PythonCompiled.icns + rm -fr PythonLauncher.app + $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \ + --builddir=. \ + --name=IDLE \ + --mainprogram=$(srcdir)/idlemain.py \ + --iconfile=$(srcdir)/../Icons/IDLE.icns \ + --bundle-id=org.python.IDLE \ + --resource=$(srcdir)/../Icons/PythonSource.icns \ + --resource=$(srcdir)/../Icons/PythonCompiled.icns \ + build Added: python/trunk/Mac/OSX/IDLE/idlemain.py ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/IDLE/idlemain.py Sun May 14 21:56:34 2006 @@ -0,0 +1,19 @@ +import argvemulator +from idlelib.PyShell import main +import sys, os + +# Make sure sys.executable points to the python interpreter inside the +# framework, instead of at the helper executable inside the application +# bundle (the latter works, but doesn't allow access to the window server) +sys.executable = os.path.join(sys.prefix, 'bin', 'python') + +# Look for the -psn argument that the launcher adds and remove it, it will +# only confuse the IDLE startup code. +for idx, value in enumerate(sys.argv): + if value.startswith('-psn_'): + del sys.argv[idx] + break + +argvemulator.ArgvCollector().mainloop() +if __name__ == '__main__': + main() Added: python/trunk/Mac/OSX/Icons/IDLE.icns ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/Icons/PythonCompiled.icns ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/Icons/PythonLauncher.icns ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/Icons/PythonSource.icns ============================================================================== Binary file. No diff available. Deleted: /python/trunk/Mac/OSX/Makefile ============================================================================== --- /python/trunk/Mac/OSX/Makefile Sun May 14 21:56:34 2006 +++ (empty file) @@ -1,273 +0,0 @@ -# This file can be invoked from the various frameworkinstall... targets in the -# main Makefile. The next couple of variables are overridden on the -# commandline in that case. - -VERSION=2.5 -builddir = ../.. -srcdir = ../.. -prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION) -LIBDEST=$(prefix)/lib/python$(VERSION) -BUILDPYTHON=$(builddir)/python.exe -DESTDIR= -# Test whether to use xcodebuild (preferred) or pbxbuild: -ifeq ($(shell ls /usr/bin/xcodebuild),/usr/bin/xcodebuild) -PBXBUILD=xcodebuild -else -PBXBUILD=pbxbuild -endif - -# These are normally glimpsed from the previous set -bindir=/usr/local/bin -PYTHONAPPSPATH=/Applications/MacPython-$(VERSION) -PYTHONAPPSDIR=$(PYTHONAPPSPATH) -APPINSTALLDIR=$(prefix)/Resources/Python.app - -# Variables for installing the "normal" unix binaries -INSTALLED_PYTHON=$(prefix)/bin/python -INSTALLED_PYTHONW=$(APPINSTALLDIR)/Contents/MacOS/Python - -# Items more-or-less copied from the main Makefile -DIRMODE=755 -FILEMODE=644 -INSTALL=/usr/bin/install -c -INSTALL_SYMLINK=ln -fsn -INSTALL_PROGRAM=${INSTALL} -INSTALL_SCRIPT= ${INSTALL_PROGRAM} -INSTALL_DATA= ${INSTALL} -m ${FILEMODE} -LN=ln -STRIPFLAG=-s -##OPT=-g -O3 -Wall -Wstrict-prototypes -Wno-long-double -no-cpp-precomp \ -## -fno-common -dynamic -##INCLUDES=-I$(builddir) -I$(srcdir)/Include -I$(srcdir)/Mac/Include -##DEFINES= -## -##CFLAGS=$(OPT) $(DEFINES) $(INCLUDES) -##LDFLAGS=-F$(builddir) -framework System -framework Python -framework Carbon \ -## -framework Foundation -##CC=cc -##LD=cc -CPMAC=/Developer/Tools/CpMac - -APPTEMPLATE=$(srcdir)/Mac/OSXResources/app -APPSUBDIRS=MacOS Resources Resources/English.lproj \ - Resources/English.lproj/Documentation \ - Resources/English.lproj/Documentation/doc \ - Resources/English.lproj/Documentation/ide -DOCDIR=$(srcdir)/Mac/OSXResources/app/Resources/English.lproj/Documentation -DOCINDEX=$(DOCDIR)/"Documentation idx" -CACHERSRC=$(srcdir)/Mac/scripts/cachersrc.py -compileall=$(srcdir)/Lib/compileall.py -bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py - -installapps: install_PythonLauncher install_Python install_BuildApplet install_IDE \ - install_IDLE install_PackageManager checkapplepython - -install_PythonLauncher: - cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ - $(PBXBUILD) -target PythonLauncher -buildstyle Deployment install \ - DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH) - -install_Python: - @if test ! -f $(DOCINDEX); then \ - echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \ - fi - @for i in $(PYTHONAPPSDIR) $(APPINSTALLDIR) $(APPINSTALLDIR)/Contents; do \ - if test ! -d $(DESTDIR)$$i; then \ - echo "Creating directory $(DESTDIR)$$i"; \ - $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ - fi;\ - done - @for i in $(APPSUBDIRS); do \ - if test ! -d $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i; then \ - echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \ - $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i; \ - else true; \ - fi; \ - done - @for d in . $(APPSUBDIRS); \ - do \ - a=$(APPTEMPLATE)/$$d; \ - if test ! -d $$a; then continue; else true; fi; \ - b=$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d; \ - for i in $$a/*; \ - do \ - case $$i in \ - *CVS) ;; \ - *.py[co]) ;; \ - *.orig) ;; \ - *~) ;; \ - *idx) \ - echo $(CPMAC) "$$i" $$b; \ - $(CPMAC) "$$i" $$b; \ - ;; \ - *) \ - if test -d $$i; then continue; fi; \ - if test -x $$i; then \ - echo $(INSTALL_SCRIPT) $$i $$b; \ - $(INSTALL_SCRIPT) $$i $$b; \ - else \ - echo $(INSTALL_DATA) $$i $$b; \ - $(INSTALL_DATA) $$i $$b; \ - fi;; \ - esac; \ - done; \ - done - $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) $(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python - -install_IDE: - @if ! $(BUILDPYTHON) -c "import waste"; then \ - echo PythonIDE needs the \"waste\" extension module; \ - echo See Mac/OSX/README for details; \ - else \ - echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot "$(DESTDIR)" \ - --python $(INSTALLED_PYTHONW) \ - --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ - $(srcdir)/Mac/Tools/IDE/PythonIDE.py ; \ - $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot "$(DESTDIR)" \ - --python $(INSTALLED_PYTHONW) \ - --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ - $(srcdir)/Mac/Tools/IDE/PythonIDE.py; \ - fi - -install_PackageManager: - @if ! $(BUILDPYTHON) -c "import waste"; then \ - echo PackageManager needs the \"waste\" extension module; \ - echo See Mac/OSX/README for details; \ - else \ - echo $(BUILDPYTHON) $(bundlebuilder) \ - --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot "$(DESTDIR)" \ - --python $(INSTALLED_PYTHONW) \ - --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ - --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ - --iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \ - --creator Pimp build; \ - $(BUILDPYTHON) $(bundlebuilder) \ - --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot "$(DESTDIR)" \ - --python $(INSTALLED_PYTHONW) \ - --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ - --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ - --iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \ - --creator Pimp build; \ - fi - -install_IDLE: - @if ! $(BUILDPYTHON) -c "import _tkinter"; then \ - echo IDLE needs the \"Tkinter\" extension module; \ - echo See Mac/OSX/README for details; \ - else \ - echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --python $(INSTALLED_PYTHONW) \ - --destroot "$(DESTDIR)" \ - --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ - --extra $(srcdir)/Lib/idlelib \ - $(srcdir)/Tools/scripts/idle ; \ - $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --python $(INSTALLED_PYTHONW) \ - --destroot "$(DESTDIR)" \ - --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ - --extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \ - $(srcdir)/Tools/scripts/idle ; \ - fi - - -install_BuildApplet: - $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot "$(DESTDIR)" \ - --python $(INSTALLED_PYTHONW) \ - --output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \ - $(srcdir)/Mac/scripts/BuildApplet.py - -MACLIBDEST=$(LIBDEST)/plat-mac -MACTOOLSDEST=$(prefix)/Mac/Tools -MACTOOLSSRC=$(srcdir)/Mac/Tools -MACTOOLSSUBDIRS=IDE -installmacsubtree: - @for i in $(MACTOOLSDEST); \ - do \ - if test ! -d $(DESTDIR)$$i; then \ - echo "Creating directory $(DESTDIR)$$i"; \ - $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ - else true; \ - fi; \ - done - @for d in $(MACTOOLSSUBDIRS); \ - do \ - a=$(MACTOOLSSRC)/$$d; \ - if test ! -d $$a; then continue; else true; fi; \ - b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ - if test ! -d $$b; then \ - echo "Creating directory $$b"; \ - $(INSTALL) -d -m $(DIRMODE) $$b; \ - else true; \ - fi; \ - done - @for d in $(MACTOOLSSUBDIRS); \ - do \ - a=$(MACTOOLSSRC)/$$d; \ - if test ! -d $$a; then continue; else true; fi; \ - b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ - for i in $$a/*; \ - do \ - case $$i in \ - *CVS) ;; \ - *.py[co]) ;; \ - *.orig) ;; \ - *~) ;; \ - *.rsrc) \ - echo $(CPMAC) $$i $$b ; \ - $(CPMAC) $$i $$b ; \ - ;; \ - *) \ - if test -d $$i; then continue; fi; \ - if test -x $$i; then \ - echo $(INSTALL_SCRIPT) $$i $$b; \ - $(INSTALL_SCRIPT) $$i $$b; \ - else \ - echo $(INSTALL_DATA) $$i $$b; \ - $(INSTALL_DATA) $$i $$b; \ - fi;; \ - esac; \ - done; \ - done - - - $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST) - $(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) - $(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) - -# -# We use the full name here in stead of $(INSTALLED_PYTHONW), because -# the latter may be overridden by Makefile.jaguar when building for a pre-installed -# /usr/bin/python -$(APPINSTALLDIR)/Contents/MacOS/Python: install_Python - -# $(INSTALLED_PYTHON) has to be done by the main Makefile, we cannot do that here. -# At least this rule will give an error if it doesn't exist. - -installunixtools: - $(INSTALL) -d $(DESTDIR)$(bindir) - $(INSTALL_SYMLINK) $(INSTALLED_PYTHON) $(DESTDIR)$(bindir)/python$(VERSION) - $(INSTALL_SYMLINK) python$(VERSION) $(DESTDIR)$(bindir)/python - echo "#!/bin/sh" > pythonw.sh - echo "exec \"$(INSTALLED_PYTHONW)\" \"\$$@\"" >> pythonw.sh - $(INSTALL) pythonw.sh $(DESTDIR)$(bindir)/pythonw$(VERSION) - $(INSTALL_SYMLINK) pythonw$(VERSION) $(DESTDIR)$(bindir)/pythonw - -installextras: - $(INSTALL) -d $(DESTDIR)$(PYTHONAPPSDIR)/Extras - $(INSTALL) $(srcdir)/Mac/OSX/Extras.ReadMe.txt $(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe - $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Demo \ - $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo - $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Tools \ - $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Tools - -checkapplepython: - @if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \ - echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ - echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \ - fi - Added: python/trunk/Mac/OSX/Makefile.in ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/Makefile.in Sun May 14 21:56:34 2006 @@ -0,0 +1,235 @@ +# This file can be invoked from the various frameworkinstall... targets in the +# main Makefile. The next couple of variables are overridden on the +# commandline in that case. + +VERSION=@VERSION@ +builddir = ../.. +srcdir = @srcdir@ +prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION) +LIBDEST=$(prefix)/lib/python$(VERSION) +BUILDPYTHON=$(builddir)/python.exe +DESTDIR= + +# These are normally glimpsed from the previous set +bindir=@exec_prefix@/bin +PYTHONAPPSDIR=/Applications/MacPython $(VERSION) +APPINSTALLDIR=$(prefix)/Resources/Python.app + +# Variables for installing the "normal" unix binaries +INSTALLED_PYDOC=$(prefix)/bin/pydoc +INSTALLED_IDLE=$(prefix)/bin/idle +INSTALLED_PYTHON=$(prefix)/bin/python +INSTALLED_PYTHONW=$(prefix)/bin/pythonw +INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/Python + +# Items more-or-less copied from the main Makefile +DIRMODE=755 +FILEMODE=644 +INSTALL=@INSTALL@ +INSTALL_SYMLINK=ln -fsn +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +INSTALL_SCRIPT= @INSTALL_SCRIPT@ +INSTALL_DATA=@INSTALL_DATA@ +LN=@LN@ +STRIPFLAG=-s +CPMAC=/Developer/Tools/CpMac + +APPTEMPLATE=$(srcdir)/OSXResources/app +APPSUBDIRS=MacOS Resources Resources/English.lproj \ + Resources/English.lproj/Documentation \ + Resources/English.lproj/Documentation/doc \ + Resources/English.lproj/Documentation/ide +DOCDIR=$(srcdir)/Mac/OSXResources/app/Resources/English.lproj/Documentation +DOCINDEX=$(DOCDIR)/"Documentation idx" +CACHERSRC=$(srcdir)/../scripts/cachersrc.py +compileall=$(srcdir)/../../Lib/compileall.py + +installapps: install_Python install_BuildApplet install_PythonLauncher \ + install_IDLE checkapplepython install_pythonw install_versionedtools + +install_pythonw: pythonw + $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)" + $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)" + ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python" + ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw" + +# +# Install unix tools in /usr/local/bin. These are just aliases for the +# actual installation inside the framework. +# +installunixtools: + if [ ! -d "$(DESTDIR)/usr/local/bin" ]; then \ + $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)/usr/local/bin" ;\ + fi + for fn in `ls "$(DESTDIR)$(prefix)/bin/"` ; \ + do \ + ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)/usr/local/bin/$${fn}" ;\ + done + +# By default most tools are installed without a version in their basename, to +# make it easier to install (and use) several python versions side-by-side move +# the tools to a version-specific name and add the non-versioned name as an +# alias. +install_versionedtools: + for fn in idle pydoc python-config ;\ + do \ + mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ + ln -sf "$${fn}$(VERSION)" "$${fn}" ;\ + done + rm -f "$(DESTDIR)$(prefix)/bin/smtpd.py" + + +pythonw: $(srcdir)/Tools/pythonw.c + $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ + -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' + + +install_PythonLauncher: + cd PythonLauncher && make install DESTDIR=$(DESTDIR) + +install_Python: + @if test ! -f $(DOCINDEX); then \ + echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \ + fi + @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \ + if test ! -d "$(DESTDIR)$$i"; then \ + echo "Creating directory $(DESTDIR)$$i"; \ + $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \ + fi;\ + done + @for i in $(APPSUBDIRS); do \ + if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \ + echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \ + $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \ + else true; \ + fi; \ + done + @for d in . $(APPSUBDIRS); \ + do \ + a=$(APPTEMPLATE)/$$d; \ + if test ! -d $$a; then continue; else true; fi; \ + b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \ + for i in $$a/*; \ + do \ + case $$i in \ + *CVS) ;; \ + *.svn) ;; \ + *.py[co]) ;; \ + *.orig) ;; \ + *~) ;; \ + *idx) \ + echo $(CPMAC) "$$i" $$b; \ + $(CPMAC) "$$i" "$$b"; \ + ;; \ + *) \ + if test -d $$i; then continue; fi; \ + if test -x $$i; then \ + echo $(INSTALL_SCRIPT) "$$i" "$$b"; \ + $(INSTALL_SCRIPT) "$$i" "$$b"; \ + else \ + echo $(INSTALL_DATA) "$$i" "$$b"; \ + $(INSTALL_DATA) "$$i" "$$b"; \ + fi;; \ + esac; \ + done; \ + done + $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python" + +install_IDLE: + cd IDLE && make install + +install_BuildApplet: + $(BUILDPYTHON) $(srcdir)/../scripts/BuildApplet.py \ + --destroot "$(DESTDIR)" \ + --python $(INSTALLED_PYTHONAPP) \ + --output "$(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app" \ + $(srcdir)/../scripts/BuildApplet.py + +MACLIBDEST=$(LIBDEST)/plat-mac +MACTOOLSDEST=$(prefix)/Mac/Tools +MACTOOLSSRC=$(srcdir)/Mac/Tools +MACTOOLSSUBDIRS=IDE + +installmacsubtree: + @for i in $(MACTOOLSDEST); \ + do \ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $(DESTDIR)$$i"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ + else true; \ + fi; \ + done + @for d in $(MACTOOLSSUBDIRS); \ + do \ + a=$(MACTOOLSSRC)/$$d; \ + if test ! -d $$a; then continue; else true; fi; \ + b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ + if test ! -d $$b; then \ + echo "Creating directory $$b"; \ + $(INSTALL) -d -m $(DIRMODE) $$b; \ + else true; \ + fi; \ + done + @for d in $(MACTOOLSSUBDIRS); \ + do \ + a=$(MACTOOLSSRC)/$$d; \ + if test ! -d $$a; then continue; else true; fi; \ + b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ + for i in $$a/*; \ + do \ + case $$i in \ + *CVS) ;; \ + *.svn) ;; \ + *.py[co]) ;; \ + *.orig) ;; \ + *~) ;; \ + *.rsrc) \ + echo $(CPMAC) $$i $$b ; \ + $(CPMAC) $$i $$b ; \ + ;; \ + *) \ + if test -d $$i; then continue; fi; \ + if test -x $$i; then \ + echo $(INSTALL_SCRIPT) $$i $$b; \ + $(INSTALL_SCRIPT) $$i $$b; \ + else \ + echo $(INSTALL_DATA) $$i $$b; \ + $(INSTALL_DATA) $$i $$b; \ + fi;; \ + esac; \ + done; \ + done + + + $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST) + $(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) + $(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) + +# +# We use the full name here in stead of $(INSTALLED_PYTHONAPP), because +# the latter may be overridden by Makefile.jaguar when building for a pre-installed +$(INSTALLED_PYTHONAPP)/Contents/MacOS/Python: install_Python + +# $(INSTALLED_PYTHON) has to be done by the main Makefile, we cannot do that here. +# At least this rule will give an error if it doesn't exist. + +installextras: + $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras" + $(INSTALL) $(srcdir)/Mac/OSX/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt" + $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Demo \ + "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo" + + +checkapplepython: + @if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \ + echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ + echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \ + fi + + +clean: + rm pythonw + cd PythonLauncher && make clean + cd IDLE && make clean + + Added: python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib Sun May 14 21:56:34 2006 @@ -0,0 +1,26 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {"do_apply" = id; "do_filetype" = id; "do_reset" = id; }; + CLASS = PreferencesWindowController; + LANGUAGE = ObjC; + OUTLETS = { + commandline = NSTextField; + debug = NSButton; + filetype = NSPopUpButton; + honourhashbang = NSButton; + inspect = NSButton; + interpreter = NSTextField; + nosite = NSButton; + optimize = NSButton; + others = NSTextField; + tabs = NSButton; + verbose = NSButton; + "with_terminal" = NSButton; + }; + SUPERCLASS = NSWindowController; + } + ); + IBVersion = 1; +} \ No newline at end of file Added: python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib Sun May 14 21:56:34 2006 @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 565 235 519 534 0 0 1280 1002 + IBFramework Version + 364.0 + IBOpenObjects + + 5 + + IBSystem Version + 7H63 + + Added: python/trunk/Mac/OSX/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/PythonLauncher/Info.plist ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/PythonLauncher/Info.plist Sun May 14 21:56:34 2006 @@ -0,0 +1,65 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + py + pyw + + CFBundleTypeIconFile + PythonSource.icns + CFBundleTypeName + Python Script + CFBundleTypeRole + Viewer + NSDocumentClass + MyDocument + + + CFBundleTypeExtensions + + pyc + pyo + + CFBundleTypeIconFile + PythonCompiled.icns + CFBundleTypeName + Python Bytecode Document + CFBundleTypeRole + Viewer + NSDocumentClass + MyDocument + + + CFBundleExecutable + PythonLauncher + CFBundleGetInfoString + 2.5, ? 2001-2006 Python Software Foundation + CFBundleIconFile + PythonLauncher.icns + CFBundleIdentifier + org.python.PythonLauncher + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + PythonLauncher + CFBundlePackageType + APPL + CFBundleShortVersionString + 2.5 + CFBundleSignature + PytL + CFBundleVersion + 2.5 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + Added: python/trunk/Mac/OSX/PythonLauncher/Makefile.in ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/PythonLauncher/Makefile.in Sun May 14 21:56:34 2006 @@ -0,0 +1,77 @@ +CC=@CC@ +LD=@CC@ +BASECFLAGS=@BASECFLAGS@ +OPT=@OPT@ +CFLAGS=$(BASECFLAGS) $(OPT) +LDFLAGS=@LDFLAGS@ +srcdir= @srcdir@ +VERSION= @VERSION@ +UNIVERSALSDK=@UNIVERSALSDK@ +builddir= ../../.. + +RUNSHARED= @RUNSHARED@ +BUILDEXE= @BUILDEXEEXT@ +BUILDPYTHON= ../../../python$(BUILDEXE) + +# Deployment target selected during configure, to be checked +# by distutils +MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ + at EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET + +BUNDLEBULDER=$(srcdir)/../../../Lib/plat-mac/bundlebuilder.py + +PYTHONAPPSDIR=/Applications/MacPython $(VERSION) +OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o + +all: Python\ Launcher.app + +install: Python\ Launcher.app + test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)" + -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" + cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)" + +clean: + rm -f *.o "Python Launcher" + rm -rf "Python Launcher.app" + +Python\ Launcher.app: \ + Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \ + $(srcdir)/../Icons/PythonSource.icns \ + $(srcdir)/../Icons/PythonCompiled.icns \ + $(srcdir)/factorySettings.plist + rm -fr "Python Launcher.app" + $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \ + --builddir=. \ + --name="Python Launcher" \ + --executable="Python Launcher" \ + --iconfile=$(srcdir)/../Icons/PythonLauncher.icns \ + --bundle-id=org.python.PythonLauncher \ + --resource=$(srcdir)/../Icons/PythonSource.icns \ + --resource=$(srcdir)/../Icons/PythonCompiled.icns \ + --resource=$(srcdir)/English.lproj \ + --resource=$(srcdir)/factorySettings.plist \ + --plist=$(srcdir)/Info.plist \ + build + find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r + + +FileSettings.o: $(srcdir)/FileSettings.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m + +MyAppDelegate.o: $(srcdir)/MyAppDelegate.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m + +MyDocument.o: $(srcdir)/MyDocument.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m + +PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m + +doscript.o: $(srcdir)/doscript.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m + +main.o: $(srcdir)/main.m + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m + +Python\ Launcher: $(OBJECTS) + $(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon Deleted: /python/trunk/Mac/OSX/PythonLauncher/PythonCompiled.icns ============================================================================== Binary file. No diff available. Deleted: /python/trunk/Mac/OSX/PythonLauncher/PythonInterpreter.icns ============================================================================== Binary file. No diff available. Deleted: /python/trunk/Mac/OSX/PythonLauncher/PythonSource.icns ============================================================================== Binary file. No diff available. Deleted: /python/trunk/Mac/OSX/PythonLauncher/PythonWSource.icns ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/Tools/pythonw.c ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/Tools/pythonw.c Sun May 14 21:56:34 2006 @@ -0,0 +1,17 @@ +/* + * This wrapper program executes a python executable hidden inside an + * application bundle inside the Python framework. This is needed to run + * GUI code: some GUI API's don't work unless the program is inside an + * application bundle. + */ +#include +#include + +static char Python[] = PYTHONWEXECUTABLE; + +int main(int argc, char **argv) { + argv[0] = Python; + execv(Python, argv); + err(1, "execv: %s", Python); + /* NOTREACHED */ +} Modified: python/trunk/Mac/OSXResources/framework/Info.plist ============================================================================== --- python/trunk/Mac/OSXResources/framework/Info.plist (original) +++ python/trunk/Mac/OSXResources/framework/Info.plist Sun May 14 21:56:34 2006 @@ -17,10 +17,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.2 + 2.5 CFBundleSignature ???? CFBundleVersion - 2.2 + 2.5 Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Sun May 14 21:56:34 2006 @@ -856,7 +856,7 @@ # Substitution happens here, as the completely-expanded BINDIR # is not available in configure sed -e "s, at BINDIR@,$(BINDIR)," < $(srcdir)/Misc/python-config.in >python-config - $(INSTALL_SCRIPT) python-config $(BINDIR)/python-config + $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python-config rm python-config @if [ -s Modules/python.exp -a \ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ @@ -936,27 +936,20 @@ # This installs Mac/Lib into the framework frameworkinstallmaclib: - $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installmacsubtree \ - $(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ - srcdir=$(srcdir) builddir=. prefix=$(prefix) LIBDEST=$(LIBDEST) \ - DESTDIR=$(DESTDIR) + cd Mac/OSX && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)" # This installs the IDE, the Launcher and other apps into /Applications frameworkinstallapps: - $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installapps \ - $(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ - srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix) + cd Mac/OSX && $(MAKE) installapps DESTDIR="$(DESTDIR)" # This install the unix python and pythonw tools in /usr/local/bin frameworkinstallunixtools: - $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installunixtools \ - DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ - srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix) + cd Mac/OSX && $(MAKE) installunixtools DESTDIR="$(DESTDIR)" # This installs the Demos and Tools into the applications directory. # It is not part of a normal frameworkinstall frameworkinstallextras: - $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installextras \ + $(MAKE) -f Mac/OSX/Makefile installextras \ $(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Sun May 14 21:56:34 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 45392 . +# From configure.in Revision: 45800 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -1451,6 +1451,15 @@ PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION + + # Add makefiles for Mac specific code to the list of output + # files: + ac_config_files="$ac_config_files Mac/OSX/Makefile" + + ac_config_files="$ac_config_files Mac/OSX/PythonLauncher/Makefile" + + ac_config_files="$ac_config_files Mac/OSX/IDLE/Makefile" + esac else @@ -22416,6 +22425,9 @@ do case "$ac_config_target" in # Handling of arguments. + "Mac/OSX/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/Makefile" ;; + "Mac/OSX/PythonLauncher/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/PythonLauncher/Makefile" ;; + "Mac/OSX/IDLE/Makefile" ) CONFIG_FILES="$CONFIG_FILES Mac/OSX/IDLE/Makefile" ;; "Makefile.pre" ) CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Modules/Setup.config" ) CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;; "pyconfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS pyconfig.h" ;; Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Sun May 14 21:56:34 2006 @@ -105,6 +105,12 @@ PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION + + # Add makefiles for Mac specific code to the list of output + # files: + AC_CONFIG_FILES(Mac/OSX/Makefile) + AC_CONFIG_FILES(Mac/OSX/PythonLauncher/Makefile) + AC_CONFIG_FILES(Mac/OSX/IDLE/Makefile) esac ],[ PYTHONFRAMEWORK= From python-checkins at python.org Sun May 14 22:35:47 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 14 May 2006 22:35:47 +0200 (CEST) Subject: [Python-checkins] r45996 - in python/trunk/Mac: OSX/Icons/Disk Image.icns OSX/Icons/IDLE.icns OSX/Icons/Python Folder.icns OSX/Icons/PythonCompiled.icns OSX/Icons/PythonLauncher.icns OSX/Icons/PythonSource.icns OSX/Icons/ReadMe.txt OSXResources/app/Resources/PythonApplet.icns OSXResources/app/Resources/PythonInterpreter.icns scripts/BuildApplet.icns Message-ID: <20060514203547.6878E1E403E@bag.python.org> Author: ronald.oussoren Date: Sun May 14 22:35:41 2006 New Revision: 45996 Added: python/trunk/Mac/OSX/Icons/Disk Image.icns (contents, props changed) python/trunk/Mac/OSX/Icons/Python Folder.icns (contents, props changed) python/trunk/Mac/OSX/Icons/ReadMe.txt Modified: python/trunk/Mac/OSX/Icons/IDLE.icns python/trunk/Mac/OSX/Icons/PythonCompiled.icns python/trunk/Mac/OSX/Icons/PythonLauncher.icns python/trunk/Mac/OSX/Icons/PythonSource.icns python/trunk/Mac/OSXResources/app/Resources/PythonApplet.icns python/trunk/Mac/OSXResources/app/Resources/PythonInterpreter.icns python/trunk/Mac/scripts/BuildApplet.icns Log: A first cut at replacing the icons on MacOS X. This replaces all icons by icons based on the new python.org logo. These are also the first icons that are "proper" OSX icons. These icons were created by Jacob Rus. Added: python/trunk/Mac/OSX/Icons/Disk Image.icns ============================================================================== Binary file. No diff available. Modified: python/trunk/Mac/OSX/Icons/IDLE.icns ============================================================================== Binary files. No diff available. Added: python/trunk/Mac/OSX/Icons/Python Folder.icns ============================================================================== Binary file. No diff available. Modified: python/trunk/Mac/OSX/Icons/PythonCompiled.icns ============================================================================== Binary files. No diff available. Modified: python/trunk/Mac/OSX/Icons/PythonLauncher.icns ============================================================================== Binary files. No diff available. Modified: python/trunk/Mac/OSX/Icons/PythonSource.icns ============================================================================== Binary files. No diff available. Added: python/trunk/Mac/OSX/Icons/ReadMe.txt ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/Icons/ReadMe.txt Sun May 14 22:35:41 2006 @@ -0,0 +1,3 @@ +The icons for use on MacOS X were created by Jacob Rus +with some feedback from the folks on pythonmac-sig at python.org. + Modified: python/trunk/Mac/OSXResources/app/Resources/PythonApplet.icns ============================================================================== Binary files. No diff available. Modified: python/trunk/Mac/OSXResources/app/Resources/PythonInterpreter.icns ============================================================================== Binary files. No diff available. Modified: python/trunk/Mac/scripts/BuildApplet.icns ============================================================================== Binary files. No diff available. From python-checkins at python.org Sun May 14 23:07:42 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 14 May 2006 23:07:42 +0200 (CEST) Subject: [Python-checkins] r45997 - python/trunk/Mac/OSX/Makefile.in Message-ID: <20060514210742.334D21E4014@bag.python.org> Author: ronald.oussoren Date: Sun May 14 23:07:41 2006 New Revision: 45997 Modified: python/trunk/Mac/OSX/Makefile.in Log: I missed one small detail in my rewrite of the osx build files: the path to the Python.app template. Modified: python/trunk/Mac/OSX/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/Makefile.in (original) +++ python/trunk/Mac/OSX/Makefile.in Sun May 14 23:07:41 2006 @@ -34,12 +34,12 @@ STRIPFLAG=-s CPMAC=/Developer/Tools/CpMac -APPTEMPLATE=$(srcdir)/OSXResources/app +APPTEMPLATE=$(srcdir)/../OSXResources/app APPSUBDIRS=MacOS Resources Resources/English.lproj \ Resources/English.lproj/Documentation \ Resources/English.lproj/Documentation/doc \ Resources/English.lproj/Documentation/ide -DOCDIR=$(srcdir)/Mac/OSXResources/app/Resources/English.lproj/Documentation +DOCDIR=$(srcdir)/../OSXResources/app/Resources/English.lproj/Documentation DOCINDEX=$(DOCDIR)/"Documentation idx" CACHERSRC=$(srcdir)/../scripts/cachersrc.py compileall=$(srcdir)/../../Lib/compileall.py From buildbot at python.org Mon May 15 00:50:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 14 May 2006 22:50:35 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060514225035.678A01E4013@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/393 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Mon May 15 04:43:27 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 14 May 2006 19:43:27 -0700 Subject: [Python-checkins] r45974 - in python/trunk: Misc/NEWS Modules/posixmodule.c In-Reply-To: <20060512122729.B08551E4004@bag.python.org> References: <20060512122729.B08551E4004@bag.python.org> Message-ID: On 5/12/06, martin.v.loewis wrote: > > @@ -1839,7 +1848,9 @@ > > if (FindClose(hFindFile) == FALSE) { > Py_DECREF(d); > - return win32_error_unicode("FindClose", wnamebuf); > + win32_error_unicode("FindClose", wnamebuf); > + free(wnamebuf); > + return NULL; > } > return d; > } Doesn't wnamebuf need to be freed in the normal return case? n From python-checkins at python.org Mon May 15 07:51:37 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 15 May 2006 07:51:37 +0200 (CEST) Subject: [Python-checkins] r45998 - python/trunk/Modules/posixmodule.c Message-ID: <20060515055137.9E34F1E4013@bag.python.org> Author: martin.v.loewis Date: Mon May 15 07:51:36 2006 New Revision: 45998 Modified: python/trunk/Modules/posixmodule.c Log: Fix memory leak. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Mon May 15 07:51:36 2006 @@ -1855,6 +1855,7 @@ free(wnamebuf); return NULL; } + free(wnamebuf); return d; } /* Drop the argument parsing error as narrow strings From martin at v.loewis.de Mon May 15 07:51:58 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 15 May 2006 07:51:58 +0200 Subject: [Python-checkins] r45974 - in python/trunk: Misc/NEWS Modules/posixmodule.c In-Reply-To: References: <20060512122729.B08551E4004@bag.python.org> Message-ID: <446816FE.3040802@v.loewis.de> Neal Norwitz wrote: > Doesn't wnamebuf need to be freed in the normal return case? Right; fixed in 45998. Regards, Martin From python-checkins at python.org Mon May 15 08:48:15 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 15 May 2006 08:48:15 +0200 (CEST) Subject: [Python-checkins] r45999 - python/trunk/Misc/NEWS Message-ID: <20060515064815.6896A1E4013@bag.python.org> Author: neal.norwitz Date: Mon May 15 08:48:14 2006 New Revision: 45999 Modified: python/trunk/Misc/NEWS Log: Move items implemented after a2 into the new a3 section Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 15 08:48:14 2006 @@ -4,10 +4,10 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.5 alpha 2? +What's New in Python 2.5 alpha 3? ================================= -*Release date: 27-APR-2006* +*Release date: XX-MAY-2006* Core and builtins ----------------- @@ -21,6 +21,65 @@ - Patch #1479181: split open() and file() from being aliases for each other. +Extension Modules +----------------- + +- On Win32, os.listdir now supports arbitrarily-long Unicode path names + (up to the system limit of 32K characters). + +- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. + As a result, these functions now raise WindowsError instead of OSError. + +- Calling Tk_Init twice is refused if the first call failed as that + may deadlock. + +Library +------- + +- Patch #721464: pdb.Pdb instances can now be given explicit stdin and + stdout arguments, making it possible to redirect input and output + for remote debugging. + +- Patch #1484695: Update the tarfile module to version 0.8. This fixes + a couple of issues, notably handling of long file names using the + GNU LONGNAME extension. + +- Patch #1478292. ``doctest.register_optionflag(name)`` shouldn't create a + new flag when ``name`` is already the name of an option flag. + +- Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler + package. + +- Patch #1472854: make the rlcompleter.Completer class usable on non- + UNIX platforms. + +- Patch #1470846: fix urllib2 ProxyBasicAuthHandler. + +Build +----- + +- Patch #1471883: Add --enable-universalsdk. + +C API +----- + +Tests +----- + +Tools +----- + +Documentation +------------- + +What's New in Python 2.5 alpha 2? +================================= + +*Release date: 27-APR-2006* + +Core and builtins +----------------- + - Bug #1465834: 'bdist_wininst preinstall script support' was fixed by converting these apis from macros into exported functions again: @@ -72,15 +131,6 @@ Extension Modules ----------------- -- On Win32, os.listdir now supports arbitrarily-long Unicode path names - (up to the system limit of 32K characters). - -- Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. - As a result, these functions now raise WindowsError instead of OSError. - -- Calling Tk_Init twice is refused if the first call failed as that - may deadlock. - - Patch #1191065: Fix preprocessor problems on systems where recvfrom is a macro. @@ -104,25 +154,6 @@ Library ------- -- Patch #721464: pdb.Pdb instances can now be given explicit stdin and - stdout arguments, making it possible to redirect input and output - for remote debugging. - -- Patch #1484695: Update the tarfile module to version 0.8. This fixes - a couple of issues, notably handling of long file names using the - GNU LONGNAME extension. - -- Patch #1478292. ``doctest.register_optionflag(name)`` shouldn't create a - new flag when ``name`` is already the name of an option flag. - -- Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler - package. - -- Patch #1472854: make the rlcompleter.Completer class usable on non- - UNIX platforms. - -- Patch #1470846: fix urllib2 ProxyBasicAuthHandler. - - Patch #1475231: ``doctest`` has a new ``SKIP`` option, which causes a doctest to be skipped (the code is not run, and the expected output or exception is ignored). @@ -179,8 +210,6 @@ Build ----- -- Patch #1471883: Add --enable-universalsdk. - - The Makefile now has a reindent target, which runs reindent.py on the library. @@ -197,9 +226,6 @@ - Fixed a libffi build problem on MIPS systems. -C API ------ - - ``PyString_FromFormat``, ``PyErr_Format``, and ``PyString_FromFormatV`` now accept formats "%u" for unsigned ints, "%lu" for unsigned longs, and "%zu" for unsigned integers of type ``size_t``. From python-checkins at python.org Mon May 15 09:04:37 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 15 May 2006 09:04:37 +0200 (CEST) Subject: [Python-checkins] r46000 - in python/trunk: Lib/test/test_syntax.py Misc/ACKS Misc/NEWS Python/ast.c Message-ID: <20060515070437.0F42E1E4013@bag.python.org> Author: neal.norwitz Date: Mon May 15 09:04:36 2006 New Revision: 46000 Modified: python/trunk/Lib/test/test_syntax.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Python/ast.c Log: - Bug #1487966: Fix SystemError with conditional expression in assignment Most of the test_syntax changes are just updating the numbers. Modified: python/trunk/Lib/test/test_syntax.py ============================================================================== --- python/trunk/Lib/test/test_syntax.py (original) +++ python/trunk/Lib/test/test_syntax.py Mon May 15 09:04:36 2006 @@ -86,13 +86,16 @@ Traceback (most recent call last): SyntaxError: can't assign to operator (, line 1) +>>> a if 1 else b = 1 +Traceback (most recent call last): +SyntaxError: can't assign to conditional expression (, line 1) From compiler_complex_args(): >>> def f(None=1): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_arguments(): @@ -100,22 +103,22 @@ >>> def f(x, y=1, z): ... pass Traceback (most recent call last): -SyntaxError: non-default argument follows default argument (, line 1) +SyntaxError: non-default argument follows default argument (, line 1) >>> def f(x, None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> def f(*None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> def f(**None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_funcdef(): @@ -123,7 +126,7 @@ >>> def None(x): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_call(): @@ -135,7 +138,7 @@ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> f(x for x in L, 1) Traceback (most recent call last): -SyntaxError: Generator expression must be parenthesized if not sole argument (, line 1) +SyntaxError: Generator expression must be parenthesized if not sole argument (, line 1) >>> f((x for x in L), 1) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] @@ -167,7 +170,7 @@ ... i244, i245, i246, i247, i248, i249, i250, i251, i252, ... i253, i254, i255) Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) +SyntaxError: more than 255 arguments (, line 1) The actual error cases counts positional arguments, keyword arguments, and generator expression arguments separately. This test combines the @@ -201,37 +204,37 @@ ... (x for x in i244), i245, i246, i247, i248, i249, i250, i251, ... i252=1, i253=1, i254=1, i255=1) Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) +SyntaxError: more than 255 arguments (, line 1) >>> f(lambda x: x[0] = 3) Traceback (most recent call last): -SyntaxError: lambda cannot contain assignment (, line 1) +SyntaxError: lambda cannot contain assignment (, line 1) The grammar accepts any test (basically, any expression) in the keyword slot of a call site. Test a few different options. >>> f(x()=2) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) >>> f(a or b=1) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) >>> f(x.y=1) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) From ast_for_expr_stmt(): >>> (x for x in x) += 1 Traceback (most recent call last): -SyntaxError: augmented assignment to generator expression not possible (, line 1) +SyntaxError: augmented assignment to generator expression not possible (, line 1) >>> None += 1 Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> f() += 1 Traceback (most recent call last): -SyntaxError: illegal expression for augmented assignment (, line 1) +SyntaxError: illegal expression for augmented assignment (, line 1) """ import re Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Mon May 15 09:04:36 2006 @@ -547,6 +547,7 @@ Barry Scott Steven Scott Nick Seidenman +?iga Seilnach Fred Sells Jiwon Seo Denis Severson Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 15 09:04:36 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1487966: Fix SystemError with conditional expression in assignment + - WindowsError now has two error code attributes: errno, which carries the error values from errno.h, and winerror, which carries the error values from winerror.h. Previous versions put the winerror.h values Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Mon May 15 09:04:36 2006 @@ -401,6 +401,9 @@ case Repr_kind: expr_name = "repr"; break; + case IfExp_kind: + expr_name = "conditional expression"; + break; default: PyErr_Format(PyExc_SystemError, "unexpected expression in assignment %d (line %d)", From python-checkins at python.org Mon May 15 09:17:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 15 May 2006 09:17:23 +0200 (CEST) Subject: [Python-checkins] r46001 - in python/trunk: Misc/ACKS Misc/NEWS Objects/unicodeobject.c Message-ID: <20060515071723.D83261E4013@bag.python.org> Author: neal.norwitz Date: Mon May 15 09:17:23 2006 New Revision: 46001 Modified: python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Objects/unicodeobject.c Log: Patch #1488312, Fix memory alignment problem on SPARC in unicode. Will backport Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Mon May 15 09:17:23 2006 @@ -455,6 +455,7 @@ Russel Owen Mike Pall Todd R. Palmer +Jan Palus Alexandre Parenteau Dan Parisien Harri Pasanen Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 15 09:17:23 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1488312, Fix memory alignment problem on SPARC in unicode + - Bug #1487966: Fix SystemError with conditional expression in assignment - WindowsError now has two error code attributes: errno, which carries Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon May 15 09:17:23 2006 @@ -2313,7 +2313,7 @@ end = s + size; while (s < end) { - *p = *(Py_UNICODE *)s; + memcpy(p, s, sizeof(Py_UNICODE)); /* We have to sanity check the raw data, otherwise doom looms for some malformed UCS-4 data. */ if ( From python-checkins at python.org Mon May 15 09:22:24 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 15 May 2006 09:22:24 +0200 (CEST) Subject: [Python-checkins] r46002 - in python/branches/release24-maint: Misc/ACKS Misc/NEWS Objects/unicodeobject.c Message-ID: <20060515072224.229C81E4013@bag.python.org> Author: neal.norwitz Date: Mon May 15 09:22:23 2006 New Revision: 46002 Modified: python/branches/release24-maint/Misc/ACKS python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Objects/unicodeobject.c Log: Backport: Patch #1488312, Fix memory alignment problem on SPARC in unicode. Modified: python/branches/release24-maint/Misc/ACKS ============================================================================== --- python/branches/release24-maint/Misc/ACKS (original) +++ python/branches/release24-maint/Misc/ACKS Mon May 15 09:22:23 2006 @@ -440,6 +440,7 @@ Russel Owen Mike Pall Todd R. Palmer +Jan Palus Alexandre Parenteau Dan Parisien Harri Pasanen Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Mon May 15 09:22:23 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1488312, Fix memory alignment problem on SPARC in unicode + Extension Modules ----------------- Modified: python/branches/release24-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release24-maint/Objects/unicodeobject.c (original) +++ python/branches/release24-maint/Objects/unicodeobject.c Mon May 15 09:22:23 2006 @@ -2302,7 +2302,7 @@ end = s + size; while (s < end) { - *p = *(Py_UNICODE *)s; + memcpy(p, s, sizeof(Py_UNICODE)); /* We have to sanity check the raw data, otherwise doom looms for some malformed UCS-4 data. */ if ( From buildbot at python.org Mon May 15 10:07:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 08:07:37 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060515080737.DBE431E4013@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/99 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Mon May 15 10:35:56 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 15 May 2006 10:35:56 +0200 Subject: [Python-checkins] r46002 - in python/branches/release24-maint: Misc/ACKS Misc/NEWS Objects/unicodeobject.c In-Reply-To: <20060515072224.229C81E4013@bag.python.org> References: <20060515072224.229C81E4013@bag.python.org> Message-ID: <44683D6C.8010101@egenix.com> neal.norwitz wrote: > Author: neal.norwitz > Date: Mon May 15 09:22:23 2006 > New Revision: 46002 > > Modified: > python/branches/release24-maint/Misc/ACKS > python/branches/release24-maint/Misc/NEWS > python/branches/release24-maint/Objects/unicodeobject.c > Log: > Backport: Patch #1488312, Fix memory alignment problem on SPARC in unicode. > > Modified: python/branches/release24-maint/Misc/NEWS > ============================================================================== > --- python/branches/release24-maint/Misc/NEWS (original) > +++ python/branches/release24-maint/Misc/NEWS Mon May 15 09:22:23 2006 > @@ -12,6 +12,8 @@ > Core and builtins > ----------------- > > +- Patch #1488312, Fix memory alignment problem on SPARC in unicode > + > Extension Modules > ----------------- > > > Modified: python/branches/release24-maint/Objects/unicodeobject.c > ============================================================================== > --- python/branches/release24-maint/Objects/unicodeobject.c (original) > +++ python/branches/release24-maint/Objects/unicodeobject.c Mon May 15 09:22:23 2006 > @@ -2302,7 +2302,7 @@ > end = s + size; > > while (s < end) { > - *p = *(Py_UNICODE *)s; > + memcpy(p, s, sizeof(Py_UNICODE)); > /* We have to sanity check the raw data, otherwise doom looms for > some malformed UCS-4 data. */ > if ( Could you please make this fix apply only on Solaris, e.g. using an #ifdef ?! The memcpy is a lot more expensive than a simple memory copy via registers and this operation is done per code point in the Unicode string, so any change to the inner loop makes a difference. Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 15 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Mon May 15 11:22:28 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 15 May 2006 11:22:28 +0200 (CEST) Subject: [Python-checkins] r46003 - python/trunk/Python/exceptions.c Message-ID: <20060515092228.60D7A1E4013@bag.python.org> Author: martin.v.loewis Date: Mon May 15 11:22:27 2006 New Revision: 46003 Modified: python/trunk/Python/exceptions.c Log: Remove bogus DECREF of self. Change __str__() functions to METH_O. Change WindowsError__str__ to use PyTuple_Pack. Modified: python/trunk/Python/exceptions.c ============================================================================== --- python/trunk/Python/exceptions.c (original) +++ python/trunk/Python/exceptions.c Mon May 15 11:22:27 2006 @@ -223,12 +223,9 @@ static PyObject * -BaseException__str__(PyObject *self, PyObject *args) +BaseException__str__(PyObject *_self, PyObject *self) { - PyObject *out; - - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; + PyObject *out, *args; args = PyObject_GetAttrString(self, "args"); if (!args) @@ -376,7 +373,7 @@ /* methods for the BaseException class */ {"__getitem__", BaseException__getitem__, METH_VARARGS}, {"__repr__", BaseException__repr__, METH_VARARGS}, - {"__str__", BaseException__str__, METH_VARARGS}, + {"__str__", BaseException__str__, METH_O}, #ifdef Py_USING_UNICODE {"__unicode__", BaseException__unicode__, METH_VARARGS}, #endif /* Py_USING_UNICODE */ @@ -617,17 +614,13 @@ static PyObject * -EnvironmentError__str__(PyObject *self, PyObject *args) +EnvironmentError__str__(PyObject *originalself, PyObject *self) { - PyObject *originalself = self; PyObject *filename; PyObject *serrno; PyObject *strerror; PyObject *rtnval = NULL; - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - filename = PyObject_GetAttrString(self, "filename"); serrno = PyObject_GetAttrString(self, "errno"); strerror = PyObject_GetAttrString(self, "strerror"); @@ -687,7 +680,7 @@ * but there is no StandardError__str__() function; we happen to * know that's just a pass through to BaseException__str__(). */ - rtnval = BaseException__str__(originalself, args); + rtnval = BaseException__str__(originalself, self); finally: Py_XDECREF(filename); @@ -700,7 +693,7 @@ static PyMethodDef EnvironmentError_methods[] = { {"__init__", EnvironmentError__init__, METH_VARARGS}, - {"__str__", EnvironmentError__str__, METH_VARARGS}, + {"__str__", EnvironmentError__str__, METH_O}, {NULL, NULL} }; @@ -746,23 +739,21 @@ failed: /* Could not set errno. */ Py_XDECREF(o_errcode); - Py_DECREF(self); Py_DECREF(result); return NULL; } static PyObject * -WindowsError__str__(PyObject *self, PyObject *args) +WindowsError__str__(PyObject *originalself, PyObject *self) { - PyObject *originalself = self; PyObject *filename; PyObject *serrno; PyObject *strerror; + PyObject *repr = NULL; + PyObject *fmt = NULL; + PyObject *tuple = NULL; PyObject *rtnval = NULL; - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - filename = PyObject_GetAttrString(self, "filename"); serrno = PyObject_GetAttrString(self, "winerror"); strerror = PyObject_GetAttrString(self, "strerror"); @@ -770,64 +761,46 @@ goto finally; if (filename != Py_None) { - PyObject *fmt = PyString_FromString("[Error %s] %s: %s"); - PyObject *repr = PyObject_Repr(filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); + fmt = PyString_FromString("[Error %s] %s: %s"); + repr = PyObject_Repr(filename); + if (!fmt || !repr) goto finally; - } + - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - PyTuple_SET_ITEM(tuple, 2, repr); + tuple = PyTuple_Pack(3, serrno, strerror, repr); + if (!tuple) + goto finally; rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; } else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - PyObject *fmt = PyString_FromString("[Error %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); + fmt = PyString_FromString("[Error %s] %s"); + if (!fmt) goto finally; - } - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); + tuple = PyTuple_Pack(2, serrno, strerror); + if (!tuple) + goto finally; rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; } else - rtnval = EnvironmentError__str__(originalself, args); + rtnval = EnvironmentError__str__(originalself, self); finally: Py_XDECREF(filename); Py_XDECREF(serrno); Py_XDECREF(strerror); + Py_XDECREF(repr); + Py_XDECREF(fmt); + Py_XDECREF(tuple); return rtnval; } static PyMethodDef WindowsError_methods[] = { {"__init__", WindowsError__init__, METH_VARARGS}, - {"__str__", WindowsError__str__, METH_VARARGS}, + {"__str__", WindowsError__str__, METH_O}, {NULL, NULL} }; #endif /* MS_WINDOWS */ @@ -972,15 +945,12 @@ static PyObject * -SyntaxError__str__(PyObject *self, PyObject *args) +SyntaxError__str__(PyObject *_self, PyObject *self) { PyObject *msg; PyObject *str; PyObject *filename, *lineno, *result; - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - if (!(msg = PyObject_GetAttrString(self, "msg"))) return NULL; @@ -1045,20 +1015,17 @@ static PyMethodDef SyntaxError_methods[] = { {"__init__", SyntaxError__init__, METH_VARARGS}, - {"__str__", SyntaxError__str__, METH_VARARGS}, + {"__str__", SyntaxError__str__, METH_O}, {NULL, NULL} }; static PyObject * -KeyError__str__(PyObject *self, PyObject *args) +KeyError__str__(PyObject *_self, PyObject *self) { PyObject *argsattr; PyObject *result; - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - argsattr = PyObject_GetAttrString(self, "args"); if (!argsattr) return NULL; @@ -1077,14 +1044,14 @@ result = PyObject_Repr(key); } else - result = BaseException__str__(self, args); + result = BaseException__str__(_self, self); Py_DECREF(argsattr); return result; } static PyMethodDef KeyError_methods[] = { - {"__str__", KeyError__str__, METH_VARARGS}, + {"__str__", KeyError__str__, METH_O}, {NULL, NULL} }; From buildbot at python.org Mon May 15 17:40:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 15:40:55 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian trunk Message-ID: <20060515154055.9190E1E4014@bag.python.org> The Buildbot has detected a new failure of MIPS Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%2520trunk/builds/107 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 15 20:18:48 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 15 May 2006 20:18:48 +0200 (CEST) Subject: [Python-checkins] r46004 - peps/trunk/pep-0356.txt Message-ID: <20060515181848.22E581E4014@bag.python.org> Author: andrew.kuchling Date: Mon May 15 20:18:47 2006 New Revision: 46004 Modified: peps/trunk/pep-0356.txt Log: Add link to SVN repo Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Mon May 15 20:18:47 2006 @@ -113,6 +113,7 @@ - Modules under consideration for inclusion: - wsgiref to the standard library + SVN repository: svn://svn.eby-sarna.com/svnroot/wsgiref (Owner: Phillip Eby) - Upgrade pyexpat to use expat 2.0? From python-checkins at python.org Mon May 15 21:30:36 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 15 May 2006 21:30:36 +0200 (CEST) Subject: [Python-checkins] r46005 - in python/trunk: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20060515193036.3A7BF1E4015@bag.python.org> Author: georg.brandl Date: Mon May 15 21:30:35 2006 New Revision: 46005 Modified: python/trunk/Lib/tarfile.py python/trunk/Lib/test/test_tarfile.py python/trunk/Misc/NEWS Log: [ 1488881 ] tarfile.py: support for file-objects and bz2 (cp. #1488634) Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Mon May 15 21:30:35 2006 @@ -556,6 +556,69 @@ self.fileobj.close() # class StreamProxy +class _BZ2Proxy(object): + """Small proxy class that enables external file object + support for "r:bz2" and "w:bz2" modes. This is actually + a workaround for a limitation in bz2 module's BZ2File + class which (unlike gzip.GzipFile) has no support for + a file object argument. + """ + + blocksize = 16 * 1024 + + def __init__(self, fileobj, mode): + self.fileobj = fileobj + self.mode = mode + self.init() + + def init(self): + import bz2 + self.pos = 0 + if self.mode == "r": + self.bz2obj = bz2.BZ2Decompressor() + self.fileobj.seek(0) + self.buf = "" + else: + self.bz2obj = bz2.BZ2Compressor() + + def read(self, size): + b = [self.buf] + x = len(self.buf) + while x < size: + try: + raw = self.fileobj.read(self.blocksize) + data = self.bz2obj.decompress(raw) + b.append(data) + except EOFError: + break + x += len(data) + self.buf = "".join(b) + + buf = self.buf[:size] + self.buf = self.buf[size:] + self.pos += len(buf) + return buf + + def seek(self, pos): + if pos < self.pos: + self.init() + self.read(pos - self.pos) + + def tell(self): + return self.pos + + def write(self, data): + self.pos += len(data) + raw = self.bz2obj.compress(data) + self.fileobj.write(raw) + + def close(self): + if self.mode == "w": + raw = self.bz2obj.flush() + self.fileobj.write(raw) + self.fileobj.close() +# class _BZ2Proxy + #------------------------ # Extraction file object #------------------------ @@ -1057,10 +1120,12 @@ tarname = pre + ext if fileobj is not None: - raise ValueError, "no support for external file objects" + fileobj = _BZ2Proxy(fileobj, mode) + else: + fileobj = bz2.BZ2File(name, mode, compresslevel=compresslevel) try: - t = cls.taropen(tarname, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel)) + t = cls.taropen(tarname, mode, fileobj) except IOError: raise ReadError, "not a bzip2 file" t._extfileobj = False Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Mon May 15 21:30:35 2006 @@ -212,6 +212,17 @@ stream.close() +class ReadDetectTest(ReadTest): + + def setUp(self): + self.tar = tarfile.open(tarname(self.comp), self.mode) + +class ReadDetectFileobjTest(ReadTest): + + def setUp(self): + name = tarname(self.comp) + self.tar = tarfile.open(name, mode=self.mode, fileobj=file(name)) + class ReadAsteriskTest(ReadTest): def setUp(self): @@ -503,6 +514,10 @@ comp = "gz" class WriteStreamTestGzip(WriteStreamTest): comp = "gz" +class ReadDetectTestGzip(ReadDetectTest): + comp = "gz" +class ReadDetectFileobjTestGzip(ReadDetectFileobjTest): + comp = "gz" class ReadAsteriskTestGzip(ReadAsteriskTest): comp = "gz" class ReadStreamAsteriskTestGzip(ReadStreamAsteriskTest): @@ -526,6 +541,10 @@ comp = "bz2" class WriteStreamTestBzip2(WriteStreamTestGzip): comp = "bz2" + class ReadDetectTestBzip2(ReadDetectTest): + comp = "bz2" + class ReadDetectFileobjTestBzip2(ReadDetectFileobjTest): + comp = "bz2" class ReadAsteriskTestBzip2(ReadAsteriskTest): comp = "bz2" class ReadStreamAsteriskTestBzip2(ReadStreamAsteriskTest): @@ -550,6 +569,8 @@ FileModeTest, ReadTest, ReadStreamTest, + ReadDetectTest, + ReadDetectFileobjTest, ReadAsteriskTest, ReadStreamAsteriskTest, WriteTest, @@ -567,6 +588,7 @@ tests.extend([ ReadTestGzip, ReadStreamTestGzip, WriteTestGzip, WriteStreamTestGzip, + ReadDetectTestGzip, ReadDetectFileobjTestGzip, ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip ]) @@ -574,6 +596,7 @@ tests.extend([ ReadTestBzip2, ReadStreamTestBzip2, WriteTestBzip2, WriteStreamTestBzip2, + ReadDetectTestBzip2, ReadDetectFileobjTestBzip2, ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2 ]) try: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 15 21:30:35 2006 @@ -40,6 +40,9 @@ Library ------- +- Patch #1488881: add support for external file objects in bz2 compressed + tarfiles. + - Patch #721464: pdb.Pdb instances can now be given explicit stdin and stdout arguments, making it possible to redirect input and output for remote debugging. From buildbot at python.org Mon May 15 21:47:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 19:47:52 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060515194753.08D511E4015@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/471 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 15 22:15:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 20:15:58 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Debian unstable trunk Message-ID: <20060515201559.32B041E4026@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/396 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 15 22:42:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 20:42:22 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060515204222.BBB171E401A@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/398 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 15 22:43:03 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 15 May 2006 22:43:03 +0200 (CEST) Subject: [Python-checkins] r46006 - sandbox/trunk/wsgiref-docs/wsgiref.tex Message-ID: <20060515204303.6A3101E4015@bag.python.org> Author: andrew.kuchling Date: Mon May 15 22:43:03 2006 New Revision: 46006 Modified: sandbox/trunk/wsgiref-docs/wsgiref.tex Log: Add some text Modified: sandbox/trunk/wsgiref-docs/wsgiref.tex ============================================================================== --- sandbox/trunk/wsgiref-docs/wsgiref.tex (original) +++ sandbox/trunk/wsgiref-docs/wsgiref.tex Mon May 15 22:43:03 2006 @@ -1,17 +1,24 @@ \section{wsgiref} +\moduleauthor{XXX} -XXX write introduction +The Web Server Gateway Interface (WSGI) is a standard interface +between web server software and web applications written in Python. +Having a standard interface makes it easy to use a WSGI-supporting +application with a number of different web servers. + +Only authors of web servers and programming frameworks need to know +every detail and corner case of the WSGI design. You don't need to +understand every detail of WSGI just to install a WSGI application or +to write a web application using an existing framework. + +\module{wsgiref} is a reference implementation of the WSGI specification +that can be used to add WSGI support to a web server or framework. +If you're just trying to write a web application, +% XXX should create a URL on python.org to point people to. -\subsection{Web Server Gateway Interface} +For the complete WSGI specification, see \pep{333}. -Brief overview of application interface - -app(environ, start_response): - call start_response(status, header) - return iterable w/ text context - -Reference to PEP 333 \subsection{wsgiref.handlers} @@ -24,26 +31,58 @@ CGIHandler -\subsection{wsgiref.util} - -FileWrapper +%\subsection{wsgiref.util} -% XXX document guess_scheme, application_uri, request_uri, shift_path_info, -% setup_testing_defaults? +% XXX document FileWrapper, guess_scheme, application_uri, +% request_uri, shift_path_info, setup_testing_defaults? \subsection{wsgiref.simple_server} -WSGIServer - -WSGIRequestHandler - -demo_app +This module contains the \class{WSGIServer} class, +a subclass of \class{BaseHTTPServer.HTTPServer} that +forwards requests to a WSGI application. There's also a simple +hello-world application called \function{demo_app} that's useful for +testing when + +\begin{methoddesc}[WSGIServer]{set_app}{application} +Sets the callable \var{application} as the application +that will receive requests. +\end{methoddesc} + +\begin{methoddesc}[WSGIServer]{get_app}{} +Returns the currently-set application callable. +\end{methoddesc} + +\begin{funcdesc}{demo_app}{environ, start_response} +This function is a small but complete WSGI application that +returns a text page containing the message ``Hello world!'' +and a list of the key/value pairs provided in the +\var{environ} parameter. +\end{funcdesc} \subsection{Examples} -Simple application: trivial 'hello world' - -Set up a server to run one application +The following example uses the \class{WSGIServer} class +to publish the \function{demo_app} example application. +You can change the application by modifying the call +to \method{set_app()}. + +\begin{verbatim} +from wsgiref import simple_server + +server_address = ('', 8000) +httpd = simple_server.WSGIServer(server_address, + simple_server.WSGIRequestHandler) +httpd.set_app(simple_server.demo_app) + +print "Serving HTTP on port", server_address[1], "..." + +# Respond to requests until process is killed +httpd.serve_forever() + +# Alternative: serve one request, then exit +##httpd.handle_request() +\end{verbatim} Other ideas? From python-checkins at python.org Mon May 15 22:44:11 2006 From: python-checkins at python.org (tim.peters) Date: Mon, 15 May 2006 22:44:11 +0200 (CEST) Subject: [Python-checkins] r46007 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060515204411.169671E4015@bag.python.org> Author: tim.peters Date: Mon May 15 22:44:10 2006 New Revision: 46007 Modified: python/trunk/Lib/test/test_tarfile.py Log: ReadDetectFileobjTest: repair Windows disasters by opening the file object in binary mode. The Windows buildbot slaves shouldn't swap themselves to death anymore. However, test_tarfile may still fail because of a temp directory left behind from a previous failing run. Windows buildbot owners may need to remove that directory by hand. Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Mon May 15 22:44:10 2006 @@ -221,7 +221,8 @@ def setUp(self): name = tarname(self.comp) - self.tar = tarfile.open(name, mode=self.mode, fileobj=file(name)) + self.tar = tarfile.open(name, mode=self.mode, + fileobj=open(name, "rb")) class ReadAsteriskTest(ReadTest): From buildbot at python.org Mon May 15 22:45:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 20:45:48 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060515204549.14E7D1E4015@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/366 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 15 22:48:05 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 15 May 2006 22:48:05 +0200 (CEST) Subject: [Python-checkins] r46008 - sandbox/trunk/wsgiref-docs/wsgiref.tex Message-ID: <20060515204805.DFC911E4015@bag.python.org> Author: andrew.kuchling Date: Mon May 15 22:48:05 2006 New Revision: 46008 Modified: sandbox/trunk/wsgiref-docs/wsgiref.tex Log: Add more text Modified: sandbox/trunk/wsgiref-docs/wsgiref.tex ============================================================================== --- sandbox/trunk/wsgiref-docs/wsgiref.tex (original) +++ sandbox/trunk/wsgiref-docs/wsgiref.tex Mon May 15 22:48:05 2006 @@ -38,21 +38,38 @@ \subsection{wsgiref.simple_server} -This module contains the \class{WSGIServer} class, -a subclass of \class{BaseHTTPServer.HTTPServer} that -forwards requests to a WSGI application. There's also a simple -hello-world application called \function{demo_app} that's useful for -testing when +This module contains the \class{WSGIServer} class, a subclass of +\class{BaseHTTPServer.HTTPServer} that +works with the \class{WSGIRequestHandler} class to forward requests to +a WSGI application. + +There's also a simple hello-world application called +\function{demo_app} that's useful for testing a server hosting WSGI +applications. \begin{methoddesc}[WSGIServer]{set_app}{application} -Sets the callable \var{application} as the application -that will receive requests. +Sets the callable \var{application} as the application that will +receive requests. \end{methoddesc} \begin{methoddesc}[WSGIServer]{get_app}{} Returns the currently-set application callable. \end{methoddesc} +\begin{methoddesc}[WSGIRequestHandler]{get_environ}{} +(Can be overridden.) Returns a dictionary containing the environment +for a request. The default implementation copies the contents of the +\class{WSGIServer} object's \member{base_environ} dictionary attribute +and then adds various headers derived from the HTTP request. +\end{methoddesc} + +\begin{methoddesc}[WSGIRequestHandler]{handle}{} +(Can be overridden.) Method for processing a single HTTP request. +\end{methoddesc} + +\begin{methoddesc}[WSGIRequestHandler]{}{} +\end{methoddesc} + \begin{funcdesc}{demo_app}{environ, start_response} This function is a small but complete WSGI application that returns a text page containing the message ``Hello world!'' From buildbot at python.org Mon May 15 23:11:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 21:11:57 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060515211157.964E71E4017@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/694 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 15 23:23:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 21:23:02 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060515212302.DDA221E4017@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/700 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 15 23:32:25 2006 From: python-checkins at python.org (tim.peters) Date: Mon, 15 May 2006 23:32:25 +0200 (CEST) Subject: [Python-checkins] r46009 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060515213225.D2E341E4017@bag.python.org> Author: tim.peters Date: Mon May 15 23:32:25 2006 New Revision: 46009 Modified: python/trunk/Lib/test/test_tarfile.py Log: test_directory(): Remove the leftover temp directory that's making the Windows buildbots fail test_tarfile. Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Mon May 15 23:32:25 2006 @@ -295,6 +295,10 @@ def test_directory(self): path = os.path.join(self.tmpdir, "directory") + if os.path.exists(path): + # This shouldn't be necessary, but is if a previous + # run was killed in mid-stream. + shutil.rmtree(path) os.mkdir(path) tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 0) From buildbot at python.org Tue May 16 00:05:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 15 May 2006 22:05:48 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060515220548.953111E401D@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/417 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Tue May 16 08:10:48 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 16 May 2006 08:10:48 +0200 Subject: [Python-checkins] r46002 - in python/branches/release24-maint: Misc/ACKS Misc/NEWS Objects/unicodeobject.c In-Reply-To: <44683D6C.8010101@egenix.com> References: <20060515072224.229C81E4013@bag.python.org> <44683D6C.8010101@egenix.com> Message-ID: <44696CE8.3040709@v.loewis.de> M.-A. Lemburg wrote: > Could you please make this fix apply only on Solaris, > e.g. using an #ifdef ?! That shouldn't be done. The code, as it was before, had undefined behaviour in C. With the fix, it is now correct. If you want to drop usage of memcpy on systems where you think it isn't needed, you should make a positive list of such systems, e.g. through an autoconf test (although such a test is difficult to formulate). > The memcpy is a lot more expensive than a simple memory > copy via registers and this operation is done per code point > in the Unicode string, so any change to the inner loop makes > a difference. This is a bit too pessimistic. On Linux/x86, with gcc 4.0.4, this memcpy call is compiled into movl 8(%ebp), %eax ; eax = s movzwl (%eax), %edx ; (e)dx = *s movl -32(%ebp), %eax ; eax = p movw %dx, (%eax) ; *p = dx (= *s) So it *is* a simple memory copy via registers. Any modern C compiler should be able to achieve this optimization: it can know what memcpy does, it can compute the number of bytes to be moved at compile time, see that this is two bytes only, and avoid calling a function, or generating a copy loop. (if you want to see what your compiler generates, put two function calls, say, foo() and bar(), around this statement, and find these function calls in the assembler output). If you worry about compilers which cannot do this optimization, you should use individual char assignments, e.g. through ((char*)p)[0] = s[0]; ((char*)p)[1] = s[1]; (and similarly for Py_UNICODE_WIDE). While this also avoids the function call, it does generate worse code for gcc 4.0.4: movl 8(%ebp), %eax movzbl (%eax), %edx movl -32(%ebp), %eax movb %dl, (%eax) movl 8(%ebp), %eax movzbl 1(%eax), %edx movl -32(%ebp), %eax movb %dl, 1(%eax) (other compiler might be able to compile this into a single two-byte move, of course). Regards, Martin From martin at v.loewis.de Tue May 16 08:15:10 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 16 May 2006 08:15:10 +0200 Subject: [Python-checkins] r45964 - in python/trunk: Doc/lib/libexcs.tex Lib/mailbox.py Lib/tempfile.py Misc/NEWS PC/errmap.h PC/errmap.mak PC/generrmap.c Python/exceptions.c In-Reply-To: References: <20060511132844.C94AD1E4008@bag.python.org> Message-ID: <44696DEE.5090204@v.loewis.de> Neal Norwitz wrote: >> + /* Could not set errno. */ >> + Py_XDECREF(o_errcode); >> + Py_DECREF(self); >> + Py_DECREF(result); >> + return NULL; >> +} > > self needs an XDECREF. Actually, self is a borrowed reference, so it shouldn't get decref'ed at all. > Doesn't repr need to be DECREF'd here? No: it's XDECREFed immediately when the tuple or fmt allocation failed. Then, the reference moves into the tuple, and tuple deallocation will also free repr. > You could use PyTuple_Pack() insead of _New() and SET_ITEM (above and > below). It would be a bit shorter I think. With some restructuring, it is indeed shorter. This code was cut-n-paste from EnvironmentError__str__. >> +static >> +PyMethodDef WindowsError_methods[] = { >> + {"__init__", WindowsError__init__, METH_VARARGS}, >> + {"__str__", WindowsError__str__, METH_VARARGS}, >> + {NULL, NULL} >> +}; > > You could use METH_O for __str__. Sure; this requires changes to most other __str__ functions as they call each other. I changed them all. All fixed in 46003 Regards, Martin From python-checkins at python.org Tue May 16 09:05:39 2006 From: python-checkins at python.org (martin.v.loewis) Date: Tue, 16 May 2006 09:05:39 +0200 (CEST) Subject: [Python-checkins] r46010 - in python/trunk: Modules/posixmodule.c configure configure.in pyconfig.h.in Message-ID: <20060516070539.217821E4006@bag.python.org> Author: martin.v.loewis Date: Tue May 16 09:05:37 2006 New Revision: 46010 Modified: python/trunk/Modules/posixmodule.c python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Log: - Test for sys/statvfs.h before including it, as statvfs is present on some OSX installation, but its header file is not. Will backport to 2.4 Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Tue May 16 09:05:37 2006 @@ -6518,7 +6518,7 @@ #endif /* HAVE_SYS_WAIT_H */ -#if defined(HAVE_FSTATVFS) +#if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) #ifdef _SCO_DS /* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the needed definitions in sys/statvfs.h */ @@ -6585,10 +6585,10 @@ return _pystatvfs_fromstructstatvfs(st); } -#endif /* HAVE_FSTATVFS */ +#endif /* HAVE_FSTATVFS && HAVE_SYS_STATVFS_H */ -#if defined(HAVE_STATVFS) +#if defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H) #include PyDoc_STRVAR(posix_statvfs__doc__, @@ -8126,10 +8126,10 @@ {"WSTOPSIG", posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__}, #endif /* WSTOPSIG */ #endif /* HAVE_SYS_WAIT_H */ -#ifdef HAVE_FSTATVFS +#if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) {"fstatvfs", posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__}, #endif -#ifdef HAVE_STATVFS +#if defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H) {"statvfs", posix_statvfs, METH_VARARGS, posix_statvfs__doc__}, #endif #ifdef HAVE_TMPFILE Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Tue May 16 09:05:37 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 45800 . +# From configure.in Revision: 45995 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -4583,14 +4583,15 @@ + for ac_header in asm/types.h curses.h dlfcn.h fcntl.h grp.h \ shadow.h langinfo.h libintl.h ncurses.h poll.h pthread.h \ stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ -sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/time.h \ +sys/times.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h do Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Tue May 16 09:05:37 2006 @@ -1033,8 +1033,8 @@ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ -sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/time.h \ +sys/times.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h) AC_HEADER_DIRENT Modified: python/trunk/pyconfig.h.in ============================================================================== --- python/trunk/pyconfig.h.in (original) +++ python/trunk/pyconfig.h.in Tue May 16 09:05:37 2006 @@ -579,6 +579,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H From python-checkins at python.org Tue May 16 09:06:35 2006 From: python-checkins at python.org (martin.v.loewis) Date: Tue, 16 May 2006 09:06:35 +0200 (CEST) Subject: [Python-checkins] r46011 - in python/branches/release24-maint: Misc/NEWS Modules/posixmodule.c configure configure.in pyconfig.h.in Message-ID: <20060516070635.7AF211E4006@bag.python.org> Author: martin.v.loewis Date: Tue May 16 09:06:33 2006 New Revision: 46011 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/posixmodule.c python/branches/release24-maint/configure python/branches/release24-maint/configure.in python/branches/release24-maint/pyconfig.h.in Log: Backport of 46010 - Test for sys/statvfs.h before including it, as statvfs is present on some OSX installations, but its header file is not. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Tue May 16 09:06:33 2006 @@ -60,6 +60,9 @@ Build ----- +- Test for sys/statvfs.h before including it, as statvfs is present + on some OSX installation, but its header file is not. + - Fix test_long failure on Tru64 with gcc by using -mieee gcc option. Documentation Modified: python/branches/release24-maint/Modules/posixmodule.c ============================================================================== --- python/branches/release24-maint/Modules/posixmodule.c (original) +++ python/branches/release24-maint/Modules/posixmodule.c Tue May 16 09:06:33 2006 @@ -6041,7 +6041,7 @@ #endif /* HAVE_SYS_WAIT_H */ -#if defined(HAVE_FSTATVFS) +#if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) #ifdef _SCO_DS /* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the needed definitions in sys/statvfs.h */ @@ -6108,10 +6108,10 @@ return _pystatvfs_fromstructstatvfs(st); } -#endif /* HAVE_FSTATVFS */ +#endif /* HAVE_FSTATVFS && HAVE_SYS_STATVFS_H */ -#if defined(HAVE_STATVFS) +#if defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H) #include PyDoc_STRVAR(posix_statvfs__doc__, @@ -7593,10 +7593,10 @@ {"WSTOPSIG", posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__}, #endif /* WSTOPSIG */ #endif /* HAVE_SYS_WAIT_H */ -#ifdef HAVE_FSTATVFS +#if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) {"fstatvfs", posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__}, #endif -#ifdef HAVE_STATVFS +#if defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H) {"statvfs", posix_statvfs, METH_VARARGS, posix_statvfs__doc__}, #endif #ifdef HAVE_TMPFILE Modified: python/branches/release24-maint/configure ============================================================================== --- python/branches/release24-maint/configure (original) +++ python/branches/release24-maint/configure Tue May 16 09:06:33 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 43537 . +# From configure.in Revision: 43618 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -4564,14 +4564,15 @@ + for ac_header in curses.h dlfcn.h fcntl.h grp.h langinfo.h \ libintl.h ncurses.h poll.h pthread.h \ stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ -sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/time.h \ +sys/times.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h do Modified: python/branches/release24-maint/configure.in ============================================================================== --- python/branches/release24-maint/configure.in (original) +++ python/branches/release24-maint/configure.in Tue May 16 09:06:33 2006 @@ -990,8 +990,8 @@ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ -sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/time.h \ +sys/times.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h) AC_HEADER_DIRENT Modified: python/branches/release24-maint/pyconfig.h.in ============================================================================== --- python/branches/release24-maint/pyconfig.h.in (original) +++ python/branches/release24-maint/pyconfig.h.in Tue May 16 09:06:33 2006 @@ -543,6 +543,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H From buildbot at python.org Tue May 16 09:23:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 16 May 2006 07:23:31 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060516072331.83BFA1E4006@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/401 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 16 09:38:28 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 16 May 2006 09:38:28 +0200 (CEST) Subject: [Python-checkins] r46012 - in python/trunk: Doc/lib/libzlib.tex Lib/test/test_zlib.py Misc/NEWS Modules/zlibmodule.c Message-ID: <20060516073828.C033A1E4006@bag.python.org> Author: georg.brandl Date: Tue May 16 09:38:27 2006 New Revision: 46012 Modified: python/trunk/Doc/lib/libzlib.tex python/trunk/Lib/test/test_zlib.py python/trunk/Misc/NEWS python/trunk/Modules/zlibmodule.c Log: Patch #1435422: zlib's compress and decompress objects now have a copy() method. Modified: python/trunk/Doc/lib/libzlib.tex ============================================================================== --- python/trunk/Doc/lib/libzlib.tex (original) +++ python/trunk/Doc/lib/libzlib.tex Tue May 16 09:38:27 2006 @@ -123,6 +123,12 @@ action is to delete the object. \end{methoddesc} +\begin{methoddesc}[Compress]{copy}{} +Returns a copy of the compression object. This can be used to efficiently +compress a set of data that share a common initial prefix. +\versionadded{2.5} +\end{methoddesc} + Decompression objects support the following methods, and two attributes: \begin{memberdesc}{unused_data} @@ -176,6 +182,13 @@ output buffer. \end{methoddesc} +\begin{methoddesc}[Decompress]{copy}{} +Returns a copy of the decompression object. This can be used to save the +state of the decompressor midway through the data stream in order to speed up +random seeks into the stream at a future point. +\versionadded{2.5} +\end{methoddesc} + \begin{seealso} \seemodule{gzip}{Reading and writing \program{gzip}-format files.} \seeurl{http://www.zlib.net}{The zlib library home page.} Modified: python/trunk/Lib/test/test_zlib.py ============================================================================== --- python/trunk/Lib/test/test_zlib.py (original) +++ python/trunk/Lib/test/test_zlib.py Tue May 16 09:38:27 2006 @@ -302,6 +302,63 @@ dco = zlib.decompressobj() self.assertEqual(dco.flush(), "") # Returns nothing + def test_compresscopy(self): + # Test copying a compression object + data0 = HAMLET_SCENE + data1 = HAMLET_SCENE.swapcase() + c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) + bufs0 = [] + bufs0.append(c0.compress(data0)) + + c1 = c0.copy() + bufs1 = bufs0[:] + + bufs0.append(c0.compress(data0)) + bufs0.append(c0.flush()) + s0 = ''.join(bufs0) + + bufs1.append(c1.compress(data1)) + bufs1.append(c1.flush()) + s1 = ''.join(bufs1) + + self.assertEqual(zlib.decompress(s0),data0+data0) + self.assertEqual(zlib.decompress(s1),data0+data1) + + def test_badcompresscopy(self): + # Test copying a compression object in an inconsistent state + c = zlib.compressobj() + c.compress(HAMLET_SCENE) + c.flush() + self.assertRaises(ValueError, c.copy) + + def test_decompresscopy(self): + # Test copying a decompression object + data = HAMLET_SCENE + comp = zlib.compress(data) + + d0 = zlib.decompressobj() + bufs0 = [] + bufs0.append(d0.decompress(comp[:32])) + + d1 = d0.copy() + bufs1 = bufs0[:] + + bufs0.append(d0.decompress(comp[32:])) + s0 = ''.join(bufs0) + + bufs1.append(d1.decompress(comp[32:])) + s1 = ''.join(bufs1) + + self.assertEqual(s0,s1) + self.assertEqual(s0,data) + + def test_baddecompresscopy(self): + # Test copying a compression object in an inconsistent state + data = zlib.compress(HAMLET_SCENE) + d = zlib.decompressobj() + d.decompress(data) + d.flush() + self.assertRaises(ValueError, d.copy) def genblock(seed, length, step=1024, generator=random): """length-byte stream of random data from a seed (in step-byte blocks).""" Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 16 09:38:27 2006 @@ -28,6 +28,9 @@ Extension Modules ----------------- +- Patch #1435422: zlib's compress and decompress objects now have a + copy() method. + - On Win32, os.listdir now supports arbitrarily-long Unicode path names (up to the system limit of 32K characters). Modified: python/trunk/Modules/zlibmodule.c ============================================================================== --- python/trunk/Modules/zlibmodule.c (original) +++ python/trunk/Modules/zlibmodule.c Tue May 16 09:38:27 2006 @@ -653,6 +653,104 @@ return RetVal; } +PyDoc_STRVAR(comp_copy__doc__, +"copy() -- Return a copy of the compression object."); + +static PyObject * +PyZlib_copy(compobject *self) +{ + compobject *retval = NULL; + int err; + + retval = newcompobject(&Comptype); + if (!retval) return NULL; + + /* Copy the zstream state + * We use ENTER_ZLIB / LEAVE_ZLIB to make this thread-safe + */ + ENTER_ZLIB + err = deflateCopy(&retval->zst, &self->zst); + switch(err) { + case(Z_OK): + break; + case(Z_STREAM_ERROR): + PyErr_SetString(PyExc_ValueError, "Inconsistent stream state"); + goto error; + case(Z_MEM_ERROR): + PyErr_SetString(PyExc_MemoryError, + "Can't allocate memory for compression object"); + goto error; + default: + zlib_error(self->zst, err, "while copying compression object"); + goto error; + } + + retval->unused_data = self->unused_data; + retval->unconsumed_tail = self->unconsumed_tail; + Py_INCREF(retval->unused_data); + Py_INCREF(retval->unconsumed_tail); + + /* Mark it as being initialized */ + retval->is_initialised = 1; + + LEAVE_ZLIB + return (PyObject *)retval; + +error: + LEAVE_ZLIB + Py_XDECREF(retval); + return NULL; +} + +PyDoc_STRVAR(decomp_copy__doc__, +"copy() -- Return a copy of the decompression object."); + +static PyObject * +PyZlib_uncopy(compobject *self) +{ + compobject *retval = NULL; + int err; + + retval = newcompobject(&Decomptype); + if (!retval) return NULL; + + /* Copy the zstream state + * We use ENTER_ZLIB / LEAVE_ZLIB to make this thread-safe + */ + ENTER_ZLIB + err = inflateCopy(&retval->zst, &self->zst); + switch(err) { + case(Z_OK): + break; + case(Z_STREAM_ERROR): + PyErr_SetString(PyExc_ValueError, "Inconsistent stream state"); + goto error; + case(Z_MEM_ERROR): + PyErr_SetString(PyExc_MemoryError, + "Can't allocate memory for decompression object"); + goto error; + default: + zlib_error(self->zst, err, "while copying decompression object"); + goto error; + } + + retval->unused_data = self->unused_data; + retval->unconsumed_tail = self->unconsumed_tail; + Py_INCREF(retval->unused_data); + Py_INCREF(retval->unconsumed_tail); + + /* Mark it as being initialized */ + retval->is_initialised = 1; + + LEAVE_ZLIB + return (PyObject *)retval; + +error: + LEAVE_ZLIB + Py_XDECREF(retval); + return NULL; +} + PyDoc_STRVAR(decomp_flush__doc__, "flush( [length] ) -- Return a string containing any remaining\n" "decompressed data. length, if given, is the initial size of the\n" @@ -725,6 +823,8 @@ comp_compress__doc__}, {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS, comp_flush__doc__}, + {"copy", (PyCFunction)PyZlib_copy, METH_NOARGS, + comp_copy__doc__}, {NULL, NULL} }; @@ -734,6 +834,8 @@ decomp_decompress__doc__}, {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS, decomp_flush__doc__}, + {"copy", (PyCFunction)PyZlib_uncopy, METH_NOARGS, + decomp_copy__doc__}, {NULL, NULL} }; From richard at commonground.com.au Tue May 16 10:29:40 2006 From: richard at commonground.com.au (Richard Jones) Date: Tue, 16 May 2006 18:29:40 +1000 Subject: [Python-checkins] r46010 - in python/trunk: Modules/posixmodule.c configure configure.in pyconfig.h.in In-Reply-To: <20060516070539.217821E4006@bag.python.org> References: <20060516070539.217821E4006@bag.python.org> Message-ID: <4384C312-5BC2-4A8F-A18C-EDD1F52782AA@commonground.com.au> On 16/05/2006, at 5:05 PM, martin.v.loewis wrote: > - Test for sys/statvfs.h before including it, as statvfs is present > on some OSX installation, but its header file is not. > Will backport to 2.4 The sys/_types.h and machine/_types.h headers were also missing. I'm not sure if there were any others - I didn't perform an extensive check. Richard From neal at metaslash.com Tue May 16 11:07:20 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 16 May 2006 05:07:20 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060516090720.GA3116@python.psfb.org> test_threading_local leaked [-91, 0, 0] references test_urllib2 leaked [143, -110, -33] references test_zlib leaked [4, 4, 4] references From buildbot at python.org Tue May 16 11:48:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 16 May 2006 09:48:30 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060516094830.881021E4006@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/26 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 16 12:01:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 16 May 2006 10:01:58 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060516100158.C4C851E4006@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/371 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Tue May 16 14:13:25 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 16 May 2006 14:13:25 +0200 Subject: [Python-checkins] r46002 - in python/branches/release24-maint: Misc/ACKS Misc/NEWS Objects/unicodeobject.c In-Reply-To: <44696CE8.3040709@v.loewis.de> References: <20060515072224.229C81E4013@bag.python.org> <44683D6C.8010101@egenix.com> <44696CE8.3040709@v.loewis.de> Message-ID: <4469C1E5.5080906@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >> Could you please make this fix apply only on Solaris, >> e.g. using an #ifdef ?! > > That shouldn't be done. The code, as it was before, had > undefined behaviour in C. With the fix, it is now correct. I don't understand - what's undefined in: const char *s; Py_UNICODE *p; ... *p = *(Py_UNICODE *)s; > If you want to drop usage of memcpy on systems where you > think it isn't needed, you should make a positive list of > such systems, e.g. through an autoconf test (although such > a test is difficult to formulate). I don't want to drop memcpy() - just keep the existing working code on platforms where the memcpy() is not needed. >> The memcpy is a lot more expensive than a simple memory >> copy via registers and this operation is done per code point >> in the Unicode string, so any change to the inner loop makes >> a difference. > > This is a bit too pessimistic. On Linux/x86, with gcc 4.0.4, > this memcpy call is compiled into > > movl 8(%ebp), %eax ; eax = s > movzwl (%eax), %edx ; (e)dx = *s > movl -32(%ebp), %eax ; eax = p > movw %dx, (%eax) ; *p = dx (= *s) > > So it *is* a simple memory copy via registers. Any modern C > compiler should be able to achieve this optimization: it can > know what memcpy does, it can compute the number of bytes to > be moved at compile time, see that this is two bytes only, > and avoid calling a function, or generating a copy loop. Last time I checked this (some years ago), the above direct copy was always faster. Some compilers didn't even inline the memcpy() as you would expect. This is what gcc 3.3.4 (standard on SuSE 9.2 x64) generates for the direct copy: Without -O3: .loc 1 2316 0 movq -72(%rbp), %rdx movq -8(%rbp), %rax movzwl (%rax), %eax movw %ax, (%rdx) With -O3: .loc 1 2316 0 movzwl (%rax), %edx .LVL2623: movw %dx, (%rcx) > (if you want to see what your compiler generates, put two > function calls, say, foo() and bar(), around this statement, > and find these function calls in the assembler output). (or search for the embedded .loc directives which point at the source code line in the original C file) > If you worry about compilers which cannot do this optimization, > you should use individual char assignments, e.g. through > > ((char*)p)[0] = s[0]; > ((char*)p)[1] = s[1]; > > (and similarly for Py_UNICODE_WIDE). What's wrong with the direct copy ? A modern compiler should know the alignment requirements of Py_UNICODE* on the platform and generate appropriate code. AFAICTL, only 64-bit platforms are subject to any such problems due to their requirement to have pointers aligned on 8-byte boundaries. > While this also avoids > the function call, it does generate worse code for gcc 4.0.4: > > movl 8(%ebp), %eax > movzbl (%eax), %edx > movl -32(%ebp), %eax > movb %dl, (%eax) > > movl 8(%ebp), %eax > movzbl 1(%eax), %edx > movl -32(%ebp), %eax > movb %dl, 1(%eax) > > (other compiler might be able to compile this into a single > two-byte move, of course). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 16 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Tue May 16 18:11:55 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 16 May 2006 18:11:55 +0200 (CEST) Subject: [Python-checkins] r46015 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060516161155.1B3511E4007@bag.python.org> Author: andrew.kuchling Date: Tue May 16 18:11:54 2006 New Revision: 46015 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add item Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 16 18:11:54 2006 @@ -1513,6 +1513,12 @@ (Contributed by Skip Montanaro.) % Patch 1120353 +\item The \module{zlib} module's \class{Compress} and \class{Decompress} +objects now support a \method{copy()} method that makes a copy of the +object's internal state and returns a new +\class{Compress} or \class{Decompress} object. +(Contributed by Chris AtLee.) +% Patch 1435422 \end{itemize} From python-checkins at python.org Tue May 16 18:27:32 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 16 May 2006 18:27:32 +0200 (CEST) Subject: [Python-checkins] r46016 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060516162732.8E1351E4024@bag.python.org> Author: andrew.kuchling Date: Tue May 16 18:27:31 2006 New Revision: 46016 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: PEP 243 has been withdrawn, so don't refer to it any more. The PyPI upload material has been moved into the section on PEP314. Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 16 18:27:31 2006 @@ -32,32 +32,6 @@ %====================================================================== -\section{PEP 243: Uploading Modules to PyPI\label{pep-243}} - -PEP 243 describes an HTTP-based protocol for submitting software -packages to a central archive. The Python package index at -\url{http://cheeseshop.python.org} now supports package uploads, and -the new \command{upload} Distutils command will upload a package to the -repository. - -Before a package can be uploaded, you must be able to build a -distribution using the \command{sdist} Distutils command. Once that -works, you can run \code{python setup.py upload} to add your package -to the PyPI archive. Optionally you can GPG-sign the package by -supplying the \longprogramopt{sign} and -\longprogramopt{identity} options. - -\begin{seealso} - -\seepep{243}{Module Repository Upload Mechanism}{PEP written by -Sean Reifschneider; implemented by Martin von~L\"owis -and Richard Jones. Note that the PEP doesn't exactly -describe what's implemented in PyPI.} - -\end{seealso} - - -%====================================================================== \section{PEP 308: Conditional Expressions\label{pep-308}} For a long time, people have been requesting a way to write @@ -234,6 +208,20 @@ % VERSION), ) \end{verbatim} + +Another new enhancement to the Python package index at +\url{http://cheeseshop.python.org} is storing source and binary +archives for a package. The new \command{upload} Distutils command +will upload a package to the repository. + +Before a package can be uploaded, you must be able to build a +distribution using the \command{sdist} Distutils command. Once that +works, you can run \code{python setup.py upload} to add your package +to the PyPI archive. Optionally you can GPG-sign the package by +supplying the \longprogramopt{sign} and +\longprogramopt{identity} options. + +Package uploading was implemented by Martin von~L\"owis and Richard Jones. \begin{seealso} From python-checkins at python.org Tue May 16 19:42:24 2006 From: python-checkins at python.org (george.yoshida) Date: Tue, 16 May 2006 19:42:24 +0200 (CEST) Subject: [Python-checkins] r46017 - python/trunk/Misc/Vim/python.vim Message-ID: <20060516174224.841951E4007@bag.python.org> Author: george.yoshida Date: Tue May 16 19:42:16 2006 New Revision: 46017 Modified: python/trunk/Misc/Vim/python.vim Log: Update for 'ImportWarning' Modified: python/trunk/Misc/Vim/python.vim ============================================================================== --- python/trunk/Misc/Vim/python.vim (original) +++ python/trunk/Misc/Vim/python.vim Tue May 16 19:42:16 2006 @@ -86,9 +86,9 @@ syn keyword pythonException UnicodeError UnicodeEncodeError syn keyword pythonException FloatingPointError ReferenceError NameError syn keyword pythonException OverflowWarning IOError SyntaxError - syn keyword pythonException FutureWarning SystemExit Exception EOFError - syn keyword pythonException StandardError ValueError TabError KeyError - syn keyword pythonException ZeroDivisionError SystemError + syn keyword pythonException FutureWarning ImportWarning SystemExit + syn keyword pythonException Exception EOFError StandardError ValueError + syn keyword pythonException TabError KeyError ZeroDivisionError SystemError syn keyword pythonException UnicodeDecodeError IndentationError syn keyword pythonException AssertionError TypeError IndexError syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning From python-checkins at python.org Tue May 16 20:08:23 2006 From: python-checkins at python.org (george.yoshida) Date: Tue, 16 May 2006 20:08:23 +0200 (CEST) Subject: [Python-checkins] r46018 - python/trunk/Doc/lib/libexcs.tex Message-ID: <20060516180823.DD0D91E401B@bag.python.org> Author: george.yoshida Date: Tue May 16 20:07:00 2006 New Revision: 46018 Modified: python/trunk/Doc/lib/libexcs.tex Log: Mention that Exception is now a subclass of BaseException. Remove a sentence that says that BaseException inherits from BaseException. (I guess this is just a copy & paste mistake.) Modified: python/trunk/Doc/lib/libexcs.tex ============================================================================== --- python/trunk/Doc/lib/libexcs.tex (original) +++ python/trunk/Doc/lib/libexcs.tex Tue May 16 20:07:00 2006 @@ -80,7 +80,6 @@ to be attached to the exception, attach it through arbitrary attributes on the instance. All arguments are also stored in \member{args} as a tuple, but it will eventually be deprecated and thus its use is discouraged. -\versionchanged[Changed to inherit from \exception{BaseException}]{2.5} \versionadded{2.5} \end{excdesc} @@ -88,6 +87,7 @@ All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class. +\versionchanged[Changed to inherit from \exception{BaseException}]{2.5} \end{excdesc} \begin{excdesc}{StandardError} From python-checkins at python.org Tue May 16 20:26:11 2006 From: python-checkins at python.org (george.yoshida) Date: Tue, 16 May 2006 20:26:11 +0200 (CEST) Subject: [Python-checkins] r46019 - python/trunk/Doc/lib/libexcs.tex Message-ID: <20060516182611.460971E4007@bag.python.org> Author: george.yoshida Date: Tue May 16 20:26:10 2006 New Revision: 46019 Modified: python/trunk/Doc/lib/libexcs.tex Log: Document ImportWarning Modified: python/trunk/Doc/lib/libexcs.tex ============================================================================== --- python/trunk/Doc/lib/libexcs.tex (original) +++ python/trunk/Doc/lib/libexcs.tex Tue May 16 20:26:10 2006 @@ -451,6 +451,11 @@ in the future. \end{excdesc} +\begin{excdesc}{ImportWarning} +Base class for warnings about probable mistakes in module imports. +\versionadded{2.5} +\end{excdesc} + The class hierarchy for built-in exceptions is: \verbatiminput{../../Lib/test/exception_hierarchy.txt} From buildbot at python.org Tue May 16 21:17:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 16 May 2006 19:17:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060516191744.A103C1E4007@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/479 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From neal at metaslash.com Tue May 16 23:06:42 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 16 May 2006 17:06:42 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060516210642.GA26949@python.psfb.org> test_cmd_line leaked [17, -17, 0] references test_threading_local leaked [-91, 0, 0] references test_urllib2 leaked [143, -110, -33] references test_zlib leaked [4, 4, 4] references From martin at v.loewis.de Tue May 16 23:34:34 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 16 May 2006 23:34:34 +0200 Subject: [Python-checkins] r46002 - in python/branches/release24-maint: Misc/ACKS Misc/NEWS Objects/unicodeobject.c In-Reply-To: <4469C1E5.5080906@egenix.com> References: <20060515072224.229C81E4013@bag.python.org> <44683D6C.8010101@egenix.com> <44696CE8.3040709@v.loewis.de> <4469C1E5.5080906@egenix.com> Message-ID: <446A456A.4010800@v.loewis.de> M.-A. Lemburg wrote: > I don't understand - what's undefined in: > > const char *s; > Py_UNICODE *p; > ... > *p = *(Py_UNICODE *)s; ISO/IEC 9899:1999, section 6.3.2.3, paragraph 7: # A pointer to an object or incomplete type may be # converted to a pointer to a different object or incomplete # type. If the resulting pointer is not correctly aligned 57) # for the pointed-to type, the behavior is undefined. # ... Footnote 57 says # In general, the concept ``correctly aligned'' is # transitive: if a pointer to type A is correctly aligned # for a pointer to type B, which in turn is correctly # aligned for a pointer to type C, then a pointer to type A # is correctly aligned for a pointer to type C. So if "s" is not correctly aligned for Py_UNICODE, the behaviour is undefined. >> If you want to drop usage of memcpy on systems where you >> think it isn't needed, you should make a positive list of >> such systems, e.g. through an autoconf test (although such >> a test is difficult to formulate). > > I don't want to drop memcpy() - just keep the existing > working code on platforms where the memcpy() is not > needed. I can understand that wish. However, by conditionalizing it for SPARC, you still break the code for all the other platforms where the memcpy *is* needed. > Last time I checked this (some years ago), the above > direct copy was always faster. Some compilers didn't even > inline the memcpy() as you would expect. It might have been always faster in all the cases that you checked - however, I very much doubt that it was always faster on all platforms on which you could have checked it at the time. If you had checked it on all possible platforms, you would have noticed that this involves unaligned accesses. > What's wrong with the direct copy ? It creates unaligned accesses. > A modern compiler should know the alignment requirements > of Py_UNICODE* on the platform and generate appropriate > code. No. The C standard doesn't require it to, and the compilers don't generate less efficient code just to support buggy C code. > AFAICTL, only 64-bit platforms are subject to any > such problems due to their requirement to have pointers > aligned on 8-byte boundaries. Your impression is incorrect: The problem occurs on all systems that require aligned acesses (i.e. SPARC, PowerPC, Itanium, ...); whether these systems use 32-bit or 64-bit processors is irrelevant. On these processors, it also depends on the operating system. For example, Linux will, by default, "correct" unaligned accesses, and only create a syslog entry. This is very expensive (it causes a bus error, and an opcode emulation in the kernel), and can be disabled at the user's option. Regards, Martin From python-checkins at python.org Wed May 17 01:22:20 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 17 May 2006 01:22:20 +0200 (CEST) Subject: [Python-checkins] r46020 - in python/trunk: Lib/plat-mac/bundlebuilder.py Mac/OSX/IDLE/idlemain.py Message-ID: <20060516232220.ACF821E4017@bag.python.org> Author: tim.peters Date: Wed May 17 01:22:20 2006 New Revision: 46020 Modified: python/trunk/Lib/plat-mac/bundlebuilder.py python/trunk/Mac/OSX/IDLE/idlemain.py Log: Whitespace normalization. Modified: python/trunk/Lib/plat-mac/bundlebuilder.py ============================================================================== --- python/trunk/Lib/plat-mac/bundlebuilder.py (original) +++ python/trunk/Lib/plat-mac/bundlebuilder.py Wed May 17 01:22:20 2006 @@ -150,7 +150,7 @@ bp = self.bundlepath # Create the app bundle in a temporary location and then - # rename the completed bundle. This way the Finder will + # rename the completed bundle. This way the Finder will # never see an incomplete bundle (where it might pick up # and cache the wrong meta data) self.bundlepath = bp + '~' Modified: python/trunk/Mac/OSX/IDLE/idlemain.py ============================================================================== --- python/trunk/Mac/OSX/IDLE/idlemain.py (original) +++ python/trunk/Mac/OSX/IDLE/idlemain.py Wed May 17 01:22:20 2006 @@ -2,7 +2,7 @@ from idlelib.PyShell import main import sys, os -# Make sure sys.executable points to the python interpreter inside the +# Make sure sys.executable points to the python interpreter inside the # framework, instead of at the helper executable inside the application # bundle (the latter works, but doesn't allow access to the window server) sys.executable = os.path.join(sys.prefix, 'bin', 'python') @@ -16,4 +16,4 @@ argvemulator.ArgvCollector().mainloop() if __name__ == '__main__': - main() + main() From python-checkins at python.org Wed May 17 01:24:10 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 17 May 2006 01:24:10 +0200 (CEST) Subject: [Python-checkins] r46021 - in python/trunk: Doc/lib/sqlite3/adapter_datetime.py Doc/lib/sqlite3/adapter_point_1.py Doc/lib/sqlite3/adapter_point_2.py Doc/lib/sqlite3/collation_reverse.py Doc/lib/sqlite3/complete_statement.py Doc/lib/sqlite3/connect_db_1.py Doc/lib/sqlite3/connect_db_2.py Doc/lib/sqlite3/converter_point.py Doc/lib/sqlite3/countcursors.py Doc/lib/sqlite3/createdb.py Doc/lib/sqlite3/execsql_fetchonerow.py Doc/lib/sqlite3/execsql_printall_1.py Doc/lib/sqlite3/execute_1.py Doc/lib/sqlite3/execute_2.py Doc/lib/sqlite3/execute_3.py Doc/lib/sqlite3/executemany_1.py Doc/lib/sqlite3/executemany_2.py Doc/lib/sqlite3/executescript.py Doc/lib/sqlite3/insert_more_people.py Doc/lib/sqlite3/md5func.py Doc/lib/sqlite3/mysumaggr.py Doc/lib/sqlite3/parse_colnames.py Doc/lib/sqlite3/pysqlite_datetime.py Doc/lib/sqlite3/row_factory.py Doc/lib/sqlite3/rowclass.py Doc/lib/sqlite3/shared_cache.py Doc/lib/sqlite3/shortcut_methods.py Doc/lib/sqlite3/simple_tableprinter.py Doc/lib/sqlite3/text_factory.py Lib/test/test_bigmem.py Mac/OSX/Icons/ReadMe.txt Message-ID: <20060516232410.B92231E4007@bag.python.org> Author: tim.peters Date: Wed May 17 01:24:08 2006 New Revision: 46021 Modified: python/trunk/Doc/lib/sqlite3/adapter_datetime.py (contents, props changed) python/trunk/Doc/lib/sqlite3/adapter_point_1.py (contents, props changed) python/trunk/Doc/lib/sqlite3/adapter_point_2.py (contents, props changed) python/trunk/Doc/lib/sqlite3/collation_reverse.py (contents, props changed) python/trunk/Doc/lib/sqlite3/complete_statement.py (props changed) python/trunk/Doc/lib/sqlite3/connect_db_1.py (contents, props changed) python/trunk/Doc/lib/sqlite3/connect_db_2.py (contents, props changed) python/trunk/Doc/lib/sqlite3/converter_point.py (contents, props changed) python/trunk/Doc/lib/sqlite3/countcursors.py (contents, props changed) python/trunk/Doc/lib/sqlite3/createdb.py (contents, props changed) python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py (contents, props changed) python/trunk/Doc/lib/sqlite3/execsql_printall_1.py (contents, props changed) python/trunk/Doc/lib/sqlite3/execute_1.py (contents, props changed) python/trunk/Doc/lib/sqlite3/execute_2.py (contents, props changed) python/trunk/Doc/lib/sqlite3/execute_3.py (contents, props changed) python/trunk/Doc/lib/sqlite3/executemany_1.py (contents, props changed) python/trunk/Doc/lib/sqlite3/executemany_2.py (contents, props changed) python/trunk/Doc/lib/sqlite3/executescript.py (contents, props changed) python/trunk/Doc/lib/sqlite3/insert_more_people.py (contents, props changed) python/trunk/Doc/lib/sqlite3/md5func.py (contents, props changed) python/trunk/Doc/lib/sqlite3/mysumaggr.py (contents, props changed) python/trunk/Doc/lib/sqlite3/parse_colnames.py (contents, props changed) python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py (contents, props changed) python/trunk/Doc/lib/sqlite3/row_factory.py (contents, props changed) python/trunk/Doc/lib/sqlite3/rowclass.py (props changed) python/trunk/Doc/lib/sqlite3/shared_cache.py (props changed) python/trunk/Doc/lib/sqlite3/shortcut_methods.py (contents, props changed) python/trunk/Doc/lib/sqlite3/simple_tableprinter.py (contents, props changed) python/trunk/Doc/lib/sqlite3/text_factory.py (contents, props changed) python/trunk/Lib/test/test_bigmem.py (contents, props changed) python/trunk/Mac/OSX/Icons/ReadMe.txt (props changed) Log: Text files missing the SVN eol-style property. Modified: python/trunk/Doc/lib/sqlite3/adapter_datetime.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/adapter_datetime.py (original) +++ python/trunk/Doc/lib/sqlite3/adapter_datetime.py Wed May 17 01:24:08 2006 @@ -1,14 +1,14 @@ -import sqlite3 -import datetime, time - -def adapt_datetime(ts): - return time.mktime(ts.timetuple()) - -sqlite3.register_adapter(datetime.datetime, adapt_datetime) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -now = datetime.datetime.now() -cur.execute("select ?", (now,)) -print cur.fetchone()[0] +import sqlite3 +import datetime, time + +def adapt_datetime(ts): + return time.mktime(ts.timetuple()) + +sqlite3.register_adapter(datetime.datetime, adapt_datetime) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +now = datetime.datetime.now() +cur.execute("select ?", (now,)) +print cur.fetchone()[0] Modified: python/trunk/Doc/lib/sqlite3/adapter_point_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/adapter_point_1.py (original) +++ python/trunk/Doc/lib/sqlite3/adapter_point_1.py Wed May 17 01:24:08 2006 @@ -1,16 +1,16 @@ -import sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - - def __conform__(self, protocol): - if protocol is sqlite3.PrepareProtocol: - return "%f;%f" % (self.x, self.y) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) -print cur.fetchone()[0] +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + + def __conform__(self, protocol): + if protocol is sqlite3.PrepareProtocol: + return "%f;%f" % (self.x, self.y) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +p = Point(4.0, -3.2) +cur.execute("select ?", (p,)) +print cur.fetchone()[0] Modified: python/trunk/Doc/lib/sqlite3/adapter_point_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/adapter_point_2.py (original) +++ python/trunk/Doc/lib/sqlite3/adapter_point_2.py Wed May 17 01:24:08 2006 @@ -1,17 +1,17 @@ -import sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - -def adapt_point(point): - return "%f;%f" % (point.x, point.y) - -sqlite3.register_adapter(Point, adapt_point) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) -print cur.fetchone()[0] +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + +def adapt_point(point): + return "%f;%f" % (point.x, point.y) + +sqlite3.register_adapter(Point, adapt_point) + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +p = Point(4.0, -3.2) +cur.execute("select ?", (p,)) +print cur.fetchone()[0] Modified: python/trunk/Doc/lib/sqlite3/collation_reverse.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/collation_reverse.py (original) +++ python/trunk/Doc/lib/sqlite3/collation_reverse.py Wed May 17 01:24:08 2006 @@ -1,15 +1,15 @@ -import sqlite3 - -def collate_reverse(string1, string2): - return -cmp(string1, string2) - -con = sqlite3.connect(":memory:") -con.create_collation("reverse", collate_reverse) - -cur = con.cursor() -cur.execute("create table test(x)") -cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]) -cur.execute("select x from test order by x collate reverse") -for row in cur: - print row -con.close() +import sqlite3 + +def collate_reverse(string1, string2): + return -cmp(string1, string2) + +con = sqlite3.connect(":memory:") +con.create_collation("reverse", collate_reverse) + +cur = con.cursor() +cur.execute("create table test(x)") +cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]) +cur.execute("select x from test order by x collate reverse") +for row in cur: + print row +con.close() Modified: python/trunk/Doc/lib/sqlite3/connect_db_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/connect_db_1.py (original) +++ python/trunk/Doc/lib/sqlite3/connect_db_1.py Wed May 17 01:24:08 2006 @@ -1,3 +1,3 @@ -import sqlite3 - -con = sqlite3.connect("mydb") +import sqlite3 + +con = sqlite3.connect("mydb") Modified: python/trunk/Doc/lib/sqlite3/connect_db_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/connect_db_2.py (original) +++ python/trunk/Doc/lib/sqlite3/connect_db_2.py Wed May 17 01:24:08 2006 @@ -1,3 +1,3 @@ -import sqlite3 - -con = sqlite3.connect(":memory:") +import sqlite3 + +con = sqlite3.connect(":memory:") Modified: python/trunk/Doc/lib/sqlite3/converter_point.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/converter_point.py (original) +++ python/trunk/Doc/lib/sqlite3/converter_point.py Wed May 17 01:24:08 2006 @@ -1,47 +1,47 @@ -import sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - - def __repr__(self): - return "(%f;%f)" % (self.x, self.y) - -def adapt_point(point): - return "%f;%f" % (point.x, point.y) - -def convert_point(s): - x, y = map(float, s.split(";")) - return Point(x, y) - -# Register the adapter -sqlite3.register_adapter(Point, adapt_point) - -# Register the converter -sqlite3.register_converter("point", convert_point) - -p = Point(4.0, -3.2) - -######################### -# 1) Using declared types -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) -cur = con.cursor() -cur.execute("create table test(p point)") - -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute("select p from test") -print "with declared types:", cur.fetchone()[0] -cur.close() -con.close() - -####################### -# 1) Using column names -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute("create table test(p)") - -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute('select p as "p [point]" from test') -print "with column names:", cur.fetchone()[0] -cur.close() -con.close() +import sqlite3 + +class Point(object): + def __init__(self, x, y): + self.x, self.y = x, y + + def __repr__(self): + return "(%f;%f)" % (self.x, self.y) + +def adapt_point(point): + return "%f;%f" % (point.x, point.y) + +def convert_point(s): + x, y = map(float, s.split(";")) + return Point(x, y) + +# Register the adapter +sqlite3.register_adapter(Point, adapt_point) + +# Register the converter +sqlite3.register_converter("point", convert_point) + +p = Point(4.0, -3.2) + +######################### +# 1) Using declared types +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) +cur = con.cursor() +cur.execute("create table test(p point)") + +cur.execute("insert into test(p) values (?)", (p,)) +cur.execute("select p from test") +print "with declared types:", cur.fetchone()[0] +cur.close() +con.close() + +####################### +# 1) Using column names +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute("create table test(p)") + +cur.execute("insert into test(p) values (?)", (p,)) +cur.execute('select p as "p [point]" from test') +print "with column names:", cur.fetchone()[0] +cur.close() +con.close() Modified: python/trunk/Doc/lib/sqlite3/countcursors.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/countcursors.py (original) +++ python/trunk/Doc/lib/sqlite3/countcursors.py Wed May 17 01:24:08 2006 @@ -1,15 +1,15 @@ -import sqlite3 - -class CountCursorsConnection(sqlite3.Connection): - def __init__(self, *args, **kwargs): - sqlite3.Connection.__init__(self, *args, **kwargs) - self.numcursors = 0 - - def cursor(self, *args, **kwargs): - self.numcursors += 1 - return sqlite3.Connection.cursor(self, *args, **kwargs) - -con = sqlite3.connect(":memory:", factory=CountCursorsConnection) -cur1 = con.cursor() -cur2 = con.cursor() -print con.numcursors +import sqlite3 + +class CountCursorsConnection(sqlite3.Connection): + def __init__(self, *args, **kwargs): + sqlite3.Connection.__init__(self, *args, **kwargs) + self.numcursors = 0 + + def cursor(self, *args, **kwargs): + self.numcursors += 1 + return sqlite3.Connection.cursor(self, *args, **kwargs) + +con = sqlite3.connect(":memory:", factory=CountCursorsConnection) +cur1 = con.cursor() +cur2 = con.cursor() +print con.numcursors Modified: python/trunk/Doc/lib/sqlite3/createdb.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/createdb.py (original) +++ python/trunk/Doc/lib/sqlite3/createdb.py Wed May 17 01:24:08 2006 @@ -1,28 +1,28 @@ -# Not referenced from the documentation, but builds the database file the other -# code snippets expect. - -import sqlite3 -import os - -DB_FILE = "mydb" - -if os.path.exists(DB_FILE): - os.remove(DB_FILE) - -con = sqlite3.connect(DB_FILE) -cur = con.cursor() -cur.execute(""" - create table people - ( - name_last varchar(20), - age integer - ) - """) - -cur.execute("insert into people (name_last, age) values ('Yeltsin', 72)") -cur.execute("insert into people (name_last, age) values ('Putin', 51)") - -con.commit() - -cur.close() -con.close() +# Not referenced from the documentation, but builds the database file the other +# code snippets expect. + +import sqlite3 +import os + +DB_FILE = "mydb" + +if os.path.exists(DB_FILE): + os.remove(DB_FILE) + +con = sqlite3.connect(DB_FILE) +cur = con.cursor() +cur.execute(""" + create table people + ( + name_last varchar(20), + age integer + ) + """) + +cur.execute("insert into people (name_last, age) values ('Yeltsin', 72)") +cur.execute("insert into people (name_last, age) values ('Putin', 51)") + +con.commit() + +cur.close() +con.close() Modified: python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py (original) +++ python/trunk/Doc/lib/sqlite3/execsql_fetchonerow.py Wed May 17 01:24:08 2006 @@ -1,17 +1,17 @@ -import sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() -SELECT = "select name_last, age from people order by age, name_last" - -# 1. Iterate over the rows available from the cursor, unpacking the -# resulting sequences to yield their elements (name_last, age): -cur.execute(SELECT) -for (name_last, age) in cur: - print '%s is %d years old.' % (name_last, age) - -# 2. Equivalently: -cur.execute(SELECT) -for row in cur: - print '%s is %d years old.' % (row[0], row[1]) +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() +SELECT = "select name_last, age from people order by age, name_last" + +# 1. Iterate over the rows available from the cursor, unpacking the +# resulting sequences to yield their elements (name_last, age): +cur.execute(SELECT) +for (name_last, age) in cur: + print '%s is %d years old.' % (name_last, age) + +# 2. Equivalently: +cur.execute(SELECT) +for row in cur: + print '%s is %d years old.' % (row[0], row[1]) Modified: python/trunk/Doc/lib/sqlite3/execsql_printall_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execsql_printall_1.py (original) +++ python/trunk/Doc/lib/sqlite3/execsql_printall_1.py Wed May 17 01:24:08 2006 @@ -1,13 +1,13 @@ -import sqlite3 - -# Create a connection to the database file "mydb": -con = sqlite3.connect("mydb") - -# Get a Cursor object that operates in the context of Connection con: -cur = con.cursor() - -# Execute the SELECT statement: -cur.execute("select * from people order by age") - -# Retrieve all rows as a sequence and print that sequence: -print cur.fetchall() +import sqlite3 + +# Create a connection to the database file "mydb": +con = sqlite3.connect("mydb") + +# Get a Cursor object that operates in the context of Connection con: +cur = con.cursor() + +# Execute the SELECT statement: +cur.execute("select * from people order by age") + +# Retrieve all rows as a sequence and print that sequence: +print cur.fetchall() Modified: python/trunk/Doc/lib/sqlite3/execute_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execute_1.py (original) +++ python/trunk/Doc/lib/sqlite3/execute_1.py Wed May 17 01:24:08 2006 @@ -1,11 +1,11 @@ -import sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) -print cur.fetchone() +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) +print cur.fetchone() Modified: python/trunk/Doc/lib/sqlite3/execute_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execute_2.py (original) +++ python/trunk/Doc/lib/sqlite3/execute_2.py Wed May 17 01:24:08 2006 @@ -1,12 +1,12 @@ -import sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=:who and age=:age", - {"who": who, "age": age}) -print cur.fetchone() +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=:who and age=:age", + {"who": who, "age": age}) +print cur.fetchone() Modified: python/trunk/Doc/lib/sqlite3/execute_3.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/execute_3.py (original) +++ python/trunk/Doc/lib/sqlite3/execute_3.py Wed May 17 01:24:08 2006 @@ -1,12 +1,12 @@ -import sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=:who and age=:age", - locals()) -print cur.fetchone() +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=:who and age=:age", + locals()) +print cur.fetchone() Modified: python/trunk/Doc/lib/sqlite3/executemany_1.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/executemany_1.py (original) +++ python/trunk/Doc/lib/sqlite3/executemany_1.py Wed May 17 01:24:08 2006 @@ -1,24 +1,24 @@ -import sqlite3 - -class IterChars: - def __init__(self): - self.count = ord('a') - - def __iter__(self): - return self - - def next(self): - if self.count > ord('z'): - raise StopIteration - self.count += 1 - return (chr(self.count - 1),) # this is a 1-tuple - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.execute("create table characters(c)") - -theIter = IterChars() -cur.executemany("insert into characters(c) values (?)", theIter) - -cur.execute("select c from characters") -print cur.fetchall() +import sqlite3 + +class IterChars: + def __init__(self): + self.count = ord('a') + + def __iter__(self): + return self + + def next(self): + if self.count > ord('z'): + raise StopIteration + self.count += 1 + return (chr(self.count - 1),) # this is a 1-tuple + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.execute("create table characters(c)") + +theIter = IterChars() +cur.executemany("insert into characters(c) values (?)", theIter) + +cur.execute("select c from characters") +print cur.fetchall() Modified: python/trunk/Doc/lib/sqlite3/executemany_2.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/executemany_2.py (original) +++ python/trunk/Doc/lib/sqlite3/executemany_2.py Wed May 17 01:24:08 2006 @@ -1,15 +1,15 @@ -import sqlite3 - -def char_generator(): - import string - for c in string.letters[:26]: - yield (c,) - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.execute("create table characters(c)") - -cur.executemany("insert into characters(c) values (?)", char_generator()) - -cur.execute("select c from characters") -print cur.fetchall() +import sqlite3 + +def char_generator(): + import string + for c in string.letters[:26]: + yield (c,) + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.execute("create table characters(c)") + +cur.executemany("insert into characters(c) values (?)", char_generator()) + +cur.execute("select c from characters") +print cur.fetchall() Modified: python/trunk/Doc/lib/sqlite3/executescript.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/executescript.py (original) +++ python/trunk/Doc/lib/sqlite3/executescript.py Wed May 17 01:24:08 2006 @@ -1,24 +1,24 @@ -import sqlite3 - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.executescript(""" - create table person( - firstname, - lastname, - age - ); - - create table book( - title, - author, - published - ); - - insert into book(title, author, published) - values ( - 'Dirk Gently''s Holistic Detective Agency - 'Douglas Adams', - 1987 - ); - """) +import sqlite3 + +con = sqlite3.connect(":memory:") +cur = con.cursor() +cur.executescript(""" + create table person( + firstname, + lastname, + age + ); + + create table book( + title, + author, + published + ); + + insert into book(title, author, published) + values ( + 'Dirk Gently''s Holistic Detective Agency + 'Douglas Adams', + 1987 + ); + """) Modified: python/trunk/Doc/lib/sqlite3/insert_more_people.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/insert_more_people.py (original) +++ python/trunk/Doc/lib/sqlite3/insert_more_people.py Wed May 17 01:24:08 2006 @@ -1,16 +1,16 @@ -import sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -newPeople = ( - ('Lebed' , 53), - ('Zhirinovsky' , 57), - ) - -for person in newPeople: - cur.execute("insert into people (name_last, age) values (?, ?)", person) - -# The changes will not be saved unless the transaction is committed explicitly: -con.commit() +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +newPeople = ( + ('Lebed' , 53), + ('Zhirinovsky' , 57), + ) + +for person in newPeople: + cur.execute("insert into people (name_last, age) values (?, ?)", person) + +# The changes will not be saved unless the transaction is committed explicitly: +con.commit() Modified: python/trunk/Doc/lib/sqlite3/md5func.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/md5func.py (original) +++ python/trunk/Doc/lib/sqlite3/md5func.py Wed May 17 01:24:08 2006 @@ -1,11 +1,11 @@ -import sqlite3 -import md5 - -def md5sum(t): - return md5.md5(t).hexdigest() - -con = sqlite3.connect(":memory:") -con.create_function("md5", 1, md5sum) -cur = con.cursor() -cur.execute("select md5(?)", ("foo",)) -print cur.fetchone()[0] +import sqlite3 +import md5 + +def md5sum(t): + return md5.md5(t).hexdigest() + +con = sqlite3.connect(":memory:") +con.create_function("md5", 1, md5sum) +cur = con.cursor() +cur.execute("select md5(?)", ("foo",)) +print cur.fetchone()[0] Modified: python/trunk/Doc/lib/sqlite3/mysumaggr.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/mysumaggr.py (original) +++ python/trunk/Doc/lib/sqlite3/mysumaggr.py Wed May 17 01:24:08 2006 @@ -1,20 +1,20 @@ -import sqlite3 - -class MySum: - def __init__(self): - self.count = 0 - - def step(self, value): - self.count += value - - def finalize(self): - return self.count - -con = sqlite3.connect(":memory:") -con.create_aggregate("mysum", 1, MySum) -cur = con.cursor() -cur.execute("create table test(i)") -cur.execute("insert into test(i) values (1)") -cur.execute("insert into test(i) values (2)") -cur.execute("select mysum(i) from test") -print cur.fetchone()[0] +import sqlite3 + +class MySum: + def __init__(self): + self.count = 0 + + def step(self, value): + self.count += value + + def finalize(self): + return self.count + +con = sqlite3.connect(":memory:") +con.create_aggregate("mysum", 1, MySum) +cur = con.cursor() +cur.execute("create table test(i)") +cur.execute("insert into test(i) values (1)") +cur.execute("insert into test(i) values (2)") +cur.execute("select mysum(i) from test") +print cur.fetchone()[0] Modified: python/trunk/Doc/lib/sqlite3/parse_colnames.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/parse_colnames.py (original) +++ python/trunk/Doc/lib/sqlite3/parse_colnames.py Wed May 17 01:24:08 2006 @@ -1,8 +1,8 @@ -import sqlite3 -import datetime - -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) -dt = cur.fetchone()[0] -print dt, type(dt) +import sqlite3 +import datetime + +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) +dt = cur.fetchone()[0] +print dt, type(dt) Modified: python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py (original) +++ python/trunk/Doc/lib/sqlite3/pysqlite_datetime.py Wed May 17 01:24:08 2006 @@ -1,20 +1,20 @@ -import sqlite3 -import datetime - -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute("create table test(d date, ts timestamp)") - -today = datetime.date.today() -now = datetime.datetime.now() - -cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) -cur.execute("select d, ts from test") -row = cur.fetchone() -print today, "=>", row[0], type(row[0]) -print now, "=>", row[1], type(row[1]) - -cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') -row = cur.fetchone() -print "current_date", row[0], type(row[0]) -print "current_timestamp", row[1], type(row[1]) +import sqlite3 +import datetime + +con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) +cur = con.cursor() +cur.execute("create table test(d date, ts timestamp)") + +today = datetime.date.today() +now = datetime.datetime.now() + +cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) +cur.execute("select d, ts from test") +row = cur.fetchone() +print today, "=>", row[0], type(row[0]) +print now, "=>", row[1], type(row[1]) + +cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') +row = cur.fetchone() +print "current_date", row[0], type(row[0]) +print "current_timestamp", row[1], type(row[1]) Modified: python/trunk/Doc/lib/sqlite3/row_factory.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/row_factory.py (original) +++ python/trunk/Doc/lib/sqlite3/row_factory.py Wed May 17 01:24:08 2006 @@ -1,13 +1,13 @@ -import sqlite3 - -def dict_factory(cursor, row): - d = {} - for idx, col in enumerate(cursor.description): - d[col[0]] = row[idx] - return d - -con = sqlite3.connect(":memory:") -con.row_factory = dict_factory -cur = con.cursor() -cur.execute("select 1 as a") -print cur.fetchone()["a"] +import sqlite3 + +def dict_factory(cursor, row): + d = {} + for idx, col in enumerate(cursor.description): + d[col[0]] = row[idx] + return d + +con = sqlite3.connect(":memory:") +con.row_factory = dict_factory +cur = con.cursor() +cur.execute("select 1 as a") +print cur.fetchone()["a"] Modified: python/trunk/Doc/lib/sqlite3/shortcut_methods.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/shortcut_methods.py (original) +++ python/trunk/Doc/lib/sqlite3/shortcut_methods.py Wed May 17 01:24:08 2006 @@ -1,21 +1,21 @@ -import sqlite3 - -persons = [ - ("Hugo", "Boss"), - ("Calvin", "Klein") - ] - -con = sqlite3.connect(":memory:") - -# Create the table -con.execute("create table person(firstname, lastname)") - -# Fill the table -con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) - -# Print the table contents -for row in con.execute("select firstname, lastname from person"): - print row - -# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. -print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" +import sqlite3 + +persons = [ + ("Hugo", "Boss"), + ("Calvin", "Klein") + ] + +con = sqlite3.connect(":memory:") + +# Create the table +con.execute("create table person(firstname, lastname)") + +# Fill the table +con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) + +# Print the table contents +for row in con.execute("select firstname, lastname from person"): + print row + +# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. +print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" Modified: python/trunk/Doc/lib/sqlite3/simple_tableprinter.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/simple_tableprinter.py (original) +++ python/trunk/Doc/lib/sqlite3/simple_tableprinter.py Wed May 17 01:24:08 2006 @@ -1,26 +1,26 @@ -import sqlite3 - -FIELD_MAX_WIDTH = 20 -TABLE_NAME = 'people' -SELECT = 'select * from %s order by age, name_last' % TABLE_NAME - -con = sqlite3.connect("mydb") - -cur = con.cursor() -cur.execute(SELECT) - -# Print a header. -for fieldDesc in cur.description: - print fieldDesc[0].ljust(FIELD_MAX_WIDTH) , -print # Finish the header with a newline. -print '-' * 78 - -# For each row, print the value of each field left-justified within -# the maximum possible width of that field. -fieldIndices = range(len(cur.description)) -for row in cur: - for fieldIndex in fieldIndices: - fieldValue = str(row[fieldIndex]) - print fieldValue.ljust(FIELD_MAX_WIDTH) , - - print # Finish the row with a newline. +import sqlite3 + +FIELD_MAX_WIDTH = 20 +TABLE_NAME = 'people' +SELECT = 'select * from %s order by age, name_last' % TABLE_NAME + +con = sqlite3.connect("mydb") + +cur = con.cursor() +cur.execute(SELECT) + +# Print a header. +for fieldDesc in cur.description: + print fieldDesc[0].ljust(FIELD_MAX_WIDTH) , +print # Finish the header with a newline. +print '-' * 78 + +# For each row, print the value of each field left-justified within +# the maximum possible width of that field. +fieldIndices = range(len(cur.description)) +for row in cur: + for fieldIndex in fieldIndices: + fieldValue = str(row[fieldIndex]) + print fieldValue.ljust(FIELD_MAX_WIDTH) , + + print # Finish the row with a newline. Modified: python/trunk/Doc/lib/sqlite3/text_factory.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/text_factory.py (original) +++ python/trunk/Doc/lib/sqlite3/text_factory.py Wed May 17 01:24:08 2006 @@ -1,42 +1,42 @@ -import sqlite3 - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -# Create the table -con.execute("create table person(lastname, firstname)") - -AUSTRIA = u"\xd6sterreich" - -# by default, rows are returned as Unicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert row[0] == AUSTRIA - -# but we can make pysqlite always return bytestrings ... -con.text_factory = str -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == str -# the bytestrings will be encoded in UTF-8, unless you stored garbage in the -# database ... -assert row[0] == AUSTRIA.encode("utf-8") - -# we can also implement a custom text_factory ... -# here we implement one that will ignore Unicode characters that cannot be -# decoded from UTF-8 -con.text_factory = lambda x: unicode(x, "utf-8", "ignore") -cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) -row = cur.fetchone() -assert type(row[0]) == unicode - -# pysqlite offers a builtin optimized text_factory that will return bytestring -# objects, if the data is in ASCII only, and otherwise return unicode objects -con.text_factory = sqlite3.OptimizedUnicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == unicode - -cur.execute("select ?", ("Germany",)) -row = cur.fetchone() -assert type(row[0]) == str +import sqlite3 + +con = sqlite3.connect(":memory:") +cur = con.cursor() + +# Create the table +con.execute("create table person(lastname, firstname)") + +AUSTRIA = u"\xd6sterreich" + +# by default, rows are returned as Unicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert row[0] == AUSTRIA + +# but we can make pysqlite always return bytestrings ... +con.text_factory = str +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == str +# the bytestrings will be encoded in UTF-8, unless you stored garbage in the +# database ... +assert row[0] == AUSTRIA.encode("utf-8") + +# we can also implement a custom text_factory ... +# here we implement one that will ignore Unicode characters that cannot be +# decoded from UTF-8 +con.text_factory = lambda x: unicode(x, "utf-8", "ignore") +cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) +row = cur.fetchone() +assert type(row[0]) == unicode + +# pysqlite offers a builtin optimized text_factory that will return bytestring +# objects, if the data is in ASCII only, and otherwise return unicode objects +con.text_factory = sqlite3.OptimizedUnicode +cur.execute("select ?", (AUSTRIA,)) +row = cur.fetchone() +assert type(row[0]) == unicode + +cur.execute("select ?", ("Germany",)) +row = cur.fetchone() +assert type(row[0]) == str Modified: python/trunk/Lib/test/test_bigmem.py ============================================================================== --- python/trunk/Lib/test/test_bigmem.py (original) +++ python/trunk/Lib/test/test_bigmem.py Wed May 17 01:24:08 2006 @@ -1,964 +1,964 @@ -from test import test_support -from test.test_support import bigmemtest, _1G, _2G - -import unittest -import operator -import string -import sys - -# Bigmem testing houserules: -# -# - Try not to allocate too many large objects. It's okay to rely on -# refcounting semantics, but don't forget that 's = create_largestring()' -# doesn't release the old 's' (if it exists) until well after its new -# value has been created. Use 'del s' before the create_largestring call. -# -# - Do *not* compare large objects using assertEquals or similar. It's a -# lengty operation and the errormessage will be utterly useless due to -# its size. To make sure whether a result has the right contents, better -# to use the strip or count methods, or compare meaningful slices. -# -# - Don't forget to test for large indices, offsets and results and such, -# in addition to large sizes. -# -# - When repeating an object (say, a substring, or a small list) to create -# a large object, make the subobject of a length that is not a power of -# 2. That way, int-wrapping problems are more easily detected. -# -# - While the bigmemtest decorator speaks of 'minsize', all tests will -# actually be called with a much smaller number too, in the normal -# test run (5Kb currently.) This is so the tests themselves get frequent -# testing Consequently, always make all large allocations based on the -# passed-in 'size', and don't rely on the size being very large. Also, -# memuse-per-size should remain sane (less than a few thousand); if your -# test uses more, adjust 'size' upward, instead. - -class StrTest(unittest.TestCase): - @bigmemtest(minsize=_2G, memuse=2) - def test_capitalize(self, size): - SUBSTR = ' abc def ghi' - s = '-' * size + SUBSTR - caps = s.capitalize() - self.assertEquals(caps[-len(SUBSTR):], - SUBSTR.capitalize()) - self.assertEquals(caps.lstrip('-'), SUBSTR) - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_center(self, size): - SUBSTR = ' abc def ghi' - s = SUBSTR.center(size) - self.assertEquals(len(s), size) - lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2 - if len(s) % 2: - lpadsize += 1 - self.assertEquals(s[lpadsize:-rpadsize], SUBSTR) - self.assertEquals(s.strip(), SUBSTR.strip()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_count(self, size): - SUBSTR = ' abc def ghi' - s = '.' * size + SUBSTR - self.assertEquals(s.count('.'), size) - s += '.' - self.assertEquals(s.count('.'), size + 1) - self.assertEquals(s.count(' '), 3) - self.assertEquals(s.count('i'), 1) - self.assertEquals(s.count('j'), 0) - - @bigmemtest(minsize=0, memuse=1) - def test_decode(self, size): - pass - - @bigmemtest(minsize=0, memuse=1) - def test_encode(self, size): - pass - - @bigmemtest(minsize=_2G, memuse=2) - def test_endswith(self, size): - SUBSTR = ' abc def ghi' - s = '-' * size + SUBSTR - self.failUnless(s.endswith(SUBSTR)) - self.failUnless(s.endswith(s)) - s2 = '...' + s - self.failUnless(s2.endswith(s)) - self.failIf(s.endswith('a' + SUBSTR)) - self.failIf(SUBSTR.endswith(s)) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_expandtabs(self, size): - s = '-' * size - tabsize = 8 - self.assertEquals(s.expandtabs(), s) - del s - slen, remainder = divmod(size, tabsize) - s = ' \t' * slen - s = s.expandtabs(tabsize) - self.assertEquals(len(s), size - remainder) - self.assertEquals(len(s.strip(' ')), 0) - - @bigmemtest(minsize=_2G, memuse=2) - def test_find(self, size): - SUBSTR = ' abc def ghi' - sublen = len(SUBSTR) - s = ''.join([SUBSTR, '-' * size, SUBSTR]) - self.assertEquals(s.find(' '), 0) - self.assertEquals(s.find(SUBSTR), 0) - self.assertEquals(s.find(' ', sublen), sublen + size) - self.assertEquals(s.find(SUBSTR, len(SUBSTR)), sublen + size) - self.assertEquals(s.find('i'), SUBSTR.find('i')) - self.assertEquals(s.find('i', sublen), - sublen + size + SUBSTR.find('i')) - self.assertEquals(s.find('i', size), - sublen + size + SUBSTR.find('i')) - self.assertEquals(s.find('j'), -1) - - @bigmemtest(minsize=_2G, memuse=2) - def test_index(self, size): - SUBSTR = ' abc def ghi' - sublen = len(SUBSTR) - s = ''.join([SUBSTR, '-' * size, SUBSTR]) - self.assertEquals(s.index(' '), 0) - self.assertEquals(s.index(SUBSTR), 0) - self.assertEquals(s.index(' ', sublen), sublen + size) - self.assertEquals(s.index(SUBSTR, sublen), sublen + size) - self.assertEquals(s.index('i'), SUBSTR.index('i')) - self.assertEquals(s.index('i', sublen), - sublen + size + SUBSTR.index('i')) - self.assertEquals(s.index('i', size), - sublen + size + SUBSTR.index('i')) - self.assertRaises(ValueError, s.index, 'j') - - @bigmemtest(minsize=_2G, memuse=2) - def test_isalnum(self, size): - SUBSTR = '123456' - s = 'a' * size + SUBSTR - self.failUnless(s.isalnum()) - s += '.' - self.failIf(s.isalnum()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_isalpha(self, size): - SUBSTR = 'zzzzzzz' - s = 'a' * size + SUBSTR - self.failUnless(s.isalpha()) - s += '.' - self.failIf(s.isalpha()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_isdigit(self, size): - SUBSTR = '123456' - s = '9' * size + SUBSTR - self.failUnless(s.isdigit()) - s += 'z' - self.failIf(s.isdigit()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_islower(self, size): - chars = ''.join([ chr(c) for c in range(255) if not chr(c).isupper() ]) - repeats = size // len(chars) + 2 - s = chars * repeats - self.failUnless(s.islower()) - s += 'A' - self.failIf(s.islower()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_isspace(self, size): - whitespace = ' \f\n\r\t\v' - repeats = size // len(whitespace) + 2 - s = whitespace * repeats - self.failUnless(s.isspace()) - s += 'j' - self.failIf(s.isspace()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_istitle(self, size): - SUBSTR = '123456' - s = ''.join(['A', 'a' * size, SUBSTR]) - self.failUnless(s.istitle()) - s += 'A' - self.failUnless(s.istitle()) - s += 'aA' - self.failIf(s.istitle()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_isupper(self, size): - chars = ''.join([ chr(c) for c in range(255) if not chr(c).islower() ]) - repeats = size // len(chars) + 2 - s = chars * repeats - self.failUnless(s.isupper()) - s += 'a' - self.failIf(s.isupper()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_join(self, size): - s = 'A' * size - x = s.join(['aaaaa', 'bbbbb']) - self.assertEquals(x.count('a'), 5) - self.assertEquals(x.count('b'), 5) - self.failUnless(x.startswith('aaaaaA')) - self.failUnless(x.endswith('Abbbbb')) - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_ljust(self, size): - SUBSTR = ' abc def ghi' - s = SUBSTR.ljust(size) - self.failUnless(s.startswith(SUBSTR + ' ')) - self.assertEquals(len(s), size) - self.assertEquals(s.strip(), SUBSTR.strip()) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_lower(self, size): - s = 'A' * size - s = s.lower() - self.assertEquals(len(s), size) - self.assertEquals(s.count('a'), size) - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_lstrip(self, size): - SUBSTR = 'abc def ghi' - s = SUBSTR.rjust(size) - self.assertEquals(len(s), size) - self.assertEquals(s.lstrip(), SUBSTR.lstrip()) - del s - s = SUBSTR.ljust(size) - self.assertEquals(len(s), size) - stripped = s.lstrip() - self.failUnless(stripped is s) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_replace(self, size): - replacement = 'a' - s = ' ' * size - s = s.replace(' ', replacement) - self.assertEquals(len(s), size) - self.assertEquals(s.count(replacement), size) - s = s.replace(replacement, ' ', size - 4) - self.assertEquals(len(s), size) - self.assertEquals(s.count(replacement), 4) - self.assertEquals(s[-10:], ' aaaa') - - @bigmemtest(minsize=_2G, memuse=2) - def test_rfind(self, size): - SUBSTR = ' abc def ghi' - sublen = len(SUBSTR) - s = ''.join([SUBSTR, '-' * size, SUBSTR]) - self.assertEquals(s.rfind(' '), sublen + size + SUBSTR.rfind(' ')) - self.assertEquals(s.rfind(SUBSTR), sublen + size) - self.assertEquals(s.rfind(' ', 0, size), SUBSTR.rfind(' ')) - self.assertEquals(s.rfind(SUBSTR, 0, sublen + size), 0) - self.assertEquals(s.rfind('i'), sublen + size + SUBSTR.rfind('i')) - self.assertEquals(s.rfind('i', 0, sublen), SUBSTR.rfind('i')) - self.assertEquals(s.rfind('i', 0, sublen + size), - SUBSTR.rfind('i')) - self.assertEquals(s.rfind('j'), -1) - - @bigmemtest(minsize=_2G, memuse=2) - def test_rindex(self, size): - SUBSTR = ' abc def ghi' - sublen = len(SUBSTR) - s = ''.join([SUBSTR, '-' * size, SUBSTR]) - self.assertEquals(s.rindex(' '), - sublen + size + SUBSTR.rindex(' ')) - self.assertEquals(s.rindex(SUBSTR), sublen + size) - self.assertEquals(s.rindex(' ', 0, sublen + size - 1), - SUBSTR.rindex(' ')) - self.assertEquals(s.rindex(SUBSTR, 0, sublen + size), 0) - self.assertEquals(s.rindex('i'), - sublen + size + SUBSTR.rindex('i')) - self.assertEquals(s.rindex('i', 0, sublen), SUBSTR.rindex('i')) - self.assertEquals(s.rindex('i', 0, sublen + size), - SUBSTR.rindex('i')) - self.assertRaises(ValueError, s.rindex, 'j') - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_rjust(self, size): - SUBSTR = ' abc def ghi' - s = SUBSTR.ljust(size) - self.failUnless(s.startswith(SUBSTR + ' ')) - self.assertEquals(len(s), size) - self.assertEquals(s.strip(), SUBSTR.strip()) - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_rstrip(self, size): - SUBSTR = ' abc def ghi' - s = SUBSTR.ljust(size) - self.assertEquals(len(s), size) - self.assertEquals(s.rstrip(), SUBSTR.rstrip()) - del s - s = SUBSTR.rjust(size) - self.assertEquals(len(s), size) - stripped = s.rstrip() - self.failUnless(stripped is s) - - # The test takes about size bytes to build a string, and then about - # sqrt(size) substrings of sqrt(size) in size and a list to - # hold sqrt(size) items. It's close but just over 2x size. - @bigmemtest(minsize=_2G, memuse=2.1) - def test_split_small(self, size): - # Crudely calculate an estimate so that the result of s.split won't - # take up an inordinate amount of memory - chunksize = int(size ** 0.5 + 2) - SUBSTR = 'a' + ' ' * chunksize - s = SUBSTR * chunksize - l = s.split() - self.assertEquals(len(l), chunksize) - self.assertEquals(set(l), set(['a'])) - del l - l = s.split('a') - self.assertEquals(len(l), chunksize + 1) - self.assertEquals(set(l), set(['', ' ' * chunksize])) - - # Allocates a string of twice size (and briefly two) and a list of - # size. Because of internal affairs, the s.split() call produces a - # list of size times the same one-character string, so we only - # suffer for the list size. (Otherwise, it'd cost another 48 times - # size in bytes!) Nevertheless, a list of size takes - # 8*size bytes. - @bigmemtest(minsize=_2G + 5, memuse=10) - def test_split_large(self, size): - s = ' a' * size + ' ' - l = s.split() - self.assertEquals(len(l), size) - self.assertEquals(set(l), set(['a'])) - del l - l = s.split('a') - self.assertEquals(len(l), size + 1) - self.assertEquals(set(l), set([' '])) - - @bigmemtest(minsize=_2G, memuse=2.1) - def test_splitlines(self, size): - # Crudely calculate an estimate so that the result of s.split won't - # take up an inordinate amount of memory - chunksize = int(size ** 0.5 + 2) // 2 - SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n' - s = SUBSTR * chunksize - l = s.splitlines() - self.assertEquals(len(l), chunksize * 2) - self.assertEquals(set(l), set([' ' * chunksize])) - - @bigmemtest(minsize=_2G, memuse=2) - def test_startswith(self, size): - SUBSTR = ' abc def ghi' - s = '-' * size + SUBSTR - self.failUnless(s.startswith(s)) - self.failUnless(s.startswith('-' * size)) - self.failIf(s.startswith(SUBSTR)) - - @bigmemtest(minsize=_2G, memuse=1) - def test_strip(self, size): - SUBSTR = ' abc def ghi ' - s = SUBSTR.rjust(size) - self.assertEquals(len(s), size) - self.assertEquals(s.strip(), SUBSTR.strip()) - del s - s = SUBSTR.ljust(size) - self.assertEquals(len(s), size) - self.assertEquals(s.strip(), SUBSTR.strip()) - - @bigmemtest(minsize=_2G, memuse=2) - def test_swapcase(self, size): - SUBSTR = "aBcDeFG12.'\xa9\x00" - sublen = len(SUBSTR) - repeats = size // sublen + 2 - s = SUBSTR * repeats - s = s.swapcase() - self.assertEquals(len(s), sublen * repeats) - self.assertEquals(s[:sublen * 3], SUBSTR.swapcase() * 3) - self.assertEquals(s[-sublen * 3:], SUBSTR.swapcase() * 3) - - @bigmemtest(minsize=_2G, memuse=2) - def test_title(self, size): - SUBSTR = 'SpaaHAaaAaham' - s = SUBSTR * (size // len(SUBSTR) + 2) - s = s.title() - self.failUnless(s.startswith((SUBSTR * 3).title())) - self.failUnless(s.endswith(SUBSTR.lower() * 3)) - - @bigmemtest(minsize=_2G, memuse=2) - def test_translate(self, size): - trans = string.maketrans('.aZ', '-!$') - SUBSTR = 'aZz.z.Aaz.' - sublen = len(SUBSTR) - repeats = size // sublen + 2 - s = SUBSTR * repeats - s = s.translate(trans) - self.assertEquals(len(s), repeats * sublen) - self.assertEquals(s[:sublen], SUBSTR.translate(trans)) - self.assertEquals(s[-sublen:], SUBSTR.translate(trans)) - self.assertEquals(s.count('.'), 0) - self.assertEquals(s.count('!'), repeats * 2) - self.assertEquals(s.count('z'), repeats * 3) - - @bigmemtest(minsize=_2G + 5, memuse=2) - def test_upper(self, size): - s = 'a' * size - s = s.upper() - self.assertEquals(len(s), size) - self.assertEquals(s.count('A'), size) - - @bigmemtest(minsize=_2G + 20, memuse=1) - def test_zfill(self, size): - SUBSTR = '-568324723598234' - s = SUBSTR.zfill(size) - self.failUnless(s.endswith('0' + SUBSTR[1:])) - self.failUnless(s.startswith('-0')) - self.assertEquals(len(s), size) - self.assertEquals(s.count('0'), size - len(SUBSTR)) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_format(self, size): - s = '-' * size - sf = '%s' % (s,) - self.failUnless(s == sf) - del sf - sf = '..%s..' % (s,) - self.assertEquals(len(sf), len(s) + 4) - self.failUnless(sf.startswith('..-')) - self.failUnless(sf.endswith('-..')) - del s, sf - - size //= 2 - edge = '-' * size - s = ''.join([edge, '%s', edge]) - del edge - s = s % '...' - self.assertEquals(len(s), size * 2 + 3) - self.assertEquals(s.count('.'), 3) - self.assertEquals(s.count('-'), size * 2) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_repr_small(self, size): - s = '-' * size - s = repr(s) - self.assertEquals(len(s), size + 2) - self.assertEquals(s[0], "'") - self.assertEquals(s[-1], "'") - self.assertEquals(s.count('-'), size) - del s - # repr() will create a string four times as large as this 'binary - # string', but we don't want to allocate much more than twice - # size in total. (We do extra testing in test_repr_large()) - size = size // 5 * 2 - s = '\x00' * size - s = repr(s) - self.assertEquals(len(s), size * 4 + 2) - self.assertEquals(s[0], "'") - self.assertEquals(s[-1], "'") - self.assertEquals(s.count('\\'), size) - self.assertEquals(s.count('0'), size * 2) - - @bigmemtest(minsize=_2G + 10, memuse=5) - def test_repr_large(self, size): - s = '\x00' * size - s = repr(s) - self.assertEquals(len(s), size * 4 + 2) - self.assertEquals(s[0], "'") - self.assertEquals(s[-1], "'") - self.assertEquals(s.count('\\'), size) - self.assertEquals(s.count('0'), size * 2) - - # This test is meaningful even with size < 2G, as long as the - # doubled string is > 2G (but it tests more if both are > 2G :) - @bigmemtest(minsize=_1G + 2, memuse=3) - def test_concat(self, size): - s = '.' * size - self.assertEquals(len(s), size) - s = s + s - self.assertEquals(len(s), size * 2) - self.assertEquals(s.count('.'), size * 2) - - # This test is meaningful even with size < 2G, as long as the - # repeated string is > 2G (but it tests more if both are > 2G :) - @bigmemtest(minsize=_1G + 2, memuse=3) - def test_repeat(self, size): - s = '.' * size - self.assertEquals(len(s), size) - s = s * 2 - self.assertEquals(len(s), size * 2) - self.assertEquals(s.count('.'), size * 2) - - @bigmemtest(minsize=_2G + 20, memuse=1) - def test_slice_and_getitem(self, size): - SUBSTR = '0123456789' - sublen = len(SUBSTR) - s = SUBSTR * (size // sublen) - stepsize = len(s) // 100 - stepsize = stepsize - (stepsize % sublen) - for i in range(0, len(s) - stepsize, stepsize): - self.assertEquals(s[i], SUBSTR[0]) - self.assertEquals(s[i:i + sublen], SUBSTR) - self.assertEquals(s[i:i + sublen:2], SUBSTR[::2]) - if i > 0: - self.assertEquals(s[i + sublen - 1:i - 1:-3], - SUBSTR[sublen::-3]) - # Make sure we do some slicing and indexing near the end of the - # string, too. - self.assertEquals(s[len(s) - 1], SUBSTR[-1]) - self.assertEquals(s[-1], SUBSTR[-1]) - self.assertEquals(s[len(s) - 10], SUBSTR[0]) - self.assertEquals(s[-sublen], SUBSTR[0]) - self.assertEquals(s[len(s):], '') - self.assertEquals(s[len(s) - 1:], SUBSTR[-1]) - self.assertEquals(s[-1:], SUBSTR[-1]) - self.assertEquals(s[len(s) - sublen:], SUBSTR) - self.assertEquals(s[-sublen:], SUBSTR) - self.assertEquals(len(s[:]), len(s)) - self.assertEquals(len(s[:len(s) - 5]), len(s) - 5) - self.assertEquals(len(s[5:-5]), len(s) - 10) - - self.assertRaises(IndexError, operator.getitem, s, len(s)) - self.assertRaises(IndexError, operator.getitem, s, len(s) + 1) - self.assertRaises(IndexError, operator.getitem, s, len(s) + 1<<31) - - @bigmemtest(minsize=_2G, memuse=2) - def test_contains(self, size): - SUBSTR = '0123456789' - edge = '-' * (size // 2) - s = ''.join([edge, SUBSTR, edge]) - del edge - self.failUnless(SUBSTR in s) - self.failIf(SUBSTR * 2 in s) - self.failUnless('-' in s) - self.failIf('a' in s) - s += 'a' - self.failUnless('a' in s) - - @bigmemtest(minsize=_2G + 10, memuse=2) - def test_compare(self, size): - s1 = '-' * size - s2 = '-' * size - self.failUnless(s1 == s2) - del s2 - s2 = s1 + 'a' - self.failIf(s1 == s2) - del s2 - s2 = '.' * size - self.failIf(s1 == s2) - - @bigmemtest(minsize=_2G + 10, memuse=1) - def test_hash(self, size): - # Not sure if we can do any meaningful tests here... Even if we - # start relying on the exact algorithm used, the result will be - # different depending on the size of the C 'long int'. Even this - # test is dodgy (there's no *guarantee* that the two things should - # have a different hash, even if they, in the current - # implementation, almost always do.) - s = '\x00' * size - h1 = hash(s) - del s - s = '\x00' * (size + 1) - self.failIf(h1 == hash(s)) - -class TupleTest(unittest.TestCase): - - # Tuples have a small, fixed-sized head and an array of pointers to - # data. Since we're testing 64-bit addressing, we can assume that the - # pointers are 8 bytes, and that thus that the tuples take up 8 bytes - # per size. - - # As a side-effect of testing long tuples, these tests happen to test - # having more than 2<<31 references to any given object. Hence the - # use of different types of objects as contents in different tests. - - @bigmemtest(minsize=_2G + 2, memuse=16) - def test_compare(self, size): - t1 = (u'',) * size - t2 = (u'',) * size - self.failUnless(t1 == t2) - del t2 - t2 = (u'',) * (size + 1) - self.failIf(t1 == t2) - del t2 - t2 = (1,) * size - self.failIf(t1 == t2) - - # Test concatenating into a single tuple of more than 2G in length, - # and concatenating a tuple of more than 2G in length separately, so - # the smaller test still gets run even if there isn't memory for the - # larger test (but we still let the tester know the larger test is - # skipped, in verbose mode.) - def basic_concat_test(self, size): - t = ((),) * size - self.assertEquals(len(t), size) - t = t + t - self.assertEquals(len(t), size * 2) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=24) - def test_concat_small(self, size): - return self.basic_concat_test(size) - - @bigmemtest(minsize=_2G + 2, memuse=24) - def test_concat_large(self, size): - return self.basic_concat_test(size) - - @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5) - def test_contains(self, size): - t = (1, 2, 3, 4, 5) * size - self.assertEquals(len(t), size * 5) - self.failUnless(5 in t) - self.failIf((1, 2, 3, 4, 5) in t) - self.failIf(0 in t) - - @bigmemtest(minsize=_2G + 10, memuse=8) - def test_hash(self, size): - t1 = (0,) * size - h1 = hash(t1) - del t1 - t2 = (0,) * (size + 1) - self.failIf(h1 == hash(t2)) - - @bigmemtest(minsize=_2G + 10, memuse=8) - def test_index_and_slice(self, size): - t = (None,) * size - self.assertEquals(len(t), size) - self.assertEquals(t[-1], None) - self.assertEquals(t[5], None) - self.assertEquals(t[size - 1], None) - self.assertRaises(IndexError, operator.getitem, t, size) - self.assertEquals(t[:5], (None,) * 5) - self.assertEquals(t[-5:], (None,) * 5) - self.assertEquals(t[20:25], (None,) * 5) - self.assertEquals(t[-25:-20], (None,) * 5) - self.assertEquals(t[size - 5:], (None,) * 5) - self.assertEquals(t[size - 5:size], (None,) * 5) - self.assertEquals(t[size - 6:size - 2], (None,) * 4) - self.assertEquals(t[size:size], ()) - self.assertEquals(t[size:size+5], ()) - - # Like test_concat, split in two. - def basic_test_repeat(self, size): - t = ('',) * size - self.assertEquals(len(t), size) - t = t * 2 - self.assertEquals(len(t), size * 2) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=24) - def test_repeat_small(self, size): - return self.basic_test_repeat(size) - - @bigmemtest(minsize=_2G + 2, memuse=24) - def test_repeat_large(self, size): - return self.basic_test_repeat(size) - - # Like test_concat, split in two. - def basic_test_repr(self, size): - t = (0,) * size - s = repr(t) - # The repr of a tuple of 0's is exactly three times the tuple length. - self.assertEquals(len(s), size * 3) - self.assertEquals(s[:5], '(0, 0') - self.assertEquals(s[-5:], '0, 0)') - self.assertEquals(s.count('0'), size) - - @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3) - def test_repr_small(self, size): - return self.basic_test_repr(size) - - @bigmemtest(minsize=_2G + 2, memuse=8 + 3) - def test_repr_large(self, size): - return self.basic_test_repr(size) - -class ListTest(unittest.TestCase): - - # Like tuples, lists have a small, fixed-sized head and an array of - # pointers to data, so 8 bytes per size. Also like tuples, we make the - # lists hold references to various objects to test their refcount - # limits. - - @bigmemtest(minsize=_2G + 2, memuse=16) - def test_compare(self, size): - l1 = [u''] * size - l2 = [u''] * size - self.failUnless(l1 == l2) - del l2 - l2 = [u''] * (size + 1) - self.failIf(l1 == l2) - del l2 - l2 = [2] * size - self.failIf(l1 == l2) - - # Test concatenating into a single list of more than 2G in length, - # and concatenating a list of more than 2G in length separately, so - # the smaller test still gets run even if there isn't memory for the - # larger test (but we still let the tester know the larger test is - # skipped, in verbose mode.) - def basic_test_concat(self, size): - l = [[]] * size - self.assertEquals(len(l), size) - l = l + l - self.assertEquals(len(l), size * 2) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=24) - def test_concat_small(self, size): - return self.basic_test_concat(size) - - @bigmemtest(minsize=_2G + 2, memuse=24) - def test_concat_large(self, size): - return self.basic_test_concat(size) - - def basic_test_inplace_concat(self, size): - l = [sys.stdout] * size - l += l - self.assertEquals(len(l), size * 2) - self.failUnless(l[0] is l[-1]) - self.failUnless(l[size - 1] is l[size + 1]) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=24) - def test_inplace_concat_small(self, size): - return self.basic_test_inplace_concat(size) - - @bigmemtest(minsize=_2G + 2, memuse=24) - def test_inplace_concat_large(self, size): - return self.basic_test_inplace_concat(size) - - @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5) - def test_contains(self, size): - l = [1, 2, 3, 4, 5] * size - self.assertEquals(len(l), size * 5) - self.failUnless(5 in l) - self.failIf([1, 2, 3, 4, 5] in l) - self.failIf(0 in l) - - @bigmemtest(minsize=_2G + 10, memuse=8) - def test_hash(self, size): - l = [0] * size - self.failUnlessRaises(TypeError, hash, l) - - @bigmemtest(minsize=_2G + 10, memuse=8) - def test_index_and_slice(self, size): - l = [None] * size - self.assertEquals(len(l), size) - self.assertEquals(l[-1], None) - self.assertEquals(l[5], None) - self.assertEquals(l[size - 1], None) - self.assertRaises(IndexError, operator.getitem, l, size) - self.assertEquals(l[:5], [None] * 5) - self.assertEquals(l[-5:], [None] * 5) - self.assertEquals(l[20:25], [None] * 5) - self.assertEquals(l[-25:-20], [None] * 5) - self.assertEquals(l[size - 5:], [None] * 5) - self.assertEquals(l[size - 5:size], [None] * 5) - self.assertEquals(l[size - 6:size - 2], [None] * 4) - self.assertEquals(l[size:size], []) - self.assertEquals(l[size:size+5], []) - - l[size - 2] = 5 - self.assertEquals(len(l), size) - self.assertEquals(l[-3:], [None, 5, None]) - self.assertEquals(l.count(5), 1) - self.assertRaises(IndexError, operator.setitem, l, size, 6) - self.assertEquals(len(l), size) - - l[size - 7:] = [1, 2, 3, 4, 5] - size -= 2 - self.assertEquals(len(l), size) - self.assertEquals(l[-7:], [None, None, 1, 2, 3, 4, 5]) - - l[:7] = [1, 2, 3, 4, 5] - size -= 2 - self.assertEquals(len(l), size) - self.assertEquals(l[:7], [1, 2, 3, 4, 5, None, None]) - - del l[size - 1] - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(l[-1], 4) - - del l[-2:] - size -= 2 - self.assertEquals(len(l), size) - self.assertEquals(l[-1], 2) - - del l[0] - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(l[0], 2) - - del l[:2] - size -= 2 - self.assertEquals(len(l), size) - self.assertEquals(l[0], 4) - - # Like test_concat, split in two. - def basic_test_repeat(self, size): - l = [] * size - self.failIf(l) - l = [''] * size - self.assertEquals(len(l), size) - l = l * 2 - self.assertEquals(len(l), size * 2) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=24) - def test_repeat_small(self, size): - return self.basic_test_repeat(size) - - @bigmemtest(minsize=_2G + 2, memuse=24) - def test_repeat_large(self, size): - return self.basic_test_repeat(size) - - def basic_test_inplace_repeat(self, size): - l = [''] - l *= size - self.assertEquals(len(l), size) - self.failUnless(l[0] is l[-1]) - del l - - l = [''] * size - l *= 2 - self.assertEquals(len(l), size * 2) - self.failUnless(l[size - 1] is l[-1]) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=16) - def test_inplace_repeat_small(self, size): - return self.basic_test_inplace_repeat(size) - - @bigmemtest(minsize=_2G + 2, memuse=16) - def test_inplace_repeat_large(self, size): - return self.basic_test_inplace_repeat(size) - - def basic_test_repr(self, size): - l = [0] * size - s = repr(l) - # The repr of a list of 0's is exactly three times the list length. - self.assertEquals(len(s), size * 3) - self.assertEquals(s[:5], '[0, 0') - self.assertEquals(s[-5:], '0, 0]') - self.assertEquals(s.count('0'), size) - - @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3) - def test_repr_small(self, size): - return self.basic_test_repr(size) - - @bigmemtest(minsize=_2G + 2, memuse=8 + 3) - def test_repr_large(self, size): - return self.basic_test_repr(size) - - # list overallocates ~1/8th of the total size (on first expansion) so - # the single list.append call puts memuse at 9 bytes per size. - @bigmemtest(minsize=_2G, memuse=9) - def test_append(self, size): - l = [object()] * size - l.append(object()) - self.assertEquals(len(l), size+1) - self.failUnless(l[-3] is l[-2]) - self.failIf(l[-2] is l[-1]) - - @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) - def test_count(self, size): - l = [1, 2, 3, 4, 5] * size - self.assertEquals(l.count(1), size) - self.assertEquals(l.count("1"), 0) - - def basic_test_extend(self, size): - l = [file] * size - l.extend(l) - self.assertEquals(len(l), size * 2) - self.failUnless(l[0] is l[-1]) - self.failUnless(l[size - 1] is l[size + 1]) - - @bigmemtest(minsize=_2G // 2 + 2, memuse=16) - def test_extend_small(self, size): - return self.basic_test_extend(size) - - @bigmemtest(minsize=_2G + 2, memuse=16) - def test_extend_large(self, size): - return self.basic_test_extend(size) - - @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) - def test_index(self, size): - l = [1L, 2L, 3L, 4L, 5L] * size - size *= 5 - self.assertEquals(l.index(1), 0) - self.assertEquals(l.index(5, size - 5), size - 1) - self.assertEquals(l.index(5, size - 5, size), size - 1) - self.assertRaises(ValueError, l.index, 1, size - 4, size) - self.assertRaises(ValueError, l.index, 6L) - - # This tests suffers from overallocation, just like test_append. - @bigmemtest(minsize=_2G + 10, memuse=9) - def test_insert(self, size): - l = [1.0] * size - l.insert(size - 1, "A") - size += 1 - self.assertEquals(len(l), size) - self.assertEquals(l[-3:], [1.0, "A", 1.0]) - - l.insert(size + 1, "B") - size += 1 - self.assertEquals(len(l), size) - self.assertEquals(l[-3:], ["A", 1.0, "B"]) - - l.insert(1, "C") - size += 1 - self.assertEquals(len(l), size) - self.assertEquals(l[:3], [1.0, "C", 1.0]) - self.assertEquals(l[size - 3:], ["A", 1.0, "B"]) - - @bigmemtest(minsize=_2G // 5 + 4, memuse=8 * 5) - def test_pop(self, size): - l = [u"a", u"b", u"c", u"d", u"e"] * size - size *= 5 - self.assertEquals(len(l), size) - - item = l.pop() - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(item, u"e") - self.assertEquals(l[-2:], [u"c", u"d"]) - - item = l.pop(0) - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(item, u"a") - self.assertEquals(l[:2], [u"b", u"c"]) - - item = l.pop(size - 2) - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(item, u"c") - self.assertEquals(l[-2:], [u"b", u"d"]) - - @bigmemtest(minsize=_2G + 10, memuse=8) - def test_remove(self, size): - l = [10] * size - self.assertEquals(len(l), size) - - l.remove(10) - size -= 1 - self.assertEquals(len(l), size) - - # Because of the earlier l.remove(), this append doesn't trigger - # a resize. - l.append(5) - size += 1 - self.assertEquals(len(l), size) - self.assertEquals(l[-2:], [10, 5]) - l.remove(5) - size -= 1 - self.assertEquals(len(l), size) - self.assertEquals(l[-2:], [10, 10]) - - @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) - def test_reverse(self, size): - l = [1, 2, 3, 4, 5] * size - l.reverse() - self.assertEquals(len(l), size * 5) - self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) - self.assertEquals(l[:5], [5, 4, 3, 2, 1]) - - @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) - def test_sort(self, size): - l = [1, 2, 3, 4, 5] * size - l.sort() - self.assertEquals(len(l), size * 5) - self.assertEquals(l.count(1), size) - self.assertEquals(l[:10], [1] * 10) - self.assertEquals(l[-10:], [5] * 10) - -def test_main(): - test_support.run_unittest(StrTest, TupleTest, ListTest) - -if __name__ == '__main__': - if len(sys.argv) > 1: - test_support.set_memlimit(sys.argv[1]) - test_main() +from test import test_support +from test.test_support import bigmemtest, _1G, _2G + +import unittest +import operator +import string +import sys + +# Bigmem testing houserules: +# +# - Try not to allocate too many large objects. It's okay to rely on +# refcounting semantics, but don't forget that 's = create_largestring()' +# doesn't release the old 's' (if it exists) until well after its new +# value has been created. Use 'del s' before the create_largestring call. +# +# - Do *not* compare large objects using assertEquals or similar. It's a +# lengty operation and the errormessage will be utterly useless due to +# its size. To make sure whether a result has the right contents, better +# to use the strip or count methods, or compare meaningful slices. +# +# - Don't forget to test for large indices, offsets and results and such, +# in addition to large sizes. +# +# - When repeating an object (say, a substring, or a small list) to create +# a large object, make the subobject of a length that is not a power of +# 2. That way, int-wrapping problems are more easily detected. +# +# - While the bigmemtest decorator speaks of 'minsize', all tests will +# actually be called with a much smaller number too, in the normal +# test run (5Kb currently.) This is so the tests themselves get frequent +# testing Consequently, always make all large allocations based on the +# passed-in 'size', and don't rely on the size being very large. Also, +# memuse-per-size should remain sane (less than a few thousand); if your +# test uses more, adjust 'size' upward, instead. + +class StrTest(unittest.TestCase): + @bigmemtest(minsize=_2G, memuse=2) + def test_capitalize(self, size): + SUBSTR = ' abc def ghi' + s = '-' * size + SUBSTR + caps = s.capitalize() + self.assertEquals(caps[-len(SUBSTR):], + SUBSTR.capitalize()) + self.assertEquals(caps.lstrip('-'), SUBSTR) + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_center(self, size): + SUBSTR = ' abc def ghi' + s = SUBSTR.center(size) + self.assertEquals(len(s), size) + lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2 + if len(s) % 2: + lpadsize += 1 + self.assertEquals(s[lpadsize:-rpadsize], SUBSTR) + self.assertEquals(s.strip(), SUBSTR.strip()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_count(self, size): + SUBSTR = ' abc def ghi' + s = '.' * size + SUBSTR + self.assertEquals(s.count('.'), size) + s += '.' + self.assertEquals(s.count('.'), size + 1) + self.assertEquals(s.count(' '), 3) + self.assertEquals(s.count('i'), 1) + self.assertEquals(s.count('j'), 0) + + @bigmemtest(minsize=0, memuse=1) + def test_decode(self, size): + pass + + @bigmemtest(minsize=0, memuse=1) + def test_encode(self, size): + pass + + @bigmemtest(minsize=_2G, memuse=2) + def test_endswith(self, size): + SUBSTR = ' abc def ghi' + s = '-' * size + SUBSTR + self.failUnless(s.endswith(SUBSTR)) + self.failUnless(s.endswith(s)) + s2 = '...' + s + self.failUnless(s2.endswith(s)) + self.failIf(s.endswith('a' + SUBSTR)) + self.failIf(SUBSTR.endswith(s)) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_expandtabs(self, size): + s = '-' * size + tabsize = 8 + self.assertEquals(s.expandtabs(), s) + del s + slen, remainder = divmod(size, tabsize) + s = ' \t' * slen + s = s.expandtabs(tabsize) + self.assertEquals(len(s), size - remainder) + self.assertEquals(len(s.strip(' ')), 0) + + @bigmemtest(minsize=_2G, memuse=2) + def test_find(self, size): + SUBSTR = ' abc def ghi' + sublen = len(SUBSTR) + s = ''.join([SUBSTR, '-' * size, SUBSTR]) + self.assertEquals(s.find(' '), 0) + self.assertEquals(s.find(SUBSTR), 0) + self.assertEquals(s.find(' ', sublen), sublen + size) + self.assertEquals(s.find(SUBSTR, len(SUBSTR)), sublen + size) + self.assertEquals(s.find('i'), SUBSTR.find('i')) + self.assertEquals(s.find('i', sublen), + sublen + size + SUBSTR.find('i')) + self.assertEquals(s.find('i', size), + sublen + size + SUBSTR.find('i')) + self.assertEquals(s.find('j'), -1) + + @bigmemtest(minsize=_2G, memuse=2) + def test_index(self, size): + SUBSTR = ' abc def ghi' + sublen = len(SUBSTR) + s = ''.join([SUBSTR, '-' * size, SUBSTR]) + self.assertEquals(s.index(' '), 0) + self.assertEquals(s.index(SUBSTR), 0) + self.assertEquals(s.index(' ', sublen), sublen + size) + self.assertEquals(s.index(SUBSTR, sublen), sublen + size) + self.assertEquals(s.index('i'), SUBSTR.index('i')) + self.assertEquals(s.index('i', sublen), + sublen + size + SUBSTR.index('i')) + self.assertEquals(s.index('i', size), + sublen + size + SUBSTR.index('i')) + self.assertRaises(ValueError, s.index, 'j') + + @bigmemtest(minsize=_2G, memuse=2) + def test_isalnum(self, size): + SUBSTR = '123456' + s = 'a' * size + SUBSTR + self.failUnless(s.isalnum()) + s += '.' + self.failIf(s.isalnum()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_isalpha(self, size): + SUBSTR = 'zzzzzzz' + s = 'a' * size + SUBSTR + self.failUnless(s.isalpha()) + s += '.' + self.failIf(s.isalpha()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_isdigit(self, size): + SUBSTR = '123456' + s = '9' * size + SUBSTR + self.failUnless(s.isdigit()) + s += 'z' + self.failIf(s.isdigit()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_islower(self, size): + chars = ''.join([ chr(c) for c in range(255) if not chr(c).isupper() ]) + repeats = size // len(chars) + 2 + s = chars * repeats + self.failUnless(s.islower()) + s += 'A' + self.failIf(s.islower()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_isspace(self, size): + whitespace = ' \f\n\r\t\v' + repeats = size // len(whitespace) + 2 + s = whitespace * repeats + self.failUnless(s.isspace()) + s += 'j' + self.failIf(s.isspace()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_istitle(self, size): + SUBSTR = '123456' + s = ''.join(['A', 'a' * size, SUBSTR]) + self.failUnless(s.istitle()) + s += 'A' + self.failUnless(s.istitle()) + s += 'aA' + self.failIf(s.istitle()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_isupper(self, size): + chars = ''.join([ chr(c) for c in range(255) if not chr(c).islower() ]) + repeats = size // len(chars) + 2 + s = chars * repeats + self.failUnless(s.isupper()) + s += 'a' + self.failIf(s.isupper()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_join(self, size): + s = 'A' * size + x = s.join(['aaaaa', 'bbbbb']) + self.assertEquals(x.count('a'), 5) + self.assertEquals(x.count('b'), 5) + self.failUnless(x.startswith('aaaaaA')) + self.failUnless(x.endswith('Abbbbb')) + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_ljust(self, size): + SUBSTR = ' abc def ghi' + s = SUBSTR.ljust(size) + self.failUnless(s.startswith(SUBSTR + ' ')) + self.assertEquals(len(s), size) + self.assertEquals(s.strip(), SUBSTR.strip()) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_lower(self, size): + s = 'A' * size + s = s.lower() + self.assertEquals(len(s), size) + self.assertEquals(s.count('a'), size) + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_lstrip(self, size): + SUBSTR = 'abc def ghi' + s = SUBSTR.rjust(size) + self.assertEquals(len(s), size) + self.assertEquals(s.lstrip(), SUBSTR.lstrip()) + del s + s = SUBSTR.ljust(size) + self.assertEquals(len(s), size) + stripped = s.lstrip() + self.failUnless(stripped is s) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_replace(self, size): + replacement = 'a' + s = ' ' * size + s = s.replace(' ', replacement) + self.assertEquals(len(s), size) + self.assertEquals(s.count(replacement), size) + s = s.replace(replacement, ' ', size - 4) + self.assertEquals(len(s), size) + self.assertEquals(s.count(replacement), 4) + self.assertEquals(s[-10:], ' aaaa') + + @bigmemtest(minsize=_2G, memuse=2) + def test_rfind(self, size): + SUBSTR = ' abc def ghi' + sublen = len(SUBSTR) + s = ''.join([SUBSTR, '-' * size, SUBSTR]) + self.assertEquals(s.rfind(' '), sublen + size + SUBSTR.rfind(' ')) + self.assertEquals(s.rfind(SUBSTR), sublen + size) + self.assertEquals(s.rfind(' ', 0, size), SUBSTR.rfind(' ')) + self.assertEquals(s.rfind(SUBSTR, 0, sublen + size), 0) + self.assertEquals(s.rfind('i'), sublen + size + SUBSTR.rfind('i')) + self.assertEquals(s.rfind('i', 0, sublen), SUBSTR.rfind('i')) + self.assertEquals(s.rfind('i', 0, sublen + size), + SUBSTR.rfind('i')) + self.assertEquals(s.rfind('j'), -1) + + @bigmemtest(minsize=_2G, memuse=2) + def test_rindex(self, size): + SUBSTR = ' abc def ghi' + sublen = len(SUBSTR) + s = ''.join([SUBSTR, '-' * size, SUBSTR]) + self.assertEquals(s.rindex(' '), + sublen + size + SUBSTR.rindex(' ')) + self.assertEquals(s.rindex(SUBSTR), sublen + size) + self.assertEquals(s.rindex(' ', 0, sublen + size - 1), + SUBSTR.rindex(' ')) + self.assertEquals(s.rindex(SUBSTR, 0, sublen + size), 0) + self.assertEquals(s.rindex('i'), + sublen + size + SUBSTR.rindex('i')) + self.assertEquals(s.rindex('i', 0, sublen), SUBSTR.rindex('i')) + self.assertEquals(s.rindex('i', 0, sublen + size), + SUBSTR.rindex('i')) + self.assertRaises(ValueError, s.rindex, 'j') + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_rjust(self, size): + SUBSTR = ' abc def ghi' + s = SUBSTR.ljust(size) + self.failUnless(s.startswith(SUBSTR + ' ')) + self.assertEquals(len(s), size) + self.assertEquals(s.strip(), SUBSTR.strip()) + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_rstrip(self, size): + SUBSTR = ' abc def ghi' + s = SUBSTR.ljust(size) + self.assertEquals(len(s), size) + self.assertEquals(s.rstrip(), SUBSTR.rstrip()) + del s + s = SUBSTR.rjust(size) + self.assertEquals(len(s), size) + stripped = s.rstrip() + self.failUnless(stripped is s) + + # The test takes about size bytes to build a string, and then about + # sqrt(size) substrings of sqrt(size) in size and a list to + # hold sqrt(size) items. It's close but just over 2x size. + @bigmemtest(minsize=_2G, memuse=2.1) + def test_split_small(self, size): + # Crudely calculate an estimate so that the result of s.split won't + # take up an inordinate amount of memory + chunksize = int(size ** 0.5 + 2) + SUBSTR = 'a' + ' ' * chunksize + s = SUBSTR * chunksize + l = s.split() + self.assertEquals(len(l), chunksize) + self.assertEquals(set(l), set(['a'])) + del l + l = s.split('a') + self.assertEquals(len(l), chunksize + 1) + self.assertEquals(set(l), set(['', ' ' * chunksize])) + + # Allocates a string of twice size (and briefly two) and a list of + # size. Because of internal affairs, the s.split() call produces a + # list of size times the same one-character string, so we only + # suffer for the list size. (Otherwise, it'd cost another 48 times + # size in bytes!) Nevertheless, a list of size takes + # 8*size bytes. + @bigmemtest(minsize=_2G + 5, memuse=10) + def test_split_large(self, size): + s = ' a' * size + ' ' + l = s.split() + self.assertEquals(len(l), size) + self.assertEquals(set(l), set(['a'])) + del l + l = s.split('a') + self.assertEquals(len(l), size + 1) + self.assertEquals(set(l), set([' '])) + + @bigmemtest(minsize=_2G, memuse=2.1) + def test_splitlines(self, size): + # Crudely calculate an estimate so that the result of s.split won't + # take up an inordinate amount of memory + chunksize = int(size ** 0.5 + 2) // 2 + SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n' + s = SUBSTR * chunksize + l = s.splitlines() + self.assertEquals(len(l), chunksize * 2) + self.assertEquals(set(l), set([' ' * chunksize])) + + @bigmemtest(minsize=_2G, memuse=2) + def test_startswith(self, size): + SUBSTR = ' abc def ghi' + s = '-' * size + SUBSTR + self.failUnless(s.startswith(s)) + self.failUnless(s.startswith('-' * size)) + self.failIf(s.startswith(SUBSTR)) + + @bigmemtest(minsize=_2G, memuse=1) + def test_strip(self, size): + SUBSTR = ' abc def ghi ' + s = SUBSTR.rjust(size) + self.assertEquals(len(s), size) + self.assertEquals(s.strip(), SUBSTR.strip()) + del s + s = SUBSTR.ljust(size) + self.assertEquals(len(s), size) + self.assertEquals(s.strip(), SUBSTR.strip()) + + @bigmemtest(minsize=_2G, memuse=2) + def test_swapcase(self, size): + SUBSTR = "aBcDeFG12.'\xa9\x00" + sublen = len(SUBSTR) + repeats = size // sublen + 2 + s = SUBSTR * repeats + s = s.swapcase() + self.assertEquals(len(s), sublen * repeats) + self.assertEquals(s[:sublen * 3], SUBSTR.swapcase() * 3) + self.assertEquals(s[-sublen * 3:], SUBSTR.swapcase() * 3) + + @bigmemtest(minsize=_2G, memuse=2) + def test_title(self, size): + SUBSTR = 'SpaaHAaaAaham' + s = SUBSTR * (size // len(SUBSTR) + 2) + s = s.title() + self.failUnless(s.startswith((SUBSTR * 3).title())) + self.failUnless(s.endswith(SUBSTR.lower() * 3)) + + @bigmemtest(minsize=_2G, memuse=2) + def test_translate(self, size): + trans = string.maketrans('.aZ', '-!$') + SUBSTR = 'aZz.z.Aaz.' + sublen = len(SUBSTR) + repeats = size // sublen + 2 + s = SUBSTR * repeats + s = s.translate(trans) + self.assertEquals(len(s), repeats * sublen) + self.assertEquals(s[:sublen], SUBSTR.translate(trans)) + self.assertEquals(s[-sublen:], SUBSTR.translate(trans)) + self.assertEquals(s.count('.'), 0) + self.assertEquals(s.count('!'), repeats * 2) + self.assertEquals(s.count('z'), repeats * 3) + + @bigmemtest(minsize=_2G + 5, memuse=2) + def test_upper(self, size): + s = 'a' * size + s = s.upper() + self.assertEquals(len(s), size) + self.assertEquals(s.count('A'), size) + + @bigmemtest(minsize=_2G + 20, memuse=1) + def test_zfill(self, size): + SUBSTR = '-568324723598234' + s = SUBSTR.zfill(size) + self.failUnless(s.endswith('0' + SUBSTR[1:])) + self.failUnless(s.startswith('-0')) + self.assertEquals(len(s), size) + self.assertEquals(s.count('0'), size - len(SUBSTR)) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_format(self, size): + s = '-' * size + sf = '%s' % (s,) + self.failUnless(s == sf) + del sf + sf = '..%s..' % (s,) + self.assertEquals(len(sf), len(s) + 4) + self.failUnless(sf.startswith('..-')) + self.failUnless(sf.endswith('-..')) + del s, sf + + size //= 2 + edge = '-' * size + s = ''.join([edge, '%s', edge]) + del edge + s = s % '...' + self.assertEquals(len(s), size * 2 + 3) + self.assertEquals(s.count('.'), 3) + self.assertEquals(s.count('-'), size * 2) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_repr_small(self, size): + s = '-' * size + s = repr(s) + self.assertEquals(len(s), size + 2) + self.assertEquals(s[0], "'") + self.assertEquals(s[-1], "'") + self.assertEquals(s.count('-'), size) + del s + # repr() will create a string four times as large as this 'binary + # string', but we don't want to allocate much more than twice + # size in total. (We do extra testing in test_repr_large()) + size = size // 5 * 2 + s = '\x00' * size + s = repr(s) + self.assertEquals(len(s), size * 4 + 2) + self.assertEquals(s[0], "'") + self.assertEquals(s[-1], "'") + self.assertEquals(s.count('\\'), size) + self.assertEquals(s.count('0'), size * 2) + + @bigmemtest(minsize=_2G + 10, memuse=5) + def test_repr_large(self, size): + s = '\x00' * size + s = repr(s) + self.assertEquals(len(s), size * 4 + 2) + self.assertEquals(s[0], "'") + self.assertEquals(s[-1], "'") + self.assertEquals(s.count('\\'), size) + self.assertEquals(s.count('0'), size * 2) + + # This test is meaningful even with size < 2G, as long as the + # doubled string is > 2G (but it tests more if both are > 2G :) + @bigmemtest(minsize=_1G + 2, memuse=3) + def test_concat(self, size): + s = '.' * size + self.assertEquals(len(s), size) + s = s + s + self.assertEquals(len(s), size * 2) + self.assertEquals(s.count('.'), size * 2) + + # This test is meaningful even with size < 2G, as long as the + # repeated string is > 2G (but it tests more if both are > 2G :) + @bigmemtest(minsize=_1G + 2, memuse=3) + def test_repeat(self, size): + s = '.' * size + self.assertEquals(len(s), size) + s = s * 2 + self.assertEquals(len(s), size * 2) + self.assertEquals(s.count('.'), size * 2) + + @bigmemtest(minsize=_2G + 20, memuse=1) + def test_slice_and_getitem(self, size): + SUBSTR = '0123456789' + sublen = len(SUBSTR) + s = SUBSTR * (size // sublen) + stepsize = len(s) // 100 + stepsize = stepsize - (stepsize % sublen) + for i in range(0, len(s) - stepsize, stepsize): + self.assertEquals(s[i], SUBSTR[0]) + self.assertEquals(s[i:i + sublen], SUBSTR) + self.assertEquals(s[i:i + sublen:2], SUBSTR[::2]) + if i > 0: + self.assertEquals(s[i + sublen - 1:i - 1:-3], + SUBSTR[sublen::-3]) + # Make sure we do some slicing and indexing near the end of the + # string, too. + self.assertEquals(s[len(s) - 1], SUBSTR[-1]) + self.assertEquals(s[-1], SUBSTR[-1]) + self.assertEquals(s[len(s) - 10], SUBSTR[0]) + self.assertEquals(s[-sublen], SUBSTR[0]) + self.assertEquals(s[len(s):], '') + self.assertEquals(s[len(s) - 1:], SUBSTR[-1]) + self.assertEquals(s[-1:], SUBSTR[-1]) + self.assertEquals(s[len(s) - sublen:], SUBSTR) + self.assertEquals(s[-sublen:], SUBSTR) + self.assertEquals(len(s[:]), len(s)) + self.assertEquals(len(s[:len(s) - 5]), len(s) - 5) + self.assertEquals(len(s[5:-5]), len(s) - 10) + + self.assertRaises(IndexError, operator.getitem, s, len(s)) + self.assertRaises(IndexError, operator.getitem, s, len(s) + 1) + self.assertRaises(IndexError, operator.getitem, s, len(s) + 1<<31) + + @bigmemtest(minsize=_2G, memuse=2) + def test_contains(self, size): + SUBSTR = '0123456789' + edge = '-' * (size // 2) + s = ''.join([edge, SUBSTR, edge]) + del edge + self.failUnless(SUBSTR in s) + self.failIf(SUBSTR * 2 in s) + self.failUnless('-' in s) + self.failIf('a' in s) + s += 'a' + self.failUnless('a' in s) + + @bigmemtest(minsize=_2G + 10, memuse=2) + def test_compare(self, size): + s1 = '-' * size + s2 = '-' * size + self.failUnless(s1 == s2) + del s2 + s2 = s1 + 'a' + self.failIf(s1 == s2) + del s2 + s2 = '.' * size + self.failIf(s1 == s2) + + @bigmemtest(minsize=_2G + 10, memuse=1) + def test_hash(self, size): + # Not sure if we can do any meaningful tests here... Even if we + # start relying on the exact algorithm used, the result will be + # different depending on the size of the C 'long int'. Even this + # test is dodgy (there's no *guarantee* that the two things should + # have a different hash, even if they, in the current + # implementation, almost always do.) + s = '\x00' * size + h1 = hash(s) + del s + s = '\x00' * (size + 1) + self.failIf(h1 == hash(s)) + +class TupleTest(unittest.TestCase): + + # Tuples have a small, fixed-sized head and an array of pointers to + # data. Since we're testing 64-bit addressing, we can assume that the + # pointers are 8 bytes, and that thus that the tuples take up 8 bytes + # per size. + + # As a side-effect of testing long tuples, these tests happen to test + # having more than 2<<31 references to any given object. Hence the + # use of different types of objects as contents in different tests. + + @bigmemtest(minsize=_2G + 2, memuse=16) + def test_compare(self, size): + t1 = (u'',) * size + t2 = (u'',) * size + self.failUnless(t1 == t2) + del t2 + t2 = (u'',) * (size + 1) + self.failIf(t1 == t2) + del t2 + t2 = (1,) * size + self.failIf(t1 == t2) + + # Test concatenating into a single tuple of more than 2G in length, + # and concatenating a tuple of more than 2G in length separately, so + # the smaller test still gets run even if there isn't memory for the + # larger test (but we still let the tester know the larger test is + # skipped, in verbose mode.) + def basic_concat_test(self, size): + t = ((),) * size + self.assertEquals(len(t), size) + t = t + t + self.assertEquals(len(t), size * 2) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=24) + def test_concat_small(self, size): + return self.basic_concat_test(size) + + @bigmemtest(minsize=_2G + 2, memuse=24) + def test_concat_large(self, size): + return self.basic_concat_test(size) + + @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5) + def test_contains(self, size): + t = (1, 2, 3, 4, 5) * size + self.assertEquals(len(t), size * 5) + self.failUnless(5 in t) + self.failIf((1, 2, 3, 4, 5) in t) + self.failIf(0 in t) + + @bigmemtest(minsize=_2G + 10, memuse=8) + def test_hash(self, size): + t1 = (0,) * size + h1 = hash(t1) + del t1 + t2 = (0,) * (size + 1) + self.failIf(h1 == hash(t2)) + + @bigmemtest(minsize=_2G + 10, memuse=8) + def test_index_and_slice(self, size): + t = (None,) * size + self.assertEquals(len(t), size) + self.assertEquals(t[-1], None) + self.assertEquals(t[5], None) + self.assertEquals(t[size - 1], None) + self.assertRaises(IndexError, operator.getitem, t, size) + self.assertEquals(t[:5], (None,) * 5) + self.assertEquals(t[-5:], (None,) * 5) + self.assertEquals(t[20:25], (None,) * 5) + self.assertEquals(t[-25:-20], (None,) * 5) + self.assertEquals(t[size - 5:], (None,) * 5) + self.assertEquals(t[size - 5:size], (None,) * 5) + self.assertEquals(t[size - 6:size - 2], (None,) * 4) + self.assertEquals(t[size:size], ()) + self.assertEquals(t[size:size+5], ()) + + # Like test_concat, split in two. + def basic_test_repeat(self, size): + t = ('',) * size + self.assertEquals(len(t), size) + t = t * 2 + self.assertEquals(len(t), size * 2) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=24) + def test_repeat_small(self, size): + return self.basic_test_repeat(size) + + @bigmemtest(minsize=_2G + 2, memuse=24) + def test_repeat_large(self, size): + return self.basic_test_repeat(size) + + # Like test_concat, split in two. + def basic_test_repr(self, size): + t = (0,) * size + s = repr(t) + # The repr of a tuple of 0's is exactly three times the tuple length. + self.assertEquals(len(s), size * 3) + self.assertEquals(s[:5], '(0, 0') + self.assertEquals(s[-5:], '0, 0)') + self.assertEquals(s.count('0'), size) + + @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3) + def test_repr_small(self, size): + return self.basic_test_repr(size) + + @bigmemtest(minsize=_2G + 2, memuse=8 + 3) + def test_repr_large(self, size): + return self.basic_test_repr(size) + +class ListTest(unittest.TestCase): + + # Like tuples, lists have a small, fixed-sized head and an array of + # pointers to data, so 8 bytes per size. Also like tuples, we make the + # lists hold references to various objects to test their refcount + # limits. + + @bigmemtest(minsize=_2G + 2, memuse=16) + def test_compare(self, size): + l1 = [u''] * size + l2 = [u''] * size + self.failUnless(l1 == l2) + del l2 + l2 = [u''] * (size + 1) + self.failIf(l1 == l2) + del l2 + l2 = [2] * size + self.failIf(l1 == l2) + + # Test concatenating into a single list of more than 2G in length, + # and concatenating a list of more than 2G in length separately, so + # the smaller test still gets run even if there isn't memory for the + # larger test (but we still let the tester know the larger test is + # skipped, in verbose mode.) + def basic_test_concat(self, size): + l = [[]] * size + self.assertEquals(len(l), size) + l = l + l + self.assertEquals(len(l), size * 2) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=24) + def test_concat_small(self, size): + return self.basic_test_concat(size) + + @bigmemtest(minsize=_2G + 2, memuse=24) + def test_concat_large(self, size): + return self.basic_test_concat(size) + + def basic_test_inplace_concat(self, size): + l = [sys.stdout] * size + l += l + self.assertEquals(len(l), size * 2) + self.failUnless(l[0] is l[-1]) + self.failUnless(l[size - 1] is l[size + 1]) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=24) + def test_inplace_concat_small(self, size): + return self.basic_test_inplace_concat(size) + + @bigmemtest(minsize=_2G + 2, memuse=24) + def test_inplace_concat_large(self, size): + return self.basic_test_inplace_concat(size) + + @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5) + def test_contains(self, size): + l = [1, 2, 3, 4, 5] * size + self.assertEquals(len(l), size * 5) + self.failUnless(5 in l) + self.failIf([1, 2, 3, 4, 5] in l) + self.failIf(0 in l) + + @bigmemtest(minsize=_2G + 10, memuse=8) + def test_hash(self, size): + l = [0] * size + self.failUnlessRaises(TypeError, hash, l) + + @bigmemtest(minsize=_2G + 10, memuse=8) + def test_index_and_slice(self, size): + l = [None] * size + self.assertEquals(len(l), size) + self.assertEquals(l[-1], None) + self.assertEquals(l[5], None) + self.assertEquals(l[size - 1], None) + self.assertRaises(IndexError, operator.getitem, l, size) + self.assertEquals(l[:5], [None] * 5) + self.assertEquals(l[-5:], [None] * 5) + self.assertEquals(l[20:25], [None] * 5) + self.assertEquals(l[-25:-20], [None] * 5) + self.assertEquals(l[size - 5:], [None] * 5) + self.assertEquals(l[size - 5:size], [None] * 5) + self.assertEquals(l[size - 6:size - 2], [None] * 4) + self.assertEquals(l[size:size], []) + self.assertEquals(l[size:size+5], []) + + l[size - 2] = 5 + self.assertEquals(len(l), size) + self.assertEquals(l[-3:], [None, 5, None]) + self.assertEquals(l.count(5), 1) + self.assertRaises(IndexError, operator.setitem, l, size, 6) + self.assertEquals(len(l), size) + + l[size - 7:] = [1, 2, 3, 4, 5] + size -= 2 + self.assertEquals(len(l), size) + self.assertEquals(l[-7:], [None, None, 1, 2, 3, 4, 5]) + + l[:7] = [1, 2, 3, 4, 5] + size -= 2 + self.assertEquals(len(l), size) + self.assertEquals(l[:7], [1, 2, 3, 4, 5, None, None]) + + del l[size - 1] + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(l[-1], 4) + + del l[-2:] + size -= 2 + self.assertEquals(len(l), size) + self.assertEquals(l[-1], 2) + + del l[0] + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(l[0], 2) + + del l[:2] + size -= 2 + self.assertEquals(len(l), size) + self.assertEquals(l[0], 4) + + # Like test_concat, split in two. + def basic_test_repeat(self, size): + l = [] * size + self.failIf(l) + l = [''] * size + self.assertEquals(len(l), size) + l = l * 2 + self.assertEquals(len(l), size * 2) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=24) + def test_repeat_small(self, size): + return self.basic_test_repeat(size) + + @bigmemtest(minsize=_2G + 2, memuse=24) + def test_repeat_large(self, size): + return self.basic_test_repeat(size) + + def basic_test_inplace_repeat(self, size): + l = [''] + l *= size + self.assertEquals(len(l), size) + self.failUnless(l[0] is l[-1]) + del l + + l = [''] * size + l *= 2 + self.assertEquals(len(l), size * 2) + self.failUnless(l[size - 1] is l[-1]) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=16) + def test_inplace_repeat_small(self, size): + return self.basic_test_inplace_repeat(size) + + @bigmemtest(minsize=_2G + 2, memuse=16) + def test_inplace_repeat_large(self, size): + return self.basic_test_inplace_repeat(size) + + def basic_test_repr(self, size): + l = [0] * size + s = repr(l) + # The repr of a list of 0's is exactly three times the list length. + self.assertEquals(len(s), size * 3) + self.assertEquals(s[:5], '[0, 0') + self.assertEquals(s[-5:], '0, 0]') + self.assertEquals(s.count('0'), size) + + @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3) + def test_repr_small(self, size): + return self.basic_test_repr(size) + + @bigmemtest(minsize=_2G + 2, memuse=8 + 3) + def test_repr_large(self, size): + return self.basic_test_repr(size) + + # list overallocates ~1/8th of the total size (on first expansion) so + # the single list.append call puts memuse at 9 bytes per size. + @bigmemtest(minsize=_2G, memuse=9) + def test_append(self, size): + l = [object()] * size + l.append(object()) + self.assertEquals(len(l), size+1) + self.failUnless(l[-3] is l[-2]) + self.failIf(l[-2] is l[-1]) + + @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) + def test_count(self, size): + l = [1, 2, 3, 4, 5] * size + self.assertEquals(l.count(1), size) + self.assertEquals(l.count("1"), 0) + + def basic_test_extend(self, size): + l = [file] * size + l.extend(l) + self.assertEquals(len(l), size * 2) + self.failUnless(l[0] is l[-1]) + self.failUnless(l[size - 1] is l[size + 1]) + + @bigmemtest(minsize=_2G // 2 + 2, memuse=16) + def test_extend_small(self, size): + return self.basic_test_extend(size) + + @bigmemtest(minsize=_2G + 2, memuse=16) + def test_extend_large(self, size): + return self.basic_test_extend(size) + + @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) + def test_index(self, size): + l = [1L, 2L, 3L, 4L, 5L] * size + size *= 5 + self.assertEquals(l.index(1), 0) + self.assertEquals(l.index(5, size - 5), size - 1) + self.assertEquals(l.index(5, size - 5, size), size - 1) + self.assertRaises(ValueError, l.index, 1, size - 4, size) + self.assertRaises(ValueError, l.index, 6L) + + # This tests suffers from overallocation, just like test_append. + @bigmemtest(minsize=_2G + 10, memuse=9) + def test_insert(self, size): + l = [1.0] * size + l.insert(size - 1, "A") + size += 1 + self.assertEquals(len(l), size) + self.assertEquals(l[-3:], [1.0, "A", 1.0]) + + l.insert(size + 1, "B") + size += 1 + self.assertEquals(len(l), size) + self.assertEquals(l[-3:], ["A", 1.0, "B"]) + + l.insert(1, "C") + size += 1 + self.assertEquals(len(l), size) + self.assertEquals(l[:3], [1.0, "C", 1.0]) + self.assertEquals(l[size - 3:], ["A", 1.0, "B"]) + + @bigmemtest(minsize=_2G // 5 + 4, memuse=8 * 5) + def test_pop(self, size): + l = [u"a", u"b", u"c", u"d", u"e"] * size + size *= 5 + self.assertEquals(len(l), size) + + item = l.pop() + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(item, u"e") + self.assertEquals(l[-2:], [u"c", u"d"]) + + item = l.pop(0) + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(item, u"a") + self.assertEquals(l[:2], [u"b", u"c"]) + + item = l.pop(size - 2) + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(item, u"c") + self.assertEquals(l[-2:], [u"b", u"d"]) + + @bigmemtest(minsize=_2G + 10, memuse=8) + def test_remove(self, size): + l = [10] * size + self.assertEquals(len(l), size) + + l.remove(10) + size -= 1 + self.assertEquals(len(l), size) + + # Because of the earlier l.remove(), this append doesn't trigger + # a resize. + l.append(5) + size += 1 + self.assertEquals(len(l), size) + self.assertEquals(l[-2:], [10, 5]) + l.remove(5) + size -= 1 + self.assertEquals(len(l), size) + self.assertEquals(l[-2:], [10, 10]) + + @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) + def test_reverse(self, size): + l = [1, 2, 3, 4, 5] * size + l.reverse() + self.assertEquals(len(l), size * 5) + self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) + self.assertEquals(l[:5], [5, 4, 3, 2, 1]) + + @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5) + def test_sort(self, size): + l = [1, 2, 3, 4, 5] * size + l.sort() + self.assertEquals(len(l), size * 5) + self.assertEquals(l.count(1), size) + self.assertEquals(l[:10], [1] * 10) + self.assertEquals(l[-10:], [5] * 10) + +def test_main(): + test_support.run_unittest(StrTest, TupleTest, ListTest) + +if __name__ == '__main__': + if len(sys.argv) > 1: + test_support.set_memlimit(sys.argv[1]) + test_main() From buildbot at python.org Wed May 17 02:00:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 17 May 2006 00:00:30 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060517000030.3D1261E4007@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/709 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Wed May 17 02:38:38 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 16 May 2006 17:38:38 -0700 Subject: [Python-checkins] r46012 - in python/trunk: Doc/lib/libzlib.tex Lib/test/test_zlib.py Misc/NEWS Modules/zlibmodule.c In-Reply-To: <20060516073828.C033A1E4006@bag.python.org> References: <20060516073828.C033A1E4006@bag.python.org> Message-ID: This change is presumably causing the new ref leaks in the zlib module. On 5/16/06, georg.brandl wrote: > Author: georg.brandl > Date: Tue May 16 09:38:27 2006 > New Revision: 46012 > > Modified: > python/trunk/Doc/lib/libzlib.tex > python/trunk/Lib/test/test_zlib.py > python/trunk/Misc/NEWS > python/trunk/Modules/zlibmodule.c > Log: > Patch #1435422: zlib's compress and decompress objects now have a > copy() method. > > > Modified: python/trunk/Doc/lib/libzlib.tex > ============================================================================== > --- python/trunk/Doc/lib/libzlib.tex (original) > +++ python/trunk/Doc/lib/libzlib.tex Tue May 16 09:38:27 2006 > @@ -123,6 +123,12 @@ > action is to delete the object. > \end{methoddesc} > > +\begin{methoddesc}[Compress]{copy}{} > +Returns a copy of the compression object. This can be used to efficiently > +compress a set of data that share a common initial prefix. > +\versionadded{2.5} > +\end{methoddesc} > + > Decompression objects support the following methods, and two attributes: > > \begin{memberdesc}{unused_data} > @@ -176,6 +182,13 @@ > output buffer. > \end{methoddesc} > > +\begin{methoddesc}[Decompress]{copy}{} > +Returns a copy of the decompression object. This can be used to save the > +state of the decompressor midway through the data stream in order to speed up > +random seeks into the stream at a future point. > +\versionadded{2.5} > +\end{methoddesc} > + > \begin{seealso} > \seemodule{gzip}{Reading and writing \program{gzip}-format files.} > \seeurl{http://www.zlib.net}{The zlib library home page.} > > Modified: python/trunk/Lib/test/test_zlib.py > ============================================================================== > --- python/trunk/Lib/test/test_zlib.py (original) > +++ python/trunk/Lib/test/test_zlib.py Tue May 16 09:38:27 2006 > @@ -302,6 +302,63 @@ > dco = zlib.decompressobj() > self.assertEqual(dco.flush(), "") # Returns nothing > > + def test_compresscopy(self): > + # Test copying a compression object > + data0 = HAMLET_SCENE > + data1 = HAMLET_SCENE.swapcase() > + c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) > + bufs0 = [] > + bufs0.append(c0.compress(data0)) > + > + c1 = c0.copy() > + bufs1 = bufs0[:] > + > + bufs0.append(c0.compress(data0)) > + bufs0.append(c0.flush()) > + s0 = ''.join(bufs0) > + > + bufs1.append(c1.compress(data1)) > + bufs1.append(c1.flush()) > + s1 = ''.join(bufs1) > + > + self.assertEqual(zlib.decompress(s0),data0+data0) > + self.assertEqual(zlib.decompress(s1),data0+data1) > + > + def test_badcompresscopy(self): > + # Test copying a compression object in an inconsistent state > + c = zlib.compressobj() > + c.compress(HAMLET_SCENE) > + c.flush() > + self.assertRaises(ValueError, c.copy) > + > + def test_decompresscopy(self): > + # Test copying a decompression object > + data = HAMLET_SCENE > + comp = zlib.compress(data) > + > + d0 = zlib.decompressobj() > + bufs0 = [] > + bufs0.append(d0.decompress(comp[:32])) > + > + d1 = d0.copy() > + bufs1 = bufs0[:] > + > + bufs0.append(d0.decompress(comp[32:])) > + s0 = ''.join(bufs0) > + > + bufs1.append(d1.decompress(comp[32:])) > + s1 = ''.join(bufs1) > + > + self.assertEqual(s0,s1) > + self.assertEqual(s0,data) > + > + def test_baddecompresscopy(self): > + # Test copying a compression object in an inconsistent state > + data = zlib.compress(HAMLET_SCENE) > + d = zlib.decompressobj() > + d.decompress(data) > + d.flush() > + self.assertRaises(ValueError, d.copy) > > def genblock(seed, length, step=1024, generator=random): > """length-byte stream of random data from a seed (in step-byte blocks).""" > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Tue May 16 09:38:27 2006 > @@ -28,6 +28,9 @@ > Extension Modules > ----------------- > > +- Patch #1435422: zlib's compress and decompress objects now have a > + copy() method. > + > - On Win32, os.listdir now supports arbitrarily-long Unicode path names > (up to the system limit of 32K characters). > > > Modified: python/trunk/Modules/zlibmodule.c > ============================================================================== > --- python/trunk/Modules/zlibmodule.c (original) > +++ python/trunk/Modules/zlibmodule.c Tue May 16 09:38:27 2006 > @@ -653,6 +653,104 @@ > return RetVal; > } > > +PyDoc_STRVAR(comp_copy__doc__, > +"copy() -- Return a copy of the compression object."); > + > +static PyObject * > +PyZlib_copy(compobject *self) > +{ > + compobject *retval = NULL; > + int err; > + > + retval = newcompobject(&Comptype); > + if (!retval) return NULL; > + > + /* Copy the zstream state > + * We use ENTER_ZLIB / LEAVE_ZLIB to make this thread-safe > + */ > + ENTER_ZLIB > + err = deflateCopy(&retval->zst, &self->zst); > + switch(err) { > + case(Z_OK): > + break; > + case(Z_STREAM_ERROR): > + PyErr_SetString(PyExc_ValueError, "Inconsistent stream state"); > + goto error; > + case(Z_MEM_ERROR): > + PyErr_SetString(PyExc_MemoryError, > + "Can't allocate memory for compression object"); > + goto error; > + default: > + zlib_error(self->zst, err, "while copying compression object"); > + goto error; > + } > + > + retval->unused_data = self->unused_data; > + retval->unconsumed_tail = self->unconsumed_tail; > + Py_INCREF(retval->unused_data); > + Py_INCREF(retval->unconsumed_tail); > + > + /* Mark it as being initialized */ > + retval->is_initialised = 1; > + > + LEAVE_ZLIB > + return (PyObject *)retval; > + > +error: > + LEAVE_ZLIB > + Py_XDECREF(retval); > + return NULL; > +} > + > +PyDoc_STRVAR(decomp_copy__doc__, > +"copy() -- Return a copy of the decompression object."); > + > +static PyObject * > +PyZlib_uncopy(compobject *self) > +{ > + compobject *retval = NULL; > + int err; > + > + retval = newcompobject(&Decomptype); > + if (!retval) return NULL; > + > + /* Copy the zstream state > + * We use ENTER_ZLIB / LEAVE_ZLIB to make this thread-safe > + */ > + ENTER_ZLIB > + err = inflateCopy(&retval->zst, &self->zst); > + switch(err) { > + case(Z_OK): > + break; > + case(Z_STREAM_ERROR): > + PyErr_SetString(PyExc_ValueError, "Inconsistent stream state"); > + goto error; > + case(Z_MEM_ERROR): > + PyErr_SetString(PyExc_MemoryError, > + "Can't allocate memory for decompression object"); > + goto error; > + default: > + zlib_error(self->zst, err, "while copying decompression object"); > + goto error; > + } > + > + retval->unused_data = self->unused_data; > + retval->unconsumed_tail = self->unconsumed_tail; > + Py_INCREF(retval->unused_data); > + Py_INCREF(retval->unconsumed_tail); > + > + /* Mark it as being initialized */ > + retval->is_initialised = 1; > + > + LEAVE_ZLIB > + return (PyObject *)retval; > + > +error: > + LEAVE_ZLIB > + Py_XDECREF(retval); > + return NULL; > +} > + > PyDoc_STRVAR(decomp_flush__doc__, > "flush( [length] ) -- Return a string containing any remaining\n" > "decompressed data. length, if given, is the initial size of the\n" > @@ -725,6 +823,8 @@ > comp_compress__doc__}, > {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS, > comp_flush__doc__}, > + {"copy", (PyCFunction)PyZlib_copy, METH_NOARGS, > + comp_copy__doc__}, > {NULL, NULL} > }; > > @@ -734,6 +834,8 @@ > decomp_decompress__doc__}, > {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS, > decomp_flush__doc__}, > + {"copy", (PyCFunction)PyZlib_uncopy, METH_NOARGS, > + decomp_copy__doc__}, > {NULL, NULL} > }; > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Wed May 17 03:30:11 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 17 May 2006 03:30:11 +0200 (CEST) Subject: [Python-checkins] r46022 - python/trunk/Modules/zlibmodule.c Message-ID: <20060517013011.D631A1E4007@bag.python.org> Author: tim.peters Date: Wed May 17 03:30:11 2006 New Revision: 46022 Modified: python/trunk/Modules/zlibmodule.c Log: PyZlib_copy(), PyZlib_uncopy(): Repair leaks on the normal-case path. Modified: python/trunk/Modules/zlibmodule.c ============================================================================== --- python/trunk/Modules/zlibmodule.c (original) +++ python/trunk/Modules/zlibmodule.c Wed May 17 03:30:11 2006 @@ -685,10 +685,12 @@ goto error; } + Py_INCREF(self->unused_data); + Py_INCREF(self->unconsumed_tail); + Py_XDECREF(retval->unused_data); + Py_XDECREF(retval->unconsumed_tail); retval->unused_data = self->unused_data; retval->unconsumed_tail = self->unconsumed_tail; - Py_INCREF(retval->unused_data); - Py_INCREF(retval->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; @@ -698,7 +700,7 @@ error: LEAVE_ZLIB - Py_XDECREF(retval); + Py_XDECREF(retval); return NULL; } @@ -734,10 +736,12 @@ goto error; } + Py_INCREF(self->unused_data); + Py_INCREF(self->unconsumed_tail); + Py_XDECREF(retval->unused_data); + Py_XDECREF(retval->unconsumed_tail); retval->unused_data = self->unused_data; retval->unconsumed_tail = self->unconsumed_tail; - Py_INCREF(retval->unused_data); - Py_INCREF(retval->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; From tim.peters at gmail.com Wed May 17 03:32:24 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 16 May 2006 21:32:24 -0400 Subject: [Python-checkins] r46012 - in python/trunk: Doc/lib/libzlib.tex Lib/test/test_zlib.py Misc/NEWS Modules/zlibmodule.c In-Reply-To: References: <20060516073828.C033A1E4006@bag.python.org> Message-ID: <1f7befae0605161832y7cc51f87n4cc29d1ceea226f9@mail.gmail.com> [Neal Norwitz] > This change is presumably causing the new ref leaks in the zlib module. Yup! Should be fixed now. From python-checkins at python.org Wed May 17 16:06:09 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:06:09 +0200 (CEST) Subject: [Python-checkins] r46023 - python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060517140609.262451E4018@bag.python.org> Author: georg.brandl Date: Wed May 17 16:06:07 2006 New Revision: 46023 Modified: python/trunk/Doc/lib/libstdtypes.tex Log: Remove misleading comment about type-class unification. Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Wed May 17 16:06:07 2006 @@ -1,12 +1,11 @@ \section{Built-in Types \label{types}} The following sections describe the standard types that are built into -the interpreter. Historically, Python's built-in types have differed -from user-defined types because it was not possible to use the built-in -types as the basis for object-oriented inheritance. With the 2.2 -release this situation has started to change, although the intended -unification of user-defined and built-in types is as yet far from -complete. +the interpreter. +\note{Historically (until release 2.2), Python's built-in types have +differed from user-defined types because it was not possible to use +the built-in types as the basis for object-oriented inheritance. +This limitation does not exist any longer.} The principal built-in types are numerics, sequences, mappings, files classes, instances and exceptions. From python-checkins at python.org Wed May 17 16:11:36 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:11:36 +0200 (CEST) Subject: [Python-checkins] r46024 - python/trunk/Doc/howto/urllib2.rst Message-ID: <20060517141136.87C4E1E4016@bag.python.org> Author: georg.brandl Date: Wed May 17 16:11:36 2006 New Revision: 46024 Modified: python/trunk/Doc/howto/urllib2.rst Log: Apply patch #1489784 from Michael Foord. Modified: python/trunk/Doc/howto/urllib2.rst ============================================================================== --- python/trunk/Doc/howto/urllib2.rst (original) +++ python/trunk/Doc/howto/urllib2.rst Wed May 17 16:11:36 2006 @@ -1,9 +1,9 @@ ============================================== HOWTO Fetch Internet Resources Using urllib2 ============================================== ------------------------------------------- +---------------------------- Fetching URLs With Python ------------------------------------------- +---------------------------- .. note:: @@ -30,19 +30,18 @@ This HOWTO is written by `Michael Foord `_. -**urllib2** is a Python_ module for fetching URLs (Uniform Resource -Locators). It offers a very simple interface, in the form of the -*urlopen* function. This is capable of fetching URLs using a variety +**urllib2** is a `Python `_ module for fetching URLs +(Uniform Resource Locators). It offers a very simple interface, in the form of +the *urlopen* function. This is capable of fetching URLs using a variety of different protocols. It also offers a slightly more complex interface for handling common situations - like basic authentication, -cookies, proxies, and so on. These are provided by objects called +cookies, proxies and so on. These are provided by objects called handlers and openers. -While urllib2 supports fetching URLs for many "URL schemes" -(identified by the string before the ":" in URL - e.g. "ftp" is the -URL scheme of "ftp://python.org/") using their associated network -protocols (e.g. FTP, HTTP), this tutorial focuses on the most common -case, HTTP. +urllib2 supports fetching URLs for many "URL schemes" (identified by the string +before the ":" in URL - for example "ftp" is the URL scheme of +"ftp://python.org/") using their associated network protocols (e.g. FTP, HTTP). +This tutorial focuses on the most common case, HTTP. For straightforward situations *urlopen* is very easy to use. But as soon as you encounter errors or non-trivial cases when opening HTTP @@ -51,7 +50,8 @@ is :RFC:`2616`. This is a technical document and not intended to be easy to read. This HOWTO aims to illustrate using *urllib2*, with enough detail about HTTP to help you through. It is not intended to -replace the `urllib2 docs`_ , but is supplementary to them. +replace the `urllib2 docs `_ , +but is supplementary to them. Fetching URLs @@ -119,22 +119,41 @@ data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) - the_page = response.read() + the_page = response.read() Note that other encodings are sometimes required (e.g. for file upload -from HTML forms - see `HTML Specification, Form Submission`_ for more -details). +from HTML forms - see +`HTML Specification, Form Submission `_ +for more details). If you do not pass the ``data`` argument, urllib2 uses a **GET** -request. One way in which GET and POST requests differ is that POST +request. One way in which GET and POST requests differ is that POST requests often have "side-effects": they change the state of the system in some way (for example by placing an order with the website for a hundredweight of tinned spam to be delivered to your door). Though the HTTP standard makes it clear that POSTs are intended to *always* cause side-effects, and GET requests *never* to cause side-effects, nothing prevents a GET request from having side-effects, -nor a POST requests from having no side-effects. Data can also be -passed in an HTTP request by encoding it in the URL itself. +nor a POST requests from having no side-effects. Data can also be +passed in an HTTP GET request by encoding it in the URL itself. + +This is done as follows:: + + >>> import urllib2 + >>> import urllib + >>> data = {} + >>> data['name'] = 'Somebody Here' + >>> data['location'] = 'Northampton' + >>> data['language'] = 'Python' + >>> url_values = urllib.urlencode(data) + >>> print url_values + name=Somebody+Here&language=Python&location=Northampton + >>> url = 'http://www.example.com/example.cgi' + >>> full_url = url + '?' + url_values + >>> data = urllib2.open(full_url) + +Notice that the full URL is created by adding a ``?`` to the URL, followed by +the encoded values. Headers ------- @@ -355,7 +374,7 @@ :: - from urllib2 import Request, urlopen + from urllib2 import Request, urlopen, URLError req = Request(someurl) try: response = urlopen(req) @@ -386,15 +405,17 @@ currently an ``httplib.HTTPMessage`` instance. Typical headers include 'Content-length', 'Content-type', and so -on. See the `Quick Reference to HTTP Headers`_ for a useful listing of -HTTP headers with brief explanations of their meaning and use. +on. See the +`Quick Reference to HTTP Headers `_ +for a useful listing of HTTP headers with brief explanations of their meaning +and use. Openers and Handlers ==================== When you fetch a URL you use an opener (an instance of the perhaps -confusingly-named urllib2.OpenerDirector). Normally we have been using +confusingly-named ``urllib2.OpenerDirector``). Normally we have been using the default opener - via ``urlopen`` - but you can create custom openers. Openers use handlers. All the "heavy lifting" is done by the handlers. Each handler knows how to open URLs for a particular URL @@ -458,7 +479,7 @@ that case, it is convenient to use ``HTTPPasswordMgrWithDefaultRealm``. This allows you to specify a default username and password for a URL. This will be supplied in the -absence of yoou providing an alternative combination for a specific +absence of you providing an alternative combination for a specific realm. We indicate this by providing ``None`` as the realm argument to the ``add_password`` method. @@ -557,19 +578,21 @@ This document was reviewed and revised by John Lee. -.. [#] For an introduction to the CGI protocol see `Writing Web Applications in Python`_. -.. [#] Like Google for example. The *proper* way to use google from a program is to use PyGoogle_ of course. See `Voidspace Google`_ for some examples of using the Google API. -.. [#] Browser sniffing is a very bad practise for website design - building sites using web standards is much more sensible. Unfortunately a lot of sites still send different versions to different browsers. -.. [#] The user agent for MSIE 6 is *'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'* -.. [#] For details of more HTTP request headers, see `Quick Reference to HTTP Headers`_. - -.. [#] In my case I have to use a proxy to access the internet at work. If you attempt to fetch *localhost* URLs through this proxy it blocks them. IE is set to use the proxy, which urllib2 picks up on. In order to test scripts with a localhost server, I have to prevent urllib2 from using the proxy. - -.. _Python: http://www.python.org -.. _urllib2 docs: http://docs.python.org/lib/module-urllib2.html -.. _HTML Specification, Form Submission: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13 -.. _Quick Reference to HTTP Headers: http://www.cs.tut.fi/~jkorpela/http.html -.. _PyGoogle: http://pygoogle.sourceforge.net -.. _Voidspace Google: http://www.voidspace.org.uk/python/recipebook.shtml#google -.. _Writing Web Applications in Python: http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html -.. _Basic Authentication Tutorial: http://www.voidspace.org.uk/python/articles/authentication.shtml +.. [#] For an introduction to the CGI protocol see + `Writing Web Applications in Python `_. +.. [#] Like Google for example. The *proper* way to use google from a program + is to use `PyGoogle _ of course. See + `Voidspace Google `_ + for some examples of using the Google API. +.. [#] Browser sniffing is a very bad practise for website design - building + sites using web standards is much more sensible. Unfortunately a lot of + sites still send different versions to different browsers. +.. [#] The user agent for MSIE 6 is + *'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)'* +.. [#] For details of more HTTP request headers, see + `Quick Reference to HTTP Headers`_. +.. [#] In my case I have to use a proxy to access the internet at work. If you + attempt to fetch *localhost* URLs through this proxy it blocks them. IE + is set to use the proxy, which urllib2 picks up on. In order to test + scripts with a localhost server, I have to prevent urllib2 from using + the proxy. From python-checkins at python.org Wed May 17 16:18:21 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:18:21 +0200 (CEST) Subject: [Python-checkins] r46025 - python/trunk/Modules/posixmodule.c Message-ID: <20060517141821.74B951E4017@bag.python.org> Author: georg.brandl Date: Wed May 17 16:18:20 2006 New Revision: 46025 Modified: python/trunk/Modules/posixmodule.c Log: Fix typo in os.utime docstring (patch #1490189) Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Wed May 17 16:18:20 2006 @@ -2401,7 +2401,7 @@ } PyDoc_STRVAR(posix_utime__doc__, -"utime(path, (atime, utime))\n\ +"utime(path, (atime, mtime))\n\ utime(path, None)\n\n\ Set the access and modified time of the file to the given values. If the\n\ second form is used, set the access and modified times to the current time."); From python-checkins at python.org Wed May 17 16:26:51 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:26:51 +0200 (CEST) Subject: [Python-checkins] r46026 - in python/trunk: Misc/NEWS Modules/timemodule.c Message-ID: <20060517142651.07DC21E401D@bag.python.org> Author: georg.brandl Date: Wed May 17 16:26:50 2006 New Revision: 46026 Modified: python/trunk/Misc/NEWS python/trunk/Modules/timemodule.c Log: Patch #1490224: set time.altzone correctly on Cygwin. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 17 16:26:50 2006 @@ -28,6 +28,8 @@ Extension Modules ----------------- +- Patch #1490224: time.altzone is now set correctly on Cygwin. + - Patch #1435422: zlib's compress and decompress objects now have a copy() method. Modified: python/trunk/Modules/timemodule.c ============================================================================== --- python/trunk/Modules/timemodule.c (original) +++ python/trunk/Modules/timemodule.c Wed May 17 16:26:50 2006 @@ -713,7 +713,7 @@ #ifdef __CYGWIN__ tzset(); PyModule_AddIntConstant(m, "timezone", _timezone); - PyModule_AddIntConstant(m, "altzone", _timezone); + PyModule_AddIntConstant(m, "altzone", _timezone-3600); PyModule_AddIntConstant(m, "daylight", _daylight); PyModule_AddObject(m, "tzname", Py_BuildValue("(zz)", _tzname[0], _tzname[1])); From python-checkins at python.org Wed May 17 16:45:07 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:45:07 +0200 (CEST) Subject: [Python-checkins] r46027 - python/trunk/Lib/cookielib.py Message-ID: <20060517144507.86A401E4016@bag.python.org> Author: georg.brandl Date: Wed May 17 16:45:06 2006 New Revision: 46027 Modified: python/trunk/Lib/cookielib.py Log: Add global debug flag to cookielib to avoid heavy dependency on the logging module. Resolves #1484758. Modified: python/trunk/Lib/cookielib.py ============================================================================== --- python/trunk/Lib/cookielib.py (original) +++ python/trunk/Lib/cookielib.py Wed May 17 16:45:06 2006 @@ -28,7 +28,7 @@ __all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy', 'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar'] -import re, urlparse, copy, time, urllib, logging +import re, urlparse, copy, time, urllib try: import threading as _threading except ImportError: @@ -36,7 +36,18 @@ import httplib # only for the default HTTP port from calendar import timegm -debug = logging.getLogger("cookielib").debug +debug = 0 # set to true to enable debugging via the logging module +logger = None + +def _debug(*args): + global logger + if not debug: + return + if not logger: + import logging + logger = logging.getLogger("cookielib") + return logger.debug(*args) + DEFAULT_HTTP_PORT = str(httplib.HTTP_PORT) MISSING_FILENAME_TEXT = ("a filename was not supplied (nor was the CookieJar " @@ -611,7 +622,7 @@ try: int(port) except ValueError: - debug("nonnumeric port: '%s'", port) + _debug("nonnumeric port: '%s'", port) return None else: port = DEFAULT_HTTP_PORT @@ -902,7 +913,7 @@ strict about which cookies to accept). """ - debug(" - checking cookie %s=%s", cookie.name, cookie.value) + _debug(" - checking cookie %s=%s", cookie.name, cookie.value) assert cookie.name is not None @@ -918,25 +929,25 @@ if cookie.version is None: # Version is always set to 0 by parse_ns_headers if it's a Netscape # cookie, so this must be an invalid RFC 2965 cookie. - debug(" Set-Cookie2 without version attribute (%s=%s)", - cookie.name, cookie.value) + _debug(" Set-Cookie2 without version attribute (%s=%s)", + cookie.name, cookie.value) return False if cookie.version > 0 and not self.rfc2965: - debug(" RFC 2965 cookies are switched off") + _debug(" RFC 2965 cookies are switched off") return False elif cookie.version == 0 and not self.netscape: - debug(" Netscape cookies are switched off") + _debug(" Netscape cookies are switched off") return False return True def set_ok_verifiability(self, cookie, request): if request.is_unverifiable() and is_third_party(request): if cookie.version > 0 and self.strict_rfc2965_unverifiable: - debug(" third-party RFC 2965 cookie during " + _debug(" third-party RFC 2965 cookie during " "unverifiable transaction") return False elif cookie.version == 0 and self.strict_ns_unverifiable: - debug(" third-party Netscape cookie during " + _debug(" third-party Netscape cookie during " "unverifiable transaction") return False return True @@ -946,7 +957,7 @@ # servers that know both V0 and V1 protocols. if (cookie.version == 0 and self.strict_ns_set_initial_dollar and cookie.name.startswith("$")): - debug(" illegal name (starts with '$'): '%s'", cookie.name) + _debug(" illegal name (starts with '$'): '%s'", cookie.name) return False return True @@ -956,17 +967,17 @@ if ((cookie.version > 0 or (cookie.version == 0 and self.strict_ns_set_path)) and not req_path.startswith(cookie.path)): - debug(" path attribute %s is not a prefix of request " - "path %s", cookie.path, req_path) + _debug(" path attribute %s is not a prefix of request " + "path %s", cookie.path, req_path) return False return True def set_ok_domain(self, cookie, request): if self.is_blocked(cookie.domain): - debug(" domain %s is in user block-list", cookie.domain) + _debug(" domain %s is in user block-list", cookie.domain) return False if self.is_not_allowed(cookie.domain): - debug(" domain %s is not in user allow-list", cookie.domain) + _debug(" domain %s is not in user allow-list", cookie.domain) return False if cookie.domain_specified: req_host, erhn = eff_request_host(request) @@ -985,7 +996,7 @@ "info", "jobs", "mobi", "museum", "name", "pro", "travel", "eu") and len(tld) == 2: # domain like .co.uk - debug(" country-code second level domain %s", domain) + _debug(" country-code second level domain %s", domain) return False if domain.startswith("."): undotted_domain = domain[1:] @@ -993,30 +1004,30 @@ undotted_domain = domain embedded_dots = (undotted_domain.find(".") >= 0) if not embedded_dots and domain != ".local": - debug(" non-local domain %s contains no embedded dot", - domain) + _debug(" non-local domain %s contains no embedded dot", + domain) return False if cookie.version == 0: if (not erhn.endswith(domain) and (not erhn.startswith(".") and not ("."+erhn).endswith(domain))): - debug(" effective request-host %s (even with added " - "initial dot) does not end end with %s", - erhn, domain) + _debug(" effective request-host %s (even with added " + "initial dot) does not end end with %s", + erhn, domain) return False if (cookie.version > 0 or (self.strict_ns_domain & self.DomainRFC2965Match)): if not domain_match(erhn, domain): - debug(" effective request-host %s does not domain-match " - "%s", erhn, domain) + _debug(" effective request-host %s does not domain-match " + "%s", erhn, domain) return False if (cookie.version > 0 or (self.strict_ns_domain & self.DomainStrictNoDots)): host_prefix = req_host[:-len(domain)] if (host_prefix.find(".") >= 0 and not IPV4_RE.search(req_host)): - debug(" host prefix %s for domain %s contains a dot", - host_prefix, domain) + _debug(" host prefix %s for domain %s contains a dot", + host_prefix, domain) return False return True @@ -1031,13 +1042,13 @@ try: int(p) except ValueError: - debug(" bad port %s (not numeric)", p) + _debug(" bad port %s (not numeric)", p) return False if p == req_port: break else: - debug(" request port (%s) not found in %s", - req_port, cookie.port) + _debug(" request port (%s) not found in %s", + req_port, cookie.port) return False return True @@ -1050,7 +1061,7 @@ """ # Path has already been checked by .path_return_ok(), and domain # blocking done by .domain_return_ok(). - debug(" - checking cookie %s=%s", cookie.name, cookie.value) + _debug(" - checking cookie %s=%s", cookie.name, cookie.value) for n in "version", "verifiability", "secure", "expires", "port", "domain": fn_name = "return_ok_"+n @@ -1061,34 +1072,34 @@ def return_ok_version(self, cookie, request): if cookie.version > 0 and not self.rfc2965: - debug(" RFC 2965 cookies are switched off") + _debug(" RFC 2965 cookies are switched off") return False elif cookie.version == 0 and not self.netscape: - debug(" Netscape cookies are switched off") + _debug(" Netscape cookies are switched off") return False return True def return_ok_verifiability(self, cookie, request): if request.is_unverifiable() and is_third_party(request): if cookie.version > 0 and self.strict_rfc2965_unverifiable: - debug(" third-party RFC 2965 cookie during unverifiable " - "transaction") + _debug(" third-party RFC 2965 cookie during unverifiable " + "transaction") return False elif cookie.version == 0 and self.strict_ns_unverifiable: - debug(" third-party Netscape cookie during unverifiable " - "transaction") + _debug(" third-party Netscape cookie during unverifiable " + "transaction") return False return True def return_ok_secure(self, cookie, request): if cookie.secure and request.get_type() != "https": - debug(" secure cookie with non-secure request") + _debug(" secure cookie with non-secure request") return False return True def return_ok_expires(self, cookie, request): if cookie.is_expired(self._now): - debug(" cookie expired") + _debug(" cookie expired") return False return True @@ -1101,8 +1112,8 @@ if p == req_port: break else: - debug(" request port %s does not match cookie port %s", - req_port, cookie.port) + _debug(" request port %s does not match cookie port %s", + req_port, cookie.port) return False return True @@ -1114,17 +1125,17 @@ if (cookie.version == 0 and (self.strict_ns_domain & self.DomainStrictNonDomain) and not cookie.domain_specified and domain != erhn): - debug(" cookie with unspecified domain does not string-compare " - "equal to request domain") + _debug(" cookie with unspecified domain does not string-compare " + "equal to request domain") return False if cookie.version > 0 and not domain_match(erhn, domain): - debug(" effective request-host name %s does not domain-match " - "RFC 2965 cookie domain %s", erhn, domain) + _debug(" effective request-host name %s does not domain-match " + "RFC 2965 cookie domain %s", erhn, domain) return False if cookie.version == 0 and not ("."+erhn).endswith(domain): - debug(" request-host %s does not match Netscape cookie domain " - "%s", req_host, domain) + _debug(" request-host %s does not match Netscape cookie domain " + "%s", req_host, domain) return False return True @@ -1137,24 +1148,24 @@ if not erhn.startswith("."): erhn = "."+erhn if not (req_host.endswith(domain) or erhn.endswith(domain)): - #debug(" request domain %s does not match cookie domain %s", - # req_host, domain) + #_debug(" request domain %s does not match cookie domain %s", + # req_host, domain) return False if self.is_blocked(domain): - debug(" domain %s is in user block-list", domain) + _debug(" domain %s is in user block-list", domain) return False if self.is_not_allowed(domain): - debug(" domain %s is not in user allow-list", domain) + _debug(" domain %s is not in user allow-list", domain) return False return True def path_return_ok(self, path, request): - debug("- checking cookie path=%s", path) + _debug("- checking cookie path=%s", path) req_path = request_path(request) if not req_path.startswith(path): - debug(" %s does not path-match %s", req_path, path) + _debug(" %s does not path-match %s", req_path, path) return False return True @@ -1216,7 +1227,7 @@ cookies = [] if not self._policy.domain_return_ok(domain, request): return [] - debug("Checking %s for cookies to return", domain) + _debug("Checking %s for cookies to return", domain) cookies_by_path = self._cookies[domain] for path in cookies_by_path.keys(): if not self._policy.path_return_ok(path, request): @@ -1224,9 +1235,9 @@ cookies_by_name = cookies_by_path[path] for cookie in cookies_by_name.values(): if not self._policy.return_ok(cookie, request): - debug(" not returning cookie") + _debug(" not returning cookie") continue - debug(" it's a match") + _debug(" it's a match") cookies.append(cookie) return cookies @@ -1303,7 +1314,7 @@ The Cookie2 header is also added unless policy.hide_cookie2 is true. """ - debug("add_cookie_header") + _debug("add_cookie_header") self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) @@ -1380,7 +1391,7 @@ continue if k == "domain": if v is None: - debug(" missing value for domain attribute") + _debug(" missing value for domain attribute") bad_cookie = True break # RFC 2965 section 3.3.3 @@ -1390,7 +1401,7 @@ # Prefer max-age to expires (like Mozilla) continue if v is None: - debug(" missing or invalid value for expires " + _debug(" missing or invalid value for expires " "attribute: treating as session cookie") continue if k == "max-age": @@ -1398,7 +1409,7 @@ try: v = int(v) except ValueError: - debug(" missing or invalid (non-numeric) value for " + _debug(" missing or invalid (non-numeric) value for " "max-age attribute") bad_cookie = True break @@ -1411,7 +1422,7 @@ if (k in value_attrs) or (k in boolean_attrs): if (v is None and k not in ("port", "comment", "commenturl")): - debug(" missing value for %s attribute" % k) + _debug(" missing value for %s attribute" % k) bad_cookie = True break standard[k] = v @@ -1497,8 +1508,8 @@ self.clear(domain, path, name) except KeyError: pass - debug("Expiring cookie, domain='%s', path='%s', name='%s'", - domain, path, name) + _debug("Expiring cookie, domain='%s', path='%s', name='%s'", + domain, path, name) return None return Cookie(version, @@ -1613,13 +1624,13 @@ def extract_cookies(self, response, request): """Extract cookies from response, where allowable given the request.""" - debug("extract_cookies: %s", response.info()) + _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) for cookie in self.make_cookies(response, request): if self._policy.set_ok(cookie, request): - debug(" setting cookie: %s", cookie) + _debug(" setting cookie: %s", cookie) self.set_cookie(cookie) self._cookies_lock.release() From python-checkins at python.org Wed May 17 16:56:05 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 16:56:05 +0200 (CEST) Subject: [Python-checkins] r46028 - in python/trunk: Lib/lib-tk/turtle.py Misc/NEWS Message-ID: <20060517145605.ADC061E4016@bag.python.org> Author: georg.brandl Date: Wed May 17 16:56:04 2006 New Revision: 46028 Modified: python/trunk/Lib/lib-tk/turtle.py python/trunk/Misc/NEWS Log: Patch #1486962: Several bugs in the turtle Tk demo module were fixed and several features added, such as speed and geometry control. Modified: python/trunk/Lib/lib-tk/turtle.py ============================================================================== --- python/trunk/Lib/lib-tk/turtle.py (original) +++ python/trunk/Lib/lib-tk/turtle.py Wed May 17 16:56:04 2006 @@ -1,8 +1,24 @@ # LogoMation-like turtle graphics +""" +Turtle graphics is a popular way for introducing programming to +kids. It was part of the original Logo programming language developed +by Wally Feurzeig and Seymour Papert in 1966. + +Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it +the command turtle.forward(15), and it moves (on-screen!) 15 pixels in +the direction it is facing, drawing a line as it moves. Give it the +command turtle.left(25), and it rotates in-place 25 degrees clockwise. + +By combining together these and similar commands, intricate shapes and +pictures can easily be drawn. +""" + from math import * # Also for export import Tkinter +speeds = ['fastest', 'fast', 'normal', 'slow', 'slowest'] + class Error(Exception): pass @@ -13,17 +29,42 @@ self._items = [] self._tracing = 1 self._arrow = 0 + self._delay = 10 # default delay for drawing self.degrees() self.reset() def degrees(self, fullcircle=360.0): + """ Set angle measurement units to degrees. + + Example: + >>> turtle.degrees() + """ self._fullcircle = fullcircle self._invradian = pi / (fullcircle * 0.5) def radians(self): + """ Set the angle measurement units to radians. + + Example: + >>> turtle.radians() + """ self.degrees(2.0*pi) def reset(self): + """ Clear the screen, re-center the pen, and set variables to + the default values. + + Example: + >>> turtle.position() + [0.0, -22.0] + >>> turtle.heading() + 100.0 + >>> turtle.reset() + >>> turtle.position() + [0.0, 0.0] + >>> turtle.heading() + 0.0 + """ canvas = self._canvas self._canvas.update() width = canvas.winfo_width() @@ -45,6 +86,11 @@ canvas._root().tkraise() def clear(self): + """ Clear the screen. The turtle does not move. + + Example: + >>> turtle.clear() + """ self.fill(0) canvas = self._canvas items = self._items @@ -55,37 +101,130 @@ self._draw_turtle() def tracer(self, flag): + """ Set tracing on if flag is True, and off if it is False. + Tracing means line are drawn more slowly, with an + animation of an arrow along the line. + + Example: + >>> turtle.tracer(False) # turns off Tracer + """ self._tracing = flag if not self._tracing: self._delete_turtle() self._draw_turtle() def forward(self, distance): + """ Go forward distance steps. + + Example: + >>> turtle.position() + [0.0, 0.0] + >>> turtle.forward(25) + >>> turtle.position() + [25.0, 0.0] + >>> turtle.forward(-75) + >>> turtle.position() + [-50.0, 0.0] + """ x0, y0 = start = self._position x1 = x0 + distance * cos(self._angle*self._invradian) y1 = y0 - distance * sin(self._angle*self._invradian) self._goto(x1, y1) def backward(self, distance): + """ Go backwards distance steps. + + The turtle's heading does not change. + + Example: + >>> turtle.position() + [0.0, 0.0] + >>> turtle.backward(30) + >>> turtle.position() + [-30.0, 0.0] + """ self.forward(-distance) def left(self, angle): + """ Turn left angle units (units are by default degrees, + but can be set via the degrees() and radians() functions.) + + When viewed from above, the turning happens in-place around + its front tip. + + Example: + >>> turtle.heading() + 22 + >>> turtle.left(45) + >>> turtle.heading() + 67.0 + """ self._angle = (self._angle + angle) % self._fullcircle self._draw_turtle() def right(self, angle): + """ Turn right angle units (units are by default degrees, + but can be set via the degrees() and radians() functions.) + + When viewed from above, the turning happens in-place around + its front tip. + + Example: + >>> turtle.heading() + 22 + >>> turtle.right(45) + >>> turtle.heading() + 337.0 + """ self.left(-angle) def up(self): + """ Pull the pen up -- no drawing when moving. + + Example: + >>> turtle.up() + """ self._drawing = 0 def down(self): + """ Put the pen down -- draw when moving. + + Example: + >>> turtle.down() + """ self._drawing = 1 def width(self, width): + """ Set the line to thickness to width. + + Example: + >>> turtle.width(10) + """ self._width = float(width) def color(self, *args): + """ Set the pen color. + + Three input formats are allowed: + + color(s) + s is a Tk specification string, such as "red" or "yellow" + + color((r, g, b)) + *a tuple* of r, g, and b, which represent, an RGB color, + and each of r, g, and b are in the range [0..1] + + color(r, g, b) + r, g, and b represent an RGB color, and each of r, g, and b + are in the range [0..1] + + Example: + + >>> turtle.color('brown') + >>> tup = (0.2, 0.8, 0.55) + >>> turtle.color(tup) + >>> turtle.color(0, .5, 0) + """ if not args: raise Error, "no color arguments" if len(args) == 1: @@ -118,11 +257,20 @@ self._color = color self._draw_turtle() - def write(self, arg, move=0): - x, y = start = self._position + def write(self, text, move=False): + """ Write text at the current pen position. + + If move is true, the pen is moved to the bottom-right corner + of the text. By default, move is False. + + Example: + >>> turtle.write('The race is on!') + >>> turtle.write('Home = (0, 0)', True) + """ + x, y = self._position x = x-1 # correction -- calibrated for Windows item = self._canvas.create_text(x, y, - text=str(arg), anchor="sw", + text=str(text), anchor="sw", fill=self._color) self._items.append(item) if move: @@ -131,6 +279,20 @@ self._draw_turtle() def fill(self, flag): + """ Call fill(1) before drawing the shape you + want to fill, and fill(0) when done. + + Example: + >>> turtle.fill(1) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.fill(0) + """ if self._filling: path = tuple(self._path) smooth = self._filling < 0 @@ -139,7 +301,6 @@ {'fill': self._color, 'smooth': smooth}) self._items.append(item) - self._canvas.lower(item) if self._tofill: for item in self._tofill: self._canvas.itemconfigure(item, fill=self._color) @@ -151,16 +312,62 @@ self._path.append(self._position) self.forward(0) + def begin_fill(self): + """ Called just before drawing a shape to be filled. + + Example: + >>> turtle.begin_fill() + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.end_fill() + """ + self.fill(1) + + def end_fill(self): + """ Called after drawing a shape to be filled. + + Example: + >>> turtle.begin_fill() + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.left(90) + >>> turtle.forward(100) + >>> turtle.end_fill() + """ + self.fill(0) + def circle(self, radius, extent=None): + """ Draw a circle with given radius. + The center is radius units left of the turtle; extent + determines which part of the circle is drawn. If not given, + the entire circle is drawn. + + If extent is not a full circle, one endpoint of the arc is the + current pen position. The arc is drawn in a counter clockwise + direction if radius is positive, otherwise in a clockwise + direction. In the process, the direction of the turtle is + changed by the amount of the extent. + + >>> turtle.circle(50) + >>> turtle.circle(120, 180) # half a circle + """ if extent is None: extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: - start = self._angle - 90.0 + start = self._angle - (self._fullcircle / 4.0) else: - start = self._angle + 90.0 + start = self._angle + (self._fullcircle / 4.0) extent = -extent if self._filling: if abs(extent) >= self._fullcircle: @@ -202,40 +409,145 @@ self._draw_turtle() def heading(self): + """ Return the turtle's current heading. + + Example: + >>> turtle.heading() + 67.0 + """ return self._angle def setheading(self, angle): + """ Set the turtle facing the given angle. + + Here are some common directions in degrees: + + 0 - east + 90 - north + 180 - west + 270 - south + + Example: + >>> turtle.setheading(90) + >>> turtle.heading() + 90 + >>> turtle.setheading(128) + >>> turtle.heading() + 128 + """ self._angle = angle self._draw_turtle() def window_width(self): + """ Returns the width of the turtle window. + + Example: + >>> turtle.window_width() + 640 + """ width = self._canvas.winfo_width() if width <= 1: # the window isn't managed by a geometry manager width = self._canvas['width'] return width def window_height(self): + """ Return the height of the turtle window. + + Example: + >>> turtle.window_height() + 768 + """ height = self._canvas.winfo_height() if height <= 1: # the window isn't managed by a geometry manager height = self._canvas['height'] return height def position(self): + """ Return the current (x, y) location of the turtle. + + Example: + >>> turtle.position() + [0.0, 240.0] + """ x0, y0 = self._origin x1, y1 = self._position return [x1-x0, -y1+y0] def setx(self, xpos): + """ Set the turtle's x coordinate to be xpos. + + Example: + >>> turtle.position() + [10.0, 240.0] + >>> turtle.setx(10) + >>> turtle.position() + [10.0, 240.0] + """ x0, y0 = self._origin x1, y1 = self._position self._goto(x0+xpos, y1) def sety(self, ypos): + """ Set the turtle's y coordinate to be ypos. + + Example: + >>> turtle.position() + [0.0, 0.0] + >>> turtle.sety(-22) + >>> turtle.position() + [0.0, -22.0] + """ x0, y0 = self._origin x1, y1 = self._position self._goto(x1, y0-ypos) + def towards(self, *args): + """Returs the angle, which corresponds to the line + from turtle-position to point (x,y). + + Argument can be two coordinates or one pair of coordinates + or a RawPen/Pen instance. + + Example: + >>> turtle.position() + [10.0, 10.0] + >>> turtle.towards(0,0) + 225.0 + """ + if len(args) == 2: + x, y = args + else: + arg = args[0] + if isinstance(arg, RawPen): + x, y = arg.position() + else: + x, y = arg + x0, y0 = self.position() + dx = x - x0 + dy = y - y0 + return (atan2(dy,dx) / self._invradian) % self._fullcircle + def goto(self, *args): + """ Go to the given point. + + If the pen is down, then a line will be drawn. The turtle's + orientation does not change. + + Two input formats are accepted: + + goto(x, y) + go to point (x, y) + + goto((x, y)) + go to point (x, y) + + Example: + >>> turtle.position() + [0.0, 0.0] + >>> turtle.goto(50, -45) + >>> turtle.position() + [50.0, -45.0] + """ if len(args) == 1: try: x, y = args[0] @@ -250,7 +562,7 @@ self._goto(x0+x, y0-y) def _goto(self, x1, y1): - x0, y0 = start = self._position + x0, y0 = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) @@ -270,7 +582,7 @@ self._canvas.coords(item, x0, y0, x, y) self._draw_turtle((x,y)) self._canvas.update() - self._canvas.after(10) + self._canvas.after(self._delay) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") @@ -285,7 +597,42 @@ self._items.append(item) self._draw_turtle() - def _draw_turtle(self,position=[]): + def speed(self, speed): + """ Set the turtle's speed. + + speed must one of these five strings: + + 'fastest' is a 0 ms delay + 'fast' is a 5 ms delay + 'normal' is a 10 ms delay + 'slow' is a 15 ms delay + 'slowest' is a 20 ms delay + + Example: + >>> turtle.speed('slow') + """ + try: + speed = speed.strip().lower() + self._delay = speeds.index(speed) * 5 + except: + raise ValueError("%r is not a valid speed. speed must be " + "one of %s" % (speed, speeds)) + + + def delay(self, delay): + """ Set the drawing delay in milliseconds. + + This is intended to allow finer control of the drawing speed + than the speed() method + + Example: + >>> turtle.delay(15) + """ + if int(delay) < 0: + raise ValueError("delay must be greater than or equal to 0") + self._delay = int(delay) + + def _draw_turtle(self, position=[]): if not self._tracing: return if position == []: @@ -305,13 +652,17 @@ def _delete_turtle(self): if self._arrow != 0: self._canvas.delete(self._arrow) - self._arrow = 0 - + self._arrow = 0 _root = None _canvas = None _pen = None +_width = 0.50 # 50% of window width +_height = 0.75 # 75% of window height +_startx = None +_starty = None +_title = "Turtle Graphics" # default title class Pen(RawPen): @@ -320,10 +671,15 @@ if _root is None: _root = Tkinter.Tk() _root.wm_protocol("WM_DELETE_WINDOW", self._destroy) + _root.title(_title) + if _canvas is None: # XXX Should have scroll bars _canvas = Tkinter.Canvas(_root, background="white") _canvas.pack(expand=1, fill="both") + + setup(width=_width, height= _height, startx=_startx, starty=_starty) + RawPen.__init__(self, _canvas) def _destroy(self): @@ -335,13 +691,18 @@ _canvas = None root.destroy() - def _getpen(): global _pen - pen = _pen - if not pen: - _pen = pen = Pen() - return pen + if not _pen: + _pen = Pen() + return _pen + +class Turtle(Pen): + pass + +"""For documentation of the following functions see + the RawPen methods with the same names +""" def degrees(): _getpen().degrees() def radians(): _getpen().radians() @@ -358,6 +719,8 @@ def color(*args): _getpen().color(*args) def write(arg, move=0): _getpen().write(arg, move) def fill(flag): _getpen().fill(flag) +def begin_fill(): _getpen().begin_fill() +def end_fill(): _getpen.end_fill() def circle(radius, extent=None): _getpen().circle(radius, extent) def goto(*args): _getpen().goto(*args) def heading(): return _getpen().heading() @@ -367,6 +730,106 @@ def window_height(): return _getpen().window_height() def setx(xpos): _getpen().setx(xpos) def sety(ypos): _getpen().sety(ypos) +def towards(*args): return _getpen().towards(*args) + +def done(): _root.mainloop() +def delay(delay): return _getpen().delay(delay) +def speed(speed): return _getpen().speed(speed) + +for methodname in dir(RawPen): + """ copies RawPen docstrings to module functions of same name """ + if not methodname.startswith("_"): + eval(methodname).__doc__ = RawPen.__dict__[methodname].__doc__ + + +def setup(**geometry): + """ Sets the size and position of the main window. + + Keywords are width, height, startx and starty + + width: either a size in pixels or a fraction of the screen. + Default is 50% of screen. + height: either the height in pixels or a fraction of the screen. + Default is 75% of screen. + + Setting either width or height to None before drawing will force + use of default geometry as in older versions of turtle.py + + startx: starting position in pixels from the left edge of the screen. + Default is to center window. Setting startx to None is the default + and centers window horizontally on screen. + + starty: starting position in pixels from the top edge of the screen. + Default is to center window. Setting starty to None is the default + and centers window vertically on screen. + + Examples: + >>> setup (width=200, height=200, startx=0, starty=0) + + sets window to 200x200 pixels, in upper left of screen + + >>> setup(width=.75, height=0.5, startx=None, starty=None) + + sets window to 75% of screen by 50% of screen and centers + + >>> setup(width=None) + + forces use of default geometry as in older versions of turtle.py + """ + + global _width, _height, _startx, _starty + + width = geometry.get('width',_width) + if width >= 0 or width == None: + _width = width + else: + raise ValueError, "width can not be less than 0" + + height = geometry.get('height',_height) + if height >= 0 or height == None: + _height = height + else: + raise ValueError, "height can not be less than 0" + + startx = geometry.get('startx', _startx) + if startx >= 0 or startx == None: + _startx = _startx + else: + raise ValueError, "startx can not be less than 0" + + starty = geometry.get('starty', _starty) + if starty >= 0 or starty == None: + _starty = starty + else: + raise ValueError, "startx can not be less than 0" + + + if _root and _width and _height: + if 0 < _width <= 1: + _width = _root.winfo_screenwidth() * +width + if 0 < _height <= 1: + _height = _root.winfo_screenheight() * _height + + # center window on screen + if _startx is None: + _startx = (_root.winfo_screenwidth() - _width) / 2 + + if _starty is None: + _starty = (_root.winfo_screenheight() - _height) / 2 + + _root.geometry("%dx%d+%d+%d" % (_width, _height, _startx, _starty)) + +def title(title): + """ set the window title. + + By default this is set to 'Turtle Graphics' + + Example: + >>> title("My Window") + """ + + global _title + _title = title def demo(): reset() @@ -417,10 +880,94 @@ forward(20) right(90) fill(0) + tracer(1) # more text write("end") - if __name__ == '__main__': - _root.mainloop() + +def demo2(): + # exercises some new and improved features + speed('fast') + width(3) + + # draw a segmented half-circle + setheading(towards(0,0)) + x,y = position() + r = (x**2+y**2)**.5/2.0 + right(90) + pendown = True + for i in range(18): + if pendown: + up() + pendown = False + else: + down() + pendown = True + circle(r,10) + sleep(2) + + reset() + left(90) + + # draw a series of triangles + l = 10 + color("green") + width(3) + left(180) + sp = 5 + for i in range(-2,16): + if i > 0: + color(1.0-0.05*i,0,0.05*i) + fill(1) + color("green") + for j in range(3): + forward(l) + left(120) + l += 10 + left(15) + if sp > 0: + sp = sp-1 + speed(speeds[sp]) + color(0.25,0,0.75) + fill(0) + color("green") + + left(130) + up() + forward(90) + color("red") + speed('fastest') + down(); + + # create a second turtle and make the original pursue and catch it + turtle=Turtle() + turtle.reset() + turtle.left(90) + turtle.speed('normal') + turtle.up() + turtle.goto(280,40) + turtle.left(24) + turtle.down() + turtle.speed('fast') + turtle.color("blue") + turtle.width(2) + speed('fastest') + + # turn default turtle towards new turtle object + setheading(towards(turtle)) + while ( abs(position()[0]-turtle.position()[0])>4 or + abs(position()[1]-turtle.position()[1])>4): + turtle.forward(3.5) + turtle.left(0.6) + # turn default turtle towards new turtle object + setheading(towards(turtle)) + forward(4) + write("CAUGHT! ", move=True) + + if __name__ == '__main__': + from time import sleep demo() + sleep(3) + demo2() + done() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 17 16:56:04 2006 @@ -45,6 +45,9 @@ Library ------- +- Patch #1486962: Several bugs in the turtle Tk demo module were fixed + and several features added, such as speed and geometry control. + - Patch #1488881: add support for external file objects in bz2 compressed tarfiles. From python-checkins at python.org Wed May 17 17:17:01 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 17:17:01 +0200 (CEST) Subject: [Python-checkins] r46029 - python/trunk/Lib/urllib2.py Message-ID: <20060517151701.1AC791E4016@bag.python.org> Author: georg.brandl Date: Wed May 17 17:17:00 2006 New Revision: 46029 Modified: python/trunk/Lib/urllib2.py Log: Delay-import some large modules to speed up urllib2 import. (fixes #1484793). Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Wed May 17 17:17:00 2006 @@ -85,11 +85,8 @@ # abstract factory for opener import base64 -import ftplib -import httplib -import inspect import hashlib -import mimetypes +import httplib import mimetools import os import posixpath @@ -100,7 +97,6 @@ import time import urlparse import bisect -import cookielib try: from cStringIO import StringIO @@ -168,6 +164,23 @@ class GopherError(URLError): pass +# copied from cookielib.py +cut_port_re = re.compile(r":\d+$") +def request_host(request): + """Return request-host, as defined by RFC 2965. + + Variation from RFC: returned value is lowercased, for convenient + comparison. + + """ + url = request.get_full_url() + host = urlparse.urlparse(url)[1] + if host == "": + host = request.get_header("Host", "") + + # remove port, if present + host = cut_port_re.sub("", host, 1) + return host.lower() class Request: @@ -185,7 +198,7 @@ self.add_header(key, value) self.unredirected_hdrs = {} if origin_req_host is None: - origin_req_host = cookielib.request_host(self) + origin_req_host = request_host(self) self.origin_req_host = origin_req_host self.unverifiable = unverifiable @@ -413,6 +426,9 @@ If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ + import types + def isclass(obj): + return isinstance(obj, types.ClassType) or hasattr(obj, "__bases__") opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, @@ -423,7 +439,7 @@ skip = [] for klass in default_classes: for check in handlers: - if inspect.isclass(check): + if isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): @@ -435,7 +451,7 @@ opener.add_handler(klass()) for h in handlers: - if inspect.isclass(h): + if isclass(h): h = h() opener.add_handler(h) return opener @@ -1071,6 +1087,7 @@ class HTTPCookieProcessor(BaseHandler): def __init__(self, cookiejar=None): + import cookielib if cookiejar is None: cookiejar = cookielib.CookieJar() self.cookiejar = cookiejar @@ -1168,6 +1185,7 @@ # not entirely sure what the rules are here def open_local_file(self, req): import email.Utils + import mimetypes host = req.get_host() file = req.get_selector() localfile = url2pathname(file) @@ -1188,6 +1206,8 @@ class FTPHandler(BaseHandler): def ftp_open(self, req): + import ftplib + import mimetypes host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') From buildbot at python.org Wed May 17 17:36:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 17 May 2006 15:36:48 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060517153649.037131E4016@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/378 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 17 17:47:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 17 May 2006 15:47:28 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060517154728.79E951E4024@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/713 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 17 17:51:18 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 17:51:18 +0200 (CEST) Subject: [Python-checkins] r46030 - in python/trunk: Doc/lib/liblocale.tex Lib/locale.py Lib/test/test_locale.py Misc/NEWS Message-ID: <20060517155118.6C8821E4004@bag.python.org> Author: georg.brandl Date: Wed May 17 17:51:16 2006 New Revision: 46030 Modified: python/trunk/Doc/lib/liblocale.tex python/trunk/Lib/locale.py python/trunk/Lib/test/test_locale.py python/trunk/Misc/NEWS Log: Patch #1180296: improve locale string formatting functions Modified: python/trunk/Doc/lib/liblocale.tex ============================================================================== --- python/trunk/Doc/lib/liblocale.tex (original) +++ python/trunk/Doc/lib/liblocale.tex Wed May 17 17:51:16 2006 @@ -61,7 +61,7 @@ Returns the database of the local conventions as a dictionary. This dictionary has the following strings as keys: - \begin{tableiii}{l|l|p{3in}}{constant}{Key}{Category}{Meaning} + \begin{tableiii}{l|l|p{3in}}{constant}{Category}{Key}{Meaning} \lineiii{LC_NUMERIC}{\code{'decimal_point'}} {Decimal point character.} \lineiii{}{\code{'grouping'}} @@ -76,8 +76,20 @@ {International currency symbol.} \lineiii{}{\code{'currency_symbol'}} {Local currency symbol.} + \lineiii{}{\code{'p_cs_precedes/n_cs_precedes'}} + {Whether the currency symbol precedes the value (for positive resp. + negative values).} + \lineiii{}{\code{'p_sep_by_space/n_sep_by_space'}} + {Whether the currency symbol is separated from the value + by a space (for positive resp. negative values).} \lineiii{}{\code{'mon_decimal_point'}} {Decimal point used for monetary values.} + \lineiii{}{\code{'frac_digits'}} + {Number of fractional digits used in local formatting + of monetary values.} + \lineiii{}{\code{'int_frac_digits'}} + {Number of fractional digits used in international + formatting of monetary values.} \lineiii{}{\code{'mon_thousands_sep'}} {Group separator used for monetary values.} \lineiii{}{\code{'mon_grouping'}} @@ -87,13 +99,12 @@ {Symbol used to annotate a positive monetary value.} \lineiii{}{\code{'negative_sign'}} {Symbol used to annotate a negative monetary value.} - \lineiii{}{\code{'frac_digits'}} - {Number of fractional digits used in local formatting - of monetary values.} - \lineiii{}{\code{'int_frac_digits'}} - {Number of fractional digits used in international - formatting of monetary values.} + \lineiii{}{\code{'p_sign_posn/n_sign_posn'}} + {The position of the sign (for positive resp. negative values), see below.} \end{tableiii} + + All numeric values can be set to \constant{CHAR_MAX} to indicate that + there is no value specified in this locale. The possible values for \code{'p_sign_posn'} and \code{'n_sign_posn'} are given below. @@ -104,7 +115,7 @@ \lineii{2}{The sign should follow the value and currency symbol.} \lineii{3}{The sign should immediately precede the value.} \lineii{4}{The sign should immediately follow the value.} - \lineii{\constant{LC_MAX}}{Nothing is specified in this locale.} + \lineii{\constant{CHAR_MAX}}{Nothing is specified in this locale.} \end{tableii} \end{funcdesc} @@ -206,12 +217,44 @@ strings. \end{funcdesc} -\begin{funcdesc}{format}{format, val\optional{, grouping}} +\begin{funcdesc}{format}{format, val\optional{, grouping\optional{, monetary}}} Formats a number \var{val} according to the current \constant{LC_NUMERIC} setting. The format follows the conventions of the \code{\%} operator. For floating point values, the decimal point is modified if appropriate. If \var{grouping} is true, also takes the grouping into account. + + If \var{monetary} is true, the conversion uses monetary thousands + separator and grouping strings. + + Please note that this function will only work for exactly one \%char + specifier. For whole format strings, use \function{format_string()}. + + \versionchanged[Added the \var{monetary} parameter]{2.5} +\end{funcdesc} + +\begin{funcdesc}{format_string}{format, val\optional{, grouping}} + Processes formatting specifiers as in \code{format \% val}, + but takes the current locale settings into account. + + \versionadded{2.5} +\end{funcdesc} + +\begin{funcdesc}{currency}{val\optional{, symbol\optional{, grouping\optional{, international}}}} + Formats a number \var{val} according to the current \constant{LC_MONETARY} + settings. + + The returned string includes the currency symbol if \var{symbol} is true, + which is the default. + If \var{grouping} is true (which is not the default), grouping is done with + the value. + If \var{international} is true (which is not the default), the international + currency symbol is used. + + Note that this function will not work with the `C' locale, so you have to set + a locale via \function{setlocale()} first. + + \versionadded{2.5} \end{funcdesc} \begin{funcdesc}{str}{float} Modified: python/trunk/Lib/locale.py ============================================================================== --- python/trunk/Lib/locale.py (original) +++ python/trunk/Lib/locale.py Wed May 17 17:51:16 2006 @@ -88,13 +88,16 @@ ### Number formatting APIs # Author: Martin von Loewis +# improved by Georg Brandl #perform the grouping from right to left -def _group(s): - conv=localeconv() - grouping=conv['grouping'] - if not grouping:return (s, 0) - result="" +def _group(s, monetary=False): + conv = localeconv() + thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep'] + grouping = conv[monetary and 'mon_grouping' or 'grouping'] + if not grouping: + return (s, 0) + result = "" seps = 0 spaces = "" if s[-1] == ' ': @@ -103,63 +106,142 @@ s = s[:sp] while s and grouping: # if grouping is -1, we are done - if grouping[0]==CHAR_MAX: + if grouping[0] == CHAR_MAX: break # 0: re-use last group ad infinitum - elif grouping[0]!=0: + elif grouping[0] != 0: #process last group - group=grouping[0] - grouping=grouping[1:] + group = grouping[0] + grouping = grouping[1:] if result: - result=s[-group:]+conv['thousands_sep']+result + result = s[-group:] + thousands_sep + result seps += 1 else: - result=s[-group:] - s=s[:-group] + result = s[-group:] + s = s[:-group] if s and s[-1] not in "0123456789": # the leading string is only spaces and signs - return s+result+spaces,seps + return s + result + spaces, seps if not result: - return s+spaces,seps + return s + spaces, seps if s: - result=s+conv['thousands_sep']+result + result = s + thousands_sep + result seps += 1 - return result+spaces,seps + return result + spaces, seps -def format(f,val,grouping=0): - """Formats a value in the same way that the % formatting would use, +def format(percent, value, grouping=False, monetary=False, *additional): + """Returns the locale-aware substitution of a %? specifier + (percent). + + additional is for format strings which contain one or more + '*' modifiers.""" + # this is only for one-percent-specifier strings and this should be checked + if percent[0] != '%': + raise ValueError("format() must be given exactly one %char " + "format specifier") + if additional: + formatted = percent % ((value,) + additional) + else: + formatted = percent % value + # floats and decimal ints need special action! + if percent[-1] in 'eEfFgG': + seps = 0 + parts = formatted.split('.') + if grouping: + parts[0], seps = _group(parts[0], monetary=monetary) + decimal_point = localeconv()[monetary and 'mon_decimal_point' + or 'decimal_point'] + formatted = decimal_point.join(parts) + while seps: + sp = formatted.find(' ') + if sp == -1: break + formatted = formatted[:sp] + formatted[sp+1:] + seps -= 1 + elif percent[-1] in 'diu': + if grouping: + formatted = _group(formatted, monetary=monetary)[0] + return formatted + +import re, operator +_percent_re = re.compile(r'%(?:\((?P.*?)\))?' + r'(?P[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]') + +def format_string(f, val, grouping=False): + """Formats a string in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" - result = f % val - fields = result.split(".") - seps = 0 - if grouping: - fields[0],seps=_group(fields[0]) - if len(fields)==2: - result = fields[0]+localeconv()['decimal_point']+fields[1] - elif len(fields)==1: - result = fields[0] + percents = list(_percent_re.finditer(f)) + new_f = _percent_re.sub('%s', f) + + if isinstance(val, tuple): + new_val = list(val) + i = 0 + for perc in percents: + starcount = perc.group('modifiers').count('*') + new_val[i] = format(perc.group(), new_val[i], grouping, False, *new_val[i+1:i+1+starcount]) + del new_val[i+1:i+1+starcount] + i += (1 + starcount) + val = tuple(new_val) + elif operator.isMappingType(val): + for perc in percents: + key = perc.group("key") + val[key] = format(perc.group(), val[key], grouping) else: - raise Error, "Too many decimal points in result string" + # val is a single value + val = format(percents[0].group(), val, grouping) + + return new_f % val - while seps: - # If the number was formatted for a specific width, then it - # might have been filled with spaces to the left or right. If - # so, kill as much spaces as there where separators. - # Leading zeroes as fillers are not yet dealt with, as it is - # not clear how they should interact with grouping. - sp = result.find(" ") - if sp==-1:break - result = result[:sp]+result[sp+1:] - seps -= 1 +def currency(val, symbol=True, grouping=False, international=False): + """Formats val according to the currency settings + in the current locale.""" + conv = localeconv() + + # check for illegal values + digits = conv[international and 'int_frac_digits' or 'frac_digits'] + if digits == 127: + raise ValueError("Currency formatting is not possible using " + "the 'C' locale.") + + s = format('%%.%if' % digits, abs(val), grouping, monetary=True) + # '<' and '>' are markers if the sign must be inserted between symbol and value + s = '<' + s + '>' + + if symbol: + smb = conv[international and 'int_curr_symbol' or 'currency_symbol'] + precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes'] + separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space'] + + if precedes: + s = smb + (separated and ' ' or '') + s + else: + s = s + (separated and ' ' or '') + smb + + sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn'] + sign = conv[val<0 and 'negative_sign' or 'positive_sign'] + + if sign_pos == 0: + s = '(' + s + ')' + elif sign_pos == 1: + s = sign + s + elif sign_pos == 2: + s = s + sign + elif sign_pos == 3: + s = s.replace('<', sign) + elif sign_pos == 4: + s = s.replace('>', sign) + else: + # the default if nothing specified; + # this should be the most fitting sign position + s = sign + s - return result + return s.replace('<', '').replace('>', '') def str(val): """Convert float to integer, taking the locale into account.""" - return format("%.12g",val) + return format("%.12g", val) -def atof(string,func=float): +def atof(string, func=float): "Parses a string as a float according to the locale settings." #First, get rid of the grouping ts = localeconv()['thousands_sep'] @@ -179,10 +261,10 @@ def _test(): setlocale(LC_ALL, "") #do grouping - s1=format("%d", 123456789,1) + s1 = format("%d", 123456789,1) print s1, "is", atoi(s1) #standard formatting - s1=str(3.14) + s1 = str(3.14) print s1, "is", atof(s1) ### Locale name aliasing engine Modified: python/trunk/Lib/test/test_locale.py ============================================================================== --- python/trunk/Lib/test/test_locale.py (original) +++ python/trunk/Lib/test/test_locale.py Wed May 17 17:51:16 2006 @@ -20,14 +20,14 @@ else: raise ImportError, "test locale not supported (tried %s)"%(', '.join(tlocs)) -def testformat(formatstr, value, grouping = 0, output=None): +def testformat(formatstr, value, grouping = 0, output=None, func=locale.format): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(value), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(value)), - result = locale.format(formatstr, value, grouping = grouping) + result = func(formatstr, value, grouping = grouping) if output and result != output: if verbose: print 'no' @@ -49,6 +49,27 @@ testformat("%-10.f", 4200, grouping=1, output='4%s200 ' % sep) # Invoke getpreferredencoding to make sure it does not cause exceptions, locale.getpreferredencoding() + + # === Test format() with more complex formatting strings + # test if grouping is independent from other characters in formatting string + testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000', + func=locale.format_string) + testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000', + func=locale.format_string) + # test dots in formatting string + testformat(".%f.", 1000.0, output='.1000.000000.', func=locale.format_string) + # test floats + testformat("--> %10.2f", 1000.0, grouping=1, output='--> 1,000.00', + func=locale.format_string) + # test asterisk formats + testformat("%10.*f", (2, 1000.0), grouping=0, output=' 1000.00', + func=locale.format_string) + testformat("%*.*f", (10, 2, 1000.0), grouping=1, output=' 1,000.00', + func=locale.format_string) + # test more-in-one + testformat("int %i float %.2f str %s", (1000, 1000.0, 'str'), grouping=1, + output='int 1,000 float 1,000.00 str str', func=locale.format_string) + finally: locale.setlocale(locale.LC_NUMERIC, oldlocale) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 17 17:51:16 2006 @@ -45,6 +45,10 @@ Library ------- +- Patch #1180296: Two new functions were added to the locale module: + format_string() to get the effect of "format % items" but locale-aware, + and currency() to format a monetary number with currency sign. + - Patch #1486962: Several bugs in the turtle Tk demo module were fixed and several features added, such as speed and geometry control. From buildbot at python.org Wed May 17 18:32:33 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 17 May 2006 16:32:33 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060517163233.E46881E4004@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/697 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From tim.peters at gmail.com Wed May 17 19:32:19 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 17 May 2006 13:32:19 -0400 Subject: [Python-checkins] r46030 - in python/trunk: Doc/lib/liblocale.tex Lib/locale.py Lib/test/test_locale.py Misc/NEWS In-Reply-To: <20060517155118.6C8821E4004@bag.python.org> References: <20060517155118.6C8821E4004@bag.python.org> Message-ID: <1f7befae0605171032h174ae66cs3d5c4e86e1279ffe@mail.gmail.com> > Author: georg.brandl > Date: Wed May 17 17:51:16 2006 > New Revision: 46030 > > Modified: > python/trunk/Doc/lib/liblocale.tex > python/trunk/Lib/locale.py > python/trunk/Lib/test/test_locale.py > python/trunk/Misc/NEWS > Log: > Patch #1180296: improve locale string formatting functions Note that this seemed to break test_locale on the Solaris buildbot: http://www.python.org/dev/buildbot/all/sparc%20solaris10%20gcc%20trunk/builds/697/step-test/0 From g.brandl at gmx.net Wed May 17 19:39:42 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Wed, 17 May 2006 19:39:42 +0200 Subject: [Python-checkins] r46030 - in python/trunk: Doc/lib/liblocale.tex Lib/locale.py Lib/test/test_locale.py Misc/NEWS In-Reply-To: <1f7befae0605171032h174ae66cs3d5c4e86e1279ffe@mail.gmail.com> References: <20060517155118.6C8821E4004@bag.python.org> <1f7befae0605171032h174ae66cs3d5c4e86e1279ffe@mail.gmail.com> Message-ID: Tim Peters wrote: >> Author: georg.brandl >> Date: Wed May 17 17:51:16 2006 >> New Revision: 46030 >> >> Modified: >> python/trunk/Doc/lib/liblocale.tex >> python/trunk/Lib/locale.py >> python/trunk/Lib/test/test_locale.py >> python/trunk/Misc/NEWS >> Log: >> Patch #1180296: improve locale string formatting functions > > Note that this seemed to break test_locale on the Solaris buildbot: > > http://www.python.org/dev/buildbot/all/sparc%20solaris10%20gcc%20trunk/builds/697/step-test/0 I just noticed. I'll investigate. Georg From python-checkins at python.org Wed May 17 19:41:35 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 17 May 2006 19:41:35 +0200 (CEST) Subject: [Python-checkins] r46031 - peps/trunk/pep-0356.txt Message-ID: <20060517174135.28D231E4008@bag.python.org> Author: georg.brandl Date: Wed May 17 19:41:34 2006 New Revision: 46031 Modified: peps/trunk/pep-0356.txt Log: Add ref to patch containing new-style icons. Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Wed May 17 19:41:34 2006 @@ -122,6 +122,7 @@ - Add new icons for Windows, MacOS and Unix with the new Python logo? (Owner: ???) Windows: http://mail.python.org/pipermail/python-dev/2006-April/063738.html + and patch http://python.org/sf/1490384 MacOS: http://hcs.harvard.edu/~jrus/python/prettified-py-icons.png - Check the various bits of code in Demo/ all still work, update or From jimjjewett at gmail.com Wed May 17 23:34:49 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 17 May 2006 17:34:49 -0400 Subject: [Python-checkins] logging issues: Re: r46027 - python/trunk/Lib/cookielib.py Message-ID: (1) I don't think logging should be removed from the stdlib. At the very least, the reasoning should be added to PEP 337, which says to *add* logging to the standard library. http://www.python.org/dev/peps/pep-0337/ (There will probably be a Summer Of Code student funded to do this; if it is a problem, lets fix the problem in the logging module.) (2) Logging isn't really as unstable as you seem to think Beta implies; it is probably more stable than the newer cookielib, let alone the combination of cookielib, urllib2, and Processors. (John Lee has been making long-overdue fixes to urllib2 -- and processors in particular -- because he was the first to really understand it well enough; these fixes are generally triggered by immediate problems and may not be complete fixes.) I will agree that it might make sense to remove the beta marker from the version of logging that is distributed in the stdlib. (3) What else was shipped with those applications which caused this? Which version of logging did you have? Both tracebacks could be caused if the root logger were not a normal logger (and its manager therefore not a normal manager). Vinay has taken some steps to allow 3rd party libraries to override the class of even the root logger, but doing it *right* is fairly subtle. Another possibility is that you got burned by threads allowing access to half-constructed loggers or managers, or by broken PlaceHolders/fixups in the manager. Again, this can't happen unless someone is doing at least two dangerous things, but ... it has triggered a few of the changelog entries. -jJ On 5/17/06, georg.brandl wrote: > Author: georg.brandl > Date: Wed May 17 16:45:06 2006 > New Revision: 46027 > > Modified: > python/trunk/Lib/cookielib.py > Log: > Add global debug flag to cookielib to avoid heavy dependency on the logging module. > Resolves #1484758. > > > > Modified: python/trunk/Lib/cookielib.py > ============================================================================== > --- python/trunk/Lib/cookielib.py (original) > +++ python/trunk/Lib/cookielib.py Wed May 17 16:45:06 2006 > @@ -28,7 +28,7 @@ > __all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy', > 'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar'] > > -import re, urlparse, copy, time, urllib, logging > +import re, urlparse, copy, time, urllib > try: > import threading as _threading > except ImportError: > @@ -36,7 +36,18 @@ > import httplib # only for the default HTTP port > from calendar import timegm > > -debug = logging.getLogger("cookielib").debug > +debug = 0 # set to true to enable debugging via the logging module > +logger = None > + > +def _debug(*args): > + global logger > + if not debug: > + return > + if not logger: > + import logging > + logger = logging.getLogger("cookielib") > + return logger.debug(*args) > + > > DEFAULT_HTTP_PORT = str(httplib.HTTP_PORT) > MISSING_FILENAME_TEXT = ("a filename was not supplied (nor was the CookieJar " > @@ -611,7 +622,7 @@ > try: > int(port) > except ValueError: > - debug("nonnumeric port: '%s'", port) > + _debug("nonnumeric port: '%s'", port) > return None > else: > port = DEFAULT_HTTP_PORT > @@ -902,7 +913,7 @@ > strict about which cookies to accept). > > """ > - debug(" - checking cookie %s=%s", cookie.name, cookie.value) > + _debug(" - checking cookie %s=%s", cookie.name, cookie.value) > > assert cookie.name is not None > > @@ -918,25 +929,25 @@ > if cookie.version is None: > # Version is always set to 0 by parse_ns_headers if it's a Netscape > # cookie, so this must be an invalid RFC 2965 cookie. > - debug(" Set-Cookie2 without version attribute (%s=%s)", > - cookie.name, cookie.value) > + _debug(" Set-Cookie2 without version attribute (%s=%s)", > + cookie.name, cookie.value) > return False > if cookie.version > 0 and not self.rfc2965: > - debug(" RFC 2965 cookies are switched off") > + _debug(" RFC 2965 cookies are switched off") > return False > elif cookie.version == 0 and not self.netscape: > - debug(" Netscape cookies are switched off") > + _debug(" Netscape cookies are switched off") > return False > return True > > def set_ok_verifiability(self, cookie, request): > if request.is_unverifiable() and is_third_party(request): > if cookie.version > 0 and self.strict_rfc2965_unverifiable: > - debug(" third-party RFC 2965 cookie during " > + _debug(" third-party RFC 2965 cookie during " > "unverifiable transaction") > return False > elif cookie.version == 0 and self.strict_ns_unverifiable: > - debug(" third-party Netscape cookie during " > + _debug(" third-party Netscape cookie during " > "unverifiable transaction") > return False > return True > @@ -946,7 +957,7 @@ > # servers that know both V0 and V1 protocols. > if (cookie.version == 0 and self.strict_ns_set_initial_dollar and > cookie.name.startswith("$")): > - debug(" illegal name (starts with '$'): '%s'", cookie.name) > + _debug(" illegal name (starts with '$'): '%s'", cookie.name) > return False > return True > > @@ -956,17 +967,17 @@ > if ((cookie.version > 0 or > (cookie.version == 0 and self.strict_ns_set_path)) and > not req_path.startswith(cookie.path)): > - debug(" path attribute %s is not a prefix of request " > - "path %s", cookie.path, req_path) > + _debug(" path attribute %s is not a prefix of request " > + "path %s", cookie.path, req_path) > return False > return True > > def set_ok_domain(self, cookie, request): > if self.is_blocked(cookie.domain): > - debug(" domain %s is in user block-list", cookie.domain) > + _debug(" domain %s is in user block-list", cookie.domain) > return False > if self.is_not_allowed(cookie.domain): > - debug(" domain %s is not in user allow-list", cookie.domain) > + _debug(" domain %s is not in user allow-list", cookie.domain) > return False > if cookie.domain_specified: > req_host, erhn = eff_request_host(request) > @@ -985,7 +996,7 @@ > "info", "jobs", "mobi", "museum", "name", "pro", > "travel", "eu") and len(tld) == 2: > # domain like .co.uk > - debug(" country-code second level domain %s", domain) > + _debug(" country-code second level domain %s", domain) > return False > if domain.startswith("."): > undotted_domain = domain[1:] > @@ -993,30 +1004,30 @@ > undotted_domain = domain > embedded_dots = (undotted_domain.find(".") >= 0) > if not embedded_dots and domain != ".local": > - debug(" non-local domain %s contains no embedded dot", > - domain) > + _debug(" non-local domain %s contains no embedded dot", > + domain) > return False > if cookie.version == 0: > if (not erhn.endswith(domain) and > (not erhn.startswith(".") and > not ("."+erhn).endswith(domain))): > - debug(" effective request-host %s (even with added " > - "initial dot) does not end end with %s", > - erhn, domain) > + _debug(" effective request-host %s (even with added " > + "initial dot) does not end end with %s", > + erhn, domain) > return False > if (cookie.version > 0 or > (self.strict_ns_domain & self.DomainRFC2965Match)): > if not domain_match(erhn, domain): > - debug(" effective request-host %s does not domain-match " > - "%s", erhn, domain) > + _debug(" effective request-host %s does not domain-match " > + "%s", erhn, domain) > return False > if (cookie.version > 0 or > (self.strict_ns_domain & self.DomainStrictNoDots)): > host_prefix = req_host[:-len(domain)] > if (host_prefix.find(".") >= 0 and > not IPV4_RE.search(req_host)): > - debug(" host prefix %s for domain %s contains a dot", > - host_prefix, domain) > + _debug(" host prefix %s for domain %s contains a dot", > + host_prefix, domain) > return False > return True > > @@ -1031,13 +1042,13 @@ > try: > int(p) > except ValueError: > - debug(" bad port %s (not numeric)", p) > + _debug(" bad port %s (not numeric)", p) > return False > if p == req_port: > break > else: > - debug(" request port (%s) not found in %s", > - req_port, cookie.port) > + _debug(" request port (%s) not found in %s", > + req_port, cookie.port) > return False > return True > > @@ -1050,7 +1061,7 @@ > """ > # Path has already been checked by .path_return_ok(), and domain > # blocking done by .domain_return_ok(). > - debug(" - checking cookie %s=%s", cookie.name, cookie.value) > + _debug(" - checking cookie %s=%s", cookie.name, cookie.value) > > for n in "version", "verifiability", "secure", "expires", "port", "domain": > fn_name = "return_ok_"+n > @@ -1061,34 +1072,34 @@ > > def return_ok_version(self, cookie, request): > if cookie.version > 0 and not self.rfc2965: > - debug(" RFC 2965 cookies are switched off") > + _debug(" RFC 2965 cookies are switched off") > return False > elif cookie.version == 0 and not self.netscape: > - debug(" Netscape cookies are switched off") > + _debug(" Netscape cookies are switched off") > return False > return True > > def return_ok_verifiability(self, cookie, request): > if request.is_unverifiable() and is_third_party(request): > if cookie.version > 0 and self.strict_rfc2965_unverifiable: > - debug(" third-party RFC 2965 cookie during unverifiable " > - "transaction") > + _debug(" third-party RFC 2965 cookie during unverifiable " > + "transaction") > return False > elif cookie.version == 0 and self.strict_ns_unverifiable: > - debug(" third-party Netscape cookie during unverifiable " > - "transaction") > + _debug(" third-party Netscape cookie during unverifiable " > + "transaction") > return False > return True > > def return_ok_secure(self, cookie, request): > if cookie.secure and request.get_type() != "https": > - debug(" secure cookie with non-secure request") > + _debug(" secure cookie with non-secure request") > return False > return True > > def return_ok_expires(self, cookie, request): > if cookie.is_expired(self._now): > - debug(" cookie expired") > + _debug(" cookie expired") > return False > return True > > @@ -1101,8 +1112,8 @@ > if p == req_port: > break > else: > - debug(" request port %s does not match cookie port %s", > - req_port, cookie.port) > + _debug(" request port %s does not match cookie port %s", > + req_port, cookie.port) > return False > return True > > @@ -1114,17 +1125,17 @@ > if (cookie.version == 0 and > (self.strict_ns_domain & self.DomainStrictNonDomain) and > not cookie.domain_specified and domain != erhn): > - debug(" cookie with unspecified domain does not string-compare " > - "equal to request domain") > + _debug(" cookie with unspecified domain does not string-compare " > + "equal to request domain") > return False > > if cookie.version > 0 and not domain_match(erhn, domain): > - debug(" effective request-host name %s does not domain-match " > - "RFC 2965 cookie domain %s", erhn, domain) > + _debug(" effective request-host name %s does not domain-match " > + "RFC 2965 cookie domain %s", erhn, domain) > return False > if cookie.version == 0 and not ("."+erhn).endswith(domain): > - debug(" request-host %s does not match Netscape cookie domain " > - "%s", req_host, domain) > + _debug(" request-host %s does not match Netscape cookie domain " > + "%s", req_host, domain) > return False > return True > > @@ -1137,24 +1148,24 @@ > if not erhn.startswith("."): > erhn = "."+erhn > if not (req_host.endswith(domain) or erhn.endswith(domain)): > - #debug(" request domain %s does not match cookie domain %s", > - # req_host, domain) > + #_debug(" request domain %s does not match cookie domain %s", > + # req_host, domain) > return False > > if self.is_blocked(domain): > - debug(" domain %s is in user block-list", domain) > + _debug(" domain %s is in user block-list", domain) > return False > if self.is_not_allowed(domain): > - debug(" domain %s is not in user allow-list", domain) > + _debug(" domain %s is not in user allow-list", domain) > return False > > return True > > def path_return_ok(self, path, request): > - debug("- checking cookie path=%s", path) > + _debug("- checking cookie path=%s", path) > req_path = request_path(request) > if not req_path.startswith(path): > - debug(" %s does not path-match %s", req_path, path) > + _debug(" %s does not path-match %s", req_path, path) > return False > return True > > @@ -1216,7 +1227,7 @@ > cookies = [] > if not self._policy.domain_return_ok(domain, request): > return [] > - debug("Checking %s for cookies to return", domain) > + _debug("Checking %s for cookies to return", domain) > cookies_by_path = self._cookies[domain] > for path in cookies_by_path.keys(): > if not self._policy.path_return_ok(path, request): > @@ -1224,9 +1235,9 @@ > cookies_by_name = cookies_by_path[path] > for cookie in cookies_by_name.values(): > if not self._policy.return_ok(cookie, request): > - debug(" not returning cookie") > + _debug(" not returning cookie") > continue > - debug(" it's a match") > + _debug(" it's a match") > cookies.append(cookie) > return cookies > > @@ -1303,7 +1314,7 @@ > The Cookie2 header is also added unless policy.hide_cookie2 is true. > > """ > - debug("add_cookie_header") > + _debug("add_cookie_header") > self._cookies_lock.acquire() > > self._policy._now = self._now = int(time.time()) > @@ -1380,7 +1391,7 @@ > continue > if k == "domain": > if v is None: > - debug(" missing value for domain attribute") > + _debug(" missing value for domain attribute") > bad_cookie = True > break > # RFC 2965 section 3.3.3 > @@ -1390,7 +1401,7 @@ > # Prefer max-age to expires (like Mozilla) > continue > if v is None: > - debug(" missing or invalid value for expires " > + _debug(" missing or invalid value for expires " > "attribute: treating as session cookie") > continue > if k == "max-age": > @@ -1398,7 +1409,7 @@ > try: > v = int(v) > except ValueError: > - debug(" missing or invalid (non-numeric) value for " > + _debug(" missing or invalid (non-numeric) value for " > "max-age attribute") > bad_cookie = True > break > @@ -1411,7 +1422,7 @@ > if (k in value_attrs) or (k in boolean_attrs): > if (v is None and > k not in ("port", "comment", "commenturl")): > - debug(" missing value for %s attribute" % k) > + _debug(" missing value for %s attribute" % k) > bad_cookie = True > break > standard[k] = v > @@ -1497,8 +1508,8 @@ > self.clear(domain, path, name) > except KeyError: > pass > - debug("Expiring cookie, domain='%s', path='%s', name='%s'", > - domain, path, name) > + _debug("Expiring cookie, domain='%s', path='%s', name='%s'", > + domain, path, name) > return None > > return Cookie(version, > @@ -1613,13 +1624,13 @@ > > def extract_cookies(self, response, request): > """Extract cookies from response, where allowable given the request.""" > - debug("extract_cookies: %s", response.info()) > + _debug("extract_cookies: %s", response.info()) > self._cookies_lock.acquire() > self._policy._now = self._now = int(time.time()) > > for cookie in self.make_cookies(response, request): > if self._policy.set_ok(cookie, request): > - debug(" setting cookie: %s", cookie) > + _debug(" setting cookie: %s", cookie) > self.set_cookie(cookie) > self._cookies_lock.release() > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From jimjjewett at gmail.com Wed May 17 23:50:22 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 17 May 2006 17:50:22 -0400 Subject: [Python-checkins] r46028 - in python/trunk: Lib/lib-tk/turtle.py Misc/NEWS In-Reply-To: <20060517145605.ADC061E4016@bag.python.org> References: <20060517145605.ADC061E4016@bag.python.org> Message-ID: On 5/17/06, georg.brandl wrote: > Author: georg.brandl > Date: Wed May 17 16:56:04 2006 > New Revision: 46028 > > Modified: > python/trunk/Lib/lib-tk/turtle.py > python/trunk/Misc/NEWS > Log: > Patch #1486962: Several bugs in the turtle Tk demo module were fixed > and several features added, such as speed and geometry control. Depending on your motivation, many of these (the docstrings, at least) could be applied even in 2.4. -jJ From python-checkins at python.org Thu May 18 04:06:41 2006 From: python-checkins at python.org (tim.peters) Date: Thu, 18 May 2006 04:06:41 +0200 (CEST) Subject: [Python-checkins] r46032 - in python/trunk/Lib: lib-tk/turtle.py locale.py Message-ID: <20060518020641.0959F1E4009@bag.python.org> Author: tim.peters Date: Thu May 18 04:06:40 2006 New Revision: 46032 Modified: python/trunk/Lib/lib-tk/turtle.py python/trunk/Lib/locale.py Log: Whitespace normalization. Modified: python/trunk/Lib/lib-tk/turtle.py ============================================================================== --- python/trunk/Lib/lib-tk/turtle.py (original) +++ python/trunk/Lib/lib-tk/turtle.py Thu May 18 04:06:40 2006 @@ -754,11 +754,11 @@ Setting either width or height to None before drawing will force use of default geometry as in older versions of turtle.py - + startx: starting position in pixels from the left edge of the screen. Default is to center window. Setting startx to None is the default and centers window horizontally on screen. - + starty: starting position in pixels from the top edge of the screen. Default is to center window. Setting starty to None is the default and centers window vertically on screen. @@ -776,7 +776,7 @@ forces use of default geometry as in older versions of turtle.py """ - + global _width, _height, _startx, _starty width = geometry.get('width',_width) @@ -790,7 +790,7 @@ _height = height else: raise ValueError, "height can not be less than 0" - + startx = geometry.get('startx', _startx) if startx >= 0 or startx == None: _startx = _startx @@ -813,7 +813,7 @@ # center window on screen if _startx is None: _startx = (_root.winfo_screenwidth() - _width) / 2 - + if _starty is None: _starty = (_root.winfo_screenheight() - _height) / 2 @@ -827,7 +827,7 @@ Example: >>> title("My Window") """ - + global _title _title = title @@ -904,10 +904,10 @@ pendown = True circle(r,10) sleep(2) - - reset() + + reset() left(90) - + # draw a series of triangles l = 10 color("green") @@ -936,7 +936,7 @@ forward(90) color("red") speed('fastest') - down(); + down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() @@ -963,7 +963,7 @@ forward(4) write("CAUGHT! ", move=True) - + if __name__ == '__main__': from time import sleep Modified: python/trunk/Lib/locale.py ============================================================================== --- python/trunk/Lib/locale.py (original) +++ python/trunk/Lib/locale.py Thu May 18 04:06:40 2006 @@ -132,7 +132,7 @@ def format(percent, value, grouping=False, monetary=False, *additional): """Returns the locale-aware substitution of a %? specifier (percent). - + additional is for format strings which contain one or more '*' modifiers.""" # this is only for one-percent-specifier strings and this should be checked From buildbot at python.org Thu May 18 04:29:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 18 May 2006 02:29:27 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060518022927.1F2461E4009@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/483 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 18 04:29:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 18 May 2006 02:29:51 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060518022951.987A31E4009@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/412 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 18 04:44:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 18 May 2006 02:44:15 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060518024415.478841E4009@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/716 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 18 08:11:20 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 18 May 2006 08:11:20 +0200 (CEST) Subject: [Python-checkins] r46033 - python/trunk/Lib/tarfile.py Message-ID: <20060518061120.70A051E400B@bag.python.org> Author: georg.brandl Date: Thu May 18 08:11:19 2006 New Revision: 46033 Modified: python/trunk/Lib/tarfile.py Log: Amendments to patch #1484695. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Thu May 18 08:11:19 2006 @@ -169,7 +169,7 @@ s = "%0*o" % (digits - 1, n) + NUL else: if posix: - raise ValueError, "overflow in number field" + raise ValueError("overflow in number field") if n < 0: # XXX We mimic GNU tar's behaviour with negative numbers, @@ -211,13 +211,13 @@ for b in xrange(blocks): buf = src.read(BUFSIZE) if len(buf) < BUFSIZE: - raise IOError, "end of file reached" + raise IOError("end of file reached") dst.write(buf) if remainder != 0: buf = src.read(remainder) if len(buf) < remainder: - raise IOError, "end of file reached" + raise IOError("end of file reached") dst.write(buf) return @@ -349,7 +349,7 @@ try: import zlib except ImportError: - raise CompressionError, "zlib module is not available" + raise CompressionError("zlib module is not available") self.zlib = zlib self.crc = zlib.crc32("") if mode == "r": @@ -361,7 +361,7 @@ try: import bz2 except ImportError: - raise CompressionError, "bz2 module is not available" + raise CompressionError("bz2 module is not available") if mode == "r": self.dbuf = "" self.cmp = bz2.BZ2Decompressor() @@ -437,9 +437,9 @@ # taken from gzip.GzipFile with some alterations if self.__read(2) != "\037\213": - raise ReadError, "not a gzip file" + raise ReadError("not a gzip file") if self.__read(1) != "\010": - raise CompressionError, "unsupported compression method" + raise CompressionError("unsupported compression method") flag = ord(self.__read(1)) self.__read(6) @@ -475,7 +475,7 @@ self.read(self.bufsize) self.read(remainder) else: - raise StreamError, "seeking backwards is not allowed" + raise StreamError("seeking backwards is not allowed") return self.pos def read(self, size=None): @@ -692,7 +692,7 @@ """Read operation for regular files. """ if self.closed: - raise ValueError, "file is closed" + raise ValueError("file is closed") self.fileobj.seek(self.offset + self.pos) bytesleft = self.size - self.pos if size is None: @@ -706,7 +706,7 @@ """Read operation for sparse files. """ if self.closed: - raise ValueError, "file is closed" + raise ValueError("file is closed") if size is None: size = self.size - self.pos @@ -766,7 +766,7 @@ """Get an iterator over the file object. """ if self.closed: - raise ValueError, "I/O operation on closed file" + raise ValueError("I/O operation on closed file") return self def next(self): @@ -822,9 +822,9 @@ """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: - raise ValueError, "truncated header" + raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: - raise ValueError, "empty header" + raise ValueError("empty header") tarinfo = cls() tarinfo.buf = buf @@ -844,7 +844,7 @@ tarinfo.prefix = buf[345:500] if tarinfo.chksum not in calc_chksums(buf): - raise ValueError, "invalid header" + raise ValueError("invalid header") return tarinfo def tobuf(self, posix=False): @@ -930,7 +930,7 @@ self.name = name if len(mode) > 1 or mode not in "raw": - raise ValueError, "mode must be 'r', 'a' or 'w'" + raise ValueError("mode must be 'r', 'a' or 'w'") self._mode = mode self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] @@ -1010,7 +1010,7 @@ """ if not name and not fileobj: - raise ValueError, "nothing to open" + raise ValueError("nothing to open") if mode in ("r", "r:*"): # Find out which *open() is appropriate for opening the file. @@ -1020,7 +1020,7 @@ return func(name, "r", fileobj) except (ReadError, CompressionError): continue - raise ReadError, "file could not be opened successfully" + raise ReadError("file could not be opened successfully") elif ":" in mode: filemode, comptype = mode.split(":", 1) @@ -1032,7 +1032,7 @@ if comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) else: - raise CompressionError, "unknown compression type %r" % comptype + raise CompressionError("unknown compression type %r" % comptype) return func(name, filemode, fileobj) elif "|" in mode: @@ -1041,7 +1041,7 @@ comptype = comptype or "tar" if filemode not in "rw": - raise ValueError, "mode must be 'r' or 'w'" + raise ValueError("mode must be 'r' or 'w'") t = cls(name, filemode, _Stream(name, filemode, comptype, fileobj, bufsize)) @@ -1051,14 +1051,14 @@ elif mode in "aw": return cls.taropen(name, mode, fileobj) - raise ValueError, "undiscernible mode" + raise ValueError("undiscernible mode") @classmethod def taropen(cls, name, mode="r", fileobj=None): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": - raise ValueError, "mode must be 'r', 'a' or 'w'" + raise ValueError("mode must be 'r', 'a' or 'w'") return cls(name, mode, fileobj) @classmethod @@ -1067,13 +1067,13 @@ Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": - raise ValueError, "mode must be 'r' or 'w'" + raise ValueError("mode must be 'r' or 'w'") try: import gzip gzip.GzipFile except (ImportError, AttributeError): - raise CompressionError, "gzip module is not available" + raise CompressionError("gzip module is not available") pre, ext = os.path.splitext(name) pre = os.path.basename(pre) @@ -1094,7 +1094,7 @@ gzip.GzipFile(name, mode, compresslevel, fileobj) ) except IOError: - raise ReadError, "not a gzip file" + raise ReadError("not a gzip file") t._extfileobj = False return t @@ -1104,12 +1104,12 @@ Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": - raise ValueError, "mode must be 'r' or 'w'." + raise ValueError("mode must be 'r' or 'w'.") try: import bz2 except ImportError: - raise CompressionError, "bz2 module is not available" + raise CompressionError("bz2 module is not available") pre, ext = os.path.splitext(name) pre = os.path.basename(pre) @@ -1127,7 +1127,7 @@ try: t = cls.taropen(tarname, mode, fileobj) except IOError: - raise ReadError, "not a bzip2 file" + raise ReadError("not a bzip2 file") t._extfileobj = False return t @@ -1169,7 +1169,7 @@ """ tarinfo = self._getmember(name) if tarinfo is None: - raise KeyError, "filename %r not found" % name + raise KeyError("filename %r not found" % name) return tarinfo def getmembers(self): @@ -1388,15 +1388,14 @@ if tarinfo.size > MAXSIZE_MEMBER: if self.posix: - raise ValueError, "file is too large (>= 8 GB)" + raise ValueError("file is too large (>= 8 GB)") else: self._dbg(2, "tarfile: Created GNU tar largefile header") if len(tarinfo.linkname) > LENGTH_LINK: if self.posix: - raise ValueError, "linkname is too long (>%d)" \ - % (LENGTH_LINK) + raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) else: self._create_gnulong(tarinfo.linkname, GNUTYPE_LONGLINK) tarinfo.linkname = tarinfo.linkname[:LENGTH_LINK -1] @@ -1412,8 +1411,7 @@ prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: - raise ValueError, "name is too long (>%d)" \ - % (LENGTH_NAME) + raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) tarinfo.name = name tarinfo.prefix = prefix @@ -1539,7 +1537,7 @@ # A small but ugly workaround for the case that someone tries # to extract a (sym)link as a file-object from a non-seekable # stream of tar blocks. - raise StreamError, "cannot extract (sym)link as file object" + raise StreamError("cannot extract (sym)link as file object") else: # A (sym)link's file object is its target's file object. return self.extractfile(self._getmember(tarinfo.linkname, @@ -1639,13 +1637,13 @@ if hasattr(os, "mkfifo"): os.mkfifo(targetpath) else: - raise ExtractError, "fifo not supported by system" + raise ExtractError("fifo not supported by system") def makedev(self, tarinfo, targetpath): """Make a character or block device called targetpath. """ if not hasattr(os, "mknod") or not hasattr(os, "makedev"): - raise ExtractError, "special devices not supported by system" + raise ExtractError("special devices not supported by system") mode = tarinfo.mode if tarinfo.isblk(): @@ -1681,7 +1679,7 @@ try: shutil.copy2(linkpath, targetpath) except EnvironmentError, e: - raise IOError, "link could not be created" + raise IOError("link could not be created") def chown(self, tarinfo, targetpath): """Set owner of targetpath according to tarinfo. @@ -1709,7 +1707,7 @@ if sys.platform != "os2emx": os.chown(targetpath, u, g) except EnvironmentError, e: - raise ExtractError, "could not change owner" + raise ExtractError("could not change owner") def chmod(self, tarinfo, targetpath): """Set file permissions of targetpath according to tarinfo. @@ -1718,7 +1716,7 @@ try: os.chmod(targetpath, tarinfo.mode) except EnvironmentError, e: - raise ExtractError, "could not change mode" + raise ExtractError("could not change mode") def utime(self, tarinfo, targetpath): """Set modification time of targetpath according to tarinfo. @@ -1732,7 +1730,7 @@ try: os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) except EnvironmentError, e: - raise ExtractError, "could not change modification time" + raise ExtractError("could not change modification time") #-------------------------------------------------------------------------- def next(self): @@ -1755,6 +1753,13 @@ try: tarinfo = TarInfo.frombuf(buf) + + # We shouldn't rely on this checksum, because some tar programs + # calculate it differently and it is merely validating the + # header block. We could just as well skip this part, which would + # have a slight effect on performance... + if tarinfo.chksum not in calc_chksums(buf): + self._dbg(1, "tarfile: Bad Checksum %r" % tarinfo.name) # Set the TarInfo object's offset to the current position of the # TarFile and set self.offset to the position where the data blocks @@ -1766,12 +1771,14 @@ except ValueError, e: if self.ignore_zeros: - self._dbg(2, "0x%X: %s" % (self.offset, e)) + self._dbg(2, "0x%X: empty or invalid block: %s" % + (self.offset, e)) self.offset += BLOCKSIZE continue else: if self.offset == 0: - raise ReadError, str(e) + raise ReadError("empty, unreadable or compressed " + "file: %s" % e) return None break @@ -1958,9 +1965,9 @@ corresponds to TarFile's mode. """ if self.closed: - raise IOError, "%s is closed" % self.__class__.__name__ + raise IOError("%s is closed" % self.__class__.__name__) if mode is not None and self._mode not in mode: - raise IOError, "bad operation for mode %r" % self._mode + raise IOError("bad operation for mode %r" % self._mode) def __iter__(self): """Provide an iterator object. @@ -2096,7 +2103,7 @@ elif compression == TAR_GZIPPED: self.tarfile = TarFile.gzopen(file, mode) else: - raise ValueError, "unknown compression constant" + raise ValueError("unknown compression constant") if mode[0:1] == "r": members = self.tarfile.getmembers() for m in members: From python-checkins at python.org Thu May 18 08:18:06 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 18 May 2006 08:18:06 +0200 (CEST) Subject: [Python-checkins] r46034 - python/trunk/Lib/_LWPCookieJar.py python/trunk/Lib/_MozillaCookieJar.py Message-ID: <20060518061806.72EE01E4009@bag.python.org> Author: georg.brandl Date: Thu May 18 08:18:06 2006 New Revision: 46034 Modified: python/trunk/Lib/_LWPCookieJar.py python/trunk/Lib/_MozillaCookieJar.py Log: Remove unused import. Modified: python/trunk/Lib/_LWPCookieJar.py ============================================================================== --- python/trunk/Lib/_LWPCookieJar.py (original) +++ python/trunk/Lib/_LWPCookieJar.py Thu May 18 08:18:06 2006 @@ -11,7 +11,7 @@ """ -import time, re, logging +import time, re from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError, Cookie, MISSING_FILENAME_TEXT, join_header_words, split_header_words, Modified: python/trunk/Lib/_MozillaCookieJar.py ============================================================================== --- python/trunk/Lib/_MozillaCookieJar.py (original) +++ python/trunk/Lib/_MozillaCookieJar.py Thu May 18 08:18:06 2006 @@ -1,6 +1,6 @@ """Mozilla / Netscape cookie loading / saving.""" -import re, time, logging +import re, time from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError, Cookie, MISSING_FILENAME_TEXT) From python-checkins at python.org Thu May 18 08:33:27 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 18 May 2006 08:33:27 +0200 (CEST) Subject: [Python-checkins] r46035 - python/trunk/Lib/test/test_locale.py Message-ID: <20060518063327.A94351E4009@bag.python.org> Author: georg.brandl Date: Thu May 18 08:33:27 2006 New Revision: 46035 Modified: python/trunk/Lib/test/test_locale.py Log: Fix test_locale for platforms without a default thousands separator. Modified: python/trunk/Lib/test/test_locale.py ============================================================================== --- python/trunk/Lib/test/test_locale.py (original) +++ python/trunk/Lib/test/test_locale.py Thu May 18 08:33:27 2006 @@ -52,23 +52,26 @@ # === Test format() with more complex formatting strings # test if grouping is independent from other characters in formatting string - testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000', + testformat("One million is %i", 1000000, grouping=1, + output='One million is 1%s000%s000' % (sep, sep), func=locale.format_string) - testformat("One million is %i", 1000000, grouping=1, output='One million is 1,000,000', + testformat("One million is %i", 1000000, grouping=1, + output='One million is 1%s000%s000' % (sep, sep), func=locale.format_string) # test dots in formatting string testformat(".%f.", 1000.0, output='.1000.000000.', func=locale.format_string) # test floats - testformat("--> %10.2f", 1000.0, grouping=1, output='--> 1,000.00', + testformat("--> %10.2f", 1000.0, grouping=1, output='--> 1%s000.00' % sep, func=locale.format_string) # test asterisk formats testformat("%10.*f", (2, 1000.0), grouping=0, output=' 1000.00', func=locale.format_string) - testformat("%*.*f", (10, 2, 1000.0), grouping=1, output=' 1,000.00', + testformat("%*.*f", (10, 2, 1000.0), grouping=1, output=' 1%s000.00' % sep, func=locale.format_string) # test more-in-one testformat("int %i float %.2f str %s", (1000, 1000.0, 'str'), grouping=1, - output='int 1,000 float 1,000.00 str str', func=locale.format_string) + output='int 1%s000 float 1%s000.00 str str' % (sep, sep), + func=locale.format_string) finally: locale.setlocale(locale.LC_NUMERIC, oldlocale) From python-checkins at python.org Thu May 18 08:51:47 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 18 May 2006 08:51:47 +0200 (CEST) Subject: [Python-checkins] r46036 - python/trunk/Lib/cookielib.py python/trunk/Lib/urllib2.py Message-ID: <20060518065147.866091E4009@bag.python.org> Author: neal.norwitz Date: Thu May 18 08:51:46 2006 New Revision: 46036 Modified: python/trunk/Lib/cookielib.py python/trunk/Lib/urllib2.py Log: Little cleanup Modified: python/trunk/Lib/cookielib.py ============================================================================== --- python/trunk/Lib/cookielib.py (original) +++ python/trunk/Lib/cookielib.py Thu May 18 08:51:46 2006 @@ -36,13 +36,13 @@ import httplib # only for the default HTTP port from calendar import timegm -debug = 0 # set to true to enable debugging via the logging module +debug = False # set to True to enable debugging via the logging module logger = None def _debug(*args): - global logger if not debug: return + global logger if not logger: import logging logger = logging.getLogger("cookielib") Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Thu May 18 08:51:46 2006 @@ -165,7 +165,7 @@ pass # copied from cookielib.py -cut_port_re = re.compile(r":\d+$") +_cut_port_re = re.compile(r":\d+$") def request_host(request): """Return request-host, as defined by RFC 2965. @@ -179,7 +179,7 @@ host = request.get_header("Host", "") # remove port, if present - host = cut_port_re.sub("", host, 1) + host = _cut_port_re.sub("", host, 1) return host.lower() class Request: From python-checkins at python.org Thu May 18 09:01:31 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 18 May 2006 09:01:31 +0200 (CEST) Subject: [Python-checkins] r46037 - in python/trunk: Doc/lib/libfuncs.tex Lib/test/test_file.py Misc/NEWS Objects/fileobject.c Message-ID: <20060518070131.1B0B71E4009@bag.python.org> Author: georg.brandl Date: Thu May 18 09:01:27 2006 New Revision: 46037 Modified: python/trunk/Doc/lib/libfuncs.tex python/trunk/Lib/test/test_file.py python/trunk/Misc/NEWS python/trunk/Objects/fileobject.c Log: Bug #1462152: file() now checks more thoroughly for invalid mode strings and removes a possible "U" before passing the mode to the C library function. Modified: python/trunk/Doc/lib/libfuncs.tex ============================================================================== --- python/trunk/Doc/lib/libfuncs.tex (original) +++ python/trunk/Doc/lib/libfuncs.tex Thu May 18 09:01:27 2006 @@ -418,7 +418,7 @@ that differentiate between binary and text files (else it is ignored). If the file cannot be opened, \exception{IOError} is raised. - + In addition to the standard \cfunction{fopen()} values \var{mode} may be \code{'U'} or \code{'rU'}. If Python is built with universal newline support (the default) the file is opened as a text file, but @@ -434,6 +434,9 @@ have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'}, or a tuple containing all the newline types seen. + Python enforces that the mode, after stripping \code{'U'}, begins with + \code{'r'}, \code{'w'} or \code{'a'}. + If \var{mode} is omitted, it defaults to \code{'r'}. When opening a binary file, you should append \code{'b'} to the \var{mode} value for improved portability. (It's useful even on systems which don't @@ -456,6 +459,9 @@ determine whether this is the case.} \versionadded{2.2} + + \versionchanged[Restriction on first letter of mode string + introduced]{2.5} \end{funcdesc} \begin{funcdesc}{filter}{function, list} Modified: python/trunk/Lib/test/test_file.py ============================================================================== --- python/trunk/Lib/test/test_file.py (original) +++ python/trunk/Lib/test/test_file.py Thu May 18 09:01:27 2006 @@ -136,7 +136,7 @@ bad_mode = "qwerty" try: open(TESTFN, bad_mode) -except IOError, msg: +except ValueError, msg: if msg[0] != 0: s = str(msg) if s.find(TESTFN) != -1 or s.find(bad_mode) == -1: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu May 18 09:01:27 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Bug #1462152: file() now checks more thoroughly for invalid mode + strings and removes a possible "U" before passing the mode to the + C library function. + - Patch #1488312, Fix memory alignment problem on SPARC in unicode - Bug #1487966: Fix SystemError with conditional expression in assignment Modified: python/trunk/Objects/fileobject.c ============================================================================== --- python/trunk/Objects/fileobject.c (original) +++ python/trunk/Objects/fileobject.c Thu May 18 09:01:27 2006 @@ -136,46 +136,45 @@ /* check for known incorrect mode strings - problem is, platforms are free to accept any mode characters they like and are supposed to ignore stuff they don't understand... write or append mode with - universal newline support is expressly forbidden by PEP 278. */ + universal newline support is expressly forbidden by PEP 278. + Additionally, remove the 'U' from the mode string as platforms + won't know what it is. */ /* zero return is kewl - one is un-kewl */ static int -check_the_mode(char *mode) +sanitize_the_mode(char *mode) { + char *upos; size_t len = strlen(mode); - switch (len) { - case 0: + if (!len) { PyErr_SetString(PyExc_ValueError, "empty mode string"); return 1; + } - /* reject wU, aU */ - case 2: - switch (mode[0]) { - case 'w': - case 'a': - if (mode[1] == 'U') { - PyErr_SetString(PyExc_ValueError, - "invalid mode string"); - return 1; - } - break; + upos = strchr(mode, 'U'); + if (upos) { + memmove(upos, upos+1, len-(upos-mode)); /* incl null char */ + + if (mode[0] == 'w' || mode[0] == 'a') { + PyErr_Format(PyExc_ValueError, "universal newline " + "mode can only be used with modes " + "starting with 'r'"); + return 1; } - break; - /* reject w+U, a+U, wU+, aU+ */ - case 3: - switch (mode[0]) { - case 'w': - case 'a': - if ((mode[1] == '+' && mode[2] == 'U') || - (mode[1] == 'U' && mode[2] == '+')) { - PyErr_SetString(PyExc_ValueError, - "invalid mode string"); - return 1; - } - break; + if (mode[0] != 'r') { + memmove(mode+1, mode, strlen(mode)+1); + mode[0] = 'r'; } - break; + + if (!strchr(mode, 'b')) { + memmove(mode+2, mode+1, strlen(mode)); + mode[1] = 'b'; + } + } else if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') { + PyErr_Format(PyExc_ValueError, "mode string must begin with " + "one of 'r', 'w', 'a' or 'U', not '%.200s'", mode); + return 1; } return 0; @@ -184,6 +183,7 @@ static PyObject * open_the_file(PyFileObject *f, char *name, char *mode) { + char *newmode; assert(f != NULL); assert(PyFile_Check(f)); #ifdef MS_WINDOWS @@ -195,8 +195,18 @@ assert(mode != NULL); assert(f->f_fp == NULL); - if (check_the_mode(mode)) + /* probably need to replace 'U' by 'rb' */ + newmode = PyMem_MALLOC(strlen(mode) + 3); + if (!newmode) { + PyErr_NoMemory(); return NULL; + } + strcpy(newmode, mode); + + if (sanitize_the_mode(newmode)) { + f = NULL; + goto cleanup; + } /* rexec.py can't stop a user from getting the file() constructor -- all they have to do is get *any* file object f, and then do @@ -204,16 +214,15 @@ if (PyEval_GetRestricted()) { PyErr_SetString(PyExc_IOError, "file() constructor not accessible in restricted mode"); - return NULL; + f = NULL; + goto cleanup; } errno = 0; - if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) - mode = "rb"; #ifdef MS_WINDOWS if (PyUnicode_Check(f->f_name)) { PyObject *wmode; - wmode = PyUnicode_DecodeASCII(mode, strlen(mode), NULL); + wmode = PyUnicode_DecodeASCII(newmode, strlen(newmode), NULL); if (f->f_name && wmode) { Py_BEGIN_ALLOW_THREADS /* PyUnicode_AS_UNICODE OK without thread @@ -227,7 +236,7 @@ #endif if (NULL == f->f_fp && NULL != name) { Py_BEGIN_ALLOW_THREADS - f->f_fp = fopen(name, mode); + f->f_fp = fopen(name, newmode); Py_END_ALLOW_THREADS } @@ -254,6 +263,10 @@ } if (f != NULL) f = dircheck(f); + +cleanup: + PyMem_FREE(newmode); + return (PyObject *)f; } From python-checkins at python.org Thu May 18 09:20:05 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 18 May 2006 09:20:05 +0200 (CEST) Subject: [Python-checkins] r46038 - python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060518072005.EC84B1E4009@bag.python.org> Author: georg.brandl Date: Thu May 18 09:20:05 2006 New Revision: 46038 Modified: python/trunk/Doc/lib/libstdtypes.tex Log: Bug #1490688: properly document %e, %f, %g format subtleties. Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Thu May 18 09:20:05 2006 @@ -970,20 +970,22 @@ \lineiii{u}{Unsigned decimal.}{} \lineiii{x}{Unsigned hexadecimal (lowercase).}{(2)} \lineiii{X}{Unsigned hexadecimal (uppercase).}{(2)} - \lineiii{e}{Floating point exponential format (lowercase).}{} - \lineiii{E}{Floating point exponential format (uppercase).}{} - \lineiii{f}{Floating point decimal format.}{} - \lineiii{F}{Floating point decimal format.}{} - \lineiii{g}{Same as \character{e} if exponent is greater than -4 or - less than precision, \character{f} otherwise.}{} - \lineiii{G}{Same as \character{E} if exponent is greater than -4 or - less than precision, \character{F} otherwise.}{} + \lineiii{e}{Floating point exponential format (lowercase).}{(3)} + \lineiii{E}{Floating point exponential format (uppercase).}{(3)} + \lineiii{f}{Floating point decimal format.}{(3)} + \lineiii{F}{Floating point decimal format.}{(3)} + \lineiii{g}{Floating point format. Uses exponential format + if exponent is greater than -4 or less than precision, + decimal format otherwise.}{(4)} + \lineiii{G}{Floating point format. Uses exponential format + if exponent is greater than -4 or less than precision, + decimal format otherwise.}{(4)} \lineiii{c}{Single character (accepts integer or single character string).}{} \lineiii{r}{String (converts any python object using - \function{repr()}).}{(3)} + \function{repr()}).}{(5)} \lineiii{s}{String (converts any python object using - \function{str()}).}{(4)} + \function{str()}).}{(6)} \lineiii{\%}{No argument is converted, results in a \character{\%} character in the result.}{} \end{tableiii} @@ -1003,10 +1005,27 @@ formatting of the number if the leading character of the result is not already a zero. \item[(3)] - The \code{\%r} conversion was added in Python 2.0. + The alternate form causes the result to always contain a decimal + point, even if no digits follow it. + + The precision determines the number of digits after the decimal + point and defaults to 6. \item[(4)] + The alternate form causes the result to always contain a decimal + point, and trailing zeroes are not removed as they would + otherwise be. + + The precision determines the number of significant digits before + and after the decimal point and defaults to 6. + \item[(5)] + The \code{\%r} conversion was added in Python 2.0. + + The precision determines the maximal number of characters used. + \item[(6)] If the object or format provided is a \class{unicode} string, the resulting string will also be \class{unicode}. + + The precision determines the maximal number of characters used. \end{description} % XXX Examples? From python-checkins at python.org Thu May 18 09:28:59 2006 From: python-checkins at python.org (vinay.sajip) Date: Thu, 18 May 2006 09:28:59 +0200 (CEST) Subject: [Python-checkins] r46039 - python/trunk/Lib/logging/__init__.py Message-ID: <20060518072859.082CD1E4020@bag.python.org> Author: vinay.sajip Date: Thu May 18 09:28:58 2006 New Revision: 46039 Modified: python/trunk/Lib/logging/__init__.py Log: Changed status from "beta" to "production"; since logging has been part of the stdlib since 2.3, it should be safe to make this assertion ;-) Modified: python/trunk/Lib/logging/__init__.py ============================================================================== --- python/trunk/Lib/logging/__init__.py (original) +++ python/trunk/Lib/logging/__init__.py Thu May 18 09:28:58 2006 @@ -40,7 +40,7 @@ thread = None __author__ = "Vinay Sajip " -__status__ = "beta" +__status__ = "production" __version__ = "0.4.9.9" __date__ = "06 February 2006" From python-checkins at python.org Thu May 18 11:04:17 2006 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 18 May 2006 11:04:17 +0200 (CEST) Subject: [Python-checkins] r46040 - in python/trunk/Mac: OSX/IDLE/Info.plist OSX/IDLE/Makefile.in OSX/Makefile.in OSX/PythonLauncher/English.lproj/InfoPlist.strings OSX/PythonLauncher/Info.plist OSX/PythonLauncher/Makefile.in OSXResources/app/Resources/PythonApplet.icns Message-ID: <20060518090417.3B07F1E4009@bag.python.org> Author: ronald.oussoren Date: Thu May 18 11:04:15 2006 New Revision: 46040 Added: python/trunk/Mac/OSX/IDLE/Info.plist Removed: python/trunk/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings Modified: python/trunk/Mac/OSX/IDLE/Makefile.in python/trunk/Mac/OSX/Makefile.in python/trunk/Mac/OSX/PythonLauncher/Info.plist python/trunk/Mac/OSX/PythonLauncher/Makefile.in python/trunk/Mac/OSXResources/app/Resources/PythonApplet.icns Log: Fix some minor issues with the generated application bundles on MacOSX Added: python/trunk/Mac/OSX/IDLE/Info.plist ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/IDLE/Info.plist Thu May 18 11:04:15 2006 @@ -0,0 +1,55 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + py + pyw + + CFBundleTypeIconFile + PythonSource.icns + CFBundleTypeName + Python Script + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + pyc + pyo + + CFBundleTypeIconFile + PythonCompiled.icns + CFBundleTypeName + Python Bytecode Document + CFBundleTypeRole + Editor + + + CFBundleExecutable + IDLE + CFBundleGetInfoString + 2.5, ? 001-2006 Python Software Foundation + CFBundleIconFile + IDLE.icns + CFBundleIdentifier + org.python.IDLE + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + IDLE + CFBundlePackageType + APPL + CFBundleShortVersionString + 2.5 + CFBundleVersion + 2.5 + + Modified: python/trunk/Mac/OSX/IDLE/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/IDLE/Makefile.in (original) +++ python/trunk/Mac/OSX/IDLE/Makefile.in Thu May 18 11:04:15 2006 @@ -1,3 +1,4 @@ +prefix=@prefix@ CC=@CC@ LD=@CC@ BASECFLAGS=@BASECFLAGS@ @@ -27,7 +28,8 @@ install: IDLE.app test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)" -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" - cp -r IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)" + cp -PR IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)" + touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" clean: rm -rf IDLE.app @@ -40,9 +42,11 @@ $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \ --builddir=. \ --name=IDLE \ + --link-exec \ + --plist=$(srcdir)/Info.plist \ --mainprogram=$(srcdir)/idlemain.py \ --iconfile=$(srcdir)/../Icons/IDLE.icns \ - --bundle-id=org.python.IDLE \ --resource=$(srcdir)/../Icons/PythonSource.icns \ --resource=$(srcdir)/../Icons/PythonCompiled.icns \ + --python=$(prefix)/Resources/Python.app/Contents/MacOS/Python \ build Modified: python/trunk/Mac/OSX/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/Makefile.in (original) +++ python/trunk/Mac/OSX/Makefile.in Thu May 18 11:04:15 2006 @@ -74,9 +74,10 @@ for fn in idle pydoc python-config ;\ do \ mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ - ln -sf "$${fn}$(VERSION)" "$${fn}" ;\ + ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\ done - rm -f "$(DESTDIR)$(prefix)/bin/smtpd.py" + mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" + ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" pythonw: $(srcdir)/Tools/pythonw.c @@ -142,7 +143,7 @@ $(BUILDPYTHON) $(srcdir)/../scripts/BuildApplet.py \ --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONAPP) \ - --output "$(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app" \ + --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \ $(srcdir)/../scripts/BuildApplet.py MACLIBDEST=$(LIBDEST)/plat-mac @@ -221,9 +222,9 @@ checkapplepython: - @if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \ + @if ! $(BUILDPYTHON) $(srcdir)/fixapplepython23.py -n; then \ echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ - echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \ + echo "* WARNING: Run $(srcdir)/fixapplepython23.py with \"sudo\" to fix this."; \ fi Deleted: /python/trunk/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings ============================================================================== Binary files /python/trunk/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings Thu May 18 11:04:15 2006 and (empty file) differ Modified: python/trunk/Mac/OSX/PythonLauncher/Info.plist ============================================================================== --- python/trunk/Mac/OSX/PythonLauncher/Info.plist (original) +++ python/trunk/Mac/OSX/PythonLauncher/Info.plist Thu May 18 11:04:15 2006 @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - 2.5, ? 2001-2006 Python Software Foundation + 2.5, ? 001-2006 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier @@ -48,7 +48,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - PythonLauncher + Python Launcher CFBundlePackageType APPL CFBundleShortVersionString Modified: python/trunk/Mac/OSX/PythonLauncher/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/PythonLauncher/Makefile.in (original) +++ python/trunk/Mac/OSX/PythonLauncher/Makefile.in Thu May 18 11:04:15 2006 @@ -29,6 +29,7 @@ test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)" -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)" + touch "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" clean: rm -f *.o "Python Launcher" Modified: python/trunk/Mac/OSXResources/app/Resources/PythonApplet.icns ============================================================================== Binary files. No diff available. From buildbot at python.org Thu May 18 11:23:25 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 18 May 2006 09:23:25 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060518092325.92FC61E4009@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/141 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz,vinay.sajip Build Had Warnings: warnings test sincerely, -The Buildbot From jimjjewett at gmail.com Thu May 18 18:31:03 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 18 May 2006 12:31:03 -0400 Subject: [Python-checkins] r46033 - python/trunk/Lib/tarfile.py In-Reply-To: <20060518061120.70A051E400B@bag.python.org> References: <20060518061120.70A051E400B@bag.python.org> Message-ID: Thanks. On 5/18/06, georg.brandl wrote: > Author: georg.brandl > Date: Thu May 18 08:11:19 2006 > New Revision: 46033 > > Modified: > python/trunk/Lib/tarfile.py > Log: > Amendments to patch #1484695. > > > > Modified: python/trunk/Lib/tarfile.py > ============================================================================== > --- python/trunk/Lib/tarfile.py (original) > +++ python/trunk/Lib/tarfile.py Thu May 18 08:11:19 2006 > @@ -169,7 +169,7 @@ > s = "%0*o" % (digits - 1, n) + NUL > else: > if posix: > - raise ValueError, "overflow in number field" > + raise ValueError("overflow in number field") > > if n < 0: > # XXX We mimic GNU tar's behaviour with negative numbers, > @@ -211,13 +211,13 @@ > for b in xrange(blocks): > buf = src.read(BUFSIZE) > if len(buf) < BUFSIZE: > - raise IOError, "end of file reached" > + raise IOError("end of file reached") > dst.write(buf) > > if remainder != 0: > buf = src.read(remainder) > if len(buf) < remainder: > - raise IOError, "end of file reached" > + raise IOError("end of file reached") > dst.write(buf) > return > > @@ -349,7 +349,7 @@ > try: > import zlib > except ImportError: > - raise CompressionError, "zlib module is not available" > + raise CompressionError("zlib module is not available") > self.zlib = zlib > self.crc = zlib.crc32("") > if mode == "r": > @@ -361,7 +361,7 @@ > try: > import bz2 > except ImportError: > - raise CompressionError, "bz2 module is not available" > + raise CompressionError("bz2 module is not available") > if mode == "r": > self.dbuf = "" > self.cmp = bz2.BZ2Decompressor() > @@ -437,9 +437,9 @@ > > # taken from gzip.GzipFile with some alterations > if self.__read(2) != "\037\213": > - raise ReadError, "not a gzip file" > + raise ReadError("not a gzip file") > if self.__read(1) != "\010": > - raise CompressionError, "unsupported compression method" > + raise CompressionError("unsupported compression method") > > flag = ord(self.__read(1)) > self.__read(6) > @@ -475,7 +475,7 @@ > self.read(self.bufsize) > self.read(remainder) > else: > - raise StreamError, "seeking backwards is not allowed" > + raise StreamError("seeking backwards is not allowed") > return self.pos > > def read(self, size=None): > @@ -692,7 +692,7 @@ > """Read operation for regular files. > """ > if self.closed: > - raise ValueError, "file is closed" > + raise ValueError("file is closed") > self.fileobj.seek(self.offset + self.pos) > bytesleft = self.size - self.pos > if size is None: > @@ -706,7 +706,7 @@ > """Read operation for sparse files. > """ > if self.closed: > - raise ValueError, "file is closed" > + raise ValueError("file is closed") > > if size is None: > size = self.size - self.pos > @@ -766,7 +766,7 @@ > """Get an iterator over the file object. > """ > if self.closed: > - raise ValueError, "I/O operation on closed file" > + raise ValueError("I/O operation on closed file") > return self > > def next(self): > @@ -822,9 +822,9 @@ > """Construct a TarInfo object from a 512 byte string buffer. > """ > if len(buf) != BLOCKSIZE: > - raise ValueError, "truncated header" > + raise ValueError("truncated header") > if buf.count(NUL) == BLOCKSIZE: > - raise ValueError, "empty header" > + raise ValueError("empty header") > > tarinfo = cls() > tarinfo.buf = buf > @@ -844,7 +844,7 @@ > tarinfo.prefix = buf[345:500] > > if tarinfo.chksum not in calc_chksums(buf): > - raise ValueError, "invalid header" > + raise ValueError("invalid header") > return tarinfo > > def tobuf(self, posix=False): > @@ -930,7 +930,7 @@ > self.name = name > > if len(mode) > 1 or mode not in "raw": > - raise ValueError, "mode must be 'r', 'a' or 'w'" > + raise ValueError("mode must be 'r', 'a' or 'w'") > self._mode = mode > self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] > > @@ -1010,7 +1010,7 @@ > """ > > if not name and not fileobj: > - raise ValueError, "nothing to open" > + raise ValueError("nothing to open") > > if mode in ("r", "r:*"): > # Find out which *open() is appropriate for opening the file. > @@ -1020,7 +1020,7 @@ > return func(name, "r", fileobj) > except (ReadError, CompressionError): > continue > - raise ReadError, "file could not be opened successfully" > + raise ReadError("file could not be opened successfully") > > elif ":" in mode: > filemode, comptype = mode.split(":", 1) > @@ -1032,7 +1032,7 @@ > if comptype in cls.OPEN_METH: > func = getattr(cls, cls.OPEN_METH[comptype]) > else: > - raise CompressionError, "unknown compression type %r" % comptype > + raise CompressionError("unknown compression type %r" % comptype) > return func(name, filemode, fileobj) > > elif "|" in mode: > @@ -1041,7 +1041,7 @@ > comptype = comptype or "tar" > > if filemode not in "rw": > - raise ValueError, "mode must be 'r' or 'w'" > + raise ValueError("mode must be 'r' or 'w'") > > t = cls(name, filemode, > _Stream(name, filemode, comptype, fileobj, bufsize)) > @@ -1051,14 +1051,14 @@ > elif mode in "aw": > return cls.taropen(name, mode, fileobj) > > - raise ValueError, "undiscernible mode" > + raise ValueError("undiscernible mode") > > @classmethod > def taropen(cls, name, mode="r", fileobj=None): > """Open uncompressed tar archive name for reading or writing. > """ > if len(mode) > 1 or mode not in "raw": > - raise ValueError, "mode must be 'r', 'a' or 'w'" > + raise ValueError("mode must be 'r', 'a' or 'w'") > return cls(name, mode, fileobj) > > @classmethod > @@ -1067,13 +1067,13 @@ > Appending is not allowed. > """ > if len(mode) > 1 or mode not in "rw": > - raise ValueError, "mode must be 'r' or 'w'" > + raise ValueError("mode must be 'r' or 'w'") > > try: > import gzip > gzip.GzipFile > except (ImportError, AttributeError): > - raise CompressionError, "gzip module is not available" > + raise CompressionError("gzip module is not available") > > pre, ext = os.path.splitext(name) > pre = os.path.basename(pre) > @@ -1094,7 +1094,7 @@ > gzip.GzipFile(name, mode, compresslevel, fileobj) > ) > except IOError: > - raise ReadError, "not a gzip file" > + raise ReadError("not a gzip file") > t._extfileobj = False > return t > > @@ -1104,12 +1104,12 @@ > Appending is not allowed. > """ > if len(mode) > 1 or mode not in "rw": > - raise ValueError, "mode must be 'r' or 'w'." > + raise ValueError("mode must be 'r' or 'w'.") > > try: > import bz2 > except ImportError: > - raise CompressionError, "bz2 module is not available" > + raise CompressionError("bz2 module is not available") > > pre, ext = os.path.splitext(name) > pre = os.path.basename(pre) > @@ -1127,7 +1127,7 @@ > try: > t = cls.taropen(tarname, mode, fileobj) > except IOError: > - raise ReadError, "not a bzip2 file" > + raise ReadError("not a bzip2 file") > t._extfileobj = False > return t > > @@ -1169,7 +1169,7 @@ > """ > tarinfo = self._getmember(name) > if tarinfo is None: > - raise KeyError, "filename %r not found" % name > + raise KeyError("filename %r not found" % name) > return tarinfo > > def getmembers(self): > @@ -1388,15 +1388,14 @@ > > if tarinfo.size > MAXSIZE_MEMBER: > if self.posix: > - raise ValueError, "file is too large (>= 8 GB)" > + raise ValueError("file is too large (>= 8 GB)") > else: > self._dbg(2, "tarfile: Created GNU tar largefile header") > > > if len(tarinfo.linkname) > LENGTH_LINK: > if self.posix: > - raise ValueError, "linkname is too long (>%d)" \ > - % (LENGTH_LINK) > + raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) > else: > self._create_gnulong(tarinfo.linkname, GNUTYPE_LONGLINK) > tarinfo.linkname = tarinfo.linkname[:LENGTH_LINK -1] > @@ -1412,8 +1411,7 @@ > prefix = prefix[:-1] > > if not prefix or len(name) > LENGTH_NAME: > - raise ValueError, "name is too long (>%d)" \ > - % (LENGTH_NAME) > + raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) > > tarinfo.name = name > tarinfo.prefix = prefix > @@ -1539,7 +1537,7 @@ > # A small but ugly workaround for the case that someone tries > # to extract a (sym)link as a file-object from a non-seekable > # stream of tar blocks. > - raise StreamError, "cannot extract (sym)link as file object" > + raise StreamError("cannot extract (sym)link as file object") > else: > # A (sym)link's file object is its target's file object. > return self.extractfile(self._getmember(tarinfo.linkname, > @@ -1639,13 +1637,13 @@ > if hasattr(os, "mkfifo"): > os.mkfifo(targetpath) > else: > - raise ExtractError, "fifo not supported by system" > + raise ExtractError("fifo not supported by system") > > def makedev(self, tarinfo, targetpath): > """Make a character or block device called targetpath. > """ > if not hasattr(os, "mknod") or not hasattr(os, "makedev"): > - raise ExtractError, "special devices not supported by system" > + raise ExtractError("special devices not supported by system") > > mode = tarinfo.mode > if tarinfo.isblk(): > @@ -1681,7 +1679,7 @@ > try: > shutil.copy2(linkpath, targetpath) > except EnvironmentError, e: > - raise IOError, "link could not be created" > + raise IOError("link could not be created") > > def chown(self, tarinfo, targetpath): > """Set owner of targetpath according to tarinfo. > @@ -1709,7 +1707,7 @@ > if sys.platform != "os2emx": > os.chown(targetpath, u, g) > except EnvironmentError, e: > - raise ExtractError, "could not change owner" > + raise ExtractError("could not change owner") > > def chmod(self, tarinfo, targetpath): > """Set file permissions of targetpath according to tarinfo. > @@ -1718,7 +1716,7 @@ > try: > os.chmod(targetpath, tarinfo.mode) > except EnvironmentError, e: > - raise ExtractError, "could not change mode" > + raise ExtractError("could not change mode") > > def utime(self, tarinfo, targetpath): > """Set modification time of targetpath according to tarinfo. > @@ -1732,7 +1730,7 @@ > try: > os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) > except EnvironmentError, e: > - raise ExtractError, "could not change modification time" > + raise ExtractError("could not change modification time") > > #-------------------------------------------------------------------------- > def next(self): > @@ -1755,6 +1753,13 @@ > > try: > tarinfo = TarInfo.frombuf(buf) > + > + # We shouldn't rely on this checksum, because some tar programs > + # calculate it differently and it is merely validating the > + # header block. We could just as well skip this part, which would > + # have a slight effect on performance... > + if tarinfo.chksum not in calc_chksums(buf): > + self._dbg(1, "tarfile: Bad Checksum %r" % tarinfo.name) > > # Set the TarInfo object's offset to the current position of the > # TarFile and set self.offset to the position where the data blocks > @@ -1766,12 +1771,14 @@ > > except ValueError, e: > if self.ignore_zeros: > - self._dbg(2, "0x%X: %s" % (self.offset, e)) > + self._dbg(2, "0x%X: empty or invalid block: %s" % > + (self.offset, e)) > self.offset += BLOCKSIZE > continue > else: > if self.offset == 0: > - raise ReadError, str(e) > + raise ReadError("empty, unreadable or compressed " > + "file: %s" % e) > return None > break > > @@ -1958,9 +1965,9 @@ > corresponds to TarFile's mode. > """ > if self.closed: > - raise IOError, "%s is closed" % self.__class__.__name__ > + raise IOError("%s is closed" % self.__class__.__name__) > if mode is not None and self._mode not in mode: > - raise IOError, "bad operation for mode %r" % self._mode > + raise IOError("bad operation for mode %r" % self._mode) > > def __iter__(self): > """Provide an iterator object. > @@ -2096,7 +2103,7 @@ > elif compression == TAR_GZIPPED: > self.tarfile = TarFile.gzopen(file, mode) > else: > - raise ValueError, "unknown compression constant" > + raise ValueError("unknown compression constant") > if mode[0:1] == "r": > members = self.tarfile.getmembers() > for m in members: > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Fri May 19 02:03:56 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 19 May 2006 02:03:56 +0200 (CEST) Subject: [Python-checkins] r46041 - python/trunk/Doc/whatsnew/whatsnew20.tex Message-ID: <20060519000356.215D71E400E@bag.python.org> Author: andrew.kuchling Date: Fri May 19 02:03:55 2006 New Revision: 46041 Modified: python/trunk/Doc/whatsnew/whatsnew20.tex Log: Typo fix; add clarifying word Modified: python/trunk/Doc/whatsnew/whatsnew20.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew20.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew20.tex Fri May 19 02:03:55 2006 @@ -330,7 +330,7 @@ [ expression for expr in sequence1 for expr2 in sequence2 ... for exprN in sequenceN - if condition + if condition ] \end{verbatim} The \keyword{for}...\keyword{in} clauses contain the sequences to be @@ -356,7 +356,7 @@ # resulting list. \end{verbatim} -This means that when there are \keyword{for}...\keyword{in} clauses, +This means that when there are multiple \keyword{for}...\keyword{in} clauses, the resulting list will be equal to the product of the lengths of all the sequences. If you have two lists of length 3, the output list is 9 elements long: From python-checkins at python.org Fri May 19 02:04:44 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 19 May 2006 02:04:44 +0200 (CEST) Subject: [Python-checkins] r46042 - sandbox/trunk/Doc/functional.rst Message-ID: <20060519000444.B5C641E400B@bag.python.org> Author: andrew.kuchling Date: Fri May 19 02:04:44 2006 New Revision: 46042 Modified: sandbox/trunk/Doc/functional.rst Log: Add two sections Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Fri May 19 02:04:44 2006 @@ -4,7 +4,11 @@ **Incomplete Draft** In this document, we'll take a tour of Python's features that are -well-suited to implementing programs in a functional style. +well-suited to implementing programs in a functional style. +After an introduction to the concepts of functional programming, +we'll look at language features such as iterators and generators +and relevant library modules such as the ``itertools`` module. + Introduction ---------------------- @@ -60,6 +64,11 @@ a pointless skill like writing a BASIC interpreter in {\TeX}. There are theoretical and practical advantages to the functional style: +* Formal provability. +* Modularity. +* Composability. +* Ease of debugging and testing. + Formal provability '''''''''''''''''''''' @@ -97,101 +106,293 @@ Modularity '''''''''''''''''''''' -Ease of debugging -'''''''''''''''''''''' +.. comment + Small functions that do one thing. Composability '''''''''''''''''''''' +.. comment + + You assemble a toolbox of functions that can be mixed -* - Formal provability - Not very relevant to Python - Modularity - Small functions that do one thing - Debuggability: +Ease of debugging +'''''''''''''''''''''' + +.. comment Easy to test due to lack of state Easy to verify output from intermediate steps - Composability - You assemble a toolbox of functions that can be mixed -Functional programming can be considered the opposite of -object-oriented programming. Objects are little capsules containing -some internal state, and there's a collection of method calls that let -you modify this state. -The Idea of Functional Programming -''''''''''''''''''''''''''''''''''''''' - Programs built out of functions - Functions are strictly input-output, no internal state - Opposed to OO programming, where objects have state - -Why Functional Programming? -''''''''''''''''''''''''''''''''''' + Formal provability - Assignment is difficult to reason about Not very relevant to Python Modularity Small functions that do one thing + Composability + You assemble a toolbox of functions that can be mixed Debuggability: Easy to test due to lack of state Easy to verify output from intermediate steps - Composability - You assemble a toolbox of functions that can be mixed -Tackling a problem -------------------------- - Need a significant example +Functional programming can be considered the opposite of +object-oriented programming. Objects are little capsules containing +some internal state along with a collection of method calls that let +you modify this state. + + Iterators ----------------------- -Basic idea - Object which supports next() and raises StopIteration - Iterators don't need to end +Iterators are the fundamental Python feature that provides +the foundation for writing functional-style programs. + +An iterator is an object representing a stream of data that returns +the data one element at a time. A Python iterator must support a +method called ``next()`` that takes no arguments and always returns +the next element of the stream. If there are no more elements in the +stream, ``next()`` must raise the ``StopIteration`` exception. +Iterators don't have to be finite, though; it's perfectly reasonable +to write an iterator that produces an infinite stream of data. + +The built-in ``iter()`` function takes an arbitrary object and tries +to return an iterator that will return the object's contents or +elements, raising ``TypeError`` if the object doesn't support +iteration. Several of Python's built-in data types support iteration, +the most common being lists and dictionaries. + +You can experiment with the iteration interface manually:: + + >>> L = [1,2,3] + >>> it = iter(L) + >>> print it + + >>> it.next() + 1 + >>> it.next() + 2 + >>> it.next() + 3 + >>> it.next() + Traceback (most recent call last): + File "", line 1, in ? + StopIteration + >>> + +Python expects iterable objects in several different contexts, the +most important being the ``for`` statement. In the statement ``for X in Y``, +Y must be an iterator or some object for which ``iter()`` can create +an iterator. These two statements are equivalent:: + + for i in iter(obj): + print i + + for i in obj: + print i + +Iterators can be materialized as lists or tuples by using the ``list()`` or ``tuple()`` +constructor functions:: + + >>> L = [1,2,3] + >>> iterator = iter(L) + >>> t = tuple(iterator) + >>> t + (1, 2, 3) + +Sequence unpacking also supports iterators: if you know an iterator +will return N elements, you can unpack them into an N-tuple:: + + >>> L = [1,2,3] + >>> iterator = iter(L) + >>> a,b,c = i + >>> a,b,c + (1, 2, 3) + +Built-in functions such as ``max()`` and ``min()`` can take a single +iterator argument and will return the largest or smallest element. +The ``"in"`` and ``"not in"`` operators also support iterators: ``X in +iterator`` is true if X is found in the stream returned by the +iterator. You'll run into obvious problems if the iterator is +infinite; ``max()``, ``min()``, and ``"not in"`` will never return, and +if the element X never appears in the stream, the ``"in"`` operator +won't return either. + +Note that you can only go forward in an iterator; there's no way to +get the previous element, reset the iterator, or make a copy of it. +Iterator objects can optionally provide these additional capabilities, +but the iterator protocol only specifies the \method{next()} method. +Functions may therefore consume all of the iterator's output, and if +you need to do something different with the same stream, you'll have +to create a new iterator. + + + +Data Types That Support Iterators +''''''''''''''''''''''''''''''''''' + +We've already seen how lists and tuples support iterators. In fact, +any Python sequence type, such as strings, will automatically support +creation of an iterator. + +Calling ``iter()`` on a dictionary returns an iterator that will loop +over the dictionary's keys:: + + >>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, + ... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12} + >>> for key in m: + ... print key, m[key] + Mar 3 + Feb 2 + Aug 8 + Sep 9 + May 5 + Jun 6 + Jul 7 + Jan 1 + Apr 4 + Nov 11 + Dec 12 + Oct 10 + +This is just the default behaviour. If you want to iterate over keys, +values, or key/value pairs, you can explicitly call the +\method{iterkeys()}, \method{itervalues()}, or \method{iteritems()} +methods to get an appropriate iterator. + +The ``dict()`` constructor can accept an iterator that returns a +finite stream of ``(key, value)`` tuples:: + + >>> L = [('Italy', 'Rome'), ('France', 'Paris'), ('US', 'Washington DC')] + >>> dict(iter(L)) + {'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'} + +Files also support iteration by calling the \method{readline()} +method until there are no more lines in the file. This means you can +read each line of a file like this: + +\begin{verbatim} +for line in file: + # do something for each line + ... +\end{verbatim} + +XXX sets -iter() -- returns an iterator for an object -Example: iter(list) -Objects: __iter__ returns iterator -Example: object w/ list of contents List comprehensions ----------------------- -Some built-ins support iterators, some don't. min(), max(), len(), dict(). -List comps. +Two common operations on a stream are performing some operation for +every element, or selecting a subset of elements that meet some +condition. For example, given a list of strings, you might want to +pull out all the strings containing a given substring, or strip off +trailing whitespace from each line. + +List comprehensions (or "listcomps") are a concise notation for such +operations, borrowed from the functional programming language Haskell +(\url{http://www.haskell.org}). You can strip all the whitespace from +a stream of strings with the following list comprehension:: + + line_list = [' line 1\n', 'line 2 \n', ...] + stripped_list = [line.strip() for line in line_list] + +You can select only certain elements by adding an ``"if"`` condition:: + + stripped_list = [line.strip() for line in line_list + if line != ""] + +Note that in all case the resulting ``stripped_list`` is a Python list +containing the resulting lines, not an iterator. This means that list +comprehensions aren't very useful if you're working with iterators +that return an infinite or a very large stream of data. + +List comprehensions have the form:: + + [ expression for expr in sequence1 + for expr2 in sequence2 + for expr3 in sequence3 ... + for exprN in sequenceN + if condition ] + +The elements of the generated list will be the successive +values of \var{expression}. The final \keyword{if} clause is +optional; if present, \var{expression} is only evaluated and added to +the result when \var{condition} is true. + +The ``for...in`` clauses contain the sequences to be iterated over. +The sequences do not have to be the same length, because they are +iterated over from left to right, **not** in parallel. For each +element in ``sequence1``, ``sequence2`` is looped over from the +beginning. ``sequence3`` is then looped over for each +resulting pair of elements from ``sequence1`` and ``sequence2``. + +Put another way, a list comprehension is equivalent to the following +Python code: + +\begin{verbatim} +for expr1 in sequence1: + for expr2 in sequence2: + ... + for exprN in sequenceN: + if (condition): + # Append the value of + # the expression to the + # resulting list. +\end{verbatim} + +This means that when there are multiple \keyword{for}...\keyword{in} +clauses, the resulting list will be equal to the product of the +lengths of all the sequences. If you have two lists of length 3, the +output list is 9 elements long: + + seq1 = 'abc' + seq2 = (1,2,3) + >>> [ (x,y) for x in seq1 for y in seq2] + [('a', 1), ('a', 2), ('a', 3), + ('b', 1), ('b', 2), ('b', 3), + ('c', 1), ('c', 2), ('c', 3)] + +To avoid introducing an ambiguity into Python's grammar, if +``expression`` is creating a tuple, it must be surrounded with +parentheses. The first list comprehension below is a syntax error, +while the second one is correct: + + # Syntax error + [ x,y for x in seq1 for y in seq2] + # Correct + [ (x,y) for x in seq1 for y in seq2] + Generators ----------------------- -Functions where internal state is stored -{Copy bits of what's new} +Generators are a special class of functions that simplify +the task of writing certain kinds of iterators. + +XXX {Copy bits of what's new} + +Mention 2.5 additions but don't describe them. -Mention 2.5 additions but don't desribe them. The itertools module ----------------------- Small functions and the lambda statement ------------------------ +---------------------------------------------- Built-in functions ------------------------ +---------------------------------------------- -map() -'''''' +map(), filter(), reduce() -filter() -'''''''''' - -reduce() -'''''''''''' .. comment + Introduction Idea of FP Programs built out of functions From buildbot at python.org Fri May 19 02:21:23 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 19 May 2006 00:21:23 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060519002123.DDDA01E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/417 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Fri May 19 06:03:52 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 18 May 2006 21:03:52 -0700 Subject: [Python-checkins] r46040 - in python/trunk/Mac: OSX/IDLE/Info.plist OSX/IDLE/Makefile.in OSX/Makefile.in OSX/PythonLauncher/English.lproj/InfoPlist.strings OSX/PythonLauncher/Info.plist OSX/PythonLauncher/Makefile.in OSXResources/app/Resources/Py Message-ID: The copyright's don't look right--001. n -- On 5/18/06, ronald.oussoren wrote: > Author: ronald.oussoren > Date: Thu May 18 11:04:15 2006 > New Revision: 46040 > > Added: > python/trunk/Mac/OSX/IDLE/Info.plist > Modified: > python/trunk/Mac/OSX/PythonLauncher/Info.plist > Log: > Fix some minor issues with the generated application bundles on MacOSX > > > Added: python/trunk/Mac/OSX/IDLE/Info.plist > + 2.5, (c) 001-2006 Python Software Foundation > Modified: python/trunk/Mac/OSX/PythonLauncher/Info.plist > ============================================================================== > --- python/trunk/Mac/OSX/PythonLauncher/Info.plist (original) > +++ python/trunk/Mac/OSX/PythonLauncher/Info.plist Thu May 18 11:04:15 2006 > @@ -40,7 +40,7 @@ > CFBundleExecutable > PythonLauncher > CFBundleGetInfoString > - 2.5, (c) 2001-2006 Python Software Foundation > + 2.5, (c) 001-2006 Python Software Foundation > CFBundleIconFile > PythonLauncher.icns > CFBundleIdentifier From python-checkins at python.org Fri May 19 06:34:03 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 19 May 2006 06:34:03 +0200 (CEST) Subject: [Python-checkins] r46043 - peps/trunk/pep-0356.txt Message-ID: <20060519043403.5D0CD1E400E@bag.python.org> Author: neal.norwitz Date: Fri May 19 06:34:02 2006 New Revision: 46043 Modified: peps/trunk/pep-0356.txt Log: Speed up schedule a bit, rc corresponds to OSCON. Gerhard checked in docs for sqlite. Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Fri May 19 06:34:02 2006 @@ -38,11 +38,11 @@ alpha 1: April 5, 2006 [completed] alpha 2: April 27, 2006 [completed] - alpha 3: May 27, 2006 [planned] - beta 1: June 24, 2006 [planned] - beta 2: July 15, 2006 [planned] - rc 1: August 5, 2006 [planned] - final: August 19, 2006 [planned] + alpha 3: May 25, 2006 [planned] + beta 1: June 14, 2006 [planned] + beta 2: July 6, 2006 [planned] + rc 1: July 27, 2006 [planned] + final: August 3, 2006 [planned] Completed features for 2.5 @@ -155,7 +155,6 @@ - Missing documentation * ctypes (Thomas Heller) * ElementTree/cElementTree (Fredrik Lundh) - * pysqlite (Gerhard Haering) * setuptools (written, needs conversion to proper format) - AST compiler problems From python-checkins at python.org Fri May 19 08:31:24 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 19 May 2006 08:31:24 +0200 (CEST) Subject: [Python-checkins] r46044 - python/trunk/Python/ceval.c Message-ID: <20060519063124.6AED21E4024@bag.python.org> Author: neal.norwitz Date: Fri May 19 08:31:23 2006 New Revision: 46044 Modified: python/trunk/Python/ceval.c Log: Fix #132 from Coverity, retval could have been derefed if a continue inside a try failed. Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Fri May 19 08:31:23 2006 @@ -2173,6 +2173,10 @@ case CONTINUE_LOOP: retval = PyInt_FromLong(oparg); + if (!retval) { + x = NULL; + break; + } why = WHY_CONTINUE; goto fast_block_end; From python-checkins at python.org Fri May 19 08:43:51 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 19 May 2006 08:43:51 +0200 (CEST) Subject: [Python-checkins] r46045 - in python/trunk: Lib/test/test_syntax.py Python/ast.c Message-ID: <20060519064351.1C4271E400E@bag.python.org> Author: neal.norwitz Date: Fri May 19 08:43:50 2006 New Revision: 46045 Modified: python/trunk/Lib/test/test_syntax.py python/trunk/Python/ast.c Log: Fix #1474677, non-keyword argument following keyword. Modified: python/trunk/Lib/test/test_syntax.py ============================================================================== --- python/trunk/Lib/test/test_syntax.py (original) +++ python/trunk/Lib/test/test_syntax.py Fri May 19 08:43:50 2006 @@ -309,6 +309,9 @@ "unindent does not match .* level", subclass=IndentationError) + def test_kwargs_last(self): + self._check_error("int(base=10, '2')", "non-keyword arg") + def test_main(): test_support.run_unittest(SyntaxTestCase) from test import test_syntax Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Fri May 19 08:43:50 2006 @@ -1750,6 +1750,11 @@ if (TYPE(ch) == argument) { expr_ty e; if (NCH(ch) == 1) { + if (nkeywords) { + ast_error(CHILD(ch, 0), + "non-keyword arg after keyword arg"); + return NULL; + } e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; From python-checkins at python.org Fri May 19 09:01:01 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 19 May 2006 09:01:01 +0200 (CEST) Subject: [Python-checkins] r46046 - in python/trunk: Misc/ACKS Misc/NEWS configure configure.in pyconfig.h.in Message-ID: <20060519070101.D77251E4017@bag.python.org> Author: neal.norwitz Date: Fri May 19 09:00:58 2006 New Revision: 46046 Modified: python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Log: Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64. I suppose this could be backported if anyone cares. Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Fri May 19 09:00:58 2006 @@ -189,6 +189,7 @@ Stephen D Evans Tim Everett Paul Everitt +David Everly Greg Ewing Martijn Faassen Andreas Faerber Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri May 19 09:00:58 2006 @@ -81,6 +81,8 @@ Build ----- +- Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64. + - Patch #1471883: Add --enable-universalsdk. C API Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Fri May 19 09:00:58 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 45995 . +# From configure.in Revision: 46010 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -3387,7 +3387,14 @@ INSTSONAME="$LDLIBRARY".$SOVERSION ;; hp*|HP*) - LDLIBRARY='libpython$(VERSION).sl' + case `uname -m` in + ia64) + LDLIBRARY='libpython$(VERSION).so' + ;; + *) + LDLIBRARY='libpython$(VERSION).sl' + ;; + esac BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ;; @@ -10869,7 +10876,12 @@ if test -z "$SO" then case $ac_sys_system in - hp*|HP*) SO=.sl;; + hp*|HP*) + case `uname -m` in + ia64) SO=.so;; + *) SO=.sl;; + esac + ;; CYGWIN*) SO=.dll;; *) SO=.so;; esac @@ -10887,6 +10899,11 @@ fi echo "$as_me:$LINENO: result: $SO" >&5 echo "${ECHO_T}$SO" >&6 + +cat >>confdefs.h <<_ACEOF +#define SHLIB_EXT "$SO" +_ACEOF + # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Fri May 19 09:00:58 2006 @@ -611,7 +611,14 @@ INSTSONAME="$LDLIBRARY".$SOVERSION ;; hp*|HP*) - LDLIBRARY='libpython$(VERSION).sl' + case `uname -m` in + ia64) + LDLIBRARY='libpython$(VERSION).so' + ;; + *) + LDLIBRARY='libpython$(VERSION).sl' + ;; + esac BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ;; @@ -1359,7 +1366,12 @@ if test -z "$SO" then case $ac_sys_system in - hp*|HP*) SO=.sl;; + hp*|HP*) + case `uname -m` in + ia64) SO=.so;; + *) SO=.sl;; + esac + ;; CYGWIN*) SO=.dll;; *) SO=.so;; esac @@ -1376,6 +1388,7 @@ sleep 10 fi AC_MSG_RESULT($SO) +AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into Modified: python/trunk/pyconfig.h.in ============================================================================== --- python/trunk/pyconfig.h.in (original) +++ python/trunk/pyconfig.h.in Fri May 19 09:00:58 2006 @@ -754,6 +754,9 @@ /* Define if setpgrp() must be called as setpgrp(0, 0). */ #undef SETPGRP_HAVE_ARG +/* Define this to be extension of shared libraries (including the dot!). */ +#undef SHLIB_EXT + /* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS From python-checkins at python.org Fri May 19 09:05:01 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 19 May 2006 09:05:01 +0200 (CEST) Subject: [Python-checkins] r46047 - python/trunk/Python/dynload_hpux.c Message-ID: <20060519070501.6768E1E400E@bag.python.org> Author: neal.norwitz Date: Fri May 19 09:05:01 2006 New Revision: 46047 Modified: python/trunk/Python/dynload_hpux.c Log: Oops, I forgot to include this file in the last commit (46046): Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64. I suppose this could be backported if anyone cares. Modified: python/trunk/Python/dynload_hpux.c ============================================================================== --- python/trunk/Python/dynload_hpux.c (original) +++ python/trunk/Python/dynload_hpux.c Fri May 19 09:05:01 2006 @@ -14,8 +14,8 @@ #endif const struct filedescr _PyImport_DynLoadFiletab[] = { - {".sl", "rb", C_EXTENSION}, - {"module.sl", "rb", C_EXTENSION}, + {SHLIB_EXT, "rb", C_EXTENSION}, + {"module"SHLIB_EXT, "rb", C_EXTENSION}, {0, 0} }; From steve at holdenweb.com Fri May 19 11:18:24 2006 From: steve at holdenweb.com (Steve Holden) Date: Fri, 19 May 2006 10:18:24 +0100 Subject: [Python-checkins] r46040 - in python/trunk/Mac: OSX/IDLE/Info.plist OSX/IDLE/Makefile.in OSX/Makefile.in OSX/PythonLauncher/English.lproj/InfoPlist.strings OSX/PythonLauncher/Info.plist OSX/PythonLauncher/Makefile.in OSXResources/app/Resources/Py In-Reply-To: References: Message-ID: <446D8D60.2050408@holdenweb.com> Neal Norwitz wrote: > The copyright's don't look right--001. > If they ARE right this must surely be the oldest module in the distribution, and a tribute to the time machine ;-) -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From steve at holdenweb.com Fri May 19 11:24:43 2006 From: steve at holdenweb.com (Steve Holden) Date: Fri, 19 May 2006 10:24:43 +0100 Subject: [Python-checkins] r46043 - peps/trunk/pep-0356.txt In-Reply-To: <20060519043403.5D0CD1E400E@bag.python.org> References: <20060519043403.5D0CD1E400E@bag.python.org> Message-ID: <446D8EDB.8000902@holdenweb.com> neal.norwitz wrote: Please note that the "Need for Speed" sprint runs May 21 - 27. Bringing the schedule forward on Alpha 3 makes it less possible to incorporate sprint changes into the 2.5 trunk. Will it be acceptable to add new (performance) changes between Alpha 3 and beta 1, or would developers prefer to put a fourth alpha in to the schedule? The intention is there should be no major functionality added by the sprint, simply that performance should be improved, so the schedule may work. It's just a call for the release manager really, I guess. regards Steve > Author: neal.norwitz > Date: Fri May 19 06:34:02 2006 > New Revision: 46043 > > Modified: > peps/trunk/pep-0356.txt > Log: > Speed up schedule a bit, rc corresponds to OSCON. > Gerhard checked in docs for sqlite. > > > > Modified: peps/trunk/pep-0356.txt > ============================================================================== > --- peps/trunk/pep-0356.txt (original) > +++ peps/trunk/pep-0356.txt Fri May 19 06:34:02 2006 > @@ -38,11 +38,11 @@ > > alpha 1: April 5, 2006 [completed] > alpha 2: April 27, 2006 [completed] > - alpha 3: May 27, 2006 [planned] > - beta 1: June 24, 2006 [planned] > - beta 2: July 15, 2006 [planned] > - rc 1: August 5, 2006 [planned] > - final: August 19, 2006 [planned] > + alpha 3: May 25, 2006 [planned] > + beta 1: June 14, 2006 [planned] > + beta 2: July 6, 2006 [planned] > + rc 1: July 27, 2006 [planned] > + final: August 3, 2006 [planned] > > > Completed features for 2.5 > @@ -155,7 +155,6 @@ > - Missing documentation > * ctypes (Thomas Heller) > * ElementTree/cElementTree (Fredrik Lundh) > - * pysqlite (Gerhard Haering) > * setuptools (written, needs conversion to proper format) > > - AST compiler problems > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > > > -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From buildbot at python.org Fri May 19 11:25:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 19 May 2006 09:25:34 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060519092534.CB1EA1E4018@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/266 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 19 13:35:37 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 19 May 2006 13:35:37 +0200 (CEST) Subject: [Python-checkins] r46048 - peps/trunk/pep-0356.txt Message-ID: <20060519113537.407371E401E@bag.python.org> Author: andrew.kuchling Date: Fri May 19 13:35:36 2006 New Revision: 46048 Modified: peps/trunk/pep-0356.txt Log: Remove setuptools items (unless Anthony or Neal thinks it might reappear in 2.5?) Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Fri May 19 13:35:36 2006 @@ -83,8 +83,6 @@ - pysqlite - - setuptools - Other notable features - Added support for reading shadow passwords (http://python.org/sf/579435) @@ -155,7 +153,6 @@ - Missing documentation * ctypes (Thomas Heller) * ElementTree/cElementTree (Fredrik Lundh) - * setuptools (written, needs conversion to proper format) - AST compiler problems (Owner: Jeremy Hylton) From python-checkins at python.org Fri May 19 18:51:58 2006 From: python-checkins at python.org (george.yoshida) Date: Fri, 19 May 2006 18:51:58 +0200 (CEST) Subject: [Python-checkins] r46049 - peps/trunk/pep-0356.txt Message-ID: <20060519165158.D80691E400D@bag.python.org> Author: george.yoshida Date: Fri May 19 18:51:58 2006 New Revision: 46049 Modified: peps/trunk/pep-0356.txt Log: Bug #1474677 is fixed in r46045. Many thanks to Georg and Neal. Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Fri May 19 18:51:58 2006 @@ -156,8 +156,6 @@ - AST compiler problems (Owner: Jeremy Hylton) - * http://python.org/sf/1474677 foo(b=1, 2) doesn't raise SyntaxError - * eval(str(-sys.maxint - 1)) should produce an int, not long. when a constant it should not be stored in co_consts From python-checkins at python.org Fri May 19 20:17:32 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 19 May 2006 20:17:32 +0200 (CEST) Subject: [Python-checkins] r46050 - python/trunk/Mac/OSX/IDLE/idlemain.py Message-ID: <20060519181732.51F261E400E@bag.python.org> Author: ronald.oussoren Date: Fri May 19 20:17:31 2006 New Revision: 46050 Modified: python/trunk/Mac/OSX/IDLE/idlemain.py Log: * Change working directory to the users home directory, that makes the file open/save dialogs more useable. * Don't use argv emulator, its not needed for idle. Modified: python/trunk/Mac/OSX/IDLE/idlemain.py ============================================================================== --- python/trunk/Mac/OSX/IDLE/idlemain.py (original) +++ python/trunk/Mac/OSX/IDLE/idlemain.py Fri May 19 20:17:31 2006 @@ -1,7 +1,15 @@ -import argvemulator -from idlelib.PyShell import main +""" +Bootstrap script for IDLE as an application bundle. +""" import sys, os +from idlelib.PyShell import main + +# Change the current directory the user's home directory, that way we'll get +# a more useful default location in the open/save dialogs. +os.chdir(os.expanduser('~')) + + # Make sure sys.executable points to the python interpreter inside the # framework, instead of at the helper executable inside the application # bundle (the latter works, but doesn't allow access to the window server) @@ -14,6 +22,6 @@ del sys.argv[idx] break -argvemulator.ArgvCollector().mainloop() +#argvemulator.ArgvCollector().mainloop() if __name__ == '__main__': main() From buildbot at python.org Fri May 19 20:58:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 19 May 2006 18:58:01 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060519185801.9B5991E400D@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/420 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 19 21:16:35 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 19 May 2006 21:16:35 +0200 (CEST) Subject: [Python-checkins] r46052 - python/trunk/Lib/tarfile.py Message-ID: <20060519191635.1F2CA1E4016@bag.python.org> Author: tim.peters Date: Fri May 19 21:16:34 2006 New Revision: 46052 Modified: python/trunk/Lib/tarfile.py Log: Whitespace normalization. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Fri May 19 21:16:34 2006 @@ -1753,7 +1753,7 @@ try: tarinfo = TarInfo.frombuf(buf) - + # We shouldn't rely on this checksum, because some tar programs # calculate it differently and it is merely validating the # header block. We could just as well skip this part, which would From buildbot at python.org Fri May 19 21:37:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 19 May 2006 19:37:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060519193745.1B30A1E400D@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/389 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 20 07:23:45 2006 From: python-checkins at python.org (talin) Date: Sat, 20 May 2006 07:23:45 +0200 (CEST) Subject: [Python-checkins] r46053 - peps/trunk/pep-3102.txt Message-ID: <20060520052345.C480F1E400E@bag.python.org> Author: talin Date: Sat May 20 07:23:44 2006 New Revision: 46053 Modified: peps/trunk/pep-3102.txt Log: Updated post history, and added a note about the BDFL pronouncement on syntax alternatives. Modified: peps/trunk/pep-3102.txt ============================================================================== --- peps/trunk/pep-3102.txt (original) +++ peps/trunk/pep-3102.txt Sat May 20 07:23:44 2006 @@ -8,7 +8,7 @@ Content-Type: text/plain Created: 22-Apr-2006 Python-Version: 3.0 -Post-History: +Post-History: 28-Apr-2006, May-19-2006 Abstract @@ -65,7 +65,9 @@ they must be supplied via keyword. The second syntactical change is to allow the argument name to - be omitted for a varargs argument: + be omitted for a varargs argument. The meaning of this is to + allow for keyword-only arguments for functions that would not + otherwise take a varargs argument: def compare(a, b, *, key=None): ... @@ -95,7 +97,11 @@ As a convenient shortcut, we can simply omit the 'ignore' name, meaning 'don't allow any positional arguments beyond this point'. - + + (Note: After much discussion of alternative syntax proposals, the + BDFL has pronounced in favor of this 'single star' syntax for + indicating the end of positional parameters.) + Function Calling Behavior From python-checkins at python.org Sat May 20 08:17:02 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sat, 20 May 2006 08:17:02 +0200 (CEST) Subject: [Python-checkins] r46054 - python/trunk/Mac/Modules/cf/_CFmodule.c Message-ID: <20060520061702.2BC341E400E@bag.python.org> Author: ronald.oussoren Date: Sat May 20 08:17:01 2006 New Revision: 46054 Modified: python/trunk/Mac/Modules/cf/_CFmodule.c Log: Fix bug #1000914 (again). This patches a file that is generated by bgen, however the code is now the same as a current copy of bgen would generate. Without this patch most types in the Carbon.CF module are unusable. I haven't managed to coax bgen into generating a complete copy of _CFmodule.c yet :-(, hence the manual patching. Modified: python/trunk/Mac/Modules/cf/_CFmodule.c ============================================================================== --- python/trunk/Mac/Modules/cf/_CFmodule.c (original) +++ python/trunk/Mac/Modules/cf/_CFmodule.c Sat May 20 08:17:01 2006 @@ -524,7 +524,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFTypeRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args) @@ -735,7 +735,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFArrayRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args) @@ -975,7 +975,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFTypeRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args) @@ -1168,7 +1168,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFDictionaryRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args) @@ -1351,7 +1351,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFTypeRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args) @@ -1576,7 +1576,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFDataRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args) @@ -1856,7 +1856,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFTypeRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args) @@ -2583,7 +2583,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFStringRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args) @@ -2971,7 +2971,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - self->ob_type->tp_base->tp_dealloc((PyObject *)self); + CFTypeRef_Type.tp_dealloc((PyObject *)self); } static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args) From python-checkins at python.org Sat May 20 17:36:20 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 20 May 2006 17:36:20 +0200 (CEST) Subject: [Python-checkins] r46055 - python/trunk/Doc/ref/ref2.tex python/trunk/Doc/ref/ref6.tex Message-ID: <20060520153620.8A16B1E400E@bag.python.org> Author: george.yoshida Date: Sat May 20 17:36:19 2006 New Revision: 46055 Modified: python/trunk/Doc/ref/ref2.tex python/trunk/Doc/ref/ref6.tex Log: - markup fix - add clarifying words Modified: python/trunk/Doc/ref/ref2.tex ============================================================================== --- python/trunk/Doc/ref/ref2.tex (original) +++ python/trunk/Doc/ref/ref2.tex Sat May 20 17:36:19 2006 @@ -652,7 +652,7 @@ \end{verbatim} Note that numeric literals do not include a sign; a phrase like -\code{-1} is actually an expression composed of the operator +\code{-1} is actually an expression composed of the unary operator \code{-} and the literal \code{1}. Modified: python/trunk/Doc/ref/ref6.tex ============================================================================== --- python/trunk/Doc/ref/ref6.tex (original) +++ python/trunk/Doc/ref/ref6.tex Sat May 20 17:36:19 2006 @@ -809,13 +809,14 @@ That is not a future statement; it's an ordinary import statement with no special semantics or syntax restrictions. -Code compiled by an exec statement or calls to the builtin functions +Code compiled by an \keyword{exec} statement or calls to the builtin functions \function{compile()} and \function{execfile()} that occur in a module \module{M} containing a future statement will, by default, use the new syntax or semantics associated with the future statement. This can, starting with Python 2.2 be controlled by optional arguments to -\function{compile()} --- see the documentation of that function in the -library reference for details. +\function{compile()} --- see the documentation of that function in the +\citetitle[../lib/built-in-funcs.html]{Python Library Reference} for +details. A future statement typed at an interactive interpreter prompt will take effect for the rest of the interpreter session. If an From python-checkins at python.org Sat May 20 17:37:28 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 20 May 2006 17:37:28 +0200 (CEST) Subject: [Python-checkins] r46056 - python/branches/release24-maint/Doc/ref/ref2.tex python/branches/release24-maint/Doc/ref/ref6.tex Message-ID: <20060520153728.D917E1E400E@bag.python.org> Author: george.yoshida Date: Sat May 20 17:37:28 2006 New Revision: 46056 Modified: python/branches/release24-maint/Doc/ref/ref2.tex python/branches/release24-maint/Doc/ref/ref6.tex Log: - markup fix - add clarifying words (backport r46055) Modified: python/branches/release24-maint/Doc/ref/ref2.tex ============================================================================== --- python/branches/release24-maint/Doc/ref/ref2.tex (original) +++ python/branches/release24-maint/Doc/ref/ref2.tex Sat May 20 17:37:28 2006 @@ -652,7 +652,7 @@ \end{verbatim} Note that numeric literals do not include a sign; a phrase like -\code{-1} is actually an expression composed of the operator +\code{-1} is actually an expression composed of the unary operator \code{-} and the literal \code{1}. Modified: python/branches/release24-maint/Doc/ref/ref6.tex ============================================================================== --- python/branches/release24-maint/Doc/ref/ref6.tex (original) +++ python/branches/release24-maint/Doc/ref/ref6.tex Sat May 20 17:37:28 2006 @@ -803,13 +803,14 @@ That is not a future statement; it's an ordinary import statement with no special semantics or syntax restrictions. -Code compiled by an exec statement or calls to the builtin functions +Code compiled by an \keyword{exec} statement or calls to the builtin functions \function{compile()} and \function{execfile()} that occur in a module \module{M} containing a future statement will, by default, use the new syntax or semantics associated with the future statement. This can, starting with Python 2.2 be controlled by optional arguments to -\function{compile()} --- see the documentation of that function in the -library reference for details. +\function{compile()} --- see the documentation of that function in the +\citetitle[../lib/built-in-funcs.html]{Python Library Reference} for +details. A future statement typed at an interactive interpreter prompt will take effect for the rest of the interpreter session. If an From python-checkins at python.org Sat May 20 18:29:14 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 20 May 2006 18:29:14 +0200 (CEST) Subject: [Python-checkins] r46057 - python/trunk/Doc/ref/ref2.tex Message-ID: <20060520162914.CADA01E400E@bag.python.org> Author: george.yoshida Date: Sat May 20 18:29:14 2006 New Revision: 46057 Modified: python/trunk/Doc/ref/ref2.tex Log: - Add 'as' and 'with' as new keywords in 2.5. - Regenerate keyword lists with reswords.py. Modified: python/trunk/Doc/ref/ref2.tex ============================================================================== --- python/trunk/Doc/ref/ref2.tex (original) +++ python/trunk/Doc/ref/ref2.tex Sat May 20 18:29:14 2006 @@ -308,23 +308,27 @@ \index{reserved word} \begin{verbatim} -and del for is raise -assert elif from lambda return -break else global not try -class except if or while -continue exec import pass yield -def finally in print +and del from not while +as elif global or with +assert else if pass yield +break except import print +class exec in raise +continue finally is return +def for lambda try \end{verbatim} % When adding keywords, use reswords.py for reformatting Note that although the identifier \code{as} can be used as part of the syntax of \keyword{import} statements, it is not currently a reserved -word. +word by default.} -In some future version of Python, the identifiers \code{as} and -\code{None} will both become keywords. +\versionchanged[Both \keyword{as} and \keyword{with} are only recognized +when the \code{with_statement} feature has been enabled. It will always +be enabled in Python 2.6. See section~\ref{with} for details]{2.5} +In some future version of Python, the identifier \code{None} will +become a keyword. \subsection{Reserved classes of identifiers\label{id-classes}} From buildbot at python.org Sat May 20 18:43:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 20 May 2006 16:43:06 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060520164306.BC9A61E400E@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/68 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 20 20:07:26 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 20 May 2006 20:07:26 +0200 (CEST) Subject: [Python-checkins] r46058 - python/trunk/Doc/howto/urllib2.rst Message-ID: <20060520180726.8CE631E400E@bag.python.org> Author: george.yoshida Date: Sat May 20 20:07:26 2006 New Revision: 46058 Modified: python/trunk/Doc/howto/urllib2.rst Log: Apply patch #1492147 from Mike Foord. Modified: python/trunk/Doc/howto/urllib2.rst ============================================================================== --- python/trunk/Doc/howto/urllib2.rst (original) +++ python/trunk/Doc/howto/urllib2.rst Sat May 20 20:07:26 2006 @@ -453,7 +453,7 @@ To illustrate creating and installing a handler we will use the ``HTTPBasicAuthHandler``. For a more detailed discussion of this subject - including an explanation of how Basic Authentication works - -see the `Basic Authentication Tutorial`_. +see the `Basic Authentication Tutorial `_. When authentication is required, the server sends a header (as well as the 401 error code) requesting authentication. This specifies the From buildbot at python.org Sat May 20 20:19:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 20 May 2006 18:19:37 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060520181937.8B77F1E400E@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/424 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat May 20 20:35:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 20 May 2006 18:35:17 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060520183517.5E3F31E400E@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/726 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 20 21:25:17 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 20 May 2006 21:25:17 +0200 (CEST) Subject: [Python-checkins] r46059 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060520192517.5E9831E400E@bag.python.org> Author: andrew.kuchling Date: Sat May 20 21:25:16 2006 New Revision: 46059 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Minor edits Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat May 20 21:25:16 2006 @@ -405,7 +405,7 @@ Python 2.5 adds a simple way to pass values \emph{into} a generator. As introduced in Python 2.3, generators only produce output; once a -generator's code is invoked to create an iterator, there's no way to +generator's code was invoked to create an iterator, there was no way to pass any new information into the function when its execution is resumed. Sometimes the ability to pass in some information would be useful. Hackish solutions to this include making the generator's code @@ -525,8 +525,8 @@ Generators also become \emph{coroutines}, a more generalized form of subroutines. Subroutines are entered at one point and exited at -another point (the top of the function, and a \keyword{return -statement}), but coroutines can be entered, exited, and resumed at +another point (the top of the function, and a \keyword{return} +statement), but coroutines can be entered, exited, and resumed at many different points (the \keyword{yield} statements). We'll have to figure out patterns for using coroutines effectively in Python. From python-checkins at python.org Sat May 20 21:54:13 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 20 May 2006 21:54:13 +0200 (CEST) Subject: [Python-checkins] r46060 - sandbox/trunk/Doc/functional.rst Message-ID: <20060520195413.C04BA1E400E@bag.python.org> Author: andrew.kuchling Date: Sat May 20 21:54:13 2006 New Revision: 46060 Modified: sandbox/trunk/Doc/functional.rst Log: Add generator section; various markup fixes Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Sat May 20 21:54:13 2006 @@ -60,9 +60,9 @@ discourage the use of assignment statements such as ``a=3`` or ``c = a + b``. -Functional programming may seem like an odd constraint to work under, -a pointless skill like writing a BASIC interpreter in {\TeX}. There -are theoretical and practical advantages to the functional style: +Functional programming may seem like an odd constraint to work under. +There are theoretical and practical advantages to the functional +style: * Formal provability. * Modularity. @@ -224,7 +224,7 @@ Note that you can only go forward in an iterator; there's no way to get the previous element, reset the iterator, or make a copy of it. Iterator objects can optionally provide these additional capabilities, -but the iterator protocol only specifies the \method{next()} method. +but the iterator protocol only specifies the ``next()`` method. Functions may therefore consume all of the iterator's output, and if you need to do something different with the same stream, you'll have to create a new iterator. @@ -260,7 +260,7 @@ This is just the default behaviour. If you want to iterate over keys, values, or key/value pairs, you can explicitly call the -\method{iterkeys()}, \method{itervalues()}, or \method{iteritems()} +``iterkeys()``, ``itervalues()``, or ``iteritems()`` methods to get an appropriate iterator. The ``dict()`` constructor can accept an iterator that returns a @@ -270,15 +270,13 @@ >>> dict(iter(L)) {'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'} -Files also support iteration by calling the \method{readline()} +Files also support iteration by calling the ``readline()`` method until there are no more lines in the file. This means you can -read each line of a file like this: +read each line of a file like this:: -\begin{verbatim} -for line in file: - # do something for each line - ... -\end{verbatim} + for line in file: + # do something for each line + ... XXX sets @@ -295,7 +293,7 @@ List comprehensions (or "listcomps") are a concise notation for such operations, borrowed from the functional programming language Haskell -(\url{http://www.haskell.org}). You can strip all the whitespace from +(http://www.haskell.org). You can strip all the whitespace from a stream of strings with the following list comprehension:: line_list = [' line 1\n', 'line 2 \n', ...] @@ -320,9 +318,9 @@ if condition ] The elements of the generated list will be the successive -values of \var{expression}. The final \keyword{if} clause is -optional; if present, \var{expression} is only evaluated and added to -the result when \var{condition} is true. +values of ``expression``. The final ``if`` clause is +optional; if present, ``expression`` is only evaluated and added to +the result when ``condition`` is true. The ``for...in`` clauses contain the sequences to be iterated over. The sequences do not have to be the same length, because they are @@ -332,23 +330,21 @@ resulting pair of elements from ``sequence1`` and ``sequence2``. Put another way, a list comprehension is equivalent to the following -Python code: +Python code:: -\begin{verbatim} -for expr1 in sequence1: - for expr2 in sequence2: - ... - for exprN in sequenceN: - if (condition): - # Append the value of - # the expression to the - # resulting list. -\end{verbatim} + for expr1 in sequence1: + for expr2 in sequence2: + ... + for exprN in sequenceN: + if (condition): + # Append the value of + # the expression to the + # resulting list. -This means that when there are multiple \keyword{for}...\keyword{in} +This means that when there are multiple ``for...in`` clauses, the resulting list will be equal to the product of the lengths of all the sequences. If you have two lists of length 3, the -output list is 9 elements long: +output list is 9 elements long:: seq1 = 'abc' seq2 = (1,2,3) @@ -371,12 +367,202 @@ Generators ----------------------- -Generators are a special class of functions that simplify -the task of writing certain kinds of iterators. +Generators are a special class of functions that simplify the task of +writing iterators. Regular functions compute a value and return it, +but generators return an iterator that returns a stream of values. + +You're doubtless familiar with how regular function calls work in +Python or C. When you call a function, it gets a private namespace +where its local variables are created. When the function reaches a +``return`` statement, the local variables are destroyed and the +value is returned to the caller. A later call to the same function +creates a new private namespace and a fresh set of local +variables. But, what if the local variables weren't thrown away on +exiting a function? What if you could later resume the function where +it left off? This is what generators provide; they can be thought of +as resumable functions. + +Here's the simplest example of a generator function:: + + def generate_ints(N): + for i in range(N): + yield i + +Any function containing a ``yield`` keyword is a generator function; +this is detected by Python's bytecode compiler which compiles the +function specially as a result. + +When you call a generator function, it doesn't return a single value; +instead it returns a generator object that supports the iterator +protocol. On executing the ``yield`` expression, the generator +outputs the value of ``i``, similar to a ``return`` +statement. The big difference between ``yield`` and a +``return`` statement is that on reaching a ``yield`` the +generator's state of execution is suspended and local variables are +preserved. On the next call to the generator's ``.next()`` method, +the function will resume executing. + +Here's a sample usage of the ``generate_ints()`` generator:: + + >>> gen = generate_ints(3) + >>> gen + + >>> gen.next() + 0 + >>> gen.next() + 1 + >>> gen.next() + 2 + >>> gen.next() + Traceback (most recent call last): + File "stdin", line 1, in ? + File "stdin", line 2, in generate_ints + StopIteration -XXX {Copy bits of what's new} +You could equally write ``for i in generate_ints(5)``, or +``a,b,c = generate_ints(3)``. + +Inside a generator function, the ``return`` statement can only be used +without a value, and signals the end of the procession of values; +after executing a ``return`` the generator cannot return any further +values. ``return`` with a value, such as ``return 5``, is a syntax +error inside a generator function. The end of the generator's results +can also be indicated by raising ``StopIteration`` manually, or by +just letting the flow of execution fall off the bottom of the +function. + +You could achieve the effect of generators manually by writing your +own class and storing all the local variables of the generator as +instance variables. For example, returning a list of integers could +be done by setting ``self.count`` to 0, and having the +``next()`` method increment ``self.count`` and return it. +However, for a moderately complicated generator, writing a +corresponding class can be much messier. + +The test suite included with Python's library, ``test_generators.py``, +contains a number of more interesting examples. Here's one generator +that implements an in-order traversal of a tree using generators +recursively. + +:: + + # A recursive generator that generates Tree leaves in in-order. + def inorder(t): + if t: + for x in inorder(t.left): + yield x + yield t.label + for x in inorder(t.right): + yield x + +Two other examples in ``test_generators.py`` produce +solutions for the N-Queens problem (placing N queens on an NxN +chess board so that no queen threatens another) and the Knight's Tour +(finding a route that takes a knight to every square of an NxN chessboard +without visiting any square twice). + + + +New generator features in Python 2.5 +'''''''''''''''''''''''''''''''''''''''''''''' + +In Python 2.4 and earlier, generators only produced output. Once a +generator's code was invoked to create an iterator, there's no way to +pass any new information into the function when its execution is +resumed. (You could hack together this ability by making the +generator look at a global variable or passing in some mutable object +that callers then modify, but these approaches are messy.) +In Python 2.5 there's a simple way to pass values into a generator. + +In Python 2.5 ``yield`` became an expression, returning a value that +can be assigned to a variable or otherwise operated on:: + + val = (yield i) + +I recommend that you **always** put parentheses around a ``yield`` +expression when you're doing something with the returned value, as in +the above example. The parentheses aren't always necessary, but it's +easier to always add them instead of having to remember when they're +needed. + +(PEP 342 explains the exact rules, which are that a +``yield``-expression must always be parenthesized except when it +occurs at the top-level expression on the right-hand side of an +assignment. This means you can write ``val = yield i`` but have to +use parentheses when there's an operation, as in ``val = (yield i) ++ 12``.) + +Values are sent into a generator by calling its +``send(value})`` method. This method resumes the +generator's code and the ``yield`` expression returns the specified +value. If the regular ``next()`` method is called, the +``yield`` returns ``None``. + +Here's a simple counter that increments by 1 and allows changing the +value of the internal counter. + +:: + + def counter (maximum): + i = 0 + while i < maximum: + val = (yield i) + # If value provided, change counter + if val is not None: + i = val + else: + i += 1 + +And here's an example of changing the counter: + + >>> it = counter(10) + >>> print it.next() + 0 + >>> print it.next() + 1 + >>> print it.send(8) + 8 + >>> print it.next() + 9 + >>> print it.next() + Traceback (most recent call last): + File ``t.py'', line 15, in ? + print it.next() + StopIteration -Mention 2.5 additions but don't describe them. +Because ``yield`` will often be returning ``None``, you +should always check for this case. Don't just use its value in +expressions unless you're sure that the ``send()`` method +will be the only method used resume your generator function. + +In addition to ``send()``, there are two other new methods on +generators: + +* ``throw(type, value=None, traceback=None)`` is used to raise an exception inside the + generator; the exception is raised by the ``yield`` expression + where the generator's execution is paused. + +* ``close()`` raises a ``GeneratorExit`` + exception inside the generator to terminate the iteration. + On receiving this + exception, the generator's code must either raise + ``GeneratorExit`` or ``StopIteration``; catching the + exception and doing anything else is illegal and will trigger + a ``RuntimeError``. ``close()`` will also be called by + Python's garbage collector when the generator is garbage-collected. + + If you need to run cleanup code when a ``GeneratorExit`` occurs, + I suggest using a ``try: ... finally:`` suite instead of + catching ``GeneratorExit``. + +The cumulative effect of these changes is to turn generators from +one-way producers of information into both producers and consumers. + +Generators also become **coroutines**, a more generalized form of +subroutines. Subroutines are entered at one point and exited at +another point (the top of the function, and a ``return`` +statement), but coroutines can be entered, exited, and resumed at +many different points (the ``yield`` statements). The itertools module From neal at metaslash.com Sat May 20 23:20:38 2006 From: neal at metaslash.com (Neal Norwitz) Date: Sat, 20 May 2006 17:20:38 -0400 Subject: [Python-checkins] Python Regression Test Failures doc (1) Message-ID: <20060520212038.GA3030@python.psfb.org> TEXINPUTS=/home/neal/python/trunk/Doc/commontex: python /home/neal/python/trunk/Doc/tools/mkhowto --html --about html/stdabout.dat --iconserver ../icons --favicon ../icons/pyfav.png --address "See About this document... for information on suggesting changes." --up-link ../index.html --up-title "Python Documentation Index" --global-module-index "../modindex.html" --dvips-safe --dir html/ref ref/ref.tex *** Session transcript and error messages are in /home/neal/python/trunk/Doc/html/ref/ref.how. *** Exited with status 1. The relevant lines from the transcript are: ------------------------------------------------------------------------ +++ latex ref This is TeX, Version 3.14159 (Web2C 7.4.5) (/home/neal/python/trunk/Doc/ref/ref.tex LaTeX2e <2001/06/01> Babel and hyphenation patterns for american, french, german, ngerman, n ohyphenation, loaded. (/home/neal/python/trunk/Doc/texinputs/manual.cls Document Class: manual 1998/03/03 Document class (Python manual) (/home/neal/python/trunk/Doc/texinputs/pypaper.sty (/usr/share/texmf/tex/latex/psnfss/times.sty) Using Times instead of Computer Modern. ) (/usr/share/texmf/tex/latex/misc/fancybox.sty Style option: `fancybox' v1.3 <2000/09/19> (tvz) ) (/usr/share/texmf/tex/latex/base/report.cls Document Class: report 2001/04/21 v1.4e Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size10.clo)) (/home/neal/python/trunk/Doc/texinputs/fancyhdr.sty) Using fancier footers than usual. (/home/neal/python/trunk/Doc/texinputs/fncychap.sty) Using fancy chapter headings. (/home/neal/python/trunk/Doc/texinputs/python.sty (/usr/share/texmf/tex/latex/tools/longtable.sty) (/home/neal/python/trunk/Doc/texinputs/underscore.sty) (/usr/share/texmf/tex/latex/tools/verbatim.sty) (/usr/share/texmf/tex/latex/base/alltt.sty))) (/home/neal/python/trunk/Doc/commontex/boilerplate.tex (/home/neal/python/trunk/Doc/commontex/patchlevel.tex)) Writing index file ref.idx No file ref.aux. (/usr/share/texmf/tex/latex/psnfss/ot1ptm.fd) (/usr/share/texmf/tex/latex/psnfss/ot1phv.fd) [1] (/home/neal/python/trunk/Doc/commontex/copyright.tex (/usr/share/texmf/tex/latex/psnfss/omsptm.fd)) [2] Adding blank page after the abstract. [1] [2] No file ref.toc. Adding blank page after the table of contents. [1] [2] (/home/neal/python/trunk/Doc/ref/ref1.tex Chapter 1. [1] (/usr/share/texmf/tex/latex/psnfss/ot1pcr.fd)) (/home/neal/python/trunk/Doc/ref/ref2.tex [2] Chapter 2. [3] Underfull \hbox (badness 10000) in paragraph at lines 86--91 \OT1/ptm/m/n/10 If a com-ment in the first or sec-ond line of the Python script matches the reg-u-lar ex-pres-sion [4] [5] [6] ! Too many }'s. l.324 word by default.} ? ! Emergency stop. l.324 word by default.} Output written on ref.dvi (12 pages, 23660 bytes). Transcript written on ref.log. *** Session transcript and error messages are in /home/neal/python/trunk/Doc/html/ref/ref.how. *** Exited with status 1. +++ TEXINPUTS=/home/neal/python/trunk/Doc/ref:/home/neal/python/trunk/Doc/commontex:/home/neal/python/trunk/Doc/paper-letter:/home/neal/python/trunk/Doc/texinputs: +++ latex ref make: *** [html/ref/ref.html] Error 1 From python-checkins at python.org Sun May 21 06:23:00 2006 From: python-checkins at python.org (george.yoshida) Date: Sun, 21 May 2006 06:23:00 +0200 (CEST) Subject: [Python-checkins] r46061 - python/trunk/Doc/ref/ref2.tex Message-ID: <20060521042300.1D4901E4011@bag.python.org> Author: george.yoshida Date: Sun May 21 06:22:59 2006 New Revision: 46061 Modified: python/trunk/Doc/ref/ref2.tex Log: Fix the TeX compile error. Modified: python/trunk/Doc/ref/ref2.tex ============================================================================== --- python/trunk/Doc/ref/ref2.tex (original) +++ python/trunk/Doc/ref/ref2.tex Sun May 21 06:22:59 2006 @@ -321,7 +321,7 @@ Note that although the identifier \code{as} can be used as part of the syntax of \keyword{import} statements, it is not currently a reserved -word by default.} +word by default.) \versionchanged[Both \keyword{as} and \keyword{with} are only recognized when the \code{with_statement} feature has been enabled. It will always From dynkin at gmail.com Sun May 21 06:36:20 2006 From: dynkin at gmail.com (George Yoshida) Date: Sun, 21 May 2006 13:36:20 +0900 Subject: [Python-checkins] Python Regression Test Failures doc (1) In-Reply-To: <20060520212038.GA3030@python.psfb.org> References: <20060520212038.GA3030@python.psfb.org> Message-ID: <2f188ee80605202136q6fc8b099q22211b04ae03102d@mail.gmail.com> Thanks for the report. It was my fault and now fixed in Revision:46061. -- george On 5/21/06, Neal Norwitz wrote: > TEXINPUTS=/home/neal/python/trunk/Doc/commontex: python /home/neal/python/trunk/Doc/tools/mkhowto --html --about html/stdabout.dat --iconserver ../icons --favicon ../icons/pyfav.png --address "See About this document... for information on suggesting changes." --up-link ../index.html --up-title "Python Documentation Index" --global-module-index "../modindex.html" --dvips-safe --dir html/ref ref/ref.tex > *** Session transcript and error messages are in /home/neal/python/trunk/Doc/html/ref/ref.how. > *** Exited with status 1. > The relevant lines from the transcript are: > ------------------------------------------------------------------------ From python-checkins at python.org Sun May 21 06:40:33 2006 From: python-checkins at python.org (george.yoshida) Date: Sun, 21 May 2006 06:40:33 +0200 (CEST) Subject: [Python-checkins] r46062 - python/trunk/Doc/howto/urllib2.rst Message-ID: <20060521044033.190591E4012@bag.python.org> Author: george.yoshida Date: Sun May 21 06:40:32 2006 New Revision: 46062 Modified: python/trunk/Doc/howto/urllib2.rst Log: Apply patch #1492255 from Mike Foord. Modified: python/trunk/Doc/howto/urllib2.rst ============================================================================== --- python/trunk/Doc/howto/urllib2.rst (original) +++ python/trunk/Doc/howto/urllib2.rst Sun May 21 06:40:32 2006 @@ -10,7 +10,7 @@ There is an French translation of an earlier revision of this HOWTO, available at `urllib2 - Le Manuel manquant - `_. + `_. .. contents:: urllib2 Tutorial @@ -574,14 +574,14 @@ Footnotes -=========== +========= This document was reviewed and revised by John Lee. .. [#] For an introduction to the CGI protocol see `Writing Web Applications in Python `_. .. [#] Like Google for example. The *proper* way to use google from a program - is to use `PyGoogle _ of course. See + is to use `PyGoogle `_ of course. See `Voidspace Google `_ for some examples of using the Google API. .. [#] Browser sniffing is a very bad practise for website design - building From buildbot at python.org Sun May 21 07:40:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 21 May 2006 05:40:40 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060521054040.BC91B1E4012@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/396 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: george.yoshida Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 10:48:31 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 22 May 2006 10:48:31 +0200 (CEST) Subject: [Python-checkins] r46063 - in python/trunk: PC/py.ico PC/pyc.ico PC/pycon.ico PCbuild/installer.bmp Message-ID: <20060522084831.AEE091E4014@bag.python.org> Author: martin.v.loewis Date: Mon May 22 10:48:14 2006 New Revision: 46063 Modified: python/trunk/PC/py.ico python/trunk/PC/pyc.ico python/trunk/PC/pycon.ico python/trunk/PCbuild/installer.bmp Log: Patch 1490384: New Icons for the PC build. Modified: python/trunk/PC/py.ico ============================================================================== Binary files. No diff available. Modified: python/trunk/PC/pyc.ico ============================================================================== Binary files. No diff available. Modified: python/trunk/PC/pycon.ico ============================================================================== Binary files. No diff available. Modified: python/trunk/PCbuild/installer.bmp ============================================================================== Binary files. No diff available. From python-checkins at python.org Mon May 22 11:16:13 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 22 May 2006 11:16:13 +0200 (CEST) Subject: [Python-checkins] r46064 - in python/trunk: Include/Python.h Include/pyport.h Misc/ACKS Misc/NEWS Modules/_localemodule.c Modules/main.c Modules/posixmodule.c Modules/sha512module.c PC/pyconfig.h Python/thread_nt.h Message-ID: <20060522091613.3A64F1E4014@bag.python.org> Author: martin.v.loewis Date: Mon May 22 11:15:18 2006 New Revision: 46064 Modified: python/trunk/Include/Python.h python/trunk/Include/pyport.h python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Modules/_localemodule.c python/trunk/Modules/main.c python/trunk/Modules/posixmodule.c python/trunk/Modules/sha512module.c python/trunk/PC/pyconfig.h python/trunk/Python/thread_nt.h Log: Patch #1492356: Port to Windows CE (patch set 1). Modified: python/trunk/Include/Python.h ============================================================================== --- python/trunk/Include/Python.h (original) +++ python/trunk/Include/Python.h Mon May 22 11:15:18 2006 @@ -35,7 +35,9 @@ #endif #include +#ifndef DONT_HAVE_ERRNO_H #include +#endif #include #ifdef HAVE_UNISTD_H #include Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Mon May 22 11:15:18 2006 @@ -685,4 +685,16 @@ #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) #endif +/* + * Older Microsoft compilers don't support the C99 long long literal suffixes, + * so these will be defined in PC/pyconfig.h for those compilers. + */ +#ifndef Py_LL +#define Py_LL(x) x##LL +#endif + +#ifndef Py_ULL +#define Py_ULL(x) Py_LL(x##U) +#endif + #endif /* Py_PYPORT_H */ Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Mon May 22 11:15:18 2006 @@ -167,6 +167,7 @@ Paul Dubois Quinn Dunkan Robin Dunn +Luke Dunstan Andy Dustman Gary Duzan Eugene Dvurechenski Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 22 11:15:18 2006 @@ -81,6 +81,8 @@ Build ----- +- Patch #1492356: Port to Windows CE. + - Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64. - Patch #1471883: Add --enable-universalsdk. Modified: python/trunk/Modules/_localemodule.c ============================================================================== --- python/trunk/Modules/_localemodule.c (original) +++ python/trunk/Modules/_localemodule.c Mon May 22 11:15:18 2006 @@ -12,11 +12,14 @@ #include "Python.h" #include -#include #include #include #include +#ifndef DONT_HAVE_ERRNO_H +#include +#endif + #ifdef HAVE_LANGINFO_H #include #endif Modified: python/trunk/Modules/main.c ============================================================================== --- python/trunk/Modules/main.c (original) +++ python/trunk/Modules/main.c Mon May 22 11:15:18 2006 @@ -10,8 +10,10 @@ #endif #if defined(MS_WINDOWS) || defined(__CYGWIN__) +#ifdef HAVE_FCNTL_H #include #endif +#endif #if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS) #define PYTHONHOMEHELP "\\lib" Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Mon May 22 11:15:18 2006 @@ -4789,7 +4789,7 @@ switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) { case _O_WRONLY | _O_TEXT: /* Case for writing to child Stdin in text mode. */ - fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdinWrDup, mode); f1 = _fdopen(fd1, "w"); f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose); PyFile_SetBufSize(f, 0); @@ -4800,7 +4800,7 @@ case _O_RDONLY | _O_TEXT: /* Case for reading from child Stdout in text mode. */ - fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdoutRdDup, mode); f1 = _fdopen(fd1, "r"); f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose); PyFile_SetBufSize(f, 0); @@ -4811,7 +4811,7 @@ case _O_RDONLY | _O_BINARY: /* Case for readinig from child Stdout in binary mode. */ - fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdoutRdDup, mode); f1 = _fdopen(fd1, "rb"); f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose); PyFile_SetBufSize(f, 0); @@ -4822,7 +4822,7 @@ case _O_WRONLY | _O_BINARY: /* Case for writing to child Stdin in binary mode. */ - fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdinWrDup, mode); f1 = _fdopen(fd1, "wb"); f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose); PyFile_SetBufSize(f, 0); @@ -4848,9 +4848,9 @@ m2 = "wb"; } - fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdinWrDup, mode); f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode); + fd2 = _open_osfhandle((Py_intptr_t)hChildStdoutRdDup, mode); f2 = _fdopen(fd2, m1); p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); PyFile_SetBufSize(p1, 0); @@ -4880,11 +4880,11 @@ m2 = "wb"; } - fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode); + fd1 = _open_osfhandle((Py_intptr_t)hChildStdinWrDup, mode); f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode); + fd2 = _open_osfhandle((Py_intptr_t)hChildStdoutRdDup, mode); f2 = _fdopen(fd2, m1); - fd3 = _open_osfhandle((intptr_t)hChildStderrRdDup, mode); + fd3 = _open_osfhandle((Py_intptr_t)hChildStderrRdDup, mode); f3 = _fdopen(fd3, m1); p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); @@ -5488,7 +5488,7 @@ static PyObject * posix_waitpid(PyObject *self, PyObject *args) { - intptr_t pid; + Py_intptr_t pid; int status, options; if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options)) Modified: python/trunk/Modules/sha512module.c ============================================================================== --- python/trunk/Modules/sha512module.c (original) +++ python/trunk/Modules/sha512module.c Mon May 22 11:15:18 2006 @@ -121,12 +121,12 @@ /* Various logical functions */ #define ROR64(x, y) \ - ( ((((x) & 0xFFFFFFFFFFFFFFFFULL)>>((unsigned PY_LONG_LONG)(y) & 63)) | \ - ((x)<<((unsigned PY_LONG_LONG)(64-((y) & 63))))) & 0xFFFFFFFFFFFFFFFFULL) + ( ((((x) & Py_ULL(0xFFFFFFFFFFFFFFFF))>>((unsigned PY_LONG_LONG)(y) & 63)) | \ + ((x)<<((unsigned PY_LONG_LONG)(64-((y) & 63))))) & Py_ULL(0xFFFFFFFFFFFFFFFF)) #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) ROR64((x),(n)) -#define R(x, n) (((x) & 0xFFFFFFFFFFFFFFFFULL) >> ((unsigned PY_LONG_LONG)n)) +#define R(x, n) (((x) & Py_ULL(0xFFFFFFFFFFFFFFFF)) >> ((unsigned PY_LONG_LONG)n)) #define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39)) #define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) #define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) @@ -156,86 +156,86 @@ d += t0; \ h = t0 + t1; - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98d728ae22ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x7137449123ef65cdULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcfec4d3b2fULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,0xe9b5dba58189dbbcULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,0x3956c25bf348b538ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,0x59f111f1b605d019ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,0x923f82a4af194f9bULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,0xab1c5ed5da6d8118ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,0xd807aa98a3030242ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,0x12835b0145706fbeULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,0x243185be4ee4b28cULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,0x550c7dc3d5ffb4e2ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,0x72be5d74f27b896fULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,0x80deb1fe3b1696b1ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,0x9bdc06a725c71235ULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,0xc19bf174cf692694ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,0xe49b69c19ef14ad2ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,0xefbe4786384f25e3ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,0x0fc19dc68b8cd5b5ULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,0x240ca1cc77ac9c65ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,0x2de92c6f592b0275ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,0x4a7484aa6ea6e483ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,0x5cb0a9dcbd41fbd4ULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,0x76f988da831153b5ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,0x983e5152ee66dfabULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,0xa831c66d2db43210ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,0xb00327c898fb213fULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,0xbf597fc7beef0ee4ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,0xc6e00bf33da88fc2ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,0xd5a79147930aa725ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,0x06ca6351e003826fULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,0x142929670a0e6e70ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,0x27b70a8546d22ffcULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,0x2e1b21385c26c926ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,0x4d2c6dfc5ac42aedULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,0x53380d139d95b3dfULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,0x650a73548baf63deULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,0x766a0abb3c77b2a8ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,0x81c2c92e47edaee6ULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,0x92722c851482353bULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,0xa2bfe8a14cf10364ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,0xa81a664bbc423001ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,0xc24b8b70d0f89791ULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,0xc76c51a30654be30ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,0xd192e819d6ef5218ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,0xd69906245565a910ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,0xf40e35855771202aULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,0x106aa07032bbd1b8ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116b8d2d0c8ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,0x1e376c085141ab53ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,0x2748774cdf8eeb99ULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,0x34b0bcb5e19b48a8ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,0x391c0cb3c5c95a63ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,0x4ed8aa4ae3418acbULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,0x5b9cca4f7763e373ULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,0x682e6ff3d6b2b8a3ULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,0x748f82ee5defb2fcULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,0x78a5636f43172f60ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,0x84c87814a1f0ab72ULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,0x8cc702081a6439ecULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,0x90befffa23631e28ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506cebde82bde9ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7b2c67915ULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2e372532bULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],64,0xca273eceea26619cULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],65,0xd186b8c721c0c207ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],66,0xeada7dd6cde0eb1eULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],67,0xf57d4f7fee6ed178ULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],68,0x06f067aa72176fbaULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],69,0x0a637dc5a2c898a6ULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],70,0x113f9804bef90daeULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],71,0x1b710b35131c471bULL); - RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],72,0x28db77f523047d84ULL); - RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],73,0x32caab7b40c72493ULL); - RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],74,0x3c9ebe0a15c9bebcULL); - RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],75,0x431d67c49c100d4cULL); - RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],76,0x4cc5d4becb3e42b6ULL); - RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],77,0x597f299cfc657e2aULL); - RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],78,0x5fcb6fab3ad6faecULL); - RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],79,0x6c44198c4a475817ULL); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,Py_ULL(0x428a2f98d728ae22)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,Py_ULL(0x7137449123ef65cd)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,Py_ULL(0xb5c0fbcfec4d3b2f)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,Py_ULL(0xe9b5dba58189dbbc)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,Py_ULL(0x3956c25bf348b538)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,Py_ULL(0x59f111f1b605d019)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,Py_ULL(0x923f82a4af194f9b)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,Py_ULL(0xab1c5ed5da6d8118)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,Py_ULL(0xd807aa98a3030242)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,Py_ULL(0x12835b0145706fbe)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,Py_ULL(0x243185be4ee4b28c)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,Py_ULL(0x550c7dc3d5ffb4e2)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,Py_ULL(0x72be5d74f27b896f)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,Py_ULL(0x80deb1fe3b1696b1)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,Py_ULL(0x9bdc06a725c71235)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,Py_ULL(0xc19bf174cf692694)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,Py_ULL(0xe49b69c19ef14ad2)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,Py_ULL(0xefbe4786384f25e3)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,Py_ULL(0x0fc19dc68b8cd5b5)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,Py_ULL(0x240ca1cc77ac9c65)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,Py_ULL(0x2de92c6f592b0275)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,Py_ULL(0x4a7484aa6ea6e483)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,Py_ULL(0x5cb0a9dcbd41fbd4)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,Py_ULL(0x76f988da831153b5)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,Py_ULL(0x983e5152ee66dfab)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,Py_ULL(0xa831c66d2db43210)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,Py_ULL(0xb00327c898fb213f)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,Py_ULL(0xbf597fc7beef0ee4)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,Py_ULL(0xc6e00bf33da88fc2)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,Py_ULL(0xd5a79147930aa725)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,Py_ULL(0x06ca6351e003826f)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,Py_ULL(0x142929670a0e6e70)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,Py_ULL(0x27b70a8546d22ffc)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,Py_ULL(0x2e1b21385c26c926)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,Py_ULL(0x4d2c6dfc5ac42aed)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,Py_ULL(0x53380d139d95b3df)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,Py_ULL(0x650a73548baf63de)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,Py_ULL(0x766a0abb3c77b2a8)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,Py_ULL(0x81c2c92e47edaee6)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,Py_ULL(0x92722c851482353b)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,Py_ULL(0xa2bfe8a14cf10364)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,Py_ULL(0xa81a664bbc423001)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,Py_ULL(0xc24b8b70d0f89791)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,Py_ULL(0xc76c51a30654be30)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,Py_ULL(0xd192e819d6ef5218)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,Py_ULL(0xd69906245565a910)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,Py_ULL(0xf40e35855771202a)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,Py_ULL(0x106aa07032bbd1b8)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,Py_ULL(0x19a4c116b8d2d0c8)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,Py_ULL(0x1e376c085141ab53)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,Py_ULL(0x2748774cdf8eeb99)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,Py_ULL(0x34b0bcb5e19b48a8)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,Py_ULL(0x391c0cb3c5c95a63)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,Py_ULL(0x4ed8aa4ae3418acb)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,Py_ULL(0x5b9cca4f7763e373)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,Py_ULL(0x682e6ff3d6b2b8a3)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,Py_ULL(0x748f82ee5defb2fc)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,Py_ULL(0x78a5636f43172f60)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,Py_ULL(0x84c87814a1f0ab72)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,Py_ULL(0x8cc702081a6439ec)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,Py_ULL(0x90befffa23631e28)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,Py_ULL(0xa4506cebde82bde9)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,Py_ULL(0xbef9a3f7b2c67915)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,Py_ULL(0xc67178f2e372532b)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],64,Py_ULL(0xca273eceea26619c)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],65,Py_ULL(0xd186b8c721c0c207)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],66,Py_ULL(0xeada7dd6cde0eb1e)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],67,Py_ULL(0xf57d4f7fee6ed178)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],68,Py_ULL(0x06f067aa72176fba)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],69,Py_ULL(0x0a637dc5a2c898a6)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],70,Py_ULL(0x113f9804bef90dae)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],71,Py_ULL(0x1b710b35131c471b)); + RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],72,Py_ULL(0x28db77f523047d84)); + RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],73,Py_ULL(0x32caab7b40c72493)); + RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],74,Py_ULL(0x3c9ebe0a15c9bebc)); + RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],75,Py_ULL(0x431d67c49c100d4c)); + RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],76,Py_ULL(0x4cc5d4becb3e42b6)); + RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],77,Py_ULL(0x597f299cfc657e2a)); + RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],78,Py_ULL(0x5fcb6fab3ad6faec)); + RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],79,Py_ULL(0x6c44198c4a475817)); #undef RND @@ -254,14 +254,14 @@ sha512_init(SHAobject *sha_info) { TestEndianness(sha_info->Endianness) - sha_info->digest[0] = 0x6a09e667f3bcc908ULL; - sha_info->digest[1] = 0xbb67ae8584caa73bULL; - sha_info->digest[2] = 0x3c6ef372fe94f82bULL; - sha_info->digest[3] = 0xa54ff53a5f1d36f1ULL; - sha_info->digest[4] = 0x510e527fade682d1ULL; - sha_info->digest[5] = 0x9b05688c2b3e6c1fULL; - sha_info->digest[6] = 0x1f83d9abfb41bd6bULL; - sha_info->digest[7] = 0x5be0cd19137e2179ULL; + sha_info->digest[0] = Py_ULL(0x6a09e667f3bcc908); + sha_info->digest[1] = Py_ULL(0xbb67ae8584caa73b); + sha_info->digest[2] = Py_ULL(0x3c6ef372fe94f82b); + sha_info->digest[3] = Py_ULL(0xa54ff53a5f1d36f1); + sha_info->digest[4] = Py_ULL(0x510e527fade682d1); + sha_info->digest[5] = Py_ULL(0x9b05688c2b3e6c1f); + sha_info->digest[6] = Py_ULL(0x1f83d9abfb41bd6b); + sha_info->digest[7] = Py_ULL(0x5be0cd19137e2179); sha_info->count_lo = 0L; sha_info->count_hi = 0L; sha_info->local = 0; @@ -272,14 +272,14 @@ sha384_init(SHAobject *sha_info) { TestEndianness(sha_info->Endianness) - sha_info->digest[0] = 0xcbbb9d5dc1059ed8ULL; - sha_info->digest[1] = 0x629a292a367cd507ULL; - sha_info->digest[2] = 0x9159015a3070dd17ULL; - sha_info->digest[3] = 0x152fecd8f70e5939ULL; - sha_info->digest[4] = 0x67332667ffc00b31ULL; - sha_info->digest[5] = 0x8eb44a8768581511ULL; - sha_info->digest[6] = 0xdb0c2e0d64f98fa7ULL; - sha_info->digest[7] = 0x47b5481dbefa4fa4ULL; + sha_info->digest[0] = Py_ULL(0xcbbb9d5dc1059ed8); + sha_info->digest[1] = Py_ULL(0x629a292a367cd507); + sha_info->digest[2] = Py_ULL(0x9159015a3070dd17); + sha_info->digest[3] = Py_ULL(0x152fecd8f70e5939); + sha_info->digest[4] = Py_ULL(0x67332667ffc00b31); + sha_info->digest[5] = Py_ULL(0x8eb44a8768581511); + sha_info->digest[6] = Py_ULL(0xdb0c2e0d64f98fa7); + sha_info->digest[7] = Py_ULL(0x47b5481dbefa4fa4); sha_info->count_lo = 0L; sha_info->count_hi = 0L; sha_info->local = 0; Modified: python/trunk/PC/pyconfig.h ============================================================================== --- python/trunk/PC/pyconfig.h (original) +++ python/trunk/PC/pyconfig.h Mon May 22 11:15:18 2006 @@ -14,6 +14,7 @@ MS_WIN64 - Code specific to the MS Win64 API MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) MS_WINDOWS - Code specific to Windows, but all versions. +MS_WINCE - Code specific to Windows CE Py_ENABLE_SHARED - Code if the Python core is built as a DLL. Also note that neither "_M_IX86" or "_MSC_VER" should be used for @@ -27,6 +28,10 @@ */ +#ifdef _WIN32_WCE +#define MS_WINCE +#endif + /* Visual Studio 2005 introduces deprecation warnings for "insecure" and POSIX functions. The insecure functions should be replaced by *_s versions (according to Microsoft); the @@ -37,15 +42,23 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 -#include +/* Windows CE does not have these */ +#ifndef MS_WINCE +#define HAVE_IO_H #define HAVE_SYS_UTIME_H -#define HAVE_HYPOT #define HAVE_TEMPNAM #define HAVE_TMPFILE #define HAVE_TMPNAM #define HAVE_CLOCK -#define HAVE_STRFTIME #define HAVE_STRERROR +#endif + +#ifdef HAVE_IO_H +#include +#endif + +#define HAVE_HYPOT +#define HAVE_STRFTIME #define DONT_HAVE_SIG_ALARM #define DONT_HAVE_SIG_PAUSE #define LONG_BIT 32 @@ -64,6 +77,11 @@ #define USE_SOCKET #endif +#ifdef MS_WINCE +#define DONT_HAVE_SYS_STAT_H +#define DONT_HAVE_ERRNO_H +#endif + /* Compiler specific defines */ /* ------------------------------------------------------------------------*/ @@ -117,6 +135,11 @@ #endif #endif /* MS_WIN64 */ +/* _W64 is not defined for VC6 or eVC4 */ +#ifndef _W64 +#define _W64 +#endif + /* Define like size_t, omitting the "unsigned" */ #ifdef MS_WIN64 typedef __int64 ssize_t; @@ -297,11 +320,16 @@ #define SIZEOF_LONG_LONG 8 /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. + Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't + define these. If some compiler does not provide them, modify the #if appropriately. */ #if defined(_MSC_VER) -#if _MSC_VER > 1200 +#if _MSC_VER > 1201 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 +#else +/* VC6 & eVC4 don't support the C99 LL suffix for 64-bit integer literals */ +#define Py_LL(x) x##I64 #endif /* _MSC_VER > 1200 */ #endif /* _MSC_VER */ @@ -397,7 +425,9 @@ /* #define HAVE_ALTZONE */ /* Define if you have the putenv function. */ +#ifndef MS_WINCE #define HAVE_PUTENV +#endif /* Define if your compiler supports function prototypes */ #define HAVE_PROTOTYPES @@ -445,7 +475,9 @@ #define HAVE_DYNAMIC_LOADING /* Define if you have ftime. */ +#ifndef MS_WINCE #define HAVE_FTIME +#endif /* Define if you have getpeername. */ #define HAVE_GETPEERNAME @@ -454,7 +486,9 @@ /* #undef HAVE_GETPGRP */ /* Define if you have getpid. */ +#ifndef MS_WINCE #define HAVE_GETPID +#endif /* Define if you have gettimeofday. */ /* #undef HAVE_GETTIMEOFDAY */ @@ -511,13 +545,17 @@ /* #undef HAVE_WAITPID */ /* Define to 1 if you have the `wcscoll' function. */ +#ifndef MS_WINCE #define HAVE_WCSCOLL 1 +#endif /* Define if you have the header file. */ /* #undef HAVE_DLFCN_H */ /* Define if you have the header file. */ +#ifndef MS_WINCE #define HAVE_FCNTL_H 1 +#endif /* Define if you have the prototypes. */ #define HAVE_STDARG_PROTOTYPES Modified: python/trunk/Python/thread_nt.h ============================================================================== --- python/trunk/Python/thread_nt.h (original) +++ python/trunk/Python/thread_nt.h Mon May 22 11:15:18 2006 @@ -170,7 +170,7 @@ long PyThread_start_new_thread(void (*func)(void *), void *arg) { - uintptr_t rv; + Py_uintptr_t rv; callobj obj; dprintf(("%ld: PyThread_start_new_thread called\n", @@ -186,7 +186,7 @@ return -1; rv = _beginthread(bootstrap, 0, &obj); /* use default stack size */ - if (rv == (uintptr_t)-1) { + if (rv == (Py_uintptr_t)-1) { /* I've seen errno == EAGAIN here, which means "there are * too many threads". */ From buildbot at python.org Mon May 22 12:50:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 10:50:57 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060522105058.23AD71E4027@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/430 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 13:29:42 2006 From: python-checkins at python.org (tim.peters) Date: Mon, 22 May 2006 13:29:42 +0200 (CEST) Subject: [Python-checkins] r46065 - python/trunk/PC/pyconfig.h Message-ID: <20060522112942.5BCA41E4014@bag.python.org> Author: tim.peters Date: Mon May 22 13:29:41 2006 New Revision: 46065 Modified: python/trunk/PC/pyconfig.h Log: Define SIZEOF_{DOUBLE,FLOAT} on Windows. Else Michael Hudson's nice gimmicks for IEEE special values (infinities, NaNs) don't work. Modified: python/trunk/PC/pyconfig.h ============================================================================== --- python/trunk/PC/pyconfig.h (original) +++ python/trunk/PC/pyconfig.h Mon May 22 13:29:41 2006 @@ -318,6 +318,8 @@ #define SIZEOF_INT 4 #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_FLOAT 4 /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't @@ -330,7 +332,7 @@ #else /* VC6 & eVC4 don't support the C99 LL suffix for 64-bit integer literals */ #define Py_LL(x) x##I64 -#endif /* _MSC_VER > 1200 */ +#endif /* _MSC_VER > 1200 */ #endif /* _MSC_VER */ #endif From python-checkins at python.org Mon May 22 14:11:55 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 22 May 2006 14:11:55 +0200 (CEST) Subject: [Python-checkins] r46066 - sandbox/trunk/gzipbench Message-ID: <20060522121155.D68721E4014@bag.python.org> Author: bob.ippolito Date: Mon May 22 14:11:55 2006 New Revision: 46066 Added: sandbox/trunk/gzipbench/ Log: gzip benchmark From python-checkins at python.org Mon May 22 15:41:05 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 22 May 2006 15:41:05 +0200 (CEST) Subject: [Python-checkins] r46067 - sandbox/trunk/gzipbench/gzipbench.py Message-ID: <20060522134105.E7FCF1E4007@bag.python.org> Author: bob.ippolito Date: Mon May 22 15:41:05 2006 New Revision: 46067 Added: sandbox/trunk/gzipbench/gzipbench.py (contents, props changed) Log: benchmark for gzip readline Added: sandbox/trunk/gzipbench/gzipbench.py ============================================================================== --- (empty file) +++ sandbox/trunk/gzipbench/gzipbench.py Mon May 22 15:41:05 2006 @@ -0,0 +1,43 @@ +import os +import tempfile +import shutil +import time +import sys +from gzip import GzipFile +from random import randint +from array import array +from itertools import izip + +def log_line(): + chars = array('B', [randint(32,127) for _ in xrange(randint(40,120))]) + return '[%s] %s\n' % (time.ctime(), chars.tostring()) + +def main(lines=10000, repeat=10): + outdir = tempfile.mkdtemp() + try: + print 'writing test file...', + sys.stdout.flush() + t = time.time() + fn = os.path.join(outdir, 'gzipbench.gz') + outfile = GzipFile(fn, 'wb') + log_lines = [log_line() for x in xrange(lines)] + outfile.writelines(log_lines) + outfile.close() + print '%.2f sec' % (time.time() - t,) + + print 'reading test file...', + sys.stdout.flush() + t = time.time() + for i in xrange(repeat): + infile = GzipFile(fn) + lines = 0 + for test, orig in izip(infile, log_lines): + lines += 1 + assert test == orig + assert lines == len(log_lines) + print '%.2f sec' % (time.time() - t,) + finally: + shutil.rmtree(outdir) + +if __name__ == '__main__': + main() From python-checkins at python.org Mon May 22 16:04:29 2006 From: python-checkins at python.org (richard.jones) Date: Mon, 22 May 2006 16:04:29 +0200 (CEST) Subject: [Python-checkins] r46068 - python/branches/rjones-funccall Message-ID: <20060522140429.068EC1E4007@bag.python.org> Author: richard.jones Date: Mon May 22 16:04:28 2006 New Revision: 46068 Added: python/branches/rjones-funccall/ - copied from r46067, python/trunk/ Log: investigating function call speedups From python-checkins at python.org Mon May 22 16:10:37 2006 From: python-checkins at python.org (richard.jones) Date: Mon, 22 May 2006 16:10:37 +0200 (CEST) Subject: [Python-checkins] r46069 - python/branches/rjones-funccall Message-ID: <20060522141037.7896B1E4007@bag.python.org> Author: richard.jones Date: Mon May 22 16:10:36 2006 New Revision: 46069 Modified: python/branches/rjones-funccall/ (props changed) Log: svnmerge init From python-checkins at python.org Mon May 22 16:31:25 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 22 May 2006 16:31:25 +0200 (CEST) Subject: [Python-checkins] r46070 - python/trunk/Lib/gzip.py Message-ID: <20060522143125.2988F1E403E@bag.python.org> Author: bob.ippolito Date: Mon May 22 16:31:24 2006 New Revision: 46070 Modified: python/trunk/Lib/gzip.py Log: GzipFile.readline performance improvement (~30-40%), patch #1281707 Modified: python/trunk/Lib/gzip.py ============================================================================== --- python/trunk/Lib/gzip.py (original) +++ python/trunk/Lib/gzip.py Mon May 22 16:31:24 2006 @@ -107,6 +107,7 @@ self.extrabuf = "" self.extrasize = 0 self.filename = filename + self.min_readsize = 64 # Starts small, scales exponentially elif mode[0:1] == 'w' or mode[0:1] == 'a': self.mode = WRITE @@ -381,32 +382,39 @@ self.read(count % 1024) def readline(self, size=-1): - if size < 0: size = sys.maxint - bufs = [] - readsize = min(100, size) # Read from the file in small chunks + if size < 0: + size = sys.maxint # Line can be as long as maxint + readsize = self.min_readsize # Read from file in small chunks + else: + readsize = size # Only read in as much as specified + + bufs = "" + while True: - if size == 0: - return "".join(bufs) # Return resulting line + if size == 0: return bufs # Return line (reached max len) c = self.read(readsize) i = c.find('\n') - if size is not None: - # We set i=size to break out of the loop under two - # conditions: 1) there's no newline, and the chunk is - # larger than size, or 2) there is a newline, but the - # resulting line would be longer than 'size'. - if i==-1 and len(c) > size: i=size-1 - elif size <= i: i = size -1 + # If there is a newline, or the string is empty if i >= 0 or c == '': - bufs.append(c[:i+1]) # Add portion of last chunk - self._unread(c[i+1:]) # Push back rest of chunk - return ''.join(bufs) # Return resulting line - - # Append chunk to list, decrease 'size', - bufs.append(c) - size = size - len(c) - readsize = min(size, readsize * 2) + if size <= i: i = size - 1 # Another larger than size check + + self._unread(c[i+1:]) # Push back rest of chunk + + return bufs + c[:i+1] # Stored line, plus new segment + + # If there is no newline + else: + if len(c) > size: i = size - 1 # If lineis larger than size + + bufs = bufs + c + size = size - len(c) + readsize = min(size, int(readsize * 1.1)) + + # Optimize future readline() calls + if readsize > self.min_readsize: + self.min_readsize = readsize def readlines(self, sizehint=0): # Negative numbers result in reading all the lines From python-checkins at python.org Mon May 22 17:22:48 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 22 May 2006 17:22:48 +0200 (CEST) Subject: [Python-checkins] r46071 - python/trunk/Lib/gzip.py Message-ID: <20060522152248.066E51E401F@bag.python.org> Author: bob.ippolito Date: Mon May 22 17:22:46 2006 New Revision: 46071 Modified: python/trunk/Lib/gzip.py Log: Revert gzip readline performance patch #1281707 until a more generic performance improvement can be found Modified: python/trunk/Lib/gzip.py ============================================================================== --- python/trunk/Lib/gzip.py (original) +++ python/trunk/Lib/gzip.py Mon May 22 17:22:46 2006 @@ -107,7 +107,6 @@ self.extrabuf = "" self.extrasize = 0 self.filename = filename - self.min_readsize = 64 # Starts small, scales exponentially elif mode[0:1] == 'w' or mode[0:1] == 'a': self.mode = WRITE @@ -382,39 +381,32 @@ self.read(count % 1024) def readline(self, size=-1): - if size < 0: - size = sys.maxint # Line can be as long as maxint - readsize = self.min_readsize # Read from file in small chunks - else: - readsize = size # Only read in as much as specified - - bufs = "" - + if size < 0: size = sys.maxint + bufs = [] + readsize = min(100, size) # Read from the file in small chunks while True: - if size == 0: return bufs # Return line (reached max len) + if size == 0: + return "".join(bufs) # Return resulting line c = self.read(readsize) i = c.find('\n') + if size is not None: + # We set i=size to break out of the loop under two + # conditions: 1) there's no newline, and the chunk is + # larger than size, or 2) there is a newline, but the + # resulting line would be longer than 'size'. + if i==-1 and len(c) > size: i=size-1 + elif size <= i: i = size -1 - # If there is a newline, or the string is empty if i >= 0 or c == '': - if size <= i: i = size - 1 # Another larger than size check - - self._unread(c[i+1:]) # Push back rest of chunk - - return bufs + c[:i+1] # Stored line, plus new segment - - # If there is no newline - else: - if len(c) > size: i = size - 1 # If lineis larger than size - - bufs = bufs + c - size = size - len(c) - readsize = min(size, int(readsize * 1.1)) - - # Optimize future readline() calls - if readsize > self.min_readsize: - self.min_readsize = readsize + bufs.append(c[:i+1]) # Add portion of last chunk + self._unread(c[i+1:]) # Push back rest of chunk + return ''.join(bufs) # Return resulting line + + # Append chunk to list, decrease 'size', + bufs.append(c) + size = size - len(c) + readsize = min(size, readsize * 2) def readlines(self, sizehint=0): # Negative numbers result in reading all the lines From python-checkins at python.org Mon May 22 17:26:18 2006 From: python-checkins at python.org (sean.reifschneider) Date: Mon, 22 May 2006 17:26:18 +0200 (CEST) Subject: [Python-checkins] r46072 - python/branches/sreifschneider-64ints Message-ID: <20060522152618.7334F1E401A@bag.python.org> Author: sean.reifschneider Date: Mon May 22 17:26:16 2006 New Revision: 46072 Added: python/branches/sreifschneider-64ints/ - copied from r46071, python/trunk/ Log: Branch for trying out 64-bit ints. From python-checkins at python.org Mon May 22 17:35:14 2006 From: python-checkins at python.org (fredrik.lundh) Date: Mon, 22 May 2006 17:35:14 +0200 (CEST) Subject: [Python-checkins] r46073 - python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Message-ID: <20060522153514.6B8431E4007@bag.python.org> Author: fredrik.lundh Date: Mon May 22 17:35:12 2006 New Revision: 46073 Modified: python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: docstring tweaks: count counts non-overlapping substrings, not total number of occurences Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Mon May 22 17:35:12 2006 @@ -2159,9 +2159,9 @@ PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ -Return the number of occurrences of substring sub in string\n\ -S[start:end]. Optional arguments start and end are\n\ -interpreted as in slice notation."); +Return the number of non-overlapping occurrences of substring sub in\n\ +string S[start:end]. Optional arguments start and end are interpreted\n\ +as in slice notation."); static PyObject * string_count(PyStringObject *self, PyObject *args) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon May 22 17:35:12 2006 @@ -5078,8 +5078,8 @@ PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ -Return the number of occurrences of substring sub in Unicode string\n\ -S[start:end]. Optional arguments start and end are\n\ +Return the number of non-overlapping occurrences of substring sub in\n\ +Unicode string S[start:end]. Optional arguments start and end are\n\ interpreted as in slice notation."); static PyObject * From python-checkins at python.org Mon May 22 17:47:16 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 22 May 2006 17:47:16 +0200 (CEST) Subject: [Python-checkins] r46074 - sandbox/trunk/decimal-c sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h Message-ID: <20060522154716.5ABC51E4007@bag.python.org> Author: georg.brandl Date: Mon May 22 17:47:15 2006 New Revision: 46074 Added: sandbox/trunk/decimal-c/ sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h Log: Import first skeleton of C decimal module. Added: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/_decimal.c Mon May 22 17:47:15 2006 @@ -0,0 +1,1942 @@ +/* C implementation of the decimal module. + */ + +#include "Python.h" +#include "modsupport.h" +#include "structmember.h" +#include "decimal.h" + +/* helpful macros ************************************************************/ + +#define MODULE_NAME "_decimal" +#define INITFUNC_NAME init_decimal + +#define contextobject PyDecimalContextObject +#define decimalobject PyDecimalObject + +#define ISFLAGSET(f, b) (((f) >> b) & 1) +#define SETFLAG(f, b) (f |= (1 << b)) + +/* Checks */ + +#define ISSPECIAL(op) ((op)->sign >= SIGN_POSINF) +#define GETNAN(op) ( ( (op)->sign == SIGN_POSNAN || (op)->sign == SIGN_NEGNAN ) ? \ + 1 : ( ( (op)->sign == SIGN_POSSNAN || (op)->sign == SIGN_NEGSNAN ) ? 2 : 0 ) ) +#define ISINF(op) ((op)->sign == SIGN_POSINF || (op)->sign == SIGN_NEGINF) + +/* Exponent calculations */ + +/* XXX: overflow? */ +#define ETINY(ctx) ((ctx)->Emin - (ctx)->prec + 1) +#define ETOP(ctx) ((ctx)->Emax - (ctx)->prec + 1) +#define ADJUSTED(dec) ((dec)->exp + (dec)->ob_size - 1) + +/* constant values ***********************************************************/ + +/* sign values */ + +#define SIGN_POS 0 +#define SIGN_NEG 1 + +#define SIGN_POSINF 2 +#define SIGN_NEGINF 3 +#define SIGN_POSNAN 4 +#define SIGN_NEGNAN 5 +#define SIGN_POSSNAN 6 +#define SIGN_NEGSNAN 7 + + +/* Rounding constants */ + +#define ROUND_DOWN 0 +#define ROUND_UP 1 +#define ROUND_HALF_DOWN 2 +#define ROUND_HALF_EVEN 3 +#define ROUND_HALF_UP 4 +#define ROUND_FLOOR 5 +#define ROUND_CEILING 6 + +#define ALWAYS_ROUND 0 +#define NEVER_ROUND 16 + +/* Context signals */ + +#define NUMSIGNALS 8 + +#define S_CLAMPED 0 +#define S_INV_OPERATION 1 +#define S_DIV_BY_ZERO 2 +#define S_INEXACT 3 +#define S_ROUNDED 4 +#define S_OVERFLOW 5 +#define S_UNDERFLOW 6 +#define S_SUBNORMAL 7 + +/* Other conditions (for context_raise_error) */ + +#define NUMCONDITIONS 4 + +#define C_DIV_IMPOSSIBLE 8 +#define C_DIV_UNDEFINED 9 +#define C_INV_CONTEXT 10 +#define C_CONV_SYNTAX 11 + + +/* Exceptions ****************************************************************/ + +/* Indentation below hints at inheritance. */ + +static PyObject *DecimalException; +static PyObject *Clamped; +static PyObject *InvalidOperation; +static PyObject *ConversionSyntax; +static PyObject *DivisionImpossible; +static PyObject *DivisionUndefined; /* also inherits ZeroDivisionError */ +static PyObject *InvalidContext; +static PyObject *DivisionByZero; /* also inherits ZeroDivisionError */ +static PyObject *Inexact; +static PyObject *Rounded; +static PyObject *Overflow; /* also inherits Inexact */ +static PyObject *Underflow; /* also inherits Inexact, Subnormal */ +static PyObject *Subnormal; + +static PyObject *errors[NUMSIGNALS+NUMCONDITIONS]; + +#define MAKE_METHODDEF(name) \ + static PyMethodDef ml_##name = {"handle", (PyCFunction)handle_##name, \ + METH_VARARGS}; + +/* These are the "handle" methods for the individual exception classes. + * They are attached in init_decimal. */ + +static PyObject * +handle_DecimalException(PyObject *self, PyObject *args) +{ + /* XXX: implement */ + Py_RETURN_NONE; +} +MAKE_METHODDEF(DecimalException) + +static PyObject * +handle_InvalidOperation(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(InvalidOperation) + +static PyObject * +handle_ConversionSyntax(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(ConversionSyntax) + +static PyObject * +handle_DivisionByZero(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(DivisionByZero) + +static PyObject * +handle_DivisionImpossible(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(DivisionImpossible) + +static PyObject * +handle_DivisionUndefined(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(DivisionUndefined) + +static PyObject * +handle_InvalidContext(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(InvalidContext) + +static PyObject * +handle_Overflow(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} +MAKE_METHODDEF(Overflow) + +/* Forwarding ****************************************************************/ + +static contextobject *getcontext(void); +static int setcontext(contextobject *); +static decimalobject *context_raise_error(contextobject *, int, char *, PyObject *); +static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); +static int decimal_nonzero(decimalobject *); +static decimalobject *decimal_copy(decimalobject *); + +/* Decimal methods ***********************************************************/ + + +static decimalobject * +_new_decimalobj(Py_ssize_t ndigits, char sign, long exp) +{ + decimalobject *new; + if (ndigits > PY_SSIZE_T_MAX) { + PyErr_NoMemory(); + return NULL; + } + new = (decimalobject *)PyObject_NEW_VAR(decimalobject, &PyDecimal_DecimalType, ndigits); + if (new == NULL) + return NULL; + new->sign = sign; + new->exp = exp; + return new; +} + +/* Check whether the number(s) aren't really numbers. + * + * If x and/or y are sNaN, signal, possibly storing the result + * of handle() in res (and return 1) + * If x and/or y are NaN, store NaN in res (and return 1) + * else return 0. + * On an unexpected error, return -1. + */ +static int +_check_nans(decimalobject *x, decimalobject *y, contextobject *ctx, decimalobject **res) +{ + int nan1 = GETNAN(x); + int nan2 = 0; + + if (y) + nan2 = GETNAN(y); + + if (nan1 || nan2) { + PyObject *tup; + + if (nan1 == 2) { + tup = Py_BuildValue("iO", 1, x); + if (!tup) + return -1; + *res = context_raise_error(ctx, S_INV_OPERATION, "sNaN", tup); + if (*res == NULL) + return -1; + return 1; + } else if (nan2 == 2) { + tup = Py_BuildValue("iO", 1, y); + if (!tup) + return -1; + *res = context_raise_error(ctx, S_INV_OPERATION, "sNaN", tup); + if (*res == NULL) + return -1; + return 1; + } + + if (nan1) + *res = x; + else + *res = y; + /* since context_raise_error above returns new references, to be + * consistent we must incref the returns here too. */ + Py_INCREF(*res); + return 1; + } + return 0; +} + +/* default: rounding=-1 (use context), see the ROUND_* constants */ +static decimalobject * +_decimal_round(decimalobject *self, long prec, contextobject *ctx, int rounding) +{ + /* XXX */ + Py_RETURN_NONE; +} + +/* Default values: rounding=-1 (use context), watchexp=1 */ +static decimalobject * +_decimal_rescale(decimalobject *self, long exp, contextobject *ctx, + int rounding, int watchexp) +{ + decimalobject *ans = NULL; + int ret; + long diff; + Py_ssize_t digits, i; + + if (ISSPECIAL(self)) { + if (ISINF(self)) + return context_raise_error(ctx, S_INV_OPERATION, "rescale with an INF", NULL); + ret = _check_nans(self, NULL, ctx, &ans); + if (ret != 0) + /* ans is NULL in case of an error */ + return ans; + } + + if (watchexp && (exp > ctx->Emax || exp < ETINY(ctx))) + return context_raise_error(ctx, S_INV_OPERATION, "rescale(a, INF)", NULL); + + if (!decimal_nonzero(self)) { + ans = _new_decimalobj(1, self->sign, exp); + if (!ans) + return NULL; + ans->digits[0] = 0; + return ans; + } + + diff = self->exp - exp; + digits = self->ob_size + diff; + + if (watchexp && ctx->prec < digits) + return context_raise_error(ctx, S_INV_OPERATION, "Rescale > prec", NULL); + + digits += 1; + ans = _new_decimalobj(self->ob_size+1, self->sign, self->exp); + if (!ans) + return NULL; + for (i = 0; i < self->ob_size; i++) + ans->digits[i+1] = self->digits[i]; + ans->digits[0] = 0; + + if (digits < 0) { + ans->exp = -digits + ans->exp; + /* XXX: not complete... */ + } + + + +} + +/* Fix the exponents and return a copy with the exponents in bounds. + * Only call if known not to be a special value. */ +static decimalobject * +_fixexponents(decimalobject *self, contextobject *ctx) +{ + decimalobject *ans = NULL, *tmp; + PyObject *tup; + long adj; + assert(!ISSPECIAL(self)); + + adj = ADJUSTED(self); + if (adj < ctx->Emin) { + long Etiny = ETINY(ctx); + if (self->exp < Etiny) { + if (!decimal_nonzero(self)) { + ans = decimal_copy(self); + if (!ans) + return NULL; + ans->exp = Etiny; + tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + if (!tmp) + goto err; + Py_DECREF(tmp); + return ans; + } + ans = _decimal_rescale(self, Etiny, ctx, -1, 1); + if (!ans) + return NULL; + tmp = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + if (!tmp) + goto err; + Py_DECREF(tmp); + if (ISFLAGSET(ctx->flags, S_INEXACT)) { + tmp = context_raise_error(ctx, S_UNDERFLOW, NULL, NULL); + if (!tmp) + goto err; + Py_DECREF(tmp); + } + return ans; + } else { + if (decimal_nonzero(self)) { + tmp = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + if (!tmp) + return NULL; + Py_DECREF(tmp); + } + /* this returns self, below */ + } + } else { + long Etop = ETOP(ctx); + if (ctx->clamp && self->exp > Etop) { + tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + if (!tmp) + return NULL; + Py_DECREF(tmp); + ans = _decimal_rescale(self, Etop, ctx, -1, 1); + if (!ans) + return NULL; + return ans; + } else { + if (adj > ctx->Emax) { + if (!decimal_nonzero(self)) { + ans = decimal_copy(self); + if (!ans) + return NULL; + ans->exp = ctx->Emax; + tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + if (!tmp) + goto err; + Py_DECREF(tmp); + return ans; + } + tmp = context_raise_error(ctx, S_INEXACT, NULL, NULL); + if (!tmp) + return NULL; + Py_DECREF(tmp); + tmp = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + if (!tmp) + return NULL; + Py_DECREF(tmp); + tup = Py_BuildValue("(b)", self->sign); + if (!tup) + return NULL; + ans = context_raise_error(ctx, S_OVERFLOW, "above Emax", tup); + Py_DECREF(tup); + return ans; + } + } + } + + Py_INCREF(self); + return self; +err: + Py_XDECREF(ans); + return NULL; +} + +static decimalobject * +_decimal_fix(decimalobject *self, contextobject *ctx) +{ + decimalobject *ans = NULL; + + if (ISSPECIAL(self)) { + Py_INCREF(self); + return self; + } + + ans = _fixexponents(self, ctx); + if (!ans) + return NULL; + + if (ans->ob_size > ctx->prec) { + decimalobject *rounded; + rounded = _decimal_round(ans, ctx->prec, ctx, -1); + Py_DECREF(ans); + if (!rounded) + return NULL; + ans = _fixexponents(self, ctx); + Py_DECREF(rounded); + if (!ans) + return NULL; + } + return ans; +} + +#define STUB_HEAD static PyObject * +#define STUB_TAIL (PyObject *self, PyObject *args) { return NULL; } +#define STUB_TAIL1 (PyObject *self) { return NULL; } +#define STUB(name) STUB_HEAD decimal_##name STUB_TAIL +#define STUB1(name) STUB_HEAD decimal_##name STUB_TAIL1 + +static char *ctxkwlist[] = {"context", 0}; + +#define PARSECONTEXT(methname) \ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" methname, ctxkwlist, &ctx)) \ + { return NULL; } \ + if (ctx == NULL) { \ + if (!(ctx = getcontext())) return NULL; \ + } + +STUB(compare) +STUB(max) +STUB(min) + +static PyObject * +decimal_normalize(decimalobject *self, PyObject *args, PyObject *kwds) +{ + decimalobject *dup; + contextobject *ctx = NULL; + PARSECONTEXT("normalize"); + + if (ISSPECIAL(self)) { + decimalobject *nan = NULL; + int res; + res = _check_nans(self, NULL, ctx, &nan); + /* if error set or NaN returned, return */ + if (res != 0) return (PyObject *)nan; + } + + dup = _decimal_fix(self, ctx); + + /* XXX: incomplete */ +} + +STUB(quantize) +STUB(remainder_near) +STUB(same_quantum) +STUB(sqrt) +STUB(to_eng_string) +STUB(to_integral) +STUB(reduce) +STUB(deepcopy) + +static decimalobject * +decimal_copy(decimalobject *self) +{ + decimalobject *new; + Py_ssize_t size = self->ob_size; + + new = _new_decimalobj(size, self->sign, self->exp); + if (!new) + return NULL; + while (--size) + new->digits[size] = self->digits[size]; + return new; +} + +static PyObject * +decimal_adjusted(decimalobject *self) +{ + if (ISSPECIAL(self)) + return PyInt_FromLong(0); + + /* XXX: Overflow? */ + return PyInt_FromSsize_t(ADJUSTED(self)); +} + +static PyObject * +decimal_as_tuple(decimalobject *self) +{ + PyObject *digits, *res, *d; + Py_ssize_t i; + + digits = PyTuple_New(self->ob_size); + if (!digits) + return NULL; + + for (i = 0; i < self->ob_size; i++) { + d = PyInt_FromLong(self->digits[i]); + if (!d) return NULL; + PyTuple_SET_ITEM(digits, i, d); + } + + res = Py_BuildValue("(bOn)", self->sign % 2, digits, self->exp); + Py_DECREF(digits); + return res; +} + +static PyMethodDef decimal_methods[] = { + {"adjusted", (PyCFunction)decimal_adjusted, + METH_NOARGS, + PyDoc_STR("Return the adjusted exponent of self.")}, + {"as_tuple", (PyCFunction)decimal_as_tuple, + METH_NOARGS, + PyDoc_STR("Represents the number as a triple tuple.\n\n" + "To show the internals exactly as they are.")}, + {"compare", (PyCFunction)decimal_compare, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Compares one to another.\n\n -1 => a < b\n" + " 0 => a = b\n 1 => a > b\n" + " NaN => one is NaN\n" + "Like __cmp__, but returns Decimal instances.")}, + {"max", (PyCFunction)decimal_max, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Returns the larger value.\n\n" + "like max(self, other) except if one is not a number, \n" + "returns NaN (and signals if one is sNaN). Also rounds.")}, + {"min", (PyCFunction)decimal_min, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Returns the smaller value.\n\n" + "like min(self, other) except if one is not a number, \n" + "returns NaN (and signals if one is sNaN). Also rounds.")}, + {"normalize", (PyCFunction)decimal_normalize, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Normalize- strip trailing 0s, change anything equal" + "to 0 to 0e0")}, + {"quantize", (PyCFunction)decimal_quantize, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Quantize self so its exponent is the same as that of exp.\n\n" + "Similar to self._rescale(exp._exp) but with error checking.")}, + {"remainder_near", (PyCFunction)decimal_remainder_near, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Remainder nearest to 0- abs(remainder-near) <= other/2")}, + {"same_quantum", (PyCFunction)decimal_same_quantum, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Test whether self and other have the same exponent.\n\n" + "same as self._exp == other._exp, except NaN == sNaN")}, + {"sqrt", (PyCFunction)decimal_sqrt, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Return the square root of self.\n\n" + "Uses a converging algorithm (Xn+1 = 0.5*(Xn + self / Xn))\n" + "Should quadratically approach the right answer.")}, + {"to_eng_string", (PyCFunction)decimal_to_eng_string, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Convert to engineering-type string.\n\n" + "Engineering notation has an exponent which is a multiple " + "of 3, so there\nare up to 3 digits left of the decimal " + "place.\n\nSame rules for when in exponential and when as " + "a value as in __str__.")}, + {"to_integral", (PyCFunction)decimal_to_integral, + METH_VARARGS | METH_KEYWORDS, + PyDoc_STR("Rounds to the nearest integer, without raising " + "inexact, rounded.")}, + {"__reduce__", (PyCFunction)decimal_reduce, + METH_NOARGS}, + {"__copy__", (PyCFunction)decimal_copy, + METH_NOARGS}, + {"__deepcopy__", decimal_deepcopy, + METH_O}, + {NULL, NULL} +}; + +static char decimal_doc[] = +PyDoc_STR("Floating point class for decimal arithmetic."); + +STUB(add) +STUB(subtract) +STUB(multiply) +STUB(divide) +STUB(remainder) +STUB(divmod) +STUB(power) +STUB1(negative) +STUB1(positive) +STUB1(absolute) +STUB1(invert) +STUB1(int) +STUB1(long) +STUB1(float) +STUB(floor_div) +STUB(true_div) + +static int +decimal_nonzero(decimalobject *self) +{ + /* XXX */ + return 0; +} + +static PyNumberMethods decimal_as_number = { + decimal_add, /* nb_add */ + decimal_subtract, /* nb_subtract */ + decimal_multiply, /* nb_multiply */ + decimal_divide, /* nb_divide */ + decimal_remainder, /* nb_remainder */ + decimal_divmod, /* nb_divmod */ + decimal_power, /* nb_power */ + decimal_negative, /* nb_negative */ + decimal_positive, /* nb_positive */ + decimal_absolute, /* nb_absolute */ + decimal_nonzero, /* nb_nonzero */ + decimal_invert, /* nb_invert */ + 0, /* nb_lshift */ + 0, /* nb_rshift */ + 0, /* nb_and */ + 0, /* nb_xor */ + 0, /* nb_or */ + 0, /* nb_coerce */ + decimal_int, /* nb_int */ + decimal_long, /* nb_long */ + decimal_float, /* nb_float */ + 0, /* nb_oct */ + 0, /* nb_hex */ + 0, /* nb_inplace_add */ + 0, /* nb_inplace_subtract */ + 0, /* nb_inplace_multiply */ + 0, /* nb_inplace_divide */ + 0, /* nb_inplace_remainder */ + 0, /* nb_inplace_power */ + 0, /* nb_inplace_lshift */ + 0, /* nb_inplace_rshift */ + 0, /* nb_inplace_and */ + 0, /* nb_inplace_xor */ + 0, /* nb_inplace_or */ + decimal_floor_div, /* nb_floor_divide */ + decimal_true_div, /* nb_true_divide */ + 0, /* nb_inplace_floor_divide */ + 0, /* nb_inplace_true_divide */ + 0, /* nb_index */ + +}; + + +static PyObject * +decimal_richcompare(decimalobject *a, decimalobject *b, int op) +{ + /* XXX */ + return NULL; +} + +int +_decimal_isint(decimalobject *d) +{ + Py_ssize_t i; + + if (d->exp >= 0) + /* if the exponent is positive, there's no + * fractional part at all. */ + return 1; + /* Here comes the tricky part. We have to find out + * whether the fractional part consists only of zeroes. */ + for (i = d->ob_size-1; i > d->ob_size + d->exp; --i) { + if (d->digits[i] > 0) + return 0; + } + return 1; +} + +static void +decimal_dealloc(PyObject *d) +{ + d->ob_type->tp_free(d); +} + +static decimalobject * +_decimal_fromliteralnan(char *str, Py_ssize_t len, contextobject *ctx) +{ + char literalsign = 0, sign = 0; + decimalobject *new; + Py_ssize_t size = 0, i; + char *start, *p; + + if (len < 3) + return NULL; + /* remove sign */ + if (str[0] == '+') + str++; + else if (str[0] == '-') { + str++; + literalsign = 1; + } + if (tolower(str[0]) == 'n' && + tolower(str[1]) == 'a' && + tolower(str[2]) == 'n') { + + sign = (literalsign ? SIGN_NEGNAN : SIGN_POSNAN); + if (len < 4) goto finish; + p = str+3; + } else if (tolower(str[0]) == 's' && + tolower(str[1]) == 'n' && + tolower(str[2]) == 'a' && + tolower(str[3]) == 'n') { + sign = (literalsign ? SIGN_NEGSNAN : SIGN_POSSNAN); + if (len < 5) goto finish; + p = str+4; + } else { + return NULL; + } + /* diagnostic info: skip leading zeroes */ + while (*p == '0') + p++; + start = p; + while (isdigit(*p++)) + size++; + if (p == str+len+1) + goto finish; + return NULL; + +finish: + if (size > ctx->prec) + return context_raise_error(ctx, C_CONV_SYNTAX, + "diagnostic info too long", NULL); + + new = _new_decimalobj(size, sign, 0); + if (!new) + return NULL; + for (i = 0; i < size; i++) + new->digits[i] = *(start+i) -48; + return new; +} + +static char *infinities[] = { + "inf", "infinity", "+inf", "+infinity", + "-inf", "-infinity", 0 +}; + +static decimalobject * +_decimal_fromliteralinfinity(char *str) +{ + decimalobject *new; + char **p = infinities; + char sign = 0; + do { + if (strcasecmp(str, *p) == 0) { + if (str[0] == '-') + sign = SIGN_NEGINF; + else + sign = SIGN_POSINF; + break; + } + } while (*++p); + if (sign) { + new = _new_decimalobj(1, sign, 0); + if (!new) + return NULL; + new->digits[0] = 0; + return new; + } + return NULL; +} + +static decimalobject * +_decimal_fromliteral(char *str, Py_ssize_t len, contextobject *ctx) +{ + Py_ssize_t ipos = 0; /* start of integral digits */ + Py_ssize_t dpos = -1; /* decimal point location */ + Py_ssize_t dend = len; /* end of integral/decimal digits */ + char *p = str; + char sign = 0; + decimalobject *new; + long exp = 0; + Py_ssize_t i = 0, ndigits; + + /* optional sign */ + if (*p == '+') { + ++p; + ipos = 1; + } else if (*p == '-') { + ++p; + ipos = 1; + sign = 1; + } + + do { + if (*p == '.') { + dpos = p-str; + } else if (*p == 'e' || *p == 'E') { + dend = p-str; + if (dend == ipos || (dpos >= 0 && dend == ipos+1)) + /* no digits between sign and E */ + goto err; + ++p; + break; + } else if (!isdigit(*p)) { + goto err; + } + } while (*++p); + + /* exponential part or end of string */ + if (*p == 0) { + if (ipos == dpos && dpos == dend-1) + /* no digits at all */ + goto err; + goto finish; + } else if (*p == '-' || *p == '+') { + ++p; + } + + do { + /* optional exponential digits */ + if (!isdigit(*p)) + goto err; + } while (*++p); + +finish: + + if (dend < len) + /* XXX: which function to convert a string to ssize_t? */ + exp = atol(str + dend + 1); + if (dpos >= 0) + /* specified fractional digits, reduce exp */ + exp -= dend - dpos - 1; + + ndigits = dend - ipos - (dpos<0 ? 0 : 1); + new = _new_decimalobj(ndigits, sign, exp); + if (!new) + return NULL; + /* XXX: leading zeroes are not stripped */ + for (p = str+ipos; p-str < dend; ++p) { + if (*p == '.') continue; + new->digits[i] = *p - 48; + i++; + } + return new; + +err: + return context_raise_error(ctx, C_CONV_SYNTAX, + "invalid literal for Decimal", NULL); +} + +PyObject * +PyDecimal_FromString(char *buffer, Py_ssize_t buf_len, contextobject *ctx) +{ + decimalobject *new; + + new = _decimal_fromliteralinfinity(buffer); + if (new) return (PyObject *)new; + if (PyErr_Occurred()) return NULL; + + new = _decimal_fromliteralnan(buffer, buf_len, ctx); + if (new) return (PyObject *)new; + if (PyErr_Occurred()) return NULL; + + return (PyObject *)_decimal_fromliteral(buffer, buf_len, ctx); +} + + +PyObject * +PyDecimal_FromLong(long value) +{ + decimalobject *new; + long v = value; + int ndigits = 0, neg = 0, i = 0; + + if (value == 0) { + new = _new_decimalobj(1, 0, 0); + if (!new) return NULL; + new->digits[0] = 0; + return (PyObject *)new; + } else if (value < 0) { + v = -value; + neg = 1; + } + + while (v) { + ndigits++; + v /= 10; + } + + new = _new_decimalobj(ndigits, (neg ? SIGN_NEG : SIGN_POS), 0); + if (!new) return NULL; + while (value) { + new->digits[ndigits-i-1] = value % 10; + value /= 10; + i++; + } + return (PyObject *)new; +} + +/* convert from a 3-tuple of (sign, digits, exp) */ +PyObject * +PyDecimal_FromSequence(PyObject *seq) +{ + decimalobject *new; + PyObject *tup, *digits, *digtup = NULL, *item; + int sign; + long exp; + Py_ssize_t i; + + if (PyTuple_Check(seq)) { + tup = seq; + Py_INCREF(tup); + } else { + tup = PySequence_Tuple(seq); + if (!tup) + return NULL; + } + + if (PyTuple_GET_SIZE(tup) != 3) { + PyErr_SetString(PyExc_ValueError, "Invalid arguments"); + return NULL; + } + if (!PyArg_ParseTuple(tup, "iOl", &sign, &digits, &exp)) + return NULL; + if (sign < 0 || sign > 7) { + PyErr_SetString(PyExc_ValueError, "Invalid sign"); + return NULL; + } + digtup = PySequence_Tuple(digits); + if (!digtup) { + PyErr_SetString(PyExc_ValueError, "Invalid arguments"); + goto err; + } + new = _new_decimalobj(PyTuple_GET_SIZE(digtup), sign, exp); + for (i = 0; i < new->ob_size; i++) { + item = PyTuple_GET_ITEM(digtup, i); + if (PyInt_Check(item)) { + long x = PyInt_AsLong(item); + if (x < 0 || x > 9) { + PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x); + return NULL; + } + new->digits[i] = (signed char)x; + } else if (PyLong_Check(item)) { + long x = PyLong_AsLong(item); + if (x == -1 && PyErr_Occurred()) + return NULL; + if (x < 0 || x > 9) { + PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x); + return NULL; + } + new->digits[i] = (signed char)x; + } else { + PyErr_SetString(PyExc_ValueError, "The second value in the tuple " + "must be composed of non negative integer elements."); + return NULL; + } + } + + Py_DECREF(digtup); + Py_DECREF(tup); + return (PyObject *)new; + +err: + Py_XDECREF(digtup); + Py_DECREF(tup); + Py_DECREF(new); + return NULL; +} + +static PyObject * +decimal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"value", "context", 0}; + PyObject *value = NULL; + PyObject *context = NULL; + PyObject *repr; + contextobject *ctx; + int decref_value = 0; + char *buffer; + Py_ssize_t buf_len = 0; + + /* XXX + if (type != &PyDecimal_DecimalType) + return decimal_subtype_new(type, args, kwds); + */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:Decimal", + kwlist, &value, &context)) + return NULL; + if (value == NULL) { + value = PyString_FromString("0"); + decref_value = 1; + } + + if (PyFloat_Check(value)) { + PyErr_SetString(PyExc_TypeError, "Cannot convert float to Decimal. " + "First convert the float to a string."); + return NULL; + } + + if (PyDecimal_Check(value)) + return (PyObject *)decimal_copy((decimalobject *)value); + + if (PyList_Check(value) || PyTuple_Check(value)) + return PyDecimal_FromSequence(value); + + if (PyInt_Check(value)) { + long x = PyInt_AsLong(value); + if (x == -1 && PyErr_Occurred()) + return NULL; + return PyDecimal_FromLong(x); + } + + if (PyLong_Check(value)) { + /* XXX: possibly do div-mod-loop */ + value = PyObject_Str(value); + if (!value) + return NULL; + decref_value = 1; + } + + ctx = getcontext(); + if (!ctx) { + if (decref_value) { + Py_DECREF(value); + } + return NULL; + } + + /* try buffer interface (e.g. strings and unicode) */ + if (PyObject_AsCharBuffer(value, (const char **)&buffer, &buf_len) == 0) { + PyObject *res = (PyObject *)PyDecimal_FromString(buffer, buf_len, ctx); + if (decref_value) { + Py_DECREF(value); + } + return res; + } + + /* if PyObject_AsCharBuffer didn't set a TypeError, fail immediately */ + if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_TypeError)) + return NULL; + + /* no suitable type found */ + repr = PyObject_Repr(value); + if (!repr) + return NULL; + if (!PyString_Check(repr)) + PyErr_SetString(PyExc_TypeError, "Cannot convert object to Decimal"); + else + PyErr_Format(PyExc_TypeError, "Cannot convert %s to Decimal", + PyString_AS_STRING(repr)); + Py_DECREF(repr); + return NULL; +} + +static PyObject * +decimal_str(decimalobject *d) +{ + /* XXX: quick hack */ + char buf[1000]; + char dig[2]; + Py_ssize_t i; + + dig[1] = 0; + PyOS_snprintf(buf, 1000, "sign=%i, exp=%ld, digits=", d->sign, d->exp); + for (i = 0; i < d->ob_size; i++) { + dig[0] = d->digits[i]+48; + strcat(buf, dig); + } + return PyString_FromString(buf); +} + +static PyObject * +decimal_repr(decimalobject *d) +{ + PyObject *str, *res; + static PyObject *format; + + if (!format) { + format = PyString_FromString("Decimal(\"%s\")"); + } + str = decimal_str(d); + if (!str) + return NULL; + res = PyString_Format(format, str); + Py_DECREF(str); + return res; +} + +static long +decimal_hash(decimalobject *d) +{ + PyObject *tmp, *tmp2; + long hash; + + if (ISSPECIAL(d)) { + if (GETNAN(d)) { + PyErr_SetString(PyExc_TypeError, "Cannot hash a NaN value."); + return -1; + } + tmp = decimal_str(d); + if (!tmp) + return -1; + hash = PyObject_Hash(tmp); + Py_DECREF(tmp); + return hash; + } + if (_decimal_isint(d)) { + tmp = decimal_int(d); + if (!tmp) + return -1; + hash = PyObject_Hash(tmp); + Py_DECREF(tmp); + return hash; + } + tmp2 = PyTuple_New(0); + if (!tmp2) + return -1; + tmp = decimal_normalize(d, tmp2, NULL); + Py_DECREF(tmp2); + if (!tmp) + return -1; + tmp2 = decimal_str((decimalobject *)tmp); + Py_DECREF(tmp); + if (!tmp2) + return -1; + hash = PyObject_Hash(tmp2); + Py_DECREF(tmp2); + return hash; +} + + +static PyTypeObject PyDecimal_DecimalType = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + MODULE_NAME ".Decimal", /* tp_name */ + sizeof(decimalobject) - sizeof(char), /* tp_basicsize */ + sizeof(char), /* tp_itemsize */ + (destructor)decimal_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)decimal_repr, /* tp_repr */ + &decimal_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)decimal_hash, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)decimal_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + decimal_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)decimal_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + decimal_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + decimal_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + + +/* Context threading magic ***************************************************/ + +#ifdef WITH_THREAD + +static contextobject * +getcontext(void) +{ + PyObject *tdict; + contextobject *ctx; + + tdict = PyThreadState_GetDict(); + if (!tdict) { + PyErr_SetString(PyExc_SystemError, + "Couldn't get thread-state dictionary"); + return NULL; + } + ctx = (contextobject *)PyDict_GetItemString(tdict, MODULE_NAME ".context"); + if (!ctx) { + PyObject *args; + args = PyTuple_New(0); + if (!args) + return NULL; + ctx = (contextobject *)context_new(&PyDecimal_DecimalContextType, args, NULL); + Py_DECREF(args); + if (!ctx) + return NULL; + if (PyDict_SetItemString(tdict, MODULE_NAME ".context", + (PyObject *)ctx) < 0) { + Py_DECREF(ctx); + return NULL; + } + /* clear the KeyError */ + PyErr_Clear(); + return ctx; + } + Py_INCREF(ctx); + return ctx; +} + +static int +setcontext(contextobject *ctx) +{ + PyObject *tdict; + + tdict = PyThreadState_GetDict(); + if (!tdict) { + PyErr_SetString(PyExc_SystemError, + "Couldn't get thread-state dictionary"); + return -1; + } + if (PyDict_SetItemString(tdict, MODULE_NAME ".context", + (PyObject *)ctx) < 0) + return -1; + return 0; +} + +#else + +static PyObject *current_context; + +static contextobject * +getcontext() +{ + if (current_context == NULL) { + PyObject *args; + args = PyTuple_New(0); + if (!args) + return NULL; + current_context = context_new(&PyDecimal_DecimalContextType, args, NULL); + Py_DECREF(args); + if (!current_context) + return NULL; + } + return (contextobject *)current_context; +} + +static int +setcontext(contextobject *ctx) +{ + Py_CLEAR(current_context); + Py_INCREF(ctx); + current_context = ctx; + return 0; +} + +#endif /* WITH_THREAD */ + +/* Context object ************************************************************/ + +static contextobject * +_new_contextobj(long prec, int rounding, int rounding_dec, int traps, + int flags, long Emin, long Emax, int capitals, + int clamp, int ignored) +{ + contextobject *new; + new = (contextobject *)PyObject_NEW(contextobject, &PyDecimal_DecimalContextType); + if (new == NULL) + return NULL; + new->prec = prec; + new->rounding = rounding; + new->rounding_dec = rounding_dec; + new->Emin = Emin; + new->Emax = Emax; + new->capitals = capitals; + new->clamp = clamp; + new->flags = flags; + new->traps = traps; + new->ignored = ignored; + return new; +} + +/* Context methods ***********************************************************/ + +static decimalobject * +context_raise_error(contextobject *self, int cond, char *explanation, PyObject *args) +{ + int err = cond; + PyObject *exc, *res, *func; + + /* map subclasses of InvalidOperation to InvalidOperation */ + if (cond >= NUMSIGNALS) + err = S_INV_OPERATION; + + if (ISFLAGSET(self->ignored, err)) { + exc = PyObject_CallObject(errors[err], NULL); + if (!exc) + return NULL; + func = PyObject_GetAttrString(exc, "handle"); + if (!func) { + Py_DECREF(exc); + return NULL; + } + res = PyObject_CallObject(func, args); + Py_DECREF(func); + Py_DECREF(exc); + if (res == NULL) + return NULL; + return (decimalobject *)res; + } + + SETFLAG(self->flags, err); + if (!ISFLAGSET(self->traps, err)) { + /* Let the exception class decide how to handle the condition. */ + exc = PyObject_CallObject(errors[cond], NULL); + if (!exc) + return NULL; + func = PyObject_GetAttrString(exc, "handle"); + if (!func) { + Py_DECREF(exc); + return NULL; + } + res = PyObject_CallObject(func, args); + Py_DECREF(func); + Py_DECREF(exc); + if (res == NULL) + return NULL; + return (decimalobject *)res; + } + + PyErr_SetString(errors[err], (explanation ? explanation : "")); + return NULL; +} + +#define CSTUB(name) STUB_HEAD context_##name STUB_TAIL + +static PyObject * +context_clear_flags(contextobject *self) +{ + self->flags = 0; + Py_RETURN_NONE; +} + +static PyObject * +context_copy(contextobject *self) +{ + return NULL; +} + +CSTUB(create_decimal) + +static PyObject * +context_Etiny(contextobject *self) +{ + return PyInt_FromSsize_t(ETINY(self)); +} + +static PyObject * +context_Etop(contextobject *self) +{ + return PyInt_FromSsize_t(ETOP(self)); +} + +CSTUB(abs) +CSTUB(add) +CSTUB(compare) +CSTUB(divide) +CSTUB(divmod) +CSTUB(max) +CSTUB(min) +CSTUB(minus) +CSTUB(multiply) +CSTUB(normalize) +CSTUB(plus) +CSTUB(power) +CSTUB(quantize) +CSTUB(remainder) +CSTUB(remainder_near) +CSTUB(same_quantum) +CSTUB(sqrt) +CSTUB(subtract) +CSTUB(to_eng_string) +CSTUB(to_integral) +CSTUB(to_sci_string) + + +static PyMethodDef context_methods[] = { + {"clear_flags", (PyCFunction)context_clear_flags, + METH_NOARGS}, + {"copy", (PyCFunction)context_copy, + METH_NOARGS}, + {"create_decimal", (PyCFunction)context_create_decimal, + METH_VARARGS | METH_KEYWORDS}, + {"Etiny", (PyCFunction)context_Etiny, + METH_NOARGS}, + {"Etop", (PyCFunction)context_Etop, + METH_NOARGS}, + {"abs", (PyCFunction)context_abs, + METH_VARARGS | METH_KEYWORDS}, + {"add", (PyCFunction)context_add, + METH_VARARGS | METH_KEYWORDS}, + {"compare", (PyCFunction)context_compare, + METH_VARARGS | METH_KEYWORDS}, + {"divide", (PyCFunction)context_divide, + METH_VARARGS | METH_KEYWORDS}, + {"divmod", (PyCFunction)context_divmod, + METH_VARARGS | METH_KEYWORDS}, + {"max", (PyCFunction)context_max, + METH_VARARGS | METH_KEYWORDS}, + {"min", (PyCFunction)context_min, + METH_VARARGS | METH_KEYWORDS}, + {"minus", (PyCFunction)context_minus, + METH_VARARGS | METH_KEYWORDS}, + {"multiply", (PyCFunction)context_multiply, + METH_VARARGS | METH_KEYWORDS}, + {"normalize", (PyCFunction)context_normalize, + METH_VARARGS | METH_KEYWORDS}, + {"plus", (PyCFunction)context_plus, + METH_VARARGS | METH_KEYWORDS}, + {"power", (PyCFunction)context_power, + METH_VARARGS | METH_KEYWORDS}, + {"quantize", (PyCFunction)context_quantize, + METH_VARARGS | METH_KEYWORDS}, + {"remainder", (PyCFunction)context_remainder, + METH_VARARGS | METH_KEYWORDS}, + {"remainder_near", (PyCFunction)context_remainder_near, + METH_VARARGS | METH_KEYWORDS}, + {"same_quantum", (PyCFunction)context_same_quantum, + METH_VARARGS | METH_KEYWORDS}, + {"sqrt", (PyCFunction)context_sqrt, + METH_VARARGS | METH_KEYWORDS}, + {"subtract", (PyCFunction)context_subtract, + METH_VARARGS | METH_KEYWORDS}, + {"to_eng_string", (PyCFunction)context_to_eng_string, + METH_VARARGS | METH_KEYWORDS}, + {"to_integral", (PyCFunction)context_to_integral, + METH_VARARGS | METH_KEYWORDS}, + {"to_sci_string", (PyCFunction)context_to_sci_string, + METH_VARARGS | METH_KEYWORDS}, + {"__copy__", (PyCFunction)context_copy, + METH_NOARGS}, + {NULL, NULL} +}; + +static char context_doc[] = +PyDoc_STR("Contains the context for a Decimal instance."); + + +static void +context_dealloc(PyObject *c) +{ + c->ob_type->tp_free(c); +} + +CSTUB(richcompare) + +static PyObject * +context_repr(contextobject *self) +{ + char roundstr[20] = "ROUND_"; + char flags[1000] = "{}"; + char traps[1000] = "[]"; + + switch (self->rounding) { + case ROUND_UP: + strcat(roundstr, "UP"); + break; + case ROUND_DOWN: + strcat(roundstr, "DOWN"); + break; + case ROUND_HALF_DOWN: + strcat(roundstr, "HALF_DOWN"); + break; + case ROUND_HALF_EVEN: + strcat(roundstr, "HALF_EVEN"); + break; + case ROUND_HALF_UP: + strcat(roundstr, "HALF_UP"); + break; + case ROUND_FLOOR: + strcat(roundstr, "FLOOR"); + break; + case ROUND_CEILING: + strcat(roundstr, "CEILING"); + break; + default: + strcpy(roundstr, "None"); + } + + /* XXX: flags/traps */ + + return PyString_FromFormat("Context(prec=%ld, rounding=%s, Emin=%ld, " + "Emax=%ld, capitals=%d, flags=%s, traps=%s)", + self->prec, roundstr, self->Emin, self->Emax, + self->capitals, flags, traps); +} + +static long +context_hash(PyObject *c) +{ + PyErr_SetString(PyExc_TypeError, "Cannot hash a Context."); + return -1; +} + +static PyObject * +context_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"prec", "rounding", "_rounding_decision", + "traps", "flags", "Emin", "Emax", + "capitals", "_clamp", "_ignored_flags", 0}; + long prec = LONG_MIN; + long Emin = LONG_MAX, Emax = LONG_MIN; + int rounding = -1, rounding_dec = -1, capitals = -1, clamp = 0; + PyObject *pytraps = NULL, *pyflags = NULL, *pyignored = NULL; + PyObject *tmp; + int traps = 0, flags = 0, ignored = 0; + int i, j; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|nbbOOnnbbO:Context", kwlist, + &prec, &rounding, &rounding_dec, &pytraps, + &pyflags, &Emin, &Emax, &capitals, &clamp, + &pyignored)) + return NULL; + + if (pytraps == NULL) { + traps = PyDecimal_DefaultContext->traps; + } else if (!PyDict_Check(pytraps)) { + for (i = 0; i < NUMSIGNALS; i++) { + j = PySequence_Contains(pytraps, errors[i]); + if (j == -1) + return NULL; + else if (j == 1) + SETFLAG(traps, i); + } + } else { + for (i = 0; i < NUMSIGNALS; i++) { + j = PyDict_Contains(pytraps, errors[i]); + if (j == -1) + return NULL; + else if (j == 0) + continue; + tmp = PyDict_GetItem(pytraps, errors[i]); + if (!tmp) + return NULL; + j = PyObject_IsTrue(tmp); + if (j == -1) + return NULL; + else if (j == 1) + SETFLAG(traps, i); + } + } + + if (pyflags == NULL) { + /* don't copy flags from default context */ + } else if (PyDict_Check(pyflags)) { + for (i = 0; i < NUMSIGNALS; i++) { + j = PyDict_Contains(pyflags, errors[i]); + if (j == -1) + return NULL; + else if (j == 0) + continue; + tmp = PyDict_GetItem(pyflags, errors[i]); + if (!tmp) + return NULL; + j = PyObject_IsTrue(tmp); + if (j == -1) + return NULL; + else if (j == 1) + SETFLAG(flags, i); + } + } else { + PyErr_SetString(PyExc_TypeError, "initial flags must be a dict"); + return NULL; + } + + if (pyignored == NULL) { + /* don't copy ignored flags from default context */ + } else if (!PyDict_Check(pyignored)) { + for (i = 0; i < NUMSIGNALS; i++) { + j = PySequence_Contains(pyignored, errors[i]); + if (j == -1) + return NULL; + else if (j == 1) + SETFLAG(ignored, i); + } + } else { + for (i = 0; i < NUMSIGNALS; i++) { + j = PyDict_Contains(pyignored, errors[i]); + if (j == -1) + return NULL; + else if (j == 0) + continue; + tmp = PyDict_GetItem(pyignored, errors[i]); + if (!tmp) + return NULL; + j = PyObject_IsTrue(tmp); + if (j == -1) + return NULL; + else if (j == 1) + SETFLAG(ignored, i); + } + } + + if (prec == LONG_MIN) + prec = PyDecimal_DefaultContext->prec; + + if (Emin == LONG_MAX) + Emin = PyDecimal_DefaultContext->Emin; + + if (Emax == LONG_MIN) + Emax = PyDecimal_DefaultContext->Emax; + + if (capitals == -1) + capitals = PyDecimal_DefaultContext->capitals; + else + capitals = capitals & 1; + + if (rounding_dec == -1) + rounding_dec = PyDecimal_DefaultContext->rounding_dec; + + if (rounding_dec != NEVER_ROUND && rounding_dec != ALWAYS_ROUND) { + PyErr_SetString(PyExc_ValueError, "_rounding_decision must be one of " + "NEVER_ROUND or ALWAYS_ROUND"); + return NULL; + } + + if (rounding == -1) + rounding = PyDecimal_DefaultContext->rounding; + + clamp = clamp & 1; + + return (PyObject *)_new_contextobj(prec, rounding, rounding_dec, traps, + flags, Emin, Emax, capitals, clamp, + ignored); +} + +static PyObject * +context_get_flags(contextobject *self) +{ + /* XXX */ + Py_RETURN_NONE; +} + +static int +context_set_flags(contextobject *self, PyObject *value) +{ + return 0; +} + +static PyObject * +context_get_traps(contextobject *self) +{ + Py_RETURN_NONE; +} + +static int +context_set_traps(contextobject *self, PyObject *value) +{ + return 0; +} + +static PyGetSetDef context_getset[] = { + {"flags", (getter)context_get_flags, (setter)context_set_flags}, + {"traps", (getter)context_get_traps, (setter)context_set_traps}, + {NULL} +}; + +#define OFF(x) offsetof(contextobject, x) + +static PyMemberDef context_members[] = { + {"prec", T_LONG, OFF(prec), 0}, + {"Emin", T_LONG, OFF(Emin), 0}, + {"Emax", T_LONG, OFF(Emax), 0}, + {"capitals", T_INT, OFF(capitals), 0}, + {"rounding", T_INT, OFF(rounding), 0}, + {NULL} +}; + +static PyTypeObject PyDecimal_DecimalContextType = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + MODULE_NAME ".Context", /* tp_name */ + sizeof(contextobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)context_dealloc,/* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)context_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + context_hash, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + context_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)context_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + context_methods, /* tp_methods */ + context_members, /* tp_members */ + context_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + context_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + + +/* module methods and initialization *****************************************/ + +static PyObject * +module_getcontext(PyObject *self) +{ + return (PyObject *)getcontext(); +} + +static PyObject * +module_setcontext(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"context", 0}; + contextobject *ctx; + int res; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:setcontext", kwlist, &ctx)) + return NULL; + + if (!PyDecimalContext_Check(ctx)) { + PyErr_SetString(PyExc_TypeError, "setcontext() requires a Context object"); + return NULL; + } + + if (ctx == PyDecimal_BasicContext || + ctx == PyDecimal_ExtendedContext || + ctx == PyDecimal_DefaultContext) { + + ctx = (contextobject *)context_copy(ctx); + res = setcontext(ctx); + Py_DECREF(ctx); + if (res == -1) return NULL; + else Py_RETURN_NONE; + } + + res = setcontext(ctx); + if (res == -1) return NULL; + else Py_RETURN_NONE; +} + +static PyMethodDef module_methods[] = { + {"getcontext", (PyCFunction)module_getcontext, METH_NOARGS}, + {"setcontext", (PyCFunction)module_setcontext, METH_VARARGS | METH_KEYWORDS}, + {NULL, NULL} +}; + + +static int +_add_handle_method(PyObject *tp, PyMethodDef *ml) +{ + PyObject *meth, *cfunc; + static PyObject *module; + + if (!module) { + module = PyString_FromString(MODULE_NAME); + if (!module) + return -1; + } + + cfunc = PyCFunction_NewEx(ml, NULL, module); + if (!cfunc) + return -1; + + meth = PyMethod_New(cfunc, NULL, tp); + if (!meth) { + Py_DECREF(cfunc); + return -1; + } + + PyObject_SetAttrString(tp, "handle", meth); + Py_DECREF(cfunc); + Py_DECREF(meth); + return 0; +} + +#define ADD_CONST(m, name) \ + if (PyModule_AddIntConstant(m, #name, name) < 0) { return; } + +#define INIT_EXC(m, name, base) \ + name = PyErr_NewException(MODULE_NAME "." #name, base, NULL); \ + if (!name) return; \ + Py_INCREF(name); \ + if (PyModule_AddObject(m, #name, name) < 0) { return; } + +#define INIT_EXC_WITH_FUNC(m, name, base) \ + INIT_EXC(m, name, base) \ + if (_add_handle_method(name, &ml_##name) < 0) { return; } + +#define INIT_EXC_WITH_FUNC_AND_2TUPLE(m, name, base1, base2) \ + tup = PyTuple_Pack(2, base1, base2); \ + if (!tup) return; \ + INIT_EXC_WITH_FUNC(m, name, tup) \ + Py_DECREF(tup) + +#define INIT_EXC_WITH_3TUPLE(m, name, base1, base2, base3) \ + tup = PyTuple_Pack(3, base1, base2, base3); \ + if (!tup) return; \ + INIT_EXC(m, name, tup) + + +PyMODINIT_FUNC +INITFUNC_NAME(void) +{ + PyObject *m; /* a module object */ + PyObject *tup; + contextobject *ctx; + int traps = 0; + + m = Py_InitModule3(MODULE_NAME, module_methods, + "Fast implementation of decimal arithmetic."); + if (m == NULL) + return; + + if (PyType_Ready(&PyDecimal_DecimalType) < 0) + return; + if (PyType_Ready(&PyDecimal_DecimalContextType) < 0) + return; + + Py_INCREF(&PyDecimal_DecimalType); + PyModule_AddObject(m, "Decimal", (PyObject *) &PyDecimal_DecimalType); + + Py_INCREF(&PyDecimal_DecimalContextType); + PyModule_AddObject(m, "Context", (PyObject *) &PyDecimal_DecimalContextType); + + SETFLAG(traps, S_DIV_BY_ZERO); + SETFLAG(traps, S_OVERFLOW); + SETFLAG(traps, S_INV_OPERATION); + PyDecimal_DefaultContext = _new_contextobj(28, ROUND_HALF_EVEN, ALWAYS_ROUND, + traps, 0, -999999999L, 999999999L, 1, 0, 0); + if (!PyDecimal_DefaultContext) + return; + if (PyModule_AddObject(m, "DefaultContext", + (PyObject *)PyDecimal_DefaultContext) < 0) + return; + + /* add flags for BasicContext */ + SETFLAG(traps, S_CLAMPED); + SETFLAG(traps, S_UNDERFLOW); + + PyDecimal_BasicContext = _new_contextobj(9, ROUND_HALF_UP, ALWAYS_ROUND, + traps, 0, -999999999L, 999999999L, 1, 0, 0); + if (!PyDecimal_BasicContext) + return; + if (PyModule_AddObject(m, "BasicContext", + (PyObject *)PyDecimal_BasicContext) < 0) + return; + + PyDecimal_ExtendedContext = _new_contextobj(9, ROUND_HALF_EVEN, ALWAYS_ROUND, + 0, 0, -999999999L, 999999999L, 1, 0, 0); + if (!PyDecimal_ExtendedContext) + return; + if (PyModule_AddObject(m, "ExtendedContext", + (PyObject *)PyDecimal_ExtendedContext) < 0) + return; + + ctx = getcontext(); + if (!ctx) return; + + PyDecimal_NaN = PyDecimal_FromString("nan", 3, ctx); + if (!PyDecimal_NaN) + return; + PyDecimal_Inf = PyDecimal_FromString("inf", 3, ctx); + if (!PyDecimal_Inf) + return; + PyDecimal_NegInf = PyDecimal_FromString("-inf", 4, ctx); + if (!PyDecimal_NegInf) + return; + + ADD_CONST(m, ROUND_DOWN); + ADD_CONST(m, ROUND_UP); + ADD_CONST(m, ROUND_HALF_DOWN); + ADD_CONST(m, ROUND_HALF_EVEN); + ADD_CONST(m, ROUND_HALF_UP); + ADD_CONST(m, ROUND_FLOOR); + ADD_CONST(m, ROUND_CEILING); + + INIT_EXC_WITH_FUNC(m, DecimalException, PyExc_ArithmeticError); + INIT_EXC(m, Clamped, DecimalException); + INIT_EXC_WITH_FUNC(m, InvalidOperation, DecimalException); + INIT_EXC_WITH_FUNC(m, ConversionSyntax, InvalidOperation); + INIT_EXC_WITH_FUNC(m, DivisionImpossible, InvalidOperation); + INIT_EXC_WITH_FUNC_AND_2TUPLE(m, DivisionUndefined, + InvalidOperation, PyExc_ZeroDivisionError); + INIT_EXC_WITH_FUNC(m, InvalidContext, InvalidOperation); + INIT_EXC_WITH_FUNC_AND_2TUPLE(m, DivisionByZero, + DecimalException, PyExc_ZeroDivisionError); + INIT_EXC(m, Inexact, DecimalException); + INIT_EXC(m, Rounded, DecimalException); + INIT_EXC(m, Subnormal, DecimalException); + INIT_EXC_WITH_FUNC_AND_2TUPLE(m, Overflow, Rounded, Inexact); + INIT_EXC_WITH_3TUPLE(m, Underflow, + Rounded, Inexact, Subnormal); + + errors[S_INV_OPERATION] = InvalidOperation; + errors[S_DIV_BY_ZERO] = DivisionByZero; + errors[S_CLAMPED] = Clamped; + errors[S_INEXACT] = Inexact; + errors[S_ROUNDED] = Rounded; + errors[S_SUBNORMAL] = Subnormal; + errors[S_OVERFLOW] = Overflow; + errors[S_UNDERFLOW] = Underflow; + errors[C_INV_CONTEXT] = InvalidContext; + errors[C_CONV_SYNTAX] = ConversionSyntax; + errors[C_DIV_IMPOSSIBLE]= DivisionImpossible; + errors[C_DIV_UNDEFINED] = DivisionUndefined; +} + Added: sandbox/trunk/decimal-c/decimal.h ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimal.h Mon May 22 17:47:15 2006 @@ -0,0 +1,66 @@ +/* decimal.h */ + +#ifndef PY_DECIMAL_H +#define PY_DECIMAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* decimalobject struct ******************************************************/ + +typedef struct { + PyObject_VAR_HEAD + unsigned int sign; /* see sign contstants above */ + long exp; + signed char digits[1]; /* digits are stored as the actual numbers 0-9 */ +} PyDecimalObject; + +static PyTypeObject PyDecimal_DecimalType; + +/* contextobject struct ******************************************************/ + +typedef struct { + PyObject_HEAD + long prec; + + /* option flags */ + int rounding; /* see rounding constants above */ + int rounding_dec; /* dito */ + int capitals; /* print "e" or "E" before exponents */ + int clamp; /* change exponents if they are too high */ + + /* min/max exponents */ + long Emin; + long Emax; + + /* signal handling -- these are bit fields */ + int traps; /* if a signal is trapped */ + int ignored; /* if a signal is ignored completely */ + int flags; /* if a signal has occurred, but not been trapped */ +} PyDecimalContextObject; + +static PyTypeObject PyDecimal_DecimalContextType; + +/* type checking macros ******************************************************/ + +#define PyDecimal_Check(op) PyObject_TypeCheck((op), &PyDecimal_DecimalType) +#define PyDecimalContext_Check(op) \ + PyObject_TypeCheck((op), &PyDecimal_DecimalContextType) + +/* static constants **********************************************************/ + +static PyObject *PyDecimal_NaN; +static PyObject *PyDecimal_Inf; +static PyObject *PyDecimal_NegInf; + +static PyDecimalContextObject *PyDecimal_DefaultContext; +static PyDecimalContextObject *PyDecimal_BasicContext; +static PyDecimalContextObject *PyDecimal_ExtendedContext; + + +#ifdef __cplusplus +} +#endif + +#endif /* defined(PY_DECIMAL_H) */ From python-checkins at python.org Mon May 22 17:59:13 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 22 May 2006 17:59:13 +0200 (CEST) Subject: [Python-checkins] r46075 - python/trunk/Lib/gzip.py Message-ID: <20060522155913.1D2FC1E4007@bag.python.org> Author: bob.ippolito Date: Mon May 22 17:59:12 2006 New Revision: 46075 Modified: python/trunk/Lib/gzip.py Log: Apply revised patch for GzipFile.readline performance #1281707 Modified: python/trunk/Lib/gzip.py ============================================================================== --- python/trunk/Lib/gzip.py (original) +++ python/trunk/Lib/gzip.py Mon May 22 17:59:12 2006 @@ -107,6 +107,8 @@ self.extrabuf = "" self.extrasize = 0 self.filename = filename + # Starts small, scales exponentially + self.min_readsize = 100 elif mode[0:1] == 'w' or mode[0:1] == 'a': self.mode = WRITE @@ -381,32 +383,35 @@ self.read(count % 1024) def readline(self, size=-1): - if size < 0: size = sys.maxint + if size < 0: + size = sys.maxint + readsize = self.min_readsize + else: + readsize = size bufs = [] - readsize = min(100, size) # Read from the file in small chunks - while True: - if size == 0: - return "".join(bufs) # Return resulting line - + while size != 0: c = self.read(readsize) i = c.find('\n') - if size is not None: - # We set i=size to break out of the loop under two - # conditions: 1) there's no newline, and the chunk is - # larger than size, or 2) there is a newline, but the - # resulting line would be longer than 'size'. - if i==-1 and len(c) > size: i=size-1 - elif size <= i: i = size -1 + + # We set i=size to break out of the loop under two + # conditions: 1) there's no newline, and the chunk is + # larger than size, or 2) there is a newline, but the + # resulting line would be longer than 'size'. + if (size <= i) or (i == -1 and len(c) > size): + i = size - 1 if i >= 0 or c == '': - bufs.append(c[:i+1]) # Add portion of last chunk - self._unread(c[i+1:]) # Push back rest of chunk - return ''.join(bufs) # Return resulting line + bufs.append(c[:i + 1]) # Add portion of last chunk + self._unread(c[i + 1:]) # Push back rest of chunk + break # Append chunk to list, decrease 'size', bufs.append(c) size = size - len(c) readsize = min(size, readsize * 2) + if readsize > self.min_readsize: + self.min_readsize = min(readsize, self.min_readsize * 2, 512) + return ''.join(bufs) # Return resulting line def readlines(self, sizehint=0): # Negative numbers result in reading all the lines From python-checkins at python.org Mon May 22 18:29:45 2006 From: python-checkins at python.org (fredrik.lundh) Date: Mon, 22 May 2006 18:29:45 +0200 (CEST) Subject: [Python-checkins] r46076 - in python/trunk: Include/unicodeobject.h Objects/unicodeobject.c Message-ID: <20060522162945.8C7471E4007@bag.python.org> Author: fredrik.lundh Date: Mon May 22 18:29:30 2006 New Revision: 46076 Modified: python/trunk/Include/unicodeobject.h python/trunk/Objects/unicodeobject.c Log: needforspeed: speed up unicode repeat, unicode string copy Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Mon May 22 18:29:30 2006 @@ -352,12 +352,15 @@ Py_UNICODE_ISDIGIT(ch) || \ Py_UNICODE_ISNUMERIC(ch)) -#define Py_UNICODE_COPY(target, source, length)\ - (memcpy((target), (source), (length)*sizeof(Py_UNICODE))) +#define Py_UNICODE_COPY(target, source, length) do\ + {int i; Py_UNICODE *t = (target); const Py_UNICODE *s = (source);\ + for (i = 0; i < (length); i++) t[i] = s[i];\ + } while (0) #define Py_UNICODE_FILL(target, value, length) do\ - {int i; for (i = 0; i < (length); i++) (target)[i] = (value);}\ - while (0) + {int i; Py_UNICODE *t = (target); Py_UNICODE v = (value);\ + for (i = 0; i < (length); i++) t[i] = v;\ + } while (0) #define Py_UNICODE_MATCH(string, offset, substring)\ ((*((string)->str + (offset)) == *((substring)->str)) &&\ Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon May 22 18:29:30 2006 @@ -5898,10 +5898,13 @@ p = u->str; - while (len-- > 0) { - Py_UNICODE_COPY(p, str->str, str->length); - p += str->length; - } + if (str->length == 1 && len > 0) { + Py_UNICODE_FILL(p, str->str[0], len); + } else + while (len-- > 0) { + Py_UNICODE_COPY(p, str->str, str->length); + p += str->length; + } return (PyObject*) u; } From buildbot at python.org Mon May 22 18:37:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 16:37:21 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060522163721.EBDCA1E4007@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/806 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 22 18:40:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 16:40:10 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060522164010.48CC71E4007@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/636 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Mon May 22 18:46:50 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 22 May 2006 18:46:50 +0200 Subject: [Python-checkins] r46076 - in python/trunk: Include/unicodeobject.h Objects/unicodeobject.c In-Reply-To: <20060522162945.8C7471E4007@bag.python.org> References: <20060522162945.8C7471E4007@bag.python.org> Message-ID: <4471EAFA.20900@egenix.com> fredrik.lundh wrote: > Author: fredrik.lundh > Date: Mon May 22 18:29:30 2006 > New Revision: 46076 > > Modified: > python/trunk/Include/unicodeobject.h > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: speed up unicode repeat, unicode string copy > > > > Modified: python/trunk/Include/unicodeobject.h > ============================================================================== > --- python/trunk/Include/unicodeobject.h (original) > +++ python/trunk/Include/unicodeobject.h Mon May 22 18:29:30 2006 > @@ -352,12 +352,15 @@ > Py_UNICODE_ISDIGIT(ch) || \ > Py_UNICODE_ISNUMERIC(ch)) > > -#define Py_UNICODE_COPY(target, source, length)\ > - (memcpy((target), (source), (length)*sizeof(Py_UNICODE))) > +#define Py_UNICODE_COPY(target, source, length) do\ > + {int i; Py_UNICODE *t = (target); const Py_UNICODE *s = (source);\ > + for (i = 0; i < (length); i++) t[i] = s[i];\ > + } while (0) Hi Fredrik, why is the for()-loop faster than the memcpy and if so, on which platforms ? > #define Py_UNICODE_FILL(target, value, length) do\ > - {int i; for (i = 0; i < (length); i++) (target)[i] = (value);}\ > - while (0) > + {int i; Py_UNICODE *t = (target); Py_UNICODE v = (value);\ > + for (i = 0; i < (length); i++) t[i] = v;\ > + } while (0) Dito here: why not use memset() ?! -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 22 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From buildbot at python.org Mon May 22 18:52:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 16:52:44 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060522165244.DDDD61E4007@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/459 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 19:02:10 2006 From: python-checkins at python.org (richard.jones) Date: Mon, 22 May 2006 19:02:10 +0200 (CEST) Subject: [Python-checkins] r46077 - in python/branches/rjones-funccall: Include/code.h Objects/codeobject.c Objects/frameobject.c Message-ID: <20060522170210.A40661E4007@bag.python.org> Author: richard.jones Date: Mon May 22 19:02:07 2006 New Revision: 46077 Modified: python/branches/rjones-funccall/Include/code.h python/branches/rjones-funccall/Objects/codeobject.c python/branches/rjones-funccall/Objects/frameobject.c Log: Applied patch zombie-frames-2.diff from sf patch 876206 with updates for Python 2.5 and also modified to retain the free_list to avoid the 67% slow-down in pybench recursion test. 5% speed up in function call pybench. More testing needed. Modified: python/branches/rjones-funccall/Include/code.h ============================================================================== --- python/branches/rjones-funccall/Include/code.h (original) +++ python/branches/rjones-funccall/Include/code.h Mon May 22 19:02:07 2006 @@ -24,6 +24,7 @@ PyObject *co_name; /* string (name, for reference) */ int co_firstlineno; /* first source line number */ PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ } PyCodeObject; /* Masks for co_flags above */ Modified: python/branches/rjones-funccall/Objects/codeobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/codeobject.c (original) +++ python/branches/rjones-funccall/Objects/codeobject.c Mon May 22 19:02:07 2006 @@ -102,6 +102,7 @@ co->co_firstlineno = firstlineno; Py_INCREF(lnotab); co->co_lnotab = lnotab; + co->co_zombieframe = NULL; } return co; } @@ -265,6 +266,8 @@ Py_XDECREF(co->co_filename); Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); + if (co->co_zombieframe != NULL) + PyObject_GC_Del(co->co_zombieframe); PyObject_DEL(co); } Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Mon May 22 19:02:07 2006 @@ -380,41 +380,45 @@ static void frame_dealloc(PyFrameObject *f) { - int i, slots; - PyObject **fastlocals; - PyObject **p; + PyObject **p, **valuestack; + PyCodeObject *co; PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - Py_XDECREF(*fastlocals); - } + valuestack = f->f_valuestack; + for (p = f->f_localsplus; p < valuestack; p++) + Py_CLEAR(*p); /* Free stack */ if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) + for (p = valuestack; p < f->f_stacktop; p++) Py_XDECREF(*p); } Py_XDECREF(f->f_back); - Py_DECREF(f->f_code); Py_DECREF(f->f_builtins); Py_DECREF(f->f_globals); - Py_XDECREF(f->f_locals); - Py_XDECREF(f->f_trace); - Py_XDECREF(f->f_exc_type); - Py_XDECREF(f->f_exc_value); - Py_XDECREF(f->f_exc_traceback); - if (numfree < MAXFREELIST) { + Py_CLEAR(f->f_locals); + Py_CLEAR(f->f_trace); + Py_CLEAR(f->f_exc_type); + Py_CLEAR(f->f_exc_value); + Py_CLEAR(f->f_exc_traceback); + + co = f->f_code; + if (co->co_zombieframe == NULL) { + co->co_zombieframe = f; + } + else if (numfree < MAXFREELIST) { ++numfree; f->f_back = free_list; free_list = f; } - else + else { PyObject_GC_Del(f); + } + + Py_DECREF(co); Py_TRASHCAN_SAFE_END(f) } @@ -532,7 +536,8 @@ PyFrameObject *back = tstate->frame; PyFrameObject *f; PyObject *builtins; - Py_ssize_t extras, ncells, nfrees, i; + Py_ssize_t i; + int frame_needs_init = 1; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || @@ -541,9 +546,6 @@ return NULL; } #endif - ncells = PyTuple_GET_SIZE(code->co_cellvars); - nfrees = PyTuple_GET_SIZE(code->co_freevars); - extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; if (back == NULL || back->f_globals != globals) { builtins = PyDict_GetItem(globals, builtin_object); if (builtins) { @@ -574,71 +576,85 @@ assert(builtins != NULL && PyDict_Check(builtins)); Py_INCREF(builtins); } - if (free_list == NULL) { - f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - else { - assert(numfree > 0); - --numfree; - f = free_list; - free_list = free_list->f_back; - if (f->ob_size < extras) { - f = PyObject_GC_Resize(PyFrameObject, f, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - _Py_NewReference((PyObject *)f); + if (code->co_zombieframe != NULL) { + frame_needs_init = 0; + f = code->co_zombieframe; + code->co_zombieframe = NULL; + _Py_NewReference((PyObject *)f); + assert(f->f_code == code); + } + else { + Py_ssize_t extras, ncells, nfrees; + ncells = PyTuple_GET_SIZE(code->co_cellvars); + nfrees = PyTuple_GET_SIZE(code->co_freevars); + extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; + if (free_list == NULL) { + f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + else { + assert(numfree > 0); + --numfree; + f = free_list; + free_list = free_list->f_back; + if (f->ob_size < extras) { + f = PyObject_GC_Resize(PyFrameObject, f, extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + _Py_NewReference((PyObject *)f); + } + + f->f_code = code; + f->f_nlocals = code->co_nlocals; + f->f_stacksize = code->co_stacksize; + f->f_ncells = ncells; + f->f_nfreevars = nfrees; + extras = f->f_nlocals + ncells + nfrees; + f->f_valuestack = f->f_localsplus + extras; + for (i=0; if_localsplus[i] = NULL; + f->f_locals = NULL; + f->f_trace = NULL; + f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; } f->f_builtins = builtins; Py_XINCREF(back); f->f_back = back; Py_INCREF(code); - f->f_code = code; Py_INCREF(globals); f->f_globals = globals; /* Most functions have CO_NEWLOCALS and CO_OPTIMIZED set. */ if ((code->co_flags & (CO_NEWLOCALS | CO_OPTIMIZED)) == (CO_NEWLOCALS | CO_OPTIMIZED)) - locals = NULL; /* PyFrame_FastToLocals() will set. */ + ; /* f_locals = NULL; will be set by PyFrame_FastToLocals() */ else if (code->co_flags & CO_NEWLOCALS) { locals = PyDict_New(); if (locals == NULL) { Py_DECREF(f); return NULL; } + f->f_locals = locals; } else { if (locals == NULL) locals = globals; Py_INCREF(locals); + f->f_locals = locals; } - f->f_locals = locals; - f->f_trace = NULL; - f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; f->f_tstate = tstate; f->f_lasti = -1; f->f_lineno = code->co_firstlineno; f->f_restricted = (builtins != tstate->interp->builtins); f->f_iblock = 0; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - - extras = f->f_nlocals + ncells + nfrees; - /* Tim said it's ok to replace memset */ - for (i=0; if_localsplus[i] = NULL; - f->f_valuestack = f->f_localsplus + extras; - f->f_stacktop = f->f_valuestack; + f->f_stacktop = f->f_valuestack; _PyObject_GC_TRACK(f); return f; } From buildbot at python.org Mon May 22 19:05:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:05:43 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060522170544.1601A1E403A@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/500 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 19:06:19 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 22 May 2006 19:06:19 +0200 (CEST) Subject: [Python-checkins] r46078 - peps/trunk/pep-3099.txt Message-ID: <20060522170619.768261E4025@bag.python.org> Author: georg.brandl Date: Mon May 22 19:06:18 2006 New Revision: 46078 Modified: peps/trunk/pep-3099.txt Log: No frozenlist. Ever. Modified: peps/trunk/pep-3099.txt ============================================================================== --- peps/trunk/pep-3099.txt (original) +++ peps/trunk/pep-3099.txt Mon May 22 19:06:18 2006 @@ -85,6 +85,11 @@ Thread: "Iterating over a dict", http://mail.python.org/pipermail/python-3000/2006-April/000283.html +* There will be no ``frozenlist`` type. + + Thread: "Immutable lists", + http://mail.python.org/pipermail/python-3000/2006-May/002219.html + Coding style ============ From buildbot at python.org Mon May 22 19:12:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:12:58 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060522171258.80F811E4007@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/722 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 19:13:01 2006 From: python-checkins at python.org (fredrik.lundh) Date: Mon, 22 May 2006 19:13:01 +0200 (CEST) Subject: [Python-checkins] r46079 - in python/trunk: Include/unicodeobject.h Objects/unicodeobject.c Message-ID: <20060522171301.1B0D91E4007@bag.python.org> Author: fredrik.lundh Date: Mon May 22 19:12:58 2006 New Revision: 46079 Modified: python/trunk/Include/unicodeobject.h python/trunk/Objects/unicodeobject.c Log: needforspeed: use memcpy for "long" strings; use a better algorithm for long repeats. Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Mon May 22 19:12:58 2006 @@ -352,14 +352,19 @@ Py_UNICODE_ISDIGIT(ch) || \ Py_UNICODE_ISNUMERIC(ch)) +/* memcpy has a considerable setup overhead on many platforms; use a + loop for short strings (the "16" below is pretty arbitary) */ #define Py_UNICODE_COPY(target, source, length) do\ - {int i; Py_UNICODE *t = (target); const Py_UNICODE *s = (source);\ - for (i = 0; i < (length); i++) t[i] = s[i];\ + {Py_ssize_t i_; Py_UNICODE *t_ = (target); const Py_UNICODE *s_ = (source);\ + if (length > 16)\ + memcpy(t_, s_, (length)*sizeof(Py_UNICODE));\ + else\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = s_[i_];\ } while (0) #define Py_UNICODE_FILL(target, value, length) do\ - {int i; Py_UNICODE *t = (target); Py_UNICODE v = (value);\ - for (i = 0; i < (length); i++) t[i] = v;\ + {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ } while (0) #define Py_UNICODE_MATCH(string, offset, substring)\ Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon May 22 19:12:58 2006 @@ -5900,11 +5900,18 @@ if (str->length == 1 && len > 0) { Py_UNICODE_FILL(p, str->str[0], len); - } else - while (len-- > 0) { + } else { + int done = 0; /* number of characters copied this far */ + if (done < nchars) { Py_UNICODE_COPY(p, str->str, str->length); - p += str->length; - } + done = str->length; + } + while (done < nchars) { + int n = (done <= nchars-done) ? done : nchars-done; + Py_UNICODE_COPY(p+done, p, n); + done += n; + } + } return (PyObject*) u; } From buildbot at python.org Mon May 22 19:13:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:13:44 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060522171344.1F8501E4007@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/718 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 19:23:32 2006 From: python-checkins at python.org (richard.jones) Date: Mon, 22 May 2006 19:23:32 +0200 (CEST) Subject: [Python-checkins] r46080 - python/branches/rjones-funccall/Objects/frameobject.c Message-ID: <20060522172332.A9E1F1E4007@bag.python.org> Author: richard.jones Date: Mon May 22 19:23:31 2006 New Revision: 46080 Modified: python/branches/rjones-funccall/Objects/frameobject.c Log: Extra paranoia chanelled from Tim. Fixed C style. Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Mon May 22 19:23:31 2006 @@ -406,17 +406,15 @@ Py_CLEAR(f->f_exc_traceback); co = f->f_code; - if (co->co_zombieframe == NULL) { + if (co != NULL && co->co_zombieframe == NULL) co->co_zombieframe = f; - } else if (numfree < MAXFREELIST) { ++numfree; f->f_back = free_list; free_list = f; - } - else { - PyObject_GC_Del(f); } + else + PyObject_GC_Del(f); Py_DECREF(co); Py_TRASHCAN_SAFE_END(f) From buildbot at python.org Mon May 22 19:24:38 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:24:38 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060522172438.8B6441E4007@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/742 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon May 22 19:29:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:29:45 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060522172945.A0E851E4007@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/160 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 19:36:33 2006 From: python-checkins at python.org (richard.jones) Date: Mon, 22 May 2006 19:36:33 +0200 (CEST) Subject: [Python-checkins] r46081 - python/branches/rjones-funccall/Objects/frameobject.c Message-ID: <20060522173633.B82FA1E4007@bag.python.org> Author: richard.jones Date: Mon May 22 19:36:32 2006 New Revision: 46081 Modified: python/branches/rjones-funccall/Objects/frameobject.c Log: update comment Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Mon May 22 19:36:32 2006 @@ -350,10 +350,31 @@ }; /* Stack frames are allocated and deallocated at a considerable rate. - In an attempt to improve the speed of function calls, we maintain a - separate free list of stack frames (just like integers are - allocated in a special way -- see intobject.c). When a stack frame - is on the free list, only the following members have a meaning: + In an attempt to improve the speed of function calls, we: + + 1. Hold a single "zombie" frame on each code object. This retains + the allocated and initialised frame object from an invocation of + the code object. The zombie is reanimated the next time we need a + frame object for that code object. Doing this saves the malloc/ + realloc required when using a free_list frame that isn't the + correct size. It also saves some field initialisation. + + In zombie mode, no field of PyFrameObject holds a reference, but + the following fields are still valid: + + * ob_type, ob_size, f_code, f_valuestack, + f_nlocals, f_ncells, f_nfreevars, f_stacksize; + + * f_locals, f_trace, + f_exc_type, f_exc_value, f_exc_traceback are NULL; + + * f_localsplus does not require re-allocation and + the local variables in f_localsplus are NULL. + + 2. We also maintain a separate free list of stack frames (just like + integers are allocated in a special way -- see intobject.c). When + a stack frame is on the free list, only the following members have + a meaning: ob_type == &Frametype f_back next item on free list, or NULL f_nlocals number of locals From buildbot at python.org Mon May 22 19:44:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 17:44:36 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060522174436.AA7ED1E4007@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/434 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 22 20:00:40 2006 From: python-checkins at python.org (steve.holden) Date: Mon, 22 May 2006 20:00:40 +0200 (CEST) Subject: [Python-checkins] r46082 - python/branches/steve-notracing Message-ID: <20060522180040.EA5D71E4007@bag.python.org> Author: steve.holden Date: Mon May 22 20:00:40 2006 New Revision: 46082 Added: python/branches/steve-notracing/ - copied from r46081, python/trunk/ Log: Create a branch for experimentation with trace removal. From python-checkins at python.org Mon May 22 20:38:17 2006 From: python-checkins at python.org (andrew.dalke) Date: Mon, 22 May 2006 20:38:17 +0200 (CEST) Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py Message-ID: <20060522183817.DDD4A1E4007@bag.python.org> Author: andrew.dalke Date: Mon May 22 20:38:16 2006 New Revision: 46083 Added: sandbox/trunk/stringbench/ sandbox/trunk/stringbench/stringbench.py (contents, props changed) Log: "Need for speed" microbenchmarks for string processing Added: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- (empty file) +++ sandbox/trunk/stringbench/stringbench.py Mon May 22 20:38:16 2006 @@ -0,0 +1,662 @@ + +import timeit +import itertools +import operator +import re +import sys +import datetime + +print sys.version +print datetime.datetime.now() + +REPEAT = 1 +REPEAT = 3 + +if __name__ != "__main__": + raise SystemExit("Must run as main program") + +_RANGE_1000 = range(1000) +_RANGE_100 = range(100) + +def bench(s="", group=1): + def blah(f): + f.comment = s + f.is_bench = True + f.group = group + return f + return blah + +####### 'in' comparisons + + + at bench('"A" in "A"*1000', group="early match, single character") +def in_test_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + for x in _RANGE_1000: + s2 in s1 + + at bench('"B" in "A"*1000', group="no match, single character") +def in_test_no_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("B") + for x in _RANGE_1000: + s2 in s1 + + + at bench('"AB" in "AB"*1000', group="early match, two characters") +def in_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + for x in _RANGE_1000: + s2 in s1 + + at bench('"BC" in "AB"*1000', group="no match, two characters") +def in_test_no_match_two_character(STR): + s1 = STR("AB" * 1000) + s2 = STR("BC") + for x in _RANGE_1000: + s2 in s1 + + at bench('"BC" in ("AB"*1000+"C")', group="late match, two characters") +def in_test_slow_match_two_characters(STR): + s1 = STR("AB" * 1000+"C") + s2 = STR("BC") + for x in _RANGE_1000: + s2 in s1 + + at bench('s="ABC"*33; s in ((s+"D")*500+s+"E")', + group="late match, 100 characters") +def in_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + for x in _RANGE_100: + s2 in s1 + +# Try with regex + at bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*500+s+"E")', + group="late match, 100 characters") +def re_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + pat = re.compile(s2) + search = pat.search + for x in _RANGE_100: + search(s1) + + +#### same tests as 'in' but use 'find' + + at bench('("A"*1000).find("A")', group="early match, single character") +def find_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('("A"*1000).find("B")', group="no match, single character") +def find_test_no_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("B") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + + at bench('("AB"*1000).find("AB")', group="early match, two characters") +def find_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('("AB"*1000).find("BC")', group="no match, two characters") +def find_test_no_match_two_character(STR): + s1 = STR("AB" * 1000) + s2 = STR("BC") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('"BC" in ("AB"*1000+"C")', group="late match, two characters") +def find_test_slow_match_two_characters(STR): + s1 = STR("AB" * 1000+"C") + s2 = STR("BC") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('s="ABC"*33; ((s+"D")*500+s+"E").find(s)', + group="late match, 100 characters") +def find_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + s1_find = s1.find + for x in _RANGE_100: + s1_find(s2) + +#### Now with index. +# Skip the ones which fail because the + + + at bench('("A"*1000).index("A")', group="early match, single character") +def index_test_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + + at bench('("AB"*1000).index("AB")', group="early match, two characters") +def index_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + at bench('("AB"*1000+"C").index("BC")', group="late match, two characters") +def index_test_slow_match_two_characters(STR): + s1 = STR("AB" * 1000+"C") + s2 = STR("BC") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + at bench('s="ABC"*33; ((s+"D")*500+s+"E").index(s)', + group="late match, 100 characters") +def index_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + s1_index = s1.index + for x in _RANGE_100: + s1_index(s2) + +#### Benchmark the operator-based methods + + at bench('"A"*10', "repeat 1 character 10 times") +def repeat_single_10_times(STR): + s = STR("A") + for x in _RANGE_1000: + s * 10 + + at bench('"A"*1000', "repeat 1 character 1000 times") +def repeat_single_1000_times(STR): + s = STR("A") + for x in _RANGE_1000: + s * 1000 + + at bench('"ABCDE"*10', "repeat 5 characters 10 times") +def repeat_5_10_times(STR): + s = STR("ABCDE") + for x in _RANGE_1000: + s * 10 + + at bench('"ABCDE"*1000', "repeat 5 characters 1000 times") +def repeat_5_1000_times(STR): + s = STR("ABCDE") + for x in _RANGE_1000: + s * 1000 + +# + for concat + + at bench('"Andrew"+"Dalke"', "concat two strings") +def concat_two_strings(STR): + s1 = STR("Andrew") + s2 = STR("Dalke") + for x in _RANGE_1000: + s1+s2 + + at bench('s1+s2+s3+s4+...+s20', "concat 20 strings of words length 4 to 15") +def concat_two_strings(STR): + s1=STR('TIXSGYNREDCVBHJ') + s2=STR('PUMTLXBZVDO') + s3=STR('FVZNJ') + s4=STR('OGDXUW') + s5=STR('WEIMRNCOYVGHKB') + s6=STR('FCQTNMXPUZH') + s7=STR('TICZJYRLBNVUEAK') + s8=STR('REYB') + s9=STR('PWUOQ') + s10=STR('EQHCMKBS') + s11=STR('AEVDFOH') + s12=STR('IFHVD') + s13=STR('JGTCNLXWOHQ') + s14=STR('ITSKEPYLROZAWXF') + s15=STR('THEK') + s16=STR('GHPZFBUYCKMNJIT') + s17=STR('JMUZ') + s18=STR('WLZQMTB') + s19=STR('KPADCBW') + s20=STR('TNJHZQAGBU') + for x in _RANGE_1000: + (s1 + s2+ s3+ s4+ s5+ s6+ s7+ s8+ s9+s10+ + s11+s12+s13+s14+s15+s16+s17+s18+s19+s20) + + +#### Benchmark join + + at bench('"A".join("")', + "join empty string, with 1 character sep") +def join_empty_single(STR): + sep = STR("A") + s2 = STR("") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join("")', + "join empty string, with 5 character sep") +def join_empty_5(STR): + sep = STR("ABCDE") + s2 = STR("") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"A".join("ABC..Z")', + "join string with 26 characters, with 1 character sep") +def join_alphabet_single(STR): + sep = STR("A") + s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join("ABC..Z")', + "join string with 26 characters, with 5 character sep") +def join_alphabet_5(STR): + sep = STR("ABCDE") + s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"A".join(list("ABC..Z"))', + "join list of 26 characters, with 1 character sep") +def join_alphabet_list_single(STR): + sep = STR("A") + s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join(list("ABC..Z"))', + "join list of 26 characters, with 5 character sep") +def join_alphabet_list_five(STR): + sep = STR("ABCDE") + s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"A".join(["Bob"]*1000))', + "join list of 1000 words, with 1 character sep") +def join_1000_words_single(STR): + sep = STR("A") + s2 = [STR("Bob")]*1000 + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join(["Bob"]*1000))', + "join list of 1000 words, with 5 character sep") +def join_1000_words_5(STR): + sep = STR("ABCDE") + s2 = [STR("Bob")]*1000 + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + +#### split tests + + at bench('"this\\nis\\na\\ntest\\n".split("\\n")', "split newlines") +def newlines_split(STR): + s = STR("this\nis\na\ntest\n") + s_split = s.split + for x in _RANGE_1000: + s_split("\n") + + at bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines") +def newlines_rsplit(STR): + s = STR("this\nis\na\ntest\n") + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\n") + + at bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines") +def newlines_splitlines(STR): + s = STR("this\nis\na\ntest\n") + s_splitlines = s.splitlines + for x in _RANGE_1000: + s_splitlines() + +## split text with 2000 newlines + +def _make_2000_lines(): + import random + r = random.Random(100) + s = "".join(map(str, range(32, 128))) + s = s*4 + words = [] + for i in range(2000): + start = r.randrange(0, 26) + n = r.randint(5, 65) + words.append(s[start:n]) + return "\n".join(words)+"\n" + +_text_with_2000_lines = _make_2000_lines() +_text_with_2000_lines_unicode = unicode(_text_with_2000_lines) +def _get_2000_lines(STR): + if STR is unicode: + return _text_with_2000_lines_unicode + if STR is str: + return _text_with_2000_lines + raise AssertionError + + + at bench('"...text...".split("\\n")', "split 2000 newlines") +def newlines_split_2000(STR): + s = _get_2000_lines(STR) + s_split = s.split + for x in _RANGE_100: + s_split("\n") + + at bench('"...text...".rsplit("\\n")', "split 2000 newlines") +def newlines_rsplit_2000(STR): + s = _get_2000_lines(STR) + s_rsplit = s.rsplit + for x in _RANGE_100: + s_rsplit("\n") + + at bench('"...text...".splitlines()', "split 2000 newlines") +def newlines_splitlines_2000(STR): + s = _get_2000_lines(STR) + s_splitlines = s.splitlines + for x in _RANGE_100: + s_splitlines() + + +## split text on "--" characters + at bench( + '"this--is--a--test--of--the--emergency--broadcast--system".split("--")', + "split on multicharacter seperator") +def split_multichar_sep(STR): + s = STR("this--is--a--test--of--the--emergency--broadcast--system") + s_split = s.split + for x in _RANGE_1000: + s_split("--") + at bench( + '"this--is--a--test--of--the--emergency--broadcast--system".rsplit("--")', + "split on multicharacter seperator") +def rsplit_multichar_sep(STR): + s = STR("this--is--a--test--of--the--emergency--broadcast--system") + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("--") + +## split with limits + +GFF3_example = "\t".join([ + "I", "Genomic_canonical", "region", "357208", "396183", ".", "+", ".", + "ID=Sequence:R119;note=Clone R119%3B Genbank AF063007;Name=R119"]) + + at bench('GFF3_example.split("\\t")', "tab split") +def tab_split_no_limit(STR): + s = STR(GFF3_example) + s_split = s.split + for x in _RANGE_1000: + s_split("\t") + + at bench('GFF3_example.split("\\t", 8)', "tab split") +def tab_split_limit(STR): + s = STR(GFF3_example) + s_split = s.split + for x in _RANGE_1000: + s_split("\t", 8) + + at bench('GFF3_example.rsplit("\\t")', "tab split") +def tab_rsplit_no_limit(STR): + s = STR(GFF3_example) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\t") + + at bench('GFF3_example.rsplit("\\t", 8)', "tab split") +def tab_rsplit_limit(STR): + s = STR(GFF3_example) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\t", 8) + +#### Count characters + + at bench('...text.with.2000.newlines.count("\\n")', + "count newlines") +def count_newlines(STR): + s = _get_2000_lines(STR) + s_count = s.count + for x in _RANGE_100: + s_count("\n") + +# Orchid sequences concatenated, from Biopython +_dna = """ +CGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGGGTT +AATCTGGAGGATCTGTTTACTTTGGTCACCCATGAGCATTTGCTGTTGAAGTGACCTAGAATTGCCATCG +AGCCTCCTTGGGAGCTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGCAGTTTTGCTCCAAGTCGTT +TGACACATAATTGGTGAAGGGGGTGGCATCCTTCCCTGACCCTCCCCCAACTATTTTTTTAACAACTCTC +AGCAACGGAGACTCAGTCTTCGGCAAATGCGATAAATGGTGTGAATTGCAGAATCCCGTGCACCATCGAG +TCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCTGCCTGGGCATTGCGAGTCATAT +CTCTCCCTTAACGAGGCTGTCCATACATACTGTTCAGCCGGTGCGGATGTGAGTTTGGCCCCTTGTTCTT +TGGTACGGGGGGTCTAAGAGCTGCATGGGCTTTTGATGGTCCTAAATACGGCAAGAGGTGGACGAACTAT +GCTACAACAAAATTGTTGTGCAGAGGCCCCGGGTTGTCGTATTAGATGGGCCACCGTAATCTGAAGACCC +TTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGGCCATTTGGTTGCGACCCCAGGTCAG +GTGAGCAACAGCTGTCGTAACAAGGTTTCCGTAGGGTGAACTGCGGAAGGATCATTGTTGAGATCACATA +ATAATTGATCGAGTTAATCTGGAGGATCTGTTTACTTGGGTCACCCATGGGCATTTGCTGTTGAAGTGAC +CTAGATTTGCCATCGAGCCTCCTTGGGAGCATCCTTGTTGGCGATATCTAAACCCTCAATTTTTCCCCCA +ATCAAATTACACAAAATTGGTGGAGGGGGTGGCATTCTTCCCTTACCCTCCCCCAAATATTTTTTTAACA +ACTCTCAGCAACGGATATCTCAGCTCTTGCATCGATGAAGAACCCACCGAAATGCGATAAATGGTGTGAA +TTGCAGAATCCCGTGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACG +CCTGCCTGGGCATTGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACATACTGTTCAGCCGGTGCG +GATGTGAGTTTGGCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGATGCATGGGCTTTTGATGGTCCTAA +ATACGGCAAGAGGTGGACGAACTATGCTACAACAAAATTGTTGTGCAAAGGCCCCGGGTTGTCGTATAAG +ATGGGCCACCGATATCTGAAGACCCTTTTGGACCCCATTGGAGCCCATCAACCCATGTCAGTTGATGGCC +ATTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGA +GTTAATCTGGAGGATCTGTTTACTTGGGTCACCCATGGGCATTTGCTGTTGAAGTGACCTAGATTTGCCA +TCGAGCCTCCTTGGGAGCTTTCTTGTTGGCGATATCTAAACCCTTGCCCGGCAGAGTTTTGGGAATCCCG +TGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCTGCCTGGGCAT +TGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACACACCTGTTCAGCCGGTGCGGATGTGAGTTTG +GCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGCTGCATGGGCTTTTGATGGTCCTAAATACGGCAAGAG +GTGGACGAACTATGCTACAACAAAATTGTTGTGCAAAGGCCCCGGGTTGTCGTATTAGATGGGCCACCAT +AATCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGGCCATTTGGTTGC +GACCCAGTCAGGTGAGGGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGAG +TTAATCTGGAGGATCTGTTTACTTTGGTCACCCATGGGCATTTGCTGTTGAAGTGACCTAGATTTGCCAT +CGAGCCTCCTTGGGAGCTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGGAGTTTGGCGCCAAGTCA +TATGACACATAATTGGTGAAGGGGGTGGCATCCTGCCCTGACCCTCCCCAAATTATTTTTTTAACAACTC +TCAGCAACGGATATCTCGGCTCTTGCATCGATGAAGAACGCAGCGAAATGCGATAAATGGTGTGAATTGC +AGAATCCCGTGAACCATCGAGTCTTTGGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCT +GCCTGGGCATTGGGAATCATATCTCTCCCCTAACGAGGCTATCCAAACATACTGTTCATCCGGTGCGGAT +GTGAGTTTGGCCCCTTGTTCTTTGGTACCGGGGGTCTAAGAGCTGCATGGGCATTTGATGGTCCTCAAAA +CGGCAAGAGGTGGACGAACTATGCCACAACAAAATTGTTGTCCCAAGGCCCCGGGTTGTCGTATTAGATG +GGCCACCGTAACCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGACCA +TTTGTTGCGACCCCAGTCAGCTGAGCAACCCGCTGAGTGGAAGGTCATTGCCGATATCACATAATAATTG +ATCGAGTTAATCTGGAGGATCTGTTTACTTGGTCACCCATGAGCATTTGCTGTTGAAGTGACCTAGATTT +GCCATCGAGCCTCCTTGGGAGTTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGGAGTTGTGCGCCA +AGTCATATGACACATAATTGGTGAAGGGGGTGGCATCCTGCCCTGACCCTCCCCAAATTATTTTTTTAAC +AACTCTCAGCAACGGATATCTCGGCTCTTGCATCGATGAAGAACGCAGCGAAATGCGATAAATGGTGTGA +ATTGCAGAATCCCGTGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCAC +GCCTGCCTGGGCATTGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACATACTGTTCATCCGGTGC +GGATGTGAGTTTGGCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGCTGCATGGGCATTTGATGGTCCTC +AAAACGGCAAGAGGTGGACGAACTATGCTACAACCAAATTGTTGTCCCAAGGCCCCGGGTTGTCGTATTA +GATGGGCCACCGTAACCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATG +ACCATGTGTTGCGACCCCAGTCAGCTGAGCAACGCGCTGAGCGTAACAAGGTTTCCGTAGGTGGACCTCC +GGGAGGATCATTGTTGAGATCACATAATAATTGATCGAGGTAATCTGGAGGATCTGCATATTTTGGTCAC +""" +_dna = "".join(_dna.splitlines()) +_dna = _dna * 50 +_dna_unicode = unicode(_dna) + + at bench('dna.count("AACT")', "count AACT substrings in DNA example") +def count_aact(STR): + if STR is unicode: + seq = _dna_unicode + elif STR is str: + seq = _dna + else: + raise AssertionError + seq_count = seq.count + for x in _RANGE_100: + seq_count("AACT") + +##### startswith and endswith + + at bench('"Andrew".startswith("A")', 'startswith single character') +def startswith_single(STR): + s1 = STR("Andrew") + s2 = STR("A") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + at bench('"Andrew".startswith("Andrew")', 'startswith multiple characters') +def startswith_multiple(STR): + s1 = STR("Andrew") + s2 = STR("Andrew") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + at bench('"Andrew".startswith("Anders")', + 'startswith multiple characters - not!') +def startswith_multiple_not(STR): + s1 = STR("Andrew") + s2 = STR("Anders") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + +# endswith + + at bench('"Andrew".endswith("w")', 'endswith single character') +def endswith_single(STR): + s1 = STR("Andrew") + s2 = STR("w") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + + at bench('"Andrew".endswith("Andrew")', 'endswith multiple characters') +def endswith_multiple(STR): + s1 = STR("Andrew") + s2 = STR("Andrew") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + + at bench('"Andrew".endswith("Anders")', + 'endswith multiple characters - not!') +def endswith_multiple_not(STR): + s1 = STR("Andrew") + s2 = STR("Anders") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + +#### Strip + + at bench('"Hello!\\n".strip()', 'strip terminal newline') +def terminal_newline_strip(STR): + s = STR("Hello!\n") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"Hello!\\n".rstrip()', 'strip terminal newline') +def terminal_newline_rstrip(STR): + s = STR("Hello!\n") + s_rstrip = s.rstrip + for x in _RANGE_1000: + s_rstrip() + + at bench('s="Hello!\\n"; s[:-1] if s[-1]=="\\n" else s', + 'strip terminal newline') +def terminal_newline_if_else(STR): + s = STR("Hello!\n") + NL = STR("\n") + for x in _RANGE_1000: + s[:-1] if (s[-1] == NL) else s + + + +# strip +# lstrip +# rstrip +# replace + +# rfind +# rindex + + +# end of benchmarks + +################# + +class BenchTimer(timeit.Timer): + def best(self, repeat=1): + for i in range(1, 10): + number = 10**i + try: + x = self.timeit(number) + except: + self.print_exc() + raise + if x > 0.2: + break + times = [x] + for i in range(1, repeat): + times.append(self.timeit(number)) + return min(times) / number + +def main(): + test_names = sys.argv[1:] + + bench_functions = [] + for (k,v) in globals().items(): + if hasattr(v, "is_bench"): + if test_names: + for name in test_names: + if name in v.group: + break + else: + # Not selected, ignore + continue + bench_functions.append( (v.group, k, v) ) + bench_functions.sort() + + print "string\tunicode" + print "(in ms)\t(in ms)\t%\tcomment" + + for title, group in itertools.groupby(bench_functions, + operator.itemgetter(0)): + print "="*10, title + for (_, k, v) in group: + if hasattr(v, "is_bench"): + str_time = BenchTimer("__main__.%s(str)" % (k,), + "import __main__").best(REPEAT) + uni_time = BenchTimer("__main__.%s(unicode)" % (k,), + "import __main__").best(REPEAT) + print "%.2f\t%.2f\t%.1f\t%s" % ( + 1000*str_time, 1000*uni_time, 100.*str_time/uni_time, + v.comment) + +if __name__ == "__main__": + main() + From python-checkins at python.org Mon May 22 21:17:05 2006 From: python-checkins at python.org (tim.peters) Date: Mon, 22 May 2006 21:17:05 +0200 (CEST) Subject: [Python-checkins] r46084 - python/trunk/Objects/unicodeobject.c Message-ID: <20060522191705.838C61E4008@bag.python.org> Author: tim.peters Date: Mon May 22 21:17:04 2006 New Revision: 46084 Modified: python/trunk/Objects/unicodeobject.c Log: PyUnicode_Join(): Recent code changes introduced new compiler warnings on Windows (signed vs unsigned mismatch in comparisons). Cleaned that up by switching more locals to Py_ssize_t. Simplified overflow checking (it can _be_ simpler because while these things are declared as Py_ssize_t, then should in fact never be negative). Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon May 22 21:17:04 2006 @@ -4148,10 +4148,10 @@ PyObject *internal_separator = NULL; const Py_UNICODE blank = ' '; const Py_UNICODE *sep = ␣ - size_t seplen = 1; + Py_ssize_t seplen = 1; PyUnicodeObject *res = NULL; /* the result */ - size_t res_alloc = 100; /* # allocated bytes for string in res */ - size_t res_used; /* # used bytes */ + Py_ssize_t res_alloc = 100; /* # allocated bytes for string in res */ + Py_ssize_t res_used; /* # used bytes */ Py_UNICODE *res_p; /* pointer to free byte in res's string area */ PyObject *fseq; /* PySequence_Fast(seq) */ Py_ssize_t seqlen; /* len(fseq) -- number of items in sequence */ @@ -4212,8 +4212,8 @@ res_used = 0; for (i = 0; i < seqlen; ++i) { - size_t itemlen; - size_t new_res_used; + Py_ssize_t itemlen; + Py_ssize_t new_res_used; item = PySequence_Fast_GET_ITEM(fseq, i); /* Convert item to Unicode. */ @@ -4235,19 +4235,18 @@ /* Make sure we have enough space for the separator and the item. */ itemlen = PyUnicode_GET_SIZE(item); new_res_used = res_used + itemlen; - if (new_res_used < res_used || new_res_used > PY_SSIZE_T_MAX) + if (new_res_used <= 0) goto Overflow; if (i < seqlen - 1) { new_res_used += seplen; - if (new_res_used < res_used || new_res_used > PY_SSIZE_T_MAX) + if (new_res_used <= 0) goto Overflow; } if (new_res_used > res_alloc) { /* double allocated size until it's big enough */ do { - size_t oldsize = res_alloc; res_alloc += res_alloc; - if (res_alloc < oldsize || res_alloc > PY_SSIZE_T_MAX) + if (res_alloc <= 0) goto Overflow; } while (new_res_used > res_alloc); if (_PyUnicode_Resize(&res, res_alloc) < 0) { From mal at egenix.com Mon May 22 22:05:54 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 22 May 2006 22:05:54 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <20060522183817.DDD4A1E4007@bag.python.org> References: <20060522183817.DDD4A1E4007@bag.python.org> Message-ID: <447219A2.4090201@egenix.com> andrew.dalke wrote: > Author: andrew.dalke > Date: Mon May 22 20:38:16 2006 > New Revision: 46083 > > Added: > sandbox/trunk/stringbench/ > sandbox/trunk/stringbench/stringbench.py (contents, props changed) > Log: > "Need for speed" microbenchmarks for string processing Why don't you add these to pybench which is now part of Python (see Tools/pybench/) ?! > Added: sandbox/trunk/stringbench/stringbench.py -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 22 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tim.peters at gmail.com Mon May 22 22:10:37 2006 From: tim.peters at gmail.com (Tim Peters) Date: Mon, 22 May 2006 20:10:37 +0000 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <447219A2.4090201@egenix.com> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> Message-ID: <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> >> Author: andrew.dalke >> Date: Mon May 22 20:38:16 2006 >> New Revision: 46083 >> >> Added: >> sandbox/trunk/stringbench/ >> sandbox/trunk/stringbench/stringbench.py (contents, props changed) >> Log: >> "Need for speed" microbenchmarks for string processing [M.-A. Lemburg] > Why don't you add these to pybench which is now part of Python > (see Tools/pybench/) ?! We were wondering about that :-) If it's OK by you, we'd like to add several new tests to pybench. From mal at egenix.com Mon May 22 22:24:19 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 22 May 2006 22:24:19 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> Message-ID: <44721DF3.1070103@egenix.com> Tim Peters wrote: >>> Author: andrew.dalke >>> Date: Mon May 22 20:38:16 2006 >>> New Revision: 46083 >>> >>> Added: >>> sandbox/trunk/stringbench/ >>> sandbox/trunk/stringbench/stringbench.py (contents, props changed) >>> Log: >>> "Need for speed" microbenchmarks for string processing > > [M.-A. Lemburg] >> Why don't you add these to pybench which is now part of Python >> (see Tools/pybench/) ?! > > We were wondering about that :-) If it's OK by you, we'd like to add > several new tests to pybench. Sure, it's definitely OK by me. The only thing you should do is make sure that the tests run in more than just the most current Python version, e.g. by either putting code using more recent syntax into different modules and/or adding the code in using a condition based on sys.version or some other feature test. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 22 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From buildbot at python.org Mon May 22 22:35:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 22 May 2006 20:35:22 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060522203522.2CF751E401A@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/162 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From skip at pobox.com Tue May 23 03:57:39 2006 From: skip at pobox.com (skip at pobox.com) Date: Mon, 22 May 2006 20:57:39 -0500 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <44721DF3.1070103@egenix.com> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> <44721DF3.1070103@egenix.com> Message-ID: <17522.27667.565671.713477@montanaro.dyndns.org> MAL> The only thing you should do is make sure that the tests run in MAL> more than just the most current Python version, e.g. by either MAL> putting code using more recent syntax into different modules and/or MAL> adding the code in using a condition based on sys.version or some MAL> other feature test. How far back should compatibility be maintained? I thought there was a file in Misc that identified version compatibility requirements. I didn't find what I was looking for or see any version compatibility in pybench/README. Skip From guido at python.org Tue May 23 04:53:24 2006 From: guido at python.org (Guido van Rossum) Date: Mon, 22 May 2006 19:53:24 -0700 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <17522.27667.565671.713477@montanaro.dyndns.org> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> <44721DF3.1070103@egenix.com> <17522.27667.565671.713477@montanaro.dyndns.org> Message-ID: On 5/22/06, skip at pobox.com wrote: > > MAL> The only thing you should do is make sure that the tests run in > MAL> more than just the most current Python version, e.g. by either > MAL> putting code using more recent syntax into different modules and/or > MAL> adding the code in using a condition based on sys.version or some > MAL> other feature test. > > How far back should compatibility be maintained? I thought there was a file > in Misc that identified version compatibility requirements. I didn't find > what I was looking for or see any version compatibility in pybench/README. Maybe you're thinking of PEP 291? -- --Guido van Rossum (home page: http://www.python.org/~guido/) From nnorwitz at gmail.com Tue May 23 07:28:37 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 22 May 2006 22:28:37 -0700 Subject: [Python-checkins] r46079 - in python/trunk: Include/unicodeobject.h Objects/unicodeobject.c In-Reply-To: <20060522171301.1B0D91E4007@bag.python.org> References: <20060522171301.1B0D91E4007@bag.python.org> Message-ID: On 5/22/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Mon May 22 19:12:58 2006 > New Revision: 46079 > > Modified: > python/trunk/Include/unicodeobject.h > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: use memcpy for "long" strings; use a better algorithm > for long repeats. > > > > Modified: python/trunk/Objects/unicodeobject.c > ============================================================================== > --- python/trunk/Objects/unicodeobject.c (original) > +++ python/trunk/Objects/unicodeobject.c Mon May 22 19:12:58 2006 > @@ -5900,11 +5900,18 @@ > > if (str->length == 1 && len > 0) { > Py_UNICODE_FILL(p, str->str[0], len); > - } else > - while (len-- > 0) { > + } else { > + int done = 0; /* number of characters copied this far */ > + if (done < nchars) { > Py_UNICODE_COPY(p, str->str, str->length); > - p += str->length; > - } > + done = str->length; done looks like it should be a Py_ssize_t here (since setting to str->length). n From nnorwitz at gmail.com Tue May 23 07:36:48 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 22 May 2006 22:36:48 -0700 Subject: [Python-checkins] r46080 - python/branches/rjones-funccall/Objects/frameobject.c In-Reply-To: <20060522172332.A9E1F1E4007@bag.python.org> References: <20060522172332.A9E1F1E4007@bag.python.org> Message-ID: On 5/22/06, richard.jones wrote: > Author: richard.jones > Date: Mon May 22 19:23:31 2006 > New Revision: 46080 > > Modified: > python/branches/rjones-funccall/Objects/frameobject.c > Log: > Extra paranoia chanelled from Tim. > > Fixed C style. > > > Modified: python/branches/rjones-funccall/Objects/frameobject.c > ============================================================================== > --- python/branches/rjones-funccall/Objects/frameobject.c (original) > +++ python/branches/rjones-funccall/Objects/frameobject.c Mon May 22 19:23:31 2006 > @@ -406,17 +406,15 @@ > Py_CLEAR(f->f_exc_traceback); > > co = f->f_code; > - if (co->co_zombieframe == NULL) { > + if (co != NULL && co->co_zombieframe == NULL) > co->co_zombieframe = f; > - } Not sure what the co NULL check buys you here... [...] > Py_DECREF(co); > Py_TRASHCAN_SAFE_END(f) since the DECREF will blow up anyway. Unless you want that to be an XDECREF. n From python-checkins at python.org Tue May 23 07:47:17 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 07:47:17 +0200 (CEST) Subject: [Python-checkins] r46085 - python/trunk/Objects/unicodeobject.c Message-ID: <20060523054717.9E2B71E4017@bag.python.org> Author: tim.peters Date: Tue May 23 07:47:16 2006 New Revision: 46085 Modified: python/trunk/Objects/unicodeobject.c Log: unicode_repeat(): Change type of local to Py_ssize_t, since that's what it should be. Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Tue May 23 07:47:16 2006 @@ -5900,7 +5900,7 @@ if (str->length == 1 && len > 0) { Py_UNICODE_FILL(p, str->str[0], len); } else { - int done = 0; /* number of characters copied this far */ + Py_ssize_t done = 0; /* number of characters copied this far */ if (done < nchars) { Py_UNICODE_COPY(p, str->str, str->length); done = str->length; From tim.peters at gmail.com Tue May 23 07:48:32 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 23 May 2006 05:48:32 +0000 Subject: [Python-checkins] r46079 - in python/trunk: Include/unicodeobject.h Objects/unicodeobject.c In-Reply-To: References: <20060522171301.1B0D91E4007@bag.python.org> Message-ID: <1f7befae0605222248v3a92c1f1r7560b5f2593a2087@mail.gmail.com> >> Author: fredrik.lundh >> Date: Mon May 22 19:12:58 2006 >> New Revision: 46079 >> >> Modified: >> python/trunk/Include/unicodeobject.h >> python/trunk/Objects/unicodeobject.c >> Log: >> needforspeed: use memcpy for "long" strings; use a better algorithm >> for long repeats. >> >> >> >> Modified: python/trunk/Objects/unicodeobject.c >> ============================================================================= >> --- python/trunk/Objects/unicodeobject.c (original) >> +++ python/trunk/Objects/unicodeobject.c Mon May 22 19:12:58 2006 >> @@ -5900,11 +5900,18 @@ >> >> if (str->length == 1 && len > 0) { >> Py_UNICODE_FILL(p, str->str[0], len); >> - } else >> - while (len-- > 0) { >> + } else { >> + int done = 0; /* number of characters copied this far */ >> + if (done < nchars) { >> Py_UNICODE_COPY(p, str->str, str->length); >> - p += str->length; >> - } >> + done = str->length; [Neal Norwitz] > done looks like it should be a Py_ssize_t here (since setting to str->length). Definitely -- I changed it. Thanks for the eyeballs! From buildbot at python.org Tue May 23 08:24:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 06:24:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060523062434.DD8241E4018@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/745 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Tue May 23 09:35:03 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 23 May 2006 09:35:03 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench/stringbench.py In-Reply-To: <17522.27667.565671.713477@montanaro.dyndns.org> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> <1f7befae0605221310r255f92a5j2096d836fb5ef174@mail.gmail.com> <44721DF3.1070103@egenix.com> <17522.27667.565671.713477@montanaro.dyndns.org> Message-ID: <4472BB27.6000300@egenix.com> skip at pobox.com wrote: > MAL> The only thing you should do is make sure that the tests run in > MAL> more than just the most current Python version, e.g. by either > MAL> putting code using more recent syntax into different modules and/or > MAL> adding the code in using a condition based on sys.version or some > MAL> other feature test. > > How far back should compatibility be maintained? I thought there was a file > in Misc that identified version compatibility requirements. I didn't find > what I was looking for or see any version compatibility in pybench/README. Here's the quote from PEP 291: pybench Marc-Andre Lemburg 1.5.2 [3] [3] pybench lives under the Tools/ directory. Compatibility with older Python version is needed in order to be able to compare performance between Python versions. New features may still be used in new tests, which may then be configured to fail gracefully on import by the tool in older Python versions. If you use new syntax, you'll have to create a new module and then add it to Setup.py embedded in try-except. If you're just using new features, then a condition based on sys.version or the specific feature will do, see e.g. Strings.py. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 23 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2006-07-03: EuroPython 2006, CERN, Switzerland 40 days left ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Tue May 23 09:57:50 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 09:57:50 +0200 (CEST) Subject: [Python-checkins] r46086 - python/branches/rjones-funccall/Objects/frameobject.c Message-ID: <20060523075750.A545E1E4019@bag.python.org> Author: richard.jones Date: Tue May 23 09:57:50 2006 New Revision: 46086 Modified: python/branches/rjones-funccall/Objects/frameobject.c Log: don't try to decref a NULL - thanks Neal Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Tue May 23 09:57:50 2006 @@ -437,7 +437,7 @@ else PyObject_GC_Del(f); - Py_DECREF(co); + Py_XDECREF(co); Py_TRASHCAN_SAFE_END(f) } From python-checkins at python.org Tue May 23 10:58:27 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 23 May 2006 10:58:27 +0200 (CEST) Subject: [Python-checkins] r46087 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060523085827.674261E4018@bag.python.org> Author: fredrik.lundh Date: Tue May 23 10:58:26 2006 New Revision: 46087 Modified: sandbox/trunk/stringbench/stringbench.py Log: whitespace normalization added a summary lines Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Tue May 23 10:58:26 2006 @@ -85,7 +85,7 @@ search = pat.search for x in _RANGE_100: search(s1) - + #### same tests as 'in' but use 'find' @@ -122,7 +122,7 @@ for x in _RANGE_1000: s1_find(s2) - at bench('"BC" in ("AB"*1000+"C")', group="late match, two characters") + at bench('("AB"*1000+"C").find("BC")', group="late match, two characters") def find_test_slow_match_two_characters(STR): s1 = STR("AB" * 1000+"C") s2 = STR("BC") @@ -143,7 +143,7 @@ #### Now with index. # Skip the ones which fail because the - + @bench('("A"*1000).index("A")', group="early match, single character") def index_test_quick_match_single_character(STR): s1 = STR("A" * 1000) @@ -204,7 +204,7 @@ s = STR("ABCDE") for x in _RANGE_1000: s * 1000 - + # + for concat @bench('"Andrew"+"Dalke"', "concat two strings") @@ -323,14 +323,14 @@ s_split = s.split for x in _RANGE_1000: s_split("\n") - + @bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines") def newlines_rsplit(STR): s = STR("this\nis\na\ntest\n") s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\n") - + @bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines") def newlines_splitlines(STR): s = STR("this\nis\na\ntest\n") @@ -339,7 +339,7 @@ s_splitlines() ## split text with 2000 newlines - + def _make_2000_lines(): import random r = random.Random(100) @@ -360,7 +360,7 @@ if STR is str: return _text_with_2000_lines raise AssertionError - + @bench('"...text...".split("\\n")', "split 2000 newlines") def newlines_split_2000(STR): @@ -368,14 +368,14 @@ s_split = s.split for x in _RANGE_100: s_split("\n") - + @bench('"...text...".rsplit("\\n")', "split 2000 newlines") def newlines_rsplit_2000(STR): s = _get_2000_lines(STR) s_rsplit = s.rsplit for x in _RANGE_100: s_rsplit("\n") - + @bench('"...text...".splitlines()', "split 2000 newlines") def newlines_splitlines_2000(STR): s = _get_2000_lines(STR) @@ -414,21 +414,21 @@ s_split = s.split for x in _RANGE_1000: s_split("\t") - + @bench('GFF3_example.split("\\t", 8)', "tab split") def tab_split_limit(STR): s = STR(GFF3_example) s_split = s.split for x in _RANGE_1000: s_split("\t", 8) - + @bench('GFF3_example.rsplit("\\t")', "tab split") def tab_rsplit_no_limit(STR): s = STR(GFF3_example) s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\t") - + @bench('GFF3_example.rsplit("\\t", 8)', "tab split") def tab_rsplit_limit(STR): s = STR(GFF3_example) @@ -595,7 +595,7 @@ s[:-1] if (s[-1] == NL) else s - + # strip # lstrip # rstrip @@ -627,7 +627,7 @@ def main(): test_names = sys.argv[1:] - + bench_functions = [] for (k,v) in globals().items(): if hasattr(v, "is_bench"): @@ -644,6 +644,8 @@ print "string\tunicode" print "(in ms)\t(in ms)\t%\tcomment" + str_total = uni_total = 0 + for title, group in itertools.groupby(bench_functions, operator.itemgetter(0)): print "="*10, title @@ -656,7 +658,14 @@ print "%.2f\t%.2f\t%.1f\t%s" % ( 1000*str_time, 1000*uni_time, 100.*str_time/uni_time, v.comment) + str_total += str_time + uni_total += uni_time + + print "%.2f\t%.2f\t%.1f\t%s" % ( + 1000*str_total, 1000*uni_total, 100.*str_total/uni_total, + "TOTAL") + if __name__ == "__main__": main() - + From python-checkins at python.org Tue May 23 11:06:31 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 11:06:31 +0200 (CEST) Subject: [Python-checkins] r46088 - in python/branches/rjones-funccall: Include/unicodeobject.h Lib/gzip.py Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060523090631.42CB11E4018@bag.python.org> Author: richard.jones Date: Tue May 23 11:06:29 2006 New Revision: 46088 Modified: python/branches/rjones-funccall/ (props changed) python/branches/rjones-funccall/Include/unicodeobject.h python/branches/rjones-funccall/Lib/gzip.py python/branches/rjones-funccall/Objects/stringobject.c python/branches/rjones-funccall/Objects/unicodeobject.c Log: merge from trunk Modified: python/branches/rjones-funccall/Include/unicodeobject.h ============================================================================== --- python/branches/rjones-funccall/Include/unicodeobject.h (original) +++ python/branches/rjones-funccall/Include/unicodeobject.h Tue May 23 11:06:29 2006 @@ -352,12 +352,20 @@ Py_UNICODE_ISDIGIT(ch) || \ Py_UNICODE_ISNUMERIC(ch)) -#define Py_UNICODE_COPY(target, source, length)\ - (memcpy((target), (source), (length)*sizeof(Py_UNICODE))) +/* memcpy has a considerable setup overhead on many platforms; use a + loop for short strings (the "16" below is pretty arbitary) */ +#define Py_UNICODE_COPY(target, source, length) do\ + {Py_ssize_t i_; Py_UNICODE *t_ = (target); const Py_UNICODE *s_ = (source);\ + if (length > 16)\ + memcpy(t_, s_, (length)*sizeof(Py_UNICODE));\ + else\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = s_[i_];\ + } while (0) #define Py_UNICODE_FILL(target, value, length) do\ - {int i; for (i = 0; i < (length); i++) (target)[i] = (value);}\ - while (0) + {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ + } while (0) #define Py_UNICODE_MATCH(string, offset, substring)\ ((*((string)->str + (offset)) == *((substring)->str)) &&\ Modified: python/branches/rjones-funccall/Lib/gzip.py ============================================================================== --- python/branches/rjones-funccall/Lib/gzip.py (original) +++ python/branches/rjones-funccall/Lib/gzip.py Tue May 23 11:06:29 2006 @@ -107,6 +107,8 @@ self.extrabuf = "" self.extrasize = 0 self.filename = filename + # Starts small, scales exponentially + self.min_readsize = 100 elif mode[0:1] == 'w' or mode[0:1] == 'a': self.mode = WRITE @@ -381,32 +383,35 @@ self.read(count % 1024) def readline(self, size=-1): - if size < 0: size = sys.maxint + if size < 0: + size = sys.maxint + readsize = self.min_readsize + else: + readsize = size bufs = [] - readsize = min(100, size) # Read from the file in small chunks - while True: - if size == 0: - return "".join(bufs) # Return resulting line - + while size != 0: c = self.read(readsize) i = c.find('\n') - if size is not None: - # We set i=size to break out of the loop under two - # conditions: 1) there's no newline, and the chunk is - # larger than size, or 2) there is a newline, but the - # resulting line would be longer than 'size'. - if i==-1 and len(c) > size: i=size-1 - elif size <= i: i = size -1 + + # We set i=size to break out of the loop under two + # conditions: 1) there's no newline, and the chunk is + # larger than size, or 2) there is a newline, but the + # resulting line would be longer than 'size'. + if (size <= i) or (i == -1 and len(c) > size): + i = size - 1 if i >= 0 or c == '': - bufs.append(c[:i+1]) # Add portion of last chunk - self._unread(c[i+1:]) # Push back rest of chunk - return ''.join(bufs) # Return resulting line + bufs.append(c[:i + 1]) # Add portion of last chunk + self._unread(c[i + 1:]) # Push back rest of chunk + break # Append chunk to list, decrease 'size', bufs.append(c) size = size - len(c) readsize = min(size, readsize * 2) + if readsize > self.min_readsize: + self.min_readsize = min(readsize, self.min_readsize * 2, 512) + return ''.join(bufs) # Return resulting line def readlines(self, sizehint=0): # Negative numbers result in reading all the lines Modified: python/branches/rjones-funccall/Objects/stringobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/stringobject.c (original) +++ python/branches/rjones-funccall/Objects/stringobject.c Tue May 23 11:06:29 2006 @@ -2159,9 +2159,9 @@ PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ -Return the number of occurrences of substring sub in string\n\ -S[start:end]. Optional arguments start and end are\n\ -interpreted as in slice notation."); +Return the number of non-overlapping occurrences of substring sub in\n\ +string S[start:end]. Optional arguments start and end are interpreted\n\ +as in slice notation."); static PyObject * string_count(PyStringObject *self, PyObject *args) Modified: python/branches/rjones-funccall/Objects/unicodeobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/unicodeobject.c (original) +++ python/branches/rjones-funccall/Objects/unicodeobject.c Tue May 23 11:06:29 2006 @@ -5078,8 +5078,8 @@ PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ -Return the number of occurrences of substring sub in Unicode string\n\ -S[start:end]. Optional arguments start and end are\n\ +Return the number of non-overlapping occurrences of substring sub in\n\ +Unicode string S[start:end]. Optional arguments start and end are\n\ interpreted as in slice notation."); static PyObject * @@ -5898,9 +5898,19 @@ p = u->str; - while (len-- > 0) { - Py_UNICODE_COPY(p, str->str, str->length); - p += str->length; + if (str->length == 1 && len > 0) { + Py_UNICODE_FILL(p, str->str[0], len); + } else { + int done = 0; /* number of characters copied this far */ + if (done < nchars) { + Py_UNICODE_COPY(p, str->str, str->length); + done = str->length; + } + while (done < nchars) { + int n = (done <= nchars-done) ? done : nchars-done; + Py_UNICODE_COPY(p+done, p, n); + done += n; + } } return (PyObject*) u; From python-checkins at python.org Tue May 23 11:09:32 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 11:09:32 +0200 (CEST) Subject: [Python-checkins] r46089 - in python/branches/rjones-funccall: Objects/unicodeobject.c Message-ID: <20060523090932.8045C1E4018@bag.python.org> Author: richard.jones Date: Tue May 23 11:09:31 2006 New Revision: 46089 Modified: python/branches/rjones-funccall/ (props changed) python/branches/rjones-funccall/Objects/unicodeobject.c Log: merge from trunk Modified: python/branches/rjones-funccall/Objects/unicodeobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/unicodeobject.c (original) +++ python/branches/rjones-funccall/Objects/unicodeobject.c Tue May 23 11:09:31 2006 @@ -4148,10 +4148,10 @@ PyObject *internal_separator = NULL; const Py_UNICODE blank = ' '; const Py_UNICODE *sep = ␣ - size_t seplen = 1; + Py_ssize_t seplen = 1; PyUnicodeObject *res = NULL; /* the result */ - size_t res_alloc = 100; /* # allocated bytes for string in res */ - size_t res_used; /* # used bytes */ + Py_ssize_t res_alloc = 100; /* # allocated bytes for string in res */ + Py_ssize_t res_used; /* # used bytes */ Py_UNICODE *res_p; /* pointer to free byte in res's string area */ PyObject *fseq; /* PySequence_Fast(seq) */ Py_ssize_t seqlen; /* len(fseq) -- number of items in sequence */ @@ -4212,8 +4212,8 @@ res_used = 0; for (i = 0; i < seqlen; ++i) { - size_t itemlen; - size_t new_res_used; + Py_ssize_t itemlen; + Py_ssize_t new_res_used; item = PySequence_Fast_GET_ITEM(fseq, i); /* Convert item to Unicode. */ @@ -4235,19 +4235,18 @@ /* Make sure we have enough space for the separator and the item. */ itemlen = PyUnicode_GET_SIZE(item); new_res_used = res_used + itemlen; - if (new_res_used < res_used || new_res_used > PY_SSIZE_T_MAX) + if (new_res_used <= 0) goto Overflow; if (i < seqlen - 1) { new_res_used += seplen; - if (new_res_used < res_used || new_res_used > PY_SSIZE_T_MAX) + if (new_res_used <= 0) goto Overflow; } if (new_res_used > res_alloc) { /* double allocated size until it's big enough */ do { - size_t oldsize = res_alloc; res_alloc += res_alloc; - if (res_alloc < oldsize || res_alloc > PY_SSIZE_T_MAX) + if (res_alloc <= 0) goto Overflow; } while (new_res_used > res_alloc); if (_PyUnicode_Resize(&res, res_alloc) < 0) { @@ -5901,7 +5900,7 @@ if (str->length == 1 && len > 0) { Py_UNICODE_FILL(p, str->str[0], len); } else { - int done = 0; /* number of characters copied this far */ + Py_ssize_t done = 0; /* number of characters copied this far */ if (done < nchars) { Py_UNICODE_COPY(p, str->str, str->length); done = str->length; From python-checkins at python.org Tue May 23 11:45:55 2006 From: python-checkins at python.org (martin.blais) Date: Tue, 23 May 2006 11:45:55 +0200 (CEST) Subject: [Python-checkins] r46090 - python/branches/blais-bytebuf Message-ID: <20060523094555.D623B1E4018@bag.python.org> Author: martin.blais Date: Tue May 23 11:45:55 2006 New Revision: 46090 Added: python/branches/blais-bytebuf/ - copied from r46089, python/trunk/ Log: Creating a new branch for the byte buffer implementation. From python-checkins at python.org Tue May 23 11:53:13 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 11:53:13 +0200 (CEST) Subject: [Python-checkins] r46091 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523095313.42CFA1E4018@bag.python.org> Author: georg.brandl Date: Tue May 23 11:53:12 2006 New Revision: 46091 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Update to current status. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 11:53:12 2006 @@ -6,6 +6,8 @@ #include "structmember.h" #include "decimal.h" +/* XXX: getcontext() perhaps shouldn't INCREF the ctx */ + /* helpful macros ************************************************************/ #define MODULE_NAME "_decimal" @@ -244,12 +246,159 @@ return 0; } -/* default: rounding=-1 (use context), see the ROUND_* constants */ +static decimalobject * +_round_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_half_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_half_even(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_half_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_floor(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +static decimalobject * +_round_ceiling(decimalobject *self, long prec, long expdiff, contextobject *ctx) +{ +} + +typedef decimalobject*(*round_func)(decimalobject *, long, long, contextobject *); +static round_func round_funcs[] = { + _round_down, _round_up, _round_half_down, _round_half_even, + _round_half_up, _round_floor, _round_ceiling +}; + +/* default: prec=-1, rounding=-1 (use context), see the ROUND_* constants */ static decimalobject * _decimal_round(decimalobject *self, long prec, contextobject *ctx, int rounding) { - /* XXX */ - Py_RETURN_NONE; + decimalobject *new, *new2, *errres; + Py_ssize_t i, expdiff; + round_func rnd_func; + + if (ISSPECIAL(self)) { + decimalobject *nan = NULL; + int ret; + ret = _check_nans(self, NULL, ctx, &nan); + if (ret != 0) return nan; + if (ISINF(self)) return decimal_copy(self); + } + if (rounding == -1) + rounding = ctx->rounding; + if (prec == -1) + prec = ctx->prec; + + if (rounding < 0 || rounding > ROUND_CEILING) { + PyErr_SetString(PyExc_ValueError, "invalid rounding mode"); + return NULL; + } + + if (!decimal_nonzero(self)) { + if (prec <= 0) + i = 1; + else + i = prec; + + new = _new_decimalobj(i, self->sign, + self->ob_size - prec + self->exp); + if (!new) return NULL; + while (i--) + new->digits[i] = 0; + + errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + if (!errres) { + Py_DECREF(new); + return NULL; /* error was set */ + } + Py_DECREF(errres); /* we don't need the returned object */ + return new; + } + + if (prec == 0) { + new = _new_decimalobj(self->ob_size+1, self->sign, self->exp); + if (!new) return NULL; + new->digits[0] = 0; + for (i = 1; i < new->ob_size; i++) + new->digits[i] = self->digits[i-1]; + prec = 1; + } else if (prec < 0) { + new = _new_decimalobj(2, self->sign, + self->exp + self->ob_size - prec - 1); + if (!new) return NULL; + new->digits[0] = 0; + new->digits[1] = 1; + prec = 1; + } else { + new = decimal_copy(self); + if (!new) return NULL; + } + + expdiff = prec - new->ob_size; + if (expdiff == 0) + return new; + else if (expdiff > 0) { + /* we need to extend precision */ + new2 = _new_decimalobj(prec, new->sign, new->exp - expdiff); + if (!new2) { + Py_DECREF(new); + return NULL; + } + for (i = 0; i < new->ob_size; i++) { + new2->digits[i] = new->digits[i]; + } + for (i = new->ob_size; i < new2->ob_size; i++) { + new2->digits[i] = 0; + } + Py_DECREF(new); + return new2; + } + + /* Maybe all the lost digits are 0. */ + for (i = expdiff; i < self->ob_size; i++) { + if (self->digits[i] > 0) + goto no_way; + } + /* All lost digits are 0. */ + new2 = _new_decimalobj(prec, new->sign, new->exp - expdiff); + if (!new2) { + Py_DECREF(new); + return NULL; + } + for (i = 0; i < new2->ob_size; i++) + new2->digits[i] = new->digits[i]; + Py_DECREF(new); + errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + if (!errres) { + Py_DECREF(new2); + return NULL; + } + Py_DECREF(errres); + return new2; + +no_way: + /* Now rounding starts. */ + rnd_func = round_funcs[rounding]; + + } /* Default values: rounding=-1 (use context), watchexp=1 */ @@ -257,9 +406,9 @@ _decimal_rescale(decimalobject *self, long exp, contextobject *ctx, int rounding, int watchexp) { - decimalobject *ans = NULL; + decimalobject *ans = NULL, *tmp, *tmp2; int ret; - long diff; + long diff, adj; Py_ssize_t digits, i; if (ISSPECIAL(self)) { @@ -276,7 +425,7 @@ if (!decimal_nonzero(self)) { ans = _new_decimalobj(1, self->sign, exp); - if (!ans) + if (!ans) return NULL; ans->digits[0] = 0; return ans; @@ -289,20 +438,54 @@ return context_raise_error(ctx, S_INV_OPERATION, "Rescale > prec", NULL); digits += 1; - ans = _new_decimalobj(self->ob_size+1, self->sign, self->exp); - if (!ans) - return NULL; - for (i = 0; i < self->ob_size; i++) - ans->digits[i+1] = self->digits[i]; - ans->digits[0] = 0; - if (digits < 0) { - ans->exp = -digits + ans->exp; - /* XXX: not complete... */ + ans = _new_decimalobj(2, self->sign, self->exp - digits); + if (!ans) + return NULL; + ans->digits[0] = 0; + ans->digits[1] = 1; + digits = 1; + } else { + ans = _new_decimalobj(self->ob_size+1, self->sign, self->exp); + if (!ans) + return NULL; + for (i = 0; i < self->ob_size; i++) + ans->digits[i+1] = self->digits[i]; + ans->digits[0] = 0; } - + tmp = _decimal_round(ans, digits, ctx, rounding); + Py_DECREF(ans); + if (!tmp) + return NULL; + if (tmp->digits[0] == 0 && tmp->ob_size > 1) { + tmp2 = _new_decimalobj(tmp->ob_size-1, tmp->sign, tmp->exp); + if (!tmp2) { + Py_DECREF(tmp); + return NULL; + } + for (i = 1; i < tmp->ob_size; i++) + tmp2->digits[i] = tmp->digits[i]; + Py_DECREF(tmp); + tmp = tmp2; + } + tmp->exp = exp; + + adj = ADJUSTED(tmp); + if (decimal_nonzero(tmp)) { + if (adj < ctx->Emin) { + ans = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + Py_DECREF(tmp); + return ans; + } else if (adj > ctx->Emax) { + ans = context_raise_error(ctx, S_INV_OPERATION, + "rescale(a, INF)", NULL); + Py_DECREF(tmp); + return ans; + } + } + return tmp; } /* Fix the exponents and return a copy with the exponents in bounds. @@ -443,35 +626,142 @@ { return NULL; } \ if (ctx == NULL) { \ if (!(ctx = getcontext())) return NULL; \ + } else if (!PyDecimalContext_Check(ctx)) { \ + PyErr_SetString(PyExc_TypeError, "context must be a Context object"); \ + return NULL; \ } STUB(compare) STUB(max) STUB(min) -static PyObject * +static decimalobject * decimal_normalize(decimalobject *self, PyObject *args, PyObject *kwds) { - decimalobject *dup; + decimalobject *dup, *new; contextobject *ctx = NULL; + Py_ssize_t end, i; + long exp; PARSECONTEXT("normalize"); if (ISSPECIAL(self)) { decimalobject *nan = NULL; int res; res = _check_nans(self, NULL, ctx, &nan); - /* if error set or NaN returned, return */ - if (res != 0) return (PyObject *)nan; + if (res != 0) return nan; /* can be NULL on error */ } dup = _decimal_fix(self, ctx); + if (ISINF(dup)) + return dup; + + if (!decimal_nonzero(dup)) { + new = _new_decimalobj(1, dup->sign, 0); + Py_DECREF(dup); + if (!new) return NULL; + new->digits[0] = 0; + return new; + } + + end = dup->ob_size; + exp = dup->exp; + while (dup->digits[end-1] == 0) { + end--; + exp++; + } + new = _new_decimalobj(end, dup->sign, exp); + if (!new) { + Py_DECREF(dup); + return NULL; + } + for (i = 0; i < end; i++) + new->digits[i] = dup->digits[i]; + Py_DECREF(dup); + return new; + +} - /* XXX: incomplete */ +static decimalobject * +decimal_quantize(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"exp", "rounding", "context", "watchexp", 0}; + contextobject *ctx = NULL; + decimalobject *other = NULL; + int rounding = -1, watchexp = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iOi:quantize", kwlist, + &other, &rounding, &ctx, &watchexp)) + return NULL; + + if (ctx == NULL) { + if (!(ctx = getcontext())) + return NULL; + } else if (!PyDecimalContext_Check(ctx)) { + PyErr_SetString(PyExc_TypeError, "context must be a Context object"); + return NULL; + } + if (!PyDecimal_Check(other)) { + PyErr_SetString(PyExc_TypeError, "exp must be a Decimal object"); + return NULL; + } + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan = NULL; + int res; + res = _check_nans(self, other, ctx, &nan); + if (res != 0) return nan; /* can be NULL on error */ + + if (ISINF(self) || ISINF(other)) { + if (ISINF(self) && ISINF(other)) { + Py_INCREF(self); + return self; + } + return context_raise_error(ctx, S_INV_OPERATION, + "quantize with one INF", NULL); + } + } + return _decimal_rescale(self, other->exp, ctx, rounding, watchexp); } -STUB(quantize) + STUB(remainder_near) -STUB(same_quantum) + +static PyObject * +decimal_same_quantum(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"other", 0}; + decimalobject *other = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:same_quantum", kwlist, + &other)) + return NULL; + + if (!PyDecimal_Check(other)) { + PyErr_SetString(PyExc_TypeError, "other must be a Decimal object"); + return NULL; + } + + if (ISSPECIAL(self) && ISSPECIAL(other)) { + if (GETNAN(self) || GETNAN(other)) { + if (GETNAN(self) && GETNAN(other)) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; + } + if (ISINF(self) || ISINF(other)) { + if (ISINF(self) && ISINF(other)) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; + } + } + + if (self->exp == other->exp) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + STUB(sqrt) STUB(to_eng_string) STUB(to_integral) @@ -695,7 +985,7 @@ char literalsign = 0, sign = 0; decimalobject *new; Py_ssize_t size = 0, i; - char *start, *p; + char *start = NULL, *p; if (len < 3) return NULL; @@ -908,7 +1198,7 @@ PyObject * PyDecimal_FromSequence(PyObject *seq) { - decimalobject *new; + decimalobject *new = NULL; PyObject *tup, *digits, *digtup = NULL, *item; int sign; long exp; @@ -1123,7 +1413,7 @@ tmp2 = PyTuple_New(0); if (!tmp2) return -1; - tmp = decimal_normalize(d, tmp2, NULL); + tmp = (PyObject *)decimal_normalize(d, tmp2, NULL); Py_DECREF(tmp2); if (!tmp) return -1; From python-checkins at python.org Tue May 23 12:01:04 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 12:01:04 +0200 (CEST) Subject: [Python-checkins] r46092 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523100104.5E00B1E4033@bag.python.org> Author: georg.brandl Date: Tue May 23 12:01:03 2006 New Revision: 46092 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Make getcontext() return a borrowed ref. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 12:01:03 2006 @@ -6,8 +6,6 @@ #include "structmember.h" #include "decimal.h" -/* XXX: getcontext() perhaps shouldn't INCREF the ctx */ - /* helpful macros ************************************************************/ #define MODULE_NAME "_decimal" @@ -397,7 +395,8 @@ no_way: /* Now rounding starts. */ rnd_func = round_funcs[rounding]; - + if (prec != ctx->prec) { + ctx = } @@ -1476,6 +1475,7 @@ #ifdef WITH_THREAD +/* Get the context for the current thread. This returns a borrowed reference. */ static contextobject * getcontext(void) { @@ -1503,11 +1503,11 @@ Py_DECREF(ctx); return NULL; } - /* clear the KeyError */ - PyErr_Clear(); + Py_DECREF(ctx); /* the dict now has a reference, see comment below */ return ctx; } - Py_INCREF(ctx); + /* ctx is NOT incref'd since that simplifies argument parsing + * in functions that either are passed a context or use the default */ return ctx; } @@ -1532,6 +1532,7 @@ static PyObject *current_context; +/* Get the global current context object. Returns a borrowed reference. */ static contextobject * getcontext() { @@ -1545,6 +1546,7 @@ if (!current_context) return NULL; } + /* no Py_INCREF here */ return (contextobject *)current_context; } @@ -2029,7 +2031,10 @@ static PyObject * module_getcontext(PyObject *self) { - return (PyObject *)getcontext(); + PyObject *ctx = (PyObject *)getcontext(); + /* getcontext() returned a borrowed reference */ + Py_XINCREF(ctx); + return ctx; } static PyObject * From python-checkins at python.org Tue May 23 12:07:22 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 12:07:22 +0200 (CEST) Subject: [Python-checkins] r46093 - python/branches/rjones-funccall/Misc/NEWS Message-ID: <20060523100722.73A2D1E4018@bag.python.org> Author: richard.jones Date: Tue May 23 12:07:22 2006 New Revision: 46093 Modified: python/branches/rjones-funccall/Misc/NEWS Log: add news Modified: python/branches/rjones-funccall/Misc/NEWS ============================================================================== --- python/branches/rjones-funccall/Misc/NEWS (original) +++ python/branches/rjones-funccall/Misc/NEWS Tue May 23 12:07:22 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Patch #876206: function call speedup by retaining allocated frame + objects. + - Bug #1462152: file() now checks more thoroughly for invalid mode strings and removes a possible "U" before passing the mode to the C library function. From python-checkins at python.org Tue May 23 12:10:57 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 23 May 2006 12:10:57 +0200 (CEST) Subject: [Python-checkins] r46094 - python/trunk/Include/unicodeobject.h Message-ID: <20060523101057.BE0971E4019@bag.python.org> Author: fredrik.lundh Date: Tue May 23 12:10:57 2006 New Revision: 46094 Modified: python/trunk/Include/unicodeobject.h Log: needforspeed: check first *and* last character before doing a full memcmp Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Tue May 23 12:10:57 2006 @@ -367,10 +367,12 @@ for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ } while (0) -#define Py_UNICODE_MATCH(string, offset, substring)\ - ((*((string)->str + (offset)) == *((substring)->str)) &&\ - !memcmp((string)->str + (offset), (substring)->str,\ - (substring)->length*sizeof(Py_UNICODE))) +/* check if substring matches at given offset. the offset must be + valid, and the substring must not be empty */ +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->str + (offset)) == *((substring)->str)) && \ + ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ + !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) #ifdef __cplusplus extern "C" { From python-checkins at python.org Tue May 23 12:12:22 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 23 May 2006 12:12:22 +0200 (CEST) Subject: [Python-checkins] r46095 - python/trunk/Objects/unicodeobject.c Message-ID: <20060523101222.07AF71E4018@bag.python.org> Author: fredrik.lundh Date: Tue May 23 12:12:21 2006 New Revision: 46095 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: fixed unicode "in" operator to use same implementation approach as find/index Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Tue May 23 12:12:21 2006 @@ -4982,54 +4982,56 @@ int PyUnicode_Contains(PyObject *container, PyObject *element) { - PyUnicodeObject *u = NULL, *v = NULL; + PyUnicodeObject *u, *v; int result; Py_ssize_t size; - register const Py_UNICODE *lhs, *end, *rhs; /* Coerce the two arguments */ - v = (PyUnicodeObject *)PyUnicode_FromObject(element); - if (v == NULL) { + v = (PyUnicodeObject *) PyUnicode_FromObject(element); + if (!v) { PyErr_SetString(PyExc_TypeError, "'in ' requires string as left operand"); - goto onError; + return -1; + } + + u = (PyUnicodeObject *) PyUnicode_FromObject(container); + if (!u) { + Py_DECREF(v); + return -1; } - u = (PyUnicodeObject *)PyUnicode_FromObject(container); - if (u == NULL) - goto onError; size = PyUnicode_GET_SIZE(v); - rhs = PyUnicode_AS_UNICODE(v); - lhs = PyUnicode_AS_UNICODE(u); + if (!size) { + result = 1; + goto done; + } result = 0; + if (size == 1) { - end = lhs + PyUnicode_GET_SIZE(u); - while (lhs < end) { - if (*lhs++ == *rhs) { - result = 1; - break; - } - } - } - else { - end = lhs + (PyUnicode_GET_SIZE(u) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size * sizeof(Py_UNICODE)) == 0) { + Py_UNICODE chr = PyUnicode_AS_UNICODE(v)[0]; + Py_UNICODE* ptr = PyUnicode_AS_UNICODE(u); + Py_UNICODE* end = ptr + PyUnicode_GET_SIZE(u); + for (; ptr < end; ptr++) { + if (*ptr == chr) { result = 1; break; } } + } else { + int start = 0; + int end = PyUnicode_GET_SIZE(u) - size; + for (; start <= end; start++) + if (Py_UNICODE_MATCH(u, start, v)) { + result = 1; + break; + } } +done: Py_DECREF(u); Py_DECREF(v); return result; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return -1; } /* Concat to string or Unicode object giving a new Unicode object. */ From fredrik at pythonware.com Tue May 23 12:34:23 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 23 May 2006 12:34:23 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <447219A2.4090201@egenix.com> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> Message-ID: M.-A. Lemburg wrote: >> "Need for speed" microbenchmarks for string processing > > Why don't you add these to pybench which is now part of Python > (see Tools/pybench/) ?! stringbench is designed to compare 8-bit and unicode implementations of the same operations, and to compare similar operations (e.g. in vs. find vs. index). the pybench output isn't really useful for this kind of benchmarking. (and pybench is also extremely unreliable if you look at individual tests; more about that later). From python-checkins at python.org Tue May 23 12:37:39 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 12:37:39 +0200 (CEST) Subject: [Python-checkins] r46096 - in python/trunk: Include/code.h Misc/NEWS Objects/codeobject.c Objects/frameobject.c Message-ID: <20060523103739.447D51E4018@bag.python.org> Author: richard.jones Date: Tue May 23 12:37:38 2006 New Revision: 46096 Modified: python/trunk/Include/code.h python/trunk/Misc/NEWS python/trunk/Objects/codeobject.c python/trunk/Objects/frameobject.c Log: Merge from rjones-funccall branch. Applied patch zombie-frames-2.diff from sf patch 876206 with updates for Python 2.5 and also modified to retain the free_list to avoid the 67% slow-down in pybench recursion test. 5% speed up in function call pybench. Modified: python/trunk/Include/code.h ============================================================================== --- python/trunk/Include/code.h (original) +++ python/trunk/Include/code.h Tue May 23 12:37:38 2006 @@ -24,6 +24,7 @@ PyObject *co_name; /* string (name, for reference) */ int co_firstlineno; /* first source line number */ PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ } PyCodeObject; /* Masks for co_flags above */ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 12:37:38 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Patch #876206: function call speedup by retaining allocated frame + objects. + - Bug #1462152: file() now checks more thoroughly for invalid mode strings and removes a possible "U" before passing the mode to the C library function. Modified: python/trunk/Objects/codeobject.c ============================================================================== --- python/trunk/Objects/codeobject.c (original) +++ python/trunk/Objects/codeobject.c Tue May 23 12:37:38 2006 @@ -102,6 +102,7 @@ co->co_firstlineno = firstlineno; Py_INCREF(lnotab); co->co_lnotab = lnotab; + co->co_zombieframe = NULL; } return co; } @@ -265,6 +266,8 @@ Py_XDECREF(co->co_filename); Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); + if (co->co_zombieframe != NULL) + PyObject_GC_Del(co->co_zombieframe); PyObject_DEL(co); } Modified: python/trunk/Objects/frameobject.c ============================================================================== --- python/trunk/Objects/frameobject.c (original) +++ python/trunk/Objects/frameobject.c Tue May 23 12:37:38 2006 @@ -350,10 +350,31 @@ }; /* Stack frames are allocated and deallocated at a considerable rate. - In an attempt to improve the speed of function calls, we maintain a - separate free list of stack frames (just like integers are - allocated in a special way -- see intobject.c). When a stack frame - is on the free list, only the following members have a meaning: + In an attempt to improve the speed of function calls, we: + + 1. Hold a single "zombie" frame on each code object. This retains + the allocated and initialised frame object from an invocation of + the code object. The zombie is reanimated the next time we need a + frame object for that code object. Doing this saves the malloc/ + realloc required when using a free_list frame that isn't the + correct size. It also saves some field initialisation. + + In zombie mode, no field of PyFrameObject holds a reference, but + the following fields are still valid: + + * ob_type, ob_size, f_code, f_valuestack, + f_nlocals, f_ncells, f_nfreevars, f_stacksize; + + * f_locals, f_trace, + f_exc_type, f_exc_value, f_exc_traceback are NULL; + + * f_localsplus does not require re-allocation and + the local variables in f_localsplus are NULL. + + 2. We also maintain a separate free list of stack frames (just like + integers are allocated in a special way -- see intobject.c). When + a stack frame is on the free list, only the following members have + a meaning: ob_type == &Frametype f_back next item on free list, or NULL f_nlocals number of locals @@ -380,41 +401,43 @@ static void frame_dealloc(PyFrameObject *f) { - int i, slots; - PyObject **fastlocals; - PyObject **p; + PyObject **p, **valuestack; + PyCodeObject *co; PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - Py_XDECREF(*fastlocals); - } + valuestack = f->f_valuestack; + for (p = f->f_localsplus; p < valuestack; p++) + Py_CLEAR(*p); /* Free stack */ if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) + for (p = valuestack; p < f->f_stacktop; p++) Py_XDECREF(*p); } Py_XDECREF(f->f_back); - Py_DECREF(f->f_code); Py_DECREF(f->f_builtins); Py_DECREF(f->f_globals); - Py_XDECREF(f->f_locals); - Py_XDECREF(f->f_trace); - Py_XDECREF(f->f_exc_type); - Py_XDECREF(f->f_exc_value); - Py_XDECREF(f->f_exc_traceback); - if (numfree < MAXFREELIST) { + Py_CLEAR(f->f_locals); + Py_CLEAR(f->f_trace); + Py_CLEAR(f->f_exc_type); + Py_CLEAR(f->f_exc_value); + Py_CLEAR(f->f_exc_traceback); + + co = f->f_code; + if (co != NULL && co->co_zombieframe == NULL) + co->co_zombieframe = f; + else if (numfree < MAXFREELIST) { ++numfree; f->f_back = free_list; free_list = f; - } - else + } + else PyObject_GC_Del(f); + + Py_XDECREF(co); Py_TRASHCAN_SAFE_END(f) } @@ -532,7 +555,7 @@ PyFrameObject *back = tstate->frame; PyFrameObject *f; PyObject *builtins; - Py_ssize_t extras, ncells, nfrees, i; + Py_ssize_t i; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || @@ -541,9 +564,6 @@ return NULL; } #endif - ncells = PyTuple_GET_SIZE(code->co_cellvars); - nfrees = PyTuple_GET_SIZE(code->co_freevars); - extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; if (back == NULL || back->f_globals != globals) { builtins = PyDict_GetItem(globals, builtin_object); if (builtins) { @@ -574,71 +594,86 @@ assert(builtins != NULL && PyDict_Check(builtins)); Py_INCREF(builtins); } - if (free_list == NULL) { - f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - else { - assert(numfree > 0); - --numfree; - f = free_list; - free_list = free_list->f_back; - if (f->ob_size < extras) { - f = PyObject_GC_Resize(PyFrameObject, f, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - _Py_NewReference((PyObject *)f); + if (code->co_zombieframe != NULL) { + f = code->co_zombieframe; + code->co_zombieframe = NULL; + _Py_NewReference((PyObject *)f); + assert(f->f_code == code); + } + else { + Py_ssize_t extras, ncells, nfrees; + ncells = PyTuple_GET_SIZE(code->co_cellvars); + nfrees = PyTuple_GET_SIZE(code->co_freevars); + extras = code->co_stacksize + code->co_nlocals + ncells + + nfrees; + if (free_list == NULL) { + f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, + extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + else { + assert(numfree > 0); + --numfree; + f = free_list; + free_list = free_list->f_back; + if (f->ob_size < extras) { + f = PyObject_GC_Resize(PyFrameObject, f, extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + _Py_NewReference((PyObject *)f); + } + + f->f_code = code; + f->f_nlocals = code->co_nlocals; + f->f_stacksize = code->co_stacksize; + f->f_ncells = ncells; + f->f_nfreevars = nfrees; + extras = f->f_nlocals + ncells + nfrees; + f->f_valuestack = f->f_localsplus + extras; + for (i=0; if_localsplus[i] = NULL; + f->f_locals = NULL; + f->f_trace = NULL; + f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; } f->f_builtins = builtins; Py_XINCREF(back); f->f_back = back; Py_INCREF(code); - f->f_code = code; Py_INCREF(globals); f->f_globals = globals; /* Most functions have CO_NEWLOCALS and CO_OPTIMIZED set. */ if ((code->co_flags & (CO_NEWLOCALS | CO_OPTIMIZED)) == (CO_NEWLOCALS | CO_OPTIMIZED)) - locals = NULL; /* PyFrame_FastToLocals() will set. */ + ; /* f_locals = NULL; will be set by PyFrame_FastToLocals() */ else if (code->co_flags & CO_NEWLOCALS) { locals = PyDict_New(); if (locals == NULL) { Py_DECREF(f); return NULL; } + f->f_locals = locals; } else { if (locals == NULL) locals = globals; Py_INCREF(locals); + f->f_locals = locals; } - f->f_locals = locals; - f->f_trace = NULL; - f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; f->f_tstate = tstate; f->f_lasti = -1; f->f_lineno = code->co_firstlineno; f->f_restricted = (builtins != tstate->interp->builtins); f->f_iblock = 0; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - - extras = f->f_nlocals + ncells + nfrees; - /* Tim said it's ok to replace memset */ - for (i=0; if_localsplus[i] = NULL; - f->f_valuestack = f->f_localsplus + extras; - f->f_stacktop = f->f_valuestack; + f->f_stacktop = f->f_valuestack; _PyObject_GC_TRACK(f); return f; } From python-checkins at python.org Tue May 23 12:48:47 2006 From: python-checkins at python.org (andrew.dalke) Date: Tue, 23 May 2006 12:48:47 +0200 (CEST) Subject: [Python-checkins] r46097 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060523104847.1053B1E4018@bag.python.org> Author: andrew.dalke Date: Tue May 23 12:48:46 2006 New Revision: 46097 Modified: sandbox/trunk/stringbench/stringbench.py Log: Added new tests. Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Tue May 23 12:48:46 2006 @@ -1,4 +1,6 @@ +# Various microbenchmarks comparing unicode and byte string performance + import timeit import itertools import operator @@ -18,25 +20,25 @@ _RANGE_1000 = range(1000) _RANGE_100 = range(100) -def bench(s="", group=1): +def bench(s, group, repeat_count): def blah(f): f.comment = s f.is_bench = True f.group = group + f.repeat_count = repeat_count return f return blah ####### 'in' comparisons - - at bench('"A" in "A"*1000', group="early match, single character") + at bench('"A" in "A"*1000', "early match, single character", 1000) def in_test_quick_match_single_character(STR): s1 = STR("A" * 1000) s2 = STR("A") for x in _RANGE_1000: s2 in s1 - at bench('"B" in "A"*1000', group="no match, single character") + at bench('"B" in "A"*1000', "no match, single character", 1000) def in_test_no_match_single_character(STR): s1 = STR("A" * 1000) s2 = STR("B") @@ -44,21 +46,21 @@ s2 in s1 - at bench('"AB" in "AB"*1000', group="early match, two characters") + at bench('"AB" in "AB"*1000', "early match, two characters", 1000) def in_test_quick_match_two_characters(STR): s1 = STR("AB" * 1000) s2 = STR("AB") for x in _RANGE_1000: s2 in s1 - at bench('"BC" in "AB"*1000', group="no match, two characters") + at bench('"BC" in "AB"*1000', "no match, two characters", 1000) def in_test_no_match_two_character(STR): s1 = STR("AB" * 1000) s2 = STR("BC") for x in _RANGE_1000: s2 in s1 - at bench('"BC" in ("AB"*1000+"C")', group="late match, two characters") + at bench('"BC" in ("AB"*1000+"C")', "late match, two characters", 1000) def in_test_slow_match_two_characters(STR): s1 = STR("AB" * 1000+"C") s2 = STR("BC") @@ -66,7 +68,7 @@ s2 in s1 @bench('s="ABC"*33; s in ((s+"D")*500+s+"E")', - group="late match, 100 characters") + "late match, 100 characters", 100) def in_test_slow_match_100_characters(STR): m = STR("ABC"*33) s1 = (m+"D")*500 + m+"E" @@ -76,7 +78,7 @@ # Try with regex @bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*500+s+"E")', - group="late match, 100 characters") + "late match, 100 characters", 100) def re_test_slow_match_100_characters(STR): m = STR("ABC"*33) s1 = (m+"D")*500 + m+"E" @@ -85,11 +87,15 @@ search = pat.search for x in _RANGE_100: search(s1) - + #### same tests as 'in' but use 'find' - at bench('("A"*1000).find("A")', group="early match, single character") +# Add rfind + + + + at bench('("A"*1000).find("A")', "early match, single character", 1000) def find_quick_match_single_character(STR): s1 = STR("A" * 1000) s2 = STR("A") @@ -97,7 +103,7 @@ for x in _RANGE_1000: s1_find(s2) - at bench('("A"*1000).find("B")', group="no match, single character") + at bench('("A"*1000).find("B")', "no match, single character", 1000) def find_test_no_match_single_character(STR): s1 = STR("A" * 1000) s2 = STR("B") @@ -106,7 +112,7 @@ s1_find(s2) - at bench('("AB"*1000).find("AB")', group="early match, two characters") + at bench('("AB"*1000).find("AB")', "early match, two characters", 1000) def find_test_quick_match_two_characters(STR): s1 = STR("AB" * 1000) s2 = STR("AB") @@ -114,7 +120,7 @@ for x in _RANGE_1000: s1_find(s2) - at bench('("AB"*1000).find("BC")', group="no match, two characters") + at bench('("AB"*1000).find("BC")', "no match, two characters", 1000) def find_test_no_match_two_character(STR): s1 = STR("AB" * 1000) s2 = STR("BC") @@ -122,7 +128,7 @@ for x in _RANGE_1000: s1_find(s2) - at bench('("AB"*1000+"C").find("BC")', group="late match, two characters") + at bench('"BC" in ("AB"*1000+"C")', "late match, two characters", 1000) def find_test_slow_match_two_characters(STR): s1 = STR("AB" * 1000+"C") s2 = STR("BC") @@ -131,7 +137,7 @@ s1_find(s2) @bench('s="ABC"*33; ((s+"D")*500+s+"E").find(s)', - group="late match, 100 characters") + "late match, 100 characters", 100) def find_test_slow_match_100_characters(STR): m = STR("ABC"*33) s1 = (m+"D")*500 + m+"E" @@ -141,10 +147,11 @@ s1_find(s2) #### Now with index. -# Skip the ones which fail because the +# Skip the ones which fail because that would include exception overhead. +# Add rindex tests. - - at bench('("A"*1000).index("A")', group="early match, single character") + + at bench('("A"*1000).index("A")', "early match, single character", 1000) def index_test_quick_match_single_character(STR): s1 = STR("A" * 1000) s2 = STR("A") @@ -153,7 +160,7 @@ s1_index(s2) - at bench('("AB"*1000).index("AB")', group="early match, two characters") + at bench('("AB"*1000).index("AB")', "early match, two characters", 1000) def index_test_quick_match_two_characters(STR): s1 = STR("AB" * 1000) s2 = STR("AB") @@ -161,7 +168,7 @@ for x in _RANGE_1000: s1_index(s2) - at bench('("AB"*1000+"C").index("BC")', group="late match, two characters") + at bench('("AB"*1000+"C").index("BC")', "late match, two characters", 1000) def index_test_slow_match_two_characters(STR): s1 = STR("AB" * 1000+"C") s2 = STR("BC") @@ -170,7 +177,7 @@ s1_index(s2) @bench('s="ABC"*33; ((s+"D")*500+s+"E").index(s)', - group="late match, 100 characters") + "late match, 100 characters", 100) def index_test_slow_match_100_characters(STR): m = STR("ABC"*33) s1 = (m+"D")*500 + m+"E" @@ -181,40 +188,41 @@ #### Benchmark the operator-based methods - at bench('"A"*10', "repeat 1 character 10 times") + at bench('"A"*10', "repeat 1 character 10 times", 1000) def repeat_single_10_times(STR): s = STR("A") for x in _RANGE_1000: s * 10 - at bench('"A"*1000', "repeat 1 character 1000 times") + at bench('"A"*1000', "repeat 1 character 1000 times", 1000) def repeat_single_1000_times(STR): s = STR("A") for x in _RANGE_1000: s * 1000 - at bench('"ABCDE"*10', "repeat 5 characters 10 times") + at bench('"ABCDE"*10', "repeat 5 characters 10 times", 1000) def repeat_5_10_times(STR): s = STR("ABCDE") for x in _RANGE_1000: s * 10 - at bench('"ABCDE"*1000', "repeat 5 characters 1000 times") + at bench('"ABCDE"*1000', "repeat 5 characters 1000 times", 1000) def repeat_5_1000_times(STR): s = STR("ABCDE") for x in _RANGE_1000: s * 1000 - + # + for concat - at bench('"Andrew"+"Dalke"', "concat two strings") + at bench('"Andrew"+"Dalke"', "concat two strings", 1000) def concat_two_strings(STR): s1 = STR("Andrew") s2 = STR("Dalke") for x in _RANGE_1000: s1+s2 - at bench('s1+s2+s3+s4+...+s20', "concat 20 strings of words length 4 to 15") + at bench('s1+s2+s3+s4+...+s20', "concat 20 strings of words length 4 to 15", + 1000) def concat_two_strings(STR): s1=STR('TIXSGYNREDCVBHJ') s2=STR('PUMTLXBZVDO') @@ -244,7 +252,7 @@ #### Benchmark join @bench('"A".join("")', - "join empty string, with 1 character sep") + "join empty string, with 1 character sep", 1000) def join_empty_single(STR): sep = STR("A") s2 = STR("") @@ -253,7 +261,7 @@ sep_join(s2) @bench('"ABCDE".join("")', - "join empty string, with 5 character sep") + "join empty string, with 5 character sep", 1000) def join_empty_5(STR): sep = STR("ABCDE") s2 = STR("") @@ -262,7 +270,7 @@ sep_join(s2) @bench('"A".join("ABC..Z")', - "join string with 26 characters, with 1 character sep") + "join string with 26 characters, with 1 character sep", 1000) def join_alphabet_single(STR): sep = STR("A") s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") @@ -271,7 +279,7 @@ sep_join(s2) @bench('"ABCDE".join("ABC..Z")', - "join string with 26 characters, with 5 character sep") + "join string with 26 characters, with 5 character sep", 1000) def join_alphabet_5(STR): sep = STR("ABCDE") s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") @@ -280,7 +288,7 @@ sep_join(s2) @bench('"A".join(list("ABC..Z"))', - "join list of 26 characters, with 1 character sep") + "join list of 26 characters, with 1 character sep", 1000) def join_alphabet_list_single(STR): sep = STR("A") s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) @@ -289,7 +297,7 @@ sep_join(s2) @bench('"ABCDE".join(list("ABC..Z"))', - "join list of 26 characters, with 5 character sep") + "join list of 26 characters, with 5 character sep", 1000) def join_alphabet_list_five(STR): sep = STR("ABCDE") s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) @@ -298,7 +306,7 @@ sep_join(s2) @bench('"A".join(["Bob"]*1000))', - "join list of 1000 words, with 1 character sep") + "join list of 1000 words, with 1 character sep", 1000) def join_1000_words_single(STR): sep = STR("A") s2 = [STR("Bob")]*1000 @@ -307,7 +315,7 @@ sep_join(s2) @bench('"ABCDE".join(["Bob"]*1000))', - "join list of 1000 words, with 5 character sep") + "join list of 1000 words, with 5 character sep", 1000) def join_1000_words_5(STR): sep = STR("ABCDE") s2 = [STR("Bob")]*1000 @@ -317,21 +325,21 @@ #### split tests - at bench('"this\\nis\\na\\ntest\\n".split("\\n")', "split newlines") + at bench('"this\\nis\\na\\ntest\\n".split("\\n")', "split newlines", 1000) def newlines_split(STR): s = STR("this\nis\na\ntest\n") s_split = s.split for x in _RANGE_1000: s_split("\n") - - at bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines") + + at bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines", 1000) def newlines_rsplit(STR): s = STR("this\nis\na\ntest\n") s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\n") - - at bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines") + + at bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines", 1000) def newlines_splitlines(STR): s = STR("this\nis\na\ntest\n") s_splitlines = s.splitlines @@ -339,7 +347,7 @@ s_splitlines() ## split text with 2000 newlines - + def _make_2000_lines(): import random r = random.Random(100) @@ -360,23 +368,23 @@ if STR is str: return _text_with_2000_lines raise AssertionError + - - at bench('"...text...".split("\\n")', "split 2000 newlines") + at bench('"...text...".split("\\n")', "split 2000 newlines", 100) def newlines_split_2000(STR): s = _get_2000_lines(STR) s_split = s.split for x in _RANGE_100: s_split("\n") - - at bench('"...text...".rsplit("\\n")', "split 2000 newlines") + + at bench('"...text...".rsplit("\\n")', "split 2000 newlines", 100) def newlines_rsplit_2000(STR): s = _get_2000_lines(STR) s_rsplit = s.rsplit for x in _RANGE_100: s_rsplit("\n") - - at bench('"...text...".splitlines()', "split 2000 newlines") + + at bench('"...text...".splitlines()', "split 2000 newlines", 100) def newlines_splitlines_2000(STR): s = _get_2000_lines(STR) s_splitlines = s.splitlines @@ -387,7 +395,7 @@ ## split text on "--" characters @bench( '"this--is--a--test--of--the--emergency--broadcast--system".split("--")', - "split on multicharacter seperator") + "split on multicharacter seperator", 1000) def split_multichar_sep(STR): s = STR("this--is--a--test--of--the--emergency--broadcast--system") s_split = s.split @@ -395,7 +403,7 @@ s_split("--") @bench( '"this--is--a--test--of--the--emergency--broadcast--system".rsplit("--")', - "split on multicharacter seperator") + "split on multicharacter seperator", 1000) def rsplit_multichar_sep(STR): s = STR("this--is--a--test--of--the--emergency--broadcast--system") s_rsplit = s.rsplit @@ -408,28 +416,28 @@ "I", "Genomic_canonical", "region", "357208", "396183", ".", "+", ".", "ID=Sequence:R119;note=Clone R119%3B Genbank AF063007;Name=R119"]) - at bench('GFF3_example.split("\\t")', "tab split") + at bench('GFF3_example.split("\\t")', "tab split", 1000) def tab_split_no_limit(STR): s = STR(GFF3_example) s_split = s.split for x in _RANGE_1000: s_split("\t") - - at bench('GFF3_example.split("\\t", 8)', "tab split") + + at bench('GFF3_example.split("\\t", 8)', "tab split", 1000) def tab_split_limit(STR): s = STR(GFF3_example) s_split = s.split for x in _RANGE_1000: s_split("\t", 8) - - at bench('GFF3_example.rsplit("\\t")', "tab split") + + at bench('GFF3_example.rsplit("\\t")', "tab split", 1000) def tab_rsplit_no_limit(STR): s = STR(GFF3_example) s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\t") - - at bench('GFF3_example.rsplit("\\t", 8)', "tab split") + + at bench('GFF3_example.rsplit("\\t", 8)', "tab split", 1000) def tab_rsplit_limit(STR): s = STR(GFF3_example) s_rsplit = s.rsplit @@ -439,7 +447,7 @@ #### Count characters @bench('...text.with.2000.newlines.count("\\n")', - "count newlines") + "count newlines", 100) def count_newlines(STR): s = _get_2000_lines(STR) s_count = s.count @@ -503,21 +511,23 @@ _dna = _dna * 50 _dna_unicode = unicode(_dna) - at bench('dna.count("AACT")', "count AACT substrings in DNA example") -def count_aact(STR): +def _get_dna(STR): if STR is unicode: - seq = _dna_unicode - elif STR is str: - seq = _dna - else: - raise AssertionError + return _dna_unicode + if STR is str: + return _dna + raise AssertionError + + at bench('dna.count("AACT")', "count AACT substrings in DNA example", 100) +def count_aact(STR): + seq = _get_dna(STR) seq_count = seq.count for x in _RANGE_100: seq_count("AACT") ##### startswith and endswith - at bench('"Andrew".startswith("A")', 'startswith single character') + at bench('"Andrew".startswith("A")', 'startswith single character', 1000) def startswith_single(STR): s1 = STR("Andrew") s2 = STR("A") @@ -525,7 +535,8 @@ for x in _RANGE_1000: s1_startswith(s2) - at bench('"Andrew".startswith("Andrew")', 'startswith multiple characters') + at bench('"Andrew".startswith("Andrew")', 'startswith multiple characters', + 1000) def startswith_multiple(STR): s1 = STR("Andrew") s2 = STR("Andrew") @@ -534,7 +545,7 @@ s1_startswith(s2) @bench('"Andrew".startswith("Anders")', - 'startswith multiple characters - not!') + 'startswith multiple characters - not!', 1000) def startswith_multiple_not(STR): s1 = STR("Andrew") s2 = STR("Anders") @@ -545,7 +556,7 @@ # endswith - at bench('"Andrew".endswith("w")', 'endswith single character') + at bench('"Andrew".endswith("w")', 'endswith single character', 1000) def endswith_single(STR): s1 = STR("Andrew") s2 = STR("w") @@ -553,7 +564,7 @@ for x in _RANGE_1000: s1_endswith(s2) - at bench('"Andrew".endswith("Andrew")', 'endswith multiple characters') + at bench('"Andrew".endswith("Andrew")', 'endswith multiple characters', 1000) def endswith_multiple(STR): s1 = STR("Andrew") s2 = STR("Andrew") @@ -562,7 +573,7 @@ s1_endswith(s2) @bench('"Andrew".endswith("Anders")', - 'endswith multiple characters - not!') + 'endswith multiple characters - not!', 1000) def endswith_multiple_not(STR): s1 = STR("Andrew") s2 = STR("Anders") @@ -572,22 +583,43 @@ #### Strip - at bench('"Hello!\\n".strip()', 'strip terminal newline') -def terminal_newline_strip(STR): + at bench('"Hello!\\n".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_right(STR): s = STR("Hello!\n") s_strip = s.strip for x in _RANGE_1000: s_strip() - at bench('"Hello!\\n".rstrip()', 'strip terminal newline') + at bench('"Hello!\\n".rstrip()', 'strip terminal newline', 1000) def terminal_newline_rstrip(STR): s = STR("Hello!\n") s_rstrip = s.rstrip for x in _RANGE_1000: s_rstrip() + at bench('"\\nHello!".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_left(STR): + s = STR("\nHello!") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"\\nHello!\\n".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_both(STR): + s = STR("\nHello!\n") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"\\nHello!".rstrip()', 'strip terminal newline', 1000) +def terminal_newline_lstrip(STR): + s = STR("\nHello!") + s_lstrip = s.lstrip + for x in _RANGE_1000: + s_lstrip() + @bench('s="Hello!\\n"; s[:-1] if s[-1]=="\\n" else s', - 'strip terminal newline') + 'strip terminal newline', 1000) def terminal_newline_if_else(STR): s = STR("Hello!\n") NL = STR("\n") @@ -595,14 +627,116 @@ s[:-1] if (s[-1] == NL) else s +# Strip multiple spaces or tabs + + at bench('"Hello\\t \\t".strip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_strip(STR): + s = STR("Hello\t \t!") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"Hello\\t \\t".rstrip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_rstrip(STR): + s = STR("Hello!\t \t") + s_rstrip = s.rstrip + for x in _RANGE_1000: + s_rstrip() + + at bench('"\\t \\tHello".rstrip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_lstrip(STR): + s = STR("\t \tHello!") + s_lstrip = s.lstrip + for x in _RANGE_1000: + s_lstrip() + + +#### replace + at bench('"This is a test".replace(" ", "\\t")', 'replace single character', + 1000) +def replace_single_character(STR): + s = STR("This is a test!") + from_str = STR(" ") + to_str = STR("\t") + s_replace = s.replace + for x in _RANGE_1000: + s_replace(from_str, to_str) + + at bench('re.sub(" ", "\\t", "This is a test"', 'replace single character', + 1000) +def replace_single_character_re(STR): + s = STR("This is a test!") + pat = re.compile(STR(" ")) + to_str = STR("\t") + pat_sub = pat.sub + for x in _RANGE_1000: + pat_sub(to_str, s) + + at bench('"...text.with.2000.lines...replace("\\n", " ")', + 'replace single character, big string', 100) +def replace_single_character_big(STR): + s = _get_2000_lines(STR) + from_str = STR("\n") + to_str = STR(" ") + s_replace = s.replace + for x in _RANGE_100: + s_replace(from_str, to_str) + + at bench('re.sub("\\n", " ", "...text.with.2000.lines...")', + 'replace single character, big string', 100) +def replace_single_character_big_re(STR): + s = _get_2000_lines(STR) + pat = re.compile(STR("\n")) + to_str = STR(" ") + pat_sub = pat.sub + for x in _RANGE_100: + pat_sub(to_str, s) + + + at bench('dna.replace("ATC", "ATT")', + 'replace multiple characters, dna', 100) +def replace_multiple_characters_dna(STR): + seq = _get_dna(STR) + from_str = STR("ATC") + to_str = STR("ATT") + seq_replace = seq.replace + for x in _RANGE_100: + seq_replace(from_str, to_str) -# strip -# lstrip -# rstrip -# replace +# This changes the total number of character + at bench('"...text.with.2000.newlines.', + 'replace multiple characters, big string', 100) +def replace_multiple_character_big(STR): + s = _get_2000_lines(STR) + from_str = STR("\n") + to_str = STR("\r\n") + s_replace = s.replace + for x in _RANGE_100: + s_replace(from_str, to_str) + +# This increases the character count + at bench('"...text.with.2000.newlines...replace("\\n", "\\r\\n")', + 'replace multiple characters, big string', 100) +def replace_multiple_character_big(STR): + s = _get_2000_lines(STR) + from_str = STR("\n") + to_str = STR("\r\n") + s_replace = s.replace + for x in _RANGE_100: + s_replace(from_str, to_str) + + +# This decreases the character count + at bench('"When shall we three meet again?".replace("ee", "")', + 'replace/remove multiple characters', 1000) +def replace_multiple_character_remove(STR): + s = STR("When shall we three meet again?") + from_str = STR("ee") + to_str = STR("") + s_replace = s.replace + for x in _RANGE_1000: + s_replace(from_str, to_str) -# rfind -# rindex # end of benchmarks @@ -627,7 +761,7 @@ def main(): test_names = sys.argv[1:] - + bench_functions = [] for (k,v) in globals().items(): if hasattr(v, "is_bench"): @@ -644,7 +778,7 @@ print "string\tunicode" print "(in ms)\t(in ms)\t%\tcomment" - str_total = uni_total = 0 + str_total = uni_total = 0.0 for title, group in itertools.groupby(bench_functions, operator.itemgetter(0)): @@ -655,9 +789,10 @@ "import __main__").best(REPEAT) uni_time = BenchTimer("__main__.%s(unicode)" % (k,), "import __main__").best(REPEAT) - print "%.2f\t%.2f\t%.1f\t%s" % ( + print "%.2f\t%.2f\t%.1f\t%s (*%d)" % ( 1000*str_time, 1000*uni_time, 100.*str_time/uni_time, - v.comment) + v.comment, v.repeat_count) + str_total += str_time uni_total += uni_time @@ -665,7 +800,6 @@ 1000*str_total, 1000*uni_total, 100.*str_total/uni_total, "TOTAL") - if __name__ == "__main__": main() - + From mal at egenix.com Tue May 23 12:53:32 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 23 May 2006 12:53:32 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> Message-ID: <4472E9AC.2000805@egenix.com> Fredrik Lundh wrote: > M.-A. Lemburg wrote: > >>> "Need for speed" microbenchmarks for string processing >> Why don't you add these to pybench which is now part of Python >> (see Tools/pybench/) ?! > > stringbench is designed to compare 8-bit and unicode > implementations of the same operations, and to compare > similar operations (e.g. in vs. find vs. index). > > the pybench output isn't really useful for this kind of > benchmarking. Why not ? pybench is designed to compare things on a low-level basis. It's easy to write tests that execute everything on string and then do the same on Unicode, in fact Strings.py and Unicode.py do just that. If you compare what you've written in stringbench.py to what's in Strings.py and Unicode.py you'll find quite a few similarities. But hey, this was just a suggestion since pybench already provides a complete framework for micro-benchmarks, including side-by-side comparisons between different runs. > (and pybench is also extremely unreliable if you look at > individual tests; more about that later). Hmm, awaiting your evidence ;-) For me, pybench has proven to be very reliable and was specifically designed to allow comparisons based on individual tests rather than some abstract benchmark figure like pystone and many other benchmark tests provide. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 23 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2006-07-03: EuroPython 2006, CERN, Switzerland 40 days left ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From fredrik at pythonware.com Tue May 23 13:00:49 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 23 May 2006 13:00:49 +0200 Subject: [Python-checkins] r46083 - sandbox/trunk/stringbench sandbox/trunk/stringbench/stringbench.py In-Reply-To: <4472E9AC.2000805@egenix.com> References: <20060522183817.DDD4A1E4007@bag.python.org> <447219A2.4090201@egenix.com> <4472E9AC.2000805@egenix.com> Message-ID: M.-A. Lemburg wrote: >> (and pybench is also extremely unreliable if you look at >> individual tests; more about that later). > > Hmm, awaiting your evidence ;-) the current case is a portion of the pybench unicode bench- mark, where pybench reports a massive slowdown for a portion of the library that hasn't really changed, and timeit reports stable timings for *exactly* the same piece code: before, according to timeit: 140 ms after, according to timeit: 139 ms slowdown, according to pybench: 62% whatever pybench is measuring in this case, it's not measuring the speed of the actual operation... we're looking into this as we speak. From buildbot at python.org Tue May 23 13:01:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 11:01:21 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060523110121.935341E4018@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/438 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 13:04:25 2006 From: python-checkins at python.org (ronald.oussoren) Date: Tue, 23 May 2006 13:04:25 +0200 (CEST) Subject: [Python-checkins] r46098 - python/trunk/Mac/OSX/Makefile.in Message-ID: <20060523110425.3D18C1E4018@bag.python.org> Author: ronald.oussoren Date: Tue May 23 13:04:24 2006 New Revision: 46098 Modified: python/trunk/Mac/OSX/Makefile.in Log: Avoid creating a mess when installing a framework for the second time. Modified: python/trunk/Mac/OSX/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/Makefile.in (original) +++ python/trunk/Mac/OSX/Makefile.in Tue May 23 13:04:24 2006 @@ -73,11 +73,16 @@ install_versionedtools: for fn in idle pydoc python-config ;\ do \ + if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \ + continue ;\ + fi ;\ mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\ done - mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" - ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" + if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \ + mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\ + ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\ + fi pythonw: $(srcdir)/Tools/pythonw.c From python-checkins at python.org Tue May 23 13:04:47 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 13:04:47 +0200 (CEST) Subject: [Python-checkins] r46099 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523110447.1B8701E4018@bag.python.org> Author: georg.brandl Date: Tue May 23 13:04:46 2006 New Revision: 46099 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Status update. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 13:04:46 2006 @@ -1,4 +1,6 @@ /* C implementation of the decimal module. + * + * Partly written in Iceland by Georg Brandl. */ #include "Python.h" @@ -245,18 +247,70 @@ } static decimalobject * +_decimal_increment(decimalobject *self, long prec, contextobject *ctx) +{ +} + +/* Round towards 0, that is, truncate digits. */ +static decimalobject * _round_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + Py_ssize_t i; + decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); + if (!new) return NULL; + for (i = 0; i < prec; i++) + new->digits[i] = self->digits[i]; + return new; } +/* Round away from 0. */ static decimalobject * _round_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + Py_ssize_t i; + decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); + decimalobject *new2; + if (!new) return NULL; + for (i = 0; i < prec; i++) + new->digits[i] = self->digits[i]; + if (!new) return NULL; + for (i = prec; i < self->ob_size; i++) + if (self->digits[i] > 0) { + new2 = _decimal_increment(new, 1, ctx); + Py_DECREF(new); + if (!new2) + return NULL; + if (new2->ob_size > prec) { + new2->ob_size--; + new2->exp++; + } + return new2; + } + return new2; +} + +/* Actually round half up. Returns a new reference, either on tmp + * or a new decimalobject. */ +static decimalobject * +_do_round_half_up(decimalobject *self, long prec, long expdiff, + contextobject *ctx, decimalobject *tmp) +{ + Py_ssize_t i; + if (!tmp) { + tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + if (!tmp) return NULL; + for (i = 0; i < prec; i++) + tmp->digits[i] = self->digits[i]; + } + /*if (self->ob_size > prec && self->digits[prec] >= 5) {*/ + } +/* Round 5 down. */ static decimalobject * _round_half_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + } static decimalobject * @@ -264,9 +318,11 @@ { } +/* Round 5 up (away from 0). */ static decimalobject * _round_half_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + return _do_round_half_up(self, prec, expdiff, ctx, NULL); } static decimalobject * @@ -277,6 +333,7 @@ static decimalobject * _round_ceiling(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + } typedef decimalobject*(*round_func)(decimalobject *, long, long, contextobject *); @@ -289,7 +346,8 @@ static decimalobject * _decimal_round(decimalobject *self, long prec, contextobject *ctx, int rounding) { - decimalobject *new, *new2, *errres; + decimalobject *new, *new2 = NULL, *errres; + contextobject *ctx2 = NULL; Py_ssize_t i, expdiff; round_func rnd_func; @@ -375,29 +433,48 @@ if (self->digits[i] > 0) goto no_way; } - /* All lost digits are 0. */ - new2 = _new_decimalobj(prec, new->sign, new->exp - expdiff); - if (!new2) { - Py_DECREF(new); - return NULL; - } - for (i = 0; i < new2->ob_size; i++) - new2->digits[i] = new->digits[i]; - Py_DECREF(new); + /* All lost digits are 0, so just clobber new */ + new->ob_size = prec; + new->exp -= expdiff; errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); if (!errres) { - Py_DECREF(new2); + Py_DECREF(new); return NULL; } Py_DECREF(errres); - return new2; + return new; no_way: - /* Now rounding starts. */ + /* Now rounding starts. We still own "new". */ rnd_func = round_funcs[rounding]; if (prec != ctx->prec) { - ctx = + ctx2 = _context_shallow_copy(ctx); + if (!ctx2) { + Py_DECREF(new); + return NULL; + } + ctx2->prec = prec; + ctx = ctx2; + } + /* ctx2 is NULL if the original context is used, and that one + * doesn't have to be DECREF'd. */ + new2 = rnd_func(new, prec, expdiff, ctx); + Py_DECREF(new); + if (!new2) + goto error; + errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + if (!errres) + goto error; + errres = context_raise_error(ctx, S_INEXACT, "Changed in rounding", NULL); + if (!errres) + goto error; + Py_XDECREF(ctx2); + return new2; +error: + Py_XDECREF(ctx2); + Py_XDECREF(new2); + return NULL; } /* Default values: rounding=-1 (use context), watchexp=1 */ @@ -459,15 +536,10 @@ return NULL; if (tmp->digits[0] == 0 && tmp->ob_size > 1) { - tmp2 = _new_decimalobj(tmp->ob_size-1, tmp->sign, tmp->exp); - if (!tmp2) { - Py_DECREF(tmp); - return NULL; - } - for (i = 1; i < tmp->ob_size; i++) - tmp2->digits[i] = tmp->digits[i]; - Py_DECREF(tmp); - tmp = tmp2; + /* We need one digit less, just clobber tmp. */ + for (i = 0; i < tmp->ob_size-1; i++) + tmp->digits[i] = tmp->digits[i+1]; + tmp->ob_size--; } tmp->exp = exp; @@ -634,13 +706,12 @@ STUB(max) STUB(min) +/* strip trailing 0s, change anything equal to 0 to 0e0 */ static decimalobject * decimal_normalize(decimalobject *self, PyObject *args, PyObject *kwds) { decimalobject *dup, *new; contextobject *ctx = NULL; - Py_ssize_t end, i; - long exp; PARSECONTEXT("normalize"); if (ISSPECIAL(self)) { @@ -661,25 +732,16 @@ new->digits[0] = 0; return new; } - - end = dup->ob_size; - exp = dup->exp; - while (dup->digits[end-1] == 0) { - end--; - exp++; - } - new = _new_decimalobj(end, dup->sign, exp); - if (!new) { - Py_DECREF(dup); - return NULL; - } - for (i = 0; i < end; i++) - new->digits[i] = dup->digits[i]; - Py_DECREF(dup); - return new; + /* strip trailing 0s from dup */ + while (dup->digits[dup->ob_size - 1] == 0) { + dup->ob_size--; + dup->exp++; + } + return dup; } +/* Quantize self so that its exponent is the same as the exponent of another. */ static decimalobject * decimal_quantize(decimalobject *self, PyObject *args, PyObject *kwds) { From buildbot at python.org Tue May 23 13:06:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 11:06:02 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060523110602.B3B4F1E40FF@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/742 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: richard.jones Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 13:07:09 2006 From: python-checkins at python.org (andrew.dalke) Date: Tue, 23 May 2006 13:07:09 +0200 (CEST) Subject: [Python-checkins] r46100 - sandbox/trunk/stringbench/README Message-ID: <20060523110709.D36D41E4018@bag.python.org> Author: andrew.dalke Date: Tue May 23 13:07:09 2006 New Revision: 46100 Added: sandbox/trunk/stringbench/README Log: Info about this benchmark Added: sandbox/trunk/stringbench/README ============================================================================== --- (empty file) +++ sandbox/trunk/stringbench/README Tue May 23 13:07:09 2006 @@ -0,0 +1,67 @@ +stringbench is a set of performance tests comparing byte string +operations with unicode operations. The two string implementations +are loosely based on each other and sometimes the algorithm for one is +faster than the other. + +These test set was started at the Need For Speed sprint in Reykjavik +to identify which string methods could be sped up quickly and to +identify obvious places for improvement. + +Here is an example of a benchmark + + + at bench('"Andrew".startswith("A")', 'startswith single character', 1000) +def startswith_single(STR): + s1 = STR("Andrew") + s2 = STR("A") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + +The bench decorator takes three parameters. The first is a short +description of how the code works. In most cases this is Python code +snippet. It is not the code which is actually run because the real +code is hand-optimized to focus on the method being tested. + +The second parameter is a group title. All benchmarks with the same +group title are listed together. This lets you compare different +implementations of the same algorithm, such as "t in s" +vs. "s.find(t)". + +The last is a count. Each benchmark loops over the algorithm either +100 or 1000 times, depending on the algorithm performance. The output +time is the time per benchmark call so the reader needs a way to know +how to scale the performance. + +These parameters become function attributes. + + +Here is an example of the output + + +========== count newlines +38.54 41.60 92.7 ...text.with.2000.newlines.count("\n") (*100) +========== early match, single character +1.14 1.18 96.8 ("A"*1000).find("A") (*1000) +0.44 0.41 105.6 "A" in "A"*1000 (*1000) +1.15 1.17 98.1 ("A"*1000).index("A") (*1000) + +The first column is the run time in milliseconds for byte strings. +The second is the run time for unicode strings. The third is a +percentage; byte time / unicode time. It's the percentage by which +unicode is faster than byte strings. + +The last column contains the code snippet and the repeat count for the +internal benchmark loop. + +The times are computed with 'timeit.py' which repeats the test more +and more times until the total time takes over 0.2 seconds, returning +the best time for a single iteration. + +The final line of the output is the cumulative time for byte and +unicode strings, and the overall performance of unicode relative to +bytes. For example + +4079.83 5432.25 75.1 TOTAL + +However, this has no meaning as it evenly weights every test. From python-checkins at python.org Tue May 23 13:17:21 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 13:17:21 +0200 (CEST) Subject: [Python-checkins] r46101 - in python/trunk: Doc/api/exceptions.tex Misc/NEWS Python/errors.c Message-ID: <20060523111721.D70C61E4018@bag.python.org> Author: georg.brandl Date: Tue May 23 13:17:21 2006 New Revision: 46101 Modified: python/trunk/Doc/api/exceptions.tex python/trunk/Misc/NEWS python/trunk/Python/errors.c Log: PyErr_NewException now accepts a tuple of base classes as its "base" parameter. Modified: python/trunk/Doc/api/exceptions.tex ============================================================================== --- python/trunk/Doc/api/exceptions.tex (original) +++ python/trunk/Doc/api/exceptions.tex Tue May 23 13:17:21 2006 @@ -341,7 +341,8 @@ The \member{__module__} attribute of the new class is set to the first part (up to the last dot) of the \var{name} argument, and the class name is set to the last part (after the last dot). The - \var{base} argument can be used to specify an alternate base class. + \var{base} argument can be used to specify alternate base classes; + it can either be only one class or a tuple of classes. The \var{dict} argument can be used to specify a dictionary of class variables and methods. \end{cfuncdesc} Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 13:17:21 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- PyErr_NewException now accepts a tuple of base classes as its + "base" parameter. + - Patch #876206: function call speedup by retaining allocated frame objects. Modified: python/trunk/Python/errors.c ============================================================================== --- python/trunk/Python/errors.c (original) +++ python/trunk/Python/errors.c Tue May 23 13:17:21 2006 @@ -527,6 +527,7 @@ } + PyObject * PyErr_NewException(char *name, PyObject *base, PyObject *dict) { @@ -559,9 +560,15 @@ classname = PyString_FromString(dot+1); if (classname == NULL) goto failure; - bases = PyTuple_Pack(1, base); - if (bases == NULL) - goto failure; + if (PyTuple_Check(base)) { + bases = base; + /* INCREF as we create a new ref in the else branch */ + Py_INCREF(bases); + } else { + bases = PyTuple_Pack(1, base); + if (bases == NULL) + goto failure; + } result = PyClass_New(bases, dict, classname); failure: Py_XDECREF(bases); From buildbot at python.org Tue May 23 13:22:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 11:22:17 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060523112217.2374A1E4018@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/747 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: richard.jones Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 13:34:19 2006 From: python-checkins at python.org (jack.diederich) Date: Tue, 23 May 2006 13:34:19 +0200 (CEST) Subject: [Python-checkins] r46102 - in sandbox/trunk/decimal-c: Makefile README.txt decimal.py decimaltestdata decimaltestdata/abs.decTest decimaltestdata/add.decTest decimaltestdata/base.decTest decimaltestdata/clamp.decTest decimaltestdata/compare.decTest decimaltestdata/decimal128.decTest decimaltestdata/decimal32.decTest decimaltestdata/decimal64.decTest decimaltestdata/divide.decTest decimaltestdata/divideint.decTest decimaltestdata/inexact.decTest decimaltestdata/max.decTest decimaltestdata/min.decTest decimaltestdata/minus.decTest decimaltestdata/multiply.decTest decimaltestdata/normalize.decTest decimaltestdata/plus.decTest decimaltestdata/power.decTest decimaltestdata/quantize.decTest decimaltestdata/randomBound32.decTest decimaltestdata/randoms.decTest decimaltestdata/remainder.decTest decimaltestdata/remainderNear.decTest decimaltestdata/rescale.decTest decimaltestdata/rounding.decTest decimaltestdata/samequantum.decTest decimaltestdata/squareroot.decTest decimaltestdata/subtract.decTest decimaltestdata/testall.decTest decimaltestdata/tointegral.decTest setup.py test_decimal.py Message-ID: <20060523113419.CD53E1E4018@bag.python.org> Author: jack.diederich Date: Tue May 23 13:34:01 2006 New Revision: 46102 Added: sandbox/trunk/decimal-c/Makefile sandbox/trunk/decimal-c/README.txt sandbox/trunk/decimal-c/decimal.py sandbox/trunk/decimal-c/decimaltestdata/ sandbox/trunk/decimal-c/decimaltestdata/abs.decTest sandbox/trunk/decimal-c/decimaltestdata/add.decTest sandbox/trunk/decimal-c/decimaltestdata/base.decTest sandbox/trunk/decimal-c/decimaltestdata/clamp.decTest sandbox/trunk/decimal-c/decimaltestdata/compare.decTest sandbox/trunk/decimal-c/decimaltestdata/decimal128.decTest sandbox/trunk/decimal-c/decimaltestdata/decimal32.decTest sandbox/trunk/decimal-c/decimaltestdata/decimal64.decTest sandbox/trunk/decimal-c/decimaltestdata/divide.decTest sandbox/trunk/decimal-c/decimaltestdata/divideint.decTest sandbox/trunk/decimal-c/decimaltestdata/inexact.decTest sandbox/trunk/decimal-c/decimaltestdata/max.decTest sandbox/trunk/decimal-c/decimaltestdata/min.decTest sandbox/trunk/decimal-c/decimaltestdata/minus.decTest sandbox/trunk/decimal-c/decimaltestdata/multiply.decTest sandbox/trunk/decimal-c/decimaltestdata/normalize.decTest sandbox/trunk/decimal-c/decimaltestdata/plus.decTest sandbox/trunk/decimal-c/decimaltestdata/power.decTest sandbox/trunk/decimal-c/decimaltestdata/quantize.decTest sandbox/trunk/decimal-c/decimaltestdata/randomBound32.decTest sandbox/trunk/decimal-c/decimaltestdata/randoms.decTest sandbox/trunk/decimal-c/decimaltestdata/remainder.decTest sandbox/trunk/decimal-c/decimaltestdata/remainderNear.decTest sandbox/trunk/decimal-c/decimaltestdata/rescale.decTest sandbox/trunk/decimal-c/decimaltestdata/rounding.decTest sandbox/trunk/decimal-c/decimaltestdata/samequantum.decTest sandbox/trunk/decimal-c/decimaltestdata/squareroot.decTest sandbox/trunk/decimal-c/decimaltestdata/subtract.decTest sandbox/trunk/decimal-c/decimaltestdata/testall.decTest sandbox/trunk/decimal-c/decimaltestdata/tointegral.decTest sandbox/trunk/decimal-c/setup.py sandbox/trunk/decimal-c/test_decimal.py Modified: sandbox/trunk/decimal-c/ (props changed) Log: * aids to build the _decimal module as a regular python extension * copies of decimal.py and tests from the trunk Added: sandbox/trunk/decimal-c/Makefile ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/Makefile Tue May 23 13:34:01 2006 @@ -0,0 +1,11 @@ +# change PYTHON_25 to point to a 2.5 HEAD build +PYTHON_25=../python-rw/python + +all: module test +module: + $(PYTHON_25) setup.py build + cp build/lib*/_decimal.so . +clean: + rm -rf build/ +test: + $(PYTHON_25) test_decimal.py Added: sandbox/trunk/decimal-c/README.txt ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/README.txt Tue May 23 13:34:01 2006 @@ -0,0 +1,14 @@ + +The decimal-c branch is an attempt to rewrite the decimal module in C + +_decimal builds as a regular stand-alone python extension module +decimal.py and test_decimal.py are copies from the 2.5 trunk + +The plan is to change decimal.Decimal to inherit from _decimal.Decimal +and replace the pure-python methods one-by-one while keeping all the +tests passing. This should allow us to tackle the job in small pieces +and allow many people to tackle it at once. + +Edit the Makefile to point PYTHON_25 to point to a trunk build of python +and then run 'make' or 'make all' to build the extension and run the +test suite. Added: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimal.py Tue May 23 13:34:01 2006 @@ -0,0 +1,3108 @@ +# Copyright (c) 2004 Python Software Foundation. +# All rights reserved. + +# Written by Eric Price +# and Facundo Batista +# and Raymond Hettinger +# and Aahz +# and Tim Peters + +# This module is currently Py2.3 compatible and should be kept that way +# unless a major compelling advantage arises. IOW, 2.3 compatibility is +# strongly preferred, but not guaranteed. + +# Also, this module should be kept in sync with the latest updates of +# the IBM specification as it evolves. Those updates will be treated +# as bug fixes (deviation from the spec is a compatibility, usability +# bug) and will be backported. At this point the spec is stabilizing +# and the updates are becoming fewer, smaller, and less significant. + +""" +This is a Py2.3 implementation of decimal floating point arithmetic based on +the General Decimal Arithmetic Specification: + + www2.hursley.ibm.com/decimal/decarith.html + +and IEEE standard 854-1987: + + www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html + +Decimal floating point has finite precision with arbitrarily large bounds. + +The purpose of the module is to support arithmetic using familiar +"schoolhouse" rules and to avoid the some of tricky representation +issues associated with binary floating point. The package is especially +useful for financial applications or for contexts where users have +expectations that are at odds with binary floating point (for instance, +in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead +of the expected Decimal("0.00") returned by decimal floating point). + +Here are some examples of using the decimal module: + +>>> from decimal import * +>>> setcontext(ExtendedContext) +>>> Decimal(0) +Decimal("0") +>>> Decimal("1") +Decimal("1") +>>> Decimal("-.0123") +Decimal("-0.0123") +>>> Decimal(123456) +Decimal("123456") +>>> Decimal("123.45e12345678901234567890") +Decimal("1.2345E+12345678901234567892") +>>> Decimal("1.33") + Decimal("1.27") +Decimal("2.60") +>>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41") +Decimal("-2.20") +>>> dig = Decimal(1) +>>> print dig / Decimal(3) +0.333333333 +>>> getcontext().prec = 18 +>>> print dig / Decimal(3) +0.333333333333333333 +>>> print dig.sqrt() +1 +>>> print Decimal(3).sqrt() +1.73205080756887729 +>>> print Decimal(3) ** 123 +4.85192780976896427E+58 +>>> inf = Decimal(1) / Decimal(0) +>>> print inf +Infinity +>>> neginf = Decimal(-1) / Decimal(0) +>>> print neginf +-Infinity +>>> print neginf + inf +NaN +>>> print neginf * inf +-Infinity +>>> print dig / 0 +Infinity +>>> getcontext().traps[DivisionByZero] = 1 +>>> print dig / 0 +Traceback (most recent call last): + ... + ... + ... +DivisionByZero: x / 0 +>>> c = Context() +>>> c.traps[InvalidOperation] = 0 +>>> print c.flags[InvalidOperation] +0 +>>> c.divide(Decimal(0), Decimal(0)) +Decimal("NaN") +>>> c.traps[InvalidOperation] = 1 +>>> print c.flags[InvalidOperation] +1 +>>> c.flags[InvalidOperation] = 0 +>>> print c.flags[InvalidOperation] +0 +>>> print c.divide(Decimal(0), Decimal(0)) +Traceback (most recent call last): + ... + ... + ... +InvalidOperation: 0 / 0 +>>> print c.flags[InvalidOperation] +1 +>>> c.flags[InvalidOperation] = 0 +>>> c.traps[InvalidOperation] = 0 +>>> print c.divide(Decimal(0), Decimal(0)) +NaN +>>> print c.flags[InvalidOperation] +1 +>>> +""" + +__all__ = [ + # Two major classes + 'Decimal', 'Context', + + # Contexts + 'DefaultContext', 'BasicContext', 'ExtendedContext', + + # Exceptions + 'DecimalException', 'Clamped', 'InvalidOperation', 'DivisionByZero', + 'Inexact', 'Rounded', 'Subnormal', 'Overflow', 'Underflow', + + # Constants for use in setting up contexts + 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', + 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', + + # Functions for manipulating contexts + 'setcontext', 'getcontext' +] + +import copy as _copy + +#Rounding +ROUND_DOWN = 'ROUND_DOWN' +ROUND_HALF_UP = 'ROUND_HALF_UP' +ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' +ROUND_CEILING = 'ROUND_CEILING' +ROUND_FLOOR = 'ROUND_FLOOR' +ROUND_UP = 'ROUND_UP' +ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' + +#Rounding decision (not part of the public API) +NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY +ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. + +#Errors + +class DecimalException(ArithmeticError): + """Base exception class. + + Used exceptions derive from this. + If an exception derives from another exception besides this (such as + Underflow (Inexact, Rounded, Subnormal) that indicates that it is only + called if the others are present. This isn't actually used for + anything, though. + + handle -- Called when context._raise_error is called and the + trap_enabler is set. First argument is self, second is the + context. More arguments can be given, those being after + the explanation in _raise_error (For example, + context._raise_error(NewError, '(-x)!', self._sign) would + call NewError().handle(context, self._sign).) + + To define a new exception, it should be sufficient to have it derive + from DecimalException. + """ + def handle(self, context, *args): + pass + + +class Clamped(DecimalException): + """Exponent of a 0 changed to fit bounds. + + This occurs and signals clamped if the exponent of a result has been + altered in order to fit the constraints of a specific concrete + representation. This may occur when the exponent of a zero result would + be outside the bounds of a representation, or when a large normal + number would have an encoded exponent that cannot be represented. In + this latter case, the exponent is reduced to fit and the corresponding + number of zero digits are appended to the coefficient ("fold-down"). + """ + + +class InvalidOperation(DecimalException): + """An invalid operation was performed. + + Various bad things cause this: + + Something creates a signaling NaN + -INF + INF + 0 * (+-)INF + (+-)INF / (+-)INF + x % 0 + (+-)INF % x + x._rescale( non-integer ) + sqrt(-x) , x > 0 + 0 ** 0 + x ** (non-integer) + x ** (+-)INF + An operand is invalid + """ + def handle(self, context, *args): + if args: + if args[0] == 1: #sNaN, must drop 's' but keep diagnostics + return Decimal( (args[1]._sign, args[1]._int, 'n') ) + return NaN + +class ConversionSyntax(InvalidOperation): + """Trying to convert badly formed string. + + This occurs and signals invalid-operation if an string is being + converted to a number and it does not conform to the numeric string + syntax. The result is [0,qNaN]. + """ + + def handle(self, context, *args): + return (0, (0,), 'n') #Passed to something which uses a tuple. + +class DivisionByZero(DecimalException, ZeroDivisionError): + """Division by 0. + + This occurs and signals division-by-zero if division of a finite number + by zero was attempted (during a divide-integer or divide operation, or a + power operation with negative right-hand operand), and the dividend was + not zero. + + The result of the operation is [sign,inf], where sign is the exclusive + or of the signs of the operands for divide, or is 1 for an odd power of + -0, for power. + """ + + def handle(self, context, sign, double = None, *args): + if double is not None: + return (Infsign[sign],)*2 + return Infsign[sign] + +class DivisionImpossible(InvalidOperation): + """Cannot perform the division adequately. + + This occurs and signals invalid-operation if the integer result of a + divide-integer or remainder operation had too many digits (would be + longer than precision). The result is [0,qNaN]. + """ + + def handle(self, context, *args): + return (NaN, NaN) + +class DivisionUndefined(InvalidOperation, ZeroDivisionError): + """Undefined result of division. + + This occurs and signals invalid-operation if division by zero was + attempted (during a divide-integer, divide, or remainder operation), and + the dividend is also zero. The result is [0,qNaN]. + """ + + def handle(self, context, tup=None, *args): + if tup is not None: + return (NaN, NaN) #for 0 %0, 0 // 0 + return NaN + +class Inexact(DecimalException): + """Had to round, losing information. + + This occurs and signals inexact whenever the result of an operation is + not exact (that is, it needed to be rounded and any discarded digits + were non-zero), or if an overflow or underflow condition occurs. The + result in all cases is unchanged. + + The inexact signal may be tested (or trapped) to determine if a given + operation (or sequence of operations) was inexact. + """ + pass + +class InvalidContext(InvalidOperation): + """Invalid context. Unknown rounding, for example. + + This occurs and signals invalid-operation if an invalid context was + detected during an operation. This can occur if contexts are not checked + on creation and either the precision exceeds the capability of the + underlying concrete representation or an unknown or unsupported rounding + was specified. These aspects of the context need only be checked when + the values are required to be used. The result is [0,qNaN]. + """ + + def handle(self, context, *args): + return NaN + +class Rounded(DecimalException): + """Number got rounded (not necessarily changed during rounding). + + This occurs and signals rounded whenever the result of an operation is + rounded (that is, some zero or non-zero digits were discarded from the + coefficient), or if an overflow or underflow condition occurs. The + result in all cases is unchanged. + + The rounded signal may be tested (or trapped) to determine if a given + operation (or sequence of operations) caused a loss of precision. + """ + pass + +class Subnormal(DecimalException): + """Exponent < Emin before rounding. + + This occurs and signals subnormal whenever the result of a conversion or + operation is subnormal (that is, its adjusted exponent is less than + Emin, before any rounding). The result in all cases is unchanged. + + The subnormal signal may be tested (or trapped) to determine if a given + or operation (or sequence of operations) yielded a subnormal result. + """ + pass + +class Overflow(Inexact, Rounded): + """Numerical overflow. + + This occurs and signals overflow if the adjusted exponent of a result + (from a conversion or from an operation that is not an attempt to divide + by zero), after rounding, would be greater than the largest value that + can be handled by the implementation (the value Emax). + + The result depends on the rounding mode: + + For round-half-up and round-half-even (and for round-half-down and + round-up, if implemented), the result of the operation is [sign,inf], + where sign is the sign of the intermediate result. For round-down, the + result is the largest finite number that can be represented in the + current precision, with the sign of the intermediate result. For + round-ceiling, the result is the same as for round-down if the sign of + the intermediate result is 1, or is [0,inf] otherwise. For round-floor, + the result is the same as for round-down if the sign of the intermediate + result is 0, or is [1,inf] otherwise. In all cases, Inexact and Rounded + will also be raised. + """ + + def handle(self, context, sign, *args): + if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN, + ROUND_HALF_DOWN, ROUND_UP): + return Infsign[sign] + if sign == 0: + if context.rounding == ROUND_CEILING: + return Infsign[sign] + return Decimal((sign, (9,)*context.prec, + context.Emax-context.prec+1)) + if sign == 1: + if context.rounding == ROUND_FLOOR: + return Infsign[sign] + return Decimal( (sign, (9,)*context.prec, + context.Emax-context.prec+1)) + + +class Underflow(Inexact, Rounded, Subnormal): + """Numerical underflow with result rounded to 0. + + This occurs and signals underflow if a result is inexact and the + adjusted exponent of the result would be smaller (more negative) than + the smallest value that can be handled by the implementation (the value + Emin). That is, the result is both inexact and subnormal. + + The result after an underflow will be a subnormal number rounded, if + necessary, so that its exponent is not less than Etiny. This may result + in 0 with the sign of the intermediate result and an exponent of Etiny. + + In all cases, Inexact, Rounded, and Subnormal will also be raised. + """ + +# List of public traps and flags +_signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, + Underflow, InvalidOperation, Subnormal] + +# Map conditions (per the spec) to signals +_condition_map = {ConversionSyntax:InvalidOperation, + DivisionImpossible:InvalidOperation, + DivisionUndefined:InvalidOperation, + InvalidContext:InvalidOperation} + +##### Context Functions ####################################### + +# The getcontext() and setcontext() function manage access to a thread-local +# current context. Py2.4 offers direct support for thread locals. If that +# is not available, use threading.currentThread() which is slower but will +# work for older Pythons. If threads are not part of the build, create a +# mock threading object with threading.local() returning the module namespace. + +try: + import threading +except ImportError: + # Python was compiled without threads; create a mock object instead + import sys + class MockThreading: + def local(self, sys=sys): + return sys.modules[__name__] + threading = MockThreading() + del sys, MockThreading + +try: + threading.local + +except AttributeError: + + #To fix reloading, force it to create a new context + #Old contexts have different exceptions in their dicts, making problems. + if hasattr(threading.currentThread(), '__decimal_context__'): + del threading.currentThread().__decimal_context__ + + def setcontext(context): + """Set this thread's context to context.""" + if context in (DefaultContext, BasicContext, ExtendedContext): + context = context.copy() + context.clear_flags() + threading.currentThread().__decimal_context__ = context + + def getcontext(): + """Returns this thread's context. + + If this thread does not yet have a context, returns + a new context and sets this thread's context. + New contexts are copies of DefaultContext. + """ + try: + return threading.currentThread().__decimal_context__ + except AttributeError: + context = Context() + threading.currentThread().__decimal_context__ = context + return context + +else: + + local = threading.local() + if hasattr(local, '__decimal_context__'): + del local.__decimal_context__ + + def getcontext(_local=local): + """Returns this thread's context. + + If this thread does not yet have a context, returns + a new context and sets this thread's context. + New contexts are copies of DefaultContext. + """ + try: + return _local.__decimal_context__ + except AttributeError: + context = Context() + _local.__decimal_context__ = context + return context + + def setcontext(context, _local=local): + """Set this thread's context to context.""" + if context in (DefaultContext, BasicContext, ExtendedContext): + context = context.copy() + context.clear_flags() + _local.__decimal_context__ = context + + del threading, local # Don't contaminate the namespace + + +##### Decimal class ########################################### + +import _decimal + +class Decimal(_decimal.Decimal): + """Floating point class for decimal arithmetic.""" + + __slots__ = ('_exp','_int','_sign', '_is_special') + # Generally, the value of the Decimal instance is given by + # (-1)**_sign * _int * 10**_exp + # Special values are signified by _is_special == True + + # We're immutable, so use __new__ not __init__ + def __new__(cls, value="0", context=None): + """Create a decimal point instance. + + >>> Decimal('3.14') # string input + Decimal("3.14") + >>> Decimal((0, (3, 1, 4), -2)) # tuple input (sign, digit_tuple, exponent) + Decimal("3.14") + >>> Decimal(314) # int or long + Decimal("314") + >>> Decimal(Decimal(314)) # another decimal instance + Decimal("314") + """ + + self = object.__new__(cls) + self._is_special = False + + # From an internal working value + if isinstance(value, _WorkRep): + self._sign = value.sign + self._int = tuple(map(int, str(value.int))) + self._exp = int(value.exp) + return self + + # From another decimal + if isinstance(value, Decimal): + self._exp = value._exp + self._sign = value._sign + self._int = value._int + self._is_special = value._is_special + return self + + # From an integer + if isinstance(value, (int,long)): + if value >= 0: + self._sign = 0 + else: + self._sign = 1 + self._exp = 0 + self._int = tuple(map(int, str(abs(value)))) + return self + + # tuple/list conversion (possibly from as_tuple()) + if isinstance(value, (list,tuple)): + if len(value) != 3: + raise ValueError, 'Invalid arguments' + if value[0] not in (0,1): + raise ValueError, 'Invalid sign' + for digit in value[1]: + if not isinstance(digit, (int,long)) or digit < 0: + raise ValueError, "The second value in the tuple must be composed of non negative integer elements." + + self._sign = value[0] + self._int = tuple(value[1]) + if value[2] in ('F','n','N'): + self._exp = value[2] + self._is_special = True + else: + self._exp = int(value[2]) + return self + + if isinstance(value, float): + raise TypeError("Cannot convert float to Decimal. " + + "First convert the float to a string") + + # Other argument types may require the context during interpretation + if context is None: + context = getcontext() + + # From a string + # REs insist on real strings, so we can too. + if isinstance(value, basestring): + if _isinfinity(value): + self._exp = 'F' + self._int = (0,) + self._is_special = True + if _isinfinity(value) == 1: + self._sign = 0 + else: + self._sign = 1 + return self + if _isnan(value): + sig, sign, diag = _isnan(value) + self._is_special = True + if len(diag) > context.prec: #Diagnostic info too long + self._sign, self._int, self._exp = \ + context._raise_error(ConversionSyntax) + return self + if sig == 1: + self._exp = 'n' #qNaN + else: #sig == 2 + self._exp = 'N' #sNaN + self._sign = sign + self._int = tuple(map(int, diag)) #Diagnostic info + return self + try: + self._sign, self._int, self._exp = _string2exact(value) + except ValueError: + self._is_special = True + self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) + return self + + raise TypeError("Cannot convert %r to Decimal" % value) + + def _isnan(self): + """Returns whether the number is not actually one. + + 0 if a number + 1 if NaN + 2 if sNaN + """ + if self._is_special: + exp = self._exp + if exp == 'n': + return 1 + elif exp == 'N': + return 2 + return 0 + + def _isinfinity(self): + """Returns whether the number is infinite + + 0 if finite or not a number + 1 if +INF + -1 if -INF + """ + if self._exp == 'F': + if self._sign: + return -1 + return 1 + return 0 + + def _check_nans(self, other = None, context=None): + """Returns whether the number is not actually one. + + if self, other are sNaN, signal + if self, other are NaN return nan + return 0 + + Done before operations. + """ + + self_is_nan = self._isnan() + if other is None: + other_is_nan = False + else: + other_is_nan = other._isnan() + + if self_is_nan or other_is_nan: + if context is None: + context = getcontext() + + if self_is_nan == 2: + return context._raise_error(InvalidOperation, 'sNaN', + 1, self) + if other_is_nan == 2: + return context._raise_error(InvalidOperation, 'sNaN', + 1, other) + if self_is_nan: + return self + + return other + return 0 + + def __nonzero__(self): + """Is the number non-zero? + + 0 if self == 0 + 1 if self != 0 + """ + if self._is_special: + return 1 + return sum(self._int) != 0 + + 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) + if ans: + return 1 # Comparison involving NaN's always reports self > other + + # INF = INF + return cmp(self._isinfinity(), other._isinfinity()) + + if not self and not other: + return 0 #If both 0, sign comparison isn't certain. + + #If different signs, neg one is less + if other._sign < self._sign: + return -1 + if self._sign < other._sign: + return 1 + + self_adjusted = self.adjusted() + other_adjusted = other.adjusted() + if self_adjusted == other_adjusted and \ + self._int + (0,)*(self._exp - other._exp) == \ + other._int + (0,)*(other._exp - self._exp): + return 0 #equal, except in precision. ([0]*(-x) = []) + elif self_adjusted > other_adjusted and self._int[0] != 0: + return (-1)**self._sign + elif self_adjusted < other_adjusted and other._int[0] != 0: + return -((-1)**self._sign) + + # Need to round, so make sure we have a valid context + if context is None: + context = getcontext() + + context = context._shallow_copy() + rounding = context._set_rounding(ROUND_UP) #round away from 0 + + flags = context._ignore_all_flags() + res = self.__sub__(other, context=context) + + context._regard_flags(*flags) + + context.rounding = rounding + + if not res: + return 0 + elif res._sign: + return -1 + return 1 + + def __eq__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) == 0 + + def __ne__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) != 0 + + def compare(self, other, context=None): + """Compares one to another. + + -1 => a < b + 0 => a = b + 1 => a > b + NaN => one is NaN + 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): + ans = self._check_nans(other, context) + if ans: + return ans + + return Decimal(self.__cmp__(other, context)) + + def __hash__(self): + """x.__hash__() <==> hash(x)""" + # Decimal integers must hash the same as the ints + # Non-integer decimals are normalized and hashed as strings + # Normalization assures that hash(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) + assert self.__nonzero__() # '-0' handled by integer case + return hash(str(self.normalize())) + + def as_tuple(self): + """Represents the number as a triple tuple. + + To show the internals exactly as they are. + """ + return (self._sign, self._int, self._exp) + + def __repr__(self): + """Represents the number as an instance of Decimal.""" + # Invariant: eval(repr(d)) == d + return 'Decimal("%s")' % str(self) + + def __str__(self, eng = 0, context=None): + """Return string representation of the number in scientific notation. + + Captures all of the information in the underlying representation. + """ + + if self._is_special: + if self._isnan(): + minus = '-'*self._sign + if self._int == (0,): + info = '' + else: + info = ''.join(map(str, self._int)) + if self._isnan() == 2: + return minus + 'sNaN' + info + return minus + 'NaN' + info + if self._isinfinity(): + minus = '-'*self._sign + return minus + 'Infinity' + + if context is None: + context = getcontext() + + tmp = map(str, self._int) + numdigits = len(self._int) + leftdigits = self._exp + numdigits + if eng and not self: #self = 0eX wants 0[.0[0]]eY, not [[0]0]0eY + if self._exp < 0 and self._exp >= -6: #short, no need for e/E + s = '-'*self._sign + '0.' + '0'*(abs(self._exp)) + return s + #exp is closest mult. of 3 >= self._exp + exp = ((self._exp - 1)// 3 + 1) * 3 + if exp != self._exp: + s = '0.'+'0'*(exp - self._exp) + else: + s = '0' + if exp != 0: + if context.capitals: + s += 'E' + else: + s += 'e' + if exp > 0: + s += '+' #0.0e+3, not 0.0e3 + s += str(exp) + s = '-'*self._sign + s + return s + if eng: + dotplace = (leftdigits-1)%3+1 + adjexp = leftdigits -1 - (leftdigits-1)%3 + else: + adjexp = leftdigits-1 + dotplace = 1 + if self._exp == 0: + pass + elif self._exp < 0 and adjexp >= 0: + tmp.insert(leftdigits, '.') + elif self._exp < 0 and adjexp >= -6: + tmp[0:0] = ['0'] * int(-leftdigits) + tmp.insert(0, '0.') + else: + if numdigits > dotplace: + tmp.insert(dotplace, '.') + elif numdigits < dotplace: + tmp.extend(['0']*(dotplace-numdigits)) + if adjexp: + if not context.capitals: + tmp.append('e') + else: + tmp.append('E') + if adjexp > 0: + tmp.append('+') + tmp.append(str(adjexp)) + if eng: + while tmp[0:1] == ['0']: + tmp[0:1] = [] + if len(tmp) == 0 or tmp[0] == '.' or tmp[0].lower() == 'e': + tmp[0:0] = ['0'] + if self._sign: + tmp.insert(0, '-') + + return ''.join(tmp) + + def to_eng_string(self, context=None): + """Convert to engineering-type string. + + Engineering notation has an exponent which is a multiple of 3, so there + are up to 3 digits left of the decimal place. + + Same rules for when in exponential and when as a value as in __str__. + """ + return self.__str__(eng=1, context=context) + + def __neg__(self, context=None): + """Returns a copy with the sign switched. + + Rounds, if it has reason. + """ + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + if not self: + # -Decimal('0') is Decimal('0'), not Decimal('-0') + sign = 0 + elif self._sign: + sign = 0 + else: + sign = 1 + + if context is None: + context = getcontext() + if context._rounding_decision == ALWAYS_ROUND: + return Decimal((sign, self._int, self._exp))._fix(context) + return Decimal( (sign, self._int, self._exp)) + + def __pos__(self, context=None): + """Returns a copy, unless it is a sNaN. + + Rounds the number (if more then precision digits) + """ + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + sign = self._sign + if not self: + # + (-0) = 0 + sign = 0 + + if context is None: + context = getcontext() + + if context._rounding_decision == ALWAYS_ROUND: + ans = self._fix(context) + else: + ans = Decimal(self) + ans._sign = sign + return ans + + def __abs__(self, round=1, context=None): + """Returns the absolute value of self. + + If the second argument is 0, do not round. + """ + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + if not round: + if context is None: + context = getcontext() + context = context._shallow_copy() + context._set_rounding_decision(NEVER_ROUND) + + if self._sign: + ans = self.__neg__(context=context) + else: + ans = self.__pos__(context=context) + + return ans + + def __add__(self, other, context=None): + """Returns self + other. + + -INF + INF (or the reverse) cause InvalidOperation errors. + """ + other = _convert_other(other) + if other is NotImplemented: + return other + + if context is None: + context = getcontext() + + if self._is_special or other._is_special: + ans = self._check_nans(other, context) + if ans: + return ans + + if self._isinfinity(): + #If both INF, same sign => same as both, opposite => error. + if self._sign != other._sign and other._isinfinity(): + return context._raise_error(InvalidOperation, '-INF + INF') + return Decimal(self) + if other._isinfinity(): + return Decimal(other) #Can't both be infinity here + + shouldround = context._rounding_decision == ALWAYS_ROUND + + exp = min(self._exp, other._exp) + negativezero = 0 + if context.rounding == ROUND_FLOOR and self._sign != other._sign: + #If the answer is 0, the sign should be negative, in this case. + negativezero = 1 + + if not self and not other: + sign = min(self._sign, other._sign) + if negativezero: + sign = 1 + return Decimal( (sign, (0,), exp)) + if not self: + exp = max(exp, other._exp - context.prec-1) + ans = other._rescale(exp, watchexp=0, context=context) + if shouldround: + ans = ans._fix(context) + return ans + if not other: + exp = max(exp, self._exp - context.prec-1) + ans = self._rescale(exp, watchexp=0, context=context) + if shouldround: + ans = ans._fix(context) + return ans + + op1 = _WorkRep(self) + op2 = _WorkRep(other) + op1, op2 = _normalize(op1, op2, shouldround, context.prec) + + result = _WorkRep() + if op1.sign != op2.sign: + # Equal and opposite + if op1.int == op2.int: + if exp < context.Etiny(): + exp = context.Etiny() + context._raise_error(Clamped) + return Decimal((negativezero, (0,), exp)) + if op1.int < op2.int: + op1, op2 = op2, op1 + #OK, now abs(op1) > abs(op2) + if op1.sign == 1: + result.sign = 1 + op1.sign, op2.sign = op2.sign, op1.sign + else: + result.sign = 0 + #So we know the sign, and op1 > 0. + elif op1.sign == 1: + result.sign = 1 + op1.sign, op2.sign = (0, 0) + else: + result.sign = 0 + #Now, op1 > abs(op2) > 0 + + if op2.sign == 0: + result.int = op1.int + op2.int + else: + result.int = op1.int - op2.int + + result.exp = op1.exp + ans = Decimal(result) + if shouldround: + ans = ans._fix(context) + return ans + + __radd__ = __add__ + + 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) + if ans: + return ans + + # -Decimal(0) = Decimal(0), which we don't want since + # (-0 - 0 = -0 + (-0) = -0, but -0 + 0 = 0.) + # so we change the sign directly to a copy + tmp = Decimal(other) + tmp._sign = 1-tmp._sign + + return self.__add__(tmp, context=context) + + 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 + return other.__add__(tmp, context=context) + + def _increment(self, round=1, context=None): + """Special case of add, adding 1eExponent + + Since it is common, (rounding, for example) this adds + (sign)*one E self._exp to the number more efficiently than add. + + For example: + Decimal('5.624e10')._increment() == Decimal('5.625e10') + """ + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + return Decimal(self) # Must be infinite, and incrementing makes no difference + + L = list(self._int) + L[-1] += 1 + spot = len(L)-1 + while L[spot] == 10: + L[spot] = 0 + if spot == 0: + L[0:0] = [1] + break + L[spot-1] += 1 + spot -= 1 + ans = Decimal((self._sign, L, self._exp)) + + if context is None: + context = getcontext() + if round and context._rounding_decision == ALWAYS_ROUND: + ans = ans._fix(context) + return ans + + def __mul__(self, other, context=None): + """Return self * other. + + (+-) INF * 0 (or its reverse) raise InvalidOperation. + """ + other = _convert_other(other) + if other is NotImplemented: + return other + + if context is None: + context = getcontext() + + resultsign = self._sign ^ other._sign + + if self._is_special or other._is_special: + ans = self._check_nans(other, context) + if ans: + return ans + + if self._isinfinity(): + if not other: + return context._raise_error(InvalidOperation, '(+-)INF * 0') + return Infsign[resultsign] + + if other._isinfinity(): + if not self: + return context._raise_error(InvalidOperation, '0 * (+-)INF') + return Infsign[resultsign] + + resultexp = self._exp + other._exp + shouldround = context._rounding_decision == ALWAYS_ROUND + + # Special case for multiplying by zero + if not self or not other: + ans = Decimal((resultsign, (0,), resultexp)) + if shouldround: + #Fixing in case the exponent is out of bounds + ans = ans._fix(context) + return ans + + # Special case for multiplying by power of 10 + if self._int == (1,): + ans = Decimal((resultsign, other._int, resultexp)) + if shouldround: + ans = ans._fix(context) + return ans + if other._int == (1,): + ans = Decimal((resultsign, self._int, resultexp)) + if shouldround: + ans = ans._fix(context) + return ans + + op1 = _WorkRep(self) + op2 = _WorkRep(other) + + ans = Decimal( (resultsign, map(int, str(op1.int * op2.int)), resultexp)) + if shouldround: + ans = ans._fix(context) + + return ans + __rmul__ = __mul__ + + def __div__(self, other, context=None): + """Return self / other.""" + return self._divide(other, context=context) + __truediv__ = __div__ + + def _divide(self, other, divmod = 0, context=None): + """Return a / b, to context.prec precision. + + divmod: + 0 => true division + 1 => (a //b, a%b) + 2 => a //b + 3 => a%b + + Actually, if divmod is 2 or 3 a tuple is returned, but errors for + 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() + + sign = self._sign ^ other._sign + + if self._is_special or other._is_special: + ans = self._check_nans(other, context) + if ans: + if divmod: + return (ans, ans) + return ans + + if self._isinfinity() and other._isinfinity(): + if divmod: + return (context._raise_error(InvalidOperation, + '(+-)INF // (+-)INF'), + context._raise_error(InvalidOperation, + '(+-)INF % (+-)INF')) + return context._raise_error(InvalidOperation, '(+-)INF/(+-)INF') + + if self._isinfinity(): + if divmod == 1: + return (Infsign[sign], + context._raise_error(InvalidOperation, 'INF % x')) + elif divmod == 2: + return (Infsign[sign], NaN) + elif divmod == 3: + return (Infsign[sign], + context._raise_error(InvalidOperation, 'INF % x')) + return Infsign[sign] + + if other._isinfinity(): + if divmod: + return (Decimal((sign, (0,), 0)), Decimal(self)) + context._raise_error(Clamped, 'Division by infinity') + return Decimal((sign, (0,), context.Etiny())) + + # Special cases for zeroes + if not self and not other: + if divmod: + return context._raise_error(DivisionUndefined, '0 / 0', 1) + return context._raise_error(DivisionUndefined, '0 / 0') + + if not self: + if divmod: + otherside = Decimal(self) + otherside._exp = min(self._exp, other._exp) + return (Decimal((sign, (0,), 0)), otherside) + exp = self._exp - other._exp + if exp < context.Etiny(): + exp = context.Etiny() + context._raise_error(Clamped, '0e-x / y') + if exp > context.Emax: + exp = context.Emax + context._raise_error(Clamped, '0e+x / y') + return Decimal( (sign, (0,), exp) ) + + if not other: + if divmod: + return context._raise_error(DivisionByZero, 'divmod(x,0)', + sign, 1) + return context._raise_error(DivisionByZero, 'x / 0', sign) + + #OK, so neither = 0, INF or NaN + + shouldround = context._rounding_decision == ALWAYS_ROUND + + #If we're dividing into ints, and self < other, stop. + #self.__abs__(0) does not round. + if divmod and (self.__abs__(0, context) < other.__abs__(0, context)): + + if divmod == 1 or divmod == 3: + exp = min(self._exp, other._exp) + ans2 = self._rescale(exp, context=context, watchexp=0) + if shouldround: + ans2 = ans2._fix(context) + return (Decimal( (sign, (0,), 0) ), + ans2) + + elif divmod == 2: + #Don't round the mod part, if we don't need it. + return (Decimal( (sign, (0,), 0) ), Decimal(self)) + + op1 = _WorkRep(self) + op2 = _WorkRep(other) + op1, op2, adjust = _adjust_coefficients(op1, op2) + res = _WorkRep( (sign, 0, (op1.exp - op2.exp)) ) + if divmod and res.exp > context.prec + 1: + return context._raise_error(DivisionImpossible) + + prec_limit = 10 ** context.prec + while 1: + while op2.int <= op1.int: + res.int += 1 + op1.int -= op2.int + if res.exp == 0 and divmod: + if res.int >= prec_limit and shouldround: + return context._raise_error(DivisionImpossible) + otherside = Decimal(op1) + frozen = context._ignore_all_flags() + + exp = min(self._exp, other._exp) + otherside = otherside._rescale(exp, context=context, watchexp=0) + context._regard_flags(*frozen) + if shouldround: + otherside = otherside._fix(context) + return (Decimal(res), otherside) + + if op1.int == 0 and adjust >= 0 and not divmod: + break + if res.int >= prec_limit and shouldround: + if divmod: + return context._raise_error(DivisionImpossible) + shouldround=1 + # Really, the answer is a bit higher, so adding a one to + # the end will make sure the rounding is right. + if op1.int != 0: + res.int *= 10 + res.int += 1 + res.exp -= 1 + + break + res.int *= 10 + res.exp -= 1 + adjust += 1 + op1.int *= 10 + op1.exp -= 1 + + if res.exp == 0 and divmod and op2.int > op1.int: + #Solves an error in precision. Same as a previous block. + + if res.int >= prec_limit and shouldround: + return context._raise_error(DivisionImpossible) + otherside = Decimal(op1) + frozen = context._ignore_all_flags() + + exp = min(self._exp, other._exp) + otherside = otherside._rescale(exp, context=context) + + context._regard_flags(*frozen) + + return (Decimal(res), otherside) + + ans = Decimal(res) + if shouldround: + ans = ans._fix(context) + return ans + + 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__ + + def __divmod__(self, other, context=None): + """ + (self // other, self % other) + """ + return self._divide(other, 1, context) + + 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): + """ + 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) + if ans: + return ans + + if self and not other: + return context._raise_error(InvalidOperation, 'x % 0') + + return self._divide(other, 3, context)[1] + + 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): + """ + 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) + if ans: + return ans + if self and not other: + return context._raise_error(InvalidOperation, 'x % 0') + + if context is None: + context = getcontext() + # If DivisionImpossible causes an error, do not leave Rounded/Inexact + # ignored in the calling function. + context = context._shallow_copy() + flags = context._ignore_flags(Rounded, Inexact) + #keep DivisionImpossible flags + (side, r) = self.__divmod__(other, context=context) + + if r._isnan(): + context._regard_flags(*flags) + return r + + context = context._shallow_copy() + rounding = context._set_rounding_decision(NEVER_ROUND) + + if other._sign: + comparison = other.__div__(Decimal(-2), context=context) + else: + comparison = other.__div__(Decimal(2), context=context) + + context._set_rounding_decision(rounding) + context._regard_flags(*flags) + + s1, s2 = r._sign, comparison._sign + r._sign, comparison._sign = 0, 0 + + if r < comparison: + r._sign, comparison._sign = s1, s2 + #Get flags now + self.__divmod__(other, context=context) + return r._fix(context) + r._sign, comparison._sign = s1, s2 + + rounding = context._set_rounding_decision(NEVER_ROUND) + + (side, r) = self.__divmod__(other, context=context) + context._set_rounding_decision(rounding) + if r._isnan(): + return r + + decrease = not side._iseven() + rounding = context._set_rounding_decision(NEVER_ROUND) + side = side.__abs__(context=context) + context._set_rounding_decision(rounding) + + s1, s2 = r._sign, comparison._sign + r._sign, comparison._sign = 0, 0 + if r > comparison or decrease and r == comparison: + r._sign, comparison._sign = s1, s2 + context.prec += 1 + if len(side.__add__(Decimal(1), context=context)._int) >= context.prec: + context.prec -= 1 + return context._raise_error(DivisionImpossible)[1] + context.prec -= 1 + if self._sign == other._sign: + r = r.__sub__(other, context=context) + else: + r = r.__add__(other, context=context) + else: + r._sign, comparison._sign = s1, s2 + + return r._fix(context) + + def __floordiv__(self, other, context=None): + """self // other""" + return self._divide(other, 2, context)[0] + + 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): + """Float representation.""" + return float(str(self)) + + def __int__(self): + """Converts self to an int, truncating if necessary.""" + if self._is_special: + if self._isnan(): + context = getcontext() + return context._raise_error(InvalidContext) + elif self._isinfinity(): + raise OverflowError, "Cannot convert infinity to long" + if self._exp >= 0: + s = ''.join(map(str, self._int)) + '0'*self._exp + else: + s = ''.join(map(str, self._int))[:self._exp] + if s == '': + s = '0' + sign = '-'*self._sign + return int(sign + s) + + def __long__(self): + """Converts to a long. + + Equivalent to long(int(self)) + """ + return long(self.__int__()) + + def _fix(self, context): + """Round if it is necessary to keep self within prec precision. + + Rounds and fixes the exponent. Does not raise on a sNaN. + + Arguments: + self - Decimal instance + context - context used. + """ + if self._is_special: + return self + if context is None: + context = getcontext() + prec = context.prec + ans = self._fixexponents(context) + if len(ans._int) > prec: + ans = ans._round(prec, context=context) + ans = ans._fixexponents(context) + return ans + + def _fixexponents(self, context): + """Fix the exponents and return a copy with the exponent in bounds. + Only call if known to not be a special value. + """ + folddown = context._clamp + Emin = context.Emin + ans = self + ans_adjusted = ans.adjusted() + if ans_adjusted < Emin: + Etiny = context.Etiny() + if ans._exp < Etiny: + if not ans: + ans = Decimal(self) + ans._exp = Etiny + context._raise_error(Clamped) + return ans + ans = ans._rescale(Etiny, context=context) + #It isn't zero, and exp < Emin => subnormal + context._raise_error(Subnormal) + if context.flags[Inexact]: + context._raise_error(Underflow) + else: + if ans: + #Only raise subnormal if non-zero. + context._raise_error(Subnormal) + else: + Etop = context.Etop() + if folddown and ans._exp > Etop: + context._raise_error(Clamped) + ans = ans._rescale(Etop, context=context) + else: + Emax = context.Emax + if ans_adjusted > Emax: + if not ans: + ans = Decimal(self) + ans._exp = Emax + context._raise_error(Clamped) + return ans + context._raise_error(Inexact) + context._raise_error(Rounded) + return context._raise_error(Overflow, 'above Emax', ans._sign) + return ans + + def _round(self, prec=None, rounding=None, context=None): + """Returns a rounded version of self. + + You can specify the precision or rounding method. Otherwise, the + context determines it. + """ + + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + if self._isinfinity(): + return Decimal(self) + + if context is None: + context = getcontext() + + if rounding is None: + rounding = context.rounding + if prec is None: + prec = context.prec + + if not self: + if prec <= 0: + dig = (0,) + exp = len(self._int) - prec + self._exp + else: + dig = (0,) * prec + exp = len(self._int) + self._exp - prec + ans = Decimal((self._sign, dig, exp)) + context._raise_error(Rounded) + return ans + + if prec == 0: + temp = Decimal(self) + temp._int = (0,)+temp._int + prec = 1 + elif prec < 0: + exp = self._exp + len(self._int) - prec - 1 + temp = Decimal( (self._sign, (0, 1), exp)) + prec = 1 + else: + temp = Decimal(self) + + numdigits = len(temp._int) + if prec == numdigits: + return temp + + # See if we need to extend precision + expdiff = prec - numdigits + if expdiff > 0: + tmp = list(temp._int) + tmp.extend([0] * expdiff) + ans = Decimal( (temp._sign, tmp, temp._exp - expdiff)) + return ans + + #OK, but maybe all the lost digits are 0. + lostdigits = self._int[expdiff:] + if lostdigits == (0,) * len(lostdigits): + ans = Decimal( (temp._sign, temp._int[:prec], temp._exp - expdiff)) + #Rounded, but not Inexact + context._raise_error(Rounded) + return ans + + # Okay, let's round and lose data + + this_function = getattr(temp, self._pick_rounding_function[rounding]) + #Now we've got the rounding function + + if prec != context.prec: + context = context._shallow_copy() + context.prec = prec + ans = this_function(prec, expdiff, context) + context._raise_error(Rounded) + context._raise_error(Inexact, 'Changed in rounding') + + return ans + + _pick_rounding_function = {} + + def _round_down(self, prec, expdiff, context): + """Also known as round-towards-0, truncate.""" + return Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) + + def _round_half_up(self, prec, expdiff, context, tmp = None): + """Rounds 5 up (away from 0)""" + + if tmp is None: + tmp = Decimal( (self._sign,self._int[:prec], self._exp - expdiff)) + if self._int[prec] >= 5: + tmp = tmp._increment(round=0, context=context) + if len(tmp._int) > prec: + return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) + return tmp + + def _round_half_even(self, prec, expdiff, context): + """Round 5 to even, rest to nearest.""" + + tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) + half = (self._int[prec] == 5) + if half: + for digit in self._int[prec+1:]: + if digit != 0: + half = 0 + break + if half: + if self._int[prec-1] & 1 == 0: + return tmp + return self._round_half_up(prec, expdiff, context, tmp) + + def _round_half_down(self, prec, expdiff, context): + """Round 5 down""" + + tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) + half = (self._int[prec] == 5) + if half: + for digit in self._int[prec+1:]: + if digit != 0: + half = 0 + break + if half: + return tmp + return self._round_half_up(prec, expdiff, context, tmp) + + def _round_up(self, prec, expdiff, context): + """Rounds away from 0.""" + tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) + for digit in self._int[prec:]: + if digit != 0: + tmp = tmp._increment(round=1, context=context) + if len(tmp._int) > prec: + return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) + else: + return tmp + return tmp + + def _round_ceiling(self, prec, expdiff, context): + """Rounds up (not away from 0 if negative.)""" + if self._sign: + return self._round_down(prec, expdiff, context) + else: + return self._round_up(prec, expdiff, context) + + def _round_floor(self, prec, expdiff, context): + """Rounds down (not towards 0 if negative)""" + if not self._sign: + return self._round_down(prec, expdiff, context) + else: + return self._round_up(prec, expdiff, context) + + def __pow__(self, n, modulo = None, context=None): + """Return self ** n (mod modulo) + + 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() + + if self._is_special or n._is_special or n.adjusted() > 8: + #Because the spot << doesn't work with really big exponents + if n._isinfinity() or n.adjusted() > 8: + return context._raise_error(InvalidOperation, 'x ** INF') + + ans = self._check_nans(n, context) + if ans: + return ans + + if not n._isinteger(): + return context._raise_error(InvalidOperation, 'x ** (non-integer)') + + if not self and not n: + return context._raise_error(InvalidOperation, '0 ** 0') + + if not n: + return Decimal(1) + + if self == Decimal(1): + return Decimal(1) + + sign = self._sign and not n._iseven() + n = int(n) + + if self._isinfinity(): + if modulo: + return context._raise_error(InvalidOperation, 'INF % x') + if n > 0: + return Infsign[sign] + return Decimal( (sign, (0,), 0) ) + + #with ludicrously large exponent, just raise an overflow and return inf. + if not modulo and n > 0 and (self._exp + len(self._int) - 1) * n > context.Emax \ + and self: + + tmp = Decimal('inf') + tmp._sign = sign + context._raise_error(Rounded) + context._raise_error(Inexact) + context._raise_error(Overflow, 'Big power', sign) + return tmp + + elength = len(str(abs(n))) + firstprec = context.prec + + if not modulo and firstprec + elength + 1 > DefaultContext.Emax: + return context._raise_error(Overflow, 'Too much precision.', sign) + + mul = Decimal(self) + val = Decimal(1) + context = context._shallow_copy() + context.prec = firstprec + elength + 1 + if n < 0: + #n is a long now, not Decimal instance + n = -n + mul = Decimal(1).__div__(mul, context=context) + + spot = 1 + while spot <= n: + spot <<= 1 + + spot >>= 1 + #Spot is the highest power of 2 less than n + while spot: + val = val.__mul__(val, context=context) + if val._isinfinity(): + val = Infsign[sign] + break + if spot & n: + val = val.__mul__(mul, context=context) + if modulo is not None: + val = val.__mod__(modulo, context=context) + spot >>= 1 + context.prec = firstprec + + if context._rounding_decision == ALWAYS_ROUND: + return val._fix(context) + return val + + 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): + """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" + + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + dup = self._fix(context) + if dup._isinfinity(): + return dup + + if not dup: + return Decimal( (dup._sign, (0,), 0) ) + end = len(dup._int) + exp = dup._exp + while dup._int[end-1] == 0: + exp += 1 + end -= 1 + return Decimal( (dup._sign, dup._int[:end], exp) ) + + + def quantize(self, exp, rounding=None, context=None, watchexp=1): + """Quantize self so its exponent is the same as that of exp. + + Similar to self._rescale(exp._exp) but with error checking. + """ + if self._is_special or exp._is_special: + ans = self._check_nans(exp, context) + if ans: + return ans + + if exp._isinfinity() or self._isinfinity(): + if exp._isinfinity() and self._isinfinity(): + return self #if both are inf, it is OK + if context is None: + context = getcontext() + return context._raise_error(InvalidOperation, + 'quantize with one INF') + return self._rescale(exp._exp, rounding, context, watchexp) + + def same_quantum(self, other): + """Test whether self and other have the same exponent. + + same as self._exp == other._exp, except NaN == sNaN + """ + if self._is_special or other._is_special: + if self._isnan() or other._isnan(): + return self._isnan() and other._isnan() and True + if self._isinfinity() or other._isinfinity(): + return self._isinfinity() and other._isinfinity() and True + return self._exp == other._exp + + def _rescale(self, exp, rounding=None, context=None, watchexp=1): + """Rescales so that the exponent is exp. + + exp = exp to scale to (an integer) + rounding = rounding version + watchexp: if set (default) an error is returned if exp is greater + than Emax or less than Etiny. + """ + if context is None: + context = getcontext() + + if self._is_special: + if self._isinfinity(): + return context._raise_error(InvalidOperation, 'rescale with an INF') + + ans = self._check_nans(context=context) + if ans: + return ans + + if watchexp and (context.Emax < exp or context.Etiny() > exp): + return context._raise_error(InvalidOperation, 'rescale(a, INF)') + + if not self: + ans = Decimal(self) + ans._int = (0,) + ans._exp = exp + return ans + + diff = self._exp - exp + digits = len(self._int) + diff + + if watchexp and digits > context.prec: + return context._raise_error(InvalidOperation, 'Rescale > prec') + + tmp = Decimal(self) + tmp._int = (0,) + tmp._int + digits += 1 + + if digits < 0: + tmp._exp = -digits + tmp._exp + tmp._int = (0,1) + digits = 1 + tmp = tmp._round(digits, rounding, context=context) + + if tmp._int[0] == 0 and len(tmp._int) > 1: + tmp._int = tmp._int[1:] + tmp._exp = exp + + tmp_adjusted = tmp.adjusted() + if tmp and tmp_adjusted < context.Emin: + context._raise_error(Subnormal) + elif tmp and tmp_adjusted > context.Emax: + return context._raise_error(InvalidOperation, 'rescale(a, INF)') + return tmp + + def to_integral(self, rounding=None, context=None): + """Rounds to the nearest integer, without raising inexact, rounded.""" + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + if self._exp >= 0: + return self + if context is None: + context = getcontext() + flags = context._ignore_flags(Rounded, Inexact) + ans = self._rescale(0, rounding, context=context) + context._regard_flags(flags) + return ans + + def sqrt(self, context=None): + """Return the square root of self. + + Uses a converging algorithm (Xn+1 = 0.5*(Xn + self / Xn)) + Should quadratically approach the right answer. + """ + if self._is_special: + ans = self._check_nans(context=context) + if ans: + return ans + + if self._isinfinity() and self._sign == 0: + return Decimal(self) + + if not self: + #exponent = self._exp / 2, using round_down. + #if self._exp < 0: + # exp = (self._exp+1) // 2 + #else: + exp = (self._exp) // 2 + if self._sign == 1: + #sqrt(-0) = -0 + return Decimal( (1, (0,), exp)) + else: + return Decimal( (0, (0,), exp)) + + if context is None: + context = getcontext() + + if self._sign == 1: + return context._raise_error(InvalidOperation, 'sqrt(-x), x > 0') + + tmp = Decimal(self) + + expadd = tmp._exp // 2 + if tmp._exp & 1: + tmp._int += (0,) + tmp._exp = 0 + else: + tmp._exp = 0 + + context = context._shallow_copy() + flags = context._ignore_all_flags() + firstprec = context.prec + context.prec = 3 + if tmp.adjusted() & 1 == 0: + ans = Decimal( (0, (8,1,9), tmp.adjusted() - 2) ) + ans = ans.__add__(tmp.__mul__(Decimal((0, (2,5,9), -2)), + context=context), context=context) + ans._exp -= 1 + tmp.adjusted() // 2 + else: + ans = Decimal( (0, (2,5,9), tmp._exp + len(tmp._int)- 3) ) + ans = ans.__add__(tmp.__mul__(Decimal((0, (8,1,9), -3)), + context=context), context=context) + ans._exp -= 1 + tmp.adjusted() // 2 + + #ans is now a linear approximation. + + Emax, Emin = context.Emax, context.Emin + context.Emax, context.Emin = DefaultContext.Emax, DefaultContext.Emin + + half = Decimal('0.5') + + maxp = firstprec + 2 + rounding = context._set_rounding(ROUND_HALF_EVEN) + while 1: + context.prec = min(2*context.prec - 2, maxp) + ans = half.__mul__(ans.__add__(tmp.__div__(ans, context=context), + context=context), context=context) + if context.prec == maxp: + break + + #round to the answer's precision-- the only error can be 1 ulp. + context.prec = firstprec + prevexp = ans.adjusted() + ans = ans._round(context=context) + + #Now, check if the other last digits are better. + context.prec = firstprec + 1 + # In case we rounded up another digit and we should actually go lower. + if prevexp != ans.adjusted(): + ans._int += (0,) + ans._exp -= 1 + + + lower = ans.__sub__(Decimal((0, (5,), ans._exp-1)), context=context) + context._set_rounding(ROUND_UP) + if lower.__mul__(lower, context=context) > (tmp): + ans = ans.__sub__(Decimal((0, (1,), ans._exp)), context=context) + + else: + upper = ans.__add__(Decimal((0, (5,), ans._exp-1)),context=context) + context._set_rounding(ROUND_DOWN) + if upper.__mul__(upper, context=context) < tmp: + ans = ans.__add__(Decimal((0, (1,), ans._exp)),context=context) + + ans._exp += expadd + + context.prec = firstprec + context.rounding = rounding + ans = ans._fix(context) + + rounding = context._set_rounding_decision(NEVER_ROUND) + if not ans.__mul__(ans, context=context) == self: + # Only rounded/inexact if here. + context._regard_flags(flags) + context._raise_error(Rounded) + context._raise_error(Inexact) + else: + #Exact answer, so let's set the exponent right. + #if self._exp < 0: + # exp = (self._exp +1)// 2 + #else: + exp = self._exp // 2 + context.prec += ans._exp - exp + ans = ans._rescale(exp, context=context) + context.prec = firstprec + context._regard_flags(flags) + context.Emax, context.Emin = Emax, Emin + + return ans._fix(context) + + def max(self, other, context=None): + """Returns the larger value. + + like max(self, other) except if one is not a number, returns + 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 + # number is always returned + sn = self._isnan() + on = other._isnan() + if sn or on: + if on == 1 and sn != 2: + return self + if sn == 1 and on != 2: + return other + return self._check_nans(other, context) + + ans = self + c = self.__cmp__(other) + if c == 0: + # if both operands are finite and equal in numerical value + # then an ordering is applied: + # + # if the signs differ then max returns the operand with the + # positive sign and min returns the operand with the negative sign + # + # if the signs are the same then the exponent is used to select + # the result. + if self._sign != other._sign: + if self._sign: + ans = other + elif self._exp < other._exp and not self._sign: + ans = other + elif self._exp > other._exp and self._sign: + ans = other + elif c == -1: + ans = other + + if context is None: + context = getcontext() + if context._rounding_decision == ALWAYS_ROUND: + return ans._fix(context) + return ans + + def min(self, other, context=None): + """Returns the smaller value. + + like min(self, other) except if one is not a number, returns + 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 + # number is always returned + sn = self._isnan() + on = other._isnan() + if sn or on: + if on == 1 and sn != 2: + return self + if sn == 1 and on != 2: + return other + return self._check_nans(other, context) + + ans = self + c = self.__cmp__(other) + if c == 0: + # if both operands are finite and equal in numerical value + # then an ordering is applied: + # + # if the signs differ then max returns the operand with the + # positive sign and min returns the operand with the negative sign + # + # if the signs are the same then the exponent is used to select + # the result. + if self._sign != other._sign: + if other._sign: + ans = other + elif self._exp > other._exp and not self._sign: + ans = other + elif self._exp < other._exp and self._sign: + ans = other + elif c == 1: + ans = other + + if context is None: + context = getcontext() + if context._rounding_decision == ALWAYS_ROUND: + return ans._fix(context) + return ans + + def _isinteger(self): + """Returns whether self is an integer""" + if self._exp >= 0: + return True + rest = self._int[self._exp:] + return rest == (0,)*len(rest) + + def _iseven(self): + """Returns 1 if self is even. Assumes self is an integer.""" + if self._exp > 0: + return 1 + return self._int[-1+self._exp] & 1 == 0 + + def adjusted(self): + """Return the adjusted exponent of self""" + try: + return self._exp + len(self._int) - 1 + #If NaN or Infinity, self._exp is string + except TypeError: + return 0 + + # support for pickling, copy, and deepcopy + def __reduce__(self): + return (self.__class__, (str(self),)) + + def __copy__(self): + if type(self) == Decimal: + return self # I'm immutable; therefore I am my own clone + return self.__class__(str(self)) + + def __deepcopy__(self, memo): + if type(self) == Decimal: + return self # My components are also immutable + return self.__class__(str(self)) + +##### Context class ########################################### + + +# get rounding method function: +rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')] +for name in rounding_functions: + #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. + globalname = name[1:].upper() + val = globals()[globalname] + Decimal._pick_rounding_function[val] = name + +del name, val, globalname, rounding_functions + +class ContextManager(object): + """Helper class to simplify Context management. + + Sample usage: + + with decimal.ExtendedContext: + s = ... + return +s # Convert result to normal precision + + with decimal.getcontext() as ctx: + ctx.prec += 2 + s = ... + return +s + + """ + def __init__(self, new_context): + self.new_context = new_context + def __enter__(self): + self.saved_context = getcontext() + setcontext(self.new_context) + return self.new_context + def __exit__(self, t, v, tb): + setcontext(self.saved_context) + +class Context(object): + """Contains the context for a Decimal instance. + + Contains: + prec - precision (for use in rounding, division, square roots..) + rounding - rounding type. (how you round) + _rounding_decision - ALWAYS_ROUND, NEVER_ROUND -- do you round? + traps - If traps[exception] = 1, then the exception is + raised when it is caused. Otherwise, a value is + substituted in. + flags - When an exception is caused, flags[exception] is incremented. + (Whether or not the trap_enabler is set) + Should be reset by user of Decimal instance. + Emin - Minimum exponent + Emax - Maximum exponent + capitals - If 1, 1*10^1 is printed as 1E+1. + If 0, printed as 1e1 + _clamp - If 1, change exponents if too high (Default 0) + """ + + def __init__(self, prec=None, rounding=None, + traps=None, flags=None, + _rounding_decision=None, + Emin=None, Emax=None, + capitals=None, _clamp=0, + _ignored_flags=None): + if flags is None: + flags = [] + if _ignored_flags is None: + _ignored_flags = [] + if not isinstance(flags, dict): + flags = dict([(s,s in flags) for s in _signals]) + del s + if traps is not None and not isinstance(traps, dict): + traps = dict([(s,s in traps) for s in _signals]) + del s + for name, val in locals().items(): + if val is None: + setattr(self, name, _copy.copy(getattr(DefaultContext, name))) + else: + setattr(self, name, val) + del self.self + + def __repr__(self): + """Show the current context.""" + s = [] + s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d' % vars(self)) + s.append('flags=[' + ', '.join([f.__name__ for f, v in self.flags.items() if v]) + ']') + s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') + return ', '.join(s) + ')' + + def get_manager(self): + return ContextManager(self.copy()) + + def clear_flags(self): + """Reset all flags to zero""" + for flag in self.flags: + self.flags[flag] = 0 + + def _shallow_copy(self): + """Returns a shallow copy from self.""" + nc = Context(self.prec, self.rounding, self.traps, self.flags, + self._rounding_decision, self.Emin, self.Emax, + self.capitals, self._clamp, self._ignored_flags) + return nc + + def copy(self): + """Returns a deep copy from self.""" + nc = Context(self.prec, self.rounding, self.traps.copy(), self.flags.copy(), + self._rounding_decision, self.Emin, self.Emax, + self.capitals, self._clamp, self._ignored_flags) + return nc + __copy__ = copy + + def _raise_error(self, condition, explanation = None, *args): + """Handles an error + + If the flag is in _ignored_flags, returns the default response. + Otherwise, it increments the flag, then, if the corresponding + trap_enabler is set, it reaises the exception. Otherwise, it returns + the default value after incrementing the flag. + """ + error = _condition_map.get(condition, condition) + if error in self._ignored_flags: + #Don't touch the flag + return error().handle(self, *args) + + self.flags[error] += 1 + if not self.traps[error]: + #The errors define how to handle themselves. + return condition().handle(self, *args) + + # Errors should only be risked on copies of the context + #self._ignored_flags = [] + raise error, explanation + + def _ignore_all_flags(self): + """Ignore all flags, if they are raised""" + return self._ignore_flags(*_signals) + + def _ignore_flags(self, *flags): + """Ignore the flags, if they are raised""" + # Do not mutate-- This way, copies of a context leave the original + # alone. + self._ignored_flags = (self._ignored_flags + list(flags)) + return list(flags) + + def _regard_flags(self, *flags): + """Stop ignoring the flags, if they are raised""" + if flags and isinstance(flags[0], (tuple,list)): + flags = flags[0] + for flag in flags: + self._ignored_flags.remove(flag) + + def __hash__(self): + """A Context cannot be hashed.""" + # We inherit object.__hash__, so we must deny this explicitly + raise TypeError, "Cannot hash a Context." + + def Etiny(self): + """Returns Etiny (= Emin - prec + 1)""" + return int(self.Emin - self.prec + 1) + + def Etop(self): + """Returns maximum exponent (= Emax - prec + 1)""" + return int(self.Emax - self.prec + 1) + + def _set_rounding_decision(self, type): + """Sets the rounding decision. + + Sets the rounding decision, and returns the current (previous) + rounding decision. Often used like: + + context = context._shallow_copy() + # That so you don't change the calling context + # if an error occurs in the middle (say DivisionImpossible is raised). + + rounding = context._set_rounding_decision(NEVER_ROUND) + instance = instance / Decimal(2) + context._set_rounding_decision(rounding) + + This will make it not round for that operation. + """ + + rounding = self._rounding_decision + self._rounding_decision = type + return rounding + + def _set_rounding(self, type): + """Sets the rounding type. + + Sets the rounding type, and returns the current (previous) + rounding type. Often used like: + + context = context.copy() + # so you don't change the calling context + # if an error occurs in the middle. + rounding = context._set_rounding(ROUND_UP) + val = self.__sub__(other, context=context) + context._set_rounding(rounding) + + This will make it round up for that operation. + """ + rounding = self.rounding + self.rounding= type + return rounding + + def create_decimal(self, num='0'): + """Creates a new Decimal instance but using self as context.""" + d = Decimal(num, context=self) + return d._fix(self) + + #Methods + def abs(self, a): + """Returns the absolute value of the operand. + + If the operand is negative, the result is the same as using the minus + operation on the operand. Otherwise, the result is the same as using + the plus operation on the operand. + + >>> ExtendedContext.abs(Decimal('2.1')) + Decimal("2.1") + >>> ExtendedContext.abs(Decimal('-100')) + Decimal("100") + >>> ExtendedContext.abs(Decimal('101.5')) + Decimal("101.5") + >>> ExtendedContext.abs(Decimal('-101.5')) + Decimal("101.5") + """ + return a.__abs__(context=self) + + def add(self, a, b): + """Return the sum of the two operands. + + >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) + Decimal("19.00") + >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) + Decimal("1.02E+4") + """ + return a.__add__(b, context=self) + + def _apply(self, a): + return str(a._fix(self)) + + def compare(self, a, b): + """Compares values numerically. + + If the signs of the operands differ, a value representing each operand + ('-1' if the operand is less than zero, '0' if the operand is zero or + negative zero, or '1' if the operand is greater than zero) is used in + place of that operand for the comparison instead of the actual + operand. + + The comparison is then effected by subtracting the second operand from + the first and then returning a value according to the result of the + subtraction: '-1' if the result is less than zero, '0' if the result is + zero or negative zero, or '1' if the result is greater than zero. + + >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) + Decimal("-1") + >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) + Decimal("0") + >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) + Decimal("0") + >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) + Decimal("1") + >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) + Decimal("1") + >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) + Decimal("-1") + """ + return a.compare(b, context=self) + + def divide(self, a, b): + """Decimal division in a specified context. + + >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) + Decimal("0.333333333") + >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) + Decimal("0.666666667") + >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) + Decimal("2.5") + >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) + Decimal("0.1") + >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) + Decimal("1") + >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) + Decimal("4.00") + >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) + Decimal("1.20") + >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) + Decimal("10") + >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) + Decimal("1000") + >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) + Decimal("1.20E+6") + """ + return a.__div__(b, context=self) + + def divide_int(self, a, b): + """Divides two numbers and returns the integer part of the result. + + >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) + Decimal("0") + >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) + Decimal("3") + >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) + Decimal("3") + """ + return a.__floordiv__(b, context=self) + + def divmod(self, a, b): + return a.__divmod__(b, context=self) + + def max(self, a,b): + """max compares two values numerically and returns the maximum. + + If either operand is a NaN then the general rules apply. + Otherwise, the operands are compared as as though by the compare + operation. If they are numerically equal then the left-hand operand + is chosen as the result. Otherwise the maximum (closer to positive + infinity) of the two operands is chosen as the result. + + >>> ExtendedContext.max(Decimal('3'), Decimal('2')) + Decimal("3") + >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) + Decimal("3") + >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) + Decimal("1") + >>> ExtendedContext.max(Decimal('7'), Decimal('NaN')) + Decimal("7") + """ + return a.max(b, context=self) + + def min(self, a,b): + """min compares two values numerically and returns the minimum. + + If either operand is a NaN then the general rules apply. + Otherwise, the operands are compared as as though by the compare + operation. If they are numerically equal then the left-hand operand + is chosen as the result. Otherwise the minimum (closer to negative + infinity) of the two operands is chosen as the result. + + >>> ExtendedContext.min(Decimal('3'), Decimal('2')) + Decimal("2") + >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) + Decimal("-10") + >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) + Decimal("1.0") + >>> ExtendedContext.min(Decimal('7'), Decimal('NaN')) + Decimal("7") + """ + return a.min(b, context=self) + + def minus(self, a): + """Minus corresponds to unary prefix minus in Python. + + The operation is evaluated using the same rules as subtract; the + operation minus(a) is calculated as subtract('0', a) where the '0' + has the same exponent as the operand. + + >>> ExtendedContext.minus(Decimal('1.3')) + Decimal("-1.3") + >>> ExtendedContext.minus(Decimal('-1.3')) + Decimal("1.3") + """ + return a.__neg__(context=self) + + def multiply(self, a, b): + """multiply multiplies two operands. + + If either operand is a special value then the general rules apply. + Otherwise, the operands are multiplied together ('long multiplication'), + resulting in a number which may be as long as the sum of the lengths + of the two operands. + + >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) + Decimal("3.60") + >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) + Decimal("21") + >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) + Decimal("0.72") + >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) + Decimal("-0.0") + >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) + Decimal("4.28135971E+11") + """ + return a.__mul__(b, context=self) + + def normalize(self, a): + """normalize reduces an operand to its simplest form. + + Essentially a plus operation with all trailing zeros removed from the + result. + + >>> ExtendedContext.normalize(Decimal('2.1')) + Decimal("2.1") + >>> ExtendedContext.normalize(Decimal('-2.0')) + Decimal("-2") + >>> ExtendedContext.normalize(Decimal('1.200')) + Decimal("1.2") + >>> ExtendedContext.normalize(Decimal('-120')) + Decimal("-1.2E+2") + >>> ExtendedContext.normalize(Decimal('120.00')) + Decimal("1.2E+2") + >>> ExtendedContext.normalize(Decimal('0.00')) + Decimal("0") + """ + return a.normalize(context=self) + + def plus(self, a): + """Plus corresponds to unary prefix plus in Python. + + The operation is evaluated using the same rules as add; the + operation plus(a) is calculated as add('0', a) where the '0' + has the same exponent as the operand. + + >>> ExtendedContext.plus(Decimal('1.3')) + Decimal("1.3") + >>> ExtendedContext.plus(Decimal('-1.3')) + Decimal("-1.3") + """ + return a.__pos__(context=self) + + def power(self, a, b, modulo=None): + """Raises a to the power of b, to modulo if given. + + The right-hand operand must be a whole number whose integer part (after + any exponent has been applied) has no more than 9 digits and whose + fractional part (if any) is all zeros before any rounding. The operand + may be positive, negative, or zero; if negative, the absolute value of + the power is used, and the left-hand operand is inverted (divided into + 1) before use. + + If the increased precision needed for the intermediate calculations + exceeds the capabilities of the implementation then an Invalid operation + condition is raised. + + If, when raising to a negative power, an underflow occurs during the + division into 1, the operation is not halted at that point but + continues. + + >>> ExtendedContext.power(Decimal('2'), Decimal('3')) + Decimal("8") + >>> ExtendedContext.power(Decimal('2'), Decimal('-3')) + Decimal("0.125") + >>> ExtendedContext.power(Decimal('1.7'), Decimal('8')) + Decimal("69.7575744") + >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-2')) + Decimal("0") + >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-1')) + Decimal("0") + >>> ExtendedContext.power(Decimal('Infinity'), Decimal('0')) + Decimal("1") + >>> ExtendedContext.power(Decimal('Infinity'), Decimal('1')) + Decimal("Infinity") + >>> ExtendedContext.power(Decimal('Infinity'), Decimal('2')) + Decimal("Infinity") + >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-2')) + Decimal("0") + >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-1')) + Decimal("-0") + >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('0')) + Decimal("1") + >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('1')) + Decimal("-Infinity") + >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('2')) + Decimal("Infinity") + >>> ExtendedContext.power(Decimal('0'), Decimal('0')) + Decimal("NaN") + """ + return a.__pow__(b, modulo, context=self) + + def quantize(self, a, b): + """Returns a value equal to 'a' (rounded) and having the exponent of 'b'. + + The coefficient of the result is derived from that of the left-hand + operand. It may be rounded using the current rounding setting (if the + exponent is being increased), multiplied by a positive power of ten (if + the exponent is being decreased), or is unchanged (if the exponent is + already equal to that of the right-hand operand). + + Unlike other operations, if the length of the coefficient after the + quantize operation would be greater than precision then an Invalid + operation condition is raised. This guarantees that, unless there is an + error condition, the exponent of the result of a quantize is always + equal to that of the right-hand operand. + + Also unlike other operations, quantize will never raise Underflow, even + if the result is subnormal and inexact. + + >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) + Decimal("2.170") + >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) + Decimal("2.17") + >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) + Decimal("2.2") + >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) + Decimal("2") + >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) + Decimal("0E+1") + >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) + Decimal("-Infinity") + >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) + Decimal("NaN") + >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) + Decimal("-0") + >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) + Decimal("-0E+5") + >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) + Decimal("NaN") + >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) + Decimal("NaN") + >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) + Decimal("217.0") + >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) + Decimal("217") + >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) + Decimal("2.2E+2") + >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) + Decimal("2E+2") + """ + return a.quantize(b, context=self) + + def remainder(self, a, b): + """Returns the remainder from integer division. + + The result is the residue of the dividend after the operation of + calculating integer division as described for divide-integer, rounded to + precision digits if necessary. The sign of the result, if non-zero, is + the same as that of the original dividend. + + This operation will fail under the same conditions as integer division + (that is, if integer division on the same two operands would fail, the + remainder cannot be calculated). + + >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) + Decimal("2.1") + >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) + Decimal("1") + >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) + Decimal("-1") + >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) + Decimal("0.2") + >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) + Decimal("0.1") + >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) + Decimal("1.0") + """ + return a.__mod__(b, context=self) + + def remainder_near(self, a, b): + """Returns to be "a - b * n", where n is the integer nearest the exact + value of "x / b" (if two integers are equally near then the even one + is chosen). If the result is equal to 0 then its sign will be the + sign of a. + + This operation will fail under the same conditions as integer division + (that is, if integer division on the same two operands would fail, the + remainder cannot be calculated). + + >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) + Decimal("-0.9") + >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) + Decimal("-2") + >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) + Decimal("1") + >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) + Decimal("-1") + >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) + Decimal("0.2") + >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) + Decimal("0.1") + >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) + Decimal("-0.3") + """ + return a.remainder_near(b, context=self) + + def same_quantum(self, a, b): + """Returns True if the two operands have the same exponent. + + The result is never affected by either the sign or the coefficient of + either operand. + + >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) + False + >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01')) + True + >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1')) + False + >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) + True + """ + return a.same_quantum(b) + + def sqrt(self, a): + """Returns the square root of a non-negative number to context precision. + + If the result must be inexact, it is rounded using the round-half-even + algorithm. + + >>> ExtendedContext.sqrt(Decimal('0')) + Decimal("0") + >>> ExtendedContext.sqrt(Decimal('-0')) + Decimal("-0") + >>> ExtendedContext.sqrt(Decimal('0.39')) + Decimal("0.624499800") + >>> ExtendedContext.sqrt(Decimal('100')) + Decimal("10") + >>> ExtendedContext.sqrt(Decimal('1')) + Decimal("1") + >>> ExtendedContext.sqrt(Decimal('1.0')) + Decimal("1.0") + >>> ExtendedContext.sqrt(Decimal('1.00')) + Decimal("1.0") + >>> ExtendedContext.sqrt(Decimal('7')) + Decimal("2.64575131") + >>> ExtendedContext.sqrt(Decimal('10')) + Decimal("3.16227766") + >>> ExtendedContext.prec + 9 + """ + return a.sqrt(context=self) + + def subtract(self, a, b): + """Return the difference between the two operands. + + >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) + Decimal("0.23") + >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) + Decimal("0.00") + >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) + Decimal("-0.77") + """ + return a.__sub__(b, context=self) + + def to_eng_string(self, a): + """Converts a number to a string, using scientific notation. + + The operation is not affected by the context. + """ + return a.to_eng_string(context=self) + + def to_sci_string(self, a): + """Converts a number to a string, using scientific notation. + + The operation is not affected by the context. + """ + return a.__str__(context=self) + + def to_integral(self, a): + """Rounds to an integer. + + When the operand has a negative exponent, the result is the same + as using the quantize() operation using the given operand as the + left-hand-operand, 1E+0 as the right-hand-operand, and the precision + of the operand as the precision setting, except that no flags will + be set. The rounding mode is taken from the context. + + >>> ExtendedContext.to_integral(Decimal('2.1')) + Decimal("2") + >>> ExtendedContext.to_integral(Decimal('100')) + Decimal("100") + >>> ExtendedContext.to_integral(Decimal('100.0')) + Decimal("100") + >>> ExtendedContext.to_integral(Decimal('101.5')) + Decimal("102") + >>> ExtendedContext.to_integral(Decimal('-101.5')) + Decimal("-102") + >>> ExtendedContext.to_integral(Decimal('10E+5')) + Decimal("1.0E+6") + >>> ExtendedContext.to_integral(Decimal('7.89E+77')) + Decimal("7.89E+77") + >>> ExtendedContext.to_integral(Decimal('-Inf')) + Decimal("-Infinity") + """ + return a.to_integral(context=self) + +class _WorkRep(object): + __slots__ = ('sign','int','exp') + # sign: 0 or 1 + # int: int or long + # exp: None, int, or string + + def __init__(self, value=None): + if value is None: + self.sign = None + self.int = 0 + self.exp = None + elif isinstance(value, Decimal): + self.sign = value._sign + cum = 0 + for digit in value._int: + cum = cum * 10 + digit + self.int = cum + self.exp = value._exp + else: + # assert isinstance(value, tuple) + self.sign = value[0] + self.int = value[1] + self.exp = value[2] + + def __repr__(self): + return "(%r, %r, %r)" % (self.sign, self.int, self.exp) + + __str__ = __repr__ + + + +def _normalize(op1, op2, shouldround = 0, prec = 0): + """Normalizes op1, op2 to have the same exp and length of coefficient. + + Done during addition. + """ + # Yes, the exponent is a long, but the difference between exponents + # must be an int-- otherwise you'd get a big memory problem. + numdigits = int(op1.exp - op2.exp) + if numdigits < 0: + numdigits = -numdigits + tmp = op2 + other = op1 + else: + tmp = op1 + other = op2 + + + if shouldround and numdigits > prec + 1: + # Big difference in exponents - check the adjusted exponents + tmp_len = len(str(tmp.int)) + other_len = len(str(other.int)) + if numdigits > (other_len + prec + 1 - tmp_len): + # If the difference in adjusted exps is > prec+1, we know + # other is insignificant, so might as well put a 1 after the precision. + # (since this is only for addition.) Also stops use of massive longs. + + extend = prec + 2 - tmp_len + if extend <= 0: + extend = 1 + tmp.int *= 10 ** extend + tmp.exp -= extend + other.int = 1 + other.exp = tmp.exp + return op1, op2 + + tmp.int *= 10 ** numdigits + tmp.exp -= numdigits + return op1, op2 + +def _adjust_coefficients(op1, op2): + """Adjust op1, op2 so that op2.int * 10 > op1.int >= op2.int. + + Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. + + Used on _WorkRep instances during division. + """ + adjust = 0 + #If op1 is smaller, make it larger + while op2.int > op1.int: + op1.int *= 10 + op1.exp -= 1 + adjust += 1 + + #If op2 is too small, make it larger + while op1.int >= (10 * op2.int): + op2.int *= 10 + op2.exp -= 1 + adjust -= 1 + + return op1, op2, adjust + +##### Helper Functions ######################################## + +def _convert_other(other): + """Convert other to Decimal. + + Verifies that it's ok to use in an implicit construction. + """ + if isinstance(other, Decimal): + return other + if isinstance(other, (int, long)): + return Decimal(other) + return NotImplemented + +_infinity_map = { + 'inf' : 1, + 'infinity' : 1, + '+inf' : 1, + '+infinity' : 1, + '-inf' : -1, + '-infinity' : -1 +} + +def _isinfinity(num): + """Determines whether a string or float is infinity. + + +1 for negative infinity; 0 for finite ; +1 for positive infinity + """ + num = str(num).lower() + return _infinity_map.get(num, 0) + +def _isnan(num): + """Determines whether a string or float is NaN + + (1, sign, diagnostic info as string) => NaN + (2, sign, diagnostic info as string) => sNaN + 0 => not a NaN + """ + num = str(num).lower() + if not num: + return 0 + + #get the sign, get rid of trailing [+-] + sign = 0 + if num[0] == '+': + num = num[1:] + elif num[0] == '-': #elif avoids '+-nan' + num = num[1:] + sign = 1 + + if num.startswith('nan'): + if len(num) > 3 and not num[3:].isdigit(): #diagnostic info + return 0 + return (1, sign, num[3:].lstrip('0')) + if num.startswith('snan'): + if len(num) > 4 and not num[4:].isdigit(): + return 0 + return (2, sign, num[4:].lstrip('0')) + return 0 + + +##### Setup Specific Contexts ################################ + +# The default context prototype used by Context() +# Is mutable, so that new contexts can have different default values + +DefaultContext = Context( + prec=28, rounding=ROUND_HALF_EVEN, + traps=[DivisionByZero, Overflow, InvalidOperation], + flags=[], + _rounding_decision=ALWAYS_ROUND, + Emax=999999999, + Emin=-999999999, + capitals=1 +) + +# Pre-made alternate contexts offered by the specification +# Don't change these; the user should be able to select these +# contexts and be able to reproduce results from other implementations +# of the spec. + +BasicContext = Context( + prec=9, rounding=ROUND_HALF_UP, + traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], + flags=[], +) + +ExtendedContext = Context( + prec=9, rounding=ROUND_HALF_EVEN, + traps=[], + flags=[], +) + + +##### Useful Constants (internal use only) #################### + +#Reusable defaults +Inf = Decimal('Inf') +negInf = Decimal('-Inf') + +#Infsign[sign] is infinity w/ that sign +Infsign = (Inf, negInf) + +NaN = Decimal('NaN') + + +##### crud for parsing strings ################################# +import re + +# There's an optional sign at the start, and an optional exponent +# at the end. The exponent has an optional sign and at least one +# digit. In between, must have either at least one digit followed +# by an optional fraction, or a decimal point followed by at least +# one digit. Yuck. + +_parser = re.compile(r""" +# \s* + (?P[-+])? + ( + (?P\d+) (\. (?P\d*))? + | + \. (?P\d+) + ) + ([eE](?P[-+]? \d+))? +# \s* + $ +""", re.VERBOSE).match #Uncomment the \s* to allow leading or trailing spaces. + +del re + +# return sign, n, p s.t. float string value == -1**sign * n * 10**p exactly + +def _string2exact(s): + m = _parser(s) + if m is None: + raise ValueError("invalid literal for Decimal: %r" % s) + + if m.group('sign') == "-": + sign = 1 + else: + sign = 0 + + exp = m.group('exp') + if exp is None: + exp = 0 + else: + exp = int(exp) + + intpart = m.group('int') + if intpart is None: + intpart = "" + fracpart = m.group('onlyfrac') + else: + fracpart = m.group('frac') + if fracpart is None: + fracpart = "" + + exp -= len(fracpart) + + mantissa = intpart + fracpart + tmp = map(int, mantissa) + backup = tmp + while tmp and tmp[0] == 0: + del tmp[0] + + # It's a zero + if not tmp: + if backup: + return (sign, tuple(backup), exp) + return (sign, (0,), exp) + mantissa = tuple(tmp) + + return (sign, mantissa, exp) + + +if __name__ == '__main__': + import doctest, sys + doctest.testmod(sys.modules[__name__]) Added: sandbox/trunk/decimal-c/decimaltestdata/abs.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/abs.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,161 @@ +------------------------------------------------------------------------ +-- abs.decTest -- decimal absolute value -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests primarily tests the existence of the operator. +-- Additon, subtraction, rounding, and more overflows are tested +-- elsewhere. + +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 +extended: 1 + +absx001 abs '1' -> '1' +absx002 abs '-1' -> '1' +absx003 abs '1.00' -> '1.00' +absx004 abs '-1.00' -> '1.00' +absx005 abs '0' -> '0' +absx006 abs '0.00' -> '0.00' +absx007 abs '00.0' -> '0.0' +absx008 abs '00.00' -> '0.00' +absx009 abs '00' -> '0' + +absx010 abs '-2' -> '2' +absx011 abs '2' -> '2' +absx012 abs '-2.00' -> '2.00' +absx013 abs '2.00' -> '2.00' +absx014 abs '-0' -> '0' +absx015 abs '-0.00' -> '0.00' +absx016 abs '-00.0' -> '0.0' +absx017 abs '-00.00' -> '0.00' +absx018 abs '-00' -> '0' + +absx020 abs '-2000000' -> '2000000' +absx021 abs '2000000' -> '2000000' +precision: 7 +absx022 abs '-2000000' -> '2000000' +absx023 abs '2000000' -> '2000000' +precision: 6 +absx024 abs '-2000000' -> '2.00000E+6' Rounded +absx025 abs '2000000' -> '2.00000E+6' Rounded +precision: 3 +absx026 abs '-2000000' -> '2.00E+6' Rounded +absx027 abs '2000000' -> '2.00E+6' Rounded + +absx030 abs '+0.1' -> '0.1' +absx031 abs '-0.1' -> '0.1' +absx032 abs '+0.01' -> '0.01' +absx033 abs '-0.01' -> '0.01' +absx034 abs '+0.001' -> '0.001' +absx035 abs '-0.001' -> '0.001' +absx036 abs '+0.000001' -> '0.000001' +absx037 abs '-0.000001' -> '0.000001' +absx038 abs '+0.000000000001' -> '1E-12' +absx039 abs '-0.000000000001' -> '1E-12' + +-- examples from decArith +precision: 9 +absx040 abs '2.1' -> '2.1' +absx041 abs '-100' -> '100' +absx042 abs '101.5' -> '101.5' +absx043 abs '-101.5' -> '101.5' + +-- more fixed, potential LHS swaps/overlays if done by subtract 0 +precision: 9 +absx060 abs '-56267E-10' -> '0.0000056267' +absx061 abs '-56267E-5' -> '0.56267' +absx062 abs '-56267E-2' -> '562.67' +absx063 abs '-56267E-1' -> '5626.7' +absx065 abs '-56267E-0' -> '56267' + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +absx210 abs 1.00E-999 -> 1.00E-999 +absx211 abs 0.1E-999 -> 1E-1000 Subnormal +absx212 abs 0.10E-999 -> 1.0E-1000 Subnormal +absx213 abs 0.100E-999 -> 1.0E-1000 Subnormal Rounded +absx214 abs 0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow +absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow + +absx230 abs -1.00E-999 -> 1.00E-999 +absx231 abs -0.1E-999 -> 1E-1000 Subnormal +absx232 abs -0.10E-999 -> 1.0E-1000 Subnormal +absx233 abs -0.100E-999 -> 1.0E-1000 Subnormal Rounded +absx234 abs -0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow +absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow + +-- long operand tests +maxexponent: 999 +minexponent: -999 +precision: 9 +absx301 abs 12345678000 -> 1.23456780E+10 Rounded +absx302 abs 1234567800 -> 1.23456780E+9 Rounded +absx303 abs 1234567890 -> 1.23456789E+9 Rounded +absx304 abs 1234567891 -> 1.23456789E+9 Inexact Rounded +absx305 abs 12345678901 -> 1.23456789E+10 Inexact Rounded +absx306 abs 1234567896 -> 1.23456790E+9 Inexact Rounded + +precision: 15 +absx321 abs 12345678000 -> 12345678000 +absx322 abs 1234567800 -> 1234567800 +absx323 abs 1234567890 -> 1234567890 +absx324 abs 1234567891 -> 1234567891 +absx325 abs 12345678901 -> 12345678901 +absx326 abs 1234567896 -> 1234567896 + + +-- Specials +precision: 9 + +-- specials +absx520 abs 'Inf' -> 'Infinity' +absx521 abs '-Inf' -> 'Infinity' +absx522 abs NaN -> NaN +absx523 abs sNaN -> NaN Invalid_operation +absx524 abs NaN22 -> NaN22 +absx525 abs sNaN33 -> NaN33 Invalid_operation +absx526 abs -NaN22 -> -NaN22 +absx527 abs -sNaN33 -> -NaN33 Invalid_operation + +-- Null tests +absx900 abs # -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/add.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/add.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,1127 @@ +------------------------------------------------------------------------ +-- add.decTest -- decimal addition -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 +extended: 1 + +-- [first group are 'quick confidence check'] +addx001 add 1 1 -> 2 +addx002 add 2 3 -> 5 +addx003 add '5.75' '3.3' -> 9.05 +addx004 add '5' '-3' -> 2 +addx005 add '-5' '-3' -> -8 +addx006 add '-7' '2.5' -> -4.5 +addx007 add '0.7' '0.3' -> 1.0 +addx008 add '1.25' '1.25' -> 2.50 +addx009 add '1.23456789' '1.00000000' -> '2.23456789' +addx010 add '1.23456789' '1.00000011' -> '2.23456800' + +addx011 add '0.4444444444' '0.5555555555' -> '1.00000000' Inexact Rounded +addx012 add '0.4444444440' '0.5555555555' -> '1.00000000' Inexact Rounded +addx013 add '0.4444444444' '0.5555555550' -> '0.999999999' Inexact Rounded +addx014 add '0.44444444449' '0' -> '0.444444444' Inexact Rounded +addx015 add '0.444444444499' '0' -> '0.444444444' Inexact Rounded +addx016 add '0.4444444444999' '0' -> '0.444444444' Inexact Rounded +addx017 add '0.4444444445000' '0' -> '0.444444445' Inexact Rounded +addx018 add '0.4444444445001' '0' -> '0.444444445' Inexact Rounded +addx019 add '0.444444444501' '0' -> '0.444444445' Inexact Rounded +addx020 add '0.44444444451' '0' -> '0.444444445' Inexact Rounded + +addx021 add 0 1 -> 1 +addx022 add 1 1 -> 2 +addx023 add 2 1 -> 3 +addx024 add 3 1 -> 4 +addx025 add 4 1 -> 5 +addx026 add 5 1 -> 6 +addx027 add 6 1 -> 7 +addx028 add 7 1 -> 8 +addx029 add 8 1 -> 9 +addx030 add 9 1 -> 10 + +-- some carrying effects +addx031 add '0.9998' '0.0000' -> '0.9998' +addx032 add '0.9998' '0.0001' -> '0.9999' +addx033 add '0.9998' '0.0002' -> '1.0000' +addx034 add '0.9998' '0.0003' -> '1.0001' + +addx035 add '70' '10000e+9' -> '1.00000000E+13' Inexact Rounded +addx036 add '700' '10000e+9' -> '1.00000000E+13' Inexact Rounded +addx037 add '7000' '10000e+9' -> '1.00000000E+13' Inexact Rounded +addx038 add '70000' '10000e+9' -> '1.00000001E+13' Inexact Rounded +addx039 add '700000' '10000e+9' -> '1.00000007E+13' Rounded + +-- symmetry: +addx040 add '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded +addx041 add '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded +addx042 add '10000e+9' '7000' -> '1.00000000E+13' Inexact Rounded +addx044 add '10000e+9' '70000' -> '1.00000001E+13' Inexact Rounded +addx045 add '10000e+9' '700000' -> '1.00000007E+13' Rounded + +-- same, higher precision +precision: 15 +addx046 add '10000e+9' '7' -> '10000000000007' +addx047 add '10000e+9' '70' -> '10000000000070' +addx048 add '10000e+9' '700' -> '10000000000700' +addx049 add '10000e+9' '7000' -> '10000000007000' +addx050 add '10000e+9' '70000' -> '10000000070000' +addx051 add '10000e+9' '700000' -> '10000000700000' + +-- examples from decarith +addx053 add '12' '7.00' -> '19.00' +addx054 add '1.3' '-1.07' -> '0.23' +addx055 add '1.3' '-1.30' -> '0.00' +addx056 add '1.3' '-2.07' -> '-0.77' +addx057 add '1E+2' '1E+4' -> '1.01E+4' + +-- zero preservation +precision: 6 +addx060 add '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded +addx061 add 1 '0.0001' -> '1.0001' +addx062 add 1 '0.00001' -> '1.00001' +addx063 add 1 '0.000001' -> '1.00000' Inexact Rounded +addx064 add 1 '0.0000001' -> '1.00000' Inexact Rounded +addx065 add 1 '0.00000001' -> '1.00000' Inexact Rounded + +-- some funny zeros [in case of bad signum] +addx070 add 1 0 -> 1 +addx071 add 1 0. -> 1 +addx072 add 1 .0 -> 1.0 +addx073 add 1 0.0 -> 1.0 +addx074 add 1 0.00 -> 1.00 +addx075 add 0 1 -> 1 +addx076 add 0. 1 -> 1 +addx077 add .0 1 -> 1.0 +addx078 add 0.0 1 -> 1.0 +addx079 add 0.00 1 -> 1.00 + +precision: 9 + +-- some carries +addx080 add 999999998 1 -> 999999999 +addx081 add 999999999 1 -> 1.00000000E+9 Rounded +addx082 add 99999999 1 -> 100000000 +addx083 add 9999999 1 -> 10000000 +addx084 add 999999 1 -> 1000000 +addx085 add 99999 1 -> 100000 +addx086 add 9999 1 -> 10000 +addx087 add 999 1 -> 1000 +addx088 add 99 1 -> 100 +addx089 add 9 1 -> 10 + + +-- more LHS swaps +addx090 add '-56267E-10' 0 -> '-0.0000056267' +addx091 add '-56267E-6' 0 -> '-0.056267' +addx092 add '-56267E-5' 0 -> '-0.56267' +addx093 add '-56267E-4' 0 -> '-5.6267' +addx094 add '-56267E-3' 0 -> '-56.267' +addx095 add '-56267E-2' 0 -> '-562.67' +addx096 add '-56267E-1' 0 -> '-5626.7' +addx097 add '-56267E-0' 0 -> '-56267' +addx098 add '-5E-10' 0 -> '-5E-10' +addx099 add '-5E-7' 0 -> '-5E-7' +addx100 add '-5E-6' 0 -> '-0.000005' +addx101 add '-5E-5' 0 -> '-0.00005' +addx102 add '-5E-4' 0 -> '-0.0005' +addx103 add '-5E-1' 0 -> '-0.5' +addx104 add '-5E0' 0 -> '-5' +addx105 add '-5E1' 0 -> '-50' +addx106 add '-5E5' 0 -> '-500000' +addx107 add '-5E8' 0 -> '-500000000' +addx108 add '-5E9' 0 -> '-5.00000000E+9' Rounded +addx109 add '-5E10' 0 -> '-5.00000000E+10' Rounded +addx110 add '-5E11' 0 -> '-5.00000000E+11' Rounded +addx111 add '-5E100' 0 -> '-5.00000000E+100' Rounded + +-- more RHS swaps +addx113 add 0 '-56267E-10' -> '-0.0000056267' +addx114 add 0 '-56267E-6' -> '-0.056267' +addx116 add 0 '-56267E-5' -> '-0.56267' +addx117 add 0 '-56267E-4' -> '-5.6267' +addx119 add 0 '-56267E-3' -> '-56.267' +addx120 add 0 '-56267E-2' -> '-562.67' +addx121 add 0 '-56267E-1' -> '-5626.7' +addx122 add 0 '-56267E-0' -> '-56267' +addx123 add 0 '-5E-10' -> '-5E-10' +addx124 add 0 '-5E-7' -> '-5E-7' +addx125 add 0 '-5E-6' -> '-0.000005' +addx126 add 0 '-5E-5' -> '-0.00005' +addx127 add 0 '-5E-4' -> '-0.0005' +addx128 add 0 '-5E-1' -> '-0.5' +addx129 add 0 '-5E0' -> '-5' +addx130 add 0 '-5E1' -> '-50' +addx131 add 0 '-5E5' -> '-500000' +addx132 add 0 '-5E8' -> '-500000000' +addx133 add 0 '-5E9' -> '-5.00000000E+9' Rounded +addx134 add 0 '-5E10' -> '-5.00000000E+10' Rounded +addx135 add 0 '-5E11' -> '-5.00000000E+11' Rounded +addx136 add 0 '-5E100' -> '-5.00000000E+100' Rounded + +-- related +addx137 add 1 '0E-12' -> '1.00000000' Rounded +addx138 add -1 '0E-12' -> '-1.00000000' Rounded +addx139 add '0E-12' 1 -> '1.00000000' Rounded +addx140 add '0E-12' -1 -> '-1.00000000' Rounded +addx141 add 1E+4 0.0000 -> '10000.0000' +addx142 add 1E+4 0.00000 -> '10000.0000' Rounded +addx143 add 0.000 1E+5 -> '100000.000' +addx144 add 0.0000 1E+5 -> '100000.000' Rounded + +-- [some of the next group are really constructor tests] +addx146 add '00.0' 0 -> '0.0' +addx147 add '0.00' 0 -> '0.00' +addx148 add 0 '0.00' -> '0.00' +addx149 add 0 '00.0' -> '0.0' +addx150 add '00.0' '0.00' -> '0.00' +addx151 add '0.00' '00.0' -> '0.00' +addx152 add '3' '.3' -> '3.3' +addx153 add '3.' '.3' -> '3.3' +addx154 add '3.0' '.3' -> '3.3' +addx155 add '3.00' '.3' -> '3.30' +addx156 add '3' '3' -> '6' +addx157 add '3' '+3' -> '6' +addx158 add '3' '-3' -> '0' +addx159 add '0.3' '-0.3' -> '0.0' +addx160 add '0.03' '-0.03' -> '0.00' + +-- try borderline precision, with carries, etc. +precision: 15 +addx161 add '1E+12' '-1' -> '999999999999' +addx162 add '1E+12' '1.11' -> '1000000000001.11' +addx163 add '1.11' '1E+12' -> '1000000000001.11' +addx164 add '-1' '1E+12' -> '999999999999' +addx165 add '7E+12' '-1' -> '6999999999999' +addx166 add '7E+12' '1.11' -> '7000000000001.11' +addx167 add '1.11' '7E+12' -> '7000000000001.11' +addx168 add '-1' '7E+12' -> '6999999999999' + +-- 123456789012345 123456789012345 1 23456789012345 +addx170 add '0.444444444444444' '0.555555555555563' -> '1.00000000000001' Inexact Rounded +addx171 add '0.444444444444444' '0.555555555555562' -> '1.00000000000001' Inexact Rounded +addx172 add '0.444444444444444' '0.555555555555561' -> '1.00000000000001' Inexact Rounded +addx173 add '0.444444444444444' '0.555555555555560' -> '1.00000000000000' Inexact Rounded +addx174 add '0.444444444444444' '0.555555555555559' -> '1.00000000000000' Inexact Rounded +addx175 add '0.444444444444444' '0.555555555555558' -> '1.00000000000000' Inexact Rounded +addx176 add '0.444444444444444' '0.555555555555557' -> '1.00000000000000' Inexact Rounded +addx177 add '0.444444444444444' '0.555555555555556' -> '1.00000000000000' Rounded +addx178 add '0.444444444444444' '0.555555555555555' -> '0.999999999999999' +addx179 add '0.444444444444444' '0.555555555555554' -> '0.999999999999998' +addx180 add '0.444444444444444' '0.555555555555553' -> '0.999999999999997' +addx181 add '0.444444444444444' '0.555555555555552' -> '0.999999999999996' +addx182 add '0.444444444444444' '0.555555555555551' -> '0.999999999999995' +addx183 add '0.444444444444444' '0.555555555555550' -> '0.999999999999994' + +-- and some more, including residue effects and different roundings +precision: 9 +rounding: half_up +addx200 add '123456789' 0 -> '123456789' +addx201 add '123456789' 0.000000001 -> '123456789' Inexact Rounded +addx202 add '123456789' 0.000001 -> '123456789' Inexact Rounded +addx203 add '123456789' 0.1 -> '123456789' Inexact Rounded +addx204 add '123456789' 0.4 -> '123456789' Inexact Rounded +addx205 add '123456789' 0.49 -> '123456789' Inexact Rounded +addx206 add '123456789' 0.499999 -> '123456789' Inexact Rounded +addx207 add '123456789' 0.499999999 -> '123456789' Inexact Rounded +addx208 add '123456789' 0.5 -> '123456790' Inexact Rounded +addx209 add '123456789' 0.500000001 -> '123456790' Inexact Rounded +addx210 add '123456789' 0.500001 -> '123456790' Inexact Rounded +addx211 add '123456789' 0.51 -> '123456790' Inexact Rounded +addx212 add '123456789' 0.6 -> '123456790' Inexact Rounded +addx213 add '123456789' 0.9 -> '123456790' Inexact Rounded +addx214 add '123456789' 0.99999 -> '123456790' Inexact Rounded +addx215 add '123456789' 0.999999999 -> '123456790' Inexact Rounded +addx216 add '123456789' 1 -> '123456790' +addx217 add '123456789' 1.000000001 -> '123456790' Inexact Rounded +addx218 add '123456789' 1.00001 -> '123456790' Inexact Rounded +addx219 add '123456789' 1.1 -> '123456790' Inexact Rounded + +rounding: half_even +addx220 add '123456789' 0 -> '123456789' +addx221 add '123456789' 0.000000001 -> '123456789' Inexact Rounded +addx222 add '123456789' 0.000001 -> '123456789' Inexact Rounded +addx223 add '123456789' 0.1 -> '123456789' Inexact Rounded +addx224 add '123456789' 0.4 -> '123456789' Inexact Rounded +addx225 add '123456789' 0.49 -> '123456789' Inexact Rounded +addx226 add '123456789' 0.499999 -> '123456789' Inexact Rounded +addx227 add '123456789' 0.499999999 -> '123456789' Inexact Rounded +addx228 add '123456789' 0.5 -> '123456790' Inexact Rounded +addx229 add '123456789' 0.500000001 -> '123456790' Inexact Rounded +addx230 add '123456789' 0.500001 -> '123456790' Inexact Rounded +addx231 add '123456789' 0.51 -> '123456790' Inexact Rounded +addx232 add '123456789' 0.6 -> '123456790' Inexact Rounded +addx233 add '123456789' 0.9 -> '123456790' Inexact Rounded +addx234 add '123456789' 0.99999 -> '123456790' Inexact Rounded +addx235 add '123456789' 0.999999999 -> '123456790' Inexact Rounded +addx236 add '123456789' 1 -> '123456790' +addx237 add '123456789' 1.00000001 -> '123456790' Inexact Rounded +addx238 add '123456789' 1.00001 -> '123456790' Inexact Rounded +addx239 add '123456789' 1.1 -> '123456790' Inexact Rounded +-- critical few with even bottom digit... +addx240 add '123456788' 0.499999999 -> '123456788' Inexact Rounded +addx241 add '123456788' 0.5 -> '123456788' Inexact Rounded +addx242 add '123456788' 0.500000001 -> '123456789' Inexact Rounded + +rounding: down +addx250 add '123456789' 0 -> '123456789' +addx251 add '123456789' 0.000000001 -> '123456789' Inexact Rounded +addx252 add '123456789' 0.000001 -> '123456789' Inexact Rounded +addx253 add '123456789' 0.1 -> '123456789' Inexact Rounded +addx254 add '123456789' 0.4 -> '123456789' Inexact Rounded +addx255 add '123456789' 0.49 -> '123456789' Inexact Rounded +addx256 add '123456789' 0.499999 -> '123456789' Inexact Rounded +addx257 add '123456789' 0.499999999 -> '123456789' Inexact Rounded +addx258 add '123456789' 0.5 -> '123456789' Inexact Rounded +addx259 add '123456789' 0.500000001 -> '123456789' Inexact Rounded +addx260 add '123456789' 0.500001 -> '123456789' Inexact Rounded +addx261 add '123456789' 0.51 -> '123456789' Inexact Rounded +addx262 add '123456789' 0.6 -> '123456789' Inexact Rounded +addx263 add '123456789' 0.9 -> '123456789' Inexact Rounded +addx264 add '123456789' 0.99999 -> '123456789' Inexact Rounded +addx265 add '123456789' 0.999999999 -> '123456789' Inexact Rounded +addx266 add '123456789' 1 -> '123456790' +addx267 add '123456789' 1.00000001 -> '123456790' Inexact Rounded +addx268 add '123456789' 1.00001 -> '123456790' Inexact Rounded +addx269 add '123456789' 1.1 -> '123456790' Inexact Rounded + +-- input preparation tests (operands should not be rounded) +precision: 3 +rounding: half_up + +addx270 add '12345678900000' 9999999999999 -> '2.23E+13' Inexact Rounded +addx271 add '9999999999999' 12345678900000 -> '2.23E+13' Inexact Rounded + +addx272 add '12E+3' '3444' -> '1.54E+4' Inexact Rounded +addx273 add '12E+3' '3446' -> '1.54E+4' Inexact Rounded +addx274 add '12E+3' '3449.9' -> '1.54E+4' Inexact Rounded +addx275 add '12E+3' '3450.0' -> '1.55E+4' Inexact Rounded +addx276 add '12E+3' '3450.1' -> '1.55E+4' Inexact Rounded +addx277 add '12E+3' '3454' -> '1.55E+4' Inexact Rounded +addx278 add '12E+3' '3456' -> '1.55E+4' Inexact Rounded + +addx281 add '3444' '12E+3' -> '1.54E+4' Inexact Rounded +addx282 add '3446' '12E+3' -> '1.54E+4' Inexact Rounded +addx283 add '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded +addx284 add '3450.0' '12E+3' -> '1.55E+4' Inexact Rounded +addx285 add '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded +addx286 add '3454' '12E+3' -> '1.55E+4' Inexact Rounded +addx287 add '3456' '12E+3' -> '1.55E+4' Inexact Rounded + +rounding: half_down +addx291 add '3444' '12E+3' -> '1.54E+4' Inexact Rounded +addx292 add '3446' '12E+3' -> '1.54E+4' Inexact Rounded +addx293 add '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded +addx294 add '3450.0' '12E+3' -> '1.54E+4' Inexact Rounded +addx295 add '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded +addx296 add '3454' '12E+3' -> '1.55E+4' Inexact Rounded +addx297 add '3456' '12E+3' -> '1.55E+4' Inexact Rounded + +-- 1 in last place tests +rounding: half_up +addx301 add -1 1 -> 0 +addx302 add 0 1 -> 1 +addx303 add 1 1 -> 2 +addx304 add 12 1 -> 13 +addx305 add 98 1 -> 99 +addx306 add 99 1 -> 100 +addx307 add 100 1 -> 101 +addx308 add 101 1 -> 102 +addx309 add -1 -1 -> -2 +addx310 add 0 -1 -> -1 +addx311 add 1 -1 -> 0 +addx312 add 12 -1 -> 11 +addx313 add 98 -1 -> 97 +addx314 add 99 -1 -> 98 +addx315 add 100 -1 -> 99 +addx316 add 101 -1 -> 100 + +addx321 add -0.01 0.01 -> 0.00 +addx322 add 0.00 0.01 -> 0.01 +addx323 add 0.01 0.01 -> 0.02 +addx324 add 0.12 0.01 -> 0.13 +addx325 add 0.98 0.01 -> 0.99 +addx326 add 0.99 0.01 -> 1.00 +addx327 add 1.00 0.01 -> 1.01 +addx328 add 1.01 0.01 -> 1.02 +addx329 add -0.01 -0.01 -> -0.02 +addx330 add 0.00 -0.01 -> -0.01 +addx331 add 0.01 -0.01 -> 0.00 +addx332 add 0.12 -0.01 -> 0.11 +addx333 add 0.98 -0.01 -> 0.97 +addx334 add 0.99 -0.01 -> 0.98 +addx335 add 1.00 -0.01 -> 0.99 +addx336 add 1.01 -0.01 -> 1.00 + +-- some more cases where adding 0 affects the coefficient +precision: 9 +addx340 add 1E+3 0 -> 1000 +addx341 add 1E+8 0 -> 100000000 +addx342 add 1E+9 0 -> 1.00000000E+9 Rounded +addx343 add 1E+10 0 -> 1.00000000E+10 Rounded +-- which simply follow from these cases ... +addx344 add 1E+3 1 -> 1001 +addx345 add 1E+8 1 -> 100000001 +addx346 add 1E+9 1 -> 1.00000000E+9 Inexact Rounded +addx347 add 1E+10 1 -> 1.00000000E+10 Inexact Rounded +addx348 add 1E+3 7 -> 1007 +addx349 add 1E+8 7 -> 100000007 +addx350 add 1E+9 7 -> 1.00000001E+9 Inexact Rounded +addx351 add 1E+10 7 -> 1.00000000E+10 Inexact Rounded + +-- tryzeros cases +precision: 7 +rounding: half_up +maxExponent: 92 +minexponent: -92 +addx361 add 0E+50 10000E+1 -> 1.0000E+5 +addx362 add 10000E+1 0E-50 -> 100000.0 Rounded +addx363 add 10000E+1 10000E-50 -> 100000.0 Rounded Inexact + +-- a curiosity from JSR 13 testing +rounding: half_down +precision: 10 +addx370 add 99999999 81512 -> 100081511 +precision: 6 +addx371 add 99999999 81512 -> 1.00082E+8 Rounded Inexact +rounding: half_up +precision: 10 +addx372 add 99999999 81512 -> 100081511 +precision: 6 +addx373 add 99999999 81512 -> 1.00082E+8 Rounded Inexact +rounding: half_even +precision: 10 +addx374 add 99999999 81512 -> 100081511 +precision: 6 +addx375 add 99999999 81512 -> 1.00082E+8 Rounded Inexact + +-- ulp replacement tests +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +addx400 add 1 77e-7 -> 1.0000077 +addx401 add 1 77e-8 -> 1.00000077 +addx402 add 1 77e-9 -> 1.00000008 Inexact Rounded +addx403 add 1 77e-10 -> 1.00000001 Inexact Rounded +addx404 add 1 77e-11 -> 1.00000000 Inexact Rounded +addx405 add 1 77e-12 -> 1.00000000 Inexact Rounded +addx406 add 1 77e-999 -> 1.00000000 Inexact Rounded +addx407 add 1 77e-9999999 -> 1.00000000 Inexact Rounded + +addx410 add 10 77e-7 -> 10.0000077 +addx411 add 10 77e-8 -> 10.0000008 Inexact Rounded +addx412 add 10 77e-9 -> 10.0000001 Inexact Rounded +addx413 add 10 77e-10 -> 10.0000000 Inexact Rounded +addx414 add 10 77e-11 -> 10.0000000 Inexact Rounded +addx415 add 10 77e-12 -> 10.0000000 Inexact Rounded +addx416 add 10 77e-999 -> 10.0000000 Inexact Rounded +addx417 add 10 77e-9999999 -> 10.0000000 Inexact Rounded + +addx420 add 77e-7 1 -> 1.0000077 +addx421 add 77e-8 1 -> 1.00000077 +addx422 add 77e-9 1 -> 1.00000008 Inexact Rounded +addx423 add 77e-10 1 -> 1.00000001 Inexact Rounded +addx424 add 77e-11 1 -> 1.00000000 Inexact Rounded +addx425 add 77e-12 1 -> 1.00000000 Inexact Rounded +addx426 add 77e-999 1 -> 1.00000000 Inexact Rounded +addx427 add 77e-9999999 1 -> 1.00000000 Inexact Rounded + +addx430 add 77e-7 10 -> 10.0000077 +addx431 add 77e-8 10 -> 10.0000008 Inexact Rounded +addx432 add 77e-9 10 -> 10.0000001 Inexact Rounded +addx433 add 77e-10 10 -> 10.0000000 Inexact Rounded +addx434 add 77e-11 10 -> 10.0000000 Inexact Rounded +addx435 add 77e-12 10 -> 10.0000000 Inexact Rounded +addx436 add 77e-999 10 -> 10.0000000 Inexact Rounded +addx437 add 77e-9999999 10 -> 10.0000000 Inexact Rounded + +-- negative ulps +addx440 add 1 -77e-7 -> 0.9999923 +addx441 add 1 -77e-8 -> 0.99999923 +addx442 add 1 -77e-9 -> 0.999999923 +addx443 add 1 -77e-10 -> 0.999999992 Inexact Rounded +addx444 add 1 -77e-11 -> 0.999999999 Inexact Rounded +addx445 add 1 -77e-12 -> 1.00000000 Inexact Rounded +addx446 add 1 -77e-999 -> 1.00000000 Inexact Rounded +addx447 add 1 -77e-9999999 -> 1.00000000 Inexact Rounded + +addx450 add 10 -77e-7 -> 9.9999923 +addx451 add 10 -77e-8 -> 9.99999923 +addx452 add 10 -77e-9 -> 9.99999992 Inexact Rounded +addx453 add 10 -77e-10 -> 9.99999999 Inexact Rounded +addx454 add 10 -77e-11 -> 10.0000000 Inexact Rounded +addx455 add 10 -77e-12 -> 10.0000000 Inexact Rounded +addx456 add 10 -77e-999 -> 10.0000000 Inexact Rounded +addx457 add 10 -77e-9999999 -> 10.0000000 Inexact Rounded + +addx460 add -77e-7 1 -> 0.9999923 +addx461 add -77e-8 1 -> 0.99999923 +addx462 add -77e-9 1 -> 0.999999923 +addx463 add -77e-10 1 -> 0.999999992 Inexact Rounded +addx464 add -77e-11 1 -> 0.999999999 Inexact Rounded +addx465 add -77e-12 1 -> 1.00000000 Inexact Rounded +addx466 add -77e-999 1 -> 1.00000000 Inexact Rounded +addx467 add -77e-9999999 1 -> 1.00000000 Inexact Rounded + +addx470 add -77e-7 10 -> 9.9999923 +addx471 add -77e-8 10 -> 9.99999923 +addx472 add -77e-9 10 -> 9.99999992 Inexact Rounded +addx473 add -77e-10 10 -> 9.99999999 Inexact Rounded +addx474 add -77e-11 10 -> 10.0000000 Inexact Rounded +addx475 add -77e-12 10 -> 10.0000000 Inexact Rounded +addx476 add -77e-999 10 -> 10.0000000 Inexact Rounded +addx477 add -77e-9999999 10 -> 10.0000000 Inexact Rounded + +-- negative ulps +addx480 add -1 77e-7 -> -0.9999923 +addx481 add -1 77e-8 -> -0.99999923 +addx482 add -1 77e-9 -> -0.999999923 +addx483 add -1 77e-10 -> -0.999999992 Inexact Rounded +addx484 add -1 77e-11 -> -0.999999999 Inexact Rounded +addx485 add -1 77e-12 -> -1.00000000 Inexact Rounded +addx486 add -1 77e-999 -> -1.00000000 Inexact Rounded +addx487 add -1 77e-9999999 -> -1.00000000 Inexact Rounded + +addx490 add -10 77e-7 -> -9.9999923 +addx491 add -10 77e-8 -> -9.99999923 +addx492 add -10 77e-9 -> -9.99999992 Inexact Rounded +addx493 add -10 77e-10 -> -9.99999999 Inexact Rounded +addx494 add -10 77e-11 -> -10.0000000 Inexact Rounded +addx495 add -10 77e-12 -> -10.0000000 Inexact Rounded +addx496 add -10 77e-999 -> -10.0000000 Inexact Rounded +addx497 add -10 77e-9999999 -> -10.0000000 Inexact Rounded + +addx500 add 77e-7 -1 -> -0.9999923 +addx501 add 77e-8 -1 -> -0.99999923 +addx502 add 77e-9 -1 -> -0.999999923 +addx503 add 77e-10 -1 -> -0.999999992 Inexact Rounded +addx504 add 77e-11 -1 -> -0.999999999 Inexact Rounded +addx505 add 77e-12 -1 -> -1.00000000 Inexact Rounded +addx506 add 77e-999 -1 -> -1.00000000 Inexact Rounded +addx507 add 77e-9999999 -1 -> -1.00000000 Inexact Rounded + +addx510 add 77e-7 -10 -> -9.9999923 +addx511 add 77e-8 -10 -> -9.99999923 +addx512 add 77e-9 -10 -> -9.99999992 Inexact Rounded +addx513 add 77e-10 -10 -> -9.99999999 Inexact Rounded +addx514 add 77e-11 -10 -> -10.0000000 Inexact Rounded +addx515 add 77e-12 -10 -> -10.0000000 Inexact Rounded +addx516 add 77e-999 -10 -> -10.0000000 Inexact Rounded +addx517 add 77e-9999999 -10 -> -10.0000000 Inexact Rounded + + +-- long operands +maxexponent: 999 +minexponent: -999 +precision: 9 +addx521 add 12345678000 0 -> 1.23456780E+10 Rounded +addx522 add 0 12345678000 -> 1.23456780E+10 Rounded +addx523 add 1234567800 0 -> 1.23456780E+9 Rounded +addx524 add 0 1234567800 -> 1.23456780E+9 Rounded +addx525 add 1234567890 0 -> 1.23456789E+9 Rounded +addx526 add 0 1234567890 -> 1.23456789E+9 Rounded +addx527 add 1234567891 0 -> 1.23456789E+9 Inexact Rounded +addx528 add 0 1234567891 -> 1.23456789E+9 Inexact Rounded +addx529 add 12345678901 0 -> 1.23456789E+10 Inexact Rounded +addx530 add 0 12345678901 -> 1.23456789E+10 Inexact Rounded +addx531 add 1234567896 0 -> 1.23456790E+9 Inexact Rounded +addx532 add 0 1234567896 -> 1.23456790E+9 Inexact Rounded + +precision: 15 +-- still checking +addx541 add 12345678000 0 -> 12345678000 +addx542 add 0 12345678000 -> 12345678000 +addx543 add 1234567800 0 -> 1234567800 +addx544 add 0 1234567800 -> 1234567800 +addx545 add 1234567890 0 -> 1234567890 +addx546 add 0 1234567890 -> 1234567890 +addx547 add 1234567891 0 -> 1234567891 +addx548 add 0 1234567891 -> 1234567891 +addx549 add 12345678901 0 -> 12345678901 +addx550 add 0 12345678901 -> 12345678901 +addx551 add 1234567896 0 -> 1234567896 +addx552 add 0 1234567896 -> 1234567896 + +-- verify a query +precision: 16 +maxExponent: +394 +minExponent: -393 +rounding: down +addx561 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded +addx562 add 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded +-- and using decimal64 bounds... +precision: 16 +maxExponent: +384 +minExponent: -383 +rounding: down +addx563 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded +addx564 add 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded + +-- some more residue effects with extreme rounding +precision: 9 +rounding: half_up +addx601 add 123456789 0.000001 -> 123456789 Inexact Rounded +rounding: half_even +addx602 add 123456789 0.000001 -> 123456789 Inexact Rounded +rounding: half_down +addx603 add 123456789 0.000001 -> 123456789 Inexact Rounded +rounding: floor +addx604 add 123456789 0.000001 -> 123456789 Inexact Rounded +rounding: ceiling +addx605 add 123456789 0.000001 -> 123456790 Inexact Rounded +rounding: up +addx606 add 123456789 0.000001 -> 123456790 Inexact Rounded +rounding: down +addx607 add 123456789 0.000001 -> 123456789 Inexact Rounded + +rounding: half_up +addx611 add 123456789 -0.000001 -> 123456789 Inexact Rounded +rounding: half_even +addx612 add 123456789 -0.000001 -> 123456789 Inexact Rounded +rounding: half_down +addx613 add 123456789 -0.000001 -> 123456789 Inexact Rounded +rounding: floor +addx614 add 123456789 -0.000001 -> 123456788 Inexact Rounded +rounding: ceiling +addx615 add 123456789 -0.000001 -> 123456789 Inexact Rounded +rounding: up +addx616 add 123456789 -0.000001 -> 123456789 Inexact Rounded +rounding: down +addx617 add 123456789 -0.000001 -> 123456788 Inexact Rounded + +rounding: half_up +addx621 add 123456789 0.499999 -> 123456789 Inexact Rounded +rounding: half_even +addx622 add 123456789 0.499999 -> 123456789 Inexact Rounded +rounding: half_down +addx623 add 123456789 0.499999 -> 123456789 Inexact Rounded +rounding: floor +addx624 add 123456789 0.499999 -> 123456789 Inexact Rounded +rounding: ceiling +addx625 add 123456789 0.499999 -> 123456790 Inexact Rounded +rounding: up +addx626 add 123456789 0.499999 -> 123456790 Inexact Rounded +rounding: down +addx627 add 123456789 0.499999 -> 123456789 Inexact Rounded + +rounding: half_up +addx631 add 123456789 -0.499999 -> 123456789 Inexact Rounded +rounding: half_even +addx632 add 123456789 -0.499999 -> 123456789 Inexact Rounded +rounding: half_down +addx633 add 123456789 -0.499999 -> 123456789 Inexact Rounded +rounding: floor +addx634 add 123456789 -0.499999 -> 123456788 Inexact Rounded +rounding: ceiling +addx635 add 123456789 -0.499999 -> 123456789 Inexact Rounded +rounding: up +addx636 add 123456789 -0.499999 -> 123456789 Inexact Rounded +rounding: down +addx637 add 123456789 -0.499999 -> 123456788 Inexact Rounded + +rounding: half_up +addx641 add 123456789 0.500001 -> 123456790 Inexact Rounded +rounding: half_even +addx642 add 123456789 0.500001 -> 123456790 Inexact Rounded +rounding: half_down +addx643 add 123456789 0.500001 -> 123456790 Inexact Rounded +rounding: floor +addx644 add 123456789 0.500001 -> 123456789 Inexact Rounded +rounding: ceiling +addx645 add 123456789 0.500001 -> 123456790 Inexact Rounded +rounding: up +addx646 add 123456789 0.500001 -> 123456790 Inexact Rounded +rounding: down +addx647 add 123456789 0.500001 -> 123456789 Inexact Rounded + +rounding: half_up +addx651 add 123456789 -0.500001 -> 123456788 Inexact Rounded +rounding: half_even +addx652 add 123456789 -0.500001 -> 123456788 Inexact Rounded +rounding: half_down +addx653 add 123456789 -0.500001 -> 123456788 Inexact Rounded +rounding: floor +addx654 add 123456789 -0.500001 -> 123456788 Inexact Rounded +rounding: ceiling +addx655 add 123456789 -0.500001 -> 123456789 Inexact Rounded +rounding: up +addx656 add 123456789 -0.500001 -> 123456789 Inexact Rounded +rounding: down +addx657 add 123456789 -0.500001 -> 123456788 Inexact Rounded + +-- long operand triangle +rounding: half_up +precision: 37 +addx660 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538 +precision: 36 +addx661 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454 Inexact Rounded +precision: 35 +addx662 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345 Inexact Rounded +precision: 34 +addx663 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835 Inexact Rounded +precision: 33 +addx664 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483 Inexact Rounded +precision: 32 +addx665 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148 Inexact Rounded +precision: 31 +addx666 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded +precision: 30 +addx667 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711 Inexact Rounded +precision: 29 +addx668 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371 Inexact Rounded +precision: 28 +addx669 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337 Inexact Rounded +precision: 27 +addx670 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234 Inexact Rounded +precision: 26 +addx671 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223 Inexact Rounded +precision: 25 +addx672 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922 Inexact Rounded +precision: 24 +addx673 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892 Inexact Rounded +precision: 23 +addx674 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389 Inexact Rounded +precision: 22 +addx675 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639 Inexact Rounded +precision: 21 +addx676 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364 Inexact Rounded +precision: 20 +addx677 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236 Inexact Rounded +precision: 19 +addx678 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024 Inexact Rounded +precision: 18 +addx679 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102 Inexact Rounded +precision: 17 +addx680 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110 Inexact Rounded +precision: 16 +addx681 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211 Inexact Rounded +precision: 15 +addx682 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221 Inexact Rounded +precision: 14 +addx683 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422 Inexact Rounded +precision: 13 +addx684 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42 Inexact Rounded +precision: 12 +addx685 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4 Inexact Rounded +precision: 11 +addx686 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166 Inexact Rounded +precision: 10 +addx687 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10 Inexact Rounded +precision: 9 +addx688 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10 Inexact Rounded +precision: 8 +addx689 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10 Inexact Rounded +precision: 7 +addx690 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10 Inexact Rounded +precision: 6 +addx691 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10 Inexact Rounded +precision: 5 +addx692 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10 Inexact Rounded +precision: 4 +addx693 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10 Inexact Rounded +precision: 3 +addx694 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10 Inexact Rounded +precision: 2 +addx695 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10 Inexact Rounded +precision: 1 +addx696 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11 Inexact Rounded + +-- more zeros, etc. +rounding: half_up +precision: 9 + +addx701 add 5.00 1.00E-3 -> 5.00100 +addx702 add 00.00 0.000 -> 0.000 +addx703 add 00.00 0E-3 -> 0.000 +addx704 add 0E-3 00.00 -> 0.000 + +addx710 add 0E+3 00.00 -> 0.00 +addx711 add 0E+3 00.0 -> 0.0 +addx712 add 0E+3 00. -> 0 +addx713 add 0E+3 00.E+1 -> 0E+1 +addx714 add 0E+3 00.E+2 -> 0E+2 +addx715 add 0E+3 00.E+3 -> 0E+3 +addx716 add 0E+3 00.E+4 -> 0E+3 +addx717 add 0E+3 00.E+5 -> 0E+3 +addx718 add 0E+3 -00.0 -> 0.0 +addx719 add 0E+3 -00. -> 0 +addx731 add 0E+3 -00.E+1 -> 0E+1 + +addx720 add 00.00 0E+3 -> 0.00 +addx721 add 00.0 0E+3 -> 0.0 +addx722 add 00. 0E+3 -> 0 +addx723 add 00.E+1 0E+3 -> 0E+1 +addx724 add 00.E+2 0E+3 -> 0E+2 +addx725 add 00.E+3 0E+3 -> 0E+3 +addx726 add 00.E+4 0E+3 -> 0E+3 +addx727 add 00.E+5 0E+3 -> 0E+3 +addx728 add -00.00 0E+3 -> 0.00 +addx729 add -00.0 0E+3 -> 0.0 +addx730 add -00. 0E+3 -> 0 + +addx732 add 0 0 -> 0 +addx733 add 0 -0 -> 0 +addx734 add -0 0 -> 0 +addx735 add -0 -0 -> -0 -- IEEE 854 special case + +addx736 add 1 -1 -> 0 +addx737 add -1 -1 -> -2 +addx738 add 1 1 -> 2 +addx739 add -1 1 -> 0 + +addx741 add 0 -1 -> -1 +addx742 add -0 -1 -> -1 +addx743 add 0 1 -> 1 +addx744 add -0 1 -> 1 +addx745 add -1 0 -> -1 +addx746 add -1 -0 -> -1 +addx747 add 1 0 -> 1 +addx748 add 1 -0 -> 1 + +addx751 add 0.0 -1 -> -1.0 +addx752 add -0.0 -1 -> -1.0 +addx753 add 0.0 1 -> 1.0 +addx754 add -0.0 1 -> 1.0 +addx755 add -1.0 0 -> -1.0 +addx756 add -1.0 -0 -> -1.0 +addx757 add 1.0 0 -> 1.0 +addx758 add 1.0 -0 -> 1.0 + +addx761 add 0 -1.0 -> -1.0 +addx762 add -0 -1.0 -> -1.0 +addx763 add 0 1.0 -> 1.0 +addx764 add -0 1.0 -> 1.0 +addx765 add -1 0.0 -> -1.0 +addx766 add -1 -0.0 -> -1.0 +addx767 add 1 0.0 -> 1.0 +addx768 add 1 -0.0 -> 1.0 + +addx771 add 0.0 -1.0 -> -1.0 +addx772 add -0.0 -1.0 -> -1.0 +addx773 add 0.0 1.0 -> 1.0 +addx774 add -0.0 1.0 -> 1.0 +addx775 add -1.0 0.0 -> -1.0 +addx776 add -1.0 -0.0 -> -1.0 +addx777 add 1.0 0.0 -> 1.0 +addx778 add 1.0 -0.0 -> 1.0 + +-- Specials +addx780 add -Inf -Inf -> -Infinity +addx781 add -Inf -1000 -> -Infinity +addx782 add -Inf -1 -> -Infinity +addx783 add -Inf -0 -> -Infinity +addx784 add -Inf 0 -> -Infinity +addx785 add -Inf 1 -> -Infinity +addx786 add -Inf 1000 -> -Infinity +addx787 add -1000 -Inf -> -Infinity +addx788 add -Inf -Inf -> -Infinity +addx789 add -1 -Inf -> -Infinity +addx790 add -0 -Inf -> -Infinity +addx791 add 0 -Inf -> -Infinity +addx792 add 1 -Inf -> -Infinity +addx793 add 1000 -Inf -> -Infinity +addx794 add Inf -Inf -> NaN Invalid_operation + +addx800 add Inf -Inf -> NaN Invalid_operation +addx801 add Inf -1000 -> Infinity +addx802 add Inf -1 -> Infinity +addx803 add Inf -0 -> Infinity +addx804 add Inf 0 -> Infinity +addx805 add Inf 1 -> Infinity +addx806 add Inf 1000 -> Infinity +addx807 add Inf Inf -> Infinity +addx808 add -1000 Inf -> Infinity +addx809 add -Inf Inf -> NaN Invalid_operation +addx810 add -1 Inf -> Infinity +addx811 add -0 Inf -> Infinity +addx812 add 0 Inf -> Infinity +addx813 add 1 Inf -> Infinity +addx814 add 1000 Inf -> Infinity +addx815 add Inf Inf -> Infinity + +addx821 add NaN -Inf -> NaN +addx822 add NaN -1000 -> NaN +addx823 add NaN -1 -> NaN +addx824 add NaN -0 -> NaN +addx825 add NaN 0 -> NaN +addx826 add NaN 1 -> NaN +addx827 add NaN 1000 -> NaN +addx828 add NaN Inf -> NaN +addx829 add NaN NaN -> NaN +addx830 add -Inf NaN -> NaN +addx831 add -1000 NaN -> NaN +addx832 add -1 NaN -> NaN +addx833 add -0 NaN -> NaN +addx834 add 0 NaN -> NaN +addx835 add 1 NaN -> NaN +addx836 add 1000 NaN -> NaN +addx837 add Inf NaN -> NaN + +addx841 add sNaN -Inf -> NaN Invalid_operation +addx842 add sNaN -1000 -> NaN Invalid_operation +addx843 add sNaN -1 -> NaN Invalid_operation +addx844 add sNaN -0 -> NaN Invalid_operation +addx845 add sNaN 0 -> NaN Invalid_operation +addx846 add sNaN 1 -> NaN Invalid_operation +addx847 add sNaN 1000 -> NaN Invalid_operation +addx848 add sNaN NaN -> NaN Invalid_operation +addx849 add sNaN sNaN -> NaN Invalid_operation +addx850 add NaN sNaN -> NaN Invalid_operation +addx851 add -Inf sNaN -> NaN Invalid_operation +addx852 add -1000 sNaN -> NaN Invalid_operation +addx853 add -1 sNaN -> NaN Invalid_operation +addx854 add -0 sNaN -> NaN Invalid_operation +addx855 add 0 sNaN -> NaN Invalid_operation +addx856 add 1 sNaN -> NaN Invalid_operation +addx857 add 1000 sNaN -> NaN Invalid_operation +addx858 add Inf sNaN -> NaN Invalid_operation +addx859 add NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +addx861 add NaN1 -Inf -> NaN1 +addx862 add +NaN2 -1000 -> NaN2 +addx863 add NaN3 1000 -> NaN3 +addx864 add NaN4 Inf -> NaN4 +addx865 add NaN5 +NaN6 -> NaN5 +addx866 add -Inf NaN7 -> NaN7 +addx867 add -1000 NaN8 -> NaN8 +addx868 add 1000 NaN9 -> NaN9 +addx869 add Inf +NaN10 -> NaN10 +addx871 add sNaN11 -Inf -> NaN11 Invalid_operation +addx872 add sNaN12 -1000 -> NaN12 Invalid_operation +addx873 add sNaN13 1000 -> NaN13 Invalid_operation +addx874 add sNaN14 NaN17 -> NaN14 Invalid_operation +addx875 add sNaN15 sNaN18 -> NaN15 Invalid_operation +addx876 add NaN16 sNaN19 -> NaN19 Invalid_operation +addx877 add -Inf +sNaN20 -> NaN20 Invalid_operation +addx878 add -1000 sNaN21 -> NaN21 Invalid_operation +addx879 add 1000 sNaN22 -> NaN22 Invalid_operation +addx880 add Inf sNaN23 -> NaN23 Invalid_operation +addx881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation +addx882 add -NaN26 NaN28 -> -NaN26 +addx883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation +addx884 add 1000 -NaN30 -> -NaN30 +addx885 add 1000 -sNaN31 -> -NaN31 Invalid_operation + +-- overflow, underflow and subnormal tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +addx890 add 1E+999999999 9E+999999999 -> Infinity Overflow Inexact Rounded +addx891 add 9E+999999999 1E+999999999 -> Infinity Overflow Inexact Rounded +addx892 add -1.1E-999999999 1E-999999999 -> -1E-1000000000 Subnormal +addx893 add 1E-999999999 -1.1e-999999999 -> -1E-1000000000 Subnormal +addx894 add -1.0001E-999999999 1E-999999999 -> -1E-1000000003 Subnormal +addx895 add 1E-999999999 -1.0001e-999999999 -> -1E-1000000003 Subnormal +addx896 add -1E+999999999 -9E+999999999 -> -Infinity Overflow Inexact Rounded +addx897 add -9E+999999999 -1E+999999999 -> -Infinity Overflow Inexact Rounded +addx898 add +1.1E-999999999 -1E-999999999 -> 1E-1000000000 Subnormal +addx899 add -1E-999999999 +1.1e-999999999 -> 1E-1000000000 Subnormal +addx900 add +1.0001E-999999999 -1E-999999999 -> 1E-1000000003 Subnormal +addx901 add -1E-999999999 +1.0001e-999999999 -> 1E-1000000003 Subnormal +addx902 add -1E+999999999 +9E+999999999 -> 8E+999999999 +addx903 add -9E+999999999 +1E+999999999 -> -8E+999999999 + +precision: 3 +addx904 add 0 -9.999E+999999999 -> -Infinity Inexact Overflow Rounded +addx905 add -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded +addx906 add 0 9.999E+999999999 -> Infinity Inexact Overflow Rounded +addx907 add 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded + +precision: 3 +maxexponent: 999 +minexponent: -999 +addx910 add 1.00E-999 0 -> 1.00E-999 +addx911 add 0.1E-999 0 -> 1E-1000 Subnormal +addx912 add 0.10E-999 0 -> 1.0E-1000 Subnormal +addx913 add 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded +addx914 add 0.01E-999 0 -> 1E-1001 Subnormal +-- next is rounded to Emin +addx915 add 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow +addx916 add 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +addx917 add 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow +addx918 add 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow +addx919 add 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow +addx920 add 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow + +addx930 add -1.00E-999 0 -> -1.00E-999 +addx931 add -0.1E-999 0 -> -1E-1000 Subnormal +addx932 add -0.10E-999 0 -> -1.0E-1000 Subnormal +addx933 add -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded +addx934 add -0.01E-999 0 -> -1E-1001 Subnormal +-- next is rounded to Emin +addx935 add -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow +addx936 add -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +addx937 add -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow +addx938 add -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow +addx939 add -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow +addx940 add -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow + +-- some non-zero subnormal adds +addx950 add 1.00E-999 0.1E-999 -> 1.10E-999 +addx951 add 0.1E-999 0.1E-999 -> 2E-1000 Subnormal +addx952 add 0.10E-999 0.1E-999 -> 2.0E-1000 Subnormal +addx953 add 0.100E-999 0.1E-999 -> 2.0E-1000 Subnormal Rounded +addx954 add 0.01E-999 0.1E-999 -> 1.1E-1000 Subnormal +addx955 add 0.999E-999 0.1E-999 -> 1.10E-999 Inexact Rounded +addx956 add 0.099E-999 0.1E-999 -> 2.0E-1000 Inexact Rounded Subnormal Underflow +addx957 add 0.009E-999 0.1E-999 -> 1.1E-1000 Inexact Rounded Subnormal Underflow +addx958 add 0.001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +addx959 add 0.0009E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +addx960 add 0.0001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +-- negatives... +addx961 add 1.00E-999 -0.1E-999 -> 9.0E-1000 Subnormal +addx962 add 0.1E-999 -0.1E-999 -> 0E-1000 +addx963 add 0.10E-999 -0.1E-999 -> 0E-1001 +addx964 add 0.100E-999 -0.1E-999 -> 0E-1001 Clamped +addx965 add 0.01E-999 -0.1E-999 -> -9E-1001 Subnormal +addx966 add 0.999E-999 -0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow +addx967 add 0.099E-999 -0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +addx968 add 0.009E-999 -0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow +addx969 add 0.001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +addx970 add 0.0009E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +addx971 add 0.0001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow + +-- check overflow edge case +precision: 7 +rounding: half_up +maxExponent: 96 +minExponent: -95 +addx972 apply 9.999999E+96 -> 9.999999E+96 +addx973 add 9.999999E+96 1 -> 9.999999E+96 Inexact Rounded +addx974 add 9999999E+90 1 -> 9.999999E+96 Inexact Rounded +addx975 add 9999999E+90 1E+90 -> Infinity Overflow Inexact Rounded +addx976 add 9999999E+90 9E+89 -> Infinity Overflow Inexact Rounded +addx977 add 9999999E+90 8E+89 -> Infinity Overflow Inexact Rounded +addx978 add 9999999E+90 7E+89 -> Infinity Overflow Inexact Rounded +addx979 add 9999999E+90 6E+89 -> Infinity Overflow Inexact Rounded +addx980 add 9999999E+90 5E+89 -> Infinity Overflow Inexact Rounded +addx981 add 9999999E+90 4E+89 -> 9.999999E+96 Inexact Rounded +addx982 add 9999999E+90 3E+89 -> 9.999999E+96 Inexact Rounded +addx983 add 9999999E+90 2E+89 -> 9.999999E+96 Inexact Rounded +addx984 add 9999999E+90 1E+89 -> 9.999999E+96 Inexact Rounded + +addx985 apply -9.999999E+96 -> -9.999999E+96 +addx986 add -9.999999E+96 -1 -> -9.999999E+96 Inexact Rounded +addx987 add -9999999E+90 -1 -> -9.999999E+96 Inexact Rounded +addx988 add -9999999E+90 -1E+90 -> -Infinity Overflow Inexact Rounded +addx989 add -9999999E+90 -9E+89 -> -Infinity Overflow Inexact Rounded +addx990 add -9999999E+90 -8E+89 -> -Infinity Overflow Inexact Rounded +addx991 add -9999999E+90 -7E+89 -> -Infinity Overflow Inexact Rounded +addx992 add -9999999E+90 -6E+89 -> -Infinity Overflow Inexact Rounded +addx993 add -9999999E+90 -5E+89 -> -Infinity Overflow Inexact Rounded +addx994 add -9999999E+90 -4E+89 -> -9.999999E+96 Inexact Rounded +addx995 add -9999999E+90 -3E+89 -> -9.999999E+96 Inexact Rounded +addx996 add -9999999E+90 -2E+89 -> -9.999999E+96 Inexact Rounded +addx997 add -9999999E+90 -1E+89 -> -9.999999E+96 Inexact Rounded + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +-- Add: lhs and rhs 0 +addx1001 add 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1002 add 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1003 add 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1004 add 0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1005 add 0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1006 add 0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow + +-- Add: lhs >> rhs and vice versa +addx1011 add 1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1012 add 1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1013 add 1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1014 add 1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1015 add 1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +addx1016 add 1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow + +-- Add: lhs + rhs addition carried out +addx1021 add 1.52443E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow +addx1022 add 1.52444E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow +addx1023 add 1.52445E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow +addx1024 add 1.00001E-80 1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow +addx1025 add 1.00001E-80 1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow +addx1026 add 1.00001E-80 1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow + +-- And for round down full and subnormal results +precision: 16 +maxExponent: +384 +minExponent: -383 +rounding: down + +addx1100 add 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact +addx1101 add 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact +addx1103 add +1 -1e-383 -> 0.9999999999999999 Rounded Inexact +addx1104 add 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact +addx1105 add 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact +addx1106 add 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact +addx1107 add 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact +addx1108 add 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact +addx1109 add 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact + +rounding: ceiling +addx1110 add -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact +addx1111 add -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact +addx1113 add -1 +1e-383 -> -0.9999999999999999 Rounded Inexact +addx1114 add -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact +addx1115 add -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact +addx1116 add -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact +addx1117 add -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact +addx1118 add -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact +addx1119 add -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact + +rounding: down +precision: 7 +maxExponent: +96 +minExponent: -95 +addx1130 add 1 -1e-200 -> 0.9999999 Rounded Inexact +-- subnormal boundary +addx1131 add 1.000000E-94 -1e-200 -> 9.999999E-95 Rounded Inexact +addx1132 add 1.000001E-95 -1e-200 -> 1.000000E-95 Rounded Inexact +addx1133 add 1.000000E-95 -1e-200 -> 9.99999E-96 Rounded Inexact Subnormal Underflow +addx1134 add 0.999999E-95 -1e-200 -> 9.99998E-96 Rounded Inexact Subnormal Underflow +addx1135 add 0.001000E-95 -1e-200 -> 9.99E-99 Rounded Inexact Subnormal Underflow +addx1136 add 0.000999E-95 -1e-200 -> 9.98E-99 Rounded Inexact Subnormal Underflow +addx1137 add 1.000000E-95 -1e-101 -> 9.99999E-96 Subnormal +addx1138 add 10000E-101 -1e-200 -> 9.999E-98 Subnormal Inexact Rounded Underflow +addx1139 add 1000E-101 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow +addx1140 add 100E-101 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow +addx1141 add 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow +addx1142 add 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow +addx1143 add 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow +addx1144 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow + +addx1151 add 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow +addx1152 add 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow +addx1153 add 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow +addx1154 add 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow +addx1155 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow +addx1156 add 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow +addx1157 add 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow + +addx1160 add 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow +addx1161 add 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow + + +-- Null tests +addx9990 add 10 # -> NaN Invalid_operation +addx9991 add # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/base.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/base.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,1272 @@ +------------------------------------------------------------------------ +-- base.decTest -- base decimal <--> string conversions -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This file tests base conversions from string to a decimal number +-- and back to a string (in either Scientific or Engineering form) + +-- Note that unlike other operations the operand is subject to rounding +-- to conform to emax and precision settings (that is, numbers will +-- conform to rules and exponent will be in permitted range). + +precision: 15 +rounding: half_up +maxExponent: 999999999 +minExponent: -999999999 +extended: 1 + +basx001 toSci 0 -> 0 +basx002 toSci 1 -> 1 +basx003 toSci 1.0 -> 1.0 +basx004 toSci 1.00 -> 1.00 +basx005 toSci 10 -> 10 +basx006 toSci 1000 -> 1000 +basx007 toSci 10.0 -> 10.0 +basx008 toSci 10.1 -> 10.1 +basx009 toSci 10.4 -> 10.4 +basx010 toSci 10.5 -> 10.5 +basx011 toSci 10.6 -> 10.6 +basx012 toSci 10.9 -> 10.9 +basx013 toSci 11.0 -> 11.0 +basx014 toSci 1.234 -> 1.234 +basx015 toSci 0.123 -> 0.123 +basx016 toSci 0.012 -> 0.012 +basx017 toSci -0 -> -0 +basx018 toSci -0.0 -> -0.0 +basx019 toSci -00.00 -> -0.00 + +basx021 toSci -1 -> -1 +basx022 toSci -1.0 -> -1.0 +basx023 toSci -0.1 -> -0.1 +basx024 toSci -9.1 -> -9.1 +basx025 toSci -9.11 -> -9.11 +basx026 toSci -9.119 -> -9.119 +basx027 toSci -9.999 -> -9.999 + +basx030 toSci '123456789.123456' -> '123456789.123456' +basx031 toSci '123456789.000000' -> '123456789.000000' +basx032 toSci '123456789123456' -> '123456789123456' +basx033 toSci '0.0000123456789' -> '0.0000123456789' +basx034 toSci '0.00000123456789' -> '0.00000123456789' +basx035 toSci '0.000000123456789' -> '1.23456789E-7' +basx036 toSci '0.0000000123456789' -> '1.23456789E-8' + +basx037 toSci '0.123456789012344' -> '0.123456789012344' +basx038 toSci '0.123456789012345' -> '0.123456789012345' + +-- String [many more examples are implicitly tested elsewhere] +-- strings without E cannot generate E in result +basx100 toSci "12" -> '12' +basx101 toSci "-76" -> '-76' +basx102 toSci "12.76" -> '12.76' +basx103 toSci "+12.76" -> '12.76' +basx104 toSci "012.76" -> '12.76' +basx105 toSci "+0.003" -> '0.003' +basx106 toSci "17." -> '17' +basx107 toSci ".5" -> '0.5' +basx108 toSci "044" -> '44' +basx109 toSci "0044" -> '44' +basx110 toSci "0.0005" -> '0.0005' +basx111 toSci "00.00005" -> '0.00005' +basx112 toSci "0.000005" -> '0.000005' +basx113 toSci "0.0000050" -> '0.0000050' +basx114 toSci "0.0000005" -> '5E-7' +basx115 toSci "0.00000005" -> '5E-8' +basx116 toSci "12345678.543210" -> '12345678.543210' +basx117 toSci "2345678.543210" -> '2345678.543210' +basx118 toSci "345678.543210" -> '345678.543210' +basx119 toSci "0345678.54321" -> '345678.54321' +basx120 toSci "345678.5432" -> '345678.5432' +basx121 toSci "+345678.5432" -> '345678.5432' +basx122 toSci "+0345678.5432" -> '345678.5432' +basx123 toSci "+00345678.5432" -> '345678.5432' +basx124 toSci "-345678.5432" -> '-345678.5432' +basx125 toSci "-0345678.5432" -> '-345678.5432' +basx126 toSci "-00345678.5432" -> '-345678.5432' +-- examples +basx127 toSci "5E-6" -> '0.000005' +basx128 toSci "50E-7" -> '0.0000050' +basx129 toSci "5E-7" -> '5E-7' + + +-- [No exotics as no Unicode] + +-- Numbers with E +basx130 toSci "0.000E-1" -> '0.0000' +basx131 toSci "0.000E-2" -> '0.00000' +basx132 toSci "0.000E-3" -> '0.000000' +basx133 toSci "0.000E-4" -> '0E-7' +basx134 toSci "0.00E-2" -> '0.0000' +basx135 toSci "0.00E-3" -> '0.00000' +basx136 toSci "0.00E-4" -> '0.000000' +basx137 toSci "0.00E-5" -> '0E-7' +basx138 toSci "+0E+9" -> '0E+9' +basx139 toSci "-0E+9" -> '-0E+9' +basx140 toSci "1E+9" -> '1E+9' +basx141 toSci "1e+09" -> '1E+9' +basx142 toSci "1E+90" -> '1E+90' +basx143 toSci "+1E+009" -> '1E+9' +basx144 toSci "0E+9" -> '0E+9' +basx145 toSci "1E+9" -> '1E+9' +basx146 toSci "1E+09" -> '1E+9' +basx147 toSci "1e+90" -> '1E+90' +basx148 toSci "1E+009" -> '1E+9' +basx149 toSci "000E+9" -> '0E+9' +basx150 toSci "1E9" -> '1E+9' +basx151 toSci "1e09" -> '1E+9' +basx152 toSci "1E90" -> '1E+90' +basx153 toSci "1E009" -> '1E+9' +basx154 toSci "0E9" -> '0E+9' +basx155 toSci "0.000e+0" -> '0.000' +basx156 toSci "0.000E-1" -> '0.0000' +basx157 toSci "4E+9" -> '4E+9' +basx158 toSci "44E+9" -> '4.4E+10' +basx159 toSci "0.73e-7" -> '7.3E-8' +basx160 toSci "00E+9" -> '0E+9' +basx161 toSci "00E-9" -> '0E-9' +basx162 toSci "10E+9" -> '1.0E+10' +basx163 toSci "10E+09" -> '1.0E+10' +basx164 toSci "10e+90" -> '1.0E+91' +basx165 toSci "10E+009" -> '1.0E+10' +basx166 toSci "100e+9" -> '1.00E+11' +basx167 toSci "100e+09" -> '1.00E+11' +basx168 toSci "100E+90" -> '1.00E+92' +basx169 toSci "100e+009" -> '1.00E+11' + +basx170 toSci "1.265" -> '1.265' +basx171 toSci "1.265E-20" -> '1.265E-20' +basx172 toSci "1.265E-8" -> '1.265E-8' +basx173 toSci "1.265E-4" -> '0.0001265' +basx174 toSci "1.265E-3" -> '0.001265' +basx175 toSci "1.265E-2" -> '0.01265' +basx176 toSci "1.265E-1" -> '0.1265' +basx177 toSci "1.265E-0" -> '1.265' +basx178 toSci "1.265E+1" -> '12.65' +basx179 toSci "1.265E+2" -> '126.5' +basx180 toSci "1.265E+3" -> '1265' +basx181 toSci "1.265E+4" -> '1.265E+4' +basx182 toSci "1.265E+8" -> '1.265E+8' +basx183 toSci "1.265E+20" -> '1.265E+20' + +basx190 toSci "12.65" -> '12.65' +basx191 toSci "12.65E-20" -> '1.265E-19' +basx192 toSci "12.65E-8" -> '1.265E-7' +basx193 toSci "12.65E-4" -> '0.001265' +basx194 toSci "12.65E-3" -> '0.01265' +basx195 toSci "12.65E-2" -> '0.1265' +basx196 toSci "12.65E-1" -> '1.265' +basx197 toSci "12.65E-0" -> '12.65' +basx198 toSci "12.65E+1" -> '126.5' +basx199 toSci "12.65E+2" -> '1265' +basx200 toSci "12.65E+3" -> '1.265E+4' +basx201 toSci "12.65E+4" -> '1.265E+5' +basx202 toSci "12.65E+8" -> '1.265E+9' +basx203 toSci "12.65E+20" -> '1.265E+21' + +basx210 toSci "126.5" -> '126.5' +basx211 toSci "126.5E-20" -> '1.265E-18' +basx212 toSci "126.5E-8" -> '0.000001265' +basx213 toSci "126.5E-4" -> '0.01265' +basx214 toSci "126.5E-3" -> '0.1265' +basx215 toSci "126.5E-2" -> '1.265' +basx216 toSci "126.5E-1" -> '12.65' +basx217 toSci "126.5E-0" -> '126.5' +basx218 toSci "126.5E+1" -> '1265' +basx219 toSci "126.5E+2" -> '1.265E+4' +basx220 toSci "126.5E+3" -> '1.265E+5' +basx221 toSci "126.5E+4" -> '1.265E+6' +basx222 toSci "126.5E+8" -> '1.265E+10' +basx223 toSci "126.5E+20" -> '1.265E+22' + +basx230 toSci "1265" -> '1265' +basx231 toSci "1265E-20" -> '1.265E-17' +basx232 toSci "1265E-8" -> '0.00001265' +basx233 toSci "1265E-4" -> '0.1265' +basx234 toSci "1265E-3" -> '1.265' +basx235 toSci "1265E-2" -> '12.65' +basx236 toSci "1265E-1" -> '126.5' +basx237 toSci "1265E-0" -> '1265' +basx238 toSci "1265E+1" -> '1.265E+4' +basx239 toSci "1265E+2" -> '1.265E+5' +basx240 toSci "1265E+3" -> '1.265E+6' +basx241 toSci "1265E+4" -> '1.265E+7' +basx242 toSci "1265E+8" -> '1.265E+11' +basx243 toSci "1265E+20" -> '1.265E+23' + +basx250 toSci "0.1265" -> '0.1265' +basx251 toSci "0.1265E-20" -> '1.265E-21' +basx252 toSci "0.1265E-8" -> '1.265E-9' +basx253 toSci "0.1265E-4" -> '0.00001265' +basx254 toSci "0.1265E-3" -> '0.0001265' +basx255 toSci "0.1265E-2" -> '0.001265' +basx256 toSci "0.1265E-1" -> '0.01265' +basx257 toSci "0.1265E-0" -> '0.1265' +basx258 toSci "0.1265E+1" -> '1.265' +basx259 toSci "0.1265E+2" -> '12.65' +basx260 toSci "0.1265E+3" -> '126.5' +basx261 toSci "0.1265E+4" -> '1265' +basx262 toSci "0.1265E+8" -> '1.265E+7' +basx263 toSci "0.1265E+20" -> '1.265E+19' + +basx270 toSci "0.09e999" -> '9E+997' +basx271 toSci "0.9e999" -> '9E+998' +basx272 toSci "9e999" -> '9E+999' +basx273 toSci "9.9e999" -> '9.9E+999' +basx274 toSci "9.99e999" -> '9.99E+999' +basx275 toSci "9.99e-999" -> '9.99E-999' +basx276 toSci "9.9e-999" -> '9.9E-999' +basx277 toSci "9e-999" -> '9E-999' +basx279 toSci "99e-999" -> '9.9E-998' +basx280 toSci "999e-999" -> '9.99E-997' +basx281 toSci '0.9e-998' -> '9E-999' +basx282 toSci '0.09e-997' -> '9E-999' +basx283 toSci '0.1e1000' -> '1E+999' +basx284 toSci '10e-1000' -> '1.0E-999' + +-- some more negative zeros [systematic tests below] +basx290 toSci "-0.000E-1" -> '-0.0000' +basx291 toSci "-0.000E-2" -> '-0.00000' +basx292 toSci "-0.000E-3" -> '-0.000000' +basx293 toSci "-0.000E-4" -> '-0E-7' +basx294 toSci "-0.00E-2" -> '-0.0000' +basx295 toSci "-0.00E-3" -> '-0.00000' +basx296 toSci "-0.0E-2" -> '-0.000' +basx297 toSci "-0.0E-3" -> '-0.0000' +basx298 toSci "-0E-2" -> '-0.00' +basx299 toSci "-0E-3" -> '-0.000' + +-- Engineering notation tests +basx301 toSci 10e12 -> 1.0E+13 +basx302 toEng 10e12 -> 10E+12 +basx303 toSci 10e11 -> 1.0E+12 +basx304 toEng 10e11 -> 1.0E+12 +basx305 toSci 10e10 -> 1.0E+11 +basx306 toEng 10e10 -> 100E+9 +basx307 toSci 10e9 -> 1.0E+10 +basx308 toEng 10e9 -> 10E+9 +basx309 toSci 10e8 -> 1.0E+9 +basx310 toEng 10e8 -> 1.0E+9 +basx311 toSci 10e7 -> 1.0E+8 +basx312 toEng 10e7 -> 100E+6 +basx313 toSci 10e6 -> 1.0E+7 +basx314 toEng 10e6 -> 10E+6 +basx315 toSci 10e5 -> 1.0E+6 +basx316 toEng 10e5 -> 1.0E+6 +basx317 toSci 10e4 -> 1.0E+5 +basx318 toEng 10e4 -> 100E+3 +basx319 toSci 10e3 -> 1.0E+4 +basx320 toEng 10e3 -> 10E+3 +basx321 toSci 10e2 -> 1.0E+3 +basx322 toEng 10e2 -> 1.0E+3 +basx323 toSci 10e1 -> 1.0E+2 +basx324 toEng 10e1 -> 100 +basx325 toSci 10e0 -> 10 +basx326 toEng 10e0 -> 10 +basx327 toSci 10e-1 -> 1.0 +basx328 toEng 10e-1 -> 1.0 +basx329 toSci 10e-2 -> 0.10 +basx330 toEng 10e-2 -> 0.10 +basx331 toSci 10e-3 -> 0.010 +basx332 toEng 10e-3 -> 0.010 +basx333 toSci 10e-4 -> 0.0010 +basx334 toEng 10e-4 -> 0.0010 +basx335 toSci 10e-5 -> 0.00010 +basx336 toEng 10e-5 -> 0.00010 +basx337 toSci 10e-6 -> 0.000010 +basx338 toEng 10e-6 -> 0.000010 +basx339 toSci 10e-7 -> 0.0000010 +basx340 toEng 10e-7 -> 0.0000010 +basx341 toSci 10e-8 -> 1.0E-7 +basx342 toEng 10e-8 -> 100E-9 +basx343 toSci 10e-9 -> 1.0E-8 +basx344 toEng 10e-9 -> 10E-9 +basx345 toSci 10e-10 -> 1.0E-9 +basx346 toEng 10e-10 -> 1.0E-9 +basx347 toSci 10e-11 -> 1.0E-10 +basx348 toEng 10e-11 -> 100E-12 +basx349 toSci 10e-12 -> 1.0E-11 +basx350 toEng 10e-12 -> 10E-12 +basx351 toSci 10e-13 -> 1.0E-12 +basx352 toEng 10e-13 -> 1.0E-12 + +basx361 toSci 7E12 -> 7E+12 +basx362 toEng 7E12 -> 7E+12 +basx363 toSci 7E11 -> 7E+11 +basx364 toEng 7E11 -> 700E+9 +basx365 toSci 7E10 -> 7E+10 +basx366 toEng 7E10 -> 70E+9 +basx367 toSci 7E9 -> 7E+9 +basx368 toEng 7E9 -> 7E+9 +basx369 toSci 7E8 -> 7E+8 +basx370 toEng 7E8 -> 700E+6 +basx371 toSci 7E7 -> 7E+7 +basx372 toEng 7E7 -> 70E+6 +basx373 toSci 7E6 -> 7E+6 +basx374 toEng 7E6 -> 7E+6 +basx375 toSci 7E5 -> 7E+5 +basx376 toEng 7E5 -> 700E+3 +basx377 toSci 7E4 -> 7E+4 +basx378 toEng 7E4 -> 70E+3 +basx379 toSci 7E3 -> 7E+3 +basx380 toEng 7E3 -> 7E+3 +basx381 toSci 7E2 -> 7E+2 +basx382 toEng 7E2 -> 700 +basx383 toSci 7E1 -> 7E+1 +basx384 toEng 7E1 -> 70 +basx385 toSci 7E0 -> 7 +basx386 toEng 7E0 -> 7 +basx387 toSci 7E-1 -> 0.7 +basx388 toEng 7E-1 -> 0.7 +basx389 toSci 7E-2 -> 0.07 +basx390 toEng 7E-2 -> 0.07 +basx391 toSci 7E-3 -> 0.007 +basx392 toEng 7E-3 -> 0.007 +basx393 toSci 7E-4 -> 0.0007 +basx394 toEng 7E-4 -> 0.0007 +basx395 toSci 7E-5 -> 0.00007 +basx396 toEng 7E-5 -> 0.00007 +basx397 toSci 7E-6 -> 0.000007 +basx398 toEng 7E-6 -> 0.000007 +basx399 toSci 7E-7 -> 7E-7 +basx400 toEng 7E-7 -> 700E-9 +basx401 toSci 7E-8 -> 7E-8 +basx402 toEng 7E-8 -> 70E-9 +basx403 toSci 7E-9 -> 7E-9 +basx404 toEng 7E-9 -> 7E-9 +basx405 toSci 7E-10 -> 7E-10 +basx406 toEng 7E-10 -> 700E-12 +basx407 toSci 7E-11 -> 7E-11 +basx408 toEng 7E-11 -> 70E-12 +basx409 toSci 7E-12 -> 7E-12 +basx410 toEng 7E-12 -> 7E-12 +basx411 toSci 7E-13 -> 7E-13 +basx412 toEng 7E-13 -> 700E-15 + +-- Exacts remain exact up to precision .. +precision: 9 +basx420 toSci 100 -> 100 +basx421 toEng 100 -> 100 +basx422 toSci 1000 -> 1000 +basx423 toEng 1000 -> 1000 +basx424 toSci 999.9 -> 999.9 +basx425 toEng 999.9 -> 999.9 +basx426 toSci 1000.0 -> 1000.0 +basx427 toEng 1000.0 -> 1000.0 +basx428 toSci 1000.1 -> 1000.1 +basx429 toEng 1000.1 -> 1000.1 +basx430 toSci 10000 -> 10000 +basx431 toEng 10000 -> 10000 +basx432 toSci 100000 -> 100000 +basx433 toEng 100000 -> 100000 +basx434 toSci 1000000 -> 1000000 +basx435 toEng 1000000 -> 1000000 +basx436 toSci 10000000 -> 10000000 +basx437 toEng 10000000 -> 10000000 +basx438 toSci 100000000 -> 100000000 +basx439 toEng 100000000 -> 100000000 +basx440 toSci 1000000000 -> 1.00000000E+9 Rounded +basx441 toEng 1000000000 -> 1.00000000E+9 Rounded +basx442 toSci 1000000000 -> 1.00000000E+9 Rounded +basx443 toEng 1000000000 -> 1.00000000E+9 Rounded +basx444 toSci 1000000003 -> 1.00000000E+9 Rounded Inexact +basx445 toEng 1000000003 -> 1.00000000E+9 Rounded Inexact +basx446 toSci 1000000005 -> 1.00000001E+9 Rounded Inexact +basx447 toEng 1000000005 -> 1.00000001E+9 Rounded Inexact +basx448 toSci 10000000050 -> 1.00000001E+10 Rounded Inexact +basx449 toEng 10000000050 -> 10.0000001E+9 Rounded Inexact +basx450 toSci 1000000009 -> 1.00000001E+9 Rounded Inexact +basx451 toEng 1000000009 -> 1.00000001E+9 Rounded Inexact +basx452 toSci 10000000000 -> 1.00000000E+10 Rounded +basx453 toEng 10000000000 -> 10.0000000E+9 Rounded +basx454 toSci 10000000003 -> 1.00000000E+10 Rounded Inexact +basx455 toEng 10000000003 -> 10.0000000E+9 Rounded Inexact +basx456 toSci 10000000005 -> 1.00000000E+10 Rounded Inexact +basx457 toEng 10000000005 -> 10.0000000E+9 Rounded Inexact +basx458 toSci 10000000009 -> 1.00000000E+10 Rounded Inexact +basx459 toEng 10000000009 -> 10.0000000E+9 Rounded Inexact +basx460 toSci 100000000000 -> 1.00000000E+11 Rounded +basx461 toEng 100000000000 -> 100.000000E+9 Rounded +basx462 toSci 100000000300 -> 1.00000000E+11 Rounded Inexact +basx463 toEng 100000000300 -> 100.000000E+9 Rounded Inexact +basx464 toSci 100000000500 -> 1.00000001E+11 Rounded Inexact +basx465 toEng 100000000500 -> 100.000001E+9 Rounded Inexact +basx466 toSci 100000000900 -> 1.00000001E+11 Rounded Inexact +basx467 toEng 100000000900 -> 100.000001E+9 Rounded Inexact +basx468 toSci 1000000000000 -> 1.00000000E+12 Rounded +basx469 toEng 1000000000000 -> 1.00000000E+12 Rounded +basx470 toSci 1000000003000 -> 1.00000000E+12 Rounded Inexact +basx471 toEng 1000000003000 -> 1.00000000E+12 Rounded Inexact +basx472 toSci 1000000005000 -> 1.00000001E+12 Rounded Inexact +basx473 toEng 1000000005000 -> 1.00000001E+12 Rounded Inexact +basx474 toSci 1000000009000 -> 1.00000001E+12 Rounded Inexact +basx475 toEng 1000000009000 -> 1.00000001E+12 Rounded Inexact + +-- check rounding modes heeded +precision: 5 +rounding: ceiling +bsrx401 toSci 1.23450 -> 1.2345 Rounded +bsrx402 toSci 1.234549 -> 1.2346 Rounded Inexact +bsrx403 toSci 1.234550 -> 1.2346 Rounded Inexact +bsrx404 toSci 1.234551 -> 1.2346 Rounded Inexact +rounding: down +bsrx405 toSci 1.23450 -> 1.2345 Rounded +bsrx406 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx407 toSci 1.234550 -> 1.2345 Rounded Inexact +bsrx408 toSci 1.234551 -> 1.2345 Rounded Inexact +rounding: floor +bsrx410 toSci 1.23450 -> 1.2345 Rounded +bsrx411 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx412 toSci 1.234550 -> 1.2345 Rounded Inexact +bsrx413 toSci 1.234551 -> 1.2345 Rounded Inexact +rounding: half_down +bsrx415 toSci 1.23450 -> 1.2345 Rounded +bsrx416 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx417 toSci 1.234550 -> 1.2345 Rounded Inexact +bsrx418 toSci 1.234650 -> 1.2346 Rounded Inexact +bsrx419 toSci 1.234551 -> 1.2346 Rounded Inexact +rounding: half_even +bsrx421 toSci 1.23450 -> 1.2345 Rounded +bsrx422 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx423 toSci 1.234550 -> 1.2346 Rounded Inexact +bsrx424 toSci 1.234650 -> 1.2346 Rounded Inexact +bsrx425 toSci 1.234551 -> 1.2346 Rounded Inexact +rounding: down +bsrx426 toSci 1.23450 -> 1.2345 Rounded +bsrx427 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx428 toSci 1.234550 -> 1.2345 Rounded Inexact +bsrx429 toSci 1.234551 -> 1.2345 Rounded Inexact +rounding: half_up +bsrx431 toSci 1.23450 -> 1.2345 Rounded +bsrx432 toSci 1.234549 -> 1.2345 Rounded Inexact +bsrx433 toSci 1.234550 -> 1.2346 Rounded Inexact +bsrx434 toSci 1.234650 -> 1.2347 Rounded Inexact +bsrx435 toSci 1.234551 -> 1.2346 Rounded Inexact +-- negatives +rounding: ceiling +bsrx501 toSci -1.23450 -> -1.2345 Rounded +bsrx502 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx503 toSci -1.234550 -> -1.2345 Rounded Inexact +bsrx504 toSci -1.234551 -> -1.2345 Rounded Inexact +rounding: down +bsrx505 toSci -1.23450 -> -1.2345 Rounded +bsrx506 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx507 toSci -1.234550 -> -1.2345 Rounded Inexact +bsrx508 toSci -1.234551 -> -1.2345 Rounded Inexact +rounding: floor +bsrx510 toSci -1.23450 -> -1.2345 Rounded +bsrx511 toSci -1.234549 -> -1.2346 Rounded Inexact +bsrx512 toSci -1.234550 -> -1.2346 Rounded Inexact +bsrx513 toSci -1.234551 -> -1.2346 Rounded Inexact +rounding: half_down +bsrx515 toSci -1.23450 -> -1.2345 Rounded +bsrx516 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx517 toSci -1.234550 -> -1.2345 Rounded Inexact +bsrx518 toSci -1.234650 -> -1.2346 Rounded Inexact +bsrx519 toSci -1.234551 -> -1.2346 Rounded Inexact +rounding: half_even +bsrx521 toSci -1.23450 -> -1.2345 Rounded +bsrx522 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx523 toSci -1.234550 -> -1.2346 Rounded Inexact +bsrx524 toSci -1.234650 -> -1.2346 Rounded Inexact +bsrx525 toSci -1.234551 -> -1.2346 Rounded Inexact +rounding: down +bsrx526 toSci -1.23450 -> -1.2345 Rounded +bsrx527 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx528 toSci -1.234550 -> -1.2345 Rounded Inexact +bsrx529 toSci -1.234551 -> -1.2345 Rounded Inexact +rounding: half_up +bsrx531 toSci -1.23450 -> -1.2345 Rounded +bsrx532 toSci -1.234549 -> -1.2345 Rounded Inexact +bsrx533 toSci -1.234550 -> -1.2346 Rounded Inexact +bsrx534 toSci -1.234650 -> -1.2347 Rounded Inexact +bsrx535 toSci -1.234551 -> -1.2346 Rounded Inexact + +rounding: half_up +precision: 9 + +-- The 'baddies' tests from DiagBigDecimal, plus some new ones +basx500 toSci '1..2' -> NaN Conversion_syntax +basx501 toSci '.' -> NaN Conversion_syntax +basx502 toSci '..' -> NaN Conversion_syntax +basx503 toSci '++1' -> NaN Conversion_syntax +basx504 toSci '--1' -> NaN Conversion_syntax +basx505 toSci '-+1' -> NaN Conversion_syntax +basx506 toSci '+-1' -> NaN Conversion_syntax +basx507 toSci '12e' -> NaN Conversion_syntax +basx508 toSci '12e++' -> NaN Conversion_syntax +basx509 toSci '12f4' -> NaN Conversion_syntax +basx510 toSci ' +1' -> NaN Conversion_syntax +basx511 toSci '+ 1' -> NaN Conversion_syntax +basx512 toSci '12 ' -> NaN Conversion_syntax +basx513 toSci ' + 1' -> NaN Conversion_syntax +basx514 toSci ' - 1 ' -> NaN Conversion_syntax +basx515 toSci 'x' -> NaN Conversion_syntax +basx516 toSci '-1-' -> NaN Conversion_syntax +basx517 toSci '12-' -> NaN Conversion_syntax +basx518 toSci '3+' -> NaN Conversion_syntax +basx519 toSci '' -> NaN Conversion_syntax +basx520 toSci '1e-' -> NaN Conversion_syntax +basx521 toSci '7e99999a' -> NaN Conversion_syntax +basx522 toSci '7e123567890x' -> NaN Conversion_syntax +basx523 toSci '7e12356789012x' -> NaN Conversion_syntax +basx524 toSci '' -> NaN Conversion_syntax +basx525 toSci 'e100' -> NaN Conversion_syntax +basx526 toSci '\u0e5a' -> NaN Conversion_syntax +basx527 toSci '\u0b65' -> NaN Conversion_syntax +basx528 toSci '123,65' -> NaN Conversion_syntax +basx529 toSci '1.34.5' -> NaN Conversion_syntax +basx530 toSci '.123.5' -> NaN Conversion_syntax +basx531 toSci '01.35.' -> NaN Conversion_syntax +basx532 toSci '01.35-' -> NaN Conversion_syntax +basx533 toSci '0000..' -> NaN Conversion_syntax +basx534 toSci '.0000.' -> NaN Conversion_syntax +basx535 toSci '00..00' -> NaN Conversion_syntax +basx536 toSci '111e*123' -> NaN Conversion_syntax +basx537 toSci '111e123-' -> NaN Conversion_syntax +basx538 toSci '111e+12+' -> NaN Conversion_syntax +basx539 toSci '111e1-3-' -> NaN Conversion_syntax +basx540 toSci '111e1*23' -> NaN Conversion_syntax +basx541 toSci '111e1e+3' -> NaN Conversion_syntax +basx542 toSci '1e1.0' -> NaN Conversion_syntax +basx543 toSci '1e123e' -> NaN Conversion_syntax +basx544 toSci 'ten' -> NaN Conversion_syntax +basx545 toSci 'ONE' -> NaN Conversion_syntax +basx546 toSci '1e.1' -> NaN Conversion_syntax +basx547 toSci '1e1.' -> NaN Conversion_syntax +basx548 toSci '1ee' -> NaN Conversion_syntax +basx549 toSci 'e+1' -> NaN Conversion_syntax +basx550 toSci '1.23.4' -> NaN Conversion_syntax +basx551 toSci '1.2.1' -> NaN Conversion_syntax +basx552 toSci '1E+1.2' -> NaN Conversion_syntax +basx553 toSci '1E+1.2.3' -> NaN Conversion_syntax +basx554 toSci '1E++1' -> NaN Conversion_syntax +basx555 toSci '1E--1' -> NaN Conversion_syntax +basx556 toSci '1E+-1' -> NaN Conversion_syntax +basx557 toSci '1E-+1' -> NaN Conversion_syntax +basx558 toSci '1E''1' -> NaN Conversion_syntax +basx559 toSci "1E""1" -> NaN Conversion_syntax +basx560 toSci "1E""""" -> NaN Conversion_syntax +-- Near-specials +basx561 toSci "qNaN" -> NaN Conversion_syntax +basx562 toSci "NaNq" -> NaN Conversion_syntax +basx563 toSci "NaNs" -> NaN Conversion_syntax +basx564 toSci "Infi" -> NaN Conversion_syntax +basx565 toSci "Infin" -> NaN Conversion_syntax +basx566 toSci "Infini" -> NaN Conversion_syntax +basx567 toSci "Infinit" -> NaN Conversion_syntax +basx568 toSci "-Infinit" -> NaN Conversion_syntax +basx569 toSci "0Inf" -> NaN Conversion_syntax +basx570 toSci "9Inf" -> NaN Conversion_syntax +basx571 toSci "-0Inf" -> NaN Conversion_syntax +basx572 toSci "-9Inf" -> NaN Conversion_syntax +basx573 toSci "-sNa" -> NaN Conversion_syntax +basx574 toSci "xNaN" -> NaN Conversion_syntax +basx575 toSci "0sNaN" -> NaN Conversion_syntax + +-- subnormals and overflows +basx576 toSci '99e999999999' -> Infinity Overflow Inexact Rounded +basx577 toSci '999e999999999' -> Infinity Overflow Inexact Rounded +basx578 toSci '0.9e-999999999' -> 9E-1000000000 Subnormal +basx579 toSci '0.09e-999999999' -> 9E-1000000001 Subnormal +basx580 toSci '0.1e1000000000' -> 1E+999999999 +basx581 toSci '10e-1000000000' -> 1.0E-999999999 +basx582 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded +basx583 toSci '99e-9999999999' -> 0E-1000000007 Underflow Subnormal Inexact Rounded +basx584 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded +basx585 toSci '1111e-9999999999' -> 0E-1000000007 Underflow Subnormal Inexact Rounded +basx586 toSci '1111e-99999999999' -> 0E-1000000007 Underflow Subnormal Inexact Rounded +basx587 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded +-- negatives the same +basx588 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded +basx589 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded +basx590 toSci '-0.9e-999999999' -> -9E-1000000000 Subnormal +basx591 toSci '-0.09e-999999999' -> -9E-1000000001 Subnormal +basx592 toSci '-0.1e1000000000' -> -1E+999999999 +basx593 toSci '-10e-1000000000' -> -1.0E-999999999 +basx594 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded +basx595 toSci '-99e-9999999999' -> -0E-1000000007 Underflow Subnormal Inexact Rounded +basx596 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded +basx597 toSci '-1111e-9999999999' -> -0E-1000000007 Underflow Subnormal Inexact Rounded +basx598 toSci '-1111e-99999999999' -> -0E-1000000007 Underflow Subnormal Inexact Rounded +basx599 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded + +-- Zeros +basx601 toSci 0.000000000 -> 0E-9 +basx602 toSci 0.00000000 -> 0E-8 +basx603 toSci 0.0000000 -> 0E-7 +basx604 toSci 0.000000 -> 0.000000 +basx605 toSci 0.00000 -> 0.00000 +basx606 toSci 0.0000 -> 0.0000 +basx607 toSci 0.000 -> 0.000 +basx608 toSci 0.00 -> 0.00 +basx609 toSci 0.0 -> 0.0 +basx610 toSci .0 -> 0.0 +basx611 toSci 0. -> 0 +basx612 toSci -.0 -> -0.0 +basx613 toSci -0. -> -0 +basx614 toSci -0.0 -> -0.0 +basx615 toSci -0.00 -> -0.00 +basx616 toSci -0.000 -> -0.000 +basx617 toSci -0.0000 -> -0.0000 +basx618 toSci -0.00000 -> -0.00000 +basx619 toSci -0.000000 -> -0.000000 +basx620 toSci -0.0000000 -> -0E-7 +basx621 toSci -0.00000000 -> -0E-8 +basx622 toSci -0.000000000 -> -0E-9 + +basx630 toSci 0.00E+0 -> 0.00 +basx631 toSci 0.00E+1 -> 0.0 +basx632 toSci 0.00E+2 -> 0 +basx633 toSci 0.00E+3 -> 0E+1 +basx634 toSci 0.00E+4 -> 0E+2 +basx635 toSci 0.00E+5 -> 0E+3 +basx636 toSci 0.00E+6 -> 0E+4 +basx637 toSci 0.00E+7 -> 0E+5 +basx638 toSci 0.00E+8 -> 0E+6 +basx639 toSci 0.00E+9 -> 0E+7 + +basx640 toSci 0.0E+0 -> 0.0 +basx641 toSci 0.0E+1 -> 0 +basx642 toSci 0.0E+2 -> 0E+1 +basx643 toSci 0.0E+3 -> 0E+2 +basx644 toSci 0.0E+4 -> 0E+3 +basx645 toSci 0.0E+5 -> 0E+4 +basx646 toSci 0.0E+6 -> 0E+5 +basx647 toSci 0.0E+7 -> 0E+6 +basx648 toSci 0.0E+8 -> 0E+7 +basx649 toSci 0.0E+9 -> 0E+8 + +basx650 toSci 0E+0 -> 0 +basx651 toSci 0E+1 -> 0E+1 +basx652 toSci 0E+2 -> 0E+2 +basx653 toSci 0E+3 -> 0E+3 +basx654 toSci 0E+4 -> 0E+4 +basx655 toSci 0E+5 -> 0E+5 +basx656 toSci 0E+6 -> 0E+6 +basx657 toSci 0E+7 -> 0E+7 +basx658 toSci 0E+8 -> 0E+8 +basx659 toSci 0E+9 -> 0E+9 + +basx660 toSci 0.0E-0 -> 0.0 +basx661 toSci 0.0E-1 -> 0.00 +basx662 toSci 0.0E-2 -> 0.000 +basx663 toSci 0.0E-3 -> 0.0000 +basx664 toSci 0.0E-4 -> 0.00000 +basx665 toSci 0.0E-5 -> 0.000000 +basx666 toSci 0.0E-6 -> 0E-7 +basx667 toSci 0.0E-7 -> 0E-8 +basx668 toSci 0.0E-8 -> 0E-9 +basx669 toSci 0.0E-9 -> 0E-10 + +basx670 toSci 0.00E-0 -> 0.00 +basx671 toSci 0.00E-1 -> 0.000 +basx672 toSci 0.00E-2 -> 0.0000 +basx673 toSci 0.00E-3 -> 0.00000 +basx674 toSci 0.00E-4 -> 0.000000 +basx675 toSci 0.00E-5 -> 0E-7 +basx676 toSci 0.00E-6 -> 0E-8 +basx677 toSci 0.00E-7 -> 0E-9 +basx678 toSci 0.00E-8 -> 0E-10 +basx679 toSci 0.00E-9 -> 0E-11 + +-- Specials +precision: 4 +basx700 toSci "NaN" -> NaN +basx701 toSci "nan" -> NaN +basx702 toSci "nAn" -> NaN +basx703 toSci "NAN" -> NaN +basx704 toSci "+NaN" -> NaN +basx705 toSci "+nan" -> NaN +basx706 toSci "+nAn" -> NaN +basx707 toSci "+NAN" -> NaN +basx708 toSci "-NaN" -> -NaN +basx709 toSci "-nan" -> -NaN +basx710 toSci "-nAn" -> -NaN +basx711 toSci "-NAN" -> -NaN +basx712 toSci 'NaN0' -> NaN +basx713 toSci 'NaN1' -> NaN1 +basx714 toSci 'NaN12' -> NaN12 +basx715 toSci 'NaN123' -> NaN123 +basx716 toSci 'NaN1234' -> NaN1234 +basx717 toSci 'NaN01' -> NaN1 +basx718 toSci 'NaN012' -> NaN12 +basx719 toSci 'NaN0123' -> NaN123 +basx720 toSci 'NaN01234' -> NaN1234 +basx721 toSci 'NaN001' -> NaN1 +basx722 toSci 'NaN0012' -> NaN12 +basx723 toSci 'NaN00123' -> NaN123 +basx724 toSci 'NaN001234' -> NaN1234 +basx725 toSci 'NaN12345' -> NaN Conversion_syntax +basx726 toSci 'NaN123e+1' -> NaN Conversion_syntax +basx727 toSci 'NaN12.45' -> NaN Conversion_syntax +basx728 toSci 'NaN-12' -> NaN Conversion_syntax +basx729 toSci 'NaN+12' -> NaN Conversion_syntax + +basx730 toSci "sNaN" -> sNaN +basx731 toSci "snan" -> sNaN +basx732 toSci "SnAn" -> sNaN +basx733 toSci "SNAN" -> sNaN +basx734 toSci "+sNaN" -> sNaN +basx735 toSci "+snan" -> sNaN +basx736 toSci "+SnAn" -> sNaN +basx737 toSci "+SNAN" -> sNaN +basx738 toSci "-sNaN" -> -sNaN +basx739 toSci "-snan" -> -sNaN +basx740 toSci "-SnAn" -> -sNaN +basx741 toSci "-SNAN" -> -sNaN +basx742 toSci 'sNaN0000' -> sNaN +basx743 toSci 'sNaN7' -> sNaN7 +basx744 toSci 'sNaN007234' -> sNaN7234 +basx745 toSci 'sNaN72345' -> NaN Conversion_syntax +basx746 toSci 'sNaN72.45' -> NaN Conversion_syntax +basx747 toSci 'sNaN-72' -> NaN Conversion_syntax + +basx748 toSci "Inf" -> Infinity +basx749 toSci "inf" -> Infinity +basx750 toSci "iNf" -> Infinity +basx751 toSci "INF" -> Infinity +basx752 toSci "+Inf" -> Infinity +basx753 toSci "+inf" -> Infinity +basx754 toSci "+iNf" -> Infinity +basx755 toSci "+INF" -> Infinity +basx756 toSci "-Inf" -> -Infinity +basx757 toSci "-inf" -> -Infinity +basx758 toSci "-iNf" -> -Infinity +basx759 toSci "-INF" -> -Infinity + +basx760 toSci "Infinity" -> Infinity +basx761 toSci "infinity" -> Infinity +basx762 toSci "iNfInItY" -> Infinity +basx763 toSci "INFINITY" -> Infinity +basx764 toSci "+Infinity" -> Infinity +basx765 toSci "+infinity" -> Infinity +basx766 toSci "+iNfInItY" -> Infinity +basx767 toSci "+INFINITY" -> Infinity +basx768 toSci "-Infinity" -> -Infinity +basx769 toSci "-infinity" -> -Infinity +basx770 toSci "-iNfInItY" -> -Infinity +basx771 toSci "-INFINITY" -> -Infinity + +-- Specials and zeros for toEng +basx772 toEng "NaN" -> NaN +basx773 toEng "-Infinity" -> -Infinity +basx774 toEng "-sNaN" -> -sNaN +basx775 toEng "-NaN" -> -NaN +basx776 toEng "+Infinity" -> Infinity +basx778 toEng "+sNaN" -> sNaN +basx779 toEng "+NaN" -> NaN +basx780 toEng "INFINITY" -> Infinity +basx781 toEng "SNAN" -> sNaN +basx782 toEng "NAN" -> NaN +basx783 toEng "infinity" -> Infinity +basx784 toEng "snan" -> sNaN +basx785 toEng "nan" -> NaN +basx786 toEng "InFINITY" -> Infinity +basx787 toEng "SnAN" -> sNaN +basx788 toEng "nAN" -> NaN +basx789 toEng "iNfinity" -> Infinity +basx790 toEng "sNan" -> sNaN +basx791 toEng "Nan" -> NaN +basx792 toEng "Infinity" -> Infinity +basx793 toEng "sNaN" -> sNaN + +-- Zero toEng, etc. +basx800 toEng 0e+1 -> "0.00E+3" -- doc example + +basx801 toEng 0.000000000 -> 0E-9 +basx802 toEng 0.00000000 -> 0.00E-6 +basx803 toEng 0.0000000 -> 0.0E-6 +basx804 toEng 0.000000 -> 0.000000 +basx805 toEng 0.00000 -> 0.00000 +basx806 toEng 0.0000 -> 0.0000 +basx807 toEng 0.000 -> 0.000 +basx808 toEng 0.00 -> 0.00 +basx809 toEng 0.0 -> 0.0 +basx810 toEng .0 -> 0.0 +basx811 toEng 0. -> 0 +basx812 toEng -.0 -> -0.0 +basx813 toEng -0. -> -0 +basx814 toEng -0.0 -> -0.0 +basx815 toEng -0.00 -> -0.00 +basx816 toEng -0.000 -> -0.000 +basx817 toEng -0.0000 -> -0.0000 +basx818 toEng -0.00000 -> -0.00000 +basx819 toEng -0.000000 -> -0.000000 +basx820 toEng -0.0000000 -> -0.0E-6 +basx821 toEng -0.00000000 -> -0.00E-6 +basx822 toEng -0.000000000 -> -0E-9 + +basx830 toEng 0.00E+0 -> 0.00 +basx831 toEng 0.00E+1 -> 0.0 +basx832 toEng 0.00E+2 -> 0 +basx833 toEng 0.00E+3 -> 0.00E+3 +basx834 toEng 0.00E+4 -> 0.0E+3 +basx835 toEng 0.00E+5 -> 0E+3 +basx836 toEng 0.00E+6 -> 0.00E+6 +basx837 toEng 0.00E+7 -> 0.0E+6 +basx838 toEng 0.00E+8 -> 0E+6 +basx839 toEng 0.00E+9 -> 0.00E+9 + +basx840 toEng 0.0E+0 -> 0.0 +basx841 toEng 0.0E+1 -> 0 +basx842 toEng 0.0E+2 -> 0.00E+3 +basx843 toEng 0.0E+3 -> 0.0E+3 +basx844 toEng 0.0E+4 -> 0E+3 +basx845 toEng 0.0E+5 -> 0.00E+6 +basx846 toEng 0.0E+6 -> 0.0E+6 +basx847 toEng 0.0E+7 -> 0E+6 +basx848 toEng 0.0E+8 -> 0.00E+9 +basx849 toEng 0.0E+9 -> 0.0E+9 + +basx850 toEng 0E+0 -> 0 +basx851 toEng 0E+1 -> 0.00E+3 +basx852 toEng 0E+2 -> 0.0E+3 +basx853 toEng 0E+3 -> 0E+3 +basx854 toEng 0E+4 -> 0.00E+6 +basx855 toEng 0E+5 -> 0.0E+6 +basx856 toEng 0E+6 -> 0E+6 +basx857 toEng 0E+7 -> 0.00E+9 +basx858 toEng 0E+8 -> 0.0E+9 +basx859 toEng 0E+9 -> 0E+9 + +basx860 toEng 0.0E-0 -> 0.0 +basx861 toEng 0.0E-1 -> 0.00 +basx862 toEng 0.0E-2 -> 0.000 +basx863 toEng 0.0E-3 -> 0.0000 +basx864 toEng 0.0E-4 -> 0.00000 +basx865 toEng 0.0E-5 -> 0.000000 +basx866 toEng 0.0E-6 -> 0.0E-6 +basx867 toEng 0.0E-7 -> 0.00E-6 +basx868 toEng 0.0E-8 -> 0E-9 +basx869 toEng 0.0E-9 -> 0.0E-9 + +basx870 toEng 0.00E-0 -> 0.00 +basx871 toEng 0.00E-1 -> 0.000 +basx872 toEng 0.00E-2 -> 0.0000 +basx873 toEng 0.00E-3 -> 0.00000 +basx874 toEng 0.00E-4 -> 0.000000 +basx875 toEng 0.00E-5 -> 0.0E-6 +basx876 toEng 0.00E-6 -> 0.00E-6 +basx877 toEng 0.00E-7 -> 0E-9 +basx878 toEng 0.00E-8 -> 0.0E-9 +basx879 toEng 0.00E-9 -> 0.00E-9 + +-- Giga exponent initial tests +maxExponent: 999999999 +minExponent: -999999999 + +basx951 toSci '99e999' -> '9.9E+1000' +basx952 toSci '999e999' -> '9.99E+1001' +basx953 toSci '0.9e-999' -> '9E-1000' +basx954 toSci '0.09e-999' -> '9E-1001' +basx955 toSci '0.1e1001' -> '1E+1000' +basx956 toSci '10e-1001' -> '1.0E-1000' +basx957 toSci '0.9e9999' -> '9E+9998' +basx958 toSci '99e-9999' -> '9.9E-9998' +basx959 toSci '111e9997' -> '1.11E+9999' +basx960 toSci '1111e-9999' -> '1.111E-9996' +basx961 toSci '99e9999' -> '9.9E+10000' +basx962 toSci '999e9999' -> '9.99E+10001' +basx963 toSci '0.9e-9999' -> '9E-10000' +basx964 toSci '0.09e-9999' -> '9E-10001' +basx965 toSci '0.1e10001' -> '1E+10000' +basx966 toSci '10e-10001' -> '1.0E-10000' +basx967 toSci '0.9e99999' -> '9E+99998' +basx968 toSci '99e-99999' -> '9.9E-99998' +basx969 toSci '111e99999' -> '1.11E+100001' +basx970 toSci '1111e-99999' -> '1.111E-99996' +basx971 toSci "0.09e999999999" -> '9E+999999997' +basx972 toSci "0.9e999999999" -> '9E+999999998' +basx973 toSci "9e999999999" -> '9E+999999999' +basx974 toSci "9.9e999999999" -> '9.9E+999999999' +basx975 toSci "9.99e999999999" -> '9.99E+999999999' +basx976 toSci "9.99e-999999999" -> '9.99E-999999999' +basx977 toSci "9.9e-999999999" -> '9.9E-999999999' +basx978 toSci "9e-999999999" -> '9E-999999999' +basx979 toSci "99e-999999999" -> '9.9E-999999998' +basx980 toSci "999e-999999999" -> '9.99E-999999997' + +-- Varying exponent maximums +precision: 5 +maxexponent: 0 +minexponent: 0 +emax001 toSci -1E+2 -> -Infinity Overflow Inexact Rounded +emax002 toSci -100 -> -Infinity Overflow Inexact Rounded +emax003 toSci -10 -> -Infinity Overflow Inexact Rounded +emax004 toSci -9.9 -> -9.9 +emax005 toSci -9 -> -9 +emax006 toSci -1 -> -1 +emax007 toSci 0 -> 0 +emax008 toSci 1 -> 1 +emax009 toSci 9 -> 9 +emax010 toSci 9.9 -> 9.9 +emax011 toSci 10 -> Infinity Overflow Inexact Rounded +emax012 toSci 100 -> Infinity Overflow Inexact Rounded +emax013 toSci 1E+2 -> Infinity Overflow Inexact Rounded +emax014 toSci 0.99 -> 0.99 Subnormal +emax015 toSci 0.1 -> 0.1 Subnormal +emax016 toSci 0.01 -> 0.01 Subnormal +emax017 toSci 1E-1 -> 0.1 Subnormal +emax018 toSci 1E-2 -> 0.01 Subnormal + +maxexponent: 1 +minexponent: -1 +emax100 toSci -1E+3 -> -Infinity Overflow Inexact Rounded +emax101 toSci -1E+2 -> -Infinity Overflow Inexact Rounded +emax102 toSci -100 -> -Infinity Overflow Inexact Rounded +emax103 toSci -10 -> -10 +emax104 toSci -9.9 -> -9.9 +emax105 toSci -9 -> -9 +emax106 toSci -1 -> -1 +emax107 toSci 0 -> 0 +emax108 toSci 1 -> 1 +emax109 toSci 9 -> 9 +emax110 toSci 9.9 -> 9.9 +emax111 toSci 10 -> 10 +emax112 toSci 100 -> Infinity Overflow Inexact Rounded +emax113 toSci 1E+2 -> Infinity Overflow Inexact Rounded +emax114 toSci 1E+3 -> Infinity Overflow Inexact Rounded +emax115 toSci 0.99 -> 0.99 +emax116 toSci 0.1 -> 0.1 +emax117 toSci 0.01 -> 0.01 Subnormal +emax118 toSci 1E-1 -> 0.1 +emax119 toSci 1E-2 -> 0.01 Subnormal +emax120 toSci 1E-3 -> 0.001 Subnormal +emax121 toSci 1.1E-3 -> 0.0011 Subnormal +emax122 toSci 1.11E-3 -> 0.00111 Subnormal +emax123 toSci 1.111E-3 -> 0.00111 Subnormal Underflow Inexact Rounded +emax124 toSci 1.1111E-3 -> 0.00111 Subnormal Underflow Inexact Rounded +emax125 toSci 1.11111E-3 -> 0.00111 Subnormal Underflow Inexact Rounded + +maxexponent: 2 +minexponent: -2 +precision: 9 +emax200 toSci -1E+3 -> -Infinity Overflow Inexact Rounded +emax201 toSci -1E+2 -> -1E+2 +emax202 toSci -100 -> -100 +emax203 toSci -10 -> -10 +emax204 toSci -9.9 -> -9.9 +emax205 toSci -9 -> -9 +emax206 toSci -1 -> -1 +emax207 toSci 0 -> 0 +emax208 toSci 1 -> 1 +emax209 toSci 9 -> 9 +emax210 toSci 9.9 -> 9.9 +emax211 toSci 10 -> 10 +emax212 toSci 100 -> 100 +emax213 toSci 1E+2 -> 1E+2 +emax214 toSci 1E+3 -> Infinity Overflow Inexact Rounded +emax215 toSci 0.99 -> 0.99 +emax216 toSci 0.1 -> 0.1 +emax217 toSci 0.01 -> 0.01 +emax218 toSci 0.001 -> 0.001 Subnormal +emax219 toSci 1E-1 -> 0.1 +emax220 toSci 1E-2 -> 0.01 +emax221 toSci 1E-3 -> 0.001 Subnormal +emax222 toSci 1E-4 -> 0.0001 Subnormal +emax223 toSci 1E-5 -> 0.00001 Subnormal +emax224 toSci 1E-6 -> 0.000001 Subnormal +emax225 toSci 1E-7 -> 1E-7 Subnormal +emax226 toSci 1E-8 -> 1E-8 Subnormal +emax227 toSci 1E-9 -> 1E-9 Subnormal +emax228 toSci 1E-10 -> 1E-10 Subnormal +emax229 toSci 1E-11 -> 0E-10 Underflow Subnormal Inexact Rounded +emax230 toSci 1E-12 -> 0E-10 Underflow Subnormal Inexact Rounded + +maxexponent: 7 +minexponent: -7 +emax231 toSci 1E-8 -> 1E-8 Subnormal +emax232 toSci 1E-7 -> 1E-7 +emax233 toSci 1E-6 -> 0.000001 +emax234 toSci 1E-5 -> 0.00001 +emax235 toSci 1E+5 -> 1E+5 +emax236 toSci 1E+6 -> 1E+6 +emax237 toSci 1E+7 -> 1E+7 +emax238 toSci 1E+8 -> Infinity Overflow Inexact Rounded + +maxexponent: 9 +minexponent: -9 +emax240 toSci 1E-21 -> 0E-17 Subnormal Underflow Inexact Rounded +emax241 toSci 1E-10 -> 1E-10 Subnormal +emax242 toSci 1E-9 -> 1E-9 +emax243 toSci 1E-8 -> 1E-8 +emax244 toSci 1E-7 -> 1E-7 +emax245 toSci 1E+7 -> 1E+7 +emax246 toSci 1E+8 -> 1E+8 +emax247 toSci 1E+9 -> 1E+9 +emax248 toSci 1E+10 -> Infinity Overflow Inexact Rounded + +maxexponent: 10 -- boundary +minexponent: -10 +emax250 toSci 1E-21 -> 0E-18 Underflow Subnormal Inexact Rounded +emax251 toSci 1E-11 -> 1E-11 Subnormal +emax252 toSci 1E-10 -> 1E-10 +emax253 toSci 1E-9 -> 1E-9 +emax254 toSci 1E-8 -> 1E-8 +emax255 toSci 1E+8 -> 1E+8 +emax256 toSci 1E+9 -> 1E+9 +emax257 toSci 1E+10 -> 1E+10 +emax258 toSci 1E+11 -> Infinity Overflow Inexact Rounded + +emax260 toSci 1.00E-21 -> 0E-18 Underflow Subnormal Inexact Rounded +emax261 toSci 1.00E-11 -> 1.00E-11 Subnormal +emax262 toSci 1.00E-10 -> 1.00E-10 +emax263 toSci 1.00E-9 -> 1.00E-9 +emax264 toSci 1.00E-8 -> 1.00E-8 +emax265 toSci 1.00E+8 -> 1.00E+8 +emax266 toSci 1.00E+9 -> 1.00E+9 +emax267 toSci 1.00E+10 -> 1.00E+10 +emax268 toSci 1.00E+11 -> Infinity Overflow Inexact Rounded +emax270 toSci 9.99E-21 -> 0E-18 Underflow Subnormal Inexact Rounded +emax271 toSci 9.99E-11 -> 9.99E-11 Subnormal +emax272 toSci 9.99E-10 -> 9.99E-10 +emax273 toSci 9.99E-9 -> 9.99E-9 +emax274 toSci 9.99E-8 -> 9.99E-8 +emax275 toSci 9.99E+8 -> 9.99E+8 +emax276 toSci 9.99E+9 -> 9.99E+9 +emax277 toSci 9.99E+10 -> 9.99E+10 +emax278 toSci 9.99E+11 -> Infinity Overflow Inexact Rounded + +maxexponent: 99 +minexponent: -99 +emax280 toSci 1E-120 -> 0E-107 Underflow Subnormal Inexact Rounded +emax281 toSci 1E-100 -> 1E-100 Subnormal +emax282 toSci 1E-99 -> 1E-99 +emax283 toSci 1E-98 -> 1E-98 +emax284 toSci 1E+98 -> 1E+98 +emax285 toSci 1E+99 -> 1E+99 +emax286 toSci 1E+100 -> Infinity Overflow Inexact Rounded + +maxexponent: 999 +minexponent: -999 +emax291 toSci 1E-1000 -> 1E-1000 Subnormal +emax292 toSci 1E-999 -> 1E-999 +emax293 toSci 1E+999 -> 1E+999 +emax294 toSci 1E+1000 -> Infinity Overflow Inexact Rounded +maxexponent: 9999 +minexponent: -9999 +emax301 toSci 1E-10000 -> 1E-10000 Subnormal +emax302 toSci 1E-9999 -> 1E-9999 +emax303 toSci 1E+9999 -> 1E+9999 +emax304 toSci 1E+10000 -> Infinity Overflow Inexact Rounded +maxexponent: 99999 +minexponent: -99999 +emax311 toSci 1E-100000 -> 1E-100000 Subnormal +emax312 toSci 1E-99999 -> 1E-99999 +emax313 toSci 1E+99999 -> 1E+99999 +emax314 toSci 1E+100000 -> Infinity Overflow Inexact Rounded +maxexponent: 999999 +minexponent: -999999 +emax321 toSci 1E-1000000 -> 1E-1000000 Subnormal +emax322 toSci 1E-999999 -> 1E-999999 +emax323 toSci 1E+999999 -> 1E+999999 +emax324 toSci 1E+1000000 -> Infinity Overflow Inexact Rounded +maxexponent: 9999999 +minexponent: -9999999 +emax331 toSci 1E-10000000 -> 1E-10000000 Subnormal +emax332 toSci 1E-9999999 -> 1E-9999999 +emax333 toSci 1E+9999999 -> 1E+9999999 +emax334 toSci 1E+10000000 -> Infinity Overflow Inexact Rounded +maxexponent: 99999999 +minexponent: -99999999 +emax341 toSci 1E-100000000 -> 1E-100000000 Subnormal +emax342 toSci 1E-99999999 -> 1E-99999999 +emax343 toSci 1E+99999999 -> 1E+99999999 +emax344 toSci 1E+100000000 -> Infinity Overflow Inexact Rounded + +maxexponent: 999999999 +minexponent: -999999999 +emax347 toSci 1E-1000000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +emax348 toSci 1E-1000000007 -> 1E-1000000007 Subnormal +emax349 toSci 1E-1000000000 -> 1E-1000000000 Subnormal +emax350 toSci 1E-999999999 -> 1E-999999999 +emax351 toSci 1E+999999999 -> 1E+999999999 +emax352 toSci 1E+1000000000 -> Infinity Overflow Inexact Rounded +emax353 toSci 1.000E-1000000000 -> 1.000E-1000000000 Subnormal +emax354 toSci 1.000E-999999999 -> 1.000E-999999999 +emax355 toSci 1.000E+999999999 -> 1.000E+999999999 +emax356 toSci 1.000E+1000000000 -> Infinity Overflow Inexact Rounded +emax357 toSci 1.001E-1000000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +emax358 toSci 1.001E-1000000007 -> 1E-1000000007 Subnormal Inexact Rounded Underflow +emax359 toSci 1.001E-1000000000 -> 1.001E-1000000000 Subnormal +emax360 toSci 1.001E-999999999 -> 1.001E-999999999 +emax361 toSci 1.001E+999999999 -> 1.001E+999999999 +emax362 toSci 1.001E+1000000000 -> Infinity Overflow Inexact Rounded +emax363 toSci 9.000E-1000000000 -> 9.000E-1000000000 Subnormal +emax364 toSci 9.000E-999999999 -> 9.000E-999999999 +emax365 toSci 9.000E+999999999 -> 9.000E+999999999 +emax366 toSci 9.000E+1000000000 -> Infinity Overflow Inexact Rounded +emax367 toSci 9.999E-1000000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +emax368 toSci 9.999E-1000000008 -> 1E-1000000007 Underflow Subnormal Inexact Rounded +emax369 toSci 9.999E-1000000007 -> 1.0E-1000000006 Underflow Subnormal Inexact Rounded +emax370 toSci 9.999E-1000000000 -> 9.999E-1000000000 Subnormal +emax371 toSci 9.999E-999999999 -> 9.999E-999999999 +emax372 toSci 9.999E+999999999 -> 9.999E+999999999 + +emax373 toSci 9.999E+1000000000 -> Infinity Overflow Inexact Rounded +emax374 toSci -1E-1000000000 -> -1E-1000000000 Subnormal +emax375 toSci -1E-999999999 -> -1E-999999999 +emax376 toSci -1E+999999999 -> -1E+999999999 +emax377 toSci -1E+1000000000 -> -Infinity Overflow Inexact Rounded +emax378 toSci -1.000E-1000000000 -> -1.000E-1000000000 Subnormal +emax379 toSci -1.000E-999999999 -> -1.000E-999999999 +emax380 toSci -1.000E+999999999 -> -1.000E+999999999 +emax381 toSci -1.000E+1000000000 -> -Infinity Overflow Inexact Rounded +emax382 toSci -1.001E-1000000008 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +emax383 toSci -1.001E-999999999 -> -1.001E-999999999 +emax384 toSci -1.001E+999999999 -> -1.001E+999999999 +emax385 toSci -1.001E+1000000000 -> -Infinity Overflow Inexact Rounded +emax386 toSci -9.000E-1000000123 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +emax387 toSci -9.000E-999999999 -> -9.000E-999999999 +emax388 toSci -9.000E+999999999 -> -9.000E+999999999 +emax389 toSci -9.000E+1000000000 -> -Infinity Overflow Inexact Rounded +emax390 toSci -9.999E-1000000008 -> -1E-1000000007 Underflow Subnormal Inexact Rounded +emax391 toSci -9.999E-999999999 -> -9.999E-999999999 +emax392 toSci -9.999E+999999999 -> -9.999E+999999999 +emax393 toSci -9.999E+1000000000 -> -Infinity Overflow Inexact Rounded + +-- Now check 854 rounding of subnormals and proper underflow to 0 +precision: 5 +maxExponent: 999 +minexponent: -999 +rounding: half_even + +emax400 toSci 1.0000E-999 -> 1.0000E-999 +emax401 toSci 0.1E-999 -> 1E-1000 Subnormal +emax402 toSci 0.1000E-999 -> 1.000E-1000 Subnormal +emax403 toSci 0.0100E-999 -> 1.00E-1001 Subnormal +emax404 toSci 0.0010E-999 -> 1.0E-1002 Subnormal +emax405 toSci 0.0001E-999 -> 1E-1003 Subnormal +emax406 toSci 0.00010E-999 -> 1E-1003 Subnormal Rounded +emax407 toSci 0.00013E-999 -> 1E-1003 Underflow Subnormal Inexact Rounded +emax408 toSci 0.00015E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax409 toSci 0.00017E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax410 toSci 0.00023E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax411 toSci 0.00025E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax412 toSci 0.00027E-999 -> 3E-1003 Underflow Subnormal Inexact Rounded +emax413 toSci 0.000149E-999 -> 1E-1003 Underflow Subnormal Inexact Rounded +emax414 toSci 0.000150E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax415 toSci 0.000151E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax416 toSci 0.000249E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax417 toSci 0.000250E-999 -> 2E-1003 Underflow Subnormal Inexact Rounded +emax418 toSci 0.000251E-999 -> 3E-1003 Underflow Subnormal Inexact Rounded +emax419 toSci 0.00009E-999 -> 1E-1003 Underflow Subnormal Inexact Rounded +emax420 toSci 0.00005E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax421 toSci 0.00003E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax422 toSci 0.000009E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax423 toSci 0.000005E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax424 toSci 0.000003E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded + +emax425 toSci 0.001049E-999 -> 1.0E-1002 Underflow Subnormal Inexact Rounded +emax426 toSci 0.001050E-999 -> 1.0E-1002 Underflow Subnormal Inexact Rounded +emax427 toSci 0.001051E-999 -> 1.1E-1002 Underflow Subnormal Inexact Rounded +emax428 toSci 0.001149E-999 -> 1.1E-1002 Underflow Subnormal Inexact Rounded +emax429 toSci 0.001150E-999 -> 1.2E-1002 Underflow Subnormal Inexact Rounded +emax430 toSci 0.001151E-999 -> 1.2E-1002 Underflow Subnormal Inexact Rounded + +emax432 toSci 0.010049E-999 -> 1.00E-1001 Underflow Subnormal Inexact Rounded +emax433 toSci 0.010050E-999 -> 1.00E-1001 Underflow Subnormal Inexact Rounded +emax434 toSci 0.010051E-999 -> 1.01E-1001 Underflow Subnormal Inexact Rounded +emax435 toSci 0.010149E-999 -> 1.01E-1001 Underflow Subnormal Inexact Rounded +emax436 toSci 0.010150E-999 -> 1.02E-1001 Underflow Subnormal Inexact Rounded +emax437 toSci 0.010151E-999 -> 1.02E-1001 Underflow Subnormal Inexact Rounded + +emax440 toSci 0.10103E-999 -> 1.010E-1000 Underflow Subnormal Inexact Rounded +emax441 toSci 0.10105E-999 -> 1.010E-1000 Underflow Subnormal Inexact Rounded +emax442 toSci 0.10107E-999 -> 1.011E-1000 Underflow Subnormal Inexact Rounded +emax443 toSci 0.10113E-999 -> 1.011E-1000 Underflow Subnormal Inexact Rounded +emax444 toSci 0.10115E-999 -> 1.012E-1000 Underflow Subnormal Inexact Rounded +emax445 toSci 0.10117E-999 -> 1.012E-1000 Underflow Subnormal Inexact Rounded + +emax450 toSci 1.10730E-1000 -> 1.107E-1000 Underflow Subnormal Inexact Rounded +emax451 toSci 1.10750E-1000 -> 1.108E-1000 Underflow Subnormal Inexact Rounded +emax452 toSci 1.10770E-1000 -> 1.108E-1000 Underflow Subnormal Inexact Rounded +emax453 toSci 1.10830E-1000 -> 1.108E-1000 Underflow Subnormal Inexact Rounded +emax454 toSci 1.10850E-1000 -> 1.108E-1000 Underflow Subnormal Inexact Rounded +emax455 toSci 1.10870E-1000 -> 1.109E-1000 Underflow Subnormal Inexact Rounded + +-- make sure sign OK +emax456 toSci -0.10103E-999 -> -1.010E-1000 Underflow Subnormal Inexact Rounded +emax457 toSci -0.10105E-999 -> -1.010E-1000 Underflow Subnormal Inexact Rounded +emax458 toSci -0.10107E-999 -> -1.011E-1000 Underflow Subnormal Inexact Rounded +emax459 toSci -0.10113E-999 -> -1.011E-1000 Underflow Subnormal Inexact Rounded +emax460 toSci -0.10115E-999 -> -1.012E-1000 Underflow Subnormal Inexact Rounded +emax461 toSci -0.10117E-999 -> -1.012E-1000 Underflow Subnormal Inexact Rounded + +-- '999s' cases +emax464 toSci 999999E-999 -> 1.0000E-993 Inexact Rounded +emax465 toSci 99999.0E-999 -> 9.9999E-995 Rounded +emax466 toSci 99999.E-999 -> 9.9999E-995 +emax467 toSci 9999.9E-999 -> 9.9999E-996 +emax468 toSci 999.99E-999 -> 9.9999E-997 +emax469 toSci 99.999E-999 -> 9.9999E-998 +emax470 toSci 9.9999E-999 -> 9.9999E-999 +emax471 toSci 0.99999E-999 -> 1.0000E-999 Underflow Subnormal Inexact Rounded +emax472 toSci 0.099999E-999 -> 1.000E-1000 Underflow Subnormal Inexact Rounded +emax473 toSci 0.0099999E-999 -> 1.00E-1001 Underflow Subnormal Inexact Rounded +emax474 toSci 0.00099999E-999 -> 1.0E-1002 Underflow Subnormal Inexact Rounded +emax475 toSci 0.000099999E-999 -> 1E-1003 Underflow Subnormal Inexact Rounded +emax476 toSci 0.0000099999E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax477 toSci 0.00000099999E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded +emax478 toSci 0.000000099999E-999 -> 0E-1003 Underflow Subnormal Inexact Rounded + +-- Exponents with insignificant leading zeros +precision: 16 +maxExponent: 999999999 +minexponent: -999999999 +basx1001 toSci 1e999999999 -> 1E+999999999 +basx1002 toSci 1e0999999999 -> 1E+999999999 +basx1003 toSci 1e00999999999 -> 1E+999999999 +basx1004 toSci 1e000999999999 -> 1E+999999999 +basx1005 toSci 1e000000000000999999999 -> 1E+999999999 +basx1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded +basx1007 toSci 1e-999999999 -> 1E-999999999 +basx1008 toSci 1e-0999999999 -> 1E-999999999 +basx1009 toSci 1e-00999999999 -> 1E-999999999 +basx1010 toSci 1e-000999999999 -> 1E-999999999 +basx1011 toSci 1e-000000000000999999999 -> 1E-999999999 +basx1012 toSci 1e-000000000001000000007 -> 1E-1000000007 Subnormal + +-- Edge cases for int32 exponents... +basx1021 tosci 1e+2147483649 -> Infinity Overflow Inexact Rounded +basx1022 tosci 1e+2147483648 -> Infinity Overflow Inexact Rounded +basx1023 tosci 1e+2147483647 -> Infinity Overflow Inexact Rounded +basx1024 tosci 1e-2147483647 -> 0E-1000000014 Underflow Subnormal Inexact Rounded +basx1025 tosci 1e-2147483648 -> 0E-1000000014 Underflow Subnormal Inexact Rounded +basx1026 tosci 1e-2147483649 -> 0E-1000000014 Underflow Subnormal Inexact Rounded +-- same unbalanced +precision: 7 +maxExponent: 96 +minexponent: -95 +basx1031 tosci 1e+2147483649 -> Infinity Overflow Inexact Rounded +basx1032 tosci 1e+2147483648 -> Infinity Overflow Inexact Rounded +basx1033 tosci 1e+2147483647 -> Infinity Overflow Inexact Rounded +basx1034 tosci 1e-2147483647 -> 0E-101 Underflow Subnormal Inexact Rounded +basx1035 tosci 1e-2147483648 -> 0E-101 Underflow Subnormal Inexact Rounded +basx1036 tosci 1e-2147483649 -> 0E-101 Underflow Subnormal Inexact Rounded + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +basx1041 toSci 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +basx1042 toSci 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow +basx1043 toSci 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow + Added: sandbox/trunk/decimal-c/decimaltestdata/clamp.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/clamp.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,197 @@ +------------------------------------------------------------------------ +-- clamp.decTest -- clamped exponent tests (format-independent) -- +-- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests uses the same limits as the 8-byte concrete +-- representation, but applies clamping without using format-specific +-- conversions. + +extended: 1 +precision: 16 +rounding: half_even +maxExponent: 384 +minExponent: -383 +clamp: 1 + +-- General testcases + +-- Normality +clam010 apply 1234567890123456 -> 1234567890123456 +clam011 apply 1234567890123456.0 -> 1234567890123456 Rounded +clam012 apply 1234567890123456.1 -> 1234567890123456 Rounded Inexact +clam013 apply -1234567890123456 -> -1234567890123456 +clam014 apply -1234567890123456.0 -> -1234567890123456 Rounded +clam015 apply -1234567890123456.1 -> -1234567890123456 Rounded Inexact + + +-- Nmax and similar +clam022 apply 9.999999999999999E+384 -> 9.999999999999999E+384 +clam024 apply 1.234567890123456E+384 -> 1.234567890123456E+384 +-- fold-downs (more below) +clam030 apply 1.23E+384 -> 1.230000000000000E+384 Clamped +clam032 apply 1E+384 -> 1.000000000000000E+384 Clamped + +clam051 apply 12345 -> 12345 +clam053 apply 1234 -> 1234 +clam055 apply 123 -> 123 +clam057 apply 12 -> 12 +clam059 apply 1 -> 1 +clam061 apply 1.23 -> 1.23 +clam063 apply 123.45 -> 123.45 + +-- Nmin and below +clam071 apply 1E-383 -> 1E-383 +clam073 apply 1.000000000000000E-383 -> 1.000000000000000E-383 +clam075 apply 1.000000000000001E-383 -> 1.000000000000001E-383 + +clam077 apply 0.100000000000000E-383 -> 1.00000000000000E-384 Subnormal +clam079 apply 0.000000000000010E-383 -> 1.0E-397 Subnormal +clam081 apply 0.00000000000001E-383 -> 1E-397 Subnormal +clam083 apply 0.000000000000001E-383 -> 1E-398 Subnormal + +-- underflows +clam090 apply 1e-398 -> #0000000000000001 Subnormal +clam091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded +clam092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +clam093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +clam094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +clam095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +clam096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +clam097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +clam098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +clam099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded + +-- Same again, negatives +-- Nmax and similar +clam122 apply -9.999999999999999E+384 -> -9.999999999999999E+384 +clam124 apply -1.234567890123456E+384 -> -1.234567890123456E+384 +-- fold-downs (more below) +clam130 apply -1.23E+384 -> -1.230000000000000E+384 Clamped +clam132 apply -1E+384 -> -1.000000000000000E+384 Clamped + +clam151 apply -12345 -> -12345 +clam153 apply -1234 -> -1234 +clam155 apply -123 -> -123 +clam157 apply -12 -> -12 +clam159 apply -1 -> -1 +clam161 apply -1.23 -> -1.23 +clam163 apply -123.45 -> -123.45 + +-- Nmin and below +clam171 apply -1E-383 -> -1E-383 +clam173 apply -1.000000000000000E-383 -> -1.000000000000000E-383 +clam175 apply -1.000000000000001E-383 -> -1.000000000000001E-383 + +clam177 apply -0.100000000000000E-383 -> -1.00000000000000E-384 Subnormal +clam179 apply -0.000000000000010E-383 -> -1.0E-397 Subnormal +clam181 apply -0.00000000000001E-383 -> -1E-397 Subnormal +clam183 apply -0.000000000000001E-383 -> -1E-398 Subnormal + +-- underflows +clam189 apply -1e-398 -> #8000000000000001 Subnormal +clam190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded +clam191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded +clam192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +clam193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +clam194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +clam195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +clam196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +clam197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +clam198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +clam199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded + +-- zeros +clam401 apply 0E-500 -> 0E-398 Clamped +clam402 apply 0E-400 -> 0E-398 Clamped +clam403 apply 0E-398 -> 0E-398 +clam404 apply 0.000000000000000E-383 -> 0E-398 +clam405 apply 0E-2 -> 0.00 +clam406 apply 0 -> 0 +clam407 apply 0E+3 -> 0E+3 +clam408 apply 0E+369 -> 0E+369 +-- clamped zeros... +clam410 apply 0E+370 -> 0E+369 Clamped +clam411 apply 0E+384 -> 0E+369 Clamped +clam412 apply 0E+400 -> 0E+369 Clamped +clam413 apply 0E+500 -> 0E+369 Clamped + +-- negative zeros +clam420 apply -0E-500 -> -0E-398 Clamped +clam421 apply -0E-400 -> -0E-398 Clamped +clam422 apply -0E-398 -> -0E-398 +clam423 apply -0.000000000000000E-383 -> -0E-398 +clam424 apply -0E-2 -> -0.00 +clam425 apply -0 -> -0 +clam426 apply -0E+3 -> -0E+3 +clam427 apply -0E+369 -> -0E+369 +-- clamped zeros... +clam431 apply -0E+370 -> -0E+369 Clamped +clam432 apply -0E+384 -> -0E+369 Clamped +clam433 apply -0E+400 -> -0E+369 Clamped +clam434 apply -0E+500 -> -0E+369 Clamped + +-- fold-down full sequence +clam601 apply 1E+384 -> 1.000000000000000E+384 Clamped +clam603 apply 1E+383 -> 1.00000000000000E+383 Clamped +clam605 apply 1E+382 -> 1.0000000000000E+382 Clamped +clam607 apply 1E+381 -> 1.000000000000E+381 Clamped +clam609 apply 1E+380 -> 1.00000000000E+380 Clamped +clam611 apply 1E+379 -> 1.0000000000E+379 Clamped +clam613 apply 1E+378 -> 1.000000000E+378 Clamped +clam615 apply 1E+377 -> 1.00000000E+377 Clamped +clam617 apply 1E+376 -> 1.0000000E+376 Clamped +clam619 apply 1E+375 -> 1.000000E+375 Clamped +clam621 apply 1E+374 -> 1.00000E+374 Clamped +clam623 apply 1E+373 -> 1.0000E+373 Clamped +clam625 apply 1E+372 -> 1.000E+372 Clamped +clam627 apply 1E+371 -> 1.00E+371 Clamped +clam629 apply 1E+370 -> 1.0E+370 Clamped +clam631 apply 1E+369 -> 1E+369 +clam633 apply 1E+368 -> 1E+368 +-- same with 9s +clam641 apply 9E+384 -> 9.000000000000000E+384 Clamped +clam643 apply 9E+383 -> 9.00000000000000E+383 Clamped +clam645 apply 9E+382 -> 9.0000000000000E+382 Clamped +clam647 apply 9E+381 -> 9.000000000000E+381 Clamped +clam649 apply 9E+380 -> 9.00000000000E+380 Clamped +clam651 apply 9E+379 -> 9.0000000000E+379 Clamped +clam653 apply 9E+378 -> 9.000000000E+378 Clamped +clam655 apply 9E+377 -> 9.00000000E+377 Clamped +clam657 apply 9E+376 -> 9.0000000E+376 Clamped +clam659 apply 9E+375 -> 9.000000E+375 Clamped +clam661 apply 9E+374 -> 9.00000E+374 Clamped +clam663 apply 9E+373 -> 9.0000E+373 Clamped +clam665 apply 9E+372 -> 9.000E+372 Clamped +clam667 apply 9E+371 -> 9.00E+371 Clamped +clam669 apply 9E+370 -> 9.0E+370 Clamped +clam671 apply 9E+369 -> 9E+369 +clam673 apply 9E+368 -> 9E+368 + +-- example from documentation +precision: 7 +rounding: half_even +maxExponent: +96 +minExponent: -95 + +clamp: 0 +clam700 apply 1.23E+96 -> 1.23E+96 + +clamp: 1 +clam701 apply 1.23E+96 -> 1.230000E+96 Clamped Added: sandbox/trunk/decimal-c/decimaltestdata/compare.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/compare.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,717 @@ +------------------------------------------------------------------------ +-- compare.decTest -- decimal comparison -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- Note that we cannot assume add/subtract tests cover paths adequately, +-- here, because the code might be quite different (comparison cannot +-- overflow or underflow, so actual subtractions are not necesary). + +extended: 1 + +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- sanity checks +comx001 compare -2 -2 -> 0 +comx002 compare -2 -1 -> -1 +comx003 compare -2 0 -> -1 +comx004 compare -2 1 -> -1 +comx005 compare -2 2 -> -1 +comx006 compare -1 -2 -> 1 +comx007 compare -1 -1 -> 0 +comx008 compare -1 0 -> -1 +comx009 compare -1 1 -> -1 +comx010 compare -1 2 -> -1 +comx011 compare 0 -2 -> 1 +comx012 compare 0 -1 -> 1 +comx013 compare 0 0 -> 0 +comx014 compare 0 1 -> -1 +comx015 compare 0 2 -> -1 +comx016 compare 1 -2 -> 1 +comx017 compare 1 -1 -> 1 +comx018 compare 1 0 -> 1 +comx019 compare 1 1 -> 0 +comx020 compare 1 2 -> -1 +comx021 compare 2 -2 -> 1 +comx022 compare 2 -1 -> 1 +comx023 compare 2 0 -> 1 +comx025 compare 2 1 -> 1 +comx026 compare 2 2 -> 0 + +comx031 compare -20 -20 -> 0 +comx032 compare -20 -10 -> -1 +comx033 compare -20 00 -> -1 +comx034 compare -20 10 -> -1 +comx035 compare -20 20 -> -1 +comx036 compare -10 -20 -> 1 +comx037 compare -10 -10 -> 0 +comx038 compare -10 00 -> -1 +comx039 compare -10 10 -> -1 +comx040 compare -10 20 -> -1 +comx041 compare 00 -20 -> 1 +comx042 compare 00 -10 -> 1 +comx043 compare 00 00 -> 0 +comx044 compare 00 10 -> -1 +comx045 compare 00 20 -> -1 +comx046 compare 10 -20 -> 1 +comx047 compare 10 -10 -> 1 +comx048 compare 10 00 -> 1 +comx049 compare 10 10 -> 0 +comx050 compare 10 20 -> -1 +comx051 compare 20 -20 -> 1 +comx052 compare 20 -10 -> 1 +comx053 compare 20 00 -> 1 +comx055 compare 20 10 -> 1 +comx056 compare 20 20 -> 0 + +comx061 compare -2.0 -2.0 -> 0 +comx062 compare -2.0 -1.0 -> -1 +comx063 compare -2.0 0.0 -> -1 +comx064 compare -2.0 1.0 -> -1 +comx065 compare -2.0 2.0 -> -1 +comx066 compare -1.0 -2.0 -> 1 +comx067 compare -1.0 -1.0 -> 0 +comx068 compare -1.0 0.0 -> -1 +comx069 compare -1.0 1.0 -> -1 +comx070 compare -1.0 2.0 -> -1 +comx071 compare 0.0 -2.0 -> 1 +comx072 compare 0.0 -1.0 -> 1 +comx073 compare 0.0 0.0 -> 0 +comx074 compare 0.0 1.0 -> -1 +comx075 compare 0.0 2.0 -> -1 +comx076 compare 1.0 -2.0 -> 1 +comx077 compare 1.0 -1.0 -> 1 +comx078 compare 1.0 0.0 -> 1 +comx079 compare 1.0 1.0 -> 0 +comx080 compare 1.0 2.0 -> -1 +comx081 compare 2.0 -2.0 -> 1 +comx082 compare 2.0 -1.0 -> 1 +comx083 compare 2.0 0.0 -> 1 +comx085 compare 2.0 1.0 -> 1 +comx086 compare 2.0 2.0 -> 0 + +-- now some cases which might overflow if subtract were used +maxexponent: 999999999 +minexponent: -999999999 +comx090 compare 9.99999999E+999999999 9.99999999E+999999999 -> 0 +comx091 compare -9.99999999E+999999999 9.99999999E+999999999 -> -1 +comx092 compare 9.99999999E+999999999 -9.99999999E+999999999 -> 1 +comx093 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0 + +-- some differing length/exponent cases +comx100 compare 7.0 7.0 -> 0 +comx101 compare 7.0 7 -> 0 +comx102 compare 7 7.0 -> 0 +comx103 compare 7E+0 7.0 -> 0 +comx104 compare 70E-1 7.0 -> 0 +comx105 compare 0.7E+1 7 -> 0 +comx106 compare 70E-1 7 -> 0 +comx107 compare 7.0 7E+0 -> 0 +comx108 compare 7.0 70E-1 -> 0 +comx109 compare 7 0.7E+1 -> 0 +comx110 compare 7 70E-1 -> 0 + +comx120 compare 8.0 7.0 -> 1 +comx121 compare 8.0 7 -> 1 +comx122 compare 8 7.0 -> 1 +comx123 compare 8E+0 7.0 -> 1 +comx124 compare 80E-1 7.0 -> 1 +comx125 compare 0.8E+1 7 -> 1 +comx126 compare 80E-1 7 -> 1 +comx127 compare 8.0 7E+0 -> 1 +comx128 compare 8.0 70E-1 -> 1 +comx129 compare 8 0.7E+1 -> 1 +comx130 compare 8 70E-1 -> 1 + +comx140 compare 8.0 9.0 -> -1 +comx141 compare 8.0 9 -> -1 +comx142 compare 8 9.0 -> -1 +comx143 compare 8E+0 9.0 -> -1 +comx144 compare 80E-1 9.0 -> -1 +comx145 compare 0.8E+1 9 -> -1 +comx146 compare 80E-1 9 -> -1 +comx147 compare 8.0 9E+0 -> -1 +comx148 compare 8.0 90E-1 -> -1 +comx149 compare 8 0.9E+1 -> -1 +comx150 compare 8 90E-1 -> -1 + +-- and again, with sign changes -+ .. +comx200 compare -7.0 7.0 -> -1 +comx201 compare -7.0 7 -> -1 +comx202 compare -7 7.0 -> -1 +comx203 compare -7E+0 7.0 -> -1 +comx204 compare -70E-1 7.0 -> -1 +comx205 compare -0.7E+1 7 -> -1 +comx206 compare -70E-1 7 -> -1 +comx207 compare -7.0 7E+0 -> -1 +comx208 compare -7.0 70E-1 -> -1 +comx209 compare -7 0.7E+1 -> -1 +comx210 compare -7 70E-1 -> -1 + +comx220 compare -8.0 7.0 -> -1 +comx221 compare -8.0 7 -> -1 +comx222 compare -8 7.0 -> -1 +comx223 compare -8E+0 7.0 -> -1 +comx224 compare -80E-1 7.0 -> -1 +comx225 compare -0.8E+1 7 -> -1 +comx226 compare -80E-1 7 -> -1 +comx227 compare -8.0 7E+0 -> -1 +comx228 compare -8.0 70E-1 -> -1 +comx229 compare -8 0.7E+1 -> -1 +comx230 compare -8 70E-1 -> -1 + +comx240 compare -8.0 9.0 -> -1 +comx241 compare -8.0 9 -> -1 +comx242 compare -8 9.0 -> -1 +comx243 compare -8E+0 9.0 -> -1 +comx244 compare -80E-1 9.0 -> -1 +comx245 compare -0.8E+1 9 -> -1 +comx246 compare -80E-1 9 -> -1 +comx247 compare -8.0 9E+0 -> -1 +comx248 compare -8.0 90E-1 -> -1 +comx249 compare -8 0.9E+1 -> -1 +comx250 compare -8 90E-1 -> -1 + +-- and again, with sign changes +- .. +comx300 compare 7.0 -7.0 -> 1 +comx301 compare 7.0 -7 -> 1 +comx302 compare 7 -7.0 -> 1 +comx303 compare 7E+0 -7.0 -> 1 +comx304 compare 70E-1 -7.0 -> 1 +comx305 compare .7E+1 -7 -> 1 +comx306 compare 70E-1 -7 -> 1 +comx307 compare 7.0 -7E+0 -> 1 +comx308 compare 7.0 -70E-1 -> 1 +comx309 compare 7 -.7E+1 -> 1 +comx310 compare 7 -70E-1 -> 1 + +comx320 compare 8.0 -7.0 -> 1 +comx321 compare 8.0 -7 -> 1 +comx322 compare 8 -7.0 -> 1 +comx323 compare 8E+0 -7.0 -> 1 +comx324 compare 80E-1 -7.0 -> 1 +comx325 compare .8E+1 -7 -> 1 +comx326 compare 80E-1 -7 -> 1 +comx327 compare 8.0 -7E+0 -> 1 +comx328 compare 8.0 -70E-1 -> 1 +comx329 compare 8 -.7E+1 -> 1 +comx330 compare 8 -70E-1 -> 1 + +comx340 compare 8.0 -9.0 -> 1 +comx341 compare 8.0 -9 -> 1 +comx342 compare 8 -9.0 -> 1 +comx343 compare 8E+0 -9.0 -> 1 +comx344 compare 80E-1 -9.0 -> 1 +comx345 compare .8E+1 -9 -> 1 +comx346 compare 80E-1 -9 -> 1 +comx347 compare 8.0 -9E+0 -> 1 +comx348 compare 8.0 -90E-1 -> 1 +comx349 compare 8 -.9E+1 -> 1 +comx350 compare 8 -90E-1 -> 1 + +-- and again, with sign changes -- .. +comx400 compare -7.0 -7.0 -> 0 +comx401 compare -7.0 -7 -> 0 +comx402 compare -7 -7.0 -> 0 +comx403 compare -7E+0 -7.0 -> 0 +comx404 compare -70E-1 -7.0 -> 0 +comx405 compare -.7E+1 -7 -> 0 +comx406 compare -70E-1 -7 -> 0 +comx407 compare -7.0 -7E+0 -> 0 +comx408 compare -7.0 -70E-1 -> 0 +comx409 compare -7 -.7E+1 -> 0 +comx410 compare -7 -70E-1 -> 0 + +comx420 compare -8.0 -7.0 -> -1 +comx421 compare -8.0 -7 -> -1 +comx422 compare -8 -7.0 -> -1 +comx423 compare -8E+0 -7.0 -> -1 +comx424 compare -80E-1 -7.0 -> -1 +comx425 compare -.8E+1 -7 -> -1 +comx426 compare -80E-1 -7 -> -1 +comx427 compare -8.0 -7E+0 -> -1 +comx428 compare -8.0 -70E-1 -> -1 +comx429 compare -8 -.7E+1 -> -1 +comx430 compare -8 -70E-1 -> -1 + +comx440 compare -8.0 -9.0 -> 1 +comx441 compare -8.0 -9 -> 1 +comx442 compare -8 -9.0 -> 1 +comx443 compare -8E+0 -9.0 -> 1 +comx444 compare -80E-1 -9.0 -> 1 +comx445 compare -.8E+1 -9 -> 1 +comx446 compare -80E-1 -9 -> 1 +comx447 compare -8.0 -9E+0 -> 1 +comx448 compare -8.0 -90E-1 -> 1 +comx449 compare -8 -.9E+1 -> 1 +comx450 compare -8 -90E-1 -> 1 + + +-- testcases that subtract to lots of zeros at boundaries [pgr] +precision: 40 +comx470 compare 123.4560000000000000E789 123.456E789 -> 0 +comx471 compare 123.456000000000000E-89 123.456E-89 -> 0 +comx472 compare 123.45600000000000E789 123.456E789 -> 0 +comx473 compare 123.4560000000000E-89 123.456E-89 -> 0 +comx474 compare 123.456000000000E789 123.456E789 -> 0 +comx475 compare 123.45600000000E-89 123.456E-89 -> 0 +comx476 compare 123.4560000000E789 123.456E789 -> 0 +comx477 compare 123.456000000E-89 123.456E-89 -> 0 +comx478 compare 123.45600000E789 123.456E789 -> 0 +comx479 compare 123.4560000E-89 123.456E-89 -> 0 +comx480 compare 123.456000E789 123.456E789 -> 0 +comx481 compare 123.45600E-89 123.456E-89 -> 0 +comx482 compare 123.4560E789 123.456E789 -> 0 +comx483 compare 123.456E-89 123.456E-89 -> 0 +comx484 compare 123.456E-89 123.4560000000000000E-89 -> 0 +comx485 compare 123.456E789 123.456000000000000E789 -> 0 +comx486 compare 123.456E-89 123.45600000000000E-89 -> 0 +comx487 compare 123.456E789 123.4560000000000E789 -> 0 +comx488 compare 123.456E-89 123.456000000000E-89 -> 0 +comx489 compare 123.456E789 123.45600000000E789 -> 0 +comx490 compare 123.456E-89 123.4560000000E-89 -> 0 +comx491 compare 123.456E789 123.456000000E789 -> 0 +comx492 compare 123.456E-89 123.45600000E-89 -> 0 +comx493 compare 123.456E789 123.4560000E789 -> 0 +comx494 compare 123.456E-89 123.456000E-89 -> 0 +comx495 compare 123.456E789 123.45600E789 -> 0 +comx496 compare 123.456E-89 123.4560E-89 -> 0 +comx497 compare 123.456E789 123.456E789 -> 0 + +-- wide-ranging, around precision; signs equal +precision: 9 +comx500 compare 1 1E-15 -> 1 +comx501 compare 1 1E-14 -> 1 +comx502 compare 1 1E-13 -> 1 +comx503 compare 1 1E-12 -> 1 +comx504 compare 1 1E-11 -> 1 +comx505 compare 1 1E-10 -> 1 +comx506 compare 1 1E-9 -> 1 +comx507 compare 1 1E-8 -> 1 +comx508 compare 1 1E-7 -> 1 +comx509 compare 1 1E-6 -> 1 +comx510 compare 1 1E-5 -> 1 +comx511 compare 1 1E-4 -> 1 +comx512 compare 1 1E-3 -> 1 +comx513 compare 1 1E-2 -> 1 +comx514 compare 1 1E-1 -> 1 +comx515 compare 1 1E-0 -> 0 +comx516 compare 1 1E+1 -> -1 +comx517 compare 1 1E+2 -> -1 +comx518 compare 1 1E+3 -> -1 +comx519 compare 1 1E+4 -> -1 +comx521 compare 1 1E+5 -> -1 +comx522 compare 1 1E+6 -> -1 +comx523 compare 1 1E+7 -> -1 +comx524 compare 1 1E+8 -> -1 +comx525 compare 1 1E+9 -> -1 +comx526 compare 1 1E+10 -> -1 +comx527 compare 1 1E+11 -> -1 +comx528 compare 1 1E+12 -> -1 +comx529 compare 1 1E+13 -> -1 +comx530 compare 1 1E+14 -> -1 +comx531 compare 1 1E+15 -> -1 +-- LR swap +comx540 compare 1E-15 1 -> -1 +comx541 compare 1E-14 1 -> -1 +comx542 compare 1E-13 1 -> -1 +comx543 compare 1E-12 1 -> -1 +comx544 compare 1E-11 1 -> -1 +comx545 compare 1E-10 1 -> -1 +comx546 compare 1E-9 1 -> -1 +comx547 compare 1E-8 1 -> -1 +comx548 compare 1E-7 1 -> -1 +comx549 compare 1E-6 1 -> -1 +comx550 compare 1E-5 1 -> -1 +comx551 compare 1E-4 1 -> -1 +comx552 compare 1E-3 1 -> -1 +comx553 compare 1E-2 1 -> -1 +comx554 compare 1E-1 1 -> -1 +comx555 compare 1E-0 1 -> 0 +comx556 compare 1E+1 1 -> 1 +comx557 compare 1E+2 1 -> 1 +comx558 compare 1E+3 1 -> 1 +comx559 compare 1E+4 1 -> 1 +comx561 compare 1E+5 1 -> 1 +comx562 compare 1E+6 1 -> 1 +comx563 compare 1E+7 1 -> 1 +comx564 compare 1E+8 1 -> 1 +comx565 compare 1E+9 1 -> 1 +comx566 compare 1E+10 1 -> 1 +comx567 compare 1E+11 1 -> 1 +comx568 compare 1E+12 1 -> 1 +comx569 compare 1E+13 1 -> 1 +comx570 compare 1E+14 1 -> 1 +comx571 compare 1E+15 1 -> 1 +-- similar with an useful coefficient, one side only +comx580 compare 0.000000987654321 1E-15 -> 1 +comx581 compare 0.000000987654321 1E-14 -> 1 +comx582 compare 0.000000987654321 1E-13 -> 1 +comx583 compare 0.000000987654321 1E-12 -> 1 +comx584 compare 0.000000987654321 1E-11 -> 1 +comx585 compare 0.000000987654321 1E-10 -> 1 +comx586 compare 0.000000987654321 1E-9 -> 1 +comx587 compare 0.000000987654321 1E-8 -> 1 +comx588 compare 0.000000987654321 1E-7 -> 1 +comx589 compare 0.000000987654321 1E-6 -> -1 +comx590 compare 0.000000987654321 1E-5 -> -1 +comx591 compare 0.000000987654321 1E-4 -> -1 +comx592 compare 0.000000987654321 1E-3 -> -1 +comx593 compare 0.000000987654321 1E-2 -> -1 +comx594 compare 0.000000987654321 1E-1 -> -1 +comx595 compare 0.000000987654321 1E-0 -> -1 +comx596 compare 0.000000987654321 1E+1 -> -1 +comx597 compare 0.000000987654321 1E+2 -> -1 +comx598 compare 0.000000987654321 1E+3 -> -1 +comx599 compare 0.000000987654321 1E+4 -> -1 + +-- check some unit-y traps +precision: 20 +comx600 compare 12 12.2345 -> -1 +comx601 compare 12.0 12.2345 -> -1 +comx602 compare 12.00 12.2345 -> -1 +comx603 compare 12.000 12.2345 -> -1 +comx604 compare 12.0000 12.2345 -> -1 +comx605 compare 12.00000 12.2345 -> -1 +comx606 compare 12.000000 12.2345 -> -1 +comx607 compare 12.0000000 12.2345 -> -1 +comx608 compare 12.00000000 12.2345 -> -1 +comx609 compare 12.000000000 12.2345 -> -1 +comx610 compare 12.1234 12 -> 1 +comx611 compare 12.1234 12.0 -> 1 +comx612 compare 12.1234 12.00 -> 1 +comx613 compare 12.1234 12.000 -> 1 +comx614 compare 12.1234 12.0000 -> 1 +comx615 compare 12.1234 12.00000 -> 1 +comx616 compare 12.1234 12.000000 -> 1 +comx617 compare 12.1234 12.0000000 -> 1 +comx618 compare 12.1234 12.00000000 -> 1 +comx619 compare 12.1234 12.000000000 -> 1 +comx620 compare -12 -12.2345 -> 1 +comx621 compare -12.0 -12.2345 -> 1 +comx622 compare -12.00 -12.2345 -> 1 +comx623 compare -12.000 -12.2345 -> 1 +comx624 compare -12.0000 -12.2345 -> 1 +comx625 compare -12.00000 -12.2345 -> 1 +comx626 compare -12.000000 -12.2345 -> 1 +comx627 compare -12.0000000 -12.2345 -> 1 +comx628 compare -12.00000000 -12.2345 -> 1 +comx629 compare -12.000000000 -12.2345 -> 1 +comx630 compare -12.1234 -12 -> -1 +comx631 compare -12.1234 -12.0 -> -1 +comx632 compare -12.1234 -12.00 -> -1 +comx633 compare -12.1234 -12.000 -> -1 +comx634 compare -12.1234 -12.0000 -> -1 +comx635 compare -12.1234 -12.00000 -> -1 +comx636 compare -12.1234 -12.000000 -> -1 +comx637 compare -12.1234 -12.0000000 -> -1 +comx638 compare -12.1234 -12.00000000 -> -1 +comx639 compare -12.1234 -12.000000000 -> -1 +precision: 9 + +-- extended zeros +comx640 compare 0 0 -> 0 +comx641 compare 0 -0 -> 0 +comx642 compare 0 -0.0 -> 0 +comx643 compare 0 0.0 -> 0 +comx644 compare -0 0 -> 0 +comx645 compare -0 -0 -> 0 +comx646 compare -0 -0.0 -> 0 +comx647 compare -0 0.0 -> 0 +comx648 compare 0.0 0 -> 0 +comx649 compare 0.0 -0 -> 0 +comx650 compare 0.0 -0.0 -> 0 +comx651 compare 0.0 0.0 -> 0 +comx652 compare -0.0 0 -> 0 +comx653 compare -0.0 -0 -> 0 +comx654 compare -0.0 -0.0 -> 0 +comx655 compare -0.0 0.0 -> 0 + +comx656 compare -0E1 0.0 -> 0 +comx657 compare -0E2 0.0 -> 0 +comx658 compare 0E1 0.0 -> 0 +comx659 compare 0E2 0.0 -> 0 +comx660 compare -0E1 0 -> 0 +comx661 compare -0E2 0 -> 0 +comx662 compare 0E1 0 -> 0 +comx663 compare 0E2 0 -> 0 +comx664 compare -0E1 -0E1 -> 0 +comx665 compare -0E2 -0E1 -> 0 +comx666 compare 0E1 -0E1 -> 0 +comx667 compare 0E2 -0E1 -> 0 +comx668 compare -0E1 -0E2 -> 0 +comx669 compare -0E2 -0E2 -> 0 +comx670 compare 0E1 -0E2 -> 0 +comx671 compare 0E2 -0E2 -> 0 +comx672 compare -0E1 0E1 -> 0 +comx673 compare -0E2 0E1 -> 0 +comx674 compare 0E1 0E1 -> 0 +comx675 compare 0E2 0E1 -> 0 +comx676 compare -0E1 0E2 -> 0 +comx677 compare -0E2 0E2 -> 0 +comx678 compare 0E1 0E2 -> 0 +comx679 compare 0E2 0E2 -> 0 + +-- trailing zeros; unit-y +precision: 20 +comx680 compare 12 12 -> 0 +comx681 compare 12 12.0 -> 0 +comx682 compare 12 12.00 -> 0 +comx683 compare 12 12.000 -> 0 +comx684 compare 12 12.0000 -> 0 +comx685 compare 12 12.00000 -> 0 +comx686 compare 12 12.000000 -> 0 +comx687 compare 12 12.0000000 -> 0 +comx688 compare 12 12.00000000 -> 0 +comx689 compare 12 12.000000000 -> 0 +comx690 compare 12 12 -> 0 +comx691 compare 12.0 12 -> 0 +comx692 compare 12.00 12 -> 0 +comx693 compare 12.000 12 -> 0 +comx694 compare 12.0000 12 -> 0 +comx695 compare 12.00000 12 -> 0 +comx696 compare 12.000000 12 -> 0 +comx697 compare 12.0000000 12 -> 0 +comx698 compare 12.00000000 12 -> 0 +comx699 compare 12.000000000 12 -> 0 + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +comx701 compare 12345678000 1 -> 1 +comx702 compare 1 12345678000 -> -1 +comx703 compare 1234567800 1 -> 1 +comx704 compare 1 1234567800 -> -1 +comx705 compare 1234567890 1 -> 1 +comx706 compare 1 1234567890 -> -1 +comx707 compare 1234567891 1 -> 1 +comx708 compare 1 1234567891 -> -1 +comx709 compare 12345678901 1 -> 1 +comx710 compare 1 12345678901 -> -1 +comx711 compare 1234567896 1 -> 1 +comx712 compare 1 1234567896 -> -1 +comx713 compare -1234567891 1 -> -1 +comx714 compare 1 -1234567891 -> 1 +comx715 compare -12345678901 1 -> -1 +comx716 compare 1 -12345678901 -> 1 +comx717 compare -1234567896 1 -> -1 +comx718 compare 1 -1234567896 -> 1 + +precision: 15 +-- same with plenty of precision +comx721 compare 12345678000 1 -> 1 +comx722 compare 1 12345678000 -> -1 +comx723 compare 1234567800 1 -> 1 +comx724 compare 1 1234567800 -> -1 +comx725 compare 1234567890 1 -> 1 +comx726 compare 1 1234567890 -> -1 +comx727 compare 1234567891 1 -> 1 +comx728 compare 1 1234567891 -> -1 +comx729 compare 12345678901 1 -> 1 +comx730 compare 1 12345678901 -> -1 +comx731 compare 1234567896 1 -> 1 +comx732 compare 1 1234567896 -> -1 + +-- residue cases +precision: 5 +comx740 compare 1 0.9999999 -> 1 +comx741 compare 1 0.999999 -> 1 +comx742 compare 1 0.99999 -> 1 +comx743 compare 1 1.0000 -> 0 +comx744 compare 1 1.00001 -> -1 +comx745 compare 1 1.000001 -> -1 +comx746 compare 1 1.0000001 -> -1 +comx750 compare 0.9999999 1 -> -1 +comx751 compare 0.999999 1 -> -1 +comx752 compare 0.99999 1 -> -1 +comx753 compare 1.0000 1 -> 0 +comx754 compare 1.00001 1 -> 1 +comx755 compare 1.000001 1 -> 1 +comx756 compare 1.0000001 1 -> 1 + +-- a selection of longies +comx760 compare -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1 +comx761 compare -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0 +comx762 compare -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1 +comx763 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +-- precisions above or below the difference should have no effect +precision: 11 +comx764 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 10 +comx765 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 9 +comx766 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 8 +comx767 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 7 +comx768 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 6 +comx769 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 5 +comx770 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 4 +comx771 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 3 +comx772 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 2 +comx773 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 +precision: 1 +comx774 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 + +-- Specials +precision: 9 +comx780 compare Inf -Inf -> 1 +comx781 compare Inf -1000 -> 1 +comx782 compare Inf -1 -> 1 +comx783 compare Inf -0 -> 1 +comx784 compare Inf 0 -> 1 +comx785 compare Inf 1 -> 1 +comx786 compare Inf 1000 -> 1 +comx787 compare Inf Inf -> 0 +comx788 compare -1000 Inf -> -1 +comx789 compare -Inf Inf -> -1 +comx790 compare -1 Inf -> -1 +comx791 compare -0 Inf -> -1 +comx792 compare 0 Inf -> -1 +comx793 compare 1 Inf -> -1 +comx794 compare 1000 Inf -> -1 +comx795 compare Inf Inf -> 0 + +comx800 compare -Inf -Inf -> 0 +comx801 compare -Inf -1000 -> -1 +comx802 compare -Inf -1 -> -1 +comx803 compare -Inf -0 -> -1 +comx804 compare -Inf 0 -> -1 +comx805 compare -Inf 1 -> -1 +comx806 compare -Inf 1000 -> -1 +comx807 compare -Inf Inf -> -1 +comx808 compare -Inf -Inf -> 0 +comx809 compare -1000 -Inf -> 1 +comx810 compare -1 -Inf -> 1 +comx811 compare -0 -Inf -> 1 +comx812 compare 0 -Inf -> 1 +comx813 compare 1 -Inf -> 1 +comx814 compare 1000 -Inf -> 1 +comx815 compare Inf -Inf -> 1 + +comx821 compare NaN -Inf -> NaN +comx822 compare NaN -1000 -> NaN +comx823 compare NaN -1 -> NaN +comx824 compare NaN -0 -> NaN +comx825 compare NaN 0 -> NaN +comx826 compare NaN 1 -> NaN +comx827 compare NaN 1000 -> NaN +comx828 compare NaN Inf -> NaN +comx829 compare NaN NaN -> NaN +comx830 compare -Inf NaN -> NaN +comx831 compare -1000 NaN -> NaN +comx832 compare -1 NaN -> NaN +comx833 compare -0 NaN -> NaN +comx834 compare 0 NaN -> NaN +comx835 compare 1 NaN -> NaN +comx836 compare 1000 NaN -> NaN +comx837 compare Inf NaN -> NaN +comx838 compare -NaN -NaN -> -NaN +comx839 compare +NaN -NaN -> NaN +comx840 compare -NaN +NaN -> -NaN + +comx841 compare sNaN -Inf -> NaN Invalid_operation +comx842 compare sNaN -1000 -> NaN Invalid_operation +comx843 compare sNaN -1 -> NaN Invalid_operation +comx844 compare sNaN -0 -> NaN Invalid_operation +comx845 compare sNaN 0 -> NaN Invalid_operation +comx846 compare sNaN 1 -> NaN Invalid_operation +comx847 compare sNaN 1000 -> NaN Invalid_operation +comx848 compare sNaN NaN -> NaN Invalid_operation +comx849 compare sNaN sNaN -> NaN Invalid_operation +comx850 compare NaN sNaN -> NaN Invalid_operation +comx851 compare -Inf sNaN -> NaN Invalid_operation +comx852 compare -1000 sNaN -> NaN Invalid_operation +comx853 compare -1 sNaN -> NaN Invalid_operation +comx854 compare -0 sNaN -> NaN Invalid_operation +comx855 compare 0 sNaN -> NaN Invalid_operation +comx856 compare 1 sNaN -> NaN Invalid_operation +comx857 compare 1000 sNaN -> NaN Invalid_operation +comx858 compare Inf sNaN -> NaN Invalid_operation +comx859 compare NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +comx860 compare NaN9 -Inf -> NaN9 +comx861 compare NaN8 999 -> NaN8 +comx862 compare NaN77 Inf -> NaN77 +comx863 compare -NaN67 NaN5 -> -NaN67 +comx864 compare -Inf -NaN4 -> -NaN4 +comx865 compare -999 -NaN33 -> -NaN33 +comx866 compare Inf NaN2 -> NaN2 +comx867 compare -NaN41 -NaN42 -> -NaN41 +comx868 compare +NaN41 -NaN42 -> NaN41 +comx869 compare -NaN41 +NaN42 -> -NaN41 +comx870 compare +NaN41 +NaN42 -> NaN41 + +comx871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation +comx872 compare sNaN98 -11 -> NaN98 Invalid_operation +comx873 compare sNaN97 NaN -> NaN97 Invalid_operation +comx874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation +comx875 compare NaN85 sNaN83 -> NaN83 Invalid_operation +comx876 compare -Inf sNaN92 -> NaN92 Invalid_operation +comx877 compare 088 sNaN81 -> NaN81 Invalid_operation +comx878 compare Inf sNaN90 -> NaN90 Invalid_operation +comx879 compare NaN -sNaN89 -> -NaN89 Invalid_operation + +-- overflow and underflow tests .. subnormal results now allowed +maxExponent: 999999999 +minexponent: -999999999 +comx880 compare +1.23456789012345E-0 9E+999999999 -> -1 +comx881 compare 9E+999999999 +1.23456789012345E-0 -> 1 +comx882 compare +0.100 9E-999999999 -> 1 +comx883 compare 9E-999999999 +0.100 -> -1 +comx885 compare -1.23456789012345E-0 9E+999999999 -> -1 +comx886 compare 9E+999999999 -1.23456789012345E-0 -> 1 +comx887 compare -0.100 9E-999999999 -> -1 +comx888 compare 9E-999999999 -0.100 -> 1 + +comx889 compare 1e-599999999 1e-400000001 -> -1 +comx890 compare 1e-599999999 1e-400000000 -> -1 +comx891 compare 1e-600000000 1e-400000000 -> -1 +comx892 compare 9e-999999998 0.01 -> -1 +comx893 compare 9e-999999998 0.1 -> -1 +comx894 compare 0.01 9e-999999998 -> 1 +comx895 compare 1e599999999 1e400000001 -> 1 +comx896 compare 1e599999999 1e400000000 -> 1 +comx897 compare 1e600000000 1e400000000 -> 1 +comx898 compare 9e999999998 100 -> 1 +comx899 compare 9e999999998 10 -> 1 +comx900 compare 100 9e999999998 -> -1 +-- signs +comx901 compare 1e+777777777 1e+411111111 -> 1 +comx902 compare 1e+777777777 -1e+411111111 -> 1 +comx903 compare -1e+777777777 1e+411111111 -> -1 +comx904 compare -1e+777777777 -1e+411111111 -> -1 +comx905 compare 1e-777777777 1e-411111111 -> -1 +comx906 compare 1e-777777777 -1e-411111111 -> 1 +comx907 compare -1e-777777777 1e-411111111 -> -1 +comx908 compare -1e-777777777 -1e-411111111 -> 1 + +-- Null tests +comx990 compare 10 # -> NaN Invalid_operation +comx991 compare # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/decimal128.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/decimal128.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,441 @@ +------------------------------------------------------------------------ +-- decimal128.decTest -- decimal sixteen-byte format testcases -- +-- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests is for the sixteen-byte concrete representation. +-- Its characteristics are: +-- +-- 1 bit sign +-- 5 bits combination field +-- 12 bits exponent continuation +-- 110 bits coefficient continuation +-- +-- Total exponent length 14 bits +-- Total coefficient length 114 bits (34 digits) +-- +-- Elimit = 12287 (maximum encoded exponent) +-- Emax = 6144 (largest exponent value) +-- Emin = -6143 (smallest exponent value) +-- bias = 6176 (subtracted from encoded exponent) = -Etiny + +extended: 1 +precision: 34 +rounding: half_up +maxExponent: 6144 +minExponent: -6143 + +-- General testcases +-- (mostly derived from the Strawman 4 document and examples) +decg001 apply #A20780000000000000000000000003D0 -> -7.50 +decg002 apply -7.50 -> #A20780000000000000000000000003D0 + +-- Normality +decf010 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534 +decf011 apply 1234567890123456789012345678901234.0 -> #2608134b9c1e28e56f3c127177823534 Rounded +decf012 apply 1234567890123456789012345678901234.1 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact +decf013 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534 +decf014 apply -1234567890123456789012345678901234.0 -> #a608134b9c1e28e56f3c127177823534 Rounded +decf015 apply -1234567890123456789012345678901234.1 -> #a608134b9c1e28e56f3c127177823534 Rounded Inexact + + +-- Nmax and similar +decf022 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff +decf023 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144 +decf024 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534 +decf025 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144 +-- fold-downs (more below) +decf030 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped +decf031 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144 +decf032 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped +decf033 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144 + +-- overflows +maxExponent: 9999 -- set high so conversion causes the overflow +minExponent: -9999 +decf040 apply 10E+6144 -> #78000000000000000000000000000000 Overflow Rounded Inexact +decf041 apply 1.000000000000000E+6145 -> #78000000000000000000000000000000 Overflow Rounded Inexact +maxExponent: 6144 +minExponent: -6143 + +decf051 apply 12345 -> #220800000000000000000000000049c5 +decf052 apply #220800000000000000000000000049c5 -> 12345 +decf053 apply 1234 -> #22080000000000000000000000000534 +decf054 apply #22080000000000000000000000000534 -> 1234 +decf055 apply 123 -> #220800000000000000000000000000a3 +decf056 apply #220800000000000000000000000000a3 -> 123 +decf057 apply 12 -> #22080000000000000000000000000012 +decf058 apply #22080000000000000000000000000012 -> 12 +decf059 apply 1 -> #22080000000000000000000000000001 +decf060 apply #22080000000000000000000000000001 -> 1 +decf061 apply 1.23 -> #220780000000000000000000000000a3 +decf062 apply #220780000000000000000000000000a3 -> 1.23 +decf063 apply 123.45 -> #220780000000000000000000000049c5 +decf064 apply #220780000000000000000000000049c5 -> 123.45 + +-- Nmin and below +decf071 apply 1E-6143 -> #00084000000000000000000000000001 +decf072 apply #00084000000000000000000000000001 -> 1E-6143 +decf073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000 +decf074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143 +decf075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001 +decf076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143 + +decf077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal +decf078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal +decf079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal +decf080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal +decf081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal +decf082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal +decf083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal +decf084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal + +-- underflows +decf090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal +decf091 apply 1.9e-6176 -> #00000000000000000000000000000002 Subnormal Underflow Inexact Rounded +decf092 apply 1.1e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf093 apply 1.00000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf094 apply 1.00000000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf095 apply 1.000000000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf096 apply 0.1e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf097 apply 0.00000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf098 apply 0.00000000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf099 apply 0.000000000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal + +-- same again, negatives +-- Nmax and similar +decf122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff +decf123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144 +decf124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534 +decf125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144 +-- fold-downs (more below) +decf130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped +decf131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144 +decf132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped +decf133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144 + +-- overflows +maxExponent: 9999 -- set high so conversion causes the overflow +minExponent: -9999 +decf140 apply -10E+6144 -> #f8000000000000000000000000000000 Overflow Rounded Inexact +decf141 apply -1.000000000000000E+6145 -> #f8000000000000000000000000000000 Overflow Rounded Inexact +maxExponent: 6144 +minExponent: -6143 + +decf151 apply -12345 -> #a20800000000000000000000000049c5 +decf152 apply #a20800000000000000000000000049c5 -> -12345 +decf153 apply -1234 -> #a2080000000000000000000000000534 +decf154 apply #a2080000000000000000000000000534 -> -1234 +decf155 apply -123 -> #a20800000000000000000000000000a3 +decf156 apply #a20800000000000000000000000000a3 -> -123 +decf157 apply -12 -> #a2080000000000000000000000000012 +decf158 apply #a2080000000000000000000000000012 -> -12 +decf159 apply -1 -> #a2080000000000000000000000000001 +decf160 apply #a2080000000000000000000000000001 -> -1 +decf161 apply -1.23 -> #a20780000000000000000000000000a3 +decf162 apply #a20780000000000000000000000000a3 -> -1.23 +decf163 apply -123.45 -> #a20780000000000000000000000049c5 +decf164 apply #a20780000000000000000000000049c5 -> -123.45 + +-- Nmin and below +decf171 apply -1E-6143 -> #80084000000000000000000000000001 +decf172 apply #80084000000000000000000000000001 -> -1E-6143 +decf173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000 +decf174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143 +decf175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001 +decf176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143 + +decf177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal +decf178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal +decf179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal +decf180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal +decf181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal +decf182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal +decf183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal +decf184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal + +-- underflows +decf190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal +decf191 apply -1.9e-6176 -> #80000000000000000000000000000002 Subnormal Underflow Inexact Rounded +decf192 apply -1.1e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf193 apply -1.00000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf194 apply -1.00000000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf195 apply -1.000000000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded +decf196 apply -0.1e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf197 apply -0.00000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf198 apply -0.00000000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf199 apply -0.000000000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded +decf200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal + +-- zeros +decf400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped +decf401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped +decf402 apply 0E-6176 -> #00000000000000000000000000000000 +decf403 apply #00000000000000000000000000000000 -> 0E-6176 +decf404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000 +decf405 apply #00000000000000000000000000000000 -> 0E-6176 +decf406 apply 0E-2 -> #22078000000000000000000000000000 +decf407 apply #22078000000000000000000000000000 -> 0.00 +decf408 apply 0 -> #22080000000000000000000000000000 +decf409 apply #22080000000000000000000000000000 -> 0 +decf410 apply 0E+3 -> #2208c000000000000000000000000000 +decf411 apply #2208c000000000000000000000000000 -> 0E+3 +decf412 apply 0E+6111 -> #43ffc000000000000000000000000000 +decf413 apply #43ffc000000000000000000000000000 -> 0E+6111 +-- clamped zeros... +decf414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped +decf415 apply #43ffc000000000000000000000000000 -> 0E+6111 +decf416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped +decf417 apply #43ffc000000000000000000000000000 -> 0E+6111 +decf418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped +decf419 apply #43ffc000000000000000000000000000 -> 0E+6111 + +-- negative zeros +decf420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped +decf421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped +decf422 apply -0E-6176 -> #80000000000000000000000000000000 +decf423 apply #80000000000000000000000000000000 -> -0E-6176 +decf424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000 +decf425 apply #80000000000000000000000000000000 -> -0E-6176 +decf426 apply -0E-2 -> #a2078000000000000000000000000000 +decf427 apply #a2078000000000000000000000000000 -> -0.00 +decf428 apply -0 -> #a2080000000000000000000000000000 +decf429 apply #a2080000000000000000000000000000 -> -0 +decf430 apply -0E+3 -> #a208c000000000000000000000000000 +decf431 apply #a208c000000000000000000000000000 -> -0E+3 +decf432 apply -0E+6111 -> #c3ffc000000000000000000000000000 +decf433 apply #c3ffc000000000000000000000000000 -> -0E+6111 +-- clamped zeros... +decf434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped +decf435 apply #c3ffc000000000000000000000000000 -> -0E+6111 +decf436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped +decf437 apply #c3ffc000000000000000000000000000 -> -0E+6111 +decf438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped +decf439 apply #c3ffc000000000000000000000000000 -> -0E+6111 + +-- Specials +decf500 apply Infinity -> #78000000000000000000000000000000 +decf501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000 +decf502 apply #78000000000000000000000000000000 -> Infinity +decf503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000 +decf504 apply #79000000000000000000000000000000 -> Infinity +decf505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000 +decf506 apply #7a000000000000000000000000000000 -> Infinity +decf507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000 +decf508 apply #7b000000000000000000000000000000 -> Infinity + +decf509 apply NaN -> #7c000000000000000000000000000000 +decf510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c +decf511 apply #7c000000000000000000000000000000 -> NaN +decf512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d +decf513 apply #7d000000000000000000000000000000 -> NaN +decf514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e +decf515 apply #7e000000000000000000000000000000 -> sNaN +decf516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f +decf517 apply #7f000000000000000000000000000000 -> sNaN +decf518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999 +decf519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff + +decf520 apply -Infinity -> #f8000000000000000000000000000000 +decf521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000 +decf522 apply #f8000000000000000000000000000000 -> -Infinity +decf523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000 +decf524 apply #f9000000000000000000000000000000 -> -Infinity +decf525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000 +decf526 apply #fa000000000000000000000000000000 -> -Infinity +decf527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000 +decf528 apply #fb000000000000000000000000000000 -> -Infinity + +decf529 apply -NaN -> #fc000000000000000000000000000000 +decf530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c +decf531 apply #fc000000000000000000000000000000 -> -NaN +decf532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d +decf533 apply #fd000000000000000000000000000000 -> -NaN +decf534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e +decf535 apply #fe000000000000000000000000000000 -> -sNaN +decf536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f +decf537 apply #ff000000000000000000000000000000 -> -sNaN +decf538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999 +decf539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff + +decf540 apply NaN -> #7c000000000000000000000000000000 +decf541 apply NaN0 -> #7c000000000000000000000000000000 +decf542 apply NaN1 -> #7c000000000000000000000000000001 +decf543 apply NaN12 -> #7c000000000000000000000000000012 +decf544 apply NaN79 -> #7c000000000000000000000000000079 +decf545 apply NaN12345 -> #7c0000000000000000000000000049c5 +decf546 apply NaN123456 -> #7c000000000000000000000000028e56 +decf547 apply NaN799799 -> #7c0000000000000000000000000f7fdf +decf548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf +decf549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff +decf550 apply NaN1234567890123456789012345678901234 -> #7c000000000000000000000000000000 -- too many digits + +-- fold-down full sequence +decf600 apply 1E+6145 -> #78000000000000000000000000000000 Overflow Inexact Rounded +decf601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped +decf602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144 +decf603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped +decf604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143 +decf605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped +decf606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142 +decf607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped +decf608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141 +decf609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped +decf610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140 +decf611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped +decf612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139 +decf613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped +decf614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138 +decf615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped +decf616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137 +decf617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped +decf618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136 +decf619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped +decf620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135 +decf621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped +decf622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134 +decf623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped +decf624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133 +decf625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped +decf626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132 +decf627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped +decf628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131 +decf629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped +decf630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130 +decf631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped +decf632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129 +decf633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped +decf634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128 +decf635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped +decf636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127 +decf637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped +decf638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126 +decf639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped +decf640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125 +decf641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped +decf642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124 +decf643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped +decf644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123 +decf645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped +decf646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122 +decf647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped +decf648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121 +decf649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped +decf650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120 +decf651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped +decf652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119 +decf653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped +decf654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118 +decf655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped +decf656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117 +decf657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped +decf658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116 +decf659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped +decf660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115 +decf661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped +decf662 apply #43ffc000000000000000000000000400 -> 1.000E+6114 +decf663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped +decf664 apply #43ffc000000000000000000000000080 -> 1.00E+6113 +decf665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped +decf666 apply #43ffc000000000000000000000000010 -> 1.0E+6112 +decf667 apply 1E+6111 -> #43ffc000000000000000000000000001 +decf668 apply #43ffc000000000000000000000000001 -> 1E+6111 +decf669 apply 1E+6110 -> #43ff8000000000000000000000000001 +decf670 apply #43ff8000000000000000000000000001 -> 1E+6110 + +-- Selected DPD codes +decf700 apply #22080000000000000000000000000000 -> 0 +decf701 apply #22080000000000000000000000000009 -> 9 +decf702 apply #22080000000000000000000000000010 -> 10 +decf703 apply #22080000000000000000000000000019 -> 19 +decf704 apply #22080000000000000000000000000020 -> 20 +decf705 apply #22080000000000000000000000000029 -> 29 +decf706 apply #22080000000000000000000000000030 -> 30 +decf707 apply #22080000000000000000000000000039 -> 39 +decf708 apply #22080000000000000000000000000040 -> 40 +decf709 apply #22080000000000000000000000000049 -> 49 +decf710 apply #22080000000000000000000000000050 -> 50 +decf711 apply #22080000000000000000000000000059 -> 59 +decf712 apply #22080000000000000000000000000060 -> 60 +decf713 apply #22080000000000000000000000000069 -> 69 +decf714 apply #22080000000000000000000000000070 -> 70 +decf715 apply #22080000000000000000000000000071 -> 71 +decf716 apply #22080000000000000000000000000072 -> 72 +decf717 apply #22080000000000000000000000000073 -> 73 +decf718 apply #22080000000000000000000000000074 -> 74 +decf719 apply #22080000000000000000000000000075 -> 75 +decf720 apply #22080000000000000000000000000076 -> 76 +decf721 apply #22080000000000000000000000000077 -> 77 +decf722 apply #22080000000000000000000000000078 -> 78 +decf723 apply #22080000000000000000000000000079 -> 79 + +decf730 apply #2208000000000000000000000000029e -> 994 +decf731 apply #2208000000000000000000000000029f -> 995 +decf732 apply #220800000000000000000000000002a0 -> 520 +decf733 apply #220800000000000000000000000002a1 -> 521 + +-- DPD: one of each of the huffman groups +decf740 apply #220800000000000000000000000003f7 -> 777 +decf741 apply #220800000000000000000000000003f8 -> 778 +decf742 apply #220800000000000000000000000003eb -> 787 +decf743 apply #2208000000000000000000000000037d -> 877 +decf744 apply #2208000000000000000000000000039f -> 997 +decf745 apply #220800000000000000000000000003bf -> 979 +decf746 apply #220800000000000000000000000003df -> 799 +decf747 apply #2208000000000000000000000000006e -> 888 + + +-- DPD all-highs cases (includes the 24 redundant codes) +decf750 apply #2208000000000000000000000000006e -> 888 +decf751 apply #2208000000000000000000000000016e -> 888 +decf752 apply #2208000000000000000000000000026e -> 888 +decf753 apply #2208000000000000000000000000036e -> 888 +decf754 apply #2208000000000000000000000000006f -> 889 +decf755 apply #2208000000000000000000000000016f -> 889 +decf756 apply #2208000000000000000000000000026f -> 889 +decf757 apply #2208000000000000000000000000036f -> 889 + +decf760 apply #2208000000000000000000000000007e -> 898 +decf761 apply #2208000000000000000000000000017e -> 898 +decf762 apply #2208000000000000000000000000027e -> 898 +decf763 apply #2208000000000000000000000000037e -> 898 +decf764 apply #2208000000000000000000000000007f -> 899 +decf765 apply #2208000000000000000000000000017f -> 899 +decf766 apply #2208000000000000000000000000027f -> 899 +decf767 apply #2208000000000000000000000000037f -> 899 + +decf770 apply #220800000000000000000000000000ee -> 988 +decf771 apply #220800000000000000000000000001ee -> 988 +decf772 apply #220800000000000000000000000002ee -> 988 +decf773 apply #220800000000000000000000000003ee -> 988 +decf774 apply #220800000000000000000000000000ef -> 989 +decf775 apply #220800000000000000000000000001ef -> 989 +decf776 apply #220800000000000000000000000002ef -> 989 +decf777 apply #220800000000000000000000000003ef -> 989 + +decf780 apply #220800000000000000000000000000fe -> 998 +decf781 apply #220800000000000000000000000001fe -> 998 +decf782 apply #220800000000000000000000000002fe -> 998 +decf783 apply #220800000000000000000000000003fe -> 998 +decf784 apply #220800000000000000000000000000ff -> 999 +decf785 apply #220800000000000000000000000001ff -> 999 +decf786 apply #220800000000000000000000000002ff -> 999 +decf787 apply #220800000000000000000000000003ff -> 999 + Added: sandbox/trunk/decimal-c/decimaltestdata/decimal32.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/decimal32.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,385 @@ +------------------------------------------------------------------------ +-- decimal32.decTest -- decimal four-byte format testcases -- +-- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests is for the four-byte concrete representation. +-- Its characteristics are: +-- +-- 1 bit sign +-- 5 bits combination field +-- 6 bits exponent continuation +-- 20 bits coefficient continuation +-- +-- Total exponent length 8 bits +-- Total coefficient length 24 bits (7 digits) +-- +-- Elimit = 191 (maximum encoded exponent) +-- Emax = 96 (largest exponent value) +-- Emin = -95 (smallest exponent value) +-- bias = 101 (subtracted from encoded exponent) = -Etiny + +extended: 1 +precision: 7 +rounding: half_up +maxExponent: 96 +minExponent: -95 + +-- General testcases +-- (mostly derived from the Strawman 4 document and examples) +decd001 apply #A23003D0 -> -7.50 +decd002 apply -7.50 -> #A23003D0 + +-- Normality +decd010 apply 1234567 -> #2654d2e7 +decd011 apply 1234567.0 -> #2654d2e7 Rounded +decd012 apply 1234567.1 -> #2654d2e7 Rounded Inexact +decd013 apply -1234567 -> #a654d2e7 +decd014 apply -1234567.0 -> #a654d2e7 Rounded +decd015 apply -1234567.1 -> #a654d2e7 Rounded Inexact + + +-- Nmax and similar +decd022 apply 9.999999E+96 -> #77f3fcff +decd023 apply #77f3fcff -> 9.999999E+96 +decd024 apply 1.234567E+96 -> #47f4d2e7 +decd025 apply #47f4d2e7 -> 1.234567E+96 +-- fold-downs (more below) +decd030 apply 1.23E+96 -> #47f4c000 Clamped +decd031 apply #47f4c000 -> 1.230000E+96 +decd032 apply 1E+96 -> #47f00000 Clamped +decd033 apply #47f00000 -> 1.000000E+96 + +-- overflows +maxExponent: 999 -- set high so conversion causes the overflow +minExponent: -999 +decd040 apply 10E+96 -> #78000000 Overflow Rounded Inexact +decd041 apply 1.000000E+97 -> #78000000 Overflow Rounded Inexact +maxExponent: 96 +minExponent: -95 + +decd051 apply 12345 -> #225049c5 +decd052 apply #225049c5 -> 12345 +decd053 apply 1234 -> #22500534 +decd054 apply #22500534 -> 1234 +decd055 apply 123 -> #225000a3 +decd056 apply #225000a3 -> 123 +decd057 apply 12 -> #22500012 +decd058 apply #22500012 -> 12 +decd059 apply 1 -> #22500001 +decd060 apply #22500001 -> 1 +decd061 apply 1.23 -> #223000a3 +decd062 apply #223000a3 -> 1.23 +decd063 apply 123.45 -> #223049c5 +decd064 apply #223049c5 -> 123.45 + +-- Nmin and below +decd071 apply 1E-95 -> #00600001 +decd072 apply #00600001 -> 1E-95 +decd073 apply 1.000000E-95 -> #04000000 +decd074 apply #04000000 -> 1.000000E-95 +decd075 apply 1.000001E-95 -> #04000001 +decd076 apply #04000001 -> 1.000001E-95 + +decd077 apply 0.100000E-95 -> #00020000 Subnormal +decd07x apply 1.00000E-96 -> 1.00000E-96 Subnormal +decd078 apply #00020000 -> 1.00000E-96 Subnormal +decd079 apply 0.000010E-95 -> #00000010 Subnormal +decd080 apply #00000010 -> 1.0E-100 Subnormal +decd081 apply 0.000001E-95 -> #00000001 Subnormal +decd082 apply #00000001 -> 1E-101 Subnormal +decd083 apply 1e-101 -> #00000001 Subnormal +decd084 apply #00000001 -> 1E-101 Subnormal +decd08x apply 1e-101 -> 1E-101 Subnormal + +-- underflows +decd090 apply 1e-101 -> #00000001 Subnormal +decd091 apply 1.9e-101 -> #00000002 Subnormal Underflow Inexact Rounded +decd092 apply 1.1e-101 -> #00000001 Subnormal Underflow Inexact Rounded +decd093 apply 1.001e-101 -> #00000001 Subnormal Underflow Inexact Rounded +decd094 apply 1.000001e-101 -> #00000001 Subnormal Underflow Inexact Rounded +decd095 apply 1.0000001e-101 -> #00000001 Subnormal Underflow Inexact Rounded +decd096 apply 0.1e-101 -> #00000000 Subnormal Underflow Inexact Rounded +decd097 apply 0.001e-101 -> #00000000 Subnormal Underflow Inexact Rounded +decd098 apply 0.000001e-101 -> #00000000 Subnormal Underflow Inexact Rounded +decd099 apply 0.0000001e-101 -> #00000000 Subnormal Underflow Inexact Rounded + +-- same again, negatives -- + +-- Nmax and similar +decd122 apply -9.999999E+96 -> #f7f3fcff +decd123 apply #f7f3fcff -> -9.999999E+96 +decd124 apply -1.234567E+96 -> #c7f4d2e7 +decd125 apply #c7f4d2e7 -> -1.234567E+96 +-- fold-downs (more below) +decd130 apply -1.23E+96 -> #c7f4c000 Clamped +decd131 apply #c7f4c000 -> -1.230000E+96 +decd132 apply -1E+96 -> #c7f00000 Clamped +decd133 apply #c7f00000 -> -1.000000E+96 + +-- overflows +maxExponent: 999 -- set high so conversion causes the overflow +minExponent: -999 +decd140 apply -10E+96 -> #f8000000 Overflow Rounded Inexact +decd141 apply -1.000000E+97 -> #f8000000 Overflow Rounded Inexact +maxExponent: 96 +minExponent: -95 + +decd151 apply -12345 -> #a25049c5 +decd152 apply #a25049c5 -> -12345 +decd153 apply -1234 -> #a2500534 +decd154 apply #a2500534 -> -1234 +decd155 apply -123 -> #a25000a3 +decd156 apply #a25000a3 -> -123 +decd157 apply -12 -> #a2500012 +decd158 apply #a2500012 -> -12 +decd159 apply -1 -> #a2500001 +decd160 apply #a2500001 -> -1 +decd161 apply -1.23 -> #a23000a3 +decd162 apply #a23000a3 -> -1.23 +decd163 apply -123.45 -> #a23049c5 +decd164 apply #a23049c5 -> -123.45 + +-- Nmin and below +decd171 apply -1E-95 -> #80600001 +decd172 apply #80600001 -> -1E-95 +decd173 apply -1.000000E-95 -> #84000000 +decd174 apply #84000000 -> -1.000000E-95 +decd175 apply -1.000001E-95 -> #84000001 +decd176 apply #84000001 -> -1.000001E-95 + +decd177 apply -0.100000E-95 -> #80020000 Subnormal +decd178 apply #80020000 -> -1.00000E-96 Subnormal +decd179 apply -0.000010E-95 -> #80000010 Subnormal +decd180 apply #80000010 -> -1.0E-100 Subnormal +decd181 apply -0.000001E-95 -> #80000001 Subnormal +decd182 apply #80000001 -> -1E-101 Subnormal +decd183 apply -1e-101 -> #80000001 Subnormal +decd184 apply #80000001 -> -1E-101 Subnormal + +-- underflows +decd190 apply -1e-101 -> #80000001 Subnormal +decd191 apply -1.9e-101 -> #80000002 Subnormal Underflow Inexact Rounded +decd192 apply -1.1e-101 -> #80000001 Subnormal Underflow Inexact Rounded +decd193 apply -1.001e-101 -> #80000001 Subnormal Underflow Inexact Rounded +decd194 apply -1.000001e-101 -> #80000001 Subnormal Underflow Inexact Rounded +decd195 apply -1.0000001e-101 -> #80000001 Subnormal Underflow Inexact Rounded +decd196 apply -0.1e-101 -> #80000000 Subnormal Underflow Inexact Rounded +decd197 apply -0.001e-101 -> #80000000 Subnormal Underflow Inexact Rounded +decd198 apply -0.000001e-101 -> #80000000 Subnormal Underflow Inexact Rounded +decd199 apply -0.0000001e-101 -> #80000000 Subnormal Underflow Inexact Rounded + +-- zeros +decd400 apply 0E-400 -> #00000000 Clamped +decd401 apply 0E-101 -> #00000000 +decd402 apply #00000000 -> 0E-101 +decd403 apply 0.000000E-95 -> #00000000 +decd404 apply #00000000 -> 0E-101 +decd405 apply 0E-2 -> #22300000 +decd406 apply #22300000 -> 0.00 +decd407 apply 0 -> #22500000 +decd408 apply #22500000 -> 0 +decd409 apply 0E+3 -> #22800000 +decd410 apply #22800000 -> 0E+3 +decd411 apply 0E+90 -> #43f00000 +decd412 apply #43f00000 -> 0E+90 +-- clamped zeros... +decd413 apply 0E+91 -> #43f00000 Clamped +decd414 apply #43f00000 -> 0E+90 +decd415 apply 0E+96 -> #43f00000 Clamped +decd416 apply #43f00000 -> 0E+90 +decd417 apply 0E+400 -> #43f00000 Clamped +decd418 apply #43f00000 -> 0E+90 + +-- negative zeros +decd420 apply -0E-400 -> #80000000 Clamped +decd421 apply -0E-101 -> #80000000 +decd422 apply #80000000 -> -0E-101 +decd423 apply -0.000000E-95 -> #80000000 +decd424 apply #80000000 -> -0E-101 +decd425 apply -0E-2 -> #a2300000 +decd426 apply #a2300000 -> -0.00 +decd427 apply -0 -> #a2500000 +decd428 apply #a2500000 -> -0 +decd429 apply -0E+3 -> #a2800000 +decd430 apply #a2800000 -> -0E+3 +decd431 apply -0E+90 -> #c3f00000 +decd432 apply #c3f00000 -> -0E+90 +-- clamped zeros... +decd433 apply -0E+91 -> #c3f00000 Clamped +decd434 apply #c3f00000 -> -0E+90 +decd435 apply -0E+96 -> #c3f00000 Clamped +decd436 apply #c3f00000 -> -0E+90 +decd437 apply -0E+400 -> #c3f00000 Clamped +decd438 apply #c3f00000 -> -0E+90 + +-- Specials +decd500 apply Infinity -> #78000000 +decd501 apply #78787878 -> #78000000 +decd502 apply #78000000 -> Infinity +decd503 apply #79797979 -> #78000000 +decd504 apply #79000000 -> Infinity +decd505 apply #7a7a7a7a -> #78000000 +decd506 apply #7a000000 -> Infinity +decd507 apply #7b7b7b7b -> #78000000 +decd508 apply #7b000000 -> Infinity +decd509 apply #7c7c7c7c -> #7c0c7c7c + +decd510 apply NaN -> #7c000000 +decd511 apply #7c000000 -> NaN +decd512 apply #7d7d7d7d -> #7c0d7d7d +decd513 apply #7d000000 -> NaN +decd514 apply #7e7e7e7e -> #7e0e7c7e +decd515 apply #7e000000 -> sNaN +decd516 apply #7f7f7f7f -> #7e0f7c7f +decd517 apply #7f000000 -> sNaN +decd518 apply #7fffffff -> sNaN999999 +decd519 apply #7fffffff -> #7e03fcff + +decd520 apply -Infinity -> #f8000000 +decd521 apply #f8787878 -> #f8000000 +decd522 apply #f8000000 -> -Infinity +decd523 apply #f9797979 -> #f8000000 +decd524 apply #f9000000 -> -Infinity +decd525 apply #fa7a7a7a -> #f8000000 +decd526 apply #fa000000 -> -Infinity +decd527 apply #fb7b7b7b -> #f8000000 +decd528 apply #fb000000 -> -Infinity + +decd529 apply -NaN -> #fc000000 +decd530 apply #fc7c7c7c -> #fc0c7c7c +decd531 apply #fc000000 -> -NaN +decd532 apply #fd7d7d7d -> #fc0d7d7d +decd533 apply #fd000000 -> -NaN +decd534 apply #fe7e7e7e -> #fe0e7c7e +decd535 apply #fe000000 -> -sNaN +decd536 apply #ff7f7f7f -> #fe0f7c7f +decd537 apply #ff000000 -> -sNaN +decd538 apply #ffffffff -> -sNaN999999 +decd539 apply #ffffffff -> #fe03fcff + +-- diagnostic NaNs +decd540 apply NaN -> #7c000000 +decd541 apply NaN0 -> #7c000000 +decd542 apply NaN1 -> #7c000001 +decd543 apply NaN12 -> #7c000012 +decd544 apply NaN79 -> #7c000079 +decd545 apply NaN12345 -> #7c0049c5 +decd546 apply NaN123456 -> #7c028e56 +decd547 apply NaN799799 -> #7c0f7fdf +decd548 apply NaN999999 -> #7c03fcff +decd549 apply NaN1234567 -> #7c000000 -- too many digits + + +-- fold-down full sequence +decd601 apply 1E+96 -> #47f00000 Clamped +decd602 apply #47f00000 -> 1.000000E+96 +decd603 apply 1E+95 -> #43f20000 Clamped +decd604 apply #43f20000 -> 1.00000E+95 +decd605 apply 1E+94 -> #43f04000 Clamped +decd606 apply #43f04000 -> 1.0000E+94 +decd607 apply 1E+93 -> #43f00400 Clamped +decd608 apply #43f00400 -> 1.000E+93 +decd609 apply 1E+92 -> #43f00080 Clamped +decd610 apply #43f00080 -> 1.00E+92 +decd611 apply 1E+91 -> #43f00010 Clamped +decd612 apply #43f00010 -> 1.0E+91 +decd613 apply 1E+90 -> #43f00001 +decd614 apply #43f00001 -> 1E+90 + + +-- Selected DPD codes +decd700 apply #22500000 -> 0 +decd701 apply #22500009 -> 9 +decd702 apply #22500010 -> 10 +decd703 apply #22500019 -> 19 +decd704 apply #22500020 -> 20 +decd705 apply #22500029 -> 29 +decd706 apply #22500030 -> 30 +decd707 apply #22500039 -> 39 +decd708 apply #22500040 -> 40 +decd709 apply #22500049 -> 49 +decd710 apply #22500050 -> 50 +decd711 apply #22500059 -> 59 +decd712 apply #22500060 -> 60 +decd713 apply #22500069 -> 69 +decd714 apply #22500070 -> 70 +decd715 apply #22500071 -> 71 +decd716 apply #22500072 -> 72 +decd717 apply #22500073 -> 73 +decd718 apply #22500074 -> 74 +decd719 apply #22500075 -> 75 +decd720 apply #22500076 -> 76 +decd721 apply #22500077 -> 77 +decd722 apply #22500078 -> 78 +decd723 apply #22500079 -> 79 + +decd730 apply #2250029e -> 994 +decd731 apply #2250029f -> 995 +decd732 apply #225002a0 -> 520 +decd733 apply #225002a1 -> 521 + +-- DPD: one of each of the huffman groups +decd740 apply #225003f7 -> 777 +decd741 apply #225003f8 -> 778 +decd742 apply #225003eb -> 787 +decd743 apply #2250037d -> 877 +decd744 apply #2250039f -> 997 +decd745 apply #225003bf -> 979 +decd746 apply #225003df -> 799 +decd747 apply #2250006e -> 888 + + +-- DPD all-highs cases (includes the 24 redundant codes) +decd750 apply #2250006e -> 888 +decd751 apply #2250016e -> 888 +decd752 apply #2250026e -> 888 +decd753 apply #2250036e -> 888 +decd754 apply #2250006f -> 889 +decd755 apply #2250016f -> 889 +decd756 apply #2250026f -> 889 +decd757 apply #2250036f -> 889 + +decd760 apply #2250007e -> 898 +decd761 apply #2250017e -> 898 +decd762 apply #2250027e -> 898 +decd763 apply #2250037e -> 898 +decd764 apply #2250007f -> 899 +decd765 apply #2250017f -> 899 +decd766 apply #2250027f -> 899 +decd767 apply #2250037f -> 899 + +decd770 apply #225000ee -> 988 +decd771 apply #225001ee -> 988 +decd772 apply #225002ee -> 988 +decd773 apply #225003ee -> 988 +decd774 apply #225000ef -> 989 +decd775 apply #225001ef -> 989 +decd776 apply #225002ef -> 989 +decd777 apply #225003ef -> 989 + +decd780 apply #225000fe -> 998 +decd781 apply #225001fe -> 998 +decd782 apply #225002fe -> 998 +decd783 apply #225003fe -> 998 +decd784 apply #225000ff -> 999 +decd785 apply #225001ff -> 999 +decd786 apply #225002ff -> 999 +decd787 apply #225003ff -> 999 + Added: sandbox/trunk/decimal-c/decimaltestdata/decimal64.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/decimal64.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,444 @@ +------------------------------------------------------------------------ +-- decimal64.decTest -- decimal eight-byte format testcases -- +-- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests is for the eight-byte concrete representation. +-- Its characteristics are: +-- +-- 1 bit sign +-- 5 bits combination field +-- 8 bits exponent continuation +-- 50 bits coefficient continuation +-- +-- Total exponent length 10 bits +-- Total coefficient length 54 bits (16 digits) +-- +-- Elimit = 767 (maximum encoded exponent) +-- Emax = 384 (largest exponent value) +-- Emin = -383 (smallest exponent value) +-- bias = 398 (subtracted from encoded exponent) = -Etiny + +extended: 1 +precision: 16 +rounding: half_up +maxExponent: 384 +minExponent: -383 + +-- General testcases +-- (mostly derived from the Strawman 4 document and examples) +dece001 apply #A2300000000003D0 -> -7.50 +dece002 apply -7.50 -> #A2300000000003D0 + +-- Normality +dece010 apply 1234567890123456 -> #263934b9c1e28e56 +dece011 apply 1234567890123456.0 -> #263934b9c1e28e56 Rounded +dece012 apply 1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact +dece013 apply -1234567890123456 -> #a63934b9c1e28e56 +dece014 apply -1234567890123456.0 -> #a63934b9c1e28e56 Rounded +dece015 apply -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact + + +-- Nmax and similar +dece022 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff +dece023 apply #77fcff3fcff3fcff -> 9.999999999999999E+384 +dece024 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56 +dece025 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384 +-- fold-downs (more below) +dece030 apply 1.23E+384 -> #47fd300000000000 Clamped +dece031 apply #47fd300000000000 -> 1.230000000000000E+384 +dece032 apply 1E+384 -> #47fc000000000000 Clamped +dece033 apply #47fc000000000000 -> 1.000000000000000E+384 + +-- overflows +maxExponent: 999 -- set high so conversion causes the overflow +minExponent: -999 +dece040 apply 10E+384 -> #7800000000000000 Overflow Rounded Inexact +dece041 apply 1.000000000000000E+385 -> #7800000000000000 Overflow Rounded Inexact +maxExponent: 384 +minExponent: -383 + +dece051 apply 12345 -> #22380000000049c5 +dece052 apply #22380000000049c5 -> 12345 +dece053 apply 1234 -> #2238000000000534 +dece054 apply #2238000000000534 -> 1234 +dece055 apply 123 -> #22380000000000a3 +dece056 apply #22380000000000a3 -> 123 +dece057 apply 12 -> #2238000000000012 +dece058 apply #2238000000000012 -> 12 +dece059 apply 1 -> #2238000000000001 +dece060 apply #2238000000000001 -> 1 +dece061 apply 1.23 -> #22300000000000a3 +dece062 apply #22300000000000a3 -> 1.23 +dece063 apply 123.45 -> #22300000000049c5 +dece064 apply #22300000000049c5 -> 123.45 + +-- Nmin and below +dece071 apply 1E-383 -> #003c000000000001 +dece072 apply #003c000000000001 -> 1E-383 +dece073 apply 1.000000000000000E-383 -> #0400000000000000 +dece074 apply #0400000000000000 -> 1.000000000000000E-383 +dece075 apply 1.000000000000001E-383 -> #0400000000000001 +dece076 apply #0400000000000001 -> 1.000000000000001E-383 + +dece077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal +dece078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal +dece079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal +dece080 apply #0000000000000010 -> 1.0E-397 Subnormal +dece081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal +dece082 apply #0004000000000001 -> 1E-397 Subnormal +dece083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal +dece084 apply #0000000000000001 -> 1E-398 Subnormal + +-- underflows +dece090 apply 1e-398 -> #0000000000000001 Subnormal +dece091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded +dece092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +dece093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +dece094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +dece095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded +dece096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +dece097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +dece098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded +dece099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded + +-- Same again, negatives +-- Nmax and similar +dece122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff +dece123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384 +dece124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56 +dece125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384 +-- fold-downs (more below) +dece130 apply -1.23E+384 -> #c7fd300000000000 Clamped +dece131 apply #c7fd300000000000 -> -1.230000000000000E+384 +dece132 apply -1E+384 -> #c7fc000000000000 Clamped +dece133 apply #c7fc000000000000 -> -1.000000000000000E+384 + +-- overflows +maxExponent: 999 -- set high so conversion causes the overflow +minExponent: -999 +dece140 apply -10E+384 -> #f800000000000000 Overflow Rounded Inexact +dece141 apply -1.000000000000000E+385 -> #f800000000000000 Overflow Rounded Inexact +maxExponent: 384 +minExponent: -383 + +dece151 apply -12345 -> #a2380000000049c5 +dece152 apply #a2380000000049c5 -> -12345 +dece153 apply -1234 -> #a238000000000534 +dece154 apply #a238000000000534 -> -1234 +dece155 apply -123 -> #a2380000000000a3 +dece156 apply #a2380000000000a3 -> -123 +dece157 apply -12 -> #a238000000000012 +dece158 apply #a238000000000012 -> -12 +dece159 apply -1 -> #a238000000000001 +dece160 apply #a238000000000001 -> -1 +dece161 apply -1.23 -> #a2300000000000a3 +dece162 apply #a2300000000000a3 -> -1.23 +dece163 apply -123.45 -> #a2300000000049c5 +dece164 apply #a2300000000049c5 -> -123.45 + +-- Nmin and below +dece171 apply -1E-383 -> #803c000000000001 +dece172 apply #803c000000000001 -> -1E-383 +dece173 apply -1.000000000000000E-383 -> #8400000000000000 +dece174 apply #8400000000000000 -> -1.000000000000000E-383 +dece175 apply -1.000000000000001E-383 -> #8400000000000001 +dece176 apply #8400000000000001 -> -1.000000000000001E-383 + +dece177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal +dece178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal +dece179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal +dece180 apply #8000000000000010 -> -1.0E-397 Subnormal +dece181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal +dece182 apply #8004000000000001 -> -1E-397 Subnormal +dece183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal +dece184 apply #8000000000000001 -> -1E-398 Subnormal + +-- underflows +dece189 apply -1e-398 -> #8000000000000001 Subnormal +dece190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded +dece191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded +dece192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +dece193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +dece194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +dece195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded +dece196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +dece197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +dece198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded +dece199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded + +-- zeros +dece401 apply 0E-500 -> #0000000000000000 Clamped +dece402 apply 0E-400 -> #0000000000000000 Clamped +dece403 apply 0E-398 -> #0000000000000000 +dece404 apply #0000000000000000 -> 0E-398 +dece405 apply 0.000000000000000E-383 -> #0000000000000000 +dece406 apply #0000000000000000 -> 0E-398 +dece407 apply 0E-2 -> #2230000000000000 +dece408 apply #2230000000000000 -> 0.00 +dece409 apply 0 -> #2238000000000000 +dece410 apply #2238000000000000 -> 0 +dece411 apply 0E+3 -> #2244000000000000 +dece412 apply #2244000000000000 -> 0E+3 +dece413 apply 0E+369 -> #43fc000000000000 +dece414 apply #43fc000000000000 -> 0E+369 +-- clamped zeros... +dece415 apply 0E+370 -> #43fc000000000000 Clamped +dece416 apply #43fc000000000000 -> 0E+369 +dece417 apply 0E+384 -> #43fc000000000000 Clamped +dece418 apply #43fc000000000000 -> 0E+369 +dece419 apply 0E+400 -> #43fc000000000000 Clamped +dece420 apply #43fc000000000000 -> 0E+369 +dece421 apply 0E+500 -> #43fc000000000000 Clamped +dece422 apply #43fc000000000000 -> 0E+369 + +-- negative zeros +dece431 apply -0E-400 -> #8000000000000000 Clamped +dece432 apply -0E-400 -> #8000000000000000 Clamped +dece433 apply -0E-398 -> #8000000000000000 +dece434 apply #8000000000000000 -> -0E-398 +dece435 apply -0.000000000000000E-383 -> #8000000000000000 +dece436 apply #8000000000000000 -> -0E-398 +dece437 apply -0E-2 -> #a230000000000000 +dece438 apply #a230000000000000 -> -0.00 +dece439 apply -0 -> #a238000000000000 +dece440 apply #a238000000000000 -> -0 +dece441 apply -0E+3 -> #a244000000000000 +dece442 apply #a244000000000000 -> -0E+3 +dece443 apply -0E+369 -> #c3fc000000000000 +dece444 apply #c3fc000000000000 -> -0E+369 +-- clamped zeros... +dece445 apply -0E+370 -> #c3fc000000000000 Clamped +dece446 apply #c3fc000000000000 -> -0E+369 +dece447 apply -0E+384 -> #c3fc000000000000 Clamped +dece448 apply #c3fc000000000000 -> -0E+369 +dece449 apply -0E+400 -> #c3fc000000000000 Clamped +dece450 apply #c3fc000000000000 -> -0E+369 +dece451 apply -0E+500 -> #c3fc000000000000 Clamped +dece452 apply #c3fc000000000000 -> -0E+369 + +-- Specials +dece500 apply Infinity -> #7800000000000000 +dece501 apply #7878787878787878 -> #7800000000000000 +dece502 apply #7800000000000000 -> Infinity +dece503 apply #7979797979797979 -> #7800000000000000 +dece504 apply #7900000000000000 -> Infinity +dece505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000 +dece506 apply #7a00000000000000 -> Infinity +dece507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000 +dece508 apply #7b00000000000000 -> Infinity + +dece509 apply NaN -> #7c00000000000000 +dece510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c +dece511 apply #7c00000000000000 -> NaN +dece512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d +dece513 apply #7d00000000000000 -> NaN +dece514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e +dece515 apply #7e00000000000000 -> sNaN +dece516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f +dece517 apply #7f00000000000000 -> sNaN +dece518 apply #7fffffffffffffff -> sNaN999999999999999 +dece519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff + +dece520 apply -Infinity -> #f800000000000000 +dece521 apply #f878787878787878 -> #f800000000000000 +dece522 apply #f800000000000000 -> -Infinity +dece523 apply #f979797979797979 -> #f800000000000000 +dece524 apply #f900000000000000 -> -Infinity +dece525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000 +dece526 apply #fa00000000000000 -> -Infinity +dece527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000 +dece528 apply #fb00000000000000 -> -Infinity + +dece529 apply -NaN -> #fc00000000000000 +dece530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c +dece531 apply #fc00000000000000 -> -NaN +dece532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d +dece533 apply #fd00000000000000 -> -NaN +dece534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e +dece535 apply #fe00000000000000 -> -sNaN +dece536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f +dece537 apply #ff00000000000000 -> -sNaN +dece538 apply #ffffffffffffffff -> -sNaN999999999999999 +dece539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff + +-- diagnostic NaNs +dece540 apply NaN -> #7c00000000000000 +dece541 apply NaN0 -> #7c00000000000000 +dece542 apply NaN1 -> #7c00000000000001 +dece543 apply NaN12 -> #7c00000000000012 +dece544 apply NaN79 -> #7c00000000000079 +dece545 apply NaN12345 -> #7c000000000049c5 +dece546 apply NaN123456 -> #7c00000000028e56 +dece547 apply NaN799799 -> #7c000000000f7fdf +dece548 apply NaN799799799799799 -> #7c03dff7fdff7fdf +dece549 apply NaN999999999999999 -> #7c00ff3fcff3fcff +dece550 apply NaN1234567890123456 -> #7c00000000000000 -- too many digits + +-- fold-down full sequence +dece601 apply 1E+384 -> #47fc000000000000 Clamped +dece602 apply #47fc000000000000 -> 1.000000000000000E+384 +dece603 apply 1E+383 -> #43fc800000000000 Clamped +dece604 apply #43fc800000000000 -> 1.00000000000000E+383 +dece605 apply 1E+382 -> #43fc100000000000 Clamped +dece606 apply #43fc100000000000 -> 1.0000000000000E+382 +dece607 apply 1E+381 -> #43fc010000000000 Clamped +dece608 apply #43fc010000000000 -> 1.000000000000E+381 +dece609 apply 1E+380 -> #43fc002000000000 Clamped +dece610 apply #43fc002000000000 -> 1.00000000000E+380 +dece611 apply 1E+379 -> #43fc000400000000 Clamped +dece612 apply #43fc000400000000 -> 1.0000000000E+379 +dece613 apply 1E+378 -> #43fc000040000000 Clamped +dece614 apply #43fc000040000000 -> 1.000000000E+378 +dece615 apply 1E+377 -> #43fc000008000000 Clamped +dece616 apply #43fc000008000000 -> 1.00000000E+377 +dece617 apply 1E+376 -> #43fc000001000000 Clamped +dece618 apply #43fc000001000000 -> 1.0000000E+376 +dece619 apply 1E+375 -> #43fc000000100000 Clamped +dece620 apply #43fc000000100000 -> 1.000000E+375 +dece621 apply 1E+374 -> #43fc000000020000 Clamped +dece622 apply #43fc000000020000 -> 1.00000E+374 +dece623 apply 1E+373 -> #43fc000000004000 Clamped +dece624 apply #43fc000000004000 -> 1.0000E+373 +dece625 apply 1E+372 -> #43fc000000000400 Clamped +dece626 apply #43fc000000000400 -> 1.000E+372 +dece627 apply 1E+371 -> #43fc000000000080 Clamped +dece628 apply #43fc000000000080 -> 1.00E+371 +dece629 apply 1E+370 -> #43fc000000000010 Clamped +dece630 apply #43fc000000000010 -> 1.0E+370 +dece631 apply 1E+369 -> #43fc000000000001 +dece632 apply #43fc000000000001 -> 1E+369 +dece633 apply 1E+368 -> #43f8000000000001 +dece634 apply #43f8000000000001 -> 1E+368 +-- same with 9s +dece641 apply 9E+384 -> #77fc000000000000 Clamped +dece642 apply #77fc000000000000 -> 9.000000000000000E+384 +dece643 apply 9E+383 -> #43fc8c0000000000 Clamped +dece644 apply #43fc8c0000000000 -> 9.00000000000000E+383 +dece645 apply 9E+382 -> #43fc1a0000000000 Clamped +dece646 apply #43fc1a0000000000 -> 9.0000000000000E+382 +dece647 apply 9E+381 -> #43fc090000000000 Clamped +dece648 apply #43fc090000000000 -> 9.000000000000E+381 +dece649 apply 9E+380 -> #43fc002300000000 Clamped +dece650 apply #43fc002300000000 -> 9.00000000000E+380 +dece651 apply 9E+379 -> #43fc000680000000 Clamped +dece652 apply #43fc000680000000 -> 9.0000000000E+379 +dece653 apply 9E+378 -> #43fc000240000000 Clamped +dece654 apply #43fc000240000000 -> 9.000000000E+378 +dece655 apply 9E+377 -> #43fc000008c00000 Clamped +dece656 apply #43fc000008c00000 -> 9.00000000E+377 +dece657 apply 9E+376 -> #43fc000001a00000 Clamped +dece658 apply #43fc000001a00000 -> 9.0000000E+376 +dece659 apply 9E+375 -> #43fc000000900000 Clamped +dece660 apply #43fc000000900000 -> 9.000000E+375 +dece661 apply 9E+374 -> #43fc000000023000 Clamped +dece662 apply #43fc000000023000 -> 9.00000E+374 +dece663 apply 9E+373 -> #43fc000000006800 Clamped +dece664 apply #43fc000000006800 -> 9.0000E+373 +dece665 apply 9E+372 -> #43fc000000002400 Clamped +dece666 apply #43fc000000002400 -> 9.000E+372 +dece667 apply 9E+371 -> #43fc00000000008c Clamped +dece668 apply #43fc00000000008c -> 9.00E+371 +dece669 apply 9E+370 -> #43fc00000000001a Clamped +dece670 apply #43fc00000000001a -> 9.0E+370 +dece671 apply 9E+369 -> #43fc000000000009 +dece672 apply #43fc000000000009 -> 9E+369 +dece673 apply 9E+368 -> #43f8000000000009 +dece674 apply #43f8000000000009 -> 9E+368 + + +-- Selected DPD codes +dece700 apply #2238000000000000 -> 0 +dece701 apply #2238000000000009 -> 9 +dece702 apply #2238000000000010 -> 10 +dece703 apply #2238000000000019 -> 19 +dece704 apply #2238000000000020 -> 20 +dece705 apply #2238000000000029 -> 29 +dece706 apply #2238000000000030 -> 30 +dece707 apply #2238000000000039 -> 39 +dece708 apply #2238000000000040 -> 40 +dece709 apply #2238000000000049 -> 49 +dece710 apply #2238000000000050 -> 50 +dece711 apply #2238000000000059 -> 59 +dece712 apply #2238000000000060 -> 60 +dece713 apply #2238000000000069 -> 69 +dece714 apply #2238000000000070 -> 70 +dece715 apply #2238000000000071 -> 71 +dece716 apply #2238000000000072 -> 72 +dece717 apply #2238000000000073 -> 73 +dece718 apply #2238000000000074 -> 74 +dece719 apply #2238000000000075 -> 75 +dece720 apply #2238000000000076 -> 76 +dece721 apply #2238000000000077 -> 77 +dece722 apply #2238000000000078 -> 78 +dece723 apply #2238000000000079 -> 79 + +dece730 apply #223800000000029e -> 994 +dece731 apply #223800000000029f -> 995 +dece732 apply #22380000000002a0 -> 520 +dece733 apply #22380000000002a1 -> 521 + +-- DPD: one of each of the huffman groups +dece740 apply #22380000000003f7 -> 777 +dece741 apply #22380000000003f8 -> 778 +dece742 apply #22380000000003eb -> 787 +dece743 apply #223800000000037d -> 877 +dece744 apply #223800000000039f -> 997 +dece745 apply #22380000000003bf -> 979 +dece746 apply #22380000000003df -> 799 +dece747 apply #223800000000006e -> 888 + + +-- DPD all-highs cases (includes the 24 redundant codes) +dece750 apply #223800000000006e -> 888 +dece751 apply #223800000000016e -> 888 +dece752 apply #223800000000026e -> 888 +dece753 apply #223800000000036e -> 888 +dece754 apply #223800000000006f -> 889 +dece755 apply #223800000000016f -> 889 +dece756 apply #223800000000026f -> 889 +dece757 apply #223800000000036f -> 889 + +dece760 apply #223800000000007e -> 898 +dece761 apply #223800000000017e -> 898 +dece762 apply #223800000000027e -> 898 +dece763 apply #223800000000037e -> 898 +dece764 apply #223800000000007f -> 899 +dece765 apply #223800000000017f -> 899 +dece766 apply #223800000000027f -> 899 +dece767 apply #223800000000037f -> 899 + +dece770 apply #22380000000000ee -> 988 +dece771 apply #22380000000001ee -> 988 +dece772 apply #22380000000002ee -> 988 +dece773 apply #22380000000003ee -> 988 +dece774 apply #22380000000000ef -> 989 +dece775 apply #22380000000001ef -> 989 +dece776 apply #22380000000002ef -> 989 +dece777 apply #22380000000003ef -> 989 + +dece780 apply #22380000000000fe -> 998 +dece781 apply #22380000000001fe -> 998 +dece782 apply #22380000000002fe -> 998 +dece783 apply #22380000000003fe -> 998 +dece784 apply #22380000000000ff -> 999 +dece785 apply #22380000000001ff -> 999 +dece786 apply #22380000000002ff -> 999 +dece787 apply #22380000000003ff -> 999 + Added: sandbox/trunk/decimal-c/decimaltestdata/divide.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/divide.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,818 @@ +------------------------------------------------------------------------ +-- divide.decTest -- decimal division -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- sanity checks +divx001 divide 1 1 -> 1 +divx002 divide 2 1 -> 2 +divx003 divide 1 2 -> 0.5 +divx004 divide 2 2 -> 1 +divx005 divide 0 1 -> 0 +divx006 divide 0 2 -> 0 +divx007 divide 1 3 -> 0.333333333 Inexact Rounded +divx008 divide 2 3 -> 0.666666667 Inexact Rounded +divx009 divide 3 3 -> 1 + +divx010 divide 2.4 1 -> 2.4 +divx011 divide 2.4 -1 -> -2.4 +divx012 divide -2.4 1 -> -2.4 +divx013 divide -2.4 -1 -> 2.4 +divx014 divide 2.40 1 -> 2.40 +divx015 divide 2.400 1 -> 2.400 +divx016 divide 2.4 2 -> 1.2 +divx017 divide 2.400 2 -> 1.200 +divx018 divide 2. 2 -> 1 +divx019 divide 20 20 -> 1 + +divx020 divide 187 187 -> 1 +divx021 divide 5 2 -> 2.5 +divx022 divide 5 2.0 -> 2.5 +divx023 divide 5 2.000 -> 2.5 +divx024 divide 5 0.20 -> 25 +divx025 divide 5 0.200 -> 25 +divx026 divide 10 1 -> 10 +divx027 divide 100 1 -> 100 +divx028 divide 1000 1 -> 1000 +divx029 divide 1000 100 -> 10 + +divx030 divide 1 2 -> 0.5 +divx031 divide 1 4 -> 0.25 +divx032 divide 1 8 -> 0.125 +divx033 divide 1 16 -> 0.0625 +divx034 divide 1 32 -> 0.03125 +divx035 divide 1 64 -> 0.015625 +divx040 divide 1 -2 -> -0.5 +divx041 divide 1 -4 -> -0.25 +divx042 divide 1 -8 -> -0.125 +divx043 divide 1 -16 -> -0.0625 +divx044 divide 1 -32 -> -0.03125 +divx045 divide 1 -64 -> -0.015625 +divx050 divide -1 2 -> -0.5 +divx051 divide -1 4 -> -0.25 +divx052 divide -1 8 -> -0.125 +divx053 divide -1 16 -> -0.0625 +divx054 divide -1 32 -> -0.03125 +divx055 divide -1 64 -> -0.015625 +divx060 divide -1 -2 -> 0.5 +divx061 divide -1 -4 -> 0.25 +divx062 divide -1 -8 -> 0.125 +divx063 divide -1 -16 -> 0.0625 +divx064 divide -1 -32 -> 0.03125 +divx065 divide -1 -64 -> 0.015625 + +divx070 divide 999999999 1 -> 999999999 +divx071 divide 999999999.4 1 -> 999999999 Inexact Rounded +divx072 divide 999999999.5 1 -> 1.00000000E+9 Inexact Rounded +divx073 divide 999999999.9 1 -> 1.00000000E+9 Inexact Rounded +divx074 divide 999999999.999 1 -> 1.00000000E+9 Inexact Rounded +precision: 6 +divx080 divide 999999999 1 -> 1.00000E+9 Inexact Rounded +divx081 divide 99999999 1 -> 1.00000E+8 Inexact Rounded +divx082 divide 9999999 1 -> 1.00000E+7 Inexact Rounded +divx083 divide 999999 1 -> 999999 +divx084 divide 99999 1 -> 99999 +divx085 divide 9999 1 -> 9999 +divx086 divide 999 1 -> 999 +divx087 divide 99 1 -> 99 +divx088 divide 9 1 -> 9 + +precision: 9 +divx090 divide 0. 1 -> 0 +divx091 divide .0 1 -> 0.0 +divx092 divide 0.00 1 -> 0.00 +divx093 divide 0.00E+9 1 -> 0E+7 +divx094 divide 0.0000E-50 1 -> 0E-54 + +divx095 divide 1 1E-8 -> 1E+8 +divx096 divide 1 1E-9 -> 1E+9 +divx097 divide 1 1E-10 -> 1E+10 +divx098 divide 1 1E-11 -> 1E+11 +divx099 divide 1 1E-12 -> 1E+12 + +divx100 divide 1 1 -> 1 +divx101 divide 1 2 -> 0.5 +divx102 divide 1 3 -> 0.333333333 Inexact Rounded +divx103 divide 1 4 -> 0.25 +divx104 divide 1 5 -> 0.2 +divx105 divide 1 6 -> 0.166666667 Inexact Rounded +divx106 divide 1 7 -> 0.142857143 Inexact Rounded +divx107 divide 1 8 -> 0.125 +divx108 divide 1 9 -> 0.111111111 Inexact Rounded +divx109 divide 1 10 -> 0.1 +divx110 divide 1 1 -> 1 +divx111 divide 2 1 -> 2 +divx112 divide 3 1 -> 3 +divx113 divide 4 1 -> 4 +divx114 divide 5 1 -> 5 +divx115 divide 6 1 -> 6 +divx116 divide 7 1 -> 7 +divx117 divide 8 1 -> 8 +divx118 divide 9 1 -> 9 +divx119 divide 10 1 -> 10 + +divx120 divide 3E+1 0.001 -> 3E+4 +divx121 divide 2.200 2 -> 1.100 + +divx130 divide 12345 4.999 -> 2469.49390 Inexact Rounded +divx131 divide 12345 4.99 -> 2473.94790 Inexact Rounded +divx132 divide 12345 4.9 -> 2519.38776 Inexact Rounded +divx133 divide 12345 5 -> 2469 +divx134 divide 12345 5.1 -> 2420.58824 Inexact Rounded +divx135 divide 12345 5.01 -> 2464.07186 Inexact Rounded +divx136 divide 12345 5.001 -> 2468.50630 Inexact Rounded + +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 + +-- test possibly imprecise results +divx220 divide 391 597 -> 0.654941374 Inexact Rounded +divx221 divide 391 -597 -> -0.654941374 Inexact Rounded +divx222 divide -391 597 -> -0.654941374 Inexact Rounded +divx223 divide -391 -597 -> 0.654941374 Inexact Rounded + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +divx270 divide 1 1e999999999 -> 1E-999999999 +divx271 divide 1 0.9e999999999 -> 1.11111111E-999999999 Inexact Rounded +divx272 divide 1 0.99e999999999 -> 1.01010101E-999999999 Inexact Rounded +divx273 divide 1 0.999999999e999999999 -> 1.00000000E-999999999 Inexact Rounded +divx274 divide 9e999999999 1 -> 9E+999999999 +divx275 divide 9.9e999999999 1 -> 9.9E+999999999 +divx276 divide 9.99e999999999 1 -> 9.99E+999999999 +divx277 divide 9.99999999e999999999 1 -> 9.99999999E+999999999 + +divx280 divide 0.1 9e-999999999 -> 1.11111111E+999999997 Inexact Rounded +divx281 divide 0.1 99e-999999999 -> 1.01010101E+999999996 Inexact Rounded +divx282 divide 0.1 999e-999999999 -> 1.00100100E+999999995 Inexact Rounded + +divx283 divide 0.1 9e-999999998 -> 1.11111111E+999999996 Inexact Rounded +divx284 divide 0.1 99e-999999998 -> 1.01010101E+999999995 Inexact Rounded +divx285 divide 0.1 999e-999999998 -> 1.00100100E+999999994 Inexact Rounded +divx286 divide 0.1 999e-999999997 -> 1.00100100E+999999993 Inexact Rounded +divx287 divide 0.1 9999e-999999997 -> 1.00010001E+999999992 Inexact Rounded +divx288 divide 0.1 99999e-999999997 -> 1.00001000E+999999991 Inexact Rounded + +-- Divide into 0 tests + +divx301 divide 0 7 -> 0 +divx302 divide 0 7E-5 -> 0E+5 +divx303 divide 0 7E-1 -> 0E+1 +divx304 divide 0 7E+1 -> 0.0 +divx305 divide 0 7E+5 -> 0.00000 +divx306 divide 0 7E+6 -> 0.000000 +divx307 divide 0 7E+7 -> 0E-7 +divx308 divide 0 70E-5 -> 0E+5 +divx309 divide 0 70E-1 -> 0E+1 +divx310 divide 0 70E+0 -> 0 +divx311 divide 0 70E+1 -> 0.0 +divx312 divide 0 70E+5 -> 0.00000 +divx313 divide 0 70E+6 -> 0.000000 +divx314 divide 0 70E+7 -> 0E-7 +divx315 divide 0 700E-5 -> 0E+5 +divx316 divide 0 700E-1 -> 0E+1 +divx317 divide 0 700E+0 -> 0 +divx318 divide 0 700E+1 -> 0.0 +divx319 divide 0 700E+5 -> 0.00000 +divx320 divide 0 700E+6 -> 0.000000 +divx321 divide 0 700E+7 -> 0E-7 +divx322 divide 0 700E+77 -> 0E-77 + +divx331 divide 0E-3 7E-5 -> 0E+2 +divx332 divide 0E-3 7E-1 -> 0.00 +divx333 divide 0E-3 7E+1 -> 0.0000 +divx334 divide 0E-3 7E+5 -> 0E-8 +divx335 divide 0E-1 7E-5 -> 0E+4 +divx336 divide 0E-1 7E-1 -> 0 +divx337 divide 0E-1 7E+1 -> 0.00 +divx338 divide 0E-1 7E+5 -> 0.000000 +divx339 divide 0E+1 7E-5 -> 0E+6 +divx340 divide 0E+1 7E-1 -> 0E+2 +divx341 divide 0E+1 7E+1 -> 0 +divx342 divide 0E+1 7E+5 -> 0.0000 +divx343 divide 0E+3 7E-5 -> 0E+8 +divx344 divide 0E+3 7E-1 -> 0E+4 +divx345 divide 0E+3 7E+1 -> 0E+2 +divx346 divide 0E+3 7E+5 -> 0.00 + +maxexponent: 92 +minexponent: -92 +precision: 7 +divx351 divide 0E-92 7E-1 -> 0E-91 +divx352 divide 0E-92 7E+1 -> 0E-93 +divx353 divide 0E-92 7E+5 -> 0E-97 +divx354 divide 0E-92 7E+6 -> 0E-98 +divx355 divide 0E-92 7E+7 -> 0E-98 Clamped +divx356 divide 0E-92 777E-1 -> 0E-91 +divx357 divide 0E-92 777E+1 -> 0E-93 +divx358 divide 0E-92 777E+3 -> 0E-95 +divx359 divide 0E-92 777E+4 -> 0E-96 +divx360 divide 0E-92 777E+5 -> 0E-97 +divx361 divide 0E-92 777E+6 -> 0E-98 +divx362 divide 0E-92 777E+7 -> 0E-98 Clamped +divx363 divide 0E-92 7E+92 -> 0E-98 Clamped + +divx371 divide 0E-92 700E-1 -> 0E-91 +divx372 divide 0E-92 700E+1 -> 0E-93 +divx373 divide 0E-92 700E+3 -> 0E-95 +divx374 divide 0E-92 700E+4 -> 0E-96 +divx375 divide 0E-92 700E+5 -> 0E-97 +divx376 divide 0E-92 700E+6 -> 0E-98 +divx377 divide 0E-92 700E+7 -> 0E-98 Clamped + +divx381 divide 0E+92 7E+1 -> 0E+91 +divx382 divide 0E+92 7E+0 -> 0E+92 +divx383 divide 0E+92 7E-1 -> 0E+92 Clamped +divx384 divide 0E+90 777E+1 -> 0E+89 +divx385 divide 0E+90 777E-1 -> 0E+91 +divx386 divide 0E+90 777E-2 -> 0E+92 +divx387 divide 0E+90 777E-3 -> 0E+92 Clamped +divx388 divide 0E+90 777E-4 -> 0E+92 Clamped + +divx391 divide 0E+90 700E+1 -> 0E+89 +divx392 divide 0E+90 700E-1 -> 0E+91 +divx393 divide 0E+90 700E-2 -> 0E+92 +divx394 divide 0E+90 700E-3 -> 0E+92 Clamped +divx395 divide 0E+90 700E-4 -> 0E+92 Clamped + +-- input rounding checks +maxexponent: 999 +minexponent: -999 +precision: 9 +divx401 divide 12345678000 1 -> 1.23456780E+10 Rounded +divx402 divide 1 12345678000 -> 8.10000066E-11 Inexact Rounded +divx403 divide 1234567800 1 -> 1.23456780E+9 Rounded +divx404 divide 1 1234567800 -> 8.10000066E-10 Inexact Rounded +divx405 divide 1234567890 1 -> 1.23456789E+9 Rounded +divx406 divide 1 1234567890 -> 8.10000007E-10 Inexact Rounded +divx407 divide 1234567891 1 -> 1.23456789E+9 Inexact Rounded +divx408 divide 1 1234567891 -> 8.10000007E-10 Inexact Rounded +divx409 divide 12345678901 1 -> 1.23456789E+10 Inexact Rounded +divx410 divide 1 12345678901 -> 8.10000007E-11 Inexact Rounded +divx411 divide 1234567896 1 -> 1.23456790E+9 Inexact Rounded +divx412 divide 1 1234567896 -> 8.10000003E-10 Inexact Rounded +divx413 divide 1 1234567897 -> 8.10000003E-10 Inexact Rounded +divx414 divide 1 1234567898 -> 8.10000002E-10 Inexact Rounded +divx415 divide 1 1234567899 -> 8.10000001E-10 Inexact Rounded +divx416 divide 1 1234567900 -> 8.10000001E-10 Inexact Rounded +divx417 divide 1 1234567901 -> 8.10000000E-10 Inexact Rounded +divx418 divide 1 1234567902 -> 8.09999999E-10 Inexact Rounded +-- some longies +divx421 divide 1234567896.000000000000 1 -> 1.23456790E+9 Inexact Rounded +divx422 divide 1 1234567896.000000000000 -> 8.10000003E-10 Inexact Rounded +divx423 divide 1234567896.000000000001 1 -> 1.23456790E+9 Inexact Rounded +divx424 divide 1 1234567896.000000000001 -> 8.10000003E-10 Inexact Rounded +divx425 divide 1234567896.000000000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded +divx426 divide 1 1234567896.000000000000000000000000000000000000000009 -> 8.10000003E-10 Inexact Rounded +divx427 divide 1234567897.900010000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded +divx428 divide 1 1234567897.900010000000000000000000000000000000000009 -> 8.10000002E-10 Inexact Rounded + +precision: 15 +-- still checking... +divx441 divide 12345678000 1 -> 12345678000 +divx442 divide 1 12345678000 -> 8.10000066420005E-11 Inexact Rounded +divx443 divide 1234567800 1 -> 1234567800 +divx444 divide 1 1234567800 -> 8.10000066420005E-10 Inexact Rounded +divx445 divide 1234567890 1 -> 1234567890 +divx446 divide 1 1234567890 -> 8.10000007371000E-10 Inexact Rounded +divx447 divide 1234567891 1 -> 1234567891 +divx448 divide 1 1234567891 -> 8.10000006714900E-10 Inexact Rounded +divx449 divide 12345678901 1 -> 12345678901 +divx450 divide 1 12345678901 -> 8.10000007305390E-11 Inexact Rounded +divx451 divide 1234567896 1 -> 1234567896 +divx452 divide 1 1234567896 -> 8.10000003434400E-10 Inexact Rounded + +-- high-lows +divx453 divide 1e+1 1 -> 1E+1 +divx454 divide 1e+1 1.0 -> 1E+1 +divx455 divide 1e+1 1.00 -> 1E+1 +divx456 divide 1e+2 2 -> 5E+1 +divx457 divide 1e+2 2.0 -> 5E+1 +divx458 divide 1e+2 2.00 -> 5E+1 + +-- some from IEEE discussions +divx460 divide 3e0 2e0 -> 1.5 +divx461 divide 30e-1 2e0 -> 1.5 +divx462 divide 300e-2 2e0 -> 1.50 +divx464 divide 3000e-3 2e0 -> 1.500 +divx465 divide 3e0 20e-1 -> 1.5 +divx466 divide 30e-1 20e-1 -> 1.5 +divx467 divide 300e-2 20e-1 -> 1.5 +divx468 divide 3000e-3 20e-1 -> 1.50 +divx469 divide 3e0 200e-2 -> 1.5 +divx470 divide 30e-1 200e-2 -> 1.5 +divx471 divide 300e-2 200e-2 -> 1.5 +divx472 divide 3000e-3 200e-2 -> 1.5 +divx473 divide 3e0 2000e-3 -> 1.5 +divx474 divide 30e-1 2000e-3 -> 1.5 +divx475 divide 300e-2 2000e-3 -> 1.5 +divx476 divide 3000e-3 2000e-3 -> 1.5 + +-- some reciprocals +divx480 divide 1 1.0E+33 -> 1E-33 +divx481 divide 1 10E+33 -> 1E-34 +divx482 divide 1 1.0E-33 -> 1E+33 +divx483 divide 1 10E-33 -> 1E+32 + +-- RMS discussion table +maxexponent: 96 +minexponent: -95 +precision: 7 + +divx484 divide 0e5 1e3 -> 0E+2 +divx485 divide 0e5 2e3 -> 0E+2 +divx486 divide 0e5 10e2 -> 0E+3 +divx487 divide 0e5 20e2 -> 0E+3 +divx488 divide 0e5 100e1 -> 0E+4 +divx489 divide 0e5 200e1 -> 0E+4 + +divx491 divide 1e5 1e3 -> 1E+2 +divx492 divide 1e5 2e3 -> 5E+1 +divx493 divide 1e5 10e2 -> 1E+2 +divx494 divide 1e5 20e2 -> 5E+1 +divx495 divide 1e5 100e1 -> 1E+2 +divx496 divide 1e5 200e1 -> 5E+1 + +-- tryzeros cases +precision: 7 +rounding: half_up +maxExponent: 92 +minexponent: -92 +divx497 divide 0E+86 1000E-13 -> 0E+92 Clamped +divx498 divide 0E-98 1000E+13 -> 0E-98 Clamped + +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- focus on trailing zeros issues +precision: 9 +divx500 divide 1 9.9 -> 0.101010101 Inexact Rounded +precision: 8 +divx501 divide 1 9.9 -> 0.10101010 Inexact Rounded +precision: 7 +divx502 divide 1 9.9 -> 0.1010101 Inexact Rounded +precision: 6 +divx503 divide 1 9.9 -> 0.101010 Inexact Rounded +precision: 9 + +divx511 divide 1 2 -> 0.5 +divx512 divide 1.0 2 -> 0.5 +divx513 divide 1.00 2 -> 0.50 +divx514 divide 1.000 2 -> 0.500 +divx515 divide 1.0000 2 -> 0.5000 +divx516 divide 1.00000 2 -> 0.50000 +divx517 divide 1.000000 2 -> 0.500000 +divx518 divide 1.0000000 2 -> 0.5000000 +divx519 divide 1.00 2.00 -> 0.5 + +divx521 divide 2 1 -> 2 +divx522 divide 2 1.0 -> 2 +divx523 divide 2 1.00 -> 2 +divx524 divide 2 1.000 -> 2 +divx525 divide 2 1.0000 -> 2 +divx526 divide 2 1.00000 -> 2 +divx527 divide 2 1.000000 -> 2 +divx528 divide 2 1.0000000 -> 2 +divx529 divide 2.00 1.00 -> 2 + +divx530 divide 2.40 2 -> 1.20 +divx531 divide 2.40 4 -> 0.60 +divx532 divide 2.40 10 -> 0.24 +divx533 divide 2.40 2.0 -> 1.2 +divx534 divide 2.40 4.0 -> 0.6 +divx535 divide 2.40 10.0 -> 0.24 +divx536 divide 2.40 2.00 -> 1.2 +divx537 divide 2.40 4.00 -> 0.6 +divx538 divide 2.40 10.00 -> 0.24 +divx539 divide 0.9 0.1 -> 9 +divx540 divide 0.9 0.01 -> 9E+1 +divx541 divide 0.9 0.001 -> 9E+2 +divx542 divide 5 2 -> 2.5 +divx543 divide 5 2.0 -> 2.5 +divx544 divide 5 2.00 -> 2.5 +divx545 divide 5 20 -> 0.25 +divx546 divide 5 20.0 -> 0.25 +divx547 divide 2.400 2 -> 1.200 +divx548 divide 2.400 2.0 -> 1.20 +divx549 divide 2.400 2.400 -> 1 + +divx550 divide 240 1 -> 240 +divx551 divide 240 10 -> 24 +divx552 divide 240 100 -> 2.4 +divx553 divide 240 1000 -> 0.24 +divx554 divide 2400 1 -> 2400 +divx555 divide 2400 10 -> 240 +divx556 divide 2400 100 -> 24 +divx557 divide 2400 1000 -> 2.4 + +-- +ve exponent +precision: 5 +divx570 divide 2.4E+6 2 -> 1.2E+6 +divx571 divide 2.40E+6 2 -> 1.20E+6 +divx572 divide 2.400E+6 2 -> 1.200E+6 +divx573 divide 2.4000E+6 2 -> 1.2000E+6 +divx574 divide 24E+5 2 -> 1.2E+6 +divx575 divide 240E+4 2 -> 1.20E+6 +divx576 divide 2400E+3 2 -> 1.200E+6 +divx577 divide 24000E+2 2 -> 1.2000E+6 +precision: 6 +divx580 divide 2.4E+6 2 -> 1.2E+6 +divx581 divide 2.40E+6 2 -> 1.20E+6 +divx582 divide 2.400E+6 2 -> 1.200E+6 +divx583 divide 2.4000E+6 2 -> 1.2000E+6 +divx584 divide 24E+5 2 -> 1.2E+6 +divx585 divide 240E+4 2 -> 1.20E+6 +divx586 divide 2400E+3 2 -> 1.200E+6 +divx587 divide 24000E+2 2 -> 1.2000E+6 +precision: 7 +divx590 divide 2.4E+6 2 -> 1.2E+6 +divx591 divide 2.40E+6 2 -> 1.20E+6 +divx592 divide 2.400E+6 2 -> 1.200E+6 +divx593 divide 2.4000E+6 2 -> 1.2000E+6 +divx594 divide 24E+5 2 -> 1.2E+6 +divx595 divide 240E+4 2 -> 1.20E+6 +divx596 divide 2400E+3 2 -> 1.200E+6 +divx597 divide 24000E+2 2 -> 1.2000E+6 +precision: 9 +divx600 divide 2.4E+9 2 -> 1.2E+9 +divx601 divide 2.40E+9 2 -> 1.20E+9 +divx602 divide 2.400E+9 2 -> 1.200E+9 +divx603 divide 2.4000E+9 2 -> 1.2000E+9 +divx604 divide 24E+8 2 -> 1.2E+9 +divx605 divide 240E+7 2 -> 1.20E+9 +divx606 divide 2400E+6 2 -> 1.200E+9 +divx607 divide 24000E+5 2 -> 1.2000E+9 + +-- long operand triangle +precision: 33 +divx610 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097703792 Inexact Rounded +precision: 32 +divx611 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770379 Inexact Rounded +precision: 31 +divx612 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977038 Inexact Rounded +precision: 30 +divx613 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097704 Inexact Rounded +precision: 29 +divx614 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770 Inexact Rounded +precision: 28 +divx615 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977 Inexact Rounded +precision: 27 +divx616 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131098 Inexact Rounded +precision: 26 +divx617 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813110 Inexact Rounded +precision: 25 +divx618 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81311 Inexact Rounded +precision: 24 +divx619 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131 Inexact Rounded +precision: 23 +divx620 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813 Inexact Rounded +precision: 22 +divx621 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81 Inexact Rounded +precision: 21 +divx622 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8 Inexact Rounded +precision: 20 +divx623 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817798 Inexact Rounded +precision: 19 +divx624 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379681780E+19 Inexact Rounded +precision: 18 +divx625 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968178E+19 Inexact Rounded +precision: 17 +divx626 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883796818E+19 Inexact Rounded +precision: 16 +divx627 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379682E+19 Inexact Rounded +precision: 15 +divx628 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968E+19 Inexact Rounded +precision: 14 +divx629 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883797E+19 Inexact Rounded +precision: 13 +divx630 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888380E+19 Inexact Rounded +precision: 12 +divx631 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088838E+19 Inexact Rounded +precision: 11 +divx632 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408884E+19 Inexact Rounded +precision: 10 +divx633 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888E+19 Inexact Rounded +precision: 9 +divx634 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114089E+19 Inexact Rounded +precision: 8 +divx635 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011409E+19 Inexact Rounded +precision: 7 +divx636 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101141E+19 Inexact Rounded +precision: 6 +divx637 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114E+19 Inexact Rounded +precision: 5 +divx638 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011E+19 Inexact Rounded +precision: 4 +divx639 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101E+19 Inexact Rounded +precision: 3 +divx640 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10E+19 Inexact Rounded +precision: 2 +divx641 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1E+19 Inexact Rounded +precision: 1 +divx642 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4E+19 Inexact Rounded + +-- more zeros, etc. +precision: 16 +rounding: half_up +maxExponent: 384 +minExponent: -383 + +divx731 divide 5.00 1E-3 -> 5.00E+3 +divx732 divide 00.00 0.000 -> NaN Division_undefined +divx733 divide 00.00 0E-3 -> NaN Division_undefined +divx734 divide 0 -0 -> NaN Division_undefined +divx735 divide -0 0 -> NaN Division_undefined +divx736 divide -0 -0 -> NaN Division_undefined + +divx741 divide 0 -1 -> -0 +divx742 divide -0 -1 -> 0 +divx743 divide 0 1 -> 0 +divx744 divide -0 1 -> -0 +divx745 divide -1 0 -> -Infinity Division_by_zero +divx746 divide -1 -0 -> Infinity Division_by_zero +divx747 divide 1 0 -> Infinity Division_by_zero +divx748 divide 1 -0 -> -Infinity Division_by_zero + +divx751 divide 0.0 -1 -> -0.0 +divx752 divide -0.0 -1 -> 0.0 +divx753 divide 0.0 1 -> 0.0 +divx754 divide -0.0 1 -> -0.0 +divx755 divide -1.0 0 -> -Infinity Division_by_zero +divx756 divide -1.0 -0 -> Infinity Division_by_zero +divx757 divide 1.0 0 -> Infinity Division_by_zero +divx758 divide 1.0 -0 -> -Infinity Division_by_zero + +divx761 divide 0 -1.0 -> -0E+1 +divx762 divide -0 -1.0 -> 0E+1 +divx763 divide 0 1.0 -> 0E+1 +divx764 divide -0 1.0 -> -0E+1 +divx765 divide -1 0.0 -> -Infinity Division_by_zero +divx766 divide -1 -0.0 -> Infinity Division_by_zero +divx767 divide 1 0.0 -> Infinity Division_by_zero +divx768 divide 1 -0.0 -> -Infinity Division_by_zero + +divx771 divide 0.0 -1.0 -> -0 +divx772 divide -0.0 -1.0 -> 0 +divx773 divide 0.0 1.0 -> 0 +divx774 divide -0.0 1.0 -> -0 +divx775 divide -1.0 0.0 -> -Infinity Division_by_zero +divx776 divide -1.0 -0.0 -> Infinity Division_by_zero +divx777 divide 1.0 0.0 -> Infinity Division_by_zero +divx778 divide 1.0 -0.0 -> -Infinity Division_by_zero + +-- Specials +divx780 divide Inf -Inf -> NaN Invalid_operation +divx781 divide Inf -1000 -> -Infinity +divx782 divide Inf -1 -> -Infinity +divx783 divide Inf -0 -> -Infinity +divx784 divide Inf 0 -> Infinity +divx785 divide Inf 1 -> Infinity +divx786 divide Inf 1000 -> Infinity +divx787 divide Inf Inf -> NaN Invalid_operation +divx788 divide -1000 Inf -> -0E-398 Clamped +divx789 divide -Inf Inf -> NaN Invalid_operation +divx790 divide -1 Inf -> -0E-398 Clamped +divx791 divide -0 Inf -> -0E-398 Clamped +divx792 divide 0 Inf -> 0E-398 Clamped +divx793 divide 1 Inf -> 0E-398 Clamped +divx794 divide 1000 Inf -> 0E-398 Clamped +divx795 divide Inf Inf -> NaN Invalid_operation + +divx800 divide -Inf -Inf -> NaN Invalid_operation +divx801 divide -Inf -1000 -> Infinity +divx802 divide -Inf -1 -> Infinity +divx803 divide -Inf -0 -> Infinity +divx804 divide -Inf 0 -> -Infinity +divx805 divide -Inf 1 -> -Infinity +divx806 divide -Inf 1000 -> -Infinity +divx807 divide -Inf Inf -> NaN Invalid_operation +divx808 divide -1000 Inf -> -0E-398 Clamped +divx809 divide -Inf -Inf -> NaN Invalid_operation +divx810 divide -1 -Inf -> 0E-398 Clamped +divx811 divide -0 -Inf -> 0E-398 Clamped +divx812 divide 0 -Inf -> -0E-398 Clamped +divx813 divide 1 -Inf -> -0E-398 Clamped +divx814 divide 1000 -Inf -> -0E-398 Clamped +divx815 divide Inf -Inf -> NaN Invalid_operation + +divx821 divide NaN -Inf -> NaN +divx822 divide NaN -1000 -> NaN +divx823 divide NaN -1 -> NaN +divx824 divide NaN -0 -> NaN +divx825 divide NaN 0 -> NaN +divx826 divide NaN 1 -> NaN +divx827 divide NaN 1000 -> NaN +divx828 divide NaN Inf -> NaN +divx829 divide NaN NaN -> NaN +divx830 divide -Inf NaN -> NaN +divx831 divide -1000 NaN -> NaN +divx832 divide -1 NaN -> NaN +divx833 divide -0 NaN -> NaN +divx834 divide 0 NaN -> NaN +divx835 divide 1 NaN -> NaN +divx836 divide 1000 NaN -> NaN +divx837 divide Inf NaN -> NaN + +divx841 divide sNaN -Inf -> NaN Invalid_operation +divx842 divide sNaN -1000 -> NaN Invalid_operation +divx843 divide sNaN -1 -> NaN Invalid_operation +divx844 divide sNaN -0 -> NaN Invalid_operation +divx845 divide sNaN 0 -> NaN Invalid_operation +divx846 divide sNaN 1 -> NaN Invalid_operation +divx847 divide sNaN 1000 -> NaN Invalid_operation +divx848 divide sNaN NaN -> NaN Invalid_operation +divx849 divide sNaN sNaN -> NaN Invalid_operation +divx850 divide NaN sNaN -> NaN Invalid_operation +divx851 divide -Inf sNaN -> NaN Invalid_operation +divx852 divide -1000 sNaN -> NaN Invalid_operation +divx853 divide -1 sNaN -> NaN Invalid_operation +divx854 divide -0 sNaN -> NaN Invalid_operation +divx855 divide 0 sNaN -> NaN Invalid_operation +divx856 divide 1 sNaN -> NaN Invalid_operation +divx857 divide 1000 sNaN -> NaN Invalid_operation +divx858 divide Inf sNaN -> NaN Invalid_operation +divx859 divide NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +divx861 divide NaN9 -Inf -> NaN9 +divx862 divide NaN8 1000 -> NaN8 +divx863 divide NaN7 Inf -> NaN7 +divx864 divide NaN6 NaN5 -> NaN6 +divx865 divide -Inf NaN4 -> NaN4 +divx866 divide -1000 NaN3 -> NaN3 +divx867 divide Inf NaN2 -> NaN2 + +divx871 divide sNaN99 -Inf -> NaN99 Invalid_operation +divx872 divide sNaN98 -1 -> NaN98 Invalid_operation +divx873 divide sNaN97 NaN -> NaN97 Invalid_operation +divx874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation +divx875 divide NaN95 sNaN93 -> NaN93 Invalid_operation +divx876 divide -Inf sNaN92 -> NaN92 Invalid_operation +divx877 divide 0 sNaN91 -> NaN91 Invalid_operation +divx878 divide Inf sNaN90 -> NaN90 Invalid_operation +divx879 divide NaN sNaN89 -> NaN89 Invalid_operation + +divx881 divide -NaN9 -Inf -> -NaN9 +divx882 divide -NaN8 1000 -> -NaN8 +divx883 divide -NaN7 Inf -> -NaN7 +divx884 divide -NaN6 -NaN5 -> -NaN6 +divx885 divide -Inf -NaN4 -> -NaN4 +divx886 divide -1000 -NaN3 -> -NaN3 +divx887 divide Inf -NaN2 -> -NaN2 + +divx891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation +divx892 divide -sNaN98 -1 -> -NaN98 Invalid_operation +divx893 divide -sNaN97 NaN -> -NaN97 Invalid_operation +divx894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation +divx895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation +divx896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation +divx897 divide 0 -sNaN91 -> -NaN91 Invalid_operation +divx898 divide Inf -sNaN90 -> -NaN90 Invalid_operation +divx899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation + +maxexponent: 999999999 +minexponent: -999999999 + +-- Various flavours of divide by 0 +divx901 divide 0 0 -> NaN Division_undefined +divx902 divide 0.0E5 0 -> NaN Division_undefined +divx903 divide 0.000 0 -> NaN Division_undefined +divx904 divide 0.0001 0 -> Infinity Division_by_zero +divx905 divide 0.01 0 -> Infinity Division_by_zero +divx906 divide 0.1 0 -> Infinity Division_by_zero +divx907 divide 1 0 -> Infinity Division_by_zero +divx908 divide 1 0.0 -> Infinity Division_by_zero +divx909 divide 10 0.0 -> Infinity Division_by_zero +divx910 divide 1E+100 0.0 -> Infinity Division_by_zero +divx911 divide 1E+1000 0 -> Infinity Division_by_zero + +divx921 divide -0.0001 0 -> -Infinity Division_by_zero +divx922 divide -0.01 0 -> -Infinity Division_by_zero +divx923 divide -0.1 0 -> -Infinity Division_by_zero +divx924 divide -1 0 -> -Infinity Division_by_zero +divx925 divide -1 0.0 -> -Infinity Division_by_zero +divx926 divide -10 0.0 -> -Infinity Division_by_zero +divx927 divide -1E+100 0.0 -> -Infinity Division_by_zero +divx928 divide -1E+1000 0 -> -Infinity Division_by_zero + +divx931 divide 0.0001 -0 -> -Infinity Division_by_zero +divx932 divide 0.01 -0 -> -Infinity Division_by_zero +divx933 divide 0.1 -0 -> -Infinity Division_by_zero +divx934 divide 1 -0 -> -Infinity Division_by_zero +divx935 divide 1 -0.0 -> -Infinity Division_by_zero +divx936 divide 10 -0.0 -> -Infinity Division_by_zero +divx937 divide 1E+100 -0.0 -> -Infinity Division_by_zero +divx938 divide 1E+1000 -0 -> -Infinity Division_by_zero + +divx941 divide -0.0001 -0 -> Infinity Division_by_zero +divx942 divide -0.01 -0 -> Infinity Division_by_zero +divx943 divide -0.1 -0 -> Infinity Division_by_zero +divx944 divide -1 -0 -> Infinity Division_by_zero +divx945 divide -1 -0.0 -> Infinity Division_by_zero +divx946 divide -10 -0.0 -> Infinity Division_by_zero +divx947 divide -1E+100 -0.0 -> Infinity Division_by_zero +divx948 divide -1E+1000 -0 -> Infinity Division_by_zero + +-- overflow and underflow tests +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +divx951 divide 9E+999999999 +0.23456789012345E-0 -> Infinity Inexact Overflow Rounded +divx952 divide +0.100 9E+999999999 -> 1.111111E-1000000001 Inexact Rounded Underflow Subnormal +divx953 divide 9E-999999999 +9.100 -> 9.8901099E-1000000000 Inexact Rounded Underflow Subnormal +divx954 divide -1.23456789 9E+999999999 -> -1.3717421E-1000000000 Subnormal +divx955 divide -1.23456789012345E-0 9E+999999999 -> -1.3717421E-1000000000 Underflow Subnormal Rounded Inexact +divx956 divide -1.23456789012345E-0 7E+999999999 -> -1.7636684E-1000000000 Inexact Rounded Underflow Subnormal +divx957 divide 9E+999999999 -0.83456789012345E-0 -> -Infinity Inexact Overflow Rounded +divx958 divide -0.100 9E+999999999 -> -1.111111E-1000000001 Subnormal Inexact Rounded Underflow +divx959 divide 9E-999999999 -9.100 -> -9.8901099E-1000000000 Inexact Rounded Underflow Subnormal + +-- overflow and underflow (additional edge tests in multiply.decTest) +-- 'subnormal' results now possible (all hard underflow or overflow in +-- base arithemtic) +divx960 divide 1e-600000000 1e+400000001 -> 1E-1000000001 Subnormal +divx961 divide 1e-600000000 1e+400000002 -> 1E-1000000002 Subnormal +divx962 divide 1e-600000000 1e+400000003 -> 1E-1000000003 Subnormal +divx963 divide 1e-600000000 1e+400000004 -> 1E-1000000004 Subnormal +divx964 divide 1e-600000000 1e+400000005 -> 1E-1000000005 Subnormal +divx965 divide 1e-600000000 1e+400000006 -> 1E-1000000006 Subnormal +divx966 divide 1e-600000000 1e+400000007 -> 1E-1000000007 Subnormal +divx967 divide 1e-600000000 1e+400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +divx968 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +divx969 divide 1e-600000000 1e+400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +-- [no equivalent of 'subnormal' for overflow] +divx970 divide 1e+600000000 1e-400000001 -> Infinity Overflow Inexact Rounded +divx971 divide 1e+600000000 1e-400000002 -> Infinity Overflow Inexact Rounded +divx972 divide 1e+600000000 1e-400000003 -> Infinity Overflow Inexact Rounded +divx973 divide 1e+600000000 1e-400000004 -> Infinity Overflow Inexact Rounded +divx974 divide 1e+600000000 1e-400000005 -> Infinity Overflow Inexact Rounded +divx975 divide 1e+600000000 1e-400000006 -> Infinity Overflow Inexact Rounded +divx976 divide 1e+600000000 1e-400000007 -> Infinity Overflow Inexact Rounded +divx977 divide 1e+600000000 1e-400000008 -> Infinity Overflow Inexact Rounded +divx978 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded +divx979 divide 1e+600000000 1e-400000010 -> Infinity Overflow Inexact Rounded + +-- Sign after overflow and underflow +divx980 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +divx981 divide 1e-600000000 -1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +divx982 divide -1e-600000000 1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +divx983 divide -1e-600000000 -1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +divx984 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded +divx985 divide 1e+600000000 -1e-400000009 -> -Infinity Overflow Inexact Rounded +divx986 divide -1e+600000000 1e-400000009 -> -Infinity Overflow Inexact Rounded +divx987 divide -1e+600000000 -1e-400000009 -> Infinity Overflow Inexact Rounded + +-- Long operand overflow may be a different path +precision: 3 +divx990 divide 1000 9.999E-999999999 -> Infinity Inexact Overflow Rounded +divx991 divide 1000 -9.999E-999999999 -> -Infinity Inexact Overflow Rounded +divx992 divide 9.999E+999999999 0.01 -> Infinity Inexact Overflow Rounded +divx993 divide -9.999E+999999999 0.01 -> -Infinity Inexact Overflow Rounded + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +divx1001 divide 1.52444E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow +divx1002 divide 1.52445E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow +divx1003 divide 1.52446E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow + +-- a rounding problem in one implementation +precision: 34 +rounding: half_up +maxExponent: 6144 +minExponent: -6143 +-- Unbounded answer to 40 digits: +-- 1.465811965811965811965811965811965811966E+7000 +divx1010 divide 343E6000 234E-1000 -> Infinity Overflow Inexact Rounded + +-- Null tests +divx9998 divide 10 # -> NaN Invalid_operation +divx9999 divide # 10 -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/divideint.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/divideint.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,470 @@ +------------------------------------------------------------------------ +-- divideint.decTest -- decimal integer division -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +dvix001 divideint 1 1 -> 1 +dvix002 divideint 2 1 -> 2 +dvix003 divideint 1 2 -> 0 +dvix004 divideint 2 2 -> 1 +dvix005 divideint 0 1 -> 0 +dvix006 divideint 0 2 -> 0 +dvix007 divideint 1 3 -> 0 +dvix008 divideint 2 3 -> 0 +dvix009 divideint 3 3 -> 1 + +dvix010 divideint 2.4 1 -> 2 +dvix011 divideint 2.4 -1 -> -2 +dvix012 divideint -2.4 1 -> -2 +dvix013 divideint -2.4 -1 -> 2 +dvix014 divideint 2.40 1 -> 2 +dvix015 divideint 2.400 1 -> 2 +dvix016 divideint 2.4 2 -> 1 +dvix017 divideint 2.400 2 -> 1 +dvix018 divideint 2. 2 -> 1 +dvix019 divideint 20 20 -> 1 + +dvix020 divideint 187 187 -> 1 +dvix021 divideint 5 2 -> 2 +dvix022 divideint 5 2.0 -> 2 +dvix023 divideint 5 2.000 -> 2 +dvix024 divideint 5 0.200 -> 25 +dvix025 divideint 5 0.200 -> 25 + +dvix030 divideint 1 2 -> 0 +dvix031 divideint 1 4 -> 0 +dvix032 divideint 1 8 -> 0 +dvix033 divideint 1 16 -> 0 +dvix034 divideint 1 32 -> 0 +dvix035 divideint 1 64 -> 0 +dvix040 divideint 1 -2 -> -0 +dvix041 divideint 1 -4 -> -0 +dvix042 divideint 1 -8 -> -0 +dvix043 divideint 1 -16 -> -0 +dvix044 divideint 1 -32 -> -0 +dvix045 divideint 1 -64 -> -0 +dvix050 divideint -1 2 -> -0 +dvix051 divideint -1 4 -> -0 +dvix052 divideint -1 8 -> -0 +dvix053 divideint -1 16 -> -0 +dvix054 divideint -1 32 -> -0 +dvix055 divideint -1 64 -> -0 +dvix060 divideint -1 -2 -> 0 +dvix061 divideint -1 -4 -> 0 +dvix062 divideint -1 -8 -> 0 +dvix063 divideint -1 -16 -> 0 +dvix064 divideint -1 -32 -> 0 +dvix065 divideint -1 -64 -> 0 + +-- similar with powers of ten +dvix160 divideint 1 1 -> 1 +dvix161 divideint 1 10 -> 0 +dvix162 divideint 1 100 -> 0 +dvix163 divideint 1 1000 -> 0 +dvix164 divideint 1 10000 -> 0 +dvix165 divideint 1 100000 -> 0 +dvix166 divideint 1 1000000 -> 0 +dvix167 divideint 1 10000000 -> 0 +dvix168 divideint 1 100000000 -> 0 +dvix170 divideint 1 -1 -> -1 +dvix171 divideint 1 -10 -> -0 +dvix172 divideint 1 -100 -> -0 +dvix173 divideint 1 -1000 -> -0 +dvix174 divideint 1 -10000 -> -0 +dvix175 divideint 1 -100000 -> -0 +dvix176 divideint 1 -1000000 -> -0 +dvix177 divideint 1 -10000000 -> -0 +dvix178 divideint 1 -100000000 -> -0 +dvix180 divideint -1 1 -> -1 +dvix181 divideint -1 10 -> -0 +dvix182 divideint -1 100 -> -0 +dvix183 divideint -1 1000 -> -0 +dvix184 divideint -1 10000 -> -0 +dvix185 divideint -1 100000 -> -0 +dvix186 divideint -1 1000000 -> -0 +dvix187 divideint -1 10000000 -> -0 +dvix188 divideint -1 100000000 -> -0 +dvix190 divideint -1 -1 -> 1 +dvix191 divideint -1 -10 -> 0 +dvix192 divideint -1 -100 -> 0 +dvix193 divideint -1 -1000 -> 0 +dvix194 divideint -1 -10000 -> 0 +dvix195 divideint -1 -100000 -> 0 +dvix196 divideint -1 -1000000 -> 0 +dvix197 divideint -1 -10000000 -> 0 +dvix198 divideint -1 -100000000 -> 0 + +-- some long operand cases here +dvix070 divideint 999999999 1 -> 999999999 +dvix071 divideint 999999999.4 1 -> 999999999 +dvix072 divideint 999999999.5 1 -> 999999999 +dvix073 divideint 999999999.9 1 -> 999999999 +dvix074 divideint 999999999.999 1 -> 999999999 +precision: 6 +dvix080 divideint 999999999 1 -> NaN Division_impossible +dvix081 divideint 99999999 1 -> NaN Division_impossible +dvix082 divideint 9999999 1 -> NaN Division_impossible +dvix083 divideint 999999 1 -> 999999 +dvix084 divideint 99999 1 -> 99999 +dvix085 divideint 9999 1 -> 9999 +dvix086 divideint 999 1 -> 999 +dvix087 divideint 99 1 -> 99 +dvix088 divideint 9 1 -> 9 + +precision: 9 +dvix090 divideint 0. 1 -> 0 +dvix091 divideint .0 1 -> 0 +dvix092 divideint 0.00 1 -> 0 +dvix093 divideint 0.00E+9 1 -> 0 +dvix094 divideint 0.0000E-50 1 -> 0 + +dvix100 divideint 1 1 -> 1 +dvix101 divideint 1 2 -> 0 +dvix102 divideint 1 3 -> 0 +dvix103 divideint 1 4 -> 0 +dvix104 divideint 1 5 -> 0 +dvix105 divideint 1 6 -> 0 +dvix106 divideint 1 7 -> 0 +dvix107 divideint 1 8 -> 0 +dvix108 divideint 1 9 -> 0 +dvix109 divideint 1 10 -> 0 +dvix110 divideint 1 1 -> 1 +dvix111 divideint 2 1 -> 2 +dvix112 divideint 3 1 -> 3 +dvix113 divideint 4 1 -> 4 +dvix114 divideint 5 1 -> 5 +dvix115 divideint 6 1 -> 6 +dvix116 divideint 7 1 -> 7 +dvix117 divideint 8 1 -> 8 +dvix118 divideint 9 1 -> 9 +dvix119 divideint 10 1 -> 10 + +-- from DiagBigDecimal +dvix131 divideint 101.3 1 -> 101 +dvix132 divideint 101.0 1 -> 101 +dvix133 divideint 101.3 3 -> 33 +dvix134 divideint 101.0 3 -> 33 +dvix135 divideint 2.4 1 -> 2 +dvix136 divideint 2.400 1 -> 2 +dvix137 divideint 18 18 -> 1 +dvix138 divideint 1120 1000 -> 1 +dvix139 divideint 2.4 2 -> 1 +dvix140 divideint 2.400 2 -> 1 +dvix141 divideint 0.5 2.000 -> 0 +dvix142 divideint 8.005 7 -> 1 +dvix143 divideint 5 2 -> 2 +dvix144 divideint 0 2 -> 0 +dvix145 divideint 0.00 2 -> 0 + +-- Others +dvix150 divideint 12345 4.999 -> 2469 +dvix151 divideint 12345 4.99 -> 2473 +dvix152 divideint 12345 4.9 -> 2519 +dvix153 divideint 12345 5 -> 2469 +dvix154 divideint 12345 5.1 -> 2420 +dvix155 divideint 12345 5.01 -> 2464 +dvix156 divideint 12345 5.001 -> 2468 +dvix157 divideint 101 7.6 -> 13 + +-- Various flavours of divideint by 0 +maxexponent: 999999999 +minexponent: -999999999 +dvix201 divideint 0 0 -> NaN Division_undefined +dvix202 divideint 0.0E5 0 -> NaN Division_undefined +dvix203 divideint 0.000 0 -> NaN Division_undefined +dvix204 divideint 0.0001 0 -> Infinity Division_by_zero +dvix205 divideint 0.01 0 -> Infinity Division_by_zero +dvix206 divideint 0.1 0 -> Infinity Division_by_zero +dvix207 divideint 1 0 -> Infinity Division_by_zero +dvix208 divideint 1 0.0 -> Infinity Division_by_zero +dvix209 divideint 10 0.0 -> Infinity Division_by_zero +dvix210 divideint 1E+100 0.0 -> Infinity Division_by_zero +dvix211 divideint 1E+1000 0 -> Infinity Division_by_zero +dvix214 divideint -0.0001 0 -> -Infinity Division_by_zero +dvix215 divideint -0.01 0 -> -Infinity Division_by_zero +dvix216 divideint -0.1 0 -> -Infinity Division_by_zero +dvix217 divideint -1 0 -> -Infinity Division_by_zero +dvix218 divideint -1 0.0 -> -Infinity Division_by_zero +dvix219 divideint -10 0.0 -> -Infinity Division_by_zero +dvix220 divideint -1E+100 0.0 -> -Infinity Division_by_zero +dvix221 divideint -1E+1000 0 -> -Infinity Division_by_zero + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +dvix270 divideint 1 1e999999999 -> 0 +dvix271 divideint 1 0.9e999999999 -> 0 +dvix272 divideint 1 0.99e999999999 -> 0 +dvix273 divideint 1 0.999999999e999999999 -> 0 +dvix274 divideint 9e999999999 1 -> NaN Division_impossible +dvix275 divideint 9.9e999999999 1 -> NaN Division_impossible +dvix276 divideint 9.99e999999999 1 -> NaN Division_impossible +dvix277 divideint 9.99999999e999999999 1 -> NaN Division_impossible + +dvix280 divideint 0.1 9e-999999999 -> NaN Division_impossible +dvix281 divideint 0.1 99e-999999999 -> NaN Division_impossible +dvix282 divideint 0.1 999e-999999999 -> NaN Division_impossible + +dvix283 divideint 0.1 9e-999999998 -> NaN Division_impossible +dvix284 divideint 0.1 99e-999999998 -> NaN Division_impossible +dvix285 divideint 0.1 999e-999999998 -> NaN Division_impossible +dvix286 divideint 0.1 999e-999999997 -> NaN Division_impossible +dvix287 divideint 0.1 9999e-999999997 -> NaN Division_impossible +dvix288 divideint 0.1 99999e-999999997 -> NaN Division_impossible + + +-- overflow and underflow tests [from divide] +maxexponent: 999999999 +minexponent: -999999999 +dvix330 divideint +1.23456789012345E-0 9E+999999999 -> 0 +dvix331 divideint 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible +dvix332 divideint +0.100 9E+999999999 -> 0 +dvix333 divideint 9E-999999999 +9.100 -> 0 +dvix335 divideint -1.23456789012345E-0 9E+999999999 -> -0 +dvix336 divideint 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible +dvix337 divideint -0.100 9E+999999999 -> -0 +dvix338 divideint 9E-999999999 -9.100 -> -0 + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +dvix401 divideint 12345678000 100 -> 123456780 +dvix402 divideint 1 12345678000 -> 0 +dvix403 divideint 1234567800 10 -> 123456780 +dvix404 divideint 1 1234567800 -> 0 +dvix405 divideint 1234567890 10 -> 123456789 +dvix406 divideint 1 1234567890 -> 0 +dvix407 divideint 1234567891 10 -> 123456789 +dvix408 divideint 1 1234567891 -> 0 +dvix409 divideint 12345678901 100 -> 123456789 +dvix410 divideint 1 12345678901 -> 0 +dvix411 divideint 1234567896 10 -> 123456789 +dvix412 divideint 1 1234567896 -> 0 +dvix413 divideint 12345678948 100 -> 123456789 +dvix414 divideint 12345678949 100 -> 123456789 +dvix415 divideint 12345678950 100 -> 123456789 +dvix416 divideint 12345678951 100 -> 123456789 +dvix417 divideint 12345678999 100 -> 123456789 + +precision: 15 +dvix441 divideint 12345678000 1 -> 12345678000 +dvix442 divideint 1 12345678000 -> 0 +dvix443 divideint 1234567800 1 -> 1234567800 +dvix444 divideint 1 1234567800 -> 0 +dvix445 divideint 1234567890 1 -> 1234567890 +dvix446 divideint 1 1234567890 -> 0 +dvix447 divideint 1234567891 1 -> 1234567891 +dvix448 divideint 1 1234567891 -> 0 +dvix449 divideint 12345678901 1 -> 12345678901 +dvix450 divideint 1 12345678901 -> 0 +dvix451 divideint 1234567896 1 -> 1234567896 +dvix452 divideint 1 1234567896 -> 0 + +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- more zeros, etc. +dvix531 divideint 5.00 1E-3 -> 5000 +dvix532 divideint 00.00 0.000 -> NaN Division_undefined +dvix533 divideint 00.00 0E-3 -> NaN Division_undefined +dvix534 divideint 0 -0 -> NaN Division_undefined +dvix535 divideint -0 0 -> NaN Division_undefined +dvix536 divideint -0 -0 -> NaN Division_undefined + +dvix541 divideint 0 -1 -> -0 +dvix542 divideint -0 -1 -> 0 +dvix543 divideint 0 1 -> 0 +dvix544 divideint -0 1 -> -0 +dvix545 divideint -1 0 -> -Infinity Division_by_zero +dvix546 divideint -1 -0 -> Infinity Division_by_zero +dvix547 divideint 1 0 -> Infinity Division_by_zero +dvix548 divideint 1 -0 -> -Infinity Division_by_zero + +dvix551 divideint 0.0 -1 -> -0 +dvix552 divideint -0.0 -1 -> 0 +dvix553 divideint 0.0 1 -> 0 +dvix554 divideint -0.0 1 -> -0 +dvix555 divideint -1.0 0 -> -Infinity Division_by_zero +dvix556 divideint -1.0 -0 -> Infinity Division_by_zero +dvix557 divideint 1.0 0 -> Infinity Division_by_zero +dvix558 divideint 1.0 -0 -> -Infinity Division_by_zero + +dvix561 divideint 0 -1.0 -> -0 +dvix562 divideint -0 -1.0 -> 0 +dvix563 divideint 0 1.0 -> 0 +dvix564 divideint -0 1.0 -> -0 +dvix565 divideint -1 0.0 -> -Infinity Division_by_zero +dvix566 divideint -1 -0.0 -> Infinity Division_by_zero +dvix567 divideint 1 0.0 -> Infinity Division_by_zero +dvix568 divideint 1 -0.0 -> -Infinity Division_by_zero + +dvix571 divideint 0.0 -1.0 -> -0 +dvix572 divideint -0.0 -1.0 -> 0 +dvix573 divideint 0.0 1.0 -> 0 +dvix574 divideint -0.0 1.0 -> -0 +dvix575 divideint -1.0 0.0 -> -Infinity Division_by_zero +dvix576 divideint -1.0 -0.0 -> Infinity Division_by_zero +dvix577 divideint 1.0 0.0 -> Infinity Division_by_zero +dvix578 divideint 1.0 -0.0 -> -Infinity Division_by_zero + +-- Specials +dvix580 divideint Inf -Inf -> NaN Invalid_operation +dvix581 divideint Inf -1000 -> -Infinity +dvix582 divideint Inf -1 -> -Infinity +dvix583 divideint Inf -0 -> -Infinity +dvix584 divideint Inf 0 -> Infinity +dvix585 divideint Inf 1 -> Infinity +dvix586 divideint Inf 1000 -> Infinity +dvix587 divideint Inf Inf -> NaN Invalid_operation +dvix588 divideint -1000 Inf -> -0 +dvix589 divideint -Inf Inf -> NaN Invalid_operation +dvix590 divideint -1 Inf -> -0 +dvix591 divideint -0 Inf -> -0 +dvix592 divideint 0 Inf -> 0 +dvix593 divideint 1 Inf -> 0 +dvix594 divideint 1000 Inf -> 0 +dvix595 divideint Inf Inf -> NaN Invalid_operation + +dvix600 divideint -Inf -Inf -> NaN Invalid_operation +dvix601 divideint -Inf -1000 -> Infinity +dvix602 divideint -Inf -1 -> Infinity +dvix603 divideint -Inf -0 -> Infinity +dvix604 divideint -Inf 0 -> -Infinity +dvix605 divideint -Inf 1 -> -Infinity +dvix606 divideint -Inf 1000 -> -Infinity +dvix607 divideint -Inf Inf -> NaN Invalid_operation +dvix608 divideint -1000 Inf -> -0 +dvix609 divideint -Inf -Inf -> NaN Invalid_operation +dvix610 divideint -1 -Inf -> 0 +dvix611 divideint -0 -Inf -> 0 +dvix612 divideint 0 -Inf -> -0 +dvix613 divideint 1 -Inf -> -0 +dvix614 divideint 1000 -Inf -> -0 +dvix615 divideint Inf -Inf -> NaN Invalid_operation + +dvix621 divideint NaN -Inf -> NaN +dvix622 divideint NaN -1000 -> NaN +dvix623 divideint NaN -1 -> NaN +dvix624 divideint NaN -0 -> NaN +dvix625 divideint NaN 0 -> NaN +dvix626 divideint NaN 1 -> NaN +dvix627 divideint NaN 1000 -> NaN +dvix628 divideint NaN Inf -> NaN +dvix629 divideint NaN NaN -> NaN +dvix630 divideint -Inf NaN -> NaN +dvix631 divideint -1000 NaN -> NaN +dvix632 divideint -1 NaN -> NaN +dvix633 divideint -0 NaN -> NaN +dvix634 divideint 0 NaN -> NaN +dvix635 divideint 1 NaN -> NaN +dvix636 divideint 1000 NaN -> NaN +dvix637 divideint Inf NaN -> NaN + +dvix641 divideint sNaN -Inf -> NaN Invalid_operation +dvix642 divideint sNaN -1000 -> NaN Invalid_operation +dvix643 divideint sNaN -1 -> NaN Invalid_operation +dvix644 divideint sNaN -0 -> NaN Invalid_operation +dvix645 divideint sNaN 0 -> NaN Invalid_operation +dvix646 divideint sNaN 1 -> NaN Invalid_operation +dvix647 divideint sNaN 1000 -> NaN Invalid_operation +dvix648 divideint sNaN NaN -> NaN Invalid_operation +dvix649 divideint sNaN sNaN -> NaN Invalid_operation +dvix650 divideint NaN sNaN -> NaN Invalid_operation +dvix651 divideint -Inf sNaN -> NaN Invalid_operation +dvix652 divideint -1000 sNaN -> NaN Invalid_operation +dvix653 divideint -1 sNaN -> NaN Invalid_operation +dvix654 divideint -0 sNaN -> NaN Invalid_operation +dvix655 divideint 0 sNaN -> NaN Invalid_operation +dvix656 divideint 1 sNaN -> NaN Invalid_operation +dvix657 divideint 1000 sNaN -> NaN Invalid_operation +dvix658 divideint Inf sNaN -> NaN Invalid_operation +dvix659 divideint NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +dvix661 divideint NaN9 -Inf -> NaN9 +dvix662 divideint NaN8 1000 -> NaN8 +dvix663 divideint NaN7 Inf -> NaN7 +dvix664 divideint -NaN6 NaN5 -> -NaN6 +dvix665 divideint -Inf NaN4 -> NaN4 +dvix666 divideint -1000 NaN3 -> NaN3 +dvix667 divideint Inf -NaN2 -> -NaN2 + +dvix671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation +dvix672 divideint sNaN98 -1 -> NaN98 Invalid_operation +dvix673 divideint sNaN97 NaN -> NaN97 Invalid_operation +dvix674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation +dvix675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation +dvix676 divideint -Inf sNaN92 -> NaN92 Invalid_operation +dvix677 divideint 0 sNaN91 -> NaN91 Invalid_operation +dvix678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation +dvix679 divideint NaN sNaN89 -> NaN89 Invalid_operation + +-- some long operand cases again +precision: 8 +dvix710 divideint 100000001 1 -> NaN Division_impossible +dvix711 divideint 100000000.4 1 -> NaN Division_impossible +dvix712 divideint 100000000.5 1 -> NaN Division_impossible +dvix713 divideint 100000000.9 1 -> NaN Division_impossible +dvix714 divideint 100000000.999 1 -> NaN Division_impossible +precision: 6 +dvix720 divideint 100000000 1 -> NaN Division_impossible +dvix721 divideint 10000000 1 -> NaN Division_impossible +dvix722 divideint 1000000 1 -> NaN Division_impossible +dvix723 divideint 100000 1 -> 100000 +dvix724 divideint 10000 1 -> 10000 +dvix725 divideint 1000 1 -> 1000 +dvix726 divideint 100 1 -> 100 +dvix727 divideint 10 1 -> 10 +dvix728 divideint 1 1 -> 1 +dvix729 divideint 1 10 -> 0 + +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +dvix732 divideint 1 0.99e999999999 -> 0 +dvix733 divideint 1 0.999999999e999999999 -> 0 +dvix734 divideint 9e999999999 1 -> NaN Division_impossible +dvix735 divideint 9.9e999999999 1 -> NaN Division_impossible +dvix736 divideint 9.99e999999999 1 -> NaN Division_impossible +dvix737 divideint 9.99999999e999999999 1 -> NaN Division_impossible + +dvix740 divideint 0.1 9e-999999999 -> NaN Division_impossible +dvix741 divideint 0.1 99e-999999999 -> NaN Division_impossible +dvix742 divideint 0.1 999e-999999999 -> NaN Division_impossible + +dvix743 divideint 0.1 9e-999999998 -> NaN Division_impossible +dvix744 divideint 0.1 99e-999999998 -> NaN Division_impossible +dvix745 divideint 0.1 999e-999999998 -> NaN Division_impossible +dvix746 divideint 0.1 999e-999999997 -> NaN Division_impossible +dvix747 divideint 0.1 9999e-999999997 -> NaN Division_impossible +dvix748 divideint 0.1 99999e-999999997 -> NaN Division_impossible + + +-- Null tests +dvix900 divideint 10 # -> NaN Invalid_operation +dvix901 divideint # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/inexact.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/inexact.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,215 @@ +------------------------------------------------------------------------ +-- inexact.decTest -- decimal inexact and rounded edge cases -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +inx001 add 1 1 -> 2 +inx002 add 123456789 0 -> 123456789 +inx003 add 123456789 0.0 -> 123456789 Rounded +inx004 add 123456789 0.00 -> 123456789 Rounded +inx005 add 123456789 1 -> 123456790 +inx006 add 123456789 0.1 -> 123456789 Inexact Rounded +inx007 add 123456789 0.01 -> 123456789 Inexact Rounded +inx008 add 123456789 0.001 -> 123456789 Inexact Rounded +inx009 add 123456789 0.000001 -> 123456789 Inexact Rounded +inx010 add 123456789 0.000000001 -> 123456789 Inexact Rounded +inx011 add 123456789 0.000000000001 -> 123456789 Inexact Rounded + +inx012 add 123456789 0.9 -> 123456790 Inexact Rounded +inx013 add 123456789 0.09 -> 123456789 Inexact Rounded +inx014 add 123456789 0.009 -> 123456789 Inexact Rounded +inx015 add 123456789 0.000009 -> 123456789 Inexact Rounded +inx016 add 123456789 0.000000009 -> 123456789 Inexact Rounded +inx017 add 123456789 0.000000000009 -> 123456789 Inexact Rounded + +inx021 add 1 -1 -> 0 +inx022 add 123456789 -0 -> 123456789 +inx023 add 123456789 -0.0 -> 123456789 Rounded +inx024 add 123456789 -0.00 -> 123456789 Rounded +inx025 add 123456789 -1 -> 123456788 +inx026 add 123456789 -0.1 -> 123456789 Inexact Rounded +inx027 add 123456789 -0.01 -> 123456789 Inexact Rounded +inx028 add 123456789 -0.001 -> 123456789 Inexact Rounded +inx029 add 123456789 -0.000001 -> 123456789 Inexact Rounded +inx030 add 123456789 -0.000000001 -> 123456789 Inexact Rounded +inx031 add 123456789 -0.000000000001 -> 123456789 Inexact Rounded +inx032 add 123456789 -0.9 -> 123456788 Inexact Rounded +inx033 add 123456789 -0.09 -> 123456789 Inexact Rounded +inx034 add 123456789 -0.009 -> 123456789 Inexact Rounded +inx035 add 123456789 -0.000009 -> 123456789 Inexact Rounded +inx036 add 123456789 -0.000000009 -> 123456789 Inexact Rounded +inx037 add 123456789 -0.000000000009 -> 123456789 Inexact Rounded + +inx042 add 0 123456789 -> 123456789 +inx043 add 0.0 123456789 -> 123456789 Rounded +inx044 add 0.00 123456789 -> 123456789 Rounded +inx045 add 1 123456789 -> 123456790 +inx046 add 0.1 123456789 -> 123456789 Inexact Rounded +inx047 add 0.01 123456789 -> 123456789 Inexact Rounded +inx048 add 0.001 123456789 -> 123456789 Inexact Rounded +inx049 add 0.000001 123456789 -> 123456789 Inexact Rounded +inx050 add 0.000000001 123456789 -> 123456789 Inexact Rounded +inx051 add 0.000000000001 123456789 -> 123456789 Inexact Rounded +inx052 add 0.9 123456789 -> 123456790 Inexact Rounded +inx053 add 0.09 123456789 -> 123456789 Inexact Rounded +inx054 add 0.009 123456789 -> 123456789 Inexact Rounded +inx055 add 0.000009 123456789 -> 123456789 Inexact Rounded +inx056 add 0.000000009 123456789 -> 123456789 Inexact Rounded +inx057 add 0.000000000009 123456789 -> 123456789 Inexact Rounded + +inx062 add -0 123456789 -> 123456789 +inx063 add -0.0 123456789 -> 123456789 Rounded +inx064 add -0.00 123456789 -> 123456789 Rounded +inx065 add -1 123456789 -> 123456788 +inx066 add -0.1 123456789 -> 123456789 Inexact Rounded +inx067 add -0.01 123456789 -> 123456789 Inexact Rounded +inx068 add -0.001 123456789 -> 123456789 Inexact Rounded +inx069 add -0.000001 123456789 -> 123456789 Inexact Rounded +inx070 add -0.000000001 123456789 -> 123456789 Inexact Rounded +inx071 add -0.000000000001 123456789 -> 123456789 Inexact Rounded +inx072 add -0.9 123456789 -> 123456788 Inexact Rounded +inx073 add -0.09 123456789 -> 123456789 Inexact Rounded +inx074 add -0.009 123456789 -> 123456789 Inexact Rounded +inx075 add -0.000009 123456789 -> 123456789 Inexact Rounded +inx076 add -0.000000009 123456789 -> 123456789 Inexact Rounded +inx077 add -0.000000000009 123456789 -> 123456789 Inexact Rounded + +-- some boundaries +inx081 add 999999999 0 -> 999999999 +inx082 add 0.999999999 0.000000000 -> 0.999999999 +inx083 add 999999999 1 -> 1.00000000E+9 Rounded +inx084 add 0.999999999 0.000000001 -> 1.00000000 Rounded +inx085 add 999999999 2 -> 1.00000000E+9 Inexact Rounded +inx086 add 0.999999999 0.000000002 -> 1.00000000 Inexact Rounded +inx087 add 999999999 3 -> 1.00000000E+9 Inexact Rounded +inx089 add 0.999999999 0.000000003 -> 1.00000000 Inexact Rounded + +-- minus, plus, and subtract all assumed to work like add. + +-- multiply +precision: 8 +inx101 multiply 1000 1000 -> 1000000 +inx102 multiply 9000 9000 -> 81000000 +inx103 multiply 9999 9999 -> 99980001 +inx104 multiply 1000 10000 -> 10000000 +inx105 multiply 10000 10000 -> 1.0000000E+8 Rounded +inx106 multiply 10001 10000 -> 1.0001000E+8 Rounded +inx107 multiply 10001 10001 -> 1.0002000E+8 Inexact Rounded +inx108 multiply 10101 10001 -> 1.0102010E+8 Inexact Rounded +inx109 multiply 10001 10101 -> 1.0102010E+8 Inexact Rounded + +-- divide +precision: 4 +inx201 divide 1000 1000 -> 1 +inx202 divide 1000 1 -> 1000 +inx203 divide 1000 2 -> 500 +inx204 divide 1000 3 -> 333.3 Inexact Rounded +inx205 divide 1000 4 -> 250 +inx206 divide 1000 5 -> 200 +inx207 divide 1000 6 -> 166.7 Inexact Rounded +inx208 divide 1000 7 -> 142.9 Inexact Rounded +inx209 divide 1000 8 -> 125 +inx210 divide 1000 9 -> 111.1 Inexact Rounded +inx211 divide 1000 10 -> 100 + +inx220 divide 1 1 -> 1 +inx221 divide 1 2 -> 0.5 +inx222 divide 1 4 -> 0.25 +inx223 divide 1 8 -> 0.125 +inx224 divide 1 16 -> 0.0625 +inx225 divide 1 32 -> 0.03125 +inx226 divide 1 64 -> 0.01563 Inexact Rounded +inx227 divide 1 128 -> 0.007813 Inexact Rounded + +precision: 5 +inx230 divide 1 1 -> 1 +inx231 divide 1 2 -> 0.5 +inx232 divide 1 4 -> 0.25 +inx233 divide 1 8 -> 0.125 +inx234 divide 1 16 -> 0.0625 +inx235 divide 1 32 -> 0.03125 +inx236 divide 1 64 -> 0.015625 +inx237 divide 1 128 -> 0.0078125 + +precision: 3 +inx240 divide 1 1 -> 1 +inx241 divide 1 2 -> 0.5 +inx242 divide 1 4 -> 0.25 +inx243 divide 1 8 -> 0.125 +inx244 divide 1 16 -> 0.0625 +inx245 divide 1 32 -> 0.0313 Inexact Rounded +inx246 divide 1 64 -> 0.0156 Inexact Rounded +inx247 divide 1 128 -> 0.00781 Inexact Rounded + +precision: 2 +inx250 divide 1 1 -> 1 +inx251 divide 1 2 -> 0.5 +inx252 divide 1 4 -> 0.25 +inx253 divide 1 8 -> 0.13 Inexact Rounded +inx254 divide 1 16 -> 0.063 Inexact Rounded +inx255 divide 1 32 -> 0.031 Inexact Rounded +inx256 divide 1 64 -> 0.016 Inexact Rounded +inx257 divide 1 128 -> 0.0078 Inexact Rounded + +precision: 1 +inx260 divide 1 1 -> 1 +inx261 divide 1 2 -> 0.5 +inx262 divide 1 4 -> 0.3 Inexact Rounded +inx263 divide 1 8 -> 0.1 Inexact Rounded +inx264 divide 1 16 -> 0.06 Inexact Rounded +inx265 divide 1 32 -> 0.03 Inexact Rounded +inx266 divide 1 64 -> 0.02 Inexact Rounded +inx267 divide 1 128 -> 0.008 Inexact Rounded + + +-- power +precision: 4 +inx301 power 0.5 2 -> 0.25 +inx302 power 0.5 4 -> 0.0625 +inx303 power 0.5 8 -> 0.003906 Inexact Rounded +inx304 power 0.5 16 -> 0.00001526 Inexact Rounded +inx305 power 0.5 32 -> 2.328E-10 Inexact Rounded + +-- compare, divideInteger, and remainder are always exact + +-- rescale +precision: 4 +inx401 rescale 0 0 -> 0 +inx402 rescale 1 0 -> 1 +inx403 rescale 0.1 +2 -> 0E+2 Inexact Rounded +inx404 rescale 0.1 +1 -> 0E+1 Inexact Rounded +inx405 rescale 0.1 0 -> 0 Inexact Rounded +inx406 rescale 0.1 -1 -> 0.1 +inx407 rescale 0.1 -2 -> 0.10 + +-- long operands cause rounding too +precision: 9 +inx801 plus 123456789 -> 123456789 +inx802 plus 1234567890 -> 1.23456789E+9 Rounded +inx803 plus 1234567891 -> 1.23456789E+9 Inexact Rounded +inx804 plus 1234567892 -> 1.23456789E+9 Inexact Rounded +inx805 plus 1234567899 -> 1.23456790E+9 Inexact Rounded +inx806 plus 1234567900 -> 1.23456790E+9 Rounded + Added: sandbox/trunk/decimal-c/decimaltestdata/max.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/max.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,376 @@ +------------------------------------------------------------------------ +-- max.decTest -- decimal maximum -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- we assume that base comparison is tested in compare.decTest, so +-- these mainly cover special cases and rounding + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- sanity checks +maxx001 max -2 -2 -> -2 +maxx002 max -2 -1 -> -1 +maxx003 max -2 0 -> 0 +maxx004 max -2 1 -> 1 +maxx005 max -2 2 -> 2 +maxx006 max -1 -2 -> -1 +maxx007 max -1 -1 -> -1 +maxx008 max -1 0 -> 0 +maxx009 max -1 1 -> 1 +maxx010 max -1 2 -> 2 +maxx011 max 0 -2 -> 0 +maxx012 max 0 -1 -> 0 +maxx013 max 0 0 -> 0 +maxx014 max 0 1 -> 1 +maxx015 max 0 2 -> 2 +maxx016 max 1 -2 -> 1 +maxx017 max 1 -1 -> 1 +maxx018 max 1 0 -> 1 +maxx019 max 1 1 -> 1 +maxx020 max 1 2 -> 2 +maxx021 max 2 -2 -> 2 +maxx022 max 2 -1 -> 2 +maxx023 max 2 0 -> 2 +maxx025 max 2 1 -> 2 +maxx026 max 2 2 -> 2 + +-- extended zeros +maxx030 max 0 0 -> 0 +maxx031 max 0 -0 -> 0 +maxx032 max 0 -0.0 -> 0 +maxx033 max 0 0.0 -> 0 +maxx034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen +maxx035 max -0 -0 -> -0 +maxx036 max -0 -0.0 -> -0.0 +maxx037 max -0 0.0 -> 0.0 +maxx038 max 0.0 0 -> 0 +maxx039 max 0.0 -0 -> 0.0 +maxx040 max 0.0 -0.0 -> 0.0 +maxx041 max 0.0 0.0 -> 0.0 +maxx042 max -0.0 0 -> 0 +maxx043 max -0.0 -0 -> -0.0 +maxx044 max -0.0 -0.0 -> -0.0 +maxx045 max -0.0 0.0 -> 0.0 + +maxx050 max -0E1 0E1 -> 0E+1 +maxx051 max -0E2 0E2 -> 0E+2 +maxx052 max -0E2 0E1 -> 0E+1 +maxx053 max -0E1 0E2 -> 0E+2 +maxx054 max 0E1 -0E1 -> 0E+1 +maxx055 max 0E2 -0E2 -> 0E+2 +maxx056 max 0E2 -0E1 -> 0E+2 +maxx057 max 0E1 -0E2 -> 0E+1 + +maxx058 max 0E1 0E1 -> 0E+1 +maxx059 max 0E2 0E2 -> 0E+2 +maxx060 max 0E2 0E1 -> 0E+2 +maxx061 max 0E1 0E2 -> 0E+2 +maxx062 max -0E1 -0E1 -> -0E+1 +maxx063 max -0E2 -0E2 -> -0E+2 +maxx064 max -0E2 -0E1 -> -0E+1 +maxx065 max -0E1 -0E2 -> -0E+1 + +-- Specials +precision: 9 +maxx090 max Inf -Inf -> Infinity +maxx091 max Inf -1000 -> Infinity +maxx092 max Inf -1 -> Infinity +maxx093 max Inf -0 -> Infinity +maxx094 max Inf 0 -> Infinity +maxx095 max Inf 1 -> Infinity +maxx096 max Inf 1000 -> Infinity +maxx097 max Inf Inf -> Infinity +maxx098 max -1000 Inf -> Infinity +maxx099 max -Inf Inf -> Infinity +maxx100 max -1 Inf -> Infinity +maxx101 max -0 Inf -> Infinity +maxx102 max 0 Inf -> Infinity +maxx103 max 1 Inf -> Infinity +maxx104 max 1000 Inf -> Infinity +maxx105 max Inf Inf -> Infinity + +maxx120 max -Inf -Inf -> -Infinity +maxx121 max -Inf -1000 -> -1000 +maxx122 max -Inf -1 -> -1 +maxx123 max -Inf -0 -> -0 +maxx124 max -Inf 0 -> 0 +maxx125 max -Inf 1 -> 1 +maxx126 max -Inf 1000 -> 1000 +maxx127 max -Inf Inf -> Infinity +maxx128 max -Inf -Inf -> -Infinity +maxx129 max -1000 -Inf -> -1000 +maxx130 max -1 -Inf -> -1 +maxx131 max -0 -Inf -> -0 +maxx132 max 0 -Inf -> 0 +maxx133 max 1 -Inf -> 1 +maxx134 max 1000 -Inf -> 1000 +maxx135 max Inf -Inf -> Infinity + +-- 2004.08.02 754r chooses number over NaN in mixed cases +maxx141 max NaN -Inf -> -Infinity +maxx142 max NaN -1000 -> -1000 +maxx143 max NaN -1 -> -1 +maxx144 max NaN -0 -> -0 +maxx145 max NaN 0 -> 0 +maxx146 max NaN 1 -> 1 +maxx147 max NaN 1000 -> 1000 +maxx148 max NaN Inf -> Infinity +maxx149 max NaN NaN -> NaN +maxx150 max -Inf NaN -> -Infinity +maxx151 max -1000 NaN -> -1000 +maxx152 max -1 NaN -> -1 +maxx153 max -0 NaN -> -0 +maxx154 max 0 NaN -> 0 +maxx155 max 1 NaN -> 1 +maxx156 max 1000 NaN -> 1000 +maxx157 max Inf NaN -> Infinity + +maxx161 max sNaN -Inf -> NaN Invalid_operation +maxx162 max sNaN -1000 -> NaN Invalid_operation +maxx163 max sNaN -1 -> NaN Invalid_operation +maxx164 max sNaN -0 -> NaN Invalid_operation +maxx165 max sNaN 0 -> NaN Invalid_operation +maxx166 max sNaN 1 -> NaN Invalid_operation +maxx167 max sNaN 1000 -> NaN Invalid_operation +maxx168 max sNaN NaN -> NaN Invalid_operation +maxx169 max sNaN sNaN -> NaN Invalid_operation +maxx170 max NaN sNaN -> NaN Invalid_operation +maxx171 max -Inf sNaN -> NaN Invalid_operation +maxx172 max -1000 sNaN -> NaN Invalid_operation +maxx173 max -1 sNaN -> NaN Invalid_operation +maxx174 max -0 sNaN -> NaN Invalid_operation +maxx175 max 0 sNaN -> NaN Invalid_operation +maxx176 max 1 sNaN -> NaN Invalid_operation +maxx177 max 1000 sNaN -> NaN Invalid_operation +maxx178 max Inf sNaN -> NaN Invalid_operation +maxx179 max NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +maxx181 max NaN9 -Inf -> -Infinity +maxx182 max NaN8 9 -> 9 +maxx183 max -NaN7 Inf -> Infinity + +maxx184 max -NaN1 NaN11 -> -NaN1 +maxx185 max NaN2 NaN12 -> NaN2 +maxx186 max -NaN13 -NaN7 -> -NaN13 +maxx187 max NaN14 -NaN5 -> NaN14 + +maxx188 max -Inf NaN4 -> -Infinity +maxx189 max -9 -NaN3 -> -9 +maxx190 max Inf NaN2 -> Infinity + +maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation +maxx192 max sNaN98 -1 -> NaN98 Invalid_operation +maxx193 max -sNaN97 NaN -> -NaN97 Invalid_operation +maxx194 max sNaN96 sNaN94 -> NaN96 Invalid_operation +maxx195 max NaN95 sNaN93 -> NaN93 Invalid_operation +maxx196 max -Inf sNaN92 -> NaN92 Invalid_operation +maxx197 max 0 sNaN91 -> NaN91 Invalid_operation +maxx198 max Inf -sNaN90 -> -NaN90 Invalid_operation +maxx199 max NaN sNaN89 -> NaN89 Invalid_operation + +-- rounding checks +maxexponent: 999 +minexponent: -999 +precision: 9 +maxx201 max 12345678000 1 -> 1.23456780E+10 Rounded +maxx202 max 1 12345678000 -> 1.23456780E+10 Rounded +maxx203 max 1234567800 1 -> 1.23456780E+9 Rounded +maxx204 max 1 1234567800 -> 1.23456780E+9 Rounded +maxx205 max 1234567890 1 -> 1.23456789E+9 Rounded +maxx206 max 1 1234567890 -> 1.23456789E+9 Rounded +maxx207 max 1234567891 1 -> 1.23456789E+9 Inexact Rounded +maxx208 max 1 1234567891 -> 1.23456789E+9 Inexact Rounded +maxx209 max 12345678901 1 -> 1.23456789E+10 Inexact Rounded +maxx210 max 1 12345678901 -> 1.23456789E+10 Inexact Rounded +maxx211 max 1234567896 1 -> 1.23456790E+9 Inexact Rounded +maxx212 max 1 1234567896 -> 1.23456790E+9 Inexact Rounded +maxx213 max -1234567891 1 -> 1 +maxx214 max 1 -1234567891 -> 1 +maxx215 max -12345678901 1 -> 1 +maxx216 max 1 -12345678901 -> 1 +maxx217 max -1234567896 1 -> 1 +maxx218 max 1 -1234567896 -> 1 + +precision: 15 +maxx221 max 12345678000 1 -> 12345678000 +maxx222 max 1 12345678000 -> 12345678000 +maxx223 max 1234567800 1 -> 1234567800 +maxx224 max 1 1234567800 -> 1234567800 +maxx225 max 1234567890 1 -> 1234567890 +maxx226 max 1 1234567890 -> 1234567890 +maxx227 max 1234567891 1 -> 1234567891 +maxx228 max 1 1234567891 -> 1234567891 +maxx229 max 12345678901 1 -> 12345678901 +maxx230 max 1 12345678901 -> 12345678901 +maxx231 max 1234567896 1 -> 1234567896 +maxx232 max 1 1234567896 -> 1234567896 +maxx233 max -1234567891 1 -> 1 +maxx234 max 1 -1234567891 -> 1 +maxx235 max -12345678901 1 -> 1 +maxx236 max 1 -12345678901 -> 1 +maxx237 max -1234567896 1 -> 1 +maxx238 max 1 -1234567896 -> 1 + +-- from examples +maxx280 max '3' '2' -> '3' +maxx281 max '-10' '3' -> '3' +maxx282 max '1.0' '1' -> '1' +maxx283 max '1' '1.0' -> '1' +maxx284 max '7' 'NaN' -> '7' + +-- overflow and underflow tests ... +maxExponent: 999999999 +minexponent: -999999999 +maxx330 max +1.23456789012345E-0 9E+999999999 -> 9E+999999999 +maxx331 max 9E+999999999 +1.23456789012345E-0 -> 9E+999999999 +maxx332 max +0.100 9E-999999999 -> 0.100 +maxx333 max 9E-999999999 +0.100 -> 0.100 +maxx335 max -1.23456789012345E-0 9E+999999999 -> 9E+999999999 +maxx336 max 9E+999999999 -1.23456789012345E-0 -> 9E+999999999 +maxx337 max -0.100 9E-999999999 -> 9E-999999999 +maxx338 max 9E-999999999 -0.100 -> 9E-999999999 + +maxx339 max 1e-599999999 1e-400000001 -> 1E-400000001 +maxx340 max 1e-599999999 1e-400000000 -> 1E-400000000 +maxx341 max 1e-600000000 1e-400000000 -> 1E-400000000 +maxx342 max 9e-999999998 0.01 -> 0.01 +maxx343 max 9e-999999998 0.1 -> 0.1 +maxx344 max 0.01 9e-999999998 -> 0.01 +maxx345 max 1e599999999 1e400000001 -> 1E+599999999 +maxx346 max 1e599999999 1e400000000 -> 1E+599999999 +maxx347 max 1e600000000 1e400000000 -> 1E+600000000 +maxx348 max 9e999999998 100 -> 9E+999999998 +maxx349 max 9e999999998 10 -> 9E+999999998 +maxx350 max 100 9e999999998 -> 9E+999999998 +-- signs +maxx351 max 1e+777777777 1e+411111111 -> 1E+777777777 +maxx352 max 1e+777777777 -1e+411111111 -> 1E+777777777 +maxx353 max -1e+777777777 1e+411111111 -> 1E+411111111 +maxx354 max -1e+777777777 -1e+411111111 -> -1E+411111111 +maxx355 max 1e-777777777 1e-411111111 -> 1E-411111111 +maxx356 max 1e-777777777 -1e-411111111 -> 1E-777777777 +maxx357 max -1e-777777777 1e-411111111 -> 1E-411111111 +maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777 + +-- expanded list from min/max 754r purple prose +-- [explicit tests for exponent ordering] +maxx401 max Inf 1.1 -> Infinity +maxx402 max 1.1 1 -> 1.1 +maxx403 max 1 1.0 -> 1 +maxx404 max 1.0 0.1 -> 1.0 +maxx405 max 0.1 0.10 -> 0.1 +maxx406 max 0.10 0.100 -> 0.10 +maxx407 max 0.10 0 -> 0.10 +maxx408 max 0 0.0 -> 0 +maxx409 max 0.0 -0 -> 0.0 +maxx410 max 0.0 -0.0 -> 0.0 +maxx411 max 0.00 -0.0 -> 0.00 +maxx412 max 0.0 -0.00 -> 0.0 +maxx413 max 0 -0.0 -> 0 +maxx414 max 0 -0 -> 0 +maxx415 max -0.0 -0 -> -0.0 +maxx416 max -0 -0.100 -> -0 +maxx417 max -0.100 -0.10 -> -0.100 +maxx418 max -0.10 -0.1 -> -0.10 +maxx419 max -0.1 -1.0 -> -0.1 +maxx420 max -1.0 -1 -> -1.0 +maxx421 max -1 -1.1 -> -1 +maxx423 max -1.1 -Inf -> -1.1 +-- same with operands reversed +maxx431 max 1.1 Inf -> Infinity +maxx432 max 1 1.1 -> 1.1 +maxx433 max 1.0 1 -> 1 +maxx434 max 0.1 1.0 -> 1.0 +maxx435 max 0.10 0.1 -> 0.1 +maxx436 max 0.100 0.10 -> 0.10 +maxx437 max 0 0.10 -> 0.10 +maxx438 max 0.0 0 -> 0 +maxx439 max -0 0.0 -> 0.0 +maxx440 max -0.0 0.0 -> 0.0 +maxx441 max -0.0 0.00 -> 0.00 +maxx442 max -0.00 0.0 -> 0.0 +maxx443 max -0.0 0 -> 0 +maxx444 max -0 0 -> 0 +maxx445 max -0 -0.0 -> -0.0 +maxx446 max -0.100 -0 -> -0 +maxx447 max -0.10 -0.100 -> -0.100 +maxx448 max -0.1 -0.10 -> -0.10 +maxx449 max -1.0 -0.1 -> -0.1 +maxx450 max -1 -1.0 -> -1.0 +maxx451 max -1.1 -1 -> -1 +maxx453 max -Inf -1.1 -> -1.1 +-- largies +maxx460 max 1000 1E+3 -> 1E+3 +maxx461 max 1E+3 1000 -> 1E+3 +maxx462 max 1000 -1E+3 -> 1000 +maxx463 max 1E+3 -1000 -> 1E+3 +maxx464 max -1000 1E+3 -> 1E+3 +maxx465 max -1E+3 1000 -> 1000 +maxx466 max -1000 -1E+3 -> -1000 +maxx467 max -1E+3 -1000 -> -1000 + + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +maxx500 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded +maxx501 max -9.999E+999999999 0 -> 0 + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +maxx510 max 1.00E-999 0 -> 1.00E-999 +maxx511 max 0.1E-999 0 -> 1E-1000 Subnormal +maxx512 max 0.10E-999 0 -> 1.0E-1000 Subnormal +maxx513 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded +maxx514 max 0.01E-999 0 -> 1E-1001 Subnormal +-- next is rounded to Emin +maxx515 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow +maxx516 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +maxx517 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow +maxx518 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow +maxx519 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow +maxx520 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow + +maxx530 max -1.00E-999 0 -> 0 +maxx531 max -0.1E-999 0 -> 0 +maxx532 max -0.10E-999 0 -> 0 +maxx533 max -0.100E-999 0 -> 0 +maxx534 max -0.01E-999 0 -> 0 +maxx535 max -0.999E-999 0 -> 0 +maxx536 max -0.099E-999 0 -> 0 +maxx537 max -0.009E-999 0 -> 0 +maxx538 max -0.001E-999 0 -> 0 +maxx539 max -0.0009E-999 0 -> 0 +maxx540 max -0.0001E-999 0 -> 0 + +-- Null tests +maxx900 max 10 # -> NaN Invalid_operation +maxx901 max # 10 -> NaN Invalid_operation + + + Added: sandbox/trunk/decimal-c/decimaltestdata/min.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/min.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,363 @@ +------------------------------------------------------------------------ +-- min.decTest -- decimal minimum -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- we assume that base comparison is tested in compare.decTest, so +-- these mainly cover special cases and rounding + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- sanity checks +mnmx001 min -2 -2 -> -2 +mnmx002 min -2 -1 -> -2 +mnmx003 min -2 0 -> -2 +mnmx004 min -2 1 -> -2 +mnmx005 min -2 2 -> -2 +mnmx006 min -1 -2 -> -2 +mnmx007 min -1 -1 -> -1 +mnmx008 min -1 0 -> -1 +mnmx009 min -1 1 -> -1 +mnmx010 min -1 2 -> -1 +mnmx011 min 0 -2 -> -2 +mnmx012 min 0 -1 -> -1 +mnmx013 min 0 0 -> 0 +mnmx014 min 0 1 -> 0 +mnmx015 min 0 2 -> 0 +mnmx016 min 1 -2 -> -2 +mnmx017 min 1 -1 -> -1 +mnmx018 min 1 0 -> 0 +mnmx019 min 1 1 -> 1 +mnmx020 min 1 2 -> 1 +mnmx021 min 2 -2 -> -2 +mnmx022 min 2 -1 -> -1 +mnmx023 min 2 0 -> 0 +mnmx025 min 2 1 -> 1 +mnmx026 min 2 2 -> 2 + +-- extended zeros +mnmx030 min 0 0 -> 0 +mnmx031 min 0 -0 -> -0 +mnmx032 min 0 -0.0 -> -0.0 +mnmx033 min 0 0.0 -> 0.0 +mnmx034 min -0 0 -> -0 +mnmx035 min -0 -0 -> -0 +mnmx036 min -0 -0.0 -> -0 +mnmx037 min -0 0.0 -> -0 +mnmx038 min 0.0 0 -> 0.0 +mnmx039 min 0.0 -0 -> -0 +mnmx040 min 0.0 -0.0 -> -0.0 +mnmx041 min 0.0 0.0 -> 0.0 +mnmx042 min -0.0 0 -> -0.0 +mnmx043 min -0.0 -0 -> -0 +mnmx044 min -0.0 -0.0 -> -0.0 +mnmx045 min -0.0 0.0 -> -0.0 + +mnmx046 min 0E1 -0E1 -> -0E+1 +mnmx047 min -0E1 0E2 -> -0E+1 +mnmx048 min 0E2 0E1 -> 0E+1 +mnmx049 min 0E1 0E2 -> 0E+1 +mnmx050 min -0E3 -0E2 -> -0E+3 +mnmx051 min -0E2 -0E3 -> -0E+3 + +-- Specials +precision: 9 +mnmx090 min Inf -Inf -> -Infinity +mnmx091 min Inf -1000 -> -1000 +mnmx092 min Inf -1 -> -1 +mnmx093 min Inf -0 -> -0 +mnmx094 min Inf 0 -> 0 +mnmx095 min Inf 1 -> 1 +mnmx096 min Inf 1000 -> 1000 +mnmx097 min Inf Inf -> Infinity +mnmx098 min -1000 Inf -> -1000 +mnmx099 min -Inf Inf -> -Infinity +mnmx100 min -1 Inf -> -1 +mnmx101 min -0 Inf -> -0 +mnmx102 min 0 Inf -> 0 +mnmx103 min 1 Inf -> 1 +mnmx104 min 1000 Inf -> 1000 +mnmx105 min Inf Inf -> Infinity + +mnmx120 min -Inf -Inf -> -Infinity +mnmx121 min -Inf -1000 -> -Infinity +mnmx122 min -Inf -1 -> -Infinity +mnmx123 min -Inf -0 -> -Infinity +mnmx124 min -Inf 0 -> -Infinity +mnmx125 min -Inf 1 -> -Infinity +mnmx126 min -Inf 1000 -> -Infinity +mnmx127 min -Inf Inf -> -Infinity +mnmx128 min -Inf -Inf -> -Infinity +mnmx129 min -1000 -Inf -> -Infinity +mnmx130 min -1 -Inf -> -Infinity +mnmx131 min -0 -Inf -> -Infinity +mnmx132 min 0 -Inf -> -Infinity +mnmx133 min 1 -Inf -> -Infinity +mnmx134 min 1000 -Inf -> -Infinity +mnmx135 min Inf -Inf -> -Infinity + +-- 2004.08.02 754r chooses number over NaN in mixed cases +mnmx141 min NaN -Inf -> -Infinity +mnmx142 min NaN -1000 -> -1000 +mnmx143 min NaN -1 -> -1 +mnmx144 min NaN -0 -> -0 +mnmx145 min NaN 0 -> 0 +mnmx146 min NaN 1 -> 1 +mnmx147 min NaN 1000 -> 1000 +mnmx148 min NaN Inf -> Infinity +mnmx149 min NaN NaN -> NaN +mnmx150 min -Inf NaN -> -Infinity +mnmx151 min -1000 NaN -> -1000 +mnmx152 min -1 -NaN -> -1 +mnmx153 min -0 NaN -> -0 +mnmx154 min 0 -NaN -> 0 +mnmx155 min 1 NaN -> 1 +mnmx156 min 1000 NaN -> 1000 +mnmx157 min Inf NaN -> Infinity + +mnmx161 min sNaN -Inf -> NaN Invalid_operation +mnmx162 min sNaN -1000 -> NaN Invalid_operation +mnmx163 min sNaN -1 -> NaN Invalid_operation +mnmx164 min sNaN -0 -> NaN Invalid_operation +mnmx165 min -sNaN 0 -> -NaN Invalid_operation +mnmx166 min -sNaN 1 -> -NaN Invalid_operation +mnmx167 min sNaN 1000 -> NaN Invalid_operation +mnmx168 min sNaN NaN -> NaN Invalid_operation +mnmx169 min sNaN sNaN -> NaN Invalid_operation +mnmx170 min NaN sNaN -> NaN Invalid_operation +mnmx171 min -Inf sNaN -> NaN Invalid_operation +mnmx172 min -1000 sNaN -> NaN Invalid_operation +mnmx173 min -1 sNaN -> NaN Invalid_operation +mnmx174 min -0 sNaN -> NaN Invalid_operation +mnmx175 min 0 sNaN -> NaN Invalid_operation +mnmx176 min 1 sNaN -> NaN Invalid_operation +mnmx177 min 1000 sNaN -> NaN Invalid_operation +mnmx178 min Inf sNaN -> NaN Invalid_operation +mnmx179 min NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +mnmx181 min NaN9 -Inf -> -Infinity +mnmx182 min -NaN8 9990 -> 9990 +mnmx183 min NaN71 Inf -> Infinity + +mnmx184 min NaN1 NaN54 -> NaN1 +mnmx185 min NaN22 -NaN53 -> NaN22 +mnmx186 min -NaN3 NaN6 -> -NaN3 +mnmx187 min -NaN44 NaN7 -> -NaN44 + +mnmx188 min -Inf NaN41 -> -Infinity +mnmx189 min -9999 -NaN33 -> -9999 +mnmx190 min Inf NaN2 -> Infinity + +mnmx191 min sNaN99 -Inf -> NaN99 Invalid_operation +mnmx192 min sNaN98 -11 -> NaN98 Invalid_operation +mnmx193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation +mnmx194 min sNaN69 sNaN94 -> NaN69 Invalid_operation +mnmx195 min NaN95 sNaN93 -> NaN93 Invalid_operation +mnmx196 min -Inf sNaN92 -> NaN92 Invalid_operation +mnmx197 min 088 sNaN91 -> NaN91 Invalid_operation +mnmx198 min Inf -sNaN90 -> -NaN90 Invalid_operation +mnmx199 min NaN sNaN86 -> NaN86 Invalid_operation + +-- rounding checks -- chosen is rounded, or not +maxExponent: 999 +minexponent: -999 +precision: 9 +mnmx201 min -12345678000 1 -> -1.23456780E+10 Rounded +mnmx202 min 1 -12345678000 -> -1.23456780E+10 Rounded +mnmx203 min -1234567800 1 -> -1.23456780E+9 Rounded +mnmx204 min 1 -1234567800 -> -1.23456780E+9 Rounded +mnmx205 min -1234567890 1 -> -1.23456789E+9 Rounded +mnmx206 min 1 -1234567890 -> -1.23456789E+9 Rounded +mnmx207 min -1234567891 1 -> -1.23456789E+9 Inexact Rounded +mnmx208 min 1 -1234567891 -> -1.23456789E+9 Inexact Rounded +mnmx209 min -12345678901 1 -> -1.23456789E+10 Inexact Rounded +mnmx210 min 1 -12345678901 -> -1.23456789E+10 Inexact Rounded +mnmx211 min -1234567896 1 -> -1.23456790E+9 Inexact Rounded +mnmx212 min 1 -1234567896 -> -1.23456790E+9 Inexact Rounded +mnmx213 min 1234567891 1 -> 1 +mnmx214 min 1 1234567891 -> 1 +mnmx215 min 12345678901 1 -> 1 +mnmx216 min 1 12345678901 -> 1 +mnmx217 min 1234567896 1 -> 1 +mnmx218 min 1 1234567896 -> 1 + +precision: 15 +mnmx221 min -12345678000 1 -> -12345678000 +mnmx222 min 1 -12345678000 -> -12345678000 +mnmx223 min -1234567800 1 -> -1234567800 +mnmx224 min 1 -1234567800 -> -1234567800 +mnmx225 min -1234567890 1 -> -1234567890 +mnmx226 min 1 -1234567890 -> -1234567890 +mnmx227 min -1234567891 1 -> -1234567891 +mnmx228 min 1 -1234567891 -> -1234567891 +mnmx229 min -12345678901 1 -> -12345678901 +mnmx230 min 1 -12345678901 -> -12345678901 +mnmx231 min -1234567896 1 -> -1234567896 +mnmx232 min 1 -1234567896 -> -1234567896 +mnmx233 min 1234567891 1 -> 1 +mnmx234 min 1 1234567891 -> 1 +mnmx235 min 12345678901 1 -> 1 +mnmx236 min 1 12345678901 -> 1 +mnmx237 min 1234567896 1 -> 1 +mnmx238 min 1 1234567896 -> 1 + +-- from examples +mnmx280 min '3' '2' -> '2' +mnmx281 min '-10' '3' -> '-10' +mnmx282 min '1.0' '1' -> '1.0' +mnmx283 min '1' '1.0' -> '1.0' +mnmx284 min '7' 'NaN' -> '7' + +-- overflow and underflow tests .. subnormal results [inputs] now allowed +maxExponent: 999999999 +minexponent: -999999999 +mnmx330 min -1.23456789012345E-0 -9E+999999999 -> -9E+999999999 +mnmx331 min -9E+999999999 -1.23456789012345E-0 -> -9E+999999999 +mnmx332 min -0.100 -9E-999999999 -> -0.100 +mnmx333 min -9E-999999999 -0.100 -> -0.100 +mnmx335 min +1.23456789012345E-0 -9E+999999999 -> -9E+999999999 +mnmx336 min -9E+999999999 1.23456789012345E-0 -> -9E+999999999 +mnmx337 min +0.100 -9E-999999999 -> -9E-999999999 +mnmx338 min -9E-999999999 0.100 -> -9E-999999999 + +mnmx339 min -1e-599999999 -1e-400000001 -> -1E-400000001 +mnmx340 min -1e-599999999 -1e-400000000 -> -1E-400000000 +mnmx341 min -1e-600000000 -1e-400000000 -> -1E-400000000 +mnmx342 min -9e-999999998 -0.01 -> -0.01 +mnmx343 min -9e-999999998 -0.1 -> -0.1 +mnmx344 min -0.01 -9e-999999998 -> -0.01 +mnmx345 min -1e599999999 -1e400000001 -> -1E+599999999 +mnmx346 min -1e599999999 -1e400000000 -> -1E+599999999 +mnmx347 min -1e600000000 -1e400000000 -> -1E+600000000 +mnmx348 min -9e999999998 -100 -> -9E+999999998 +mnmx349 min -9e999999998 -10 -> -9E+999999998 +mnmx350 min -100 -9e999999998 -> -9E+999999998 +-- signs +mnmx351 min -1e+777777777 -1e+411111111 -> -1E+777777777 +mnmx352 min -1e+777777777 +1e+411111111 -> -1E+777777777 +mnmx353 min +1e+777777777 -1e+411111111 -> -1E+411111111 +mnmx354 min +1e+777777777 +1e+411111111 -> 1E+411111111 +mnmx355 min -1e-777777777 -1e-411111111 -> -1E-411111111 +mnmx356 min -1e-777777777 +1e-411111111 -> -1E-777777777 +mnmx357 min +1e-777777777 -1e-411111111 -> -1E-411111111 +mnmx358 min +1e-777777777 +1e-411111111 -> 1E-777777777 + +-- expanded list from min/max 754r purple prose +-- [explicit tests for exponent ordering] +mnmx401 min Inf 1.1 -> 1.1 +mnmx402 min 1.1 1 -> 1 +mnmx403 min 1 1.0 -> 1.0 +mnmx404 min 1.0 0.1 -> 0.1 +mnmx405 min 0.1 0.10 -> 0.10 +mnmx406 min 0.10 0.100 -> 0.100 +mnmx407 min 0.10 0 -> 0 +mnmx408 min 0 0.0 -> 0.0 +mnmx409 min 0.0 -0 -> -0 +mnmx410 min 0.0 -0.0 -> -0.0 +mnmx411 min 0.00 -0.0 -> -0.0 +mnmx412 min 0.0 -0.00 -> -0.00 +mnmx413 min 0 -0.0 -> -0.0 +mnmx414 min 0 -0 -> -0 +mnmx415 min -0.0 -0 -> -0 +mnmx416 min -0 -0.100 -> -0.100 +mnmx417 min -0.100 -0.10 -> -0.10 +mnmx418 min -0.10 -0.1 -> -0.1 +mnmx419 min -0.1 -1.0 -> -1.0 +mnmx420 min -1.0 -1 -> -1 +mnmx421 min -1 -1.1 -> -1.1 +mnmx423 min -1.1 -Inf -> -Infinity +-- same with operands reversed +mnmx431 min 1.1 Inf -> 1.1 +mnmx432 min 1 1.1 -> 1 +mnmx433 min 1.0 1 -> 1.0 +mnmx434 min 0.1 1.0 -> 0.1 +mnmx435 min 0.10 0.1 -> 0.10 +mnmx436 min 0.100 0.10 -> 0.100 +mnmx437 min 0 0.10 -> 0 +mnmx438 min 0.0 0 -> 0.0 +mnmx439 min -0 0.0 -> -0 +mnmx440 min -0.0 0.0 -> -0.0 +mnmx441 min -0.0 0.00 -> -0.0 +mnmx442 min -0.00 0.0 -> -0.00 +mnmx443 min -0.0 0 -> -0.0 +mnmx444 min -0 0 -> -0 +mnmx445 min -0 -0.0 -> -0 +mnmx446 min -0.100 -0 -> -0.100 +mnmx447 min -0.10 -0.100 -> -0.10 +mnmx448 min -0.1 -0.10 -> -0.1 +mnmx449 min -1.0 -0.1 -> -1.0 +mnmx450 min -1 -1.0 -> -1 +mnmx451 min -1.1 -1 -> -1.1 +mnmx453 min -Inf -1.1 -> -Infinity +-- largies +mnmx460 min 1000 1E+3 -> 1000 +mnmx461 min 1E+3 1000 -> 1000 +mnmx462 min 1000 -1E+3 -> -1E+3 +mnmx463 min 1E+3 -1000 -> -1000 +mnmx464 min -1000 1E+3 -> -1000 +mnmx465 min -1E+3 1000 -> -1E+3 +mnmx466 min -1000 -1E+3 -> -1E+3 +mnmx467 min -1E+3 -1000 -> -1E+3 + + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +mnmx500 min 9.999E+999999999 0 -> 0 +mnmx501 min -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +mnmx510 min 1.00E-999 0 -> 0 +mnmx511 min 0.1E-999 0 -> 0 +mnmx512 min 0.10E-999 0 -> 0 +mnmx513 min 0.100E-999 0 -> 0 +mnmx514 min 0.01E-999 0 -> 0 +mnmx515 min 0.999E-999 0 -> 0 +mnmx516 min 0.099E-999 0 -> 0 +mnmx517 min 0.009E-999 0 -> 0 +mnmx518 min 0.001E-999 0 -> 0 +mnmx519 min 0.0009E-999 0 -> 0 +mnmx520 min 0.0001E-999 0 -> 0 + +mnmx530 min -1.00E-999 0 -> -1.00E-999 +mnmx531 min -0.1E-999 0 -> -1E-1000 Subnormal +mnmx532 min -0.10E-999 0 -> -1.0E-1000 Subnormal +mnmx533 min -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded +mnmx534 min -0.01E-999 0 -> -1E-1001 Subnormal +-- next is rounded to Emin +mnmx535 min -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow +mnmx536 min -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +mnmx537 min -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow +mnmx538 min -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow +mnmx539 min -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow +mnmx540 min -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow + + +-- Null tests +mnm900 min 10 # -> NaN Invalid_operation +mnm901 min # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/minus.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/minus.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,182 @@ +------------------------------------------------------------------------ +-- minus.decTest -- decimal negation -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests primarily tests the existence of the operator. +-- Subtraction, rounding, and more overflows are tested elsewhere. + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +minx001 minus '1' -> '-1' +minx002 minus '-1' -> '1' +minx003 minus '1.00' -> '-1.00' +minx004 minus '-1.00' -> '1.00' +minx005 minus '0' -> '0' +minx006 minus '0.00' -> '0.00' +minx007 minus '00.0' -> '0.0' +minx008 minus '00.00' -> '0.00' +minx009 minus '00' -> '0' + +minx010 minus '-2' -> '2' +minx011 minus '2' -> '-2' +minx012 minus '-2.00' -> '2.00' +minx013 minus '2.00' -> '-2.00' +minx014 minus '-0' -> '0' +minx015 minus '-0.00' -> '0.00' +minx016 minus '-00.0' -> '0.0' +minx017 minus '-00.00' -> '0.00' +minx018 minus '-00' -> '0' + +-- "lhs" zeros in plus and minus have exponent = operand +minx020 minus '-0E3' -> '0E+3' +minx021 minus '-0E2' -> '0E+2' +minx022 minus '-0E1' -> '0E+1' +minx023 minus '-0E0' -> '0' +minx024 minus '+0E0' -> '0' +minx025 minus '+0E1' -> '0E+1' +minx026 minus '+0E2' -> '0E+2' +minx027 minus '+0E3' -> '0E+3' + +minx030 minus '-5E3' -> '5E+3' +minx031 minus '-5E8' -> '5E+8' +minx032 minus '-5E13' -> '5E+13' +minx033 minus '-5E18' -> '5E+18' +minx034 minus '+5E3' -> '-5E+3' +minx035 minus '+5E8' -> '-5E+8' +minx036 minus '+5E13' -> '-5E+13' +minx037 minus '+5E18' -> '-5E+18' + +minx050 minus '-2000000' -> '2000000' +minx051 minus '2000000' -> '-2000000' +precision: 7 +minx052 minus '-2000000' -> '2000000' +minx053 minus '2000000' -> '-2000000' +precision: 6 +minx054 minus '-2000000' -> '2.00000E+6' Rounded +minx055 minus '2000000' -> '-2.00000E+6' Rounded +precision: 3 +minx056 minus '-2000000' -> '2.00E+6' Rounded +minx057 minus '2000000' -> '-2.00E+6' Rounded + +-- more fixed, potential LHS swaps/overlays if done by 0 subtract x +precision: 9 +minx060 minus '56267E-10' -> '-0.0000056267' +minx061 minus '56267E-5' -> '-0.56267' +minx062 minus '56267E-2' -> '-562.67' +minx063 minus '56267E-1' -> '-5626.7' +minx065 minus '56267E-0' -> '-56267' +minx066 minus '56267E+0' -> '-56267' +minx067 minus '56267E+1' -> '-5.6267E+5' +minx068 minus '56267E+2' -> '-5.6267E+6' +minx069 minus '56267E+3' -> '-5.6267E+7' +minx070 minus '56267E+4' -> '-5.6267E+8' +minx071 minus '56267E+5' -> '-5.6267E+9' +minx072 minus '56267E+6' -> '-5.6267E+10' +minx080 minus '-56267E-10' -> '0.0000056267' +minx081 minus '-56267E-5' -> '0.56267' +minx082 minus '-56267E-2' -> '562.67' +minx083 minus '-56267E-1' -> '5626.7' +minx085 minus '-56267E-0' -> '56267' +minx086 minus '-56267E+0' -> '56267' +minx087 minus '-56267E+1' -> '5.6267E+5' +minx088 minus '-56267E+2' -> '5.6267E+6' +minx089 minus '-56267E+3' -> '5.6267E+7' +minx090 minus '-56267E+4' -> '5.6267E+8' +minx091 minus '-56267E+5' -> '5.6267E+9' +minx092 minus '-56267E+6' -> '5.6267E+10' + + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +minx100 minus 9.999E+999999999 -> -Infinity Inexact Overflow Rounded +minx101 minus -9.999E+999999999 -> Infinity Inexact Overflow Rounded + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +minx110 minus 1.00E-999 -> -1.00E-999 +minx111 minus 0.1E-999 -> -1E-1000 Subnormal +minx112 minus 0.10E-999 -> -1.0E-1000 Subnormal +minx113 minus 0.100E-999 -> -1.0E-1000 Subnormal Rounded +minx114 minus 0.01E-999 -> -1E-1001 Subnormal +-- next is rounded to Emin +minx115 minus 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow +minx116 minus 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +minx117 minus 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow +minx118 minus 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +minx119 minus 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +minx120 minus 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow + +minx130 minus -1.00E-999 -> 1.00E-999 +minx131 minus -0.1E-999 -> 1E-1000 Subnormal +minx132 minus -0.10E-999 -> 1.0E-1000 Subnormal +minx133 minus -0.100E-999 -> 1.0E-1000 Subnormal Rounded +minx134 minus -0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +minx135 minus -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow +minx136 minus -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +minx137 minus -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +minx138 minus -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +minx139 minus -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +minx140 minus -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow + + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +minx301 minus 12345678000 -> -1.23456780E+10 Rounded +minx302 minus 1234567800 -> -1.23456780E+9 Rounded +minx303 minus 1234567890 -> -1.23456789E+9 Rounded +minx304 minus 1234567891 -> -1.23456789E+9 Inexact Rounded +minx305 minus 12345678901 -> -1.23456789E+10 Inexact Rounded +minx306 minus 1234567896 -> -1.23456790E+9 Inexact Rounded + +precision: 15 +-- still checking +minx321 minus 12345678000 -> -12345678000 +minx322 minus 1234567800 -> -1234567800 +minx323 minus 1234567890 -> -1234567890 +minx324 minus 1234567891 -> -1234567891 +minx325 minus 12345678901 -> -12345678901 +minx326 minus 1234567896 -> -1234567896 + +-- specials +minx420 minus 'Inf' -> '-Infinity' +minx421 minus '-Inf' -> 'Infinity' +minx422 minus NaN -> NaN +minx423 minus sNaN -> NaN Invalid_operation +minx424 minus NaN255 -> NaN255 +minx425 minus sNaN256 -> NaN256 Invalid_operation +minx426 minus -NaN -> -NaN +minx427 minus -sNaN -> -NaN Invalid_operation +minx428 minus -NaN255 -> -NaN255 +minx429 minus -sNaN256 -> -NaN256 Invalid_operation + +-- Null tests +minx900 minus # -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/multiply.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/multiply.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,651 @@ +------------------------------------------------------------------------ +-- multiply.decTest -- decimal multiplication -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- sanity checks (as base, above) +mulx000 multiply 2 2 -> 4 +mulx001 multiply 2 3 -> 6 +mulx002 multiply 5 1 -> 5 +mulx003 multiply 5 2 -> 10 +mulx004 multiply 1.20 2 -> 2.40 +mulx005 multiply 1.20 0 -> 0.00 +mulx006 multiply 1.20 -2 -> -2.40 +mulx007 multiply -1.20 2 -> -2.40 +mulx008 multiply -1.20 0 -> -0.00 +mulx009 multiply -1.20 -2 -> 2.40 +mulx010 multiply 5.09 7.1 -> 36.139 +mulx011 multiply 2.5 4 -> 10.0 +mulx012 multiply 2.50 4 -> 10.00 +mulx013 multiply 1.23456789 1.00000000 -> 1.23456789 Rounded +mulx014 multiply 9.999999999 9.999999999 -> 100.000000 Inexact Rounded +mulx015 multiply 2.50 4 -> 10.00 +precision: 6 +mulx016 multiply 2.50 4 -> 10.00 +mulx017 multiply 9.999999999 9.999999999 -> 100.000 Inexact Rounded + +-- 1999.12.21: next one is a edge case if intermediate longs are used +precision: 15 +mulx019 multiply 999999999999 9765625 -> 9.76562499999023E+18 Inexact Rounded +precision: 30 +mulx160 multiply 999999999999 9765625 -> 9765624999990234375 +precision: 9 +----- + +-- zeros, etc. +mulx020 multiply 0 0 -> 0 +mulx021 multiply 0 -0 -> -0 +mulx022 multiply -0 0 -> -0 +mulx023 multiply -0 -0 -> 0 +mulx030 multiply 5.00 1E-3 -> 0.00500 +mulx031 multiply 00.00 0.000 -> 0.00000 +mulx032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0 +mulx033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0 +mulx034 multiply -5.00 1E-3 -> -0.00500 +mulx035 multiply -00.00 0.000 -> -0.00000 +mulx036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0 +mulx037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0 +mulx038 multiply 5.00 -1E-3 -> -0.00500 +mulx039 multiply 00.00 -0.000 -> -0.00000 +mulx040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0 +mulx041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0 +mulx042 multiply -5.00 -1E-3 -> 0.00500 +mulx043 multiply -00.00 -0.000 -> 0.00000 +mulx044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0 +mulx045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0 + +-- examples from decarith +mulx050 multiply 1.20 3 -> 3.60 +mulx051 multiply 7 3 -> 21 +mulx052 multiply 0.9 0.8 -> 0.72 +mulx053 multiply 0.9 -0 -> -0.0 +mulx054 multiply 654321 654321 -> 4.28135971E+11 Inexact Rounded + +mulx060 multiply 123.45 1e7 -> 1.2345E+9 +mulx061 multiply 123.45 1e8 -> 1.2345E+10 +mulx062 multiply 123.45 1e+9 -> 1.2345E+11 +mulx063 multiply 123.45 1e10 -> 1.2345E+12 +mulx064 multiply 123.45 1e11 -> 1.2345E+13 +mulx065 multiply 123.45 1e12 -> 1.2345E+14 +mulx066 multiply 123.45 1e13 -> 1.2345E+15 + + +-- test some intermediate lengths +precision: 9 +mulx080 multiply 0.1 123456789 -> 12345678.9 +mulx081 multiply 0.1 1234567891 -> 123456789 Inexact Rounded +mulx082 multiply 0.1 12345678912 -> 1.23456789E+9 Inexact Rounded +mulx083 multiply 0.1 12345678912345 -> 1.23456789E+12 Inexact Rounded +mulx084 multiply 0.1 123456789 -> 12345678.9 +precision: 8 +mulx085 multiply 0.1 12345678912 -> 1.2345679E+9 Inexact Rounded +mulx086 multiply 0.1 12345678912345 -> 1.2345679E+12 Inexact Rounded +precision: 7 +mulx087 multiply 0.1 12345678912 -> 1.234568E+9 Inexact Rounded +mulx088 multiply 0.1 12345678912345 -> 1.234568E+12 Inexact Rounded + +precision: 9 +mulx090 multiply 123456789 0.1 -> 12345678.9 +mulx091 multiply 1234567891 0.1 -> 123456789 Inexact Rounded +mulx092 multiply 12345678912 0.1 -> 1.23456789E+9 Inexact Rounded +mulx093 multiply 12345678912345 0.1 -> 1.23456789E+12 Inexact Rounded +mulx094 multiply 123456789 0.1 -> 12345678.9 +precision: 8 +mulx095 multiply 12345678912 0.1 -> 1.2345679E+9 Inexact Rounded +mulx096 multiply 12345678912345 0.1 -> 1.2345679E+12 Inexact Rounded +precision: 7 +mulx097 multiply 12345678912 0.1 -> 1.234568E+9 Inexact Rounded +mulx098 multiply 12345678912345 0.1 -> 1.234568E+12 Inexact Rounded + +-- test some more edge cases and carries +maxexponent: 9999 +minexponent: -9999 +precision: 33 +mulx101 multiply 9 9 -> 81 +mulx102 multiply 9 90 -> 810 +mulx103 multiply 9 900 -> 8100 +mulx104 multiply 9 9000 -> 81000 +mulx105 multiply 9 90000 -> 810000 +mulx106 multiply 9 900000 -> 8100000 +mulx107 multiply 9 9000000 -> 81000000 +mulx108 multiply 9 90000000 -> 810000000 +mulx109 multiply 9 900000000 -> 8100000000 +mulx110 multiply 9 9000000000 -> 81000000000 +mulx111 multiply 9 90000000000 -> 810000000000 +mulx112 multiply 9 900000000000 -> 8100000000000 +mulx113 multiply 9 9000000000000 -> 81000000000000 +mulx114 multiply 9 90000000000000 -> 810000000000000 +mulx115 multiply 9 900000000000000 -> 8100000000000000 +mulx116 multiply 9 9000000000000000 -> 81000000000000000 +mulx117 multiply 9 90000000000000000 -> 810000000000000000 +mulx118 multiply 9 900000000000000000 -> 8100000000000000000 +mulx119 multiply 9 9000000000000000000 -> 81000000000000000000 +mulx120 multiply 9 90000000000000000000 -> 810000000000000000000 +mulx121 multiply 9 900000000000000000000 -> 8100000000000000000000 +mulx122 multiply 9 9000000000000000000000 -> 81000000000000000000000 +mulx123 multiply 9 90000000000000000000000 -> 810000000000000000000000 +-- test some more edge cases without carries +mulx131 multiply 3 3 -> 9 +mulx132 multiply 3 30 -> 90 +mulx133 multiply 3 300 -> 900 +mulx134 multiply 3 3000 -> 9000 +mulx135 multiply 3 30000 -> 90000 +mulx136 multiply 3 300000 -> 900000 +mulx137 multiply 3 3000000 -> 9000000 +mulx138 multiply 3 30000000 -> 90000000 +mulx139 multiply 3 300000000 -> 900000000 +mulx140 multiply 3 3000000000 -> 9000000000 +mulx141 multiply 3 30000000000 -> 90000000000 +mulx142 multiply 3 300000000000 -> 900000000000 +mulx143 multiply 3 3000000000000 -> 9000000000000 +mulx144 multiply 3 30000000000000 -> 90000000000000 +mulx145 multiply 3 300000000000000 -> 900000000000000 +mulx146 multiply 3 3000000000000000 -> 9000000000000000 +mulx147 multiply 3 30000000000000000 -> 90000000000000000 +mulx148 multiply 3 300000000000000000 -> 900000000000000000 +mulx149 multiply 3 3000000000000000000 -> 9000000000000000000 +mulx150 multiply 3 30000000000000000000 -> 90000000000000000000 +mulx151 multiply 3 300000000000000000000 -> 900000000000000000000 +mulx152 multiply 3 3000000000000000000000 -> 9000000000000000000000 +mulx153 multiply 3 30000000000000000000000 -> 90000000000000000000000 + +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +-- test some cases that are close to exponent overflow/underflow +mulx170 multiply 1 9e999999999 -> 9E+999999999 +mulx171 multiply 1 9.9e999999999 -> 9.9E+999999999 +mulx172 multiply 1 9.99e999999999 -> 9.99E+999999999 +mulx173 multiply 9e999999999 1 -> 9E+999999999 +mulx174 multiply 9.9e999999999 1 -> 9.9E+999999999 +mulx176 multiply 9.99e999999999 1 -> 9.99E+999999999 +mulx177 multiply 1 9.99999999e999999999 -> 9.99999999E+999999999 +mulx178 multiply 9.99999999e999999999 1 -> 9.99999999E+999999999 + +mulx180 multiply 0.1 9e-999999998 -> 9E-999999999 +mulx181 multiply 0.1 99e-999999998 -> 9.9E-999999998 +mulx182 multiply 0.1 999e-999999998 -> 9.99E-999999997 + +mulx183 multiply 0.1 9e-999999998 -> 9E-999999999 +mulx184 multiply 0.1 99e-999999998 -> 9.9E-999999998 +mulx185 multiply 0.1 999e-999999998 -> 9.99E-999999997 +mulx186 multiply 0.1 999e-999999997 -> 9.99E-999999996 +mulx187 multiply 0.1 9999e-999999997 -> 9.999E-999999995 +mulx188 multiply 0.1 99999e-999999997 -> 9.9999E-999999994 + +mulx190 multiply 1 9e-999999998 -> 9E-999999998 +mulx191 multiply 1 99e-999999998 -> 9.9E-999999997 +mulx192 multiply 1 999e-999999998 -> 9.99E-999999996 +mulx193 multiply 9e-999999998 1 -> 9E-999999998 +mulx194 multiply 99e-999999998 1 -> 9.9E-999999997 +mulx195 multiply 999e-999999998 1 -> 9.99E-999999996 + +mulx196 multiply 1e-599999999 1e-400000000 -> 1E-999999999 +mulx197 multiply 1e-600000000 1e-399999999 -> 1E-999999999 +mulx198 multiply 1.2e-599999999 1.2e-400000000 -> 1.44E-999999999 +mulx199 multiply 1.2e-600000000 1.2e-399999999 -> 1.44E-999999999 + +mulx201 multiply 1e599999999 1e400000000 -> 1E+999999999 +mulx202 multiply 1e600000000 1e399999999 -> 1E+999999999 +mulx203 multiply 1.2e599999999 1.2e400000000 -> 1.44E+999999999 +mulx204 multiply 1.2e600000000 1.2e399999999 -> 1.44E+999999999 + +-- long operand triangle +precision: 33 +mulx246 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511992830 Inexact Rounded +precision: 32 +mulx247 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199283 Inexact Rounded +precision: 31 +mulx248 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928 Inexact Rounded +precision: 30 +mulx249 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511993 Inexact Rounded +precision: 29 +mulx250 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199 Inexact Rounded +precision: 28 +mulx251 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165120 Inexact Rounded +precision: 27 +mulx252 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916512 Inexact Rounded +precision: 26 +mulx253 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651 Inexact Rounded +precision: 25 +mulx254 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165 Inexact Rounded +precision: 24 +mulx255 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671917 Inexact Rounded +precision: 23 +mulx256 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967192 Inexact Rounded +precision: 22 +mulx257 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719 Inexact Rounded +precision: 21 +mulx258 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369672 Inexact Rounded +precision: 20 +mulx259 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967 Inexact Rounded +precision: 19 +mulx260 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933697 Inexact Rounded +precision: 18 +mulx261 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193370 Inexact Rounded +precision: 17 +mulx262 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119337 Inexact Rounded +precision: 16 +mulx263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011934 Inexact Rounded +precision: 15 +mulx264 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193 Inexact Rounded +precision: 14 +mulx265 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119 Inexact Rounded +precision: 13 +mulx266 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908012 Inexact Rounded +precision: 12 +mulx267 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801 Inexact Rounded +precision: 11 +mulx268 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080 Inexact Rounded +precision: 10 +mulx269 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908 Inexact Rounded +precision: 9 +mulx270 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.291 Inexact Rounded +precision: 8 +mulx271 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29 Inexact Rounded +precision: 7 +mulx272 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.3 Inexact Rounded +precision: 6 +mulx273 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433 Inexact Rounded +precision: 5 +mulx274 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.4543E+5 Inexact Rounded +precision: 4 +mulx275 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.454E+5 Inexact Rounded +precision: 3 +mulx276 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.45E+5 Inexact Rounded +precision: 2 +mulx277 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.5E+5 Inexact Rounded +precision: 1 +mulx278 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1E+5 Inexact Rounded + +-- tryzeros cases +precision: 7 +rounding: half_up +maxExponent: 92 +minexponent: -92 +mulx504 multiply 0E-60 1000E-60 -> 0E-98 Clamped +mulx505 multiply 100E+60 0E+60 -> 0E+92 Clamped + +-- mixed with zeros +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +mulx541 multiply 0 -1 -> -0 +mulx542 multiply -0 -1 -> 0 +mulx543 multiply 0 1 -> 0 +mulx544 multiply -0 1 -> -0 +mulx545 multiply -1 0 -> -0 +mulx546 multiply -1 -0 -> 0 +mulx547 multiply 1 0 -> 0 +mulx548 multiply 1 -0 -> -0 + +mulx551 multiply 0.0 -1 -> -0.0 +mulx552 multiply -0.0 -1 -> 0.0 +mulx553 multiply 0.0 1 -> 0.0 +mulx554 multiply -0.0 1 -> -0.0 +mulx555 multiply -1.0 0 -> -0.0 +mulx556 multiply -1.0 -0 -> 0.0 +mulx557 multiply 1.0 0 -> 0.0 +mulx558 multiply 1.0 -0 -> -0.0 + +mulx561 multiply 0 -1.0 -> -0.0 +mulx562 multiply -0 -1.0 -> 0.0 +mulx563 multiply 0 1.0 -> 0.0 +mulx564 multiply -0 1.0 -> -0.0 +mulx565 multiply -1 0.0 -> -0.0 +mulx566 multiply -1 -0.0 -> 0.0 +mulx567 multiply 1 0.0 -> 0.0 +mulx568 multiply 1 -0.0 -> -0.0 + +mulx571 multiply 0.0 -1.0 -> -0.00 +mulx572 multiply -0.0 -1.0 -> 0.00 +mulx573 multiply 0.0 1.0 -> 0.00 +mulx574 multiply -0.0 1.0 -> -0.00 +mulx575 multiply -1.0 0.0 -> -0.00 +mulx576 multiply -1.0 -0.0 -> 0.00 +mulx577 multiply 1.0 0.0 -> 0.00 +mulx578 multiply 1.0 -0.0 -> -0.00 + + +-- Specials +mulx580 multiply Inf -Inf -> -Infinity +mulx581 multiply Inf -1000 -> -Infinity +mulx582 multiply Inf -1 -> -Infinity +mulx583 multiply Inf -0 -> NaN Invalid_operation +mulx584 multiply Inf 0 -> NaN Invalid_operation +mulx585 multiply Inf 1 -> Infinity +mulx586 multiply Inf 1000 -> Infinity +mulx587 multiply Inf Inf -> Infinity +mulx588 multiply -1000 Inf -> -Infinity +mulx589 multiply -Inf Inf -> -Infinity +mulx590 multiply -1 Inf -> -Infinity +mulx591 multiply -0 Inf -> NaN Invalid_operation +mulx592 multiply 0 Inf -> NaN Invalid_operation +mulx593 multiply 1 Inf -> Infinity +mulx594 multiply 1000 Inf -> Infinity +mulx595 multiply Inf Inf -> Infinity + +mulx600 multiply -Inf -Inf -> Infinity +mulx601 multiply -Inf -1000 -> Infinity +mulx602 multiply -Inf -1 -> Infinity +mulx603 multiply -Inf -0 -> NaN Invalid_operation +mulx604 multiply -Inf 0 -> NaN Invalid_operation +mulx605 multiply -Inf 1 -> -Infinity +mulx606 multiply -Inf 1000 -> -Infinity +mulx607 multiply -Inf Inf -> -Infinity +mulx608 multiply -1000 Inf -> -Infinity +mulx609 multiply -Inf -Inf -> Infinity +mulx610 multiply -1 -Inf -> Infinity +mulx611 multiply -0 -Inf -> NaN Invalid_operation +mulx612 multiply 0 -Inf -> NaN Invalid_operation +mulx613 multiply 1 -Inf -> -Infinity +mulx614 multiply 1000 -Inf -> -Infinity +mulx615 multiply Inf -Inf -> -Infinity + +mulx621 multiply NaN -Inf -> NaN +mulx622 multiply NaN -1000 -> NaN +mulx623 multiply NaN -1 -> NaN +mulx624 multiply NaN -0 -> NaN +mulx625 multiply NaN 0 -> NaN +mulx626 multiply NaN 1 -> NaN +mulx627 multiply NaN 1000 -> NaN +mulx628 multiply NaN Inf -> NaN +mulx629 multiply NaN NaN -> NaN +mulx630 multiply -Inf NaN -> NaN +mulx631 multiply -1000 NaN -> NaN +mulx632 multiply -1 NaN -> NaN +mulx633 multiply -0 NaN -> NaN +mulx634 multiply 0 NaN -> NaN +mulx635 multiply 1 NaN -> NaN +mulx636 multiply 1000 NaN -> NaN +mulx637 multiply Inf NaN -> NaN + +mulx641 multiply sNaN -Inf -> NaN Invalid_operation +mulx642 multiply sNaN -1000 -> NaN Invalid_operation +mulx643 multiply sNaN -1 -> NaN Invalid_operation +mulx644 multiply sNaN -0 -> NaN Invalid_operation +mulx645 multiply sNaN 0 -> NaN Invalid_operation +mulx646 multiply sNaN 1 -> NaN Invalid_operation +mulx647 multiply sNaN 1000 -> NaN Invalid_operation +mulx648 multiply sNaN NaN -> NaN Invalid_operation +mulx649 multiply sNaN sNaN -> NaN Invalid_operation +mulx650 multiply NaN sNaN -> NaN Invalid_operation +mulx651 multiply -Inf sNaN -> NaN Invalid_operation +mulx652 multiply -1000 sNaN -> NaN Invalid_operation +mulx653 multiply -1 sNaN -> NaN Invalid_operation +mulx654 multiply -0 sNaN -> NaN Invalid_operation +mulx655 multiply 0 sNaN -> NaN Invalid_operation +mulx656 multiply 1 sNaN -> NaN Invalid_operation +mulx657 multiply 1000 sNaN -> NaN Invalid_operation +mulx658 multiply Inf sNaN -> NaN Invalid_operation +mulx659 multiply NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +mulx661 multiply NaN9 -Inf -> NaN9 +mulx662 multiply NaN8 999 -> NaN8 +mulx663 multiply NaN71 Inf -> NaN71 +mulx664 multiply NaN6 NaN5 -> NaN6 +mulx665 multiply -Inf NaN4 -> NaN4 +mulx666 multiply -999 NaN33 -> NaN33 +mulx667 multiply Inf NaN2 -> NaN2 + +mulx671 multiply sNaN99 -Inf -> NaN99 Invalid_operation +mulx672 multiply sNaN98 -11 -> NaN98 Invalid_operation +mulx673 multiply sNaN97 NaN -> NaN97 Invalid_operation +mulx674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation +mulx675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation +mulx676 multiply -Inf sNaN92 -> NaN92 Invalid_operation +mulx677 multiply 088 sNaN91 -> NaN91 Invalid_operation +mulx678 multiply Inf sNaN90 -> NaN90 Invalid_operation +mulx679 multiply NaN sNaN89 -> NaN89 Invalid_operation + +mulx681 multiply -NaN9 -Inf -> -NaN9 +mulx682 multiply -NaN8 999 -> -NaN8 +mulx683 multiply -NaN71 Inf -> -NaN71 +mulx684 multiply -NaN6 -NaN5 -> -NaN6 +mulx685 multiply -Inf -NaN4 -> -NaN4 +mulx686 multiply -999 -NaN33 -> -NaN33 +mulx687 multiply Inf -NaN2 -> -NaN2 + +mulx691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation +mulx692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation +mulx693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation +mulx694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation +mulx695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation +mulx696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation +mulx697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation +mulx698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation +mulx699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation + +mulx701 multiply -NaN -Inf -> -NaN +mulx702 multiply -NaN 999 -> -NaN +mulx703 multiply -NaN Inf -> -NaN +mulx704 multiply -NaN -NaN -> -NaN +mulx705 multiply -Inf -NaN0 -> -NaN +mulx706 multiply -999 -NaN -> -NaN +mulx707 multiply Inf -NaN -> -NaN + +mulx711 multiply -sNaN -Inf -> -NaN Invalid_operation +mulx712 multiply -sNaN -11 -> -NaN Invalid_operation +mulx713 multiply -sNaN00 NaN -> -NaN Invalid_operation +mulx714 multiply -sNaN -sNaN -> -NaN Invalid_operation +mulx715 multiply -NaN -sNaN -> -NaN Invalid_operation +mulx716 multiply -Inf -sNaN -> -NaN Invalid_operation +mulx717 multiply 088 -sNaN -> -NaN Invalid_operation +mulx718 multiply Inf -sNaN -> -NaN Invalid_operation +mulx719 multiply -NaN -sNaN -> -NaN Invalid_operation + +-- overflow and underflow tests .. note subnormal results +maxexponent: 999999999 +minexponent: -999999999 +mulx730 multiply +1.23456789012345E-0 9E+999999999 -> Infinity Inexact Overflow Rounded +mulx731 multiply 9E+999999999 +1.23456789012345E-0 -> Infinity Inexact Overflow Rounded +mulx732 multiply +0.100 9E-999999999 -> 9.00E-1000000000 Subnormal +mulx733 multiply 9E-999999999 +0.100 -> 9.00E-1000000000 Subnormal +mulx735 multiply -1.23456789012345E-0 9E+999999999 -> -Infinity Inexact Overflow Rounded +mulx736 multiply 9E+999999999 -1.23456789012345E-0 -> -Infinity Inexact Overflow Rounded +mulx737 multiply -0.100 9E-999999999 -> -9.00E-1000000000 Subnormal +mulx738 multiply 9E-999999999 -0.100 -> -9.00E-1000000000 Subnormal + +mulx739 multiply 1e-599999999 1e-400000001 -> 1E-1000000000 Subnormal +mulx740 multiply 1e-599999999 1e-400000000 -> 1E-999999999 +mulx741 multiply 1e-600000000 1e-400000000 -> 1E-1000000000 Subnormal +mulx742 multiply 9e-999999998 0.01 -> 9E-1000000000 Subnormal +mulx743 multiply 9e-999999998 0.1 -> 9E-999999999 +mulx744 multiply 0.01 9e-999999998 -> 9E-1000000000 Subnormal +mulx745 multiply 1e599999999 1e400000001 -> Infinity Overflow Inexact Rounded +mulx746 multiply 1e599999999 1e400000000 -> 1E+999999999 +mulx747 multiply 1e600000000 1e400000000 -> Infinity Overflow Inexact Rounded +mulx748 multiply 9e999999998 100 -> Infinity Overflow Inexact Rounded +mulx749 multiply 9e999999998 10 -> 9.0E+999999999 +mulx750 multiply 100 9e999999998 -> Infinity Overflow Inexact Rounded +-- signs +mulx751 multiply 1e+777777777 1e+411111111 -> Infinity Overflow Inexact Rounded +mulx752 multiply 1e+777777777 -1e+411111111 -> -Infinity Overflow Inexact Rounded +mulx753 multiply -1e+777777777 1e+411111111 -> -Infinity Overflow Inexact Rounded +mulx754 multiply -1e+777777777 -1e+411111111 -> Infinity Overflow Inexact Rounded +mulx755 multiply 1e-777777777 1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +mulx756 multiply 1e-777777777 -1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +mulx757 multiply -1e-777777777 1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +mulx758 multiply -1e-777777777 -1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded + +-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic) +precision: 9 +mulx760 multiply 1e-600000000 1e-400000001 -> 1E-1000000001 Subnormal +mulx761 multiply 1e-600000000 1e-400000002 -> 1E-1000000002 Subnormal +mulx762 multiply 1e-600000000 1e-400000003 -> 1E-1000000003 Subnormal +mulx763 multiply 1e-600000000 1e-400000004 -> 1E-1000000004 Subnormal +mulx764 multiply 1e-600000000 1e-400000005 -> 1E-1000000005 Subnormal +mulx765 multiply 1e-600000000 1e-400000006 -> 1E-1000000006 Subnormal +mulx766 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal +mulx767 multiply 1e-600000000 1e-400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +mulx768 multiply 1e-600000000 1e-400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +mulx769 multiply 1e-600000000 1e-400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +-- [no equivalent of 'subnormal' for overflow] +mulx770 multiply 1e+600000000 1e+400000001 -> Infinity Overflow Inexact Rounded +mulx771 multiply 1e+600000000 1e+400000002 -> Infinity Overflow Inexact Rounded +mulx772 multiply 1e+600000000 1e+400000003 -> Infinity Overflow Inexact Rounded +mulx773 multiply 1e+600000000 1e+400000004 -> Infinity Overflow Inexact Rounded +mulx774 multiply 1e+600000000 1e+400000005 -> Infinity Overflow Inexact Rounded +mulx775 multiply 1e+600000000 1e+400000006 -> Infinity Overflow Inexact Rounded +mulx776 multiply 1e+600000000 1e+400000007 -> Infinity Overflow Inexact Rounded +mulx777 multiply 1e+600000000 1e+400000008 -> Infinity Overflow Inexact Rounded +mulx778 multiply 1e+600000000 1e+400000009 -> Infinity Overflow Inexact Rounded +mulx779 multiply 1e+600000000 1e+400000010 -> Infinity Overflow Inexact Rounded + +-- 'subnormal' test edge condition at higher precisions +precision: 99 +mulx780 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal +mulx781 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal +mulx782 multiply 1e-600000000 1e-400000097 -> 1E-1000000097 Subnormal +mulx783 multiply 1e-600000000 1e-400000098 -> 0E-1000000097 Underflow Subnormal Inexact Rounded +precision: 999 +mulx784 multiply 1e-600000000 1e-400000997 -> 1E-1000000997 Subnormal +mulx785 multiply 1e-600000000 1e-400000998 -> 0E-1000000997 Underflow Subnormal Inexact Rounded + +-- following testcases [through mulx800] not yet run against code +precision: 9999 +mulx786 multiply 1e-600000000 1e-400009997 -> 1E-1000009997 Subnormal +mulx787 multiply 1e-600000000 1e-400009998 -> 0E-1000009997 Underflow Subnormal Inexact Rounded +precision: 99999 +mulx788 multiply 1e-600000000 1e-400099997 -> 1E-1000099997 Subnormal +mulx789 multiply 1e-600000000 1e-400099998 -> 0E-1000099997 Underflow Subnormal Inexact Rounded +precision: 999999 +mulx790 multiply 1e-600000000 1e-400999997 -> 1E-1000999997 Subnormal +mulx791 multiply 1e-600000000 1e-400999998 -> 0E-1000999997 Underflow Subnormal Inexact Rounded +precision: 9999999 +mulx792 multiply 1e-600000000 1e-409999997 -> 1E-1009999997 Subnormal +mulx793 multiply 1e-600000000 1e-409999998 -> 0E-1009999997 Underflow Subnormal Inexact Rounded +precision: 99999999 +mulx794 multiply 1e-600000000 1e-499999997 -> 1E-1099999997 Subnormal +mulx795 multiply 1e-600000000 1e-499999998 -> 0E-1099999997 Underflow Subnormal Inexact Rounded +precision: 999999999 +mulx796 multiply 1e-999999999 1e-999999997 -> 1E-1999999996 Subnormal +mulx797 multiply 1e-999999999 1e-999999998 -> 1E-1999999997 Subnormal +mulx798 multiply 1e-999999999 1e-999999999 -> 0E-1999999997 Underflow Subnormal Inexact Rounded +mulx799 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal +mulx800 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal + +-- test subnormals rounding +precision: 5 +maxExponent: 999 +minexponent: -999 +rounding: half_even + +mulx801 multiply 1.0000E-999 1 -> 1.0000E-999 +mulx802 multiply 1.000E-999 1e-1 -> 1.000E-1000 Subnormal +mulx803 multiply 1.00E-999 1e-2 -> 1.00E-1001 Subnormal +mulx804 multiply 1.0E-999 1e-3 -> 1.0E-1002 Subnormal +mulx805 multiply 1.0E-999 1e-4 -> 1E-1003 Subnormal Rounded +mulx806 multiply 1.3E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded +mulx807 multiply 1.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx808 multiply 1.7E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx809 multiply 2.3E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx810 multiply 2.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx811 multiply 2.7E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded +mulx812 multiply 1.49E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded +mulx813 multiply 1.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx814 multiply 1.51E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx815 multiply 2.49E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx816 multiply 2.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded +mulx817 multiply 2.51E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded + +mulx818 multiply 1E-999 1e-4 -> 1E-1003 Subnormal +mulx819 multiply 3E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded +mulx820 multiply 5E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded +mulx821 multiply 7E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded +mulx822 multiply 9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded +mulx823 multiply 9.9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded + +mulx824 multiply 1E-999 -1e-4 -> -1E-1003 Subnormal +mulx825 multiply 3E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded +mulx826 multiply -5E-999 1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded +mulx827 multiply 7E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded +mulx828 multiply -9E-999 1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded +mulx829 multiply 9.9E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded +mulx830 multiply 3.0E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded + +mulx831 multiply 1.0E-501 1e-501 -> 1.0E-1002 Subnormal +mulx832 multiply 2.0E-501 2e-501 -> 4.0E-1002 Subnormal +mulx833 multiply 4.0E-501 4e-501 -> 1.60E-1001 Subnormal +mulx834 multiply 10.0E-501 10e-501 -> 1.000E-1000 Subnormal +mulx835 multiply 30.0E-501 30e-501 -> 9.000E-1000 Subnormal +mulx836 multiply 40.0E-501 40e-501 -> 1.6000E-999 + +-- squares +mulx840 multiply 1E-502 1e-502 -> 0E-1003 Underflow Subnormal Inexact Rounded +mulx841 multiply 1E-501 1e-501 -> 1E-1002 Subnormal +mulx842 multiply 2E-501 2e-501 -> 4E-1002 Subnormal +mulx843 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal +mulx844 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal +mulx845 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal +mulx846 multiply 40E-501 40e-501 -> 1.600E-999 + +-- cubes +mulx850 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded +mulx851 multiply 1E-668 1e-334 -> 1E-1002 Subnormal +mulx852 multiply 4E-668 2e-334 -> 8E-1002 Subnormal +mulx853 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal +mulx854 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal +mulx855 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal +mulx856 multiply 10E-668 100e-334 -> 1.000E-999 + +-- test from 0.099 ** 999 at 15 digits +precision: 19 +mulx860 multiply 6636851557994578716E-520 6636851557994578716E-520 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded + +-- Long operand overflow may be a different path +precision: 3 +maxExponent: 999999999 +minexponent: -999999999 +mulx870 multiply 1 9.999E+999999999 -> Infinity Inexact Overflow Rounded +mulx871 multiply 1 -9.999E+999999999 -> -Infinity Inexact Overflow Rounded +mulx872 multiply 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded +mulx873 multiply -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +mulx881 multiply 1.2347E-40 1.2347E-40 -> 1.524E-80 Inexact Rounded Subnormal Underflow +mulx882 multiply 1.234E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow +mulx883 multiply 1.23E-40 1.23E-40 -> 1.513E-80 Inexact Rounded Subnormal Underflow +mulx884 multiply 1.2E-40 1.2E-40 -> 1.44E-80 Subnormal +mulx885 multiply 1.2E-40 1.2E-41 -> 1.44E-81 Subnormal +mulx886 multiply 1.2E-40 1.2E-42 -> 1.4E-82 Subnormal Inexact Rounded Underflow +mulx887 multiply 1.2E-40 1.3E-42 -> 1.6E-82 Subnormal Inexact Rounded Underflow +mulx888 multiply 1.3E-40 1.3E-42 -> 1.7E-82 Subnormal Inexact Rounded Underflow + +mulx891 multiply 1.2345E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded +mulx892 multiply 1.23456E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded +mulx893 multiply 1.2345E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow +mulx894 multiply 1.23456E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow +mulx895 multiply 1.2345E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow +mulx896 multiply 1.23456E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow + +-- Null tests +mulx900 multiply 10 # -> NaN Invalid_operation +mulx901 multiply # 10 -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/normalize.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/normalize.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,225 @@ +------------------------------------------------------------------------ +-- normalize.decTest -- remove trailing zeros -- +-- Copyright (c) IBM Corporation, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +nrmx001 normalize '1' -> '1' +nrmx002 normalize '-1' -> '-1' +nrmx003 normalize '1.00' -> '1' +nrmx004 normalize '-1.00' -> '-1' +nrmx005 normalize '0' -> '0' +nrmx006 normalize '0.00' -> '0' +nrmx007 normalize '00.0' -> '0' +nrmx008 normalize '00.00' -> '0' +nrmx009 normalize '00' -> '0' +nrmx010 normalize '0E+1' -> '0' +nrmx011 normalize '0E+5' -> '0' + +nrmx012 normalize '-2' -> '-2' +nrmx013 normalize '2' -> '2' +nrmx014 normalize '-2.00' -> '-2' +nrmx015 normalize '2.00' -> '2' +nrmx016 normalize '-0' -> '-0' +nrmx017 normalize '-0.00' -> '-0' +nrmx018 normalize '-00.0' -> '-0' +nrmx019 normalize '-00.00' -> '-0' +nrmx020 normalize '-00' -> '-0' +nrmx021 normalize '-0E+5' -> '-0' +nrmx022 normalize '-0E+1' -> '-0' + +nrmx030 normalize '+0.1' -> '0.1' +nrmx031 normalize '-0.1' -> '-0.1' +nrmx032 normalize '+0.01' -> '0.01' +nrmx033 normalize '-0.01' -> '-0.01' +nrmx034 normalize '+0.001' -> '0.001' +nrmx035 normalize '-0.001' -> '-0.001' +nrmx036 normalize '+0.000001' -> '0.000001' +nrmx037 normalize '-0.000001' -> '-0.000001' +nrmx038 normalize '+0.000000000001' -> '1E-12' +nrmx039 normalize '-0.000000000001' -> '-1E-12' + +nrmx041 normalize 1.1 -> 1.1 +nrmx042 normalize 1.10 -> 1.1 +nrmx043 normalize 1.100 -> 1.1 +nrmx044 normalize 1.110 -> 1.11 +nrmx045 normalize -1.1 -> -1.1 +nrmx046 normalize -1.10 -> -1.1 +nrmx047 normalize -1.100 -> -1.1 +nrmx048 normalize -1.110 -> -1.11 +nrmx049 normalize 9.9 -> 9.9 +nrmx050 normalize 9.90 -> 9.9 +nrmx051 normalize 9.900 -> 9.9 +nrmx052 normalize 9.990 -> 9.99 +nrmx053 normalize -9.9 -> -9.9 +nrmx054 normalize -9.90 -> -9.9 +nrmx055 normalize -9.900 -> -9.9 +nrmx056 normalize -9.990 -> -9.99 + +-- some trailing fractional zeros with zeros in units +nrmx060 normalize 10.0 -> 1E+1 +nrmx061 normalize 10.00 -> 1E+1 +nrmx062 normalize 100.0 -> 1E+2 +nrmx063 normalize 100.00 -> 1E+2 +nrmx064 normalize 1.1000E+3 -> 1.1E+3 +nrmx065 normalize 1.10000E+3 -> 1.1E+3 +nrmx066 normalize -10.0 -> -1E+1 +nrmx067 normalize -10.00 -> -1E+1 +nrmx068 normalize -100.0 -> -1E+2 +nrmx069 normalize -100.00 -> -1E+2 +nrmx070 normalize -1.1000E+3 -> -1.1E+3 +nrmx071 normalize -1.10000E+3 -> -1.1E+3 + +-- some insignificant trailing zeros with positive exponent +nrmx080 normalize 10E+1 -> 1E+2 +nrmx081 normalize 100E+1 -> 1E+3 +nrmx082 normalize 1.0E+2 -> 1E+2 +nrmx083 normalize 1.0E+3 -> 1E+3 +nrmx084 normalize 1.1E+3 -> 1.1E+3 +nrmx085 normalize 1.00E+3 -> 1E+3 +nrmx086 normalize 1.10E+3 -> 1.1E+3 +nrmx087 normalize -10E+1 -> -1E+2 +nrmx088 normalize -100E+1 -> -1E+3 +nrmx089 normalize -1.0E+2 -> -1E+2 +nrmx090 normalize -1.0E+3 -> -1E+3 +nrmx091 normalize -1.1E+3 -> -1.1E+3 +nrmx092 normalize -1.00E+3 -> -1E+3 +nrmx093 normalize -1.10E+3 -> -1.1E+3 + +-- some significant trailing zeros, were we to be trimming +nrmx100 normalize 11 -> 11 +nrmx101 normalize 10 -> 1E+1 +nrmx102 normalize 10. -> 1E+1 +nrmx103 normalize 1.1E+1 -> 11 +nrmx104 normalize 1.0E+1 -> 1E+1 +nrmx105 normalize 1.10E+2 -> 1.1E+2 +nrmx106 normalize 1.00E+2 -> 1E+2 +nrmx107 normalize 1.100E+3 -> 1.1E+3 +nrmx108 normalize 1.000E+3 -> 1E+3 +nrmx109 normalize 1.000000E+6 -> 1E+6 +nrmx110 normalize -11 -> -11 +nrmx111 normalize -10 -> -1E+1 +nrmx112 normalize -10. -> -1E+1 +nrmx113 normalize -1.1E+1 -> -11 +nrmx114 normalize -1.0E+1 -> -1E+1 +nrmx115 normalize -1.10E+2 -> -1.1E+2 +nrmx116 normalize -1.00E+2 -> -1E+2 +nrmx117 normalize -1.100E+3 -> -1.1E+3 +nrmx118 normalize -1.000E+3 -> -1E+3 +nrmx119 normalize -1.00000E+5 -> -1E+5 +nrmx120 normalize -1.000000E+6 -> -1E+6 +nrmx121 normalize -10.00000E+6 -> -1E+7 +nrmx122 normalize -100.0000E+6 -> -1E+8 +nrmx123 normalize -1000.000E+6 -> -1E+9 +nrmx124 normalize -10000.00E+6 -> -1E+10 +nrmx125 normalize -100000.0E+6 -> -1E+11 +nrmx126 normalize -1000000.E+6 -> -1E+12 + +-- examples from decArith +nrmx140 normalize '2.1' -> '2.1' +nrmx141 normalize '-2.0' -> '-2' +nrmx142 normalize '1.200' -> '1.2' +nrmx143 normalize '-120' -> '-1.2E+2' +nrmx144 normalize '120.00' -> '1.2E+2' +nrmx145 normalize '0.00' -> '0' + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +nrmx160 normalize 9.999E+999999999 -> Infinity Inexact Overflow Rounded +nrmx161 normalize -9.999E+999999999 -> -Infinity Inexact Overflow Rounded + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +nrmx210 normalize 1.00E-999 -> 1E-999 +nrmx211 normalize 0.1E-999 -> 1E-1000 Subnormal +nrmx212 normalize 0.10E-999 -> 1E-1000 Subnormal +nrmx213 normalize 0.100E-999 -> 1E-1000 Subnormal Rounded +nrmx214 normalize 0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +nrmx215 normalize 0.999E-999 -> 1E-999 Inexact Rounded Subnormal Underflow +nrmx216 normalize 0.099E-999 -> 1E-1000 Inexact Rounded Subnormal Underflow +nrmx217 normalize 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +nrmx218 normalize 0.001E-999 -> 0 Inexact Rounded Subnormal Underflow +nrmx219 normalize 0.0009E-999 -> 0 Inexact Rounded Subnormal Underflow +nrmx220 normalize 0.0001E-999 -> 0 Inexact Rounded Subnormal Underflow + +nrmx230 normalize -1.00E-999 -> -1E-999 +nrmx231 normalize -0.1E-999 -> -1E-1000 Subnormal +nrmx232 normalize -0.10E-999 -> -1E-1000 Subnormal +nrmx233 normalize -0.100E-999 -> -1E-1000 Subnormal Rounded +nrmx234 normalize -0.01E-999 -> -1E-1001 Subnormal +-- next is rounded to Emin +nrmx235 normalize -0.999E-999 -> -1E-999 Inexact Rounded Subnormal Underflow +nrmx236 normalize -0.099E-999 -> -1E-1000 Inexact Rounded Subnormal Underflow +nrmx237 normalize -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow +nrmx238 normalize -0.001E-999 -> -0 Inexact Rounded Subnormal Underflow +nrmx239 normalize -0.0009E-999 -> -0 Inexact Rounded Subnormal Underflow +nrmx240 normalize -0.0001E-999 -> -0 Inexact Rounded Subnormal Underflow + +-- more reshaping +precision: 9 +nrmx260 normalize '56260E-10' -> '0.000005626' +nrmx261 normalize '56260E-5' -> '0.5626' +nrmx262 normalize '56260E-2' -> '562.6' +nrmx263 normalize '56260E-1' -> '5626' +nrmx265 normalize '56260E-0' -> '5.626E+4' +nrmx266 normalize '56260E+0' -> '5.626E+4' +nrmx267 normalize '56260E+1' -> '5.626E+5' +nrmx268 normalize '56260E+2' -> '5.626E+6' +nrmx269 normalize '56260E+3' -> '5.626E+7' +nrmx270 normalize '56260E+4' -> '5.626E+8' +nrmx271 normalize '56260E+5' -> '5.626E+9' +nrmx272 normalize '56260E+6' -> '5.626E+10' +nrmx280 normalize '-56260E-10' -> '-0.000005626' +nrmx281 normalize '-56260E-5' -> '-0.5626' +nrmx282 normalize '-56260E-2' -> '-562.6' +nrmx283 normalize '-56260E-1' -> '-5626' +nrmx285 normalize '-56260E-0' -> '-5.626E+4' +nrmx286 normalize '-56260E+0' -> '-5.626E+4' +nrmx287 normalize '-56260E+1' -> '-5.626E+5' +nrmx288 normalize '-56260E+2' -> '-5.626E+6' +nrmx289 normalize '-56260E+3' -> '-5.626E+7' +nrmx290 normalize '-56260E+4' -> '-5.626E+8' +nrmx291 normalize '-56260E+5' -> '-5.626E+9' +nrmx292 normalize '-56260E+6' -> '-5.626E+10' + + +-- specials +nrmx820 normalize 'Inf' -> 'Infinity' +nrmx821 normalize '-Inf' -> '-Infinity' +nrmx822 normalize NaN -> NaN +nrmx823 normalize sNaN -> NaN Invalid_operation +nrmx824 normalize NaN101 -> NaN101 +nrmx825 normalize sNaN010 -> NaN10 Invalid_operation +nrmx827 normalize -NaN -> -NaN +nrmx828 normalize -sNaN -> -NaN Invalid_operation +nrmx829 normalize -NaN101 -> -NaN101 +nrmx830 normalize -sNaN010 -> -NaN10 Invalid_operation + +-- Null test +nrmx900 normalize # -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/plus.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/plus.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,181 @@ +------------------------------------------------------------------------ +-- plus.decTest -- decimal monadic addition -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests primarily tests the existence of the operator. +-- Addition and rounding, and most overflows, are tested elsewhere. + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +plux001 plus '1' -> '1' +plux002 plus '-1' -> '-1' +plux003 plus '1.00' -> '1.00' +plux004 plus '-1.00' -> '-1.00' +plux005 plus '0' -> '0' +plux006 plus '0.00' -> '0.00' +plux007 plus '00.0' -> '0.0' +plux008 plus '00.00' -> '0.00' +plux009 plus '00' -> '0' + +plux010 plus '-2' -> '-2' +plux011 plus '2' -> '2' +plux012 plus '-2.00' -> '-2.00' +plux013 plus '2.00' -> '2.00' +plux014 plus '-0' -> '0' +plux015 plus '-0.00' -> '0.00' +plux016 plus '-00.0' -> '0.0' +plux017 plus '-00.00' -> '0.00' +plux018 plus '-00' -> '0' + +plux020 plus '-2000000' -> '-2000000' +plux021 plus '2000000' -> '2000000' +precision: 7 +plux022 plus '-2000000' -> '-2000000' +plux023 plus '2000000' -> '2000000' +precision: 6 +plux024 plus '-2000000' -> '-2.00000E+6' Rounded +plux025 plus '2000000' -> '2.00000E+6' Rounded +precision: 3 +plux026 plus '-2000000' -> '-2.00E+6' Rounded +plux027 plus '2000000' -> '2.00E+6' Rounded + +-- more fixed, potential LHS swaps if done by add 0 +precision: 9 +plux060 plus '56267E-10' -> '0.0000056267' +plux061 plus '56267E-5' -> '0.56267' +plux062 plus '56267E-2' -> '562.67' +plux063 plus '56267E-1' -> '5626.7' +plux065 plus '56267E-0' -> '56267' +plux066 plus '56267E+0' -> '56267' +plux067 plus '56267E+1' -> '5.6267E+5' +plux068 plus '56267E+2' -> '5.6267E+6' +plux069 plus '56267E+3' -> '5.6267E+7' +plux070 plus '56267E+4' -> '5.6267E+8' +plux071 plus '56267E+5' -> '5.6267E+9' +plux072 plus '56267E+6' -> '5.6267E+10' +plux080 plus '-56267E-10' -> '-0.0000056267' +plux081 plus '-56267E-5' -> '-0.56267' +plux082 plus '-56267E-2' -> '-562.67' +plux083 plus '-56267E-1' -> '-5626.7' +plux085 plus '-56267E-0' -> '-56267' +plux086 plus '-56267E+0' -> '-56267' +plux087 plus '-56267E+1' -> '-5.6267E+5' +plux088 plus '-56267E+2' -> '-5.6267E+6' +plux089 plus '-56267E+3' -> '-5.6267E+7' +plux090 plus '-56267E+4' -> '-5.6267E+8' +plux091 plus '-56267E+5' -> '-5.6267E+9' +plux092 plus '-56267E+6' -> '-5.6267E+10' + +-- "lhs" zeros in plus and minus have exponent = operand +plux120 plus '-0E3' -> '0E+3' +plux121 plus '-0E2' -> '0E+2' +plux122 plus '-0E1' -> '0E+1' +plux123 plus '-0E0' -> '0' +plux124 plus '+0E0' -> '0' +plux125 plus '+0E1' -> '0E+1' +plux126 plus '+0E2' -> '0E+2' +plux127 plus '+0E3' -> '0E+3' + +plux130 plus '-5E3' -> '-5E+3' +plux131 plus '-5E8' -> '-5E+8' +plux132 plus '-5E13' -> '-5E+13' +plux133 plus '-5E18' -> '-5E+18' +plux134 plus '+5E3' -> '5E+3' +plux135 plus '+5E8' -> '5E+8' +plux136 plus '+5E13' -> '5E+13' +plux137 plus '+5E18' -> '5E+18' + +-- specials +plux150 plus 'Inf' -> 'Infinity' +plux151 plus '-Inf' -> '-Infinity' +plux152 plus NaN -> NaN +plux153 plus sNaN -> NaN Invalid_operation +plux154 plus NaN77 -> NaN77 +plux155 plus sNaN88 -> NaN88 Invalid_operation +plux156 plus -NaN -> -NaN +plux157 plus -sNaN -> -NaN Invalid_operation +plux158 plus -NaN77 -> -NaN77 +plux159 plus -sNaN88 -> -NaN88 Invalid_operation + +-- overflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 3 +plux160 plus 9.999E+999999999 -> Infinity Inexact Overflow Rounded +plux161 plus -9.999E+999999999 -> -Infinity Inexact Overflow Rounded + +-- subnormals and underflow +precision: 3 +maxexponent: 999 +minexponent: -999 +plux210 plus 1.00E-999 -> 1.00E-999 +plux211 plus 0.1E-999 -> 1E-1000 Subnormal +plux212 plus 0.10E-999 -> 1.0E-1000 Subnormal +plux213 plus 0.100E-999 -> 1.0E-1000 Subnormal Rounded +plux214 plus 0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +plux215 plus 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow +plux216 plus 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +plux217 plus 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +plux218 plus 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +plux219 plus 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +plux220 plus 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow + +plux230 plus -1.00E-999 -> -1.00E-999 +plux231 plus -0.1E-999 -> -1E-1000 Subnormal +plux232 plus -0.10E-999 -> -1.0E-1000 Subnormal +plux233 plus -0.100E-999 -> -1.0E-1000 Subnormal Rounded +plux234 plus -0.01E-999 -> -1E-1001 Subnormal +-- next is rounded to Emin +plux235 plus -0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow +plux236 plus -0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +plux237 plus -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow +plux238 plus -0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +plux239 plus -0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +plux240 plus -0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +plux301 plus 12345678000 -> 1.23456780E+10 Rounded +plux302 plus 1234567800 -> 1.23456780E+9 Rounded +plux303 plus 1234567890 -> 1.23456789E+9 Rounded +plux304 plus 1234567891 -> 1.23456789E+9 Inexact Rounded +plux305 plus 12345678901 -> 1.23456789E+10 Inexact Rounded +plux306 plus 1234567896 -> 1.23456790E+9 Inexact Rounded + +-- still checking +precision: 15 +plux321 plus 12345678000 -> 12345678000 +plux322 plus 1234567800 -> 1234567800 +plux323 plus 1234567890 -> 1234567890 +plux324 plus 1234567891 -> 1234567891 +plux325 plus 12345678901 -> 12345678901 +plux326 plus 1234567896 -> 1234567896 +precision: 9 + +-- Null tests +plu900 plus # -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/power.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/power.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,651 @@ +---------------------------------------------------------------------- +-- power.decTest -- decimal exponentiation -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of testcases tests raising numbers to an integer power only. +-- If arbitrary powers were supported, 1 ulp differences would be +-- permitted. + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- base checks. Note 0**0 is an error. +powx001 power '0' '0' -> NaN Invalid_operation +powx002 power '0' '1' -> '0' +powx003 power '0' '2' -> '0' +powx004 power '1' '0' -> '1' +powx005 power '1' '1' -> '1' +powx006 power '1' '2' -> '1' + +powx010 power '2' '0' -> '1' +powx011 power '2' '1' -> '2' +powx012 power '2' '2' -> '4' +powx013 power '2' '3' -> '8' +powx014 power '2' '4' -> '16' +powx015 power '2' '5' -> '32' +powx016 power '2' '6' -> '64' +powx017 power '2' '7' -> '128' +powx018 power '2' '8' -> '256' +powx019 power '2' '9' -> '512' +powx020 power '2' '10' -> '1024' +powx021 power '2' '11' -> '2048' +powx022 power '2' '12' -> '4096' +powx023 power '2' '15' -> '32768' +powx024 power '2' '16' -> '65536' +powx025 power '2' '31' -> '2.14748365E+9' Inexact Rounded +-- NB 0 not stripped in next +powx026 power '2' '32' -> '4.29496730E+9' Inexact Rounded +precision: 10 +powx027 power '2' '31' -> '2147483648' +powx028 power '2' '32' -> '4294967296' +precision: 9 + +powx030 power '3' '2' -> 9 +powx031 power '4' '2' -> 16 +powx032 power '5' '2' -> 25 +powx033 power '6' '2' -> 36 +powx034 power '7' '2' -> 49 +powx035 power '8' '2' -> 64 +powx036 power '9' '2' -> 81 +powx037 power '10' '2' -> 100 +powx038 power '11' '2' -> 121 +powx039 power '12' '2' -> 144 + +powx040 power '3' '3' -> 27 +powx041 power '4' '3' -> 64 +powx042 power '5' '3' -> 125 +powx043 power '6' '3' -> 216 +powx044 power '7' '3' -> 343 + +powx050 power '10' '0' -> 1 +powx051 power '10' '1' -> 10 +powx052 power '10' '2' -> 100 +powx053 power '10' '3' -> 1000 +powx054 power '10' '4' -> 10000 +powx055 power '10' '5' -> 100000 +powx056 power '10' '6' -> 1000000 +powx057 power '10' '7' -> 10000000 +powx058 power '10' '8' -> 100000000 +powx059 power '10' '9' -> 1.00000000E+9 Rounded +powx060 power '10' '22' -> 1.00000000E+22 Rounded +powx061 power '10' '77' -> 1.00000000E+77 Rounded +powx062 power '10' '99' -> 1.00000000E+99 Rounded + +maxexponent: 999999999 +minexponent: -999999999 +powx063 power '10' '999999999' -> '1.00000000E+999999999' Rounded +powx064 power '10' '999999998' -> '1.00000000E+999999998' Rounded +powx065 power '10' '999999997' -> '1.00000000E+999999997' Rounded +powx066 power '10' '333333333' -> '1.00000000E+333333333' Rounded + +powx070 power '0.3' '0' -> '1' +powx071 power '0.3' '1' -> '0.3' +powx072 power '0.3' '1.00' -> '0.3' +powx073 power '0.3' '2.00' -> '0.09' +powx074 power '0.3' '2.000000000' -> '0.09' +powx075 power '6.0' '1' -> '6.0' -- NB zeros not stripped +powx076 power '6.0' '2' -> '36.00' -- .. +powx077 power '-3' '2' -> '9' -- from NetRexx book +powx078 power '4' '3' -> '64' -- .. (sort of) + +powx080 power 0.1 0 -> 1 +powx081 power 0.1 1 -> 0.1 +powx082 power 0.1 2 -> 0.01 +powx083 power 0.1 3 -> 0.001 +powx084 power 0.1 4 -> 0.0001 +powx085 power 0.1 5 -> 0.00001 +powx086 power 0.1 6 -> 0.000001 +powx087 power 0.1 7 -> 1E-7 +powx088 power 0.1 8 -> 1E-8 +powx089 power 0.1 9 -> 1E-9 + +powx090 power 101 2 -> 10201 +powx091 power 101 3 -> 1030301 +powx092 power 101 4 -> 104060401 +powx093 power 101 5 -> 1.05101005E+10 Inexact Rounded +powx094 power 101 6 -> 1.06152015E+12 Inexact Rounded +powx095 power 101 7 -> 1.07213535E+14 Inexact Rounded + +-- negative powers +powx101 power '2' '-1' -> 0.5 +powx102 power '2' '-2' -> 0.25 +powx103 power '2' '-4' -> 0.0625 +powx104 power '2' '-8' -> 0.00390625 +powx105 power '2' '-16' -> 0.0000152587891 Inexact Rounded +powx106 power '2' '-32' -> 2.32830644E-10 Inexact Rounded +powx108 power '2' '-64' -> 5.42101086E-20 Inexact Rounded +powx110 power '10' '-8' -> 1E-8 +powx111 power '10' '-7' -> 1E-7 +powx112 power '10' '-6' -> 0.000001 +powx113 power '10' '-5' -> 0.00001 +powx114 power '10' '-4' -> 0.0001 +powx115 power '10' '-3' -> 0.001 +powx116 power '10' '-2' -> 0.01 +powx117 power '10' '-1' -> 0.1 + +powx118 power '10' '-333333333' -> 1E-333333333 +powx119 power '10' '-999999998' -> 1E-999999998 +powx120 power '10' '-999999999' -> 1E-999999999 +powx121 power '10' '-77' -> '1E-77' +powx122 power '10' '-22' -> '1E-22' + +powx123 power '2' '-1' -> '0.5' +powx124 power '2' '-2' -> '0.25' +powx125 power '2' '-4' -> '0.0625' +powx126 power '0' '-1' -> Infinity Division_by_zero +powx127 power '0' '-2' -> Infinity Division_by_zero +powx128 power -0 '-1' -> -Infinity Division_by_zero +powx129 power -0 '-2' -> Infinity Division_by_zero + +-- out-of-range edge cases +powx181 power '7' '999999998' -> 2.10892313E+845098038 Inexact Rounded +powx182 power '7' '999999999' -> 1.47624619E+845098039 Inexact Rounded +powx183 power '7' '1000000000' -> NaN Invalid_operation +powx184 power '7' '1000000001' -> NaN Invalid_operation +powx185 power '7' '10000000000' -> NaN Invalid_operation +powx186 power '7' '-1000000001' -> NaN Invalid_operation +powx187 power '7' '-1000000000' -> NaN Invalid_operation +powx189 power '7' '-999999999' -> 6.77393787E-845098040 Inexact Rounded +powx190 power '7' '-999999998' -> 4.74175651E-845098039 Inexact Rounded + +-- some baddies [more below] +powx191 power '2' '2.000001' -> NaN Invalid_operation +powx192 power '2' '2.00000000' -> 4 +powx193 power '2' '2.000000001' -> NaN Invalid_operation +powx194 power '2' '2.0000000001' -> NaN Invalid_operation + +-- "0.5" tests from original Rexx diagnostics [loop unrolled] +powx200 power 0.5 0 -> 1 +powx201 power 0.5 1 -> 0.5 +powx202 power 0.5 2 -> 0.25 +powx203 power 0.5 3 -> 0.125 +powx204 power 0.5 4 -> 0.0625 +powx205 power 0.5 5 -> 0.03125 +powx206 power 0.5 6 -> 0.015625 +powx207 power 0.5 7 -> 0.0078125 +powx208 power 0.5 8 -> 0.00390625 +powx209 power 0.5 9 -> 0.001953125 +powx210 power 0.5 10 -> 0.0009765625 + +-- A (rare) case where the last digit is not within 0.5 ULP +precision: 9 +powx215 power "-21971575.0E+31454441" "-7" -> "-4.04549503E-220181139" Inexact Rounded +precision: 20 +powx216 power "-21971575.0E+31454441" "-7" -> "-4.0454950249324891788E-220181139" Inexact Rounded + +-- The Vienna case. Checks both setup and 1/acc working precision +-- Modified 1998.12.14 as RHS no longer rounded before use (must fit) +-- Modified 1990.02.04 as LHS is now rounded (instead of truncated to guard) +-- '123456789E+10' -- lhs .. rounded to 1.23E+18 +-- '-1.23000e+2' -- rhs .. [was: -1.23455e+2, rounds to -123] +-- Modified 2002.10.06 -- finally, no input rounding +-- With input rounding, result would be 8.74E-2226 +precision: 3 +powx219 power '123456789E+10' '-1.23000e+2' -> '5.54E-2226' Inexact Rounded + +-- whole number checks +precision: 9 +powx221 power 1 1234 -> 1 +precision: 4 +powx222 power 1 1234 -> 1 +precision: 3 +powx223 power 1 1234 -> 1 +powx224 power 1 12.34e+2 -> 1 +powx225 power 1 12.3 -> NaN Invalid_operation +powx226 power 1 12.0 -> 1 +powx227 power 1 1.01 -> NaN Invalid_operation +powx228 power 2 1.00 -> 2 +powx229 power 2 2.00 -> 4 +precision: 9 +powx230 power 1 1.0001 -> NaN Invalid_operation +powx231 power 1 1.0000001 -> NaN Invalid_operation +powx232 power 1 1.0000000001 -> NaN Invalid_operation +powx233 power 1 1.0000000000001 -> NaN Invalid_operation +precision: 5 +powx234 power 1 1.0001 -> NaN Invalid_operation +powx235 power 1 1.0000001 -> NaN Invalid_operation +powx236 power 1 1.0000000001 -> NaN Invalid_operation +powx237 power 1 1.0000000000001 -> NaN Invalid_operation +powx238 power 1 1.0000000000001 -> NaN Invalid_operation + +maxexponent: 999999999 +minexponent: -999999999 +powx239 power 1 5.67E-987654321 -> NaN Invalid_operation + +powx240 power 1 100000000 -> 1 +powx241 power 1 999999998 -> 1 +powx242 power 1 999999999 -> 1 +powx243 power 1 1000000000 -> NaN Invalid_operation +powx244 power 1 9999999999 -> NaN Invalid_operation + +-- Checks for 'Too much precision needed' +-- For x^12, digits+elength+1 = digits+3 +precision: 999999999 +powx249 add 1 1 -> 2 -- check basic operation at this precision +powx250 power 2 12 -> Infinity Overflow +precision: 999999998 +powx251 power 2 12 -> Infinity Overflow +precision: 999999997 +powx252 power 2 12 -> Infinity Overflow +precision: 999999996 +powx253 power 2 12 -> 4096 +precision: 999999995 +powx254 power 2 12 -> 4096 + +-- zeros +maxexponent: +96 +minexponent: -95 +precision: 7 +powx260 power 0E-34 3 -> 0E-101 Clamped +powx261 power 0E-33 3 -> 0E-99 +powx262 power 0E-32 3 -> 0E-96 +powx263 power 0E-30 3 -> 0E-90 +powx264 power 0E-10 3 -> 0E-30 +powx265 power 0E-1 3 -> 0.000 +powx266 power 0E+0 3 -> 0 +powx267 power 0 3 -> 0 +powx268 power 0E+1 3 -> 0E+3 +powx269 power 0E+10 3 -> 0E+30 +powx270 power 0E+30 3 -> 0E+90 +powx271 power 0E+32 3 -> 0E+96 +powx272 power 0E+33 3 -> 0E+96 Clamped + +-- overflow and underflow tests +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +powx280 power 9 999999999 -> 3.05550054E+954242508 Inexact Rounded +powx281 power 10 999999999 -> 1.00000000E+999999999 Rounded +powx282 power 10.0001 999999999 -> Infinity Overflow Inexact Rounded +powx283 power 10.1 999999999 -> Infinity Overflow Inexact Rounded +powx284 power 11 999999999 -> Infinity Overflow Inexact Rounded +powx285 power 12 999999999 -> Infinity Overflow Inexact Rounded +powx286 power 999 999999999 -> Infinity Overflow Inexact Rounded +powx287 power 999999 999999999 -> Infinity Overflow Inexact Rounded +powx288 power 999999999 999999999 -> Infinity Overflow Inexact Rounded +powx289 power 9.9E999999999 999999999 -> Infinity Overflow Inexact Rounded + +powx290 power 0.5 999999999 -> 4.33559594E-301029996 Inexact Rounded +powx291 power 0.1 999999999 -> 1E-999999999 -- unrounded +powx292 power 0.09 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx293 power 0.05 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx294 power 0.01 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx295 power 0.0001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx297 power 0.0000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx298 power 0.0000000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx299 power 1E-999999999 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped + +powx310 power -9 999999999 -> -3.05550054E+954242508 Inexact Rounded +powx311 power -10 999999999 -> -1.00000000E+999999999 Rounded +powx312 power -10.0001 999999999 -> -Infinity Overflow Inexact Rounded +powx313 power -10.1 999999999 -> -Infinity Overflow Inexact Rounded +powx314 power -11 999999999 -> -Infinity Overflow Inexact Rounded +powx315 power -12 999999999 -> -Infinity Overflow Inexact Rounded +powx316 power -999 999999999 -> -Infinity Overflow Inexact Rounded +powx317 power -999999 999999999 -> -Infinity Overflow Inexact Rounded +powx318 power -999999999 999999999 -> -Infinity Overflow Inexact Rounded +powx319 power -9.9E999999999 999999999 -> -Infinity Overflow Inexact Rounded + +powx320 power -0.5 999999999 -> -4.33559594E-301029996 Inexact Rounded +powx321 power -0.1 999999999 -> -1E-999999999 +powx322 power -0.09 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx323 power -0.05 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx324 power -0.01 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx325 power -0.0001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx327 power -0.0000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx328 power -0.0000000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx329 power -1E-999999999 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped + +-- note no trim of next result +powx330 power -9 999999998 -> 3.39500060E+954242507 Inexact Rounded +powx331 power -10 999999998 -> 1.00000000E+999999998 Rounded +powx332 power -10.0001 999999998 -> Infinity Overflow Inexact Rounded +powx333 power -10.1 999999998 -> Infinity Overflow Inexact Rounded +powx334 power -11 999999998 -> Infinity Overflow Inexact Rounded +powx335 power -12 999999998 -> Infinity Overflow Inexact Rounded +powx336 power -999 999999998 -> Infinity Overflow Inexact Rounded +powx337 power -999999 999999998 -> Infinity Overflow Inexact Rounded +powx338 power -999999999 999999998 -> Infinity Overflow Inexact Rounded +powx339 power -9.9E999999999 999999998 -> Infinity Overflow Inexact Rounded + +powx340 power -0.5 999999998 -> 8.67119187E-301029996 Inexact Rounded +powx341 power -0.1 999999998 -> 1E-999999998 -- NB exact unrounded +powx342 power -0.09 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx343 power -0.05 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx344 power -0.01 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx345 power -0.0001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx347 power -0.0000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx348 power -0.0000000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx349 power -1E-999999999 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped + +-- some subnormals +precision: 9 +-- [precision is 9, so smallest exponent is -1000000007 +powx350 power 1e-1 500000000 -> 1E-500000000 +powx351 power 1e-2 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +powx352 power 1e-2 500000000 -> 1E-1000000000 Subnormal +powx353 power 1e-2 500000001 -> 1E-1000000002 Subnormal +powx354 power 1e-2 500000002 -> 1E-1000000004 Subnormal +powx355 power 1e-2 500000003 -> 1E-1000000006 Subnormal +powx356 power 1e-2 500000004 -> 0E-1000000007 Underflow Subnormal Inexact Rounded + +powx360 power 0.010001 500000000 -> 4.34941988E-999978287 Inexact Rounded +powx361 power 0.010000001 500000000 -> 5.18469257E-999999979 Inexact Rounded +powx362 power 0.010000001 500000001 -> 5.18469309E-999999981 Inexact Rounded +powx363 power 0.0100000009 500000000 -> 3.49342003E-999999981 Inexact Rounded +powx364 power 0.0100000001 500000000 -> 1.48413155E-999999998 Inexact Rounded +powx365 power 0.01 500000000 -> 1E-1000000000 Subnormal +powx366 power 0.0099999999 500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded +powx367 power 0.0099999998 500000000 -> 4.54E-1000000005 Underflow Subnormal Inexact Rounded +powx368 power 0.0099999997 500000000 -> 3E-1000000007 Underflow Subnormal Inexact Rounded +powx369 power 0.0099999996 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded +powx370 power 0.009 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped + +-- 1/subnormal -> overflow +powx371 power 1e-1 -500000000 -> 1E+500000000 +powx372 power 1e-2 -999999999 -> Infinity Overflow Inexact Rounded +powx373 power 1e-2 -500000000 -> Infinity Overflow Inexact Rounded +powx374 power 1e-2 -500000001 -> Infinity Overflow Inexact Rounded +powx375 power 1e-2 -500000002 -> Infinity Overflow Inexact Rounded +powx376 power 1e-2 -500000003 -> Infinity Overflow Inexact Rounded +powx377 power 1e-2 -500000004 -> Infinity Overflow Inexact Rounded + +powx381 power 0.010001 -500000000 -> 2.29915719E+999978286 Inexact Rounded +powx382 power 0.010000001 -500000000 -> 1.92875467E+999999978 Inexact Rounded +powx383 power 0.010000001 -500000001 -> 1.92875448E+999999980 Inexact Rounded +powx384 power 0.0100000009 -500000000 -> 2.86252438E+999999980 Inexact Rounded +powx385 power 0.0100000001 -500000000 -> 6.73794717E+999999997 Inexact Rounded +powx386 power 0.01 -500000000 -> Infinity Overflow Inexact Rounded +powx387 power 0.009999 -500000000 -> Infinity Overflow Inexact Rounded + +-- negative power giving subnormal +powx388 power 100.000001 -500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded + +-- some more edge cases +precision: 15 +maxExponent: 999 +minexponent: -999 +powx391 power 0.1 999 -> 1E-999 +powx392 power 0.099 999 -> 4.360732062E-1004 Underflow Subnormal Inexact Rounded +powx393 power 0.098 999 -> 1.71731E-1008 Underflow Subnormal Inexact Rounded +powx394 power 0.097 999 -> 6E-1013 Underflow Subnormal Inexact Rounded +powx395 power 0.096 999 -> 0E-1013 Underflow Subnormal Inexact Rounded +powx396 power 0.01 999 -> 0E-1013 Underflow Subnormal Inexact Rounded Clamped + +-- multiply tests are here to aid checking and test for consistent handling +-- of underflow +precision: 5 +maxexponent: 999 +minexponent: -999 + +-- squares +mulx400 multiply 1E-502 1e-502 -> 0E-1003 Subnormal Inexact Underflow Rounded +mulx401 multiply 1E-501 1e-501 -> 1E-1002 Subnormal +mulx402 multiply 2E-501 2e-501 -> 4E-1002 Subnormal +mulx403 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal +mulx404 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal +mulx405 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal +mulx406 multiply 40E-501 40e-501 -> 1.600E-999 + +powx400 power 1E-502 2 -> 0E-1003 Underflow Subnormal Inexact Rounded +powx401 power 1E-501 2 -> 1E-1002 Subnormal +powx402 power 2E-501 2 -> 4E-1002 Subnormal +powx403 power 4E-501 2 -> 1.6E-1001 Subnormal +powx404 power 10E-501 2 -> 1.00E-1000 Subnormal +powx405 power 30E-501 2 -> 9.00E-1000 Subnormal +powx406 power 40E-501 2 -> 1.600E-999 + +-- cubes +mulx410 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded +mulx411 multiply 1E-668 1e-334 -> 1E-1002 Subnormal +mulx412 multiply 4E-668 2e-334 -> 8E-1002 Subnormal +mulx413 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal +mulx414 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal +mulx415 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal +mulx416 multiply 10E-668 100e-334 -> 1.000E-999 + +powx410 power 1E-335 3 -> 0E-1003 Underflow Subnormal Inexact Rounded +powx411 power 1E-334 3 -> 1E-1002 Subnormal +powx412 power 2E-334 3 -> 8E-1002 Subnormal +powx413 power 3E-334 3 -> 2.7E-1001 Subnormal +powx414 power 4E-334 3 -> 6.4E-1001 Subnormal +powx415 power 5E-334 3 -> 1.25E-1000 Subnormal +powx416 power 10E-334 3 -> 1.000E-999 + +-- negative powers, testing subnormals +precision: 5 +maxExponent: 999 +minexponent: -999 +powx421 power 2.5E-501 -2 -> Infinity Overflow Inexact Rounded +powx422 power 2.5E-500 -2 -> 1.6E+999 + +powx423 power 2.5E+499 -2 -> 1.6E-999 +powx424 power 2.5E+500 -2 -> 1.6E-1001 Subnormal +powx425 power 2.5E+501 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded +powx426 power 2.5E+502 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded + +powx427 power 0.25E+499 -2 -> 1.6E-997 +powx428 power 0.25E+500 -2 -> 1.6E-999 +powx429 power 0.25E+501 -2 -> 1.6E-1001 Subnormal +powx430 power 0.25E+502 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded +powx431 power 0.25E+503 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded + +powx432 power 0.04E+499 -2 -> 6.25E-996 +powx433 power 0.04E+500 -2 -> 6.25E-998 +powx434 power 0.04E+501 -2 -> 6.25E-1000 Subnormal +powx435 power 0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded +powx436 power 0.04E+503 -2 -> 1E-1003 Underflow Subnormal Inexact Rounded +powx437 power 0.04E+504 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded + +powx441 power 0.04E+334 -3 -> 1.5625E-998 +powx442 power 0.04E+335 -3 -> 1.56E-1001 Underflow Subnormal Inexact Rounded +powx443 power 0.04E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded +powx444 power 0.25E+333 -3 -> 6.4E-998 +powx445 power 0.25E+334 -3 -> 6.4E-1001 Subnormal +powx446 power 0.25E+335 -3 -> 1E-1003 Underflow Subnormal Inexact Rounded +powx447 power 0.25E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped +-- check sign for cubes and a few squares +powx448 power -0.04E+334 -3 -> -1.5625E-998 +powx449 power -0.04E+335 -3 -> -1.56E-1001 Underflow Subnormal Inexact Rounded +powx450 power -0.04E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded +powx451 power -0.25E+333 -3 -> -6.4E-998 +powx452 power -0.25E+334 -3 -> -6.4E-1001 Subnormal +powx453 power -0.25E+335 -3 -> -1E-1003 Underflow Subnormal Inexact Rounded +powx454 power -0.25E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped +powx455 power -0.04E+499 -2 -> 6.25E-996 +powx456 power -0.04E+500 -2 -> 6.25E-998 +powx457 power -0.04E+501 -2 -> 6.25E-1000 Subnormal +powx458 power -0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded + +-- test -0s +precision: 9 +powx560 power 0 0 -> NaN Invalid_operation +powx561 power 0 -0 -> NaN Invalid_operation +powx562 power -0 0 -> NaN Invalid_operation +powx563 power -0 -0 -> NaN Invalid_operation +powx564 power 1 0 -> 1 +powx565 power 1 -0 -> 1 +powx566 power -1 0 -> 1 +powx567 power -1 -0 -> 1 +powx568 power 0 1 -> 0 +powx569 power 0 -1 -> Infinity Division_by_zero +powx570 power -0 1 -> -0 +powx571 power -0 -1 -> -Infinity Division_by_zero +powx572 power 0 2 -> 0 +powx573 power 0 -2 -> Infinity Division_by_zero +powx574 power -0 2 -> 0 +powx575 power -0 -2 -> Infinity Division_by_zero +powx576 power 0 3 -> 0 +powx577 power 0 -3 -> Infinity Division_by_zero +powx578 power -0 3 -> -0 +powx579 power -0 -3 -> -Infinity Division_by_zero + +-- Specials +powx580 power Inf -Inf -> NaN Invalid_operation +powx581 power Inf -1000 -> 0 +powx582 power Inf -1 -> 0 +powx583 power Inf -0 -> 1 +powx584 power Inf 0 -> 1 +powx585 power Inf 1 -> Infinity +powx586 power Inf 1000 -> Infinity +powx587 power Inf Inf -> NaN Invalid_operation +powx588 power -1000 Inf -> NaN Invalid_operation +powx589 power -Inf Inf -> NaN Invalid_operation +powx590 power -1 Inf -> NaN Invalid_operation +powx591 power -0 Inf -> NaN Invalid_operation +powx592 power 0 Inf -> NaN Invalid_operation +powx593 power 1 Inf -> NaN Invalid_operation +powx594 power 1000 Inf -> NaN Invalid_operation +powx595 power Inf Inf -> NaN Invalid_operation + +powx600 power -Inf -Inf -> NaN Invalid_operation +powx601 power -Inf -1000 -> 0 +powx602 power -Inf -1 -> -0 +powx603 power -Inf -0 -> 1 +powx604 power -Inf 0 -> 1 +powx605 power -Inf 1 -> -Infinity +powx606 power -Inf 1000 -> Infinity +powx607 power -Inf Inf -> NaN Invalid_operation +powx608 power -1000 Inf -> NaN Invalid_operation +powx609 power -Inf -Inf -> NaN Invalid_operation +powx610 power -1 -Inf -> NaN Invalid_operation +powx611 power -0 -Inf -> NaN Invalid_operation +powx612 power 0 -Inf -> NaN Invalid_operation +powx613 power 1 -Inf -> NaN Invalid_operation +powx614 power 1000 -Inf -> NaN Invalid_operation +powx615 power Inf -Inf -> NaN Invalid_operation + +powx621 power NaN -Inf -> NaN Invalid_operation +powx622 power NaN -1000 -> NaN +powx623 power NaN -1 -> NaN +powx624 power NaN -0 -> NaN +powx625 power NaN 0 -> NaN +powx626 power NaN 1 -> NaN +powx627 power NaN 1000 -> NaN +powx628 power NaN Inf -> NaN Invalid_operation +powx629 power NaN NaN -> NaN +powx630 power -Inf NaN -> NaN +powx631 power -1000 NaN -> NaN +powx632 power -1 NaN -> NaN +powx633 power -0 NaN -> NaN +powx634 power 0 NaN -> NaN +powx635 power 1 NaN -> NaN +powx636 power 1000 NaN -> NaN +powx637 power Inf NaN -> NaN + +powx641 power sNaN -Inf -> NaN Invalid_operation +powx642 power sNaN -1000 -> NaN Invalid_operation +powx643 power sNaN -1 -> NaN Invalid_operation +powx644 power sNaN -0 -> NaN Invalid_operation +powx645 power sNaN 0 -> NaN Invalid_operation +powx646 power sNaN 1 -> NaN Invalid_operation +powx647 power sNaN 1000 -> NaN Invalid_operation +powx648 power sNaN NaN -> NaN Invalid_operation +powx649 power sNaN sNaN -> NaN Invalid_operation +powx650 power NaN sNaN -> NaN Invalid_operation +powx651 power -Inf sNaN -> NaN Invalid_operation +powx652 power -1000 sNaN -> NaN Invalid_operation +powx653 power -1 sNaN -> NaN Invalid_operation +powx654 power -0 sNaN -> NaN Invalid_operation +powx655 power 0 sNaN -> NaN Invalid_operation +powx656 power 1 sNaN -> NaN Invalid_operation +powx657 power 1000 sNaN -> NaN Invalid_operation +powx658 power Inf sNaN -> NaN Invalid_operation +powx659 power NaN sNaN -> NaN Invalid_operation + +-- NaN propagation +powx660 power NaN3 sNaN7 -> NaN7 Invalid_operation +powx661 power sNaN8 NaN6 -> NaN8 Invalid_operation +powx662 power 1 sNaN7 -> NaN7 Invalid_operation +powx663 power sNaN8 1 -> NaN8 Invalid_operation +powx664 power Inf sNaN7 -> NaN7 Invalid_operation +powx665 power sNaN8 Inf -> NaN Invalid_operation +powx666 power Inf NaN9 -> NaN9 +powx667 power NaN6 Inf -> NaN Invalid_operation +powx668 power 1 NaN5 -> NaN5 +powx669 power NaN2 1 -> NaN2 +powx670 power NaN2 Nan4 -> NaN2 +powx671 power NaN Nan4 -> NaN +powx672 power NaN345 Nan -> NaN345 +powx673 power Inf -sNaN7 -> -NaN7 Invalid_operation +powx674 power -sNaN8 Inf -> NaN Invalid_operation +powx675 power Inf -NaN9 -> -NaN9 +powx676 power -NaN6 Inf -> NaN Invalid_operation +powx677 power -NaN2 -Nan4 -> -NaN2 + +-- Examples from extended specification +powx690 power Inf -2 -> 0 +powx691 power Inf -1 -> 0 +powx692 power Inf 0 -> 1 +powx693 power Inf 1 -> Infinity +powx694 power Inf 2 -> Infinity +powx695 power -Inf -2 -> 0 +powx696 power -Inf -1 -> -0 +powx697 power -Inf 0 -> 1 +powx698 power -Inf 1 -> -Infinity +powx699 power -Inf 2 -> Infinity +powx700 power 0 0 -> NaN Invalid_operation + +-- long operand and RHS range checks +maxexponent: 999 +minexponent: -999 +precision: 9 +powx701 power 12345678000 1 -> 1.23456780E+10 Rounded +powx702 power 1234567800 1 -> 1.23456780E+9 Rounded +powx703 power 1234567890 1 -> 1.23456789E+9 Rounded +powx704 power 1234567891 1 -> 1.23456789E+9 Inexact Rounded +powx705 power 12345678901 1 -> 1.23456789E+10 Inexact Rounded +powx706 power 1234567896 1 -> 1.23456790E+9 Inexact Rounded +powx707 power 1 12345678000 -> NaN Invalid_operation +powx708 power 1 1234567800 -> NaN Invalid_operation +powx709 power 1 1234567890 -> NaN Invalid_operation +powx710 power 1 11234567891 -> NaN Invalid_operation +powx711 power 1 12345678901 -> NaN Invalid_operation +powx712 power 1 1234567896 -> NaN Invalid_operation +powx713 power 1 -1234567896 -> NaN Invalid_operation +powx714 power 1 1000000000 -> NaN Invalid_operation +powx715 power 1 -1000000000 -> NaN Invalid_operation + +precision: 15 +-- still checking +powx741 power 12345678000 1 -> 12345678000 +powx742 power 1234567800 1 -> 1234567800 +powx743 power 1234567890 1 -> 1234567890 +powx744 power 1234567891 1 -> 1234567891 +powx745 power 12345678901 1 -> 12345678901 +powx746 power 1234567896 1 -> 1234567896 +powx747 power 1 12345678000 -> NaN Invalid_operation +powx748 power 1 -1234567896 -> NaN Invalid_operation +powx749 power 1 1000000000 -> NaN Invalid_operation +powx740 power 1 -1000000000 -> NaN Invalid_operation + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +powx750 power 1.2347E-40 2 -> 1.524E-80 Inexact Rounded Subnormal Underflow + +-- Null tests +powx900 power 1 # -> NaN Invalid_operation +powx901 power # 1 -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/quantize.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/quantize.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,780 @@ +------------------------------------------------------------------------ +-- quantize.decTest -- decimal quantize operation -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- Most of the tests here assume a "regular pattern", where the +-- sign and coefficient are +1. +-- 2004.03.15 Underflow for quantize is suppressed + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- sanity checks +quax001 quantize 0 1e0 -> 0 +quax002 quantize 1 1e0 -> 1 +quax003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded +quax005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded +quax006 quantize 0.1 1e0 -> 0 Inexact Rounded +quax007 quantize 0.1 1e-1 -> 0.1 +quax008 quantize 0.1 1e-2 -> 0.10 +quax009 quantize 0.1 1e-3 -> 0.100 +quax010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded +quax011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded +quax012 quantize 0.9 1e+0 -> 1 Inexact Rounded +quax013 quantize 0.9 1e-1 -> 0.9 +quax014 quantize 0.9 1e-2 -> 0.90 +quax015 quantize 0.9 1e-3 -> 0.900 +-- negatives +quax021 quantize -0 1e0 -> -0 +quax022 quantize -1 1e0 -> -1 +quax023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded +quax025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded +quax026 quantize -0.1 1e0 -> -0 Inexact Rounded +quax027 quantize -0.1 1e-1 -> -0.1 +quax028 quantize -0.1 1e-2 -> -0.10 +quax029 quantize -0.1 1e-3 -> -0.100 +quax030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded +quax031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded +quax032 quantize -0.9 1e+0 -> -1 Inexact Rounded +quax033 quantize -0.9 1e-1 -> -0.9 +quax034 quantize -0.9 1e-2 -> -0.90 +quax035 quantize -0.9 1e-3 -> -0.900 +quax036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded +quax037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded +quax038 quantize -0.5 1e+0 -> -1 Inexact Rounded +quax039 quantize -0.5 1e-1 -> -0.5 +quax040 quantize -0.5 1e-2 -> -0.50 +quax041 quantize -0.5 1e-3 -> -0.500 +quax042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded +quax043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded +quax044 quantize -0.9 1e+0 -> -1 Inexact Rounded +quax045 quantize -0.9 1e-1 -> -0.9 +quax046 quantize -0.9 1e-2 -> -0.90 +quax047 quantize -0.9 1e-3 -> -0.900 + +-- examples from Specification +quax060 quantize 2.17 0.001 -> 2.170 +quax061 quantize 2.17 0.01 -> 2.17 +quax062 quantize 2.17 0.1 -> 2.2 Inexact Rounded +quax063 quantize 2.17 1e+0 -> 2 Inexact Rounded +quax064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded +quax065 quantize -Inf Inf -> -Infinity +quax066 quantize 2 Inf -> NaN Invalid_operation +quax067 quantize -0.1 1 -> -0 Inexact Rounded +quax068 quantize -0 1e+5 -> -0E+5 +quax069 quantize +35236450.6 1e-2 -> NaN Invalid_operation +quax070 quantize -35236450.6 1e-2 -> NaN Invalid_operation +quax071 quantize 217 1e-1 -> 217.0 +quax072 quantize 217 1e+0 -> 217 +quax073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded +quax074 quantize 217 1e+2 -> 2E+2 Inexact Rounded + +-- general tests .. +quax089 quantize 12 1e+4 -> 0E+4 Inexact Rounded +quax090 quantize 12 1e+3 -> 0E+3 Inexact Rounded +quax091 quantize 12 1e+2 -> 0E+2 Inexact Rounded +quax092 quantize 12 1e+1 -> 1E+1 Inexact Rounded +quax093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded +quax094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded +quax095 quantize 1.2345 1e-6 -> 1.234500 +quax096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded +quax097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded +quax098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded +quax099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded +quax100 quantize 92 1e+2 -> 1E+2 Inexact Rounded + +quax101 quantize -1 1e0 -> -1 +quax102 quantize -1 1e-1 -> -1.0 +quax103 quantize -1 1e-2 -> -1.00 +quax104 quantize 0 1e0 -> 0 +quax105 quantize 0 1e-1 -> 0.0 +quax106 quantize 0 1e-2 -> 0.00 +quax107 quantize 0.00 1e0 -> 0 +quax108 quantize 0 1e+1 -> 0E+1 +quax109 quantize 0 1e+2 -> 0E+2 +quax110 quantize +1 1e0 -> 1 +quax111 quantize +1 1e-1 -> 1.0 +quax112 quantize +1 1e-2 -> 1.00 + +quax120 quantize 1.04 1e-3 -> 1.040 +quax121 quantize 1.04 1e-2 -> 1.04 +quax122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded +quax123 quantize 1.04 1e0 -> 1 Inexact Rounded +quax124 quantize 1.05 1e-3 -> 1.050 +quax125 quantize 1.05 1e-2 -> 1.05 +quax126 quantize 1.05 1e-1 -> 1.1 Inexact Rounded +quax127 quantize 1.05 1e0 -> 1 Inexact Rounded +quax128 quantize 1.05 1e-3 -> 1.050 +quax129 quantize 1.05 1e-2 -> 1.05 +quax130 quantize 1.05 1e-1 -> 1.1 Inexact Rounded +quax131 quantize 1.05 1e0 -> 1 Inexact Rounded +quax132 quantize 1.06 1e-3 -> 1.060 +quax133 quantize 1.06 1e-2 -> 1.06 +quax134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded +quax135 quantize 1.06 1e0 -> 1 Inexact Rounded + +quax140 quantize -10 1e-2 -> -10.00 +quax141 quantize +1 1e-2 -> 1.00 +quax142 quantize +10 1e-2 -> 10.00 +quax143 quantize 1E+10 1e-2 -> NaN Invalid_operation +quax144 quantize 1E-10 1e-2 -> 0.00 Inexact Rounded +quax145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded +quax146 quantize 1E-2 1e-2 -> 0.01 +quax147 quantize 1E-1 1e-2 -> 0.10 +quax148 quantize 0E-10 1e-2 -> 0.00 + +quax150 quantize 1.0600 1e-5 -> 1.06000 +quax151 quantize 1.0600 1e-4 -> 1.0600 +quax152 quantize 1.0600 1e-3 -> 1.060 Rounded +quax153 quantize 1.0600 1e-2 -> 1.06 Rounded +quax154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded +quax155 quantize 1.0600 1e0 -> 1 Inexact Rounded + +-- base tests with non-1 coefficients +quax161 quantize 0 -9e0 -> 0 +quax162 quantize 1 -7e0 -> 1 +quax163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded +quax165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded +quax166 quantize 0.1 2e0 -> 0 Inexact Rounded +quax167 quantize 0.1 3e-1 -> 0.1 +quax168 quantize 0.1 44e-2 -> 0.10 +quax169 quantize 0.1 555e-3 -> 0.100 +quax170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded +quax171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded +quax172 quantize 0.9 -88e+0 -> 1 Inexact Rounded +quax173 quantize 0.9 -9e-1 -> 0.9 +quax174 quantize 0.9 0e-2 -> 0.90 +quax175 quantize 0.9 1.1e-3 -> 0.9000 +-- negatives +quax181 quantize -0 1.1e0 -> -0.0 +quax182 quantize -1 -1e0 -> -1 +quax183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded +quax185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded +quax186 quantize -0.1 71e0 -> -0 Inexact Rounded +quax187 quantize -0.1 -91e-1 -> -0.1 +quax188 quantize -0.1 -.1e-2 -> -0.100 +quax189 quantize -0.1 -1e-3 -> -0.100 +quax190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded +quax191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded +quax192 quantize -0.9 -10e+0 -> -1 Inexact Rounded +quax193 quantize -0.9 100e-1 -> -0.9 +quax194 quantize -0.9 999e-2 -> -0.90 + +-- +ve exponents .. +quax201 quantize -1 1e+0 -> -1 +quax202 quantize -1 1e+1 -> -0E+1 Inexact Rounded +quax203 quantize -1 1e+2 -> -0E+2 Inexact Rounded +quax204 quantize 0 1e+0 -> 0 +quax205 quantize 0 1e+1 -> 0E+1 +quax206 quantize 0 1e+2 -> 0E+2 +quax207 quantize +1 1e+0 -> 1 +quax208 quantize +1 1e+1 -> 0E+1 Inexact Rounded +quax209 quantize +1 1e+2 -> 0E+2 Inexact Rounded + +quax220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded +quax221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded +quax222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded +quax223 quantize 1.04 1e+0 -> 1 Inexact Rounded +quax224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded +quax225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded +quax226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded +quax227 quantize 1.05 1e+0 -> 1 Inexact Rounded +quax228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded +quax229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded +quax230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded +quax231 quantize 1.05 1e+0 -> 1 Inexact Rounded +quax232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded +quax233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded +quax234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded +quax235 quantize 1.06 1e+0 -> 1 Inexact Rounded + +quax240 quantize -10 1e+1 -> -1E+1 Rounded +quax241 quantize +1 1e+1 -> 0E+1 Inexact Rounded +quax242 quantize +10 1e+1 -> 1E+1 Rounded +quax243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1 +quax244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1 +quax245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1 +quax246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1 +quax247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1 +quax248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1 +quax249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1 +quax250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1 +quax251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1 +-- next one tries to add 9 zeros +quax252 quantize 1E+10 1e+1 -> NaN Invalid_operation +quax253 quantize 1E-10 1e+1 -> 0E+1 Inexact Rounded +quax254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded +quax255 quantize 0E-10 1e+1 -> 0E+1 +quax256 quantize -0E-10 1e+1 -> -0E+1 +quax257 quantize -0E-1 1e+1 -> -0E+1 +quax258 quantize -0 1e+1 -> -0E+1 +quax259 quantize -0E+1 1e+1 -> -0E+1 + +quax260 quantize -10 1e+2 -> -0E+2 Inexact Rounded +quax261 quantize +1 1e+2 -> 0E+2 Inexact Rounded +quax262 quantize +10 1e+2 -> 0E+2 Inexact Rounded +quax263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded +quax264 quantize 1E+2 1e+2 -> 1E+2 +quax265 quantize 1E+3 1e+2 -> 1.0E+3 +quax266 quantize 1E+4 1e+2 -> 1.00E+4 +quax267 quantize 1E+5 1e+2 -> 1.000E+5 +quax268 quantize 1E+6 1e+2 -> 1.0000E+6 +quax269 quantize 1E+7 1e+2 -> 1.00000E+7 +quax270 quantize 1E+8 1e+2 -> 1.000000E+8 +quax271 quantize 1E+9 1e+2 -> 1.0000000E+9 +quax272 quantize 1E+10 1e+2 -> 1.00000000E+10 +quax273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded +quax274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded +quax275 quantize 0E-10 1e+2 -> 0E+2 + +quax280 quantize -10 1e+3 -> -0E+3 Inexact Rounded +quax281 quantize +1 1e+3 -> 0E+3 Inexact Rounded +quax282 quantize +10 1e+3 -> 0E+3 Inexact Rounded +quax283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded +quax284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded +quax285 quantize 1E+3 1e+3 -> 1E+3 +quax286 quantize 1E+4 1e+3 -> 1.0E+4 +quax287 quantize 1E+5 1e+3 -> 1.00E+5 +quax288 quantize 1E+6 1e+3 -> 1.000E+6 +quax289 quantize 1E+7 1e+3 -> 1.0000E+7 +quax290 quantize 1E+8 1e+3 -> 1.00000E+8 +quax291 quantize 1E+9 1e+3 -> 1.000000E+9 +quax292 quantize 1E+10 1e+3 -> 1.0000000E+10 +quax293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded +quax294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded +quax295 quantize 0E-10 1e+3 -> 0E+3 + +-- round up from below [sign wrong in JIT compiler once] +quax300 quantize 0.0078 1e-5 -> 0.00780 +quax301 quantize 0.0078 1e-4 -> 0.0078 +quax302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded +quax303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded +quax304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded +quax305 quantize 0.0078 1e0 -> 0 Inexact Rounded +quax306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded +quax307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded + +quax310 quantize -0.0078 1e-5 -> -0.00780 +quax311 quantize -0.0078 1e-4 -> -0.0078 +quax312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded +quax313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded +quax314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded +quax315 quantize -0.0078 1e0 -> -0 Inexact Rounded +quax316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded +quax317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded + +quax320 quantize 0.078 1e-5 -> 0.07800 +quax321 quantize 0.078 1e-4 -> 0.0780 +quax322 quantize 0.078 1e-3 -> 0.078 +quax323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded +quax324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded +quax325 quantize 0.078 1e0 -> 0 Inexact Rounded +quax326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded +quax327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded + +quax330 quantize -0.078 1e-5 -> -0.07800 +quax331 quantize -0.078 1e-4 -> -0.0780 +quax332 quantize -0.078 1e-3 -> -0.078 +quax333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded +quax334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded +quax335 quantize -0.078 1e0 -> -0 Inexact Rounded +quax336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded +quax337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded + +quax340 quantize 0.78 1e-5 -> 0.78000 +quax341 quantize 0.78 1e-4 -> 0.7800 +quax342 quantize 0.78 1e-3 -> 0.780 +quax343 quantize 0.78 1e-2 -> 0.78 +quax344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded +quax345 quantize 0.78 1e0 -> 1 Inexact Rounded +quax346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded +quax347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded + +quax350 quantize -0.78 1e-5 -> -0.78000 +quax351 quantize -0.78 1e-4 -> -0.7800 +quax352 quantize -0.78 1e-3 -> -0.780 +quax353 quantize -0.78 1e-2 -> -0.78 +quax354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded +quax355 quantize -0.78 1e0 -> -1 Inexact Rounded +quax356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded +quax357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded + +quax360 quantize 7.8 1e-5 -> 7.80000 +quax361 quantize 7.8 1e-4 -> 7.8000 +quax362 quantize 7.8 1e-3 -> 7.800 +quax363 quantize 7.8 1e-2 -> 7.80 +quax364 quantize 7.8 1e-1 -> 7.8 +quax365 quantize 7.8 1e0 -> 8 Inexact Rounded +quax366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded +quax367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded +quax368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded + +quax370 quantize -7.8 1e-5 -> -7.80000 +quax371 quantize -7.8 1e-4 -> -7.8000 +quax372 quantize -7.8 1e-3 -> -7.800 +quax373 quantize -7.8 1e-2 -> -7.80 +quax374 quantize -7.8 1e-1 -> -7.8 +quax375 quantize -7.8 1e0 -> -8 Inexact Rounded +quax376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded +quax377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded +quax378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded + +-- some individuals +precision: 9 +quax380 quantize 352364.506 1e-2 -> 352364.51 Inexact Rounded +quax381 quantize 3523645.06 1e-2 -> 3523645.06 +quax382 quantize 35236450.6 1e-2 -> NaN Invalid_operation +quax383 quantize 352364506 1e-2 -> NaN Invalid_operation +quax384 quantize -352364.506 1e-2 -> -352364.51 Inexact Rounded +quax385 quantize -3523645.06 1e-2 -> -3523645.06 +quax386 quantize -35236450.6 1e-2 -> NaN Invalid_operation +quax387 quantize -352364506 1e-2 -> NaN Invalid_operation + +rounding: down +quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation +-- ? should that one instead have been: +-- quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation +rounding: half_up + +-- and a few more from e-mail discussions +precision: 7 +quax391 quantize 12.34567 1e-3 -> 12.346 Inexact Rounded +quax392 quantize 123.4567 1e-3 -> 123.457 Inexact Rounded +quax393 quantize 1234.567 1e-3 -> 1234.567 +quax394 quantize 12345.67 1e-3 -> NaN Invalid_operation +quax395 quantize 123456.7 1e-3 -> NaN Invalid_operation +quax396 quantize 1234567. 1e-3 -> NaN Invalid_operation + +-- some 9999 round-up cases +precision: 9 +quax400 quantize 9.999 1e-5 -> 9.99900 +quax401 quantize 9.999 1e-4 -> 9.9990 +quax402 quantize 9.999 1e-3 -> 9.999 +quax403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded +quax404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded +quax405 quantize 9.999 1e0 -> 10 Inexact Rounded +quax406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded +quax407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded + +quax410 quantize 0.999 1e-5 -> 0.99900 +quax411 quantize 0.999 1e-4 -> 0.9990 +quax412 quantize 0.999 1e-3 -> 0.999 +quax413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded +quax414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded +quax415 quantize 0.999 1e0 -> 1 Inexact Rounded +quax416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded + +quax420 quantize 0.0999 1e-5 -> 0.09990 +quax421 quantize 0.0999 1e-4 -> 0.0999 +quax422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded +quax423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded +quax424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded +quax425 quantize 0.0999 1e0 -> 0 Inexact Rounded +quax426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded + +quax430 quantize 0.00999 1e-5 -> 0.00999 +quax431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded +quax432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded +quax433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded +quax434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded +quax435 quantize 0.00999 1e0 -> 0 Inexact Rounded +quax436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded + +quax440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded +quax441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded +quax442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded +quax443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded +quax444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded +quax445 quantize 0.000999 1e0 -> 0 Inexact Rounded +quax446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded + +precision: 8 +quax449 quantize 9.999E-15 1e-23 -> NaN Invalid_operation +quax450 quantize 9.999E-15 1e-22 -> 9.9990000E-15 +quax451 quantize 9.999E-15 1e-21 -> 9.999000E-15 +quax452 quantize 9.999E-15 1e-20 -> 9.99900E-15 +quax453 quantize 9.999E-15 1e-19 -> 9.9990E-15 +quax454 quantize 9.999E-15 1e-18 -> 9.999E-15 +quax455 quantize 9.999E-15 1e-17 -> 1.000E-14 Inexact Rounded +quax456 quantize 9.999E-15 1e-16 -> 1.00E-14 Inexact Rounded +quax457 quantize 9.999E-15 1e-15 -> 1.0E-14 Inexact Rounded +quax458 quantize 9.999E-15 1e-14 -> 1E-14 Inexact Rounded +quax459 quantize 9.999E-15 1e-13 -> 0E-13 Inexact Rounded +quax460 quantize 9.999E-15 1e-12 -> 0E-12 Inexact Rounded +quax461 quantize 9.999E-15 1e-11 -> 0E-11 Inexact Rounded +quax462 quantize 9.999E-15 1e-10 -> 0E-10 Inexact Rounded +quax463 quantize 9.999E-15 1e-9 -> 0E-9 Inexact Rounded +quax464 quantize 9.999E-15 1e-8 -> 0E-8 Inexact Rounded +quax465 quantize 9.999E-15 1e-7 -> 0E-7 Inexact Rounded +quax466 quantize 9.999E-15 1e-6 -> 0.000000 Inexact Rounded +quax467 quantize 9.999E-15 1e-5 -> 0.00000 Inexact Rounded +quax468 quantize 9.999E-15 1e-4 -> 0.0000 Inexact Rounded +quax469 quantize 9.999E-15 1e-3 -> 0.000 Inexact Rounded +quax470 quantize 9.999E-15 1e-2 -> 0.00 Inexact Rounded +quax471 quantize 9.999E-15 1e-1 -> 0.0 Inexact Rounded +quax472 quantize 9.999E-15 1e0 -> 0 Inexact Rounded +quax473 quantize 9.999E-15 1e1 -> 0E+1 Inexact Rounded + +-- long operand checks [rhs checks removed] +maxexponent: 999 +minexponent: -999 +precision: 9 +quax481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded +quax482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded +quax483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded +quax484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded +quax485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded +quax486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded +-- a potential double-round +quax487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded +quax488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded + +precision: 15 +quax491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded +quax492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded +quax493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded +quax494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded +quax495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded +quax496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded +quax497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded +quax498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded + +-- Zeros +quax500 quantize 0 1e1 -> 0E+1 +quax501 quantize 0 1e0 -> 0 +quax502 quantize 0 1e-1 -> 0.0 +quax503 quantize 0.0 1e-1 -> 0.0 +quax504 quantize 0.0 1e0 -> 0 +quax505 quantize 0.0 1e+1 -> 0E+1 +quax506 quantize 0E+1 1e-1 -> 0.0 +quax507 quantize 0E+1 1e0 -> 0 +quax508 quantize 0E+1 1e+1 -> 0E+1 +quax509 quantize -0 1e1 -> -0E+1 +quax510 quantize -0 1e0 -> -0 +quax511 quantize -0 1e-1 -> -0.0 +quax512 quantize -0.0 1e-1 -> -0.0 +quax513 quantize -0.0 1e0 -> -0 +quax514 quantize -0.0 1e+1 -> -0E+1 +quax515 quantize -0E+1 1e-1 -> -0.0 +quax516 quantize -0E+1 1e0 -> -0 +quax517 quantize -0E+1 1e+1 -> -0E+1 + +-- Suspicious RHS values +maxexponent: 999999999 +minexponent: -999999999 +precision: 15 +quax520 quantize 1.234 1e999999000 -> 0E+999999000 Inexact Rounded +quax521 quantize 123.456 1e999999000 -> 0E+999999000 Inexact Rounded +quax522 quantize 1.234 1e999999999 -> 0E+999999999 Inexact Rounded +quax523 quantize 123.456 1e999999999 -> 0E+999999999 Inexact Rounded +quax524 quantize 123.456 1e1000000000 -> NaN Invalid_operation +quax525 quantize 123.456 1e12345678903 -> NaN Invalid_operation +-- next four are "won't fit" overflows +quax526 quantize 1.234 1e-999999000 -> NaN Invalid_operation +quax527 quantize 123.456 1e-999999000 -> NaN Invalid_operation +quax528 quantize 1.234 1e-999999999 -> NaN Invalid_operation +quax529 quantize 123.456 1e-999999999 -> NaN Invalid_operation +quax530 quantize 123.456 1e-1000000014 -> NaN Invalid_operation +quax531 quantize 123.456 1e-12345678903 -> NaN Invalid_operation + +maxexponent: 999 +minexponent: -999 +precision: 15 +quax532 quantize 1.234E+999 1e999 -> 1E+999 Inexact Rounded +quax533 quantize 1.234E+998 1e999 -> 0E+999 Inexact Rounded +quax534 quantize 1.234 1e999 -> 0E+999 Inexact Rounded +quax535 quantize 1.234 1e1000 -> NaN Invalid_operation +quax536 quantize 1.234 1e5000 -> NaN Invalid_operation +quax537 quantize 0 1e-999 -> 0E-999 +-- next two are "won't fit" overflows +quax538 quantize 1.234 1e-999 -> NaN Invalid_operation +quax539 quantize 1.234 1e-1000 -> NaN Invalid_operation +quax540 quantize 1.234 1e-5000 -> NaN Invalid_operation +-- [more below] + +-- check bounds (lhs maybe out of range for destination, etc.) +precision: 7 +quax541 quantize 1E+999 1e+999 -> 1E+999 +quax542 quantize 1E+1000 1e+999 -> NaN Invalid_operation +quax543 quantize 1E+999 1e+1000 -> NaN Invalid_operation +quax544 quantize 1E-999 1e-999 -> 1E-999 +quax545 quantize 1E-1000 1e-999 -> 0E-999 Inexact Rounded +quax546 quantize 1E-999 1e-1000 -> 1.0E-999 +quax547 quantize 1E-1005 1e-999 -> 0E-999 Inexact Rounded +quax548 quantize 1E-1006 1e-999 -> 0E-999 Inexact Rounded +quax549 quantize 1E-1007 1e-999 -> 0E-999 Inexact Rounded +quax550 quantize 1E-998 1e-1005 -> NaN Invalid_operation -- won't fit +quax551 quantize 1E-999 1e-1005 -> 1.000000E-999 +quax552 quantize 1E-1000 1e-1005 -> 1.00000E-1000 Subnormal +quax553 quantize 1E-999 1e-1006 -> NaN Invalid_operation +quax554 quantize 1E-999 1e-1007 -> NaN Invalid_operation +-- related subnormal rounding +quax555 quantize 1.666666E-999 1e-1005 -> 1.666666E-999 +quax556 quantize 1.666666E-1000 1e-1005 -> 1.66667E-1000 Subnormal Inexact Rounded +quax557 quantize 1.666666E-1001 1e-1005 -> 1.6667E-1001 Subnormal Inexact Rounded +quax558 quantize 1.666666E-1002 1e-1005 -> 1.667E-1002 Subnormal Inexact Rounded +quax559 quantize 1.666666E-1003 1e-1005 -> 1.67E-1003 Subnormal Inexact Rounded +quax560 quantize 1.666666E-1004 1e-1005 -> 1.7E-1004 Subnormal Inexact Rounded +quax561 quantize 1.666666E-1005 1e-1005 -> 2E-1005 Subnormal Inexact Rounded +quax562 quantize 1.666666E-1006 1e-1005 -> 0E-1005 Inexact Rounded +quax563 quantize 1.666666E-1007 1e-1005 -> 0E-1005 Inexact Rounded + +-- Specials +quax580 quantize Inf -Inf -> Infinity +quax581 quantize Inf 1e-1000 -> NaN Invalid_operation +quax582 quantize Inf 1e-1 -> NaN Invalid_operation +quax583 quantize Inf 1e0 -> NaN Invalid_operation +quax584 quantize Inf 1e1 -> NaN Invalid_operation +quax585 quantize Inf 1e1000 -> NaN Invalid_operation +quax586 quantize Inf Inf -> Infinity +quax587 quantize -1000 Inf -> NaN Invalid_operation +quax588 quantize -Inf Inf -> -Infinity +quax589 quantize -1 Inf -> NaN Invalid_operation +quax590 quantize 0 Inf -> NaN Invalid_operation +quax591 quantize 1 Inf -> NaN Invalid_operation +quax592 quantize 1000 Inf -> NaN Invalid_operation +quax593 quantize Inf Inf -> Infinity +quax594 quantize Inf 1e-0 -> NaN Invalid_operation +quax595 quantize -0 Inf -> NaN Invalid_operation + +quax600 quantize -Inf -Inf -> -Infinity +quax601 quantize -Inf 1e-1000 -> NaN Invalid_operation +quax602 quantize -Inf 1e-1 -> NaN Invalid_operation +quax603 quantize -Inf 1e0 -> NaN Invalid_operation +quax604 quantize -Inf 1e1 -> NaN Invalid_operation +quax605 quantize -Inf 1e1000 -> NaN Invalid_operation +quax606 quantize -Inf Inf -> -Infinity +quax607 quantize -1000 Inf -> NaN Invalid_operation +quax608 quantize -Inf -Inf -> -Infinity +quax609 quantize -1 -Inf -> NaN Invalid_operation +quax610 quantize 0 -Inf -> NaN Invalid_operation +quax611 quantize 1 -Inf -> NaN Invalid_operation +quax612 quantize 1000 -Inf -> NaN Invalid_operation +quax613 quantize Inf -Inf -> Infinity +quax614 quantize -Inf 1e-0 -> NaN Invalid_operation +quax615 quantize -0 -Inf -> NaN Invalid_operation + +quax621 quantize NaN -Inf -> NaN +quax622 quantize NaN 1e-1000 -> NaN +quax623 quantize NaN 1e-1 -> NaN +quax624 quantize NaN 1e0 -> NaN +quax625 quantize NaN 1e1 -> NaN +quax626 quantize NaN 1e1000 -> NaN +quax627 quantize NaN Inf -> NaN +quax628 quantize NaN NaN -> NaN +quax629 quantize -Inf NaN -> NaN +quax630 quantize -1000 NaN -> NaN +quax631 quantize -1 NaN -> NaN +quax632 quantize 0 NaN -> NaN +quax633 quantize 1 NaN -> NaN +quax634 quantize 1000 NaN -> NaN +quax635 quantize Inf NaN -> NaN +quax636 quantize NaN 1e-0 -> NaN +quax637 quantize -0 NaN -> NaN + +quax641 quantize sNaN -Inf -> NaN Invalid_operation +quax642 quantize sNaN 1e-1000 -> NaN Invalid_operation +quax643 quantize sNaN 1e-1 -> NaN Invalid_operation +quax644 quantize sNaN 1e0 -> NaN Invalid_operation +quax645 quantize sNaN 1e1 -> NaN Invalid_operation +quax646 quantize sNaN 1e1000 -> NaN Invalid_operation +quax647 quantize sNaN NaN -> NaN Invalid_operation +quax648 quantize sNaN sNaN -> NaN Invalid_operation +quax649 quantize NaN sNaN -> NaN Invalid_operation +quax650 quantize -Inf sNaN -> NaN Invalid_operation +quax651 quantize -1000 sNaN -> NaN Invalid_operation +quax652 quantize -1 sNaN -> NaN Invalid_operation +quax653 quantize 0 sNaN -> NaN Invalid_operation +quax654 quantize 1 sNaN -> NaN Invalid_operation +quax655 quantize 1000 sNaN -> NaN Invalid_operation +quax656 quantize Inf sNaN -> NaN Invalid_operation +quax657 quantize NaN sNaN -> NaN Invalid_operation +quax658 quantize sNaN 1e-0 -> NaN Invalid_operation +quax659 quantize -0 sNaN -> NaN Invalid_operation + +-- propagating NaNs +quax661 quantize NaN9 -Inf -> NaN9 +quax662 quantize NaN8 919 -> NaN8 +quax663 quantize NaN71 Inf -> NaN71 +quax664 quantize NaN6 NaN5 -> NaN6 +quax665 quantize -Inf NaN4 -> NaN4 +quax666 quantize -919 NaN31 -> NaN31 +quax667 quantize Inf NaN2 -> NaN2 + +quax671 quantize sNaN99 -Inf -> NaN99 Invalid_operation +quax672 quantize sNaN98 -11 -> NaN98 Invalid_operation +quax673 quantize sNaN97 NaN -> NaN97 Invalid_operation +quax674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation +quax675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation +quax676 quantize -Inf sNaN92 -> NaN92 Invalid_operation +quax677 quantize 088 sNaN91 -> NaN91 Invalid_operation +quax678 quantize Inf sNaN90 -> NaN90 Invalid_operation +quax679 quantize NaN sNaN88 -> NaN88 Invalid_operation + +quax681 quantize -NaN9 -Inf -> -NaN9 +quax682 quantize -NaN8 919 -> -NaN8 +quax683 quantize -NaN71 Inf -> -NaN71 +quax684 quantize -NaN6 -NaN5 -> -NaN6 +quax685 quantize -Inf -NaN4 -> -NaN4 +quax686 quantize -919 -NaN31 -> -NaN31 +quax687 quantize Inf -NaN2 -> -NaN2 + +quax691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation +quax692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation +quax693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation +quax694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation +quax695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation +quax696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation +quax697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation +quax698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation +quax699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation + +-- subnormals and underflow +precision: 4 +maxexponent: 999 +minexponent: -999 +quax710 quantize 1.00E-999 1e-999 -> 1E-999 Rounded +quax711 quantize 0.1E-999 2e-1000 -> 1E-1000 Subnormal +quax712 quantize 0.10E-999 3e-1000 -> 1E-1000 Subnormal Rounded +quax713 quantize 0.100E-999 4e-1000 -> 1E-1000 Subnormal Rounded +quax714 quantize 0.01E-999 5e-1001 -> 1E-1001 Subnormal +-- next is rounded to Emin +quax715 quantize 0.999E-999 1e-999 -> 1E-999 Inexact Rounded +quax716 quantize 0.099E-999 10e-1000 -> 1E-1000 Inexact Rounded Subnormal + +quax717 quantize 0.009E-999 1e-1001 -> 1E-1001 Inexact Rounded Subnormal +quax718 quantize 0.001E-999 1e-1001 -> 0E-1001 Inexact Rounded +quax719 quantize 0.0009E-999 1e-1001 -> 0E-1001 Inexact Rounded +quax720 quantize 0.0001E-999 1e-1001 -> 0E-1001 Inexact Rounded + +quax730 quantize -1.00E-999 1e-999 -> -1E-999 Rounded +quax731 quantize -0.1E-999 1e-999 -> -0E-999 Rounded Inexact +quax732 quantize -0.10E-999 1e-999 -> -0E-999 Rounded Inexact +quax733 quantize -0.100E-999 1e-999 -> -0E-999 Rounded Inexact +quax734 quantize -0.01E-999 1e-999 -> -0E-999 Inexact Rounded +-- next is rounded to Emin +quax735 quantize -0.999E-999 90e-999 -> -1E-999 Inexact Rounded +quax736 quantize -0.099E-999 -1e-999 -> -0E-999 Inexact Rounded +quax737 quantize -0.009E-999 -1e-999 -> -0E-999 Inexact Rounded +quax738 quantize -0.001E-999 -0e-999 -> -0E-999 Inexact Rounded +quax739 quantize -0.0001E-999 0e-999 -> -0E-999 Inexact Rounded + +quax740 quantize -1.00E-999 1e-1000 -> -1.0E-999 Rounded +quax741 quantize -0.1E-999 1e-1000 -> -1E-1000 Subnormal +quax742 quantize -0.10E-999 1e-1000 -> -1E-1000 Subnormal Rounded +quax743 quantize -0.100E-999 1e-1000 -> -1E-1000 Subnormal Rounded +quax744 quantize -0.01E-999 1e-1000 -> -0E-1000 Inexact Rounded +-- next is rounded to Emin +quax745 quantize -0.999E-999 1e-1000 -> -1.0E-999 Inexact Rounded +quax746 quantize -0.099E-999 1e-1000 -> -1E-1000 Inexact Rounded Subnormal +quax747 quantize -0.009E-999 1e-1000 -> -0E-1000 Inexact Rounded +quax748 quantize -0.001E-999 1e-1000 -> -0E-1000 Inexact Rounded +quax749 quantize -0.0001E-999 1e-1000 -> -0E-1000 Inexact Rounded + +quax750 quantize -1.00E-999 1e-1001 -> -1.00E-999 +quax751 quantize -0.1E-999 1e-1001 -> -1.0E-1000 Subnormal +quax752 quantize -0.10E-999 1e-1001 -> -1.0E-1000 Subnormal +quax753 quantize -0.100E-999 1e-1001 -> -1.0E-1000 Subnormal Rounded +quax754 quantize -0.01E-999 1e-1001 -> -1E-1001 Subnormal +-- next is rounded to Emin +quax755 quantize -0.999E-999 1e-1001 -> -1.00E-999 Inexact Rounded +quax756 quantize -0.099E-999 1e-1001 -> -1.0E-1000 Inexact Rounded Subnormal +quax757 quantize -0.009E-999 1e-1001 -> -1E-1001 Inexact Rounded Subnormal +quax758 quantize -0.001E-999 1e-1001 -> -0E-1001 Inexact Rounded +quax759 quantize -0.0001E-999 1e-1001 -> -0E-1001 Inexact Rounded + +quax760 quantize -1.00E-999 1e-1002 -> -1.000E-999 +quax761 quantize -0.1E-999 1e-1002 -> -1.00E-1000 Subnormal +quax762 quantize -0.10E-999 1e-1002 -> -1.00E-1000 Subnormal +quax763 quantize -0.100E-999 1e-1002 -> -1.00E-1000 Subnormal +quax764 quantize -0.01E-999 1e-1002 -> -1.0E-1001 Subnormal +quax765 quantize -0.999E-999 1e-1002 -> -9.99E-1000 Subnormal +quax766 quantize -0.099E-999 1e-1002 -> -9.9E-1001 Subnormal +quax767 quantize -0.009E-999 1e-1002 -> -9E-1002 Subnormal +quax768 quantize -0.001E-999 1e-1002 -> -1E-1002 Subnormal +quax769 quantize -0.0001E-999 1e-1002 -> -0E-1002 Inexact Rounded + +-- rhs must be no less than Etiny +quax770 quantize -1.00E-999 1e-1003 -> NaN Invalid_operation +quax771 quantize -0.1E-999 1e-1003 -> NaN Invalid_operation +quax772 quantize -0.10E-999 1e-1003 -> NaN Invalid_operation +quax773 quantize -0.100E-999 1e-1003 -> NaN Invalid_operation +quax774 quantize -0.01E-999 1e-1003 -> NaN Invalid_operation +quax775 quantize -0.999E-999 1e-1003 -> NaN Invalid_operation +quax776 quantize -0.099E-999 1e-1003 -> NaN Invalid_operation +quax777 quantize -0.009E-999 1e-1003 -> NaN Invalid_operation +quax778 quantize -0.001E-999 1e-1003 -> NaN Invalid_operation +quax779 quantize -0.0001E-999 1e-1003 -> NaN Invalid_operation +quax780 quantize -0.0001E-999 1e-1004 -> NaN Invalid_operation + +precision: 9 +maxExponent: 999999999 +minexponent: -999999999 + +-- some extremes derived from Rescale testcases +quax801 quantize 0 1e1000000000 -> NaN Invalid_operation +quax802 quantize 0 1e-1000000000 -> 0E-1000000000 +quax803 quantize 0 1e2000000000 -> NaN Invalid_operation +quax804 quantize 0 1e-2000000000 -> NaN Invalid_operation +quax805 quantize 0 1e3000000000 -> NaN Invalid_operation +quax806 quantize 0 1e-3000000000 -> NaN Invalid_operation +quax807 quantize 0 1e4000000000 -> NaN Invalid_operation +quax808 quantize 0 1e-4000000000 -> NaN Invalid_operation +quax809 quantize 0 1e5000000000 -> NaN Invalid_operation +quax810 quantize 0 1e-5000000000 -> NaN Invalid_operation +quax811 quantize 0 1e6000000000 -> NaN Invalid_operation +quax812 quantize 0 1e-6000000000 -> NaN Invalid_operation +quax813 quantize 0 1e7000000000 -> NaN Invalid_operation +quax814 quantize 0 1e-7000000000 -> NaN Invalid_operation +quax815 quantize 0 1e8000000000 -> NaN Invalid_operation +quax816 quantize 0 1e-8000000000 -> NaN Invalid_operation +quax817 quantize 0 1e9000000000 -> NaN Invalid_operation +quax818 quantize 0 1e-9000000000 -> NaN Invalid_operation +quax819 quantize 0 1e9999999999 -> NaN Invalid_operation +quax820 quantize 0 1e-9999999999 -> NaN Invalid_operation +quax821 quantize 0 1e10000000000 -> NaN Invalid_operation +quax822 quantize 0 1e-10000000000 -> NaN Invalid_operation + +quax843 quantize 0 1e999999999 -> 0E+999999999 +quax844 quantize 0 1e1000000000 -> NaN Invalid_operation +quax845 quantize 0 1e-999999999 -> 0E-999999999 +quax846 quantize 0 1e-1000000000 -> 0E-1000000000 +quax847 quantize 0 1e-1000000001 -> 0E-1000000001 +quax848 quantize 0 1e-1000000002 -> 0E-1000000002 +quax849 quantize 0 1e-1000000003 -> 0E-1000000003 +quax850 quantize 0 1e-1000000004 -> 0E-1000000004 +quax851 quantize 0 1e-1000000005 -> 0E-1000000005 +quax852 quantize 0 1e-1000000006 -> 0E-1000000006 +quax853 quantize 0 1e-1000000007 -> 0E-1000000007 +quax854 quantize 0 1e-1000000008 -> NaN Invalid_operation + +quax861 quantize 1 1e+2147483649 -> NaN Invalid_operation +quax862 quantize 1 1e+2147483648 -> NaN Invalid_operation +quax863 quantize 1 1e+2147483647 -> NaN Invalid_operation +quax864 quantize 1 1e-2147483647 -> NaN Invalid_operation +quax865 quantize 1 1e-2147483648 -> NaN Invalid_operation +quax866 quantize 1 1e-2147483649 -> NaN Invalid_operation + +-- Null tests +quax900 quantize 10 # -> NaN Invalid_operation +quax901 quantize # 1e10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/randomBound32.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/randomBound32.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,2443 @@ +------------------------------------------------------------------------ +-- randomBound32.decTest -- decimal testcases -- boundaries near 32 -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- These testcases test calculations at precisions 31, 32, and 33, to +-- exercise the boundaries around 2**5 + +-- randomly generated testcases [26 Sep 2001] +extended: 1 +precision: 31 +rounding: half_up +maxExponent: 9999 +minexponent: -9999 + +addx3001 add 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> 2.189320103965343717049307148600E+799 Inexact Rounded +comx3001 compare 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> -1 +divx3001 divide 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> 2.262681764507965005284080800438E-787 Inexact Rounded +dvix3001 divideint 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> 0 +mulx3001 multiply 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> 1.084531091568672041923151632066E+812 Inexact Rounded +powx3001 power 4953734675913.065314738743322579 2 -> 24539487239343522246155890.99495 Inexact Rounded +remx3001 remainder 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> 4953734675913.065314738743322579 +subx3001 subtract 4953734675913.065314738743322579 0218.932010396534371704930714860E+797 -> -2.189320103965343717049307148600E+799 Inexact Rounded +addx3002 add 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> -7.886453204712287484430980636798E+944 Inexact Rounded +comx3002 compare 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> 1 +divx3002 divide 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> -1.222562801441069667849402782716E-1785 Inexact Rounded +dvix3002 divideint 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> -0 +mulx3002 multiply 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> -7.603869223099928141659831589905E+104 Inexact Rounded +powx3002 power 9641.684323386955881595490347910E-844 -8 -> 1.338988152067180337738955757587E+6720 Inexact Rounded +remx3002 remainder 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> 9.641684323386955881595490347910E-841 +subx3002 subtract 9641.684323386955881595490347910E-844 -78864532047.12287484430980636798E+934 -> 7.886453204712287484430980636798E+944 Inexact Rounded +addx3003 add -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> -1.028048571628326871054964307774E+529 Inexact Rounded +comx3003 compare -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> -1 +divx3003 divide -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> -2.089529249946971482861843692465E+515 Inexact Rounded +dvix3003 divideint -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> NaN Division_impossible +mulx3003 multiply -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> -5.057999861231255549283737861207E+542 Inexact Rounded +powx3003 power -1.028048571628326871054964307774E+529 5 -> -1.148333858253704284232780819739E+2645 Inexact Rounded +remx3003 remainder -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> NaN Division_impossible +subx3003 subtract -1.028048571628326871054964307774E+529 49200008645699.35577937582714739 -> -1.028048571628326871054964307774E+529 Inexact Rounded +addx3004 add 479084.8561808930525417735205519 084157571054.2691784660983989931 -> 84158050139.12535935915094076662 Inexact Rounded +comx3004 compare 479084.8561808930525417735205519 084157571054.2691784660983989931 -> -1 +divx3004 divide 479084.8561808930525417735205519 084157571054.2691784660983989931 -> 0.000005692712493709617905493710207969 Inexact Rounded +dvix3004 divideint 479084.8561808930525417735205519 084157571054.2691784660983989931 -> 0 +mulx3004 multiply 479084.8561808930525417735205519 084157571054.2691784660983989931 -> 40318617825067837.47317700523687 Inexact Rounded +powx3004 power 479084.8561808930525417735205519 8 -> 2.775233598021235973545933045837E+45 Inexact Rounded +remx3004 remainder 479084.8561808930525417735205519 084157571054.2691784660983989931 -> 479084.8561808930525417735205519 +subx3004 subtract 479084.8561808930525417735205519 084157571054.2691784660983989931 -> -84157091969.41299757304585721958 Inexact Rounded +addx3005 add -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> -363753960.6547166697980414728370 Inexact Rounded +comx3005 compare -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> -1 +divx3005 divide -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> 114672.6064337420167096295290890 Inexact Rounded +dvix3005 divideint -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> 114672 +mulx3005 multiply -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> 1153846941331.188583292239230818 Inexact Rounded +powx3005 power -0363750788.573782205664349562931 -3172 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3005 remainder -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> -1923.656911066945656824381431488 +subx3005 subtract -0363750788.573782205664349562931 -3172.080934464133691909905980096 -> -363747616.4928477415306576530250 Inexact Rounded +addx3006 add 1381026551423669919010191878449 -82.66614775445371254999357800739 -> 1381026551423669919010191878366 Inexact Rounded +comx3006 compare 1381026551423669919010191878449 -82.66614775445371254999357800739 -> 1 +divx3006 divide 1381026551423669919010191878449 -82.66614775445371254999357800739 -> -16706071214613552377376639557.90 Inexact Rounded +dvix3006 divideint 1381026551423669919010191878449 -82.66614775445371254999357800739 -> -16706071214613552377376639557 +mulx3006 multiply 1381026551423669919010191878449 -82.66614775445371254999357800739 -> -1.141641449528127656560770057228E+32 Inexact Rounded +powx3006 power 1381026551423669919010191878449 -83 -> 2.307977908106564299925193011052E-2502 Inexact Rounded +remx3006 remainder 1381026551423669919010191878449 -82.66614775445371254999357800739 -> 74.22115953553602036042168767377 +subx3006 subtract 1381026551423669919010191878449 -82.66614775445371254999357800739 -> 1381026551423669919010191878532 Inexact Rounded +addx3007 add 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> -4410583128274.803057056669103177 Inexact Rounded +comx3007 compare 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> 1 +divx3007 divide 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> -1.049073743992404570569003129346E-9 Inexact Rounded +dvix3007 divideint 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> -0 +mulx3007 multiply 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> -20407887067124025.31576887565113 Inexact Rounded +powx3007 power 4627.026960423072127953556635585 -4 -> 2.181684167222334934221407781701E-15 Inexact Rounded +remx3007 remainder 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> 4627.026960423072127953556635585 +subx3007 subtract 4627.026960423072127953556635585 -4410583132901.830017479741231131 -> 4410583137528.856977902813359085 Inexact Rounded +addx3008 add 75353574493.84484153484918212042 -8684111695095849922263044191221 -> -8684111695095849922187690616727 Inexact Rounded +comx3008 compare 75353574493.84484153484918212042 -8684111695095849922263044191221 -> 1 +divx3008 divide 75353574493.84484153484918212042 -8684111695095849922263044191221 -> -8.677177026223536475531592432118E-21 Inexact Rounded +dvix3008 divideint 75353574493.84484153484918212042 -8684111695095849922263044191221 -> -0 +mulx3008 multiply 75353574493.84484153484918212042 -8684111695095849922263044191221 -> -6.543788575292743281456830701127E+41 Inexact Rounded +powx3008 power 75353574493.84484153484918212042 -9 -> 1.276630670287906925570645490708E-98 Inexact Rounded +remx3008 remainder 75353574493.84484153484918212042 -8684111695095849922263044191221 -> 75353574493.84484153484918212042 +subx3008 subtract 75353574493.84484153484918212042 -8684111695095849922263044191221 -> 8684111695095849922338397765715 Inexact Rounded +addx3009 add 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 6907061.073440802792400108035410 Inexact Rounded +comx3009 compare 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 1 +divx3009 divide 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 2417586.646146283856436864121104 Inexact Rounded +dvix3009 divideint 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 2417586 +mulx3009 multiply 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 19733502.94653326211623698034717 Inexact Rounded +powx3009 power 6907058.216435355874729592373011 3 -> 329518156646369505494.8971353240 Inexact Rounded +remx3009 remainder 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 1.846043452483451396449034189630 +subx3009 subtract 6907058.216435355874729592373011 2.857005446917670515662398741545 -> 6907055.359429908957059076710612 Inexact Rounded +addx3010 add -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> -38949530427253.24030680468677190 Inexact Rounded +comx3010 compare -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> -1 +divx3010 divide -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> -5.469149031100999700489221122509E+996 Inexact Rounded +dvix3010 divideint -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> NaN Division_impossible +mulx3010 multiply -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> -2.773861000818483769292240109417E-970 Inexact Rounded +powx3010 power -38949530427253.24030680468677190 7 -> -1.359926959823071332599817363877E+95 Inexact Rounded +remx3010 remainder -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> NaN Division_impossible +subx3010 subtract -38949530427253.24030680468677190 712168021.1265384466442576619064E-992 -> -38949530427253.24030680468677190 Inexact Rounded +addx3011 add -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> -1270911.495819550779479954702829 Inexact Rounded +comx3011 compare -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> -1 +divx3011 divide -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> 1.258023449218665608349145394069 Inexact Rounded +dvix3011 divideint -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> 1 +mulx3011 multiply -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> 398531319444.8556128729086112205 Inexact Rounded +powx3011 power -0708069.025667471996378081482549 -562842 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3011 remainder -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> -145226.5555153932132762082622686 +subx3011 subtract -0708069.025667471996378081482549 -562842.4701520787831018732202804 -> -145226.5555153932132762082622686 +addx3012 add 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> -4.318314692189767383476104084575E+224 Inexact Rounded +comx3012 compare 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> 1 +divx3012 divide 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> -9.390439409913307906923909630247E-219 Inexact Rounded +dvix3012 divideint 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> -0 +mulx3012 multiply 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> -1.751114283680833039197637874453E+231 Inexact Rounded +powx3012 power 4055087.246994644709729942673976 -4 -> 3.698274893849241116195795515302E-27 Inexact Rounded +remx3012 remainder 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> 4055087.246994644709729942673976 +subx3012 subtract 4055087.246994644709729942673976 -43183146921897.67383476104084575E+211 -> 4.318314692189767383476104084575E+224 Inexact Rounded +addx3013 add 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> -815.9047305921862348263521876034 Inexact Rounded +comx3013 compare 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> 1 +divx3013 divide 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> -5.518899111238367862234798433551E-503 Inexact Rounded +dvix3013 divideint 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> -0 +mulx3013 multiply 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> -3.673934060071516156604453756541E-497 Inexact Rounded +powx3013 power 4502895892520.396581348110906909E-512 -816 -> Infinity Overflow Inexact Rounded +remx3013 remainder 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> 4.502895892520396581348110906909E-500 +subx3013 subtract 4502895892520.396581348110906909E-512 -815.9047305921862348263521876034 -> 815.9047305921862348263521876034 Inexact Rounded +addx3014 add 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> 465.6005787733070743275007572563 Inexact Rounded +comx3014 compare 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> 1 +divx3014 divide 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> -225.7594380101027705997496045999 Inexact Rounded +dvix3014 divideint 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> -225 +mulx3014 multiply 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> -968.8065431314121523074875069807 Inexact Rounded +powx3014 power 467.6721295072628100260239179865 -2 -> 0.000004572113694193221810609836080931 Inexact Rounded +remx3014 remainder 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> 1.57321436722227785831275368025 +subx3014 subtract 467.6721295072628100260239179865 -02.07155073395573569852316073025 -> 469.7436802412185457245470787168 Inexact Rounded +addx3015 add 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> -8677147.586389401682712180146855 Inexact Rounded +comx3015 compare 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> 1 +divx3015 divide 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> -2.485604044230163799604243529005E-578 Inexact Rounded +dvix3015 divideint 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> -0 +mulx3015 multiply 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> -1.871483124723381986272837942577E-564 Inexact Rounded +powx3015 power 2.156795313311150143949997552501E-571 -8677148 -> Infinity Overflow Inexact Rounded +remx3015 remainder 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> 2.156795313311150143949997552501E-571 +subx3015 subtract 2.156795313311150143949997552501E-571 -8677147.586389401682712180146855 -> 8677147.586389401682712180146855 Inexact Rounded +addx3016 add -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> -694070746.6469215276170700777068 Inexact Rounded +comx3016 compare -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> 1 +divx3016 divide -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> 0.001406664546942092941961075608769 Inexact Rounded +dvix3016 divideint -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> 0 +mulx3016 multiply -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> 675736017210596.9899587749991363 Inexact Rounded +powx3016 power -974953.2801637208368002585822457 -693095793 -> -0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3016 remainder -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> -974953.2801637208368002585822457 +subx3016 subtract -974953.2801637208368002585822457 -693095793.3667578067802698191246 -> 692120840.0865940859434695605424 Inexact Rounded +addx3017 add -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> -7634680140009571846155654339781 Inexact Rounded +comx3017 compare -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> -1 +divx3017 divide -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> -2.536749610869326753741024659948E+508 Inexact Rounded +dvix3017 divideint -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> NaN Division_impossible +mulx3017 multiply -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> -2.297756963892134373657544025107E-447 Inexact Rounded +powx3017 power -7634680140009571846155654339781 3 -> -4.450128382072157170207584847831E+92 Inexact Rounded +remx3017 remainder -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> NaN Division_impossible +subx3017 subtract -7634680140009571846155654339781 3009630949502.035852433434214413E-490 -> -7634680140009571846155654339781 Inexact Rounded +addx3018 add 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> 74177.21073338090843145838835480 Inexact Rounded +comx3018 compare 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> -1 +divx3018 divide 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> 3.535762799545274329358292065343E-624 Inexact Rounded +dvix3018 divideint 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> 0 +mulx3018 multiply 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> 1.945468124372395349192665031675E-614 Inexact Rounded +powx3018 power 262273.0222851186523650889896428E-624 74177 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3018 remainder 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> 2.622730222851186523650889896428E-619 +subx3018 subtract 262273.0222851186523650889896428E-624 74177.21073338090843145838835480 -> -74177.21073338090843145838835480 Inexact Rounded +addx3019 add -8036052748815903177624716581732 -066677357.4438809548850966167573 -> -8036052748815903177624783259089 Inexact Rounded +comx3019 compare -8036052748815903177624716581732 -066677357.4438809548850966167573 -> -1 +divx3019 divide -8036052748815903177624716581732 -066677357.4438809548850966167573 -> 120521464210387351732732.6271469 Inexact Rounded +dvix3019 divideint -8036052748815903177624716581732 -066677357.4438809548850966167573 -> 120521464210387351732732 +mulx3019 multiply -8036052748815903177624716581732 -066677357.4438809548850966167573 -> 5.358227615706800711033262124598E+38 Inexact Rounded +powx3019 power -8036052748815903177624716581732 -66677357 -> -0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3019 remainder -8036052748815903177624716581732 -066677357.4438809548850966167573 -> -41816499.5048993028288978900564 +subx3019 subtract -8036052748815903177624716581732 -066677357.4438809548850966167573 -> -8036052748815903177624649904375 Inexact Rounded +addx3020 add 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> 8.834295928031498103637713570166E+770 Inexact Rounded +comx3020 compare 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> 1 +divx3020 divide 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> -2.008754492913739633208672455025E+766 Inexact Rounded +dvix3020 divideint 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> NaN Division_impossible +mulx3020 multiply 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> -3.885232606540600490321438191516E+775 Inexact Rounded +powx3020 power 883429.5928031498103637713570166E+765 -43979 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3020 remainder 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> NaN Division_impossible +subx3020 subtract 883429.5928031498103637713570166E+765 -43978.97283712939198111043032726 -> 8.834295928031498103637713570166E+770 Inexact Rounded +addx3021 add 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> -5588536565419.943265474528122494 Inexact Rounded +comx3021 compare 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> 1 +divx3021 divide 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> -0.004416506865458415275182120038399 Inexact Rounded +dvix3021 divideint 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> -0 +mulx3021 multiply 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> -139161701088530765925120.8408852 Inexact Rounded +powx3021 power 24791301060.37938360567775506973 -6 -> 4.307289712375673028996126249656E-63 Inexact Rounded +remx3021 remainder 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> 24791301060.37938360567775506973 +subx3021 subtract 24791301060.37938360567775506973 -5613327866480.322649080205877564 -> 5638119167540.702032685883632634 Inexact Rounded +addx3022 add -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> -930712184.3335760878938383398937 Inexact Rounded +comx3022 compare -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> -1 +divx3022 divide -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> 1257062.290270583507131602958799 Inexact Rounded +dvix3022 divideint -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> 1257062 +mulx3022 multiply -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> 689085814282.3968746911100154133 Inexact Rounded +powx3022 power -930711443.9474781586162910776139 -740 -> 1.193603394165051899997226995178E-6637 Inexact Rounded +remx3022 remainder -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> -214.9123046664996750639167712140 +subx3022 subtract -930711443.9474781586162910776139 -740.3860979292775472622798348030 -> -930710703.5613802293387438153341 Inexact Rounded +addx3023 add 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 2358276428979.423170691006252127 Inexact Rounded +comx3023 compare 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 1 +divx3023 divide 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 11001528525.07089502152736489473 Inexact Rounded +dvix3023 divideint 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 11001528525 +mulx3023 multiply 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 505517728904226.6233443209659001 Inexact Rounded +powx3023 power 2358276428765.064191082773385539 214 -> 5.435856480782850080741276939256E+2647 Inexact Rounded +remx3023 remainder 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 15.1969844739096415643561521775 +subx3023 subtract 2358276428765.064191082773385539 214.3589796082328665878602304469 -> 2358276428550.705211474540518951 Inexact Rounded +addx3024 add -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> -3.868744449795653651638308926987E+750 Inexact Rounded +comx3024 compare -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> -1 +divx3024 divide -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> -4.677779235812959233092739433453E+746 Inexact Rounded +dvix3024 divideint -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> NaN Division_impossible +mulx3024 multiply -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> -3.199634455434813294426505526063E+754 Inexact Rounded +powx3024 power -3.868744449795653651638308926987E+750 8270 -> Infinity Overflow Inexact Rounded +remx3024 remainder -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> NaN Division_impossible +subx3024 subtract -3.868744449795653651638308926987E+750 8270.472492965559872384018329418 -> -3.868744449795653651638308926987E+750 Inexact Rounded +addx3025 add 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> -567195652586.2454217069003186487 Inexact Rounded +comx3025 compare 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> 1 +divx3025 divide 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> -2.475725421131866851190640203633E-451 Inexact Rounded +dvix3025 divideint 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> -0 +mulx3025 multiply 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> -7.964678739652657498503799559950E-428 Inexact Rounded +powx3025 power 140422069.5863246490180206814374E-447 -6 -> 1.304330899731988395473578425854E+2633 Inexact Rounded +remx3025 remainder 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> 1.404220695863246490180206814374E-439 +subx3025 subtract 140422069.5863246490180206814374E-447 -567195652586.2454217069003186487 -> 567195652586.2454217069003186487 Inexact Rounded +addx3026 add 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> -9.452601935038035195726041512900E+467 Inexact Rounded +comx3026 compare 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> 1 +divx3026 divide 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> -8.032613347885465805613265604973E-305 Inexact Rounded +dvix3026 divideint 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> -0 +mulx3026 multiply 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> -7.177275242712723733041569606882E+631 Inexact Rounded +powx3026 power 75929096475.63450425339472559646E+153 -9 -> 1.192136299657177324051477375561E-1475 Inexact Rounded +remx3026 remainder 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> 7.592909647563450425339472559646E+163 +subx3026 subtract 75929096475.63450425339472559646E+153 -0945260193.503803519572604151290E+459 -> 9.452601935038035195726041512900E+467 Inexact Rounded +addx3027 add 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> -5.641317823202274083982487558514E+637 Inexact Rounded +comx3027 compare 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> 1 +divx3027 divide 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> -1.118943925332481944765809682502E-628 Inexact Rounded +dvix3027 divideint 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> -0 +mulx3027 multiply 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> -3.560979378308906043783023726787E+647 Inexact Rounded +powx3027 power 6312318309.142044953357460463732 -6 -> 1.580762611512787720076533747265E-59 Inexact Rounded +remx3027 remainder 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> 6312318309.142044953357460463732 +subx3027 subtract 6312318309.142044953357460463732 -5641317823.202274083982487558514E+628 -> 5.641317823202274083982487558514E+637 Inexact Rounded +addx3028 add 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> 93793652428100.52105928239469937 Inexact Rounded +comx3028 compare 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> 1 +divx3028 divide 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> 1.022544815694674972559924997256E+723 Inexact Rounded +dvix3028 divideint 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> NaN Division_impossible +mulx3028 multiply 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> 8.603289656137796526769786965341E-696 Inexact Rounded +powx3028 power 93793652428100.52105928239469937 9 -> 5.617732206663136654187263964365E+125 Inexact Rounded +remx3028 remainder 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> NaN Division_impossible +subx3028 subtract 93793652428100.52105928239469937 917.2571313109730433369594936416E-712 -> 93793652428100.52105928239469937 Inexact Rounded +addx3029 add 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded +comx3029 compare 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1 +divx3029 divide 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> -4103968.106336710126241266685434 Inexact Rounded +dvix3029 divideint 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> -4103968 +mulx3029 multiply 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> -2362732023235112.375960528304974 Inexact Rounded +powx3029 power 98471198160.56524417578665886060 -23994 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3029 remainder 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 2551.45824316125588493249246784 +subx3029 subtract 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471222154.70837811518409435005 Inexact Rounded +addx3030 add 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> 329324100.9201858301191681987940 Inexact Rounded +comx3030 compare 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> 1 +divx3030 divide 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> -134358.6406732917173739187421978 Inexact Rounded +dvix3030 divideint 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> -134358 +mulx3030 multiply 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> -807212527028.0005401736893474430 Inexact Rounded +powx3030 power 329326552.0208398002250836592043 -2451 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3030 remainder 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> 1570.35472430963565384668749322 +subx3030 subtract 329326552.0208398002250836592043 -02451.10065397010591546041034041 -> 329329003.1214937703309991196146 Inexact Rounded +addx3031 add -92980.68431371090354435763218439 -2282178507046019721925800997065 -> -2282178507046019721925801090046 Inexact Rounded +comx3031 compare -92980.68431371090354435763218439 -2282178507046019721925800997065 -> 1 +divx3031 divide -92980.68431371090354435763218439 -2282178507046019721925800997065 -> 4.074207342968196863070496994457E-26 Inexact Rounded +dvix3031 divideint -92980.68431371090354435763218439 -2282178507046019721925800997065 -> 0 +mulx3031 multiply -92980.68431371090354435763218439 -2282178507046019721925800997065 -> 2.121985193111820147170707717938E+35 Inexact Rounded +powx3031 power -92980.68431371090354435763218439 -2 -> 1.156683455371909793870207184337E-10 Inexact Rounded +remx3031 remainder -92980.68431371090354435763218439 -2282178507046019721925800997065 -> -92980.68431371090354435763218439 +subx3031 subtract -92980.68431371090354435763218439 -2282178507046019721925800997065 -> 2282178507046019721925800904084 Inexact Rounded +addx3032 add 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> 1.213581776227858606259822256987E+748 Inexact Rounded +comx3032 compare 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> 1 +divx3032 divide 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> 1.233860374149945561886955398724E+1648 Inexact Rounded +dvix3032 divideint 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> NaN Division_impossible +mulx3032 multiply 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> 1.193636458750059340733188876015E-152 Inexact Rounded +powx3032 power 12135817762.27858606259822256987E+738 10 -> 6.929317520577437720457517499936E+7480 Inexact Rounded +remx3032 remainder 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> NaN Division_impossible +subx3032 subtract 12135817762.27858606259822256987E+738 98.35649167872356132249561021910E-902 -> 1.213581776227858606259822256987E+748 Inexact Rounded +addx3033 add 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> -392513.2044337156627881674596002 Inexact Rounded +comx3033 compare 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> 1 +divx3033 divide 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> -0.00009495486002714264641177211062199 Inexact Rounded +dvix3033 divideint 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> -0 +mulx3033 multiply 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> -14632152.58043001234518095997140 Inexact Rounded +powx3033 power 37.27457578793521166809739140081 -392550 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3033 remainder 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> 37.27457578793521166809739140081 +subx3033 subtract 37.27457578793521166809739140081 -392550.4790095035979998355569916 -> 392587.7535852915332115036543830 Inexact Rounded +addx3034 add -2787.980590304199878755265273703 7117631179305319208210387565324 -> 7117631179305319208210387562536 Inexact Rounded +comx3034 compare -2787.980590304199878755265273703 7117631179305319208210387565324 -> -1 +divx3034 divide -2787.980590304199878755265273703 7117631179305319208210387565324 -> -3.917006262435063093475140250870E-28 Inexact Rounded +dvix3034 divideint -2787.980590304199878755265273703 7117631179305319208210387565324 -> -0 +mulx3034 multiply -2787.980590304199878755265273703 7117631179305319208210387565324 -> -1.984381757684722217801410305714E+34 Inexact Rounded +powx3034 power -2787.980590304199878755265273703 7 -> -1309266999233099220127139.440082 Inexact Rounded +remx3034 remainder -2787.980590304199878755265273703 7117631179305319208210387565324 -> -2787.980590304199878755265273703 +subx3034 subtract -2787.980590304199878755265273703 7117631179305319208210387565324 -> -7117631179305319208210387568112 Inexact Rounded +addx3035 add -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> -9.890633854609434943559831911276E+977 Inexact Rounded +comx3035 compare -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> -1 +divx3035 divide -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> 5.098302376420396260404821158158E+968 Inexact Rounded +dvix3035 divideint -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> NaN Division_impossible +mulx3035 multiply -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> 1.918768853302706825964087702307E+987 Inexact Rounded +powx3035 power -9890633.854609434943559831911276E+971 -2 -> 1.022237362667592867768511487814E-1956 Inexact Rounded +remx3035 remainder -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> NaN Division_impossible +subx3035 subtract -9890633.854609434943559831911276E+971 -1939985729.436827777055699361237 -> -9.890633854609434943559831911276E+977 Inexact Rounded +addx3036 add 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> 3927209601.042340294247970850347 Inexact Rounded +comx3036 compare 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> 1 +divx3036 divide 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> -227.2123393091837706827708196101 Inexact Rounded +dvix3036 divideint 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> -227 +mulx3036 multiply 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> -68480589931920481.56020043213767 Inexact Rounded +powx3036 power 3944570323.331121750661920475191 -17360722 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3036 remainder 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> 3686363.77773114469535563568018 +subx3036 subtract 3944570323.331121750661920475191 -17360722.28878145641394962484366 -> 3961931045.619903207075870100035 Inexact Rounded +addx3037 add 19544.14018503427029002552872707 1786697762.885178994182133839546 -> 1786717307.025364028452423865075 Inexact Rounded +comx3037 compare 19544.14018503427029002552872707 1786697762.885178994182133839546 -> -1 +divx3037 divide 19544.14018503427029002552872707 1786697762.885178994182133839546 -> 0.00001093869404832867759234359871991 Inexact Rounded +dvix3037 divideint 19544.14018503427029002552872707 1786697762.885178994182133839546 -> 0 +mulx3037 multiply 19544.14018503427029002552872707 1786697762.885178994182133839546 -> 34919471546115.05897163496162290 Inexact Rounded +powx3037 power 19544.14018503427029002552872707 2 -> 381973415.5722714009298802557940 Inexact Rounded +remx3037 remainder 19544.14018503427029002552872707 1786697762.885178994182133839546 -> 19544.14018503427029002552872707 +subx3037 subtract 19544.14018503427029002552872707 1786697762.885178994182133839546 -> -1786678218.744993959911843814017 Inexact Rounded +addx3038 add -05.75485957937617757983513662981 5564476875.989640431173694372083 -> 5564476870.234780851797516792248 Inexact Rounded +comx3038 compare -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -1 +divx3038 divide -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -1.034213944568271324841608825136E-9 Inexact Rounded +dvix3038 divideint -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -0 +mulx3038 multiply -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -32022783054.00620878436398990135 Inexact Rounded +powx3038 power -05.75485957937617757983513662981 6 -> 36325.23118223611421303238908472 Inexact Rounded +remx3038 remainder -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -5.75485957937617757983513662981 +subx3038 subtract -05.75485957937617757983513662981 5564476875.989640431173694372083 -> -5564476881.744500010549871951918 Inexact Rounded +addx3039 add -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> 6.268877553774705678201112845462E+211 Inexact Rounded +comx3039 compare -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -1 +divx3039 divide -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -6.713834913211527184907421856434E-206 Inexact Rounded +dvix3039 divideint -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -0 +mulx3039 multiply -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -2.638458285983158789458925170267E+218 Inexact Rounded +powx3039 power -4208820.898718069194008526302746 6 -> 5.558564783291260359142223337994E+39 Inexact Rounded +remx3039 remainder -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -4208820.898718069194008526302746 +subx3039 subtract -4208820.898718069194008526302746 626887.7553774705678201112845462E+206 -> -6.268877553774705678201112845462E+211 Inexact Rounded +addx3040 add -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> -7.007719547806630896979085821269E+562 Inexact Rounded +comx3040 compare -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> -1 +divx3040 divide -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> -1.521048673498997627360230078306E+559 Inexact Rounded +dvix3040 divideint -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> NaN Division_impossible +mulx3040 multiply -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> -3.228570795682925509478191397878E+566 Inexact Rounded +powx3040 power -70077195478066.30896979085821269E+549 4607 -> -Infinity Overflow Inexact Rounded +remx3040 remainder -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> NaN Division_impossible +subx3040 subtract -70077195478066.30896979085821269E+549 4607.163248554155483681430013073 -> -7.007719547806630896979085821269E+562 Inexact Rounded +addx3041 add -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> -68569709.81053713470972973953995 Inexact Rounded +comx3041 compare -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> 1 +divx3041 divide -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> 0.006501728568934042143913111768557 Inexact Rounded +dvix3041 divideint -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> 0 +mulx3041 multiply -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> 30176190149574.84386395947593970 Inexact Rounded +powx3041 power -442941.7541811527940918244383454 -68126768 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3041 remainder -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> -442941.7541811527940918244383454 +subx3041 subtract -442941.7541811527940918244383454 -068126768.0563559819156379151016 -> 67683826.30217482912154609066325 Inexact Rounded +addx3042 add -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -40726479019.92472703575370611619 Inexact Rounded +comx3042 compare -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -1 +divx3042 divide -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -135895.4741975690872548233111888 Inexact Rounded +dvix3042 divideint -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -135895 +mulx3042 multiply -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -12205487445696816.02175665622242 Inexact Rounded +powx3042 power -040726778711.8677615616711676159 299692 -> Infinity Overflow Inexact Rounded +remx3042 remainder -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -142113.1908620082406650022240180 +subx3042 subtract -040726778711.8677615616711676159 299691.9430345259174614997064916 -> -40727078403.81079608758862911561 Inexact Rounded +addx3043 add -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -1934197516.927615489663964685661 Inexact Rounded +comx3043 compare -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -1 +divx3043 divide -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -507563287.7312566071537233697473 Inexact Rounded +dvix3043 divideint -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -507563287 +mulx3043 multiply -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -7370745953.579062985130438309023 Inexact Rounded +powx3043 power -1934197520.738366912179143085955 4 -> 1.399597922275400947497855539475E+37 Inexact Rounded +remx3043 remainder -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -2.786637155934674312936704177047 +subx3043 subtract -1934197520.738366912179143085955 3.810751422515178400293693371519 -> -1934197524.549118334694321486249 Inexact Rounded +addx3044 add 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> -303284009454.0558644298079356347 Inexact Rounded +comx3044 compare 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> 1 +divx3044 divide 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> -0.000002681514904267770294213381485108 Inexact Rounded +dvix3044 divideint 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> -0 +mulx3044 multiply 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> -246650255735392080.1357404280431 Inexact Rounded +powx3044 power 813262.7723533833038829559646830 -3 -> 1.859119568310997605545914895133E-18 Inexact Rounded +remx3044 remainder 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> 813262.7723533833038829559646830 +subx3044 subtract 813262.7723533833038829559646830 -303284822716.8282178131118185907 -> 303285635979.6005711964157015467 Inexact Rounded +addx3045 add 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> 36105954884.94621434979365589311 Inexact Rounded +comx3045 compare 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> 1 +divx3045 divide 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> 4.842808328786805821411674302686E+953 Inexact Rounded +dvix3045 divideint 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> NaN Division_impossible +mulx3045 multiply 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> 2.691909094160561673391352743869E-933 Inexact Rounded +powx3045 power 36105954884.94621434979365589311 7 -> 7.999297449713301719582732447386E+73 Inexact Rounded +remx3045 remainder 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> NaN Division_impossible +subx3045 subtract 36105954884.94621434979365589311 745558205.7692397481313005659523E-952 -> 36105954884.94621434979365589311 Inexact Rounded +addx3046 add -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -48556402282.66602309736499370002 +comx3046 compare -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -1 +divx3046 divide -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -2.799666682029089956269018541649 Inexact Rounded +dvix3046 divideint -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -2 +mulx3046 multiply -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -2038051610593641947717.268652175 Inexact Rounded +powx3046 power -075537177538.1814516621962185490 3 -> -4.310049518987988084595264617727E+32 Inexact Rounded +remx3046 remainder -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -21575627027.15059453253376885104 +subx3046 subtract -075537177538.1814516621962185490 26980775255.51542856483122484898 -> -102517952793.6968802270274433980 Inexact Rounded +addx3047 add -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> -4223765.415319564898840040697647 Inexact Rounded +comx3047 compare -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> -1 +divx3047 divide -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> 1.630425855588347356570076909053E+191 Inexact Rounded +dvix3047 divideint -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> NaN Division_impossible +mulx3047 multiply -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> 1.094204573762229308798604845395E-178 Inexact Rounded +powx3047 power -4223765.415319564898840040697647 -3 -> -1.327090775863616939309569791138E-20 Inexact Rounded +remx3047 remainder -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> NaN Division_impossible +subx3047 subtract -4223765.415319564898840040697647 -2590590305497454185455459149918E-215 -> -4223765.415319564898840040697647 Inexact Rounded +addx3048 add -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> -7.877324314273694312164407794939E+270 Inexact Rounded +comx3048 compare -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> 1 +divx3048 divide -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> 8.212057140774706874666307246628E-268 Inexact Rounded +dvix3048 divideint -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> 0 +mulx3048 multiply -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> 5.095765270616284455922747530676E+274 Inexact Rounded +powx3048 power -6468.903738522951259063099946195 -8 -> 3.261027724982089298030362367616E-31 Inexact Rounded +remx3048 remainder -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> -6468.903738522951259063099946195 +subx3048 subtract -6468.903738522951259063099946195 -7877.324314273694312164407794939E+267 -> 7.877324314273694312164407794939E+270 Inexact Rounded +addx3049 add -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> 1650.198961256061165362319471264 Inexact Rounded +comx3049 compare -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -1 +divx3049 divide -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -5.797616777301250711985729776957E-200 Inexact Rounded +dvix3049 divideint -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -0 +mulx3049 multiply -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -1.578781845938805737527304303976E-193 Inexact Rounded +powx3049 power -9567221.183663236817239254783372E-203 1650 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3049 remainder -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -9.567221183663236817239254783372E-197 +subx3049 subtract -9567221.183663236817239254783372E-203 1650.198961256061165362319471264 -> -1650.198961256061165362319471264 Inexact Rounded +addx3050 add 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> 2.679017380163975186972720427030E+572 Inexact Rounded +comx3050 compare 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> -1 +divx3050 divide 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> 3.289379965960065573444140749635E-988 Inexact Rounded +dvix3050 divideint 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> 0 +mulx3050 multiply 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> 2.360832119793036398127652187732E+157 Inexact Rounded +powx3050 power 8812306098770.200752139142033569E-428 3 -> 6.843349527476967274129043949969E-1246 Inexact Rounded +remx3050 remainder 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> 8.812306098770200752139142033569E-416 +subx3050 subtract 8812306098770.200752139142033569E-428 26790.17380163975186972720427030E+568 -> -2.679017380163975186972720427030E+572 Inexact Rounded +addx3051 add 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> -706127147059.6372708438205200619 Inexact Rounded +comx3051 compare 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> 1 +divx3051 divide 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> -0.0001134341690057060105325397863996 Inexact Rounded +dvix3051 divideint 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> -0 +mulx3051 multiply 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> -56572874185674332398.36004114372 Inexact Rounded +powx3051 power 80108033.12724838718736922500904 -7 -> 4.723539145042336483008674060324E-56 Inexact Rounded +remx3051 remainder 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> 80108033.12724838718736922500904 +subx3051 subtract 80108033.12724838718736922500904 -706207255092.7645192310078892869 -> 706287363125.8917676181952585119 Inexact Rounded +addx3052 add -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> -37942846288.41047269183344038636 Inexact Rounded +comx3052 compare -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> -1 +divx3052 divide -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> 6716194607.139224735032566328960 Inexact Rounded +dvix3052 divideint -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> 6716194607 +mulx3052 multiply -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> 214356442635.9672009449140933366 Inexact Rounded +powx3052 power -37942846282.76101663789059003505 -6 -> 3.351355986382646046773008753885E-64 Inexact Rounded +remx3052 remainder -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> -0.786544022188321089603127981421 +subx3052 subtract -37942846282.76101663789059003505 -5.649456053942850351313869983197 -> -37942846277.11156058394773968374 Inexact Rounded +addx3053 add 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> 92659632115305.13735437728445541 Inexact Rounded +comx3053 compare 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> 1 +divx3053 divide 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> 1.429174267919135710410529211791E+146 Inexact Rounded +dvix3053 divideint 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> NaN Division_impossible +mulx3053 multiply 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> 6.007530093754446085819255987878E-119 Inexact Rounded +powx3053 power 92659632115305.13735437728445541 6 -> 6.329121451953461546696051563323E+83 Inexact Rounded +remx3053 remainder 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> NaN Division_impossible +subx3053 subtract 92659632115305.13735437728445541 6483438.317862851676468094261410E-139 -> 92659632115305.13735437728445541 Inexact Rounded +addx3054 add 2838948.589837595494152150647194 569547026247.5469563701415715960 -> 569549865196.1367939656357237466 Inexact Rounded +comx3054 compare 2838948.589837595494152150647194 569547026247.5469563701415715960 -> -1 +divx3054 divide 2838948.589837595494152150647194 569547026247.5469563701415715960 -> 0.000004984572755198057481907281080406 Inexact Rounded +dvix3054 divideint 2838948.589837595494152150647194 569547026247.5469563701415715960 -> 0 +mulx3054 multiply 2838948.589837595494152150647194 569547026247.5469563701415715960 -> 1616914727011669419.390959984273 Inexact Rounded +powx3054 power 2838948.589837595494152150647194 6 -> 5.235343334986059753096884080673E+38 Inexact Rounded +remx3054 remainder 2838948.589837595494152150647194 569547026247.5469563701415715960 -> 2838948.589837595494152150647194 +subx3054 subtract 2838948.589837595494152150647194 569547026247.5469563701415715960 -> -569544187298.9571187746474194454 Inexact Rounded +addx3055 add 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> 5.249952045236053307941775794287E+705 Inexact Rounded +comx3055 compare 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> 1 +divx3055 divide 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> 3.302685669286670708554753139233E+675 Inexact Rounded +dvix3055 divideint 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> NaN Division_impossible +mulx3055 multiply 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> 8.345328389435009812933599889447E+735 Inexact Rounded +powx3055 power 524995204523.6053307941775794287E+694 2 -> 2.756199647727821911857160230849E+1411 Inexact Rounded +remx3055 remainder 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> NaN Division_impossible +subx3055 subtract 524995204523.6053307941775794287E+694 1589600879689517100527293028553 -> 5.249952045236053307941775794287E+705 Inexact Rounded +addx3056 add -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -52461892246715.82764070853532913 Inexact Rounded +comx3056 compare -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -1 +divx3056 divide -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -12.23457628210057733643575143694 Inexact Rounded +dvix3056 divideint -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -12 +mulx3056 multiply -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -266786248710342647746063322.0544 Inexact Rounded +powx3056 power -57131573677452.15449921725097290 5 -> -6.086686503752679375430019503679E+68 Inexact Rounded +remx3056 remainder -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -1095396508616.232197112663247672 +subx3056 subtract -57131573677452.15449921725097290 4669681430736.326858508715643769 -> -61801255108188.48135772596661667 Inexact Rounded +addx3057 add 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> 90794821.08377791746707352380646 Inexact Rounded +comx3057 compare 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> 1 +divx3057 divide 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> -16594131.20365054928428313232246 Inexact Rounded +dvix3057 divideint 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> -16594131 +mulx3057 multiply 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> -496784099.6333617958496589124964 Inexact Rounded +powx3057 power 90794826.55528018781830463383411 -5 -> 1.620669590532856523565742953997E-40 Inexact Rounded +remx3057 remainder 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> 1.114274442767230442307896655232 +subx3057 subtract 90794826.55528018781830463383411 -5.471502270351231110027647216128 -> 90794832.02678245816953574386176 Inexact Rounded +addx3058 add 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> 58461733862.10202881160156091690 Inexact Rounded +comx3058 compare 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> 1 +divx3058 divide 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> -1243.257894477021678809337875304 Inexact Rounded +dvix3058 divideint 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> -1243 +mulx3058 multiply 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> -2753474621708672573.249029643967 Inexact Rounded +powx3058 power 58508794729.35191160840980489138 -47060867 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3058 remainder 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> 12136737.74759517576254461832107 +subx3058 subtract 58508794729.35191160840980489138 -47060867.24988279680824397447551 -> 58555855596.60179440521804886586 Inexact Rounded +addx3059 add -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> 9.595418300613754556671852801667E+391 Inexact Rounded +comx3059 compare -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -1 +divx3059 divide -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -7.775628465932789700547872511745E-381 Inexact Rounded +dvix3059 divideint -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -0 +mulx3059 multiply -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -7.159180712764549711669939947084E+403 Inexact Rounded +powx3059 power -746104.0768078474426464219416332E+006 10 -> 5.345571346302582882805035996696E+118 Inexact Rounded +remx3059 remainder -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -746104076807.8474426464219416332 +subx3059 subtract -746104.0768078474426464219416332E+006 9595418.300613754556671852801667E+385 -> -9.595418300613754556671852801667E+391 Inexact Rounded +addx3060 add 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> 5.599427632688387400403789659459E+120 Inexact Rounded +comx3060 compare 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> 1 +divx3060 divide 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> -6.105892851759828176655685111491E+119 Inexact Rounded +dvix3060 divideint 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> NaN Division_impossible +mulx3060 multiply 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> -5.134972161307679939281170944556E+121 Inexact Rounded +powx3060 power 55.99427632688387400403789659459E+119 -9 -> 1.848022584764384077672041056396E-1087 Inexact Rounded +remx3060 remainder 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> NaN Division_impossible +subx3060 subtract 55.99427632688387400403789659459E+119 -9.170530450881612853998489340127 -> 5.599427632688387400403789659459E+120 Inexact Rounded +addx3061 add -41214265628.83801241467317270595 1015336323798389903361978271354 -> 1015336323798389903320764005725 Inexact Rounded +comx3061 compare -41214265628.83801241467317270595 1015336323798389903361978271354 -> -1 +divx3061 divide -41214265628.83801241467317270595 1015336323798389903361978271354 -> -4.059173759750342247620706384027E-20 Inexact Rounded +dvix3061 divideint -41214265628.83801241467317270595 1015336323798389903361978271354 -> -0 +mulx3061 multiply -41214265628.83801241467317270595 1015336323798389903361978271354 -> -4.184634095163472384028549378392E+40 Inexact Rounded +powx3061 power -41214265628.83801241467317270595 1 -> -41214265628.83801241467317270595 +remx3061 remainder -41214265628.83801241467317270595 1015336323798389903361978271354 -> -41214265628.83801241467317270595 +subx3061 subtract -41214265628.83801241467317270595 1015336323798389903361978271354 -> -1015336323798389903403192536983 Inexact Rounded +addx3062 add 89937.39749201095570357557430822 82351554210093.60879476027800331 -> 82351554300031.00628677123370689 Inexact Rounded +comx3062 compare 89937.39749201095570357557430822 82351554210093.60879476027800331 -> -1 +divx3062 divide 89937.39749201095570357557430822 82351554210093.60879476027800331 -> 1.092115362662913415592930982129E-9 Inexact Rounded +dvix3062 divideint 89937.39749201095570357557430822 82351554210093.60879476027800331 -> 0 +mulx3062 multiply 89937.39749201095570357557430822 82351554210093.60879476027800331 -> 7406484465078077191.920015793662 Inexact Rounded +powx3062 power 89937.39749201095570357557430822 8 -> 4.280776267723913043050100934291E+39 Inexact Rounded +remx3062 remainder 89937.39749201095570357557430822 82351554210093.60879476027800331 -> 89937.39749201095570357557430822 +subx3062 subtract 89937.39749201095570357557430822 82351554210093.60879476027800331 -> -82351554120156.21130274932229973 Inexact Rounded +addx3063 add 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> 1.712661646770821562841254869430E+365 Inexact Rounded +comx3063 compare 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> 1 +divx3063 divide 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> 2.956290925475414185960999788848E+397 Inexact Rounded +dvix3063 divideint 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> NaN Division_impossible +mulx3063 multiply 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> 9.921925785595813587655312307930E+332 Inexact Rounded +powx3063 power 01712661.64677082156284125486943E+359 6 -> 2.523651803323047711735501944959E+2191 Inexact Rounded +remx3063 remainder 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> NaN Division_impossible +subx3063 subtract 01712661.64677082156284125486943E+359 57932.78435529483241552042115837E-037 -> 1.712661646770821562841254869430E+365 Inexact Rounded +addx3064 add -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> -658179152015.9868345843925715053 Inexact Rounded +comx3064 compare -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> 1 +divx3064 divide -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> 0.004038849497560303158639192895544 Inexact Rounded +dvix3064 divideint -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> 0 +mulx3064 multiply -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> 1735580967057433153120.099643641 Inexact Rounded +powx3064 power -2647593306.528617691373470059213 -7 -> -1.096581914005902583413810201571E-66 Inexact Rounded +remx3064 remainder -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> -2647593306.528617691373470059213 +subx3064 subtract -2647593306.528617691373470059213 -655531558709.4582168930191014461 -> 652883965402.9295992016456313869 Inexact Rounded +addx3065 add 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> -7.145586619176091599264717047885E+788 Inexact Rounded +comx3065 compare 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> 1 +divx3065 divide 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> -4.064157144036712325084472022316E-1088 Inexact Rounded +dvix3065 divideint 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> -0 +mulx3065 multiply 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> -2.075134583305571527962710017262E+490 Inexact Rounded +powx3065 power 2904078690665765116603253099668E-329 -7 -> 5.740389208842895561250128407803E+2089 Inexact Rounded +remx3065 remainder 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> 2.904078690665765116603253099668E-299 +subx3065 subtract 2904078690665765116603253099668E-329 -71.45586619176091599264717047885E+787 -> 7.145586619176091599264717047885E+788 Inexact Rounded +addx3066 add 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> 22094338972.39109726522477999515 Inexact Rounded +comx3066 compare 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> 1 +divx3066 divide 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> -5.390880808019174194010224736965E+497 Inexact Rounded +dvix3066 divideint 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> NaN Division_impossible +mulx3066 multiply 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> -9.055288588476315822113975426730E-478 Inexact Rounded +powx3066 power 22094338972.39109726522477999515 -4 -> 4.196391022354122686725315209967E-42 Inexact Rounded +remx3066 remainder 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> NaN Division_impossible +subx3066 subtract 22094338972.39109726522477999515 -409846549371.3900805039668417203E-499 -> 22094338972.39109726522477999515 Inexact Rounded +addx3067 add -3374988581607586061255542201048 82293895124.90045271504836568681 -> -3374988581607586061173248305923 Inexact Rounded +comx3067 compare -3374988581607586061255542201048 82293895124.90045271504836568681 -> -1 +divx3067 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977038 Inexact Rounded +dvix3067 divideint -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797 +mulx3067 multiply -3374988581607586061255542201048 82293895124.90045271504836568681 -> -2.777409563825512202793336132310E+41 Inexact Rounded +powx3067 power -3374988581607586061255542201048 8 -> 1.683365657238878057620634207267E+244 Inexact Rounded +remx3067 remainder -3374988581607586061255542201048 82293895124.90045271504836568681 -> -66913970168.62046257175566384243 +subx3067 subtract -3374988581607586061255542201048 82293895124.90045271504836568681 -> -3374988581607586061337836096173 Inexact Rounded +addx3068 add -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> -84172558171932.94780431960508260 Inexact Rounded +comx3068 compare -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> -1 +divx3068 divide -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> 7467674426.467986736459678347587 Inexact Rounded +dvix3068 divideint -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> 7467674426 +mulx3068 multiply -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> 948758494638999235.1953022970755 Inexact Rounded +powx3068 power -84172558160661.35863831029352323 -11272 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3068 remainder -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> -5274.95422851496534479122656860 +subx3068 subtract -84172558160661.35863831029352323 -11271.58916600931155937291904890 -> -84172558149389.76947230098196386 Inexact Rounded +addx3069 add -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> -7.004693232461490596396237508541E-555 Inexact Rounded +comx3069 compare -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> -1 +divx3069 divide -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> -2.082768876995463487926920072359E+362 Inexact Rounded +dvix3069 divideint -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> NaN Division_impossible +mulx3069 multiply -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> -2.355793185832144388285949021738E-1471 Inexact Rounded +powx3069 power -70046932324614.90596396237508541E-568 3 -> -3.436903678302639677280508409829E-1663 Inexact Rounded +remx3069 remainder -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> NaN Division_impossible +subx3069 subtract -70046932324614.90596396237508541E-568 33.63163964004608865836577297698E-918 -> -7.004693232461490596396237508541E-555 Inexact Rounded +addx3070 add 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> 4125384407.053782660115680886000 Inexact Rounded +comx3070 compare 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> 1 +divx3070 divide 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> -1.053928941287132717250540955457E+649 Inexact Rounded +dvix3070 divideint 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> NaN Division_impossible +mulx3070 multiply 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> -1.614795442013190139080634449273E-630 Inexact Rounded +powx3070 power 0004125384407.053782660115680886 -4 -> 3.452568541597450106266555783362E-39 Inexact Rounded +remx3070 remainder 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> NaN Division_impossible +subx3070 subtract 0004125384407.053782660115680886 -391429084.5847321402514385603223E-648 -> 4125384407.053782660115680886000 Inexact Rounded +addx3071 add -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> 9.291391582947237200286427030028E+775 Inexact Rounded +comx3071 compare -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -1 +divx3071 divide -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -3.425012375468251447194400841658E-1209 Inexact Rounded +dvix3071 divideint -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -0 +mulx3071 multiply -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -2.956811729743937541973845029816E+343 Inexact Rounded +powx3071 power -31823131.15691583393820628480997E-440 9 -> -3.347234803487575870321338308655E-3893 Inexact Rounded +remx3071 remainder -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -3.182313115691583393820628480997E-433 +subx3071 subtract -31823131.15691583393820628480997E-440 92913.91582947237200286427030028E+771 -> -9.291391582947237200286427030028E+775 Inexact Rounded +addx3072 add 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 55573868488.43891477926020011694 Inexact Rounded +comx3072 compare 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 1 +divx3072 divide 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 92696782.14318796763098335498657 Inexact Rounded +dvix3072 divideint 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 92696782 +mulx3072 multiply 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 33317820972080.24347717542221477 Inexact Rounded +powx3072 power 55573867888.91575330563698128150 600 -> 8.363240671070136278221965616973E+6446 Inexact Rounded +remx3072 remainder 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 85.8445030391099686478265169012 +subx3072 subtract 55573867888.91575330563698128150 599.5231614736232188354393212234 -> 55573867289.39259183201376244606 Inexact Rounded +addx3073 add -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> 5.487207142687001607026665515349E-356 Inexact Rounded +comx3073 compare -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -1 +divx3073 divide -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -9.928051387110587327889009363069E-415 Inexact Rounded +dvix3073 divideint -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -0 +mulx3073 multiply -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -2.989280896644635352838087864373E-1125 Inexact Rounded +powx3073 power -5447727448431680878699555714796E-800 5 -> -4.798183553278543065204833300725E-3847 Inexact Rounded +remx3073 remainder -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -5.447727448431680878699555714796E-770 +subx3073 subtract -5447727448431680878699555714796E-800 5487207.142687001607026665515349E-362 -> -5.487207142687001607026665515349E-356 Inexact Rounded +addx3074 add 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 418359224750.4711631202083513795 Inexact Rounded +comx3074 compare 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 1 +divx3074 divide 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 42602.13713335803513874339309132 Inexact Rounded +dvix3074 divideint 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 42602 +mulx3074 multiply 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 4108155982352814348.343441299082 Inexact Rounded +powx3074 power 0418349404834.547110239542290134 9819916 -> Infinity Overflow Inexact Rounded +remx3074 remainder 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 1346638.04628810400110728063718 +subx3074 subtract 0418349404834.547110239542290134 09819915.92405288066606124554841 -> 418339584918.6230573588762288885 Inexact Rounded +addx3075 add -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> -7.983992600094836304387324162042E+420 Inexact Rounded +comx3075 compare -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> 1 +divx3075 divide -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> 3.281838669494274896180376328433E-416 Inexact Rounded +dvix3075 divideint -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> 0 +mulx3075 multiply -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> 2.091979765115329268275803385534E+426 Inexact Rounded +powx3075 power -262021.7565194737396448014286436 -8 -> 4.500918721033033032706782304195E-44 Inexact Rounded +remx3075 remainder -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> -262021.7565194737396448014286436 +subx3075 subtract -262021.7565194737396448014286436 -7983992600094836304387324162042E+390 -> 7.983992600094836304387324162042E+420 Inexact Rounded +addx3076 add 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> -3.386875233985057267609967806187E+831 Inexact Rounded +comx3076 compare 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> 1 +divx3076 divide 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> -1.437786964892976582009952172420E-1326 Inexact Rounded +dvix3076 divideint 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> -0 +mulx3076 multiply 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> -1.649274478764579569246425611629E+337 Inexact Rounded +powx3076 power 48696050631.42565380301204592392E-505 -3 -> 8.660017688773759463020340778853E+1482 Inexact Rounded +remx3076 remainder 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> 4.869605063142565380301204592392E-495 +subx3076 subtract 48696050631.42565380301204592392E-505 -33868752339.85057267609967806187E+821 -> 3.386875233985057267609967806187E+831 Inexact Rounded +addx3077 add 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> 95256207.85635086953625240702318 Inexact Rounded +comx3077 compare 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> 1 +divx3077 divide 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> -1567.937180706641856870286122623 Inexact Rounded +dvix3077 divideint 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> -1567 +mulx3077 multiply 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> -5794447919993.150493301061195714 Inexact Rounded +powx3077 power 95316999.19440144356471126680708 -60791 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3077 remainder 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> 56972.46915194096967798542896355 +subx3077 subtract 95316999.19440144356471126680708 -60791.33805057402845885978390435 -> 95377790.53245201759317012659098 Inexact Rounded +addx3078 add -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> 8032459.450998820205916538543258 Inexact Rounded +comx3078 compare -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -1 +divx3078 divide -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -6.631471131473117487839243582873E-113 Inexact Rounded +dvix3078 divideint -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -0 +mulx3078 multiply -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -4.278652020339705265013632757349E-99 Inexact Rounded +powx3078 power -5326702296402708234722215224979E-136 8032459 -> -0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3078 remainder -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -5.326702296402708234722215224979E-106 +subx3078 subtract -5326702296402708234722215224979E-136 8032459.450998820205916538543258 -> -8032459.450998820205916538543258 Inexact Rounded +addx3079 add 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> 6.718750684079501575335482615780E-280 Inexact Rounded +comx3079 compare 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> 1 +divx3079 divide 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> 9.152153872187460598958616592442E+571 Inexact Rounded +dvix3079 divideint 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> NaN Division_impossible +mulx3079 multiply 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> 4.932348317700372401849231767007E-1131 Inexact Rounded +powx3079 power 67.18750684079501575335482615780E-281 7 -> 6.180444071023111300817518409550E-1955 Inexact Rounded +remx3079 remainder 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> NaN Division_impossible +subx3079 subtract 67.18750684079501575335482615780E-281 734.1168841683438410314843011541E-854 -> 6.718750684079501575335482615780E-280 Inexact Rounded +addx3080 add -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -8738791762039.358125211204773930 Inexact Rounded +comx3080 compare -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -1 +divx3080 divide -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -17216.56012577673731612130068130 Inexact Rounded +dvix3080 divideint -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -17216 +mulx3080 multiply -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -4436156407404759833857.580707024 Inexact Rounded +powx3080 power -8739299372114.092482914139281669 507610075 -> -Infinity Overflow Inexact Rounded +remx3080 remainder -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -284325487.3902691936540542102992 +subx3080 subtract -8739299372114.092482914139281669 507610074.7343577029345077385838 -> -8739806982188.826840617073789408 Inexact Rounded +addx3081 add 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> 2454.002078468928665008217727731 Inexact Rounded +comx3081 compare 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> 1 +divx3081 divide 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> 4.205327278123112611006652533618E+141 Inexact Rounded +dvix3081 divideint 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> NaN Division_impossible +mulx3081 multiply 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> 1.432023194118096842806010293027E-135 Inexact Rounded +powx3081 power 2454.002078468928665008217727731 6 -> 218398452792293853786.9263054420 Inexact Rounded +remx3081 remainder 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> NaN Division_impossible +subx3081 subtract 2454.002078468928665008217727731 583546039.6233842869119950982009E-147 -> 2454.002078468928665008217727731 Inexact Rounded +addx3082 add 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 829181.6561975853393326976860680 Inexact Rounded +comx3082 compare 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 1 +divx3082 divide 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 11.83500633601553578851124281417 Inexact Rounded +dvix3082 divideint 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 11 +mulx3082 multiply 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 49394169921.82458094138096628957 Inexact Rounded +powx3082 power 764578.5204849936912066033177429 64603 -> Infinity Overflow Inexact Rounded +remx3082 remainder 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 53944.02764648556181956526616724 +subx3082 subtract 764578.5204849936912066033177429 64603.13571259164812609436832506 -> 699975.3847724020430805089494178 Inexact Rounded +addx3083 add 079203.7330103777716903518367560 846388934347.6324036132959664705 -> 846389013551.3654139910676568223 Inexact Rounded +comx3083 compare 079203.7330103777716903518367560 846388934347.6324036132959664705 -> -1 +divx3083 divide 079203.7330103777716903518367560 846388934347.6324036132959664705 -> 9.357841270860339858146471876044E-8 Inexact Rounded +dvix3083 divideint 079203.7330103777716903518367560 846388934347.6324036132959664705 -> 0 +mulx3083 multiply 079203.7330103777716903518367560 846388934347.6324036132959664705 -> 67037163179008037.19983564789203 Inexact Rounded +powx3083 power 079203.7330103777716903518367560 8 -> 1.548692549503356788115682996756E+39 Inexact Rounded +remx3083 remainder 079203.7330103777716903518367560 846388934347.6324036132959664705 -> 79203.7330103777716903518367560 +subx3083 subtract 079203.7330103777716903518367560 846388934347.6324036132959664705 -> -846388855143.8993932355242761187 Inexact Rounded +addx3084 add -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> 5.474973992953902631890208360829 Inexact Rounded +comx3084 compare -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -1 +divx3084 divide -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -7.814797878848469282033896969532E-327 Inexact Rounded +dvix3084 divideint -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -0 +mulx3084 multiply -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -2.342512251965378028433584538870E-325 Inexact Rounded +powx3084 power -4278.581514688669249247007127899E-329 5 -> -1.433834587801771244104676682986E-1627 Inexact Rounded +remx3084 remainder -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -4.278581514688669249247007127899E-326 +subx3084 subtract -4278.581514688669249247007127899E-329 5.474973992953902631890208360829 -> -5.474973992953902631890208360829 Inexact Rounded +addx3085 add 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> 6.149612565404080501157093851895E+817 Inexact Rounded +comx3085 compare 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> -1 +divx3085 divide 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> 9.897699923417617920996187420968E-160 Inexact Rounded +dvix3085 divideint 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> 0 +mulx3085 multiply 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> 3.743085898893072544197564013497E+1476 Inexact Rounded +powx3085 power 60867019.81764798845468445196869E+651 6 -> 5.085014897388871736767602086646E+3952 Inexact Rounded +remx3085 remainder 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> 6.086701981764798845468445196869E+658 +subx3085 subtract 60867019.81764798845468445196869E+651 6.149612565404080501157093851895E+817 -> -6.149612565404080501157093851895E+817 Inexact Rounded +addx3086 add 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> -8.945059095290523784746184357820E+538 Inexact Rounded +comx3086 compare 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> 1 +divx3086 divide 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> -2.074264411286709228674841672954E-908 Inexact Rounded +dvix3086 divideint 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> -0 +mulx3086 multiply 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> -1.659703631470633700884136887614E+170 Inexact Rounded +powx3086 power 18554417738217.62218590965803605E-382 -9 -> 3.836842998295531899082688721531E+3318 Inexact Rounded +remx3086 remainder 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> 1.855441773821762218590965803605E-369 +subx3086 subtract 18554417738217.62218590965803605E-382 -0894505909529.052378474618435782E+527 -> 8.945059095290523784746184357820E+538 Inexact Rounded +addx3087 add 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> 9.977847825356104634823627327033E+127 Inexact Rounded +comx3087 compare 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> -1 +divx3087 divide 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> 6.922670772910807388395384866884E-115 Inexact Rounded +dvix3087 divideint 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> 0 +mulx3087 multiply 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> 6.892034301367879802693422066425E+141 Inexact Rounded +powx3087 power 69073355517144.36356688642213839 10 -> 2.472324890841334302628435461516E+138 Inexact Rounded +remx3087 remainder 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> 69073355517144.36356688642213839 +subx3087 subtract 69073355517144.36356688642213839 997784782535.6104634823627327033E+116 -> -9.977847825356104634823627327033E+127 Inexact Rounded +addx3088 add 450282259072.8657099359104277477 -1791307965314309175477911369824 -> -1791307965314309175027629110751 Inexact Rounded +comx3088 compare 450282259072.8657099359104277477 -1791307965314309175477911369824 -> 1 +divx3088 divide 450282259072.8657099359104277477 -1791307965314309175477911369824 -> -2.513706564096350714213771006483E-19 Inexact Rounded +dvix3088 divideint 450282259072.8657099359104277477 -1791307965314309175477911369824 -> -0 +mulx3088 multiply 450282259072.8657099359104277477 -1791307965314309175477911369824 -> -8.065941973169457071650996861677E+41 Inexact Rounded +powx3088 power 450282259072.8657099359104277477 -2 -> 4.932082442194544671633570348838E-24 Inexact Rounded +remx3088 remainder 450282259072.8657099359104277477 -1791307965314309175477911369824 -> 450282259072.8657099359104277477 +subx3088 subtract 450282259072.8657099359104277477 -1791307965314309175477911369824 -> 1791307965314309175928193628897 Inexact Rounded +addx3089 add 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 954821400.4934353520984462184316 Inexact Rounded +comx3089 compare 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 1 +divx3089 divide 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 6676.599951968811589335427770046 Inexact Rounded +dvix3089 divideint 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 6676 +mulx3089 multiply 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 136508234203444.8694879431412375 Inexact Rounded +powx3089 power 954678411.7838149266455177850037 142989 -> Infinity Overflow Inexact Rounded +remx3089 remainder 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 85786.3578546028952962204808256 +subx3089 subtract 954678411.7838149266455177850037 142988.7096204254529284334278794 -> 954535423.0741945011925893515758 Inexact Rounded +addx3090 add -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> -9.244530976220812127155852389807E+566 Inexact Rounded +comx3090 compare -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> -1 +divx3090 divide -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> -1.708503207395591002370649848757E+561 Inexact Rounded +dvix3090 divideint -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> NaN Division_impossible +mulx3090 multiply -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> -5.002118380601798392363043558941E+572 Inexact Rounded +powx3090 power -9244530976.220812127155852389807E+557 541089 -> -Infinity Overflow Inexact Rounded +remx3090 remainder -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> NaN Division_impossible +subx3090 subtract -9244530976.220812127155852389807E+557 541089.4715446858896619078627941 -> -9.244530976220812127155852389807E+566 Inexact Rounded +addx3091 add -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> -14760496803372.56259241638975169 Inexact Rounded +comx3091 compare -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> 1 +divx3091 divide -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> 0.000005114489797920668836278344635108 Inexact Rounded +dvix3091 divideint -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> 0 +mulx3091 multiply -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> 1114294082984662825831.464787487 Inexact Rounded +powx3091 power -75492024.20990197005974241975449 -1 -> -1.324643246046162082348970735576E-8 Inexact Rounded +remx3091 remainder -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> -75492024.20990197005974241975449 +subx3091 subtract -75492024.20990197005974241975449 -14760421311348.35269044633000927 -> 14760345819324.14278847627026685 Inexact Rounded +addx3092 add 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> 2.475976333144824613591228097330E+99 Inexact Rounded +comx3092 compare 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> -1 +divx3092 divide 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> 1.283322837007852247594216151634E-546 Inexact Rounded +dvix3092 divideint 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> 0 +mulx3092 multiply 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> 7.867357782318786860404997647513E-348 Inexact Rounded +powx3092 power 317747.6972215715434186596178036E-452 2 -> 1.009635990896115043331231496209E-893 Inexact Rounded +remx3092 remainder 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> 3.177476972215715434186596178036E-447 +subx3092 subtract 317747.6972215715434186596178036E-452 24759763.33144824613591228097330E+092 -> -2.475976333144824613591228097330E+99 Inexact Rounded +addx3093 add -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> -17.87120645617324368279740020695 Inexact Rounded +comx3093 compare -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> 1 +divx3093 divide -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> 0.8390040956188859972044344532019 Inexact Rounded +dvix3093 divideint -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> 0 +mulx3093 multiply -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> 79.23306057789328578902960605222 Inexact Rounded +powx3093 power -8.153334430358647134334545353427 -10 -> 7.702778966876727056635952801162E-10 Inexact Rounded +remx3093 remainder -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> -8.153334430358647134334545353427 +subx3093 subtract -8.153334430358647134334545353427 -9.717872025814596548462854853522 -> 1.564537595455949414128309500095 +addx3094 add 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> 5054015481833.263541189916208065 Inexact Rounded +comx3094 compare 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> -1 +divx3094 divide 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> 1.437934890309606594895299558654E-490 Inexact Rounded +dvix3094 divideint 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> 0 +mulx3094 multiply 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> 3.672927513995607308048737751972E-465 Inexact Rounded +powx3094 power 7.267345197492967332320456062961E-478 5 -> 2.027117616846668568108096583897E-2386 Inexact Rounded +remx3094 remainder 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> 7.267345197492967332320456062961E-478 +subx3094 subtract 7.267345197492967332320456062961E-478 5054015481833.263541189916208065 -> -5054015481833.263541189916208065 Inexact Rounded +addx3095 add -1223354029.862567054230912271171 8135774223401322785475014855625 -> 8135774223401322785473791501595 Inexact Rounded +comx3095 compare -1223354029.862567054230912271171 8135774223401322785475014855625 -> -1 +divx3095 divide -1223354029.862567054230912271171 8135774223401322785475014855625 -> -1.503672540892020337688277553692E-22 Inexact Rounded +dvix3095 divideint -1223354029.862567054230912271171 8135774223401322785475014855625 -> -0 +mulx3095 multiply -1223354029.862567054230912271171 8135774223401322785475014855625 -> -9.952932182250005119307429060894E+39 Inexact Rounded +powx3095 power -1223354029.862567054230912271171 8 -> 5.016689887192830666848068841227E+72 Inexact Rounded +remx3095 remainder -1223354029.862567054230912271171 8135774223401322785475014855625 -> -1223354029.862567054230912271171 +subx3095 subtract -1223354029.862567054230912271171 8135774223401322785475014855625 -> -8135774223401322785476238209655 Inexact Rounded +addx3096 add 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> 2.853976441115655679961211349982E+656 Inexact Rounded +comx3096 compare 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> 1 +divx3096 divide 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> -1.151029280076495626421134733122E+626 Inexact Rounded +dvix3096 divideint 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> NaN Division_impossible +mulx3096 multiply 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> -7.076432952167704614138411740001E+686 Inexact Rounded +powx3096 power 285397644111.5655679961211349982E+645 -2 -> 1.227719722087860401233030479451E-1313 Inexact Rounded +remx3096 remainder 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> NaN Division_impossible +subx3096 subtract 285397644111.5655679961211349982E+645 -2479499427613157519359627280704 -> 2.853976441115655679961211349982E+656 Inexact Rounded +addx3097 add -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> -4676542.661845508839813784891890 Inexact Rounded +comx3097 compare -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> -1 +divx3097 divide -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> 1362.424151323477505064686589716 Inexact Rounded +dvix3097 divideint -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> 1362 +mulx3097 multiply -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> 16028768973.31252639476148371361 Inexact Rounded +powx3097 power -4673112.663442366293812346653429 -3430 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3097 remainder -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> -1454.838362218639853465869604204 +subx3097 subtract -4673112.663442366293812346653429 -3429.998403142546001438238460958 -> -4669682.665039223747810908414968 Inexact Rounded +addx3098 add 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> 3.869394621006514751889096510923E+144 Inexact Rounded +comx3098 compare 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> -1 +divx3098 divide 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> 2.299194926095985647821385937618E-143 Inexact Rounded +dvix3098 divideint 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> 0 +mulx3098 multiply 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> 3.442404014670364763780946297856E+146 Inexact Rounded +powx3098 power 88.96492479681278079861456051103 4 -> 62643391.73078290226474758858970 Inexact Rounded +remx3098 remainder 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> 88.96492479681278079861456051103 +subx3098 subtract 88.96492479681278079861456051103 386939.4621006514751889096510923E+139 -> -3.869394621006514751889096510923E+144 Inexact Rounded +addx3099 add 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> 92.23649942010862087149015091350 Inexact Rounded +comx3099 compare 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> -1 +divx3099 divide 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> 6.974120530708230229344349531719E-937 Inexact Rounded +dvix3099 divideint 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> 0 +mulx3099 multiply 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> 5.933283133313013755814405436342E-933 Inexact Rounded +powx3099 power 064326846.4286437304788069444326E-942 92 -> 0E-10029 Underflow Subnormal Inexact Rounded Clamped +remx3099 remainder 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> 6.43268464286437304788069444326E-935 +subx3099 subtract 064326846.4286437304788069444326E-942 92.23649942010862087149015091350 -> -92.23649942010862087149015091350 Inexact Rounded +addx3100 add 504507.0043949324433170405699360 605387.7175522955344659311072099 -> 1109894.721947227977782971677146 Inexact Rounded +comx3100 compare 504507.0043949324433170405699360 605387.7175522955344659311072099 -> -1 +divx3100 divide 504507.0043949324433170405699360 605387.7175522955344659311072099 -> 0.8333618105678718895216067463832 Inexact Rounded +dvix3100 divideint 504507.0043949324433170405699360 605387.7175522955344659311072099 -> 0 +mulx3100 multiply 504507.0043949324433170405699360 605387.7175522955344659311072099 -> 305422343879.7940838630401656585 Inexact Rounded +powx3100 power 504507.0043949324433170405699360 605388 -> Infinity Overflow Inexact Rounded +remx3100 remainder 504507.0043949324433170405699360 605387.7175522955344659311072099 -> 504507.0043949324433170405699360 +subx3100 subtract 504507.0043949324433170405699360 605387.7175522955344659311072099 -> -100880.7131573630911488905372739 + +-- randomly generated testcases [26 Sep 2001] +precision: 32 +rounding: half_up +maxExponent: 9999 + +addx3201 add 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> -0.1294608320983180201262861125848 +comx3201 compare 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> 1 +divx3201 divide 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> -0.92190879812324313630282980110280 Inexact Rounded +dvix3201 divideint 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> -0 +mulx3201 multiply 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> -2.5337311682687808926633910761614 Inexact Rounded +powx3201 power 1.5283550163839789319142430253644 -2 -> 0.42810618916584924451466691603128 Inexact Rounded +remx3201 remainder 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> 1.5283550163839789319142430253644 +subx3201 subtract 1.5283550163839789319142430253644 -1.6578158484822969520405291379492 -> 3.1861708648662758839547721633136 +addx3202 add -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -616383641998.15356482333651785302 Inexact Rounded +comx3202 compare -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -1 +divx3202 divide -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -95.546234185785110491676894153510 Inexact Rounded +dvix3202 divideint -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -95 +mulx3202 multiply -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -4060946921076840449949.6988828486 Inexact Rounded +powx3202 power -622903030605.2867503937836507326 7 -> -3.6386736597702404352813308064300E+82 Inexact Rounded +remx3202 remainder -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -3561112927.6341212013060271723005 +subx3202 subtract -622903030605.2867503937836507326 6519388607.1331855704471328795821 -> -629422419212.41993596423078361218 Inexact Rounded +addx3203 add -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> 73908233965.134822146441861002895 Inexact Rounded +comx3203 compare -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -1 +divx3203 divide -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -0.000076790894376056827552388054657082 Inexact Rounded +dvix3203 divideint -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -0 +mulx3203 multiply -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -419529088021865067.23307352973589 Inexact Rounded +powx3203 power -5675915.2465457487632250245209054 7 -> -1.8978038060207777231389234721908E+47 Inexact Rounded +remx3203 remainder -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -5675915.2465457487632250245209054 +subx3203 subtract -5675915.2465457487632250245209054 73913909880.381367895205086027416 -> -73919585795.627913643968311051937 Inexact Rounded +addx3204 add 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 102.50941233130989977580658947572 Inexact Rounded +comx3204 compare 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 1 +divx3204 divide 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 20.083399916665466374741708949621 Inexact Rounded +dvix3204 divideint 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 20 +mulx3204 multiply 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 474.77017694916635398652276042175 Inexact Rounded +powx3204 power 97.647321172555144900685605318635 5 -> 8877724578.7935312939231828719842 Inexact Rounded +remx3204 remainder 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 0.4054979974600473982659221768650 +subx3204 subtract 97.647321172555144900685605318635 4.8620911587547548751209841570885 -> 92.785230013800390025564621161547 Inexact Rounded +addx3205 add -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> -2.6692539695193820424002013488480E+366 Inexact Rounded +comx3205 compare -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> 1 +divx3205 divide -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> 3.6404378818903462695633337631098E-354 Inexact Rounded +dvix3205 divideint -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> 0 +mulx3205 multiply -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> 2.5937816855830431899123217912144E+379 Inexact Rounded +powx3205 power -9717253267024.5380651435435603552 -3 -> -1.0898567880085337780041328661330E-39 Inexact Rounded +remx3205 remainder -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> -9717253267024.5380651435435603552 +subx3205 subtract -9717253267024.5380651435435603552 -2669.2539695193820424002013488480E+363 -> 2.6692539695193820424002013488480E+366 Inexact Rounded +addx3206 add -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> 12772.807105920712660991033689206 Inexact Rounded +comx3206 compare -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -1 +divx3206 divide -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -3.1956477052150593175206769891434E-771 Inexact Rounded +dvix3206 divideint -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -0 +mulx3206 multiply -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -5.2135267097047531336100750110314E-763 Inexact Rounded +powx3206 power -4.0817391717190128506083001702335E-767 12773 -> -0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3206 remainder -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -4.0817391717190128506083001702335E-767 +subx3206 subtract -4.0817391717190128506083001702335E-767 12772.807105920712660991033689206 -> -12772.807105920712660991033689206 Inexact Rounded +addx3207 add 68625322655934146845003028928647 -59.634169944840280159782488098700 -> 68625322655934146845003028928587 Inexact Rounded +comx3207 compare 68625322655934146845003028928647 -59.634169944840280159782488098700 -> 1 +divx3207 divide 68625322655934146845003028928647 -59.634169944840280159782488098700 -> -1150771826276954946844322988192.5 Inexact Rounded +dvix3207 divideint 68625322655934146845003028928647 -59.634169944840280159782488098700 -> -1150771826276954946844322988192 +mulx3207 multiply 68625322655934146845003028928647 -59.634169944840280159782488098700 -> -4.0924141537834748501140151997778E+33 Inexact Rounded +powx3207 power 68625322655934146845003028928647 -60 -> 6.4704731111943370171711131942603E-1911 Inexact Rounded +remx3207 remainder 68625322655934146845003028928647 -59.634169944840280159782488098700 -> 28.201254004897257552939369449600 +subx3207 subtract 68625322655934146845003028928647 -59.634169944840280159782488098700 -> 68625322655934146845003028928707 Inexact Rounded +addx3208 add 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> -92134479103305.554299334115573170 Inexact Rounded +comx3208 compare 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> 1 +divx3208 divide 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> -7.9505063318943846655593887991914E-9 Inexact Rounded +dvix3208 divideint 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> -0 +mulx3208 multiply 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> -67489959009342175728.710494356322 Inexact Rounded +powx3208 power 732515.76532049290815665856727641 -9 -> 1.6468241050443471359358016585877E-53 Inexact Rounded +remx3208 remainder 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> 732515.76532049290815665856727641 +subx3208 subtract 732515.76532049290815665856727641 -92134479835821.319619827023729829 -> 92134480568337.084940319931886488 Inexact Rounded +addx3209 add -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> -5.0233720245976651023364304104030E+861 Inexact Rounded +comx3209 compare -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> 1 +divx3209 divide -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> 6.0632602550311410821483001305010E-861 Inexact Rounded +dvix3209 divideint -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> 0 +mulx3209 multiply -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> 1.5300192511921895929031818638961E+863 Inexact Rounded +powx3209 power -30.458011942978338421676454778733 -5 -> -3.8149797481405136042487643253109E-8 Inexact Rounded +remx3209 remainder -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> -30.458011942978338421676454778733 +subx3209 subtract -30.458011942978338421676454778733 -5023372024597665102336430410403E+831 -> 5.0233720245976651023364304104030E+861 Inexact Rounded +addx3210 add -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> -58703509398.895039317872169695760 Inexact Rounded +comx3210 compare -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> 1 +divx3210 divide -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> 0.0000015269995260536025237167199970238 Inexact Rounded +dvix3210 divideint -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> 0 +mulx3210 multiply -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> 5262180074071519.7018252171579753 Inexact Rounded +powx3210 power -89640.094149414644660480286430462 -6 -> 1.9274635591165405888724595165741E-30 Inexact Rounded +remx3210 remainder -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> -89640.094149414644660480286430462 +subx3210 subtract -89640.094149414644660480286430462 -58703419758.800889903227509215474 -> 58703330118.706740488582848735188 Inexact Rounded +addx3211 add 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> 458653.15678700818100529177142590 Inexact Rounded +comx3211 compare 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> 1 +divx3211 divide 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> 2.4990492117594160215641311760498E+33 Inexact Rounded +dvix3211 divideint 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> NaN Division_impossible +mulx3211 multiply 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> 8.4177101131428047497998594379593E-23 Inexact Rounded +powx3211 power 458653.1567870081810052917714259 2 -> 210362718230.68790865117452429990 Inexact Rounded +remx3211 remainder 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> NaN Division_impossible +subx3211 subtract 458653.1567870081810052917714259 18353106238.516235116080449814053E-038 -> 458653.15678700818100529177142590 Inexact Rounded +addx3212 add 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> -2.1051638816432817393202262710630E+439 Inexact Rounded +comx3212 compare 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> 1 +divx3212 divide 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> -4.3388138824102151127273259092613E-434 Inexact Rounded +dvix3212 divideint 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> -0 +mulx3212 multiply 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> -1.9228386428540135340600836707270E+445 Inexact Rounded +powx3212 power 913391.42744224458216174967853722 -2 -> 1.1986327439971532470297300128074E-12 Inexact Rounded +remx3212 remainder 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> 913391.42744224458216174967853722 +subx3212 subtract 913391.42744224458216174967853722 -21051638.816432817393202262710630E+432 -> 2.1051638816432817393202262710630E+439 Inexact Rounded +addx3213 add -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> -2.8892177726858026955513438843371E+739 Inexact Rounded +comx3213 compare -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> 1 +divx3213 divide -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> 3.1759165595057674196644927106447E-728 Inexact Rounded +dvix3213 divideint -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> 0 +mulx3213 multiply -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> 2.6511215451353541156703914721725E+751 Inexact Rounded +powx3213 power -917591456829.12109027484399536567 -3 -> -1.2943505591853739240003453341911E-36 Inexact Rounded +remx3213 remainder -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> -917591456829.12109027484399536567 +subx3213 subtract -917591456829.12109027484399536567 -28892177726858026955513438843371E+708 -> 2.8892177726858026955513438843371E+739 Inexact Rounded +addx3214 add 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 34938410840676.731620092461631064 Inexact Rounded +comx3214 compare 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 1 +divx3214 divide 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 1133693327999.7879503260098666966 Inexact Rounded +dvix3214 divideint 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 1133693327999 +mulx3214 multiply 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 1076739645476675.3318519289128961 Inexact Rounded +powx3214 power 34938410840645.913399699219228218 31 -> 6.9566085958798732786509909683267E+419 Inexact Rounded +remx3214 remainder 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 24.283226805899273551376371736548 +subx3214 subtract 34938410840645.913399699219228218 30.818220393242402846077755480548 -> 34938410840615.095179305976825372 Inexact Rounded +addx3215 add 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> 29771833428054709077850588904653 Inexact Rounded +comx3215 compare 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> -1 +divx3215 divide 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> 2.0269955680376683526099444523691E-545 Inexact Rounded +dvix3215 divideint 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> 0 +mulx3215 multiply 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> 1.7966519787854159464382359411642E-482 Inexact Rounded +powx3215 power 6034.7374411022598081745006769023E-517 3 -> 2.1977340597301840681528507640032E-1540 Inexact Rounded +remx3215 remainder 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> 6.0347374411022598081745006769023E-514 +subx3215 subtract 6034.7374411022598081745006769023E-517 29771833428054709077850588904653 -> -29771833428054709077850588904653 Inexact Rounded +addx3216 add -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> -5565747672224.4775959193681631431 Inexact Rounded +comx3216 compare -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> -1 +divx3216 divide -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> 11351510433.365074871574519756245 Inexact Rounded +dvix3216 divideint -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> 11351510433 +mulx3216 multiply -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> 2728936147066663.4580064428639745 Inexact Rounded +powx3216 power -5565747671734.1686009705574503152 -490 -> 4.9371745297619526113991728953197E-6246 Inexact Rounded +remx3216 remainder -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> -178.99949336276892685183308348801 +subx3216 subtract -5565747671734.1686009705574503152 -490.30899494881071282787487030303 -> -5565747671243.8596060217467374873 Inexact Rounded +addx3217 add 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> 3.1954551189203199952335879232538E+44 Inexact Rounded +comx3217 compare 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> 1 +divx3217 divide 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> -108102711781422.68663084859902931 Inexact Rounded +dvix3217 divideint 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> -108102711781422 +mulx3217 multiply 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> -9.4455848967786959996525702197139E+74 Inexact Rounded +powx3217 power 319545511.89203495546689273564728E+036 -3 -> 3.0647978448946294457985223953472E-134 Inexact Rounded +remx3217 remainder 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> 2029642017122316721531728309258 +subx3217 subtract 319545511.89203495546689273564728E+036 -2955943533943321899150310192061 -> 3.1954551189203791141042667896918E+44 Inexact Rounded +addx3218 add -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> -42682764.676651465089307430325104 Rounded +comx3218 compare -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> -1 +divx3218 divide -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> 6.3204380807318655475459047410160 Inexact Rounded +dvix3218 divideint -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> 6 +mulx3218 multiply -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> 214871156882133.34437417534873098 Inexact Rounded +powx3218 power -36852134.84194296250843579428931 -5830630 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3218 remainder -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> -1868355.8336919470232059780745460 +subx3218 subtract -36852134.84194296250843579428931 -5830629.8347085025808716360357940 -> -31021505.007234459927564158253516 Rounded +addx3219 add 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> -39505285344943.729681835377530908 Inexact Rounded +comx3219 compare 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> 1 +divx3219 divide 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> -2.1774783867700502002511486885272E-387 Inexact Rounded +dvix3219 divideint 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> -0 +mulx3219 multiply 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> -3.3983199030116951081865430362053E-360 Inexact Rounded +powx3219 power 8.6021905001798578659275880018221E-374 -4 -> 1.8262649155820433126240754123257E+1492 Inexact Rounded +remx3219 remainder 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> 8.6021905001798578659275880018221E-374 +subx3219 subtract 8.6021905001798578659275880018221E-374 -39505285344943.729681835377530908 -> 39505285344943.729681835377530908 Inexact Rounded +addx3220 add -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -54862429.012326453703398777272191 Inexact Rounded +comx3220 compare -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -1 +divx3220 divide -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -74528.182826764384088602813142847 Inexact Rounded +dvix3220 divideint -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -74528 +mulx3220 multiply -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -40386962037.048345148338122539405 Inexact Rounded +powx3220 power -54863165.152174109720312887805017 736 -> 1.2903643981679111625370174573639E+5696 Inexact Rounded +remx3220 remainder -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -134.5860664811454830973740198416 +subx3220 subtract -54863165.152174109720312887805017 736.1398476560169141105328256628 -> -54863901.292021765737226998337843 Inexact Rounded +addx3221 add -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -3263743464517851012531706353100.8 Inexact Rounded +comx3221 compare -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -1 +divx3221 divide -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -1328233422952076975055082.5768082 Inexact Rounded +dvix3221 divideint -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -1328233422952076975055082 +mulx3221 multiply -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -8.0196908300261262548565838031943E+36 Inexact Rounded +powx3221 power -3263743464517851012531708810307 2457206 -> Infinity Overflow Inexact Rounded +remx3221 remainder -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -1417336.7573398366062994535940062 +subx3221 subtract -3263743464517851012531708810307 2457206.2471248382136273643208109 -> -3263743464517851012531711267513.2 Inexact Rounded +addx3222 add 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> 9.5354563764657694835860339582821E+91 Inexact Rounded +comx3222 compare 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> -1 +divx3222 divide 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> 2.9957525170007980008712828968300E-978 Inexact Rounded +dvix3222 divideint 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> 0 +mulx3222 multiply 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> 2.7238858283525541854826594343954E-794 Inexact Rounded +powx3222 power 2856586744.0548637797291151154902E-895 10 -> 3.6180466753307072256807593988336E-8856 Inexact Rounded +remx3222 remainder 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> 2.8565867440548637797291151154902E-886 +subx3222 subtract 2856586744.0548637797291151154902E-895 953545637646.57694835860339582821E+080 -> -9.5354563764657694835860339582821E+91 Inexact Rounded +addx3223 add 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> 631722566499.28075196842125460014 Inexact Rounded +comx3223 compare 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> -1 +divx3223 divide 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> 0.0089828645946207580492752544218316 Inexact Rounded +dvix3223 divideint 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> 0 +mulx3223 multiply 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> 3521275897257796938833.8975037909 Inexact Rounded +powx3223 power 5624157233.3433661009203529937625 6 -> 3.1647887196303262540158328459030E+58 Inexact Rounded +remx3223 remainder 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> 5624157233.3433661009203529937625 +subx3223 subtract 5624157233.3433661009203529937625 626098409265.93738586750090160638 -> -620474252032.59401976658054861262 Inexact Rounded +addx3224 add -213499362.91476998701834067092611 419272438.02555757699863022643444 -> 205773075.11078758998028955550833 +comx3224 compare -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -1 +divx3224 divide -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -0.50921392286166855779828061147786 Inexact Rounded +dvix3224 divideint -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -0 +mulx3224 multiply -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -89514398406178925.073260776410672 Inexact Rounded +powx3224 power -213499362.91476998701834067092611 419272438 -> Infinity Overflow Inexact Rounded +remx3224 remainder -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -213499362.91476998701834067092611 +subx3224 subtract -213499362.91476998701834067092611 419272438.02555757699863022643444 -> -632771800.94032756401697089736055 +addx3225 add 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 30274.392356614101238316845401518 Inexact Rounded +comx3225 compare 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1 +divx3225 divide 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 6300.1252178837655359831527173832 Inexact Rounded +dvix3225 divideint 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 6300 +mulx3225 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199283 Inexact Rounded +powx3225 power 30269.587755640502150977251770554 5 -> 25411630481547464128383.220368208 Inexact Rounded +remx3225 remainder 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 0.6016219662519115373766970119100 +subx3225 subtract 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 30264.783154666903063637658139590 Inexact Rounded +addx3226 add 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> 4.7525676459351505682005359699680E+705 Inexact Rounded +comx3226 compare 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> 1 +divx3226 divide 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> -8.1057651538555854520994438038537E+673 Inexact Rounded +dvix3226 divideint 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> NaN Division_impossible +mulx3226 multiply 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> -2.7865227773649353769876975366506E+737 Inexact Rounded +powx3226 power 47.525676459351505682005359699680E+704 -6 -> 8.6782100393941226535150385475463E-4235 Inexact Rounded +remx3226 remainder 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> NaN Division_impossible +subx3226 subtract 47.525676459351505682005359699680E+704 -58631943508436657383369760970210 -> 4.7525676459351505682005359699680E+705 Inexact Rounded +addx3227 add -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> -74396977890406.153948943614775470 Inexact Rounded +comx3227 compare -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> -1 +divx3227 divide -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> 643479.03948459716424778005613112 Inexact Rounded +dvix3227 divideint -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> 643479 +mulx3227 multiply -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> 8601512678051025297297.7169654467 Inexact Rounded +powx3227 power -74396862273800.625679130772935550 -115616606 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3227 remainder -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> -4565075.09478147646296920746797 +subx3227 subtract -74396862273800.625679130772935550 -115616605.52826981284183992013157 -> -74396746657195.097409317931095630 Inexact Rounded +addx3228 add 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 67586387.525464115583388327481014 Inexact Rounded +comx3228 compare 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 1 +divx3228 divide 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 81727.439437354248789852715586510 Inexact Rounded +dvix3228 divideint 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 81727 +mulx3228 multiply 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 55890751355.998983433895910295596 Inexact Rounded +powx3228 power 67585560.562561229497720955705979 827 -> 1.9462204583352191108781197788255E+6475 Inexact Rounded +remx3228 remainder 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 363.39839010616042789746007924349 +subx3228 subtract 67585560.562561229497720955705979 826.96290288608566737177503451613 -> 67584733.599658343412053583930944 Inexact Rounded +addx3229 add 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> 390.31542898606435093937697545510 Inexact Rounded +comx3229 compare 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> -1 +divx3229 divide 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> 1.7620074325054038174571564409871E-225 Inexact Rounded +dvix3229 divideint 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> 0 +mulx3229 multiply 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> 2.6843502060572691408091663822732E-220 Inexact Rounded +powx3229 power 6877386868.9498051860742298735156E-232 390 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3229 remainder 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> 6.8773868689498051860742298735156E-223 +subx3229 subtract 6877386868.9498051860742298735156E-232 390.3154289860643509393769754551 -> -390.31542898606435093937697545510 Inexact Rounded +addx3230 add -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> -186656471117.70574263160637723440 Inexact Rounded +comx3230 compare -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> 1 +divx3230 divide -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> 0.0000088255699357876233458660331146583 Inexact Rounded +dvix3230 divideint -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> 0 +mulx3230 multiply -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> 307483061680363807.48775619333285 Inexact Rounded +powx3230 power -1647335.201144609256134925838937 -2 -> 3.6849876990439502152784389237891E-13 Inexact Rounded +remx3230 remainder -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> -1647335.201144609256134925838937 +subx3230 subtract -1647335.201144609256134925838937 -186654823782.50459802235024230856 -> 186653176447.30345341309410738272 Inexact Rounded +addx3231 add 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> 41407818140948.866630923934138155 Inexact Rounded +comx3231 compare 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> 1 +divx3231 divide 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> -8.0298091128179204076796507697517E+972 Inexact Rounded +dvix3231 divideint 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> NaN Division_impossible +mulx3231 multiply 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> -2.1353028186646179369220834691156E-946 Inexact Rounded +powx3231 power 41407818140948.866630923934138155 -5 -> 8.2146348556648547525693528004081E-69 Inexact Rounded +remx3231 remainder 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> NaN Division_impossible +subx3231 subtract 41407818140948.866630923934138155 -5156.7624534000311342310106671627E-963 -> 41407818140948.866630923934138155 Inexact Rounded +addx3232 add -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> -574454585586.71690214265053093061 Inexact Rounded +comx3232 compare -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> 1 +divx3232 divide -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> 1.1584453442097568745411568037078E-11 Inexact Rounded +dvix3232 divideint -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> 0 +mulx3232 multiply -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> 3822847288253.1035559206691532826 Inexact Rounded +powx3232 power -6.6547424012516834662011706165297 -6 -> 0.000011513636283388791488128239232906 Inexact Rounded +remx3232 remainder -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> -6.6547424012516834662011706165297 +subx3232 subtract -6.6547424012516834662011706165297 -574454585580.06215974139884746441 -> 574454585573.40741734014716399821 Inexact Rounded +addx3233 add -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> -23385972217069.468331815025891947 Inexact Rounded +comx3233 compare -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> 1 +divx3233 divide -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> 1.1813816642548920194709898111624E-9 Inexact Rounded +dvix3233 divideint -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> 0 +mulx3233 multiply -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> 646101997676091306.41485393678655 Inexact Rounded +powx3233 power -27627.758745381267780885067447671 -2 -> 1.3101128009560812529198521922269E-9 Inexact Rounded +remx3233 remainder -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> -27627.758745381267780885067447671 +subx3233 subtract -27627.758745381267780885067447671 -23385972189441.709586433758111062 -> 23385972161813.950841052490330177 Inexact Rounded +addx3234 add 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> 2.0981974379099914752963711944307E-223 Inexact Rounded +comx3234 compare 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> 1 +divx3234 divide 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> -4.7661318949867060595545765053187E+731 Inexact Rounded +dvix3234 divideint 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> NaN Division_impossible +mulx3234 multiply 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> -9.2369086409102239573726316593648E-1178 Inexact Rounded +powx3234 power 209819.74379099914752963711944307E-228 -4 -> 5.1595828494111690910650919776705E+890 Inexact Rounded +remx3234 remainder 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> NaN Division_impossible +subx3234 subtract 209819.74379099914752963711944307E-228 -440230.6700989532467831370320266E-960 -> 2.0981974379099914752963711944307E-223 Inexact Rounded +addx3235 add 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> 2.3488457600415474270259330865184 Inexact Rounded +comx3235 compare 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> 1 +divx3235 divide 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> 2.5579771002708402753412266574941E+605 Inexact Rounded +dvix3235 divideint 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> NaN Division_impossible +mulx3235 multiply 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> 2.1568122732142531556215204459407E-605 Inexact Rounded +powx3235 power 2.3488457600415474270259330865184 9 -> 2176.1583446147511579113022622255 Inexact Rounded +remx3235 remainder 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> NaN Division_impossible +subx3235 subtract 2.3488457600415474270259330865184 9182434.6660212482500376220508605E-612 -> 2.3488457600415474270259330865184 Inexact Rounded +addx3236 add -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> -5107586300197.9703941034404557409 Inexact Rounded +comx3236 compare -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> -1 +divx3236 divide -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> -9.0225606358909877855326357402242E+775 Inexact Rounded +dvix3236 divideint -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> NaN Division_impossible +mulx3236 multiply -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> -2.8913563307290346152596212593532E-751 Inexact Rounded +powx3236 power -5107586300197.9703941034404557409 6 -> 1.7753920894188022125919559565029E+76 Inexact Rounded +remx3236 remainder -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> NaN Division_impossible +subx3236 subtract -5107586300197.9703941034404557409 56609.05486055057838678039496686E-768 -> -5107586300197.9703941034404557409 Inexact Rounded +addx3237 add -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> -70454076296048.077427972135182788 Inexact Rounded +comx3237 compare -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> -1 +divx3237 divide -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> 11363232.779549422490548997517194 Inexact Rounded +dvix3237 divideint -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> 11363232 +mulx3237 multiply -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> 436827801504436566945.76663687924 Inexact Rounded +powx3237 power -70454070095869.70717871212601390 -6200178 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3237 remainder -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> -4833345.467866203920028883583808 +subx3237 subtract -70454070095869.70717871212601390 -6200178.370249260009168888392406 -> -70454063895691.336929452116845012 Inexact Rounded +addx3238 add 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> 29119.220621511046558757900645228 Inexact Rounded +comx3238 compare 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> 1 +divx3238 divide 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> 8.2781197380089684063239752337467E+219 Inexact Rounded +dvix3238 divideint 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> NaN Division_impossible +mulx3238 multiply 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> 1.0243014554512542440592768088600E-211 Inexact Rounded +powx3238 power 29119.220621511046558757900645228 4 -> 718983605328417461.32835984217255 Inexact Rounded +remx3238 remainder 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> NaN Division_impossible +subx3238 subtract 29119.220621511046558757900645228 3517612.8810761470018676311863010E-222 -> 29119.220621511046558757900645228 Inexact Rounded +addx3239 add -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> -5695442.3185284567660037344669935 Inexact Rounded +comx3239 compare -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> 1 +divx3239 divide -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> 0.00090825526554639915580539316714451 Inexact Rounded +dvix3239 divideint -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> 0 +mulx3239 multiply -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> 29408596423.801454053855793898323 Inexact Rounded +powx3239 power -5168.2214111091132913776042214525 -5690274 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3239 remainder -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> -5168.2214111091132913776042214525 +subx3239 subtract -5168.2214111091132913776042214525 -5690274.0971173476527123568627720 -> 5685105.8757062385394209792585505 Inexact Rounded +addx3240 add 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> 31712.980161250558571611312236423 Inexact Rounded +comx3240 compare 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> 1 +divx3240 divide 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> -16.319683055519892881394358449220 Inexact Rounded +dvix3240 divideint 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> -16 +mulx3240 multiply 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> -69933662.130469766080574235843448 Inexact Rounded +powx3240 power 33783.060857197067391462144517964 -2070 -> 3.9181336001803008597293818984406E-9375 Inexact Rounded +remx3240 remainder 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> 661.7697220529262738488280133144 +subx3240 subtract 33783.060857197067391462144517964 -2070.0806959465088198508322815406 -> 35853.141553143576211312976799505 Inexact Rounded +addx3241 add 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> 7.3330633078828216018536326743325E+986 Inexact Rounded +comx3241 compare 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> -1 +divx3241 divide 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> 5.7557712676064206636178247554056E-1879 Inexact Rounded +dvix3241 divideint 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> 0 +mulx3241 multiply 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> 3.0950979358603075650592433398939E+95 Inexact Rounded +powx3241 power 42207435091050.840296353874733169E-905 7 -> 2.3862872940615283599573082966642E-6240 Inexact Rounded +remx3241 remainder 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> 4.2207435091050840296353874733169E-892 +subx3241 subtract 42207435091050.840296353874733169E-905 73330633078.828216018536326743325E+976 -> -7.3330633078828216018536326743325E+986 Inexact Rounded +addx3242 add -71800.806700868784841045406679641 -39617456964250697902519150526701 -> -39617456964250697902519150598502 Inexact Rounded +comx3242 compare -71800.806700868784841045406679641 -39617456964250697902519150526701 -> 1 +divx3242 divide -71800.806700868784841045406679641 -39617456964250697902519150526701 -> 1.8123527405017220178579049964126E-27 Inexact Rounded +dvix3242 divideint -71800.806700868784841045406679641 -39617456964250697902519150526701 -> 0 +mulx3242 multiply -71800.806700868784841045406679641 -39617456964250697902519150526701 -> 2.8445653694701522164901827524538E+36 Inexact Rounded +powx3242 power -71800.806700868784841045406679641 -4 -> 3.7625536850895480882178599428774E-20 Inexact Rounded +remx3242 remainder -71800.806700868784841045406679641 -39617456964250697902519150526701 -> -71800.806700868784841045406679641 +subx3242 subtract -71800.806700868784841045406679641 -39617456964250697902519150526701 -> 39617456964250697902519150454900 Inexact Rounded +addx3243 add 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 53627809061.200981502803149181991 Inexact Rounded +comx3243 compare 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 1 +divx3243 divide 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 163369.13159039717901500465109839 Inexact Rounded +dvix3243 divideint 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 163369 +mulx3243 multiply 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 17603733760058752.363123585224369 Inexact Rounded +powx3243 power 53627480801.631504892310016062160 328260 -> Infinity Overflow Inexact Rounded +remx3243 remainder 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 43195.80712523964536237599604393 +subx3243 subtract 53627480801.631504892310016062160 328259.56947661049313311983109503 -> 53627152542.062028281816882942329 Inexact Rounded +addx3244 add -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> -5150456970.7802587986281516264289 Inexact Rounded +comx3244 compare -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> -1 +divx3244 divide -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> 51.633359351732432283879274192947 Inexact Rounded +dvix3244 divideint -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> 51 +mulx3244 multiply -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> 494424210127893893.12581512954787 Inexact Rounded +powx3244 power -5052601598.5559371338428368438728 -97855372 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3244 remainder -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> -61977615.115532229791782933513536 +subx3244 subtract -5052601598.5559371338428368438728 -97855372.224321664785314782556064 -> -4954746226.3316154690575220613167 Inexact Rounded +addx3245 add 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> 4.2708691760149477598920960628392E+477 Inexact Rounded +comx3245 compare 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> -1 +divx3245 divide 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> 9.8531098643021951048744078027283E-320 Inexact Rounded +dvix3245 divideint 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> 0 +mulx3245 multiply 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> 1.7972391158952189002169082753183E+636 Inexact Rounded +powx3245 power 4208134320733.7069742988228068191E+146 4 -> 3.1358723439830872127129821963857E+634 Inexact Rounded +remx3245 remainder 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> 4.2081343207337069742988228068191E+158 +subx3245 subtract 4208134320733.7069742988228068191E+146 4270869.1760149477598920960628392E+471 -> -4.2708691760149477598920960628392E+477 Inexact Rounded +addx3246 add -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> -8.5077009657942581515590471189084E+308 Inexact Rounded +comx3246 compare -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> -1 +divx3246 divide -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> -8.8143110457236089978070419047970E+548 Inexact Rounded +dvix3246 divideint -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> NaN Division_impossible +mulx3246 multiply -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> -8.2117564660363596283732942091852E+68 Inexact Rounded +powx3246 power -8.5077009657942581515590471189084E+308 10 -> 1.9866536812573207868350640760678E+3089 Inexact Rounded +remx3246 remainder -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> NaN Division_impossible +subx3246 subtract -8.5077009657942581515590471189084E+308 9652145155.374217047842114042376E-250 -> -8.5077009657942581515590471189084E+308 Inexact Rounded +addx3247 add -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> -9.5049703032286960790904181078063E+622 Inexact Rounded +comx3247 compare -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> -1 +divx3247 divide -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> 1.1020772033225707125391212519421E+621 Inexact Rounded +dvix3247 divideint -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> NaN Division_impossible +mulx3247 multiply -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> 8.1976525957425311427858087117655E+624 Inexact Rounded +powx3247 power -9504.9703032286960790904181078063E+619 -86 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3247 remainder -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> NaN Division_impossible +subx3247 subtract -9504.9703032286960790904181078063E+619 -86.245956949049186533469206485003 -> -9.5049703032286960790904181078063E+622 Inexact Rounded +addx3248 add -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> -440323641.68311120898457496019108 Inexact Rounded +comx3248 compare -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> -1 +divx3248 divide -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> 4285.4305022264473269770246126234 Inexact Rounded +dvix3248 divideint -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> 4285 +mulx3248 multiply -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> 45221700683419.655596771711603505 Inexact Rounded +powx3248 power -440220916.66716743026896931194749 -102725 -> -0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3248 remainder -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> -44223.34807563389876658817398125 +subx3248 subtract -440220916.66716743026896931194749 -102725.01594377871560564824358775 -> -440118191.65122365155336366370390 Inexact Rounded +addx3249 add -46.250735086006350517943464758019 14656357555174.263295266074908024 -> 14656357555128.012560180068557506 Inexact Rounded +comx3249 compare -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -1 +divx3249 divide -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -3.1556773169523313932207725522866E-12 Inexact Rounded +dvix3249 divideint -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -0 +mulx3249 multiply -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -677867310610152.55569620459788530 Inexact Rounded +powx3249 power -46.250735086006350517943464758019 1 -> -46.250735086006350517943464758019 +remx3249 remainder -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -46.250735086006350517943464758019 +subx3249 subtract -46.250735086006350517943464758019 14656357555174.263295266074908024 -> -14656357555220.514030352081258542 Inexact Rounded +addx3250 add -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> -6.1641121299391316420647102699627E+776 Inexact Rounded +comx3250 compare -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> -1 +divx3250 divide -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> 6.7076702065897819604716946852581E+291 Inexact Rounded +dvix3250 divideint -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> NaN Division_impossible +mulx3250 multiply -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> 5.6646014458394584921579417504939E+1261 Inexact Rounded +powx3250 power -61641121299391.316420647102699627E+763 -9 -> -7.7833261179975532508748150708605E-6992 Inexact Rounded +remx3250 remainder -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> NaN Division_impossible +subx3250 subtract -61641121299391.316420647102699627E+763 -91896469863.461006903590004188187E+474 -> -6.1641121299391316420647102699627E+776 Inexact Rounded +addx3251 add 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> -1.9498732131365824921639467044927E-511 Inexact Rounded +comx3251 compare 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> 1 +divx3251 divide 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> -4.9576772044192514715453215933704E-314 Inexact Rounded +dvix3251 divideint 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> -0 +mulx3251 multiply 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> -1.8849116232962331617140676274611E-1335 Inexact Rounded +powx3251 power 96668419802749.555738010239087449E-838 -2 -> 1.0701157625268896323611633350003E+1648 Inexact Rounded +remx3251 remainder 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> 9.6668419802749555738010239087449E-825 +subx3251 subtract 96668419802749.555738010239087449E-838 -19498732131365824921639467044927E-542 -> 1.9498732131365824921639467044927E-511 Inexact Rounded +addx3252 add -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> -8.5345439111979959060312457195190E+154 Inexact Rounded +comx3252 compare -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> -1 +divx3252 divide -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> -5.1764925822381062287959523371316E+141 Inexact Rounded +dvix3252 divideint -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> NaN Division_impossible +mulx3252 multiply -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> -1.4071002443255581217471698731240E+168 Inexact Rounded +powx3252 power -8534543911197995906031245719519E+124 2 -> 7.2838439772166785429482995041337E+309 Inexact Rounded +remx3252 remainder -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> NaN Division_impossible +subx3252 subtract -8534543911197995906031245719519E+124 16487117050031.594886541650897974 -> -8.5345439111979959060312457195190E+154 Inexact Rounded +addx3253 add -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> 9.2570938837239134052589184917186E+916 Inexact Rounded +comx3253 compare -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -1 +divx3253 divide -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -6.7692307720384142592597124956951E-907 Inexact Rounded +dvix3253 divideint -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -0 +mulx3253 multiply -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -5.8008102109774576654709018012876E+927 Inexact Rounded +powx3253 power -62663404777.352508979582846931050 9 -> -1.4897928814133059615670462753825E+97 Inexact Rounded +remx3253 remainder -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -62663404777.352508979582846931050 +subx3253 subtract -62663404777.352508979582846931050 9.2570938837239134052589184917186E+916 -> -9.2570938837239134052589184917186E+916 Inexact Rounded +addx3254 add 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> -1.7353669504253419489494030651507E-630 Inexact Rounded +comx3254 compare 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> 1 +divx3254 divide 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> -1.0053212169604565230497117966004E-197 Inexact Rounded +dvix3254 divideint 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> -0 +mulx3254 multiply 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> -3.0275232892710668432895049546233E-1457 Inexact Rounded +powx3254 power 1.744601214474560992754529320172E-827 -2 -> 3.2855468099615282394992542515980E+1653 Inexact Rounded +remx3254 remainder 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> 1.744601214474560992754529320172E-827 +subx3254 subtract 1.744601214474560992754529320172E-827 -17.353669504253419489494030651507E-631 -> 1.7353669504253419489494030651507E-630 Inexact Rounded +addx3255 add 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> 4.4103206624152665337631438377420E+751 Inexact Rounded +comx3255 compare 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> -1 +divx3255 divide 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> 8.3257335949720619093963917942525E-723 Inexact Rounded +dvix3255 divideint 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> 0 +mulx3255 multiply 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> 1.6194324757808363802947192054966E+781 Inexact Rounded +powx3255 power 0367191549036702224827734853471 4 -> 1.8179030119354318182493703269258E+118 Inexact Rounded +remx3255 remainder 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> 367191549036702224827734853471 +subx3255 subtract 0367191549036702224827734853471 4410320662415266533763143837742E+721 -> -4.4103206624152665337631438377420E+751 Inexact Rounded +addx3256 add 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> 97607380.048316862763014969003011 Inexact Rounded +comx3256 compare 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> 1 +divx3256 divide 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> -1010.0036335861757252324592571874 Inexact Rounded +dvix3256 divideint 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> -1010 +mulx3256 multiply 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> -9451544582305.1234805483449772252 Inexact Rounded +powx3256 power 097704116.4492566721965710365073 -96736 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3256 remainder 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> 351.500049144304942857175263550 +subx3256 subtract 097704116.4492566721965710365073 -96736.400939809433556067504289145 -> 97800852.850196481630127104011589 Inexact Rounded +addx3257 add 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> 19533298.147150158931958733807878 Inexact Rounded +comx3257 compare 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> 1 +divx3257 divide 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> 2.4373460837728485395672882395171E+646 Inexact Rounded +dvix3257 divideint 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> NaN Division_impossible +mulx3257 multiply 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> 1.5654311016630284502459158971272E-632 Inexact Rounded +powx3257 power 19533298.147150158931958733807878 8 -> 2.1193595047638230427530063654613E+58 Inexact Rounded +remx3257 remainder 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> NaN Division_impossible +subx3257 subtract 19533298.147150158931958733807878 80.141668338350708476637377647025E-641 -> 19533298.147150158931958733807878 Inexact Rounded +addx3258 add -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> -23765003221220177430797028997378 Inexact Rounded +comx3258 compare -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> -1 +divx3258 divide -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> 1.5631405336020930064824135669541E+966 Inexact Rounded +dvix3258 divideint -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> NaN Division_impossible +mulx3258 multiply -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> 3.6130812678955994625210007005216E-904 Inexact Rounded +powx3258 power -23765003221220177430797028997378 -2 -> 1.7706154318483481190364979209436E-63 Inexact Rounded +remx3258 remainder -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> NaN Division_impossible +subx3258 subtract -23765003221220177430797028997378 -15203369569.373411506379096871224E-945 -> -23765003221220177430797028997378 Inexact Rounded +addx3259 add 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> 1.2925541937932433359193338910552E+937 Inexact Rounded +comx3259 compare 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> 1 +divx3259 divide 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> -4.5956836453828213050223260551064E+928 Inexact Rounded +dvix3259 divideint 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> NaN Division_impossible +mulx3259 multiply 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> -3.6353597697504958096931088780367E+945 Inexact Rounded +powx3259 power 129255.41937932433359193338910552E+932 -281253953 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3259 remainder 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> NaN Division_impossible +subx3259 subtract 129255.41937932433359193338910552E+932 -281253953.38990382799508873560320 -> 1.2925541937932433359193338910552E+937 Inexact Rounded +addx3260 add -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -86331.770222938687407130786425993 Inexact Rounded +comx3260 compare -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -1 +divx3260 divide -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -163.42858201815891408475902229649 Inexact Rounded +dvix3260 divideint -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -163 +mulx3260 multiply -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -46168354.810498682140456143534524 Inexact Rounded +powx3260 power -86863.276249466008289214762980838 532 -> 2.8897579184173839519859710217510E+2627 Inexact Rounded +remx3260 remainder -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -227.79392551270450952658454114212 +subx3260 subtract -86863.276249466008289214762980838 531.50602652732088208397655484476 -> -87394.782275993329171298739535683 Inexact Rounded +addx3261 add -40707.169006771111855573524157083 -68795521421321853333274411827749 -> -68795521421321853333274411868456 Inexact Rounded +comx3261 compare -40707.169006771111855573524157083 -68795521421321853333274411827749 -> 1 +divx3261 divide -40707.169006771111855573524157083 -68795521421321853333274411827749 -> 5.9171248601300236694386185513139E-28 Inexact Rounded +dvix3261 divideint -40707.169006771111855573524157083 -68795521421321853333274411827749 -> 0 +mulx3261 multiply -40707.169006771111855573524157083 -68795521421321853333274411827749 -> 2.8004709174066910577370895499575E+36 Inexact Rounded +powx3261 power -40707.169006771111855573524157083 -7 -> -5.3988802915897595722440392884051E-33 Inexact Rounded +remx3261 remainder -40707.169006771111855573524157083 -68795521421321853333274411827749 -> -40707.169006771111855573524157083 +subx3261 subtract -40707.169006771111855573524157083 -68795521421321853333274411827749 -> 68795521421321853333274411787042 Inexact Rounded +addx3262 add -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> -9.0838752568673728630494658778003E+108 Inexact Rounded +comx3262 compare -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> -1 +divx3262 divide -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> 1.2308545518588430875268553851424E+106 Inexact Rounded +dvix3262 divideint -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> NaN Division_impossible +mulx3262 multiply -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> 6.7040244160213718891633678248127E+111 Inexact Rounded +powx3262 power -90838752568673.728630494658778003E+095 -738 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3262 remainder -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> NaN Division_impossible +subx3262 subtract -90838752568673.728630494658778003E+095 -738.01370301217606577533107981431 -> -9.0838752568673728630494658778003E+108 Inexact Rounded +addx3263 add -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> -3.1196062390425302071032035080570 Inexact Rounded +comx3263 compare -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> 1 +divx3263 divide -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> 1.3608643662980066356437236081969E-670 Inexact Rounded +dvix3263 divideint -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> 0 +mulx3263 multiply -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> 1.3243854561493627844105290415330E-669 Inexact Rounded +powx3263 power -4245360967593.9206771555839718158E-682 -3 -> -1.3069414504933253288042820429894E+2008 Inexact Rounded +remx3263 remainder -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> -4.2453609675939206771555839718158E-670 +subx3263 subtract -4245360967593.9206771555839718158E-682 -3.119606239042530207103203508057 -> 3.1196062390425302071032035080570 Inexact Rounded +addx3264 add -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> -60810.964656409685060465379447110 Inexact Rounded +comx3264 compare -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> 1 +divx3264 divide -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> 5.6275137635287882875914124742650E-16 Inexact Rounded +dvix3264 divideint -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> 0 +mulx3264 multiply -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> 0.0000020810396331962224323288744910607 Inexact Rounded +powx3264 power -3422145405774.0800213000547612240E-023 -60811 -> -Infinity Overflow Inexact Rounded +remx3264 remainder -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> -3.4221454057740800213000547612240E-11 +subx3264 subtract -3422145405774.0800213000547612240E-023 -60810.964656409650839011321706310 -> 60810.964656409616617557263965510 Inexact Rounded +addx3265 add -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> -94860846133404815410816234000694 Inexact Rounded +comx3265 compare -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> 1 +divx3265 divide -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> 2.5850297647576657819483988845904E-686 Inexact Rounded +dvix3265 divideint -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> 0 +mulx3265 multiply -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> 2.3261597474398006215017751785104E-622 Inexact Rounded +powx3265 power -24521811.07649485796598387627478E-661 -9 -> -3.1190843559949184618590264246586E+5882 Inexact Rounded +remx3265 remainder -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> -2.452181107649485796598387627478E-654 +subx3265 subtract -24521811.07649485796598387627478E-661 -94860846133404815410816234000694 -> 94860846133404815410816234000694 Inexact Rounded +addx3266 add -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -5038638032824.4395321279731805825 Inexact Rounded +comx3266 compare -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -1 +divx3266 divide -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -1295.6457979549894351378127413283 Inexact Rounded +dvix3266 divideint -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -1295 +mulx3266 multiply -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -19625045834830808256871.952659048 Inexact Rounded +powx3266 power -5042529937498.8944492248538951438 4 -> 6.4653782991800009492580180960839E+50 Inexact Rounded +remx3266 remainder -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -2513384079.7768087643285383187045 +subx3266 subtract -5042529937498.8944492248538951438 3891904674.4549170968807145612549 -> -5046421842173.3493663217346097051 Inexact Rounded +addx3267 add -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> 2732988.5891363639325008206099712 Inexact Rounded +comx3267 compare -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -1 +divx3267 divide -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -1.9605795855687791246611683328346E-663 Inexact Rounded +dvix3267 divideint -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -0 +mulx3267 multiply -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -1.4644013247528895376254850705597E-650 Inexact Rounded +powx3267 power -535824163.54531747646293693868651E-665 2732989 -> -0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3267 remainder -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -5.3582416354531747646293693868651E-657 +subx3267 subtract -535824163.54531747646293693868651E-665 2732988.5891363639325008206099712 -> -2732988.5891363639325008206099712 Inexact Rounded +addx3268 add 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> 52864854.899420632375589206704068 Inexact Rounded +comx3268 compare 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> -1 +divx3268 divide 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> 4.5460641203455697917573431961511E-513 Inexact Rounded +dvix3268 divideint 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> 0 +mulx3268 multiply 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> 1.2704853045231735885074945710576E-497 Inexact Rounded +powx3268 power 24032.702008553084252925140858134E-509 52864855 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3268 remainder 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> 2.4032702008553084252925140858134E-505 +subx3268 subtract 24032.702008553084252925140858134E-509 52864854.899420632375589206704068 -> -52864854.899420632375589206704068 Inexact Rounded +addx3269 add 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> 754.44220417415325444943566016062 Inexact Rounded +comx3269 compare 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> -1 +divx3269 divide 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> 9.4842547068617879794218050008353E-489 Inexact Rounded +dvix3269 divideint 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> 0 +mulx3269 multiply 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> 5.3982769208667021044675146787248E-483 Inexact Rounded +powx3269 power 71553220259.938950698030519906727E-496 754 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3269 remainder 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> 7.1553220259938950698030519906727E-486 +subx3269 subtract 71553220259.938950698030519906727E-496 754.44220417415325444943566016062 -> -754.44220417415325444943566016062 Inexact Rounded +addx3270 add 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> 35572.960284795962697740953932508 Inexact Rounded +comx3270 compare 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> 1 +divx3270 divide 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> 6.8357605153869556504869061469852E+732 Inexact Rounded +dvix3270 divideint 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> NaN Division_impossible +mulx3270 multiply 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> 1.8511992931514185102474609686066E-724 Inexact Rounded +powx3270 power 35572.960284795962697740953932508 5 -> 56963942247985404337401.149353169 Inexact Rounded +remx3270 remainder 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> NaN Division_impossible +subx3270 subtract 35572.960284795962697740953932508 520.39506364687594082725754878910E-731 -> 35572.960284795962697740953932508 Inexact Rounded +addx3271 add 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> 5.3035405018123760598334895413057E+849 Inexact Rounded +comx3271 compare 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> 1 +divx3271 divide 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> -5.5485278436266802470202487233285E+836 Inexact Rounded +dvix3271 divideint 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> NaN Division_impossible +mulx3271 multiply 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> -5.0693702270365259274203181894613E+862 Inexact Rounded +powx3271 power 53035405018123760598334895413057E+818 -10 -> 5.6799053935427267944455848135618E-8498 Inexact Rounded +remx3271 remainder 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> NaN Division_impossible +subx3271 subtract 53035405018123760598334895413057E+818 -9558464247240.4476790042911379151 -> 5.3035405018123760598334895413057E+849 Inexact Rounded +addx3272 add 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> 9.8701498316307365714167410690192E+135 Inexact Rounded +comx3272 compare 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> -1 +divx3272 divide 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> 9.6747012716293341927566515915016E-135 Inexact Rounded +dvix3272 divideint 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> 0 +mulx3272 multiply 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> 9.4250802116091862185764800227004E+137 Inexact Rounded +powx3272 power 95.490751127249945886828257312118 10 -> 63039548646186864162.847491534337 Inexact Rounded +remx3272 remainder 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> 95.490751127249945886828257312118 +subx3272 subtract 95.490751127249945886828257312118 987.01498316307365714167410690192E+133 -> -9.8701498316307365714167410690192E+135 Inexact Rounded +addx3273 add 69434850287.460788550936730296153 -35119136549015044241569827542264 -> -35119136549015044241500392691977 Inexact Rounded +comx3273 compare 69434850287.460788550936730296153 -35119136549015044241569827542264 -> 1 +divx3273 divide 69434850287.460788550936730296153 -35119136549015044241569827542264 -> -1.9771229338327273644129394734299E-21 Inexact Rounded +dvix3273 divideint 69434850287.460788550936730296153 -35119136549015044241569827542264 -> -0 +mulx3273 multiply 69434850287.460788550936730296153 -35119136549015044241569827542264 -> -2.4384919885057519302646522425980E+42 Inexact Rounded +powx3273 power 69434850287.460788550936730296153 -4 -> 4.3021939605842038995370443743844E-44 Inexact Rounded +remx3273 remainder 69434850287.460788550936730296153 -35119136549015044241569827542264 -> 69434850287.460788550936730296153 +subx3273 subtract 69434850287.460788550936730296153 -35119136549015044241569827542264 -> 35119136549015044241639262392551 Inexact Rounded +addx3274 add -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> -65551667.214560244414938327003123 Inexact Rounded +comx3274 compare -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> 1 +divx3274 divide -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> 0.0000059835205237890809449684317245033 Inexact Rounded +dvix3274 divideint -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> 0 +mulx3274 multiply -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> 25711006105.487929108329637701882 Inexact Rounded +powx3274 power -392.22739924621965621739098725407 -65551275 -> -0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3274 remainder -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> -392.22739924621965621739098725407 +subx3274 subtract -392.22739924621965621739098725407 -65551274.987160998195282109612136 -> 65550882.759761751975625892221149 Inexact Rounded +addx3275 add 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 6437779.6650608333186472347196668 Inexact Rounded +comx3275 compare 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 1 +divx3275 divide 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 261.61406460270241498757868681883 Inexact Rounded +dvix3275 divideint 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 261 +mulx3275 multiply 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 157216217318.36494525300694583138 Inexact Rounded +powx3275 power 6413265.4423561191792972085539457 24514 -> Infinity Overflow Inexact Rounded +remx3275 remainder 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 15053.316425728808940379300726594 +subx3275 subtract 6413265.4423561191792972085539457 24514.222704714139350026165721146 -> 6388751.2196514050399471823882246 Inexact Rounded +addx3276 add -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> -6.9667706389122107760046184064057E+487 Inexact Rounded +comx3276 compare -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> -1 +divx3276 divide -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> -2.1498522911689997341347293419761E+486 Inexact Rounded +dvix3276 divideint -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> NaN Division_impossible +mulx3276 multiply -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> -2.2576385054257595259511556258470E+489 Inexact Rounded +powx3276 power -6.9667706389122107760046184064057E+487 32 -> Infinity Overflow Inexact Rounded +remx3276 remainder -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> NaN Division_impossible +subx3276 subtract -6.9667706389122107760046184064057E+487 32.405810703971538278419625527234 -> -6.9667706389122107760046184064057E+487 Inexact Rounded +addx3277 add 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> 77986002255.07800973642274406015 +comx3277 compare 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> 1 +divx3277 divide 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> -1.2597639604731753284599748820876 Inexact Rounded +dvix3277 divideint 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> -1 +mulx3277 multiply 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> -113544133799497082075557.21180430 Inexact Rounded +powx3277 power 378204716633.40024100602896057615 -3 -> 1.8484988212401886887562779996737E-35 Inexact Rounded +remx3277 remainder 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> 77986002255.07800973642274406015 +subx3277 subtract 378204716633.40024100602896057615 -0300218714378.322231269606216516 -> 678423431011.72247227563517709215 +addx3278 add -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> -4.4234512012457148027685282969235E+505 Inexact Rounded +comx3278 compare -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> -1 +divx3278 divide -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> -2.0742325477916347193181603963257E+499 Inexact Rounded +dvix3278 divideint -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> NaN Division_impossible +mulx3278 multiply -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> -9.4333301975395170465982968019915E+511 Inexact Rounded +powx3278 power -44234.512012457148027685282969235E+501 2132572 -> Infinity Overflow Inexact Rounded +remx3278 remainder -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> NaN Division_impossible +subx3278 subtract -44234.512012457148027685282969235E+501 2132572.4571987908375002100894927 -> -4.4234512012457148027685282969235E+505 Inexact Rounded +addx3279 add -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> 9.7520428746722497621936998533848E+519 Inexact Rounded +comx3279 compare -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -1 +divx3279 divide -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -3.6449692061227100572768330912162E-590 Inexact Rounded +dvix3279 divideint -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -0 +mulx3279 multiply -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -3.4664510156653491769901435777060E+450 Inexact Rounded +powx3279 power -3554.5895974968741465654022772100E-073 10 -> 3.2202875716019266933215387456197E-695 Inexact Rounded +remx3279 remainder -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -3.5545895974968741465654022772100E-70 +subx3279 subtract -3554.5895974968741465654022772100E-073 9752.0428746722497621936998533848E+516 -> -9.7520428746722497621936998533848E+519 Inexact Rounded +addx3280 add 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> 4633944440549.3093886865008969464 Inexact Rounded +comx3280 compare 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> -1 +divx3280 divide 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> 0.00016191587157664541463871807382759 Inexact Rounded +dvix3280 divideint 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> 0 +mulx3280 multiply 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> 3475765273659325895012.7612107556 Inexact Rounded +powx3280 power 750187685.63632608923397234391668 5 -> 2.3760176068829529745152188798557E+44 Inexact Rounded +remx3280 remainder 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> 750187685.63632608923397234391668 +subx3280 subtract 750187685.63632608923397234391668 4633194252863.6730625972669246025 -> -4632444065178.0367365080329522586 Inexact Rounded +addx3281 add 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> 8038885676320423832297608779.9751 Inexact Rounded +comx3281 compare 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> -1 +divx3281 divide 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> 3.7554998862319807295903348960280E-43 Inexact Rounded +dvix3281 divideint 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> 0 +mulx3281 multiply 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> 24269423384249.611263728854793731 Inexact Rounded +powx3281 power 30190034242853.251165951457589386E-028 8 -> 6.9009494305612589578332690692113E-117 Inexact Rounded +remx3281 remainder 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> 3.0190034242853251165951457589386E-15 +subx3281 subtract 30190034242853.251165951457589386E-028 8038885676.3204238322976087799751E+018 -> -8038885676320423832297608779.9751 Inexact Rounded +addx3282 add 65.537942676774715953400768803539 125946917260.87536506197191782198 -> 125946917326.41330773874663377538 Inexact Rounded +comx3282 compare 65.537942676774715953400768803539 125946917260.87536506197191782198 -> -1 +divx3282 divide 65.537942676774715953400768803539 125946917260.87536506197191782198 -> 5.2036162616846894920389414735878E-10 Inexact Rounded +dvix3282 divideint 65.537942676774715953400768803539 125946917260.87536506197191782198 -> 0 +mulx3282 multiply 65.537942676774715953400768803539 125946917260.87536506197191782198 -> 8254301843759.7376990957355411370 Inexact Rounded +powx3282 power 65.537942676774715953400768803539 1 -> 65.537942676774715953400768803539 +remx3282 remainder 65.537942676774715953400768803539 125946917260.87536506197191782198 -> 65.537942676774715953400768803539 +subx3282 subtract 65.537942676774715953400768803539 125946917260.87536506197191782198 -> -125946917195.33742238519720186858 Inexact Rounded +addx3283 add 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 8015272349626.7792105333859739528 Inexact Rounded +comx3283 compare 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 1 +divx3283 divide 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 8443970438.5560107978790084430110 Inexact Rounded +dvix3283 divideint 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 8443970438 +mulx3283 multiply 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 7608339144595734.8984281431471741 Inexact Rounded +powx3283 power 8015272348677.5489394183881813700 949 -> Infinity Overflow Inexact Rounded +remx3283 remainder 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 527.78228041355742397895303690364 +subx3283 subtract 8015272348677.5489394183881813700 949.23027111499779258284877920022 -> 8015272347728.3186683033903887872 Inexact Rounded +addx3284 add -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> -32595333982.670686221204518042250 Inexact Rounded +comx3284 compare -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> -1 +divx3284 divide -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> -4.7150744038935574574681609457727E+867 Inexact Rounded +dvix3284 divideint -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> NaN Division_impossible +mulx3284 multiply -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> -2.2533171407952851885446213697715E-847 Inexact Rounded +powx3284 power -32595333982.67068622120451804225 7 -> -3.9092014148031739666525606093306E+73 Inexact Rounded +remx3284 remainder -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> NaN Division_impossible +subx3284 subtract -32595333982.67068622120451804225 69130.052233649808750113141502465E-862 -> -32595333982.670686221204518042250 Inexact Rounded +addx3285 add -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> 292178000.06450804618299520094843 Inexact Rounded +comx3285 compare -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -1 +divx3285 divide -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -6.0046235559392715334668277026896E-533 Inexact Rounded +dvix3285 divideint -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -0 +mulx3285 multiply -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -5.1260260597833406461110136952456E-516 Inexact Rounded +powx3285 power -17544189017145.710117633021800426E-537 292178000 -> 0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3285 remainder -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -1.7544189017145710117633021800426E-524 +subx3285 subtract -17544189017145.710117633021800426E-537 292178000.06450804618299520094843 -> -292178000.06450804618299520094843 Inexact Rounded +addx3286 add -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -506639.97552899703974189156234893 Inexact Rounded +comx3286 compare -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -1 +divx3286 divide -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -45982.150707356329027698717189104 Inexact Rounded +dvix3286 divideint -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -45982 +mulx3286 multiply -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -5582497.2457419607392940234271222 Inexact Rounded +powx3286 power -506650.99395649907139204052441630 11 -> -5.6467412678809885333313818078829E+62 Inexact Rounded +remx3286 remainder -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -1.660558079734242466742739640844 +subx3286 subtract -506650.99395649907139204052441630 11.018427502031650148962067367158 -> -506662.01238400110304218948648367 Inexact Rounded +addx3287 add 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> -84.001893040865864590122330800768 Inexact Rounded +comx3287 compare 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> 1 +divx3287 divide 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> -5.7699118247660357814641813260524E-234 Inexact Rounded +dvix3287 divideint 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> -0 +mulx3287 multiply 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> -4.0714332866277514481192856925775E-230 Inexact Rounded +powx3287 power 4846835159.5922372307656000769395E-241 -84 -> Infinity Overflow Inexact Rounded +remx3287 remainder 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> 4.8468351595922372307656000769395E-232 +subx3287 subtract 4846835159.5922372307656000769395E-241 -84.001893040865864590122330800768 -> 84.001893040865864590122330800768 Inexact Rounded +addx3288 add -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> -3994308913.2287755451637127790293 Inexact Rounded +comx3288 compare -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> 1 +divx3288 divide -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> 8.7698052609323004543538163061774E-9 Inexact Rounded +dvix3288 divideint -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> 0 +mulx3288 multiply -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> 139917887979.72053637272961120639 Inexact Rounded +powx3288 power -35.029311013822259358116556164908 -4 -> 6.6416138040522124693495178218096E-7 Inexact Rounded +remx3288 remainder -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> -35.029311013822259358116556164908 +subx3288 subtract -35.029311013822259358116556164908 -3994308878.1994645313414534209127 -> 3994308843.1701535175191940627961 Inexact Rounded +addx3289 add 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> -5.4918146394484565418284686127552E+374 Inexact Rounded +comx3289 compare 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> 1 +divx3289 divide 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> -1.3850911310869487895947733090204E-199 Inexact Rounded +dvix3289 divideint 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> -0 +mulx3289 multiply 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> -4.1774387343310777190917128006589E+550 Inexact Rounded +powx3289 power 7606663750.6735265233044420887018E+166 -5 -> 3.9267106978887346373957314818178E-880 Inexact Rounded +remx3289 remainder 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> 7.6066637506735265233044420887018E+175 +subx3289 subtract 7606663750.6735265233044420887018E+166 -5491814639.4484565418284686127552E+365 -> 5.4918146394484565418284686127552E+374 Inexact Rounded +addx3290 add -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> -2.5677829660831741274207326697052E-159 Inexact Rounded +comx3290 compare -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> -1 +divx3290 divide -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> 2.7277550199853009708493167299838E+671 Inexact Rounded +dvix3290 divideint -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> NaN Division_impossible +mulx3290 multiply -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> 2.4171926410541199393728294762559E-989 Inexact Rounded +powx3290 power -25677.829660831741274207326697052E-163 -9 -> -2.0605121420682764897867221992174E+1427 Inexact Rounded +remx3290 remainder -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> NaN Division_impossible +subx3290 subtract -25677.829660831741274207326697052E-163 -94135395124193048560172705082029E-862 -> -2.5677829660831741274207326697052E-159 Inexact Rounded +addx3291 add 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> -1.5412563837540810793697955063295E+554 Inexact Rounded +comx3291 compare 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> 1 +divx3291 divide 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> -6.3111872313890646144473652645030E-544 Inexact Rounded +dvix3291 divideint 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> -0 +mulx3291 multiply 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> -1.4992043761340180288065959300090E+565 Inexact Rounded +powx3291 power 97271576094.456406729671729224827 -2 -> 1.0568858765852073181352309401343E-22 Inexact Rounded +remx3291 remainder 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> 97271576094.456406729671729224827 +subx3291 subtract 97271576094.456406729671729224827 -1.5412563837540810793697955063295E+554 -> 1.5412563837540810793697955063295E+554 Inexact Rounded +addx3292 add 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> 41139789894.401826915757391777544 Inexact Rounded +comx3292 compare 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> 1 +divx3292 divide 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> -2196474369511625389289506461551.0 Inexact Rounded +dvix3292 divideint 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> -2196474369511625389289506461551 +mulx3292 multiply 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> -7.7054498611419776714291080928601E-10 Inexact Rounded +powx3292 power 41139789894.401826915757391777563 -2 -> 5.9084812442741091550891451069919E-22 Inexact Rounded +remx3292 remainder 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> 6.98141022640544018935102953527E-22 +subx3292 subtract 41139789894.401826915757391777563 -1.8729920305671057957156159690823E-020 -> 41139789894.401826915757391777582 Inexact Rounded +addx3293 add -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> -83310831287241.777598696853498149 Inexact Rounded +comx3293 compare -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> -1 +divx3293 divide -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> 1.5202754978845438636605170857478E+333 Inexact Rounded +dvix3293 divideint -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> NaN Division_impossible +mulx3293 multiply -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> 4.5654189779610386760330527839588E-306 Inexact Rounded +powx3293 power -83310831287241.777598696853498149 -5 -> -2.4916822606682624827900581728387E-70 Inexact Rounded +remx3293 remainder -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> NaN Division_impossible +subx3293 subtract -83310831287241.777598696853498149 -54799825033.797100418162985103519E-330 -> -83310831287241.777598696853498149 Inexact Rounded +addx3294 add 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> 4506653461.4414974233678331771169 Inexact Rounded +comx3294 compare 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> 1 +divx3294 divide 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> -6.0124409901781490054438220048629E+888 Inexact Rounded +dvix3294 divideint 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> NaN Division_impossible +mulx3294 multiply 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> -3.3779833273541776470902903512949E-870 Inexact Rounded +powx3294 power 4506653461.4414974233678331771169 -7 -> 2.6486272911486461102735412463189E-68 Inexact Rounded +remx3294 remainder 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> NaN Division_impossible +subx3294 subtract 4506653461.4414974233678331771169 -74955470.977653038010031457181957E-887 -> 4506653461.4414974233678331771169 Inexact Rounded +addx3295 add 23777.857951114967684767609401626 720760.03897144157012301385227528 -> 744537.89692255653780778146167691 Inexact Rounded +comx3295 compare 23777.857951114967684767609401626 720760.03897144157012301385227528 -> -1 +divx3295 divide 23777.857951114967684767609401626 720760.03897144157012301385227528 -> 0.032989978169498808275308039034795 Inexact Rounded +dvix3295 divideint 23777.857951114967684767609401626 720760.03897144157012301385227528 -> 0 +mulx3295 multiply 23777.857951114967684767609401626 720760.03897144157012301385227528 -> 17138129823.503025913034987537096 Inexact Rounded +powx3295 power 23777.857951114967684767609401626 720760 -> Infinity Overflow Inexact Rounded +remx3295 remainder 23777.857951114967684767609401626 720760.03897144157012301385227528 -> 23777.857951114967684767609401626 +subx3295 subtract 23777.857951114967684767609401626 720760.03897144157012301385227528 -> -696982.18102032660243824624287365 Inexact Rounded +addx3296 add -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> 6.0802728403071490445256786982100E+541 Inexact Rounded +comx3296 compare -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -1 +divx3296 divide -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -3.5093578667274020123788514069885E-511 Inexact Rounded +dvix3296 divideint -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -0 +mulx3296 multiply -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -1.2973997003625843317417981902198E+573 Inexact Rounded +powx3296 power -21337853323980858055292469611948 6 -> 9.4385298321304970306180652097874E+187 Inexact Rounded +remx3296 remainder -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -21337853323980858055292469611948 +subx3296 subtract -21337853323980858055292469611948 6080272840.3071490445256786982100E+532 -> -6.0802728403071490445256786982100E+541 Inexact Rounded +addx3297 add -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -818408481.65082668425744179302401 Inexact Rounded +comx3297 compare -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -1 +divx3297 divide -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -1081991.4954690752676494129493403 Inexact Rounded +dvix3297 divideint -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -1081991 +mulx3297 multiply -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -619037842458.03980537370328252817 Inexact Rounded +powx3297 power -818409238.0423893439849743856947 756 -> 1.6058883946373232750995543573461E+6738 Inexact Rounded +remx3297 remainder -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -374.76862809126749803143314108840 +subx3297 subtract -818409238.0423893439849743856947 756.39156265972753259267069158760 -> -818409994.43395200371250697836539 Inexact Rounded +addx3298 add 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 47567380385008.954845377769826287 Inexact Rounded +comx3298 compare 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 1 +divx3298 divide 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 730853388480.86247690474303493972 Inexact Rounded +dvix3298 divideint 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 730853388480 +mulx3298 multiply 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 3095909128079784.3348591472999468 Inexact Rounded +powx3298 power 47567380384943.87013600286155046 65 -> 1.0594982876763214301042437482634E+889 Inexact Rounded +remx3298 remainder 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 56.134058687770878126430844955520 +subx3298 subtract 47567380384943.87013600286155046 65.084709374908275826942076480326 -> 47567380384878.785426627953274633 Inexact Rounded +addx3299 add -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> -302031659.49048519905267279799984 Inexact Rounded +comx3299 compare -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> -1 +divx3299 divide -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> 54.765366028496664530688259272591 Inexact Rounded +dvix3299 divideint -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> 54 +mulx3299 multiply -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> 1606504025402196.8484885386501478 Inexact Rounded +powx3299 power -296615544.05897984545127115290251 -5416115 -> -0E-10030 Underflow Subnormal Inexact Rounded Clamped +remx3299 remainder -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> -4145310.7576907509755823176468844 +subx3299 subtract -296615544.05897984545127115290251 -5416115.4315053536014016450973264 -> -291199428.62747449184986950780518 Inexact Rounded +addx3300 add 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> 6.1391705914046707180652185247584E+749 Inexact Rounded +comx3300 compare 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> 1 +divx3300 divide 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> -9.0818539468906248593699700040068E+737 Inexact Rounded +dvix3300 divideint 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> NaN Division_impossible +mulx3300 multiply 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> -4.1499693532587347944890300176290E+761 Inexact Rounded +powx3300 power 61391705914.046707180652185247584E+739 -7 -> 3.0425105291210947473420999890124E-5249 Inexact Rounded +remx3300 remainder 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> NaN Division_impossible +subx3300 subtract 61391705914.046707180652185247584E+739 -675982087721.91856456125242297346 -> 6.1391705914046707180652185247584E+749 Inexact Rounded + +-- randomly generated testcases [26 Sep 2001] +precision: 33 +rounding: half_up +maxExponent: 9999 + +addx3401 add 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> -1364112374596.82605557115996067822 Inexact Rounded +comx3401 compare 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> 1 +divx3401 divide 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> -3.12789896373176963160811150593867E-11 Inexact Rounded +dvix3401 divideint 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> -0 +mulx3401 multiply 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> -58204024324286.5595453066065234923 Inexact Rounded +powx3401 power 042.668056830485571428877212944418 -1 -> 0.0234367363850869744523417227148909 Inexact Rounded +remx3401 remainder 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> 42.668056830485571428877212944418 +subx3401 subtract 042.668056830485571428877212944418 -01364112374639.4941124016455321071 -> 1364112374682.16216923213110353598 Inexact Rounded +addx3402 add -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> -3.27179426341653256363531809227344E+455 Inexact Rounded +comx3402 compare -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> -1 +divx3402 divide -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> -4.31028129684803083255704680611589E+446 Inexact Rounded +dvix3402 divideint -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> NaN Division_impossible +mulx3402 multiply -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> -2.48351255171055445110558613627379E+464 Inexact Rounded +powx3402 power -327.179426341653256363531809227344E+453 759067457 -> -Infinity Overflow Inexact Rounded +remx3402 remainder -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> NaN Division_impossible +subx3402 subtract -327.179426341653256363531809227344E+453 759067457.107518663444899356760793 -> -3.27179426341653256363531809227344E+455 Inexact Rounded +addx3403 add 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> 900181194.826119246619069527471177 Inexact Rounded +comx3403 compare 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> -1 +divx3403 divide 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> 0.0000907917210693679220610511319812826 Inexact Rounded +dvix3403 divideint 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> 0 +mulx3403 multiply 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> 73557551389502.7779979042453102926 Inexact Rounded +powx3403 power 81721.5803096185422787702538493471 900099473 -> Infinity Overflow Inexact Rounded +remx3403 remainder 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> 81721.5803096185422787702538493471 +subx3403 subtract 81721.5803096185422787702538493471 900099473.245809628076790757217328 -> -900017751.665500009534511986963479 Inexact Rounded +addx3404 add 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> 72.3239822255871305731314565069132 Inexact Rounded +comx3404 compare 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> -1 +divx3404 divide 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> 5.51900935695390664984598248115290E-806 Inexact Rounded +dvix3404 divideint 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> 0 +mulx3404 multiply 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> 2.88686045809784034794803928177854E-802 Inexact Rounded +powx3404 power 3991.56734635183403814636354392163E-807 72 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3404 remainder 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> 3.99156734635183403814636354392163E-804 +subx3404 subtract 3991.56734635183403814636354392163E-807 72.3239822255871305731314565069132 -> -72.3239822255871305731314565069132 Inexact Rounded +addx3405 add -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -61.2544651290911805069948520197050 Inexact Rounded +comx3405 compare -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -1 +divx3405 divide -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -13.0464272560079276694749924915850 Inexact Rounded +dvix3405 divideint -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -13 +mulx3405 multiply -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -337.326590072564290813539036280205 Inexact Rounded +powx3405 power -66.3393308595957726456416979163306 5 -> -1284858888.27285822259184896667990 Inexact Rounded +remx3405 remainder -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -0.23607636303607484323270126019793 +subx3405 subtract -66.3393308595957726456416979163306 5.08486573050459213864684589662559 -> -71.4241965901003647842885438129562 Inexact Rounded +addx3406 add -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> -3.93606873703567753255097095208112E+116 Inexact Rounded +comx3406 compare -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> -1 +divx3406 divide -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> 1.85284350396137075010428736564737E+107 Inexact Rounded +dvix3406 divideint -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> NaN Division_impossible +mulx3406 multiply -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> 8.36154649302353269818801263275941E+125 Inexact Rounded +powx3406 power -393606.873703567753255097095208112E+111 -2 -> 6.45467904123103560528919747688443E-234 Inexact Rounded +remx3406 remainder -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> NaN Division_impossible +subx3406 subtract -393606.873703567753255097095208112E+111 -2124339550.86891093200758095660557 -> -3.93606873703567753255097095208112E+116 Inexact Rounded +addx3407 add -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> -877573445.238180259264773343614397 +comx3407 compare -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> 1 +divx3407 divide -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> 0.0222888053076312565797460650311070 Inexact Rounded +dvix3407 divideint -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> 0 +mulx3407 multiply -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> 16425043456056213.7395191514029288 Inexact Rounded +powx3407 power -019133598.609812524622150421584346 -858439847 -> -0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3407 remainder -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> -19133598.609812524622150421584346 +subx3407 subtract -019133598.609812524622150421584346 -858439846.628367734642622922030051 -> 839306248.018555210020472500445705 +addx3408 add 465.351982159046525762715549761814 240444.975944666924657629172844780 -> 240910.327926825971183391888394542 Inexact Rounded +comx3408 compare 465.351982159046525762715549761814 240444.975944666924657629172844780 -> -1 +divx3408 divide 465.351982159046525762715549761814 240444.975944666924657629172844780 -> 0.00193537827243326122782974132829095 Inexact Rounded +dvix3408 divideint 465.351982159046525762715549761814 240444.975944666924657629172844780 -> 0 +mulx3408 multiply 465.351982159046525762715549761814 240444.975944666924657629172844780 -> 111891546.156035013780371395668674 Inexact Rounded +powx3408 power 465.351982159046525762715549761814 240445 -> Infinity Overflow Inexact Rounded +remx3408 remainder 465.351982159046525762715549761814 240444.975944666924657629172844780 -> 465.351982159046525762715549761814 +subx3408 subtract 465.351982159046525762715549761814 240444.975944666924657629172844780 -> -239979.623962507878131866457295018 Inexact Rounded +addx3409 add 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> 28066955004783.1076824222873384828 Inexact Rounded +comx3409 compare 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> 1 +divx3409 divide 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> 4.90938543219432390013656968123815E+722 Inexact Rounded +dvix3409 divideint 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> NaN Division_impossible +mulx3409 multiply 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> 1.60458773123547770690452195569223E-696 Inexact Rounded +powx3409 power 28066955004783.1076824222873384828 6 -> 4.88845689938951583020171325568218E+80 Inexact Rounded +remx3409 remainder 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> NaN Division_impossible +subx3409 subtract 28066955004783.1076824222873384828 571699969.220753535758504907561016E-718 -> 28066955004783.1076824222873384828 Inexact Rounded +addx3410 add 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> 2.82120384825243127096613158419270E+429 Inexact Rounded +comx3410 compare 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> -1 +divx3410 divide 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> 1.00224012330435927467559203688861E-416 Inexact Rounded +dvix3410 divideint 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> 0 +mulx3410 multiply 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> 7.97702072298089605706798770013561E+442 Inexact Rounded +powx3410 power 28275236927392.4960902824105246047 3 -> 2.26057415546622161347322061281516E+40 Inexact Rounded +remx3410 remainder 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> 28275236927392.4960902824105246047 +subx3410 subtract 28275236927392.4960902824105246047 28212038.4825243127096613158419270E+422 -> -2.82120384825243127096613158419270E+429 Inexact Rounded +addx3411 add 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> 11783.4098484281593848173575655680 Inexact Rounded +comx3411 compare 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> 1 +divx3411 divide 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> -1394.73214754836418731335761858151 Inexact Rounded +dvix3411 divideint 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> -1394 +mulx3411 multiply 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> -99695.1757167732926302533138186716 Inexact Rounded +powx3411 power 11791.8644211874630234271801789996 -8 -> 2.67510099318723516565332928253711E-33 Inexact Rounded +remx3411 remainder 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> 6.18999471819080133445705535281046 +subx3411 subtract 11791.8644211874630234271801789996 -8.45457275930363860982261343159741 -> 11800.3189939467666620370027924312 Inexact Rounded +addx3412 add 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> -9292.34554725628103950730533220061 Inexact Rounded +comx3412 compare 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> 1 +divx3412 divide 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> -0.00478829121953512281527242631775613 Inexact Rounded +dvix3412 divideint 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> -0 +mulx3412 multiply 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> -417446.000545543168866158913077419 Inexact Rounded +powx3412 power 44.7085340739581668975502342787578 -9337 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3412 remainder 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> 44.7085340739581668975502342787578 +subx3412 subtract 44.7085340739581668975502342787578 -9337.05408133023920640485556647937 -> 9381.76261540419737330240580075813 Inexact Rounded +addx3413 add 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> 9.33545274288045458053295581965867E+589 Inexact Rounded +comx3413 compare 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> 1 +divx3413 divide 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> -1.08992064752484400353231056271614E+578 Inexact Rounded +dvix3413 divideint 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> NaN Division_impossible +mulx3413 multiply 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> -7.99605715447900642683774360731254E+601 Inexact Rounded +powx3413 power 93354527428804.5458053295581965867E+576 -9 -> 1.85687015691763406448005521221518E-5310 Inexact Rounded +remx3413 remainder 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> NaN Division_impossible +subx3413 subtract 93354527428804.5458053295581965867E+576 -856525909852.318790321300941615314 -> 9.33545274288045458053295581965867E+589 Inexact Rounded +addx3414 add -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> -367399415798804503177950095289166 Inexact Rounded +comx3414 compare -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> -1 +divx3414 divide -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> 6698784465980529140072174.30474769 Inexact Rounded +dvix3414 divideint -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> 6698784465980529140072174 +mulx3414 multiply -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> 2.01502722493617222018040789291414E+40 Inexact Rounded +powx3414 power -367399415798804503177950040443482 -54845684 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3414 remainder -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> -16714095.6549657189177857892292804 +subx3414 subtract -367399415798804503177950040443482 -54845683.9691776397285506712812754 -> -367399415798804503177949985597798 Inexact Rounded +addx3415 add -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> 89529730127.7712289354674386343440 Inexact Rounded +comx3415 compare -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -1 +divx3415 divide -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -3.20738060264454013174835928754430E-11 Inexact Rounded +dvix3415 divideint -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -0 +mulx3415 multiply -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -257089920034.115975469931085527642 Inexact Rounded +powx3415 power -2.87155919781024108503670175443740 9 -> -13275.7774683251354527310820885737 Inexact Rounded +remx3415 remainder -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -2.87155919781024108503670175443740 +subx3415 subtract -2.87155919781024108503670175443740 89529730130.6427881332776797193807 -> -89529730133.5143473310879208044174 Inexact Rounded +addx3416 add -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> -1.06939343381794796521780572792040E+189 Inexact Rounded +comx3416 compare -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> -1 +divx3416 divide -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> -4.03774938598259547575707503087638E+184 Inexact Rounded +dvix3416 divideint -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> NaN Division_impossible +mulx3416 multiply -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> -2.83227661494558963558481633880647E+193 Inexact Rounded +powx3416 power -010.693934338179479652178057279204E+188 26485 -> -Infinity Overflow Inexact Rounded +remx3416 remainder -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> NaN Division_impossible +subx3416 subtract -010.693934338179479652178057279204E+188 26484.8887731973153745666514260684 -> -1.06939343381794796521780572792040E+189 Inexact Rounded +addx3417 add 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 621838312788.308537943268041906168 +comx3417 compare 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 1 +divx3417 divide 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 60.0678575886074367081836436812959 Inexact Rounded +dvix3417 divideint 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 60 +mulx3417 multiply 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 6228331603681663511826.60450280350 Inexact Rounded +powx3417 power 611655569568.832698912762075889186 1 -> 611655569568.832698912762075889186 +remx3417 remainder 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 690976400.282357082404114870266 +subx3417 subtract 611655569568.832698912762075889186 010182743219.475839030505966016982 -> 601472826349.356859882256109872204 +addx3418 add 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> 3457945.39110674985794181949638944 Inexact Rounded +comx3418 compare 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> 1 +divx3418 divide 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> -1729387.11663991852426428263230475 Inexact Rounded +dvix3418 divideint 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> -1729387 +mulx3418 multiply 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> -6914241.49127918361259252956576654 Inexact Rounded +powx3418 power 3457947.39062863674882672518304442 -2 -> 8.36302195229701913376802373659526E-14 Inexact Rounded +remx3418 remainder 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> 0.2332240699744359979851713353525 +subx3418 subtract 3457947.39062863674882672518304442 -01.9995218868908849056866549811425 -> 3457949.39015052363971163086969940 Inexact Rounded +addx3419 add -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> -53308666960535.7393391289364591513 Inexact Rounded +comx3419 compare -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> -1 +divx3419 divide -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> 8.16740037282731870883136714441204E+451 Inexact Rounded +dvix3419 divideint -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> NaN Division_impossible +mulx3419 multiply -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> 3.47945961185390084641156250100085E-425 Inexact Rounded +powx3419 power -53308666960535.7393391289364591513 -7 -> -8.17363502380497033342380498988958E-97 Inexact Rounded +remx3419 remainder -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> NaN Division_impossible +subx3419 subtract -53308666960535.7393391289364591513 -6527.00547629475578694521436764596E-442 -> -53308666960535.7393391289364591513 Inexact Rounded +addx3420 add -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> -413474500.320043571235254629529038 Inexact Rounded +comx3420 compare -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> 1 +divx3420 divide -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> 0.0136503290701197094953429018013146 Inexact Rounded +dvix3420 divideint -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> 0 +mulx3420 multiply -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> 2271246398971702.91169807728132089 Inexact Rounded +powx3420 power -5568057.17870139549478277980540034 -407906443 -> -0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3420 remainder -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> -5568057.17870139549478277980540034 +subx3420 subtract -5568057.17870139549478277980540034 -407906443.141342175740471849723638 -> 402338385.962640780245689069918238 Inexact Rounded +addx3421 add 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 9804385357.63872821851861785530505 Inexact Rounded +comx3421 compare 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 1 +divx3421 divide 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 116519965.821719977402398190558439 Inexact Rounded +dvix3421 divideint 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 116519965 +mulx3421 multiply 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 824974242939.691780798621180901714 Inexact Rounded +powx3421 power 9804385273.49533524416415189990857 84 -> 1.90244010779692739037080418507909E+839 Inexact Rounded +remx3421 remainder 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 69.1423069734476624350435642749915 +subx3421 subtract 9804385273.49533524416415189990857 84.1433929743544659553964804646569 -> 9804385189.35194226980968594451209 Inexact Rounded +addx3422 add -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> -5874220715892.91440069210512515154 Inexact Rounded +comx3422 compare -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> 1 +divx3422 divide -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> 8.91166886601477021757439826903776E-548 Inexact Rounded +dvix3422 divideint -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> 0 +mulx3422 multiply -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> 3.07510225632952455144944282925583E-522 Inexact Rounded +powx3422 power -5234910986592.18801727046580014273E-547 -6 -> 4.85896970703117149235935037271084E+3205 Inexact Rounded +remx3422 remainder -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> -5.23491098659218801727046580014273E-535 +subx3422 subtract -5234910986592.18801727046580014273E-547 -5874220715892.91440069210512515154 -> 5874220715892.91440069210512515154 Inexact Rounded +addx3423 add 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> 5.17546816784872628933218985216916E-259 Inexact Rounded +comx3423 compare 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> -1 +divx3423 divide 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> 1.34947513442491971488363250398908E-204 Inexact Rounded +dvix3423 divideint 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> 0 +mulx3423 multiply 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> 3.61463267496484976064271305679796E-721 Inexact Rounded +powx3423 power 698416560151955285929747633786867E-495 5 -> 1.66177661007189430761396979787413E-2311 Inexact Rounded +remx3423 remainder 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> 6.98416560151955285929747633786867E-463 +subx3423 subtract 698416560151955285929747633786867E-495 51754681.6784872628933218985216916E-266 -> -5.17546816784872628933218985216916E-259 Inexact Rounded +addx3424 add 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> 107635.497735316515080720330536027 Inexact Rounded +comx3424 compare 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> 1 +divx3424 divide 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> -2.70980469844599888443309571235597E+603 Inexact Rounded +dvix3424 divideint 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> NaN Division_impossible +mulx3424 multiply 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> -4.27536360069537352698066408021773E-594 Inexact Rounded +powx3424 power 107635.497735316515080720330536027 -4 -> 7.45037111502910487803432806334714E-21 Inexact Rounded +remx3424 remainder 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> NaN Division_impossible +subx3424 subtract 107635.497735316515080720330536027 -3972075.83989512668362609609006425E-605 -> 107635.497735316515080720330536027 Inexact Rounded +addx3425 add -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> 7.95188637593855925052747867099091E+421 Inexact Rounded +comx3425 compare -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -1 +divx3425 divide -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -4.04612060894658007715621807881076E-409 Inexact Rounded +dvix3425 divideint -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -0 +mulx3425 multiply -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -2.55846309007242668513226814043593E+435 Inexact Rounded +powx3425 power -32174291345686.5371446616670961807 8 -> 1.14834377656109143210058690590666E+108 Inexact Rounded +remx3425 remainder -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -32174291345686.5371446616670961807 +subx3425 subtract -32174291345686.5371446616670961807 79518863759385.5925052747867099091E+408 -> -7.95188637593855925052747867099091E+421 Inexact Rounded +addx3426 add -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> -9.31730631474527142307644239919480E+904 Inexact Rounded +comx3426 compare -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> 1 +divx3426 divide -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> 8.74902060655796717043678441884283E-208 Inexact Rounded +dvix3426 divideint -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> 0 +mulx3426 multiply -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> 7.59521700128037149179751467730962E+1602 Inexact Rounded +powx3426 power -8151730494.53190523620899410544099E+688 -9 -> -6.29146352774842448375275282183700E-6282 Inexact Rounded +remx3426 remainder -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> -8.15173049453190523620899410544099E+697 +subx3426 subtract -8151730494.53190523620899410544099E+688 -93173.0631474527142307644239919480E+900 -> 9.31730631474527142307644239919480E+904 Inexact Rounded +addx3427 add 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> -5.66230530039528969825480755159562E+463 Inexact Rounded +comx3427 compare 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> 1 +divx3427 divide 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> -2.36034255052700900395787131334608E-464 Inexact Rounded +dvix3427 divideint 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> -0 +mulx3427 multiply 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> -7.56765978558098558928268129700052E+463 Inexact Rounded +powx3427 power 1.33649801345976199708341799505220 -6 -> 0.175464835912284900180305028965188 Inexact Rounded +remx3427 remainder 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> 1.33649801345976199708341799505220 +subx3427 subtract 1.33649801345976199708341799505220 -56623.0530039528969825480755159562E+459 -> 5.66230530039528969825480755159562E+463 Inexact Rounded +addx3428 add 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> 67762238162788.6551061476018185196 Inexact Rounded +comx3428 compare 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> 1 +divx3428 divide 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> -1.10348321777294157014941951870409E+832 Inexact Rounded +dvix3428 divideint 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> NaN Division_impossible +mulx3428 multiply 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> -4.16111531818085838717201828773857E-805 Inexact Rounded +powx3428 power 67762238162788.6551061476018185196 -6 -> 1.03293631708006509074972764670281E-83 Inexact Rounded +remx3428 remainder 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> NaN Division_impossible +subx3428 subtract 67762238162788.6551061476018185196 -6140.75837959248100352788853809376E-822 -> 67762238162788.6551061476018185196 Inexact Rounded +addx3429 add 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> 6.28677291578497580015557979349893E+823 Inexact Rounded +comx3429 compare 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> -1 +divx3429 divide 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> 6.81838333133660025740681459349372E-818 Inexact Rounded +dvix3429 divideint 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> 0 +mulx3429 multiply 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> 2.69486466971438542975159893306219E+830 Inexact Rounded +powx3429 power 4286562.76568866751577306056498271 6 -> 6.20376193064412081058181881805108E+39 Inexact Rounded +remx3429 remainder 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> 4286562.76568866751577306056498271 +subx3429 subtract 4286562.76568866751577306056498271 6286.77291578497580015557979349893E+820 -> -6.28677291578497580015557979349893E+823 Inexact Rounded +addx3430 add -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -765715.663995796739622174820554104 Inexact Rounded +comx3430 compare -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -1 +divx3430 divide -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -11401.7814363639478774761697650867 Inexact Rounded +dvix3430 divideint -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -11401 +mulx3430 multiply -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -51432606.5679912088468256122315944 Inexact Rounded +powx3430 power -765782.827432642697305644096365566 67 -> -1.71821200770749773595473594136582E+394 Inexact Rounded +remx3430 remainder -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -52.4839518791480724305698888408548 +subx3430 subtract -765782.827432642697305644096365566 67.1634368459576834692758114618652 -> -765849.990869488654989113372177028 Inexact Rounded +addx3431 add 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> 105.582516975019937108929234216907 Inexact Rounded +comx3431 compare 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> -1 +divx3431 divide 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> 0.780513207299722975882416995140701 Inexact Rounded +dvix3431 divideint 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> 0 +mulx3431 multiply 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> 2744.56726509164060561370653286614 Inexact Rounded +powx3431 power 46.2835931916106252756465724211276 59 -> 1.82052645780601002671007943923993E+98 Inexact Rounded +remx3431 remainder 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> 46.2835931916106252756465724211276 +subx3431 subtract 46.2835931916106252756465724211276 59.2989237834093118332826617957791 -> -13.0153305917986865576360893746515 +addx3432 add -3029555.82298840234029474459694644 857535844655004737373089601128532 -> 857535844655004737373089598098976 Inexact Rounded +comx3432 compare -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -1 +divx3432 divide -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -3.53286202771759704502126811323937E-27 Inexact Rounded +dvix3432 divideint -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -0 +mulx3432 multiply -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -2.59795271159584761928986181925721E+39 Inexact Rounded +powx3432 power -3029555.82298840234029474459694644 9 -> -2.14986224790431302561340100746360E+58 Inexact Rounded +remx3432 remainder -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -3029555.82298840234029474459694644 +subx3432 subtract -3029555.82298840234029474459694644 857535844655004737373089601128532 -> -857535844655004737373089604158088 Inexact Rounded +addx3433 add -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> 481026979918882487383654367924619 Inexact Rounded +comx3433 compare -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -1 +divx3433 divide -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -2.87856597038397207797777811199804E-970 Inexact Rounded +dvix3433 divideint -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -0 +mulx3433 multiply -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -6.66062615833636908683785283687416E-905 Inexact Rounded +powx3433 power -0138466789523.10694176543700501945E-948 5 -> -5.09012109092637525843636056746667E-4685 Inexact Rounded +remx3433 remainder -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -1.3846678952310694176543700501945E-937 +subx3433 subtract -0138466789523.10694176543700501945E-948 481026979918882487383654367924619 -> -481026979918882487383654367924619 Inexact Rounded +addx3434 add -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> -8.76320343474845477961976776833770E+779 Inexact Rounded +comx3434 compare -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> 1 +divx3434 divide -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> 1.09475564939253134070730299863765E-770 Inexact Rounded +dvix3434 divideint -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> 0 +mulx3434 multiply -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> 8.40703746148119867711463485065336E+789 Inexact Rounded +powx3434 power -9593566466.96690575714244442109870 -9 -> -1.45271091841882960010964421066745E-90 Inexact Rounded +remx3434 remainder -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> -9593566466.96690575714244442109870 +subx3434 subtract -9593566466.96690575714244442109870 -87632034347.4845477961976776833770E+769 -> 8.76320343474845477961976776833770E+779 Inexact Rounded +addx3435 add -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> 5.65688889355241946154894311253202E-458 Inexact Rounded +comx3435 compare -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -1 +divx3435 divide -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -5.63791814686655486612569970629128E-438 Inexact Rounded +dvix3435 divideint -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -0 +mulx3435 multiply -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -1.80415590504280580443565448126548E-1352 Inexact Rounded +powx3435 power -3189.30765477670526823106100241863E-898 6 -> 1.05239431027683904514311527228736E-5367 Inexact Rounded +remx3435 remainder -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -3.18930765477670526823106100241863E-895 +subx3435 subtract -3189.30765477670526823106100241863E-898 565688889.355241946154894311253202E-466 -> -5.65688889355241946154894311253202E-458 Inexact Rounded +addx3436 add -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> -6.31925802672685034379197328370812E+538 Inexact Rounded +comx3436 compare -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> 1 +divx3436 divide -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> 2.70356936263934622050341328519534E-529 Inexact Rounded +dvix3436 divideint -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> 0 +mulx3436 multiply -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> 1.07961694859382462346866817306769E+549 Inexact Rounded +powx3436 power -17084552395.6714834680088150543965 -6 -> 4.02141014977177984123011868387622E-62 Inexact Rounded +remx3436 remainder -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> -17084552395.6714834680088150543965 +subx3436 subtract -17084552395.6714834680088150543965 -631925802672.685034379197328370812E+527 -> 6.31925802672685034379197328370812E+538 Inexact Rounded +addx3437 add 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> 34956830.3498233068159118874697600 Inexact Rounded +comx3437 compare 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> 1 +divx3437 divide 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> -5.67473494371787737607169979602343E+666 Inexact Rounded +dvix3437 divideint 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> NaN Division_impossible +mulx3437 multiply 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> -2.15336927667273841617128781173293E-652 Inexact Rounded +powx3437 power 034956830.349823306815911887469760 -6 -> 5.48034272566098493462169431762597E-46 Inexact Rounded +remx3437 remainder 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> NaN Division_impossible +subx3437 subtract 034956830.349823306815911887469760 -61600816.0672274126966042956781665E-667 -> 34956830.3498233068159118874697600 Inexact Rounded +addx3438 add -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -743.513686646195531912469919819067 Inexact Rounded +comx3438 compare -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -1 +divx3438 divide -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -38.3130314835722766807703585435688 Inexact Rounded +dvix3438 divideint -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -38 +mulx3438 multiply -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -15212.5977643862002585039364868883 Inexact Rounded +powx3438 power -763.440067781256632695791981893608 20 -> 4.52375407727336769552481661250924E+57 Inexact Rounded +remx3438 remainder -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -6.2375846489348029295536230610386 +subx3438 subtract -763.440067781256632695791981893608 19.9263811350611007833220620745413 -> -783.366448916317733479114043968149 Inexact Rounded +addx3439 add -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> -5.10472027868440667684575147556654E+821 Inexact Rounded +comx3439 compare -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> -1 +divx3439 divide -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> -6.11437198047603754107526874071737E+788 Inexact Rounded +dvix3439 divideint -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> NaN Division_impossible +mulx3439 multiply -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> -4.26178996090176289115594057419892E+854 Inexact Rounded +powx3439 power -510472027868440667684575147556654E+789 8 -> 4.61079266619522147262600755274182E+6573 Inexact Rounded +remx3439 remainder -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> NaN Division_impossible +subx3439 subtract -510472027868440667684575147556654E+789 834872378550801889983927148587909 -> -5.10472027868440667684575147556654E+821 Inexact Rounded +addx3440 add 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> 7.03047615605170866769935030348280E-87 Inexact Rounded +comx3440 compare 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> 1 +divx3440 divide 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> -3.95554019499502537743883483402608E+670 Inexact Rounded +dvix3440 divideint 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> NaN Division_impossible +mulx3440 multiply 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> -1.24957888288817581538108991453732E-843 Inexact Rounded +powx3440 power 070304761.560517086676993503034828E-094 -2 -> 2.02316135427631488479902919959627E+172 Inexact Rounded +remx3440 remainder 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> NaN Division_impossible +subx3440 subtract 070304761.560517086676993503034828E-094 -17773.7446959771077104057845273992E-761 -> 7.03047615605170866769935030348280E-87 Inexact Rounded +addx3441 add -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> -970725702203.695030010334183533769 Inexact Rounded +comx3441 compare -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> -1 +divx3441 divide -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> 213749425.654447811698884007553614 Inexact Rounded +dvix3441 divideint -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> 213749425 +mulx3441 multiply -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> 4408472103336875.21161867891724392 Inexact Rounded +powx3441 power -0970725697662.27605454336231195463 -4541 -> -0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3441 remainder -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> -2972.12171050214753770792631747550 +subx3441 subtract -0970725697662.27605454336231195463 -4541.41897546697187157913886433474 -> -970725693120.857079076390440375491 Inexact Rounded +addx3442 add -808178238631844268316111259558675 -598400.265108644514211244980426520 -> -808178238631844268316111260157075 Inexact Rounded +comx3442 compare -808178238631844268316111259558675 -598400.265108644514211244980426520 -> -1 +divx3442 divide -808178238631844268316111259558675 -598400.265108644514211244980426520 -> 1350564640015847635178945884.97836 Inexact Rounded +dvix3442 divideint -808178238631844268316111259558675 -598400.265108644514211244980426520 -> 1350564640015847635178945884 +mulx3442 multiply -808178238631844268316111259558675 -598400.265108644514211244980426520 -> 4.83614072252332979731348423145208E+38 Inexact Rounded +powx3442 power -808178238631844268316111259558675 -598400 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3442 remainder -808178238631844268316111259558675 -598400.265108644514211244980426520 -> -585452.097764536570956813681556320 +subx3442 subtract -808178238631844268316111259558675 -598400.265108644514211244980426520 -> -808178238631844268316111258960275 Inexact Rounded +addx3443 add -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> -41.5341827319983835079860474697980 Rounded +comx3443 compare -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> 1 +divx3443 divide -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> 0.313295770023233218639213140599856 Inexact Rounded +dvix3443 divideint -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> 0 +mulx3443 multiply -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> 313.357994403604968250936036978086 Inexact Rounded +powx3443 power -9.90826595069053564311371766315200 -32 -> 1.34299698259038003011439568004625E-32 Inexact Rounded +remx3443 remainder -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> -9.90826595069053564311371766315200 +subx3443 subtract -9.90826595069053564311371766315200 -031.625916781307847864872329806646 -> 21.7176508306173122217586121434940 Rounded +addx3444 add -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> -238194.467436351098567470879626885 Inexact Rounded +comx3444 compare -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> -1 +divx3444 divide -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> 4.77175317088274715226553516820589 Inexact Rounded +dvix3444 divideint -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> 4 +mulx3444 multiply -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> 8126916733.40905487026003135987472 Inexact Rounded +powx3444 power -196925.469891897719160698483752907 -41269 -> -0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3444 remainder -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> -31849.4797140842015336089002569958 +subx3444 subtract -196925.469891897719160698483752907 -41268.9975444533794067723958739778 -> -155656.472347444339753926087878929 Inexact Rounded +addx3445 add 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> 421071135212152225162086005824310 Inexact Rounded +comx3445 compare 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> 1 +divx3445 divide 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> 3.15333426537349744281860005497304E+627 Inexact Rounded +dvix3445 divideint 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> NaN Division_impossible +mulx3445 multiply 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> 5.62264847262712040027311932121460E-563 Inexact Rounded +powx3445 power 421071135212152225162086005824310 1 -> 421071135212152225162086005824310 +remx3445 remainder 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> NaN Division_impossible +subx3445 subtract 421071135212152225162086005824310 1335320330.08964354845796510145246E-604 -> 421071135212152225162086005824310 Inexact Rounded +addx3446 add 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> 1249441.46421514282301182772247227 Inexact Rounded +comx3446 compare 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> 1 +divx3446 divide 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> -4.31066764178328992440635387255816E+676 Inexact Rounded +dvix3446 divideint 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> NaN Division_impossible +mulx3446 multiply 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> -3.62148999233506984566620611700349E-665 Inexact Rounded +powx3446 power 1249441.46421514282301182772247227 -3 -> 5.12686942572191282348415024932322E-19 Inexact Rounded +remx3446 remainder 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> NaN Division_impossible +subx3446 subtract 1249441.46421514282301182772247227 -0289848.71208912281976374705180836E-676 -> 1249441.46421514282301182772247227 Inexact Rounded +addx3447 add 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> -6.90425401708167622194241915195001E+923 Inexact Rounded +comx3447 compare 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> 1 +divx3447 divide 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> -1.08360729901578455109968388309079E-916 Inexact Rounded +dvix3447 divideint 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> -0 +mulx3447 multiply 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> -5.16541767544616308732028810026275E+931 Inexact Rounded +powx3447 power 74815000.4716875558358937279052903 -7 -> 7.62218032252683815537906972439985E-56 Inexact Rounded +remx3447 remainder 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> 74815000.4716875558358937279052903 +subx3447 subtract 74815000.4716875558358937279052903 -690425401708167622194241915195001E+891 -> 6.90425401708167622194241915195001E+923 Inexact Rounded +addx3448 add -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> -72394386611338.3523609383834372430 Inexact Rounded +comx3448 compare -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> 1 +divx3448 divide -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> 2.32613829621244113284301004158794E-8 Inexact Rounded +dvix3448 divideint -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> 0 +mulx3448 multiply -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> 121911674530293613615.441384822381 Inexact Rounded +powx3448 power -1683993.51210241555668790556759021 -7 -> -2.60385683509956889000676113860292E-44 Inexact Rounded +remx3448 remainder -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> -1683993.51210241555668790556759021 +subx3448 subtract -1683993.51210241555668790556759021 -72394384927344.8402585228267493374 -> 72394383243351.3281561072700614318 Inexact Rounded +addx3449 add -763.148530974741766171756970448158 517370.808956957601473642272664647 -> 516607.660425982859707470515694199 Inexact Rounded +comx3449 compare -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -1 +divx3449 divide -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -0.00147505139014951946381155525173867 Inexact Rounded +dvix3449 divideint -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -0 +mulx3449 multiply -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -394830772.824715962925351447322187 Inexact Rounded +powx3449 power -763.148530974741766171756970448158 517371 -> -Infinity Overflow Inexact Rounded +remx3449 remainder -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -763.148530974741766171756970448158 +subx3449 subtract -763.148530974741766171756970448158 517370.808956957601473642272664647 -> -518133.957487932343239814029635095 Inexact Rounded +addx3450 add -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> -9.27540422641025050968830154578151E+532 Inexact Rounded +comx3450 compare -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> 1 +divx3450 divide -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> 8.36450164191471769978415758342237E-532 Inexact Rounded +dvix3450 divideint -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> 0 +mulx3450 multiply -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> 7.19624203304351070562409746475943E+534 Inexact Rounded +powx3450 power -77.5841338812312523460591226178754 -9 -> -9.81846856873938549466341693997829E-18 Inexact Rounded +remx3450 remainder -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> -77.5841338812312523460591226178754 +subx3450 subtract -77.5841338812312523460591226178754 -927540422.641025050968830154578151E+524 -> 9.27540422641025050968830154578151E+532 Inexact Rounded +addx3451 add 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> 5176165576.79580866488385418967956 Inexact Rounded +comx3451 compare 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> 1 +divx3451 divide 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> -39899.5720067736855444089432524094 Inexact Rounded +dvix3451 divideint 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> -39899 +mulx3451 multiply 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> -671536855852442.071887385512001794 Inexact Rounded +powx3451 power 5176295309.89943746236102209837813 -129733 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3451 remainder 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> 74208.214046920838632934314641965 +subx3451 subtract 5176295309.89943746236102209837813 -129733.103628797477167908698565465 -> 5176425043.00306625983819000707670 Inexact Rounded +addx3452 add 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> 4.47163484116690197229286530307326E+184 Inexact Rounded +comx3452 compare 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> 1 +divx3452 divide 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> 1.41906636616314987705536737025932E+1129 Inexact Rounded +dvix3452 divideint 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> NaN Division_impossible +mulx3452 multiply 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> 1.40906152309150441010046222214810E-760 Inexact Rounded +powx3452 power 4471634841166.90197229286530307326E+172 3 -> 8.94126556389673498386397569249516E+553 Inexact Rounded +remx3452 remainder 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> NaN Division_impossible +subx3452 subtract 4471634841166.90197229286530307326E+172 31511104397.8671727003201890825879E-955 -> 4.47163484116690197229286530307326E+184 Inexact Rounded +addx3453 add -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> -8189130.15945231049670285726774317 Inexact Rounded +comx3453 compare -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> -1 +divx3453 divide -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> -3.17515949922556778343526099830093E+372 Inexact Rounded +dvix3453 divideint -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> NaN Division_impossible +mulx3453 multiply -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> -2.11207823685103185039979144161848E-359 Inexact Rounded +powx3453 power -8189130.15945231049670285726774317 3 -> -549178241054875982731.000937875885 Inexact Rounded +remx3453 remainder -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> NaN Division_impossible +subx3453 subtract -8189130.15945231049670285726774317 2.57912402871404325831670923864936E-366 -> -8189130.15945231049670285726774317 Inexact Rounded +addx3454 add -254346232981353293392888785643245 -764.416902486152093758287929678445 -> -254346232981353293392888785644009 Inexact Rounded +comx3454 compare -254346232981353293392888785643245 -764.416902486152093758287929678445 -> -1 +divx3454 divide -254346232981353293392888785643245 -764.416902486152093758287929678445 -> 332732350833857889204406356900.665 Inexact Rounded +dvix3454 divideint -254346232981353293392888785643245 -764.416902486152093758287929678445 -> 332732350833857889204406356900 +mulx3454 multiply -254346232981353293392888785643245 -764.416902486152093758287929678445 -> 1.94426559574627262006307326336289E+35 Inexact Rounded +powx3454 power -254346232981353293392888785643245 -764 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3454 remainder -254346232981353293392888785643245 -764.416902486152093758287929678445 -> -508.299323962538610580669092979500 +subx3454 subtract -254346232981353293392888785643245 -764.416902486152093758287929678445 -> -254346232981353293392888785642481 Inexact Rounded +addx3455 add -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> -16063.2166595009220002171676000611 Inexact Rounded +comx3455 compare -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> 1 +divx3455 divide -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> 0.218031569091122520391599541575615 Inexact Rounded +dvix3455 divideint -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> 0 +mulx3455 multiply -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> 37919912.4040225840727281633024665 Inexact Rounded +powx3455 power -2875.36745499544177964804277329726 -13188 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3455 remainder -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> -2875.36745499544177964804277329726 +subx3455 subtract -2875.36745499544177964804277329726 -13187.8492045054802205691248267638 -> 10312.4817495100384409210820534665 Inexact Rounded +addx3456 add -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> -7.26927570984219944693602140223103 Inexact Rounded +comx3456 compare -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> -1 +divx3456 divide -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> -4.51836100553039917574557235275173E+427 Inexact Rounded +dvix3456 divideint -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> NaN Division_impossible +mulx3456 multiply -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> -1.16950304061635681891361504442479E-426 Inexact Rounded +powx3456 power -7.26927570984219944693602140223103 2 -> 52.8423693457018126451998096211036 Inexact Rounded +remx3456 remainder -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> NaN Division_impossible +subx3456 subtract -7.26927570984219944693602140223103 0160883021541.32275286769110003971E-438 -> -7.26927570984219944693602140223103 Inexact Rounded +addx3457 add -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> -2.85671516868762752241056540028515E+505 Inexact Rounded +comx3457 compare -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> -1 +divx3457 divide -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> 6.39064071690455919792707589054106E+501 Inexact Rounded +dvix3457 divideint -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> NaN Division_impossible +mulx3457 multiply -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> 1.27699583132923253605397736797000E+509 Inexact Rounded +powx3457 power -28567151.6868762752241056540028515E+498 -4470 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3457 remainder -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> NaN Division_impossible +subx3457 subtract -28567151.6868762752241056540028515E+498 -4470.15455137546427645290210989675 -> -2.85671516868762752241056540028515E+505 Inexact Rounded +addx3458 add 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 7191835.18758398207642347765831492 Inexact Rounded +comx3458 compare 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 1 +divx3458 divide 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 88363.9812586188186733935569874100 Inexact Rounded +dvix3458 divideint 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 88363 +mulx3458 multiply 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 585321326.397904638863485891524555 Inexact Rounded +powx3458 power 7191753.79974136447257468282073718 81 -> 2.53290983138561482612557404148760E+555 Inexact Rounded +remx3458 remainder 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 79.8625220355815164499390351500273 +subx3458 subtract 7191753.79974136447257468282073718 81.3878426176038487948375777384429 -> 7191672.41189874686872588798315944 Inexact Rounded +addx3459 add 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 502976488.859892968179149660674285 Inexact Rounded +comx3459 compare 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 1 +divx3459 divide 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 734496.390406706323899801641278933 Inexact Rounded +dvix3459 divideint 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 734496 +mulx3459 multiply 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 344432815169.648082754214631086270 Inexact Rounded +powx3459 power 502975804.069864536104621700404770 685 -> 3.62876716573623552761739177592677E+5960 Inexact Rounded +remx3459 remainder 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 267.346619523615915582548420925472 +subx3459 subtract 502975804.069864536104621700404770 684.790028432074527960269515227243 -> 502975119.279836104030093740135255 Inexact Rounded +addx3460 add 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> 1040125.74219736715313697451377660 Inexact Rounded +comx3460 compare 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> 1 +divx3460 divide 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> -3.23566278503319947059213001405065 Inexact Rounded +dvix3460 divideint 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> -3 +mulx3460 multiply 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> -700361636056.225618266296899048765 Inexact Rounded +powx3460 power 1505368.42063731861590460453659570 -465243 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3460 remainder 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> 109640.385317464227601714468138385 +subx3460 subtract 1505368.42063731861590460453659570 -465242.678439951462767630022819105 -> 1970611.09907727007867223455941481 Inexact Rounded +addx3461 add 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 77809073.3514961963946898136677398 Inexact Rounded +comx3461 compare 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 1 +divx3461 divide 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 8.06437785764050431295652411163382 Inexact Rounded +dvix3461 divideint 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 8 +mulx3461 multiply 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 594231065731939.137329770485497261 Inexact Rounded +powx3461 power 69225023.2850142784063416137144829 8584050 -> Infinity Overflow Inexact Rounded +remx3461 remainder 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 552622.75315893449955601408842746 +subx3461 subtract 69225023.2850142784063416137144829 8584050.06648191798834819995325693 -> 60640973.2185323604179934137612260 Inexact Rounded +addx3462 add -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> -5.56695018537751006841940471339310E+624 Inexact Rounded +comx3462 compare -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> -1 +divx3462 divide -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> -9.06661464189378059067792554300676E+616 Inexact Rounded +dvix3462 divideint -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> NaN Division_impossible +mulx3462 multiply -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> -3.41813737437080390787865389703565E+632 Inexact Rounded +powx3462 power -55669501853.7751006841940471339310E+614 61400538 -> Infinity Overflow Inexact Rounded +remx3462 remainder -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> NaN Division_impossible +subx3462 subtract -55669501853.7751006841940471339310E+614 061400538.186044693233816566977189 -> -5.56695018537751006841940471339310E+624 Inexact Rounded +addx3463 add -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> -834662.599983953345718523807123972 Inexact Rounded +comx3463 compare -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> 1 +divx3463 divide -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> 6.32071595497552015656909892339226E-409 Inexact Rounded +dvix3463 divideint -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> 0 +mulx3463 multiply -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> 4.40340044311040151960763108019957E-397 Inexact Rounded +powx3463 power -527566.521273992424649346837337602E-408 -834663 -> -Infinity Overflow Inexact Rounded +remx3463 remainder -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> -5.27566521273992424649346837337602E-403 +subx3463 subtract -527566.521273992424649346837337602E-408 -834662.599983953345718523807123972 -> 834662.599983953345718523807123972 Inexact Rounded +addx3464 add 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> 69065510.0459653699418083455335366 Inexact Rounded +comx3464 compare 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> 1 +divx3464 divide 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> 9.93964810285396646889830919492683E+827 Inexact Rounded +dvix3464 divideint 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> NaN Division_impossible +mulx3464 multiply 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> 4.79900759921241352562381181332720E-813 Inexact Rounded +powx3464 power 69065510.0459653699418083455335366 7 -> 7.49598249763416483824919118973567E+54 Inexact Rounded +remx3464 remainder 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> NaN Division_impossible +subx3464 subtract 69065510.0459653699418083455335366 694848643848212520086960886818157E-853 -> 69065510.0459653699418083455335366 Inexact Rounded +addx3465 add -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> -2921982.82411285505229122890041841 Inexact Rounded +comx3465 compare -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> -1 +divx3465 divide -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> 4.00300943792444663467732029501716E+764 Inexact Rounded +dvix3465 divideint -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> NaN Division_impossible +mulx3465 multiply -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> 2.13289120518223547921212412642411E-752 Inexact Rounded +powx3465 power -2921982.82411285505229122890041841 -7 -> -5.49865394870631248479668782154131E-46 Inexact Rounded +remx3465 remainder -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> NaN Division_impossible +subx3465 subtract -2921982.82411285505229122890041841 -72994.6523840298017471962569778803E-763 -> -2921982.82411285505229122890041841 Inexact Rounded +addx3466 add 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> 3873389.71099271106554595739922987 Inexact Rounded +comx3466 compare 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> -1 +divx3466 divide 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> 0.00000116465942888322776753062580106351 Inexact Rounded +dvix3466 divideint 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> 0 +mulx3466 multiply 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> 17473516.9087705701652062546164705 Inexact Rounded +powx3466 power 4.51117459466491451401835756593793 3873385 -> Infinity Overflow Inexact Rounded +remx3466 remainder 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> 4.51117459466491451401835756593793 +subx3466 subtract 4.51117459466491451401835756593793 3873385.19981811640063144338087230 -> -3873380.68864352173571692936251473 Inexact Rounded +addx3467 add 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> 3.61713861293896216593840817950781E+411 Inexact Rounded +comx3467 compare 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> -1 +divx3467 divide 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> 1.36997137177543416190811827685231E-398 Inexact Rounded +dvix3467 divideint 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> 0 +mulx3467 multiply 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> 1.79242831280777466554271332425735E+425 Inexact Rounded +powx3467 power 49553763474698.8118661758811091120 4 -> 6.02985091099730236635954801474802E+54 Inexact Rounded +remx3467 remainder 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> 49553763474698.8118661758811091120 +subx3467 subtract 49553763474698.8118661758811091120 36.1713861293896216593840817950781E+410 -> -3.61713861293896216593840817950781E+411 Inexact Rounded +addx3468 add 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> 7.55985583344379951506071499170749E+967 Inexact Rounded +comx3468 compare 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> 1 +divx3468 divide 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> 1.01213580367212873025671916758669E+935 Inexact Rounded +dvix3468 divideint 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> NaN Division_impossible +mulx3468 multiply 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> 5.64661580146688255286933753616580E+1000 Inexact Rounded +powx3468 power 755985583344.379951506071499170749E+956 7 -> 1.41121958516547725677142981375469E+6775 Inexact Rounded +remx3468 remainder 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> NaN Division_impossible +subx3468 subtract 755985583344.379951506071499170749E+956 746921095569971477373643487285780 -> 7.55985583344379951506071499170749E+967 Inexact Rounded +addx3469 add -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> -20497230690.0922299809209551116556 Inexact Rounded +comx3469 compare -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> -1 +divx3469 divide -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> 50.8179779735012053661447873666816 Inexact Rounded +dvix3469 divideint -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> 50 +mulx3469 multiply -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> 7951459193692715079.09328760016914 Inexact Rounded +powx3469 power -20101668541.7472260497594230105456 -395562148 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3469 remainder -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> -323561124.497029491682817955047400 +subx3469 subtract -20101668541.7472260497594230105456 -395562148.345003931161532101109964 -> -19706106393.4022221185978909094356 Inexact Rounded +addx3470 add 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> 460874498597.269108074612032613370 Inexact Rounded +comx3470 compare 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> -1 +divx3470 divide 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> 0.0000121160334374633240168068405467307 Inexact Rounded +dvix3470 divideint 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> 0 +mulx3470 multiply 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> 2573447398655758659.39475672905225 Inexact Rounded +powx3470 power 5583903.18072100716072011264668631 5 -> 5.42861943589418603298670454702901E+33 Inexact Rounded +remx3470 remainder 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> 5583903.18072100716072011264668631 +subx3470 subtract 5583903.18072100716072011264668631 460868914694.088387067451312500723 -> -460863330790.907666060290592388076 Inexact Rounded +addx3471 add -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> -5.08580148958769104511751975720470E+667 Inexact Rounded +comx3471 compare -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> 1 +divx3471 divide -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> 1.87903204624039476408191264564568E-615 Inexact Rounded +dvix3471 divideint -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> 0 +mulx3471 multiply -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> 4.86018718792967378985838739820108E+720 Inexact Rounded +powx3471 power -955638397975240685017992436116257E+020 -5 -> -1.25467730420304189161768408462414E-265 Inexact Rounded +remx3471 remainder -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> -9.55638397975240685017992436116257E+52 +subx3471 subtract -955638397975240685017992436116257E+020 -508580.148958769104511751975720470E+662 -> 5.08580148958769104511751975720470E+667 Inexact Rounded +addx3472 add -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> -1.36243796098020983814115584402407E+828 Inexact Rounded +comx3472 compare -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> -1 +divx3472 divide -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> -2.06771226638255600634939371365920E+818 Inexact Rounded +dvix3472 divideint -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> NaN Division_impossible +mulx3472 multiply -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> -8.97725098263977535966921696143011E+837 Inexact Rounded +powx3472 power -136243796098020983814115584402407E+796 7 -> -8.71399185551742199752832286984005E+5796 Inexact Rounded +remx3472 remainder -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> NaN Division_impossible +subx3472 subtract -136243796098020983814115584402407E+796 6589108083.99750311651581032447390 -> -1.36243796098020983814115584402407E+828 Inexact Rounded +addx3473 add -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> -8.08498482718304598213092937543934E+526 Inexact Rounded +comx3473 compare -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> -1 +divx3473 divide -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> -1.68419126177106468565397017107736E+522 Inexact Rounded +dvix3473 divideint -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> NaN Division_impossible +mulx3473 multiply -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> -3.88120881158362912220132691803539E+531 Inexact Rounded +powx3473 power -808498.482718304598213092937543934E+521 48005 -> -Infinity Overflow Inexact Rounded +remx3473 remainder -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> NaN Division_impossible +subx3473 subtract -808498.482718304598213092937543934E+521 48005.1465097914355096301483788905 -> -8.08498482718304598213092937543934E+526 Inexact Rounded +addx3474 add -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> -3.19563111559114001594257448970812E+989 Inexact Rounded +comx3474 compare -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> 1 +divx3474 divide -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> 2.54180257724779721448484781056040E-591 Inexact Rounded +dvix3474 divideint -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> 0 +mulx3474 multiply -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> 2.59570359202261082537505332325404E+1388 Inexact Rounded +powx3474 power -812.266340554281305985524813074211E+396 -3 -> -1.86596988030914616216741808216469E-1197 Inexact Rounded +remx3474 remainder -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> -8.12266340554281305985524813074211E+398 +subx3474 subtract -812.266340554281305985524813074211E+396 -3195.63111559114001594257448970812E+986 -> 3.19563111559114001594257448970812E+989 Inexact Rounded +addx3475 add -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> -9.29889720905183397678866648217793E+139 Inexact Rounded +comx3475 compare -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> -1 +divx3475 divide -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> 3.31747801646964399331556971055197E+128 Inexact Rounded +dvix3475 divideint -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> NaN Division_impossible +mulx3475 multiply -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> 2.60648266168558079957349074609920E+151 Inexact Rounded +powx3475 power -929889.720905183397678866648217793E+134 -3 -> -1.24367143370300189518778505830181E-420 Inexact Rounded +remx3475 remainder -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> NaN Division_impossible +subx3475 subtract -929889.720905183397678866648217793E+134 -280300190774.057595671079264841349 -> -9.29889720905183397678866648217793E+139 Inexact Rounded +addx3476 add 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> 492754319.251171861122327008214092 Inexact Rounded +comx3476 compare 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> -1 +divx3476 divide 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> 0.000170389819117633485695890041185782 Inexact Rounded +dvix3476 divideint 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> 0 +mulx3476 multiply 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> 41357714926052.9282985560380064649 Inexact Rounded +powx3476 power 83946.0157801953636255078996185540 492670373 -> Infinity Overflow Inexact Rounded +remx3476 remainder 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> 83946.0157801953636255078996185540 +subx3476 subtract 83946.0157801953636255078996185540 492670373.235391665758701500314473 -> -492586427.219611470395075992414854 Inexact Rounded +addx3477 add 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> 7812758113817.99135851825223122508 Inexact Rounded +comx3477 compare 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> 1 +divx3477 divide 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> 2.57210790001590171809512871857381E+163 Inexact Rounded +dvix3477 divideint 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> NaN Division_impossible +mulx3477 multiply 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> 2.37311931372130583136091717093935E-138 Inexact Rounded +powx3477 power 7812758113817.99135851825223122508 3 -> 4.76884421816246896090414314934253E+38 Inexact Rounded +remx3477 remainder 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> NaN Division_impossible +subx3477 subtract 7812758113817.99135851825223122508 3037492.36716301443309571918002123E-157 -> 7812758113817.99135851825223122508 Inexact Rounded +addx3478 add 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 490328689.266902084767070133475071 Inexact Rounded +comx3478 compare 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 1 +divx3478 divide 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 430.269702657525223124148258641358 Inexact Rounded +dvix3478 divideint 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 430 +mulx3478 multiply 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 556182701222751.588454129518830550 Inexact Rounded +powx3478 power 489191747.148674326757767356626016 1136942 -> Infinity Overflow Inexact Rounded +remx3478 remainder 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 306636.3107383827575733115325810 +subx3478 subtract 489191747.148674326757767356626016 01136942.1182277580093027768490545 -> 488054805.030446568748464579776962 Inexact Rounded +addx3479 add -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> -5.99369540373174482335865567937853E+297 Inexact Rounded +comx3479 compare -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> -1 +divx3479 divide -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> 1.56540833065089684132688143737586E+287 Inexact Rounded +dvix3479 divideint -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> NaN Division_impossible +mulx3479 multiply -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> 2.29488906436173641324091638963715E+308 Inexact Rounded +powx3479 power -599369540.373174482335865567937853E+289 -4 -> 7.74856580646291366270329165540958E-1192 Inexact Rounded +remx3479 remainder -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> NaN Division_impossible +subx3479 subtract -599369540.373174482335865567937853E+289 -38288383205.6749439588707955585209 -> -5.99369540373174482335865567937853E+297 Inexact Rounded +addx3480 add -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> -68624373320.5930758945974232604298 Inexact Rounded +comx3480 compare -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> 1 +divx3480 divide -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> 0.0517550008335747813596332404664731 Inexact Rounded +dvix3480 divideint -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> 0 +mulx3480 multiply -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> 220333194736887939420.719579906257 Inexact Rounded +powx3480 power -3376883870.85961692148022521960139 -7 -> -1.99704163718361153125735756179280E-67 Inexact Rounded +remx3480 remainder -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> -3376883870.85961692148022521960139 +subx3480 subtract -3376883870.85961692148022521960139 -65247489449.7334589731171980408284 -> 61870605578.8738420516369728212270 Inexact Rounded +addx3481 add 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 60.2702299236537409084931002396185 +comx3481 compare 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 1 +divx3481 divide 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 36.8450651616286048437498576613622 Inexact Rounded +dvix3481 divideint 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 36 +mulx3481 multiply 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 93.4472468622373769590900258060029 Inexact Rounded +powx3481 power 58.6776780370008364590621772421025 2 -> 3443.06989981393033632008313505230 Inexact Rounded +remx3481 remainder 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 1.3458101174962762795489493315265 +subx3481 subtract 58.6776780370008364590621772421025 01.5925518866529044494309229975160 -> 57.0851261503479320096312542445865 +addx3482 add 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 4099616630.75768235660057557396732 Inexact Rounded +comx3482 compare 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 1 +divx3482 divide 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 14097951.1289920788134209002390834 Inexact Rounded +dvix3482 divideint 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 14097951 +mulx3482 multiply 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 1192148701687.90798437501397900174 Inexact Rounded +powx3482 power 4099616339.96249499552808575717579 291 -> 2.03364757877800497409765979877258E+2797 Inexact Rounded +remx3482 remainder 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 37.510275726642959858538282144855 +subx3482 subtract 4099616339.96249499552808575717579 290.795187361072489816791525139895 -> 4099616049.16730763445559594038426 Inexact Rounded +addx3483 add 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> -2140306990376.46573014981378406578 Inexact Rounded +comx3483 compare 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> 1 +divx3483 divide 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> -0.0000401191663393971853092748263233128 Inexact Rounded +dvix3483 divideint 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> -0 +mulx3483 multiply 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> -183797198561136797328.508878254848 Inexact Rounded +powx3483 power 85870777.2282833141709970713739108 -2 -> 1.35615463448707573424578785973269E-16 Inexact Rounded +remx3483 remainder 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> 85870777.2282833141709970713739108 +subx3483 subtract 85870777.2282833141709970713739108 -2140392861153.69401346398478113715 -> 2140478731930.92229677815577820852 Inexact Rounded +addx3484 add 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> 20862.2147613905641948547078989489 Inexact Rounded +comx3484 compare 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> 1 +divx3484 divide 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> -539.315627388386430188627412639767 Inexact Rounded +dvix3484 divideint 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> -539 +mulx3484 multiply 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> -810009.016386974103738622793670566 Inexact Rounded +powx3484 power 20900.9693761555165742010339929779 -39 -> 3.26219014701526335296044439989665E-169 Inexact Rounded +remx3484 remainder 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> 12.2320178461841065312693113692685 +subx3484 subtract 20900.9693761555165742010339929779 -38.7546147649523793463260940289585 -> 20939.7239909204689535473600870069 Inexact Rounded +addx3485 add 448.827596155587910947511170319456 379130153.382794042652974596286062 -> 379130602.210390198240885543797232 Inexact Rounded +comx3485 compare 448.827596155587910947511170319456 379130153.382794042652974596286062 -> -1 +divx3485 divide 448.827596155587910947511170319456 379130153.382794042652974596286062 -> 0.00000118383513458615061394140895596979 Inexact Rounded +dvix3485 divideint 448.827596155587910947511170319456 379130153.382794042652974596286062 -> 0 +mulx3485 multiply 448.827596155587910947511170319456 379130153.382794042652974596286062 -> 170164075372.898786469094460692097 Inexact Rounded +powx3485 power 448.827596155587910947511170319456 379130153 -> Infinity Overflow Inexact Rounded +remx3485 remainder 448.827596155587910947511170319456 379130153.382794042652974596286062 -> 448.827596155587910947511170319456 +subx3485 subtract 448.827596155587910947511170319456 379130153.382794042652974596286062 -> -379129704.555197887065063648774892 Inexact Rounded +addx3486 add 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> 3404725642.18381024654682525116780 Inexact Rounded +comx3486 compare 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> -1 +divx3486 divide 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> 2.89049673833970863420201979291523E-8 Inexact Rounded +dvix3486 divideint 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> 0 +mulx3486 multiply 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> 335070891904.214504811798212040413 Inexact Rounded +powx3486 power 98.4134807921002817357000140482039 3 -> 953155.543384739667965055839894682 Inexact Rounded +remx3486 remainder 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> 98.4134807921002817357000140482039 +subx3486 subtract 98.4134807921002817357000140482039 3404725543.77032945444654351546779 -> -3404725445.35684866234626177976778 Inexact Rounded +addx3487 add 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> -5.14995709970912830072802043560650E-425 Inexact Rounded +comx3487 compare 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> 1 +divx3487 divide 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> -1.05971064046375011086850722752614E-354 Inexact Rounded +dvix3487 divideint 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> -0 +mulx3487 multiply 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> -2.81057072061345688074304873033317E-1203 Inexact Rounded +powx3487 power 545746433.649359734136476718176330E-787 -5 -> 2.06559640092667166976186801348662E+3891 Inexact Rounded +remx3487 remainder 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> 5.45746433649359734136476718176330E-779 +subx3487 subtract 545746433.649359734136476718176330E-787 -5149957099709.12830072802043560650E-437 -> 5.14995709970912830072802043560650E-425 Inexact Rounded +addx3488 add 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> 741304513547.273820525801608231737 Inexact Rounded +comx3488 compare 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> 1 +divx3488 divide 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> 1.87090281565101612623398174727653E+839 Inexact Rounded +dvix3488 divideint 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> NaN Division_impossible +mulx3488 multiply 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> 2.93725776244737788947443361076095E-816 Inexact Rounded +powx3488 power 741304513547.273820525801608231737 4 -> 3.01985838652892073903194846668712E+47 Inexact Rounded +remx3488 remainder 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> NaN Division_impossible +subx3488 subtract 741304513547.273820525801608231737 0396.22823128272584928019323186355E-830 -> 741304513547.273820525801608231737 Inexact Rounded +addx3489 add -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> 4033.67985686310526747345220908179 Inexact Rounded +comx3489 compare -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -1 +divx3489 divide -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -0.148981244172527671907534117771626 Inexact Rounded +dvix3489 divideint -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -0 +mulx3489 multiply -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -3347003.65129295988793454267973464 Inexact Rounded +powx3489 power -706.145005094292315613907254240553 4740 -> Infinity Overflow Inexact Rounded +remx3489 remainder -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -706.145005094292315613907254240553 +subx3489 subtract -706.145005094292315613907254240553 4739.82486195739758308735946332234 -> -5445.96986705168989870126671756289 Inexact Rounded +addx3490 add -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> -769956988.821146059252782194757952 Inexact Rounded +comx3490 compare -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> -1 +divx3490 divide -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> 24675.5283319978698932292028650803 Inexact Rounded +dvix3490 divideint -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> 24675 +mulx3490 multiply -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> 24023222896770.8161787236737395477 Inexact Rounded +powx3490 power -769925786.823099083228795187975893 -31202 -> 0E-10031 Underflow Subnormal Inexact Rounded Clamped +remx3490 remainder -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> -16485.0139656913494028406582486750 +subx3490 subtract -769925786.823099083228795187975893 -31201.9980469760239870067820594790 -> -769894584.825052107204808181193834 Inexact Rounded +addx3491 add 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> 8.44386105460497256507419289692857E+919 Inexact Rounded +comx3491 compare 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> 1 +divx3491 divide 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> 1.60516736512701978695559003341922E+888 Inexact Rounded +dvix3491 divideint 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> NaN Division_impossible +mulx3491 multiply 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> 4.44182899917309231779837668210610E+951 Inexact Rounded +powx3491 power 84438610546049.7256507419289692857E+906 5 -> 4.29245144719689283247342866988213E+4599 Inexact Rounded +remx3491 remainder 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> NaN Division_impossible +subx3491 subtract 84438610546049.7256507419289692857E+906 052604240766736461898844111790311 -> 8.44386105460497256507419289692857E+919 Inexact Rounded +addx3492 add 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 549926.071394341400088797374170467 Inexact Rounded +comx3492 compare 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 1 +divx3492 divide 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 3328.65471667062107598395714348089 Inexact Rounded +dvix3492 divideint 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 3328 +mulx3492 multiply 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 90798561.3782451425861113694732484 Inexact Rounded +powx3492 power 549760.911304725795164589619286514 165 -> 1.34488925442386544028875603347654E+947 Inexact Rounded +remx3492 remainder 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 108.133063992607401181365489319248 +subx3492 subtract 549760.911304725795164589619286514 165.160089615604924207754883953484 -> 549595.751215110190240381864402561 Inexact Rounded +addx3493 add 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> 11737235.5901860743933857728701908 Inexact Rounded +comx3493 compare 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> -1 +divx3493 divide 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> 0.451420792712387250865423208234291 Inexact Rounded +dvix3493 divideint 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> 0 +mulx3493 multiply 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> 29520691206417.5831886752808745421 Inexact Rounded +powx3493 power 3650514.18649737956855828939662794 8086721 -> Infinity Overflow Inexact Rounded +remx3493 remainder 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> 3650514.18649737956855828939662794 +subx3493 subtract 3650514.18649737956855828939662794 08086721.4036886948248274834735629 -> -4436207.21719131525626919407693496 +addx3494 add 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> 55067723881941.2298810010885806451 Inexact Rounded +comx3494 compare 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> 1 +divx3494 divide 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> -6184039198391.19853088419484117054 Inexact Rounded +dvix3494 divideint 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> -6184039198391 +mulx3494 multiply 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> -490367883555396.250365158593373279 Inexact Rounded +powx3494 power 55067723881950.1346958179604099594 -9 -> 2.14746386538529270173788457887121E-124 Inexact Rounded +remx3494 remainder 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> 1.76788075918488693086347720461547 +subx3494 subtract 55067723881950.1346958179604099594 -8.90481481687182931431054785192083 -> 55067723881959.0395106348322392737 Inexact Rounded +addx3495 add 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> 5.57966504537858308541154858567656E+140 Inexact Rounded +comx3495 compare 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> -1 +divx3495 divide 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> 1.55609900657590706155251902725027E-113 Inexact Rounded +dvix3495 divideint 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> 0 +mulx3495 multiply 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> 4.84455044392374106106966779322483E+168 Inexact Rounded +powx3495 power 868251123.413992653362860637541060E+019 6 -> 4.28422354304291884802690733853227E+167 Inexact Rounded +remx3495 remainder 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> 8682511234139926533628606375.41060 +subx3495 subtract 868251123.413992653362860637541060E+019 5579665045.37858308541154858567656E+131 -> -5.57966504537858308541154858567656E+140 Inexact Rounded +addx3496 add -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> -646.464431574014407536004990059069 Inexact Rounded +comx3496 compare -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> -1 +divx3496 divide -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> 8.09416521887063886613527228353543E+36 Inexact Rounded +dvix3496 divideint -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> NaN Division_impossible +mulx3496 multiply -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> 5.16317927778381197995451363439626E-32 Inexact Rounded +powx3496 power -646.464431574014407536004990059069 -8 -> 3.27825641569860861774700548035691E-23 Inexact Rounded +remx3496 remainder -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> NaN Division_impossible +subx3496 subtract -646.464431574014407536004990059069 -798.679560020414523841321724649594E-037 -> -646.464431574014407536004990059069 Inexact Rounded +addx3497 add 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> 354.546679975219753598558273421556 Inexact Rounded +comx3497 compare 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> 1 +divx3497 divide 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> -5.03655799102477192579414523352028E+446 Inexact Rounded +dvix3497 divideint 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> NaN Division_impossible +mulx3497 multiply 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> -2.49581854324831161267369292071408E-442 Inexact Rounded +powx3497 power 354.546679975219753598558273421556 -7 -> 1.41999246365875617298270414304233E-18 Inexact Rounded +remx3497 remainder 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> NaN Division_impossible +subx3497 subtract 354.546679975219753598558273421556 -7039.46386812239015144581761752927E-448 -> 354.546679975219753598558273421556 Inexact Rounded +addx3498 add 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> 91936087917435.5974889495278215874 Inexact Rounded +comx3498 compare 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> 1 +divx3498 divide 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> -1.37052712434303366569304688993783E+760 Inexact Rounded +dvix3498 divideint 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> NaN Division_impossible +mulx3498 multiply 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> -6.16714847260980448099292763939423E-733 Inexact Rounded +powx3498 power 91936087917435.5974889495278215874 -7 -> 1.80134899939035708719659065082630E-98 Inexact Rounded +remx3498 remainder 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> NaN Division_impossible +subx3498 subtract 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> 91936087917435.5974889495278215874 Inexact Rounded +addx3499 add -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded +comx3499 compare -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1 +divx3499 divide -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1.78342822299163842247184303878022E+159 Inexact Rounded +dvix3499 divideint -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible +mulx3499 multiply -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -3.02554705575380338274126867655676E-1352 Inexact Rounded +powx3499 power -07345.6422518528556136521417259811E-600 4 -> 2.91151541552217582082937236255996E-2385 Inexact Rounded +remx3499 remainder -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible +subx3499 subtract -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded +addx3500 add -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> 6.16988426425908872398170896375634E+401 Inexact Rounded +comx3500 compare -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1 +divx3500 divide -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -4.10511306357337753351655511866170E-394 Inexact Rounded +dvix3500 divideint -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -0 +mulx3500 multiply -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1.56271275924409657991913620522315E+410 Inexact Rounded +powx3500 power -253280724.939458021588167965038184 6 -> 2.64005420221406808782284459794424E+50 Inexact Rounded +remx3500 remainder -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -253280724.939458021588167965038184 +subx3500 subtract -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -6.16988426425908872398170896375634E+401 Inexact Rounded Added: sandbox/trunk/decimal-c/decimaltestdata/randoms.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/randoms.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,4029 @@ +------------------------------------------------------------------------ +-- randoms.decTest -- decimal random testcases -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +rounding: half_up + +-- Randomly generated testcases [31 Dec 2000, with results defined for +-- all cases [27 Oct 2001], and no trim/finish [9 Jun 2002] +xadd001 add 905.67402 -202896611.E-780472620 -> 905.674020 Inexact Rounded +xcom001 compare 905.67402 -202896611.E-780472620 -> 1 +xdiv001 divide 905.67402 -202896611.E-780472620 -> -4.46372177E+780472614 Inexact Rounded +xdvi001 divideint 905.67402 -202896611.E-780472620 -> NaN Division_impossible +xmul001 multiply 905.67402 -202896611.E-780472620 -> -1.83758189E-780472609 Inexact Rounded +xpow001 power 905.67402 -2 -> 0.00000121914730 Inexact Rounded +xrem001 remainder 905.67402 -202896611.E-780472620 -> NaN Division_impossible +xsub001 subtract 905.67402 -202896611.E-780472620 -> 905.674020 Inexact Rounded +xadd002 add 3915134.7 -597164907. -> -593249772 Inexact Rounded +xcom002 compare 3915134.7 -597164907. -> 1 +xdiv002 divide 3915134.7 -597164907. -> -0.00655620358 Inexact Rounded +xdvi002 divideint 3915134.7 -597164907. -> -0 +xmul002 multiply 3915134.7 -597164907. -> -2.33798105E+15 Inexact Rounded +xpow002 power 3915134.7 -597164907 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem002 remainder 3915134.7 -597164907. -> 3915134.7 +xsub002 subtract 3915134.7 -597164907. -> 601080042 Inexact Rounded +xadd003 add 309759261 62663.487 -> 309821924 Inexact Rounded +xcom003 compare 309759261 62663.487 -> 1 +xdiv003 divide 309759261 62663.487 -> 4943.21775 Inexact Rounded +xdvi003 divideint 309759261 62663.487 -> 4943 +xmul003 multiply 309759261 62663.487 -> 1.94105954E+13 Inexact Rounded +xpow003 power 309759261 62663 -> 1.13679199E+532073 Inexact Rounded +xrem003 remainder 309759261 62663.487 -> 13644.759 +xsub003 subtract 309759261 62663.487 -> 309696598 Inexact Rounded +xadd004 add 3.93591888E-236595626 7242375.00 -> 7242375.00 Inexact Rounded +xcom004 compare 3.93591888E-236595626 7242375.00 -> -1 +xdiv004 divide 3.93591888E-236595626 7242375.00 -> 5.43456930E-236595633 Inexact Rounded +xdvi004 divideint 3.93591888E-236595626 7242375.00 -> 0 +xmul004 multiply 3.93591888E-236595626 7242375.00 -> 2.85054005E-236595619 Inexact Rounded +xpow004 power 3.93591888E-236595626 7242375 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem004 remainder 3.93591888E-236595626 7242375.00 -> 3.93591888E-236595626 +xsub004 subtract 3.93591888E-236595626 7242375.00 -> -7242375.00 Inexact Rounded +xadd005 add 323902.714 -608669.607E-657060568 -> 323902.714 Inexact Rounded +xcom005 compare 323902.714 -608669.607E-657060568 -> 1 +xdiv005 divide 323902.714 -608669.607E-657060568 -> -5.32148657E+657060567 Inexact Rounded +xdvi005 divideint 323902.714 -608669.607E-657060568 -> NaN Division_impossible +xmul005 multiply 323902.714 -608669.607E-657060568 -> -1.97149738E-657060557 Inexact Rounded +xpow005 power 323902.714 -6 -> 8.65989204E-34 Inexact Rounded +xrem005 remainder 323902.714 -608669.607E-657060568 -> NaN Division_impossible +xsub005 subtract 323902.714 -608669.607E-657060568 -> 323902.714 Inexact Rounded +xadd006 add 5.11970092 -8807.22036 -> -8802.10066 Inexact Rounded +xcom006 compare 5.11970092 -8807.22036 -> 1 +xdiv006 divide 5.11970092 -8807.22036 -> -0.000581307236 Inexact Rounded +xdvi006 divideint 5.11970092 -8807.22036 -> -0 +xmul006 multiply 5.11970092 -8807.22036 -> -45090.3342 Inexact Rounded +xpow006 power 5.11970092 -8807 -> 4.81819262E-6247 Inexact Rounded +xrem006 remainder 5.11970092 -8807.22036 -> 5.11970092 +xsub006 subtract 5.11970092 -8807.22036 -> 8812.34006 Inexact Rounded +xadd007 add -7.99874516 4561.83758 -> 4553.83883 Inexact Rounded +xcom007 compare -7.99874516 4561.83758 -> -1 +xdiv007 divide -7.99874516 4561.83758 -> -0.00175340420 Inexact Rounded +xdvi007 divideint -7.99874516 4561.83758 -> -0 +xmul007 multiply -7.99874516 4561.83758 -> -36488.9763 Inexact Rounded +xpow007 power -7.99874516 4562 -> 3.85236199E+4119 Inexact Rounded +xrem007 remainder -7.99874516 4561.83758 -> -7.99874516 +xsub007 subtract -7.99874516 4561.83758 -> -4569.83633 Inexact Rounded +xadd008 add 297802878 -927206.324 -> 296875672 Inexact Rounded +xcom008 compare 297802878 -927206.324 -> 1 +xdiv008 divide 297802878 -927206.324 -> -321.182967 Inexact Rounded +xdvi008 divideint 297802878 -927206.324 -> -321 +xmul008 multiply 297802878 -927206.324 -> -2.76124712E+14 Inexact Rounded +xpow008 power 297802878 -927206 -> 1.94602810E-7857078 Inexact Rounded +xrem008 remainder 297802878 -927206.324 -> 169647.996 +xsub008 subtract 297802878 -927206.324 -> 298730084 Inexact Rounded +xadd009 add -766.651824 31300.3619 -> 30533.7101 Inexact Rounded +xcom009 compare -766.651824 31300.3619 -> -1 +xdiv009 divide -766.651824 31300.3619 -> -0.0244933853 Inexact Rounded +xdvi009 divideint -766.651824 31300.3619 -> -0 +xmul009 multiply -766.651824 31300.3619 -> -23996479.5 Inexact Rounded +xpow009 power -766.651824 31300 -> 8.37189011E+90287 Inexact Rounded +xrem009 remainder -766.651824 31300.3619 -> -766.651824 +xsub009 subtract -766.651824 31300.3619 -> -32067.0137 Inexact Rounded +xadd010 add -56746.8689E+934981942 471002521. -> -5.67468689E+934981946 Inexact Rounded +xcom010 compare -56746.8689E+934981942 471002521. -> -1 +xdiv010 divide -56746.8689E+934981942 471002521. -> -1.20481030E+934981938 Inexact Rounded +xdvi010 divideint -56746.8689E+934981942 471002521. -> NaN Division_impossible +xmul010 multiply -56746.8689E+934981942 471002521. -> -2.67279183E+934981955 Inexact Rounded +xpow010 power -56746.8689E+934981942 471002521 -> -Infinity Overflow Inexact Rounded +xrem010 remainder -56746.8689E+934981942 471002521. -> NaN Division_impossible +xsub010 subtract -56746.8689E+934981942 471002521. -> -5.67468689E+934981946 Inexact Rounded +xadd011 add 456417160 -41346.1024 -> 456375814 Inexact Rounded +xcom011 compare 456417160 -41346.1024 -> 1 +xdiv011 divide 456417160 -41346.1024 -> -11038.9404 Inexact Rounded +xdvi011 divideint 456417160 -41346.1024 -> -11038 +xmul011 multiply 456417160 -41346.1024 -> -1.88710706E+13 Inexact Rounded +xpow011 power 456417160 -41346 -> 1.04766863E-358030 Inexact Rounded +xrem011 remainder 456417160 -41346.1024 -> 38881.7088 +xsub011 subtract 456417160 -41346.1024 -> 456458506 Inexact Rounded +xadd012 add 102895.722 -2.62214826 -> 102893.100 Inexact Rounded +xcom012 compare 102895.722 -2.62214826 -> 1 +xdiv012 divide 102895.722 -2.62214826 -> -39241.0008 Inexact Rounded +xdvi012 divideint 102895.722 -2.62214826 -> -39241 +xmul012 multiply 102895.722 -2.62214826 -> -269807.838 Inexact Rounded +xpow012 power 102895.722 -3 -> 9.17926786E-16 Inexact Rounded +xrem012 remainder 102895.722 -2.62214826 -> 0.00212934 +xsub012 subtract 102895.722 -2.62214826 -> 102898.344 Inexact Rounded +xadd013 add 61.3033331E+157644141 -567740.918E-893439456 -> 6.13033331E+157644142 Inexact Rounded +xcom013 compare 61.3033331E+157644141 -567740.918E-893439456 -> 1 +xdiv013 divide 61.3033331E+157644141 -567740.918E-893439456 -> -Infinity Inexact Overflow Rounded +xdvi013 divideint 61.3033331E+157644141 -567740.918E-893439456 -> NaN Division_impossible +xmul013 multiply 61.3033331E+157644141 -567740.918E-893439456 -> -3.48044106E-735795308 Inexact Rounded +xpow013 power 61.3033331E+157644141 -6 -> 1.88406322E-945864857 Inexact Rounded +xrem013 remainder 61.3033331E+157644141 -567740.918E-893439456 -> NaN Division_impossible +xsub013 subtract 61.3033331E+157644141 -567740.918E-893439456 -> 6.13033331E+157644142 Inexact Rounded +xadd014 add 80223.3897 73921.0383E-467772675 -> 80223.3897 Inexact Rounded +xcom014 compare 80223.3897 73921.0383E-467772675 -> 1 +xdiv014 divide 80223.3897 73921.0383E-467772675 -> 1.08525789E+467772675 Inexact Rounded +xdvi014 divideint 80223.3897 73921.0383E-467772675 -> NaN Division_impossible +xmul014 multiply 80223.3897 73921.0383E-467772675 -> 5.93019626E-467772666 Inexact Rounded +xpow014 power 80223.3897 7 -> 2.13848919E+34 Inexact Rounded +xrem014 remainder 80223.3897 73921.0383E-467772675 -> NaN Division_impossible +xsub014 subtract 80223.3897 73921.0383E-467772675 -> 80223.3897 Inexact Rounded +xadd015 add -654645.954 -9.12535752 -> -654655.079 Inexact Rounded +xcom015 compare -654645.954 -9.12535752 -> -1 +xdiv015 divide -654645.954 -9.12535752 -> 71739.2116 Inexact Rounded +xdvi015 divideint -654645.954 -9.12535752 -> 71739 +xmul015 multiply -654645.954 -9.12535752 -> 5973878.38 Inexact Rounded +xpow015 power -654645.954 -9 -> -4.52836690E-53 Inexact Rounded +xrem015 remainder -654645.954 -9.12535752 -> -1.93087272 +xsub015 subtract -654645.954 -9.12535752 -> -654636.829 Inexact Rounded +xadd016 add 63.1917772E-706014634 -7.56253257E-138579234 -> -7.56253257E-138579234 Inexact Rounded +xcom016 compare 63.1917772E-706014634 -7.56253257E-138579234 -> 1 +xdiv016 divide 63.1917772E-706014634 -7.56253257E-138579234 -> -8.35590149E-567435400 Inexact Rounded +xdvi016 divideint 63.1917772E-706014634 -7.56253257E-138579234 -> -0 +xmul016 multiply 63.1917772E-706014634 -7.56253257E-138579234 -> -4.77889873E-844593866 Inexact Rounded +xpow016 power 63.1917772E-706014634 -8 -> Infinity Overflow Inexact Rounded +xrem016 remainder 63.1917772E-706014634 -7.56253257E-138579234 -> 6.31917772E-706014633 +xsub016 subtract 63.1917772E-706014634 -7.56253257E-138579234 -> 7.56253257E-138579234 Inexact Rounded +xadd017 add -39674.7190 2490607.78 -> 2450933.06 Inexact Rounded +xcom017 compare -39674.7190 2490607.78 -> -1 +xdiv017 divide -39674.7190 2490607.78 -> -0.0159297338 Inexact Rounded +xdvi017 divideint -39674.7190 2490607.78 -> -0 +xmul017 multiply -39674.7190 2490607.78 -> -9.88141638E+10 Inexact Rounded +xpow017 power -39674.7190 2490608 -> 2.55032329E+11453095 Inexact Rounded +xrem017 remainder -39674.7190 2490607.78 -> -39674.7190 +xsub017 subtract -39674.7190 2490607.78 -> -2530282.50 Inexact Rounded +xadd018 add -3364.59737E-600363681 896487.451 -> 896487.451 Inexact Rounded +xcom018 compare -3364.59737E-600363681 896487.451 -> -1 +xdiv018 divide -3364.59737E-600363681 896487.451 -> -3.75308920E-600363684 Inexact Rounded +xdvi018 divideint -3364.59737E-600363681 896487.451 -> -0 +xmul018 multiply -3364.59737E-600363681 896487.451 -> -3.01631932E-600363672 Inexact Rounded +xpow018 power -3364.59737E-600363681 896487 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem018 remainder -3364.59737E-600363681 896487.451 -> -3.36459737E-600363678 +xsub018 subtract -3364.59737E-600363681 896487.451 -> -896487.451 Inexact Rounded +xadd019 add -64138.0578 31759011.3E+697488342 -> 3.17590113E+697488349 Inexact Rounded +xcom019 compare -64138.0578 31759011.3E+697488342 -> -1 +xdiv019 divide -64138.0578 31759011.3E+697488342 -> -2.01952313E-697488345 Inexact Rounded +xdvi019 divideint -64138.0578 31759011.3E+697488342 -> -0 +xmul019 multiply -64138.0578 31759011.3E+697488342 -> -2.03696130E+697488354 Inexact Rounded +xpow019 power -64138.0578 3 -> -2.63844116E+14 Inexact Rounded +xrem019 remainder -64138.0578 31759011.3E+697488342 -> -64138.0578 +xsub019 subtract -64138.0578 31759011.3E+697488342 -> -3.17590113E+697488349 Inexact Rounded +xadd020 add 61399.8527 -64344484.5 -> -64283084.6 Inexact Rounded +xcom020 compare 61399.8527 -64344484.5 -> 1 +xdiv020 divide 61399.8527 -64344484.5 -> -0.000954236454 Inexact Rounded +xdvi020 divideint 61399.8527 -64344484.5 -> -0 +xmul020 multiply 61399.8527 -64344484.5 -> -3.95074187E+12 Inexact Rounded +xpow020 power 61399.8527 -64344485 -> 1.27378842E-308092161 Inexact Rounded +xrem020 remainder 61399.8527 -64344484.5 -> 61399.8527 +xsub020 subtract 61399.8527 -64344484.5 -> 64405884.4 Inexact Rounded +xadd021 add -722960.204 -26154599.8 -> -26877560.0 Inexact Rounded +xcom021 compare -722960.204 -26154599.8 -> 1 +xdiv021 divide -722960.204 -26154599.8 -> 0.0276417995 Inexact Rounded +xdvi021 divideint -722960.204 -26154599.8 -> 0 +xmul021 multiply -722960.204 -26154599.8 -> 1.89087348E+13 Inexact Rounded +xpow021 power -722960.204 -26154600 -> 5.34236139E-153242794 Inexact Rounded +xrem021 remainder -722960.204 -26154599.8 -> -722960.204 +xsub021 subtract -722960.204 -26154599.8 -> 25431639.6 Inexact Rounded +xadd022 add 9.47109959E+230565093 73354723.2 -> 9.47109959E+230565093 Inexact Rounded +xcom022 compare 9.47109959E+230565093 73354723.2 -> 1 +xdiv022 divide 9.47109959E+230565093 73354723.2 -> 1.29113698E+230565086 Inexact Rounded +xdvi022 divideint 9.47109959E+230565093 73354723.2 -> NaN Division_impossible +xmul022 multiply 9.47109959E+230565093 73354723.2 -> 6.94749889E+230565101 Inexact Rounded +xpow022 power 9.47109959E+230565093 73354723 -> Infinity Overflow Inexact Rounded +xrem022 remainder 9.47109959E+230565093 73354723.2 -> NaN Division_impossible +xsub022 subtract 9.47109959E+230565093 73354723.2 -> 9.47109959E+230565093 Inexact Rounded +xadd023 add 43.7456245 547441956. -> 547442000 Inexact Rounded +xcom023 compare 43.7456245 547441956. -> -1 +xdiv023 divide 43.7456245 547441956. -> 7.99091557E-8 Inexact Rounded +xdvi023 divideint 43.7456245 547441956. -> 0 +xmul023 multiply 43.7456245 547441956. -> 2.39481902E+10 Inexact Rounded +xpow023 power 43.7456245 547441956 -> 2.91742391E+898316458 Inexact Rounded +xrem023 remainder 43.7456245 547441956. -> 43.7456245 +xsub023 subtract 43.7456245 547441956. -> -547441912 Inexact Rounded +xadd024 add -73150542E-242017390 -8.15869954 -> -8.15869954 Inexact Rounded +xcom024 compare -73150542E-242017390 -8.15869954 -> 1 +xdiv024 divide -73150542E-242017390 -8.15869954 -> 8.96595611E-242017384 Inexact Rounded +xdvi024 divideint -73150542E-242017390 -8.15869954 -> 0 +xmul024 multiply -73150542E-242017390 -8.15869954 -> 5.96813293E-242017382 Inexact Rounded +xpow024 power -73150542E-242017390 -8 -> Infinity Overflow Inexact Rounded +xrem024 remainder -73150542E-242017390 -8.15869954 -> -7.3150542E-242017383 +xsub024 subtract -73150542E-242017390 -8.15869954 -> 8.15869954 Inexact Rounded +xadd025 add 2015.62109E+299897596 -11788916.1 -> 2.01562109E+299897599 Inexact Rounded +xcom025 compare 2015.62109E+299897596 -11788916.1 -> 1 +xdiv025 divide 2015.62109E+299897596 -11788916.1 -> -1.70975947E+299897592 Inexact Rounded +xdvi025 divideint 2015.62109E+299897596 -11788916.1 -> NaN Division_impossible +xmul025 multiply 2015.62109E+299897596 -11788916.1 -> -2.37619879E+299897606 Inexact Rounded +xpow025 power 2015.62109E+299897596 -11788916 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem025 remainder 2015.62109E+299897596 -11788916.1 -> NaN Division_impossible +xsub025 subtract 2015.62109E+299897596 -11788916.1 -> 2.01562109E+299897599 Inexact Rounded +xadd026 add 29.498114 -26486451 -> -26486421.5 Inexact Rounded +xcom026 compare 29.498114 -26486451 -> 1 +xdiv026 divide 29.498114 -26486451 -> -0.00000111370580 Inexact Rounded +xdvi026 divideint 29.498114 -26486451 -> -0 +xmul026 multiply 29.498114 -26486451 -> -781300351 Inexact Rounded +xpow026 power 29.498114 -26486451 -> 4.22252513E-38929634 Inexact Rounded +xrem026 remainder 29.498114 -26486451 -> 29.498114 +xsub026 subtract 29.498114 -26486451 -> 26486480.5 Inexact Rounded +xadd027 add 244375043.E+130840878 -9.44522029 -> 2.44375043E+130840886 Inexact Rounded +xcom027 compare 244375043.E+130840878 -9.44522029 -> 1 +xdiv027 divide 244375043.E+130840878 -9.44522029 -> -2.58728791E+130840885 Inexact Rounded +xdvi027 divideint 244375043.E+130840878 -9.44522029 -> NaN Division_impossible +xmul027 multiply 244375043.E+130840878 -9.44522029 -> -2.30817611E+130840887 Inexact Rounded +xpow027 power 244375043.E+130840878 -9 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem027 remainder 244375043.E+130840878 -9.44522029 -> NaN Division_impossible +xsub027 subtract 244375043.E+130840878 -9.44522029 -> 2.44375043E+130840886 Inexact Rounded +xadd028 add -349388.759 -196215.776 -> -545604.535 +xcom028 compare -349388.759 -196215.776 -> -1 +xdiv028 divide -349388.759 -196215.776 -> 1.78063541 Inexact Rounded +xdvi028 divideint -349388.759 -196215.776 -> 1 +xmul028 multiply -349388.759 -196215.776 -> 6.85555865E+10 Inexact Rounded +xpow028 power -349388.759 -196216 -> 1.24551752E-1087686 Inexact Rounded +xrem028 remainder -349388.759 -196215.776 -> -153172.983 +xsub028 subtract -349388.759 -196215.776 -> -153172.983 +xadd029 add -70905112.4 -91353968.8 -> -162259081 Inexact Rounded +xcom029 compare -70905112.4 -91353968.8 -> 1 +xdiv029 divide -70905112.4 -91353968.8 -> 0.776157986 Inexact Rounded +xdvi029 divideint -70905112.4 -91353968.8 -> 0 +xmul029 multiply -70905112.4 -91353968.8 -> 6.47746343E+15 Inexact Rounded +xpow029 power -70905112.4 -91353969 -> -3.05944741E-717190554 Inexact Rounded +xrem029 remainder -70905112.4 -91353968.8 -> -70905112.4 +xsub029 subtract -70905112.4 -91353968.8 -> 20448856.4 +xadd030 add -225094.28 -88.7723542 -> -225183.052 Inexact Rounded +xcom030 compare -225094.28 -88.7723542 -> -1 +xdiv030 divide -225094.28 -88.7723542 -> 2535.63491 Inexact Rounded +xdvi030 divideint -225094.28 -88.7723542 -> 2535 +xmul030 multiply -225094.28 -88.7723542 -> 19982149.2 Inexact Rounded +xpow030 power -225094.28 -89 -> -4.36076964E-477 Inexact Rounded +xrem030 remainder -225094.28 -88.7723542 -> -56.3621030 +xsub030 subtract -225094.28 -88.7723542 -> -225005.508 Inexact Rounded +xadd031 add 50.4442340 82.7952169E+880120759 -> 8.27952169E+880120760 Inexact Rounded +xcom031 compare 50.4442340 82.7952169E+880120759 -> -1 +xdiv031 divide 50.4442340 82.7952169E+880120759 -> 6.09265075E-880120760 Inexact Rounded +xdvi031 divideint 50.4442340 82.7952169E+880120759 -> 0 +xmul031 multiply 50.4442340 82.7952169E+880120759 -> 4.17654130E+880120762 Inexact Rounded +xpow031 power 50.4442340 8 -> 4.19268518E+13 Inexact Rounded +xrem031 remainder 50.4442340 82.7952169E+880120759 -> 50.4442340 +xsub031 subtract 50.4442340 82.7952169E+880120759 -> -8.27952169E+880120760 Inexact Rounded +xadd032 add -32311.9037 8.36379449 -> -32303.5399 Inexact Rounded +xcom032 compare -32311.9037 8.36379449 -> -1 +xdiv032 divide -32311.9037 8.36379449 -> -3863.30675 Inexact Rounded +xdvi032 divideint -32311.9037 8.36379449 -> -3863 +xmul032 multiply -32311.9037 8.36379449 -> -270250.122 Inexact Rounded +xpow032 power -32311.9037 8 -> 1.18822960E+36 Inexact Rounded +xrem032 remainder -32311.9037 8.36379449 -> -2.56558513 +xsub032 subtract -32311.9037 8.36379449 -> -32320.2675 Inexact Rounded +xadd033 add 615396156.E+549895291 -29530247.4 -> 6.15396156E+549895299 Inexact Rounded +xcom033 compare 615396156.E+549895291 -29530247.4 -> 1 +xdiv033 divide 615396156.E+549895291 -29530247.4 -> -2.08395191E+549895292 Inexact Rounded +xdvi033 divideint 615396156.E+549895291 -29530247.4 -> NaN Division_impossible +xmul033 multiply 615396156.E+549895291 -29530247.4 -> -1.81728007E+549895307 Inexact Rounded +xpow033 power 615396156.E+549895291 -29530247 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem033 remainder 615396156.E+549895291 -29530247.4 -> NaN Division_impossible +xsub033 subtract 615396156.E+549895291 -29530247.4 -> 6.15396156E+549895299 Inexact Rounded +xadd034 add 592.142173E-419941416 -3.46079109E-844011845 -> 5.92142173E-419941414 Inexact Rounded +xcom034 compare 592.142173E-419941416 -3.46079109E-844011845 -> 1 +xdiv034 divide 592.142173E-419941416 -3.46079109E-844011845 -> -1.71100236E+424070431 Inexact Rounded +xdvi034 divideint 592.142173E-419941416 -3.46079109E-844011845 -> NaN Division_impossible +xmul034 multiply 592.142173E-419941416 -3.46079109E-844011845 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow034 power 592.142173E-419941416 -3 -> Infinity Overflow Inexact Rounded +xrem034 remainder 592.142173E-419941416 -3.46079109E-844011845 -> NaN Division_impossible +xsub034 subtract 592.142173E-419941416 -3.46079109E-844011845 -> 5.92142173E-419941414 Inexact Rounded +xadd035 add 849.515993E-878446473 -1039.08778 -> -1039.08778 Inexact Rounded +xcom035 compare 849.515993E-878446473 -1039.08778 -> 1 +xdiv035 divide 849.515993E-878446473 -1039.08778 -> -8.17559411E-878446474 Inexact Rounded +xdvi035 divideint 849.515993E-878446473 -1039.08778 -> -0 +xmul035 multiply 849.515993E-878446473 -1039.08778 -> -8.82721687E-878446468 Inexact Rounded +xpow035 power 849.515993E-878446473 -1039 -> Infinity Overflow Inexact Rounded +xrem035 remainder 849.515993E-878446473 -1039.08778 -> 8.49515993E-878446471 +xsub035 subtract 849.515993E-878446473 -1039.08778 -> 1039.08778 Inexact Rounded +xadd036 add 213361789 -599.644851 -> 213361189 Inexact Rounded +xcom036 compare 213361789 -599.644851 -> 1 +xdiv036 divide 213361789 -599.644851 -> -355813.593 Inexact Rounded +xdvi036 divideint 213361789 -599.644851 -> -355813 +xmul036 multiply 213361789 -599.644851 -> -1.27941298E+11 Inexact Rounded +xpow036 power 213361789 -600 -> 3.38854684E-4998 Inexact Rounded +xrem036 remainder 213361789 -599.644851 -> 355.631137 +xsub036 subtract 213361789 -599.644851 -> 213362389 Inexact Rounded +xadd037 add -795522555. -298.037702 -> -795522853 Inexact Rounded +xcom037 compare -795522555. -298.037702 -> -1 +xdiv037 divide -795522555. -298.037702 -> 2669201.08 Inexact Rounded +xdvi037 divideint -795522555. -298.037702 -> 2669201 +xmul037 multiply -795522555. -298.037702 -> 2.37095714E+11 Inexact Rounded +xpow037 power -795522555. -298 -> 4.03232712E-2653 Inexact Rounded +xrem037 remainder -795522555. -298.037702 -> -22.783898 +xsub037 subtract -795522555. -298.037702 -> -795522257 Inexact Rounded +xadd038 add -501260651. -8761893.0E-689281479 -> -501260651 Inexact Rounded +xcom038 compare -501260651. -8761893.0E-689281479 -> -1 +xdiv038 divide -501260651. -8761893.0E-689281479 -> 5.72091728E+689281480 Inexact Rounded +xdvi038 divideint -501260651. -8761893.0E-689281479 -> NaN Division_impossible +xmul038 multiply -501260651. -8761893.0E-689281479 -> 4.39199219E-689281464 Inexact Rounded +xpow038 power -501260651. -9 -> -5.00526961E-79 Inexact Rounded +xrem038 remainder -501260651. -8761893.0E-689281479 -> NaN Division_impossible +xsub038 subtract -501260651. -8761893.0E-689281479 -> -501260651 Inexact Rounded +xadd039 add -1.70781105E-848889023 36504769.4 -> 36504769.4 Inexact Rounded +xcom039 compare -1.70781105E-848889023 36504769.4 -> -1 +xdiv039 divide -1.70781105E-848889023 36504769.4 -> -4.67832307E-848889031 Inexact Rounded +xdvi039 divideint -1.70781105E-848889023 36504769.4 -> -0 +xmul039 multiply -1.70781105E-848889023 36504769.4 -> -6.23432486E-848889016 Inexact Rounded +xpow039 power -1.70781105E-848889023 36504769 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem039 remainder -1.70781105E-848889023 36504769.4 -> -1.70781105E-848889023 +xsub039 subtract -1.70781105E-848889023 36504769.4 -> -36504769.4 Inexact Rounded +xadd040 add -5290.54984E-490626676 842535254 -> 842535254 Inexact Rounded +xcom040 compare -5290.54984E-490626676 842535254 -> -1 +xdiv040 divide -5290.54984E-490626676 842535254 -> -6.27932162E-490626682 Inexact Rounded +xdvi040 divideint -5290.54984E-490626676 842535254 -> -0 +xmul040 multiply -5290.54984E-490626676 842535254 -> -4.45747475E-490626664 Inexact Rounded +xpow040 power -5290.54984E-490626676 842535254 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem040 remainder -5290.54984E-490626676 842535254 -> -5.29054984E-490626673 +xsub040 subtract -5290.54984E-490626676 842535254 -> -842535254 Inexact Rounded +xadd041 add 608.31825E+535268120 -59609.0993 -> 6.08318250E+535268122 Inexact Rounded +xcom041 compare 608.31825E+535268120 -59609.0993 -> 1 +xdiv041 divide 608.31825E+535268120 -59609.0993 -> -1.02051240E+535268118 Inexact Rounded +xdvi041 divideint 608.31825E+535268120 -59609.0993 -> NaN Division_impossible +xmul041 multiply 608.31825E+535268120 -59609.0993 -> -3.62613030E+535268127 Inexact Rounded +xpow041 power 608.31825E+535268120 -59609 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem041 remainder 608.31825E+535268120 -59609.0993 -> NaN Division_impossible +xsub041 subtract 608.31825E+535268120 -59609.0993 -> 6.08318250E+535268122 Inexact Rounded +xadd042 add -4629035.31 -167.884398 -> -4629203.19 Inexact Rounded +xcom042 compare -4629035.31 -167.884398 -> -1 +xdiv042 divide -4629035.31 -167.884398 -> 27572.7546 Inexact Rounded +xdvi042 divideint -4629035.31 -167.884398 -> 27572 +xmul042 multiply -4629035.31 -167.884398 -> 777142806 Inexact Rounded +xpow042 power -4629035.31 -168 -> 1.57614831E-1120 Inexact Rounded +xrem042 remainder -4629035.31 -167.884398 -> -126.688344 +xsub042 subtract -4629035.31 -167.884398 -> -4628867.43 Inexact Rounded +xadd043 add -66527378. -706400268. -> -772927646 +xcom043 compare -66527378. -706400268. -> 1 +xdiv043 divide -66527378. -706400268. -> 0.0941780192 Inexact Rounded +xdvi043 divideint -66527378. -706400268. -> 0 +xmul043 multiply -66527378. -706400268. -> 4.69949576E+16 Inexact Rounded +xpow043 power -66527378. -706400268 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem043 remainder -66527378. -706400268. -> -66527378 +xsub043 subtract -66527378. -706400268. -> 639872890 +xadd044 add -2510497.53 372882462. -> 370371964 Inexact Rounded +xcom044 compare -2510497.53 372882462. -> -1 +xdiv044 divide -2510497.53 372882462. -> -0.00673267795 Inexact Rounded +xdvi044 divideint -2510497.53 372882462. -> -0 +xmul044 multiply -2510497.53 372882462. -> -9.36120500E+14 Inexact Rounded +xpow044 power -2510497.53 372882462 -> Infinity Overflow Inexact Rounded +xrem044 remainder -2510497.53 372882462. -> -2510497.53 +xsub044 subtract -2510497.53 372882462. -> -375392960 Inexact Rounded +xadd045 add 136.255393E+53329961 -53494.7201E+720058060 -> -5.34947201E+720058064 Inexact Rounded +xcom045 compare 136.255393E+53329961 -53494.7201E+720058060 -> 1 +xdiv045 divide 136.255393E+53329961 -53494.7201E+720058060 -> -2.54708115E-666728102 Inexact Rounded +xdvi045 divideint 136.255393E+53329961 -53494.7201E+720058060 -> -0 +xmul045 multiply 136.255393E+53329961 -53494.7201E+720058060 -> -7.28894411E+773388027 Inexact Rounded +xpow045 power 136.255393E+53329961 -5 -> 2.12927373E-266649816 Inexact Rounded +xrem045 remainder 136.255393E+53329961 -53494.7201E+720058060 -> 1.36255393E+53329963 +xsub045 subtract 136.255393E+53329961 -53494.7201E+720058060 -> 5.34947201E+720058064 Inexact Rounded +xadd046 add -876673.100 -6150.92266 -> -882824.023 Inexact Rounded +xcom046 compare -876673.100 -6150.92266 -> -1 +xdiv046 divide -876673.100 -6150.92266 -> 142.527089 Inexact Rounded +xdvi046 divideint -876673.100 -6150.92266 -> 142 +xmul046 multiply -876673.100 -6150.92266 -> 5.39234844E+9 Inexact Rounded +xpow046 power -876673.100 -6151 -> -4.03111774E-36555 Inexact Rounded +xrem046 remainder -876673.100 -6150.92266 -> -3242.08228 +xsub046 subtract -876673.100 -6150.92266 -> -870522.177 Inexact Rounded +xadd047 add -2.45151797E+911306117 27235771 -> -2.45151797E+911306117 Inexact Rounded +xcom047 compare -2.45151797E+911306117 27235771 -> -1 +xdiv047 divide -2.45151797E+911306117 27235771 -> -9.00109628E+911306109 Inexact Rounded +xdvi047 divideint -2.45151797E+911306117 27235771 -> NaN Division_impossible +xmul047 multiply -2.45151797E+911306117 27235771 -> -6.67689820E+911306124 Inexact Rounded +xpow047 power -2.45151797E+911306117 27235771 -> -Infinity Overflow Inexact Rounded +xrem047 remainder -2.45151797E+911306117 27235771 -> NaN Division_impossible +xsub047 subtract -2.45151797E+911306117 27235771 -> -2.45151797E+911306117 Inexact Rounded +xadd048 add -9.15117551 -4.95100733E-314511326 -> -9.15117551 Inexact Rounded +xcom048 compare -9.15117551 -4.95100733E-314511326 -> -1 +xdiv048 divide -9.15117551 -4.95100733E-314511326 -> 1.84834618E+314511326 Inexact Rounded +xdvi048 divideint -9.15117551 -4.95100733E-314511326 -> NaN Division_impossible +xmul048 multiply -9.15117551 -4.95100733E-314511326 -> 4.53075370E-314511325 Inexact Rounded +xpow048 power -9.15117551 -5 -> -0.0000155817265 Inexact Rounded +xrem048 remainder -9.15117551 -4.95100733E-314511326 -> NaN Division_impossible +xsub048 subtract -9.15117551 -4.95100733E-314511326 -> -9.15117551 Inexact Rounded +xadd049 add 3.61890453E-985606128 30664416. -> 30664416.0 Inexact Rounded +xcom049 compare 3.61890453E-985606128 30664416. -> -1 +xdiv049 divide 3.61890453E-985606128 30664416. -> 1.18016418E-985606135 Inexact Rounded +xdvi049 divideint 3.61890453E-985606128 30664416. -> 0 +xmul049 multiply 3.61890453E-985606128 30664416. -> 1.10971594E-985606120 Inexact Rounded +xpow049 power 3.61890453E-985606128 30664416 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem049 remainder 3.61890453E-985606128 30664416. -> 3.61890453E-985606128 +xsub049 subtract 3.61890453E-985606128 30664416. -> -30664416.0 Inexact Rounded +xadd050 add -257674602E+216723382 -70820959.4 -> -2.57674602E+216723390 Inexact Rounded +xcom050 compare -257674602E+216723382 -70820959.4 -> -1 +xdiv050 divide -257674602E+216723382 -70820959.4 -> 3.63839468E+216723382 Inexact Rounded +xdvi050 divideint -257674602E+216723382 -70820959.4 -> NaN Division_impossible +xmul050 multiply -257674602E+216723382 -70820959.4 -> 1.82487625E+216723398 Inexact Rounded +xpow050 power -257674602E+216723382 -70820959 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem050 remainder -257674602E+216723382 -70820959.4 -> NaN Division_impossible +xsub050 subtract -257674602E+216723382 -70820959.4 -> -2.57674602E+216723390 Inexact Rounded +xadd051 add 218699.206 556944241. -> 557162940 Inexact Rounded +xcom051 compare 218699.206 556944241. -> -1 +xdiv051 divide 218699.206 556944241. -> 0.000392677022 Inexact Rounded +xdvi051 divideint 218699.206 556944241. -> 0 +xmul051 multiply 218699.206 556944241. -> 1.21803263E+14 Inexact Rounded +xpow051 power 218699.206 556944241 -> Infinity Overflow Inexact Rounded +xrem051 remainder 218699.206 556944241. -> 218699.206 +xsub051 subtract 218699.206 556944241. -> -556725542 Inexact Rounded +xadd052 add 106211716. -3456793.74 -> 102754922 Inexact Rounded +xcom052 compare 106211716. -3456793.74 -> 1 +xdiv052 divide 106211716. -3456793.74 -> -30.7255000 Inexact Rounded +xdvi052 divideint 106211716. -3456793.74 -> -30 +xmul052 multiply 106211716. -3456793.74 -> -3.67151995E+14 Inexact Rounded +xpow052 power 106211716. -3456794 -> 2.07225581E-27744825 Inexact Rounded +xrem052 remainder 106211716. -3456793.74 -> 2507903.80 +xsub052 subtract 106211716. -3456793.74 -> 109668510 Inexact Rounded +xadd053 add 1.25018078 399856.763E-726816740 -> 1.25018078 Inexact Rounded +xcom053 compare 1.25018078 399856.763E-726816740 -> 1 +xdiv053 divide 1.25018078 399856.763E-726816740 -> 3.12657155E+726816734 Inexact Rounded +xdvi053 divideint 1.25018078 399856.763E-726816740 -> NaN Division_impossible +xmul053 multiply 1.25018078 399856.763E-726816740 -> 4.99893240E-726816735 Inexact Rounded +xpow053 power 1.25018078 4 -> 2.44281890 Inexact Rounded +xrem053 remainder 1.25018078 399856.763E-726816740 -> NaN Division_impossible +xsub053 subtract 1.25018078 399856.763E-726816740 -> 1.25018078 Inexact Rounded +xadd054 add 364.99811 -46222.0505 -> -45857.0524 Inexact Rounded +xcom054 compare 364.99811 -46222.0505 -> 1 +xdiv054 divide 364.99811 -46222.0505 -> -0.00789662306 Inexact Rounded +xdvi054 divideint 364.99811 -46222.0505 -> -0 +xmul054 multiply 364.99811 -46222.0505 -> -16870961.1 Inexact Rounded +xpow054 power 364.99811 -46222 -> 6.35570856E-118435 Inexact Rounded +xrem054 remainder 364.99811 -46222.0505 -> 364.99811 +xsub054 subtract 364.99811 -46222.0505 -> 46587.0486 Inexact Rounded +xadd055 add -392217576. -958364096 -> -1.35058167E+9 Inexact Rounded +xcom055 compare -392217576. -958364096 -> 1 +xdiv055 divide -392217576. -958364096 -> 0.409257377 Inexact Rounded +xdvi055 divideint -392217576. -958364096 -> 0 +xmul055 multiply -392217576. -958364096 -> 3.75887243E+17 Inexact Rounded +xpow055 power -392217576. -958364096 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem055 remainder -392217576. -958364096 -> -392217576 +xsub055 subtract -392217576. -958364096 -> 566146520 +xadd056 add 169601285 714526.639 -> 170315812 Inexact Rounded +xcom056 compare 169601285 714526.639 -> 1 +xdiv056 divide 169601285 714526.639 -> 237.361738 Inexact Rounded +xdvi056 divideint 169601285 714526.639 -> 237 +xmul056 multiply 169601285 714526.639 -> 1.21184636E+14 Inexact Rounded +xpow056 power 169601285 714527 -> 2.06052444E+5880149 Inexact Rounded +xrem056 remainder 169601285 714526.639 -> 258471.557 +xsub056 subtract 169601285 714526.639 -> 168886758 Inexact Rounded +xadd057 add -674.094552E+586944319 6354.2668E+589657266 -> 6.35426680E+589657269 Inexact Rounded +xcom057 compare -674.094552E+586944319 6354.2668E+589657266 -> -1 +xdiv057 divide -674.094552E+586944319 6354.2668E+589657266 -> -1.06085340E-2712948 Inexact Rounded +xdvi057 divideint -674.094552E+586944319 6354.2668E+589657266 -> -0 +xmul057 multiply -674.094552E+586944319 6354.2668E+589657266 -> -Infinity Inexact Overflow Rounded +xpow057 power -674.094552E+586944319 6 -> Infinity Overflow Inexact Rounded +xrem057 remainder -674.094552E+586944319 6354.2668E+589657266 -> -6.74094552E+586944321 +xsub057 subtract -674.094552E+586944319 6354.2668E+589657266 -> -6.35426680E+589657269 Inexact Rounded +xadd058 add 151795163E-371727182 -488.09788E-738852245 -> 1.51795163E-371727174 Inexact Rounded +xcom058 compare 151795163E-371727182 -488.09788E-738852245 -> 1 +xdiv058 divide 151795163E-371727182 -488.09788E-738852245 -> -3.10993285E+367125068 Inexact Rounded +xdvi058 divideint 151795163E-371727182 -488.09788E-738852245 -> NaN Division_impossible +xmul058 multiply 151795163E-371727182 -488.09788E-738852245 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow058 power 151795163E-371727182 -5 -> Infinity Overflow Inexact Rounded +xrem058 remainder 151795163E-371727182 -488.09788E-738852245 -> NaN Division_impossible +xsub058 subtract 151795163E-371727182 -488.09788E-738852245 -> 1.51795163E-371727174 Inexact Rounded +xadd059 add -746.293386 927749.647 -> 927003.354 Inexact Rounded +xcom059 compare -746.293386 927749.647 -> -1 +xdiv059 divide -746.293386 927749.647 -> -0.000804412471 Inexact Rounded +xdvi059 divideint -746.293386 927749.647 -> -0 +xmul059 multiply -746.293386 927749.647 -> -692373425 Inexact Rounded +xpow059 power -746.293386 927750 -> 7.49278741E+2665341 Inexact Rounded +xrem059 remainder -746.293386 927749.647 -> -746.293386 +xsub059 subtract -746.293386 927749.647 -> -928495.940 Inexact Rounded +xadd060 add 888946471E+241331592 -235739.595 -> 8.88946471E+241331600 Inexact Rounded +xcom060 compare 888946471E+241331592 -235739.595 -> 1 +xdiv060 divide 888946471E+241331592 -235739.595 -> -3.77088317E+241331595 Inexact Rounded +xdvi060 divideint 888946471E+241331592 -235739.595 -> NaN Division_impossible +xmul060 multiply 888946471E+241331592 -235739.595 -> -2.09559881E+241331606 Inexact Rounded +xpow060 power 888946471E+241331592 -235740 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem060 remainder 888946471E+241331592 -235739.595 -> NaN Division_impossible +xsub060 subtract 888946471E+241331592 -235739.595 -> 8.88946471E+241331600 Inexact Rounded +xadd061 add 6.64377249 79161.1070E+619453776 -> 7.91611070E+619453780 Inexact Rounded +xcom061 compare 6.64377249 79161.1070E+619453776 -> -1 +xdiv061 divide 6.64377249 79161.1070E+619453776 -> 8.39272307E-619453781 Inexact Rounded +xdvi061 divideint 6.64377249 79161.1070E+619453776 -> 0 +xmul061 multiply 6.64377249 79161.1070E+619453776 -> 5.25928385E+619453781 Inexact Rounded +xpow061 power 6.64377249 8 -> 3795928.44 Inexact Rounded +xrem061 remainder 6.64377249 79161.1070E+619453776 -> 6.64377249 +xsub061 subtract 6.64377249 79161.1070E+619453776 -> -7.91611070E+619453780 Inexact Rounded +xadd062 add 3146.66571E-313373366 88.5282010 -> 88.5282010 Inexact Rounded +xcom062 compare 3146.66571E-313373366 88.5282010 -> -1 +xdiv062 divide 3146.66571E-313373366 88.5282010 -> 3.55442184E-313373365 Inexact Rounded +xdvi062 divideint 3146.66571E-313373366 88.5282010 -> 0 +xmul062 multiply 3146.66571E-313373366 88.5282010 -> 2.78568654E-313373361 Inexact Rounded +xpow062 power 3146.66571E-313373366 89 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem062 remainder 3146.66571E-313373366 88.5282010 -> 3.14666571E-313373363 +xsub062 subtract 3146.66571E-313373366 88.5282010 -> -88.5282010 Inexact Rounded +xadd063 add 6.44693097 -87195.8711 -> -87189.4242 Inexact Rounded +xcom063 compare 6.44693097 -87195.8711 -> 1 +xdiv063 divide 6.44693097 -87195.8711 -> -0.0000739361955 Inexact Rounded +xdvi063 divideint 6.44693097 -87195.8711 -> -0 +xmul063 multiply 6.44693097 -87195.8711 -> -562145.762 Inexact Rounded +xpow063 power 6.44693097 -87196 -> 4.50881730E-70573 Inexact Rounded +xrem063 remainder 6.44693097 -87195.8711 -> 6.44693097 +xsub063 subtract 6.44693097 -87195.8711 -> 87202.3180 Inexact Rounded +xadd064 add -2113132.56E+577957840 981125821 -> -2.11313256E+577957846 Inexact Rounded +xcom064 compare -2113132.56E+577957840 981125821 -> -1 +xdiv064 divide -2113132.56E+577957840 981125821 -> -2.15378345E+577957837 Inexact Rounded +xdvi064 divideint -2113132.56E+577957840 981125821 -> NaN Division_impossible +xmul064 multiply -2113132.56E+577957840 981125821 -> -2.07324892E+577957855 Inexact Rounded +xpow064 power -2113132.56E+577957840 981125821 -> -Infinity Overflow Inexact Rounded +xrem064 remainder -2113132.56E+577957840 981125821 -> NaN Division_impossible +xsub064 subtract -2113132.56E+577957840 981125821 -> -2.11313256E+577957846 Inexact Rounded +xadd065 add -7701.42814 72667.5181 -> 64966.0900 Inexact Rounded +xcom065 compare -7701.42814 72667.5181 -> -1 +xdiv065 divide -7701.42814 72667.5181 -> -0.105981714 Inexact Rounded +xdvi065 divideint -7701.42814 72667.5181 -> -0 +xmul065 multiply -7701.42814 72667.5181 -> -559643669 Inexact Rounded +xpow065 power -7701.42814 72668 -> 2.29543837E+282429 Inexact Rounded +xrem065 remainder -7701.42814 72667.5181 -> -7701.42814 +xsub065 subtract -7701.42814 72667.5181 -> -80368.9462 Inexact Rounded +xadd066 add -851.754789 -582659.149 -> -583510.904 Inexact Rounded +xcom066 compare -851.754789 -582659.149 -> 1 +xdiv066 divide -851.754789 -582659.149 -> 0.00146184058 Inexact Rounded +xdvi066 divideint -851.754789 -582659.149 -> 0 +xmul066 multiply -851.754789 -582659.149 -> 496282721 Inexact Rounded +xpow066 power -851.754789 -582659 -> -6.83532593E-1707375 Inexact Rounded +xrem066 remainder -851.754789 -582659.149 -> -851.754789 +xsub066 subtract -851.754789 -582659.149 -> 581807.394 Inexact Rounded +xadd067 add -5.01992943 7852.16531 -> 7847.14538 Inexact Rounded +xcom067 compare -5.01992943 7852.16531 -> -1 +xdiv067 divide -5.01992943 7852.16531 -> -0.000639305113 Inexact Rounded +xdvi067 divideint -5.01992943 7852.16531 -> -0 +xmul067 multiply -5.01992943 7852.16531 -> -39417.3157 Inexact Rounded +xpow067 power -5.01992943 7852 -> 7.54481448E+5501 Inexact Rounded +xrem067 remainder -5.01992943 7852.16531 -> -5.01992943 +xsub067 subtract -5.01992943 7852.16531 -> -7857.18524 Inexact Rounded +xadd068 add -12393257.2 76803689E+949125770 -> 7.68036890E+949125777 Inexact Rounded +xcom068 compare -12393257.2 76803689E+949125770 -> -1 +xdiv068 divide -12393257.2 76803689E+949125770 -> -1.61362786E-949125771 Inexact Rounded +xdvi068 divideint -12393257.2 76803689E+949125770 -> -0 +xmul068 multiply -12393257.2 76803689E+949125770 -> -9.51847872E+949125784 Inexact Rounded +xpow068 power -12393257.2 8 -> 5.56523750E+56 Inexact Rounded +xrem068 remainder -12393257.2 76803689E+949125770 -> -12393257.2 +xsub068 subtract -12393257.2 76803689E+949125770 -> -7.68036890E+949125777 Inexact Rounded +xadd069 add -754771634.E+716555026 -292336.311 -> -7.54771634E+716555034 Inexact Rounded +xcom069 compare -754771634.E+716555026 -292336.311 -> -1 +xdiv069 divide -754771634.E+716555026 -292336.311 -> 2.58186070E+716555029 Inexact Rounded +xdvi069 divideint -754771634.E+716555026 -292336.311 -> NaN Division_impossible +xmul069 multiply -754771634.E+716555026 -292336.311 -> 2.20647155E+716555040 Inexact Rounded +xpow069 power -754771634.E+716555026 -292336 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem069 remainder -754771634.E+716555026 -292336.311 -> NaN Division_impossible +xsub069 subtract -754771634.E+716555026 -292336.311 -> -7.54771634E+716555034 Inexact Rounded +xadd070 add -915006.171E+614548652 -314086965. -> -9.15006171E+614548657 Inexact Rounded +xcom070 compare -915006.171E+614548652 -314086965. -> -1 +xdiv070 divide -915006.171E+614548652 -314086965. -> 2.91322555E+614548649 Inexact Rounded +xdvi070 divideint -915006.171E+614548652 -314086965. -> NaN Division_impossible +xmul070 multiply -915006.171E+614548652 -314086965. -> 2.87391511E+614548666 Inexact Rounded +xpow070 power -915006.171E+614548652 -314086965 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem070 remainder -915006.171E+614548652 -314086965. -> NaN Division_impossible +xsub070 subtract -915006.171E+614548652 -314086965. -> -9.15006171E+614548657 Inexact Rounded +xadd071 add -296590035 -481734529 -> -778324564 +xcom071 compare -296590035 -481734529 -> 1 +xdiv071 divide -296590035 -481734529 -> 0.615671116 Inexact Rounded +xdvi071 divideint -296590035 -481734529 -> 0 +xmul071 multiply -296590035 -481734529 -> 1.42877661E+17 Inexact Rounded +xpow071 power -296590035 -481734529 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem071 remainder -296590035 -481734529 -> -296590035 +xsub071 subtract -296590035 -481734529 -> 185144494 +xadd072 add 8.27822605 9241557.19 -> 9241565.47 Inexact Rounded +xcom072 compare 8.27822605 9241557.19 -> -1 +xdiv072 divide 8.27822605 9241557.19 -> 8.95760950E-7 Inexact Rounded +xdvi072 divideint 8.27822605 9241557.19 -> 0 +xmul072 multiply 8.27822605 9241557.19 -> 76503699.5 Inexact Rounded +xpow072 power 8.27822605 9241557 -> 5.10219969E+8483169 Inexact Rounded +xrem072 remainder 8.27822605 9241557.19 -> 8.27822605 +xsub072 subtract 8.27822605 9241557.19 -> -9241548.91 Inexact Rounded +xadd073 add -1.43581098 7286313.54 -> 7286312.10 Inexact Rounded +xcom073 compare -1.43581098 7286313.54 -> -1 +xdiv073 divide -1.43581098 7286313.54 -> -1.97055887E-7 Inexact Rounded +xdvi073 divideint -1.43581098 7286313.54 -> -0 +xmul073 multiply -1.43581098 7286313.54 -> -10461769.0 Inexact Rounded +xpow073 power -1.43581098 7286314 -> 1.09389741E+1144660 Inexact Rounded +xrem073 remainder -1.43581098 7286313.54 -> -1.43581098 +xsub073 subtract -1.43581098 7286313.54 -> -7286314.98 Inexact Rounded +xadd074 add -699036193. 759263.509E+533543625 -> 7.59263509E+533543630 Inexact Rounded +xcom074 compare -699036193. 759263.509E+533543625 -> -1 +xdiv074 divide -699036193. 759263.509E+533543625 -> -9.20676662E-533543623 Inexact Rounded +xdvi074 divideint -699036193. 759263.509E+533543625 -> -0 +xmul074 multiply -699036193. 759263.509E+533543625 -> -5.30752673E+533543639 Inexact Rounded +xpow074 power -699036193. 8 -> 5.70160724E+70 Inexact Rounded +xrem074 remainder -699036193. 759263.509E+533543625 -> -699036193 +xsub074 subtract -699036193. 759263.509E+533543625 -> -7.59263509E+533543630 Inexact Rounded +xadd075 add -83.7273615E-305281957 -287779593.E+458777774 -> -2.87779593E+458777782 Inexact Rounded +xcom075 compare -83.7273615E-305281957 -287779593.E+458777774 -> 1 +xdiv075 divide -83.7273615E-305281957 -287779593.E+458777774 -> 2.90942664E-764059738 Inexact Rounded +xdvi075 divideint -83.7273615E-305281957 -287779593.E+458777774 -> 0 +xmul075 multiply -83.7273615E-305281957 -287779593.E+458777774 -> 2.40950260E+153495827 Inexact Rounded +xpow075 power -83.7273615E-305281957 -3 -> -1.70371828E+915845865 Inexact Rounded +xrem075 remainder -83.7273615E-305281957 -287779593.E+458777774 -> -8.37273615E-305281956 +xsub075 subtract -83.7273615E-305281957 -287779593.E+458777774 -> 2.87779593E+458777782 Inexact Rounded +xadd076 add 8.48503224 6522.03316 -> 6530.51819 Inexact Rounded +xcom076 compare 8.48503224 6522.03316 -> -1 +xdiv076 divide 8.48503224 6522.03316 -> 0.00130097962 Inexact Rounded +xdvi076 divideint 8.48503224 6522.03316 -> 0 +xmul076 multiply 8.48503224 6522.03316 -> 55339.6616 Inexact Rounded +xpow076 power 8.48503224 6522 -> 4.76547542E+6056 Inexact Rounded +xrem076 remainder 8.48503224 6522.03316 -> 8.48503224 +xsub076 subtract 8.48503224 6522.03316 -> -6513.54813 Inexact Rounded +xadd077 add 527916091 -809.054070 -> 527915282 Inexact Rounded +xcom077 compare 527916091 -809.054070 -> 1 +xdiv077 divide 527916091 -809.054070 -> -652510.272 Inexact Rounded +xdvi077 divideint 527916091 -809.054070 -> -652510 +xmul077 multiply 527916091 -809.054070 -> -4.27112662E+11 Inexact Rounded +xpow077 power 527916091 -809 -> 2.78609697E-7057 Inexact Rounded +xrem077 remainder 527916091 -809.054070 -> 219.784300 +xsub077 subtract 527916091 -809.054070 -> 527916900 Inexact Rounded +xadd078 add 3857058.60 5792997.58E+881077409 -> 5.79299758E+881077415 Inexact Rounded +xcom078 compare 3857058.60 5792997.58E+881077409 -> -1 +xdiv078 divide 3857058.60 5792997.58E+881077409 -> 6.65813950E-881077410 Inexact Rounded +xdvi078 divideint 3857058.60 5792997.58E+881077409 -> 0 +xmul078 multiply 3857058.60 5792997.58E+881077409 -> 2.23439311E+881077422 Inexact Rounded +xpow078 power 3857058.60 6 -> 3.29258824E+39 Inexact Rounded +xrem078 remainder 3857058.60 5792997.58E+881077409 -> 3857058.60 +xsub078 subtract 3857058.60 5792997.58E+881077409 -> -5.79299758E+881077415 Inexact Rounded +xadd079 add -66587363.E+556538173 -551902402E+357309146 -> -6.65873630E+556538180 Inexact Rounded +xcom079 compare -66587363.E+556538173 -551902402E+357309146 -> -1 +xdiv079 divide -66587363.E+556538173 -551902402E+357309146 -> 1.20650613E+199229026 Inexact Rounded +xdvi079 divideint -66587363.E+556538173 -551902402E+357309146 -> NaN Division_impossible +xmul079 multiply -66587363.E+556538173 -551902402E+357309146 -> 3.67497256E+913847335 Inexact Rounded +xpow079 power -66587363.E+556538173 -6 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem079 remainder -66587363.E+556538173 -551902402E+357309146 -> NaN Division_impossible +xsub079 subtract -66587363.E+556538173 -551902402E+357309146 -> -6.65873630E+556538180 Inexact Rounded +xadd080 add -580.502955 38125521.7 -> 38124941.2 Inexact Rounded +xcom080 compare -580.502955 38125521.7 -> -1 +xdiv080 divide -580.502955 38125521.7 -> -0.0000152260987 Inexact Rounded +xdvi080 divideint -580.502955 38125521.7 -> -0 +xmul080 multiply -580.502955 38125521.7 -> -2.21319780E+10 Inexact Rounded +xpow080 power -580.502955 38125522 -> 6.07262078E+105371486 Inexact Rounded +xrem080 remainder -580.502955 38125521.7 -> -580.502955 +xsub080 subtract -580.502955 38125521.7 -> -38126102.2 Inexact Rounded +xadd081 add -9627363.00 -80616885E-749891394 -> -9627363.00 Inexact Rounded +xcom081 compare -9627363.00 -80616885E-749891394 -> -1 +xdiv081 divide -9627363.00 -80616885E-749891394 -> 1.19421173E+749891393 Inexact Rounded +xdvi081 divideint -9627363.00 -80616885E-749891394 -> NaN Division_impossible +xmul081 multiply -9627363.00 -80616885E-749891394 -> 7.76128016E-749891380 Inexact Rounded +xpow081 power -9627363.00 -8 -> 1.35500601E-56 Inexact Rounded +xrem081 remainder -9627363.00 -80616885E-749891394 -> NaN Division_impossible +xsub081 subtract -9627363.00 -80616885E-749891394 -> -9627363.00 Inexact Rounded +xadd082 add -526.594855E+803110107 -64.5451639 -> -5.26594855E+803110109 Inexact Rounded +xcom082 compare -526.594855E+803110107 -64.5451639 -> -1 +xdiv082 divide -526.594855E+803110107 -64.5451639 -> 8.15854858E+803110107 Inexact Rounded +xdvi082 divideint -526.594855E+803110107 -64.5451639 -> NaN Division_impossible +xmul082 multiply -526.594855E+803110107 -64.5451639 -> 3.39891512E+803110111 Inexact Rounded +xpow082 power -526.594855E+803110107 -65 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem082 remainder -526.594855E+803110107 -64.5451639 -> NaN Division_impossible +xsub082 subtract -526.594855E+803110107 -64.5451639 -> -5.26594855E+803110109 Inexact Rounded +xadd083 add -8378.55499 760.131257 -> -7618.42373 Inexact Rounded +xcom083 compare -8378.55499 760.131257 -> -1 +xdiv083 divide -8378.55499 760.131257 -> -11.0225108 Inexact Rounded +xdvi083 divideint -8378.55499 760.131257 -> -11 +xmul083 multiply -8378.55499 760.131257 -> -6368801.54 Inexact Rounded +xpow083 power -8378.55499 760 -> 4.06007928E+2981 Inexact Rounded +xrem083 remainder -8378.55499 760.131257 -> -17.111163 +xsub083 subtract -8378.55499 760.131257 -> -9138.68625 Inexact Rounded +xadd084 add -717.697718 984304413 -> 984303695 Inexact Rounded +xcom084 compare -717.697718 984304413 -> -1 +xdiv084 divide -717.697718 984304413 -> -7.29142030E-7 Inexact Rounded +xdvi084 divideint -717.697718 984304413 -> -0 +xmul084 multiply -717.697718 984304413 -> -7.06433031E+11 Inexact Rounded +xpow084 power -717.697718 984304413 -> -Infinity Overflow Inexact Rounded +xrem084 remainder -717.697718 984304413 -> -717.697718 +xsub084 subtract -717.697718 984304413 -> -984305131 Inexact Rounded +xadd085 add -76762243.4E-741100094 -273.706674 -> -273.706674 Inexact Rounded +xcom085 compare -76762243.4E-741100094 -273.706674 -> 1 +xdiv085 divide -76762243.4E-741100094 -273.706674 -> 2.80454409E-741100089 Inexact Rounded +xdvi085 divideint -76762243.4E-741100094 -273.706674 -> 0 +xmul085 multiply -76762243.4E-741100094 -273.706674 -> 2.10103383E-741100084 Inexact Rounded +xpow085 power -76762243.4E-741100094 -274 -> Infinity Overflow Inexact Rounded +xrem085 remainder -76762243.4E-741100094 -273.706674 -> -7.67622434E-741100087 +xsub085 subtract -76762243.4E-741100094 -273.706674 -> 273.706674 Inexact Rounded +xadd086 add -701.518354E+786274918 8822750.68E+243052107 -> -7.01518354E+786274920 Inexact Rounded +xcom086 compare -701.518354E+786274918 8822750.68E+243052107 -> -1 +xdiv086 divide -701.518354E+786274918 8822750.68E+243052107 -> -7.95124309E+543222806 Inexact Rounded +xdvi086 divideint -701.518354E+786274918 8822750.68E+243052107 -> NaN Division_impossible +xmul086 multiply -701.518354E+786274918 8822750.68E+243052107 -> -Infinity Inexact Overflow Rounded +xpow086 power -701.518354E+786274918 9 -> -Infinity Overflow Inexact Rounded +xrem086 remainder -701.518354E+786274918 8822750.68E+243052107 -> NaN Division_impossible +xsub086 subtract -701.518354E+786274918 8822750.68E+243052107 -> -7.01518354E+786274920 Inexact Rounded +xadd087 add -359866845. -4.57434117 -> -359866850 Inexact Rounded +xcom087 compare -359866845. -4.57434117 -> -1 +xdiv087 divide -359866845. -4.57434117 -> 78670748.8 Inexact Rounded +xdvi087 divideint -359866845. -4.57434117 -> 78670748 +xmul087 multiply -359866845. -4.57434117 -> 1.64615372E+9 Inexact Rounded +xpow087 power -359866845. -5 -> -1.65687909E-43 Inexact Rounded +xrem087 remainder -359866845. -4.57434117 -> -3.54890484 +xsub087 subtract -359866845. -4.57434117 -> -359866840 Inexact Rounded +xadd088 add 779934536. -76562645.7 -> 703371890 Inexact Rounded +xcom088 compare 779934536. -76562645.7 -> 1 +xdiv088 divide 779934536. -76562645.7 -> -10.1868807 Inexact Rounded +xdvi088 divideint 779934536. -76562645.7 -> -10 +xmul088 multiply 779934536. -76562645.7 -> -5.97138515E+16 Inexact Rounded +xpow088 power 779934536. -76562646 -> 3.36739063E-680799501 Inexact Rounded +xrem088 remainder 779934536. -76562645.7 -> 14308079.0 +xsub088 subtract 779934536. -76562645.7 -> 856497182 Inexact Rounded +xadd089 add -4820.95451 3516234.99E+303303176 -> 3.51623499E+303303182 Inexact Rounded +xcom089 compare -4820.95451 3516234.99E+303303176 -> -1 +xdiv089 divide -4820.95451 3516234.99E+303303176 -> -1.37105584E-303303179 Inexact Rounded +xdvi089 divideint -4820.95451 3516234.99E+303303176 -> -0 +xmul089 multiply -4820.95451 3516234.99E+303303176 -> -1.69516089E+303303186 Inexact Rounded +xpow089 power -4820.95451 4 -> 5.40172082E+14 Inexact Rounded +xrem089 remainder -4820.95451 3516234.99E+303303176 -> -4820.95451 +xsub089 subtract -4820.95451 3516234.99E+303303176 -> -3.51623499E+303303182 Inexact Rounded +xadd090 add 69355976.9 -9.57838562E+758804984 -> -9.57838562E+758804984 Inexact Rounded +xcom090 compare 69355976.9 -9.57838562E+758804984 -> 1 +xdiv090 divide 69355976.9 -9.57838562E+758804984 -> -7.24088376E-758804978 Inexact Rounded +xdvi090 divideint 69355976.9 -9.57838562E+758804984 -> -0 +xmul090 multiply 69355976.9 -9.57838562E+758804984 -> -6.64318292E+758804992 Inexact Rounded +xpow090 power 69355976.9 -10 -> 3.88294346E-79 Inexact Rounded +xrem090 remainder 69355976.9 -9.57838562E+758804984 -> 69355976.9 +xsub090 subtract 69355976.9 -9.57838562E+758804984 -> 9.57838562E+758804984 Inexact Rounded +xadd091 add -12672093.1 8569.78255E-382866025 -> -12672093.1 Inexact Rounded +xcom091 compare -12672093.1 8569.78255E-382866025 -> -1 +xdiv091 divide -12672093.1 8569.78255E-382866025 -> -1.47869482E+382866028 Inexact Rounded +xdvi091 divideint -12672093.1 8569.78255E-382866025 -> NaN Division_impossible +xmul091 multiply -12672093.1 8569.78255E-382866025 -> -1.08597082E-382866014 Inexact Rounded +xpow091 power -12672093.1 9 -> -8.42626658E+63 Inexact Rounded +xrem091 remainder -12672093.1 8569.78255E-382866025 -> NaN Division_impossible +xsub091 subtract -12672093.1 8569.78255E-382866025 -> -12672093.1 Inexact Rounded +xadd092 add -5910750.2 66150383E-662459241 -> -5910750.20 Inexact Rounded +xcom092 compare -5910750.2 66150383E-662459241 -> -1 +xdiv092 divide -5910750.2 66150383E-662459241 -> -8.93532272E+662459239 Inexact Rounded +xdvi092 divideint -5910750.2 66150383E-662459241 -> NaN Division_impossible +xmul092 multiply -5910750.2 66150383E-662459241 -> -3.90998390E-662459227 Inexact Rounded +xpow092 power -5910750.2 7 -> -2.52056696E+47 Inexact Rounded +xrem092 remainder -5910750.2 66150383E-662459241 -> NaN Division_impossible +xsub092 subtract -5910750.2 66150383E-662459241 -> -5910750.20 Inexact Rounded +xadd093 add -532577268.E-163806629 -240650398E-650110558 -> -5.32577268E-163806621 Inexact Rounded +xcom093 compare -532577268.E-163806629 -240650398E-650110558 -> -1 +xdiv093 divide -532577268.E-163806629 -240650398E-650110558 -> 2.21307454E+486303929 Inexact Rounded +xdvi093 divideint -532577268.E-163806629 -240650398E-650110558 -> NaN Division_impossible +xmul093 multiply -532577268.E-163806629 -240650398E-650110558 -> 1.28164932E-813917170 Inexact Rounded +xpow093 power -532577268.E-163806629 -2 -> 3.52561389E+327613240 Inexact Rounded +xrem093 remainder -532577268.E-163806629 -240650398E-650110558 -> NaN Division_impossible +xsub093 subtract -532577268.E-163806629 -240650398E-650110558 -> -5.32577268E-163806621 Inexact Rounded +xadd094 add -671.507198E-908587890 3057429.32E-555230623 -> 3.05742932E-555230617 Inexact Rounded +xcom094 compare -671.507198E-908587890 3057429.32E-555230623 -> -1 +xdiv094 divide -671.507198E-908587890 3057429.32E-555230623 -> -2.19631307E-353357271 Inexact Rounded +xdvi094 divideint -671.507198E-908587890 3057429.32E-555230623 -> -0 +xmul094 multiply -671.507198E-908587890 3057429.32E-555230623 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow094 power -671.507198E-908587890 3 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem094 remainder -671.507198E-908587890 3057429.32E-555230623 -> -6.71507198E-908587888 +xsub094 subtract -671.507198E-908587890 3057429.32E-555230623 -> -3.05742932E-555230617 Inexact Rounded +xadd095 add -294.994352E+346452027 -6061853.0 -> -2.94994352E+346452029 Inexact Rounded +xcom095 compare -294.994352E+346452027 -6061853.0 -> -1 +xdiv095 divide -294.994352E+346452027 -6061853.0 -> 4.86640557E+346452022 Inexact Rounded +xdvi095 divideint -294.994352E+346452027 -6061853.0 -> NaN Division_impossible +xmul095 multiply -294.994352E+346452027 -6061853.0 -> 1.78821240E+346452036 Inexact Rounded +xpow095 power -294.994352E+346452027 -6061853 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem095 remainder -294.994352E+346452027 -6061853.0 -> NaN Division_impossible +xsub095 subtract -294.994352E+346452027 -6061853.0 -> -2.94994352E+346452029 Inexact Rounded +xadd096 add 329579114 146780548. -> 476359662 +xcom096 compare 329579114 146780548. -> 1 +xdiv096 divide 329579114 146780548. -> 2.24538686 Inexact Rounded +xdvi096 divideint 329579114 146780548. -> 2 +xmul096 multiply 329579114 146780548. -> 4.83758030E+16 Inexact Rounded +xpow096 power 329579114 146780548 -> Infinity Overflow Inexact Rounded +xrem096 remainder 329579114 146780548. -> 36018018 +xsub096 subtract 329579114 146780548. -> 182798566 +xadd097 add -789904.686E-217225000 -1991.07181E-84080059 -> -1.99107181E-84080056 Inexact Rounded +xcom097 compare -789904.686E-217225000 -1991.07181E-84080059 -> 1 +xdiv097 divide -789904.686E-217225000 -1991.07181E-84080059 -> 3.96723354E-133144939 Inexact Rounded +xdvi097 divideint -789904.686E-217225000 -1991.07181E-84080059 -> 0 +xmul097 multiply -789904.686E-217225000 -1991.07181E-84080059 -> 1.57275695E-301305050 Inexact Rounded +xpow097 power -789904.686E-217225000 -2 -> 1.60269403E+434449988 Inexact Rounded +xrem097 remainder -789904.686E-217225000 -1991.07181E-84080059 -> -7.89904686E-217224995 +xsub097 subtract -789904.686E-217225000 -1991.07181E-84080059 -> 1.99107181E-84080056 Inexact Rounded +xadd098 add 59893.3544 -408595868 -> -408535975 Inexact Rounded +xcom098 compare 59893.3544 -408595868 -> 1 +xdiv098 divide 59893.3544 -408595868 -> -0.000146583358 Inexact Rounded +xdvi098 divideint 59893.3544 -408595868 -> -0 +xmul098 multiply 59893.3544 -408595868 -> -2.44721771E+13 Inexact Rounded +xpow098 power 59893.3544 -408595868 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem098 remainder 59893.3544 -408595868 -> 59893.3544 +xsub098 subtract 59893.3544 -408595868 -> 408655761 Inexact Rounded +xadd099 add 129.878613 -54652.7288E-963564940 -> 129.878613 Inexact Rounded +xcom099 compare 129.878613 -54652.7288E-963564940 -> 1 +xdiv099 divide 129.878613 -54652.7288E-963564940 -> -2.37643418E+963564937 Inexact Rounded +xdvi099 divideint 129.878613 -54652.7288E-963564940 -> NaN Division_impossible +xmul099 multiply 129.878613 -54652.7288E-963564940 -> -7.09822061E-963564934 Inexact Rounded +xpow099 power 129.878613 -5 -> 2.70590029E-11 Inexact Rounded +xrem099 remainder 129.878613 -54652.7288E-963564940 -> NaN Division_impossible +xsub099 subtract 129.878613 -54652.7288E-963564940 -> 129.878613 Inexact Rounded +xadd100 add 9866.99208 708756501. -> 708766368 Inexact Rounded +xcom100 compare 9866.99208 708756501. -> -1 +xdiv100 divide 9866.99208 708756501. -> 0.0000139215543 Inexact Rounded +xdvi100 divideint 9866.99208 708756501. -> 0 +xmul100 multiply 9866.99208 708756501. -> 6.99329478E+12 Inexact Rounded +xpow100 power 9866.99208 708756501 -> Infinity Overflow Inexact Rounded +xrem100 remainder 9866.99208 708756501. -> 9866.99208 +xsub100 subtract 9866.99208 708756501. -> -708746634 Inexact Rounded +xadd101 add -78810.6297 -399884.68 -> -478695.310 Inexact Rounded +xcom101 compare -78810.6297 -399884.68 -> 1 +xdiv101 divide -78810.6297 -399884.68 -> 0.197083393 Inexact Rounded +xdvi101 divideint -78810.6297 -399884.68 -> 0 +xmul101 multiply -78810.6297 -399884.68 -> 3.15151634E+10 Inexact Rounded +xpow101 power -78810.6297 -399885 -> -1.54252408E-1958071 Inexact Rounded +xrem101 remainder -78810.6297 -399884.68 -> -78810.6297 +xsub101 subtract -78810.6297 -399884.68 -> 321074.050 Inexact Rounded +xadd102 add 409189761 -771.471460 -> 409188990 Inexact Rounded +xcom102 compare 409189761 -771.471460 -> 1 +xdiv102 divide 409189761 -771.471460 -> -530401.683 Inexact Rounded +xdvi102 divideint 409189761 -771.471460 -> -530401 +xmul102 multiply 409189761 -771.471460 -> -3.15678222E+11 Inexact Rounded +xpow102 power 409189761 -771 -> 1.60698414E-6640 Inexact Rounded +xrem102 remainder 409189761 -771.471460 -> 527.144540 +xsub102 subtract 409189761 -771.471460 -> 409190532 Inexact Rounded +xadd103 add -1.68748838 460.46924 -> 458.781752 Inexact Rounded +xcom103 compare -1.68748838 460.46924 -> -1 +xdiv103 divide -1.68748838 460.46924 -> -0.00366471467 Inexact Rounded +xdvi103 divideint -1.68748838 460.46924 -> -0 +xmul103 multiply -1.68748838 460.46924 -> -777.036492 Inexact Rounded +xpow103 power -1.68748838 460 -> 3.39440648E+104 Inexact Rounded +xrem103 remainder -1.68748838 460.46924 -> -1.68748838 +xsub103 subtract -1.68748838 460.46924 -> -462.156728 Inexact Rounded +xadd104 add 553527296. -7924.40185 -> 553519372 Inexact Rounded +xcom104 compare 553527296. -7924.40185 -> 1 +xdiv104 divide 553527296. -7924.40185 -> -69850.9877 Inexact Rounded +xdvi104 divideint 553527296. -7924.40185 -> -69850 +xmul104 multiply 553527296. -7924.40185 -> -4.38637273E+12 Inexact Rounded +xpow104 power 553527296. -7924 -> 2.32397213E-69281 Inexact Rounded +xrem104 remainder 553527296. -7924.40185 -> 7826.77750 +xsub104 subtract 553527296. -7924.40185 -> 553535220 Inexact Rounded +xadd105 add -38.7465207 64936.2942 -> 64897.5477 Inexact Rounded +xcom105 compare -38.7465207 64936.2942 -> -1 +xdiv105 divide -38.7465207 64936.2942 -> -0.000596685123 Inexact Rounded +xdvi105 divideint -38.7465207 64936.2942 -> -0 +xmul105 multiply -38.7465207 64936.2942 -> -2516055.47 Inexact Rounded +xpow105 power -38.7465207 64936 -> 3.01500762E+103133 Inexact Rounded +xrem105 remainder -38.7465207 64936.2942 -> -38.7465207 +xsub105 subtract -38.7465207 64936.2942 -> -64975.0407 Inexact Rounded +xadd106 add -201075.248 845.663928 -> -200229.584 Inexact Rounded +xcom106 compare -201075.248 845.663928 -> -1 +xdiv106 divide -201075.248 845.663928 -> -237.772053 Inexact Rounded +xdvi106 divideint -201075.248 845.663928 -> -237 +xmul106 multiply -201075.248 845.663928 -> -170042084 Inexact Rounded +xpow106 power -201075.248 846 -> 4.37911767E+4486 Inexact Rounded +xrem106 remainder -201075.248 845.663928 -> -652.897064 +xsub106 subtract -201075.248 845.663928 -> -201920.912 Inexact Rounded +xadd107 add 91048.4559 75953609.3 -> 76044657.8 Inexact Rounded +xcom107 compare 91048.4559 75953609.3 -> -1 +xdiv107 divide 91048.4559 75953609.3 -> 0.00119873771 Inexact Rounded +xdvi107 divideint 91048.4559 75953609.3 -> 0 +xmul107 multiply 91048.4559 75953609.3 -> 6.91545885E+12 Inexact Rounded +xpow107 power 91048.4559 75953609 -> 6.94467746E+376674650 Inexact Rounded +xrem107 remainder 91048.4559 75953609.3 -> 91048.4559 +xsub107 subtract 91048.4559 75953609.3 -> -75862560.8 Inexact Rounded +xadd108 add 6898273.86E-252097460 15.3456196 -> 15.3456196 Inexact Rounded +xcom108 compare 6898273.86E-252097460 15.3456196 -> -1 +xdiv108 divide 6898273.86E-252097460 15.3456196 -> 4.49527229E-252097455 Inexact Rounded +xdvi108 divideint 6898273.86E-252097460 15.3456196 -> 0 +xmul108 multiply 6898273.86E-252097460 15.3456196 -> 1.05858287E-252097452 Inexact Rounded +xpow108 power 6898273.86E-252097460 15 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem108 remainder 6898273.86E-252097460 15.3456196 -> 6.89827386E-252097454 +xsub108 subtract 6898273.86E-252097460 15.3456196 -> -15.3456196 Inexact Rounded +xadd109 add 88.4370343 -980709105E-869899289 -> 88.4370343 Inexact Rounded +xcom109 compare 88.4370343 -980709105E-869899289 -> 1 +xdiv109 divide 88.4370343 -980709105E-869899289 -> -9.01766220E+869899281 Inexact Rounded +xdvi109 divideint 88.4370343 -980709105E-869899289 -> NaN Division_impossible +xmul109 multiply 88.4370343 -980709105E-869899289 -> -8.67310048E-869899279 Inexact Rounded +xpow109 power 88.4370343 -10 -> 3.41710479E-20 Inexact Rounded +xrem109 remainder 88.4370343 -980709105E-869899289 -> NaN Division_impossible +xsub109 subtract 88.4370343 -980709105E-869899289 -> 88.4370343 Inexact Rounded +xadd110 add -17643.39 2.0352568E+304871331 -> 2.03525680E+304871331 Inexact Rounded +xcom110 compare -17643.39 2.0352568E+304871331 -> -1 +xdiv110 divide -17643.39 2.0352568E+304871331 -> -8.66887658E-304871328 Inexact Rounded +xdvi110 divideint -17643.39 2.0352568E+304871331 -> -0 +xmul110 multiply -17643.39 2.0352568E+304871331 -> -3.59088295E+304871335 Inexact Rounded +xpow110 power -17643.39 2 -> 311289211 Inexact Rounded +xrem110 remainder -17643.39 2.0352568E+304871331 -> -17643.39 +xsub110 subtract -17643.39 2.0352568E+304871331 -> -2.03525680E+304871331 Inexact Rounded +xadd111 add 4589785.16 7459.04237 -> 4597244.20 Inexact Rounded +xcom111 compare 4589785.16 7459.04237 -> 1 +xdiv111 divide 4589785.16 7459.04237 -> 615.331692 Inexact Rounded +xdvi111 divideint 4589785.16 7459.04237 -> 615 +xmul111 multiply 4589785.16 7459.04237 -> 3.42354020E+10 Inexact Rounded +xpow111 power 4589785.16 7459 -> 2.03795258E+49690 Inexact Rounded +xrem111 remainder 4589785.16 7459.04237 -> 2474.10245 +xsub111 subtract 4589785.16 7459.04237 -> 4582326.12 Inexact Rounded +xadd112 add -51.1632090E-753968082 8.96207471E-585797887 -> 8.96207471E-585797887 Inexact Rounded +xcom112 compare -51.1632090E-753968082 8.96207471E-585797887 -> -1 +xdiv112 divide -51.1632090E-753968082 8.96207471E-585797887 -> -5.70885768E-168170195 Inexact Rounded +xdvi112 divideint -51.1632090E-753968082 8.96207471E-585797887 -> -0 +xmul112 multiply -51.1632090E-753968082 8.96207471E-585797887 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow112 power -51.1632090E-753968082 9 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem112 remainder -51.1632090E-753968082 8.96207471E-585797887 -> -5.11632090E-753968081 +xsub112 subtract -51.1632090E-753968082 8.96207471E-585797887 -> -8.96207471E-585797887 Inexact Rounded +xadd113 add 982.217817 7224909.4E-45243816 -> 982.217817 Inexact Rounded +xcom113 compare 982.217817 7224909.4E-45243816 -> 1 +xdiv113 divide 982.217817 7224909.4E-45243816 -> 1.35948807E+45243812 Inexact Rounded +xdvi113 divideint 982.217817 7224909.4E-45243816 -> NaN Division_impossible +xmul113 multiply 982.217817 7224909.4E-45243816 -> 7.09643474E-45243807 Inexact Rounded +xpow113 power 982.217817 7 -> 8.81971709E+20 Inexact Rounded +xrem113 remainder 982.217817 7224909.4E-45243816 -> NaN Division_impossible +xsub113 subtract 982.217817 7224909.4E-45243816 -> 982.217817 Inexact Rounded +xadd114 add 503712056. -57490703.5E+924890183 -> -5.74907035E+924890190 Inexact Rounded +xcom114 compare 503712056. -57490703.5E+924890183 -> 1 +xdiv114 divide 503712056. -57490703.5E+924890183 -> -8.76162623E-924890183 Inexact Rounded +xdvi114 divideint 503712056. -57490703.5E+924890183 -> -0 +xmul114 multiply 503712056. -57490703.5E+924890183 -> -2.89587605E+924890199 Inexact Rounded +xpow114 power 503712056. -6 -> 6.12217764E-53 Inexact Rounded +xrem114 remainder 503712056. -57490703.5E+924890183 -> 503712056 +xsub114 subtract 503712056. -57490703.5E+924890183 -> 5.74907035E+924890190 Inexact Rounded +xadd115 add 883.849223 249259171 -> 249260055 Inexact Rounded +xcom115 compare 883.849223 249259171 -> -1 +xdiv115 divide 883.849223 249259171 -> 0.00000354590453 Inexact Rounded +xdvi115 divideint 883.849223 249259171 -> 0 +xmul115 multiply 883.849223 249259171 -> 2.20307525E+11 Inexact Rounded +xpow115 power 883.849223 249259171 -> 5.15642844E+734411783 Inexact Rounded +xrem115 remainder 883.849223 249259171 -> 883.849223 +xsub115 subtract 883.849223 249259171 -> -249258287 Inexact Rounded +xadd116 add 245.092853E+872642874 828195.152E+419771532 -> 2.45092853E+872642876 Inexact Rounded +xcom116 compare 245.092853E+872642874 828195.152E+419771532 -> 1 +xdiv116 divide 245.092853E+872642874 828195.152E+419771532 -> 2.95936112E+452871338 Inexact Rounded +xdvi116 divideint 245.092853E+872642874 828195.152E+419771532 -> NaN Division_impossible +xmul116 multiply 245.092853E+872642874 828195.152E+419771532 -> Infinity Inexact Overflow Rounded +xpow116 power 245.092853E+872642874 8 -> Infinity Overflow Inexact Rounded +xrem116 remainder 245.092853E+872642874 828195.152E+419771532 -> NaN Division_impossible +xsub116 subtract 245.092853E+872642874 828195.152E+419771532 -> 2.45092853E+872642876 Inexact Rounded +xadd117 add -83658638.6E+728551928 2952478.42 -> -8.36586386E+728551935 Inexact Rounded +xcom117 compare -83658638.6E+728551928 2952478.42 -> -1 +xdiv117 divide -83658638.6E+728551928 2952478.42 -> -2.83350551E+728551929 Inexact Rounded +xdvi117 divideint -83658638.6E+728551928 2952478.42 -> NaN Division_impossible +xmul117 multiply -83658638.6E+728551928 2952478.42 -> -2.47000325E+728551942 Inexact Rounded +xpow117 power -83658638.6E+728551928 2952478 -> Infinity Overflow Inexact Rounded +xrem117 remainder -83658638.6E+728551928 2952478.42 -> NaN Division_impossible +xsub117 subtract -83658638.6E+728551928 2952478.42 -> -8.36586386E+728551935 Inexact Rounded +xadd118 add -6291780.97 269967.394E-22000817 -> -6291780.97 Inexact Rounded +xcom118 compare -6291780.97 269967.394E-22000817 -> -1 +xdiv118 divide -6291780.97 269967.394E-22000817 -> -2.33057069E+22000818 Inexact Rounded +xdvi118 divideint -6291780.97 269967.394E-22000817 -> NaN Division_impossible +xmul118 multiply -6291780.97 269967.394E-22000817 -> -1.69857571E-22000805 Inexact Rounded +xpow118 power -6291780.97 3 -> -2.49069636E+20 Inexact Rounded +xrem118 remainder -6291780.97 269967.394E-22000817 -> NaN Division_impossible +xsub118 subtract -6291780.97 269967.394E-22000817 -> -6291780.97 Inexact Rounded +xadd119 add 978571348.E+222382547 6006.19370 -> 9.78571348E+222382555 Inexact Rounded +xcom119 compare 978571348.E+222382547 6006.19370 -> 1 +xdiv119 divide 978571348.E+222382547 6006.19370 -> 1.62927038E+222382552 Inexact Rounded +xdvi119 divideint 978571348.E+222382547 6006.19370 -> NaN Division_impossible +xmul119 multiply 978571348.E+222382547 6006.19370 -> 5.87748907E+222382559 Inexact Rounded +xpow119 power 978571348.E+222382547 6006 -> Infinity Overflow Inexact Rounded +xrem119 remainder 978571348.E+222382547 6006.19370 -> NaN Division_impossible +xsub119 subtract 978571348.E+222382547 6006.19370 -> 9.78571348E+222382555 Inexact Rounded +xadd120 add 14239029. -36527.2221 -> 14202501.8 Inexact Rounded +xcom120 compare 14239029. -36527.2221 -> 1 +xdiv120 divide 14239029. -36527.2221 -> -389.819652 Inexact Rounded +xdvi120 divideint 14239029. -36527.2221 -> -389 +xmul120 multiply 14239029. -36527.2221 -> -5.20112175E+11 Inexact Rounded +xpow120 power 14239029. -36527 -> 6.64292731E-261296 Inexact Rounded +xrem120 remainder 14239029. -36527.2221 -> 29939.6031 +xsub120 subtract 14239029. -36527.2221 -> 14275556.2 Inexact Rounded +xadd121 add 72333.2654E-544425548 -690.664836E+662155120 -> -6.90664836E+662155122 Inexact Rounded +xcom121 compare 72333.2654E-544425548 -690.664836E+662155120 -> 1 +xdiv121 divide 72333.2654E-544425548 -690.664836E+662155120 -> -0E-1000000007 Inexact Rounded Underflow Subnormal +xdvi121 divideint 72333.2654E-544425548 -690.664836E+662155120 -> -0 +xmul121 multiply 72333.2654E-544425548 -690.664836E+662155120 -> -4.99580429E+117729579 Inexact Rounded +xpow121 power 72333.2654E-544425548 -7 -> Infinity Overflow Inexact Rounded +xrem121 remainder 72333.2654E-544425548 -690.664836E+662155120 -> 7.23332654E-544425544 +xsub121 subtract 72333.2654E-544425548 -690.664836E+662155120 -> 6.90664836E+662155122 Inexact Rounded +xadd122 add -37721.1567E-115787341 -828949864E-76251747 -> -8.28949864E-76251739 Inexact Rounded +xcom122 compare -37721.1567E-115787341 -828949864E-76251747 -> 1 +xdiv122 divide -37721.1567E-115787341 -828949864E-76251747 -> 4.55047505E-39535599 Inexact Rounded +xdvi122 divideint -37721.1567E-115787341 -828949864E-76251747 -> 0 +xmul122 multiply -37721.1567E-115787341 -828949864E-76251747 -> 3.12689477E-192039075 Inexact Rounded +xpow122 power -37721.1567E-115787341 -8 -> 2.43960765E+926298691 Inexact Rounded +xrem122 remainder -37721.1567E-115787341 -828949864E-76251747 -> -3.77211567E-115787337 +xsub122 subtract -37721.1567E-115787341 -828949864E-76251747 -> 8.28949864E-76251739 Inexact Rounded +xadd123 add -2078852.83E-647080089 -119779858.E+734665461 -> -1.19779858E+734665469 Inexact Rounded +xcom123 compare -2078852.83E-647080089 -119779858.E+734665461 -> 1 +xdiv123 divide -2078852.83E-647080089 -119779858.E+734665461 -> 0E-1000000007 Inexact Rounded Underflow Subnormal +xdvi123 divideint -2078852.83E-647080089 -119779858.E+734665461 -> 0 +xmul123 multiply -2078852.83E-647080089 -119779858.E+734665461 -> 2.49004697E+87585386 Inexact Rounded +xpow123 power -2078852.83E-647080089 -1 -> -4.81034533E+647080082 Inexact Rounded +xrem123 remainder -2078852.83E-647080089 -119779858.E+734665461 -> -2.07885283E-647080083 +xsub123 subtract -2078852.83E-647080089 -119779858.E+734665461 -> 1.19779858E+734665469 Inexact Rounded +xadd124 add -79145.3625 -7718.57307 -> -86863.9356 Inexact Rounded +xcom124 compare -79145.3625 -7718.57307 -> -1 +xdiv124 divide -79145.3625 -7718.57307 -> 10.2538852 Inexact Rounded +xdvi124 divideint -79145.3625 -7718.57307 -> 10 +xmul124 multiply -79145.3625 -7718.57307 -> 610889264 Inexact Rounded +xpow124 power -79145.3625 -7719 -> -1.13181941E-37811 Inexact Rounded +xrem124 remainder -79145.3625 -7718.57307 -> -1959.63180 +xsub124 subtract -79145.3625 -7718.57307 -> -71426.7894 Inexact Rounded +xadd125 add 2103890.49E+959247237 20024.3017 -> 2.10389049E+959247243 Inexact Rounded +xcom125 compare 2103890.49E+959247237 20024.3017 -> 1 +xdiv125 divide 2103890.49E+959247237 20024.3017 -> 1.05066859E+959247239 Inexact Rounded +xdvi125 divideint 2103890.49E+959247237 20024.3017 -> NaN Division_impossible +xmul125 multiply 2103890.49E+959247237 20024.3017 -> 4.21289379E+959247247 Inexact Rounded +xpow125 power 2103890.49E+959247237 20024 -> Infinity Overflow Inexact Rounded +xrem125 remainder 2103890.49E+959247237 20024.3017 -> NaN Division_impossible +xsub125 subtract 2103890.49E+959247237 20024.3017 -> 2.10389049E+959247243 Inexact Rounded +xadd126 add 911249557 79810804.9 -> 991060362 Inexact Rounded +xcom126 compare 911249557 79810804.9 -> 1 +xdiv126 divide 911249557 79810804.9 -> 11.4176214 Inexact Rounded +xdvi126 divideint 911249557 79810804.9 -> 11 +xmul126 multiply 911249557 79810804.9 -> 7.27275606E+16 Inexact Rounded +xpow126 power 911249557 79810805 -> 6.77595741E+715075867 Inexact Rounded +xrem126 remainder 911249557 79810804.9 -> 33330703.1 +xsub126 subtract 911249557 79810804.9 -> 831438752 Inexact Rounded +xadd127 add 341134.994 3.37486292 -> 341138.369 Inexact Rounded +xcom127 compare 341134.994 3.37486292 -> 1 +xdiv127 divide 341134.994 3.37486292 -> 101081.141 Inexact Rounded +xdvi127 divideint 341134.994 3.37486292 -> 101081 +xmul127 multiply 341134.994 3.37486292 -> 1151283.84 Inexact Rounded +xpow127 power 341134.994 3 -> 3.96989314E+16 Inexact Rounded +xrem127 remainder 341134.994 3.37486292 -> 0.47518348 +xsub127 subtract 341134.994 3.37486292 -> 341131.619 Inexact Rounded +xadd128 add 244.23634 512706190E-341459836 -> 244.236340 Inexact Rounded +xcom128 compare 244.23634 512706190E-341459836 -> 1 +xdiv128 divide 244.23634 512706190E-341459836 -> 4.76367059E+341459829 Inexact Rounded +xdvi128 divideint 244.23634 512706190E-341459836 -> NaN Division_impossible +xmul128 multiply 244.23634 512706190E-341459836 -> 1.25221483E-341459825 Inexact Rounded +xpow128 power 244.23634 5 -> 8.69063312E+11 Inexact Rounded +xrem128 remainder 244.23634 512706190E-341459836 -> NaN Division_impossible +xsub128 subtract 244.23634 512706190E-341459836 -> 244.236340 Inexact Rounded +xadd129 add -9.22783849E+171585954 -99.0946800 -> -9.22783849E+171585954 Inexact Rounded +xcom129 compare -9.22783849E+171585954 -99.0946800 -> -1 +xdiv129 divide -9.22783849E+171585954 -99.0946800 -> 9.31214318E+171585952 Inexact Rounded +xdvi129 divideint -9.22783849E+171585954 -99.0946800 -> NaN Division_impossible +xmul129 multiply -9.22783849E+171585954 -99.0946800 -> 9.14429702E+171585956 Inexact Rounded +xpow129 power -9.22783849E+171585954 -99 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem129 remainder -9.22783849E+171585954 -99.0946800 -> NaN Division_impossible +xsub129 subtract -9.22783849E+171585954 -99.0946800 -> -9.22783849E+171585954 Inexact Rounded +xadd130 add 699631.893 -226.423958 -> 699405.469 Inexact Rounded +xcom130 compare 699631.893 -226.423958 -> 1 +xdiv130 divide 699631.893 -226.423958 -> -3089.91990 Inexact Rounded +xdvi130 divideint 699631.893 -226.423958 -> -3089 +xmul130 multiply 699631.893 -226.423958 -> -158413422 Inexact Rounded +xpow130 power 699631.893 -226 -> 1.14675511E-1321 Inexact Rounded +xrem130 remainder 699631.893 -226.423958 -> 208.286738 +xsub130 subtract 699631.893 -226.423958 -> 699858.317 Inexact Rounded +xadd131 add -249350139.E-571793673 775732428. -> 775732428 Inexact Rounded +xcom131 compare -249350139.E-571793673 775732428. -> -1 +xdiv131 divide -249350139.E-571793673 775732428. -> -3.21438334E-571793674 Inexact Rounded +xdvi131 divideint -249350139.E-571793673 775732428. -> -0 +xmul131 multiply -249350139.E-571793673 775732428. -> -1.93428989E-571793656 Inexact Rounded +xpow131 power -249350139.E-571793673 775732428 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem131 remainder -249350139.E-571793673 775732428. -> -2.49350139E-571793665 +xsub131 subtract -249350139.E-571793673 775732428. -> -775732428 Inexact Rounded +xadd132 add 5.11629020 -480.53194 -> -475.415650 Inexact Rounded +xcom132 compare 5.11629020 -480.53194 -> 1 +xdiv132 divide 5.11629020 -480.53194 -> -0.0106471387 Inexact Rounded +xdvi132 divideint 5.11629020 -480.53194 -> -0 +xmul132 multiply 5.11629020 -480.53194 -> -2458.54086 Inexact Rounded +xpow132 power 5.11629020 -481 -> 9.83021951E-342 Inexact Rounded +xrem132 remainder 5.11629020 -480.53194 -> 5.11629020 +xsub132 subtract 5.11629020 -480.53194 -> 485.648230 Inexact Rounded +xadd133 add -8.23352673E-446723147 -530710.866 -> -530710.866 Inexact Rounded +xcom133 compare -8.23352673E-446723147 -530710.866 -> 1 +xdiv133 divide -8.23352673E-446723147 -530710.866 -> 1.55141476E-446723152 Inexact Rounded +xdvi133 divideint -8.23352673E-446723147 -530710.866 -> 0 +xmul133 multiply -8.23352673E-446723147 -530710.866 -> 4.36962210E-446723141 Inexact Rounded +xpow133 power -8.23352673E-446723147 -530711 -> -Infinity Overflow Inexact Rounded +xrem133 remainder -8.23352673E-446723147 -530710.866 -> -8.23352673E-446723147 +xsub133 subtract -8.23352673E-446723147 -530710.866 -> 530710.866 Inexact Rounded +xadd134 add 7.0598608 -95908.35 -> -95901.2901 Inexact Rounded +xcom134 compare 7.0598608 -95908.35 -> 1 +xdiv134 divide 7.0598608 -95908.35 -> -0.0000736104917 Inexact Rounded +xdvi134 divideint 7.0598608 -95908.35 -> -0 +xmul134 multiply 7.0598608 -95908.35 -> -677099.601 Inexact Rounded +xpow134 power 7.0598608 -95908 -> 4.57073877E-81407 Inexact Rounded +xrem134 remainder 7.0598608 -95908.35 -> 7.0598608 +xsub134 subtract 7.0598608 -95908.35 -> 95915.4099 Inexact Rounded +xadd135 add -7.91189845E+207202706 1532.71847E+509944335 -> 1.53271847E+509944338 Inexact Rounded +xcom135 compare -7.91189845E+207202706 1532.71847E+509944335 -> -1 +xdiv135 divide -7.91189845E+207202706 1532.71847E+509944335 -> -5.16200372E-302741632 Inexact Rounded +xdvi135 divideint -7.91189845E+207202706 1532.71847E+509944335 -> -0 +xmul135 multiply -7.91189845E+207202706 1532.71847E+509944335 -> -1.21267129E+717147045 Inexact Rounded +xpow135 power -7.91189845E+207202706 2 -> 6.25981371E+414405413 Inexact Rounded +xrem135 remainder -7.91189845E+207202706 1532.71847E+509944335 -> -7.91189845E+207202706 +xsub135 subtract -7.91189845E+207202706 1532.71847E+509944335 -> -1.53271847E+509944338 Inexact Rounded +xadd136 add 208839370.E-215147432 -75.9420559 -> -75.9420559 Inexact Rounded +xcom136 compare 208839370.E-215147432 -75.9420559 -> 1 +xdiv136 divide 208839370.E-215147432 -75.9420559 -> -2.74998310E-215147426 Inexact Rounded +xdvi136 divideint 208839370.E-215147432 -75.9420559 -> -0 +xmul136 multiply 208839370.E-215147432 -75.9420559 -> -1.58596911E-215147422 Inexact Rounded +xpow136 power 208839370.E-215147432 -76 -> Infinity Overflow Inexact Rounded +xrem136 remainder 208839370.E-215147432 -75.9420559 -> 2.08839370E-215147424 +xsub136 subtract 208839370.E-215147432 -75.9420559 -> 75.9420559 Inexact Rounded +xadd137 add 427.754244E-353328369 4705.0796 -> 4705.07960 Inexact Rounded +xcom137 compare 427.754244E-353328369 4705.0796 -> -1 +xdiv137 divide 427.754244E-353328369 4705.0796 -> 9.09132853E-353328371 Inexact Rounded +xdvi137 divideint 427.754244E-353328369 4705.0796 -> 0 +xmul137 multiply 427.754244E-353328369 4705.0796 -> 2.01261777E-353328363 Inexact Rounded +xpow137 power 427.754244E-353328369 4705 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem137 remainder 427.754244E-353328369 4705.0796 -> 4.27754244E-353328367 +xsub137 subtract 427.754244E-353328369 4705.0796 -> -4705.07960 Inexact Rounded +xadd138 add 44911.089 -95.1733605E-313081848 -> 44911.0890 Inexact Rounded +xcom138 compare 44911.089 -95.1733605E-313081848 -> 1 +xdiv138 divide 44911.089 -95.1733605E-313081848 -> -4.71887183E+313081850 Inexact Rounded +xdvi138 divideint 44911.089 -95.1733605E-313081848 -> NaN Division_impossible +xmul138 multiply 44911.089 -95.1733605E-313081848 -> -4.27433926E-313081842 Inexact Rounded +xpow138 power 44911.089 -10 -> 2.99546425E-47 Inexact Rounded +xrem138 remainder 44911.089 -95.1733605E-313081848 -> NaN Division_impossible +xsub138 subtract 44911.089 -95.1733605E-313081848 -> 44911.0890 Inexact Rounded +xadd139 add 452371821. -4109709.19 -> 448262112 Inexact Rounded +xcom139 compare 452371821. -4109709.19 -> 1 +xdiv139 divide 452371821. -4109709.19 -> -110.073925 Inexact Rounded +xdvi139 divideint 452371821. -4109709.19 -> -110 +xmul139 multiply 452371821. -4109709.19 -> -1.85911663E+15 Inexact Rounded +xpow139 power 452371821. -4109709 -> 1.15528807E-35571568 Inexact Rounded +xrem139 remainder 452371821. -4109709.19 -> 303810.10 +xsub139 subtract 452371821. -4109709.19 -> 456481530 Inexact Rounded +xadd140 add 94007.4392 -9467725.5E+681898234 -> -9.46772550E+681898240 Inexact Rounded +xcom140 compare 94007.4392 -9467725.5E+681898234 -> 1 +xdiv140 divide 94007.4392 -9467725.5E+681898234 -> -9.92925272E-681898237 Inexact Rounded +xdvi140 divideint 94007.4392 -9467725.5E+681898234 -> -0 +xmul140 multiply 94007.4392 -9467725.5E+681898234 -> -8.90036629E+681898245 Inexact Rounded +xpow140 power 94007.4392 -9 -> 1.74397397E-45 Inexact Rounded +xrem140 remainder 94007.4392 -9467725.5E+681898234 -> 94007.4392 +xsub140 subtract 94007.4392 -9467725.5E+681898234 -> 9.46772550E+681898240 Inexact Rounded +xadd141 add 99147554.0E-751410586 38313.6423 -> 38313.6423 Inexact Rounded +xcom141 compare 99147554.0E-751410586 38313.6423 -> -1 +xdiv141 divide 99147554.0E-751410586 38313.6423 -> 2.58778722E-751410583 Inexact Rounded +xdvi141 divideint 99147554.0E-751410586 38313.6423 -> 0 +xmul141 multiply 99147554.0E-751410586 38313.6423 -> 3.79870392E-751410574 Inexact Rounded +xpow141 power 99147554.0E-751410586 38314 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem141 remainder 99147554.0E-751410586 38313.6423 -> 9.91475540E-751410579 +xsub141 subtract 99147554.0E-751410586 38313.6423 -> -38313.6423 Inexact Rounded +xadd142 add -7919.30254 -669.607854 -> -8588.91039 Inexact Rounded +xcom142 compare -7919.30254 -669.607854 -> -1 +xdiv142 divide -7919.30254 -669.607854 -> 11.8267767 Inexact Rounded +xdvi142 divideint -7919.30254 -669.607854 -> 11 +xmul142 multiply -7919.30254 -669.607854 -> 5302827.18 Inexact Rounded +xpow142 power -7919.30254 -670 -> 7.58147724E-2613 Inexact Rounded +xrem142 remainder -7919.30254 -669.607854 -> -553.616146 +xsub142 subtract -7919.30254 -669.607854 -> -7249.69469 Inexact Rounded +xadd143 add 461.58280E+136110821 710666052.E-383754231 -> 4.61582800E+136110823 Inexact Rounded +xcom143 compare 461.58280E+136110821 710666052.E-383754231 -> 1 +xdiv143 divide 461.58280E+136110821 710666052.E-383754231 -> 6.49507316E+519865045 Inexact Rounded +xdvi143 divideint 461.58280E+136110821 710666052.E-383754231 -> NaN Division_impossible +xmul143 multiply 461.58280E+136110821 710666052.E-383754231 -> 3.28031226E-247643399 Inexact Rounded +xpow143 power 461.58280E+136110821 7 -> 4.46423781E+952775765 Inexact Rounded +xrem143 remainder 461.58280E+136110821 710666052.E-383754231 -> NaN Division_impossible +xsub143 subtract 461.58280E+136110821 710666052.E-383754231 -> 4.61582800E+136110823 Inexact Rounded +xadd144 add 3455755.47E-112465506 771.674306 -> 771.674306 Inexact Rounded +xcom144 compare 3455755.47E-112465506 771.674306 -> -1 +xdiv144 divide 3455755.47E-112465506 771.674306 -> 4.47825649E-112465503 Inexact Rounded +xdvi144 divideint 3455755.47E-112465506 771.674306 -> 0 +xmul144 multiply 3455755.47E-112465506 771.674306 -> 2.66671770E-112465497 Inexact Rounded +xpow144 power 3455755.47E-112465506 772 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem144 remainder 3455755.47E-112465506 771.674306 -> 3.45575547E-112465500 +xsub144 subtract 3455755.47E-112465506 771.674306 -> -771.674306 Inexact Rounded +xadd145 add -477067757.E-961684940 7.70122608E-741072245 -> 7.70122608E-741072245 Inexact Rounded +xcom145 compare -477067757.E-961684940 7.70122608E-741072245 -> -1 +xdiv145 divide -477067757.E-961684940 7.70122608E-741072245 -> -6.19469877E-220612688 Inexact Rounded +xdvi145 divideint -477067757.E-961684940 7.70122608E-741072245 -> -0 +xmul145 multiply -477067757.E-961684940 7.70122608E-741072245 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow145 power -477067757.E-961684940 8 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem145 remainder -477067757.E-961684940 7.70122608E-741072245 -> -4.77067757E-961684932 +xsub145 subtract -477067757.E-961684940 7.70122608E-741072245 -> -7.70122608E-741072245 Inexact Rounded +xadd146 add 76482.352 8237806.8 -> 8314289.15 Inexact Rounded +xcom146 compare 76482.352 8237806.8 -> -1 +xdiv146 divide 76482.352 8237806.8 -> 0.00928430999 Inexact Rounded +xdvi146 divideint 76482.352 8237806.8 -> 0 +xmul146 multiply 76482.352 8237806.8 -> 6.30046839E+11 Inexact Rounded +xpow146 power 76482.352 8237807 -> 8.44216559E+40229834 Inexact Rounded +xrem146 remainder 76482.352 8237806.8 -> 76482.352 +xsub146 subtract 76482.352 8237806.8 -> -8161324.45 Inexact Rounded +xadd147 add 1.21505164E-565556504 9.26146573 -> 9.26146573 Inexact Rounded +xcom147 compare 1.21505164E-565556504 9.26146573 -> -1 +xdiv147 divide 1.21505164E-565556504 9.26146573 -> 1.31194314E-565556505 Inexact Rounded +xdvi147 divideint 1.21505164E-565556504 9.26146573 -> 0 +xmul147 multiply 1.21505164E-565556504 9.26146573 -> 1.12531591E-565556503 Inexact Rounded +xpow147 power 1.21505164E-565556504 9 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem147 remainder 1.21505164E-565556504 9.26146573 -> 1.21505164E-565556504 +xsub147 subtract 1.21505164E-565556504 9.26146573 -> -9.26146573 Inexact Rounded +xadd148 add -8303060.25E-169894883 901561.985 -> 901561.985 Inexact Rounded +xcom148 compare -8303060.25E-169894883 901561.985 -> -1 +xdiv148 divide -8303060.25E-169894883 901561.985 -> -9.20963881E-169894883 Inexact Rounded +xdvi148 divideint -8303060.25E-169894883 901561.985 -> -0 +xmul148 multiply -8303060.25E-169894883 901561.985 -> -7.48572348E-169894871 Inexact Rounded +xpow148 power -8303060.25E-169894883 901562 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem148 remainder -8303060.25E-169894883 901561.985 -> -8.30306025E-169894877 +xsub148 subtract -8303060.25E-169894883 901561.985 -> -901561.985 Inexact Rounded +xadd149 add -592464.92 71445510.7 -> 70853045.8 Inexact Rounded +xcom149 compare -592464.92 71445510.7 -> -1 +xdiv149 divide -592464.92 71445510.7 -> -0.00829254231 Inexact Rounded +xdvi149 divideint -592464.92 71445510.7 -> -0 +xmul149 multiply -592464.92 71445510.7 -> -4.23289588E+13 Inexact Rounded +xpow149 power -592464.92 71445511 -> -1.58269108E+412430832 Inexact Rounded +xrem149 remainder -592464.92 71445510.7 -> -592464.92 +xsub149 subtract -592464.92 71445510.7 -> -72037975.6 Inexact Rounded +xadd150 add -73774.4165 -39.8243027 -> -73814.2408 Inexact Rounded +xcom150 compare -73774.4165 -39.8243027 -> -1 +xdiv150 divide -73774.4165 -39.8243027 -> 1852.49738 Inexact Rounded +xdvi150 divideint -73774.4165 -39.8243027 -> 1852 +xmul150 multiply -73774.4165 -39.8243027 -> 2938014.69 Inexact Rounded +xpow150 power -73774.4165 -40 -> 1.92206765E-195 Inexact Rounded +xrem150 remainder -73774.4165 -39.8243027 -> -19.8078996 +xsub150 subtract -73774.4165 -39.8243027 -> -73734.5922 Inexact Rounded +xadd151 add -524724715. -55763.7937 -> -524780479 Inexact Rounded +xcom151 compare -524724715. -55763.7937 -> -1 +xdiv151 divide -524724715. -55763.7937 -> 9409.77434 Inexact Rounded +xdvi151 divideint -524724715. -55763.7937 -> 9409 +xmul151 multiply -524724715. -55763.7937 -> 2.92606408E+13 Inexact Rounded +xpow151 power -524724715. -55764 -> 5.47898351E-486259 Inexact Rounded +xrem151 remainder -524724715. -55763.7937 -> -43180.0767 +xsub151 subtract -524724715. -55763.7937 -> -524668951 Inexact Rounded +xadd152 add 7.53800427 784873768E-9981146 -> 7.53800427 Inexact Rounded +xcom152 compare 7.53800427 784873768E-9981146 -> 1 +xdiv152 divide 7.53800427 784873768E-9981146 -> 9.60409760E+9981137 Inexact Rounded +xdvi152 divideint 7.53800427 784873768E-9981146 -> NaN Division_impossible +xmul152 multiply 7.53800427 784873768E-9981146 -> 5.91638181E-9981137 Inexact Rounded +xpow152 power 7.53800427 8 -> 10424399.2 Inexact Rounded +xrem152 remainder 7.53800427 784873768E-9981146 -> NaN Division_impossible +xsub152 subtract 7.53800427 784873768E-9981146 -> 7.53800427 Inexact Rounded +xadd153 add 37.6027452 7.22454233 -> 44.8272875 Inexact Rounded +xcom153 compare 37.6027452 7.22454233 -> 1 +xdiv153 divide 37.6027452 7.22454233 -> 5.20486191 Inexact Rounded +xdvi153 divideint 37.6027452 7.22454233 -> 5 +xmul153 multiply 37.6027452 7.22454233 -> 271.662624 Inexact Rounded +xpow153 power 37.6027452 7 -> 1.06300881E+11 Inexact Rounded +xrem153 remainder 37.6027452 7.22454233 -> 1.48003355 +xsub153 subtract 37.6027452 7.22454233 -> 30.3782029 Inexact Rounded +xadd154 add 2447660.39 -36981.4253 -> 2410678.96 Inexact Rounded +xcom154 compare 2447660.39 -36981.4253 -> 1 +xdiv154 divide 2447660.39 -36981.4253 -> -66.1862102 Inexact Rounded +xdvi154 divideint 2447660.39 -36981.4253 -> -66 +xmul154 multiply 2447660.39 -36981.4253 -> -9.05179699E+10 Inexact Rounded +xpow154 power 2447660.39 -36981 -> 3.92066064E-236263 Inexact Rounded +xrem154 remainder 2447660.39 -36981.4253 -> 6886.3202 +xsub154 subtract 2447660.39 -36981.4253 -> 2484641.82 Inexact Rounded +xadd155 add 2160.36419 1418.33574E+656265382 -> 1.41833574E+656265385 Inexact Rounded +xcom155 compare 2160.36419 1418.33574E+656265382 -> -1 +xdiv155 divide 2160.36419 1418.33574E+656265382 -> 1.52316841E-656265382 Inexact Rounded +xdvi155 divideint 2160.36419 1418.33574E+656265382 -> 0 +xmul155 multiply 2160.36419 1418.33574E+656265382 -> 3.06412174E+656265388 Inexact Rounded +xpow155 power 2160.36419 1 -> 2160.36419 +xrem155 remainder 2160.36419 1418.33574E+656265382 -> 2160.36419 +xsub155 subtract 2160.36419 1418.33574E+656265382 -> -1.41833574E+656265385 Inexact Rounded +xadd156 add 8926.44939 54.9430027 -> 8981.39239 Inexact Rounded +xcom156 compare 8926.44939 54.9430027 -> 1 +xdiv156 divide 8926.44939 54.9430027 -> 162.467447 Inexact Rounded +xdvi156 divideint 8926.44939 54.9430027 -> 162 +xmul156 multiply 8926.44939 54.9430027 -> 490445.933 Inexact Rounded +xpow156 power 8926.44939 55 -> 1.93789877E+217 Inexact Rounded +xrem156 remainder 8926.44939 54.9430027 -> 25.6829526 +xsub156 subtract 8926.44939 54.9430027 -> 8871.50639 Inexact Rounded +xadd157 add 861588029 -41657398E+77955925 -> -4.16573980E+77955932 Inexact Rounded +xcom157 compare 861588029 -41657398E+77955925 -> 1 +xdiv157 divide 861588029 -41657398E+77955925 -> -2.06827135E-77955924 Inexact Rounded +xdvi157 divideint 861588029 -41657398E+77955925 -> -0 +xmul157 multiply 861588029 -41657398E+77955925 -> -3.58915154E+77955941 Inexact Rounded +xpow157 power 861588029 -4 -> 1.81468553E-36 Inexact Rounded +xrem157 remainder 861588029 -41657398E+77955925 -> 861588029 +xsub157 subtract 861588029 -41657398E+77955925 -> 4.16573980E+77955932 Inexact Rounded +xadd158 add -34.5253062 52.6722019 -> 18.1468957 +xcom158 compare -34.5253062 52.6722019 -> -1 +xdiv158 divide -34.5253062 52.6722019 -> -0.655474899 Inexact Rounded +xdvi158 divideint -34.5253062 52.6722019 -> -0 +xmul158 multiply -34.5253062 52.6722019 -> -1818.52390 Inexact Rounded +xpow158 power -34.5253062 53 -> -3.32115821E+81 Inexact Rounded +xrem158 remainder -34.5253062 52.6722019 -> -34.5253062 +xsub158 subtract -34.5253062 52.6722019 -> -87.1975081 +xadd159 add -18861647. 99794586.7 -> 80932939.7 +xcom159 compare -18861647. 99794586.7 -> -1 +xdiv159 divide -18861647. 99794586.7 -> -0.189004711 Inexact Rounded +xdvi159 divideint -18861647. 99794586.7 -> -0 +xmul159 multiply -18861647. 99794586.7 -> -1.88229027E+15 Inexact Rounded +xpow159 power -18861647. 99794587 -> -4.28957460E+726063462 Inexact Rounded +xrem159 remainder -18861647. 99794586.7 -> -18861647.0 +xsub159 subtract -18861647. 99794586.7 -> -118656234 Inexact Rounded +xadd160 add 322192.407 461.67044 -> 322654.077 Inexact Rounded +xcom160 compare 322192.407 461.67044 -> 1 +xdiv160 divide 322192.407 461.67044 -> 697.883986 Inexact Rounded +xdvi160 divideint 322192.407 461.67044 -> 697 +xmul160 multiply 322192.407 461.67044 -> 148746710 Inexact Rounded +xpow160 power 322192.407 462 -> 5.61395873E+2544 Inexact Rounded +xrem160 remainder 322192.407 461.67044 -> 408.11032 +xsub160 subtract 322192.407 461.67044 -> 321730.737 Inexact Rounded +xadd161 add -896298518E+61412314 78873.8049 -> -8.96298518E+61412322 Inexact Rounded +xcom161 compare -896298518E+61412314 78873.8049 -> -1 +xdiv161 divide -896298518E+61412314 78873.8049 -> -1.13637033E+61412318 Inexact Rounded +xdvi161 divideint -896298518E+61412314 78873.8049 -> NaN Division_impossible +xmul161 multiply -896298518E+61412314 78873.8049 -> -7.06944744E+61412327 Inexact Rounded +xpow161 power -896298518E+61412314 78874 -> Infinity Overflow Inexact Rounded +xrem161 remainder -896298518E+61412314 78873.8049 -> NaN Division_impossible +xsub161 subtract -896298518E+61412314 78873.8049 -> -8.96298518E+61412322 Inexact Rounded +xadd162 add 293.773732 479899052E+789950177 -> 4.79899052E+789950185 Inexact Rounded +xcom162 compare 293.773732 479899052E+789950177 -> -1 +xdiv162 divide 293.773732 479899052E+789950177 -> 6.12157350E-789950184 Inexact Rounded +xdvi162 divideint 293.773732 479899052E+789950177 -> 0 +xmul162 multiply 293.773732 479899052E+789950177 -> 1.40981735E+789950188 Inexact Rounded +xpow162 power 293.773732 5 -> 2.18808809E+12 Inexact Rounded +xrem162 remainder 293.773732 479899052E+789950177 -> 293.773732 +xsub162 subtract 293.773732 479899052E+789950177 -> -4.79899052E+789950185 Inexact Rounded +xadd163 add -103519362 51897955.3 -> -51621406.7 +xcom163 compare -103519362 51897955.3 -> -1 +xdiv163 divide -103519362 51897955.3 -> -1.99467130 Inexact Rounded +xdvi163 divideint -103519362 51897955.3 -> -1 +xmul163 multiply -103519362 51897955.3 -> -5.37244322E+15 Inexact Rounded +xpow163 power -103519362 51897955 -> -4.28858229E+415963229 Inexact Rounded +xrem163 remainder -103519362 51897955.3 -> -51621406.7 +xsub163 subtract -103519362 51897955.3 -> -155417317 Inexact Rounded +xadd164 add 37380.7802 -277719788. -> -277682407 Inexact Rounded +xcom164 compare 37380.7802 -277719788. -> 1 +xdiv164 divide 37380.7802 -277719788. -> -0.000134598908 Inexact Rounded +xdvi164 divideint 37380.7802 -277719788. -> -0 +xmul164 multiply 37380.7802 -277719788. -> -1.03813824E+13 Inexact Rounded +xpow164 power 37380.7802 -277719788 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem164 remainder 37380.7802 -277719788. -> 37380.7802 +xsub164 subtract 37380.7802 -277719788. -> 277757169 Inexact Rounded +xadd165 add 320133844. -977517477 -> -657383633 +xcom165 compare 320133844. -977517477 -> 1 +xdiv165 divide 320133844. -977517477 -> -0.327496798 Inexact Rounded +xdvi165 divideint 320133844. -977517477 -> -0 +xmul165 multiply 320133844. -977517477 -> -3.12936427E+17 Inexact Rounded +xpow165 power 320133844. -977517477 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem165 remainder 320133844. -977517477 -> 320133844 +xsub165 subtract 320133844. -977517477 -> 1.29765132E+9 Inexact Rounded +xadd166 add 721776701E+933646161 -5689279.64E+669903645 -> 7.21776701E+933646169 Inexact Rounded +xcom166 compare 721776701E+933646161 -5689279.64E+669903645 -> 1 +xdiv166 divide 721776701E+933646161 -5689279.64E+669903645 -> -1.26866097E+263742518 Inexact Rounded +xdvi166 divideint 721776701E+933646161 -5689279.64E+669903645 -> NaN Division_impossible +xmul166 multiply 721776701E+933646161 -5689279.64E+669903645 -> -Infinity Inexact Overflow Rounded +xpow166 power 721776701E+933646161 -6 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem166 remainder 721776701E+933646161 -5689279.64E+669903645 -> NaN Division_impossible +xsub166 subtract 721776701E+933646161 -5689279.64E+669903645 -> 7.21776701E+933646169 Inexact Rounded +xadd167 add -5409.00482 -2.16149386 -> -5411.16631 Inexact Rounded +xcom167 compare -5409.00482 -2.16149386 -> -1 +xdiv167 divide -5409.00482 -2.16149386 -> 2502.43821 Inexact Rounded +xdvi167 divideint -5409.00482 -2.16149386 -> 2502 +xmul167 multiply -5409.00482 -2.16149386 -> 11691.5307 Inexact Rounded +xpow167 power -5409.00482 -2 -> 3.41794652E-8 Inexact Rounded +xrem167 remainder -5409.00482 -2.16149386 -> -0.94718228 +xsub167 subtract -5409.00482 -2.16149386 -> -5406.84333 Inexact Rounded +xadd168 add -957960.367 322.858170 -> -957637.509 Inexact Rounded +xcom168 compare -957960.367 322.858170 -> -1 +xdiv168 divide -957960.367 322.858170 -> -2967.12444 Inexact Rounded +xdvi168 divideint -957960.367 322.858170 -> -2967 +xmul168 multiply -957960.367 322.858170 -> -309285331 Inexact Rounded +xpow168 power -957960.367 323 -> -9.44617460E+1931 Inexact Rounded +xrem168 remainder -957960.367 322.858170 -> -40.176610 +xsub168 subtract -957960.367 322.858170 -> -958283.225 Inexact Rounded +xadd169 add -11817.8754E+613893442 -3.84735082E+888333249 -> -3.84735082E+888333249 Inexact Rounded +xcom169 compare -11817.8754E+613893442 -3.84735082E+888333249 -> 1 +xdiv169 divide -11817.8754E+613893442 -3.84735082E+888333249 -> 3.07169165E-274439804 Inexact Rounded +xdvi169 divideint -11817.8754E+613893442 -3.84735082E+888333249 -> 0 +xmul169 multiply -11817.8754E+613893442 -3.84735082E+888333249 -> Infinity Inexact Overflow Rounded +xpow169 power -11817.8754E+613893442 -4 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem169 remainder -11817.8754E+613893442 -3.84735082E+888333249 -> -1.18178754E+613893446 +xsub169 subtract -11817.8754E+613893442 -3.84735082E+888333249 -> 3.84735082E+888333249 Inexact Rounded +xadd170 add 840258203 58363.980E-906584723 -> 840258203 Inexact Rounded +xcom170 compare 840258203 58363.980E-906584723 -> 1 +xdiv170 divide 840258203 58363.980E-906584723 -> 1.43968626E+906584727 Inexact Rounded +xdvi170 divideint 840258203 58363.980E-906584723 -> NaN Division_impossible +xmul170 multiply 840258203 58363.980E-906584723 -> 4.90408130E-906584710 Inexact Rounded +xpow170 power 840258203 6 -> 3.51946431E+53 Inexact Rounded +xrem170 remainder 840258203 58363.980E-906584723 -> NaN Division_impossible +xsub170 subtract 840258203 58363.980E-906584723 -> 840258203 Inexact Rounded +xadd171 add -205842096. -191342.721 -> -206033439 Inexact Rounded +xcom171 compare -205842096. -191342.721 -> -1 +xdiv171 divide -205842096. -191342.721 -> 1075.77699 Inexact Rounded +xdvi171 divideint -205842096. -191342.721 -> 1075 +xmul171 multiply -205842096. -191342.721 -> 3.93863867E+13 Inexact Rounded +xpow171 power -205842096. -191343 -> -2.66955553E-1590737 Inexact Rounded +xrem171 remainder -205842096. -191342.721 -> -148670.925 +xsub171 subtract -205842096. -191342.721 -> -205650753 Inexact Rounded +xadd172 add 42501124. 884.938498E+123341480 -> 8.84938498E+123341482 Inexact Rounded +xcom172 compare 42501124. 884.938498E+123341480 -> -1 +xdiv172 divide 42501124. 884.938498E+123341480 -> 4.80272065E-123341476 Inexact Rounded +xdvi172 divideint 42501124. 884.938498E+123341480 -> 0 +xmul172 multiply 42501124. 884.938498E+123341480 -> 3.76108808E+123341490 Inexact Rounded +xpow172 power 42501124. 9 -> 4.52484536E+68 Inexact Rounded +xrem172 remainder 42501124. 884.938498E+123341480 -> 42501124 +xsub172 subtract 42501124. 884.938498E+123341480 -> -8.84938498E+123341482 Inexact Rounded +xadd173 add -57809452. -620380746 -> -678190198 +xcom173 compare -57809452. -620380746 -> 1 +xdiv173 divide -57809452. -620380746 -> 0.0931838268 Inexact Rounded +xdvi173 divideint -57809452. -620380746 -> 0 +xmul173 multiply -57809452. -620380746 -> 3.58638710E+16 Inexact Rounded +xpow173 power -57809452. -620380746 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem173 remainder -57809452. -620380746 -> -57809452 +xsub173 subtract -57809452. -620380746 -> 562571294 +xadd174 add -8022370.31 9858581.6 -> 1836211.29 +xcom174 compare -8022370.31 9858581.6 -> -1 +xdiv174 divide -8022370.31 9858581.6 -> -0.813744881 Inexact Rounded +xdvi174 divideint -8022370.31 9858581.6 -> -0 +xmul174 multiply -8022370.31 9858581.6 -> -7.90891923E+13 Inexact Rounded +xpow174 power -8022370.31 9858582 -> 2.34458249E+68066634 Inexact Rounded +xrem174 remainder -8022370.31 9858581.6 -> -8022370.31 +xsub174 subtract -8022370.31 9858581.6 -> -17880951.9 Inexact Rounded +xadd175 add 2.49065060E+592139141 -5432.72014E-419965357 -> 2.49065060E+592139141 Inexact Rounded +xcom175 compare 2.49065060E+592139141 -5432.72014E-419965357 -> 1 +xdiv175 divide 2.49065060E+592139141 -5432.72014E-419965357 -> -Infinity Inexact Overflow Rounded +xdvi175 divideint 2.49065060E+592139141 -5432.72014E-419965357 -> NaN Division_impossible +xmul175 multiply 2.49065060E+592139141 -5432.72014E-419965357 -> -1.35310077E+172173788 Inexact Rounded +xpow175 power 2.49065060E+592139141 -5 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem175 remainder 2.49065060E+592139141 -5432.72014E-419965357 -> NaN Division_impossible +xsub175 subtract 2.49065060E+592139141 -5432.72014E-419965357 -> 2.49065060E+592139141 Inexact Rounded +xadd176 add -697273715E-242824870 -3.81757506 -> -3.81757506 Inexact Rounded +xcom176 compare -697273715E-242824870 -3.81757506 -> 1 +xdiv176 divide -697273715E-242824870 -3.81757506 -> 1.82648331E-242824862 Inexact Rounded +xdvi176 divideint -697273715E-242824870 -3.81757506 -> 0 +xmul176 multiply -697273715E-242824870 -3.81757506 -> 2.66189474E-242824861 Inexact Rounded +xpow176 power -697273715E-242824870 -4 -> 4.23045251E+971299444 Inexact Rounded +xrem176 remainder -697273715E-242824870 -3.81757506 -> -6.97273715E-242824862 +xsub176 subtract -697273715E-242824870 -3.81757506 -> 3.81757506 Inexact Rounded +xadd177 add -7.42204403E-315716280 -8156111.67E+283261636 -> -8.15611167E+283261642 Inexact Rounded +xcom177 compare -7.42204403E-315716280 -8156111.67E+283261636 -> 1 +xdiv177 divide -7.42204403E-315716280 -8156111.67E+283261636 -> 9.09997843E-598977923 Inexact Rounded +xdvi177 divideint -7.42204403E-315716280 -8156111.67E+283261636 -> 0 +xmul177 multiply -7.42204403E-315716280 -8156111.67E+283261636 -> 6.05350199E-32454637 Inexact Rounded +xpow177 power -7.42204403E-315716280 -8 -> Infinity Overflow Inexact Rounded +xrem177 remainder -7.42204403E-315716280 -8156111.67E+283261636 -> -7.42204403E-315716280 +xsub177 subtract -7.42204403E-315716280 -8156111.67E+283261636 -> 8.15611167E+283261642 Inexact Rounded +xadd178 add 738063892 89900467.8 -> 827964360 Inexact Rounded +xcom178 compare 738063892 89900467.8 -> 1 +xdiv178 divide 738063892 89900467.8 -> 8.20978923 Inexact Rounded +xdvi178 divideint 738063892 89900467.8 -> 8 +xmul178 multiply 738063892 89900467.8 -> 6.63522892E+16 Inexact Rounded +xpow178 power 738063892 89900468 -> 1.53166723E+797245797 Inexact Rounded +xrem178 remainder 738063892 89900467.8 -> 18860149.6 +xsub178 subtract 738063892 89900467.8 -> 648163424 Inexact Rounded +xadd179 add -630309366 -884783.338E-21595410 -> -630309366 Inexact Rounded +xcom179 compare -630309366 -884783.338E-21595410 -> -1 +xdiv179 divide -630309366 -884783.338E-21595410 -> 7.12388377E+21595412 Inexact Rounded +xdvi179 divideint -630309366 -884783.338E-21595410 -> NaN Division_impossible +xmul179 multiply -630309366 -884783.338E-21595410 -> 5.57687225E-21595396 Inexact Rounded +xpow179 power -630309366 -9 -> -6.36819210E-80 Inexact Rounded +xrem179 remainder -630309366 -884783.338E-21595410 -> NaN Division_impossible +xsub179 subtract -630309366 -884783.338E-21595410 -> -630309366 Inexact Rounded +xadd180 add 613.207774 -3007.78608 -> -2394.57831 Inexact Rounded +xcom180 compare 613.207774 -3007.78608 -> 1 +xdiv180 divide 613.207774 -3007.78608 -> -0.203873466 Inexact Rounded +xdvi180 divideint 613.207774 -3007.78608 -> -0 +xmul180 multiply 613.207774 -3007.78608 -> -1844397.81 Inexact Rounded +xpow180 power 613.207774 -3008 -> 7.51939160E-8386 Inexact Rounded +xrem180 remainder 613.207774 -3007.78608 -> 613.207774 +xsub180 subtract 613.207774 -3007.78608 -> 3620.99385 Inexact Rounded +xadd181 add -93006222.3 -3.08964619 -> -93006225.4 Inexact Rounded +xcom181 compare -93006222.3 -3.08964619 -> -1 +xdiv181 divide -93006222.3 -3.08964619 -> 30102547.9 Inexact Rounded +xdvi181 divideint -93006222.3 -3.08964619 -> 30102547 +xmul181 multiply -93006222.3 -3.08964619 -> 287356320 Inexact Rounded +xpow181 power -93006222.3 -3 -> -1.24297956E-24 Inexact Rounded +xrem181 remainder -93006222.3 -3.08964619 -> -2.65215407 +xsub181 subtract -93006222.3 -3.08964619 -> -93006219.2 Inexact Rounded +xadd182 add -18116.0621 34096.306E-270347092 -> -18116.0621 Inexact Rounded +xcom182 compare -18116.0621 34096.306E-270347092 -> -1 +xdiv182 divide -18116.0621 34096.306E-270347092 -> -5.31320375E+270347091 Inexact Rounded +xdvi182 divideint -18116.0621 34096.306E-270347092 -> NaN Division_impossible +xmul182 multiply -18116.0621 34096.306E-270347092 -> -6.17690797E-270347084 Inexact Rounded +xpow182 power -18116.0621 3 -> -5.94554133E+12 Inexact Rounded +xrem182 remainder -18116.0621 34096.306E-270347092 -> NaN Division_impossible +xsub182 subtract -18116.0621 34096.306E-270347092 -> -18116.0621 Inexact Rounded +xadd183 add 19272386.9 -410442379. -> -391169992 Inexact Rounded +xcom183 compare 19272386.9 -410442379. -> 1 +xdiv183 divide 19272386.9 -410442379. -> -0.0469551584 Inexact Rounded +xdvi183 divideint 19272386.9 -410442379. -> -0 +xmul183 multiply 19272386.9 -410442379. -> -7.91020433E+15 Inexact Rounded +xpow183 power 19272386.9 -410442379 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem183 remainder 19272386.9 -410442379. -> 19272386.9 +xsub183 subtract 19272386.9 -410442379. -> 429714766 Inexact Rounded +xadd184 add 4180.30821 -1.6439543E-624759104 -> 4180.30821 Inexact Rounded +xcom184 compare 4180.30821 -1.6439543E-624759104 -> 1 +xdiv184 divide 4180.30821 -1.6439543E-624759104 -> -2.54283724E+624759107 Inexact Rounded +xdvi184 divideint 4180.30821 -1.6439543E-624759104 -> NaN Division_impossible +xmul184 multiply 4180.30821 -1.6439543E-624759104 -> -6.87223566E-624759101 Inexact Rounded +xpow184 power 4180.30821 -2 -> 5.72246828E-8 Inexact Rounded +xrem184 remainder 4180.30821 -1.6439543E-624759104 -> NaN Division_impossible +xsub184 subtract 4180.30821 -1.6439543E-624759104 -> 4180.30821 Inexact Rounded +xadd185 add 571.536725 389.899220 -> 961.435945 +xcom185 compare 571.536725 389.899220 -> 1 +xdiv185 divide 571.536725 389.899220 -> 1.46585757 Inexact Rounded +xdvi185 divideint 571.536725 389.899220 -> 1 +xmul185 multiply 571.536725 389.899220 -> 222841.723 Inexact Rounded +xpow185 power 571.536725 390 -> 1.76691373E+1075 Inexact Rounded +xrem185 remainder 571.536725 389.899220 -> 181.637505 +xsub185 subtract 571.536725 389.899220 -> 181.637505 +xadd186 add -622007306.E+159924886 -126.971745 -> -6.22007306E+159924894 Inexact Rounded +xcom186 compare -622007306.E+159924886 -126.971745 -> -1 +xdiv186 divide -622007306.E+159924886 -126.971745 -> 4.89878521E+159924892 Inexact Rounded +xdvi186 divideint -622007306.E+159924886 -126.971745 -> NaN Division_impossible +xmul186 multiply -622007306.E+159924886 -126.971745 -> 7.89773530E+159924896 Inexact Rounded +xpow186 power -622007306.E+159924886 -127 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem186 remainder -622007306.E+159924886 -126.971745 -> NaN Division_impossible +xsub186 subtract -622007306.E+159924886 -126.971745 -> -6.22007306E+159924894 Inexact Rounded +xadd187 add -29.356551E-282816139 37141748E-903397821 -> -2.93565510E-282816138 Inexact Rounded +xcom187 compare -29.356551E-282816139 37141748E-903397821 -> -1 +xdiv187 divide -29.356551E-282816139 37141748E-903397821 -> -7.90392283E+620581675 Inexact Rounded +xdvi187 divideint -29.356551E-282816139 37141748E-903397821 -> NaN Division_impossible +xmul187 multiply -29.356551E-282816139 37141748E-903397821 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow187 power -29.356551E-282816139 4 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem187 remainder -29.356551E-282816139 37141748E-903397821 -> NaN Division_impossible +xsub187 subtract -29.356551E-282816139 37141748E-903397821 -> -2.93565510E-282816138 Inexact Rounded +xadd188 add 92427442.4 674334898. -> 766762340 Inexact Rounded +xcom188 compare 92427442.4 674334898. -> -1 +xdiv188 divide 92427442.4 674334898. -> 0.137064599 Inexact Rounded +xdvi188 divideint 92427442.4 674334898. -> 0 +xmul188 multiply 92427442.4 674334898. -> 6.23270499E+16 Inexact Rounded +xpow188 power 92427442.4 674334898 -> Infinity Overflow Inexact Rounded +xrem188 remainder 92427442.4 674334898. -> 92427442.4 +xsub188 subtract 92427442.4 674334898. -> -581907456 Inexact Rounded +xadd189 add 44651895.7 -910508.438 -> 43741387.3 Inexact Rounded +xcom189 compare 44651895.7 -910508.438 -> 1 +xdiv189 divide 44651895.7 -910508.438 -> -49.0406171 Inexact Rounded +xdvi189 divideint 44651895.7 -910508.438 -> -49 +xmul189 multiply 44651895.7 -910508.438 -> -4.06559278E+13 Inexact Rounded +xpow189 power 44651895.7 -910508 -> 3.72264277E-6965241 Inexact Rounded +xrem189 remainder 44651895.7 -910508.438 -> 36982.238 +xsub189 subtract 44651895.7 -910508.438 -> 45562404.1 Inexact Rounded +xadd190 add 647897872.E+374021790 -467.423029 -> 6.47897872E+374021798 Inexact Rounded +xcom190 compare 647897872.E+374021790 -467.423029 -> 1 +xdiv190 divide 647897872.E+374021790 -467.423029 -> -1.38610601E+374021796 Inexact Rounded +xdvi190 divideint 647897872.E+374021790 -467.423029 -> NaN Division_impossible +xmul190 multiply 647897872.E+374021790 -467.423029 -> -3.02842386E+374021801 Inexact Rounded +xpow190 power 647897872.E+374021790 -467 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem190 remainder 647897872.E+374021790 -467.423029 -> NaN Division_impossible +xsub190 subtract 647897872.E+374021790 -467.423029 -> 6.47897872E+374021798 Inexact Rounded +xadd191 add 25.2592149 59.0436981 -> 84.3029130 +xcom191 compare 25.2592149 59.0436981 -> -1 +xdiv191 divide 25.2592149 59.0436981 -> 0.427805434 Inexact Rounded +xdvi191 divideint 25.2592149 59.0436981 -> 0 +xmul191 multiply 25.2592149 59.0436981 -> 1491.39746 Inexact Rounded +xpow191 power 25.2592149 59 -> 5.53058435E+82 Inexact Rounded +xrem191 remainder 25.2592149 59.0436981 -> 25.2592149 +xsub191 subtract 25.2592149 59.0436981 -> -33.7844832 +xadd192 add -6.850835 -1273.48240 -> -1280.33324 Inexact Rounded +xcom192 compare -6.850835 -1273.48240 -> 1 +xdiv192 divide -6.850835 -1273.48240 -> 0.00537960713 Inexact Rounded +xdvi192 divideint -6.850835 -1273.48240 -> 0 +xmul192 multiply -6.850835 -1273.48240 -> 8724.41780 Inexact Rounded +xpow192 power -6.850835 -1273 -> -1.25462678E-1064 Inexact Rounded +xrem192 remainder -6.850835 -1273.48240 -> -6.850835 +xsub192 subtract -6.850835 -1273.48240 -> 1266.63157 Inexact Rounded +xadd193 add 174.272325 5638.16229 -> 5812.43462 Inexact Rounded +xcom193 compare 174.272325 5638.16229 -> -1 +xdiv193 divide 174.272325 5638.16229 -> 0.0309094198 Inexact Rounded +xdvi193 divideint 174.272325 5638.16229 -> 0 +xmul193 multiply 174.272325 5638.16229 -> 982575.651 Inexact Rounded +xpow193 power 174.272325 5638 -> 1.11137724E+12636 Inexact Rounded +xrem193 remainder 174.272325 5638.16229 -> 174.272325 +xsub193 subtract 174.272325 5638.16229 -> -5463.88997 Inexact Rounded +xadd194 add 3455629.76 -8.27332322 -> 3455621.49 Inexact Rounded +xcom194 compare 3455629.76 -8.27332322 -> 1 +xdiv194 divide 3455629.76 -8.27332322 -> -417683.399 Inexact Rounded +xdvi194 divideint 3455629.76 -8.27332322 -> -417683 +xmul194 multiply 3455629.76 -8.27332322 -> -28589541.9 Inexact Rounded +xpow194 power 3455629.76 -8 -> 4.91793015E-53 Inexact Rounded +xrem194 remainder 3455629.76 -8.27332322 -> 3.29750074 +xsub194 subtract 3455629.76 -8.27332322 -> 3455638.03 Inexact Rounded +xadd195 add -924337723E-640771235 86639377.1 -> 86639377.1 Inexact Rounded +xcom195 compare -924337723E-640771235 86639377.1 -> -1 +xdiv195 divide -924337723E-640771235 86639377.1 -> -1.06687947E-640771234 Inexact Rounded +xdvi195 divideint -924337723E-640771235 86639377.1 -> -0 +xmul195 multiply -924337723E-640771235 86639377.1 -> -8.00840446E-640771219 Inexact Rounded +xpow195 power -924337723E-640771235 86639377 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem195 remainder -924337723E-640771235 86639377.1 -> -9.24337723E-640771227 +xsub195 subtract -924337723E-640771235 86639377.1 -> -86639377.1 Inexact Rounded +xadd196 add -620236932.E+656823969 3364722.73 -> -6.20236932E+656823977 Inexact Rounded +xcom196 compare -620236932.E+656823969 3364722.73 -> -1 +xdiv196 divide -620236932.E+656823969 3364722.73 -> -1.84335228E+656823971 Inexact Rounded +xdvi196 divideint -620236932.E+656823969 3364722.73 -> NaN Division_impossible +xmul196 multiply -620236932.E+656823969 3364722.73 -> -2.08692530E+656823984 Inexact Rounded +xpow196 power -620236932.E+656823969 3364723 -> -Infinity Overflow Inexact Rounded +xrem196 remainder -620236932.E+656823969 3364722.73 -> NaN Division_impossible +xsub196 subtract -620236932.E+656823969 3364722.73 -> -6.20236932E+656823977 Inexact Rounded +xadd197 add 9.10025079 702777882E-8192234 -> 9.10025079 Inexact Rounded +xcom197 compare 9.10025079 702777882E-8192234 -> 1 +xdiv197 divide 9.10025079 702777882E-8192234 -> 1.29489715E+8192226 Inexact Rounded +xdvi197 divideint 9.10025079 702777882E-8192234 -> NaN Division_impossible +xmul197 multiply 9.10025079 702777882E-8192234 -> 6.39545498E-8192225 Inexact Rounded +xpow197 power 9.10025079 7 -> 5168607.19 Inexact Rounded +xrem197 remainder 9.10025079 702777882E-8192234 -> NaN Division_impossible +xsub197 subtract 9.10025079 702777882E-8192234 -> 9.10025079 Inexact Rounded +xadd198 add -18857539.9 813013129. -> 794155589 Inexact Rounded +xcom198 compare -18857539.9 813013129. -> -1 +xdiv198 divide -18857539.9 813013129. -> -0.0231946315 Inexact Rounded +xdvi198 divideint -18857539.9 813013129. -> -0 +xmul198 multiply -18857539.9 813013129. -> -1.53314275E+16 Inexact Rounded +xpow198 power -18857539.9 813013129 -> -Infinity Overflow Inexact Rounded +xrem198 remainder -18857539.9 813013129. -> -18857539.9 +xsub198 subtract -18857539.9 813013129. -> -831870669 Inexact Rounded +xadd199 add -8.29530327 3243419.57E+35688332 -> 3.24341957E+35688338 Inexact Rounded +xcom199 compare -8.29530327 3243419.57E+35688332 -> -1 +xdiv199 divide -8.29530327 3243419.57E+35688332 -> -2.55757946E-35688338 Inexact Rounded +xdvi199 divideint -8.29530327 3243419.57E+35688332 -> -0 +xmul199 multiply -8.29530327 3243419.57E+35688332 -> -2.69051490E+35688339 Inexact Rounded +xpow199 power -8.29530327 3 -> -570.816876 Inexact Rounded +xrem199 remainder -8.29530327 3243419.57E+35688332 -> -8.29530327 +xsub199 subtract -8.29530327 3243419.57E+35688332 -> -3.24341957E+35688338 Inexact Rounded +xadd200 add -57101683.5 763551341E+991491712 -> 7.63551341E+991491720 Inexact Rounded +xcom200 compare -57101683.5 763551341E+991491712 -> -1 +xdiv200 divide -57101683.5 763551341E+991491712 -> -7.47843405E-991491714 Inexact Rounded +xdvi200 divideint -57101683.5 763551341E+991491712 -> -0 +xmul200 multiply -57101683.5 763551341E+991491712 -> -4.36000670E+991491728 Inexact Rounded +xpow200 power -57101683.5 8 -> 1.13029368E+62 Inexact Rounded +xrem200 remainder -57101683.5 763551341E+991491712 -> -57101683.5 +xsub200 subtract -57101683.5 763551341E+991491712 -> -7.63551341E+991491720 Inexact Rounded +xadd201 add -603326.740 1710.95183 -> -601615.788 Inexact Rounded +xcom201 compare -603326.740 1710.95183 -> -1 +xdiv201 divide -603326.740 1710.95183 -> -352.626374 Inexact Rounded +xdvi201 divideint -603326.740 1710.95183 -> -352 +xmul201 multiply -603326.740 1710.95183 -> -1.03226299E+9 Inexact Rounded +xpow201 power -603326.740 1711 -> -3.35315976E+9890 Inexact Rounded +xrem201 remainder -603326.740 1710.95183 -> -1071.69584 +xsub201 subtract -603326.740 1710.95183 -> -605037.692 Inexact Rounded +xadd202 add -48142763.3 -943434114 -> -991576877 Inexact Rounded +xcom202 compare -48142763.3 -943434114 -> 1 +xdiv202 divide -48142763.3 -943434114 -> 0.0510292797 Inexact Rounded +xdvi202 divideint -48142763.3 -943434114 -> 0 +xmul202 multiply -48142763.3 -943434114 -> 4.54195252E+16 Inexact Rounded +xpow202 power -48142763.3 -943434114 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem202 remainder -48142763.3 -943434114 -> -48142763.3 +xsub202 subtract -48142763.3 -943434114 -> 895291351 Inexact Rounded +xadd203 add -204.586767 -235.531847 -> -440.118614 +xcom203 compare -204.586767 -235.531847 -> 1 +xdiv203 divide -204.586767 -235.531847 -> 0.868616154 Inexact Rounded +xdvi203 divideint -204.586767 -235.531847 -> 0 +xmul203 multiply -204.586767 -235.531847 -> 48186.6991 Inexact Rounded +xpow203 power -204.586767 -236 -> 4.29438222E-546 Inexact Rounded +xrem203 remainder -204.586767 -235.531847 -> -204.586767 +xsub203 subtract -204.586767 -235.531847 -> 30.945080 +xadd204 add -70.3805581 830137.913 -> 830067.532 Inexact Rounded +xcom204 compare -70.3805581 830137.913 -> -1 +xdiv204 divide -70.3805581 830137.913 -> -0.0000847817658 Inexact Rounded +xdvi204 divideint -70.3805581 830137.913 -> -0 +xmul204 multiply -70.3805581 830137.913 -> -58425569.6 Inexact Rounded +xpow204 power -70.3805581 830138 -> 4.95165841E+1533640 Inexact Rounded +xrem204 remainder -70.3805581 830137.913 -> -70.3805581 +xsub204 subtract -70.3805581 830137.913 -> -830208.294 Inexact Rounded +xadd205 add -8818.47606 -60766.4571 -> -69584.9332 Inexact Rounded +xcom205 compare -8818.47606 -60766.4571 -> 1 +xdiv205 divide -8818.47606 -60766.4571 -> 0.145120787 Inexact Rounded +xdvi205 divideint -8818.47606 -60766.4571 -> 0 +xmul205 multiply -8818.47606 -60766.4571 -> 535867547 Inexact Rounded +xpow205 power -8818.47606 -60766 -> 1.64487755E-239746 Inexact Rounded +xrem205 remainder -8818.47606 -60766.4571 -> -8818.47606 +xsub205 subtract -8818.47606 -60766.4571 -> 51947.9810 Inexact Rounded +xadd206 add 37060929.3E-168439509 -79576717.1 -> -79576717.1 Inexact Rounded +xcom206 compare 37060929.3E-168439509 -79576717.1 -> 1 +xdiv206 divide 37060929.3E-168439509 -79576717.1 -> -4.65725788E-168439510 Inexact Rounded +xdvi206 divideint 37060929.3E-168439509 -79576717.1 -> -0 +xmul206 multiply 37060929.3E-168439509 -79576717.1 -> -2.94918709E-168439494 Inexact Rounded +xpow206 power 37060929.3E-168439509 -79576717 -> Infinity Overflow Inexact Rounded +xrem206 remainder 37060929.3E-168439509 -79576717.1 -> 3.70609293E-168439502 +xsub206 subtract 37060929.3E-168439509 -79576717.1 -> 79576717.1 Inexact Rounded +xadd207 add -656285310. -107221462. -> -763506772 +xcom207 compare -656285310. -107221462. -> -1 +xdiv207 divide -656285310. -107221462. -> 6.12083904 Inexact Rounded +xdvi207 divideint -656285310. -107221462. -> 6 +xmul207 multiply -656285310. -107221462. -> 7.03678704E+16 Inexact Rounded +xpow207 power -656285310. -107221462 -> 8.05338080E-945381569 Inexact Rounded +xrem207 remainder -656285310. -107221462. -> -12956538 +xsub207 subtract -656285310. -107221462. -> -549063848 +xadd208 add 653397.125 7195.30990 -> 660592.435 Inexact Rounded +xcom208 compare 653397.125 7195.30990 -> 1 +xdiv208 divide 653397.125 7195.30990 -> 90.8087538 Inexact Rounded +xdvi208 divideint 653397.125 7195.30990 -> 90 +xmul208 multiply 653397.125 7195.30990 -> 4.70139480E+9 Inexact Rounded +xpow208 power 653397.125 7195 -> 1.58522983E+41840 Inexact Rounded +xrem208 remainder 653397.125 7195.30990 -> 5819.23400 +xsub208 subtract 653397.125 7195.30990 -> 646201.815 Inexact Rounded +xadd209 add 56221910.0E+857909374 -58.7247929 -> 5.62219100E+857909381 Inexact Rounded +xcom209 compare 56221910.0E+857909374 -58.7247929 -> 1 +xdiv209 divide 56221910.0E+857909374 -58.7247929 -> -9.57379451E+857909379 Inexact Rounded +xdvi209 divideint 56221910.0E+857909374 -58.7247929 -> NaN Division_impossible +xmul209 multiply 56221910.0E+857909374 -58.7247929 -> -3.30162002E+857909383 Inexact Rounded +xpow209 power 56221910.0E+857909374 -59 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem209 remainder 56221910.0E+857909374 -58.7247929 -> NaN Division_impossible +xsub209 subtract 56221910.0E+857909374 -58.7247929 -> 5.62219100E+857909381 Inexact Rounded +xadd210 add 809862859E+643769974 -5.06784016 -> 8.09862859E+643769982 Inexact Rounded +xcom210 compare 809862859E+643769974 -5.06784016 -> 1 +xdiv210 divide 809862859E+643769974 -5.06784016 -> -1.59804341E+643769982 Inexact Rounded +xdvi210 divideint 809862859E+643769974 -5.06784016 -> NaN Division_impossible +xmul210 multiply 809862859E+643769974 -5.06784016 -> -4.10425552E+643769983 Inexact Rounded +xpow210 power 809862859E+643769974 -5 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem210 remainder 809862859E+643769974 -5.06784016 -> NaN Division_impossible +xsub210 subtract 809862859E+643769974 -5.06784016 -> 8.09862859E+643769982 Inexact Rounded +xadd211 add -62011.4563E-117563240 -57.1731586E+115657204 -> -5.71731586E+115657205 Inexact Rounded +xcom211 compare -62011.4563E-117563240 -57.1731586E+115657204 -> 1 +xdiv211 divide -62011.4563E-117563240 -57.1731586E+115657204 -> 1.08462534E-233220441 Inexact Rounded +xdvi211 divideint -62011.4563E-117563240 -57.1731586E+115657204 -> 0 +xmul211 multiply -62011.4563E-117563240 -57.1731586E+115657204 -> 3.54539083E-1906030 Inexact Rounded +xpow211 power -62011.4563E-117563240 -6 -> 1.75860546E+705379411 Inexact Rounded +xrem211 remainder -62011.4563E-117563240 -57.1731586E+115657204 -> -6.20114563E-117563236 +xsub211 subtract -62011.4563E-117563240 -57.1731586E+115657204 -> 5.71731586E+115657205 Inexact Rounded +xadd212 add 315.33351 91588.837E-536020149 -> 315.333510 Inexact Rounded +xcom212 compare 315.33351 91588.837E-536020149 -> 1 +xdiv212 divide 315.33351 91588.837E-536020149 -> 3.44292515E+536020146 Inexact Rounded +xdvi212 divideint 315.33351 91588.837E-536020149 -> NaN Division_impossible +xmul212 multiply 315.33351 91588.837E-536020149 -> 2.88810294E-536020142 Inexact Rounded +xpow212 power 315.33351 9 -> 3.08269902E+22 Inexact Rounded +xrem212 remainder 315.33351 91588.837E-536020149 -> NaN Division_impossible +xsub212 subtract 315.33351 91588.837E-536020149 -> 315.333510 Inexact Rounded +xadd213 add 739.944710 202949.175 -> 203689.120 Inexact Rounded +xcom213 compare 739.944710 202949.175 -> -1 +xdiv213 divide 739.944710 202949.175 -> 0.00364596067 Inexact Rounded +xdvi213 divideint 739.944710 202949.175 -> 0 +xmul213 multiply 739.944710 202949.175 -> 150171168 Inexact Rounded +xpow213 power 739.944710 202949 -> 1.32611729E+582301 Inexact Rounded +xrem213 remainder 739.944710 202949.175 -> 739.944710 +xsub213 subtract 739.944710 202949.175 -> -202209.230 Inexact Rounded +xadd214 add 87686.8016 4204890.40 -> 4292577.20 Inexact Rounded +xcom214 compare 87686.8016 4204890.40 -> -1 +xdiv214 divide 87686.8016 4204890.40 -> 0.0208535285 Inexact Rounded +xdvi214 divideint 87686.8016 4204890.40 -> 0 +xmul214 multiply 87686.8016 4204890.40 -> 3.68713390E+11 Inexact Rounded +xpow214 power 87686.8016 4204890 -> 5.14846981E+20784494 Inexact Rounded +xrem214 remainder 87686.8016 4204890.40 -> 87686.8016 +xsub214 subtract 87686.8016 4204890.40 -> -4117203.60 Inexact Rounded +xadd215 add 987126721.E-725794834 4874166.23 -> 4874166.23 Inexact Rounded +xcom215 compare 987126721.E-725794834 4874166.23 -> -1 +xdiv215 divide 987126721.E-725794834 4874166.23 -> 2.02522170E-725794832 Inexact Rounded +xdvi215 divideint 987126721.E-725794834 4874166.23 -> 0 +xmul215 multiply 987126721.E-725794834 4874166.23 -> 4.81141973E-725794819 Inexact Rounded +xpow215 power 987126721.E-725794834 4874166 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem215 remainder 987126721.E-725794834 4874166.23 -> 9.87126721E-725794826 +xsub215 subtract 987126721.E-725794834 4874166.23 -> -4874166.23 Inexact Rounded +xadd216 add 728148726.E-661695938 32798.5202 -> 32798.5202 Inexact Rounded +xcom216 compare 728148726.E-661695938 32798.5202 -> -1 +xdiv216 divide 728148726.E-661695938 32798.5202 -> 2.22006579E-661695934 Inexact Rounded +xdvi216 divideint 728148726.E-661695938 32798.5202 -> 0 +xmul216 multiply 728148726.E-661695938 32798.5202 -> 2.38822007E-661695925 Inexact Rounded +xpow216 power 728148726.E-661695938 32799 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem216 remainder 728148726.E-661695938 32798.5202 -> 7.28148726E-661695930 +xsub216 subtract 728148726.E-661695938 32798.5202 -> -32798.5202 Inexact Rounded +xadd217 add 7428219.97 667.326760 -> 7428887.30 Inexact Rounded +xcom217 compare 7428219.97 667.326760 -> 1 +xdiv217 divide 7428219.97 667.326760 -> 11131.3084 Inexact Rounded +xdvi217 divideint 7428219.97 667.326760 -> 11131 +xmul217 multiply 7428219.97 667.326760 -> 4.95704997E+9 Inexact Rounded +xpow217 power 7428219.97 667 -> 7.58808510E+4582 Inexact Rounded +xrem217 remainder 7428219.97 667.326760 -> 205.804440 +xsub217 subtract 7428219.97 667.326760 -> 7427552.64 Inexact Rounded +xadd218 add -7291.19212 209.64966E-588526476 -> -7291.19212 Inexact Rounded +xcom218 compare -7291.19212 209.64966E-588526476 -> -1 +xdiv218 divide -7291.19212 209.64966E-588526476 -> -3.47779821E+588526477 Inexact Rounded +xdvi218 divideint -7291.19212 209.64966E-588526476 -> NaN Division_impossible +xmul218 multiply -7291.19212 209.64966E-588526476 -> -1.52859595E-588526470 Inexact Rounded +xpow218 power -7291.19212 2 -> 53161482.5 Inexact Rounded +xrem218 remainder -7291.19212 209.64966E-588526476 -> NaN Division_impossible +xsub218 subtract -7291.19212 209.64966E-588526476 -> -7291.19212 Inexact Rounded +xadd219 add -358.24550 -4447.78675E+601402509 -> -4.44778675E+601402512 Inexact Rounded +xcom219 compare -358.24550 -4447.78675E+601402509 -> 1 +xdiv219 divide -358.24550 -4447.78675E+601402509 -> 8.05446664E-601402511 Inexact Rounded +xdvi219 divideint -358.24550 -4447.78675E+601402509 -> 0 +xmul219 multiply -358.24550 -4447.78675E+601402509 -> 1.59339959E+601402515 Inexact Rounded +xpow219 power -358.24550 -4 -> 6.07123474E-11 Inexact Rounded +xrem219 remainder -358.24550 -4447.78675E+601402509 -> -358.24550 +xsub219 subtract -358.24550 -4447.78675E+601402509 -> 4.44778675E+601402512 Inexact Rounded +xadd220 add 118.621826 -2.72010038 -> 115.901726 Inexact Rounded +xcom220 compare 118.621826 -2.72010038 -> 1 +xdiv220 divide 118.621826 -2.72010038 -> -43.6093561 Inexact Rounded +xdvi220 divideint 118.621826 -2.72010038 -> -43 +xmul220 multiply 118.621826 -2.72010038 -> -322.663274 Inexact Rounded +xpow220 power 118.621826 -3 -> 5.99109471E-7 Inexact Rounded +xrem220 remainder 118.621826 -2.72010038 -> 1.65750966 +xsub220 subtract 118.621826 -2.72010038 -> 121.341926 Inexact Rounded +xadd221 add 8071961.94 -135533740.E-102451543 -> 8071961.94 Inexact Rounded +xcom221 compare 8071961.94 -135533740.E-102451543 -> 1 +xdiv221 divide 8071961.94 -135533740.E-102451543 -> -5.95568450E+102451541 Inexact Rounded +xdvi221 divideint 8071961.94 -135533740.E-102451543 -> NaN Division_impossible +xmul221 multiply 8071961.94 -135533740.E-102451543 -> -1.09402319E-102451528 Inexact Rounded +xpow221 power 8071961.94 -1 -> 1.23885619E-7 Inexact Rounded +xrem221 remainder 8071961.94 -135533740.E-102451543 -> NaN Division_impossible +xsub221 subtract 8071961.94 -135533740.E-102451543 -> 8071961.94 Inexact Rounded +xadd222 add 64262528.5E+812118682 -8692.94447E-732186947 -> 6.42625285E+812118689 Inexact Rounded +xcom222 compare 64262528.5E+812118682 -8692.94447E-732186947 -> 1 +xdiv222 divide 64262528.5E+812118682 -8692.94447E-732186947 -> -Infinity Inexact Overflow Rounded +xdvi222 divideint 64262528.5E+812118682 -8692.94447E-732186947 -> NaN Division_impossible +xmul222 multiply 64262528.5E+812118682 -8692.94447E-732186947 -> -5.58630592E+79931746 Inexact Rounded +xpow222 power 64262528.5E+812118682 -9 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem222 remainder 64262528.5E+812118682 -8692.94447E-732186947 -> NaN Division_impossible +xsub222 subtract 64262528.5E+812118682 -8692.94447E-732186947 -> 6.42625285E+812118689 Inexact Rounded +xadd223 add -35544.4029 -567830.130 -> -603374.533 Inexact Rounded +xcom223 compare -35544.4029 -567830.130 -> 1 +xdiv223 divide -35544.4029 -567830.130 -> 0.0625968948 Inexact Rounded +xdvi223 divideint -35544.4029 -567830.130 -> 0 +xmul223 multiply -35544.4029 -567830.130 -> 2.01831829E+10 Inexact Rounded +xpow223 power -35544.4029 -567830 -> 3.77069368E-2584065 Inexact Rounded +xrem223 remainder -35544.4029 -567830.130 -> -35544.4029 +xsub223 subtract -35544.4029 -567830.130 -> 532285.727 Inexact Rounded +xadd224 add -7.16513047E+59297103 87767.8211 -> -7.16513047E+59297103 Inexact Rounded +xcom224 compare -7.16513047E+59297103 87767.8211 -> -1 +xdiv224 divide -7.16513047E+59297103 87767.8211 -> -8.16373288E+59297098 Inexact Rounded +xdvi224 divideint -7.16513047E+59297103 87767.8211 -> NaN Division_impossible +xmul224 multiply -7.16513047E+59297103 87767.8211 -> -6.28867889E+59297108 Inexact Rounded +xpow224 power -7.16513047E+59297103 87768 -> Infinity Overflow Inexact Rounded +xrem224 remainder -7.16513047E+59297103 87767.8211 -> NaN Division_impossible +xsub224 subtract -7.16513047E+59297103 87767.8211 -> -7.16513047E+59297103 Inexact Rounded +xadd225 add -509.483395 -147242915. -> -147243424 Inexact Rounded +xcom225 compare -509.483395 -147242915. -> 1 +xdiv225 divide -509.483395 -147242915. -> 0.00000346015559 Inexact Rounded +xdvi225 divideint -509.483395 -147242915. -> 0 +xmul225 multiply -509.483395 -147242915. -> 7.50178202E+10 Inexact Rounded +xpow225 power -509.483395 -147242915 -> -3.10760519E-398605718 Inexact Rounded +xrem225 remainder -509.483395 -147242915. -> -509.483395 +xsub225 subtract -509.483395 -147242915. -> 147242406 Inexact Rounded +xadd226 add -7919047.28E+956041629 -367667329 -> -7.91904728E+956041635 Inexact Rounded +xcom226 compare -7919047.28E+956041629 -367667329 -> -1 +xdiv226 divide -7919047.28E+956041629 -367667329 -> 2.15386211E+956041627 Inexact Rounded +xdvi226 divideint -7919047.28E+956041629 -367667329 -> NaN Division_impossible +xmul226 multiply -7919047.28E+956041629 -367667329 -> 2.91157496E+956041644 Inexact Rounded +xpow226 power -7919047.28E+956041629 -367667329 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem226 remainder -7919047.28E+956041629 -367667329 -> NaN Division_impossible +xsub226 subtract -7919047.28E+956041629 -367667329 -> -7.91904728E+956041635 Inexact Rounded +xadd227 add 895612630. -36.4104040 -> 895612594 Inexact Rounded +xcom227 compare 895612630. -36.4104040 -> 1 +xdiv227 divide 895612630. -36.4104040 -> -24597712.0 Inexact Rounded +xdvi227 divideint 895612630. -36.4104040 -> -24597711 +xmul227 multiply 895612630. -36.4104040 -> -3.26096177E+10 Inexact Rounded +xpow227 power 895612630. -36 -> 5.29264130E-323 Inexact Rounded +xrem227 remainder 895612630. -36.4104040 -> 35.0147560 +xsub227 subtract 895612630. -36.4104040 -> 895612666 Inexact Rounded +xadd228 add 25455.4973 2955.00006E+528196218 -> 2.95500006E+528196221 Inexact Rounded +xcom228 compare 25455.4973 2955.00006E+528196218 -> -1 +xdiv228 divide 25455.4973 2955.00006E+528196218 -> 8.61438131E-528196218 Inexact Rounded +xdvi228 divideint 25455.4973 2955.00006E+528196218 -> 0 +xmul228 multiply 25455.4973 2955.00006E+528196218 -> 7.52209960E+528196225 Inexact Rounded +xpow228 power 25455.4973 3 -> 1.64947128E+13 Inexact Rounded +xrem228 remainder 25455.4973 2955.00006E+528196218 -> 25455.4973 +xsub228 subtract 25455.4973 2955.00006E+528196218 -> -2.95500006E+528196221 Inexact Rounded +xadd229 add -112.294144E+273414172 -71448007.7 -> -1.12294144E+273414174 Inexact Rounded +xcom229 compare -112.294144E+273414172 -71448007.7 -> -1 +xdiv229 divide -112.294144E+273414172 -71448007.7 -> 1.57169035E+273414166 Inexact Rounded +xdvi229 divideint -112.294144E+273414172 -71448007.7 -> NaN Division_impossible +xmul229 multiply -112.294144E+273414172 -71448007.7 -> 8.02319287E+273414181 Inexact Rounded +xpow229 power -112.294144E+273414172 -71448008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem229 remainder -112.294144E+273414172 -71448007.7 -> NaN Division_impossible +xsub229 subtract -112.294144E+273414172 -71448007.7 -> -1.12294144E+273414174 Inexact Rounded +xadd230 add 62871.2202 2484.0382E+211662557 -> 2.48403820E+211662560 Inexact Rounded +xcom230 compare 62871.2202 2484.0382E+211662557 -> -1 +xdiv230 divide 62871.2202 2484.0382E+211662557 -> 2.53100859E-211662556 Inexact Rounded +xdvi230 divideint 62871.2202 2484.0382E+211662557 -> 0 +xmul230 multiply 62871.2202 2484.0382E+211662557 -> 1.56174513E+211662565 Inexact Rounded +xpow230 power 62871.2202 2 -> 3.95279033E+9 Inexact Rounded +xrem230 remainder 62871.2202 2484.0382E+211662557 -> 62871.2202 +xsub230 subtract 62871.2202 2484.0382E+211662557 -> -2.48403820E+211662560 Inexact Rounded +xadd231 add 71.9281575 -9810012.5 -> -9809940.57 Inexact Rounded +xcom231 compare 71.9281575 -9810012.5 -> 1 +xdiv231 divide 71.9281575 -9810012.5 -> -0.00000733211680 Inexact Rounded +xdvi231 divideint 71.9281575 -9810012.5 -> -0 +xmul231 multiply 71.9281575 -9810012.5 -> -705616124 Inexact Rounded +xpow231 power 71.9281575 -9810013 -> 2.00363798E-18216203 Inexact Rounded +xrem231 remainder 71.9281575 -9810012.5 -> 71.9281575 +xsub231 subtract 71.9281575 -9810012.5 -> 9810084.43 Inexact Rounded +xadd232 add -6388022. -88.042967 -> -6388110.04 Inexact Rounded +xcom232 compare -6388022. -88.042967 -> -1 +xdiv232 divide -6388022. -88.042967 -> 72555.7329 Inexact Rounded +xdvi232 divideint -6388022. -88.042967 -> 72555 +xmul232 multiply -6388022. -88.042967 -> 562420410 Inexact Rounded +xpow232 power -6388022. -88 -> 1.34201238E-599 Inexact Rounded +xrem232 remainder -6388022. -88.042967 -> -64.529315 +xsub232 subtract -6388022. -88.042967 -> -6387933.96 Inexact Rounded +xadd233 add 372567445. 96.0992141 -> 372567541 Inexact Rounded +xcom233 compare 372567445. 96.0992141 -> 1 +xdiv233 divide 372567445. 96.0992141 -> 3876904.18 Inexact Rounded +xdvi233 divideint 372567445. 96.0992141 -> 3876904 +xmul233 multiply 372567445. 96.0992141 -> 3.58034387E+10 Inexact Rounded +xpow233 power 372567445. 96 -> 6.84968715E+822 Inexact Rounded +xrem233 remainder 372567445. 96.0992141 -> 17.4588536 +xsub233 subtract 372567445. 96.0992141 -> 372567349 Inexact Rounded +xadd234 add 802.156517 -174409310.E-255338020 -> 802.156517 Inexact Rounded +xcom234 compare 802.156517 -174409310.E-255338020 -> 1 +xdiv234 divide 802.156517 -174409310.E-255338020 -> -4.59927579E+255338014 Inexact Rounded +xdvi234 divideint 802.156517 -174409310.E-255338020 -> NaN Division_impossible +xmul234 multiply 802.156517 -174409310.E-255338020 -> -1.39903565E-255338009 Inexact Rounded +xpow234 power 802.156517 -2 -> 0.00000155411005 Inexact Rounded +xrem234 remainder 802.156517 -174409310.E-255338020 -> NaN Division_impossible +xsub234 subtract 802.156517 -174409310.E-255338020 -> 802.156517 Inexact Rounded +xadd235 add -3.65207541 74501982.0 -> 74501978.3 Inexact Rounded +xcom235 compare -3.65207541 74501982.0 -> -1 +xdiv235 divide -3.65207541 74501982.0 -> -4.90198423E-8 Inexact Rounded +xdvi235 divideint -3.65207541 74501982.0 -> -0 +xmul235 multiply -3.65207541 74501982.0 -> -272086856 Inexact Rounded +xpow235 power -3.65207541 74501982 -> 2.10339452E+41910325 Inexact Rounded +xrem235 remainder -3.65207541 74501982.0 -> -3.65207541 +xsub235 subtract -3.65207541 74501982.0 -> -74501985.7 Inexact Rounded +xadd236 add -5297.76981 -859.719404 -> -6157.48921 Inexact Rounded +xcom236 compare -5297.76981 -859.719404 -> -1 +xdiv236 divide -5297.76981 -859.719404 -> 6.16220802 Inexact Rounded +xdvi236 divideint -5297.76981 -859.719404 -> 6 +xmul236 multiply -5297.76981 -859.719404 -> 4554595.50 Inexact Rounded +xpow236 power -5297.76981 -860 -> 1.90523108E-3203 Inexact Rounded +xrem236 remainder -5297.76981 -859.719404 -> -139.453386 +xsub236 subtract -5297.76981 -859.719404 -> -4438.05041 Inexact Rounded +xadd237 add -684172.592 766.448597E+288361959 -> 7.66448597E+288361961 Inexact Rounded +xcom237 compare -684172.592 766.448597E+288361959 -> -1 +xdiv237 divide -684172.592 766.448597E+288361959 -> -8.92652938E-288361957 Inexact Rounded +xdvi237 divideint -684172.592 766.448597E+288361959 -> -0 +xmul237 multiply -684172.592 766.448597E+288361959 -> -5.24383123E+288361967 Inexact Rounded +xpow237 power -684172.592 8 -> 4.80093005E+46 Inexact Rounded +xrem237 remainder -684172.592 766.448597E+288361959 -> -684172.592 +xsub237 subtract -684172.592 766.448597E+288361959 -> -7.66448597E+288361961 Inexact Rounded +xadd238 add 626919.219 57469.8727E+13188610 -> 5.74698727E+13188614 Inexact Rounded +xcom238 compare 626919.219 57469.8727E+13188610 -> -1 +xdiv238 divide 626919.219 57469.8727E+13188610 -> 1.09086586E-13188609 Inexact Rounded +xdvi238 divideint 626919.219 57469.8727E+13188610 -> 0 +xmul238 multiply 626919.219 57469.8727E+13188610 -> 3.60289677E+13188620 Inexact Rounded +xpow238 power 626919.219 6 -> 6.07112959E+34 Inexact Rounded +xrem238 remainder 626919.219 57469.8727E+13188610 -> 626919.219 +xsub238 subtract 626919.219 57469.8727E+13188610 -> -5.74698727E+13188614 Inexact Rounded +xadd239 add -77480.5840 893265.594E+287982552 -> 8.93265594E+287982557 Inexact Rounded +xcom239 compare -77480.5840 893265.594E+287982552 -> -1 +xdiv239 divide -77480.5840 893265.594E+287982552 -> -8.67385742E-287982554 Inexact Rounded +xdvi239 divideint -77480.5840 893265.594E+287982552 -> -0 +xmul239 multiply -77480.5840 893265.594E+287982552 -> -6.92107399E+287982562 Inexact Rounded +xpow239 power -77480.5840 9 -> -1.00631969E+44 Inexact Rounded +xrem239 remainder -77480.5840 893265.594E+287982552 -> -77480.5840 +xsub239 subtract -77480.5840 893265.594E+287982552 -> -8.93265594E+287982557 Inexact Rounded +xadd240 add -7177620.29 7786343.83 -> 608723.54 +xcom240 compare -7177620.29 7786343.83 -> -1 +xdiv240 divide -7177620.29 7786343.83 -> -0.921821647 Inexact Rounded +xdvi240 divideint -7177620.29 7786343.83 -> -0 +xmul240 multiply -7177620.29 7786343.83 -> -5.58874195E+13 Inexact Rounded +xpow240 power -7177620.29 7786344 -> 2.96037074E+53383022 Inexact Rounded +xrem240 remainder -7177620.29 7786343.83 -> -7177620.29 +xsub240 subtract -7177620.29 7786343.83 -> -14963964.1 Inexact Rounded +xadd241 add 9.6224130 4.50355112 -> 14.1259641 Inexact Rounded +xcom241 compare 9.6224130 4.50355112 -> 1 +xdiv241 divide 9.6224130 4.50355112 -> 2.13662791 Inexact Rounded +xdvi241 divideint 9.6224130 4.50355112 -> 2 +xmul241 multiply 9.6224130 4.50355112 -> 43.3350288 Inexact Rounded +xpow241 power 9.6224130 5 -> 82493.5448 Inexact Rounded +xrem241 remainder 9.6224130 4.50355112 -> 0.61531076 +xsub241 subtract 9.6224130 4.50355112 -> 5.11886188 +xadd242 add -66.6337347E-597410086 -818812885 -> -818812885 Inexact Rounded +xcom242 compare -66.6337347E-597410086 -818812885 -> 1 +xdiv242 divide -66.6337347E-597410086 -818812885 -> 8.13784638E-597410094 Inexact Rounded +xdvi242 divideint -66.6337347E-597410086 -818812885 -> 0 +xmul242 multiply -66.6337347E-597410086 -818812885 -> 5.45605605E-597410076 Inexact Rounded +xpow242 power -66.6337347E-597410086 -818812885 -> -Infinity Overflow Inexact Rounded +xrem242 remainder -66.6337347E-597410086 -818812885 -> -6.66337347E-597410085 +xsub242 subtract -66.6337347E-597410086 -818812885 -> 818812885 Inexact Rounded +xadd243 add 65587553.7 600574.736 -> 66188128.4 Inexact Rounded +xcom243 compare 65587553.7 600574.736 -> 1 +xdiv243 divide 65587553.7 600574.736 -> 109.207980 Inexact Rounded +xdvi243 divideint 65587553.7 600574.736 -> 109 +xmul243 multiply 65587553.7 600574.736 -> 3.93902277E+13 Inexact Rounded +xpow243 power 65587553.7 600575 -> 3.40404817E+4694587 Inexact Rounded +xrem243 remainder 65587553.7 600574.736 -> 124907.476 +xsub243 subtract 65587553.7 600574.736 -> 64986979.0 Inexact Rounded +xadd244 add -32401.939 -585200217. -> -585232619 Inexact Rounded +xcom244 compare -32401.939 -585200217. -> 1 +xdiv244 divide -32401.939 -585200217. -> 0.0000553689798 Inexact Rounded +xdvi244 divideint -32401.939 -585200217. -> 0 +xmul244 multiply -32401.939 -585200217. -> 1.89616217E+13 Inexact Rounded +xpow244 power -32401.939 -585200217 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem244 remainder -32401.939 -585200217. -> -32401.939 +xsub244 subtract -32401.939 -585200217. -> 585167815 Inexact Rounded +xadd245 add 69573.988 -9.77003465E+740933668 -> -9.77003465E+740933668 Inexact Rounded +xcom245 compare 69573.988 -9.77003465E+740933668 -> 1 +xdiv245 divide 69573.988 -9.77003465E+740933668 -> -7.12116082E-740933665 Inexact Rounded +xdvi245 divideint 69573.988 -9.77003465E+740933668 -> -0 +xmul245 multiply 69573.988 -9.77003465E+740933668 -> -6.79740273E+740933673 Inexact Rounded +xpow245 power 69573.988 -10 -> 3.76297229E-49 Inexact Rounded +xrem245 remainder 69573.988 -9.77003465E+740933668 -> 69573.988 +xsub245 subtract 69573.988 -9.77003465E+740933668 -> 9.77003465E+740933668 Inexact Rounded +xadd246 add 2362.06251 -433149546.E-152643629 -> 2362.06251 Inexact Rounded +xcom246 compare 2362.06251 -433149546.E-152643629 -> 1 +xdiv246 divide 2362.06251 -433149546.E-152643629 -> -5.45322633E+152643623 Inexact Rounded +xdvi246 divideint 2362.06251 -433149546.E-152643629 -> NaN Division_impossible +xmul246 multiply 2362.06251 -433149546.E-152643629 -> -1.02312630E-152643617 Inexact Rounded +xpow246 power 2362.06251 -4 -> 3.21243577E-14 Inexact Rounded +xrem246 remainder 2362.06251 -433149546.E-152643629 -> NaN Division_impossible +xsub246 subtract 2362.06251 -433149546.E-152643629 -> 2362.06251 Inexact Rounded +xadd247 add -615.23488E+249953452 -21437483.7 -> -6.15234880E+249953454 Inexact Rounded +xcom247 compare -615.23488E+249953452 -21437483.7 -> -1 +xdiv247 divide -615.23488E+249953452 -21437483.7 -> 2.86990250E+249953447 Inexact Rounded +xdvi247 divideint -615.23488E+249953452 -21437483.7 -> NaN Division_impossible +xmul247 multiply -615.23488E+249953452 -21437483.7 -> 1.31890877E+249953462 Inexact Rounded +xpow247 power -615.23488E+249953452 -21437484 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem247 remainder -615.23488E+249953452 -21437483.7 -> NaN Division_impossible +xsub247 subtract -615.23488E+249953452 -21437483.7 -> -6.15234880E+249953454 Inexact Rounded +xadd248 add 216741082. 250290244 -> 467031326 +xcom248 compare 216741082. 250290244 -> -1 +xdiv248 divide 216741082. 250290244 -> 0.865958970 Inexact Rounded +xdvi248 divideint 216741082. 250290244 -> 0 +xmul248 multiply 216741082. 250290244 -> 5.42481783E+16 Inexact Rounded +xpow248 power 216741082. 250290244 -> Infinity Overflow Inexact Rounded +xrem248 remainder 216741082. 250290244 -> 216741082 +xsub248 subtract 216741082. 250290244 -> -33549162 +xadd249 add -6364720.49 5539245.64 -> -825474.85 +xcom249 compare -6364720.49 5539245.64 -> -1 +xdiv249 divide -6364720.49 5539245.64 -> -1.14902297 Inexact Rounded +xdvi249 divideint -6364720.49 5539245.64 -> -1 +xmul249 multiply -6364720.49 5539245.64 -> -3.52557502E+13 Inexact Rounded +xpow249 power -6364720.49 5539246 -> 2.96894641E+37687807 Inexact Rounded +xrem249 remainder -6364720.49 5539245.64 -> -825474.85 +xsub249 subtract -6364720.49 5539245.64 -> -11903966.1 Inexact Rounded +xadd250 add -814599.475 -14.5431191 -> -814614.018 Inexact Rounded +xcom250 compare -814599.475 -14.5431191 -> -1 +xdiv250 divide -814599.475 -14.5431191 -> 56012.7074 Inexact Rounded +xdvi250 divideint -814599.475 -14.5431191 -> 56012 +xmul250 multiply -814599.475 -14.5431191 -> 11846817.2 Inexact Rounded +xpow250 power -814599.475 -15 -> -2.16689622E-89 Inexact Rounded +xrem250 remainder -814599.475 -14.5431191 -> -10.2879708 +xsub250 subtract -814599.475 -14.5431191 -> -814584.932 Inexact Rounded +xadd251 add -877498.755 507408724E-168628106 -> -877498.755 Inexact Rounded +xcom251 compare -877498.755 507408724E-168628106 -> -1 +xdiv251 divide -877498.755 507408724E-168628106 -> -1.72937262E+168628103 Inexact Rounded +xdvi251 divideint -877498.755 507408724E-168628106 -> NaN Division_impossible +xmul251 multiply -877498.755 507408724E-168628106 -> -4.45250524E-168628092 Inexact Rounded +xpow251 power -877498.755 5 -> -5.20274505E+29 Inexact Rounded +xrem251 remainder -877498.755 507408724E-168628106 -> NaN Division_impossible +xsub251 subtract -877498.755 507408724E-168628106 -> -877498.755 Inexact Rounded +xadd252 add 10634446.5E+475783861 50.7213056E+17807809 -> 1.06344465E+475783868 Inexact Rounded +xcom252 compare 10634446.5E+475783861 50.7213056E+17807809 -> 1 +xdiv252 divide 10634446.5E+475783861 50.7213056E+17807809 -> 2.09664289E+457976057 Inexact Rounded +xdvi252 divideint 10634446.5E+475783861 50.7213056E+17807809 -> NaN Division_impossible +xmul252 multiply 10634446.5E+475783861 50.7213056E+17807809 -> 5.39393011E+493591678 Inexact Rounded +xpow252 power 10634446.5E+475783861 5 -> Infinity Overflow Inexact Rounded +xrem252 remainder 10634446.5E+475783861 50.7213056E+17807809 -> NaN Division_impossible +xsub252 subtract 10634446.5E+475783861 50.7213056E+17807809 -> 1.06344465E+475783868 Inexact Rounded +xadd253 add -162726.257E-597285918 -4391.54799 -> -4391.54799 Inexact Rounded +xcom253 compare -162726.257E-597285918 -4391.54799 -> 1 +xdiv253 divide -162726.257E-597285918 -4391.54799 -> 3.70544185E-597285917 Inexact Rounded +xdvi253 divideint -162726.257E-597285918 -4391.54799 -> 0 +xmul253 multiply -162726.257E-597285918 -4391.54799 -> 7.14620167E-597285910 Inexact Rounded +xpow253 power -162726.257E-597285918 -4392 -> Infinity Overflow Inexact Rounded +xrem253 remainder -162726.257E-597285918 -4391.54799 -> -1.62726257E-597285913 +xsub253 subtract -162726.257E-597285918 -4391.54799 -> 4391.54799 Inexact Rounded +xadd254 add 700354586.E-99856707 7198.0493E+436250299 -> 7.19804930E+436250302 Inexact Rounded +xcom254 compare 700354586.E-99856707 7198.0493E+436250299 -> -1 +xdiv254 divide 700354586.E-99856707 7198.0493E+436250299 -> 9.72978312E-536107002 Inexact Rounded +xdvi254 divideint 700354586.E-99856707 7198.0493E+436250299 -> 0 +xmul254 multiply 700354586.E-99856707 7198.0493E+436250299 -> 5.04118684E+336393604 Inexact Rounded +xpow254 power 700354586.E-99856707 7 -> 8.26467610E-698996888 Inexact Rounded +xrem254 remainder 700354586.E-99856707 7198.0493E+436250299 -> 7.00354586E-99856699 +xsub254 subtract 700354586.E-99856707 7198.0493E+436250299 -> -7.19804930E+436250302 Inexact Rounded +xadd255 add 39617663E-463704664 -895.290346 -> -895.290346 Inexact Rounded +xcom255 compare 39617663E-463704664 -895.290346 -> 1 +xdiv255 divide 39617663E-463704664 -895.290346 -> -4.42511898E-463704660 Inexact Rounded +xdvi255 divideint 39617663E-463704664 -895.290346 -> -0 +xmul255 multiply 39617663E-463704664 -895.290346 -> -3.54693112E-463704654 Inexact Rounded +xpow255 power 39617663E-463704664 -895 -> Infinity Overflow Inexact Rounded +xrem255 remainder 39617663E-463704664 -895.290346 -> 3.9617663E-463704657 +xsub255 subtract 39617663E-463704664 -895.290346 -> 895.290346 Inexact Rounded +xadd256 add 5350882.59 -36329829 -> -30978946.4 Inexact Rounded +xcom256 compare 5350882.59 -36329829 -> 1 +xdiv256 divide 5350882.59 -36329829 -> -0.147286204 Inexact Rounded +xdvi256 divideint 5350882.59 -36329829 -> -0 +xmul256 multiply 5350882.59 -36329829 -> -1.94396649E+14 Inexact Rounded +xpow256 power 5350882.59 -36329829 -> 9.77006107E-244442546 Inexact Rounded +xrem256 remainder 5350882.59 -36329829 -> 5350882.59 +xsub256 subtract 5350882.59 -36329829 -> 41680711.6 Inexact Rounded +xadd257 add 91966.4084E+210382952 166740.46E-42001390 -> 9.19664084E+210382956 Inexact Rounded +xcom257 compare 91966.4084E+210382952 166740.46E-42001390 -> 1 +xdiv257 divide 91966.4084E+210382952 166740.46E-42001390 -> 5.51554244E+252384341 Inexact Rounded +xdvi257 divideint 91966.4084E+210382952 166740.46E-42001390 -> NaN Division_impossible +xmul257 multiply 91966.4084E+210382952 166740.46E-42001390 -> 1.53345212E+168381572 Inexact Rounded +xpow257 power 91966.4084E+210382952 2 -> 8.45782027E+420765913 Inexact Rounded +xrem257 remainder 91966.4084E+210382952 166740.46E-42001390 -> NaN Division_impossible +xsub257 subtract 91966.4084E+210382952 166740.46E-42001390 -> 9.19664084E+210382956 Inexact Rounded +xadd258 add 231899031.E-481759076 726.337100 -> 726.337100 Inexact Rounded +xcom258 compare 231899031.E-481759076 726.337100 -> -1 +xdiv258 divide 231899031.E-481759076 726.337100 -> 3.19271907E-481759071 Inexact Rounded +xdvi258 divideint 231899031.E-481759076 726.337100 -> 0 +xmul258 multiply 231899031.E-481759076 726.337100 -> 1.68436870E-481759065 Inexact Rounded +xpow258 power 231899031.E-481759076 726 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem258 remainder 231899031.E-481759076 726.337100 -> 2.31899031E-481759068 +xsub258 subtract 231899031.E-481759076 726.337100 -> -726.337100 Inexact Rounded +xadd259 add -9611312.33 22109735.9 -> 12498423.6 Inexact Rounded +xcom259 compare -9611312.33 22109735.9 -> -1 +xdiv259 divide -9611312.33 22109735.9 -> -0.434709504 Inexact Rounded +xdvi259 divideint -9611312.33 22109735.9 -> -0 +xmul259 multiply -9611312.33 22109735.9 -> -2.12503577E+14 Inexact Rounded +xpow259 power -9611312.33 22109736 -> 6.74530828E+154387481 Inexact Rounded +xrem259 remainder -9611312.33 22109735.9 -> -9611312.33 +xsub259 subtract -9611312.33 22109735.9 -> -31721048.2 Inexact Rounded +xadd260 add -5604938.15E-36812542 735937577. -> 735937577 Inexact Rounded +xcom260 compare -5604938.15E-36812542 735937577. -> -1 +xdiv260 divide -5604938.15E-36812542 735937577. -> -7.61605104E-36812545 Inexact Rounded +xdvi260 divideint -5604938.15E-36812542 735937577. -> -0 +xmul260 multiply -5604938.15E-36812542 735937577. -> -4.12488460E-36812527 Inexact Rounded +xpow260 power -5604938.15E-36812542 735937577 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem260 remainder -5604938.15E-36812542 735937577. -> -5.60493815E-36812536 +xsub260 subtract -5604938.15E-36812542 735937577. -> -735937577 Inexact Rounded +xadd261 add 693881413. 260547224E-480281418 -> 693881413 Inexact Rounded +xcom261 compare 693881413. 260547224E-480281418 -> 1 +xdiv261 divide 693881413. 260547224E-480281418 -> 2.66316947E+480281418 Inexact Rounded +xdvi261 divideint 693881413. 260547224E-480281418 -> NaN Division_impossible +xmul261 multiply 693881413. 260547224E-480281418 -> 1.80788876E-480281401 Inexact Rounded +xpow261 power 693881413. 3 -> 3.34084066E+26 Inexact Rounded +xrem261 remainder 693881413. 260547224E-480281418 -> NaN Division_impossible +xsub261 subtract 693881413. 260547224E-480281418 -> 693881413 Inexact Rounded +xadd262 add -34865.7378E-368768024 2297117.88 -> 2297117.88 Inexact Rounded +xcom262 compare -34865.7378E-368768024 2297117.88 -> -1 +xdiv262 divide -34865.7378E-368768024 2297117.88 -> -1.51780360E-368768026 Inexact Rounded +xdvi262 divideint -34865.7378E-368768024 2297117.88 -> -0 +xmul262 multiply -34865.7378E-368768024 2297117.88 -> -8.00907097E-368768014 Inexact Rounded +xpow262 power -34865.7378E-368768024 2297118 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem262 remainder -34865.7378E-368768024 2297117.88 -> -3.48657378E-368768020 +xsub262 subtract -34865.7378E-368768024 2297117.88 -> -2297117.88 Inexact Rounded +xadd263 add 1123.32456 7.86747918E+930888796 -> 7.86747918E+930888796 Inexact Rounded +xcom263 compare 1123.32456 7.86747918E+930888796 -> -1 +xdiv263 divide 1123.32456 7.86747918E+930888796 -> 1.42780748E-930888794 Inexact Rounded +xdvi263 divideint 1123.32456 7.86747918E+930888796 -> 0 +xmul263 multiply 1123.32456 7.86747918E+930888796 -> 8.83773259E+930888799 Inexact Rounded +xpow263 power 1123.32456 8 -> 2.53537401E+24 Inexact Rounded +xrem263 remainder 1123.32456 7.86747918E+930888796 -> 1123.32456 +xsub263 subtract 1123.32456 7.86747918E+930888796 -> -7.86747918E+930888796 Inexact Rounded +xadd264 add 56.6607465E+467812565 909552512E+764516200 -> 9.09552512E+764516208 Inexact Rounded +xcom264 compare 56.6607465E+467812565 909552512E+764516200 -> -1 +xdiv264 divide 56.6607465E+467812565 909552512E+764516200 -> 6.22951899E-296703643 Inexact Rounded +xdvi264 divideint 56.6607465E+467812565 909552512E+764516200 -> 0 +xmul264 multiply 56.6607465E+467812565 909552512E+764516200 -> Infinity Inexact Overflow Rounded +xpow264 power 56.6607465E+467812565 9 -> Infinity Overflow Inexact Rounded +xrem264 remainder 56.6607465E+467812565 909552512E+764516200 -> 5.66607465E+467812566 +xsub264 subtract 56.6607465E+467812565 909552512E+764516200 -> -9.09552512E+764516208 Inexact Rounded +xadd265 add -1.85771840E+365552540 -73028339.7 -> -1.85771840E+365552540 Inexact Rounded +xcom265 compare -1.85771840E+365552540 -73028339.7 -> -1 +xdiv265 divide -1.85771840E+365552540 -73028339.7 -> 2.54383217E+365552532 Inexact Rounded +xdvi265 divideint -1.85771840E+365552540 -73028339.7 -> NaN Division_impossible +xmul265 multiply -1.85771840E+365552540 -73028339.7 -> 1.35666090E+365552548 Inexact Rounded +xpow265 power -1.85771840E+365552540 -73028340 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem265 remainder -1.85771840E+365552540 -73028339.7 -> NaN Division_impossible +xsub265 subtract -1.85771840E+365552540 -73028339.7 -> -1.85771840E+365552540 Inexact Rounded +xadd266 add 34.1935525 -40767.6450 -> -40733.4514 Inexact Rounded +xcom266 compare 34.1935525 -40767.6450 -> 1 +xdiv266 divide 34.1935525 -40767.6450 -> -0.000838742402 Inexact Rounded +xdvi266 divideint 34.1935525 -40767.6450 -> -0 +xmul266 multiply 34.1935525 -40767.6450 -> -1393990.61 Inexact Rounded +xpow266 power 34.1935525 -40768 -> 1.45174210E-62536 Inexact Rounded +xrem266 remainder 34.1935525 -40767.6450 -> 34.1935525 +xsub266 subtract 34.1935525 -40767.6450 -> 40801.8386 Inexact Rounded +xadd267 add 26.0009168E+751618294 -304019.929 -> 2.60009168E+751618295 Inexact Rounded +xcom267 compare 26.0009168E+751618294 -304019.929 -> 1 +xdiv267 divide 26.0009168E+751618294 -304019.929 -> -8.55237250E+751618289 Inexact Rounded +xdvi267 divideint 26.0009168E+751618294 -304019.929 -> NaN Division_impossible +xmul267 multiply 26.0009168E+751618294 -304019.929 -> -7.90479688E+751618300 Inexact Rounded +xpow267 power 26.0009168E+751618294 -304020 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem267 remainder 26.0009168E+751618294 -304019.929 -> NaN Division_impossible +xsub267 subtract 26.0009168E+751618294 -304019.929 -> 2.60009168E+751618295 Inexact Rounded +xadd268 add -58.4853072E+588540055 -4647.3205 -> -5.84853072E+588540056 Inexact Rounded +xcom268 compare -58.4853072E+588540055 -4647.3205 -> -1 +xdiv268 divide -58.4853072E+588540055 -4647.3205 -> 1.25847372E+588540053 Inexact Rounded +xdvi268 divideint -58.4853072E+588540055 -4647.3205 -> NaN Division_impossible +xmul268 multiply -58.4853072E+588540055 -4647.3205 -> 2.71799967E+588540060 Inexact Rounded +xpow268 power -58.4853072E+588540055 -4647 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem268 remainder -58.4853072E+588540055 -4647.3205 -> NaN Division_impossible +xsub268 subtract -58.4853072E+588540055 -4647.3205 -> -5.84853072E+588540056 Inexact Rounded +xadd269 add 51.025101 -4467691.57 -> -4467640.54 Inexact Rounded +xcom269 compare 51.025101 -4467691.57 -> 1 +xdiv269 divide 51.025101 -4467691.57 -> -0.0000114209095 Inexact Rounded +xdvi269 divideint 51.025101 -4467691.57 -> -0 +xmul269 multiply 51.025101 -4467691.57 -> -227964414 Inexact Rounded +xpow269 power 51.025101 -4467692 -> 4.49462589E-7629853 Inexact Rounded +xrem269 remainder 51.025101 -4467691.57 -> 51.025101 +xsub269 subtract 51.025101 -4467691.57 -> 4467742.60 Inexact Rounded +xadd270 add -2214.76582 379785372E+223117572 -> 3.79785372E+223117580 Inexact Rounded +xcom270 compare -2214.76582 379785372E+223117572 -> -1 +xdiv270 divide -2214.76582 379785372E+223117572 -> -5.83162487E-223117578 Inexact Rounded +xdvi270 divideint -2214.76582 379785372E+223117572 -> -0 +xmul270 multiply -2214.76582 379785372E+223117572 -> -8.41135661E+223117583 Inexact Rounded +xpow270 power -2214.76582 4 -> 2.40608658E+13 Inexact Rounded +xrem270 remainder -2214.76582 379785372E+223117572 -> -2214.76582 +xsub270 subtract -2214.76582 379785372E+223117572 -> -3.79785372E+223117580 Inexact Rounded +xadd271 add -2564.75207E-841443929 -653498187 -> -653498187 Inexact Rounded +xcom271 compare -2564.75207E-841443929 -653498187 -> 1 +xdiv271 divide -2564.75207E-841443929 -653498187 -> 3.92465063E-841443935 Inexact Rounded +xdvi271 divideint -2564.75207E-841443929 -653498187 -> 0 +xmul271 multiply -2564.75207E-841443929 -653498187 -> 1.67606083E-841443917 Inexact Rounded +xpow271 power -2564.75207E-841443929 -653498187 -> -Infinity Overflow Inexact Rounded +xrem271 remainder -2564.75207E-841443929 -653498187 -> -2.56475207E-841443926 +xsub271 subtract -2564.75207E-841443929 -653498187 -> 653498187 Inexact Rounded +xadd272 add 513115529. 27775075.6E+217133352 -> 2.77750756E+217133359 Inexact Rounded +xcom272 compare 513115529. 27775075.6E+217133352 -> -1 +xdiv272 divide 513115529. 27775075.6E+217133352 -> 1.84739562E-217133351 Inexact Rounded +xdvi272 divideint 513115529. 27775075.6E+217133352 -> 0 +xmul272 multiply 513115529. 27775075.6E+217133352 -> 1.42518226E+217133368 Inexact Rounded +xpow272 power 513115529. 3 -> 1.35096929E+26 Inexact Rounded +xrem272 remainder 513115529. 27775075.6E+217133352 -> 513115529 +xsub272 subtract 513115529. 27775075.6E+217133352 -> -2.77750756E+217133359 Inexact Rounded +xadd273 add -247157.208 -532990.453 -> -780147.661 +xcom273 compare -247157.208 -532990.453 -> 1 +xdiv273 divide -247157.208 -532990.453 -> 0.463717890 Inexact Rounded +xdvi273 divideint -247157.208 -532990.453 -> 0 +xmul273 multiply -247157.208 -532990.453 -> 1.31732432E+11 Inexact Rounded +xpow273 power -247157.208 -532990 -> 1.48314033E-2874401 Inexact Rounded +xrem273 remainder -247157.208 -532990.453 -> -247157.208 +xsub273 subtract -247157.208 -532990.453 -> 285833.245 +xadd274 add 40.2490764E-339482253 7626.85442E+594264540 -> 7.62685442E+594264543 Inexact Rounded +xcom274 compare 40.2490764E-339482253 7626.85442E+594264540 -> -1 +xdiv274 divide 40.2490764E-339482253 7626.85442E+594264540 -> 5.27728395E-933746796 Inexact Rounded +xdvi274 divideint 40.2490764E-339482253 7626.85442E+594264540 -> 0 +xmul274 multiply 40.2490764E-339482253 7626.85442E+594264540 -> 3.06973846E+254782292 Inexact Rounded +xpow274 power 40.2490764E-339482253 8 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem274 remainder 40.2490764E-339482253 7626.85442E+594264540 -> 4.02490764E-339482252 +xsub274 subtract 40.2490764E-339482253 7626.85442E+594264540 -> -7.62685442E+594264543 Inexact Rounded +xadd275 add -1156008.8 -8870382.36 -> -10026391.2 Inexact Rounded +xcom275 compare -1156008.8 -8870382.36 -> 1 +xdiv275 divide -1156008.8 -8870382.36 -> 0.130322319 Inexact Rounded +xdvi275 divideint -1156008.8 -8870382.36 -> 0 +xmul275 multiply -1156008.8 -8870382.36 -> 1.02542401E+13 Inexact Rounded +xpow275 power -1156008.8 -8870382 -> 4.32494996E-53780782 Inexact Rounded +xrem275 remainder -1156008.8 -8870382.36 -> -1156008.80 +xsub275 subtract -1156008.8 -8870382.36 -> 7714373.56 +xadd276 add 880097928. -52455011.1E+204538218 -> -5.24550111E+204538225 Inexact Rounded +xcom276 compare 880097928. -52455011.1E+204538218 -> 1 +xdiv276 divide 880097928. -52455011.1E+204538218 -> -1.67781478E-204538217 Inexact Rounded +xdvi276 divideint 880097928. -52455011.1E+204538218 -> -0 +xmul276 multiply 880097928. -52455011.1E+204538218 -> -4.61655466E+204538234 Inexact Rounded +xpow276 power 880097928. -5 -> 1.89384751E-45 Inexact Rounded +xrem276 remainder 880097928. -52455011.1E+204538218 -> 880097928 +xsub276 subtract 880097928. -52455011.1E+204538218 -> 5.24550111E+204538225 Inexact Rounded +xadd277 add 5796.2524 34458329.7E+832129426 -> 3.44583297E+832129433 Inexact Rounded +xcom277 compare 5796.2524 34458329.7E+832129426 -> -1 +xdiv277 divide 5796.2524 34458329.7E+832129426 -> 1.68210486E-832129430 Inexact Rounded +xdvi277 divideint 5796.2524 34458329.7E+832129426 -> 0 +xmul277 multiply 5796.2524 34458329.7E+832129426 -> 1.99729176E+832129437 Inexact Rounded +xpow277 power 5796.2524 3 -> 1.94734037E+11 Inexact Rounded +xrem277 remainder 5796.2524 34458329.7E+832129426 -> 5796.2524 +xsub277 subtract 5796.2524 34458329.7E+832129426 -> -3.44583297E+832129433 Inexact Rounded +xadd278 add 27.1000923E-218032223 -45.0198341 -> -45.0198341 Inexact Rounded +xcom278 compare 27.1000923E-218032223 -45.0198341 -> 1 +xdiv278 divide 27.1000923E-218032223 -45.0198341 -> -6.01958955E-218032224 Inexact Rounded +xdvi278 divideint 27.1000923E-218032223 -45.0198341 -> -0 +xmul278 multiply 27.1000923E-218032223 -45.0198341 -> -1.22004166E-218032220 Inexact Rounded +xpow278 power 27.1000923E-218032223 -45 -> Infinity Overflow Inexact Rounded +xrem278 remainder 27.1000923E-218032223 -45.0198341 -> 2.71000923E-218032222 +xsub278 subtract 27.1000923E-218032223 -45.0198341 -> 45.0198341 Inexact Rounded +xadd279 add 42643477.8 26118465E-730390549 -> 42643477.8 Inexact Rounded +xcom279 compare 42643477.8 26118465E-730390549 -> 1 +xdiv279 divide 42643477.8 26118465E-730390549 -> 1.63269464E+730390549 Inexact Rounded +xdvi279 divideint 42643477.8 26118465E-730390549 -> NaN Division_impossible +xmul279 multiply 42643477.8 26118465E-730390549 -> 1.11378218E-730390534 Inexact Rounded +xpow279 power 42643477.8 3 -> 7.75457230E+22 Inexact Rounded +xrem279 remainder 42643477.8 26118465E-730390549 -> NaN Division_impossible +xsub279 subtract 42643477.8 26118465E-730390549 -> 42643477.8 Inexact Rounded +xadd280 add -31918.9176E-163031657 -21.5422824E-807317258 -> -3.19189176E-163031653 Inexact Rounded +xcom280 compare -31918.9176E-163031657 -21.5422824E-807317258 -> -1 +xdiv280 divide -31918.9176E-163031657 -21.5422824E-807317258 -> 1.48168690E+644285604 Inexact Rounded +xdvi280 divideint -31918.9176E-163031657 -21.5422824E-807317258 -> NaN Division_impossible +xmul280 multiply -31918.9176E-163031657 -21.5422824E-807317258 -> 6.87606337E-970348910 Inexact Rounded +xpow280 power -31918.9176E-163031657 -2 -> 9.81530250E+326063304 Inexact Rounded +xrem280 remainder -31918.9176E-163031657 -21.5422824E-807317258 -> NaN Division_impossible +xsub280 subtract -31918.9176E-163031657 -21.5422824E-807317258 -> -3.19189176E-163031653 Inexact Rounded +xadd281 add 84224841.0 2.62548255E+647087608 -> 2.62548255E+647087608 Inexact Rounded +xcom281 compare 84224841.0 2.62548255E+647087608 -> -1 +xdiv281 divide 84224841.0 2.62548255E+647087608 -> 3.20797565E-647087601 Inexact Rounded +xdvi281 divideint 84224841.0 2.62548255E+647087608 -> 0 +xmul281 multiply 84224841.0 2.62548255E+647087608 -> 2.21130850E+647087616 Inexact Rounded +xpow281 power 84224841.0 3 -> 5.97476185E+23 Inexact Rounded +xrem281 remainder 84224841.0 2.62548255E+647087608 -> 84224841.0 +xsub281 subtract 84224841.0 2.62548255E+647087608 -> -2.62548255E+647087608 Inexact Rounded +xadd282 add -64413698.9 -6674.1055E-701047852 -> -64413698.9 Inexact Rounded +xcom282 compare -64413698.9 -6674.1055E-701047852 -> -1 +xdiv282 divide -64413698.9 -6674.1055E-701047852 -> 9.65128569E+701047855 Inexact Rounded +xdvi282 divideint -64413698.9 -6674.1055E-701047852 -> NaN Division_impossible +xmul282 multiply -64413698.9 -6674.1055E-701047852 -> 4.29903822E-701047841 Inexact Rounded +xpow282 power -64413698.9 -7 -> -2.17346338E-55 Inexact Rounded +xrem282 remainder -64413698.9 -6674.1055E-701047852 -> NaN Division_impossible +xsub282 subtract -64413698.9 -6674.1055E-701047852 -> -64413698.9 Inexact Rounded +xadd283 add -62.5059208 9.5795779E-898350012 -> -62.5059208 Inexact Rounded +xcom283 compare -62.5059208 9.5795779E-898350012 -> -1 +xdiv283 divide -62.5059208 9.5795779E-898350012 -> -6.52491388E+898350012 Inexact Rounded +xdvi283 divideint -62.5059208 9.5795779E-898350012 -> NaN Division_impossible +xmul283 multiply -62.5059208 9.5795779E-898350012 -> -5.98780338E-898350010 Inexact Rounded +xpow283 power -62.5059208 10 -> 9.10356659E+17 Inexact Rounded +xrem283 remainder -62.5059208 9.5795779E-898350012 -> NaN Division_impossible +xsub283 subtract -62.5059208 9.5795779E-898350012 -> -62.5059208 Inexact Rounded +xadd284 add 9090950.80 436.400932 -> 9091387.20 Inexact Rounded +xcom284 compare 9090950.80 436.400932 -> 1 +xdiv284 divide 9090950.80 436.400932 -> 20831.6485 Inexact Rounded +xdvi284 divideint 9090950.80 436.400932 -> 20831 +xmul284 multiply 9090950.80 436.400932 -> 3.96729940E+9 Inexact Rounded +xpow284 power 9090950.80 436 -> 8.98789557E+3033 Inexact Rounded +xrem284 remainder 9090950.80 436.400932 -> 282.985508 +xsub284 subtract 9090950.80 436.400932 -> 9090514.40 Inexact Rounded +xadd285 add -89833825.7E+329205393 -779430.194 -> -8.98338257E+329205400 Inexact Rounded +xcom285 compare -89833825.7E+329205393 -779430.194 -> -1 +xdiv285 divide -89833825.7E+329205393 -779430.194 -> 1.15255768E+329205395 Inexact Rounded +xdvi285 divideint -89833825.7E+329205393 -779430.194 -> NaN Division_impossible +xmul285 multiply -89833825.7E+329205393 -779430.194 -> 7.00191962E+329205406 Inexact Rounded +xpow285 power -89833825.7E+329205393 -779430 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem285 remainder -89833825.7E+329205393 -779430.194 -> NaN Division_impossible +xsub285 subtract -89833825.7E+329205393 -779430.194 -> -8.98338257E+329205400 Inexact Rounded +xadd286 add -714562.019E+750205688 704079764 -> -7.14562019E+750205693 Inexact Rounded +xcom286 compare -714562.019E+750205688 704079764 -> -1 +xdiv286 divide -714562.019E+750205688 704079764 -> -1.01488788E+750205685 Inexact Rounded +xdvi286 divideint -714562.019E+750205688 704079764 -> NaN Division_impossible +xmul286 multiply -714562.019E+750205688 704079764 -> -5.03108658E+750205702 Inexact Rounded +xpow286 power -714562.019E+750205688 704079764 -> Infinity Overflow Inexact Rounded +xrem286 remainder -714562.019E+750205688 704079764 -> NaN Division_impossible +xsub286 subtract -714562.019E+750205688 704079764 -> -7.14562019E+750205693 Inexact Rounded +xadd287 add -584537670. 31139.7737E-146687560 -> -584537670 Inexact Rounded +xcom287 compare -584537670. 31139.7737E-146687560 -> -1 +xdiv287 divide -584537670. 31139.7737E-146687560 -> -1.87714168E+146687564 Inexact Rounded +xdvi287 divideint -584537670. 31139.7737E-146687560 -> NaN Division_impossible +xmul287 multiply -584537670. 31139.7737E-146687560 -> -1.82023708E-146687547 Inexact Rounded +xpow287 power -584537670. 3 -> -1.99727337E+26 Inexact Rounded +xrem287 remainder -584537670. 31139.7737E-146687560 -> NaN Division_impossible +xsub287 subtract -584537670. 31139.7737E-146687560 -> -584537670 Inexact Rounded +xadd288 add -4.18074650E-858746879 571035.277E-279409165 -> 5.71035277E-279409160 Inexact Rounded +xcom288 compare -4.18074650E-858746879 571035.277E-279409165 -> -1 +xdiv288 divide -4.18074650E-858746879 571035.277E-279409165 -> -7.32134540E-579337720 Inexact Rounded +xdvi288 divideint -4.18074650E-858746879 571035.277E-279409165 -> -0 +xmul288 multiply -4.18074650E-858746879 571035.277E-279409165 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow288 power -4.18074650E-858746879 6 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem288 remainder -4.18074650E-858746879 571035.277E-279409165 -> -4.18074650E-858746879 +xsub288 subtract -4.18074650E-858746879 571035.277E-279409165 -> -5.71035277E-279409160 Inexact Rounded +xadd289 add 5.15309635 -695649.219E+451948183 -> -6.95649219E+451948188 Inexact Rounded +xcom289 compare 5.15309635 -695649.219E+451948183 -> 1 +xdiv289 divide 5.15309635 -695649.219E+451948183 -> -7.40760747E-451948189 Inexact Rounded +xdvi289 divideint 5.15309635 -695649.219E+451948183 -> -0 +xmul289 multiply 5.15309635 -695649.219E+451948183 -> -3.58474745E+451948189 Inexact Rounded +xpow289 power 5.15309635 -7 -> 0.0000103638749 Inexact Rounded +xrem289 remainder 5.15309635 -695649.219E+451948183 -> 5.15309635 +xsub289 subtract 5.15309635 -695649.219E+451948183 -> 6.95649219E+451948188 Inexact Rounded +xadd290 add -940030153.E+83797657 -4.11510193 -> -9.40030153E+83797665 Inexact Rounded +xcom290 compare -940030153.E+83797657 -4.11510193 -> -1 +xdiv290 divide -940030153.E+83797657 -4.11510193 -> 2.28434233E+83797665 Inexact Rounded +xdvi290 divideint -940030153.E+83797657 -4.11510193 -> NaN Division_impossible +xmul290 multiply -940030153.E+83797657 -4.11510193 -> 3.86831990E+83797666 Inexact Rounded +xpow290 power -940030153.E+83797657 -4 -> 1.28065710E-335190664 Inexact Rounded +xrem290 remainder -940030153.E+83797657 -4.11510193 -> NaN Division_impossible +xsub290 subtract -940030153.E+83797657 -4.11510193 -> -9.40030153E+83797665 Inexact Rounded +xadd291 add 89088.9683E+587739290 1.31932110 -> 8.90889683E+587739294 Inexact Rounded +xcom291 compare 89088.9683E+587739290 1.31932110 -> 1 +xdiv291 divide 89088.9683E+587739290 1.31932110 -> 6.75263727E+587739294 Inexact Rounded +xdvi291 divideint 89088.9683E+587739290 1.31932110 -> NaN Division_impossible +xmul291 multiply 89088.9683E+587739290 1.31932110 -> 1.17536956E+587739295 Inexact Rounded +xpow291 power 89088.9683E+587739290 1 -> 8.90889683E+587739294 +xrem291 remainder 89088.9683E+587739290 1.31932110 -> NaN Division_impossible +xsub291 subtract 89088.9683E+587739290 1.31932110 -> 8.90889683E+587739294 Inexact Rounded +xadd292 add 3336750 6.47961126 -> 3336756.48 Inexact Rounded +xcom292 compare 3336750 6.47961126 -> 1 +xdiv292 divide 3336750 6.47961126 -> 514961.448 Inexact Rounded +xdvi292 divideint 3336750 6.47961126 -> 514961 +xmul292 multiply 3336750 6.47961126 -> 21620842.9 Inexact Rounded +xpow292 power 3336750 6 -> 1.38019997E+39 Inexact Rounded +xrem292 remainder 3336750 6.47961126 -> 2.90593914 +xsub292 subtract 3336750 6.47961126 -> 3336743.52 Inexact Rounded +xadd293 add 904654622. 692065270.E+329081915 -> 6.92065270E+329081923 Inexact Rounded +xcom293 compare 904654622. 692065270.E+329081915 -> -1 +xdiv293 divide 904654622. 692065270.E+329081915 -> 1.30718107E-329081915 Inexact Rounded +xdvi293 divideint 904654622. 692065270.E+329081915 -> 0 +xmul293 multiply 904654622. 692065270.E+329081915 -> 6.26080045E+329081932 Inexact Rounded +xpow293 power 904654622. 7 -> 4.95883485E+62 Inexact Rounded +xrem293 remainder 904654622. 692065270.E+329081915 -> 904654622 +xsub293 subtract 904654622. 692065270.E+329081915 -> -6.92065270E+329081923 Inexact Rounded +xadd294 add 304804380 -4681.23698 -> 304799699 Inexact Rounded +xcom294 compare 304804380 -4681.23698 -> 1 +xdiv294 divide 304804380 -4681.23698 -> -65111.9312 Inexact Rounded +xdvi294 divideint 304804380 -4681.23698 -> -65111 +xmul294 multiply 304804380 -4681.23698 -> -1.42686154E+12 Inexact Rounded +xpow294 power 304804380 -4681 -> 1.98037102E-39714 Inexact Rounded +xrem294 remainder 304804380 -4681.23698 -> 4358.99522 +xsub294 subtract 304804380 -4681.23698 -> 304809061 Inexact Rounded +xadd295 add 674.55569 -82981.2684E+852890752 -> -8.29812684E+852890756 Inexact Rounded +xcom295 compare 674.55569 -82981.2684E+852890752 -> 1 +xdiv295 divide 674.55569 -82981.2684E+852890752 -> -8.12901156E-852890755 Inexact Rounded +xdvi295 divideint 674.55569 -82981.2684E+852890752 -> -0 +xmul295 multiply 674.55569 -82981.2684E+852890752 -> -5.59754868E+852890759 Inexact Rounded +xpow295 power 674.55569 -8 -> 2.33269265E-23 Inexact Rounded +xrem295 remainder 674.55569 -82981.2684E+852890752 -> 674.55569 +xsub295 subtract 674.55569 -82981.2684E+852890752 -> 8.29812684E+852890756 Inexact Rounded +xadd296 add -5111.51025E-108006096 5448870.4E+279212255 -> 5.44887040E+279212261 Inexact Rounded +xcom296 compare -5111.51025E-108006096 5448870.4E+279212255 -> -1 +xdiv296 divide -5111.51025E-108006096 5448870.4E+279212255 -> -9.38086222E-387218355 Inexact Rounded +xdvi296 divideint -5111.51025E-108006096 5448870.4E+279212255 -> -0 +xmul296 multiply -5111.51025E-108006096 5448870.4E+279212255 -> -2.78519569E+171206169 Inexact Rounded +xpow296 power -5111.51025E-108006096 5 -> -3.48936323E-540030462 Inexact Rounded +xrem296 remainder -5111.51025E-108006096 5448870.4E+279212255 -> -5.11151025E-108006093 +xsub296 subtract -5111.51025E-108006096 5448870.4E+279212255 -> -5.44887040E+279212261 Inexact Rounded +xadd297 add -2623.45068 -466463938. -> -466466561 Inexact Rounded +xcom297 compare -2623.45068 -466463938. -> 1 +xdiv297 divide -2623.45068 -466463938. -> 0.00000562412325 Inexact Rounded +xdvi297 divideint -2623.45068 -466463938. -> 0 +xmul297 multiply -2623.45068 -466463938. -> 1.22374514E+12 Inexact Rounded +xpow297 power -2623.45068 -466463938 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem297 remainder -2623.45068 -466463938. -> -2623.45068 +xsub297 subtract -2623.45068 -466463938. -> 466461315 Inexact Rounded +xadd298 add 299350.435 3373.33551 -> 302723.771 Inexact Rounded +xcom298 compare 299350.435 3373.33551 -> 1 +xdiv298 divide 299350.435 3373.33551 -> 88.7401903 Inexact Rounded +xdvi298 divideint 299350.435 3373.33551 -> 88 +xmul298 multiply 299350.435 3373.33551 -> 1.00980945E+9 Inexact Rounded +xpow298 power 299350.435 3373 -> 1.42817370E+18471 Inexact Rounded +xrem298 remainder 299350.435 3373.33551 -> 2496.91012 +xsub298 subtract 299350.435 3373.33551 -> 295977.099 Inexact Rounded +xadd299 add -6589947.80 -2448.75933E-591549734 -> -6589947.80 Inexact Rounded +xcom299 compare -6589947.80 -2448.75933E-591549734 -> -1 +xdiv299 divide -6589947.80 -2448.75933E-591549734 -> 2.69113739E+591549737 Inexact Rounded +xdvi299 divideint -6589947.80 -2448.75933E-591549734 -> NaN Division_impossible +xmul299 multiply -6589947.80 -2448.75933E-591549734 -> 1.61371962E-591549724 Inexact Rounded +xpow299 power -6589947.80 -2 -> 2.30269305E-14 Inexact Rounded +xrem299 remainder -6589947.80 -2448.75933E-591549734 -> NaN Division_impossible +xsub299 subtract -6589947.80 -2448.75933E-591549734 -> -6589947.80 Inexact Rounded +xadd300 add 3774.5358E-491090520 173.060090 -> 173.060090 Inexact Rounded +xcom300 compare 3774.5358E-491090520 173.060090 -> -1 +xdiv300 divide 3774.5358E-491090520 173.060090 -> 2.18105503E-491090519 Inexact Rounded +xdvi300 divideint 3774.5358E-491090520 173.060090 -> 0 +xmul300 multiply 3774.5358E-491090520 173.060090 -> 6.53221505E-491090515 Inexact Rounded +xpow300 power 3774.5358E-491090520 173 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem300 remainder 3774.5358E-491090520 173.060090 -> 3.7745358E-491090517 +xsub300 subtract 3774.5358E-491090520 173.060090 -> -173.060090 Inexact Rounded +xadd301 add -13.6783690 -453.610117 -> -467.288486 Rounded +xcom301 compare -13.6783690 -453.610117 -> 1 +xdiv301 divide -13.6783690 -453.610117 -> 0.0301544619 Inexact Rounded +xdvi301 divideint -13.6783690 -453.610117 -> 0 +xmul301 multiply -13.6783690 -453.610117 -> 6204.64656 Inexact Rounded +xpow301 power -13.6783690 -454 -> 1.73948535E-516 Inexact Rounded +xrem301 remainder -13.6783690 -453.610117 -> -13.6783690 +xsub301 subtract -13.6783690 -453.610117 -> 439.931748 Rounded +xadd302 add -990100927.E-615244634 223801.421E+247632618 -> 2.23801421E+247632623 Inexact Rounded +xcom302 compare -990100927.E-615244634 223801.421E+247632618 -> -1 +xdiv302 divide -990100927.E-615244634 223801.421E+247632618 -> -4.42401537E-862877249 Inexact Rounded +xdvi302 divideint -990100927.E-615244634 223801.421E+247632618 -> -0 +xmul302 multiply -990100927.E-615244634 223801.421E+247632618 -> -2.21585994E-367612002 Inexact Rounded +xpow302 power -990100927.E-615244634 2 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem302 remainder -990100927.E-615244634 223801.421E+247632618 -> -9.90100927E-615244626 +xsub302 subtract -990100927.E-615244634 223801.421E+247632618 -> -2.23801421E+247632623 Inexact Rounded +xadd303 add 1275.10292 -667965353 -> -667964078 Inexact Rounded +xcom303 compare 1275.10292 -667965353 -> 1 +xdiv303 divide 1275.10292 -667965353 -> -0.00000190893572 Inexact Rounded +xdvi303 divideint 1275.10292 -667965353 -> -0 +xmul303 multiply 1275.10292 -667965353 -> -8.51724572E+11 Inexact Rounded +xpow303 power 1275.10292 -667965353 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem303 remainder 1275.10292 -667965353 -> 1275.10292 +xsub303 subtract 1275.10292 -667965353 -> 667966628 Inexact Rounded +xadd304 add -8.76375480E-596792197 992.077361 -> 992.077361 Inexact Rounded +xcom304 compare -8.76375480E-596792197 992.077361 -> -1 +xdiv304 divide -8.76375480E-596792197 992.077361 -> -8.83374134E-596792200 Inexact Rounded +xdvi304 divideint -8.76375480E-596792197 992.077361 -> -0 +xmul304 multiply -8.76375480E-596792197 992.077361 -> -8.69432273E-596792194 Inexact Rounded +xpow304 power -8.76375480E-596792197 992 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem304 remainder -8.76375480E-596792197 992.077361 -> -8.76375480E-596792197 +xsub304 subtract -8.76375480E-596792197 992.077361 -> -992.077361 Inexact Rounded +xadd305 add 953.976935E+385444720 96503.3378 -> 9.53976935E+385444722 Inexact Rounded +xcom305 compare 953.976935E+385444720 96503.3378 -> 1 +xdiv305 divide 953.976935E+385444720 96503.3378 -> 9.88542942E+385444717 Inexact Rounded +xdvi305 divideint 953.976935E+385444720 96503.3378 -> NaN Division_impossible +xmul305 multiply 953.976935E+385444720 96503.3378 -> 9.20619584E+385444727 Inexact Rounded +xpow305 power 953.976935E+385444720 96503 -> Infinity Overflow Inexact Rounded +xrem305 remainder 953.976935E+385444720 96503.3378 -> NaN Division_impossible +xsub305 subtract 953.976935E+385444720 96503.3378 -> 9.53976935E+385444722 Inexact Rounded +xadd306 add 213577152 -986710073E+31900046 -> -9.86710073E+31900054 Inexact Rounded +xcom306 compare 213577152 -986710073E+31900046 -> 1 +xdiv306 divide 213577152 -986710073E+31900046 -> -2.16453807E-31900047 Inexact Rounded +xdvi306 divideint 213577152 -986710073E+31900046 -> -0 +xmul306 multiply 213577152 -986710073E+31900046 -> -2.10738727E+31900063 Inexact Rounded +xpow306 power 213577152 -10 -> 5.06351487E-84 Inexact Rounded +xrem306 remainder 213577152 -986710073E+31900046 -> 213577152 +xsub306 subtract 213577152 -986710073E+31900046 -> 9.86710073E+31900054 Inexact Rounded +xadd307 add 91393.9398E-323439228 -135.701000 -> -135.701000 Inexact Rounded +xcom307 compare 91393.9398E-323439228 -135.701000 -> 1 +xdiv307 divide 91393.9398E-323439228 -135.701000 -> -6.73494962E-323439226 Inexact Rounded +xdvi307 divideint 91393.9398E-323439228 -135.701000 -> -0 +xmul307 multiply 91393.9398E-323439228 -135.701000 -> -1.24022490E-323439221 Inexact Rounded +xpow307 power 91393.9398E-323439228 -136 -> Infinity Overflow Inexact Rounded +xrem307 remainder 91393.9398E-323439228 -135.701000 -> 9.13939398E-323439224 +xsub307 subtract 91393.9398E-323439228 -135.701000 -> 135.701000 Inexact Rounded +xadd308 add -396.503557 45757264.E-254363788 -> -396.503557 Inexact Rounded +xcom308 compare -396.503557 45757264.E-254363788 -> -1 +xdiv308 divide -396.503557 45757264.E-254363788 -> -8.66536856E+254363782 Inexact Rounded +xdvi308 divideint -396.503557 45757264.E-254363788 -> NaN Division_impossible +xmul308 multiply -396.503557 45757264.E-254363788 -> -1.81429179E-254363778 Inexact Rounded +xpow308 power -396.503557 5 -> -9.80021128E+12 Inexact Rounded +xrem308 remainder -396.503557 45757264.E-254363788 -> NaN Division_impossible +xsub308 subtract -396.503557 45757264.E-254363788 -> -396.503557 Inexact Rounded +xadd309 add 59807846.1 1.53345254 -> 59807847.6 Inexact Rounded +xcom309 compare 59807846.1 1.53345254 -> 1 +xdiv309 divide 59807846.1 1.53345254 -> 39002084.9 Inexact Rounded +xdvi309 divideint 59807846.1 1.53345254 -> 39002084 +xmul309 multiply 59807846.1 1.53345254 -> 91712493.5 Inexact Rounded +xpow309 power 59807846.1 2 -> 3.57697846E+15 Inexact Rounded +xrem309 remainder 59807846.1 1.53345254 -> 1.32490664 +xsub309 subtract 59807846.1 1.53345254 -> 59807844.6 Inexact Rounded +xadd310 add -8046158.45 8.3635397 -> -8046150.09 Inexact Rounded +xcom310 compare -8046158.45 8.3635397 -> -1 +xdiv310 divide -8046158.45 8.3635397 -> -962051.803 Inexact Rounded +xdvi310 divideint -8046158.45 8.3635397 -> -962051 +xmul310 multiply -8046158.45 8.3635397 -> -67294365.6 Inexact Rounded +xpow310 power -8046158.45 8 -> 1.75674467E+55 Inexact Rounded +xrem310 remainder -8046158.45 8.3635397 -> -6.7180753 +xsub310 subtract -8046158.45 8.3635397 -> -8046166.81 Inexact Rounded +xadd311 add 55.1123381E+50627250 -94.0355047E-162540316 -> 5.51123381E+50627251 Inexact Rounded +xcom311 compare 55.1123381E+50627250 -94.0355047E-162540316 -> 1 +xdiv311 divide 55.1123381E+50627250 -94.0355047E-162540316 -> -5.86080101E+213167565 Inexact Rounded +xdvi311 divideint 55.1123381E+50627250 -94.0355047E-162540316 -> NaN Division_impossible +xmul311 multiply 55.1123381E+50627250 -94.0355047E-162540316 -> -5.18251653E-111913063 Inexact Rounded +xpow311 power 55.1123381E+50627250 -9 -> 2.13186881E-455645266 Inexact Rounded +xrem311 remainder 55.1123381E+50627250 -94.0355047E-162540316 -> NaN Division_impossible +xsub311 subtract 55.1123381E+50627250 -94.0355047E-162540316 -> 5.51123381E+50627251 Inexact Rounded +xadd312 add -948.038054 3580.84510 -> 2632.80705 Inexact Rounded +xcom312 compare -948.038054 3580.84510 -> -1 +xdiv312 divide -948.038054 3580.84510 -> -0.264752601 Inexact Rounded +xdvi312 divideint -948.038054 3580.84510 -> -0 +xmul312 multiply -948.038054 3580.84510 -> -3394777.42 Inexact Rounded +xpow312 power -948.038054 3581 -> -1.03058288E+10660 Inexact Rounded +xrem312 remainder -948.038054 3580.84510 -> -948.038054 +xsub312 subtract -948.038054 3580.84510 -> -4528.88315 Inexact Rounded +xadd313 add -6026.42752 -14.2286406E-334921364 -> -6026.42752 Inexact Rounded +xcom313 compare -6026.42752 -14.2286406E-334921364 -> -1 +xdiv313 divide -6026.42752 -14.2286406E-334921364 -> 4.23542044E+334921366 Inexact Rounded +xdvi313 divideint -6026.42752 -14.2286406E-334921364 -> NaN Division_impossible +xmul313 multiply -6026.42752 -14.2286406E-334921364 -> 8.57478713E-334921360 Inexact Rounded +xpow313 power -6026.42752 -1 -> -0.000165935788 Inexact Rounded +xrem313 remainder -6026.42752 -14.2286406E-334921364 -> NaN Division_impossible +xsub313 subtract -6026.42752 -14.2286406E-334921364 -> -6026.42752 Inexact Rounded +xadd314 add 79551.5014 -538.186229 -> 79013.3152 Inexact Rounded +xcom314 compare 79551.5014 -538.186229 -> 1 +xdiv314 divide 79551.5014 -538.186229 -> -147.814078 Inexact Rounded +xdvi314 divideint 79551.5014 -538.186229 -> -147 +xmul314 multiply 79551.5014 -538.186229 -> -42813522.5 Inexact Rounded +xpow314 power 79551.5014 -538 -> 2.82599389E-2637 Inexact Rounded +xrem314 remainder 79551.5014 -538.186229 -> 438.125737 +xsub314 subtract 79551.5014 -538.186229 -> 80089.6876 Inexact Rounded +xadd315 add 42706056.E+623578292 -690.327745 -> 4.27060560E+623578299 Inexact Rounded +xcom315 compare 42706056.E+623578292 -690.327745 -> 1 +xdiv315 divide 42706056.E+623578292 -690.327745 -> -6.18634501E+623578296 Inexact Rounded +xdvi315 divideint 42706056.E+623578292 -690.327745 -> NaN Division_impossible +xmul315 multiply 42706056.E+623578292 -690.327745 -> -2.94811753E+623578302 Inexact Rounded +xpow315 power 42706056.E+623578292 -690 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem315 remainder 42706056.E+623578292 -690.327745 -> NaN Division_impossible +xsub315 subtract 42706056.E+623578292 -690.327745 -> 4.27060560E+623578299 Inexact Rounded +xadd316 add 2454136.08E+502374077 856268.795E-356664934 -> 2.45413608E+502374083 Inexact Rounded +xcom316 compare 2454136.08E+502374077 856268.795E-356664934 -> 1 +xdiv316 divide 2454136.08E+502374077 856268.795E-356664934 -> 2.86608142E+859039011 Inexact Rounded +xdvi316 divideint 2454136.08E+502374077 856268.795E-356664934 -> NaN Division_impossible +xmul316 multiply 2454136.08E+502374077 856268.795E-356664934 -> 2.10140014E+145709155 Inexact Rounded +xpow316 power 2454136.08E+502374077 9 -> Infinity Overflow Inexact Rounded +xrem316 remainder 2454136.08E+502374077 856268.795E-356664934 -> NaN Division_impossible +xsub316 subtract 2454136.08E+502374077 856268.795E-356664934 -> 2.45413608E+502374083 Inexact Rounded +xadd317 add -3264204.54 -42704.501 -> -3306909.04 Inexact Rounded +xcom317 compare -3264204.54 -42704.501 -> -1 +xdiv317 divide -3264204.54 -42704.501 -> 76.4370140 Inexact Rounded +xdvi317 divideint -3264204.54 -42704.501 -> 76 +xmul317 multiply -3264204.54 -42704.501 -> 1.39396226E+11 Inexact Rounded +xpow317 power -3264204.54 -42705 -> -1.37293410E-278171 Inexact Rounded +xrem317 remainder -3264204.54 -42704.501 -> -18662.464 +xsub317 subtract -3264204.54 -42704.501 -> -3221500.04 Inexact Rounded +xadd318 add 1.21265492 44102.6073 -> 44103.8200 Inexact Rounded +xcom318 compare 1.21265492 44102.6073 -> -1 +xdiv318 divide 1.21265492 44102.6073 -> 0.0000274962183 Inexact Rounded +xdvi318 divideint 1.21265492 44102.6073 -> 0 +xmul318 multiply 1.21265492 44102.6073 -> 53481.2437 Inexact Rounded +xpow318 power 1.21265492 44103 -> 1.15662573E+3693 Inexact Rounded +xrem318 remainder 1.21265492 44102.6073 -> 1.21265492 +xsub318 subtract 1.21265492 44102.6073 -> -44101.3946 Inexact Rounded +xadd319 add -19.054711E+975514652 -22144.0822 -> -1.90547110E+975514653 Inexact Rounded +xcom319 compare -19.054711E+975514652 -22144.0822 -> -1 +xdiv319 divide -19.054711E+975514652 -22144.0822 -> 8.60487729E+975514648 Inexact Rounded +xdvi319 divideint -19.054711E+975514652 -22144.0822 -> NaN Division_impossible +xmul319 multiply -19.054711E+975514652 -22144.0822 -> 4.21949087E+975514657 Inexact Rounded +xpow319 power -19.054711E+975514652 -22144 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem319 remainder -19.054711E+975514652 -22144.0822 -> NaN Division_impossible +xsub319 subtract -19.054711E+975514652 -22144.0822 -> -1.90547110E+975514653 Inexact Rounded +xadd320 add 745.78452 -1922.00670E+375923302 -> -1.92200670E+375923305 Inexact Rounded +xcom320 compare 745.78452 -1922.00670E+375923302 -> 1 +xdiv320 divide 745.78452 -1922.00670E+375923302 -> -3.88023892E-375923303 Inexact Rounded +xdvi320 divideint 745.78452 -1922.00670E+375923302 -> -0 +xmul320 multiply 745.78452 -1922.00670E+375923302 -> -1.43340284E+375923308 Inexact Rounded +xpow320 power 745.78452 -2 -> 0.00000179793204 Inexact Rounded +xrem320 remainder 745.78452 -1922.00670E+375923302 -> 745.78452 +xsub320 subtract 745.78452 -1922.00670E+375923302 -> 1.92200670E+375923305 Inexact Rounded +xadd321 add -963717836 -823989308 -> -1.78770714E+9 Inexact Rounded +xcom321 compare -963717836 -823989308 -> -1 +xdiv321 divide -963717836 -823989308 -> 1.16957566 Inexact Rounded +xdvi321 divideint -963717836 -823989308 -> 1 +xmul321 multiply -963717836 -823989308 -> 7.94093193E+17 Inexact Rounded +xpow321 power -963717836 -823989308 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem321 remainder -963717836 -823989308 -> -139728528 +xsub321 subtract -963717836 -823989308 -> -139728528 +xadd322 add 82.4185291E-321919303 -215747737.E-995147400 -> 8.24185291E-321919302 Inexact Rounded +xcom322 compare 82.4185291E-321919303 -215747737.E-995147400 -> 1 +xdiv322 divide 82.4185291E-321919303 -215747737.E-995147400 -> -3.82013412E+673228090 Inexact Rounded +xdvi322 divideint 82.4185291E-321919303 -215747737.E-995147400 -> NaN Division_impossible +xmul322 multiply 82.4185291E-321919303 -215747737.E-995147400 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow322 power 82.4185291E-321919303 -2 -> 1.47214396E+643838602 Inexact Rounded +xrem322 remainder 82.4185291E-321919303 -215747737.E-995147400 -> NaN Division_impossible +xsub322 subtract 82.4185291E-321919303 -215747737.E-995147400 -> 8.24185291E-321919302 Inexact Rounded +xadd323 add -808328.607E-790810342 53075.7082 -> 53075.7082 Inexact Rounded +xcom323 compare -808328.607E-790810342 53075.7082 -> -1 +xdiv323 divide -808328.607E-790810342 53075.7082 -> -1.52297281E-790810341 Inexact Rounded +xdvi323 divideint -808328.607E-790810342 53075.7082 -> -0 +xmul323 multiply -808328.607E-790810342 53075.7082 -> -4.29026133E-790810332 Inexact Rounded +xpow323 power -808328.607E-790810342 53076 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem323 remainder -808328.607E-790810342 53075.7082 -> -8.08328607E-790810337 +xsub323 subtract -808328.607E-790810342 53075.7082 -> -53075.7082 Inexact Rounded +xadd324 add 700592.720 -698485.085 -> 2107.635 +xcom324 compare 700592.720 -698485.085 -> 1 +xdiv324 divide 700592.720 -698485.085 -> -1.00301744 Inexact Rounded +xdvi324 divideint 700592.720 -698485.085 -> -1 +xmul324 multiply 700592.720 -698485.085 -> -4.89353566E+11 Inexact Rounded +xpow324 power 700592.720 -698485 -> 8.83690000E-4082971 Inexact Rounded +xrem324 remainder 700592.720 -698485.085 -> 2107.635 +xsub324 subtract 700592.720 -698485.085 -> 1399077.81 Inexact Rounded +xadd325 add -80273928.0 661346.239 -> -79612581.8 Inexact Rounded +xcom325 compare -80273928.0 661346.239 -> -1 +xdiv325 divide -80273928.0 661346.239 -> -121.379579 Inexact Rounded +xdvi325 divideint -80273928.0 661346.239 -> -121 +xmul325 multiply -80273928.0 661346.239 -> -5.30888604E+13 Inexact Rounded +xpow325 power -80273928.0 661346 -> 5.45664856E+5227658 Inexact Rounded +xrem325 remainder -80273928.0 661346.239 -> -251033.081 +xsub325 subtract -80273928.0 661346.239 -> -80935274.2 Inexact Rounded +xadd326 add -24018251.0E+819786764 59141.9600E-167165065 -> -2.40182510E+819786771 Inexact Rounded +xcom326 compare -24018251.0E+819786764 59141.9600E-167165065 -> -1 +xdiv326 divide -24018251.0E+819786764 59141.9600E-167165065 -> -4.06111854E+986951831 Inexact Rounded +xdvi326 divideint -24018251.0E+819786764 59141.9600E-167165065 -> NaN Division_impossible +xmul326 multiply -24018251.0E+819786764 59141.9600E-167165065 -> -1.42048644E+652621711 Inexact Rounded +xpow326 power -24018251.0E+819786764 6 -> Infinity Overflow Inexact Rounded +xrem326 remainder -24018251.0E+819786764 59141.9600E-167165065 -> NaN Division_impossible +xsub326 subtract -24018251.0E+819786764 59141.9600E-167165065 -> -2.40182510E+819786771 Inexact Rounded +xadd327 add 2512953.3 -3769170.35E-993621645 -> 2512953.30 Inexact Rounded +xcom327 compare 2512953.3 -3769170.35E-993621645 -> 1 +xdiv327 divide 2512953.3 -3769170.35E-993621645 -> -6.66712583E+993621644 Inexact Rounded +xdvi327 divideint 2512953.3 -3769170.35E-993621645 -> NaN Division_impossible +xmul327 multiply 2512953.3 -3769170.35E-993621645 -> -9.47174907E-993621633 Inexact Rounded +xpow327 power 2512953.3 -4 -> 2.50762349E-26 Inexact Rounded +xrem327 remainder 2512953.3 -3769170.35E-993621645 -> NaN Division_impossible +xsub327 subtract 2512953.3 -3769170.35E-993621645 -> 2512953.30 Inexact Rounded +xadd328 add -682.796370 71131.0224 -> 70448.2260 Inexact Rounded +xcom328 compare -682.796370 71131.0224 -> -1 +xdiv328 divide -682.796370 71131.0224 -> -0.00959913617 Inexact Rounded +xdvi328 divideint -682.796370 71131.0224 -> -0 +xmul328 multiply -682.796370 71131.0224 -> -48568003.9 Inexact Rounded +xpow328 power -682.796370 71131 -> -9.28114741E+201605 Inexact Rounded +xrem328 remainder -682.796370 71131.0224 -> -682.796370 +xsub328 subtract -682.796370 71131.0224 -> -71813.8188 Inexact Rounded +xadd329 add 89.9997490 -4993.69831 -> -4903.69856 Inexact Rounded +xcom329 compare 89.9997490 -4993.69831 -> 1 +xdiv329 divide 89.9997490 -4993.69831 -> -0.0180226644 Inexact Rounded +xdvi329 divideint 89.9997490 -4993.69831 -> -0 +xmul329 multiply 89.9997490 -4993.69831 -> -449431.594 Inexact Rounded +xpow329 power 89.9997490 -4994 -> 3.30336526E-9760 Inexact Rounded +xrem329 remainder 89.9997490 -4993.69831 -> 89.9997490 +xsub329 subtract 89.9997490 -4993.69831 -> 5083.69806 Inexact Rounded +xadd330 add 76563354.6E-112338836 278271.585E-511481095 -> 7.65633546E-112338829 Inexact Rounded +xcom330 compare 76563354.6E-112338836 278271.585E-511481095 -> 1 +xdiv330 divide 76563354.6E-112338836 278271.585E-511481095 -> 2.75138960E+399142261 Inexact Rounded +xdvi330 divideint 76563354.6E-112338836 278271.585E-511481095 -> NaN Division_impossible +xmul330 multiply 76563354.6E-112338836 278271.585E-511481095 -> 2.13054060E-623819918 Inexact Rounded +xpow330 power 76563354.6E-112338836 3 -> 4.48810347E-337016485 Inexact Rounded +xrem330 remainder 76563354.6E-112338836 278271.585E-511481095 -> NaN Division_impossible +xsub330 subtract 76563354.6E-112338836 278271.585E-511481095 -> 7.65633546E-112338829 Inexact Rounded +xadd331 add -932499.010 873.377701E-502190452 -> -932499.010 Inexact Rounded +xcom331 compare -932499.010 873.377701E-502190452 -> -1 +xdiv331 divide -932499.010 873.377701E-502190452 -> -1.06769272E+502190455 Inexact Rounded +xdvi331 divideint -932499.010 873.377701E-502190452 -> NaN Division_impossible +xmul331 multiply -932499.010 873.377701E-502190452 -> -8.14423842E-502190444 Inexact Rounded +xpow331 power -932499.010 9 -> -5.33132815E+53 Inexact Rounded +xrem331 remainder -932499.010 873.377701E-502190452 -> NaN Division_impossible +xsub331 subtract -932499.010 873.377701E-502190452 -> -932499.010 Inexact Rounded +xadd332 add -7735918.21E+799514797 -7748.78023 -> -7.73591821E+799514803 Inexact Rounded +xcom332 compare -7735918.21E+799514797 -7748.78023 -> -1 +xdiv332 divide -7735918.21E+799514797 -7748.78023 -> 9.98340123E+799514799 Inexact Rounded +xdvi332 divideint -7735918.21E+799514797 -7748.78023 -> NaN Division_impossible +xmul332 multiply -7735918.21E+799514797 -7748.78023 -> 5.99439301E+799514807 Inexact Rounded +xpow332 power -7735918.21E+799514797 -7749 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem332 remainder -7735918.21E+799514797 -7748.78023 -> NaN Division_impossible +xsub332 subtract -7735918.21E+799514797 -7748.78023 -> -7.73591821E+799514803 Inexact Rounded +xadd333 add -3708780.75E+445232787 980.006567E-780728623 -> -3.70878075E+445232793 Inexact Rounded +xcom333 compare -3708780.75E+445232787 980.006567E-780728623 -> -1 +xdiv333 divide -3708780.75E+445232787 980.006567E-780728623 -> -Infinity Inexact Overflow Rounded +xdvi333 divideint -3708780.75E+445232787 980.006567E-780728623 -> NaN Division_impossible +xmul333 multiply -3708780.75E+445232787 980.006567E-780728623 -> -3.63462949E-335495827 Inexact Rounded +xpow333 power -3708780.75E+445232787 10 -> Infinity Overflow Inexact Rounded +xrem333 remainder -3708780.75E+445232787 980.006567E-780728623 -> NaN Division_impossible +xsub333 subtract -3708780.75E+445232787 980.006567E-780728623 -> -3.70878075E+445232793 Inexact Rounded +xadd334 add -5205124.44E-140588661 -495394029.E-620856313 -> -5.20512444E-140588655 Inexact Rounded +xcom334 compare -5205124.44E-140588661 -495394029.E-620856313 -> -1 +xdiv334 divide -5205124.44E-140588661 -495394029.E-620856313 -> 1.05070391E+480267650 Inexact Rounded +xdvi334 divideint -5205124.44E-140588661 -495394029.E-620856313 -> NaN Division_impossible +xmul334 multiply -5205124.44E-140588661 -495394029.E-620856313 -> 2.57858757E-761444959 Inexact Rounded +xpow334 power -5205124.44E-140588661 -5 -> -2.61724523E+702943271 Inexact Rounded +xrem334 remainder -5205124.44E-140588661 -495394029.E-620856313 -> NaN Division_impossible +xsub334 subtract -5205124.44E-140588661 -495394029.E-620856313 -> -5.20512444E-140588655 Inexact Rounded +xadd335 add -8868.72074 5592399.93 -> 5583531.21 Inexact Rounded +xcom335 compare -8868.72074 5592399.93 -> -1 +xdiv335 divide -8868.72074 5592399.93 -> -0.00158585238 Inexact Rounded +xdvi335 divideint -8868.72074 5592399.93 -> -0 +xmul335 multiply -8868.72074 5592399.93 -> -4.95974332E+10 Inexact Rounded +xpow335 power -8868.72074 5592400 -> 5.55074142E+22078017 Inexact Rounded +xrem335 remainder -8868.72074 5592399.93 -> -8868.72074 +xsub335 subtract -8868.72074 5592399.93 -> -5601268.65 Inexact Rounded +xadd336 add -74.7852037E-175205809 4.14316542 -> 4.14316542 Inexact Rounded +xcom336 compare -74.7852037E-175205809 4.14316542 -> -1 +xdiv336 divide -74.7852037E-175205809 4.14316542 -> -1.80502577E-175205808 Inexact Rounded +xdvi336 divideint -74.7852037E-175205809 4.14316542 -> -0 +xmul336 multiply -74.7852037E-175205809 4.14316542 -> -3.09847470E-175205807 Inexact Rounded +xpow336 power -74.7852037E-175205809 4 -> 3.12797104E-700823229 Inexact Rounded +xrem336 remainder -74.7852037E-175205809 4.14316542 -> -7.47852037E-175205808 +xsub336 subtract -74.7852037E-175205809 4.14316542 -> -4.14316542 Inexact Rounded +xadd337 add 84196.1091E+242628748 8.07523036E-288231467 -> 8.41961091E+242628752 Inexact Rounded +xcom337 compare 84196.1091E+242628748 8.07523036E-288231467 -> 1 +xdiv337 divide 84196.1091E+242628748 8.07523036E-288231467 -> 1.04264653E+530860219 Inexact Rounded +xdvi337 divideint 84196.1091E+242628748 8.07523036E-288231467 -> NaN Division_impossible +xmul337 multiply 84196.1091E+242628748 8.07523036E-288231467 -> 6.79902976E-45602714 Inexact Rounded +xpow337 power 84196.1091E+242628748 8 -> Infinity Overflow Inexact Rounded +xrem337 remainder 84196.1091E+242628748 8.07523036E-288231467 -> NaN Division_impossible +xsub337 subtract 84196.1091E+242628748 8.07523036E-288231467 -> 8.41961091E+242628752 Inexact Rounded +xadd338 add 38660103.1 -6671.73085E+900998477 -> -6.67173085E+900998480 Inexact Rounded +xcom338 compare 38660103.1 -6671.73085E+900998477 -> 1 +xdiv338 divide 38660103.1 -6671.73085E+900998477 -> -5.79461372E-900998474 Inexact Rounded +xdvi338 divideint 38660103.1 -6671.73085E+900998477 -> -0 +xmul338 multiply 38660103.1 -6671.73085E+900998477 -> -2.57929803E+900998488 Inexact Rounded +xpow338 power 38660103.1 -7 -> 7.74745290E-54 Inexact Rounded +xrem338 remainder 38660103.1 -6671.73085E+900998477 -> 38660103.1 +xsub338 subtract 38660103.1 -6671.73085E+900998477 -> 6.67173085E+900998480 Inexact Rounded +xadd339 add -52.2659460 -296404199E+372050476 -> -2.96404199E+372050484 Inexact Rounded +xcom339 compare -52.2659460 -296404199E+372050476 -> 1 +xdiv339 divide -52.2659460 -296404199E+372050476 -> 1.76333352E-372050483 Inexact Rounded +xdvi339 divideint -52.2659460 -296404199E+372050476 -> 0 +xmul339 multiply -52.2659460 -296404199E+372050476 -> 1.54918459E+372050486 Inexact Rounded +xpow339 power -52.2659460 -3 -> -0.00000700395833 Inexact Rounded +xrem339 remainder -52.2659460 -296404199E+372050476 -> -52.2659460 +xsub339 subtract -52.2659460 -296404199E+372050476 -> 2.96404199E+372050484 Inexact Rounded +xadd340 add 6.06625013 -276.359186 -> -270.292936 Inexact Rounded +xcom340 compare 6.06625013 -276.359186 -> 1 +xdiv340 divide 6.06625013 -276.359186 -> -0.0219506007 Inexact Rounded +xdvi340 divideint 6.06625013 -276.359186 -> -0 +xmul340 multiply 6.06625013 -276.359186 -> -1676.46395 Inexact Rounded +xpow340 power 6.06625013 -276 -> 8.20339149E-217 Inexact Rounded +xrem340 remainder 6.06625013 -276.359186 -> 6.06625013 +xsub340 subtract 6.06625013 -276.359186 -> 282.425436 Inexact Rounded +xadd341 add -62971617.5E-241444744 46266799.3 -> 46266799.3 Inexact Rounded +xcom341 compare -62971617.5E-241444744 46266799.3 -> -1 +xdiv341 divide -62971617.5E-241444744 46266799.3 -> -1.36105411E-241444744 Inexact Rounded +xdvi341 divideint -62971617.5E-241444744 46266799.3 -> -0 +xmul341 multiply -62971617.5E-241444744 46266799.3 -> -2.91349519E-241444729 Inexact Rounded +xpow341 power -62971617.5E-241444744 46266799 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem341 remainder -62971617.5E-241444744 46266799.3 -> -6.29716175E-241444737 +xsub341 subtract -62971617.5E-241444744 46266799.3 -> -46266799.3 Inexact Rounded +xadd342 add -5.36917800 -311124593.E-976066491 -> -5.36917800 Inexact Rounded +xcom342 compare -5.36917800 -311124593.E-976066491 -> -1 +xdiv342 divide -5.36917800 -311124593.E-976066491 -> 1.72573243E+976066483 Inexact Rounded +xdvi342 divideint -5.36917800 -311124593.E-976066491 -> NaN Division_impossible +xmul342 multiply -5.36917800 -311124593.E-976066491 -> 1.67048332E-976066482 Inexact Rounded +xpow342 power -5.36917800 -3 -> -0.00646065565 Inexact Rounded +xrem342 remainder -5.36917800 -311124593.E-976066491 -> NaN Division_impossible +xsub342 subtract -5.36917800 -311124593.E-976066491 -> -5.36917800 Inexact Rounded +xadd343 add 2467915.01 -92.5558322 -> 2467822.45 Inexact Rounded +xcom343 compare 2467915.01 -92.5558322 -> 1 +xdiv343 divide 2467915.01 -92.5558322 -> -26664.0681 Inexact Rounded +xdvi343 divideint 2467915.01 -92.5558322 -> -26664 +xmul343 multiply 2467915.01 -92.5558322 -> -228419928 Inexact Rounded +xpow343 power 2467915.01 -93 -> 3.26055444E-595 Inexact Rounded +xrem343 remainder 2467915.01 -92.5558322 -> 6.3002192 +xsub343 subtract 2467915.01 -92.5558322 -> 2468007.57 Inexact Rounded +xadd344 add 187.232671 -840.469347 -> -653.236676 +xcom344 compare 187.232671 -840.469347 -> 1 +xdiv344 divide 187.232671 -840.469347 -> -0.222771564 Inexact Rounded +xdvi344 divideint 187.232671 -840.469347 -> -0 +xmul344 multiply 187.232671 -840.469347 -> -157363.321 Inexact Rounded +xpow344 power 187.232671 -840 -> 1.58280862E-1909 Inexact Rounded +xrem344 remainder 187.232671 -840.469347 -> 187.232671 +xsub344 subtract 187.232671 -840.469347 -> 1027.70202 Inexact Rounded +xadd345 add 81233.6823 -5192.21666E+309315093 -> -5.19221666E+309315096 Inexact Rounded +xcom345 compare 81233.6823 -5192.21666E+309315093 -> 1 +xdiv345 divide 81233.6823 -5192.21666E+309315093 -> -1.56452798E-309315092 Inexact Rounded +xdvi345 divideint 81233.6823 -5192.21666E+309315093 -> -0 +xmul345 multiply 81233.6823 -5192.21666E+309315093 -> -4.21782879E+309315101 Inexact Rounded +xpow345 power 81233.6823 -5 -> 2.82695763E-25 Inexact Rounded +xrem345 remainder 81233.6823 -5192.21666E+309315093 -> 81233.6823 +xsub345 subtract 81233.6823 -5192.21666E+309315093 -> 5.19221666E+309315096 Inexact Rounded +xadd346 add -854.586113 -79.8715762E-853065103 -> -854.586113 Inexact Rounded +xcom346 compare -854.586113 -79.8715762E-853065103 -> -1 +xdiv346 divide -854.586113 -79.8715762E-853065103 -> 1.06995023E+853065104 Inexact Rounded +xdvi346 divideint -854.586113 -79.8715762E-853065103 -> NaN Division_impossible +xmul346 multiply -854.586113 -79.8715762E-853065103 -> 6.82571398E-853065099 Inexact Rounded +xpow346 power -854.586113 -8 -> 3.51522679E-24 Inexact Rounded +xrem346 remainder -854.586113 -79.8715762E-853065103 -> NaN Division_impossible +xsub346 subtract -854.586113 -79.8715762E-853065103 -> -854.586113 Inexact Rounded +xadd347 add 78872665.3 172.102119 -> 78872837.4 Inexact Rounded +xcom347 compare 78872665.3 172.102119 -> 1 +xdiv347 divide 78872665.3 172.102119 -> 458289.914 Inexact Rounded +xdvi347 divideint 78872665.3 172.102119 -> 458289 +xmul347 multiply 78872665.3 172.102119 -> 1.35741528E+10 Inexact Rounded +xpow347 power 78872665.3 172 -> 1.86793137E+1358 Inexact Rounded +xrem347 remainder 78872665.3 172.102119 -> 157.285609 +xsub347 subtract 78872665.3 172.102119 -> 78872493.2 Inexact Rounded +xadd348 add 328268.1E-436315617 -204.522245 -> -204.522245 Inexact Rounded +xcom348 compare 328268.1E-436315617 -204.522245 -> 1 +xdiv348 divide 328268.1E-436315617 -204.522245 -> -1.60504839E-436315614 Inexact Rounded +xdvi348 divideint 328268.1E-436315617 -204.522245 -> -0 +xmul348 multiply 328268.1E-436315617 -204.522245 -> -6.71381288E-436315610 Inexact Rounded +xpow348 power 328268.1E-436315617 -205 -> Infinity Overflow Inexact Rounded +xrem348 remainder 328268.1E-436315617 -204.522245 -> 3.282681E-436315612 +xsub348 subtract 328268.1E-436315617 -204.522245 -> 204.522245 Inexact Rounded +xadd349 add -4037911.02E+641367645 29.5713010 -> -4.03791102E+641367651 Inexact Rounded +xcom349 compare -4037911.02E+641367645 29.5713010 -> -1 +xdiv349 divide -4037911.02E+641367645 29.5713010 -> -1.36548305E+641367650 Inexact Rounded +xdvi349 divideint -4037911.02E+641367645 29.5713010 -> NaN Division_impossible +xmul349 multiply -4037911.02E+641367645 29.5713010 -> -1.19406282E+641367653 Inexact Rounded +xpow349 power -4037911.02E+641367645 30 -> Infinity Overflow Inexact Rounded +xrem349 remainder -4037911.02E+641367645 29.5713010 -> NaN Division_impossible +xsub349 subtract -4037911.02E+641367645 29.5713010 -> -4.03791102E+641367651 Inexact Rounded +xadd350 add -688755561.E-95301699 978.275312E+913812609 -> 9.78275312E+913812611 Inexact Rounded +xcom350 compare -688755561.E-95301699 978.275312E+913812609 -> -1 +xdiv350 divide -688755561.E-95301699 978.275312E+913812609 -> -0E-1000000007 Inexact Rounded Underflow Subnormal +xdvi350 divideint -688755561.E-95301699 978.275312E+913812609 -> -0 +xmul350 multiply -688755561.E-95301699 978.275312E+913812609 -> -6.73792561E+818510921 Inexact Rounded +xpow350 power -688755561.E-95301699 10 -> 2.40243244E-953016902 Inexact Rounded +xrem350 remainder -688755561.E-95301699 978.275312E+913812609 -> -6.88755561E-95301691 +xsub350 subtract -688755561.E-95301699 978.275312E+913812609 -> -9.78275312E+913812611 Inexact Rounded +xadd351 add -5.47345502 59818.7580 -> 59813.2845 Inexact Rounded +xcom351 compare -5.47345502 59818.7580 -> -1 +xdiv351 divide -5.47345502 59818.7580 -> -0.0000915006463 Inexact Rounded +xdvi351 divideint -5.47345502 59818.7580 -> -0 +xmul351 multiply -5.47345502 59818.7580 -> -327415.281 Inexact Rounded +xpow351 power -5.47345502 59819 -> -1.16914146E+44162 Inexact Rounded +xrem351 remainder -5.47345502 59818.7580 -> -5.47345502 +xsub351 subtract -5.47345502 59818.7580 -> -59824.2315 Inexact Rounded +xadd352 add 563891620E-361354567 -845900362. -> -845900362 Inexact Rounded +xcom352 compare 563891620E-361354567 -845900362. -> 1 +xdiv352 divide 563891620E-361354567 -845900362. -> -6.66617069E-361354568 Inexact Rounded +xdvi352 divideint 563891620E-361354567 -845900362. -> -0 +xmul352 multiply 563891620E-361354567 -845900362. -> -4.76996125E-361354550 Inexact Rounded +xpow352 power 563891620E-361354567 -845900362 -> Infinity Overflow Inexact Rounded +xrem352 remainder 563891620E-361354567 -845900362. -> 5.63891620E-361354559 +xsub352 subtract 563891620E-361354567 -845900362. -> 845900362 Inexact Rounded +xadd353 add -69.7231286 85773.7504 -> 85704.0273 Inexact Rounded +xcom353 compare -69.7231286 85773.7504 -> -1 +xdiv353 divide -69.7231286 85773.7504 -> -0.000812872566 Inexact Rounded +xdvi353 divideint -69.7231286 85773.7504 -> -0 +xmul353 multiply -69.7231286 85773.7504 -> -5980414.23 Inexact Rounded +xpow353 power -69.7231286 85774 -> 6.41714261E+158113 Inexact Rounded +xrem353 remainder -69.7231286 85773.7504 -> -69.7231286 +xsub353 subtract -69.7231286 85773.7504 -> -85843.4735 Inexact Rounded +xadd354 add 5125.51188 73814638.4E-500934741 -> 5125.51188 Inexact Rounded +xcom354 compare 5125.51188 73814638.4E-500934741 -> 1 +xdiv354 divide 5125.51188 73814638.4E-500934741 -> 6.94376074E+500934736 Inexact Rounded +xdvi354 divideint 5125.51188 73814638.4E-500934741 -> NaN Division_impossible +xmul354 multiply 5125.51188 73814638.4E-500934741 -> 3.78337806E-500934730 Inexact Rounded +xpow354 power 5125.51188 7 -> 9.29310216E+25 Inexact Rounded +xrem354 remainder 5125.51188 73814638.4E-500934741 -> NaN Division_impossible +xsub354 subtract 5125.51188 73814638.4E-500934741 -> 5125.51188 Inexact Rounded +xadd355 add -54.6254096 -332921899. -> -332921954 Inexact Rounded +xcom355 compare -54.6254096 -332921899. -> 1 +xdiv355 divide -54.6254096 -332921899. -> 1.64078752E-7 Inexact Rounded +xdvi355 divideint -54.6254096 -332921899. -> 0 +xmul355 multiply -54.6254096 -332921899. -> 1.81859951E+10 Inexact Rounded +xpow355 power -54.6254096 -332921899 -> -1.01482569E-578416745 Inexact Rounded +xrem355 remainder -54.6254096 -332921899. -> -54.6254096 +xsub355 subtract -54.6254096 -332921899. -> 332921844 Inexact Rounded +xadd356 add -9.04778095E-591874079 8719.40286 -> 8719.40286 Inexact Rounded +xcom356 compare -9.04778095E-591874079 8719.40286 -> -1 +xdiv356 divide -9.04778095E-591874079 8719.40286 -> -1.03766062E-591874082 Inexact Rounded +xdvi356 divideint -9.04778095E-591874079 8719.40286 -> -0 +xmul356 multiply -9.04778095E-591874079 8719.40286 -> -7.88912471E-591874075 Inexact Rounded +xpow356 power -9.04778095E-591874079 8719 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem356 remainder -9.04778095E-591874079 8719.40286 -> -9.04778095E-591874079 +xsub356 subtract -9.04778095E-591874079 8719.40286 -> -8719.40286 Inexact Rounded +xadd357 add -21006.1733E+884684431 -48872.9175 -> -2.10061733E+884684435 Inexact Rounded +xcom357 compare -21006.1733E+884684431 -48872.9175 -> -1 +xdiv357 divide -21006.1733E+884684431 -48872.9175 -> 4.29812141E+884684430 Inexact Rounded +xdvi357 divideint -21006.1733E+884684431 -48872.9175 -> NaN Division_impossible +xmul357 multiply -21006.1733E+884684431 -48872.9175 -> 1.02663297E+884684440 Inexact Rounded +xpow357 power -21006.1733E+884684431 -48873 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem357 remainder -21006.1733E+884684431 -48872.9175 -> NaN Division_impossible +xsub357 subtract -21006.1733E+884684431 -48872.9175 -> -2.10061733E+884684435 Inexact Rounded +xadd358 add -1546783 -51935370.4 -> -53482153.4 +xcom358 compare -1546783 -51935370.4 -> 1 +xdiv358 divide -1546783 -51935370.4 -> 0.0297828433 Inexact Rounded +xdvi358 divideint -1546783 -51935370.4 -> 0 +xmul358 multiply -1546783 -51935370.4 -> 8.03327480E+13 Inexact Rounded +xpow358 power -1546783 -51935370 -> 3.36022461E-321450306 Inexact Rounded +xrem358 remainder -1546783 -51935370.4 -> -1546783.0 +xsub358 subtract -1546783 -51935370.4 -> 50388587.4 +xadd359 add 61302486.8 205.490417 -> 61302692.3 Inexact Rounded +xcom359 compare 61302486.8 205.490417 -> 1 +xdiv359 divide 61302486.8 205.490417 -> 298322.850 Inexact Rounded +xdvi359 divideint 61302486.8 205.490417 -> 298322 +xmul359 multiply 61302486.8 205.490417 -> 1.25970736E+10 Inexact Rounded +xpow359 power 61302486.8 205 -> 2.71024755E+1596 Inexact Rounded +xrem359 remainder 61302486.8 205.490417 -> 174.619726 +xsub359 subtract 61302486.8 205.490417 -> 61302281.3 Inexact Rounded +xadd360 add -318180109. -54008744.6E-170931002 -> -318180109 Inexact Rounded +xcom360 compare -318180109. -54008744.6E-170931002 -> -1 +xdiv360 divide -318180109. -54008744.6E-170931002 -> 5.89127023E+170931002 Inexact Rounded +xdvi360 divideint -318180109. -54008744.6E-170931002 -> NaN Division_impossible +xmul360 multiply -318180109. -54008744.6E-170931002 -> 1.71845082E-170930986 Inexact Rounded +xpow360 power -318180109. -5 -> -3.06644280E-43 Inexact Rounded +xrem360 remainder -318180109. -54008744.6E-170931002 -> NaN Division_impossible +xsub360 subtract -318180109. -54008744.6E-170931002 -> -318180109 Inexact Rounded +xadd361 add -28486137.1E+901441714 -42454.940 -> -2.84861371E+901441721 Inexact Rounded +xcom361 compare -28486137.1E+901441714 -42454.940 -> -1 +xdiv361 divide -28486137.1E+901441714 -42454.940 -> 6.70973439E+901441716 Inexact Rounded +xdvi361 divideint -28486137.1E+901441714 -42454.940 -> NaN Division_impossible +xmul361 multiply -28486137.1E+901441714 -42454.940 -> 1.20937724E+901441726 Inexact Rounded +xpow361 power -28486137.1E+901441714 -42455 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem361 remainder -28486137.1E+901441714 -42454.940 -> NaN Division_impossible +xsub361 subtract -28486137.1E+901441714 -42454.940 -> -2.84861371E+901441721 Inexact Rounded +xadd362 add -546398328. -27.9149712 -> -546398356 Inexact Rounded +xcom362 compare -546398328. -27.9149712 -> -1 +xdiv362 divide -546398328. -27.9149712 -> 19573666.2 Inexact Rounded +xdvi362 divideint -546398328. -27.9149712 -> 19573666 +xmul362 multiply -546398328. -27.9149712 -> 1.52526936E+10 Inexact Rounded +xpow362 power -546398328. -28 -> 2.23737032E-245 Inexact Rounded +xrem362 remainder -546398328. -27.9149712 -> -5.3315808 +xsub362 subtract -546398328. -27.9149712 -> -546398300 Inexact Rounded +xadd363 add 5402066.1E-284978216 622.751128 -> 622.751128 Inexact Rounded +xcom363 compare 5402066.1E-284978216 622.751128 -> -1 +xdiv363 divide 5402066.1E-284978216 622.751128 -> 8.67451837E-284978213 Inexact Rounded +xdvi363 divideint 5402066.1E-284978216 622.751128 -> 0 +xmul363 multiply 5402066.1E-284978216 622.751128 -> 3.36414276E-284978207 Inexact Rounded +xpow363 power 5402066.1E-284978216 623 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem363 remainder 5402066.1E-284978216 622.751128 -> 5.4020661E-284978210 +xsub363 subtract 5402066.1E-284978216 622.751128 -> -622.751128 Inexact Rounded +xadd364 add 18845620 3129.43753 -> 18848749.4 Inexact Rounded +xcom364 compare 18845620 3129.43753 -> 1 +xdiv364 divide 18845620 3129.43753 -> 6022.04704 Inexact Rounded +xdvi364 divideint 18845620 3129.43753 -> 6022 +xmul364 multiply 18845620 3129.43753 -> 5.89761905E+10 Inexact Rounded +xpow364 power 18845620 3129 -> 1.35967443E+22764 Inexact Rounded +xrem364 remainder 18845620 3129.43753 -> 147.19434 +xsub364 subtract 18845620 3129.43753 -> 18842490.6 Inexact Rounded +xadd365 add 50707.1412E+912475670 -198098.186E+701407524 -> 5.07071412E+912475674 Inexact Rounded +xcom365 compare 50707.1412E+912475670 -198098.186E+701407524 -> 1 +xdiv365 divide 50707.1412E+912475670 -198098.186E+701407524 -> -2.55969740E+211068145 Inexact Rounded +xdvi365 divideint 50707.1412E+912475670 -198098.186E+701407524 -> NaN Division_impossible +xmul365 multiply 50707.1412E+912475670 -198098.186E+701407524 -> -Infinity Inexact Overflow Rounded +xpow365 power 50707.1412E+912475670 -2 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem365 remainder 50707.1412E+912475670 -198098.186E+701407524 -> NaN Division_impossible +xsub365 subtract 50707.1412E+912475670 -198098.186E+701407524 -> 5.07071412E+912475674 Inexact Rounded +xadd366 add 55.8245006E+928885991 99170843.9E-47402167 -> 5.58245006E+928885992 Inexact Rounded +xcom366 compare 55.8245006E+928885991 99170843.9E-47402167 -> 1 +xdiv366 divide 55.8245006E+928885991 99170843.9E-47402167 -> 5.62912429E+976288151 Inexact Rounded +xdvi366 divideint 55.8245006E+928885991 99170843.9E-47402167 -> NaN Division_impossible +xmul366 multiply 55.8245006E+928885991 99170843.9E-47402167 -> 5.53616283E+881483833 Inexact Rounded +xpow366 power 55.8245006E+928885991 10 -> Infinity Overflow Inexact Rounded +xrem366 remainder 55.8245006E+928885991 99170843.9E-47402167 -> NaN Division_impossible +xsub366 subtract 55.8245006E+928885991 99170843.9E-47402167 -> 5.58245006E+928885992 Inexact Rounded +xadd367 add 13.8003883E-386224921 -84126481.9E-296378341 -> -8.41264819E-296378334 Inexact Rounded +xcom367 compare 13.8003883E-386224921 -84126481.9E-296378341 -> 1 +xdiv367 divide 13.8003883E-386224921 -84126481.9E-296378341 -> -1.64043331E-89846587 Inexact Rounded +xdvi367 divideint 13.8003883E-386224921 -84126481.9E-296378341 -> -0 +xmul367 multiply 13.8003883E-386224921 -84126481.9E-296378341 -> -1.16097812E-682603253 Inexact Rounded +xpow367 power 13.8003883E-386224921 -8 -> Infinity Overflow Inexact Rounded +xrem367 remainder 13.8003883E-386224921 -84126481.9E-296378341 -> 1.38003883E-386224920 +xsub367 subtract 13.8003883E-386224921 -84126481.9E-296378341 -> 8.41264819E-296378334 Inexact Rounded +xadd368 add 9820.90457 46671.5915 -> 56492.4961 Inexact Rounded +xcom368 compare 9820.90457 46671.5915 -> -1 +xdiv368 divide 9820.90457 46671.5915 -> 0.210425748 Inexact Rounded +xdvi368 divideint 9820.90457 46671.5915 -> 0 +xmul368 multiply 9820.90457 46671.5915 -> 458357246 Inexact Rounded +xpow368 power 9820.90457 46672 -> 4.94753070E+186321 Inexact Rounded +xrem368 remainder 9820.90457 46671.5915 -> 9820.90457 +xsub368 subtract 9820.90457 46671.5915 -> -36850.6869 Inexact Rounded +xadd369 add 7.22436006E+831949153 -11168830E+322331045 -> 7.22436006E+831949153 Inexact Rounded +xcom369 compare 7.22436006E+831949153 -11168830E+322331045 -> 1 +xdiv369 divide 7.22436006E+831949153 -11168830E+322331045 -> -6.46832306E+509618101 Inexact Rounded +xdvi369 divideint 7.22436006E+831949153 -11168830E+322331045 -> NaN Division_impossible +xmul369 multiply 7.22436006E+831949153 -11168830E+322331045 -> -Infinity Inexact Overflow Rounded +xpow369 power 7.22436006E+831949153 -1 -> 1.38420565E-831949154 Inexact Rounded +xrem369 remainder 7.22436006E+831949153 -11168830E+322331045 -> NaN Division_impossible +xsub369 subtract 7.22436006E+831949153 -11168830E+322331045 -> 7.22436006E+831949153 Inexact Rounded +xadd370 add 472648900 -207.784153 -> 472648692 Inexact Rounded +xcom370 compare 472648900 -207.784153 -> 1 +xdiv370 divide 472648900 -207.784153 -> -2274711.01 Inexact Rounded +xdvi370 divideint 472648900 -207.784153 -> -2274711 +xmul370 multiply 472648900 -207.784153 -> -9.82089514E+10 Inexact Rounded +xpow370 power 472648900 -208 -> 4.96547145E-1805 Inexact Rounded +xrem370 remainder 472648900 -207.784153 -> 1.545217 +xsub370 subtract 472648900 -207.784153 -> 472649108 Inexact Rounded +xadd371 add -8754.49306 -818.165153E+631475457 -> -8.18165153E+631475459 Inexact Rounded +xcom371 compare -8754.49306 -818.165153E+631475457 -> 1 +xdiv371 divide -8754.49306 -818.165153E+631475457 -> 1.07001539E-631475456 Inexact Rounded +xdvi371 divideint -8754.49306 -818.165153E+631475457 -> 0 +xmul371 multiply -8754.49306 -818.165153E+631475457 -> 7.16262115E+631475463 Inexact Rounded +xpow371 power -8754.49306 -8 -> 2.89835767E-32 Inexact Rounded +xrem371 remainder -8754.49306 -818.165153E+631475457 -> -8754.49306 +xsub371 subtract -8754.49306 -818.165153E+631475457 -> 8.18165153E+631475459 Inexact Rounded +xadd372 add 98750864 191380.551 -> 98942244.6 Inexact Rounded +xcom372 compare 98750864 191380.551 -> 1 +xdiv372 divide 98750864 191380.551 -> 515.992161 Inexact Rounded +xdvi372 divideint 98750864 191380.551 -> 515 +xmul372 multiply 98750864 191380.551 -> 1.88989948E+13 Inexact Rounded +xpow372 power 98750864 191381 -> 1.70908809E+1530003 Inexact Rounded +xrem372 remainder 98750864 191380.551 -> 189880.235 +xsub372 subtract 98750864 191380.551 -> 98559483.4 Inexact Rounded +xadd373 add 725292561. -768963606.E+340762986 -> -7.68963606E+340762994 Inexact Rounded +xcom373 compare 725292561. -768963606.E+340762986 -> 1 +xdiv373 divide 725292561. -768963606.E+340762986 -> -9.43207917E-340762987 Inexact Rounded +xdvi373 divideint 725292561. -768963606.E+340762986 -> -0 +xmul373 multiply 725292561. -768963606.E+340762986 -> -5.57723583E+340763003 Inexact Rounded +xpow373 power 725292561. -8 -> 1.30585277E-71 Inexact Rounded +xrem373 remainder 725292561. -768963606.E+340762986 -> 725292561 +xsub373 subtract 725292561. -768963606.E+340762986 -> 7.68963606E+340762994 Inexact Rounded +xadd374 add 1862.80445 648254483. -> 648256346 Inexact Rounded +xcom374 compare 1862.80445 648254483. -> -1 +xdiv374 divide 1862.80445 648254483. -> 0.00000287356972 Inexact Rounded +xdvi374 divideint 1862.80445 648254483. -> 0 +xmul374 multiply 1862.80445 648254483. -> 1.20757134E+12 Inexact Rounded +xpow374 power 1862.80445 648254483 -> Infinity Overflow Inexact Rounded +xrem374 remainder 1862.80445 648254483. -> 1862.80445 +xsub374 subtract 1862.80445 648254483. -> -648252620 Inexact Rounded +xadd375 add -5549320.1 -93580684.1 -> -99130004.2 +xcom375 compare -5549320.1 -93580684.1 -> 1 +xdiv375 divide -5549320.1 -93580684.1 -> 0.0592998454 Inexact Rounded +xdvi375 divideint -5549320.1 -93580684.1 -> 0 +xmul375 multiply -5549320.1 -93580684.1 -> 5.19309171E+14 Inexact Rounded +xpow375 power -5549320.1 -93580684 -> 4.20662080E-631130572 Inexact Rounded +xrem375 remainder -5549320.1 -93580684.1 -> -5549320.1 +xsub375 subtract -5549320.1 -93580684.1 -> 88031364.0 +xadd376 add -14677053.1 -25784.7358 -> -14702837.8 Inexact Rounded +xcom376 compare -14677053.1 -25784.7358 -> -1 +xdiv376 divide -14677053.1 -25784.7358 -> 569.214795 Inexact Rounded +xdvi376 divideint -14677053.1 -25784.7358 -> 569 +xmul376 multiply -14677053.1 -25784.7358 -> 3.78443937E+11 Inexact Rounded +xpow376 power -14677053.1 -25785 -> -1.64760831E-184792 Inexact Rounded +xrem376 remainder -14677053.1 -25784.7358 -> -5538.4298 +xsub376 subtract -14677053.1 -25784.7358 -> -14651268.4 Inexact Rounded +xadd377 add 547402.308E+571687617 -7835797.01E+500067364 -> 5.47402308E+571687622 Inexact Rounded +xcom377 compare 547402.308E+571687617 -7835797.01E+500067364 -> 1 +xdiv377 divide 547402.308E+571687617 -7835797.01E+500067364 -> -6.98591742E+71620251 Inexact Rounded +xdvi377 divideint 547402.308E+571687617 -7835797.01E+500067364 -> NaN Division_impossible +xmul377 multiply 547402.308E+571687617 -7835797.01E+500067364 -> -Infinity Inexact Overflow Rounded +xpow377 power 547402.308E+571687617 -8 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem377 remainder 547402.308E+571687617 -7835797.01E+500067364 -> NaN Division_impossible +xsub377 subtract 547402.308E+571687617 -7835797.01E+500067364 -> 5.47402308E+571687622 Inexact Rounded +xadd378 add -4131738.09 7579.07566 -> -4124159.01 Inexact Rounded +xcom378 compare -4131738.09 7579.07566 -> -1 +xdiv378 divide -4131738.09 7579.07566 -> -545.150659 Inexact Rounded +xdvi378 divideint -4131738.09 7579.07566 -> -545 +xmul378 multiply -4131738.09 7579.07566 -> -3.13147556E+10 Inexact Rounded +xpow378 power -4131738.09 7579 -> -4.68132794E+50143 Inexact Rounded +xrem378 remainder -4131738.09 7579.07566 -> -1141.85530 +xsub378 subtract -4131738.09 7579.07566 -> -4139317.17 Inexact Rounded +xadd379 add 504544.648 -7678.96133E-662143268 -> 504544.648 Inexact Rounded +xcom379 compare 504544.648 -7678.96133E-662143268 -> 1 +xdiv379 divide 504544.648 -7678.96133E-662143268 -> -6.57048039E+662143269 Inexact Rounded +xdvi379 divideint 504544.648 -7678.96133E-662143268 -> NaN Division_impossible +xmul379 multiply 504544.648 -7678.96133E-662143268 -> -3.87437884E-662143259 Inexact Rounded +xpow379 power 504544.648 -8 -> 2.38124001E-46 Inexact Rounded +xrem379 remainder 504544.648 -7678.96133E-662143268 -> NaN Division_impossible +xsub379 subtract 504544.648 -7678.96133E-662143268 -> 504544.648 Inexact Rounded +xadd380 add 829898241 8912.99114E+929228149 -> 8.91299114E+929228152 Inexact Rounded +xcom380 compare 829898241 8912.99114E+929228149 -> -1 +xdiv380 divide 829898241 8912.99114E+929228149 -> 9.31110811E-929228145 Inexact Rounded +xdvi380 divideint 829898241 8912.99114E+929228149 -> 0 +xmul380 multiply 829898241 8912.99114E+929228149 -> 7.39687567E+929228161 Inexact Rounded +xpow380 power 829898241 9 -> 1.86734084E+80 Inexact Rounded +xrem380 remainder 829898241 8912.99114E+929228149 -> 829898241 +xsub380 subtract 829898241 8912.99114E+929228149 -> -8.91299114E+929228152 Inexact Rounded +xadd381 add 53.6891691 -11.2371140 -> 42.4520551 +xcom381 compare 53.6891691 -11.2371140 -> 1 +xdiv381 divide 53.6891691 -11.2371140 -> -4.77784323 Inexact Rounded +xdvi381 divideint 53.6891691 -11.2371140 -> -4 +xmul381 multiply 53.6891691 -11.2371140 -> -603.311314 Inexact Rounded +xpow381 power 53.6891691 -11 -> 9.35936725E-20 Inexact Rounded +xrem381 remainder 53.6891691 -11.2371140 -> 8.7407131 +xsub381 subtract 53.6891691 -11.2371140 -> 64.9262831 +xadd382 add -93951823.4 -25317.8645 -> -93977141.3 Inexact Rounded +xcom382 compare -93951823.4 -25317.8645 -> -1 +xdiv382 divide -93951823.4 -25317.8645 -> 3710.89052 Inexact Rounded +xdvi382 divideint -93951823.4 -25317.8645 -> 3710 +xmul382 multiply -93951823.4 -25317.8645 -> 2.37865953E+12 Inexact Rounded +xpow382 power -93951823.4 -25318 -> 9.67857714E-201859 Inexact Rounded +xrem382 remainder -93951823.4 -25317.8645 -> -22546.1050 +xsub382 subtract -93951823.4 -25317.8645 -> -93926505.5 Inexact Rounded +xadd383 add 446919.123 951338490. -> 951785409 Inexact Rounded +xcom383 compare 446919.123 951338490. -> -1 +xdiv383 divide 446919.123 951338490. -> 0.000469779293 Inexact Rounded +xdvi383 divideint 446919.123 951338490. -> 0 +xmul383 multiply 446919.123 951338490. -> 4.25171364E+14 Inexact Rounded +xpow383 power 446919.123 951338490 -> Infinity Overflow Inexact Rounded +xrem383 remainder 446919.123 951338490. -> 446919.123 +xsub383 subtract 446919.123 951338490. -> -950891571 Inexact Rounded +xadd384 add -8.01787748 -88.3076852 -> -96.3255627 Inexact Rounded +xcom384 compare -8.01787748 -88.3076852 -> 1 +xdiv384 divide -8.01787748 -88.3076852 -> 0.0907947871 Inexact Rounded +xdvi384 divideint -8.01787748 -88.3076852 -> 0 +xmul384 multiply -8.01787748 -88.3076852 -> 708.040200 Inexact Rounded +xpow384 power -8.01787748 -88 -> 2.77186088E-80 Inexact Rounded +xrem384 remainder -8.01787748 -88.3076852 -> -8.01787748 +xsub384 subtract -8.01787748 -88.3076852 -> 80.2898077 Inexact Rounded +xadd385 add 517458139 -999731.548 -> 516458407 Inexact Rounded +xcom385 compare 517458139 -999731.548 -> 1 +xdiv385 divide 517458139 -999731.548 -> -517.597089 Inexact Rounded +xdvi385 divideint 517458139 -999731.548 -> -517 +xmul385 multiply 517458139 -999731.548 -> -5.17319226E+14 Inexact Rounded +xpow385 power 517458139 -999732 -> 1.24821346E-8711540 Inexact Rounded +xrem385 remainder 517458139 -999731.548 -> 596928.684 +xsub385 subtract 517458139 -999731.548 -> 518457871 Inexact Rounded +xadd386 add -405543440 -4013.18295 -> -405547453 Inexact Rounded +xcom386 compare -405543440 -4013.18295 -> -1 +xdiv386 divide -405543440 -4013.18295 -> 101052.816 Inexact Rounded +xdvi386 divideint -405543440 -4013.18295 -> 101052 +xmul386 multiply -405543440 -4013.18295 -> 1.62752002E+12 Inexact Rounded +xpow386 power -405543440 -4013 -> -8.83061932E-34545 Inexact Rounded +xrem386 remainder -405543440 -4013.18295 -> -3276.53660 +xsub386 subtract -405543440 -4013.18295 -> -405539427 Inexact Rounded +xadd387 add -49245250.1E+682760825 -848776.637 -> -4.92452501E+682760832 Inexact Rounded +xcom387 compare -49245250.1E+682760825 -848776.637 -> -1 +xdiv387 divide -49245250.1E+682760825 -848776.637 -> 5.80190924E+682760826 Inexact Rounded +xdvi387 divideint -49245250.1E+682760825 -848776.637 -> NaN Division_impossible +xmul387 multiply -49245250.1E+682760825 -848776.637 -> 4.17982178E+682760838 Inexact Rounded +xpow387 power -49245250.1E+682760825 -848777 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem387 remainder -49245250.1E+682760825 -848776.637 -> NaN Division_impossible +xsub387 subtract -49245250.1E+682760825 -848776.637 -> -4.92452501E+682760832 Inexact Rounded +xadd388 add -151144455 -170371.29 -> -151314826 Inexact Rounded +xcom388 compare -151144455 -170371.29 -> -1 +xdiv388 divide -151144455 -170371.29 -> 887.147447 Inexact Rounded +xdvi388 divideint -151144455 -170371.29 -> 887 +xmul388 multiply -151144455 -170371.29 -> 2.57506758E+13 Inexact Rounded +xpow388 power -151144455 -170371 -> -5.86496369E-1393532 Inexact Rounded +xrem388 remainder -151144455 -170371.29 -> -25120.77 +xsub388 subtract -151144455 -170371.29 -> -150974084 Inexact Rounded +xadd389 add -729236746.E+662737067 9.10823602 -> -7.29236746E+662737075 Inexact Rounded +xcom389 compare -729236746.E+662737067 9.10823602 -> -1 +xdiv389 divide -729236746.E+662737067 9.10823602 -> -8.00634442E+662737074 Inexact Rounded +xdvi389 divideint -729236746.E+662737067 9.10823602 -> NaN Division_impossible +xmul389 multiply -729236746.E+662737067 9.10823602 -> -6.64206040E+662737076 Inexact Rounded +xpow389 power -729236746.E+662737067 9 -> -Infinity Overflow Inexact Rounded +xrem389 remainder -729236746.E+662737067 9.10823602 -> NaN Division_impossible +xsub389 subtract -729236746.E+662737067 9.10823602 -> -7.29236746E+662737075 Inexact Rounded +xadd390 add 534.394729 -2369839.37 -> -2369304.98 Inexact Rounded +xcom390 compare 534.394729 -2369839.37 -> 1 +xdiv390 divide 534.394729 -2369839.37 -> -0.000225498291 Inexact Rounded +xdvi390 divideint 534.394729 -2369839.37 -> -0 +xmul390 multiply 534.394729 -2369839.37 -> -1.26642967E+9 Inexact Rounded +xpow390 power 534.394729 -2369839 -> 7.12522896E-6464595 Inexact Rounded +xrem390 remainder 534.394729 -2369839.37 -> 534.394729 +xsub390 subtract 534.394729 -2369839.37 -> 2370373.76 Inexact Rounded +xadd391 add 89100.1797 224.370309 -> 89324.5500 Inexact Rounded +xcom391 compare 89100.1797 224.370309 -> 1 +xdiv391 divide 89100.1797 224.370309 -> 397.112167 Inexact Rounded +xdvi391 divideint 89100.1797 224.370309 -> 397 +xmul391 multiply 89100.1797 224.370309 -> 19991434.9 Inexact Rounded +xpow391 power 89100.1797 224 -> 5.92654936E+1108 Inexact Rounded +xrem391 remainder 89100.1797 224.370309 -> 25.167027 +xsub391 subtract 89100.1797 224.370309 -> 88875.8094 Inexact Rounded +xadd392 add -821377.777 38.552821 -> -821339.224 Inexact Rounded +xcom392 compare -821377.777 38.552821 -> -1 +xdiv392 divide -821377.777 38.552821 -> -21305.2575 Inexact Rounded +xdvi392 divideint -821377.777 38.552821 -> -21305 +xmul392 multiply -821377.777 38.552821 -> -31666430.4 Inexact Rounded +xpow392 power -821377.777 39 -> -4.64702482E+230 Inexact Rounded +xrem392 remainder -821377.777 38.552821 -> -9.925595 +xsub392 subtract -821377.777 38.552821 -> -821416.330 Inexact Rounded +xadd393 add -392640.782 -2571619.5E+113237865 -> -2.57161950E+113237871 Inexact Rounded +xcom393 compare -392640.782 -2571619.5E+113237865 -> 1 +xdiv393 divide -392640.782 -2571619.5E+113237865 -> 1.52682301E-113237866 Inexact Rounded +xdvi393 divideint -392640.782 -2571619.5E+113237865 -> 0 +xmul393 multiply -392640.782 -2571619.5E+113237865 -> 1.00972269E+113237877 Inexact Rounded +xpow393 power -392640.782 -3 -> -1.65201422E-17 Inexact Rounded +xrem393 remainder -392640.782 -2571619.5E+113237865 -> -392640.782 +xsub393 subtract -392640.782 -2571619.5E+113237865 -> 2.57161950E+113237871 Inexact Rounded +xadd394 add -651397.712 -723.59673 -> -652121.309 Inexact Rounded +xcom394 compare -651397.712 -723.59673 -> -1 +xdiv394 divide -651397.712 -723.59673 -> 900.222023 Inexact Rounded +xdvi394 divideint -651397.712 -723.59673 -> 900 +xmul394 multiply -651397.712 -723.59673 -> 471349254 Inexact Rounded +xpow394 power -651397.712 -724 -> 5.96115415E-4210 Inexact Rounded +xrem394 remainder -651397.712 -723.59673 -> -160.65500 +xsub394 subtract -651397.712 -723.59673 -> -650674.115 Inexact Rounded +xadd395 add 86.6890892 940380864 -> 940380951 Inexact Rounded +xcom395 compare 86.6890892 940380864 -> -1 +xdiv395 divide 86.6890892 940380864 -> 9.21850843E-8 Inexact Rounded +xdvi395 divideint 86.6890892 940380864 -> 0 +xmul395 multiply 86.6890892 940380864 -> 8.15207606E+10 Inexact Rounded +xpow395 power 86.6890892 940380864 -> Infinity Overflow Inexact Rounded +xrem395 remainder 86.6890892 940380864 -> 86.6890892 +xsub395 subtract 86.6890892 940380864 -> -940380777 Inexact Rounded +xadd396 add 4880.06442E-382222621 -115627239E-912834031 -> 4.88006442E-382222618 Inexact Rounded +xcom396 compare 4880.06442E-382222621 -115627239E-912834031 -> 1 +xdiv396 divide 4880.06442E-382222621 -115627239E-912834031 -> -4.22051453E+530611405 Inexact Rounded +xdvi396 divideint 4880.06442E-382222621 -115627239E-912834031 -> NaN Division_impossible +xmul396 multiply 4880.06442E-382222621 -115627239E-912834031 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow396 power 4880.06442E-382222621 -1 -> 2.04915328E+382222617 Inexact Rounded +xrem396 remainder 4880.06442E-382222621 -115627239E-912834031 -> NaN Division_impossible +xsub396 subtract 4880.06442E-382222621 -115627239E-912834031 -> 4.88006442E-382222618 Inexact Rounded +xadd397 add 173398265E-532383158 3462.51450E+80986915 -> 3.46251450E+80986918 Inexact Rounded +xcom397 compare 173398265E-532383158 3462.51450E+80986915 -> -1 +xdiv397 divide 173398265E-532383158 3462.51450E+80986915 -> 5.00787116E-613370069 Inexact Rounded +xdvi397 divideint 173398265E-532383158 3462.51450E+80986915 -> 0 +xmul397 multiply 173398265E-532383158 3462.51450E+80986915 -> 6.00394007E-451396232 Inexact Rounded +xpow397 power 173398265E-532383158 3 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem397 remainder 173398265E-532383158 3462.51450E+80986915 -> 1.73398265E-532383150 +xsub397 subtract 173398265E-532383158 3462.51450E+80986915 -> -3.46251450E+80986918 Inexact Rounded +xadd398 add -1522176.78 -6631061.77 -> -8153238.55 +xcom398 compare -1522176.78 -6631061.77 -> 1 +xdiv398 divide -1522176.78 -6631061.77 -> 0.229552496 Inexact Rounded +xdvi398 divideint -1522176.78 -6631061.77 -> 0 +xmul398 multiply -1522176.78 -6631061.77 -> 1.00936483E+13 Inexact Rounded +xpow398 power -1522176.78 -6631062 -> 4.54268854E-40996310 Inexact Rounded +xrem398 remainder -1522176.78 -6631061.77 -> -1522176.78 +xsub398 subtract -1522176.78 -6631061.77 -> 5108884.99 +xadd399 add 538.10453 522934310 -> 522934848 Inexact Rounded +xcom399 compare 538.10453 522934310 -> -1 +xdiv399 divide 538.10453 522934310 -> 0.00000102900980 Inexact Rounded +xdvi399 divideint 538.10453 522934310 -> 0 +xmul399 multiply 538.10453 522934310 -> 2.81393321E+11 Inexact Rounded +xpow399 power 538.10453 522934310 -> Infinity Overflow Inexact Rounded +xrem399 remainder 538.10453 522934310 -> 538.10453 +xsub399 subtract 538.10453 522934310 -> -522933772 Inexact Rounded +xadd400 add 880243.444E-750940977 -354.601578E-204943740 -> -3.54601578E-204943738 Inexact Rounded +xcom400 compare 880243.444E-750940977 -354.601578E-204943740 -> 1 +xdiv400 divide 880243.444E-750940977 -354.601578E-204943740 -> -2.48234497E-545997234 Inexact Rounded +xdvi400 divideint 880243.444E-750940977 -354.601578E-204943740 -> -0 +xmul400 multiply 880243.444E-750940977 -354.601578E-204943740 -> -3.12135714E-955884709 Inexact Rounded +xpow400 power 880243.444E-750940977 -4 -> Infinity Overflow Inexact Rounded +xrem400 remainder 880243.444E-750940977 -354.601578E-204943740 -> 8.80243444E-750940972 +xsub400 subtract 880243.444E-750940977 -354.601578E-204943740 -> 3.54601578E-204943738 Inexact Rounded +xadd401 add 968370.780 6677268.73 -> 7645639.51 Rounded +xcom401 compare 968370.780 6677268.73 -> -1 +xdiv401 divide 968370.780 6677268.73 -> 0.145024982 Inexact Rounded +xdvi401 divideint 968370.780 6677268.73 -> 0 +xmul401 multiply 968370.780 6677268.73 -> 6.46607193E+12 Inexact Rounded +xpow401 power 968370.780 6677269 -> 3.29990931E+39970410 Inexact Rounded +xrem401 remainder 968370.780 6677268.73 -> 968370.780 +xsub401 subtract 968370.780 6677268.73 -> -5708897.95 Rounded +xadd402 add -97.7474945 31248241.5 -> 31248143.8 Inexact Rounded +xcom402 compare -97.7474945 31248241.5 -> -1 +xdiv402 divide -97.7474945 31248241.5 -> -0.00000312809585 Inexact Rounded +xdvi402 divideint -97.7474945 31248241.5 -> -0 +xmul402 multiply -97.7474945 31248241.5 -> -3.05443731E+9 Inexact Rounded +xpow402 power -97.7474945 31248242 -> 2.90714257E+62187302 Inexact Rounded +xrem402 remainder -97.7474945 31248241.5 -> -97.7474945 +xsub402 subtract -97.7474945 31248241.5 -> -31248339.2 Inexact Rounded +xadd403 add -187582786.E+369916952 957840435E+744365567 -> 9.57840435E+744365575 Inexact Rounded +xcom403 compare -187582786.E+369916952 957840435E+744365567 -> -1 +xdiv403 divide -187582786.E+369916952 957840435E+744365567 -> -1.95839285E-374448616 Inexact Rounded +xdvi403 divideint -187582786.E+369916952 957840435E+744365567 -> -0 +xmul403 multiply -187582786.E+369916952 957840435E+744365567 -> -Infinity Inexact Overflow Rounded +xpow403 power -187582786.E+369916952 10 -> Infinity Overflow Inexact Rounded +xrem403 remainder -187582786.E+369916952 957840435E+744365567 -> -1.87582786E+369916960 +xsub403 subtract -187582786.E+369916952 957840435E+744365567 -> -9.57840435E+744365575 Inexact Rounded +xadd404 add -328026144. -125499735. -> -453525879 +xcom404 compare -328026144. -125499735. -> -1 +xdiv404 divide -328026144. -125499735. -> 2.61375965 Inexact Rounded +xdvi404 divideint -328026144. -125499735. -> 2 +xmul404 multiply -328026144. -125499735. -> 4.11671941E+16 Inexact Rounded +xpow404 power -328026144. -125499735 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem404 remainder -328026144. -125499735. -> -77026674 +xsub404 subtract -328026144. -125499735. -> -202526409 +xadd405 add -99424150.2E-523662102 3712.35030 -> 3712.35030 Inexact Rounded +xcom405 compare -99424150.2E-523662102 3712.35030 -> -1 +xdiv405 divide -99424150.2E-523662102 3712.35030 -> -2.67819958E-523662098 Inexact Rounded +xdvi405 divideint -99424150.2E-523662102 3712.35030 -> -0 +xmul405 multiply -99424150.2E-523662102 3712.35030 -> -3.69097274E-523662091 Inexact Rounded +xpow405 power -99424150.2E-523662102 3712 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem405 remainder -99424150.2E-523662102 3712.35030 -> -9.94241502E-523662095 +xsub405 subtract -99424150.2E-523662102 3712.35030 -> -3712.35030 Inexact Rounded +xadd406 add 14838.0718 9489893.28E+830631266 -> 9.48989328E+830631272 Inexact Rounded +xcom406 compare 14838.0718 9489893.28E+830631266 -> -1 +xdiv406 divide 14838.0718 9489893.28E+830631266 -> 1.56356572E-830631269 Inexact Rounded +xdvi406 divideint 14838.0718 9489893.28E+830631266 -> 0 +xmul406 multiply 14838.0718 9489893.28E+830631266 -> 1.40811718E+830631277 Inexact Rounded +xpow406 power 14838.0718 9 -> 3.48656057E+37 Inexact Rounded +xrem406 remainder 14838.0718 9489893.28E+830631266 -> 14838.0718 +xsub406 subtract 14838.0718 9489893.28E+830631266 -> -9.48989328E+830631272 Inexact Rounded +xadd407 add 71207472.8 -31835.0809 -> 71175637.7 Inexact Rounded +xcom407 compare 71207472.8 -31835.0809 -> 1 +xdiv407 divide 71207472.8 -31835.0809 -> -2236.76117 Inexact Rounded +xdvi407 divideint 71207472.8 -31835.0809 -> -2236 +xmul407 multiply 71207472.8 -31835.0809 -> -2.26689566E+12 Inexact Rounded +xpow407 power 71207472.8 -31835 -> 7.05333953E-249986 Inexact Rounded +xrem407 remainder 71207472.8 -31835.0809 -> 24231.9076 +xsub407 subtract 71207472.8 -31835.0809 -> 71239307.9 Inexact Rounded +xadd408 add -20440.4394 -44.4064328E+511085806 -> -4.44064328E+511085807 Inexact Rounded +xcom408 compare -20440.4394 -44.4064328E+511085806 -> 1 +xdiv408 divide -20440.4394 -44.4064328E+511085806 -> 4.60303567E-511085804 Inexact Rounded +xdvi408 divideint -20440.4394 -44.4064328E+511085806 -> 0 +xmul408 multiply -20440.4394 -44.4064328E+511085806 -> 9.07686999E+511085811 Inexact Rounded +xpow408 power -20440.4394 -4 -> 5.72847590E-18 Inexact Rounded +xrem408 remainder -20440.4394 -44.4064328E+511085806 -> -20440.4394 +xsub408 subtract -20440.4394 -44.4064328E+511085806 -> 4.44064328E+511085807 Inexact Rounded +xadd409 add -54.3684171E-807210192 1.04592973E-984041807 -> -5.43684171E-807210191 Inexact Rounded +xcom409 compare -54.3684171E-807210192 1.04592973E-984041807 -> -1 +xdiv409 divide -54.3684171E-807210192 1.04592973E-984041807 -> -5.19809463E+176831616 Inexact Rounded +xdvi409 divideint -54.3684171E-807210192 1.04592973E-984041807 -> NaN Division_impossible +xmul409 multiply -54.3684171E-807210192 1.04592973E-984041807 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow409 power -54.3684171E-807210192 1 -> -5.43684171E-807210191 +xrem409 remainder -54.3684171E-807210192 1.04592973E-984041807 -> NaN Division_impossible +xsub409 subtract -54.3684171E-807210192 1.04592973E-984041807 -> -5.43684171E-807210191 Inexact Rounded +xadd410 add 54310060.5E+948159739 274320701.E+205880484 -> 5.43100605E+948159746 Inexact Rounded +xcom410 compare 54310060.5E+948159739 274320701.E+205880484 -> 1 +xdiv410 divide 54310060.5E+948159739 274320701.E+205880484 -> 1.97980175E+742279254 Inexact Rounded +xdvi410 divideint 54310060.5E+948159739 274320701.E+205880484 -> NaN Division_impossible +xmul410 multiply 54310060.5E+948159739 274320701.E+205880484 -> Infinity Inexact Overflow Rounded +xpow410 power 54310060.5E+948159739 3 -> Infinity Overflow Inexact Rounded +xrem410 remainder 54310060.5E+948159739 274320701.E+205880484 -> NaN Division_impossible +xsub410 subtract 54310060.5E+948159739 274320701.E+205880484 -> 5.43100605E+948159746 Inexact Rounded +xadd411 add -657.186702 426844.39 -> 426187.203 Inexact Rounded +xcom411 compare -657.186702 426844.39 -> -1 +xdiv411 divide -657.186702 426844.39 -> -0.00153964001 Inexact Rounded +xdvi411 divideint -657.186702 426844.39 -> -0 +xmul411 multiply -657.186702 426844.39 -> -280516457 Inexact Rounded +xpow411 power -657.186702 426844 -> 3.50000575E+1202713 Inexact Rounded +xrem411 remainder -657.186702 426844.39 -> -657.186702 +xsub411 subtract -657.186702 426844.39 -> -427501.577 Inexact Rounded +xadd412 add -41593077.0 -688607.564 -> -42281684.6 Inexact Rounded +xcom412 compare -41593077.0 -688607.564 -> -1 +xdiv412 divide -41593077.0 -688607.564 -> 60.4017138 Inexact Rounded +xdvi412 divideint -41593077.0 -688607.564 -> 60 +xmul412 multiply -41593077.0 -688607.564 -> 2.86413074E+13 Inexact Rounded +xpow412 power -41593077.0 -688608 -> 1.42150750E-5246519 Inexact Rounded +xrem412 remainder -41593077.0 -688607.564 -> -276623.160 +xsub412 subtract -41593077.0 -688607.564 -> -40904469.4 Inexact Rounded +xadd413 add -5786.38132 190556652.E+177045877 -> 1.90556652E+177045885 Inexact Rounded +xcom413 compare -5786.38132 190556652.E+177045877 -> -1 +xdiv413 divide -5786.38132 190556652.E+177045877 -> -3.03656748E-177045882 Inexact Rounded +xdvi413 divideint -5786.38132 190556652.E+177045877 -> -0 +xmul413 multiply -5786.38132 190556652.E+177045877 -> -1.10263345E+177045889 Inexact Rounded +xpow413 power -5786.38132 2 -> 33482208.8 Inexact Rounded +xrem413 remainder -5786.38132 190556652.E+177045877 -> -5786.38132 +xsub413 subtract -5786.38132 190556652.E+177045877 -> -1.90556652E+177045885 Inexact Rounded +xadd414 add 737622.974 -241560693E+249506565 -> -2.41560693E+249506573 Inexact Rounded +xcom414 compare 737622.974 -241560693E+249506565 -> 1 +xdiv414 divide 737622.974 -241560693E+249506565 -> -3.05357202E-249506568 Inexact Rounded +xdvi414 divideint 737622.974 -241560693E+249506565 -> -0 +xmul414 multiply 737622.974 -241560693E+249506565 -> -1.78180717E+249506579 Inexact Rounded +xpow414 power 737622.974 -2 -> 1.83793916E-12 Inexact Rounded +xrem414 remainder 737622.974 -241560693E+249506565 -> 737622.974 +xsub414 subtract 737622.974 -241560693E+249506565 -> 2.41560693E+249506573 Inexact Rounded +xadd415 add 5615373.52 -7.27583808E-949781048 -> 5615373.52 Inexact Rounded +xcom415 compare 5615373.52 -7.27583808E-949781048 -> 1 +xdiv415 divide 5615373.52 -7.27583808E-949781048 -> -7.71783739E+949781053 Inexact Rounded +xdvi415 divideint 5615373.52 -7.27583808E-949781048 -> NaN Division_impossible +xmul415 multiply 5615373.52 -7.27583808E-949781048 -> -4.08565485E-949781041 Inexact Rounded +xpow415 power 5615373.52 -7 -> 5.68001460E-48 Inexact Rounded +xrem415 remainder 5615373.52 -7.27583808E-949781048 -> NaN Division_impossible +xsub415 subtract 5615373.52 -7.27583808E-949781048 -> 5615373.52 Inexact Rounded +xadd416 add 644136.179 -835708.103 -> -191571.924 +xcom416 compare 644136.179 -835708.103 -> 1 +xdiv416 divide 644136.179 -835708.103 -> -0.770766942 Inexact Rounded +xdvi416 divideint 644136.179 -835708.103 -> -0 +xmul416 multiply 644136.179 -835708.103 -> -5.38309824E+11 Inexact Rounded +xpow416 power 644136.179 -835708 -> 7.41936858E-4854610 Inexact Rounded +xrem416 remainder 644136.179 -835708.103 -> 644136.179 +xsub416 subtract 644136.179 -835708.103 -> 1479844.28 Inexact Rounded +xadd417 add -307.419521E+466861843 -738689976.E-199032711 -> -3.07419521E+466861845 Inexact Rounded +xcom417 compare -307.419521E+466861843 -738689976.E-199032711 -> -1 +xdiv417 divide -307.419521E+466861843 -738689976.E-199032711 -> 4.16168529E+665894547 Inexact Rounded +xdvi417 divideint -307.419521E+466861843 -738689976.E-199032711 -> NaN Division_impossible +xmul417 multiply -307.419521E+466861843 -738689976.E-199032711 -> 2.27087719E+267829143 Inexact Rounded +xpow417 power -307.419521E+466861843 -7 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem417 remainder -307.419521E+466861843 -738689976.E-199032711 -> NaN Division_impossible +xsub417 subtract -307.419521E+466861843 -738689976.E-199032711 -> -3.07419521E+466861845 Inexact Rounded +xadd418 add -619642.130 -226740537.E-902590153 -> -619642.130 Inexact Rounded +xcom418 compare -619642.130 -226740537.E-902590153 -> -1 +xdiv418 divide -619642.130 -226740537.E-902590153 -> 2.73282466E+902590150 Inexact Rounded +xdvi418 divideint -619642.130 -226740537.E-902590153 -> NaN Division_impossible +xmul418 multiply -619642.130 -226740537.E-902590153 -> 1.40497989E-902590139 Inexact Rounded +xpow418 power -619642.130 -2 -> 2.60446259E-12 Inexact Rounded +xrem418 remainder -619642.130 -226740537.E-902590153 -> NaN Division_impossible +xsub418 subtract -619642.130 -226740537.E-902590153 -> -619642.130 Inexact Rounded +xadd419 add -31068.7549 -3.41495042E+86001379 -> -3.41495042E+86001379 Inexact Rounded +xcom419 compare -31068.7549 -3.41495042E+86001379 -> 1 +xdiv419 divide -31068.7549 -3.41495042E+86001379 -> 9.09786412E-86001376 Inexact Rounded +xdvi419 divideint -31068.7549 -3.41495042E+86001379 -> 0 +xmul419 multiply -31068.7549 -3.41495042E+86001379 -> 1.06098258E+86001384 Inexact Rounded +xpow419 power -31068.7549 -3 -> -3.33448258E-14 Inexact Rounded +xrem419 remainder -31068.7549 -3.41495042E+86001379 -> -31068.7549 +xsub419 subtract -31068.7549 -3.41495042E+86001379 -> 3.41495042E+86001379 Inexact Rounded +xadd420 add -68951173. -211804977.E-97318126 -> -68951173.0 Inexact Rounded +xcom420 compare -68951173. -211804977.E-97318126 -> -1 +xdiv420 divide -68951173. -211804977.E-97318126 -> 3.25540854E+97318125 Inexact Rounded +xdvi420 divideint -68951173. -211804977.E-97318126 -> NaN Division_impossible +xmul420 multiply -68951173. -211804977.E-97318126 -> 1.46042016E-97318110 Inexact Rounded +xpow420 power -68951173. -2 -> 2.10337488E-16 Inexact Rounded +xrem420 remainder -68951173. -211804977.E-97318126 -> NaN Division_impossible +xsub420 subtract -68951173. -211804977.E-97318126 -> -68951173.0 Inexact Rounded +xadd421 add -4.09492571E-301749490 434.20199E-749390952 -> -4.09492571E-301749490 Inexact Rounded +xcom421 compare -4.09492571E-301749490 434.20199E-749390952 -> -1 +xdiv421 divide -4.09492571E-301749490 434.20199E-749390952 -> -9.43092341E+447641459 Inexact Rounded +xdvi421 divideint -4.09492571E-301749490 434.20199E-749390952 -> NaN Division_impossible +xmul421 multiply -4.09492571E-301749490 434.20199E-749390952 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow421 power -4.09492571E-301749490 4 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem421 remainder -4.09492571E-301749490 434.20199E-749390952 -> NaN Division_impossible +xsub421 subtract -4.09492571E-301749490 434.20199E-749390952 -> -4.09492571E-301749490 Inexact Rounded +xadd422 add 3898.03188 -82572.615 -> -78674.5831 Inexact Rounded +xcom422 compare 3898.03188 -82572.615 -> 1 +xdiv422 divide 3898.03188 -82572.615 -> -0.0472073202 Inexact Rounded +xdvi422 divideint 3898.03188 -82572.615 -> -0 +xmul422 multiply 3898.03188 -82572.615 -> -321870686 Inexact Rounded +xpow422 power 3898.03188 -82573 -> 1.33010737E-296507 Inexact Rounded +xrem422 remainder 3898.03188 -82572.615 -> 3898.03188 +xsub422 subtract 3898.03188 -82572.615 -> 86470.6469 Inexact Rounded +xadd423 add -1.7619356 -2546.64043 -> -2548.40237 Inexact Rounded +xcom423 compare -1.7619356 -2546.64043 -> 1 +xdiv423 divide -1.7619356 -2546.64043 -> 0.000691866657 Inexact Rounded +xdvi423 divideint -1.7619356 -2546.64043 -> 0 +xmul423 multiply -1.7619356 -2546.64043 -> 4487.01643 Inexact Rounded +xpow423 power -1.7619356 -2547 -> -2.90664557E-627 Inexact Rounded +xrem423 remainder -1.7619356 -2546.64043 -> -1.7619356 +xsub423 subtract -1.7619356 -2546.64043 -> 2544.87849 Inexact Rounded +xadd424 add 59714.1968 29734388.6E-564525525 -> 59714.1968 Inexact Rounded +xcom424 compare 59714.1968 29734388.6E-564525525 -> 1 +xdiv424 divide 59714.1968 29734388.6E-564525525 -> 2.00825373E+564525522 Inexact Rounded +xdvi424 divideint 59714.1968 29734388.6E-564525525 -> NaN Division_impossible +xmul424 multiply 59714.1968 29734388.6E-564525525 -> 1.77556513E-564525513 Inexact Rounded +xpow424 power 59714.1968 3 -> 2.12928005E+14 Inexact Rounded +xrem424 remainder 59714.1968 29734388.6E-564525525 -> NaN Division_impossible +xsub424 subtract 59714.1968 29734388.6E-564525525 -> 59714.1968 Inexact Rounded +xadd425 add 6.88891136E-935467395 -785049.562E-741671442 -> -7.85049562E-741671437 Inexact Rounded +xcom425 compare 6.88891136E-935467395 -785049.562E-741671442 -> 1 +xdiv425 divide 6.88891136E-935467395 -785049.562E-741671442 -> -8.77512923E-193795959 Inexact Rounded +xdvi425 divideint 6.88891136E-935467395 -785049.562E-741671442 -> -0 +xmul425 multiply 6.88891136E-935467395 -785049.562E-741671442 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow425 power 6.88891136E-935467395 -8 -> Infinity Overflow Inexact Rounded +xrem425 remainder 6.88891136E-935467395 -785049.562E-741671442 -> 6.88891136E-935467395 +xsub425 subtract 6.88891136E-935467395 -785049.562E-741671442 -> 7.85049562E-741671437 Inexact Rounded +xadd426 add 975566251 -519.858530 -> 975565731 Inexact Rounded +xcom426 compare 975566251 -519.858530 -> 1 +xdiv426 divide 975566251 -519.858530 -> -1876599.49 Inexact Rounded +xdvi426 divideint 975566251 -519.858530 -> -1876599 +xmul426 multiply 975566251 -519.858530 -> -5.07156437E+11 Inexact Rounded +xpow426 power 975566251 -520 -> 3.85905300E-4675 Inexact Rounded +xrem426 remainder 975566251 -519.858530 -> 253.460530 +xsub426 subtract 975566251 -519.858530 -> 975566771 Inexact Rounded +xadd427 add 307401954 -231481582. -> 75920372 +xcom427 compare 307401954 -231481582. -> 1 +xdiv427 divide 307401954 -231481582. -> -1.32797586 Inexact Rounded +xdvi427 divideint 307401954 -231481582. -> -1 +xmul427 multiply 307401954 -231481582. -> -7.11578906E+16 Inexact Rounded +xpow427 power 307401954 -231481582 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem427 remainder 307401954 -231481582. -> 75920372 +xsub427 subtract 307401954 -231481582. -> 538883536 +xadd428 add 2237645.48E+992947388 -60618055.3E-857316706 -> 2.23764548E+992947394 Inexact Rounded +xcom428 compare 2237645.48E+992947388 -60618055.3E-857316706 -> 1 +xdiv428 divide 2237645.48E+992947388 -60618055.3E-857316706 -> -Infinity Inexact Overflow Rounded +xdvi428 divideint 2237645.48E+992947388 -60618055.3E-857316706 -> NaN Division_impossible +xmul428 multiply 2237645.48E+992947388 -60618055.3E-857316706 -> -1.35641717E+135630696 Inexact Rounded +xpow428 power 2237645.48E+992947388 -6 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem428 remainder 2237645.48E+992947388 -60618055.3E-857316706 -> NaN Division_impossible +xsub428 subtract 2237645.48E+992947388 -60618055.3E-857316706 -> 2.23764548E+992947394 Inexact Rounded +xadd429 add -403903.851 35.5049687E-72095155 -> -403903.851 Inexact Rounded +xcom429 compare -403903.851 35.5049687E-72095155 -> -1 +xdiv429 divide -403903.851 35.5049687E-72095155 -> -1.13759810E+72095159 Inexact Rounded +xdvi429 divideint -403903.851 35.5049687E-72095155 -> NaN Division_impossible +xmul429 multiply -403903.851 35.5049687E-72095155 -> -1.43405936E-72095148 Inexact Rounded +xpow429 power -403903.851 4 -> 2.66141117E+22 Inexact Rounded +xrem429 remainder -403903.851 35.5049687E-72095155 -> NaN Division_impossible +xsub429 subtract -403903.851 35.5049687E-72095155 -> -403903.851 Inexact Rounded +xadd430 add 6.48674979 -621732.532E+422575800 -> -6.21732532E+422575805 Inexact Rounded +xcom430 compare 6.48674979 -621732.532E+422575800 -> 1 +xdiv430 divide 6.48674979 -621732.532E+422575800 -> -1.04333447E-422575805 Inexact Rounded +xdvi430 divideint 6.48674979 -621732.532E+422575800 -> -0 +xmul430 multiply 6.48674979 -621732.532E+422575800 -> -4.03302337E+422575806 Inexact Rounded +xpow430 power 6.48674979 -6 -> 0.0000134226146 Inexact Rounded +xrem430 remainder 6.48674979 -621732.532E+422575800 -> 6.48674979 +xsub430 subtract 6.48674979 -621732.532E+422575800 -> 6.21732532E+422575805 Inexact Rounded +xadd431 add -31401.9418 36.3960679 -> -31365.5457 Inexact Rounded +xcom431 compare -31401.9418 36.3960679 -> -1 +xdiv431 divide -31401.9418 36.3960679 -> -862.783911 Inexact Rounded +xdvi431 divideint -31401.9418 36.3960679 -> -862 +xmul431 multiply -31401.9418 36.3960679 -> -1142907.21 Inexact Rounded +xpow431 power -31401.9418 36 -> 7.77023505E+161 Inexact Rounded +xrem431 remainder -31401.9418 36.3960679 -> -28.5312702 +xsub431 subtract -31401.9418 36.3960679 -> -31438.3379 Inexact Rounded +xadd432 add 31345321.1 51.5482191 -> 31345372.6 Inexact Rounded +xcom432 compare 31345321.1 51.5482191 -> 1 +xdiv432 divide 31345321.1 51.5482191 -> 608077.673 Inexact Rounded +xdvi432 divideint 31345321.1 51.5482191 -> 608077 +xmul432 multiply 31345321.1 51.5482191 -> 1.61579548E+9 Inexact Rounded +xpow432 power 31345321.1 52 -> 6.32385059E+389 Inexact Rounded +xrem432 remainder 31345321.1 51.5482191 -> 34.6743293 +xsub432 subtract 31345321.1 51.5482191 -> 31345269.6 Inexact Rounded +xadd433 add -64.172844 -28506227.2E-767965800 -> -64.1728440 Inexact Rounded +xcom433 compare -64.172844 -28506227.2E-767965800 -> -1 +xdiv433 divide -64.172844 -28506227.2E-767965800 -> 2.25118686E+767965794 Inexact Rounded +xdvi433 divideint -64.172844 -28506227.2E-767965800 -> NaN Division_impossible +xmul433 multiply -64.172844 -28506227.2E-767965800 -> 1.82932567E-767965791 Inexact Rounded +xpow433 power -64.172844 -3 -> -0.00000378395654 Inexact Rounded +xrem433 remainder -64.172844 -28506227.2E-767965800 -> NaN Division_impossible +xsub433 subtract -64.172844 -28506227.2E-767965800 -> -64.1728440 Inexact Rounded +xadd434 add 70437.1551 -62916.1233 -> 7521.0318 +xcom434 compare 70437.1551 -62916.1233 -> 1 +xdiv434 divide 70437.1551 -62916.1233 -> -1.11954061 Inexact Rounded +xdvi434 divideint 70437.1551 -62916.1233 -> -1 +xmul434 multiply 70437.1551 -62916.1233 -> -4.43163274E+9 Inexact Rounded +xpow434 power 70437.1551 -62916 -> 5.02945060E-305005 Inexact Rounded +xrem434 remainder 70437.1551 -62916.1233 -> 7521.0318 +xsub434 subtract 70437.1551 -62916.1233 -> 133353.278 Inexact Rounded +xadd435 add 916260164 -58.4017325 -> 916260106 Inexact Rounded +xcom435 compare 916260164 -58.4017325 -> 1 +xdiv435 divide 916260164 -58.4017325 -> -15688920.9 Inexact Rounded +xdvi435 divideint 916260164 -58.4017325 -> -15688920 +xmul435 multiply 916260164 -58.4017325 -> -5.35111810E+10 Inexact Rounded +xpow435 power 916260164 -58 -> 1.59554587E-520 Inexact Rounded +xrem435 remainder 916260164 -58.4017325 -> 54.9461000 +xsub435 subtract 916260164 -58.4017325 -> 916260222 Inexact Rounded +xadd436 add 19889085.3E-46816480 1581683.94 -> 1581683.94 Inexact Rounded +xcom436 compare 19889085.3E-46816480 1581683.94 -> -1 +xdiv436 divide 19889085.3E-46816480 1581683.94 -> 1.25746268E-46816479 Inexact Rounded +xdvi436 divideint 19889085.3E-46816480 1581683.94 -> 0 +xmul436 multiply 19889085.3E-46816480 1581683.94 -> 3.14582468E-46816467 Inexact Rounded +xpow436 power 19889085.3E-46816480 1581684 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem436 remainder 19889085.3E-46816480 1581683.94 -> 1.98890853E-46816473 +xsub436 subtract 19889085.3E-46816480 1581683.94 -> -1581683.94 Inexact Rounded +xadd437 add -56312.3383 789.466064 -> -55522.8722 Inexact Rounded +xcom437 compare -56312.3383 789.466064 -> -1 +xdiv437 divide -56312.3383 789.466064 -> -71.3296503 Inexact Rounded +xdvi437 divideint -56312.3383 789.466064 -> -71 +xmul437 multiply -56312.3383 789.466064 -> -44456680.1 Inexact Rounded +xpow437 power -56312.3383 789 -> -1.68348724E+3748 Inexact Rounded +xrem437 remainder -56312.3383 789.466064 -> -260.247756 +xsub437 subtract -56312.3383 789.466064 -> -57101.8044 Inexact Rounded +xadd438 add 183442.849 -925876106 -> -925692663 Inexact Rounded +xcom438 compare 183442.849 -925876106 -> 1 +xdiv438 divide 183442.849 -925876106 -> -0.000198128937 Inexact Rounded +xdvi438 divideint 183442.849 -925876106 -> -0 +xmul438 multiply 183442.849 -925876106 -> -1.69845351E+14 Inexact Rounded +xpow438 power 183442.849 -925876106 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem438 remainder 183442.849 -925876106 -> 183442.849 +xsub438 subtract 183442.849 -925876106 -> 926059549 Inexact Rounded +xadd439 add 971113.655E-695540249 -419351120E-977743823 -> 9.71113655E-695540244 Inexact Rounded +xcom439 compare 971113.655E-695540249 -419351120E-977743823 -> 1 +xdiv439 divide 971113.655E-695540249 -419351120E-977743823 -> -2.31575310E+282203571 Inexact Rounded +xdvi439 divideint 971113.655E-695540249 -419351120E-977743823 -> NaN Division_impossible +xmul439 multiply 971113.655E-695540249 -419351120E-977743823 -> -0E-1000000007 Underflow Subnormal Inexact Rounded +xpow439 power 971113.655E-695540249 -4 -> Infinity Overflow Inexact Rounded +xrem439 remainder 971113.655E-695540249 -419351120E-977743823 -> NaN Division_impossible +xsub439 subtract 971113.655E-695540249 -419351120E-977743823 -> 9.71113655E-695540244 Inexact Rounded +xadd440 add 859658551. 72338.2054 -> 859730889 Inexact Rounded +xcom440 compare 859658551. 72338.2054 -> 1 +xdiv440 divide 859658551. 72338.2054 -> 11883.8800 Inexact Rounded +xdvi440 divideint 859658551. 72338.2054 -> 11883 +xmul440 multiply 859658551. 72338.2054 -> 6.21861568E+13 Inexact Rounded +xpow440 power 859658551. 72338 -> 1.87620450E+646291 Inexact Rounded +xrem440 remainder 859658551. 72338.2054 -> 63656.2318 +xsub440 subtract 859658551. 72338.2054 -> 859586213 Inexact Rounded +xadd441 add -3.86446630E+426816068 -664.534737 -> -3.86446630E+426816068 Inexact Rounded +xcom441 compare -3.86446630E+426816068 -664.534737 -> -1 +xdiv441 divide -3.86446630E+426816068 -664.534737 -> 5.81529615E+426816065 Inexact Rounded +xdvi441 divideint -3.86446630E+426816068 -664.534737 -> NaN Division_impossible +xmul441 multiply -3.86446630E+426816068 -664.534737 -> 2.56807210E+426816071 Inexact Rounded +xpow441 power -3.86446630E+426816068 -665 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem441 remainder -3.86446630E+426816068 -664.534737 -> NaN Division_impossible +xsub441 subtract -3.86446630E+426816068 -664.534737 -> -3.86446630E+426816068 Inexact Rounded +xadd442 add -969.881818 31170.8555 -> 30200.9737 Inexact Rounded +xcom442 compare -969.881818 31170.8555 -> -1 +xdiv442 divide -969.881818 31170.8555 -> -0.0311150208 Inexact Rounded +xdvi442 divideint -969.881818 31170.8555 -> -0 +xmul442 multiply -969.881818 31170.8555 -> -30232046.0 Inexact Rounded +xpow442 power -969.881818 31171 -> -1.02865894E+93099 Inexact Rounded +xrem442 remainder -969.881818 31170.8555 -> -969.881818 +xsub442 subtract -969.881818 31170.8555 -> -32140.7373 Inexact Rounded +xadd443 add 7980537.27 85.4040512 -> 7980622.67 Inexact Rounded +xcom443 compare 7980537.27 85.4040512 -> 1 +xdiv443 divide 7980537.27 85.4040512 -> 93444.4814 Inexact Rounded +xdvi443 divideint 7980537.27 85.4040512 -> 93444 +xmul443 multiply 7980537.27 85.4040512 -> 681570214 Inexact Rounded +xpow443 power 7980537.27 85 -> 4.70685763E+586 Inexact Rounded +xrem443 remainder 7980537.27 85.4040512 -> 41.1096672 +xsub443 subtract 7980537.27 85.4040512 -> 7980451.87 Inexact Rounded +xadd444 add -114609916. 7525.14981 -> -114602391 Inexact Rounded +xcom444 compare -114609916. 7525.14981 -> -1 +xdiv444 divide -114609916. 7525.14981 -> -15230.2504 Inexact Rounded +xdvi444 divideint -114609916. 7525.14981 -> -15230 +xmul444 multiply -114609916. 7525.14981 -> -8.62456788E+11 Inexact Rounded +xpow444 power -114609916. 7525 -> -4.43620445E+60645 Inexact Rounded +xrem444 remainder -114609916. 7525.14981 -> -1884.39370 +xsub444 subtract -114609916. 7525.14981 -> -114617441 Inexact Rounded +xadd445 add 8.43404682E-500572568 474526719 -> 474526719 Inexact Rounded +xcom445 compare 8.43404682E-500572568 474526719 -> -1 +xdiv445 divide 8.43404682E-500572568 474526719 -> 1.77735973E-500572576 Inexact Rounded +xdvi445 divideint 8.43404682E-500572568 474526719 -> 0 +xmul445 multiply 8.43404682E-500572568 474526719 -> 4.00218057E-500572559 Inexact Rounded +xpow445 power 8.43404682E-500572568 474526719 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem445 remainder 8.43404682E-500572568 474526719 -> 8.43404682E-500572568 +xsub445 subtract 8.43404682E-500572568 474526719 -> -474526719 Inexact Rounded +xadd446 add 188006433 2260.17037E-978192525 -> 188006433 Inexact Rounded +xcom446 compare 188006433 2260.17037E-978192525 -> 1 +xdiv446 divide 188006433 2260.17037E-978192525 -> 8.31824165E+978192529 Inexact Rounded +xdvi446 divideint 188006433 2260.17037E-978192525 -> NaN Division_impossible +xmul446 multiply 188006433 2260.17037E-978192525 -> 4.24926569E-978192514 Inexact Rounded +xpow446 power 188006433 2 -> 3.53464188E+16 Inexact Rounded +xrem446 remainder 188006433 2260.17037E-978192525 -> NaN Division_impossible +xsub446 subtract 188006433 2260.17037E-978192525 -> 188006433 Inexact Rounded +xadd447 add -9.95836312 -866466703 -> -866466713 Inexact Rounded +xcom447 compare -9.95836312 -866466703 -> 1 +xdiv447 divide -9.95836312 -866466703 -> 1.14930707E-8 Inexact Rounded +xdvi447 divideint -9.95836312 -866466703 -> 0 +xmul447 multiply -9.95836312 -866466703 -> 8.62859006E+9 Inexact Rounded +xpow447 power -9.95836312 -866466703 -> -6.71744368E-864896630 Inexact Rounded +xrem447 remainder -9.95836312 -866466703 -> -9.95836312 +xsub447 subtract -9.95836312 -866466703 -> 866466693 Inexact Rounded +xadd448 add 80919339.2E-967231586 219.824266 -> 219.824266 Inexact Rounded +xcom448 compare 80919339.2E-967231586 219.824266 -> -1 +xdiv448 divide 80919339.2E-967231586 219.824266 -> 3.68109220E-967231581 Inexact Rounded +xdvi448 divideint 80919339.2E-967231586 219.824266 -> 0 +xmul448 multiply 80919339.2E-967231586 219.824266 -> 1.77880343E-967231576 Inexact Rounded +xpow448 power 80919339.2E-967231586 220 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem448 remainder 80919339.2E-967231586 219.824266 -> 8.09193392E-967231579 +xsub448 subtract 80919339.2E-967231586 219.824266 -> -219.824266 Inexact Rounded +xadd449 add 159579.444 -89827.5229 -> 69751.9211 +xcom449 compare 159579.444 -89827.5229 -> 1 +xdiv449 divide 159579.444 -89827.5229 -> -1.77650946 Inexact Rounded +xdvi449 divideint 159579.444 -89827.5229 -> -1 +xmul449 multiply 159579.444 -89827.5229 -> -1.43346262E+10 Inexact Rounded +xpow449 power 159579.444 -89828 -> 9.69955849E-467374 Inexact Rounded +xrem449 remainder 159579.444 -89827.5229 -> 69751.9211 +xsub449 subtract 159579.444 -89827.5229 -> 249406.967 Inexact Rounded +xadd450 add -4.54000153 6966333.74 -> 6966329.20 Inexact Rounded +xcom450 compare -4.54000153 6966333.74 -> -1 +xdiv450 divide -4.54000153 6966333.74 -> -6.51706005E-7 Inexact Rounded +xdvi450 divideint -4.54000153 6966333.74 -> -0 +xmul450 multiply -4.54000153 6966333.74 -> -31627165.8 Inexact Rounded +xpow450 power -4.54000153 6966334 -> 3.52568913E+4577271 Inexact Rounded +xrem450 remainder -4.54000153 6966333.74 -> -4.54000153 +xsub450 subtract -4.54000153 6966333.74 -> -6966338.28 Inexact Rounded +xadd451 add 28701538.7E-391015649 -920999192. -> -920999192 Inexact Rounded +xcom451 compare 28701538.7E-391015649 -920999192. -> 1 +xdiv451 divide 28701538.7E-391015649 -920999192. -> -3.11634787E-391015651 Inexact Rounded +xdvi451 divideint 28701538.7E-391015649 -920999192. -> -0 +xmul451 multiply 28701538.7E-391015649 -920999192. -> -2.64340940E-391015633 Inexact Rounded +xpow451 power 28701538.7E-391015649 -920999192 -> Infinity Overflow Inexact Rounded +xrem451 remainder 28701538.7E-391015649 -920999192. -> 2.87015387E-391015642 +xsub451 subtract 28701538.7E-391015649 -920999192. -> 920999192 Inexact Rounded +xadd452 add -361382575. -7976.15286E+898491169 -> -7.97615286E+898491172 Inexact Rounded +xcom452 compare -361382575. -7976.15286E+898491169 -> 1 +xdiv452 divide -361382575. -7976.15286E+898491169 -> 4.53078798E-898491165 Inexact Rounded +xdvi452 divideint -361382575. -7976.15286E+898491169 -> 0 +xmul452 multiply -361382575. -7976.15286E+898491169 -> 2.88244266E+898491181 Inexact Rounded +xpow452 power -361382575. -8 -> 3.43765536E-69 Inexact Rounded +xrem452 remainder -361382575. -7976.15286E+898491169 -> -361382575 +xsub452 subtract -361382575. -7976.15286E+898491169 -> 7.97615286E+898491172 Inexact Rounded +xadd453 add 7021805.61 1222952.83 -> 8244758.44 +xcom453 compare 7021805.61 1222952.83 -> 1 +xdiv453 divide 7021805.61 1222952.83 -> 5.74168148 Inexact Rounded +xdvi453 divideint 7021805.61 1222952.83 -> 5 +xmul453 multiply 7021805.61 1222952.83 -> 8.58733704E+12 Inexact Rounded +xpow453 power 7021805.61 1222953 -> 1.26540553E+8372885 Inexact Rounded +xrem453 remainder 7021805.61 1222952.83 -> 907041.46 +xsub453 subtract 7021805.61 1222952.83 -> 5798852.78 +xadd454 add -40.4811667 -79655.5635 -> -79696.0447 Inexact Rounded +xcom454 compare -40.4811667 -79655.5635 -> 1 +xdiv454 divide -40.4811667 -79655.5635 -> 0.000508202628 Inexact Rounded +xdvi454 divideint -40.4811667 -79655.5635 -> 0 +xmul454 multiply -40.4811667 -79655.5635 -> 3224550.14 Inexact Rounded +xpow454 power -40.4811667 -79656 -> 4.50174275E-128028 Inexact Rounded +xrem454 remainder -40.4811667 -79655.5635 -> -40.4811667 +xsub454 subtract -40.4811667 -79655.5635 -> 79615.0823 Inexact Rounded +xadd455 add -8755674.38E+117168177 148.903404 -> -8.75567438E+117168183 Inexact Rounded +xcom455 compare -8755674.38E+117168177 148.903404 -> -1 +xdiv455 divide -8755674.38E+117168177 148.903404 -> -5.88010357E+117168181 Inexact Rounded +xdvi455 divideint -8755674.38E+117168177 148.903404 -> NaN Division_impossible +xmul455 multiply -8755674.38E+117168177 148.903404 -> -1.30374972E+117168186 Inexact Rounded +xpow455 power -8755674.38E+117168177 149 -> -Infinity Overflow Inexact Rounded +xrem455 remainder -8755674.38E+117168177 148.903404 -> NaN Division_impossible +xsub455 subtract -8755674.38E+117168177 148.903404 -> -8.75567438E+117168183 Inexact Rounded +xadd456 add 34.5329781E+382829392 -45.2177309 -> 3.45329781E+382829393 Inexact Rounded +xcom456 compare 34.5329781E+382829392 -45.2177309 -> 1 +xdiv456 divide 34.5329781E+382829392 -45.2177309 -> -7.63704357E+382829391 Inexact Rounded +xdvi456 divideint 34.5329781E+382829392 -45.2177309 -> NaN Division_impossible +xmul456 multiply 34.5329781E+382829392 -45.2177309 -> -1.56150291E+382829395 Inexact Rounded +xpow456 power 34.5329781E+382829392 -45 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem456 remainder 34.5329781E+382829392 -45.2177309 -> NaN Division_impossible +xsub456 subtract 34.5329781E+382829392 -45.2177309 -> 3.45329781E+382829393 Inexact Rounded +xadd457 add -37958476.0 584367.935 -> -37374108.1 Inexact Rounded +xcom457 compare -37958476.0 584367.935 -> -1 +xdiv457 divide -37958476.0 584367.935 -> -64.9564662 Inexact Rounded +xdvi457 divideint -37958476.0 584367.935 -> -64 +xmul457 multiply -37958476.0 584367.935 -> -2.21817162E+13 Inexact Rounded +xpow457 power -37958476.0 584368 -> 3.20538268E+4429105 Inexact Rounded +xrem457 remainder -37958476.0 584367.935 -> -558928.160 +xsub457 subtract -37958476.0 584367.935 -> -38542843.9 Inexact Rounded +xadd458 add 495233.553E-414152215 62352759.2 -> 62352759.2 Inexact Rounded +xcom458 compare 495233.553E-414152215 62352759.2 -> -1 +xdiv458 divide 495233.553E-414152215 62352759.2 -> 7.94244809E-414152218 Inexact Rounded +xdvi458 divideint 495233.553E-414152215 62352759.2 -> 0 +xmul458 multiply 495233.553E-414152215 62352759.2 -> 3.08791785E-414152202 Inexact Rounded +xpow458 power 495233.553E-414152215 62352759 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem458 remainder 495233.553E-414152215 62352759.2 -> 4.95233553E-414152210 +xsub458 subtract 495233.553E-414152215 62352759.2 -> -62352759.2 Inexact Rounded +xadd459 add -502343060 -96828.994 -> -502439889 Inexact Rounded +xcom459 compare -502343060 -96828.994 -> -1 +xdiv459 divide -502343060 -96828.994 -> 5187.94050 Inexact Rounded +xdvi459 divideint -502343060 -96828.994 -> 5187 +xmul459 multiply -502343060 -96828.994 -> 4.86413731E+13 Inexact Rounded +xpow459 power -502343060 -96829 -> -6.78602119E-842510 Inexact Rounded +xrem459 remainder -502343060 -96828.994 -> -91068.122 +xsub459 subtract -502343060 -96828.994 -> -502246231 Inexact Rounded +xadd460 add -22.439639E+916362878 -39.4037681 -> -2.24396390E+916362879 Inexact Rounded +xcom460 compare -22.439639E+916362878 -39.4037681 -> -1 +xdiv460 divide -22.439639E+916362878 -39.4037681 -> 5.69479521E+916362877 Inexact Rounded +xdvi460 divideint -22.439639E+916362878 -39.4037681 -> NaN Division_impossible +xmul460 multiply -22.439639E+916362878 -39.4037681 -> 8.84206331E+916362880 Inexact Rounded +xpow460 power -22.439639E+916362878 -39 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem460 remainder -22.439639E+916362878 -39.4037681 -> NaN Division_impossible +xsub460 subtract -22.439639E+916362878 -39.4037681 -> -2.24396390E+916362879 Inexact Rounded +xadd461 add 718180.587E-957473722 1.66223443 -> 1.66223443 Inexact Rounded +xcom461 compare 718180.587E-957473722 1.66223443 -> -1 +xdiv461 divide 718180.587E-957473722 1.66223443 -> 4.32057340E-957473717 Inexact Rounded +xdvi461 divideint 718180.587E-957473722 1.66223443 -> 0 +xmul461 multiply 718180.587E-957473722 1.66223443 -> 1.19378450E-957473716 Inexact Rounded +xpow461 power 718180.587E-957473722 2 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem461 remainder 718180.587E-957473722 1.66223443 -> 7.18180587E-957473717 +xsub461 subtract 718180.587E-957473722 1.66223443 -> -1.66223443 Inexact Rounded +xadd462 add -51592.2698 -713885.741 -> -765478.011 Inexact Rounded +xcom462 compare -51592.2698 -713885.741 -> 1 +xdiv462 divide -51592.2698 -713885.741 -> 0.0722696460 Inexact Rounded +xdvi462 divideint -51592.2698 -713885.741 -> 0 +xmul462 multiply -51592.2698 -713885.741 -> 3.68309858E+10 Inexact Rounded +xpow462 power -51592.2698 -713886 -> 6.38576921E-3364249 Inexact Rounded +xrem462 remainder -51592.2698 -713885.741 -> -51592.2698 +xsub462 subtract -51592.2698 -713885.741 -> 662293.471 Inexact Rounded +xadd463 add 51.2279848E+80439745 207.55925E+865165070 -> 2.07559250E+865165072 Inexact Rounded +xcom463 compare 51.2279848E+80439745 207.55925E+865165070 -> -1 +xdiv463 divide 51.2279848E+80439745 207.55925E+865165070 -> 2.46811379E-784725326 Inexact Rounded +xdvi463 divideint 51.2279848E+80439745 207.55925E+865165070 -> 0 +xmul463 multiply 51.2279848E+80439745 207.55925E+865165070 -> 1.06328421E+945604819 Inexact Rounded +xpow463 power 51.2279848E+80439745 2 -> 2.62430643E+160879493 Inexact Rounded +xrem463 remainder 51.2279848E+80439745 207.55925E+865165070 -> 5.12279848E+80439746 +xsub463 subtract 51.2279848E+80439745 207.55925E+865165070 -> -2.07559250E+865165072 Inexact Rounded +xadd464 add -5983.23468 -39.9544513 -> -6023.18913 Inexact Rounded +xcom464 compare -5983.23468 -39.9544513 -> -1 +xdiv464 divide -5983.23468 -39.9544513 -> 149.751392 Inexact Rounded +xdvi464 divideint -5983.23468 -39.9544513 -> 149 +xmul464 multiply -5983.23468 -39.9544513 -> 239056.859 Inexact Rounded +xpow464 power -5983.23468 -40 -> 8.36678291E-152 Inexact Rounded +xrem464 remainder -5983.23468 -39.9544513 -> -30.0214363 +xsub464 subtract -5983.23468 -39.9544513 -> -5943.28023 Inexact Rounded +xadd465 add 921639332.E-917542963 287325.891 -> 287325.891 Inexact Rounded +xcom465 compare 921639332.E-917542963 287325.891 -> -1 +xdiv465 divide 921639332.E-917542963 287325.891 -> 3.20764456E-917542960 Inexact Rounded +xdvi465 divideint 921639332.E-917542963 287325.891 -> 0 +xmul465 multiply 921639332.E-917542963 287325.891 -> 2.64810842E-917542949 Inexact Rounded +xpow465 power 921639332.E-917542963 287326 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem465 remainder 921639332.E-917542963 287325.891 -> 9.21639332E-917542955 +xsub465 subtract 921639332.E-917542963 287325.891 -> -287325.891 Inexact Rounded +xadd466 add 91095916.8E-787312969 -58643.418E+58189880 -> -5.86434180E+58189884 Inexact Rounded +xcom466 compare 91095916.8E-787312969 -58643.418E+58189880 -> 1 +xdiv466 divide 91095916.8E-787312969 -58643.418E+58189880 -> -1.55338689E-845502846 Inexact Rounded +xdvi466 divideint 91095916.8E-787312969 -58643.418E+58189880 -> -0 +xmul466 multiply 91095916.8E-787312969 -58643.418E+58189880 -> -5.34217593E-729123077 Inexact Rounded +xpow466 power 91095916.8E-787312969 -6 -> Infinity Overflow Inexact Rounded +xrem466 remainder 91095916.8E-787312969 -58643.418E+58189880 -> 9.10959168E-787312962 +xsub466 subtract 91095916.8E-787312969 -58643.418E+58189880 -> 5.86434180E+58189884 Inexact Rounded +xadd467 add -6410.5555 -234964259 -> -234970670 Inexact Rounded +xcom467 compare -6410.5555 -234964259 -> 1 +xdiv467 divide -6410.5555 -234964259 -> 0.0000272831090 Inexact Rounded +xdvi467 divideint -6410.5555 -234964259 -> 0 +xmul467 multiply -6410.5555 -234964259 -> 1.50625142E+12 Inexact Rounded +xpow467 power -6410.5555 -234964259 -> -1.27064467E-894484419 Inexact Rounded +xrem467 remainder -6410.5555 -234964259 -> -6410.5555 +xsub467 subtract -6410.5555 -234964259 -> 234957848 Inexact Rounded +xadd468 add -5.32711606 -8447286.21 -> -8447291.54 Inexact Rounded +xcom468 compare -5.32711606 -8447286.21 -> 1 +xdiv468 divide -5.32711606 -8447286.21 -> 6.30630468E-7 Inexact Rounded +xdvi468 divideint -5.32711606 -8447286.21 -> 0 +xmul468 multiply -5.32711606 -8447286.21 -> 44999674.0 Inexact Rounded +xpow468 power -5.32711606 -8447286 -> 9.09138729E-6136888 Inexact Rounded +xrem468 remainder -5.32711606 -8447286.21 -> -5.32711606 +xsub468 subtract -5.32711606 -8447286.21 -> 8447280.88 Inexact Rounded +xadd469 add -82272171.8 -776.238587E-372690416 -> -82272171.8 Inexact Rounded +xcom469 compare -82272171.8 -776.238587E-372690416 -> -1 +xdiv469 divide -82272171.8 -776.238587E-372690416 -> 1.05988253E+372690421 Inexact Rounded +xdvi469 divideint -82272171.8 -776.238587E-372690416 -> NaN Division_impossible +xmul469 multiply -82272171.8 -776.238587E-372690416 -> 6.38628344E-372690406 Inexact Rounded +xpow469 power -82272171.8 -8 -> 4.76404994E-64 Inexact Rounded +xrem469 remainder -82272171.8 -776.238587E-372690416 -> NaN Division_impossible +xsub469 subtract -82272171.8 -776.238587E-372690416 -> -82272171.8 Inexact Rounded +xadd470 add 412411244.E-774339264 866452.465 -> 866452.465 Inexact Rounded +xcom470 compare 412411244.E-774339264 866452.465 -> -1 +xdiv470 divide 412411244.E-774339264 866452.465 -> 4.75976768E-774339262 Inexact Rounded +xdvi470 divideint 412411244.E-774339264 866452.465 -> 0 +xmul470 multiply 412411244.E-774339264 866452.465 -> 3.57334739E-774339250 Inexact Rounded +xpow470 power 412411244.E-774339264 866452 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem470 remainder 412411244.E-774339264 866452.465 -> 4.12411244E-774339256 +xsub470 subtract 412411244.E-774339264 866452.465 -> -866452.465 Inexact Rounded +xadd471 add -103.474598 -3.01660661E-446661257 -> -103.474598 Inexact Rounded +xcom471 compare -103.474598 -3.01660661E-446661257 -> -1 +xdiv471 divide -103.474598 -3.01660661E-446661257 -> 3.43016546E+446661258 Inexact Rounded +xdvi471 divideint -103.474598 -3.01660661E-446661257 -> NaN Division_impossible +xmul471 multiply -103.474598 -3.01660661E-446661257 -> 3.12142156E-446661255 Inexact Rounded +xpow471 power -103.474598 -3 -> -9.02607123E-7 Inexact Rounded +xrem471 remainder -103.474598 -3.01660661E-446661257 -> NaN Division_impossible +xsub471 subtract -103.474598 -3.01660661E-446661257 -> -103.474598 Inexact Rounded +xadd472 add -31027.8323 -475378186. -> -475409214 Inexact Rounded +xcom472 compare -31027.8323 -475378186. -> 1 +xdiv472 divide -31027.8323 -475378186. -> 0.0000652697856 Inexact Rounded +xdvi472 divideint -31027.8323 -475378186. -> 0 +xmul472 multiply -31027.8323 -475378186. -> 1.47499546E+13 Inexact Rounded +xpow472 power -31027.8323 -475378186 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem472 remainder -31027.8323 -475378186. -> -31027.8323 +xsub472 subtract -31027.8323 -475378186. -> 475347158 Inexact Rounded +xadd473 add -1199339.72 -5.73068392E+53774632 -> -5.73068392E+53774632 Inexact Rounded +xcom473 compare -1199339.72 -5.73068392E+53774632 -> 1 +xdiv473 divide -1199339.72 -5.73068392E+53774632 -> 2.09283872E-53774627 Inexact Rounded +xdvi473 divideint -1199339.72 -5.73068392E+53774632 -> 0 +xmul473 multiply -1199339.72 -5.73068392E+53774632 -> 6.87303685E+53774638 Inexact Rounded +xpow473 power -1199339.72 -6 -> 3.36005741E-37 Inexact Rounded +xrem473 remainder -1199339.72 -5.73068392E+53774632 -> -1199339.72 +xsub473 subtract -1199339.72 -5.73068392E+53774632 -> 5.73068392E+53774632 Inexact Rounded +xadd474 add -732908.930E+364345433 -3486146.26 -> -7.32908930E+364345438 Inexact Rounded +xcom474 compare -732908.930E+364345433 -3486146.26 -> -1 +xdiv474 divide -732908.930E+364345433 -3486146.26 -> 2.10234705E+364345432 Inexact Rounded +xdvi474 divideint -732908.930E+364345433 -3486146.26 -> NaN Division_impossible +xmul474 multiply -732908.930E+364345433 -3486146.26 -> 2.55502773E+364345445 Inexact Rounded +xpow474 power -732908.930E+364345433 -3486146 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem474 remainder -732908.930E+364345433 -3486146.26 -> NaN Division_impossible +xsub474 subtract -732908.930E+364345433 -3486146.26 -> -7.32908930E+364345438 Inexact Rounded +xadd475 add -2376150.83 -46777583.3 -> -49153734.1 Inexact Rounded +xcom475 compare -2376150.83 -46777583.3 -> 1 +xdiv475 divide -2376150.83 -46777583.3 -> 0.0507967847 Inexact Rounded +xdvi475 divideint -2376150.83 -46777583.3 -> 0 +xmul475 multiply -2376150.83 -46777583.3 -> 1.11150593E+14 Inexact Rounded +xpow475 power -2376150.83 -46777583 -> -3.51886193E-298247976 Inexact Rounded +xrem475 remainder -2376150.83 -46777583.3 -> -2376150.83 +xsub475 subtract -2376150.83 -46777583.3 -> 44401432.5 Inexact Rounded +xadd476 add 6.3664211 -140854908. -> -140854902 Inexact Rounded +xcom476 compare 6.3664211 -140854908. -> 1 +xdiv476 divide 6.3664211 -140854908. -> -4.51984328E-8 Inexact Rounded +xdvi476 divideint 6.3664211 -140854908. -> -0 +xmul476 multiply 6.3664211 -140854908. -> -896741658 Inexact Rounded +xpow476 power 6.3664211 -140854908 -> 7.25432803E-113232608 Inexact Rounded +xrem476 remainder 6.3664211 -140854908. -> 6.3664211 +xsub476 subtract 6.3664211 -140854908. -> 140854914 Inexact Rounded +xadd477 add -15.791522 1902.30210E+90741844 -> 1.90230210E+90741847 Inexact Rounded +xcom477 compare -15.791522 1902.30210E+90741844 -> -1 +xdiv477 divide -15.791522 1902.30210E+90741844 -> -8.30126929E-90741847 Inexact Rounded +xdvi477 divideint -15.791522 1902.30210E+90741844 -> -0 +xmul477 multiply -15.791522 1902.30210E+90741844 -> -3.00402455E+90741848 Inexact Rounded +xpow477 power -15.791522 2 -> 249.372167 Inexact Rounded +xrem477 remainder -15.791522 1902.30210E+90741844 -> -15.791522 +xsub477 subtract -15.791522 1902.30210E+90741844 -> -1.90230210E+90741847 Inexact Rounded +xadd478 add 15356.1505E+373950429 2.88020400 -> 1.53561505E+373950433 Inexact Rounded +xcom478 compare 15356.1505E+373950429 2.88020400 -> 1 +xdiv478 divide 15356.1505E+373950429 2.88020400 -> 5.33161905E+373950432 Inexact Rounded +xdvi478 divideint 15356.1505E+373950429 2.88020400 -> NaN Division_impossible +xmul478 multiply 15356.1505E+373950429 2.88020400 -> 4.42288461E+373950433 Inexact Rounded +xpow478 power 15356.1505E+373950429 3 -> Infinity Overflow Inexact Rounded +xrem478 remainder 15356.1505E+373950429 2.88020400 -> NaN Division_impossible +xsub478 subtract 15356.1505E+373950429 2.88020400 -> 1.53561505E+373950433 Inexact Rounded +xadd479 add -3.12001326E+318884762 9567.21595 -> -3.12001326E+318884762 Inexact Rounded +xcom479 compare -3.12001326E+318884762 9567.21595 -> -1 +xdiv479 divide -3.12001326E+318884762 9567.21595 -> -3.26115066E+318884758 Inexact Rounded +xdvi479 divideint -3.12001326E+318884762 9567.21595 -> NaN Division_impossible +xmul479 multiply -3.12001326E+318884762 9567.21595 -> -2.98498406E+318884766 Inexact Rounded +xpow479 power -3.12001326E+318884762 9567 -> -Infinity Overflow Inexact Rounded +xrem479 remainder -3.12001326E+318884762 9567.21595 -> NaN Division_impossible +xsub479 subtract -3.12001326E+318884762 9567.21595 -> -3.12001326E+318884762 Inexact Rounded +xadd480 add 49436.6528 751.919517 -> 50188.5723 Inexact Rounded +xcom480 compare 49436.6528 751.919517 -> 1 +xdiv480 divide 49436.6528 751.919517 -> 65.7472664 Inexact Rounded +xdvi480 divideint 49436.6528 751.919517 -> 65 +xmul480 multiply 49436.6528 751.919517 -> 37172384.1 Inexact Rounded +xpow480 power 49436.6528 752 -> 8.41185718E+3529 Inexact Rounded +xrem480 remainder 49436.6528 751.919517 -> 561.884195 +xsub480 subtract 49436.6528 751.919517 -> 48684.7333 Inexact Rounded +xadd481 add 552.669453 8.3725760E+16223526 -> 8.37257600E+16223526 Inexact Rounded +xcom481 compare 552.669453 8.3725760E+16223526 -> -1 +xdiv481 divide 552.669453 8.3725760E+16223526 -> 6.60094878E-16223525 Inexact Rounded +xdvi481 divideint 552.669453 8.3725760E+16223526 -> 0 +xmul481 multiply 552.669453 8.3725760E+16223526 -> 4.62726700E+16223529 Inexact Rounded +xpow481 power 552.669453 8 -> 8.70409632E+21 Inexact Rounded +xrem481 remainder 552.669453 8.3725760E+16223526 -> 552.669453 +xsub481 subtract 552.669453 8.3725760E+16223526 -> -8.37257600E+16223526 Inexact Rounded +xadd482 add -3266303 453741.520 -> -2812561.48 Rounded +xcom482 compare -3266303 453741.520 -> -1 +xdiv482 divide -3266303 453741.520 -> -7.19859844 Inexact Rounded +xdvi482 divideint -3266303 453741.520 -> -7 +xmul482 multiply -3266303 453741.520 -> -1.48205729E+12 Inexact Rounded +xpow482 power -3266303 453742 -> 1.02497315E+2955701 Inexact Rounded +xrem482 remainder -3266303 453741.520 -> -90112.360 +xsub482 subtract -3266303 453741.520 -> -3720044.52 Rounded +xadd483 add 12302757.4 542922.487E+414443353 -> 5.42922487E+414443358 Inexact Rounded +xcom483 compare 12302757.4 542922.487E+414443353 -> -1 +xdiv483 divide 12302757.4 542922.487E+414443353 -> 2.26602465E-414443352 Inexact Rounded +xdvi483 divideint 12302757.4 542922.487E+414443353 -> 0 +xmul483 multiply 12302757.4 542922.487E+414443353 -> 6.67944364E+414443365 Inexact Rounded +xpow483 power 12302757.4 5 -> 2.81846276E+35 Inexact Rounded +xrem483 remainder 12302757.4 542922.487E+414443353 -> 12302757.4 +xsub483 subtract 12302757.4 542922.487E+414443353 -> -5.42922487E+414443358 Inexact Rounded +xadd484 add -5670757.79E-784754984 128144.503 -> 128144.503 Inexact Rounded +xcom484 compare -5670757.79E-784754984 128144.503 -> -1 +xdiv484 divide -5670757.79E-784754984 128144.503 -> -4.42528369E-784754983 Inexact Rounded +xdvi484 divideint -5670757.79E-784754984 128144.503 -> -0 +xmul484 multiply -5670757.79E-784754984 128144.503 -> -7.26676439E-784754973 Inexact Rounded +xpow484 power -5670757.79E-784754984 128145 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem484 remainder -5670757.79E-784754984 128144.503 -> -5.67075779E-784754978 +xsub484 subtract -5670757.79E-784754984 128144.503 -> -128144.503 Inexact Rounded +xadd485 add 22.7721968E+842530698 5223.70462 -> 2.27721968E+842530699 Inexact Rounded +xcom485 compare 22.7721968E+842530698 5223.70462 -> 1 +xdiv485 divide 22.7721968E+842530698 5223.70462 -> 4.35939596E+842530695 Inexact Rounded +xdvi485 divideint 22.7721968E+842530698 5223.70462 -> NaN Division_impossible +xmul485 multiply 22.7721968E+842530698 5223.70462 -> 1.18955230E+842530703 Inexact Rounded +xpow485 power 22.7721968E+842530698 5224 -> Infinity Overflow Inexact Rounded +xrem485 remainder 22.7721968E+842530698 5223.70462 -> NaN Division_impossible +xsub485 subtract 22.7721968E+842530698 5223.70462 -> 2.27721968E+842530699 Inexact Rounded +xadd486 add 88.5158199E-980164357 325846116 -> 325846116 Inexact Rounded +xcom486 compare 88.5158199E-980164357 325846116 -> -1 +xdiv486 divide 88.5158199E-980164357 325846116 -> 2.71649148E-980164364 Inexact Rounded +xdvi486 divideint 88.5158199E-980164357 325846116 -> 0 +xmul486 multiply 88.5158199E-980164357 325846116 -> 2.88425361E-980164347 Inexact Rounded +xpow486 power 88.5158199E-980164357 325846116 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem486 remainder 88.5158199E-980164357 325846116 -> 8.85158199E-980164356 +xsub486 subtract 88.5158199E-980164357 325846116 -> -325846116 Inexact Rounded +xadd487 add -22881.0408 5.63661562 -> -22875.4042 Inexact Rounded +xcom487 compare -22881.0408 5.63661562 -> -1 +xdiv487 divide -22881.0408 5.63661562 -> -4059.35802 Inexact Rounded +xdvi487 divideint -22881.0408 5.63661562 -> -4059 +xmul487 multiply -22881.0408 5.63661562 -> -128971.632 Inexact Rounded +xpow487 power -22881.0408 6 -> 1.43500909E+26 Inexact Rounded +xrem487 remainder -22881.0408 5.63661562 -> -2.01799842 +xsub487 subtract -22881.0408 5.63661562 -> -22886.6774 Inexact Rounded +xadd488 add -7157.57449 -76.4455519E-85647047 -> -7157.57449 Inexact Rounded +xcom488 compare -7157.57449 -76.4455519E-85647047 -> -1 +xdiv488 divide -7157.57449 -76.4455519E-85647047 -> 9.36297052E+85647048 Inexact Rounded +xdvi488 divideint -7157.57449 -76.4455519E-85647047 -> NaN Division_impossible +xmul488 multiply -7157.57449 -76.4455519E-85647047 -> 5.47164732E-85647042 Inexact Rounded +xpow488 power -7157.57449 -8 -> 1.45168700E-31 Inexact Rounded +xrem488 remainder -7157.57449 -76.4455519E-85647047 -> NaN Division_impossible +xsub488 subtract -7157.57449 -76.4455519E-85647047 -> -7157.57449 Inexact Rounded +xadd489 add -503113.801 -9715149.82E-612184422 -> -503113.801 Inexact Rounded +xcom489 compare -503113.801 -9715149.82E-612184422 -> -1 +xdiv489 divide -503113.801 -9715149.82E-612184422 -> 5.17865201E+612184420 Inexact Rounded +xdvi489 divideint -503113.801 -9715149.82E-612184422 -> NaN Division_impossible +xmul489 multiply -503113.801 -9715149.82E-612184422 -> 4.88782595E-612184410 Inexact Rounded +xpow489 power -503113.801 -10 -> 9.62360287E-58 Inexact Rounded +xrem489 remainder -503113.801 -9715149.82E-612184422 -> NaN Division_impossible +xsub489 subtract -503113.801 -9715149.82E-612184422 -> -503113.801 Inexact Rounded +xadd490 add -3066962.41 -55.3096879 -> -3067017.72 Inexact Rounded +xcom490 compare -3066962.41 -55.3096879 -> -1 +xdiv490 divide -3066962.41 -55.3096879 -> 55450.7271 Inexact Rounded +xdvi490 divideint -3066962.41 -55.3096879 -> 55450 +xmul490 multiply -3066962.41 -55.3096879 -> 169632734 Inexact Rounded +xpow490 power -3066962.41 -55 -> -1.70229600E-357 Inexact Rounded +xrem490 remainder -3066962.41 -55.3096879 -> -40.2159450 +xsub490 subtract -3066962.41 -55.3096879 -> -3066907.10 Inexact Rounded +xadd491 add -53311.5738E+156608936 -7.45890666 -> -5.33115738E+156608940 Inexact Rounded +xcom491 compare -53311.5738E+156608936 -7.45890666 -> -1 +xdiv491 divide -53311.5738E+156608936 -7.45890666 -> 7.14737109E+156608939 Inexact Rounded +xdvi491 divideint -53311.5738E+156608936 -7.45890666 -> NaN Division_impossible +xmul491 multiply -53311.5738E+156608936 -7.45890666 -> 3.97646053E+156608941 Inexact Rounded +xpow491 power -53311.5738E+156608936 -7 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem491 remainder -53311.5738E+156608936 -7.45890666 -> NaN Division_impossible +xsub491 subtract -53311.5738E+156608936 -7.45890666 -> -5.33115738E+156608940 Inexact Rounded +xadd492 add 998890068. -92.057879 -> 998889976 Inexact Rounded +xcom492 compare 998890068. -92.057879 -> 1 +xdiv492 divide 998890068. -92.057879 -> -10850674.4 Inexact Rounded +xdvi492 divideint 998890068. -92.057879 -> -10850674 +xmul492 multiply 998890068. -92.057879 -> -9.19557010E+10 Inexact Rounded +xpow492 power 998890068. -92 -> 1.10757225E-828 Inexact Rounded +xrem492 remainder 998890068. -92.057879 -> 33.839554 +xsub492 subtract 998890068. -92.057879 -> 998890160 Inexact Rounded +xadd493 add 122.495591 -407836028. -> -407835906 Inexact Rounded +xcom493 compare 122.495591 -407836028. -> 1 +xdiv493 divide 122.495591 -407836028. -> -3.00355002E-7 Inexact Rounded +xdvi493 divideint 122.495591 -407836028. -> -0 +xmul493 multiply 122.495591 -407836028. -> -4.99581153E+10 Inexact Rounded +xpow493 power 122.495591 -407836028 -> 4.82463773E-851610754 Inexact Rounded +xrem493 remainder 122.495591 -407836028. -> 122.495591 +xsub493 subtract 122.495591 -407836028. -> 407836150 Inexact Rounded +xadd494 add 187098.488 6220.05584E-236541249 -> 187098.488 Inexact Rounded +xcom494 compare 187098.488 6220.05584E-236541249 -> 1 +xdiv494 divide 187098.488 6220.05584E-236541249 -> 3.00798727E+236541250 Inexact Rounded +xdvi494 divideint 187098.488 6220.05584E-236541249 -> NaN Division_impossible +xmul494 multiply 187098.488 6220.05584E-236541249 -> 1.16376304E-236541240 Inexact Rounded +xpow494 power 187098.488 6 -> 4.28964811E+31 Inexact Rounded +xrem494 remainder 187098.488 6220.05584E-236541249 -> NaN Division_impossible +xsub494 subtract 187098.488 6220.05584E-236541249 -> 187098.488 Inexact Rounded +xadd495 add 4819899.21E+432982550 -727441917 -> 4.81989921E+432982556 Inexact Rounded +xcom495 compare 4819899.21E+432982550 -727441917 -> 1 +xdiv495 divide 4819899.21E+432982550 -727441917 -> -6.62582001E+432982547 Inexact Rounded +xdvi495 divideint 4819899.21E+432982550 -727441917 -> NaN Division_impossible +xmul495 multiply 4819899.21E+432982550 -727441917 -> -3.50619672E+432982565 Inexact Rounded +xpow495 power 4819899.21E+432982550 -727441917 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem495 remainder 4819899.21E+432982550 -727441917 -> NaN Division_impossible +xsub495 subtract 4819899.21E+432982550 -727441917 -> 4.81989921E+432982556 Inexact Rounded +xadd496 add 5770.01020E+507459752 -4208339.33E-129766680 -> 5.77001020E+507459755 Inexact Rounded +xcom496 compare 5770.01020E+507459752 -4208339.33E-129766680 -> 1 +xdiv496 divide 5770.01020E+507459752 -4208339.33E-129766680 -> -1.37108958E+637226429 Inexact Rounded +xdvi496 divideint 5770.01020E+507459752 -4208339.33E-129766680 -> NaN Division_impossible +xmul496 multiply 5770.01020E+507459752 -4208339.33E-129766680 -> -2.42821609E+377693082 Inexact Rounded +xpow496 power 5770.01020E+507459752 -4 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped +xrem496 remainder 5770.01020E+507459752 -4208339.33E-129766680 -> NaN Division_impossible +xsub496 subtract 5770.01020E+507459752 -4208339.33E-129766680 -> 5.77001020E+507459755 Inexact Rounded +xadd497 add -286.371320 710319152 -> 710318866 Inexact Rounded +xcom497 compare -286.371320 710319152 -> -1 +xdiv497 divide -286.371320 710319152 -> -4.03158664E-7 Inexact Rounded +xdvi497 divideint -286.371320 710319152 -> -0 +xmul497 multiply -286.371320 710319152 -> -2.03415033E+11 Inexact Rounded +xpow497 power -286.371320 710319152 -> Infinity Overflow Inexact Rounded +xrem497 remainder -286.371320 710319152 -> -286.371320 +xsub497 subtract -286.371320 710319152 -> -710319438 Inexact Rounded +xadd498 add -7.27403536 -481469656E-835183700 -> -7.27403536 Inexact Rounded +xcom498 compare -7.27403536 -481469656E-835183700 -> -1 +xdiv498 divide -7.27403536 -481469656E-835183700 -> 1.51079830E+835183692 Inexact Rounded +xdvi498 divideint -7.27403536 -481469656E-835183700 -> NaN Division_impossible +xmul498 multiply -7.27403536 -481469656E-835183700 -> 3.50222730E-835183691 Inexact Rounded +xpow498 power -7.27403536 -5 -> -0.0000491046885 Inexact Rounded +xrem498 remainder -7.27403536 -481469656E-835183700 -> NaN Division_impossible +xsub498 subtract -7.27403536 -481469656E-835183700 -> -7.27403536 Inexact Rounded +xadd499 add -6157.74292 -94075286.2E+92555877 -> -9.40752862E+92555884 Inexact Rounded +xcom499 compare -6157.74292 -94075286.2E+92555877 -> 1 +xdiv499 divide -6157.74292 -94075286.2E+92555877 -> 6.54554790E-92555882 Inexact Rounded +xdvi499 divideint -6157.74292 -94075286.2E+92555877 -> 0 +xmul499 multiply -6157.74292 -94075286.2E+92555877 -> 5.79291428E+92555888 Inexact Rounded +xpow499 power -6157.74292 -9 -> -7.85608218E-35 Inexact Rounded +xrem499 remainder -6157.74292 -94075286.2E+92555877 -> -6157.74292 +xsub499 subtract -6157.74292 -94075286.2E+92555877 -> 9.40752862E+92555884 Inexact Rounded +xadd500 add -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded +xcom500 compare -525445087.E+231529167 188227460 -> -1 +xdiv500 divide -525445087.E+231529167 188227460 -> -2.79154321E+231529167 Inexact Rounded +xdvi500 divideint -525445087.E+231529167 188227460 -> NaN Division_impossible +xmul500 multiply -525445087.E+231529167 188227460 -> -9.89031941E+231529183 Inexact Rounded +xpow500 power -525445087.E+231529167 188227460 -> Infinity Overflow Inexact Rounded +xrem500 remainder -525445087.E+231529167 188227460 -> NaN Division_impossible +xsub500 subtract -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded Added: sandbox/trunk/decimal-c/decimaltestdata/remainder.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/remainder.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,629 @@ +------------------------------------------------------------------------ +-- remainder.decTest -- decimal remainder -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- sanity checks (as base, above) +remx001 remainder 1 1 -> 0 +remx002 remainder 2 1 -> 0 +remx003 remainder 1 2 -> 1 +remx004 remainder 2 2 -> 0 +remx005 remainder 0 1 -> 0 +remx006 remainder 0 2 -> 0 +remx007 remainder 1 3 -> 1 +remx008 remainder 2 3 -> 2 +remx009 remainder 3 3 -> 0 + +remx010 remainder 2.4 1 -> 0.4 +remx011 remainder 2.4 -1 -> 0.4 +remx012 remainder -2.4 1 -> -0.4 +remx013 remainder -2.4 -1 -> -0.4 +remx014 remainder 2.40 1 -> 0.40 +remx015 remainder 2.400 1 -> 0.400 +remx016 remainder 2.4 2 -> 0.4 +remx017 remainder 2.400 2 -> 0.400 +remx018 remainder 2. 2 -> 0 +remx019 remainder 20 20 -> 0 + +remx020 remainder 187 187 -> 0 +remx021 remainder 5 2 -> 1 +remx022 remainder 5 2.0 -> 1.0 +remx023 remainder 5 2.000 -> 1.000 +remx024 remainder 5 0.200 -> 0.000 +remx025 remainder 5 0.200 -> 0.000 + +remx030 remainder 1 2 -> 1 +remx031 remainder 1 4 -> 1 +remx032 remainder 1 8 -> 1 + +remx033 remainder 1 16 -> 1 +remx034 remainder 1 32 -> 1 +remx035 remainder 1 64 -> 1 +remx040 remainder 1 -2 -> 1 +remx041 remainder 1 -4 -> 1 +remx042 remainder 1 -8 -> 1 +remx043 remainder 1 -16 -> 1 +remx044 remainder 1 -32 -> 1 +remx045 remainder 1 -64 -> 1 +remx050 remainder -1 2 -> -1 +remx051 remainder -1 4 -> -1 +remx052 remainder -1 8 -> -1 +remx053 remainder -1 16 -> -1 +remx054 remainder -1 32 -> -1 +remx055 remainder -1 64 -> -1 +remx060 remainder -1 -2 -> -1 +remx061 remainder -1 -4 -> -1 +remx062 remainder -1 -8 -> -1 +remx063 remainder -1 -16 -> -1 +remx064 remainder -1 -32 -> -1 +remx065 remainder -1 -64 -> -1 + +remx066 remainder 999999999 1 -> 0 +remx067 remainder 999999999.4 1 -> 0.4 +remx068 remainder 999999999.5 1 -> 0.5 +remx069 remainder 999999999.9 1 -> 0.9 +remx070 remainder 999999999.999 1 -> 0.999 +precision: 6 +remx071 remainder 999999999 1 -> NaN Division_impossible +remx072 remainder 99999999 1 -> NaN Division_impossible +remx073 remainder 9999999 1 -> NaN Division_impossible +remx074 remainder 999999 1 -> 0 +remx075 remainder 99999 1 -> 0 +remx076 remainder 9999 1 -> 0 +remx077 remainder 999 1 -> 0 +remx078 remainder 99 1 -> 0 +remx079 remainder 9 1 -> 0 + +precision: 9 +remx080 remainder 0. 1 -> 0 +remx081 remainder .0 1 -> 0.0 +remx082 remainder 0.00 1 -> 0.00 +remx083 remainder 0.00E+9 1 -> 0 +remx084 remainder 0.00E+3 1 -> 0 +remx085 remainder 0.00E+2 1 -> 0 +remx086 remainder 0.00E+1 1 -> 0.0 +remx087 remainder 0.00E+0 1 -> 0.00 +remx088 remainder 0.00E-0 1 -> 0.00 +remx089 remainder 0.00E-1 1 -> 0.000 +remx090 remainder 0.00E-2 1 -> 0.0000 +remx091 remainder 0.00E-3 1 -> 0.00000 +remx092 remainder 0.00E-4 1 -> 0.000000 +remx093 remainder 0.00E-5 1 -> 0E-7 +remx094 remainder 0.00E-6 1 -> 0E-8 +remx095 remainder 0.0000E-50 1 -> 0E-54 + +-- Various flavours of remainder by 0 +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +remx101 remainder 0 0 -> NaN Division_undefined +remx102 remainder 0 -0 -> NaN Division_undefined +remx103 remainder -0 0 -> NaN Division_undefined +remx104 remainder -0 -0 -> NaN Division_undefined +remx105 remainder 0.0E5 0 -> NaN Division_undefined +remx106 remainder 0.000 0 -> NaN Division_undefined +-- [Some think this next group should be Division_by_zero exception, but +-- IEEE 854 is explicit that it is Invalid operation .. for +-- remainder-near, anyway] +remx107 remainder 0.0001 0 -> NaN Invalid_operation +remx108 remainder 0.01 0 -> NaN Invalid_operation +remx109 remainder 0.1 0 -> NaN Invalid_operation +remx110 remainder 1 0 -> NaN Invalid_operation +remx111 remainder 1 0.0 -> NaN Invalid_operation +remx112 remainder 10 0.0 -> NaN Invalid_operation +remx113 remainder 1E+100 0.0 -> NaN Invalid_operation +remx114 remainder 1E+1000 0 -> NaN Invalid_operation +remx115 remainder 0.0001 -0 -> NaN Invalid_operation +remx116 remainder 0.01 -0 -> NaN Invalid_operation +remx119 remainder 0.1 -0 -> NaN Invalid_operation +remx120 remainder 1 -0 -> NaN Invalid_operation +remx121 remainder 1 -0.0 -> NaN Invalid_operation +remx122 remainder 10 -0.0 -> NaN Invalid_operation +remx123 remainder 1E+100 -0.0 -> NaN Invalid_operation +remx124 remainder 1E+1000 -0 -> NaN Invalid_operation +-- and zeros on left +remx130 remainder 0 1 -> 0 +remx131 remainder 0 -1 -> 0 +remx132 remainder 0.0 1 -> 0.0 +remx133 remainder 0.0 -1 -> 0.0 +remx134 remainder -0 1 -> -0 +remx135 remainder -0 -1 -> -0 +remx136 remainder -0.0 1 -> -0.0 +remx137 remainder -0.0 -1 -> -0.0 + +-- 0.5ers +remx143 remainder 0.5 2 -> 0.5 +remx144 remainder 0.5 2.1 -> 0.5 +remx145 remainder 0.5 2.01 -> 0.50 +remx146 remainder 0.5 2.001 -> 0.500 +remx147 remainder 0.50 2 -> 0.50 +remx148 remainder 0.50 2.01 -> 0.50 +remx149 remainder 0.50 2.001 -> 0.500 + +-- steadies +remx150 remainder 1 1 -> 0 +remx151 remainder 1 2 -> 1 +remx152 remainder 1 3 -> 1 +remx153 remainder 1 4 -> 1 +remx154 remainder 1 5 -> 1 +remx155 remainder 1 6 -> 1 +remx156 remainder 1 7 -> 1 +remx157 remainder 1 8 -> 1 +remx158 remainder 1 9 -> 1 +remx159 remainder 1 10 -> 1 +remx160 remainder 1 1 -> 0 +remx161 remainder 2 1 -> 0 +remx162 remainder 3 1 -> 0 +remx163 remainder 4 1 -> 0 +remx164 remainder 5 1 -> 0 +remx165 remainder 6 1 -> 0 +remx166 remainder 7 1 -> 0 +remx167 remainder 8 1 -> 0 +remx168 remainder 9 1 -> 0 +remx169 remainder 10 1 -> 0 + +-- some differences from remainderNear +remx171 remainder 0.4 1.020 -> 0.400 +remx172 remainder 0.50 1.020 -> 0.500 +remx173 remainder 0.51 1.020 -> 0.510 +remx174 remainder 0.52 1.020 -> 0.520 +remx175 remainder 0.6 1.020 -> 0.600 + + +-- More flavours of remainder by 0 +maxexponent: 999999999 +minexponent: -999999999 +remx201 remainder 0 0 -> NaN Division_undefined +remx202 remainder 0.0E5 0 -> NaN Division_undefined +remx203 remainder 0.000 0 -> NaN Division_undefined +remx204 remainder 0.0001 0 -> NaN Invalid_operation +remx205 remainder 0.01 0 -> NaN Invalid_operation +remx206 remainder 0.1 0 -> NaN Invalid_operation +remx207 remainder 1 0 -> NaN Invalid_operation +remx208 remainder 1 0.0 -> NaN Invalid_operation +remx209 remainder 10 0.0 -> NaN Invalid_operation +remx210 remainder 1E+100 0.0 -> NaN Invalid_operation +remx211 remainder 1E+1000 0 -> NaN Invalid_operation + +-- some differences from remainderNear +remx231 remainder -0.4 1.020 -> -0.400 +remx232 remainder -0.50 1.020 -> -0.500 +remx233 remainder -0.51 1.020 -> -0.510 +remx234 remainder -0.52 1.020 -> -0.520 +remx235 remainder -0.6 1.020 -> -0.600 + +-- high Xs +remx240 remainder 1E+2 1.00 -> 0.00 + + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +remx270 remainder 1 1e999999999 -> 1 +remx271 remainder 1 0.9e999999999 -> 1 +remx272 remainder 1 0.99e999999999 -> 1 +remx273 remainder 1 0.999999999e999999999 -> 1 +remx274 remainder 9e999999999 1 -> NaN Division_impossible +remx275 remainder 9.9e999999999 1 -> NaN Division_impossible +remx276 remainder 9.99e999999999 1 -> NaN Division_impossible +remx277 remainder 9.99999999e999999999 1 -> NaN Division_impossible + +remx280 remainder 0.1 9e-999999999 -> NaN Division_impossible +remx281 remainder 0.1 99e-999999999 -> NaN Division_impossible +remx282 remainder 0.1 999e-999999999 -> NaN Division_impossible + +remx283 remainder 0.1 9e-999999998 -> NaN Division_impossible +remx284 remainder 0.1 99e-999999998 -> NaN Division_impossible +remx285 remainder 0.1 999e-999999998 -> NaN Division_impossible +remx286 remainder 0.1 999e-999999997 -> NaN Division_impossible +remx287 remainder 0.1 9999e-999999997 -> NaN Division_impossible +remx288 remainder 0.1 99999e-999999997 -> NaN Division_impossible + +-- remx3xx are from DiagBigDecimal +remx301 remainder 1 3 -> 1 +remx302 remainder 5 5 -> 0 +remx303 remainder 13 10 -> 3 +remx304 remainder 13 50 -> 13 +remx305 remainder 13 100 -> 13 +remx306 remainder 13 1000 -> 13 +remx307 remainder .13 1 -> 0.13 +remx308 remainder 0.133 1 -> 0.133 +remx309 remainder 0.1033 1 -> 0.1033 +remx310 remainder 1.033 1 -> 0.033 +remx311 remainder 10.33 1 -> 0.33 +remx312 remainder 10.33 10 -> 0.33 +remx313 remainder 103.3 1 -> 0.3 +remx314 remainder 133 10 -> 3 +remx315 remainder 1033 10 -> 3 +remx316 remainder 1033 50 -> 33 +remx317 remainder 101.0 3 -> 2.0 +remx318 remainder 102.0 3 -> 0.0 +remx319 remainder 103.0 3 -> 1.0 +remx320 remainder 2.40 1 -> 0.40 +remx321 remainder 2.400 1 -> 0.400 +remx322 remainder 2.4 1 -> 0.4 +remx323 remainder 2.4 2 -> 0.4 +remx324 remainder 2.400 2 -> 0.400 +remx325 remainder 1 0.3 -> 0.1 +remx326 remainder 1 0.30 -> 0.10 +remx327 remainder 1 0.300 -> 0.100 +remx328 remainder 1 0.3000 -> 0.1000 +remx329 remainder 1.0 0.3 -> 0.1 +remx330 remainder 1.00 0.3 -> 0.10 +remx331 remainder 1.000 0.3 -> 0.100 +remx332 remainder 1.0000 0.3 -> 0.1000 +remx333 remainder 0.5 2 -> 0.5 +remx334 remainder 0.5 2.1 -> 0.5 +remx335 remainder 0.5 2.01 -> 0.50 +remx336 remainder 0.5 2.001 -> 0.500 +remx337 remainder 0.50 2 -> 0.50 +remx338 remainder 0.50 2.01 -> 0.50 +remx339 remainder 0.50 2.001 -> 0.500 + +remx340 remainder 0.5 0.5000001 -> 0.5000000 +remx341 remainder 0.5 0.50000001 -> 0.50000000 +remx342 remainder 0.5 0.500000001 -> 0.500000000 +remx343 remainder 0.5 0.5000000001 -> 0.500000000 Rounded +remx344 remainder 0.5 0.50000000001 -> 0.500000000 Rounded +remx345 remainder 0.5 0.4999999 -> 1E-7 +remx346 remainder 0.5 0.49999999 -> 1E-8 +remx347 remainder 0.5 0.499999999 -> 1E-9 +remx348 remainder 0.5 0.4999999999 -> 1E-10 +remx349 remainder 0.5 0.49999999999 -> 1E-11 +remx350 remainder 0.5 0.499999999999 -> 1E-12 + +remx351 remainder 0.03 7 -> 0.03 +remx352 remainder 5 2 -> 1 +remx353 remainder 4.1 2 -> 0.1 +remx354 remainder 4.01 2 -> 0.01 +remx355 remainder 4.001 2 -> 0.001 +remx356 remainder 4.0001 2 -> 0.0001 +remx357 remainder 4.00001 2 -> 0.00001 +remx358 remainder 4.000001 2 -> 0.000001 +remx359 remainder 4.0000001 2 -> 1E-7 + +remx360 remainder 1.2 0.7345 -> 0.4655 +remx361 remainder 0.8 12 -> 0.8 +remx362 remainder 0.8 0.2 -> 0.0 +remx363 remainder 0.8 0.3 -> 0.2 +remx364 remainder 0.800 12 -> 0.800 +remx365 remainder 0.800 1.7 -> 0.800 +remx366 remainder 2.400 2 -> 0.400 + +precision: 6 +remx371 remainder 2.400 2 -> 0.400 +precision: 3 +-- long operand, rounded, case +remx372 remainder 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded +-- 12000000000000 + +precision: 5 +remx381 remainder 12345 1 -> 0 +remx382 remainder 12345 1.0001 -> 0.7657 +remx383 remainder 12345 1.001 -> 0.668 +remx384 remainder 12345 1.01 -> 0.78 +remx385 remainder 12345 1.1 -> 0.8 +remx386 remainder 12355 4 -> 3 +remx387 remainder 12345 4 -> 1 +remx388 remainder 12355 4.0001 -> 2.6912 +remx389 remainder 12345 4.0001 -> 0.6914 +remx390 remainder 12345 4.9 -> 1.9 +remx391 remainder 12345 4.99 -> 4.73 +remx392 remainder 12345 4.999 -> 2.469 +remx393 remainder 12345 4.9999 -> 0.2469 +remx394 remainder 12345 5 -> 0 +remx395 remainder 12345 5.0001 -> 4.7532 +remx396 remainder 12345 5.001 -> 2.532 +remx397 remainder 12345 5.01 -> 0.36 +remx398 remainder 12345 5.1 -> 3.0 + +precision: 9 +-- the nasty division-by-1 cases +remx401 remainder 0.5 1 -> 0.5 +remx402 remainder 0.55 1 -> 0.55 +remx403 remainder 0.555 1 -> 0.555 +remx404 remainder 0.5555 1 -> 0.5555 +remx405 remainder 0.55555 1 -> 0.55555 +remx406 remainder 0.555555 1 -> 0.555555 +remx407 remainder 0.5555555 1 -> 0.5555555 +remx408 remainder 0.55555555 1 -> 0.55555555 +remx409 remainder 0.555555555 1 -> 0.555555555 + + +-- Specials +remx680 remainder Inf -Inf -> NaN Invalid_operation +remx681 remainder Inf -1000 -> NaN Invalid_operation +remx682 remainder Inf -1 -> NaN Invalid_operation +remx683 remainder Inf 0 -> NaN Invalid_operation +remx684 remainder Inf -0 -> NaN Invalid_operation +remx685 remainder Inf 1 -> NaN Invalid_operation +remx686 remainder Inf 1000 -> NaN Invalid_operation +remx687 remainder Inf Inf -> NaN Invalid_operation +remx688 remainder -1000 Inf -> -1000 +remx689 remainder -Inf Inf -> NaN Invalid_operation +remx691 remainder -1 Inf -> -1 +remx692 remainder 0 Inf -> 0 +remx693 remainder -0 Inf -> -0 +remx694 remainder 1 Inf -> 1 +remx695 remainder 1000 Inf -> 1000 +remx696 remainder Inf Inf -> NaN Invalid_operation + +remx700 remainder -Inf -Inf -> NaN Invalid_operation +remx701 remainder -Inf -1000 -> NaN Invalid_operation +remx702 remainder -Inf -1 -> NaN Invalid_operation +remx703 remainder -Inf -0 -> NaN Invalid_operation +remx704 remainder -Inf 0 -> NaN Invalid_operation +remx705 remainder -Inf 1 -> NaN Invalid_operation +remx706 remainder -Inf 1000 -> NaN Invalid_operation +remx707 remainder -Inf Inf -> NaN Invalid_operation +remx708 remainder -Inf -Inf -> NaN Invalid_operation +remx709 remainder -1000 Inf -> -1000 +remx710 remainder -1 -Inf -> -1 +remx711 remainder -0 -Inf -> -0 +remx712 remainder 0 -Inf -> 0 +remx713 remainder 1 -Inf -> 1 +remx714 remainder 1000 -Inf -> 1000 +remx715 remainder Inf -Inf -> NaN Invalid_operation + +remx721 remainder NaN -Inf -> NaN +remx722 remainder NaN -1000 -> NaN +remx723 remainder NaN -1 -> NaN +remx724 remainder NaN -0 -> NaN +remx725 remainder -NaN 0 -> -NaN +remx726 remainder NaN 1 -> NaN +remx727 remainder NaN 1000 -> NaN +remx728 remainder NaN Inf -> NaN +remx729 remainder NaN -NaN -> NaN +remx730 remainder -Inf NaN -> NaN +remx731 remainder -1000 NaN -> NaN +remx732 remainder -1 NaN -> NaN +remx733 remainder -0 -NaN -> -NaN +remx734 remainder 0 NaN -> NaN +remx735 remainder 1 -NaN -> -NaN +remx736 remainder 1000 NaN -> NaN +remx737 remainder Inf NaN -> NaN + +remx741 remainder sNaN -Inf -> NaN Invalid_operation +remx742 remainder sNaN -1000 -> NaN Invalid_operation +remx743 remainder -sNaN -1 -> -NaN Invalid_operation +remx744 remainder sNaN -0 -> NaN Invalid_operation +remx745 remainder sNaN 0 -> NaN Invalid_operation +remx746 remainder sNaN 1 -> NaN Invalid_operation +remx747 remainder sNaN 1000 -> NaN Invalid_operation +remx749 remainder sNaN NaN -> NaN Invalid_operation +remx750 remainder sNaN sNaN -> NaN Invalid_operation +remx751 remainder NaN sNaN -> NaN Invalid_operation +remx752 remainder -Inf sNaN -> NaN Invalid_operation +remx753 remainder -1000 sNaN -> NaN Invalid_operation +remx754 remainder -1 sNaN -> NaN Invalid_operation +remx755 remainder -0 sNaN -> NaN Invalid_operation +remx756 remainder 0 sNaN -> NaN Invalid_operation +remx757 remainder 1 sNaN -> NaN Invalid_operation +remx758 remainder 1000 sNaN -> NaN Invalid_operation +remx759 remainder Inf -sNaN -> -NaN Invalid_operation + +-- propaging NaNs +remx760 remainder NaN1 NaN7 -> NaN1 +remx761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation +remx762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation +remx763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation +remx764 remainder 15 NaN11 -> NaN11 +remx765 remainder NaN6 NaN12 -> NaN6 +remx766 remainder Inf NaN13 -> NaN13 +remx767 remainder NaN14 -Inf -> NaN14 +remx768 remainder 0 NaN15 -> NaN15 +remx769 remainder NaN16 -0 -> NaN16 + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +remx770 remainder 1 1e999999999 -> 1 +remx771 remainder 1 0.9e999999999 -> 1 +remx772 remainder 1 0.99e999999999 -> 1 +remx773 remainder 1 0.999999999e999999999 -> 1 +remx774 remainder 9e999999999 1 -> NaN Division_impossible +remx775 remainder 9.9e999999999 1 -> NaN Division_impossible +remx776 remainder 9.99e999999999 1 -> NaN Division_impossible +remx777 remainder 9.99999999e999999999 1 -> NaN Division_impossible + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +remx801 remainder 12345678000 100 -> 0 +remx802 remainder 1 12345678000 -> 1 +remx803 remainder 1234567800 10 -> 0 +remx804 remainder 1 1234567800 -> 1 +remx805 remainder 1234567890 10 -> 0 +remx806 remainder 1 1234567890 -> 1 +remx807 remainder 1234567891 10 -> 1 +remx808 remainder 1 1234567891 -> 1 +remx809 remainder 12345678901 100 -> 1 +remx810 remainder 1 12345678901 -> 1 +remx811 remainder 1234567896 10 -> 6 +remx812 remainder 1 1234567896 -> 1 + +precision: 15 +remx821 remainder 12345678000 100 -> 0 +remx822 remainder 1 12345678000 -> 1 +remx823 remainder 1234567800 10 -> 0 +remx824 remainder 1 1234567800 -> 1 +remx825 remainder 1234567890 10 -> 0 +remx826 remainder 1 1234567890 -> 1 +remx827 remainder 1234567891 10 -> 1 +remx828 remainder 1 1234567891 -> 1 +remx829 remainder 12345678901 100 -> 1 +remx830 remainder 1 12345678901 -> 1 +remx831 remainder 1234567896 10 -> 6 +remx832 remainder 1 1234567896 -> 1 + +-- worries from divideint +precision: 8 +remx840 remainder 100000000.0 1 -> NaN Division_impossible +remx841 remainder 100000000.4 1 -> NaN Division_impossible +remx842 remainder 100000000.5 1 -> NaN Division_impossible +remx843 remainder 100000000.9 1 -> NaN Division_impossible +remx844 remainder 100000000.999 1 -> NaN Division_impossible +precision: 6 +remx850 remainder 100000003 5 -> NaN Division_impossible +remx851 remainder 10000003 5 -> NaN Division_impossible +remx852 remainder 1000003 5 -> 3 +remx853 remainder 100003 5 -> 3 +remx854 remainder 10003 5 -> 3 +remx855 remainder 1003 5 -> 3 +remx856 remainder 103 5 -> 3 +remx857 remainder 13 5 -> 3 +remx858 remainder 1 5 -> 1 + +-- Vladimir's cases +remx860 remainder 123.0e1 10000000000000000 -> 1230 +remx861 remainder 1230 10000000000000000 -> 1230 +remx862 remainder 12.3e2 10000000000000000 -> 1230 +remx863 remainder 1.23e3 10000000000000000 -> 1230 +remx864 remainder 123e1 10000000000000000 -> 1230 +remx870 remainder 123e1 1000000000000000 -> 1230 +remx871 remainder 123e1 100000000000000 -> 1230 +remx872 remainder 123e1 10000000000000 -> 1230 +remx873 remainder 123e1 1000000000000 -> 1230 +remx874 remainder 123e1 100000000000 -> 1230 +remx875 remainder 123e1 10000000000 -> 1230 +remx876 remainder 123e1 1000000000 -> 1230 +remx877 remainder 123e1 100000000 -> 1230 +remx878 remainder 1230 100000000 -> 1230 +remx879 remainder 123e1 10000000 -> 1230 +remx880 remainder 123e1 1000000 -> 1230 +remx881 remainder 123e1 100000 -> 1230 +remx882 remainder 123e1 10000 -> 1230 +remx883 remainder 123e1 1000 -> 230 +remx884 remainder 123e1 100 -> 30 +remx885 remainder 123e1 10 -> 0 +remx886 remainder 123e1 1 -> 0 + +remx889 remainder 123e1 20000000000000000 -> 1230 +remx890 remainder 123e1 2000000000000000 -> 1230 +remx891 remainder 123e1 200000000000000 -> 1230 +remx892 remainder 123e1 20000000000000 -> 1230 +remx893 remainder 123e1 2000000000000 -> 1230 +remx894 remainder 123e1 200000000000 -> 1230 +remx895 remainder 123e1 20000000000 -> 1230 +remx896 remainder 123e1 2000000000 -> 1230 +remx897 remainder 123e1 200000000 -> 1230 +remx899 remainder 123e1 20000000 -> 1230 +remx900 remainder 123e1 2000000 -> 1230 +remx901 remainder 123e1 200000 -> 1230 +remx902 remainder 123e1 20000 -> 1230 +remx903 remainder 123e1 2000 -> 1230 +remx904 remainder 123e1 200 -> 30 +remx905 remainder 123e1 20 -> 10 +remx906 remainder 123e1 2 -> 0 + +remx909 remainder 123e1 50000000000000000 -> 1230 +remx910 remainder 123e1 5000000000000000 -> 1230 +remx911 remainder 123e1 500000000000000 -> 1230 +remx912 remainder 123e1 50000000000000 -> 1230 +remx913 remainder 123e1 5000000000000 -> 1230 +remx914 remainder 123e1 500000000000 -> 1230 +remx915 remainder 123e1 50000000000 -> 1230 +remx916 remainder 123e1 5000000000 -> 1230 +remx917 remainder 123e1 500000000 -> 1230 +remx919 remainder 123e1 50000000 -> 1230 +remx920 remainder 123e1 5000000 -> 1230 +remx921 remainder 123e1 500000 -> 1230 +remx922 remainder 123e1 50000 -> 1230 +remx923 remainder 123e1 5000 -> 1230 +remx924 remainder 123e1 500 -> 230 +remx925 remainder 123e1 50 -> 30 +remx926 remainder 123e1 5 -> 0 + +remx929 remainder 123e1 90000000000000000 -> 1230 +remx930 remainder 123e1 9000000000000000 -> 1230 +remx931 remainder 123e1 900000000000000 -> 1230 +remx932 remainder 123e1 90000000000000 -> 1230 +remx933 remainder 123e1 9000000000000 -> 1230 +remx934 remainder 123e1 900000000000 -> 1230 +remx935 remainder 123e1 90000000000 -> 1230 +remx936 remainder 123e1 9000000000 -> 1230 +remx937 remainder 123e1 900000000 -> 1230 +remx939 remainder 123e1 90000000 -> 1230 +remx940 remainder 123e1 9000000 -> 1230 +remx941 remainder 123e1 900000 -> 1230 +remx942 remainder 123e1 90000 -> 1230 +remx943 remainder 123e1 9000 -> 1230 +remx944 remainder 123e1 900 -> 330 +remx945 remainder 123e1 90 -> 60 +remx946 remainder 123e1 9 -> 6 + +remx950 remainder 123e1 10000000000000000 -> 1230 +remx951 remainder 123e1 100000000000000000 -> 1230 +remx952 remainder 123e1 1000000000000000000 -> 1230 +remx953 remainder 123e1 10000000000000000000 -> 1230 +remx954 remainder 123e1 100000000000000000000 -> 1230 +remx955 remainder 123e1 1000000000000000000000 -> 1230 +remx956 remainder 123e1 10000000000000000000000 -> 1230 +remx957 remainder 123e1 100000000000000000000000 -> 1230 +remx958 remainder 123e1 1000000000000000000000000 -> 1230 +remx959 remainder 123e1 10000000000000000000000000 -> 1230 + +remx960 remainder 123e1 19999999999999999 -> 1230 +remx961 remainder 123e1 199999999999999990 -> 1230 +remx962 remainder 123e1 1999999999999999999 -> 1230 +remx963 remainder 123e1 19999999999999999990 -> 1230 +remx964 remainder 123e1 199999999999999999999 -> 1230 +remx965 remainder 123e1 1999999999999999999990 -> 1230 +remx966 remainder 123e1 19999999999999999999999 -> 1230 +remx967 remainder 123e1 199999999999999999999990 -> 1230 +remx968 remainder 123e1 1999999999999999999999999 -> 1230 +remx969 remainder 123e1 19999999999999999999999990 -> 1230 + +remx970 remainder 1e1 10000000000000000 -> 10 +remx971 remainder 1e1 100000000000000000 -> 10 +remx972 remainder 1e1 1000000000000000000 -> 10 +remx973 remainder 1e1 10000000000000000000 -> 10 +remx974 remainder 1e1 100000000000000000000 -> 10 +remx975 remainder 1e1 1000000000000000000000 -> 10 +remx976 remainder 1e1 10000000000000000000000 -> 10 +remx977 remainder 1e1 100000000000000000000000 -> 10 +remx978 remainder 1e1 1000000000000000000000000 -> 10 +remx979 remainder 1e1 10000000000000000000000000 -> 10 + +remx980 remainder 123e1 1000E999999 -> 1.23E+3 -- 123E+1 internally + +-- overflow and underflow tests [from divide] +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +remx990 remainder +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded +remx991 remainder 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible +remx992 remainder +0.100 9E+999999999 -> 0.100 +remx993 remainder 9E-999999999 +9.100 -> 9E-999999999 +remx995 remainder -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded +remx996 remainder 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible +remx997 remainder -0.100 9E+999999999 -> -0.100 +remx998 remainder 9E-999999999 -9.100 -> 9E-999999999 + +-- Null tests +remx1000 remainder 10 # -> NaN Invalid_operation +remx1001 remainder # 10 -> NaN Invalid_operation + Added: sandbox/trunk/decimal-c/decimaltestdata/remainderNear.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/remainderNear.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,560 @@ +------------------------------------------------------------------------ +-- remainderNear.decTest -- decimal remainder-near (IEEE remainder) -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +rmnx001 remaindernear 1 1 -> 0 +rmnx002 remaindernear 2 1 -> 0 +rmnx003 remaindernear 1 2 -> 1 +rmnx004 remaindernear 2 2 -> 0 +rmnx005 remaindernear 0 1 -> 0 +rmnx006 remaindernear 0 2 -> 0 +rmnx007 remaindernear 1 3 -> 1 +rmnx008 remaindernear 2 3 -> -1 +rmnx009 remaindernear 3 3 -> 0 + +rmnx010 remaindernear 2.4 1 -> 0.4 +rmnx011 remaindernear 2.4 -1 -> 0.4 +rmnx012 remaindernear -2.4 1 -> -0.4 +rmnx013 remaindernear -2.4 -1 -> -0.4 +rmnx014 remaindernear 2.40 1 -> 0.40 +rmnx015 remaindernear 2.400 1 -> 0.400 +rmnx016 remaindernear 2.4 2 -> 0.4 +rmnx017 remaindernear 2.400 2 -> 0.400 +rmnx018 remaindernear 2. 2 -> 0 +rmnx019 remaindernear 20 20 -> 0 + +rmnx020 remaindernear 187 187 -> 0 +rmnx021 remaindernear 5 2 -> 1 +rmnx022 remaindernear 5 2.0 -> 1.0 +rmnx023 remaindernear 5 2.000 -> 1.000 +rmnx024 remaindernear 5 0.200 -> 0.000 +rmnx025 remaindernear 5 0.200 -> 0.000 + +rmnx030 remaindernear 1 2 -> 1 +rmnx031 remaindernear 1 4 -> 1 +rmnx032 remaindernear 1 8 -> 1 +rmnx033 remaindernear 1 16 -> 1 +rmnx034 remaindernear 1 32 -> 1 +rmnx035 remaindernear 1 64 -> 1 +rmnx040 remaindernear 1 -2 -> 1 +rmnx041 remaindernear 1 -4 -> 1 +rmnx042 remaindernear 1 -8 -> 1 +rmnx043 remaindernear 1 -16 -> 1 +rmnx044 remaindernear 1 -32 -> 1 +rmnx045 remaindernear 1 -64 -> 1 +rmnx050 remaindernear -1 2 -> -1 +rmnx051 remaindernear -1 4 -> -1 +rmnx052 remaindernear -1 8 -> -1 +rmnx053 remaindernear -1 16 -> -1 +rmnx054 remaindernear -1 32 -> -1 +rmnx055 remaindernear -1 64 -> -1 +rmnx060 remaindernear -1 -2 -> -1 +rmnx061 remaindernear -1 -4 -> -1 +rmnx062 remaindernear -1 -8 -> -1 +rmnx063 remaindernear -1 -16 -> -1 +rmnx064 remaindernear -1 -32 -> -1 +rmnx065 remaindernear -1 -64 -> -1 + +rmnx066 remaindernear 999999997 1 -> 0 +rmnx067 remaindernear 999999997.4 1 -> 0.4 +rmnx068 remaindernear 999999997.5 1 -> -0.5 +rmnx069 remaindernear 999999997.9 1 -> -0.1 +rmnx070 remaindernear 999999997.999 1 -> -0.001 + +rmnx071 remaindernear 999999998 1 -> 0 +rmnx072 remaindernear 999999998.4 1 -> 0.4 +rmnx073 remaindernear 999999998.5 1 -> 0.5 +rmnx074 remaindernear 999999998.9 1 -> -0.1 +rmnx075 remaindernear 999999998.999 1 -> -0.001 + +rmnx076 remaindernear 999999999 1 -> 0 +rmnx077 remaindernear 999999999.4 1 -> 0.4 +rmnx078 remaindernear 999999999.5 1 -> NaN Division_impossible +rmnx079 remaindernear 999999999.9 1 -> NaN Division_impossible +rmnx080 remaindernear 999999999.999 1 -> NaN Division_impossible + +precision: 6 +rmnx081 remaindernear 999999999 1 -> NaN Division_impossible +rmnx082 remaindernear 99999999 1 -> NaN Division_impossible +rmnx083 remaindernear 9999999 1 -> NaN Division_impossible +rmnx084 remaindernear 999999 1 -> 0 +rmnx085 remaindernear 99999 1 -> 0 +rmnx086 remaindernear 9999 1 -> 0 +rmnx087 remaindernear 999 1 -> 0 +rmnx088 remaindernear 99 1 -> 0 +rmnx089 remaindernear 9 1 -> 0 + +precision: 9 +rmnx090 remaindernear 0. 1 -> 0 +rmnx091 remaindernear .0 1 -> 0.0 +rmnx092 remaindernear 0.00 1 -> 0.00 +rmnx093 remaindernear 0.00E+9 1 -> 0 +rmnx094 remaindernear 0.0000E-50 1 -> 0E-54 + + +-- Various flavours of remaindernear by 0 +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +rmnx101 remaindernear 0 0 -> NaN Division_undefined +rmnx102 remaindernear 0 -0 -> NaN Division_undefined +rmnx103 remaindernear -0 0 -> NaN Division_undefined +rmnx104 remaindernear -0 -0 -> NaN Division_undefined +rmnx105 remaindernear 0.0E5 0 -> NaN Division_undefined +rmnx106 remaindernear 0.000 0 -> NaN Division_undefined +-- [Some think this next group should be Division_by_zero exception, +-- but IEEE 854 is explicit that it is Invalid operation .. for +-- remaindernear-near, anyway] +rmnx107 remaindernear 0.0001 0 -> NaN Invalid_operation +rmnx108 remaindernear 0.01 0 -> NaN Invalid_operation +rmnx109 remaindernear 0.1 0 -> NaN Invalid_operation +rmnx110 remaindernear 1 0 -> NaN Invalid_operation +rmnx111 remaindernear 1 0.0 -> NaN Invalid_operation +rmnx112 remaindernear 10 0.0 -> NaN Invalid_operation +rmnx113 remaindernear 1E+100 0.0 -> NaN Invalid_operation +rmnx114 remaindernear 1E+1000 0 -> NaN Invalid_operation +rmnx115 remaindernear 0.0001 -0 -> NaN Invalid_operation +rmnx116 remaindernear 0.01 -0 -> NaN Invalid_operation +rmnx119 remaindernear 0.1 -0 -> NaN Invalid_operation +rmnx120 remaindernear 1 -0 -> NaN Invalid_operation +rmnx121 remaindernear 1 -0.0 -> NaN Invalid_operation +rmnx122 remaindernear 10 -0.0 -> NaN Invalid_operation +rmnx123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation +rmnx124 remaindernear 1E+1000 -0 -> NaN Invalid_operation +-- and zeros on left +rmnx130 remaindernear 0 1 -> 0 +rmnx131 remaindernear 0 -1 -> 0 +rmnx132 remaindernear 0.0 1 -> 0.0 +rmnx133 remaindernear 0.0 -1 -> 0.0 +rmnx134 remaindernear -0 1 -> -0 +rmnx135 remaindernear -0 -1 -> -0 +rmnx136 remaindernear -0.0 1 -> -0.0 +rmnx137 remaindernear -0.0 -1 -> -0.0 + +-- 0.5ers +rmmx143 remaindernear 0.5 2 -> 0.5 +rmmx144 remaindernear 0.5 2.1 -> 0.5 +rmmx145 remaindernear 0.5 2.01 -> 0.50 +rmmx146 remaindernear 0.5 2.001 -> 0.500 +rmmx147 remaindernear 0.50 2 -> 0.50 +rmmx148 remaindernear 0.50 2.01 -> 0.50 +rmmx149 remaindernear 0.50 2.001 -> 0.500 + +-- some differences from remainder +rmnx150 remaindernear 0.4 1.020 -> 0.400 +rmnx151 remaindernear 0.50 1.020 -> 0.500 +rmnx152 remaindernear 0.51 1.020 -> 0.510 +rmnx153 remaindernear 0.52 1.020 -> -0.500 +rmnx154 remaindernear 0.6 1.020 -> -0.420 +rmnx155 remaindernear 0.49 1 -> 0.49 +rmnx156 remaindernear 0.50 1 -> 0.50 +rmnx157 remaindernear 1.50 1 -> -0.50 +rmnx158 remaindernear 2.50 1 -> 0.50 +rmnx159 remaindernear 9.50 1 -> -0.50 +rmnx160 remaindernear 0.51 1 -> -0.49 + +-- the nasty division-by-1 cases +rmnx161 remaindernear 0.4 1 -> 0.4 +rmnx162 remaindernear 0.45 1 -> 0.45 +rmnx163 remaindernear 0.455 1 -> 0.455 +rmnx164 remaindernear 0.4555 1 -> 0.4555 +rmnx165 remaindernear 0.45555 1 -> 0.45555 +rmnx166 remaindernear 0.455555 1 -> 0.455555 +rmnx167 remaindernear 0.4555555 1 -> 0.4555555 +rmnx168 remaindernear 0.45555555 1 -> 0.45555555 +rmnx169 remaindernear 0.455555555 1 -> 0.455555555 +-- with spill... +rmnx171 remaindernear 0.5 1 -> 0.5 +rmnx172 remaindernear 0.55 1 -> -0.45 +rmnx173 remaindernear 0.555 1 -> -0.445 +rmnx174 remaindernear 0.5555 1 -> -0.4445 +rmnx175 remaindernear 0.55555 1 -> -0.44445 +rmnx176 remaindernear 0.555555 1 -> -0.444445 +rmnx177 remaindernear 0.5555555 1 -> -0.4444445 +rmnx178 remaindernear 0.55555555 1 -> -0.44444445 +rmnx179 remaindernear 0.555555555 1 -> -0.444444445 + +-- progression +rmnx180 remaindernear 1 1 -> 0 +rmnx181 remaindernear 1 2 -> 1 +rmnx182 remaindernear 1 3 -> 1 +rmnx183 remaindernear 1 4 -> 1 +rmnx184 remaindernear 1 5 -> 1 +rmnx185 remaindernear 1 6 -> 1 +rmnx186 remaindernear 1 7 -> 1 +rmnx187 remaindernear 1 8 -> 1 +rmnx188 remaindernear 1 9 -> 1 +rmnx189 remaindernear 1 10 -> 1 +rmnx190 remaindernear 1 1 -> 0 +rmnx191 remaindernear 2 1 -> 0 +rmnx192 remaindernear 3 1 -> 0 +rmnx193 remaindernear 4 1 -> 0 +rmnx194 remaindernear 5 1 -> 0 +rmnx195 remaindernear 6 1 -> 0 +rmnx196 remaindernear 7 1 -> 0 +rmnx197 remaindernear 8 1 -> 0 +rmnx198 remaindernear 9 1 -> 0 +rmnx199 remaindernear 10 1 -> 0 + + +-- Various flavours of remaindernear by 0 +maxexponent: 999999999 +minexponent: -999999999 +rmnx201 remaindernear 0 0 -> NaN Division_undefined +rmnx202 remaindernear 0.0E5 0 -> NaN Division_undefined +rmnx203 remaindernear 0.000 0 -> NaN Division_undefined +rmnx204 remaindernear 0.0001 0 -> NaN Invalid_operation +rmnx205 remaindernear 0.01 0 -> NaN Invalid_operation +rmnx206 remaindernear 0.1 0 -> NaN Invalid_operation +rmnx207 remaindernear 1 0 -> NaN Invalid_operation +rmnx208 remaindernear 1 0.0 -> NaN Invalid_operation +rmnx209 remaindernear 10 0.0 -> NaN Invalid_operation +rmnx210 remaindernear 1E+100 0.0 -> NaN Invalid_operation +rmnx211 remaindernear 1E+1000 0 -> NaN Invalid_operation + +-- tests from the extended specification +rmnx221 remaindernear 2.1 3 -> -0.9 +rmnx222 remaindernear 10 6 -> -2 +rmnx223 remaindernear 10 3 -> 1 +rmnx224 remaindernear -10 3 -> -1 +rmnx225 remaindernear 10.2 1 -> 0.2 +rmnx226 remaindernear 10 0.3 -> 0.1 +rmnx227 remaindernear 3.6 1.3 -> -0.3 + +-- some differences from remainder +rmnx231 remaindernear 0.4 1.020 -> 0.400 +rmnx232 remaindernear 0.50 1.020 -> 0.500 +rmnx233 remaindernear 0.51 1.020 -> 0.510 +rmnx234 remaindernear 0.52 1.020 -> -0.500 +rmnx235 remaindernear 0.6 1.020 -> -0.420 + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +rmnx270 remaindernear 1 1e999999999 -> 1 +rmnx271 remaindernear 1 0.9e999999999 -> 1 +rmnx272 remaindernear 1 0.99e999999999 -> 1 +rmnx273 remaindernear 1 0.999999999e999999999 -> 1 +rmnx274 remaindernear 9e999999999 1 -> NaN Division_impossible +rmnx275 remaindernear 9.9e999999999 1 -> NaN Division_impossible +rmnx276 remaindernear 9.99e999999999 1 -> NaN Division_impossible +rmnx277 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible + +rmnx280 remaindernear 0.1 9e-999999999 -> NaN Division_impossible +rmnx281 remaindernear 0.1 99e-999999999 -> NaN Division_impossible +rmnx282 remaindernear 0.1 999e-999999999 -> NaN Division_impossible + +rmnx283 remaindernear 0.1 9e-999999998 -> NaN Division_impossible +rmnx284 remaindernear 0.1 99e-999999998 -> NaN Division_impossible +rmnx285 remaindernear 0.1 999e-999999998 -> NaN Division_impossible +rmnx286 remaindernear 0.1 999e-999999997 -> NaN Division_impossible +rmnx287 remaindernear 0.1 9999e-999999997 -> NaN Division_impossible +rmnx288 remaindernear 0.1 99999e-999999997 -> NaN Division_impossible + +-- rmnx3xx are from DiagBigDecimal +rmnx301 remaindernear 1 3 -> 1 +rmnx302 remaindernear 5 5 -> 0 +rmnx303 remaindernear 13 10 -> 3 +rmnx304 remaindernear 13 50 -> 13 +rmnx305 remaindernear 13 100 -> 13 +rmnx306 remaindernear 13 1000 -> 13 +rmnx307 remaindernear .13 1 -> 0.13 +rmnx308 remaindernear 0.133 1 -> 0.133 +rmnx309 remaindernear 0.1033 1 -> 0.1033 +rmnx310 remaindernear 1.033 1 -> 0.033 +rmnx311 remaindernear 10.33 1 -> 0.33 +rmnx312 remaindernear 10.33 10 -> 0.33 +rmnx313 remaindernear 103.3 1 -> 0.3 +rmnx314 remaindernear 133 10 -> 3 +rmnx315 remaindernear 1033 10 -> 3 +rmnx316 remaindernear 1033 50 -> -17 +rmnx317 remaindernear 101.0 3 -> -1.0 +rmnx318 remaindernear 102.0 3 -> 0.0 +rmnx319 remaindernear 103.0 3 -> 1.0 +rmnx320 remaindernear 2.40 1 -> 0.40 +rmnx321 remaindernear 2.400 1 -> 0.400 +rmnx322 remaindernear 2.4 1 -> 0.4 +rmnx323 remaindernear 2.4 2 -> 0.4 +rmnx324 remaindernear 2.400 2 -> 0.400 +rmnx325 remaindernear 1 0.3 -> 0.1 +rmnx326 remaindernear 1 0.30 -> 0.10 +rmnx327 remaindernear 1 0.300 -> 0.100 +rmnx328 remaindernear 1 0.3000 -> 0.1000 +rmnx329 remaindernear 1.0 0.3 -> 0.1 +rmnx330 remaindernear 1.00 0.3 -> 0.10 +rmnx331 remaindernear 1.000 0.3 -> 0.100 +rmnx332 remaindernear 1.0000 0.3 -> 0.1000 +rmnx333 remaindernear 0.5 2 -> 0.5 +rmnx334 remaindernear 0.5 2.1 -> 0.5 +rmnx335 remaindernear 0.5 2.01 -> 0.50 +rmnx336 remaindernear 0.5 2.001 -> 0.500 +rmnx337 remaindernear 0.50 2 -> 0.50 +rmnx338 remaindernear 0.50 2.01 -> 0.50 +rmnx339 remaindernear 0.50 2.001 -> 0.500 + +rmnx340 remaindernear 0.5 0.5000001 -> -1E-7 +rmnx341 remaindernear 0.5 0.50000001 -> -1E-8 +rmnx342 remaindernear 0.5 0.500000001 -> -1E-9 +rmnx343 remaindernear 0.5 0.5000000001 -> -1E-10 +rmnx344 remaindernear 0.5 0.50000000001 -> -1E-11 +rmnx345 remaindernear 0.5 0.4999999 -> 1E-7 +rmnx346 remaindernear 0.5 0.49999999 -> 1E-8 +rmnx347 remaindernear 0.5 0.499999999 -> 1E-9 +rmnx348 remaindernear 0.5 0.4999999999 -> 1E-10 +rmnx349 remaindernear 0.5 0.49999999999 -> 1E-11 + +rmnx350 remaindernear 0.03 7 -> 0.03 +rmnx351 remaindernear 5 2 -> 1 +rmnx352 remaindernear 4.1 2 -> 0.1 +rmnx353 remaindernear 4.01 2 -> 0.01 +rmnx354 remaindernear 4.001 2 -> 0.001 +rmnx355 remaindernear 4.0001 2 -> 0.0001 +rmnx356 remaindernear 4.00001 2 -> 0.00001 +rmnx357 remaindernear 4.000001 2 -> 0.000001 +rmnx358 remaindernear 4.0000001 2 -> 1E-7 + +rmnx360 remaindernear 1.2 0.7345 -> -0.2690 +rmnx361 remaindernear 0.8 12 -> 0.8 +rmnx362 remaindernear 0.8 0.2 -> 0.0 +rmnx363 remaindernear 0.8 0.3 -> -0.1 +rmnx364 remaindernear 0.800 12 -> 0.800 +rmnx365 remaindernear 0.800 1.7 -> 0.800 +rmnx366 remaindernear 2.400 2 -> 0.400 + +precision: 6 +rmnx371 remaindernear 2.400 2 -> 0.400 +precision: 3 +rmnx372 remaindernear 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded + +precision: 5 +rmnx381 remaindernear 12345 1 -> 0 +rmnx382 remaindernear 12345 1.0001 -> -0.2344 +rmnx383 remaindernear 12345 1.001 -> -0.333 +rmnx384 remaindernear 12345 1.01 -> -0.23 +rmnx385 remaindernear 12345 1.1 -> -0.3 +rmnx386 remaindernear 12355 4 -> -1 +rmnx387 remaindernear 12345 4 -> 1 +rmnx388 remaindernear 12355 4.0001 -> -1.3089 +rmnx389 remaindernear 12345 4.0001 -> 0.6914 +rmnx390 remaindernear 12345 4.9 -> 1.9 +rmnx391 remaindernear 12345 4.99 -> -0.26 +rmnx392 remaindernear 12345 4.999 -> 2.469 +rmnx393 remaindernear 12345 4.9999 -> 0.2469 +rmnx394 remaindernear 12345 5 -> 0 +rmnx395 remaindernear 12345 5.0001 -> -0.2469 +rmnx396 remaindernear 12345 5.001 -> -2.469 +rmnx397 remaindernear 12345 5.01 -> 0.36 +rmnx398 remaindernear 12345 5.1 -> -2.1 + +precision: 9 +-- some nasty division-by-1 cases [some similar above] +rmnx401 remaindernear 0.4 1 -> 0.4 +rmnx402 remaindernear 0.45 1 -> 0.45 +rmnx403 remaindernear 0.455 1 -> 0.455 +rmnx404 remaindernear 0.4555 1 -> 0.4555 +rmnx405 remaindernear 0.45555 1 -> 0.45555 +rmnx406 remaindernear 0.455555 1 -> 0.455555 +rmnx407 remaindernear 0.4555555 1 -> 0.4555555 +rmnx408 remaindernear 0.45555555 1 -> 0.45555555 +rmnx409 remaindernear 0.455555555 1 -> 0.455555555 + +-- some tricky LHSs +rmnx420 remaindernear 99999999.999999999 1E+8 -> -1E-9 +rmnx421 remaindernear 999999999.999999999 1E+9 -> -1E-9 +precision: 9 +rmnx430 remaindernear 0.455555555 1 -> 0.455555555 +precision: 8 +rmnx431 remaindernear 0.455555555 1 -> 0.45555556 Inexact Rounded +precision: 7 +rmnx432 remaindernear 0.455555555 1 -> 0.4555556 Inexact Rounded +precision: 6 +rmnx433 remaindernear 0.455555555 1 -> 0.455556 Inexact Rounded +precision: 5 +rmnx434 remaindernear 0.455555555 1 -> 0.45556 Inexact Rounded +precision: 4 +rmnx435 remaindernear 0.455555555 1 -> 0.4556 Inexact Rounded +precision: 3 +rmnx436 remaindernear 0.455555555 1 -> 0.456 Inexact Rounded +precision: 2 +rmnx437 remaindernear 0.455555555 1 -> 0.46 Inexact Rounded +precision: 1 +rmnx438 remaindernear 0.455555555 1 -> 0.5 Inexact Rounded + +-- early tests; from text descriptions +precision: 9 +rmnx601 remaindernear 10 6 -> -2 +rmnx602 remaindernear -10 6 -> 2 +rmnx603 remaindernear 11 3 -> -1 +rmnx604 remaindernear 11 5 -> 1 +rmnx605 remaindernear 7.7 8 -> -0.3 +rmnx606 remaindernear 31.5 3 -> 1.5 -- i=10 +rmnx607 remaindernear 34.5 3 -> -1.5 -- i=11 + +-- Specials +rmnx680 remaindernear Inf -Inf -> NaN Invalid_operation +rmnx681 remaindernear Inf -1000 -> NaN Invalid_operation +rmnx682 remaindernear Inf -1 -> NaN Invalid_operation +rmnx683 remaindernear Inf 0 -> NaN Invalid_operation +rmnx684 remaindernear Inf -0 -> NaN Invalid_operation +rmnx685 remaindernear Inf 1 -> NaN Invalid_operation +rmnx686 remaindernear Inf 1000 -> NaN Invalid_operation +rmnx687 remaindernear Inf Inf -> NaN Invalid_operation +rmnx688 remaindernear -1000 Inf -> -1000 +rmnx689 remaindernear -Inf Inf -> NaN Invalid_operation +rmnx691 remaindernear -1 Inf -> -1 +rmnx692 remaindernear 0 Inf -> 0 +rmnx693 remaindernear -0 Inf -> -0 +rmnx694 remaindernear 1 Inf -> 1 +rmnx695 remaindernear 1000 Inf -> 1000 +rmnx696 remaindernear Inf Inf -> NaN Invalid_operation + +rmnx700 remaindernear -Inf -Inf -> NaN Invalid_operation +rmnx701 remaindernear -Inf -1000 -> NaN Invalid_operation +rmnx702 remaindernear -Inf -1 -> NaN Invalid_operation +rmnx703 remaindernear -Inf -0 -> NaN Invalid_operation +rmnx704 remaindernear -Inf 0 -> NaN Invalid_operation +rmnx705 remaindernear -Inf 1 -> NaN Invalid_operation +rmnx706 remaindernear -Inf 1000 -> NaN Invalid_operation +rmnx707 remaindernear -Inf Inf -> NaN Invalid_operation +rmnx708 remaindernear -Inf -Inf -> NaN Invalid_operation +rmnx709 remaindernear -1000 Inf -> -1000 +rmnx710 remaindernear -1 -Inf -> -1 +rmnx711 remaindernear -0 -Inf -> -0 +rmnx712 remaindernear 0 -Inf -> 0 +rmnx713 remaindernear 1 -Inf -> 1 +rmnx714 remaindernear 1000 -Inf -> 1000 +rmnx715 remaindernear Inf -Inf -> NaN Invalid_operation + +rmnx721 remaindernear NaN -Inf -> NaN +rmnx722 remaindernear NaN -1000 -> NaN +rmnx723 remaindernear NaN -1 -> NaN +rmnx724 remaindernear NaN -0 -> NaN +rmnx725 remaindernear NaN 0 -> NaN +rmnx726 remaindernear NaN 1 -> NaN +rmnx727 remaindernear NaN 1000 -> NaN +rmnx728 remaindernear NaN Inf -> NaN +rmnx729 remaindernear NaN NaN -> NaN +rmnx730 remaindernear -Inf NaN -> NaN +rmnx731 remaindernear -1000 NaN -> NaN +rmnx732 remaindernear -1 -NaN -> -NaN +rmnx733 remaindernear -0 NaN -> NaN +rmnx734 remaindernear 0 NaN -> NaN +rmnx735 remaindernear 1 NaN -> NaN +rmnx736 remaindernear 1000 NaN -> NaN +rmnx737 remaindernear Inf NaN -> NaN + +rmnx741 remaindernear sNaN -Inf -> NaN Invalid_operation +rmnx742 remaindernear sNaN -1000 -> NaN Invalid_operation +rmnx743 remaindernear -sNaN -1 -> -NaN Invalid_operation +rmnx744 remaindernear sNaN -0 -> NaN Invalid_operation +rmnx745 remaindernear sNaN 0 -> NaN Invalid_operation +rmnx746 remaindernear sNaN 1 -> NaN Invalid_operation +rmnx747 remaindernear sNaN 1000 -> NaN Invalid_operation +rmnx749 remaindernear sNaN NaN -> NaN Invalid_operation +rmnx750 remaindernear sNaN sNaN -> NaN Invalid_operation +rmnx751 remaindernear NaN sNaN -> NaN Invalid_operation +rmnx752 remaindernear -Inf sNaN -> NaN Invalid_operation +rmnx753 remaindernear -1000 sNaN -> NaN Invalid_operation +rmnx754 remaindernear -1 sNaN -> NaN Invalid_operation +rmnx755 remaindernear -0 -sNaN -> -NaN Invalid_operation +rmnx756 remaindernear 0 sNaN -> NaN Invalid_operation +rmnx757 remaindernear 1 sNaN -> NaN Invalid_operation +rmnx758 remaindernear 1000 sNaN -> NaN Invalid_operation +rmnx759 remaindernear Inf sNaN -> NaN Invalid_operation +rmnx760 remaindernear NaN sNaN -> NaN Invalid_operation + +-- propaging NaNs +rmnx761 remaindernear NaN1 NaN7 -> NaN1 +rmnx762 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation +rmnx763 remaindernear NaN3 -sNaN9 -> -NaN9 Invalid_operation +rmnx764 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation +rmnx765 remaindernear 15 NaN11 -> NaN11 +rmnx766 remaindernear NaN6 NaN12 -> NaN6 +rmnx767 remaindernear Inf -NaN13 -> -NaN13 +rmnx768 remaindernear NaN14 -Inf -> NaN14 +rmnx769 remaindernear 0 NaN15 -> NaN15 +rmnx770 remaindernear -NaN16 -0 -> -NaN16 + +-- test some cases that are close to exponent overflow +maxexponent: 999999999 +minexponent: -999999999 +rmnx780 remaindernear 1 1e999999999 -> 1 +rmnx781 remaindernear 1 0.9e999999999 -> 1 +rmnx782 remaindernear 1 0.99e999999999 -> 1 +rmnx783 remaindernear 1 0.999999999e999999999 -> 1 +rmnx784 remaindernear 9e999999999 1 -> NaN Division_impossible +rmnx785 remaindernear 9.9e999999999 1 -> NaN Division_impossible +rmnx786 remaindernear 9.99e999999999 1 -> NaN Division_impossible +rmnx787 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible + + +-- overflow and underflow tests [from divide] +precision: 9 +maxexponent: 999999999 +minexponent: -999999999 +rmnx790 remaindernear +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded +rmnx791 remaindernear 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible +rmnx792 remaindernear +0.100 9E+999999999 -> 0.100 +rmnx793 remaindernear 9E-999999999 +9.100 -> 9E-999999999 +rmnx795 remaindernear -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded +rmnx796 remaindernear 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible +rmnx797 remaindernear -0.100 9E+999999999 -> -0.100 +rmnx798 remaindernear 9E-999999999 -9.100 -> 9E-999999999 + +-- long operands checks +maxexponent: 999 +minexponent: -999 +precision: 9 +rmnx801 remaindernear 12345678000 100 -> 0 +rmnx802 remaindernear 1 12345678000 -> 1 +rmnx803 remaindernear 1234567800 10 -> 0 +rmnx804 remaindernear 1 1234567800 -> 1 +rmnx805 remaindernear 1234567890 10 -> 0 +rmnx806 remaindernear 1 1234567890 -> 1 +rmnx807 remaindernear 1234567891 10 -> 1 +rmnx808 remaindernear 1 1234567891 -> 1 +rmnx809 remaindernear 12345678901 100 -> 1 +rmnx810 remaindernear 1 12345678901 -> 1 +rmnx811 remaindernear 1234567896 10 -> -4 +rmnx812 remaindernear 1 1234567896 -> 1 + +precision: 15 +rmnx841 remaindernear 12345678000 100 -> 0 +rmnx842 remaindernear 1 12345678000 -> 1 +rmnx843 remaindernear 1234567800 10 -> 0 +rmnx844 remaindernear 1 1234567800 -> 1 +rmnx845 remaindernear 1234567890 10 -> 0 +rmnx846 remaindernear 1 1234567890 -> 1 +rmnx847 remaindernear 1234567891 10 -> 1 +rmnx848 remaindernear 1 1234567891 -> 1 +rmnx849 remaindernear 12345678901 100 -> 1 +rmnx850 remaindernear 1 12345678901 -> 1 +rmnx851 remaindernear 1234567896 10 -> -4 +rmnx852 remaindernear 1 1234567896 -> 1 + +-- Null tests +rmnx900 remaindernear 10 # -> NaN Invalid_operation +rmnx901 remaindernear # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/rescale.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/rescale.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,758 @@ +------------------------------------------------------------------------ +-- rescale.decTest -- decimal rescale operation -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- [obsolete] Quantize.decTest has the improved version + +-- 2004.03.15 Underflow for quantize is suppressed + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minexponent: -999 + +-- sanity checks + +resx001 rescale 0 0 -> 0 +resx002 rescale 1 0 -> 1 +resx003 rescale 0.1 +2 -> 0E+2 Inexact Rounded +resx005 rescale 0.1 +1 -> 0E+1 Inexact Rounded +resx006 rescale 0.1 0 -> 0 Inexact Rounded +resx007 rescale 0.1 -1 -> 0.1 +resx008 rescale 0.1 -2 -> 0.10 +resx009 rescale 0.1 -3 -> 0.100 +resx010 rescale 0.9 +2 -> 0E+2 Inexact Rounded +resx011 rescale 0.9 +1 -> 0E+1 Inexact Rounded +resx012 rescale 0.9 +0 -> 1 Inexact Rounded +resx013 rescale 0.9 -1 -> 0.9 +resx014 rescale 0.9 -2 -> 0.90 +resx015 rescale 0.9 -3 -> 0.900 +-- negatives +resx021 rescale -0 0 -> -0 +resx022 rescale -1 0 -> -1 +resx023 rescale -0.1 +2 -> -0E+2 Inexact Rounded +resx025 rescale -0.1 +1 -> -0E+1 Inexact Rounded +resx026 rescale -0.1 0 -> -0 Inexact Rounded +resx027 rescale -0.1 -1 -> -0.1 +resx028 rescale -0.1 -2 -> -0.10 +resx029 rescale -0.1 -3 -> -0.100 +resx030 rescale -0.9 +2 -> -0E+2 Inexact Rounded +resx031 rescale -0.9 +1 -> -0E+1 Inexact Rounded +resx032 rescale -0.9 +0 -> -1 Inexact Rounded +resx033 rescale -0.9 -1 -> -0.9 +resx034 rescale -0.9 -2 -> -0.90 +resx035 rescale -0.9 -3 -> -0.900 +resx036 rescale -0.5 +2 -> -0E+2 Inexact Rounded +resx037 rescale -0.5 +1 -> -0E+1 Inexact Rounded +resx038 rescale -0.5 +0 -> -1 Inexact Rounded +resx039 rescale -0.5 -1 -> -0.5 +resx040 rescale -0.5 -2 -> -0.50 +resx041 rescale -0.5 -3 -> -0.500 +resx042 rescale -0.9 +2 -> -0E+2 Inexact Rounded +resx043 rescale -0.9 +1 -> -0E+1 Inexact Rounded +resx044 rescale -0.9 +0 -> -1 Inexact Rounded +resx045 rescale -0.9 -1 -> -0.9 +resx046 rescale -0.9 -2 -> -0.90 +resx047 rescale -0.9 -3 -> -0.900 + +-- examples from Specification +resx060 rescale 2.17 -3 -> 2.170 +resx061 rescale 2.17 -2 -> 2.17 +resx062 rescale 2.17 -1 -> 2.2 Inexact Rounded +resx063 rescale 2.17 0 -> 2 Inexact Rounded +resx064 rescale 2.17 +1 -> 0E+1 Inexact Rounded +resx065 rescale 2 Inf -> NaN Invalid_operation +resx066 rescale -0.1 0 -> -0 Inexact Rounded +resx067 rescale -0 5 -> -0E+5 +resx068 rescale +35236450.6 -2 -> NaN Invalid_operation +resx069 rescale -35236450.6 -2 -> NaN Invalid_operation +resx070 rescale 217 -1 -> 217.0 +resx071 rescale 217 0 -> 217 +resx072 rescale 217 +1 -> 2.2E+2 Inexact Rounded +resx073 rescale 217 +2 -> 2E+2 Inexact Rounded + +-- general tests .. +resx089 rescale 12 +4 -> 0E+4 Inexact Rounded +resx090 rescale 12 +3 -> 0E+3 Inexact Rounded +resx091 rescale 12 +2 -> 0E+2 Inexact Rounded +resx092 rescale 12 +1 -> 1E+1 Inexact Rounded +resx093 rescale 1.2345 -2 -> 1.23 Inexact Rounded +resx094 rescale 1.2355 -2 -> 1.24 Inexact Rounded +resx095 rescale 1.2345 -6 -> 1.234500 +resx096 rescale 9.9999 -2 -> 10.00 Inexact Rounded +resx097 rescale 0.0001 -2 -> 0.00 Inexact Rounded +resx098 rescale 0.001 -2 -> 0.00 Inexact Rounded +resx099 rescale 0.009 -2 -> 0.01 Inexact Rounded +resx100 rescale 92 +2 -> 1E+2 Inexact Rounded + +resx101 rescale -1 0 -> -1 +resx102 rescale -1 -1 -> -1.0 +resx103 rescale -1 -2 -> -1.00 +resx104 rescale 0 0 -> 0 +resx105 rescale 0 -1 -> 0.0 +resx106 rescale 0 -2 -> 0.00 +resx107 rescale 0.00 0 -> 0 +resx108 rescale 0 +1 -> 0E+1 +resx109 rescale 0 +2 -> 0E+2 +resx110 rescale +1 0 -> 1 +resx111 rescale +1 -1 -> 1.0 +resx112 rescale +1 -2 -> 1.00 + +resx120 rescale 1.04 -3 -> 1.040 +resx121 rescale 1.04 -2 -> 1.04 +resx122 rescale 1.04 -1 -> 1.0 Inexact Rounded +resx123 rescale 1.04 0 -> 1 Inexact Rounded +resx124 rescale 1.05 -3 -> 1.050 +resx125 rescale 1.05 -2 -> 1.05 +resx126 rescale 1.05 -1 -> 1.1 Inexact Rounded +resx127 rescale 1.05 0 -> 1 Inexact Rounded +resx128 rescale 1.05 -3 -> 1.050 +resx129 rescale 1.05 -2 -> 1.05 +resx130 rescale 1.05 -1 -> 1.1 Inexact Rounded +resx131 rescale 1.05 0 -> 1 Inexact Rounded +resx132 rescale 1.06 -3 -> 1.060 +resx133 rescale 1.06 -2 -> 1.06 +resx134 rescale 1.06 -1 -> 1.1 Inexact Rounded +resx135 rescale 1.06 0 -> 1 Inexact Rounded + +resx140 rescale -10 -2 -> -10.00 +resx141 rescale +1 -2 -> 1.00 +resx142 rescale +10 -2 -> 10.00 +resx143 rescale 1E+10 -2 -> NaN Invalid_operation +resx144 rescale 1E-10 -2 -> 0.00 Inexact Rounded +resx145 rescale 1E-3 -2 -> 0.00 Inexact Rounded +resx146 rescale 1E-2 -2 -> 0.01 +resx147 rescale 1E-1 -2 -> 0.10 +resx148 rescale 0E-10 -2 -> 0.00 + +resx150 rescale 1.0600 -5 -> 1.06000 +resx151 rescale 1.0600 -4 -> 1.0600 +resx152 rescale 1.0600 -3 -> 1.060 Rounded +resx153 rescale 1.0600 -2 -> 1.06 Rounded +resx154 rescale 1.0600 -1 -> 1.1 Inexact Rounded +resx155 rescale 1.0600 0 -> 1 Inexact Rounded + +-- +ve exponents .. +resx201 rescale -1 +0 -> -1 +resx202 rescale -1 +1 -> -0E+1 Inexact Rounded +resx203 rescale -1 +2 -> -0E+2 Inexact Rounded +resx204 rescale 0 +0 -> 0 +resx205 rescale 0 +1 -> 0E+1 +resx206 rescale 0 +2 -> 0E+2 +resx207 rescale +1 +0 -> 1 +resx208 rescale +1 +1 -> 0E+1 Inexact Rounded +resx209 rescale +1 +2 -> 0E+2 Inexact Rounded + +resx220 rescale 1.04 +3 -> 0E+3 Inexact Rounded +resx221 rescale 1.04 +2 -> 0E+2 Inexact Rounded +resx222 rescale 1.04 +1 -> 0E+1 Inexact Rounded +resx223 rescale 1.04 +0 -> 1 Inexact Rounded +resx224 rescale 1.05 +3 -> 0E+3 Inexact Rounded +resx225 rescale 1.05 +2 -> 0E+2 Inexact Rounded +resx226 rescale 1.05 +1 -> 0E+1 Inexact Rounded +resx227 rescale 1.05 +0 -> 1 Inexact Rounded +resx228 rescale 1.05 +3 -> 0E+3 Inexact Rounded +resx229 rescale 1.05 +2 -> 0E+2 Inexact Rounded +resx230 rescale 1.05 +1 -> 0E+1 Inexact Rounded +resx231 rescale 1.05 +0 -> 1 Inexact Rounded +resx232 rescale 1.06 +3 -> 0E+3 Inexact Rounded +resx233 rescale 1.06 +2 -> 0E+2 Inexact Rounded +resx234 rescale 1.06 +1 -> 0E+1 Inexact Rounded +resx235 rescale 1.06 +0 -> 1 Inexact Rounded + +resx240 rescale -10 +1 -> -1E+1 Rounded +resx241 rescale +1 +1 -> 0E+1 Inexact Rounded +resx242 rescale +10 +1 -> 1E+1 Rounded +resx243 rescale 1E+1 +1 -> 1E+1 -- underneath this is E+1 +resx244 rescale 1E+2 +1 -> 1.0E+2 -- underneath this is E+1 +resx245 rescale 1E+3 +1 -> 1.00E+3 -- underneath this is E+1 +resx246 rescale 1E+4 +1 -> 1.000E+4 -- underneath this is E+1 +resx247 rescale 1E+5 +1 -> 1.0000E+5 -- underneath this is E+1 +resx248 rescale 1E+6 +1 -> 1.00000E+6 -- underneath this is E+1 +resx249 rescale 1E+7 +1 -> 1.000000E+7 -- underneath this is E+1 +resx250 rescale 1E+8 +1 -> 1.0000000E+8 -- underneath this is E+1 +resx251 rescale 1E+9 +1 -> 1.00000000E+9 -- underneath this is E+1 +-- next one tries to add 9 zeros +resx252 rescale 1E+10 +1 -> NaN Invalid_operation +resx253 rescale 1E-10 +1 -> 0E+1 Inexact Rounded +resx254 rescale 1E-2 +1 -> 0E+1 Inexact Rounded +resx255 rescale 0E-10 +1 -> 0E+1 +resx256 rescale -0E-10 +1 -> -0E+1 +resx257 rescale -0E-1 +1 -> -0E+1 +resx258 rescale -0 +1 -> -0E+1 +resx259 rescale -0E+1 +1 -> -0E+1 + +resx260 rescale -10 +2 -> -0E+2 Inexact Rounded +resx261 rescale +1 +2 -> 0E+2 Inexact Rounded +resx262 rescale +10 +2 -> 0E+2 Inexact Rounded +resx263 rescale 1E+1 +2 -> 0E+2 Inexact Rounded +resx264 rescale 1E+2 +2 -> 1E+2 +resx265 rescale 1E+3 +2 -> 1.0E+3 +resx266 rescale 1E+4 +2 -> 1.00E+4 +resx267 rescale 1E+5 +2 -> 1.000E+5 +resx268 rescale 1E+6 +2 -> 1.0000E+6 +resx269 rescale 1E+7 +2 -> 1.00000E+7 +resx270 rescale 1E+8 +2 -> 1.000000E+8 +resx271 rescale 1E+9 +2 -> 1.0000000E+9 +resx272 rescale 1E+10 +2 -> 1.00000000E+10 +resx273 rescale 1E-10 +2 -> 0E+2 Inexact Rounded +resx274 rescale 1E-2 +2 -> 0E+2 Inexact Rounded +resx275 rescale 0E-10 +2 -> 0E+2 + +resx280 rescale -10 +3 -> -0E+3 Inexact Rounded +resx281 rescale +1 +3 -> 0E+3 Inexact Rounded +resx282 rescale +10 +3 -> 0E+3 Inexact Rounded +resx283 rescale 1E+1 +3 -> 0E+3 Inexact Rounded +resx284 rescale 1E+2 +3 -> 0E+3 Inexact Rounded +resx285 rescale 1E+3 +3 -> 1E+3 +resx286 rescale 1E+4 +3 -> 1.0E+4 +resx287 rescale 1E+5 +3 -> 1.00E+5 +resx288 rescale 1E+6 +3 -> 1.000E+6 +resx289 rescale 1E+7 +3 -> 1.0000E+7 +resx290 rescale 1E+8 +3 -> 1.00000E+8 +resx291 rescale 1E+9 +3 -> 1.000000E+9 +resx292 rescale 1E+10 +3 -> 1.0000000E+10 +resx293 rescale 1E-10 +3 -> 0E+3 Inexact Rounded +resx294 rescale 1E-2 +3 -> 0E+3 Inexact Rounded +resx295 rescale 0E-10 +3 -> 0E+3 + +-- round up from below [sign wrong in JIT compiler once] +resx300 rescale 0.0078 -5 -> 0.00780 +resx301 rescale 0.0078 -4 -> 0.0078 +resx302 rescale 0.0078 -3 -> 0.008 Inexact Rounded +resx303 rescale 0.0078 -2 -> 0.01 Inexact Rounded +resx304 rescale 0.0078 -1 -> 0.0 Inexact Rounded +resx305 rescale 0.0078 0 -> 0 Inexact Rounded +resx306 rescale 0.0078 +1 -> 0E+1 Inexact Rounded +resx307 rescale 0.0078 +2 -> 0E+2 Inexact Rounded + +resx310 rescale -0.0078 -5 -> -0.00780 +resx311 rescale -0.0078 -4 -> -0.0078 +resx312 rescale -0.0078 -3 -> -0.008 Inexact Rounded +resx313 rescale -0.0078 -2 -> -0.01 Inexact Rounded +resx314 rescale -0.0078 -1 -> -0.0 Inexact Rounded +resx315 rescale -0.0078 0 -> -0 Inexact Rounded +resx316 rescale -0.0078 +1 -> -0E+1 Inexact Rounded +resx317 rescale -0.0078 +2 -> -0E+2 Inexact Rounded + +resx320 rescale 0.078 -5 -> 0.07800 +resx321 rescale 0.078 -4 -> 0.0780 +resx322 rescale 0.078 -3 -> 0.078 +resx323 rescale 0.078 -2 -> 0.08 Inexact Rounded +resx324 rescale 0.078 -1 -> 0.1 Inexact Rounded +resx325 rescale 0.078 0 -> 0 Inexact Rounded +resx326 rescale 0.078 +1 -> 0E+1 Inexact Rounded +resx327 rescale 0.078 +2 -> 0E+2 Inexact Rounded + +resx330 rescale -0.078 -5 -> -0.07800 +resx331 rescale -0.078 -4 -> -0.0780 +resx332 rescale -0.078 -3 -> -0.078 +resx333 rescale -0.078 -2 -> -0.08 Inexact Rounded +resx334 rescale -0.078 -1 -> -0.1 Inexact Rounded +resx335 rescale -0.078 0 -> -0 Inexact Rounded +resx336 rescale -0.078 +1 -> -0E+1 Inexact Rounded +resx337 rescale -0.078 +2 -> -0E+2 Inexact Rounded + +resx340 rescale 0.78 -5 -> 0.78000 +resx341 rescale 0.78 -4 -> 0.7800 +resx342 rescale 0.78 -3 -> 0.780 +resx343 rescale 0.78 -2 -> 0.78 +resx344 rescale 0.78 -1 -> 0.8 Inexact Rounded +resx345 rescale 0.78 0 -> 1 Inexact Rounded +resx346 rescale 0.78 +1 -> 0E+1 Inexact Rounded +resx347 rescale 0.78 +2 -> 0E+2 Inexact Rounded + +resx350 rescale -0.78 -5 -> -0.78000 +resx351 rescale -0.78 -4 -> -0.7800 +resx352 rescale -0.78 -3 -> -0.780 +resx353 rescale -0.78 -2 -> -0.78 +resx354 rescale -0.78 -1 -> -0.8 Inexact Rounded +resx355 rescale -0.78 0 -> -1 Inexact Rounded +resx356 rescale -0.78 +1 -> -0E+1 Inexact Rounded +resx357 rescale -0.78 +2 -> -0E+2 Inexact Rounded + +resx360 rescale 7.8 -5 -> 7.80000 +resx361 rescale 7.8 -4 -> 7.8000 +resx362 rescale 7.8 -3 -> 7.800 +resx363 rescale 7.8 -2 -> 7.80 +resx364 rescale 7.8 -1 -> 7.8 +resx365 rescale 7.8 0 -> 8 Inexact Rounded +resx366 rescale 7.8 +1 -> 1E+1 Inexact Rounded +resx367 rescale 7.8 +2 -> 0E+2 Inexact Rounded +resx368 rescale 7.8 +3 -> 0E+3 Inexact Rounded + +resx370 rescale -7.8 -5 -> -7.80000 +resx371 rescale -7.8 -4 -> -7.8000 +resx372 rescale -7.8 -3 -> -7.800 +resx373 rescale -7.8 -2 -> -7.80 +resx374 rescale -7.8 -1 -> -7.8 +resx375 rescale -7.8 0 -> -8 Inexact Rounded +resx376 rescale -7.8 +1 -> -1E+1 Inexact Rounded +resx377 rescale -7.8 +2 -> -0E+2 Inexact Rounded +resx378 rescale -7.8 +3 -> -0E+3 Inexact Rounded + +-- some individuals +precision: 9 +resx380 rescale 352364.506 -2 -> 352364.51 Inexact Rounded +resx381 rescale 3523645.06 -2 -> 3523645.06 +resx382 rescale 35236450.6 -2 -> NaN Invalid_operation +resx383 rescale 352364506 -2 -> NaN Invalid_operation +resx384 rescale -352364.506 -2 -> -352364.51 Inexact Rounded +resx385 rescale -3523645.06 -2 -> -3523645.06 +resx386 rescale -35236450.6 -2 -> NaN Invalid_operation +resx387 rescale -352364506 -2 -> NaN Invalid_operation + +rounding: down +resx389 rescale 35236450.6 -2 -> NaN Invalid_operation +-- ? should that one instead have been: +-- resx389 rescale 35236450.6 -2 -> NaN Invalid_operation +rounding: half_up + +-- and a few more from e-mail discussions +precision: 7 +resx391 rescale 12.34567 -3 -> 12.346 Inexact Rounded +resx392 rescale 123.4567 -3 -> 123.457 Inexact Rounded +resx393 rescale 1234.567 -3 -> 1234.567 +resx394 rescale 12345.67 -3 -> NaN Invalid_operation +resx395 rescale 123456.7 -3 -> NaN Invalid_operation +resx396 rescale 1234567. -3 -> NaN Invalid_operation + +-- some 9999 round-up cases +precision: 9 +resx400 rescale 9.999 -5 -> 9.99900 +resx401 rescale 9.999 -4 -> 9.9990 +resx402 rescale 9.999 -3 -> 9.999 +resx403 rescale 9.999 -2 -> 10.00 Inexact Rounded +resx404 rescale 9.999 -1 -> 10.0 Inexact Rounded +resx405 rescale 9.999 0 -> 10 Inexact Rounded +resx406 rescale 9.999 1 -> 1E+1 Inexact Rounded +resx407 rescale 9.999 2 -> 0E+2 Inexact Rounded + +resx410 rescale 0.999 -5 -> 0.99900 +resx411 rescale 0.999 -4 -> 0.9990 +resx412 rescale 0.999 -3 -> 0.999 +resx413 rescale 0.999 -2 -> 1.00 Inexact Rounded +resx414 rescale 0.999 -1 -> 1.0 Inexact Rounded +resx415 rescale 0.999 0 -> 1 Inexact Rounded +resx416 rescale 0.999 1 -> 0E+1 Inexact Rounded + +resx420 rescale 0.0999 -5 -> 0.09990 +resx421 rescale 0.0999 -4 -> 0.0999 +resx422 rescale 0.0999 -3 -> 0.100 Inexact Rounded +resx423 rescale 0.0999 -2 -> 0.10 Inexact Rounded +resx424 rescale 0.0999 -1 -> 0.1 Inexact Rounded +resx425 rescale 0.0999 0 -> 0 Inexact Rounded +resx426 rescale 0.0999 1 -> 0E+1 Inexact Rounded + +resx430 rescale 0.00999 -5 -> 0.00999 +resx431 rescale 0.00999 -4 -> 0.0100 Inexact Rounded +resx432 rescale 0.00999 -3 -> 0.010 Inexact Rounded +resx433 rescale 0.00999 -2 -> 0.01 Inexact Rounded +resx434 rescale 0.00999 -1 -> 0.0 Inexact Rounded +resx435 rescale 0.00999 0 -> 0 Inexact Rounded +resx436 rescale 0.00999 1 -> 0E+1 Inexact Rounded + +resx440 rescale 0.000999 -5 -> 0.00100 Inexact Rounded +resx441 rescale 0.000999 -4 -> 0.0010 Inexact Rounded +resx442 rescale 0.000999 -3 -> 0.001 Inexact Rounded +resx443 rescale 0.000999 -2 -> 0.00 Inexact Rounded +resx444 rescale 0.000999 -1 -> 0.0 Inexact Rounded +resx445 rescale 0.000999 0 -> 0 Inexact Rounded +resx446 rescale 0.000999 1 -> 0E+1 Inexact Rounded + +precision: 8 +resx449 rescale 9.999E-15 -23 -> NaN Invalid_operation +resx450 rescale 9.999E-15 -22 -> 9.9990000E-15 +resx451 rescale 9.999E-15 -21 -> 9.999000E-15 +resx452 rescale 9.999E-15 -20 -> 9.99900E-15 +resx453 rescale 9.999E-15 -19 -> 9.9990E-15 +resx454 rescale 9.999E-15 -18 -> 9.999E-15 +resx455 rescale 9.999E-15 -17 -> 1.000E-14 Inexact Rounded +resx456 rescale 9.999E-15 -16 -> 1.00E-14 Inexact Rounded +resx457 rescale 9.999E-15 -15 -> 1.0E-14 Inexact Rounded +resx458 rescale 9.999E-15 -14 -> 1E-14 Inexact Rounded +resx459 rescale 9.999E-15 -13 -> 0E-13 Inexact Rounded +resx460 rescale 9.999E-15 -12 -> 0E-12 Inexact Rounded +resx461 rescale 9.999E-15 -11 -> 0E-11 Inexact Rounded +resx462 rescale 9.999E-15 -10 -> 0E-10 Inexact Rounded +resx463 rescale 9.999E-15 -9 -> 0E-9 Inexact Rounded +resx464 rescale 9.999E-15 -8 -> 0E-8 Inexact Rounded +resx465 rescale 9.999E-15 -7 -> 0E-7 Inexact Rounded +resx466 rescale 9.999E-15 -6 -> 0.000000 Inexact Rounded +resx467 rescale 9.999E-15 -5 -> 0.00000 Inexact Rounded +resx468 rescale 9.999E-15 -4 -> 0.0000 Inexact Rounded +resx469 rescale 9.999E-15 -3 -> 0.000 Inexact Rounded +resx470 rescale 9.999E-15 -2 -> 0.00 Inexact Rounded +resx471 rescale 9.999E-15 -1 -> 0.0 Inexact Rounded +resx472 rescale 9.999E-15 0 -> 0 Inexact Rounded +resx473 rescale 9.999E-15 1 -> 0E+1 Inexact Rounded + +-- long operand checks [rhs checks removed] +maxexponent: 999 +minexponent: -999 +precision: 9 +resx481 rescale 12345678000 +3 -> 1.2345678E+10 Rounded +resx482 rescale 1234567800 +1 -> 1.23456780E+9 Rounded +resx483 rescale 1234567890 +1 -> 1.23456789E+9 Rounded +resx484 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded +resx485 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded +resx486 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded +-- a potential double-round +resx487 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded +resx488 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded + +precision: 15 +resx491 rescale 12345678000 +3 -> 1.2345678E+10 Rounded +resx492 rescale 1234567800 +1 -> 1.23456780E+9 Rounded +resx493 rescale 1234567890 +1 -> 1.23456789E+9 Rounded +resx494 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded +resx495 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded +resx496 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded +resx497 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded +resx498 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded + +-- Zeros +resx500 rescale 0 1 -> 0E+1 +resx501 rescale 0 0 -> 0 +resx502 rescale 0 -1 -> 0.0 +resx503 rescale 0.0 -1 -> 0.0 +resx504 rescale 0.0 0 -> 0 +resx505 rescale 0.0 +1 -> 0E+1 +resx506 rescale 0E+1 -1 -> 0.0 +resx507 rescale 0E+1 0 -> 0 +resx508 rescale 0E+1 +1 -> 0E+1 +resx509 rescale -0 1 -> -0E+1 +resx510 rescale -0 0 -> -0 +resx511 rescale -0 -1 -> -0.0 +resx512 rescale -0.0 -1 -> -0.0 +resx513 rescale -0.0 0 -> -0 +resx514 rescale -0.0 +1 -> -0E+1 +resx515 rescale -0E+1 -1 -> -0.0 +resx516 rescale -0E+1 0 -> -0 +resx517 rescale -0E+1 +1 -> -0E+1 + +-- Suspicious RHS values +maxexponent: 999999999 +minexponent: -999999999 +precision: 15 +resx520 rescale 1.234 999999E+3 -> 0E+999999000 Inexact Rounded +resx521 rescale 123.456 999999E+3 -> 0E+999999000 Inexact Rounded +resx522 rescale 1.234 999999999 -> 0E+999999999 Inexact Rounded +resx523 rescale 123.456 999999999 -> 0E+999999999 Inexact Rounded +resx524 rescale 123.456 1000000000 -> NaN Invalid_operation +resx525 rescale 123.456 12345678903 -> NaN Invalid_operation +-- next four are "won't fit" overflows +resx526 rescale 1.234 -999999E+3 -> NaN Invalid_operation +resx527 rescale 123.456 -999999E+3 -> NaN Invalid_operation +resx528 rescale 1.234 -999999999 -> NaN Invalid_operation +resx529 rescale 123.456 -999999999 -> NaN Invalid_operation +resx530 rescale 123.456 -1000000014 -> NaN Invalid_operation +resx531 rescale 123.456 -12345678903 -> NaN Invalid_operation + +maxexponent: 999 +minexponent: -999 +precision: 15 +resx532 rescale 1.234E+999 999 -> 1E+999 Inexact Rounded +resx533 rescale 1.234E+998 999 -> 0E+999 Inexact Rounded +resx534 rescale 1.234 999 -> 0E+999 Inexact Rounded +resx535 rescale 1.234 1000 -> NaN Invalid_operation +resx536 rescale 1.234 5000 -> NaN Invalid_operation +resx537 rescale 0 -999 -> 0E-999 +-- next two are "won't fit" overflows +resx538 rescale 1.234 -999 -> NaN Invalid_operation +resx539 rescale 1.234 -1000 -> NaN Invalid_operation +resx540 rescale 1.234 -5000 -> NaN Invalid_operation +-- [more below] + +-- check bounds (lhs maybe out of range for destination, etc.) +precision: 7 +resx541 rescale 1E+999 +999 -> 1E+999 +resx542 rescale 1E+1000 +999 -> NaN Invalid_operation +resx543 rescale 1E+999 +1000 -> NaN Invalid_operation +resx544 rescale 1E-999 -999 -> 1E-999 +resx545 rescale 1E-1000 -999 -> 0E-999 Inexact Rounded +resx546 rescale 1E-999 -1000 -> 1.0E-999 +resx547 rescale 1E-1005 -999 -> 0E-999 Inexact Rounded +resx548 rescale 1E-1006 -999 -> 0E-999 Inexact Rounded +resx549 rescale 1E-1007 -999 -> 0E-999 Inexact Rounded +resx550 rescale 1E-998 -1005 -> NaN Invalid_operation -- won't fit +resx551 rescale 1E-999 -1005 -> 1.000000E-999 +resx552 rescale 1E-1000 -1005 -> 1.00000E-1000 Subnormal +resx553 rescale 1E-999 -1006 -> NaN Invalid_operation +resx554 rescale 1E-999 -1007 -> NaN Invalid_operation +-- related subnormal rounding +resx555 rescale 1.666666E-999 -1005 -> 1.666666E-999 +resx556 rescale 1.666666E-1000 -1005 -> 1.66667E-1000 Subnormal Inexact Rounded +resx557 rescale 1.666666E-1001 -1005 -> 1.6667E-1001 Subnormal Inexact Rounded +resx558 rescale 1.666666E-1002 -1005 -> 1.667E-1002 Subnormal Inexact Rounded +resx559 rescale 1.666666E-1003 -1005 -> 1.67E-1003 Subnormal Inexact Rounded +resx560 rescale 1.666666E-1004 -1005 -> 1.7E-1004 Subnormal Inexact Rounded +resx561 rescale 1.666666E-1005 -1005 -> 2E-1005 Subnormal Inexact Rounded +resx562 rescale 1.666666E-1006 -1005 -> 0E-1005 Inexact Rounded +resx563 rescale 1.666666E-1007 -1005 -> 0E-1005 Inexact Rounded + +-- fractional RHS, some good and some bad +precision: 9 +resx564 rescale 222 +2.0 -> 2E+2 Inexact Rounded +resx565 rescale 222 +2.00000000 -> 2E+2 Inexact Rounded +resx566 rescale 222 +2.00100000000 -> NaN Invalid_operation +resx567 rescale 222 +2.000001 -> NaN Invalid_operation +resx568 rescale 222 +2.000000001 -> NaN Invalid_operation +resx569 rescale 222 +2.0000000001 -> NaN Invalid_operation +resx570 rescale 222 +2.00000000001 -> NaN Invalid_operation +resx571 rescale 222 +2.99999999999 -> NaN Invalid_operation +resx572 rescale 222 -2.00000000 -> 222.00 +resx573 rescale 222 -2.00100000000 -> NaN Invalid_operation +resx574 rescale 222 -2.0000001000 -> NaN Invalid_operation +resx575 rescale 222 -2.00000000001 -> NaN Invalid_operation +resx576 rescale 222 -2.99999999999 -> NaN Invalid_operation + +-- Specials +resx580 rescale Inf -Inf -> Infinity +resx581 rescale Inf -1000 -> NaN Invalid_operation +resx582 rescale Inf -1 -> NaN Invalid_operation +resx583 rescale Inf 0 -> NaN Invalid_operation +resx584 rescale Inf 1 -> NaN Invalid_operation +resx585 rescale Inf 1000 -> NaN Invalid_operation +resx586 rescale Inf Inf -> Infinity +resx587 rescale -1000 Inf -> NaN Invalid_operation +resx588 rescale -Inf Inf -> -Infinity +resx589 rescale -1 Inf -> NaN Invalid_operation +resx590 rescale 0 Inf -> NaN Invalid_operation +resx591 rescale 1 Inf -> NaN Invalid_operation +resx592 rescale 1000 Inf -> NaN Invalid_operation +resx593 rescale Inf Inf -> Infinity +resx594 rescale Inf -0 -> NaN Invalid_operation +resx595 rescale -0 Inf -> NaN Invalid_operation + +resx600 rescale -Inf -Inf -> -Infinity +resx601 rescale -Inf -1000 -> NaN Invalid_operation +resx602 rescale -Inf -1 -> NaN Invalid_operation +resx603 rescale -Inf 0 -> NaN Invalid_operation +resx604 rescale -Inf 1 -> NaN Invalid_operation +resx605 rescale -Inf 1000 -> NaN Invalid_operation +resx606 rescale -Inf Inf -> -Infinity +resx607 rescale -1000 Inf -> NaN Invalid_operation +resx608 rescale -Inf -Inf -> -Infinity +resx609 rescale -1 -Inf -> NaN Invalid_operation +resx610 rescale 0 -Inf -> NaN Invalid_operation +resx611 rescale 1 -Inf -> NaN Invalid_operation +resx612 rescale 1000 -Inf -> NaN Invalid_operation +resx613 rescale Inf -Inf -> Infinity +resx614 rescale -Inf -0 -> NaN Invalid_operation +resx615 rescale -0 -Inf -> NaN Invalid_operation + +resx621 rescale NaN -Inf -> NaN +resx622 rescale NaN -1000 -> NaN +resx623 rescale NaN -1 -> NaN +resx624 rescale NaN 0 -> NaN +resx625 rescale NaN 1 -> NaN +resx626 rescale NaN 1000 -> NaN +resx627 rescale NaN Inf -> NaN +resx628 rescale NaN NaN -> NaN +resx629 rescale -Inf NaN -> NaN +resx630 rescale -1000 NaN -> NaN +resx631 rescale -1 NaN -> NaN +resx632 rescale 0 NaN -> NaN +resx633 rescale 1 -NaN -> -NaN +resx634 rescale 1000 NaN -> NaN +resx635 rescale Inf NaN -> NaN +resx636 rescale NaN -0 -> NaN +resx637 rescale -0 NaN -> NaN + +resx641 rescale sNaN -Inf -> NaN Invalid_operation +resx642 rescale sNaN -1000 -> NaN Invalid_operation +resx643 rescale sNaN -1 -> NaN Invalid_operation +resx644 rescale sNaN 0 -> NaN Invalid_operation +resx645 rescale sNaN 1 -> NaN Invalid_operation +resx646 rescale sNaN 1000 -> NaN Invalid_operation +resx647 rescale -sNaN NaN -> -NaN Invalid_operation +resx648 rescale sNaN -sNaN -> NaN Invalid_operation +resx649 rescale NaN sNaN -> NaN Invalid_operation +resx650 rescale -Inf sNaN -> NaN Invalid_operation +resx651 rescale -1000 sNaN -> NaN Invalid_operation +resx652 rescale -1 sNaN -> NaN Invalid_operation +resx653 rescale 0 sNaN -> NaN Invalid_operation +resx654 rescale 1 -sNaN -> -NaN Invalid_operation +resx655 rescale 1000 sNaN -> NaN Invalid_operation +resx656 rescale Inf sNaN -> NaN Invalid_operation +resx657 rescale NaN sNaN -> NaN Invalid_operation +resx658 rescale sNaN -0 -> NaN Invalid_operation +resx659 rescale -0 sNaN -> NaN Invalid_operation + +-- propagating NaNs +resx661 rescale NaN9 -Inf -> NaN9 +resx662 rescale NaN81 919 -> NaN81 +resx663 rescale NaN72 Inf -> NaN72 +resx664 rescale -NaN66 NaN5 -> -NaN66 +resx665 rescale -Inf NaN4 -> NaN4 +resx666 rescale -919 NaN32 -> NaN32 +resx667 rescale Inf NaN2 -> NaN2 + +resx671 rescale sNaN99 -Inf -> NaN99 Invalid_operation +resx672 rescale -sNaN98 -11 -> -NaN98 Invalid_operation +resx673 rescale sNaN97 NaN -> NaN97 Invalid_operation +resx674 rescale sNaN16 sNaN94 -> NaN16 Invalid_operation +resx675 rescale NaN95 sNaN93 -> NaN93 Invalid_operation +resx676 rescale -Inf sNaN92 -> NaN92 Invalid_operation +resx677 rescale 088 -sNaN91 -> -NaN91 Invalid_operation +resx678 rescale Inf -sNaN90 -> -NaN90 Invalid_operation +resx679 rescale NaN sNaN87 -> NaN87 Invalid_operation + +-- subnormals and underflow +precision: 4 +maxexponent: 999 +minexponent: -999 +resx710 rescale 1.00E-999 -999 -> 1E-999 Rounded +resx711 rescale 0.1E-999 -1000 -> 1E-1000 Subnormal +resx712 rescale 0.10E-999 -1000 -> 1E-1000 Subnormal Rounded +resx713 rescale 0.100E-999 -1000 -> 1E-1000 Subnormal Rounded +resx714 rescale 0.01E-999 -1001 -> 1E-1001 Subnormal +-- next is rounded to Emin +resx715 rescale 0.999E-999 -999 -> 1E-999 Inexact Rounded +resx716 rescale 0.099E-999 -1000 -> 1E-1000 Inexact Rounded Subnormal + +resx717 rescale 0.009E-999 -1001 -> 1E-1001 Inexact Rounded Subnormal +resx718 rescale 0.001E-999 -1001 -> 0E-1001 Inexact Rounded +resx719 rescale 0.0009E-999 -1001 -> 0E-1001 Inexact Rounded +resx720 rescale 0.0001E-999 -1001 -> 0E-1001 Inexact Rounded + +resx730 rescale -1.00E-999 -999 -> -1E-999 Rounded +resx731 rescale -0.1E-999 -999 -> -0E-999 Rounded Inexact +resx732 rescale -0.10E-999 -999 -> -0E-999 Rounded Inexact +resx733 rescale -0.100E-999 -999 -> -0E-999 Rounded Inexact +resx734 rescale -0.01E-999 -999 -> -0E-999 Inexact Rounded +-- next is rounded to Emin +resx735 rescale -0.999E-999 -999 -> -1E-999 Inexact Rounded +resx736 rescale -0.099E-999 -999 -> -0E-999 Inexact Rounded +resx737 rescale -0.009E-999 -999 -> -0E-999 Inexact Rounded +resx738 rescale -0.001E-999 -999 -> -0E-999 Inexact Rounded +resx739 rescale -0.0001E-999 -999 -> -0E-999 Inexact Rounded + +resx740 rescale -1.00E-999 -1000 -> -1.0E-999 Rounded +resx741 rescale -0.1E-999 -1000 -> -1E-1000 Subnormal +resx742 rescale -0.10E-999 -1000 -> -1E-1000 Subnormal Rounded +resx743 rescale -0.100E-999 -1000 -> -1E-1000 Subnormal Rounded +resx744 rescale -0.01E-999 -1000 -> -0E-1000 Inexact Rounded +-- next is rounded to Emin +resx745 rescale -0.999E-999 -1000 -> -1.0E-999 Inexact Rounded +resx746 rescale -0.099E-999 -1000 -> -1E-1000 Inexact Rounded Subnormal +resx747 rescale -0.009E-999 -1000 -> -0E-1000 Inexact Rounded +resx748 rescale -0.001E-999 -1000 -> -0E-1000 Inexact Rounded +resx749 rescale -0.0001E-999 -1000 -> -0E-1000 Inexact Rounded + +resx750 rescale -1.00E-999 -1001 -> -1.00E-999 +resx751 rescale -0.1E-999 -1001 -> -1.0E-1000 Subnormal +resx752 rescale -0.10E-999 -1001 -> -1.0E-1000 Subnormal +resx753 rescale -0.100E-999 -1001 -> -1.0E-1000 Subnormal Rounded +resx754 rescale -0.01E-999 -1001 -> -1E-1001 Subnormal +-- next is rounded to Emin +resx755 rescale -0.999E-999 -1001 -> -1.00E-999 Inexact Rounded +resx756 rescale -0.099E-999 -1001 -> -1.0E-1000 Inexact Rounded Subnormal +resx757 rescale -0.009E-999 -1001 -> -1E-1001 Inexact Rounded Subnormal +resx758 rescale -0.001E-999 -1001 -> -0E-1001 Inexact Rounded +resx759 rescale -0.0001E-999 -1001 -> -0E-1001 Inexact Rounded + +resx760 rescale -1.00E-999 -1002 -> -1.000E-999 +resx761 rescale -0.1E-999 -1002 -> -1.00E-1000 Subnormal +resx762 rescale -0.10E-999 -1002 -> -1.00E-1000 Subnormal +resx763 rescale -0.100E-999 -1002 -> -1.00E-1000 Subnormal +resx764 rescale -0.01E-999 -1002 -> -1.0E-1001 Subnormal +resx765 rescale -0.999E-999 -1002 -> -9.99E-1000 Subnormal +resx766 rescale -0.099E-999 -1002 -> -9.9E-1001 Subnormal +resx767 rescale -0.009E-999 -1002 -> -9E-1002 Subnormal +resx768 rescale -0.001E-999 -1002 -> -1E-1002 Subnormal +resx769 rescale -0.0001E-999 -1002 -> -0E-1002 Inexact Rounded + +-- rhs must be no less than Etiny +resx770 rescale -1.00E-999 -1003 -> NaN Invalid_operation +resx771 rescale -0.1E-999 -1003 -> NaN Invalid_operation +resx772 rescale -0.10E-999 -1003 -> NaN Invalid_operation +resx773 rescale -0.100E-999 -1003 -> NaN Invalid_operation +resx774 rescale -0.01E-999 -1003 -> NaN Invalid_operation +resx775 rescale -0.999E-999 -1003 -> NaN Invalid_operation +resx776 rescale -0.099E-999 -1003 -> NaN Invalid_operation +resx777 rescale -0.009E-999 -1003 -> NaN Invalid_operation +resx778 rescale -0.001E-999 -1003 -> NaN Invalid_operation +resx779 rescale -0.0001E-999 -1003 -> NaN Invalid_operation + +precision: 9 +maxExponent: 999999999 +minexponent: -999999999 + +-- getInt worries +resx801 rescale 0 1000000000 -> NaN Invalid_operation +resx802 rescale 0 -1000000000 -> 0E-1000000000 +resx803 rescale 0 2000000000 -> NaN Invalid_operation +resx804 rescale 0 -2000000000 -> NaN Invalid_operation +resx805 rescale 0 3000000000 -> NaN Invalid_operation +resx806 rescale 0 -3000000000 -> NaN Invalid_operation +resx807 rescale 0 4000000000 -> NaN Invalid_operation +resx808 rescale 0 -4000000000 -> NaN Invalid_operation +resx809 rescale 0 5000000000 -> NaN Invalid_operation +resx810 rescale 0 -5000000000 -> NaN Invalid_operation +resx811 rescale 0 6000000000 -> NaN Invalid_operation +resx812 rescale 0 -6000000000 -> NaN Invalid_operation +resx813 rescale 0 7000000000 -> NaN Invalid_operation +resx814 rescale 0 -7000000000 -> NaN Invalid_operation +resx815 rescale 0 8000000000 -> NaN Invalid_operation +resx816 rescale 0 -8000000000 -> NaN Invalid_operation +resx817 rescale 0 9000000000 -> NaN Invalid_operation +resx818 rescale 0 -9000000000 -> NaN Invalid_operation +resx819 rescale 0 9999999999 -> NaN Invalid_operation +resx820 rescale 0 -9999999999 -> NaN Invalid_operation +resx821 rescale 0 10000000000 -> NaN Invalid_operation +resx822 rescale 0 -10000000000 -> NaN Invalid_operation + +resx831 rescale 1 0E-1 -> 1 +resx832 rescale 1 0E-2 -> 1 +resx833 rescale 1 0E-3 -> 1 +resx834 rescale 1 0E-4 -> 1 +resx835 rescale 1 0E-100 -> 1 +resx836 rescale 1 0E-100000 -> 1 +resx837 rescale 1 0E+100 -> 1 +resx838 rescale 1 0E+100000 -> 1 + +resx841 rescale 0 5E-1000000 -> NaN Invalid_operation +resx842 rescale 0 5E-1000000 -> NaN Invalid_operation +resx843 rescale 0 999999999 -> 0E+999999999 +resx844 rescale 0 1000000000 -> NaN Invalid_operation +resx845 rescale 0 -999999999 -> 0E-999999999 +resx846 rescale 0 -1000000000 -> 0E-1000000000 +resx847 rescale 0 -1000000001 -> 0E-1000000001 +resx848 rescale 0 -1000000002 -> 0E-1000000002 +resx849 rescale 0 -1000000003 -> 0E-1000000003 +resx850 rescale 0 -1000000004 -> 0E-1000000004 +resx851 rescale 0 -1000000005 -> 0E-1000000005 +resx852 rescale 0 -1000000006 -> 0E-1000000006 +resx853 rescale 0 -1000000007 -> 0E-1000000007 +resx854 rescale 0 -1000000008 -> NaN Invalid_operation + +resx861 rescale 1 +2147483649 -> NaN Invalid_operation +resx862 rescale 1 +2147483648 -> NaN Invalid_operation +resx863 rescale 1 +2147483647 -> NaN Invalid_operation +resx864 rescale 1 -2147483647 -> NaN Invalid_operation +resx865 rescale 1 -2147483648 -> NaN Invalid_operation +resx866 rescale 1 -2147483649 -> NaN Invalid_operation + +-- Null tests +res900 rescale 10 # -> NaN Invalid_operation +res901 rescale # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/rounding.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/rounding.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,1079 @@ +------------------------------------------------------------------------ +-- rounding.decTest -- decimal rounding modes testcases -- +-- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- These tests require that implementations take account of residues in +-- order to get correct results for some rounding modes. Rather than +-- single rounding tests we therefore need tests for most operators. +-- [We do assume add/minus/plus/subtract are common paths, however, as +-- is rounding of negatives (if the latter works for addition, assume it +-- works for the others, too).] +-- +-- Underflow Subnormal and overflow behaviours are tested under the individual +-- operators. + +extended: 1 +precision: 5 -- for easier visual inspection +maxExponent: 999 +minexponent: -999 + +-- Addition operators ------------------------------------------------- +rounding: down + +radx100 add 12345 -0.1 -> 12344 Inexact Rounded +radx101 add 12345 -0.01 -> 12344 Inexact Rounded +radx102 add 12345 -0.001 -> 12344 Inexact Rounded +radx103 add 12345 -0.00001 -> 12344 Inexact Rounded +radx104 add 12345 -0.000001 -> 12344 Inexact Rounded +radx105 add 12345 -0.0000001 -> 12344 Inexact Rounded +radx106 add 12345 0 -> 12345 +radx107 add 12345 0.0000001 -> 12345 Inexact Rounded +radx108 add 12345 0.000001 -> 12345 Inexact Rounded +radx109 add 12345 0.00001 -> 12345 Inexact Rounded +radx110 add 12345 0.0001 -> 12345 Inexact Rounded +radx111 add 12345 0.001 -> 12345 Inexact Rounded +radx112 add 12345 0.01 -> 12345 Inexact Rounded +radx113 add 12345 0.1 -> 12345 Inexact Rounded + +radx115 add 12346 0.49999 -> 12346 Inexact Rounded +radx116 add 12346 0.5 -> 12346 Inexact Rounded +radx117 add 12346 0.50001 -> 12346 Inexact Rounded + +radx120 add 12345 0.4 -> 12345 Inexact Rounded +radx121 add 12345 0.49 -> 12345 Inexact Rounded +radx122 add 12345 0.499 -> 12345 Inexact Rounded +radx123 add 12345 0.49999 -> 12345 Inexact Rounded +radx124 add 12345 0.5 -> 12345 Inexact Rounded +radx125 add 12345 0.50001 -> 12345 Inexact Rounded +radx126 add 12345 0.5001 -> 12345 Inexact Rounded +radx127 add 12345 0.501 -> 12345 Inexact Rounded +radx128 add 12345 0.51 -> 12345 Inexact Rounded +radx129 add 12345 0.6 -> 12345 Inexact Rounded + +rounding: half_down + +radx140 add 12345 -0.1 -> 12345 Inexact Rounded +radx141 add 12345 -0.01 -> 12345 Inexact Rounded +radx142 add 12345 -0.001 -> 12345 Inexact Rounded +radx143 add 12345 -0.00001 -> 12345 Inexact Rounded +radx144 add 12345 -0.000001 -> 12345 Inexact Rounded +radx145 add 12345 -0.0000001 -> 12345 Inexact Rounded +radx146 add 12345 0 -> 12345 +radx147 add 12345 0.0000001 -> 12345 Inexact Rounded +radx148 add 12345 0.000001 -> 12345 Inexact Rounded +radx149 add 12345 0.00001 -> 12345 Inexact Rounded +radx150 add 12345 0.0001 -> 12345 Inexact Rounded +radx151 add 12345 0.001 -> 12345 Inexact Rounded +radx152 add 12345 0.01 -> 12345 Inexact Rounded +radx153 add 12345 0.1 -> 12345 Inexact Rounded + +radx155 add 12346 0.49999 -> 12346 Inexact Rounded +radx156 add 12346 0.5 -> 12346 Inexact Rounded +radx157 add 12346 0.50001 -> 12347 Inexact Rounded + +radx160 add 12345 0.4 -> 12345 Inexact Rounded +radx161 add 12345 0.49 -> 12345 Inexact Rounded +radx162 add 12345 0.499 -> 12345 Inexact Rounded +radx163 add 12345 0.49999 -> 12345 Inexact Rounded +radx164 add 12345 0.5 -> 12345 Inexact Rounded +radx165 add 12345 0.50001 -> 12346 Inexact Rounded +radx166 add 12345 0.5001 -> 12346 Inexact Rounded +radx167 add 12345 0.501 -> 12346 Inexact Rounded +radx168 add 12345 0.51 -> 12346 Inexact Rounded +radx169 add 12345 0.6 -> 12346 Inexact Rounded + +rounding: half_even + +radx170 add 12345 -0.1 -> 12345 Inexact Rounded +radx171 add 12345 -0.01 -> 12345 Inexact Rounded +radx172 add 12345 -0.001 -> 12345 Inexact Rounded +radx173 add 12345 -0.00001 -> 12345 Inexact Rounded +radx174 add 12345 -0.000001 -> 12345 Inexact Rounded +radx175 add 12345 -0.0000001 -> 12345 Inexact Rounded +radx176 add 12345 0 -> 12345 +radx177 add 12345 0.0000001 -> 12345 Inexact Rounded +radx178 add 12345 0.000001 -> 12345 Inexact Rounded +radx179 add 12345 0.00001 -> 12345 Inexact Rounded +radx180 add 12345 0.0001 -> 12345 Inexact Rounded +radx181 add 12345 0.001 -> 12345 Inexact Rounded +radx182 add 12345 0.01 -> 12345 Inexact Rounded +radx183 add 12345 0.1 -> 12345 Inexact Rounded + +radx185 add 12346 0.49999 -> 12346 Inexact Rounded +radx186 add 12346 0.5 -> 12346 Inexact Rounded +radx187 add 12346 0.50001 -> 12347 Inexact Rounded + +radx190 add 12345 0.4 -> 12345 Inexact Rounded +radx191 add 12345 0.49 -> 12345 Inexact Rounded +radx192 add 12345 0.499 -> 12345 Inexact Rounded +radx193 add 12345 0.49999 -> 12345 Inexact Rounded +radx194 add 12345 0.5 -> 12346 Inexact Rounded +radx195 add 12345 0.50001 -> 12346 Inexact Rounded +radx196 add 12345 0.5001 -> 12346 Inexact Rounded +radx197 add 12345 0.501 -> 12346 Inexact Rounded +radx198 add 12345 0.51 -> 12346 Inexact Rounded +radx199 add 12345 0.6 -> 12346 Inexact Rounded + +rounding: half_up + +radx200 add 12345 -0.1 -> 12345 Inexact Rounded +radx201 add 12345 -0.01 -> 12345 Inexact Rounded +radx202 add 12345 -0.001 -> 12345 Inexact Rounded +radx203 add 12345 -0.00001 -> 12345 Inexact Rounded +radx204 add 12345 -0.000001 -> 12345 Inexact Rounded +radx205 add 12345 -0.0000001 -> 12345 Inexact Rounded +radx206 add 12345 0 -> 12345 +radx207 add 12345 0.0000001 -> 12345 Inexact Rounded +radx208 add 12345 0.000001 -> 12345 Inexact Rounded +radx209 add 12345 0.00001 -> 12345 Inexact Rounded +radx210 add 12345 0.0001 -> 12345 Inexact Rounded +radx211 add 12345 0.001 -> 12345 Inexact Rounded +radx212 add 12345 0.01 -> 12345 Inexact Rounded +radx213 add 12345 0.1 -> 12345 Inexact Rounded + +radx215 add 12346 0.49999 -> 12346 Inexact Rounded +radx216 add 12346 0.5 -> 12347 Inexact Rounded +radx217 add 12346 0.50001 -> 12347 Inexact Rounded + +radx220 add 12345 0.4 -> 12345 Inexact Rounded +radx221 add 12345 0.49 -> 12345 Inexact Rounded +radx222 add 12345 0.499 -> 12345 Inexact Rounded +radx223 add 12345 0.49999 -> 12345 Inexact Rounded +radx224 add 12345 0.5 -> 12346 Inexact Rounded +radx225 add 12345 0.50001 -> 12346 Inexact Rounded +radx226 add 12345 0.5001 -> 12346 Inexact Rounded +radx227 add 12345 0.501 -> 12346 Inexact Rounded +radx228 add 12345 0.51 -> 12346 Inexact Rounded +radx229 add 12345 0.6 -> 12346 Inexact Rounded + +rounding: up + +radx230 add 12345 -0.1 -> 12345 Inexact Rounded +radx231 add 12345 -0.01 -> 12345 Inexact Rounded +radx232 add 12345 -0.001 -> 12345 Inexact Rounded +radx233 add 12345 -0.00001 -> 12345 Inexact Rounded +radx234 add 12345 -0.000001 -> 12345 Inexact Rounded +radx235 add 12345 -0.0000001 -> 12345 Inexact Rounded +radx236 add 12345 0 -> 12345 +radx237 add 12345 0.0000001 -> 12346 Inexact Rounded +radx238 add 12345 0.000001 -> 12346 Inexact Rounded +radx239 add 12345 0.00001 -> 12346 Inexact Rounded +radx240 add 12345 0.0001 -> 12346 Inexact Rounded +radx241 add 12345 0.001 -> 12346 Inexact Rounded +radx242 add 12345 0.01 -> 12346 Inexact Rounded +radx243 add 12345 0.1 -> 12346 Inexact Rounded + +radx245 add 12346 0.49999 -> 12347 Inexact Rounded +radx246 add 12346 0.5 -> 12347 Inexact Rounded +radx247 add 12346 0.50001 -> 12347 Inexact Rounded + +radx250 add 12345 0.4 -> 12346 Inexact Rounded +radx251 add 12345 0.49 -> 12346 Inexact Rounded +radx252 add 12345 0.499 -> 12346 Inexact Rounded +radx253 add 12345 0.49999 -> 12346 Inexact Rounded +radx254 add 12345 0.5 -> 12346 Inexact Rounded +radx255 add 12345 0.50001 -> 12346 Inexact Rounded +radx256 add 12345 0.5001 -> 12346 Inexact Rounded +radx257 add 12345 0.501 -> 12346 Inexact Rounded +radx258 add 12345 0.51 -> 12346 Inexact Rounded +radx259 add 12345 0.6 -> 12346 Inexact Rounded + +rounding: floor + +radx300 add 12345 -0.1 -> 12344 Inexact Rounded +radx301 add 12345 -0.01 -> 12344 Inexact Rounded +radx302 add 12345 -0.001 -> 12344 Inexact Rounded +radx303 add 12345 -0.00001 -> 12344 Inexact Rounded +radx304 add 12345 -0.000001 -> 12344 Inexact Rounded +radx305 add 12345 -0.0000001 -> 12344 Inexact Rounded +radx306 add 12345 0 -> 12345 +radx307 add 12345 0.0000001 -> 12345 Inexact Rounded +radx308 add 12345 0.000001 -> 12345 Inexact Rounded +radx309 add 12345 0.00001 -> 12345 Inexact Rounded +radx310 add 12345 0.0001 -> 12345 Inexact Rounded +radx311 add 12345 0.001 -> 12345 Inexact Rounded +radx312 add 12345 0.01 -> 12345 Inexact Rounded +radx313 add 12345 0.1 -> 12345 Inexact Rounded + +radx315 add 12346 0.49999 -> 12346 Inexact Rounded +radx316 add 12346 0.5 -> 12346 Inexact Rounded +radx317 add 12346 0.50001 -> 12346 Inexact Rounded + +radx320 add 12345 0.4 -> 12345 Inexact Rounded +radx321 add 12345 0.49 -> 12345 Inexact Rounded +radx322 add 12345 0.499 -> 12345 Inexact Rounded +radx323 add 12345 0.49999 -> 12345 Inexact Rounded +radx324 add 12345 0.5 -> 12345 Inexact Rounded +radx325 add 12345 0.50001 -> 12345 Inexact Rounded +radx326 add 12345 0.5001 -> 12345 Inexact Rounded +radx327 add 12345 0.501 -> 12345 Inexact Rounded +radx328 add 12345 0.51 -> 12345 Inexact Rounded +radx329 add 12345 0.6 -> 12345 Inexact Rounded + +rounding: ceiling + +radx330 add 12345 -0.1 -> 12345 Inexact Rounded +radx331 add 12345 -0.01 -> 12345 Inexact Rounded +radx332 add 12345 -0.001 -> 12345 Inexact Rounded +radx333 add 12345 -0.00001 -> 12345 Inexact Rounded +radx334 add 12345 -0.000001 -> 12345 Inexact Rounded +radx335 add 12345 -0.0000001 -> 12345 Inexact Rounded +radx336 add 12345 0 -> 12345 +radx337 add 12345 0.0000001 -> 12346 Inexact Rounded +radx338 add 12345 0.000001 -> 12346 Inexact Rounded +radx339 add 12345 0.00001 -> 12346 Inexact Rounded +radx340 add 12345 0.0001 -> 12346 Inexact Rounded +radx341 add 12345 0.001 -> 12346 Inexact Rounded +radx342 add 12345 0.01 -> 12346 Inexact Rounded +radx343 add 12345 0.1 -> 12346 Inexact Rounded + +radx345 add 12346 0.49999 -> 12347 Inexact Rounded +radx346 add 12346 0.5 -> 12347 Inexact Rounded +radx347 add 12346 0.50001 -> 12347 Inexact Rounded + +radx350 add 12345 0.4 -> 12346 Inexact Rounded +radx351 add 12345 0.49 -> 12346 Inexact Rounded +radx352 add 12345 0.499 -> 12346 Inexact Rounded +radx353 add 12345 0.49999 -> 12346 Inexact Rounded +radx354 add 12345 0.5 -> 12346 Inexact Rounded +radx355 add 12345 0.50001 -> 12346 Inexact Rounded +radx356 add 12345 0.5001 -> 12346 Inexact Rounded +radx357 add 12345 0.501 -> 12346 Inexact Rounded +radx358 add 12345 0.51 -> 12346 Inexact Rounded +radx359 add 12345 0.6 -> 12346 Inexact Rounded + +-- negatives... + +rounding: down + +rsux100 add -12345 -0.1 -> -12345 Inexact Rounded +rsux101 add -12345 -0.01 -> -12345 Inexact Rounded +rsux102 add -12345 -0.001 -> -12345 Inexact Rounded +rsux103 add -12345 -0.00001 -> -12345 Inexact Rounded +rsux104 add -12345 -0.000001 -> -12345 Inexact Rounded +rsux105 add -12345 -0.0000001 -> -12345 Inexact Rounded +rsux106 add -12345 0 -> -12345 +rsux107 add -12345 0.0000001 -> -12344 Inexact Rounded +rsux108 add -12345 0.000001 -> -12344 Inexact Rounded +rsux109 add -12345 0.00001 -> -12344 Inexact Rounded +rsux110 add -12345 0.0001 -> -12344 Inexact Rounded +rsux111 add -12345 0.001 -> -12344 Inexact Rounded +rsux112 add -12345 0.01 -> -12344 Inexact Rounded +rsux113 add -12345 0.1 -> -12344 Inexact Rounded + +rsux115 add -12346 0.49999 -> -12345 Inexact Rounded +rsux116 add -12346 0.5 -> -12345 Inexact Rounded +rsux117 add -12346 0.50001 -> -12345 Inexact Rounded + +rsux120 add -12345 0.4 -> -12344 Inexact Rounded +rsux121 add -12345 0.49 -> -12344 Inexact Rounded +rsux122 add -12345 0.499 -> -12344 Inexact Rounded +rsux123 add -12345 0.49999 -> -12344 Inexact Rounded +rsux124 add -12345 0.5 -> -12344 Inexact Rounded +rsux125 add -12345 0.50001 -> -12344 Inexact Rounded +rsux126 add -12345 0.5001 -> -12344 Inexact Rounded +rsux127 add -12345 0.501 -> -12344 Inexact Rounded +rsux128 add -12345 0.51 -> -12344 Inexact Rounded +rsux129 add -12345 0.6 -> -12344 Inexact Rounded + +rounding: half_down + +rsux140 add -12345 -0.1 -> -12345 Inexact Rounded +rsux141 add -12345 -0.01 -> -12345 Inexact Rounded +rsux142 add -12345 -0.001 -> -12345 Inexact Rounded +rsux143 add -12345 -0.00001 -> -12345 Inexact Rounded +rsux144 add -12345 -0.000001 -> -12345 Inexact Rounded +rsux145 add -12345 -0.0000001 -> -12345 Inexact Rounded +rsux146 add -12345 0 -> -12345 +rsux147 add -12345 0.0000001 -> -12345 Inexact Rounded +rsux148 add -12345 0.000001 -> -12345 Inexact Rounded +rsux149 add -12345 0.00001 -> -12345 Inexact Rounded +rsux150 add -12345 0.0001 -> -12345 Inexact Rounded +rsux151 add -12345 0.001 -> -12345 Inexact Rounded +rsux152 add -12345 0.01 -> -12345 Inexact Rounded +rsux153 add -12345 0.1 -> -12345 Inexact Rounded + +rsux155 add -12346 0.49999 -> -12346 Inexact Rounded +rsux156 add -12346 0.5 -> -12345 Inexact Rounded +rsux157 add -12346 0.50001 -> -12345 Inexact Rounded + +rsux160 add -12345 0.4 -> -12345 Inexact Rounded +rsux161 add -12345 0.49 -> -12345 Inexact Rounded +rsux162 add -12345 0.499 -> -12345 Inexact Rounded +rsux163 add -12345 0.49999 -> -12345 Inexact Rounded +rsux164 add -12345 0.5 -> -12344 Inexact Rounded +rsux165 add -12345 0.50001 -> -12344 Inexact Rounded +rsux166 add -12345 0.5001 -> -12344 Inexact Rounded +rsux167 add -12345 0.501 -> -12344 Inexact Rounded +rsux168 add -12345 0.51 -> -12344 Inexact Rounded +rsux169 add -12345 0.6 -> -12344 Inexact Rounded + +rounding: half_even + +rsux170 add -12345 -0.1 -> -12345 Inexact Rounded +rsux171 add -12345 -0.01 -> -12345 Inexact Rounded +rsux172 add -12345 -0.001 -> -12345 Inexact Rounded +rsux173 add -12345 -0.00001 -> -12345 Inexact Rounded +rsux174 add -12345 -0.000001 -> -12345 Inexact Rounded +rsux175 add -12345 -0.0000001 -> -12345 Inexact Rounded +rsux176 add -12345 0 -> -12345 +rsux177 add -12345 0.0000001 -> -12345 Inexact Rounded +rsux178 add -12345 0.000001 -> -12345 Inexact Rounded +rsux179 add -12345 0.00001 -> -12345 Inexact Rounded +rsux180 add -12345 0.0001 -> -12345 Inexact Rounded +rsux181 add -12345 0.001 -> -12345 Inexact Rounded +rsux182 add -12345 0.01 -> -12345 Inexact Rounded +rsux183 add -12345 0.1 -> -12345 Inexact Rounded + +rsux185 add -12346 0.49999 -> -12346 Inexact Rounded +rsux186 add -12346 0.5 -> -12346 Inexact Rounded +rsux187 add -12346 0.50001 -> -12345 Inexact Rounded + +rsux190 add -12345 0.4 -> -12345 Inexact Rounded +rsux191 add -12345 0.49 -> -12345 Inexact Rounded +rsux192 add -12345 0.499 -> -12345 Inexact Rounded +rsux193 add -12345 0.49999 -> -12345 Inexact Rounded +rsux194 add -12345 0.5 -> -12344 Inexact Rounded +rsux195 add -12345 0.50001 -> -12344 Inexact Rounded +rsux196 add -12345 0.5001 -> -12344 Inexact Rounded +rsux197 add -12345 0.501 -> -12344 Inexact Rounded +rsux198 add -12345 0.51 -> -12344 Inexact Rounded +rsux199 add -12345 0.6 -> -12344 Inexact Rounded + +rounding: half_up + +rsux200 add -12345 -0.1 -> -12345 Inexact Rounded +rsux201 add -12345 -0.01 -> -12345 Inexact Rounded +rsux202 add -12345 -0.001 -> -12345 Inexact Rounded +rsux203 add -12345 -0.00001 -> -12345 Inexact Rounded +rsux204 add -12345 -0.000001 -> -12345 Inexact Rounded +rsux205 add -12345 -0.0000001 -> -12345 Inexact Rounded +rsux206 add -12345 0 -> -12345 +rsux207 add -12345 0.0000001 -> -12345 Inexact Rounded +rsux208 add -12345 0.000001 -> -12345 Inexact Rounded +rsux209 add -12345 0.00001 -> -12345 Inexact Rounded +rsux210 add -12345 0.0001 -> -12345 Inexact Rounded +rsux211 add -12345 0.001 -> -12345 Inexact Rounded +rsux212 add -12345 0.01 -> -12345 Inexact Rounded +rsux213 add -12345 0.1 -> -12345 Inexact Rounded + +rsux215 add -12346 0.49999 -> -12346 Inexact Rounded +rsux216 add -12346 0.5 -> -12346 Inexact Rounded +rsux217 add -12346 0.50001 -> -12345 Inexact Rounded + +rsux220 add -12345 0.4 -> -12345 Inexact Rounded +rsux221 add -12345 0.49 -> -12345 Inexact Rounded +rsux222 add -12345 0.499 -> -12345 Inexact Rounded +rsux223 add -12345 0.49999 -> -12345 Inexact Rounded +rsux224 add -12345 0.5 -> -12345 Inexact Rounded +rsux225 add -12345 0.50001 -> -12344 Inexact Rounded +rsux226 add -12345 0.5001 -> -12344 Inexact Rounded +rsux227 add -12345 0.501 -> -12344 Inexact Rounded +rsux228 add -12345 0.51 -> -12344 Inexact Rounded +rsux229 add -12345 0.6 -> -12344 Inexact Rounded + +rounding: up + +rsux230 add -12345 -0.1 -> -12346 Inexact Rounded +rsux231 add -12345 -0.01 -> -12346 Inexact Rounded +rsux232 add -12345 -0.001 -> -12346 Inexact Rounded +rsux233 add -12345 -0.00001 -> -12346 Inexact Rounded +rsux234 add -12345 -0.000001 -> -12346 Inexact Rounded +rsux235 add -12345 -0.0000001 -> -12346 Inexact Rounded +rsux236 add -12345 0 -> -12345 +rsux237 add -12345 0.0000001 -> -12345 Inexact Rounded +rsux238 add -12345 0.000001 -> -12345 Inexact Rounded +rsux239 add -12345 0.00001 -> -12345 Inexact Rounded +rsux240 add -12345 0.0001 -> -12345 Inexact Rounded +rsux241 add -12345 0.001 -> -12345 Inexact Rounded +rsux242 add -12345 0.01 -> -12345 Inexact Rounded +rsux243 add -12345 0.1 -> -12345 Inexact Rounded + +rsux245 add -12346 0.49999 -> -12346 Inexact Rounded +rsux246 add -12346 0.5 -> -12346 Inexact Rounded +rsux247 add -12346 0.50001 -> -12346 Inexact Rounded + +rsux250 add -12345 0.4 -> -12345 Inexact Rounded +rsux251 add -12345 0.49 -> -12345 Inexact Rounded +rsux252 add -12345 0.499 -> -12345 Inexact Rounded +rsux253 add -12345 0.49999 -> -12345 Inexact Rounded +rsux254 add -12345 0.5 -> -12345 Inexact Rounded +rsux255 add -12345 0.50001 -> -12345 Inexact Rounded +rsux256 add -12345 0.5001 -> -12345 Inexact Rounded +rsux257 add -12345 0.501 -> -12345 Inexact Rounded +rsux258 add -12345 0.51 -> -12345 Inexact Rounded +rsux259 add -12345 0.6 -> -12345 Inexact Rounded + +rounding: floor + +rsux300 add -12345 -0.1 -> -12346 Inexact Rounded +rsux301 add -12345 -0.01 -> -12346 Inexact Rounded +rsux302 add -12345 -0.001 -> -12346 Inexact Rounded +rsux303 add -12345 -0.00001 -> -12346 Inexact Rounded +rsux304 add -12345 -0.000001 -> -12346 Inexact Rounded +rsux305 add -12345 -0.0000001 -> -12346 Inexact Rounded +rsux306 add -12345 0 -> -12345 +rsux307 add -12345 0.0000001 -> -12345 Inexact Rounded +rsux308 add -12345 0.000001 -> -12345 Inexact Rounded +rsux309 add -12345 0.00001 -> -12345 Inexact Rounded +rsux310 add -12345 0.0001 -> -12345 Inexact Rounded +rsux311 add -12345 0.001 -> -12345 Inexact Rounded +rsux312 add -12345 0.01 -> -12345 Inexact Rounded +rsux313 add -12345 0.1 -> -12345 Inexact Rounded + +rsux315 add -12346 0.49999 -> -12346 Inexact Rounded +rsux316 add -12346 0.5 -> -12346 Inexact Rounded +rsux317 add -12346 0.50001 -> -12346 Inexact Rounded + +rsux320 add -12345 0.4 -> -12345 Inexact Rounded +rsux321 add -12345 0.49 -> -12345 Inexact Rounded +rsux322 add -12345 0.499 -> -12345 Inexact Rounded +rsux323 add -12345 0.49999 -> -12345 Inexact Rounded +rsux324 add -12345 0.5 -> -12345 Inexact Rounded +rsux325 add -12345 0.50001 -> -12345 Inexact Rounded +rsux326 add -12345 0.5001 -> -12345 Inexact Rounded +rsux327 add -12345 0.501 -> -12345 Inexact Rounded +rsux328 add -12345 0.51 -> -12345 Inexact Rounded +rsux329 add -12345 0.6 -> -12345 Inexact Rounded + +rounding: ceiling + +rsux330 add -12345 -0.1 -> -12345 Inexact Rounded +rsux331 add -12345 -0.01 -> -12345 Inexact Rounded +rsux332 add -12345 -0.001 -> -12345 Inexact Rounded +rsux333 add -12345 -0.00001 -> -12345 Inexact Rounded +rsux334 add -12345 -0.000001 -> -12345 Inexact Rounded +rsux335 add -12345 -0.0000001 -> -12345 Inexact Rounded +rsux336 add -12345 0 -> -12345 +rsux337 add -12345 0.0000001 -> -12344 Inexact Rounded +rsux338 add -12345 0.000001 -> -12344 Inexact Rounded +rsux339 add -12345 0.00001 -> -12344 Inexact Rounded +rsux340 add -12345 0.0001 -> -12344 Inexact Rounded +rsux341 add -12345 0.001 -> -12344 Inexact Rounded +rsux342 add -12345 0.01 -> -12344 Inexact Rounded +rsux343 add -12345 0.1 -> -12344 Inexact Rounded + +rsux345 add -12346 0.49999 -> -12345 Inexact Rounded +rsux346 add -12346 0.5 -> -12345 Inexact Rounded +rsux347 add -12346 0.50001 -> -12345 Inexact Rounded + +rsux350 add -12345 0.4 -> -12344 Inexact Rounded +rsux351 add -12345 0.49 -> -12344 Inexact Rounded +rsux352 add -12345 0.499 -> -12344 Inexact Rounded +rsux353 add -12345 0.49999 -> -12344 Inexact Rounded +rsux354 add -12345 0.5 -> -12344 Inexact Rounded +rsux355 add -12345 0.50001 -> -12344 Inexact Rounded +rsux356 add -12345 0.5001 -> -12344 Inexact Rounded +rsux357 add -12345 0.501 -> -12344 Inexact Rounded +rsux358 add -12345 0.51 -> -12344 Inexact Rounded +rsux359 add -12345 0.6 -> -12344 Inexact Rounded + +-- Check cancellation subtractions +-- (The IEEE 854 'curious rule' in $6.3) + +rounding: down +rzex001 add 0 0 -> 0 +rzex002 add 0 -0 -> 0 +rzex003 add -0 0 -> 0 +rzex004 add -0 -0 -> -0 +rzex005 add 1 -1 -> 0 +rzex006 add -1 1 -> 0 +rzex007 add 1.5 -1.5 -> 0.0 +rzex008 add -1.5 1.5 -> 0.0 +rzex009 add 2 -2 -> 0 +rzex010 add -2 2 -> 0 + +rounding: up +rzex011 add 0 0 -> 0 +rzex012 add 0 -0 -> 0 +rzex013 add -0 0 -> 0 +rzex014 add -0 -0 -> -0 +rzex015 add 1 -1 -> 0 +rzex016 add -1 1 -> 0 +rzex017 add 1.5 -1.5 -> 0.0 +rzex018 add -1.5 1.5 -> 0.0 +rzex019 add 2 -2 -> 0 +rzex020 add -2 2 -> 0 + +rounding: half_up +rzex021 add 0 0 -> 0 +rzex022 add 0 -0 -> 0 +rzex023 add -0 0 -> 0 +rzex024 add -0 -0 -> -0 +rzex025 add 1 -1 -> 0 +rzex026 add -1 1 -> 0 +rzex027 add 1.5 -1.5 -> 0.0 +rzex028 add -1.5 1.5 -> 0.0 +rzex029 add 2 -2 -> 0 +rzex030 add -2 2 -> 0 + +rounding: half_down +rzex031 add 0 0 -> 0 +rzex032 add 0 -0 -> 0 +rzex033 add -0 0 -> 0 +rzex034 add -0 -0 -> -0 +rzex035 add 1 -1 -> 0 +rzex036 add -1 1 -> 0 +rzex037 add 1.5 -1.5 -> 0.0 +rzex038 add -1.5 1.5 -> 0.0 +rzex039 add 2 -2 -> 0 +rzex040 add -2 2 -> 0 + +rounding: half_even +rzex041 add 0 0 -> 0 +rzex042 add 0 -0 -> 0 +rzex043 add -0 0 -> 0 +rzex044 add -0 -0 -> -0 +rzex045 add 1 -1 -> 0 +rzex046 add -1 1 -> 0 +rzex047 add 1.5 -1.5 -> 0.0 +rzex048 add -1.5 1.5 -> 0.0 +rzex049 add 2 -2 -> 0 +rzex050 add -2 2 -> 0 + +rounding: floor +rzex051 add 0 0 -> 0 +rzex052 add 0 -0 -> -0 -- here are two 'curious' +rzex053 add -0 0 -> -0 -- +rzex054 add -0 -0 -> -0 +rzex055 add 1 -1 -> -0 -- here are the rest +rzex056 add -1 1 -> -0 -- .. +rzex057 add 1.5 -1.5 -> -0.0 -- .. +rzex058 add -1.5 1.5 -> -0.0 -- .. +rzex059 add 2 -2 -> -0 -- .. +rzex060 add -2 2 -> -0 -- .. + +rounding: ceiling +rzex061 add 0 0 -> 0 +rzex062 add 0 -0 -> 0 +rzex063 add -0 0 -> 0 +rzex064 add -0 -0 -> -0 +rzex065 add 1 -1 -> 0 +rzex066 add -1 1 -> 0 +rzex067 add 1.5 -1.5 -> 0.0 +rzex068 add -1.5 1.5 -> 0.0 +rzex069 add 2 -2 -> 0 +rzex070 add -2 2 -> 0 + + +-- Division operators ------------------------------------------------- + +rounding: down +rdvx101 divide 12345 1 -> 12345 +rdvx102 divide 12345 1.0001 -> 12343 Inexact Rounded +rdvx103 divide 12345 1.001 -> 12332 Inexact Rounded +rdvx104 divide 12345 1.01 -> 12222 Inexact Rounded +rdvx105 divide 12345 1.1 -> 11222 Inexact Rounded +rdvx106 divide 12355 4 -> 3088.7 Inexact Rounded +rdvx107 divide 12345 4 -> 3086.2 Inexact Rounded +rdvx108 divide 12355 4.0001 -> 3088.6 Inexact Rounded +rdvx109 divide 12345 4.0001 -> 3086.1 Inexact Rounded +rdvx110 divide 12345 4.9 -> 2519.3 Inexact Rounded +rdvx111 divide 12345 4.99 -> 2473.9 Inexact Rounded +rdvx112 divide 12345 4.999 -> 2469.4 Inexact Rounded +rdvx113 divide 12345 4.9999 -> 2469.0 Inexact Rounded +rdvx114 divide 12345 5 -> 2469 +rdvx115 divide 12345 5.0001 -> 2468.9 Inexact Rounded +rdvx116 divide 12345 5.001 -> 2468.5 Inexact Rounded +rdvx117 divide 12345 5.01 -> 2464.0 Inexact Rounded +rdvx118 divide 12345 5.1 -> 2420.5 Inexact Rounded + +rounding: half_down +rdvx201 divide 12345 1 -> 12345 +rdvx202 divide 12345 1.0001 -> 12344 Inexact Rounded +rdvx203 divide 12345 1.001 -> 12333 Inexact Rounded +rdvx204 divide 12345 1.01 -> 12223 Inexact Rounded +rdvx205 divide 12345 1.1 -> 11223 Inexact Rounded +rdvx206 divide 12355 4 -> 3088.7 Inexact Rounded +rdvx207 divide 12345 4 -> 3086.2 Inexact Rounded +rdvx208 divide 12355 4.0001 -> 3088.7 Inexact Rounded +rdvx209 divide 12345 4.0001 -> 3086.2 Inexact Rounded +rdvx210 divide 12345 4.9 -> 2519.4 Inexact Rounded +rdvx211 divide 12345 4.99 -> 2473.9 Inexact Rounded +rdvx212 divide 12345 4.999 -> 2469.5 Inexact Rounded +rdvx213 divide 12345 4.9999 -> 2469.0 Inexact Rounded +rdvx214 divide 12345 5 -> 2469 +rdvx215 divide 12345 5.0001 -> 2469.0 Inexact Rounded +rdvx216 divide 12345 5.001 -> 2468.5 Inexact Rounded +rdvx217 divide 12345 5.01 -> 2464.1 Inexact Rounded +rdvx218 divide 12345 5.1 -> 2420.6 Inexact Rounded + +rounding: half_even +rdvx301 divide 12345 1 -> 12345 +rdvx302 divide 12345 1.0001 -> 12344 Inexact Rounded +rdvx303 divide 12345 1.001 -> 12333 Inexact Rounded +rdvx304 divide 12345 1.01 -> 12223 Inexact Rounded +rdvx305 divide 12345 1.1 -> 11223 Inexact Rounded +rdvx306 divide 12355 4 -> 3088.8 Inexact Rounded +rdvx307 divide 12345 4 -> 3086.2 Inexact Rounded +rdvx308 divide 12355 4.0001 -> 3088.7 Inexact Rounded +rdvx309 divide 12345 4.0001 -> 3086.2 Inexact Rounded +rdvx310 divide 12345 4.9 -> 2519.4 Inexact Rounded +rdvx311 divide 12345 4.99 -> 2473.9 Inexact Rounded +rdvx312 divide 12345 4.999 -> 2469.5 Inexact Rounded +rdvx313 divide 12345 4.9999 -> 2469.0 Inexact Rounded +rdvx314 divide 12345 5 -> 2469 +rdvx315 divide 12345 5.0001 -> 2469.0 Inexact Rounded +rdvx316 divide 12345 5.001 -> 2468.5 Inexact Rounded +rdvx317 divide 12345 5.01 -> 2464.1 Inexact Rounded +rdvx318 divide 12345 5.1 -> 2420.6 Inexact Rounded + +rounding: half_up +rdvx401 divide 12345 1 -> 12345 +rdvx402 divide 12345 1.0001 -> 12344 Inexact Rounded +rdvx403 divide 12345 1.001 -> 12333 Inexact Rounded +rdvx404 divide 12345 1.01 -> 12223 Inexact Rounded +rdvx405 divide 12345 1.1 -> 11223 Inexact Rounded +rdvx406 divide 12355 4 -> 3088.8 Inexact Rounded +rdvx407 divide 12345 4 -> 3086.3 Inexact Rounded +rdvx408 divide 12355 4.0001 -> 3088.7 Inexact Rounded +rdvx409 divide 12345 4.0001 -> 3086.2 Inexact Rounded +rdvx410 divide 12345 4.9 -> 2519.4 Inexact Rounded +rdvx411 divide 12345 4.99 -> 2473.9 Inexact Rounded +rdvx412 divide 12345 4.999 -> 2469.5 Inexact Rounded +rdvx413 divide 12345 4.9999 -> 2469.0 Inexact Rounded +rdvx414 divide 12345 5 -> 2469 +rdvx415 divide 12345 5.0001 -> 2469.0 Inexact Rounded +rdvx416 divide 12345 5.001 -> 2468.5 Inexact Rounded +rdvx417 divide 12345 5.01 -> 2464.1 Inexact Rounded +rdvx418 divide 12345 5.1 -> 2420.6 Inexact Rounded + +rounding: up +rdvx501 divide 12345 1 -> 12345 +rdvx502 divide 12345 1.0001 -> 12344 Inexact Rounded +rdvx503 divide 12345 1.001 -> 12333 Inexact Rounded +rdvx504 divide 12345 1.01 -> 12223 Inexact Rounded +rdvx505 divide 12345 1.1 -> 11223 Inexact Rounded +rdvx506 divide 12355 4 -> 3088.8 Inexact Rounded +rdvx507 divide 12345 4 -> 3086.3 Inexact Rounded +rdvx508 divide 12355 4.0001 -> 3088.7 Inexact Rounded +rdvx509 divide 12345 4.0001 -> 3086.2 Inexact Rounded +rdvx510 divide 12345 4.9 -> 2519.4 Inexact Rounded +rdvx511 divide 12345 4.99 -> 2474.0 Inexact Rounded +rdvx512 divide 12345 4.999 -> 2469.5 Inexact Rounded +rdvx513 divide 12345 4.9999 -> 2469.1 Inexact Rounded +rdvx514 divide 12345 5 -> 2469 +rdvx515 divide 12345 5.0001 -> 2469.0 Inexact Rounded +rdvx516 divide 12345 5.001 -> 2468.6 Inexact Rounded +rdvx517 divide 12345 5.01 -> 2464.1 Inexact Rounded +rdvx518 divide 12345 5.1 -> 2420.6 Inexact Rounded + +rounding: floor +rdvx601 divide 12345 1 -> 12345 +rdvx602 divide 12345 1.0001 -> 12343 Inexact Rounded +rdvx603 divide 12345 1.001 -> 12332 Inexact Rounded +rdvx604 divide 12345 1.01 -> 12222 Inexact Rounded +rdvx605 divide 12345 1.1 -> 11222 Inexact Rounded +rdvx606 divide 12355 4 -> 3088.7 Inexact Rounded +rdvx607 divide 12345 4 -> 3086.2 Inexact Rounded +rdvx608 divide 12355 4.0001 -> 3088.6 Inexact Rounded +rdvx609 divide 12345 4.0001 -> 3086.1 Inexact Rounded +rdvx610 divide 12345 4.9 -> 2519.3 Inexact Rounded +rdvx611 divide 12345 4.99 -> 2473.9 Inexact Rounded +rdvx612 divide 12345 4.999 -> 2469.4 Inexact Rounded +rdvx613 divide 12345 4.9999 -> 2469.0 Inexact Rounded +rdvx614 divide 12345 5 -> 2469 +rdvx615 divide 12345 5.0001 -> 2468.9 Inexact Rounded +rdvx616 divide 12345 5.001 -> 2468.5 Inexact Rounded +rdvx617 divide 12345 5.01 -> 2464.0 Inexact Rounded +rdvx618 divide 12345 5.1 -> 2420.5 Inexact Rounded + +rounding: ceiling +rdvx701 divide 12345 1 -> 12345 +rdvx702 divide 12345 1.0001 -> 12344 Inexact Rounded +rdvx703 divide 12345 1.001 -> 12333 Inexact Rounded +rdvx704 divide 12345 1.01 -> 12223 Inexact Rounded +rdvx705 divide 12345 1.1 -> 11223 Inexact Rounded +rdvx706 divide 12355 4 -> 3088.8 Inexact Rounded +rdvx707 divide 12345 4 -> 3086.3 Inexact Rounded +rdvx708 divide 12355 4.0001 -> 3088.7 Inexact Rounded +rdvx709 divide 12345 4.0001 -> 3086.2 Inexact Rounded +rdvx710 divide 12345 4.9 -> 2519.4 Inexact Rounded +rdvx711 divide 12345 4.99 -> 2474.0 Inexact Rounded +rdvx712 divide 12345 4.999 -> 2469.5 Inexact Rounded +rdvx713 divide 12345 4.9999 -> 2469.1 Inexact Rounded +rdvx714 divide 12345 5 -> 2469 +rdvx715 divide 12345 5.0001 -> 2469.0 Inexact Rounded +rdvx716 divide 12345 5.001 -> 2468.6 Inexact Rounded +rdvx717 divide 12345 5.01 -> 2464.1 Inexact Rounded +rdvx718 divide 12345 5.1 -> 2420.6 Inexact Rounded + +-- [divideInteger and remainder unaffected] + +-- Multiplication operator -------------------------------------------- + +rounding: down +rmux101 multiply 12345 1 -> 12345 +rmux102 multiply 12345 1.0001 -> 12346 Inexact Rounded +rmux103 multiply 12345 1.001 -> 12357 Inexact Rounded +rmux104 multiply 12345 1.01 -> 12468 Inexact Rounded +rmux105 multiply 12345 1.1 -> 13579 Inexact Rounded +rmux106 multiply 12345 4 -> 49380 +rmux107 multiply 12345 4.0001 -> 49381 Inexact Rounded +rmux108 multiply 12345 4.9 -> 60490 Inexact Rounded +rmux109 multiply 12345 4.99 -> 61601 Inexact Rounded +rmux110 multiply 12345 4.999 -> 61712 Inexact Rounded +rmux111 multiply 12345 4.9999 -> 61723 Inexact Rounded +rmux112 multiply 12345 5 -> 61725 +rmux113 multiply 12345 5.0001 -> 61726 Inexact Rounded +rmux114 multiply 12345 5.001 -> 61737 Inexact Rounded +rmux115 multiply 12345 5.01 -> 61848 Inexact Rounded +rmux116 multiply 12345 12 -> 1.4814E+5 Rounded +rmux117 multiply 12345 13 -> 1.6048E+5 Inexact Rounded +rmux118 multiply 12355 12 -> 1.4826E+5 Rounded +rmux119 multiply 12355 13 -> 1.6061E+5 Inexact Rounded + +rounding: half_down +rmux201 multiply 12345 1 -> 12345 +rmux202 multiply 12345 1.0001 -> 12346 Inexact Rounded +rmux203 multiply 12345 1.001 -> 12357 Inexact Rounded +rmux204 multiply 12345 1.01 -> 12468 Inexact Rounded +rmux205 multiply 12345 1.1 -> 13579 Inexact Rounded +rmux206 multiply 12345 4 -> 49380 +rmux207 multiply 12345 4.0001 -> 49381 Inexact Rounded +rmux208 multiply 12345 4.9 -> 60490 Inexact Rounded +rmux209 multiply 12345 4.99 -> 61602 Inexact Rounded +rmux210 multiply 12345 4.999 -> 61713 Inexact Rounded +rmux211 multiply 12345 4.9999 -> 61724 Inexact Rounded +rmux212 multiply 12345 5 -> 61725 +rmux213 multiply 12345 5.0001 -> 61726 Inexact Rounded +rmux214 multiply 12345 5.001 -> 61737 Inexact Rounded +rmux215 multiply 12345 5.01 -> 61848 Inexact Rounded +rmux216 multiply 12345 12 -> 1.4814E+5 Rounded +rmux217 multiply 12345 13 -> 1.6048E+5 Inexact Rounded +rmux218 multiply 12355 12 -> 1.4826E+5 Rounded +rmux219 multiply 12355 13 -> 1.6061E+5 Inexact Rounded + +rounding: half_even +rmux301 multiply 12345 1 -> 12345 +rmux302 multiply 12345 1.0001 -> 12346 Inexact Rounded +rmux303 multiply 12345 1.001 -> 12357 Inexact Rounded +rmux304 multiply 12345 1.01 -> 12468 Inexact Rounded +rmux305 multiply 12345 1.1 -> 13580 Inexact Rounded +rmux306 multiply 12345 4 -> 49380 +rmux307 multiply 12345 4.0001 -> 49381 Inexact Rounded +rmux308 multiply 12345 4.9 -> 60490 Inexact Rounded +rmux309 multiply 12345 4.99 -> 61602 Inexact Rounded +rmux310 multiply 12345 4.999 -> 61713 Inexact Rounded +rmux311 multiply 12345 4.9999 -> 61724 Inexact Rounded +rmux312 multiply 12345 5 -> 61725 +rmux313 multiply 12345 5.0001 -> 61726 Inexact Rounded +rmux314 multiply 12345 5.001 -> 61737 Inexact Rounded +rmux315 multiply 12345 5.01 -> 61848 Inexact Rounded +rmux316 multiply 12345 12 -> 1.4814E+5 Rounded +rmux317 multiply 12345 13 -> 1.6048E+5 Inexact Rounded +rmux318 multiply 12355 12 -> 1.4826E+5 Rounded +rmux319 multiply 12355 13 -> 1.6062E+5 Inexact Rounded + +rounding: half_up +rmux401 multiply 12345 1 -> 12345 +rmux402 multiply 12345 1.0001 -> 12346 Inexact Rounded +rmux403 multiply 12345 1.001 -> 12357 Inexact Rounded +rmux404 multiply 12345 1.01 -> 12468 Inexact Rounded +rmux405 multiply 12345 1.1 -> 13580 Inexact Rounded +rmux406 multiply 12345 4 -> 49380 +rmux407 multiply 12345 4.0001 -> 49381 Inexact Rounded +rmux408 multiply 12345 4.9 -> 60491 Inexact Rounded +rmux409 multiply 12345 4.99 -> 61602 Inexact Rounded +rmux410 multiply 12345 4.999 -> 61713 Inexact Rounded +rmux411 multiply 12345 4.9999 -> 61724 Inexact Rounded +rmux412 multiply 12345 5 -> 61725 +rmux413 multiply 12345 5.0001 -> 61726 Inexact Rounded +rmux414 multiply 12345 5.001 -> 61737 Inexact Rounded +rmux415 multiply 12345 5.01 -> 61848 Inexact Rounded +rmux416 multiply 12345 12 -> 1.4814E+5 Rounded +rmux417 multiply 12345 13 -> 1.6049E+5 Inexact Rounded +rmux418 multiply 12355 12 -> 1.4826E+5 Rounded +rmux419 multiply 12355 13 -> 1.6062E+5 Inexact Rounded + +rounding: up +rmux501 multiply 12345 1 -> 12345 +rmux502 multiply 12345 1.0001 -> 12347 Inexact Rounded +rmux503 multiply 12345 1.001 -> 12358 Inexact Rounded +rmux504 multiply 12345 1.01 -> 12469 Inexact Rounded +rmux505 multiply 12345 1.1 -> 13580 Inexact Rounded +rmux506 multiply 12345 4 -> 49380 +rmux507 multiply 12345 4.0001 -> 49382 Inexact Rounded +rmux508 multiply 12345 4.9 -> 60491 Inexact Rounded +rmux509 multiply 12345 4.99 -> 61602 Inexact Rounded +rmux510 multiply 12345 4.999 -> 61713 Inexact Rounded +rmux511 multiply 12345 4.9999 -> 61724 Inexact Rounded +rmux512 multiply 12345 5 -> 61725 +rmux513 multiply 12345 5.0001 -> 61727 Inexact Rounded +rmux514 multiply 12345 5.001 -> 61738 Inexact Rounded +rmux515 multiply 12345 5.01 -> 61849 Inexact Rounded +rmux516 multiply 12345 12 -> 1.4814E+5 Rounded +rmux517 multiply 12345 13 -> 1.6049E+5 Inexact Rounded +rmux518 multiply 12355 12 -> 1.4826E+5 Rounded +rmux519 multiply 12355 13 -> 1.6062E+5 Inexact Rounded +-- [rmux516 & rmux518] can surprise + +rounding: floor +rmux601 multiply 12345 1 -> 12345 +rmux602 multiply 12345 1.0001 -> 12346 Inexact Rounded +rmux603 multiply 12345 1.001 -> 12357 Inexact Rounded +rmux604 multiply 12345 1.01 -> 12468 Inexact Rounded +rmux605 multiply 12345 1.1 -> 13579 Inexact Rounded +rmux606 multiply 12345 4 -> 49380 +rmux607 multiply 12345 4.0001 -> 49381 Inexact Rounded +rmux608 multiply 12345 4.9 -> 60490 Inexact Rounded +rmux609 multiply 12345 4.99 -> 61601 Inexact Rounded +rmux610 multiply 12345 4.999 -> 61712 Inexact Rounded +rmux611 multiply 12345 4.9999 -> 61723 Inexact Rounded +rmux612 multiply 12345 5 -> 61725 +rmux613 multiply 12345 5.0001 -> 61726 Inexact Rounded +rmux614 multiply 12345 5.001 -> 61737 Inexact Rounded +rmux615 multiply 12345 5.01 -> 61848 Inexact Rounded +rmux616 multiply 12345 12 -> 1.4814E+5 Rounded +rmux617 multiply 12345 13 -> 1.6048E+5 Inexact Rounded +rmux618 multiply 12355 12 -> 1.4826E+5 Rounded +rmux619 multiply 12355 13 -> 1.6061E+5 Inexact Rounded + +rounding: ceiling +rmux701 multiply 12345 1 -> 12345 +rmux702 multiply 12345 1.0001 -> 12347 Inexact Rounded +rmux703 multiply 12345 1.001 -> 12358 Inexact Rounded +rmux704 multiply 12345 1.01 -> 12469 Inexact Rounded +rmux705 multiply 12345 1.1 -> 13580 Inexact Rounded +rmux706 multiply 12345 4 -> 49380 +rmux707 multiply 12345 4.0001 -> 49382 Inexact Rounded +rmux708 multiply 12345 4.9 -> 60491 Inexact Rounded +rmux709 multiply 12345 4.99 -> 61602 Inexact Rounded +rmux710 multiply 12345 4.999 -> 61713 Inexact Rounded +rmux711 multiply 12345 4.9999 -> 61724 Inexact Rounded +rmux712 multiply 12345 5 -> 61725 +rmux713 multiply 12345 5.0001 -> 61727 Inexact Rounded +rmux714 multiply 12345 5.001 -> 61738 Inexact Rounded +rmux715 multiply 12345 5.01 -> 61849 Inexact Rounded +rmux716 multiply 12345 12 -> 1.4814E+5 Rounded +rmux717 multiply 12345 13 -> 1.6049E+5 Inexact Rounded +rmux718 multiply 12355 12 -> 1.4826E+5 Rounded +rmux719 multiply 12355 13 -> 1.6062E+5 Inexact Rounded + +-- Power operator ----------------------------------------------------- + +rounding: down +rpox101 power 12345 -5 -> 3.4877E-21 Inexact Rounded +rpox102 power 12345 -4 -> 4.3056E-17 Inexact Rounded +rpox103 power 12345 -3 -> 5.3152E-13 Inexact Rounded +rpox104 power 12345 -2 -> 6.5617E-9 Inexact Rounded +rpox105 power 12345 -1 -> 0.000081004 Inexact Rounded +rpox106 power 12345 0 -> 1 +rpox107 power 12345 1 -> 12345 +rpox108 power 12345 2 -> 1.5239E+8 Inexact Rounded +rpox109 power 12345 3 -> 1.8813E+12 Inexact Rounded +rpox110 power 12345 4 -> 2.3225E+16 Inexact Rounded +rpox111 power 12345 5 -> 2.8671E+20 Inexact Rounded +rpox112 power 415 2 -> 1.7222E+5 Inexact Rounded +rpox113 power 75 3 -> 4.2187E+5 Inexact Rounded + +rounding: half_down +rpox201 power 12345 -5 -> 3.4877E-21 Inexact Rounded +rpox202 power 12345 -4 -> 4.3056E-17 Inexact Rounded +rpox203 power 12345 -3 -> 5.3153E-13 Inexact Rounded +rpox204 power 12345 -2 -> 6.5617E-9 Inexact Rounded +rpox205 power 12345 -1 -> 0.000081004 Inexact Rounded +rpox206 power 12345 0 -> 1 +rpox207 power 12345 1 -> 12345 +rpox208 power 12345 2 -> 1.5240E+8 Inexact Rounded +rpox209 power 12345 3 -> 1.8814E+12 Inexact Rounded +rpox210 power 12345 4 -> 2.3225E+16 Inexact Rounded +rpox211 power 12345 5 -> 2.8672E+20 Inexact Rounded +rpox212 power 415 2 -> 1.7222E+5 Inexact Rounded +rpox213 power 75 3 -> 4.2187E+5 Inexact Rounded + +rounding: half_even +rpox301 power 12345 -5 -> 3.4877E-21 Inexact Rounded +rpox302 power 12345 -4 -> 4.3056E-17 Inexact Rounded +rpox303 power 12345 -3 -> 5.3153E-13 Inexact Rounded +rpox304 power 12345 -2 -> 6.5617E-9 Inexact Rounded +rpox305 power 12345 -1 -> 0.000081004 Inexact Rounded +rpox306 power 12345 0 -> 1 +rpox307 power 12345 1 -> 12345 +rpox308 power 12345 2 -> 1.5240E+8 Inexact Rounded +rpox309 power 12345 3 -> 1.8814E+12 Inexact Rounded +rpox310 power 12345 4 -> 2.3225E+16 Inexact Rounded +rpox311 power 12345 5 -> 2.8672E+20 Inexact Rounded +rpox312 power 415 2 -> 1.7222E+5 Inexact Rounded +rpox313 power 75 3 -> 4.2188E+5 Inexact Rounded + +rounding: half_up +rpox401 power 12345 -5 -> 3.4877E-21 Inexact Rounded +rpox402 power 12345 -4 -> 4.3056E-17 Inexact Rounded +rpox403 power 12345 -3 -> 5.3153E-13 Inexact Rounded +rpox404 power 12345 -2 -> 6.5617E-9 Inexact Rounded +rpox405 power 12345 -1 -> 0.000081004 Inexact Rounded +rpox406 power 12345 0 -> 1 +rpox407 power 12345 1 -> 12345 +rpox408 power 12345 2 -> 1.5240E+8 Inexact Rounded +rpox409 power 12345 3 -> 1.8814E+12 Inexact Rounded +rpox410 power 12345 4 -> 2.3225E+16 Inexact Rounded +rpox411 power 12345 5 -> 2.8672E+20 Inexact Rounded +rpox412 power 415 2 -> 1.7223E+5 Inexact Rounded +rpox413 power 75 3 -> 4.2188E+5 Inexact Rounded + +rounding: up +rpox501 power 12345 -5 -> 3.4878E-21 Inexact Rounded +rpox502 power 12345 -4 -> 4.3057E-17 Inexact Rounded +rpox503 power 12345 -3 -> 5.3153E-13 Inexact Rounded +rpox504 power 12345 -2 -> 6.5618E-9 Inexact Rounded +rpox505 power 12345 -1 -> 0.000081005 Inexact Rounded +rpox506 power 12345 0 -> 1 +rpox507 power 12345 1 -> 12345 +rpox508 power 12345 2 -> 1.5240E+8 Inexact Rounded +rpox509 power 12345 3 -> 1.8814E+12 Inexact Rounded +rpox510 power 12345 4 -> 2.3226E+16 Inexact Rounded +rpox511 power 12345 5 -> 2.8672E+20 Inexact Rounded +rpox512 power 415 2 -> 1.7223E+5 Inexact Rounded +rpox513 power 75 3 -> 4.2188E+5 Inexact Rounded + +rounding: floor +rpox601 power 12345 -5 -> 3.4877E-21 Inexact Rounded +rpox602 power 12345 -4 -> 4.3056E-17 Inexact Rounded +rpox603 power 12345 -3 -> 5.3152E-13 Inexact Rounded +rpox604 power 12345 -2 -> 6.5617E-9 Inexact Rounded +rpox605 power 12345 -1 -> 0.000081004 Inexact Rounded +rpox606 power 12345 0 -> 1 +rpox607 power 12345 1 -> 12345 +rpox608 power 12345 2 -> 1.5239E+8 Inexact Rounded +rpox609 power 12345 3 -> 1.8813E+12 Inexact Rounded +rpox610 power 12345 4 -> 2.3225E+16 Inexact Rounded +rpox611 power 12345 5 -> 2.8671E+20 Inexact Rounded +rpox612 power 415 2 -> 1.7222E+5 Inexact Rounded +rpox613 power 75 3 -> 4.2187E+5 Inexact Rounded + +rounding: ceiling +rpox701 power 12345 -5 -> 3.4878E-21 Inexact Rounded +rpox702 power 12345 -4 -> 4.3057E-17 Inexact Rounded +rpox703 power 12345 -3 -> 5.3153E-13 Inexact Rounded +rpox704 power 12345 -2 -> 6.5618E-9 Inexact Rounded +rpox705 power 12345 -1 -> 0.000081005 Inexact Rounded +rpox706 power 12345 0 -> 1 +rpox707 power 12345 1 -> 12345 +rpox708 power 12345 2 -> 1.5240E+8 Inexact Rounded +rpox709 power 12345 3 -> 1.8814E+12 Inexact Rounded +rpox710 power 12345 4 -> 2.3226E+16 Inexact Rounded +rpox711 power 12345 5 -> 2.8672E+20 Inexact Rounded +rpox712 power 415 2 -> 1.7223E+5 Inexact Rounded +rpox713 power 75 3 -> 4.2188E+5 Inexact Rounded + +-- Underflow Subnormal and overflow values vary with rounding mode and sign +maxexponent: 999999999 +minexponent: -999999999 +rounding: down +rovx100 multiply 10 9E+999999999 -> 9.9999E+999999999 Overflow Inexact Rounded +rovx101 multiply -10 9E+999999999 -> -9.9999E+999999999 Overflow Inexact Rounded +rovx102 divide 1E-9 9E+999999999 -> 0E-1000000003 Underflow Subnormal Inexact Rounded +rovx104 divide -1E-9 9E+999999999 -> -0E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: up +rovx110 multiply 10 9E+999999999 -> Infinity Overflow Inexact Rounded +rovx111 multiply -10 9E+999999999 -> -Infinity Overflow Inexact Rounded +rovx112 divide 1E-9 9E+999999999 -> 1E-1000000003 Underflow Subnormal Inexact Rounded +rovx114 divide -1E-9 9E+999999999 -> -1E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: ceiling +rovx120 multiply 10 9E+999999999 -> Infinity Overflow Inexact Rounded +rovx121 multiply -10 9E+999999999 -> -9.9999E+999999999 Overflow Inexact Rounded +rovx122 divide 1E-9 9E+999999999 -> 1E-1000000003 Underflow Subnormal Inexact Rounded +rovx124 divide -1E-9 9E+999999999 -> -0E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: floor +rovx130 multiply 10 9E+999999999 -> 9.9999E+999999999 Overflow Inexact Rounded +rovx131 multiply -10 9E+999999999 -> -Infinity Overflow Inexact Rounded +rovx132 divide 1E-9 9E+999999999 -> 0E-1000000003 Underflow Subnormal Inexact Rounded +rovx134 divide -1E-9 9E+999999999 -> -1E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: half_up +rovx140 multiply 10 9E+999999999 -> Infinity Overflow Inexact Rounded +rovx141 multiply -10 9E+999999999 -> -Infinity Overflow Inexact Rounded +rovx142 divide 1E-9 9E+999999999 -> 0E-1000000003 Underflow Subnormal Inexact Rounded +rovx144 divide -1E-9 9E+999999999 -> -0E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: half_even +rovx150 multiply 10 9E+999999999 -> Infinity Overflow Inexact Rounded +rovx151 multiply -10 9E+999999999 -> -Infinity Overflow Inexact Rounded +rovx152 divide 1E-9 9E+999999999 -> 0E-1000000003 Underflow Subnormal Inexact Rounded +rovx154 divide -1E-9 9E+999999999 -> -0E-1000000003 Underflow Subnormal Inexact Rounded + +rounding: half_down +rovx160 multiply 10 9E+999999999 -> Infinity Overflow Inexact Rounded +rovx161 multiply -10 9E+999999999 -> -Infinity Overflow Inexact Rounded +rovx162 divide 1E-9 9E+999999999 -> 0E-1000000003 Underflow Subnormal Inexact Rounded +rovx164 divide -1E-9 9E+999999999 -> -0E-1000000003 Underflow Subnormal Inexact Rounded + +-- check maximum finite value over a range of precisions +rounding: down +precision: 1 +rovx200 multiply 10 9E+999999999 -> 9E+999999999 Overflow Inexact Rounded +rovx201 multiply -10 9E+999999999 -> -9E+999999999 Overflow Inexact Rounded +precision: 2 +rovx210 multiply 10 9E+999999999 -> 9.9E+999999999 Overflow Inexact Rounded +rovx211 multiply -10 9E+999999999 -> -9.9E+999999999 Overflow Inexact Rounded +precision: 3 +rovx220 multiply 10 9E+999999999 -> 9.99E+999999999 Overflow Inexact Rounded +rovx221 multiply -10 9E+999999999 -> -9.99E+999999999 Overflow Inexact Rounded +precision: 4 +rovx230 multiply 10 9E+999999999 -> 9.999E+999999999 Overflow Inexact Rounded +rovx231 multiply -10 9E+999999999 -> -9.999E+999999999 Overflow Inexact Rounded +precision: 5 +rovx240 multiply 10 9E+999999999 -> 9.9999E+999999999 Overflow Inexact Rounded +rovx241 multiply -10 9E+999999999 -> -9.9999E+999999999 Overflow Inexact Rounded +precision: 6 +rovx250 multiply 10 9E+999999999 -> 9.99999E+999999999 Overflow Inexact Rounded +rovx251 multiply -10 9E+999999999 -> -9.99999E+999999999 Overflow Inexact Rounded +precision: 7 +rovx260 multiply 10 9E+999999999 -> 9.999999E+999999999 Overflow Inexact Rounded +rovx261 multiply -10 9E+999999999 -> -9.999999E+999999999 Overflow Inexact Rounded +precision: 8 +rovx270 multiply 10 9E+999999999 -> 9.9999999E+999999999 Overflow Inexact Rounded +rovx271 multiply -10 9E+999999999 -> -9.9999999E+999999999 Overflow Inexact Rounded +precision: 9 +rovx280 multiply 10 9E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded +rovx281 multiply -10 9E+999999999 -> -9.99999999E+999999999 Overflow Inexact Rounded +precision: 10 +rovx290 multiply 10 9E+999999999 -> 9.999999999E+999999999 Overflow Inexact Rounded +rovx291 multiply -10 9E+999999999 -> -9.999999999E+999999999 Overflow Inexact Rounded + +-- reprise rounding mode effect (using multiplies so precision directive used) +precision: 9 +maxexponent: 999999999 +rounding: half_up +rmex400 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded +rmex401 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded +rounding: half_down +rmex402 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded +rmex403 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded +rounding: half_even +rmex404 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded +rmex405 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded +rounding: floor +rmex406 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded +rmex407 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded +rounding: ceiling +rmex408 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded +rmex409 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded +rounding: up +rmex410 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded +rmex411 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded +rounding: down +rmex412 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded +rmex413 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded + Added: sandbox/trunk/decimal-c/decimaltestdata/samequantum.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/samequantum.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,353 @@ +------------------------------------------------------------------------ +-- samequantum.decTest -- check quantums match -- +-- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minExponent: -999 + +samq001 samequantum 0 0 -> 1 +samq002 samequantum 0 1 -> 1 +samq003 samequantum 1 0 -> 1 +samq004 samequantum 1 1 -> 1 + +samq011 samequantum 10 1E+1 -> 0 +samq012 samequantum 10E+1 10E+1 -> 1 +samq013 samequantum 100 10E+1 -> 0 +samq014 samequantum 100 1E+2 -> 0 +samq015 samequantum 0.1 1E-2 -> 0 +samq016 samequantum 0.1 1E-1 -> 1 +samq017 samequantum 0.1 1E-0 -> 0 +samq018 samequantum 999 999 -> 1 +samq019 samequantum 999E-1 99.9 -> 1 +samq020 samequantum 111E-1 22.2 -> 1 +samq021 samequantum 111E-1 1234.2 -> 1 + +-- zeros +samq030 samequantum 0.0 1.1 -> 1 +samq031 samequantum 0.0 1.11 -> 0 +samq032 samequantum 0.0 0 -> 0 +samq033 samequantum 0.0 0.0 -> 1 +samq034 samequantum 0.0 0.00 -> 0 +samq035 samequantum 0E+1 0E+0 -> 0 +samq036 samequantum 0E+1 0E+1 -> 1 +samq037 samequantum 0E+1 0E+2 -> 0 +samq038 samequantum 0E-17 0E-16 -> 0 +samq039 samequantum 0E-17 0E-17 -> 1 +samq040 samequantum 0E-17 0E-18 -> 0 +samq041 samequantum 0E-17 0.0E-15 -> 0 +samq042 samequantum 0E-17 0.0E-16 -> 1 +samq043 samequantum 0E-17 0.0E-17 -> 0 +samq044 samequantum -0E-17 0.0E-16 -> 1 +samq045 samequantum 0E-17 -0.0E-17 -> 0 +samq046 samequantum 0E-17 -0.0E-16 -> 1 +samq047 samequantum -0E-17 0.0E-17 -> 0 +samq048 samequantum -0E-17 -0.0E-16 -> 1 +samq049 samequantum -0E-17 -0.0E-17 -> 0 + +-- specials & combinations + +samq0110 samequantum -Inf -Inf -> 1 +samq0111 samequantum -Inf Inf -> 1 +samq0112 samequantum -Inf NaN -> 0 +samq0113 samequantum -Inf -7E+3 -> 0 +samq0114 samequantum -Inf -7 -> 0 +samq0115 samequantum -Inf -7E-3 -> 0 +samq0116 samequantum -Inf -0E-3 -> 0 +samq0117 samequantum -Inf -0 -> 0 +samq0118 samequantum -Inf -0E+3 -> 0 +samq0119 samequantum -Inf 0E-3 -> 0 +samq0120 samequantum -Inf 0 -> 0 +samq0121 samequantum -Inf 0E+3 -> 0 +samq0122 samequantum -Inf 7E-3 -> 0 +samq0123 samequantum -Inf 7 -> 0 +samq0124 samequantum -Inf 7E+3 -> 0 +samq0125 samequantum -Inf sNaN -> 0 + +samq0210 samequantum Inf -Inf -> 1 +samq0211 samequantum Inf Inf -> 1 +samq0212 samequantum Inf NaN -> 0 +samq0213 samequantum Inf -7E+3 -> 0 +samq0214 samequantum Inf -7 -> 0 +samq0215 samequantum Inf -7E-3 -> 0 +samq0216 samequantum Inf -0E-3 -> 0 +samq0217 samequantum Inf -0 -> 0 +samq0218 samequantum Inf -0E+3 -> 0 +samq0219 samequantum Inf 0E-3 -> 0 +samq0220 samequantum Inf 0 -> 0 +samq0221 samequantum Inf 0E+3 -> 0 +samq0222 samequantum Inf 7E-3 -> 0 +samq0223 samequantum Inf 7 -> 0 +samq0224 samequantum Inf 7E+3 -> 0 +samq0225 samequantum Inf sNaN -> 0 + +samq0310 samequantum NaN -Inf -> 0 +samq0311 samequantum NaN Inf -> 0 +samq0312 samequantum NaN NaN -> 1 +samq0313 samequantum NaN -7E+3 -> 0 +samq0314 samequantum NaN -7 -> 0 +samq0315 samequantum NaN -7E-3 -> 0 +samq0316 samequantum NaN -0E-3 -> 0 +samq0317 samequantum NaN -0 -> 0 +samq0318 samequantum NaN -0E+3 -> 0 +samq0319 samequantum NaN 0E-3 -> 0 +samq0320 samequantum NaN 0 -> 0 +samq0321 samequantum NaN 0E+3 -> 0 +samq0322 samequantum NaN 7E-3 -> 0 +samq0323 samequantum NaN 7 -> 0 +samq0324 samequantum NaN 7E+3 -> 0 +samq0325 samequantum NaN sNaN -> 1 + +samq0410 samequantum -7E+3 -Inf -> 0 +samq0411 samequantum -7E+3 Inf -> 0 +samq0412 samequantum -7E+3 NaN -> 0 +samq0413 samequantum -7E+3 -7E+3 -> 1 +samq0414 samequantum -7E+3 -7 -> 0 +samq0415 samequantum -7E+3 -7E-3 -> 0 +samq0416 samequantum -7E+3 -0E-3 -> 0 +samq0417 samequantum -7E+3 -0 -> 0 +samq0418 samequantum -7E+3 -0E+3 -> 1 +samq0419 samequantum -7E+3 0E-3 -> 0 +samq0420 samequantum -7E+3 0 -> 0 +samq0421 samequantum -7E+3 0E+3 -> 1 +samq0422 samequantum -7E+3 7E-3 -> 0 +samq0423 samequantum -7E+3 7 -> 0 +samq0424 samequantum -7E+3 7E+3 -> 1 +samq0425 samequantum -7E+3 sNaN -> 0 + +samq0510 samequantum -7 -Inf -> 0 +samq0511 samequantum -7 Inf -> 0 +samq0512 samequantum -7 NaN -> 0 +samq0513 samequantum -7 -7E+3 -> 0 +samq0514 samequantum -7 -7 -> 1 +samq0515 samequantum -7 -7E-3 -> 0 +samq0516 samequantum -7 -0E-3 -> 0 +samq0517 samequantum -7 -0 -> 1 +samq0518 samequantum -7 -0E+3 -> 0 +samq0519 samequantum -7 0E-3 -> 0 +samq0520 samequantum -7 0 -> 1 +samq0521 samequantum -7 0E+3 -> 0 +samq0522 samequantum -7 7E-3 -> 0 +samq0523 samequantum -7 7 -> 1 +samq0524 samequantum -7 7E+3 -> 0 +samq0525 samequantum -7 sNaN -> 0 + +samq0610 samequantum -7E-3 -Inf -> 0 +samq0611 samequantum -7E-3 Inf -> 0 +samq0612 samequantum -7E-3 NaN -> 0 +samq0613 samequantum -7E-3 -7E+3 -> 0 +samq0614 samequantum -7E-3 -7 -> 0 +samq0615 samequantum -7E-3 -7E-3 -> 1 +samq0616 samequantum -7E-3 -0E-3 -> 1 +samq0617 samequantum -7E-3 -0 -> 0 +samq0618 samequantum -7E-3 -0E+3 -> 0 +samq0619 samequantum -7E-3 0E-3 -> 1 +samq0620 samequantum -7E-3 0 -> 0 +samq0621 samequantum -7E-3 0E+3 -> 0 +samq0622 samequantum -7E-3 7E-3 -> 1 +samq0623 samequantum -7E-3 7 -> 0 +samq0624 samequantum -7E-3 7E+3 -> 0 +samq0625 samequantum -7E-3 sNaN -> 0 + +samq0710 samequantum -0E-3 -Inf -> 0 +samq0711 samequantum -0E-3 Inf -> 0 +samq0712 samequantum -0E-3 NaN -> 0 +samq0713 samequantum -0E-3 -7E+3 -> 0 +samq0714 samequantum -0E-3 -7 -> 0 +samq0715 samequantum -0E-3 -7E-3 -> 1 +samq0716 samequantum -0E-3 -0E-3 -> 1 +samq0717 samequantum -0E-3 -0 -> 0 +samq0718 samequantum -0E-3 -0E+3 -> 0 +samq0719 samequantum -0E-3 0E-3 -> 1 +samq0720 samequantum -0E-3 0 -> 0 +samq0721 samequantum -0E-3 0E+3 -> 0 +samq0722 samequantum -0E-3 7E-3 -> 1 +samq0723 samequantum -0E-3 7 -> 0 +samq0724 samequantum -0E-3 7E+3 -> 0 +samq0725 samequantum -0E-3 sNaN -> 0 + +samq0810 samequantum -0 -Inf -> 0 +samq0811 samequantum -0 Inf -> 0 +samq0812 samequantum -0 NaN -> 0 +samq0813 samequantum -0 -7E+3 -> 0 +samq0814 samequantum -0 -7 -> 1 +samq0815 samequantum -0 -7E-3 -> 0 +samq0816 samequantum -0 -0E-3 -> 0 +samq0817 samequantum -0 -0 -> 1 +samq0818 samequantum -0 -0E+3 -> 0 +samq0819 samequantum -0 0E-3 -> 0 +samq0820 samequantum -0 0 -> 1 +samq0821 samequantum -0 0E+3 -> 0 +samq0822 samequantum -0 7E-3 -> 0 +samq0823 samequantum -0 7 -> 1 +samq0824 samequantum -0 7E+3 -> 0 +samq0825 samequantum -0 sNaN -> 0 + +samq0910 samequantum -0E+3 -Inf -> 0 +samq0911 samequantum -0E+3 Inf -> 0 +samq0912 samequantum -0E+3 NaN -> 0 +samq0913 samequantum -0E+3 -7E+3 -> 1 +samq0914 samequantum -0E+3 -7 -> 0 +samq0915 samequantum -0E+3 -7E-3 -> 0 +samq0916 samequantum -0E+3 -0E-3 -> 0 +samq0917 samequantum -0E+3 -0 -> 0 +samq0918 samequantum -0E+3 -0E+3 -> 1 +samq0919 samequantum -0E+3 0E-3 -> 0 +samq0920 samequantum -0E+3 0 -> 0 +samq0921 samequantum -0E+3 0E+3 -> 1 +samq0922 samequantum -0E+3 7E-3 -> 0 +samq0923 samequantum -0E+3 7 -> 0 +samq0924 samequantum -0E+3 7E+3 -> 1 +samq0925 samequantum -0E+3 sNaN -> 0 + +samq1110 samequantum 0E-3 -Inf -> 0 +samq1111 samequantum 0E-3 Inf -> 0 +samq1112 samequantum 0E-3 NaN -> 0 +samq1113 samequantum 0E-3 -7E+3 -> 0 +samq1114 samequantum 0E-3 -7 -> 0 +samq1115 samequantum 0E-3 -7E-3 -> 1 +samq1116 samequantum 0E-3 -0E-3 -> 1 +samq1117 samequantum 0E-3 -0 -> 0 +samq1118 samequantum 0E-3 -0E+3 -> 0 +samq1119 samequantum 0E-3 0E-3 -> 1 +samq1120 samequantum 0E-3 0 -> 0 +samq1121 samequantum 0E-3 0E+3 -> 0 +samq1122 samequantum 0E-3 7E-3 -> 1 +samq1123 samequantum 0E-3 7 -> 0 +samq1124 samequantum 0E-3 7E+3 -> 0 +samq1125 samequantum 0E-3 sNaN -> 0 + +samq1210 samequantum 0 -Inf -> 0 +samq1211 samequantum 0 Inf -> 0 +samq1212 samequantum 0 NaN -> 0 +samq1213 samequantum 0 -7E+3 -> 0 +samq1214 samequantum 0 -7 -> 1 +samq1215 samequantum 0 -7E-3 -> 0 +samq1216 samequantum 0 -0E-3 -> 0 +samq1217 samequantum 0 -0 -> 1 +samq1218 samequantum 0 -0E+3 -> 0 +samq1219 samequantum 0 0E-3 -> 0 +samq1220 samequantum 0 0 -> 1 +samq1221 samequantum 0 0E+3 -> 0 +samq1222 samequantum 0 7E-3 -> 0 +samq1223 samequantum 0 7 -> 1 +samq1224 samequantum 0 7E+3 -> 0 +samq1225 samequantum 0 sNaN -> 0 + +samq1310 samequantum 0E+3 -Inf -> 0 +samq1311 samequantum 0E+3 Inf -> 0 +samq1312 samequantum 0E+3 NaN -> 0 +samq1313 samequantum 0E+3 -7E+3 -> 1 +samq1314 samequantum 0E+3 -7 -> 0 +samq1315 samequantum 0E+3 -7E-3 -> 0 +samq1316 samequantum 0E+3 -0E-3 -> 0 +samq1317 samequantum 0E+3 -0 -> 0 +samq1318 samequantum 0E+3 -0E+3 -> 1 +samq1319 samequantum 0E+3 0E-3 -> 0 +samq1320 samequantum 0E+3 0 -> 0 +samq1321 samequantum 0E+3 0E+3 -> 1 +samq1322 samequantum 0E+3 7E-3 -> 0 +samq1323 samequantum 0E+3 7 -> 0 +samq1324 samequantum 0E+3 7E+3 -> 1 +samq1325 samequantum 0E+3 sNaN -> 0 + +samq1410 samequantum 7E-3 -Inf -> 0 +samq1411 samequantum 7E-3 Inf -> 0 +samq1412 samequantum 7E-3 NaN -> 0 +samq1413 samequantum 7E-3 -7E+3 -> 0 +samq1414 samequantum 7E-3 -7 -> 0 +samq1415 samequantum 7E-3 -7E-3 -> 1 +samq1416 samequantum 7E-3 -0E-3 -> 1 +samq1417 samequantum 7E-3 -0 -> 0 +samq1418 samequantum 7E-3 -0E+3 -> 0 +samq1419 samequantum 7E-3 0E-3 -> 1 +samq1420 samequantum 7E-3 0 -> 0 +samq1421 samequantum 7E-3 0E+3 -> 0 +samq1422 samequantum 7E-3 7E-3 -> 1 +samq1423 samequantum 7E-3 7 -> 0 +samq1424 samequantum 7E-3 7E+3 -> 0 +samq1425 samequantum 7E-3 sNaN -> 0 + +samq1510 samequantum 7 -Inf -> 0 +samq1511 samequantum 7 Inf -> 0 +samq1512 samequantum 7 NaN -> 0 +samq1513 samequantum 7 -7E+3 -> 0 +samq1514 samequantum 7 -7 -> 1 +samq1515 samequantum 7 -7E-3 -> 0 +samq1516 samequantum 7 -0E-3 -> 0 +samq1517 samequantum 7 -0 -> 1 +samq1518 samequantum 7 -0E+3 -> 0 +samq1519 samequantum 7 0E-3 -> 0 +samq1520 samequantum 7 0 -> 1 +samq1521 samequantum 7 0E+3 -> 0 +samq1522 samequantum 7 7E-3 -> 0 +samq1523 samequantum 7 7 -> 1 +samq1524 samequantum 7 7E+3 -> 0 +samq1525 samequantum 7 sNaN -> 0 + +samq1610 samequantum 7E+3 -Inf -> 0 +samq1611 samequantum 7E+3 Inf -> 0 +samq1612 samequantum 7E+3 NaN -> 0 +samq1613 samequantum 7E+3 -7E+3 -> 1 +samq1614 samequantum 7E+3 -7 -> 0 +samq1615 samequantum 7E+3 -7E-3 -> 0 +samq1616 samequantum 7E+3 -0E-3 -> 0 +samq1617 samequantum 7E+3 -0 -> 0 +samq1618 samequantum 7E+3 -0E+3 -> 1 +samq1619 samequantum 7E+3 0E-3 -> 0 +samq1620 samequantum 7E+3 0 -> 0 +samq1621 samequantum 7E+3 0E+3 -> 1 +samq1622 samequantum 7E+3 7E-3 -> 0 +samq1623 samequantum 7E+3 7 -> 0 +samq1624 samequantum 7E+3 7E+3 -> 1 +samq1625 samequantum 7E+3 sNaN -> 0 + +samq1710 samequantum sNaN -Inf -> 0 +samq1711 samequantum sNaN Inf -> 0 +samq1712 samequantum sNaN NaN -> 1 +samq1713 samequantum sNaN -7E+3 -> 0 +samq1714 samequantum sNaN -7 -> 0 +samq1715 samequantum sNaN -7E-3 -> 0 +samq1716 samequantum sNaN -0E-3 -> 0 +samq1717 samequantum sNaN -0 -> 0 +samq1718 samequantum sNaN -0E+3 -> 0 +samq1719 samequantum sNaN 0E-3 -> 0 +samq1720 samequantum sNaN 0 -> 0 +samq1721 samequantum sNaN 0E+3 -> 0 +samq1722 samequantum sNaN 7E-3 -> 0 +samq1723 samequantum sNaN 7 -> 0 +samq1724 samequantum sNaN 7E+3 -> 0 +samq1725 samequantum sNaN sNaN -> 1 +-- noisy NaNs +samq1730 samequantum sNaN3 sNaN3 -> 1 +samq1731 samequantum sNaN3 sNaN4 -> 1 +samq1732 samequantum NaN3 NaN3 -> 1 +samq1733 samequantum NaN3 NaN4 -> 1 +samq1734 samequantum sNaN3 3 -> 0 +samq1735 samequantum NaN3 3 -> 0 +samq1736 samequantum 4 sNaN4 -> 0 +samq1737 samequantum 3 NaN3 -> 0 +samq1738 samequantum Inf sNaN4 -> 0 +samq1739 samequantum -Inf NaN3 -> 0 + + + Added: sandbox/trunk/decimal-c/decimaltestdata/squareroot.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/squareroot.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,2958 @@ +------------------------------------------------------------------------ +-- squareroot.decTest -- decimal square root -- +-- Copyright (c) IBM Corporation, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- basics +sqtx001 squareroot 1 -> 1 +sqtx002 squareroot -1 -> NaN Invalid_operation +sqtx003 squareroot 1.00 -> 1.0 +sqtx004 squareroot -1.00 -> NaN Invalid_operation +sqtx005 squareroot 0 -> 0 +sqtx006 squareroot 00.0 -> 0.0 +sqtx007 squareroot 0.00 -> 0.0 +sqtx008 squareroot 00.00 -> 0.0 +sqtx009 squareroot 00.000 -> 0.00 +sqtx010 squareroot 00.0000 -> 0.00 +sqtx011 squareroot 00 -> 0 + +sqtx012 squareroot -2 -> NaN Invalid_operation +sqtx013 squareroot 2 -> 1.41421356 Inexact Rounded +sqtx014 squareroot -2.00 -> NaN Invalid_operation +sqtx015 squareroot 2.00 -> 1.41421356 Inexact Rounded +sqtx016 squareroot -0 -> -0 +sqtx017 squareroot -0.0 -> -0.0 +sqtx018 squareroot -00.00 -> -0.0 +sqtx019 squareroot -00.000 -> -0.00 +sqtx020 squareroot -0.0000 -> -0.00 +sqtx021 squareroot -0E+9 -> -0E+4 +sqtx022 squareroot -0E+10 -> -0E+5 +sqtx023 squareroot -0E+11 -> -0E+5 +sqtx024 squareroot -0E+12 -> -0E+6 +sqtx025 squareroot -00 -> -0 +sqtx026 squareroot 0E+5 -> 0E+2 +sqtx027 squareroot 4.0 -> 2.0 +sqtx028 squareroot 4.00 -> 2.0 + +sqtx030 squareroot +0.1 -> 0.316227766 Inexact Rounded +sqtx031 squareroot -0.1 -> NaN Invalid_operation +sqtx032 squareroot +0.01 -> 0.1 +sqtx033 squareroot -0.01 -> NaN Invalid_operation +sqtx034 squareroot +0.001 -> 0.0316227766 Inexact Rounded +sqtx035 squareroot -0.001 -> NaN Invalid_operation +sqtx036 squareroot +0.000001 -> 0.001 +sqtx037 squareroot -0.000001 -> NaN Invalid_operation +sqtx038 squareroot +0.000000000001 -> 0.000001 +sqtx039 squareroot -0.000000000001 -> NaN Invalid_operation + +sqtx041 squareroot 1.1 -> 1.04880885 Inexact Rounded +sqtx042 squareroot 1.10 -> 1.04880885 Inexact Rounded +sqtx043 squareroot 1.100 -> 1.04880885 Inexact Rounded +sqtx044 squareroot 1.110 -> 1.05356538 Inexact Rounded +sqtx045 squareroot -1.1 -> NaN Invalid_operation +sqtx046 squareroot -1.10 -> NaN Invalid_operation +sqtx047 squareroot -1.100 -> NaN Invalid_operation +sqtx048 squareroot -1.110 -> NaN Invalid_operation +sqtx049 squareroot 9.9 -> 3.14642654 Inexact Rounded +sqtx050 squareroot 9.90 -> 3.14642654 Inexact Rounded +sqtx051 squareroot 9.900 -> 3.14642654 Inexact Rounded +sqtx052 squareroot 9.990 -> 3.16069613 Inexact Rounded +sqtx053 squareroot -9.9 -> NaN Invalid_operation +sqtx054 squareroot -9.90 -> NaN Invalid_operation +sqtx055 squareroot -9.900 -> NaN Invalid_operation +sqtx056 squareroot -9.990 -> NaN Invalid_operation + +sqtx060 squareroot 1 -> 1 +sqtx061 squareroot 1.0 -> 1.0 +sqtx062 squareroot 1.00 -> 1.0 +sqtx063 squareroot 10.0 -> 3.16227766 Inexact Rounded +sqtx064 squareroot 10.0 -> 3.16227766 Inexact Rounded +sqtx065 squareroot 10.0 -> 3.16227766 Inexact Rounded +sqtx066 squareroot 10.00 -> 3.16227766 Inexact Rounded +sqtx067 squareroot 100 -> 10 +sqtx068 squareroot 100.0 -> 10.0 +sqtx069 squareroot 100.00 -> 10.0 +sqtx070 squareroot 1.1000E+3 -> 33.1662479 Inexact Rounded +sqtx071 squareroot 1.10000E+3 -> 33.1662479 Inexact Rounded +sqtx072 squareroot -10.0 -> NaN Invalid_operation +sqtx073 squareroot -10.00 -> NaN Invalid_operation +sqtx074 squareroot -100.0 -> NaN Invalid_operation +sqtx075 squareroot -100.00 -> NaN Invalid_operation +sqtx076 squareroot -1.1000E+3 -> NaN Invalid_operation +sqtx077 squareroot -1.10000E+3 -> NaN Invalid_operation + +-- famous squares +sqtx080 squareroot 1 -> 1 +sqtx081 squareroot 4 -> 2 +sqtx082 squareroot 9 -> 3 +sqtx083 squareroot 16 -> 4 +sqtx084 squareroot 25 -> 5 +sqtx085 squareroot 36 -> 6 +sqtx086 squareroot 49 -> 7 +sqtx087 squareroot 64 -> 8 +sqtx088 squareroot 81 -> 9 +sqtx089 squareroot 100 -> 10 +sqtx090 squareroot 121 -> 11 +sqtx091 squareroot 144 -> 12 +sqtx092 squareroot 169 -> 13 +sqtx093 squareroot 256 -> 16 +sqtx094 squareroot 1024 -> 32 +sqtx095 squareroot 4096 -> 64 +sqtx100 squareroot 0.01 -> 0.1 +sqtx101 squareroot 0.04 -> 0.2 +sqtx102 squareroot 0.09 -> 0.3 +sqtx103 squareroot 0.16 -> 0.4 +sqtx104 squareroot 0.25 -> 0.5 +sqtx105 squareroot 0.36 -> 0.6 +sqtx106 squareroot 0.49 -> 0.7 +sqtx107 squareroot 0.64 -> 0.8 +sqtx108 squareroot 0.81 -> 0.9 +sqtx109 squareroot 1.00 -> 1.0 +sqtx110 squareroot 1.21 -> 1.1 +sqtx111 squareroot 1.44 -> 1.2 +sqtx112 squareroot 1.69 -> 1.3 +sqtx113 squareroot 2.56 -> 1.6 +sqtx114 squareroot 10.24 -> 3.2 +sqtx115 squareroot 40.96 -> 6.4 + +-- Precision 1 squareroot tests [exhaustive, plus exponent adjusts] +rounding: half_even +maxExponent: 999 +minexponent: -999 +precision: 1 +sqtx1201 squareroot 0.1 -> 0.3 Inexact Rounded +sqtx1202 squareroot 0.01 -> 0.1 +sqtx1203 squareroot 1.0E-1 -> 0.3 Inexact Rounded +sqtx1204 squareroot 1.00E-2 -> 0.1 Rounded +sqtx1205 squareroot 1E-3 -> 0.03 Inexact Rounded +sqtx1206 squareroot 1E+1 -> 3 Inexact Rounded +sqtx1207 squareroot 1E+2 -> 1E+1 +sqtx1208 squareroot 1E+3 -> 3E+1 Inexact Rounded +sqtx1209 squareroot 0.2 -> 0.4 Inexact Rounded +sqtx1210 squareroot 0.02 -> 0.1 Inexact Rounded +sqtx1211 squareroot 2.0E-1 -> 0.4 Inexact Rounded +sqtx1212 squareroot 2.00E-2 -> 0.1 Inexact Rounded +sqtx1213 squareroot 2E-3 -> 0.04 Inexact Rounded +sqtx1214 squareroot 2E+1 -> 4 Inexact Rounded +sqtx1215 squareroot 2E+2 -> 1E+1 Inexact Rounded +sqtx1216 squareroot 2E+3 -> 4E+1 Inexact Rounded +sqtx1217 squareroot 0.3 -> 0.5 Inexact Rounded +sqtx1218 squareroot 0.03 -> 0.2 Inexact Rounded +sqtx1219 squareroot 3.0E-1 -> 0.5 Inexact Rounded +sqtx1220 squareroot 3.00E-2 -> 0.2 Inexact Rounded +sqtx1221 squareroot 3E-3 -> 0.05 Inexact Rounded +sqtx1222 squareroot 3E+1 -> 5 Inexact Rounded +sqtx1223 squareroot 3E+2 -> 2E+1 Inexact Rounded +sqtx1224 squareroot 3E+3 -> 5E+1 Inexact Rounded +sqtx1225 squareroot 0.4 -> 0.6 Inexact Rounded +sqtx1226 squareroot 0.04 -> 0.2 +sqtx1227 squareroot 4.0E-1 -> 0.6 Inexact Rounded +sqtx1228 squareroot 4.00E-2 -> 0.2 Rounded +sqtx1229 squareroot 4E-3 -> 0.06 Inexact Rounded +sqtx1230 squareroot 4E+1 -> 6 Inexact Rounded +sqtx1231 squareroot 4E+2 -> 2E+1 +sqtx1232 squareroot 4E+3 -> 6E+1 Inexact Rounded +sqtx1233 squareroot 0.5 -> 0.7 Inexact Rounded +sqtx1234 squareroot 0.05 -> 0.2 Inexact Rounded +sqtx1235 squareroot 5.0E-1 -> 0.7 Inexact Rounded +sqtx1236 squareroot 5.00E-2 -> 0.2 Inexact Rounded +sqtx1237 squareroot 5E-3 -> 0.07 Inexact Rounded +sqtx1238 squareroot 5E+1 -> 7 Inexact Rounded +sqtx1239 squareroot 5E+2 -> 2E+1 Inexact Rounded +sqtx1240 squareroot 5E+3 -> 7E+1 Inexact Rounded +sqtx1241 squareroot 0.6 -> 0.8 Inexact Rounded +sqtx1242 squareroot 0.06 -> 0.2 Inexact Rounded +sqtx1243 squareroot 6.0E-1 -> 0.8 Inexact Rounded +sqtx1244 squareroot 6.00E-2 -> 0.2 Inexact Rounded +sqtx1245 squareroot 6E-3 -> 0.08 Inexact Rounded +sqtx1246 squareroot 6E+1 -> 8 Inexact Rounded +sqtx1247 squareroot 6E+2 -> 2E+1 Inexact Rounded +sqtx1248 squareroot 6E+3 -> 8E+1 Inexact Rounded +sqtx1249 squareroot 0.7 -> 0.8 Inexact Rounded +sqtx1250 squareroot 0.07 -> 0.3 Inexact Rounded +sqtx1251 squareroot 7.0E-1 -> 0.8 Inexact Rounded +sqtx1252 squareroot 7.00E-2 -> 0.3 Inexact Rounded +sqtx1253 squareroot 7E-3 -> 0.08 Inexact Rounded +sqtx1254 squareroot 7E+1 -> 8 Inexact Rounded +sqtx1255 squareroot 7E+2 -> 3E+1 Inexact Rounded +sqtx1256 squareroot 7E+3 -> 8E+1 Inexact Rounded +sqtx1257 squareroot 0.8 -> 0.9 Inexact Rounded +sqtx1258 squareroot 0.08 -> 0.3 Inexact Rounded +sqtx1259 squareroot 8.0E-1 -> 0.9 Inexact Rounded +sqtx1260 squareroot 8.00E-2 -> 0.3 Inexact Rounded +sqtx1261 squareroot 8E-3 -> 0.09 Inexact Rounded +sqtx1262 squareroot 8E+1 -> 9 Inexact Rounded +sqtx1263 squareroot 8E+2 -> 3E+1 Inexact Rounded +sqtx1264 squareroot 8E+3 -> 9E+1 Inexact Rounded +sqtx1265 squareroot 0.9 -> 0.9 Inexact Rounded +sqtx1266 squareroot 0.09 -> 0.3 +sqtx1267 squareroot 9.0E-1 -> 0.9 Inexact Rounded +sqtx1268 squareroot 9.00E-2 -> 0.3 Rounded +sqtx1269 squareroot 9E-3 -> 0.09 Inexact Rounded +sqtx1270 squareroot 9E+1 -> 9 Inexact Rounded +sqtx1271 squareroot 9E+2 -> 3E+1 +sqtx1272 squareroot 9E+3 -> 9E+1 Inexact Rounded + +-- Precision 2 squareroot tests [exhaustive, plus exponent adjusts] +rounding: half_even +maxExponent: 999 +minexponent: -999 +precision: 2 +sqtx2201 squareroot 0.1 -> 0.32 Inexact Rounded +sqtx2202 squareroot 0.01 -> 0.1 +sqtx2203 squareroot 1.0E-1 -> 0.32 Inexact Rounded +sqtx2204 squareroot 1.00E-2 -> 0.10 +sqtx2205 squareroot 1E-3 -> 0.032 Inexact Rounded +sqtx2206 squareroot 1E+1 -> 3.2 Inexact Rounded +sqtx2207 squareroot 1E+2 -> 1E+1 +sqtx2208 squareroot 1E+3 -> 32 Inexact Rounded +sqtx2209 squareroot 0.2 -> 0.45 Inexact Rounded +sqtx2210 squareroot 0.02 -> 0.14 Inexact Rounded +sqtx2211 squareroot 2.0E-1 -> 0.45 Inexact Rounded +sqtx2212 squareroot 2.00E-2 -> 0.14 Inexact Rounded +sqtx2213 squareroot 2E-3 -> 0.045 Inexact Rounded +sqtx2214 squareroot 2E+1 -> 4.5 Inexact Rounded +sqtx2215 squareroot 2E+2 -> 14 Inexact Rounded +sqtx2216 squareroot 2E+3 -> 45 Inexact Rounded +sqtx2217 squareroot 0.3 -> 0.55 Inexact Rounded +sqtx2218 squareroot 0.03 -> 0.17 Inexact Rounded +sqtx2219 squareroot 3.0E-1 -> 0.55 Inexact Rounded +sqtx2220 squareroot 3.00E-2 -> 0.17 Inexact Rounded +sqtx2221 squareroot 3E-3 -> 0.055 Inexact Rounded +sqtx2222 squareroot 3E+1 -> 5.5 Inexact Rounded +sqtx2223 squareroot 3E+2 -> 17 Inexact Rounded +sqtx2224 squareroot 3E+3 -> 55 Inexact Rounded +sqtx2225 squareroot 0.4 -> 0.63 Inexact Rounded +sqtx2226 squareroot 0.04 -> 0.2 +sqtx2227 squareroot 4.0E-1 -> 0.63 Inexact Rounded +sqtx2228 squareroot 4.00E-2 -> 0.20 +sqtx2229 squareroot 4E-3 -> 0.063 Inexact Rounded +sqtx2230 squareroot 4E+1 -> 6.3 Inexact Rounded +sqtx2231 squareroot 4E+2 -> 2E+1 +sqtx2232 squareroot 4E+3 -> 63 Inexact Rounded +sqtx2233 squareroot 0.5 -> 0.71 Inexact Rounded +sqtx2234 squareroot 0.05 -> 0.22 Inexact Rounded +sqtx2235 squareroot 5.0E-1 -> 0.71 Inexact Rounded +sqtx2236 squareroot 5.00E-2 -> 0.22 Inexact Rounded +sqtx2237 squareroot 5E-3 -> 0.071 Inexact Rounded +sqtx2238 squareroot 5E+1 -> 7.1 Inexact Rounded +sqtx2239 squareroot 5E+2 -> 22 Inexact Rounded +sqtx2240 squareroot 5E+3 -> 71 Inexact Rounded +sqtx2241 squareroot 0.6 -> 0.77 Inexact Rounded +sqtx2242 squareroot 0.06 -> 0.24 Inexact Rounded +sqtx2243 squareroot 6.0E-1 -> 0.77 Inexact Rounded +sqtx2244 squareroot 6.00E-2 -> 0.24 Inexact Rounded +sqtx2245 squareroot 6E-3 -> 0.077 Inexact Rounded +sqtx2246 squareroot 6E+1 -> 7.7 Inexact Rounded +sqtx2247 squareroot 6E+2 -> 24 Inexact Rounded +sqtx2248 squareroot 6E+3 -> 77 Inexact Rounded +sqtx2249 squareroot 0.7 -> 0.84 Inexact Rounded +sqtx2250 squareroot 0.07 -> 0.26 Inexact Rounded +sqtx2251 squareroot 7.0E-1 -> 0.84 Inexact Rounded +sqtx2252 squareroot 7.00E-2 -> 0.26 Inexact Rounded +sqtx2253 squareroot 7E-3 -> 0.084 Inexact Rounded +sqtx2254 squareroot 7E+1 -> 8.4 Inexact Rounded +sqtx2255 squareroot 7E+2 -> 26 Inexact Rounded +sqtx2256 squareroot 7E+3 -> 84 Inexact Rounded +sqtx2257 squareroot 0.8 -> 0.89 Inexact Rounded +sqtx2258 squareroot 0.08 -> 0.28 Inexact Rounded +sqtx2259 squareroot 8.0E-1 -> 0.89 Inexact Rounded +sqtx2260 squareroot 8.00E-2 -> 0.28 Inexact Rounded +sqtx2261 squareroot 8E-3 -> 0.089 Inexact Rounded +sqtx2262 squareroot 8E+1 -> 8.9 Inexact Rounded +sqtx2263 squareroot 8E+2 -> 28 Inexact Rounded +sqtx2264 squareroot 8E+3 -> 89 Inexact Rounded +sqtx2265 squareroot 0.9 -> 0.95 Inexact Rounded +sqtx2266 squareroot 0.09 -> 0.3 +sqtx2267 squareroot 9.0E-1 -> 0.95 Inexact Rounded +sqtx2268 squareroot 9.00E-2 -> 0.30 +sqtx2269 squareroot 9E-3 -> 0.095 Inexact Rounded +sqtx2270 squareroot 9E+1 -> 9.5 Inexact Rounded +sqtx2271 squareroot 9E+2 -> 3E+1 +sqtx2272 squareroot 9E+3 -> 95 Inexact Rounded +sqtx2273 squareroot 0.10 -> 0.32 Inexact Rounded +sqtx2274 squareroot 0.010 -> 0.10 +sqtx2275 squareroot 10.0E-1 -> 1.0 +sqtx2276 squareroot 10.00E-2 -> 0.32 Inexact Rounded +sqtx2277 squareroot 10E-3 -> 0.10 +sqtx2278 squareroot 10E+1 -> 10 +sqtx2279 squareroot 10E+2 -> 32 Inexact Rounded +sqtx2280 squareroot 10E+3 -> 1.0E+2 +sqtx2281 squareroot 0.11 -> 0.33 Inexact Rounded +sqtx2282 squareroot 0.011 -> 0.10 Inexact Rounded +sqtx2283 squareroot 11.0E-1 -> 1.0 Inexact Rounded +sqtx2284 squareroot 11.00E-2 -> 0.33 Inexact Rounded +sqtx2285 squareroot 11E-3 -> 0.10 Inexact Rounded +sqtx2286 squareroot 11E+1 -> 10 Inexact Rounded +sqtx2287 squareroot 11E+2 -> 33 Inexact Rounded +sqtx2288 squareroot 11E+3 -> 1.0E+2 Inexact Rounded +sqtx2289 squareroot 0.12 -> 0.35 Inexact Rounded +sqtx2290 squareroot 0.012 -> 0.11 Inexact Rounded +sqtx2291 squareroot 12.0E-1 -> 1.1 Inexact Rounded +sqtx2292 squareroot 12.00E-2 -> 0.35 Inexact Rounded +sqtx2293 squareroot 12E-3 -> 0.11 Inexact Rounded +sqtx2294 squareroot 12E+1 -> 11 Inexact Rounded +sqtx2295 squareroot 12E+2 -> 35 Inexact Rounded +sqtx2296 squareroot 12E+3 -> 1.1E+2 Inexact Rounded +sqtx2297 squareroot 0.13 -> 0.36 Inexact Rounded +sqtx2298 squareroot 0.013 -> 0.11 Inexact Rounded +sqtx2299 squareroot 13.0E-1 -> 1.1 Inexact Rounded +sqtx2300 squareroot 13.00E-2 -> 0.36 Inexact Rounded +sqtx2301 squareroot 13E-3 -> 0.11 Inexact Rounded +sqtx2302 squareroot 13E+1 -> 11 Inexact Rounded +sqtx2303 squareroot 13E+2 -> 36 Inexact Rounded +sqtx2304 squareroot 13E+3 -> 1.1E+2 Inexact Rounded +sqtx2305 squareroot 0.14 -> 0.37 Inexact Rounded +sqtx2306 squareroot 0.014 -> 0.12 Inexact Rounded +sqtx2307 squareroot 14.0E-1 -> 1.2 Inexact Rounded +sqtx2308 squareroot 14.00E-2 -> 0.37 Inexact Rounded +sqtx2309 squareroot 14E-3 -> 0.12 Inexact Rounded +sqtx2310 squareroot 14E+1 -> 12 Inexact Rounded +sqtx2311 squareroot 14E+2 -> 37 Inexact Rounded +sqtx2312 squareroot 14E+3 -> 1.2E+2 Inexact Rounded +sqtx2313 squareroot 0.15 -> 0.39 Inexact Rounded +sqtx2314 squareroot 0.015 -> 0.12 Inexact Rounded +sqtx2315 squareroot 15.0E-1 -> 1.2 Inexact Rounded +sqtx2316 squareroot 15.00E-2 -> 0.39 Inexact Rounded +sqtx2317 squareroot 15E-3 -> 0.12 Inexact Rounded +sqtx2318 squareroot 15E+1 -> 12 Inexact Rounded +sqtx2319 squareroot 15E+2 -> 39 Inexact Rounded +sqtx2320 squareroot 15E+3 -> 1.2E+2 Inexact Rounded +sqtx2321 squareroot 0.16 -> 0.4 +sqtx2322 squareroot 0.016 -> 0.13 Inexact Rounded +sqtx2323 squareroot 16.0E-1 -> 1.3 Inexact Rounded +sqtx2324 squareroot 16.00E-2 -> 0.40 +sqtx2325 squareroot 16E-3 -> 0.13 Inexact Rounded +sqtx2326 squareroot 16E+1 -> 13 Inexact Rounded +sqtx2327 squareroot 16E+2 -> 4E+1 +sqtx2328 squareroot 16E+3 -> 1.3E+2 Inexact Rounded +sqtx2329 squareroot 0.17 -> 0.41 Inexact Rounded +sqtx2330 squareroot 0.017 -> 0.13 Inexact Rounded +sqtx2331 squareroot 17.0E-1 -> 1.3 Inexact Rounded +sqtx2332 squareroot 17.00E-2 -> 0.41 Inexact Rounded +sqtx2333 squareroot 17E-3 -> 0.13 Inexact Rounded +sqtx2334 squareroot 17E+1 -> 13 Inexact Rounded +sqtx2335 squareroot 17E+2 -> 41 Inexact Rounded +sqtx2336 squareroot 17E+3 -> 1.3E+2 Inexact Rounded +sqtx2337 squareroot 0.18 -> 0.42 Inexact Rounded +sqtx2338 squareroot 0.018 -> 0.13 Inexact Rounded +sqtx2339 squareroot 18.0E-1 -> 1.3 Inexact Rounded +sqtx2340 squareroot 18.00E-2 -> 0.42 Inexact Rounded +sqtx2341 squareroot 18E-3 -> 0.13 Inexact Rounded +sqtx2342 squareroot 18E+1 -> 13 Inexact Rounded +sqtx2343 squareroot 18E+2 -> 42 Inexact Rounded +sqtx2344 squareroot 18E+3 -> 1.3E+2 Inexact Rounded +sqtx2345 squareroot 0.19 -> 0.44 Inexact Rounded +sqtx2346 squareroot 0.019 -> 0.14 Inexact Rounded +sqtx2347 squareroot 19.0E-1 -> 1.4 Inexact Rounded +sqtx2348 squareroot 19.00E-2 -> 0.44 Inexact Rounded +sqtx2349 squareroot 19E-3 -> 0.14 Inexact Rounded +sqtx2350 squareroot 19E+1 -> 14 Inexact Rounded +sqtx2351 squareroot 19E+2 -> 44 Inexact Rounded +sqtx2352 squareroot 19E+3 -> 1.4E+2 Inexact Rounded +sqtx2353 squareroot 0.20 -> 0.45 Inexact Rounded +sqtx2354 squareroot 0.020 -> 0.14 Inexact Rounded +sqtx2355 squareroot 20.0E-1 -> 1.4 Inexact Rounded +sqtx2356 squareroot 20.00E-2 -> 0.45 Inexact Rounded +sqtx2357 squareroot 20E-3 -> 0.14 Inexact Rounded +sqtx2358 squareroot 20E+1 -> 14 Inexact Rounded +sqtx2359 squareroot 20E+2 -> 45 Inexact Rounded +sqtx2360 squareroot 20E+3 -> 1.4E+2 Inexact Rounded +sqtx2361 squareroot 0.21 -> 0.46 Inexact Rounded +sqtx2362 squareroot 0.021 -> 0.14 Inexact Rounded +sqtx2363 squareroot 21.0E-1 -> 1.4 Inexact Rounded +sqtx2364 squareroot 21.00E-2 -> 0.46 Inexact Rounded +sqtx2365 squareroot 21E-3 -> 0.14 Inexact Rounded +sqtx2366 squareroot 21E+1 -> 14 Inexact Rounded +sqtx2367 squareroot 21E+2 -> 46 Inexact Rounded +sqtx2368 squareroot 21E+3 -> 1.4E+2 Inexact Rounded +sqtx2369 squareroot 0.22 -> 0.47 Inexact Rounded +sqtx2370 squareroot 0.022 -> 0.15 Inexact Rounded +sqtx2371 squareroot 22.0E-1 -> 1.5 Inexact Rounded +sqtx2372 squareroot 22.00E-2 -> 0.47 Inexact Rounded +sqtx2373 squareroot 22E-3 -> 0.15 Inexact Rounded +sqtx2374 squareroot 22E+1 -> 15 Inexact Rounded +sqtx2375 squareroot 22E+2 -> 47 Inexact Rounded +sqtx2376 squareroot 22E+3 -> 1.5E+2 Inexact Rounded +sqtx2377 squareroot 0.23 -> 0.48 Inexact Rounded +sqtx2378 squareroot 0.023 -> 0.15 Inexact Rounded +sqtx2379 squareroot 23.0E-1 -> 1.5 Inexact Rounded +sqtx2380 squareroot 23.00E-2 -> 0.48 Inexact Rounded +sqtx2381 squareroot 23E-3 -> 0.15 Inexact Rounded +sqtx2382 squareroot 23E+1 -> 15 Inexact Rounded +sqtx2383 squareroot 23E+2 -> 48 Inexact Rounded +sqtx2384 squareroot 23E+3 -> 1.5E+2 Inexact Rounded +sqtx2385 squareroot 0.24 -> 0.49 Inexact Rounded +sqtx2386 squareroot 0.024 -> 0.15 Inexact Rounded +sqtx2387 squareroot 24.0E-1 -> 1.5 Inexact Rounded +sqtx2388 squareroot 24.00E-2 -> 0.49 Inexact Rounded +sqtx2389 squareroot 24E-3 -> 0.15 Inexact Rounded +sqtx2390 squareroot 24E+1 -> 15 Inexact Rounded +sqtx2391 squareroot 24E+2 -> 49 Inexact Rounded +sqtx2392 squareroot 24E+3 -> 1.5E+2 Inexact Rounded +sqtx2393 squareroot 0.25 -> 0.5 +sqtx2394 squareroot 0.025 -> 0.16 Inexact Rounded +sqtx2395 squareroot 25.0E-1 -> 1.6 Inexact Rounded +sqtx2396 squareroot 25.00E-2 -> 0.50 +sqtx2397 squareroot 25E-3 -> 0.16 Inexact Rounded +sqtx2398 squareroot 25E+1 -> 16 Inexact Rounded +sqtx2399 squareroot 25E+2 -> 5E+1 +sqtx2400 squareroot 25E+3 -> 1.6E+2 Inexact Rounded +sqtx2401 squareroot 0.26 -> 0.51 Inexact Rounded +sqtx2402 squareroot 0.026 -> 0.16 Inexact Rounded +sqtx2403 squareroot 26.0E-1 -> 1.6 Inexact Rounded +sqtx2404 squareroot 26.00E-2 -> 0.51 Inexact Rounded +sqtx2405 squareroot 26E-3 -> 0.16 Inexact Rounded +sqtx2406 squareroot 26E+1 -> 16 Inexact Rounded +sqtx2407 squareroot 26E+2 -> 51 Inexact Rounded +sqtx2408 squareroot 26E+3 -> 1.6E+2 Inexact Rounded +sqtx2409 squareroot 0.27 -> 0.52 Inexact Rounded +sqtx2410 squareroot 0.027 -> 0.16 Inexact Rounded +sqtx2411 squareroot 27.0E-1 -> 1.6 Inexact Rounded +sqtx2412 squareroot 27.00E-2 -> 0.52 Inexact Rounded +sqtx2413 squareroot 27E-3 -> 0.16 Inexact Rounded +sqtx2414 squareroot 27E+1 -> 16 Inexact Rounded +sqtx2415 squareroot 27E+2 -> 52 Inexact Rounded +sqtx2416 squareroot 27E+3 -> 1.6E+2 Inexact Rounded +sqtx2417 squareroot 0.28 -> 0.53 Inexact Rounded +sqtx2418 squareroot 0.028 -> 0.17 Inexact Rounded +sqtx2419 squareroot 28.0E-1 -> 1.7 Inexact Rounded +sqtx2420 squareroot 28.00E-2 -> 0.53 Inexact Rounded +sqtx2421 squareroot 28E-3 -> 0.17 Inexact Rounded +sqtx2422 squareroot 28E+1 -> 17 Inexact Rounded +sqtx2423 squareroot 28E+2 -> 53 Inexact Rounded +sqtx2424 squareroot 28E+3 -> 1.7E+2 Inexact Rounded +sqtx2425 squareroot 0.29 -> 0.54 Inexact Rounded +sqtx2426 squareroot 0.029 -> 0.17 Inexact Rounded +sqtx2427 squareroot 29.0E-1 -> 1.7 Inexact Rounded +sqtx2428 squareroot 29.00E-2 -> 0.54 Inexact Rounded +sqtx2429 squareroot 29E-3 -> 0.17 Inexact Rounded +sqtx2430 squareroot 29E+1 -> 17 Inexact Rounded +sqtx2431 squareroot 29E+2 -> 54 Inexact Rounded +sqtx2432 squareroot 29E+3 -> 1.7E+2 Inexact Rounded +sqtx2433 squareroot 0.30 -> 0.55 Inexact Rounded +sqtx2434 squareroot 0.030 -> 0.17 Inexact Rounded +sqtx2435 squareroot 30.0E-1 -> 1.7 Inexact Rounded +sqtx2436 squareroot 30.00E-2 -> 0.55 Inexact Rounded +sqtx2437 squareroot 30E-3 -> 0.17 Inexact Rounded +sqtx2438 squareroot 30E+1 -> 17 Inexact Rounded +sqtx2439 squareroot 30E+2 -> 55 Inexact Rounded +sqtx2440 squareroot 30E+3 -> 1.7E+2 Inexact Rounded +sqtx2441 squareroot 0.31 -> 0.56 Inexact Rounded +sqtx2442 squareroot 0.031 -> 0.18 Inexact Rounded +sqtx2443 squareroot 31.0E-1 -> 1.8 Inexact Rounded +sqtx2444 squareroot 31.00E-2 -> 0.56 Inexact Rounded +sqtx2445 squareroot 31E-3 -> 0.18 Inexact Rounded +sqtx2446 squareroot 31E+1 -> 18 Inexact Rounded +sqtx2447 squareroot 31E+2 -> 56 Inexact Rounded +sqtx2448 squareroot 31E+3 -> 1.8E+2 Inexact Rounded +sqtx2449 squareroot 0.32 -> 0.57 Inexact Rounded +sqtx2450 squareroot 0.032 -> 0.18 Inexact Rounded +sqtx2451 squareroot 32.0E-1 -> 1.8 Inexact Rounded +sqtx2452 squareroot 32.00E-2 -> 0.57 Inexact Rounded +sqtx2453 squareroot 32E-3 -> 0.18 Inexact Rounded +sqtx2454 squareroot 32E+1 -> 18 Inexact Rounded +sqtx2455 squareroot 32E+2 -> 57 Inexact Rounded +sqtx2456 squareroot 32E+3 -> 1.8E+2 Inexact Rounded +sqtx2457 squareroot 0.33 -> 0.57 Inexact Rounded +sqtx2458 squareroot 0.033 -> 0.18 Inexact Rounded +sqtx2459 squareroot 33.0E-1 -> 1.8 Inexact Rounded +sqtx2460 squareroot 33.00E-2 -> 0.57 Inexact Rounded +sqtx2461 squareroot 33E-3 -> 0.18 Inexact Rounded +sqtx2462 squareroot 33E+1 -> 18 Inexact Rounded +sqtx2463 squareroot 33E+2 -> 57 Inexact Rounded +sqtx2464 squareroot 33E+3 -> 1.8E+2 Inexact Rounded +sqtx2465 squareroot 0.34 -> 0.58 Inexact Rounded +sqtx2466 squareroot 0.034 -> 0.18 Inexact Rounded +sqtx2467 squareroot 34.0E-1 -> 1.8 Inexact Rounded +sqtx2468 squareroot 34.00E-2 -> 0.58 Inexact Rounded +sqtx2469 squareroot 34E-3 -> 0.18 Inexact Rounded +sqtx2470 squareroot 34E+1 -> 18 Inexact Rounded +sqtx2471 squareroot 34E+2 -> 58 Inexact Rounded +sqtx2472 squareroot 34E+3 -> 1.8E+2 Inexact Rounded +sqtx2473 squareroot 0.35 -> 0.59 Inexact Rounded +sqtx2474 squareroot 0.035 -> 0.19 Inexact Rounded +sqtx2475 squareroot 35.0E-1 -> 1.9 Inexact Rounded +sqtx2476 squareroot 35.00E-2 -> 0.59 Inexact Rounded +sqtx2477 squareroot 35E-3 -> 0.19 Inexact Rounded +sqtx2478 squareroot 35E+1 -> 19 Inexact Rounded +sqtx2479 squareroot 35E+2 -> 59 Inexact Rounded +sqtx2480 squareroot 35E+3 -> 1.9E+2 Inexact Rounded +sqtx2481 squareroot 0.36 -> 0.6 +sqtx2482 squareroot 0.036 -> 0.19 Inexact Rounded +sqtx2483 squareroot 36.0E-1 -> 1.9 Inexact Rounded +sqtx2484 squareroot 36.00E-2 -> 0.60 +sqtx2485 squareroot 36E-3 -> 0.19 Inexact Rounded +sqtx2486 squareroot 36E+1 -> 19 Inexact Rounded +sqtx2487 squareroot 36E+2 -> 6E+1 +sqtx2488 squareroot 36E+3 -> 1.9E+2 Inexact Rounded +sqtx2489 squareroot 0.37 -> 0.61 Inexact Rounded +sqtx2490 squareroot 0.037 -> 0.19 Inexact Rounded +sqtx2491 squareroot 37.0E-1 -> 1.9 Inexact Rounded +sqtx2492 squareroot 37.00E-2 -> 0.61 Inexact Rounded +sqtx2493 squareroot 37E-3 -> 0.19 Inexact Rounded +sqtx2494 squareroot 37E+1 -> 19 Inexact Rounded +sqtx2495 squareroot 37E+2 -> 61 Inexact Rounded +sqtx2496 squareroot 37E+3 -> 1.9E+2 Inexact Rounded +sqtx2497 squareroot 0.38 -> 0.62 Inexact Rounded +sqtx2498 squareroot 0.038 -> 0.19 Inexact Rounded +sqtx2499 squareroot 38.0E-1 -> 1.9 Inexact Rounded +sqtx2500 squareroot 38.00E-2 -> 0.62 Inexact Rounded +sqtx2501 squareroot 38E-3 -> 0.19 Inexact Rounded +sqtx2502 squareroot 38E+1 -> 19 Inexact Rounded +sqtx2503 squareroot 38E+2 -> 62 Inexact Rounded +sqtx2504 squareroot 38E+3 -> 1.9E+2 Inexact Rounded +sqtx2505 squareroot 0.39 -> 0.62 Inexact Rounded +sqtx2506 squareroot 0.039 -> 0.20 Inexact Rounded +sqtx2507 squareroot 39.0E-1 -> 2.0 Inexact Rounded +sqtx2508 squareroot 39.00E-2 -> 0.62 Inexact Rounded +sqtx2509 squareroot 39E-3 -> 0.20 Inexact Rounded +sqtx2510 squareroot 39E+1 -> 20 Inexact Rounded +sqtx2511 squareroot 39E+2 -> 62 Inexact Rounded +sqtx2512 squareroot 39E+3 -> 2.0E+2 Inexact Rounded +sqtx2513 squareroot 0.40 -> 0.63 Inexact Rounded +sqtx2514 squareroot 0.040 -> 0.20 +sqtx2515 squareroot 40.0E-1 -> 2.0 +sqtx2516 squareroot 40.00E-2 -> 0.63 Inexact Rounded +sqtx2517 squareroot 40E-3 -> 0.20 +sqtx2518 squareroot 40E+1 -> 20 +sqtx2519 squareroot 40E+2 -> 63 Inexact Rounded +sqtx2520 squareroot 40E+3 -> 2.0E+2 +sqtx2521 squareroot 0.41 -> 0.64 Inexact Rounded +sqtx2522 squareroot 0.041 -> 0.20 Inexact Rounded +sqtx2523 squareroot 41.0E-1 -> 2.0 Inexact Rounded +sqtx2524 squareroot 41.00E-2 -> 0.64 Inexact Rounded +sqtx2525 squareroot 41E-3 -> 0.20 Inexact Rounded +sqtx2526 squareroot 41E+1 -> 20 Inexact Rounded +sqtx2527 squareroot 41E+2 -> 64 Inexact Rounded +sqtx2528 squareroot 41E+3 -> 2.0E+2 Inexact Rounded +sqtx2529 squareroot 0.42 -> 0.65 Inexact Rounded +sqtx2530 squareroot 0.042 -> 0.20 Inexact Rounded +sqtx2531 squareroot 42.0E-1 -> 2.0 Inexact Rounded +sqtx2532 squareroot 42.00E-2 -> 0.65 Inexact Rounded +sqtx2533 squareroot 42E-3 -> 0.20 Inexact Rounded +sqtx2534 squareroot 42E+1 -> 20 Inexact Rounded +sqtx2535 squareroot 42E+2 -> 65 Inexact Rounded +sqtx2536 squareroot 42E+3 -> 2.0E+2 Inexact Rounded +sqtx2537 squareroot 0.43 -> 0.66 Inexact Rounded +sqtx2538 squareroot 0.043 -> 0.21 Inexact Rounded +sqtx2539 squareroot 43.0E-1 -> 2.1 Inexact Rounded +sqtx2540 squareroot 43.00E-2 -> 0.66 Inexact Rounded +sqtx2541 squareroot 43E-3 -> 0.21 Inexact Rounded +sqtx2542 squareroot 43E+1 -> 21 Inexact Rounded +sqtx2543 squareroot 43E+2 -> 66 Inexact Rounded +sqtx2544 squareroot 43E+3 -> 2.1E+2 Inexact Rounded +sqtx2545 squareroot 0.44 -> 0.66 Inexact Rounded +sqtx2546 squareroot 0.044 -> 0.21 Inexact Rounded +sqtx2547 squareroot 44.0E-1 -> 2.1 Inexact Rounded +sqtx2548 squareroot 44.00E-2 -> 0.66 Inexact Rounded +sqtx2549 squareroot 44E-3 -> 0.21 Inexact Rounded +sqtx2550 squareroot 44E+1 -> 21 Inexact Rounded +sqtx2551 squareroot 44E+2 -> 66 Inexact Rounded +sqtx2552 squareroot 44E+3 -> 2.1E+2 Inexact Rounded +sqtx2553 squareroot 0.45 -> 0.67 Inexact Rounded +sqtx2554 squareroot 0.045 -> 0.21 Inexact Rounded +sqtx2555 squareroot 45.0E-1 -> 2.1 Inexact Rounded +sqtx2556 squareroot 45.00E-2 -> 0.67 Inexact Rounded +sqtx2557 squareroot 45E-3 -> 0.21 Inexact Rounded +sqtx2558 squareroot 45E+1 -> 21 Inexact Rounded +sqtx2559 squareroot 45E+2 -> 67 Inexact Rounded +sqtx2560 squareroot 45E+3 -> 2.1E+2 Inexact Rounded +sqtx2561 squareroot 0.46 -> 0.68 Inexact Rounded +sqtx2562 squareroot 0.046 -> 0.21 Inexact Rounded +sqtx2563 squareroot 46.0E-1 -> 2.1 Inexact Rounded +sqtx2564 squareroot 46.00E-2 -> 0.68 Inexact Rounded +sqtx2565 squareroot 46E-3 -> 0.21 Inexact Rounded +sqtx2566 squareroot 46E+1 -> 21 Inexact Rounded +sqtx2567 squareroot 46E+2 -> 68 Inexact Rounded +sqtx2568 squareroot 46E+3 -> 2.1E+2 Inexact Rounded +sqtx2569 squareroot 0.47 -> 0.69 Inexact Rounded +sqtx2570 squareroot 0.047 -> 0.22 Inexact Rounded +sqtx2571 squareroot 47.0E-1 -> 2.2 Inexact Rounded +sqtx2572 squareroot 47.00E-2 -> 0.69 Inexact Rounded +sqtx2573 squareroot 47E-3 -> 0.22 Inexact Rounded +sqtx2574 squareroot 47E+1 -> 22 Inexact Rounded +sqtx2575 squareroot 47E+2 -> 69 Inexact Rounded +sqtx2576 squareroot 47E+3 -> 2.2E+2 Inexact Rounded +sqtx2577 squareroot 0.48 -> 0.69 Inexact Rounded +sqtx2578 squareroot 0.048 -> 0.22 Inexact Rounded +sqtx2579 squareroot 48.0E-1 -> 2.2 Inexact Rounded +sqtx2580 squareroot 48.00E-2 -> 0.69 Inexact Rounded +sqtx2581 squareroot 48E-3 -> 0.22 Inexact Rounded +sqtx2582 squareroot 48E+1 -> 22 Inexact Rounded +sqtx2583 squareroot 48E+2 -> 69 Inexact Rounded +sqtx2584 squareroot 48E+3 -> 2.2E+2 Inexact Rounded +sqtx2585 squareroot 0.49 -> 0.7 +sqtx2586 squareroot 0.049 -> 0.22 Inexact Rounded +sqtx2587 squareroot 49.0E-1 -> 2.2 Inexact Rounded +sqtx2588 squareroot 49.00E-2 -> 0.70 +sqtx2589 squareroot 49E-3 -> 0.22 Inexact Rounded +sqtx2590 squareroot 49E+1 -> 22 Inexact Rounded +sqtx2591 squareroot 49E+2 -> 7E+1 +sqtx2592 squareroot 49E+3 -> 2.2E+2 Inexact Rounded +sqtx2593 squareroot 0.50 -> 0.71 Inexact Rounded +sqtx2594 squareroot 0.050 -> 0.22 Inexact Rounded +sqtx2595 squareroot 50.0E-1 -> 2.2 Inexact Rounded +sqtx2596 squareroot 50.00E-2 -> 0.71 Inexact Rounded +sqtx2597 squareroot 50E-3 -> 0.22 Inexact Rounded +sqtx2598 squareroot 50E+1 -> 22 Inexact Rounded +sqtx2599 squareroot 50E+2 -> 71 Inexact Rounded +sqtx2600 squareroot 50E+3 -> 2.2E+2 Inexact Rounded +sqtx2601 squareroot 0.51 -> 0.71 Inexact Rounded +sqtx2602 squareroot 0.051 -> 0.23 Inexact Rounded +sqtx2603 squareroot 51.0E-1 -> 2.3 Inexact Rounded +sqtx2604 squareroot 51.00E-2 -> 0.71 Inexact Rounded +sqtx2605 squareroot 51E-3 -> 0.23 Inexact Rounded +sqtx2606 squareroot 51E+1 -> 23 Inexact Rounded +sqtx2607 squareroot 51E+2 -> 71 Inexact Rounded +sqtx2608 squareroot 51E+3 -> 2.3E+2 Inexact Rounded +sqtx2609 squareroot 0.52 -> 0.72 Inexact Rounded +sqtx2610 squareroot 0.052 -> 0.23 Inexact Rounded +sqtx2611 squareroot 52.0E-1 -> 2.3 Inexact Rounded +sqtx2612 squareroot 52.00E-2 -> 0.72 Inexact Rounded +sqtx2613 squareroot 52E-3 -> 0.23 Inexact Rounded +sqtx2614 squareroot 52E+1 -> 23 Inexact Rounded +sqtx2615 squareroot 52E+2 -> 72 Inexact Rounded +sqtx2616 squareroot 52E+3 -> 2.3E+2 Inexact Rounded +sqtx2617 squareroot 0.53 -> 0.73 Inexact Rounded +sqtx2618 squareroot 0.053 -> 0.23 Inexact Rounded +sqtx2619 squareroot 53.0E-1 -> 2.3 Inexact Rounded +sqtx2620 squareroot 53.00E-2 -> 0.73 Inexact Rounded +sqtx2621 squareroot 53E-3 -> 0.23 Inexact Rounded +sqtx2622 squareroot 53E+1 -> 23 Inexact Rounded +sqtx2623 squareroot 53E+2 -> 73 Inexact Rounded +sqtx2624 squareroot 53E+3 -> 2.3E+2 Inexact Rounded +sqtx2625 squareroot 0.54 -> 0.73 Inexact Rounded +sqtx2626 squareroot 0.054 -> 0.23 Inexact Rounded +sqtx2627 squareroot 54.0E-1 -> 2.3 Inexact Rounded +sqtx2628 squareroot 54.00E-2 -> 0.73 Inexact Rounded +sqtx2629 squareroot 54E-3 -> 0.23 Inexact Rounded +sqtx2630 squareroot 54E+1 -> 23 Inexact Rounded +sqtx2631 squareroot 54E+2 -> 73 Inexact Rounded +sqtx2632 squareroot 54E+3 -> 2.3E+2 Inexact Rounded +sqtx2633 squareroot 0.55 -> 0.74 Inexact Rounded +sqtx2634 squareroot 0.055 -> 0.23 Inexact Rounded +sqtx2635 squareroot 55.0E-1 -> 2.3 Inexact Rounded +sqtx2636 squareroot 55.00E-2 -> 0.74 Inexact Rounded +sqtx2637 squareroot 55E-3 -> 0.23 Inexact Rounded +sqtx2638 squareroot 55E+1 -> 23 Inexact Rounded +sqtx2639 squareroot 55E+2 -> 74 Inexact Rounded +sqtx2640 squareroot 55E+3 -> 2.3E+2 Inexact Rounded +sqtx2641 squareroot 0.56 -> 0.75 Inexact Rounded +sqtx2642 squareroot 0.056 -> 0.24 Inexact Rounded +sqtx2643 squareroot 56.0E-1 -> 2.4 Inexact Rounded +sqtx2644 squareroot 56.00E-2 -> 0.75 Inexact Rounded +sqtx2645 squareroot 56E-3 -> 0.24 Inexact Rounded +sqtx2646 squareroot 56E+1 -> 24 Inexact Rounded +sqtx2647 squareroot 56E+2 -> 75 Inexact Rounded +sqtx2648 squareroot 56E+3 -> 2.4E+2 Inexact Rounded +sqtx2649 squareroot 0.57 -> 0.75 Inexact Rounded +sqtx2650 squareroot 0.057 -> 0.24 Inexact Rounded +sqtx2651 squareroot 57.0E-1 -> 2.4 Inexact Rounded +sqtx2652 squareroot 57.00E-2 -> 0.75 Inexact Rounded +sqtx2653 squareroot 57E-3 -> 0.24 Inexact Rounded +sqtx2654 squareroot 57E+1 -> 24 Inexact Rounded +sqtx2655 squareroot 57E+2 -> 75 Inexact Rounded +sqtx2656 squareroot 57E+3 -> 2.4E+2 Inexact Rounded +sqtx2657 squareroot 0.58 -> 0.76 Inexact Rounded +sqtx2658 squareroot 0.058 -> 0.24 Inexact Rounded +sqtx2659 squareroot 58.0E-1 -> 2.4 Inexact Rounded +sqtx2660 squareroot 58.00E-2 -> 0.76 Inexact Rounded +sqtx2661 squareroot 58E-3 -> 0.24 Inexact Rounded +sqtx2662 squareroot 58E+1 -> 24 Inexact Rounded +sqtx2663 squareroot 58E+2 -> 76 Inexact Rounded +sqtx2664 squareroot 58E+3 -> 2.4E+2 Inexact Rounded +sqtx2665 squareroot 0.59 -> 0.77 Inexact Rounded +sqtx2666 squareroot 0.059 -> 0.24 Inexact Rounded +sqtx2667 squareroot 59.0E-1 -> 2.4 Inexact Rounded +sqtx2668 squareroot 59.00E-2 -> 0.77 Inexact Rounded +sqtx2669 squareroot 59E-3 -> 0.24 Inexact Rounded +sqtx2670 squareroot 59E+1 -> 24 Inexact Rounded +sqtx2671 squareroot 59E+2 -> 77 Inexact Rounded +sqtx2672 squareroot 59E+3 -> 2.4E+2 Inexact Rounded +sqtx2673 squareroot 0.60 -> 0.77 Inexact Rounded +sqtx2674 squareroot 0.060 -> 0.24 Inexact Rounded +sqtx2675 squareroot 60.0E-1 -> 2.4 Inexact Rounded +sqtx2676 squareroot 60.00E-2 -> 0.77 Inexact Rounded +sqtx2677 squareroot 60E-3 -> 0.24 Inexact Rounded +sqtx2678 squareroot 60E+1 -> 24 Inexact Rounded +sqtx2679 squareroot 60E+2 -> 77 Inexact Rounded +sqtx2680 squareroot 60E+3 -> 2.4E+2 Inexact Rounded +sqtx2681 squareroot 0.61 -> 0.78 Inexact Rounded +sqtx2682 squareroot 0.061 -> 0.25 Inexact Rounded +sqtx2683 squareroot 61.0E-1 -> 2.5 Inexact Rounded +sqtx2684 squareroot 61.00E-2 -> 0.78 Inexact Rounded +sqtx2685 squareroot 61E-3 -> 0.25 Inexact Rounded +sqtx2686 squareroot 61E+1 -> 25 Inexact Rounded +sqtx2687 squareroot 61E+2 -> 78 Inexact Rounded +sqtx2688 squareroot 61E+3 -> 2.5E+2 Inexact Rounded +sqtx2689 squareroot 0.62 -> 0.79 Inexact Rounded +sqtx2690 squareroot 0.062 -> 0.25 Inexact Rounded +sqtx2691 squareroot 62.0E-1 -> 2.5 Inexact Rounded +sqtx2692 squareroot 62.00E-2 -> 0.79 Inexact Rounded +sqtx2693 squareroot 62E-3 -> 0.25 Inexact Rounded +sqtx2694 squareroot 62E+1 -> 25 Inexact Rounded +sqtx2695 squareroot 62E+2 -> 79 Inexact Rounded +sqtx2696 squareroot 62E+3 -> 2.5E+2 Inexact Rounded +sqtx2697 squareroot 0.63 -> 0.79 Inexact Rounded +sqtx2698 squareroot 0.063 -> 0.25 Inexact Rounded +sqtx2699 squareroot 63.0E-1 -> 2.5 Inexact Rounded +sqtx2700 squareroot 63.00E-2 -> 0.79 Inexact Rounded +sqtx2701 squareroot 63E-3 -> 0.25 Inexact Rounded +sqtx2702 squareroot 63E+1 -> 25 Inexact Rounded +sqtx2703 squareroot 63E+2 -> 79 Inexact Rounded +sqtx2704 squareroot 63E+3 -> 2.5E+2 Inexact Rounded +sqtx2705 squareroot 0.64 -> 0.8 +sqtx2706 squareroot 0.064 -> 0.25 Inexact Rounded +sqtx2707 squareroot 64.0E-1 -> 2.5 Inexact Rounded +sqtx2708 squareroot 64.00E-2 -> 0.80 +sqtx2709 squareroot 64E-3 -> 0.25 Inexact Rounded +sqtx2710 squareroot 64E+1 -> 25 Inexact Rounded +sqtx2711 squareroot 64E+2 -> 8E+1 +sqtx2712 squareroot 64E+3 -> 2.5E+2 Inexact Rounded +sqtx2713 squareroot 0.65 -> 0.81 Inexact Rounded +sqtx2714 squareroot 0.065 -> 0.25 Inexact Rounded +sqtx2715 squareroot 65.0E-1 -> 2.5 Inexact Rounded +sqtx2716 squareroot 65.00E-2 -> 0.81 Inexact Rounded +sqtx2717 squareroot 65E-3 -> 0.25 Inexact Rounded +sqtx2718 squareroot 65E+1 -> 25 Inexact Rounded +sqtx2719 squareroot 65E+2 -> 81 Inexact Rounded +sqtx2720 squareroot 65E+3 -> 2.5E+2 Inexact Rounded +sqtx2721 squareroot 0.66 -> 0.81 Inexact Rounded +sqtx2722 squareroot 0.066 -> 0.26 Inexact Rounded +sqtx2723 squareroot 66.0E-1 -> 2.6 Inexact Rounded +sqtx2724 squareroot 66.00E-2 -> 0.81 Inexact Rounded +sqtx2725 squareroot 66E-3 -> 0.26 Inexact Rounded +sqtx2726 squareroot 66E+1 -> 26 Inexact Rounded +sqtx2727 squareroot 66E+2 -> 81 Inexact Rounded +sqtx2728 squareroot 66E+3 -> 2.6E+2 Inexact Rounded +sqtx2729 squareroot 0.67 -> 0.82 Inexact Rounded +sqtx2730 squareroot 0.067 -> 0.26 Inexact Rounded +sqtx2731 squareroot 67.0E-1 -> 2.6 Inexact Rounded +sqtx2732 squareroot 67.00E-2 -> 0.82 Inexact Rounded +sqtx2733 squareroot 67E-3 -> 0.26 Inexact Rounded +sqtx2734 squareroot 67E+1 -> 26 Inexact Rounded +sqtx2735 squareroot 67E+2 -> 82 Inexact Rounded +sqtx2736 squareroot 67E+3 -> 2.6E+2 Inexact Rounded +sqtx2737 squareroot 0.68 -> 0.82 Inexact Rounded +sqtx2738 squareroot 0.068 -> 0.26 Inexact Rounded +sqtx2739 squareroot 68.0E-1 -> 2.6 Inexact Rounded +sqtx2740 squareroot 68.00E-2 -> 0.82 Inexact Rounded +sqtx2741 squareroot 68E-3 -> 0.26 Inexact Rounded +sqtx2742 squareroot 68E+1 -> 26 Inexact Rounded +sqtx2743 squareroot 68E+2 -> 82 Inexact Rounded +sqtx2744 squareroot 68E+3 -> 2.6E+2 Inexact Rounded +sqtx2745 squareroot 0.69 -> 0.83 Inexact Rounded +sqtx2746 squareroot 0.069 -> 0.26 Inexact Rounded +sqtx2747 squareroot 69.0E-1 -> 2.6 Inexact Rounded +sqtx2748 squareroot 69.00E-2 -> 0.83 Inexact Rounded +sqtx2749 squareroot 69E-3 -> 0.26 Inexact Rounded +sqtx2750 squareroot 69E+1 -> 26 Inexact Rounded +sqtx2751 squareroot 69E+2 -> 83 Inexact Rounded +sqtx2752 squareroot 69E+3 -> 2.6E+2 Inexact Rounded +sqtx2753 squareroot 0.70 -> 0.84 Inexact Rounded +sqtx2754 squareroot 0.070 -> 0.26 Inexact Rounded +sqtx2755 squareroot 70.0E-1 -> 2.6 Inexact Rounded +sqtx2756 squareroot 70.00E-2 -> 0.84 Inexact Rounded +sqtx2757 squareroot 70E-3 -> 0.26 Inexact Rounded +sqtx2758 squareroot 70E+1 -> 26 Inexact Rounded +sqtx2759 squareroot 70E+2 -> 84 Inexact Rounded +sqtx2760 squareroot 70E+3 -> 2.6E+2 Inexact Rounded +sqtx2761 squareroot 0.71 -> 0.84 Inexact Rounded +sqtx2762 squareroot 0.071 -> 0.27 Inexact Rounded +sqtx2763 squareroot 71.0E-1 -> 2.7 Inexact Rounded +sqtx2764 squareroot 71.00E-2 -> 0.84 Inexact Rounded +sqtx2765 squareroot 71E-3 -> 0.27 Inexact Rounded +sqtx2766 squareroot 71E+1 -> 27 Inexact Rounded +sqtx2767 squareroot 71E+2 -> 84 Inexact Rounded +sqtx2768 squareroot 71E+3 -> 2.7E+2 Inexact Rounded +sqtx2769 squareroot 0.72 -> 0.85 Inexact Rounded +sqtx2770 squareroot 0.072 -> 0.27 Inexact Rounded +sqtx2771 squareroot 72.0E-1 -> 2.7 Inexact Rounded +sqtx2772 squareroot 72.00E-2 -> 0.85 Inexact Rounded +sqtx2773 squareroot 72E-3 -> 0.27 Inexact Rounded +sqtx2774 squareroot 72E+1 -> 27 Inexact Rounded +sqtx2775 squareroot 72E+2 -> 85 Inexact Rounded +sqtx2776 squareroot 72E+3 -> 2.7E+2 Inexact Rounded +sqtx2777 squareroot 0.73 -> 0.85 Inexact Rounded +sqtx2778 squareroot 0.073 -> 0.27 Inexact Rounded +sqtx2779 squareroot 73.0E-1 -> 2.7 Inexact Rounded +sqtx2780 squareroot 73.00E-2 -> 0.85 Inexact Rounded +sqtx2781 squareroot 73E-3 -> 0.27 Inexact Rounded +sqtx2782 squareroot 73E+1 -> 27 Inexact Rounded +sqtx2783 squareroot 73E+2 -> 85 Inexact Rounded +sqtx2784 squareroot 73E+3 -> 2.7E+2 Inexact Rounded +sqtx2785 squareroot 0.74 -> 0.86 Inexact Rounded +sqtx2786 squareroot 0.074 -> 0.27 Inexact Rounded +sqtx2787 squareroot 74.0E-1 -> 2.7 Inexact Rounded +sqtx2788 squareroot 74.00E-2 -> 0.86 Inexact Rounded +sqtx2789 squareroot 74E-3 -> 0.27 Inexact Rounded +sqtx2790 squareroot 74E+1 -> 27 Inexact Rounded +sqtx2791 squareroot 74E+2 -> 86 Inexact Rounded +sqtx2792 squareroot 74E+3 -> 2.7E+2 Inexact Rounded +sqtx2793 squareroot 0.75 -> 0.87 Inexact Rounded +sqtx2794 squareroot 0.075 -> 0.27 Inexact Rounded +sqtx2795 squareroot 75.0E-1 -> 2.7 Inexact Rounded +sqtx2796 squareroot 75.00E-2 -> 0.87 Inexact Rounded +sqtx2797 squareroot 75E-3 -> 0.27 Inexact Rounded +sqtx2798 squareroot 75E+1 -> 27 Inexact Rounded +sqtx2799 squareroot 75E+2 -> 87 Inexact Rounded +sqtx2800 squareroot 75E+3 -> 2.7E+2 Inexact Rounded +sqtx2801 squareroot 0.76 -> 0.87 Inexact Rounded +sqtx2802 squareroot 0.076 -> 0.28 Inexact Rounded +sqtx2803 squareroot 76.0E-1 -> 2.8 Inexact Rounded +sqtx2804 squareroot 76.00E-2 -> 0.87 Inexact Rounded +sqtx2805 squareroot 76E-3 -> 0.28 Inexact Rounded +sqtx2806 squareroot 76E+1 -> 28 Inexact Rounded +sqtx2807 squareroot 76E+2 -> 87 Inexact Rounded +sqtx2808 squareroot 76E+3 -> 2.8E+2 Inexact Rounded +sqtx2809 squareroot 0.77 -> 0.88 Inexact Rounded +sqtx2810 squareroot 0.077 -> 0.28 Inexact Rounded +sqtx2811 squareroot 77.0E-1 -> 2.8 Inexact Rounded +sqtx2812 squareroot 77.00E-2 -> 0.88 Inexact Rounded +sqtx2813 squareroot 77E-3 -> 0.28 Inexact Rounded +sqtx2814 squareroot 77E+1 -> 28 Inexact Rounded +sqtx2815 squareroot 77E+2 -> 88 Inexact Rounded +sqtx2816 squareroot 77E+3 -> 2.8E+2 Inexact Rounded +sqtx2817 squareroot 0.78 -> 0.88 Inexact Rounded +sqtx2818 squareroot 0.078 -> 0.28 Inexact Rounded +sqtx2819 squareroot 78.0E-1 -> 2.8 Inexact Rounded +sqtx2820 squareroot 78.00E-2 -> 0.88 Inexact Rounded +sqtx2821 squareroot 78E-3 -> 0.28 Inexact Rounded +sqtx2822 squareroot 78E+1 -> 28 Inexact Rounded +sqtx2823 squareroot 78E+2 -> 88 Inexact Rounded +sqtx2824 squareroot 78E+3 -> 2.8E+2 Inexact Rounded +sqtx2825 squareroot 0.79 -> 0.89 Inexact Rounded +sqtx2826 squareroot 0.079 -> 0.28 Inexact Rounded +sqtx2827 squareroot 79.0E-1 -> 2.8 Inexact Rounded +sqtx2828 squareroot 79.00E-2 -> 0.89 Inexact Rounded +sqtx2829 squareroot 79E-3 -> 0.28 Inexact Rounded +sqtx2830 squareroot 79E+1 -> 28 Inexact Rounded +sqtx2831 squareroot 79E+2 -> 89 Inexact Rounded +sqtx2832 squareroot 79E+3 -> 2.8E+2 Inexact Rounded +sqtx2833 squareroot 0.80 -> 0.89 Inexact Rounded +sqtx2834 squareroot 0.080 -> 0.28 Inexact Rounded +sqtx2835 squareroot 80.0E-1 -> 2.8 Inexact Rounded +sqtx2836 squareroot 80.00E-2 -> 0.89 Inexact Rounded +sqtx2837 squareroot 80E-3 -> 0.28 Inexact Rounded +sqtx2838 squareroot 80E+1 -> 28 Inexact Rounded +sqtx2839 squareroot 80E+2 -> 89 Inexact Rounded +sqtx2840 squareroot 80E+3 -> 2.8E+2 Inexact Rounded +sqtx2841 squareroot 0.81 -> 0.9 +sqtx2842 squareroot 0.081 -> 0.28 Inexact Rounded +sqtx2843 squareroot 81.0E-1 -> 2.8 Inexact Rounded +sqtx2844 squareroot 81.00E-2 -> 0.90 +sqtx2845 squareroot 81E-3 -> 0.28 Inexact Rounded +sqtx2846 squareroot 81E+1 -> 28 Inexact Rounded +sqtx2847 squareroot 81E+2 -> 9E+1 +sqtx2848 squareroot 81E+3 -> 2.8E+2 Inexact Rounded +sqtx2849 squareroot 0.82 -> 0.91 Inexact Rounded +sqtx2850 squareroot 0.082 -> 0.29 Inexact Rounded +sqtx2851 squareroot 82.0E-1 -> 2.9 Inexact Rounded +sqtx2852 squareroot 82.00E-2 -> 0.91 Inexact Rounded +sqtx2853 squareroot 82E-3 -> 0.29 Inexact Rounded +sqtx2854 squareroot 82E+1 -> 29 Inexact Rounded +sqtx2855 squareroot 82E+2 -> 91 Inexact Rounded +sqtx2856 squareroot 82E+3 -> 2.9E+2 Inexact Rounded +sqtx2857 squareroot 0.83 -> 0.91 Inexact Rounded +sqtx2858 squareroot 0.083 -> 0.29 Inexact Rounded +sqtx2859 squareroot 83.0E-1 -> 2.9 Inexact Rounded +sqtx2860 squareroot 83.00E-2 -> 0.91 Inexact Rounded +sqtx2861 squareroot 83E-3 -> 0.29 Inexact Rounded +sqtx2862 squareroot 83E+1 -> 29 Inexact Rounded +sqtx2863 squareroot 83E+2 -> 91 Inexact Rounded +sqtx2864 squareroot 83E+3 -> 2.9E+2 Inexact Rounded +sqtx2865 squareroot 0.84 -> 0.92 Inexact Rounded +sqtx2866 squareroot 0.084 -> 0.29 Inexact Rounded +sqtx2867 squareroot 84.0E-1 -> 2.9 Inexact Rounded +sqtx2868 squareroot 84.00E-2 -> 0.92 Inexact Rounded +sqtx2869 squareroot 84E-3 -> 0.29 Inexact Rounded +sqtx2870 squareroot 84E+1 -> 29 Inexact Rounded +sqtx2871 squareroot 84E+2 -> 92 Inexact Rounded +sqtx2872 squareroot 84E+3 -> 2.9E+2 Inexact Rounded +sqtx2873 squareroot 0.85 -> 0.92 Inexact Rounded +sqtx2874 squareroot 0.085 -> 0.29 Inexact Rounded +sqtx2875 squareroot 85.0E-1 -> 2.9 Inexact Rounded +sqtx2876 squareroot 85.00E-2 -> 0.92 Inexact Rounded +sqtx2877 squareroot 85E-3 -> 0.29 Inexact Rounded +sqtx2878 squareroot 85E+1 -> 29 Inexact Rounded +sqtx2879 squareroot 85E+2 -> 92 Inexact Rounded +sqtx2880 squareroot 85E+3 -> 2.9E+2 Inexact Rounded +sqtx2881 squareroot 0.86 -> 0.93 Inexact Rounded +sqtx2882 squareroot 0.086 -> 0.29 Inexact Rounded +sqtx2883 squareroot 86.0E-1 -> 2.9 Inexact Rounded +sqtx2884 squareroot 86.00E-2 -> 0.93 Inexact Rounded +sqtx2885 squareroot 86E-3 -> 0.29 Inexact Rounded +sqtx2886 squareroot 86E+1 -> 29 Inexact Rounded +sqtx2887 squareroot 86E+2 -> 93 Inexact Rounded +sqtx2888 squareroot 86E+3 -> 2.9E+2 Inexact Rounded +sqtx2889 squareroot 0.87 -> 0.93 Inexact Rounded +sqtx2890 squareroot 0.087 -> 0.29 Inexact Rounded +sqtx2891 squareroot 87.0E-1 -> 2.9 Inexact Rounded +sqtx2892 squareroot 87.00E-2 -> 0.93 Inexact Rounded +sqtx2893 squareroot 87E-3 -> 0.29 Inexact Rounded +sqtx2894 squareroot 87E+1 -> 29 Inexact Rounded +sqtx2895 squareroot 87E+2 -> 93 Inexact Rounded +sqtx2896 squareroot 87E+3 -> 2.9E+2 Inexact Rounded +sqtx2897 squareroot 0.88 -> 0.94 Inexact Rounded +sqtx2898 squareroot 0.088 -> 0.30 Inexact Rounded +sqtx2899 squareroot 88.0E-1 -> 3.0 Inexact Rounded +sqtx2900 squareroot 88.00E-2 -> 0.94 Inexact Rounded +sqtx2901 squareroot 88E-3 -> 0.30 Inexact Rounded +sqtx2902 squareroot 88E+1 -> 30 Inexact Rounded +sqtx2903 squareroot 88E+2 -> 94 Inexact Rounded +sqtx2904 squareroot 88E+3 -> 3.0E+2 Inexact Rounded +sqtx2905 squareroot 0.89 -> 0.94 Inexact Rounded +sqtx2906 squareroot 0.089 -> 0.30 Inexact Rounded +sqtx2907 squareroot 89.0E-1 -> 3.0 Inexact Rounded +sqtx2908 squareroot 89.00E-2 -> 0.94 Inexact Rounded +sqtx2909 squareroot 89E-3 -> 0.30 Inexact Rounded +sqtx2910 squareroot 89E+1 -> 30 Inexact Rounded +sqtx2911 squareroot 89E+2 -> 94 Inexact Rounded +sqtx2912 squareroot 89E+3 -> 3.0E+2 Inexact Rounded +sqtx2913 squareroot 0.90 -> 0.95 Inexact Rounded +sqtx2914 squareroot 0.090 -> 0.30 +sqtx2915 squareroot 90.0E-1 -> 3.0 +sqtx2916 squareroot 90.00E-2 -> 0.95 Inexact Rounded +sqtx2917 squareroot 90E-3 -> 0.30 +sqtx2918 squareroot 90E+1 -> 30 +sqtx2919 squareroot 90E+2 -> 95 Inexact Rounded +sqtx2920 squareroot 90E+3 -> 3.0E+2 +sqtx2921 squareroot 0.91 -> 0.95 Inexact Rounded +sqtx2922 squareroot 0.091 -> 0.30 Inexact Rounded +sqtx2923 squareroot 91.0E-1 -> 3.0 Inexact Rounded +sqtx2924 squareroot 91.00E-2 -> 0.95 Inexact Rounded +sqtx2925 squareroot 91E-3 -> 0.30 Inexact Rounded +sqtx2926 squareroot 91E+1 -> 30 Inexact Rounded +sqtx2927 squareroot 91E+2 -> 95 Inexact Rounded +sqtx2928 squareroot 91E+3 -> 3.0E+2 Inexact Rounded +sqtx2929 squareroot 0.92 -> 0.96 Inexact Rounded +sqtx2930 squareroot 0.092 -> 0.30 Inexact Rounded +sqtx2931 squareroot 92.0E-1 -> 3.0 Inexact Rounded +sqtx2932 squareroot 92.00E-2 -> 0.96 Inexact Rounded +sqtx2933 squareroot 92E-3 -> 0.30 Inexact Rounded +sqtx2934 squareroot 92E+1 -> 30 Inexact Rounded +sqtx2935 squareroot 92E+2 -> 96 Inexact Rounded +sqtx2936 squareroot 92E+3 -> 3.0E+2 Inexact Rounded +sqtx2937 squareroot 0.93 -> 0.96 Inexact Rounded +sqtx2938 squareroot 0.093 -> 0.30 Inexact Rounded +sqtx2939 squareroot 93.0E-1 -> 3.0 Inexact Rounded +sqtx2940 squareroot 93.00E-2 -> 0.96 Inexact Rounded +sqtx2941 squareroot 93E-3 -> 0.30 Inexact Rounded +sqtx2942 squareroot 93E+1 -> 30 Inexact Rounded +sqtx2943 squareroot 93E+2 -> 96 Inexact Rounded +sqtx2944 squareroot 93E+3 -> 3.0E+2 Inexact Rounded +sqtx2945 squareroot 0.94 -> 0.97 Inexact Rounded +sqtx2946 squareroot 0.094 -> 0.31 Inexact Rounded +sqtx2947 squareroot 94.0E-1 -> 3.1 Inexact Rounded +sqtx2948 squareroot 94.00E-2 -> 0.97 Inexact Rounded +sqtx2949 squareroot 94E-3 -> 0.31 Inexact Rounded +sqtx2950 squareroot 94E+1 -> 31 Inexact Rounded +sqtx2951 squareroot 94E+2 -> 97 Inexact Rounded +sqtx2952 squareroot 94E+3 -> 3.1E+2 Inexact Rounded +sqtx2953 squareroot 0.95 -> 0.97 Inexact Rounded +sqtx2954 squareroot 0.095 -> 0.31 Inexact Rounded +sqtx2955 squareroot 95.0E-1 -> 3.1 Inexact Rounded +sqtx2956 squareroot 95.00E-2 -> 0.97 Inexact Rounded +sqtx2957 squareroot 95E-3 -> 0.31 Inexact Rounded +sqtx2958 squareroot 95E+1 -> 31 Inexact Rounded +sqtx2959 squareroot 95E+2 -> 97 Inexact Rounded +sqtx2960 squareroot 95E+3 -> 3.1E+2 Inexact Rounded +sqtx2961 squareroot 0.96 -> 0.98 Inexact Rounded +sqtx2962 squareroot 0.096 -> 0.31 Inexact Rounded +sqtx2963 squareroot 96.0E-1 -> 3.1 Inexact Rounded +sqtx2964 squareroot 96.00E-2 -> 0.98 Inexact Rounded +sqtx2965 squareroot 96E-3 -> 0.31 Inexact Rounded +sqtx2966 squareroot 96E+1 -> 31 Inexact Rounded +sqtx2967 squareroot 96E+2 -> 98 Inexact Rounded +sqtx2968 squareroot 96E+3 -> 3.1E+2 Inexact Rounded +sqtx2969 squareroot 0.97 -> 0.98 Inexact Rounded +sqtx2970 squareroot 0.097 -> 0.31 Inexact Rounded +sqtx2971 squareroot 97.0E-1 -> 3.1 Inexact Rounded +sqtx2972 squareroot 97.00E-2 -> 0.98 Inexact Rounded +sqtx2973 squareroot 97E-3 -> 0.31 Inexact Rounded +sqtx2974 squareroot 97E+1 -> 31 Inexact Rounded +sqtx2975 squareroot 97E+2 -> 98 Inexact Rounded +sqtx2976 squareroot 97E+3 -> 3.1E+2 Inexact Rounded +sqtx2977 squareroot 0.98 -> 0.99 Inexact Rounded +sqtx2978 squareroot 0.098 -> 0.31 Inexact Rounded +sqtx2979 squareroot 98.0E-1 -> 3.1 Inexact Rounded +sqtx2980 squareroot 98.00E-2 -> 0.99 Inexact Rounded +sqtx2981 squareroot 98E-3 -> 0.31 Inexact Rounded +sqtx2982 squareroot 98E+1 -> 31 Inexact Rounded +sqtx2983 squareroot 98E+2 -> 99 Inexact Rounded +sqtx2984 squareroot 98E+3 -> 3.1E+2 Inexact Rounded +sqtx2985 squareroot 0.99 -> 0.99 Inexact Rounded +sqtx2986 squareroot 0.099 -> 0.31 Inexact Rounded +sqtx2987 squareroot 99.0E-1 -> 3.1 Inexact Rounded +sqtx2988 squareroot 99.00E-2 -> 0.99 Inexact Rounded +sqtx2989 squareroot 99E-3 -> 0.31 Inexact Rounded +sqtx2990 squareroot 99E+1 -> 31 Inexact Rounded +sqtx2991 squareroot 99E+2 -> 99 Inexact Rounded +sqtx2992 squareroot 99E+3 -> 3.1E+2 Inexact Rounded + +-- Precision 3 squareroot tests [exhaustive, f and f/10] +rounding: half_even +maxExponent: 999 +minexponent: -999 +precision: 3 +sqtx3001 squareroot 0.1 -> 0.316 Inexact Rounded +sqtx3002 squareroot 0.01 -> 0.1 +sqtx3003 squareroot 0.2 -> 0.447 Inexact Rounded +sqtx3004 squareroot 0.02 -> 0.141 Inexact Rounded +sqtx3005 squareroot 0.3 -> 0.548 Inexact Rounded +sqtx3006 squareroot 0.03 -> 0.173 Inexact Rounded +sqtx3007 squareroot 0.4 -> 0.632 Inexact Rounded +sqtx3008 squareroot 0.04 -> 0.2 +sqtx3009 squareroot 0.5 -> 0.707 Inexact Rounded +sqtx3010 squareroot 0.05 -> 0.224 Inexact Rounded +sqtx3011 squareroot 0.6 -> 0.775 Inexact Rounded +sqtx3012 squareroot 0.06 -> 0.245 Inexact Rounded +sqtx3013 squareroot 0.7 -> 0.837 Inexact Rounded +sqtx3014 squareroot 0.07 -> 0.265 Inexact Rounded +sqtx3015 squareroot 0.8 -> 0.894 Inexact Rounded +sqtx3016 squareroot 0.08 -> 0.283 Inexact Rounded +sqtx3017 squareroot 0.9 -> 0.949 Inexact Rounded +sqtx3018 squareroot 0.09 -> 0.3 +sqtx3019 squareroot 0.11 -> 0.332 Inexact Rounded +sqtx3020 squareroot 0.011 -> 0.105 Inexact Rounded +sqtx3021 squareroot 0.12 -> 0.346 Inexact Rounded +sqtx3022 squareroot 0.012 -> 0.110 Inexact Rounded +sqtx3023 squareroot 0.13 -> 0.361 Inexact Rounded +sqtx3024 squareroot 0.013 -> 0.114 Inexact Rounded +sqtx3025 squareroot 0.14 -> 0.374 Inexact Rounded +sqtx3026 squareroot 0.014 -> 0.118 Inexact Rounded +sqtx3027 squareroot 0.15 -> 0.387 Inexact Rounded +sqtx3028 squareroot 0.015 -> 0.122 Inexact Rounded +sqtx3029 squareroot 0.16 -> 0.4 +sqtx3030 squareroot 0.016 -> 0.126 Inexact Rounded +sqtx3031 squareroot 0.17 -> 0.412 Inexact Rounded +sqtx3032 squareroot 0.017 -> 0.130 Inexact Rounded +sqtx3033 squareroot 0.18 -> 0.424 Inexact Rounded +sqtx3034 squareroot 0.018 -> 0.134 Inexact Rounded +sqtx3035 squareroot 0.19 -> 0.436 Inexact Rounded +sqtx3036 squareroot 0.019 -> 0.138 Inexact Rounded +sqtx3037 squareroot 0.21 -> 0.458 Inexact Rounded +sqtx3038 squareroot 0.021 -> 0.145 Inexact Rounded +sqtx3039 squareroot 0.22 -> 0.469 Inexact Rounded +sqtx3040 squareroot 0.022 -> 0.148 Inexact Rounded +sqtx3041 squareroot 0.23 -> 0.480 Inexact Rounded +sqtx3042 squareroot 0.023 -> 0.152 Inexact Rounded +sqtx3043 squareroot 0.24 -> 0.490 Inexact Rounded +sqtx3044 squareroot 0.024 -> 0.155 Inexact Rounded +sqtx3045 squareroot 0.25 -> 0.5 +sqtx3046 squareroot 0.025 -> 0.158 Inexact Rounded +sqtx3047 squareroot 0.26 -> 0.510 Inexact Rounded +sqtx3048 squareroot 0.026 -> 0.161 Inexact Rounded +sqtx3049 squareroot 0.27 -> 0.520 Inexact Rounded +sqtx3050 squareroot 0.027 -> 0.164 Inexact Rounded +sqtx3051 squareroot 0.28 -> 0.529 Inexact Rounded +sqtx3052 squareroot 0.028 -> 0.167 Inexact Rounded +sqtx3053 squareroot 0.29 -> 0.539 Inexact Rounded +sqtx3054 squareroot 0.029 -> 0.170 Inexact Rounded +sqtx3055 squareroot 0.31 -> 0.557 Inexact Rounded +sqtx3056 squareroot 0.031 -> 0.176 Inexact Rounded +sqtx3057 squareroot 0.32 -> 0.566 Inexact Rounded +sqtx3058 squareroot 0.032 -> 0.179 Inexact Rounded +sqtx3059 squareroot 0.33 -> 0.574 Inexact Rounded +sqtx3060 squareroot 0.033 -> 0.182 Inexact Rounded +sqtx3061 squareroot 0.34 -> 0.583 Inexact Rounded +sqtx3062 squareroot 0.034 -> 0.184 Inexact Rounded +sqtx3063 squareroot 0.35 -> 0.592 Inexact Rounded +sqtx3064 squareroot 0.035 -> 0.187 Inexact Rounded +sqtx3065 squareroot 0.36 -> 0.6 +sqtx3066 squareroot 0.036 -> 0.190 Inexact Rounded +sqtx3067 squareroot 0.37 -> 0.608 Inexact Rounded +sqtx3068 squareroot 0.037 -> 0.192 Inexact Rounded +sqtx3069 squareroot 0.38 -> 0.616 Inexact Rounded +sqtx3070 squareroot 0.038 -> 0.195 Inexact Rounded +sqtx3071 squareroot 0.39 -> 0.624 Inexact Rounded +sqtx3072 squareroot 0.039 -> 0.197 Inexact Rounded +sqtx3073 squareroot 0.41 -> 0.640 Inexact Rounded +sqtx3074 squareroot 0.041 -> 0.202 Inexact Rounded +sqtx3075 squareroot 0.42 -> 0.648 Inexact Rounded +sqtx3076 squareroot 0.042 -> 0.205 Inexact Rounded +sqtx3077 squareroot 0.43 -> 0.656 Inexact Rounded +sqtx3078 squareroot 0.043 -> 0.207 Inexact Rounded +sqtx3079 squareroot 0.44 -> 0.663 Inexact Rounded +sqtx3080 squareroot 0.044 -> 0.210 Inexact Rounded +sqtx3081 squareroot 0.45 -> 0.671 Inexact Rounded +sqtx3082 squareroot 0.045 -> 0.212 Inexact Rounded +sqtx3083 squareroot 0.46 -> 0.678 Inexact Rounded +sqtx3084 squareroot 0.046 -> 0.214 Inexact Rounded +sqtx3085 squareroot 0.47 -> 0.686 Inexact Rounded +sqtx3086 squareroot 0.047 -> 0.217 Inexact Rounded +sqtx3087 squareroot 0.48 -> 0.693 Inexact Rounded +sqtx3088 squareroot 0.048 -> 0.219 Inexact Rounded +sqtx3089 squareroot 0.49 -> 0.7 +sqtx3090 squareroot 0.049 -> 0.221 Inexact Rounded +sqtx3091 squareroot 0.51 -> 0.714 Inexact Rounded +sqtx3092 squareroot 0.051 -> 0.226 Inexact Rounded +sqtx3093 squareroot 0.52 -> 0.721 Inexact Rounded +sqtx3094 squareroot 0.052 -> 0.228 Inexact Rounded +sqtx3095 squareroot 0.53 -> 0.728 Inexact Rounded +sqtx3096 squareroot 0.053 -> 0.230 Inexact Rounded +sqtx3097 squareroot 0.54 -> 0.735 Inexact Rounded +sqtx3098 squareroot 0.054 -> 0.232 Inexact Rounded +sqtx3099 squareroot 0.55 -> 0.742 Inexact Rounded +sqtx3100 squareroot 0.055 -> 0.235 Inexact Rounded +sqtx3101 squareroot 0.56 -> 0.748 Inexact Rounded +sqtx3102 squareroot 0.056 -> 0.237 Inexact Rounded +sqtx3103 squareroot 0.57 -> 0.755 Inexact Rounded +sqtx3104 squareroot 0.057 -> 0.239 Inexact Rounded +sqtx3105 squareroot 0.58 -> 0.762 Inexact Rounded +sqtx3106 squareroot 0.058 -> 0.241 Inexact Rounded +sqtx3107 squareroot 0.59 -> 0.768 Inexact Rounded +sqtx3108 squareroot 0.059 -> 0.243 Inexact Rounded +sqtx3109 squareroot 0.61 -> 0.781 Inexact Rounded +sqtx3110 squareroot 0.061 -> 0.247 Inexact Rounded +sqtx3111 squareroot 0.62 -> 0.787 Inexact Rounded +sqtx3112 squareroot 0.062 -> 0.249 Inexact Rounded +sqtx3113 squareroot 0.63 -> 0.794 Inexact Rounded +sqtx3114 squareroot 0.063 -> 0.251 Inexact Rounded +sqtx3115 squareroot 0.64 -> 0.8 +sqtx3116 squareroot 0.064 -> 0.253 Inexact Rounded +sqtx3117 squareroot 0.65 -> 0.806 Inexact Rounded +sqtx3118 squareroot 0.065 -> 0.255 Inexact Rounded +sqtx3119 squareroot 0.66 -> 0.812 Inexact Rounded +sqtx3120 squareroot 0.066 -> 0.257 Inexact Rounded +sqtx3121 squareroot 0.67 -> 0.819 Inexact Rounded +sqtx3122 squareroot 0.067 -> 0.259 Inexact Rounded +sqtx3123 squareroot 0.68 -> 0.825 Inexact Rounded +sqtx3124 squareroot 0.068 -> 0.261 Inexact Rounded +sqtx3125 squareroot 0.69 -> 0.831 Inexact Rounded +sqtx3126 squareroot 0.069 -> 0.263 Inexact Rounded +sqtx3127 squareroot 0.71 -> 0.843 Inexact Rounded +sqtx3128 squareroot 0.071 -> 0.266 Inexact Rounded +sqtx3129 squareroot 0.72 -> 0.849 Inexact Rounded +sqtx3130 squareroot 0.072 -> 0.268 Inexact Rounded +sqtx3131 squareroot 0.73 -> 0.854 Inexact Rounded +sqtx3132 squareroot 0.073 -> 0.270 Inexact Rounded +sqtx3133 squareroot 0.74 -> 0.860 Inexact Rounded +sqtx3134 squareroot 0.074 -> 0.272 Inexact Rounded +sqtx3135 squareroot 0.75 -> 0.866 Inexact Rounded +sqtx3136 squareroot 0.075 -> 0.274 Inexact Rounded +sqtx3137 squareroot 0.76 -> 0.872 Inexact Rounded +sqtx3138 squareroot 0.076 -> 0.276 Inexact Rounded +sqtx3139 squareroot 0.77 -> 0.877 Inexact Rounded +sqtx3140 squareroot 0.077 -> 0.277 Inexact Rounded +sqtx3141 squareroot 0.78 -> 0.883 Inexact Rounded +sqtx3142 squareroot 0.078 -> 0.279 Inexact Rounded +sqtx3143 squareroot 0.79 -> 0.889 Inexact Rounded +sqtx3144 squareroot 0.079 -> 0.281 Inexact Rounded +sqtx3145 squareroot 0.81 -> 0.9 +sqtx3146 squareroot 0.081 -> 0.285 Inexact Rounded +sqtx3147 squareroot 0.82 -> 0.906 Inexact Rounded +sqtx3148 squareroot 0.082 -> 0.286 Inexact Rounded +sqtx3149 squareroot 0.83 -> 0.911 Inexact Rounded +sqtx3150 squareroot 0.083 -> 0.288 Inexact Rounded +sqtx3151 squareroot 0.84 -> 0.917 Inexact Rounded +sqtx3152 squareroot 0.084 -> 0.290 Inexact Rounded +sqtx3153 squareroot 0.85 -> 0.922 Inexact Rounded +sqtx3154 squareroot 0.085 -> 0.292 Inexact Rounded +sqtx3155 squareroot 0.86 -> 0.927 Inexact Rounded +sqtx3156 squareroot 0.086 -> 0.293 Inexact Rounded +sqtx3157 squareroot 0.87 -> 0.933 Inexact Rounded +sqtx3158 squareroot 0.087 -> 0.295 Inexact Rounded +sqtx3159 squareroot 0.88 -> 0.938 Inexact Rounded +sqtx3160 squareroot 0.088 -> 0.297 Inexact Rounded +sqtx3161 squareroot 0.89 -> 0.943 Inexact Rounded +sqtx3162 squareroot 0.089 -> 0.298 Inexact Rounded +sqtx3163 squareroot 0.91 -> 0.954 Inexact Rounded +sqtx3164 squareroot 0.091 -> 0.302 Inexact Rounded +sqtx3165 squareroot 0.92 -> 0.959 Inexact Rounded +sqtx3166 squareroot 0.092 -> 0.303 Inexact Rounded +sqtx3167 squareroot 0.93 -> 0.964 Inexact Rounded +sqtx3168 squareroot 0.093 -> 0.305 Inexact Rounded +sqtx3169 squareroot 0.94 -> 0.970 Inexact Rounded +sqtx3170 squareroot 0.094 -> 0.307 Inexact Rounded +sqtx3171 squareroot 0.95 -> 0.975 Inexact Rounded +sqtx3172 squareroot 0.095 -> 0.308 Inexact Rounded +sqtx3173 squareroot 0.96 -> 0.980 Inexact Rounded +sqtx3174 squareroot 0.096 -> 0.310 Inexact Rounded +sqtx3175 squareroot 0.97 -> 0.985 Inexact Rounded +sqtx3176 squareroot 0.097 -> 0.311 Inexact Rounded +sqtx3177 squareroot 0.98 -> 0.990 Inexact Rounded +sqtx3178 squareroot 0.098 -> 0.313 Inexact Rounded +sqtx3179 squareroot 0.99 -> 0.995 Inexact Rounded +sqtx3180 squareroot 0.099 -> 0.315 Inexact Rounded +sqtx3181 squareroot 0.101 -> 0.318 Inexact Rounded +sqtx3182 squareroot 0.0101 -> 0.100 Inexact Rounded +sqtx3183 squareroot 0.102 -> 0.319 Inexact Rounded +sqtx3184 squareroot 0.0102 -> 0.101 Inexact Rounded +sqtx3185 squareroot 0.103 -> 0.321 Inexact Rounded +sqtx3186 squareroot 0.0103 -> 0.101 Inexact Rounded +sqtx3187 squareroot 0.104 -> 0.322 Inexact Rounded +sqtx3188 squareroot 0.0104 -> 0.102 Inexact Rounded +sqtx3189 squareroot 0.105 -> 0.324 Inexact Rounded +sqtx3190 squareroot 0.0105 -> 0.102 Inexact Rounded +sqtx3191 squareroot 0.106 -> 0.326 Inexact Rounded +sqtx3192 squareroot 0.0106 -> 0.103 Inexact Rounded +sqtx3193 squareroot 0.107 -> 0.327 Inexact Rounded +sqtx3194 squareroot 0.0107 -> 0.103 Inexact Rounded +sqtx3195 squareroot 0.108 -> 0.329 Inexact Rounded +sqtx3196 squareroot 0.0108 -> 0.104 Inexact Rounded +sqtx3197 squareroot 0.109 -> 0.330 Inexact Rounded +sqtx3198 squareroot 0.0109 -> 0.104 Inexact Rounded +sqtx3199 squareroot 0.111 -> 0.333 Inexact Rounded +sqtx3200 squareroot 0.0111 -> 0.105 Inexact Rounded +sqtx3201 squareroot 0.112 -> 0.335 Inexact Rounded +sqtx3202 squareroot 0.0112 -> 0.106 Inexact Rounded +sqtx3203 squareroot 0.113 -> 0.336 Inexact Rounded +sqtx3204 squareroot 0.0113 -> 0.106 Inexact Rounded +sqtx3205 squareroot 0.114 -> 0.338 Inexact Rounded +sqtx3206 squareroot 0.0114 -> 0.107 Inexact Rounded +sqtx3207 squareroot 0.115 -> 0.339 Inexact Rounded +sqtx3208 squareroot 0.0115 -> 0.107 Inexact Rounded +sqtx3209 squareroot 0.116 -> 0.341 Inexact Rounded +sqtx3210 squareroot 0.0116 -> 0.108 Inexact Rounded +sqtx3211 squareroot 0.117 -> 0.342 Inexact Rounded +sqtx3212 squareroot 0.0117 -> 0.108 Inexact Rounded +sqtx3213 squareroot 0.118 -> 0.344 Inexact Rounded +sqtx3214 squareroot 0.0118 -> 0.109 Inexact Rounded +sqtx3215 squareroot 0.119 -> 0.345 Inexact Rounded +sqtx3216 squareroot 0.0119 -> 0.109 Inexact Rounded +sqtx3217 squareroot 0.121 -> 0.348 Inexact Rounded +sqtx3218 squareroot 0.0121 -> 0.11 +sqtx3219 squareroot 0.122 -> 0.349 Inexact Rounded +sqtx3220 squareroot 0.0122 -> 0.110 Inexact Rounded +sqtx3221 squareroot 0.123 -> 0.351 Inexact Rounded +sqtx3222 squareroot 0.0123 -> 0.111 Inexact Rounded +sqtx3223 squareroot 0.124 -> 0.352 Inexact Rounded +sqtx3224 squareroot 0.0124 -> 0.111 Inexact Rounded +sqtx3225 squareroot 0.125 -> 0.354 Inexact Rounded +sqtx3226 squareroot 0.0125 -> 0.112 Inexact Rounded +sqtx3227 squareroot 0.126 -> 0.355 Inexact Rounded +sqtx3228 squareroot 0.0126 -> 0.112 Inexact Rounded +sqtx3229 squareroot 0.127 -> 0.356 Inexact Rounded +sqtx3230 squareroot 0.0127 -> 0.113 Inexact Rounded +sqtx3231 squareroot 0.128 -> 0.358 Inexact Rounded +sqtx3232 squareroot 0.0128 -> 0.113 Inexact Rounded +sqtx3233 squareroot 0.129 -> 0.359 Inexact Rounded +sqtx3234 squareroot 0.0129 -> 0.114 Inexact Rounded +sqtx3235 squareroot 0.131 -> 0.362 Inexact Rounded +sqtx3236 squareroot 0.0131 -> 0.114 Inexact Rounded +sqtx3237 squareroot 0.132 -> 0.363 Inexact Rounded +sqtx3238 squareroot 0.0132 -> 0.115 Inexact Rounded +sqtx3239 squareroot 0.133 -> 0.365 Inexact Rounded +sqtx3240 squareroot 0.0133 -> 0.115 Inexact Rounded +sqtx3241 squareroot 0.134 -> 0.366 Inexact Rounded +sqtx3242 squareroot 0.0134 -> 0.116 Inexact Rounded +sqtx3243 squareroot 0.135 -> 0.367 Inexact Rounded +sqtx3244 squareroot 0.0135 -> 0.116 Inexact Rounded +sqtx3245 squareroot 0.136 -> 0.369 Inexact Rounded +sqtx3246 squareroot 0.0136 -> 0.117 Inexact Rounded +sqtx3247 squareroot 0.137 -> 0.370 Inexact Rounded +sqtx3248 squareroot 0.0137 -> 0.117 Inexact Rounded +sqtx3249 squareroot 0.138 -> 0.371 Inexact Rounded +sqtx3250 squareroot 0.0138 -> 0.117 Inexact Rounded +sqtx3251 squareroot 0.139 -> 0.373 Inexact Rounded +sqtx3252 squareroot 0.0139 -> 0.118 Inexact Rounded +sqtx3253 squareroot 0.141 -> 0.375 Inexact Rounded +sqtx3254 squareroot 0.0141 -> 0.119 Inexact Rounded +sqtx3255 squareroot 0.142 -> 0.377 Inexact Rounded +sqtx3256 squareroot 0.0142 -> 0.119 Inexact Rounded +sqtx3257 squareroot 0.143 -> 0.378 Inexact Rounded +sqtx3258 squareroot 0.0143 -> 0.120 Inexact Rounded +sqtx3259 squareroot 0.144 -> 0.379 Inexact Rounded +sqtx3260 squareroot 0.0144 -> 0.12 +sqtx3261 squareroot 0.145 -> 0.381 Inexact Rounded +sqtx3262 squareroot 0.0145 -> 0.120 Inexact Rounded +sqtx3263 squareroot 0.146 -> 0.382 Inexact Rounded +sqtx3264 squareroot 0.0146 -> 0.121 Inexact Rounded +sqtx3265 squareroot 0.147 -> 0.383 Inexact Rounded +sqtx3266 squareroot 0.0147 -> 0.121 Inexact Rounded +sqtx3267 squareroot 0.148 -> 0.385 Inexact Rounded +sqtx3268 squareroot 0.0148 -> 0.122 Inexact Rounded +sqtx3269 squareroot 0.149 -> 0.386 Inexact Rounded +sqtx3270 squareroot 0.0149 -> 0.122 Inexact Rounded +sqtx3271 squareroot 0.151 -> 0.389 Inexact Rounded +sqtx3272 squareroot 0.0151 -> 0.123 Inexact Rounded +sqtx3273 squareroot 0.152 -> 0.390 Inexact Rounded +sqtx3274 squareroot 0.0152 -> 0.123 Inexact Rounded +sqtx3275 squareroot 0.153 -> 0.391 Inexact Rounded +sqtx3276 squareroot 0.0153 -> 0.124 Inexact Rounded +sqtx3277 squareroot 0.154 -> 0.392 Inexact Rounded +sqtx3278 squareroot 0.0154 -> 0.124 Inexact Rounded +sqtx3279 squareroot 0.155 -> 0.394 Inexact Rounded +sqtx3280 squareroot 0.0155 -> 0.124 Inexact Rounded +sqtx3281 squareroot 0.156 -> 0.395 Inexact Rounded +sqtx3282 squareroot 0.0156 -> 0.125 Inexact Rounded +sqtx3283 squareroot 0.157 -> 0.396 Inexact Rounded +sqtx3284 squareroot 0.0157 -> 0.125 Inexact Rounded +sqtx3285 squareroot 0.158 -> 0.397 Inexact Rounded +sqtx3286 squareroot 0.0158 -> 0.126 Inexact Rounded +sqtx3287 squareroot 0.159 -> 0.399 Inexact Rounded +sqtx3288 squareroot 0.0159 -> 0.126 Inexact Rounded +sqtx3289 squareroot 0.161 -> 0.401 Inexact Rounded +sqtx3290 squareroot 0.0161 -> 0.127 Inexact Rounded +sqtx3291 squareroot 0.162 -> 0.402 Inexact Rounded +sqtx3292 squareroot 0.0162 -> 0.127 Inexact Rounded +sqtx3293 squareroot 0.163 -> 0.404 Inexact Rounded +sqtx3294 squareroot 0.0163 -> 0.128 Inexact Rounded +sqtx3295 squareroot 0.164 -> 0.405 Inexact Rounded +sqtx3296 squareroot 0.0164 -> 0.128 Inexact Rounded +sqtx3297 squareroot 0.165 -> 0.406 Inexact Rounded +sqtx3298 squareroot 0.0165 -> 0.128 Inexact Rounded +sqtx3299 squareroot 0.166 -> 0.407 Inexact Rounded +sqtx3300 squareroot 0.0166 -> 0.129 Inexact Rounded +sqtx3301 squareroot 0.167 -> 0.409 Inexact Rounded +sqtx3302 squareroot 0.0167 -> 0.129 Inexact Rounded +sqtx3303 squareroot 0.168 -> 0.410 Inexact Rounded +sqtx3304 squareroot 0.0168 -> 0.130 Inexact Rounded +sqtx3305 squareroot 0.169 -> 0.411 Inexact Rounded +sqtx3306 squareroot 0.0169 -> 0.13 +sqtx3307 squareroot 0.171 -> 0.414 Inexact Rounded +sqtx3308 squareroot 0.0171 -> 0.131 Inexact Rounded +sqtx3309 squareroot 0.172 -> 0.415 Inexact Rounded +sqtx3310 squareroot 0.0172 -> 0.131 Inexact Rounded +sqtx3311 squareroot 0.173 -> 0.416 Inexact Rounded +sqtx3312 squareroot 0.0173 -> 0.132 Inexact Rounded +sqtx3313 squareroot 0.174 -> 0.417 Inexact Rounded +sqtx3314 squareroot 0.0174 -> 0.132 Inexact Rounded +sqtx3315 squareroot 0.175 -> 0.418 Inexact Rounded +sqtx3316 squareroot 0.0175 -> 0.132 Inexact Rounded +sqtx3317 squareroot 0.176 -> 0.420 Inexact Rounded +sqtx3318 squareroot 0.0176 -> 0.133 Inexact Rounded +sqtx3319 squareroot 0.177 -> 0.421 Inexact Rounded +sqtx3320 squareroot 0.0177 -> 0.133 Inexact Rounded +sqtx3321 squareroot 0.178 -> 0.422 Inexact Rounded +sqtx3322 squareroot 0.0178 -> 0.133 Inexact Rounded +sqtx3323 squareroot 0.179 -> 0.423 Inexact Rounded +sqtx3324 squareroot 0.0179 -> 0.134 Inexact Rounded +sqtx3325 squareroot 0.181 -> 0.425 Inexact Rounded +sqtx3326 squareroot 0.0181 -> 0.135 Inexact Rounded +sqtx3327 squareroot 0.182 -> 0.427 Inexact Rounded +sqtx3328 squareroot 0.0182 -> 0.135 Inexact Rounded +sqtx3329 squareroot 0.183 -> 0.428 Inexact Rounded +sqtx3330 squareroot 0.0183 -> 0.135 Inexact Rounded +sqtx3331 squareroot 0.184 -> 0.429 Inexact Rounded +sqtx3332 squareroot 0.0184 -> 0.136 Inexact Rounded +sqtx3333 squareroot 0.185 -> 0.430 Inexact Rounded +sqtx3334 squareroot 0.0185 -> 0.136 Inexact Rounded +sqtx3335 squareroot 0.186 -> 0.431 Inexact Rounded +sqtx3336 squareroot 0.0186 -> 0.136 Inexact Rounded +sqtx3337 squareroot 0.187 -> 0.432 Inexact Rounded +sqtx3338 squareroot 0.0187 -> 0.137 Inexact Rounded +sqtx3339 squareroot 0.188 -> 0.434 Inexact Rounded +sqtx3340 squareroot 0.0188 -> 0.137 Inexact Rounded +sqtx3341 squareroot 0.189 -> 0.435 Inexact Rounded +sqtx3342 squareroot 0.0189 -> 0.137 Inexact Rounded +sqtx3343 squareroot 0.191 -> 0.437 Inexact Rounded +sqtx3344 squareroot 0.0191 -> 0.138 Inexact Rounded +sqtx3345 squareroot 0.192 -> 0.438 Inexact Rounded +sqtx3346 squareroot 0.0192 -> 0.139 Inexact Rounded +sqtx3347 squareroot 0.193 -> 0.439 Inexact Rounded +sqtx3348 squareroot 0.0193 -> 0.139 Inexact Rounded +sqtx3349 squareroot 0.194 -> 0.440 Inexact Rounded +sqtx3350 squareroot 0.0194 -> 0.139 Inexact Rounded +sqtx3351 squareroot 0.195 -> 0.442 Inexact Rounded +sqtx3352 squareroot 0.0195 -> 0.140 Inexact Rounded +sqtx3353 squareroot 0.196 -> 0.443 Inexact Rounded +sqtx3354 squareroot 0.0196 -> 0.14 +sqtx3355 squareroot 0.197 -> 0.444 Inexact Rounded +sqtx3356 squareroot 0.0197 -> 0.140 Inexact Rounded +sqtx3357 squareroot 0.198 -> 0.445 Inexact Rounded +sqtx3358 squareroot 0.0198 -> 0.141 Inexact Rounded +sqtx3359 squareroot 0.199 -> 0.446 Inexact Rounded +sqtx3360 squareroot 0.0199 -> 0.141 Inexact Rounded +sqtx3361 squareroot 0.201 -> 0.448 Inexact Rounded +sqtx3362 squareroot 0.0201 -> 0.142 Inexact Rounded +sqtx3363 squareroot 0.202 -> 0.449 Inexact Rounded +sqtx3364 squareroot 0.0202 -> 0.142 Inexact Rounded +sqtx3365 squareroot 0.203 -> 0.451 Inexact Rounded +sqtx3366 squareroot 0.0203 -> 0.142 Inexact Rounded +sqtx3367 squareroot 0.204 -> 0.452 Inexact Rounded +sqtx3368 squareroot 0.0204 -> 0.143 Inexact Rounded +sqtx3369 squareroot 0.205 -> 0.453 Inexact Rounded +sqtx3370 squareroot 0.0205 -> 0.143 Inexact Rounded +sqtx3371 squareroot 0.206 -> 0.454 Inexact Rounded +sqtx3372 squareroot 0.0206 -> 0.144 Inexact Rounded +sqtx3373 squareroot 0.207 -> 0.455 Inexact Rounded +sqtx3374 squareroot 0.0207 -> 0.144 Inexact Rounded +sqtx3375 squareroot 0.208 -> 0.456 Inexact Rounded +sqtx3376 squareroot 0.0208 -> 0.144 Inexact Rounded +sqtx3377 squareroot 0.209 -> 0.457 Inexact Rounded +sqtx3378 squareroot 0.0209 -> 0.145 Inexact Rounded +sqtx3379 squareroot 0.211 -> 0.459 Inexact Rounded +sqtx3380 squareroot 0.0211 -> 0.145 Inexact Rounded +sqtx3381 squareroot 0.212 -> 0.460 Inexact Rounded +sqtx3382 squareroot 0.0212 -> 0.146 Inexact Rounded +sqtx3383 squareroot 0.213 -> 0.462 Inexact Rounded +sqtx3384 squareroot 0.0213 -> 0.146 Inexact Rounded +sqtx3385 squareroot 0.214 -> 0.463 Inexact Rounded +sqtx3386 squareroot 0.0214 -> 0.146 Inexact Rounded +sqtx3387 squareroot 0.215 -> 0.464 Inexact Rounded +sqtx3388 squareroot 0.0215 -> 0.147 Inexact Rounded +sqtx3389 squareroot 0.216 -> 0.465 Inexact Rounded +sqtx3390 squareroot 0.0216 -> 0.147 Inexact Rounded +sqtx3391 squareroot 0.217 -> 0.466 Inexact Rounded +sqtx3392 squareroot 0.0217 -> 0.147 Inexact Rounded +sqtx3393 squareroot 0.218 -> 0.467 Inexact Rounded +sqtx3394 squareroot 0.0218 -> 0.148 Inexact Rounded +sqtx3395 squareroot 0.219 -> 0.468 Inexact Rounded +sqtx3396 squareroot 0.0219 -> 0.148 Inexact Rounded +sqtx3397 squareroot 0.221 -> 0.470 Inexact Rounded +sqtx3398 squareroot 0.0221 -> 0.149 Inexact Rounded +sqtx3399 squareroot 0.222 -> 0.471 Inexact Rounded +sqtx3400 squareroot 0.0222 -> 0.149 Inexact Rounded +sqtx3401 squareroot 0.223 -> 0.472 Inexact Rounded +sqtx3402 squareroot 0.0223 -> 0.149 Inexact Rounded +sqtx3403 squareroot 0.224 -> 0.473 Inexact Rounded +sqtx3404 squareroot 0.0224 -> 0.150 Inexact Rounded +sqtx3405 squareroot 0.225 -> 0.474 Inexact Rounded +sqtx3406 squareroot 0.0225 -> 0.15 +sqtx3407 squareroot 0.226 -> 0.475 Inexact Rounded +sqtx3408 squareroot 0.0226 -> 0.150 Inexact Rounded +sqtx3409 squareroot 0.227 -> 0.476 Inexact Rounded +sqtx3410 squareroot 0.0227 -> 0.151 Inexact Rounded +sqtx3411 squareroot 0.228 -> 0.477 Inexact Rounded +sqtx3412 squareroot 0.0228 -> 0.151 Inexact Rounded +sqtx3413 squareroot 0.229 -> 0.479 Inexact Rounded +sqtx3414 squareroot 0.0229 -> 0.151 Inexact Rounded +sqtx3415 squareroot 0.231 -> 0.481 Inexact Rounded +sqtx3416 squareroot 0.0231 -> 0.152 Inexact Rounded +sqtx3417 squareroot 0.232 -> 0.482 Inexact Rounded +sqtx3418 squareroot 0.0232 -> 0.152 Inexact Rounded +sqtx3419 squareroot 0.233 -> 0.483 Inexact Rounded +sqtx3420 squareroot 0.0233 -> 0.153 Inexact Rounded +sqtx3421 squareroot 0.234 -> 0.484 Inexact Rounded +sqtx3422 squareroot 0.0234 -> 0.153 Inexact Rounded +sqtx3423 squareroot 0.235 -> 0.485 Inexact Rounded +sqtx3424 squareroot 0.0235 -> 0.153 Inexact Rounded +sqtx3425 squareroot 0.236 -> 0.486 Inexact Rounded +sqtx3426 squareroot 0.0236 -> 0.154 Inexact Rounded +sqtx3427 squareroot 0.237 -> 0.487 Inexact Rounded +sqtx3428 squareroot 0.0237 -> 0.154 Inexact Rounded +sqtx3429 squareroot 0.238 -> 0.488 Inexact Rounded +sqtx3430 squareroot 0.0238 -> 0.154 Inexact Rounded +sqtx3431 squareroot 0.239 -> 0.489 Inexact Rounded +sqtx3432 squareroot 0.0239 -> 0.155 Inexact Rounded +sqtx3433 squareroot 0.241 -> 0.491 Inexact Rounded +sqtx3434 squareroot 0.0241 -> 0.155 Inexact Rounded +sqtx3435 squareroot 0.242 -> 0.492 Inexact Rounded +sqtx3436 squareroot 0.0242 -> 0.156 Inexact Rounded +sqtx3437 squareroot 0.243 -> 0.493 Inexact Rounded +sqtx3438 squareroot 0.0243 -> 0.156 Inexact Rounded +sqtx3439 squareroot 0.244 -> 0.494 Inexact Rounded +sqtx3440 squareroot 0.0244 -> 0.156 Inexact Rounded +sqtx3441 squareroot 0.245 -> 0.495 Inexact Rounded +sqtx3442 squareroot 0.0245 -> 0.157 Inexact Rounded +sqtx3443 squareroot 0.246 -> 0.496 Inexact Rounded +sqtx3444 squareroot 0.0246 -> 0.157 Inexact Rounded +sqtx3445 squareroot 0.247 -> 0.497 Inexact Rounded +sqtx3446 squareroot 0.0247 -> 0.157 Inexact Rounded +sqtx3447 squareroot 0.248 -> 0.498 Inexact Rounded +sqtx3448 squareroot 0.0248 -> 0.157 Inexact Rounded +sqtx3449 squareroot 0.249 -> 0.499 Inexact Rounded +sqtx3450 squareroot 0.0249 -> 0.158 Inexact Rounded +sqtx3451 squareroot 0.251 -> 0.501 Inexact Rounded +sqtx3452 squareroot 0.0251 -> 0.158 Inexact Rounded +sqtx3453 squareroot 0.252 -> 0.502 Inexact Rounded +sqtx3454 squareroot 0.0252 -> 0.159 Inexact Rounded +sqtx3455 squareroot 0.253 -> 0.503 Inexact Rounded +sqtx3456 squareroot 0.0253 -> 0.159 Inexact Rounded +sqtx3457 squareroot 0.254 -> 0.504 Inexact Rounded +sqtx3458 squareroot 0.0254 -> 0.159 Inexact Rounded +sqtx3459 squareroot 0.255 -> 0.505 Inexact Rounded +sqtx3460 squareroot 0.0255 -> 0.160 Inexact Rounded +sqtx3461 squareroot 0.256 -> 0.506 Inexact Rounded +sqtx3462 squareroot 0.0256 -> 0.16 +sqtx3463 squareroot 0.257 -> 0.507 Inexact Rounded +sqtx3464 squareroot 0.0257 -> 0.160 Inexact Rounded +sqtx3465 squareroot 0.258 -> 0.508 Inexact Rounded +sqtx3466 squareroot 0.0258 -> 0.161 Inexact Rounded +sqtx3467 squareroot 0.259 -> 0.509 Inexact Rounded +sqtx3468 squareroot 0.0259 -> 0.161 Inexact Rounded +sqtx3469 squareroot 0.261 -> 0.511 Inexact Rounded +sqtx3470 squareroot 0.0261 -> 0.162 Inexact Rounded +sqtx3471 squareroot 0.262 -> 0.512 Inexact Rounded +sqtx3472 squareroot 0.0262 -> 0.162 Inexact Rounded +sqtx3473 squareroot 0.263 -> 0.513 Inexact Rounded +sqtx3474 squareroot 0.0263 -> 0.162 Inexact Rounded +sqtx3475 squareroot 0.264 -> 0.514 Inexact Rounded +sqtx3476 squareroot 0.0264 -> 0.162 Inexact Rounded +sqtx3477 squareroot 0.265 -> 0.515 Inexact Rounded +sqtx3478 squareroot 0.0265 -> 0.163 Inexact Rounded +sqtx3479 squareroot 0.266 -> 0.516 Inexact Rounded +sqtx3480 squareroot 0.0266 -> 0.163 Inexact Rounded +sqtx3481 squareroot 0.267 -> 0.517 Inexact Rounded +sqtx3482 squareroot 0.0267 -> 0.163 Inexact Rounded +sqtx3483 squareroot 0.268 -> 0.518 Inexact Rounded +sqtx3484 squareroot 0.0268 -> 0.164 Inexact Rounded +sqtx3485 squareroot 0.269 -> 0.519 Inexact Rounded +sqtx3486 squareroot 0.0269 -> 0.164 Inexact Rounded +sqtx3487 squareroot 0.271 -> 0.521 Inexact Rounded +sqtx3488 squareroot 0.0271 -> 0.165 Inexact Rounded +sqtx3489 squareroot 0.272 -> 0.522 Inexact Rounded +sqtx3490 squareroot 0.0272 -> 0.165 Inexact Rounded +sqtx3491 squareroot 0.273 -> 0.522 Inexact Rounded +sqtx3492 squareroot 0.0273 -> 0.165 Inexact Rounded +sqtx3493 squareroot 0.274 -> 0.523 Inexact Rounded +sqtx3494 squareroot 0.0274 -> 0.166 Inexact Rounded +sqtx3495 squareroot 0.275 -> 0.524 Inexact Rounded +sqtx3496 squareroot 0.0275 -> 0.166 Inexact Rounded +sqtx3497 squareroot 0.276 -> 0.525 Inexact Rounded +sqtx3498 squareroot 0.0276 -> 0.166 Inexact Rounded +sqtx3499 squareroot 0.277 -> 0.526 Inexact Rounded +sqtx3500 squareroot 0.0277 -> 0.166 Inexact Rounded +sqtx3501 squareroot 0.278 -> 0.527 Inexact Rounded +sqtx3502 squareroot 0.0278 -> 0.167 Inexact Rounded +sqtx3503 squareroot 0.279 -> 0.528 Inexact Rounded +sqtx3504 squareroot 0.0279 -> 0.167 Inexact Rounded +sqtx3505 squareroot 0.281 -> 0.530 Inexact Rounded +sqtx3506 squareroot 0.0281 -> 0.168 Inexact Rounded +sqtx3507 squareroot 0.282 -> 0.531 Inexact Rounded +sqtx3508 squareroot 0.0282 -> 0.168 Inexact Rounded +sqtx3509 squareroot 0.283 -> 0.532 Inexact Rounded +sqtx3510 squareroot 0.0283 -> 0.168 Inexact Rounded +sqtx3511 squareroot 0.284 -> 0.533 Inexact Rounded +sqtx3512 squareroot 0.0284 -> 0.169 Inexact Rounded +sqtx3513 squareroot 0.285 -> 0.534 Inexact Rounded +sqtx3514 squareroot 0.0285 -> 0.169 Inexact Rounded +sqtx3515 squareroot 0.286 -> 0.535 Inexact Rounded +sqtx3516 squareroot 0.0286 -> 0.169 Inexact Rounded +sqtx3517 squareroot 0.287 -> 0.536 Inexact Rounded +sqtx3518 squareroot 0.0287 -> 0.169 Inexact Rounded +sqtx3519 squareroot 0.288 -> 0.537 Inexact Rounded +sqtx3520 squareroot 0.0288 -> 0.170 Inexact Rounded +sqtx3521 squareroot 0.289 -> 0.538 Inexact Rounded +sqtx3522 squareroot 0.0289 -> 0.17 +sqtx3523 squareroot 0.291 -> 0.539 Inexact Rounded +sqtx3524 squareroot 0.0291 -> 0.171 Inexact Rounded +sqtx3525 squareroot 0.292 -> 0.540 Inexact Rounded +sqtx3526 squareroot 0.0292 -> 0.171 Inexact Rounded +sqtx3527 squareroot 0.293 -> 0.541 Inexact Rounded +sqtx3528 squareroot 0.0293 -> 0.171 Inexact Rounded +sqtx3529 squareroot 0.294 -> 0.542 Inexact Rounded +sqtx3530 squareroot 0.0294 -> 0.171 Inexact Rounded +sqtx3531 squareroot 0.295 -> 0.543 Inexact Rounded +sqtx3532 squareroot 0.0295 -> 0.172 Inexact Rounded +sqtx3533 squareroot 0.296 -> 0.544 Inexact Rounded +sqtx3534 squareroot 0.0296 -> 0.172 Inexact Rounded +sqtx3535 squareroot 0.297 -> 0.545 Inexact Rounded +sqtx3536 squareroot 0.0297 -> 0.172 Inexact Rounded +sqtx3537 squareroot 0.298 -> 0.546 Inexact Rounded +sqtx3538 squareroot 0.0298 -> 0.173 Inexact Rounded +sqtx3539 squareroot 0.299 -> 0.547 Inexact Rounded +sqtx3540 squareroot 0.0299 -> 0.173 Inexact Rounded +sqtx3541 squareroot 0.301 -> 0.549 Inexact Rounded +sqtx3542 squareroot 0.0301 -> 0.173 Inexact Rounded +sqtx3543 squareroot 0.302 -> 0.550 Inexact Rounded +sqtx3544 squareroot 0.0302 -> 0.174 Inexact Rounded +sqtx3545 squareroot 0.303 -> 0.550 Inexact Rounded +sqtx3546 squareroot 0.0303 -> 0.174 Inexact Rounded +sqtx3547 squareroot 0.304 -> 0.551 Inexact Rounded +sqtx3548 squareroot 0.0304 -> 0.174 Inexact Rounded +sqtx3549 squareroot 0.305 -> 0.552 Inexact Rounded +sqtx3550 squareroot 0.0305 -> 0.175 Inexact Rounded +sqtx3551 squareroot 0.306 -> 0.553 Inexact Rounded +sqtx3552 squareroot 0.0306 -> 0.175 Inexact Rounded +sqtx3553 squareroot 0.307 -> 0.554 Inexact Rounded +sqtx3554 squareroot 0.0307 -> 0.175 Inexact Rounded +sqtx3555 squareroot 0.308 -> 0.555 Inexact Rounded +sqtx3556 squareroot 0.0308 -> 0.175 Inexact Rounded +sqtx3557 squareroot 0.309 -> 0.556 Inexact Rounded +sqtx3558 squareroot 0.0309 -> 0.176 Inexact Rounded +sqtx3559 squareroot 0.311 -> 0.558 Inexact Rounded +sqtx3560 squareroot 0.0311 -> 0.176 Inexact Rounded +sqtx3561 squareroot 0.312 -> 0.559 Inexact Rounded +sqtx3562 squareroot 0.0312 -> 0.177 Inexact Rounded +sqtx3563 squareroot 0.313 -> 0.559 Inexact Rounded +sqtx3564 squareroot 0.0313 -> 0.177 Inexact Rounded +sqtx3565 squareroot 0.314 -> 0.560 Inexact Rounded +sqtx3566 squareroot 0.0314 -> 0.177 Inexact Rounded +sqtx3567 squareroot 0.315 -> 0.561 Inexact Rounded +sqtx3568 squareroot 0.0315 -> 0.177 Inexact Rounded +sqtx3569 squareroot 0.316 -> 0.562 Inexact Rounded +sqtx3570 squareroot 0.0316 -> 0.178 Inexact Rounded +sqtx3571 squareroot 0.317 -> 0.563 Inexact Rounded +sqtx3572 squareroot 0.0317 -> 0.178 Inexact Rounded +sqtx3573 squareroot 0.318 -> 0.564 Inexact Rounded +sqtx3574 squareroot 0.0318 -> 0.178 Inexact Rounded +sqtx3575 squareroot 0.319 -> 0.565 Inexact Rounded +sqtx3576 squareroot 0.0319 -> 0.179 Inexact Rounded +sqtx3577 squareroot 0.321 -> 0.567 Inexact Rounded +sqtx3578 squareroot 0.0321 -> 0.179 Inexact Rounded +sqtx3579 squareroot 0.322 -> 0.567 Inexact Rounded +sqtx3580 squareroot 0.0322 -> 0.179 Inexact Rounded +sqtx3581 squareroot 0.323 -> 0.568 Inexact Rounded +sqtx3582 squareroot 0.0323 -> 0.180 Inexact Rounded +sqtx3583 squareroot 0.324 -> 0.569 Inexact Rounded +sqtx3584 squareroot 0.0324 -> 0.18 +sqtx3585 squareroot 0.325 -> 0.570 Inexact Rounded +sqtx3586 squareroot 0.0325 -> 0.180 Inexact Rounded +sqtx3587 squareroot 0.326 -> 0.571 Inexact Rounded +sqtx3588 squareroot 0.0326 -> 0.181 Inexact Rounded +sqtx3589 squareroot 0.327 -> 0.572 Inexact Rounded +sqtx3590 squareroot 0.0327 -> 0.181 Inexact Rounded +sqtx3591 squareroot 0.328 -> 0.573 Inexact Rounded +sqtx3592 squareroot 0.0328 -> 0.181 Inexact Rounded +sqtx3593 squareroot 0.329 -> 0.574 Inexact Rounded +sqtx3594 squareroot 0.0329 -> 0.181 Inexact Rounded +sqtx3595 squareroot 0.331 -> 0.575 Inexact Rounded +sqtx3596 squareroot 0.0331 -> 0.182 Inexact Rounded +sqtx3597 squareroot 0.332 -> 0.576 Inexact Rounded +sqtx3598 squareroot 0.0332 -> 0.182 Inexact Rounded +sqtx3599 squareroot 0.333 -> 0.577 Inexact Rounded +sqtx3600 squareroot 0.0333 -> 0.182 Inexact Rounded +sqtx3601 squareroot 0.334 -> 0.578 Inexact Rounded +sqtx3602 squareroot 0.0334 -> 0.183 Inexact Rounded +sqtx3603 squareroot 0.335 -> 0.579 Inexact Rounded +sqtx3604 squareroot 0.0335 -> 0.183 Inexact Rounded +sqtx3605 squareroot 0.336 -> 0.580 Inexact Rounded +sqtx3606 squareroot 0.0336 -> 0.183 Inexact Rounded +sqtx3607 squareroot 0.337 -> 0.581 Inexact Rounded +sqtx3608 squareroot 0.0337 -> 0.184 Inexact Rounded +sqtx3609 squareroot 0.338 -> 0.581 Inexact Rounded +sqtx3610 squareroot 0.0338 -> 0.184 Inexact Rounded +sqtx3611 squareroot 0.339 -> 0.582 Inexact Rounded +sqtx3612 squareroot 0.0339 -> 0.184 Inexact Rounded +sqtx3613 squareroot 0.341 -> 0.584 Inexact Rounded +sqtx3614 squareroot 0.0341 -> 0.185 Inexact Rounded +sqtx3615 squareroot 0.342 -> 0.585 Inexact Rounded +sqtx3616 squareroot 0.0342 -> 0.185 Inexact Rounded +sqtx3617 squareroot 0.343 -> 0.586 Inexact Rounded +sqtx3618 squareroot 0.0343 -> 0.185 Inexact Rounded +sqtx3619 squareroot 0.344 -> 0.587 Inexact Rounded +sqtx3620 squareroot 0.0344 -> 0.185 Inexact Rounded +sqtx3621 squareroot 0.345 -> 0.587 Inexact Rounded +sqtx3622 squareroot 0.0345 -> 0.186 Inexact Rounded +sqtx3623 squareroot 0.346 -> 0.588 Inexact Rounded +sqtx3624 squareroot 0.0346 -> 0.186 Inexact Rounded +sqtx3625 squareroot 0.347 -> 0.589 Inexact Rounded +sqtx3626 squareroot 0.0347 -> 0.186 Inexact Rounded +sqtx3627 squareroot 0.348 -> 0.590 Inexact Rounded +sqtx3628 squareroot 0.0348 -> 0.187 Inexact Rounded +sqtx3629 squareroot 0.349 -> 0.591 Inexact Rounded +sqtx3630 squareroot 0.0349 -> 0.187 Inexact Rounded +sqtx3631 squareroot 0.351 -> 0.592 Inexact Rounded +sqtx3632 squareroot 0.0351 -> 0.187 Inexact Rounded +sqtx3633 squareroot 0.352 -> 0.593 Inexact Rounded +sqtx3634 squareroot 0.0352 -> 0.188 Inexact Rounded +sqtx3635 squareroot 0.353 -> 0.594 Inexact Rounded +sqtx3636 squareroot 0.0353 -> 0.188 Inexact Rounded +sqtx3637 squareroot 0.354 -> 0.595 Inexact Rounded +sqtx3638 squareroot 0.0354 -> 0.188 Inexact Rounded +sqtx3639 squareroot 0.355 -> 0.596 Inexact Rounded +sqtx3640 squareroot 0.0355 -> 0.188 Inexact Rounded +sqtx3641 squareroot 0.356 -> 0.597 Inexact Rounded +sqtx3642 squareroot 0.0356 -> 0.189 Inexact Rounded +sqtx3643 squareroot 0.357 -> 0.597 Inexact Rounded +sqtx3644 squareroot 0.0357 -> 0.189 Inexact Rounded +sqtx3645 squareroot 0.358 -> 0.598 Inexact Rounded +sqtx3646 squareroot 0.0358 -> 0.189 Inexact Rounded +sqtx3647 squareroot 0.359 -> 0.599 Inexact Rounded +sqtx3648 squareroot 0.0359 -> 0.189 Inexact Rounded +sqtx3649 squareroot 0.361 -> 0.601 Inexact Rounded +sqtx3650 squareroot 0.0361 -> 0.19 +sqtx3651 squareroot 0.362 -> 0.602 Inexact Rounded +sqtx3652 squareroot 0.0362 -> 0.190 Inexact Rounded +sqtx3653 squareroot 0.363 -> 0.602 Inexact Rounded +sqtx3654 squareroot 0.0363 -> 0.191 Inexact Rounded +sqtx3655 squareroot 0.364 -> 0.603 Inexact Rounded +sqtx3656 squareroot 0.0364 -> 0.191 Inexact Rounded +sqtx3657 squareroot 0.365 -> 0.604 Inexact Rounded +sqtx3658 squareroot 0.0365 -> 0.191 Inexact Rounded +sqtx3659 squareroot 0.366 -> 0.605 Inexact Rounded +sqtx3660 squareroot 0.0366 -> 0.191 Inexact Rounded +sqtx3661 squareroot 0.367 -> 0.606 Inexact Rounded +sqtx3662 squareroot 0.0367 -> 0.192 Inexact Rounded +sqtx3663 squareroot 0.368 -> 0.607 Inexact Rounded +sqtx3664 squareroot 0.0368 -> 0.192 Inexact Rounded +sqtx3665 squareroot 0.369 -> 0.607 Inexact Rounded +sqtx3666 squareroot 0.0369 -> 0.192 Inexact Rounded +sqtx3667 squareroot 0.371 -> 0.609 Inexact Rounded +sqtx3668 squareroot 0.0371 -> 0.193 Inexact Rounded +sqtx3669 squareroot 0.372 -> 0.610 Inexact Rounded +sqtx3670 squareroot 0.0372 -> 0.193 Inexact Rounded +sqtx3671 squareroot 0.373 -> 0.611 Inexact Rounded +sqtx3672 squareroot 0.0373 -> 0.193 Inexact Rounded +sqtx3673 squareroot 0.374 -> 0.612 Inexact Rounded +sqtx3674 squareroot 0.0374 -> 0.193 Inexact Rounded +sqtx3675 squareroot 0.375 -> 0.612 Inexact Rounded +sqtx3676 squareroot 0.0375 -> 0.194 Inexact Rounded +sqtx3677 squareroot 0.376 -> 0.613 Inexact Rounded +sqtx3678 squareroot 0.0376 -> 0.194 Inexact Rounded +sqtx3679 squareroot 0.377 -> 0.614 Inexact Rounded +sqtx3680 squareroot 0.0377 -> 0.194 Inexact Rounded +sqtx3681 squareroot 0.378 -> 0.615 Inexact Rounded +sqtx3682 squareroot 0.0378 -> 0.194 Inexact Rounded +sqtx3683 squareroot 0.379 -> 0.616 Inexact Rounded +sqtx3684 squareroot 0.0379 -> 0.195 Inexact Rounded +sqtx3685 squareroot 0.381 -> 0.617 Inexact Rounded +sqtx3686 squareroot 0.0381 -> 0.195 Inexact Rounded +sqtx3687 squareroot 0.382 -> 0.618 Inexact Rounded +sqtx3688 squareroot 0.0382 -> 0.195 Inexact Rounded +sqtx3689 squareroot 0.383 -> 0.619 Inexact Rounded +sqtx3690 squareroot 0.0383 -> 0.196 Inexact Rounded +sqtx3691 squareroot 0.384 -> 0.620 Inexact Rounded +sqtx3692 squareroot 0.0384 -> 0.196 Inexact Rounded +sqtx3693 squareroot 0.385 -> 0.620 Inexact Rounded +sqtx3694 squareroot 0.0385 -> 0.196 Inexact Rounded +sqtx3695 squareroot 0.386 -> 0.621 Inexact Rounded +sqtx3696 squareroot 0.0386 -> 0.196 Inexact Rounded +sqtx3697 squareroot 0.387 -> 0.622 Inexact Rounded +sqtx3698 squareroot 0.0387 -> 0.197 Inexact Rounded +sqtx3699 squareroot 0.388 -> 0.623 Inexact Rounded +sqtx3700 squareroot 0.0388 -> 0.197 Inexact Rounded +sqtx3701 squareroot 0.389 -> 0.624 Inexact Rounded +sqtx3702 squareroot 0.0389 -> 0.197 Inexact Rounded +sqtx3703 squareroot 0.391 -> 0.625 Inexact Rounded +sqtx3704 squareroot 0.0391 -> 0.198 Inexact Rounded +sqtx3705 squareroot 0.392 -> 0.626 Inexact Rounded +sqtx3706 squareroot 0.0392 -> 0.198 Inexact Rounded +sqtx3707 squareroot 0.393 -> 0.627 Inexact Rounded +sqtx3708 squareroot 0.0393 -> 0.198 Inexact Rounded +sqtx3709 squareroot 0.394 -> 0.628 Inexact Rounded +sqtx3710 squareroot 0.0394 -> 0.198 Inexact Rounded +sqtx3711 squareroot 0.395 -> 0.628 Inexact Rounded +sqtx3712 squareroot 0.0395 -> 0.199 Inexact Rounded +sqtx3713 squareroot 0.396 -> 0.629 Inexact Rounded +sqtx3714 squareroot 0.0396 -> 0.199 Inexact Rounded +sqtx3715 squareroot 0.397 -> 0.630 Inexact Rounded +sqtx3716 squareroot 0.0397 -> 0.199 Inexact Rounded +sqtx3717 squareroot 0.398 -> 0.631 Inexact Rounded +sqtx3718 squareroot 0.0398 -> 0.199 Inexact Rounded +sqtx3719 squareroot 0.399 -> 0.632 Inexact Rounded +sqtx3720 squareroot 0.0399 -> 0.200 Inexact Rounded +sqtx3721 squareroot 0.401 -> 0.633 Inexact Rounded +sqtx3722 squareroot 0.0401 -> 0.200 Inexact Rounded +sqtx3723 squareroot 0.402 -> 0.634 Inexact Rounded +sqtx3724 squareroot 0.0402 -> 0.200 Inexact Rounded +sqtx3725 squareroot 0.403 -> 0.635 Inexact Rounded +sqtx3726 squareroot 0.0403 -> 0.201 Inexact Rounded +sqtx3727 squareroot 0.404 -> 0.636 Inexact Rounded +sqtx3728 squareroot 0.0404 -> 0.201 Inexact Rounded +sqtx3729 squareroot 0.405 -> 0.636 Inexact Rounded +sqtx3730 squareroot 0.0405 -> 0.201 Inexact Rounded +sqtx3731 squareroot 0.406 -> 0.637 Inexact Rounded +sqtx3732 squareroot 0.0406 -> 0.201 Inexact Rounded +sqtx3733 squareroot 0.407 -> 0.638 Inexact Rounded +sqtx3734 squareroot 0.0407 -> 0.202 Inexact Rounded +sqtx3735 squareroot 0.408 -> 0.639 Inexact Rounded +sqtx3736 squareroot 0.0408 -> 0.202 Inexact Rounded +sqtx3737 squareroot 0.409 -> 0.640 Inexact Rounded +sqtx3738 squareroot 0.0409 -> 0.202 Inexact Rounded +sqtx3739 squareroot 0.411 -> 0.641 Inexact Rounded +sqtx3740 squareroot 0.0411 -> 0.203 Inexact Rounded +sqtx3741 squareroot 0.412 -> 0.642 Inexact Rounded +sqtx3742 squareroot 0.0412 -> 0.203 Inexact Rounded +sqtx3743 squareroot 0.413 -> 0.643 Inexact Rounded +sqtx3744 squareroot 0.0413 -> 0.203 Inexact Rounded +sqtx3745 squareroot 0.414 -> 0.643 Inexact Rounded +sqtx3746 squareroot 0.0414 -> 0.203 Inexact Rounded +sqtx3747 squareroot 0.415 -> 0.644 Inexact Rounded +sqtx3748 squareroot 0.0415 -> 0.204 Inexact Rounded +sqtx3749 squareroot 0.416 -> 0.645 Inexact Rounded +sqtx3750 squareroot 0.0416 -> 0.204 Inexact Rounded +sqtx3751 squareroot 0.417 -> 0.646 Inexact Rounded +sqtx3752 squareroot 0.0417 -> 0.204 Inexact Rounded +sqtx3753 squareroot 0.418 -> 0.647 Inexact Rounded +sqtx3754 squareroot 0.0418 -> 0.204 Inexact Rounded +sqtx3755 squareroot 0.419 -> 0.647 Inexact Rounded +sqtx3756 squareroot 0.0419 -> 0.205 Inexact Rounded +sqtx3757 squareroot 0.421 -> 0.649 Inexact Rounded +sqtx3758 squareroot 0.0421 -> 0.205 Inexact Rounded +sqtx3759 squareroot 0.422 -> 0.650 Inexact Rounded +sqtx3760 squareroot 0.0422 -> 0.205 Inexact Rounded +sqtx3761 squareroot 0.423 -> 0.650 Inexact Rounded +sqtx3762 squareroot 0.0423 -> 0.206 Inexact Rounded +sqtx3763 squareroot 0.424 -> 0.651 Inexact Rounded +sqtx3764 squareroot 0.0424 -> 0.206 Inexact Rounded +sqtx3765 squareroot 0.425 -> 0.652 Inexact Rounded +sqtx3766 squareroot 0.0425 -> 0.206 Inexact Rounded +sqtx3767 squareroot 0.426 -> 0.653 Inexact Rounded +sqtx3768 squareroot 0.0426 -> 0.206 Inexact Rounded +sqtx3769 squareroot 0.427 -> 0.653 Inexact Rounded +sqtx3770 squareroot 0.0427 -> 0.207 Inexact Rounded +sqtx3771 squareroot 0.428 -> 0.654 Inexact Rounded +sqtx3772 squareroot 0.0428 -> 0.207 Inexact Rounded +sqtx3773 squareroot 0.429 -> 0.655 Inexact Rounded +sqtx3774 squareroot 0.0429 -> 0.207 Inexact Rounded +sqtx3775 squareroot 0.431 -> 0.657 Inexact Rounded +sqtx3776 squareroot 0.0431 -> 0.208 Inexact Rounded +sqtx3777 squareroot 0.432 -> 0.657 Inexact Rounded +sqtx3778 squareroot 0.0432 -> 0.208 Inexact Rounded +sqtx3779 squareroot 0.433 -> 0.658 Inexact Rounded +sqtx3780 squareroot 0.0433 -> 0.208 Inexact Rounded +sqtx3781 squareroot 0.434 -> 0.659 Inexact Rounded +sqtx3782 squareroot 0.0434 -> 0.208 Inexact Rounded +sqtx3783 squareroot 0.435 -> 0.660 Inexact Rounded +sqtx3784 squareroot 0.0435 -> 0.209 Inexact Rounded +sqtx3785 squareroot 0.436 -> 0.660 Inexact Rounded +sqtx3786 squareroot 0.0436 -> 0.209 Inexact Rounded +sqtx3787 squareroot 0.437 -> 0.661 Inexact Rounded +sqtx3788 squareroot 0.0437 -> 0.209 Inexact Rounded +sqtx3789 squareroot 0.438 -> 0.662 Inexact Rounded +sqtx3790 squareroot 0.0438 -> 0.209 Inexact Rounded +sqtx3791 squareroot 0.439 -> 0.663 Inexact Rounded +sqtx3792 squareroot 0.0439 -> 0.210 Inexact Rounded +sqtx3793 squareroot 0.441 -> 0.664 Inexact Rounded +sqtx3794 squareroot 0.0441 -> 0.21 +sqtx3795 squareroot 0.442 -> 0.665 Inexact Rounded +sqtx3796 squareroot 0.0442 -> 0.210 Inexact Rounded +sqtx3797 squareroot 0.443 -> 0.666 Inexact Rounded +sqtx3798 squareroot 0.0443 -> 0.210 Inexact Rounded +sqtx3799 squareroot 0.444 -> 0.666 Inexact Rounded +sqtx3800 squareroot 0.0444 -> 0.211 Inexact Rounded +sqtx3801 squareroot 0.445 -> 0.667 Inexact Rounded +sqtx3802 squareroot 0.0445 -> 0.211 Inexact Rounded +sqtx3803 squareroot 0.446 -> 0.668 Inexact Rounded +sqtx3804 squareroot 0.0446 -> 0.211 Inexact Rounded +sqtx3805 squareroot 0.447 -> 0.669 Inexact Rounded +sqtx3806 squareroot 0.0447 -> 0.211 Inexact Rounded +sqtx3807 squareroot 0.448 -> 0.669 Inexact Rounded +sqtx3808 squareroot 0.0448 -> 0.212 Inexact Rounded +sqtx3809 squareroot 0.449 -> 0.670 Inexact Rounded +sqtx3810 squareroot 0.0449 -> 0.212 Inexact Rounded +sqtx3811 squareroot 0.451 -> 0.672 Inexact Rounded +sqtx3812 squareroot 0.0451 -> 0.212 Inexact Rounded +sqtx3813 squareroot 0.452 -> 0.672 Inexact Rounded +sqtx3814 squareroot 0.0452 -> 0.213 Inexact Rounded +sqtx3815 squareroot 0.453 -> 0.673 Inexact Rounded +sqtx3816 squareroot 0.0453 -> 0.213 Inexact Rounded +sqtx3817 squareroot 0.454 -> 0.674 Inexact Rounded +sqtx3818 squareroot 0.0454 -> 0.213 Inexact Rounded +sqtx3819 squareroot 0.455 -> 0.675 Inexact Rounded +sqtx3820 squareroot 0.0455 -> 0.213 Inexact Rounded +sqtx3821 squareroot 0.456 -> 0.675 Inexact Rounded +sqtx3822 squareroot 0.0456 -> 0.214 Inexact Rounded +sqtx3823 squareroot 0.457 -> 0.676 Inexact Rounded +sqtx3824 squareroot 0.0457 -> 0.214 Inexact Rounded +sqtx3825 squareroot 0.458 -> 0.677 Inexact Rounded +sqtx3826 squareroot 0.0458 -> 0.214 Inexact Rounded +sqtx3827 squareroot 0.459 -> 0.677 Inexact Rounded +sqtx3828 squareroot 0.0459 -> 0.214 Inexact Rounded +sqtx3829 squareroot 0.461 -> 0.679 Inexact Rounded +sqtx3830 squareroot 0.0461 -> 0.215 Inexact Rounded +sqtx3831 squareroot 0.462 -> 0.680 Inexact Rounded +sqtx3832 squareroot 0.0462 -> 0.215 Inexact Rounded +sqtx3833 squareroot 0.463 -> 0.680 Inexact Rounded +sqtx3834 squareroot 0.0463 -> 0.215 Inexact Rounded +sqtx3835 squareroot 0.464 -> 0.681 Inexact Rounded +sqtx3836 squareroot 0.0464 -> 0.215 Inexact Rounded +sqtx3837 squareroot 0.465 -> 0.682 Inexact Rounded +sqtx3838 squareroot 0.0465 -> 0.216 Inexact Rounded +sqtx3839 squareroot 0.466 -> 0.683 Inexact Rounded +sqtx3840 squareroot 0.0466 -> 0.216 Inexact Rounded +sqtx3841 squareroot 0.467 -> 0.683 Inexact Rounded +sqtx3842 squareroot 0.0467 -> 0.216 Inexact Rounded +sqtx3843 squareroot 0.468 -> 0.684 Inexact Rounded +sqtx3844 squareroot 0.0468 -> 0.216 Inexact Rounded +sqtx3845 squareroot 0.469 -> 0.685 Inexact Rounded +sqtx3846 squareroot 0.0469 -> 0.217 Inexact Rounded +sqtx3847 squareroot 0.471 -> 0.686 Inexact Rounded +sqtx3848 squareroot 0.0471 -> 0.217 Inexact Rounded +sqtx3849 squareroot 0.472 -> 0.687 Inexact Rounded +sqtx3850 squareroot 0.0472 -> 0.217 Inexact Rounded +sqtx3851 squareroot 0.473 -> 0.688 Inexact Rounded +sqtx3852 squareroot 0.0473 -> 0.217 Inexact Rounded +sqtx3853 squareroot 0.474 -> 0.688 Inexact Rounded +sqtx3854 squareroot 0.0474 -> 0.218 Inexact Rounded +sqtx3855 squareroot 0.475 -> 0.689 Inexact Rounded +sqtx3856 squareroot 0.0475 -> 0.218 Inexact Rounded +sqtx3857 squareroot 0.476 -> 0.690 Inexact Rounded +sqtx3858 squareroot 0.0476 -> 0.218 Inexact Rounded +sqtx3859 squareroot 0.477 -> 0.691 Inexact Rounded +sqtx3860 squareroot 0.0477 -> 0.218 Inexact Rounded +sqtx3861 squareroot 0.478 -> 0.691 Inexact Rounded +sqtx3862 squareroot 0.0478 -> 0.219 Inexact Rounded +sqtx3863 squareroot 0.479 -> 0.692 Inexact Rounded +sqtx3864 squareroot 0.0479 -> 0.219 Inexact Rounded +sqtx3865 squareroot 0.481 -> 0.694 Inexact Rounded +sqtx3866 squareroot 0.0481 -> 0.219 Inexact Rounded +sqtx3867 squareroot 0.482 -> 0.694 Inexact Rounded +sqtx3868 squareroot 0.0482 -> 0.220 Inexact Rounded +sqtx3869 squareroot 0.483 -> 0.695 Inexact Rounded +sqtx3870 squareroot 0.0483 -> 0.220 Inexact Rounded +sqtx3871 squareroot 0.484 -> 0.696 Inexact Rounded +sqtx3872 squareroot 0.0484 -> 0.22 +sqtx3873 squareroot 0.485 -> 0.696 Inexact Rounded +sqtx3874 squareroot 0.0485 -> 0.220 Inexact Rounded +sqtx3875 squareroot 0.486 -> 0.697 Inexact Rounded +sqtx3876 squareroot 0.0486 -> 0.220 Inexact Rounded +sqtx3877 squareroot 0.487 -> 0.698 Inexact Rounded +sqtx3878 squareroot 0.0487 -> 0.221 Inexact Rounded +sqtx3879 squareroot 0.488 -> 0.699 Inexact Rounded +sqtx3880 squareroot 0.0488 -> 0.221 Inexact Rounded +sqtx3881 squareroot 0.489 -> 0.699 Inexact Rounded +sqtx3882 squareroot 0.0489 -> 0.221 Inexact Rounded +sqtx3883 squareroot 0.491 -> 0.701 Inexact Rounded +sqtx3884 squareroot 0.0491 -> 0.222 Inexact Rounded +sqtx3885 squareroot 0.492 -> 0.701 Inexact Rounded +sqtx3886 squareroot 0.0492 -> 0.222 Inexact Rounded +sqtx3887 squareroot 0.493 -> 0.702 Inexact Rounded +sqtx3888 squareroot 0.0493 -> 0.222 Inexact Rounded +sqtx3889 squareroot 0.494 -> 0.703 Inexact Rounded +sqtx3890 squareroot 0.0494 -> 0.222 Inexact Rounded +sqtx3891 squareroot 0.495 -> 0.704 Inexact Rounded +sqtx3892 squareroot 0.0495 -> 0.222 Inexact Rounded +sqtx3893 squareroot 0.496 -> 0.704 Inexact Rounded +sqtx3894 squareroot 0.0496 -> 0.223 Inexact Rounded +sqtx3895 squareroot 0.497 -> 0.705 Inexact Rounded +sqtx3896 squareroot 0.0497 -> 0.223 Inexact Rounded +sqtx3897 squareroot 0.498 -> 0.706 Inexact Rounded +sqtx3898 squareroot 0.0498 -> 0.223 Inexact Rounded +sqtx3899 squareroot 0.499 -> 0.706 Inexact Rounded +sqtx3900 squareroot 0.0499 -> 0.223 Inexact Rounded +sqtx3901 squareroot 0.501 -> 0.708 Inexact Rounded +sqtx3902 squareroot 0.0501 -> 0.224 Inexact Rounded +sqtx3903 squareroot 0.502 -> 0.709 Inexact Rounded +sqtx3904 squareroot 0.0502 -> 0.224 Inexact Rounded +sqtx3905 squareroot 0.503 -> 0.709 Inexact Rounded +sqtx3906 squareroot 0.0503 -> 0.224 Inexact Rounded +sqtx3907 squareroot 0.504 -> 0.710 Inexact Rounded +sqtx3908 squareroot 0.0504 -> 0.224 Inexact Rounded +sqtx3909 squareroot 0.505 -> 0.711 Inexact Rounded +sqtx3910 squareroot 0.0505 -> 0.225 Inexact Rounded +sqtx3911 squareroot 0.506 -> 0.711 Inexact Rounded +sqtx3912 squareroot 0.0506 -> 0.225 Inexact Rounded +sqtx3913 squareroot 0.507 -> 0.712 Inexact Rounded +sqtx3914 squareroot 0.0507 -> 0.225 Inexact Rounded +sqtx3915 squareroot 0.508 -> 0.713 Inexact Rounded +sqtx3916 squareroot 0.0508 -> 0.225 Inexact Rounded +sqtx3917 squareroot 0.509 -> 0.713 Inexact Rounded +sqtx3918 squareroot 0.0509 -> 0.226 Inexact Rounded +sqtx3919 squareroot 0.511 -> 0.715 Inexact Rounded +sqtx3920 squareroot 0.0511 -> 0.226 Inexact Rounded +sqtx3921 squareroot 0.512 -> 0.716 Inexact Rounded +sqtx3922 squareroot 0.0512 -> 0.226 Inexact Rounded +sqtx3923 squareroot 0.513 -> 0.716 Inexact Rounded +sqtx3924 squareroot 0.0513 -> 0.226 Inexact Rounded +sqtx3925 squareroot 0.514 -> 0.717 Inexact Rounded +sqtx3926 squareroot 0.0514 -> 0.227 Inexact Rounded +sqtx3927 squareroot 0.515 -> 0.718 Inexact Rounded +sqtx3928 squareroot 0.0515 -> 0.227 Inexact Rounded +sqtx3929 squareroot 0.516 -> 0.718 Inexact Rounded +sqtx3930 squareroot 0.0516 -> 0.227 Inexact Rounded +sqtx3931 squareroot 0.517 -> 0.719 Inexact Rounded +sqtx3932 squareroot 0.0517 -> 0.227 Inexact Rounded +sqtx3933 squareroot 0.518 -> 0.720 Inexact Rounded +sqtx3934 squareroot 0.0518 -> 0.228 Inexact Rounded +sqtx3935 squareroot 0.519 -> 0.720 Inexact Rounded +sqtx3936 squareroot 0.0519 -> 0.228 Inexact Rounded +sqtx3937 squareroot 0.521 -> 0.722 Inexact Rounded +sqtx3938 squareroot 0.0521 -> 0.228 Inexact Rounded +sqtx3939 squareroot 0.522 -> 0.722 Inexact Rounded +sqtx3940 squareroot 0.0522 -> 0.228 Inexact Rounded +sqtx3941 squareroot 0.523 -> 0.723 Inexact Rounded +sqtx3942 squareroot 0.0523 -> 0.229 Inexact Rounded +sqtx3943 squareroot 0.524 -> 0.724 Inexact Rounded +sqtx3944 squareroot 0.0524 -> 0.229 Inexact Rounded +sqtx3945 squareroot 0.525 -> 0.725 Inexact Rounded +sqtx3946 squareroot 0.0525 -> 0.229 Inexact Rounded +sqtx3947 squareroot 0.526 -> 0.725 Inexact Rounded +sqtx3948 squareroot 0.0526 -> 0.229 Inexact Rounded +sqtx3949 squareroot 0.527 -> 0.726 Inexact Rounded +sqtx3950 squareroot 0.0527 -> 0.230 Inexact Rounded +sqtx3951 squareroot 0.528 -> 0.727 Inexact Rounded +sqtx3952 squareroot 0.0528 -> 0.230 Inexact Rounded +sqtx3953 squareroot 0.529 -> 0.727 Inexact Rounded +sqtx3954 squareroot 0.0529 -> 0.23 +sqtx3955 squareroot 0.531 -> 0.729 Inexact Rounded +sqtx3956 squareroot 0.0531 -> 0.230 Inexact Rounded +sqtx3957 squareroot 0.532 -> 0.729 Inexact Rounded +sqtx3958 squareroot 0.0532 -> 0.231 Inexact Rounded +sqtx3959 squareroot 0.533 -> 0.730 Inexact Rounded +sqtx3960 squareroot 0.0533 -> 0.231 Inexact Rounded +sqtx3961 squareroot 0.534 -> 0.731 Inexact Rounded +sqtx3962 squareroot 0.0534 -> 0.231 Inexact Rounded +sqtx3963 squareroot 0.535 -> 0.731 Inexact Rounded +sqtx3964 squareroot 0.0535 -> 0.231 Inexact Rounded +sqtx3965 squareroot 0.536 -> 0.732 Inexact Rounded +sqtx3966 squareroot 0.0536 -> 0.232 Inexact Rounded +sqtx3967 squareroot 0.537 -> 0.733 Inexact Rounded +sqtx3968 squareroot 0.0537 -> 0.232 Inexact Rounded +sqtx3969 squareroot 0.538 -> 0.733 Inexact Rounded +sqtx3970 squareroot 0.0538 -> 0.232 Inexact Rounded +sqtx3971 squareroot 0.539 -> 0.734 Inexact Rounded +sqtx3972 squareroot 0.0539 -> 0.232 Inexact Rounded +sqtx3973 squareroot 0.541 -> 0.736 Inexact Rounded +sqtx3974 squareroot 0.0541 -> 0.233 Inexact Rounded +sqtx3975 squareroot 0.542 -> 0.736 Inexact Rounded +sqtx3976 squareroot 0.0542 -> 0.233 Inexact Rounded +sqtx3977 squareroot 0.543 -> 0.737 Inexact Rounded +sqtx3978 squareroot 0.0543 -> 0.233 Inexact Rounded +sqtx3979 squareroot 0.544 -> 0.738 Inexact Rounded +sqtx3980 squareroot 0.0544 -> 0.233 Inexact Rounded +sqtx3981 squareroot 0.545 -> 0.738 Inexact Rounded +sqtx3982 squareroot 0.0545 -> 0.233 Inexact Rounded +sqtx3983 squareroot 0.546 -> 0.739 Inexact Rounded +sqtx3984 squareroot 0.0546 -> 0.234 Inexact Rounded +sqtx3985 squareroot 0.547 -> 0.740 Inexact Rounded +sqtx3986 squareroot 0.0547 -> 0.234 Inexact Rounded +sqtx3987 squareroot 0.548 -> 0.740 Inexact Rounded +sqtx3988 squareroot 0.0548 -> 0.234 Inexact Rounded +sqtx3989 squareroot 0.549 -> 0.741 Inexact Rounded +sqtx3990 squareroot 0.0549 -> 0.234 Inexact Rounded +sqtx3991 squareroot 0.551 -> 0.742 Inexact Rounded +sqtx3992 squareroot 0.0551 -> 0.235 Inexact Rounded +sqtx3993 squareroot 0.552 -> 0.743 Inexact Rounded +sqtx3994 squareroot 0.0552 -> 0.235 Inexact Rounded +sqtx3995 squareroot 0.553 -> 0.744 Inexact Rounded +sqtx3996 squareroot 0.0553 -> 0.235 Inexact Rounded +sqtx3997 squareroot 0.554 -> 0.744 Inexact Rounded +sqtx3998 squareroot 0.0554 -> 0.235 Inexact Rounded +sqtx3999 squareroot 0.555 -> 0.745 Inexact Rounded +sqtx4000 squareroot 0.0555 -> 0.236 Inexact Rounded +sqtx4001 squareroot 0.556 -> 0.746 Inexact Rounded +sqtx4002 squareroot 0.0556 -> 0.236 Inexact Rounded +sqtx4003 squareroot 0.557 -> 0.746 Inexact Rounded +sqtx4004 squareroot 0.0557 -> 0.236 Inexact Rounded +sqtx4005 squareroot 0.558 -> 0.747 Inexact Rounded +sqtx4006 squareroot 0.0558 -> 0.236 Inexact Rounded +sqtx4007 squareroot 0.559 -> 0.748 Inexact Rounded +sqtx4008 squareroot 0.0559 -> 0.236 Inexact Rounded +sqtx4009 squareroot 0.561 -> 0.749 Inexact Rounded +sqtx4010 squareroot 0.0561 -> 0.237 Inexact Rounded +sqtx4011 squareroot 0.562 -> 0.750 Inexact Rounded +sqtx4012 squareroot 0.0562 -> 0.237 Inexact Rounded +sqtx4013 squareroot 0.563 -> 0.750 Inexact Rounded +sqtx4014 squareroot 0.0563 -> 0.237 Inexact Rounded +sqtx4015 squareroot 0.564 -> 0.751 Inexact Rounded +sqtx4016 squareroot 0.0564 -> 0.237 Inexact Rounded +sqtx4017 squareroot 0.565 -> 0.752 Inexact Rounded +sqtx4018 squareroot 0.0565 -> 0.238 Inexact Rounded +sqtx4019 squareroot 0.566 -> 0.752 Inexact Rounded +sqtx4020 squareroot 0.0566 -> 0.238 Inexact Rounded +sqtx4021 squareroot 0.567 -> 0.753 Inexact Rounded +sqtx4022 squareroot 0.0567 -> 0.238 Inexact Rounded +sqtx4023 squareroot 0.568 -> 0.754 Inexact Rounded +sqtx4024 squareroot 0.0568 -> 0.238 Inexact Rounded +sqtx4025 squareroot 0.569 -> 0.754 Inexact Rounded +sqtx4026 squareroot 0.0569 -> 0.239 Inexact Rounded +sqtx4027 squareroot 0.571 -> 0.756 Inexact Rounded +sqtx4028 squareroot 0.0571 -> 0.239 Inexact Rounded +sqtx4029 squareroot 0.572 -> 0.756 Inexact Rounded +sqtx4030 squareroot 0.0572 -> 0.239 Inexact Rounded +sqtx4031 squareroot 0.573 -> 0.757 Inexact Rounded +sqtx4032 squareroot 0.0573 -> 0.239 Inexact Rounded +sqtx4033 squareroot 0.574 -> 0.758 Inexact Rounded +sqtx4034 squareroot 0.0574 -> 0.240 Inexact Rounded +sqtx4035 squareroot 0.575 -> 0.758 Inexact Rounded +sqtx4036 squareroot 0.0575 -> 0.240 Inexact Rounded +sqtx4037 squareroot 0.576 -> 0.759 Inexact Rounded +sqtx4038 squareroot 0.0576 -> 0.24 +sqtx4039 squareroot 0.577 -> 0.760 Inexact Rounded +sqtx4040 squareroot 0.0577 -> 0.240 Inexact Rounded +sqtx4041 squareroot 0.578 -> 0.760 Inexact Rounded +sqtx4042 squareroot 0.0578 -> 0.240 Inexact Rounded +sqtx4043 squareroot 0.579 -> 0.761 Inexact Rounded +sqtx4044 squareroot 0.0579 -> 0.241 Inexact Rounded +sqtx4045 squareroot 0.581 -> 0.762 Inexact Rounded +sqtx4046 squareroot 0.0581 -> 0.241 Inexact Rounded +sqtx4047 squareroot 0.582 -> 0.763 Inexact Rounded +sqtx4048 squareroot 0.0582 -> 0.241 Inexact Rounded +sqtx4049 squareroot 0.583 -> 0.764 Inexact Rounded +sqtx4050 squareroot 0.0583 -> 0.241 Inexact Rounded +sqtx4051 squareroot 0.584 -> 0.764 Inexact Rounded +sqtx4052 squareroot 0.0584 -> 0.242 Inexact Rounded +sqtx4053 squareroot 0.585 -> 0.765 Inexact Rounded +sqtx4054 squareroot 0.0585 -> 0.242 Inexact Rounded +sqtx4055 squareroot 0.586 -> 0.766 Inexact Rounded +sqtx4056 squareroot 0.0586 -> 0.242 Inexact Rounded +sqtx4057 squareroot 0.587 -> 0.766 Inexact Rounded +sqtx4058 squareroot 0.0587 -> 0.242 Inexact Rounded +sqtx4059 squareroot 0.588 -> 0.767 Inexact Rounded +sqtx4060 squareroot 0.0588 -> 0.242 Inexact Rounded +sqtx4061 squareroot 0.589 -> 0.767 Inexact Rounded +sqtx4062 squareroot 0.0589 -> 0.243 Inexact Rounded +sqtx4063 squareroot 0.591 -> 0.769 Inexact Rounded +sqtx4064 squareroot 0.0591 -> 0.243 Inexact Rounded +sqtx4065 squareroot 0.592 -> 0.769 Inexact Rounded +sqtx4066 squareroot 0.0592 -> 0.243 Inexact Rounded +sqtx4067 squareroot 0.593 -> 0.770 Inexact Rounded +sqtx4068 squareroot 0.0593 -> 0.244 Inexact Rounded +sqtx4069 squareroot 0.594 -> 0.771 Inexact Rounded +sqtx4070 squareroot 0.0594 -> 0.244 Inexact Rounded +sqtx4071 squareroot 0.595 -> 0.771 Inexact Rounded +sqtx4072 squareroot 0.0595 -> 0.244 Inexact Rounded +sqtx4073 squareroot 0.596 -> 0.772 Inexact Rounded +sqtx4074 squareroot 0.0596 -> 0.244 Inexact Rounded +sqtx4075 squareroot 0.597 -> 0.773 Inexact Rounded +sqtx4076 squareroot 0.0597 -> 0.244 Inexact Rounded +sqtx4077 squareroot 0.598 -> 0.773 Inexact Rounded +sqtx4078 squareroot 0.0598 -> 0.245 Inexact Rounded +sqtx4079 squareroot 0.599 -> 0.774 Inexact Rounded +sqtx4080 squareroot 0.0599 -> 0.245 Inexact Rounded +sqtx4081 squareroot 0.601 -> 0.775 Inexact Rounded +sqtx4082 squareroot 0.0601 -> 0.245 Inexact Rounded +sqtx4083 squareroot 0.602 -> 0.776 Inexact Rounded +sqtx4084 squareroot 0.0602 -> 0.245 Inexact Rounded +sqtx4085 squareroot 0.603 -> 0.777 Inexact Rounded +sqtx4086 squareroot 0.0603 -> 0.246 Inexact Rounded +sqtx4087 squareroot 0.604 -> 0.777 Inexact Rounded +sqtx4088 squareroot 0.0604 -> 0.246 Inexact Rounded +sqtx4089 squareroot 0.605 -> 0.778 Inexact Rounded +sqtx4090 squareroot 0.0605 -> 0.246 Inexact Rounded +sqtx4091 squareroot 0.606 -> 0.778 Inexact Rounded +sqtx4092 squareroot 0.0606 -> 0.246 Inexact Rounded +sqtx4093 squareroot 0.607 -> 0.779 Inexact Rounded +sqtx4094 squareroot 0.0607 -> 0.246 Inexact Rounded +sqtx4095 squareroot 0.608 -> 0.780 Inexact Rounded +sqtx4096 squareroot 0.0608 -> 0.247 Inexact Rounded +sqtx4097 squareroot 0.609 -> 0.780 Inexact Rounded +sqtx4098 squareroot 0.0609 -> 0.247 Inexact Rounded +sqtx4099 squareroot 0.611 -> 0.782 Inexact Rounded +sqtx4100 squareroot 0.0611 -> 0.247 Inexact Rounded +sqtx4101 squareroot 0.612 -> 0.782 Inexact Rounded +sqtx4102 squareroot 0.0612 -> 0.247 Inexact Rounded +sqtx4103 squareroot 0.613 -> 0.783 Inexact Rounded +sqtx4104 squareroot 0.0613 -> 0.248 Inexact Rounded +sqtx4105 squareroot 0.614 -> 0.784 Inexact Rounded +sqtx4106 squareroot 0.0614 -> 0.248 Inexact Rounded +sqtx4107 squareroot 0.615 -> 0.784 Inexact Rounded +sqtx4108 squareroot 0.0615 -> 0.248 Inexact Rounded +sqtx4109 squareroot 0.616 -> 0.785 Inexact Rounded +sqtx4110 squareroot 0.0616 -> 0.248 Inexact Rounded +sqtx4111 squareroot 0.617 -> 0.785 Inexact Rounded +sqtx4112 squareroot 0.0617 -> 0.248 Inexact Rounded +sqtx4113 squareroot 0.618 -> 0.786 Inexact Rounded +sqtx4114 squareroot 0.0618 -> 0.249 Inexact Rounded +sqtx4115 squareroot 0.619 -> 0.787 Inexact Rounded +sqtx4116 squareroot 0.0619 -> 0.249 Inexact Rounded +sqtx4117 squareroot 0.621 -> 0.788 Inexact Rounded +sqtx4118 squareroot 0.0621 -> 0.249 Inexact Rounded +sqtx4119 squareroot 0.622 -> 0.789 Inexact Rounded +sqtx4120 squareroot 0.0622 -> 0.249 Inexact Rounded +sqtx4121 squareroot 0.623 -> 0.789 Inexact Rounded +sqtx4122 squareroot 0.0623 -> 0.250 Inexact Rounded +sqtx4123 squareroot 0.624 -> 0.790 Inexact Rounded +sqtx4124 squareroot 0.0624 -> 0.250 Inexact Rounded +sqtx4125 squareroot 0.625 -> 0.791 Inexact Rounded +sqtx4126 squareroot 0.0625 -> 0.25 +sqtx4127 squareroot 0.626 -> 0.791 Inexact Rounded +sqtx4128 squareroot 0.0626 -> 0.250 Inexact Rounded +sqtx4129 squareroot 0.627 -> 0.792 Inexact Rounded +sqtx4130 squareroot 0.0627 -> 0.250 Inexact Rounded +sqtx4131 squareroot 0.628 -> 0.792 Inexact Rounded +sqtx4132 squareroot 0.0628 -> 0.251 Inexact Rounded +sqtx4133 squareroot 0.629 -> 0.793 Inexact Rounded +sqtx4134 squareroot 0.0629 -> 0.251 Inexact Rounded +sqtx4135 squareroot 0.631 -> 0.794 Inexact Rounded +sqtx4136 squareroot 0.0631 -> 0.251 Inexact Rounded +sqtx4137 squareroot 0.632 -> 0.795 Inexact Rounded +sqtx4138 squareroot 0.0632 -> 0.251 Inexact Rounded +sqtx4139 squareroot 0.633 -> 0.796 Inexact Rounded +sqtx4140 squareroot 0.0633 -> 0.252 Inexact Rounded +sqtx4141 squareroot 0.634 -> 0.796 Inexact Rounded +sqtx4142 squareroot 0.0634 -> 0.252 Inexact Rounded +sqtx4143 squareroot 0.635 -> 0.797 Inexact Rounded +sqtx4144 squareroot 0.0635 -> 0.252 Inexact Rounded +sqtx4145 squareroot 0.636 -> 0.797 Inexact Rounded +sqtx4146 squareroot 0.0636 -> 0.252 Inexact Rounded +sqtx4147 squareroot 0.637 -> 0.798 Inexact Rounded +sqtx4148 squareroot 0.0637 -> 0.252 Inexact Rounded +sqtx4149 squareroot 0.638 -> 0.799 Inexact Rounded +sqtx4150 squareroot 0.0638 -> 0.253 Inexact Rounded +sqtx4151 squareroot 0.639 -> 0.799 Inexact Rounded +sqtx4152 squareroot 0.0639 -> 0.253 Inexact Rounded +sqtx4153 squareroot 0.641 -> 0.801 Inexact Rounded +sqtx4154 squareroot 0.0641 -> 0.253 Inexact Rounded +sqtx4155 squareroot 0.642 -> 0.801 Inexact Rounded +sqtx4156 squareroot 0.0642 -> 0.253 Inexact Rounded +sqtx4157 squareroot 0.643 -> 0.802 Inexact Rounded +sqtx4158 squareroot 0.0643 -> 0.254 Inexact Rounded +sqtx4159 squareroot 0.644 -> 0.802 Inexact Rounded +sqtx4160 squareroot 0.0644 -> 0.254 Inexact Rounded +sqtx4161 squareroot 0.645 -> 0.803 Inexact Rounded +sqtx4162 squareroot 0.0645 -> 0.254 Inexact Rounded +sqtx4163 squareroot 0.646 -> 0.804 Inexact Rounded +sqtx4164 squareroot 0.0646 -> 0.254 Inexact Rounded +sqtx4165 squareroot 0.647 -> 0.804 Inexact Rounded +sqtx4166 squareroot 0.0647 -> 0.254 Inexact Rounded +sqtx4167 squareroot 0.648 -> 0.805 Inexact Rounded +sqtx4168 squareroot 0.0648 -> 0.255 Inexact Rounded +sqtx4169 squareroot 0.649 -> 0.806 Inexact Rounded +sqtx4170 squareroot 0.0649 -> 0.255 Inexact Rounded +sqtx4171 squareroot 0.651 -> 0.807 Inexact Rounded +sqtx4172 squareroot 0.0651 -> 0.255 Inexact Rounded +sqtx4173 squareroot 0.652 -> 0.807 Inexact Rounded +sqtx4174 squareroot 0.0652 -> 0.255 Inexact Rounded +sqtx4175 squareroot 0.653 -> 0.808 Inexact Rounded +sqtx4176 squareroot 0.0653 -> 0.256 Inexact Rounded +sqtx4177 squareroot 0.654 -> 0.809 Inexact Rounded +sqtx4178 squareroot 0.0654 -> 0.256 Inexact Rounded +sqtx4179 squareroot 0.655 -> 0.809 Inexact Rounded +sqtx4180 squareroot 0.0655 -> 0.256 Inexact Rounded +sqtx4181 squareroot 0.656 -> 0.810 Inexact Rounded +sqtx4182 squareroot 0.0656 -> 0.256 Inexact Rounded +sqtx4183 squareroot 0.657 -> 0.811 Inexact Rounded +sqtx4184 squareroot 0.0657 -> 0.256 Inexact Rounded +sqtx4185 squareroot 0.658 -> 0.811 Inexact Rounded +sqtx4186 squareroot 0.0658 -> 0.257 Inexact Rounded +sqtx4187 squareroot 0.659 -> 0.812 Inexact Rounded +sqtx4188 squareroot 0.0659 -> 0.257 Inexact Rounded +sqtx4189 squareroot 0.661 -> 0.813 Inexact Rounded +sqtx4190 squareroot 0.0661 -> 0.257 Inexact Rounded +sqtx4191 squareroot 0.662 -> 0.814 Inexact Rounded +sqtx4192 squareroot 0.0662 -> 0.257 Inexact Rounded +sqtx4193 squareroot 0.663 -> 0.814 Inexact Rounded +sqtx4194 squareroot 0.0663 -> 0.257 Inexact Rounded +sqtx4195 squareroot 0.664 -> 0.815 Inexact Rounded +sqtx4196 squareroot 0.0664 -> 0.258 Inexact Rounded +sqtx4197 squareroot 0.665 -> 0.815 Inexact Rounded +sqtx4198 squareroot 0.0665 -> 0.258 Inexact Rounded +sqtx4199 squareroot 0.666 -> 0.816 Inexact Rounded +sqtx4200 squareroot 0.0666 -> 0.258 Inexact Rounded +sqtx4201 squareroot 0.667 -> 0.817 Inexact Rounded +sqtx4202 squareroot 0.0667 -> 0.258 Inexact Rounded +sqtx4203 squareroot 0.668 -> 0.817 Inexact Rounded +sqtx4204 squareroot 0.0668 -> 0.258 Inexact Rounded +sqtx4205 squareroot 0.669 -> 0.818 Inexact Rounded +sqtx4206 squareroot 0.0669 -> 0.259 Inexact Rounded +sqtx4207 squareroot 0.671 -> 0.819 Inexact Rounded +sqtx4208 squareroot 0.0671 -> 0.259 Inexact Rounded +sqtx4209 squareroot 0.672 -> 0.820 Inexact Rounded +sqtx4210 squareroot 0.0672 -> 0.259 Inexact Rounded +sqtx4211 squareroot 0.673 -> 0.820 Inexact Rounded +sqtx4212 squareroot 0.0673 -> 0.259 Inexact Rounded +sqtx4213 squareroot 0.674 -> 0.821 Inexact Rounded +sqtx4214 squareroot 0.0674 -> 0.260 Inexact Rounded +sqtx4215 squareroot 0.675 -> 0.822 Inexact Rounded +sqtx4216 squareroot 0.0675 -> 0.260 Inexact Rounded +sqtx4217 squareroot 0.676 -> 0.822 Inexact Rounded +sqtx4218 squareroot 0.0676 -> 0.26 +sqtx4219 squareroot 0.677 -> 0.823 Inexact Rounded +sqtx4220 squareroot 0.0677 -> 0.260 Inexact Rounded +sqtx4221 squareroot 0.678 -> 0.823 Inexact Rounded +sqtx4222 squareroot 0.0678 -> 0.260 Inexact Rounded +sqtx4223 squareroot 0.679 -> 0.824 Inexact Rounded +sqtx4224 squareroot 0.0679 -> 0.261 Inexact Rounded +sqtx4225 squareroot 0.681 -> 0.825 Inexact Rounded +sqtx4226 squareroot 0.0681 -> 0.261 Inexact Rounded +sqtx4227 squareroot 0.682 -> 0.826 Inexact Rounded +sqtx4228 squareroot 0.0682 -> 0.261 Inexact Rounded +sqtx4229 squareroot 0.683 -> 0.826 Inexact Rounded +sqtx4230 squareroot 0.0683 -> 0.261 Inexact Rounded +sqtx4231 squareroot 0.684 -> 0.827 Inexact Rounded +sqtx4232 squareroot 0.0684 -> 0.262 Inexact Rounded +sqtx4233 squareroot 0.685 -> 0.828 Inexact Rounded +sqtx4234 squareroot 0.0685 -> 0.262 Inexact Rounded +sqtx4235 squareroot 0.686 -> 0.828 Inexact Rounded +sqtx4236 squareroot 0.0686 -> 0.262 Inexact Rounded +sqtx4237 squareroot 0.687 -> 0.829 Inexact Rounded +sqtx4238 squareroot 0.0687 -> 0.262 Inexact Rounded +sqtx4239 squareroot 0.688 -> 0.829 Inexact Rounded +sqtx4240 squareroot 0.0688 -> 0.262 Inexact Rounded +sqtx4241 squareroot 0.689 -> 0.830 Inexact Rounded +sqtx4242 squareroot 0.0689 -> 0.262 Inexact Rounded +sqtx4243 squareroot 0.691 -> 0.831 Inexact Rounded +sqtx4244 squareroot 0.0691 -> 0.263 Inexact Rounded +sqtx4245 squareroot 0.692 -> 0.832 Inexact Rounded +sqtx4246 squareroot 0.0692 -> 0.263 Inexact Rounded +sqtx4247 squareroot 0.693 -> 0.832 Inexact Rounded +sqtx4248 squareroot 0.0693 -> 0.263 Inexact Rounded +sqtx4249 squareroot 0.694 -> 0.833 Inexact Rounded +sqtx4250 squareroot 0.0694 -> 0.263 Inexact Rounded +sqtx4251 squareroot 0.695 -> 0.834 Inexact Rounded +sqtx4252 squareroot 0.0695 -> 0.264 Inexact Rounded +sqtx4253 squareroot 0.696 -> 0.834 Inexact Rounded +sqtx4254 squareroot 0.0696 -> 0.264 Inexact Rounded +sqtx4255 squareroot 0.697 -> 0.835 Inexact Rounded +sqtx4256 squareroot 0.0697 -> 0.264 Inexact Rounded +sqtx4257 squareroot 0.698 -> 0.835 Inexact Rounded +sqtx4258 squareroot 0.0698 -> 0.264 Inexact Rounded +sqtx4259 squareroot 0.699 -> 0.836 Inexact Rounded +sqtx4260 squareroot 0.0699 -> 0.264 Inexact Rounded +sqtx4261 squareroot 0.701 -> 0.837 Inexact Rounded +sqtx4262 squareroot 0.0701 -> 0.265 Inexact Rounded +sqtx4263 squareroot 0.702 -> 0.838 Inexact Rounded +sqtx4264 squareroot 0.0702 -> 0.265 Inexact Rounded +sqtx4265 squareroot 0.703 -> 0.838 Inexact Rounded +sqtx4266 squareroot 0.0703 -> 0.265 Inexact Rounded +sqtx4267 squareroot 0.704 -> 0.839 Inexact Rounded +sqtx4268 squareroot 0.0704 -> 0.265 Inexact Rounded +sqtx4269 squareroot 0.705 -> 0.840 Inexact Rounded +sqtx4270 squareroot 0.0705 -> 0.266 Inexact Rounded +sqtx4271 squareroot 0.706 -> 0.840 Inexact Rounded +sqtx4272 squareroot 0.0706 -> 0.266 Inexact Rounded +sqtx4273 squareroot 0.707 -> 0.841 Inexact Rounded +sqtx4274 squareroot 0.0707 -> 0.266 Inexact Rounded +sqtx4275 squareroot 0.708 -> 0.841 Inexact Rounded +sqtx4276 squareroot 0.0708 -> 0.266 Inexact Rounded +sqtx4277 squareroot 0.709 -> 0.842 Inexact Rounded +sqtx4278 squareroot 0.0709 -> 0.266 Inexact Rounded +sqtx4279 squareroot 0.711 -> 0.843 Inexact Rounded +sqtx4280 squareroot 0.0711 -> 0.267 Inexact Rounded +sqtx4281 squareroot 0.712 -> 0.844 Inexact Rounded +sqtx4282 squareroot 0.0712 -> 0.267 Inexact Rounded +sqtx4283 squareroot 0.713 -> 0.844 Inexact Rounded +sqtx4284 squareroot 0.0713 -> 0.267 Inexact Rounded +sqtx4285 squareroot 0.714 -> 0.845 Inexact Rounded +sqtx4286 squareroot 0.0714 -> 0.267 Inexact Rounded +sqtx4287 squareroot 0.715 -> 0.846 Inexact Rounded +sqtx4288 squareroot 0.0715 -> 0.267 Inexact Rounded +sqtx4289 squareroot 0.716 -> 0.846 Inexact Rounded +sqtx4290 squareroot 0.0716 -> 0.268 Inexact Rounded +sqtx4291 squareroot 0.717 -> 0.847 Inexact Rounded +sqtx4292 squareroot 0.0717 -> 0.268 Inexact Rounded +sqtx4293 squareroot 0.718 -> 0.847 Inexact Rounded +sqtx4294 squareroot 0.0718 -> 0.268 Inexact Rounded +sqtx4295 squareroot 0.719 -> 0.848 Inexact Rounded +sqtx4296 squareroot 0.0719 -> 0.268 Inexact Rounded +sqtx4297 squareroot 0.721 -> 0.849 Inexact Rounded +sqtx4298 squareroot 0.0721 -> 0.269 Inexact Rounded +sqtx4299 squareroot 0.722 -> 0.850 Inexact Rounded +sqtx4300 squareroot 0.0722 -> 0.269 Inexact Rounded +sqtx4301 squareroot 0.723 -> 0.850 Inexact Rounded +sqtx4302 squareroot 0.0723 -> 0.269 Inexact Rounded +sqtx4303 squareroot 0.724 -> 0.851 Inexact Rounded +sqtx4304 squareroot 0.0724 -> 0.269 Inexact Rounded +sqtx4305 squareroot 0.725 -> 0.851 Inexact Rounded +sqtx4306 squareroot 0.0725 -> 0.269 Inexact Rounded +sqtx4307 squareroot 0.726 -> 0.852 Inexact Rounded +sqtx4308 squareroot 0.0726 -> 0.269 Inexact Rounded +sqtx4309 squareroot 0.727 -> 0.853 Inexact Rounded +sqtx4310 squareroot 0.0727 -> 0.270 Inexact Rounded +sqtx4311 squareroot 0.728 -> 0.853 Inexact Rounded +sqtx4312 squareroot 0.0728 -> 0.270 Inexact Rounded +sqtx4313 squareroot 0.729 -> 0.854 Inexact Rounded +sqtx4314 squareroot 0.0729 -> 0.27 +sqtx4315 squareroot 0.731 -> 0.855 Inexact Rounded +sqtx4316 squareroot 0.0731 -> 0.270 Inexact Rounded +sqtx4317 squareroot 0.732 -> 0.856 Inexact Rounded +sqtx4318 squareroot 0.0732 -> 0.271 Inexact Rounded +sqtx4319 squareroot 0.733 -> 0.856 Inexact Rounded +sqtx4320 squareroot 0.0733 -> 0.271 Inexact Rounded +sqtx4321 squareroot 0.734 -> 0.857 Inexact Rounded +sqtx4322 squareroot 0.0734 -> 0.271 Inexact Rounded +sqtx4323 squareroot 0.735 -> 0.857 Inexact Rounded +sqtx4324 squareroot 0.0735 -> 0.271 Inexact Rounded +sqtx4325 squareroot 0.736 -> 0.858 Inexact Rounded +sqtx4326 squareroot 0.0736 -> 0.271 Inexact Rounded +sqtx4327 squareroot 0.737 -> 0.858 Inexact Rounded +sqtx4328 squareroot 0.0737 -> 0.271 Inexact Rounded +sqtx4329 squareroot 0.738 -> 0.859 Inexact Rounded +sqtx4330 squareroot 0.0738 -> 0.272 Inexact Rounded +sqtx4331 squareroot 0.739 -> 0.860 Inexact Rounded +sqtx4332 squareroot 0.0739 -> 0.272 Inexact Rounded +sqtx4333 squareroot 0.741 -> 0.861 Inexact Rounded +sqtx4334 squareroot 0.0741 -> 0.272 Inexact Rounded +sqtx4335 squareroot 0.742 -> 0.861 Inexact Rounded +sqtx4336 squareroot 0.0742 -> 0.272 Inexact Rounded +sqtx4337 squareroot 0.743 -> 0.862 Inexact Rounded +sqtx4338 squareroot 0.0743 -> 0.273 Inexact Rounded +sqtx4339 squareroot 0.744 -> 0.863 Inexact Rounded +sqtx4340 squareroot 0.0744 -> 0.273 Inexact Rounded +sqtx4341 squareroot 0.745 -> 0.863 Inexact Rounded +sqtx4342 squareroot 0.0745 -> 0.273 Inexact Rounded +sqtx4343 squareroot 0.746 -> 0.864 Inexact Rounded +sqtx4344 squareroot 0.0746 -> 0.273 Inexact Rounded +sqtx4345 squareroot 0.747 -> 0.864 Inexact Rounded +sqtx4346 squareroot 0.0747 -> 0.273 Inexact Rounded +sqtx4347 squareroot 0.748 -> 0.865 Inexact Rounded +sqtx4348 squareroot 0.0748 -> 0.273 Inexact Rounded +sqtx4349 squareroot 0.749 -> 0.865 Inexact Rounded +sqtx4350 squareroot 0.0749 -> 0.274 Inexact Rounded +sqtx4351 squareroot 0.751 -> 0.867 Inexact Rounded +sqtx4352 squareroot 0.0751 -> 0.274 Inexact Rounded +sqtx4353 squareroot 0.752 -> 0.867 Inexact Rounded +sqtx4354 squareroot 0.0752 -> 0.274 Inexact Rounded +sqtx4355 squareroot 0.753 -> 0.868 Inexact Rounded +sqtx4356 squareroot 0.0753 -> 0.274 Inexact Rounded +sqtx4357 squareroot 0.754 -> 0.868 Inexact Rounded +sqtx4358 squareroot 0.0754 -> 0.275 Inexact Rounded +sqtx4359 squareroot 0.755 -> 0.869 Inexact Rounded +sqtx4360 squareroot 0.0755 -> 0.275 Inexact Rounded +sqtx4361 squareroot 0.756 -> 0.869 Inexact Rounded +sqtx4362 squareroot 0.0756 -> 0.275 Inexact Rounded +sqtx4363 squareroot 0.757 -> 0.870 Inexact Rounded +sqtx4364 squareroot 0.0757 -> 0.275 Inexact Rounded +sqtx4365 squareroot 0.758 -> 0.871 Inexact Rounded +sqtx4366 squareroot 0.0758 -> 0.275 Inexact Rounded +sqtx4367 squareroot 0.759 -> 0.871 Inexact Rounded +sqtx4368 squareroot 0.0759 -> 0.275 Inexact Rounded +sqtx4369 squareroot 0.761 -> 0.872 Inexact Rounded +sqtx4370 squareroot 0.0761 -> 0.276 Inexact Rounded +sqtx4371 squareroot 0.762 -> 0.873 Inexact Rounded +sqtx4372 squareroot 0.0762 -> 0.276 Inexact Rounded +sqtx4373 squareroot 0.763 -> 0.873 Inexact Rounded +sqtx4374 squareroot 0.0763 -> 0.276 Inexact Rounded +sqtx4375 squareroot 0.764 -> 0.874 Inexact Rounded +sqtx4376 squareroot 0.0764 -> 0.276 Inexact Rounded +sqtx4377 squareroot 0.765 -> 0.875 Inexact Rounded +sqtx4378 squareroot 0.0765 -> 0.277 Inexact Rounded +sqtx4379 squareroot 0.766 -> 0.875 Inexact Rounded +sqtx4380 squareroot 0.0766 -> 0.277 Inexact Rounded +sqtx4381 squareroot 0.767 -> 0.876 Inexact Rounded +sqtx4382 squareroot 0.0767 -> 0.277 Inexact Rounded +sqtx4383 squareroot 0.768 -> 0.876 Inexact Rounded +sqtx4384 squareroot 0.0768 -> 0.277 Inexact Rounded +sqtx4385 squareroot 0.769 -> 0.877 Inexact Rounded +sqtx4386 squareroot 0.0769 -> 0.277 Inexact Rounded +sqtx4387 squareroot 0.771 -> 0.878 Inexact Rounded +sqtx4388 squareroot 0.0771 -> 0.278 Inexact Rounded +sqtx4389 squareroot 0.772 -> 0.879 Inexact Rounded +sqtx4390 squareroot 0.0772 -> 0.278 Inexact Rounded +sqtx4391 squareroot 0.773 -> 0.879 Inexact Rounded +sqtx4392 squareroot 0.0773 -> 0.278 Inexact Rounded +sqtx4393 squareroot 0.774 -> 0.880 Inexact Rounded +sqtx4394 squareroot 0.0774 -> 0.278 Inexact Rounded +sqtx4395 squareroot 0.775 -> 0.880 Inexact Rounded +sqtx4396 squareroot 0.0775 -> 0.278 Inexact Rounded +sqtx4397 squareroot 0.776 -> 0.881 Inexact Rounded +sqtx4398 squareroot 0.0776 -> 0.279 Inexact Rounded +sqtx4399 squareroot 0.777 -> 0.881 Inexact Rounded +sqtx4400 squareroot 0.0777 -> 0.279 Inexact Rounded +sqtx4401 squareroot 0.778 -> 0.882 Inexact Rounded +sqtx4402 squareroot 0.0778 -> 0.279 Inexact Rounded +sqtx4403 squareroot 0.779 -> 0.883 Inexact Rounded +sqtx4404 squareroot 0.0779 -> 0.279 Inexact Rounded +sqtx4405 squareroot 0.781 -> 0.884 Inexact Rounded +sqtx4406 squareroot 0.0781 -> 0.279 Inexact Rounded +sqtx4407 squareroot 0.782 -> 0.884 Inexact Rounded +sqtx4408 squareroot 0.0782 -> 0.280 Inexact Rounded +sqtx4409 squareroot 0.783 -> 0.885 Inexact Rounded +sqtx4410 squareroot 0.0783 -> 0.280 Inexact Rounded +sqtx4411 squareroot 0.784 -> 0.885 Inexact Rounded +sqtx4412 squareroot 0.0784 -> 0.28 +sqtx4413 squareroot 0.785 -> 0.886 Inexact Rounded +sqtx4414 squareroot 0.0785 -> 0.280 Inexact Rounded +sqtx4415 squareroot 0.786 -> 0.887 Inexact Rounded +sqtx4416 squareroot 0.0786 -> 0.280 Inexact Rounded +sqtx4417 squareroot 0.787 -> 0.887 Inexact Rounded +sqtx4418 squareroot 0.0787 -> 0.281 Inexact Rounded +sqtx4419 squareroot 0.788 -> 0.888 Inexact Rounded +sqtx4420 squareroot 0.0788 -> 0.281 Inexact Rounded +sqtx4421 squareroot 0.789 -> 0.888 Inexact Rounded +sqtx4422 squareroot 0.0789 -> 0.281 Inexact Rounded +sqtx4423 squareroot 0.791 -> 0.889 Inexact Rounded +sqtx4424 squareroot 0.0791 -> 0.281 Inexact Rounded +sqtx4425 squareroot 0.792 -> 0.890 Inexact Rounded +sqtx4426 squareroot 0.0792 -> 0.281 Inexact Rounded +sqtx4427 squareroot 0.793 -> 0.891 Inexact Rounded +sqtx4428 squareroot 0.0793 -> 0.282 Inexact Rounded +sqtx4429 squareroot 0.794 -> 0.891 Inexact Rounded +sqtx4430 squareroot 0.0794 -> 0.282 Inexact Rounded +sqtx4431 squareroot 0.795 -> 0.892 Inexact Rounded +sqtx4432 squareroot 0.0795 -> 0.282 Inexact Rounded +sqtx4433 squareroot 0.796 -> 0.892 Inexact Rounded +sqtx4434 squareroot 0.0796 -> 0.282 Inexact Rounded +sqtx4435 squareroot 0.797 -> 0.893 Inexact Rounded +sqtx4436 squareroot 0.0797 -> 0.282 Inexact Rounded +sqtx4437 squareroot 0.798 -> 0.893 Inexact Rounded +sqtx4438 squareroot 0.0798 -> 0.282 Inexact Rounded +sqtx4439 squareroot 0.799 -> 0.894 Inexact Rounded +sqtx4440 squareroot 0.0799 -> 0.283 Inexact Rounded +sqtx4441 squareroot 0.801 -> 0.895 Inexact Rounded +sqtx4442 squareroot 0.0801 -> 0.283 Inexact Rounded +sqtx4443 squareroot 0.802 -> 0.896 Inexact Rounded +sqtx4444 squareroot 0.0802 -> 0.283 Inexact Rounded +sqtx4445 squareroot 0.803 -> 0.896 Inexact Rounded +sqtx4446 squareroot 0.0803 -> 0.283 Inexact Rounded +sqtx4447 squareroot 0.804 -> 0.897 Inexact Rounded +sqtx4448 squareroot 0.0804 -> 0.284 Inexact Rounded +sqtx4449 squareroot 0.805 -> 0.897 Inexact Rounded +sqtx4450 squareroot 0.0805 -> 0.284 Inexact Rounded +sqtx4451 squareroot 0.806 -> 0.898 Inexact Rounded +sqtx4452 squareroot 0.0806 -> 0.284 Inexact Rounded +sqtx4453 squareroot 0.807 -> 0.898 Inexact Rounded +sqtx4454 squareroot 0.0807 -> 0.284 Inexact Rounded +sqtx4455 squareroot 0.808 -> 0.899 Inexact Rounded +sqtx4456 squareroot 0.0808 -> 0.284 Inexact Rounded +sqtx4457 squareroot 0.809 -> 0.899 Inexact Rounded +sqtx4458 squareroot 0.0809 -> 0.284 Inexact Rounded +sqtx4459 squareroot 0.811 -> 0.901 Inexact Rounded +sqtx4460 squareroot 0.0811 -> 0.285 Inexact Rounded +sqtx4461 squareroot 0.812 -> 0.901 Inexact Rounded +sqtx4462 squareroot 0.0812 -> 0.285 Inexact Rounded +sqtx4463 squareroot 0.813 -> 0.902 Inexact Rounded +sqtx4464 squareroot 0.0813 -> 0.285 Inexact Rounded +sqtx4465 squareroot 0.814 -> 0.902 Inexact Rounded +sqtx4466 squareroot 0.0814 -> 0.285 Inexact Rounded +sqtx4467 squareroot 0.815 -> 0.903 Inexact Rounded +sqtx4468 squareroot 0.0815 -> 0.285 Inexact Rounded +sqtx4469 squareroot 0.816 -> 0.903 Inexact Rounded +sqtx4470 squareroot 0.0816 -> 0.286 Inexact Rounded +sqtx4471 squareroot 0.817 -> 0.904 Inexact Rounded +sqtx4472 squareroot 0.0817 -> 0.286 Inexact Rounded +sqtx4473 squareroot 0.818 -> 0.904 Inexact Rounded +sqtx4474 squareroot 0.0818 -> 0.286 Inexact Rounded +sqtx4475 squareroot 0.819 -> 0.905 Inexact Rounded +sqtx4476 squareroot 0.0819 -> 0.286 Inexact Rounded +sqtx4477 squareroot 0.821 -> 0.906 Inexact Rounded +sqtx4478 squareroot 0.0821 -> 0.287 Inexact Rounded +sqtx4479 squareroot 0.822 -> 0.907 Inexact Rounded +sqtx4480 squareroot 0.0822 -> 0.287 Inexact Rounded +sqtx4481 squareroot 0.823 -> 0.907 Inexact Rounded +sqtx4482 squareroot 0.0823 -> 0.287 Inexact Rounded +sqtx4483 squareroot 0.824 -> 0.908 Inexact Rounded +sqtx4484 squareroot 0.0824 -> 0.287 Inexact Rounded +sqtx4485 squareroot 0.825 -> 0.908 Inexact Rounded +sqtx4486 squareroot 0.0825 -> 0.287 Inexact Rounded +sqtx4487 squareroot 0.826 -> 0.909 Inexact Rounded +sqtx4488 squareroot 0.0826 -> 0.287 Inexact Rounded +sqtx4489 squareroot 0.827 -> 0.909 Inexact Rounded +sqtx4490 squareroot 0.0827 -> 0.288 Inexact Rounded +sqtx4491 squareroot 0.828 -> 0.910 Inexact Rounded +sqtx4492 squareroot 0.0828 -> 0.288 Inexact Rounded +sqtx4493 squareroot 0.829 -> 0.910 Inexact Rounded +sqtx4494 squareroot 0.0829 -> 0.288 Inexact Rounded +sqtx4495 squareroot 0.831 -> 0.912 Inexact Rounded +sqtx4496 squareroot 0.0831 -> 0.288 Inexact Rounded +sqtx4497 squareroot 0.832 -> 0.912 Inexact Rounded +sqtx4498 squareroot 0.0832 -> 0.288 Inexact Rounded +sqtx4499 squareroot 0.833 -> 0.913 Inexact Rounded +sqtx4500 squareroot 0.0833 -> 0.289 Inexact Rounded +sqtx4501 squareroot 0.834 -> 0.913 Inexact Rounded +sqtx4502 squareroot 0.0834 -> 0.289 Inexact Rounded +sqtx4503 squareroot 0.835 -> 0.914 Inexact Rounded +sqtx4504 squareroot 0.0835 -> 0.289 Inexact Rounded +sqtx4505 squareroot 0.836 -> 0.914 Inexact Rounded +sqtx4506 squareroot 0.0836 -> 0.289 Inexact Rounded +sqtx4507 squareroot 0.837 -> 0.915 Inexact Rounded +sqtx4508 squareroot 0.0837 -> 0.289 Inexact Rounded +sqtx4509 squareroot 0.838 -> 0.915 Inexact Rounded +sqtx4510 squareroot 0.0838 -> 0.289 Inexact Rounded +sqtx4511 squareroot 0.839 -> 0.916 Inexact Rounded +sqtx4512 squareroot 0.0839 -> 0.290 Inexact Rounded +sqtx4513 squareroot 0.841 -> 0.917 Inexact Rounded +sqtx4514 squareroot 0.0841 -> 0.29 +sqtx4515 squareroot 0.842 -> 0.918 Inexact Rounded +sqtx4516 squareroot 0.0842 -> 0.290 Inexact Rounded +sqtx4517 squareroot 0.843 -> 0.918 Inexact Rounded +sqtx4518 squareroot 0.0843 -> 0.290 Inexact Rounded +sqtx4519 squareroot 0.844 -> 0.919 Inexact Rounded +sqtx4520 squareroot 0.0844 -> 0.291 Inexact Rounded +sqtx4521 squareroot 0.845 -> 0.919 Inexact Rounded +sqtx4522 squareroot 0.0845 -> 0.291 Inexact Rounded +sqtx4523 squareroot 0.846 -> 0.920 Inexact Rounded +sqtx4524 squareroot 0.0846 -> 0.291 Inexact Rounded +sqtx4525 squareroot 0.847 -> 0.920 Inexact Rounded +sqtx4526 squareroot 0.0847 -> 0.291 Inexact Rounded +sqtx4527 squareroot 0.848 -> 0.921 Inexact Rounded +sqtx4528 squareroot 0.0848 -> 0.291 Inexact Rounded +sqtx4529 squareroot 0.849 -> 0.921 Inexact Rounded +sqtx4530 squareroot 0.0849 -> 0.291 Inexact Rounded +sqtx4531 squareroot 0.851 -> 0.922 Inexact Rounded +sqtx4532 squareroot 0.0851 -> 0.292 Inexact Rounded +sqtx4533 squareroot 0.852 -> 0.923 Inexact Rounded +sqtx4534 squareroot 0.0852 -> 0.292 Inexact Rounded +sqtx4535 squareroot 0.853 -> 0.924 Inexact Rounded +sqtx4536 squareroot 0.0853 -> 0.292 Inexact Rounded +sqtx4537 squareroot 0.854 -> 0.924 Inexact Rounded +sqtx4538 squareroot 0.0854 -> 0.292 Inexact Rounded +sqtx4539 squareroot 0.855 -> 0.925 Inexact Rounded +sqtx4540 squareroot 0.0855 -> 0.292 Inexact Rounded +sqtx4541 squareroot 0.856 -> 0.925 Inexact Rounded +sqtx4542 squareroot 0.0856 -> 0.293 Inexact Rounded +sqtx4543 squareroot 0.857 -> 0.926 Inexact Rounded +sqtx4544 squareroot 0.0857 -> 0.293 Inexact Rounded +sqtx4545 squareroot 0.858 -> 0.926 Inexact Rounded +sqtx4546 squareroot 0.0858 -> 0.293 Inexact Rounded +sqtx4547 squareroot 0.859 -> 0.927 Inexact Rounded +sqtx4548 squareroot 0.0859 -> 0.293 Inexact Rounded +sqtx4549 squareroot 0.861 -> 0.928 Inexact Rounded +sqtx4550 squareroot 0.0861 -> 0.293 Inexact Rounded +sqtx4551 squareroot 0.862 -> 0.928 Inexact Rounded +sqtx4552 squareroot 0.0862 -> 0.294 Inexact Rounded +sqtx4553 squareroot 0.863 -> 0.929 Inexact Rounded +sqtx4554 squareroot 0.0863 -> 0.294 Inexact Rounded +sqtx4555 squareroot 0.864 -> 0.930 Inexact Rounded +sqtx4556 squareroot 0.0864 -> 0.294 Inexact Rounded +sqtx4557 squareroot 0.865 -> 0.930 Inexact Rounded +sqtx4558 squareroot 0.0865 -> 0.294 Inexact Rounded +sqtx4559 squareroot 0.866 -> 0.931 Inexact Rounded +sqtx4560 squareroot 0.0866 -> 0.294 Inexact Rounded +sqtx4561 squareroot 0.867 -> 0.931 Inexact Rounded +sqtx4562 squareroot 0.0867 -> 0.294 Inexact Rounded +sqtx4563 squareroot 0.868 -> 0.932 Inexact Rounded +sqtx4564 squareroot 0.0868 -> 0.295 Inexact Rounded +sqtx4565 squareroot 0.869 -> 0.932 Inexact Rounded +sqtx4566 squareroot 0.0869 -> 0.295 Inexact Rounded +sqtx4567 squareroot 0.871 -> 0.933 Inexact Rounded +sqtx4568 squareroot 0.0871 -> 0.295 Inexact Rounded +sqtx4569 squareroot 0.872 -> 0.934 Inexact Rounded +sqtx4570 squareroot 0.0872 -> 0.295 Inexact Rounded +sqtx4571 squareroot 0.873 -> 0.934 Inexact Rounded +sqtx4572 squareroot 0.0873 -> 0.295 Inexact Rounded +sqtx4573 squareroot 0.874 -> 0.935 Inexact Rounded +sqtx4574 squareroot 0.0874 -> 0.296 Inexact Rounded +sqtx4575 squareroot 0.875 -> 0.935 Inexact Rounded +sqtx4576 squareroot 0.0875 -> 0.296 Inexact Rounded +sqtx4577 squareroot 0.876 -> 0.936 Inexact Rounded +sqtx4578 squareroot 0.0876 -> 0.296 Inexact Rounded +sqtx4579 squareroot 0.877 -> 0.936 Inexact Rounded +sqtx4580 squareroot 0.0877 -> 0.296 Inexact Rounded +sqtx4581 squareroot 0.878 -> 0.937 Inexact Rounded +sqtx4582 squareroot 0.0878 -> 0.296 Inexact Rounded +sqtx4583 squareroot 0.879 -> 0.938 Inexact Rounded +sqtx4584 squareroot 0.0879 -> 0.296 Inexact Rounded +sqtx4585 squareroot 0.881 -> 0.939 Inexact Rounded +sqtx4586 squareroot 0.0881 -> 0.297 Inexact Rounded +sqtx4587 squareroot 0.882 -> 0.939 Inexact Rounded +sqtx4588 squareroot 0.0882 -> 0.297 Inexact Rounded +sqtx4589 squareroot 0.883 -> 0.940 Inexact Rounded +sqtx4590 squareroot 0.0883 -> 0.297 Inexact Rounded +sqtx4591 squareroot 0.884 -> 0.940 Inexact Rounded +sqtx4592 squareroot 0.0884 -> 0.297 Inexact Rounded +sqtx4593 squareroot 0.885 -> 0.941 Inexact Rounded +sqtx4594 squareroot 0.0885 -> 0.297 Inexact Rounded +sqtx4595 squareroot 0.886 -> 0.941 Inexact Rounded +sqtx4596 squareroot 0.0886 -> 0.298 Inexact Rounded +sqtx4597 squareroot 0.887 -> 0.942 Inexact Rounded +sqtx4598 squareroot 0.0887 -> 0.298 Inexact Rounded +sqtx4599 squareroot 0.888 -> 0.942 Inexact Rounded +sqtx4600 squareroot 0.0888 -> 0.298 Inexact Rounded +sqtx4601 squareroot 0.889 -> 0.943 Inexact Rounded +sqtx4602 squareroot 0.0889 -> 0.298 Inexact Rounded +sqtx4603 squareroot 0.891 -> 0.944 Inexact Rounded +sqtx4604 squareroot 0.0891 -> 0.298 Inexact Rounded +sqtx4605 squareroot 0.892 -> 0.944 Inexact Rounded +sqtx4606 squareroot 0.0892 -> 0.299 Inexact Rounded +sqtx4607 squareroot 0.893 -> 0.945 Inexact Rounded +sqtx4608 squareroot 0.0893 -> 0.299 Inexact Rounded +sqtx4609 squareroot 0.894 -> 0.946 Inexact Rounded +sqtx4610 squareroot 0.0894 -> 0.299 Inexact Rounded +sqtx4611 squareroot 0.895 -> 0.946 Inexact Rounded +sqtx4612 squareroot 0.0895 -> 0.299 Inexact Rounded +sqtx4613 squareroot 0.896 -> 0.947 Inexact Rounded +sqtx4614 squareroot 0.0896 -> 0.299 Inexact Rounded +sqtx4615 squareroot 0.897 -> 0.947 Inexact Rounded +sqtx4616 squareroot 0.0897 -> 0.299 Inexact Rounded +sqtx4617 squareroot 0.898 -> 0.948 Inexact Rounded +sqtx4618 squareroot 0.0898 -> 0.300 Inexact Rounded +sqtx4619 squareroot 0.899 -> 0.948 Inexact Rounded +sqtx4620 squareroot 0.0899 -> 0.300 Inexact Rounded +sqtx4621 squareroot 0.901 -> 0.949 Inexact Rounded +sqtx4622 squareroot 0.0901 -> 0.300 Inexact Rounded +sqtx4623 squareroot 0.902 -> 0.950 Inexact Rounded +sqtx4624 squareroot 0.0902 -> 0.300 Inexact Rounded +sqtx4625 squareroot 0.903 -> 0.950 Inexact Rounded +sqtx4626 squareroot 0.0903 -> 0.300 Inexact Rounded +sqtx4627 squareroot 0.904 -> 0.951 Inexact Rounded +sqtx4628 squareroot 0.0904 -> 0.301 Inexact Rounded +sqtx4629 squareroot 0.905 -> 0.951 Inexact Rounded +sqtx4630 squareroot 0.0905 -> 0.301 Inexact Rounded +sqtx4631 squareroot 0.906 -> 0.952 Inexact Rounded +sqtx4632 squareroot 0.0906 -> 0.301 Inexact Rounded +sqtx4633 squareroot 0.907 -> 0.952 Inexact Rounded +sqtx4634 squareroot 0.0907 -> 0.301 Inexact Rounded +sqtx4635 squareroot 0.908 -> 0.953 Inexact Rounded +sqtx4636 squareroot 0.0908 -> 0.301 Inexact Rounded +sqtx4637 squareroot 0.909 -> 0.953 Inexact Rounded +sqtx4638 squareroot 0.0909 -> 0.301 Inexact Rounded +sqtx4639 squareroot 0.911 -> 0.954 Inexact Rounded +sqtx4640 squareroot 0.0911 -> 0.302 Inexact Rounded +sqtx4641 squareroot 0.912 -> 0.955 Inexact Rounded +sqtx4642 squareroot 0.0912 -> 0.302 Inexact Rounded +sqtx4643 squareroot 0.913 -> 0.956 Inexact Rounded +sqtx4644 squareroot 0.0913 -> 0.302 Inexact Rounded +sqtx4645 squareroot 0.914 -> 0.956 Inexact Rounded +sqtx4646 squareroot 0.0914 -> 0.302 Inexact Rounded +sqtx4647 squareroot 0.915 -> 0.957 Inexact Rounded +sqtx4648 squareroot 0.0915 -> 0.302 Inexact Rounded +sqtx4649 squareroot 0.916 -> 0.957 Inexact Rounded +sqtx4650 squareroot 0.0916 -> 0.303 Inexact Rounded +sqtx4651 squareroot 0.917 -> 0.958 Inexact Rounded +sqtx4652 squareroot 0.0917 -> 0.303 Inexact Rounded +sqtx4653 squareroot 0.918 -> 0.958 Inexact Rounded +sqtx4654 squareroot 0.0918 -> 0.303 Inexact Rounded +sqtx4655 squareroot 0.919 -> 0.959 Inexact Rounded +sqtx4656 squareroot 0.0919 -> 0.303 Inexact Rounded +sqtx4657 squareroot 0.921 -> 0.960 Inexact Rounded +sqtx4658 squareroot 0.0921 -> 0.303 Inexact Rounded +sqtx4659 squareroot 0.922 -> 0.960 Inexact Rounded +sqtx4660 squareroot 0.0922 -> 0.304 Inexact Rounded +sqtx4661 squareroot 0.923 -> 0.961 Inexact Rounded +sqtx4662 squareroot 0.0923 -> 0.304 Inexact Rounded +sqtx4663 squareroot 0.924 -> 0.961 Inexact Rounded +sqtx4664 squareroot 0.0924 -> 0.304 Inexact Rounded +sqtx4665 squareroot 0.925 -> 0.962 Inexact Rounded +sqtx4666 squareroot 0.0925 -> 0.304 Inexact Rounded +sqtx4667 squareroot 0.926 -> 0.962 Inexact Rounded +sqtx4668 squareroot 0.0926 -> 0.304 Inexact Rounded +sqtx4669 squareroot 0.927 -> 0.963 Inexact Rounded +sqtx4670 squareroot 0.0927 -> 0.304 Inexact Rounded +sqtx4671 squareroot 0.928 -> 0.963 Inexact Rounded +sqtx4672 squareroot 0.0928 -> 0.305 Inexact Rounded +sqtx4673 squareroot 0.929 -> 0.964 Inexact Rounded +sqtx4674 squareroot 0.0929 -> 0.305 Inexact Rounded +sqtx4675 squareroot 0.931 -> 0.965 Inexact Rounded +sqtx4676 squareroot 0.0931 -> 0.305 Inexact Rounded +sqtx4677 squareroot 0.932 -> 0.965 Inexact Rounded +sqtx4678 squareroot 0.0932 -> 0.305 Inexact Rounded +sqtx4679 squareroot 0.933 -> 0.966 Inexact Rounded +sqtx4680 squareroot 0.0933 -> 0.305 Inexact Rounded +sqtx4681 squareroot 0.934 -> 0.966 Inexact Rounded +sqtx4682 squareroot 0.0934 -> 0.306 Inexact Rounded +sqtx4683 squareroot 0.935 -> 0.967 Inexact Rounded +sqtx4684 squareroot 0.0935 -> 0.306 Inexact Rounded +sqtx4685 squareroot 0.936 -> 0.967 Inexact Rounded +sqtx4686 squareroot 0.0936 -> 0.306 Inexact Rounded +sqtx4687 squareroot 0.937 -> 0.968 Inexact Rounded +sqtx4688 squareroot 0.0937 -> 0.306 Inexact Rounded +sqtx4689 squareroot 0.938 -> 0.969 Inexact Rounded +sqtx4690 squareroot 0.0938 -> 0.306 Inexact Rounded +sqtx4691 squareroot 0.939 -> 0.969 Inexact Rounded +sqtx4692 squareroot 0.0939 -> 0.306 Inexact Rounded +sqtx4693 squareroot 0.941 -> 0.970 Inexact Rounded +sqtx4694 squareroot 0.0941 -> 0.307 Inexact Rounded +sqtx4695 squareroot 0.942 -> 0.971 Inexact Rounded +sqtx4696 squareroot 0.0942 -> 0.307 Inexact Rounded +sqtx4697 squareroot 0.943 -> 0.971 Inexact Rounded +sqtx4698 squareroot 0.0943 -> 0.307 Inexact Rounded +sqtx4699 squareroot 0.944 -> 0.972 Inexact Rounded +sqtx4700 squareroot 0.0944 -> 0.307 Inexact Rounded +sqtx4701 squareroot 0.945 -> 0.972 Inexact Rounded +sqtx4702 squareroot 0.0945 -> 0.307 Inexact Rounded +sqtx4703 squareroot 0.946 -> 0.973 Inexact Rounded +sqtx4704 squareroot 0.0946 -> 0.308 Inexact Rounded +sqtx4705 squareroot 0.947 -> 0.973 Inexact Rounded +sqtx4706 squareroot 0.0947 -> 0.308 Inexact Rounded +sqtx4707 squareroot 0.948 -> 0.974 Inexact Rounded +sqtx4708 squareroot 0.0948 -> 0.308 Inexact Rounded +sqtx4709 squareroot 0.949 -> 0.974 Inexact Rounded +sqtx4710 squareroot 0.0949 -> 0.308 Inexact Rounded +sqtx4711 squareroot 0.951 -> 0.975 Inexact Rounded +sqtx4712 squareroot 0.0951 -> 0.308 Inexact Rounded +sqtx4713 squareroot 0.952 -> 0.976 Inexact Rounded +sqtx4714 squareroot 0.0952 -> 0.309 Inexact Rounded +sqtx4715 squareroot 0.953 -> 0.976 Inexact Rounded +sqtx4716 squareroot 0.0953 -> 0.309 Inexact Rounded +sqtx4717 squareroot 0.954 -> 0.977 Inexact Rounded +sqtx4718 squareroot 0.0954 -> 0.309 Inexact Rounded +sqtx4719 squareroot 0.955 -> 0.977 Inexact Rounded +sqtx4720 squareroot 0.0955 -> 0.309 Inexact Rounded +sqtx4721 squareroot 0.956 -> 0.978 Inexact Rounded +sqtx4722 squareroot 0.0956 -> 0.309 Inexact Rounded +sqtx4723 squareroot 0.957 -> 0.978 Inexact Rounded +sqtx4724 squareroot 0.0957 -> 0.309 Inexact Rounded +sqtx4725 squareroot 0.958 -> 0.979 Inexact Rounded +sqtx4726 squareroot 0.0958 -> 0.310 Inexact Rounded +sqtx4727 squareroot 0.959 -> 0.979 Inexact Rounded +sqtx4728 squareroot 0.0959 -> 0.310 Inexact Rounded +sqtx4729 squareroot 0.961 -> 0.980 Inexact Rounded +sqtx4730 squareroot 0.0961 -> 0.31 +sqtx4731 squareroot 0.962 -> 0.981 Inexact Rounded +sqtx4732 squareroot 0.0962 -> 0.310 Inexact Rounded +sqtx4733 squareroot 0.963 -> 0.981 Inexact Rounded +sqtx4734 squareroot 0.0963 -> 0.310 Inexact Rounded +sqtx4735 squareroot 0.964 -> 0.982 Inexact Rounded +sqtx4736 squareroot 0.0964 -> 0.310 Inexact Rounded +sqtx4737 squareroot 0.965 -> 0.982 Inexact Rounded +sqtx4738 squareroot 0.0965 -> 0.311 Inexact Rounded +sqtx4739 squareroot 0.966 -> 0.983 Inexact Rounded +sqtx4740 squareroot 0.0966 -> 0.311 Inexact Rounded +sqtx4741 squareroot 0.967 -> 0.983 Inexact Rounded +sqtx4742 squareroot 0.0967 -> 0.311 Inexact Rounded +sqtx4743 squareroot 0.968 -> 0.984 Inexact Rounded +sqtx4744 squareroot 0.0968 -> 0.311 Inexact Rounded +sqtx4745 squareroot 0.969 -> 0.984 Inexact Rounded +sqtx4746 squareroot 0.0969 -> 0.311 Inexact Rounded +sqtx4747 squareroot 0.971 -> 0.985 Inexact Rounded +sqtx4748 squareroot 0.0971 -> 0.312 Inexact Rounded +sqtx4749 squareroot 0.972 -> 0.986 Inexact Rounded +sqtx4750 squareroot 0.0972 -> 0.312 Inexact Rounded +sqtx4751 squareroot 0.973 -> 0.986 Inexact Rounded +sqtx4752 squareroot 0.0973 -> 0.312 Inexact Rounded +sqtx4753 squareroot 0.974 -> 0.987 Inexact Rounded +sqtx4754 squareroot 0.0974 -> 0.312 Inexact Rounded +sqtx4755 squareroot 0.975 -> 0.987 Inexact Rounded +sqtx4756 squareroot 0.0975 -> 0.312 Inexact Rounded +sqtx4757 squareroot 0.976 -> 0.988 Inexact Rounded +sqtx4758 squareroot 0.0976 -> 0.312 Inexact Rounded +sqtx4759 squareroot 0.977 -> 0.988 Inexact Rounded +sqtx4760 squareroot 0.0977 -> 0.313 Inexact Rounded +sqtx4761 squareroot 0.978 -> 0.989 Inexact Rounded +sqtx4762 squareroot 0.0978 -> 0.313 Inexact Rounded +sqtx4763 squareroot 0.979 -> 0.989 Inexact Rounded +sqtx4764 squareroot 0.0979 -> 0.313 Inexact Rounded +sqtx4765 squareroot 0.981 -> 0.990 Inexact Rounded +sqtx4766 squareroot 0.0981 -> 0.313 Inexact Rounded +sqtx4767 squareroot 0.982 -> 0.991 Inexact Rounded +sqtx4768 squareroot 0.0982 -> 0.313 Inexact Rounded +sqtx4769 squareroot 0.983 -> 0.991 Inexact Rounded +sqtx4770 squareroot 0.0983 -> 0.314 Inexact Rounded +sqtx4771 squareroot 0.984 -> 0.992 Inexact Rounded +sqtx4772 squareroot 0.0984 -> 0.314 Inexact Rounded +sqtx4773 squareroot 0.985 -> 0.992 Inexact Rounded +sqtx4774 squareroot 0.0985 -> 0.314 Inexact Rounded +sqtx4775 squareroot 0.986 -> 0.993 Inexact Rounded +sqtx4776 squareroot 0.0986 -> 0.314 Inexact Rounded +sqtx4777 squareroot 0.987 -> 0.993 Inexact Rounded +sqtx4778 squareroot 0.0987 -> 0.314 Inexact Rounded +sqtx4779 squareroot 0.988 -> 0.994 Inexact Rounded +sqtx4780 squareroot 0.0988 -> 0.314 Inexact Rounded +sqtx4781 squareroot 0.989 -> 0.994 Inexact Rounded +sqtx4782 squareroot 0.0989 -> 0.314 Inexact Rounded +sqtx4783 squareroot 0.991 -> 0.995 Inexact Rounded +sqtx4784 squareroot 0.0991 -> 0.315 Inexact Rounded +sqtx4785 squareroot 0.992 -> 0.996 Inexact Rounded +sqtx4786 squareroot 0.0992 -> 0.315 Inexact Rounded +sqtx4787 squareroot 0.993 -> 0.996 Inexact Rounded +sqtx4788 squareroot 0.0993 -> 0.315 Inexact Rounded +sqtx4789 squareroot 0.994 -> 0.997 Inexact Rounded +sqtx4790 squareroot 0.0994 -> 0.315 Inexact Rounded +sqtx4791 squareroot 0.995 -> 0.997 Inexact Rounded +sqtx4792 squareroot 0.0995 -> 0.315 Inexact Rounded +sqtx4793 squareroot 0.996 -> 0.998 Inexact Rounded +sqtx4794 squareroot 0.0996 -> 0.316 Inexact Rounded +sqtx4795 squareroot 0.997 -> 0.998 Inexact Rounded +sqtx4796 squareroot 0.0997 -> 0.316 Inexact Rounded +sqtx4797 squareroot 0.998 -> 0.999 Inexact Rounded +sqtx4798 squareroot 0.0998 -> 0.316 Inexact Rounded +sqtx4799 squareroot 0.999 -> 0.999 Inexact Rounded +sqtx4800 squareroot 0.0999 -> 0.316 Inexact Rounded + +-- A group of precision 4 tests where Hull & Abrham adjustments are +-- needed in some cases (both up and down) [see Hull1985b] +rounding: half_even +maxExponent: 999 +minexponent: -999 +precision: 4 +sqtx5001 squareroot 0.0118 -> 0.1086 Inexact Rounded +sqtx5002 squareroot 0.119 -> 0.3450 Inexact Rounded +sqtx5003 squareroot 0.0119 -> 0.1091 Inexact Rounded +sqtx5004 squareroot 0.121 -> 0.3479 Inexact Rounded +sqtx5005 squareroot 0.0121 -> 0.11 +sqtx5006 squareroot 0.122 -> 0.3493 Inexact Rounded +sqtx5007 squareroot 0.0122 -> 0.1105 Inexact Rounded +sqtx5008 squareroot 0.123 -> 0.3507 Inexact Rounded +sqtx5009 squareroot 0.494 -> 0.7029 Inexact Rounded +sqtx5010 squareroot 0.0669 -> 0.2587 Inexact Rounded +sqtx5011 squareroot 0.9558 -> 0.9777 Inexact Rounded +sqtx5012 squareroot 0.9348 -> 0.9669 Inexact Rounded +sqtx5013 squareroot 0.9345 -> 0.9667 Inexact Rounded +sqtx5014 squareroot 0.09345 -> 0.3057 Inexact Rounded +sqtx5015 squareroot 0.9346 -> 0.9667 Inexact Rounded +sqtx5016 squareroot 0.09346 -> 0.3057 Inexact Rounded +sqtx5017 squareroot 0.9347 -> 0.9668 Inexact Rounded + +-- examples from decArith +precision: 9 +sqtx700 squareroot 0 -> '0' +sqtx701 squareroot -0 -> '-0' +sqtx702 squareroot 0.39 -> 0.624499800 Inexact Rounded +sqtx703 squareroot 100 -> '10' +sqtx704 squareroot 1.00 -> '1.0' +sqtx705 squareroot 7 -> '2.64575131' Inexact Rounded +sqtx706 squareroot 10 -> 3.16227766 Inexact Rounded + +-- some one-offs +precision: 9 +sqtx711 squareroot 0.1 -> 0.316227766 Inexact Rounded +sqtx712 squareroot 0.2 -> 0.447213595 Inexact Rounded +sqtx713 squareroot 0.3 -> 0.547722558 Inexact Rounded +sqtx714 squareroot 0.4 -> 0.632455532 Inexact Rounded +sqtx715 squareroot 0.5 -> 0.707106781 Inexact Rounded +sqtx716 squareroot 0.6 -> 0.774596669 Inexact Rounded +sqtx717 squareroot 0.7 -> 0.836660027 Inexact Rounded +sqtx718 squareroot 0.8 -> 0.894427191 Inexact Rounded +sqtx719 squareroot 0.9 -> 0.948683298 Inexact Rounded +precision: 10 -- note no normalizatoin here +sqtx720 squareroot +0.1 -> 0.3162277660 Inexact Rounded +precision: 11 +sqtx721 squareroot +0.1 -> 0.31622776602 Inexact Rounded +precision: 12 +sqtx722 squareroot +0.1 -> 0.316227766017 Inexact Rounded +precision: 9 +sqtx723 squareroot 0.39 -> 0.624499800 Inexact Rounded +precision: 15 +sqtx724 squareroot 0.39 -> 0.624499799839840 Inexact Rounded + +-- discussion cases +precision: 7 +sqtx731 squareroot 9 -> 3 +sqtx732 squareroot 100 -> 10 +sqtx733 squareroot 123 -> 11.09054 Inexact Rounded +sqtx734 squareroot 144 -> 12 +sqtx735 squareroot 156 -> 12.49000 Inexact Rounded +sqtx736 squareroot 10000 -> 100 + +-- values close to overflow (if there were input rounding) +maxexponent: 99 +minexponent: -99 +precision: 5 +sqtx760 squareroot 9.9997E+99 -> 9.9998E+49 Inexact Rounded +sqtx761 squareroot 9.9998E+99 -> 9.9999E+49 Inexact Rounded +sqtx762 squareroot 9.9999E+99 -> 9.9999E+49 Inexact Rounded +sqtx763 squareroot 9.99991E+99 -> 1.0000E+50 Inexact Rounded +sqtx764 squareroot 9.99994E+99 -> 1.0000E+50 Inexact Rounded +sqtx765 squareroot 9.99995E+99 -> 1.0000E+50 Inexact Rounded +sqtx766 squareroot 9.99999E+99 -> 1.0000E+50 Inexact Rounded +precision: 9 +sqtx770 squareroot 9.9997E+99 -> 9.99985000E+49 Inexact Rounded +sqtx771 squareroot 9.9998E+99 -> 9.99990000E+49 Inexact Rounded +sqtx772 squareroot 9.9999E+99 -> 9.99995000E+49 Inexact Rounded +sqtx773 squareroot 9.99991E+99 -> 9.99995500E+49 Inexact Rounded +sqtx774 squareroot 9.99994E+99 -> 9.99997000E+49 Inexact Rounded +sqtx775 squareroot 9.99995E+99 -> 9.99997500E+49 Inexact Rounded +sqtx776 squareroot 9.99999E+99 -> 9.99999500E+49 Inexact Rounded +precision: 20 +sqtx780 squareroot 9.9997E+99 -> '9.9998499988749831247E+49' Inexact Rounded +sqtx781 squareroot 9.9998E+99 -> '9.9998999994999949999E+49' Inexact Rounded +sqtx782 squareroot 9.9999E+99 -> '9.9999499998749993750E+49' Inexact Rounded +sqtx783 squareroot 9.99991E+99 -> '9.9999549998987495444E+49' Inexact Rounded +sqtx784 squareroot 9.99994E+99 -> '9.9999699999549998650E+49' Inexact Rounded +sqtx785 squareroot 9.99995E+99 -> '9.9999749999687499219E+49' Inexact Rounded +sqtx786 squareroot 9.99999E+99 -> '9.9999949999987499994E+49' Inexact Rounded + +-- subnormals and underflows [these can only result when eMax is < digits+1] +-- Etiny = -(Emax + (precision-1)) +-- start with subnormal operands and normal results +maxexponent: 9 +minexponent: -9 +precision: 9 -- Etiny=-17 +sqtx800 squareroot 1E-17 -> 3.16227766E-9 Inexact Rounded +sqtx801 squareroot 10E-17 -> 1.0E-8 +precision: 10 -- Etiny=-18 +sqtx802 squareroot 10E-18 -> 3.162277660E-9 Inexact Rounded +sqtx803 squareroot 1E-18 -> 1E-9 + +precision: 11 -- Etiny=-19 +sqtx804 squareroot 1E-19 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded +sqtx805 squareroot 10E-19 -> 1.0E-9 +precision: 12 -- Etiny=-20 +sqtx806 squareroot 10E-20 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded +sqtx807 squareroot 1E-20 -> 1E-10 Subnormal -- Exact Subnormal case + +precision: 13 -- Etiny=-21 +sqtx808 squareroot 1E-21 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded +sqtx809 squareroot 10E-21 -> 1.0E-10 Subnormal +precision: 14 -- Etiny=-22 +sqtx810 squareroot 1E-21 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded +sqtx811 squareroot 10E-22 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded +sqtx812 squareroot 1E-22 -> 1E-11 Subnormal -- Exact Subnormal case + + +-- special values +maxexponent: 999 +minexponent: -999 +sqtx820 squareroot Inf -> Infinity +sqtx821 squareroot -Inf -> NaN Invalid_operation +sqtx822 squareroot NaN -> NaN +sqtx823 squareroot sNaN -> NaN Invalid_operation +-- propagating NaNs +sqtx824 squareroot sNaN123 -> NaN123 Invalid_operation +sqtx825 squareroot -sNaN321 -> -NaN321 Invalid_operation +sqtx826 squareroot NaN456 -> NaN456 +sqtx827 squareroot -NaN654 -> -NaN654 +sqtx828 squareroot NaN1 -> NaN1 + +-- Null test +sqtx900 squareroot # -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/subtract.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/subtract.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,863 @@ +------------------------------------------------------------------------ +-- subtract.decTest -- decimal subtraction -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 384 +minexponent: -383 + +-- [first group are 'quick confidence check'] +subx001 subtract 0 0 -> '0' +subx002 subtract 1 1 -> '0' +subx003 subtract 1 2 -> '-1' +subx004 subtract 2 1 -> '1' +subx005 subtract 2 2 -> '0' +subx006 subtract 3 2 -> '1' +subx007 subtract 2 3 -> '-1' + +subx011 subtract -0 0 -> '-0' +subx012 subtract -1 1 -> '-2' +subx013 subtract -1 2 -> '-3' +subx014 subtract -2 1 -> '-3' +subx015 subtract -2 2 -> '-4' +subx016 subtract -3 2 -> '-5' +subx017 subtract -2 3 -> '-5' + +subx021 subtract 0 -0 -> '0' +subx022 subtract 1 -1 -> '2' +subx023 subtract 1 -2 -> '3' +subx024 subtract 2 -1 -> '3' +subx025 subtract 2 -2 -> '4' +subx026 subtract 3 -2 -> '5' +subx027 subtract 2 -3 -> '5' + +subx030 subtract 11 1 -> 10 +subx031 subtract 10 1 -> 9 +subx032 subtract 9 1 -> 8 +subx033 subtract 1 1 -> 0 +subx034 subtract 0 1 -> -1 +subx035 subtract -1 1 -> -2 +subx036 subtract -9 1 -> -10 +subx037 subtract -10 1 -> -11 +subx038 subtract -11 1 -> -12 + +subx040 subtract '5.75' '3.3' -> '2.45' +subx041 subtract '5' '-3' -> '8' +subx042 subtract '-5' '-3' -> '-2' +subx043 subtract '-7' '2.5' -> '-9.5' +subx044 subtract '0.7' '0.3' -> '0.4' +subx045 subtract '1.3' '0.3' -> '1.0' +subx046 subtract '1.25' '1.25' -> '0.00' + +subx050 subtract '1.23456789' '1.00000000' -> '0.23456789' +subx051 subtract '1.23456789' '1.00000089' -> '0.23456700' +subx052 subtract '0.5555555559' '0.0000000001' -> '0.555555556' Inexact Rounded +subx053 subtract '0.5555555559' '0.0000000005' -> '0.555555555' Inexact Rounded +subx054 subtract '0.4444444444' '0.1111111111' -> '0.333333333' Inexact Rounded +subx055 subtract '1.0000000000' '0.00000001' -> '0.999999990' Rounded +subx056 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded +subx057 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded + +subx060 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded +subx061 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded +subx062 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded +subx063 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded +subx064 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded + -- symmetry: +subx065 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded +subx066 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded +subx067 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded +subx068 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded +subx069 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded + + -- change precision +subx080 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded +precision: 6 +subx081 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded +precision: 9 + + -- some of the next group are really constructor tests +subx090 subtract '00.0' '0.0' -> '0.0' +subx091 subtract '00.0' '0.00' -> '0.00' +subx092 subtract '0.00' '00.0' -> '0.00' +subx093 subtract '00.0' '0.00' -> '0.00' +subx094 subtract '0.00' '00.0' -> '0.00' +subx095 subtract '3' '.3' -> '2.7' +subx096 subtract '3.' '.3' -> '2.7' +subx097 subtract '3.0' '.3' -> '2.7' +subx098 subtract '3.00' '.3' -> '2.70' +subx099 subtract '3' '3' -> '0' +subx100 subtract '3' '+3' -> '0' +subx101 subtract '3' '-3' -> '6' +subx102 subtract '3' '0.3' -> '2.7' +subx103 subtract '3.' '0.3' -> '2.7' +subx104 subtract '3.0' '0.3' -> '2.7' +subx105 subtract '3.00' '0.3' -> '2.70' +subx106 subtract '3' '3.0' -> '0.0' +subx107 subtract '3' '+3.0' -> '0.0' +subx108 subtract '3' '-3.0' -> '6.0' + +-- the above all from add; massaged and extended. Now some new ones... +-- [particularly important for comparisons] +-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7 +-- with input rounding. +subx120 subtract '10.23456784' '10.23456789' -> '-5E-8' +subx121 subtract '10.23456785' '10.23456789' -> '-4E-8' +subx122 subtract '10.23456786' '10.23456789' -> '-3E-8' +subx123 subtract '10.23456787' '10.23456789' -> '-2E-8' +subx124 subtract '10.23456788' '10.23456789' -> '-1E-8' +subx125 subtract '10.23456789' '10.23456789' -> '0E-8' +subx126 subtract '10.23456790' '10.23456789' -> '1E-8' +subx127 subtract '10.23456791' '10.23456789' -> '2E-8' +subx128 subtract '10.23456792' '10.23456789' -> '3E-8' +subx129 subtract '10.23456793' '10.23456789' -> '4E-8' +subx130 subtract '10.23456794' '10.23456789' -> '5E-8' +subx131 subtract '10.23456781' '10.23456786' -> '-5E-8' +subx132 subtract '10.23456782' '10.23456786' -> '-4E-8' +subx133 subtract '10.23456783' '10.23456786' -> '-3E-8' +subx134 subtract '10.23456784' '10.23456786' -> '-2E-8' +subx135 subtract '10.23456785' '10.23456786' -> '-1E-8' +subx136 subtract '10.23456786' '10.23456786' -> '0E-8' +subx137 subtract '10.23456787' '10.23456786' -> '1E-8' +subx138 subtract '10.23456788' '10.23456786' -> '2E-8' +subx139 subtract '10.23456789' '10.23456786' -> '3E-8' +subx140 subtract '10.23456790' '10.23456786' -> '4E-8' +subx141 subtract '10.23456791' '10.23456786' -> '5E-8' +subx142 subtract '1' '0.999999999' -> '1E-9' +subx143 subtract '0.999999999' '1' -> '-1E-9' +subx144 subtract '-10.23456780' '-10.23456786' -> '6E-8' +subx145 subtract '-10.23456790' '-10.23456786' -> '-4E-8' +subx146 subtract '-10.23456791' '-10.23456786' -> '-5E-8' + +precision: 3 +subx150 subtract '12345678900000' '9999999999999' -> 2.35E+12 Inexact Rounded +subx151 subtract '9999999999999' '12345678900000' -> -2.35E+12 Inexact Rounded +precision: 6 +subx152 subtract '12345678900000' '9999999999999' -> 2.34568E+12 Inexact Rounded +subx153 subtract '9999999999999' '12345678900000' -> -2.34568E+12 Inexact Rounded +precision: 9 +subx154 subtract '12345678900000' '9999999999999' -> 2.34567890E+12 Inexact Rounded +subx155 subtract '9999999999999' '12345678900000' -> -2.34567890E+12 Inexact Rounded +precision: 12 +subx156 subtract '12345678900000' '9999999999999' -> 2.34567890000E+12 Inexact Rounded +subx157 subtract '9999999999999' '12345678900000' -> -2.34567890000E+12 Inexact Rounded +precision: 15 +subx158 subtract '12345678900000' '9999999999999' -> 2345678900001 +subx159 subtract '9999999999999' '12345678900000' -> -2345678900001 +precision: 9 + +-- additional scaled arithmetic tests [0.97 problem] +subx160 subtract '0' '.1' -> '-0.1' +subx161 subtract '00' '.97983' -> '-0.97983' +subx162 subtract '0' '.9' -> '-0.9' +subx163 subtract '0' '0.102' -> '-0.102' +subx164 subtract '0' '.4' -> '-0.4' +subx165 subtract '0' '.307' -> '-0.307' +subx166 subtract '0' '.43822' -> '-0.43822' +subx167 subtract '0' '.911' -> '-0.911' +subx168 subtract '.0' '.02' -> '-0.02' +subx169 subtract '00' '.392' -> '-0.392' +subx170 subtract '0' '.26' -> '-0.26' +subx171 subtract '0' '0.51' -> '-0.51' +subx172 subtract '0' '.2234' -> '-0.2234' +subx173 subtract '0' '.2' -> '-0.2' +subx174 subtract '.0' '.0008' -> '-0.0008' +-- 0. on left +subx180 subtract '0.0' '-.1' -> '0.1' +subx181 subtract '0.00' '-.97983' -> '0.97983' +subx182 subtract '0.0' '-.9' -> '0.9' +subx183 subtract '0.0' '-0.102' -> '0.102' +subx184 subtract '0.0' '-.4' -> '0.4' +subx185 subtract '0.0' '-.307' -> '0.307' +subx186 subtract '0.0' '-.43822' -> '0.43822' +subx187 subtract '0.0' '-.911' -> '0.911' +subx188 subtract '0.0' '-.02' -> '0.02' +subx189 subtract '0.00' '-.392' -> '0.392' +subx190 subtract '0.0' '-.26' -> '0.26' +subx191 subtract '0.0' '-0.51' -> '0.51' +subx192 subtract '0.0' '-.2234' -> '0.2234' +subx193 subtract '0.0' '-.2' -> '0.2' +subx194 subtract '0.0' '-.0008' -> '0.0008' +-- negatives of same +subx200 subtract '0' '-.1' -> '0.1' +subx201 subtract '00' '-.97983' -> '0.97983' +subx202 subtract '0' '-.9' -> '0.9' +subx203 subtract '0' '-0.102' -> '0.102' +subx204 subtract '0' '-.4' -> '0.4' +subx205 subtract '0' '-.307' -> '0.307' +subx206 subtract '0' '-.43822' -> '0.43822' +subx207 subtract '0' '-.911' -> '0.911' +subx208 subtract '.0' '-.02' -> '0.02' +subx209 subtract '00' '-.392' -> '0.392' +subx210 subtract '0' '-.26' -> '0.26' +subx211 subtract '0' '-0.51' -> '0.51' +subx212 subtract '0' '-.2234' -> '0.2234' +subx213 subtract '0' '-.2' -> '0.2' +subx214 subtract '.0' '-.0008' -> '0.0008' + +-- more fixed, LHS swaps [really the same as testcases under add] +subx220 subtract '-56267E-12' 0 -> '-5.6267E-8' +subx221 subtract '-56267E-11' 0 -> '-5.6267E-7' +subx222 subtract '-56267E-10' 0 -> '-0.0000056267' +subx223 subtract '-56267E-9' 0 -> '-0.000056267' +subx224 subtract '-56267E-8' 0 -> '-0.00056267' +subx225 subtract '-56267E-7' 0 -> '-0.0056267' +subx226 subtract '-56267E-6' 0 -> '-0.056267' +subx227 subtract '-56267E-5' 0 -> '-0.56267' +subx228 subtract '-56267E-2' 0 -> '-562.67' +subx229 subtract '-56267E-1' 0 -> '-5626.7' +subx230 subtract '-56267E-0' 0 -> '-56267' +-- symmetry ... +subx240 subtract 0 '-56267E-12' -> '5.6267E-8' +subx241 subtract 0 '-56267E-11' -> '5.6267E-7' +subx242 subtract 0 '-56267E-10' -> '0.0000056267' +subx243 subtract 0 '-56267E-9' -> '0.000056267' +subx244 subtract 0 '-56267E-8' -> '0.00056267' +subx245 subtract 0 '-56267E-7' -> '0.0056267' +subx246 subtract 0 '-56267E-6' -> '0.056267' +subx247 subtract 0 '-56267E-5' -> '0.56267' +subx248 subtract 0 '-56267E-2' -> '562.67' +subx249 subtract 0 '-56267E-1' -> '5626.7' +subx250 subtract 0 '-56267E-0' -> '56267' + +-- now some more from the 'new' add +precision: 9 +subx301 subtract '1.23456789' '1.00000000' -> '0.23456789' +subx302 subtract '1.23456789' '1.00000011' -> '0.23456778' + +subx311 subtract '0.4444444444' '0.5555555555' -> '-0.111111111' Inexact Rounded +subx312 subtract '0.4444444440' '0.5555555555' -> '-0.111111112' Inexact Rounded +subx313 subtract '0.4444444444' '0.5555555550' -> '-0.111111111' Inexact Rounded +subx314 subtract '0.44444444449' '0' -> '0.444444444' Inexact Rounded +subx315 subtract '0.444444444499' '0' -> '0.444444444' Inexact Rounded +subx316 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded +subx317 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded +subx318 subtract '0.4444444445001' '0' -> '0.444444445' Inexact Rounded +subx319 subtract '0.444444444501' '0' -> '0.444444445' Inexact Rounded +subx320 subtract '0.44444444451' '0' -> '0.444444445' Inexact Rounded + +-- some carrying effects +subx321 subtract '0.9998' '0.0000' -> '0.9998' +subx322 subtract '0.9998' '0.0001' -> '0.9997' +subx323 subtract '0.9998' '0.0002' -> '0.9996' +subx324 subtract '0.9998' '0.0003' -> '0.9995' +subx325 subtract '0.9998' '-0.0000' -> '0.9998' +subx326 subtract '0.9998' '-0.0001' -> '0.9999' +subx327 subtract '0.9998' '-0.0002' -> '1.0000' +subx328 subtract '0.9998' '-0.0003' -> '1.0001' + +subx330 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded +subx331 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded +subx332 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded +subx333 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded +subx334 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded +subx335 subtract '7000000' '10000e+9' -> '-9.99999300E+12' Rounded +-- symmetry: +subx340 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded +subx341 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded +subx342 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded +subx343 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded +subx344 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded +subx345 subtract '10000e+9' '7000000' -> '9.99999300E+12' Rounded + +-- same, higher precision +precision: 15 +subx346 subtract '10000e+9' '7' -> '9999999999993' +subx347 subtract '10000e+9' '70' -> '9999999999930' +subx348 subtract '10000e+9' '700' -> '9999999999300' +subx349 subtract '10000e+9' '7000' -> '9999999993000' +subx350 subtract '10000e+9' '70000' -> '9999999930000' +subx351 subtract '10000e+9' '700000' -> '9999999300000' +subx352 subtract '7' '10000e+9' -> '-9999999999993' +subx353 subtract '70' '10000e+9' -> '-9999999999930' +subx354 subtract '700' '10000e+9' -> '-9999999999300' +subx355 subtract '7000' '10000e+9' -> '-9999999993000' +subx356 subtract '70000' '10000e+9' -> '-9999999930000' +subx357 subtract '700000' '10000e+9' -> '-9999999300000' + +-- zero preservation +precision: 6 +subx360 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded +subx361 subtract 1 '0.0001' -> '0.9999' +subx362 subtract 1 '0.00001' -> '0.99999' +subx363 subtract 1 '0.000001' -> '0.999999' +subx364 subtract 1 '0.0000001' -> '1.00000' Inexact Rounded +subx365 subtract 1 '0.00000001' -> '1.00000' Inexact Rounded + +-- some funny zeros [in case of bad signum] +subx370 subtract 1 0 -> 1 +subx371 subtract 1 0. -> 1 +subx372 subtract 1 .0 -> 1.0 +subx373 subtract 1 0.0 -> 1.0 +subx374 subtract 0 1 -> -1 +subx375 subtract 0. 1 -> -1 +subx376 subtract .0 1 -> -1.0 +subx377 subtract 0.0 1 -> -1.0 + +precision: 9 + +-- leading 0 digit before round +subx910 subtract -103519362 -51897955.3 -> -51621406.7 +subx911 subtract 159579.444 89827.5229 -> 69751.9211 + +subx920 subtract 333.123456 33.1234566 -> 299.999999 Inexact Rounded +subx921 subtract 333.123456 33.1234565 -> 300.000000 Inexact Rounded +subx922 subtract 133.123456 33.1234565 -> 99.9999995 +subx923 subtract 133.123456 33.1234564 -> 99.9999996 +subx924 subtract 133.123456 33.1234540 -> 100.000002 Rounded +subx925 subtract 133.123456 43.1234560 -> 90.0000000 +subx926 subtract 133.123456 43.1234561 -> 89.9999999 +subx927 subtract 133.123456 43.1234566 -> 89.9999994 +subx928 subtract 101.123456 91.1234566 -> 9.9999994 +subx929 subtract 101.123456 99.1234566 -> 1.9999994 + +-- more of the same; probe for cluster boundary problems +precision: 1 +subx930 subtract 11 2 -> 9 +precision: 2 +subx932 subtract 101 2 -> 99 +precision: 3 +subx934 subtract 101 2.1 -> 98.9 +subx935 subtract 101 92.01 -> 8.99 +precision: 4 +subx936 subtract 101 2.01 -> 98.99 +subx937 subtract 101 92.01 -> 8.99 +subx938 subtract 101 92.006 -> 8.994 +precision: 5 +subx939 subtract 101 2.001 -> 98.999 +subx940 subtract 101 92.001 -> 8.999 +subx941 subtract 101 92.0006 -> 8.9994 +precision: 6 +subx942 subtract 101 2.0001 -> 98.9999 +subx943 subtract 101 92.0001 -> 8.9999 +subx944 subtract 101 92.00006 -> 8.99994 +precision: 7 +subx945 subtract 101 2.00001 -> 98.99999 +subx946 subtract 101 92.00001 -> 8.99999 +subx947 subtract 101 92.000006 -> 8.999994 +precision: 8 +subx948 subtract 101 2.000001 -> 98.999999 +subx949 subtract 101 92.000001 -> 8.999999 +subx950 subtract 101 92.0000006 -> 8.9999994 +precision: 9 +subx951 subtract 101 2.0000001 -> 98.9999999 +subx952 subtract 101 92.0000001 -> 8.9999999 +subx953 subtract 101 92.00000006 -> 8.99999994 + +precision: 9 + +-- more LHS swaps [were fixed] +subx390 subtract '-56267E-10' 0 -> '-0.0000056267' +subx391 subtract '-56267E-6' 0 -> '-0.056267' +subx392 subtract '-56267E-5' 0 -> '-0.56267' +subx393 subtract '-56267E-4' 0 -> '-5.6267' +subx394 subtract '-56267E-3' 0 -> '-56.267' +subx395 subtract '-56267E-2' 0 -> '-562.67' +subx396 subtract '-56267E-1' 0 -> '-5626.7' +subx397 subtract '-56267E-0' 0 -> '-56267' +subx398 subtract '-5E-10' 0 -> '-5E-10' +subx399 subtract '-5E-7' 0 -> '-5E-7' +subx400 subtract '-5E-6' 0 -> '-0.000005' +subx401 subtract '-5E-5' 0 -> '-0.00005' +subx402 subtract '-5E-4' 0 -> '-0.0005' +subx403 subtract '-5E-1' 0 -> '-0.5' +subx404 subtract '-5E0' 0 -> '-5' +subx405 subtract '-5E1' 0 -> '-50' +subx406 subtract '-5E5' 0 -> '-500000' +subx407 subtract '-5E8' 0 -> '-500000000' +subx408 subtract '-5E9' 0 -> '-5.00000000E+9' Rounded +subx409 subtract '-5E10' 0 -> '-5.00000000E+10' Rounded +subx410 subtract '-5E11' 0 -> '-5.00000000E+11' Rounded +subx411 subtract '-5E100' 0 -> '-5.00000000E+100' Rounded + +-- more RHS swaps [were fixed] +subx420 subtract 0 '-56267E-10' -> '0.0000056267' +subx421 subtract 0 '-56267E-6' -> '0.056267' +subx422 subtract 0 '-56267E-5' -> '0.56267' +subx423 subtract 0 '-56267E-4' -> '5.6267' +subx424 subtract 0 '-56267E-3' -> '56.267' +subx425 subtract 0 '-56267E-2' -> '562.67' +subx426 subtract 0 '-56267E-1' -> '5626.7' +subx427 subtract 0 '-56267E-0' -> '56267' +subx428 subtract 0 '-5E-10' -> '5E-10' +subx429 subtract 0 '-5E-7' -> '5E-7' +subx430 subtract 0 '-5E-6' -> '0.000005' +subx431 subtract 0 '-5E-5' -> '0.00005' +subx432 subtract 0 '-5E-4' -> '0.0005' +subx433 subtract 0 '-5E-1' -> '0.5' +subx434 subtract 0 '-5E0' -> '5' +subx435 subtract 0 '-5E1' -> '50' +subx436 subtract 0 '-5E5' -> '500000' +subx437 subtract 0 '-5E8' -> '500000000' +subx438 subtract 0 '-5E9' -> '5.00000000E+9' Rounded +subx439 subtract 0 '-5E10' -> '5.00000000E+10' Rounded +subx440 subtract 0 '-5E11' -> '5.00000000E+11' Rounded +subx441 subtract 0 '-5E100' -> '5.00000000E+100' Rounded + + +-- try borderline precision, with carries, etc. +precision: 15 +subx461 subtract '1E+12' '1' -> '999999999999' +subx462 subtract '1E+12' '-1.11' -> '1000000000001.11' +subx463 subtract '1.11' '-1E+12' -> '1000000000001.11' +subx464 subtract '-1' '-1E+12' -> '999999999999' +subx465 subtract '7E+12' '1' -> '6999999999999' +subx466 subtract '7E+12' '-1.11' -> '7000000000001.11' +subx467 subtract '1.11' '-7E+12' -> '7000000000001.11' +subx468 subtract '-1' '-7E+12' -> '6999999999999' + +-- 123456789012345 123456789012345 1 23456789012345 +subx470 subtract '0.444444444444444' '-0.555555555555563' -> '1.00000000000001' Inexact Rounded +subx471 subtract '0.444444444444444' '-0.555555555555562' -> '1.00000000000001' Inexact Rounded +subx472 subtract '0.444444444444444' '-0.555555555555561' -> '1.00000000000001' Inexact Rounded +subx473 subtract '0.444444444444444' '-0.555555555555560' -> '1.00000000000000' Inexact Rounded +subx474 subtract '0.444444444444444' '-0.555555555555559' -> '1.00000000000000' Inexact Rounded +subx475 subtract '0.444444444444444' '-0.555555555555558' -> '1.00000000000000' Inexact Rounded +subx476 subtract '0.444444444444444' '-0.555555555555557' -> '1.00000000000000' Inexact Rounded +subx477 subtract '0.444444444444444' '-0.555555555555556' -> '1.00000000000000' Rounded +subx478 subtract '0.444444444444444' '-0.555555555555555' -> '0.999999999999999' +subx479 subtract '0.444444444444444' '-0.555555555555554' -> '0.999999999999998' +subx480 subtract '0.444444444444444' '-0.555555555555553' -> '0.999999999999997' +subx481 subtract '0.444444444444444' '-0.555555555555552' -> '0.999999999999996' +subx482 subtract '0.444444444444444' '-0.555555555555551' -> '0.999999999999995' +subx483 subtract '0.444444444444444' '-0.555555555555550' -> '0.999999999999994' + +-- and some more, including residue effects and different roundings +precision: 9 +rounding: half_up +subx500 subtract '123456789' 0 -> '123456789' +subx501 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded +subx502 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded +subx503 subtract '123456789' 0.1 -> '123456789' Inexact Rounded +subx504 subtract '123456789' 0.4 -> '123456789' Inexact Rounded +subx505 subtract '123456789' 0.49 -> '123456789' Inexact Rounded +subx506 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded +subx507 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded +subx508 subtract '123456789' 0.5 -> '123456789' Inexact Rounded +subx509 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded +subx510 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded +subx511 subtract '123456789' 0.51 -> '123456788' Inexact Rounded +subx512 subtract '123456789' 0.6 -> '123456788' Inexact Rounded +subx513 subtract '123456789' 0.9 -> '123456788' Inexact Rounded +subx514 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded +subx515 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded +subx516 subtract '123456789' 1 -> '123456788' +subx517 subtract '123456789' 1.000000001 -> '123456788' Inexact Rounded +subx518 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded +subx519 subtract '123456789' 1.1 -> '123456788' Inexact Rounded + +rounding: half_even +subx520 subtract '123456789' 0 -> '123456789' +subx521 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded +subx522 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded +subx523 subtract '123456789' 0.1 -> '123456789' Inexact Rounded +subx524 subtract '123456789' 0.4 -> '123456789' Inexact Rounded +subx525 subtract '123456789' 0.49 -> '123456789' Inexact Rounded +subx526 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded +subx527 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded +subx528 subtract '123456789' 0.5 -> '123456788' Inexact Rounded +subx529 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded +subx530 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded +subx531 subtract '123456789' 0.51 -> '123456788' Inexact Rounded +subx532 subtract '123456789' 0.6 -> '123456788' Inexact Rounded +subx533 subtract '123456789' 0.9 -> '123456788' Inexact Rounded +subx534 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded +subx535 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded +subx536 subtract '123456789' 1 -> '123456788' +subx537 subtract '123456789' 1.00000001 -> '123456788' Inexact Rounded +subx538 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded +subx539 subtract '123456789' 1.1 -> '123456788' Inexact Rounded +-- critical few with even bottom digit... +subx540 subtract '123456788' 0.499999999 -> '123456788' Inexact Rounded +subx541 subtract '123456788' 0.5 -> '123456788' Inexact Rounded +subx542 subtract '123456788' 0.500000001 -> '123456787' Inexact Rounded + +rounding: down +subx550 subtract '123456789' 0 -> '123456789' +subx551 subtract '123456789' 0.000000001 -> '123456788' Inexact Rounded +subx552 subtract '123456789' 0.000001 -> '123456788' Inexact Rounded +subx553 subtract '123456789' 0.1 -> '123456788' Inexact Rounded +subx554 subtract '123456789' 0.4 -> '123456788' Inexact Rounded +subx555 subtract '123456789' 0.49 -> '123456788' Inexact Rounded +subx556 subtract '123456789' 0.499999 -> '123456788' Inexact Rounded +subx557 subtract '123456789' 0.499999999 -> '123456788' Inexact Rounded +subx558 subtract '123456789' 0.5 -> '123456788' Inexact Rounded +subx559 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded +subx560 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded +subx561 subtract '123456789' 0.51 -> '123456788' Inexact Rounded +subx562 subtract '123456789' 0.6 -> '123456788' Inexact Rounded +subx563 subtract '123456789' 0.9 -> '123456788' Inexact Rounded +subx564 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded +subx565 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded +subx566 subtract '123456789' 1 -> '123456788' +subx567 subtract '123456789' 1.00000001 -> '123456787' Inexact Rounded +subx568 subtract '123456789' 1.00001 -> '123456787' Inexact Rounded +subx569 subtract '123456789' 1.1 -> '123456787' Inexact Rounded + +-- symmetry... +rounding: half_up +subx600 subtract 0 '123456789' -> '-123456789' +subx601 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded +subx602 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded +subx603 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded +subx604 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded +subx605 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded +subx606 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded +subx607 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded +subx608 subtract 0.5 '123456789' -> '-123456789' Inexact Rounded +subx609 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded +subx610 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded +subx611 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded +subx612 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded +subx613 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded +subx614 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded +subx615 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded +subx616 subtract 1 '123456789' -> '-123456788' +subx617 subtract 1.000000001 '123456789' -> '-123456788' Inexact Rounded +subx618 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded +subx619 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded + +rounding: half_even +subx620 subtract 0 '123456789' -> '-123456789' +subx621 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded +subx622 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded +subx623 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded +subx624 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded +subx625 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded +subx626 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded +subx627 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded +subx628 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded +subx629 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded +subx630 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded +subx631 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded +subx632 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded +subx633 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded +subx634 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded +subx635 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded +subx636 subtract 1 '123456789' -> '-123456788' +subx637 subtract 1.00000001 '123456789' -> '-123456788' Inexact Rounded +subx638 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded +subx639 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded +-- critical few with even bottom digit... +subx640 subtract 0.499999999 '123456788' -> '-123456788' Inexact Rounded +subx641 subtract 0.5 '123456788' -> '-123456788' Inexact Rounded +subx642 subtract 0.500000001 '123456788' -> '-123456787' Inexact Rounded + +rounding: down +subx650 subtract 0 '123456789' -> '-123456789' +subx651 subtract 0.000000001 '123456789' -> '-123456788' Inexact Rounded +subx652 subtract 0.000001 '123456789' -> '-123456788' Inexact Rounded +subx653 subtract 0.1 '123456789' -> '-123456788' Inexact Rounded +subx654 subtract 0.4 '123456789' -> '-123456788' Inexact Rounded +subx655 subtract 0.49 '123456789' -> '-123456788' Inexact Rounded +subx656 subtract 0.499999 '123456789' -> '-123456788' Inexact Rounded +subx657 subtract 0.499999999 '123456789' -> '-123456788' Inexact Rounded +subx658 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded +subx659 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded +subx660 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded +subx661 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded +subx662 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded +subx663 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded +subx664 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded +subx665 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded +subx666 subtract 1 '123456789' -> '-123456788' +subx667 subtract 1.00000001 '123456789' -> '-123456787' Inexact Rounded +subx668 subtract 1.00001 '123456789' -> '-123456787' Inexact Rounded +subx669 subtract 1.1 '123456789' -> '-123456787' Inexact Rounded + + +-- lots of leading zeros in intermediate result, and showing effects of +-- input rounding would have affected the following +precision: 9 +rounding: half_up +subx670 subtract '123456789' '123456788.1' -> 0.9 +subx671 subtract '123456789' '123456788.9' -> 0.1 +subx672 subtract '123456789' '123456789.1' -> -0.1 +subx673 subtract '123456789' '123456789.5' -> -0.5 +subx674 subtract '123456789' '123456789.9' -> -0.9 + +rounding: half_even +subx680 subtract '123456789' '123456788.1' -> 0.9 +subx681 subtract '123456789' '123456788.9' -> 0.1 +subx682 subtract '123456789' '123456789.1' -> -0.1 +subx683 subtract '123456789' '123456789.5' -> -0.5 +subx684 subtract '123456789' '123456789.9' -> -0.9 + +subx685 subtract '123456788' '123456787.1' -> 0.9 +subx686 subtract '123456788' '123456787.9' -> 0.1 +subx687 subtract '123456788' '123456788.1' -> -0.1 +subx688 subtract '123456788' '123456788.5' -> -0.5 +subx689 subtract '123456788' '123456788.9' -> -0.9 + +rounding: down +subx690 subtract '123456789' '123456788.1' -> 0.9 +subx691 subtract '123456789' '123456788.9' -> 0.1 +subx692 subtract '123456789' '123456789.1' -> -0.1 +subx693 subtract '123456789' '123456789.5' -> -0.5 +subx694 subtract '123456789' '123456789.9' -> -0.9 + +-- input preparation tests +rounding: half_up +precision: 3 + +subx700 subtract '12345678900000' -9999999999999 -> '2.23E+13' Inexact Rounded +subx701 subtract '9999999999999' -12345678900000 -> '2.23E+13' Inexact Rounded +subx702 subtract '12E+3' '-3456' -> '1.55E+4' Inexact Rounded +subx703 subtract '12E+3' '-3446' -> '1.54E+4' Inexact Rounded +subx704 subtract '12E+3' '-3454' -> '1.55E+4' Inexact Rounded +subx705 subtract '12E+3' '-3444' -> '1.54E+4' Inexact Rounded + +subx706 subtract '3456' '-12E+3' -> '1.55E+4' Inexact Rounded +subx707 subtract '3446' '-12E+3' -> '1.54E+4' Inexact Rounded +subx708 subtract '3454' '-12E+3' -> '1.55E+4' Inexact Rounded +subx709 subtract '3444' '-12E+3' -> '1.54E+4' Inexact Rounded + +-- overflow and underflow tests [subnormals now possible] +maxexponent: 999999999 +minexponent: -999999999 +precision: 9 +rounding: down +subx710 subtract 1E+999999999 -9E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded +subx711 subtract 9E+999999999 -1E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded +rounding: half_up +subx712 subtract 1E+999999999 -9E+999999999 -> Infinity Overflow Inexact Rounded +subx713 subtract 9E+999999999 -1E+999999999 -> Infinity Overflow Inexact Rounded +subx714 subtract -1.1E-999999999 -1E-999999999 -> -1E-1000000000 Subnormal +subx715 subtract 1E-999999999 +1.1e-999999999 -> -1E-1000000000 Subnormal +subx716 subtract -1E+999999999 +9E+999999999 -> -Infinity Overflow Inexact Rounded +subx717 subtract -9E+999999999 +1E+999999999 -> -Infinity Overflow Inexact Rounded +subx718 subtract +1.1E-999999999 +1E-999999999 -> 1E-1000000000 Subnormal +subx719 subtract -1E-999999999 -1.1e-999999999 -> 1E-1000000000 Subnormal + +precision: 3 +subx720 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded +subx721 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded +subx722 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded +subx723 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded +subx724 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded +subx725 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded +subx726 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded +subx727 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded + +-- [more below] + +-- long operand checks +maxexponent: 999 +minexponent: -999 +precision: 9 +sub731 subtract 12345678000 0 -> 1.23456780E+10 Rounded +sub732 subtract 0 12345678000 -> -1.23456780E+10 Rounded +sub733 subtract 1234567800 0 -> 1.23456780E+9 Rounded +sub734 subtract 0 1234567800 -> -1.23456780E+9 Rounded +sub735 subtract 1234567890 0 -> 1.23456789E+9 Rounded +sub736 subtract 0 1234567890 -> -1.23456789E+9 Rounded +sub737 subtract 1234567891 0 -> 1.23456789E+9 Inexact Rounded +sub738 subtract 0 1234567891 -> -1.23456789E+9 Inexact Rounded +sub739 subtract 12345678901 0 -> 1.23456789E+10 Inexact Rounded +sub740 subtract 0 12345678901 -> -1.23456789E+10 Inexact Rounded +sub741 subtract 1234567896 0 -> 1.23456790E+9 Inexact Rounded +sub742 subtract 0 1234567896 -> -1.23456790E+9 Inexact Rounded + +precision: 15 +sub751 subtract 12345678000 0 -> 12345678000 +sub752 subtract 0 12345678000 -> -12345678000 +sub753 subtract 1234567800 0 -> 1234567800 +sub754 subtract 0 1234567800 -> -1234567800 +sub755 subtract 1234567890 0 -> 1234567890 +sub756 subtract 0 1234567890 -> -1234567890 +sub757 subtract 1234567891 0 -> 1234567891 +sub758 subtract 0 1234567891 -> -1234567891 +sub759 subtract 12345678901 0 -> 12345678901 +sub760 subtract 0 12345678901 -> -12345678901 +sub761 subtract 1234567896 0 -> 1234567896 +sub762 subtract 0 1234567896 -> -1234567896 + +-- Specials +subx780 subtract -Inf Inf -> -Infinity +subx781 subtract -Inf 1000 -> -Infinity +subx782 subtract -Inf 1 -> -Infinity +subx783 subtract -Inf -0 -> -Infinity +subx784 subtract -Inf -1 -> -Infinity +subx785 subtract -Inf -1000 -> -Infinity +subx787 subtract -1000 Inf -> -Infinity +subx788 subtract -Inf Inf -> -Infinity +subx789 subtract -1 Inf -> -Infinity +subx790 subtract 0 Inf -> -Infinity +subx791 subtract 1 Inf -> -Infinity +subx792 subtract 1000 Inf -> -Infinity + +subx800 subtract Inf Inf -> NaN Invalid_operation +subx801 subtract Inf 1000 -> Infinity +subx802 subtract Inf 1 -> Infinity +subx803 subtract Inf 0 -> Infinity +subx804 subtract Inf -0 -> Infinity +subx805 subtract Inf -1 -> Infinity +subx806 subtract Inf -1000 -> Infinity +subx807 subtract Inf -Inf -> Infinity +subx808 subtract -1000 -Inf -> Infinity +subx809 subtract -Inf -Inf -> NaN Invalid_operation +subx810 subtract -1 -Inf -> Infinity +subx811 subtract -0 -Inf -> Infinity +subx812 subtract 0 -Inf -> Infinity +subx813 subtract 1 -Inf -> Infinity +subx814 subtract 1000 -Inf -> Infinity +subx815 subtract Inf -Inf -> Infinity + +subx821 subtract NaN Inf -> NaN +subx822 subtract -NaN 1000 -> -NaN +subx823 subtract NaN 1 -> NaN +subx824 subtract NaN 0 -> NaN +subx825 subtract NaN -0 -> NaN +subx826 subtract NaN -1 -> NaN +subx827 subtract NaN -1000 -> NaN +subx828 subtract NaN -Inf -> NaN +subx829 subtract -NaN NaN -> -NaN +subx830 subtract -Inf NaN -> NaN +subx831 subtract -1000 NaN -> NaN +subx832 subtract -1 NaN -> NaN +subx833 subtract -0 NaN -> NaN +subx834 subtract 0 NaN -> NaN +subx835 subtract 1 NaN -> NaN +subx836 subtract 1000 -NaN -> -NaN +subx837 subtract Inf NaN -> NaN + +subx841 subtract sNaN Inf -> NaN Invalid_operation +subx842 subtract -sNaN 1000 -> -NaN Invalid_operation +subx843 subtract sNaN 1 -> NaN Invalid_operation +subx844 subtract sNaN 0 -> NaN Invalid_operation +subx845 subtract sNaN -0 -> NaN Invalid_operation +subx846 subtract sNaN -1 -> NaN Invalid_operation +subx847 subtract sNaN -1000 -> NaN Invalid_operation +subx848 subtract sNaN NaN -> NaN Invalid_operation +subx849 subtract sNaN sNaN -> NaN Invalid_operation +subx850 subtract NaN sNaN -> NaN Invalid_operation +subx851 subtract -Inf -sNaN -> -NaN Invalid_operation +subx852 subtract -1000 sNaN -> NaN Invalid_operation +subx853 subtract -1 sNaN -> NaN Invalid_operation +subx854 subtract -0 sNaN -> NaN Invalid_operation +subx855 subtract 0 sNaN -> NaN Invalid_operation +subx856 subtract 1 sNaN -> NaN Invalid_operation +subx857 subtract 1000 sNaN -> NaN Invalid_operation +subx858 subtract Inf sNaN -> NaN Invalid_operation +subx859 subtract NaN sNaN -> NaN Invalid_operation + +-- propagating NaNs +subx861 subtract NaN01 -Inf -> NaN1 +subx862 subtract -NaN02 -1000 -> -NaN2 +subx863 subtract NaN03 1000 -> NaN3 +subx864 subtract NaN04 Inf -> NaN4 +subx865 subtract NaN05 NaN61 -> NaN5 +subx866 subtract -Inf -NaN71 -> -NaN71 +subx867 subtract -1000 NaN81 -> NaN81 +subx868 subtract 1000 NaN91 -> NaN91 +subx869 subtract Inf NaN101 -> NaN101 +subx871 subtract sNaN011 -Inf -> NaN11 Invalid_operation +subx872 subtract sNaN012 -1000 -> NaN12 Invalid_operation +subx873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation +subx874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation +subx875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation +subx876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation +subx877 subtract -Inf sNaN201 -> NaN201 Invalid_operation +subx878 subtract -1000 sNaN211 -> NaN211 Invalid_operation +subx879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation +subx880 subtract Inf sNaN231 -> NaN231 Invalid_operation +subx881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation + +-- edge case spills +subx901 subtract 2.E-3 1.002 -> -1.000 +subx902 subtract 2.0E-3 1.002 -> -1.0000 +subx903 subtract 2.00E-3 1.0020 -> -1.00000 +subx904 subtract 2.000E-3 1.00200 -> -1.000000 +subx905 subtract 2.0000E-3 1.002000 -> -1.0000000 +subx906 subtract 2.00000E-3 1.0020000 -> -1.00000000 +subx907 subtract 2.000000E-3 1.00200000 -> -1.000000000 +subx908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000 + +-- subnormals and underflows +precision: 3 +maxexponent: 999 +minexponent: -999 +subx1010 subtract 0 1.00E-999 -> -1.00E-999 +subx1011 subtract 0 0.1E-999 -> -1E-1000 Subnormal +subx1012 subtract 0 0.10E-999 -> -1.0E-1000 Subnormal +subx1013 subtract 0 0.100E-999 -> -1.0E-1000 Subnormal Rounded +subx1014 subtract 0 0.01E-999 -> -1E-1001 Subnormal +-- next is rounded to Emin +subx1015 subtract 0 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow +subx1016 subtract 0 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +subx1017 subtract 0 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow +subx1018 subtract 0 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +subx1019 subtract 0 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +subx1020 subtract 0 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow + +subx1030 subtract 0 -1.00E-999 -> 1.00E-999 +subx1031 subtract 0 -0.1E-999 -> 1E-1000 Subnormal +subx1032 subtract 0 -0.10E-999 -> 1.0E-1000 Subnormal +subx1033 subtract 0 -0.100E-999 -> 1.0E-1000 Subnormal Rounded +subx1034 subtract 0 -0.01E-999 -> 1E-1001 Subnormal +-- next is rounded to Emin +subx1035 subtract 0 -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow +subx1036 subtract 0 -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow +subx1037 subtract 0 -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow +subx1038 subtract 0 -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +subx1039 subtract 0 -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow +subx1040 subtract 0 -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow + +-- some non-zero subnormal subtracts +-- subx1056 is a tricky case +rounding: half_up +subx1050 subtract 1.00E-999 0.1E-999 -> 9.0E-1000 Subnormal +subx1051 subtract 0.1E-999 0.1E-999 -> 0E-1000 +subx1052 subtract 0.10E-999 0.1E-999 -> 0E-1001 +subx1053 subtract 0.100E-999 0.1E-999 -> 0E-1001 Clamped +subx1054 subtract 0.01E-999 0.1E-999 -> -9E-1001 Subnormal +subx1055 subtract 0.999E-999 0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow +subx1056 subtract 0.099E-999 0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow +subx1057 subtract 0.009E-999 0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow +subx1058 subtract 0.001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +subx1059 subtract 0.0009E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow +subx1060 subtract 0.0001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow + + +-- check for double-rounded subnormals +precision: 5 +maxexponent: 79 +minexponent: -79 +subx1101 subtract 0 1.52444E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow +subx1102 subtract 0 1.52445E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow +subx1103 subtract 0 1.52446E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow +subx1104 subtract 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow +subx1105 subtract 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow +subx1106 subtract 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow + +subx1111 subtract 1.2345678E-80 1.2345671E-80 -> 0E-83 Inexact Rounded Subnormal Underflow +subx1112 subtract 1.2345678E-80 1.2345618E-80 -> 0E-83 Inexact Rounded Subnormal Underflow +subx1113 subtract 1.2345678E-80 1.2345178E-80 -> 0E-83 Inexact Rounded Subnormal Underflow +subx1114 subtract 1.2345678E-80 1.2341678E-80 -> 0E-83 Inexact Rounded Subnormal Underflow +subx1115 subtract 1.2345678E-80 1.2315678E-80 -> 3E-83 Rounded Subnormal +subx1116 subtract 1.2345678E-80 1.2145678E-80 -> 2.0E-82 Rounded Subnormal +subx1117 subtract 1.2345678E-80 1.1345678E-80 -> 1.00E-81 Rounded Subnormal +subx1118 subtract 1.2345678E-80 0.2345678E-80 -> 1.000E-80 Rounded Subnormal + +-- Null tests +subx9990 subtract 10 # -> NaN Invalid_operation +subx9991 subtract # 10 -> NaN Invalid_operation Added: sandbox/trunk/decimal-c/decimaltestdata/testall.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/testall.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,58 @@ +------------------------------------------------------------------------ +-- testall.decTest -- run all general decimal arithmetic testcases -- +-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- core tests (using Extended: 1) -------------------------------------- +dectest: base +dectest: abs +dectest: add +dectest: clamp +dectest: compare +dectest: divide +dectest: divideint +dectest: inexact +dectest: max +dectest: min +dectest: minus +dectest: multiply +dectest: normalize +dectest: plus +dectest: power +dectest: quantize +dectest: randoms +dectest: remainder +dectest: remaindernear +dectest: rescale -- [obsolete] +dectest: rounding +dectest: samequantum +dectest: squareroot +dectest: subtract +dectest: tointegral +dectest: trim + +-- The next are for the Strawman 4d concrete representations +dectest: decimal32 +dectest: decimal64 +dectest: decimal128 + + +-- General 31->33-digit boundary tests +dectest: randombound32 + Added: sandbox/trunk/decimal-c/decimaltestdata/tointegral.decTest ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/decimaltestdata/tointegral.decTest Tue May 23 13:34:01 2006 @@ -0,0 +1,176 @@ +------------------------------------------------------------------------ +-- tointegral.decTest -- round decimal to integral value -- +-- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- +------------------------------------------------------------------------ +-- Please see the document "General Decimal Arithmetic Testcases" -- +-- at http://www2.hursley.ibm.com/decimal for the description of -- +-- these testcases. -- +-- -- +-- These testcases are experimental ('beta' versions), and they -- +-- may contain errors. They are offered on an as-is basis. In -- +-- particular, achieving the same results as the tests here is not -- +-- a guarantee that an implementation complies with any Standard -- +-- or specification. The tests are not exhaustive. -- +-- -- +-- Please send comments, suggestions, and corrections to the author: -- +-- Mike Cowlishaw, IBM Fellow -- +-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- +-- mfc at uk.ibm.com -- +------------------------------------------------------------------------ +version: 2.39 + +-- This set of tests tests the extended specification 'round-to-integral +-- value' operation (from IEEE 854, later modified in 754r). +-- All non-zero results are defined as being those from either copy or +-- quantize, so those are assumed to have been tested. +-- Note that 754r requires that Inexact not be set, and we similarly +-- assume Rounded is not set. + +extended: 1 +precision: 9 +rounding: half_up +maxExponent: 999 +minExponent: -999 + +intx001 tointegral 0 -> 0 +intx002 tointegral 0.0 -> 0 +intx003 tointegral 0.1 -> 0 +intx004 tointegral 0.2 -> 0 +intx005 tointegral 0.3 -> 0 +intx006 tointegral 0.4 -> 0 +intx007 tointegral 0.5 -> 1 +intx008 tointegral 0.6 -> 1 +intx009 tointegral 0.7 -> 1 +intx010 tointegral 0.8 -> 1 +intx011 tointegral 0.9 -> 1 +intx012 tointegral 1 -> 1 +intx013 tointegral 1.0 -> 1 +intx014 tointegral 1.1 -> 1 +intx015 tointegral 1.2 -> 1 +intx016 tointegral 1.3 -> 1 +intx017 tointegral 1.4 -> 1 +intx018 tointegral 1.5 -> 2 +intx019 tointegral 1.6 -> 2 +intx020 tointegral 1.7 -> 2 +intx021 tointegral 1.8 -> 2 +intx022 tointegral 1.9 -> 2 +-- negatives +intx031 tointegral -0 -> -0 +intx032 tointegral -0.0 -> -0 +intx033 tointegral -0.1 -> -0 +intx034 tointegral -0.2 -> -0 +intx035 tointegral -0.3 -> -0 +intx036 tointegral -0.4 -> -0 +intx037 tointegral -0.5 -> -1 +intx038 tointegral -0.6 -> -1 +intx039 tointegral -0.7 -> -1 +intx040 tointegral -0.8 -> -1 +intx041 tointegral -0.9 -> -1 +intx042 tointegral -1 -> -1 +intx043 tointegral -1.0 -> -1 +intx044 tointegral -1.1 -> -1 +intx045 tointegral -1.2 -> -1 +intx046 tointegral -1.3 -> -1 +intx047 tointegral -1.4 -> -1 +intx048 tointegral -1.5 -> -2 +intx049 tointegral -1.6 -> -2 +intx050 tointegral -1.7 -> -2 +intx051 tointegral -1.8 -> -2 +intx052 tointegral -1.9 -> -2 +-- next two would be NaN using quantize(x, 0) +intx053 tointegral 10E+30 -> 1.0E+31 +intx054 tointegral -10E+30 -> -1.0E+31 + +-- numbers around precision +precision: 9 +intx060 tointegral '56267E-10' -> '0' +intx061 tointegral '56267E-5' -> '1' +intx062 tointegral '56267E-2' -> '563' +intx063 tointegral '56267E-1' -> '5627' +intx065 tointegral '56267E-0' -> '56267' +intx066 tointegral '56267E+0' -> '56267' +intx067 tointegral '56267E+1' -> '5.6267E+5' +intx068 tointegral '56267E+2' -> '5.6267E+6' +intx069 tointegral '56267E+3' -> '5.6267E+7' +intx070 tointegral '56267E+4' -> '5.6267E+8' +intx071 tointegral '56267E+5' -> '5.6267E+9' +intx072 tointegral '56267E+6' -> '5.6267E+10' +intx073 tointegral '1.23E+96' -> '1.23E+96' +intx074 tointegral '1.23E+384' -> '1.23E+384' +intx075 tointegral '1.23E+999' -> '1.23E+999' + +intx080 tointegral '-56267E-10' -> '-0' +intx081 tointegral '-56267E-5' -> '-1' +intx082 tointegral '-56267E-2' -> '-563' +intx083 tointegral '-56267E-1' -> '-5627' +intx085 tointegral '-56267E-0' -> '-56267' +intx086 tointegral '-56267E+0' -> '-56267' +intx087 tointegral '-56267E+1' -> '-5.6267E+5' +intx088 tointegral '-56267E+2' -> '-5.6267E+6' +intx089 tointegral '-56267E+3' -> '-5.6267E+7' +intx090 tointegral '-56267E+4' -> '-5.6267E+8' +intx091 tointegral '-56267E+5' -> '-5.6267E+9' +intx092 tointegral '-56267E+6' -> '-5.6267E+10' +intx093 tointegral '-1.23E+96' -> '-1.23E+96' +intx094 tointegral '-1.23E+384' -> '-1.23E+384' +intx095 tointegral '-1.23E+999' -> '-1.23E+999' + +-- subnormal inputs +intx100 tointegral 1E-999 -> 0 +intx101 tointegral 0.1E-999 -> 0 +intx102 tointegral 0.01E-999 -> 0 +intx103 tointegral 0E-999 -> 0 + +-- specials and zeros +intx120 tointegral 'Inf' -> Infinity +intx121 tointegral '-Inf' -> -Infinity +intx122 tointegral NaN -> NaN +intx123 tointegral sNaN -> NaN Invalid_operation +intx124 tointegral 0 -> 0 +intx125 tointegral -0 -> -0 +intx126 tointegral 0.000 -> 0 +intx127 tointegral 0.00 -> 0 +intx128 tointegral 0.0 -> 0 +intx129 tointegral 0 -> 0 +intx130 tointegral 0E-3 -> 0 +intx131 tointegral 0E-2 -> 0 +intx132 tointegral 0E-1 -> 0 +intx133 tointegral 0E-0 -> 0 +intx134 tointegral 0E+1 -> 0E+1 +intx135 tointegral 0E+2 -> 0E+2 +intx136 tointegral 0E+3 -> 0E+3 +intx137 tointegral 0E+4 -> 0E+4 +intx138 tointegral 0E+5 -> 0E+5 +intx139 tointegral -0.000 -> -0 +intx140 tointegral -0.00 -> -0 +intx141 tointegral -0.0 -> -0 +intx142 tointegral -0 -> -0 +intx143 tointegral -0E-3 -> -0 +intx144 tointegral -0E-2 -> -0 +intx145 tointegral -0E-1 -> -0 +intx146 tointegral -0E-0 -> -0 +intx147 tointegral -0E+1 -> -0E+1 +intx148 tointegral -0E+2 -> -0E+2 +intx149 tointegral -0E+3 -> -0E+3 +intx150 tointegral -0E+4 -> -0E+4 +intx151 tointegral -0E+5 -> -0E+5 +-- propagating NaNs +intx152 tointegral NaN808 -> NaN808 +intx153 tointegral sNaN080 -> NaN80 Invalid_operation +intx154 tointegral -NaN808 -> -NaN808 +intx155 tointegral -sNaN080 -> -NaN80 Invalid_operation +intx156 tointegral -NaN -> -NaN +intx157 tointegral -sNaN -> -NaN Invalid_operation + +-- examples +rounding: half_up +precision: 9 +intx200 tointegral 2.1 -> 2 +intx201 tointegral 100 -> 100 +intx202 tointegral 100.0 -> 100 +intx203 tointegral 101.5 -> 102 +intx204 tointegral -101.5 -> -102 +intx205 tointegral 10E+5 -> 1.0E+6 +intx206 tointegral 7.89E+77 -> 7.89E+77 +intx207 tointegral -Inf -> -Infinity + Added: sandbox/trunk/decimal-c/setup.py ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/setup.py Tue May 23 13:34:01 2006 @@ -0,0 +1,13 @@ +from distutils.core import setup, Extension + +files = ['_decimal.c'] + +libraries = [] +includes = [] +setup(name = "_decimal", version = "0.1", + ext_modules = [Extension("_decimal", files, + libraries = libraries, + include_dirs = includes, + ) + ], + ) Added: sandbox/trunk/decimal-c/test_decimal.py ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/test_decimal.py Tue May 23 13:34:01 2006 @@ -0,0 +1,1105 @@ +# Copyright (c) 2004 Python Software Foundation. +# All rights reserved. + +# Written by Eric Price +# and Facundo Batista +# and Raymond Hettinger +# and Aahz (aahz at pobox.com) +# and Tim Peters + +""" +These are the test cases for the Decimal module. + +There are two groups of tests, Arithmetic and Behaviour. The former test +the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter +test the pythonic behaviour according to PEP 327. + +Cowlishaw's tests can be downloaded from: + + www2.hursley.ibm.com/decimal/dectest.zip + +This test module can be called from command line with one parameter (Arithmetic +or Behaviour) to test each part, or without parameter to test both parts. If +you're working through IDLE, you can import this test module and call test_main() +with the corresponding argument. +""" + +import unittest +import glob +import os, sys +import pickle, copy +from decimal import * +from test.test_support import (TestSkipped, run_unittest, run_doctest, + is_resource_enabled) +import random +try: + import threading +except ImportError: + threading = None + +# Useful Test Constant +Signals = getcontext().flags.keys() + +# Tests are built around these assumed context defaults. +# test_main() restores the original context. +def init(): + global ORIGINAL_CONTEXT + ORIGINAL_CONTEXT = getcontext().copy() + DefaultContext.prec = 9 + DefaultContext.rounding = ROUND_HALF_EVEN + DefaultContext.traps = dict.fromkeys(Signals, 0) + setcontext(DefaultContext) + +TESTDATADIR = 'decimaltestdata' +if __name__ == '__main__': + file = sys.argv[0] +else: + file = __file__ +testdir = os.path.dirname(file) or os.curdir +directory = testdir + os.sep + TESTDATADIR + os.sep + +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. +EXTENDEDERRORTEST = False + + +#Map the test cases' error names to the actual errors + +ErrorNames = {'clamped' : Clamped, + 'conversion_syntax' : InvalidOperation, + 'division_by_zero' : DivisionByZero, + 'division_impossible' : InvalidOperation, + 'division_undefined' : InvalidOperation, + 'inexact' : Inexact, + 'invalid_context' : InvalidOperation, + 'invalid_operation' : InvalidOperation, + 'overflow' : Overflow, + 'rounded' : Rounded, + 'subnormal' : Subnormal, + 'underflow' : Underflow} + + +def Nonfunction(*args): + """Doesn't do anything.""" + return None + +RoundingDict = {'ceiling' : ROUND_CEILING, #Maps test-case names to roundings. + 'down' : ROUND_DOWN, + 'floor' : ROUND_FLOOR, + 'half_down' : ROUND_HALF_DOWN, + 'half_even' : ROUND_HALF_EVEN, + 'half_up' : ROUND_HALF_UP, + 'up' : ROUND_UP} + +# Name adapter to be able to change the Decimal and Context +# interface without changing the test files from Cowlishaw +nameAdapter = {'toeng':'to_eng_string', + 'tosci':'to_sci_string', + 'samequantum':'same_quantum', + 'tointegral':'to_integral', + 'remaindernear':'remainder_near', + 'divideint':'divide_int', + 'squareroot':'sqrt', + 'apply':'_apply', + } + +class DecimalTest(unittest.TestCase): + """Class which tests the Decimal class against the test cases. + + Changed for unittest. + """ + def setUp(self): + self.context = Context() + for key in DefaultContext.traps.keys(): + DefaultContext.traps[key] = 1 + self.ignore_list = ['#'] + # Basically, a # means return NaN InvalidOperation. + # Different from a sNaN in trim + + self.ChangeDict = {'precision' : self.change_precision, + 'rounding' : self.change_rounding_method, + 'maxexponent' : self.change_max_exponent, + 'minexponent' : self.change_min_exponent, + 'clamp' : self.change_clamp} + + def tearDown(self): + """Cleaning up enviroment.""" + # leaving context in original state + for key in DefaultContext.traps.keys(): + DefaultContext.traps[key] = 0 + return + + def eval_file(self, file): + global skip_expected + if skip_expected: + raise TestSkipped + return + for line in open(file).xreadlines(): + line = line.replace('\r\n', '').replace('\n', '') + #print line + try: + t = self.eval_line(line) + except InvalidOperation: + print 'Error in test cases:' + print line + continue + except DecimalException, exception: + #Exception raised where there shoudn't have been one. + self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line) + + return + + def eval_line(self, s): + if s.find(' -> ') >= 0 and s[:2] != '--' and not s.startswith(' --'): + s = (s.split('->')[0] + '->' + + s.split('->')[1].split('--')[0]).strip() + else: + s = s.split('--')[0].strip() + + for ignore in self.ignore_list: + if s.find(ignore) >= 0: + #print s.split()[0], 'NotImplemented--', ignore + return + if not s: + return + elif ':' in s: + return self.eval_directive(s) + else: + return self.eval_equation(s) + + def eval_directive(self, s): + funct, value = map(lambda x: x.strip().lower(), s.split(':')) + if funct == 'rounding': + value = RoundingDict[value] + else: + try: + value = int(value) + except ValueError: + pass + + funct = self.ChangeDict.get(funct, Nonfunction) + funct(value) + + def eval_equation(self, s): + #global DEFAULT_PRECISION + #print DEFAULT_PRECISION + + if not TEST_ALL and random.random() < 0.90: + return + + try: + Sides = s.split('->') + L = Sides[0].strip().split() + id = L[0] +# print id, + funct = L[1].lower() + valstemp = L[2:] + L = Sides[1].strip().split() + ans = L[0] + exceptions = L[1:] + except (TypeError, AttributeError, IndexError): + raise InvalidOperation + def FixQuotes(val): + val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') + val = val.replace("'", '').replace('"', '') + val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') + return val + fname = nameAdapter.get(funct, funct) + if fname == 'rescale': + return + funct = getattr(self.context, fname) + vals = [] + conglomerate = '' + quote = 0 + theirexceptions = [ErrorNames[x.lower()] for x in exceptions] + + for exception in Signals: + self.context.traps[exception] = 1 #Catch these bugs... + for exception in theirexceptions: + self.context.traps[exception] = 0 + for i, val in enumerate(valstemp): + if val.count("'") % 2 == 1: + quote = 1 - quote + if quote: + conglomerate = conglomerate + ' ' + val + continue + else: + val = conglomerate + val + conglomerate = '' + v = FixQuotes(val) + if fname in ('to_sci_string', 'to_eng_string'): + if EXTENDEDERRORTEST: + for error in theirexceptions: + self.context.traps[error] = 1 + try: + funct(self.context.create_decimal(v)) + except error: + pass + except Signals, e: + self.fail("Raised %s in %s when %s disabled" % \ + (e, s, error)) + else: + self.fail("Did not raise %s in %s" % (error, s)) + self.context.traps[error] = 0 + v = self.context.create_decimal(v) + else: + v = Decimal(v) + vals.append(v) + + ans = FixQuotes(ans) + + if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'): + for error in theirexceptions: + self.context.traps[error] = 1 + try: + funct(*vals) + except error: + pass + except Signals, e: + self.fail("Raised %s in %s when %s disabled" % \ + (e, s, error)) + else: + self.fail("Did not raise %s in %s" % (error, s)) + self.context.traps[error] = 0 + try: + result = str(funct(*vals)) + if fname == 'same_quantum': + result = str(int(eval(result))) # 'True', 'False' -> '1', '0' + except Signals, error: + self.fail("Raised %s in %s" % (error, s)) + except: #Catch any error long enough to state the test case. + print "ERROR:", s + raise + + myexceptions = self.getexceptions() + self.context.clear_flags() + + myexceptions.sort() + theirexceptions.sort() + + self.assertEqual(result, ans, + 'Incorrect answer for ' + s + ' -- got ' + result) + self.assertEqual(myexceptions, theirexceptions, + 'Incorrect flags set in ' + s + ' -- got ' \ + + str(myexceptions)) + return + + def getexceptions(self): + return [e for e in Signals if self.context.flags[e]] + + def change_precision(self, prec): + self.context.prec = prec + def change_rounding_method(self, rounding): + self.context.rounding = rounding + def change_min_exponent(self, exp): + self.context.Emin = exp + def change_max_exponent(self, exp): + self.context.Emax = exp + def change_clamp(self, clamp): + self.context._clamp = clamp + +# 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(directory): + if '.decTest' not in filename: + continue + head, tail = filename.split('.') + tester = lambda self, f=filename: self.eval_file(directory + f) + setattr(DecimalTest, 'test_' + head, tester) + del filename, head, tail, tester + + + +# The following classes test the behaviour of Decimal according to PEP 327 + +class DecimalExplicitConstructionTest(unittest.TestCase): + '''Unit tests for Explicit Construction cases of Decimal.''' + + def test_explicit_empty(self): + self.assertEqual(Decimal(), Decimal("0")) + + def test_explicit_from_None(self): + self.assertRaises(TypeError, Decimal, None) + + def test_explicit_from_int(self): + + #positive + d = Decimal(45) + self.assertEqual(str(d), '45') + + #very large positive + d = Decimal(500000123) + self.assertEqual(str(d), '500000123') + + #negative + d = Decimal(-45) + self.assertEqual(str(d), '-45') + + #zero + d = Decimal(0) + self.assertEqual(str(d), '0') + + def test_explicit_from_string(self): + + #empty + self.assertEqual(str(Decimal('')), 'NaN') + + #int + self.assertEqual(str(Decimal('45')), '45') + + #float + self.assertEqual(str(Decimal('45.34')), '45.34') + + #engineer notation + self.assertEqual(str(Decimal('45e2')), '4.5E+3') + + #just not a number + self.assertEqual(str(Decimal('ugly')), 'NaN') + + def test_explicit_from_tuples(self): + + #zero + d = Decimal( (0, (0,), 0) ) + self.assertEqual(str(d), '0') + + #int + d = Decimal( (1, (4, 5), 0) ) + self.assertEqual(str(d), '-45') + + #float + d = Decimal( (0, (4, 5, 3, 4), -2) ) + self.assertEqual(str(d), '45.34') + + #weird + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.34913534E-17') + + #wrong number of items + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1)) ) + + #bad sign + self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) ) + + #bad exp + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) + + #bad coefficients + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) + + def test_explicit_from_Decimal(self): + + #positive + d = Decimal(45) + e = Decimal(d) + self.assertEqual(str(e), '45') + self.assertNotEqual(id(d), id(e)) + + #very large positive + d = Decimal(500000123) + e = Decimal(d) + self.assertEqual(str(e), '500000123') + self.assertNotEqual(id(d), id(e)) + + #negative + d = Decimal(-45) + e = Decimal(d) + self.assertEqual(str(e), '-45') + self.assertNotEqual(id(d), id(e)) + + #zero + d = Decimal(0) + e = Decimal(d) + self.assertEqual(str(e), '0') + self.assertNotEqual(id(d), id(e)) + + def test_explicit_context_create_decimal(self): + + nc = copy.copy(getcontext()) + nc.prec = 3 + + # empty + d = Decimal() + self.assertEqual(str(d), '0') + d = nc.create_decimal() + self.assertEqual(str(d), '0') + + # from None + self.assertRaises(TypeError, nc.create_decimal, None) + + # from int + d = nc.create_decimal(456) + self.failUnless(isinstance(d, Decimal)) + self.assertEqual(nc.create_decimal(45678), + nc.create_decimal('457E+2')) + + # from string + d = Decimal('456789') + self.assertEqual(str(d), '456789') + d = nc.create_decimal('456789') + self.assertEqual(str(d), '4.57E+5') + + # from tuples + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.34913534E-17') + d = nc.create_decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.35E-17') + + # from Decimal + prevdec = Decimal(500000123) + d = Decimal(prevdec) + self.assertEqual(str(d), '500000123') + d = nc.create_decimal(prevdec) + self.assertEqual(str(d), '5.00E+8') + + +class DecimalImplicitConstructionTest(unittest.TestCase): + '''Unit tests for Implicit Construction cases of Decimal.''' + + def test_implicit_from_None(self): + self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals()) + + def test_implicit_from_int(self): + #normal + self.assertEqual(str(Decimal(5) + 45), '50') + #exceeding precision + self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) + + def test_implicit_from_string(self): + self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals()) + + def test_implicit_from_float(self): + self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals()) + + 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 + oplist = [ + ('+', '__add__', '__radd__'), + ('-', '__sub__', '__rsub__'), + ('*', '__mul__', '__rmul__'), + ('%', '__mod__', '__rmod__'), + ('//', '__floordiv__', '__rfloordiv__'), + ('**', '__pow__', '__rpow__') + ] + if 1/2 == 0: + # testing with classic division, so add __div__ + oplist.append(('/', '__div__', '__rdiv__')) + else: + # testing with -Qnew, so add __truediv__ + oplist.append(('/', '__truediv__', '__rtruediv__')) + + for sym, lop, rop in oplist: + 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.''' + + def test_addition(self): + + d1 = Decimal('-11.1') + d2 = Decimal('22.2') + + #two Decimals + self.assertEqual(d1+d2, Decimal('11.1')) + self.assertEqual(d2+d1, Decimal('11.1')) + + #with other type, left + c = d1 + 5 + self.assertEqual(c, Decimal('-6.1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 + d1 + self.assertEqual(c, Decimal('-6.1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 += d2 + self.assertEqual(d1, Decimal('11.1')) + + #inline with other type + d1 += 5 + self.assertEqual(d1, Decimal('16.1')) + + def test_subtraction(self): + + d1 = Decimal('-11.1') + d2 = Decimal('22.2') + + #two Decimals + self.assertEqual(d1-d2, Decimal('-33.3')) + self.assertEqual(d2-d1, Decimal('33.3')) + + #with other type, left + c = d1 - 5 + self.assertEqual(c, Decimal('-16.1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 - d1 + self.assertEqual(c, Decimal('16.1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 -= d2 + self.assertEqual(d1, Decimal('-33.3')) + + #inline with other type + d1 -= 5 + self.assertEqual(d1, Decimal('-38.3')) + + def test_multiplication(self): + + d1 = Decimal('-5') + d2 = Decimal('3') + + #two Decimals + self.assertEqual(d1*d2, Decimal('-15')) + self.assertEqual(d2*d1, Decimal('-15')) + + #with other type, left + c = d1 * 5 + self.assertEqual(c, Decimal('-25')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 * d1 + self.assertEqual(c, Decimal('-25')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 *= d2 + self.assertEqual(d1, Decimal('-15')) + + #inline with other type + d1 *= 5 + self.assertEqual(d1, Decimal('-75')) + + def test_division(self): + + d1 = Decimal('-5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1/d2, Decimal('-2.5')) + self.assertEqual(d2/d1, Decimal('-0.4')) + + #with other type, left + c = d1 / 4 + self.assertEqual(c, Decimal('-1.25')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 4 / d1 + self.assertEqual(c, Decimal('-0.8')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 /= d2 + self.assertEqual(d1, Decimal('-2.5')) + + #inline with other type + d1 /= 4 + self.assertEqual(d1, Decimal('-0.625')) + + def test_floor_division(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1//d2, Decimal('2')) + self.assertEqual(d2//d1, Decimal('0')) + + #with other type, left + c = d1 // 4 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 // d1 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 //= d2 + self.assertEqual(d1, Decimal('2')) + + #inline with other type + d1 //= 2 + self.assertEqual(d1, Decimal('1')) + + def test_powering(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1**d2, Decimal('25')) + self.assertEqual(d2**d1, Decimal('32')) + + #with other type, left + c = d1 ** 4 + self.assertEqual(c, Decimal('625')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 ** d1 + self.assertEqual(c, Decimal('16807')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 **= d2 + self.assertEqual(d1, Decimal('25')) + + #inline with other type + d1 **= 4 + self.assertEqual(d1, Decimal('390625')) + + def test_module(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1%d2, Decimal('1')) + self.assertEqual(d2%d1, Decimal('2')) + + #with other type, left + c = d1 % 4 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 % d1 + self.assertEqual(c, Decimal('2')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 %= d2 + self.assertEqual(d1, Decimal('1')) + + #inline with other type + d1 %= 4 + self.assertEqual(d1, Decimal('1')) + + def test_floor_div_module(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + (p, q) = divmod(d1, d2) + self.assertEqual(p, Decimal('2')) + self.assertEqual(q, Decimal('1')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + #with other type, left + (p, q) = divmod(d1, 4) + self.assertEqual(p, Decimal('1')) + self.assertEqual(q, Decimal('1')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + #with other type, right + (p, q) = divmod(7, d1) + self.assertEqual(p, Decimal('1')) + self.assertEqual(q, Decimal('2')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + def test_unary_operators(self): + self.assertEqual(+Decimal(45), Decimal(+45)) # + + self.assertEqual(-Decimal(45), Decimal(-45)) # - + self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs + + +# The following are two functions used to test threading in the next class + +def thfunc1(cls): + d1 = Decimal(1) + d3 = Decimal(3) + cls.assertEqual(d1/d3, Decimal('0.333333333')) + cls.synchro.wait() + cls.assertEqual(d1/d3, Decimal('0.333333333')) + cls.finish1.set() + return + +def thfunc2(cls): + d1 = Decimal(1) + d3 = Decimal(3) + cls.assertEqual(d1/d3, Decimal('0.333333333')) + thiscontext = getcontext() + thiscontext.prec = 18 + cls.assertEqual(d1/d3, Decimal('0.333333333333333333')) + cls.synchro.set() + cls.finish2.set() + return + + +class DecimalUseOfContextTest(unittest.TestCase): + '''Unit tests for Use of Context cases in Decimal.''' + + try: + import threading + except ImportError: + threading = None + + # Take care executing this test from IDLE, there's an issue in threading + # that hangs IDLE and I couldn't find it + + def test_threading(self): + #Test the "threading isolation" of a Context. + + self.synchro = threading.Event() + self.finish1 = threading.Event() + self.finish2 = threading.Event() + + th1 = threading.Thread(target=thfunc1, args=(self,)) + th2 = threading.Thread(target=thfunc2, args=(self,)) + + th1.start() + th2.start() + + self.finish1.wait() + self.finish1.wait() + return + + if threading is None: + del test_threading + + +class DecimalUsabilityTest(unittest.TestCase): + '''Unit tests for Usability cases of Decimal.''' + + def test_comparison_operators(self): + + da = Decimal('23.42') + db = Decimal('23.42') + dc = Decimal('45') + + #two Decimals + self.failUnless(dc > da) + self.failUnless(dc >= da) + self.failUnless(da < dc) + self.failUnless(da <= dc) + self.failUnless(da == db) + self.failUnless(da != dc) + self.failUnless(da <= db) + self.failUnless(da >= db) + self.assertEqual(cmp(dc,da), 1) + self.assertEqual(cmp(da,dc), -1) + self.assertEqual(cmp(da,db), 0) + + #a Decimal and an int + self.failUnless(dc > 23) + self.failUnless(23 < dc) + self.failUnless(dc == 45) + self.assertEqual(cmp(dc,23), 1) + self.assertEqual(cmp(23,dc), -1) + self.assertEqual(cmp(dc,45), 0) + + #a Decimal and uncomparable + self.assertNotEqual(da, 'ugly') + self.assertNotEqual(da, 32.7) + self.assertNotEqual(da, object()) + self.assertNotEqual(da, object) + + # sortable + a = map(Decimal, xrange(100)) + b = a[:] + random.shuffle(a) + a.sort() + self.assertEqual(a, b) + + def test_copy_and_deepcopy_methods(self): + d = Decimal('43.24') + c = copy.copy(d) + self.assertEqual(id(c), id(d)) + dc = copy.deepcopy(d) + self.assertEqual(id(dc), id(d)) + + def test_hash_method(self): + #just that it's hashable + 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): + + d1 = Decimal('15.32') + d2 = Decimal('28.5') + l1 = 15 + l2 = 28 + + #between Decimals + self.failUnless(min(d1,d2) is d1) + self.failUnless(min(d2,d1) is d1) + self.failUnless(max(d1,d2) is d2) + self.failUnless(max(d2,d1) is d2) + + #between Decimal and long + self.failUnless(min(d1,l2) is d1) + self.failUnless(min(l2,d1) is d1) + self.failUnless(max(l1,d2) is d2) + self.failUnless(max(d2,l1) is d2) + + def test_as_nonzero(self): + #as false + self.failIf(Decimal(0)) + #as true + self.failUnless(Decimal('0.372')) + + def test_tostring_methods(self): + #Test str and repr methods. + + d = Decimal('15.32') + self.assertEqual(str(d), '15.32') # str + self.assertEqual(repr(d), 'Decimal("15.32")') # repr + + def test_tonum_methods(self): + #Test float, int and long methods. + + d1 = Decimal('66') + d2 = Decimal('15.32') + + #int + self.assertEqual(int(d1), 66) + self.assertEqual(int(d2), 15) + + #long + self.assertEqual(long(d1), 66) + self.assertEqual(long(d2), 15) + + #float + self.assertEqual(float(d1), 66) + self.assertEqual(float(d2), 15.32) + + def test_eval_round_trip(self): + + #with zero + d = Decimal( (0, (0,), 0) ) + self.assertEqual(d, eval(repr(d))) + + #int + d = Decimal( (1, (4, 5), 0) ) + self.assertEqual(d, eval(repr(d))) + + #float + d = Decimal( (0, (4, 5, 3, 4), -2) ) + self.assertEqual(d, eval(repr(d))) + + #weird + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(d, eval(repr(d))) + + def test_as_tuple(self): + + #with zero + d = Decimal(0) + self.assertEqual(d.as_tuple(), (0, (0,), 0) ) + + #int + d = Decimal(-45) + self.assertEqual(d.as_tuple(), (1, (4, 5), 0) ) + + #complicated string + d = Decimal("-4.34913534E-17") + self.assertEqual(d.as_tuple(), (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + + #inf + d = Decimal("Infinity") + self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) + + def test_immutability_operations(self): + # Do operations and check that it didn't change change internal objects. + + d1 = Decimal('-25e55') + b1 = Decimal('-25e55') + d2 = Decimal('33e-33') + b2 = Decimal('33e-33') + + def checkSameDec(operation, useOther=False): + if useOther: + eval("d1." + operation + "(d2)") + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + self.assertEqual(d2._sign, b2._sign) + self.assertEqual(d2._int, b2._int) + self.assertEqual(d2._exp, b2._exp) + else: + eval("d1." + operation + "()") + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + return + + Decimal(d1) + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + + checkSameDec("__abs__") + checkSameDec("__add__", True) + checkSameDec("__div__", True) + checkSameDec("__divmod__", True) + checkSameDec("__cmp__", True) + checkSameDec("__float__") + checkSameDec("__floordiv__", True) + checkSameDec("__hash__") + checkSameDec("__int__") + checkSameDec("__long__") + checkSameDec("__mod__", True) + checkSameDec("__mul__", True) + checkSameDec("__neg__") + checkSameDec("__nonzero__") + checkSameDec("__pos__") + checkSameDec("__pow__", True) + checkSameDec("__radd__", True) + checkSameDec("__rdiv__", True) + checkSameDec("__rdivmod__", True) + checkSameDec("__repr__") + checkSameDec("__rfloordiv__", True) + checkSameDec("__rmod__", True) + checkSameDec("__rmul__", True) + checkSameDec("__rpow__", True) + checkSameDec("__rsub__", True) + checkSameDec("__str__") + checkSameDec("__sub__", True) + checkSameDec("__truediv__", True) + checkSameDec("adjusted") + checkSameDec("as_tuple") + checkSameDec("compare", True) + checkSameDec("max", True) + checkSameDec("min", True) + checkSameDec("normalize") + checkSameDec("quantize", True) + checkSameDec("remainder_near", True) + checkSameDec("same_quantum", True) + checkSameDec("sqrt") + checkSameDec("to_eng_string") + checkSameDec("to_integral") + +class DecimalPythonAPItests(unittest.TestCase): + + def test_pickle(self): + d = Decimal('-3.141590000') + p = pickle.dumps(d) + e = pickle.loads(p) + self.assertEqual(d, e) + + def test_int(self): + for x in range(-250, 250): + s = '%0.2f' % (x / 100.0) + # should work the same as for floats + self.assertEqual(int(Decimal(s)), int(float(s))) + # should work the same as to_integral in the ROUND_DOWN mode + d = Decimal(s) + r = d.to_integral(ROUND_DOWN) + self.assertEqual(Decimal(int(d)), r) + +class ContextAPItests(unittest.TestCase): + + def test_pickle(self): + c = Context() + e = pickle.loads(pickle.dumps(c)) + for k in vars(c): + v1 = vars(c)[k] + v2 = vars(e)[k] + self.assertEqual(v1, v2) + + def test_equality_with_other_types(self): + self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}]) + self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}]) + + def test_copy(self): + # All copies should be deep + c = Context() + d = c.copy() + self.assertNotEqual(id(c), id(d)) + self.assertNotEqual(id(c.flags), id(d.flags)) + self.assertNotEqual(id(c.traps), id(d.traps)) + +def test_main(arith=False, verbose=None): + """ Execute the tests. + + Runs all arithmetic tests if arith is True or if the "decimal" resource + is enabled in regrtest.py + """ + + init() + global TEST_ALL + TEST_ALL = arith or is_resource_enabled('decimal') + + test_classes = [ + DecimalExplicitConstructionTest, + DecimalImplicitConstructionTest, + DecimalArithmeticOperatorsTest, + DecimalUseOfContextTest, + DecimalUsabilityTest, + DecimalPythonAPItests, + ContextAPItests, + DecimalTest, + ] + + try: + run_unittest(*test_classes) + import decimal as DecimalModule + run_doctest(DecimalModule, verbose) + finally: + setcontext(ORIGINAL_CONTEXT) + +if __name__ == '__main__': + # Calling with no arguments runs all tests. + # Calling with "Skip" will skip over 90% of the arithmetic tests. + if len(sys.argv) == 1: + test_main(arith=True, verbose=True) + elif len(sys.argv) == 2: + arith = sys.argv[1].lower() != 'skip' + test_main(arith=arith, verbose=True) + else: + raise ValueError("test called with wrong arguments, use test_Decimal [Skip]") From python-checkins at python.org Tue May 23 13:47:16 2006 From: python-checkins at python.org (ronald.oussoren) Date: Tue, 23 May 2006 13:47:16 +0200 (CEST) Subject: [Python-checkins] r46103 - python/trunk/Lib/distutils/command/build_ext.py Message-ID: <20060523114716.F16EE1E4018@bag.python.org> Author: ronald.oussoren Date: Tue May 23 13:47:16 2006 New Revision: 46103 Modified: python/trunk/Lib/distutils/command/build_ext.py Log: Disable linking extensions with -lpython2.5 for darwin. This should fix bug #1487105. Modified: python/trunk/Lib/distutils/command/build_ext.py ============================================================================== --- python/trunk/Lib/distutils/command/build_ext.py (original) +++ python/trunk/Lib/distutils/command/build_ext.py Tue May 23 13:47:16 2006 @@ -689,6 +689,11 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib, "m"] + extra + + elif sys.platform == 'darwin': + # Don't use the default code below + return ext.libraries + else: from distutils import sysconfig if sysconfig.get_config_var('Py_ENABLE_SHARED'): From buildbot at python.org Tue May 23 13:56:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 11:56:22 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060523115622.711061E4009@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/744 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 14:01:12 2006 From: python-checkins at python.org (ronald.oussoren) Date: Tue, 23 May 2006 14:01:12 +0200 (CEST) Subject: [Python-checkins] r46104 - python/trunk/Lib/distutils/sysconfig.py python/trunk/Lib/distutils/unixccompiler.py python/trunk/Lib/distutils/util.py Message-ID: <20060523120112.8D3D61E4009@bag.python.org> Author: ronald.oussoren Date: Tue May 23 14:01:11 2006 New Revision: 46104 Modified: python/trunk/Lib/distutils/sysconfig.py python/trunk/Lib/distutils/unixccompiler.py python/trunk/Lib/distutils/util.py Log: Patch #1488098. This patchs makes it possible to create a universal build on OSX 10.4 and use the result to build extensions on 10.3. It also makes it possible to override the '-arch' and '-isysroot' compiler arguments for specific extensions. Modified: python/trunk/Lib/distutils/sysconfig.py ============================================================================== --- python/trunk/Lib/distutils/sysconfig.py (original) +++ python/trunk/Lib/distutils/sysconfig.py Tue May 23 14:01:11 2006 @@ -500,6 +500,21 @@ _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX + if sys.platform == 'darwin': + kernel_version = os.uname()[2] # Kernel version (8.4.3) + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # On Mac OS X before 10.4, check if -arch and -isysroot + # are in CFLAGS or LDFLAGS and remove them if they are. + # This is needed when building extensions on a 10.3 system + # using a universal build of python. + for key in ('LDFLAGS', 'BASECFLAGS'): + flags = _config_vars[key] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = re.sub('-isysroot [^ \t]* ', ' ', flags) + _config_vars[key] = flags + if args: vals = [] for name in args: Modified: python/trunk/Lib/distutils/unixccompiler.py ============================================================================== --- python/trunk/Lib/distutils/unixccompiler.py (original) +++ python/trunk/Lib/distutils/unixccompiler.py Tue May 23 14:01:11 2006 @@ -42,6 +42,48 @@ # should just happily stuff them into the preprocessor/compiler/linker # options and carry on. +def _darwin_compiler_fixup(compiler_so, cc_args): + """ + This function will strip '-isysroot PATH' and '-arch ARCH' from the + compile flags if the user has specified one them in extra_compile_flags. + + This is needed because '-arch ARCH' adds another architecture to the + build, without a way to remove an architecture. Furthermore GCC will + barf if multiple '-isysroot' arguments are present. + """ + stripArch = stripSysroot = 0 + + compiler_so = list(compiler_so) + kernel_version = os.uname()[2] # 8.4.3 + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # OSX before 10.4.0, these don't support -arch and -isysroot at + # all. + stripArch = stripSysroot = True + else: + stripArch = '-arch' in cc_args + stripSysroot = '-isysroot' in cc_args + + if stripArch: + while 1: + try: + index = compiler_so.index('-arch') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + if stripSysroot: + try: + index = compiler_so.index('-isysroot') + # Strip this argument and the next one: + del compiler_so[index:index+1] + except ValueError: + pass + + return compiler_so + class UnixCCompiler(CCompiler): compiler_type = 'unix' @@ -108,8 +150,11 @@ raise CompileError, msg def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): + compiler_so = self.compiler_so + if sys.platform == 'darwin': + compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) try: - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + + self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg @@ -172,7 +217,22 @@ else: linker = self.linker_so[:] if target_lang == "c++" and self.compiler_cxx: - linker[0] = self.compiler_cxx[0] + # skip over environment variable settings if /usr/bin/env + # is used to set up the linker's environment. + # This is needed on OSX. Note: this assumes that the + # normal and C++ compiler have the same environment + # settings. + i = 0 + if os.path.basename(linker[0]) == "env": + i = 1 + while '=' in linker[i]: + i = i + 1 + + linker[i] = self.compiler_cxx[i] + + if sys.platform == 'darwin': + linker = _darwin_compiler_fixup(linker, ld_args) + self.spawn(linker + ld_args) except DistutilsExecError, msg: raise LinkError, msg Modified: python/trunk/Lib/distutils/util.py ============================================================================== --- python/trunk/Lib/distutils/util.py (original) +++ python/trunk/Lib/distutils/util.py Tue May 23 14:01:11 2006 @@ -67,6 +67,54 @@ m = rel_re.match(release) if m: release = m.group() + elif osname[:6] == "darwin": + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + from distutils.sysconfig import get_config_vars + cfgvars = get_config_vars() + + macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET') + if not macver: + macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') + + if not macver: + # Get the system version. Reading this plist is a documented + # way to get the system version (see the documentation for + # the Gestalt Manager) + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + m = re.search( + r'ProductUserVisibleVersion\s*' + + r'(.*?)', f.read()) + f.close() + if m is not None: + macver = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + if macver: + from distutils.sysconfig import get_config_vars + release = macver + osname = "macosx" + + + if (release + '.') < '10.4.' and \ + get_config_vars().get('UNIVERSALSDK', '').strip(): + # The universal build will build fat binaries, but not on + # systems before 10.4 + machine = 'fat' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + machine = 'ppc' return "%s-%s-%s" % (osname, release, machine) From python-checkins at python.org Tue May 23 14:07:27 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 14:07:27 +0200 (CEST) Subject: [Python-checkins] r46105 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h sandbox/trunk/decimal-c/decimal.py Message-ID: <20060523120727.38CBD1E4009@bag.python.org> Author: georg.brandl Date: Tue May 23 14:07:26 2006 New Revision: 46105 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h sandbox/trunk/decimal-c/decimal.py Log: Don't use the PyObject_VAR machinery any longer. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 14:07:26 2006 @@ -181,18 +181,26 @@ static decimalobject * -_new_decimalobj(Py_ssize_t ndigits, char sign, long exp) +_new_decimalobj(long ndigits, char sign, long exp) { decimalobject *new; - if (ndigits > PY_SSIZE_T_MAX) { + char *arr; + if (ndigits > LONG_MAX) { PyErr_NoMemory(); return NULL; } - new = (decimalobject *)PyObject_NEW_VAR(decimalobject, &PyDecimal_DecimalType, ndigits); + arr = PyObject_MALLOC(ndigits); + if (!arr) { + PyErr_NoMemory(); + return NULL; + } + new = (decimalobject *)PyObject_NEW(decimalobject, &PyDecimal_DecimalType); if (new == NULL) return NULL; new->sign = sign; new->exp = exp; + new->ob_size = ndigits; + new->digits = arr; return new; } @@ -249,13 +257,14 @@ static decimalobject * _decimal_increment(decimalobject *self, long prec, contextobject *ctx) { + /* XXX */ } /* Round towards 0, that is, truncate digits. */ static decimalobject * _round_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) { - Py_ssize_t i; + long i; decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); if (!new) return NULL; for (i = 0; i < prec; i++) @@ -267,9 +276,9 @@ static decimalobject * _round_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) { - Py_ssize_t i; + long i; decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); - decimalobject *new2; + decimalobject *new2 = NULL; if (!new) return NULL; for (i = 0; i < prec; i++) new->digits[i] = self->digits[i]; @@ -290,27 +299,54 @@ } /* Actually round half up. Returns a new reference, either on tmp - * or a new decimalobject. */ + * or a new decimalobject, and steals one reference on tmp in turn, + * if it was passed in so that you can just do + * return _do_round_half_up(...) */ static decimalobject * _do_round_half_up(decimalobject *self, long prec, long expdiff, contextobject *ctx, decimalobject *tmp) { - Py_ssize_t i; + decimalobject *new; + long i; if (!tmp) { tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; for (i = 0; i < prec; i++) tmp->digits[i] = self->digits[i]; } - /*if (self->ob_size > prec && self->digits[prec] >= 5) {*/ - + if (self->ob_size > prec && self->digits[prec] >= 5) { + new = _decimal_increment(tmp, 1, ctx); + Py_DECREF(tmp); + if (!new) return NULL; + if (new->ob_size > prec) { + new->ob_size--; + new->exp++; + } + return new; + } else { + return tmp; + } } /* Round 5 down. */ static decimalobject * _round_half_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) { - + long i; + decimalobject *tmp; + tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + if (!tmp) return NULL; + for (i = 0; i < prec; i++) + tmp->digits[i] = self->digits[i]; + if (self->digits[prec] == 5) { + for (i = prec+1; i < self->ob_size; i++) { + if (self->digits[i] != 0) + return _do_round_half_up(self, prec, expdiff, ctx, tmp); + } + /* self ends in 5000...., so tmp is okay */ + return tmp; + } + return _do_round_half_up(self, prec, expdiff, ctx, tmp); } static decimalobject * @@ -348,7 +384,7 @@ { decimalobject *new, *new2 = NULL, *errres; contextobject *ctx2 = NULL; - Py_ssize_t i, expdiff; + long i, expdiff; round_func rnd_func; if (ISSPECIAL(self)) { @@ -482,10 +518,10 @@ _decimal_rescale(decimalobject *self, long exp, contextobject *ctx, int rounding, int watchexp) { - decimalobject *ans = NULL, *tmp, *tmp2; + decimalobject *ans = NULL, *tmp; int ret; long diff, adj; - Py_ssize_t digits, i; + long digits, i; if (ISSPECIAL(self)) { if (ISINF(self)) @@ -833,7 +869,7 @@ decimal_copy(decimalobject *self) { decimalobject *new; - Py_ssize_t size = self->ob_size; + long size = self->ob_size; new = _new_decimalobj(size, self->sign, self->exp); if (!new) @@ -857,7 +893,7 @@ decimal_as_tuple(decimalobject *self) { PyObject *digits, *res, *d; - Py_ssize_t i; + long i; digits = PyTuple_New(self->ob_size); if (!digits) @@ -1019,7 +1055,7 @@ int _decimal_isint(decimalobject *d) { - Py_ssize_t i; + long i; if (d->exp >= 0) /* if the exponent is positive, there's no @@ -1035,17 +1071,19 @@ } static void -decimal_dealloc(PyObject *d) +decimal_dealloc(decimalobject *d) { + PyObject_FREE(d->digits); d->ob_type->tp_free(d); } static decimalobject * -_decimal_fromliteralnan(char *str, Py_ssize_t len, contextobject *ctx) +_decimal_fromliteralnan(char *str, long len, contextobject *ctx) { + /* XXX: what if buffer is longer than LONG_MAX? */ char literalsign = 0, sign = 0; decimalobject *new; - Py_ssize_t size = 0, i; + long size = 0, i; char *start = NULL, *p; if (len < 3) @@ -1128,16 +1166,15 @@ } static decimalobject * -_decimal_fromliteral(char *str, Py_ssize_t len, contextobject *ctx) +_decimal_fromliteral(char *str, long len, contextobject *ctx) { - Py_ssize_t ipos = 0; /* start of integral digits */ - Py_ssize_t dpos = -1; /* decimal point location */ - Py_ssize_t dend = len; /* end of integral/decimal digits */ + long ipos = 0; /* start of integral digits */ + long dpos = -1; /* decimal point location */ + long dend = len; /* end of integral/decimal digits */ char *p = str; char sign = 0; decimalobject *new; - long exp = 0; - Py_ssize_t i = 0, ndigits; + long exp = 0, i = 0, ndigits; /* optional sign */ if (*p == '+') { @@ -1207,7 +1244,7 @@ } PyObject * -PyDecimal_FromString(char *buffer, Py_ssize_t buf_len, contextobject *ctx) +PyDecimal_FromString(char *buffer, long buf_len, contextobject *ctx) { decimalobject *new; @@ -1262,8 +1299,7 @@ decimalobject *new = NULL; PyObject *tup, *digits, *digtup = NULL, *item; int sign; - long exp; - Py_ssize_t i; + long i, exp; if (PyTuple_Check(seq)) { tup = seq; @@ -1387,6 +1423,11 @@ /* try buffer interface (e.g. strings and unicode) */ if (PyObject_AsCharBuffer(value, (const char **)&buffer, &buf_len) == 0) { + if (buf_len > LONG_MAX) { + PyErr_NoMemory(); + if (decref_value) { Py_DECREF(value); } + return NULL; + } PyObject *res = (PyObject *)PyDecimal_FromString(buffer, buf_len, ctx); if (decref_value) { Py_DECREF(value); @@ -1417,7 +1458,7 @@ /* XXX: quick hack */ char buf[1000]; char dig[2]; - Py_ssize_t i; + long i; dig[1] = 0; PyOS_snprintf(buf, 1000, "sign=%i, exp=%ld, digits=", d->sign, d->exp); @@ -1487,6 +1528,40 @@ return hash; } +/* XXX: just for debugging? */ +static PyMemberDef _decimal_members[] = { + {"_sign", T_INT, offsetof(decimalobject, sign), 0}, + {"_exp", T_LONG, offsetof(decimalobject, exp), 0}, + {NULL} +}; + +static PyObject * +_decimal_get_int(decimalobject *self) +{ + PyObject *tup; + long i; + tup = PyTuple_New(self->ob_size); + if (!tup) return NULL; + for (i = 0; i < self->ob_size; i++) + PyTuple_SET_ITEM(tup, i, PyInt_FromLong(self->digits[i])); + return tup; +} + +static PyObject * +_decimal_is_special(decimalobject *self) +{ + if (ISSPECIAL(self)) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyGetSetDef _decimal_getset[] = { + {"_int", (getter)_decimal_get_int, 0}, + {"_is_special", (getter)_decimal_is_special, 0}, + {NULL} +}; + static PyTypeObject PyDecimal_DecimalType = { PyObject_HEAD_INIT(NULL) @@ -1519,8 +1594,8 @@ 0, /* tp_iter */ 0, /* tp_iternext */ decimal_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ + _decimal_members, /* tp_members */ + _decimal_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ Modified: sandbox/trunk/decimal-c/decimal.h ============================================================================== --- sandbox/trunk/decimal-c/decimal.h (original) +++ sandbox/trunk/decimal-c/decimal.h Tue May 23 14:07:26 2006 @@ -10,10 +10,11 @@ /* decimalobject struct ******************************************************/ typedef struct { - PyObject_VAR_HEAD + PyObject_HEAD + long ob_size; /* number of digits */ unsigned int sign; /* see sign contstants above */ long exp; - signed char digits[1]; /* digits are stored as the actual numbers 0-9 */ + signed char *digits; /* digits are stored as the actual numbers 0-9 */ } PyDecimalObject; static PyTypeObject PyDecimal_DecimalType; Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Tue May 23 14:07:26 2006 @@ -466,114 +466,117 @@ class Decimal(_decimal.Decimal): """Floating point class for decimal arithmetic.""" - __slots__ = ('_exp','_int','_sign', '_is_special') # Generally, the value of the Decimal instance is given by # (-1)**_sign * _int * 10**_exp # Special values are signified by _is_special == True - # We're immutable, so use __new__ not __init__ - def __new__(cls, value="0", context=None): - """Create a decimal point instance. - - >>> Decimal('3.14') # string input - Decimal("3.14") - >>> Decimal((0, (3, 1, 4), -2)) # tuple input (sign, digit_tuple, exponent) - Decimal("3.14") - >>> Decimal(314) # int or long - Decimal("314") - >>> Decimal(Decimal(314)) # another decimal instance - Decimal("314") - """ - - self = object.__new__(cls) - self._is_special = False - - # From an internal working value - if isinstance(value, _WorkRep): - self._sign = value.sign - self._int = tuple(map(int, str(value.int))) - self._exp = int(value.exp) - return self - - # From another decimal - if isinstance(value, Decimal): - self._exp = value._exp - self._sign = value._sign - self._int = value._int - self._is_special = value._is_special - return self - - # From an integer - if isinstance(value, (int,long)): - if value >= 0: - self._sign = 0 - else: - self._sign = 1 - self._exp = 0 - self._int = tuple(map(int, str(abs(value)))) - return self - - # tuple/list conversion (possibly from as_tuple()) - if isinstance(value, (list,tuple)): - if len(value) != 3: - raise ValueError, 'Invalid arguments' - if value[0] not in (0,1): - raise ValueError, 'Invalid sign' - for digit in value[1]: - if not isinstance(digit, (int,long)) or digit < 0: - raise ValueError, "The second value in the tuple must be composed of non negative integer elements." - - self._sign = value[0] - self._int = tuple(value[1]) - if value[2] in ('F','n','N'): - self._exp = value[2] - self._is_special = True - else: - self._exp = int(value[2]) - return self - - if isinstance(value, float): - raise TypeError("Cannot convert float to Decimal. " + - "First convert the float to a string") - - # Other argument types may require the context during interpretation - if context is None: - context = getcontext() - - # From a string - # REs insist on real strings, so we can too. - if isinstance(value, basestring): - if _isinfinity(value): - self._exp = 'F' - self._int = (0,) - self._is_special = True - if _isinfinity(value) == 1: - self._sign = 0 - else: - self._sign = 1 - return self - if _isnan(value): - sig, sign, diag = _isnan(value) - self._is_special = True - if len(diag) > context.prec: #Diagnostic info too long - self._sign, self._int, self._exp = \ - context._raise_error(ConversionSyntax) - return self - if sig == 1: - self._exp = 'n' #qNaN - else: #sig == 2 - self._exp = 'N' #sNaN - self._sign = sign - self._int = tuple(map(int, diag)) #Diagnostic info - return self - try: - self._sign, self._int, self._exp = _string2exact(value) - except ValueError: - self._is_special = True - self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) - return self - - raise TypeError("Cannot convert %r to Decimal" % value) + @property + def _is_special(self): + return (self._sign > 1) + +# # We're immutable, so use __new__ not __init__ +# def __new__(cls, value="0", context=None): +# """Create a decimal point instance. +# +# >>> Decimal('3.14') # string input +# Decimal("3.14") +# >>> Decimal((0, (3, 1, 4), -2)) # tuple input (sign, digit_tuple, exponent) +# Decimal("3.14") +# >>> Decimal(314) # int or long +# Decimal("314") +# >>> Decimal(Decimal(314)) # another decimal instance +# Decimal("314") +# """ +# +# self = _decimal.Decimal.__new__(cls) +# self._is_special = False +# +# # From an internal working value +# if isinstance(value, _WorkRep): +# self._sign = value.sign +# self._int = tuple(map(int, str(value.int))) +# self._exp = int(value.exp) +# return self +# +# # From another decimal +# if isinstance(value, Decimal): +# self._exp = value._exp +# self._sign = value._sign +# self._int = value._int +# self._is_special = value._is_special +# return self +# +# # From an integer +# if isinstance(value, (int,long)): +# if value >= 0: +# self._sign = 0 +# else: +# self._sign = 1 +# self._exp = 0 +# self._int = tuple(map(int, str(abs(value)))) +# return self +# +# # tuple/list conversion (possibly from as_tuple()) +# if isinstance(value, (list,tuple)): +# if len(value) != 3: +# raise ValueError, 'Invalid arguments' +# if value[0] not in (0,1): +# raise ValueError, 'Invalid sign' +# for digit in value[1]: +# if not isinstance(digit, (int,long)) or digit < 0: +# raise ValueError, "The second value in the tuple must be composed of non negative integer elements." +# +# self._sign = value[0] +# self._int = tuple(value[1]) +# if value[2] in ('F','n','N'): +# self._exp = value[2] +# self._is_special = True +# else: +# self._exp = int(value[2]) +# return self +# +# if isinstance(value, float): +# raise TypeError("Cannot convert float to Decimal. " + +# "First convert the float to a string") +# +# # Other argument types may require the context during interpretation +# if context is None: +# context = getcontext() +# +# # From a string +# # REs insist on real strings, so we can too. +# if isinstance(value, basestring): +# if _isinfinity(value): +# self._exp = 'F' +# self._int = (0,) +# self._is_special = True +# if _isinfinity(value) == 1: +# self._sign = 0 +# else: +# self._sign = 1 +# return self +# if _isnan(value): +# sig, sign, diag = _isnan(value) +# self._is_special = True +# if len(diag) > context.prec: #Diagnostic info too long +# self._sign, self._int, self._exp = \ +# context._raise_error(ConversionSyntax) +# return self +# if sig == 1: +# self._exp = 'n' #qNaN +# else: #sig == 2 +# self._exp = 'N' #sNaN +# self._sign = sign +# self._int = tuple(map(int, diag)) #Diagnostic info +# return self +# try: +# self._sign, self._int, self._exp = _string2exact(value) +# except ValueError: +# self._is_special = True +# self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) +# return self +# +# raise TypeError("Cannot convert %r to Decimal" % value) def _isnan(self): """Returns whether the number is not actually one. From python-checkins at python.org Tue May 23 14:15:15 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 14:15:15 +0200 (CEST) Subject: [Python-checkins] r46106 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523121515.17A7D1E401D@bag.python.org> Author: georg.brandl Date: Tue May 23 14:15:14 2006 New Revision: 46106 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Add accessor for self._int. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 14:15:14 2006 @@ -1547,6 +1547,44 @@ return tup; } +static int +_decimal_set_int(decimalobject *self, PyObject *value) +{ + long i, size, val; + char *arr; + PyObject *item; + if (!PyTuple_Check(value)) { + PyErr_SetString(PyExc_TypeError, "_int must be a tuple"); + return -1; + } + size = PyTuple_GET_SIZE(value); + arr = PyObject_MALLOC(size); + if (!arr) { + PyErr_NoMemory(); + return -1; + } + for (i = 0; i < PyTuple_GET_SIZE(value); i++) { + item = PyTuple_GET_ITEM(value, i); + if (!PyInt_Check(item)) { + PyObject_FREE(arr); + PyErr_SetString(PyExc_TypeError, "_int must consist of ints"); + return -1; + } + val = PyInt_AsLong(item); + if (val < 0 || val > 9) { + PyObject_FREE(arr); + PyErr_SetString(PyExc_TypeError, "_int digits must be 0-9"); + return NULL; + } + arr[i] = val; + } + + PyObject_FREE(self->digits); + self->ob_size = size; + self->digits = arr; + return 0; +} + static PyObject * _decimal_is_special(decimalobject *self) { @@ -1557,7 +1595,7 @@ } static PyGetSetDef _decimal_getset[] = { - {"_int", (getter)_decimal_get_int, 0}, + {"_int", (getter)_decimal_get_int, (setter)_decimal_set_int}, {"_is_special", (getter)_decimal_is_special, 0}, {NULL} }; From python-checkins at python.org Tue May 23 14:38:51 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 14:38:51 +0200 (CEST) Subject: [Python-checkins] r46107 - peps/trunk/pep-0291.txt Message-ID: <20060523123851.A55491E4009@bag.python.org> Author: andrew.kuchling Date: Tue May 23 14:38:51 2006 New Revision: 46107 Modified: peps/trunk/pep-0291.txt Log: Typo fix Modified: peps/trunk/pep-0291.txt ============================================================================== --- peps/trunk/pep-0291.txt (original) +++ peps/trunk/pep-0291.txt Tue May 23 14:38:51 2006 @@ -120,7 +120,7 @@ unless compelling advantages arise. [3] pybench lives under the Tools/ directory. Compatibility with - older Python version is needed in order to be able to compare + older Python versions is needed in order to be able to compare performance between Python versions. New features may still be used in new tests, which may then be configured to fail gracefully on import by the tool in older Python versions. From python-checkins at python.org Tue May 23 14:44:37 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 14:44:37 +0200 (CEST) Subject: [Python-checkins] r46108 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060523124437.345B91E4009@bag.python.org> Author: andrew.kuchling Date: Tue May 23 14:44:36 2006 New Revision: 46108 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add some items; mention the sprint Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 23 14:44:36 2006 @@ -1120,6 +1120,13 @@ %====================================================================== \subsection{Optimizations\label{opts}} +Several of the optimizations were developed at the NeedForSpeed +sprint, an event held in Reykjavik, Iceland, from May 21--28 2006. +The sprint focused on speed enhancements to the CPython implementation +and was funded by EWT LLC with local support from CCP Games. Those +optimizations added at this sprint are specially marked in the +following list. + \begin{itemize} \item When they were introduced @@ -1138,6 +1145,13 @@ \code{a = 2+3}, the code generator will do the arithmetic and produce code corresponding to \code{a = 5}. +\item Function calls are now faster because code objects now keep +the most recently finished frame (a ``zombie frame'') in an internal +field of the code object, reusing it the next time the code object is +invoked. (Original patch by Michael Hudson, modified by Armin Rigo +and Richard Jones; committed at the NeedForSpeed sprint.) +% Patch 876206 + \end{itemize} The net result of the 2.5 optimizations is that Python 2.5 runs the @@ -1935,6 +1949,10 @@ \code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}. (Contributed by Barry Warsaw.) +\item \cfunction{PyErr_NewException(\var{name}, \var{base}, +\var{dict})} can now accept a tuple of base classes as its \var{base} +argument. (Contributed by Georg Brandl.) + \item The CPython interpreter is still written in C, but the code can now be compiled with a {\Cpp} compiler without errors. (Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.) From python-checkins at python.org Tue May 23 14:47:03 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 14:47:03 +0200 (CEST) Subject: [Python-checkins] r46109 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060523124703.1BA081E401A@bag.python.org> Author: andrew.kuchling Date: Tue May 23 14:47:01 2006 New Revision: 46109 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Mention string improvements Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 23 14:47:01 2006 @@ -1137,7 +1137,10 @@ (Implemented by Raymond Hettinger.) \item The performance of some Unicode operations, such as -character map decoding, has been improved. +finding substrings and character map decoding, has been improved. +(Substring search improvements were added by Fredrik Lundh and Andrew +Dalke at the NeedForSpeed sprint. Character map decoding was improved +by Walter D\"orwald.) % Patch 1313939 \item The code generator's peephole optimizer now performs From python-checkins at python.org Tue May 23 14:49:36 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 14:49:36 +0200 (CEST) Subject: [Python-checkins] r46110 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060523124936.1A2171E4009@bag.python.org> Author: andrew.kuchling Date: Tue May 23 14:49:35 2006 New Revision: 46110 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Use 'speed' instead of 'performance', because I agree with the argument at http://zestyping.livejournal.com/193260.html that 'erformance' really means something more general. Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 23 14:49:35 2006 @@ -1136,7 +1136,7 @@ and as a result sets will use a third less memory and are somewhat faster. (Implemented by Raymond Hettinger.) -\item The performance of some Unicode operations, such as +\item The speed of some Unicode operations, such as finding substrings and character map decoding, has been improved. (Substring search improvements were added by Fredrik Lundh and Andrew Dalke at the NeedForSpeed sprint. Character map decoding was improved @@ -1428,7 +1428,7 @@ included in the \file{Tools/pybench} directory. The pybench suite is an improvement on the commonly used \file{pystone.py} program because pybench provides a more detailed measurement of the interpreter's -performance. It times particular operations such as function calls, +speed. It times particular operations such as function calls, tuple slicing, method lookups, and numeric operations, instead of performing many different operations and reducing the result to a single number as \file{pystone.py} does. From buildbot at python.org Tue May 23 14:59:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 12:59:17 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060523125917.382F81E4009@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/165 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,richard.jones,ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 16:06:03 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 16:06:03 +0200 (CEST) Subject: [Python-checkins] r46111 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523140603.C13E41E4022@bag.python.org> Author: georg.brandl Date: Tue May 23 16:06:03 2006 New Revision: 46111 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Finish rounding functions. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 16:06:03 2006 @@ -1,6 +1,8 @@ /* C implementation of the decimal module. * * Partly written in Iceland by Georg Brandl. + * + * vim:ts=4:sw=4:et:si */ #include "Python.h" @@ -254,10 +256,53 @@ return 0; } +/* add 1eExponent. This is more efficient than add, used in rounding. */ static decimalobject * -_decimal_increment(decimalobject *self, long prec, contextobject *ctx) +_decimal_increment(decimalobject *self, int round, contextobject *ctx) { - /* XXX */ + long spot; + decimalobject *new; + + if (ISSPECIAL(self)) { + decimalobject *nan; + int res; + res = _check_nans(self, NULL, ctx, &nan); + if (res != 0) return nan; + + /* I'm infinite, so incrementing makes no difference. */ + return decimal_copy(self); + } + + new = _new_decimalobj(self->ob_size + 1, /* we possibly need a new digit */ + self->sign, self->exp); + if (!new) return NULL; + + /* determine if we need a new digit */ + for (spot = 0; spot < self->ob_size; spot++) { + if (self->digits[spot] != 9) { + spot = -1; + break; + } + } + if (spot != -1) { + /* no new digit needed */ + new->ob_size--; + for (spot = 0; spot < self->ob_size; spot++) + new->digits[spot] = self->digits[spot]; + } else { + for (spot = 0; spot < self->ob_size; spot++) + new->digits[spot+1] = self->digits[spot]; + } + + spot = new->ob_size-1; + new->digits[spot]++; + while (new->digits[spot] == 10) { + new->digits[spot] = 0; + spot--; + assert(spot >= 0); + new->digits[spot]++; + } + return new; } /* Round towards 0, that is, truncate digits. */ @@ -308,6 +353,7 @@ { decimalobject *new; long i; + assert(expdiff > 0); if (!tmp) { tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; @@ -334,6 +380,7 @@ { long i; decimalobject *tmp; + assert(expdiff > 0); tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; for (i = 0; i < prec; i++) @@ -352,6 +399,22 @@ static decimalobject * _round_half_even(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + decimalobject *tmp; + long i; + assert(expdiff > 0); + tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + if (!tmp) return NULL; + for (i = 0; i < prec; i++) + tmp->digits[i] = self->digits[i]; + if (self->digits[prec] == 5) { + for (i = prec+1; i < self->ob_size; i++) { + if (self->digits[i] != 0) + return _do_round_half_up(self, prec, expdiff, ctx, tmp); + } + if ((self->digits[prec-1] & 1) == 0) + return tmp; + } + return _do_round_half_up(self, prec, expdiff, ctx, tmp); } /* Round 5 up (away from 0). */ @@ -361,15 +424,26 @@ return _do_round_half_up(self, prec, expdiff, ctx, NULL); } +/* Round up (regardless of sign) */ static decimalobject * _round_floor(decimalobject *self, long prec, long expdiff, contextobject *ctx) { + assert(self->sign <= 1); + if (self->sign > 0) + return _round_down(self, prec, expdiff, ctx); + else + return _round_up(self, prec, expdiff, ctx); } +/* Round down (regardless of sign) */ static decimalobject * _round_ceiling(decimalobject *self, long prec, long expdiff, contextobject *ctx) { - + assert(self->sign <= 1); + if (self->sign > 0) + return _round_up(self, prec, expdiff, ctx); + else + return _round_down(self, prec, expdiff, ctx); } typedef decimalobject*(*round_func)(decimalobject *, long, long, contextobject *); @@ -997,7 +1071,11 @@ static int decimal_nonzero(decimalobject *self) { - /* XXX */ + long i; + if (ISSPECIAL(self)) + return 1; + for (i = 0; i < self->ob_size; i++) + if (i != 0) return 1; return 0; } @@ -1080,7 +1158,6 @@ static decimalobject * _decimal_fromliteralnan(char *str, long len, contextobject *ctx) { - /* XXX: what if buffer is longer than LONG_MAX? */ char literalsign = 0, sign = 0; decimalobject *new; long size = 0, i; @@ -1170,11 +1247,11 @@ { long ipos = 0; /* start of integral digits */ long dpos = -1; /* decimal point location */ - long dend = len; /* end of integral/decimal digits */ + long dend = len; /* end of integral/decimal digits (last digit+1) */ char *p = str; char sign = 0; decimalobject *new; - long exp = 0, i = 0, ndigits; + long exp = 0, i, ndigits; /* optional sign */ if (*p == '+') { @@ -1206,7 +1283,7 @@ if (ipos == dpos && dpos == dend-1) /* no digits at all */ goto err; - goto finish; + goto calculate; } else if (*p == '-' || *p == '+') { ++p; } @@ -1217,20 +1294,31 @@ goto err; } while (*++p); -finish: +calculate: if (dend < len) - /* XXX: which function to convert a string to ssize_t? */ exp = atol(str + dend + 1); if (dpos >= 0) /* specified fractional digits, reduce exp */ exp -= dend - dpos - 1; + /* If it's not a zero, strip leading 0s */ + for (p = str+ipos; p-str < dend; ++p) { + if (*p != '0' && *p != '.') { + /* first nonzero digit */ + ipos = (p-str); + goto finish; + } + } + /* it's a zero */ + dend = (dpos == ipos ? ipos+2 : ipos+1); + +finish: ndigits = dend - ipos - (dpos<0 ? 0 : 1); new = _new_decimalobj(ndigits, sign, exp); if (!new) return NULL; - /* XXX: leading zeroes are not stripped */ + i = 0; for (p = str+ipos; p-str < dend; ++p) { if (*p == '.') continue; new->digits[i] = *p - 48; @@ -1574,7 +1662,7 @@ if (val < 0 || val > 9) { PyObject_FREE(arr); PyErr_SetString(PyExc_TypeError, "_int digits must be 0-9"); - return NULL; + return -1; } arr[i] = val; } From python-checkins at python.org Tue May 23 16:49:57 2006 From: python-checkins at python.org (jack.diederich) Date: Tue, 23 May 2006 16:49:57 +0200 (CEST) Subject: [Python-checkins] r46112 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523144957.615F01E4009@bag.python.org> Author: jack.diederich Date: Tue May 23 16:49:56 2006 New Revision: 46112 Modified: sandbox/trunk/decimal-c/_decimal.c Log: * added context_shallow_copy Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 16:49:56 2006 @@ -178,6 +178,8 @@ static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); static int decimal_nonzero(decimalobject *); static decimalobject *decimal_copy(decimalobject *); +static PyObject * py_context_shallow_copy(PyObject *, PyObject *, PyObject *); +static contextobject * context_shallow_copy(contextobject *); /* Decimal methods ***********************************************************/ @@ -558,7 +560,7 @@ /* Now rounding starts. We still own "new". */ rnd_func = round_funcs[rounding]; if (prec != ctx->prec) { - ctx2 = _context_shallow_copy(ctx); + ctx2 = (contextobject *)context_shallow_copy(ctx); if (!ctx2) { Py_DECREF(new); return NULL; @@ -1929,6 +1931,23 @@ return PyInt_FromSsize_t(ETOP(self)); } +static contextobject * +context_shallow_copy(contextobject *ctx) +{ + contextobject *cp = _new_contextobj(ctx->prec, ctx->rounding, + ctx->rounding_dec, ctx->traps, + ctx->flags, ctx->Emin, ctx->Emax, + ctx->capitals, ctx->clamp, + ctx->ignored); + return cp; +} + +static PyObject * +py_context_shallow_copy(PyObject *self, PyObject *args, PyObject *kwds) +{ + return (PyObject *)context_shallow_copy((contextobject *)self); +} + CSTUB(abs) CSTUB(add) CSTUB(compare) @@ -2007,6 +2026,8 @@ METH_VARARGS | METH_KEYWORDS}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, + {"_shallow_copy", (PyCFunction)py_context_shallow_copy, + METH_NOARGS}, {NULL, NULL} }; From python-checkins at python.org Tue May 23 17:09:58 2006 From: python-checkins at python.org (ronald.oussoren) Date: Tue, 23 May 2006 17:09:58 +0200 (CEST) Subject: [Python-checkins] r46113 - in python/trunk/Mac/OSX/BuildScript: README.txt build-installer.py ncurses-5.5.patch resources resources/ReadMe.txt resources/Welcome.rtf resources/background.jpg scripts scripts/postflight.documentation scripts/postflight.framework scripts/postflight.patch-profile Message-ID: <20060523150958.DC8C41E4009@bag.python.org> Author: ronald.oussoren Date: Tue May 23 17:09:57 2006 New Revision: 46113 Added: python/trunk/Mac/OSX/BuildScript/ python/trunk/Mac/OSX/BuildScript/README.txt python/trunk/Mac/OSX/BuildScript/build-installer.py (contents, props changed) python/trunk/Mac/OSX/BuildScript/ncurses-5.5.patch python/trunk/Mac/OSX/BuildScript/resources/ python/trunk/Mac/OSX/BuildScript/resources/ReadMe.txt python/trunk/Mac/OSX/BuildScript/resources/Welcome.rtf python/trunk/Mac/OSX/BuildScript/resources/background.jpg (contents, props changed) python/trunk/Mac/OSX/BuildScript/scripts/ python/trunk/Mac/OSX/BuildScript/scripts/postflight.documentation (contents, props changed) python/trunk/Mac/OSX/BuildScript/scripts/postflight.framework (contents, props changed) python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile (contents, props changed) Log: An improved script for building the binary distribution on MacOSX. Added: python/trunk/Mac/OSX/BuildScript/README.txt ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/README.txt Tue May 23 17:09:57 2006 @@ -0,0 +1,35 @@ +Building a MacPython distribution +================================= + +The ``build-install.py`` script creates MacPython distributions, including +sleepycat db4, sqlite3 and readline support. It builds a complete +framework-based Python out-of-tree, installs it in a funny place with +$DESTROOT, massages that installation to remove .pyc files and such, creates +an Installer package from the installation plus other files in ``resources`` +and ``scripts`` and placed that on a ``.dmg`` disk image. + +Here are the steps you ned to follow to build a MacPython installer: + +- Run ``./build-installer.py``. Optionally you can pass a number of arguments + to specify locations of various files. Please see the top of + ``build-installer.py`` for its usage. +- When done the script will tell you where the DMG image is. + +The script needs to be run on Mac OS X 10.4 with Xcode 2.2 or later and +the 10.4u SDK. + +When all is done, announcements can be posted to at least the following +places: +- pythonmac-sig at python.org +- python-dev at python.org +- python-announce at python.org +- archivist at info-mac.org +- adcnews at apple.com +- news at macnn.com +- http://www.macupdate.com +- http://guide.apple.com/usindex.lasso +- http://www.apple.com/downloads/macosx/submit +- http://www.versiontracker.com/ (userid Jack.Jansen at oratrix.com) +- http://www.macshareware.net (userid jackjansen) + +Also, check out Stephan Deibels http://pythonology.org/market contact list Added: python/trunk/Mac/OSX/BuildScript/build-installer.py ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/build-installer.py Tue May 23 17:09:57 2006 @@ -0,0 +1,1013 @@ +#!/usr/bin/python2.3 +""" +This script is used to build the "official unofficial" universal build on +Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its +work. + +Please ensure that this script keeps working with Python 2.3, to avoid +bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) + +Usage: see USAGE variable in the script. +""" +import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd + +INCLUDE_TIMESTAMP=1 +VERBOSE=1 + +from plistlib import Plist + +import MacOS +import Carbon.File +import Carbon.Icn +import Carbon.Res +from Carbon.Files import kCustomIconResource, fsRdWrPerm, kHasCustomIcon +from Carbon.Files import kFSCatInfoFinderInfo + +try: + from plistlib import writePlist +except ImportError: + # We're run using python2.3 + def writePlist(plist, path): + plist.write(path) + +def shellQuote(value): + """ + Return the string value in a form that can savely be inserted into + a shell command. + """ + return "'%s'"%(value.replace("'", "'\"'\"'")) + +def grepValue(fn, variable): + variable = variable + '=' + for ln in open(fn, 'r'): + if ln.startswith(variable): + value = ln[len(variable):].strip() + return value[1:-1] + +def getVersion(): + return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + +def getFullVersion(): + fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') + for ln in open(fn): + if 'PY_VERSION' in ln: + return ln.split()[-1][1:-1] + + raise RuntimeError, "Cannot find full version??" + +# The directory we'll use to create the build, will be erased and recreated +WORKDIR="/tmp/_py" + +# The directory we'll use to store third-party sources, set this to something +# else if you don't want to re-fetch required libraries every time. +DEPSRC=os.path.join(WORKDIR, 'third-party') +DEPSRC=os.path.expanduser('~/Universal/other-sources') + +# Location of the preferred SDK +SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" +#SDKPATH="/" + +# Source directory (asume we're in Mac/OSX/Dist) +SRCDIR=os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.abspath(__file__ + ))))) + +USAGE=textwrap.dedent("""\ + Usage: build_python [options] + + Options: + -? or -h: Show this message + -b DIR + --build-dir=DIR: Create build here (default: %(WORKDIR)r) + --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) + --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) + --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) +""")% globals() + + +# Instructions for building libraries that are necessary for building a +# batteries included python. +LIBRARY_RECIPES=[ + dict( + # Note that GNU readline is GPL'd software + name="GNU Readline 5.1.4", + url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" , + patchlevel='0', + patches=[ + # The readline maintainers don't do actual micro releases, but + # just ship a set of patches. + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004', + ] + ), + + dict( + name="SQLite 3.3.5", + url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", + checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', + configure_pre=[ + '--enable-threadsafe', + '--enable-tempstore', + '--enable-shared=no', + '--enable-static=yes', + '--disable-tcl', + ] + ), + + dict( + name="NCurses 5.5", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", + configure_pre=[ + "--without-cxx", + "--without-ada", + "--without-progs", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + "--enable-termcap", + ], + patches=[ + "ncurses-5.5.patch", + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="Sleepycat DB 4.4", + url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", + #name="Sleepycat DB 4.3.29", + #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", + buildDir="build_unix", + configure="../dist/configure", + configure_pre=[ + '--includedir=/usr/local/include/db4', + ] + ), +] + + +# Instructions for building packages inside the .mpkg. +PKG_RECIPES=[ + dict( + name="PythonFramework", + long_name="Python Framework", + source="/Library/Frameworks/Python.framework", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + postflight="scripts/postflight.framework", + ), + dict( + name="PythonApplications", + long_name="GUI Applications", + source="/Applications/MacPython %(VER)s", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + required=False, + ), + dict( + name="PythonUnixTools", + long_name="UNIX command-line tools", + source="/usr/local/bin", + readme="""\ + This package installs the unix tools in /usr/local/bin for + compatibility with older releases of MacPython. This package + is not necessary to use MacPython. + """, + required=False, + ), + dict( + name="PythonDocumentation", + long_name="Python Documentation", + topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", + source="/pydocs", + readme="""\ + This package installs the python documentation at a location + that is useable for pydoc and IDLE. If you have installed Xcode + it will also install a link to the documentation in + /Developer/Documentation/Python + """, + postflight="scripts/postflight.documentation", + required=False, + ), + dict( + name="PythonProfileChanges", + long_name="Shell profile updater", + readme="""\ + This packages updates your shell profile to make sure that + the MacPython tools are found by your shell in preference of + the system provided Python tools. + + If you don't install this package you'll have to add + "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" + to your PATH by hand. + """, + postflight="scripts/postflight.patch-profile", + topdir="/Library/Frameworks/Python.framework", + source="/empty-dir", + required=False, + ), +] + + +def fatal(msg): + """ + A fatal error, bail out. + """ + sys.stderr.write('FATAL: ') + sys.stderr.write(msg) + sys.stderr.write('\n') + sys.exit(1) + +def fileContents(fn): + """ + Return the contents of the named file + """ + return open(fn, 'rb').read() + +def runCommand(commandline): + """ + Run a command and raise RuntimeError if it fails. Output is surpressed + unless the command fails. + """ + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + if VERBOSE: + sys.stdout.write(data); sys.stdout.flush() + +def captureCommand(commandline): + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + return data + +def checkEnvironment(): + """ + Check that we're running on a supported system. + """ + + if platform.system() != 'Darwin': + fatal("This script should be run on a Mac OS X 10.4 system") + + if platform.release() <= '8.': + fatal("This script should be run on a Mac OS X 10.4 system") + + if not os.path.exists(SDKPATH): + fatal("Please install the latest version of Xcode and the %s SDK"%( + os.path.basename(SDKPATH[:-4]))) + + + +def parseOptions(args = None): + """ + Parse arguments and update global settings. + """ + global WORKDIR, DEPSRC, SDKPATH, SRCDIR + + if args is None: + args = sys.argv[1:] + + try: + options, args = getopt.getopt(args, '?hb', + [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) + except getopt.error, msg: + print msg + sys.exit(1) + + if args: + print "Additional arguments" + sys.exit(1) + + for k, v in options: + if k in ('-h', '-?'): + print USAGE + sys.exit(0) + + elif k in ('-d', '--build-dir'): + WORKDIR=v + + elif k in ('--third-party',): + DEPSRC=v + + elif k in ('--sdk-path',): + SDKPATH=v + + elif k in ('--src-dir',): + SRCDIR=v + + else: + raise NotImplementedError, k + + SRCDIR=os.path.abspath(SRCDIR) + WORKDIR=os.path.abspath(WORKDIR) + SDKPATH=os.path.abspath(SDKPATH) + DEPSRC=os.path.abspath(DEPSRC) + + print "Settings:" + print " * Source directory:", SRCDIR + print " * Build directory: ", WORKDIR + print " * SDK location: ", SDKPATH + print " * third-party source:", DEPSRC + print "" + + + + +def extractArchive(builddir, archiveName): + """ + Extract a source archive into 'builddir'. Returns the path of the + extracted archive. + + XXX: This function assumes that archives contain a toplevel directory + that is has the same name as the basename of the archive. This is + save enough for anything we use. + """ + curdir = os.getcwd() + try: + os.chdir(builddir) + if archiveName.endswith('.tar.gz'): + retval = os.path.basename(archiveName[:-7]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar.bz2'): + retval = os.path.basename(archiveName[:-8]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.zip'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') + + data = fp.read() + xit = fp.close() + if xit is not None: + sys.stdout.write(data) + raise RuntimeError, "Cannot extract %s"%(archiveName,) + + return os.path.join(builddir, retval) + + finally: + os.chdir(curdir) + +KNOWNSIZES = { + "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, + "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, +} + +def downloadURL(url, fname): + """ + Download the contents of the url into the file. + """ + try: + size = os.path.getsize(fname) + except OSError: + pass + else: + if KNOWNSIZES.get(url) == size: + print "Using existing file for", url + return + fpIn = urllib2.urlopen(url) + fpOut = open(fname, 'wb') + block = fpIn.read(10240) + try: + while block: + fpOut.write(block) + block = fpIn.read(10240) + fpIn.close() + fpOut.close() + except: + try: + os.unlink(fname) + except: + pass + +def buildRecipe(recipe, basedir, archList): + """ + Build software using a recipe. This function does the + 'configure;make;make install' dance for C software, with a possibility + to customize this process, basically a poor-mans DarwinPorts. + """ + curdir = os.getcwd() + + name = recipe['name'] + url = recipe['url'] + configure = recipe.get('configure', './configure') + install = recipe.get('install', 'make && make install DESTDIR=%s'%( + shellQuote(basedir))) + + archiveName = os.path.split(url)[-1] + sourceArchive = os.path.join(DEPSRC, archiveName) + + if not os.path.exists(DEPSRC): + os.mkdir(DEPSRC) + + + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL(url, sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + print "Extracting archive for %s"%(name,) + buildDir=os.path.join(WORKDIR, '_bld') + if not os.path.exists(buildDir): + os.mkdir(buildDir) + + workDir = extractArchive(buildDir, sourceArchive) + os.chdir(workDir) + if 'buildDir' in recipe: + os.chdir(recipe['buildDir']) + + + for fn in recipe.get('patches', ()): + if fn.startswith('http://'): + # Download the patch before applying it. + path = os.path.join(DEPSRC, os.path.basename(fn)) + downloadURL(fn, path) + fn = path + + fn = os.path.join(curdir, fn) + runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), + shellQuote(fn),)) + + configure_args = [ + "--prefix=/usr/local", + "--enable-static", + "--disable-shared", + #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), + ] + + if 'configure_pre' in recipe: + args = list(recipe['configure_pre']) + if '--disable-static' in args: + configure_args.remove('--enable-static') + if '--enable-shared' in args: + configure_args.remove('--disable-shared') + configure_args.extend(args) + + if recipe.get('useLDFlags', 1): + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1], + ' -arch '.join(archList)), + ]) + else: + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + ]) + + if 'configure_post' in recipe: + configure_args = configure_args = list(recipe['configure_post']) + + configure_args.insert(0, configure) + configure_args = [ shellQuote(a) for a in configure_args ] + + print "Running configure for %s"%(name,) + runCommand(' '.join(configure_args) + ' 2>&1') + + print "Running install for %s"%(name,) + runCommand('{ ' + install + ' ;} 2>&1') + + print "Done %s"%(name,) + print "" + + os.chdir(curdir) + +def buildLibraries(): + """ + Build our dependencies into $WORKDIR/libraries/usr/local + """ + print "" + print "Building required libraries" + print "" + universal = os.path.join(WORKDIR, 'libraries') + os.mkdir(universal) + os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) + os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) + + for recipe in LIBRARY_RECIPES: + buildRecipe(recipe, universal, ('i386', 'ppc',)) + + + +def buildPythonDocs(): + # This stores the documentation as Resources/English.lproj/Docuentation + # inside the framwork. pydoc and IDLE will pick it up there. + print "Install python documentation" + rootDir = os.path.join(WORKDIR, '_root') + version = getVersion() + docdir = os.path.join(rootDir, 'pydocs') + + name = 'html-%s.tar.bz2'%(getFullVersion(),) + sourceArchive = os.path.join(DEPSRC, name) + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( + getFullVersion(), name), sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + extractArchive(os.path.dirname(docdir), sourceArchive) + os.rename( + os.path.join( + os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), + docdir) + + +def buildPython(): + print "Building a universal python" + + buildDir = os.path.join(WORKDIR, '_bld', 'python') + rootDir = os.path.join(WORKDIR, '_root') + + if os.path.exists(buildDir): + shutil.rmtree(buildDir) + if os.path.exists(rootDir): + shutil.rmtree(rootDir) + os.mkdir(buildDir) + os.mkdir(rootDir) + os.mkdir(os.path.join(rootDir, 'empty-dir')) + curdir = os.getcwd() + os.chdir(buildDir) + + # Not sure if this is still needed, the original build script + # claims that parts of the install assume python.exe exists. + os.symlink('python', os.path.join(buildDir, 'python.exe')) + + # Extract the version from the configure file, needed to calculate + # several paths. + version = getVersion() + + print "Running configure..." + runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( + shellQuote(os.path.join(SRCDIR, 'configure')), + shellQuote(SDKPATH), shellQuote(WORKDIR), + shellQuote(WORKDIR))) + + print "Running make" + runCommand("make") + + print "Runing make frameworkinstall" + runCommand("make frameworkinstall DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Runing make frameworkinstallextras" + runCommand("make frameworkinstallextras DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Copy required shared libraries" + if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): + runCommand("mv %s/* %s"%( + shellQuote(os.path.join( + WORKDIR, 'libraries', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')), + shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')))) + + print "Fix file modes" + frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') + for dirpath, dirnames, filenames in os.walk(frmDir): + for dn in dirnames: + os.chmod(os.path.join(dirpath, dn), 0775) + + for fn in filenames: + if os.path.islink(fn): + continue + + # "chmod g+w $fn" + p = os.path.join(dirpath, fn) + st = os.stat(p) + os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) + + # We added some directories to the search path during the configure + # phase. Remove those because those directories won't be there on + # the end-users system. + path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', + 'Versions', version, 'lib', 'python%s'%(version,), + 'config', 'Makefile') + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() + + # Add symlinks in /usr/local/bin, using relative links + usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') + to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', + 'Python.framework', 'Versions', version, 'bin') + if os.path.exists(usr_local_bin): + shutil.rmtree(usr_local_bin) + os.makedirs(usr_local_bin) + for fn in os.listdir( + os.path.join(frmDir, 'Versions', version, 'bin')): + os.symlink(os.path.join(to_framework, fn), + os.path.join(usr_local_bin, fn)) + + os.chdir(curdir) + + + +def patchFile(inPath, outPath): + data = fileContents(inPath) + data = data.replace('$FULL_VERSION', getFullVersion()) + data = data.replace('$VERSION', getVersion()) + data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') + data = data.replace('$ARCHITECTURES', "i386, ppc") + data = data.replace('$INSTALL_SIZE', installSize()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + +def patchScript(inPath, outPath): + data = fileContents(inPath) + data = data.replace('@PYVER@', getVersion()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + os.chmod(outPath, 0755) + + + +def packageFromRecipe(targetDir, recipe): + curdir = os.getcwd() + try: + pkgname = recipe['name'] + srcdir = recipe.get('source') + pkgroot = recipe.get('topdir', srcdir) + postflight = recipe.get('postflight') + readme = textwrap.dedent(recipe['readme']) + isRequired = recipe.get('required', True) + + print "- building package %s"%(pkgname,) + + # Substitute some variables + textvars = dict( + VER=getVersion(), + FULLVER=getFullVersion(), + ) + readme = readme % textvars + + if pkgroot is not None: + pkgroot = pkgroot % textvars + else: + pkgroot = '/' + + if srcdir is not None: + srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) + srcdir = srcdir % textvars + + if postflight is not None: + postflight = os.path.abspath(postflight) + + packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') + os.makedirs(packageContents) + + if srcdir is not None: + os.chdir(srcdir) + runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) + + fn = os.path.join(packageContents, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + rsrcDir = os.path.join(packageContents, "Resources") + os.mkdir(rsrcDir) + fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') + fp.write(readme) + fp.close() + + if postflight is not None: + patchScript(postflight, os.path.join(rsrcDir, 'postflight')) + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + pl = Plist( + CFBundleGetInfoString="MacPython.%s %s"%(pkgname, vers,), + CFBundleIdentifier='org.python.MacPython.%s'%(pkgname,), + CFBundleName='MacPython.%s'%(pkgname,), + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagAllowBackRev=False, + IFPkgFlagAuthorizationAction="RootAuthorization", + IFPkgFlagDefaultLocation=pkgroot, + IFPkgFlagFollowLinks=True, + IFPkgFlagInstallFat=True, + IFPkgFlagIsRequired=isRequired, + IFPkgFlagOverwritePermissions=False, + IFPkgFlagRelocatable=False, + IFPkgFlagRestartAction="NoRestart", + IFPkgFlagRootVolumeOnly=True, + IFPkgFlagUpdateInstalledLangauges=False, + ) + writePlist(pl, os.path.join(packageContents, 'Info.plist')) + + pl = Plist( + IFPkgDescriptionDescription=readme, + IFPkgDescriptionTitle=recipe.get('long_name', "MacPython.%s"%(pkgname,)), + IFPkgDescriptionVersion=vers, + ) + writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) + + finally: + os.chdir(curdir) + + +def makeMpkgPlist(path): + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + + pl = Plist( + CFBundleGetInfoString="MacPython %s"%(vers,), + CFBundleIdentifier='org.python.MacPython', + CFBundleName='MacPython', + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFlagComponentDirectory="Contents/Packages", + IFPkgFlagPackageList=[ + dict( + IFPkgFlagPackageLocation='%s.pkg'%(item['name']), + IFPkgFlagPackageSelection='selected' + ) + for item in PKG_RECIPES + ], + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagBackgroundScaling="proportional", + IFPkgFlagBackgroundAlignment="left", + ) + + writePlist(pl, path) + + +def buildInstaller(): + + # Zap all compiled files + for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): + for fn in filenames: + if fn.endswith('.pyc') or fn.endswith('.pyo'): + os.unlink(os.path.join(dirpath, fn)) + + outdir = os.path.join(WORKDIR, 'installer') + if os.path.exists(outdir): + shutil.rmtree(outdir) + os.mkdir(outdir) + + pkgroot = os.path.join(outdir, 'MacPython.mpkg', 'Contents') + pkgcontents = os.path.join(pkgroot, 'Packages') + os.makedirs(pkgcontents) + for recipe in PKG_RECIPES: + packageFromRecipe(pkgcontents, recipe) + + rsrcDir = os.path.join(pkgroot, 'Resources') + + fn = os.path.join(pkgroot, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + os.mkdir(rsrcDir) + + makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) + pl = Plist( + IFPkgDescriptionTitle="Universal MacPython", + IFPkgDescriptionVersion=getVersion(), + ) + + writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) + for fn in os.listdir('resources'): + if fn.endswith('.jpg'): + shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + else: + patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + + shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt')) + + +def installSize(clear=False, _saved=[]): + if clear: + del _saved[:] + if not _saved: + data = captureCommand("du -ks %s"%( + shellQuote(os.path.join(WORKDIR, '_root')))) + _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) + return _saved[0] + + +def buildDMG(): + """ + Create DMG containing the rootDir + """ + outdir = os.path.join(WORKDIR, 'diskimage') + if os.path.exists(outdir): + shutil.rmtree(outdir) + + imagepath = os.path.join(outdir, + 'python-%s-macosx'%(getFullVersion(),)) + if INCLUDE_TIMESTAMP: + imagepath = imagepath + '%04d-%02d-%02d'%(time.localtime()[:3]) + imagepath = imagepath + '.dmg' + + os.mkdir(outdir) + runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( + getFullVersion(), + shellQuote(os.path.join(WORKDIR, 'installer')), + shellQuote(imagepath))) + + return imagepath + + +def setIcon(filePath, icnsPath): + """ + Set the custom icon for the specified file or directory. + + For a directory the icon data is written in a file named 'Icon\r' inside + the directory. For both files and directories write the icon as an 'icns' + resource. Furthermore set kHasCustomIcon in the finder flags for filePath. + """ + ref, isDirectory = Carbon.File.FSPathMakeRef(icnsPath) + icon = Carbon.Icn.ReadIconFile(ref) + del ref + + # + # Open the resource fork of the target, to add the icon later on. + # For directories we use the file 'Icon\r' inside the directory. + # + + ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) + + if isDirectory: + tmpPath = os.path.join(filePath, "Icon\r") + if not os.path.exists(tmpPath): + fp = open(tmpPath, 'w') + fp.close() + + tmpRef, _ = Carbon.File.FSPathMakeRef(tmpPath) + spec = Carbon.File.FSSpec(tmpRef) + + else: + spec = Carbon.File.FSSpec(ref) + + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + # Try to create the resource fork again, this will avoid problems + # when adding an icon to a directory. I have no idea why this helps, + # but without this adding the icon to a directory will fail sometimes. + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + refNum = Carbon.Res.FSpOpenResFile(spec, fsRdWrPerm) + + Carbon.Res.UseResFile(refNum) + + # Check if there already is an icon, remove it if there is. + try: + h = Carbon.Res.Get1Resource('icns', kCustomIconResource) + except MacOS.Error: + pass + + else: + h.RemoveResource() + del h + + # Add the icon to the resource for of the target + res = Carbon.Res.Resource(icon) + res.AddResource('icns', kCustomIconResource, '') + res.WriteResource() + res.DetachResource() + Carbon.Res.CloseResFile(refNum) + + # And now set the kHasCustomIcon property for the target. Annoyingly, + # python doesn't seem to have bindings for the API that is needed for + # this. Cop out and call SetFile + os.system("/Developer/Tools/SetFile -a C %s"%( + shellQuote(filePath),)) + + if isDirectory: + os.system('/Developer/Tools/SetFile -a V %s'%( + shellQuote(tmpPath), + )) + +def main(): + # First parse options and check if we can perform our work + parseOptions() + checkEnvironment() + + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + + if os.path.exists(WORKDIR): + shutil.rmtree(WORKDIR) + os.mkdir(WORKDIR) + + # Then build third-party libraries such as sleepycat DB4. + buildLibraries() + + # Now build python itself + buildPython() + buildPythonDocs() + fn = os.path.join(WORKDIR, "_root", "Applications", + "MacPython %s"%(getVersion(),), "Update Shell Profile.command") + shutil.copy("scripts/postflight.patch-profile", fn) + os.chmod(fn, 0755) + + folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( + getVersion(),)) + os.chmod(folder, 0755) + setIcon(folder, "../Icons/Python Folder.icns") + + # Create the installer + buildInstaller() + + # And copy the readme into the directory containing the installer + patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt')) + + # Ditto for the license file. + shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) + + fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') + print >> fp, "# BUILD INFO" + print >> fp, "# Date:", time.ctime() + print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.close() + + # Custom icon for the DMG, shown when the DMG is mounted. + shutil.copy("../Icons/Disk Image.icns", + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns")) + os.system("/Developer/Tools/SetFile -a C %s"%( + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns"))) + + + # And copy it to a DMG + buildDMG() + + +if __name__ == "__main__": + main() Added: python/trunk/Mac/OSX/BuildScript/ncurses-5.5.patch ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/ncurses-5.5.patch Tue May 23 17:09:57 2006 @@ -0,0 +1,36 @@ +diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in +--- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 ++++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 +@@ -75,7 +75,7 @@ + MATH_LIB = @MATH_LIB@ + + LD = @LD@ +-LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) ++LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) + + usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ + +diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c +--- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 ++++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 +@@ -474,7 +474,7 @@ + } + + /* truncate the terminal name to prevent buffer overflow */ +- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); ++ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); + + /* This is System V behavior, in conjunction with our requirements for + * writing terminfo entries. +diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure +--- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 ++++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 +@@ -5027,7 +5027,7 @@ + darwin*) + EXTRA_CFLAGS="-no-cpp-precomp" + CC_SHARED_OPTS="-dynamic" +- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' ++ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' + test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi + cf_cv_shlib_version_infix=yes + ;; Added: python/trunk/Mac/OSX/BuildScript/resources/ReadMe.txt ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/resources/ReadMe.txt Tue May 23 17:09:57 2006 @@ -0,0 +1,31 @@ +This package will install MacPython $FULL_VERSION for Mac OS X +$MACOSX_DEPLOYMENT_TARGET for the following +architecture(s): $ARCHITECTURES. + +Separate installers are available for older versions +of Mac OS X, see the homepage, below. + +Installation requires approximately $INSTALL_SIZE MB of disk +space, ignore the message that it will take zero bytes. + +You must install onto your current boot disk, even +though the installer does not enforce this, otherwise +things will not work. + +MacPython consists of the Python programming language +interpreter, plus a set of programs to allow easy +access to it for Mac users (an integrated development +environment, an applet builder), plus a set of pre-built +extension modules that open up specific Macintosh technologies +to Python programs (Carbon, AppleScript, Quicktime, more). + +The installer puts the applications in "MacPython $VERSION" +in your Applications folder, command-line tools in +/usr/local/bin and the underlying machinery in +$PYTHONFRAMEWORKINSTALLDIR. + +More information on MacPython can be found at +http://www.cwi.nl/~jack/macpython and +http://pythonmac.org/. More information on +Python in general can be found at +http://www.python.org. Added: python/trunk/Mac/OSX/BuildScript/resources/Welcome.rtf ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/resources/Welcome.rtf Tue May 23 17:09:57 2006 @@ -0,0 +1,15 @@ +{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf330 +{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;} +{\colortbl;\red255\green255\blue255;} +\paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0 +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural + +\f0\fs24 \cf0 This package will install +\f1\b MacPython $FULL_VERSION +\f0\b0 for +\f1\b Mac OS X $MACOSX_DEPLOYMENT_TARGET +\f0\b0 .\ +\ +MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, an applet builder), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\ +\ +See the ReadMe file for more information.} \ No newline at end of file Added: python/trunk/Mac/OSX/BuildScript/resources/background.jpg ============================================================================== Binary file. No diff available. Added: python/trunk/Mac/OSX/BuildScript/scripts/postflight.documentation ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/scripts/postflight.documentation Tue May 23 17:09:57 2006 @@ -0,0 +1,12 @@ +#!/bin/sh + +# FIXME +PYVER="@PYVER@" + +if [ -d /Developer/Documentation ]; then + if [ ! -d /Developer/Documentation/Python ]; then + mkdir -p /Developer/Documentation/Python + fi + + ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation" +fi Added: python/trunk/Mac/OSX/BuildScript/scripts/postflight.framework ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/scripts/postflight.framework Tue May 23 17:09:57 2006 @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Recompile the .py files. +# + +PYVER="@PYVER@" +FWK="/Library/Frameworks/Python.framework/Versions/@PYVER@/" + +"${FWK}/bin/python" -Wi -tt \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -x badsyntax -x site-packages \ + "${FWK}/lib/python${PYVER}" + +"${FWK}/bin/python" -Wi -tt -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -x badsyntax -x site-packages \ + "${FWK}/lib/python${PYVER}" + +"${FWK}/bin/python" -Wi -tt \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -x badsyntax -x site-packages \ + "${FWK}/Mac/Tools" + +"${FWK}/bin/python" -Wi -tt -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -x badsyntax -x site-packages \ + "${FWK}/Mac/Tools" + + +chown -R admin "${FWK}" +chmod -R g+w "${FWK}" + +exit 0 Added: python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile ============================================================================== --- (empty file) +++ python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile Tue May 23 17:09:57 2006 @@ -0,0 +1,71 @@ +#!/bin/sh + +echo "This script will update your shell profile when the 'bin' directory" +echo "of python is not early enough of the PATH of your shell." +echo "These changes will be effective only in shell windows that you open" +echo "after running this script." + +PYVER=@PYVER@ +PYTHON_ROOT="/Library/Frameworks/Python.framework/Versions/Current" + +# Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH. +BSH="`basename "${SHELL}"`" +case "${BSH}" in +bash|ksh|sh|*csh) + P="`${SHELL} -c 'echo $PATH'`" + ;; +*) + echo "Sorry, I don't know how to patch $BSH shells" + exit 0 + ;; +esac + +# Now ensure that our bin directory is on $P and before /usr/bin at that +for elem in `echo $P | tr ':' ' '` +do + if [ "${elem}" == "${PYTHON_ROOT}/bin" ]; then + echo "All right, you're a python lover already" + exit 0 + elif [ "${elem}" == "/usr/bin" ]; then + break + fi +done + +echo "${PYTHON_ROOT}/bin is not on your PATH or at least not early enough" +case "${BSH}" in +*csh) + # Create backup copy before patching + if [ -f "${HOME}/.cshrc" ]; then + cp -fp "${HOME}/.cshrc" "${HOME}/.cshrc.pysave" + fi + echo "" >> "${HOME}/.cshrc" + echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc" + echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc" + echo "setenv path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" + exit 0 + ;; +bash) + if [ -e "${HOME}/.profile" ]; then + PR="${HOME}/.profile" + else + PR="${HOME}/.bash_profile" + fi + ;; +*sh) + PR="${HOME}/.profile" + ;; +esac + +# Create backup copy before patching +if [ -f "${PR}" ]; then + cp -fp "${PR}" "${PR}.pysave" +fi +echo "" >> "${PR}" +echo "# Setting PATH for MacPython ${PYVER}" >> "${PR}" +echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}" +echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}" +echo 'export PATH' >> "${PR}" +if [ `id -ur` = 0 ]; then + chown "${LOGNAME}" "${PR}" +fi +exit 0 From python-checkins at python.org Tue May 23 17:26:29 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 17:26:29 +0200 (CEST) Subject: [Python-checkins] r46114 - in sandbox/trunk/newstruct: Modules Modules/_newstruct.c newstruct.py setup.py test_newstruct.py Message-ID: <20060523152629.35F841E4009@bag.python.org> Author: bob.ippolito Date: Tue May 23 17:26:27 2006 New Revision: 46114 Added: sandbox/trunk/newstruct/ sandbox/trunk/newstruct/Modules/ sandbox/trunk/newstruct/Modules/_newstruct.c (contents, props changed) sandbox/trunk/newstruct/newstruct.py (contents, props changed) sandbox/trunk/newstruct/setup.py (contents, props changed) sandbox/trunk/newstruct/test_newstruct.py (contents, props changed) Log: optimized compiling version of struct module (like re) Added: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- (empty file) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Tue May 23 17:26:27 2006 @@ -0,0 +1,1355 @@ +/* struct module -- pack values into and (out of) strings */ + +/* New version supporting byte order, alignment and size options, + character strings, and unsigned numbers */ + +#include "Python.h" +#include "structseq.h" +#include "structmember.h" +#include + + +/* compatibility macros */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + + + +/* The translation function for each format character is table driven */ + +typedef struct _formatdef { + char format; + int size; + int alignment; + PyObject* (*unpack)(const char *, + const struct _formatdef *); + int (*pack)(char *, PyObject *, + const struct _formatdef *); +} formatdef; + +typedef struct _formatcode { + const struct _formatdef *fmtdef; + int offset; + int repeat; +} formatcode; + +/* Struct object interface */ + +typedef struct { + PyObject_HEAD + int s_size; + int s_len; + formatcode *s_codes; + PyObject *s_format; + PyObject *weakreflist; /* List of weak references */ +} PyStructObject; + +PyAPI_DATA(PyTypeObject) PyStruct_Type; + +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) + + +/* Exception */ + +static PyObject *StructError; + + +/* Define various structs to figure out the alignments of types */ + + +typedef struct { char c; short x; } st_short; +typedef struct { char c; int x; } st_int; +typedef struct { char c; long x; } st_long; +typedef struct { char c; float x; } st_float; +typedef struct { char c; double x; } st_double; +typedef struct { char c; void *x; } st_void_p; + +#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) +#define INT_ALIGN (sizeof(st_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) +#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) +#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) + +/* We can't support q and Q in native mode unless the compiler does; + in std mode, they're 8 bytes on all platforms. */ +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +#define STRINGIFY(x) #x + +#ifdef __powerc +#pragma options align=reset +#endif + +/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ + +static PyObject * +get_pylong(PyObject *v) +{ + PyNumberMethods *m; + + assert(v != NULL); + if (PyInt_Check(v)) + return PyLong_FromLong(PyInt_AS_LONG(v)); + if (PyLong_Check(v)) { + Py_INCREF(v); + return v; + } + m = v->ob_type->tp_as_number; + if (m != NULL && m->nb_long != NULL) { + v = m->nb_long(v); + if (v == NULL) + return NULL; + if (PyLong_Check(v)) + return v; + Py_DECREF(v); + } + PyErr_SetString(StructError, + "cannot convert argument to long"); + return NULL; +} + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x = PyInt_AsLong(v); + if (x == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_SetString(StructError, + "required argument is not an integer"); + return -1; + } + *p = x; + return 0; +} + + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + if (PyLong_Check(v)) { + unsigned long x = PyLong_AsUnsignedLong(v); + if (x == (unsigned long)(-1) && PyErr_Occurred()) + return -1; + *p = x; + return 0; + } + else { + return get_long(v, (long *)p); + } +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsLongLong(v); + Py_DECREF(v); + if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsUnsignedLongLong(v); + Py_DECREF(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/* Floating point helpers */ + +static PyObject * +unpack_float(const char *p, /* start of 4-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack4((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + +static PyObject * +unpack_double(const char *p, /* start of 8-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack8((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + + +/* A large number of small routines follow, with names of the form + + [bln][up]_TYPE + + [bln] distiguishes among big-endian, little-endian and native. + [pu] distiguishes between pack (to struct) and unpack (from struct). + TYPE is one of char, byte, ubyte, etc. +*/ + +/* Native mode routines. ****************************************************/ +/* NOTE: + In all n[up]_ routines handling types larger than 1 byte, there is + *no* guarantee that the p pointer is properly aligned for each type, + therefore memcpy is called. An intermediate variable is used to + compensate for big-endian architectures. + Normally both the intermediate variable and the memcpy call will be + skipped by C optimisation in little-endian architectures (gcc >= 2.91 + does this). */ + +static PyObject * +nu_char(const char *p, const formatdef *f) +{ + return PyString_FromStringAndSize(p, 1); +} + +static PyObject * +nu_byte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(signed char *)p); +} + +static PyObject * +nu_ubyte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(unsigned char *)p); +} + +static PyObject * +nu_short(const char *p, const formatdef *f) +{ + short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_ushort(const char *p, const formatdef *f) +{ + unsigned short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_int(const char *p, const formatdef *f) +{ + int x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_uint(const char *p, const formatdef *f) +{ + unsigned int x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong((unsigned long)x); +} + +static PyObject * +nu_long(const char *p, const formatdef *f) +{ + long x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong(x); +} + +static PyObject * +nu_ulong(const char *p, const formatdef *f) +{ + unsigned long x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong(x); +} + +/* Native mode doesn't support q or Q unless the platform C supports + long long (or, on Windows, __int64). */ + +#ifdef HAVE_LONG_LONG + +static PyObject * +nu_longlong(const char *p, const formatdef *f) +{ + PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromLongLong(x); +} + +static PyObject * +nu_ulonglong(const char *p, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLongLong(x); +} + +#endif + +static PyObject * +nu_float(const char *p, const formatdef *f) +{ + float x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble((double)x); +} + +static PyObject * +nu_double(const char *p, const formatdef *f) +{ + double x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble(x); +} + +static PyObject * +nu_void_p(const char *p, const formatdef *f) +{ + void *x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromVoidPtr(x); +} + +static int +np_byte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < -128 || x > 127){ + PyErr_SetString(StructError, + "byte format requires -128<=number<=127"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_ubyte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > 255){ + PyErr_SetString(StructError, + "ubyte format requires 0<=number<=255"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_char(char *p, PyObject *v, const formatdef *f) +{ + if (!PyString_Check(v) || PyString_Size(v) != 1) { + PyErr_SetString(StructError, + "char format require string of length 1"); + return -1; + } + *p = *PyString_AsString(v); + return 0; +} + +static int +np_short(char *p, PyObject *v, const formatdef *f) +{ + long x; + short y; + if (get_long(v, &x) < 0) + return -1; + if (x < SHRT_MIN || x > SHRT_MAX){ + PyErr_SetString(StructError, + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); + return -1; + } + y = (short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_ushort(char *p, PyObject *v, const formatdef *f) +{ + long x; + unsigned short y; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > USHRT_MAX){ + PyErr_SetString(StructError, + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + return -1; + } + y = (unsigned short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int y; + if (get_long(v, &x) < 0) + return -1; + y = (int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + unsigned int y; + if (get_ulong(v, &x) < 0) + return -1; + y = (unsigned int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_long(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulong(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + if (get_ulong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +#ifdef HAVE_LONG_LONG + +static int +np_longlong(char *p, PyObject *v, const formatdef *f) +{ + PY_LONG_LONG x; + if (get_longlong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + if (get_ulonglong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} +#endif + +static int +np_float(char *p, PyObject *v, const formatdef *f) +{ + float x = (float)PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof(double)); + return 0; +} + +static int +np_void_p(char *p, PyObject *v, const formatdef *f) +{ + void *x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsVoidPtr(v); + Py_DECREF(v); + if (x == NULL && PyErr_Occurred()) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static formatdef native_table[] = { + {'x', sizeof(char), 0, NULL}, + {'b', sizeof(char), 0, nu_byte, np_byte}, + {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, + {'c', sizeof(char), 0, nu_char, np_char}, + {'s', sizeof(char), 0, NULL}, + {'p', sizeof(char), 0, NULL}, + {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, + {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, + {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, + {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, + {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, + {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, +#ifdef HAVE_LONG_LONG + {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, +#endif + {0} +}; + +/* Big-endian routines. *****************************************************/ + +static PyObject * +bu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +bu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +bu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +bu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +bu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 0); +} + +static PyObject * +bu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 0); +} + +static int +bp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 0); +} + +static int +bp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 0); +} + +static formatdef bigendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, bu_int, bp_int}, + {'B', 1, 0, bu_uint, bp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, bu_int, bp_int}, + {'H', 2, 0, bu_uint, bp_uint}, + {'i', 4, 0, bu_int, bp_int}, + {'I', 4, 0, bu_uint, bp_uint}, + {'l', 4, 0, bu_int, bp_int}, + {'L', 4, 0, bu_uint, bp_uint}, + {'q', 8, 0, bu_longlong, bp_longlong}, + {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, + {'f', 4, 0, bu_float, bp_float}, + {'d', 8, 0, bu_double, bp_double}, + {0} +}; + +/* Little-endian routines. *****************************************************/ + +static PyObject * +lu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +lu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +lu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +lu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +lu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 1); +} + +static PyObject * +lu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 1); +} + +static int +lp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 1); +} + +static int +lp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 1); +} + +static formatdef lilendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, lu_int, lp_int}, + {'B', 1, 0, lu_uint, lp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, lu_int, lp_int}, + {'H', 2, 0, lu_uint, lp_uint}, + {'i', 4, 0, lu_int, lp_int}, + {'I', 4, 0, lu_uint, lp_uint}, + {'l', 4, 0, lu_int, lp_int}, + {'L', 4, 0, lu_uint, lp_uint}, + {'q', 8, 0, lu_longlong, lp_longlong}, + {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, + {'f', 4, 0, lu_float, lp_float}, + {'d', 8, 0, lu_double, lp_double}, + {0} +}; + + +static const formatdef * +whichtable(char **pfmt) +{ + const char *fmt = (*pfmt)++; /* May be backed out of later */ + switch (*fmt) { + case '<': + return lilendian_table; + case '>': + case '!': /* Network byte order is big-endian */ + return bigendian_table; + case '=': { /* Host byte order -- different from native in aligment! */ + int n = 1; + char *p = (char *) &n; + if (*p == 1) + return lilendian_table; + else + return bigendian_table; + } + default: + --*pfmt; /* Back out of pointer increment */ + /* Fall through */ + case '@': + return native_table; + } +} + + +/* Get the table entry for a format code */ + +static const formatdef * +getentry(int c, const formatdef *f) +{ + for (; f->format != '\0'; f++) { + if (f->format == c) { + return f; + } + } + PyErr_SetString(StructError, "bad char in struct format"); + return NULL; +} + + +/* Align a size according to a format code */ + +static int +align(int size, int c, const formatdef *e) +{ + if (e->format == c) { + if (e->alignment) { + size = ((size + e->alignment - 1) + / e->alignment) + * e->alignment; + } + } + return size; +} + + +/* calculate the size of a format string */ + +static int +prepare_s(PyStructObject *self) +{ + const formatdef *f; + const formatdef *e; + formatcode *codes; + + const char *s; + const char *fmt; + char c; + int size, len, numcodes, num, itemsize, x; + + fmt = PyString_AS_STRING(self->s_format); + + f = whichtable((char **)&fmt); + + s = fmt; + size = 0; + len = 0; + numcodes = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') { + x = num*10 + (c - '0'); + if (x/10 != num) { + PyErr_SetString( + StructError, + "overflow in item count"); + return -1; + } + num = x; + } + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + return -1; + + switch (c) { + case 's': /* fall through */ + case 'p': len++; break; + case 'x': break; + default: len += num; break; + } + if (c != 'x') numcodes++; + + itemsize = e->size; + size = align(size, c, e); + x = num * itemsize; + size += x; + if (x/itemsize != num || size < 0) { + PyErr_SetString(StructError, + "total struct size too long"); + return -1; + } + } + + self->s_size = size; + self->s_len = len; + codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + if (codes == NULL) { + PyErr_NoMemory(); + return -1; + } + self->s_codes = codes; + + s = fmt; + size = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + + size = align(size, c, e); + if (c != 'x') { + codes->offset = size; + codes->repeat = num; + codes->fmtdef = e; + codes++; + } + size += num * e->size; + } + codes->fmtdef = NULL; + codes->offset = -1; + codes->repeat = -1; + + return 0; +} + +static PyObject * +s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + static PyObject *not_yet_string; + + assert(type != NULL && type->tp_alloc != NULL); + + self = type->tp_alloc(type, 0); + if (self != NULL) { + PyStructObject *s = (PyStructObject*)self; + Py_INCREF(Py_None); + s->s_format = Py_None; + s->s_codes = NULL; + s->s_size = -1; + s->s_len = -1; + } + return self; +} + +static int +s_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyStructObject *soself = (PyStructObject *)self; + PyObject *o_format = NULL; + int ret = 0; + static char *kwlist[] = {"format", 0}; + + assert(PyStruct_Check(self)); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, + &o_format)) + return -1; + + Py_INCREF(o_format); + Py_XDECREF(soself->s_format); + soself->s_format = o_format; + + ret = prepare_s(soself); + return ret; +} + +static void +s_dealloc(PyStructObject *s) +{ + int sts = 0; + if (s->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *)s); + if (s->s_codes != NULL) { + PyMem_FREE(s->s_codes); + } + Py_XDECREF(s->s_format); + s->ob_type->tp_free((PyObject *)s); +} + +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See newstruct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + result = PyTuple_New(soself->s_len); + if (result == NULL) + return NULL; + + + restart = PyString_AS_STRING(inputstr); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + const char *res = restart + code->offset; + if (e->format == 's') { + v = PyString_FromStringAndSize(res, code->repeat); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else if (e->format == 'p') { + n = *(unsigned char*)res; + if (n >= code->repeat) + n = code->repeat - 1; + v = PyString_FromStringAndSize(res + 1, n); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else { + for (n = 0; n < code->repeat; n++) { + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + res += e->size; + } + } + } + + return result; +fail: + Py_DECREF(result); + return NULL; +}; + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See newstruct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + restart = PyString_AS_STRING(result); + memset(restart, '\0', soself->s_size); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + char *res = restart + code->offset; + if (e->format == 's') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 's' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > code->repeat) + n = code->repeat; + if (n > 0) + memcpy(res, PyString_AS_STRING(v), n); + } else if (e->format == 'p') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 'p' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > (code->repeat - 1)) + n = code->repeat - 1; + if (n > 0) + memcpy(res + 1, PyString_AS_STRING(v), n); + if (n > 255) + n = 255; + *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + } else { + for (n = 0; n < code->repeat; n++) { + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; + res += e->size; + } + } + } + + return result; + +fail: + Py_DECREF(result); + return NULL; + +} + + +/* List of functions */ + +static struct PyMethodDef s_methods[] = { + {"pack", s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {NULL, NULL} /* sentinel */ +}; + +PyDoc_STRVAR(s__doc__, "Compiled struct object"); + +#define OFF(x) offsetof(PyStructObject, x) + +static PyMemberDef s_memberlist[] = { + {"format", T_OBJECT, OFF(s_format), RO, + "struct format string"}, + {"size", T_INT, OFF(s_size), RO, + "struct size in bytes"}, + {"_len", T_INT, OFF(s_len), RO, + "number of items expected in tuple"}, + {NULL} /* Sentinel */ +}; + + +static +PyTypeObject PyStructType = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "Struct", + sizeof(PyStructObject), + 0, + (destructor)s_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ + s__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + s_methods, /* tp_methods */ + s_memberlist, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + s_init, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + s_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + +/* Module initialization */ + +PyMODINIT_FUNC +init_newstruct(void) +{ + PyObject *m = Py_InitModule("_newstruct", NULL); + if (m == NULL) + return; + + /* Add some symbolic constants to the module */ + if (StructError == NULL) { + StructError = PyErr_NewException("newstruct.error", NULL, NULL); + if (StructError == NULL) + return; + } + Py_INCREF(StructError); + PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); + PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); +} \ No newline at end of file Added: sandbox/trunk/newstruct/newstruct.py ============================================================================== --- (empty file) +++ sandbox/trunk/newstruct/newstruct.py Tue May 23 17:26:27 2006 @@ -0,0 +1,76 @@ +""" +Functions to convert between Python values and C structs. +Python strings are used to hold the data representing the C struct +and also as format strings to describe the layout of data in the C struct. + +The optional first format char indicates byte order, size and alignment: + @: native order, size & alignment (default) + =: native order, std. size & alignment + <: little-endian, std. size & alignment + >: big-endian, std. size & alignment + !: same as > + +The remaining chars indicate types of args and must match exactly; +these can be preceded by a decimal repeat count: + x: pad byte (no data); c:char; b:signed byte; B:unsigned byte; + h:short; H:unsigned short; i:int; I:unsigned int; + l:long; L:unsigned long; f:float; d:double. +Special cases (preceding decimal count indicates length): + s:string (array of char); p: pascal string (with count byte). +Special case (only available in native format): + P:an integer type that is wide enough to hold a pointer. +Special case (not in native mode unless 'long long' in platform C): + q:long long; Q:unsigned long long +Whitespace between formats is ignored. + +The variable newstruct.error is an exception raised on errors. +""" +__version__ = '0.1' + +from _newstruct import Struct, error + +_MAXCACHE = 100 +_cache = {} + +def _compile(fmt): + # Internal: compile struct pattern + if len(_cache) >= _MAXCACHE: + _cache.clear() + s = Struct(fmt) + _cache[fmt] = s + return s + +def calcsize(fmt): + """ + Return size of C struct described by format string fmt. + See newstruct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.size + +def pack(fmt, *args): + """ + Return string containing values v1, v2, ... packed according to fmt. + See newstruct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack(*args) + +def unpack(fmt, s): + """ + Unpack the string, containing packed C structure data, according + to fmt. Requires len(string)==calcsize(fmt). + See newstruct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack(s) + Added: sandbox/trunk/newstruct/setup.py ============================================================================== --- (empty file) +++ sandbox/trunk/newstruct/setup.py Tue May 23 17:26:27 2006 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +#import ez_setup +#ez_setup.use_setuptools() + +#from setuptools import setup, Extension + +from distutils.core import setup, Extension + +VERSION = '0.1' +DESCRIPTION = "Rewrite of the struct module" +LONG_DESCRIPTION = """ +Struct module offering a compile feature +""" + +CLASSIFIERS = filter(None, map(str.strip, +""" +Environment :: Console +Intended Audience :: Developers +License :: OSI Approved :: MIT License +Natural Language :: English +Programming Language :: Python +Topic :: Software Development :: Libraries :: Python Modules +""".splitlines())) + +setup( + name="newstruct", + version=VERSION, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + classifiers=CLASSIFIERS, + author="Bob Ippolito", + author_email="bob at redivi.com", + url="http://undefined.org/python/#newstruct", + license="MIT License", + py_modules=['newstruct'], + ext_modules=[ + Extension("_newstruct", ["Modules/_newstruct.c"]), + ], + #zip_safe=False, +) Added: sandbox/trunk/newstruct/test_newstruct.py ============================================================================== --- (empty file) +++ sandbox/trunk/newstruct/test_newstruct.py Tue May 23 17:26:27 2006 @@ -0,0 +1,439 @@ +from test.test_support import TestFailed, verbose, verify +import newstruct as struct + +import sys +ISBIGENDIAN = sys.byteorder == "big" +del sys +verify((struct.pack('=i', 1)[0] == chr(0)) == ISBIGENDIAN, + "bigendian determination appears wrong") + +def string_reverse(s): + chars = list(s) + chars.reverse() + return "".join(chars) + +def bigendian_to_native(value): + if ISBIGENDIAN: + return value + else: + return string_reverse(value) + +def simple_err(func, *args): + try: + func(*args) + except struct.error: + pass + else: + raise TestFailed, "%s%s did not raise struct.error" % ( + func.__name__, args) + +def any_err(func, *args): + try: + func(*args) + except (struct.error, OverflowError, TypeError): + pass + else: + raise TestFailed, "%s%s did not raise error" % ( + func.__name__, args) + + +simple_err(struct.calcsize, 'Z') + +sz = struct.calcsize('i') +if sz * 3 != struct.calcsize('iii'): + raise TestFailed, 'inconsistent sizes' + +fmt = 'cbxxxxxxhhhhiillffd' +fmt3 = '3c3b18x12h6i6l6f3d' +sz = struct.calcsize(fmt) +sz3 = struct.calcsize(fmt3) +if sz * 3 != sz3: + raise TestFailed, 'inconsistent sizes (3*%r -> 3*%d = %d, %r -> %d)' % ( + fmt, sz, 3*sz, fmt3, sz3) + +simple_err(struct.pack, 'iii', 3) +simple_err(struct.pack, 'i', 3, 3, 3) +simple_err(struct.pack, 'i', 'foo') +simple_err(struct.pack, 'P', 'foo') +simple_err(struct.unpack, 'd', 'flap') +s = struct.pack('ii', 1, 2) +simple_err(struct.unpack, 'iii', s) +simple_err(struct.unpack, 'i', s) + +c = 'a' +b = 1 +h = 255 +i = 65535 +l = 65536 +f = 3.1415 +d = 3.1415 + +for prefix in ('', '@', '<', '>', '=', '!'): + for format in ('xcbhilfd', 'xcBHILfd'): + format = prefix + format + if verbose: + print "trying:", format + s = struct.pack(format, c, b, h, i, l, f, d) + cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) + if (cp != c or bp != b or hp != h or ip != i or lp != l or + int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d)): + # ^^^ calculate only to two decimal places + raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( + str(format), str((cp, bp, hp, ip, lp, fp, dp))) + +# Test some of the new features in detail + +# (format, argument, big-endian result, little-endian result, asymmetric) +tests = [ + ('c', 'a', 'a', 'a', 0), + ('xc', 'a', '\0a', '\0a', 0), + ('cx', 'a', 'a\0', 'a\0', 0), + ('s', 'a', 'a', 'a', 0), + ('0s', 'helloworld', '', '', 1), + ('1s', 'helloworld', 'h', 'h', 1), + ('9s', 'helloworld', 'helloworl', 'helloworl', 1), + ('10s', 'helloworld', 'helloworld', 'helloworld', 0), + ('11s', 'helloworld', 'helloworld\0', 'helloworld\0', 1), + ('20s', 'helloworld', 'helloworld'+10*'\0', 'helloworld'+10*'\0', 1), + ('b', 7, '\7', '\7', 0), + ('b', -7, '\371', '\371', 0), + ('B', 7, '\7', '\7', 0), + ('B', 249, '\371', '\371', 0), + ('h', 700, '\002\274', '\274\002', 0), + ('h', -700, '\375D', 'D\375', 0), + ('H', 700, '\002\274', '\274\002', 0), + ('H', 0x10000-700, '\375D', 'D\375', 0), + ('i', 70000000, '\004,\035\200', '\200\035,\004', 0), + ('i', -70000000, '\373\323\342\200', '\200\342\323\373', 0), + ('I', 70000000L, '\004,\035\200', '\200\035,\004', 0), + ('I', 0x100000000L-70000000, '\373\323\342\200', '\200\342\323\373', 0), + ('l', 70000000, '\004,\035\200', '\200\035,\004', 0), + ('l', -70000000, '\373\323\342\200', '\200\342\323\373', 0), + ('L', 70000000L, '\004,\035\200', '\200\035,\004', 0), + ('L', 0x100000000L-70000000, '\373\323\342\200', '\200\342\323\373', 0), + ('f', 2.0, '@\000\000\000', '\000\000\000@', 0), + ('d', 2.0, '@\000\000\000\000\000\000\000', + '\000\000\000\000\000\000\000@', 0), + ('f', -2.0, '\300\000\000\000', '\000\000\000\300', 0), + ('d', -2.0, '\300\000\000\000\000\000\000\000', + '\000\000\000\000\000\000\000\300', 0), +] + +for fmt, arg, big, lil, asy in tests: + if verbose: + print "%r %r %r %r" % (fmt, arg, big, lil) + for (xfmt, exp) in [('>'+fmt, big), ('!'+fmt, big), ('<'+fmt, lil), + ('='+fmt, ISBIGENDIAN and big or lil)]: + res = struct.pack(xfmt, arg) + if res != exp: + raise TestFailed, "pack(%r, %r) -> %r # expected %r" % ( + fmt, arg, res, exp) + n = struct.calcsize(xfmt) + if n != len(res): + raise TestFailed, "calcsize(%r) -> %d # expected %d" % ( + xfmt, n, len(res)) + rev = struct.unpack(xfmt, res)[0] + if rev != arg and not asy: + raise TestFailed, "unpack(%r, %r) -> (%r,) # expected (%r,)" % ( + fmt, res, rev, arg) + +########################################################################### +# Simple native q/Q tests. + +has_native_qQ = 1 +try: + struct.pack("q", 5) +except struct.error: + has_native_qQ = 0 + +if verbose: + print "Platform has native q/Q?", has_native_qQ and "Yes." or "No." + +any_err(struct.pack, "Q", -1) # can't pack -1 as unsigned regardless +simple_err(struct.pack, "q", "a") # can't pack string as 'q' regardless +simple_err(struct.pack, "Q", "a") # ditto, but 'Q' + +def test_native_qQ(): + bytes = struct.calcsize('q') + # The expected values here are in big-endian format, primarily because + # I'm on a little-endian machine and so this is the clearest way (for + # me) to force the code to get exercised. + for format, input, expected in ( + ('q', -1, '\xff' * bytes), + ('q', 0, '\x00' * bytes), + ('Q', 0, '\x00' * bytes), + ('q', 1L, '\x00' * (bytes-1) + '\x01'), + ('Q', (1L << (8*bytes))-1, '\xff' * bytes), + ('q', (1L << (8*bytes-1))-1, '\x7f' + '\xff' * (bytes - 1))): + got = struct.pack(format, input) + native_expected = bigendian_to_native(expected) + verify(got == native_expected, + "%r-pack of %r gave %r, not %r" % + (format, input, got, native_expected)) + retrieved = struct.unpack(format, got)[0] + verify(retrieved == input, + "%r-unpack of %r gave %r, not %r" % + (format, got, retrieved, input)) + +if has_native_qQ: + test_native_qQ() + +########################################################################### +# Standard integer tests (bBhHiIlLqQ). + +import binascii + +class IntTester: + + # XXX Most std integer modes fail to test for out-of-range. + # The "i" and "l" codes appear to range-check OK on 32-bit boxes, but + # fail to check correctly on some 64-bit ones (Tru64 Unix + Compaq C + # reported by Mark Favas). + BUGGY_RANGE_CHECK = "bBhHiIlL" + + def __init__(self, formatpair, bytesize): + assert len(formatpair) == 2 + self.formatpair = formatpair + for direction in "<>!=": + for code in formatpair: + format = direction + code + verify(struct.calcsize(format) == bytesize) + self.bytesize = bytesize + self.bitsize = bytesize * 8 + self.signed_code, self.unsigned_code = formatpair + self.unsigned_min = 0 + self.unsigned_max = 2L**self.bitsize - 1 + self.signed_min = -(2L**(self.bitsize-1)) + self.signed_max = 2L**(self.bitsize-1) - 1 + + def test_one(self, x, pack=struct.pack, + unpack=struct.unpack, + unhexlify=binascii.unhexlify): + if verbose: + print "trying std", self.formatpair, "on", x, "==", hex(x) + + # Try signed. + code = self.signed_code + if self.signed_min <= x <= self.signed_max: + # Try big-endian. + expected = long(x) + if x < 0: + expected += 1L << self.bitsize + assert expected > 0 + expected = hex(expected)[2:-1] # chop "0x" and trailing 'L' + if len(expected) & 1: + expected = "0" + expected + expected = unhexlify(expected) + expected = "\x00" * (self.bytesize - len(expected)) + expected + + # Pack work? + format = ">" + code + got = pack(format, x) + verify(got == expected, + "'%s'-pack of %r gave %r, not %r" % + (format, x, got, expected)) + + # Unpack work? + retrieved = unpack(format, got)[0] + verify(x == retrieved, + "'%s'-unpack of %r gave %r, not %r" % + (format, got, retrieved, x)) + + # Adding any byte should cause a "too big" error. + any_err(unpack, format, '\x01' + got) + + # Try little-endian. + format = "<" + code + expected = string_reverse(expected) + + # Pack work? + got = pack(format, x) + verify(got == expected, + "'%s'-pack of %r gave %r, not %r" % + (format, x, got, expected)) + + # Unpack work? + retrieved = unpack(format, got)[0] + verify(x == retrieved, + "'%s'-unpack of %r gave %r, not %r" % + (format, got, retrieved, x)) + + # Adding any byte should cause a "too big" error. + any_err(unpack, format, '\x01' + got) + + else: + # x is out of range -- verify pack realizes that. + if code in self.BUGGY_RANGE_CHECK: + if verbose: + print "Skipping buggy range check for code", code + else: + any_err(pack, ">" + code, x) + any_err(pack, "<" + code, x) + + # Much the same for unsigned. + code = self.unsigned_code + if self.unsigned_min <= x <= self.unsigned_max: + # Try big-endian. + format = ">" + code + expected = long(x) + expected = hex(expected)[2:-1] # chop "0x" and trailing 'L' + if len(expected) & 1: + expected = "0" + expected + expected = unhexlify(expected) + expected = "\x00" * (self.bytesize - len(expected)) + expected + + # Pack work? + got = pack(format, x) + verify(got == expected, + "'%s'-pack of %r gave %r, not %r" % + (format, x, got, expected)) + + # Unpack work? + retrieved = unpack(format, got)[0] + verify(x == retrieved, + "'%s'-unpack of %r gave %r, not %r" % + (format, got, retrieved, x)) + + # Adding any byte should cause a "too big" error. + any_err(unpack, format, '\x01' + got) + + # Try little-endian. + format = "<" + code + expected = string_reverse(expected) + + # Pack work? + got = pack(format, x) + verify(got == expected, + "'%s'-pack of %r gave %r, not %r" % + (format, x, got, expected)) + + # Unpack work? + retrieved = unpack(format, got)[0] + verify(x == retrieved, + "'%s'-unpack of %r gave %r, not %r" % + (format, got, retrieved, x)) + + # Adding any byte should cause a "too big" error. + any_err(unpack, format, '\x01' + got) + + else: + # x is out of range -- verify pack realizes that. + if code in self.BUGGY_RANGE_CHECK: + if verbose: + print "Skipping buggy range check for code", code + else: + any_err(pack, ">" + code, x) + any_err(pack, "<" + code, x) + + def run(self): + from random import randrange + + # Create all interesting powers of 2. + values = [] + for exp in range(self.bitsize + 3): + values.append(1L << exp) + + # Add some random values. + for i in range(self.bitsize): + val = 0L + for j in range(self.bytesize): + val = (val << 8) | randrange(256) + values.append(val) + + # Try all those, and their negations, and +-1 from them. Note + # that this tests all power-of-2 boundaries in range, and a few out + # of range, plus +-(2**n +- 1). + for base in values: + for val in -base, base: + for incr in -1, 0, 1: + x = val + incr + try: + x = int(x) + except OverflowError: + pass + self.test_one(x) + + # Some error cases. + for direction in "<>": + for code in self.formatpair: + for badobject in "a string", 3+42j, randrange: + any_err(struct.pack, direction + code, badobject) + +for args in [("bB", 1), + ("hH", 2), + ("iI", 4), + ("lL", 4), + ("qQ", 8)]: + t = IntTester(*args) + t.run() + + +########################################################################### +# The p ("Pascal string") code. + +def test_p_code(): + for code, input, expected, expectedback in [ + ('p','abc', '\x00', ''), + ('1p', 'abc', '\x00', ''), + ('2p', 'abc', '\x01a', 'a'), + ('3p', 'abc', '\x02ab', 'ab'), + ('4p', 'abc', '\x03abc', 'abc'), + ('5p', 'abc', '\x03abc\x00', 'abc'), + ('6p', 'abc', '\x03abc\x00\x00', 'abc'), + ('1000p', 'x'*1000, '\xff' + 'x'*999, 'x'*255)]: + got = struct.pack(code, input) + if got != expected: + raise TestFailed("pack(%r, %r) == %r but expected %r" % + (code, input, got, expected)) + (got,) = struct.unpack(code, got) + if got != expectedback: + raise TestFailed("unpack(%r, %r) == %r but expected %r" % + (code, input, got, expectedback)) + +test_p_code() + + +########################################################################### +# SF bug 705836. "f" had a severe rounding bug, where a carry +# from the low-order discarded bits could propagate into the exponent +# field, causing the result to be wrong by a factor of 2. + +def test_705836(): + import math + + for base in range(1, 33): + # smaller <- largest representable float less than base. + delta = 0.5 + while base - delta / 2.0 != base: + delta /= 2.0 + smaller = base - delta + # Packing this rounds away a solid string of trailing 1 bits. + packed = struct.pack("f", smaller) + verify(bigpacked == string_reverse(packed), + ">f pack should be byte-reversal of f", bigpacked)[0] + verify(base == unpacked) + + # Largest finite IEEE single. + big = (1 << 24) - 1 + big = math.ldexp(big, 127 - 23) + packed = struct.pack(">f", big) + unpacked = struct.unpack(">f", packed)[0] + verify(big == unpacked) + + # The same, but tack on a 1 bit so it rounds up to infinity. + big = (1 << 25) - 1 + big = math.ldexp(big, 127 - 24) + try: + packed = struct.pack(">f", big) + except OverflowError: + pass + else: + TestFailed("expected OverflowError") + +test_705836() From python-checkins at python.org Tue May 23 17:44:35 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 17:44:35 +0200 (CEST) Subject: [Python-checkins] r46115 - python/bippolito-newstruct Message-ID: <20060523154435.6B6A31E4018@bag.python.org> Author: bob.ippolito Date: Tue May 23 17:44:35 2006 New Revision: 46115 Added: python/bippolito-newstruct/ - copied from r46114, python/trunk/ Log: branch for newstruct integration From buildbot at python.org Tue May 23 17:46:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 15:46:42 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060523154642.68AEC1E401E@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/752 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 18:09:05 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 18:09:05 +0200 (CEST) Subject: [Python-checkins] r46116 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h sandbox/trunk/decimal-c/decimal.py Message-ID: <20060523160905.C2B941E4018@bag.python.org> Author: georg.brandl Date: Tue May 23 18:09:04 2006 New Revision: 46116 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h sandbox/trunk/decimal-c/decimal.py Log: Make subclassing possible. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 18:09:04 2006 @@ -178,6 +178,7 @@ static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); static int decimal_nonzero(decimalobject *); static decimalobject *decimal_copy(decimalobject *); +static decimalobject *_decimal_from_pylong(PyTypeObject *, PyObject *, contextobject *); static PyObject * py_context_shallow_copy(PyObject *, PyObject *, PyObject *); static contextobject * context_shallow_copy(contextobject *); @@ -185,7 +186,7 @@ static decimalobject * -_new_decimalobj(long ndigits, char sign, long exp) +_new_decimalobj(PyTypeObject *type, long ndigits, char sign, long exp) { decimalobject *new; char *arr; @@ -198,7 +199,7 @@ PyErr_NoMemory(); return NULL; } - new = (decimalobject *)PyObject_NEW(decimalobject, &PyDecimal_DecimalType); + new = (decimalobject *)type->tp_alloc(type, 0); if (new == NULL) return NULL; new->sign = sign; @@ -208,6 +209,9 @@ return new; } +#define _NEW_decimalobj(ndigits, sign, exp) \ + _new_decimalobj(self->ob_type, ndigits, sign, exp) + /* Check whether the number(s) aren't really numbers. * * If x and/or y are sNaN, signal, possibly storing the result @@ -275,7 +279,7 @@ return decimal_copy(self); } - new = _new_decimalobj(self->ob_size + 1, /* we possibly need a new digit */ + new = _NEW_decimalobj(self->ob_size + 1, /* we possibly need a new digit */ self->sign, self->exp); if (!new) return NULL; @@ -312,7 +316,7 @@ _round_down(decimalobject *self, long prec, long expdiff, contextobject *ctx) { long i; - decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); + decimalobject *new = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); if (!new) return NULL; for (i = 0; i < prec; i++) new->digits[i] = self->digits[i]; @@ -324,7 +328,7 @@ _round_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) { long i; - decimalobject *new = _new_decimalobj(prec, self->sign, self->exp - expdiff); + decimalobject *new = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); decimalobject *new2 = NULL; if (!new) return NULL; for (i = 0; i < prec; i++) @@ -357,7 +361,7 @@ long i; assert(expdiff > 0); if (!tmp) { - tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + tmp = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; for (i = 0; i < prec; i++) tmp->digits[i] = self->digits[i]; @@ -383,7 +387,7 @@ long i; decimalobject *tmp; assert(expdiff > 0); - tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + tmp = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; for (i = 0; i < prec; i++) tmp->digits[i] = self->digits[i]; @@ -404,7 +408,7 @@ decimalobject *tmp; long i; assert(expdiff > 0); - tmp = _new_decimalobj(prec, self->sign, self->exp - expdiff); + tmp = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); if (!tmp) return NULL; for (i = 0; i < prec; i++) tmp->digits[i] = self->digits[i]; @@ -486,7 +490,7 @@ else i = prec; - new = _new_decimalobj(i, self->sign, + new = _NEW_decimalobj(i, self->sign, self->ob_size - prec + self->exp); if (!new) return NULL; while (i--) @@ -502,14 +506,14 @@ } if (prec == 0) { - new = _new_decimalobj(self->ob_size+1, self->sign, self->exp); + new = _NEW_decimalobj(self->ob_size+1, self->sign, self->exp); if (!new) return NULL; new->digits[0] = 0; for (i = 1; i < new->ob_size; i++) new->digits[i] = self->digits[i-1]; prec = 1; } else if (prec < 0) { - new = _new_decimalobj(2, self->sign, + new = _NEW_decimalobj(2, self->sign, self->exp + self->ob_size - prec - 1); if (!new) return NULL; new->digits[0] = 0; @@ -525,7 +529,7 @@ return new; else if (expdiff > 0) { /* we need to extend precision */ - new2 = _new_decimalobj(prec, new->sign, new->exp - expdiff); + new2 = _NEW_decimalobj(prec, new->sign, new->exp - expdiff); if (!new2) { Py_DECREF(new); return NULL; @@ -612,7 +616,7 @@ return context_raise_error(ctx, S_INV_OPERATION, "rescale(a, INF)", NULL); if (!decimal_nonzero(self)) { - ans = _new_decimalobj(1, self->sign, exp); + ans = _NEW_decimalobj(1, self->sign, exp); if (!ans) return NULL; ans->digits[0] = 0; @@ -627,14 +631,14 @@ digits += 1; if (digits < 0) { - ans = _new_decimalobj(2, self->sign, self->exp - digits); + ans = _NEW_decimalobj(2, self->sign, self->exp - digits); if (!ans) return NULL; ans->digits[0] = 0; ans->digits[1] = 1; digits = 1; } else { - ans = _new_decimalobj(self->ob_size+1, self->sign, self->exp); + ans = _NEW_decimalobj(self->ob_size+1, self->sign, self->exp); if (!ans) return NULL; for (i = 0; i < self->ob_size; i++) @@ -796,6 +800,25 @@ return ans; } +/* convert something to a Decimal. Returns NULL on failure, but + * does not set an exception! */ +static decimalobject * +_convert_to_decimal(PyTypeObject *type, PyObject *thing, contextobject *ctx) +{ + if (PyDecimal_Check(thing)) { + Py_INCREF(thing); + return (decimalobject *)thing; + } else if (PyInt_Check(thing)) { + long val = PyInt_AsLong(thing); + if (val == -1 && PyErr_Occurred()) + return NULL; + return (decimalobject *)decimal_from_long(type, val); + } else if (PyLong_Check(thing)) { + return _decimal_from_pylong(type, thing, ctx); + } + return NULL; +} + #define STUB_HEAD static PyObject * #define STUB_TAIL (PyObject *self, PyObject *args) { return NULL; } #define STUB_TAIL1 (PyObject *self) { return NULL; } @@ -804,19 +827,54 @@ static char *ctxkwlist[] = {"context", 0}; -#define PARSECONTEXT(methname) \ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" methname, ctxkwlist, &ctx)) \ - { return NULL; } \ +#define ENSURE_DECIMAL(methname, dec) \ + dec = _convert_to_decimal((PyObject *)dec, ctx); \ + if (!dec) { \ + PyErr_SetString(PyExc_TypeError, methname ": " #dec " must be a Decimal object"); \ + return NULL; \ + } + +#define ENSURE_CONTEXT(methname, ctx) \ if (ctx == NULL) { \ if (!(ctx = getcontext())) return NULL; \ } else if (!PyDecimalContext_Check(ctx)) { \ - PyErr_SetString(PyExc_TypeError, "context must be a Context object"); \ + PyErr_SetString(PyExc_TypeError, methname ": context must be a Context object"); \ return NULL; \ } +#define PARSE_CONTEXT(methname, ctx) \ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" methname, ctxkwlist, &ctx)) \ + { return NULL; } \ + ENSURE_CONTEXT(methname, ctx) + STUB(compare) -STUB(max) -STUB(min) + +static decimalobject * +decimal_max(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"other", "context", 0}; + decimalobject *other = NULL; + contextobject *ctx = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:max", kwlist, + &other, &ctx)) + return NULL; + ENSURE_CONTEXT("max", ctx); + +} + +static decimalobject * +decimal_min(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"other", "context", 0}; + decimalobject *other = NULL; + contextobject *ctx = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:min", kwlist, + &other, &ctx)) + return NULL; + ENSURE_CONTEXT("max", ctx); +} /* strip trailing 0s, change anything equal to 0 to 0e0 */ static decimalobject * @@ -824,7 +882,7 @@ { decimalobject *dup, *new; contextobject *ctx = NULL; - PARSECONTEXT("normalize"); + PARSE_CONTEXT("normalize", ctx); if (ISSPECIAL(self)) { decimalobject *nan = NULL; @@ -838,7 +896,7 @@ return dup; if (!decimal_nonzero(dup)) { - new = _new_decimalobj(1, dup->sign, 0); + new = _NEW_decimalobj(1, dup->sign, 0); Py_DECREF(dup); if (!new) return NULL; new->digits[0] = 0; @@ -947,7 +1005,7 @@ decimalobject *new; long size = self->ob_size; - new = _new_decimalobj(size, self->sign, self->exp); + new = _NEW_decimalobj(size, self->sign, self->exp); if (!new) return NULL; while (--size) @@ -1158,7 +1216,7 @@ } static decimalobject * -_decimal_fromliteralnan(char *str, long len, contextobject *ctx) +_decimal_fromliteralnan(PyTypeObject *type, char *str, long len, contextobject *ctx) { char literalsign = 0, sign = 0; decimalobject *new; @@ -1206,7 +1264,7 @@ return context_raise_error(ctx, C_CONV_SYNTAX, "diagnostic info too long", NULL); - new = _new_decimalobj(size, sign, 0); + new = _new_decimalobj(type, size, sign, 0); if (!new) return NULL; for (i = 0; i < size; i++) @@ -1220,7 +1278,7 @@ }; static decimalobject * -_decimal_fromliteralinfinity(char *str) +_decimal_fromliteralinfinity(PyTypeObject *type, char *str) { decimalobject *new; char **p = infinities; @@ -1235,7 +1293,7 @@ } } while (*++p); if (sign) { - new = _new_decimalobj(1, sign, 0); + new = _new_decimalobj(type, 1, sign, 0); if (!new) return NULL; new->digits[0] = 0; @@ -1245,7 +1303,7 @@ } static decimalobject * -_decimal_fromliteral(char *str, long len, contextobject *ctx) +_decimal_fromliteral(PyTypeObject *type, char *str, long len, contextobject *ctx) { long ipos = 0; /* start of integral digits */ long dpos = -1; /* decimal point location */ @@ -1317,7 +1375,7 @@ finish: ndigits = dend - ipos - (dpos<0 ? 0 : 1); - new = _new_decimalobj(ndigits, sign, exp); + new = _new_decimalobj(type, ndigits, sign, exp); if (!new) return NULL; i = 0; @@ -1333,32 +1391,38 @@ "invalid literal for Decimal", NULL); } -PyObject * -PyDecimal_FromString(char *buffer, long buf_len, contextobject *ctx) +static PyObject * +decimal_from_string(PyTypeObject *type, char *buffer, + long buf_len, contextobject *ctx) { decimalobject *new; - new = _decimal_fromliteralinfinity(buffer); + new = _decimal_fromliteralinfinity(type, buffer); if (new) return (PyObject *)new; if (PyErr_Occurred()) return NULL; - new = _decimal_fromliteralnan(buffer, buf_len, ctx); + new = _decimal_fromliteralnan(type, buffer, buf_len, ctx); if (new) return (PyObject *)new; if (PyErr_Occurred()) return NULL; - return (PyObject *)_decimal_fromliteral(buffer, buf_len, ctx); + return (PyObject *)_decimal_fromliteral(type, buffer, buf_len, ctx); } +PyObject * +PyDecimal_FromString(char *buffer, long buf_len, contextobject *ctx) +{ + return decimal_from_string(&PyDecimal_DecimalType, buffer, buf_len, ctx); +} PyObject * -PyDecimal_FromLong(long value) +_decimal_from_long(PyTypeObject *type, long value) { decimalobject *new; long v = value; int ndigits = 0, neg = 0, i = 0; if (value == 0) { - new = _new_decimalobj(1, 0, 0); + new = _new_decimalobj(type, 1, 0, 0); if (!new) return NULL; new->digits[0] = 0; return (PyObject *)new; @@ -1372,7 +1436,7 @@ v /= 10; } - new = _new_decimalobj(ndigits, (neg ? SIGN_NEG : SIGN_POS), 0); + new = _new_decimalobj(type, ndigits, (neg ? SIGN_NEG : SIGN_POS), 0); if (!new) return NULL; while (value) { new->digits[ndigits-i-1] = value % 10; @@ -1382,9 +1446,15 @@ return (PyObject *)new; } +PyObject * +PyDecimal_FromLong(long value) +{ + return _decimal_from_long(&PyDecimal_DecimalType, value); +} + /* convert from a 3-tuple of (sign, digits, exp) */ PyObject * -PyDecimal_FromSequence(PyObject *seq) +decimal_from_sequence(PyTypeObject *type, PyObject *seq) { decimalobject *new = NULL; PyObject *tup, *digits, *digtup = NULL, *item; @@ -1415,7 +1485,7 @@ PyErr_SetString(PyExc_ValueError, "Invalid arguments"); goto err; } - new = _new_decimalobj(PyTuple_GET_SIZE(digtup), sign, exp); + new = _new_decimalobj(type, PyTuple_GET_SIZE(digtup), sign, exp); for (i = 0; i < new->ob_size; i++) { item = PyTuple_GET_ITEM(digtup, i); if (PyInt_Check(item)) { @@ -1448,10 +1518,42 @@ err: Py_XDECREF(digtup); Py_DECREF(tup); - Py_DECREF(new); + Py_XDECREF(new); return NULL; } +PyObject * +PyDecimal_FromSequence(PyObject *seq) +{ + return decimal_from_sequence(&PyDecimal_DecimalType, seq); +} + +static decimalobject * +_decimal_from_pylong(PyTypeObject *type, PyObject *val, contextobject *ctx) +{ + char *buffer; + Py_ssize_t buf_len = 0; + PyObject *strval; + decimalobject *res; + + strval = PyObject_Str(val); + if (!strval) + return NULL; + if (PyObject_AsCharBuffer(strval, (const char **)&buffer, &buf_len) == -1) { + Py_DECREF(strval); + return NULL; + } + if (buf_len > LONG_MAX) { + PyErr_NoMemory(); + return NULL; + } + res = (decimalobject *)decimal_from_string(type, buffer, buf_len, ctx); + Py_DECREF(strval); + return res; +} + +static PyObject *decimal_new(PyTypeObject *, PyObject *, PyObject *); + static PyObject * decimal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -1460,20 +1562,18 @@ PyObject *context = NULL; PyObject *repr; contextobject *ctx; - int decref_value = 0; char *buffer; Py_ssize_t buf_len = 0; - - /* XXX - if (type != &PyDecimal_DecimalType) - return decimal_subtype_new(type, args, kwds); - */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:Decimal", kwlist, &value, &context)) return NULL; + if (value == NULL) { - value = PyString_FromString("0"); - decref_value = 1; + decimalobject *new = _new_decimalobj(type, 1, 0, 0); + if (!new) return NULL; + new->digits[0] = 0; + return new; } if (PyFloat_Check(value)) { @@ -1486,42 +1586,28 @@ return (PyObject *)decimal_copy((decimalobject *)value); if (PyList_Check(value) || PyTuple_Check(value)) - return PyDecimal_FromSequence(value); + return decimal_from_sequence(type, value); if (PyInt_Check(value)) { long x = PyInt_AsLong(value); if (x == -1 && PyErr_Occurred()) return NULL; - return PyDecimal_FromLong(x); - } - - if (PyLong_Check(value)) { - /* XXX: possibly do div-mod-loop */ - value = PyObject_Str(value); - if (!value) - return NULL; - decref_value = 1; + return decimal_from_long(type, x); } ctx = getcontext(); - if (!ctx) { - if (decref_value) { - Py_DECREF(value); - } - return NULL; - } + if (!ctx) return NULL; + + if (PyLong_Check(value)) + return (PyObject *)_decimal_from_pylong(type, value, ctx); /* try buffer interface (e.g. strings and unicode) */ if (PyObject_AsCharBuffer(value, (const char **)&buffer, &buf_len) == 0) { if (buf_len > LONG_MAX) { PyErr_NoMemory(); - if (decref_value) { Py_DECREF(value); } return NULL; } - PyObject *res = (PyObject *)PyDecimal_FromString(buffer, buf_len, ctx); - if (decref_value) { - Py_DECREF(value); - } + PyObject *res = (PyObject *)decimal_from_string(type, buffer, buf_len, ctx); return res; } @@ -1545,11 +1631,13 @@ static PyObject * decimal_str(decimalobject *d) { - /* XXX: quick hack */ char buf[1000]; char dig[2]; long i; - + + /*if (ISSPECIAL(d)) { + if (ISNAN(d)) + */ dig[1] = 0; PyOS_snprintf(buf, 1000, "sign=%i, exp=%ld, digits=", d->sign, d->exp); for (i = 0; i < d->ob_size; i++) { @@ -1653,7 +1741,7 @@ PyErr_NoMemory(); return -1; } - for (i = 0; i < PyTuple_GET_SIZE(value); i++) { + for (i = 0; i < size; i++) { item = PyTuple_GET_ITEM(value, i); if (!PyInt_Check(item)) { PyObject_FREE(arr); @@ -1695,8 +1783,8 @@ PyObject_HEAD_INIT(NULL) 0, /* ob_size */ MODULE_NAME ".Decimal", /* tp_name */ - sizeof(decimalobject) - sizeof(char), /* tp_basicsize */ - sizeof(char), /* tp_itemsize */ + sizeof(decimalobject), /* tp_basicsize */ + 0, /* tp_itemsize */ (destructor)decimal_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ @@ -1730,7 +1818,7 @@ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ - 0, /* tp_alloc */ + PyType_GenericAlloc, /* tp_alloc */ decimal_new, /* tp_new */ PyObject_Del, /* tp_free */ }; Modified: sandbox/trunk/decimal-c/decimal.h ============================================================================== --- sandbox/trunk/decimal-c/decimal.h (original) +++ sandbox/trunk/decimal-c/decimal.h Tue May 23 18:09:04 2006 @@ -43,6 +43,12 @@ static PyTypeObject PyDecimal_DecimalContextType; +/* functions *****************************************************************/ + +PyAPI_FUNC(PyObject *) PyDecimal_FromString(char *, long, PyDecimalContextObject *); +PyAPI_FUNC(PyObject *) PyDecimal_FromLong(long); +PyAPI_FUNC(PyObject *) PyDecimal_FromSequence(PyObject *); + /* type checking macros ******************************************************/ #define PyDecimal_Check(op) PyObject_TypeCheck((op), &PyDecimal_DecimalType) Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Tue May 23 18:09:04 2006 @@ -470,10 +470,6 @@ # (-1)**_sign * _int * 10**_exp # Special values are signified by _is_special == True - @property - def _is_special(self): - return (self._sign > 1) - # # We're immutable, so use __new__ not __init__ # def __new__(cls, value="0", context=None): # """Create a decimal point instance. From python-checkins at python.org Tue May 23 18:13:12 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 18:13:12 +0200 (CEST) Subject: [Python-checkins] r46117 - in python/bippolito-newstruct: Lib/struct.py Modules/Setup.dist Modules/_struct.c Modules/structmodule.c setup.py Message-ID: <20060523161312.BD8F11E4018@bag.python.org> Author: bob.ippolito Date: Tue May 23 18:13:11 2006 New Revision: 46117 Added: python/bippolito-newstruct/Lib/struct.py (contents, props changed) python/bippolito-newstruct/Modules/_struct.c (contents, props changed) Removed: python/bippolito-newstruct/Modules/structmodule.c Modified: python/bippolito-newstruct/Modules/Setup.dist python/bippolito-newstruct/setup.py Log: replace stdlib struct with newstruct in branch Added: python/bippolito-newstruct/Lib/struct.py ============================================================================== --- (empty file) +++ python/bippolito-newstruct/Lib/struct.py Tue May 23 18:13:11 2006 @@ -0,0 +1,76 @@ +""" +Functions to convert between Python values and C structs. +Python strings are used to hold the data representing the C struct +and also as format strings to describe the layout of data in the C struct. + +The optional first format char indicates byte order, size and alignment: + @: native order, size & alignment (default) + =: native order, std. size & alignment + <: little-endian, std. size & alignment + >: big-endian, std. size & alignment + !: same as > + +The remaining chars indicate types of args and must match exactly; +these can be preceded by a decimal repeat count: + x: pad byte (no data); c:char; b:signed byte; B:unsigned byte; + h:short; H:unsigned short; i:int; I:unsigned int; + l:long; L:unsigned long; f:float; d:double. +Special cases (preceding decimal count indicates length): + s:string (array of char); p: pascal string (with count byte). +Special case (only available in native format): + P:an integer type that is wide enough to hold a pointer. +Special case (not in native mode unless 'long long' in platform C): + q:long long; Q:unsigned long long +Whitespace between formats is ignored. + +The variable struct.error is an exception raised on errors. +""" +__version__ = '0.1' + +from _struct import Struct, error + +_MAXCACHE = 100 +_cache = {} + +def _compile(fmt): + # Internal: compile struct pattern + if len(_cache) >= _MAXCACHE: + _cache.clear() + s = Struct(fmt) + _cache[fmt] = s + return s + +def calcsize(fmt): + """ + Return size of C struct described by format string fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.size + +def pack(fmt, *args): + """ + Return string containing values v1, v2, ... packed according to fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack(*args) + +def unpack(fmt, s): + """ + Unpack the string, containing packed C structure data, according + to fmt. Requires len(string)==calcsize(fmt). + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack(s) + Modified: python/bippolito-newstruct/Modules/Setup.dist ============================================================================== --- python/bippolito-newstruct/Modules/Setup.dist (original) +++ python/bippolito-newstruct/Modules/Setup.dist Tue May 23 18:13:11 2006 @@ -167,7 +167,7 @@ #array arraymodule.c # array objects #cmath cmathmodule.c # -lm # complex math library functions #math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking +#_struct _struct.c # binary structure packing/unpacking #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support Added: python/bippolito-newstruct/Modules/_struct.c ============================================================================== --- (empty file) +++ python/bippolito-newstruct/Modules/_struct.c Tue May 23 18:13:11 2006 @@ -0,0 +1,1355 @@ +/* struct module -- pack values into and (out of) strings */ + +/* New version supporting byte order, alignment and size options, + character strings, and unsigned numbers */ + +#include "Python.h" +#include "structseq.h" +#include "structmember.h" +#include + + +/* compatibility macros */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + + + +/* The translation function for each format character is table driven */ + +typedef struct _formatdef { + char format; + int size; + int alignment; + PyObject* (*unpack)(const char *, + const struct _formatdef *); + int (*pack)(char *, PyObject *, + const struct _formatdef *); +} formatdef; + +typedef struct _formatcode { + const struct _formatdef *fmtdef; + int offset; + int repeat; +} formatcode; + +/* Struct object interface */ + +typedef struct { + PyObject_HEAD + int s_size; + int s_len; + formatcode *s_codes; + PyObject *s_format; + PyObject *weakreflist; /* List of weak references */ +} PyStructObject; + +PyAPI_DATA(PyTypeObject) PyStruct_Type; + +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) + + +/* Exception */ + +static PyObject *StructError; + + +/* Define various structs to figure out the alignments of types */ + + +typedef struct { char c; short x; } st_short; +typedef struct { char c; int x; } st_int; +typedef struct { char c; long x; } st_long; +typedef struct { char c; float x; } st_float; +typedef struct { char c; double x; } st_double; +typedef struct { char c; void *x; } st_void_p; + +#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) +#define INT_ALIGN (sizeof(st_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) +#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) +#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) + +/* We can't support q and Q in native mode unless the compiler does; + in std mode, they're 8 bytes on all platforms. */ +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +#define STRINGIFY(x) #x + +#ifdef __powerc +#pragma options align=reset +#endif + +/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ + +static PyObject * +get_pylong(PyObject *v) +{ + PyNumberMethods *m; + + assert(v != NULL); + if (PyInt_Check(v)) + return PyLong_FromLong(PyInt_AS_LONG(v)); + if (PyLong_Check(v)) { + Py_INCREF(v); + return v; + } + m = v->ob_type->tp_as_number; + if (m != NULL && m->nb_long != NULL) { + v = m->nb_long(v); + if (v == NULL) + return NULL; + if (PyLong_Check(v)) + return v; + Py_DECREF(v); + } + PyErr_SetString(StructError, + "cannot convert argument to long"); + return NULL; +} + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x = PyInt_AsLong(v); + if (x == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_SetString(StructError, + "required argument is not an integer"); + return -1; + } + *p = x; + return 0; +} + + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + if (PyLong_Check(v)) { + unsigned long x = PyLong_AsUnsignedLong(v); + if (x == (unsigned long)(-1) && PyErr_Occurred()) + return -1; + *p = x; + return 0; + } + else { + return get_long(v, (long *)p); + } +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsLongLong(v); + Py_DECREF(v); + if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsUnsignedLongLong(v); + Py_DECREF(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/* Floating point helpers */ + +static PyObject * +unpack_float(const char *p, /* start of 4-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack4((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + +static PyObject * +unpack_double(const char *p, /* start of 8-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack8((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + + +/* A large number of small routines follow, with names of the form + + [bln][up]_TYPE + + [bln] distiguishes among big-endian, little-endian and native. + [pu] distiguishes between pack (to struct) and unpack (from struct). + TYPE is one of char, byte, ubyte, etc. +*/ + +/* Native mode routines. ****************************************************/ +/* NOTE: + In all n[up]_ routines handling types larger than 1 byte, there is + *no* guarantee that the p pointer is properly aligned for each type, + therefore memcpy is called. An intermediate variable is used to + compensate for big-endian architectures. + Normally both the intermediate variable and the memcpy call will be + skipped by C optimisation in little-endian architectures (gcc >= 2.91 + does this). */ + +static PyObject * +nu_char(const char *p, const formatdef *f) +{ + return PyString_FromStringAndSize(p, 1); +} + +static PyObject * +nu_byte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(signed char *)p); +} + +static PyObject * +nu_ubyte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(unsigned char *)p); +} + +static PyObject * +nu_short(const char *p, const formatdef *f) +{ + short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_ushort(const char *p, const formatdef *f) +{ + unsigned short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_int(const char *p, const formatdef *f) +{ + int x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_uint(const char *p, const formatdef *f) +{ + unsigned int x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong((unsigned long)x); +} + +static PyObject * +nu_long(const char *p, const formatdef *f) +{ + long x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong(x); +} + +static PyObject * +nu_ulong(const char *p, const formatdef *f) +{ + unsigned long x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong(x); +} + +/* Native mode doesn't support q or Q unless the platform C supports + long long (or, on Windows, __int64). */ + +#ifdef HAVE_LONG_LONG + +static PyObject * +nu_longlong(const char *p, const formatdef *f) +{ + PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromLongLong(x); +} + +static PyObject * +nu_ulonglong(const char *p, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLongLong(x); +} + +#endif + +static PyObject * +nu_float(const char *p, const formatdef *f) +{ + float x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble((double)x); +} + +static PyObject * +nu_double(const char *p, const formatdef *f) +{ + double x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble(x); +} + +static PyObject * +nu_void_p(const char *p, const formatdef *f) +{ + void *x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromVoidPtr(x); +} + +static int +np_byte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < -128 || x > 127){ + PyErr_SetString(StructError, + "byte format requires -128<=number<=127"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_ubyte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > 255){ + PyErr_SetString(StructError, + "ubyte format requires 0<=number<=255"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_char(char *p, PyObject *v, const formatdef *f) +{ + if (!PyString_Check(v) || PyString_Size(v) != 1) { + PyErr_SetString(StructError, + "char format require string of length 1"); + return -1; + } + *p = *PyString_AsString(v); + return 0; +} + +static int +np_short(char *p, PyObject *v, const formatdef *f) +{ + long x; + short y; + if (get_long(v, &x) < 0) + return -1; + if (x < SHRT_MIN || x > SHRT_MAX){ + PyErr_SetString(StructError, + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); + return -1; + } + y = (short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_ushort(char *p, PyObject *v, const formatdef *f) +{ + long x; + unsigned short y; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > USHRT_MAX){ + PyErr_SetString(StructError, + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + return -1; + } + y = (unsigned short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int y; + if (get_long(v, &x) < 0) + return -1; + y = (int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + unsigned int y; + if (get_ulong(v, &x) < 0) + return -1; + y = (unsigned int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_long(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulong(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + if (get_ulong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +#ifdef HAVE_LONG_LONG + +static int +np_longlong(char *p, PyObject *v, const formatdef *f) +{ + PY_LONG_LONG x; + if (get_longlong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + if (get_ulonglong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} +#endif + +static int +np_float(char *p, PyObject *v, const formatdef *f) +{ + float x = (float)PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof(double)); + return 0; +} + +static int +np_void_p(char *p, PyObject *v, const formatdef *f) +{ + void *x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsVoidPtr(v); + Py_DECREF(v); + if (x == NULL && PyErr_Occurred()) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static formatdef native_table[] = { + {'x', sizeof(char), 0, NULL}, + {'b', sizeof(char), 0, nu_byte, np_byte}, + {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, + {'c', sizeof(char), 0, nu_char, np_char}, + {'s', sizeof(char), 0, NULL}, + {'p', sizeof(char), 0, NULL}, + {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, + {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, + {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, + {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, + {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, + {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, +#ifdef HAVE_LONG_LONG + {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, +#endif + {0} +}; + +/* Big-endian routines. *****************************************************/ + +static PyObject * +bu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +bu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +bu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +bu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +bu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 0); +} + +static PyObject * +bu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 0); +} + +static int +bp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 0); +} + +static int +bp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 0); +} + +static formatdef bigendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, bu_int, bp_int}, + {'B', 1, 0, bu_uint, bp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, bu_int, bp_int}, + {'H', 2, 0, bu_uint, bp_uint}, + {'i', 4, 0, bu_int, bp_int}, + {'I', 4, 0, bu_uint, bp_uint}, + {'l', 4, 0, bu_int, bp_int}, + {'L', 4, 0, bu_uint, bp_uint}, + {'q', 8, 0, bu_longlong, bp_longlong}, + {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, + {'f', 4, 0, bu_float, bp_float}, + {'d', 8, 0, bu_double, bp_double}, + {0} +}; + +/* Little-endian routines. *****************************************************/ + +static PyObject * +lu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +lu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +lu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +lu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +lu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 1); +} + +static PyObject * +lu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 1); +} + +static int +lp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 1); +} + +static int +lp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 1); +} + +static formatdef lilendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, lu_int, lp_int}, + {'B', 1, 0, lu_uint, lp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, lu_int, lp_int}, + {'H', 2, 0, lu_uint, lp_uint}, + {'i', 4, 0, lu_int, lp_int}, + {'I', 4, 0, lu_uint, lp_uint}, + {'l', 4, 0, lu_int, lp_int}, + {'L', 4, 0, lu_uint, lp_uint}, + {'q', 8, 0, lu_longlong, lp_longlong}, + {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, + {'f', 4, 0, lu_float, lp_float}, + {'d', 8, 0, lu_double, lp_double}, + {0} +}; + + +static const formatdef * +whichtable(char **pfmt) +{ + const char *fmt = (*pfmt)++; /* May be backed out of later */ + switch (*fmt) { + case '<': + return lilendian_table; + case '>': + case '!': /* Network byte order is big-endian */ + return bigendian_table; + case '=': { /* Host byte order -- different from native in aligment! */ + int n = 1; + char *p = (char *) &n; + if (*p == 1) + return lilendian_table; + else + return bigendian_table; + } + default: + --*pfmt; /* Back out of pointer increment */ + /* Fall through */ + case '@': + return native_table; + } +} + + +/* Get the table entry for a format code */ + +static const formatdef * +getentry(int c, const formatdef *f) +{ + for (; f->format != '\0'; f++) { + if (f->format == c) { + return f; + } + } + PyErr_SetString(StructError, "bad char in struct format"); + return NULL; +} + + +/* Align a size according to a format code */ + +static int +align(int size, int c, const formatdef *e) +{ + if (e->format == c) { + if (e->alignment) { + size = ((size + e->alignment - 1) + / e->alignment) + * e->alignment; + } + } + return size; +} + + +/* calculate the size of a format string */ + +static int +prepare_s(PyStructObject *self) +{ + const formatdef *f; + const formatdef *e; + formatcode *codes; + + const char *s; + const char *fmt; + char c; + int size, len, numcodes, num, itemsize, x; + + fmt = PyString_AS_STRING(self->s_format); + + f = whichtable((char **)&fmt); + + s = fmt; + size = 0; + len = 0; + numcodes = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') { + x = num*10 + (c - '0'); + if (x/10 != num) { + PyErr_SetString( + StructError, + "overflow in item count"); + return -1; + } + num = x; + } + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + return -1; + + switch (c) { + case 's': /* fall through */ + case 'p': len++; break; + case 'x': break; + default: len += num; break; + } + if (c != 'x') numcodes++; + + itemsize = e->size; + size = align(size, c, e); + x = num * itemsize; + size += x; + if (x/itemsize != num || size < 0) { + PyErr_SetString(StructError, + "total struct size too long"); + return -1; + } + } + + self->s_size = size; + self->s_len = len; + codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + if (codes == NULL) { + PyErr_NoMemory(); + return -1; + } + self->s_codes = codes; + + s = fmt; + size = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + + size = align(size, c, e); + if (c != 'x') { + codes->offset = size; + codes->repeat = num; + codes->fmtdef = e; + codes++; + } + size += num * e->size; + } + codes->fmtdef = NULL; + codes->offset = -1; + codes->repeat = -1; + + return 0; +} + +static PyObject * +s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + static PyObject *not_yet_string; + + assert(type != NULL && type->tp_alloc != NULL); + + self = type->tp_alloc(type, 0); + if (self != NULL) { + PyStructObject *s = (PyStructObject*)self; + Py_INCREF(Py_None); + s->s_format = Py_None; + s->s_codes = NULL; + s->s_size = -1; + s->s_len = -1; + } + return self; +} + +static int +s_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyStructObject *soself = (PyStructObject *)self; + PyObject *o_format = NULL; + int ret = 0; + static char *kwlist[] = {"format", 0}; + + assert(PyStruct_Check(self)); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, + &o_format)) + return -1; + + Py_INCREF(o_format); + Py_XDECREF(soself->s_format); + soself->s_format = o_format; + + ret = prepare_s(soself); + return ret; +} + +static void +s_dealloc(PyStructObject *s) +{ + int sts = 0; + if (s->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *)s); + if (s->s_codes != NULL) { + PyMem_FREE(s->s_codes); + } + Py_XDECREF(s->s_format); + s->ob_type->tp_free((PyObject *)s); +} + +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See struct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + result = PyTuple_New(soself->s_len); + if (result == NULL) + return NULL; + + + restart = PyString_AS_STRING(inputstr); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + const char *res = restart + code->offset; + if (e->format == 's') { + v = PyString_FromStringAndSize(res, code->repeat); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else if (e->format == 'p') { + n = *(unsigned char*)res; + if (n >= code->repeat) + n = code->repeat - 1; + v = PyString_FromStringAndSize(res + 1, n); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else { + for (n = 0; n < code->repeat; n++) { + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + res += e->size; + } + } + } + + return result; +fail: + Py_DECREF(result); + return NULL; +}; + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See struct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + restart = PyString_AS_STRING(result); + memset(restart, '\0', soself->s_size); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + char *res = restart + code->offset; + if (e->format == 's') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 's' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > code->repeat) + n = code->repeat; + if (n > 0) + memcpy(res, PyString_AS_STRING(v), n); + } else if (e->format == 'p') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 'p' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > (code->repeat - 1)) + n = code->repeat - 1; + if (n > 0) + memcpy(res + 1, PyString_AS_STRING(v), n); + if (n > 255) + n = 255; + *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + } else { + for (n = 0; n < code->repeat; n++) { + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; + res += e->size; + } + } + } + + return result; + +fail: + Py_DECREF(result); + return NULL; + +} + + +/* List of functions */ + +static struct PyMethodDef s_methods[] = { + {"pack", s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {NULL, NULL} /* sentinel */ +}; + +PyDoc_STRVAR(s__doc__, "Compiled struct object"); + +#define OFF(x) offsetof(PyStructObject, x) + +static PyMemberDef s_memberlist[] = { + {"format", T_OBJECT, OFF(s_format), RO, + "struct format string"}, + {"size", T_INT, OFF(s_size), RO, + "struct size in bytes"}, + {"_len", T_INT, OFF(s_len), RO, + "number of items expected in tuple"}, + {NULL} /* Sentinel */ +}; + + +static +PyTypeObject PyStructType = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "Struct", + sizeof(PyStructObject), + 0, + (destructor)s_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ + s__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + s_methods, /* tp_methods */ + s_memberlist, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + s_init, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + s_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + +/* Module initialization */ + +PyMODINIT_FUNC +init_struct(void) +{ + PyObject *m = Py_InitModule("_struct", NULL); + if (m == NULL) + return; + + /* Add some symbolic constants to the module */ + if (StructError == NULL) { + StructError = PyErr_NewException("struct.error", NULL, NULL); + if (StructError == NULL) + return; + } + Py_INCREF(StructError); + PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); + PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); +} Deleted: /python/bippolito-newstruct/Modules/structmodule.c ============================================================================== --- /python/bippolito-newstruct/Modules/structmodule.c Tue May 23 18:13:11 2006 +++ (empty file) @@ -1,1293 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include - -PyDoc_STRVAR(struct__doc__, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ -\n\ -The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ -\n\ -The remaining chars indicate types of args and must match exactly;\n\ -these can be preceded by a decimal repeat count:\n\ - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ - h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double.\n\ -Special cases (preceding decimal count indicates length):\n\ - s:string (array of char); p: pascal string (with count byte).\n\ -Special case (only available in native format):\n\ - P:an integer type that is wide enough to hold a pointer.\n\ -Special case (not in native mode unless 'long long' in platform C):\n\ - q:long long; Q:unsigned long long\n\ -Whitespace between formats is ignored.\n\ -\n\ -The variable struct.error is an exception raised on errors."); - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsVoidPtr(v); - Py_DECREF(v); - if (x == NULL && PyErr_Occurred()) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -calcsize(const char *fmt, const formatdef *f) -{ - const formatdef *e; - const char *s; - char c; - int size, num, itemsize, x; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - return size; -} - - -PyDoc_STRVAR(calcsize__doc__, -"calcsize(fmt) -> int\n\ -Return size of C struct described by format string fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_calcsize(PyObject *self, PyObject *args) -{ - char *fmt; - const formatdef *f; - int size; - - if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(pack__doc__, -"pack(fmt, v1, v2, ...) -> string\n\ -Return string containing values v1, v2, ... packed according to fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_pack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - PyObject *format, *result, *v; - char *fmt; - int size, num; - Py_ssize_t i, n; - char *s, *res, *restart, *nres; - char c; - - if (args == NULL || !PyTuple_Check(args) || - (n = PyTuple_Size(args)) < 1) - { - PyErr_SetString(PyExc_TypeError, - "struct.pack requires at least one argument"); - return NULL; - } - format = PyTuple_GetItem(args, 0); - fmt = PyString_AsString(format); - if (!fmt) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - result = PyString_FromStringAndSize((char *)NULL, size); - if (result == NULL) - return NULL; - - s = fmt; - i = 1; - res = restart = PyString_AsString(result); - - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - nres = restart + align((int)(res-restart), c, e); - /* Fill padd bytes with zeros */ - while (res < nres) - *res++ = '\0'; - if (num == 0 && c != 's') - continue; - do { - if (c == 'x') { - /* doesn't consume arguments */ - memset(res, '\0', num); - res += num; - break; - } - if (i >= n) { - PyErr_SetString(StructError, - "insufficient arguments to pack"); - goto fail; - } - v = PyTuple_GetItem(args, i++); - if (v == NULL) - goto fail; - if (c == 's') { - /* num is string size, not repeat count */ - Py_ssize_t n; - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res, PyString_AsString(v), n); - if (n < num) - memset(res+n, '\0', num-n); - res += num; - break; - } - else if (c == 'p') { - /* num is string size + 1, - to fit in the count byte */ - Py_ssize_t n; - num--; /* now num is max string size */ - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res+1, PyString_AsString(v), n); - if (n < num) - /* no real need, just to be nice */ - memset(res+1+n, '\0', num-n); - if (n > 255) - n = 255; - /* store the length byte */ - *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); - res += num; - break; - } - else { - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } while (--num > 0); - } - - if (i < n) { - PyErr_SetString(StructError, - "too many arguments for pack format"); - goto fail; - } - - return result; - - fail: - Py_DECREF(result); - return NULL; -} - - -PyDoc_STRVAR(unpack__doc__, -"unpack(fmt, string) -> (v1, v2, ...)\n\ -Unpack the string, containing packed C structure data, according\n\ -to fmt. Requires len(string)==calcsize(fmt).\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_unpack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - char *str, *start, *fmt, *s; - char c; - int len, size, num; - PyObject *res, *v; - - if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - if (size != len) { - PyErr_SetString(StructError, - "unpack str size does not match format"); - return NULL; - } - res = PyList_New(0); - if (res == NULL) - return NULL; - str = start; - s = fmt; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - str = start + align((int)(str-start), c, e); - if (num == 0 && c != 's') - continue; - - do { - if (c == 'x') { - str += num; - break; - } - if (c == 's') { - /* num is string size, not repeat count */ - v = PyString_FromStringAndSize(str, num); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else if (c == 'p') { - /* num is string buffer size, - not repeat count */ - int n = *(unsigned char*)str; - /* first byte (unsigned) is string size */ - if (n >= num) - n = num-1; - v = PyString_FromStringAndSize(str+1, n); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else { - v = e->unpack(str, e); - if (v == NULL) - goto fail; - str += e->size; - } - if (v == NULL || PyList_Append(res, v) < 0) - goto fail; - Py_DECREF(v); - } while (--num > 0); - } - - v = PyList_AsTuple(res); - Py_DECREF(res); - return v; - - fail: - Py_DECREF(res); - return NULL; -} - - -/* List of functions */ - -static PyMethodDef struct_methods[] = { - {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, - {"pack", struct_pack, METH_VARARGS, pack__doc__}, - {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initstruct(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule4("struct", struct_methods, struct__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); -} Modified: python/bippolito-newstruct/setup.py ============================================================================== --- python/bippolito-newstruct/setup.py (original) +++ python/bippolito-newstruct/setup.py Tue May 23 18:13:11 2006 @@ -1444,7 +1444,7 @@ 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('struct', ['structmodule.c'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', From python-checkins at python.org Tue May 23 18:19:50 2006 From: python-checkins at python.org (martin.blais) Date: Tue, 23 May 2006 18:19:50 +0200 (CEST) Subject: [Python-checkins] r46118 - in python/branches/blais-bytebuf: Modules/bytebufmodule.c setup.py Message-ID: <20060523161950.61F931E4022@bag.python.org> Author: martin.blais Date: Tue May 23 18:19:49 2006 New Revision: 46118 Added: python/branches/blais-bytebuf/Modules/bytebufmodule.c - copied, changed from r46090, python/branches/blais-bytebuf/Objects/bufferobject.c Modified: python/branches/blais-bytebuf/setup.py Log: Basic byte buffer class skeleton for adding fast I/O functions. Copied: python/branches/blais-bytebuf/Modules/bytebufmodule.c (from r46090, python/branches/blais-bytebuf/Objects/bufferobject.c) ============================================================================== --- python/branches/blais-bytebuf/Objects/bufferobject.c (original) +++ python/branches/blais-bytebuf/Modules/bytebufmodule.c Tue May 23 18:19:49 2006 @@ -1,657 +1,353 @@ - -/* Buffer object implementation */ +/* Bytebuf object interface */ #include "Python.h" +/* Note: the object's structure is private */ -typedef struct { - PyObject_HEAD - PyObject *b_base; - void *b_ptr; - Py_ssize_t b_size; - Py_ssize_t b_offset; - int b_readonly; - long b_hash; -} PyBufferObject; +#ifndef Py_BYTEBUFOBJECT_H +#define Py_BYTEBUFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif -static int -get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size) -{ - if (self->b_base == NULL) { - assert (ptr != NULL); - *ptr = self->b_ptr; - *size = self->b_size; - } - else { - Py_ssize_t count, offset; - readbufferproc proc; - PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer; - if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) { - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return 0; - } - if (self->b_readonly) - proc = bp->bf_getreadbuffer; - else - proc = (readbufferproc)bp->bf_getwritebuffer; - if ((count = (*proc)(self->b_base, 0, ptr)) < 0) - return 0; - /* apply constraints to the start/end */ - if (self->b_offset > count) - offset = count; - else - offset = self->b_offset; - *(char **)ptr = *(char **)ptr + offset; - if (self->b_size == Py_END_OF_BUFFER) - *size = count; - else - *size = self->b_size; - if (offset + *size > count) - *size = count - offset; - } - return 1; -} +PyAPI_DATA(PyTypeObject) PyBytebuf_Type; +#define PyBytebuf_Check(op) ((op)->ob_type == &PyBytebuf_Type) -static PyObject * -buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset, void *ptr, - int readonly) -{ - PyBufferObject * b; +#define Py_END_OF_BYTEBUF (-1) - if (size < 0 && size != Py_END_OF_BUFFER) { - PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); - return NULL; - } - if (offset < 0) { - PyErr_SetString(PyExc_ValueError, - "offset must be zero or positive"); - return NULL; - } - - b = PyObject_NEW(PyBufferObject, &PyBuffer_Type); - if ( b == NULL ) - return NULL; - - Py_XINCREF(base); - b->b_base = base; - b->b_ptr = ptr; - b->b_size = size; - b->b_offset = offset; - b->b_readonly = readonly; - b->b_hash = -1; +PyAPI_FUNC(PyObject *) PyBytebuf_New(Py_ssize_t size); - return (PyObject *) b; +#ifdef __cplusplus } +#endif +#endif /* !Py_BYTEBUFOBJECT_H */ -static PyObject * -buffer_from_object(PyObject *base, Py_ssize_t size, Py_ssize_t offset, int readonly) -{ - if (offset < 0) { - PyErr_SetString(PyExc_ValueError, - "offset must be zero or positive"); - return NULL; - } - if ( PyBuffer_Check(base) && (((PyBufferObject *)base)->b_base) ) { - /* another buffer, refer to the base object */ - PyBufferObject *b = (PyBufferObject *)base; - if (b->b_size != Py_END_OF_BUFFER) { - Py_ssize_t base_size = b->b_size - offset; - if (base_size < 0) - base_size = 0; - if (size == Py_END_OF_BUFFER || size > base_size) - size = base_size; - } - offset += b->b_offset; - base = b->b_base; - } - return buffer_from_memory(base, size, offset, NULL, readonly); -} +/* Byte Buffer object implementation */ -PyObject * -PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) -{ - PyBufferProcs *pb = base->ob_type->tp_as_buffer; +/* + * bytebuf object structure declaration. + */ +typedef struct { + PyObject_HEAD - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_SetString(PyExc_TypeError, "buffer object expected"); - return NULL; - } + /* Base pointer location */ + void* b_ptr; - return buffer_from_object(base, size, offset, 1); -} - -PyObject * -PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) -{ - PyBufferProcs *pb = base->ob_type->tp_as_buffer; + /* Total size in bytes of the area that we can access. The allocated + memory must be at least as large as this size. */ + Py_ssize_t b_size; - if ( pb == NULL || - pb->bf_getwritebuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_SetString(PyExc_TypeError, "buffer object expected"); - return NULL; - } +} PyBytebufObject; - return buffer_from_object(base, size, offset, 0); -} -PyObject * -PyBuffer_FromMemory(void *ptr, Py_ssize_t size) -{ - return buffer_from_memory(NULL, size, 0, ptr, 1); -} - -PyObject * -PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) +/* + * Given a bytebuf object, return the buffer memory (in 'ptr' and 'size') and + * true if there was no error. + */ +static int +get_buf(PyBytebufObject *self, void **ptr, Py_ssize_t *size) { - return buffer_from_memory(NULL, size, 0, ptr, 0); + assert(ptr != NULL); + *ptr = self->b_ptr; + *size = self->b_size; + return 1; } +/* + * Create a new bytebuf where we allocate the memory ourselves. + */ PyObject * -PyBuffer_New(Py_ssize_t size) +PyBytebuf_New(Py_ssize_t size) { - PyObject *o; - PyBufferObject * b; + PyObject *o; + PyBytebufObject * b; - if (size < 0) { - PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); - return NULL; - } - /* XXX: check for overflow in multiply */ - /* Inline PyObject_New */ - o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size); - if ( o == NULL ) - return PyErr_NoMemory(); - b = (PyBufferObject *) PyObject_INIT(o, &PyBuffer_Type); - - b->b_base = NULL; - b->b_ptr = (void *)(b + 1); - b->b_size = size; - b->b_offset = 0; - b->b_readonly = 0; - b->b_hash = -1; + if (size < 0) { + PyErr_SetString(PyExc_ValueError, + "size must be zero or positive"); + return NULL; + } + + /* FIXME: check for overflow in multiply */ + o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size); + if ( o == NULL ) + return PyErr_NoMemory(); + b = (PyBytebufObject *) PyObject_INIT(o, &PyBytebuf_Type); + + /* We setup the memory buffer to be right after the object itself. */ + b->b_ptr = (void *)(b + 1); + b->b_size = size; - return o; + return o; } /* Methods */ +/* + * Constructor. + */ static PyObject * -buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw) +bytebuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) { - PyObject *ob; - Py_ssize_t offset = 0; - Py_ssize_t size = Py_END_OF_BUFFER; + Py_ssize_t size = -1; - if (!_PyArg_NoKeywords("buffer()", kw)) - return NULL; - - if (!PyArg_ParseTuple(args, "O|nn:buffer", &ob, &offset, &size)) - return NULL; - return PyBuffer_FromObject(ob, offset, size); -} + if (!_PyArg_NoKeywords("bytebuf()", kw)) + return NULL; + + if (!PyArg_ParseTuple(args, "n:bytebuf", &size)) + return NULL; -PyDoc_STRVAR(buffer_doc, -"buffer(object [, offset[, size]])\n\ -\n\ -Create a new buffer object which references the given object.\n\ -The buffer will reference a slice of the target object from the\n\ -start of the object (or at the specified offset). The slice will\n\ -extend to the end of the target object (or with the specified size)."); + if ( size <= 0 ) { + PyErr_SetString(PyExc_TypeError, + "size must be greater than zero"); + return NULL; + } + return PyBytebuf_New(size); +} +/* + * Destructor. + */ static void -buffer_dealloc(PyBufferObject *self) +bytebuf_dealloc(PyBytebufObject *self) { - Py_XDECREF(self->b_base); - PyObject_DEL(self); + /* Note: by virtue of the memory buffer being allocated with the PyObject + itself, this frees the buffer as well. */ + PyObject_DEL(self); } +/* + * Comparison. + */ static int -buffer_compare(PyBufferObject *self, PyBufferObject *other) +bytebuf_compare(PyBytebufObject *self, PyBytebufObject *other) { - void *p1, *p2; - Py_ssize_t len_self, len_other, min_len; - int cmp; - - if (!get_buf(self, &p1, &len_self)) - return -1; - if (!get_buf(other, &p2, &len_other)) - return -1; - min_len = (len_self < len_other) ? len_self : len_other; - if (min_len > 0) { - cmp = memcmp(p1, p2, min_len); - if (cmp != 0) - return cmp; - } - return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; + void *p1, *p2; + Py_ssize_t len_self, len_other, min_len; + int cmp; + + if (!get_buf(self, &p1, &len_self)) + return -1; + if (!get_buf(other, &p2, &len_other)) + return -1; + min_len = (len_self < len_other) ? len_self : len_other; + if (min_len > 0) { + cmp = memcmp(p1, p2, min_len); + if (cmp != 0) + return cmp; + } + return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; } + +/* + * Conversion to 'repr' string. + */ static PyObject * -buffer_repr(PyBufferObject *self) +bytebuf_repr(PyBytebufObject *self) { - const char *status = self->b_readonly ? "read-only" : "read-write"; - - if ( self->b_base == NULL ) - return PyString_FromFormat("<%s buffer ptr %p, size %zd at %p>", - status, - self->b_ptr, - self->b_size, - self); - else - return PyString_FromFormat( - "<%s buffer for %p, size %zd, offset %zd at %p>", - status, - self->b_base, - self->b_size, - self->b_offset, - self); -} - -static long -buffer_hash(PyBufferObject *self) -{ - void *ptr; - Py_ssize_t size; - register Py_ssize_t len; - register unsigned char *p; - register long x; - - if ( self->b_hash != -1 ) - return self->b_hash; - - /* XXX potential bugs here, a readonly buffer does not imply that the - * underlying memory is immutable. b_readonly is a necessary but not - * sufficient condition for a buffer to be hashable. Perhaps it would - * be better to only allow hashing if the underlying object is known to - * be immutable (e.g. PyString_Check() is true). Another idea would - * be to call tp_hash on the underlying object and see if it raises - * an error. */ - if ( !self->b_readonly ) - { - PyErr_SetString(PyExc_TypeError, - "writable buffers are not hashable"); - return -1; - } - - if (!get_buf(self, &ptr, &size)) - return -1; - p = (unsigned char *) ptr; - len = size; - x = *p << 7; - while (--len >= 0) - x = (1000003*x) ^ *p++; - x ^= size; - if (x == -1) - x = -2; - self->b_hash = x; - return x; + return PyString_FromFormat("", + self->b_ptr, + self->b_size, + self); } +/* + * Conversion to string. + */ static PyObject * -buffer_str(PyBufferObject *self) +bytebuf_str(PyBytebufObject *self) { - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return NULL; - return PyString_FromStringAndSize((const char *)ptr, size); + void *ptr; + Py_ssize_t size; + if (!get_buf(self, &ptr, &size)) + return NULL; + return PyString_FromStringAndSize((const char *)ptr, size); } -/* Sequence methods */ +/* Bytebuf methods */ + +/* + * Returns the buffer for reading or writing. + */ static Py_ssize_t -buffer_length(PyBufferObject *self) +bytebuf_getwritebuf(PyBytebufObject *self, Py_ssize_t idx, void **pp) { - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; - return size; + Py_ssize_t size; + if ( idx != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent bytebuf segment"); + return -1; + } + if (!get_buf(self, pp, &size)) + return -1; + return size; } -static PyObject * -buffer_concat(PyBufferObject *self, PyObject *other) +static Py_ssize_t +bytebuf_getsegcount(PyBytebufObject *self, Py_ssize_t *lenp) { - PyBufferProcs *pb = other->ob_type->tp_as_buffer; - void *ptr1, *ptr2; - char *p; - PyObject *ob; - Py_ssize_t size, count; - - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return NULL; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return NULL; - } + void *ptr; + Py_ssize_t size; + if (!get_buf(self, &ptr, &size)) + return -1; + if (lenp) + *lenp = size; + return 1; +} - if (!get_buf(self, &ptr1, &size)) - return NULL; - - /* optimize special case */ - if ( size == 0 ) - { - Py_INCREF(other); - return other; - } - - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) - return NULL; - - ob = PyString_FromStringAndSize(NULL, size + count); - if ( ob == NULL ) - return NULL; - p = PyString_AS_STRING(ob); - memcpy(p, ptr1, size); - memcpy(p + size, ptr2, count); +static Py_ssize_t +bytebuf_getcharbuf(PyBytebufObject *self, Py_ssize_t idx, const char **pp) +{ + void *ptr; + Py_ssize_t size; + if ( idx != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent bytebuf segment"); + return -1; + } + if (!get_buf(self, &ptr, &size)) + return -1; + *pp = (const char *)ptr; + return size; +} - /* there is an extra byte in the string object, so this is safe */ - p[size + count] = '\0'; - return ob; -} +PyDoc_STRVAR(module_doc, + "This module defines an object type which can represent a fixed size\n\ +buffer of bytes in momery, from which you can directly read and into\n\ +which you can directly write objects in various other types. This is\n\ +used to avoid buffer copies in network I/O as much as possible. For\n\ +example, socket recv() can directly fill a byte buffer's memory and\n\ +send() can read the data to be sent from one as well.\n\ +\n\ +In addition, a byte buffer has two pointers within it, that delimit\n\ +an active slice, the current \"position\" and the \"limit\". The\n\ +active region of a byte buffer is located within these boundaries.\n\ +\n\ +This class is heaviliy inspired from Java's NIO ByteBuffer class.\n\ +\n\ +The constructor is:\n\ +\n\ +bytebuf(nbytes) -- create a new bytebuf\n\ +"); -static PyObject * -buffer_repeat(PyBufferObject *self, Py_ssize_t count) -{ - PyObject *ob; - register char *p; - void *ptr; - Py_ssize_t size; - - if ( count < 0 ) - count = 0; - if (!get_buf(self, &ptr, &size)) - return NULL; - ob = PyString_FromStringAndSize(NULL, size * count); - if ( ob == NULL ) - return NULL; - - p = PyString_AS_STRING(ob); - while ( count-- ) - { - memcpy(p, ptr, size); - p += size; - } - /* there is an extra byte in the string object, so this is safe */ - *p = '\0'; +/* FIXME: needs an update */ - return ob; -} +/* PyDoc_STRVAR(bytebuf_doc, */ +/* "bytebuf(object [, offset[, size]])\n\ */ +/* \n\ */ +/* Create a new bytebuf object which references the given object.\n\ */ +/* The bytebuf will reference a slice of the target object from the\n\ */ +/* start of the object (or at the specified offset). The slice will\n\ */ +/* extend to the end of the target object (or with the specified size)."); */ -static PyObject * -buffer_item(PyBufferObject *self, Py_ssize_t idx) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return NULL; - if ( idx < 0 || idx >= size ) { - PyErr_SetString(PyExc_IndexError, "buffer index out of range"); - return NULL; - } - return PyString_FromStringAndSize((char *)ptr + idx, 1); -} +PyDoc_STRVAR(bytebuftype_doc, + "bytebuf(size) -> bytebuf\n\ +\n\ +Return a new bytebuf with a new buffer of fixed size 'size'.\n\ +\n\ +Methods:\n\ +\n\ +Attributes:\n\ +\n\ +"); -static PyObject * -buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return NULL; - if ( left < 0 ) - left = 0; - if ( right < 0 ) - right = 0; - if ( right > size ) - right = size; - if ( right < left ) - right = left; - return PyString_FromStringAndSize((char *)ptr + left, - right - left); -} -static int -buffer_ass_item(PyBufferObject *self, Py_ssize_t idx, PyObject *other) -{ - PyBufferProcs *pb; - void *ptr1, *ptr2; - Py_ssize_t size; - Py_ssize_t count; - - if ( self->b_readonly ) { - PyErr_SetString(PyExc_TypeError, - "buffer is read-only"); - return -1; - } - - if (!get_buf(self, &ptr1, &size)) - return -1; - - if (idx < 0 || idx >= size) { - PyErr_SetString(PyExc_IndexError, - "buffer assignment index out of range"); - return -1; - } - - pb = other ? other->ob_type->tp_as_buffer : NULL; - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return -1; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return -1; - } - - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) - return -1; - if ( count != 1 ) { - PyErr_SetString(PyExc_TypeError, - "right operand must be a single byte"); - return -1; - } +static PyBufferProcs bytebuf_as_buffer = { + (readbufferproc)bytebuf_getwritebuf, + (writebufferproc)bytebuf_getwritebuf, + (segcountproc)bytebuf_getsegcount, + (charbufferproc)bytebuf_getcharbuf, +}; - ((char *)ptr1)[idx] = *(char *)ptr2; - return 0; -} +PyTypeObject PyBytebuf_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "bytebuf", + sizeof(PyBytebufObject), + 0, + (destructor)bytebuf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)bytebuf_compare, /* tp_compare */ + (reprfunc)bytebuf_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)bytebuf_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &bytebuf_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + bytebuftype_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + bytebuf_new, /* tp_new */ +}; -static int -buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObject *other) -{ - PyBufferProcs *pb; - void *ptr1, *ptr2; - Py_ssize_t size; - Py_ssize_t slice_len; - Py_ssize_t count; - - if ( self->b_readonly ) { - PyErr_SetString(PyExc_TypeError, - "buffer is read-only"); - return -1; - } - - pb = other ? other->ob_type->tp_as_buffer : NULL; - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return -1; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return -1; - } - if (!get_buf(self, &ptr1, &size)) - return -1; - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) - return -1; - - if ( left < 0 ) - left = 0; - else if ( left > size ) - left = size; - if ( right < left ) - right = left; - else if ( right > size ) - right = size; - slice_len = right - left; - - if ( count != slice_len ) { - PyErr_SetString( - PyExc_TypeError, - "right operand length must match slice length"); - return -1; - } - if ( slice_len ) - memcpy((char *)ptr1 + left, ptr2, slice_len); +/*********************** Install Module **************************/ - return 0; -} +/* No functions in array module. */ +static PyMethodDef a_methods[] = { + {NULL, NULL, 0, NULL} /* Sentinel */ +}; -/* Buffer methods */ -static Py_ssize_t -buffer_getreadbuf(PyBufferObject *self, Py_ssize_t idx, void **pp) +PyMODINIT_FUNC +initbytebuf(void) { - Py_ssize_t size; - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent buffer segment"); - return -1; - } - if (!get_buf(self, pp, &size)) - return -1; - return size; -} + PyObject *m; -static Py_ssize_t -buffer_getwritebuf(PyBufferObject *self, Py_ssize_t idx, void **pp) -{ - if ( self->b_readonly ) - { - PyErr_SetString(PyExc_TypeError, "buffer is read-only"); - return -1; - } - return buffer_getreadbuf(self, idx, pp); -} + PyBytebuf_Type.ob_type = &PyType_Type; + m = Py_InitModule3("bytebuf", a_methods, module_doc); + if (m == NULL) + return; -static Py_ssize_t -buffer_getsegcount(PyBufferObject *self, Py_ssize_t *lenp) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; - if (lenp) - *lenp = size; - return 1; + Py_INCREF((PyObject *)&PyBytebuf_Type); + PyModule_AddObject(m, "BytebufType", (PyObject *)&PyBytebuf_Type); + Py_INCREF((PyObject *)&PyBytebuf_Type); + PyModule_AddObject(m, "bytebuf", (PyObject *)&PyBytebuf_Type); + /* No need to check the error here, the caller will do that */ } -static Py_ssize_t -buffer_getcharbuf(PyBufferObject *self, Py_ssize_t idx, const char **pp) -{ - void *ptr; - Py_ssize_t size; - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent buffer segment"); - return -1; - } - if (!get_buf(self, &ptr, &size)) - return -1; - *pp = (const char *)ptr; - return size; -} -static PySequenceMethods buffer_as_sequence = { - (lenfunc)buffer_length, /*sq_length*/ - (binaryfunc)buffer_concat, /*sq_concat*/ - (ssizeargfunc)buffer_repeat, /*sq_repeat*/ - (ssizeargfunc)buffer_item, /*sq_item*/ - (ssizessizeargfunc)buffer_slice, /*sq_slice*/ - (ssizeobjargproc)buffer_ass_item, /*sq_ass_item*/ - (ssizessizeobjargproc)buffer_ass_slice, /*sq_ass_slice*/ -}; +/* + TODO + ---- + - Update doc. + - Add hash function + - Add support for sequence methods. -static PyBufferProcs buffer_as_buffer = { - (readbufferproc)buffer_getreadbuf, - (writebufferproc)buffer_getwritebuf, - (segcountproc)buffer_getsegcount, - (charbufferproc)buffer_getcharbuf, -}; -PyTypeObject PyBuffer_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "buffer", - sizeof(PyBufferObject), - 0, - (destructor)buffer_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)buffer_compare, /* tp_compare */ - (reprfunc)buffer_repr, /* tp_repr */ - 0, /* tp_as_number */ - &buffer_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)buffer_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)buffer_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &buffer_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - buffer_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - buffer_new, /* tp_new */ -}; + Pending Issues + -------------- + - Should we support weakrefs? + +*/ + Modified: python/branches/blais-bytebuf/setup.py ============================================================================== --- python/branches/blais-bytebuf/setup.py (original) +++ python/branches/blais-bytebuf/setup.py Tue May 23 18:19:49 2006 @@ -334,6 +334,10 @@ # array objects exts.append( Extension('array', ['arraymodule.c']) ) + + # array objects + exts.append( Extension('bytebuf', ['bytebufmodule.c']) ) + # complex math library functions exts.append( Extension('cmath', ['cmathmodule.c'], libraries=math_libs) ) From python-checkins at python.org Tue May 23 18:22:56 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 18:22:56 +0200 (CEST) Subject: [Python-checkins] r46119 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060523162256.1E5D41E401D@bag.python.org> Author: georg.brandl Date: Tue May 23 18:22:55 2006 New Revision: 46119 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Fix off-by-one errors. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 18:22:55 2006 @@ -181,6 +181,7 @@ static decimalobject *_decimal_from_pylong(PyTypeObject *, PyObject *, contextobject *); static PyObject * py_context_shallow_copy(PyObject *, PyObject *, PyObject *); static contextobject * context_shallow_copy(contextobject *); +static PyObject *decimal_from_long(PyTypeObject *, long); /* Decimal methods ***********************************************************/ @@ -1003,13 +1004,13 @@ decimal_copy(decimalobject *self) { decimalobject *new; - long size = self->ob_size; + long i; - new = _NEW_decimalobj(size, self->sign, self->exp); + new = _NEW_decimalobj(self->ob_size, self->sign, self->exp); if (!new) return NULL; - while (--size) - new->digits[size] = self->digits[size]; + for (i = 0; i < self->ob_size; i++) + new->digits[i] = self->digits[i]; return new; } @@ -1364,7 +1365,7 @@ /* If it's not a zero, strip leading 0s */ for (p = str+ipos; p-str < dend; ++p) { - if (*p != '0' && *p != '.') { + if (*p != '0') { /* first nonzero digit */ ipos = (p-str); goto finish; @@ -1415,7 +1416,7 @@ } PyObject * -_decimal_from_long(PyTypeObject *type, long value) +decimal_from_long(PyTypeObject *type, long value) { decimalobject *new; long v = value; @@ -1449,7 +1450,7 @@ PyObject * PyDecimal_FromLong(long value) { - return _decimal_from_long(&PyDecimal_DecimalType, value); + return decimal_from_long(&PyDecimal_DecimalType, value); } /* convert from a 3-tuple of (sign, digits, exp) */ From python-checkins at python.org Tue May 23 18:38:42 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 18:38:42 +0200 (CEST) Subject: [Python-checkins] r46120 - sandbox/trunk/decimal-c/decimal.py Message-ID: <20060523163842.469321E4018@bag.python.org> Author: georg.brandl Date: Tue May 23 18:38:41 2006 New Revision: 46120 Modified: sandbox/trunk/decimal-c/decimal.py Log: Allow _WorkReps to be converted. Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Tue May 23 18:38:41 2006 @@ -470,6 +470,14 @@ # (-1)**_sign * _int * 10**_exp # Special values are signified by _is_special == True + # HACK: to get support for converting WorkRep instances + def __new__(cls, value="0", context=None): + if isinstance(value, _WorkRep): + value = (value.sign, tuple(map(int, str(value.int))), int(value.exp)) + + return _decimal.Decimal.__new__(cls, value, context) + + # # We're immutable, so use __new__ not __init__ # def __new__(cls, value="0", context=None): # """Create a decimal point instance. From python-checkins at python.org Tue May 23 19:12:42 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 19:12:42 +0200 (CEST) Subject: [Python-checkins] r46121 - sandbox/trunk/rjsh-pybench Message-ID: <20060523171242.DE10D1E4018@bag.python.org> Author: richard.jones Date: Tue May 23 19:12:42 2006 New Revision: 46121 Added: sandbox/trunk/rjsh-pybench/ - copied from r46120, python/trunk/Tools/pybench/ Log: sandbox for messing with pybench From python-checkins at python.org Tue May 23 19:15:38 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 19:15:38 +0200 (CEST) Subject: [Python-checkins] r46122 - sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060523171538.9895C1E402A@bag.python.org> Author: richard.jones Date: Tue May 23 19:15:38 2006 New Revision: 46122 Modified: sandbox/trunk/rjsh-pybench/pybench.py Log: Various changes: - report and compare the min run time - enable sys.setcheckinterval(sys.maxint) - enable "verbose" mode (default off) to reduce console output - allow selection of specific benchmarks to run Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Tue May 23 19:15:38 2006 @@ -182,6 +182,7 @@ runs = len(self.times) if runs == 0: return 0,0 + mintime = min(self.times) totaltime = reduce(operator.add,self.times,0.0) avg = totaltime / float(runs) op_avg = totaltime / float(runs * self.rounds * self.operations) @@ -191,7 +192,7 @@ else: # use self.last_timing - not too accurate ov_avg = self.last_timing[2] - return avg,op_avg,ov_avg + return mintime,avg,op_avg,ov_avg ### Load Setup @@ -217,22 +218,32 @@ self.tests = {} self.version = 0.31 - def load_tests(self,setupmod,warp=1): + def load_tests(self,setupmod,warp=1, limitnames=""): self.warp = warp + if limitnames: + limitnames = re.compile(limitnames, re.I) + else: + limitnames = None tests = self.tests print 'Searching for tests...' setupmod.__dict__.values() for c in setupmod.__dict__.values(): - if hasattr(c,'is_a_test') and c.__name__ != 'Test': - tests[c.__name__] = c(warp) + if not hasattr(c,'is_a_test'): + continue + name = c.__name__ + if name == 'Test': + continue + if limitnames is not None and limitnames.search(name) is None: + continue + tests[name] = c(warp) l = tests.keys() l.sort() for t in l: print ' ',t print - def run(self): + def run(self, verbose): tests = self.tests.items() tests.sort() @@ -242,73 +253,84 @@ self.starttime = time.time() roundtime = clock() for i in range(self.rounds): - print ' Round %-25i real abs overhead' % (i+1) + if verbose: + print ' Round %-25i real abs overhead' % (i+1) for j in range(len(tests)): name,t = tests[j] - print '%30s:' % name, + if verbose: + print '%30s:' % name, t.run() - print ' %.3fr %.3fa %.3fo' % t.last_timing - print ' ----------------------' - print ' Average round time: %.3f seconds' % \ - ((clock() - roundtime)/(i+1)) - print + if verbose: + print ' %.3fr %.3fa %.3fo' % t.last_timing + if verbose: + print ' ----------------------' + print ' Average round time: %.3f seconds' % \ + ((clock() - roundtime)/(i+1)) + print + else: + print '%d ... done'%i self.roundtime = (clock() - roundtime) / self.rounds print def print_stat(self, compare_to=None, hidenoise=0): if not compare_to: - print '%-30s per run per oper. overhead' % 'Tests:' - print '-'*72 + print '%-30s min run avg run per oprn overhead' % 'Tests:' + print '-'*77 tests = self.tests.items() tests.sort() + totalmintime = 0 for name,t in tests: - avg,op_avg,ov_avg = t.stat() - print '%30s: %10.2f ms %7.2f us %7.2f ms' % \ - (name,avg*1000.0,op_avg*1000000.0,ov_avg*1000.0) - print '-'*72 - print '%30s: %10.2f ms' % \ - ('Average round time',self.roundtime * 1000.0) + mintime,avg,op_avg,ov_avg = t.stat() + totalmintime += mintime + print '%30s: %9.2f ms %9.2f ms %6.2f us %6.2f' % \ + (name,mintime*1000.0,avg*1000.0,op_avg*1000000.0,ov_avg*1000.0) + print '-'*77 + print '%30s: %9.2f ms' % \ + ('Notional minimum round time', totalmintime * 1000.0) else: - print '%-30s per run per oper. diff *)' % \ + print 'Comparing with: %s (rounds=%i, warp=%i)' % \ + (compare_to.name,compare_to.rounds,compare_to.warp) + print '%-30s min run cmp run avg run diff' % \ 'Tests:' - print '-'*72 + print '-'*77 tests = self.tests.items() tests.sort() compatible = 1 + totalmintime = other_totalmintime = 0 for name,t in tests: - avg,op_avg,ov_avg = t.stat() + mintime,avg,op_avg,ov_avg = t.stat() + totalmintime += mintime try: other = compare_to.tests[name] except KeyError: other = None if other and other.version == t.version and \ other.operations == t.operations: - avg1,op_avg1,ov_avg1 = other.stat() - qop_avg = (op_avg/op_avg1-1.0)*100.0 + mintime1,avg1,op_avg1,ov_avg1 = other.stat() + other_totalmintime += mintime1 + diff = (mintime/mintime1 - 1.0)*100.0 if hidenoise and abs(qop_avg) < 10: - qop_avg = '' + diff = '' else: - qop_avg = '%+7.2f%%' % qop_avg + diff = '%+7.2f%%' % diff else: - qavg,qop_avg = 'n/a', 'n/a' + qavg,diff = 'n/a', 'n/a' compatible = 0 - print '%30s: %10.2f ms %7.2f us %8s' % \ - (name,avg*1000.0,op_avg*1000000.0,qop_avg) - print '-'*72 + print '%30s: %8.2f ms %8.2f ms %8.2f ms %8s' % \ + (name,mintime*1000.0,mintime1*1000.0, avg*1000.0,diff) + print '-'*77 if compatible and compare_to.roundtime > 0 and \ compare_to.version == self.version: - print '%30s: %10.2f ms %+7.2f%%' % \ - ('Average round time',self.roundtime * 1000.0, - ((self.roundtime*self.warp)/ - (compare_to.roundtime*compare_to.warp)-1.0)*100.0) + print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ + ('Notional minimum round time', totalmintime * 1000.0, + other_totalmintime * 1000.0, + ((totalmintime*self.warp)/ + (other_totalmintime*compare_to.warp)-1.0)*100.0) else: - print '%30s: %10.2f ms n/a' % \ - ('Average round time',self.roundtime * 1000.0) - print - print '*) measured against: %s (rounds=%i, warp=%i)' % \ - (compare_to.name,compare_to.rounds,compare_to.warp) + print '%30s: %9.2f ms n/a' % \ + ('Notional minimum round time', totalmintime * 1000.0) print def print_machine(): @@ -339,7 +361,11 @@ SwitchOption('-S','show statistics of benchmarks',0), ArgumentOption('-w','set warp factor to arg',Setup.Warp_factor), SwitchOption('-d','hide noise in compares', 0), + SwitchOption('-v','verbose output (not recommended)', 0), SwitchOption('--no-gc','disable garbage collection', 0), + SwitchOption('--no-syscheck', + '"disable" sys check interval (set to sys.maxint)', 0), + ArgumentOption('-t', 'tests containing substring', '') ] about = """\ @@ -380,6 +406,11 @@ hidenoise = self.values['-d'] warp = self.values['-w'] nogc = self.values['--no-gc'] + limitnames = self.values['-t'] + verbose = self.values['-v'] + nosyscheck = self.values['--no-syscheck'] + + print 'PYBENCH',__version__ # Switch off GC if nogc: @@ -390,8 +421,13 @@ else: if self.values['--no-gc']: gc.disable() + print 'NO GC' + + # maximise sys check interval + if nosyscheck: + sys.setcheckinterval(sys.maxint) + print 'CHECKINTERVAL =', sys.maxint - print 'PYBENCH',__version__ print if not compare_to: @@ -436,9 +472,9 @@ # Create benchmark object bench = Benchmark() bench.rounds = rounds - bench.load_tests(Setup,warp) + bench.load_tests(Setup,warp,limitnames) try: - bench.run() + bench.run(verbose) except KeyboardInterrupt: print print '*** KeyboardInterrupt -- Aborting' From python-checkins at python.org Tue May 23 19:28:55 2006 From: python-checkins at python.org (runar.petursson) Date: Tue, 23 May 2006 19:28:55 +0200 (CEST) Subject: [Python-checkins] r46123 - in python/branches/runar-longslice-branch: Include/abstract.h Include/longobject.h Objects/abstract.c Objects/longobject.c Message-ID: <20060523172855.C3CB51E4018@bag.python.org> Author: runar.petursson Date: Tue May 23 19:28:54 2006 New Revision: 46123 Added: python/branches/runar-longslice-branch/ - copied from r46081, python/trunk/ Modified: python/branches/runar-longslice-branch/Include/abstract.h python/branches/runar-longslice-branch/Include/longobject.h python/branches/runar-longslice-branch/Objects/abstract.c python/branches/runar-longslice-branch/Objects/longobject.c Log: Long Patch and added slice-like parameters to the long constructor Modified: python/branches/runar-longslice-branch/Include/abstract.h ============================================================================== --- python/trunk/Include/abstract.h (original) +++ python/branches/runar-longslice-branch/Include/abstract.h Tue May 23 19:28:54 2006 @@ -776,6 +776,7 @@ */ PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); + PyAPI_FUNC(PyObject *) PyNumber_LongWithSlice(PyObject *o, Py_ssize_t start, Py_ssize_t end); /* Returns the o converted to a long integer object on success, Modified: python/branches/runar-longslice-branch/Include/longobject.h ============================================================================== --- python/trunk/Include/longobject.h (original) +++ python/branches/runar-longslice-branch/Include/longobject.h Tue May 23 19:28:54 2006 @@ -47,6 +47,7 @@ #endif /* HAVE_LONG_LONG */ PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); +PyAPI_FUNC(PyObject *) PyLong_FromStringWithSlice(char *, char **, int, Py_ssize_t, Py_ssize_t, Py_ssize_t); #ifdef Py_USING_UNICODE PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); #endif Modified: python/branches/runar-longslice-branch/Objects/abstract.c ============================================================================== --- python/trunk/Objects/abstract.c (original) +++ python/branches/runar-longslice-branch/Objects/abstract.c Tue May 23 19:28:54 2006 @@ -994,27 +994,14 @@ return type_error("int() argument must be a string or a number"); } -/* Add a check for embedded NULL-bytes in the argument. */ -static PyObject * -long_from_string(const char *s, Py_ssize_t len) +PyObject * +PyNumber_Long(PyObject *o) { - char *end; - PyObject *x; - - x = PyLong_FromString((char*)s, &end, 10); - if (x == NULL) - return NULL; - if (end != s + len) { - PyErr_SetString(PyExc_ValueError, - "null byte in argument for long()"); - Py_DECREF(x); - return NULL; - } - return x; + return PyNumber_LongWithSlice(o, 0, -1); } PyObject * -PyNumber_Long(PyObject *o) +PyNumber_LongWithSlice(PyObject *o, Py_ssize_t start, Py_ssize_t end) { PyNumberMethods *m; const char *buffer; @@ -1041,8 +1028,9 @@ * doesn't do. In particular long('9.5') must raise an * exception, not truncate the float. */ - return long_from_string(PyString_AS_STRING(o), - PyString_GET_SIZE(o)); + + return PyLong_FromStringWithSlice(PyString_AS_STRING(o), NULL, + 10, PyString_GET_SIZE(o), start, end); #ifdef Py_USING_UNICODE if (PyUnicode_Check(o)) /* The above check is done in PyLong_FromUnicode(). */ @@ -1051,7 +1039,8 @@ 10); #endif if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) - return long_from_string(buffer, buffer_len); + return PyLong_FromStringWithSlice(buffer, NULL, + 10, buffer_len, start, end); return type_error("long() argument must be a string or a number"); } Modified: python/branches/runar-longslice-branch/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/branches/runar-longslice-branch/Objects/longobject.c Tue May 23 19:28:54 2006 @@ -1304,6 +1304,34 @@ return (PyObject *)str; } +static twodigits _longdigitlookup[] = { + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 +}; +static twodigits* longdigitlookup = _longdigitlookup + 128; + /* *str points to the first digit in a string of base base digits. base * is a power of 2 (2, 4, 8, 16, or 32). *str is set to point to the first * non-digit (which may be *str!). A normalized long is returned. @@ -1328,20 +1356,8 @@ n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - for (;;) { - int k = -1; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else if (ch >= 'A') - k = ch - 'A' + 10; - if (k < 0 || k >= base) - break; + while (longdigitlookup[(int) *p] < (twodigits) base) ++p; - } *str = p; n = (p - start) * bits_per_char; if (n / bits_per_char != p - start) { @@ -1361,17 +1377,7 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else { - assert(ch >= 'A'); - k = ch - 'A' + 10; - } + int k = longdigitlookup[(int) *p]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1394,13 +1400,38 @@ } PyObject * -PyLong_FromString(char *str, char **pend, int base) -{ +PyLong_FromString(char *str, char **pend, int base) { + Py_ssize_t len = strlen(str); + return PyLong_FromStringWithSlice(str, pend, base, len, 0, len); +} + +PyObject * +PyLong_FromStringWithSlice(char *str, char **pend, int base, Py_ssize_t len, Py_ssize_t startpos, Py_ssize_t endpos) { int sign = 1; - char *start, *orig_str = str; PyLongObject *z; PyObject *strobj, *strrepr; - Py_ssize_t slen; + char *start, *orig_str = str; + char *end; + + /* Validate the Offset */ + if (startpos < 0) + startpos += len; + if (startpos >= len) { + PyErr_SetString(PyExc_ValueError, + "String index is out of range"); + return NULL; + } + if (startpos < 0) + startpos = 0; + + /* In the case of end=0, set end to length of string */ + if (endpos <= 0) + endpos += len; + if (endpos > len) + endpos = len; + + end = str + endpos; + str = str + startpos; if ((base != 0 && base < 2) || base > 36) { PyErr_SetString(PyExc_ValueError, @@ -1431,22 +1462,75 @@ if ((base & (base - 1)) == 0) z = long_from_binary_base(&str, base); else { - z = _PyLong_New(0); - for ( ; z != NULL; ++str) { - int k = -1; - PyLongObject *temp; - - if (*str <= '9') - k = *str - '0'; - else if (*str >= 'a') - k = *str - 'a' + 10; - else if (*str >= 'A') - k = *str - 'A' + 10; - if (k < 0 || k >= base) - break; - temp = muladd1(z, (digit)base, (digit)k); - Py_DECREF(z); - z = temp; + /* find length of the string of numeric characters */ + register twodigits c; /* current input character */ + char* scan = str; + Py_ssize_t i, convwidth, size_z; + twodigits convmultmax, convmult; + digit *pz, *pzstop; + while ((c = longdigitlookup[(int) *scan]) < (twodigits) base && scan < end) { + scan++; + } + + /* Create a long object that can contain the largest possible integer + that would fit in the string we've been given. This long is + manipulated in-place to perform the string-to-long conversion. */ + size_z = (int)((scan - str + 1) * log10(base) / log10(BASE)) + 1; + + /* Take advantage of the fact that the long internal representation + uses a base much larger than that allowed for the input string, and + find the number of digits of the input string that can always fit in a + single long digit. */ + convwidth = (int) (log10(BASE) / log10(base)) - 1; + convmultmax = base; + for (i = 1; i < convwidth; i ++) + convmultmax *= base; + + z = _PyLong_New(size_z); + z->ob_size = 0; + memset(z->ob_digit, 0, sizeof(*z->ob_digit)*size_z); + + /* do the conversion over all numeric characters in the input string; + grab digits in groups of size convwidth, and for each group, perform + z = z*(base^convwidth) + ((c1*base + c2)*base + c3*base)... */ + while (str < scan) { + pz = z->ob_digit; + pzstop = pz + z->ob_size; + + /* grab up to 'convwidth' digits from the input string */ + c = longdigitlookup[(int) *str++]; + for (i = 1; i < convwidth && str != scan; i ++) { + c *= base; + c += longdigitlookup[(int) *str++]; + } + + /* only calculate the shift if we couldn't get convwidth digits */ + convmult = convmultmax; + if (i != convwidth) { + convmult = base; + for (; i > 1; i --) + convmult *= base; + } + + for (;pz != pzstop; ++pz) { + c += ((twodigits) *pz) * convmult; + /* the AND and shift are apparently expensive enough + (for decimal numbers) so that it's less costly to add a + check for c != 0 before doing the AND+shift operation */ + if (c) { + *pz = (digit) (c & MASK); + c >>= SHIFT; + } + else { + *pz = 0; + } + } + *pz = (digit) c; + + /* update z size to indicate last updated digit */ + size_z = pz - z->ob_digit; + if (c && size_z >= z->ob_size) + z->ob_size = size_z + 1; } } if (z == NULL) @@ -1455,20 +1539,25 @@ goto onError; if (sign < 0 && z != NULL && z->ob_size != 0) z->ob_size = -(z->ob_size); - if (*str == 'L' || *str == 'l') + if (*str == 'L' || *str == 'l') { str++; + } while (*str && isspace(Py_CHARMASK(*str))) str++; - if (*str != '\0') + if (!(str == end || *str == '\0')) { goto onError; + } + if (str != orig_str + endpos) { + goto onError; + } if (pend) *pend = str; return (PyObject *) z; onError: Py_XDECREF(z); - slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200; - strobj = PyString_FromStringAndSize(orig_str, slen); + len = (endpos - startpos) < 200 ? (endpos - startpos) : 200; + strobj = PyString_FromStringAndSize(start, len); if (strobj == NULL) return NULL; strrepr = PyObject_Repr(strobj); @@ -3066,19 +3155,22 @@ { PyObject *x = NULL; int base = -909; /* unlikely! */ - static char *kwlist[] = {"x", "base", 0}; + Py_ssize_t start = 0; + Py_ssize_t end = 0; + static char *kwlist[] = {"x", "base", "start", "end", 0}; if (type != &PyLong_Type) return long_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:long", kwlist, - &x, &base)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oiii:long", kwlist, + &x, &base, &start, &end)) return NULL; if (x == NULL) return PyLong_FromLong(0L); if (base == -909) - return PyNumber_Long(x); - else if (PyString_Check(x)) - return PyLong_FromString(PyString_AS_STRING(x), NULL, base); + return PyNumber_LongWithSlice(x, start, end); + else if (PyString_Check(x)) { + return PyLong_FromStringWithSlice(PyString_AS_STRING(x), NULL, base, PyString_GET_SIZE(x), start, end); + } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(x)) return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x), From python-checkins at python.org Tue May 23 19:52:30 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 23 May 2006 19:52:30 +0200 (CEST) Subject: [Python-checkins] r46124 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/test_decimal.py Message-ID: <20060523175230.0BC591E401B@bag.python.org> Author: georg.brandl Date: Tue May 23 19:52:29 2006 New Revision: 46124 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/test_decimal.py Log: (For Tim:) This was an off-by-2*however-large-the-integer-was error. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 19:52:29 2006 @@ -1419,7 +1419,7 @@ decimal_from_long(PyTypeObject *type, long value) { decimalobject *new; - long v = value; + long v; int ndigits = 0, neg = 0, i = 0; if (value == 0) { @@ -1428,10 +1428,11 @@ new->digits[0] = 0; return (PyObject *)new; } else if (value < 0) { - v = -value; + value = -value; neg = 1; } + v = value; while (v) { ndigits++; v /= 10; @@ -1577,15 +1578,15 @@ return new; } + if (PyDecimal_Check(value)) + return (PyObject *)decimal_copy((decimalobject *)value); + if (PyFloat_Check(value)) { PyErr_SetString(PyExc_TypeError, "Cannot convert float to Decimal. " "First convert the float to a string."); return NULL; } - if (PyDecimal_Check(value)) - return (PyObject *)decimal_copy((decimalobject *)value); - if (PyList_Check(value) || PyTuple_Check(value)) return decimal_from_sequence(type, value); @@ -1806,7 +1807,7 @@ decimal_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)decimal_richcompare, /* tp_richcompare */ + 0, /* XXX: activate when it's implemented (richcmpfunc)decimal_richcompare,*/ /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: sandbox/trunk/decimal-c/test_decimal.py ============================================================================== --- sandbox/trunk/decimal-c/test_decimal.py (original) +++ sandbox/trunk/decimal-c/test_decimal.py Tue May 23 19:52:29 2006 @@ -384,7 +384,7 @@ self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) ) #bad exp - self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) + self.assertRaises(TypeError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) #bad coefficients self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) ) @@ -1079,7 +1079,7 @@ DecimalExplicitConstructionTest, DecimalImplicitConstructionTest, DecimalArithmeticOperatorsTest, - DecimalUseOfContextTest, + #DecimalUseOfContextTest, DecimalUsabilityTest, DecimalPythonAPItests, ContextAPItests, From python-checkins at python.org Tue May 23 20:10:12 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 20:10:12 +0200 (CEST) Subject: [Python-checkins] r46125 - in python/branches/rjones-funccall: Include/frameobject.h Objects/frameobject.c Python/ceval.c Message-ID: <20060523181012.CFBEA1E401A@bag.python.org> Author: richard.jones Date: Tue May 23 20:10:11 2006 New Revision: 46125 Modified: python/branches/rjones-funccall/Include/frameobject.h python/branches/rjones-funccall/Objects/frameobject.c python/branches/rjones-funccall/Python/ceval.c Log: Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects. Modified: python/branches/rjones-funccall/Include/frameobject.h ============================================================================== --- python/branches/rjones-funccall/Include/frameobject.h (original) +++ python/branches/rjones-funccall/Include/frameobject.h Tue May 23 20:10:11 2006 @@ -36,10 +36,6 @@ in this scope */ int f_iblock; /* index in f_blockstack */ PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ - int f_nlocals; /* number of locals */ - int f_ncells; - int f_nfreevars; - int f_stacksize; /* size of value stack */ PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ } PyFrameObject; Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Tue May 23 20:10:11 2006 @@ -377,7 +377,6 @@ a meaning: ob_type == &Frametype f_back next item on free list, or NULL - f_nlocals number of locals f_stacksize size of value stack ob_size size of localsplus Note that the value and block stacks are preserved -- this can save @@ -458,7 +457,7 @@ Py_VISIT(f->f_exc_traceback); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_VISIT(*fastlocals); @@ -491,7 +490,7 @@ Py_CLEAR(f->f_trace); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_CLEAR(*fastlocals); @@ -630,11 +629,7 @@ } f->f_code = code; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - extras = f->f_nlocals + ncells + nfrees; + extras = f->f_code->co_nlocals + ncells + nfrees; f->f_valuestack = f->f_localsplus + extras; for (i=0; if_localsplus[i] = NULL; @@ -760,7 +755,9 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; @@ -771,27 +768,24 @@ return; } } - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) map_to_dict(map, j, locals, fast, 0); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) { - return; - } - map_to_dict(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1); - map_to_dict(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + map_to_dict(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1); + map_to_dict(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1); } PyErr_Restore(error_type, error_value, error_traceback); } @@ -803,11 +797,14 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (locals == NULL) return; if (!PyTuple_Check(map)) @@ -815,21 +812,18 @@ PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) - dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) - return; - dict_to_map(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1, clear); - dict_to_map(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1, - clear); + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) + dict_to_map(co->co_varnames, j, locals, fast, 0, clear); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + dict_to_map(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1, clear); + dict_to_map(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1, + clear); } PyErr_Restore(error_type, error_value, error_traceback); } Modified: python/branches/rjones-funccall/Python/ceval.c ============================================================================== --- python/branches/rjones-funccall/Python/ceval.c (original) +++ python/branches/rjones-funccall/Python/ceval.c Tue May 23 20:10:11 2006 @@ -654,11 +654,11 @@ #ifdef LLTRACE #define PUSH(v) { (void)(BASIC_PUSH(v), \ lltrace && prtrace(TOP(), "push")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define POP() ((void)(lltrace && prtrace(TOP(), "pop")), BASIC_POP()) #define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ lltrace && prtrace(TOP(), "stackadj")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define EXT_POP(STACK_POINTER) (lltrace && prtrace(*(STACK_POINTER), "ext_pop"), *--(STACK_POINTER)) #else #define PUSH(v) BASIC_PUSH(v) @@ -729,7 +729,7 @@ names = co->co_names; consts = co->co_consts; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; first_instr = (unsigned char*) PyString_AS_STRING(co->co_code); /* An explanation is in order for the next line. @@ -780,7 +780,7 @@ READ_TIMESTAMP(loop0); #endif assert(stack_pointer >= f->f_valuestack); /* else underflow */ - assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ + assert(STACK_LEVEL() <= co->co_stacksize); /* else overflow */ /* Do periodic things. Doing this every time through the loop would add too much overhead, so we do it @@ -1916,17 +1916,17 @@ /* Don't stomp existing exception */ if (PyErr_Occurred()) break; - if (oparg < f->f_ncells) { - v = PyTuple_GetItem(co->co_cellvars, + if (oparg < PyTuple_GET_SIZE(co->co_cellvars)) { + v = PyTuple_GET_ITEM(co->co_cellvars, oparg); format_exc_check_arg( PyExc_UnboundLocalError, UNBOUNDLOCAL_ERROR_MSG, v); } else { - v = PyTuple_GetItem( + v = PyTuple_GET_ITEM( co->co_freevars, - oparg - f->f_ncells); + oparg - PyTuple_GET_SIZE(co->co_cellvars)); format_exc_check_arg( PyExc_NameError, UNBOUNDFREE_ERROR_MSG, @@ -2610,7 +2610,7 @@ return NULL; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; if (co->co_argcount > 0 || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { @@ -2746,7 +2746,7 @@ } /* Allocate and initialize storage for cell vars, and copy free vars into frame. This isn't too efficient right now. */ - if (f->f_ncells) { + if (PyTuple_GET_SIZE(co->co_cellvars)) { int i = 0, j = 0, nargs, found; char *cellname, *argname; PyObject *c; @@ -2764,7 +2764,7 @@ that are arguments at the beginning of the cellvars list so that we can march over it more efficiently? */ - for (i = 0; i < f->f_ncells; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) { cellname = PyString_AS_STRING( PyTuple_GET_ITEM(co->co_cellvars, i)); found = 0; @@ -2775,7 +2775,7 @@ c = PyCell_New(GETLOCAL(j)); if (c == NULL) goto fail; - GETLOCAL(f->f_nlocals + i) = c; + GETLOCAL(co->co_nlocals + i) = c; found = 1; break; } @@ -2784,16 +2784,16 @@ c = PyCell_New(NULL); if (c == NULL) goto fail; - SETLOCAL(f->f_nlocals + i, c); + SETLOCAL(co->co_nlocals + i, c); } } } - if (f->f_nfreevars) { + if (PyTuple_GET_SIZE(co->co_freevars)) { int i; - for (i = 0; i < f->f_nfreevars; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_freevars); ++i) { PyObject *o = PyTuple_GET_ITEM(closure, i); Py_INCREF(o); - freevars[f->f_ncells + i] = o; + freevars[PyTuple_GET_SIZE(co->co_cellvars) + i] = o; } } @@ -4214,7 +4214,7 @@ } case STORE_DEREF: { - PyObject **freevars = f->f_localsplus + f->f_nlocals; + PyObject **freevars = f->f_localsplus + f->f_code->co_nlocals; PyObject *c = freevars[PEEKARG()]; if (PyCell_GET(c) == v) PyCell_Set(c, NULL); From python-checkins at python.org Tue May 23 20:19:17 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 20:19:17 +0200 (CEST) Subject: [Python-checkins] r46126 - in python/branches/rjones-funccall: Doc/api/exceptions.tex Doc/whatsnew/whatsnew25.tex Include/unicodeobject.h Lib/distutils/command/build_ext.py Lib/distutils/sysconfig.py Lib/distutils/unixccompiler.py Lib/distutils/util.py Mac/OSX/BuildScript Mac/OSX/BuildScript/build-installer.py Mac/OSX/BuildScript/resources/background.jpg Mac/OSX/BuildScript/scripts/postflight.documentation Mac/OSX/BuildScript/scripts/postflight.framework Mac/OSX/BuildScript/scripts/postflight.patch-profile Mac/OSX/Makefile.in Misc/NEWS Objects/frameobject.c Objects/unicodeobject.c Python/errors.c Message-ID: <20060523181917.BAF721E4009@bag.python.org> Author: richard.jones Date: Tue May 23 20:19:15 2006 New Revision: 46126 Added: python/branches/rjones-funccall/Mac/OSX/BuildScript/ - copied from r46113, python/trunk/Mac/OSX/BuildScript/ Modified: python/branches/rjones-funccall/ (props changed) python/branches/rjones-funccall/Doc/api/exceptions.tex python/branches/rjones-funccall/Doc/whatsnew/whatsnew25.tex python/branches/rjones-funccall/Include/unicodeobject.h python/branches/rjones-funccall/Lib/distutils/command/build_ext.py python/branches/rjones-funccall/Lib/distutils/sysconfig.py python/branches/rjones-funccall/Lib/distutils/unixccompiler.py python/branches/rjones-funccall/Lib/distutils/util.py python/branches/rjones-funccall/Mac/OSX/BuildScript/build-installer.py (props changed) python/branches/rjones-funccall/Mac/OSX/BuildScript/resources/background.jpg (props changed) python/branches/rjones-funccall/Mac/OSX/BuildScript/scripts/postflight.documentation (props changed) python/branches/rjones-funccall/Mac/OSX/BuildScript/scripts/postflight.framework (props changed) python/branches/rjones-funccall/Mac/OSX/BuildScript/scripts/postflight.patch-profile (props changed) python/branches/rjones-funccall/Mac/OSX/Makefile.in python/branches/rjones-funccall/Misc/NEWS python/branches/rjones-funccall/Objects/frameobject.c python/branches/rjones-funccall/Objects/unicodeobject.c python/branches/rjones-funccall/Python/errors.c Log: merge from trunk Modified: python/branches/rjones-funccall/Doc/api/exceptions.tex ============================================================================== --- python/branches/rjones-funccall/Doc/api/exceptions.tex (original) +++ python/branches/rjones-funccall/Doc/api/exceptions.tex Tue May 23 20:19:15 2006 @@ -341,7 +341,8 @@ The \member{__module__} attribute of the new class is set to the first part (up to the last dot) of the \var{name} argument, and the class name is set to the last part (after the last dot). The - \var{base} argument can be used to specify an alternate base class. + \var{base} argument can be used to specify alternate base classes; + it can either be only one class or a tuple of classes. The \var{dict} argument can be used to specify a dictionary of class variables and methods. \end{cfuncdesc} Modified: python/branches/rjones-funccall/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/rjones-funccall/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/rjones-funccall/Doc/whatsnew/whatsnew25.tex Tue May 23 20:19:15 2006 @@ -1120,6 +1120,13 @@ %====================================================================== \subsection{Optimizations\label{opts}} +Several of the optimizations were developed at the NeedForSpeed +sprint, an event held in Reykjavik, Iceland, from May 21--28 2006. +The sprint focused on speed enhancements to the CPython implementation +and was funded by EWT LLC with local support from CCP Games. Those +optimizations added at this sprint are specially marked in the +following list. + \begin{itemize} \item When they were introduced @@ -1129,8 +1136,11 @@ and as a result sets will use a third less memory and are somewhat faster. (Implemented by Raymond Hettinger.) -\item The performance of some Unicode operations, such as -character map decoding, has been improved. +\item The speed of some Unicode operations, such as +finding substrings and character map decoding, has been improved. +(Substring search improvements were added by Fredrik Lundh and Andrew +Dalke at the NeedForSpeed sprint. Character map decoding was improved +by Walter D\"orwald.) % Patch 1313939 \item The code generator's peephole optimizer now performs @@ -1138,6 +1148,13 @@ \code{a = 2+3}, the code generator will do the arithmetic and produce code corresponding to \code{a = 5}. +\item Function calls are now faster because code objects now keep +the most recently finished frame (a ``zombie frame'') in an internal +field of the code object, reusing it the next time the code object is +invoked. (Original patch by Michael Hudson, modified by Armin Rigo +and Richard Jones; committed at the NeedForSpeed sprint.) +% Patch 876206 + \end{itemize} The net result of the 2.5 optimizations is that Python 2.5 runs the @@ -1411,7 +1428,7 @@ included in the \file{Tools/pybench} directory. The pybench suite is an improvement on the commonly used \file{pystone.py} program because pybench provides a more detailed measurement of the interpreter's -performance. It times particular operations such as function calls, +speed. It times particular operations such as function calls, tuple slicing, method lookups, and numeric operations, instead of performing many different operations and reducing the result to a single number as \file{pystone.py} does. @@ -1935,6 +1952,10 @@ \code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}. (Contributed by Barry Warsaw.) +\item \cfunction{PyErr_NewException(\var{name}, \var{base}, +\var{dict})} can now accept a tuple of base classes as its \var{base} +argument. (Contributed by Georg Brandl.) + \item The CPython interpreter is still written in C, but the code can now be compiled with a {\Cpp} compiler without errors. (Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.) Modified: python/branches/rjones-funccall/Include/unicodeobject.h ============================================================================== --- python/branches/rjones-funccall/Include/unicodeobject.h (original) +++ python/branches/rjones-funccall/Include/unicodeobject.h Tue May 23 20:19:15 2006 @@ -367,10 +367,12 @@ for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ } while (0) -#define Py_UNICODE_MATCH(string, offset, substring)\ - ((*((string)->str + (offset)) == *((substring)->str)) &&\ - !memcmp((string)->str + (offset), (substring)->str,\ - (substring)->length*sizeof(Py_UNICODE))) +/* check if substring matches at given offset. the offset must be + valid, and the substring must not be empty */ +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->str + (offset)) == *((substring)->str)) && \ + ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ + !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) #ifdef __cplusplus extern "C" { Modified: python/branches/rjones-funccall/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/rjones-funccall/Lib/distutils/command/build_ext.py (original) +++ python/branches/rjones-funccall/Lib/distutils/command/build_ext.py Tue May 23 20:19:15 2006 @@ -689,6 +689,11 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib, "m"] + extra + + elif sys.platform == 'darwin': + # Don't use the default code below + return ext.libraries + else: from distutils import sysconfig if sysconfig.get_config_var('Py_ENABLE_SHARED'): Modified: python/branches/rjones-funccall/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/rjones-funccall/Lib/distutils/sysconfig.py (original) +++ python/branches/rjones-funccall/Lib/distutils/sysconfig.py Tue May 23 20:19:15 2006 @@ -500,6 +500,21 @@ _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX + if sys.platform == 'darwin': + kernel_version = os.uname()[2] # Kernel version (8.4.3) + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # On Mac OS X before 10.4, check if -arch and -isysroot + # are in CFLAGS or LDFLAGS and remove them if they are. + # This is needed when building extensions on a 10.3 system + # using a universal build of python. + for key in ('LDFLAGS', 'BASECFLAGS'): + flags = _config_vars[key] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = re.sub('-isysroot [^ \t]* ', ' ', flags) + _config_vars[key] = flags + if args: vals = [] for name in args: Modified: python/branches/rjones-funccall/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/rjones-funccall/Lib/distutils/unixccompiler.py (original) +++ python/branches/rjones-funccall/Lib/distutils/unixccompiler.py Tue May 23 20:19:15 2006 @@ -42,6 +42,48 @@ # should just happily stuff them into the preprocessor/compiler/linker # options and carry on. +def _darwin_compiler_fixup(compiler_so, cc_args): + """ + This function will strip '-isysroot PATH' and '-arch ARCH' from the + compile flags if the user has specified one them in extra_compile_flags. + + This is needed because '-arch ARCH' adds another architecture to the + build, without a way to remove an architecture. Furthermore GCC will + barf if multiple '-isysroot' arguments are present. + """ + stripArch = stripSysroot = 0 + + compiler_so = list(compiler_so) + kernel_version = os.uname()[2] # 8.4.3 + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # OSX before 10.4.0, these don't support -arch and -isysroot at + # all. + stripArch = stripSysroot = True + else: + stripArch = '-arch' in cc_args + stripSysroot = '-isysroot' in cc_args + + if stripArch: + while 1: + try: + index = compiler_so.index('-arch') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + if stripSysroot: + try: + index = compiler_so.index('-isysroot') + # Strip this argument and the next one: + del compiler_so[index:index+1] + except ValueError: + pass + + return compiler_so + class UnixCCompiler(CCompiler): compiler_type = 'unix' @@ -108,8 +150,11 @@ raise CompileError, msg def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): + compiler_so = self.compiler_so + if sys.platform == 'darwin': + compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) try: - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + + self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg @@ -172,7 +217,22 @@ else: linker = self.linker_so[:] if target_lang == "c++" and self.compiler_cxx: - linker[0] = self.compiler_cxx[0] + # skip over environment variable settings if /usr/bin/env + # is used to set up the linker's environment. + # This is needed on OSX. Note: this assumes that the + # normal and C++ compiler have the same environment + # settings. + i = 0 + if os.path.basename(linker[0]) == "env": + i = 1 + while '=' in linker[i]: + i = i + 1 + + linker[i] = self.compiler_cxx[i] + + if sys.platform == 'darwin': + linker = _darwin_compiler_fixup(linker, ld_args) + self.spawn(linker + ld_args) except DistutilsExecError, msg: raise LinkError, msg Modified: python/branches/rjones-funccall/Lib/distutils/util.py ============================================================================== --- python/branches/rjones-funccall/Lib/distutils/util.py (original) +++ python/branches/rjones-funccall/Lib/distutils/util.py Tue May 23 20:19:15 2006 @@ -67,6 +67,54 @@ m = rel_re.match(release) if m: release = m.group() + elif osname[:6] == "darwin": + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + from distutils.sysconfig import get_config_vars + cfgvars = get_config_vars() + + macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET') + if not macver: + macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') + + if not macver: + # Get the system version. Reading this plist is a documented + # way to get the system version (see the documentation for + # the Gestalt Manager) + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + m = re.search( + r'ProductUserVisibleVersion\s*' + + r'(.*?)', f.read()) + f.close() + if m is not None: + macver = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + if macver: + from distutils.sysconfig import get_config_vars + release = macver + osname = "macosx" + + + if (release + '.') < '10.4.' and \ + get_config_vars().get('UNIVERSALSDK', '').strip(): + # The universal build will build fat binaries, but not on + # systems before 10.4 + machine = 'fat' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + machine = 'ppc' return "%s-%s-%s" % (osname, release, machine) Modified: python/branches/rjones-funccall/Mac/OSX/Makefile.in ============================================================================== --- python/branches/rjones-funccall/Mac/OSX/Makefile.in (original) +++ python/branches/rjones-funccall/Mac/OSX/Makefile.in Tue May 23 20:19:15 2006 @@ -73,11 +73,16 @@ install_versionedtools: for fn in idle pydoc python-config ;\ do \ + if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \ + continue ;\ + fi ;\ mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\ done - mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" - ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" + if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \ + mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\ + ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\ + fi pythonw: $(srcdir)/Tools/pythonw.c Modified: python/branches/rjones-funccall/Misc/NEWS ============================================================================== --- python/branches/rjones-funccall/Misc/NEWS (original) +++ python/branches/rjones-funccall/Misc/NEWS Tue May 23 20:19:15 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- PyErr_NewException now accepts a tuple of base classes as its + "base" parameter. + - Patch #876206: function call speedup by retaining allocated frame objects. Modified: python/branches/rjones-funccall/Objects/frameobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/frameobject.c (original) +++ python/branches/rjones-funccall/Objects/frameobject.c Tue May 23 20:19:15 2006 @@ -555,7 +555,6 @@ PyFrameObject *f; PyObject *builtins; Py_ssize_t i; - int frame_needs_init = 1; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || @@ -595,7 +594,6 @@ Py_INCREF(builtins); } if (code->co_zombieframe != NULL) { - frame_needs_init = 0; f = code->co_zombieframe; code->co_zombieframe = NULL; _Py_NewReference((PyObject *)f); @@ -605,9 +603,11 @@ Py_ssize_t extras, ncells, nfrees; ncells = PyTuple_GET_SIZE(code->co_cellvars); nfrees = PyTuple_GET_SIZE(code->co_freevars); - extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; + extras = code->co_stacksize + code->co_nlocals + ncells + + nfrees; if (free_list == NULL) { - f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); + f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, + extras); if (f == NULL) { Py_DECREF(builtins); return NULL; @@ -629,7 +629,11 @@ } f->f_code = code; - extras = f->f_code->co_nlocals + ncells + nfrees; + f->f_nlocals = code->co_nlocals; + f->f_stacksize = code->co_stacksize; + f->f_ncells = ncells; + f->f_nfreevars = nfrees; + extras = f->f_nlocals + ncells + nfrees; f->f_valuestack = f->f_localsplus + extras; for (i=0; if_localsplus[i] = NULL; Modified: python/branches/rjones-funccall/Objects/unicodeobject.c ============================================================================== --- python/branches/rjones-funccall/Objects/unicodeobject.c (original) +++ python/branches/rjones-funccall/Objects/unicodeobject.c Tue May 23 20:19:15 2006 @@ -4982,54 +4982,56 @@ int PyUnicode_Contains(PyObject *container, PyObject *element) { - PyUnicodeObject *u = NULL, *v = NULL; + PyUnicodeObject *u, *v; int result; Py_ssize_t size; - register const Py_UNICODE *lhs, *end, *rhs; /* Coerce the two arguments */ - v = (PyUnicodeObject *)PyUnicode_FromObject(element); - if (v == NULL) { + v = (PyUnicodeObject *) PyUnicode_FromObject(element); + if (!v) { PyErr_SetString(PyExc_TypeError, "'in ' requires string as left operand"); - goto onError; + return -1; + } + + u = (PyUnicodeObject *) PyUnicode_FromObject(container); + if (!u) { + Py_DECREF(v); + return -1; } - u = (PyUnicodeObject *)PyUnicode_FromObject(container); - if (u == NULL) - goto onError; size = PyUnicode_GET_SIZE(v); - rhs = PyUnicode_AS_UNICODE(v); - lhs = PyUnicode_AS_UNICODE(u); + if (!size) { + result = 1; + goto done; + } result = 0; + if (size == 1) { - end = lhs + PyUnicode_GET_SIZE(u); - while (lhs < end) { - if (*lhs++ == *rhs) { - result = 1; - break; - } - } - } - else { - end = lhs + (PyUnicode_GET_SIZE(u) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size * sizeof(Py_UNICODE)) == 0) { + Py_UNICODE chr = PyUnicode_AS_UNICODE(v)[0]; + Py_UNICODE* ptr = PyUnicode_AS_UNICODE(u); + Py_UNICODE* end = ptr + PyUnicode_GET_SIZE(u); + for (; ptr < end; ptr++) { + if (*ptr == chr) { result = 1; break; } } + } else { + int start = 0; + int end = PyUnicode_GET_SIZE(u) - size; + for (; start <= end; start++) + if (Py_UNICODE_MATCH(u, start, v)) { + result = 1; + break; + } } +done: Py_DECREF(u); Py_DECREF(v); return result; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return -1; } /* Concat to string or Unicode object giving a new Unicode object. */ Modified: python/branches/rjones-funccall/Python/errors.c ============================================================================== --- python/branches/rjones-funccall/Python/errors.c (original) +++ python/branches/rjones-funccall/Python/errors.c Tue May 23 20:19:15 2006 @@ -527,6 +527,7 @@ } + PyObject * PyErr_NewException(char *name, PyObject *base, PyObject *dict) { @@ -559,9 +560,15 @@ classname = PyString_FromString(dot+1); if (classname == NULL) goto failure; - bases = PyTuple_Pack(1, base); - if (bases == NULL) - goto failure; + if (PyTuple_Check(base)) { + bases = base; + /* INCREF as we create a new ref in the else branch */ + Py_INCREF(bases); + } else { + bases = PyTuple_Pack(1, base); + if (bases == NULL) + goto failure; + } result = PyClass_New(bases, dict, classname); failure: Py_XDECREF(bases); From python-checkins at python.org Tue May 23 20:20:10 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 20:20:10 +0200 (CEST) Subject: [Python-checkins] r46127 - python/branches/rjones-funccall/Misc/NEWS Message-ID: <20060523182010.5378B1E401B@bag.python.org> Author: richard.jones Date: Tue May 23 20:20:09 2006 New Revision: 46127 Modified: python/branches/rjones-funccall/Misc/NEWS Log: add news item Modified: python/branches/rjones-funccall/Misc/NEWS ============================================================================== --- python/branches/rjones-funccall/Misc/NEWS (original) +++ python/branches/rjones-funccall/Misc/NEWS Tue May 23 20:20:09 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1337051: reduced size of frame objects. + - PyErr_NewException now accepts a tuple of base classes as its "base" parameter. From python-checkins at python.org Tue May 23 20:28:18 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 20:28:18 +0200 (CEST) Subject: [Python-checkins] r46128 - in python/trunk: Include/frameobject.h Misc/NEWS Objects/frameobject.c Python/ceval.c Message-ID: <20060523182818.5CA5C1E401D@bag.python.org> Author: richard.jones Date: Tue May 23 20:28:17 2006 New Revision: 46128 Modified: python/trunk/Include/frameobject.h python/trunk/Misc/NEWS python/trunk/Objects/frameobject.c python/trunk/Python/ceval.c Log: Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects. Modified: python/trunk/Include/frameobject.h ============================================================================== --- python/trunk/Include/frameobject.h (original) +++ python/trunk/Include/frameobject.h Tue May 23 20:28:17 2006 @@ -36,10 +36,6 @@ in this scope */ int f_iblock; /* index in f_blockstack */ PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ - int f_nlocals; /* number of locals */ - int f_ncells; - int f_nfreevars; - int f_stacksize; /* size of value stack */ PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ } PyFrameObject; Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 20:28:17 2006 @@ -12,6 +12,11 @@ Core and builtins ----------------- +- Patch #1337051: reduced size of frame objects. + +- PyErr_NewException now accepts a tuple of base classes as its + "base" parameter. + - PyErr_NewException now accepts a tuple of base classes as its "base" parameter. Modified: python/trunk/Objects/frameobject.c ============================================================================== --- python/trunk/Objects/frameobject.c (original) +++ python/trunk/Objects/frameobject.c Tue May 23 20:28:17 2006 @@ -377,7 +377,6 @@ a meaning: ob_type == &Frametype f_back next item on free list, or NULL - f_nlocals number of locals f_stacksize size of value stack ob_size size of localsplus Note that the value and block stacks are preserved -- this can save @@ -458,7 +457,7 @@ Py_VISIT(f->f_exc_traceback); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_VISIT(*fastlocals); @@ -491,7 +490,7 @@ Py_CLEAR(f->f_trace); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_CLEAR(*fastlocals); @@ -760,7 +759,9 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; @@ -771,27 +772,24 @@ return; } } - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) map_to_dict(map, j, locals, fast, 0); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) { - return; - } - map_to_dict(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1); - map_to_dict(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + map_to_dict(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1); + map_to_dict(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1); } PyErr_Restore(error_type, error_value, error_traceback); } @@ -803,11 +801,14 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (locals == NULL) return; if (!PyTuple_Check(map)) @@ -815,21 +816,18 @@ PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) - dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) - return; - dict_to_map(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1, clear); - dict_to_map(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1, - clear); + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) + dict_to_map(co->co_varnames, j, locals, fast, 0, clear); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + dict_to_map(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1, clear); + dict_to_map(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1, + clear); } PyErr_Restore(error_type, error_value, error_traceback); } Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Tue May 23 20:28:17 2006 @@ -654,11 +654,11 @@ #ifdef LLTRACE #define PUSH(v) { (void)(BASIC_PUSH(v), \ lltrace && prtrace(TOP(), "push")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define POP() ((void)(lltrace && prtrace(TOP(), "pop")), BASIC_POP()) #define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ lltrace && prtrace(TOP(), "stackadj")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define EXT_POP(STACK_POINTER) (lltrace && prtrace(*(STACK_POINTER), "ext_pop"), *--(STACK_POINTER)) #else #define PUSH(v) BASIC_PUSH(v) @@ -729,7 +729,7 @@ names = co->co_names; consts = co->co_consts; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; first_instr = (unsigned char*) PyString_AS_STRING(co->co_code); /* An explanation is in order for the next line. @@ -780,7 +780,7 @@ READ_TIMESTAMP(loop0); #endif assert(stack_pointer >= f->f_valuestack); /* else underflow */ - assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ + assert(STACK_LEVEL() <= co->co_stacksize); /* else overflow */ /* Do periodic things. Doing this every time through the loop would add too much overhead, so we do it @@ -1916,17 +1916,17 @@ /* Don't stomp existing exception */ if (PyErr_Occurred()) break; - if (oparg < f->f_ncells) { - v = PyTuple_GetItem(co->co_cellvars, + if (oparg < PyTuple_GET_SIZE(co->co_cellvars)) { + v = PyTuple_GET_ITEM(co->co_cellvars, oparg); format_exc_check_arg( PyExc_UnboundLocalError, UNBOUNDLOCAL_ERROR_MSG, v); } else { - v = PyTuple_GetItem( + v = PyTuple_GET_ITEM( co->co_freevars, - oparg - f->f_ncells); + oparg - PyTuple_GET_SIZE(co->co_cellvars)); format_exc_check_arg( PyExc_NameError, UNBOUNDFREE_ERROR_MSG, @@ -2610,7 +2610,7 @@ return NULL; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; if (co->co_argcount > 0 || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { @@ -2746,7 +2746,7 @@ } /* Allocate and initialize storage for cell vars, and copy free vars into frame. This isn't too efficient right now. */ - if (f->f_ncells) { + if (PyTuple_GET_SIZE(co->co_cellvars)) { int i = 0, j = 0, nargs, found; char *cellname, *argname; PyObject *c; @@ -2764,7 +2764,7 @@ that are arguments at the beginning of the cellvars list so that we can march over it more efficiently? */ - for (i = 0; i < f->f_ncells; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) { cellname = PyString_AS_STRING( PyTuple_GET_ITEM(co->co_cellvars, i)); found = 0; @@ -2775,7 +2775,7 @@ c = PyCell_New(GETLOCAL(j)); if (c == NULL) goto fail; - GETLOCAL(f->f_nlocals + i) = c; + GETLOCAL(co->co_nlocals + i) = c; found = 1; break; } @@ -2784,16 +2784,16 @@ c = PyCell_New(NULL); if (c == NULL) goto fail; - SETLOCAL(f->f_nlocals + i, c); + SETLOCAL(co->co_nlocals + i, c); } } } - if (f->f_nfreevars) { + if (PyTuple_GET_SIZE(co->co_freevars)) { int i; - for (i = 0; i < f->f_nfreevars; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_freevars); ++i) { PyObject *o = PyTuple_GET_ITEM(closure, i); Py_INCREF(o); - freevars[f->f_ncells + i] = o; + freevars[PyTuple_GET_SIZE(co->co_cellvars) + i] = o; } } @@ -4214,7 +4214,7 @@ } case STORE_DEREF: { - PyObject **freevars = f->f_localsplus + f->f_nlocals; + PyObject **freevars = f->f_localsplus + f->f_code->co_nlocals; PyObject *c = freevars[PEEKARG()]; if (PyCell_GET(c) == v) PyCell_Set(c, NULL); From python-checkins at python.org Tue May 23 20:32:12 2006 From: python-checkins at python.org (richard.jones) Date: Tue, 23 May 2006 20:32:12 +0200 (CEST) Subject: [Python-checkins] r46129 - python/trunk/Objects/frameobject.c Message-ID: <20060523183212.3C6AA1E4020@bag.python.org> Author: richard.jones Date: Tue May 23 20:32:11 2006 New Revision: 46129 Modified: python/trunk/Objects/frameobject.c Log: fix broken merge Modified: python/trunk/Objects/frameobject.c ============================================================================== --- python/trunk/Objects/frameobject.c (original) +++ python/trunk/Objects/frameobject.c Tue May 23 20:32:11 2006 @@ -362,8 +362,7 @@ In zombie mode, no field of PyFrameObject holds a reference, but the following fields are still valid: - * ob_type, ob_size, f_code, f_valuestack, - f_nlocals, f_ncells, f_nfreevars, f_stacksize; + * ob_type, ob_size, f_code, f_valuestack; * f_locals, f_trace, f_exc_type, f_exc_value, f_exc_traceback are NULL; @@ -629,11 +628,7 @@ } f->f_code = code; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - extras = f->f_nlocals + ncells + nfrees; + extras = code->co_nlocals + ncells + nfrees; f->f_valuestack = f->f_localsplus + extras; for (i=0; if_localsplus[i] = NULL; From python-checkins at python.org Tue May 23 20:41:17 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 20:41:17 +0200 (CEST) Subject: [Python-checkins] r46130 - python/trunk/Misc/NEWS Message-ID: <20060523184117.CEA6E1E401A@bag.python.org> Author: bob.ippolito Date: Tue May 23 20:41:17 2006 New Revision: 46130 Modified: python/trunk/Misc/NEWS Log: Update Misc/NEWS for gzip patch #1281707 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 20:41:17 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Patch #1281707: speed up gzip.readline. + - Patch #1337051: reduced size of frame objects. - PyErr_NewException now accepts a tuple of base classes as its From python-checkins at python.org Tue May 23 20:43:48 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 20:43:48 +0200 (CEST) Subject: [Python-checkins] r46131 - python/trunk/Misc/NEWS Message-ID: <20060523184348.54B201E4009@bag.python.org> Author: bob.ippolito Date: Tue May 23 20:43:47 2006 New Revision: 46131 Modified: python/trunk/Misc/NEWS Log: Update Misc/NEWS for gzip patch #1281707 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 20:43:47 2006 @@ -12,8 +12,6 @@ Core and builtins ----------------- -- Patch #1281707: speed up gzip.readline. - - Patch #1337051: reduced size of frame objects. - PyErr_NewException now accepts a tuple of base classes as its @@ -62,6 +60,8 @@ Library ------- +- Patch #1281707: speed up gzip.readline. + - Patch #1180296: Two new functions were added to the locale module: format_string() to get the effect of "format % items" but locale-aware, and currency() to format a monetary number with currency sign. From python-checkins at python.org Tue May 23 20:44:26 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 23 May 2006 20:44:26 +0200 (CEST) Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c Message-ID: <20060523184426.5EDC41E4009@bag.python.org> Author: fredrik.lundh Date: Tue May 23 20:44:25 2006 New Revision: 46132 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: use append+reverse for rsplit, use "bloom filters" to speed up splitlines and strip with charsets; etc. rsplit is now as fast as split in all our tests (reverse takes no time at all), and splitlines() is nearly as fast as a plain split("\n") in our tests. and we're not done yet... ;-) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Tue May 23 20:44:25 2006 @@ -46,6 +46,18 @@ #include #endif +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) /* this is taken from _sre.c */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define LOCAL(type) static inline type +#else +#define LOCAL(type) static type +#endif + /* Limit for the Unicode object free list */ #define MAX_UNICODE_FREELIST_SIZE 1024 @@ -121,6 +133,51 @@ #endif } +/* --- Bloom Filters ----------------------------------------------------- */ + +/* stuff to implement simple "bloom filters" for Unicode characters. + to keep things simple, we use a single bitmask, using the least 5 + bits from each unicode characters as the bit index. */ + +/* the linebreak mask is set up by Unicode_Init below */ + +#define BLOOM_MASK unsigned long + +static BLOOM_MASK bloom_linebreak; + +#define BLOOM(mask, ch) ((mask & (1 << ((ch) & 0x1F)))) + +#define BLOOM_LINEBREAK(ch)\ + (BLOOM(bloom_linebreak, (ch)) && Py_UNICODE_ISLINEBREAK((ch))) + +LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) +{ + /* calculate simple bloom-style bitmask for a given unicode string */ + + long mask; + Py_ssize_t i; + + mask = 0; + for (i = 0; i < len; i++) + mask |= (1 << (ptr[i] & 0x1F)); + + return mask; +} + +LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) +{ + Py_ssize_t i; + + for (i = 0; i < setlen; i++) + if (set[i] == chr) + return 1; + + return -1; +} + +#define BLOOM_MEMBER(mask, chr, set, setlen)\ + BLOOM(mask, chr) && unicode_member(chr, set, setlen) + /* --- Unicode Object ----------------------------------------------------- */ static @@ -3791,8 +3848,7 @@ /* --- Helpers ------------------------------------------------------------ */ -static -Py_ssize_t count(PyUnicodeObject *self, +static Py_ssize_t count(PyUnicodeObject *self, Py_ssize_t start, Py_ssize_t end, PyUnicodeObject *substring) @@ -3850,8 +3906,7 @@ return result; } -static -Py_ssize_t findstring(PyUnicodeObject *self, +static Py_ssize_t findstring(PyUnicodeObject *self, PyUnicodeObject *substring, Py_ssize_t start, Py_ssize_t end, @@ -4332,17 +4387,6 @@ else \ Py_DECREF(str); -#define SPLIT_INSERT(data, left, right) \ - str = PyUnicode_FromUnicode((data) + (left), (right) - (left)); \ - if (!str) \ - goto onError; \ - if (PyList_Insert(list, 0, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - static PyObject *split_whitespace(PyUnicodeObject *self, PyObject *list, @@ -4403,7 +4447,7 @@ Py_ssize_t eol; /* Find a line and append it */ - while (i < len && !Py_UNICODE_ISLINEBREAK(data[i])) + while (i < len && !BLOOM_LINEBREAK(data[i])) i++; /* Skip the line break reading CRLF as one line break */ @@ -4514,15 +4558,17 @@ if (j > i) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + 1, j + 1); + SPLIT_APPEND(self->str, i + 1, j + 1); while (i >= 0 && Py_UNICODE_ISSPACE(self->str[i])) i--; j = i; } } if (j >= 0) { - SPLIT_INSERT(self->str, 0, j + 1); + SPLIT_APPEND(self->str, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4545,14 +4591,16 @@ if (self->str[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + 1, j + 1); + SPLIT_APPEND(self->str, i + 1, j + 1); j = i = i - 1; } else i--; } if (j >= -1) { - SPLIT_INSERT(self->str, 0, j + 1); + SPLIT_APPEND(self->str, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4576,15 +4624,17 @@ if (Py_UNICODE_MATCH(self, i, substring)) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + sublen, j); + SPLIT_APPEND(self->str, i + sublen, j); j = i; i -= sublen; } else i--; } if (j >= 0) { - SPLIT_INSERT(self->str, 0, j); + SPLIT_APPEND(self->str, 0, j); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4593,7 +4643,6 @@ } #undef SPLIT_APPEND -#undef SPLIT_INSERT static PyObject *split(PyUnicodeObject *self, @@ -5703,16 +5752,6 @@ #define STRIPNAME(i) (stripformat[i]+3) -static const Py_UNICODE * -unicode_memchr(const Py_UNICODE *s, Py_UNICODE c, size_t n) -{ - size_t i; - for (i = 0; i < n; ++i) - if (s[i] == c) - return s+i; - return NULL; -} - /* externally visible for str.strip(unicode) */ PyObject * _PyUnicode_XStrip(PyUnicodeObject *self, int striptype, PyObject *sepobj) @@ -5723,27 +5762,29 @@ Py_ssize_t seplen = PyUnicode_GET_SIZE(sepobj); Py_ssize_t i, j; + BLOOM_MASK sepmask = make_bloom_mask(sep, seplen); + i = 0; if (striptype != RIGHTSTRIP) { - while (i < len && unicode_memchr(sep, s[i], seplen)) { - i++; - } + while (i < len && BLOOM_MEMBER(sepmask, s[i], sep, seplen)) { + i++; + } } j = len; if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && unicode_memchr(sep, s[j], seplen)); - j++; + do { + j--; + } while (j >= i && BLOOM_MEMBER(sepmask, s[j], sep, seplen)); + j++; } if (i == 0 && j == len && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; + Py_INCREF(self); + return (PyObject*)self; } else - return PyUnicode_FromUnicode(s+i, j-i); + return PyUnicode_FromUnicode(s+i, j-i); } @@ -7387,6 +7428,18 @@ { int i; + /* XXX - move this array to unicodectype.c ? */ + Py_UNICODE linebreak[] = { + 0x000A, /* LINE FEED */ + 0x000D, /* CARRIAGE RETURN */ + 0x001C, /* FILE SEPARATOR */ + 0x001D, /* GROUP SEPARATOR */ + 0x001E, /* RECORD SEPARATOR */ + 0x0085, /* NEXT LINE */ + 0x2028, /* LINE SEPARATOR */ + 0x2029, /* PARAGRAPH SEPARATOR */ + }; + /* Init the implementation */ unicode_freelist = NULL; unicode_freelist_size = 0; @@ -7396,6 +7449,11 @@ unicode_latin1[i] = NULL; if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); + + /* initialize the linebreak bloom filter */ + bloom_linebreak = make_bloom_mask( + linebreak, sizeof(linebreak) / sizeof(linebreak[0]) + ); } /* Finalize the Unicode implementation */ From python-checkins at python.org Tue May 23 20:45:31 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 20:45:31 +0200 (CEST) Subject: [Python-checkins] r46133 - in python/trunk: Lib/test/test_builtin.py Misc/ACKS Misc/NEWS Python/mystrtoul.c Message-ID: <20060523184531.2192E1E4009@bag.python.org> Author: tim.peters Date: Tue May 23 20:45:30 2006 New Revision: 46133 Modified: python/trunk/Lib/test/test_builtin.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Python/mystrtoul.c Log: Bug #1334662 / patch #1335972: int(string, base) wrong answers. In rare cases of strings specifying true values near sys.maxint, and oddball bases (not decimal or a power of 2), int(string, base) could deliver insane answers. This repairs all such problems, and also speeds string->int significantly. On my box, here are % speedups for decimal strings of various lengths: length speedup ------ ------- 1 12.4% 2 15.7% 3 20.6% 4 28.1% 5 33.2% 6 37.5% 7 41.9% 8 46.3% 9 51.2% 10 19.5% 11 19.9% 12 23.9% 13 23.7% 14 23.3% 15 24.9% 16 25.3% 17 28.3% 18 27.9% 19 35.7% Note that the difference between 9 and 10 is the difference between short and long Python ints on a 32-bit box. The patch doesn't actually do anything to speed conversion to long: the speedup is due to detecting "unsigned long" overflow more quickly. This is a bugfix candidate, but it's a non-trivial patch and it would be painful to separate the "bug fix" from the "speed up" parts. Modified: python/trunk/Lib/test/test_builtin.py ============================================================================== --- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Tue May 23 20:45:30 2006 @@ -709,6 +709,84 @@ self.assertEqual(int('0123', 0), 83) self.assertEqual(int('0x123', 16), 291) + # SF bug 1334662: int(string, base) wrong answers + # Various representations of 2**32 evaluated to 0 + # rather than 2**32 in previous versions + + self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296L) + self.assertEqual(int('102002022201221111211', 3), 4294967296L) + self.assertEqual(int('10000000000000000', 4), 4294967296L) + self.assertEqual(int('32244002423141', 5), 4294967296L) + self.assertEqual(int('1550104015504', 6), 4294967296L) + self.assertEqual(int('211301422354', 7), 4294967296L) + self.assertEqual(int('40000000000', 8), 4294967296L) + self.assertEqual(int('12068657454', 9), 4294967296L) + self.assertEqual(int('4294967296', 10), 4294967296L) + self.assertEqual(int('1904440554', 11), 4294967296L) + self.assertEqual(int('9ba461594', 12), 4294967296L) + self.assertEqual(int('535a79889', 13), 4294967296L) + self.assertEqual(int('2ca5b7464', 14), 4294967296L) + self.assertEqual(int('1a20dcd81', 15), 4294967296L) + self.assertEqual(int('100000000', 16), 4294967296L) + self.assertEqual(int('a7ffda91', 17), 4294967296L) + self.assertEqual(int('704he7g4', 18), 4294967296L) + self.assertEqual(int('4f5aff66', 19), 4294967296L) + self.assertEqual(int('3723ai4g', 20), 4294967296L) + self.assertEqual(int('281d55i4', 21), 4294967296L) + self.assertEqual(int('1fj8b184', 22), 4294967296L) + self.assertEqual(int('1606k7ic', 23), 4294967296L) + self.assertEqual(int('mb994ag', 24), 4294967296L) + self.assertEqual(int('hek2mgl', 25), 4294967296L) + self.assertEqual(int('dnchbnm', 26), 4294967296L) + self.assertEqual(int('b28jpdm', 27), 4294967296L) + self.assertEqual(int('8pfgih4', 28), 4294967296L) + self.assertEqual(int('76beigg', 29), 4294967296L) + self.assertEqual(int('5qmcpqg', 30), 4294967296L) + self.assertEqual(int('4q0jto4', 31), 4294967296L) + self.assertEqual(int('4000000', 32), 4294967296L) + self.assertEqual(int('3aokq94', 33), 4294967296L) + self.assertEqual(int('2qhxjli', 34), 4294967296L) + self.assertEqual(int('2br45qb', 35), 4294967296L) + self.assertEqual(int('1z141z4', 36), 4294967296L) + + # SF bug 1334662: int(string, base) wrong answers + # Checks for proper evaluation of 2**32 + 1 + self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297L) + self.assertEqual(int('102002022201221111212', 3), 4294967297L) + self.assertEqual(int('10000000000000001', 4), 4294967297L) + self.assertEqual(int('32244002423142', 5), 4294967297L) + self.assertEqual(int('1550104015505', 6), 4294967297L) + self.assertEqual(int('211301422355', 7), 4294967297L) + self.assertEqual(int('40000000001', 8), 4294967297L) + self.assertEqual(int('12068657455', 9), 4294967297L) + self.assertEqual(int('4294967297', 10), 4294967297L) + self.assertEqual(int('1904440555', 11), 4294967297L) + self.assertEqual(int('9ba461595', 12), 4294967297L) + self.assertEqual(int('535a7988a', 13), 4294967297L) + self.assertEqual(int('2ca5b7465', 14), 4294967297L) + self.assertEqual(int('1a20dcd82', 15), 4294967297L) + self.assertEqual(int('100000001', 16), 4294967297L) + self.assertEqual(int('a7ffda92', 17), 4294967297L) + self.assertEqual(int('704he7g5', 18), 4294967297L) + self.assertEqual(int('4f5aff67', 19), 4294967297L) + self.assertEqual(int('3723ai4h', 20), 4294967297L) + self.assertEqual(int('281d55i5', 21), 4294967297L) + self.assertEqual(int('1fj8b185', 22), 4294967297L) + self.assertEqual(int('1606k7id', 23), 4294967297L) + self.assertEqual(int('mb994ah', 24), 4294967297L) + self.assertEqual(int('hek2mgm', 25), 4294967297L) + self.assertEqual(int('dnchbnn', 26), 4294967297L) + self.assertEqual(int('b28jpdn', 27), 4294967297L) + self.assertEqual(int('8pfgih5', 28), 4294967297L) + self.assertEqual(int('76beigh', 29), 4294967297L) + self.assertEqual(int('5qmcpqh', 30), 4294967297L) + self.assertEqual(int('4q0jto5', 31), 4294967297L) + self.assertEqual(int('4000001', 32), 4294967297L) + self.assertEqual(int('3aokq95', 33), 4294967297L) + self.assertEqual(int('2qhxjlj', 34), 4294967297L) + self.assertEqual(int('2br45qc', 35), 4294967297L) + self.assertEqual(int('1z141z5', 36), 4294967297L) + def test_intconversion(self): # Test __int__() class Foo0: Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Tue May 23 20:45:30 2006 @@ -390,6 +390,7 @@ Mark Lutz Jim Lynch Mikael Lyngvig +Alan McIntyre Andrew I MacIntyre Tim MacKenzie Nick Maclaren Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 20:45:30 2006 @@ -12,6 +12,11 @@ Core and builtins ----------------- +- Bug #1334662: ``int(string, base)`` could deliver a wrong answer + when ``base`` was not 2, 4, 8, 10, 16 or 32, and ``string`` represented + an integer close to ``sys.maxint``. This was repaired by patch + #1335972, which also gives a nice speedup. + - Patch #1337051: reduced size of frame objects. - PyErr_NewException now accepts a tuple of base classes as its Modified: python/trunk/Python/mystrtoul.c ============================================================================== --- python/trunk/Python/mystrtoul.c (original) +++ python/trunk/Python/mystrtoul.c Tue May 23 20:45:30 2006 @@ -15,6 +15,94 @@ /* strtol and strtoul, renamed to avoid conflicts */ + +#include +#ifndef DONT_HAVE_ERRNO_H +#include +#endif + +/* Static overflow check values for bases 2 through 36. + * smallmax[base] is the largest unsigned long i such that + * i * base doesn't overflow unsigned long. + */ +static unsigned long smallmax[] = { + 0, /* bases 0 and 1 are invalid */ + 0, + ULONG_MAX / 2, + ULONG_MAX / 3, + ULONG_MAX / 4, + ULONG_MAX / 5, + ULONG_MAX / 6, + ULONG_MAX / 7, + ULONG_MAX / 8, + ULONG_MAX / 9, + ULONG_MAX / 10, + ULONG_MAX / 11, + ULONG_MAX / 12, + ULONG_MAX / 13, + ULONG_MAX / 14, + ULONG_MAX / 15, + ULONG_MAX / 16, + ULONG_MAX / 17, + ULONG_MAX / 18, + ULONG_MAX / 19, + ULONG_MAX / 20, + ULONG_MAX / 21, + ULONG_MAX / 22, + ULONG_MAX / 23, + ULONG_MAX / 24, + ULONG_MAX / 25, + ULONG_MAX / 26, + ULONG_MAX / 27, + ULONG_MAX / 28, + ULONG_MAX / 29, + ULONG_MAX / 30, + ULONG_MAX / 31, + ULONG_MAX / 32, + ULONG_MAX / 33, + ULONG_MAX / 34, + ULONG_MAX / 35, + ULONG_MAX / 36, +}; + +/* maximum digits that can't ever overflow for bases 2 through 36, + * calculated by [int(math.floor(math.log(2**32, i))) for i in range(2, 37)]. + * Note that this is pessimistic if sizeof(long) > 4. + */ +static int digitlimit[] = { + 0, 0, 32, 20, 16, 13, 12, 11, 10, 10, /* 0 - 9 */ + 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, /* 10 - 19 */ + 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */ + 6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */ + +/* char-to-digit conversion for bases 2-36; all non-digits are 37 */ +static int digitlookup[] = { + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 +}; + /* ** strtoul ** This is a general purpose routine for converting @@ -28,98 +116,100 @@ ** Errors due to bad pointers will probably result in ** exceptions - we don't check for them. */ - -#include -#ifndef DONT_HAVE_ERRNO_H -#include -#endif - unsigned long PyOS_strtoul(register char *str, char **ptr, int base) { - register unsigned long result; /* return value of the function */ - register int c; /* current input character */ - register unsigned long temp; /* used in overflow testing */ - int ovf; /* true if overflow occurred */ - - result = 0; - ovf = 0; - -/* catch silly bases */ - if (base != 0 && (base < 2 || base > 36)) - { - if (ptr) - *ptr = str; - return 0; - } - -/* skip leading white space */ - while (*str && isspace(Py_CHARMASK(*str))) - str++; - -/* check for leading 0 or 0x for auto-base or base 16 */ - switch (base) - { - case 0: /* look for leading 0, 0x or 0X */ - if (*str == '0') - { - str++; - if (*str == 'x' || *str == 'X') - { - str++; - base = 16; - } - else - base = 8; - } - else - base = 10; - break; - - case 16: /* skip leading 0x or 0X */ - if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) - str += 2; - break; - } - -/* do the conversion */ - while ((c = Py_CHARMASK(*str)) != '\0') - { - if (isdigit(c) && c - '0' < base) - c -= '0'; - else - { - if (isupper(c)) - c = tolower(c); - if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else /* non-"digit" character */ - break; - if (c >= base) /* non-"digit" character */ - break; + register unsigned long result = 0; /* return value of the function */ + register int c; /* current input character */ + register int ovlimit; /* required digits to overflow */ + + /* skip leading white space */ + while (*str && isspace(Py_CHARMASK(*str))) + ++str; + + /* check for leading 0 or 0x for auto-base or base 16 */ + switch (base) { + case 0: /* look for leading 0, 0x or 0X */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') { + ++str; + base = 16; + } + else + base = 8; + } + else + base = 10; + break; + + case 16: /* skip leading 0x or 0X */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') + ++str; + } + break; } - temp = result; - result = result * base + c; - if(base == 10) { - if(((long)(result - c) / base != (long)temp)) /* overflow */ - ovf = 1; + + /* catch silly bases */ + if (base < 2 || base > 36) { + if (ptr) + *ptr = str; + return 0; } - else { - if ((result - c) / base != temp) /* overflow */ - ovf = 1; + + /* skip leading zeroes */ + while (*str == '0') + ++str; + + /* base is guaranteed to be in [2, 36] at this point */ + ovlimit = digitlimit[base]; + + /* do the conversion until non-digit character encountered */ + while ((c = digitlookup[Py_CHARMASK(*str)]) < base) { + if (ovlimit > 0) /* no overflow check required */ + result = result * base + c; + else { /* requires overflow check */ + register unsigned long temp_result; + + if (ovlimit < 0) /* guaranteed overflow */ + goto overflowed; + + /* there could be an overflow */ + /* check overflow just from shifting */ + if (result > smallmax[base]) + goto overflowed; + + result *= base; + + /* check overflow from the digit's value */ + temp_result = result + c; + if (temp_result < result) + goto overflowed; + + result = temp_result; + } + + ++str; + --ovlimit; } - str++; - } -/* set pointer to point to the last character scanned */ - if (ptr) - *ptr = str; - if (ovf) - { - result = (unsigned long) ~0L; + /* set pointer to point to the last character scanned */ + if (ptr) + *ptr = str; + + return result; + +overflowed: + if (ptr) { + /* spool through remaining digit characters */ + while (digitlookup[Py_CHARMASK(*str)] < base) + ++str; + *ptr = str; + } errno = ERANGE; - } - return result; + return (unsigned long)-1; } long @@ -127,25 +217,25 @@ { long result; char sign; - + while (*str && isspace(Py_CHARMASK(*str))) str++; - + sign = *str; if (sign == '+' || sign == '-') str++; - + result = (long) PyOS_strtoul(str, ptr, base); - + /* Signal overflow if the result appears negative, except for the largest negative integer */ if (result < 0 && !(sign == '-' && result == -result)) { errno = ERANGE; result = 0x7fffffff; } - + if (sign == '-') result = -result; - + return result; } From python-checkins at python.org Tue May 23 20:46:43 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 20:46:43 +0200 (CEST) Subject: [Python-checkins] r46134 - in python/trunk: Lib/struct.py Misc/NEWS Modules/Setup.dist Modules/_struct.c Modules/structmodule.c setup.py Message-ID: <20060523184643.10AF51E4009@bag.python.org> Author: bob.ippolito Date: Tue May 23 20:46:41 2006 New Revision: 46134 Added: python/trunk/Lib/struct.py (contents, props changed) python/trunk/Modules/_struct.c (contents, props changed) Removed: python/trunk/Modules/structmodule.c Modified: python/trunk/Misc/NEWS python/trunk/Modules/Setup.dist python/trunk/setup.py Log: Patch #1493701: performance enhancements for struct module. Added: python/trunk/Lib/struct.py ============================================================================== --- (empty file) +++ python/trunk/Lib/struct.py Tue May 23 20:46:41 2006 @@ -0,0 +1,76 @@ +""" +Functions to convert between Python values and C structs. +Python strings are used to hold the data representing the C struct +and also as format strings to describe the layout of data in the C struct. + +The optional first format char indicates byte order, size and alignment: + @: native order, size & alignment (default) + =: native order, std. size & alignment + <: little-endian, std. size & alignment + >: big-endian, std. size & alignment + !: same as > + +The remaining chars indicate types of args and must match exactly; +these can be preceded by a decimal repeat count: + x: pad byte (no data); c:char; b:signed byte; B:unsigned byte; + h:short; H:unsigned short; i:int; I:unsigned int; + l:long; L:unsigned long; f:float; d:double. +Special cases (preceding decimal count indicates length): + s:string (array of char); p: pascal string (with count byte). +Special case (only available in native format): + P:an integer type that is wide enough to hold a pointer. +Special case (not in native mode unless 'long long' in platform C): + q:long long; Q:unsigned long long +Whitespace between formats is ignored. + +The variable struct.error is an exception raised on errors. +""" +__version__ = '0.1' + +from _struct import Struct, error + +_MAXCACHE = 100 +_cache = {} + +def _compile(fmt): + # Internal: compile struct pattern + if len(_cache) >= _MAXCACHE: + _cache.clear() + s = Struct(fmt) + _cache[fmt] = s + return s + +def calcsize(fmt): + """ + Return size of C struct described by format string fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.size + +def pack(fmt, *args): + """ + Return string containing values v1, v2, ... packed according to fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack(*args) + +def unpack(fmt, s): + """ + Unpack the string, containing packed C structure data, according + to fmt. Requires len(string)==calcsize(fmt). + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack(s) + Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 20:46:41 2006 @@ -48,6 +48,8 @@ Extension Modules ----------------- +- Patch #1493701: performance enhancements for struct module. + - Patch #1490224: time.altzone is now set correctly on Cygwin. - Patch #1435422: zlib's compress and decompress objects now have a Modified: python/trunk/Modules/Setup.dist ============================================================================== --- python/trunk/Modules/Setup.dist (original) +++ python/trunk/Modules/Setup.dist Tue May 23 20:46:41 2006 @@ -167,7 +167,7 @@ #array arraymodule.c # array objects #cmath cmathmodule.c # -lm # complex math library functions #math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking +#_struct _struct.c # binary structure packing/unpacking #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support Added: python/trunk/Modules/_struct.c ============================================================================== --- (empty file) +++ python/trunk/Modules/_struct.c Tue May 23 20:46:41 2006 @@ -0,0 +1,1355 @@ +/* struct module -- pack values into and (out of) strings */ + +/* New version supporting byte order, alignment and size options, + character strings, and unsigned numbers */ + +#include "Python.h" +#include "structseq.h" +#include "structmember.h" +#include + + +/* compatibility macros */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + + + +/* The translation function for each format character is table driven */ + +typedef struct _formatdef { + char format; + int size; + int alignment; + PyObject* (*unpack)(const char *, + const struct _formatdef *); + int (*pack)(char *, PyObject *, + const struct _formatdef *); +} formatdef; + +typedef struct _formatcode { + const struct _formatdef *fmtdef; + int offset; + int repeat; +} formatcode; + +/* Struct object interface */ + +typedef struct { + PyObject_HEAD + int s_size; + int s_len; + formatcode *s_codes; + PyObject *s_format; + PyObject *weakreflist; /* List of weak references */ +} PyStructObject; + +PyAPI_DATA(PyTypeObject) PyStruct_Type; + +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) + + +/* Exception */ + +static PyObject *StructError; + + +/* Define various structs to figure out the alignments of types */ + + +typedef struct { char c; short x; } st_short; +typedef struct { char c; int x; } st_int; +typedef struct { char c; long x; } st_long; +typedef struct { char c; float x; } st_float; +typedef struct { char c; double x; } st_double; +typedef struct { char c; void *x; } st_void_p; + +#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) +#define INT_ALIGN (sizeof(st_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) +#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) +#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) + +/* We can't support q and Q in native mode unless the compiler does; + in std mode, they're 8 bytes on all platforms. */ +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +#define STRINGIFY(x) #x + +#ifdef __powerc +#pragma options align=reset +#endif + +/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ + +static PyObject * +get_pylong(PyObject *v) +{ + PyNumberMethods *m; + + assert(v != NULL); + if (PyInt_Check(v)) + return PyLong_FromLong(PyInt_AS_LONG(v)); + if (PyLong_Check(v)) { + Py_INCREF(v); + return v; + } + m = v->ob_type->tp_as_number; + if (m != NULL && m->nb_long != NULL) { + v = m->nb_long(v); + if (v == NULL) + return NULL; + if (PyLong_Check(v)) + return v; + Py_DECREF(v); + } + PyErr_SetString(StructError, + "cannot convert argument to long"); + return NULL; +} + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x = PyInt_AsLong(v); + if (x == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_SetString(StructError, + "required argument is not an integer"); + return -1; + } + *p = x; + return 0; +} + + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + if (PyLong_Check(v)) { + unsigned long x = PyLong_AsUnsignedLong(v); + if (x == (unsigned long)(-1) && PyErr_Occurred()) + return -1; + *p = x; + return 0; + } + else { + return get_long(v, (long *)p); + } +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsLongLong(v); + Py_DECREF(v); + if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsUnsignedLongLong(v); + Py_DECREF(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/* Floating point helpers */ + +static PyObject * +unpack_float(const char *p, /* start of 4-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack4((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + +static PyObject * +unpack_double(const char *p, /* start of 8-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack8((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + + +/* A large number of small routines follow, with names of the form + + [bln][up]_TYPE + + [bln] distiguishes among big-endian, little-endian and native. + [pu] distiguishes between pack (to struct) and unpack (from struct). + TYPE is one of char, byte, ubyte, etc. +*/ + +/* Native mode routines. ****************************************************/ +/* NOTE: + In all n[up]_ routines handling types larger than 1 byte, there is + *no* guarantee that the p pointer is properly aligned for each type, + therefore memcpy is called. An intermediate variable is used to + compensate for big-endian architectures. + Normally both the intermediate variable and the memcpy call will be + skipped by C optimisation in little-endian architectures (gcc >= 2.91 + does this). */ + +static PyObject * +nu_char(const char *p, const formatdef *f) +{ + return PyString_FromStringAndSize(p, 1); +} + +static PyObject * +nu_byte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(signed char *)p); +} + +static PyObject * +nu_ubyte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(unsigned char *)p); +} + +static PyObject * +nu_short(const char *p, const formatdef *f) +{ + short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_ushort(const char *p, const formatdef *f) +{ + unsigned short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_int(const char *p, const formatdef *f) +{ + int x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_uint(const char *p, const formatdef *f) +{ + unsigned int x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong((unsigned long)x); +} + +static PyObject * +nu_long(const char *p, const formatdef *f) +{ + long x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong(x); +} + +static PyObject * +nu_ulong(const char *p, const formatdef *f) +{ + unsigned long x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong(x); +} + +/* Native mode doesn't support q or Q unless the platform C supports + long long (or, on Windows, __int64). */ + +#ifdef HAVE_LONG_LONG + +static PyObject * +nu_longlong(const char *p, const formatdef *f) +{ + PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromLongLong(x); +} + +static PyObject * +nu_ulonglong(const char *p, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLongLong(x); +} + +#endif + +static PyObject * +nu_float(const char *p, const formatdef *f) +{ + float x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble((double)x); +} + +static PyObject * +nu_double(const char *p, const formatdef *f) +{ + double x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble(x); +} + +static PyObject * +nu_void_p(const char *p, const formatdef *f) +{ + void *x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromVoidPtr(x); +} + +static int +np_byte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < -128 || x > 127){ + PyErr_SetString(StructError, + "byte format requires -128<=number<=127"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_ubyte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > 255){ + PyErr_SetString(StructError, + "ubyte format requires 0<=number<=255"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_char(char *p, PyObject *v, const formatdef *f) +{ + if (!PyString_Check(v) || PyString_Size(v) != 1) { + PyErr_SetString(StructError, + "char format require string of length 1"); + return -1; + } + *p = *PyString_AsString(v); + return 0; +} + +static int +np_short(char *p, PyObject *v, const formatdef *f) +{ + long x; + short y; + if (get_long(v, &x) < 0) + return -1; + if (x < SHRT_MIN || x > SHRT_MAX){ + PyErr_SetString(StructError, + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); + return -1; + } + y = (short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_ushort(char *p, PyObject *v, const formatdef *f) +{ + long x; + unsigned short y; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > USHRT_MAX){ + PyErr_SetString(StructError, + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + return -1; + } + y = (unsigned short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int y; + if (get_long(v, &x) < 0) + return -1; + y = (int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + unsigned int y; + if (get_ulong(v, &x) < 0) + return -1; + y = (unsigned int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_long(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulong(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + if (get_ulong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +#ifdef HAVE_LONG_LONG + +static int +np_longlong(char *p, PyObject *v, const formatdef *f) +{ + PY_LONG_LONG x; + if (get_longlong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + if (get_ulonglong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} +#endif + +static int +np_float(char *p, PyObject *v, const formatdef *f) +{ + float x = (float)PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof(double)); + return 0; +} + +static int +np_void_p(char *p, PyObject *v, const formatdef *f) +{ + void *x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsVoidPtr(v); + Py_DECREF(v); + if (x == NULL && PyErr_Occurred()) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static formatdef native_table[] = { + {'x', sizeof(char), 0, NULL}, + {'b', sizeof(char), 0, nu_byte, np_byte}, + {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, + {'c', sizeof(char), 0, nu_char, np_char}, + {'s', sizeof(char), 0, NULL}, + {'p', sizeof(char), 0, NULL}, + {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, + {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, + {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, + {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, + {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, + {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, +#ifdef HAVE_LONG_LONG + {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, +#endif + {0} +}; + +/* Big-endian routines. *****************************************************/ + +static PyObject * +bu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +bu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +bu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +bu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +bu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 0); +} + +static PyObject * +bu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 0); +} + +static int +bp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 0); +} + +static int +bp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 0); +} + +static formatdef bigendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, bu_int, bp_int}, + {'B', 1, 0, bu_uint, bp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, bu_int, bp_int}, + {'H', 2, 0, bu_uint, bp_uint}, + {'i', 4, 0, bu_int, bp_int}, + {'I', 4, 0, bu_uint, bp_uint}, + {'l', 4, 0, bu_int, bp_int}, + {'L', 4, 0, bu_uint, bp_uint}, + {'q', 8, 0, bu_longlong, bp_longlong}, + {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, + {'f', 4, 0, bu_float, bp_float}, + {'d', 8, 0, bu_double, bp_double}, + {0} +}; + +/* Little-endian routines. *****************************************************/ + +static PyObject * +lu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +lu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +lu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +lu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +lu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 1); +} + +static PyObject * +lu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 1); +} + +static int +lp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 1); +} + +static int +lp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 1); +} + +static formatdef lilendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, lu_int, lp_int}, + {'B', 1, 0, lu_uint, lp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, lu_int, lp_int}, + {'H', 2, 0, lu_uint, lp_uint}, + {'i', 4, 0, lu_int, lp_int}, + {'I', 4, 0, lu_uint, lp_uint}, + {'l', 4, 0, lu_int, lp_int}, + {'L', 4, 0, lu_uint, lp_uint}, + {'q', 8, 0, lu_longlong, lp_longlong}, + {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, + {'f', 4, 0, lu_float, lp_float}, + {'d', 8, 0, lu_double, lp_double}, + {0} +}; + + +static const formatdef * +whichtable(char **pfmt) +{ + const char *fmt = (*pfmt)++; /* May be backed out of later */ + switch (*fmt) { + case '<': + return lilendian_table; + case '>': + case '!': /* Network byte order is big-endian */ + return bigendian_table; + case '=': { /* Host byte order -- different from native in aligment! */ + int n = 1; + char *p = (char *) &n; + if (*p == 1) + return lilendian_table; + else + return bigendian_table; + } + default: + --*pfmt; /* Back out of pointer increment */ + /* Fall through */ + case '@': + return native_table; + } +} + + +/* Get the table entry for a format code */ + +static const formatdef * +getentry(int c, const formatdef *f) +{ + for (; f->format != '\0'; f++) { + if (f->format == c) { + return f; + } + } + PyErr_SetString(StructError, "bad char in struct format"); + return NULL; +} + + +/* Align a size according to a format code */ + +static int +align(int size, int c, const formatdef *e) +{ + if (e->format == c) { + if (e->alignment) { + size = ((size + e->alignment - 1) + / e->alignment) + * e->alignment; + } + } + return size; +} + + +/* calculate the size of a format string */ + +static int +prepare_s(PyStructObject *self) +{ + const formatdef *f; + const formatdef *e; + formatcode *codes; + + const char *s; + const char *fmt; + char c; + int size, len, numcodes, num, itemsize, x; + + fmt = PyString_AS_STRING(self->s_format); + + f = whichtable((char **)&fmt); + + s = fmt; + size = 0; + len = 0; + numcodes = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') { + x = num*10 + (c - '0'); + if (x/10 != num) { + PyErr_SetString( + StructError, + "overflow in item count"); + return -1; + } + num = x; + } + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + return -1; + + switch (c) { + case 's': /* fall through */ + case 'p': len++; break; + case 'x': break; + default: len += num; break; + } + if (c != 'x') numcodes++; + + itemsize = e->size; + size = align(size, c, e); + x = num * itemsize; + size += x; + if (x/itemsize != num || size < 0) { + PyErr_SetString(StructError, + "total struct size too long"); + return -1; + } + } + + self->s_size = size; + self->s_len = len; + codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + if (codes == NULL) { + PyErr_NoMemory(); + return -1; + } + self->s_codes = codes; + + s = fmt; + size = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + + size = align(size, c, e); + if (c != 'x') { + codes->offset = size; + codes->repeat = num; + codes->fmtdef = e; + codes++; + } + size += num * e->size; + } + codes->fmtdef = NULL; + codes->offset = -1; + codes->repeat = -1; + + return 0; +} + +static PyObject * +s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + static PyObject *not_yet_string; + + assert(type != NULL && type->tp_alloc != NULL); + + self = type->tp_alloc(type, 0); + if (self != NULL) { + PyStructObject *s = (PyStructObject*)self; + Py_INCREF(Py_None); + s->s_format = Py_None; + s->s_codes = NULL; + s->s_size = -1; + s->s_len = -1; + } + return self; +} + +static int +s_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyStructObject *soself = (PyStructObject *)self; + PyObject *o_format = NULL; + int ret = 0; + static char *kwlist[] = {"format", 0}; + + assert(PyStruct_Check(self)); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, + &o_format)) + return -1; + + Py_INCREF(o_format); + Py_XDECREF(soself->s_format); + soself->s_format = o_format; + + ret = prepare_s(soself); + return ret; +} + +static void +s_dealloc(PyStructObject *s) +{ + int sts = 0; + if (s->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *)s); + if (s->s_codes != NULL) { + PyMem_FREE(s->s_codes); + } + Py_XDECREF(s->s_format); + s->ob_type->tp_free((PyObject *)s); +} + +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See struct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + result = PyTuple_New(soself->s_len); + if (result == NULL) + return NULL; + + + restart = PyString_AS_STRING(inputstr); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + const char *res = restart + code->offset; + if (e->format == 's') { + v = PyString_FromStringAndSize(res, code->repeat); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else if (e->format == 'p') { + n = *(unsigned char*)res; + if (n >= code->repeat) + n = code->repeat - 1; + v = PyString_FromStringAndSize(res + 1, n); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else { + for (n = 0; n < code->repeat; n++) { + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + res += e->size; + } + } + } + + return result; +fail: + Py_DECREF(result); + return NULL; +}; + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See struct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + restart = PyString_AS_STRING(result); + memset(restart, '\0', soself->s_size); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + char *res = restart + code->offset; + if (e->format == 's') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 's' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > code->repeat) + n = code->repeat; + if (n > 0) + memcpy(res, PyString_AS_STRING(v), n); + } else if (e->format == 'p') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 'p' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > (code->repeat - 1)) + n = code->repeat - 1; + if (n > 0) + memcpy(res + 1, PyString_AS_STRING(v), n); + if (n > 255) + n = 255; + *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + } else { + for (n = 0; n < code->repeat; n++) { + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; + res += e->size; + } + } + } + + return result; + +fail: + Py_DECREF(result); + return NULL; + +} + + +/* List of functions */ + +static struct PyMethodDef s_methods[] = { + {"pack", s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {NULL, NULL} /* sentinel */ +}; + +PyDoc_STRVAR(s__doc__, "Compiled struct object"); + +#define OFF(x) offsetof(PyStructObject, x) + +static PyMemberDef s_memberlist[] = { + {"format", T_OBJECT, OFF(s_format), RO, + "struct format string"}, + {"size", T_INT, OFF(s_size), RO, + "struct size in bytes"}, + {"_len", T_INT, OFF(s_len), RO, + "number of items expected in tuple"}, + {NULL} /* Sentinel */ +}; + + +static +PyTypeObject PyStructType = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "Struct", + sizeof(PyStructObject), + 0, + (destructor)s_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ + s__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + s_methods, /* tp_methods */ + s_memberlist, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + s_init, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + s_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + +/* Module initialization */ + +PyMODINIT_FUNC +init_struct(void) +{ + PyObject *m = Py_InitModule("_struct", NULL); + if (m == NULL) + return; + + /* Add some symbolic constants to the module */ + if (StructError == NULL) { + StructError = PyErr_NewException("struct.error", NULL, NULL); + if (StructError == NULL) + return; + } + Py_INCREF(StructError); + PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); + PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); +} Deleted: /python/trunk/Modules/structmodule.c ============================================================================== --- /python/trunk/Modules/structmodule.c Tue May 23 20:46:41 2006 +++ (empty file) @@ -1,1293 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include - -PyDoc_STRVAR(struct__doc__, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ -\n\ -The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ -\n\ -The remaining chars indicate types of args and must match exactly;\n\ -these can be preceded by a decimal repeat count:\n\ - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ - h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double.\n\ -Special cases (preceding decimal count indicates length):\n\ - s:string (array of char); p: pascal string (with count byte).\n\ -Special case (only available in native format):\n\ - P:an integer type that is wide enough to hold a pointer.\n\ -Special case (not in native mode unless 'long long' in platform C):\n\ - q:long long; Q:unsigned long long\n\ -Whitespace between formats is ignored.\n\ -\n\ -The variable struct.error is an exception raised on errors."); - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsVoidPtr(v); - Py_DECREF(v); - if (x == NULL && PyErr_Occurred()) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -calcsize(const char *fmt, const formatdef *f) -{ - const formatdef *e; - const char *s; - char c; - int size, num, itemsize, x; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - return size; -} - - -PyDoc_STRVAR(calcsize__doc__, -"calcsize(fmt) -> int\n\ -Return size of C struct described by format string fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_calcsize(PyObject *self, PyObject *args) -{ - char *fmt; - const formatdef *f; - int size; - - if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(pack__doc__, -"pack(fmt, v1, v2, ...) -> string\n\ -Return string containing values v1, v2, ... packed according to fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_pack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - PyObject *format, *result, *v; - char *fmt; - int size, num; - Py_ssize_t i, n; - char *s, *res, *restart, *nres; - char c; - - if (args == NULL || !PyTuple_Check(args) || - (n = PyTuple_Size(args)) < 1) - { - PyErr_SetString(PyExc_TypeError, - "struct.pack requires at least one argument"); - return NULL; - } - format = PyTuple_GetItem(args, 0); - fmt = PyString_AsString(format); - if (!fmt) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - result = PyString_FromStringAndSize((char *)NULL, size); - if (result == NULL) - return NULL; - - s = fmt; - i = 1; - res = restart = PyString_AsString(result); - - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - nres = restart + align((int)(res-restart), c, e); - /* Fill padd bytes with zeros */ - while (res < nres) - *res++ = '\0'; - if (num == 0 && c != 's') - continue; - do { - if (c == 'x') { - /* doesn't consume arguments */ - memset(res, '\0', num); - res += num; - break; - } - if (i >= n) { - PyErr_SetString(StructError, - "insufficient arguments to pack"); - goto fail; - } - v = PyTuple_GetItem(args, i++); - if (v == NULL) - goto fail; - if (c == 's') { - /* num is string size, not repeat count */ - Py_ssize_t n; - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res, PyString_AsString(v), n); - if (n < num) - memset(res+n, '\0', num-n); - res += num; - break; - } - else if (c == 'p') { - /* num is string size + 1, - to fit in the count byte */ - Py_ssize_t n; - num--; /* now num is max string size */ - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res+1, PyString_AsString(v), n); - if (n < num) - /* no real need, just to be nice */ - memset(res+1+n, '\0', num-n); - if (n > 255) - n = 255; - /* store the length byte */ - *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); - res += num; - break; - } - else { - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } while (--num > 0); - } - - if (i < n) { - PyErr_SetString(StructError, - "too many arguments for pack format"); - goto fail; - } - - return result; - - fail: - Py_DECREF(result); - return NULL; -} - - -PyDoc_STRVAR(unpack__doc__, -"unpack(fmt, string) -> (v1, v2, ...)\n\ -Unpack the string, containing packed C structure data, according\n\ -to fmt. Requires len(string)==calcsize(fmt).\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_unpack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - char *str, *start, *fmt, *s; - char c; - int len, size, num; - PyObject *res, *v; - - if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - if (size != len) { - PyErr_SetString(StructError, - "unpack str size does not match format"); - return NULL; - } - res = PyList_New(0); - if (res == NULL) - return NULL; - str = start; - s = fmt; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - str = start + align((int)(str-start), c, e); - if (num == 0 && c != 's') - continue; - - do { - if (c == 'x') { - str += num; - break; - } - if (c == 's') { - /* num is string size, not repeat count */ - v = PyString_FromStringAndSize(str, num); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else if (c == 'p') { - /* num is string buffer size, - not repeat count */ - int n = *(unsigned char*)str; - /* first byte (unsigned) is string size */ - if (n >= num) - n = num-1; - v = PyString_FromStringAndSize(str+1, n); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else { - v = e->unpack(str, e); - if (v == NULL) - goto fail; - str += e->size; - } - if (v == NULL || PyList_Append(res, v) < 0) - goto fail; - Py_DECREF(v); - } while (--num > 0); - } - - v = PyList_AsTuple(res); - Py_DECREF(res); - return v; - - fail: - Py_DECREF(res); - return NULL; -} - - -/* List of functions */ - -static PyMethodDef struct_methods[] = { - {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, - {"pack", struct_pack, METH_VARARGS, pack__doc__}, - {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initstruct(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule4("struct", struct_methods, struct__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); -} Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Tue May 23 20:46:41 2006 @@ -1444,7 +1444,7 @@ 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('struct', ['structmodule.c'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', From buildbot at python.org Tue May 23 20:49:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 18:49:07 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060523184907.00CF31E4009@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/444 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: richard.jones Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 20:56:48 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 20:56:48 +0200 (CEST) Subject: [Python-checkins] r46135 - sandbox/trunk/Doc/functional.rst Message-ID: <20060523185648.5A1B51E4009@bag.python.org> Author: andrew.kuchling Date: Tue May 23 20:56:47 2006 New Revision: 46135 Modified: sandbox/trunk/Doc/functional.rst Log: Fill out the introductory section... still pretty rough. Minor markup fixing. Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Tue May 23 20:56:47 2006 @@ -50,19 +50,38 @@ multi-paradigm; you can write programs or libraries that are largely procedural, object-oriented, or functional. In a large program, different sections might be written in different styles; the GUI might -be object-oriented while the processing logic is procedural, for -example. +be object-oriented while the processing logic is procedural or +functional, for example. In a functional program, input flows through a set of functions. Each function operates on its input and produces some output. Functional -style discourages the use of data structures that get updated as a -program runs. Some languages are very strict about this and even -discourage the use of assignment statements such as ``a=3`` or ``c = a -+ b``. - -Functional programming may seem like an odd constraint to work under. -There are theoretical and practical advantages to the functional -style: +style avoids making functions have side effects that modify internal +state or make other changes that aren't visible in the function's +return value. Avoiding side effects means not using data structures +that get updated as a program runs. Some languages are very strict +about this and don't even have assignment statements such as ``a=3`` +or ``c = a + b``, but it's difficult to avoid all side effects; some +Python code, such as a ``print`` statement or a ``time.sleep(1)``, +returns nothing and is only called for its side effects. + +Python programs written in functional style usually won't go to the +extreme of avoiding all I/O or all assignments. The implementation of +a function will still use assignments to local variables, but won't +touch any global variables or have other side effects. + +Functional programming can be considered the opposite of +object-oriented programming. Objects are little capsules containing +some internal state along with a collection of method calls that let +you modify this state, and programs consist of making the right set of +state changes. Functional programming wants to avoid state changes as +much as possible and works with data flowing between functions. In +Python you might combine the two approaches by writing functions that +take and return instances representing objects in your application +(e-mail messages, transactions, etc.). + +Functional design may seem like an odd constraint to work under. Why +should you avoid objects and side effects? There are theoretical and +practical advantages to the functional style: * Formal provability. * Modularity. @@ -72,13 +91,15 @@ Formal provability '''''''''''''''''''''' -For a long time researchers have been interested in finding -ways to mathematically prove programs correct. This is different -from testing a program on numerous inputs and concluding that -its output is usually correct, or reading a program's source code -and concluding that the code looks right; the goal is instead -a rigorous proof that a program produces the right result for all -possible inputs. +A theoretical benefit is that it's easier to construct a mathematical proof +that a functional program is correct. + +For a long time researchers have been interested in finding ways to +mathematically prove programs correct. This is different from testing +a program on numerous inputs and concluding that its output is usually +correct, or reading a program's source code and concluding that the +code looks right; the goal is instead a rigorous proof that a program +produces the right result for all possible inputs. The technique used to prove programs correct is to write down **invariants**, properties of the input data and of the program's @@ -94,62 +115,68 @@ assignments can break invariants that were true before the assignment without producing any new invariants that can be propagated onward. -Unfortunately, proving programs correct is largely impractical. -Even trivial programs require proofs that are several pages long; -the proof of correctness for a moderately complicated program -would be enormous, and few or none of the programs you use daily -could be proven correct. Even if you wrote down or generated a proof, -there's -now the question of verifying the proof; maybe you -only think you've proved that the program correct. +Unfortunately, proving programs correct is largely impractical and not +relevant to Python software. Even trivial programs require proofs that +are several pages long; the proof of correctness for a moderately +complicated program would be enormous, and few or none of the programs +you use daily (the Python interpreter, your XML parser, your web +browser) could be proven correct. Even if you wrote down or generated +a proof, there would then be the question of verifying the proof; +maybe you only ***think*** you've proved that the program correct. Modularity '''''''''''''''''''''' -.. comment - - Small functions that do one thing. - -Composability -'''''''''''''''''''''' +A more practical benefit of functional programming is that it forces +you to break apart your problem into small pieces. It's easier to +specify and write a small function that does one thing than a large +function that performs a complicated transformation. Small functions +are easier to read and to check for errors. A program that's +structured into many small pieces is a **modular** program. + + +Ease of debugging and testing +'''''''''''''''''''''''''''''''''' + +It's also easier to test and to debug a functional-style program. + +It's easier to debug because functions are generally small and clearly +specified. When a program doesn't work, each function is an interface +point where you can check that the data is correct. You can look at +the intermediate inputs and outputs to quickly isolate the function +that's responsible for a bug. + +Testing is easier because each function is a potential subject for a +unit test. Functions don't depend on system state that needs to be +replicated before running a test; instead you only have to synthesize +the right input and then check that the output matches expectations. -.. comment - You assemble a toolbox of functions that can be mixed -Ease of debugging +Composability '''''''''''''''''''''' -.. comment - Easy to test due to lack of state - Easy to verify output from intermediate steps - - +As you work on a functional-style program, you'll write a number of +functions with varying inputs and outputs. Some of these functions +will be unavoidably specialized to a particular application, but +others will be useful in a wide variety of programs. For example, a +function that takes a directory path and returns all the XML files in +the directory, or a function that takes a filename and returns its +contents would be useful in many different situations. + +Over time you'll form a personal library of utilities. Often you'll +assemble new programs by arranging existing functions in a new +configuration and writing a few functions specialized for the current +task. - - Formal provability - Not very relevant to Python - Modularity - Small functions that do one thing - Composability - You assemble a toolbox of functions that can be mixed - Debuggability: - Easy to test due to lack of state - Easy to verify output from intermediate steps - -Functional programming can be considered the opposite of -object-oriented programming. Objects are little capsules containing -some internal state along with a collection of method calls that let -you modify this state. - Iterators ----------------------- -Iterators are the fundamental Python feature that provides -the foundation for writing functional-style programs. +Iterators are an important foundation for writing functional-style +programs. An iterator is an object representing a stream of data that returns the data one element at a time. A Python iterator must support a @@ -324,7 +351,7 @@ The ``for...in`` clauses contain the sequences to be iterated over. The sequences do not have to be the same length, because they are -iterated over from left to right, **not** in parallel. For each +iterated over from left to right, ***not*** in parallel. For each element in ``sequence1``, ``sequence2`` is looped over from the beginning. ``sequence3`` is then looped over for each resulting pair of elements from ``sequence1`` and ``sequence2``. From python-checkins at python.org Tue May 23 21:00:47 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 21:00:47 +0200 (CEST) Subject: [Python-checkins] r46136 - python/trunk/Misc/NEWS Message-ID: <20060523190047.402A51E4003@bag.python.org> Author: andrew.kuchling Date: Tue May 23 21:00:45 2006 New Revision: 46136 Modified: python/trunk/Misc/NEWS Log: Remove duplicate item Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 21:00:45 2006 @@ -22,9 +22,6 @@ - PyErr_NewException now accepts a tuple of base classes as its "base" parameter. -- PyErr_NewException now accepts a tuple of base classes as its - "base" parameter. - - Patch #876206: function call speedup by retaining allocated frame objects. From buildbot at python.org Tue May 23 21:01:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:01:07 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060523190107.CC0731E4003@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/819 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 23 21:02:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:02:59 +0000 Subject: [Python-checkins] buildbot failure in x86 W2k trunk Message-ID: <20060523190259.9AEEF1E4003@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/750 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,tim.peters BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Tue May 23 21:04:56 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:04:56 +0200 (CEST) Subject: [Python-checkins] r46137 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setup.py setuptools/__init__.py version.dat Message-ID: <20060523190456.E27E41E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:04:56 2006 New Revision: 46137 Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/version.dat Log: Bump version for development of 0.6b2 Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Tue May 23 21:04:56 2006 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6b1" +DEFAULT_VERSION = "0.6b2" DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Tue May 23 21:04:56 2006 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6b1" +export VERSION="0.6b2" wpython setup.py -q source && \ cpython setup.py -q binary && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Tue May 23 21:04:56 2006 @@ -19,7 +19,7 @@ d = {}; execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6b1" +VERSION = "0.6b2" from setuptools import setup, find_packages import sys scripts = [] Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Tue May 23 21:04:56 2006 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6b1' +__version__ = '0.6b2' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Tue May 23 21:04:56 2006 @@ -1,6 +1,6 @@ [setuptools] status = 'beta' major = 0 -build = 1 +build = 2 minor = 6 From buildbot at python.org Tue May 23 21:05:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:05:19 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060523190520.0C5B61E403C@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/649 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 21:06:13 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:06:13 +0200 (CEST) Subject: [Python-checkins] r46138 - sandbox/trunk/setuptools/ez_setup.py Message-ID: <20060523190613.838FB1E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:06:13 2006 New Revision: 46138 Modified: sandbox/trunk/setuptools/ez_setup.py Log: Remove outdated MD5 signatures Modified: sandbox/trunk/setuptools/ez_setup.py ============================================================================== --- sandbox/trunk/setuptools/ez_setup.py (original) +++ sandbox/trunk/setuptools/ez_setup.py Tue May 23 21:06:13 2006 @@ -18,32 +18,10 @@ DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { - 'setuptools-0.6a1-py2.3.egg': 'ee819a13b924d9696b0d6ca6d1c5833d', - 'setuptools-0.6a1-py2.4.egg': '8256b5f1cd9e348ea6877b5ddd56257d', 'setuptools-0.6a10-py2.3.egg': '162d8357f1aff2b0349c6c247ee62987', 'setuptools-0.6a10-py2.4.egg': '803a2d8db501c1ac3b5b6fb4e907f788', 'setuptools-0.6a11-py2.3.egg': 'd12bf8e13aaeb25c91350c8d77f01a71', 'setuptools-0.6a11-py2.4.egg': 'a95d5bc7a070aa1028bc4dcb5270b133', - 'setuptools-0.6a11dev_r43177-py2.3.egg': '068ef7c8522539af12f5fb14b4a8cf21', - 'setuptools-0.6a11dev_r43295-py2.3.egg': 'eb78390e6beac3694342b5629cc6653f', - 'setuptools-0.6a11dev_r43403-py2.3.egg': 'ba1a6b00f5c1fdd482284a7df3d8bd19', - 'setuptools-0.6a11dev_r43417-py2.3.egg': 'c6014183afd9fd167d7d82eee78db2c6', - 'setuptools-0.6a2-py2.3.egg': 'b98da449da411267c37a738f0ab625ba', - 'setuptools-0.6a2-py2.4.egg': 'be5b88bc30aed63fdefd2683be135c3b', - 'setuptools-0.6a3-py2.3.egg': 'ee0e325de78f23aab79d33106dc2a8c8', - 'setuptools-0.6a3-py2.4.egg': 'd95453d525a456d6c23e7a5eea89a063', - 'setuptools-0.6a4-py2.3.egg': 'e958cbed4623bbf47dd1f268b99d7784', - 'setuptools-0.6a4-py2.4.egg': '7f33c3ac2ef1296f0ab4fac1de4767d8', - 'setuptools-0.6a5-py2.3.egg': '748408389c49bcd2d84f6ae0b01695b1', - 'setuptools-0.6a5-py2.4.egg': '999bacde623f4284bfb3ea77941d2627', - 'setuptools-0.6a6-py2.3.egg': '7858139f06ed0600b0d9383f36aca24c', - 'setuptools-0.6a6-py2.4.egg': 'c10d20d29acebce0dc76219dc578d058', - 'setuptools-0.6a7-py2.3.egg': 'cfc4125ddb95c07f9500adc5d6abef6f', - 'setuptools-0.6a7-py2.4.egg': 'c6d62dab4461f71aed943caea89e6f20', - 'setuptools-0.6a8-py2.3.egg': '2f18eaaa3f544f5543ead4a68f3b2e1a', - 'setuptools-0.6a8-py2.4.egg': '799018f2894f14c9f8bcb2b34e69b391', - 'setuptools-0.6a9-py2.3.egg': '8e438ad70438b07b0d8f82cae42b278f', - 'setuptools-0.6a9-py2.4.egg': '8f6e01fc12fb1cd006dc0d6c04327ec1', } import sys, os @@ -58,7 +36,7 @@ % egg_name ) sys.exit(2) - return data + return data def use_setuptools( @@ -74,7 +52,7 @@ be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in - an attempt to abort the calling script. + an attempt to abort the calling script. """ try: import setuptools @@ -189,7 +167,7 @@ print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' - + def update_md5(filenames): """Update our built-in md5 registry""" @@ -198,7 +176,7 @@ for name in filenames: base = os.path.basename(name) - f = open(name,'rb') + f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() From python-checkins at python.org Tue May 23 21:06:45 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:06:45 +0200 (CEST) Subject: [Python-checkins] r46139 - sandbox/trunk/setuptools/EasyInstall.txt Message-ID: <20060523190645.675031E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:06:45 2006 New Revision: 46139 Modified: sandbox/trunk/setuptools/EasyInstall.txt Log: Merge doc update from 0.6b1 Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Tue May 23 21:06:45 2006 @@ -1106,6 +1106,16 @@ remove ones that fail, until something works. The removed IPs stay removed for the remainder of the run. + * Better ambiguity management: accept ``#egg`` name/version even if processing + what appears to be a correctly-named distutils file, and ignore ``.egg`` + files with no ``-``, since valid Python ``.egg`` files always have a version + number (but Scheme eggs often don't). + + * Support ``file://`` links to directories in ``--find-links``, so that + easy_install can build packages from local source checkouts. + + * Ignore bdist_dumb distributions when looking at download URLs. + Future Plans ============ From python-checkins at python.org Tue May 23 21:09:28 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:09:28 +0200 (CEST) Subject: [Python-checkins] r46140 - in sandbox/trunk/setuptools: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20060523190928.4865C1E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:09:27 2006 New Revision: 46140 Modified: sandbox/trunk/setuptools/EasyInstall.txt sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Don't install or update a ``site.py`` patch when installing to a ``PYTHONPATH`` directory with ``--multi-version``, unless an ``easy-install.pth`` file is already in use there. Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Tue May 23 21:09:27 2006 @@ -1116,6 +1116,10 @@ * Ignore bdist_dumb distributions when looking at download URLs. + * Don't install or update a ``site.py`` patch when installing to a + ``PYTHONPATH`` directory with ``--multi-version``, unless an + ``easy-install.pth`` file is already in use there. + Future Plans ============ Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Tue May 23 21:09:27 2006 @@ -246,7 +246,6 @@ def check_site_dir(self): """Verify that self.install_dir is .pth-capable dir, if needed""" - instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir,'easy-install.pth') @@ -281,10 +280,11 @@ if instdir not in map(normalize_path, filter(None,PYTHONPATH)): # only PYTHONPATH dirs need a site.py, so pretend it's there self.sitepy_installed = True - + elif self.multi_version and not os.path.exists(pth_file): + self.sitepy_installed = True # don't need site.py in this case + self.pth_file = None # and don't create a .pth file self.install_dir = instdir - def cant_write_to_target(self): msg = """can't create or remove files in install directory @@ -572,8 +572,6 @@ - - def install_script(self, dist, script_name, script_text, dev_path=None): """Generate a legacy script wrapper and install it""" spec = str(dist.as_requirement()) From python-checkins at python.org Tue May 23 21:09:52 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:09:52 +0200 (CEST) Subject: [Python-checkins] r46141 - in python/trunk: Lib/struct.py Misc/NEWS Modules/Setup.dist Modules/_struct.c Modules/structmodule.c setup.py Message-ID: <20060523190952.D305F1E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:09:51 2006 New Revision: 46141 Added: python/trunk/Modules/structmodule.c (contents, props changed) Removed: python/trunk/Lib/struct.py python/trunk/Modules/_struct.c Modified: python/trunk/Misc/NEWS python/trunk/Modules/Setup.dist python/trunk/setup.py Log: revert #1493701 Deleted: /python/trunk/Lib/struct.py ============================================================================== --- /python/trunk/Lib/struct.py Tue May 23 21:09:51 2006 +++ (empty file) @@ -1,76 +0,0 @@ -""" -Functions to convert between Python values and C structs. -Python strings are used to hold the data representing the C struct -and also as format strings to describe the layout of data in the C struct. - -The optional first format char indicates byte order, size and alignment: - @: native order, size & alignment (default) - =: native order, std. size & alignment - <: little-endian, std. size & alignment - >: big-endian, std. size & alignment - !: same as > - -The remaining chars indicate types of args and must match exactly; -these can be preceded by a decimal repeat count: - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte; - h:short; H:unsigned short; i:int; I:unsigned int; - l:long; L:unsigned long; f:float; d:double. -Special cases (preceding decimal count indicates length): - s:string (array of char); p: pascal string (with count byte). -Special case (only available in native format): - P:an integer type that is wide enough to hold a pointer. -Special case (not in native mode unless 'long long' in platform C): - q:long long; Q:unsigned long long -Whitespace between formats is ignored. - -The variable struct.error is an exception raised on errors. -""" -__version__ = '0.1' - -from _struct import Struct, error - -_MAXCACHE = 100 -_cache = {} - -def _compile(fmt): - # Internal: compile struct pattern - if len(_cache) >= _MAXCACHE: - _cache.clear() - s = Struct(fmt) - _cache[fmt] = s - return s - -def calcsize(fmt): - """ - Return size of C struct described by format string fmt. - See struct.__doc__ for more on format strings. - """ - try: - o = _cache[fmt] - except KeyError: - o = _compile(fmt) - return o.size - -def pack(fmt, *args): - """ - Return string containing values v1, v2, ... packed according to fmt. - See struct.__doc__ for more on format strings. - """ - try: - o = _cache[fmt] - except KeyError: - o = _compile(fmt) - return o.pack(*args) - -def unpack(fmt, s): - """ - Unpack the string, containing packed C structure data, according - to fmt. Requires len(string)==calcsize(fmt). - See struct.__doc__ for more on format strings. - """ - try: - o = _cache[fmt] - except KeyError: - o = _compile(fmt) - return o.unpack(s) - Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 21:09:51 2006 @@ -45,8 +45,6 @@ Extension Modules ----------------- -- Patch #1493701: performance enhancements for struct module. - - Patch #1490224: time.altzone is now set correctly on Cygwin. - Patch #1435422: zlib's compress and decompress objects now have a Modified: python/trunk/Modules/Setup.dist ============================================================================== --- python/trunk/Modules/Setup.dist (original) +++ python/trunk/Modules/Setup.dist Tue May 23 21:09:51 2006 @@ -167,7 +167,7 @@ #array arraymodule.c # array objects #cmath cmathmodule.c # -lm # complex math library functions #math mathmodule.c # -lm # math library functions, e.g. sin() -#_struct _struct.c # binary structure packing/unpacking +#struct structmodule.c # binary structure packing/unpacking #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support Deleted: /python/trunk/Modules/_struct.c ============================================================================== --- /python/trunk/Modules/_struct.c Tue May 23 21:09:51 2006 +++ (empty file) @@ -1,1355 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include "structseq.h" -#include "structmember.h" -#include - - -/* compatibility macros */ -#if (PY_VERSION_HEX < 0x02050000) -typedef int Py_ssize_t; -#endif - - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -typedef struct _formatcode { - const struct _formatdef *fmtdef; - int offset; - int repeat; -} formatcode; - -/* Struct object interface */ - -typedef struct { - PyObject_HEAD - int s_size; - int s_len; - formatcode *s_codes; - PyObject *s_format; - PyObject *weakreflist; /* List of weak references */ -} PyStructObject; - -PyAPI_DATA(PyTypeObject) PyStruct_Type; - -#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) -#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsVoidPtr(v); - Py_DECREF(v); - if (x == NULL && PyErr_Occurred()) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -prepare_s(PyStructObject *self) -{ - const formatdef *f; - const formatdef *e; - formatcode *codes; - - const char *s; - const char *fmt; - char c; - int size, len, numcodes, num, itemsize, x; - - fmt = PyString_AS_STRING(self->s_format); - - f = whichtable((char **)&fmt); - - s = fmt; - size = 0; - len = 0; - numcodes = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - - switch (c) { - case 's': /* fall through */ - case 'p': len++; break; - case 'x': break; - default: len += num; break; - } - if (c != 'x') numcodes++; - - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - self->s_size = size; - self->s_len = len; - codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); - if (codes == NULL) { - PyErr_NoMemory(); - return -1; - } - self->s_codes = codes; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - - size = align(size, c, e); - if (c != 'x') { - codes->offset = size; - codes->repeat = num; - codes->fmtdef = e; - codes++; - } - size += num * e->size; - } - codes->fmtdef = NULL; - codes->offset = -1; - codes->repeat = -1; - - return 0; -} - -static PyObject * -s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *self; - static PyObject *not_yet_string; - - assert(type != NULL && type->tp_alloc != NULL); - - self = type->tp_alloc(type, 0); - if (self != NULL) { - PyStructObject *s = (PyStructObject*)self; - Py_INCREF(Py_None); - s->s_format = Py_None; - s->s_codes = NULL; - s->s_size = -1; - s->s_len = -1; - } - return self; -} - -static int -s_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyStructObject *soself = (PyStructObject *)self; - PyObject *o_format = NULL; - int ret = 0; - static char *kwlist[] = {"format", 0}; - - assert(PyStruct_Check(self)); - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, - &o_format)) - return -1; - - Py_INCREF(o_format); - Py_XDECREF(soself->s_format); - soself->s_format = o_format; - - ret = prepare_s(soself); - return ret; -} - -static void -s_dealloc(PyStructObject *s) -{ - int sts = 0; - if (s->weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *)s); - if (s->s_codes != NULL) { - PyMem_FREE(s->s_codes); - } - Py_XDECREF(s->s_format); - s->ob_type->tp_free((PyObject *)s); -} - -PyDoc_STRVAR(s_unpack__doc__, -"unpack(str) -> (v1, v2, ...)\n\ -\n\ -Return tuple containing values unpacked according to this Struct's format.\n\ -Requires len(str) == self.size. See struct.__doc__ for more on format\n\ -strings."); - -static PyObject * -s_unpack(PyObject *self, PyObject *inputstr) -{ - PyStructObject *soself; - PyObject *result; - char *restart; - formatcode *code; - Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (inputstr == NULL || !PyString_Check(inputstr) || - PyString_GET_SIZE(inputstr) != soself->s_size) { - PyErr_Format(StructError, - "unpack requires a string argument of length %d", soself->s_size); - return NULL; - } - result = PyTuple_New(soself->s_len); - if (result == NULL) - return NULL; - - - restart = PyString_AS_STRING(inputstr); - i = 0; - for (code = soself->s_codes; code->fmtdef != NULL; code++) { - Py_ssize_t n; - PyObject *v; - const formatdef *e = code->fmtdef; - const char *res = restart + code->offset; - if (e->format == 's') { - v = PyString_FromStringAndSize(res, code->repeat); - if (v == NULL) - goto fail; - PyTuple_SET_ITEM(result, i++, v); - } else if (e->format == 'p') { - n = *(unsigned char*)res; - if (n >= code->repeat) - n = code->repeat - 1; - v = PyString_FromStringAndSize(res + 1, n); - if (v == NULL) - goto fail; - PyTuple_SET_ITEM(result, i++, v); - } else { - for (n = 0; n < code->repeat; n++) { - v = e->unpack(res, e); - if (v == NULL) - goto fail; - PyTuple_SET_ITEM(result, i++, v); - res += e->size; - } - } - } - - return result; -fail: - Py_DECREF(result); - return NULL; -}; - - -PyDoc_STRVAR(s_pack__doc__, -"pack(v1, v2, ...) -> string\n\ -\n\ -Return a string containing values v1, v2, ... packed according to this\n\ -Struct's format. See struct.__doc__ for more on format strings."); - -static PyObject * -s_pack(PyObject *self, PyObject *args) -{ - PyStructObject *soself; - PyObject *result; - char *restart; - formatcode *code; - Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (args == NULL || !PyTuple_Check(args) || - PyTuple_GET_SIZE(args) != soself->s_len) - { - PyErr_Format(StructError, - "pack requires exactly %d arguments", soself->s_len); - return NULL; - } - - result = PyString_FromStringAndSize((char *)NULL, soself->s_size); - if (result == NULL) - return NULL; - - restart = PyString_AS_STRING(result); - memset(restart, '\0', soself->s_size); - i = 0; - for (code = soself->s_codes; code->fmtdef != NULL; code++) { - Py_ssize_t n; - PyObject *v; - const formatdef *e = code->fmtdef; - char *res = restart + code->offset; - if (e->format == 's') { - v = PyTuple_GET_ITEM(args, i++); - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_GET_SIZE(v); - if (n > code->repeat) - n = code->repeat; - if (n > 0) - memcpy(res, PyString_AS_STRING(v), n); - } else if (e->format == 'p') { - v = PyTuple_GET_ITEM(args, i++); - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_GET_SIZE(v); - if (n > (code->repeat - 1)) - n = code->repeat - 1; - if (n > 0) - memcpy(res + 1, PyString_AS_STRING(v), n); - if (n > 255) - n = 255; - *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); - } else { - for (n = 0; n < code->repeat; n++) { - v = PyTuple_GET_ITEM(args, i++); - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } - } - - return result; - -fail: - Py_DECREF(result); - return NULL; - -} - - -/* List of functions */ - -static struct PyMethodDef s_methods[] = { - {"pack", s_pack, METH_VARARGS, s_pack__doc__}, - {"unpack", s_unpack, METH_O, s_unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(s__doc__, "Compiled struct object"); - -#define OFF(x) offsetof(PyStructObject, x) - -static PyMemberDef s_memberlist[] = { - {"format", T_OBJECT, OFF(s_format), RO, - "struct format string"}, - {"size", T_INT, OFF(s_size), RO, - "struct size in bytes"}, - {"_len", T_INT, OFF(s_len), RO, - "number of items expected in tuple"}, - {NULL} /* Sentinel */ -}; - - -static -PyTypeObject PyStructType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "Struct", - sizeof(PyStructObject), - 0, - (destructor)s_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ - s__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - s_methods, /* tp_methods */ - s_memberlist, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - s_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - s_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - -/* Module initialization */ - -PyMODINIT_FUNC -init_struct(void) -{ - PyObject *m = Py_InitModule("_struct", NULL); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); - Py_INCREF((PyObject*)&PyStructType); - PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); -} Added: python/trunk/Modules/structmodule.c ============================================================================== --- (empty file) +++ python/trunk/Modules/structmodule.c Tue May 23 21:09:51 2006 @@ -0,0 +1,1293 @@ +/* struct module -- pack values into and (out of) strings */ + +/* New version supporting byte order, alignment and size options, + character strings, and unsigned numbers */ + +#include "Python.h" +#include + +PyDoc_STRVAR(struct__doc__, +"Functions to convert between Python values and C structs.\n\ +Python strings are used to hold the data representing the C struct\n\ +and also as format strings to describe the layout of data in the C struct.\n\ +\n\ +The optional first format char indicates byte order, size and alignment:\n\ + @: native order, size & alignment (default)\n\ + =: native order, std. size & alignment\n\ + <: little-endian, std. size & alignment\n\ + >: big-endian, std. size & alignment\n\ + !: same as >\n\ +\n\ +The remaining chars indicate types of args and must match exactly;\n\ +these can be preceded by a decimal repeat count:\n\ + x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ + h:short; H:unsigned short; i:int; I:unsigned int;\n\ + l:long; L:unsigned long; f:float; d:double.\n\ +Special cases (preceding decimal count indicates length):\n\ + s:string (array of char); p: pascal string (with count byte).\n\ +Special case (only available in native format):\n\ + P:an integer type that is wide enough to hold a pointer.\n\ +Special case (not in native mode unless 'long long' in platform C):\n\ + q:long long; Q:unsigned long long\n\ +Whitespace between formats is ignored.\n\ +\n\ +The variable struct.error is an exception raised on errors."); + + +/* Exception */ + +static PyObject *StructError; + + +/* Define various structs to figure out the alignments of types */ + + +typedef struct { char c; short x; } st_short; +typedef struct { char c; int x; } st_int; +typedef struct { char c; long x; } st_long; +typedef struct { char c; float x; } st_float; +typedef struct { char c; double x; } st_double; +typedef struct { char c; void *x; } st_void_p; + +#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) +#define INT_ALIGN (sizeof(st_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) +#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) +#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) + +/* We can't support q and Q in native mode unless the compiler does; + in std mode, they're 8 bytes on all platforms. */ +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +#define STRINGIFY(x) #x + +#ifdef __powerc +#pragma options align=reset +#endif + +/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ + +static PyObject * +get_pylong(PyObject *v) +{ + PyNumberMethods *m; + + assert(v != NULL); + if (PyInt_Check(v)) + return PyLong_FromLong(PyInt_AS_LONG(v)); + if (PyLong_Check(v)) { + Py_INCREF(v); + return v; + } + m = v->ob_type->tp_as_number; + if (m != NULL && m->nb_long != NULL) { + v = m->nb_long(v); + if (v == NULL) + return NULL; + if (PyLong_Check(v)) + return v; + Py_DECREF(v); + } + PyErr_SetString(StructError, + "cannot convert argument to long"); + return NULL; +} + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x = PyInt_AsLong(v); + if (x == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_SetString(StructError, + "required argument is not an integer"); + return -1; + } + *p = x; + return 0; +} + + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + if (PyLong_Check(v)) { + unsigned long x = PyLong_AsUnsignedLong(v); + if (x == (unsigned long)(-1) && PyErr_Occurred()) + return -1; + *p = x; + return 0; + } + else { + return get_long(v, (long *)p); + } +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsLongLong(v); + Py_DECREF(v); + if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsUnsignedLongLong(v); + Py_DECREF(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/* Floating point helpers */ + +static PyObject * +unpack_float(const char *p, /* start of 4-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack4((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + +static PyObject * +unpack_double(const char *p, /* start of 8-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack8((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + + +/* The translation function for each format character is table driven */ + +typedef struct _formatdef { + char format; + int size; + int alignment; + PyObject* (*unpack)(const char *, + const struct _formatdef *); + int (*pack)(char *, PyObject *, + const struct _formatdef *); +} formatdef; + +/* A large number of small routines follow, with names of the form + + [bln][up]_TYPE + + [bln] distiguishes among big-endian, little-endian and native. + [pu] distiguishes between pack (to struct) and unpack (from struct). + TYPE is one of char, byte, ubyte, etc. +*/ + +/* Native mode routines. ****************************************************/ +/* NOTE: + In all n[up]_ routines handling types larger than 1 byte, there is + *no* guarantee that the p pointer is properly aligned for each type, + therefore memcpy is called. An intermediate variable is used to + compensate for big-endian architectures. + Normally both the intermediate variable and the memcpy call will be + skipped by C optimisation in little-endian architectures (gcc >= 2.91 + does this). */ + +static PyObject * +nu_char(const char *p, const formatdef *f) +{ + return PyString_FromStringAndSize(p, 1); +} + +static PyObject * +nu_byte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(signed char *)p); +} + +static PyObject * +nu_ubyte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(unsigned char *)p); +} + +static PyObject * +nu_short(const char *p, const formatdef *f) +{ + short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_ushort(const char *p, const formatdef *f) +{ + unsigned short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_int(const char *p, const formatdef *f) +{ + int x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_uint(const char *p, const formatdef *f) +{ + unsigned int x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong((unsigned long)x); +} + +static PyObject * +nu_long(const char *p, const formatdef *f) +{ + long x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong(x); +} + +static PyObject * +nu_ulong(const char *p, const formatdef *f) +{ + unsigned long x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong(x); +} + +/* Native mode doesn't support q or Q unless the platform C supports + long long (or, on Windows, __int64). */ + +#ifdef HAVE_LONG_LONG + +static PyObject * +nu_longlong(const char *p, const formatdef *f) +{ + PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromLongLong(x); +} + +static PyObject * +nu_ulonglong(const char *p, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLongLong(x); +} + +#endif + +static PyObject * +nu_float(const char *p, const formatdef *f) +{ + float x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble((double)x); +} + +static PyObject * +nu_double(const char *p, const formatdef *f) +{ + double x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble(x); +} + +static PyObject * +nu_void_p(const char *p, const formatdef *f) +{ + void *x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromVoidPtr(x); +} + +static int +np_byte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < -128 || x > 127){ + PyErr_SetString(StructError, + "byte format requires -128<=number<=127"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_ubyte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > 255){ + PyErr_SetString(StructError, + "ubyte format requires 0<=number<=255"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_char(char *p, PyObject *v, const formatdef *f) +{ + if (!PyString_Check(v) || PyString_Size(v) != 1) { + PyErr_SetString(StructError, + "char format require string of length 1"); + return -1; + } + *p = *PyString_AsString(v); + return 0; +} + +static int +np_short(char *p, PyObject *v, const formatdef *f) +{ + long x; + short y; + if (get_long(v, &x) < 0) + return -1; + if (x < SHRT_MIN || x > SHRT_MAX){ + PyErr_SetString(StructError, + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); + return -1; + } + y = (short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_ushort(char *p, PyObject *v, const formatdef *f) +{ + long x; + unsigned short y; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > USHRT_MAX){ + PyErr_SetString(StructError, + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + return -1; + } + y = (unsigned short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int y; + if (get_long(v, &x) < 0) + return -1; + y = (int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + unsigned int y; + if (get_ulong(v, &x) < 0) + return -1; + y = (unsigned int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_long(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulong(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + if (get_ulong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +#ifdef HAVE_LONG_LONG + +static int +np_longlong(char *p, PyObject *v, const formatdef *f) +{ + PY_LONG_LONG x; + if (get_longlong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + if (get_ulonglong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} +#endif + +static int +np_float(char *p, PyObject *v, const formatdef *f) +{ + float x = (float)PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof(double)); + return 0; +} + +static int +np_void_p(char *p, PyObject *v, const formatdef *f) +{ + void *x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsVoidPtr(v); + Py_DECREF(v); + if (x == NULL && PyErr_Occurred()) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static formatdef native_table[] = { + {'x', sizeof(char), 0, NULL}, + {'b', sizeof(char), 0, nu_byte, np_byte}, + {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, + {'c', sizeof(char), 0, nu_char, np_char}, + {'s', sizeof(char), 0, NULL}, + {'p', sizeof(char), 0, NULL}, + {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, + {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, + {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, + {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, + {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, + {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, +#ifdef HAVE_LONG_LONG + {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, +#endif + {0} +}; + +/* Big-endian routines. *****************************************************/ + +static PyObject * +bu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +bu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +bu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +bu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +bu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 0); +} + +static PyObject * +bu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 0); +} + +static int +bp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 0); +} + +static int +bp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 0); +} + +static formatdef bigendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, bu_int, bp_int}, + {'B', 1, 0, bu_uint, bp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, bu_int, bp_int}, + {'H', 2, 0, bu_uint, bp_uint}, + {'i', 4, 0, bu_int, bp_int}, + {'I', 4, 0, bu_uint, bp_uint}, + {'l', 4, 0, bu_int, bp_int}, + {'L', 4, 0, bu_uint, bp_uint}, + {'q', 8, 0, bu_longlong, bp_longlong}, + {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, + {'f', 4, 0, bu_float, bp_float}, + {'d', 8, 0, bu_double, bp_double}, + {0} +}; + +/* Little-endian routines. *****************************************************/ + +static PyObject * +lu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +lu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +lu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +lu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +lu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 1); +} + +static PyObject * +lu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 1); +} + +static int +lp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 1); +} + +static int +lp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 1); +} + +static formatdef lilendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, lu_int, lp_int}, + {'B', 1, 0, lu_uint, lp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, lu_int, lp_int}, + {'H', 2, 0, lu_uint, lp_uint}, + {'i', 4, 0, lu_int, lp_int}, + {'I', 4, 0, lu_uint, lp_uint}, + {'l', 4, 0, lu_int, lp_int}, + {'L', 4, 0, lu_uint, lp_uint}, + {'q', 8, 0, lu_longlong, lp_longlong}, + {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, + {'f', 4, 0, lu_float, lp_float}, + {'d', 8, 0, lu_double, lp_double}, + {0} +}; + + +static const formatdef * +whichtable(char **pfmt) +{ + const char *fmt = (*pfmt)++; /* May be backed out of later */ + switch (*fmt) { + case '<': + return lilendian_table; + case '>': + case '!': /* Network byte order is big-endian */ + return bigendian_table; + case '=': { /* Host byte order -- different from native in aligment! */ + int n = 1; + char *p = (char *) &n; + if (*p == 1) + return lilendian_table; + else + return bigendian_table; + } + default: + --*pfmt; /* Back out of pointer increment */ + /* Fall through */ + case '@': + return native_table; + } +} + + +/* Get the table entry for a format code */ + +static const formatdef * +getentry(int c, const formatdef *f) +{ + for (; f->format != '\0'; f++) { + if (f->format == c) { + return f; + } + } + PyErr_SetString(StructError, "bad char in struct format"); + return NULL; +} + + +/* Align a size according to a format code */ + +static int +align(int size, int c, const formatdef *e) +{ + if (e->format == c) { + if (e->alignment) { + size = ((size + e->alignment - 1) + / e->alignment) + * e->alignment; + } + } + return size; +} + + +/* calculate the size of a format string */ + +static int +calcsize(const char *fmt, const formatdef *f) +{ + const formatdef *e; + const char *s; + char c; + int size, num, itemsize, x; + + s = fmt; + size = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') { + x = num*10 + (c - '0'); + if (x/10 != num) { + PyErr_SetString( + StructError, + "overflow in item count"); + return -1; + } + num = x; + } + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + return -1; + itemsize = e->size; + size = align(size, c, e); + x = num * itemsize; + size += x; + if (x/itemsize != num || size < 0) { + PyErr_SetString(StructError, + "total struct size too long"); + return -1; + } + } + + return size; +} + + +PyDoc_STRVAR(calcsize__doc__, +"calcsize(fmt) -> int\n\ +Return size of C struct described by format string fmt.\n\ +See struct.__doc__ for more on format strings."); + +static PyObject * +struct_calcsize(PyObject *self, PyObject *args) +{ + char *fmt; + const formatdef *f; + int size; + + if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) + return NULL; + f = whichtable(&fmt); + size = calcsize(fmt, f); + if (size < 0) + return NULL; + return PyInt_FromLong((long)size); +} + + +PyDoc_STRVAR(pack__doc__, +"pack(fmt, v1, v2, ...) -> string\n\ +Return string containing values v1, v2, ... packed according to fmt.\n\ +See struct.__doc__ for more on format strings."); + +static PyObject * +struct_pack(PyObject *self, PyObject *args) +{ + const formatdef *f, *e; + PyObject *format, *result, *v; + char *fmt; + int size, num; + Py_ssize_t i, n; + char *s, *res, *restart, *nres; + char c; + + if (args == NULL || !PyTuple_Check(args) || + (n = PyTuple_Size(args)) < 1) + { + PyErr_SetString(PyExc_TypeError, + "struct.pack requires at least one argument"); + return NULL; + } + format = PyTuple_GetItem(args, 0); + fmt = PyString_AsString(format); + if (!fmt) + return NULL; + f = whichtable(&fmt); + size = calcsize(fmt, f); + if (size < 0) + return NULL; + result = PyString_FromStringAndSize((char *)NULL, size); + if (result == NULL) + return NULL; + + s = fmt; + i = 1; + res = restart = PyString_AsString(result); + + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + goto fail; + nres = restart + align((int)(res-restart), c, e); + /* Fill padd bytes with zeros */ + while (res < nres) + *res++ = '\0'; + if (num == 0 && c != 's') + continue; + do { + if (c == 'x') { + /* doesn't consume arguments */ + memset(res, '\0', num); + res += num; + break; + } + if (i >= n) { + PyErr_SetString(StructError, + "insufficient arguments to pack"); + goto fail; + } + v = PyTuple_GetItem(args, i++); + if (v == NULL) + goto fail; + if (c == 's') { + /* num is string size, not repeat count */ + Py_ssize_t n; + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 's' must be a string"); + goto fail; + } + n = PyString_Size(v); + if (n > num) + n = num; + if (n > 0) + memcpy(res, PyString_AsString(v), n); + if (n < num) + memset(res+n, '\0', num-n); + res += num; + break; + } + else if (c == 'p') { + /* num is string size + 1, + to fit in the count byte */ + Py_ssize_t n; + num--; /* now num is max string size */ + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 'p' must be a string"); + goto fail; + } + n = PyString_Size(v); + if (n > num) + n = num; + if (n > 0) + memcpy(res+1, PyString_AsString(v), n); + if (n < num) + /* no real need, just to be nice */ + memset(res+1+n, '\0', num-n); + if (n > 255) + n = 255; + /* store the length byte */ + *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + res += num; + break; + } + else { + if (e->pack(res, v, e) < 0) + goto fail; + res += e->size; + } + } while (--num > 0); + } + + if (i < n) { + PyErr_SetString(StructError, + "too many arguments for pack format"); + goto fail; + } + + return result; + + fail: + Py_DECREF(result); + return NULL; +} + + +PyDoc_STRVAR(unpack__doc__, +"unpack(fmt, string) -> (v1, v2, ...)\n\ +Unpack the string, containing packed C structure data, according\n\ +to fmt. Requires len(string)==calcsize(fmt).\n\ +See struct.__doc__ for more on format strings."); + +static PyObject * +struct_unpack(PyObject *self, PyObject *args) +{ + const formatdef *f, *e; + char *str, *start, *fmt, *s; + char c; + int len, size, num; + PyObject *res, *v; + + if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) + return NULL; + f = whichtable(&fmt); + size = calcsize(fmt, f); + if (size < 0) + return NULL; + if (size != len) { + PyErr_SetString(StructError, + "unpack str size does not match format"); + return NULL; + } + res = PyList_New(0); + if (res == NULL) + return NULL; + str = start; + s = fmt; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + goto fail; + str = start + align((int)(str-start), c, e); + if (num == 0 && c != 's') + continue; + + do { + if (c == 'x') { + str += num; + break; + } + if (c == 's') { + /* num is string size, not repeat count */ + v = PyString_FromStringAndSize(str, num); + if (v == NULL) + goto fail; + str += num; + num = 0; + } + else if (c == 'p') { + /* num is string buffer size, + not repeat count */ + int n = *(unsigned char*)str; + /* first byte (unsigned) is string size */ + if (n >= num) + n = num-1; + v = PyString_FromStringAndSize(str+1, n); + if (v == NULL) + goto fail; + str += num; + num = 0; + } + else { + v = e->unpack(str, e); + if (v == NULL) + goto fail; + str += e->size; + } + if (v == NULL || PyList_Append(res, v) < 0) + goto fail; + Py_DECREF(v); + } while (--num > 0); + } + + v = PyList_AsTuple(res); + Py_DECREF(res); + return v; + + fail: + Py_DECREF(res); + return NULL; +} + + +/* List of functions */ + +static PyMethodDef struct_methods[] = { + {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, + {"pack", struct_pack, METH_VARARGS, pack__doc__}, + {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, + {NULL, NULL} /* sentinel */ +}; + + +/* Module initialization */ + +PyMODINIT_FUNC +initstruct(void) +{ + PyObject *m; + + /* Create the module and add the functions */ + m = Py_InitModule4("struct", struct_methods, struct__doc__, + (PyObject*)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; + + /* Add some symbolic constants to the module */ + if (StructError == NULL) { + StructError = PyErr_NewException("struct.error", NULL, NULL); + if (StructError == NULL) + return; + } + Py_INCREF(StructError); + PyModule_AddObject(m, "error", StructError); +} Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Tue May 23 21:09:51 2006 @@ -1444,7 +1444,7 @@ 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('_struct', ['_struct.c'])], + ext_modules=[Extension('struct', ['structmodule.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', From python-checkins at python.org Tue May 23 21:11:35 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:11:35 +0200 (CEST) Subject: [Python-checkins] r46142 - in python/trunk: Misc/NEWS Modules/Setup.dist Modules/structmodule.c setup.py Message-ID: <20060523191135.616381E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:11:34 2006 New Revision: 46142 Modified: python/trunk/Misc/NEWS python/trunk/Modules/Setup.dist python/trunk/Modules/structmodule.c python/trunk/setup.py Log: patch #1493701: performance enhancements for struct module Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue May 23 21:11:34 2006 @@ -45,6 +45,8 @@ Extension Modules ----------------- +- Patch #1493701: performance enhancements for struct module. + - Patch #1490224: time.altzone is now set correctly on Cygwin. - Patch #1435422: zlib's compress and decompress objects now have a Modified: python/trunk/Modules/Setup.dist ============================================================================== --- python/trunk/Modules/Setup.dist (original) +++ python/trunk/Modules/Setup.dist Tue May 23 21:11:34 2006 @@ -167,7 +167,7 @@ #array arraymodule.c # array objects #cmath cmathmodule.c # -lm # complex math library functions #math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking +#_struct _struct.c # binary structure packing/unpacking #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support Modified: python/trunk/Modules/structmodule.c ============================================================================== --- python/trunk/Modules/structmodule.c (original) +++ python/trunk/Modules/structmodule.c Tue May 23 21:11:34 2006 @@ -1,1293 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include - -PyDoc_STRVAR(struct__doc__, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ -\n\ -The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ -\n\ -The remaining chars indicate types of args and must match exactly;\n\ -these can be preceded by a decimal repeat count:\n\ - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ - h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double.\n\ -Special cases (preceding decimal count indicates length):\n\ - s:string (array of char); p: pascal string (with count byte).\n\ -Special case (only available in native format):\n\ - P:an integer type that is wide enough to hold a pointer.\n\ -Special case (not in native mode unless 'long long' in platform C):\n\ - q:long long; Q:unsigned long long\n\ -Whitespace between formats is ignored.\n\ -\n\ -The variable struct.error is an exception raised on errors."); - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsVoidPtr(v); - Py_DECREF(v); - if (x == NULL && PyErr_Occurred()) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -calcsize(const char *fmt, const formatdef *f) -{ - const formatdef *e; - const char *s; - char c; - int size, num, itemsize, x; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - return size; -} - - -PyDoc_STRVAR(calcsize__doc__, -"calcsize(fmt) -> int\n\ -Return size of C struct described by format string fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_calcsize(PyObject *self, PyObject *args) -{ - char *fmt; - const formatdef *f; - int size; - - if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(pack__doc__, -"pack(fmt, v1, v2, ...) -> string\n\ -Return string containing values v1, v2, ... packed according to fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_pack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - PyObject *format, *result, *v; - char *fmt; - int size, num; - Py_ssize_t i, n; - char *s, *res, *restart, *nres; - char c; - - if (args == NULL || !PyTuple_Check(args) || - (n = PyTuple_Size(args)) < 1) - { - PyErr_SetString(PyExc_TypeError, - "struct.pack requires at least one argument"); - return NULL; - } - format = PyTuple_GetItem(args, 0); - fmt = PyString_AsString(format); - if (!fmt) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - result = PyString_FromStringAndSize((char *)NULL, size); - if (result == NULL) - return NULL; - - s = fmt; - i = 1; - res = restart = PyString_AsString(result); - - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - nres = restart + align((int)(res-restart), c, e); - /* Fill padd bytes with zeros */ - while (res < nres) - *res++ = '\0'; - if (num == 0 && c != 's') - continue; - do { - if (c == 'x') { - /* doesn't consume arguments */ - memset(res, '\0', num); - res += num; - break; - } - if (i >= n) { - PyErr_SetString(StructError, - "insufficient arguments to pack"); - goto fail; - } - v = PyTuple_GetItem(args, i++); - if (v == NULL) - goto fail; - if (c == 's') { - /* num is string size, not repeat count */ - Py_ssize_t n; - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res, PyString_AsString(v), n); - if (n < num) - memset(res+n, '\0', num-n); - res += num; - break; - } - else if (c == 'p') { - /* num is string size + 1, - to fit in the count byte */ - Py_ssize_t n; - num--; /* now num is max string size */ - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res+1, PyString_AsString(v), n); - if (n < num) - /* no real need, just to be nice */ - memset(res+1+n, '\0', num-n); - if (n > 255) - n = 255; - /* store the length byte */ - *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); - res += num; - break; - } - else { - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } while (--num > 0); - } - - if (i < n) { - PyErr_SetString(StructError, - "too many arguments for pack format"); - goto fail; - } - - return result; - - fail: - Py_DECREF(result); - return NULL; -} - - -PyDoc_STRVAR(unpack__doc__, -"unpack(fmt, string) -> (v1, v2, ...)\n\ -Unpack the string, containing packed C structure data, according\n\ -to fmt. Requires len(string)==calcsize(fmt).\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_unpack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - char *str, *start, *fmt, *s; - char c; - int len, size, num; - PyObject *res, *v; - - if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - if (size != len) { - PyErr_SetString(StructError, - "unpack str size does not match format"); - return NULL; - } - res = PyList_New(0); - if (res == NULL) - return NULL; - str = start; - s = fmt; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - str = start + align((int)(str-start), c, e); - if (num == 0 && c != 's') - continue; - - do { - if (c == 'x') { - str += num; - break; - } - if (c == 's') { - /* num is string size, not repeat count */ - v = PyString_FromStringAndSize(str, num); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else if (c == 'p') { - /* num is string buffer size, - not repeat count */ - int n = *(unsigned char*)str; - /* first byte (unsigned) is string size */ - if (n >= num) - n = num-1; - v = PyString_FromStringAndSize(str+1, n); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else { - v = e->unpack(str, e); - if (v == NULL) - goto fail; - str += e->size; - } - if (v == NULL || PyList_Append(res, v) < 0) - goto fail; - Py_DECREF(v); - } while (--num > 0); - } - - v = PyList_AsTuple(res); - Py_DECREF(res); - return v; - - fail: - Py_DECREF(res); - return NULL; -} - - -/* List of functions */ - -static PyMethodDef struct_methods[] = { - {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, - {"pack", struct_pack, METH_VARARGS, pack__doc__}, - {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initstruct(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule4("struct", struct_methods, struct__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); -} Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Tue May 23 21:11:34 2006 @@ -1444,7 +1444,7 @@ 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('struct', ['structmodule.c'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', From buildbot at python.org Tue May 23 21:11:47 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:11:47 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20060523191147.93D051E4003@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/754 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito,fredrik.lundh,tim.peters BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Tue May 23 21:12:04 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:12:04 +0200 (CEST) Subject: [Python-checkins] r46143 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20060523191204.4FFB81E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:12:03 2006 New Revision: 46143 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Don't install or update a ``site.py`` patch when installing to a ``PYTHONPATH`` directory with ``--multi-version``, unless an ``easy-install.pth`` file is already in use there. (Bugfix merge from 0.7 trunk) Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Tue May 23 21:12:03 2006 @@ -1111,6 +1111,10 @@ * Ignore bdist_dumb distributions when looking at download URLs. + * Don't install or update a ``site.py`` patch when installing to a + ``PYTHONPATH`` directory with ``--multi-version``, unless an + ``easy-install.pth`` file is already in use there. + 0.6a11 * Process ``dependency_links.txt`` if found in a distribution, by adding the URLs to the list for scanning. Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Tue May 23 21:12:03 2006 @@ -246,7 +246,6 @@ def check_site_dir(self): """Verify that self.install_dir is .pth-capable dir, if needed""" - instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir,'easy-install.pth') @@ -281,10 +280,11 @@ if instdir not in map(normalize_path, filter(None,PYTHONPATH)): # only PYTHONPATH dirs need a site.py, so pretend it's there self.sitepy_installed = True - + elif self.multi_version and not os.path.exists(pth_file): + self.sitepy_installed = True # don't need site.py in this case + self.pth_file = None # and don't create a .pth file self.install_dir = instdir - def cant_write_to_target(self): msg = """can't create or remove files in install directory @@ -572,8 +572,6 @@ - - def install_script(self, dist, script_name, script_text, dev_path=None): """Generate a legacy script wrapper and install it""" spec = str(dist.as_requirement()) From python-checkins at python.org Tue May 23 21:12:41 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:12:41 +0200 (CEST) Subject: [Python-checkins] r46144 - in python/trunk: Lib/struct.py Modules/_struct.c Modules/structmodule.c Message-ID: <20060523191241.B5FEF1E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:12:41 2006 New Revision: 46144 Added: python/trunk/Lib/struct.py (contents, props changed) python/trunk/Modules/_struct.c (contents, props changed) Removed: python/trunk/Modules/structmodule.c Log: patch #1493701: performance enhancements for struct module Added: python/trunk/Lib/struct.py ============================================================================== --- (empty file) +++ python/trunk/Lib/struct.py Tue May 23 21:12:41 2006 @@ -0,0 +1,76 @@ +""" +Functions to convert between Python values and C structs. +Python strings are used to hold the data representing the C struct +and also as format strings to describe the layout of data in the C struct. + +The optional first format char indicates byte order, size and alignment: + @: native order, size & alignment (default) + =: native order, std. size & alignment + <: little-endian, std. size & alignment + >: big-endian, std. size & alignment + !: same as > + +The remaining chars indicate types of args and must match exactly; +these can be preceded by a decimal repeat count: + x: pad byte (no data); c:char; b:signed byte; B:unsigned byte; + h:short; H:unsigned short; i:int; I:unsigned int; + l:long; L:unsigned long; f:float; d:double. +Special cases (preceding decimal count indicates length): + s:string (array of char); p: pascal string (with count byte). +Special case (only available in native format): + P:an integer type that is wide enough to hold a pointer. +Special case (not in native mode unless 'long long' in platform C): + q:long long; Q:unsigned long long +Whitespace between formats is ignored. + +The variable struct.error is an exception raised on errors. +""" +__version__ = '0.1' + +from _struct import Struct, error + +_MAXCACHE = 100 +_cache = {} + +def _compile(fmt): + # Internal: compile struct pattern + if len(_cache) >= _MAXCACHE: + _cache.clear() + s = Struct(fmt) + _cache[fmt] = s + return s + +def calcsize(fmt): + """ + Return size of C struct described by format string fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.size + +def pack(fmt, *args): + """ + Return string containing values v1, v2, ... packed according to fmt. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack(*args) + +def unpack(fmt, s): + """ + Unpack the string, containing packed C structure data, according + to fmt. Requires len(string)==calcsize(fmt). + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack(s) + Added: python/trunk/Modules/_struct.c ============================================================================== --- (empty file) +++ python/trunk/Modules/_struct.c Tue May 23 21:12:41 2006 @@ -0,0 +1,1355 @@ +/* struct module -- pack values into and (out of) strings */ + +/* New version supporting byte order, alignment and size options, + character strings, and unsigned numbers */ + +#include "Python.h" +#include "structseq.h" +#include "structmember.h" +#include + + +/* compatibility macros */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + + + +/* The translation function for each format character is table driven */ + +typedef struct _formatdef { + char format; + int size; + int alignment; + PyObject* (*unpack)(const char *, + const struct _formatdef *); + int (*pack)(char *, PyObject *, + const struct _formatdef *); +} formatdef; + +typedef struct _formatcode { + const struct _formatdef *fmtdef; + int offset; + int repeat; +} formatcode; + +/* Struct object interface */ + +typedef struct { + PyObject_HEAD + int s_size; + int s_len; + formatcode *s_codes; + PyObject *s_format; + PyObject *weakreflist; /* List of weak references */ +} PyStructObject; + +PyAPI_DATA(PyTypeObject) PyStruct_Type; + +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) + + +/* Exception */ + +static PyObject *StructError; + + +/* Define various structs to figure out the alignments of types */ + + +typedef struct { char c; short x; } st_short; +typedef struct { char c; int x; } st_int; +typedef struct { char c; long x; } st_long; +typedef struct { char c; float x; } st_float; +typedef struct { char c; double x; } st_double; +typedef struct { char c; void *x; } st_void_p; + +#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) +#define INT_ALIGN (sizeof(st_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) +#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) +#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) + +/* We can't support q and Q in native mode unless the compiler does; + in std mode, they're 8 bytes on all platforms. */ +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +#define STRINGIFY(x) #x + +#ifdef __powerc +#pragma options align=reset +#endif + +/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ + +static PyObject * +get_pylong(PyObject *v) +{ + PyNumberMethods *m; + + assert(v != NULL); + if (PyInt_Check(v)) + return PyLong_FromLong(PyInt_AS_LONG(v)); + if (PyLong_Check(v)) { + Py_INCREF(v); + return v; + } + m = v->ob_type->tp_as_number; + if (m != NULL && m->nb_long != NULL) { + v = m->nb_long(v); + if (v == NULL) + return NULL; + if (PyLong_Check(v)) + return v; + Py_DECREF(v); + } + PyErr_SetString(StructError, + "cannot convert argument to long"); + return NULL; +} + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x = PyInt_AsLong(v); + if (x == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_SetString(StructError, + "required argument is not an integer"); + return -1; + } + *p = x; + return 0; +} + + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + if (PyLong_Check(v)) { + unsigned long x = PyLong_AsUnsignedLong(v); + if (x == (unsigned long)(-1) && PyErr_Occurred()) + return -1; + *p = x; + return 0; + } + else { + return get_long(v, (long *)p); + } +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsLongLong(v); + Py_DECREF(v); + if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsUnsignedLongLong(v); + Py_DECREF(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/* Floating point helpers */ + +static PyObject * +unpack_float(const char *p, /* start of 4-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack4((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + +static PyObject * +unpack_double(const char *p, /* start of 8-byte string */ + int le) /* true for little-endian, false for big-endian */ +{ + double x; + + x = _PyFloat_Unpack8((unsigned char *)p, le); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble(x); +} + + +/* A large number of small routines follow, with names of the form + + [bln][up]_TYPE + + [bln] distiguishes among big-endian, little-endian and native. + [pu] distiguishes between pack (to struct) and unpack (from struct). + TYPE is one of char, byte, ubyte, etc. +*/ + +/* Native mode routines. ****************************************************/ +/* NOTE: + In all n[up]_ routines handling types larger than 1 byte, there is + *no* guarantee that the p pointer is properly aligned for each type, + therefore memcpy is called. An intermediate variable is used to + compensate for big-endian architectures. + Normally both the intermediate variable and the memcpy call will be + skipped by C optimisation in little-endian architectures (gcc >= 2.91 + does this). */ + +static PyObject * +nu_char(const char *p, const formatdef *f) +{ + return PyString_FromStringAndSize(p, 1); +} + +static PyObject * +nu_byte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(signed char *)p); +} + +static PyObject * +nu_ubyte(const char *p, const formatdef *f) +{ + return PyInt_FromLong((long) *(unsigned char *)p); +} + +static PyObject * +nu_short(const char *p, const formatdef *f) +{ + short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_ushort(const char *p, const formatdef *f) +{ + unsigned short x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_int(const char *p, const formatdef *f) +{ + int x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong((long)x); +} + +static PyObject * +nu_uint(const char *p, const formatdef *f) +{ + unsigned int x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong((unsigned long)x); +} + +static PyObject * +nu_long(const char *p, const formatdef *f) +{ + long x; + memcpy((char *)&x, p, sizeof x); + return PyInt_FromLong(x); +} + +static PyObject * +nu_ulong(const char *p, const formatdef *f) +{ + unsigned long x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLong(x); +} + +/* Native mode doesn't support q or Q unless the platform C supports + long long (or, on Windows, __int64). */ + +#ifdef HAVE_LONG_LONG + +static PyObject * +nu_longlong(const char *p, const formatdef *f) +{ + PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromLongLong(x); +} + +static PyObject * +nu_ulonglong(const char *p, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromUnsignedLongLong(x); +} + +#endif + +static PyObject * +nu_float(const char *p, const formatdef *f) +{ + float x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble((double)x); +} + +static PyObject * +nu_double(const char *p, const formatdef *f) +{ + double x; + memcpy((char *)&x, p, sizeof x); + return PyFloat_FromDouble(x); +} + +static PyObject * +nu_void_p(const char *p, const formatdef *f) +{ + void *x; + memcpy((char *)&x, p, sizeof x); + return PyLong_FromVoidPtr(x); +} + +static int +np_byte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < -128 || x > 127){ + PyErr_SetString(StructError, + "byte format requires -128<=number<=127"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_ubyte(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > 255){ + PyErr_SetString(StructError, + "ubyte format requires 0<=number<=255"); + return -1; + } + *p = (char)x; + return 0; +} + +static int +np_char(char *p, PyObject *v, const formatdef *f) +{ + if (!PyString_Check(v) || PyString_Size(v) != 1) { + PyErr_SetString(StructError, + "char format require string of length 1"); + return -1; + } + *p = *PyString_AsString(v); + return 0; +} + +static int +np_short(char *p, PyObject *v, const formatdef *f) +{ + long x; + short y; + if (get_long(v, &x) < 0) + return -1; + if (x < SHRT_MIN || x > SHRT_MAX){ + PyErr_SetString(StructError, + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); + return -1; + } + y = (short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_ushort(char *p, PyObject *v, const formatdef *f) +{ + long x; + unsigned short y; + if (get_long(v, &x) < 0) + return -1; + if (x < 0 || x > USHRT_MAX){ + PyErr_SetString(StructError, + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + return -1; + } + y = (unsigned short)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int y; + if (get_long(v, &x) < 0) + return -1; + y = (int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + unsigned int y; + if (get_ulong(v, &x) < 0) + return -1; + y = (unsigned int)x; + memcpy(p, (char *)&y, sizeof y); + return 0; +} + +static int +np_long(char *p, PyObject *v, const formatdef *f) +{ + long x; + if (get_long(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulong(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + if (get_ulong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +#ifdef HAVE_LONG_LONG + +static int +np_longlong(char *p, PyObject *v, const formatdef *f) +{ + PY_LONG_LONG x; + if (get_longlong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + unsigned PY_LONG_LONG x; + if (get_ulonglong(v, &x) < 0) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} +#endif + +static int +np_float(char *p, PyObject *v, const formatdef *f) +{ + float x = (float)PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static int +np_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + memcpy(p, (char *)&x, sizeof(double)); + return 0; +} + +static int +np_void_p(char *p, PyObject *v, const formatdef *f) +{ + void *x; + + v = get_pylong(v); + if (v == NULL) + return -1; + assert(PyLong_Check(v)); + x = PyLong_AsVoidPtr(v); + Py_DECREF(v); + if (x == NULL && PyErr_Occurred()) + return -1; + memcpy(p, (char *)&x, sizeof x); + return 0; +} + +static formatdef native_table[] = { + {'x', sizeof(char), 0, NULL}, + {'b', sizeof(char), 0, nu_byte, np_byte}, + {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, + {'c', sizeof(char), 0, nu_char, np_char}, + {'s', sizeof(char), 0, NULL}, + {'p', sizeof(char), 0, NULL}, + {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, + {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, + {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, + {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, + {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, + {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, +#ifdef HAVE_LONG_LONG + {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, +#endif + {0} +}; + +/* Big-endian routines. *****************************************************/ + +static PyObject * +bu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +bu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +bu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +bu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 0, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +bu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 0); +} + +static PyObject * +bu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 0); +} + +static int +bp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + p[--i] = (char)x; + x >>= 8; + } while (i > 0); + return 0; +} + +static int +bp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject *)v, + (unsigned char *)p, + 8, + 0, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +bp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 0); +} + +static int +bp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 0); +} + +static formatdef bigendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, bu_int, bp_int}, + {'B', 1, 0, bu_uint, bp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, bu_int, bp_int}, + {'H', 2, 0, bu_uint, bp_uint}, + {'i', 4, 0, bu_int, bp_int}, + {'I', 4, 0, bu_uint, bp_uint}, + {'l', 4, 0, bu_int, bp_int}, + {'L', 4, 0, bu_uint, bp_uint}, + {'q', 8, 0, bu_longlong, bp_longlong}, + {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, + {'f', 4, 0, bu_float, bp_float}, + {'d', 8, 0, bu_double, bp_double}, + {0} +}; + +/* Little-endian routines. *****************************************************/ + +static PyObject * +lu_int(const char *p, const formatdef *f) +{ + long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG > f->size) + x |= -(x & (1L << (8*f->size - 1))); + return PyInt_FromLong(x); +} + +static PyObject * +lu_uint(const char *p, const formatdef *f) +{ + unsigned long x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + if (f->size >= 4) + return PyLong_FromUnsignedLong(x); + else + return PyInt_FromLong((long)x); +} + +static PyObject * +lu_longlong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 1 /* signed */); +} + +static PyObject * +lu_ulonglong(const char *p, const formatdef *f) +{ + return _PyLong_FromByteArray((const unsigned char *)p, + 8, + 1, /* little-endian */ + 0 /* signed */); +} + +static PyObject * +lu_float(const char *p, const formatdef *f) +{ + return unpack_float(p, 1); +} + +static PyObject * +lu_double(const char *p, const formatdef *f) +{ + return unpack_double(p, 1); +} + +static int +lp_int(char *p, PyObject *v, const formatdef *f) +{ + long x; + int i; + if (get_long(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_uint(char *p, PyObject *v, const formatdef *f) +{ + unsigned long x; + int i; + if (get_ulong(v, &x) < 0) + return -1; + i = f->size; + do { + *p++ = (char)x; + x >>= 8; + } while (--i > 0); + return 0; +} + +static int +lp_longlong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 1 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_ulonglong(char *p, PyObject *v, const formatdef *f) +{ + int res; + v = get_pylong(v); + if (v == NULL) + return -1; + res = _PyLong_AsByteArray((PyLongObject*)v, + (unsigned char *)p, + 8, + 1, /* little_endian */ + 0 /* signed */); + Py_DECREF(v); + return res; +} + +static int +lp_float(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack4(x, (unsigned char *)p, 1); +} + +static int +lp_double(char *p, PyObject *v, const formatdef *f) +{ + double x = PyFloat_AsDouble(v); + if (x == -1 && PyErr_Occurred()) { + PyErr_SetString(StructError, + "required argument is not a float"); + return -1; + } + return _PyFloat_Pack8(x, (unsigned char *)p, 1); +} + +static formatdef lilendian_table[] = { + {'x', 1, 0, NULL}, + {'b', 1, 0, lu_int, lp_int}, + {'B', 1, 0, lu_uint, lp_int}, + {'c', 1, 0, nu_char, np_char}, + {'s', 1, 0, NULL}, + {'p', 1, 0, NULL}, + {'h', 2, 0, lu_int, lp_int}, + {'H', 2, 0, lu_uint, lp_uint}, + {'i', 4, 0, lu_int, lp_int}, + {'I', 4, 0, lu_uint, lp_uint}, + {'l', 4, 0, lu_int, lp_int}, + {'L', 4, 0, lu_uint, lp_uint}, + {'q', 8, 0, lu_longlong, lp_longlong}, + {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, + {'f', 4, 0, lu_float, lp_float}, + {'d', 8, 0, lu_double, lp_double}, + {0} +}; + + +static const formatdef * +whichtable(char **pfmt) +{ + const char *fmt = (*pfmt)++; /* May be backed out of later */ + switch (*fmt) { + case '<': + return lilendian_table; + case '>': + case '!': /* Network byte order is big-endian */ + return bigendian_table; + case '=': { /* Host byte order -- different from native in aligment! */ + int n = 1; + char *p = (char *) &n; + if (*p == 1) + return lilendian_table; + else + return bigendian_table; + } + default: + --*pfmt; /* Back out of pointer increment */ + /* Fall through */ + case '@': + return native_table; + } +} + + +/* Get the table entry for a format code */ + +static const formatdef * +getentry(int c, const formatdef *f) +{ + for (; f->format != '\0'; f++) { + if (f->format == c) { + return f; + } + } + PyErr_SetString(StructError, "bad char in struct format"); + return NULL; +} + + +/* Align a size according to a format code */ + +static int +align(int size, int c, const formatdef *e) +{ + if (e->format == c) { + if (e->alignment) { + size = ((size + e->alignment - 1) + / e->alignment) + * e->alignment; + } + } + return size; +} + + +/* calculate the size of a format string */ + +static int +prepare_s(PyStructObject *self) +{ + const formatdef *f; + const formatdef *e; + formatcode *codes; + + const char *s; + const char *fmt; + char c; + int size, len, numcodes, num, itemsize, x; + + fmt = PyString_AS_STRING(self->s_format); + + f = whichtable((char **)&fmt); + + s = fmt; + size = 0; + len = 0; + numcodes = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') { + x = num*10 + (c - '0'); + if (x/10 != num) { + PyErr_SetString( + StructError, + "overflow in item count"); + return -1; + } + num = x; + } + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + if (e == NULL) + return -1; + + switch (c) { + case 's': /* fall through */ + case 'p': len++; break; + case 'x': break; + default: len += num; break; + } + if (c != 'x') numcodes++; + + itemsize = e->size; + size = align(size, c, e); + x = num * itemsize; + size += x; + if (x/itemsize != num || size < 0) { + PyErr_SetString(StructError, + "total struct size too long"); + return -1; + } + } + + self->s_size = size; + self->s_len = len; + codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + if (codes == NULL) { + PyErr_NoMemory(); + return -1; + } + self->s_codes = codes; + + s = fmt; + size = 0; + while ((c = *s++) != '\0') { + if (isspace(Py_CHARMASK(c))) + continue; + if ('0' <= c && c <= '9') { + num = c - '0'; + while ('0' <= (c = *s++) && c <= '9') + num = num*10 + (c - '0'); + if (c == '\0') + break; + } + else + num = 1; + + e = getentry(c, f); + + size = align(size, c, e); + if (c != 'x') { + codes->offset = size; + codes->repeat = num; + codes->fmtdef = e; + codes++; + } + size += num * e->size; + } + codes->fmtdef = NULL; + codes->offset = -1; + codes->repeat = -1; + + return 0; +} + +static PyObject * +s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + static PyObject *not_yet_string; + + assert(type != NULL && type->tp_alloc != NULL); + + self = type->tp_alloc(type, 0); + if (self != NULL) { + PyStructObject *s = (PyStructObject*)self; + Py_INCREF(Py_None); + s->s_format = Py_None; + s->s_codes = NULL; + s->s_size = -1; + s->s_len = -1; + } + return self; +} + +static int +s_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyStructObject *soself = (PyStructObject *)self; + PyObject *o_format = NULL; + int ret = 0; + static char *kwlist[] = {"format", 0}; + + assert(PyStruct_Check(self)); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, + &o_format)) + return -1; + + Py_INCREF(o_format); + Py_XDECREF(soself->s_format); + soself->s_format = o_format; + + ret = prepare_s(soself); + return ret; +} + +static void +s_dealloc(PyStructObject *s) +{ + int sts = 0; + if (s->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *)s); + if (s->s_codes != NULL) { + PyMem_FREE(s->s_codes); + } + Py_XDECREF(s->s_format); + s->ob_type->tp_free((PyObject *)s); +} + +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See struct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + result = PyTuple_New(soself->s_len); + if (result == NULL) + return NULL; + + + restart = PyString_AS_STRING(inputstr); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + const char *res = restart + code->offset; + if (e->format == 's') { + v = PyString_FromStringAndSize(res, code->repeat); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else if (e->format == 'p') { + n = *(unsigned char*)res; + if (n >= code->repeat) + n = code->repeat - 1; + v = PyString_FromStringAndSize(res + 1, n); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + } else { + for (n = 0; n < code->repeat; n++) { + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); + res += e->size; + } + } + } + + return result; +fail: + Py_DECREF(result); + return NULL; +}; + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See struct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + char *restart; + formatcode *code; + Py_ssize_t i; + + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + restart = PyString_AS_STRING(result); + memset(restart, '\0', soself->s_size); + i = 0; + for (code = soself->s_codes; code->fmtdef != NULL; code++) { + Py_ssize_t n; + PyObject *v; + const formatdef *e = code->fmtdef; + char *res = restart + code->offset; + if (e->format == 's') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 's' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > code->repeat) + n = code->repeat; + if (n > 0) + memcpy(res, PyString_AS_STRING(v), n); + } else if (e->format == 'p') { + v = PyTuple_GET_ITEM(args, i++); + if (!PyString_Check(v)) { + PyErr_SetString(StructError, + "argument for 'p' must be a string"); + goto fail; + } + n = PyString_GET_SIZE(v); + if (n > (code->repeat - 1)) + n = code->repeat - 1; + if (n > 0) + memcpy(res + 1, PyString_AS_STRING(v), n); + if (n > 255) + n = 255; + *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + } else { + for (n = 0; n < code->repeat; n++) { + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; + res += e->size; + } + } + } + + return result; + +fail: + Py_DECREF(result); + return NULL; + +} + + +/* List of functions */ + +static struct PyMethodDef s_methods[] = { + {"pack", s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {NULL, NULL} /* sentinel */ +}; + +PyDoc_STRVAR(s__doc__, "Compiled struct object"); + +#define OFF(x) offsetof(PyStructObject, x) + +static PyMemberDef s_memberlist[] = { + {"format", T_OBJECT, OFF(s_format), RO, + "struct format string"}, + {"size", T_INT, OFF(s_size), RO, + "struct size in bytes"}, + {"_len", T_INT, OFF(s_len), RO, + "number of items expected in tuple"}, + {NULL} /* Sentinel */ +}; + + +static +PyTypeObject PyStructType = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "Struct", + sizeof(PyStructObject), + 0, + (destructor)s_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ + s__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + s_methods, /* tp_methods */ + s_memberlist, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + s_init, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + s_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + +/* Module initialization */ + +PyMODINIT_FUNC +init_struct(void) +{ + PyObject *m = Py_InitModule("_struct", NULL); + if (m == NULL) + return; + + /* Add some symbolic constants to the module */ + if (StructError == NULL) { + StructError = PyErr_NewException("struct.error", NULL, NULL); + if (StructError == NULL) + return; + } + Py_INCREF(StructError); + PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); + PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); +} Deleted: /python/trunk/Modules/structmodule.c ============================================================================== From python-checkins at python.org Tue May 23 21:12:45 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 23 May 2006 21:12:45 +0200 (CEST) Subject: [Python-checkins] r46145 - sandbox/branches/setuptools-0.6/EasyInstall.txt Message-ID: <20060523191245.ED01A1E4003@bag.python.org> Author: phillip.eby Date: Tue May 23 21:12:45 2006 New Revision: 46145 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt Log: Oops; doc needs to go under 0.6b2, not 0.6b1 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Tue May 23 21:12:45 2006 @@ -1095,6 +1095,11 @@ Release Notes/Change History ============================ +0.6b2 + * Don't install or update a ``site.py`` patch when installing to a + ``PYTHONPATH`` directory with ``--multi-version``, unless an + ``easy-install.pth`` file is already in use there. + 0.6b1 * Better ambiguity management: accept ``#egg`` name/version even if processing what appears to be a correctly-named distutils file, and ignore ``.egg`` @@ -1111,10 +1116,6 @@ * Ignore bdist_dumb distributions when looking at download URLs. - * Don't install or update a ``site.py`` patch when installing to a - ``PYTHONPATH`` directory with ``--multi-version``, unless an - ``easy-install.pth`` file is already in use there. - 0.6a11 * Process ``dependency_links.txt`` if found in a distribution, by adding the URLs to the list for scanning. From buildbot at python.org Tue May 23 21:15:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:15:41 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060523191541.3B46C1E4009@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/471 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From amk at amk.ca Tue May 23 21:18:08 2006 From: amk at amk.ca (A.M. Kuchling) Date: Tue, 23 May 2006 15:18:08 -0400 Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060523184426.5EDC41E4009@bag.python.org> References: <20060523184426.5EDC41E4009@bag.python.org> Message-ID: <20060523191808.GA14542@localhost.localdomain> On Tue, May 23, 2006 at 08:44:26PM +0200, fredrik.lundh wrote: > +LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) > +{ > + Py_ssize_t i; > + > + for (i = 0; i < setlen; i++) > + if (set[i] == chr) > + return 1; > + > + return -1; > +} > + > +#define BLOOM_MEMBER(mask, chr, set, setlen)\ > + BLOOM(mask, chr) && unicode_member(chr, set, setlen) unicode_member returns 1 if found, -1 if not; doesn't this mean that the second part of the && in BLOOM_MEMBER() will always be true? --amk From python-checkins at python.org Tue May 23 21:21:01 2006 From: python-checkins at python.org (steve.holden) Date: Tue, 23 May 2006 21:21:01 +0200 (CEST) Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060523192101.43DF31E401A@bag.python.org> Author: steve.holden Date: Tue May 23 21:21:00 2006 New Revision: 46146 Modified: sandbox/trunk/rjsh-pybench/pybench.py Log: Use the appropriate clock for the platform. Default the number of calibration runs to 0 (can set with -C) Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Tue May 23 21:21:00 2006 @@ -56,6 +56,13 @@ except ImportError: import pickle +if sys.platform == "win32": + # On Windows, the best timer is time.clock() + default_timer = time.clock +else: + # On most other platforms the best timer is time.time() + default_timer = time.time + ### Test baseclass class Test: @@ -108,7 +115,7 @@ # Misc. internal variables last_timing = (0,0,0) # last timing (real,run,calibration) warp = 1 # warp factor this test uses - cruns = 20 # number of calibration runs + cruns = 0 # number of calibration runs overhead = None # list of calibration timings def __init__(self,warp=1): @@ -133,16 +140,17 @@ """ test = self.test calibrate = self.calibrate - clock = time.clock + clock = default_timer cruns = self.cruns # first calibrate offset = 0.0 - for i in range(cruns): - t = clock() - calibrate() - t = clock() - t - offset = offset + t - offset = offset / cruns + if cruns: + for i in range(cruns): + t = clock() + calibrate() + t = clock() - t + offset = offset + t + offset = offset / cruns # now the real thing t = clock() test() @@ -211,7 +219,6 @@ roundtime = 0 # Average round time version = None # Benchmark version number (see __init__) # as float x.yy - starttime = None # Benchmark start time def __init__(self): @@ -250,7 +257,6 @@ clock = time.clock print 'Running %i round(s) of the suite: ' % self.rounds print - self.starttime = time.time() roundtime = clock() for i in range(self.rounds): if verbose: @@ -323,7 +329,7 @@ print '-'*77 if compatible and compare_to.roundtime > 0 and \ compare_to.version == self.version: - print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ + print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ ('Notional minimum round time', totalmintime * 1000.0, other_totalmintime * 1000.0, ((totalmintime*self.warp)/ @@ -365,7 +371,8 @@ SwitchOption('--no-gc','disable garbage collection', 0), SwitchOption('--no-syscheck', '"disable" sys check interval (set to sys.maxint)', 0), - ArgumentOption('-t', 'tests containing substring', '') + ArgumentOption('-t', 'tests containing substring', ''), + ArgumentOption('-C', 'number of calibration runs (default 0)', '') ] about = """\ From python-checkins at python.org Tue May 23 21:22:03 2006 From: python-checkins at python.org (steve.holden) Date: Tue, 23 May 2006 21:22:03 +0200 (CEST) Subject: [Python-checkins] r46147 - sandbox/trunk/rjsh-pybench/NewInstances.py sandbox/trunk/rjsh-pybench/Setup.py Message-ID: <20060523192203.BDBDD1E4003@bag.python.org> Author: steve.holden Date: Tue May 23 21:22:03 2006 New Revision: 46147 Added: sandbox/trunk/rjsh-pybench/NewInstances.py (contents, props changed) Modified: sandbox/trunk/rjsh-pybench/Setup.py Log: Add test for new-style instance creation. Added: sandbox/trunk/rjsh-pybench/NewInstances.py ============================================================================== --- (empty file) +++ sandbox/trunk/rjsh-pybench/NewInstances.py Tue May 23 21:22:03 2006 @@ -0,0 +1,66 @@ +from pybench import Test + +class CreateNewInstances(Test): + + version = 0.1 + operations = 3 + 7 + 4 + rounds = 60000 + + def test(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + o = c() + o1 = c() + o2 = c() + p = d(i,i,3) + p1 = d(i,i,3) + p2 = d(i,3,3) + p3 = d(3,i,3) + p4 = d(i,i,i) + p5 = d(3,i,3) + p6 = d(i,i,i) + q = e(i,i,3) + q1 = e(i,i,3) + q2 = e(i,i,3) + q3 = e(i,i) + + def calibrate(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + pass Modified: sandbox/trunk/rjsh-pybench/Setup.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Setup.py (original) +++ sandbox/trunk/rjsh-pybench/Setup.py Tue May 23 21:22:03 2006 @@ -17,11 +17,16 @@ Warp_factor = 20 # Import tests +#from Empty import * from Arithmetic import * from Calls import * from Constructs import * from Lookups import * from Instances import * +try: + from NewInstances import * +except: + print "Cannot test new-style objects" from Lists import * from Tuples import * from Dict import * From guido at python.org Tue May 23 21:22:57 2006 From: guido at python.org (Guido van Rossum) Date: Tue, 23 May 2006 12:22:57 -0700 Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060523184426.5EDC41E4009@bag.python.org> References: <20060523184426.5EDC41E4009@bag.python.org> Message-ID: On 5/23/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Tue May 23 20:44:25 2006 > New Revision: 46132 > > Modified: > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: use append+reverse for rsplit, use "bloom filters" to > speed up splitlines and strip with charsets; etc. rsplit is now as > fast as split in all our tests (reverse takes no time at all), and > splitlines() is nearly as fast as a plain split("\n") in our tests. > and we're not done yet... ;-) Can I just say that you all in Iceland are having waaaaaay too much fun?! Looks like some great stuff is being done. Yay! -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Tue May 23 21:25:52 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:25:52 +0200 (CEST) Subject: [Python-checkins] r46148 - python/trunk/Modules/_struct.c Message-ID: <20060523192552.D5D121E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:25:52 2006 New Revision: 46148 Modified: python/trunk/Modules/_struct.c Log: fix linking issue, warnings, in struct Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Tue May 23 21:25:52 2006 @@ -45,8 +45,6 @@ PyObject *weakreflist; /* List of weak references */ } PyStructObject; -PyAPI_DATA(PyTypeObject) PyStruct_Type; - #define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) #define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) @@ -1063,7 +1061,6 @@ s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *self; - static PyObject *not_yet_string; assert(type != NULL && type->tp_alloc != NULL); @@ -1104,7 +1101,6 @@ static void s_dealloc(PyStructObject *s) { - int sts = 0; if (s->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)s); if (s->s_codes != NULL) { From buildbot at python.org Tue May 23 21:28:18 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:28:18 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060523192818.73CEE1E4022@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/734 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 23 21:28:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:28:59 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060523192859.444241E4009@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/730 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 23 21:29:38 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 21:29:38 +0200 (CEST) Subject: [Python-checkins] r46149 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060523192938.A083B1E4009@bag.python.org> Author: andrew.kuchling Date: Tue May 23 21:29:38 2006 New Revision: 46149 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add two items Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 23 21:29:38 2006 @@ -1137,10 +1137,10 @@ (Implemented by Raymond Hettinger.) \item The speed of some Unicode operations, such as -finding substrings and character map decoding, has been improved. -(Substring search improvements were added by Fredrik Lundh and Andrew -Dalke at the NeedForSpeed sprint. Character map decoding was improved -by Walter D\"orwald.) +finding substrings, string splitting, and character map decoding, has +been improved. (Substring search and splitting improvements were +added by Fredrik Lundh and Andrew Dalke at the NeedForSpeed +sprint. Character map decoding was improved by Walter D\"orwald.) % Patch 1313939 \item The code generator's peephole optimizer now performs @@ -1155,6 +1155,10 @@ and Richard Jones; committed at the NeedForSpeed sprint.) % Patch 876206 +Frame objects are also slightly smaller, which may improve cache locality +and reduce memory usage a bit. (Contributed by Neal Norwitz.) +% Patch 1337051 + \end{itemize} The net result of the 2.5 optimizations is that Python 2.5 runs the From python-checkins at python.org Tue May 23 21:31:23 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:31:23 +0200 (CEST) Subject: [Python-checkins] r46150 - python/trunk/Modules/_struct.c Message-ID: <20060523193123.74F721E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:31:23 2006 New Revision: 46150 Modified: python/trunk/Modules/_struct.c Log: forward declaration for PyStructType Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Tue May 23 21:31:23 2006 @@ -8,6 +8,7 @@ #include "structmember.h" #include +static PyTypeObject PyStructType; /* compatibility macros */ #if (PY_VERSION_HEX < 0x02050000) From python-checkins at python.org Tue May 23 21:32:25 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 23 May 2006 21:32:25 +0200 (CEST) Subject: [Python-checkins] r46151 - python/trunk/Modules/_struct.c Message-ID: <20060523193225.7D4161E4003@bag.python.org> Author: bob.ippolito Date: Tue May 23 21:32:25 2006 New Revision: 46151 Modified: python/trunk/Modules/_struct.c Log: fix typo in _struct Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Tue May 23 21:32:25 2006 @@ -46,8 +46,8 @@ PyObject *weakreflist; /* List of weak references */ } PyStructObject; -#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) -#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType) /* Exception */ From python-checkins at python.org Tue May 23 21:32:36 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 23 May 2006 21:32:36 +0200 (CEST) Subject: [Python-checkins] r46152 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060523193236.280011E4003@bag.python.org> Author: andrew.kuchling Date: Tue May 23 21:32:35 2006 New Revision: 46152 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add item Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue May 23 21:32:35 2006 @@ -1143,6 +1143,11 @@ sprint. Character map decoding was improved by Walter D\"orwald.) % Patch 1313939 +\item The \module{struct} module now compiles structure format +strings into an internal representation and caches this +representation, yielding a 20\% speedup. (Contributed by Bob Ippolito +at the NeedForSpeed sprint.) + \item The code generator's peephole optimizer now performs simple constant folding in expressions. If you write something like \code{a = 2+3}, the code generator will do the arithmetic and produce From mal at egenix.com Tue May 23 21:34:34 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 23 May 2006 21:34:34 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <20060523192101.43DF31E401A@bag.python.org> References: <20060523192101.43DF31E401A@bag.python.org> Message-ID: <447363CA.30604@egenix.com> steve.holden wrote: > Author: steve.holden > Date: Tue May 23 21:21:00 2006 > New Revision: 46146 > > Modified: > sandbox/trunk/rjsh-pybench/pybench.py > Log: > Use the appropriate clock for the platform. > Default the number of calibration runs to 0 (can set with -C) Defaulting to 0 is a bad idea, since you basically turn off calibration altogether. Note that calibration is *very* important so that only the operation itself is timed, not the setup, loop and other logic not related to the test run. > Modified: sandbox/trunk/rjsh-pybench/pybench.py > ============================================================================== > --- sandbox/trunk/rjsh-pybench/pybench.py (original) > +++ sandbox/trunk/rjsh-pybench/pybench.py Tue May 23 21:21:00 2006 > @@ -56,6 +56,13 @@ > except ImportError: > import pickle > > +if sys.platform == "win32": > + # On Windows, the best timer is time.clock() > + default_timer = time.clock > +else: > + # On most other platforms the best timer is time.time() > + default_timer = time.time > + > ### Test baseclass > > class Test: > @@ -108,7 +115,7 @@ > # Misc. internal variables > last_timing = (0,0,0) # last timing (real,run,calibration) > warp = 1 # warp factor this test uses > - cruns = 20 # number of calibration runs > + cruns = 0 # number of calibration runs > overhead = None # list of calibration timings > > def __init__(self,warp=1): > @@ -133,16 +140,17 @@ > """ > test = self.test > calibrate = self.calibrate > - clock = time.clock > + clock = default_timer > cruns = self.cruns > # first calibrate > offset = 0.0 > - for i in range(cruns): > - t = clock() > - calibrate() > - t = clock() - t > - offset = offset + t > - offset = offset / cruns > + if cruns: > + for i in range(cruns): > + t = clock() > + calibrate() > + t = clock() - t > + offset = offset + t > + offset = offset / cruns > # now the real thing > t = clock() > test() > @@ -211,7 +219,6 @@ > roundtime = 0 # Average round time > version = None # Benchmark version number (see __init__) > # as float x.yy > - starttime = None # Benchmark start time > > def __init__(self): > > @@ -250,7 +257,6 @@ > clock = time.clock > print 'Running %i round(s) of the suite: ' % self.rounds > print > - self.starttime = time.time() > roundtime = clock() > for i in range(self.rounds): > if verbose: > @@ -323,7 +329,7 @@ > print '-'*77 > if compatible and compare_to.roundtime > 0 and \ > compare_to.version == self.version: > - print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ > + print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ > ('Notional minimum round time', totalmintime * 1000.0, > other_totalmintime * 1000.0, > ((totalmintime*self.warp)/ > @@ -365,7 +371,8 @@ > SwitchOption('--no-gc','disable garbage collection', 0), > SwitchOption('--no-syscheck', > '"disable" sys check interval (set to sys.maxint)', 0), > - ArgumentOption('-t', 'tests containing substring', '') > + ArgumentOption('-t', 'tests containing substring', ''), > + ArgumentOption('-C', 'number of calibration runs (default 0)', '') > ] > > about = """\ > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 23 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Tue May 23 21:34:37 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 21:34:37 +0200 (CEST) Subject: [Python-checkins] r46153 - in python/trunk: PC/config.c PCbuild/pythoncore.vcproj Message-ID: <20060523193437.D37351E4003@bag.python.org> Author: tim.peters Date: Tue May 23 21:34:37 2006 New Revision: 46153 Modified: python/trunk/PC/config.c python/trunk/PCbuild/pythoncore.vcproj Log: Get the Windows build working again (recover from `struct` module changes). Modified: python/trunk/PC/config.c ============================================================================== --- python/trunk/PC/config.c (original) +++ python/trunk/PC/config.c Tue May 23 21:34:37 2006 @@ -28,7 +28,6 @@ extern void init_sha256(void); extern void init_sha512(void); extern void initstrop(void); -extern void initstruct(void); extern void inittime(void); extern void initthread(void); extern void initcStringIO(void); @@ -53,6 +52,7 @@ extern void init_sre(void); extern void initparser(void); extern void init_winreg(void); +extern void init_struct(void); extern void initdatetime(void); extern void initfunctional(void); extern void initzlib(void); @@ -102,7 +102,6 @@ {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"strop", initstrop}, - {"struct", initstruct}, {"time", inittime}, #ifdef WITH_THREAD {"thread", initthread}, @@ -131,6 +130,7 @@ {"_sre", init_sre}, {"parser", initparser}, {"_winreg", init_winreg}, + {"_struct", init_struct}, {"datetime", initdatetime}, {"functional", initfunctional}, Modified: python/trunk/PCbuild/pythoncore.vcproj ============================================================================== --- python/trunk/PCbuild/pythoncore.vcproj (original) +++ python/trunk/PCbuild/pythoncore.vcproj Tue May 23 21:34:37 2006 @@ -344,6 +344,9 @@ RelativePath="..\Modules\_bisectmodule.c"> + + - - Author: bob.ippolito Date: Tue May 23 21:39:01 2006 New Revision: 46154 Modified: sandbox/trunk/newstruct/Modules/_newstruct.c Log: bring back fixes Modified: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- sandbox/trunk/newstruct/Modules/_newstruct.c (original) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Tue May 23 21:39:01 2006 @@ -8,6 +8,7 @@ #include "structmember.h" #include +static PyTypeObject PyStructType; /* compatibility macros */ #if (PY_VERSION_HEX < 0x02050000) @@ -45,10 +46,9 @@ PyObject *weakreflist; /* List of weak references */ } PyStructObject; -PyAPI_DATA(PyTypeObject) PyStruct_Type; -#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStruct_Type) -#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStruct_Type) +#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType) +#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType) /* Exception */ @@ -1063,7 +1063,6 @@ s_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *self; - static PyObject *not_yet_string; assert(type != NULL && type->tp_alloc != NULL); @@ -1104,7 +1103,6 @@ static void s_dealloc(PyStructObject *s) { - int sts = 0; if (s->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)s); if (s->s_codes != NULL) { @@ -1352,4 +1350,4 @@ PyModule_AddObject(m, "error", StructError); Py_INCREF((PyObject*)&PyStructType); PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); -} \ No newline at end of file +} From fredrik at pythonware.com Tue May 23 21:46:53 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 23 May 2006 21:46:53 +0200 Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060523191808.GA14542@localhost.localdomain> References: <20060523184426.5EDC41E4009@bag.python.org> <20060523191808.GA14542@localhost.localdomain> Message-ID: A.M. Kuchling wrote: >> +#define BLOOM_MEMBER(mask, chr, set, setlen)\ >> + BLOOM(mask, chr) && unicode_member(chr, set, setlen) > > unicode_member returns 1 if found, -1 if not; doesn't this mean that > the second part of the && in BLOOM_MEMBER() will always be true? oops: unfortunately, the test suite didn't catch this. thanks /F From python-checkins at python.org Tue May 23 21:47:36 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 23 May 2006 21:47:36 +0200 (CEST) Subject: [Python-checkins] r46155 - python/trunk/Objects/unicodeobject.c Message-ID: <20060523194736.335AA1E4019@bag.python.org> Author: fredrik.lundh Date: Tue May 23 21:47:35 2006 New Revision: 46155 Modified: python/trunk/Objects/unicodeobject.c Log: return 0 on misses, not -1. Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Tue May 23 21:47:35 2006 @@ -172,7 +172,7 @@ if (set[i] == chr) return 1; - return -1; + return 0; } #define BLOOM_MEMBER(mask, chr, set, setlen)\ From buildbot at python.org Tue May 23 21:53:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:53:27 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060523195327.2CBD21E4003@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/511 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 23 21:56:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 19:56:22 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060523195622.3DE3A1E4003@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/168 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: richard.jones Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Tue May 23 22:02:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 20:02:00 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060523200200.5EBC71E4003@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/413 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito,fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From neal at metaslash.com Tue May 23 23:06:59 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 23 May 2006 17:06:59 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060523210659.GA5150@python.psfb.org> test_cmd_line leaked [0, 0, 17] references test_filecmp leaked [0, 0, 13] references test_struct leaked [-231, 129, 51] references test_threading_local leaked [-91, 0, 0] references test_urllib2 leaked [143, -110, -33] references From python-checkins at python.org Tue May 23 23:51:36 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 23:51:36 +0200 (CEST) Subject: [Python-checkins] r46156 - python/trunk/Lib/test/regrtest.py Message-ID: <20060523215136.319EE1E4009@bag.python.org> Author: tim.peters Date: Tue May 23 23:51:35 2006 New Revision: 46156 Modified: python/trunk/Lib/test/regrtest.py Log: test_struct grew weird behavior under regrtest.py -R, due to a module-level cache. Clearing the cache should make it stop showing up in refleak reports. Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Tue May 23 23:51:35 2006 @@ -545,6 +545,7 @@ def cleanup(): import _strptime, linecache, warnings, dircache import urlparse, urllib, urllib2, mimetypes, doctest + import struct from distutils.dir_util import _path_created _path_created.clear() warnings.filters[:] = fs @@ -561,6 +562,7 @@ dircache.reset() linecache.clearcache() mimetypes._default_mime_types() + struct._cache.clear() doctest.master = None if indirect_test: def run_the_test(): From python-checkins at python.org Tue May 23 23:54:24 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 23:54:24 +0200 (CEST) Subject: [Python-checkins] r46157 - in python/trunk: Lib/distutils/unixccompiler.py Lib/distutils/util.py Lib/struct.py Mac/OSX/BuildScript/build-installer.py Message-ID: <20060523215424.1E1A91E4009@bag.python.org> Author: tim.peters Date: Tue May 23 23:54:23 2006 New Revision: 46157 Modified: python/trunk/Lib/distutils/unixccompiler.py python/trunk/Lib/distutils/util.py python/trunk/Lib/struct.py python/trunk/Mac/OSX/BuildScript/build-installer.py Log: Whitespace normalization. Modified: python/trunk/Lib/distutils/unixccompiler.py ============================================================================== --- python/trunk/Lib/distutils/unixccompiler.py (original) +++ python/trunk/Lib/distutils/unixccompiler.py Tue May 23 23:54:23 2006 @@ -220,7 +220,7 @@ # skip over environment variable settings if /usr/bin/env # is used to set up the linker's environment. # This is needed on OSX. Note: this assumes that the - # normal and C++ compiler have the same environment + # normal and C++ compiler have the same environment # settings. i = 0 if os.path.basename(linker[0]) == "env": Modified: python/trunk/Lib/distutils/util.py ============================================================================== --- python/trunk/Lib/distutils/util.py (original) +++ python/trunk/Lib/distutils/util.py Tue May 23 23:54:23 2006 @@ -69,10 +69,10 @@ release = m.group() elif osname[:6] == "darwin": # - # For our purposes, we'll assume that the system version from - # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set # to. This makes the compatibility story a bit more sane because the - # machine is going to compile and link as if it were + # machine is going to compile and link as if it were # MACOSX_DEPLOYMENT_TARGET. from distutils.sysconfig import get_config_vars cfgvars = get_config_vars() @@ -97,7 +97,7 @@ r'(.*?)', f.read()) f.close() if m is not None: - macver = '.'.join(m.group(1).split('.')[:2]) + macver = '.'.join(m.group(1).split('.')[:2]) # else: fall back to the default behaviour if macver: Modified: python/trunk/Lib/struct.py ============================================================================== --- python/trunk/Lib/struct.py (original) +++ python/trunk/Lib/struct.py Tue May 23 23:54:23 2006 @@ -50,7 +50,7 @@ except KeyError: o = _compile(fmt) return o.size - + def pack(fmt, *args): """ Return string containing values v1, v2, ... packed according to fmt. @@ -73,4 +73,3 @@ except KeyError: o = _compile(fmt) return o.unpack(s) - Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py ============================================================================== --- python/trunk/Mac/OSX/BuildScript/build-installer.py (original) +++ python/trunk/Mac/OSX/BuildScript/build-installer.py Tue May 23 23:54:23 2006 @@ -1,1013 +1,1013 @@ -#!/usr/bin/python2.3 -""" -This script is used to build the "official unofficial" universal build on -Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its -work. - -Please ensure that this script keeps working with Python 2.3, to avoid -bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) - -Usage: see USAGE variable in the script. -""" -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd - -INCLUDE_TIMESTAMP=1 -VERBOSE=1 - -from plistlib import Plist - -import MacOS -import Carbon.File -import Carbon.Icn -import Carbon.Res -from Carbon.Files import kCustomIconResource, fsRdWrPerm, kHasCustomIcon -from Carbon.Files import kFSCatInfoFinderInfo - -try: - from plistlib import writePlist -except ImportError: - # We're run using python2.3 - def writePlist(plist, path): - plist.write(path) - -def shellQuote(value): - """ - Return the string value in a form that can savely be inserted into - a shell command. - """ - return "'%s'"%(value.replace("'", "'\"'\"'")) - -def grepValue(fn, variable): - variable = variable + '=' - for ln in open(fn, 'r'): - if ln.startswith(variable): - value = ln[len(variable):].strip() - return value[1:-1] - -def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') - -def getFullVersion(): - fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') - for ln in open(fn): - if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - - raise RuntimeError, "Cannot find full version??" - -# The directory we'll use to create the build, will be erased and recreated -WORKDIR="/tmp/_py" - -# The directory we'll use to store third-party sources, set this to something -# else if you don't want to re-fetch required libraries every time. -DEPSRC=os.path.join(WORKDIR, 'third-party') -DEPSRC=os.path.expanduser('~/Universal/other-sources') - -# Location of the preferred SDK -SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" -#SDKPATH="/" - -# Source directory (asume we're in Mac/OSX/Dist) -SRCDIR=os.path.dirname( - os.path.dirname( - os.path.dirname( - os.path.dirname( - os.path.abspath(__file__ - ))))) - -USAGE=textwrap.dedent("""\ - Usage: build_python [options] - - Options: - -? or -h: Show this message - -b DIR - --build-dir=DIR: Create build here (default: %(WORKDIR)r) - --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) - --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) - --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) -""")% globals() - - -# Instructions for building libraries that are necessary for building a -# batteries included python. -LIBRARY_RECIPES=[ - dict( - # Note that GNU readline is GPL'd software - name="GNU Readline 5.1.4", - url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" , - patchlevel='0', - patches=[ - # The readline maintainers don't do actual micro releases, but - # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004', - ] - ), - - dict( - name="SQLite 3.3.5", - url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", - checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', - configure_pre=[ - '--enable-threadsafe', - '--enable-tempstore', - '--enable-shared=no', - '--enable-static=yes', - '--disable-tcl', - ] - ), - - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - configure_pre=[ - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), - dict( - name="Sleepycat DB 4.4", - url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", - #name="Sleepycat DB 4.3.29", - #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", - buildDir="build_unix", - configure="../dist/configure", - configure_pre=[ - '--includedir=/usr/local/include/db4', - ] - ), -] - - -# Instructions for building packages inside the .mpkg. -PKG_RECIPES=[ - dict( - name="PythonFramework", - long_name="Python Framework", - source="/Library/Frameworks/Python.framework", - readme="""\ - This package installs Python.framework, that is the python - interpreter and the standard library. This also includes Python - wrappers for lots of Mac OS X API's. - """, - postflight="scripts/postflight.framework", - ), - dict( - name="PythonApplications", - long_name="GUI Applications", - source="/Applications/MacPython %(VER)s", - readme="""\ - This package installs Python.framework, that is the python - interpreter and the standard library. This also includes Python - wrappers for lots of Mac OS X API's. - """, - required=False, - ), - dict( - name="PythonUnixTools", - long_name="UNIX command-line tools", - source="/usr/local/bin", - readme="""\ - This package installs the unix tools in /usr/local/bin for - compatibility with older releases of MacPython. This package - is not necessary to use MacPython. - """, - required=False, - ), - dict( - name="PythonDocumentation", - long_name="Python Documentation", - topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", - source="/pydocs", - readme="""\ - This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python - """, - postflight="scripts/postflight.documentation", - required=False, - ), - dict( - name="PythonProfileChanges", - long_name="Shell profile updater", - readme="""\ - This packages updates your shell profile to make sure that - the MacPython tools are found by your shell in preference of - the system provided Python tools. - - If you don't install this package you'll have to add - "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" - to your PATH by hand. - """, - postflight="scripts/postflight.patch-profile", - topdir="/Library/Frameworks/Python.framework", - source="/empty-dir", - required=False, - ), -] - - -def fatal(msg): - """ - A fatal error, bail out. - """ - sys.stderr.write('FATAL: ') - sys.stderr.write(msg) - sys.stderr.write('\n') - sys.exit(1) - -def fileContents(fn): - """ - Return the contents of the named file - """ - return open(fn, 'rb').read() - -def runCommand(commandline): - """ - Run a command and raise RuntimeError if it fails. Output is surpressed - unless the command fails. - """ - fd = os.popen(commandline, 'r') - data = fd.read() - xit = fd.close() - if xit != None: - sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) - - if VERBOSE: - sys.stdout.write(data); sys.stdout.flush() - -def captureCommand(commandline): - fd = os.popen(commandline, 'r') - data = fd.read() - xit = fd.close() - if xit != None: - sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) - - return data - -def checkEnvironment(): - """ - Check that we're running on a supported system. - """ - - if platform.system() != 'Darwin': - fatal("This script should be run on a Mac OS X 10.4 system") - - if platform.release() <= '8.': - fatal("This script should be run on a Mac OS X 10.4 system") - - if not os.path.exists(SDKPATH): - fatal("Please install the latest version of Xcode and the %s SDK"%( - os.path.basename(SDKPATH[:-4]))) - - - -def parseOptions(args = None): - """ - Parse arguments and update global settings. - """ - global WORKDIR, DEPSRC, SDKPATH, SRCDIR - - if args is None: - args = sys.argv[1:] - - try: - options, args = getopt.getopt(args, '?hb', - [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) - except getopt.error, msg: - print msg - sys.exit(1) - - if args: - print "Additional arguments" - sys.exit(1) - - for k, v in options: - if k in ('-h', '-?'): - print USAGE - sys.exit(0) - - elif k in ('-d', '--build-dir'): - WORKDIR=v - - elif k in ('--third-party',): - DEPSRC=v - - elif k in ('--sdk-path',): - SDKPATH=v - - elif k in ('--src-dir',): - SRCDIR=v - - else: - raise NotImplementedError, k - - SRCDIR=os.path.abspath(SRCDIR) - WORKDIR=os.path.abspath(WORKDIR) - SDKPATH=os.path.abspath(SDKPATH) - DEPSRC=os.path.abspath(DEPSRC) - - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * third-party source:", DEPSRC - print "" - - - - -def extractArchive(builddir, archiveName): - """ - Extract a source archive into 'builddir'. Returns the path of the - extracted archive. - - XXX: This function assumes that archives contain a toplevel directory - that is has the same name as the basename of the archive. This is - save enough for anything we use. - """ - curdir = os.getcwd() - try: - os.chdir(builddir) - if archiveName.endswith('.tar.gz'): - retval = os.path.basename(archiveName[:-7]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.tar.bz2'): - retval = os.path.basename(archiveName[:-8]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.tar'): - retval = os.path.basename(archiveName[:-4]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.zip'): - retval = os.path.basename(archiveName[:-4]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') - - data = fp.read() - xit = fp.close() - if xit is not None: - sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) - - return os.path.join(builddir, retval) - - finally: - os.chdir(curdir) - -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - -def downloadURL(url, fname): - """ - Download the contents of the url into the file. - """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) - fpOut = open(fname, 'wb') - block = fpIn.read(10240) - try: - while block: - fpOut.write(block) - block = fpIn.read(10240) - fpIn.close() - fpOut.close() - except: - try: - os.unlink(fname) - except: - pass - -def buildRecipe(recipe, basedir, archList): - """ - Build software using a recipe. This function does the - 'configure;make;make install' dance for C software, with a possibility - to customize this process, basically a poor-mans DarwinPorts. - """ - curdir = os.getcwd() - - name = recipe['name'] - url = recipe['url'] - configure = recipe.get('configure', './configure') - install = recipe.get('install', 'make && make install DESTDIR=%s'%( - shellQuote(basedir))) - - archiveName = os.path.split(url)[-1] - sourceArchive = os.path.join(DEPSRC, archiveName) - - if not os.path.exists(DEPSRC): - os.mkdir(DEPSRC) - - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) - buildDir=os.path.join(WORKDIR, '_bld') - if not os.path.exists(buildDir): - os.mkdir(buildDir) - - workDir = extractArchive(buildDir, sourceArchive) - os.chdir(workDir) - if 'buildDir' in recipe: - os.chdir(recipe['buildDir']) - - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) - runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), - shellQuote(fn),)) - - configure_args = [ - "--prefix=/usr/local", - "--enable-static", - "--disable-shared", - #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), - ] - - if 'configure_pre' in recipe: - args = list(recipe['configure_pre']) - if '--disable-static' in args: - configure_args.remove('--enable-static') - if '--enable-shared' in args: - configure_args.remove('--disable-shared') - configure_args.extend(args) - - if recipe.get('useLDFlags', 1): - configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( - ' -arch '.join(archList), - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1], - ' -arch '.join(archList)), - ]) - else: - configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( - ' -arch '.join(archList), - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1],), - ]) - - if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) - - configure_args.insert(0, configure) - configure_args = [ shellQuote(a) for a in configure_args ] - - print "Running configure for %s"%(name,) - runCommand(' '.join(configure_args) + ' 2>&1') - - print "Running install for %s"%(name,) - runCommand('{ ' + install + ' ;} 2>&1') - - print "Done %s"%(name,) - print "" - - os.chdir(curdir) - -def buildLibraries(): - """ - Build our dependencies into $WORKDIR/libraries/usr/local - """ - print "" - print "Building required libraries" - print "" - universal = os.path.join(WORKDIR, 'libraries') - os.mkdir(universal) - os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) - os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) - - for recipe in LIBRARY_RECIPES: - buildRecipe(recipe, universal, ('i386', 'ppc',)) - - - -def buildPythonDocs(): - # This stores the documentation as Resources/English.lproj/Docuentation - # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" - rootDir = os.path.join(WORKDIR, '_root') - version = getVersion() - docdir = os.path.join(rootDir, 'pydocs') - - name = 'html-%s.tar.bz2'%(getFullVersion(),) - sourceArchive = os.path.join(DEPSRC, name) - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Downloading %s"%(name,) - downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( - getFullVersion(), name), sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - extractArchive(os.path.dirname(docdir), sourceArchive) - os.rename( - os.path.join( - os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), - docdir) - - -def buildPython(): - print "Building a universal python" - - buildDir = os.path.join(WORKDIR, '_bld', 'python') - rootDir = os.path.join(WORKDIR, '_root') - - if os.path.exists(buildDir): - shutil.rmtree(buildDir) - if os.path.exists(rootDir): - shutil.rmtree(rootDir) - os.mkdir(buildDir) - os.mkdir(rootDir) - os.mkdir(os.path.join(rootDir, 'empty-dir')) - curdir = os.getcwd() - os.chdir(buildDir) - - # Not sure if this is still needed, the original build script - # claims that parts of the install assume python.exe exists. - os.symlink('python', os.path.join(buildDir, 'python.exe')) - - # Extract the version from the configure file, needed to calculate - # several paths. - version = getVersion() - - print "Running configure..." - runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( - shellQuote(os.path.join(SRCDIR, 'configure')), - shellQuote(SDKPATH), shellQuote(WORKDIR), - shellQuote(WORKDIR))) - - print "Running make" - runCommand("make") - - print "Runing make frameworkinstall" - runCommand("make frameworkinstall DESTDIR=%s"%( - shellQuote(rootDir))) - - print "Runing make frameworkinstallextras" - runCommand("make frameworkinstallextras DESTDIR=%s"%( - shellQuote(rootDir))) - - print "Copy required shared libraries" - if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): - runCommand("mv %s/* %s"%( - shellQuote(os.path.join( - WORKDIR, 'libraries', 'Library', 'Frameworks', - 'Python.framework', 'Versions', getVersion(), - 'lib')), - shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', - 'Python.framework', 'Versions', getVersion(), - 'lib')))) - - print "Fix file modes" - frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') - for dirpath, dirnames, filenames in os.walk(frmDir): - for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) - - for fn in filenames: - if os.path.islink(fn): - continue - - # "chmod g+w $fn" - p = os.path.join(dirpath, fn) - st = os.stat(p) - os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) - - # We added some directories to the search path during the configure - # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config', 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() - - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() - - # Add symlinks in /usr/local/bin, using relative links - usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') - to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', - 'Python.framework', 'Versions', version, 'bin') - if os.path.exists(usr_local_bin): - shutil.rmtree(usr_local_bin) - os.makedirs(usr_local_bin) - for fn in os.listdir( - os.path.join(frmDir, 'Versions', version, 'bin')): - os.symlink(os.path.join(to_framework, fn), - os.path.join(usr_local_bin, fn)) - - os.chdir(curdir) - - - -def patchFile(inPath, outPath): - data = fileContents(inPath) - data = data.replace('$FULL_VERSION', getFullVersion()) - data = data.replace('$VERSION', getVersion()) - data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') - data = data.replace('$ARCHITECTURES', "i386, ppc") - data = data.replace('$INSTALL_SIZE', installSize()) - fp = open(outPath, 'wb') - fp.write(data) - fp.close() - -def patchScript(inPath, outPath): - data = fileContents(inPath) - data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') - fp.write(data) - fp.close() - os.chmod(outPath, 0755) - - - -def packageFromRecipe(targetDir, recipe): - curdir = os.getcwd() - try: - pkgname = recipe['name'] - srcdir = recipe.get('source') - pkgroot = recipe.get('topdir', srcdir) - postflight = recipe.get('postflight') - readme = textwrap.dedent(recipe['readme']) - isRequired = recipe.get('required', True) - - print "- building package %s"%(pkgname,) - - # Substitute some variables - textvars = dict( - VER=getVersion(), - FULLVER=getFullVersion(), - ) - readme = readme % textvars - - if pkgroot is not None: - pkgroot = pkgroot % textvars - else: - pkgroot = '/' - - if srcdir is not None: - srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) - srcdir = srcdir % textvars - - if postflight is not None: - postflight = os.path.abspath(postflight) - - packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') - os.makedirs(packageContents) - - if srcdir is not None: - os.chdir(srcdir) - runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) - runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) - runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) - - fn = os.path.join(packageContents, 'PkgInfo') - fp = open(fn, 'w') - fp.write('pmkrpkg1') - fp.close() - - rsrcDir = os.path.join(packageContents, "Resources") - os.mkdir(rsrcDir) - fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') - fp.write(readme) - fp.close() - - if postflight is not None: - patchScript(postflight, os.path.join(rsrcDir, 'postflight')) - - vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) - pl = Plist( - CFBundleGetInfoString="MacPython.%s %s"%(pkgname, vers,), - CFBundleIdentifier='org.python.MacPython.%s'%(pkgname,), - CFBundleName='MacPython.%s'%(pkgname,), - CFBundleShortVersionString=vers, - IFMajorVersion=major, - IFMinorVersion=minor, - IFPkgFormatVersion=0.10000000149011612, - IFPkgFlagAllowBackRev=False, - IFPkgFlagAuthorizationAction="RootAuthorization", - IFPkgFlagDefaultLocation=pkgroot, - IFPkgFlagFollowLinks=True, - IFPkgFlagInstallFat=True, - IFPkgFlagIsRequired=isRequired, - IFPkgFlagOverwritePermissions=False, - IFPkgFlagRelocatable=False, - IFPkgFlagRestartAction="NoRestart", - IFPkgFlagRootVolumeOnly=True, - IFPkgFlagUpdateInstalledLangauges=False, - ) - writePlist(pl, os.path.join(packageContents, 'Info.plist')) - - pl = Plist( - IFPkgDescriptionDescription=readme, - IFPkgDescriptionTitle=recipe.get('long_name', "MacPython.%s"%(pkgname,)), - IFPkgDescriptionVersion=vers, - ) - writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) - - finally: - os.chdir(curdir) - - -def makeMpkgPlist(path): - - vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) - - pl = Plist( - CFBundleGetInfoString="MacPython %s"%(vers,), - CFBundleIdentifier='org.python.MacPython', - CFBundleName='MacPython', - CFBundleShortVersionString=vers, - IFMajorVersion=major, - IFMinorVersion=minor, - IFPkgFlagComponentDirectory="Contents/Packages", - IFPkgFlagPackageList=[ - dict( - IFPkgFlagPackageLocation='%s.pkg'%(item['name']), - IFPkgFlagPackageSelection='selected' - ) - for item in PKG_RECIPES - ], - IFPkgFormatVersion=0.10000000149011612, - IFPkgFlagBackgroundScaling="proportional", - IFPkgFlagBackgroundAlignment="left", - ) - - writePlist(pl, path) - - -def buildInstaller(): - - # Zap all compiled files - for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): - for fn in filenames: - if fn.endswith('.pyc') or fn.endswith('.pyo'): - os.unlink(os.path.join(dirpath, fn)) - - outdir = os.path.join(WORKDIR, 'installer') - if os.path.exists(outdir): - shutil.rmtree(outdir) - os.mkdir(outdir) - - pkgroot = os.path.join(outdir, 'MacPython.mpkg', 'Contents') - pkgcontents = os.path.join(pkgroot, 'Packages') - os.makedirs(pkgcontents) - for recipe in PKG_RECIPES: - packageFromRecipe(pkgcontents, recipe) - - rsrcDir = os.path.join(pkgroot, 'Resources') - - fn = os.path.join(pkgroot, 'PkgInfo') - fp = open(fn, 'w') - fp.write('pmkrpkg1') - fp.close() - - os.mkdir(rsrcDir) - - makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) - pl = Plist( - IFPkgDescriptionTitle="Universal MacPython", - IFPkgDescriptionVersion=getVersion(), - ) - - writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) - for fn in os.listdir('resources'): - if fn.endswith('.jpg'): - shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) - else: - patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) - - shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt')) - - -def installSize(clear=False, _saved=[]): - if clear: - del _saved[:] - if not _saved: - data = captureCommand("du -ks %s"%( - shellQuote(os.path.join(WORKDIR, '_root')))) - _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) - return _saved[0] - - -def buildDMG(): - """ - Create DMG containing the rootDir - """ - outdir = os.path.join(WORKDIR, 'diskimage') - if os.path.exists(outdir): - shutil.rmtree(outdir) - - imagepath = os.path.join(outdir, - 'python-%s-macosx'%(getFullVersion(),)) - if INCLUDE_TIMESTAMP: - imagepath = imagepath + '%04d-%02d-%02d'%(time.localtime()[:3]) - imagepath = imagepath + '.dmg' - - os.mkdir(outdir) - runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( - getFullVersion(), - shellQuote(os.path.join(WORKDIR, 'installer')), - shellQuote(imagepath))) - - return imagepath - - -def setIcon(filePath, icnsPath): - """ - Set the custom icon for the specified file or directory. - - For a directory the icon data is written in a file named 'Icon\r' inside - the directory. For both files and directories write the icon as an 'icns' - resource. Furthermore set kHasCustomIcon in the finder flags for filePath. - """ - ref, isDirectory = Carbon.File.FSPathMakeRef(icnsPath) - icon = Carbon.Icn.ReadIconFile(ref) - del ref - - # - # Open the resource fork of the target, to add the icon later on. - # For directories we use the file 'Icon\r' inside the directory. - # - - ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) - - if isDirectory: - tmpPath = os.path.join(filePath, "Icon\r") - if not os.path.exists(tmpPath): - fp = open(tmpPath, 'w') - fp.close() - - tmpRef, _ = Carbon.File.FSPathMakeRef(tmpPath) - spec = Carbon.File.FSSpec(tmpRef) - - else: - spec = Carbon.File.FSSpec(ref) - - try: - Carbon.Res.HCreateResFile(*spec.as_tuple()) - except MacOS.Error: - pass - - # Try to create the resource fork again, this will avoid problems - # when adding an icon to a directory. I have no idea why this helps, - # but without this adding the icon to a directory will fail sometimes. - try: - Carbon.Res.HCreateResFile(*spec.as_tuple()) - except MacOS.Error: - pass - - refNum = Carbon.Res.FSpOpenResFile(spec, fsRdWrPerm) - - Carbon.Res.UseResFile(refNum) - - # Check if there already is an icon, remove it if there is. - try: - h = Carbon.Res.Get1Resource('icns', kCustomIconResource) - except MacOS.Error: - pass - - else: - h.RemoveResource() - del h - - # Add the icon to the resource for of the target - res = Carbon.Res.Resource(icon) - res.AddResource('icns', kCustomIconResource, '') - res.WriteResource() - res.DetachResource() - Carbon.Res.CloseResFile(refNum) - - # And now set the kHasCustomIcon property for the target. Annoyingly, - # python doesn't seem to have bindings for the API that is needed for - # this. Cop out and call SetFile - os.system("/Developer/Tools/SetFile -a C %s"%( - shellQuote(filePath),)) - - if isDirectory: - os.system('/Developer/Tools/SetFile -a V %s'%( - shellQuote(tmpPath), - )) - -def main(): - # First parse options and check if we can perform our work - parseOptions() - checkEnvironment() - - os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' - - if os.path.exists(WORKDIR): - shutil.rmtree(WORKDIR) - os.mkdir(WORKDIR) - - # Then build third-party libraries such as sleepycat DB4. - buildLibraries() - - # Now build python itself - buildPython() - buildPythonDocs() - fn = os.path.join(WORKDIR, "_root", "Applications", - "MacPython %s"%(getVersion(),), "Update Shell Profile.command") - shutil.copy("scripts/postflight.patch-profile", fn) - os.chmod(fn, 0755) - - folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( - getVersion(),)) - os.chmod(folder, 0755) - setIcon(folder, "../Icons/Python Folder.icns") - - # Create the installer - buildInstaller() - - # And copy the readme into the directory containing the installer - patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt')) - - # Ditto for the license file. - shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) - - fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos - fp.close() - - # Custom icon for the DMG, shown when the DMG is mounted. - shutil.copy("../Icons/Disk Image.icns", - os.path.join(WORKDIR, "installer", ".VolumeIcon.icns")) - os.system("/Developer/Tools/SetFile -a C %s"%( - os.path.join(WORKDIR, "installer", ".VolumeIcon.icns"))) - - - # And copy it to a DMG - buildDMG() - - -if __name__ == "__main__": - main() +#!/usr/bin/python2.3 +""" +This script is used to build the "official unofficial" universal build on +Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its +work. + +Please ensure that this script keeps working with Python 2.3, to avoid +bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) + +Usage: see USAGE variable in the script. +""" +import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd + +INCLUDE_TIMESTAMP=1 +VERBOSE=1 + +from plistlib import Plist + +import MacOS +import Carbon.File +import Carbon.Icn +import Carbon.Res +from Carbon.Files import kCustomIconResource, fsRdWrPerm, kHasCustomIcon +from Carbon.Files import kFSCatInfoFinderInfo + +try: + from plistlib import writePlist +except ImportError: + # We're run using python2.3 + def writePlist(plist, path): + plist.write(path) + +def shellQuote(value): + """ + Return the string value in a form that can savely be inserted into + a shell command. + """ + return "'%s'"%(value.replace("'", "'\"'\"'")) + +def grepValue(fn, variable): + variable = variable + '=' + for ln in open(fn, 'r'): + if ln.startswith(variable): + value = ln[len(variable):].strip() + return value[1:-1] + +def getVersion(): + return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + +def getFullVersion(): + fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') + for ln in open(fn): + if 'PY_VERSION' in ln: + return ln.split()[-1][1:-1] + + raise RuntimeError, "Cannot find full version??" + +# The directory we'll use to create the build, will be erased and recreated +WORKDIR="/tmp/_py" + +# The directory we'll use to store third-party sources, set this to something +# else if you don't want to re-fetch required libraries every time. +DEPSRC=os.path.join(WORKDIR, 'third-party') +DEPSRC=os.path.expanduser('~/Universal/other-sources') + +# Location of the preferred SDK +SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" +#SDKPATH="/" + +# Source directory (asume we're in Mac/OSX/Dist) +SRCDIR=os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.abspath(__file__ + ))))) + +USAGE=textwrap.dedent("""\ + Usage: build_python [options] + + Options: + -? or -h: Show this message + -b DIR + --build-dir=DIR: Create build here (default: %(WORKDIR)r) + --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) + --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) + --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) +""")% globals() + + +# Instructions for building libraries that are necessary for building a +# batteries included python. +LIBRARY_RECIPES=[ + dict( + # Note that GNU readline is GPL'd software + name="GNU Readline 5.1.4", + url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" , + patchlevel='0', + patches=[ + # The readline maintainers don't do actual micro releases, but + # just ship a set of patches. + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004', + ] + ), + + dict( + name="SQLite 3.3.5", + url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", + checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', + configure_pre=[ + '--enable-threadsafe', + '--enable-tempstore', + '--enable-shared=no', + '--enable-static=yes', + '--disable-tcl', + ] + ), + + dict( + name="NCurses 5.5", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", + configure_pre=[ + "--without-cxx", + "--without-ada", + "--without-progs", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + "--enable-termcap", + ], + patches=[ + "ncurses-5.5.patch", + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="Sleepycat DB 4.4", + url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", + #name="Sleepycat DB 4.3.29", + #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", + buildDir="build_unix", + configure="../dist/configure", + configure_pre=[ + '--includedir=/usr/local/include/db4', + ] + ), +] + + +# Instructions for building packages inside the .mpkg. +PKG_RECIPES=[ + dict( + name="PythonFramework", + long_name="Python Framework", + source="/Library/Frameworks/Python.framework", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + postflight="scripts/postflight.framework", + ), + dict( + name="PythonApplications", + long_name="GUI Applications", + source="/Applications/MacPython %(VER)s", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + required=False, + ), + dict( + name="PythonUnixTools", + long_name="UNIX command-line tools", + source="/usr/local/bin", + readme="""\ + This package installs the unix tools in /usr/local/bin for + compatibility with older releases of MacPython. This package + is not necessary to use MacPython. + """, + required=False, + ), + dict( + name="PythonDocumentation", + long_name="Python Documentation", + topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", + source="/pydocs", + readme="""\ + This package installs the python documentation at a location + that is useable for pydoc and IDLE. If you have installed Xcode + it will also install a link to the documentation in + /Developer/Documentation/Python + """, + postflight="scripts/postflight.documentation", + required=False, + ), + dict( + name="PythonProfileChanges", + long_name="Shell profile updater", + readme="""\ + This packages updates your shell profile to make sure that + the MacPython tools are found by your shell in preference of + the system provided Python tools. + + If you don't install this package you'll have to add + "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" + to your PATH by hand. + """, + postflight="scripts/postflight.patch-profile", + topdir="/Library/Frameworks/Python.framework", + source="/empty-dir", + required=False, + ), +] + + +def fatal(msg): + """ + A fatal error, bail out. + """ + sys.stderr.write('FATAL: ') + sys.stderr.write(msg) + sys.stderr.write('\n') + sys.exit(1) + +def fileContents(fn): + """ + Return the contents of the named file + """ + return open(fn, 'rb').read() + +def runCommand(commandline): + """ + Run a command and raise RuntimeError if it fails. Output is surpressed + unless the command fails. + """ + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + if VERBOSE: + sys.stdout.write(data); sys.stdout.flush() + +def captureCommand(commandline): + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + return data + +def checkEnvironment(): + """ + Check that we're running on a supported system. + """ + + if platform.system() != 'Darwin': + fatal("This script should be run on a Mac OS X 10.4 system") + + if platform.release() <= '8.': + fatal("This script should be run on a Mac OS X 10.4 system") + + if not os.path.exists(SDKPATH): + fatal("Please install the latest version of Xcode and the %s SDK"%( + os.path.basename(SDKPATH[:-4]))) + + + +def parseOptions(args = None): + """ + Parse arguments and update global settings. + """ + global WORKDIR, DEPSRC, SDKPATH, SRCDIR + + if args is None: + args = sys.argv[1:] + + try: + options, args = getopt.getopt(args, '?hb', + [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) + except getopt.error, msg: + print msg + sys.exit(1) + + if args: + print "Additional arguments" + sys.exit(1) + + for k, v in options: + if k in ('-h', '-?'): + print USAGE + sys.exit(0) + + elif k in ('-d', '--build-dir'): + WORKDIR=v + + elif k in ('--third-party',): + DEPSRC=v + + elif k in ('--sdk-path',): + SDKPATH=v + + elif k in ('--src-dir',): + SRCDIR=v + + else: + raise NotImplementedError, k + + SRCDIR=os.path.abspath(SRCDIR) + WORKDIR=os.path.abspath(WORKDIR) + SDKPATH=os.path.abspath(SDKPATH) + DEPSRC=os.path.abspath(DEPSRC) + + print "Settings:" + print " * Source directory:", SRCDIR + print " * Build directory: ", WORKDIR + print " * SDK location: ", SDKPATH + print " * third-party source:", DEPSRC + print "" + + + + +def extractArchive(builddir, archiveName): + """ + Extract a source archive into 'builddir'. Returns the path of the + extracted archive. + + XXX: This function assumes that archives contain a toplevel directory + that is has the same name as the basename of the archive. This is + save enough for anything we use. + """ + curdir = os.getcwd() + try: + os.chdir(builddir) + if archiveName.endswith('.tar.gz'): + retval = os.path.basename(archiveName[:-7]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar.bz2'): + retval = os.path.basename(archiveName[:-8]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.zip'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') + + data = fp.read() + xit = fp.close() + if xit is not None: + sys.stdout.write(data) + raise RuntimeError, "Cannot extract %s"%(archiveName,) + + return os.path.join(builddir, retval) + + finally: + os.chdir(curdir) + +KNOWNSIZES = { + "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, + "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, +} + +def downloadURL(url, fname): + """ + Download the contents of the url into the file. + """ + try: + size = os.path.getsize(fname) + except OSError: + pass + else: + if KNOWNSIZES.get(url) == size: + print "Using existing file for", url + return + fpIn = urllib2.urlopen(url) + fpOut = open(fname, 'wb') + block = fpIn.read(10240) + try: + while block: + fpOut.write(block) + block = fpIn.read(10240) + fpIn.close() + fpOut.close() + except: + try: + os.unlink(fname) + except: + pass + +def buildRecipe(recipe, basedir, archList): + """ + Build software using a recipe. This function does the + 'configure;make;make install' dance for C software, with a possibility + to customize this process, basically a poor-mans DarwinPorts. + """ + curdir = os.getcwd() + + name = recipe['name'] + url = recipe['url'] + configure = recipe.get('configure', './configure') + install = recipe.get('install', 'make && make install DESTDIR=%s'%( + shellQuote(basedir))) + + archiveName = os.path.split(url)[-1] + sourceArchive = os.path.join(DEPSRC, archiveName) + + if not os.path.exists(DEPSRC): + os.mkdir(DEPSRC) + + + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL(url, sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + print "Extracting archive for %s"%(name,) + buildDir=os.path.join(WORKDIR, '_bld') + if not os.path.exists(buildDir): + os.mkdir(buildDir) + + workDir = extractArchive(buildDir, sourceArchive) + os.chdir(workDir) + if 'buildDir' in recipe: + os.chdir(recipe['buildDir']) + + + for fn in recipe.get('patches', ()): + if fn.startswith('http://'): + # Download the patch before applying it. + path = os.path.join(DEPSRC, os.path.basename(fn)) + downloadURL(fn, path) + fn = path + + fn = os.path.join(curdir, fn) + runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), + shellQuote(fn),)) + + configure_args = [ + "--prefix=/usr/local", + "--enable-static", + "--disable-shared", + #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), + ] + + if 'configure_pre' in recipe: + args = list(recipe['configure_pre']) + if '--disable-static' in args: + configure_args.remove('--enable-static') + if '--enable-shared' in args: + configure_args.remove('--disable-shared') + configure_args.extend(args) + + if recipe.get('useLDFlags', 1): + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1], + ' -arch '.join(archList)), + ]) + else: + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + ]) + + if 'configure_post' in recipe: + configure_args = configure_args = list(recipe['configure_post']) + + configure_args.insert(0, configure) + configure_args = [ shellQuote(a) for a in configure_args ] + + print "Running configure for %s"%(name,) + runCommand(' '.join(configure_args) + ' 2>&1') + + print "Running install for %s"%(name,) + runCommand('{ ' + install + ' ;} 2>&1') + + print "Done %s"%(name,) + print "" + + os.chdir(curdir) + +def buildLibraries(): + """ + Build our dependencies into $WORKDIR/libraries/usr/local + """ + print "" + print "Building required libraries" + print "" + universal = os.path.join(WORKDIR, 'libraries') + os.mkdir(universal) + os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) + os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) + + for recipe in LIBRARY_RECIPES: + buildRecipe(recipe, universal, ('i386', 'ppc',)) + + + +def buildPythonDocs(): + # This stores the documentation as Resources/English.lproj/Docuentation + # inside the framwork. pydoc and IDLE will pick it up there. + print "Install python documentation" + rootDir = os.path.join(WORKDIR, '_root') + version = getVersion() + docdir = os.path.join(rootDir, 'pydocs') + + name = 'html-%s.tar.bz2'%(getFullVersion(),) + sourceArchive = os.path.join(DEPSRC, name) + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( + getFullVersion(), name), sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + extractArchive(os.path.dirname(docdir), sourceArchive) + os.rename( + os.path.join( + os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), + docdir) + + +def buildPython(): + print "Building a universal python" + + buildDir = os.path.join(WORKDIR, '_bld', 'python') + rootDir = os.path.join(WORKDIR, '_root') + + if os.path.exists(buildDir): + shutil.rmtree(buildDir) + if os.path.exists(rootDir): + shutil.rmtree(rootDir) + os.mkdir(buildDir) + os.mkdir(rootDir) + os.mkdir(os.path.join(rootDir, 'empty-dir')) + curdir = os.getcwd() + os.chdir(buildDir) + + # Not sure if this is still needed, the original build script + # claims that parts of the install assume python.exe exists. + os.symlink('python', os.path.join(buildDir, 'python.exe')) + + # Extract the version from the configure file, needed to calculate + # several paths. + version = getVersion() + + print "Running configure..." + runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( + shellQuote(os.path.join(SRCDIR, 'configure')), + shellQuote(SDKPATH), shellQuote(WORKDIR), + shellQuote(WORKDIR))) + + print "Running make" + runCommand("make") + + print "Runing make frameworkinstall" + runCommand("make frameworkinstall DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Runing make frameworkinstallextras" + runCommand("make frameworkinstallextras DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Copy required shared libraries" + if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): + runCommand("mv %s/* %s"%( + shellQuote(os.path.join( + WORKDIR, 'libraries', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')), + shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')))) + + print "Fix file modes" + frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') + for dirpath, dirnames, filenames in os.walk(frmDir): + for dn in dirnames: + os.chmod(os.path.join(dirpath, dn), 0775) + + for fn in filenames: + if os.path.islink(fn): + continue + + # "chmod g+w $fn" + p = os.path.join(dirpath, fn) + st = os.stat(p) + os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) + + # We added some directories to the search path during the configure + # phase. Remove those because those directories won't be there on + # the end-users system. + path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', + 'Versions', version, 'lib', 'python%s'%(version,), + 'config', 'Makefile') + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() + + # Add symlinks in /usr/local/bin, using relative links + usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') + to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', + 'Python.framework', 'Versions', version, 'bin') + if os.path.exists(usr_local_bin): + shutil.rmtree(usr_local_bin) + os.makedirs(usr_local_bin) + for fn in os.listdir( + os.path.join(frmDir, 'Versions', version, 'bin')): + os.symlink(os.path.join(to_framework, fn), + os.path.join(usr_local_bin, fn)) + + os.chdir(curdir) + + + +def patchFile(inPath, outPath): + data = fileContents(inPath) + data = data.replace('$FULL_VERSION', getFullVersion()) + data = data.replace('$VERSION', getVersion()) + data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') + data = data.replace('$ARCHITECTURES', "i386, ppc") + data = data.replace('$INSTALL_SIZE', installSize()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + +def patchScript(inPath, outPath): + data = fileContents(inPath) + data = data.replace('@PYVER@', getVersion()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + os.chmod(outPath, 0755) + + + +def packageFromRecipe(targetDir, recipe): + curdir = os.getcwd() + try: + pkgname = recipe['name'] + srcdir = recipe.get('source') + pkgroot = recipe.get('topdir', srcdir) + postflight = recipe.get('postflight') + readme = textwrap.dedent(recipe['readme']) + isRequired = recipe.get('required', True) + + print "- building package %s"%(pkgname,) + + # Substitute some variables + textvars = dict( + VER=getVersion(), + FULLVER=getFullVersion(), + ) + readme = readme % textvars + + if pkgroot is not None: + pkgroot = pkgroot % textvars + else: + pkgroot = '/' + + if srcdir is not None: + srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) + srcdir = srcdir % textvars + + if postflight is not None: + postflight = os.path.abspath(postflight) + + packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') + os.makedirs(packageContents) + + if srcdir is not None: + os.chdir(srcdir) + runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) + + fn = os.path.join(packageContents, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + rsrcDir = os.path.join(packageContents, "Resources") + os.mkdir(rsrcDir) + fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') + fp.write(readme) + fp.close() + + if postflight is not None: + patchScript(postflight, os.path.join(rsrcDir, 'postflight')) + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + pl = Plist( + CFBundleGetInfoString="MacPython.%s %s"%(pkgname, vers,), + CFBundleIdentifier='org.python.MacPython.%s'%(pkgname,), + CFBundleName='MacPython.%s'%(pkgname,), + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagAllowBackRev=False, + IFPkgFlagAuthorizationAction="RootAuthorization", + IFPkgFlagDefaultLocation=pkgroot, + IFPkgFlagFollowLinks=True, + IFPkgFlagInstallFat=True, + IFPkgFlagIsRequired=isRequired, + IFPkgFlagOverwritePermissions=False, + IFPkgFlagRelocatable=False, + IFPkgFlagRestartAction="NoRestart", + IFPkgFlagRootVolumeOnly=True, + IFPkgFlagUpdateInstalledLangauges=False, + ) + writePlist(pl, os.path.join(packageContents, 'Info.plist')) + + pl = Plist( + IFPkgDescriptionDescription=readme, + IFPkgDescriptionTitle=recipe.get('long_name', "MacPython.%s"%(pkgname,)), + IFPkgDescriptionVersion=vers, + ) + writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) + + finally: + os.chdir(curdir) + + +def makeMpkgPlist(path): + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + + pl = Plist( + CFBundleGetInfoString="MacPython %s"%(vers,), + CFBundleIdentifier='org.python.MacPython', + CFBundleName='MacPython', + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFlagComponentDirectory="Contents/Packages", + IFPkgFlagPackageList=[ + dict( + IFPkgFlagPackageLocation='%s.pkg'%(item['name']), + IFPkgFlagPackageSelection='selected' + ) + for item in PKG_RECIPES + ], + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagBackgroundScaling="proportional", + IFPkgFlagBackgroundAlignment="left", + ) + + writePlist(pl, path) + + +def buildInstaller(): + + # Zap all compiled files + for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): + for fn in filenames: + if fn.endswith('.pyc') or fn.endswith('.pyo'): + os.unlink(os.path.join(dirpath, fn)) + + outdir = os.path.join(WORKDIR, 'installer') + if os.path.exists(outdir): + shutil.rmtree(outdir) + os.mkdir(outdir) + + pkgroot = os.path.join(outdir, 'MacPython.mpkg', 'Contents') + pkgcontents = os.path.join(pkgroot, 'Packages') + os.makedirs(pkgcontents) + for recipe in PKG_RECIPES: + packageFromRecipe(pkgcontents, recipe) + + rsrcDir = os.path.join(pkgroot, 'Resources') + + fn = os.path.join(pkgroot, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + os.mkdir(rsrcDir) + + makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) + pl = Plist( + IFPkgDescriptionTitle="Universal MacPython", + IFPkgDescriptionVersion=getVersion(), + ) + + writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) + for fn in os.listdir('resources'): + if fn.endswith('.jpg'): + shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + else: + patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + + shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt')) + + +def installSize(clear=False, _saved=[]): + if clear: + del _saved[:] + if not _saved: + data = captureCommand("du -ks %s"%( + shellQuote(os.path.join(WORKDIR, '_root')))) + _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) + return _saved[0] + + +def buildDMG(): + """ + Create DMG containing the rootDir + """ + outdir = os.path.join(WORKDIR, 'diskimage') + if os.path.exists(outdir): + shutil.rmtree(outdir) + + imagepath = os.path.join(outdir, + 'python-%s-macosx'%(getFullVersion(),)) + if INCLUDE_TIMESTAMP: + imagepath = imagepath + '%04d-%02d-%02d'%(time.localtime()[:3]) + imagepath = imagepath + '.dmg' + + os.mkdir(outdir) + runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( + getFullVersion(), + shellQuote(os.path.join(WORKDIR, 'installer')), + shellQuote(imagepath))) + + return imagepath + + +def setIcon(filePath, icnsPath): + """ + Set the custom icon for the specified file or directory. + + For a directory the icon data is written in a file named 'Icon\r' inside + the directory. For both files and directories write the icon as an 'icns' + resource. Furthermore set kHasCustomIcon in the finder flags for filePath. + """ + ref, isDirectory = Carbon.File.FSPathMakeRef(icnsPath) + icon = Carbon.Icn.ReadIconFile(ref) + del ref + + # + # Open the resource fork of the target, to add the icon later on. + # For directories we use the file 'Icon\r' inside the directory. + # + + ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) + + if isDirectory: + tmpPath = os.path.join(filePath, "Icon\r") + if not os.path.exists(tmpPath): + fp = open(tmpPath, 'w') + fp.close() + + tmpRef, _ = Carbon.File.FSPathMakeRef(tmpPath) + spec = Carbon.File.FSSpec(tmpRef) + + else: + spec = Carbon.File.FSSpec(ref) + + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + # Try to create the resource fork again, this will avoid problems + # when adding an icon to a directory. I have no idea why this helps, + # but without this adding the icon to a directory will fail sometimes. + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + refNum = Carbon.Res.FSpOpenResFile(spec, fsRdWrPerm) + + Carbon.Res.UseResFile(refNum) + + # Check if there already is an icon, remove it if there is. + try: + h = Carbon.Res.Get1Resource('icns', kCustomIconResource) + except MacOS.Error: + pass + + else: + h.RemoveResource() + del h + + # Add the icon to the resource for of the target + res = Carbon.Res.Resource(icon) + res.AddResource('icns', kCustomIconResource, '') + res.WriteResource() + res.DetachResource() + Carbon.Res.CloseResFile(refNum) + + # And now set the kHasCustomIcon property for the target. Annoyingly, + # python doesn't seem to have bindings for the API that is needed for + # this. Cop out and call SetFile + os.system("/Developer/Tools/SetFile -a C %s"%( + shellQuote(filePath),)) + + if isDirectory: + os.system('/Developer/Tools/SetFile -a V %s'%( + shellQuote(tmpPath), + )) + +def main(): + # First parse options and check if we can perform our work + parseOptions() + checkEnvironment() + + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + + if os.path.exists(WORKDIR): + shutil.rmtree(WORKDIR) + os.mkdir(WORKDIR) + + # Then build third-party libraries such as sleepycat DB4. + buildLibraries() + + # Now build python itself + buildPython() + buildPythonDocs() + fn = os.path.join(WORKDIR, "_root", "Applications", + "MacPython %s"%(getVersion(),), "Update Shell Profile.command") + shutil.copy("scripts/postflight.patch-profile", fn) + os.chmod(fn, 0755) + + folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( + getVersion(),)) + os.chmod(folder, 0755) + setIcon(folder, "../Icons/Python Folder.icns") + + # Create the installer + buildInstaller() + + # And copy the readme into the directory containing the installer + patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt')) + + # Ditto for the license file. + shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) + + fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') + print >> fp, "# BUILD INFO" + print >> fp, "# Date:", time.ctime() + print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.close() + + # Custom icon for the DMG, shown when the DMG is mounted. + shutil.copy("../Icons/Disk Image.icns", + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns")) + os.system("/Developer/Tools/SetFile -a C %s"%( + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns"))) + + + # And copy it to a DMG + buildDMG() + + +if __name__ == "__main__": + main() From python-checkins at python.org Tue May 23 23:55:54 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 23 May 2006 23:55:54 +0200 (CEST) Subject: [Python-checkins] r46158 - in python/trunk/Mac/OSX/BuildScript: README.txt build-installer.py resources/ReadMe.txt Message-ID: <20060523215554.362241E4009@bag.python.org> Author: tim.peters Date: Tue May 23 23:55:53 2006 New Revision: 46158 Modified: python/trunk/Mac/OSX/BuildScript/README.txt (props changed) python/trunk/Mac/OSX/BuildScript/build-installer.py (contents, props changed) python/trunk/Mac/OSX/BuildScript/resources/ReadMe.txt (props changed) Log: Add missing svn:eol-style property to text files. Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py ============================================================================== --- python/trunk/Mac/OSX/BuildScript/build-installer.py (original) +++ python/trunk/Mac/OSX/BuildScript/build-installer.py Tue May 23 23:55:53 2006 @@ -1,1013 +1,1013 @@ -#!/usr/bin/python2.3 -""" -This script is used to build the "official unofficial" universal build on -Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its -work. - -Please ensure that this script keeps working with Python 2.3, to avoid -bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) - -Usage: see USAGE variable in the script. -""" -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd - -INCLUDE_TIMESTAMP=1 -VERBOSE=1 - -from plistlib import Plist - -import MacOS -import Carbon.File -import Carbon.Icn -import Carbon.Res -from Carbon.Files import kCustomIconResource, fsRdWrPerm, kHasCustomIcon -from Carbon.Files import kFSCatInfoFinderInfo - -try: - from plistlib import writePlist -except ImportError: - # We're run using python2.3 - def writePlist(plist, path): - plist.write(path) - -def shellQuote(value): - """ - Return the string value in a form that can savely be inserted into - a shell command. - """ - return "'%s'"%(value.replace("'", "'\"'\"'")) - -def grepValue(fn, variable): - variable = variable + '=' - for ln in open(fn, 'r'): - if ln.startswith(variable): - value = ln[len(variable):].strip() - return value[1:-1] - -def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') - -def getFullVersion(): - fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') - for ln in open(fn): - if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - - raise RuntimeError, "Cannot find full version??" - -# The directory we'll use to create the build, will be erased and recreated -WORKDIR="/tmp/_py" - -# The directory we'll use to store third-party sources, set this to something -# else if you don't want to re-fetch required libraries every time. -DEPSRC=os.path.join(WORKDIR, 'third-party') -DEPSRC=os.path.expanduser('~/Universal/other-sources') - -# Location of the preferred SDK -SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" -#SDKPATH="/" - -# Source directory (asume we're in Mac/OSX/Dist) -SRCDIR=os.path.dirname( - os.path.dirname( - os.path.dirname( - os.path.dirname( - os.path.abspath(__file__ - ))))) - -USAGE=textwrap.dedent("""\ - Usage: build_python [options] - - Options: - -? or -h: Show this message - -b DIR - --build-dir=DIR: Create build here (default: %(WORKDIR)r) - --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) - --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) - --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) -""")% globals() - - -# Instructions for building libraries that are necessary for building a -# batteries included python. -LIBRARY_RECIPES=[ - dict( - # Note that GNU readline is GPL'd software - name="GNU Readline 5.1.4", - url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" , - patchlevel='0', - patches=[ - # The readline maintainers don't do actual micro releases, but - # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003', - 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004', - ] - ), - - dict( - name="SQLite 3.3.5", - url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", - checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', - configure_pre=[ - '--enable-threadsafe', - '--enable-tempstore', - '--enable-shared=no', - '--enable-static=yes', - '--disable-tcl', - ] - ), - - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - configure_pre=[ - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), - dict( - name="Sleepycat DB 4.4", - url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", - #name="Sleepycat DB 4.3.29", - #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", - buildDir="build_unix", - configure="../dist/configure", - configure_pre=[ - '--includedir=/usr/local/include/db4', - ] - ), -] - - -# Instructions for building packages inside the .mpkg. -PKG_RECIPES=[ - dict( - name="PythonFramework", - long_name="Python Framework", - source="/Library/Frameworks/Python.framework", - readme="""\ - This package installs Python.framework, that is the python - interpreter and the standard library. This also includes Python - wrappers for lots of Mac OS X API's. - """, - postflight="scripts/postflight.framework", - ), - dict( - name="PythonApplications", - long_name="GUI Applications", - source="/Applications/MacPython %(VER)s", - readme="""\ - This package installs Python.framework, that is the python - interpreter and the standard library. This also includes Python - wrappers for lots of Mac OS X API's. - """, - required=False, - ), - dict( - name="PythonUnixTools", - long_name="UNIX command-line tools", - source="/usr/local/bin", - readme="""\ - This package installs the unix tools in /usr/local/bin for - compatibility with older releases of MacPython. This package - is not necessary to use MacPython. - """, - required=False, - ), - dict( - name="PythonDocumentation", - long_name="Python Documentation", - topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", - source="/pydocs", - readme="""\ - This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python - """, - postflight="scripts/postflight.documentation", - required=False, - ), - dict( - name="PythonProfileChanges", - long_name="Shell profile updater", - readme="""\ - This packages updates your shell profile to make sure that - the MacPython tools are found by your shell in preference of - the system provided Python tools. - - If you don't install this package you'll have to add - "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" - to your PATH by hand. - """, - postflight="scripts/postflight.patch-profile", - topdir="/Library/Frameworks/Python.framework", - source="/empty-dir", - required=False, - ), -] - - -def fatal(msg): - """ - A fatal error, bail out. - """ - sys.stderr.write('FATAL: ') - sys.stderr.write(msg) - sys.stderr.write('\n') - sys.exit(1) - -def fileContents(fn): - """ - Return the contents of the named file - """ - return open(fn, 'rb').read() - -def runCommand(commandline): - """ - Run a command and raise RuntimeError if it fails. Output is surpressed - unless the command fails. - """ - fd = os.popen(commandline, 'r') - data = fd.read() - xit = fd.close() - if xit != None: - sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) - - if VERBOSE: - sys.stdout.write(data); sys.stdout.flush() - -def captureCommand(commandline): - fd = os.popen(commandline, 'r') - data = fd.read() - xit = fd.close() - if xit != None: - sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) - - return data - -def checkEnvironment(): - """ - Check that we're running on a supported system. - """ - - if platform.system() != 'Darwin': - fatal("This script should be run on a Mac OS X 10.4 system") - - if platform.release() <= '8.': - fatal("This script should be run on a Mac OS X 10.4 system") - - if not os.path.exists(SDKPATH): - fatal("Please install the latest version of Xcode and the %s SDK"%( - os.path.basename(SDKPATH[:-4]))) - - - -def parseOptions(args = None): - """ - Parse arguments and update global settings. - """ - global WORKDIR, DEPSRC, SDKPATH, SRCDIR - - if args is None: - args = sys.argv[1:] - - try: - options, args = getopt.getopt(args, '?hb', - [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) - except getopt.error, msg: - print msg - sys.exit(1) - - if args: - print "Additional arguments" - sys.exit(1) - - for k, v in options: - if k in ('-h', '-?'): - print USAGE - sys.exit(0) - - elif k in ('-d', '--build-dir'): - WORKDIR=v - - elif k in ('--third-party',): - DEPSRC=v - - elif k in ('--sdk-path',): - SDKPATH=v - - elif k in ('--src-dir',): - SRCDIR=v - - else: - raise NotImplementedError, k - - SRCDIR=os.path.abspath(SRCDIR) - WORKDIR=os.path.abspath(WORKDIR) - SDKPATH=os.path.abspath(SDKPATH) - DEPSRC=os.path.abspath(DEPSRC) - - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * third-party source:", DEPSRC - print "" - - - - -def extractArchive(builddir, archiveName): - """ - Extract a source archive into 'builddir'. Returns the path of the - extracted archive. - - XXX: This function assumes that archives contain a toplevel directory - that is has the same name as the basename of the archive. This is - save enough for anything we use. - """ - curdir = os.getcwd() - try: - os.chdir(builddir) - if archiveName.endswith('.tar.gz'): - retval = os.path.basename(archiveName[:-7]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.tar.bz2'): - retval = os.path.basename(archiveName[:-8]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.tar'): - retval = os.path.basename(archiveName[:-4]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') - - elif archiveName.endswith('.zip'): - retval = os.path.basename(archiveName[:-4]) - if os.path.exists(retval): - shutil.rmtree(retval) - fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') - - data = fp.read() - xit = fp.close() - if xit is not None: - sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) - - return os.path.join(builddir, retval) - - finally: - os.chdir(curdir) - -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - -def downloadURL(url, fname): - """ - Download the contents of the url into the file. - """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) - fpOut = open(fname, 'wb') - block = fpIn.read(10240) - try: - while block: - fpOut.write(block) - block = fpIn.read(10240) - fpIn.close() - fpOut.close() - except: - try: - os.unlink(fname) - except: - pass - -def buildRecipe(recipe, basedir, archList): - """ - Build software using a recipe. This function does the - 'configure;make;make install' dance for C software, with a possibility - to customize this process, basically a poor-mans DarwinPorts. - """ - curdir = os.getcwd() - - name = recipe['name'] - url = recipe['url'] - configure = recipe.get('configure', './configure') - install = recipe.get('install', 'make && make install DESTDIR=%s'%( - shellQuote(basedir))) - - archiveName = os.path.split(url)[-1] - sourceArchive = os.path.join(DEPSRC, archiveName) - - if not os.path.exists(DEPSRC): - os.mkdir(DEPSRC) - - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) - buildDir=os.path.join(WORKDIR, '_bld') - if not os.path.exists(buildDir): - os.mkdir(buildDir) - - workDir = extractArchive(buildDir, sourceArchive) - os.chdir(workDir) - if 'buildDir' in recipe: - os.chdir(recipe['buildDir']) - - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) - runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), - shellQuote(fn),)) - - configure_args = [ - "--prefix=/usr/local", - "--enable-static", - "--disable-shared", - #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), - ] - - if 'configure_pre' in recipe: - args = list(recipe['configure_pre']) - if '--disable-static' in args: - configure_args.remove('--enable-static') - if '--enable-shared' in args: - configure_args.remove('--disable-shared') - configure_args.extend(args) - - if recipe.get('useLDFlags', 1): - configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( - ' -arch '.join(archList), - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1], - ' -arch '.join(archList)), - ]) - else: - configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( - ' -arch '.join(archList), - shellQuote(SDKPATH)[1:-1], - shellQuote(basedir)[1:-1],), - ]) - - if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) - - configure_args.insert(0, configure) - configure_args = [ shellQuote(a) for a in configure_args ] - - print "Running configure for %s"%(name,) - runCommand(' '.join(configure_args) + ' 2>&1') - - print "Running install for %s"%(name,) - runCommand('{ ' + install + ' ;} 2>&1') - - print "Done %s"%(name,) - print "" - - os.chdir(curdir) - -def buildLibraries(): - """ - Build our dependencies into $WORKDIR/libraries/usr/local - """ - print "" - print "Building required libraries" - print "" - universal = os.path.join(WORKDIR, 'libraries') - os.mkdir(universal) - os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) - os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) - - for recipe in LIBRARY_RECIPES: - buildRecipe(recipe, universal, ('i386', 'ppc',)) - - - -def buildPythonDocs(): - # This stores the documentation as Resources/English.lproj/Docuentation - # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" - rootDir = os.path.join(WORKDIR, '_root') - version = getVersion() - docdir = os.path.join(rootDir, 'pydocs') - - name = 'html-%s.tar.bz2'%(getFullVersion(),) - sourceArchive = os.path.join(DEPSRC, name) - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Downloading %s"%(name,) - downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( - getFullVersion(), name), sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - extractArchive(os.path.dirname(docdir), sourceArchive) - os.rename( - os.path.join( - os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), - docdir) - - -def buildPython(): - print "Building a universal python" - - buildDir = os.path.join(WORKDIR, '_bld', 'python') - rootDir = os.path.join(WORKDIR, '_root') - - if os.path.exists(buildDir): - shutil.rmtree(buildDir) - if os.path.exists(rootDir): - shutil.rmtree(rootDir) - os.mkdir(buildDir) - os.mkdir(rootDir) - os.mkdir(os.path.join(rootDir, 'empty-dir')) - curdir = os.getcwd() - os.chdir(buildDir) - - # Not sure if this is still needed, the original build script - # claims that parts of the install assume python.exe exists. - os.symlink('python', os.path.join(buildDir, 'python.exe')) - - # Extract the version from the configure file, needed to calculate - # several paths. - version = getVersion() - - print "Running configure..." - runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( - shellQuote(os.path.join(SRCDIR, 'configure')), - shellQuote(SDKPATH), shellQuote(WORKDIR), - shellQuote(WORKDIR))) - - print "Running make" - runCommand("make") - - print "Runing make frameworkinstall" - runCommand("make frameworkinstall DESTDIR=%s"%( - shellQuote(rootDir))) - - print "Runing make frameworkinstallextras" - runCommand("make frameworkinstallextras DESTDIR=%s"%( - shellQuote(rootDir))) - - print "Copy required shared libraries" - if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): - runCommand("mv %s/* %s"%( - shellQuote(os.path.join( - WORKDIR, 'libraries', 'Library', 'Frameworks', - 'Python.framework', 'Versions', getVersion(), - 'lib')), - shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', - 'Python.framework', 'Versions', getVersion(), - 'lib')))) - - print "Fix file modes" - frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') - for dirpath, dirnames, filenames in os.walk(frmDir): - for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) - - for fn in filenames: - if os.path.islink(fn): - continue - - # "chmod g+w $fn" - p = os.path.join(dirpath, fn) - st = os.stat(p) - os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) - - # We added some directories to the search path during the configure - # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config', 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() - - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() - - # Add symlinks in /usr/local/bin, using relative links - usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') - to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', - 'Python.framework', 'Versions', version, 'bin') - if os.path.exists(usr_local_bin): - shutil.rmtree(usr_local_bin) - os.makedirs(usr_local_bin) - for fn in os.listdir( - os.path.join(frmDir, 'Versions', version, 'bin')): - os.symlink(os.path.join(to_framework, fn), - os.path.join(usr_local_bin, fn)) - - os.chdir(curdir) - - - -def patchFile(inPath, outPath): - data = fileContents(inPath) - data = data.replace('$FULL_VERSION', getFullVersion()) - data = data.replace('$VERSION', getVersion()) - data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') - data = data.replace('$ARCHITECTURES', "i386, ppc") - data = data.replace('$INSTALL_SIZE', installSize()) - fp = open(outPath, 'wb') - fp.write(data) - fp.close() - -def patchScript(inPath, outPath): - data = fileContents(inPath) - data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') - fp.write(data) - fp.close() - os.chmod(outPath, 0755) - - - -def packageFromRecipe(targetDir, recipe): - curdir = os.getcwd() - try: - pkgname = recipe['name'] - srcdir = recipe.get('source') - pkgroot = recipe.get('topdir', srcdir) - postflight = recipe.get('postflight') - readme = textwrap.dedent(recipe['readme']) - isRequired = recipe.get('required', True) - - print "- building package %s"%(pkgname,) - - # Substitute some variables - textvars = dict( - VER=getVersion(), - FULLVER=getFullVersion(), - ) - readme = readme % textvars - - if pkgroot is not None: - pkgroot = pkgroot % textvars - else: - pkgroot = '/' - - if srcdir is not None: - srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) - srcdir = srcdir % textvars - - if postflight is not None: - postflight = os.path.abspath(postflight) - - packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') - os.makedirs(packageContents) - - if srcdir is not None: - os.chdir(srcdir) - runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) - runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) - runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) - - fn = os.path.join(packageContents, 'PkgInfo') - fp = open(fn, 'w') - fp.write('pmkrpkg1') - fp.close() - - rsrcDir = os.path.join(packageContents, "Resources") - os.mkdir(rsrcDir) - fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') - fp.write(readme) - fp.close() - - if postflight is not None: - patchScript(postflight, os.path.join(rsrcDir, 'postflight')) - - vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) - pl = Plist( - CFBundleGetInfoString="MacPython.%s %s"%(pkgname, vers,), - CFBundleIdentifier='org.python.MacPython.%s'%(pkgname,), - CFBundleName='MacPython.%s'%(pkgname,), - CFBundleShortVersionString=vers, - IFMajorVersion=major, - IFMinorVersion=minor, - IFPkgFormatVersion=0.10000000149011612, - IFPkgFlagAllowBackRev=False, - IFPkgFlagAuthorizationAction="RootAuthorization", - IFPkgFlagDefaultLocation=pkgroot, - IFPkgFlagFollowLinks=True, - IFPkgFlagInstallFat=True, - IFPkgFlagIsRequired=isRequired, - IFPkgFlagOverwritePermissions=False, - IFPkgFlagRelocatable=False, - IFPkgFlagRestartAction="NoRestart", - IFPkgFlagRootVolumeOnly=True, - IFPkgFlagUpdateInstalledLangauges=False, - ) - writePlist(pl, os.path.join(packageContents, 'Info.plist')) - - pl = Plist( - IFPkgDescriptionDescription=readme, - IFPkgDescriptionTitle=recipe.get('long_name', "MacPython.%s"%(pkgname,)), - IFPkgDescriptionVersion=vers, - ) - writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) - - finally: - os.chdir(curdir) - - -def makeMpkgPlist(path): - - vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) - - pl = Plist( - CFBundleGetInfoString="MacPython %s"%(vers,), - CFBundleIdentifier='org.python.MacPython', - CFBundleName='MacPython', - CFBundleShortVersionString=vers, - IFMajorVersion=major, - IFMinorVersion=minor, - IFPkgFlagComponentDirectory="Contents/Packages", - IFPkgFlagPackageList=[ - dict( - IFPkgFlagPackageLocation='%s.pkg'%(item['name']), - IFPkgFlagPackageSelection='selected' - ) - for item in PKG_RECIPES - ], - IFPkgFormatVersion=0.10000000149011612, - IFPkgFlagBackgroundScaling="proportional", - IFPkgFlagBackgroundAlignment="left", - ) - - writePlist(pl, path) - - -def buildInstaller(): - - # Zap all compiled files - for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): - for fn in filenames: - if fn.endswith('.pyc') or fn.endswith('.pyo'): - os.unlink(os.path.join(dirpath, fn)) - - outdir = os.path.join(WORKDIR, 'installer') - if os.path.exists(outdir): - shutil.rmtree(outdir) - os.mkdir(outdir) - - pkgroot = os.path.join(outdir, 'MacPython.mpkg', 'Contents') - pkgcontents = os.path.join(pkgroot, 'Packages') - os.makedirs(pkgcontents) - for recipe in PKG_RECIPES: - packageFromRecipe(pkgcontents, recipe) - - rsrcDir = os.path.join(pkgroot, 'Resources') - - fn = os.path.join(pkgroot, 'PkgInfo') - fp = open(fn, 'w') - fp.write('pmkrpkg1') - fp.close() - - os.mkdir(rsrcDir) - - makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) - pl = Plist( - IFPkgDescriptionTitle="Universal MacPython", - IFPkgDescriptionVersion=getVersion(), - ) - - writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) - for fn in os.listdir('resources'): - if fn.endswith('.jpg'): - shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) - else: - patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) - - shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt')) - - -def installSize(clear=False, _saved=[]): - if clear: - del _saved[:] - if not _saved: - data = captureCommand("du -ks %s"%( - shellQuote(os.path.join(WORKDIR, '_root')))) - _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) - return _saved[0] - - -def buildDMG(): - """ - Create DMG containing the rootDir - """ - outdir = os.path.join(WORKDIR, 'diskimage') - if os.path.exists(outdir): - shutil.rmtree(outdir) - - imagepath = os.path.join(outdir, - 'python-%s-macosx'%(getFullVersion(),)) - if INCLUDE_TIMESTAMP: - imagepath = imagepath + '%04d-%02d-%02d'%(time.localtime()[:3]) - imagepath = imagepath + '.dmg' - - os.mkdir(outdir) - runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( - getFullVersion(), - shellQuote(os.path.join(WORKDIR, 'installer')), - shellQuote(imagepath))) - - return imagepath - - -def setIcon(filePath, icnsPath): - """ - Set the custom icon for the specified file or directory. - - For a directory the icon data is written in a file named 'Icon\r' inside - the directory. For both files and directories write the icon as an 'icns' - resource. Furthermore set kHasCustomIcon in the finder flags for filePath. - """ - ref, isDirectory = Carbon.File.FSPathMakeRef(icnsPath) - icon = Carbon.Icn.ReadIconFile(ref) - del ref - - # - # Open the resource fork of the target, to add the icon later on. - # For directories we use the file 'Icon\r' inside the directory. - # - - ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) - - if isDirectory: - tmpPath = os.path.join(filePath, "Icon\r") - if not os.path.exists(tmpPath): - fp = open(tmpPath, 'w') - fp.close() - - tmpRef, _ = Carbon.File.FSPathMakeRef(tmpPath) - spec = Carbon.File.FSSpec(tmpRef) - - else: - spec = Carbon.File.FSSpec(ref) - - try: - Carbon.Res.HCreateResFile(*spec.as_tuple()) - except MacOS.Error: - pass - - # Try to create the resource fork again, this will avoid problems - # when adding an icon to a directory. I have no idea why this helps, - # but without this adding the icon to a directory will fail sometimes. - try: - Carbon.Res.HCreateResFile(*spec.as_tuple()) - except MacOS.Error: - pass - - refNum = Carbon.Res.FSpOpenResFile(spec, fsRdWrPerm) - - Carbon.Res.UseResFile(refNum) - - # Check if there already is an icon, remove it if there is. - try: - h = Carbon.Res.Get1Resource('icns', kCustomIconResource) - except MacOS.Error: - pass - - else: - h.RemoveResource() - del h - - # Add the icon to the resource for of the target - res = Carbon.Res.Resource(icon) - res.AddResource('icns', kCustomIconResource, '') - res.WriteResource() - res.DetachResource() - Carbon.Res.CloseResFile(refNum) - - # And now set the kHasCustomIcon property for the target. Annoyingly, - # python doesn't seem to have bindings for the API that is needed for - # this. Cop out and call SetFile - os.system("/Developer/Tools/SetFile -a C %s"%( - shellQuote(filePath),)) - - if isDirectory: - os.system('/Developer/Tools/SetFile -a V %s'%( - shellQuote(tmpPath), - )) - -def main(): - # First parse options and check if we can perform our work - parseOptions() - checkEnvironment() - - os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' - - if os.path.exists(WORKDIR): - shutil.rmtree(WORKDIR) - os.mkdir(WORKDIR) - - # Then build third-party libraries such as sleepycat DB4. - buildLibraries() - - # Now build python itself - buildPython() - buildPythonDocs() - fn = os.path.join(WORKDIR, "_root", "Applications", - "MacPython %s"%(getVersion(),), "Update Shell Profile.command") - shutil.copy("scripts/postflight.patch-profile", fn) - os.chmod(fn, 0755) - - folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( - getVersion(),)) - os.chmod(folder, 0755) - setIcon(folder, "../Icons/Python Folder.icns") - - # Create the installer - buildInstaller() - - # And copy the readme into the directory containing the installer - patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt')) - - # Ditto for the license file. - shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) - - fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos - fp.close() - - # Custom icon for the DMG, shown when the DMG is mounted. - shutil.copy("../Icons/Disk Image.icns", - os.path.join(WORKDIR, "installer", ".VolumeIcon.icns")) - os.system("/Developer/Tools/SetFile -a C %s"%( - os.path.join(WORKDIR, "installer", ".VolumeIcon.icns"))) - - - # And copy it to a DMG - buildDMG() - - -if __name__ == "__main__": - main() +#!/usr/bin/python2.3 +""" +This script is used to build the "official unofficial" universal build on +Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its +work. + +Please ensure that this script keeps working with Python 2.3, to avoid +bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) + +Usage: see USAGE variable in the script. +""" +import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd + +INCLUDE_TIMESTAMP=1 +VERBOSE=1 + +from plistlib import Plist + +import MacOS +import Carbon.File +import Carbon.Icn +import Carbon.Res +from Carbon.Files import kCustomIconResource, fsRdWrPerm, kHasCustomIcon +from Carbon.Files import kFSCatInfoFinderInfo + +try: + from plistlib import writePlist +except ImportError: + # We're run using python2.3 + def writePlist(plist, path): + plist.write(path) + +def shellQuote(value): + """ + Return the string value in a form that can savely be inserted into + a shell command. + """ + return "'%s'"%(value.replace("'", "'\"'\"'")) + +def grepValue(fn, variable): + variable = variable + '=' + for ln in open(fn, 'r'): + if ln.startswith(variable): + value = ln[len(variable):].strip() + return value[1:-1] + +def getVersion(): + return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + +def getFullVersion(): + fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') + for ln in open(fn): + if 'PY_VERSION' in ln: + return ln.split()[-1][1:-1] + + raise RuntimeError, "Cannot find full version??" + +# The directory we'll use to create the build, will be erased and recreated +WORKDIR="/tmp/_py" + +# The directory we'll use to store third-party sources, set this to something +# else if you don't want to re-fetch required libraries every time. +DEPSRC=os.path.join(WORKDIR, 'third-party') +DEPSRC=os.path.expanduser('~/Universal/other-sources') + +# Location of the preferred SDK +SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" +#SDKPATH="/" + +# Source directory (asume we're in Mac/OSX/Dist) +SRCDIR=os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.abspath(__file__ + ))))) + +USAGE=textwrap.dedent("""\ + Usage: build_python [options] + + Options: + -? or -h: Show this message + -b DIR + --build-dir=DIR: Create build here (default: %(WORKDIR)r) + --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) + --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) + --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) +""")% globals() + + +# Instructions for building libraries that are necessary for building a +# batteries included python. +LIBRARY_RECIPES=[ + dict( + # Note that GNU readline is GPL'd software + name="GNU Readline 5.1.4", + url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" , + patchlevel='0', + patches=[ + # The readline maintainers don't do actual micro releases, but + # just ship a set of patches. + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003', + 'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004', + ] + ), + + dict( + name="SQLite 3.3.5", + url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", + checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', + configure_pre=[ + '--enable-threadsafe', + '--enable-tempstore', + '--enable-shared=no', + '--enable-static=yes', + '--disable-tcl', + ] + ), + + dict( + name="NCurses 5.5", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", + configure_pre=[ + "--without-cxx", + "--without-ada", + "--without-progs", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + "--enable-termcap", + ], + patches=[ + "ncurses-5.5.patch", + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="Sleepycat DB 4.4", + url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", + #name="Sleepycat DB 4.3.29", + #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", + buildDir="build_unix", + configure="../dist/configure", + configure_pre=[ + '--includedir=/usr/local/include/db4', + ] + ), +] + + +# Instructions for building packages inside the .mpkg. +PKG_RECIPES=[ + dict( + name="PythonFramework", + long_name="Python Framework", + source="/Library/Frameworks/Python.framework", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + postflight="scripts/postflight.framework", + ), + dict( + name="PythonApplications", + long_name="GUI Applications", + source="/Applications/MacPython %(VER)s", + readme="""\ + This package installs Python.framework, that is the python + interpreter and the standard library. This also includes Python + wrappers for lots of Mac OS X API's. + """, + required=False, + ), + dict( + name="PythonUnixTools", + long_name="UNIX command-line tools", + source="/usr/local/bin", + readme="""\ + This package installs the unix tools in /usr/local/bin for + compatibility with older releases of MacPython. This package + is not necessary to use MacPython. + """, + required=False, + ), + dict( + name="PythonDocumentation", + long_name="Python Documentation", + topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation", + source="/pydocs", + readme="""\ + This package installs the python documentation at a location + that is useable for pydoc and IDLE. If you have installed Xcode + it will also install a link to the documentation in + /Developer/Documentation/Python + """, + postflight="scripts/postflight.documentation", + required=False, + ), + dict( + name="PythonProfileChanges", + long_name="Shell profile updater", + readme="""\ + This packages updates your shell profile to make sure that + the MacPython tools are found by your shell in preference of + the system provided Python tools. + + If you don't install this package you'll have to add + "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin" + to your PATH by hand. + """, + postflight="scripts/postflight.patch-profile", + topdir="/Library/Frameworks/Python.framework", + source="/empty-dir", + required=False, + ), +] + + +def fatal(msg): + """ + A fatal error, bail out. + """ + sys.stderr.write('FATAL: ') + sys.stderr.write(msg) + sys.stderr.write('\n') + sys.exit(1) + +def fileContents(fn): + """ + Return the contents of the named file + """ + return open(fn, 'rb').read() + +def runCommand(commandline): + """ + Run a command and raise RuntimeError if it fails. Output is surpressed + unless the command fails. + """ + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + if VERBOSE: + sys.stdout.write(data); sys.stdout.flush() + +def captureCommand(commandline): + fd = os.popen(commandline, 'r') + data = fd.read() + xit = fd.close() + if xit != None: + sys.stdout.write(data) + raise RuntimeError, "command failed: %s"%(commandline,) + + return data + +def checkEnvironment(): + """ + Check that we're running on a supported system. + """ + + if platform.system() != 'Darwin': + fatal("This script should be run on a Mac OS X 10.4 system") + + if platform.release() <= '8.': + fatal("This script should be run on a Mac OS X 10.4 system") + + if not os.path.exists(SDKPATH): + fatal("Please install the latest version of Xcode and the %s SDK"%( + os.path.basename(SDKPATH[:-4]))) + + + +def parseOptions(args = None): + """ + Parse arguments and update global settings. + """ + global WORKDIR, DEPSRC, SDKPATH, SRCDIR + + if args is None: + args = sys.argv[1:] + + try: + options, args = getopt.getopt(args, '?hb', + [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) + except getopt.error, msg: + print msg + sys.exit(1) + + if args: + print "Additional arguments" + sys.exit(1) + + for k, v in options: + if k in ('-h', '-?'): + print USAGE + sys.exit(0) + + elif k in ('-d', '--build-dir'): + WORKDIR=v + + elif k in ('--third-party',): + DEPSRC=v + + elif k in ('--sdk-path',): + SDKPATH=v + + elif k in ('--src-dir',): + SRCDIR=v + + else: + raise NotImplementedError, k + + SRCDIR=os.path.abspath(SRCDIR) + WORKDIR=os.path.abspath(WORKDIR) + SDKPATH=os.path.abspath(SDKPATH) + DEPSRC=os.path.abspath(DEPSRC) + + print "Settings:" + print " * Source directory:", SRCDIR + print " * Build directory: ", WORKDIR + print " * SDK location: ", SDKPATH + print " * third-party source:", DEPSRC + print "" + + + + +def extractArchive(builddir, archiveName): + """ + Extract a source archive into 'builddir'. Returns the path of the + extracted archive. + + XXX: This function assumes that archives contain a toplevel directory + that is has the same name as the basename of the archive. This is + save enough for anything we use. + """ + curdir = os.getcwd() + try: + os.chdir(builddir) + if archiveName.endswith('.tar.gz'): + retval = os.path.basename(archiveName[:-7]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar.bz2'): + retval = os.path.basename(archiveName[:-8]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.tar'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') + + elif archiveName.endswith('.zip'): + retval = os.path.basename(archiveName[:-4]) + if os.path.exists(retval): + shutil.rmtree(retval) + fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') + + data = fp.read() + xit = fp.close() + if xit is not None: + sys.stdout.write(data) + raise RuntimeError, "Cannot extract %s"%(archiveName,) + + return os.path.join(builddir, retval) + + finally: + os.chdir(curdir) + +KNOWNSIZES = { + "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, + "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, +} + +def downloadURL(url, fname): + """ + Download the contents of the url into the file. + """ + try: + size = os.path.getsize(fname) + except OSError: + pass + else: + if KNOWNSIZES.get(url) == size: + print "Using existing file for", url + return + fpIn = urllib2.urlopen(url) + fpOut = open(fname, 'wb') + block = fpIn.read(10240) + try: + while block: + fpOut.write(block) + block = fpIn.read(10240) + fpIn.close() + fpOut.close() + except: + try: + os.unlink(fname) + except: + pass + +def buildRecipe(recipe, basedir, archList): + """ + Build software using a recipe. This function does the + 'configure;make;make install' dance for C software, with a possibility + to customize this process, basically a poor-mans DarwinPorts. + """ + curdir = os.getcwd() + + name = recipe['name'] + url = recipe['url'] + configure = recipe.get('configure', './configure') + install = recipe.get('install', 'make && make install DESTDIR=%s'%( + shellQuote(basedir))) + + archiveName = os.path.split(url)[-1] + sourceArchive = os.path.join(DEPSRC, archiveName) + + if not os.path.exists(DEPSRC): + os.mkdir(DEPSRC) + + + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL(url, sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + print "Extracting archive for %s"%(name,) + buildDir=os.path.join(WORKDIR, '_bld') + if not os.path.exists(buildDir): + os.mkdir(buildDir) + + workDir = extractArchive(buildDir, sourceArchive) + os.chdir(workDir) + if 'buildDir' in recipe: + os.chdir(recipe['buildDir']) + + + for fn in recipe.get('patches', ()): + if fn.startswith('http://'): + # Download the patch before applying it. + path = os.path.join(DEPSRC, os.path.basename(fn)) + downloadURL(fn, path) + fn = path + + fn = os.path.join(curdir, fn) + runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), + shellQuote(fn),)) + + configure_args = [ + "--prefix=/usr/local", + "--enable-static", + "--disable-shared", + #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),), + ] + + if 'configure_pre' in recipe: + args = list(recipe['configure_pre']) + if '--disable-static' in args: + configure_args.remove('--enable-static') + if '--enable-shared' in args: + configure_args.remove('--disable-shared') + configure_args.extend(args) + + if recipe.get('useLDFlags', 1): + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1], + ' -arch '.join(archList)), + ]) + else: + configure_args.extend([ + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + ' -arch '.join(archList), + shellQuote(SDKPATH)[1:-1], + shellQuote(basedir)[1:-1],), + ]) + + if 'configure_post' in recipe: + configure_args = configure_args = list(recipe['configure_post']) + + configure_args.insert(0, configure) + configure_args = [ shellQuote(a) for a in configure_args ] + + print "Running configure for %s"%(name,) + runCommand(' '.join(configure_args) + ' 2>&1') + + print "Running install for %s"%(name,) + runCommand('{ ' + install + ' ;} 2>&1') + + print "Done %s"%(name,) + print "" + + os.chdir(curdir) + +def buildLibraries(): + """ + Build our dependencies into $WORKDIR/libraries/usr/local + """ + print "" + print "Building required libraries" + print "" + universal = os.path.join(WORKDIR, 'libraries') + os.mkdir(universal) + os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) + os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) + + for recipe in LIBRARY_RECIPES: + buildRecipe(recipe, universal, ('i386', 'ppc',)) + + + +def buildPythonDocs(): + # This stores the documentation as Resources/English.lproj/Docuentation + # inside the framwork. pydoc and IDLE will pick it up there. + print "Install python documentation" + rootDir = os.path.join(WORKDIR, '_root') + version = getVersion() + docdir = os.path.join(rootDir, 'pydocs') + + name = 'html-%s.tar.bz2'%(getFullVersion(),) + sourceArchive = os.path.join(DEPSRC, name) + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Downloading %s"%(name,) + downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( + getFullVersion(), name), sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + extractArchive(os.path.dirname(docdir), sourceArchive) + os.rename( + os.path.join( + os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), + docdir) + + +def buildPython(): + print "Building a universal python" + + buildDir = os.path.join(WORKDIR, '_bld', 'python') + rootDir = os.path.join(WORKDIR, '_root') + + if os.path.exists(buildDir): + shutil.rmtree(buildDir) + if os.path.exists(rootDir): + shutil.rmtree(rootDir) + os.mkdir(buildDir) + os.mkdir(rootDir) + os.mkdir(os.path.join(rootDir, 'empty-dir')) + curdir = os.getcwd() + os.chdir(buildDir) + + # Not sure if this is still needed, the original build script + # claims that parts of the install assume python.exe exists. + os.symlink('python', os.path.join(buildDir, 'python.exe')) + + # Extract the version from the configure file, needed to calculate + # several paths. + version = getVersion() + + print "Running configure..." + runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( + shellQuote(os.path.join(SRCDIR, 'configure')), + shellQuote(SDKPATH), shellQuote(WORKDIR), + shellQuote(WORKDIR))) + + print "Running make" + runCommand("make") + + print "Runing make frameworkinstall" + runCommand("make frameworkinstall DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Runing make frameworkinstallextras" + runCommand("make frameworkinstallextras DESTDIR=%s"%( + shellQuote(rootDir))) + + print "Copy required shared libraries" + if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): + runCommand("mv %s/* %s"%( + shellQuote(os.path.join( + WORKDIR, 'libraries', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')), + shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', + 'Python.framework', 'Versions', getVersion(), + 'lib')))) + + print "Fix file modes" + frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') + for dirpath, dirnames, filenames in os.walk(frmDir): + for dn in dirnames: + os.chmod(os.path.join(dirpath, dn), 0775) + + for fn in filenames: + if os.path.islink(fn): + continue + + # "chmod g+w $fn" + p = os.path.join(dirpath, fn) + st = os.stat(p) + os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) + + # We added some directories to the search path during the configure + # phase. Remove those because those directories won't be there on + # the end-users system. + path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', + 'Versions', version, 'lib', 'python%s'%(version,), + 'config', 'Makefile') + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() + + # Add symlinks in /usr/local/bin, using relative links + usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') + to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', + 'Python.framework', 'Versions', version, 'bin') + if os.path.exists(usr_local_bin): + shutil.rmtree(usr_local_bin) + os.makedirs(usr_local_bin) + for fn in os.listdir( + os.path.join(frmDir, 'Versions', version, 'bin')): + os.symlink(os.path.join(to_framework, fn), + os.path.join(usr_local_bin, fn)) + + os.chdir(curdir) + + + +def patchFile(inPath, outPath): + data = fileContents(inPath) + data = data.replace('$FULL_VERSION', getFullVersion()) + data = data.replace('$VERSION', getVersion()) + data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') + data = data.replace('$ARCHITECTURES', "i386, ppc") + data = data.replace('$INSTALL_SIZE', installSize()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + +def patchScript(inPath, outPath): + data = fileContents(inPath) + data = data.replace('@PYVER@', getVersion()) + fp = open(outPath, 'wb') + fp.write(data) + fp.close() + os.chmod(outPath, 0755) + + + +def packageFromRecipe(targetDir, recipe): + curdir = os.getcwd() + try: + pkgname = recipe['name'] + srcdir = recipe.get('source') + pkgroot = recipe.get('topdir', srcdir) + postflight = recipe.get('postflight') + readme = textwrap.dedent(recipe['readme']) + isRequired = recipe.get('required', True) + + print "- building package %s"%(pkgname,) + + # Substitute some variables + textvars = dict( + VER=getVersion(), + FULLVER=getFullVersion(), + ) + readme = readme % textvars + + if pkgroot is not None: + pkgroot = pkgroot % textvars + else: + pkgroot = '/' + + if srcdir is not None: + srcdir = os.path.join(WORKDIR, '_root', srcdir[1:]) + srcdir = srcdir % textvars + + if postflight is not None: + postflight = os.path.abspath(postflight) + + packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents') + os.makedirs(packageContents) + + if srcdir is not None: + os.chdir(srcdir) + runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),)) + runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),)) + + fn = os.path.join(packageContents, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + rsrcDir = os.path.join(packageContents, "Resources") + os.mkdir(rsrcDir) + fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w') + fp.write(readme) + fp.close() + + if postflight is not None: + patchScript(postflight, os.path.join(rsrcDir, 'postflight')) + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + pl = Plist( + CFBundleGetInfoString="MacPython.%s %s"%(pkgname, vers,), + CFBundleIdentifier='org.python.MacPython.%s'%(pkgname,), + CFBundleName='MacPython.%s'%(pkgname,), + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagAllowBackRev=False, + IFPkgFlagAuthorizationAction="RootAuthorization", + IFPkgFlagDefaultLocation=pkgroot, + IFPkgFlagFollowLinks=True, + IFPkgFlagInstallFat=True, + IFPkgFlagIsRequired=isRequired, + IFPkgFlagOverwritePermissions=False, + IFPkgFlagRelocatable=False, + IFPkgFlagRestartAction="NoRestart", + IFPkgFlagRootVolumeOnly=True, + IFPkgFlagUpdateInstalledLangauges=False, + ) + writePlist(pl, os.path.join(packageContents, 'Info.plist')) + + pl = Plist( + IFPkgDescriptionDescription=readme, + IFPkgDescriptionTitle=recipe.get('long_name', "MacPython.%s"%(pkgname,)), + IFPkgDescriptionVersion=vers, + ) + writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist')) + + finally: + os.chdir(curdir) + + +def makeMpkgPlist(path): + + vers = getFullVersion() + major, minor = map(int, getVersion().split('.', 2)) + + pl = Plist( + CFBundleGetInfoString="MacPython %s"%(vers,), + CFBundleIdentifier='org.python.MacPython', + CFBundleName='MacPython', + CFBundleShortVersionString=vers, + IFMajorVersion=major, + IFMinorVersion=minor, + IFPkgFlagComponentDirectory="Contents/Packages", + IFPkgFlagPackageList=[ + dict( + IFPkgFlagPackageLocation='%s.pkg'%(item['name']), + IFPkgFlagPackageSelection='selected' + ) + for item in PKG_RECIPES + ], + IFPkgFormatVersion=0.10000000149011612, + IFPkgFlagBackgroundScaling="proportional", + IFPkgFlagBackgroundAlignment="left", + ) + + writePlist(pl, path) + + +def buildInstaller(): + + # Zap all compiled files + for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')): + for fn in filenames: + if fn.endswith('.pyc') or fn.endswith('.pyo'): + os.unlink(os.path.join(dirpath, fn)) + + outdir = os.path.join(WORKDIR, 'installer') + if os.path.exists(outdir): + shutil.rmtree(outdir) + os.mkdir(outdir) + + pkgroot = os.path.join(outdir, 'MacPython.mpkg', 'Contents') + pkgcontents = os.path.join(pkgroot, 'Packages') + os.makedirs(pkgcontents) + for recipe in PKG_RECIPES: + packageFromRecipe(pkgcontents, recipe) + + rsrcDir = os.path.join(pkgroot, 'Resources') + + fn = os.path.join(pkgroot, 'PkgInfo') + fp = open(fn, 'w') + fp.write('pmkrpkg1') + fp.close() + + os.mkdir(rsrcDir) + + makeMpkgPlist(os.path.join(pkgroot, 'Info.plist')) + pl = Plist( + IFPkgDescriptionTitle="Universal MacPython", + IFPkgDescriptionVersion=getVersion(), + ) + + writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) + for fn in os.listdir('resources'): + if fn.endswith('.jpg'): + shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + else: + patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) + + shutil.copy("../../../LICENSE", os.path.join(rsrcDir, 'License.txt')) + + +def installSize(clear=False, _saved=[]): + if clear: + del _saved[:] + if not _saved: + data = captureCommand("du -ks %s"%( + shellQuote(os.path.join(WORKDIR, '_root')))) + _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),)) + return _saved[0] + + +def buildDMG(): + """ + Create DMG containing the rootDir + """ + outdir = os.path.join(WORKDIR, 'diskimage') + if os.path.exists(outdir): + shutil.rmtree(outdir) + + imagepath = os.path.join(outdir, + 'python-%s-macosx'%(getFullVersion(),)) + if INCLUDE_TIMESTAMP: + imagepath = imagepath + '%04d-%02d-%02d'%(time.localtime()[:3]) + imagepath = imagepath + '.dmg' + + os.mkdir(outdir) + runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( + getFullVersion(), + shellQuote(os.path.join(WORKDIR, 'installer')), + shellQuote(imagepath))) + + return imagepath + + +def setIcon(filePath, icnsPath): + """ + Set the custom icon for the specified file or directory. + + For a directory the icon data is written in a file named 'Icon\r' inside + the directory. For both files and directories write the icon as an 'icns' + resource. Furthermore set kHasCustomIcon in the finder flags for filePath. + """ + ref, isDirectory = Carbon.File.FSPathMakeRef(icnsPath) + icon = Carbon.Icn.ReadIconFile(ref) + del ref + + # + # Open the resource fork of the target, to add the icon later on. + # For directories we use the file 'Icon\r' inside the directory. + # + + ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) + + if isDirectory: + tmpPath = os.path.join(filePath, "Icon\r") + if not os.path.exists(tmpPath): + fp = open(tmpPath, 'w') + fp.close() + + tmpRef, _ = Carbon.File.FSPathMakeRef(tmpPath) + spec = Carbon.File.FSSpec(tmpRef) + + else: + spec = Carbon.File.FSSpec(ref) + + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + # Try to create the resource fork again, this will avoid problems + # when adding an icon to a directory. I have no idea why this helps, + # but without this adding the icon to a directory will fail sometimes. + try: + Carbon.Res.HCreateResFile(*spec.as_tuple()) + except MacOS.Error: + pass + + refNum = Carbon.Res.FSpOpenResFile(spec, fsRdWrPerm) + + Carbon.Res.UseResFile(refNum) + + # Check if there already is an icon, remove it if there is. + try: + h = Carbon.Res.Get1Resource('icns', kCustomIconResource) + except MacOS.Error: + pass + + else: + h.RemoveResource() + del h + + # Add the icon to the resource for of the target + res = Carbon.Res.Resource(icon) + res.AddResource('icns', kCustomIconResource, '') + res.WriteResource() + res.DetachResource() + Carbon.Res.CloseResFile(refNum) + + # And now set the kHasCustomIcon property for the target. Annoyingly, + # python doesn't seem to have bindings for the API that is needed for + # this. Cop out and call SetFile + os.system("/Developer/Tools/SetFile -a C %s"%( + shellQuote(filePath),)) + + if isDirectory: + os.system('/Developer/Tools/SetFile -a V %s'%( + shellQuote(tmpPath), + )) + +def main(): + # First parse options and check if we can perform our work + parseOptions() + checkEnvironment() + + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + + if os.path.exists(WORKDIR): + shutil.rmtree(WORKDIR) + os.mkdir(WORKDIR) + + # Then build third-party libraries such as sleepycat DB4. + buildLibraries() + + # Now build python itself + buildPython() + buildPythonDocs() + fn = os.path.join(WORKDIR, "_root", "Applications", + "MacPython %s"%(getVersion(),), "Update Shell Profile.command") + shutil.copy("scripts/postflight.patch-profile", fn) + os.chmod(fn, 0755) + + folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( + getVersion(),)) + os.chmod(folder, 0755) + setIcon(folder, "../Icons/Python Folder.icns") + + # Create the installer + buildInstaller() + + # And copy the readme into the directory containing the installer + patchFile('resources/ReadMe.txt', os.path.join(WORKDIR, 'installer', 'ReadMe.txt')) + + # Ditto for the license file. + shutil.copy('../../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) + + fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') + print >> fp, "# BUILD INFO" + print >> fp, "# Date:", time.ctime() + print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.close() + + # Custom icon for the DMG, shown when the DMG is mounted. + shutil.copy("../Icons/Disk Image.icns", + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns")) + os.system("/Developer/Tools/SetFile -a C %s"%( + os.path.join(WORKDIR, "installer", ".VolumeIcon.icns"))) + + + # And copy it to a DMG + buildDMG() + + +if __name__ == "__main__": + main() From buildbot at python.org Wed May 24 00:03:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 23 May 2006 22:03:20 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060523220321.1F0AE1E401A@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/450 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Wed May 24 08:18:35 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 23 May 2006 23:18:35 -0700 Subject: [Python-checkins] r46095 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060523101222.07AF71E4018@bag.python.org> References: <20060523101222.07AF71E4018@bag.python.org> Message-ID: start and end look like they should be Py_ssize_t's. On 5/23/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Tue May 23 12:12:21 2006 > New Revision: 46095 > > Modified: > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: fixed unicode "in" operator to use same implementation > approach as find/index > > > > Modified: python/trunk/Objects/unicodeobject.c > ============================================================================== > --- python/trunk/Objects/unicodeobject.c (original) > +++ python/trunk/Objects/unicodeobject.c Tue May 23 12:12:21 2006 > + } else { > + int start = 0; > + int end = PyUnicode_GET_SIZE(u) - size; > + for (; start <= end; start++) > + if (Py_UNICODE_MATCH(u, start, v)) { > + result = 1; > + break; > + } From nnorwitz at gmail.com Wed May 24 08:37:25 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 23 May 2006 23:37:25 -0700 Subject: [Python-checkins] r46104 - python/trunk/Lib/distutils/sysconfig.py python/trunk/Lib/distutils/unixccompiler.py python/trunk/Lib/distutils/util.py In-Reply-To: <20060523120112.8D3D61E4009@bag.python.org> References: <20060523120112.8D3D61E4009@bag.python.org> Message-ID: On 5/23/06, ronald.oussoren wrote: > Author: ronald.oussoren > Date: Tue May 23 14:01:11 2006 > New Revision: 46104 > > Modified: > python/trunk/Lib/distutils/sysconfig.py > python/trunk/Lib/distutils/unixccompiler.py > python/trunk/Lib/distutils/util.py > Log: > Patch #1488098. > > This patchs makes it possible to create a universal build on OSX 10.4 and use > the result to build extensions on 10.3. It also makes it possible to override > the '-arch' and '-isysroot' compiler arguments for specific extensions. > > > Modified: python/trunk/Lib/distutils/unixccompiler.py > ============================================================================== > --- python/trunk/Lib/distutils/unixccompiler.py (original) > +++ python/trunk/Lib/distutils/unixccompiler.py Tue May 23 14:01:11 2006 > @@ -42,6 +42,48 @@ > # should just happily stuff them into the preprocessor/compiler/linker > # options and carry on. > > +def _darwin_compiler_fixup(compiler_so, cc_args): > + """ > + This function will strip '-isysroot PATH' and '-arch ARCH' from the > + compile flags if the user has specified one them in extra_compile_flags. > + > + This is needed because '-arch ARCH' adds another architecture to the > + build, without a way to remove an architecture. Furthermore GCC will > + barf if multiple '-isysroot' arguments are present. > + """ > + stripArch = stripSysroot = 0 This initialization can be removed. The variables are set below. > + > + compiler_so = list(compiler_so) > + kernel_version = os.uname()[2] # 8.4.3 > + major_version = int(kernel_version.split('.')[0]) > + > + if major_version < 8: > + # OSX before 10.4.0, these don't support -arch and -isysroot at > + # all. > + stripArch = stripSysroot = True > + else: > + stripArch = '-arch' in cc_args > + stripSysroot = '-isysroot' in cc_args They are set in both suites. > + if stripArch: > + while 1: > + try: > + index = compiler_so.index('-arch') > + # Strip this argument and the next one: > + del compiler_so[index:index+2] > + except ValueError: > + break > + > + if stripSysroot: > + try: > + index = compiler_so.index('-isysroot') > + # Strip this argument and the next one: Is the comment correct or should the code below be index+2? > + del compiler_so[index:index+1] > + except ValueError: > + pass > + > + return compiler_so From nnorwitz at gmail.com Wed May 24 08:59:10 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 23 May 2006 23:59:10 -0700 Subject: [Python-checkins] r46128 - in python/trunk: Include/frameobject.h Misc/NEWS Objects/frameobject.c Python/ceval.c In-Reply-To: <20060523182818.5CA5C1E401D@bag.python.org> References: <20060523182818.5CA5C1E401D@bag.python.org> Message-ID: On 5/23/06, richard.jones wrote: > Author: richard.jones > Date: Tue May 23 20:28:17 2006 > New Revision: 46128 > > Log: > Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects. Richard, You can get rid of one more int, f_restricted if you make it a PyGetSetDef, it's a pretty trivial change. Most of the patch is below, but since I cut and pasted, it would have to be applied manually. (Plus it's missing one removal of setting f_restricted in Frame_New.) n -- Index: Python/ceval.c =================================================================== --- Python/ceval.c (revision 42560) +++ Python/ceval.c (working copy) @@ -3357,7 +3357,7 @@ PyEval_GetRestricted(void) { PyFrameObject *current_frame = PyEval_GetFrame(); - return current_frame == NULL ? 0 : current_frame->f_restricted; + return current_frame == NULL ? 0 : PyFrame_IsRestricted(current_frame); } int Index: Include/frameobject.h =================================================================== --- Include/frameobject.h (revision 42560) +++ Include/frameobject.h (working copy) @@ -32,15 +32,13 @@ /* As of 2.3 f_lineno is only valid when tracing is active (i.e. when f_trace is set) -- at other times use PyCode_Addr2Line instead. */ int f_lineno; /* Current line number */ - int f_restricted; /* Flag set if restricted operations - in this scope */ int f_iblock; /* index in f_blockstack */ @@ -49,6 +44,8 @@ PyAPI_DATA(PyTypeObject) PyFrame_Type; #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) +#define PyFrame_IsRestricted(f) \ + ((f)->f_builtins != (f)->f_tstate->interp->builtins) PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, PyObject *, PyObject *); Index: Objects/frameobject.c =================================================================== --- Objects/frameobject.c (revision 42560) +++ Objects/frameobject.c (working copy) @@ -15,13 +15,14 @@ {"f_builtins", T_OBJECT, OFF(f_builtins),RO}, {"f_globals", T_OBJECT, OFF(f_globals), RO}, {"f_lasti", T_INT, OFF(f_lasti), RO}, - {"f_restricted",T_INT, OFF(f_restricted),RO}, {"f_exc_type", T_OBJECT, OFF(f_exc_type)}, {"f_exc_value", T_OBJECT, OFF(f_exc_value)}, {"f_exc_traceback", T_OBJECT, OFF(f_exc_traceback)}, @@ -342,11 +343,18 @@ return 0; } +static PyObject * +frame_getrestricted(PyFrameObject *f, void *closure) +{ + return PyBool_FromLong(PyFrame_IsRestricted(f)); +} + static PyGetSetDef frame_getsetlist[] = { {"f_locals", (getter)frame_getlocals, NULL, NULL}, {"f_lineno", (getter)frame_getlineno, (setter)frame_setlineno, NULL}, {"f_trace", (getter)frame_gettrace, (setter)frame_settrace, NULL}, + {"f_restricted",(getter)frame_getrestricted, NULL, NULL}, {0} }; From nnorwitz at gmail.com Wed May 24 09:17:39 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 24 May 2006 00:17:39 -0700 Subject: [Python-checkins] r46155 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060523194736.335AA1E4019@bag.python.org> References: <20060523194736.335AA1E4019@bag.python.org> Message-ID: On 5/23/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Tue May 23 21:47:35 2006 > New Revision: 46155 > > Modified: > python/trunk/Objects/unicodeobject.c > Log: > return 0 on misses, not -1. > > > > Modified: python/trunk/Objects/unicodeobject.c > ============================================================================== > --- python/trunk/Objects/unicodeobject.c (original) > +++ python/trunk/Objects/unicodeobject.c Tue May 23 21:47:35 2006 > @@ -172,7 +172,7 @@ > if (set[i] == chr) > return 1; > > - return -1; > + return 0; In that case, can't you just do: return set[i] == chr; From steve at holdenweb.com Wed May 24 08:58:17 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 07:58:17 +0100 Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c In-Reply-To: References: <20060523184426.5EDC41E4009@bag.python.org> Message-ID: <44740409.7080704@holdenweb.com> Guido van Rossum wrote: > On 5/23/06, fredrik.lundh wrote: > >>Author: fredrik.lundh >>Date: Tue May 23 20:44:25 2006 >>New Revision: 46132 >> >>Modified: >> python/trunk/Objects/unicodeobject.c >>Log: >>needforspeed: use append+reverse for rsplit, use "bloom filters" to >>speed up splitlines and strip with charsets; etc. rsplit is now as >>fast as split in all our tests (reverse takes no time at all), and >>splitlines() is nearly as fast as a plain split("\n") in our tests. >>and we're not done yet... ;-) > > > Can I just say that you all in Iceland are having waaaaaay too much fun?! > > Looks like some great stuff is being done. Yay! > Fun? Don't talk to me about fun. I've got this pain in all the diodes down my left side. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From steve at holdenweb.com Wed May 24 08:59:26 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 07:59:26 +0100 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <447363CA.30604@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> Message-ID: <4474044E.8070609@holdenweb.com> M.-A. Lemburg wrote: > steve.holden wrote: > >>Author: steve.holden >>Date: Tue May 23 21:21:00 2006 >>New Revision: 46146 >> >>Modified: >> sandbox/trunk/rjsh-pybench/pybench.py >>Log: >>Use the appropriate clock for the platform. >>Default the number of calibration runs to 0 (can set with -C) > > > Defaulting to 0 is a bad idea, since you basically turn > off calibration altogether. > > Note that calibration is *very* important so > that only the operation itself is timed, not the setup, > loop and other logic not related to the test run. > I understand the purpose of the calibration and agree that omitting calibration could falsely skew the operation times. I don't feel the operation times are a particularly valuable performance parameter anyway - nobody is going to say "ah, well I'll use dict lookup because it's faster than instance creation". It may not be appropriate to check back into the trunk a version with the default number of calibration runs at zero. However, repeated testing has shown that there is sufficient variability in calibration times to throw some results into confusion on some platforms. Comparing a run with calibration to a run without, for example, does not (on Windows, at least) yield the uniform speedup I should have expected. I therefore think we should at least retain the option to ignore the operation times and omit calibration as it will give a more reproducible measure of absolute execution speed. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From nnorwitz at gmail.com Wed May 24 09:21:12 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 24 May 2006 00:21:12 -0700 Subject: [Python-checkins] r46155 - python/trunk/Objects/unicodeobject.c In-Reply-To: References: <20060523194736.335AA1E4019@bag.python.org> Message-ID: On 5/24/06, Neal Norwitz wrote: > On 5/23/06, fredrik.lundh wrote: > > Author: fredrik.lundh > > Date: Tue May 23 21:47:35 2006 > > New Revision: 46155 > > > > Modified: > > python/trunk/Objects/unicodeobject.c > > Log: > > return 0 on misses, not -1. > > > > > > > > Modified: python/trunk/Objects/unicodeobject.c > > ============================================================================== > > --- python/trunk/Objects/unicodeobject.c (original) > > +++ python/trunk/Objects/unicodeobject.c Tue May 23 21:47:35 2006 > > @@ -172,7 +172,7 @@ > > if (set[i] == chr) > > return 1; > > > > - return -1; > > + return 0; > > In that case, can't you just do: > > return set[i] == chr; If this was unicode_member(), nevermind. I see the if stmt above is in a for loop. -- n From nnorwitz at gmail.com Wed May 24 09:24:22 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 24 May 2006 00:24:22 -0700 Subject: [Python-checkins] r46132 - python/trunk/Objects/unicodeobject.c In-Reply-To: References: <20060523184426.5EDC41E4009@bag.python.org> <20060523191808.GA14542@localhost.localdomain> Message-ID: On 5/23/06, Fredrik Lundh wrote: > A.M. Kuchling wrote: > > >> +#define BLOOM_MEMBER(mask, chr, set, setlen)\ > >> + BLOOM(mask, chr) && unicode_member(chr, set, setlen) > > > > unicode_member returns 1 if found, -1 if not; doesn't this mean that > > the second part of the && in BLOOM_MEMBER() will always be true? > > oops: unfortunately, the test suite didn't catch this. Can you update the test suite so it exercises this code? Thanks, n From mal at egenix.com Wed May 24 10:43:50 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 10:43:50 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <4474044E.8070609@holdenweb.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> Message-ID: <44741CC6.6070307@egenix.com> Steve Holden wrote: > M.-A. Lemburg wrote: >> steve.holden wrote: >> >>> Author: steve.holden >>> Date: Tue May 23 21:21:00 2006 >>> New Revision: 46146 >>> >>> Modified: >>> sandbox/trunk/rjsh-pybench/pybench.py >>> Log: >>> Use the appropriate clock for the platform. >>> Default the number of calibration runs to 0 (can set with -C) >> >> >> Defaulting to 0 is a bad idea, since you basically turn >> off calibration altogether. >> >> Note that calibration is *very* important so >> that only the operation itself is timed, not the setup, >> loop and other logic not related to the test run. >> > I understand the purpose of the calibration and agree that omitting > calibration could falsely skew the operation times. I don't feel the > operation times are a particularly valuable performance parameter anyway > - nobody is going to say "ah, well I'll use dict lookup because it's > faster than instance creation". That's not the point: you want to measure and compare the operation, not the setup time and loop mechanism. Both can have quite different performance timings on different machines, since they usually involve a lot more complex machinery than the simple operation you are trying to time. If you add a parameter to change the number of rounds the calibration is run, that's fine. Switching it off completely will make comparisons between platforms generate wrong results. > It may not be appropriate to check back into the trunk a version with > the default number of calibration runs at zero. However, repeated > testing has shown that there is sufficient variability in calibration > times to throw some results into confusion on some platforms. Comparing > a run with calibration to a run without, for example, does not (on > Windows, at least) yield the uniform speedup I should have expected. In that case, you should try to raise the number of rounds the calibration code is run. The default of 20 rounds may not be enough to create an average on Windows. It appears that time.clock() measures wall time instead of just the process time on Windows, so it's likely that the calibration run result depends a lot on what else is going on on the system at the time you run pybench. > I therefore think we should at least retain the option to ignore the > operation times and omit calibration as it will give a more reproducible > measure of absolute execution speed. On the change of time.clock() to time.time(): the precision of time.time() doesn't appear to be more accurate than time.clock() on Windows. Is this documented somewhere ? -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From mal at egenix.com Wed May 24 11:04:38 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 11:04:38 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44741CC6.6070307@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> Message-ID: <447421A6.3090204@egenix.com> M.-A. Lemburg wrote: > Steve Holden wrote: >> M.-A. Lemburg wrote: >>> steve.holden wrote: >>> >>>> Author: steve.holden >>>> Date: Tue May 23 21:21:00 2006 >>>> New Revision: 46146 >>>> >>>> Modified: >>>> sandbox/trunk/rjsh-pybench/pybench.py >>>> Log: >>>> Use the appropriate clock for the platform. >>>> Default the number of calibration runs to 0 (can set with -C) >>> >>> Defaulting to 0 is a bad idea, since you basically turn >>> off calibration altogether. >>> >>> Note that calibration is *very* important so >>> that only the operation itself is timed, not the setup, >>> loop and other logic not related to the test run. >>> >> I understand the purpose of the calibration and agree that omitting >> calibration could falsely skew the operation times. I don't feel the >> operation times are a particularly valuable performance parameter anyway >> - nobody is going to say "ah, well I'll use dict lookup because it's >> faster than instance creation". > > That's not the point: you want to measure and compare the operation, > not the setup time and loop mechanism. Both can have quite different > performance timings on different machines, since they usually > involve a lot more complex machinery than the simple operation > you are trying to time. > > If you add a parameter to change the number of rounds the calibration > is run, that's fine. Switching it off completely will make comparisons > between platforms generate wrong results. > >> It may not be appropriate to check back into the trunk a version with >> the default number of calibration runs at zero. However, repeated >> testing has shown that there is sufficient variability in calibration >> times to throw some results into confusion on some platforms. Comparing >> a run with calibration to a run without, for example, does not (on >> Windows, at least) yield the uniform speedup I should have expected. > > In that case, you should try to raise the number of rounds > the calibration code is run. The default of 20 rounds may > not be enough to create an average on Windows. > > It appears that time.clock() measures wall time instead of > just the process time on Windows, so it's likely that the > calibration run result depends a lot on what else is going on > on the system at the time you run pybench. > >> I therefore think we should at least retain the option to ignore the >> operation times and omit calibration as it will give a more reproducible >> measure of absolute execution speed. > > On the change of time.clock() to time.time(): the precision > of time.time() doesn't appear to be more accurate than > time.clock() on Windows. Is this documented somewhere ? It may actually be better to use the win32process API GetProcessTimes() directly: http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32process__GetProcessTimes_meth.html http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp provided the win32 package is installed. This would be more in line with what time.clock() returns on Unix platforms, namely the process time... I wonder why time.clock() doesn't use this API on Windows. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From steve at holdenweb.com Wed May 24 11:34:37 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 10:34:37 +0100 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <447421A6.3090204@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> Message-ID: <447428AD.4030801@holdenweb.com> M.-A. Lemburg wrote: > M.-A. Lemburg wrote: > >>Steve Holden wrote: >> >>>M.-A. Lemburg wrote: >>> >>>>steve.holden wrote: >>>> >>>> >>>>>Author: steve.holden >>>>>Date: Tue May 23 21:21:00 2006 >>>>>New Revision: 46146 >>>>> >>>>>Modified: >>>>> sandbox/trunk/rjsh-pybench/pybench.py >>>>>Log: >>>>>Use the appropriate clock for the platform. >>>>>Default the number of calibration runs to 0 (can set with -C) >>>> >>>>Defaulting to 0 is a bad idea, since you basically turn >>>>off calibration altogether. >>>> >>>>Note that calibration is *very* important so >>>>that only the operation itself is timed, not the setup, >>>>loop and other logic not related to the test run. >>>> >>> >>>I understand the purpose of the calibration and agree that omitting >>>calibration could falsely skew the operation times. I don't feel the >>>operation times are a particularly valuable performance parameter anyway >>>- nobody is going to say "ah, well I'll use dict lookup because it's >>>faster than instance creation". >> >>That's not the point: you want to measure and compare the operation, >>not the setup time and loop mechanism. Both can have quite different >>performance timings on different machines, since they usually >>involve a lot more complex machinery than the simple operation >>you are trying to time. >> >>If you add a parameter to change the number of rounds the calibration >>is run, that's fine. Switching it off completely will make comparisons >>between platforms generate wrong results. >> >> >>>It may not be appropriate to check back into the trunk a version with >>>the default number of calibration runs at zero. However, repeated >>>testing has shown that there is sufficient variability in calibration >>>times to throw some results into confusion on some platforms. Comparing >>>a run with calibration to a run without, for example, does not (on >>>Windows, at least) yield the uniform speedup I should have expected. >> >>In that case, you should try to raise the number of rounds >>the calibration code is run. The default of 20 rounds may >>not be enough to create an average on Windows. >> >>It appears that time.clock() measures wall time instead of >>just the process time on Windows, so it's likely that the >>calibration run result depends a lot on what else is going on >>on the system at the time you run pybench. >> >> >>>I therefore think we should at least retain the option to ignore the >>>operation times and omit calibration as it will give a more reproducible >>>measure of absolute execution speed. >> >>On the change of time.clock() to time.time(): the precision >>of time.time() doesn't appear to be more accurate than >>time.clock() on Windows. Is this documented somewhere ? > > > It may actually be better to use the win32process API > GetProcessTimes() directly: > > http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32process__GetProcessTimes_meth.html > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp > > provided the win32 package is installed. > > This would be more in line with what time.clock() returns > on Unix platforms, namely the process time... I wonder why > time.clock() doesn't use this API on Windows. > That's a pending change here thanks to Kristjan V Jonsson of CCP, who brought the same code to my attention yesterday. It shouldn't be a difficult fix, so I'll see how it affects reliability. On Windows I can't imnagine it will hurt ... regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From mal at egenix.com Wed May 24 11:44:59 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 11:44:59 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <447428AD.4030801@holdenweb.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> Message-ID: <44742B1B.9090100@egenix.com> Steve Holden wrote: > M.-A. Lemburg wrote: >> M.-A. Lemburg wrote: >> >>> Steve Holden wrote: >>> >>>> M.-A. Lemburg wrote: >>>> >>>>> steve.holden wrote: >>>>> >>>>> >>>>>> Author: steve.holden >>>>>> Date: Tue May 23 21:21:00 2006 >>>>>> New Revision: 46146 >>>>>> >>>>>> Modified: >>>>>> sandbox/trunk/rjsh-pybench/pybench.py >>>>>> Log: >>>>>> Use the appropriate clock for the platform. >>>>>> Default the number of calibration runs to 0 (can set with -C) >>>>> >>>>> Defaulting to 0 is a bad idea, since you basically turn >>>>> off calibration altogether. >>>>> >>>>> Note that calibration is *very* important so >>>>> that only the operation itself is timed, not the setup, >>>>> loop and other logic not related to the test run. >>>>> >>>> >>>> I understand the purpose of the calibration and agree that omitting >>>> calibration could falsely skew the operation times. I don't feel the >>>> operation times are a particularly valuable performance parameter >>>> anyway >>>> - nobody is going to say "ah, well I'll use dict lookup because it's >>>> faster than instance creation". >>> >>> That's not the point: you want to measure and compare the operation, >>> not the setup time and loop mechanism. Both can have quite different >>> performance timings on different machines, since they usually >>> involve a lot more complex machinery than the simple operation >>> you are trying to time. >>> >>> If you add a parameter to change the number of rounds the calibration >>> is run, that's fine. Switching it off completely will make comparisons >>> between platforms generate wrong results. >>> >>> >>>> It may not be appropriate to check back into the trunk a version with >>>> the default number of calibration runs at zero. However, repeated >>>> testing has shown that there is sufficient variability in calibration >>>> times to throw some results into confusion on some platforms. Comparing >>>> a run with calibration to a run without, for example, does not (on >>>> Windows, at least) yield the uniform speedup I should have expected. >>> >>> In that case, you should try to raise the number of rounds >>> the calibration code is run. The default of 20 rounds may >>> not be enough to create an average on Windows. >>> >>> It appears that time.clock() measures wall time instead of >>> just the process time on Windows, so it's likely that the >>> calibration run result depends a lot on what else is going on >>> on the system at the time you run pybench. >>> >>> >>>> I therefore think we should at least retain the option to ignore the >>>> operation times and omit calibration as it will give a more >>>> reproducible >>>> measure of absolute execution speed. >>> >>> On the change of time.clock() to time.time(): the precision >>> of time.time() doesn't appear to be more accurate than >>> time.clock() on Windows. Is this documented somewhere ? >> >> >> It may actually be better to use the win32process API >> GetProcessTimes() directly: >> >> http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32process__GetProcessTimes_meth.html >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp >> >> >> provided the win32 package is installed. >> >> This would be more in line with what time.clock() returns >> on Unix platforms, namely the process time... I wonder why >> time.clock() doesn't use this API on Windows. >> > That's a pending change here thanks to Kristjan V Jonsson of CCP, who > brought the same code to my attention yesterday. It shouldn't be a > difficult fix, so I'll see how it affects reliability. On Windows I > can't imnagine it will hurt ... I gave it a go, but the results are not very promising (or I did something wrong). The UserTime value does change, but it seems to measure something different than process time, e.g. if you run "while 1: pass" for a while, the value doesn't change. I've also had a look at the implementation of time.time() vs. time.clock(): time.clock() is definitely more accurate on Windows since it uses the high resolution performance counter: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp This is about at accurate as it'll get on Windows. time.time() uses ftime() which is only accurate to the millisecond (if at all): http://msdn2.microsoft.com/en-us/library/z54t9z5f(VS.80).aspx -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Wed May 24 12:11:51 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 12:11:51 +0200 (CEST) Subject: [Python-checkins] r46159 - in python/branches/blais-bytebuf: Lib/socket.py Lib/test/test_socket.py Modules/arraymodule.c Modules/bytebufmodule.c Modules/socketmodule.c Message-ID: <20060524101151.117341E4009@bag.python.org> Author: martin.blais Date: Wed May 24 12:11:49 2006 New Revision: 46159 Modified: python/branches/blais-bytebuf/Lib/socket.py python/branches/blais-bytebuf/Lib/test/test_socket.py python/branches/blais-bytebuf/Modules/arraymodule.c python/branches/blais-bytebuf/Modules/bytebufmodule.c python/branches/blais-bytebuf/Modules/socketmodule.c Log: Implemented socket.socket.recv_buf Modified: python/branches/blais-bytebuf/Lib/socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/socket.py (original) +++ python/branches/blais-bytebuf/Lib/socket.py Wed May 24 12:11:49 2006 @@ -140,7 +140,7 @@ __doc__ = _realsocket.__doc__ - __slots__ = ["_sock", "send", "recv", "sendto", "recvfrom", + __slots__ = ["_sock", "send", "recv", "recv_buf", "sendto", "recvfrom", "__weakref__"] def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): @@ -149,6 +149,7 @@ self._sock = _sock self.send = self._sock.send self.recv = self._sock.recv + self.recv_buf = self._sock.recv_buf self.sendto = self._sock.sendto self.recvfrom = self._sock.recvfrom Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_socket.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_socket.py Wed May 24 12:11:49 2006 @@ -9,6 +9,8 @@ import thread, threading import Queue import sys +import array +import bytebuf from weakref import proxy PORT = 50007 @@ -852,6 +854,103 @@ self.assertRaises(socket.error, s.bind, address) +class BufferIOTest(SocketConnectedTest): + """ + Test the buffer versions of socket.recv() and socket.send(). + """ + def __init__(self, methodName='runTest'): + SocketConnectedTest.__init__(self, methodName=methodName) + + def testRecv(self): + # Receive into the buffer of an array class. + buf = array.array('c', ' '*1024) + nbytes = self.cli_conn.recv_buf(buf) + self.assertEqual(nbytes, len(MSG)) + trunc = buf.tostring()[:len(MSG)] + self.assertEqual(trunc, MSG) + + def _testRecv(self): + # Send using a read-only buffer. + buf = buffer(MSG) + self.serv_conn.send(buf) + + def testRecvBB(self): + # Receive into the buffer of an array class. + buf = bytebuf.bytebuf(1024) + nbytes = self.cli_conn.recv_buf(buf) + self.assertEqual(nbytes, len(MSG)) + trunc = str(buf)[:len(MSG)] + self.assertEqual(trunc, MSG) + + def _testRecvBB(self): + # Send using a read-only buffer. +## buf = bytebuf.bytebuf(MSG) + self.serv_conn.send(MSG) + +## def testOverFlowRecv(self): +## # Testing receive in chunks over TCP +## seg1 = self.cli_conn.recv(len(MSG) - 3) +## seg2 = self.cli_conn.recv(1024) +## msg = seg1 + seg2 +## self.assertEqual(msg, MSG) + +## def _testOverFlowRecv(self): +## self.serv_conn.send(MSG) + +## def testRecvFrom(self): +## # Testing large recvfrom() over TCP +## msg, addr = self.cli_conn.recvfrom(1024) +## self.assertEqual(msg, MSG) + +## def _testRecvFrom(self): +## self.serv_conn.send(MSG) + +## def testOverFlowRecvFrom(self): +## # Testing recvfrom() in chunks over TCP +## seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) +## seg2, addr = self.cli_conn.recvfrom(1024) +## msg = seg1 + seg2 +## self.assertEqual(msg, MSG) + +## def _testOverFlowRecvFrom(self): +## self.serv_conn.send(MSG) + +## def testSendAll(self): +## # Testing sendall() with a 2048 byte string over TCP +## msg = '' +## while 1: +## read = self.cli_conn.recv(1024) +## if not read: +## break +## msg += read +## self.assertEqual(msg, 'f' * 2048) + +## def _testSendAll(self): +## big_chunk = 'f' * 2048 +## self.serv_conn.sendall(big_chunk) + +## def testFromFd(self): +## # Testing fromfd() +## if not hasattr(socket, "fromfd"): +## return # On Windows, this doesn't exist +## fd = self.cli_conn.fileno() +## sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) +## msg = sock.recv(1024) +## self.assertEqual(msg, MSG) + +## def _testFromFd(self): +## self.serv_conn.send(MSG) + +## def testShutdown(self): +## # Testing shutdown() +## msg = self.cli_conn.recv(1024) +## self.assertEqual(msg, MSG) + +## def _testShutdown(self): +## self.serv_conn.send(MSG) +## self.serv_conn.shutdown(2) + + def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions] if sys.platform != 'mac': @@ -870,5 +969,9 @@ tests.append(TestLinuxAbstractNamespace) test_support.run_unittest(*tests) +def test_main2(): + tests = [BufferIOTest] + test_support.run_unittest(*tests) + if __name__ == "__main__": - test_main() + test_main2() Modified: python/branches/blais-bytebuf/Modules/arraymodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/arraymodule.c (original) +++ python/branches/blais-bytebuf/Modules/arraymodule.c Wed May 24 12:11:49 2006 @@ -1975,9 +1975,9 @@ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)array_repr, /* tp_repr */ - 0, /* tp_as _number*/ - &array_as_sequence, /* tp_as _sequence*/ - &array_as_mapping, /* tp_as _mapping*/ + 0, /* tp_as_number*/ + &array_as_sequence, /* tp_as_sequence*/ + &array_as_mapping, /* tp_as_mapping*/ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ Modified: python/branches/blais-bytebuf/Modules/bytebufmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/bytebufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/bytebufmodule.c Wed May 24 12:11:49 2006 @@ -1,4 +1,6 @@ -/* Bytebuf object interface */ +/* =========================================================================== + * Bytebuf object + */ #include "Python.h" @@ -25,7 +27,10 @@ #endif /* !Py_BYTEBUFOBJECT_H */ -/* Byte Buffer object implementation */ +/* =========================================================================== + * Byte Buffer object implementation + */ + /* * bytebuf object structure declaration. @@ -47,6 +52,11 @@ * Given a bytebuf object, return the buffer memory (in 'ptr' and 'size') and * true if there was no error. */ + + +/* FIXME remove get_buf() everywhere, at least the checks for the return + value. */ + static int get_buf(PyBytebufObject *self, void **ptr, Py_ssize_t *size) { @@ -217,27 +227,25 @@ return size; } +/* =========================================================================== + * Sequence methods + */ -PyDoc_STRVAR(module_doc, - "This module defines an object type which can represent a fixed size\n\ -buffer of bytes in momery, from which you can directly read and into\n\ -which you can directly write objects in various other types. This is\n\ -used to avoid buffer copies in network I/O as much as possible. For\n\ -example, socket recv() can directly fill a byte buffer's memory and\n\ -send() can read the data to be sent from one as well.\n\ -\n\ -In addition, a byte buffer has two pointers within it, that delimit\n\ -an active slice, the current \"position\" and the \"limit\". The\n\ -active region of a byte buffer is located within these boundaries.\n\ -\n\ -This class is heaviliy inspired from Java's NIO ByteBuffer class.\n\ -\n\ -The constructor is:\n\ -\n\ -bytebuf(nbytes) -- create a new bytebuf\n\ -"); +static Py_ssize_t +bytebuf_length(PyBytebufObject *self) +{ + void *ptr; + Py_ssize_t size; + if (!get_buf(self, &ptr, &size)) + return -1; + return size; +} +/* =========================================================================== + * Object interfaces declaration + */ + /* FIXME: needs an update */ /* PyDoc_STRVAR(bytebuf_doc, */ @@ -260,6 +268,16 @@ "); +static PySequenceMethods bytebuf_as_sequence = { + (lenfunc)bytebuf_length, /*sq_length*/ + 0 /* (binaryfunc)bytebuf_concat */, /*sq_concat*/ + 0 /* (ssizeargfunc)bytebuf_repeat */, /*sq_repeat*/ + 0 /* (ssizeargfunc)bytebuf_item */, /*sq_item*/ + 0 /*(ssizessizeargfunc)bytebuf_slice*/, /*sq_slice*/ + 0 /*(ssizeobjargproc)bytebuf_ass_item*/, /*sq_ass_item*/ + 0 /*(ssizessizeobjargproc)bytebuf_ass_slice*/, /*sq_ass_slice*/ +}; + static PyBufferProcs bytebuf_as_buffer = { (readbufferproc)bytebuf_getwritebuf, (writebufferproc)bytebuf_getwritebuf, @@ -273,18 +291,18 @@ "bytebuf", sizeof(PyBytebufObject), 0, - (destructor)bytebuf_dealloc, /* tp_dealloc */ + (destructor)bytebuf_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ (cmpfunc)bytebuf_compare, /* tp_compare */ - (reprfunc)bytebuf_repr, /* tp_repr */ + (reprfunc)bytebuf_repr, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &bytebuf_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc)bytebuf_str, /* tp_str */ + (reprfunc)bytebuf_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &bytebuf_as_buffer, /* tp_as_buffer */ @@ -306,11 +324,33 @@ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - bytebuf_new, /* tp_new */ + bytebuf_new, /* tp_new */ }; -/*********************** Install Module **************************/ +/* =========================================================================== + * Install Module + */ + +PyDoc_STRVAR(module_doc, + "This module defines an object type which can represent a fixed size\n\ +buffer of bytes in momery, from which you can directly read and into\n\ +which you can directly write objects in various other types. This is\n\ +used to avoid buffer copies in network I/O as much as possible. For\n\ +example, socket recv() can directly fill a byte buffer's memory and\n\ +send() can read the data to be sent from one as well.\n\ +\n\ +In addition, a byte buffer has two pointers within it, that delimit\n\ +an active slice, the current \"position\" and the \"limit\". The\n\ +active region of a byte buffer is located within these boundaries.\n\ +\n\ +This class is heaviliy inspired from Java's NIO ByteBuffer class.\n\ +\n\ +The constructor is:\n\ +\n\ +bytebuf(nbytes) -- create a new bytebuf\n\ +"); + /* No functions in array module. */ static PyMethodDef a_methods[] = { Modified: python/branches/blais-bytebuf/Modules/socketmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/socketmodule.c (original) +++ python/branches/blais-bytebuf/Modules/socketmodule.c Wed May 24 12:11:49 2006 @@ -2135,95 +2135,126 @@ #endif /* NO_DUP */ - -/* s.recv(nbytes [,flags]) method */ - -static PyObject * -sock_recv(PySocketSockObject *s, PyObject *args) +/* + * This is the guts of the recv() and recv_buf() methods, which reads into a + * char buffer. If you have any inc/def ref to do to the objects that contain + * the buffer, do it in the caller. This function returns the number of bytes + * succesfully read. If there was an error, it returns -1. Note that it is + * also possible that we return a number of bytes smaller than the request + * bytes. + */ +static int +sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags) { - int len, n = 0, flags = 0, timeout; - PyObject *buf; + int timeout, outlen = 0; #ifdef __VMS - int read_length; + int remaining, nread; char *read_buf; #endif - if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) - return NULL; - - if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); - return NULL; + if (!IS_SELECTABLE(s)) { + select_error(); + return -1; } - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) - return NULL; - - if (!IS_SELECTABLE(s)) - return select_error(); - #ifndef __VMS Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); + outlen = recv(s->sock_fd, cbuf, len, flags); Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + if (outlen < 0) { + /* Note: the call to errorhandler() ALWAYS indirectly returned + NULL, so ignore its return value */ + s->errorhandler(); + return -1; } - if (n != len) - _PyString_Resize(&buf, n); #else - read_buf = PyString_AsString(buf); - read_length = len; - while (read_length != 0) { + read_buf = cbuf; + remaining = len; + while (remaining != 0) { unsigned int segment; - segment = read_length /SEGMENT_SIZE; + segment = remaining /SEGMENT_SIZE; if (segment != 0) { segment = SEGMENT_SIZE; } else { - segment = read_length; + segment = remaining; } Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - n = recv(s->sock_fd, read_buf, segment, flags); + nread = recv(s->sock_fd, read_buf, segment, flags); Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + if (nread < 0) { + s->errorhandler(); + return -1; } - if (n != read_length) { - read_buf += n; + if (nread != remaining) { + read_buf += nread; break; } - read_length -= segment; + remaining -= segment; read_buf += segment; } - if (_PyString_Resize(&buf, (read_buf - PyString_AsString(buf))) < 0) - { - return NULL; - } + outlen = read_buf - cbuf; #endif /* !__VMS */ + + return outlen; +} + + +/* s.recv(nbytes [,flags]) method */ + +static PyObject * +sock_recv(PySocketSockObject *s, PyObject *args) +{ + int recvlen, flags = 0, outlen; + PyObject *buf; + + if (!PyArg_ParseTuple(args, "i|i:recv", &recvlen, &flags)) + return NULL; + + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); + return NULL; + } + + /* Allocate a new string. */ + buf = PyString_FromStringAndSize((char *) 0, recvlen); + if (buf == NULL) + return NULL; + + /* Call the guts */ + outlen = sock_recv_guts(s, PyString_AsString(buf), recvlen, flags); + if (outlen < 0) { + /* An error occured, release the string and return an + error. */ + Py_DECREF(buf); + return NULL; + } + if (outlen != recvlen) { + /* We did not read as many bytes as we anticipated, resize the + string if possible and be succesful. */ + if (_PyString_Resize(&buf, outlen) < 0) + /* Oopsy, not so succesful after all. */ + return NULL; + } + return buf; } @@ -2236,6 +2267,62 @@ the remote end is closed and all data is read, return the empty string."); +/* s.recv_buf(buffer, [nbytes [,flags]]) method */ + +static PyObject* +sock_recv_buf(PySocketSockObject *s, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; + + int recvlen = 0, flags = 0, readlen; + char *buf; + int buflen; + + /* Get the buffer's memory */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recv", kwlist, + &buf, &buflen, &recvlen, &flags)) + return NULL; + assert(buf != 0 && buflen > 0); + + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); + return NULL; + } + if (recvlen == 0) { + /* If nbytes was not specified, use the buffer's length */ + recvlen = buflen; + } + + /* Check if the buffer is large enough */ + if (buflen < recvlen) { + PyErr_SetString(PyExc_ValueError, + "buffer too small for requested bytes"); + return NULL; + } + + /* Call the guts */ + readlen = sock_recv_guts(s, buf, recvlen, flags); + if (readlen < 0) { + /* Return an error. */ + return NULL; + } + + /* Return the number of bytes read. Note that we do not do anything + special here in the case that readlen < recvlen. */ + return PyInt_FromLong(readlen); +} + +PyDoc_STRVAR(recv_buf_doc, +"recv_buf(buffer, [nbytes[, flags]]) -> nbytes_read\n\ +\n\ +A version of recv() that stores its data into a buffer rather than creating \n\ +a new string. Receive up to buffersize bytes from the socket. If buffersize \n\ +is not specified (or 0), receive up to the size available in the given buffer.\n\ +\n\ +See recv() for documentation about the flags."); + + /* s.recvfrom(nbytes [,flags]) method */ static PyObject * @@ -2535,6 +2622,8 @@ #endif {"recv", (PyCFunction)sock_recv, METH_VARARGS, recv_doc}, + {"recv_buf", (PyCFunction)sock_recv_buf, METH_VARARGS | METH_KEYWORDS, + recv_buf_doc}, {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, recvfrom_doc}, {"send", (PyCFunction)sock_send, METH_VARARGS, From python-checkins at python.org Wed May 24 12:18:36 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 12:18:36 +0200 (CEST) Subject: [Python-checkins] r46160 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Message-ID: <20060524101836.AE8801E4009@bag.python.org> Author: georg.brandl Date: Wed May 24 12:18:35 2006 New Revision: 46160 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Log: Changes so far. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 12:18:35 2006 @@ -76,7 +76,7 @@ #define S_UNDERFLOW 6 #define S_SUBNORMAL 7 -/* Other conditions (for context_raise_error) */ +/* Other conditions, all raising S_INV_OPERATION. */ #define NUMCONDITIONS 4 @@ -106,82 +106,186 @@ static PyObject *errors[NUMSIGNALS+NUMCONDITIONS]; -#define MAKE_METHODDEF(name) \ - static PyMethodDef ml_##name = {"handle", (PyCFunction)handle_##name, \ - METH_VARARGS}; +/* Forward */ +static decimalobject *_new_decimalobj(PyTypeObject *, long, char, long); + + +#define HANDLE_ERROR(ctx, cond, expl) \ + int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ + if (! ISFLAGSET(ctx->ignored, err)) { \ + SETFLAG(ctx->flags, err); \ + if (ISFLAGSET(ctx->traps, err)) { \ + PyErr_SetString(errors[err], (expl ? expl : "")); \ + return NULL; \ + } \ + } -/* These are the "handle" methods for the individual exception classes. - * They are attached in init_decimal. */ static PyObject * -handle_DecimalException(PyObject *self, PyObject *args) +handle_Clamped(PyTypeObject *type, contextobject *ctx, char *expl) { - /* XXX: implement */ + HANDLE_ERROR(ctx, S_CLAMPED, expl); Py_RETURN_NONE; } -MAKE_METHODDEF(DecimalException) -static PyObject * -handle_InvalidOperation(PyObject *self, PyObject *args) +static decimalobject * +handle_InvalidOperation(PyTypeObject *type, contextobject *ctx, + char *expl, decimalobject *thing) { - Py_RETURN_NONE; + decimalobject *res; + long sign, i; + + if (thing == NULL) { + Py_INCREF(PyDecimal_NaN); + return (decimalobject *)PyDecimal_NaN; + } + assert(PyDecimal_Check(thing)); + /* we want to return a NaN, but keep diagnostics */ + sign = (thing->sign == 0 ? SIGN_POSNAN : SIGN_NEGNAN); + res = _new_decimalobj(type, thing->ob_size, sign, 0); + if (!res) return NULL; + for (i = 0; i < thing->ob_size; i++) + res->digits[i] = thing->digits[i]; + return res; } -MAKE_METHODDEF(InvalidOperation) -static PyObject * -handle_ConversionSyntax(PyObject *self, PyObject *args) +static decimalobject * +handle_ConversionSyntax(PyTypeObject *type, contextobject *ctx, char *expl) +{ + HANDLE_ERROR(ctx, C_CONV_SYNTAX, expl); + + Py_INCREF(PyDecimal_NaN); + return PyDecimal_NaN; +} + +static decimalobject * +handle_DivisionByZero(PyTypeObject *type, contextobject *ctx, char *expl, + long sign, int two) { + HANDLE_ERROR(ctx, S_DIV_BY_ZERO, expl); + + /* XXX: return tuple */ Py_RETURN_NONE; } -MAKE_METHODDEF(ConversionSyntax) -static PyObject * -handle_DivisionByZero(PyObject *self, PyObject *args) +static decimalobject * +handle_DivisionImpossible(PyTypeObject *type, contextobject *ctx, char *expl) { + HANDLE_ERROR(ctx, C_DIV_IMPOSSIBLE, expl); + + /* XXX: return tuple */ Py_RETURN_NONE; } -MAKE_METHODDEF(DivisionByZero) + +static decimalobject * +handle_DivisionUndefined(PyTypeObject *type, contextobject *ctx, + char *expl, int two) +{ + HANDLE_ERROR(ctx, C_DIV_UNDEFINED, expl); + + /* XXX: return tuple? */ + + Py_INCREF(PyDecimal_NaN); + return PyDecimal_NaN; +} static PyObject * -handle_DivisionImpossible(PyObject *self, PyObject *args) +handle_Inexact(PyTypeObject *type, contextobject *ctx, char *expl) { + HANDLE_ERROR(ctx, S_INEXACT, expl); Py_RETURN_NONE; } -MAKE_METHODDEF(DivisionImpossible) + +static decimalobject * +handle_InvalidContext(PyTypeObject *type, contextobject *ctx, char *expl) +{ + HANDLE_ERROR(ctx, C_INV_CONTEXT, expl); + + Py_INCREF(PyDecimal_NaN); + return PyDecimal_NaN; +} static PyObject * -handle_DivisionUndefined(PyObject *self, PyObject *args) +handle_Rounded(PyTypeObject *type, contextobject *ctx, char *expl) { + HANDLE_ERROR(ctx, S_ROUNDED, expl); + Py_RETURN_NONE; } -MAKE_METHODDEF(DivisionUndefined) static PyObject * -handle_InvalidContext(PyObject *self, PyObject *args) +handle_Subnormal(PyTypeObject *type, contextobject *ctx, char *expl) { + HANDLE_ERROR(ctx, S_SUBNORMAL, expl); + Py_RETURN_NONE; } -MAKE_METHODDEF(InvalidContext) + +static decimalobject * +handle_Overflow(PyTypeObject *type, contextobject *ctx, char *expl, long lsign) +{ + decimalobject *res; + long i; + + HANDLE_ERROR(ctx, S_OVERFLOW, expl); + + assert(lsign == 0 || lsign == 1); + + if (ctx->rounding == ROUND_HALF_UP || + ctx->rounding == ROUND_HALF_EVEN || + ctx->rounding == ROUND_HALF_DOWN || + ctx->rounding == ROUND_UP) { + + res = (decimalobject *)(lsign == 0 ? PyDecimal_Inf : PyDecimal_NegInf); + } else if (lsign == 0) { + if (ctx->rounding == ROUND_CEILING) + res = (decimalobject *)PyDecimal_Inf; + else { + res = _new_decimalobj(type, ctx->prec, + lsign, ctx->Emax - ctx->prec + 1); + if (res) { + for (i = 0; i < ctx->prec; i++) + res->digits[i] = 9; + return res; + } + } + } else if (lsign == 1) { + if (ctx->rounding == ROUND_FLOOR) + res = (decimalobject *)PyDecimal_NegInf; + else { + res = _new_decimalobj(type, ctx->prec, + lsign, ctx->Emax - ctx->prec + 1); + if (res) { + for (i = 0; i < ctx->prec; i++) + res->digits[i] = 9; + return res; + } + } + } + Py_XINCREF(res); + return res; +} static PyObject * -handle_Overflow(PyObject *self, PyObject *args) +handle_Underflow(PyTypeObject *type, contextobject *ctx, char *expl) { + HANDLE_ERROR(ctx, S_UNDERFLOW, expl); + Py_RETURN_NONE; } -MAKE_METHODDEF(Overflow) + /* Forwarding ****************************************************************/ static contextobject *getcontext(void); static int setcontext(contextobject *); -static decimalobject *context_raise_error(contextobject *, int, char *, PyObject *); static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); static int decimal_nonzero(decimalobject *); -static decimalobject *decimal_copy(decimalobject *); +static decimalobject *_decimal_get_copy(decimalobject *); static decimalobject *_decimal_from_pylong(PyTypeObject *, PyObject *, contextobject *); -static PyObject * py_context_shallow_copy(PyObject *, PyObject *, PyObject *); -static contextobject * context_shallow_copy(contextobject *); +static contextobject * context_copy(contextobject *); static PyObject *decimal_from_long(PyTypeObject *, long); +static PyObject *decimal_str(decimalobject *); /* Decimal methods ***********************************************************/ @@ -210,16 +314,18 @@ return new; } +/* shortcut to use in methods */ #define _NEW_decimalobj(ndigits, sign, exp) \ _new_decimalobj(self->ob_type, ndigits, sign, exp) /* Check whether the number(s) aren't really numbers. * * If x and/or y are sNaN, signal, possibly storing the result - * of handle() in res (and return 1) - * If x and/or y are NaN, store NaN in res (and return 1) + * of handle() in res and returning 1 + * or raising and returning -1 + * If x and/or y are NaN, store NaN in res and return 1 * else return 0. - * On an unexpected error, return -1. + * If an exception was set, return -1. */ static int _check_nans(decimalobject *x, decimalobject *y, contextobject *ctx, decimalobject **res) @@ -231,31 +337,23 @@ nan2 = GETNAN(y); if (nan1 || nan2) { - PyObject *tup; - if (nan1 == 2) { - tup = Py_BuildValue("iO", 1, x); - if (!tup) - return -1; - *res = context_raise_error(ctx, S_INV_OPERATION, "sNaN", tup); + *res = handle_InvalidOperation(x->ob_type, ctx, "sNaN", x); if (*res == NULL) return -1; return 1; } else if (nan2 == 2) { - tup = Py_BuildValue("iO", 1, y); - if (!tup) - return -1; - *res = context_raise_error(ctx, S_INV_OPERATION, "sNaN", tup); + *res = handle_InvalidOperation(y->ob_type, ctx, "sNaN", y); if (*res == NULL) return -1; return 1; } - + if (nan1) *res = x; else *res = y; - /* since context_raise_error above returns new references, to be + /* since handle_InvalidOperation above returns new references, to be * consistent we must incref the returns here too. */ Py_INCREF(*res); return 1; @@ -277,7 +375,7 @@ if (res != 0) return nan; /* I'm infinite, so incrementing makes no difference. */ - return decimal_copy(self); + return _decimal_get_copy(self); } new = _NEW_decimalobj(self->ob_size + 1, /* we possibly need a new digit */ @@ -463,8 +561,9 @@ static decimalobject * _decimal_round(decimalobject *self, long prec, contextobject *ctx, int rounding) { - decimalobject *new, *new2 = NULL, *errres; + decimalobject *new, *new2 = NULL; contextobject *ctx2 = NULL; + PyObject *errres; long i, expdiff; round_func rnd_func; @@ -473,7 +572,7 @@ int ret; ret = _check_nans(self, NULL, ctx, &nan); if (ret != 0) return nan; - if (ISINF(self)) return decimal_copy(self); + if (ISINF(self)) return _decimal_get_copy(self); } if (rounding == -1) rounding = ctx->rounding; @@ -497,7 +596,7 @@ while (i--) new->digits[i] = 0; - errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + errres = handle_Rounded(self->ob_type, ctx, NULL); if (!errres) { Py_DECREF(new); return NULL; /* error was set */ @@ -521,7 +620,7 @@ new->digits[1] = 1; prec = 1; } else { - new = decimal_copy(self); + new = _decimal_get_copy(self); if (!new) return NULL; } @@ -553,7 +652,7 @@ /* All lost digits are 0, so just clobber new */ new->ob_size = prec; new->exp -= expdiff; - errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + errres = handle_Rounded(self->ob_type, ctx, NULL); if (!errres) { Py_DECREF(new); return NULL; @@ -565,7 +664,7 @@ /* Now rounding starts. We still own "new". */ rnd_func = round_funcs[rounding]; if (prec != ctx->prec) { - ctx2 = (contextobject *)context_shallow_copy(ctx); + ctx2 = (contextobject *)context_copy(ctx); if (!ctx2) { Py_DECREF(new); return NULL; @@ -573,16 +672,16 @@ ctx2->prec = prec; ctx = ctx2; } - /* ctx2 is NULL if the original context is used, and that one + /* ctx2 is NULL if the original context is used, because that one * doesn't have to be DECREF'd. */ new2 = rnd_func(new, prec, expdiff, ctx); Py_DECREF(new); if (!new2) goto error; - errres = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + errres = handle_Rounded(self->ob_type, ctx, NULL); if (!errres) goto error; - errres = context_raise_error(ctx, S_INEXACT, "Changed in rounding", NULL); + errres = handle_Rounded(self->ob_type, ctx, "Changed in rounding"); if (!errres) goto error; Py_XDECREF(ctx2); @@ -606,7 +705,8 @@ if (ISSPECIAL(self)) { if (ISINF(self)) - return context_raise_error(ctx, S_INV_OPERATION, "rescale with an INF", NULL); + return handle_InvalidOperation(self->ob_type, ctx, + "rescale with an INF", NULL); ret = _check_nans(self, NULL, ctx, &ans); if (ret != 0) /* ans is NULL in case of an error */ @@ -614,7 +714,8 @@ } if (watchexp && (exp > ctx->Emax || exp < ETINY(ctx))) - return context_raise_error(ctx, S_INV_OPERATION, "rescale(a, INF)", NULL); + return handle_InvalidOperation(self->ob_type, ctx, + "rescale(a, INF)", NULL); if (!decimal_nonzero(self)) { ans = _NEW_decimalobj(1, self->sign, exp); @@ -628,7 +729,8 @@ digits = self->ob_size + diff; if (watchexp && ctx->prec < digits) - return context_raise_error(ctx, S_INV_OPERATION, "Rescale > prec", NULL); + return handle_InvalidOperation(self->ob_type, ctx, + "Rescale > prec", NULL); digits += 1; if (digits < 0) { @@ -663,12 +765,12 @@ adj = ADJUSTED(tmp); if (decimal_nonzero(tmp)) { if (adj < ctx->Emin) { - ans = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + ans = handle_Subnormal(self->ob_type, ctx, NULL); Py_DECREF(tmp); return ans; } else if (adj > ctx->Emax) { - ans = context_raise_error(ctx, S_INV_OPERATION, - "rescale(a, INF)", NULL); + ans = handle_InvalidOperation(self->ob_type, ctx, + "rescale(a, INF)", NULL); Py_DECREF(tmp); return ans; } @@ -682,7 +784,6 @@ _fixexponents(decimalobject *self, contextobject *ctx) { decimalobject *ans = NULL, *tmp; - PyObject *tup; long adj; assert(!ISSPECIAL(self)); @@ -691,11 +792,11 @@ long Etiny = ETINY(ctx); if (self->exp < Etiny) { if (!decimal_nonzero(self)) { - ans = decimal_copy(self); + ans = _decimal_get_copy(self); if (!ans) return NULL; ans->exp = Etiny; - tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + tmp = handle_Clamped(self->ob_type, ctx, NULL); if (!tmp) goto err; Py_DECREF(tmp); @@ -704,12 +805,12 @@ ans = _decimal_rescale(self, Etiny, ctx, -1, 1); if (!ans) return NULL; - tmp = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + tmp = handle_Subnormal(self->ob_type, ctx, NULL); if (!tmp) goto err; Py_DECREF(tmp); if (ISFLAGSET(ctx->flags, S_INEXACT)) { - tmp = context_raise_error(ctx, S_UNDERFLOW, NULL, NULL); + tmp = handle_Underflow(self->ob_type, ctx, NULL); if (!tmp) goto err; Py_DECREF(tmp); @@ -717,7 +818,7 @@ return ans; } else { if (decimal_nonzero(self)) { - tmp = context_raise_error(ctx, S_SUBNORMAL, NULL, NULL); + tmp = handle_Subnormal(self->ob_type, ctx, NULL); if (!tmp) return NULL; Py_DECREF(tmp); @@ -727,7 +828,7 @@ } else { long Etop = ETOP(ctx); if (ctx->clamp && self->exp > Etop) { - tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + tmp = handle_Clamped(self->ob_type, ctx, NULL); if (!tmp) return NULL; Py_DECREF(tmp); @@ -738,30 +839,25 @@ } else { if (adj > ctx->Emax) { if (!decimal_nonzero(self)) { - ans = decimal_copy(self); + ans = _decimal_get_copy(self); if (!ans) return NULL; ans->exp = ctx->Emax; - tmp = context_raise_error(ctx, S_CLAMPED, NULL, NULL); + tmp = handle_Clamped(self->ob_type, ctx, NULL); if (!tmp) goto err; Py_DECREF(tmp); return ans; } - tmp = context_raise_error(ctx, S_INEXACT, NULL, NULL); + tmp = handle_Inexact(self->ob_type, ctx, NULL); if (!tmp) return NULL; Py_DECREF(tmp); - tmp = context_raise_error(ctx, S_ROUNDED, NULL, NULL); + tmp = handle_Rounded(self->ob_type, ctx, NULL); if (!tmp) return NULL; Py_DECREF(tmp); - tup = Py_BuildValue("(b)", self->sign); - if (!tup) - return NULL; - ans = context_raise_error(ctx, S_OVERFLOW, "above Emax", tup); - Py_DECREF(tup); - return ans; + return handle_Overflow(self->ob_type, ctx, "above Emax", self->sign); } } } @@ -801,10 +897,13 @@ return ans; } -/* convert something to a Decimal. Returns NULL on failure, but - * does not set an exception! */ +/* convert something to a Decimal. On failure, either + returns NotImplemented or raises an exception, depending + on the raise argument. +*/ static decimalobject * -_convert_to_decimal(PyTypeObject *type, PyObject *thing, contextobject *ctx) +_convert_to_decimal(PyTypeObject *type, PyObject *thing, + contextobject *ctx, int raise) { if (PyDecimal_Check(thing)) { Py_INCREF(thing); @@ -817,7 +916,13 @@ } else if (PyLong_Check(thing)) { return _decimal_from_pylong(type, thing, ctx); } - return NULL; + /* failed to convert */ + if (raise) { + PyErr_SetString(PyExc_TypeError, "Cannot convert to a Decimal"); + return NULL; + } + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } #define STUB_HEAD static PyObject * @@ -947,8 +1052,8 @@ Py_INCREF(self); return self; } - return context_raise_error(ctx, S_INV_OPERATION, - "quantize with one INF", NULL); + return handle_InvalidOperation(self->ob_type, ctx, + "quantize with one INF", NULL); } } return _decimal_rescale(self, other->exp, ctx, rounding, watchexp); @@ -997,11 +1102,41 @@ STUB(sqrt) STUB(to_eng_string) STUB(to_integral) -STUB(reduce) -STUB(deepcopy) + +static PyObject * +decimal_reduce(decimalobject *self) +{ + PyObject *str, *val; + + str = decimal_str(self); + if (!str) return NULL; + + val = Py_BuildValue("(O(O))", self->ob_type, str); + Py_DECREF(str); + return val; +} + + +/* Decimals are immutable, therefore copy() returns self. */ +static PyObject * +decimal_copy_method(PyObject *self) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +decimal_deepcopy(PyObject *self, PyObject *memo) +{ + Py_INCREF(self); + return self; +} + +/* For internal use, this does what Python code achieves + with "Decimal(self)". */ static decimalobject * -decimal_copy(decimalobject *self) +_decimal_get_copy(decimalobject *self) { decimalobject *new; long i; @@ -1102,7 +1237,7 @@ "inexact, rounded.")}, {"__reduce__", (PyCFunction)decimal_reduce, METH_NOARGS}, - {"__copy__", (PyCFunction)decimal_copy, + {"__copy__", (PyCFunction)decimal_copy_method, METH_NOARGS}, {"__deepcopy__", decimal_deepcopy, METH_O}, @@ -1112,8 +1247,59 @@ static char decimal_doc[] = PyDoc_STR("Floating point class for decimal arithmetic."); -STUB(add) -STUB(subtract) + +#define DECIMAL_SPECIAL_FUNC(func) \ + static PyObject * \ + func (decimalobject *self, decimalobject *other) { \ + contextobject *ctx = getcontext(); \ + if (!ctx) return NULL; \ + return (PyObject *)_do_##func(self, other, ctx); \ + } + +static PyObject * +_do_decimal_add(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ + other = _convert_to_decimal(self->ob_type, other, ctx, 0); + if (other == Py_NotImplemented) return other; + + /* XXX */ +} +DECIMAL_SPECIAL_FUNC(decimal_add) + +static decimalobject * +_do_decimal_subtract(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ + decimalobject *copy, *res; + + other = _convert_to_decimal(self->ob_type, other, ctx, 0); + if (other == Py_NotImplemented) return other; + + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan; + if (_check_nans(self, other, ctx, &nan) != 0) { + Py_DECREF(other); + return nan; + } + } + + copy = _decimal_get_copy(other); + Py_DECREF(other); + if (!copy) + return NULL; + /* flip sign */ + if (copy->sign & 1) + copy->sign--; + else + copy->sign++; + + res = _do_decimal_add(self, copy, ctx); + Py_DECREF(copy); + return res; +} +DECIMAL_SPECIAL_FUNC(decimal_subtract) + STUB(multiply) STUB(divide) STUB(remainder) @@ -1123,9 +1309,53 @@ STUB1(positive) STUB1(absolute) STUB1(invert) -STUB1(int) -STUB1(long) -STUB1(float) + + +static PyObject * +decimal_int(decimalobject *self) +{ + if (ISSPECIAL(self)) + if (GETNAN(self)) { + contextobject *ctx; + ctx = getcontext(); + if (!ctx) return NULL; + return handle_InvalidContext(self->ob_type, ctx, NULL); + } else if (ISINF(self)) { + PyErr_SetString(PyExc_OverflowError, "Cannot convert infinity to long"); + return NULL; + } + +} + + +static PyObject * +decimal_long(decimalobject *self) +{ + PyObject *tmp, *res; + tmp = decimal_int(self); + if (PyInt_Check(tmp)) { + res = PyLong_FromLong(PyInt_AsLong(tmp)); + Py_DECREF(tmp); + return res; + } else { + /* it's already a long */ + assert(PyLong_Check(tmp)); + return tmp; + } +} + +static PyObject * +decimal_float(decimalobject *self) +{ + PyObject *str, *res; + str = decimal_str(self); + if (!str) return NULL; + + res = PyFloat_FromString(str, NULL); + Py_DECREF(str); + return res; +} + STUB(floor_div) STUB(true_div) @@ -1241,9 +1471,9 @@ if (len < 4) goto finish; p = str+3; } else if (tolower(str[0]) == 's' && - tolower(str[1]) == 'n' && - tolower(str[2]) == 'a' && - tolower(str[3]) == 'n') { + tolower(str[1]) == 'n' && + tolower(str[2]) == 'a' && + tolower(str[3]) == 'n') { sign = (literalsign ? SIGN_NEGSNAN : SIGN_POSSNAN); if (len < 5) goto finish; p = str+4; @@ -1262,8 +1492,7 @@ finish: if (size > ctx->prec) - return context_raise_error(ctx, C_CONV_SYNTAX, - "diagnostic info too long", NULL); + return handle_ConversionSyntax(type, ctx, "diagnostic info too long"); new = _new_decimalobj(type, size, sign, 0); if (!new) @@ -1388,8 +1617,7 @@ return new; err: - return context_raise_error(ctx, C_CONV_SYNTAX, - "invalid literal for Decimal", NULL); + return handle_ConversionSyntax(type, ctx, "invalid literal for Decimal"); } static PyObject * @@ -1415,7 +1643,7 @@ return decimal_from_string(&PyDecimal_DecimalType, buffer, buf_len, ctx); } -PyObject * +static PyObject * decimal_from_long(PyTypeObject *type, long value) { decimalobject *new; @@ -1455,7 +1683,7 @@ } /* convert from a 3-tuple of (sign, digits, exp) */ -PyObject * +static PyObject * decimal_from_sequence(PyTypeObject *type, PyObject *seq) { decimalobject *new = NULL; @@ -1575,11 +1803,11 @@ decimalobject *new = _new_decimalobj(type, 1, 0, 0); if (!new) return NULL; new->digits[0] = 0; - return new; + return (PyObject *)new; } if (PyDecimal_Check(value)) - return (PyObject *)decimal_copy((decimalobject *)value); + return (PyObject *)_decimal_get_copy((decimalobject *)value); if (PyFloat_Check(value)) { PyErr_SetString(PyExc_TypeError, "Cannot convert float to Decimal. " @@ -1942,55 +2170,6 @@ /* Context methods ***********************************************************/ -static decimalobject * -context_raise_error(contextobject *self, int cond, char *explanation, PyObject *args) -{ - int err = cond; - PyObject *exc, *res, *func; - - /* map subclasses of InvalidOperation to InvalidOperation */ - if (cond >= NUMSIGNALS) - err = S_INV_OPERATION; - - if (ISFLAGSET(self->ignored, err)) { - exc = PyObject_CallObject(errors[err], NULL); - if (!exc) - return NULL; - func = PyObject_GetAttrString(exc, "handle"); - if (!func) { - Py_DECREF(exc); - return NULL; - } - res = PyObject_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(exc); - if (res == NULL) - return NULL; - return (decimalobject *)res; - } - - SETFLAG(self->flags, err); - if (!ISFLAGSET(self->traps, err)) { - /* Let the exception class decide how to handle the condition. */ - exc = PyObject_CallObject(errors[cond], NULL); - if (!exc) - return NULL; - func = PyObject_GetAttrString(exc, "handle"); - if (!func) { - Py_DECREF(exc); - return NULL; - } - res = PyObject_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(exc); - if (res == NULL) - return NULL; - return (decimalobject *)res; - } - - PyErr_SetString(errors[err], (explanation ? explanation : "")); - return NULL; -} #define CSTUB(name) STUB_HEAD context_##name STUB_TAIL @@ -2001,13 +2180,55 @@ Py_RETURN_NONE; } -static PyObject * -context_copy(contextobject *self) +/* As a C Context doesn't have mutable attributes, this is the + same as Context._shallow_copy. */ +static contextobject * +context_copy(contextobject *ctx) { - return NULL; + return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, ctx->traps, + ctx->flags, ctx->Emin, ctx->Emax, ctx->capitals, ctx->clamp, + ctx->ignored); } -CSTUB(create_decimal) +static decimalobject * +context_create_decimal(contextobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"num", 0}; + PyObject *thing = NULL; + PyObject *nargs, *nkwds; + PyObject *res, *fixed; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &thing)) + return NULL; + + if (thing == NULL) { + nargs = PyTuple_New(0); + if (!nargs) return NULL; + nkwds = PyDict_New(); + if (!nkwds) { + Py_DECREF(nargs); + return NULL; + } + if (PyDict_SetItemString(nkwds, "context", (PyObject *)self) < 0) { + Py_DECREF(nargs); + Py_DECREF(nkwds); + return NULL; + } + res = decimal_new(&PyDecimal_DecimalType, nargs, nkwds); + Py_DECREF(nargs); + Py_DECREF(nkwds); + } else { + nargs = PyTuple_Pack(2, thing, self); + if (!nargs) return NULL; + res = decimal_new(&PyDecimal_DecimalType, nargs, NULL); + Py_DECREF(nargs); + } + + fixed = _decimal_fix(res, self); + Py_DECREF(res); + return fixed; +} + static PyObject * context_Etiny(contextobject *self) @@ -2021,25 +2242,13 @@ return PyInt_FromSsize_t(ETOP(self)); } -static contextobject * -context_shallow_copy(contextobject *ctx) -{ - contextobject *cp = _new_contextobj(ctx->prec, ctx->rounding, - ctx->rounding_dec, ctx->traps, - ctx->flags, ctx->Emin, ctx->Emax, - ctx->capitals, ctx->clamp, - ctx->ignored); - return cp; -} +CSTUB(abs) -static PyObject * -py_context_shallow_copy(PyObject *self, PyObject *args, PyObject *kwds) -{ - return (PyObject *)context_shallow_copy((contextobject *)self); -} -CSTUB(abs) CSTUB(add) + + + CSTUB(compare) CSTUB(divide) CSTUB(divmod) @@ -2051,6 +2260,7 @@ CSTUB(plus) CSTUB(power) CSTUB(quantize) +CSTUB(reduce) CSTUB(remainder) CSTUB(remainder_near) CSTUB(same_quantum) @@ -2116,7 +2326,9 @@ METH_VARARGS | METH_KEYWORDS}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, - {"_shallow_copy", (PyCFunction)py_context_shallow_copy, + {"_shallow_copy", (PyCFunction)context_copy, + METH_NOARGS}, + {"__reduce__", (PyCFunction)context_reduce, METH_NOARGS}, {NULL, NULL} }; @@ -2316,31 +2528,54 @@ static PyObject * context_get_flags(contextobject *self) { - /* XXX */ - Py_RETURN_NONE; -} + PyObject *dict = NULL, *val, *dp; + int i, res; -static int -context_set_flags(contextobject *self, PyObject *value) -{ - return 0; + dict = PyDict_New(); + if (!dict) return NULL; + for (i = 0; i < NUMSIGNALS; i++) { + val = PyInt_FromLong(ISFLAGSET(self->flags, i)); + if (!val) goto err; + res = PyDict_SetItem(dict, errors[i], val); + Py_DECREF(val); + if (val < 0) goto err; + } + dp = PyDictProxy_New(dict); + Py_DECREF(dict); + return dp; + + err: + Py_XDECREF(dict); + return NULL; } static PyObject * context_get_traps(contextobject *self) { - Py_RETURN_NONE; -} + PyObject *dict = NULL, *val, *dp; + int i, res; -static int -context_set_traps(contextobject *self, PyObject *value) -{ - return 0; + dict = PyDict_New(); + if (!dict) return NULL; + for (i = 0; i < NUMSIGNALS; i++) { + val = PyInt_FromLong(ISFLAGSET(self->traps, i)); + if (!val) goto err; + res = PyDict_SetItem(dict, errors[i], val); + Py_DECREF(val); + if (val < 0) goto err; + } + dp = PyDictProxy_New(dict); + Py_DECREF(dict); + return dp; + + err: + Py_XDECREF(dict); + return NULL; } static PyGetSetDef context_getset[] = { - {"flags", (getter)context_get_flags, (setter)context_set_flags}, - {"traps", (getter)context_get_traps, (setter)context_set_traps}, + {"flags", (getter)context_get_flags, (setter)0}, + {"traps", (getter)context_get_traps, (setter)0}, {NULL} }; @@ -2352,6 +2587,8 @@ {"Emax", T_LONG, OFF(Emax), 0}, {"capitals", T_INT, OFF(capitals), 0}, {"rounding", T_INT, OFF(rounding), 0}, + {"_rounding_decision", T_INT, OFF(rounding_dec), 0}, + {"_clamp", T_INT, OFF(clamp), 0}, {NULL} }; @@ -2477,29 +2714,26 @@ return 0; } -#define ADD_CONST(m, name) \ - if (PyModule_AddIntConstant(m, #name, name) < 0) { return; } +#define ADD_CONST(m, name) \ + if (PyModule_AddIntConstant(m, #name, name) < 0) { return; } -#define INIT_EXC(m, name, base) \ - name = PyErr_NewException(MODULE_NAME "." #name, base, NULL); \ - if (!name) return; \ - Py_INCREF(name); \ - if (PyModule_AddObject(m, #name, name) < 0) { return; } - -#define INIT_EXC_WITH_FUNC(m, name, base) \ - INIT_EXC(m, name, base) \ - if (_add_handle_method(name, &ml_##name) < 0) { return; } - -#define INIT_EXC_WITH_FUNC_AND_2TUPLE(m, name, base1, base2) \ - tup = PyTuple_Pack(2, base1, base2); \ - if (!tup) return; \ - INIT_EXC_WITH_FUNC(m, name, tup) \ - Py_DECREF(tup) +#define INIT_EXC(m, name, base) \ + name = PyErr_NewException(MODULE_NAME "." #name, base, NULL); \ + if (!name) return; \ + Py_INCREF(name); \ + if (PyModule_AddObject(m, #name, name) < 0) { return; } + +#define INIT_EXC_WITH_2TUPLE(m, name, base1, base2) \ + tup = PyTuple_Pack(2, base1, base2); \ + if (!tup) return; \ + INIT_EXC(m, name, tup); \ + Py_DECREF(tup) #define INIT_EXC_WITH_3TUPLE(m, name, base1, base2, base3) \ - tup = PyTuple_Pack(3, base1, base2, base3); \ - if (!tup) return; \ - INIT_EXC(m, name, tup) + tup = PyTuple_Pack(3, base1, base2, base3); \ + if (!tup) return; \ + INIT_EXC(m, name, tup) \ + Py_DECREF(tup) PyMODINIT_FUNC @@ -2563,12 +2797,18 @@ PyDecimal_NaN = PyDecimal_FromString("nan", 3, ctx); if (!PyDecimal_NaN) return; + if (PyModule_AddObject(m, "NaN", PyDecimal_NaN) < 0) + return; PyDecimal_Inf = PyDecimal_FromString("inf", 3, ctx); if (!PyDecimal_Inf) return; + if (PyModule_AddObject(m, "Inf", PyDecimal_Inf) < 0) + return; PyDecimal_NegInf = PyDecimal_FromString("-inf", 4, ctx); if (!PyDecimal_NegInf) return; + if (PyModule_AddObject(m, "negInf", PyDecimal_NegInf) < 0) + return; ADD_CONST(m, ROUND_DOWN); ADD_CONST(m, ROUND_UP); @@ -2577,21 +2817,23 @@ ADD_CONST(m, ROUND_HALF_UP); ADD_CONST(m, ROUND_FLOOR); ADD_CONST(m, ROUND_CEILING); + ADD_CONST(m, ALWAYS_ROUND); + ADD_CONST(m, NEVER_ROUND); - INIT_EXC_WITH_FUNC(m, DecimalException, PyExc_ArithmeticError); + INIT_EXC(m, DecimalException, PyExc_ArithmeticError); INIT_EXC(m, Clamped, DecimalException); - INIT_EXC_WITH_FUNC(m, InvalidOperation, DecimalException); - INIT_EXC_WITH_FUNC(m, ConversionSyntax, InvalidOperation); - INIT_EXC_WITH_FUNC(m, DivisionImpossible, InvalidOperation); - INIT_EXC_WITH_FUNC_AND_2TUPLE(m, DivisionUndefined, - InvalidOperation, PyExc_ZeroDivisionError); - INIT_EXC_WITH_FUNC(m, InvalidContext, InvalidOperation); - INIT_EXC_WITH_FUNC_AND_2TUPLE(m, DivisionByZero, - DecimalException, PyExc_ZeroDivisionError); + INIT_EXC(m, InvalidOperation, DecimalException); + INIT_EXC(m, ConversionSyntax, InvalidOperation); + INIT_EXC(m, DivisionImpossible, InvalidOperation); + INIT_EXC_WITH_2TUPLE(m, DivisionUndefined, + InvalidOperation, PyExc_ZeroDivisionError); + INIT_EXC(m, InvalidContext, InvalidOperation); + INIT_EXC_WITH_2TUPLE(m, DivisionByZero, + DecimalException, PyExc_ZeroDivisionError); INIT_EXC(m, Inexact, DecimalException); INIT_EXC(m, Rounded, DecimalException); INIT_EXC(m, Subnormal, DecimalException); - INIT_EXC_WITH_FUNC_AND_2TUPLE(m, Overflow, Rounded, Inexact); + INIT_EXC_WITH_2TUPLE(m, Overflow, Rounded, Inexact); INIT_EXC_WITH_3TUPLE(m, Underflow, Rounded, Inexact, Subnormal); @@ -2608,4 +2850,3 @@ errors[C_DIV_IMPOSSIBLE]= DivisionImpossible; errors[C_DIV_UNDEFINED] = DivisionUndefined; } - Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Wed May 24 12:18:35 2006 @@ -136,248 +136,256 @@ import copy as _copy -#Rounding -ROUND_DOWN = 'ROUND_DOWN' -ROUND_HALF_UP = 'ROUND_HALF_UP' -ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' -ROUND_CEILING = 'ROUND_CEILING' -ROUND_FLOOR = 'ROUND_FLOOR' -ROUND_UP = 'ROUND_UP' -ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' - -#Rounding decision (not part of the public API) -NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY -ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. - -#Errors - -class DecimalException(ArithmeticError): - """Base exception class. - - Used exceptions derive from this. - If an exception derives from another exception besides this (such as - Underflow (Inexact, Rounded, Subnormal) that indicates that it is only - called if the others are present. This isn't actually used for - anything, though. - - handle -- Called when context._raise_error is called and the - trap_enabler is set. First argument is self, second is the - context. More arguments can be given, those being after - the explanation in _raise_error (For example, - context._raise_error(NewError, '(-x)!', self._sign) would - call NewError().handle(context, self._sign).) - - To define a new exception, it should be sufficient to have it derive - from DecimalException. - """ - def handle(self, context, *args): - pass - - -class Clamped(DecimalException): - """Exponent of a 0 changed to fit bounds. - - This occurs and signals clamped if the exponent of a result has been - altered in order to fit the constraints of a specific concrete - representation. This may occur when the exponent of a zero result would - be outside the bounds of a representation, or when a large normal - number would have an encoded exponent that cannot be represented. In - this latter case, the exponent is reduced to fit and the corresponding - number of zero digits are appended to the coefficient ("fold-down"). - """ - - -class InvalidOperation(DecimalException): - """An invalid operation was performed. - - Various bad things cause this: - - Something creates a signaling NaN - -INF + INF - 0 * (+-)INF - (+-)INF / (+-)INF - x % 0 - (+-)INF % x - x._rescale( non-integer ) - sqrt(-x) , x > 0 - 0 ** 0 - x ** (non-integer) - x ** (+-)INF - An operand is invalid - """ - def handle(self, context, *args): - if args: - if args[0] == 1: #sNaN, must drop 's' but keep diagnostics - return Decimal( (args[1]._sign, args[1]._int, 'n') ) - return NaN - -class ConversionSyntax(InvalidOperation): - """Trying to convert badly formed string. - - This occurs and signals invalid-operation if an string is being - converted to a number and it does not conform to the numeric string - syntax. The result is [0,qNaN]. - """ - - def handle(self, context, *args): - return (0, (0,), 'n') #Passed to something which uses a tuple. - -class DivisionByZero(DecimalException, ZeroDivisionError): - """Division by 0. - - This occurs and signals division-by-zero if division of a finite number - by zero was attempted (during a divide-integer or divide operation, or a - power operation with negative right-hand operand), and the dividend was - not zero. - - The result of the operation is [sign,inf], where sign is the exclusive - or of the signs of the operands for divide, or is 1 for an odd power of - -0, for power. - """ - - def handle(self, context, sign, double = None, *args): - if double is not None: - return (Infsign[sign],)*2 - return Infsign[sign] - -class DivisionImpossible(InvalidOperation): - """Cannot perform the division adequately. - - This occurs and signals invalid-operation if the integer result of a - divide-integer or remainder operation had too many digits (would be - longer than precision). The result is [0,qNaN]. - """ - - def handle(self, context, *args): - return (NaN, NaN) - -class DivisionUndefined(InvalidOperation, ZeroDivisionError): - """Undefined result of division. - - This occurs and signals invalid-operation if division by zero was - attempted (during a divide-integer, divide, or remainder operation), and - the dividend is also zero. The result is [0,qNaN]. - """ - - def handle(self, context, tup=None, *args): - if tup is not None: - return (NaN, NaN) #for 0 %0, 0 // 0 - return NaN - -class Inexact(DecimalException): - """Had to round, losing information. - - This occurs and signals inexact whenever the result of an operation is - not exact (that is, it needed to be rounded and any discarded digits - were non-zero), or if an overflow or underflow condition occurs. The - result in all cases is unchanged. - - The inexact signal may be tested (or trapped) to determine if a given - operation (or sequence of operations) was inexact. - """ - pass - -class InvalidContext(InvalidOperation): - """Invalid context. Unknown rounding, for example. - - This occurs and signals invalid-operation if an invalid context was - detected during an operation. This can occur if contexts are not checked - on creation and either the precision exceeds the capability of the - underlying concrete representation or an unknown or unsupported rounding - was specified. These aspects of the context need only be checked when - the values are required to be used. The result is [0,qNaN]. - """ - - def handle(self, context, *args): - return NaN - -class Rounded(DecimalException): - """Number got rounded (not necessarily changed during rounding). - - This occurs and signals rounded whenever the result of an operation is - rounded (that is, some zero or non-zero digits were discarded from the - coefficient), or if an overflow or underflow condition occurs. The - result in all cases is unchanged. - - The rounded signal may be tested (or trapped) to determine if a given - operation (or sequence of operations) caused a loss of precision. - """ - pass - -class Subnormal(DecimalException): - """Exponent < Emin before rounding. - - This occurs and signals subnormal whenever the result of a conversion or - operation is subnormal (that is, its adjusted exponent is less than - Emin, before any rounding). The result in all cases is unchanged. - - The subnormal signal may be tested (or trapped) to determine if a given - or operation (or sequence of operations) yielded a subnormal result. - """ - pass - -class Overflow(Inexact, Rounded): - """Numerical overflow. - - This occurs and signals overflow if the adjusted exponent of a result - (from a conversion or from an operation that is not an attempt to divide - by zero), after rounding, would be greater than the largest value that - can be handled by the implementation (the value Emax). - - The result depends on the rounding mode: - - For round-half-up and round-half-even (and for round-half-down and - round-up, if implemented), the result of the operation is [sign,inf], - where sign is the sign of the intermediate result. For round-down, the - result is the largest finite number that can be represented in the - current precision, with the sign of the intermediate result. For - round-ceiling, the result is the same as for round-down if the sign of - the intermediate result is 1, or is [0,inf] otherwise. For round-floor, - the result is the same as for round-down if the sign of the intermediate - result is 0, or is [1,inf] otherwise. In all cases, Inexact and Rounded - will also be raised. - """ - - def handle(self, context, sign, *args): - if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN, - ROUND_HALF_DOWN, ROUND_UP): - return Infsign[sign] - if sign == 0: - if context.rounding == ROUND_CEILING: - return Infsign[sign] - return Decimal((sign, (9,)*context.prec, - context.Emax-context.prec+1)) - if sign == 1: - if context.rounding == ROUND_FLOOR: - return Infsign[sign] - return Decimal( (sign, (9,)*context.prec, - context.Emax-context.prec+1)) - - -class Underflow(Inexact, Rounded, Subnormal): - """Numerical underflow with result rounded to 0. - - This occurs and signals underflow if a result is inexact and the - adjusted exponent of the result would be smaller (more negative) than - the smallest value that can be handled by the implementation (the value - Emin). That is, the result is both inexact and subnormal. - - The result after an underflow will be a subnormal number rounded, if - necessary, so that its exponent is not less than Etiny. This may result - in 0 with the sign of the intermediate result and an exponent of Etiny. - - In all cases, Inexact, Rounded, and Subnormal will also be raised. - """ - -# List of public traps and flags -_signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, - Underflow, InvalidOperation, Subnormal] - -# Map conditions (per the spec) to signals -_condition_map = {ConversionSyntax:InvalidOperation, - DivisionImpossible:InvalidOperation, - DivisionUndefined:InvalidOperation, - InvalidContext:InvalidOperation} +# #Rounding +# ROUND_DOWN = 'ROUND_DOWN' +# ROUND_HALF_UP = 'ROUND_HALF_UP' +# ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' +# ROUND_CEILING = 'ROUND_CEILING' +# ROUND_FLOOR = 'ROUND_FLOOR' +# ROUND_UP = 'ROUND_UP' +# ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' + +# #Rounding decision (not part of the public API) +# NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY +# ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. + +# #Errors + +# class DecimalException(ArithmeticError): +# """Base exception class. + +# Used exceptions derive from this. +# If an exception derives from another exception besides this (such as +# Underflow (Inexact, Rounded, Subnormal) that indicates that it is only +# called if the others are present. This isn't actually used for +# anything, though. + +# handle -- Called when context._raise_error is called and the +# trap_enabler is set. First argument is self, second is the +# context. More arguments can be given, those being after +# the explanation in _raise_error (For example, +# context._raise_error(NewError, '(-x)!', self._sign) would +# call NewError().handle(context, self._sign).) + +# To define a new exception, it should be sufficient to have it derive +# from DecimalException. +# """ +# def handle(self, context, *args): +# pass + + +# class Clamped(DecimalException): +# """Exponent of a 0 changed to fit bounds. + +# This occurs and signals clamped if the exponent of a result has been +# altered in order to fit the constraints of a specific concrete +# representation. This may occur when the exponent of a zero result would +# be outside the bounds of a representation, or when a large normal +# number would have an encoded exponent that cannot be represented. In +# this latter case, the exponent is reduced to fit and the corresponding +# number of zero digits are appended to the coefficient ("fold-down"). +# """ + + +# class InvalidOperation(DecimalException): +# """An invalid operation was performed. + +# Various bad things cause this: + +# Something creates a signaling NaN +# -INF + INF +# 0 * (+-)INF +# (+-)INF / (+-)INF +# x % 0 +# (+-)INF % x +# x._rescale( non-integer ) +# sqrt(-x) , x > 0 +# 0 ** 0 +# x ** (non-integer) +# x ** (+-)INF +# An operand is invalid +# """ +# def handle(self, context, *args): +# if args: +# if args[0] == 1: #sNaN, must drop 's' but keep diagnostics +# return Decimal( (args[1]._sign, args[1]._int, 'n') ) +# return NaN + +# class ConversionSyntax(InvalidOperation): +# """Trying to convert badly formed string. + +# This occurs and signals invalid-operation if an string is being +# converted to a number and it does not conform to the numeric string +# syntax. The result is [0,qNaN]. +# """ + +# def handle(self, context, *args): +# return (0, (0,), 'n') #Passed to something which uses a tuple. + +# class DivisionByZero(DecimalException, ZeroDivisionError): +# """Division by 0. + +# This occurs and signals division-by-zero if division of a finite number +# by zero was attempted (during a divide-integer or divide operation, or a +# power operation with negative right-hand operand), and the dividend was +# not zero. + +# The result of the operation is [sign,inf], where sign is the exclusive +# or of the signs of the operands for divide, or is 1 for an odd power of +# -0, for power. +# """ + +# def handle(self, context, sign, double = None, *args): +# if double is not None: +# return (Infsign[sign],)*2 +# return Infsign[sign] + +# class DivisionImpossible(InvalidOperation): +# """Cannot perform the division adequately. + +# This occurs and signals invalid-operation if the integer result of a +# divide-integer or remainder operation had too many digits (would be +# longer than precision). The result is [0,qNaN]. +# """ + +# def handle(self, context, *args): +# return (NaN, NaN) + +# class DivisionUndefined(InvalidOperation, ZeroDivisionError): +# """Undefined result of division. + +# This occurs and signals invalid-operation if division by zero was +# attempted (during a divide-integer, divide, or remainder operation), and +# the dividend is also zero. The result is [0,qNaN]. +# """ + +# def handle(self, context, tup=None, *args): +# if tup is not None: +# return (NaN, NaN) #for 0 %0, 0 // 0 +# return NaN + +# class Inexact(DecimalException): +# """Had to round, losing information. + +# This occurs and signals inexact whenever the result of an operation is +# not exact (that is, it needed to be rounded and any discarded digits +# were non-zero), or if an overflow or underflow condition occurs. The +# result in all cases is unchanged. + +# The inexact signal may be tested (or trapped) to determine if a given +# operation (or sequence of operations) was inexact. +# """ +# pass + +# class InvalidContext(InvalidOperation): +# """Invalid context. Unknown rounding, for example. + +# This occurs and signals invalid-operation if an invalid context was +# detected during an operation. This can occur if contexts are not checked +# on creation and either the precision exceeds the capability of the +# underlying concrete representation or an unknown or unsupported rounding +# was specified. These aspects of the context need only be checked when +# the values are required to be used. The result is [0,qNaN]. +# """ + +# def handle(self, context, *args): +# return NaN + +# class Rounded(DecimalException): +# """Number got rounded (not necessarily changed during rounding). + +# This occurs and signals rounded whenever the result of an operation is +# rounded (that is, some zero or non-zero digits were discarded from the +# coefficient), or if an overflow or underflow condition occurs. The +# result in all cases is unchanged. + +# The rounded signal may be tested (or trapped) to determine if a given +# operation (or sequence of operations) caused a loss of precision. +# """ +# pass + +# class Subnormal(DecimalException): +# """Exponent < Emin before rounding. + +# This occurs and signals subnormal whenever the result of a conversion or +# operation is subnormal (that is, its adjusted exponent is less than +# Emin, before any rounding). The result in all cases is unchanged. + +# The subnormal signal may be tested (or trapped) to determine if a given +# or operation (or sequence of operations) yielded a subnormal result. +# """ +# pass + +# class Overflow(Inexact, Rounded): +# """Numerical overflow. + +# This occurs and signals overflow if the adjusted exponent of a result +# (from a conversion or from an operation that is not an attempt to divide +# by zero), after rounding, would be greater than the largest value that +# can be handled by the implementation (the value Emax). + +# The result depends on the rounding mode: + +# For round-half-up and round-half-even (and for round-half-down and +# round-up, if implemented), the result of the operation is [sign,inf], +# where sign is the sign of the intermediate result. For round-down, the +# result is the largest finite number that can be represented in the +# current precision, with the sign of the intermediate result. For +# round-ceiling, the result is the same as for round-down if the sign of +# the intermediate result is 1, or is [0,inf] otherwise. For round-floor, +# the result is the same as for round-down if the sign of the intermediate +# result is 0, or is [1,inf] otherwise. In all cases, Inexact and Rounded +# will also be raised. +# """ + +# def handle(self, context, sign, *args): +# if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN, +# ROUND_HALF_DOWN, ROUND_UP): +# return Infsign[sign] +# if sign == 0: +# if context.rounding == ROUND_CEILING: +# return Infsign[sign] +# return Decimal((sign, (9,)*context.prec, +# context.Emax-context.prec+1)) +# if sign == 1: +# if context.rounding == ROUND_FLOOR: +# return Infsign[sign] +# return Decimal( (sign, (9,)*context.prec, +# context.Emax-context.prec+1)) + + +# class Underflow(Inexact, Rounded, Subnormal): +# """Numerical underflow with result rounded to 0. + +# This occurs and signals underflow if a result is inexact and the +# adjusted exponent of the result would be smaller (more negative) than +# the smallest value that can be handled by the implementation (the value +# Emin). That is, the result is both inexact and subnormal. + +# The result after an underflow will be a subnormal number rounded, if +# necessary, so that its exponent is not less than Etiny. This may result +# in 0 with the sign of the intermediate result and an exponent of Etiny. + +# In all cases, Inexact, Rounded, and Subnormal will also be raised. +# """ + +# # List of public traps and flags +# _signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, +# Underflow, InvalidOperation, Subnormal] + +# # Map conditions (per the spec) to signals +# _condition_map = {ConversionSyntax:InvalidOperation, +# DivisionImpossible:InvalidOperation, +# DivisionUndefined:InvalidOperation, +# InvalidContext:InvalidOperation} + +from _decimal import DecimalException, Overflow, Underflow, \ + Clamped, DivisionByZero, Inexact, Rounded, InvalidOperation, \ + ConversionSyntax, DivisionImpossible, DivisionUndefined, \ + InvalidContext, Subnormal +from _decimal import ROUND_UP, ROUND_DOWN, ROUND_HALF_UP, \ + ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_FLOOR, \ + ROUND_CEILING, ALWAYS_ROUND, NEVER_ROUND ##### Context Functions ####################################### @@ -387,82 +395,85 @@ # work for older Pythons. If threads are not part of the build, create a # mock threading object with threading.local() returning the module namespace. -try: - import threading -except ImportError: - # Python was compiled without threads; create a mock object instead - import sys - class MockThreading: - def local(self, sys=sys): - return sys.modules[__name__] - threading = MockThreading() - del sys, MockThreading - -try: - threading.local - -except AttributeError: - - #To fix reloading, force it to create a new context - #Old contexts have different exceptions in their dicts, making problems. - if hasattr(threading.currentThread(), '__decimal_context__'): - del threading.currentThread().__decimal_context__ - - def setcontext(context): - """Set this thread's context to context.""" - if context in (DefaultContext, BasicContext, ExtendedContext): - context = context.copy() - context.clear_flags() - threading.currentThread().__decimal_context__ = context - - def getcontext(): - """Returns this thread's context. - - If this thread does not yet have a context, returns - a new context and sets this thread's context. - New contexts are copies of DefaultContext. - """ - try: - return threading.currentThread().__decimal_context__ - except AttributeError: - context = Context() - threading.currentThread().__decimal_context__ = context - return context - -else: - - local = threading.local() - if hasattr(local, '__decimal_context__'): - del local.__decimal_context__ - - def getcontext(_local=local): - """Returns this thread's context. - - If this thread does not yet have a context, returns - a new context and sets this thread's context. - New contexts are copies of DefaultContext. - """ - try: - return _local.__decimal_context__ - except AttributeError: - context = Context() - _local.__decimal_context__ = context - return context - - def setcontext(context, _local=local): - """Set this thread's context to context.""" - if context in (DefaultContext, BasicContext, ExtendedContext): - context = context.copy() - context.clear_flags() - _local.__decimal_context__ = context - - del threading, local # Don't contaminate the namespace - +#try: +# import threading +#except ImportError: +# # Python was compiled without threads; create a mock object instead +# import sys +# class MockThreading: +# def local(self, sys=sys): +# return sys.modules[__name__] +# threading = MockThreading() +# del sys, MockThreading +# +#try: +# threading.local +# +#except AttributeError: +# +# #To fix reloading, force it to create a new context +# #Old contexts have different exceptions in their dicts, making problems. +# if hasattr(threading.currentThread(), '__decimal_context__'): +# del threading.currentThread().__decimal_context__ +# +# def setcontext(context): +# """Set this thread's context to context.""" +# if context in (DefaultContext, BasicContext, ExtendedContext): +# context = context.copy() +# context.clear_flags() +# threading.currentThread().__decimal_context__ = context +# +# def getcontext(): +# """Returns this thread's context. +# +# If this thread does not yet have a context, returns +# a new context and sets this thread's context. +# New contexts are copies of DefaultContext. +# """ +# try: +# return threading.currentThread().__decimal_context__ +# except AttributeError: +# context = Context() +# threading.currentThread().__decimal_context__ = context +# return context +# +#else: +# +# local = threading.local() +# if hasattr(local, '__decimal_context__'): +# del local.__decimal_context__ +# +# def getcontext(_local=local): +# """Returns this thread's context. +# +# If this thread does not yet have a context, returns +# a new context and sets this thread's context. +# New contexts are copies of DefaultContext. +# """ +# try: +# return _local.__decimal_context__ +# except AttributeError: +# context = Context() +# _local.__decimal_context__ = context +# return context +# +# def setcontext(context, _local=local): +# """Set this thread's context to context.""" +# if context in (DefaultContext, BasicContext, ExtendedContext): +# context = context.copy() +# context.clear_flags() +# _local.__decimal_context__ = context +# +# del threading, local # Don't contaminate the namespace +# ##### Decimal class ########################################### import _decimal +getcontext = _decimal.getcontext +setcontext = _decimal.setcontext + class Decimal(_decimal.Decimal): """Floating point class for decimal arithmetic.""" @@ -582,33 +593,41 @@ # # raise TypeError("Cannot convert %r to Decimal" % value) - def _isnan(self): - """Returns whether the number is not actually one. +# def _isnan(self): +# """Returns whether the number is not actually one. - 0 if a number - 1 if NaN - 2 if sNaN - """ - if self._is_special: - exp = self._exp - if exp == 'n': - return 1 - elif exp == 'N': - return 2 +# 0 if a number +# 1 if NaN +# 2 if sNaN +# """ +# if self._is_special: +# exp = self._exp +# if exp == 'n': +# return 1 +# elif exp == 'N': +# return 2 +# return 0 + +# def _isinfinity(self): +# """Returns whether the number is infinite + +# 0 if finite or not a number +# 1 if +INF +# -1 if -INF +# """ +# if self._exp == 'F': +# if self._sign: +# return -1 +# return 1 +# return 0 + + def _isnan(self): + if self._sign in (4, 5): return 1 + if self._sign in (6, 7): return 2 return 0 def _isinfinity(self): - """Returns whether the number is infinite - - 0 if finite or not a number - 1 if +INF - -1 if -INF - """ - if self._exp == 'F': - if self._sign: - return -1 - return 1 - return 0 + return int(self._sign in (2, 3)) def _check_nans(self, other = None, context=None): """Returns whether the number is not actually one. @@ -2206,7 +2225,7 @@ def __exit__(self, t, v, tb): setcontext(self.saved_context) -class Context(object): +class Context(_decimal.Context): """Contains the context for a Decimal instance. Contains: @@ -2844,6 +2863,14 @@ """ return a.to_integral(context=self) +from _decimal import BasicContext, ExtendedContext, \ + DefaultContext + +BasicContext.__class__ = Context +ExtendedContext.__class__ = Context +DefaultContext.__class__ = Context + + class _WorkRep(object): __slots__ = ('sign','int','exp') # sign: 0 or 1 @@ -2996,118 +3023,122 @@ return 0 -##### Setup Specific Contexts ################################ +# ##### Setup Specific Contexts ################################ -# The default context prototype used by Context() -# Is mutable, so that new contexts can have different default values +# # The default context prototype used by Context() +# # Is mutable, so that new contexts can have different default values -DefaultContext = Context( - prec=28, rounding=ROUND_HALF_EVEN, - traps=[DivisionByZero, Overflow, InvalidOperation], - flags=[], - _rounding_decision=ALWAYS_ROUND, - Emax=999999999, - Emin=-999999999, - capitals=1 -) - -# Pre-made alternate contexts offered by the specification -# Don't change these; the user should be able to select these -# contexts and be able to reproduce results from other implementations -# of the spec. - -BasicContext = Context( - prec=9, rounding=ROUND_HALF_UP, - traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], - flags=[], -) - -ExtendedContext = Context( - prec=9, rounding=ROUND_HALF_EVEN, - traps=[], - flags=[], -) - - -##### Useful Constants (internal use only) #################### - -#Reusable defaults -Inf = Decimal('Inf') -negInf = Decimal('-Inf') +# DefaultContext = Context( +# prec=28, rounding=ROUND_HALF_EVEN, +# traps=[DivisionByZero, Overflow, InvalidOperation], +# flags=[], +# _rounding_decision=ALWAYS_ROUND, +# Emax=999999999, +# Emin=-999999999, +# capitals=1 +# ) + +# # Pre-made alternate contexts offered by the specification +# # Don't change these; the user should be able to select these +# # contexts and be able to reproduce results from other implementations +# # of the spec. + +# BasicContext = Context( +# prec=9, rounding=ROUND_HALF_UP, +# traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], +# flags=[], +# ) + +# ExtendedContext = Context( +# prec=9, rounding=ROUND_HALF_EVEN, +# traps=[], +# flags=[], +# ) + + +# ##### Useful Constants (internal use only) #################### + +from _decimal import Inf, negInf, NaN + +# #Reusable defaults +# Inf = Decimal('Inf') +# negInf = Decimal('-Inf') -#Infsign[sign] is infinity w/ that sign +# #Infsign[sign] is infinity w/ that sign Infsign = (Inf, negInf) -NaN = Decimal('NaN') +# NaN = Decimal('NaN') -##### crud for parsing strings ################################# -import re -# There's an optional sign at the start, and an optional exponent -# at the end. The exponent has an optional sign and at least one -# digit. In between, must have either at least one digit followed -# by an optional fraction, or a decimal point followed by at least -# one digit. Yuck. - -_parser = re.compile(r""" -# \s* - (?P[-+])? - ( - (?P\d+) (\. (?P\d*))? - | - \. (?P\d+) - ) - ([eE](?P[-+]? \d+))? -# \s* - $ -""", re.VERBOSE).match #Uncomment the \s* to allow leading or trailing spaces. - -del re - -# return sign, n, p s.t. float string value == -1**sign * n * 10**p exactly - -def _string2exact(s): - m = _parser(s) - if m is None: - raise ValueError("invalid literal for Decimal: %r" % s) - if m.group('sign') == "-": - sign = 1 - else: - sign = 0 +# ##### crud for parsing strings ################################# +# import re - exp = m.group('exp') - if exp is None: - exp = 0 - else: - exp = int(exp) - - intpart = m.group('int') - if intpart is None: - intpart = "" - fracpart = m.group('onlyfrac') - else: - fracpart = m.group('frac') - if fracpart is None: - fracpart = "" - - exp -= len(fracpart) - - mantissa = intpart + fracpart - tmp = map(int, mantissa) - backup = tmp - while tmp and tmp[0] == 0: - del tmp[0] - - # It's a zero - if not tmp: - if backup: - return (sign, tuple(backup), exp) - return (sign, (0,), exp) - mantissa = tuple(tmp) +# # There's an optional sign at the start, and an optional exponent +# # at the end. The exponent has an optional sign and at least one +# # digit. In between, must have either at least one digit followed +# # by an optional fraction, or a decimal point followed by at least +# # one digit. Yuck. + +# _parser = re.compile(r""" +# # \s* +# (?P[-+])? +# ( +# (?P\d+) (\. (?P\d*))? +# | +# \. (?P\d+) +# ) +# ([eE](?P[-+]? \d+))? +# # \s* +# $ +# """, re.VERBOSE).match #Uncomment the \s* to allow leading or trailing spaces. + +# del re + +# # return sign, n, p s.t. float string value == -1**sign * n * 10**p exactly + +# def _string2exact(s): +# m = _parser(s) +# if m is None: +# raise ValueError("invalid literal for Decimal: %r" % s) + +# if m.group('sign') == "-": +# sign = 1 +# else: +# sign = 0 + +# exp = m.group('exp') +# if exp is None: +# exp = 0 +# else: +# exp = int(exp) + +# intpart = m.group('int') +# if intpart is None: +# intpart = "" +# fracpart = m.group('onlyfrac') +# else: +# fracpart = m.group('frac') +# if fracpart is None: +# fracpart = "" + +# exp -= len(fracpart) + +# mantissa = intpart + fracpart +# tmp = map(int, mantissa) +# backup = tmp +# while tmp and tmp[0] == 0: +# del tmp[0] + +# # It's a zero +# if not tmp: +# if backup: +# return (sign, tuple(backup), exp) +# return (sign, (0,), exp) +# mantissa = tuple(tmp) - return (sign, mantissa, exp) +# return (sign, mantissa, exp) if __name__ == '__main__': From python-checkins at python.org Wed May 24 12:20:37 2006 From: python-checkins at python.org (fredrik.lundh) Date: Wed, 24 May 2006 12:20:37 +0200 (CEST) Subject: [Python-checkins] r46161 - python/trunk/Objects/unicodeobject.c Message-ID: <20060524102037.8211E1E4009@bag.python.org> Author: fredrik.lundh Date: Wed May 24 12:20:36 2006 New Revision: 46161 Modified: python/trunk/Objects/unicodeobject.c Log: use Py_ssize_t for string indexes (thanks, neal!) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Wed May 24 12:20:36 2006 @@ -5068,8 +5068,8 @@ } } } else { - int start = 0; - int end = PyUnicode_GET_SIZE(u) - size; + Py_ssize_t start = 0; + Py_ssize_t end = PyUnicode_GET_SIZE(u) - size; for (; start <= end; start++) if (Py_UNICODE_MATCH(u, start, v)) { result = 1; From tim.peters at gmail.com Wed May 24 12:24:49 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 10:24:49 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <447421A6.3090204@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> Message-ID: <1f7befae0605240324s3b96fa5dy725163309764e2d@mail.gmail.com> [M.-A. Lemburg] > It may actually be better to use the win32process API > GetProcessTimes() directly: > > http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32process__GetProcessTimes_meth.html > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp > > provided the win32 package is installed. > > This would be more in line with what time.clock() returns > on Unix platforms, namely the process time... I wonder why > time.clock() doesn't use this API on Windows. GetProcessTimes() is a relatively new addition to the Win32 API. Doesn't exist in any version of 9X/ME. Does exist in XP. May or may not exist in Win2K (docs say it exists in Win2K Pro and Win2K Server; they don't claim it exists in plain Win2K). From steve at holdenweb.com Wed May 24 12:32:44 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 11:32:44 +0100 Subject: [Python-checkins] Thanks for the terrific support Message-ID: <4474364C.8080909@holdenweb.com> Hey, all: I just wanted to thank all python-checkins subscribers who *aren't* at the sprint for the way you are pitching in to help us, catching small and large problems and smoothing over any holes we may have left behind us in our race for speed. It's great to be able to say that this is truly a community effort despite the fact that only a limited number of people could be in Iceland, and I'm truly delighted by the remote activity around the sprint. What a team. After Guido's much-appreciated message of support it might seem ungentlemanly to reveal that he was the first person to receive an invitation to attend. That'll teach him to go and work at Google (where I am sure we are all grateful that he gets to devote a substantial portion of his time to Python development). Way to go, guys, and thanks again! Our sponsors will hear about this. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From steve at holdenweb.com Wed May 24 12:41:06 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 11:41:06 +0100 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44742B1B.9090100@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> Message-ID: <44743842.1020602@holdenweb.com> M.-A. Lemburg wrote: > Steve Holden wrote: [...] >>>This would be more in line with what time.clock() returns >>>on Unix platforms, namely the process time... I wonder why >>>time.clock() doesn't use this API on Windows. >>> >> >>That's a pending change here thanks to Kristjan V Jonsson of CCP, who >>brought the same code to my attention yesterday. It shouldn't be a >>difficult fix, so I'll see how it affects reliability. On Windows I >>can't imnagine it will hurt ... > > > I gave it a go, but the results are not very promising (or > I did something wrong). The UserTime value does change, but > it seems to measure something different than process time, e.g. > if you run "while 1: pass" for a while, the value doesn't > change. > > I've also had a look at the implementation of time.time() > vs. time.clock(): time.clock() is definitely more accurate > on Windows since it uses the high resolution performance > counter: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp > > This is about at accurate as it'll get on Windows. > > time.time() uses ftime() which is only accurate to the > millisecond (if at all): > > http://msdn2.microsoft.com/en-us/library/z54t9z5f(VS.80).aspx > The sandbox copy already uses the same code timeit.py uses to determine the clock to use. Uncle Timmy points out that the GetProcessTimes() isn't ubiquitous, so I don't think there's much point in trying to make use of it. The one change I still do want to make is to allow the use of some bogomips-like feature to provide scaled testing to ensure that the individual test times can more easily be made large enough. At that point I'll probably be looking to check it back into the trunk as version 1.4 - unless you have any further suggestions? Indications are that the timings do seem to be more reliable. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From tim.peters at gmail.com Wed May 24 12:42:32 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 10:42:32 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44742B1B.9090100@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> Message-ID: <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> [M.-A. Lemburg] > I gave it a go, but the results are not very promising (or > I did something wrong). The UserTime value does change, but > it seems to measure something different than process time, e.g. > if you run "while 1: pass" for a while, the value doesn't > change. LOL -- figures ;-) I haven't used it myself, so can't guess without seeing the code. Best guess is that you passed a process handle for some _other_ process (easy to screw up on Windows, because process ids and process handles aren't the same things). > I've also had a look at the implementation of time.time() > vs. time.clock(): time.clock() is definitely more accurate > on Windows since it uses the high resolution performance > counter: time.clock() has sub-microsecond resolution (better than a millionth of a second) on all flavors of Windows. time.time() has poor resolution on all flavors of Windows, and is extraordinarily expensive to call on some flavors of Windows. The resolution depends in part on HW configuration. Most common are updating 18.2 times per second (0.055 second resolution) or 100 times per second (0.01 second resolution). As a result, if you call time.time() twice in a row on Windows, it's likely you'll get exactly the same value both times. >>> from time import time >>> print time(), time(), time() 1148467169.97 1148467169.97 1148467169.97 From thomas at python.org Wed May 24 12:52:25 2006 From: thomas at python.org (Thomas Wouters) Date: Wed, 24 May 2006 12:52:25 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> Message-ID: <9e804ac0605240352r3543de37ge42f11860562de62@mail.gmail.com> On 5/24/06, Tim Peters wrote: > time.clock() has sub-microsecond resolution (better than a millionth of a > second) on all flavors of Windows. > > time.time() has poor resolution on all flavors of Windows, and is > extraordinarily expensive to call on some flavors of Windows. The > resolution depends in part on HW configuration. Most common are updating > 18.2 times per second (0.055 second resolution) or 100 times per second ( > 0.01 second resolution). As a result, if you call time.time() twice in a > row on Windows, it's likely you'll get exactly the same value both times. Is there any particular reason we don't implement time.time() in terms of time.clock() (or rather, the same underlying mechanism?) Seed it once with ftime or gettimeofday or whatever's best on Windows, then use the performance counters to keep track of elapsed time? It wouldn't provide more accurate absolute time (and indeed, slightly more inaccurate, depending on howlong it takes between the two calls), but it would provide more accurate time-differences (as far as I understand.) Or is time.time(), in spite of being extraordinarily expensive, still faster than time.clock()? Or is time.clock() unreasonably bounded? Aren't-half-liter-coke-cans-great'ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060524/e0a06a38/attachment.html From mal at egenix.com Wed May 24 12:58:05 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 12:58:05 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> Message-ID: <44743C3D.2000409@egenix.com> Tim Peters wrote: > [M.-A. Lemburg] >> I gave it a go, but the results are not very promising (or >> I did something wrong). The UserTime value does change, but >> it seems to measure something different than process time, e.g. >> if you run "while 1: pass" for a while, the value doesn't >> change. > > LOL -- figures ;-) I haven't used it myself, so can't guess without > seeing the code. Best guess is that you passed a process handle for > some _other_ process (easy to screw up on Windows, because process ids > and process handles aren't the same things). I did the next best thing: win32process.GetProcessTimes(win32process.GetCurrentProcess()) Looking at the win32 docs, the GetCurrentProcess() returns an int where GetProcessTimes() wants a PyHANDLE. Shouldn't have known better though to actually *look* at the return value of GetCurrentProcess(): -1 Looks like I should have used OpenProcess() instead. Anyway, the path looks about right... I'll leave digging up the win32 details to a Windows geek instead ;-) >> I've also had a look at the implementation of time.time() >> vs. time.clock(): time.clock() is definitely more accurate >> on Windows since it uses the high resolution performance >> counter: > > time.clock() has sub-microsecond resolution (better than a millionth > of a second) on all flavors of Windows. > > time.time() has poor resolution on all flavors of Windows, and is > extraordinarily expensive to call on some flavors of Windows. The > resolution depends in part on HW configuration. Most common are > updating 18.2 times per second (0.055 second resolution) or 100 times > per second (0.01 second resolution). As a result, if you call > time.time() twice in a row on Windows, it's likely you'll get exactly > the same value both times. > >>>> from time import time >>>> print time(), time(), time() > 1148467169.97 1148467169.97 1148467169.97 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Wed May 24 13:11:28 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 13:11:28 +0200 (CEST) Subject: [Python-checkins] r46162 - in python/branches/blais-bytebuf: Lib/socket.py Lib/test/test_socket.py Modules/socketmodule.c Message-ID: <20060524111128.9DF3F1E4018@bag.python.org> Author: martin.blais Date: Wed May 24 13:11:27 2006 New Revision: 46162 Modified: python/branches/blais-bytebuf/Lib/socket.py python/branches/blais-bytebuf/Lib/test/test_socket.py python/branches/blais-bytebuf/Modules/socketmodule.c Log: Implemented recvfrom_buf Modified: python/branches/blais-bytebuf/Lib/socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/socket.py (original) +++ python/branches/blais-bytebuf/Lib/socket.py Wed May 24 13:11:27 2006 @@ -140,7 +140,9 @@ __doc__ = _realsocket.__doc__ - __slots__ = ["_sock", "send", "recv", "recv_buf", "sendto", "recvfrom", + __slots__ = ["_sock", + "recv", "recv_buf", "recvfrom_buf", + "send", "sendto", "recvfrom", "__weakref__"] def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): @@ -152,6 +154,7 @@ self.recv_buf = self._sock.recv_buf self.sendto = self._sock.sendto self.recvfrom = self._sock.recvfrom + self.recvfrom_buf = self._sock.recvfrom_buf def close(self): self._sock = _closedsocket() Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_socket.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_socket.py Wed May 24 13:11:27 2006 @@ -866,24 +866,25 @@ buf = array.array('c', ' '*1024) nbytes = self.cli_conn.recv_buf(buf) self.assertEqual(nbytes, len(MSG)) - trunc = buf.tostring()[:len(MSG)] - self.assertEqual(trunc, MSG) + msg = buf.tostring()[:len(MSG)] + self.assertEqual(msg, MSG) def _testRecv(self): # Send using a read-only buffer. buf = buffer(MSG) self.serv_conn.send(buf) - def testRecvBB(self): - # Receive into the buffer of an array class. + def testRecv2(self): + # Receive into a bytebuf. buf = bytebuf.bytebuf(1024) nbytes = self.cli_conn.recv_buf(buf) self.assertEqual(nbytes, len(MSG)) - trunc = str(buf)[:len(MSG)] - self.assertEqual(trunc, MSG) + msg = str(buf)[:len(MSG)] + self.assertEqual(msg, MSG) - def _testRecvBB(self): - # Send using a read-only buffer. + def _testRecv2(self): + # Send using a bytebuf. +## FIXME: todo ## buf = bytebuf.bytebuf(MSG) self.serv_conn.send(MSG) @@ -897,13 +898,31 @@ ## def _testOverFlowRecv(self): ## self.serv_conn.send(MSG) -## def testRecvFrom(self): -## # Testing large recvfrom() over TCP -## msg, addr = self.cli_conn.recvfrom(1024) -## self.assertEqual(msg, MSG) + def testRecvFrom(self): + # Testing large recvfrom() over TCP + buf = array.array('c', ' '*1024) + nbytes, addr = self.cli_conn.recvfrom_buf(buf) + self.assertEqual(nbytes, len(MSG)) + msg = buf.tostring()[:len(MSG)] + self.assertEqual(msg, MSG) -## def _testRecvFrom(self): -## self.serv_conn.send(MSG) + def _testRecvFrom(self): + buf = buffer(MSG) + self.serv_conn.send(buf) + + def testRecvFrom2(self): + # Testing large recvfrom() over TCP + buf = bytebuf.bytebuf(1024) + nbytes, addr = self.cli_conn.recvfrom_buf(buf) + self.assertEqual(nbytes, len(MSG)) + msg = str(buf)[:len(MSG)] + self.assertEqual(msg, MSG) + + def _testRecvFrom2(self): + # Send using a bytebuf. +## FIXME: todo +## buf = bytebuf.bytebuf(MSG) + self.serv_conn.send(MSG) ## def testOverFlowRecvFrom(self): ## # Testing recvfrom() in chunks over TCP Modified: python/branches/blais-bytebuf/Modules/socketmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/socketmodule.c (original) +++ python/branches/blais-bytebuf/Modules/socketmodule.c Wed May 24 13:11:27 2006 @@ -104,7 +104,10 @@ listen(n) -- start listening for incoming connections\n\ makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\ recv(buflen[, flags]) -- receive data\n\ -recvfrom(buflen[, flags]) -- receive data and sender's address\n\ +recv_buf(buffer[, nbytes[, flags]]) -- receive data (into a buffer)\n\ +recvfrom(buflen[, flags]) -- receive data and sender\'s address\n\ +recvfrom_buf(buffer[, nbytes, [, flags])\n\ + -- receive data and sender\'s address (into a buffer)\n\ sendall(data[, flags]) -- send all data\n\ send(data[, flags]) -- send data, may not send all of it\n\ sendto(data[, flags], addr) -- send data to a given address\n\ @@ -205,7 +208,7 @@ functions are declared correctly if compiling with MIPSPro 7.x in ANSI C mode (default) */ -/* XXX Using _SGIAPI is the wrong thing, +/* XXX Using _SGIAPI is the wrong thing, but I don't know what the right thing is. */ #undef _SGIAPI /* to avoid warning */ #define _SGIAPI 1 @@ -223,8 +226,8 @@ #include #endif -/* Irix 6.5 fails to define this variable at all. This is needed - for both GCC and SGI's compiler. I'd say that the SGI headers +/* Irix 6.5 fails to define this variable at all. This is needed + for both GCC and SGI's compiler. I'd say that the SGI headers are just busted. Same thing for Solaris. */ #if (defined(__sgi) || defined(sun)) && !defined(INET_ADDRSTRLEN) #define INET_ADDRSTRLEN 16 @@ -1194,10 +1197,10 @@ args->ob_type->tp_name); return 0; } - if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", + if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; - result = setipaddr(host, (struct sockaddr *)addr, + result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); if (result < 0) @@ -1225,12 +1228,12 @@ args->ob_type->tp_name); return 0; } - if (!PyArg_ParseTuple(args, "eti|ii", + if (!PyArg_ParseTuple(args, "eti|ii", "idna", &host, &port, &flowinfo, &scope_id)) { return 0; } - result = setipaddr(host, (struct sockaddr *)addr, + result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); if (result < 0) @@ -1839,7 +1842,7 @@ int res_size = sizeof res; /* It must be in the exception set */ assert(FD_ISSET(s->sock_fd, &fds_exc)); - if (0 == getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR, + if (0 == getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR, (char *)&res, &res_size)) /* getsockopt also clears WSAGetLastError, so reset it back. */ @@ -2323,29 +2326,34 @@ See recv() for documentation about the flags."); -/* s.recvfrom(nbytes [,flags]) method */ - -static PyObject * -sock_recvfrom(PySocketSockObject *s, PyObject *args) +/* + * This is the guts of the recv() and recv_buf() methods, which reads into a + * char buffer. If you have any inc/def ref to do to the objects that contain + * the buffer, do it in the caller. This function returns the number of bytes + * succesfully read. If there was an error, it returns -1. Note that it is + * also possible that we return a number of bytes smaller than the request + * bytes. + * + * 'addr' is a return value for the address object. Note that you must decref + * it yourself. + */ +static int +sock_recvfrom_guts(PySocketSockObject *s, char* cbuf, int len, int flags, + PyObject** addr) { sock_addr_t addrbuf; - PyObject *buf = NULL; - PyObject *addr = NULL; - PyObject *ret = NULL; - int len, n = 0, flags = 0, timeout; + int n = 0, timeout; socklen_t addrlen; - if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) - return NULL; + *addr = NULL; if (!getsockaddrlen(s, &addrlen)) - return NULL; - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) - return NULL; + return -1; - if (!IS_SELECTABLE(s)) - return select_error(); + if (!IS_SELECTABLE(s)) { + select_error(); + return -1; + } Py_BEGIN_ALLOW_THREADS memset(&addrbuf, 0, addrlen); @@ -2353,41 +2361,71 @@ if (!timeout) { #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (struct sockaddr *) &addrbuf, &addrlen); #else - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (struct sockaddr *) &addrbuf, &addrlen); #endif } Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + s->errorhandler(); + return -1; } - if (n != len && _PyString_Resize(&buf, n) < 0) + if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addrlen, s->sock_proto))) + return -1; + + return n; +} + +/* s.recvfrom(nbytes [,flags]) method */ + +static PyObject * +sock_recvfrom(PySocketSockObject *s, PyObject *args) +{ + PyObject *buf = NULL; + PyObject *addr = NULL; + PyObject *ret = NULL; + int recvlen, outlen, flags = 0; + + if (!PyArg_ParseTuple(args, "i|i:recvfrom", &recvlen, &flags)) return NULL; - if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, - addrlen, s->sock_proto))) + buf = PyString_FromStringAndSize((char *) 0, recvlen); + if (buf == NULL) + return NULL; + + outlen = sock_recvfrom_guts(s, PyString_AS_STRING(buf), + recvlen, flags, &addr); + if (outlen < 0) { goto finally; + } + + if (outlen != recvlen) { + /* We did not read as many bytes as we anticipated, resize the + string if possible and be succesful. */ + if (_PyString_Resize(&buf, outlen) < 0) + /* Oopsy, not so succesful after all. */ + goto finally; + } ret = PyTuple_Pack(2, buf, addr); finally: - Py_XDECREF(addr); Py_XDECREF(buf); + Py_XDECREF(addr); return ret; } @@ -2396,6 +2434,57 @@ \n\ Like recv(buffersize, flags) but also return the sender's address info."); + +/* s.recvfrom_buf(buffer[, nbytes [,flags]]) method */ + +static PyObject * +sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds) +{ + static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; + + int recvlen = 0, flags = 0, readlen; + char *buf; + int buflen; + + PyObject *addr = NULL; + PyObject *ret = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recvfrom", kwlist, + &buf, &buflen, &recvlen, &flags)) + return NULL; + assert(buf != 0 && buflen > 0); + + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); + return NULL; + } + if (recvlen == 0) { + /* If nbytes was not specified, use the buffer's length */ + recvlen = buflen; + } + + readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); + if (readlen < 0) { + /* Return an error */ + goto finally; + } + + /* Return the number of bytes read and the address. Note that we do + not do anything special here in the case that readlen < recvlen. */ + ret = PyTuple_Pack(2, PyInt_FromLong(readlen), addr); + +finally: + Py_XDECREF(addr); + return ret; +} + +PyDoc_STRVAR(recvfrom_buf_doc, +"recvfrom_buf(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\ +\n\ +Like recv_buf(buffer[, nbytes[, flags]]) but also return the sender's address info."); + + /* s.send(data [,flags]) method */ static PyObject * @@ -2590,61 +2679,63 @@ /* List of methods for socket objects */ static PyMethodDef sock_methods[] = { - {"accept", (PyCFunction)sock_accept, METH_NOARGS, - accept_doc}, - {"bind", (PyCFunction)sock_bind, METH_O, - bind_doc}, - {"close", (PyCFunction)sock_close, METH_NOARGS, - close_doc}, - {"connect", (PyCFunction)sock_connect, METH_O, - connect_doc}, - {"connect_ex", (PyCFunction)sock_connect_ex, METH_O, - connect_ex_doc}, + {"accept", (PyCFunction)sock_accept, METH_NOARGS, + accept_doc}, + {"bind", (PyCFunction)sock_bind, METH_O, + bind_doc}, + {"close", (PyCFunction)sock_close, METH_NOARGS, + close_doc}, + {"connect", (PyCFunction)sock_connect, METH_O, + connect_doc}, + {"connect_ex", (PyCFunction)sock_connect_ex, METH_O, + connect_ex_doc}, #ifndef NO_DUP - {"dup", (PyCFunction)sock_dup, METH_NOARGS, - dup_doc}, + {"dup", (PyCFunction)sock_dup, METH_NOARGS, + dup_doc}, #endif - {"fileno", (PyCFunction)sock_fileno, METH_NOARGS, - fileno_doc}, + {"fileno", (PyCFunction)sock_fileno, METH_NOARGS, + fileno_doc}, #ifdef HAVE_GETPEERNAME - {"getpeername", (PyCFunction)sock_getpeername, - METH_NOARGS, getpeername_doc}, + {"getpeername", (PyCFunction)sock_getpeername, + METH_NOARGS, getpeername_doc}, #endif - {"getsockname", (PyCFunction)sock_getsockname, - METH_NOARGS, getsockname_doc}, - {"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS, - getsockopt_doc}, - {"listen", (PyCFunction)sock_listen, METH_O, - listen_doc}, + {"getsockname", (PyCFunction)sock_getsockname, + METH_NOARGS, getsockname_doc}, + {"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS, + getsockopt_doc}, + {"listen", (PyCFunction)sock_listen, METH_O, + listen_doc}, #ifndef NO_DUP - {"makefile", (PyCFunction)sock_makefile, METH_VARARGS, - makefile_doc}, + {"makefile", (PyCFunction)sock_makefile, METH_VARARGS, + makefile_doc}, #endif - {"recv", (PyCFunction)sock_recv, METH_VARARGS, - recv_doc}, - {"recv_buf", (PyCFunction)sock_recv_buf, METH_VARARGS | METH_KEYWORDS, - recv_buf_doc}, - {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, - recvfrom_doc}, - {"send", (PyCFunction)sock_send, METH_VARARGS, - send_doc}, - {"sendall", (PyCFunction)sock_sendall, METH_VARARGS, - sendall_doc}, - {"sendto", (PyCFunction)sock_sendto, METH_VARARGS, - sendto_doc}, - {"setblocking", (PyCFunction)sock_setblocking, METH_O, - setblocking_doc}, - {"settimeout", (PyCFunction)sock_settimeout, METH_O, - settimeout_doc}, - {"gettimeout", (PyCFunction)sock_gettimeout, METH_NOARGS, - gettimeout_doc}, - {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, - setsockopt_doc}, - {"shutdown", (PyCFunction)sock_shutdown, METH_O, - shutdown_doc}, + {"recv", (PyCFunction)sock_recv, METH_VARARGS, + recv_doc}, + {"recv_buf", (PyCFunction)sock_recv_buf, METH_VARARGS | METH_KEYWORDS, + recv_buf_doc}, + {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, + recvfrom_doc}, + {"recvfrom_buf", (PyCFunction)sock_recvfrom_buf, METH_VARARGS | METH_KEYWORDS, + recvfrom_buf_doc}, + {"send", (PyCFunction)sock_send, METH_VARARGS, + send_doc}, + {"sendall", (PyCFunction)sock_sendall, METH_VARARGS, + sendall_doc}, + {"sendto", (PyCFunction)sock_sendto, METH_VARARGS, + sendto_doc}, + {"setblocking", (PyCFunction)sock_setblocking, METH_O, + setblocking_doc}, + {"settimeout", (PyCFunction)sock_settimeout, METH_O, + settimeout_doc}, + {"gettimeout", (PyCFunction)sock_gettimeout, METH_NOARGS, + gettimeout_doc}, + {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, + setsockopt_doc}, + {"shutdown", (PyCFunction)sock_shutdown, METH_O, + shutdown_doc}, #ifdef RISCOS - {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O, - sleeptaskw_doc}, + {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O, + sleeptaskw_doc}, #endif {NULL, NULL} /* sentinel */ }; @@ -3490,7 +3581,7 @@ if (strcmp(ip_addr, "255.255.255.255") == 0) { packed_addr = 0xFFFFFFFF; } else { - + packed_addr = inet_addr(ip_addr); if (packed_addr == INADDR_NONE) { /* invalid address */ @@ -3565,7 +3656,7 @@ "can't use AF_INET6, IPv6 is disabled"); return NULL; } -#endif +#endif retval = inet_pton(af, ip, packed); if (retval < 0) { @@ -3588,7 +3679,7 @@ return NULL; } } - + PyDoc_STRVAR(inet_ntop_doc, "inet_ntop(af, packed_ip) -> string formatted IP address\n\ \n\ @@ -3606,7 +3697,7 @@ #else char ip[INET_ADDRSTRLEN + 1]; #endif - + /* Guarantee NUL-termination for PyString_FromString() below */ memset((void *) &ip[0], '\0', sizeof(ip)); @@ -3684,7 +3775,7 @@ } else if (PyString_Check(hobj)) { hptr = PyString_AsString(hobj); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "getaddrinfo() argument 1 must be string or None"); return NULL; } From mal at egenix.com Wed May 24 13:11:43 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 13:11:43 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44743842.1020602@holdenweb.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> Message-ID: <44743F6F.1030105@egenix.com> Steve Holden wrote: > M.-A. Lemburg wrote: >> Steve Holden wrote: > [...] >>>> This would be more in line with what time.clock() returns >>>> on Unix platforms, namely the process time... I wonder why >>>> time.clock() doesn't use this API on Windows. >>>> >>> That's a pending change here thanks to Kristjan V Jonsson of CCP, who >>> brought the same code to my attention yesterday. It shouldn't be a >>> difficult fix, so I'll see how it affects reliability. On Windows I >>> can't imnagine it will hurt ... >> >> I gave it a go, but the results are not very promising (or >> I did something wrong). The UserTime value does change, but >> it seems to measure something different than process time, e.g. >> if you run "while 1: pass" for a while, the value doesn't >> change. >> >> I've also had a look at the implementation of time.time() >> vs. time.clock(): time.clock() is definitely more accurate >> on Windows since it uses the high resolution performance >> counter: >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp >> >> This is about at accurate as it'll get on Windows. >> >> time.time() uses ftime() which is only accurate to the >> millisecond (if at all): >> >> http://msdn2.microsoft.com/en-us/library/z54t9z5f(VS.80).aspx >> > The sandbox copy already uses the same code timeit.py uses to determine > the clock to use. Sorry, but that approach is just plain wrong: if sys.platform == "win32": # On Windows, the best timer is time.clock() default_timer = time.clock else: # On most other platforms the best timer is time.time() default_timer = time.time You never want to use a wall clock timer to measure the speed of code execution. There are simply too many other things going on in a multi-process system to make this a reliable approach. On Unix time.clock() will give you process time which is far more reliable as it provides feedback on the time the process actually received from the kernel for execution. Try it: print time.clock(); time.sleep(10); print time.clock() On Unix, you'll get the same results for both prints. On Windows, you get wall clock results, ie. a 10 second difference. > Uncle Timmy points out that the GetProcessTimes() > isn't ubiquitous, so I don't think there's much point in trying to make > use of it. According to MSDN it's only available on the WinNT branch of the Windows kernel. Since we're trying to optimize for a current system, it should be available on all systems where you'd normally be running pybench to check whether an optimization makes sense or not. > The one change I still do want to make is to allow the use of some > bogomips-like feature to provide scaled testing to ensure that the > individual test times can more easily be made large enough. Isn't that what the warp factor already implements ? > At that point I'll probably be looking to check it back into the trunk > as version 1.4 - unless you have any further suggestions? Indications > are that the timings do seem to be more reliable. I disagree on the clock approach you implemented and the change to use a 0 default for calibration runs, so those changes should not go into the trunk. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tim.peters at gmail.com Wed May 24 13:24:08 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 11:24:08 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <9e804ac0605240352r3543de37ge42f11860562de62@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <9e804ac0605240352r3543de37ge42f11860562de62@mail.gmail.com> Message-ID: <1f7befae0605240424x158f6909wed61c58481d1f6d3@mail.gmail.com> [Thomas Wouters] > Is there any particular reason we don't implement time.time() in terms of > time.clock() (or rather, the same underlying mechanism?) Seed it once with > ftime or gettimeofday or whatever's best on Windows, then use the > performance counters to keep track of elapsed time? It wouldn't provide more > accurate absolute time (and indeed, slightly more inaccurate, depending on > howlong it takes between the two calls), but it would provide more accurate > time-differences (as far as I understand.) People who care about time differences on Windows should use time.clock() directly, of course. time.time() "should", e.g., reflect differences due to synch'ing the system time-of-day clock with an external time source, while time.clock() "should not". They have different purposes. > Or is time.time(), in spite of being extraordinarily expensive, still faster > than time.clock()? No, time.clock() is very cheap on most Windows boxes (it just reads up the Pentium's real-time counter and packages the result). > Or is time.clock() unreasonably bounded? Not documented and don't know. On Windows is the underlying source is a 64-bit integer, but the units aren't defined (it's related to whatever QueryPerformanceFrequency() happens to return). While I haven't seen it "wrap around", can't say that's impossible. From mal at egenix.com Wed May 24 13:28:37 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 13:28:37 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240324s3b96fa5dy725163309764e2d@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <1f7befae0605240324s3b96fa5dy725163309764e2d@mail.gmail.com> Message-ID: <44744365.8080701@egenix.com> Tim Peters wrote: > [M.-A. Lemburg] >> It may actually be better to use the win32process API >> GetProcessTimes() directly: >> >> http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32process__GetProcessTimes_meth.html >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp >> >> >> provided the win32 package is installed. >> >> This would be more in line with what time.clock() returns >> on Unix platforms, namely the process time... I wonder why >> time.clock() doesn't use this API on Windows. > > GetProcessTimes() is a relatively new addition to the Win32 API. > Doesn't exist in any version of 9X/ME. Does exist in XP. May or may > not exist in Win2K (docs say it exists in Win2K Pro and Win2K Server; > they don't claim it exists in plain Win2K). Hmm, perhaps we should then add it as new function (and also make the change that Thomas proposed to the time.time() function on Windows) ?! -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From fredrik at pythonware.com Wed May 24 13:27:23 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 May 2006 13:27:23 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44743F6F.1030105@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> Message-ID: M.-A. Lemburg wrote: >> At that point I'll probably be looking to check it back into the trunk >> as version 1.4 - unless you have any further suggestions? Indications >> are that the timings do seem to be more reliable. > > I disagree on the clock approach you implemented and the > change to use a 0 default for calibration runs, so those > changes should not go into the trunk. so being wrong in a mal-approved way is better than being usable? sheesh. From tim.peters at gmail.com Wed May 24 13:36:20 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 11:36:20 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44743F6F.1030105@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> Message-ID: <1f7befae0605240436t43339917y94d5905a92dbf107@mail.gmail.com> [MAL] > Sorry, but that approach is just plain wrong: > > if sys.platform == "win32": > # On Windows, the best timer is time.clock() > default_timer = time.clock > else: > # On most other platforms the best timer is time.time() > default_timer = time.time > > You never want to use a wall clock timer to measure > the speed of code execution. You do on Windows, because the resolution of time.time() is unusably crude. Note that the code above was copied from Python's timeit.py, which is heavily and happily used on Windows. > There are simply too man other things going on in a multi-process > system to make this a reliable approach. That's life. Windows people know to keep their machine as quiet as possible when doing timings, and most Linux people know that too despite that it's not supposed to necessary there ;-) > On Unix time.clock() will give you process time which > is far more reliable as it provides feedback on the > time the process actually received from the kernel > for execution. This is understood by all. Nevertheless, Unix time.clock() results also vary across runs of identical code -- there is no _truly_ "reliable" approach on any box, if "reliable" means "reproducible without great care". > According to MSDN it's only available on the WinNT branch > of the Windows kernel. Since we're trying to optimize for > a current system, it should be available on all systems > where you'd normally be running pybench to check whether > an optimization makes sense or not. As noted before, "plain" Win2K is conspicuous by absence in the MSDN docs for GetProcessTimes. From python-checkins at python.org Wed May 24 13:42:02 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 13:42:02 +0200 (CEST) Subject: [Python-checkins] r46163 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524114202.964261E4009@bag.python.org> Author: georg.brandl Date: Wed May 24 13:42:02 2006 New Revision: 46163 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Adding some nb_ methods. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 13:42:02 2006 @@ -624,10 +624,10 @@ if (!new) return NULL; } - expdiff = prec - new->ob_size; + expdiff = new->ob_size - prec; if (expdiff == 0) return new; - else if (expdiff > 0) { + else if (expdiff < 0) { /* we need to extend precision */ new2 = _NEW_decimalobj(prec, new->sign, new->exp - expdiff); if (!new2) { @@ -901,20 +901,20 @@ returns NotImplemented or raises an exception, depending on the raise argument. */ -static decimalobject * +static PyObject * _convert_to_decimal(PyTypeObject *type, PyObject *thing, contextobject *ctx, int raise) { if (PyDecimal_Check(thing)) { Py_INCREF(thing); - return (decimalobject *)thing; + return thing; } else if (PyInt_Check(thing)) { long val = PyInt_AsLong(thing); if (val == -1 && PyErr_Occurred()) return NULL; - return (decimalobject *)decimal_from_long(type, val); + return decimal_from_long(type, val); } else if (PyLong_Check(thing)) { - return _decimal_from_pylong(type, thing, ctx); + return (PyObject *)_decimal_from_pylong(type, thing, ctx); } /* failed to convert */ if (raise) { @@ -1248,24 +1248,36 @@ PyDoc_STR("Floating point class for decimal arithmetic."); -#define DECIMAL_SPECIAL_FUNC(func) \ - static PyObject * \ - func (decimalobject *self, decimalobject *other) { \ - contextobject *ctx = getcontext(); \ - if (!ctx) return NULL; \ - return (PyObject *)_do_##func(self, other, ctx); \ +#define DECIMAL_SPECIAL_2FUNC(func) \ + static PyObject * \ + func (PyObject *self, PyObject *other) { \ + decimalobject *res; \ + contextobject *ctx = getcontext(); \ + if (!ctx) return NULL; \ + other = _convert_to_decimal(self->ob_type, other, ctx, 0); \ + if (other == NULL || other == Py_NotImplemented) return other; \ + res = _do_##func((decimalobject *)self, \ + (decimalobject *)other, ctx); \ + Py_DECREF(other); \ + } + +#define DECIMAL_SPECIAL_1FUNC(func) \ + static PyObject * \ + func (PyObject *self) { \ + contextobject *ctx = getcontext(); \ + if (!ctx) return NULL; \ + return (PyObject *)_do_##func((decimalobject *)self, ctx); \ } -static PyObject * + + +static decimalobject * _do_decimal_add(decimalobject *self, decimalobject *other, contextobject *ctx) { - other = _convert_to_decimal(self->ob_type, other, ctx, 0); - if (other == Py_NotImplemented) return other; - /* XXX */ } -DECIMAL_SPECIAL_FUNC(decimal_add) +DECIMAL_SPECIAL_2FUNC(decimal_add) static decimalobject * _do_decimal_subtract(decimalobject *self, decimalobject *other, @@ -1273,19 +1285,13 @@ { decimalobject *copy, *res; - other = _convert_to_decimal(self->ob_type, other, ctx, 0); - if (other == Py_NotImplemented) return other; - if (ISSPECIAL(self) || ISSPECIAL(other)) { decimalobject *nan; - if (_check_nans(self, other, ctx, &nan) != 0) { - Py_DECREF(other); + if (_check_nans(self, other, ctx, &nan) != 0) return nan; - } } copy = _decimal_get_copy(other); - Py_DECREF(other); if (!copy) return NULL; /* flip sign */ @@ -1298,52 +1304,180 @@ Py_DECREF(copy); return res; } -DECIMAL_SPECIAL_FUNC(decimal_subtract) +DECIMAL_SPECIAL_2FUNC(decimal_subtract) STUB(multiply) STUB(divide) STUB(remainder) STUB(divmod) STUB(power) -STUB1(negative) -STUB1(positive) -STUB1(absolute) -STUB1(invert) +static decimalobject * +_do_decimal_negative(decimalobject *self, contextobject *ctx) +{ + int sign = 0; + decimalobject *tmp, *res; + + if (ISSPECIAL(self)) { + decimalobject *nan; + if (_check_nans(self, NULL, ctx, &nan) != 0) + return nan; + } + if (! decimal_nonzero(self)) + /* - '0' => '0', not '-0' */ + sign = 0; + else if (self->sign & 1) + sign--; + else + sign++; + + res = _decimal_get_copy(self); + if (!res) return NULL; + res->sign = sign; + if (ctx->rounding_dec == ALWAYS_ROUND) { + tmp = _decimal_fix(res, ctx); + Py_DECREF(res); + if (!tmp) + return NULL; + return tmp; + } else { + return res; + } +} +DECIMAL_SPECIAL_1FUNC(decimal_negative) + + +static decimalobject * +_do_decimal_positive(decimalobject *self, contextobject *ctx) +{ + decimalobject *res, *tmp; + char sign = self->sign; + + if (ISSPECIAL(self)) { + decimalobject *nan; + if (_check_nans(self, NULL, ctx, &nan) != 0) + return nan; + } + + if (! decimal_nonzero(self)) + /* + '-0' => '0' */ + sign = 0; + + res = _decimal_get_copy(self); + if (!res) return NULL; + res->sign = sign; + if (ctx->rounding_dec == ALWAYS_ROUND) { + tmp = _decimal_fix(res, ctx); + Py_DECREF(res); + if (!tmp) + return NULL; + return tmp; + } else { + return res; + } +} +DECIMAL_SPECIAL_1FUNC(decimal_positive) + + +static decimalobject * +_do_decimal_absolute(decimalobject *self, contextobject *ctx, int round) +{ + contextobject *ctx2 = NULL; + decimalobject *ans; + + if (ISSPECIAL(self)) { + decimalobject *nan; + if (_check_nans(self, NULL, ctx, &nan) != 0) + return nan; + } + + if (!round) { + ctx2 = context_copy(ctx); + if (!ctx2) return NULL; + ctx2->rounding_dec = NEVER_ROUND; + } + + if (self->sign & 1) + ans = _do_decimal_negative(self, ctx2); + else + ans = _do_decimal_positive(self, ctx2); + Py_XDECREF(ctx2); + return ans; +} static PyObject * +decimal_absolute(PyObject *self) +{ + contextobject *ctx = getcontext(); + if (!ctx) return NULL; + return (PyObject *)_do_decimal_absolute((decimalobject *)self, ctx, 1); +} + + +static PyObject * +decimal_long(decimalobject *self) +{ + long i, max; + char *buf; + PyObject *res; + + max = self->ob_size + self->exp; + + buf = PyMem_MALLOC(max + 2); /* with sign */ + if (!buf) return NULL; + buf[0] = (self->sign & 1 ? '-' : '+'); + for (i = 0; i < max; i++) { + if (i < self->ob_size) + buf[i+1] = self->digits[i] + 48; + else + buf[i+1] = '0'; + } + buf[max+1] = 0; + res = PyLong_FromString(buf, NULL, 10); + PyMem_FREE(buf); + return res; +} + +/* Convert to int, truncating. */ +static PyObject * decimal_int(decimalobject *self) { - if (ISSPECIAL(self)) + long res = 0; + long i, max; + + if (ISSPECIAL(self)) { if (GETNAN(self)) { contextobject *ctx; ctx = getcontext(); if (!ctx) return NULL; - return handle_InvalidContext(self->ob_type, ctx, NULL); + return (PyObject *)handle_InvalidContext(self->ob_type, ctx, NULL); } else if (ISINF(self)) { PyErr_SetString(PyExc_OverflowError, "Cannot convert infinity to long"); return NULL; } + } -} - + /* try converting to int, if it's too big, convert to long */ + max = self->ob_size + self->exp; -static PyObject * -decimal_long(decimalobject *self) -{ - PyObject *tmp, *res; - tmp = decimal_int(self); - if (PyInt_Check(tmp)) { - res = PyLong_FromLong(PyInt_AsLong(tmp)); - Py_DECREF(tmp); - return res; - } else { - /* it's already a long */ - assert(PyLong_Check(tmp)); - return tmp; +#if SIZEOF_LONG == 4 + if (max > 9) return decimal_long(self); +#elif SIZEOF_LONG == 8 + if (max > 18) return decimal_long(self); +#else +#error "Decimal currently assumes that SIZEOF_LONG is 4 or 8, please adapt this" +#endif + + for (i = 0; i < max; i++) { + if (i < self->ob_size) + res = res * 10 + self->digits[i]; + else + res *= 10; } + if (self->sign & 1) res = -res; + return PyInt_FromLong(res); } - + static PyObject * decimal_float(decimalobject *self) { @@ -1366,7 +1500,7 @@ if (ISSPECIAL(self)) return 1; for (i = 0; i < self->ob_size; i++) - if (i != 0) return 1; + if (self->digits[i] != 0) return 1; return 0; } @@ -1381,17 +1515,17 @@ decimal_negative, /* nb_negative */ decimal_positive, /* nb_positive */ decimal_absolute, /* nb_absolute */ - decimal_nonzero, /* nb_nonzero */ - decimal_invert, /* nb_invert */ + (inquiry)decimal_nonzero, /* nb_nonzero */ + 0, /* nb_invert */ 0, /* nb_lshift */ 0, /* nb_rshift */ 0, /* nb_and */ 0, /* nb_xor */ 0, /* nb_or */ 0, /* nb_coerce */ - decimal_int, /* nb_int */ - decimal_long, /* nb_long */ - decimal_float, /* nb_float */ + (unaryfunc)decimal_int, /* nb_int */ + (unaryfunc)decimal_long, /* nb_long */ + (unaryfunc)decimal_float, /* nb_float */ 0, /* nb_oct */ 0, /* nb_hex */ 0, /* nb_inplace_add */ @@ -2195,8 +2329,8 @@ { static char *kwlist[] = {"num", 0}; PyObject *thing = NULL; - PyObject *nargs, *nkwds; - PyObject *res, *fixed; + PyObject *nargs, *nkwds, *res; + decimalobject *fixed; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &thing)) return NULL; @@ -2224,7 +2358,7 @@ Py_DECREF(nargs); } - fixed = _decimal_fix(res, self); + fixed = _decimal_fix((decimalobject *)res, self); Py_DECREF(res); return fixed; } @@ -2794,20 +2928,20 @@ ctx = getcontext(); if (!ctx) return; - PyDecimal_NaN = PyDecimal_FromString("nan", 3, ctx); + PyDecimal_NaN = (decimalobject *)PyDecimal_FromString("nan", 3, ctx); if (!PyDecimal_NaN) return; - if (PyModule_AddObject(m, "NaN", PyDecimal_NaN) < 0) + if (PyModule_AddObject(m, "NaN", (PyObject *)PyDecimal_NaN) < 0) return; - PyDecimal_Inf = PyDecimal_FromString("inf", 3, ctx); + PyDecimal_Inf = (decimalobject *)PyDecimal_FromString("inf", 3, ctx); if (!PyDecimal_Inf) return; - if (PyModule_AddObject(m, "Inf", PyDecimal_Inf) < 0) + if (PyModule_AddObject(m, "Inf", (PyObject *)PyDecimal_Inf) < 0) return; - PyDecimal_NegInf = PyDecimal_FromString("-inf", 4, ctx); + PyDecimal_NegInf = (decimalobject *)PyDecimal_FromString("-inf", 4, ctx); if (!PyDecimal_NegInf) return; - if (PyModule_AddObject(m, "negInf", PyDecimal_NegInf) < 0) + if (PyModule_AddObject(m, "negInf", (PyObject *)PyDecimal_NegInf) < 0) return; ADD_CONST(m, ROUND_DOWN); From python-checkins at python.org Wed May 24 13:51:20 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 13:51:20 +0200 (CEST) Subject: [Python-checkins] r46164 - in python/branches/blais-bytebuf: Lib/test/test_socket.py Modules/bytebufmodule.c Modules/hotbufmodule.c setup.py Message-ID: <20060524115120.F25161E4009@bag.python.org> Author: martin.blais Date: Wed May 24 13:51:19 2006 New Revision: 46164 Added: python/branches/blais-bytebuf/Modules/hotbufmodule.c - copied, changed from r46159, python/branches/blais-bytebuf/Modules/bytebufmodule.c Removed: python/branches/blais-bytebuf/Modules/bytebufmodule.c Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py python/branches/blais-bytebuf/setup.py Log: Moved bytebuf to hotbuf (dont complain, it almost went the way of hrattbuf (fast in Icelandic)) Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_socket.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_socket.py Wed May 24 13:51:19 2006 @@ -10,7 +10,7 @@ import Queue import sys import array -import bytebuf +import hotbuf from weakref import proxy PORT = 50007 @@ -875,17 +875,17 @@ self.serv_conn.send(buf) def testRecv2(self): - # Receive into a bytebuf. - buf = bytebuf.bytebuf(1024) + # Receive into a hotbuf. + buf = hotbuf.hotbuf(1024) nbytes = self.cli_conn.recv_buf(buf) self.assertEqual(nbytes, len(MSG)) msg = str(buf)[:len(MSG)] self.assertEqual(msg, MSG) def _testRecv2(self): - # Send using a bytebuf. + # Send using a hotbuf. ## FIXME: todo -## buf = bytebuf.bytebuf(MSG) +## buf = hotbuf.hotbuf(MSG) self.serv_conn.send(MSG) ## def testOverFlowRecv(self): @@ -912,16 +912,16 @@ def testRecvFrom2(self): # Testing large recvfrom() over TCP - buf = bytebuf.bytebuf(1024) + buf = hotbuf.hotbuf(1024) nbytes, addr = self.cli_conn.recvfrom_buf(buf) self.assertEqual(nbytes, len(MSG)) msg = str(buf)[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFrom2(self): - # Send using a bytebuf. + # Send using a hotbuf. ## FIXME: todo -## buf = bytebuf.bytebuf(MSG) +## buf = hotbuf.hotbuf(MSG) self.serv_conn.send(MSG) ## def testOverFlowRecvFrom(self): Deleted: /python/branches/blais-bytebuf/Modules/bytebufmodule.c ============================================================================== --- /python/branches/blais-bytebuf/Modules/bytebufmodule.c Wed May 24 13:51:19 2006 +++ (empty file) @@ -1,393 +0,0 @@ -/* =========================================================================== - * Bytebuf object - */ - -#include "Python.h" - -/* Note: the object's structure is private */ - -#ifndef Py_BYTEBUFOBJECT_H -#define Py_BYTEBUFOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -PyAPI_DATA(PyTypeObject) PyBytebuf_Type; - -#define PyBytebuf_Check(op) ((op)->ob_type == &PyBytebuf_Type) - -#define Py_END_OF_BYTEBUF (-1) - -PyAPI_FUNC(PyObject *) PyBytebuf_New(Py_ssize_t size); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BYTEBUFOBJECT_H */ - - -/* =========================================================================== - * Byte Buffer object implementation - */ - - -/* - * bytebuf object structure declaration. - */ -typedef struct { - PyObject_HEAD - - /* Base pointer location */ - void* b_ptr; - - /* Total size in bytes of the area that we can access. The allocated - memory must be at least as large as this size. */ - Py_ssize_t b_size; - -} PyBytebufObject; - - -/* - * Given a bytebuf object, return the buffer memory (in 'ptr' and 'size') and - * true if there was no error. - */ - - -/* FIXME remove get_buf() everywhere, at least the checks for the return - value. */ - -static int -get_buf(PyBytebufObject *self, void **ptr, Py_ssize_t *size) -{ - assert(ptr != NULL); - *ptr = self->b_ptr; - *size = self->b_size; - return 1; -} - -/* - * Create a new bytebuf where we allocate the memory ourselves. - */ -PyObject * -PyBytebuf_New(Py_ssize_t size) -{ - PyObject *o; - PyBytebufObject * b; - - if (size < 0) { - PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); - return NULL; - } - - /* FIXME: check for overflow in multiply */ - o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size); - if ( o == NULL ) - return PyErr_NoMemory(); - b = (PyBytebufObject *) PyObject_INIT(o, &PyBytebuf_Type); - - /* We setup the memory buffer to be right after the object itself. */ - b->b_ptr = (void *)(b + 1); - b->b_size = size; - - return o; -} - -/* Methods */ - -/* - * Constructor. - */ -static PyObject * -bytebuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - Py_ssize_t size = -1; - - if (!_PyArg_NoKeywords("bytebuf()", kw)) - return NULL; - - if (!PyArg_ParseTuple(args, "n:bytebuf", &size)) - return NULL; - - if ( size <= 0 ) { - PyErr_SetString(PyExc_TypeError, - "size must be greater than zero"); - return NULL; - } - - return PyBytebuf_New(size); -} - -/* - * Destructor. - */ -static void -bytebuf_dealloc(PyBytebufObject *self) -{ - /* Note: by virtue of the memory buffer being allocated with the PyObject - itself, this frees the buffer as well. */ - PyObject_DEL(self); -} - -/* - * Comparison. - */ -static int -bytebuf_compare(PyBytebufObject *self, PyBytebufObject *other) -{ - void *p1, *p2; - Py_ssize_t len_self, len_other, min_len; - int cmp; - - if (!get_buf(self, &p1, &len_self)) - return -1; - if (!get_buf(other, &p2, &len_other)) - return -1; - min_len = (len_self < len_other) ? len_self : len_other; - if (min_len > 0) { - cmp = memcmp(p1, p2, min_len); - if (cmp != 0) - return cmp; - } - return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; -} - - -/* - * Conversion to 'repr' string. - */ -static PyObject * -bytebuf_repr(PyBytebufObject *self) -{ - return PyString_FromFormat("", - self->b_ptr, - self->b_size, - self); -} - -/* - * Conversion to string. - */ -static PyObject * -bytebuf_str(PyBytebufObject *self) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return NULL; - return PyString_FromStringAndSize((const char *)ptr, size); -} - - -/* Bytebuf methods */ - -/* - * Returns the buffer for reading or writing. - */ -static Py_ssize_t -bytebuf_getwritebuf(PyBytebufObject *self, Py_ssize_t idx, void **pp) -{ - Py_ssize_t size; - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent bytebuf segment"); - return -1; - } - if (!get_buf(self, pp, &size)) - return -1; - return size; -} - -static Py_ssize_t -bytebuf_getsegcount(PyBytebufObject *self, Py_ssize_t *lenp) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; - if (lenp) - *lenp = size; - return 1; -} - -static Py_ssize_t -bytebuf_getcharbuf(PyBytebufObject *self, Py_ssize_t idx, const char **pp) -{ - void *ptr; - Py_ssize_t size; - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent bytebuf segment"); - return -1; - } - if (!get_buf(self, &ptr, &size)) - return -1; - *pp = (const char *)ptr; - return size; -} - -/* =========================================================================== - * Sequence methods - */ - -static Py_ssize_t -bytebuf_length(PyBytebufObject *self) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; - return size; -} - - -/* =========================================================================== - * Object interfaces declaration - */ - -/* FIXME: needs an update */ - -/* PyDoc_STRVAR(bytebuf_doc, */ -/* "bytebuf(object [, offset[, size]])\n\ */ -/* \n\ */ -/* Create a new bytebuf object which references the given object.\n\ */ -/* The bytebuf will reference a slice of the target object from the\n\ */ -/* start of the object (or at the specified offset). The slice will\n\ */ -/* extend to the end of the target object (or with the specified size)."); */ - -PyDoc_STRVAR(bytebuftype_doc, - "bytebuf(size) -> bytebuf\n\ -\n\ -Return a new bytebuf with a new buffer of fixed size 'size'.\n\ -\n\ -Methods:\n\ -\n\ -Attributes:\n\ -\n\ -"); - - -static PySequenceMethods bytebuf_as_sequence = { - (lenfunc)bytebuf_length, /*sq_length*/ - 0 /* (binaryfunc)bytebuf_concat */, /*sq_concat*/ - 0 /* (ssizeargfunc)bytebuf_repeat */, /*sq_repeat*/ - 0 /* (ssizeargfunc)bytebuf_item */, /*sq_item*/ - 0 /*(ssizessizeargfunc)bytebuf_slice*/, /*sq_slice*/ - 0 /*(ssizeobjargproc)bytebuf_ass_item*/, /*sq_ass_item*/ - 0 /*(ssizessizeobjargproc)bytebuf_ass_slice*/, /*sq_ass_slice*/ -}; - -static PyBufferProcs bytebuf_as_buffer = { - (readbufferproc)bytebuf_getwritebuf, - (writebufferproc)bytebuf_getwritebuf, - (segcountproc)bytebuf_getsegcount, - (charbufferproc)bytebuf_getcharbuf, -}; - -PyTypeObject PyBytebuf_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "bytebuf", - sizeof(PyBytebufObject), - 0, - (destructor)bytebuf_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)bytebuf_compare, /* tp_compare */ - (reprfunc)bytebuf_repr, /* tp_repr */ - 0, /* tp_as_number */ - &bytebuf_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)bytebuf_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &bytebuf_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - bytebuftype_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - bytebuf_new, /* tp_new */ -}; - - -/* =========================================================================== - * Install Module - */ - -PyDoc_STRVAR(module_doc, - "This module defines an object type which can represent a fixed size\n\ -buffer of bytes in momery, from which you can directly read and into\n\ -which you can directly write objects in various other types. This is\n\ -used to avoid buffer copies in network I/O as much as possible. For\n\ -example, socket recv() can directly fill a byte buffer's memory and\n\ -send() can read the data to be sent from one as well.\n\ -\n\ -In addition, a byte buffer has two pointers within it, that delimit\n\ -an active slice, the current \"position\" and the \"limit\". The\n\ -active region of a byte buffer is located within these boundaries.\n\ -\n\ -This class is heaviliy inspired from Java's NIO ByteBuffer class.\n\ -\n\ -The constructor is:\n\ -\n\ -bytebuf(nbytes) -- create a new bytebuf\n\ -"); - - -/* No functions in array module. */ -static PyMethodDef a_methods[] = { - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - - -PyMODINIT_FUNC -initbytebuf(void) -{ - PyObject *m; - - PyBytebuf_Type.ob_type = &PyType_Type; - m = Py_InitModule3("bytebuf", a_methods, module_doc); - if (m == NULL) - return; - - Py_INCREF((PyObject *)&PyBytebuf_Type); - PyModule_AddObject(m, "BytebufType", (PyObject *)&PyBytebuf_Type); - Py_INCREF((PyObject *)&PyBytebuf_Type); - PyModule_AddObject(m, "bytebuf", (PyObject *)&PyBytebuf_Type); - /* No need to check the error here, the caller will do that */ -} - - - -/* - TODO - ---- - - Update doc. - - Add hash function - - Add support for sequence methods. - - - Pending Issues - -------------- - - Should we support weakrefs? - -*/ - Copied: python/branches/blais-bytebuf/Modules/hotbufmodule.c (from r46159, python/branches/blais-bytebuf/Modules/bytebufmodule.c) ============================================================================== --- python/branches/blais-bytebuf/Modules/bytebufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 13:51:19 2006 @@ -1,30 +1,30 @@ /* =========================================================================== - * Bytebuf object + * Hotbuf object */ #include "Python.h" /* Note: the object's structure is private */ -#ifndef Py_BYTEBUFOBJECT_H -#define Py_BYTEBUFOBJECT_H +#ifndef Py_HOTBUFOBJECT_H +#define Py_HOTBUFOBJECT_H #ifdef __cplusplus extern "C" { #endif -PyAPI_DATA(PyTypeObject) PyBytebuf_Type; +PyAPI_DATA(PyTypeObject) PyHotbuf_Type; -#define PyBytebuf_Check(op) ((op)->ob_type == &PyBytebuf_Type) +#define PyHotbuf_Check(op) ((op)->ob_type == &PyHotbuf_Type) -#define Py_END_OF_BYTEBUF (-1) +#define Py_END_OF_HOTBUF (-1) -PyAPI_FUNC(PyObject *) PyBytebuf_New(Py_ssize_t size); +PyAPI_FUNC(PyObject *) PyHotbuf_New(Py_ssize_t size); #ifdef __cplusplus } #endif -#endif /* !Py_BYTEBUFOBJECT_H */ +#endif /* !Py_HOTBUFOBJECT_H */ /* =========================================================================== @@ -33,7 +33,7 @@ /* - * bytebuf object structure declaration. + * hotbuf object structure declaration. */ typedef struct { PyObject_HEAD @@ -45,11 +45,11 @@ memory must be at least as large as this size. */ Py_ssize_t b_size; -} PyBytebufObject; +} PyHotbufObject; /* - * Given a bytebuf object, return the buffer memory (in 'ptr' and 'size') and + * Given a hotbuf object, return the buffer memory (in 'ptr' and 'size') and * true if there was no error. */ @@ -58,7 +58,7 @@ value. */ static int -get_buf(PyBytebufObject *self, void **ptr, Py_ssize_t *size) +get_buf(PyHotbufObject *self, void **ptr, Py_ssize_t *size) { assert(ptr != NULL); *ptr = self->b_ptr; @@ -67,13 +67,13 @@ } /* - * Create a new bytebuf where we allocate the memory ourselves. + * Create a new hotbuf where we allocate the memory ourselves. */ PyObject * -PyBytebuf_New(Py_ssize_t size) +PyHotbuf_New(Py_ssize_t size) { PyObject *o; - PyBytebufObject * b; + PyHotbufObject * b; if (size < 0) { PyErr_SetString(PyExc_ValueError, @@ -85,7 +85,7 @@ o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size); if ( o == NULL ) return PyErr_NoMemory(); - b = (PyBytebufObject *) PyObject_INIT(o, &PyBytebuf_Type); + b = (PyHotbufObject *) PyObject_INIT(o, &PyHotbuf_Type); /* We setup the memory buffer to be right after the object itself. */ b->b_ptr = (void *)(b + 1); @@ -100,14 +100,14 @@ * Constructor. */ static PyObject * -bytebuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) +hotbuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) { Py_ssize_t size = -1; - if (!_PyArg_NoKeywords("bytebuf()", kw)) + if (!_PyArg_NoKeywords("hotbuf()", kw)) return NULL; - if (!PyArg_ParseTuple(args, "n:bytebuf", &size)) + if (!PyArg_ParseTuple(args, "n:hotbuf", &size)) return NULL; if ( size <= 0 ) { @@ -116,14 +116,14 @@ return NULL; } - return PyBytebuf_New(size); + return PyHotbuf_New(size); } /* * Destructor. */ static void -bytebuf_dealloc(PyBytebufObject *self) +hotbuf_dealloc(PyHotbufObject *self) { /* Note: by virtue of the memory buffer being allocated with the PyObject itself, this frees the buffer as well. */ @@ -134,7 +134,7 @@ * Comparison. */ static int -bytebuf_compare(PyBytebufObject *self, PyBytebufObject *other) +hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) { void *p1, *p2; Py_ssize_t len_self, len_other, min_len; @@ -158,9 +158,9 @@ * Conversion to 'repr' string. */ static PyObject * -bytebuf_repr(PyBytebufObject *self) +hotbuf_repr(PyHotbufObject *self) { - return PyString_FromFormat("", + return PyString_FromFormat("", self->b_ptr, self->b_size, self); @@ -170,7 +170,7 @@ * Conversion to string. */ static PyObject * -bytebuf_str(PyBytebufObject *self) +hotbuf_str(PyHotbufObject *self) { void *ptr; Py_ssize_t size; @@ -180,18 +180,18 @@ } -/* Bytebuf methods */ +/* Hotbuf methods */ /* * Returns the buffer for reading or writing. */ static Py_ssize_t -bytebuf_getwritebuf(PyBytebufObject *self, Py_ssize_t idx, void **pp) +hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) { Py_ssize_t size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, - "accessing non-existent bytebuf segment"); + "accessing non-existent hotbuf segment"); return -1; } if (!get_buf(self, pp, &size)) @@ -200,7 +200,7 @@ } static Py_ssize_t -bytebuf_getsegcount(PyBytebufObject *self, Py_ssize_t *lenp) +hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) { void *ptr; Py_ssize_t size; @@ -212,13 +212,13 @@ } static Py_ssize_t -bytebuf_getcharbuf(PyBytebufObject *self, Py_ssize_t idx, const char **pp) +hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) { void *ptr; Py_ssize_t size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, - "accessing non-existent bytebuf segment"); + "accessing non-existent hotbuf segment"); return -1; } if (!get_buf(self, &ptr, &size)) @@ -232,7 +232,7 @@ */ static Py_ssize_t -bytebuf_length(PyBytebufObject *self) +hotbuf_length(PyHotbufObject *self) { void *ptr; Py_ssize_t size; @@ -248,18 +248,18 @@ /* FIXME: needs an update */ -/* PyDoc_STRVAR(bytebuf_doc, */ -/* "bytebuf(object [, offset[, size]])\n\ */ +/* PyDoc_STRVAR(hotbuf_doc, */ +/* "hotbuf(object [, offset[, size]])\n\ */ /* \n\ */ -/* Create a new bytebuf object which references the given object.\n\ */ -/* The bytebuf will reference a slice of the target object from the\n\ */ +/* Create a new hotbuf object which references the given object.\n\ */ +/* The hotbuf will reference a slice of the target object from the\n\ */ /* start of the object (or at the specified offset). The slice will\n\ */ /* extend to the end of the target object (or with the specified size)."); */ -PyDoc_STRVAR(bytebuftype_doc, - "bytebuf(size) -> bytebuf\n\ +PyDoc_STRVAR(hotbuftype_doc, + "hotbuf(size) -> hotbuf\n\ \n\ -Return a new bytebuf with a new buffer of fixed size 'size'.\n\ +Return a new hotbuf with a new buffer of fixed size 'size'.\n\ \n\ Methods:\n\ \n\ @@ -268,46 +268,46 @@ "); -static PySequenceMethods bytebuf_as_sequence = { - (lenfunc)bytebuf_length, /*sq_length*/ - 0 /* (binaryfunc)bytebuf_concat */, /*sq_concat*/ - 0 /* (ssizeargfunc)bytebuf_repeat */, /*sq_repeat*/ - 0 /* (ssizeargfunc)bytebuf_item */, /*sq_item*/ - 0 /*(ssizessizeargfunc)bytebuf_slice*/, /*sq_slice*/ - 0 /*(ssizeobjargproc)bytebuf_ass_item*/, /*sq_ass_item*/ - 0 /*(ssizessizeobjargproc)bytebuf_ass_slice*/, /*sq_ass_slice*/ +static PySequenceMethods hotbuf_as_sequence = { + (lenfunc)hotbuf_length, /*sq_length*/ + 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ + 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ + 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ + 0 /*(ssizessizeargfunc)hotbuf_slice*/, /*sq_slice*/ + 0 /*(ssizeobjargproc)hotbuf_ass_item*/, /*sq_ass_item*/ + 0 /*(ssizessizeobjargproc)hotbuf_ass_slice*/, /*sq_ass_slice*/ }; -static PyBufferProcs bytebuf_as_buffer = { - (readbufferproc)bytebuf_getwritebuf, - (writebufferproc)bytebuf_getwritebuf, - (segcountproc)bytebuf_getsegcount, - (charbufferproc)bytebuf_getcharbuf, +static PyBufferProcs hotbuf_as_buffer = { + (readbufferproc)hotbuf_getwritebuf, + (writebufferproc)hotbuf_getwritebuf, + (segcountproc)hotbuf_getsegcount, + (charbufferproc)hotbuf_getcharbuf, }; -PyTypeObject PyBytebuf_Type = { +PyTypeObject PyHotbuf_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, - "bytebuf", - sizeof(PyBytebufObject), + "hotbuf", + sizeof(PyHotbufObject), 0, - (destructor)bytebuf_dealloc, /* tp_dealloc */ + (destructor)hotbuf_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)bytebuf_compare, /* tp_compare */ - (reprfunc)bytebuf_repr, /* tp_repr */ + (cmpfunc)hotbuf_compare, /* tp_compare */ + (reprfunc)hotbuf_repr, /* tp_repr */ 0, /* tp_as_number */ - &bytebuf_as_sequence, /* tp_as_sequence */ + &hotbuf_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc)bytebuf_str, /* tp_str */ + (reprfunc)hotbuf_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ - &bytebuf_as_buffer, /* tp_as_buffer */ + &hotbuf_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ - bytebuftype_doc, /* tp_doc */ + hotbuftype_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -324,7 +324,7 @@ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - bytebuf_new, /* tp_new */ + hotbuf_new, /* tp_new */ }; @@ -344,11 +344,11 @@ an active slice, the current \"position\" and the \"limit\". The\n\ active region of a byte buffer is located within these boundaries.\n\ \n\ -This class is heaviliy inspired from Java's NIO ByteBuffer class.\n\ +This class is heaviliy inspired from Java's NIO Hotbuffer class.\n\ \n\ The constructor is:\n\ \n\ -bytebuf(nbytes) -- create a new bytebuf\n\ +hotbuf(nbytes) -- create a new hotbuf\n\ "); @@ -359,19 +359,19 @@ PyMODINIT_FUNC -initbytebuf(void) +inithotbuf(void) { PyObject *m; - PyBytebuf_Type.ob_type = &PyType_Type; - m = Py_InitModule3("bytebuf", a_methods, module_doc); + PyHotbuf_Type.ob_type = &PyType_Type; + m = Py_InitModule3("hotbuf", a_methods, module_doc); if (m == NULL) return; - Py_INCREF((PyObject *)&PyBytebuf_Type); - PyModule_AddObject(m, "BytebufType", (PyObject *)&PyBytebuf_Type); - Py_INCREF((PyObject *)&PyBytebuf_Type); - PyModule_AddObject(m, "bytebuf", (PyObject *)&PyBytebuf_Type); + Py_INCREF((PyObject *)&PyHotbuf_Type); + PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); + Py_INCREF((PyObject *)&PyHotbuf_Type); + PyModule_AddObject(m, "hotbuf", (PyObject *)&PyHotbuf_Type); /* No need to check the error here, the caller will do that */ } Modified: python/branches/blais-bytebuf/setup.py ============================================================================== --- python/branches/blais-bytebuf/setup.py (original) +++ python/branches/blais-bytebuf/setup.py Wed May 24 13:51:19 2006 @@ -336,7 +336,7 @@ exts.append( Extension('array', ['arraymodule.c']) ) # array objects - exts.append( Extension('bytebuf', ['bytebufmodule.c']) ) + exts.append( Extension('hotbuf', ['hotbufmodule.c']) ) # complex math library functions exts.append( Extension('cmath', ['cmathmodule.c'], From mal at egenix.com Wed May 24 13:54:19 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 13:54:19 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240436t43339917y94d5905a92dbf107@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <1f7befae0605240436t43339917y94d5905a92dbf107@mail.gmail.com> Message-ID: <4474496B.8060307@egenix.com> Tim Peters wrote: > [MAL] >> Sorry, but that approach is just plain wrong: >> >> if sys.platform == "win32": >> # On Windows, the best timer is time.clock() >> default_timer = time.clock >> else: >> # On most other platforms the best timer is time.time() >> default_timer = time.time >> >> You never want to use a wall clock timer to measure >> the speed of code execution. > > You do on Windows, because the resolution of time.time() is unusably > crude. Note that the code above was copied from Python's timeit.py, > which is heavily and happily used on Windows. Actually, I was trying to imply that you should use time.clock() on all platforms. The fact that time.clock() uses wall-time on Windows is sad, but like you say, it's still better than time.time(). >> There are simply too man other things going on in a multi-process >> system to make this a reliable approach. > > That's life. Windows people know to keep their machine as quiet as > possible when doing timings, and most Linux people know that too > despite that it's not supposed to necessary there ;-) True, since you want to get the maximum out of CPU cache(s) and other optimizations happening at a much lower level in the system. >> On Unix time.clock() will give you process time which >> is far more reliable as it provides feedback on the >> time the process actually received from the kernel >> for execution. > > This is understood by all. Nevertheless, Unix time.clock() results > also vary across runs of identical code -- there is no _truly_ > "reliable" approach on any box, if "reliable" means "reproducible > without great care". True. You can still try measure the right thing, though ;-) >> According to MSDN it's only available on the WinNT branch >> of the Windows kernel. Since we're trying to optimize for >> a current system, it should be available on all systems >> where you'd normally be running pybench to check whether >> an optimization makes sense or not. > > As noted before, "plain" Win2K is conspicuous by absence in the MSDN > docs for GetProcessTimes. Does anyone of you at the sprint use Win2k ? -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Wed May 24 14:03:56 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 14:03:56 +0200 (CEST) Subject: [Python-checkins] r46165 - python/branches/blais-bytebuf/Modules/hotbufmodule.c Message-ID: <20060524120356.485671E400B@bag.python.org> Author: martin.blais Date: Wed May 24 14:03:55 2006 New Revision: 46165 Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c Log: Internal changes to hotbuf (simplification, removed get_buf) Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/hotbufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 14:03:55 2006 @@ -1,5 +1,6 @@ /* =========================================================================== - * Hotbuf object + * Hotbuf object: an equivalent to Java's NIO ByteBuffer class for fast + * network I/O. */ #include "Python.h" @@ -53,19 +54,6 @@ * true if there was no error. */ - -/* FIXME remove get_buf() everywhere, at least the checks for the return - value. */ - -static int -get_buf(PyHotbufObject *self, void **ptr, Py_ssize_t *size) -{ - assert(ptr != NULL); - *ptr = self->b_ptr; - *size = self->b_size; - return 1; -} - /* * Create a new hotbuf where we allocate the memory ourselves. */ @@ -136,21 +124,17 @@ static int hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) { - void *p1, *p2; - Py_ssize_t len_self, len_other, min_len; + Py_ssize_t min_len; int cmp; - if (!get_buf(self, &p1, &len_self)) - return -1; - if (!get_buf(other, &p2, &len_other)) - return -1; - min_len = (len_self < len_other) ? len_self : len_other; + min_len = (self->b_size < other->b_size) ? self->b_size : other->b_size; if (min_len > 0) { - cmp = memcmp(p1, p2, min_len); + cmp = memcmp(self->b_ptr, other->b_ptr, min_len); if (cmp != 0) return cmp; } - return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; + return ((self->b_size < other->b_size) ? + -1 : (self->b_size > other->b_size) ? 1 : 0); } @@ -172,11 +156,7 @@ static PyObject * hotbuf_str(PyHotbufObject *self) { - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return NULL; - return PyString_FromStringAndSize((const char *)ptr, size); + return PyString_FromStringAndSize((const char *)self->b_ptr, self->b_size); } @@ -188,43 +168,35 @@ static Py_ssize_t hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) { - Py_ssize_t size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, "accessing non-existent hotbuf segment"); return -1; } - if (!get_buf(self, pp, &size)) - return -1; - return size; + + *pp = self->b_ptr; + return self->b_size; } static Py_ssize_t hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) { - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; if (lenp) - *lenp = size; + *lenp = self->b_size; return 1; } static Py_ssize_t hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) { - void *ptr; - Py_ssize_t size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, "accessing non-existent hotbuf segment"); return -1; } - if (!get_buf(self, &ptr, &size)) - return -1; - *pp = (const char *)ptr; - return size; + + *pp = (const char *)self->b_ptr; + return self->b_size; } /* =========================================================================== @@ -234,11 +206,7 @@ static Py_ssize_t hotbuf_length(PyHotbufObject *self) { - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size)) - return -1; - return size; + return self->b_size; } From steve at holdenweb.com Wed May 24 14:05:01 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 13:05:01 +0100 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44743F6F.1030105@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> Message-ID: <44744BED.2000308@holdenweb.com> M.-A. Lemburg wrote: > Steve Holden wrote: [...] >>The sandbox copy already uses the same code timeit.py uses to determine >>the clock to use. > > > Sorry, but that approach is just plain wrong: > > if sys.platform == "win32": > # On Windows, the best timer is time.clock() > default_timer = time.clock > else: > # On most other platforms the best timer is time.time() > default_timer = time.time > It's a good job you pointed that out, since that would appear to mean that timeit.py is also wrong, since it uses exactly the same code. > You never want to use a wall clock timer to measure > the speed of code execution. There are simply too many > other things going on in a multi-process system to make > this a reliable approach. > It's not a matter of what I *want* to use, it's a matter of what I *can* use. Easily, portably, and with reasonable repeatibility. > On Unix time.clock() will give you process time which > is far more reliable as it provides feedback on the > time the process actually received from the kernel > for execution. > > Try it: > > print time.clock(); time.sleep(10); print time.clock() > > On Unix, you'll get the same results for both prints. > On Windows, you get wall clock results, ie. a 10 second > difference. > So timeit.py isn't just wrong for one platform, it's doing exactly the reverse of what it should, and it's just my bad luck that you didn't spot *that* checkin? > >>Uncle Timmy points out that the GetProcessTimes() >>isn't ubiquitous, so I don't think there's much point in trying to make >>use of it. > > > According to MSDN it's only available on the WinNT branch > of the Windows kernel. Since we're trying to optimize for > a current system, it should be available on all systems > where you'd normally be running pybench to check whether > an optimization makes sense or not. > So I can also ignore the comments about retaining 1.5.2 compatibility? > >>The one change I still do want to make is to allow the use of some >>bogomips-like feature to provide scaled testing to ensure that the >>individual test times can more easily be made large enough. > > > Isn't that what the warp factor already implements ? > Yes, but not automatically. > >>At that point I'll probably be looking to check it back into the trunk >>as version 1.4 - unless you have any further suggestions? Indications >>are that the timings do seem to be more reliable. > > > I disagree on the clock approach you implemented and the > change to use a 0 default for calibration runs, so those > changes should not go into the trunk. > I wasn't proposing to check it back in with 0 calibration. There's obviously plenty of mileage in the discussion about how to do the timings. I'm just not sure we will come to any reliable conclusion. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From tim.peters at gmail.com Wed May 24 14:06:11 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 12:06:11 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <4474496B.8060307@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <1f7befae0605240436t43339917y94d5905a92dbf107@mail.gmail.com> <4474496B.8060307@egenix.com> Message-ID: <1f7befae0605240506m1bff8f2fo1260e5bd85fa0ebb@mail.gmail.com> [M.-A. Lemburg] > ... > You can still try measure the right thing, though ;-) Alas, people will disagree about what the right thing is. I'm generally much more interested in wall-clock time than in CPU time myself. If, e.g., I write a program that spends 99.9% of its time waiting for I/O, the important thing to me is that it may take an hour of real time to run, not that it might take just one CPU second during that hour. Or it it's constantly swapping, etc. I'd only care about CPU time if I were on a time-sharing mainframe and charged for CPU-minutes <0.5 wink>. > Does anyone of you at the sprint use Win2k ? Don't think so -- just Win XP and Win64. There's a Win2K box in the buildbot farm, but I don't which flavor of Win2K that is. Win2K is still in use, but not among hackers :-) From mal at egenix.com Wed May 24 14:16:28 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 14:16:28 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44744BED.2000308@holdenweb.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <44744BED.2000308@holdenweb.com> Message-ID: <44744E9C.6020305@egenix.com> Steve Holden wrote: > M.-A. Lemburg wrote: >> Steve Holden wrote: > [...] >>> The sandbox copy already uses the same code timeit.py uses to >>> determine the clock to use. >> >> >> Sorry, but that approach is just plain wrong: >> >> if sys.platform == "win32": >> # On Windows, the best timer is time.clock() >> default_timer = time.clock >> else: >> # On most other platforms the best timer is time.time() >> default_timer = time.time >> > It's a good job you pointed that out, since that would appear to mean > that timeit.py is also wrong, since it uses exactly the same code. > >> You never want to use a wall clock timer to measure >> the speed of code execution. There are simply too many >> other things going on in a multi-process system to make >> this a reliable approach. >> > It's not a matter of what I *want* to use, it's a matter of what I *can* > use. Easily, portably, and with reasonable repeatibility. I understand, I would just like to have a good and reliable timer used in pybench. On Unix (which I use most the time), time.clock() gives reasonable and repeatable results, so it's the obvious choice. On Windows, it seems that we should try to come up with a better alternative to time.clock(). I'll give that a shot later today. >> On Unix time.clock() will give you process time which >> is far more reliable as it provides feedback on the >> time the process actually received from the kernel >> for execution. >> >> Try it: >> >> print time.clock(); time.sleep(10); print time.clock() >> >> On Unix, you'll get the same results for both prints. >> On Windows, you get wall clock results, ie. a 10 second >> difference. >> > So timeit.py isn't just wrong for one platform, it's doing exactly the > reverse of what it should, and it's just my bad luck that you didn't > spot *that* checkin? I'm not sure where timeit.py originated, but yes, it's certainly doing the wrong thing on Unix. >>> Uncle Timmy points out that the GetProcessTimes() isn't ubiquitous, >>> so I don't think there's much point in trying to make use of it. >> >> >> According to MSDN it's only available on the WinNT branch >> of the Windows kernel. Since we're trying to optimize for >> a current system, it should be available on all systems >> where you'd normally be running pybench to check whether >> an optimization makes sense or not. >> > So I can also ignore the comments about retaining 1.5.2 compatibility? No, actually I think pybench should report which timer it uses for timing things and then use the best alternative available on the system. Comparisons should then just work in case the same timer was used in both runs. >>> The one change I still do want to make is to allow the use of some >>> bogomips-like feature to provide scaled testing to ensure that the >>> individual test times can more easily be made large enough. >> >> >> Isn't that what the warp factor already implements ? > > Yes, but not automatically. You lost me there :-) Do want pybench to automatically scale the warp factor so that each run takes e.g. 60 seconds ? >>> At that point I'll probably be looking to check it back into the >>> trunk as version 1.4 - unless you have any further suggestions? >>> Indications are that the timings do seem to be more reliable. >> >> >> I disagree on the clock approach you implemented and the >> change to use a 0 default for calibration runs, so those >> changes should not go into the trunk. > > I wasn't proposing to check it back in with 0 calibration. Ok. > There's obviously plenty of mileage in the discussion about how to do > the timings. I'm just not sure we will come to any reliable conclusion. We don't have to decide things today - let's leave it cooking for a while until we find suitable solutions for the platforms we care about. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From mal at egenix.com Wed May 24 14:25:16 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 24 May 2006 14:25:16 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240506m1bff8f2fo1260e5bd85fa0ebb@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <1f7befae0605240436t43339917y94d5905a92dbf107@mail.gmail.com> <4474496B.8060307@egenix.com> <1f7befae0605240506m1bff8f2fo1260e5bd85fa0ebb@mail.gmail.com> Message-ID: <447450AC.9070300@egenix.com> Tim Peters wrote: > [M.-A. Lemburg] >> ... >> You can still try measure the right thing, though ;-) > > Alas, people will disagree about what the right thing is. I'm > generally much more interested in wall-clock time than in CPU time > myself. If, e.g., I write a program that spends 99.9% of its time > waiting for I/O, the important thing to me is that it may take an hour > of real time to run, not that it might take just one CPU second during > that hour. Or it it's constantly swapping, etc. I'd only care about > CPU time if I were on a time-sharing mainframe and charged for > CPU-minutes <0.5 wink>. That's why I put the smiley there... of course, people will have different views on whether they lose life time or CPU time or both :-) I guess the simple "one timer for all" just doesn't work out for the diverse set of benchmarks people might want to implement. The important aspect here is that results should be comparable across runs - otherwise the whole concept of a benchmark wouldn't work. >> Does anyone of you at the sprint use Win2k ? > > Don't think so -- just Win XP and Win64. There's a Win2K box in the > buildbot farm, but I don't which flavor of Win2K that is. Win2K is > still in use, but not among hackers :-) Well, then I guess GetProcessTimes() is a valid option - if it actually works. I'll have to find that out first. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 24 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From steve at holdenweb.com Wed May 24 14:27:09 2006 From: steve at holdenweb.com (Steve Holden) Date: Wed, 24 May 2006 13:27:09 +0100 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44744E9C.6020305@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <44744BED.2000308@holdenweb.com> <44744E9C.6020305@egenix.com> Message-ID: <4474511D.7050103@holdenweb.com> M.-A. Lemburg wrote: > Steve Holden wrote: > [...] >>>>The one change I still do want to make is to allow the use of some >>>>bogomips-like feature to provide scaled testing to ensure that the >>>>individual test times can more easily be made large enough. >>> >>> >>>Isn't that what the warp factor already implements ? >> >>Yes, but not automatically. > > > You lost me there :-) > > Do want pybench to automatically scale the warp factor so > that each run takes e.g. 60 seconds ? > Or provide an option that says *roughly* how long each round should take, and to compute an appropriate warp factor. [...] > >>There's obviously plenty of mileage in the discussion about how to do >>the timings. I'm just not sure we will come to any reliable conclusion. > > > We don't have to decide things today - let's leave it cooking > for a while until we find suitable solutions for the platforms > we care about. > Agreed. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From python-checkins at python.org Wed May 24 14:27:24 2006 From: python-checkins at python.org (bob.ippolito) Date: Wed, 24 May 2006 14:27:24 +0200 (CEST) Subject: [Python-checkins] r46166 - in sandbox/trunk/newstruct: Modules/_newstruct.c test_newstruct.py Message-ID: <20060524122724.B5BDB1E4009@bag.python.org> Author: bob.ippolito Date: Wed May 24 14:27:22 2006 New Revision: 46166 Modified: sandbox/trunk/newstruct/Modules/_newstruct.c sandbox/trunk/newstruct/test_newstruct.py Log: unpack_from and tests Modified: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- sandbox/trunk/newstruct/Modules/_newstruct.c (original) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Wed May 24 14:27:22 2006 @@ -1112,43 +1112,19 @@ s->ob_type->tp_free((PyObject *)s); } -PyDoc_STRVAR(s_unpack__doc__, -"unpack(str) -> (v1, v2, ...)\n\ -\n\ -Return tuple containing values unpacked according to this Struct's format.\n\ -Requires len(str) == self.size. See newstruct.__doc__ for more on format\n\ -strings."); - static PyObject * -s_unpack(PyObject *self, PyObject *inputstr) -{ - PyStructObject *soself; - PyObject *result; - char *restart; +s_unpack_internal(PyStructObject *soself, char *startfrom) { formatcode *code; - Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (inputstr == NULL || !PyString_Check(inputstr) || - PyString_GET_SIZE(inputstr) != soself->s_size) { - PyErr_Format(StructError, - "unpack requires a string argument of length %d", soself->s_size); - return NULL; - } - result = PyTuple_New(soself->s_len); + Py_ssize_t i = 0; + PyObject *result = PyTuple_New(soself->s_len); if (result == NULL) return NULL; - - restart = PyString_AS_STRING(inputstr); - i = 0; for (code = soself->s_codes; code->fmtdef != NULL; code++) { Py_ssize_t n; PyObject *v; const formatdef *e = code->fmtdef; - const char *res = restart + code->offset; + const char *res = startfrom + code->offset; if (e->format == 's') { v = PyString_FromStringAndSize(res, code->repeat); if (v == NULL) @@ -1180,6 +1156,73 @@ }; +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See newstruct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + return s_unpack_internal(soself, PyString_AS_STRING(inputstr)); +} + +PyDoc_STRVAR(s_unpack_from__doc__, +"unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Unlike unpack, unpack_from can unpack values from any object supporting\n\ +the buffer API, not just str. Requires len(buffer[offset:]) >= self.size.\n\ +See newstruct.__doc__ for more on format strings."); + +static PyObject * +s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"buffer", "offset", 0}; +#if (PY_VERSION_HEX < 0x02050000) + static char *fmt = "z#|i:unpack_from"; +#else + static char *fmt = "z#|n:unpack_from"; +#endif + Py_ssize_t buffer_len = 0, offset = 0; + char *buffer = NULL; + PyStructObject *soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, + &buffer, &buffer_len, &offset)) + return NULL; + + if (buffer == NULL) { + PyErr_Format(StructError, + "unpack_from requires a buffer argument"); + return NULL; + } + + if (offset < 0) + offset += buffer_len; + + if (offset < 0 || (buffer_len - offset) < soself->s_size) { + PyErr_Format(StructError, + "unpack_from requires a buffer of at least %d bytes", + soself->s_size); + return NULL; + } + return s_unpack_internal(soself, buffer + offset); +} + PyDoc_STRVAR(s_pack__doc__, "pack(v1, v2, ...) -> string\n\ \n\ @@ -1267,8 +1310,9 @@ /* List of functions */ static struct PyMethodDef s_methods[] = { - {"pack", s_pack, METH_VARARGS, s_pack__doc__}, - {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, + {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ }; Modified: sandbox/trunk/newstruct/test_newstruct.py ============================================================================== --- sandbox/trunk/newstruct/test_newstruct.py (original) +++ sandbox/trunk/newstruct/test_newstruct.py Wed May 24 14:27:22 2006 @@ -437,3 +437,33 @@ TestFailed("expected OverflowError") test_705836() + +def test_unpack_from(): + test_string = 'abcd01234' + s = struct.Struct('4s') + for cls in (str, buffer): + data = cls(test_string) + assert s.unpack_from(data) == ('abcd',) + assert s.unpack_from(data, 2) == ('cd01',) + assert s.unpack_from(data, 4) == ('0123',) + for i in xrange(6): + assert s.unpack_from(data, i) == (data[i:i+4],) + for i in xrange(6, len(test_string) + 1): + simple_err(s.unpack_from, data, i) + +test_unpack_from() + +def test_1229380(): + for endian in ('', '>', '<'): + for cls in (int, long): + for fmt in ('B', 'H', 'I', 'L'): + any_err(struct.pack, endian + fmt, cls(-1)) + + any_err(struct.pack, endian + 'B', cls(300)) + any_err(struct.pack, endian + 'H', cls(70000)) + + any_err(struct.pack, endian + 'I', sys.maxint * 4L) + any_err(struct.pack, endian + 'L', sys.maxint * 4L) + +if 0: + test_1229380() From python-checkins at python.org Wed May 24 14:29:56 2006 From: python-checkins at python.org (bob.ippolito) Date: Wed, 24 May 2006 14:29:56 +0200 (CEST) Subject: [Python-checkins] r46167 - sandbox/trunk/newstruct/newstruct.py Message-ID: <20060524122956.210D31E4009@bag.python.org> Author: bob.ippolito Date: Wed May 24 14:29:54 2006 New Revision: 46167 Modified: sandbox/trunk/newstruct/newstruct.py Log: unpack_from func Modified: sandbox/trunk/newstruct/newstruct.py ============================================================================== --- sandbox/trunk/newstruct/newstruct.py (original) +++ sandbox/trunk/newstruct/newstruct.py Wed May 24 14:29:54 2006 @@ -73,4 +73,16 @@ except KeyError: o = _compile(fmt) return o.unpack(s) + +def unpack_from(fmt, buffer, offset=0): + """ + Unpack the buffer, containing packed C structure data, according + to fmt starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt). + See newstruct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack_from(buffer, offset) From python-checkins at python.org Wed May 24 15:11:10 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 15:11:10 +0200 (CEST) Subject: [Python-checkins] r46168 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524131110.1ED231E4020@bag.python.org> Author: georg.brandl Date: Wed May 24 15:11:06 2006 New Revision: 46168 Modified: sandbox/trunk/decimal-c/_decimal.c Log: "Implement" some context methods. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 15:11:06 2006 @@ -49,7 +49,6 @@ #define SIGN_POSSNAN 6 #define SIGN_NEGSNAN 7 - /* Rounding constants */ #define ROUND_DOWN 0 @@ -1259,6 +1258,7 @@ res = _do_##func((decimalobject *)self, \ (decimalobject *)other, ctx); \ Py_DECREF(other); \ + return (PyObject *)res; \ } #define DECIMAL_SPECIAL_1FUNC(func) \ @@ -1306,11 +1306,80 @@ } DECIMAL_SPECIAL_2FUNC(decimal_subtract) -STUB(multiply) -STUB(divide) -STUB(remainder) -STUB(divmod) -STUB(power) +static decimalobject * +_do_decimal_multiply(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_multiply) + +static decimalobject * +_do_decimal_divide(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_divide) + + +static decimalobject * +_do_decimal_floor_div(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_floor_div) + +static decimalobject * +_do_decimal_true_div(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_true_div) + +static decimalobject * +_do_decimal_remainder(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_remainder) + +static decimalobject * +_do_decimal_divmod(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ +} +DECIMAL_SPECIAL_2FUNC(decimal_divmod) + +static decimalobject * +_do_decimal_power(decimalobject *self, decimalobject *other, + decimalobject *modulo, contextobject *ctx) +{ +} + +static PyObject * +decimal_power(PyObject *self, PyObject *other, PyObject *modulo) { + decimalobject *res; + contextobject *ctx = getcontext(); + if (!ctx) return NULL; + other = _convert_to_decimal(self->ob_type, other, ctx, 0); + if (other == NULL || other == Py_NotImplemented) return other; + if (modulo == Py_None) { + Py_INCREF(modulo); + } else { + modulo = _convert_to_decimal(self->ob_type, modulo, ctx, 0); + if (modulo == NULL || modulo == Py_NotImplemented) { + Py_DECREF(other); + return modulo; + } + } + res = _do_decimal_power((decimalobject *)self, + (decimalobject *)other, + (decimalobject *)modulo, + ctx); + Py_DECREF(other); + Py_DECREF(modulo); + return (PyObject *)res; +} + static decimalobject * _do_decimal_negative(decimalobject *self, contextobject *ctx) @@ -1490,9 +1559,6 @@ return res; } -STUB(floor_div) -STUB(true_div) - static int decimal_nonzero(decimalobject *self) { @@ -2376,22 +2442,54 @@ return PyInt_FromSsize_t(ETOP(self)); } -CSTUB(abs) - - -CSTUB(add) - - +#define CONTEXT_UNARY_FUNC(name, decname) \ + static decimalobject * \ + context_##name(contextobject *self, PyObject *a) { \ + decimalobject *dec_a = NULL, *res; \ + dec_a = (decimalobject *)_convert_to_decimal( \ + &PyDecimal_DecimalType, a, self, 1); \ + if (dec_a == NULL) return NULL; \ + res = _do_decimal_##decname(dec_a, self); \ + Py_DECREF(dec_a); \ + return res; \ + } + +#define CONTEXT_BINARY_FUNC(name, decname) \ + static decimalobject * \ + context_##name(contextobject *self, PyObject *args) { \ + PyObject *a, *b; \ + decimalobject *dec_a = NULL, *dec_b = NULL, *res; \ + if (!PyArg_ParseTuple(args, "OO:" #name)) return NULL; \ + dec_a = (decimalobject *)_convert_to_decimal( \ + &PyDecimal_DecimalType, a, self, 1); \ + if (dec_a == NULL) return NULL; \ + dec_b = (decimalobject *)_convert_to_decimal( \ + &PyDecimal_DecimalType, b, self, 1); \ + if (dec_b == NULL) { Py_DECREF(dec_a); return NULL; } \ + res = _do_decimal_##decname(dec_a, dec_b, self); \ + Py_DECREF(dec_a); \ + Py_DECREF(dec_b); \ + return res; \ + } + +/* helper so that I can use the CONTEXT_UNARY_FUNC macro above */ +#define _do_decimal_abs_with_round(a, b) \ + _do_decimal_absolute(a, b, 1) + +CONTEXT_UNARY_FUNC(abs, abs_with_round) +CONTEXT_BINARY_FUNC(add, add) +CONTEXT_BINARY_FUNC(divide, divide) +CONTEXT_BINARY_FUNC(divide_int, floor_div) +CONTEXT_BINARY_FUNC(divmod, divmod) +CONTEXT_UNARY_FUNC(minus, negative) +CONTEXT_BINARY_FUNC(multiply, multiply) +CONTEXT_UNARY_FUNC(plus, positive) +CONTEXT_BINARY_FUNC(subtract, subtract) CSTUB(compare) -CSTUB(divide) -CSTUB(divmod) -CSTUB(max) CSTUB(min) -CSTUB(minus) -CSTUB(multiply) +CSTUB(max) CSTUB(normalize) -CSTUB(plus) CSTUB(power) CSTUB(quantize) CSTUB(reduce) @@ -2399,7 +2497,6 @@ CSTUB(remainder_near) CSTUB(same_quantum) CSTUB(sqrt) -CSTUB(subtract) CSTUB(to_eng_string) CSTUB(to_integral) CSTUB(to_sci_string) @@ -2417,47 +2514,49 @@ {"Etop", (PyCFunction)context_Etop, METH_NOARGS}, {"abs", (PyCFunction)context_abs, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"add", (PyCFunction)context_add, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"compare", (PyCFunction)context_compare, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"divide", (PyCFunction)context_divide, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, + {"divide_int", (PyCFunction)context_divide_int, + METH_VARARGS}, {"divmod", (PyCFunction)context_divmod, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"max", (PyCFunction)context_max, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"min", (PyCFunction)context_min, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"minus", (PyCFunction)context_minus, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"multiply", (PyCFunction)context_multiply, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"normalize", (PyCFunction)context_normalize, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"plus", (PyCFunction)context_plus, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"power", (PyCFunction)context_power, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"quantize", (PyCFunction)context_quantize, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"remainder", (PyCFunction)context_remainder, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"remainder_near", (PyCFunction)context_remainder_near, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"same_quantum", (PyCFunction)context_same_quantum, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"sqrt", (PyCFunction)context_sqrt, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"subtract", (PyCFunction)context_subtract, - METH_VARARGS | METH_KEYWORDS}, + METH_VARARGS}, {"to_eng_string", (PyCFunction)context_to_eng_string, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"to_integral", (PyCFunction)context_to_integral, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"to_sci_string", (PyCFunction)context_to_sci_string, - METH_VARARGS | METH_KEYWORDS}, + METH_O}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, {"_shallow_copy", (PyCFunction)context_copy, From tim.peters at gmail.com Wed May 24 15:13:10 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 13:13:10 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44744E9C.6020305@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <44744BED.2000308@holdenweb.com> <44744E9C.6020305@egenix.com> Message-ID: <1f7befae0605240613k5a65388atbb5bafdd2342908e@mail.gmail.com> [M.-A. Lemburg] > .. > I understand, I would just like to have a good and > reliable timer used in pybench. > > On Unix (which I use most the time), time.clock() gives > reasonable and repeatable results, so it's the > obvious choice. > > On Windows, it seems that we should try to come up with > a better alternative to time.clock(). I'll give that a shot > later today. > ... > I'm not sure where timeit.py originated, but yes, it's > certainly doing the wrong thing on Unix. No. The real proof is in the pudding: timeit.py is also heavily and happily used on Linux. It's not some distinction between "wall-clock time" and "CPU tijme" timeit.py cares about, it's the underlying timer's _resolution_, whatever it's measuring. time.clock() typically has poor resolution on Linux (as does time.time() on Windows), and that's the real reason timeit.py uses time.clock() on Windows but time.time() on Linux. The good _resolution_ of those timers allows running simple tests for a much shorter amount of total time without introducing gross quantification errors due to poor resolution. Running for a shorter total amount of time in turn makes timing tests go faster, and reduces chances for gross interference. Running several times and reporting the minimum time taken is then usually effective at filtering out whatever gross interference may have occurred during some run(s). Since timeit.py aims at small, fast-running code segments, it's doing exactly the right thing for that purpose. If a Windows process-time gimmick were added, timeit.py would not want to use it (unless its _resolution_ was better than the Windows time.clock()). From python-checkins at python.org Wed May 24 15:14:24 2006 From: python-checkins at python.org (jack.diederich) Date: Wed, 24 May 2006 15:14:24 +0200 (CEST) Subject: [Python-checkins] r46169 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524131424.5AA371E4009@bag.python.org> Author: jack.diederich Date: Wed May 24 15:14:23 2006 New Revision: 46169 Modified: sandbox/trunk/decimal-c/_decimal.c Log: * str() formatting for non-eng/sci Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 15:14:23 2006 @@ -2058,24 +2058,134 @@ return NULL; } +/* + max length of output is len(str(max_long)) + len(str(max_long)) + + len(".") + len("-") +*/ +#define FORMAT_SIZE 50 +#define SANITY_CHECK(x) assert((x) < end); + +static PyObject * +decimal_special_str(decimalobject *d) +{ + char outbuf[FORMAT_SIZE]; + char *p, *end; + int i; + end = &outbuf[FORMAT_SIZE]; + p = outbuf; + + if (d->sign & 1) + *p++ = '-'; + + if (GETNAN(d)) { + if (GETNAN(d) == 2) + *p++ = 's'; + SANITY_CHECK(p); + p += sprintf(p, "%s", "NaN"); + SANITY_CHECK(p); + + /* check for digits != {0, } */ + if (d->ob_size != 1 || d->digits[0] != 0) { + for (i = 0; i < d->ob_size; i++) { + p += sprintf(p, "%d", d->digits[i]); + SANITY_CHECK(p); + } + } + } else { /* infinity */ + p += sprintf(p, "%s", "Infinity"); + } + *p++ = 0; + SANITY_CHECK(p); + return PyString_FromString(p); +} + static PyObject * decimal_str(decimalobject *d) { - char buf[1000]; - char dig[2]; - long i; + char outbuf[FORMAT_SIZE]; + int i, imax, j; + int leftdigits, dotplace, adjexp; + int append_E = 0, append_adjexp = 0; + char *p, *end; + end = &outbuf[FORMAT_SIZE]; + contextobject *context = NULL; /* debug, make this an arg */ + + if (ISSPECIAL(d)) + return decimal_special_str(d); + + if (context == NULL) { + context = getcontext(); + if (!context) + return NULL; + } + if (d->sign & 1) { + outbuf[0] = '-'; + p = &outbuf[1]; + } else { + p = &outbuf[0]; + } + + leftdigits = d->exp + d->ob_size; + adjexp = leftdigits - 1; + dotplace = 1; + if (d->exp) { + dotplace = -1; /* no dot */ + } else if (d->exp < 0 && adjexp >= 0) { + dotplace = leftdigits; + } else if (d->exp < 0 && adjexp >= -6) { + for (i = leftdigits; i < 0; i++) { + *p++ = '0'; + SANITY_CHECK(p); + } + *p++ = '0'; + } else { + if (d->ob_size <= dotplace) + dotplace = -1; - /*if (ISSPECIAL(d)) { - if (ISNAN(d)) - */ - dig[1] = 0; - PyOS_snprintf(buf, 1000, "sign=%i, exp=%ld, digits=", d->sign, d->exp); - for (i = 0; i < d->ob_size; i++) { - dig[0] = d->digits[i]+48; - strcat(buf, dig); + if (adjexp) { + append_E = 1; + append_adjexp = 1; + } + } + + imax = d->ob_size; + if (dotplace > 0) { + imax++; + } + for (i = 0, j = 0; i < imax; i++) { + if (i == dotplace) { + *p++ = '.'; + SANITY_CHECK(p); + continue; + } else { + p += sprintf(p, "%d", d->digits[j]); + SANITY_CHECK(p); + j++; + } + } + + if (append_E) { + if (context->capitals) { + *p++ = 'E'; + SANITY_CHECK(p); + if (adjexp > 0) { + *p++ = '+'; + SANITY_CHECK(p); + } + } else { + *p++ = 'e'; + SANITY_CHECK(p); + } + } + if (append_adjexp) { + p += sprintf(p, "%d", adjexp); } - return PyString_FromString(buf); + SANITY_CHECK(p); + *p++ = 0; + SANITY_CHECK(p); + return PyString_FromString(&outbuf); } +#undef SANITY_CHECK static PyObject * decimal_repr(decimalobject *d) From python-checkins at python.org Wed May 24 15:32:42 2006 From: python-checkins at python.org (richard.jones) Date: Wed, 24 May 2006 15:32:42 +0200 (CEST) Subject: [Python-checkins] r46170 - python/branches/rjones-prealloc Message-ID: <20060524133242.E81511E4009@bag.python.org> Author: richard.jones Date: Wed May 24 15:32:42 2006 New Revision: 46170 Added: python/branches/rjones-prealloc/ - copied from r46169, python/trunk/ Log: Branch to look into preallocating lists/dicts. From python-checkins at python.org Wed May 24 15:38:52 2006 From: python-checkins at python.org (richard.jones) Date: Wed, 24 May 2006 15:38:52 +0200 (CEST) Subject: [Python-checkins] r46171 - python/branches/rjones-prealloc/Objects/listobject.c Message-ID: <20060524133852.E91021E4009@bag.python.org> Author: richard.jones Date: Wed May 24 15:38:52 2006 New Revision: 46171 Modified: python/branches/rjones-prealloc/Objects/listobject.c Log: Enable pre-allocating list storage to avoid later mallocs. list(size=100) will pre-allocate 100 elements in the list. Modified list_resize to not shrink lists when invoked by a list operation that increases the list size. Modified: python/branches/rjones-prealloc/Objects/listobject.c ============================================================================== --- python/branches/rjones-prealloc/Objects/listobject.c (original) +++ python/branches/rjones-prealloc/Objects/listobject.c Wed May 24 15:38:52 2006 @@ -22,17 +22,20 @@ * than ob_size on entry. */ static int -list_resize(PyListObject *self, Py_ssize_t newsize) +list_resize(PyListObject *self, Py_ssize_t newsize, int allow_shrink) { PyObject **items; size_t new_allocated; Py_ssize_t allocated = self->allocated; /* Bypass realloc() when a previous overallocation is large enough - to accommodate the newsize. If the newsize falls lower than half - the allocated size, then proceed with the realloc() to shrink the list. + to accommodate the newsize. + If the newsize falls lower than half the allocated size and we + allow shrinking, then proceed with the realloc() to shrink the + list. */ - if (allocated >= newsize && newsize >= (allocated >> 1)) { + if (allocated >= newsize && (newsize >= (allocated >> 1) || + !allow_shrink)) { assert(self->ob_item != NULL || newsize == 0); self->ob_size = newsize; return 0; @@ -187,7 +190,7 @@ return -1; } - if (list_resize(self, n+1) == -1) + if (list_resize(self, n+1, 0) == -1) return -1; if (where < 0) { @@ -227,7 +230,7 @@ return -1; } - if (list_resize(self, n+1) == -1) + if (list_resize(self, n+1, 0) == -1) return -1; Py_INCREF(v); @@ -614,12 +617,12 @@ if (d < 0) { /* Delete -d items */ memmove(&item[ihigh+d], &item[ihigh], (a->ob_size - ihigh)*sizeof(PyObject *)); - list_resize(a, a->ob_size + d); + list_resize(a, a->ob_size + d, 1); item = a->ob_item; } else if (d > 0) { /* Insert d items */ k = a->ob_size; - if (list_resize(a, k+d) < 0) + if (list_resize(a, k+d, 0) < 0) goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], @@ -670,7 +673,7 @@ return (PyObject *)self; } - if (list_resize(self, size*n) == -1) + if (list_resize(self, size*n, 0) == -1) return NULL; p = size; @@ -750,7 +753,7 @@ Py_RETURN_NONE; } m = self->ob_size; - if (list_resize(self, m + n) == -1) { + if (list_resize(self, m + n, 0) == -1) { Py_DECREF(b); return NULL; } @@ -791,7 +794,7 @@ mn = m + n; if (mn >= m) { /* Make room. */ - if (list_resize(self, mn) == -1) + if (list_resize(self, mn, 0) == -1) goto error; /* Make the list sane again. */ self->ob_size = m; @@ -828,7 +831,7 @@ /* Cut back result list if initial guess was too large. */ if (self->ob_size < self->allocated) - list_resize(self, self->ob_size); /* shrinking can't fail */ + list_resize(self, self->ob_size, 1); /* shrinking can't fail */ Py_DECREF(it); Py_RETURN_NONE; @@ -885,7 +888,7 @@ } v = self->ob_item[i]; if (i == self->ob_size - 1) { - status = list_resize(self, self->ob_size - 1); + status = list_resize(self, self->ob_size - 1, 1); assert(status >= 0); return v; /* and v now owns the reference the list had */ } @@ -2355,10 +2358,13 @@ static int list_init(PyListObject *self, PyObject *args, PyObject *kw) { - PyObject *arg = NULL; - static char *kwlist[] = {"sequence", 0}; + PyObject *sequence = NULL; + Py_ssize_t size = 0; + static char *kwlist[] = {"sequence", "size", 0}; + PyObject **items; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "|On:list", kwlist, + &sequence, &size)) return -1; /* Verify list invariants established by PyType_GenericAlloc() */ @@ -2371,12 +2377,32 @@ if (self->ob_item != NULL) { (void)list_clear(self); } - if (arg != NULL) { - PyObject *rv = listextend(self, arg); + if (sequence != NULL) { + PyObject *rv = listextend(self, sequence); if (rv == NULL) return -1; Py_DECREF(rv); } + + if (size != 0) { + if (size < PyList_GET_SIZE(self)) { + PyErr_SetString(PyExc_ValueError, "size argument" + " too small to contain supplied sequence"); + return -1; + } + /* (p)re-allocate to the indicated size */ + items = self->ob_item; + if (size <= ((~(size_t)0) / sizeof(PyObject *))) + PyMem_RESIZE(items, PyObject *, size); + else + items = NULL; + if (items == NULL) { + PyErr_NoMemory(); + return -1; + } + self->ob_item = items; + self->allocated = size; + } return 0; } @@ -2565,7 +2591,7 @@ } self->ob_size -= slicelength; - list_resize(self, self->ob_size); + list_resize(self, self->ob_size, 1); for (i = 0; i < slicelength; i++) { Py_DECREF(garbage[i]); From python-checkins at python.org Wed May 24 16:21:57 2006 From: python-checkins at python.org (bob.ippolito) Date: Wed, 24 May 2006 16:21:57 +0200 (CEST) Subject: [Python-checkins] r46172 - sandbox/trunk/newstruct/Modules/_newstruct.c Message-ID: <20060524142157.29FBD1E4009@bag.python.org> Author: bob.ippolito Date: Wed May 24 16:21:56 2006 New Revision: 46172 Modified: sandbox/trunk/newstruct/Modules/_newstruct.c Log: simplify code by removing loops Modified: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- sandbox/trunk/newstruct/Modules/_newstruct.c (original) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Wed May 24 16:21:56 2006 @@ -32,7 +32,7 @@ typedef struct _formatcode { const struct _formatdef *fmtdef; int offset; - int repeat; + int size; } formatcode; /* Struct object interface */ @@ -963,7 +963,7 @@ const char *s; const char *fmt; char c; - int size, len, numcodes, num, itemsize, x; + int size, len, num, itemsize, x; fmt = PyString_AS_STRING(self->s_format); @@ -972,7 +972,6 @@ s = fmt; size = 0; len = 0; - numcodes = 0; while ((c = *s++) != '\0') { if (isspace(Py_CHARMASK(c))) continue; @@ -1004,7 +1003,6 @@ case 'x': break; default: len += num; break; } - if (c != 'x') numcodes++; itemsize = e->size; size = align(size, c, e); @@ -1019,7 +1017,7 @@ self->s_size = size; self->s_len = len; - codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + codes = PyMem_MALLOC((len + 1) * sizeof(formatcode)); if (codes == NULL) { PyErr_NoMemory(); return -1; @@ -1044,17 +1042,27 @@ e = getentry(c, f); size = align(size, c, e); - if (c != 'x') { + if (c == 's' || c == 'p') { codes->offset = size; - codes->repeat = num; + codes->size = num; codes->fmtdef = e; codes++; + size += num; + } else if (c == 'x') { + size += num; + } else { + while (--num >= 0) { + codes->offset = size; + codes->size = e->size; + codes->fmtdef = e; + codes++; + size += e->size; + } } - size += num * e->size; } codes->fmtdef = NULL; - codes->offset = -1; - codes->repeat = -1; + codes->offset = size; + codes->size = 0; return 0; } @@ -1121,31 +1129,27 @@ return NULL; for (code = soself->s_codes; code->fmtdef != NULL; code++) { - Py_ssize_t n; PyObject *v; const formatdef *e = code->fmtdef; const char *res = startfrom + code->offset; if (e->format == 's') { - v = PyString_FromStringAndSize(res, code->repeat); + v = PyString_FromStringAndSize(res, code->size); if (v == NULL) goto fail; PyTuple_SET_ITEM(result, i++, v); } else if (e->format == 'p') { - n = *(unsigned char*)res; - if (n >= code->repeat) - n = code->repeat - 1; + Py_ssize_t n = *(unsigned char*)res; + if (n >= code->size) + n = code->size - 1; v = PyString_FromStringAndSize(res + 1, n); if (v == NULL) goto fail; PyTuple_SET_ITEM(result, i++, v); } else { - for (n = 0; n < code->repeat; n++) { - v = e->unpack(res, e); - if (v == NULL) - goto fail; - PyTuple_SET_ITEM(result, i++, v); - res += e->size; - } + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); } } @@ -1269,8 +1273,8 @@ goto fail; } n = PyString_GET_SIZE(v); - if (n > code->repeat) - n = code->repeat; + if (n > code->size) + n = code->size; if (n > 0) memcpy(res, PyString_AS_STRING(v), n); } else if (e->format == 'p') { @@ -1281,20 +1285,17 @@ goto fail; } n = PyString_GET_SIZE(v); - if (n > (code->repeat - 1)) - n = code->repeat - 1; + if (n > (code->size - 1)) + n = code->size - 1; if (n > 0) memcpy(res + 1, PyString_AS_STRING(v), n); if (n > 255) n = 255; *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); } else { - for (n = 0; n < code->repeat; n++) { - v = PyTuple_GET_ITEM(args, i++); - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; } } From python-checkins at python.org Wed May 24 16:28:12 2006 From: python-checkins at python.org (fredrik.lundh) Date: Wed, 24 May 2006 16:28:12 +0200 (CEST) Subject: [Python-checkins] r46173 - python/trunk/Objects/unicodeobject.c Message-ID: <20060524142812.2F0081E401B@bag.python.org> Author: fredrik.lundh Date: Wed May 24 16:28:11 2006 New Revision: 46173 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: use "fastsearch" for count and findstring helpers. this results in a 2.5x speedup on the stringbench count tests, and a 20x (!) speedup on the stringbench search/find/contains test, compared to 2.5a2. for more on the algorithm, see: http://effbot.org/zone/stringlib.htm if you get weird results, you can disable the new algoritm by undefining USE_FAST in Objects/unicodeobject.c. enjoy /F Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Wed May 24 16:28:11 2006 @@ -3848,7 +3848,94 @@ /* --- Helpers ------------------------------------------------------------ */ -static Py_ssize_t count(PyUnicodeObject *self, +#define USE_FAST /* experimental fast search implementation */ + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +LOCAL(int) fastsearch(Py_UNICODE* s, Py_ssize_t n, + Py_UNICODE* p, Py_ssize_t m, + int mode) +{ + long mask; + int skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m < 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else { + i = i + skip; + continue; + } + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +LOCAL(Py_ssize_t) count(PyUnicodeObject *self, Py_ssize_t start, Py_ssize_t end, PyUnicodeObject *substring) @@ -3869,6 +3956,14 @@ if (substring->length == 0) return (end - start + 1); +#ifdef USE_FAST + count = fastsearch( + PyUnicode_AS_UNICODE(self) + start, end - start, + substring->str, substring->length, FAST_COUNT + ); + if (count < 0) + count = 0; /* no match */ +#else end -= substring->length; while (start <= end) @@ -3877,6 +3972,7 @@ start += substring->length; } else start++; +#endif return count; } @@ -3927,6 +4023,18 @@ if (substring->length == 0) return (direction > 0) ? start : end; +#ifdef USE_FAST + if (direction > 0) { + Py_ssize_t pos = fastsearch( + PyUnicode_AS_UNICODE(self) + start, end - start, + substring->str, substring->length, FAST_SEARCH + ); + if (pos < 0) + return pos; + return pos + start; + } +#endif + end -= substring->length; if (direction < 0) { From python-checkins at python.org Wed May 24 16:46:36 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 16:46:36 +0200 (CEST) Subject: [Python-checkins] r46174 - python/branches/sreifschneider-64ints Message-ID: <20060524144636.6672F1E4009@bag.python.org> Author: sean.reifschneider Date: Wed May 24 16:46:36 2006 New Revision: 46174 Removed: python/branches/sreifschneider-64ints/ Log: Removing 64-bit int test. From python-checkins at python.org Wed May 24 16:47:24 2006 From: python-checkins at python.org (richard.jones) Date: Wed, 24 May 2006 16:47:24 +0200 (CEST) Subject: [Python-checkins] r46175 - python/branches/rjones-prealloc/Objects/listobject.c Message-ID: <20060524144724.D569F1E4009@bag.python.org> Author: richard.jones Date: Wed May 24 16:47:24 2006 New Revision: 46175 Modified: python/branches/rjones-prealloc/Objects/listobject.c Log: minor paranoia Modified: python/branches/rjones-prealloc/Objects/listobject.c ============================================================================== --- python/branches/rjones-prealloc/Objects/listobject.c (original) +++ python/branches/rjones-prealloc/Objects/listobject.c Wed May 24 16:47:24 2006 @@ -2390,6 +2390,11 @@ " too small to contain supplied sequence"); return -1; } + if (size < 0) { + PyErr_SetString(PyExc_ValueError, "size argument" + " must be positive"); + return -1; + } /* (p)re-allocate to the indicated size */ items = self->ob_item; if (size <= ((~(size_t)0) / sizeof(PyObject *))) From python-checkins at python.org Wed May 24 16:48:09 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 16:48:09 +0200 (CEST) Subject: [Python-checkins] r46176 - python/branches/sreifschneider-newnewexcept Message-ID: <20060524144809.E699A1E4009@bag.python.org> Author: sean.reifschneider Date: Wed May 24 16:48:09 2006 New Revision: 46176 Added: python/branches/sreifschneider-newnewexcept/ - copied from r46175, python/trunk/ Log: For testing new new-type exceptions. From amk at amk.ca Wed May 24 16:58:36 2006 From: amk at amk.ca (A.M. Kuchling) Date: Wed, 24 May 2006 10:58:36 -0400 Subject: [Python-checkins] r46173 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060524142812.2F0081E401B@bag.python.org> References: <20060524142812.2F0081E401B@bag.python.org> Message-ID: <20060524145836.GA26004@rogue.amk.ca> On Wed, May 24, 2006 at 04:28:12PM +0200, fredrik.lundh wrote: > + if (m <= 1) { > + if (m < 0) > + return -1; > + /* use special case for 1-character strings */ The special case is also arrived at if m==0; is that desired? (Perhaps the caller of fastsearch will have already checked this case.) A very neat approach! --amk From python-checkins at python.org Wed May 24 16:56:27 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 16:56:27 +0200 (CEST) Subject: [Python-checkins] r46177 - in python/branches/blais-bytebuf: Lib/test/test_hotbuf.py Modules/hotbufmodule.c Message-ID: <20060524145627.F1E751E401B@bag.python.org> Author: martin.blais Date: Wed May 24 16:56:27 2006 New Revision: 46177 Added: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (contents, props changed) Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c Log: Added basic java buffer operations on hotbuf Added: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- (empty file) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Wed May 24 16:56:27 2006 @@ -0,0 +1,81 @@ +# Test the hotbuf module. +# +# $Id$ +# +# Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) +# Licensed to PSF under a Contributor Agreement. +# + +from hotbuf import hotbuf +import unittest +from test import test_support + + +class HotbufTestCase(unittest.TestCase): + + def test_base( self ): + CAPACITY = 1024 + + # Create a new hotbuf + self.assertRaises(ValueError, hotbuf, -1) + self.assertRaises(ValueError, hotbuf, 0) + b = hotbuf(CAPACITY) + self.assertEquals(len(b), CAPACITY) + self.assertEquals(b.capacity(), CAPACITY) + + # Play with the position + assert b.position() == 0 + b.setposition(10) + self.assertEquals(b.position(), 10) + self.assertRaises(IndexError, b.setposition, CAPACITY + 1) + + # Play with the limit + assert b.limit() == CAPACITY + b.setlimit(CAPACITY - 10) + self.assertEquals(b.limit(), CAPACITY - 10) + self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + b.setlimit(b.position() - 1) + self.assertEquals(b.position(), b.limit()) + + # Play with reset before the mark has been set. + self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + + # Play with the mark + b.setposition(10) + b.setlimit(100) + b.setmark() + b.setposition(15) + self.assertEquals(b.mark(), 10) + + # Play with clear + b.clear() + self.assertEquals((b.position(), b.limit(), b.mark()), + (0, CAPACITY, -1)) + + # Play with flip. + b.setposition(42) + b.setlimit(104) + b.setmark() + b.flip() + self.assertEquals((b.position(), b.limit(), b.mark()), + (0, 42, -1)) + + # Play with rewind. + b.setposition(42) + b.setlimit(104) + b.setmark() + b.rewind() + self.assertEquals((b.position(), b.limit(), b.mark()), + (0, 104, -1)) + + # Play with remaining. + self.assertEquals(b.remaining(), 104) + + +def test_main(): + test_support.run_unittest(HotbufTestCase) + + +if __name__ == "__main__": + test_main() + Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/hotbufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 16:56:27 2006 @@ -28,13 +28,37 @@ #endif /* !Py_HOTBUFOBJECT_H */ + /* =========================================================================== - * Byte Buffer object implementation + * Byte Buffer object implementation */ /* * hotbuf object structure declaration. + + From the Java Buffer docs: + + A buffer is a linear, finite sequence of elements of a specific + primitive type. Aside from its content, the essential properties of a + buffer are its capacity, limit, and position: + + A buffer's capacity is the number of elements it contains. The + capacity of a buffer is never negative and never changes. + + A buffer's limit is the index of the first element that should not + be read or written. A buffer's limit is never negative and is never + greater than its capacity. + + A buffer's position is the index of the next element to be read or + written. A buffer's position is never negative and is never greater + than its limit. + + The following invariant holds for the mark, position, limit, and + capacity values: + + 0 <= mark <= position <= limit <= capacity (length) + */ typedef struct { PyObject_HEAD @@ -44,7 +68,31 @@ /* Total size in bytes of the area that we can access. The allocated memory must be at least as large as this size. */ - Py_ssize_t b_size; + Py_ssize_t b_capacity; + + /* + * The "active window" is defined by the interval [position, limit[. + */ + + /* The current position in the buffer. */ + int b_position; + + /* The limit position in the buffer. */ + int b_limit; + + /* The mark. From the Java Buffer docs: + + A buffer's mark is the index to which its position will be reset when + the reset method is invoked. The mark is not always defined, but when + it is defined it is never negative and is never greater than the + position. If the mark is defined then it is discarded when the + position or the limit is adjusted to a value smaller than the mark. If + the mark is not defined then invoking the reset method causes an + InvalidMarkException to be thrown. + + The mark is set to -1 to indicate that the mark is unset. + */ + int b_mark; } PyHotbufObject; @@ -58,26 +106,29 @@ * Create a new hotbuf where we allocate the memory ourselves. */ PyObject * -PyHotbuf_New(Py_ssize_t size) +PyHotbuf_New(Py_ssize_t capacity) { PyObject *o; PyHotbufObject * b; - if (size < 0) { + if (capacity < 0) { PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); + "capacity must be zero or positive"); return NULL; } /* FIXME: check for overflow in multiply */ - o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size); + o = (PyObject *)PyObject_MALLOC(sizeof(*b) + capacity); if ( o == NULL ) return PyErr_NoMemory(); b = (PyHotbufObject *) PyObject_INIT(o, &PyHotbuf_Type); /* We setup the memory buffer to be right after the object itself. */ b->b_ptr = (void *)(b + 1); - b->b_size = size; + b->b_position = 0; + b->b_mark = -1; + b->b_limit = capacity; + b->b_capacity = capacity; return o; } @@ -94,12 +145,12 @@ if (!_PyArg_NoKeywords("hotbuf()", kw)) return NULL; - + if (!PyArg_ParseTuple(args, "n:hotbuf", &size)) return NULL; if ( size <= 0 ) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "size must be greater than zero"); return NULL; } @@ -118,27 +169,29 @@ PyObject_DEL(self); } -/* - * Comparison. +/* + * Comparison. We compare the active windows, not the entire allocated buffer + * memory. */ static int hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) { Py_ssize_t min_len; int cmp; - - min_len = (self->b_size < other->b_size) ? self->b_size : other->b_size; + + min_len = ((self->b_capacity < other->b_capacity) ? + self->b_capacity : other->b_capacity); if (min_len > 0) { cmp = memcmp(self->b_ptr, other->b_ptr, min_len); if (cmp != 0) return cmp; } - return ((self->b_size < other->b_size) ? - -1 : (self->b_size > other->b_size) ? 1 : 0); + return ((self->b_capacity < other->b_capacity) ? + -1 : (self->b_capacity > other->b_capacity) ? 1 : 0); } -/* +/* * Conversion to 'repr' string. */ static PyObject * @@ -146,21 +199,276 @@ { return PyString_FromFormat("", self->b_ptr, - self->b_size, + self->b_capacity, self); } -/* - * Conversion to string. +/* + * Conversion to string. We convert only the active window. */ static PyObject * hotbuf_str(PyHotbufObject *self) { - return PyString_FromStringAndSize((const char *)self->b_ptr, self->b_size); + return PyString_FromStringAndSize((const char *)self->b_ptr, self->b_capacity); +} + + + +/* =========================================================================== + * Object Methods + */ + +PyDoc_STRVAR(capacity__doc__, +"B.capacity() -> int\n\ +\n\ +Returns this buffer's capacity. \n\ +(the entire size of the allocated buffer.)"); + +static PyObject* +hotbuf_capacity(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_capacity); +} + + +PyDoc_STRVAR(position__doc__, +"B.position() -> int\n\ +\n\ +Returns this buffer's position."); + +static PyObject* +hotbuf_position(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_position); +} + + +PyDoc_STRVAR(setposition__doc__, +"B.setposition(int)\n\ +\n\ +Sets this buffer's position. If the mark is defined and larger than\n\ +the new position then it is discarded. If the given position is\n\ +larger than the limit an exception is raised."); + +static PyObject* +hotbuf_setposition(PyHotbufObject *self, PyObject* arg) +{ + int newposition; + + newposition = PyInt_AsLong(arg); + if (newposition == -1 && PyErr_Occurred()) + return NULL; + + if ( newposition > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than capacity"); + return NULL; + } + + /* Set the new position */ + self->b_position = newposition; + + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + return Py_None; +} + + +PyDoc_STRVAR(limit__doc__, +"B.limit() -> int\n\ +\n\ +Returns this buffer's limit."); + +static PyObject* +hotbuf_limit(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_limit); +} + + +PyDoc_STRVAR(setlimit__doc__, +"B.setlimit(int)\n\ +\n\ +Sets this buffer's limit. If the position is larger than the new limit\n\ +then it is set to the new limit. If the mark is defined and larger\n\ +than the new limit then it is discarded."); + +static PyObject* +hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) +{ + int newlimit; + + newlimit = PyInt_AsLong(arg); + if (newlimit == -1 && PyErr_Occurred()) + return NULL; + + if ( newlimit > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "limit must be smaller than capacity"); + return NULL; + } + + /* Set the new limit. */ + self->b_limit = newlimit; + + /* If the position is larger than the new limit, set it to the new + limit. */ + if ( self->b_position > self->b_limit ) + self->b_position = newlimit; + + /* Discard the mark if it is beyond the new limit */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + return Py_None; +} + + +PyDoc_STRVAR(mark__doc__, +"B.mark() -> int\n\ +\n\ +Returns this buffer's mark. \n\ +Return -1 if the mark is not set."); + +static PyObject* +hotbuf_mark(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_mark); +} + + +PyDoc_STRVAR(setmark__doc__, +"B.setmark()\n\ +\n\ +Sets this buffer's mark at its position."); + +static PyObject* +hotbuf_setmark(PyHotbufObject *self) +{ + self->b_mark = self->b_position; + return Py_None; +} + + +PyDoc_STRVAR(reset__doc__, +"B.reset() -> int\n\ +\n\ +Resets this buffer's position to the previously-marked position.\n\ +Invoking this method neither changes nor discards the mark's value.\n\ +An IndexError is raised if the mark has not been set.\n\ +This method returns the new position's value."); + +static PyObject* +hotbuf_reset(PyHotbufObject *self) +{ + if ( self->b_mark == -1 ) { + PyErr_SetString(PyExc_IndexError, + "mark has not been yet set"); + return NULL; + } + + self->b_position = self->b_mark; + return PyInt_FromLong(self->b_position); +} + + +PyDoc_STRVAR(clear__doc__, +"B.clear()\n\ +\n\ +Clears this buffer. The position is set to zero, the limit is set to\n\ +the capacity, and the mark is discarded.\n\ +\n\ +Invoke this method before using a sequence of channel-read or put\n\ +operations to fill this buffer. For example:\n\ +\n\ + buf.clear() # Prepare buffer for reading\n\ + in.read(buf) # Read data\n\ +\n\ +(This method does not actually erase the data in the buffer, but it is\n\ +named as if it did because it will most often be used in situations in\n\ +which that might as well be the case.)"); + +static PyObject* +hotbuf_clear(PyHotbufObject *self) +{ + self->b_position = 0; + self->b_limit = self->b_capacity; + self->b_mark = -1; + return Py_None; } -/* Hotbuf methods */ +PyDoc_STRVAR(flip__doc__, +"B.flip()\n\ +\n\ +Flips this buffer. The limit is set to the current position and then\n\ +the position is set to zero. If the mark is defined then it is\n\ +discarded.\n\ +\n\ +After a sequence of channel-read or put operations, invoke this method\n\ +to prepare for a sequence of channel-write or relative get\n\ +operations. For example:\n\ +\n\ + buf.put(magic) # Prepend header\n\ + in.read(buf) # Read data into rest of buffer\n\ + buf.flip() # Flip buffer\n\ + out.write(buf) # Write header + data to channel\n\ +\n\ +This method is often used in conjunction with the compact method when\n\ +transferring data from one place to another."); + +static PyObject* +hotbuf_flip(PyHotbufObject *self) +{ + self->b_limit = self->b_position; + self->b_position = 0; + self->b_mark = -1; + return Py_None; +} + + +PyDoc_STRVAR(rewind__doc__, +"B.rewind()\n\ +\n\ +Rewinds this buffer. The position is set to zero and the mark is\n\ +discarded.\n\ +\n\ +Invoke this method before a sequence of channel-write or get\n\ +operations, assuming that the limit has already been set\n\ +appropriately. For example:\n\ +\n\ + out.write(buf) # Write remaining data\n\ + buf.rewind() # Rewind buffer\n\ + buf.get(array) # Copy data into array\n\ +"); + +static PyObject* +hotbuf_rewind(PyHotbufObject *self) +{ + self->b_position = 0; + self->b_mark = -1; + return Py_None; +} + + +PyDoc_STRVAR(remaining__doc__, +"B.remaining() -> int\n\ +\n\ +Returns the number of bytes between the current position and the limit."); + +static PyObject* +hotbuf_remaining(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_limit - self->b_position); +} + + + +/* =========================================================================== + * Buffer protocol methods + */ /* * Returns the buffer for reading or writing. @@ -175,14 +483,14 @@ } *pp = self->b_ptr; - return self->b_size; + return self->b_capacity; } static Py_ssize_t hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) { if (lenp) - *lenp = self->b_size; + *lenp = self->b_capacity; return 1; } @@ -196,22 +504,26 @@ } *pp = (const char *)self->b_ptr; - return self->b_size; + return self->b_capacity; } + + /* =========================================================================== - * Sequence methods + * Sequence methods */ static Py_ssize_t hotbuf_length(PyHotbufObject *self) { - return self->b_size; + assert(self->b_position <= self->b_limit); + return self->b_limit - self->b_position; } + /* =========================================================================== - * Object interfaces declaration + * Object interfaces declaration */ /* FIXME: needs an update */ @@ -236,6 +548,23 @@ "); +static PyMethodDef +hotbuf_methods[] = { + {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, + {"capacity", (PyCFunction)hotbuf_capacity, METH_NOARGS, capacity__doc__}, + {"position", (PyCFunction)hotbuf_position, METH_NOARGS, position__doc__}, + {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, + {"limit", (PyCFunction)hotbuf_limit, METH_NOARGS, limit__doc__}, + {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, + {"mark", (PyCFunction)hotbuf_mark, METH_NOARGS, mark__doc__}, + {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, + {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, + {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, + {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, + {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, + {NULL, NULL} /* sentinel */ +}; + static PySequenceMethods hotbuf_as_sequence = { (lenfunc)hotbuf_length, /*sq_length*/ 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ @@ -259,12 +588,12 @@ "hotbuf", sizeof(PyHotbufObject), 0, - (destructor)hotbuf_dealloc, /* tp_dealloc */ + (destructor)hotbuf_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)hotbuf_compare, /* tp_compare */ - (reprfunc)hotbuf_repr, /* tp_repr */ + (cmpfunc)hotbuf_compare, /* tp_compare */ + (reprfunc)hotbuf_repr, /* tp_repr */ 0, /* tp_as_number */ &hotbuf_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ @@ -282,7 +611,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - 0, /* tp_methods */ + hotbuf_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -296,6 +625,7 @@ }; + /* =========================================================================== * Install Module */ @@ -345,13 +675,14 @@ -/* +/* TODO ---- - Update doc. - Add hash function - Add support for sequence methods. - + - Perhaps implement returning the buffer object itself from some of + the methods in order to allow chaining of operations on a single line. Pending Issues -------------- From python-checkins at python.org Wed May 24 17:02:00 2006 From: python-checkins at python.org (jack.diederich) Date: Wed, 24 May 2006 17:02:00 +0200 (CEST) Subject: [Python-checkins] r46178 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Message-ID: <20060524150200.27A4A1E4031@bag.python.org> Author: jack.diederich Date: Wed May 24 17:01:56 2006 New Revision: 46178 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Log: * Decimal.__str__ and Decimal.to_eng_string implemented Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 17:01:56 2006 @@ -285,6 +285,7 @@ static contextobject * context_copy(contextobject *); static PyObject *decimal_from_long(PyTypeObject *, long); static PyObject *decimal_str(decimalobject *); +static PyObject *_do_decimal_str(decimalobject *, contextobject *, int); /* Decimal methods ***********************************************************/ @@ -1099,7 +1100,6 @@ STUB(sqrt) -STUB(to_eng_string) STUB(to_integral) @@ -1179,6 +1179,240 @@ return res; } +/* + max length of output is len(str(max_long)) + len(str(max_long)) + + len(".") + len("-") +*/ +#define FORMAT_SIZE 50 +#define SANITY_CHECK(x) assert((x) < end); + +static PyObject * +decimal_special_str(decimalobject *d) +{ + char outbuf[FORMAT_SIZE]; + char *p, *end; + int i; + end = &outbuf[FORMAT_SIZE]; + p = outbuf; + + if (d->sign & 1) + *p++ = '-'; + + if (GETNAN(d)) { + if (GETNAN(d) == 2) + *p++ = 's'; + SANITY_CHECK(p); + p += sprintf(p, "%s", "NaN"); + SANITY_CHECK(p); + + /* check for digits != {0, } */ + if (d->ob_size != 1 || d->digits[0] != 0) { + for (i = 0; i < d->ob_size; i++) { + p += sprintf(p, "%d", d->digits[i]); + SANITY_CHECK(p); + } + } + } else { /* infinity */ + p += sprintf(p, "%s", "Infinity"); + } + *p++ = 0; + SANITY_CHECK(p); + return PyString_FromString(p); +} + +static PyObject * +decimal_eng_zero_str(decimalobject *d, contextobject *context) +{ + char outbuf[FORMAT_SIZE]; + char *p, *end; + int roundexp, i; + + p = outbuf; + if (d->sign & 1) { + *p++ = '-'; + SANITY_CHECK(p); + } + if (d->exp < 0 && d->exp >= -6) { + /* figure out the right number of digits */ + i = sprintf(p, "0.%0*d", abs(d->exp), 0); + /* and write those as zeros */ + for (; i > 0; i--) { + *p++ = '0'; + } + SANITY_CHECK(p); + } else { + roundexp = ((d->exp - 1)/3 + 1) * 3; /* nearest gt mult of 3 */ + if (roundexp != d->exp) { + for (i = 0; i < (roundexp - d->exp); i++) + *p++ = '0'; + SANITY_CHECK(p); + } else { + *p++ = '0'; + } + if (roundexp != 0) { + if (context->capitals) + *p++ = 'E'; + else + *p++ = 'e'; + SANITY_CHECK(p); + + if (roundexp > 0) + *p++ = '+'; + SANITY_CHECK(p); + + p += sprintf(p, "%d", roundexp); + SANITY_CHECK(p); + } + } + return PyString_FromString(p); +} + +PyObject * +decimal_to_eng_string(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"context", 0}; + PyObject *context = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", kwlist, &context, &PyDecimal_DecimalContextType)) + return NULL; + return _do_decimal_str((decimalobject *)self, (contextobject *)context, 1); +} +PyObject * +PyDecimal_Str(PyObject *self, PyObject *args, PyObject *kwds) +{ + return _do_decimal_str((decimalobject *)self, NULL, 0); +} + +static PyObject * +decimal_str(decimalobject *d) +{ + return _do_decimal_str(d, NULL, 0); +} + +static PyObject * +_do_decimal_str(decimalobject *d, contextobject *context, int engineering) +{ + char *outbuf; + int buflen, i, imax, j; + int leftdigits, dotplace, adjexp; + int append_E = 0, append_adjexp = 0; + char *p, *end; + PyObject *ret; + + if (context == NULL) { + context = getcontext(); + if (!context) + return NULL; + } + + if (ISSPECIAL(d)) + return decimal_special_str(d); + if (engineering && !decimal_nonzero(d)) + return decimal_eng_zero_str(d, context); + + buflen = FORMAT_SIZE + d->ob_size; + outbuf = (char *)PyMem_MALLOC(buflen); + if (outbuf == NULL) + return NULL; + + end = outbuf + buflen; + p = &outbuf[1]; /* reserve the first byte for a possible leading zero */ + + if (d->sign & 1) { + *p++ = '-'; + } + + leftdigits = d->exp + d->ob_size; + if (engineering) { + dotplace = (leftdigits-1)%3+1; + adjexp = leftdigits -1 - (leftdigits-1)%3; + } else { + dotplace = 1; + adjexp = leftdigits - 1; + } + if (d->exp == 0) { + dotplace = -1; /* no dot */ + } else if (d->exp < 0 && adjexp >= 0) { + dotplace = leftdigits; + } else if (d->exp < 0 && adjexp >= -6) { + if (!engineering) { /* eng has no leading zeros */ + for (i = leftdigits; i < 0; i++) { + *p++ = '0'; + SANITY_CHECK(p); + } + *p++ = '0'; + } + } else { + if (d->ob_size <= dotplace) + dotplace = -1; + + if (adjexp) { + append_E = 1; + append_adjexp = 1; + } + } + + imax = d->ob_size; + if (dotplace > 0) { + imax++; + } + if (engineering) { /* eng has no leading zeros */ + for (i = 0, j = 0; i < imax; i++) { + if (d->digits[j] == 0) { + j++; + } else { + break; + } + } + } + for (i = 0, j = 0; i < imax; i++) { + if (i == dotplace) { + *p++ = '.'; + SANITY_CHECK(p); + continue; + } else { + p += sprintf(p, "%d", d->digits[j]); + SANITY_CHECK(p); + j++; + } + } + + if (append_E) { + if (context->capitals) { + *p++ = 'E'; + SANITY_CHECK(p); + if (adjexp > 0) { + *p++ = '+'; + SANITY_CHECK(p); + } + } else { + *p++ = 'e'; + SANITY_CHECK(p); + } + } + + if (append_adjexp) { + p += sprintf(p, "%d", adjexp); + } + SANITY_CHECK(p); + *p++ = 0; + SANITY_CHECK(p); + + /* if engineering and (just a sign | empty | starts with a dot or an E) */ + if (engineering && ((p - &outbuf[1] > (d->sign & 1)) || outbuf[1] == '.' || + outbuf[1] == 'E' || outbuf[1] == 'e')) { + outbuf[0] = '0'; + p = outbuf; + } else { + p = &outbuf[1]; + } + SANITY_CHECK(p); + ret = PyString_FromString(p); + PyMem_FREE(outbuf); + return ret; +} +#undef SANITY_CHECK + static PyMethodDef decimal_methods[] = { {"adjusted", (PyCFunction)decimal_adjusted, METH_NOARGS, @@ -2058,135 +2292,6 @@ return NULL; } -/* - max length of output is len(str(max_long)) + len(str(max_long)) + - len(".") + len("-") -*/ -#define FORMAT_SIZE 50 -#define SANITY_CHECK(x) assert((x) < end); - -static PyObject * -decimal_special_str(decimalobject *d) -{ - char outbuf[FORMAT_SIZE]; - char *p, *end; - int i; - end = &outbuf[FORMAT_SIZE]; - p = outbuf; - - if (d->sign & 1) - *p++ = '-'; - - if (GETNAN(d)) { - if (GETNAN(d) == 2) - *p++ = 's'; - SANITY_CHECK(p); - p += sprintf(p, "%s", "NaN"); - SANITY_CHECK(p); - - /* check for digits != {0, } */ - if (d->ob_size != 1 || d->digits[0] != 0) { - for (i = 0; i < d->ob_size; i++) { - p += sprintf(p, "%d", d->digits[i]); - SANITY_CHECK(p); - } - } - } else { /* infinity */ - p += sprintf(p, "%s", "Infinity"); - } - *p++ = 0; - SANITY_CHECK(p); - return PyString_FromString(p); -} - -static PyObject * -decimal_str(decimalobject *d) -{ - char outbuf[FORMAT_SIZE]; - int i, imax, j; - int leftdigits, dotplace, adjexp; - int append_E = 0, append_adjexp = 0; - char *p, *end; - end = &outbuf[FORMAT_SIZE]; - contextobject *context = NULL; /* debug, make this an arg */ - - if (ISSPECIAL(d)) - return decimal_special_str(d); - - if (context == NULL) { - context = getcontext(); - if (!context) - return NULL; - } - if (d->sign & 1) { - outbuf[0] = '-'; - p = &outbuf[1]; - } else { - p = &outbuf[0]; - } - - leftdigits = d->exp + d->ob_size; - adjexp = leftdigits - 1; - dotplace = 1; - if (d->exp) { - dotplace = -1; /* no dot */ - } else if (d->exp < 0 && adjexp >= 0) { - dotplace = leftdigits; - } else if (d->exp < 0 && adjexp >= -6) { - for (i = leftdigits; i < 0; i++) { - *p++ = '0'; - SANITY_CHECK(p); - } - *p++ = '0'; - } else { - if (d->ob_size <= dotplace) - dotplace = -1; - - if (adjexp) { - append_E = 1; - append_adjexp = 1; - } - } - - imax = d->ob_size; - if (dotplace > 0) { - imax++; - } - for (i = 0, j = 0; i < imax; i++) { - if (i == dotplace) { - *p++ = '.'; - SANITY_CHECK(p); - continue; - } else { - p += sprintf(p, "%d", d->digits[j]); - SANITY_CHECK(p); - j++; - } - } - - if (append_E) { - if (context->capitals) { - *p++ = 'E'; - SANITY_CHECK(p); - if (adjexp > 0) { - *p++ = '+'; - SANITY_CHECK(p); - } - } else { - *p++ = 'e'; - SANITY_CHECK(p); - } - } - if (append_adjexp) { - p += sprintf(p, "%d", adjexp); - } - SANITY_CHECK(p); - *p++ = 0; - SANITY_CHECK(p); - return PyString_FromString(&outbuf); -} -#undef SANITY_CHECK - static PyObject * decimal_repr(decimalobject *d) { Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Wed May 24 17:01:56 2006 @@ -782,98 +782,6 @@ # Invariant: eval(repr(d)) == d return 'Decimal("%s")' % str(self) - def __str__(self, eng = 0, context=None): - """Return string representation of the number in scientific notation. - - Captures all of the information in the underlying representation. - """ - - if self._is_special: - if self._isnan(): - minus = '-'*self._sign - if self._int == (0,): - info = '' - else: - info = ''.join(map(str, self._int)) - if self._isnan() == 2: - return minus + 'sNaN' + info - return minus + 'NaN' + info - if self._isinfinity(): - minus = '-'*self._sign - return minus + 'Infinity' - - if context is None: - context = getcontext() - - tmp = map(str, self._int) - numdigits = len(self._int) - leftdigits = self._exp + numdigits - if eng and not self: #self = 0eX wants 0[.0[0]]eY, not [[0]0]0eY - if self._exp < 0 and self._exp >= -6: #short, no need for e/E - s = '-'*self._sign + '0.' + '0'*(abs(self._exp)) - return s - #exp is closest mult. of 3 >= self._exp - exp = ((self._exp - 1)// 3 + 1) * 3 - if exp != self._exp: - s = '0.'+'0'*(exp - self._exp) - else: - s = '0' - if exp != 0: - if context.capitals: - s += 'E' - else: - s += 'e' - if exp > 0: - s += '+' #0.0e+3, not 0.0e3 - s += str(exp) - s = '-'*self._sign + s - return s - if eng: - dotplace = (leftdigits-1)%3+1 - adjexp = leftdigits -1 - (leftdigits-1)%3 - else: - adjexp = leftdigits-1 - dotplace = 1 - if self._exp == 0: - pass - elif self._exp < 0 and adjexp >= 0: - tmp.insert(leftdigits, '.') - elif self._exp < 0 and adjexp >= -6: - tmp[0:0] = ['0'] * int(-leftdigits) - tmp.insert(0, '0.') - else: - if numdigits > dotplace: - tmp.insert(dotplace, '.') - elif numdigits < dotplace: - tmp.extend(['0']*(dotplace-numdigits)) - if adjexp: - if not context.capitals: - tmp.append('e') - else: - tmp.append('E') - if adjexp > 0: - tmp.append('+') - tmp.append(str(adjexp)) - if eng: - while tmp[0:1] == ['0']: - tmp[0:1] = [] - if len(tmp) == 0 or tmp[0] == '.' or tmp[0].lower() == 'e': - tmp[0:0] = ['0'] - if self._sign: - tmp.insert(0, '-') - - return ''.join(tmp) - - def to_eng_string(self, context=None): - """Convert to engineering-type string. - - Engineering notation has an exponent which is a multiple of 3, so there - are up to 3 digits left of the decimal place. - - Same rules for when in exponential and when as a value as in __str__. - """ - return self.__str__(eng=1, context=context) - def __neg__(self, context=None): """Returns a copy with the sign switched. From python-checkins at python.org Wed May 24 17:06:18 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 17:06:18 +0200 (CEST) Subject: [Python-checkins] r46179 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524150618.26D171E401B@bag.python.org> Author: georg.brandl Date: Wed May 24 17:06:16 2006 New Revision: 46179 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Resolve conflict. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 17:06:16 2006 @@ -925,71 +925,83 @@ return Py_NotImplemented; } -#define STUB_HEAD static PyObject * -#define STUB_TAIL (PyObject *self, PyObject *args) { return NULL; } -#define STUB_TAIL1 (PyObject *self) { return NULL; } -#define STUB(name) STUB_HEAD decimal_##name STUB_TAIL -#define STUB1(name) STUB_HEAD decimal_##name STUB_TAIL1 - static char *ctxkwlist[] = {"context", 0}; +static char *decctxkwlist[] = {"other", "context", 0}; -#define ENSURE_DECIMAL(methname, dec) \ - dec = _convert_to_decimal((PyObject *)dec, ctx); \ - if (!dec) { \ - PyErr_SetString(PyExc_TypeError, methname ": " #dec " must be a Decimal object"); \ - return NULL; \ - } - -#define ENSURE_CONTEXT(methname, ctx) \ - if (ctx == NULL) { \ - if (!(ctx = getcontext())) return NULL; \ - } else if (!PyDecimalContext_Check(ctx)) { \ - PyErr_SetString(PyExc_TypeError, methname ": context must be a Context object"); \ - return NULL; \ - } - -#define PARSE_CONTEXT(methname, ctx) \ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" methname, ctxkwlist, &ctx)) \ - { return NULL; } \ - ENSURE_CONTEXT(methname, ctx) +#define ENSURE_DECIMAL(methname, dec, type) \ + dec = _convert_to_decimal(type, (PyObject *)dec, ctx, 1); \ + if (!dec) { \ + PyErr_SetString(PyExc_TypeError, methname ": " #dec " must be a Decimal object"); \ + return NULL; \ + } -STUB(compare) +#define ENSURE_CONTEXT(methname, ctx) \ + if (ctx == NULL) { \ + if (!(ctx = getcontext())) return NULL; \ + } else if (!PyDecimalContext_Check(ctx)) { \ + PyErr_SetString(PyExc_TypeError, methname ": context must be a Context object"); \ + return NULL; \ + } -static decimalobject * -decimal_max(decimalobject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"other", "context", 0}; - decimalobject *other = NULL; - contextobject *ctx = NULL; +#define DECIMAL_UNARY_FUNC(methname) \ + static PyObject * \ + decimal_##methname(decimalobject *self, PyObject *args, PyObject *kwds) \ + { \ + contextobject *ctx = NULL; \ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" #methname, ctxkwlist, &ctx)) \ + return NULL; \ + ENSURE_CONTEXT(#methname, ctx); \ + return _do_decimal_##methname(self, ctx); \ + } + +#define DECIMAL_BINARY_FUNC(methname) \ + static PyObject * \ + decimal_##methname(decimalobject *self, PyObject *args, PyObject *kwds) \ + { \ + decimalobject *res; \ + decimalobject *dec = NULL; \ + contextobject *ctx = NULL; \ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:" #methname, \ + decctxkwlist, &dec, &ctx)) \ + return NULL; \ + ENSURE_CONTEXT(#methname, ctx); \ + ENSURE_DECIMAL(#methname, dec, self->ob_type); \ + res = _do_decimal_##methname(self, dec, ctx); \ + Py_DECREF(dec); \ + return res; \ + } + - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:max", kwlist, - &other, &ctx)) - return NULL; - ENSURE_CONTEXT("max", ctx); +static decimalobject * +_do_decimal_compare(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ + /* XXX */ } +DECIMAL_BINARY_FUNC(compare) static decimalobject * -decimal_min(decimalobject *self, PyObject *args, PyObject *kwds) +_do_decimal_max(decimalobject *self, decimalobject *other, + contextobject *ctx) { - static char *kwlist[] = {"other", "context", 0}; - decimalobject *other = NULL; - contextobject *ctx = NULL; + /* XXX */ +} +DECIMAL_BINARY_FUNC(max) - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:min", kwlist, - &other, &ctx)) - return NULL; - ENSURE_CONTEXT("max", ctx); +static decimalobject * +_do_decimal_min(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ + /* XXX */ } +DECIMAL_BINARY_FUNC(min) /* strip trailing 0s, change anything equal to 0 to 0e0 */ static decimalobject * -decimal_normalize(decimalobject *self, PyObject *args, PyObject *kwds) +_do_decimal_normalize(decimalobject *self, contextobject *ctx) { decimalobject *dup, *new; - contextobject *ctx = NULL; - PARSE_CONTEXT("normalize", ctx); - if (ISSPECIAL(self)) { decimalobject *nan = NULL; int res; @@ -1016,8 +1028,32 @@ } return dup; } +DECIMAL_UNARY_FUNC(normalize) /* Quantize self so that its exponent is the same as the exponent of another. */ + +static decimalobject * +_do_decimal_quantize(decimalobject *self, decimalobject *other, + contextobject *ctx, int rounding, int watchexp) +{ + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan = NULL; + int res; + res = _check_nans(self, other, ctx, &nan); + if (res != 0) return nan; /* can be NULL on error */ + + if (ISINF(self) || ISINF(other)) { + if (ISINF(self) && ISINF(other)) { + Py_INCREF(self); + return self; + } + return handle_InvalidOperation(self->ob_type, ctx, + "quantize with one INF", NULL); + } + } + return _decimal_rescale(self, other->exp, ctx, rounding, watchexp); +} + static decimalobject * decimal_quantize(decimalobject *self, PyObject *args, PyObject *kwds) { @@ -1041,42 +1077,22 @@ PyErr_SetString(PyExc_TypeError, "exp must be a Decimal object"); return NULL; } - if (ISSPECIAL(self) || ISSPECIAL(other)) { - decimalobject *nan = NULL; - int res; - res = _check_nans(self, other, ctx, &nan); - if (res != 0) return nan; /* can be NULL on error */ - if (ISINF(self) || ISINF(other)) { - if (ISINF(self) && ISINF(other)) { - Py_INCREF(self); - return self; - } - return handle_InvalidOperation(self->ob_type, ctx, - "quantize with one INF", NULL); - } - } - return _decimal_rescale(self, other->exp, ctx, rounding, watchexp); + return _do_decimal_quantize(self, other, ctx, rounding, watchexp); } -STUB(remainder_near) - -static PyObject * -decimal_same_quantum(decimalobject *self, PyObject *args, PyObject *kwds) +static decimalobject * +_do_decimal_remainder_near(decimalobject *self, decimalobject *other, + contextobject *ctx) { - static char *kwlist[] = {"other", 0}; - decimalobject *other = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:same_quantum", kwlist, - &other)) - return NULL; +} +DECIMAL_BINARY_FUNC(remainder_near) - if (!PyDecimal_Check(other)) { - PyErr_SetString(PyExc_TypeError, "other must be a Decimal object"); - return NULL; - } +static PyObject * +_do_decimal_same_quantum(decimalobject *self, decimalobject *other) +{ if (ISSPECIAL(self) && ISSPECIAL(other)) { if (GETNAN(self) || GETNAN(other)) { if (GETNAN(self) && GETNAN(other)) @@ -1098,9 +1114,65 @@ Py_RETURN_FALSE; } +static PyObject * +decimal_same_quantum(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"other", 0}; + decimalobject *other = NULL; + + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:same_quantum", kwlist, + &other)) + return NULL; + + + if (!PyDecimal_Check(other)) { + PyErr_SetString(PyExc_TypeError, "other must be a Decimal object"); + return NULL; + } + + return _do_decimal_same_quantum(self, other); +} + + +static decimalobject * +_do_decimal_sqrt(decimalobject *self, contextobject *ctx) +{ +} +DECIMAL_UNARY_FUNC(sqrt) + + +static decimalobject * +_do_decimal_to_eng_string(decimalobject *self, contextobject *ctx) +{ + return _do_decimal_str(self, ctx, 1); +} +DECIMAL_UNARY_FUNC(to_eng_string) + -STUB(sqrt) -STUB(to_integral) +static decimalobject * +_do_decimal_to_integral(decimalobject *self, contextobject *ctx, int rounding) +{ + /* XXX */ +} + +static PyObject * +decimal_to_integral(decimalobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"rounding", "context", 0}; + contextobject *ctx = NULL; + int rounding = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iO:to_integral", kwlist, + &rounding, &ctx)) + return NULL; + ENSURE_CONTEXT("to_integral", ctx); + if (rounding < -1 || rounding > 6) { + PyErr_SetString(PyExc_ValueError, "invalid rounding value"); + return NULL; + } + return _do_decimal_to_integral(self, ctx, rounding); +} static PyObject * @@ -1268,16 +1340,6 @@ } PyObject * -decimal_to_eng_string(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"context", 0}; - PyObject *context = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", kwlist, &context, &PyDecimal_DecimalContextType)) - return NULL; - return _do_decimal_str((decimalobject *)self, (contextobject *)context, 1); -} -PyObject * PyDecimal_Str(PyObject *self, PyObject *args, PyObject *kwds) { return _do_decimal_str((decimalobject *)self, NULL, 0); @@ -2338,6 +2400,8 @@ tmp2 = PyTuple_New(0); if (!tmp2) return -1; + /* This is not calling _do_decimal_normalize because we're having + no Context ready. */ tmp = (PyObject *)decimal_normalize(d, tmp2, NULL); Py_DECREF(tmp2); if (!tmp) @@ -2583,10 +2647,59 @@ return new; } -/* Context methods ***********************************************************/ +/* Context properties *********************************************************/ -#define CSTUB(name) STUB_HEAD context_##name STUB_TAIL +static PyObject * +_dict_from_bitmask(int bitmask) +{ + PyObject *dict = NULL, *val, *dp; + int i, res; + + dict = PyDict_New(); + if (!dict) return NULL; + for (i = 0; i < NUMSIGNALS; i++) { + val = PyInt_FromLong(ISFLAGSET(bitmask, i)); + if (!val) goto err; + res = PyDict_SetItem(dict, errors[i], val); + Py_DECREF(val); + if (val < 0) goto err; + } + dp = PyDictProxy_New(dict); + Py_DECREF(dict); + return dp; + + err: + Py_XDECREF(dict); + return NULL; +} + +static PyObject * +context_get_flags(contextobject *self) +{ + return _dict_from_bitmask(self->flags); +} + +static PyObject * +context_get_traps(contextobject *self) +{ + return _dict_from_bitmask(self->traps); +} + +static PyObject * +context_get_ignored(contextobject *self) +{ + return _dict_from_bitmask(self->ignored); +} + +static PyGetSetDef context_getset[] = { + {"flags", (getter)context_get_flags, (setter)0}, + {"traps", (getter)context_get_traps, (setter)0}, + {"_ignored", (getter)context_get_ignored, (setter)0}, + {NULL} +}; + +/* Context methods ************************************************************/ static PyObject * context_clear_flags(contextobject *self) @@ -2674,7 +2787,7 @@ context_##name(contextobject *self, PyObject *args) { \ PyObject *a, *b; \ decimalobject *dec_a = NULL, *dec_b = NULL, *res; \ - if (!PyArg_ParseTuple(args, "OO:" #name)) return NULL; \ + if (!PyArg_ParseTuple(args, "OO:" #name, &a, &b)) return NULL; \ dec_a = (decimalobject *)_convert_to_decimal( \ &PyDecimal_DecimalType, a, self, 1); \ if (dec_a == NULL) return NULL; \ @@ -2687,7 +2800,7 @@ return res; \ } -/* helper so that I can use the CONTEXT_UNARY_FUNC macro above */ +/* helper so that we can use the CONTEXT_UNARY_FUNC macro above */ #define _do_decimal_abs_with_round(a, b) \ _do_decimal_absolute(a, b, 1) @@ -2696,25 +2809,177 @@ CONTEXT_BINARY_FUNC(divide, divide) CONTEXT_BINARY_FUNC(divide_int, floor_div) CONTEXT_BINARY_FUNC(divmod, divmod) +CONTEXT_BINARY_FUNC(remainder, remainder) CONTEXT_UNARY_FUNC(minus, negative) CONTEXT_BINARY_FUNC(multiply, multiply) CONTEXT_UNARY_FUNC(plus, positive) CONTEXT_BINARY_FUNC(subtract, subtract) -CSTUB(compare) -CSTUB(min) -CSTUB(max) -CSTUB(normalize) -CSTUB(power) -CSTUB(quantize) -CSTUB(reduce) -CSTUB(remainder) -CSTUB(remainder_near) -CSTUB(same_quantum) -CSTUB(sqrt) -CSTUB(to_eng_string) -CSTUB(to_integral) -CSTUB(to_sci_string) +CONTEXT_BINARY_FUNC(compare, compare) +CONTEXT_BINARY_FUNC(min, min) +CONTEXT_BINARY_FUNC(max, max) +CONTEXT_UNARY_FUNC(normalize, normalize) +CONTEXT_BINARY_FUNC(remainder_near, remainder_near) +CONTEXT_UNARY_FUNC(sqrt, sqrt) +CONTEXT_UNARY_FUNC(to_eng_string, to_eng_string) + + +/* Unfortunately, the following methods are non-standard and can't + be created by macros. */ + +static PyObject * +context_power(contextobject *self, PyObject *args) +{ + PyObject *a, *b, *c; + decimalobject *dec_a = NULL, *dec_b = NULL, *dec_c = NULL, *res; + if (!PyArg_ParseTuple(args, "OO|O:power", &a, &b, &c)) + return NULL; + dec_a = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, a, self, 1); + if (dec_a == NULL) + return NULL; + + dec_b = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, b, self, 1); + if (dec_b == NULL) { + Py_DECREF(dec_a); + return NULL; + } + + dec_c = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, c, self, 1); + if (dec_c == NULL) { + Py_DECREF(dec_a); + Py_DECREF(dec_b); + return NULL; + } + res = _do_decimal_power(dec_a, dec_b, dec_c, self); + Py_DECREF(dec_a); + Py_DECREF(dec_b); + Py_DECREF(dec_c); + return res; +} + + +static PyObject * +context_quantize(contextobject *self, PyObject *args) +{ + PyObject *a, *b; + decimalobject *dec_a = NULL, *dec_b = NULL, *res; + if (!PyArg_ParseTuple(args, "OO:quantize", &a, &b)) + return NULL; + + dec_a = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, a, self, 1); + if (dec_a == NULL) + return NULL; + + dec_b = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, b, self, 1); + if (dec_b == NULL) { + Py_DECREF(dec_a); + return NULL; + } + + res = _do_decimal_quantize(dec_a, dec_b, self, -1, 1); + Py_DECREF(dec_a); + Py_DECREF(dec_b); + return res; +} + + +static PyObject * +context_same_quantum(contextobject *self, PyObject *args) +{ + PyObject *a, *b, *res; + decimalobject *dec_a = NULL, *dec_b = NULL; + if (!PyArg_ParseTuple(args, "OO:same_quantum", &a, &b)) + return NULL; + + dec_a = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, a, self, 1); + if (dec_a == NULL) + return NULL; + + dec_b = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, b, self, 1); + if (dec_b == NULL) { + Py_DECREF(dec_a); + return NULL; + } + + res = _do_decimal_same_quantum(dec_a, dec_b); + Py_DECREF(dec_a); + Py_DECREF(dec_b); + return res; +} + + +static PyObject * +context_to_integral(contextobject *self, PyObject *args) +{ + PyObject *a, *res; + decimalobject *dec_a = NULL; + + if (!PyArg_ParseTuple(args, "O:to_integral", &a)) + return NULL; + + dec_a = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, a, self, 1); + if (dec_a == NULL) + return NULL; + + res = _do_decimal_to_integral(dec_a, self, -1); + Py_DECREF(dec_a); + return res; +} + + +static PyObject * +context_to_sci_string(contextobject *self, PyObject *args) +{ + PyObject *a, *res; + decimalobject *dec_a = NULL; + + if (!PyArg_ParseTuple(args, "O:to_sci_string", &a)) + return NULL; + + dec_a = (decimalobject *)_convert_to_decimal( + &PyDecimal_DecimalType, a, self, 1); + if (dec_a == NULL) + return NULL; + + /* XXX: default third argument? */ + res = _do_decimal_str(dec_a, self, -1); + Py_DECREF(dec_a); + return res; +} + + +static PyObject * +context_reduce(contextobject *self) +{ + PyObject *flags = NULL, *traps = NULL, *ignored = NULL; + PyObject *res = NULL; + + flags = context_get_flags(self); + if (!flags) goto err; + traps = context_get_traps(self); + if (!traps) goto err; + ignored = context_get_ignored(self); + if (!ignored) goto err; + + res = Py_BuildValue("liiOOlliiO", self->prec, self->rounding, + self->rounding_dec, traps, flags, self->Emin, + self->Emax, self->capitals, self->clamp, + ignored); + + err: + Py_XDECREF(flags); + Py_XDECREF(traps); + Py_XDECREF(ignored); + return res; +} static PyMethodDef context_methods[] = { @@ -2791,8 +3056,6 @@ c->ob_type->tp_free(c); } -CSTUB(richcompare) - static PyObject * context_repr(contextobject *self) { @@ -2973,59 +3236,6 @@ ignored); } -static PyObject * -context_get_flags(contextobject *self) -{ - PyObject *dict = NULL, *val, *dp; - int i, res; - - dict = PyDict_New(); - if (!dict) return NULL; - for (i = 0; i < NUMSIGNALS; i++) { - val = PyInt_FromLong(ISFLAGSET(self->flags, i)); - if (!val) goto err; - res = PyDict_SetItem(dict, errors[i], val); - Py_DECREF(val); - if (val < 0) goto err; - } - dp = PyDictProxy_New(dict); - Py_DECREF(dict); - return dp; - - err: - Py_XDECREF(dict); - return NULL; -} - -static PyObject * -context_get_traps(contextobject *self) -{ - PyObject *dict = NULL, *val, *dp; - int i, res; - - dict = PyDict_New(); - if (!dict) return NULL; - for (i = 0; i < NUMSIGNALS; i++) { - val = PyInt_FromLong(ISFLAGSET(self->traps, i)); - if (!val) goto err; - res = PyDict_SetItem(dict, errors[i], val); - Py_DECREF(val); - if (val < 0) goto err; - } - dp = PyDictProxy_New(dict); - Py_DECREF(dict); - return dp; - - err: - Py_XDECREF(dict); - return NULL; -} - -static PyGetSetDef context_getset[] = { - {"flags", (getter)context_get_flags, (setter)0}, - {"traps", (getter)context_get_traps, (setter)0}, - {NULL} -}; #define OFF(x) offsetof(contextobject, x) @@ -3066,7 +3276,7 @@ context_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)context_richcompare, /* tp_richcompare */ + 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -3162,8 +3372,10 @@ return 0; } -#define ADD_CONST(m, name) \ - if (PyModule_AddIntConstant(m, #name, name) < 0) { return; } +#define ADD_CONST(m, name) \ + if (PyModule_AddIntConstant(m, #name, name) < 0) { \ + return; \ + } #define INIT_EXC(m, name, base) \ name = PyErr_NewException(MODULE_NAME "." #name, base, NULL); \ From python-checkins at python.org Wed May 24 17:10:09 2006 From: python-checkins at python.org (jack.diederich) Date: Wed, 24 May 2006 17:10:09 +0200 (CEST) Subject: [Python-checkins] r46180 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524151009.CAE901E4019@bag.python.org> Author: jack.diederich Date: Wed May 24 17:10:08 2006 New Revision: 46180 Modified: sandbox/trunk/decimal-c/_decimal.c Log: * copy the string from the beginning, not starting after the end Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 17:10:08 2006 @@ -1269,6 +1269,7 @@ if (d->sign & 1) *p++ = '-'; + SANITY_CHECK(p); if (GETNAN(d)) { if (GETNAN(d) == 2) @@ -1289,7 +1290,7 @@ } *p++ = 0; SANITY_CHECK(p); - return PyString_FromString(p); + return PyString_FromString(outbuf); } static PyObject * From python-checkins at python.org Wed May 24 17:10:50 2006 From: python-checkins at python.org (richard.jones) Date: Wed, 24 May 2006 17:10:50 +0200 (CEST) Subject: [Python-checkins] r46181 - python/branches/rjones-prealloc Message-ID: <20060524151050.83D921E4019@bag.python.org> Author: richard.jones Date: Wed May 24 17:10:50 2006 New Revision: 46181 Removed: python/branches/rjones-prealloc/ Log: Didn't pan out - at best we can speed up appends by about 7-8% for lists of 50-100 elements. For the large part the benefit is 0-2%. For lists under 20 elements, peformance is actually reduced when pre-allocating. From python-checkins at python.org Wed May 24 17:11:01 2006 From: python-checkins at python.org (fredrik.lundh) Date: Wed, 24 May 2006 17:11:01 +0200 (CEST) Subject: [Python-checkins] r46182 - python/trunk/Objects/unicodeobject.c Message-ID: <20060524151101.CE0A31E4021@bag.python.org> Author: fredrik.lundh Date: Wed May 24 17:11:01 2006 New Revision: 46182 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeedindeed: use fastsearch also for __contains__ Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Wed May 24 17:11:01 2006 @@ -3854,12 +3854,16 @@ moore and horspool, with a few more bells and whistles on the top. for some more background, see: http://effbot.org/stringlib */ +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types. also, the count mode returns -1 if + there cannot possible be a match in the target string, and 0 if it + has actually checked for matches. */ + #define FAST_COUNT 0 #define FAST_SEARCH 1 -LOCAL(int) fastsearch(Py_UNICODE* s, Py_ssize_t n, - Py_UNICODE* p, Py_ssize_t m, - int mode) +LOCAL(Py_ssize_t) +fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) { long mask; int skip, count = 0; @@ -3872,7 +3876,7 @@ /* look for special cases */ if (m <= 1) { - if (m < 0) + if (m <= 0) return -1; /* use special case for 1-character strings */ if (mode == FAST_COUNT) { @@ -5142,6 +5146,9 @@ PyUnicodeObject *u, *v; int result; Py_ssize_t size; +#ifdef USE_FAST + Py_ssize_t pos; +#endif /* Coerce the two arguments */ v = (PyUnicodeObject *) PyUnicode_FromObject(element); @@ -5163,6 +5170,13 @@ goto done; } +#ifdef USE_FAST + pos = fastsearch( + PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), + PyUnicode_AS_UNICODE(v), size, FAST_SEARCH + ); + result = (pos != -1); +#else result = 0; if (size == 1) { @@ -5184,6 +5198,7 @@ break; } } +#endif done: Py_DECREF(u); From python-checkins at python.org Wed May 24 17:15:10 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 17:15:10 +0200 (CEST) Subject: [Python-checkins] r46183 - sandbox/trunk/decimal-c/decimal.py Message-ID: <20060524151510.428491E401A@bag.python.org> Author: georg.brandl Date: Wed May 24 17:15:09 2006 New Revision: 46183 Modified: sandbox/trunk/decimal-c/decimal.py Log: To do. Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Wed May 24 17:15:09 2006 @@ -2153,29 +2153,6 @@ _clamp - If 1, change exponents if too high (Default 0) """ - def __init__(self, prec=None, rounding=None, - traps=None, flags=None, - _rounding_decision=None, - Emin=None, Emax=None, - capitals=None, _clamp=0, - _ignored_flags=None): - if flags is None: - flags = [] - if _ignored_flags is None: - _ignored_flags = [] - if not isinstance(flags, dict): - flags = dict([(s,s in flags) for s in _signals]) - del s - if traps is not None and not isinstance(traps, dict): - traps = dict([(s,s in traps) for s in _signals]) - del s - for name, val in locals().items(): - if val is None: - setattr(self, name, _copy.copy(getattr(DefaultContext, name))) - else: - setattr(self, name, val) - del self.self - def __repr__(self): """Show the current context.""" s = [] @@ -2184,28 +2161,7 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def get_manager(self): - return ContextManager(self.copy()) - - def clear_flags(self): - """Reset all flags to zero""" - for flag in self.flags: - self.flags[flag] = 0 - - def _shallow_copy(self): - """Returns a shallow copy from self.""" - nc = Context(self.prec, self.rounding, self.traps, self.flags, - self._rounding_decision, self.Emin, self.Emax, - self.capitals, self._clamp, self._ignored_flags) - return nc - - def copy(self): - """Returns a deep copy from self.""" - nc = Context(self.prec, self.rounding, self.traps.copy(), self.flags.copy(), - self._rounding_decision, self.Emin, self.Emax, - self.capitals, self._clamp, self._ignored_flags) - return nc - __copy__ = copy +## FROM HERE def _raise_error(self, condition, explanation = None, *args): """Handles an error @@ -2247,19 +2203,6 @@ for flag in flags: self._ignored_flags.remove(flag) - def __hash__(self): - """A Context cannot be hashed.""" - # We inherit object.__hash__, so we must deny this explicitly - raise TypeError, "Cannot hash a Context." - - def Etiny(self): - """Returns Etiny (= Emin - prec + 1)""" - return int(self.Emin - self.prec + 1) - - def Etop(self): - """Returns maximum exponent (= Emax - prec + 1)""" - return int(self.Emax - self.prec + 1) - def _set_rounding_decision(self, type): """Sets the rounding decision. @@ -2300,6 +2243,8 @@ self.rounding= type return rounding +## TO HERE + def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) @@ -2774,9 +2719,7 @@ from _decimal import BasicContext, ExtendedContext, \ DefaultContext -BasicContext.__class__ = Context -ExtendedContext.__class__ = Context -DefaultContext.__class__ = Context +BasicContext._ignore_flags = Context._ignore_flags class _WorkRep(object): From python-checkins at python.org Wed May 24 17:32:07 2006 From: python-checkins at python.org (bob.ippolito) Date: Wed, 24 May 2006 17:32:07 +0200 (CEST) Subject: [Python-checkins] r46184 - in python/trunk: Lib/struct.py Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060524153207.B13711E4026@bag.python.org> Author: bob.ippolito Date: Wed May 24 17:32:06 2006 New Revision: 46184 Modified: python/trunk/Lib/struct.py python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: refactor unpack, add unpack_from Modified: python/trunk/Lib/struct.py ============================================================================== --- python/trunk/Lib/struct.py (original) +++ python/trunk/Lib/struct.py Wed May 24 17:32:06 2006 @@ -73,3 +73,15 @@ except KeyError: o = _compile(fmt) return o.unpack(s) + +def unpack_from(fmt, buf, offset=0): + """ + Unpack the buffer, containing packed C structure data, according to + fmt starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt). + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.unpack_from(buf, offset) \ No newline at end of file Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Wed May 24 17:32:06 2006 @@ -437,3 +437,44 @@ TestFailed("expected OverflowError") test_705836() + +def test_unpack_from(): + test_string = 'abcd01234' + fmt = '4s' + s = struct.Struct(fmt) + for cls in (str, buffer): + data = cls(test_string) + assert s.unpack_from(data) == ('abcd',) + assert s.unpack_from(data, 2) == ('cd01',) + assert s.unpack_from(data, 4) == ('0123',) + for i in xrange(6): + assert s.unpack_from(data, i) == (data[i:i+4],) + for i in xrange(6, len(test_string) + 1): + simple_err(s.unpack_from, data, i) + for cls in (str, buffer): + data = cls(test_string) + assert struct.unpack_from(fmt, data) == ('abcd',) + assert struct.unpack_from(fmt, data, 2) == ('cd01',) + assert struct.unpack_from(fmt, data, 4) == ('0123',) + for i in xrange(6): + assert struct.unpack_from(fmt, data, i) == (data[i:i+4],) + for i in xrange(6, len(test_string) + 1): + simple_err(struct.unpack_from, fmt, data, i) + +test_unpack_from() + +def test_1229380(): + for endian in ('', '>', '<'): + for cls in (int, long): + for fmt in ('B', 'H', 'I', 'L'): + any_err(struct.pack, endian + fmt, cls(-1)) + + any_err(struct.pack, endian + 'B', cls(300)) + any_err(struct.pack, endian + 'H', cls(70000)) + + any_err(struct.pack, endian + 'I', sys.maxint * 4L) + any_err(struct.pack, endian + 'L', sys.maxint * 4L) + +if 0: + # TODO: bug #1229380 + test_1229380() Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Wed May 24 17:32:06 2006 @@ -32,7 +32,7 @@ typedef struct _formatcode { const struct _formatdef *fmtdef; int offset; - int repeat; + int size; } formatcode; /* Struct object interface */ @@ -46,6 +46,7 @@ PyObject *weakreflist; /* List of weak references */ } PyStructObject; + #define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType) #define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType) @@ -962,7 +963,7 @@ const char *s; const char *fmt; char c; - int size, len, numcodes, num, itemsize, x; + int size, len, num, itemsize, x; fmt = PyString_AS_STRING(self->s_format); @@ -971,7 +972,6 @@ s = fmt; size = 0; len = 0; - numcodes = 0; while ((c = *s++) != '\0') { if (isspace(Py_CHARMASK(c))) continue; @@ -1003,7 +1003,6 @@ case 'x': break; default: len += num; break; } - if (c != 'x') numcodes++; itemsize = e->size; size = align(size, c, e); @@ -1018,7 +1017,7 @@ self->s_size = size; self->s_len = len; - codes = PyMem_MALLOC((numcodes + 1) * sizeof(formatcode)); + codes = PyMem_MALLOC((len + 1) * sizeof(formatcode)); if (codes == NULL) { PyErr_NoMemory(); return -1; @@ -1043,17 +1042,27 @@ e = getentry(c, f); size = align(size, c, e); - if (c != 'x') { + if (c == 's' || c == 'p') { codes->offset = size; - codes->repeat = num; + codes->size = num; codes->fmtdef = e; codes++; + size += num; + } else if (c == 'x') { + size += num; + } else { + while (--num >= 0) { + codes->offset = size; + codes->size = e->size; + codes->fmtdef = e; + codes++; + size += e->size; + } } - size += num * e->size; } codes->fmtdef = NULL; - codes->offset = -1; - codes->repeat = -1; + codes->offset = size; + codes->size = 0; return 0; } @@ -1111,64 +1120,36 @@ s->ob_type->tp_free((PyObject *)s); } -PyDoc_STRVAR(s_unpack__doc__, -"unpack(str) -> (v1, v2, ...)\n\ -\n\ -Return tuple containing values unpacked according to this Struct's format.\n\ -Requires len(str) == self.size. See struct.__doc__ for more on format\n\ -strings."); - static PyObject * -s_unpack(PyObject *self, PyObject *inputstr) -{ - PyStructObject *soself; - PyObject *result; - char *restart; +s_unpack_internal(PyStructObject *soself, char *startfrom) { formatcode *code; - Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (inputstr == NULL || !PyString_Check(inputstr) || - PyString_GET_SIZE(inputstr) != soself->s_size) { - PyErr_Format(StructError, - "unpack requires a string argument of length %d", soself->s_size); - return NULL; - } - result = PyTuple_New(soself->s_len); + Py_ssize_t i = 0; + PyObject *result = PyTuple_New(soself->s_len); if (result == NULL) return NULL; - - restart = PyString_AS_STRING(inputstr); - i = 0; for (code = soself->s_codes; code->fmtdef != NULL; code++) { - Py_ssize_t n; PyObject *v; const formatdef *e = code->fmtdef; - const char *res = restart + code->offset; + const char *res = startfrom + code->offset; if (e->format == 's') { - v = PyString_FromStringAndSize(res, code->repeat); + v = PyString_FromStringAndSize(res, code->size); if (v == NULL) goto fail; PyTuple_SET_ITEM(result, i++, v); } else if (e->format == 'p') { - n = *(unsigned char*)res; - if (n >= code->repeat) - n = code->repeat - 1; + Py_ssize_t n = *(unsigned char*)res; + if (n >= code->size) + n = code->size - 1; v = PyString_FromStringAndSize(res + 1, n); if (v == NULL) goto fail; PyTuple_SET_ITEM(result, i++, v); } else { - for (n = 0; n < code->repeat; n++) { - v = e->unpack(res, e); - if (v == NULL) - goto fail; - PyTuple_SET_ITEM(result, i++, v); - res += e->size; - } + v = e->unpack(res, e); + if (v == NULL) + goto fail; + PyTuple_SET_ITEM(result, i++, v); } } @@ -1179,6 +1160,73 @@ }; +PyDoc_STRVAR(s_unpack__doc__, +"unpack(str) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Requires len(str) == self.size. See struct.__doc__ for more on format\n\ +strings."); + +static PyObject * +s_unpack(PyObject *self, PyObject *inputstr) +{ + PyStructObject *soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (inputstr == NULL || !PyString_Check(inputstr) || + PyString_GET_SIZE(inputstr) != soself->s_size) { + PyErr_Format(StructError, + "unpack requires a string argument of length %d", soself->s_size); + return NULL; + } + return s_unpack_internal(soself, PyString_AS_STRING(inputstr)); +} + +PyDoc_STRVAR(s_unpack_from__doc__, +"unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\ +\n\ +Return tuple containing values unpacked according to this Struct's format.\n\ +Unlike unpack, unpack_from can unpack values from any object supporting\n\ +the buffer API, not just str. Requires len(buffer[offset:]) >= self.size.\n\ +See struct.__doc__ for more on format strings."); + +static PyObject * +s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"buffer", "offset", 0}; +#if (PY_VERSION_HEX < 0x02050000) + static char *fmt = "z#|i:unpack_from"; +#else + static char *fmt = "z#|n:unpack_from"; +#endif + Py_ssize_t buffer_len = 0, offset = 0; + char *buffer = NULL; + PyStructObject *soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, + &buffer, &buffer_len, &offset)) + return NULL; + + if (buffer == NULL) { + PyErr_Format(StructError, + "unpack_from requires a buffer argument"); + return NULL; + } + + if (offset < 0) + offset += buffer_len; + + if (offset < 0 || (buffer_len - offset) < soself->s_size) { + PyErr_Format(StructError, + "unpack_from requires a buffer of at least %d bytes", + soself->s_size); + return NULL; + } + return s_unpack_internal(soself, buffer + offset); +} + PyDoc_STRVAR(s_pack__doc__, "pack(v1, v2, ...) -> string\n\ \n\ @@ -1225,8 +1273,8 @@ goto fail; } n = PyString_GET_SIZE(v); - if (n > code->repeat) - n = code->repeat; + if (n > code->size) + n = code->size; if (n > 0) memcpy(res, PyString_AS_STRING(v), n); } else if (e->format == 'p') { @@ -1237,20 +1285,17 @@ goto fail; } n = PyString_GET_SIZE(v); - if (n > (code->repeat - 1)) - n = code->repeat - 1; + if (n > (code->size - 1)) + n = code->size - 1; if (n > 0) memcpy(res + 1, PyString_AS_STRING(v), n); if (n > 255) n = 255; *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); } else { - for (n = 0; n < code->repeat; n++) { - v = PyTuple_GET_ITEM(args, i++); - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } + v = PyTuple_GET_ITEM(args, i++); + if (e->pack(res, v, e) < 0) + goto fail; } } @@ -1266,8 +1311,9 @@ /* List of functions */ static struct PyMethodDef s_methods[] = { - {"pack", s_pack, METH_VARARGS, s_pack__doc__}, - {"unpack", s_unpack, METH_O, s_unpack__doc__}, + {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, + {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, + {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ }; From python-checkins at python.org Wed May 24 17:51:22 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 17:51:22 +0200 (CEST) Subject: [Python-checkins] r46185 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524155122.4D2CC1E4009@bag.python.org> Author: georg.brandl Date: Wed May 24 17:51:21 2006 New Revision: 46185 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Clean up and implement Context.__repr__. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 17:51:21 2006 @@ -929,7 +929,7 @@ static char *decctxkwlist[] = {"other", "context", 0}; #define ENSURE_DECIMAL(methname, dec, type) \ - dec = _convert_to_decimal(type, (PyObject *)dec, ctx, 1); \ + dec = (decimalobject *)_convert_to_decimal(type, (PyObject *)dec, ctx, 1); \ if (!dec) { \ PyErr_SetString(PyExc_TypeError, methname ": " #dec " must be a Decimal object"); \ return NULL; \ @@ -951,14 +951,14 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:" #methname, ctxkwlist, &ctx)) \ return NULL; \ ENSURE_CONTEXT(#methname, ctx); \ - return _do_decimal_##methname(self, ctx); \ + return (PyObject *)_do_decimal_##methname(self, ctx); \ } #define DECIMAL_BINARY_FUNC(methname) \ static PyObject * \ decimal_##methname(decimalobject *self, PyObject *args, PyObject *kwds) \ { \ - decimalobject *res; \ + PyObject *res; \ decimalobject *dec = NULL; \ contextobject *ctx = NULL; \ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:" #methname, \ @@ -966,11 +966,10 @@ return NULL; \ ENSURE_CONTEXT(#methname, ctx); \ ENSURE_DECIMAL(#methname, dec, self->ob_type); \ - res = _do_decimal_##methname(self, dec, ctx); \ + res = (PyObject *)_do_decimal_##methname(self, dec, ctx); \ Py_DECREF(dec); \ return res; \ } - static decimalobject * @@ -1142,7 +1141,7 @@ DECIMAL_UNARY_FUNC(sqrt) -static decimalobject * +static PyObject * _do_decimal_to_eng_string(decimalobject *self, contextobject *ctx) { return _do_decimal_str(self, ctx, 1); @@ -1171,7 +1170,7 @@ PyErr_SetString(PyExc_ValueError, "invalid rounding value"); return NULL; } - return _do_decimal_to_integral(self, ctx, rounding); + return (PyObject *)_do_decimal_to_integral(self, ctx, rounding); } @@ -2772,31 +2771,32 @@ } #define CONTEXT_UNARY_FUNC(name, decname) \ - static decimalobject * \ + static PyObject * \ context_##name(contextobject *self, PyObject *a) { \ - decimalobject *dec_a = NULL, *res; \ + decimalobject *dec_a = NULL; \ + PyObject *res; \ dec_a = (decimalobject *)_convert_to_decimal( \ &PyDecimal_DecimalType, a, self, 1); \ - if (dec_a == NULL) return NULL; \ - res = _do_decimal_##decname(dec_a, self); \ - Py_DECREF(dec_a); \ - return res; \ + if (dec_a == NULL) return NULL; \ + res = (PyObject *)_do_decimal_##decname(dec_a, self); \ + Py_DECREF(dec_a); \ + return res; \ } #define CONTEXT_BINARY_FUNC(name, decname) \ - static decimalobject * \ + static PyObject * \ context_##name(contextobject *self, PyObject *args) { \ - PyObject *a, *b; \ - decimalobject *dec_a = NULL, *dec_b = NULL, *res; \ + PyObject *a, *b, *res; \ + decimalobject *dec_a = NULL, *dec_b = NULL; \ if (!PyArg_ParseTuple(args, "OO:" #name, &a, &b)) return NULL; \ - dec_a = (decimalobject *)_convert_to_decimal( \ - &PyDecimal_DecimalType, a, self, 1); \ - if (dec_a == NULL) return NULL; \ - dec_b = (decimalobject *)_convert_to_decimal( \ - &PyDecimal_DecimalType, b, self, 1); \ - if (dec_b == NULL) { Py_DECREF(dec_a); return NULL; } \ - res = _do_decimal_##decname(dec_a, dec_b, self); \ - Py_DECREF(dec_a); \ + dec_a = (decimalobject *)_convert_to_decimal( \ + &PyDecimal_DecimalType, a, self, 1); \ + if (dec_a == NULL) return NULL; \ + dec_b = (decimalobject *)_convert_to_decimal( \ + &PyDecimal_DecimalType, b, self, 1); \ + if (dec_b == NULL) { Py_DECREF(dec_a); return NULL; } \ + res = (PyObject *)_do_decimal_##decname(dec_a, dec_b, self); \ + Py_DECREF(dec_a); \ Py_DECREF(dec_b); \ return res; \ } @@ -2858,7 +2858,7 @@ Py_DECREF(dec_a); Py_DECREF(dec_b); Py_DECREF(dec_c); - return res; + return (PyObject *)res; } @@ -2885,7 +2885,7 @@ res = _do_decimal_quantize(dec_a, dec_b, self, -1, 1); Py_DECREF(dec_a); Py_DECREF(dec_b); - return res; + return (PyObject *)res; } @@ -2930,7 +2930,7 @@ if (dec_a == NULL) return NULL; - res = _do_decimal_to_integral(dec_a, self, -1); + res = (PyObject *)_do_decimal_to_integral(dec_a, self, -1); Py_DECREF(dec_a); return res; } @@ -3057,12 +3057,25 @@ c->ob_type->tp_free(c); } +#define TEST_AND_CAT(num, name) \ + if (ISFLAGSET(self->flags, num)) { \ + strcat(flags, name); \ + strcat(flags, ", "); \ + flaglen += strlen(name) + 2; \ + } \ + if (ISFLAGSET(self->traps, num)) { \ + strcat(traps, name); \ + strcat(traps, ", "); \ + traplen += strlen(name) + 2; \ + } + static PyObject * context_repr(contextobject *self) { char roundstr[20] = "ROUND_"; - char flags[1000] = "{}"; - char traps[1000] = "[]"; + char flags[250] = "["; /* 250 is enough for 12 error names of max. 17 chars */ + char traps[250] = "["; /* and commas inbetween. */ + long flaglen = 1, traplen = 1; switch (self->rounding) { case ROUND_UP: @@ -3090,7 +3103,24 @@ strcpy(roundstr, "None"); } - /* XXX: flags/traps */ + TEST_AND_CAT(S_CLAMPED, "Clamped"); + TEST_AND_CAT(S_INV_OPERATION, "InvalidOperation"); + TEST_AND_CAT(S_DIV_BY_ZERO, "DivisionByZero"); + TEST_AND_CAT(S_INEXACT, "Inexact"); + TEST_AND_CAT(S_ROUNDED, "Rounded"); + TEST_AND_CAT(S_SUBNORMAL, "Subnormal"); + TEST_AND_CAT(S_OVERFLOW, "Overflow"); + TEST_AND_CAT(S_UNDERFLOW, "Underflow"); + + /* if no flag/trap */ + if (flaglen == 1) + flaglen = 3; + if (traplen == 1) + traplen = 3; + flags[flaglen-2] = ']'; + flags[flaglen-1] = 0; + traps[traplen-2] = ']'; + traps[traplen-1] = 0; return PyString_FromFormat("Context(prec=%ld, rounding=%s, Emin=%ld, " "Emax=%ld, capitals=%d, flags=%s, traps=%s)", @@ -3345,34 +3375,6 @@ }; -static int -_add_handle_method(PyObject *tp, PyMethodDef *ml) -{ - PyObject *meth, *cfunc; - static PyObject *module; - - if (!module) { - module = PyString_FromString(MODULE_NAME); - if (!module) - return -1; - } - - cfunc = PyCFunction_NewEx(ml, NULL, module); - if (!cfunc) - return -1; - - meth = PyMethod_New(cfunc, NULL, tp); - if (!meth) { - Py_DECREF(cfunc); - return -1; - } - - PyObject_SetAttrString(tp, "handle", meth); - Py_DECREF(cfunc); - Py_DECREF(meth); - return 0; -} - #define ADD_CONST(m, name) \ if (PyModule_AddIntConstant(m, #name, name) < 0) { \ return; \ From python-checkins at python.org Wed May 24 18:01:41 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 18:01:41 +0200 (CEST) Subject: [Python-checkins] r46186 - in python/branches/blais-bytebuf: Lib/test/test_hotbuf.py Modules/hotbufmodule.c Message-ID: <20060524160141.F153F1E400B@bag.python.org> Author: martin.blais Date: Wed May 24 18:01:38 2006 New Revision: 46186 Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Modules/hotbufmodule.c Log: Implemented compact() and a few other things. Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Wed May 24 18:01:38 2006 @@ -70,6 +70,20 @@ # Play with remaining. self.assertEquals(b.remaining(), 104) + b.setposition(10) + self.assertEquals(b.remaining(), 94) + + def test_compact( self ): + CAPACITY = 1024 + b = hotbuf(CAPACITY) + + b.setposition(100) + b.setlimit(200) + b.mark() + b.compact() + self.assertEquals((b.position(), b.limit(), b.mark()), + (100, CAPACITY, -1)) + def test_main(): Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/hotbufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 18:01:38 2006 @@ -4,15 +4,7 @@ */ #include "Python.h" - -/* Note: the object's structure is private */ - -#ifndef Py_HOTBUFOBJECT_H -#define Py_HOTBUFOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - +#include /* for memmove */ PyAPI_DATA(PyTypeObject) PyHotbuf_Type; @@ -22,11 +14,6 @@ PyAPI_FUNC(PyObject *) PyHotbuf_New(Py_ssize_t size); -#ifdef __cplusplus -} -#endif -#endif /* !Py_HOTBUFOBJECT_H */ - /* =========================================================================== @@ -73,7 +60,7 @@ /* * The "active window" is defined by the interval [position, limit[. */ - + /* The current position in the buffer. */ int b_position; @@ -178,7 +165,7 @@ { Py_ssize_t min_len; int cmp; - + min_len = ((self->b_capacity < other->b_capacity) ? self->b_capacity : other->b_capacity); if (min_len > 0) { @@ -215,7 +202,7 @@ /* =========================================================================== - * Object Methods + * Object Methods (basic interface) */ PyDoc_STRVAR(capacity__doc__, @@ -269,7 +256,7 @@ self->b_position = newposition; /* Discard the mark if it is beyond the new position */ - if ( self->b_mark > self->b_position ) + if ( self->b_mark > self->b_position ) self->b_mark = -1; return Py_None; @@ -319,7 +306,7 @@ self->b_position = newlimit; /* Discard the mark if it is beyond the new limit */ - if ( self->b_mark > self->b_position ) + if ( self->b_mark > self->b_position ) self->b_mark = -1; return Py_None; @@ -467,7 +454,728 @@ /* =========================================================================== - * Buffer protocol methods + * Object Methods (byte buffer interface) + */ + +PyDoc_STRVAR(compact__doc__, +"B.compact()\n\ +\n\ +public abstract ByteBuffer compact()\n\ +\n\ +Compacts this buffer (optional operation).\n\ +\n\ +The bytes between the buffer's current position and its limit, if\n\ +any, are copied to the beginning of the buffer. That is, the byte\n\ +at index p = position() is copied to index zero, the byte at index\n\ +p + 1 is copied to index one, and so forth until the byte at index\n\ +limit() - 1 is copied to index n = limit() - 1 - p. The buffer's\n\ +position is then set to n+1 and its limit is set to its\n\ +capacity. The mark, if defined, is discarded.\n\ +\n\ +The buffer's position is set to the number of bytes copied, rather\n\ +than to zero, so that an invocation of this method can be followed\n\ +immediately by an invocation of another relative put method.\n\ +\n\ +Invoke this method after writing data from a buffer in case the\n\ +write was incomplete. The following loop, for example, copies\n\ +bytes from one channel to another via the buffer buf:\n\ +\n\ + buf.clear() # Prepare buffer for use\n\ + while 1:\n\ + if in.read(buf) < 0 and buf.remaining() == 0:\n\ + break # No more bytes to transfer\n\ + buf.flip()\n\ + out.write(buf)\n\ + buf.compact() # In case of partial write\n\ +\n\ +"); + +static PyObject* +hotbuf_compact(PyHotbufObject *self) +{ + int length; + + /* Calculate the number of bytes in the active window */ + length = self->b_limit - self->b_position; + + /* Move the memory from the active window to the beginning of the + allocated buffer (only if we need to). */ + if ( length > 0 && self->b_position > 0 ) { + memmove(self->b_ptr, self->b_ptr + self->b_position, length); + } + + self->b_position = length; + self->b_limit = self->b_capacity; + self->b_mark = -1; + + return Py_None; +} + + + +/* + +get + +public abstract byte get() + + Relative get method. Reads the byte at this buffer's current position, and then increments the position. + + Returns: + The byte at the buffer's current position + Throws: + BufferUnderflowException - If the buffer's current position is not smaller than its limit + +put + +public abstract ByteBuffer put(byte b) + + Relative put method (optional operation). + + Writes the given byte into this buffer at the current position, and then increments the position. + + Parameters: + b - The byte to be written + Returns: + This buffer + Throws: + BufferOverflowException - If this buffer's current position is not smaller than its limit + ReadOnlyBufferException - If this buffer is read-only + +get + +public abstract byte get(int index) + + Absolute get method. Reads the byte at the given index. + + Parameters: + index - The index from which the byte will be read + Returns: + The byte at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit + +put + +public abstract ByteBuffer put(int index, + byte b) + + Absolute put method (optional operation). + + Writes the given byte into this buffer at the given index. + + Parameters: + index - The index at which the byte will be written + b - The byte value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit + ReadOnlyBufferException - If this buffer is read-only + +get + +public ByteBuffer get(byte[] dst, + int offset, + int length) + + Relative bulk get method. + + This method transfers bytes from this buffer into the given destination array. If there are fewer bytes remaining in the buffer than are required to satisfy the request, that is, if length > remaining(), then no bytes are transferred and a BufferUnderflowException is thrown. + + Otherwise, this method copies length bytes from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length. + + In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop + + for (int i = off; i < off + len; i++) + dst[i] = src.get(); + + except that it first checks that there are sufficient bytes in this buffer and it is potentially much more efficient. + + Parameters: + dst - The array into which bytes are to be written + offset - The offset within the array of the first byte to be written; must be non-negative and no larger than dst.length + length - The maximum number of bytes to be written to the given array; must be non-negative and no larger than dst.length - offset + Returns: + This buffer + Throws: + BufferUnderflowException - If there are fewer than length bytes remaining in this buffer + IndexOutOfBoundsException - If the preconditions on the offset and length parameters do not hold + +get + +public ByteBuffer get(byte[] dst) + + Relative bulk get method. + + This method transfers bytes from this buffer into the given destination array. An invocation of this method of the form src.get(a) behaves in exactly the same way as the invocation + + src.get(a, 0, a.length) + + Returns: + This buffer + Throws: + BufferUnderflowException - If there are fewer than length bytes remaining in this buffer + +put + +public ByteBuffer put(ByteBuffer src) + + Relative bulk put method (optional operation). + + This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. + + Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n. + + In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop + + while (src.hasRemaining()) + dst.put(src.get()); + + except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. + + Parameters: + src - The source buffer from which bytes are to be read; must not be this buffer + Returns: + This buffer + Throws: + BufferOverflowException - If there is insufficient space in this buffer for the remaining bytes in the source buffer + IllegalArgumentException - If the source buffer is this buffer + ReadOnlyBufferException - If this buffer is read-only + +put + +public ByteBuffer put(byte[] src, + int offset, + int length) + + Relative bulk put method (optional operation). + + This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. + + Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length. + + In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop + + for (int i = off; i < off + len; i++) + dst.put(a[i]); + + except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. + + Parameters: + src - The array from which bytes are to be read + offset - The offset within the array of the first byte to be read; must be non-negative and no larger than array.length + length - The number of bytes to be read from the given array; must be non-negative and no larger than array.length - offset + Returns: + This buffer + Throws: + BufferOverflowException - If there is insufficient space in this buffer + IndexOutOfBoundsException - If the preconditions on the offset and length parameters do not hold + ReadOnlyBufferException - If this buffer is read-only + +put + +public final ByteBuffer put(byte[] src) + + Relative bulk put method (optional operation). + + This method transfers the entire content of the given source byte array into this buffer. An invocation of this method of the form dst.put(a) behaves in exactly the same way as the invocation + + dst.put(a, 0, a.length) + + Returns: + This buffer + Throws: + BufferOverflowException - If there is insufficient space in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getChar + +public abstract char getChar() + + Relative get method for reading a char value. + + Reads the next two bytes at this buffer's current position, composing them into a char value according to the current byte order, and then increments the position by two. + + Returns: + The char value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than two bytes remaining in this buffer + +putChar + +public abstract ByteBuffer putChar(char value) + + Relative put method for writing a char value (optional operation). + + Writes two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two. + + Parameters: + value - The char value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than two bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getChar + +public abstract char getChar(int index) + + Absolute get method for reading a char value. + + Reads two bytes at the given index, composing them into a char value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The char value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one + +putChar + +public abstract ByteBuffer putChar(int index, + char value) + + Absolute put method for writing a char value (optional operation). + + Writes two bytes containing the given char value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The char value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one + ReadOnlyBufferException - If this buffer is read-only + +asCharBuffer + +public abstract CharBuffer asCharBuffer() + + Creates a view of this byte buffer as a char buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new char buffer + +getShort + +public abstract short getShort() + + Relative get method for reading a short value. + + Reads the next two bytes at this buffer's current position, composing them into a short value according to the current byte order, and then increments the position by two. + + Returns: + The short value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than two bytes remaining in this buffer + +putShort + +public abstract ByteBuffer putShort(short value) + + Relative put method for writing a short value (optional operation). + + Writes two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two. + + Parameters: + value - The short value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than two bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getShort + +public abstract short getShort(int index) + + Absolute get method for reading a short value. + + Reads two bytes at the given index, composing them into a short value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The short value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one + +putShort + +public abstract ByteBuffer putShort(int index, + short value) + + Absolute put method for writing a short value (optional operation). + + Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The short value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one + ReadOnlyBufferException - If this buffer is read-only + +asShortBuffer + +public abstract ShortBuffer asShortBuffer() + + Creates a view of this byte buffer as a short buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new short buffer + +getInt + +public abstract int getInt() + + Relative get method for reading an int value. + + Reads the next four bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by four. + + Returns: + The int value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than four bytes remaining in this buffer + +putInt + +public abstract ByteBuffer putInt(int value) + + Relative put method for writing an int value (optional operation). + + Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four. + + Parameters: + value - The int value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than four bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getInt + +public abstract int getInt(int index) + + Absolute get method for reading an int value. + + Reads four bytes at the given index, composing them into a int value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The int value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three + +putInt + +public abstract ByteBuffer putInt(int index, + int value) + + Absolute put method for writing an int value (optional operation). + + Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The int value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three + ReadOnlyBufferException - If this buffer is read-only + +asIntBuffer + +public abstract IntBuffer asIntBuffer() + + Creates a view of this byte buffer as an int buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new int buffer + +getLong + +public abstract long getLong() + + Relative get method for reading a long value. + + Reads the next eight bytes at this buffer's current position, composing them into a long value according to the current byte order, and then increments the position by eight. + + Returns: + The long value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than eight bytes remaining in this buffer + +putLong + +public abstract ByteBuffer putLong(long value) + + Relative put method for writing a long value (optional operation). + + Writes eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight. + + Parameters: + value - The long value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than eight bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getLong + +public abstract long getLong(int index) + + Absolute get method for reading a long value. + + Reads eight bytes at the given index, composing them into a long value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The long value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven + +putLong + +public abstract ByteBuffer putLong(int index, + long value) + + Absolute put method for writing a long value (optional operation). + + Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The long value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven + ReadOnlyBufferException - If this buffer is read-only + +asLongBuffer + +public abstract LongBuffer asLongBuffer() + + Creates a view of this byte buffer as a long buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new long buffer + +getFloat + +public abstract float getFloat() + + Relative get method for reading a float value. + + Reads the next four bytes at this buffer's current position, composing them into a float value according to the current byte order, and then increments the position by four. + + Returns: + The float value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than four bytes remaining in this buffer + +putFloat + +public abstract ByteBuffer putFloat(float value) + + Relative put method for writing a float value (optional operation). + + Writes four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four. + + Parameters: + value - The float value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than four bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getFloat + +public abstract float getFloat(int index) + + Absolute get method for reading a float value. + + Reads four bytes at the given index, composing them into a float value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The float value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three + +putFloat + +public abstract ByteBuffer putFloat(int index, + float value) + + Absolute put method for writing a float value (optional operation). + + Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The float value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three + ReadOnlyBufferException - If this buffer is read-only + +asFloatBuffer + +public abstract FloatBuffer asFloatBuffer() + + Creates a view of this byte buffer as a float buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new float buffer + +getDouble + +public abstract double getDouble() + + Relative get method for reading a double value. + + Reads the next eight bytes at this buffer's current position, composing them into a double value according to the current byte order, and then increments the position by eight. + + Returns: + The double value at the buffer's current position + Throws: + BufferUnderflowException - If there are fewer than eight bytes remaining in this buffer + +putDouble + +public abstract ByteBuffer putDouble(double value) + + Relative put method for writing a double value (optional operation). + + Writes eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight. + + Parameters: + value - The double value to be written + Returns: + This buffer + Throws: + BufferOverflowException - If there are fewer than eight bytes remaining in this buffer + ReadOnlyBufferException - If this buffer is read-only + +getDouble + +public abstract double getDouble(int index) + + Absolute get method for reading a double value. + + Reads eight bytes at the given index, composing them into a double value according to the current byte order. + + Parameters: + index - The index from which the bytes will be read + Returns: + The double value at the given index + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven + +putDouble + +public abstract ByteBuffer putDouble(int index, + double value) + + Absolute put method for writing a double value (optional operation). + + Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index. + + Parameters: + index - The index at which the bytes will be written + value - The double value to be written + Returns: + This buffer + Throws: + IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven + ReadOnlyBufferException - If this buffer is read-only + +asDoubleBuffer + +public abstract DoubleBuffer asDoubleBuffer() + + Creates a view of this byte buffer as a double buffer. + + The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. + + The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. + + Returns: + A new double buffer + +*/ + + + +/* + +order + +public final ByteOrder order() + + Retrieves this buffer's byte order. + + The byte order is used when reading or writing multibyte values, + and when creating buffers that are views of this byte buffer. The + order of a newly-created byte buffer is always BIG_ENDIAN. + + Returns: + This buffer's byte order + + +order + +public final ByteBuffer order(ByteOrder bo) + + Modifies this buffer's byte order. + + Parameters: + bo - The new byte order, either BIG_ENDIAN or LITTLE_ENDIAN + Returns: + This buffer + +*/ + + + +/* =========================================================================== + * Buffer protocol methods */ /* @@ -526,26 +1234,20 @@ * Object interfaces declaration */ -/* FIXME: needs an update */ - -/* PyDoc_STRVAR(hotbuf_doc, */ -/* "hotbuf(object [, offset[, size]])\n\ */ -/* \n\ */ -/* Create a new hotbuf object which references the given object.\n\ */ -/* The hotbuf will reference a slice of the target object from the\n\ */ -/* start of the object (or at the specified offset). The slice will\n\ */ -/* extend to the end of the target object (or with the specified size)."); */ -PyDoc_STRVAR(hotbuftype_doc, - "hotbuf(size) -> hotbuf\n\ +PyDoc_STRVAR(hotbuf_doc, +"hotbuf(capacity) -> hotbuf\n\ \n\ -Return a new hotbuf with a new buffer of fixed size 'size'.\n\ +Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ \n\ -Methods:\n\ +hotbuf is a C encapsulation of a fixed-size buffer of bytes in memory.\n\ +One can read and write objects of different primitive types directly\n\ +into it, without having to convert from/to strings. Also, this is\n\ +meant for the network I/O functions (recv, recvfrom, send, sendto) to\n\ +read/write directly into without having to create temporary strings.\n\ \n\ -Attributes:\n\ -\n\ -"); +Note that hotbuf is a direct Python equivalent of Java's NIO\n\ +ByteBuffer class."); static PyMethodDef @@ -562,6 +1264,7 @@ {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, + {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, {NULL, NULL} /* sentinel */ }; @@ -604,7 +1307,7 @@ 0, /* tp_setattro */ &hotbuf_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ - hotbuftype_doc, /* tp_doc */ + hotbuf_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -678,11 +1381,13 @@ /* TODO ---- - - Update doc. - Add hash function - Add support for sequence methods. - Perhaps implement returning the buffer object itself from some of the methods in order to allow chaining of operations on a single line. + - Implement a resize function + - Maybe remove the API methods declared at the top. + - Add support for big vs. little endian Pending Issues -------------- From buildbot at python.org Wed May 24 18:02:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 16:02:40 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060524160240.B0C621E4009@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/759 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 24 18:10:32 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 18:10:32 +0200 (CEST) Subject: [Python-checkins] r46187 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524161032.934A01E401D@bag.python.org> Author: georg.brandl Date: Wed May 24 18:10:31 2006 New Revision: 46187 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Cleanup handle_* functions. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 18:10:31 2006 @@ -109,22 +109,22 @@ static decimalobject *_new_decimalobj(PyTypeObject *, long, char, long); -#define HANDLE_ERROR(ctx, cond, expl) \ +#define HANDLE_ERROR(ctx, cond, expl, onerror) \ int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ if (! ISFLAGSET(ctx->ignored, err)) { \ SETFLAG(ctx->flags, err); \ if (ISFLAGSET(ctx->traps, err)) { \ PyErr_SetString(errors[err], (expl ? expl : "")); \ - return NULL; \ + return onerror; \ } \ } -static PyObject * -handle_Clamped(PyTypeObject *type, contextobject *ctx, char *expl) +static int +handle_Clamped(contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, S_CLAMPED, expl); - Py_RETURN_NONE; + HANDLE_ERROR(ctx, S_CLAMPED, expl, -1); + return 0; } static decimalobject * @@ -133,6 +133,7 @@ { decimalobject *res; long sign, i; + HANDLE_ERROR(ctx, S_INV_OPERATION, expl, NULL); if (thing == NULL) { Py_INCREF(PyDecimal_NaN); @@ -151,7 +152,7 @@ static decimalobject * handle_ConversionSyntax(PyTypeObject *type, contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, C_CONV_SYNTAX, expl); + HANDLE_ERROR(ctx, C_CONV_SYNTAX, expl, NULL); Py_INCREF(PyDecimal_NaN); return PyDecimal_NaN; @@ -161,63 +162,66 @@ handle_DivisionByZero(PyTypeObject *type, contextobject *ctx, char *expl, long sign, int two) { - HANDLE_ERROR(ctx, S_DIV_BY_ZERO, expl); + decimalobject *res; + HANDLE_ERROR(ctx, S_DIV_BY_ZERO, expl, NULL); + + if (sign & 1) + res = PyDecimal_NegInf; + else + res = PyDecimal_Inf; - /* XXX: return tuple */ - Py_RETURN_NONE; + Py_INCREF(res); + return res; } static decimalobject * handle_DivisionImpossible(PyTypeObject *type, contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, C_DIV_IMPOSSIBLE, expl); + HANDLE_ERROR(ctx, C_DIV_IMPOSSIBLE, expl, NULL); - /* XXX: return tuple */ - Py_RETURN_NONE; + Py_INCREF(PyDecimal_NaN); + return PyDecimal_NaN; } static decimalobject * handle_DivisionUndefined(PyTypeObject *type, contextobject *ctx, char *expl, int two) { - HANDLE_ERROR(ctx, C_DIV_UNDEFINED, expl); - - /* XXX: return tuple? */ + HANDLE_ERROR(ctx, C_DIV_UNDEFINED, expl, NULL); Py_INCREF(PyDecimal_NaN); return PyDecimal_NaN; } -static PyObject * -handle_Inexact(PyTypeObject *type, contextobject *ctx, char *expl) +static int +handle_Inexact(contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, S_INEXACT, expl); - Py_RETURN_NONE; + HANDLE_ERROR(ctx, S_INEXACT, expl, -1); + return 0; } static decimalobject * handle_InvalidContext(PyTypeObject *type, contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, C_INV_CONTEXT, expl); + HANDLE_ERROR(ctx, C_INV_CONTEXT, expl, NULL); Py_INCREF(PyDecimal_NaN); return PyDecimal_NaN; } -static PyObject * -handle_Rounded(PyTypeObject *type, contextobject *ctx, char *expl) +static int +handle_Rounded(contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, S_ROUNDED, expl); - - Py_RETURN_NONE; + HANDLE_ERROR(ctx, S_ROUNDED, expl, -1); + return 0; } -static PyObject * -handle_Subnormal(PyTypeObject *type, contextobject *ctx, char *expl) +static int +handle_Subnormal(contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, S_SUBNORMAL, expl); + HANDLE_ERROR(ctx, S_SUBNORMAL, expl, -1); - Py_RETURN_NONE; + return 0; } static decimalobject * @@ -226,7 +230,7 @@ decimalobject *res; long i; - HANDLE_ERROR(ctx, S_OVERFLOW, expl); + HANDLE_ERROR(ctx, S_OVERFLOW, expl, NULL); assert(lsign == 0 || lsign == 1); @@ -265,12 +269,11 @@ return res; } -static PyObject * -handle_Underflow(PyTypeObject *type, contextobject *ctx, char *expl) +static int +handle_Underflow(contextobject *ctx, char *expl) { - HANDLE_ERROR(ctx, S_UNDERFLOW, expl); - - Py_RETURN_NONE; + HANDLE_ERROR(ctx, S_UNDERFLOW, expl, -1); + return 0; } @@ -563,7 +566,6 @@ { decimalobject *new, *new2 = NULL; contextobject *ctx2 = NULL; - PyObject *errres; long i, expdiff; round_func rnd_func; @@ -596,12 +598,10 @@ while (i--) new->digits[i] = 0; - errres = handle_Rounded(self->ob_type, ctx, NULL); - if (!errres) { + if (handle_Rounded(ctx, NULL) != 0) { Py_DECREF(new); return NULL; /* error was set */ } - Py_DECREF(errres); /* we don't need the returned object */ return new; } @@ -652,12 +652,10 @@ /* All lost digits are 0, so just clobber new */ new->ob_size = prec; new->exp -= expdiff; - errres = handle_Rounded(self->ob_type, ctx, NULL); - if (!errres) { + if (handle_Rounded(ctx, NULL) != 0) { Py_DECREF(new); return NULL; } - Py_DECREF(errres); return new; no_way: @@ -678,11 +676,9 @@ Py_DECREF(new); if (!new2) goto error; - errres = handle_Rounded(self->ob_type, ctx, NULL); - if (!errres) + if (handle_Rounded(ctx, NULL) != 0) goto error; - errres = handle_Rounded(self->ob_type, ctx, "Changed in rounding"); - if (!errres) + if (handle_Inexact(ctx, "Changed in rounding") != 0) goto error; Py_XDECREF(ctx2); return new2; @@ -765,9 +761,8 @@ adj = ADJUSTED(tmp); if (decimal_nonzero(tmp)) { if (adj < ctx->Emin) { - ans = handle_Subnormal(self->ob_type, ctx, NULL); - Py_DECREF(tmp); - return ans; + if (handle_Subnormal(ctx, NULL) != 0) + return NULL; } else if (adj > ctx->Emax) { ans = handle_InvalidOperation(self->ob_type, ctx, "rescale(a, INF)", NULL); @@ -783,7 +778,7 @@ static decimalobject * _fixexponents(decimalobject *self, contextobject *ctx) { - decimalobject *ans = NULL, *tmp; + decimalobject *ans = NULL; long adj; assert(!ISSPECIAL(self)); @@ -796,42 +791,32 @@ if (!ans) return NULL; ans->exp = Etiny; - tmp = handle_Clamped(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Clamped(ctx, NULL) != 0) goto err; - Py_DECREF(tmp); return ans; } ans = _decimal_rescale(self, Etiny, ctx, -1, 1); if (!ans) return NULL; - tmp = handle_Subnormal(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Subnormal(ctx, NULL) != 0) goto err; - Py_DECREF(tmp); if (ISFLAGSET(ctx->flags, S_INEXACT)) { - tmp = handle_Underflow(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Underflow(ctx, NULL) != 0) goto err; - Py_DECREF(tmp); } return ans; } else { if (decimal_nonzero(self)) { - tmp = handle_Subnormal(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Subnormal(ctx, NULL) != 0) return NULL; - Py_DECREF(tmp); } /* this returns self, below */ } } else { long Etop = ETOP(ctx); if (ctx->clamp && self->exp > Etop) { - tmp = handle_Clamped(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Clamped(ctx, NULL) != 0) return NULL; - Py_DECREF(tmp); ans = _decimal_rescale(self, Etop, ctx, -1, 1); if (!ans) return NULL; @@ -843,20 +828,14 @@ if (!ans) return NULL; ans->exp = ctx->Emax; - tmp = handle_Clamped(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Clamped(ctx, NULL) != 0) goto err; - Py_DECREF(tmp); return ans; } - tmp = handle_Inexact(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Inexact(ctx, NULL) != 0) return NULL; - Py_DECREF(tmp); - tmp = handle_Rounded(self->ob_type, ctx, NULL); - if (!tmp) + if (handle_Rounded(ctx, NULL) != 0) return NULL; - Py_DECREF(tmp); return handle_Overflow(self->ob_type, ctx, "above Emax", self->sign); } } From buildbot at python.org Wed May 24 18:20:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 16:20:02 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060524162002.ECABA1E4009@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/453 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 24 18:24:34 2006 From: python-checkins at python.org (jack.diederich) Date: Wed, 24 May 2006 18:24:34 +0200 (CEST) Subject: [Python-checkins] r46188 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Message-ID: <20060524162434.9700C1E4009@bag.python.org> Author: jack.diederich Date: Wed May 24 18:24:33 2006 New Revision: 46188 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Log: * added more context methods Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 18:24:33 2006 @@ -20,6 +20,7 @@ #define ISFLAGSET(f, b) (((f) >> b) & 1) #define SETFLAG(f, b) (f |= (1 << b)) +#define UNSETFLAG(f, b) (f &= (0 << b)) /* Checks */ @@ -58,9 +59,11 @@ #define ROUND_HALF_UP 4 #define ROUND_FLOOR 5 #define ROUND_CEILING 6 +#define VALID_ROUND(x) ((x) <= ROUND_CEILING && (x) >= ROUND_DOWN) #define ALWAYS_ROUND 0 #define NEVER_ROUND 16 +#define VALID_ROUND_DEC(x) ((x) == ALWAYS_ROUND || (x) == NEVER_ROUND) /* Context signals */ @@ -2961,6 +2964,122 @@ return res; } +static PyObject * +context_ignore_flags(contextobject *self, PyObject *args) +{ + PyObject *flag, *ret_flags; + Py_ssize_t i, j; + + /* NB, unlike regard_flags this doesn't accept a sequence as the + first element and regard_flags returns a list-ized version of + its arguments instead of None + */ + + if (ret_flags == NULL) + return NULL; + for (i = 0; i < PyTuple_GET_SIZE(args); i++) { + flag = PyTuple_GET_ITEM(args, i); + for (j = 0; j < NUMSIGNALS; j++) { + if (errors[j] == flag) { + SETFLAG(self->ignored, j); + Py_INCREF(flag); + PyList_SET_ITEM(ret_flags, i, flag); + break; + } + } + if (j == NUMSIGNALS) { + Py_DECREF(ret_flags); + PyErr_SetString(PyExc_ValueError, "arguments must be valid flags"); + return NULL; + } + } + return ret_flags; +} + +static PyObject * +context_ignore_all_flags(contextobject *self) +{ + PyObject *allflags, *flag; + int i = 0; + + allflags = PyTuple_New(NUMSIGNALS); + if (allflags == NULL) + return NULL; + + for (i = 0; i < NUMSIGNALS; i++) { + flag = errors[i]; + Py_INCREF(flag); + PyTuple_SET_ITEM(allflags, i, flag); + } + return context_ignore_flags(self, allflags); +} + +static PyObject * +context_regard_flags(contextobject *self, PyObject *args) +{ + PyObject *flag, *flags; + Py_ssize_t i, j; + + /* regard_flags allows a list of flags as the first arg */ + flags = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) != 1 && !PySequence_Check(flags)) + flags = args; + + for (i = 0; i < PySequence_Size(flags); i++) { + flag = PySequence_GetItem(flags, i); + for (j = 0; j < NUMSIGNALS; j++) { + if (flag == errors[j]) { + UNSETFLAG(self->ignored, j); + break; + } + } + if (j == NUMSIGNALS) { + PyErr_SetString(PyExc_ValueError, "arguments must be valid flags"); + return NULL; + } + } + Py_RETURN_NONE; +} + +static PyObject * +context_set_rounding_decision(contextobject *self, PyObject *args) +{ + int old_dec, new_dec; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "i:_set_rounding_decision", &new_dec)) + return NULL; + if (!VALID_ROUND_DEC(new_dec)) { + PyErr_SetString(PyExc_ValueError, "value is not a valid rounding decision"); + return NULL; + } + + old_dec = self->rounding_dec; + self->rounding_dec = new_dec; + ret = PyLong_FromLong((long)old_dec); + if (ret == NULL) + return NULL; + return ret; +} +static PyObject * +context_set_rounding(contextobject *self, PyObject *args) +{ + int old_round, new_round; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "i:_set_rounding", &new_round)) + return NULL; + if (!VALID_ROUND(new_round)) { + PyErr_SetString(PyExc_ValueError, "value is not a valid rounding"); + return NULL; + } + old_round = self->rounding; + self->rounding = new_round; + ret = PyLong_FromLong((long)old_round); + if (ret == NULL) + return NULL; + return ret; +} static PyMethodDef context_methods[] = { {"clear_flags", (PyCFunction)context_clear_flags, @@ -2973,8 +3092,7 @@ METH_NOARGS}, {"Etop", (PyCFunction)context_Etop, METH_NOARGS}, - {"abs", (PyCFunction)context_abs, - METH_O}, + {"abs", (PyCFunction)context_abs, METH_O}, {"add", (PyCFunction)context_add, METH_VARARGS}, {"compare", (PyCFunction)context_compare, @@ -3017,6 +3135,16 @@ METH_O}, {"to_sci_string", (PyCFunction)context_to_sci_string, METH_O}, + {"_ignore_all_flags", (PyCFunction)context_ignore_all_flags, + METH_NOARGS}, + {"_ignore_flags", (PyCFunction)context_ignore_flags, + METH_VARARGS}, + {"_regard_flags", (PyCFunction)context_regard_flags, + METH_VARARGS}, + {"_set_rounding_decision", (PyCFunction)context_set_rounding_decision, + METH_VARARGS}, + {"_set_rounding", (PyCFunction)context_set_rounding, + METH_VARARGS}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, {"_shallow_copy", (PyCFunction)context_copy, Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Wed May 24 18:24:33 2006 @@ -370,9 +370,6 @@ # """ # # List of public traps and flags -# _signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded, -# Underflow, InvalidOperation, Subnormal] - # # Map conditions (per the spec) to signals # _condition_map = {ConversionSyntax:InvalidOperation, # DivisionImpossible:InvalidOperation, @@ -2185,64 +2182,6 @@ #self._ignored_flags = [] raise error, explanation - def _ignore_all_flags(self): - """Ignore all flags, if they are raised""" - return self._ignore_flags(*_signals) - - def _ignore_flags(self, *flags): - """Ignore the flags, if they are raised""" - # Do not mutate-- This way, copies of a context leave the original - # alone. - self._ignored_flags = (self._ignored_flags + list(flags)) - return list(flags) - - def _regard_flags(self, *flags): - """Stop ignoring the flags, if they are raised""" - if flags and isinstance(flags[0], (tuple,list)): - flags = flags[0] - for flag in flags: - self._ignored_flags.remove(flag) - - def _set_rounding_decision(self, type): - """Sets the rounding decision. - - Sets the rounding decision, and returns the current (previous) - rounding decision. Often used like: - - context = context._shallow_copy() - # That so you don't change the calling context - # if an error occurs in the middle (say DivisionImpossible is raised). - - rounding = context._set_rounding_decision(NEVER_ROUND) - instance = instance / Decimal(2) - context._set_rounding_decision(rounding) - - This will make it not round for that operation. - """ - - rounding = self._rounding_decision - self._rounding_decision = type - return rounding - - def _set_rounding(self, type): - """Sets the rounding type. - - Sets the rounding type, and returns the current (previous) - rounding type. Often used like: - - context = context.copy() - # so you don't change the calling context - # if an error occurs in the middle. - rounding = context._set_rounding(ROUND_UP) - val = self.__sub__(other, context=context) - context._set_rounding(rounding) - - This will make it round up for that operation. - """ - rounding = self.rounding - self.rounding= type - return rounding - ## TO HERE def create_decimal(self, num='0'): @@ -2719,9 +2658,6 @@ from _decimal import BasicContext, ExtendedContext, \ DefaultContext -BasicContext._ignore_flags = Context._ignore_flags - - class _WorkRep(object): __slots__ = ('sign','int','exp') # sign: 0 or 1 From python-checkins at python.org Wed May 24 18:35:19 2006 From: python-checkins at python.org (fredrik.lundh) Date: Wed, 24 May 2006 18:35:19 +0200 (CEST) Subject: [Python-checkins] r46189 - python/trunk/Objects/unicodeobject.c Message-ID: <20060524163519.886DF1E4025@bag.python.org> Author: fredrik.lundh Date: Wed May 24 18:35:18 2006 New Revision: 46189 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: refactored the replace code slightly; special-case constant-length changes; use fastsearch to locate the first match. Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Wed May 24 18:35:18 2006 @@ -2020,9 +2020,20 @@ */ -static const Py_UNICODE *findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch); +LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, + Py_ssize_t size, + Py_UNICODE ch) +{ + /* like wcschr, but doesn't stop at NULL characters */ + + while (size-- > 0) { + if (*s == ch) + return s; + s++; + } + + return NULL; +} static PyObject *unicodeescape_string(const Py_UNICODE *s, @@ -4141,22 +4152,6 @@ return result; } -static -const Py_UNICODE *findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch) -{ - /* like wcschr, but doesn't stop at NULL characters */ - - while (size-- > 0) { - if (*s == ch) - return s; - s++; - } - - return NULL; -} - /* Apply fixfct filter to the Unicode object self and return a reference to the modified object */ @@ -4825,36 +4820,47 @@ if (maxcount < 0) maxcount = PY_SSIZE_T_MAX; - if (str1->length == 1 && str2->length == 1) { + if (str1->length == str2->length) { + /* same length */ Py_ssize_t i; - - /* replace characters */ - if (!findchar(self->str, self->length, str1->str[0]) && - PyUnicode_CheckExact(self)) { - /* nothing to replace, return original string */ - Py_INCREF(self); - u = self; + if (str1->length == 1) { + /* replace characters */ + Py_UNICODE u1, u2; + if (!findchar(self->str, self->length, str1->str[0])) + goto nothing; + u = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, self->length); + if (!u) + return NULL; + Py_UNICODE_COPY(u->str, self->str, self->length); + u1 = str1->str[0]; + u2 = str2->str[0]; + for (i = 0; i < u->length; i++) + if (u->str[i] == u1) { + if (--maxcount < 0) + break; + u->str[i] = u2; + } } else { - Py_UNICODE u1 = str1->str[0]; - Py_UNICODE u2 = str2->str[0]; - - u = (PyUnicodeObject*) PyUnicode_FromUnicode( - NULL, - self->length + i = fastsearch( + self->str, self->length, str1->str, str1->length, FAST_SEARCH ); - if (u != NULL) { - Py_UNICODE_COPY(u->str, self->str, - self->length); - for (i = 0; i < u->length; i++) - if (u->str[i] == u1) { - if (--maxcount < 0) - break; - u->str[i] = u2; - } - } + if (i < 0) + goto nothing; + u = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, self->length); + if (!u) + return NULL; + Py_UNICODE_COPY(u->str, self->str, self->length); + while (i <= self->length - str1->length) + if (Py_UNICODE_MATCH(self, i, str1)) { + if (--maxcount < 0) + break; + Py_UNICODE_COPY(u->str+i, str2->str, str2->length); + i += str1->length; + } else + i++; } - } else { + Py_ssize_t n, i; Py_UNICODE *p; @@ -4862,51 +4868,47 @@ n = count(self, 0, self->length, str1); if (n > maxcount) n = maxcount; - if (n == 0) { - /* nothing to replace, return original string */ - if (PyUnicode_CheckExact(self)) { - Py_INCREF(self); - u = self; - } - else { - u = (PyUnicodeObject *) - PyUnicode_FromUnicode(self->str, self->length); - } - } else { - u = _PyUnicode_New( - self->length + n * (str2->length - str1->length)); - if (u) { - i = 0; - p = u->str; - if (str1->length > 0) { - while (i <= self->length - str1->length) - if (Py_UNICODE_MATCH(self, i, str1)) { - /* replace string segment */ - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - i += str1->length; - if (--n <= 0) { - /* copy remaining part */ - Py_UNICODE_COPY(p, self->str+i, self->length-i); - break; - } - } else - *p++ = self->str[i++]; - } else { - while (n > 0) { - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - if (--n <= 0) - break; - *p++ = self->str[i++]; + if (n == 0) + goto nothing; + u = _PyUnicode_New(self->length + n * (str2->length - str1->length)); + if (!u) + return NULL; + i = 0; + p = u->str; + if (str1->length > 0) { + while (i <= self->length - str1->length) + if (Py_UNICODE_MATCH(self, i, str1)) { + /* replace string segment */ + Py_UNICODE_COPY(p, str2->str, str2->length); + p += str2->length; + i += str1->length; + if (--n <= 0) { + /* copy remaining part */ + Py_UNICODE_COPY(p, self->str+i, self->length-i); + break; } - Py_UNICODE_COPY(p, self->str+i, self->length-i); - } + } else + *p++ = self->str[i++]; + } else { + while (n > 0) { + Py_UNICODE_COPY(p, str2->str, str2->length); + p += str2->length; + if (--n <= 0) + break; + *p++ = self->str[i++]; } + Py_UNICODE_COPY(p, self->str+i, self->length-i); } } - return (PyObject *) u; + +nothing: + /* nothing to replace; return original string (when possible) */ + if (PyUnicode_CheckExact(self)) { + Py_INCREF(self); + return (PyObject *) self; + } + return PyUnicode_FromUnicode(self->str, self->length); } /* --- Unicode Object Methods --------------------------------------------- */ From buildbot at python.org Wed May 24 18:38:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 16:38:07 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060524163807.B50911E4009@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/418 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 24 19:11:42 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 19:11:42 +0200 (CEST) Subject: [Python-checkins] r46190 - in python/branches/blais-bytebuf: Lib/test/test_hotbuf.py Modules/hotbufmodule.c Message-ID: <20060524171142.516E31E4009@bag.python.org> Author: martin.blais Date: Wed May 24 19:11:40 2006 New Revision: 46190 Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Modules/hotbufmodule.c Log: Added getbyte/putbyte, ci before rename to add corresponding Python module Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Wed May 24 19:11:40 2006 @@ -2,7 +2,7 @@ # # $Id$ # -# Copyright (C) 2005 Gregory P. Smith (greg at electricrain.com) +# Copyright (C) 2006 Martin Blais # Licensed to PSF under a Contributor Agreement. # @@ -11,18 +11,18 @@ from test import test_support +CAPACITY = 1024 + class HotbufTestCase(unittest.TestCase): def test_base( self ): - CAPACITY = 1024 - # Create a new hotbuf self.assertRaises(ValueError, hotbuf, -1) self.assertRaises(ValueError, hotbuf, 0) b = hotbuf(CAPACITY) self.assertEquals(len(b), CAPACITY) self.assertEquals(b.capacity(), CAPACITY) - + # Play with the position assert b.position() == 0 b.setposition(10) @@ -39,7 +39,7 @@ # Play with reset before the mark has been set. self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) - + # Play with the mark b.setposition(10) b.setlimit(100) @@ -59,7 +59,7 @@ b.flip() self.assertEquals((b.position(), b.limit(), b.mark()), (0, 42, -1)) - + # Play with rewind. b.setposition(42) b.setlimit(104) @@ -74,7 +74,6 @@ self.assertEquals(b.remaining(), 94) def test_compact( self ): - CAPACITY = 1024 b = hotbuf(CAPACITY) b.setposition(100) @@ -84,12 +83,35 @@ self.assertEquals((b.position(), b.limit(), b.mark()), (100, CAPACITY, -1)) + def test_byte( self ): + b = hotbuf(256) + + # Fill up the buffer with bytes. + for x in xrange(256): + b.putbyte(x) + + # Test overflow. + self.assertRaises(IndexError, b.putbyte, 42) + + # Read all data from the buffer. + b.flip() + for x in xrange(256): + nx = b.getbyte() + print nx + assert nx == x + + # Test underflow. + self.assertRaises(IndexError, b.putbyte, 42) + + + + + + - def test_main(): test_support.run_unittest(HotbufTestCase) - if __name__ == "__main__": test_main() Modified: python/branches/blais-bytebuf/Modules/hotbufmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/hotbufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 19:11:40 2006 @@ -452,11 +452,6 @@ } - -/* =========================================================================== - * Object Methods (byte buffer interface) - */ - PyDoc_STRVAR(compact__doc__, "B.compact()\n\ \n\ @@ -512,665 +507,69 @@ } + +/* =========================================================================== + * Object Methods (get/put methods) + */ -/* - -get - -public abstract byte get() - - Relative get method. Reads the byte at this buffer's current position, and then increments the position. - - Returns: - The byte at the buffer's current position - Throws: - BufferUnderflowException - If the buffer's current position is not smaller than its limit - -put - -public abstract ByteBuffer put(byte b) - - Relative put method (optional operation). - - Writes the given byte into this buffer at the current position, and then increments the position. - - Parameters: - b - The byte to be written - Returns: - This buffer - Throws: - BufferOverflowException - If this buffer's current position is not smaller than its limit - ReadOnlyBufferException - If this buffer is read-only - -get - -public abstract byte get(int index) - - Absolute get method. Reads the byte at the given index. - - Parameters: - index - The index from which the byte will be read - Returns: - The byte at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit - -put - -public abstract ByteBuffer put(int index, - byte b) - - Absolute put method (optional operation). - - Writes the given byte into this buffer at the given index. - - Parameters: - index - The index at which the byte will be written - b - The byte value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit - ReadOnlyBufferException - If this buffer is read-only - -get - -public ByteBuffer get(byte[] dst, - int offset, - int length) - - Relative bulk get method. - - This method transfers bytes from this buffer into the given destination array. If there are fewer bytes remaining in the buffer than are required to satisfy the request, that is, if length > remaining(), then no bytes are transferred and a BufferUnderflowException is thrown. - - Otherwise, this method copies length bytes from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length. - - In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop - - for (int i = off; i < off + len; i++) - dst[i] = src.get(); - - except that it first checks that there are sufficient bytes in this buffer and it is potentially much more efficient. - - Parameters: - dst - The array into which bytes are to be written - offset - The offset within the array of the first byte to be written; must be non-negative and no larger than dst.length - length - The maximum number of bytes to be written to the given array; must be non-negative and no larger than dst.length - offset - Returns: - This buffer - Throws: - BufferUnderflowException - If there are fewer than length bytes remaining in this buffer - IndexOutOfBoundsException - If the preconditions on the offset and length parameters do not hold - -get - -public ByteBuffer get(byte[] dst) - - Relative bulk get method. - - This method transfers bytes from this buffer into the given destination array. An invocation of this method of the form src.get(a) behaves in exactly the same way as the invocation - - src.get(a, 0, a.length) - - Returns: - This buffer - Throws: - BufferUnderflowException - If there are fewer than length bytes remaining in this buffer - -put - -public ByteBuffer put(ByteBuffer src) - - Relative bulk put method (optional operation). - - This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. - - Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n. - - In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop - - while (src.hasRemaining()) - dst.put(src.get()); - - except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. - - Parameters: - src - The source buffer from which bytes are to be read; must not be this buffer - Returns: - This buffer - Throws: - BufferOverflowException - If there is insufficient space in this buffer for the remaining bytes in the source buffer - IllegalArgumentException - If the source buffer is this buffer - ReadOnlyBufferException - If this buffer is read-only - -put - -public ByteBuffer put(byte[] src, - int offset, - int length) - - Relative bulk put method (optional operation). - - This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. - - Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length. - - In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop - - for (int i = off; i < off + len; i++) - dst.put(a[i]); - - except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. - - Parameters: - src - The array from which bytes are to be read - offset - The offset within the array of the first byte to be read; must be non-negative and no larger than array.length - length - The number of bytes to be read from the given array; must be non-negative and no larger than array.length - offset - Returns: - This buffer - Throws: - BufferOverflowException - If there is insufficient space in this buffer - IndexOutOfBoundsException - If the preconditions on the offset and length parameters do not hold - ReadOnlyBufferException - If this buffer is read-only - -put - -public final ByteBuffer put(byte[] src) - - Relative bulk put method (optional operation). - - This method transfers the entire content of the given source byte array into this buffer. An invocation of this method of the form dst.put(a) behaves in exactly the same way as the invocation - - dst.put(a, 0, a.length) - - Returns: - This buffer - Throws: - BufferOverflowException - If there is insufficient space in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getChar - -public abstract char getChar() - - Relative get method for reading a char value. - - Reads the next two bytes at this buffer's current position, composing them into a char value according to the current byte order, and then increments the position by two. - - Returns: - The char value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than two bytes remaining in this buffer - -putChar - -public abstract ByteBuffer putChar(char value) - - Relative put method for writing a char value (optional operation). - - Writes two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two. - - Parameters: - value - The char value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than two bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getChar - -public abstract char getChar(int index) - - Absolute get method for reading a char value. - - Reads two bytes at the given index, composing them into a char value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The char value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one - -putChar - -public abstract ByteBuffer putChar(int index, - char value) - - Absolute put method for writing a char value (optional operation). - - Writes two bytes containing the given char value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The char value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one - ReadOnlyBufferException - If this buffer is read-only - -asCharBuffer - -public abstract CharBuffer asCharBuffer() - - Creates a view of this byte buffer as a char buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new char buffer - -getShort - -public abstract short getShort() - - Relative get method for reading a short value. - - Reads the next two bytes at this buffer's current position, composing them into a short value according to the current byte order, and then increments the position by two. - - Returns: - The short value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than two bytes remaining in this buffer - -putShort - -public abstract ByteBuffer putShort(short value) - - Relative put method for writing a short value (optional operation). - - Writes two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two. - - Parameters: - value - The short value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than two bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getShort - -public abstract short getShort(int index) - - Absolute get method for reading a short value. - - Reads two bytes at the given index, composing them into a short value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The short value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one - -putShort - -public abstract ByteBuffer putShort(int index, - short value) - - Absolute put method for writing a short value (optional operation). - - Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The short value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus one - ReadOnlyBufferException - If this buffer is read-only - -asShortBuffer - -public abstract ShortBuffer asShortBuffer() - - Creates a view of this byte buffer as a short buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new short buffer - -getInt - -public abstract int getInt() - - Relative get method for reading an int value. - - Reads the next four bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by four. - - Returns: - The int value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than four bytes remaining in this buffer - -putInt - -public abstract ByteBuffer putInt(int value) - - Relative put method for writing an int value (optional operation). - - Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four. - - Parameters: - value - The int value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than four bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getInt - -public abstract int getInt(int index) - - Absolute get method for reading an int value. - - Reads four bytes at the given index, composing them into a int value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The int value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three - -putInt - -public abstract ByteBuffer putInt(int index, - int value) - - Absolute put method for writing an int value (optional operation). - - Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The int value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three - ReadOnlyBufferException - If this buffer is read-only - -asIntBuffer - -public abstract IntBuffer asIntBuffer() - - Creates a view of this byte buffer as an int buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new int buffer - -getLong - -public abstract long getLong() - - Relative get method for reading a long value. - - Reads the next eight bytes at this buffer's current position, composing them into a long value according to the current byte order, and then increments the position by eight. - - Returns: - The long value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than eight bytes remaining in this buffer - -putLong - -public abstract ByteBuffer putLong(long value) - - Relative put method for writing a long value (optional operation). - - Writes eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight. - - Parameters: - value - The long value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than eight bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getLong - -public abstract long getLong(int index) - - Absolute get method for reading a long value. - - Reads eight bytes at the given index, composing them into a long value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The long value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven - -putLong - -public abstract ByteBuffer putLong(int index, - long value) - - Absolute put method for writing a long value (optional operation). - - Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The long value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven - ReadOnlyBufferException - If this buffer is read-only - -asLongBuffer - -public abstract LongBuffer asLongBuffer() - - Creates a view of this byte buffer as a long buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new long buffer - -getFloat - -public abstract float getFloat() - - Relative get method for reading a float value. - - Reads the next four bytes at this buffer's current position, composing them into a float value according to the current byte order, and then increments the position by four. - - Returns: - The float value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than four bytes remaining in this buffer - -putFloat - -public abstract ByteBuffer putFloat(float value) - - Relative put method for writing a float value (optional operation). - - Writes four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four. - - Parameters: - value - The float value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than four bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getFloat - -public abstract float getFloat(int index) - - Absolute get method for reading a float value. - - Reads four bytes at the given index, composing them into a float value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The float value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three - -putFloat - -public abstract ByteBuffer putFloat(int index, - float value) - - Absolute put method for writing a float value (optional operation). - - Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The float value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three - ReadOnlyBufferException - If this buffer is read-only - -asFloatBuffer - -public abstract FloatBuffer asFloatBuffer() - - Creates a view of this byte buffer as a float buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new float buffer - -getDouble - -public abstract double getDouble() - - Relative get method for reading a double value. - - Reads the next eight bytes at this buffer's current position, composing them into a double value according to the current byte order, and then increments the position by eight. - - Returns: - The double value at the buffer's current position - Throws: - BufferUnderflowException - If there are fewer than eight bytes remaining in this buffer - -putDouble - -public abstract ByteBuffer putDouble(double value) - - Relative put method for writing a double value (optional operation). - - Writes eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight. - - Parameters: - value - The double value to be written - Returns: - This buffer - Throws: - BufferOverflowException - If there are fewer than eight bytes remaining in this buffer - ReadOnlyBufferException - If this buffer is read-only - -getDouble - -public abstract double getDouble(int index) - - Absolute get method for reading a double value. - - Reads eight bytes at the given index, composing them into a double value according to the current byte order. - - Parameters: - index - The index from which the bytes will be read - Returns: - The double value at the given index - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven - -putDouble - -public abstract ByteBuffer putDouble(int index, - double value) - - Absolute put method for writing a double value (optional operation). - - Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index. - - Parameters: - index - The index at which the bytes will be written - value - The double value to be written - Returns: - This buffer - Throws: - IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus seven - ReadOnlyBufferException - If this buffer is read-only - -asDoubleBuffer - -public abstract DoubleBuffer asDoubleBuffer() - - Creates a view of this byte buffer as a double buffer. - - The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent. - - The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only. - - Returns: - A new double buffer - -*/ - - - -/* - -order - -public final ByteOrder order() - - Retrieves this buffer's byte order. - - The byte order is used when reading or writing multibyte values, - and when creating buffers that are views of this byte buffer. The - order of a newly-created byte buffer is always BIG_ENDIAN. +PyDoc_STRVAR(relative_get__doc__, +"B.get*() -> data\n\ +\n\ +Relative get methods. \n\ +Reads something at this buffer's current position, \n\ +and then increments the position.\n\ +An IndexError is raised if the position is at the end of the buffer."); + +PyDoc_STRVAR(relative_put__doc__, +"B.put*(data)\n\ +\n\ +Relative put methods. \n\ +Writes the given byte into this buffer at the current position,\n\ +and then increments the position.\n\ +An IndexError is raised if the position is at the end of the buffer."); + + +/* Check if we're going to be trying to year beyond the buffer active + window limit, and if so, sets and error and return */ +#define CHECK_LIMIT_ERROR(sz) \ + if ( (self->b_position + sz) > self->b_limit ) { \ + PyErr_SetString(PyExc_IndexError, \ + "attempted read beyond buffer limit"); \ + return NULL; \ + } - Returns: - This buffer's byte order +static PyObject* +hotbuf_getbyte(PyHotbufObject *self) +{ + unsigned char byte; + CHECK_LIMIT_ERROR(sizeof(byte)); -order + byte = *(unsigned char*)(self->b_ptr + self->b_position); + self->b_position += sizeof(byte); + return PyInt_FromLong(byte); +} -public final ByteBuffer order(ByteOrder bo) +static PyObject* +hotbuf_putbyte(PyHotbufObject *self, PyObject* arg) +{ + int byte_i; + unsigned char byte; - Modifies this buffer's byte order. + byte_i = PyInt_AsLong(arg); + if ( byte_i > 255 ) { + PyErr_SetString(PyExc_ValueError, + "overflow for byte"); + return NULL; + } + byte = (unsigned char)byte_i; - Parameters: - bo - The new byte order, either BIG_ENDIAN or LITTLE_ENDIAN - Returns: - This buffer + CHECK_LIMIT_ERROR(sizeof(byte)); + *(unsigned char*)(self->b_ptr + self->b_position) = byte; + self->b_position += sizeof(byte); + return Py_None; +} -*/ @@ -1265,6 +664,9 @@ {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, + + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, {NULL, NULL} /* sentinel */ }; From buildbot at python.org Wed May 24 19:38:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 17:38:59 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060524173859.C3E6B1E400A@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/518 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 24 19:40:38 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 24 May 2006 19:40:38 +0200 (CEST) Subject: [Python-checkins] r46191 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060524174038.191181E400A@bag.python.org> Author: georg.brandl Date: Wed May 24 19:40:36 2006 New Revision: 46191 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Upadtes. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 19:40:36 2006 @@ -1,10 +1,19 @@ /* C implementation of the decimal module. * - * Partly written in Iceland by Georg Brandl. - * - * vim:ts=4:sw=4:et:si + * Partly written for the Need for Speed sprint in + * Iceland by Georg Brandl and Jack Diederich. */ +/* Notable incompatibilities between this and the original decimal.py: + + - Rounding constants are integers. + - There's handle method on the exceptions. + - Special values are represented by special sign values, so + the results of as_tuple() differ. + - Many internal "underscore" methods are not accessible on the object. + +*/ + #include "Python.h" #include "modsupport.h" #include "structmember.h" @@ -18,15 +27,19 @@ #define contextobject PyDecimalContextObject #define decimalobject PyDecimalObject +/* for context->flags, ->traps, ->ignored */ #define ISFLAGSET(f, b) (((f) >> b) & 1) #define SETFLAG(f, b) (f |= (1 << b)) -#define UNSETFLAG(f, b) (f &= (0 << b)) +#define UNSETFLAG(f, b) (f ^= (1 << b)) /* Checks */ #define ISSPECIAL(op) ((op)->sign >= SIGN_POSINF) + +/* 1 if NaN, 2 if sNan, 0 else */ #define GETNAN(op) ( ( (op)->sign == SIGN_POSNAN || (op)->sign == SIGN_NEGNAN ) ? \ 1 : ( ( (op)->sign == SIGN_POSSNAN || (op)->sign == SIGN_NEGSNAN ) ? 2 : 0 ) ) + #define ISINF(op) ((op)->sign == SIGN_POSINF || (op)->sign == SIGN_NEGINF) /* Exponent calculations */ @@ -52,6 +65,7 @@ /* Rounding constants */ +/* for context->rounding */ #define ROUND_DOWN 0 #define ROUND_UP 1 #define ROUND_HALF_DOWN 2 @@ -61,6 +75,7 @@ #define ROUND_CEILING 6 #define VALID_ROUND(x) ((x) <= ROUND_CEILING && (x) >= ROUND_DOWN) +/* for context->rounding_dec */ #define ALWAYS_ROUND 0 #define NEVER_ROUND 16 #define VALID_ROUND_DEC(x) ((x) == ALWAYS_ROUND || (x) == NEVER_ROUND) @@ -78,7 +93,10 @@ #define S_UNDERFLOW 6 #define S_SUBNORMAL 7 -/* Other conditions, all raising S_INV_OPERATION. */ +/* Other conditions. If they occur and raise an exception, + it will be InvalidOperation. Also, context->flags, ->traps and + ->ignored will only contain bits for the signals defined above. +*/ #define NUMCONDITIONS 4 @@ -92,7 +110,7 @@ /* Indentation below hints at inheritance. */ -static PyObject *DecimalException; +static PyObject *DecimalException; /* never actually raised */ static PyObject *Clamped; static PyObject *InvalidOperation; static PyObject *ConversionSyntax; @@ -106,12 +124,28 @@ static PyObject *Underflow; /* also inherits Inexact, Subnormal */ static PyObject *Subnormal; +/* this contains these exception types, indexed by the S_* and C_* + constants defined above. Initialized in init_decimal. */ static PyObject *errors[NUMSIGNALS+NUMCONDITIONS]; -/* Forward */ + +/* Forwarding ****************************************************************/ + +static contextobject *getcontext(void); +static int setcontext(contextobject *); +static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); +static int decimal_nonzero(decimalobject *); +static decimalobject *_decimal_get_copy(decimalobject *); +static decimalobject *_decimal_from_pylong(PyTypeObject *, PyObject *, contextobject *); +static contextobject * context_copy(contextobject *); +static PyObject *decimal_from_long(PyTypeObject *, long); +static PyObject *decimal_str(decimalobject *); +static PyObject *_do_decimal_str(decimalobject *, contextobject *, int); static decimalobject *_new_decimalobj(PyTypeObject *, long, char, long); +/* Exception handlers *********************************************************/ +/* Raise the exception if signal is trapped and not ignored. */ #define HANDLE_ERROR(ctx, cond, expl, onerror) \ int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ if (! ISFLAGSET(ctx->ignored, err)) { \ @@ -280,20 +314,7 @@ } -/* Forwarding ****************************************************************/ - -static contextobject *getcontext(void); -static int setcontext(contextobject *); -static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); -static int decimal_nonzero(decimalobject *); -static decimalobject *_decimal_get_copy(decimalobject *); -static decimalobject *_decimal_from_pylong(PyTypeObject *, PyObject *, contextobject *); -static contextobject * context_copy(contextobject *); -static PyObject *decimal_from_long(PyTypeObject *, long); -static PyObject *decimal_str(decimalobject *); -static PyObject *_do_decimal_str(decimalobject *, contextobject *, int); - -/* Decimal methods ***********************************************************/ +/* Decimal object methods *****************************************************/ static decimalobject * @@ -320,10 +341,12 @@ return new; } -/* shortcut to use in methods */ +/* shortcut for use in methods */ #define _NEW_decimalobj(ndigits, sign, exp) \ _new_decimalobj(self->ob_type, ndigits, sign, exp) +/* Helper functions ***********************************************************/ + /* Check whether the number(s) aren't really numbers. * * If x and/or y are sNaN, signal, possibly storing the result @@ -455,22 +478,16 @@ } /* Actually round half up. Returns a new reference, either on tmp - * or a new decimalobject, and steals one reference on tmp in turn, - * if it was passed in so that you can just do - * return _do_round_half_up(...) */ + * or a new decimalobject, and steals one reference on tmp in turn + * if it was passed in so that you can just return _do_round_half_up(...) + * without DECREFing tmp afterwards. + */ static decimalobject * _do_round_half_up(decimalobject *self, long prec, long expdiff, contextobject *ctx, decimalobject *tmp) { decimalobject *new; - long i; assert(expdiff > 0); - if (!tmp) { - tmp = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); - if (!tmp) return NULL; - for (i = 0; i < prec; i++) - tmp->digits[i] = self->digits[i]; - } if (self->ob_size > prec && self->digits[prec] >= 5) { new = _decimal_increment(tmp, 1, ctx); Py_DECREF(tmp); @@ -507,6 +524,7 @@ return _do_round_half_up(self, prec, expdiff, ctx, tmp); } +/* Round 5 to even, rest to nearest. */ static decimalobject * _round_half_even(decimalobject *self, long prec, long expdiff, contextobject *ctx) { @@ -532,7 +550,13 @@ static decimalobject * _round_half_up(decimalobject *self, long prec, long expdiff, contextobject *ctx) { - return _do_round_half_up(self, prec, expdiff, ctx, NULL); + decimalobject *tmp; + long i; + tmp = _NEW_decimalobj(prec, self->sign, self->exp - expdiff); + if (!tmp) return NULL; + for (i = 0; i < prec; i++) + tmp->digits[i] = self->digits[i]; + return _do_round_half_up(self, prec, expdiff, ctx, tmp); } /* Round up (regardless of sign) */ @@ -1134,7 +1158,26 @@ static decimalobject * _do_decimal_to_integral(decimalobject *self, contextobject *ctx, int rounding) { - /* XXX */ + int rnd, inex; + decimalobject *ans; + + if (ISSPECIAL(self)) { + decimalobject *nan; + if (_check_nans(self, NULL, ctx, &nan) != 0) + return nan; + } + if (self->exp >= 0) { + Py_INCREF(self); + return self; + } + rnd = ISFLAGSET(ctx->ignored, S_ROUNDED); + inex = ISFLAGSET(ctx->ignored, S_INEXACT); + SETFLAG(ctx->ignored, S_ROUNDED); + SETFLAG(ctx->ignored, S_INEXACT); + ans = _decimal_rescale(self, 0, ctx, rounding, 1); + if (!rnd) UNSETFLAG(ctx->ignored, S_ROUNDED); + if (!inex) UNSETFLAG(ctx->ignored, S_INEXACT); + return ans; } static PyObject * @@ -1148,7 +1191,7 @@ &rounding, &ctx)) return NULL; ENSURE_CONTEXT("to_integral", ctx); - if (rounding < -1 || rounding > 6) { + if (!VALID_ROUND(rounding)) { PyErr_SetString(PyExc_ValueError, "invalid rounding value"); return NULL; } @@ -2733,6 +2776,7 @@ res = decimal_new(&PyDecimal_DecimalType, nargs, NULL); Py_DECREF(nargs); } + if (!res) return NULL; fixed = _decimal_fix((decimalobject *)res, self); Py_DECREF(res); @@ -2952,7 +2996,8 @@ ignored = context_get_ignored(self); if (!ignored) goto err; - res = Py_BuildValue("liiOOlliiO", self->prec, self->rounding, + res = Py_BuildValue("(O(liiOOlliiO))", self->ob_type, + self->prec, self->rounding, self->rounding_dec, traps, flags, self->Emin, self->Emax, self->capitals, self->clamp, ignored); @@ -3056,7 +3101,7 @@ old_dec = self->rounding_dec; self->rounding_dec = new_dec; - ret = PyLong_FromLong((long)old_dec); + ret = PyInt_FromLong((long)old_dec); if (ret == NULL) return NULL; return ret; @@ -3075,7 +3120,7 @@ } old_round = self->rounding; self->rounding = new_round; - ret = PyLong_FromLong((long)old_round); + ret = PyInt_FromLong((long)old_round); if (ret == NULL) return NULL; return ret; @@ -3235,6 +3280,8 @@ self->capitals, flags, traps); } +#undef TEST_AND_CAT + static long context_hash(PyObject *c) { @@ -3482,11 +3529,6 @@ }; -#define ADD_CONST(m, name) \ - if (PyModule_AddIntConstant(m, #name, name) < 0) { \ - return; \ - } - #define INIT_EXC(m, name, base) \ name = PyErr_NewException(MODULE_NAME "." #name, base, NULL); \ if (!name) return; \ @@ -3505,6 +3547,9 @@ INIT_EXC(m, name, tup) \ Py_DECREF(tup) +#define ADD_CONST(m, name) \ + if (PyModule_AddIntConstant(m, #name, name) < 0) return + PyMODINIT_FUNC INITFUNC_NAME(void) @@ -3529,7 +3574,8 @@ Py_INCREF(&PyDecimal_DecimalContextType); PyModule_AddObject(m, "Context", (PyObject *) &PyDecimal_DecimalContextType); - + + /* initialize default Context objects */ SETFLAG(traps, S_DIV_BY_ZERO); SETFLAG(traps, S_OVERFLOW); SETFLAG(traps, S_INV_OPERATION); From python-checkins at python.org Wed May 24 19:40:55 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 19:40:55 +0200 (CEST) Subject: [Python-checkins] r46192 - in python/branches/blais-bytebuf: Lib/hotbuf.py Lib/test/test_hotbuf.py Modules/_hotbuf.c Modules/hotbufmodule.c setup.py Message-ID: <20060524174055.ED2531E400A@bag.python.org> Author: martin.blais Date: Wed May 24 19:40:55 2006 New Revision: 46192 Added: python/branches/blais-bytebuf/Lib/hotbuf.py (contents, props changed) python/branches/blais-bytebuf/Modules/_hotbuf.c - copied, changed from r46190, python/branches/blais-bytebuf/Modules/hotbufmodule.c Removed: python/branches/blais-bytebuf/Modules/hotbufmodule.c Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/setup.py Log: Moved hotbufmodule to _hotbuf, created hotbuf.py wrapper and enabled as a base class. Added: python/branches/blais-bytebuf/Lib/hotbuf.py ============================================================================== --- (empty file) +++ python/branches/blais-bytebuf/Lib/hotbuf.py Wed May 24 19:40:55 2006 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +""" +A buffer class for fast I/O. +""" + +from _hotbuf import _hotbuf + +class hotbuf(_hotbuf): + pass + + Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Wed May 24 19:40:55 2006 @@ -97,18 +97,12 @@ b.flip() for x in xrange(256): nx = b.getbyte() - print nx assert nx == x # Test underflow. self.assertRaises(IndexError, b.putbyte, 42) - - - - - def test_main(): test_support.run_unittest(HotbufTestCase) Copied: python/branches/blais-bytebuf/Modules/_hotbuf.c (from r46190, python/branches/blais-bytebuf/Modules/hotbufmodule.c) ============================================================================== --- python/branches/blais-bytebuf/Modules/hotbufmodule.c (original) +++ python/branches/blais-bytebuf/Modules/_hotbuf.c Wed May 24 19:40:55 2006 @@ -651,23 +651,23 @@ static PyMethodDef hotbuf_methods[] = { - {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, - {"capacity", (PyCFunction)hotbuf_capacity, METH_NOARGS, capacity__doc__}, - {"position", (PyCFunction)hotbuf_position, METH_NOARGS, position__doc__}, - {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, - {"limit", (PyCFunction)hotbuf_limit, METH_NOARGS, limit__doc__}, - {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, - {"mark", (PyCFunction)hotbuf_mark, METH_NOARGS, mark__doc__}, - {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, - {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, - {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, - {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, - {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, - {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, - - {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, - {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, - {NULL, NULL} /* sentinel */ + {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, + {"capacity", (PyCFunction)hotbuf_capacity, METH_NOARGS, capacity__doc__}, + {"position", (PyCFunction)hotbuf_position, METH_NOARGS, position__doc__}, + {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, + {"limit", (PyCFunction)hotbuf_limit, METH_NOARGS, limit__doc__}, + {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, + {"mark", (PyCFunction)hotbuf_mark, METH_NOARGS, mark__doc__}, + {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, + {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, + {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, + {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, + {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, + {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, + + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, + {NULL, NULL} /* sentinel */ }; static PySequenceMethods hotbuf_as_sequence = { @@ -687,46 +687,46 @@ (charbufferproc)hotbuf_getcharbuf, }; -PyTypeObject PyHotbuf_Type = { +static PyTypeObject PyHotbuf_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, - "hotbuf", + "_hotbuf._hotbuf", sizeof(PyHotbufObject), 0, - (destructor)hotbuf_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)hotbuf_compare, /* tp_compare */ - (reprfunc)hotbuf_repr, /* tp_repr */ - 0, /* tp_as_number */ - &hotbuf_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)hotbuf_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &hotbuf_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - hotbuf_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - hotbuf_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - hotbuf_new, /* tp_new */ + (destructor)hotbuf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)hotbuf_compare, /* tp_compare */ + (reprfunc)hotbuf_repr, /* tp_repr */ + 0, /* tp_as_number */ + &hotbuf_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)hotbuf_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &hotbuf_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + hotbuf_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + hotbuf_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + hotbuf_new, /* tp_new */ }; @@ -762,38 +762,18 @@ PyMODINIT_FUNC -inithotbuf(void) +init_hotbuf(void) { PyObject *m; PyHotbuf_Type.ob_type = &PyType_Type; - m = Py_InitModule3("hotbuf", a_methods, module_doc); + m = Py_InitModule3("_hotbuf", a_methods, module_doc); if (m == NULL) return; Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Py_INCREF((PyObject *)&PyHotbuf_Type); - PyModule_AddObject(m, "hotbuf", (PyObject *)&PyHotbuf_Type); - /* No need to check the error here, the caller will do that */ + PyModule_AddObject(m, "_hotbuf", (PyObject *)&PyHotbuf_Type); } - - -/* - TODO - ---- - - Add hash function - - Add support for sequence methods. - - Perhaps implement returning the buffer object itself from some of - the methods in order to allow chaining of operations on a single line. - - Implement a resize function - - Maybe remove the API methods declared at the top. - - Add support for big vs. little endian - - Pending Issues - -------------- - - Should we support weakrefs? - -*/ - Deleted: /python/branches/blais-bytebuf/Modules/hotbufmodule.c ============================================================================== --- /python/branches/blais-bytebuf/Modules/hotbufmodule.c Wed May 24 19:40:55 2006 +++ (empty file) @@ -1,799 +0,0 @@ -/* =========================================================================== - * Hotbuf object: an equivalent to Java's NIO ByteBuffer class for fast - * network I/O. - */ - -#include "Python.h" -#include /* for memmove */ - -PyAPI_DATA(PyTypeObject) PyHotbuf_Type; - -#define PyHotbuf_Check(op) ((op)->ob_type == &PyHotbuf_Type) - -#define Py_END_OF_HOTBUF (-1) - -PyAPI_FUNC(PyObject *) PyHotbuf_New(Py_ssize_t size); - - - -/* =========================================================================== - * Byte Buffer object implementation - */ - - -/* - * hotbuf object structure declaration. - - From the Java Buffer docs: - - A buffer is a linear, finite sequence of elements of a specific - primitive type. Aside from its content, the essential properties of a - buffer are its capacity, limit, and position: - - A buffer's capacity is the number of elements it contains. The - capacity of a buffer is never negative and never changes. - - A buffer's limit is the index of the first element that should not - be read or written. A buffer's limit is never negative and is never - greater than its capacity. - - A buffer's position is the index of the next element to be read or - written. A buffer's position is never negative and is never greater - than its limit. - - The following invariant holds for the mark, position, limit, and - capacity values: - - 0 <= mark <= position <= limit <= capacity (length) - - */ -typedef struct { - PyObject_HEAD - - /* Base pointer location */ - void* b_ptr; - - /* Total size in bytes of the area that we can access. The allocated - memory must be at least as large as this size. */ - Py_ssize_t b_capacity; - - /* - * The "active window" is defined by the interval [position, limit[. - */ - - /* The current position in the buffer. */ - int b_position; - - /* The limit position in the buffer. */ - int b_limit; - - /* The mark. From the Java Buffer docs: - - A buffer's mark is the index to which its position will be reset when - the reset method is invoked. The mark is not always defined, but when - it is defined it is never negative and is never greater than the - position. If the mark is defined then it is discarded when the - position or the limit is adjusted to a value smaller than the mark. If - the mark is not defined then invoking the reset method causes an - InvalidMarkException to be thrown. - - The mark is set to -1 to indicate that the mark is unset. - */ - int b_mark; - -} PyHotbufObject; - - -/* - * Given a hotbuf object, return the buffer memory (in 'ptr' and 'size') and - * true if there was no error. - */ - -/* - * Create a new hotbuf where we allocate the memory ourselves. - */ -PyObject * -PyHotbuf_New(Py_ssize_t capacity) -{ - PyObject *o; - PyHotbufObject * b; - - if (capacity < 0) { - PyErr_SetString(PyExc_ValueError, - "capacity must be zero or positive"); - return NULL; - } - - /* FIXME: check for overflow in multiply */ - o = (PyObject *)PyObject_MALLOC(sizeof(*b) + capacity); - if ( o == NULL ) - return PyErr_NoMemory(); - b = (PyHotbufObject *) PyObject_INIT(o, &PyHotbuf_Type); - - /* We setup the memory buffer to be right after the object itself. */ - b->b_ptr = (void *)(b + 1); - b->b_position = 0; - b->b_mark = -1; - b->b_limit = capacity; - b->b_capacity = capacity; - - return o; -} - -/* Methods */ - -/* - * Constructor. - */ -static PyObject * -hotbuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - Py_ssize_t size = -1; - - if (!_PyArg_NoKeywords("hotbuf()", kw)) - return NULL; - - if (!PyArg_ParseTuple(args, "n:hotbuf", &size)) - return NULL; - - if ( size <= 0 ) { - PyErr_SetString(PyExc_ValueError, - "size must be greater than zero"); - return NULL; - } - - return PyHotbuf_New(size); -} - -/* - * Destructor. - */ -static void -hotbuf_dealloc(PyHotbufObject *self) -{ - /* Note: by virtue of the memory buffer being allocated with the PyObject - itself, this frees the buffer as well. */ - PyObject_DEL(self); -} - -/* - * Comparison. We compare the active windows, not the entire allocated buffer - * memory. - */ -static int -hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) -{ - Py_ssize_t min_len; - int cmp; - - min_len = ((self->b_capacity < other->b_capacity) ? - self->b_capacity : other->b_capacity); - if (min_len > 0) { - cmp = memcmp(self->b_ptr, other->b_ptr, min_len); - if (cmp != 0) - return cmp; - } - return ((self->b_capacity < other->b_capacity) ? - -1 : (self->b_capacity > other->b_capacity) ? 1 : 0); -} - - -/* - * Conversion to 'repr' string. - */ -static PyObject * -hotbuf_repr(PyHotbufObject *self) -{ - return PyString_FromFormat("", - self->b_ptr, - self->b_capacity, - self); -} - -/* - * Conversion to string. We convert only the active window. - */ -static PyObject * -hotbuf_str(PyHotbufObject *self) -{ - return PyString_FromStringAndSize((const char *)self->b_ptr, self->b_capacity); -} - - - -/* =========================================================================== - * Object Methods (basic interface) - */ - -PyDoc_STRVAR(capacity__doc__, -"B.capacity() -> int\n\ -\n\ -Returns this buffer's capacity. \n\ -(the entire size of the allocated buffer.)"); - -static PyObject* -hotbuf_capacity(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_capacity); -} - - -PyDoc_STRVAR(position__doc__, -"B.position() -> int\n\ -\n\ -Returns this buffer's position."); - -static PyObject* -hotbuf_position(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_position); -} - - -PyDoc_STRVAR(setposition__doc__, -"B.setposition(int)\n\ -\n\ -Sets this buffer's position. If the mark is defined and larger than\n\ -the new position then it is discarded. If the given position is\n\ -larger than the limit an exception is raised."); - -static PyObject* -hotbuf_setposition(PyHotbufObject *self, PyObject* arg) -{ - int newposition; - - newposition = PyInt_AsLong(arg); - if (newposition == -1 && PyErr_Occurred()) - return NULL; - - if ( newposition > self->b_capacity ) { - PyErr_SetString(PyExc_IndexError, - "position must be smaller than capacity"); - return NULL; - } - - /* Set the new position */ - self->b_position = newposition; - - /* Discard the mark if it is beyond the new position */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; - - return Py_None; -} - - -PyDoc_STRVAR(limit__doc__, -"B.limit() -> int\n\ -\n\ -Returns this buffer's limit."); - -static PyObject* -hotbuf_limit(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_limit); -} - - -PyDoc_STRVAR(setlimit__doc__, -"B.setlimit(int)\n\ -\n\ -Sets this buffer's limit. If the position is larger than the new limit\n\ -then it is set to the new limit. If the mark is defined and larger\n\ -than the new limit then it is discarded."); - -static PyObject* -hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) -{ - int newlimit; - - newlimit = PyInt_AsLong(arg); - if (newlimit == -1 && PyErr_Occurred()) - return NULL; - - if ( newlimit > self->b_capacity ) { - PyErr_SetString(PyExc_IndexError, - "limit must be smaller than capacity"); - return NULL; - } - - /* Set the new limit. */ - self->b_limit = newlimit; - - /* If the position is larger than the new limit, set it to the new - limit. */ - if ( self->b_position > self->b_limit ) - self->b_position = newlimit; - - /* Discard the mark if it is beyond the new limit */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; - - return Py_None; -} - - -PyDoc_STRVAR(mark__doc__, -"B.mark() -> int\n\ -\n\ -Returns this buffer's mark. \n\ -Return -1 if the mark is not set."); - -static PyObject* -hotbuf_mark(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_mark); -} - - -PyDoc_STRVAR(setmark__doc__, -"B.setmark()\n\ -\n\ -Sets this buffer's mark at its position."); - -static PyObject* -hotbuf_setmark(PyHotbufObject *self) -{ - self->b_mark = self->b_position; - return Py_None; -} - - -PyDoc_STRVAR(reset__doc__, -"B.reset() -> int\n\ -\n\ -Resets this buffer's position to the previously-marked position.\n\ -Invoking this method neither changes nor discards the mark's value.\n\ -An IndexError is raised if the mark has not been set.\n\ -This method returns the new position's value."); - -static PyObject* -hotbuf_reset(PyHotbufObject *self) -{ - if ( self->b_mark == -1 ) { - PyErr_SetString(PyExc_IndexError, - "mark has not been yet set"); - return NULL; - } - - self->b_position = self->b_mark; - return PyInt_FromLong(self->b_position); -} - - -PyDoc_STRVAR(clear__doc__, -"B.clear()\n\ -\n\ -Clears this buffer. The position is set to zero, the limit is set to\n\ -the capacity, and the mark is discarded.\n\ -\n\ -Invoke this method before using a sequence of channel-read or put\n\ -operations to fill this buffer. For example:\n\ -\n\ - buf.clear() # Prepare buffer for reading\n\ - in.read(buf) # Read data\n\ -\n\ -(This method does not actually erase the data in the buffer, but it is\n\ -named as if it did because it will most often be used in situations in\n\ -which that might as well be the case.)"); - -static PyObject* -hotbuf_clear(PyHotbufObject *self) -{ - self->b_position = 0; - self->b_limit = self->b_capacity; - self->b_mark = -1; - return Py_None; -} - - -PyDoc_STRVAR(flip__doc__, -"B.flip()\n\ -\n\ -Flips this buffer. The limit is set to the current position and then\n\ -the position is set to zero. If the mark is defined then it is\n\ -discarded.\n\ -\n\ -After a sequence of channel-read or put operations, invoke this method\n\ -to prepare for a sequence of channel-write or relative get\n\ -operations. For example:\n\ -\n\ - buf.put(magic) # Prepend header\n\ - in.read(buf) # Read data into rest of buffer\n\ - buf.flip() # Flip buffer\n\ - out.write(buf) # Write header + data to channel\n\ -\n\ -This method is often used in conjunction with the compact method when\n\ -transferring data from one place to another."); - -static PyObject* -hotbuf_flip(PyHotbufObject *self) -{ - self->b_limit = self->b_position; - self->b_position = 0; - self->b_mark = -1; - return Py_None; -} - - -PyDoc_STRVAR(rewind__doc__, -"B.rewind()\n\ -\n\ -Rewinds this buffer. The position is set to zero and the mark is\n\ -discarded.\n\ -\n\ -Invoke this method before a sequence of channel-write or get\n\ -operations, assuming that the limit has already been set\n\ -appropriately. For example:\n\ -\n\ - out.write(buf) # Write remaining data\n\ - buf.rewind() # Rewind buffer\n\ - buf.get(array) # Copy data into array\n\ -"); - -static PyObject* -hotbuf_rewind(PyHotbufObject *self) -{ - self->b_position = 0; - self->b_mark = -1; - return Py_None; -} - - -PyDoc_STRVAR(remaining__doc__, -"B.remaining() -> int\n\ -\n\ -Returns the number of bytes between the current position and the limit."); - -static PyObject* -hotbuf_remaining(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_limit - self->b_position); -} - - -PyDoc_STRVAR(compact__doc__, -"B.compact()\n\ -\n\ -public abstract ByteBuffer compact()\n\ -\n\ -Compacts this buffer (optional operation).\n\ -\n\ -The bytes between the buffer's current position and its limit, if\n\ -any, are copied to the beginning of the buffer. That is, the byte\n\ -at index p = position() is copied to index zero, the byte at index\n\ -p + 1 is copied to index one, and so forth until the byte at index\n\ -limit() - 1 is copied to index n = limit() - 1 - p. The buffer's\n\ -position is then set to n+1 and its limit is set to its\n\ -capacity. The mark, if defined, is discarded.\n\ -\n\ -The buffer's position is set to the number of bytes copied, rather\n\ -than to zero, so that an invocation of this method can be followed\n\ -immediately by an invocation of another relative put method.\n\ -\n\ -Invoke this method after writing data from a buffer in case the\n\ -write was incomplete. The following loop, for example, copies\n\ -bytes from one channel to another via the buffer buf:\n\ -\n\ - buf.clear() # Prepare buffer for use\n\ - while 1:\n\ - if in.read(buf) < 0 and buf.remaining() == 0:\n\ - break # No more bytes to transfer\n\ - buf.flip()\n\ - out.write(buf)\n\ - buf.compact() # In case of partial write\n\ -\n\ -"); - -static PyObject* -hotbuf_compact(PyHotbufObject *self) -{ - int length; - - /* Calculate the number of bytes in the active window */ - length = self->b_limit - self->b_position; - - /* Move the memory from the active window to the beginning of the - allocated buffer (only if we need to). */ - if ( length > 0 && self->b_position > 0 ) { - memmove(self->b_ptr, self->b_ptr + self->b_position, length); - } - - self->b_position = length; - self->b_limit = self->b_capacity; - self->b_mark = -1; - - return Py_None; -} - - - -/* =========================================================================== - * Object Methods (get/put methods) - */ - -PyDoc_STRVAR(relative_get__doc__, -"B.get*() -> data\n\ -\n\ -Relative get methods. \n\ -Reads something at this buffer's current position, \n\ -and then increments the position.\n\ -An IndexError is raised if the position is at the end of the buffer."); - -PyDoc_STRVAR(relative_put__doc__, -"B.put*(data)\n\ -\n\ -Relative put methods. \n\ -Writes the given byte into this buffer at the current position,\n\ -and then increments the position.\n\ -An IndexError is raised if the position is at the end of the buffer."); - - -/* Check if we're going to be trying to year beyond the buffer active - window limit, and if so, sets and error and return */ -#define CHECK_LIMIT_ERROR(sz) \ - if ( (self->b_position + sz) > self->b_limit ) { \ - PyErr_SetString(PyExc_IndexError, \ - "attempted read beyond buffer limit"); \ - return NULL; \ - } - - -static PyObject* -hotbuf_getbyte(PyHotbufObject *self) -{ - unsigned char byte; - CHECK_LIMIT_ERROR(sizeof(byte)); - - byte = *(unsigned char*)(self->b_ptr + self->b_position); - self->b_position += sizeof(byte); - return PyInt_FromLong(byte); -} - -static PyObject* -hotbuf_putbyte(PyHotbufObject *self, PyObject* arg) -{ - int byte_i; - unsigned char byte; - - byte_i = PyInt_AsLong(arg); - if ( byte_i > 255 ) { - PyErr_SetString(PyExc_ValueError, - "overflow for byte"); - return NULL; - } - byte = (unsigned char)byte_i; - - CHECK_LIMIT_ERROR(sizeof(byte)); - *(unsigned char*)(self->b_ptr + self->b_position) = byte; - self->b_position += sizeof(byte); - return Py_None; -} - - - - -/* =========================================================================== - * Buffer protocol methods - */ - -/* - * Returns the buffer for reading or writing. - */ -static Py_ssize_t -hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) -{ - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent hotbuf segment"); - return -1; - } - - *pp = self->b_ptr; - return self->b_capacity; -} - -static Py_ssize_t -hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) -{ - if (lenp) - *lenp = self->b_capacity; - return 1; -} - -static Py_ssize_t -hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) -{ - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent hotbuf segment"); - return -1; - } - - *pp = (const char *)self->b_ptr; - return self->b_capacity; -} - - - -/* =========================================================================== - * Sequence methods - */ - -static Py_ssize_t -hotbuf_length(PyHotbufObject *self) -{ - assert(self->b_position <= self->b_limit); - return self->b_limit - self->b_position; -} - - - -/* =========================================================================== - * Object interfaces declaration - */ - - -PyDoc_STRVAR(hotbuf_doc, -"hotbuf(capacity) -> hotbuf\n\ -\n\ -Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ -\n\ -hotbuf is a C encapsulation of a fixed-size buffer of bytes in memory.\n\ -One can read and write objects of different primitive types directly\n\ -into it, without having to convert from/to strings. Also, this is\n\ -meant for the network I/O functions (recv, recvfrom, send, sendto) to\n\ -read/write directly into without having to create temporary strings.\n\ -\n\ -Note that hotbuf is a direct Python equivalent of Java's NIO\n\ -ByteBuffer class."); - - -static PyMethodDef -hotbuf_methods[] = { - {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, - {"capacity", (PyCFunction)hotbuf_capacity, METH_NOARGS, capacity__doc__}, - {"position", (PyCFunction)hotbuf_position, METH_NOARGS, position__doc__}, - {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, - {"limit", (PyCFunction)hotbuf_limit, METH_NOARGS, limit__doc__}, - {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, - {"mark", (PyCFunction)hotbuf_mark, METH_NOARGS, mark__doc__}, - {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, - {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, - {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, - {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, - {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, - {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, - - {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, - {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PySequenceMethods hotbuf_as_sequence = { - (lenfunc)hotbuf_length, /*sq_length*/ - 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ - 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ - 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ - 0 /*(ssizessizeargfunc)hotbuf_slice*/, /*sq_slice*/ - 0 /*(ssizeobjargproc)hotbuf_ass_item*/, /*sq_ass_item*/ - 0 /*(ssizessizeobjargproc)hotbuf_ass_slice*/, /*sq_ass_slice*/ -}; - -static PyBufferProcs hotbuf_as_buffer = { - (readbufferproc)hotbuf_getwritebuf, - (writebufferproc)hotbuf_getwritebuf, - (segcountproc)hotbuf_getsegcount, - (charbufferproc)hotbuf_getcharbuf, -}; - -PyTypeObject PyHotbuf_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "hotbuf", - sizeof(PyHotbufObject), - 0, - (destructor)hotbuf_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)hotbuf_compare, /* tp_compare */ - (reprfunc)hotbuf_repr, /* tp_repr */ - 0, /* tp_as_number */ - &hotbuf_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)hotbuf_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &hotbuf_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - hotbuf_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - hotbuf_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - hotbuf_new, /* tp_new */ -}; - - - -/* =========================================================================== - * Install Module - */ - -PyDoc_STRVAR(module_doc, - "This module defines an object type which can represent a fixed size\n\ -buffer of bytes in momery, from which you can directly read and into\n\ -which you can directly write objects in various other types. This is\n\ -used to avoid buffer copies in network I/O as much as possible. For\n\ -example, socket recv() can directly fill a byte buffer's memory and\n\ -send() can read the data to be sent from one as well.\n\ -\n\ -In addition, a byte buffer has two pointers within it, that delimit\n\ -an active slice, the current \"position\" and the \"limit\". The\n\ -active region of a byte buffer is located within these boundaries.\n\ -\n\ -This class is heaviliy inspired from Java's NIO Hotbuffer class.\n\ -\n\ -The constructor is:\n\ -\n\ -hotbuf(nbytes) -- create a new hotbuf\n\ -"); - - -/* No functions in array module. */ -static PyMethodDef a_methods[] = { - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - - -PyMODINIT_FUNC -inithotbuf(void) -{ - PyObject *m; - - PyHotbuf_Type.ob_type = &PyType_Type; - m = Py_InitModule3("hotbuf", a_methods, module_doc); - if (m == NULL) - return; - - Py_INCREF((PyObject *)&PyHotbuf_Type); - PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); - Py_INCREF((PyObject *)&PyHotbuf_Type); - PyModule_AddObject(m, "hotbuf", (PyObject *)&PyHotbuf_Type); - /* No need to check the error here, the caller will do that */ -} - - - -/* - TODO - ---- - - Add hash function - - Add support for sequence methods. - - Perhaps implement returning the buffer object itself from some of - the methods in order to allow chaining of operations on a single line. - - Implement a resize function - - Maybe remove the API methods declared at the top. - - Add support for big vs. little endian - - Pending Issues - -------------- - - Should we support weakrefs? - -*/ - Modified: python/branches/blais-bytebuf/setup.py ============================================================================== --- python/branches/blais-bytebuf/setup.py (original) +++ python/branches/blais-bytebuf/setup.py Wed May 24 19:40:55 2006 @@ -336,7 +336,7 @@ exts.append( Extension('array', ['arraymodule.c']) ) # array objects - exts.append( Extension('hotbuf', ['hotbufmodule.c']) ) + exts.append( Extension('_hotbuf', ['_hotbuf.c']) ) # complex math library functions exts.append( Extension('cmath', ['cmathmodule.c'], From python-checkins at python.org Wed May 24 20:23:56 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 20:23:56 +0200 (CEST) Subject: [Python-checkins] r46193 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060524182356.2B16C1E400A@bag.python.org> Author: sean.reifschneider Date: Wed May 24 20:23:55 2006 New Revision: 46193 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding tests for things that Richard expects to break. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Wed May 24 20:23:55 2006 @@ -206,3 +206,58 @@ test_capi2() unlink(TESTFN) + +# test that exception attributes are happy. +try: unicode('\xff') +except Exception, e: sampleUnicodeError = e +exceptionList = [ + ( BaseException, (), { 'message' : '', 'args' : () }), + ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), + ( BaseException, ('foo', ), { 'message' : 'foo', 'args' : ( 'foo', ) }), + ( BaseException, ('foo', 1), { 'message' : '', 'args' : ( 'foo', 1 ) }), + ( SystemExit, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), + 'code' : 'foo' }), + ( EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 'errnoStr', 'filename' : 'filenameStr' }), + ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', + 'textStr', 'print_file_and_lineStr'), + { 'message' : '', 'args' : ('msgStr', 'filenameStr', + 'linenoStr', 'offsetStr', 'textStr', + 'print_file_and_lineStr'), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( sampleUnicodeError, + { 'message' : '', 'args' : ('ascii', '\xff', 0, 1, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : '\xff', + 'start' : 0, 'reason' : 'ordinal not in range(128)' }), + ( UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), + { 'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), + 'object' : u'\u3042', 'reason' : 'ouch', + 'start' : 0, 'end' : 1 }), + ] +try: + exceptionList.append( + ( WindowsError, ('errnoStr', 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 'errnoStr', 'filename' : 'filenameStr', + 'winerror' : 'foo' })) +except NameError: pass + +for args in exceptionList: + expected = args[-1] + try: + if len(args) == 2: raise args[0] + else: raise apply(args[0], args[1]) + except BaseException, e: + for checkArgName in expected.keys(): + if getattr(e, checkArgName) != expected[checkArgName]: + raise TestFailed('Checking exception arguments, exception ' + '"%s", attribute "%s" expected %s got %s.' % + ( repr(e), checkArgName, + repr(expected[checkArgName]), + repr(getattr(e, checkArgName)) )) From python-checkins at python.org Wed May 24 20:30:47 2006 From: python-checkins at python.org (martin.blais) Date: Wed, 24 May 2006 20:30:47 +0200 (CEST) Subject: [Python-checkins] r46194 - in python/branches/blais-bytebuf: Doc/api/exceptions.tex Doc/whatsnew/whatsnew25.tex Include/code.h Include/frameobject.h Include/unicodeobject.h Lib/distutils/command/build_ext.py Lib/distutils/sysconfig.py Lib/distutils/unixccompiler.py Lib/distutils/util.py Lib/struct.py Lib/test/regrtest.py Lib/test/test_builtin.py Lib/test/test_struct.py Mac/OSX/BuildScript Mac/OSX/Makefile.in Misc/ACKS Misc/NEWS Modules/Setup.dist Modules/_struct.c Modules/structmodule.c Objects/codeobject.c Objects/frameobject.c Objects/unicodeobject.c PC/config.c PCbuild/pythoncore.vcproj Python/ceval.c Python/errors.c Python/mystrtoul.c setup.py Message-ID: <20060524183047.36AA11E400A@bag.python.org> Author: martin.blais Date: Wed May 24 20:30:42 2006 New Revision: 46194 Added: python/branches/blais-bytebuf/Lib/struct.py - copied unchanged from r46193, python/trunk/Lib/struct.py python/branches/blais-bytebuf/Mac/OSX/BuildScript/ - copied from r46193, python/trunk/Mac/OSX/BuildScript/ python/branches/blais-bytebuf/Modules/_struct.c - copied unchanged from r46193, python/trunk/Modules/_struct.c Removed: python/branches/blais-bytebuf/Modules/structmodule.c Modified: python/branches/blais-bytebuf/Doc/api/exceptions.tex python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex python/branches/blais-bytebuf/Include/code.h python/branches/blais-bytebuf/Include/frameobject.h python/branches/blais-bytebuf/Include/unicodeobject.h python/branches/blais-bytebuf/Lib/distutils/command/build_ext.py python/branches/blais-bytebuf/Lib/distutils/sysconfig.py python/branches/blais-bytebuf/Lib/distutils/unixccompiler.py python/branches/blais-bytebuf/Lib/distutils/util.py python/branches/blais-bytebuf/Lib/test/regrtest.py python/branches/blais-bytebuf/Lib/test/test_builtin.py python/branches/blais-bytebuf/Lib/test/test_struct.py python/branches/blais-bytebuf/Mac/OSX/Makefile.in python/branches/blais-bytebuf/Misc/ACKS python/branches/blais-bytebuf/Misc/NEWS python/branches/blais-bytebuf/Modules/Setup.dist python/branches/blais-bytebuf/Objects/codeobject.c python/branches/blais-bytebuf/Objects/frameobject.c python/branches/blais-bytebuf/Objects/unicodeobject.c python/branches/blais-bytebuf/PC/config.c python/branches/blais-bytebuf/PCbuild/pythoncore.vcproj python/branches/blais-bytebuf/Python/ceval.c python/branches/blais-bytebuf/Python/errors.c python/branches/blais-bytebuf/Python/mystrtoul.c python/branches/blais-bytebuf/setup.py Log: (Updated to trunk) Modified: python/branches/blais-bytebuf/Doc/api/exceptions.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/api/exceptions.tex (original) +++ python/branches/blais-bytebuf/Doc/api/exceptions.tex Wed May 24 20:30:42 2006 @@ -341,7 +341,8 @@ The \member{__module__} attribute of the new class is set to the first part (up to the last dot) of the \var{name} argument, and the class name is set to the last part (after the last dot). The - \var{base} argument can be used to specify an alternate base class. + \var{base} argument can be used to specify alternate base classes; + it can either be only one class or a tuple of classes. The \var{dict} argument can be used to specify a dictionary of class variables and methods. \end{cfuncdesc} Modified: python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex Wed May 24 20:30:42 2006 @@ -1120,6 +1120,13 @@ %====================================================================== \subsection{Optimizations\label{opts}} +Several of the optimizations were developed at the NeedForSpeed +sprint, an event held in Reykjavik, Iceland, from May 21--28 2006. +The sprint focused on speed enhancements to the CPython implementation +and was funded by EWT LLC with local support from CCP Games. Those +optimizations added at this sprint are specially marked in the +following list. + \begin{itemize} \item When they were introduced @@ -1129,15 +1136,34 @@ and as a result sets will use a third less memory and are somewhat faster. (Implemented by Raymond Hettinger.) -\item The performance of some Unicode operations, such as -character map decoding, has been improved. +\item The speed of some Unicode operations, such as +finding substrings, string splitting, and character map decoding, has +been improved. (Substring search and splitting improvements were +added by Fredrik Lundh and Andrew Dalke at the NeedForSpeed +sprint. Character map decoding was improved by Walter D\"orwald.) % Patch 1313939 +\item The \module{struct} module now compiles structure format +strings into an internal representation and caches this +representation, yielding a 20\% speedup. (Contributed by Bob Ippolito +at the NeedForSpeed sprint.) + \item The code generator's peephole optimizer now performs simple constant folding in expressions. If you write something like \code{a = 2+3}, the code generator will do the arithmetic and produce code corresponding to \code{a = 5}. +\item Function calls are now faster because code objects now keep +the most recently finished frame (a ``zombie frame'') in an internal +field of the code object, reusing it the next time the code object is +invoked. (Original patch by Michael Hudson, modified by Armin Rigo +and Richard Jones; committed at the NeedForSpeed sprint.) +% Patch 876206 + +Frame objects are also slightly smaller, which may improve cache locality +and reduce memory usage a bit. (Contributed by Neal Norwitz.) +% Patch 1337051 + \end{itemize} The net result of the 2.5 optimizations is that Python 2.5 runs the @@ -1411,7 +1437,7 @@ included in the \file{Tools/pybench} directory. The pybench suite is an improvement on the commonly used \file{pystone.py} program because pybench provides a more detailed measurement of the interpreter's -performance. It times particular operations such as function calls, +speed. It times particular operations such as function calls, tuple slicing, method lookups, and numeric operations, instead of performing many different operations and reducing the result to a single number as \file{pystone.py} does. @@ -1935,6 +1961,10 @@ \code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}. (Contributed by Barry Warsaw.) +\item \cfunction{PyErr_NewException(\var{name}, \var{base}, +\var{dict})} can now accept a tuple of base classes as its \var{base} +argument. (Contributed by Georg Brandl.) + \item The CPython interpreter is still written in C, but the code can now be compiled with a {\Cpp} compiler without errors. (Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.) Modified: python/branches/blais-bytebuf/Include/code.h ============================================================================== --- python/branches/blais-bytebuf/Include/code.h (original) +++ python/branches/blais-bytebuf/Include/code.h Wed May 24 20:30:42 2006 @@ -24,6 +24,7 @@ PyObject *co_name; /* string (name, for reference) */ int co_firstlineno; /* first source line number */ PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ } PyCodeObject; /* Masks for co_flags above */ Modified: python/branches/blais-bytebuf/Include/frameobject.h ============================================================================== --- python/branches/blais-bytebuf/Include/frameobject.h (original) +++ python/branches/blais-bytebuf/Include/frameobject.h Wed May 24 20:30:42 2006 @@ -36,10 +36,6 @@ in this scope */ int f_iblock; /* index in f_blockstack */ PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ - int f_nlocals; /* number of locals */ - int f_ncells; - int f_nfreevars; - int f_stacksize; /* size of value stack */ PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ } PyFrameObject; Modified: python/branches/blais-bytebuf/Include/unicodeobject.h ============================================================================== --- python/branches/blais-bytebuf/Include/unicodeobject.h (original) +++ python/branches/blais-bytebuf/Include/unicodeobject.h Wed May 24 20:30:42 2006 @@ -367,10 +367,12 @@ for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ } while (0) -#define Py_UNICODE_MATCH(string, offset, substring)\ - ((*((string)->str + (offset)) == *((substring)->str)) &&\ - !memcmp((string)->str + (offset), (substring)->str,\ - (substring)->length*sizeof(Py_UNICODE))) +/* check if substring matches at given offset. the offset must be + valid, and the substring must not be empty */ +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->str + (offset)) == *((substring)->str)) && \ + ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ + !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) #ifdef __cplusplus extern "C" { Modified: python/branches/blais-bytebuf/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/blais-bytebuf/Lib/distutils/command/build_ext.py (original) +++ python/branches/blais-bytebuf/Lib/distutils/command/build_ext.py Wed May 24 20:30:42 2006 @@ -689,6 +689,11 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib, "m"] + extra + + elif sys.platform == 'darwin': + # Don't use the default code below + return ext.libraries + else: from distutils import sysconfig if sysconfig.get_config_var('Py_ENABLE_SHARED'): Modified: python/branches/blais-bytebuf/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/blais-bytebuf/Lib/distutils/sysconfig.py (original) +++ python/branches/blais-bytebuf/Lib/distutils/sysconfig.py Wed May 24 20:30:42 2006 @@ -500,6 +500,21 @@ _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX + if sys.platform == 'darwin': + kernel_version = os.uname()[2] # Kernel version (8.4.3) + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # On Mac OS X before 10.4, check if -arch and -isysroot + # are in CFLAGS or LDFLAGS and remove them if they are. + # This is needed when building extensions on a 10.3 system + # using a universal build of python. + for key in ('LDFLAGS', 'BASECFLAGS'): + flags = _config_vars[key] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = re.sub('-isysroot [^ \t]* ', ' ', flags) + _config_vars[key] = flags + if args: vals = [] for name in args: Modified: python/branches/blais-bytebuf/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/blais-bytebuf/Lib/distutils/unixccompiler.py (original) +++ python/branches/blais-bytebuf/Lib/distutils/unixccompiler.py Wed May 24 20:30:42 2006 @@ -42,6 +42,48 @@ # should just happily stuff them into the preprocessor/compiler/linker # options and carry on. +def _darwin_compiler_fixup(compiler_so, cc_args): + """ + This function will strip '-isysroot PATH' and '-arch ARCH' from the + compile flags if the user has specified one them in extra_compile_flags. + + This is needed because '-arch ARCH' adds another architecture to the + build, without a way to remove an architecture. Furthermore GCC will + barf if multiple '-isysroot' arguments are present. + """ + stripArch = stripSysroot = 0 + + compiler_so = list(compiler_so) + kernel_version = os.uname()[2] # 8.4.3 + major_version = int(kernel_version.split('.')[0]) + + if major_version < 8: + # OSX before 10.4.0, these don't support -arch and -isysroot at + # all. + stripArch = stripSysroot = True + else: + stripArch = '-arch' in cc_args + stripSysroot = '-isysroot' in cc_args + + if stripArch: + while 1: + try: + index = compiler_so.index('-arch') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + if stripSysroot: + try: + index = compiler_so.index('-isysroot') + # Strip this argument and the next one: + del compiler_so[index:index+1] + except ValueError: + pass + + return compiler_so + class UnixCCompiler(CCompiler): compiler_type = 'unix' @@ -108,8 +150,11 @@ raise CompileError, msg def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): + compiler_so = self.compiler_so + if sys.platform == 'darwin': + compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) try: - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + + self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg @@ -172,7 +217,22 @@ else: linker = self.linker_so[:] if target_lang == "c++" and self.compiler_cxx: - linker[0] = self.compiler_cxx[0] + # skip over environment variable settings if /usr/bin/env + # is used to set up the linker's environment. + # This is needed on OSX. Note: this assumes that the + # normal and C++ compiler have the same environment + # settings. + i = 0 + if os.path.basename(linker[0]) == "env": + i = 1 + while '=' in linker[i]: + i = i + 1 + + linker[i] = self.compiler_cxx[i] + + if sys.platform == 'darwin': + linker = _darwin_compiler_fixup(linker, ld_args) + self.spawn(linker + ld_args) except DistutilsExecError, msg: raise LinkError, msg Modified: python/branches/blais-bytebuf/Lib/distutils/util.py ============================================================================== --- python/branches/blais-bytebuf/Lib/distutils/util.py (original) +++ python/branches/blais-bytebuf/Lib/distutils/util.py Wed May 24 20:30:42 2006 @@ -67,6 +67,54 @@ m = rel_re.match(release) if m: release = m.group() + elif osname[:6] == "darwin": + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + from distutils.sysconfig import get_config_vars + cfgvars = get_config_vars() + + macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET') + if not macver: + macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') + + if not macver: + # Get the system version. Reading this plist is a documented + # way to get the system version (see the documentation for + # the Gestalt Manager) + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + m = re.search( + r'ProductUserVisibleVersion\s*' + + r'(.*?)', f.read()) + f.close() + if m is not None: + macver = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + if macver: + from distutils.sysconfig import get_config_vars + release = macver + osname = "macosx" + + + if (release + '.') < '10.4.' and \ + get_config_vars().get('UNIVERSALSDK', '').strip(): + # The universal build will build fat binaries, but not on + # systems before 10.4 + machine = 'fat' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + machine = 'ppc' return "%s-%s-%s" % (osname, release, machine) Modified: python/branches/blais-bytebuf/Lib/test/regrtest.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/regrtest.py (original) +++ python/branches/blais-bytebuf/Lib/test/regrtest.py Wed May 24 20:30:42 2006 @@ -545,6 +545,7 @@ def cleanup(): import _strptime, linecache, warnings, dircache import urlparse, urllib, urllib2, mimetypes, doctest + import struct from distutils.dir_util import _path_created _path_created.clear() warnings.filters[:] = fs @@ -561,6 +562,7 @@ dircache.reset() linecache.clearcache() mimetypes._default_mime_types() + struct._cache.clear() doctest.master = None if indirect_test: def run_the_test(): Modified: python/branches/blais-bytebuf/Lib/test/test_builtin.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_builtin.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_builtin.py Wed May 24 20:30:42 2006 @@ -709,6 +709,84 @@ self.assertEqual(int('0123', 0), 83) self.assertEqual(int('0x123', 16), 291) + # SF bug 1334662: int(string, base) wrong answers + # Various representations of 2**32 evaluated to 0 + # rather than 2**32 in previous versions + + self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296L) + self.assertEqual(int('102002022201221111211', 3), 4294967296L) + self.assertEqual(int('10000000000000000', 4), 4294967296L) + self.assertEqual(int('32244002423141', 5), 4294967296L) + self.assertEqual(int('1550104015504', 6), 4294967296L) + self.assertEqual(int('211301422354', 7), 4294967296L) + self.assertEqual(int('40000000000', 8), 4294967296L) + self.assertEqual(int('12068657454', 9), 4294967296L) + self.assertEqual(int('4294967296', 10), 4294967296L) + self.assertEqual(int('1904440554', 11), 4294967296L) + self.assertEqual(int('9ba461594', 12), 4294967296L) + self.assertEqual(int('535a79889', 13), 4294967296L) + self.assertEqual(int('2ca5b7464', 14), 4294967296L) + self.assertEqual(int('1a20dcd81', 15), 4294967296L) + self.assertEqual(int('100000000', 16), 4294967296L) + self.assertEqual(int('a7ffda91', 17), 4294967296L) + self.assertEqual(int('704he7g4', 18), 4294967296L) + self.assertEqual(int('4f5aff66', 19), 4294967296L) + self.assertEqual(int('3723ai4g', 20), 4294967296L) + self.assertEqual(int('281d55i4', 21), 4294967296L) + self.assertEqual(int('1fj8b184', 22), 4294967296L) + self.assertEqual(int('1606k7ic', 23), 4294967296L) + self.assertEqual(int('mb994ag', 24), 4294967296L) + self.assertEqual(int('hek2mgl', 25), 4294967296L) + self.assertEqual(int('dnchbnm', 26), 4294967296L) + self.assertEqual(int('b28jpdm', 27), 4294967296L) + self.assertEqual(int('8pfgih4', 28), 4294967296L) + self.assertEqual(int('76beigg', 29), 4294967296L) + self.assertEqual(int('5qmcpqg', 30), 4294967296L) + self.assertEqual(int('4q0jto4', 31), 4294967296L) + self.assertEqual(int('4000000', 32), 4294967296L) + self.assertEqual(int('3aokq94', 33), 4294967296L) + self.assertEqual(int('2qhxjli', 34), 4294967296L) + self.assertEqual(int('2br45qb', 35), 4294967296L) + self.assertEqual(int('1z141z4', 36), 4294967296L) + + # SF bug 1334662: int(string, base) wrong answers + # Checks for proper evaluation of 2**32 + 1 + self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297L) + self.assertEqual(int('102002022201221111212', 3), 4294967297L) + self.assertEqual(int('10000000000000001', 4), 4294967297L) + self.assertEqual(int('32244002423142', 5), 4294967297L) + self.assertEqual(int('1550104015505', 6), 4294967297L) + self.assertEqual(int('211301422355', 7), 4294967297L) + self.assertEqual(int('40000000001', 8), 4294967297L) + self.assertEqual(int('12068657455', 9), 4294967297L) + self.assertEqual(int('4294967297', 10), 4294967297L) + self.assertEqual(int('1904440555', 11), 4294967297L) + self.assertEqual(int('9ba461595', 12), 4294967297L) + self.assertEqual(int('535a7988a', 13), 4294967297L) + self.assertEqual(int('2ca5b7465', 14), 4294967297L) + self.assertEqual(int('1a20dcd82', 15), 4294967297L) + self.assertEqual(int('100000001', 16), 4294967297L) + self.assertEqual(int('a7ffda92', 17), 4294967297L) + self.assertEqual(int('704he7g5', 18), 4294967297L) + self.assertEqual(int('4f5aff67', 19), 4294967297L) + self.assertEqual(int('3723ai4h', 20), 4294967297L) + self.assertEqual(int('281d55i5', 21), 4294967297L) + self.assertEqual(int('1fj8b185', 22), 4294967297L) + self.assertEqual(int('1606k7id', 23), 4294967297L) + self.assertEqual(int('mb994ah', 24), 4294967297L) + self.assertEqual(int('hek2mgm', 25), 4294967297L) + self.assertEqual(int('dnchbnn', 26), 4294967297L) + self.assertEqual(int('b28jpdn', 27), 4294967297L) + self.assertEqual(int('8pfgih5', 28), 4294967297L) + self.assertEqual(int('76beigh', 29), 4294967297L) + self.assertEqual(int('5qmcpqh', 30), 4294967297L) + self.assertEqual(int('4q0jto5', 31), 4294967297L) + self.assertEqual(int('4000001', 32), 4294967297L) + self.assertEqual(int('3aokq95', 33), 4294967297L) + self.assertEqual(int('2qhxjlj', 34), 4294967297L) + self.assertEqual(int('2br45qc', 35), 4294967297L) + self.assertEqual(int('1z141z5', 36), 4294967297L) + def test_intconversion(self): # Test __int__() class Foo0: Modified: python/branches/blais-bytebuf/Lib/test/test_struct.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_struct.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_struct.py Wed May 24 20:30:42 2006 @@ -437,3 +437,44 @@ TestFailed("expected OverflowError") test_705836() + +def test_unpack_from(): + test_string = 'abcd01234' + fmt = '4s' + s = struct.Struct(fmt) + for cls in (str, buffer): + data = cls(test_string) + assert s.unpack_from(data) == ('abcd',) + assert s.unpack_from(data, 2) == ('cd01',) + assert s.unpack_from(data, 4) == ('0123',) + for i in xrange(6): + assert s.unpack_from(data, i) == (data[i:i+4],) + for i in xrange(6, len(test_string) + 1): + simple_err(s.unpack_from, data, i) + for cls in (str, buffer): + data = cls(test_string) + assert struct.unpack_from(fmt, data) == ('abcd',) + assert struct.unpack_from(fmt, data, 2) == ('cd01',) + assert struct.unpack_from(fmt, data, 4) == ('0123',) + for i in xrange(6): + assert struct.unpack_from(fmt, data, i) == (data[i:i+4],) + for i in xrange(6, len(test_string) + 1): + simple_err(struct.unpack_from, fmt, data, i) + +test_unpack_from() + +def test_1229380(): + for endian in ('', '>', '<'): + for cls in (int, long): + for fmt in ('B', 'H', 'I', 'L'): + any_err(struct.pack, endian + fmt, cls(-1)) + + any_err(struct.pack, endian + 'B', cls(300)) + any_err(struct.pack, endian + 'H', cls(70000)) + + any_err(struct.pack, endian + 'I', sys.maxint * 4L) + any_err(struct.pack, endian + 'L', sys.maxint * 4L) + +if 0: + # TODO: bug #1229380 + test_1229380() Modified: python/branches/blais-bytebuf/Mac/OSX/Makefile.in ============================================================================== --- python/branches/blais-bytebuf/Mac/OSX/Makefile.in (original) +++ python/branches/blais-bytebuf/Mac/OSX/Makefile.in Wed May 24 20:30:42 2006 @@ -73,11 +73,16 @@ install_versionedtools: for fn in idle pydoc python-config ;\ do \ + if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \ + continue ;\ + fi ;\ mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\ done - mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" - ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" + if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \ + mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\ + ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\ + fi pythonw: $(srcdir)/Tools/pythonw.c Modified: python/branches/blais-bytebuf/Misc/ACKS ============================================================================== --- python/branches/blais-bytebuf/Misc/ACKS (original) +++ python/branches/blais-bytebuf/Misc/ACKS Wed May 24 20:30:42 2006 @@ -390,6 +390,7 @@ Mark Lutz Jim Lynch Mikael Lyngvig +Alan McIntyre Andrew I MacIntyre Tim MacKenzie Nick Maclaren Modified: python/branches/blais-bytebuf/Misc/NEWS ============================================================================== --- python/branches/blais-bytebuf/Misc/NEWS (original) +++ python/branches/blais-bytebuf/Misc/NEWS Wed May 24 20:30:42 2006 @@ -12,6 +12,19 @@ Core and builtins ----------------- +- Bug #1334662: ``int(string, base)`` could deliver a wrong answer + when ``base`` was not 2, 4, 8, 10, 16 or 32, and ``string`` represented + an integer close to ``sys.maxint``. This was repaired by patch + #1335972, which also gives a nice speedup. + +- Patch #1337051: reduced size of frame objects. + +- PyErr_NewException now accepts a tuple of base classes as its + "base" parameter. + +- Patch #876206: function call speedup by retaining allocated frame + objects. + - Bug #1462152: file() now checks more thoroughly for invalid mode strings and removes a possible "U" before passing the mode to the C library function. @@ -32,6 +45,8 @@ Extension Modules ----------------- +- Patch #1493701: performance enhancements for struct module. + - Patch #1490224: time.altzone is now set correctly on Cygwin. - Patch #1435422: zlib's compress and decompress objects now have a @@ -49,6 +64,8 @@ Library ------- +- Patch #1281707: speed up gzip.readline. + - Patch #1180296: Two new functions were added to the locale module: format_string() to get the effect of "format % items" but locale-aware, and currency() to format a monetary number with currency sign. Modified: python/branches/blais-bytebuf/Modules/Setup.dist ============================================================================== --- python/branches/blais-bytebuf/Modules/Setup.dist (original) +++ python/branches/blais-bytebuf/Modules/Setup.dist Wed May 24 20:30:42 2006 @@ -167,7 +167,7 @@ #array arraymodule.c # array objects #cmath cmathmodule.c # -lm # complex math library functions #math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking +#_struct _struct.c # binary structure packing/unpacking #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support Deleted: /python/branches/blais-bytebuf/Modules/structmodule.c ============================================================================== --- /python/branches/blais-bytebuf/Modules/structmodule.c Wed May 24 20:30:42 2006 +++ (empty file) @@ -1,1293 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include - -PyDoc_STRVAR(struct__doc__, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ -\n\ -The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ -\n\ -The remaining chars indicate types of args and must match exactly;\n\ -these can be preceded by a decimal repeat count:\n\ - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ - h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double.\n\ -Special cases (preceding decimal count indicates length):\n\ - s:string (array of char); p: pascal string (with count byte).\n\ -Special case (only available in native format):\n\ - P:an integer type that is wide enough to hold a pointer.\n\ -Special case (not in native mode unless 'long long' in platform C):\n\ - q:long long; Q:unsigned long long\n\ -Whitespace between formats is ignored.\n\ -\n\ -The variable struct.error is an exception raised on errors."); - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsVoidPtr(v); - Py_DECREF(v); - if (x == NULL && PyErr_Occurred()) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -calcsize(const char *fmt, const formatdef *f) -{ - const formatdef *e; - const char *s; - char c; - int size, num, itemsize, x; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - return size; -} - - -PyDoc_STRVAR(calcsize__doc__, -"calcsize(fmt) -> int\n\ -Return size of C struct described by format string fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_calcsize(PyObject *self, PyObject *args) -{ - char *fmt; - const formatdef *f; - int size; - - if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(pack__doc__, -"pack(fmt, v1, v2, ...) -> string\n\ -Return string containing values v1, v2, ... packed according to fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_pack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - PyObject *format, *result, *v; - char *fmt; - int size, num; - Py_ssize_t i, n; - char *s, *res, *restart, *nres; - char c; - - if (args == NULL || !PyTuple_Check(args) || - (n = PyTuple_Size(args)) < 1) - { - PyErr_SetString(PyExc_TypeError, - "struct.pack requires at least one argument"); - return NULL; - } - format = PyTuple_GetItem(args, 0); - fmt = PyString_AsString(format); - if (!fmt) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - result = PyString_FromStringAndSize((char *)NULL, size); - if (result == NULL) - return NULL; - - s = fmt; - i = 1; - res = restart = PyString_AsString(result); - - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - nres = restart + align((int)(res-restart), c, e); - /* Fill padd bytes with zeros */ - while (res < nres) - *res++ = '\0'; - if (num == 0 && c != 's') - continue; - do { - if (c == 'x') { - /* doesn't consume arguments */ - memset(res, '\0', num); - res += num; - break; - } - if (i >= n) { - PyErr_SetString(StructError, - "insufficient arguments to pack"); - goto fail; - } - v = PyTuple_GetItem(args, i++); - if (v == NULL) - goto fail; - if (c == 's') { - /* num is string size, not repeat count */ - Py_ssize_t n; - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res, PyString_AsString(v), n); - if (n < num) - memset(res+n, '\0', num-n); - res += num; - break; - } - else if (c == 'p') { - /* num is string size + 1, - to fit in the count byte */ - Py_ssize_t n; - num--; /* now num is max string size */ - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res+1, PyString_AsString(v), n); - if (n < num) - /* no real need, just to be nice */ - memset(res+1+n, '\0', num-n); - if (n > 255) - n = 255; - /* store the length byte */ - *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); - res += num; - break; - } - else { - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } while (--num > 0); - } - - if (i < n) { - PyErr_SetString(StructError, - "too many arguments for pack format"); - goto fail; - } - - return result; - - fail: - Py_DECREF(result); - return NULL; -} - - -PyDoc_STRVAR(unpack__doc__, -"unpack(fmt, string) -> (v1, v2, ...)\n\ -Unpack the string, containing packed C structure data, according\n\ -to fmt. Requires len(string)==calcsize(fmt).\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_unpack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - char *str, *start, *fmt, *s; - char c; - int len, size, num; - PyObject *res, *v; - - if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - if (size != len) { - PyErr_SetString(StructError, - "unpack str size does not match format"); - return NULL; - } - res = PyList_New(0); - if (res == NULL) - return NULL; - str = start; - s = fmt; - while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - str = start + align((int)(str-start), c, e); - if (num == 0 && c != 's') - continue; - - do { - if (c == 'x') { - str += num; - break; - } - if (c == 's') { - /* num is string size, not repeat count */ - v = PyString_FromStringAndSize(str, num); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else if (c == 'p') { - /* num is string buffer size, - not repeat count */ - int n = *(unsigned char*)str; - /* first byte (unsigned) is string size */ - if (n >= num) - n = num-1; - v = PyString_FromStringAndSize(str+1, n); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else { - v = e->unpack(str, e); - if (v == NULL) - goto fail; - str += e->size; - } - if (v == NULL || PyList_Append(res, v) < 0) - goto fail; - Py_DECREF(v); - } while (--num > 0); - } - - v = PyList_AsTuple(res); - Py_DECREF(res); - return v; - - fail: - Py_DECREF(res); - return NULL; -} - - -/* List of functions */ - -static PyMethodDef struct_methods[] = { - {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, - {"pack", struct_pack, METH_VARARGS, pack__doc__}, - {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initstruct(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule4("struct", struct_methods, struct__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - if (m == NULL) - return; - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); -} Modified: python/branches/blais-bytebuf/Objects/codeobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/codeobject.c (original) +++ python/branches/blais-bytebuf/Objects/codeobject.c Wed May 24 20:30:42 2006 @@ -102,6 +102,7 @@ co->co_firstlineno = firstlineno; Py_INCREF(lnotab); co->co_lnotab = lnotab; + co->co_zombieframe = NULL; } return co; } @@ -265,6 +266,8 @@ Py_XDECREF(co->co_filename); Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); + if (co->co_zombieframe != NULL) + PyObject_GC_Del(co->co_zombieframe); PyObject_DEL(co); } Modified: python/branches/blais-bytebuf/Objects/frameobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/frameobject.c (original) +++ python/branches/blais-bytebuf/Objects/frameobject.c Wed May 24 20:30:42 2006 @@ -350,13 +350,32 @@ }; /* Stack frames are allocated and deallocated at a considerable rate. - In an attempt to improve the speed of function calls, we maintain a - separate free list of stack frames (just like integers are - allocated in a special way -- see intobject.c). When a stack frame - is on the free list, only the following members have a meaning: + In an attempt to improve the speed of function calls, we: + + 1. Hold a single "zombie" frame on each code object. This retains + the allocated and initialised frame object from an invocation of + the code object. The zombie is reanimated the next time we need a + frame object for that code object. Doing this saves the malloc/ + realloc required when using a free_list frame that isn't the + correct size. It also saves some field initialisation. + + In zombie mode, no field of PyFrameObject holds a reference, but + the following fields are still valid: + + * ob_type, ob_size, f_code, f_valuestack; + + * f_locals, f_trace, + f_exc_type, f_exc_value, f_exc_traceback are NULL; + + * f_localsplus does not require re-allocation and + the local variables in f_localsplus are NULL. + + 2. We also maintain a separate free list of stack frames (just like + integers are allocated in a special way -- see intobject.c). When + a stack frame is on the free list, only the following members have + a meaning: ob_type == &Frametype f_back next item on free list, or NULL - f_nlocals number of locals f_stacksize size of value stack ob_size size of localsplus Note that the value and block stacks are preserved -- this can save @@ -380,41 +399,43 @@ static void frame_dealloc(PyFrameObject *f) { - int i, slots; - PyObject **fastlocals; - PyObject **p; + PyObject **p, **valuestack; + PyCodeObject *co; PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - Py_XDECREF(*fastlocals); - } + valuestack = f->f_valuestack; + for (p = f->f_localsplus; p < valuestack; p++) + Py_CLEAR(*p); /* Free stack */ if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) + for (p = valuestack; p < f->f_stacktop; p++) Py_XDECREF(*p); } Py_XDECREF(f->f_back); - Py_DECREF(f->f_code); Py_DECREF(f->f_builtins); Py_DECREF(f->f_globals); - Py_XDECREF(f->f_locals); - Py_XDECREF(f->f_trace); - Py_XDECREF(f->f_exc_type); - Py_XDECREF(f->f_exc_value); - Py_XDECREF(f->f_exc_traceback); - if (numfree < MAXFREELIST) { + Py_CLEAR(f->f_locals); + Py_CLEAR(f->f_trace); + Py_CLEAR(f->f_exc_type); + Py_CLEAR(f->f_exc_value); + Py_CLEAR(f->f_exc_traceback); + + co = f->f_code; + if (co != NULL && co->co_zombieframe == NULL) + co->co_zombieframe = f; + else if (numfree < MAXFREELIST) { ++numfree; f->f_back = free_list; free_list = f; - } - else + } + else PyObject_GC_Del(f); + + Py_XDECREF(co); Py_TRASHCAN_SAFE_END(f) } @@ -435,7 +456,7 @@ Py_VISIT(f->f_exc_traceback); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_VISIT(*fastlocals); @@ -468,7 +489,7 @@ Py_CLEAR(f->f_trace); /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; + slots = f->f_code->co_nlocals + PyTuple_GET_SIZE(f->f_code->co_cellvars) + PyTuple_GET_SIZE(f->f_code->co_freevars); fastlocals = f->f_localsplus; for (i = slots; --i >= 0; ++fastlocals) Py_CLEAR(*fastlocals); @@ -532,7 +553,7 @@ PyFrameObject *back = tstate->frame; PyFrameObject *f; PyObject *builtins; - Py_ssize_t extras, ncells, nfrees, i; + Py_ssize_t i; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || @@ -541,9 +562,6 @@ return NULL; } #endif - ncells = PyTuple_GET_SIZE(code->co_cellvars); - nfrees = PyTuple_GET_SIZE(code->co_freevars); - extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; if (back == NULL || back->f_globals != globals) { builtins = PyDict_GetItem(globals, builtin_object); if (builtins) { @@ -574,71 +592,82 @@ assert(builtins != NULL && PyDict_Check(builtins)); Py_INCREF(builtins); } - if (free_list == NULL) { - f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - else { - assert(numfree > 0); - --numfree; - f = free_list; - free_list = free_list->f_back; - if (f->ob_size < extras) { - f = PyObject_GC_Resize(PyFrameObject, f, extras); - if (f == NULL) { - Py_DECREF(builtins); - return NULL; - } - } - _Py_NewReference((PyObject *)f); + if (code->co_zombieframe != NULL) { + f = code->co_zombieframe; + code->co_zombieframe = NULL; + _Py_NewReference((PyObject *)f); + assert(f->f_code == code); + } + else { + Py_ssize_t extras, ncells, nfrees; + ncells = PyTuple_GET_SIZE(code->co_cellvars); + nfrees = PyTuple_GET_SIZE(code->co_freevars); + extras = code->co_stacksize + code->co_nlocals + ncells + + nfrees; + if (free_list == NULL) { + f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, + extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + else { + assert(numfree > 0); + --numfree; + f = free_list; + free_list = free_list->f_back; + if (f->ob_size < extras) { + f = PyObject_GC_Resize(PyFrameObject, f, extras); + if (f == NULL) { + Py_DECREF(builtins); + return NULL; + } + } + _Py_NewReference((PyObject *)f); + } + + f->f_code = code; + extras = code->co_nlocals + ncells + nfrees; + f->f_valuestack = f->f_localsplus + extras; + for (i=0; if_localsplus[i] = NULL; + f->f_locals = NULL; + f->f_trace = NULL; + f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; } f->f_builtins = builtins; Py_XINCREF(back); f->f_back = back; Py_INCREF(code); - f->f_code = code; Py_INCREF(globals); f->f_globals = globals; /* Most functions have CO_NEWLOCALS and CO_OPTIMIZED set. */ if ((code->co_flags & (CO_NEWLOCALS | CO_OPTIMIZED)) == (CO_NEWLOCALS | CO_OPTIMIZED)) - locals = NULL; /* PyFrame_FastToLocals() will set. */ + ; /* f_locals = NULL; will be set by PyFrame_FastToLocals() */ else if (code->co_flags & CO_NEWLOCALS) { locals = PyDict_New(); if (locals == NULL) { Py_DECREF(f); return NULL; } + f->f_locals = locals; } else { if (locals == NULL) locals = globals; Py_INCREF(locals); + f->f_locals = locals; } - f->f_locals = locals; - f->f_trace = NULL; - f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; f->f_tstate = tstate; f->f_lasti = -1; f->f_lineno = code->co_firstlineno; f->f_restricted = (builtins != tstate->interp->builtins); f->f_iblock = 0; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - - extras = f->f_nlocals + ncells + nfrees; - /* Tim said it's ok to replace memset */ - for (i=0; if_localsplus[i] = NULL; - f->f_valuestack = f->f_localsplus + extras; - f->f_stacktop = f->f_valuestack; + f->f_stacktop = f->f_valuestack; _PyObject_GC_TRACK(f); return f; } @@ -725,7 +754,9 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; @@ -736,27 +767,24 @@ return; } } - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) map_to_dict(map, j, locals, fast, 0); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) { - return; - } - map_to_dict(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1); - map_to_dict(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + map_to_dict(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1); + map_to_dict(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1); } PyErr_Restore(error_type, error_value, error_traceback); } @@ -768,11 +796,14 @@ PyObject *locals, *map; PyObject **fast; PyObject *error_type, *error_value, *error_traceback; + PyCodeObject *co; Py_ssize_t j; + int ncells, nfreevars; if (f == NULL) return; locals = f->f_locals; - map = f->f_code->co_varnames; + co = f->f_code; + map = co->co_varnames; if (locals == NULL) return; if (!PyTuple_Check(map)) @@ -780,21 +811,18 @@ PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; j = PyTuple_GET_SIZE(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) - dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) - return; - dict_to_map(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1, clear); - dict_to_map(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1, - clear); + if (j > co->co_nlocals) + j = co->co_nlocals; + if (co->co_nlocals) + dict_to_map(co->co_varnames, j, locals, fast, 0, clear); + ncells = PyTuple_GET_SIZE(co->co_cellvars); + nfreevars = PyTuple_GET_SIZE(co->co_freevars); + if (ncells || nfreevars) { + dict_to_map(co->co_cellvars, ncells, + locals, fast + co->co_nlocals, 1, clear); + dict_to_map(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1, + clear); } PyErr_Restore(error_type, error_value, error_traceback); } Modified: python/branches/blais-bytebuf/Objects/unicodeobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/unicodeobject.c (original) +++ python/branches/blais-bytebuf/Objects/unicodeobject.c Wed May 24 20:30:42 2006 @@ -46,6 +46,18 @@ #include #endif +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) /* this is taken from _sre.c */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define LOCAL(type) static inline type +#else +#define LOCAL(type) static type +#endif + /* Limit for the Unicode object free list */ #define MAX_UNICODE_FREELIST_SIZE 1024 @@ -121,6 +133,51 @@ #endif } +/* --- Bloom Filters ----------------------------------------------------- */ + +/* stuff to implement simple "bloom filters" for Unicode characters. + to keep things simple, we use a single bitmask, using the least 5 + bits from each unicode characters as the bit index. */ + +/* the linebreak mask is set up by Unicode_Init below */ + +#define BLOOM_MASK unsigned long + +static BLOOM_MASK bloom_linebreak; + +#define BLOOM(mask, ch) ((mask & (1 << ((ch) & 0x1F)))) + +#define BLOOM_LINEBREAK(ch)\ + (BLOOM(bloom_linebreak, (ch)) && Py_UNICODE_ISLINEBREAK((ch))) + +LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) +{ + /* calculate simple bloom-style bitmask for a given unicode string */ + + long mask; + Py_ssize_t i; + + mask = 0; + for (i = 0; i < len; i++) + mask |= (1 << (ptr[i] & 0x1F)); + + return mask; +} + +LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) +{ + Py_ssize_t i; + + for (i = 0; i < setlen; i++) + if (set[i] == chr) + return 1; + + return 0; +} + +#define BLOOM_MEMBER(mask, chr, set, setlen)\ + BLOOM(mask, chr) && unicode_member(chr, set, setlen) + /* --- Unicode Object ----------------------------------------------------- */ static @@ -1963,9 +2020,20 @@ */ -static const Py_UNICODE *findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch); +LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, + Py_ssize_t size, + Py_UNICODE ch) +{ + /* like wcschr, but doesn't stop at NULL characters */ + + while (size-- > 0) { + if (*s == ch) + return s; + s++; + } + + return NULL; +} static PyObject *unicodeescape_string(const Py_UNICODE *s, @@ -3791,8 +3859,98 @@ /* --- Helpers ------------------------------------------------------------ */ -static -Py_ssize_t count(PyUnicodeObject *self, +#define USE_FAST /* experimental fast search implementation */ + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types. also, the count mode returns -1 if + there cannot possible be a match in the target string, and 0 if it + has actually checked for matches. */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +LOCAL(Py_ssize_t) +fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) +{ + long mask; + int skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m <= 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else { + i = i + skip; + continue; + } + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +LOCAL(Py_ssize_t) count(PyUnicodeObject *self, Py_ssize_t start, Py_ssize_t end, PyUnicodeObject *substring) @@ -3813,6 +3971,14 @@ if (substring->length == 0) return (end - start + 1); +#ifdef USE_FAST + count = fastsearch( + PyUnicode_AS_UNICODE(self) + start, end - start, + substring->str, substring->length, FAST_COUNT + ); + if (count < 0) + count = 0; /* no match */ +#else end -= substring->length; while (start <= end) @@ -3821,6 +3987,7 @@ start += substring->length; } else start++; +#endif return count; } @@ -3850,8 +4017,7 @@ return result; } -static -Py_ssize_t findstring(PyUnicodeObject *self, +static Py_ssize_t findstring(PyUnicodeObject *self, PyUnicodeObject *substring, Py_ssize_t start, Py_ssize_t end, @@ -3872,6 +4038,18 @@ if (substring->length == 0) return (direction > 0) ? start : end; +#ifdef USE_FAST + if (direction > 0) { + Py_ssize_t pos = fastsearch( + PyUnicode_AS_UNICODE(self) + start, end - start, + substring->str, substring->length, FAST_SEARCH + ); + if (pos < 0) + return pos; + return pos + start; + } +#endif + end -= substring->length; if (direction < 0) { @@ -3974,22 +4152,6 @@ return result; } -static -const Py_UNICODE *findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch) -{ - /* like wcschr, but doesn't stop at NULL characters */ - - while (size-- > 0) { - if (*s == ch) - return s; - s++; - } - - return NULL; -} - /* Apply fixfct filter to the Unicode object self and return a reference to the modified object */ @@ -4332,17 +4494,6 @@ else \ Py_DECREF(str); -#define SPLIT_INSERT(data, left, right) \ - str = PyUnicode_FromUnicode((data) + (left), (right) - (left)); \ - if (!str) \ - goto onError; \ - if (PyList_Insert(list, 0, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - static PyObject *split_whitespace(PyUnicodeObject *self, PyObject *list, @@ -4403,7 +4554,7 @@ Py_ssize_t eol; /* Find a line and append it */ - while (i < len && !Py_UNICODE_ISLINEBREAK(data[i])) + while (i < len && !BLOOM_LINEBREAK(data[i])) i++; /* Skip the line break reading CRLF as one line break */ @@ -4514,15 +4665,17 @@ if (j > i) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + 1, j + 1); + SPLIT_APPEND(self->str, i + 1, j + 1); while (i >= 0 && Py_UNICODE_ISSPACE(self->str[i])) i--; j = i; } } if (j >= 0) { - SPLIT_INSERT(self->str, 0, j + 1); + SPLIT_APPEND(self->str, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4545,14 +4698,16 @@ if (self->str[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + 1, j + 1); + SPLIT_APPEND(self->str, i + 1, j + 1); j = i = i - 1; } else i--; } if (j >= -1) { - SPLIT_INSERT(self->str, 0, j + 1); + SPLIT_APPEND(self->str, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4576,15 +4731,17 @@ if (Py_UNICODE_MATCH(self, i, substring)) { if (maxcount-- <= 0) break; - SPLIT_INSERT(self->str, i + sublen, j); + SPLIT_APPEND(self->str, i + sublen, j); j = i; i -= sublen; } else i--; } if (j >= 0) { - SPLIT_INSERT(self->str, 0, j); + SPLIT_APPEND(self->str, 0, j); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -4593,7 +4750,6 @@ } #undef SPLIT_APPEND -#undef SPLIT_INSERT static PyObject *split(PyUnicodeObject *self, @@ -4664,36 +4820,47 @@ if (maxcount < 0) maxcount = PY_SSIZE_T_MAX; - if (str1->length == 1 && str2->length == 1) { + if (str1->length == str2->length) { + /* same length */ Py_ssize_t i; - - /* replace characters */ - if (!findchar(self->str, self->length, str1->str[0]) && - PyUnicode_CheckExact(self)) { - /* nothing to replace, return original string */ - Py_INCREF(self); - u = self; + if (str1->length == 1) { + /* replace characters */ + Py_UNICODE u1, u2; + if (!findchar(self->str, self->length, str1->str[0])) + goto nothing; + u = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, self->length); + if (!u) + return NULL; + Py_UNICODE_COPY(u->str, self->str, self->length); + u1 = str1->str[0]; + u2 = str2->str[0]; + for (i = 0; i < u->length; i++) + if (u->str[i] == u1) { + if (--maxcount < 0) + break; + u->str[i] = u2; + } } else { - Py_UNICODE u1 = str1->str[0]; - Py_UNICODE u2 = str2->str[0]; - - u = (PyUnicodeObject*) PyUnicode_FromUnicode( - NULL, - self->length + i = fastsearch( + self->str, self->length, str1->str, str1->length, FAST_SEARCH ); - if (u != NULL) { - Py_UNICODE_COPY(u->str, self->str, - self->length); - for (i = 0; i < u->length; i++) - if (u->str[i] == u1) { - if (--maxcount < 0) - break; - u->str[i] = u2; - } + if (i < 0) + goto nothing; + u = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, self->length); + if (!u) + return NULL; + Py_UNICODE_COPY(u->str, self->str, self->length); + while (i <= self->length - str1->length) + if (Py_UNICODE_MATCH(self, i, str1)) { + if (--maxcount < 0) + break; + Py_UNICODE_COPY(u->str+i, str2->str, str2->length); + i += str1->length; + } else + i++; } - } - } else { + Py_ssize_t n, i; Py_UNICODE *p; @@ -4701,51 +4868,47 @@ n = count(self, 0, self->length, str1); if (n > maxcount) n = maxcount; - if (n == 0) { - /* nothing to replace, return original string */ - if (PyUnicode_CheckExact(self)) { - Py_INCREF(self); - u = self; - } - else { - u = (PyUnicodeObject *) - PyUnicode_FromUnicode(self->str, self->length); - } - } else { - u = _PyUnicode_New( - self->length + n * (str2->length - str1->length)); - if (u) { - i = 0; - p = u->str; - if (str1->length > 0) { - while (i <= self->length - str1->length) - if (Py_UNICODE_MATCH(self, i, str1)) { - /* replace string segment */ - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - i += str1->length; - if (--n <= 0) { - /* copy remaining part */ - Py_UNICODE_COPY(p, self->str+i, self->length-i); - break; - } - } else - *p++ = self->str[i++]; - } else { - while (n > 0) { - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - if (--n <= 0) - break; - *p++ = self->str[i++]; + if (n == 0) + goto nothing; + u = _PyUnicode_New(self->length + n * (str2->length - str1->length)); + if (!u) + return NULL; + i = 0; + p = u->str; + if (str1->length > 0) { + while (i <= self->length - str1->length) + if (Py_UNICODE_MATCH(self, i, str1)) { + /* replace string segment */ + Py_UNICODE_COPY(p, str2->str, str2->length); + p += str2->length; + i += str1->length; + if (--n <= 0) { + /* copy remaining part */ + Py_UNICODE_COPY(p, self->str+i, self->length-i); + break; } - Py_UNICODE_COPY(p, self->str+i, self->length-i); - } + } else + *p++ = self->str[i++]; + } else { + while (n > 0) { + Py_UNICODE_COPY(p, str2->str, str2->length); + p += str2->length; + if (--n <= 0) + break; + *p++ = self->str[i++]; } + Py_UNICODE_COPY(p, self->str+i, self->length-i); } } - return (PyObject *) u; + +nothing: + /* nothing to replace; return original string (when possible) */ + if (PyUnicode_CheckExact(self)) { + Py_INCREF(self); + return (PyObject *) self; + } + return PyUnicode_FromUnicode(self->str, self->length); } /* --- Unicode Object Methods --------------------------------------------- */ @@ -4982,54 +5145,67 @@ int PyUnicode_Contains(PyObject *container, PyObject *element) { - PyUnicodeObject *u = NULL, *v = NULL; + PyUnicodeObject *u, *v; int result; Py_ssize_t size; - register const Py_UNICODE *lhs, *end, *rhs; +#ifdef USE_FAST + Py_ssize_t pos; +#endif /* Coerce the two arguments */ - v = (PyUnicodeObject *)PyUnicode_FromObject(element); - if (v == NULL) { + v = (PyUnicodeObject *) PyUnicode_FromObject(element); + if (!v) { PyErr_SetString(PyExc_TypeError, "'in ' requires string as left operand"); - goto onError; + return -1; + } + + u = (PyUnicodeObject *) PyUnicode_FromObject(container); + if (!u) { + Py_DECREF(v); + return -1; } - u = (PyUnicodeObject *)PyUnicode_FromObject(container); - if (u == NULL) - goto onError; size = PyUnicode_GET_SIZE(v); - rhs = PyUnicode_AS_UNICODE(v); - lhs = PyUnicode_AS_UNICODE(u); + if (!size) { + result = 1; + goto done; + } +#ifdef USE_FAST + pos = fastsearch( + PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), + PyUnicode_AS_UNICODE(v), size, FAST_SEARCH + ); + result = (pos != -1); +#else result = 0; + if (size == 1) { - end = lhs + PyUnicode_GET_SIZE(u); - while (lhs < end) { - if (*lhs++ == *rhs) { - result = 1; - break; - } - } - } - else { - end = lhs + (PyUnicode_GET_SIZE(u) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size * sizeof(Py_UNICODE)) == 0) { + Py_UNICODE chr = PyUnicode_AS_UNICODE(v)[0]; + Py_UNICODE* ptr = PyUnicode_AS_UNICODE(u); + Py_UNICODE* end = ptr + PyUnicode_GET_SIZE(u); + for (; ptr < end; ptr++) { + if (*ptr == chr) { result = 1; break; } } + } else { + Py_ssize_t start = 0; + Py_ssize_t end = PyUnicode_GET_SIZE(u) - size; + for (; start <= end; start++) + if (Py_UNICODE_MATCH(u, start, v)) { + result = 1; + break; + } } +#endif +done: Py_DECREF(u); Py_DECREF(v); return result; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return -1; } /* Concat to string or Unicode object giving a new Unicode object. */ @@ -5701,16 +5877,6 @@ #define STRIPNAME(i) (stripformat[i]+3) -static const Py_UNICODE * -unicode_memchr(const Py_UNICODE *s, Py_UNICODE c, size_t n) -{ - size_t i; - for (i = 0; i < n; ++i) - if (s[i] == c) - return s+i; - return NULL; -} - /* externally visible for str.strip(unicode) */ PyObject * _PyUnicode_XStrip(PyUnicodeObject *self, int striptype, PyObject *sepobj) @@ -5721,27 +5887,29 @@ Py_ssize_t seplen = PyUnicode_GET_SIZE(sepobj); Py_ssize_t i, j; + BLOOM_MASK sepmask = make_bloom_mask(sep, seplen); + i = 0; if (striptype != RIGHTSTRIP) { - while (i < len && unicode_memchr(sep, s[i], seplen)) { - i++; - } + while (i < len && BLOOM_MEMBER(sepmask, s[i], sep, seplen)) { + i++; + } } j = len; if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && unicode_memchr(sep, s[j], seplen)); - j++; + do { + j--; + } while (j >= i && BLOOM_MEMBER(sepmask, s[j], sep, seplen)); + j++; } if (i == 0 && j == len && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; + Py_INCREF(self); + return (PyObject*)self; } else - return PyUnicode_FromUnicode(s+i, j-i); + return PyUnicode_FromUnicode(s+i, j-i); } @@ -7385,6 +7553,18 @@ { int i; + /* XXX - move this array to unicodectype.c ? */ + Py_UNICODE linebreak[] = { + 0x000A, /* LINE FEED */ + 0x000D, /* CARRIAGE RETURN */ + 0x001C, /* FILE SEPARATOR */ + 0x001D, /* GROUP SEPARATOR */ + 0x001E, /* RECORD SEPARATOR */ + 0x0085, /* NEXT LINE */ + 0x2028, /* LINE SEPARATOR */ + 0x2029, /* PARAGRAPH SEPARATOR */ + }; + /* Init the implementation */ unicode_freelist = NULL; unicode_freelist_size = 0; @@ -7394,6 +7574,11 @@ unicode_latin1[i] = NULL; if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); + + /* initialize the linebreak bloom filter */ + bloom_linebreak = make_bloom_mask( + linebreak, sizeof(linebreak) / sizeof(linebreak[0]) + ); } /* Finalize the Unicode implementation */ Modified: python/branches/blais-bytebuf/PC/config.c ============================================================================== --- python/branches/blais-bytebuf/PC/config.c (original) +++ python/branches/blais-bytebuf/PC/config.c Wed May 24 20:30:42 2006 @@ -28,7 +28,6 @@ extern void init_sha256(void); extern void init_sha512(void); extern void initstrop(void); -extern void initstruct(void); extern void inittime(void); extern void initthread(void); extern void initcStringIO(void); @@ -53,6 +52,7 @@ extern void init_sre(void); extern void initparser(void); extern void init_winreg(void); +extern void init_struct(void); extern void initdatetime(void); extern void initfunctional(void); extern void initzlib(void); @@ -102,7 +102,6 @@ {"_sha256", init_sha256}, {"_sha512", init_sha512}, {"strop", initstrop}, - {"struct", initstruct}, {"time", inittime}, #ifdef WITH_THREAD {"thread", initthread}, @@ -131,6 +130,7 @@ {"_sre", init_sre}, {"parser", initparser}, {"_winreg", init_winreg}, + {"_struct", init_struct}, {"datetime", initdatetime}, {"functional", initfunctional}, Modified: python/branches/blais-bytebuf/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/blais-bytebuf/PCbuild/pythoncore.vcproj (original) +++ python/branches/blais-bytebuf/PCbuild/pythoncore.vcproj Wed May 24 20:30:42 2006 @@ -344,6 +344,9 @@ RelativePath="..\Modules\_bisectmodule.c"> + + - - f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define POP() ((void)(lltrace && prtrace(TOP(), "pop")), BASIC_POP()) #define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ lltrace && prtrace(TOP(), "stackadj")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } + assert(STACK_LEVEL() <= co->co_stacksize); } #define EXT_POP(STACK_POINTER) (lltrace && prtrace(*(STACK_POINTER), "ext_pop"), *--(STACK_POINTER)) #else #define PUSH(v) BASIC_PUSH(v) @@ -729,7 +729,7 @@ names = co->co_names; consts = co->co_consts; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; first_instr = (unsigned char*) PyString_AS_STRING(co->co_code); /* An explanation is in order for the next line. @@ -780,7 +780,7 @@ READ_TIMESTAMP(loop0); #endif assert(stack_pointer >= f->f_valuestack); /* else underflow */ - assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ + assert(STACK_LEVEL() <= co->co_stacksize); /* else overflow */ /* Do periodic things. Doing this every time through the loop would add too much overhead, so we do it @@ -1916,17 +1916,17 @@ /* Don't stomp existing exception */ if (PyErr_Occurred()) break; - if (oparg < f->f_ncells) { - v = PyTuple_GetItem(co->co_cellvars, + if (oparg < PyTuple_GET_SIZE(co->co_cellvars)) { + v = PyTuple_GET_ITEM(co->co_cellvars, oparg); format_exc_check_arg( PyExc_UnboundLocalError, UNBOUNDLOCAL_ERROR_MSG, v); } else { - v = PyTuple_GetItem( + v = PyTuple_GET_ITEM( co->co_freevars, - oparg - f->f_ncells); + oparg - PyTuple_GET_SIZE(co->co_cellvars)); format_exc_check_arg( PyExc_NameError, UNBOUNDFREE_ERROR_MSG, @@ -2610,7 +2610,7 @@ return NULL; fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; + freevars = f->f_localsplus + co->co_nlocals; if (co->co_argcount > 0 || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { @@ -2746,7 +2746,7 @@ } /* Allocate and initialize storage for cell vars, and copy free vars into frame. This isn't too efficient right now. */ - if (f->f_ncells) { + if (PyTuple_GET_SIZE(co->co_cellvars)) { int i = 0, j = 0, nargs, found; char *cellname, *argname; PyObject *c; @@ -2764,7 +2764,7 @@ that are arguments at the beginning of the cellvars list so that we can march over it more efficiently? */ - for (i = 0; i < f->f_ncells; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) { cellname = PyString_AS_STRING( PyTuple_GET_ITEM(co->co_cellvars, i)); found = 0; @@ -2775,7 +2775,7 @@ c = PyCell_New(GETLOCAL(j)); if (c == NULL) goto fail; - GETLOCAL(f->f_nlocals + i) = c; + GETLOCAL(co->co_nlocals + i) = c; found = 1; break; } @@ -2784,16 +2784,16 @@ c = PyCell_New(NULL); if (c == NULL) goto fail; - SETLOCAL(f->f_nlocals + i, c); + SETLOCAL(co->co_nlocals + i, c); } } } - if (f->f_nfreevars) { + if (PyTuple_GET_SIZE(co->co_freevars)) { int i; - for (i = 0; i < f->f_nfreevars; ++i) { + for (i = 0; i < PyTuple_GET_SIZE(co->co_freevars); ++i) { PyObject *o = PyTuple_GET_ITEM(closure, i); Py_INCREF(o); - freevars[f->f_ncells + i] = o; + freevars[PyTuple_GET_SIZE(co->co_cellvars) + i] = o; } } @@ -4214,7 +4214,7 @@ } case STORE_DEREF: { - PyObject **freevars = f->f_localsplus + f->f_nlocals; + PyObject **freevars = f->f_localsplus + f->f_code->co_nlocals; PyObject *c = freevars[PEEKARG()]; if (PyCell_GET(c) == v) PyCell_Set(c, NULL); Modified: python/branches/blais-bytebuf/Python/errors.c ============================================================================== --- python/branches/blais-bytebuf/Python/errors.c (original) +++ python/branches/blais-bytebuf/Python/errors.c Wed May 24 20:30:42 2006 @@ -527,6 +527,7 @@ } + PyObject * PyErr_NewException(char *name, PyObject *base, PyObject *dict) { @@ -559,9 +560,15 @@ classname = PyString_FromString(dot+1); if (classname == NULL) goto failure; - bases = PyTuple_Pack(1, base); - if (bases == NULL) - goto failure; + if (PyTuple_Check(base)) { + bases = base; + /* INCREF as we create a new ref in the else branch */ + Py_INCREF(bases); + } else { + bases = PyTuple_Pack(1, base); + if (bases == NULL) + goto failure; + } result = PyClass_New(bases, dict, classname); failure: Py_XDECREF(bases); Modified: python/branches/blais-bytebuf/Python/mystrtoul.c ============================================================================== --- python/branches/blais-bytebuf/Python/mystrtoul.c (original) +++ python/branches/blais-bytebuf/Python/mystrtoul.c Wed May 24 20:30:42 2006 @@ -15,6 +15,94 @@ /* strtol and strtoul, renamed to avoid conflicts */ + +#include +#ifndef DONT_HAVE_ERRNO_H +#include +#endif + +/* Static overflow check values for bases 2 through 36. + * smallmax[base] is the largest unsigned long i such that + * i * base doesn't overflow unsigned long. + */ +static unsigned long smallmax[] = { + 0, /* bases 0 and 1 are invalid */ + 0, + ULONG_MAX / 2, + ULONG_MAX / 3, + ULONG_MAX / 4, + ULONG_MAX / 5, + ULONG_MAX / 6, + ULONG_MAX / 7, + ULONG_MAX / 8, + ULONG_MAX / 9, + ULONG_MAX / 10, + ULONG_MAX / 11, + ULONG_MAX / 12, + ULONG_MAX / 13, + ULONG_MAX / 14, + ULONG_MAX / 15, + ULONG_MAX / 16, + ULONG_MAX / 17, + ULONG_MAX / 18, + ULONG_MAX / 19, + ULONG_MAX / 20, + ULONG_MAX / 21, + ULONG_MAX / 22, + ULONG_MAX / 23, + ULONG_MAX / 24, + ULONG_MAX / 25, + ULONG_MAX / 26, + ULONG_MAX / 27, + ULONG_MAX / 28, + ULONG_MAX / 29, + ULONG_MAX / 30, + ULONG_MAX / 31, + ULONG_MAX / 32, + ULONG_MAX / 33, + ULONG_MAX / 34, + ULONG_MAX / 35, + ULONG_MAX / 36, +}; + +/* maximum digits that can't ever overflow for bases 2 through 36, + * calculated by [int(math.floor(math.log(2**32, i))) for i in range(2, 37)]. + * Note that this is pessimistic if sizeof(long) > 4. + */ +static int digitlimit[] = { + 0, 0, 32, 20, 16, 13, 12, 11, 10, 10, /* 0 - 9 */ + 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, /* 10 - 19 */ + 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */ + 6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */ + +/* char-to-digit conversion for bases 2-36; all non-digits are 37 */ +static int digitlookup[] = { + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 +}; + /* ** strtoul ** This is a general purpose routine for converting @@ -28,98 +116,100 @@ ** Errors due to bad pointers will probably result in ** exceptions - we don't check for them. */ - -#include -#ifndef DONT_HAVE_ERRNO_H -#include -#endif - unsigned long PyOS_strtoul(register char *str, char **ptr, int base) { - register unsigned long result; /* return value of the function */ - register int c; /* current input character */ - register unsigned long temp; /* used in overflow testing */ - int ovf; /* true if overflow occurred */ - - result = 0; - ovf = 0; - -/* catch silly bases */ - if (base != 0 && (base < 2 || base > 36)) - { - if (ptr) - *ptr = str; - return 0; - } - -/* skip leading white space */ - while (*str && isspace(Py_CHARMASK(*str))) - str++; - -/* check for leading 0 or 0x for auto-base or base 16 */ - switch (base) - { - case 0: /* look for leading 0, 0x or 0X */ - if (*str == '0') - { - str++; - if (*str == 'x' || *str == 'X') - { - str++; - base = 16; - } - else - base = 8; - } - else - base = 10; - break; - - case 16: /* skip leading 0x or 0X */ - if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) - str += 2; - break; - } - -/* do the conversion */ - while ((c = Py_CHARMASK(*str)) != '\0') - { - if (isdigit(c) && c - '0' < base) - c -= '0'; - else - { - if (isupper(c)) - c = tolower(c); - if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else /* non-"digit" character */ - break; - if (c >= base) /* non-"digit" character */ - break; + register unsigned long result = 0; /* return value of the function */ + register int c; /* current input character */ + register int ovlimit; /* required digits to overflow */ + + /* skip leading white space */ + while (*str && isspace(Py_CHARMASK(*str))) + ++str; + + /* check for leading 0 or 0x for auto-base or base 16 */ + switch (base) { + case 0: /* look for leading 0, 0x or 0X */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') { + ++str; + base = 16; + } + else + base = 8; + } + else + base = 10; + break; + + case 16: /* skip leading 0x or 0X */ + if (*str == '0') { + ++str; + if (*str == 'x' || *str == 'X') + ++str; + } + break; } - temp = result; - result = result * base + c; - if(base == 10) { - if(((long)(result - c) / base != (long)temp)) /* overflow */ - ovf = 1; + + /* catch silly bases */ + if (base < 2 || base > 36) { + if (ptr) + *ptr = str; + return 0; } - else { - if ((result - c) / base != temp) /* overflow */ - ovf = 1; + + /* skip leading zeroes */ + while (*str == '0') + ++str; + + /* base is guaranteed to be in [2, 36] at this point */ + ovlimit = digitlimit[base]; + + /* do the conversion until non-digit character encountered */ + while ((c = digitlookup[Py_CHARMASK(*str)]) < base) { + if (ovlimit > 0) /* no overflow check required */ + result = result * base + c; + else { /* requires overflow check */ + register unsigned long temp_result; + + if (ovlimit < 0) /* guaranteed overflow */ + goto overflowed; + + /* there could be an overflow */ + /* check overflow just from shifting */ + if (result > smallmax[base]) + goto overflowed; + + result *= base; + + /* check overflow from the digit's value */ + temp_result = result + c; + if (temp_result < result) + goto overflowed; + + result = temp_result; + } + + ++str; + --ovlimit; } - str++; - } -/* set pointer to point to the last character scanned */ - if (ptr) - *ptr = str; - if (ovf) - { - result = (unsigned long) ~0L; + /* set pointer to point to the last character scanned */ + if (ptr) + *ptr = str; + + return result; + +overflowed: + if (ptr) { + /* spool through remaining digit characters */ + while (digitlookup[Py_CHARMASK(*str)] < base) + ++str; + *ptr = str; + } errno = ERANGE; - } - return result; + return (unsigned long)-1; } long @@ -127,25 +217,25 @@ { long result; char sign; - + while (*str && isspace(Py_CHARMASK(*str))) str++; - + sign = *str; if (sign == '+' || sign == '-') str++; - + result = (long) PyOS_strtoul(str, ptr, base); - + /* Signal overflow if the result appears negative, except for the largest negative integer */ if (result < 0 && !(sign == '-' && result == -result)) { errno = ERANGE; result = 0x7fffffff; } - + if (sign == '-') result = -result; - + return result; } Modified: python/branches/blais-bytebuf/setup.py ============================================================================== --- python/branches/blais-bytebuf/setup.py (original) +++ python/branches/blais-bytebuf/setup.py Wed May 24 20:30:42 2006 @@ -1448,7 +1448,7 @@ 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('struct', ['structmodule.c'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', From python-checkins at python.org Wed May 24 20:38:23 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 20:38:23 +0200 (CEST) Subject: [Python-checkins] r46195 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060524183823.F36931E400A@bag.python.org> Author: sean.reifschneider Date: Wed May 24 20:38:23 2006 New Revision: 46195 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding errno testing as string and int. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Wed May 24 20:38:23 2006 @@ -221,6 +221,10 @@ { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', 'filename' : 'filenameStr' }), + ( EnvironmentError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), + 'strerror' : 'strErrorStr', 'errno' : 1, + 'filename' : 'filenameStr' }), ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', 'textStr', 'print_file_and_lineStr'), { 'message' : '', 'args' : ('msgStr', 'filenameStr', From python-checkins at python.org Wed May 24 20:44:04 2006 From: python-checkins at python.org (jack.diederich) Date: Wed, 24 May 2006 20:44:04 +0200 (CEST) Subject: [Python-checkins] r46196 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Message-ID: <20060524184404.9E99E1E400A@bag.python.org> Author: jack.diederich Date: Wed May 24 20:44:03 2006 New Revision: 46196 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Log: * Context._raise_error() replacement Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Wed May 24 20:44:03 2006 @@ -3126,6 +3126,147 @@ return ret; } +static PyObject * +_do_context_error_dispatch(int flag, PyObject *args) +{ + contextobject *ctx; + decimalobject *thing; + PyTypeObject *ctx_type; + char *expl; + long sign; + int two; + int ret; + + switch (flag) { + case S_CLAMPED: + case S_SUBNORMAL: + case S_UNDERFLOW: + case S_INEXACT: + case S_ROUNDED: + if (!PyArg_ParseTuple(args, "OO:_raise_error", &ctx, &expl)) + return NULL; + switch (flag) { + case S_CLAMPED: + ret = handle_Clamped(ctx, expl); + break; + case S_SUBNORMAL: + ret = handle_Subnormal(ctx, expl); + break; + case S_UNDERFLOW: + ret = handle_Underflow(ctx, expl); + break; + case S_INEXACT: + ret = handle_Inexact(ctx, expl); + break; + case S_ROUNDED: + ret = handle_Rounded(ctx, expl); + break; + }; + break; + case C_INV_CONTEXT: + case C_DIV_IMPOSSIBLE: + case C_CONV_SYNTAX: + if (!PyArg_ParseTuple(args, "OOs:_raise_error", &ctx_type, &ctx, &expl)) + return NULL; + switch (flag) { + case C_INV_CONTEXT: + return (PyObject *)handle_InvalidContext(ctx_type, ctx, expl); + break; + case C_DIV_IMPOSSIBLE: + return (PyObject *)handle_DivisionImpossible(ctx_type, ctx, expl); + break; + case C_CONV_SYNTAX: + return (PyObject *)handle_ConversionSyntax(ctx_type, ctx, expl); + break; + }; + break; + case S_INV_OPERATION: + if (!PyArg_ParseTuple(args, "OOsO:_raise_error", &ctx_type, &ctx, &expl, &thing)) + return NULL; + return (PyObject *)handle_InvalidOperation(ctx_type, ctx, expl, thing); + break; + case S_DIV_BY_ZERO: + if (!PyArg_ParseTuple(args, "OOsli:_raise_error", &ctx_type, &ctx, &expl, &sign, &two)) + return NULL; + return (PyObject *)handle_DivisionByZero(ctx_type, ctx, expl, sign, two); + break; + case C_DIV_UNDEFINED: + if (!PyArg_ParseTuple(args, "OOsl:_raise_error", &ctx_type, &ctx, &expl, &two)) + return NULL; + return (PyObject *)handle_DivisionUndefined(ctx_type, ctx, expl, two); + break; + case S_OVERFLOW: + if (!PyArg_ParseTuple(args, "OOsl:_raise_error", &ctx_type, &ctx, &expl, &sign)) + return NULL; + return (PyObject *)handle_Overflow(ctx_type, ctx, expl, sign); + break; + default: + printf("flag %d\n", flag); + PyErr_SetString(PyExc_ValueError, "bad handler in _do_context_error_dispatch"); + return NULL; + } + return PyLong_FromLong((long)ret); +} + +static PyObject * +context_raise_error(contextobject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"explanation", 0}; + PyObject *condition = NULL; + PyObject *explanation = NULL; + PyObject *rest = NULL; + PyObject *handler; + PyObject *dummy; + int flag = -1; + int i; + + if (!PyArg_ParseTuple(args, "O|OO:_raise_error", &condition, &explanation, &rest)) + return NULL; + + dummy = PyTuple_New(0); + if (dummy == NULL) + return NULL; + + + if (explanation == NULL && !PyArg_ParseTupleAndKeywords(dummy, kwds, + "O:_raise_error", kwlist, + &explanation)) + return NULL; + + if ((condition == ConversionSyntax) || + (condition == DivisionImpossible) || + (condition == DivisionUndefined) || + (condition == InvalidContext)) { + handler = InvalidOperation; + } else { + /* reuse the condition */ + handler = condition; + } + for (i = 0; i < NUMSIGNALS; i++) { + if (errors[i] == handler) { + flag = i; + break; + } + } + + if (ISFLAGSET(self->ignored, flag)) { + return _do_context_error_dispatch(flag, args); + } else { + SETFLAG(self->ignored, flag); + if (!ISFLAGSET(self->traps, flag)) { + for (i = 0; i < NUMSIGNALS; i++) { + if (errors[i] == condition) { + flag = i; + break; + } + } + return _do_context_error_dispatch(flag, args); + + } + } + PyErr_SetString(handler, PyString_AsString(explanation)); + return NULL; +} static PyMethodDef context_methods[] = { {"clear_flags", (PyCFunction)context_clear_flags, METH_NOARGS}, @@ -3190,6 +3331,8 @@ METH_VARARGS}, {"_set_rounding", (PyCFunction)context_set_rounding, METH_VARARGS}, + {"_raise_error", (PyCFunction)context_raise_error, + METH_VARARGS | METH_KEYWORDS}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, {"_shallow_copy", (PyCFunction)context_copy, Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Wed May 24 20:44:03 2006 @@ -2158,32 +2158,6 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' -## FROM HERE - - def _raise_error(self, condition, explanation = None, *args): - """Handles an error - - If the flag is in _ignored_flags, returns the default response. - Otherwise, it increments the flag, then, if the corresponding - trap_enabler is set, it reaises the exception. Otherwise, it returns - the default value after incrementing the flag. - """ - error = _condition_map.get(condition, condition) - if error in self._ignored_flags: - #Don't touch the flag - return error().handle(self, *args) - - self.flags[error] += 1 - if not self.traps[error]: - #The errors define how to handle themselves. - return condition().handle(self, *args) - - # Errors should only be risked on copies of the context - #self._ignored_flags = [] - raise error, explanation - -## TO HERE - def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) From python-checkins at python.org Wed May 24 20:50:41 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 20:50:41 +0200 (CEST) Subject: [Python-checkins] r46197 - python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Message-ID: <20060524185041.992B21E400A@bag.python.org> Author: sean.reifschneider Date: Wed May 24 20:50:41 2006 New Revision: 46197 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Log: Adding VMSError to the exception_heirarchy documentation. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Wed May 24 20:50:41 2006 @@ -15,6 +15,7 @@ | | +-- IOError | | +-- OSError | | +-- WindowsError (Windows) + | | +-- VMSError (VMS) | +-- EOFError | +-- ImportError | +-- LookupError From martin at v.loewis.de Wed May 24 20:51:50 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 24 May 2006 20:51:50 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240324s3b96fa5dy725163309764e2d@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <1f7befae0605240324s3b96fa5dy725163309764e2d@mail.gmail.com> Message-ID: <4474AB46.3070605@v.loewis.de> Tim Peters wrote: > GetProcessTimes() is a relatively new addition to the Win32 API. > Doesn't exist in any version of 9X/ME. Does exist in XP. May or may > not exist in Win2K (docs say it exists in Win2K Pro and Win2K Server; > they don't claim it exists in plain Win2K). IIRC, there was no "plain Win2K", only Pro, AS, and Datacenter (actually, I didn't remember - wikipedia told me). So GetProcessTimes *is* available on W2k (it actually was available in NT 3.5 according to the API documentation). However, it is *not* available in W9x, and we decided to still support W9x in Python 2.5. That means it must be called through GetProcAddress still. Regards, Martin From python-checkins at python.org Wed May 24 20:55:37 2006 From: python-checkins at python.org (andrew.dalke) Date: Wed, 24 May 2006 20:55:37 +0200 (CEST) Subject: [Python-checkins] r46198 - python/trunk/Lib/test/string_tests.py Message-ID: <20060524185537.9BC571E400A@bag.python.org> Author: andrew.dalke Date: Wed May 24 20:55:37 2006 New Revision: 46198 Modified: python/trunk/Lib/test/string_tests.py Log: Added a slew of test for string replace, based various corner cases from the Need For Speed sprint coding. Includes commented out overflow tests which will be uncommented once the code is fixed. This test will break the 8-bit string tests because "".replace("", "A") == "" when it should == "A" We have a fix for it, which should be added tomorrow. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Wed May 24 20:55:37 2006 @@ -376,6 +376,153 @@ self.checkraises(TypeError, 'hello', 'swapcase', 42) def test_replace(self): + EQ = self.checkequal + + # Operations on the empty string + EQ("", "", "replace", "", "") + EQ("A", "", "replace", "", "A") + EQ("", "", "replace", "A", "") + EQ("", "", "replace", "A", "A") + EQ("", "", "replace", "", "", 100) + EQ("", "", "replace", "", "", sys.maxint) + + # interleave (from=="", 'to' gets inserted everywhere) + EQ("A", "A", "replace", "", "") + EQ("*A*", "A", "replace", "", "*") + EQ("*1A*1", "A", "replace", "", "*1") + EQ("*-#A*-#", "A", "replace", "", "*-#") + EQ("*-A*-A*-", "AA", "replace", "", "*-") + EQ("*-A*-A*-", "AA", "replace", "", "*-", -1) + EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 4) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 3) + EQ("*-A*-A", "AA", "replace", "", "*-", 2) + EQ("*-AA", "AA", "replace", "", "*-", 1) + EQ("AA", "AA", "replace", "", "*-", 0) + + # single character deletion (from=="A", to=="") + EQ("", "A", "replace", "A", "") + EQ("", "AAA", "replace", "A", "") + EQ("", "AAA", "replace", "A", "", -1) + EQ("", "AAA", "replace", "A", "", sys.maxint) + EQ("", "AAA", "replace", "A", "", 4) + EQ("", "AAA", "replace", "A", "", 3) + EQ("A", "AAA", "replace", "A", "", 2) + EQ("AA", "AAA", "replace", "A", "", 1) + EQ("AAA", "AAA", "replace", "A", "", 0) + EQ("", "AAAAAAAAAA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "", -1) + EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint) + EQ("BCD", "ABACADA", "replace", "A", "", 5) + EQ("BCD", "ABACADA", "replace", "A", "", 4) + EQ("BCDA", "ABACADA", "replace", "A", "", 3) + EQ("BCADA", "ABACADA", "replace", "A", "", 2) + EQ("BACADA", "ABACADA", "replace", "A", "", 1) + EQ("ABACADA", "ABACADA", "replace", "A", "", 0) + EQ("BCD", "ABCAD", "replace", "A", "") + EQ("BCD", "ABCADAA", "replace", "A", "") + EQ("BCD", "BCD", "replace", "A", "") + EQ("*************", "*************", "replace", "A", "") + EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999) + + # substring deletion (from=="the", to=="") + EQ("", "the", "replace", "the", "") + EQ("ater", "theater", "replace", "the", "") + EQ("", "thethe", "replace", "the", "") + EQ("", "thethethethe", "replace", "the", "") + EQ("aaaa", "theatheatheathea", "replace", "the", "") + EQ("that", "that", "replace", "the", "") + EQ("thaet", "thaet", "replace", "the", "") + EQ("here and re", "here and there", "replace", "the", "") + EQ("here and re and re", "here and there and there", + "replace", "the", "", sys.maxint) + EQ("here and re and re", "here and there and there", + "replace", "the", "", -1) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 3) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 2) + EQ("here and re and there", "here and there and there", + "replace", "the", "", 1) + EQ("here and there and there", "here and there and there", + "replace", "the", "", 0) + EQ("here and re and re", "here and there and there", "replace", "the", "") + + EQ("abc", "abc", "replace", "the", "") + EQ("abcdefg", "abcdefg", "replace", "the", "") + + # substring deletion (from=="bob", to=="") + EQ("bob", "bbobob", "replace", "bob", "") + EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "") + + # single character replace in place (len(from)==len(to)==1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "o") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2) + EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0) + + EQ("Who goes there?", "Who goes there?", "replace", "a", "q") + EQ("who goes there?", "Who goes there?", "replace", "W", "w") + EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w") + EQ("Who goes there!", "Who goes there?", "replace", "?", "!") + EQ("Who goes there!!", "Who goes there??", "replace", "?", "!") + + EQ("Who goes there?", "Who goes there?", "replace", ".", "!") + + # substring replace in place (len(from)==len(to) > 1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3) + EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2) + EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1) + EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0) + EQ("cobob", "bobob", "replace", "bob", "cob") + EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob") + EQ("bobob", "bobob", "replace", "bot", "bot") + + # replace single character (len(from)==1, len(to)>1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK") + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2) + EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) + EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) + EQ("A----B----C----", "A.B.C.", "replace", ".", "----") + + EQ("Reykjavik", "Reykjavik", "replace", "q", "KK") + + # replace substring (len(from)>1, len(to)!=len(from)) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham") + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", sys.maxint) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", -1) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 4) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 3) + EQ("ham, ham, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 2) + EQ("ham, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 1) + EQ("spam, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 0) + + EQ("bobob", "bobobob", "replace", "bobob", "bob") + EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") + EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") + + # self.checkequal('one at two!three!', 'one!two!three!', 'replace', '!', '@', 1) self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '') self.checkequal('one at two@three!', 'one!two!three!', 'replace', '!', '@', 2) @@ -403,6 +550,16 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) +### Commented out until the underlying libraries are fixed +## def test_replace_overflow(self): +## # Check for overflow checking on 32 bit machines +## if sys.maxint != 2147483647: +## return +## A2_16 = "A" * (2**16) +## self.checkraises(OverflowError, A2_16, "replace", "", A2_16) +## self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) +## self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) + def test_zfill(self): self.checkequal('123', '123', 'zfill', 2) self.checkequal('123', '123', 'zfill', 3) From buildbot at python.org Wed May 24 21:17:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:17:11 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060524191711.55BA91E400B@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/830 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:19:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:19:26 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060524191926.EBC271E400A@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/174 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 24 21:20:14 2006 From: python-checkins at python.org (sean.reifschneider) Date: Wed, 24 May 2006 21:20:14 +0200 (CEST) Subject: [Python-checkins] r46199 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060524192014.A7E221E400A@bag.python.org> Author: sean.reifschneider Date: Wed May 24 21:20:14 2006 New Revision: 46199 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding a couple of other SyntaxError tests. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Wed May 24 21:20:14 2006 @@ -225,6 +225,18 @@ { 'message' : '', 'args' : (1, 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 1, 'filename' : 'filenameStr' }), + ( SyntaxError, ('msgStr',), + { 'message' : 'msgStr', 'args' : ('msgStr', ), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', + 'textStr')), + { 'message' : '', 'args' : ('msgStr', ('filenameStr', + 'linenoStr', 'offsetStr', 'textStr' )), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : 'filenameStr', 'lineno' : 'linenoStr', + 'offset' : 'offsetStr', 'text' : 'textStr' }), ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', 'textStr', 'print_file_and_lineStr'), { 'message' : '', 'args' : ('msgStr', 'filenameStr', From buildbot at python.org Wed May 24 21:24:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:24:22 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060524192422.D72A81E400A@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/761 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:28:23 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:28:23 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060524192823.C52A51E400A@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/482 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:32:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:32:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060524193234.294371E400A@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/764 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:36:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:36:19 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060524193619.A72C71E400B@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/744 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:36:47 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:36:47 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060524193647.93C011E400A@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/740 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 24 21:40:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 19:40:58 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060524194058.925E11E401A@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/660 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Wed May 24 22:04:37 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 24 May 2006 22:04:37 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240613k5a65388atbb5bafdd2342908e@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <44744BED.2000308@holdenweb.com> <44744E9C.6020305@egenix.com> <1f7befae0605240613k5a65388atbb5bafdd2342908e@mail.gmail.com> Message-ID: <4474BC55.2060806@v.loewis.de> Tim Peters wrote: > Since timeit.py aims at small, fast-running code segments, it's doing > exactly the right thing for that purpose. If a Windows process-time > gimmick were added, timeit.py would not want to use it (unless its > _resolution_ was better than the Windows time.clock()). GetProcessTimes results are measured in units of 100ns. Unfortunately, the API documentation is silent as to what the actual resolution is, however, I would expect that it is "precise", i.e. as close as possible to the "one true" time as the scheduler can measure times. Even Linux has a low-resolution clock only "on purpose": process times are measured in "jiffies", and then scaled down to 100Hz because of backwards compatibility. Regards, Martin From neal at metaslash.com Wed May 24 22:12:26 2006 From: neal at metaslash.com (Neal Norwitz) Date: Wed, 24 May 2006 16:12:26 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (2) Message-ID: <20060524201226.GA13792@python.psfb.org> ----------------------------------------------- Modules/Setup.dist is newer than Modules/Setup; check to make sure you have all the updates you need in your Modules/Setup file. Usually, copying Setup.dist to Setup will work. ----------------------------------------------- case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33724 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 383, in test_replace EQ("A", "", "replace", "", "A") File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 'A' != '' test_strftime test_string test test_string failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 383, in test_replace EQ("A", "", "replace", "", "A") File "/home/neal/python/trunk/Lib/test/test_string.py", line 16, in checkequal realresult AssertionError: 'A' != '' test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 282 tests OK. 3 tests failed: test_str test_string test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [423084 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 383, in test_replace EQ("A", "", "replace", "", "A") File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 'A' != '' test_strftime test_string test test_string failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 383, in test_replace EQ("A", "", "replace", "", "A") File "/home/neal/python/trunk/Lib/test/test_string.py", line 16, in checkequal realresult AssertionError: 'A' != '' test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 282 tests OK. 3 tests failed: test_str test_string test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [422515 refs] make: *** [test] Error 1 From python-checkins at python.org Wed May 24 22:27:19 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 24 May 2006 22:27:19 +0200 (CEST) Subject: [Python-checkins] r46200 - python/trunk/Lib/test/string_tests.py Message-ID: <20060524202719.E1A071E400A@bag.python.org> Author: tim.peters Date: Wed May 24 22:27:18 2006 New Revision: 46200 Modified: python/trunk/Lib/test/string_tests.py Log: We can't leave the checked-in tests broken. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Wed May 24 22:27:18 2006 @@ -380,7 +380,12 @@ # Operations on the empty string EQ("", "", "replace", "", "") - EQ("A", "", "replace", "", "A") + + #EQ("A", "", "replace", "", "A") + # That was the correct result; this is the result we actually get + # now: + EQ("", "", "replace", "", "A") + EQ("", "", "replace", "A", "") EQ("", "", "replace", "A", "A") EQ("", "", "replace", "", "", 100) @@ -457,7 +462,7 @@ EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "") EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "") EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "") - + # single character replace in place (len(from)==len(to)==1) EQ("Who goes there?", "Who goes there?", "replace", "o", "o") EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") @@ -475,7 +480,7 @@ EQ("Who goes there!!", "Who goes there??", "replace", "?", "!") EQ("Who goes there?", "Who goes there?", "replace", ".", "!") - + # substring replace in place (len(from)==len(to) > 1) EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint) @@ -521,8 +526,8 @@ EQ("bobob", "bobobob", "replace", "bobob", "bob") EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") - - # + + # self.checkequal('one at two!three!', 'one!two!three!', 'replace', '!', '@', 1) self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '') self.checkequal('one at two@three!', 'one!two!three!', 'replace', '!', '@', 2) From python-checkins at python.org Wed May 24 22:29:44 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 24 May 2006 22:29:44 +0200 (CEST) Subject: [Python-checkins] r46201 - python/trunk/Lib/struct.py Message-ID: <20060524202944.B60EB1E400A@bag.python.org> Author: tim.peters Date: Wed May 24 22:29:44 2006 New Revision: 46201 Modified: python/trunk/Lib/struct.py Log: Whitespace normalization. Modified: python/trunk/Lib/struct.py ============================================================================== --- python/trunk/Lib/struct.py (original) +++ python/trunk/Lib/struct.py Wed May 24 22:29:44 2006 @@ -73,7 +73,7 @@ except KeyError: o = _compile(fmt) return o.unpack(s) - + def unpack_from(fmt, buf, offset=0): """ Unpack the buffer, containing packed C structure data, according to @@ -84,4 +84,4 @@ o = _cache[fmt] except KeyError: o = _compile(fmt) - return o.unpack_from(buf, offset) \ No newline at end of file + return o.unpack_from(buf, offset) From python-checkins at python.org Wed May 24 23:00:47 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 24 May 2006 23:00:47 +0200 (CEST) Subject: [Python-checkins] r46202 - python/trunk/Lib/test/string_tests.py Message-ID: <20060524210047.554C61E400A@bag.python.org> Author: tim.peters Date: Wed May 24 23:00:45 2006 New Revision: 46202 Modified: python/trunk/Lib/test/string_tests.py Log: Disable the damn empty-string replace test -- it can't be make to pass now for unicode if it passes for str, or vice versa. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Wed May 24 23:00:45 2006 @@ -383,8 +383,8 @@ #EQ("A", "", "replace", "", "A") # That was the correct result; this is the result we actually get - # now: - EQ("", "", "replace", "", "A") + # now (for str, but not for unicode): + #EQ("", "", "replace", "", "A") EQ("", "", "replace", "A", "") EQ("", "", "replace", "A", "A") From python-checkins at python.org Wed May 24 23:10:41 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 24 May 2006 23:10:41 +0200 (CEST) Subject: [Python-checkins] r46203 - in python/trunk: Lib/test/test_builtin.py Misc/NEWS Objects/longobject.c Message-ID: <20060524211041.BE05A1E401E@bag.python.org> Author: tim.peters Date: Wed May 24 23:10:40 2006 New Revision: 46203 Modified: python/trunk/Lib/test/test_builtin.py python/trunk/Misc/NEWS python/trunk/Objects/longobject.c Log: Heavily fiddled variant of patch #1442927: PyLong_FromString optimization. ``long(str, base)`` is now up to 6x faster for non-power-of-2 bases. The largest speedup is for inputs with about 1000 decimal digits. Conversion from non-power-of-2 bases remains quadratic-time in the number of input digits (it was and remains linear-time for bases 2, 4, 8, 16 and 32). Speedups at various lengths for decimal inputs, comparing 2.4.3 with current trunk. Note that it's actually a bit slower for 1-digit strings: len speedup ---- ------- 1 -4.5% 2 4.6% 3 8.3% 4 12.7% 5 16.9% 6 28.6% 7 35.5% 8 44.3% 9 46.6% 10 55.3% 11 65.7% 12 77.7% 13 73.4% 14 75.3% 15 85.2% 16 103.0% 17 95.1% 18 112.8% 19 117.9% 20 128.3% 30 174.5% 40 209.3% 50 236.3% 60 254.3% 70 262.9% 80 295.8% 90 297.3% 100 324.5% 200 374.6% 300 403.1% 400 391.1% 500 388.7% 600 440.6% 700 468.7% 800 498.0% 900 507.2% 1000 501.2% 2000 450.2% 3000 463.2% 4000 452.5% 5000 440.6% 6000 439.6% 7000 424.8% 8000 418.1% 9000 417.7% Modified: python/trunk/Lib/test/test_builtin.py ============================================================================== --- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Wed May 24 23:10:40 2006 @@ -980,6 +980,81 @@ self.assertRaises(ValueError, long, '53', 40) self.assertRaises(TypeError, long, 1, 12) + self.assertEqual(long('100000000000000000000000000000000', 2), + 4294967296) + self.assertEqual(long('102002022201221111211', 3), 4294967296) + self.assertEqual(long('10000000000000000', 4), 4294967296) + self.assertEqual(long('32244002423141', 5), 4294967296) + self.assertEqual(long('1550104015504', 6), 4294967296) + self.assertEqual(long('211301422354', 7), 4294967296) + self.assertEqual(long('40000000000', 8), 4294967296) + self.assertEqual(long('12068657454', 9), 4294967296) + self.assertEqual(long('4294967296', 10), 4294967296) + self.assertEqual(long('1904440554', 11), 4294967296) + self.assertEqual(long('9ba461594', 12), 4294967296) + self.assertEqual(long('535a79889', 13), 4294967296) + self.assertEqual(long('2ca5b7464', 14), 4294967296) + self.assertEqual(long('1a20dcd81', 15), 4294967296) + self.assertEqual(long('100000000', 16), 4294967296) + self.assertEqual(long('a7ffda91', 17), 4294967296) + self.assertEqual(long('704he7g4', 18), 4294967296) + self.assertEqual(long('4f5aff66', 19), 4294967296) + self.assertEqual(long('3723ai4g', 20), 4294967296) + self.assertEqual(long('281d55i4', 21), 4294967296) + self.assertEqual(long('1fj8b184', 22), 4294967296) + self.assertEqual(long('1606k7ic', 23), 4294967296) + self.assertEqual(long('mb994ag', 24), 4294967296) + self.assertEqual(long('hek2mgl', 25), 4294967296) + self.assertEqual(long('dnchbnm', 26), 4294967296) + self.assertEqual(long('b28jpdm', 27), 4294967296) + self.assertEqual(long('8pfgih4', 28), 4294967296) + self.assertEqual(long('76beigg', 29), 4294967296) + self.assertEqual(long('5qmcpqg', 30), 4294967296) + self.assertEqual(long('4q0jto4', 31), 4294967296) + self.assertEqual(long('4000000', 32), 4294967296) + self.assertEqual(long('3aokq94', 33), 4294967296) + self.assertEqual(long('2qhxjli', 34), 4294967296) + self.assertEqual(long('2br45qb', 35), 4294967296) + self.assertEqual(long('1z141z4', 36), 4294967296) + + self.assertEqual(long('100000000000000000000000000000001', 2), + 4294967297) + self.assertEqual(long('102002022201221111212', 3), 4294967297) + self.assertEqual(long('10000000000000001', 4), 4294967297) + self.assertEqual(long('32244002423142', 5), 4294967297) + self.assertEqual(long('1550104015505', 6), 4294967297) + self.assertEqual(long('211301422355', 7), 4294967297) + self.assertEqual(long('40000000001', 8), 4294967297) + self.assertEqual(long('12068657455', 9), 4294967297) + self.assertEqual(long('4294967297', 10), 4294967297) + self.assertEqual(long('1904440555', 11), 4294967297) + self.assertEqual(long('9ba461595', 12), 4294967297) + self.assertEqual(long('535a7988a', 13), 4294967297) + self.assertEqual(long('2ca5b7465', 14), 4294967297) + self.assertEqual(long('1a20dcd82', 15), 4294967297) + self.assertEqual(long('100000001', 16), 4294967297) + self.assertEqual(long('a7ffda92', 17), 4294967297) + self.assertEqual(long('704he7g5', 18), 4294967297) + self.assertEqual(long('4f5aff67', 19), 4294967297) + self.assertEqual(long('3723ai4h', 20), 4294967297) + self.assertEqual(long('281d55i5', 21), 4294967297) + self.assertEqual(long('1fj8b185', 22), 4294967297) + self.assertEqual(long('1606k7id', 23), 4294967297) + self.assertEqual(long('mb994ah', 24), 4294967297) + self.assertEqual(long('hek2mgm', 25), 4294967297) + self.assertEqual(long('dnchbnn', 26), 4294967297) + self.assertEqual(long('b28jpdn', 27), 4294967297) + self.assertEqual(long('8pfgih5', 28), 4294967297) + self.assertEqual(long('76beigh', 29), 4294967297) + self.assertEqual(long('5qmcpqh', 30), 4294967297) + self.assertEqual(long('4q0jto5', 31), 4294967297) + self.assertEqual(long('4000001', 32), 4294967297) + self.assertEqual(long('3aokq95', 33), 4294967297) + self.assertEqual(long('2qhxjlj', 34), 4294967297) + self.assertEqual(long('2br45qc', 35), 4294967297) + self.assertEqual(long('1z141z5', 36), 4294967297) + + def test_longconversion(self): # Test __long__() class Foo0: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed May 24 23:10:40 2006 @@ -12,6 +12,12 @@ Core and builtins ----------------- +- Patch #1442927: ``long(str, base)`` is now up to 6x faster for non-power- + of-2 bases. The largest speedup is for inputs with about 1000 decimal + digits. Conversion from non-power-of-2 bases remains quadratic-time in + the number of input digits (it was and remains linear-time for bases + 2, 4, 8, 16 and 32). + - Bug #1334662: ``int(string, base)`` could deliver a wrong answer when ``base`` was not 2, 4, 8, 10, 16 or 32, and ``string`` represented an integer close to ``sys.maxint``. This was repaired by patch Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Wed May 24 23:10:40 2006 @@ -277,9 +277,9 @@ overflow: PyErr_SetString(PyExc_OverflowError, "long int too large to convert to int"); - if (sign > 0) + if (sign > 0) return PY_SSIZE_T_MAX; - else + else return PY_SSIZE_T_MIN; } @@ -1304,7 +1304,34 @@ return (PyObject *)str; } -/* *str points to the first digit in a string of base base digits. base +static int digval[] = { + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 +}; + +/* *str points to the first digit in a string of base `base` digits. base * is a power of 2 (2, 4, 8, 16, or 32). *str is set to point to the first * non-digit (which may be *str!). A normalized long is returned. * The point to this routine is that it takes time linear in the number of @@ -1328,20 +1355,8 @@ n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - for (;;) { - int k = -1; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else if (ch >= 'A') - k = ch - 'A' + 10; - if (k < 0 || k >= base) - break; + while (digval[Py_CHARMASK(*p)] < base) ++p; - } *str = p; n = (p - start) * bits_per_char; if (n / bits_per_char != p - start) { @@ -1361,17 +1376,7 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else { - assert(ch >= 'A'); - k = ch - 'A' + 10; - } + int k = digval[Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1427,33 +1432,140 @@ } if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) str += 2; + start = str; if ((base & (base - 1)) == 0) z = long_from_binary_base(&str, base); else { - z = _PyLong_New(0); - for ( ; z != NULL; ++str) { - int k = -1; - PyLongObject *temp; - - if (*str <= '9') - k = *str - '0'; - else if (*str >= 'a') - k = *str - 'a' + 10; - else if (*str >= 'A') - k = *str - 'A' + 10; - if (k < 0 || k >= base) - break; - temp = muladd1(z, (digit)base, (digit)k); - Py_DECREF(z); - z = temp; +/*** +Binary bases can be converted in time linear in the number of digits, because +Python's representation base is binary. Other bases (including decimal!) use +the simple quadratic-time algorithm below, complicated by some speed tricks. + +First some math: the largest integer that can be expressed in N base-B digits +is B**N-1. Consequently, if we have an N-digit input in base B, the worst- +case number of Python digits needed to hold it is the smallest integer n s.t. + + BASE**n-1 >= B**N-1 [or, adding 1 to both sides] + BASE**n >= B**N [taking logs to base BASE] + n >= log(B**N)/log(BASE) = N * log(B)/log(BASE) + +The static array log_base_BASE[base] == log(base)/log(BASE) so we can compute +this quickly. A Python long with that much space is reserved near the start, +and the result is computed into it. + +The input string is actually treated as being in base base**i (i.e., i digits +are processed at a time), where two more static arrays hold: + + convwidth_base[base] = the largest integer i such that base**i <= BASE + convmultmax_base[base] = base ** convwidth_base[base] + +The first of these is the largest i such that i consecutive input digits +must fit in a single Python digit. The second is effectively the input +base we're really using. + +Viewing the input as a sequence of digits in base +convmultmax_base[base], the result is "simply" + + (((c0*B + c1)*B + c2)*B + c3)*B + ... ))) + c_n-1 + +where B = convmultmax_base[base]. +***/ + register twodigits c; /* current input character */ + Py_ssize_t size_z; + int i; + int convwidth; + twodigits convmultmax, convmult; + digit *pz, *pzstop; + char* scan; + + static double log_base_BASE[37] = {0.0e0,}; + static int convwidth_base[37] = {0,}; + static twodigits convmultmax_base[37] = {0,}; + + if (log_base_BASE[base] == 0.0) { + twodigits convmax = base; + int i = 1; + + log_base_BASE[base] = log((double)base) / + log((double)BASE); + for (;;) { + twodigits next = convmax * base; + if (next > BASE) + break; + convmax = next; + ++i; + } + convmultmax_base[base] = convmax; + assert(i > 0); + convwidth_base[base] = i; + } + + /* Find length of the string of numeric characters. */ + scan = str; + while (digval[Py_CHARMASK(*scan)] < base) + ++scan; + + /* Create a long object that can contain the largest possible + * integer with this base and length. Note that there's no + * need to initialize z->ob_digit -- no slot is read up before + * being stored into. + */ + size_z = (Py_ssize_t)((scan - str) * log_base_BASE[base]) + 1; + assert(size_z > 0); + z = _PyLong_New(size_z); + if (z == NULL) + return NULL; + z->ob_size = 0; + + /* `convwidth` consecutive input digits are treated as a single + * digit in base `convmultmax`. + */ + convwidth = convwidth_base[base]; + convmultmax = convmultmax_base[base]; + + /* Work ;-) */ + while (str < scan) { + /* grab up to convwidth digits from the input string */ + c = (digit)digval[Py_CHARMASK(*str++)]; + for (i = 1; i < convwidth && str != scan; ++i, ++str) { + c = (twodigits)(c * base + + digval[Py_CHARMASK(*str)]); + assert(c < BASE); + } + + convmult = convmultmax; + /* Calculate the shift only if we couldn't get + * convwidth digits. + */ + if (i != convwidth) { + convmult = base; + for ( ; i > 1; --i) + convmult *= base; + } + + /* Multiply z by convmult, and add c. */ + pz = z->ob_digit; + pzstop = pz + z->ob_size; + for (; pz < pzstop; ++pz) { + c += (twodigits)*pz * convmult; + *pz = (digit)(c & MASK); + c >>= SHIFT; + } + /* carry off the current end? */ + if (c) { + assert(c < BASE); + assert(z->ob_size < size_z); + *pz = (digit)c; + ++z->ob_size; + } } } if (z == NULL) return NULL; if (str == start) goto onError; - if (sign < 0 && z != NULL && z->ob_size != 0) + if (sign < 0) z->ob_size = -(z->ob_size); if (*str == 'L' || *str == 'l') str++; From buildbot at python.org Wed May 24 23:16:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 21:16:39 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060524211639.BECB51E401A@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/520 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From jimjjewett at gmail.com Thu May 25 00:24:56 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 24 May 2006 18:24:56 -0400 Subject: [Python-checkins] r46181 - python/branches/rjones-prealloc In-Reply-To: <20060524151050.83D921E4019@bag.python.org> References: <20060524151050.83D921E4019@bag.python.org> Message-ID: On 5/24/06, richard.jones wrote: > Author: richard.jones > Date: Wed May 24 17:10:50 2006 > New Revision: 46181 > > Removed: > python/branches/rjones-prealloc/ > Log: > Didn't pan out - at best we can speed up appends by about 7-8% for lists of > 50-100 elements. For the large part the benefit is 0-2%. For lists under 20 > elements, peformance is actually reduced when pre-allocating. Is this because you don't know (often enough) what size to allocate? Or are you actually saying that even if you know exactly how long the list will be, it is better to grow and copy than to allocate it all at once? For instance, d=dict() t=tuple() ... k=d.keys() l=list(t) Don't benefit? -jJ From tim.peters at gmail.com Thu May 25 00:39:42 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 22:39:42 +0000 Subject: [Python-checkins] r46181 - python/branches/rjones-prealloc In-Reply-To: References: <20060524151050.83D921E4019@bag.python.org> Message-ID: <1f7befae0605241539g36698fbeh8d35c036c2a03759@mail.gmail.com> [richard.jones] >> Didn't pan out - at best we can speed up appends by about 7-8% for lists of >> 50-100 elements. For the large part the benefit is 0-2%. For lists under 20 >> elements, peformance is actually reduced when pre-allocating. [Jim Jewett] > Is this because you don't know (often enough) what size to allocate? No. > Or are you actually saying that even if you know exactly how long the > list will be, it is better to grow and copy than to allocate it all at > once. Yes, but not always. He explained when above. The experiments here added a new optional argument to the list constructor, allowing you to explicitly say how many elements you expect the list to hold. The returned list then contained room for that many elements. > For instance, > > d=dict() > t=tuple() > > ... > > k=d.keys() > l=list(t) > > Don't benefit? That should have been irrelevant to what he was trying. However, under the covers, Python already allocates lists of exactly the right sizes in both the examples (specifying the list size is already catered to at the C level). For example, dict_keys() starts with n = mp->ma_used; v = PyList_New(n); and then uses the ultra-fast, never-resizes, segfault-prone macro PyList_SET_ITEM(v, j, key) in a loop to populate the result list. From jimjjewett at gmail.com Thu May 25 00:44:14 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 24 May 2006 18:44:14 -0400 Subject: [Python-checkins] r46186 - in python/branches/blais-bytebuf: Lib/test/test_hotbuf.py Modules/hotbufmodule.c In-Reply-To: <20060524160141.F153F1E400B@bag.python.org> References: <20060524160141.F153F1E400B@bag.python.org> Message-ID: > Author: martin.blais > Date: Wed May 24 18:01:38 2006 > New Revision: 46186 > Modified: > python/branches/blais-bytebuf/Lib/test/test_hotbuf.py > python/branches/blais-bytebuf/Modules/hotbufmodule.c > Log: > Implemented compact() and a few other things. (1) Why should clients have to call compact explicitly? I would much prefer that it act like a circular buffer, and handle wraparound itself, instead of expecting me to call compact. (For buffers with a size that is a power of two, this can even be done fairly efficiently...) Otherwise the typical idiom will be to stick a compact() call after every buffer read or write, which will sort of blow the efficiency gains. (2) The Char methods seem to assume two bytes for a character. Should that be build-dependent, for UCS4? -jJ From buildbot at python.org Thu May 25 00:51:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 24 May 2006 22:51:21 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060524225121.BA8BD1E400B@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/291 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke Build Had Warnings: warnings test sincerely, -The Buildbot From tim.peters at gmail.com Thu May 25 01:04:46 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 24 May 2006 23:04:46 +0000 Subject: [Python-checkins] r46198 - python/trunk/Lib/test/string_tests.py In-Reply-To: <20060524185537.9BC571E400A@bag.python.org> References: <20060524185537.9BC571E400A@bag.python.org> Message-ID: <1f7befae0605241604h11d3b1b4g38b8b27c7842e546@mail.gmail.com> > Author: andrew.dalke > Date: Wed May 24 20:55:37 2006 > New Revision: 46198 > > Modified: > python/trunk/Lib/test/string_tests.py > Log: > Added a slew of test for string replace, based various corner cases from > the Need For Speed sprint coding. Includes commented out overflow tests > which will be uncommented once the code is fixed. > > This test will break the 8-bit string tests because > "".replace("", "A") == "" when it should == "A" > > We have a fix for it, which should be added tomorrow. Please note that it's never OK to check in a failing test to the trunk or to a release development branch (like the 2.4 maintenance branch). For now, I simply commented out that new test. From python-checkins at python.org Thu May 25 02:23:04 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 02:23:04 +0200 (CEST) Subject: [Python-checkins] r46204 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060525002304.0C87D1E400A@bag.python.org> Author: andrew.kuchling Date: Thu May 25 02:23:03 2006 New Revision: 46204 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Minor edits; add an item Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Thu May 25 02:23:03 2006 @@ -512,9 +512,9 @@ \exception{GeneratorExit} or \exception{StopIteration}; catching the exception and doing anything else is illegal and will trigger a \exception{RuntimeError}. \method{close()} will also be called by - Python's garbage collection when the generator is garbage-collected. + Python's garbage collector when the generator is garbage-collected. - If you need to run cleanup code in case of a \exception{GeneratorExit}, + If you need to run cleanup code when a \exception{GeneratorExit} occurs, I suggest using a \code{try: ... finally:} suite instead of catching \exception{GeneratorExit}. @@ -1143,6 +1143,13 @@ sprint. Character map decoding was improved by Walter D\"orwald.) % Patch 1313939 +\item The \function{long(\var{str}, \var{base})} function is now +faster on long digit strings because fewer intermediate results are +calculated. The peak is for strings of around 800--1000 digits where +the function is 6 times faster. +(Contributed by Alan McIntyre and committed at the NeedForSpeed sprint.) +% Patch 1442927 + \item The \module{struct} module now compiles structure format strings into an internal representation and caches this representation, yielding a 20\% speedup. (Contributed by Bob Ippolito From buildbot at python.org Thu May 25 04:04:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 02:04:52 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060525020452.3AA1A1E400A@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/458 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 04:42:26 2006 From: python-checkins at python.org (fred.drake) Date: Thu, 25 May 2006 04:42:26 +0200 (CEST) Subject: [Python-checkins] r46205 - in python/trunk/Doc: ACKS texinputs/python.sty Message-ID: <20060525024226.D8F9A1E400A@bag.python.org> Author: fred.drake Date: Thu May 25 04:42:25 2006 New Revision: 46205 Modified: python/trunk/Doc/ACKS python/trunk/Doc/texinputs/python.sty Log: fix broken links in PDF (SF patch #1281291, contributed by Rory Yorke) Modified: python/trunk/Doc/ACKS ============================================================================== --- python/trunk/Doc/ACKS (original) +++ python/trunk/Doc/ACKS Thu May 25 04:42:25 2006 @@ -195,6 +195,7 @@ Steven Work Thomas Wouters Ka-Ping Yee +Rory Yorke Moshe Zadka Milan Zamazal Cheng Zhang Modified: python/trunk/Doc/texinputs/python.sty ============================================================================== --- python/trunk/Doc/texinputs/python.sty (original) +++ python/trunk/Doc/texinputs/python.sty Thu May 25 04:42:25 2006 @@ -848,8 +848,17 @@ % but only if we actually used hyperref: \ifpdf \newcommand{\url}[1]{{% - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% - \py at LinkColor% color of the link text + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#1)% + >>% + }% + \py at LinkColor% color of the link text \py at smallsize\sf #1% \py at NormalColor% Turn it back off; these are declarative \pdfendlink}% and don't appear bound to the current @@ -925,7 +934,16 @@ \ifpdf \newcommand{\ulink}[2]{{% % For PDF, we *should* only generate a link when the URL is absolute. - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#2)% + >>% + }% \py at LinkColor% color of the link text #1% \py at NormalColor% Turn it back off; these are declarative From python-checkins at python.org Thu May 25 04:45:39 2006 From: python-checkins at python.org (fred.drake) Date: Thu, 25 May 2006 04:45:39 +0200 (CEST) Subject: [Python-checkins] r46206 - in python/branches/release24-maint/Doc: ACKS texinputs/python.sty Message-ID: <20060525024539.BCACB1E400A@bag.python.org> Author: fred.drake Date: Thu May 25 04:45:39 2006 New Revision: 46206 Modified: python/branches/release24-maint/Doc/ACKS python/branches/release24-maint/Doc/texinputs/python.sty Log: fix broken links in PDF (SF patch #1281291, contributed by Rory Yorke) Modified: python/branches/release24-maint/Doc/ACKS ============================================================================== --- python/branches/release24-maint/Doc/ACKS (original) +++ python/branches/release24-maint/Doc/ACKS Thu May 25 04:45:39 2006 @@ -192,6 +192,7 @@ Steven Work Thomas Wouters Ka-Ping Yee +Rory Yorke Moshe Zadka Milan Zamazal Cheng Zhang Modified: python/branches/release24-maint/Doc/texinputs/python.sty ============================================================================== --- python/branches/release24-maint/Doc/texinputs/python.sty (original) +++ python/branches/release24-maint/Doc/texinputs/python.sty Thu May 25 04:45:39 2006 @@ -869,8 +869,17 @@ % but only if we actually used hyperref: \ifpdf \newcommand{\url}[1]{{% - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% - \py at LinkColor% color of the link text + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#1)% + >>% + }% + \py at LinkColor% color of the link text \py at smallsize\sf #1% \py at NormalColor% Turn it back off; these are declarative \pdfendlink}% and don't appear bound to the current @@ -946,7 +955,16 @@ \ifpdf \newcommand{\ulink}[2]{{% % For PDF, we *should* only generate a link when the URL is absolute. - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#2)% + >>% + }% \py at LinkColor% color of the link text #1% \py at NormalColor% Turn it back off; these are declarative From buildbot at python.org Thu May 25 05:18:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 03:18:32 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060525031832.8A2A21E400A@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/103 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: fred.drake Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 05:55:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 03:55:28 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.4 Message-ID: <20060525035528.2B9C81E400A@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%25202.4/builds/133 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: fred.drake Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Thu May 25 08:31:29 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 25 May 2006 08:31:29 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> Message-ID: <44754F41.9030700@v.loewis.de> Tim Peters wrote: > LOL -- figures ;-) I haven't used it myself, so can't guess without > seeing the code. Best guess is that you passed a process handle for > some _other_ process (easy to screw up on Windows, because process ids > and process handles aren't the same things). Actually, that can't happen: to get a process handle, you either need to be creator of the process (CreateProcess gives you both the process id and a process handle), or you must have called OpenProcess. If you pass an arbitrary integer, you likely get an "invalid handle" error. > time.clock() has sub-microsecond resolution (better than a millionth > of a second) on all flavors of Windows. Are you sure about that? It has a *scale* of sub-microseconds (100ns); the resolution is unspecified. clock() uses GetSystemTimeAsFileTime(). This likely reads some kernel variable, and I very much doubt that this kernel variable is updated every 100ns. For example, in http://groups.google.com/group/microsoft.public.win2000.applications/msg/6fba505a7c8ca122?dmode=source somebody claims that you can get only roughly 10ms resolution with that function. More generally, I would expect that this function has the resolution equal to the timer resolution: http://www.sysinternals.com/Information/HighResolutionTimers.html To get a finer time measurement, you should use QueryPerformanceCounter. On x86 processors that support it, this uses rdtsc to fetch the time-stamping counter: http://www.lochan.org/2005/keith-cl/useful/win32time.html Regards, Martin From martin at v.loewis.de Thu May 25 08:35:11 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 25 May 2006 08:35:11 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <44743C3D.2000409@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44743C3D.2000409@egenix.com> Message-ID: <4475501F.1030106@v.loewis.de> M.-A. Lemburg wrote: > I did the next best thing: > > win32process.GetProcessTimes(win32process.GetCurrentProcess()) > > Looking at the win32 docs, the GetCurrentProcess() returns an > int where GetProcessTimes() wants a PyHANDLE. > > Shouldn't have known better though to actually *look* at > the return value of GetCurrentProcess(): > > -1 > > Looks like I should have used OpenProcess() instead. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getcurrentprocess.asp The process handle -1 *does* denote the current process; you don't need to open your own process. Regards, Martin From nnorwitz at gmail.com Thu May 25 09:12:41 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 25 May 2006 00:12:41 -0700 Subject: [Python-checkins] r46173 - python/trunk/Objects/unicodeobject.c In-Reply-To: <20060524142812.2F0081E401B@bag.python.org> References: <20060524142812.2F0081E401B@bag.python.org> Message-ID: Since fastcount() can return i which is a Py_ssize_t, fastcount() should return Py_ssize_t rather than int. Also, count needs to be a Py_ssize_t. See below for another comment. On 5/24/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Wed May 24 16:28:11 2006 > New Revision: 46173 > > > Modified: python/trunk/Objects/unicodeobject.c > ============================================================================== > --- python/trunk/Objects/unicodeobject.c (original) > +++ python/trunk/Objects/unicodeobject.c Wed May 24 16:28:11 2006 > @@ -3848,7 +3848,94 @@ > > /* --- Helpers ------------------------------------------------------------ */ > > -static Py_ssize_t count(PyUnicodeObject *self, > +#define USE_FAST /* experimental fast search implementation */ > + > +/* fast search/count implementation, based on a mix between boyer- > + moore and horspool, with a few more bells and whistles on the top. > + for some more background, see: http://effbot.org/stringlib */ > + > +#define FAST_COUNT 0 > +#define FAST_SEARCH 1 > + > +LOCAL(int) fastsearch(Py_UNICODE* s, Py_ssize_t n, > + Py_UNICODE* p, Py_ssize_t m, > + int mode) Should be static? Return Py_ssize_t instead of int? > +{ > + long mask; > + int skip, count = 0; count should be Py_ssize_t, also no need to init here, though it's probably not worth removing since it adds code below. > + Py_ssize_t i, j, mlast, w; > + w = n - m; > + > + if (w < 0) > + return -1; Move init of w and check below special case. Also, if we are doing a count, do we really want to return -1? u''.count(u'a') isn't an error. I'm not sure how the rest of things are handled, so maybe this is ok. > + /* look for special cases */ > + if (m <= 1) { m == 1 per amk's mail? > + if (m < 0) > + return -1; If the real check is for m == 1, this check for m < 0 is not necessary. > + /* use special case for 1-character strings */ > + if (mode == FAST_COUNT) { count = 0; // if not init above > + for (i = 0; i < n; i++) > + if (s[i] == p[0]) > + count++; > + return count; > + } else { > + for (i = 0; i < n; i++) > + if (s[i] == p[0]) > + return i; > + } > + return -1; > + } set w here and check for < 0. count = 0; // if not init above + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else { + i = i + skip; + continue; continue isn't necessary here. Sorry, it's late and I realize this msg is kinda cryptic. Hope you can decipher. n From python-checkins at python.org Thu May 25 10:14:04 2006 From: python-checkins at python.org (richard.jones) Date: Thu, 25 May 2006 10:14:04 +0200 (CEST) Subject: [Python-checkins] r46207 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060525081404.045711E400A@bag.python.org> Author: richard.jones Date: Thu May 25 10:14:03 2006 New Revision: 46207 Added: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (contents, props changed) Log: just a checkpoint I should have done last night Added: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- (empty file) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Thu May 25 10:14:03 2006 @@ -0,0 +1,799 @@ + +/* + * BaseException + */ +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; +} BaseExceptionObject; + +static int +BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +{ + /* we just want to store off the args as they are */ + self->args = args; + Py_INCREF(args); + + if (PySequence_Length(args) == 1) + self->message = PySequence_GetItem(args, 0); + else + self->message = PyString_FromString(""); + + return 0; +} + +static void +BaseException_dealloc(BaseExceptionObject *self) +{ + Py_DECREF(self->args); + Py_DECREF(self->message); +} + + +static PyObject * +BaseException_str(BaseExceptionObject *self) +{ + PyObject *out; + + switch (PySequence_Size(self->args)) { + case 0: + out = PyString_FromString(""); + break; + case 1: + { + PyObject *tmp = PySequence_GetItem(self->args, 0); + if (tmp) { + out = PyObject_Str(tmp); + Py_DECREF(tmp); + } + else + out = NULL; + break; + } + case -1: + PyErr_Clear(); + /* Fall through */ + default: + out = PyObject_Str(self->args); + break; + } + + return out; +} + + +#ifdef Py_USING_UNICODE +static PyObject * +BaseException_unicode(PyObject *self, PyObject *args) +{ + Py_ssize_t args_len; + + if (!PyArg_ParseTuple(args, "O:__unicode__", &self)) + return NULL; + + args_len = PySequence_Size(self->args); + if (args_len < 0) { + return NULL; + } + + if (args_len == 0) { + return PyUnicode_FromUnicode(NULL, 0); + } + else if (args_len == 1) { + PyObject *temp = PySequence_GetItem(self->args, 0); + PyObject *unicode_obj; + + if (!temp) { + return NULL; + } + unicode_obj = PyObject_Unicode(temp); + Py_DECREF(temp); + return unicode_obj; + } + else { + PyObject *unicode_obj = PyObject_Unicode(self->args); + + return unicode_obj; + } +} +#endif /* Py_USING_UNICODE */ + +static PyObject * +BaseException_repr(PyObject *self) +{ + Py_ssize_t args_len; + PyObject *repr_suffix; + PyObject *repr; + + if (!PyArg_ParseTuple(args, "O:__repr__", &self)) + return NULL; + + args_len = PySequence_Length(self->args); + if (args_len < 0) { + return NULL; + } + + if (args_len == 0) { + repr_suffix = PyString_FromString("()"); + if (!repr_suffix) + return NULL; + } + else { + PyObject *args_repr = PyObject_Repr(self->args); + if (!args_repr) + return NULL; + + repr_suffix = args_repr; + } + + repr = PyString_FromString(self->ob_type->tp_name); + if (!repr) { + Py_DECREF(repr_suffix); + return NULL; + } + + PyString_ConcatAndDel(&repr, repr_suffix); + return repr; +} + +static PyObject * +BaseException_getitem(PyObject *self, PyObject *args) +{ + PyObject *out; + PyObject *index; + + if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) + return NULL; + + return PyObject_GetItem(self->args, index); +} + +static PySequenceMethods BaseException_as_sequence = { + 0 sq_length; + 0 sq_concat; + 0 sq_repeat; + BaseException_getitem sq_item; + 0 sq_slice; + 0 sq_ass_item; + 0 sq_ass_slice; + 0 sq_contains; + 0 sq_inplace_concat; + 0 sq_inplace_repeat; +}; + +static PyMemberDef BaseException_members[] = { + {"args", T_OBJECT, offsetof(BaseExceptionObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, "exception message"}, + {NULL} /* Sentinel */ +}; + +static PyMethodDef BaseException_methods[] = { + {"__unicode__", (PyCFunction)BaseException_unicode, METH_O }, + {NULL, NULL, 0, NULL}, +}; + +static PyTypeObject BaseExceptionType = { + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "exceptions.BaseException", /*tp_name*/ + sizeof(BaseExceptionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + BaseException_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + (reprfunc)BaseException_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + &BaseException_as_sequence, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + (reprfunc)BaseException_str, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "Common base class for all exceptions", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BaseException_methods, /* tp_methods */ + BaseException_members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BaseException_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +#define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \ +static PyTypeObject EXCNAMEType = { \ + PyObject_HEAD_INIT(NULL) \ + 0, \ + "exceptions.EXCNAME", \ + sizeof(BaseExceptionObject), \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ + EXCDOC, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, &EXCBASE, \ + 0, 0, 0, 0, 0, 0, 0,\ +}; + +#define ComplexExtendsException(EXCBASE, EXCNAME, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCINIT, EXCNEW, EXCSTR, EXCDOC) \ +static PyTypeObject EXCNAMEType = { \ + PyObject_HEAD_INIT(NULL) \ + 0, \ + "exceptions.EXCNAME", \ + sizeof(EXCNAMEObject), \ + 0, EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, EXCSTR, 0, 0, 0, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ + EXCDOC, \ + 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &EXCBASE, \ + 0, 0, 0, 0, EXCINIT, 0, EXCNEW,\ +}; + + +/* + * Exception extends BaseException + */ +SimpleExtendsException(BaseExceptionType, Exception, "Common base class for all non-exit exceptions.") + + +/* + * StandardError extends Exception + */ +SimpleExtendsException(ExceptionType, StandardError, +"Base class for all standard Python exceptions that do not represent" +"interpreter exiting."); + + +/* + * TypeError extends StandardError + */ +SimpleExtendsException(StandardErrorType, TypeError, "Inappropriate argument type."); + + +/* + * StopIteration extends Exception + */ +SimpleExtendsException(ExceptionType, StopIteration, "Signal the end from iterator.next()."); + + +/* + * GeneratorExit extends Exception + */ +SimpleExtendsException(ExceptionType, GeneratorExit, "Request that a generator exit."); + + +/* + * SystemExit extends BaseException + */ +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *code; +} SystemExitObject; + +static int +SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) +{ + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; + + if (PySequence_Length(args) == 1) + self->code = PySequence_GetItem(args, 0); + else { + self->code = Py_None; + Py_INCREF(Py_None); + } + + return 0; +} + +static void +SystemExit_dealloc(SystemExitObject *self) +{ + BaseException_dealloc((BaseExceptionObject *)self); + Py_DECREF(self->code); +} + +static PyMemberDef SystemExit_members[] = { + {"args", T_OBJECT, offsetof(SystemExitObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, "exception message"}, + {"code", T_OBJECT, offsetof(SystemExitObject, code), 0, "exception code"}, + {NULL} /* Sentinel */ +}; + +ComplexExtendsException(BaseExceptionType, SystemExit, SystemExit_dealloc, 0, SystemExit_members, SystemExit_init, 0, "Request to exit from the interpreter."); + + +/* + * KeyboardInterrupt extends BaseException + */ +SimpleExtendsException(BaseExceptionType, KeyboardInterrupt, "Program interrupted by user."); + + +/* + * ImportError extends StandardError + */ +SimpleExtendsException(StandardErrorType, ImportError, "Import can't find module, or can't find name in module."); + + +/* + * EnvironmentError extends StandardError + */ +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *errno; + PyObject *strerror; + PyObject *filename; +} EnvironmentErrorObject; + +static int +EnvironmentError_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *subslice = NULL; + + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; + + self->errno = Py_None; + Py_INCREF(Py_None); + self->strerror = Py_None; + Py_INCREF(Py_None); + self->filename = Py_None; + Py_INCREF(Py_None); + + switch (PySequence_Size(args)) { + case 3: + /* Where a function has a single filename, such as open() or some + * of the os module functions, PyErr_SetFromErrnoWithFilename() is + * called, giving a third argument which is the filename. But, so + * that old code using in-place unpacking doesn't break, e.g.: + * + * except IOError, (errno, strerror): + * + * we hack args so that it only contains two items. This also + * means we need our own __str__() which prints out the filename + * when it was supplied. + */ + self->errno = PySequence_GetItem(args, 0); + if (!self->errno) goto finally; + self->strerror = PySequence_GetItem(args, 1); + if (!self->strerror) goto finally; + self->filename = PySequence_GetItem(args, 2); + if (!self->filename) goto finally; + + subslice = PySequence_GetSlice(args, 0, 2); + if (!subslice) + goto finally; + + Py_DECREF(self->args); /* drop old ref set by base class init */ + self->args = subslice; + return 0; + + case 2: + /* Used when PyErr_SetFromErrno() is called and no filename + * argument is given. + */ + self->errno = PySequence_GetItem(args, 0); + if (!self->errno) goto finally; + self->strerror = PySequence_GetItem(args, 1); + if (!self->strerror) goto finally; + return 0; + + case -1: + PyErr_Clear(); + return 0; + } + + finally: + Py_XDECREF(subslice); + Py_XDECREF(self->errno); + Py_XDECREF(self->strerror); + Py_XDECREF(self->filename); + return -1; +} + +static void +EnvironmentError_dealloc(EnvironmentErrorObject *self) +{ + BaseException_dealloc((BaseExceptionObject *)self); + Py_DECREF(self->errno); + Py_DECREF(self->strerror); + Py_DECREF(self->filename); +} + +static PyObject * +EnvironmentError_str(PyObject *self) +{ + PyObject *rtnval = NULL; + + if (filename != Py_None) { + PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); + PyObject *repr = PyObject_Repr(self->filename); + PyObject *tuple = PyTuple_New(3); + + if (!fmt || !repr || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(repr); + Py_XDECREF(tuple); + return NULL; + } + + PyTuple_SET_ITEM(tuple, 0, serrno); + PyTuple_SET_ITEM(tuple, 1, strerror); + PyTuple_SET_ITEM(tuple, 2, repr); + + rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); + Py_DECREF(tuple); + /* already freed because tuple owned only reference */ + serrno = NULL; + strerror = NULL; + } + else if (PyObject_IsTrue(self->errno) && PyObject_IsTrue(self->strerror)) { + PyObject *fmt = PyString_FromString("[Errno %s] %s"); + PyObject *tuple = PyTuple_New(2); + + if (!fmt || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(tuple); + goto finally; + } + + PyTuple_SET_ITEM(tuple, 0, self->errno); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + + rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); + Py_DECREF(tuple); + } + else + rtnval = BaseException_str_(self); + + return rtnval; +} + +static PyMemberDef EnvironmentError_members[] = { + {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, "exception message"}, + {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, errno), 0, "exception code"}, + {"strerror", T_OBJECT, offsetof(EnvironmentErrorObject, strerror), 0, "exception code"}, + {"filename", T_OBJECT, offsetof(EnvironmentErrorObject, filename), 0, "exception code"}, + {NULL} /* Sentinel */ +}; + +ComplexExtendsException(StandardErrorType, EnvironmentError, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_init, EnvironmentError_str, "Base class for I/O related errors."); + + +/* + * IOError extends EnvironmentError + */ +SimpleExtendsException(EnvironmentErrorType, IOError, "I/O operation failed."); + + +/* + * OSError extends EnvironmentError + */ +SimpleExtendsException(EnvironmentErrorType, OSError, "OS system call failed."); + + +/* + * WindowsError extends OSError + */ +#ifdef MS_WINDOWS +#include "errmap.h" + +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *errno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; +} WindowsErrorObject; + +static int +WindowsError_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *o_errcode = NULL; + long posix_errno; + + if (EnvironmentError_init(self, args, kwds) == -1 ) + return -1; + + /* Set errno to the POSIX errno, and winerror to the Win32 + error code. */ + errcode = PyInt_AsLong(self->errno); + if (!errcode == -1 && PyErr_Occurred()) + goto failed; + posix_errno = winerror_to_errno(errcode); + + self->winerror = self->errno; + + o_errcode = PyInt_FromLong(posix_errno); + if (!o_errcode) + goto failed; + + self->errno = o_errcode; + + return 0; +failed: + /* Could not set errno. */ + Py_XDECREF(o_errcode); + return -1; +} + + +static PyObject * +WindowsError_str(PyObject *self) +{ + PyObject *repr = NULL; + PyObject *fmt = NULL; + PyObject *tuple = NULL; + PyObject *rtnval = NULL; + + if (self->filename != Py_None) { + fmt = PyString_FromString("[Error %s] %s: %s"); + repr = PyObject_Repr(self->filename); + if (!fmt || !repr) + goto finally; + + tuple = PyTuple_Pack(3, sellf->errno, self->strerror, repr); + if (!tuple) + goto finally; + + rtnval = PyString_Format(fmt, tuple); + } + else if (PyObject_IsTrue(self->errno) && PyObject_IsTrue(self->strerror)) { + fmt = PyString_FromString("[Error %s] %s"); + if (!fmt) + goto finally; + + tuple = PyTuple_Pack(2, self->errno, self->strerror); + if (!tuple) + goto finally; + + rtnval = PyString_Format(fmt, tuple); + } + else + rtnval = EnvironmentError_str(self); + + finally: + Py_XDECREF(filename); + Py_XDECREF(serrno); + Py_XDECREF(strerror); + Py_XDECREF(repr); + Py_XDECREF(fmt); + Py_XDECREF(tuple); + return rtnval; +} + +static PyMemberDef WindowsError_members[] = { + {"args", T_OBJECT, offsetof(WindowsErrorObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, "exception message"}, + {"errno", T_OBJECT, offsetof(WindowsErrorObject, errno), 0, "exception code"}, + {"strerror", T_OBJECT, offsetof(WindowsErrorObject, strerror), 0, "exception code"}, + {"filename", T_OBJECT, offsetof(WindowsErrorObject, filename), 0, "exception code"}, + {"winerror", T_OBJECT, offsetof(WindowsErrorObject, winerror), 0, "windows exception code"}, + {NULL} /* Sentinel */ +}; + +ComplexExtendsException(OSErrorType, WindowsError, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_init, WindowsError_str, "MS-Windows OS system call failed."); + +#endif /* MS_WINDOWS */ + + +/* + * VMSError extends OSError (I think) + */ +#ifdef __VMS +SimpleExtendsException(OSErrorType, VMSError, "OpenVMS OS system call failed."); +#endif + + +/* + * EOFError extends StandardError + */ +SimpleExtendsException(StandardErrorType, EOFError, "Read beyond end of file."); + + +/* + * RuntimeError extends StandardError + */ +SimpleExtendsException(StandardErrorType, RuntimeError, "Unspecified run-time error."); + + +/* + * NotImplementedError extends RuntimeError + */ +SimpleExtendsException(RuntimeErrorType, NotImplementedError, "Method or function hasn't been implemented yet."); + +/* + * NameError extends StandardError + */ +SimpleExtendsException(StandardErrorType, NameError, "Name not found globally."); + +/* + * UnboundLocalError extends NameError + */ +SimpleExtendsException(NameErrorType, UnboundLocalError, "Local name referenced but not bound to a value."); + +/* + * AttributeError extends StandardError + */ +SimpleExtendsException(StandardErrorType, AttributeError, "Attribute not found."); + + +/* + * SyntaxError extends StandardError + */ + +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} SyntaxErrorObject; + +static int +SyntaxError_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *info = NULL; + Py_ssize_t lenargs; + + if (BaseException_init(self, args, kwds) == -1 ) + return -1; + + self->msg = self->filename = self->lineno = self->offset = + self->text = NULL; + + /* this is always None - yes, I know it doesn't seem to be used + anywhere, but it was in the previous implementation */ + self->print_file_and_line = Py_None; + Py_INCREF(Py_None); + + lenargs = PySequence_Size(args); + if (lenargs >= 1) { + PyObject *item0 = PySequence_GetItem(args, 0); + if (!item0) goto finally; + self->msg = item0; + } + if (lenargs == 2) { + info = PySequence_GetItem(args, 1); + if (!info) goto finally; + self->filename = PySequence_GetItem(info, 0); + if (!self->filename) goto finally; + self->lineno = PySequence_GetItem(info, 1); + if (!self->lineno) goto finally; + self->offset = PySequence_GetItem(info, 2); + if (!self->offset) goto finally; + self->text = PySequence_GetItem(info, 3); + if (!self->text) goto finally; + } + return 0; + + finally: + Py_XDECREF(info); + Py_XDECREF(self->msg); + Py_XDECREF(self->filename); + Py_XDECREF(self->lineno); + Py_XDECREF(self->offset); + Py_XDECREF(self->text); + Py_XDECREF(self->print_file_and_line); + return -1; +} + + +static void +SyntaxError_dealloc(SyntaxErrorObject *self) +{ + BaseException_dealloc((BaseExceptionObject *)self); + Py_DECREF(self->code); + Py_DECREF(self->msg); + Py_DECREF(self->filename); + Py_DECREF(self->lineno); + Py_DECREF(self->offset); + Py_DECREF(self->text); + Py_DECREF(self->print_file_and_line); +} + +/* This is called "my_basename" instead of just "basename" to avoid name + conflicts with glibc; basename is already prototyped if _GNU_SOURCE is + defined, and Python does define that. */ +static char * +my_basename(char *name) +{ + char *cp = name; + char *result = name; + + if (name == NULL) + return "???"; + while (*cp != '\0') { + if (*cp == SEP) + result = cp + 1; + ++cp; + } + return result; +} + + +static PyObject * +SyntaxError_str(PyObject *self) +{ + PyObject *str; + PyObject *result; + + str = PyObject_Str(self->msg); + result = str; + + /* XXX -- do all the additional formatting with filename and + lineno here */ + + if (str != NULL && PyString_Check(str)) { + int have_filename = 0; + int have_lineno = 0; + char *buffer = NULL; + + have_filename = PyString_Check(self->filename); + have_lineno = PyInt_Check(self->lineno); + + if (have_filename || have_lineno) { + Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; + if (have_filename) + bufsize += PyString_GET_SIZE(self->filename); + + buffer = (char *)PyMem_MALLOC(bufsize); + if (buffer != NULL) { + if (have_filename && have_lineno) + PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename)), + PyInt_AsLong(self->lineno)); + else if (have_filename) + PyOS_snprintf(buffer, bufsize, "%s (%s)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename))); + else if (have_lineno) + PyOS_snprintf(buffer, bufsize, "%s (line %ld)", + PyString_AS_STRING(str), + PyInt_AsLong(self->lineno)); + + result = PyString_FromString(buffer); + PyMem_FREE(buffer); + + if (result == NULL) + result = str; + else + Py_DECREF(str); + } + } + } + return result; +} + +ComplexExtendsException(StandardErrorType, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_init, SyntaxError_str, "Invalid syntax."); + + +/* WE'RE HALF WAY! WOO! */ + From tim.peters at gmail.com Thu May 25 10:42:19 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 08:42:19 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605250136n15a9be15occ220f1adbd303a8@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44754F41.9030700@v.loewis.de> <1f7befae0605250136n15a9be15occ220f1adbd303a8@mail.gmail.com> Message-ID: <1f7befae0605250142r161a3c57ka14d1adc93275044@mail.gmail.com> [Tim] ... >> time.clock() has sub-microsecond resolution (better than a millionth >> of a second) on all flavors of Windows. [Martin v. L?wis] > Are you sure about that? It has a *scale* of sub-microseconds (100ns); > the resolution is unspecified. "Most" Windows boxes run on HW with a capable real-time counter. > clock() uses GetSystemTimeAsFileTime(). This likely reads some > kernel variable, and I very much doubt that this kernel variable > is updated every 100ns. For example, in ... Windoes clock() does, yes, but Python's time.clock() on Windows does not. See the source ;-) > ... > To get a finer time measurement, you should use QueryPerformanceCounter. > On x86 processors that support it, this uses rdtsc to fetch the > time-stamping counter: That's exactly what Python uses for time.clock() on Windows ... although I see it doesn't on Win64: #if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Win32 has better clock replacement XXX Win64 does not yet, but might when the platform matures. */ #undef HAVE_CLOCK /* We have our own version down below */ #endif /* MS_WINDOWS && !MS_WIN64 */ Do you know whether Win64 still has that limitation? From python-checkins at python.org Thu May 25 10:53:29 2006 From: python-checkins at python.org (walter.doerwald) Date: Thu, 25 May 2006 10:53:29 +0200 (CEST) Subject: [Python-checkins] r46208 - python/trunk/Python/errors.c Message-ID: <20060525085329.054451E400A@bag.python.org> Author: walter.doerwald Date: Thu May 25 10:53:28 2006 New Revision: 46208 Modified: python/trunk/Python/errors.c Log: Replace tab inside comment with space. Modified: python/trunk/Python/errors.c ============================================================================== --- python/trunk/Python/errors.c (original) +++ python/trunk/Python/errors.c Thu May 25 10:53:28 2006 @@ -785,7 +785,7 @@ break; /* fgets read *something*; if it didn't get as far as pLastChar, it must have found a newline - or hit the end of the file; if pLastChar is \n, + or hit the end of the file; if pLastChar is \n, it obviously found a newline; else we haven't yet seen a newline, so must continue */ } while (*pLastChar != '\0' && *pLastChar != '\n'); From neal at metaslash.com Thu May 25 11:09:28 2006 From: neal at metaslash.com (Neal Norwitz) Date: Thu, 25 May 2006 05:09:28 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060525090928.GA31226@python.psfb.org> test_cmd_line leaked [0, 0, -17] references test_threadedtempfile leaked [-166, 83, 0] references test_threadsignals leaked [0, -8, 0] references test_urllib2 leaked [143, -110, -33] references From buildbot at python.org Thu May 25 11:31:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 09:31:43 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060525093143.3F4B91E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/770 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: walter.doerwald Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 13:25:52 2006 From: python-checkins at python.org (thomas.wouters) Date: Thu, 25 May 2006 13:25:52 +0200 (CEST) Subject: [Python-checkins] r46209 - python/trunk/Grammar/Grammar Message-ID: <20060525112552.860561E401E@bag.python.org> Author: thomas.wouters Date: Thu May 25 13:25:51 2006 New Revision: 46209 Modified: python/trunk/Grammar/Grammar Log: Fix #1488915, Multiple dots in relative import statement raise SyntaxError. Modified: python/trunk/Grammar/Grammar ============================================================================== --- python/trunk/Grammar/Grammar (original) +++ python/trunk/Grammar/Grammar Thu May 25 13:25:51 2006 @@ -62,7 +62,7 @@ raise_stmt: 'raise' [test [',' test [',' test]]] import_stmt: import_name | import_from import_name: 'import' dotted_as_names -import_from: ('from' ('.'* dotted_name | '.') +import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) import_as_name: NAME [('as' | NAME) NAME] dotted_as_name: dotted_name [('as' | NAME) NAME] From python-checkins at python.org Thu May 25 13:26:26 2006 From: python-checkins at python.org (thomas.wouters) Date: Thu, 25 May 2006 13:26:26 +0200 (CEST) Subject: [Python-checkins] r46210 - in python/trunk: Lib/test/test_importhooks.py Python/graminit.c Message-ID: <20060525112626.3A0961E400B@bag.python.org> Author: thomas.wouters Date: Thu May 25 13:26:25 2006 New Revision: 46210 Modified: python/trunk/Lib/test/test_importhooks.py python/trunk/Python/graminit.c Log: Update graminit.c for the fix for #1488915, Multiple dots in relative import statement raise SyntaxError, and add testcase. Modified: python/trunk/Lib/test/test_importhooks.py ============================================================================== --- python/trunk/Lib/test/test_importhooks.py (original) +++ python/trunk/Lib/test/test_importhooks.py Thu May 25 13:26:25 2006 @@ -14,6 +14,7 @@ absimp = "import sub\n" relimp = "from . import sub\n" +deeprelimp = "from .... import sub\n" futimp = "from __future__ import absolute_import\n" reload_src = test_src+"""\ @@ -26,6 +27,7 @@ test2_oldabs_co = compile(absimp + test_src, "", "exec") test2_newabs_co = compile(futimp + absimp + test_src, "", "exec") test2_newrel_co = compile(relimp + test_src, "", "exec") +test2_deeprel_co = compile(deeprelimp + test_src, "", "exec") test2_futrel_co = compile(futimp + relimp + test_src, "", "exec") test_path = "!!!_test_!!!" @@ -46,10 +48,11 @@ "hooktestmodule": (False, test_co), "hooktestpackage": (True, test_co), "hooktestpackage.sub": (True, test_co), - "hooktestpackage.sub.subber": (False, test_co), + "hooktestpackage.sub.subber": (True, test_co), "hooktestpackage.oldabs": (False, test2_oldabs_co), "hooktestpackage.newabs": (False, test2_newabs_co), "hooktestpackage.newrel": (False, test2_newrel_co), + "hooktestpackage.sub.subber.subest": (True, test2_deeprel_co), "hooktestpackage.futrel": (False, test2_futrel_co), "sub": (False, test_co), "reloadmodule": (False, test_co), @@ -203,6 +206,12 @@ self.assertEqual(hooktestpackage.newrel.sub, hooktestpackage.sub) + import hooktestpackage.sub.subber.subest as subest + self.assertEqual(subest.get_name(), + "hooktestpackage.sub.subber.subest") + self.assertEqual(subest.sub, + hooktestpackage.sub) + import hooktestpackage.futrel self.assertEqual(hooktestpackage.futrel.get_name(), "hooktestpackage.futrel") Modified: python/trunk/Python/graminit.c ============================================================================== --- python/trunk/Python/graminit.c (original) +++ python/trunk/Python/graminit.c Thu May 25 13:26:25 2006 @@ -517,41 +517,36 @@ {12, 3}, }; static arc arcs_26_2[3] = { - {75, 4}, + {75, 2}, {12, 3}, - {72, 5}, + {72, 4}, }; static arc arcs_26_3[1] = { - {72, 5}, + {72, 4}, }; -static arc arcs_26_4[2] = { - {75, 4}, - {12, 3}, +static arc arcs_26_4[3] = { + {28, 5}, + {13, 6}, + {76, 5}, }; -static arc arcs_26_5[3] = { - {28, 6}, - {13, 7}, - {76, 6}, +static arc arcs_26_5[1] = { + {0, 5}, }; static arc arcs_26_6[1] = { - {0, 6}, + {76, 7}, }; static arc arcs_26_7[1] = { - {76, 8}, -}; -static arc arcs_26_8[1] = { - {15, 6}, + {15, 5}, }; -static state states_26[9] = { +static state states_26[8] = { {1, arcs_26_0}, {2, arcs_26_1}, {3, arcs_26_2}, {1, arcs_26_3}, - {2, arcs_26_4}, - {3, arcs_26_5}, + {3, arcs_26_4}, + {1, arcs_26_5}, {1, arcs_26_6}, {1, arcs_26_7}, - {1, arcs_26_8}, }; static arc arcs_27_0[1] = { {19, 1}, @@ -1839,7 +1834,7 @@ "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000"}, {281, "import_name", 0, 3, states_25, "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, - {282, "import_from", 0, 9, states_26, + {282, "import_from", 0, 8, states_26, "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, {283, "import_as_name", 0, 4, states_27, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, From buildbot at python.org Thu May 25 13:36:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 11:36:41 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060525113641.A89621E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/461 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: thomas.wouters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 13:54:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 11:54:58 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060525115458.ADF361E400B@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/768 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: thomas.wouters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 14:27:59 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 14:27:59 +0200 (CEST) Subject: [Python-checkins] r46211 - python/trunk/Misc/developers.txt Message-ID: <20060525122759.E29E11E400B@bag.python.org> Author: andrew.kuchling Date: Thu May 25 14:27:59 2006 New Revision: 46211 Modified: python/trunk/Misc/developers.txt Log: Add entry; and fix a typo Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Thu May 25 14:27:59 2006 @@ -17,6 +17,12 @@ Permissions History ------------------- +- 2006 Summer of Code entries: Matt Fleming was added on 25 May 2006 + by AMK; he'll be working on enhancing the Python debugger. SoC + developers are expected to work primarily in nondist/sandbox or on a + branch of their own, and will have their work reviewed before + changes are accepted into the trunk. + - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. @@ -40,7 +46,7 @@ - Added two new developers for the Summer of Code project. 8 July 2005 by RDH. Andrew Kuchling will be mentoring Gregory K Johnson for a - project to enchance mailbox. Brett Cannon requested access for Flovis + project to enhance mailbox. Brett Cannon requested access for Flovis Bruynooghe (sirolf) to work on pstats, profile, and hotshot. Both users are expected to work primarily in nondist/sandbox and have their work reviewed before making updates to active code. From buildbot at python.org Thu May 25 14:44:54 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 12:44:54 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060525124454.9E8861E400B@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/181 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: thomas.wouters Build Had Warnings: warnings test sincerely, -The Buildbot From tim.peters at gmail.com Thu May 25 16:00:34 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 14:00:34 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605250655g2e33c3ffkad142b3afc94e637@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44754F41.9030700@v.loewis.de> <1f7befae0605250136n15a9be15occ220f1adbd303a8@mail.gmail.com> <44757BE7.2060609@v.loewis.de> <1f7befae0605250655g2e33c3ffkad142b3afc94e637@mail.gmail.com> Message-ID: <1f7befae0605250700w7fcfa08aoee58470a764a3485@mail.gmail.com> [Tim] >> That's exactly what Python uses for time.clock() on Windows ... >> although I see it doesn't on Win64: >> >> #if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) >> /* Win32 has better clock replacement >> XXX Win64 does not yet, but might when the platform matures. */ >> #undef HAVE_CLOCK /* We have our own version down below */ >> #endif /* MS_WINDOWS && !MS_WIN64 */ >> >> Do you know whether Win64 still has that limitation? [Martin] > I'm surprised it ever did. Atleast on my IA64 W2k3 installation, > kernel32.dll exports QueryPerformanceCounter, and I can call it > successfully. > > Now, I don't know how that is implemented on that hardware, and > I'm certain the implementation is different on IA64 than on > AMD64. Perhaps Trent didn't use it not because it wasn't available, > but because it had some defect? So let's ask him :-) Trent, do you know whether the reason you had at the time for excluding MS_WIN64 (see above) still applies? I'm guessing it's because you were using a very early Win64 pre-release, and the reason actually went way long ago. I'm guessing that because it's the best outcome ;-) From python-checkins at python.org Thu May 25 16:25:42 2006 From: python-checkins at python.org (martin.blais) Date: Thu, 25 May 2006 16:25:42 +0200 (CEST) Subject: [Python-checkins] r46212 - in python/branches/blais-bytebuf: Doc/ACKS Doc/texinputs/python.sty Doc/whatsnew/whatsnew25.tex Grammar/Grammar Lib/hotbuf.py Lib/struct.py Lib/test/string_tests.py Lib/test/test_builtin.py Lib/test/test_hotbuf.py Lib/test/test_importhooks.py Misc/NEWS Misc/developers.txt Modules/_hotbuf.c Objects/longobject.c Python/errors.c Python/graminit.c Message-ID: <20060525142542.5ED651E400C@bag.python.org> Author: martin.blais Date: Thu May 25 16:25:38 2006 New Revision: 46212 Modified: python/branches/blais-bytebuf/Doc/ACKS python/branches/blais-bytebuf/Doc/texinputs/python.sty python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex python/branches/blais-bytebuf/Grammar/Grammar python/branches/blais-bytebuf/Lib/hotbuf.py python/branches/blais-bytebuf/Lib/struct.py python/branches/blais-bytebuf/Lib/test/string_tests.py python/branches/blais-bytebuf/Lib/test/test_builtin.py python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Lib/test/test_importhooks.py python/branches/blais-bytebuf/Misc/NEWS python/branches/blais-bytebuf/Misc/developers.txt python/branches/blais-bytebuf/Modules/_hotbuf.c python/branches/blais-bytebuf/Objects/longobject.c python/branches/blais-bytebuf/Python/errors.c python/branches/blais-bytebuf/Python/graminit.c Log: Update bytebuf branch to 46211 Modified: python/branches/blais-bytebuf/Doc/ACKS ============================================================================== --- python/branches/blais-bytebuf/Doc/ACKS (original) +++ python/branches/blais-bytebuf/Doc/ACKS Thu May 25 16:25:38 2006 @@ -195,6 +195,7 @@ Steven Work Thomas Wouters Ka-Ping Yee +Rory Yorke Moshe Zadka Milan Zamazal Cheng Zhang Modified: python/branches/blais-bytebuf/Doc/texinputs/python.sty ============================================================================== --- python/branches/blais-bytebuf/Doc/texinputs/python.sty (original) +++ python/branches/blais-bytebuf/Doc/texinputs/python.sty Thu May 25 16:25:38 2006 @@ -848,8 +848,17 @@ % but only if we actually used hyperref: \ifpdf \newcommand{\url}[1]{{% - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% - \py at LinkColor% color of the link text + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#1)% + >>% + }% + \py at LinkColor% color of the link text \py at smallsize\sf #1% \py at NormalColor% Turn it back off; these are declarative \pdfendlink}% and don't appear bound to the current @@ -925,7 +934,16 @@ \ifpdf \newcommand{\ulink}[2]{{% % For PDF, we *should* only generate a link when the URL is absolute. - \py at pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% + \py at pdfstartlink% + attr{ /Border [0 0 0] }% + user{% + /Subtype/Link% + /A<<% + /Type/Action% + /S/URI% + /URI(#2)% + >>% + }% \py at LinkColor% color of the link text #1% \py at NormalColor% Turn it back off; these are declarative Modified: python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/blais-bytebuf/Doc/whatsnew/whatsnew25.tex Thu May 25 16:25:38 2006 @@ -512,9 +512,9 @@ \exception{GeneratorExit} or \exception{StopIteration}; catching the exception and doing anything else is illegal and will trigger a \exception{RuntimeError}. \method{close()} will also be called by - Python's garbage collection when the generator is garbage-collected. + Python's garbage collector when the generator is garbage-collected. - If you need to run cleanup code in case of a \exception{GeneratorExit}, + If you need to run cleanup code when a \exception{GeneratorExit} occurs, I suggest using a \code{try: ... finally:} suite instead of catching \exception{GeneratorExit}. @@ -1143,6 +1143,13 @@ sprint. Character map decoding was improved by Walter D\"orwald.) % Patch 1313939 +\item The \function{long(\var{str}, \var{base})} function is now +faster on long digit strings because fewer intermediate results are +calculated. The peak is for strings of around 800--1000 digits where +the function is 6 times faster. +(Contributed by Alan McIntyre and committed at the NeedForSpeed sprint.) +% Patch 1442927 + \item The \module{struct} module now compiles structure format strings into an internal representation and caches this representation, yielding a 20\% speedup. (Contributed by Bob Ippolito Modified: python/branches/blais-bytebuf/Grammar/Grammar ============================================================================== --- python/branches/blais-bytebuf/Grammar/Grammar (original) +++ python/branches/blais-bytebuf/Grammar/Grammar Thu May 25 16:25:38 2006 @@ -62,7 +62,7 @@ raise_stmt: 'raise' [test [',' test [',' test]]] import_stmt: import_name | import_from import_name: 'import' dotted_as_names -import_from: ('from' ('.'* dotted_name | '.') +import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) import_as_name: NAME [('as' | NAME) NAME] dotted_as_name: dotted_name [('as' | NAME) NAME] Modified: python/branches/blais-bytebuf/Lib/hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/hotbuf.py Thu May 25 16:25:38 2006 @@ -5,8 +5,20 @@ """ from _hotbuf import _hotbuf +from struct import Struct + +_long = Struct('l') class hotbuf(_hotbuf): - pass + + def getlong( self ): + r = _long.unpack_from(self, 0) + self.setposition(self.position + _long.size) + return r + +## def putlong( self ): +## s = _long.pack(0) +## self.setposition(self.position + _long.size) +## return Modified: python/branches/blais-bytebuf/Lib/struct.py ============================================================================== --- python/branches/blais-bytebuf/Lib/struct.py (original) +++ python/branches/blais-bytebuf/Lib/struct.py Thu May 25 16:25:38 2006 @@ -73,7 +73,7 @@ except KeyError: o = _compile(fmt) return o.unpack(s) - + def unpack_from(fmt, buf, offset=0): """ Unpack the buffer, containing packed C structure data, according to @@ -84,4 +84,4 @@ o = _cache[fmt] except KeyError: o = _compile(fmt) - return o.unpack_from(buf, offset) \ No newline at end of file + return o.unpack_from(buf, offset) Modified: python/branches/blais-bytebuf/Lib/test/string_tests.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/string_tests.py (original) +++ python/branches/blais-bytebuf/Lib/test/string_tests.py Thu May 25 16:25:38 2006 @@ -376,6 +376,158 @@ self.checkraises(TypeError, 'hello', 'swapcase', 42) def test_replace(self): + EQ = self.checkequal + + # Operations on the empty string + EQ("", "", "replace", "", "") + + #EQ("A", "", "replace", "", "A") + # That was the correct result; this is the result we actually get + # now (for str, but not for unicode): + #EQ("", "", "replace", "", "A") + + EQ("", "", "replace", "A", "") + EQ("", "", "replace", "A", "A") + EQ("", "", "replace", "", "", 100) + EQ("", "", "replace", "", "", sys.maxint) + + # interleave (from=="", 'to' gets inserted everywhere) + EQ("A", "A", "replace", "", "") + EQ("*A*", "A", "replace", "", "*") + EQ("*1A*1", "A", "replace", "", "*1") + EQ("*-#A*-#", "A", "replace", "", "*-#") + EQ("*-A*-A*-", "AA", "replace", "", "*-") + EQ("*-A*-A*-", "AA", "replace", "", "*-", -1) + EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 4) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 3) + EQ("*-A*-A", "AA", "replace", "", "*-", 2) + EQ("*-AA", "AA", "replace", "", "*-", 1) + EQ("AA", "AA", "replace", "", "*-", 0) + + # single character deletion (from=="A", to=="") + EQ("", "A", "replace", "A", "") + EQ("", "AAA", "replace", "A", "") + EQ("", "AAA", "replace", "A", "", -1) + EQ("", "AAA", "replace", "A", "", sys.maxint) + EQ("", "AAA", "replace", "A", "", 4) + EQ("", "AAA", "replace", "A", "", 3) + EQ("A", "AAA", "replace", "A", "", 2) + EQ("AA", "AAA", "replace", "A", "", 1) + EQ("AAA", "AAA", "replace", "A", "", 0) + EQ("", "AAAAAAAAAA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "", -1) + EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint) + EQ("BCD", "ABACADA", "replace", "A", "", 5) + EQ("BCD", "ABACADA", "replace", "A", "", 4) + EQ("BCDA", "ABACADA", "replace", "A", "", 3) + EQ("BCADA", "ABACADA", "replace", "A", "", 2) + EQ("BACADA", "ABACADA", "replace", "A", "", 1) + EQ("ABACADA", "ABACADA", "replace", "A", "", 0) + EQ("BCD", "ABCAD", "replace", "A", "") + EQ("BCD", "ABCADAA", "replace", "A", "") + EQ("BCD", "BCD", "replace", "A", "") + EQ("*************", "*************", "replace", "A", "") + EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999) + + # substring deletion (from=="the", to=="") + EQ("", "the", "replace", "the", "") + EQ("ater", "theater", "replace", "the", "") + EQ("", "thethe", "replace", "the", "") + EQ("", "thethethethe", "replace", "the", "") + EQ("aaaa", "theatheatheathea", "replace", "the", "") + EQ("that", "that", "replace", "the", "") + EQ("thaet", "thaet", "replace", "the", "") + EQ("here and re", "here and there", "replace", "the", "") + EQ("here and re and re", "here and there and there", + "replace", "the", "", sys.maxint) + EQ("here and re and re", "here and there and there", + "replace", "the", "", -1) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 3) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 2) + EQ("here and re and there", "here and there and there", + "replace", "the", "", 1) + EQ("here and there and there", "here and there and there", + "replace", "the", "", 0) + EQ("here and re and re", "here and there and there", "replace", "the", "") + + EQ("abc", "abc", "replace", "the", "") + EQ("abcdefg", "abcdefg", "replace", "the", "") + + # substring deletion (from=="bob", to=="") + EQ("bob", "bbobob", "replace", "bob", "") + EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "") + + # single character replace in place (len(from)==len(to)==1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "o") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2) + EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0) + + EQ("Who goes there?", "Who goes there?", "replace", "a", "q") + EQ("who goes there?", "Who goes there?", "replace", "W", "w") + EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w") + EQ("Who goes there!", "Who goes there?", "replace", "?", "!") + EQ("Who goes there!!", "Who goes there??", "replace", "?", "!") + + EQ("Who goes there?", "Who goes there?", "replace", ".", "!") + + # substring replace in place (len(from)==len(to) > 1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3) + EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2) + EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1) + EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0) + EQ("cobob", "bobob", "replace", "bob", "cob") + EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob") + EQ("bobob", "bobob", "replace", "bot", "bot") + + # replace single character (len(from)==1, len(to)>1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK") + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2) + EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) + EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) + EQ("A----B----C----", "A.B.C.", "replace", ".", "----") + + EQ("Reykjavik", "Reykjavik", "replace", "q", "KK") + + # replace substring (len(from)>1, len(to)!=len(from)) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham") + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", sys.maxint) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", -1) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 4) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 3) + EQ("ham, ham, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 2) + EQ("ham, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 1) + EQ("spam, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 0) + + EQ("bobob", "bobobob", "replace", "bobob", "bob") + EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") + EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") + + # self.checkequal('one at two!three!', 'one!two!three!', 'replace', '!', '@', 1) self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '') self.checkequal('one at two@three!', 'one!two!three!', 'replace', '!', '@', 2) @@ -403,6 +555,16 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) +### Commented out until the underlying libraries are fixed +## def test_replace_overflow(self): +## # Check for overflow checking on 32 bit machines +## if sys.maxint != 2147483647: +## return +## A2_16 = "A" * (2**16) +## self.checkraises(OverflowError, A2_16, "replace", "", A2_16) +## self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) +## self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) + def test_zfill(self): self.checkequal('123', '123', 'zfill', 2) self.checkequal('123', '123', 'zfill', 3) Modified: python/branches/blais-bytebuf/Lib/test/test_builtin.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_builtin.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_builtin.py Thu May 25 16:25:38 2006 @@ -980,6 +980,81 @@ self.assertRaises(ValueError, long, '53', 40) self.assertRaises(TypeError, long, 1, 12) + self.assertEqual(long('100000000000000000000000000000000', 2), + 4294967296) + self.assertEqual(long('102002022201221111211', 3), 4294967296) + self.assertEqual(long('10000000000000000', 4), 4294967296) + self.assertEqual(long('32244002423141', 5), 4294967296) + self.assertEqual(long('1550104015504', 6), 4294967296) + self.assertEqual(long('211301422354', 7), 4294967296) + self.assertEqual(long('40000000000', 8), 4294967296) + self.assertEqual(long('12068657454', 9), 4294967296) + self.assertEqual(long('4294967296', 10), 4294967296) + self.assertEqual(long('1904440554', 11), 4294967296) + self.assertEqual(long('9ba461594', 12), 4294967296) + self.assertEqual(long('535a79889', 13), 4294967296) + self.assertEqual(long('2ca5b7464', 14), 4294967296) + self.assertEqual(long('1a20dcd81', 15), 4294967296) + self.assertEqual(long('100000000', 16), 4294967296) + self.assertEqual(long('a7ffda91', 17), 4294967296) + self.assertEqual(long('704he7g4', 18), 4294967296) + self.assertEqual(long('4f5aff66', 19), 4294967296) + self.assertEqual(long('3723ai4g', 20), 4294967296) + self.assertEqual(long('281d55i4', 21), 4294967296) + self.assertEqual(long('1fj8b184', 22), 4294967296) + self.assertEqual(long('1606k7ic', 23), 4294967296) + self.assertEqual(long('mb994ag', 24), 4294967296) + self.assertEqual(long('hek2mgl', 25), 4294967296) + self.assertEqual(long('dnchbnm', 26), 4294967296) + self.assertEqual(long('b28jpdm', 27), 4294967296) + self.assertEqual(long('8pfgih4', 28), 4294967296) + self.assertEqual(long('76beigg', 29), 4294967296) + self.assertEqual(long('5qmcpqg', 30), 4294967296) + self.assertEqual(long('4q0jto4', 31), 4294967296) + self.assertEqual(long('4000000', 32), 4294967296) + self.assertEqual(long('3aokq94', 33), 4294967296) + self.assertEqual(long('2qhxjli', 34), 4294967296) + self.assertEqual(long('2br45qb', 35), 4294967296) + self.assertEqual(long('1z141z4', 36), 4294967296) + + self.assertEqual(long('100000000000000000000000000000001', 2), + 4294967297) + self.assertEqual(long('102002022201221111212', 3), 4294967297) + self.assertEqual(long('10000000000000001', 4), 4294967297) + self.assertEqual(long('32244002423142', 5), 4294967297) + self.assertEqual(long('1550104015505', 6), 4294967297) + self.assertEqual(long('211301422355', 7), 4294967297) + self.assertEqual(long('40000000001', 8), 4294967297) + self.assertEqual(long('12068657455', 9), 4294967297) + self.assertEqual(long('4294967297', 10), 4294967297) + self.assertEqual(long('1904440555', 11), 4294967297) + self.assertEqual(long('9ba461595', 12), 4294967297) + self.assertEqual(long('535a7988a', 13), 4294967297) + self.assertEqual(long('2ca5b7465', 14), 4294967297) + self.assertEqual(long('1a20dcd82', 15), 4294967297) + self.assertEqual(long('100000001', 16), 4294967297) + self.assertEqual(long('a7ffda92', 17), 4294967297) + self.assertEqual(long('704he7g5', 18), 4294967297) + self.assertEqual(long('4f5aff67', 19), 4294967297) + self.assertEqual(long('3723ai4h', 20), 4294967297) + self.assertEqual(long('281d55i5', 21), 4294967297) + self.assertEqual(long('1fj8b185', 22), 4294967297) + self.assertEqual(long('1606k7id', 23), 4294967297) + self.assertEqual(long('mb994ah', 24), 4294967297) + self.assertEqual(long('hek2mgm', 25), 4294967297) + self.assertEqual(long('dnchbnn', 26), 4294967297) + self.assertEqual(long('b28jpdn', 27), 4294967297) + self.assertEqual(long('8pfgih5', 28), 4294967297) + self.assertEqual(long('76beigh', 29), 4294967297) + self.assertEqual(long('5qmcpqh', 30), 4294967297) + self.assertEqual(long('4q0jto5', 31), 4294967297) + self.assertEqual(long('4000001', 32), 4294967297) + self.assertEqual(long('3aokq95', 33), 4294967297) + self.assertEqual(long('2qhxjlj', 34), 4294967297) + self.assertEqual(long('2br45qc', 35), 4294967297) + self.assertEqual(long('1z141z5', 36), 4294967297) + + def test_longconversion(self): # Test __long__() class Foo0: Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Thu May 25 16:25:38 2006 @@ -21,21 +21,21 @@ self.assertRaises(ValueError, hotbuf, 0) b = hotbuf(CAPACITY) self.assertEquals(len(b), CAPACITY) - self.assertEquals(b.capacity(), CAPACITY) + self.assertEquals(b.capacity, CAPACITY) # Play with the position - assert b.position() == 0 + assert b.position == 0 b.setposition(10) - self.assertEquals(b.position(), 10) + self.assertEquals(b.position, 10) self.assertRaises(IndexError, b.setposition, CAPACITY + 1) # Play with the limit - assert b.limit() == CAPACITY + assert b.limit == CAPACITY b.setlimit(CAPACITY - 10) - self.assertEquals(b.limit(), CAPACITY - 10) + self.assertEquals(b.limit, CAPACITY - 10) self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) - b.setlimit(b.position() - 1) - self.assertEquals(b.position(), b.limit()) + b.setlimit(b.position - 1) + self.assertEquals(b.position, b.limit) # Play with reset before the mark has been set. self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) @@ -45,11 +45,11 @@ b.setlimit(100) b.setmark() b.setposition(15) - self.assertEquals(b.mark(), 10) + self.assertEquals(b.mark, 10) # Play with clear b.clear() - self.assertEquals((b.position(), b.limit(), b.mark()), + self.assertEquals((b.position, b.limit, b.mark), (0, CAPACITY, -1)) # Play with flip. @@ -57,7 +57,7 @@ b.setlimit(104) b.setmark() b.flip() - self.assertEquals((b.position(), b.limit(), b.mark()), + self.assertEquals((b.position, b.limit, b.mark), (0, 42, -1)) # Play with rewind. @@ -65,7 +65,7 @@ b.setlimit(104) b.setmark() b.rewind() - self.assertEquals((b.position(), b.limit(), b.mark()), + self.assertEquals((b.position, b.limit, b.mark), (0, 104, -1)) # Play with remaining. @@ -78,9 +78,9 @@ b.setposition(100) b.setlimit(200) - b.mark() + m = b.mark b.compact() - self.assertEquals((b.position(), b.limit(), b.mark()), + self.assertEquals((b.position, b.limit, b.mark), (100, CAPACITY, -1)) def test_byte( self ): @@ -102,6 +102,26 @@ # Test underflow. self.assertRaises(IndexError, b.putbyte, 42) + def test_conversion( self ): + b = hotbuf(CAPACITY) + + b.setposition(100) + b.setlimit(132) + + self.assertEquals(len(b), 32) + s = str(b) + self.assertEquals(len(s), 32) + + r = repr(b) + self.assert_(r.startswith('", "exec") test2_newabs_co = compile(futimp + absimp + test_src, "", "exec") test2_newrel_co = compile(relimp + test_src, "", "exec") +test2_deeprel_co = compile(deeprelimp + test_src, "", "exec") test2_futrel_co = compile(futimp + relimp + test_src, "", "exec") test_path = "!!!_test_!!!" @@ -46,10 +48,11 @@ "hooktestmodule": (False, test_co), "hooktestpackage": (True, test_co), "hooktestpackage.sub": (True, test_co), - "hooktestpackage.sub.subber": (False, test_co), + "hooktestpackage.sub.subber": (True, test_co), "hooktestpackage.oldabs": (False, test2_oldabs_co), "hooktestpackage.newabs": (False, test2_newabs_co), "hooktestpackage.newrel": (False, test2_newrel_co), + "hooktestpackage.sub.subber.subest": (True, test2_deeprel_co), "hooktestpackage.futrel": (False, test2_futrel_co), "sub": (False, test_co), "reloadmodule": (False, test_co), @@ -203,6 +206,12 @@ self.assertEqual(hooktestpackage.newrel.sub, hooktestpackage.sub) + import hooktestpackage.sub.subber.subest as subest + self.assertEqual(subest.get_name(), + "hooktestpackage.sub.subber.subest") + self.assertEqual(subest.sub, + hooktestpackage.sub) + import hooktestpackage.futrel self.assertEqual(hooktestpackage.futrel.get_name(), "hooktestpackage.futrel") Modified: python/branches/blais-bytebuf/Misc/NEWS ============================================================================== --- python/branches/blais-bytebuf/Misc/NEWS (original) +++ python/branches/blais-bytebuf/Misc/NEWS Thu May 25 16:25:38 2006 @@ -12,6 +12,12 @@ Core and builtins ----------------- +- Patch #1442927: ``long(str, base)`` is now up to 6x faster for non-power- + of-2 bases. The largest speedup is for inputs with about 1000 decimal + digits. Conversion from non-power-of-2 bases remains quadratic-time in + the number of input digits (it was and remains linear-time for bases + 2, 4, 8, 16 and 32). + - Bug #1334662: ``int(string, base)`` could deliver a wrong answer when ``base`` was not 2, 4, 8, 10, 16 or 32, and ``string`` represented an integer close to ``sys.maxint``. This was repaired by patch Modified: python/branches/blais-bytebuf/Misc/developers.txt ============================================================================== --- python/branches/blais-bytebuf/Misc/developers.txt (original) +++ python/branches/blais-bytebuf/Misc/developers.txt Thu May 25 16:25:38 2006 @@ -17,6 +17,12 @@ Permissions History ------------------- +- 2006 Summer of Code entries: Matt Fleming was added on 25 May 2006 + by AMK; he'll be working on enhancing the Python debugger. SoC + developers are expected to work primarily in nondist/sandbox or on a + branch of their own, and will have their work reviewed before + changes are accepted into the trunk. + - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. @@ -40,7 +46,7 @@ - Added two new developers for the Summer of Code project. 8 July 2005 by RDH. Andrew Kuchling will be mentoring Gregory K Johnson for a - project to enchance mailbox. Brett Cannon requested access for Flovis + project to enhance mailbox. Brett Cannon requested access for Flovis Bruynooghe (sirolf) to work on pstats, profile, and hotshot. Both users are expected to work primarily in nondist/sandbox and have their work reviewed before making updates to active code. Modified: python/branches/blais-bytebuf/Modules/_hotbuf.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_hotbuf.c (original) +++ python/branches/blais-bytebuf/Modules/_hotbuf.c Thu May 25 16:25:38 2006 @@ -4,6 +4,7 @@ */ #include "Python.h" +#include "structmember.h" #include /* for memmove */ PyAPI_DATA(PyTypeObject) PyHotbuf_Type; @@ -163,18 +164,21 @@ static int hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) { - Py_ssize_t min_len; + Py_ssize_t len_self, len_other, min_len; int cmp; - min_len = ((self->b_capacity < other->b_capacity) ? - self->b_capacity : other->b_capacity); + len_self = self->b_limit - self->b_position; + len_other = other->b_limit - other->b_position; + + min_len = ((len_self < len_other) ? len_self : len_other); if (min_len > 0) { - cmp = memcmp(self->b_ptr, other->b_ptr, min_len); + cmp = memcmp(self->b_ptr + self->b_position, + other->b_ptr + other->b_position, min_len); if (cmp != 0) return cmp; } - return ((self->b_capacity < other->b_capacity) ? - -1 : (self->b_capacity > other->b_capacity) ? 1 : 0); + + return ((len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0); } @@ -196,7 +200,12 @@ static PyObject * hotbuf_str(PyHotbufObject *self) { - return PyString_FromStringAndSize((const char *)self->b_ptr, self->b_capacity); + if ( self->b_position == self->b_limit ) { + return Py_None; + } + return PyString_FromStringAndSize( + (const char *)(self->b_ptr + self->b_position), + self->b_limit - self->b_position); } @@ -205,31 +214,6 @@ * Object Methods (basic interface) */ -PyDoc_STRVAR(capacity__doc__, -"B.capacity() -> int\n\ -\n\ -Returns this buffer's capacity. \n\ -(the entire size of the allocated buffer.)"); - -static PyObject* -hotbuf_capacity(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_capacity); -} - - -PyDoc_STRVAR(position__doc__, -"B.position() -> int\n\ -\n\ -Returns this buffer's position."); - -static PyObject* -hotbuf_position(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_position); -} - - PyDoc_STRVAR(setposition__doc__, "B.setposition(int)\n\ \n\ @@ -263,18 +247,6 @@ } -PyDoc_STRVAR(limit__doc__, -"B.limit() -> int\n\ -\n\ -Returns this buffer's limit."); - -static PyObject* -hotbuf_limit(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_limit); -} - - PyDoc_STRVAR(setlimit__doc__, "B.setlimit(int)\n\ \n\ @@ -313,19 +285,6 @@ } -PyDoc_STRVAR(mark__doc__, -"B.mark() -> int\n\ -\n\ -Returns this buffer's mark. \n\ -Return -1 if the mark is not set."); - -static PyObject* -hotbuf_mark(PyHotbufObject *self) -{ - return PyInt_FromLong(self->b_mark); -} - - PyDoc_STRVAR(setmark__doc__, "B.setmark()\n\ \n\ @@ -571,6 +530,57 @@ } +static PyObject* +hotbuf_getstring(PyHotbufObject *self, PyObject* arg) +{ + int len; + CHECK_LIMIT_ERROR(sizeof(byte)); + + len = PyInt_AsLong(arg); + if (len == -1 && PyErr_Occurred()) + return NULL; + + if (len > (self->b_limit - self->b_position)) { + PyErr_SetString(PyExc_IndexError, + "cannot read beyond limit"); + return NULL; + } + +FIXME continue here + + return PyString_FromStringAndSize( + (const char *)(self->b_ptr + self->b_position), len); +} + +FIXME continue here + +FIXME we need to find a way to automatically advance position without doing it in Python + + +static PyObject* +hotbuf_putstring(PyHotbufObject *self, PyObject* arg) +{ + int byte_i; + unsigned char byte; + + byte_i = PyInt_AsLong(arg); + if (byte_i == -1 && PyErr_Occurred()) + return NULL; + + if ( byte_i > 255 ) { + PyErr_SetString(PyExc_ValueError, + "overflow for byte"); + return NULL; + } + byte = (unsigned char)byte_i; + + CHECK_LIMIT_ERROR(sizeof(byte)); + *(unsigned char*)(self->b_ptr + self->b_position) = byte; + self->b_position += sizeof(byte); + return Py_None; +} + + /* =========================================================================== @@ -649,35 +659,45 @@ ByteBuffer class."); + +#define OFF(x) offsetof(PyHotbufObject, x) + +static PyMemberDef hotbuf_members[] = { + {"capacity", T_INT, OFF(b_capacity), RO, + "buffer's capacity, it's total allocated size"}, + {"position", T_INT, OFF(b_position), RO, + "buffer's position"}, + {"limit", T_INT, OFF(b_limit), RO, + "buffer's limit"}, + {"mark", T_INT, OFF(b_mark), RO, + "buffer's mark, -1 if not set"}, + {NULL} /* Sentinel */ +}; + static PyMethodDef hotbuf_methods[] = { - {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, - {"capacity", (PyCFunction)hotbuf_capacity, METH_NOARGS, capacity__doc__}, - {"position", (PyCFunction)hotbuf_position, METH_NOARGS, position__doc__}, - {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, - {"limit", (PyCFunction)hotbuf_limit, METH_NOARGS, limit__doc__}, - {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, - {"mark", (PyCFunction)hotbuf_mark, METH_NOARGS, mark__doc__}, - {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, - {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, - {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, - {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, - {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, - {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, - - {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, - {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, - {NULL, NULL} /* sentinel */ + {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, + {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, + {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, + {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, + {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, + {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, + {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, + {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, + {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, + {NULL, NULL} /* sentinel */ }; static PySequenceMethods hotbuf_as_sequence = { - (lenfunc)hotbuf_length, /*sq_length*/ - 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ - 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ - 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ - 0 /*(ssizessizeargfunc)hotbuf_slice*/, /*sq_slice*/ - 0 /*(ssizeobjargproc)hotbuf_ass_item*/, /*sq_ass_item*/ - 0 /*(ssizessizeobjargproc)hotbuf_ass_slice*/, /*sq_ass_slice*/ + (lenfunc)hotbuf_length, /*sq_length*/ + 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ + 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ + 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ + 0 /*(ssizessizeargfunc)hotbuf_slice*/, /*sq_slice*/ + 0 /*(ssizeobjargproc)hotbuf_ass_item*/, /*sq_ass_item*/ + 0 /*(ssizessizeobjargproc)hotbuf_ass_slice*/, /*sq_ass_slice*/ }; static PyBufferProcs hotbuf_as_buffer = { @@ -717,7 +737,7 @@ 0, /* tp_iter */ 0, /* tp_iternext */ hotbuf_methods, /* tp_methods */ - 0, /* tp_members */ + hotbuf_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ Modified: python/branches/blais-bytebuf/Objects/longobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/longobject.c (original) +++ python/branches/blais-bytebuf/Objects/longobject.c Thu May 25 16:25:38 2006 @@ -277,9 +277,9 @@ overflow: PyErr_SetString(PyExc_OverflowError, "long int too large to convert to int"); - if (sign > 0) + if (sign > 0) return PY_SSIZE_T_MAX; - else + else return PY_SSIZE_T_MIN; } @@ -1304,7 +1304,34 @@ return (PyObject *)str; } -/* *str points to the first digit in a string of base base digits. base +static int digval[] = { + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 +}; + +/* *str points to the first digit in a string of base `base` digits. base * is a power of 2 (2, 4, 8, 16, or 32). *str is set to point to the first * non-digit (which may be *str!). A normalized long is returned. * The point to this routine is that it takes time linear in the number of @@ -1328,20 +1355,8 @@ n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - for (;;) { - int k = -1; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else if (ch >= 'A') - k = ch - 'A' + 10; - if (k < 0 || k >= base) - break; + while (digval[Py_CHARMASK(*p)] < base) ++p; - } *str = p; n = (p - start) * bits_per_char; if (n / bits_per_char != p - start) { @@ -1361,17 +1376,7 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else { - assert(ch >= 'A'); - k = ch - 'A' + 10; - } + int k = digval[Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1427,33 +1432,140 @@ } if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) str += 2; + start = str; if ((base & (base - 1)) == 0) z = long_from_binary_base(&str, base); else { - z = _PyLong_New(0); - for ( ; z != NULL; ++str) { - int k = -1; - PyLongObject *temp; - - if (*str <= '9') - k = *str - '0'; - else if (*str >= 'a') - k = *str - 'a' + 10; - else if (*str >= 'A') - k = *str - 'A' + 10; - if (k < 0 || k >= base) - break; - temp = muladd1(z, (digit)base, (digit)k); - Py_DECREF(z); - z = temp; +/*** +Binary bases can be converted in time linear in the number of digits, because +Python's representation base is binary. Other bases (including decimal!) use +the simple quadratic-time algorithm below, complicated by some speed tricks. + +First some math: the largest integer that can be expressed in N base-B digits +is B**N-1. Consequently, if we have an N-digit input in base B, the worst- +case number of Python digits needed to hold it is the smallest integer n s.t. + + BASE**n-1 >= B**N-1 [or, adding 1 to both sides] + BASE**n >= B**N [taking logs to base BASE] + n >= log(B**N)/log(BASE) = N * log(B)/log(BASE) + +The static array log_base_BASE[base] == log(base)/log(BASE) so we can compute +this quickly. A Python long with that much space is reserved near the start, +and the result is computed into it. + +The input string is actually treated as being in base base**i (i.e., i digits +are processed at a time), where two more static arrays hold: + + convwidth_base[base] = the largest integer i such that base**i <= BASE + convmultmax_base[base] = base ** convwidth_base[base] + +The first of these is the largest i such that i consecutive input digits +must fit in a single Python digit. The second is effectively the input +base we're really using. + +Viewing the input as a sequence of digits in base +convmultmax_base[base], the result is "simply" + + (((c0*B + c1)*B + c2)*B + c3)*B + ... ))) + c_n-1 + +where B = convmultmax_base[base]. +***/ + register twodigits c; /* current input character */ + Py_ssize_t size_z; + int i; + int convwidth; + twodigits convmultmax, convmult; + digit *pz, *pzstop; + char* scan; + + static double log_base_BASE[37] = {0.0e0,}; + static int convwidth_base[37] = {0,}; + static twodigits convmultmax_base[37] = {0,}; + + if (log_base_BASE[base] == 0.0) { + twodigits convmax = base; + int i = 1; + + log_base_BASE[base] = log((double)base) / + log((double)BASE); + for (;;) { + twodigits next = convmax * base; + if (next > BASE) + break; + convmax = next; + ++i; + } + convmultmax_base[base] = convmax; + assert(i > 0); + convwidth_base[base] = i; + } + + /* Find length of the string of numeric characters. */ + scan = str; + while (digval[Py_CHARMASK(*scan)] < base) + ++scan; + + /* Create a long object that can contain the largest possible + * integer with this base and length. Note that there's no + * need to initialize z->ob_digit -- no slot is read up before + * being stored into. + */ + size_z = (Py_ssize_t)((scan - str) * log_base_BASE[base]) + 1; + assert(size_z > 0); + z = _PyLong_New(size_z); + if (z == NULL) + return NULL; + z->ob_size = 0; + + /* `convwidth` consecutive input digits are treated as a single + * digit in base `convmultmax`. + */ + convwidth = convwidth_base[base]; + convmultmax = convmultmax_base[base]; + + /* Work ;-) */ + while (str < scan) { + /* grab up to convwidth digits from the input string */ + c = (digit)digval[Py_CHARMASK(*str++)]; + for (i = 1; i < convwidth && str != scan; ++i, ++str) { + c = (twodigits)(c * base + + digval[Py_CHARMASK(*str)]); + assert(c < BASE); + } + + convmult = convmultmax; + /* Calculate the shift only if we couldn't get + * convwidth digits. + */ + if (i != convwidth) { + convmult = base; + for ( ; i > 1; --i) + convmult *= base; + } + + /* Multiply z by convmult, and add c. */ + pz = z->ob_digit; + pzstop = pz + z->ob_size; + for (; pz < pzstop; ++pz) { + c += (twodigits)*pz * convmult; + *pz = (digit)(c & MASK); + c >>= SHIFT; + } + /* carry off the current end? */ + if (c) { + assert(c < BASE); + assert(z->ob_size < size_z); + *pz = (digit)c; + ++z->ob_size; + } } } if (z == NULL) return NULL; if (str == start) goto onError; - if (sign < 0 && z != NULL && z->ob_size != 0) + if (sign < 0) z->ob_size = -(z->ob_size); if (*str == 'L' || *str == 'l') str++; Modified: python/branches/blais-bytebuf/Python/errors.c ============================================================================== --- python/branches/blais-bytebuf/Python/errors.c (original) +++ python/branches/blais-bytebuf/Python/errors.c Thu May 25 16:25:38 2006 @@ -785,7 +785,7 @@ break; /* fgets read *something*; if it didn't get as far as pLastChar, it must have found a newline - or hit the end of the file; if pLastChar is \n, + or hit the end of the file; if pLastChar is \n, it obviously found a newline; else we haven't yet seen a newline, so must continue */ } while (*pLastChar != '\0' && *pLastChar != '\n'); Modified: python/branches/blais-bytebuf/Python/graminit.c ============================================================================== --- python/branches/blais-bytebuf/Python/graminit.c (original) +++ python/branches/blais-bytebuf/Python/graminit.c Thu May 25 16:25:38 2006 @@ -517,41 +517,36 @@ {12, 3}, }; static arc arcs_26_2[3] = { - {75, 4}, + {75, 2}, {12, 3}, - {72, 5}, + {72, 4}, }; static arc arcs_26_3[1] = { - {72, 5}, + {72, 4}, }; -static arc arcs_26_4[2] = { - {75, 4}, - {12, 3}, +static arc arcs_26_4[3] = { + {28, 5}, + {13, 6}, + {76, 5}, }; -static arc arcs_26_5[3] = { - {28, 6}, - {13, 7}, - {76, 6}, +static arc arcs_26_5[1] = { + {0, 5}, }; static arc arcs_26_6[1] = { - {0, 6}, + {76, 7}, }; static arc arcs_26_7[1] = { - {76, 8}, -}; -static arc arcs_26_8[1] = { - {15, 6}, + {15, 5}, }; -static state states_26[9] = { +static state states_26[8] = { {1, arcs_26_0}, {2, arcs_26_1}, {3, arcs_26_2}, {1, arcs_26_3}, - {2, arcs_26_4}, - {3, arcs_26_5}, + {3, arcs_26_4}, + {1, arcs_26_5}, {1, arcs_26_6}, {1, arcs_26_7}, - {1, arcs_26_8}, }; static arc arcs_27_0[1] = { {19, 1}, @@ -1839,7 +1834,7 @@ "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000"}, {281, "import_name", 0, 3, states_25, "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, - {282, "import_from", 0, 9, states_26, + {282, "import_from", 0, 8, states_26, "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, {283, "import_as_name", 0, 4, states_27, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, From python-checkins at python.org Thu May 25 16:43:42 2006 From: python-checkins at python.org (matt.fleming) Date: Thu, 25 May 2006 16:43:42 +0200 (CEST) Subject: [Python-checkins] r46213 - sandbox/trunk/pdb sandbox/trunk/pdb/bdb.py sandbox/trunk/pdb/cmd.py sandbox/trunk/pdb/pdb.py Message-ID: <20060525144342.1637F1E400B@bag.python.org> Author: matt.fleming Date: Thu May 25 16:43:40 2006 New Revision: 46213 Added: sandbox/trunk/pdb/ sandbox/trunk/pdb/bdb.py sandbox/trunk/pdb/cmd.py sandbox/trunk/pdb/pdb.py (contents, props changed) Log: Setting up a working directory for the python debugger for Google Summer of Code project. Added: sandbox/trunk/pdb/bdb.py ============================================================================== --- (empty file) +++ sandbox/trunk/pdb/bdb.py Thu May 25 16:43:40 2006 @@ -0,0 +1,613 @@ +"""Debugger basics""" + +import sys +import os +import types + +__all__ = ["BdbQuit","Bdb","Breakpoint"] + +class BdbQuit(Exception): + """Exception to give up completely""" + + +class Bdb: + + """Generic Python debugger base class. + + This class takes care of details of the trace facility; + a derived class should implement user interaction. + The standard debugger class (pdb.Pdb) is an example. + """ + + def __init__(self): + self.breaks = {} + self.fncache = {} + + def canonic(self, filename): + if filename == "<" + filename[1:-1] + ">": + return filename + canonic = self.fncache.get(filename) + if not canonic: + canonic = os.path.abspath(filename) + canonic = os.path.normcase(canonic) + self.fncache[filename] = canonic + return canonic + + def reset(self): + import linecache + linecache.checkcache() + self.botframe = None + self.stopframe = None + self.returnframe = None + self.quitting = 0 + + def trace_dispatch(self, frame, event, arg): + if self.quitting: + return # None + if event == 'line': + return self.dispatch_line(frame) + if event == 'call': + return self.dispatch_call(frame, arg) + if event == 'return': + return self.dispatch_return(frame, arg) + if event == 'exception': + return self.dispatch_exception(frame, arg) + if event == 'c_call': + return self.trace_dispatch + if event == 'c_exception': + return self.trace_dispatch + if event == 'c_return': + return self.trace_dispatch + print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event) + return self.trace_dispatch + + def dispatch_line(self, frame): + if self.stop_here(frame) or self.break_here(frame): + self.user_line(frame) + if self.quitting: raise BdbQuit + return self.trace_dispatch + + def dispatch_call(self, frame, arg): + # XXX 'arg' is no longer used + if self.botframe is None: + # First call of dispatch since reset() + self.botframe = frame.f_back # (CT) Note that this may also be None! + return self.trace_dispatch + if not (self.stop_here(frame) or self.break_anywhere(frame)): + # No need to trace this function + return # None + self.user_call(frame, arg) + if self.quitting: raise BdbQuit + return self.trace_dispatch + + def dispatch_return(self, frame, arg): + if self.stop_here(frame) or frame == self.returnframe: + self.user_return(frame, arg) + if self.quitting: raise BdbQuit + return self.trace_dispatch + + def dispatch_exception(self, frame, arg): + if self.stop_here(frame): + self.user_exception(frame, arg) + if self.quitting: raise BdbQuit + return self.trace_dispatch + + # Normally derived classes don't override the following + # methods, but they may if they want to redefine the + # definition of stopping and breakpoints. + + def stop_here(self, frame): + # (CT) stopframe may now also be None, see dispatch_call. + # (CT) the former test for None is therefore removed from here. + if frame is self.stopframe: + return True + while frame is not None and frame is not self.stopframe: + if frame is self.botframe: + return True + frame = frame.f_back + return False + + def break_here(self, frame): + filename = self.canonic(frame.f_code.co_filename) + if not filename in self.breaks: + return False + lineno = frame.f_lineno + if not lineno in self.breaks[filename]: + # The line itself has no breakpoint, but maybe the line is the + # first line of a function with breakpoint set by function name. + lineno = frame.f_code.co_firstlineno + if not lineno in self.breaks[filename]: + return False + + # flag says ok to delete temp. bp + (bp, flag) = effective(filename, lineno, frame) + if bp: + self.currentbp = bp.number + if (flag and bp.temporary): + self.do_clear(str(bp.number)) + return True + else: + return False + + def do_clear(self, arg): + raise NotImplementedError, "subclass of bdb must implement do_clear()" + + def break_anywhere(self, frame): + return self.breaks.has_key( + self.canonic(frame.f_code.co_filename)) + + # Derived classes should override the user_* methods + # to gain control. + + def user_call(self, frame, argument_list): + """This method is called when there is the remote possibility + that we ever need to stop in this function.""" + pass + + def user_line(self, frame): + """This method is called when we stop or break at this line.""" + pass + + def user_return(self, frame, return_value): + """This method is called when a return trap is set here.""" + pass + + def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): + """This method is called if an exception occurs, + but only if we are to stop at or just below this level.""" + pass + + # Derived classes and clients can call the following methods + # to affect the stepping state. + + def set_step(self): + """Stop after one line of code.""" + self.stopframe = None + self.returnframe = None + self.quitting = 0 + + def set_next(self, frame): + """Stop on the next line in or below the given frame.""" + self.stopframe = frame + self.returnframe = None + self.quitting = 0 + + def set_return(self, frame): + """Stop when returning from the given frame.""" + self.stopframe = frame.f_back + self.returnframe = frame + self.quitting = 0 + + def set_trace(self, frame=None): + """Start debugging from `frame`. + + If frame is not specified, debugging starts from caller's frame. + """ + if frame is None: + frame = sys._getframe().f_back + self.reset() + while frame: + frame.f_trace = self.trace_dispatch + self.botframe = frame + frame = frame.f_back + self.set_step() + sys.settrace(self.trace_dispatch) + + def set_continue(self): + # Don't stop except at breakpoints or when finished + self.stopframe = self.botframe + self.returnframe = None + self.quitting = 0 + if not self.breaks: + # no breakpoints; run without debugger overhead + sys.settrace(None) + frame = sys._getframe().f_back + while frame and frame is not self.botframe: + del frame.f_trace + frame = frame.f_back + + def set_quit(self): + self.stopframe = self.botframe + self.returnframe = None + self.quitting = 1 + sys.settrace(None) + + # Derived classes and clients can call the following methods + # to manipulate breakpoints. These methods return an + # error message is something went wrong, None if all is well. + # Set_break prints out the breakpoint line and file:lineno. + # Call self.get_*break*() to see the breakpoints or better + # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint(). + + def set_break(self, filename, lineno, temporary=0, cond = None, + funcname=None): + filename = self.canonic(filename) + import linecache # Import as late as possible + line = linecache.getline(filename, lineno) + if not line: + return 'Line %s:%d does not exist' % (filename, + lineno) + if not filename in self.breaks: + self.breaks[filename] = [] + list = self.breaks[filename] + if not lineno in list: + list.append(lineno) + bp = Breakpoint(filename, lineno, temporary, cond, funcname) + + def clear_break(self, filename, lineno): + filename = self.canonic(filename) + if not filename in self.breaks: + return 'There are no breakpoints in %s' % filename + if lineno not in self.breaks[filename]: + return 'There is no breakpoint at %s:%d' % (filename, + lineno) + # If there's only one bp in the list for that file,line + # pair, then remove the breaks entry + for bp in Breakpoint.bplist[filename, lineno][:]: + bp.deleteMe() + if not Breakpoint.bplist.has_key((filename, lineno)): + self.breaks[filename].remove(lineno) + if not self.breaks[filename]: + del self.breaks[filename] + + def clear_bpbynumber(self, arg): + try: + number = int(arg) + except: + return 'Non-numeric breakpoint number (%s)' % arg + try: + bp = Breakpoint.bpbynumber[number] + except IndexError: + return 'Breakpoint number (%d) out of range' % number + if not bp: + return 'Breakpoint (%d) already deleted' % number + self.clear_break(bp.file, bp.line) + + def clear_all_file_breaks(self, filename): + filename = self.canonic(filename) + if not filename in self.breaks: + return 'There are no breakpoints in %s' % filename + for line in self.breaks[filename]: + blist = Breakpoint.bplist[filename, line] + for bp in blist: + bp.deleteMe() + del self.breaks[filename] + + def clear_all_breaks(self): + if not self.breaks: + return 'There are no breakpoints' + for bp in Breakpoint.bpbynumber: + if bp: + bp.deleteMe() + self.breaks = {} + + def get_break(self, filename, lineno): + filename = self.canonic(filename) + return filename in self.breaks and \ + lineno in self.breaks[filename] + + def get_breaks(self, filename, lineno): + filename = self.canonic(filename) + return filename in self.breaks and \ + lineno in self.breaks[filename] and \ + Breakpoint.bplist[filename, lineno] or [] + + def get_file_breaks(self, filename): + filename = self.canonic(filename) + if filename in self.breaks: + return self.breaks[filename] + else: + return [] + + def get_all_breaks(self): + return self.breaks + + # Derived classes and clients can call the following method + # to get a data structure representing a stack trace. + + def get_stack(self, f, t): + stack = [] + if t and t.tb_frame is f: + t = t.tb_next + while f is not None: + stack.append((f, f.f_lineno)) + if f is self.botframe: + break + f = f.f_back + stack.reverse() + i = max(0, len(stack) - 1) + while t is not None: + stack.append((t.tb_frame, t.tb_lineno)) + t = t.tb_next + return stack, i + + # + + def format_stack_entry(self, frame_lineno, lprefix=': '): + import linecache, repr + frame, lineno = frame_lineno + filename = self.canonic(frame.f_code.co_filename) + s = '%s(%r)' % (filename, lineno) + if frame.f_code.co_name: + s = s + frame.f_code.co_name + else: + s = s + "" + if '__args__' in frame.f_locals: + args = frame.f_locals['__args__'] + else: + args = None + if args: + s = s + repr.repr(args) + else: + s = s + '()' + if '__return__' in frame.f_locals: + rv = frame.f_locals['__return__'] + s = s + '->' + s = s + repr.repr(rv) + line = linecache.getline(filename, lineno) + if line: s = s + lprefix + line.strip() + return s + + # The following two methods can be called by clients to use + # a debugger to debug a statement, given as a string. + + def run(self, cmd, globals=None, locals=None): + if globals is None: + import __main__ + globals = __main__.__dict__ + if locals is None: + locals = globals + self.reset() + sys.settrace(self.trace_dispatch) + if not isinstance(cmd, types.CodeType): + cmd = cmd+'\n' + try: + try: + exec cmd in globals, locals + except BdbQuit: + pass + finally: + self.quitting = 1 + sys.settrace(None) + + def runeval(self, expr, globals=None, locals=None): + if globals is None: + import __main__ + globals = __main__.__dict__ + if locals is None: + locals = globals + self.reset() + sys.settrace(self.trace_dispatch) + if not isinstance(expr, types.CodeType): + expr = expr+'\n' + try: + try: + return eval(expr, globals, locals) + except BdbQuit: + pass + finally: + self.quitting = 1 + sys.settrace(None) + + def runctx(self, cmd, globals, locals): + # B/W compatibility + self.run(cmd, globals, locals) + + # This method is more useful to debug a single function call. + + def runcall(self, func, *args, **kwds): + self.reset() + sys.settrace(self.trace_dispatch) + res = None + try: + try: + res = func(*args, **kwds) + except BdbQuit: + pass + finally: + self.quitting = 1 + sys.settrace(None) + return res + + +def set_trace(): + Bdb().set_trace() + + +class Breakpoint: + + """Breakpoint class + + Implements temporary breakpoints, ignore counts, disabling and + (re)-enabling, and conditionals. + + Breakpoints are indexed by number through bpbynumber and by + the file,line tuple using bplist. The former points to a + single instance of class Breakpoint. The latter points to a + list of such instances since there may be more than one + breakpoint per line. + + """ + + # XXX Keeping state in the class is a mistake -- this means + # you cannot have more than one active Bdb instance. + + next = 1 # Next bp to be assigned + bplist = {} # indexed by (file, lineno) tuple + bpbynumber = [None] # Each entry is None or an instance of Bpt + # index 0 is unused, except for marking an + # effective break .... see effective() + + def __init__(self, file, line, temporary=0, cond=None, funcname=None): + self.funcname = funcname + # Needed if funcname is not None. + self.func_first_executable_line = None + self.file = file # This better be in canonical form! + self.line = line + self.temporary = temporary + self.cond = cond + self.enabled = 1 + self.ignore = 0 + self.hits = 0 + self.number = Breakpoint.next + Breakpoint.next = Breakpoint.next + 1 + # Build the two lists + self.bpbynumber.append(self) + if self.bplist.has_key((file, line)): + self.bplist[file, line].append(self) + else: + self.bplist[file, line] = [self] + + + def deleteMe(self): + index = (self.file, self.line) + self.bpbynumber[self.number] = None # No longer in list + self.bplist[index].remove(self) + if not self.bplist[index]: + # No more bp for this f:l combo + del self.bplist[index] + + def enable(self): + self.enabled = 1 + + def disable(self): + self.enabled = 0 + + def bpprint(self, out=None): + if out is None: + out = sys.stdout + if self.temporary: + disp = 'del ' + else: + disp = 'keep ' + if self.enabled: + disp = disp + 'yes ' + else: + disp = disp + 'no ' + print >>out, '%-4dbreakpoint %s at %s:%d' % (self.number, disp, + self.file, self.line) + if self.cond: + print >>out, '\tstop only if %s' % (self.cond,) + if self.ignore: + print >>out, '\tignore next %d hits' % (self.ignore) + if (self.hits): + if (self.hits > 1): ss = 's' + else: ss = '' + print >>out, ('\tbreakpoint already hit %d time%s' % + (self.hits, ss)) + +# -----------end of Breakpoint class---------- + +def checkfuncname(b, frame): + """Check whether we should break here because of `b.funcname`.""" + if not b.funcname: + # Breakpoint was set via line number. + if b.line != frame.f_lineno: + # Breakpoint was set at a line with a def statement and the function + # defined is called: don't break. + return False + return True + + # Breakpoint set via function name. + + if frame.f_code.co_name != b.funcname: + # It's not a function call, but rather execution of def statement. + return False + + # We are in the right frame. + if not b.func_first_executable_line: + # The function is entered for the 1st time. + b.func_first_executable_line = frame.f_lineno + + if b.func_first_executable_line != frame.f_lineno: + # But we are not at the first line number: don't break. + return False + return True + +# Determines if there is an effective (active) breakpoint at this +# line of code. Returns breakpoint number or 0 if none +def effective(file, line, frame): + """Determine which breakpoint for this file:line is to be acted upon. + + Called only if we know there is a bpt at this + location. Returns breakpoint that was triggered and a flag + that indicates if it is ok to delete a temporary bp. + + """ + possibles = Breakpoint.bplist[file,line] + for i in range(0, len(possibles)): + b = possibles[i] + if b.enabled == 0: + continue + if not checkfuncname(b, frame): + continue + # Count every hit when bp is enabled + b.hits = b.hits + 1 + if not b.cond: + # If unconditional, and ignoring, + # go on to next, else break + if b.ignore > 0: + b.ignore = b.ignore -1 + continue + else: + # breakpoint and marker that's ok + # to delete if temporary + return (b,1) + else: + # Conditional bp. + # Ignore count applies only to those bpt hits where the + # condition evaluates to true. + try: + val = eval(b.cond, frame.f_globals, + frame.f_locals) + if val: + if b.ignore > 0: + b.ignore = b.ignore -1 + # continue + else: + return (b,1) + # else: + # continue + except: + # if eval fails, most conservative + # thing is to stop on breakpoint + # regardless of ignore count. + # Don't delete temporary, + # as another hint to user. + return (b,0) + return (None, None) + +# -------------------- testing -------------------- + +class Tdb(Bdb): + def user_call(self, frame, args): + name = frame.f_code.co_name + if not name: name = '???' + print '+++ call', name, args + def user_line(self, frame): + import linecache + name = frame.f_code.co_name + if not name: name = '???' + fn = self.canonic(frame.f_code.co_filename) + line = linecache.getline(fn, frame.f_lineno) + print '+++', fn, frame.f_lineno, name, ':', line.strip() + def user_return(self, frame, retval): + print '+++ return', retval + def user_exception(self, frame, exc_stuff): + print '+++ exception', exc_stuff + self.set_continue() + +def foo(n): + print 'foo(', n, ')' + x = bar(n*10) + print 'bar returned', x + +def bar(a): + print 'bar(', a, ')' + return a/2 + +def test(): + t = Tdb() + t.run('import bdb; bdb.foo(10)') + +# end Added: sandbox/trunk/pdb/cmd.py ============================================================================== --- (empty file) +++ sandbox/trunk/pdb/cmd.py Thu May 25 16:43:40 2006 @@ -0,0 +1,405 @@ +"""A generic class to build line-oriented command interpreters. + +Interpreters constructed with this class obey the following conventions: + +1. End of file on input is processed as the command 'EOF'. +2. A command is parsed out of each line by collecting the prefix composed + of characters in the identchars member. +3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method + is passed a single argument consisting of the remainder of the line. +4. Typing an empty line repeats the last command. (Actually, it calls the + method `emptyline', which may be overridden in a subclass.) +5. There is a predefined `help' method. Given an argument `topic', it + calls the command `help_topic'. With no arguments, it lists all topics + with defined help_ functions, broken into up to three topics; documented + commands, miscellaneous help topics, and undocumented commands. +6. The command '?' is a synonym for `help'. The command '!' is a synonym + for `shell', if a do_shell method exists. +7. If completion is enabled, completing commands will be done automatically, + and completing of commands args is done by calling complete_foo() with + arguments text, line, begidx, endidx. text is string we are matching + against, all returned matches must begin with it. line is the current + input line (lstripped), begidx and endidx are the beginning and end + indexes of the text being matched, which could be used to provide + different completion depending upon which position the argument is in. + +The `default' method may be overridden to intercept commands for which there +is no do_ method. + +The `completedefault' method may be overridden to intercept completions for +commands that have no complete_ method. + +The data member `self.ruler' sets the character used to draw separator lines +in the help messages. If empty, no ruler line is drawn. It defaults to "=". + +If the value of `self.intro' is nonempty when the cmdloop method is called, +it is printed out on interpreter startup. This value may be overridden +via an optional argument to the cmdloop() method. + +The data members `self.doc_header', `self.misc_header', and +`self.undoc_header' set the headers used for the help function's +listings of documented functions, miscellaneous topics, and undocumented +functions respectively. + +These interpreters use raw_input; thus, if the readline module is loaded, +they automatically support Emacs-like command history and editing features. +""" + +import string + +__all__ = ["Cmd"] + +PROMPT = '(Cmd) ' +IDENTCHARS = string.ascii_letters + string.digits + '_' + +class Cmd: + """A simple framework for writing line-oriented command interpreters. + + These are often useful for test harnesses, administrative tools, and + prototypes that will later be wrapped in a more sophisticated interface. + + A Cmd instance or subclass instance is a line-oriented interpreter + framework. There is no good reason to instantiate Cmd itself; rather, + it's useful as a superclass of an interpreter class you define yourself + in order to inherit Cmd's methods and encapsulate action methods. + + """ + prompt = PROMPT + identchars = IDENTCHARS + ruler = '=' + lastcmd = '' + intro = None + doc_leader = "" + doc_header = "Documented commands (type help ):" + misc_header = "Miscellaneous help topics:" + undoc_header = "Undocumented commands:" + nohelp = "*** No help on %s" + use_rawinput = 1 + + def __init__(self, completekey='tab', stdin=None, stdout=None): + """Instantiate a line-oriented interpreter framework. + + The optional argument 'completekey' is the readline name of a + completion key; it defaults to the Tab key. If completekey is + not None and the readline module is available, command completion + is done automatically. The optional arguments stdin and stdout + specify alternate input and output file objects; if not specified, + sys.stdin and sys.stdout are used. + + """ + import sys + if stdin is not None: + self.stdin = stdin + else: + self.stdin = sys.stdin + if stdout is not None: + self.stdout = stdout + else: + self.stdout = sys.stdout + self.cmdqueue = [] + self.completekey = completekey + + def cmdloop(self, intro=None): + """Repeatedly issue a prompt, accept input, parse an initial prefix + off the received input, and dispatch to action methods, passing them + the remainder of the line as argument. + + """ + + self.preloop() + if self.use_rawinput and self.completekey: + try: + import readline + self.old_completer = readline.get_completer() + readline.set_completer(self.complete) + readline.parse_and_bind(self.completekey+": complete") + except ImportError: + pass + try: + if intro is not None: + self.intro = intro + if self.intro: + self.stdout.write(str(self.intro)+"\n") + stop = None + while not stop: + if self.cmdqueue: + line = self.cmdqueue.pop(0) + else: + if self.use_rawinput: + try: + line = raw_input(self.prompt) + except EOFError: + line = 'EOF' + else: + self.stdout.write(self.prompt) + self.stdout.flush() + line = self.stdin.readline() + if not len(line): + line = 'EOF' + else: + line = line[:-1] # chop \n + line = self.precmd(line) + stop = self.onecmd(line) + stop = self.postcmd(stop, line) + self.postloop() + finally: + if self.use_rawinput and self.completekey: + try: + import readline + readline.set_completer(self.old_completer) + except ImportError: + pass + + + def precmd(self, line): + """Hook method executed just before the command line is + interpreted, but after the input prompt is generated and issued. + + """ + return line + + def postcmd(self, stop, line): + """Hook method executed just after a command dispatch is finished.""" + return stop + + def preloop(self): + """Hook method executed once when the cmdloop() method is called.""" + pass + + def postloop(self): + """Hook method executed once when the cmdloop() method is about to + return. + + """ + pass + + def parseline(self, line): + """Parse the line into a command name and a string containing + the arguments. Returns a tuple containing (command, args, line). + 'command' and 'args' may be None if the line couldn't be parsed. + """ + line = line.strip() + if not line: + return None, None, line + elif line[0] == '?': + line = 'help ' + line[1:] + elif line[0] == '!': + if hasattr(self, 'do_shell'): + line = 'shell ' + line[1:] + else: + return None, None, line + i, n = 0, len(line) + while i < n and line[i] in self.identchars: i = i+1 + cmd, arg = line[:i], line[i:].strip() + return cmd, arg, line + + def onecmd(self, line): + """Interpret the argument as though it had been typed in response + to the prompt. + + This may be overridden, but should not normally need to be; + see the precmd() and postcmd() methods for useful execution hooks. + The return value is a flag indicating whether interpretation of + commands by the interpreter should stop. + + """ + cmd, arg, line = self.parseline(line) + if not line: + return self.emptyline() + if cmd is None: + return self.default(line) + self.lastcmd = line + if cmd == '': + return self.default(line) + else: + try: + func = getattr(self, 'do_' + cmd) + except AttributeError: + return self.default(line) + return func(arg) + + def emptyline(self): + """Called when an empty line is entered in response to the prompt. + + If this method is not overridden, it repeats the last nonempty + command entered. + + """ + if self.lastcmd: + return self.onecmd(self.lastcmd) + + def default(self, line): + """Called on an input line when the command prefix is not recognized. + + If this method is not overridden, it prints an error message and + returns. + + """ + self.stdout.write('*** Unknown syntax: %s\n'%line) + + def completedefault(self, *ignored): + """Method called to complete an input line when no command-specific + complete_*() method is available. + + By default, it returns an empty list. + + """ + return [] + + def completenames(self, text, *ignored): + dotext = 'do_'+text + return [a[3:] for a in self.get_names() if a.startswith(dotext)] + + def complete(self, text, state): + """Return the next possible completion for 'text'. + + If a command has not been entered, then complete against command list. + Otherwise try to call complete_ to get list of completions. + """ + if state == 0: + import readline + origline = readline.get_line_buffer() + line = origline.lstrip() + stripped = len(origline) - len(line) + begidx = readline.get_begidx() - stripped + endidx = readline.get_endidx() - stripped + if begidx>0: + cmd, args, foo = self.parseline(line) + if cmd == '': + compfunc = self.completedefault + else: + try: + compfunc = getattr(self, 'complete_' + cmd) + except AttributeError: + compfunc = self.completedefault + else: + compfunc = self.completenames + self.completion_matches = compfunc(text, line, begidx, endidx) + try: + return self.completion_matches[state] + except IndexError: + return None + + def get_names(self): + # Inheritance says we have to look in class and + # base classes; order is not important. + names = [] + classes = [self.__class__] + while classes: + aclass = classes.pop(0) + if aclass.__bases__: + classes = classes + list(aclass.__bases__) + names = names + dir(aclass) + return names + + def complete_help(self, *args): + return self.completenames(*args) + + def do_help(self, arg): + if arg: + # XXX check arg syntax + try: + func = getattr(self, 'help_' + arg) + except AttributeError: + try: + doc=getattr(self, 'do_' + arg).__doc__ + if doc: + self.stdout.write("%s\n"%str(doc)) + return + except AttributeError: + pass + self.stdout.write("%s\n"%str(self.nohelp % (arg,))) + return + func() + else: + names = self.get_names() + cmds_doc = [] + cmds_undoc = [] + help = {} + for name in names: + if name[:5] == 'help_': + help[name[5:]]=1 + names.sort() + # There can be duplicates if routines overridden + prevname = '' + for name in names: + if name[:3] == 'do_': + if name == prevname: + continue + prevname = name + cmd=name[3:] + if cmd in help: + cmds_doc.append(cmd) + del help[cmd] + elif getattr(self, name).__doc__: + cmds_doc.append(cmd) + else: + cmds_undoc.append(cmd) + self.stdout.write("%s\n"%str(self.doc_leader)) + self.print_topics(self.doc_header, cmds_doc, 15,80) + self.print_topics(self.misc_header, help.keys(),15,80) + self.print_topics(self.undoc_header, cmds_undoc, 15,80) + + def print_topics(self, header, cmds, cmdlen, maxcol): + if cmds: + self.stdout.write("%s\n"%str(header)) + if self.ruler: + self.stdout.write("%s\n"%str(self.ruler * len(header))) + self.columnize(cmds, maxcol-1) + self.stdout.write("\n") + + def columnize(self, list, displaywidth=80): + """Display a list of strings as a compact set of columns. + + Each column is only as wide as necessary. + Columns are separated by two spaces (one was not legible enough). + """ + if not list: + self.stdout.write("\n") + return + nonstrings = [i for i in range(len(list)) + if not isinstance(list[i], str)] + if nonstrings: + raise TypeError, ("list[i] not a string for i in %s" % + ", ".join(map(str, nonstrings))) + size = len(list) + if size == 1: + self.stdout.write('%s\n'%str(list[0])) + return + # Try every row count from 1 upwards + for nrows in range(1, len(list)): + ncols = (size+nrows-1) // nrows + colwidths = [] + totwidth = -2 + for col in range(ncols): + colwidth = 0 + for row in range(nrows): + i = row + nrows*col + if i >= size: + break + x = list[i] + colwidth = max(colwidth, len(x)) + colwidths.append(colwidth) + totwidth += colwidth + 2 + if totwidth > displaywidth: + break + if totwidth <= displaywidth: + break + else: + nrows = len(list) + ncols = 1 + colwidths = [0] + for row in range(nrows): + texts = [] + for col in range(ncols): + i = row + nrows*col + if i >= size: + x = "" + else: + x = list[i] + texts.append(x) + while texts and not texts[-1]: + del texts[-1] + for col in range(len(texts)): + texts[col] = texts[col].ljust(colwidths[col]) + self.stdout.write("%s\n"%str(" ".join(texts))) Added: sandbox/trunk/pdb/pdb.py ============================================================================== --- (empty file) +++ sandbox/trunk/pdb/pdb.py Thu May 25 16:43:40 2006 @@ -0,0 +1,1213 @@ +#! /usr/bin/env python + +"""A Python debugger.""" + +# (See pdb.doc for documentation.) + +import sys +import linecache +import cmd +import bdb +from repr import Repr +import os +import re +import pprint +import traceback +# Create a custom safe Repr instance and increase its maxstring. +# The default of 30 truncates error messages too easily. +_repr = Repr() +_repr.maxstring = 200 +_saferepr = _repr.repr + +__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", + "post_mortem", "help"] + +def find_function(funcname, filename): + cre = re.compile(r'def\s+%s\s*[(]' % funcname) + try: + fp = open(filename) + except IOError: + return None + # consumer of this info expects the first line to be 1 + lineno = 1 + answer = None + while 1: + line = fp.readline() + if line == '': + break + if cre.match(line): + answer = funcname, filename, lineno + break + lineno = lineno + 1 + fp.close() + return answer + + +# Interaction prompt line will separate file and call info from code +# text using value of line_prefix string. A newline and arrow may +# be to your liking. You can set it once pdb is imported using the +# command "pdb.line_prefix = '\n% '". +# line_prefix = ': ' # Use this to get the old situation back +line_prefix = '\n-> ' # Probably a better default + +class Pdb(bdb.Bdb, cmd.Cmd): + + def __init__(self, completekey='tab', stdin=None, stdout=None): + bdb.Bdb.__init__(self) + cmd.Cmd.__init__(self, completekey, stdin, stdout) + if stdout: + self.use_rawinput = 0 + self.prompt = '(Pdb) ' + self.aliases = {} + self.mainpyfile = '' + self._wait_for_mainpyfile = 0 + # Try to load readline if it exists + try: + import readline + except ImportError: + pass + + # Read $HOME/.pdbrc and ./.pdbrc + self.rcLines = [] + if 'HOME' in os.environ: + envHome = os.environ['HOME'] + try: + rcFile = open(os.path.join(envHome, ".pdbrc")) + except IOError: + pass + else: + for line in rcFile.readlines(): + self.rcLines.append(line) + rcFile.close() + try: + rcFile = open(".pdbrc") + except IOError: + pass + else: + for line in rcFile.readlines(): + self.rcLines.append(line) + rcFile.close() + + self.commands = {} # associates a command list to breakpoint numbers + self.commands_doprompt = {} # for each bp num, tells if the prompt must be disp. after execing the cmd list + self.commands_silent = {} # for each bp num, tells if the stack trace must be disp. after execing the cmd list + self.commands_defining = False # True while in the process of defining a command list + self.commands_bnum = None # The breakpoint number for which we are defining a list + + def reset(self): + bdb.Bdb.reset(self) + self.forget() + + def forget(self): + self.lineno = None + self.stack = [] + self.curindex = 0 + self.curframe = None + + def setup(self, f, t): + self.forget() + self.stack, self.curindex = self.get_stack(f, t) + self.curframe = self.stack[self.curindex][0] + self.execRcLines() + + # Can be executed earlier than 'setup' if desired + def execRcLines(self): + if self.rcLines: + # Make local copy because of recursion + rcLines = self.rcLines + # executed only once + self.rcLines = [] + for line in rcLines: + line = line[:-1] + if len(line) > 0 and line[0] != '#': + self.onecmd(line) + + # Override Bdb methods + + def user_call(self, frame, argument_list): + """This method is called when there is the remote possibility + that we ever need to stop in this function.""" + if self._wait_for_mainpyfile: + return + if self.stop_here(frame): + print >>self.stdout, '--Call--' + self.interaction(frame, None) + + def user_line(self, frame): + """This function is called when we stop or break at this line.""" + if self._wait_for_mainpyfile: + if (self.mainpyfile != self.canonic(frame.f_code.co_filename) + or frame.f_lineno<= 0): + return + self._wait_for_mainpyfile = 0 + if self.bp_commands(frame): + self.interaction(frame, None) + + def bp_commands(self,frame): + """ Call every command that was set for the current active breakpoint (if there is one) + Returns True if the normal interaction function must be called, False otherwise """ + #self.currentbp is set in bdb.py in bdb.break_here if a breakpoint was hit + if getattr(self,"currentbp",False) and self.currentbp in self.commands: + currentbp = self.currentbp + self.currentbp = 0 + lastcmd_back = self.lastcmd + self.setup(frame, None) + for line in self.commands[currentbp]: + self.onecmd(line) + self.lastcmd = lastcmd_back + if not self.commands_silent[currentbp]: + self.print_stack_entry(self.stack[self.curindex]) + if self.commands_doprompt[currentbp]: + self.cmdloop() + self.forget() + return + return 1 + + def user_return(self, frame, return_value): + """This function is called when a return trap is set here.""" + frame.f_locals['__return__'] = return_value + print >>self.stdout, '--Return--' + self.interaction(frame, None) + + def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): + """This function is called if an exception occurs, + but only if we are to stop at or just below this level.""" + frame.f_locals['__exception__'] = exc_type, exc_value + if type(exc_type) == type(''): + exc_type_name = exc_type + else: exc_type_name = exc_type.__name__ + print >>self.stdout, exc_type_name + ':', _saferepr(exc_value) + self.interaction(frame, exc_traceback) + + # General interaction function + + def interaction(self, frame, traceback): + self.setup(frame, traceback) + self.print_stack_entry(self.stack[self.curindex]) + self.cmdloop() + self.forget() + + def default(self, line): + if line[:1] == '!': line = line[1:] + locals = self.curframe.f_locals + globals = self.curframe.f_globals + try: + code = compile(line + '\n', '', 'single') + exec code in globals, locals + except: + t, v = sys.exc_info()[:2] + if type(t) == type(''): + exc_type_name = t + else: exc_type_name = t.__name__ + print >>self.stdout, '***', exc_type_name + ':', v + + def precmd(self, line): + """Handle alias expansion and ';;' separator.""" + if not line.strip(): + return line + args = line.split() + while args[0] in self.aliases: + line = self.aliases[args[0]] + ii = 1 + for tmpArg in args[1:]: + line = line.replace("%" + str(ii), + tmpArg) + ii = ii + 1 + line = line.replace("%*", ' '.join(args[1:])) + args = line.split() + # split into ';;' separated commands + # unless it's an alias command + if args[0] != 'alias': + marker = line.find(';;') + if marker >= 0: + # queue up everything after marker + next = line[marker+2:].lstrip() + self.cmdqueue.append(next) + line = line[:marker].rstrip() + return line + + def onecmd(self, line): + """Interpret the argument as though it had been typed in response + to the prompt. + + Checks wether this line is typed in the normal prompt or in a breakpoint command list definition + """ + if not self.commands_defining: + return cmd.Cmd.onecmd(self, line) + else: + return self.handle_command_def(line) + + def handle_command_def(self,line): + """ Handles one command line during command list definition. """ + cmd, arg, line = self.parseline(line) + if cmd == 'silent': + self.commands_silent[self.commands_bnum] = True + return # continue to handle other cmd def in the cmd list + elif cmd == 'end': + self.cmdqueue = [] + return 1 # end of cmd list + cmdlist = self.commands[self.commands_bnum] + if (arg): + cmdlist.append(cmd+' '+arg) + else: + cmdlist.append(cmd) + # Determine if we must stop + try: + func = getattr(self, 'do_' + cmd) + except AttributeError: + func = self.default + if func.func_name in self.commands_resuming : # one of the resuming commands. + self.commands_doprompt[self.commands_bnum] = False + self.cmdqueue = [] + return 1 + return + + # Command definitions, called by cmdloop() + # The argument is the remaining string on the command line + # Return true to exit from the command loop + + do_h = cmd.Cmd.do_help + + def do_commands(self, arg): + """Defines a list of commands associated to a breakpoint + Those commands will be executed whenever the breakpoint causes the program to stop execution.""" + if not arg: + bnum = len(bdb.Breakpoint.bpbynumber)-1 + else: + try: + bnum = int(arg) + except: + print >>self.stdout, "Usage : commands [bnum]\n ...\n end" + return + self.commands_bnum = bnum + self.commands[bnum] = [] + self.commands_doprompt[bnum] = True + self.commands_silent[bnum] = False + prompt_back = self.prompt + self.prompt = '(com) ' + self.commands_defining = True + self.cmdloop() + self.commands_defining = False + self.prompt = prompt_back + + def do_break(self, arg, temporary = 0): + # break [ ([filename:]lineno | function) [, "condition"] ] + if not arg: + if self.breaks: # There's at least one + print >>self.stdout, "Num Type Disp Enb Where" + for bp in bdb.Breakpoint.bpbynumber: + if bp: + bp.bpprint(self.stdout) + return + # parse arguments; comma has lowest precedence + # and cannot occur in filename + filename = None + lineno = None + cond = None + comma = arg.find(',') + if comma > 0: + # parse stuff after comma: "condition" + cond = arg[comma+1:].lstrip() + arg = arg[:comma].rstrip() + # parse stuff before comma: [filename:]lineno | function + colon = arg.rfind(':') + funcname = None + if colon >= 0: + filename = arg[:colon].rstrip() + f = self.lookupmodule(filename) + if not f: + print >>self.stdout, '*** ', repr(filename), + print >>self.stdout, 'not found from sys.path' + return + else: + filename = f + arg = arg[colon+1:].lstrip() + try: + lineno = int(arg) + except ValueError, msg: + print >>self.stdout, '*** Bad lineno:', arg + return + else: + # no colon; can be lineno or function + try: + lineno = int(arg) + except ValueError: + try: + func = eval(arg, + self.curframe.f_globals, + self.curframe.f_locals) + except: + func = arg + try: + if hasattr(func, 'im_func'): + func = func.im_func + code = func.func_code + #use co_name to identify the bkpt (function names + #could be aliased, but co_name is invariant) + funcname = code.co_name + lineno = code.co_firstlineno + filename = code.co_filename + except: + # last thing to try + (ok, filename, ln) = self.lineinfo(arg) + if not ok: + print >>self.stdout, '*** The specified object', + print >>self.stdout, repr(arg), + print >>self.stdout, 'is not a function' + print >>self.stdout, 'or was not found along sys.path.' + return + funcname = ok # ok contains a function name + lineno = int(ln) + if not filename: + filename = self.defaultFile() + # Check for reasonable breakpoint + line = self.checkline(filename, lineno) + if line: + # now set the break point + err = self.set_break(filename, line, temporary, cond, funcname) + if err: print >>self.stdout, '***', err + else: + bp = self.get_breaks(filename, line)[-1] + print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number, + bp.file, + bp.line) + + # To be overridden in derived debuggers + def defaultFile(self): + """Produce a reasonable default.""" + filename = self.curframe.f_code.co_filename + if filename == '' and self.mainpyfile: + filename = self.mainpyfile + return filename + + do_b = do_break + + def do_tbreak(self, arg): + self.do_break(arg, 1) + + def lineinfo(self, identifier): + failed = (None, None, None) + # Input is identifier, may be in single quotes + idstring = identifier.split("'") + if len(idstring) == 1: + # not in single quotes + id = idstring[0].strip() + elif len(idstring) == 3: + # quoted + id = idstring[1].strip() + else: + return failed + if id == '': return failed + parts = id.split('.') + # Protection for derived debuggers + if parts[0] == 'self': + del parts[0] + if len(parts) == 0: + return failed + # Best first guess at file to look at + fname = self.defaultFile() + if len(parts) == 1: + item = parts[0] + else: + # More than one part. + # First is module, second is method/class + f = self.lookupmodule(parts[0]) + if f: + fname = f + item = parts[1] + answer = find_function(item, fname) + return answer or failed + + def checkline(self, filename, lineno): + """Check whether specified line seems to be executable. + + Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank + line or EOF). Warning: testing is not comprehensive. + """ + line = linecache.getline(filename, lineno) + if not line: + print >>self.stdout, 'End of file' + return 0 + line = line.strip() + # Don't allow setting breakpoint at a blank line + if (not line or (line[0] == '#') or + (line[:3] == '"""') or line[:3] == "'''"): + print >>self.stdout, '*** Blank or comment' + return 0 + return lineno + + def do_enable(self, arg): + args = arg.split() + for i in args: + try: + i = int(i) + except ValueError: + print >>self.stdout, 'Breakpoint index %r is not a number' % i + continue + + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): + print >>self.stdout, 'No breakpoint numbered', i + continue + + bp = bdb.Breakpoint.bpbynumber[i] + if bp: + bp.enable() + + def do_disable(self, arg): + args = arg.split() + for i in args: + try: + i = int(i) + except ValueError: + print >>self.stdout, 'Breakpoint index %r is not a number' % i + continue + + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): + print >>self.stdout, 'No breakpoint numbered', i + continue + + bp = bdb.Breakpoint.bpbynumber[i] + if bp: + bp.disable() + + def do_condition(self, arg): + # arg is breakpoint number and condition + args = arg.split(' ', 1) + bpnum = int(args[0].strip()) + try: + cond = args[1] + except: + cond = None + bp = bdb.Breakpoint.bpbynumber[bpnum] + if bp: + bp.cond = cond + if not cond: + print >>self.stdout, 'Breakpoint', bpnum, + print >>self.stdout, 'is now unconditional.' + + def do_ignore(self,arg): + """arg is bp number followed by ignore count.""" + args = arg.split() + bpnum = int(args[0].strip()) + try: + count = int(args[1].strip()) + except: + count = 0 + bp = bdb.Breakpoint.bpbynumber[bpnum] + if bp: + bp.ignore = count + if count > 0: + reply = 'Will ignore next ' + if count > 1: + reply = reply + '%d crossings' % count + else: + reply = reply + '1 crossing' + print >>self.stdout, reply + ' of breakpoint %d.' % bpnum + else: + print >>self.stdout, 'Will stop next time breakpoint', + print >>self.stdout, bpnum, 'is reached.' + + def do_clear(self, arg): + """Three possibilities, tried in this order: + clear -> clear all breaks, ask for confirmation + clear file:lineno -> clear all breaks at file:lineno + clear bpno bpno ... -> clear breakpoints by number""" + if not arg: + try: + reply = raw_input('Clear all breaks? ') + except EOFError: + reply = 'no' + reply = reply.strip().lower() + if reply in ('y', 'yes'): + self.clear_all_breaks() + return + if ':' in arg: + # Make sure it works for "clear C:\foo\bar.py:12" + i = arg.rfind(':') + filename = arg[:i] + arg = arg[i+1:] + try: + lineno = int(arg) + except ValueError: + err = "Invalid line number (%s)" % arg + else: + err = self.clear_break(filename, lineno) + if err: print >>self.stdout, '***', err + return + numberlist = arg.split() + for i in numberlist: + try: + i = int(i) + except ValueError: + print >>self.stdout, 'Breakpoint index %r is not a number' % i + continue + + if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): + print >>self.stdout, 'No breakpoint numbered', i + continue + err = self.clear_bpbynumber(i) + if err: + print >>self.stdout, '***', err + else: + print >>self.stdout, 'Deleted breakpoint', i + do_cl = do_clear # 'c' is already an abbreviation for 'continue' + + def do_where(self, arg): + self.print_stack_trace() + do_w = do_where + do_bt = do_where + + def do_up(self, arg): + if self.curindex == 0: + print >>self.stdout, '*** Oldest frame' + else: + self.curindex = self.curindex - 1 + self.curframe = self.stack[self.curindex][0] + self.print_stack_entry(self.stack[self.curindex]) + self.lineno = None + do_u = do_up + + def do_down(self, arg): + if self.curindex + 1 == len(self.stack): + print >>self.stdout, '*** Newest frame' + else: + self.curindex = self.curindex + 1 + self.curframe = self.stack[self.curindex][0] + self.print_stack_entry(self.stack[self.curindex]) + self.lineno = None + do_d = do_down + + def do_step(self, arg): + self.set_step() + return 1 + do_s = do_step + + def do_next(self, arg): + self.set_next(self.curframe) + return 1 + do_n = do_next + + def do_return(self, arg): + self.set_return(self.curframe) + return 1 + do_r = do_return + + def do_continue(self, arg): + self.set_continue() + return 1 + do_c = do_cont = do_continue + + def do_jump(self, arg): + if self.curindex + 1 != len(self.stack): + print >>self.stdout, "*** You can only jump within the bottom frame" + return + try: + arg = int(arg) + except ValueError: + print >>self.stdout, "*** The 'jump' command requires a line number." + else: + try: + # Do the jump, fix up our copy of the stack, and display the + # new position + self.curframe.f_lineno = arg + self.stack[self.curindex] = self.stack[self.curindex][0], arg + self.print_stack_entry(self.stack[self.curindex]) + except ValueError, e: + print >>self.stdout, '*** Jump failed:', e + do_j = do_jump + + def do_debug(self, arg): + sys.settrace(None) + globals = self.curframe.f_globals + locals = self.curframe.f_locals + p = Pdb() + p.prompt = "(%s) " % self.prompt.strip() + print >>self.stdout, "ENTERING RECURSIVE DEBUGGER" + sys.call_tracing(p.run, (arg, globals, locals)) + print >>self.stdout, "LEAVING RECURSIVE DEBUGGER" + sys.settrace(self.trace_dispatch) + self.lastcmd = p.lastcmd + + def do_quit(self, arg): + self._user_requested_quit = 1 + self.set_quit() + return 1 + + do_q = do_quit + do_exit = do_quit + + def do_EOF(self, arg): + print >>self.stdout + self._user_requested_quit = 1 + self.set_quit() + return 1 + + def do_args(self, arg): + f = self.curframe + co = f.f_code + dict = f.f_locals + n = co.co_argcount + if co.co_flags & 4: n = n+1 + if co.co_flags & 8: n = n+1 + for i in range(n): + name = co.co_varnames[i] + print >>self.stdout, name, '=', + if name in dict: print >>self.stdout, dict[name] + else: print >>self.stdout, "*** undefined ***" + do_a = do_args + + def do_retval(self, arg): + if '__return__' in self.curframe.f_locals: + print >>self.stdout, self.curframe.f_locals['__return__'] + else: + print >>self.stdout, '*** Not yet returned!' + do_rv = do_retval + + def _getval(self, arg): + try: + return eval(arg, self.curframe.f_globals, + self.curframe.f_locals) + except: + t, v = sys.exc_info()[:2] + if isinstance(t, str): + exc_type_name = t + else: exc_type_name = t.__name__ + print >>self.stdout, '***', exc_type_name + ':', repr(v) + raise + + def do_p(self, arg): + try: + print >>self.stdout, repr(self._getval(arg)) + except: + pass + + def do_pp(self, arg): + try: + pprint.pprint(self._getval(arg), self.stdout) + except: + pass + + def do_list(self, arg): + self.lastcmd = 'list' + last = None + if arg: + try: + x = eval(arg, {}, {}) + if type(x) == type(()): + first, last = x + first = int(first) + last = int(last) + if last < first: + # Assume it's a count + last = first + last + else: + first = max(1, int(x) - 5) + except: + print >>self.stdout, '*** Error in argument:', repr(arg) + return + elif self.lineno is None: + first = max(1, self.curframe.f_lineno - 5) + else: + first = self.lineno + 1 + if last is None: + last = first + 10 + filename = self.curframe.f_code.co_filename + breaklist = self.get_file_breaks(filename) + try: + for lineno in range(first, last+1): + line = linecache.getline(filename, lineno) + if not line: + print >>self.stdout, '[EOF]' + break + else: + s = repr(lineno).rjust(3) + if len(s) < 4: s = s + ' ' + if lineno in breaklist: s = s + 'B' + else: s = s + ' ' + if lineno == self.curframe.f_lineno: + s = s + '->' + print >>self.stdout, s + '\t' + line, + self.lineno = lineno + except KeyboardInterrupt: + pass + do_l = do_list + + def do_whatis(self, arg): + try: + value = eval(arg, self.curframe.f_globals, + self.curframe.f_locals) + except: + t, v = sys.exc_info()[:2] + if type(t) == type(''): + exc_type_name = t + else: exc_type_name = t.__name__ + print >>self.stdout, '***', exc_type_name + ':', repr(v) + return + code = None + # Is it a function? + try: code = value.func_code + except: pass + if code: + print >>self.stdout, 'Function', code.co_name + return + # Is it an instance method? + try: code = value.im_func.func_code + except: pass + if code: + print >>self.stdout, 'Method', code.co_name + return + # None of the above... + print >>self.stdout, type(value) + + def do_alias(self, arg): + args = arg.split() + if len(args) == 0: + keys = self.aliases.keys() + keys.sort() + for alias in keys: + print >>self.stdout, "%s = %s" % (alias, self.aliases[alias]) + return + if args[0] in self.aliases and len(args) == 1: + print >>self.stdout, "%s = %s" % (args[0], self.aliases[args[0]]) + else: + self.aliases[args[0]] = ' '.join(args[1:]) + + def do_unalias(self, arg): + args = arg.split() + if len(args) == 0: return + if args[0] in self.aliases: + del self.aliases[args[0]] + + #list of all the commands making the program resume execution. + commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return', + 'do_quit', 'do_jump'] + + # Print a traceback starting at the top stack frame. + # The most recently entered frame is printed last; + # this is different from dbx and gdb, but consistent with + # the Python interpreter's stack trace. + # It is also consistent with the up/down commands (which are + # compatible with dbx and gdb: up moves towards 'main()' + # and down moves towards the most recent stack frame). + + def print_stack_trace(self): + try: + for frame_lineno in self.stack: + self.print_stack_entry(frame_lineno) + except KeyboardInterrupt: + pass + + def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix): + frame, lineno = frame_lineno + if frame is self.curframe: + print >>self.stdout, '>', + else: + print >>self.stdout, ' ', + print >>self.stdout, self.format_stack_entry(frame_lineno, + prompt_prefix) + + + # Help methods (derived from pdb.doc) + + def help_help(self): + self.help_h() + + def help_h(self): + print >>self.stdout, """h(elp) +Without argument, print the list of available commands. +With a command name as argument, print help about that command +"help pdb" pipes the full documentation file to the $PAGER +"help exec" gives help on the ! command""" + + def help_where(self): + self.help_w() + + def help_w(self): + print >>self.stdout, """w(here) +Print a stack trace, with the most recent frame at the bottom. +An arrow indicates the "current frame", which determines the +context of most commands. 'bt' is an alias for this command.""" + + help_bt = help_w + + def help_down(self): + self.help_d() + + def help_d(self): + print >>self.stdout, """d(own) +Move the current frame one level down in the stack trace +(to a newer frame).""" + + def help_up(self): + self.help_u() + + def help_u(self): + print >>self.stdout, """u(p) +Move the current frame one level up in the stack trace +(to an older frame).""" + + def help_break(self): + self.help_b() + + def help_b(self): + print >>self.stdout, """b(reak) ([file:]lineno | function) [, condition] +With a line number argument, set a break there in the current +file. With a function name, set a break at first executable line +of that function. Without argument, list all breaks. If a second +argument is present, it is a string specifying an expression +which must evaluate to true before the breakpoint is honored. + +The line number may be prefixed with a filename and a colon, +to specify a breakpoint in another file (probably one that +hasn't been loaded yet). The file is searched for on sys.path; +the .py suffix may be omitted.""" + + def help_clear(self): + self.help_cl() + + def help_cl(self): + print >>self.stdout, "cl(ear) filename:lineno" + print >>self.stdout, """cl(ear) [bpnumber [bpnumber...]] +With a space separated list of breakpoint numbers, clear +those breakpoints. Without argument, clear all breaks (but +first ask confirmation). With a filename:lineno argument, +clear all breaks at that line in that file. + +Note that the argument is different from previous versions of +the debugger (in python distributions 1.5.1 and before) where +a linenumber was used instead of either filename:lineno or +breakpoint numbers.""" + + def help_tbreak(self): + print >>self.stdout, """tbreak same arguments as break, but breakpoint is +removed when first hit.""" + + def help_enable(self): + print >>self.stdout, """enable bpnumber [bpnumber ...] +Enables the breakpoints given as a space separated list of +bp numbers.""" + + def help_disable(self): + print >>self.stdout, """disable bpnumber [bpnumber ...] +Disables the breakpoints given as a space separated list of +bp numbers.""" + + def help_ignore(self): + print >>self.stdout, """ignore bpnumber count +Sets the ignore count for the given breakpoint number. A breakpoint +becomes active when the ignore count is zero. When non-zero, the +count is decremented each time the breakpoint is reached and the +breakpoint is not disabled and any associated condition evaluates +to true.""" + + def help_condition(self): + print >>self.stdout, """condition bpnumber str_condition +str_condition is a string specifying an expression which +must evaluate to true before the breakpoint is honored. +If str_condition is absent, any existing condition is removed; +i.e., the breakpoint is made unconditional.""" + + def help_step(self): + self.help_s() + + def help_s(self): + print >>self.stdout, """s(tep) +Execute the current line, stop at the first possible occasion +(either in a function that is called or in the current function).""" + + def help_next(self): + self.help_n() + + def help_n(self): + print >>self.stdout, """n(ext) +Continue execution until the next line in the current function +is reached or it returns.""" + + def help_return(self): + self.help_r() + + def help_r(self): + print >>self.stdout, """r(eturn) +Continue execution until the current function returns.""" + + def help_continue(self): + self.help_c() + + def help_cont(self): + self.help_c() + + def help_c(self): + print >>self.stdout, """c(ont(inue)) +Continue execution, only stop when a breakpoint is encountered.""" + + def help_jump(self): + self.help_j() + + def help_j(self): + print >>self.stdout, """j(ump) lineno +Set the next line that will be executed.""" + + def help_debug(self): + print >>self.stdout, """debug code +Enter a recursive debugger that steps through the code argument +(which is an arbitrary expression or statement to be executed +in the current environment).""" + + def help_list(self): + self.help_l() + + def help_l(self): + print >>self.stdout, """l(ist) [first [,last]] +List source code for the current file. +Without arguments, list 11 lines around the current line +or continue the previous listing. +With one argument, list 11 lines starting at that line. +With two arguments, list the given range; +if the second argument is less than the first, it is a count.""" + + def help_args(self): + self.help_a() + + def help_a(self): + print >>self.stdout, """a(rgs) +Print the arguments of the current function.""" + + def help_p(self): + print >>self.stdout, """p expression +Print the value of the expression.""" + + def help_pp(self): + print >>self.stdout, """pp expression +Pretty-print the value of the expression.""" + + def help_exec(self): + print >>self.stdout, """(!) statement +Execute the (one-line) statement in the context of +the current stack frame. +The exclamation point can be omitted unless the first word +of the statement resembles a debugger command. +To assign to a global variable you must always prefix the +command with a 'global' command, e.g.: +(Pdb) global list_options; list_options = ['-l'] +(Pdb)""" + + def help_quit(self): + self.help_q() + + def help_q(self): + print >>self.stdout, """q(uit) or exit - Quit from the debugger. +The program being executed is aborted.""" + + help_exit = help_q + + def help_whatis(self): + print >>self.stdout, """whatis arg +Prints the type of the argument.""" + + def help_EOF(self): + print >>self.stdout, """EOF +Handles the receipt of EOF as a command.""" + + def help_alias(self): + print >>self.stdout, """alias [name [command [parameter parameter ...] ]] +Creates an alias called 'name' the executes 'command'. The command +must *not* be enclosed in quotes. Replaceable parameters are +indicated by %1, %2, and so on, while %* is replaced by all the +parameters. If no command is given, the current alias for name +is shown. If no name is given, all aliases are listed. + +Aliases may be nested and can contain anything that can be +legally typed at the pdb prompt. Note! You *can* override +internal pdb commands with aliases! Those internal commands +are then hidden until the alias is removed. Aliasing is recursively +applied to the first word of the command line; all other words +in the line are left alone. + +Some useful aliases (especially when placed in the .pdbrc file) are: + +#Print instance variables (usage "pi classInst") +alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k] + +#Print instance variables in self +alias ps pi self +""" + + def help_unalias(self): + print >>self.stdout, """unalias name +Deletes the specified alias.""" + + def help_commands(self): + print >>self.stdout, """commands [bpnumber] +(com) ... +(com) end +(Pdb) + +Specify a list of commands for breakpoint number bpnumber. The +commands themselves appear on the following lines. Type a line +containing just 'end' to terminate the commands. + +To remove all commands from a breakpoint, type commands and +follow it immediately with end; that is, give no commands. + +With no bpnumber argument, commands refers to the last +breakpoint set. + +You can use breakpoint commands to start your program up again. +Simply use the continue command, or step, or any other +command that resumes execution. + +Specifying any command resuming execution (currently continue, +step, next, return, jump, quit and their abbreviations) terminates +the command list (as if that command was immediately followed by end). +This is because any time you resume execution +(even with a simple next or step), you may encounter +another breakpoint--which could have its own command list, leading to +ambiguities about which list to execute. + + If you use the 'silent' command in the command list, the +usual message about stopping at a breakpoint is not printed. This may +be desirable for breakpoints that are to print a specific message and +then continue. If none of the other commands print anything, you +see no sign that the breakpoint was reached. +""" + + def help_pdb(self): + help() + + def lookupmodule(self, filename): + """Helper function for break/clear parsing -- may be overridden. + + lookupmodule() translates (possibly incomplete) file or module name + into an absolute file name. + """ + if os.path.isabs(filename) and os.path.exists(filename): + return filename + f = os.path.join(sys.path[0], filename) + if os.path.exists(f) and self.canonic(f) == self.mainpyfile: + return f + root, ext = os.path.splitext(filename) + if ext == '': + filename = filename + '.py' + if os.path.isabs(filename): + return filename + for dirname in sys.path: + while os.path.islink(dirname): + dirname = os.readlink(dirname) + fullname = os.path.join(dirname, filename) + if os.path.exists(fullname): + return fullname + return None + + def _runscript(self, filename): + # Start with fresh empty copy of globals and locals and tell the script + # that it's being run as __main__ to avoid scripts being able to access + # the pdb.py namespace. + globals_ = {"__name__" : "__main__"} + locals_ = globals_ + + # When bdb sets tracing, a number of call and line events happens + # BEFORE debugger even reaches user's code (and the exact sequence of + # events depends on python version). So we take special measures to + # avoid stopping before we reach the main script (see user_line and + # user_call for details). + self._wait_for_mainpyfile = 1 + self.mainpyfile = self.canonic(filename) + self._user_requested_quit = 0 + statement = 'execfile( "%s")' % filename + self.run(statement, globals=globals_, locals=locals_) + +# Simplified interface + +def run(statement, globals=None, locals=None): + Pdb().run(statement, globals, locals) + +def runeval(expression, globals=None, locals=None): + return Pdb().runeval(expression, globals, locals) + +def runctx(statement, globals, locals): + # B/W compatibility + run(statement, globals, locals) + +def runcall(*args, **kwds): + return Pdb().runcall(*args, **kwds) + +def set_trace(): + Pdb().set_trace(sys._getframe().f_back) + +# Post-Mortem interface + +def post_mortem(t): + p = Pdb() + p.reset() + while t.tb_next is not None: + t = t.tb_next + p.interaction(t.tb_frame, t) + +def pm(): + post_mortem(sys.last_traceback) + + +# Main program for testing + +TESTCMD = 'import x; x.main()' + +def test(): + run(TESTCMD) + +# print help +def help(): + for dirname in sys.path: + fullname = os.path.join(dirname, 'pdb.doc') + if os.path.exists(fullname): + sts = os.system('${PAGER-more} '+fullname) + if sts: print '*** Pager exit status:', sts + break + else: + print 'Sorry, can\'t find the help file "pdb.doc"', + print 'along the Python search path' + +def main(): + if not sys.argv[1:]: + print "usage: pdb.py scriptfile [arg] ..." + sys.exit(2) + + mainpyfile = sys.argv[1] # Get script filename + if not os.path.exists(mainpyfile): + print 'Error:', mainpyfile, 'does not exist' + sys.exit(1) + + del sys.argv[0] # Hide "pdb.py" from argument list + + # Replace pdb's dir with script's dir in front of module search path. + sys.path[0] = os.path.dirname(mainpyfile) + + # Note on saving/restoring sys.argv: it's a good idea when sys.argv was + # modified by the script being debugged. It's a bad idea when it was + # changed by the user from the command line. The best approach would be to + # have a "restart" command which would allow explicit specification of + # command line arguments. + pdb = Pdb() + while 1: + try: + pdb._runscript(mainpyfile) + if pdb._user_requested_quit: + break + print "The program finished and will be restarted" + except SystemExit: + # In most cases SystemExit does not warrant a post-mortem session. + print "The program exited via sys.exit(). Exit status: ", + print sys.exc_info()[1] + except: + traceback.print_exc() + print "Uncaught exception. Entering post mortem debugging" + print "Running 'cont' or 'step' will restart the program" + t = sys.exc_info()[2] + while t.tb_next is not None: + t = t.tb_next + pdb.interaction(t.tb_frame,t) + print "Post mortem debugger finished. The "+mainpyfile+" will be restarted" + + +# When invoked as main program, invoke the debugger on a script +if __name__=='__main__': + main() From python-checkins at python.org Thu May 25 17:22:03 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 17:22:03 +0200 (CEST) Subject: [Python-checkins] r46214 - python/trunk/Objects/stringobject.c Message-ID: <20060525152203.C5F8A1E400B@bag.python.org> Author: fredrik.lundh Date: Thu May 25 17:22:03 2006 New Revision: 46214 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: speed up upper and lower for 8-bit string objects. (the unicode versions of these are still 2x faster on windows, though...) based on work by Andrew Dalke, with tweaks by yours truly. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 17:22:03 2006 @@ -2036,26 +2036,25 @@ static PyObject * string_lower(PyStringObject *self) { - char *s = PyString_AS_STRING(self), *s_new; + char *s; Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; - newobj = PyString_FromStringAndSize(NULL, n); - if (newobj == NULL) + newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); + if (!newobj) return NULL; - s_new = PyString_AsString(newobj); + + s = PyString_AS_STRING(newobj); + for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) { - *s_new = tolower(c); - } else - *s_new = c; - s_new++; + char c = Py_CHARMASK(s[i]); + if (isupper(c)) + s[i] = _tolower(c); } + return newobj; } - PyDoc_STRVAR(upper__doc__, "S.upper() -> string\n\ \n\ @@ -2064,26 +2063,25 @@ static PyObject * string_upper(PyStringObject *self) { - char *s = PyString_AS_STRING(self), *s_new; + char *s; Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; - newobj = PyString_FromStringAndSize(NULL, n); - if (newobj == NULL) + newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); + if (!newobj) return NULL; - s_new = PyString_AsString(newobj); + + s = PyString_AS_STRING(newobj); + for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - *s_new = toupper(c); - } else - *s_new = c; - s_new++; + char c = Py_CHARMASK(s[i]); + if (islower(c)) + s[i] = _toupper(c); } + return newobj; } - PyDoc_STRVAR(title__doc__, "S.title() -> string\n\ \n\ From mal at egenix.com Thu May 25 17:22:10 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 25 May 2006 17:22:10 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <4475501F.1030106@v.loewis.de> References: <20060523192101.43DF31E401A@bag.python.org> <447363CA.30604@egenix.com> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44743C3D.2000409@egenix.com> <4475501F.1030106@v.loewis.de> Message-ID: <4475CBA2.6010708@egenix.com> Martin v. L?wis wrote: > M.-A. Lemburg wrote: >> I did the next best thing: >> >> win32process.GetProcessTimes(win32process.GetCurrentProcess()) >> >> Looking at the win32 docs, the GetCurrentProcess() returns an >> int where GetProcessTimes() wants a PyHANDLE. >> >> Shouldn't have known better though to actually *look* at >> the return value of GetCurrentProcess(): >> >> -1 >> >> Looks like I should have used OpenProcess() instead. > > See > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getcurrentprocess.asp > > The process handle -1 *does* denote the current process; you > don't need to open your own process. Hmm, then I don't understand why I get weird results from the GetProcessTimes() API. I'll have to do some more testing. It's possible that the Windows API has a different understanding of what "user time" refers to than e.g. Linux does. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 25 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tim.peters at gmail.com Thu May 25 17:26:43 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 15:26:43 +0000 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <4475CBA2.6010708@egenix.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44743C3D.2000409@egenix.com> <4475501F.1030106@v.loewis.de> <4475CBA2.6010708@egenix.com> Message-ID: <1f7befae0605250826m13dc994i82319f7d17b8f608@mail.gmail.com> [M.-A. Lemburg] > Hmm, then I don't understand why I get weird results from the > GetProcessTimes() API. > > I'll have to do some more testing. > > It's possible that the Windows API has a different understanding > of what "user time" refers to than e.g. Linux does. It might be helpful to post the code you're using, and describe what you did with it in sufficient detail so that others could confirm or deny they see the same thing on their Windows box. From buildbot at python.org Thu May 25 17:33:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:33:07 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060525153307.503E71E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/463 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 17:34:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:34:10 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060525153410.537551E4022@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/669 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 17:34:29 2006 From: python-checkins at python.org (martin.blais) Date: Thu, 25 May 2006 17:34:29 +0200 (CEST) Subject: [Python-checkins] r46215 - in python/branches/blais-bytebuf: Lib/test/test_hotbuf.py Modules/_hotbuf.c Message-ID: <20060525153429.BCF2E1E400B@bag.python.org> Author: martin.blais Date: Thu May 25 17:34:28 2006 New Revision: 46215 Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Modules/_hotbuf.c Log: Added getstr/putstr methods to the hot blue lagoon bufferola Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Thu May 25 17:34:28 2006 @@ -12,6 +12,8 @@ CAPACITY = 1024 +MSG = 'Martin Blais was here scribble scribble.' + class HotbufTestCase(unittest.TestCase): @@ -102,6 +104,23 @@ # Test underflow. self.assertRaises(IndexError, b.putbyte, 42) + def test_str( self ): + b = hotbuf(256) + + # Write into the buffer + b.putstr(MSG) + b.flip() + + # Read back and assert message + self.assertEquals(b.getstr(len(MSG)), MSG) + + # Test overflow. + b.flip() + self.assertRaises(IndexError, b.putstr, ' ' * 1000) + + # Test underflow. + self.assertRaises(IndexError, b.getstr, 1000) + def test_conversion( self ): b = hotbuf(CAPACITY) Modified: python/branches/blais-bytebuf/Modules/_hotbuf.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_hotbuf.c (original) +++ python/branches/blais-bytebuf/Modules/_hotbuf.c Thu May 25 17:34:28 2006 @@ -172,7 +172,7 @@ min_len = ((len_self < len_other) ? len_self : len_other); if (min_len > 0) { - cmp = memcmp(self->b_ptr + self->b_position, + cmp = memcmp(self->b_ptr + self->b_position, other->b_ptr + other->b_position, min_len); if (cmp != 0) return cmp; @@ -204,7 +204,7 @@ return Py_None; } return PyString_FromStringAndSize( - (const char *)(self->b_ptr + self->b_position), + (const char *)(self->b_ptr + self->b_position), self->b_limit - self->b_position); } @@ -247,6 +247,44 @@ } +PyDoc_STRVAR(advance__doc__, +"B.advance(int)\n\ +\n\ +Advance this buffer's position by the given number of bytes. \n\ +If the mark is defined and larger than\n\ +the new position then it is discarded. If the given position is\n\ +larger than the limit an exception is raised."); + +static PyObject* +hotbuf_advance(PyHotbufObject *self, PyObject* arg) +{ + int nbytes; + int newposition; + + nbytes = PyInt_AsLong(arg); + if (nbytes == -1 && PyErr_Occurred()) + return NULL; + + newposition = self->b_position + nbytes; + if ( newposition > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than capacity"); + return NULL; + } + + /* Set the new position */ + self->b_position = newposition; + + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + return Py_None; +} + + + + PyDoc_STRVAR(setlimit__doc__, "B.setlimit(int)\n\ \n\ @@ -471,7 +509,7 @@ * Object Methods (get/put methods) */ -PyDoc_STRVAR(relative_get__doc__, +PyDoc_STRVAR(get__doc__, "B.get*() -> data\n\ \n\ Relative get methods. \n\ @@ -479,7 +517,7 @@ and then increments the position.\n\ An IndexError is raised if the position is at the end of the buffer."); -PyDoc_STRVAR(relative_put__doc__, +PyDoc_STRVAR(put__doc__, "B.put*(data)\n\ \n\ Relative put methods. \n\ @@ -530,53 +568,72 @@ } +PyDoc_STRVAR(getstr__doc__, +"B.getstr(nbytes) -> data\n\ +\n\ +Extract a string of 'nbytes' bytes from the buffer and advance the \n\ +position accordingly.\n\ +An IndexError is raised if the position is at the end of the buffer."); + static PyObject* -hotbuf_getstring(PyHotbufObject *self, PyObject* arg) +hotbuf_getstr(PyHotbufObject *self, PyObject* arg) { int len; - CHECK_LIMIT_ERROR(sizeof(byte)); + PyObject* s; + /* Extract the given number of bytes */ len = PyInt_AsLong(arg); if (len == -1 && PyErr_Occurred()) return NULL; + + CHECK_LIMIT_ERROR(len); - if (len > (self->b_limit - self->b_position)) { - PyErr_SetString(PyExc_IndexError, - "cannot read beyond limit"); - return NULL; - } + /* Extract the string object from the buffer */ + s = PyString_FromStringAndSize( + (const char *)(self->b_ptr + self->b_position), len); -FIXME continue here + /* Advance to the new position */ + self->b_position += len; - return PyString_FromStringAndSize( - (const char *)(self->b_ptr + self->b_position), len); -} + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; -FIXME continue here + /* Return the new string */ + return s; +} -FIXME we need to find a way to automatically advance position without doing it in Python +PyDoc_STRVAR(putstr__doc__, +"B.putstr(str)\n\ +\n\ +Write a string of 'nbytes' bytes from the buffer and advance the \n\ +position accordingly.\n\ +An IndexError is raised if the position is at the end of the buffer."); static PyObject* -hotbuf_putstring(PyHotbufObject *self, PyObject* arg) +hotbuf_putstr(PyHotbufObject *self, PyObject* arg) { - int byte_i; - unsigned char byte; - - byte_i = PyInt_AsLong(arg); - if (byte_i == -1 && PyErr_Occurred()) - return NULL; + char *instring; + int len; - if ( byte_i > 255 ) { + /* Check and extract input string */ + if ( arg == NULL || !PyString_Check(arg) ) { PyErr_SetString(PyExc_ValueError, - "overflow for byte"); + "incorrect input type, require string"); return NULL; } - byte = (unsigned char)byte_i; + instring = PyString_AsString(arg); + len = strlen(instring); + + CHECK_LIMIT_ERROR(len); + + /* Copy the string into the buffer */ + memcpy(self->b_ptr, instring, len); + + /* Advance the position */ + self->b_position += len; - CHECK_LIMIT_ERROR(sizeof(byte)); - *(unsigned char*)(self->b_ptr + self->b_position) = byte; - self->b_position += sizeof(byte); return Py_None; } @@ -678,6 +735,7 @@ hotbuf_methods[] = { {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, + {"advance", (PyCFunction)hotbuf_advance, METH_O, advance__doc__}, {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, @@ -685,8 +743,10 @@ {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, - {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, relative_get__doc__}, - {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, relative_put__doc__}, + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, get__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, + {"getstr", (PyCFunction)hotbuf_getstr, METH_O, getstr__doc__}, + {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, {NULL, NULL} /* sentinel */ }; From buildbot at python.org Thu May 25 17:40:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:40:07 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060525154007.A82841E400B@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/429 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 17:43:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:43:15 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060525154316.0DE781E400B@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/183 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 17:45:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:45:42 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060525154542.88D641E400B@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/749 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 17:46:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 15:46:32 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060525154632.BD2951E400B@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/491 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 17:49:46 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 17:49:46 +0200 (CEST) Subject: [Python-checkins] r46216 - python/trunk/Objects/stringobject.c Message-ID: <20060525154946.66EED1E400B@bag.python.org> Author: fredrik.lundh Date: Thu May 25 17:49:45 2006 New Revision: 46216 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: make new upper/lower work properly for single-character strings too... (thanks to georg brandl for spotting the exact problem faster than anyone else) Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 17:49:45 2006 @@ -2040,14 +2040,16 @@ Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; - newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); + newobj = PyString_FromStringAndSize(NULL, n); if (!newobj) return NULL; s = PyString_AS_STRING(newobj); + memcpy(s, PyString_AS_STRING(self), n); + for (i = 0; i < n; i++) { - char c = Py_CHARMASK(s[i]); + int c = Py_CHARMASK(s[i]); if (isupper(c)) s[i] = _tolower(c); } @@ -2067,14 +2069,16 @@ Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; - newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); + newobj = PyString_FromStringAndSize(NULL, n); if (!newobj) return NULL; s = PyString_AS_STRING(newobj); + memcpy(s, PyString_AS_STRING(self), n); + for (i = 0; i < n; i++) { - char c = Py_CHARMASK(s[i]); + int c = Py_CHARMASK(s[i]); if (islower(c)) s[i] = _toupper(c); } From python-checkins at python.org Thu May 25 17:53:38 2006 From: python-checkins at python.org (kristjan.jonsson) Date: Thu, 25 May 2006 17:53:38 +0200 (CEST) Subject: [Python-checkins] r46217 - in python/trunk: Include/pyport.h Objects/floatobject.c PC/pyconfig.h Message-ID: <20060525155338.959761E400B@bag.python.org> Author: kristjan.jonsson Date: Thu May 25 17:53:30 2006 New Revision: 46217 Modified: python/trunk/Include/pyport.h python/trunk/Objects/floatobject.c python/trunk/PC/pyconfig.h Log: Added a new macro, Py_IS_FINITE(X). On windows there is an intrinsic for this and it is more efficient than to use !Py_IS_INFINITE(X) && !Py_IS_NAN(X). No change on other platforms Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Thu May 25 17:53:30 2006 @@ -295,6 +295,15 @@ #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) #endif +/* Py_IS_INFINITY(X) + * Return 1 if float or double arg is an infinity, else 0. + * This some archicetcures (windows) have intrisics for this, so a special + * macro for this particular test is useful + */ +#ifndef Py_IS_FINITE +#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) +#endif + /* HUGE_VAL is supposed to expand to a positive double infinity. Python * uses Py_HUGE_VAL instead because some platforms are broken in this * respect. We used to embed code in pyport.h to try to worm around that, Modified: python/trunk/Objects/floatobject.c ============================================================================== --- python/trunk/Objects/floatobject.c (original) +++ python/trunk/Objects/floatobject.c Thu May 25 17:53:30 2006 @@ -384,7 +384,7 @@ if (PyFloat_Check(w)) j = PyFloat_AS_DOUBLE(w); - else if (Py_IS_INFINITY(i) || Py_IS_NAN(i)) { + else if (!Py_IS_FINITE(i)) { if (PyInt_Check(w) || PyLong_Check(w)) /* If i is an infinity, its magnitude exceeds any * finite integer, so it doesn't matter which int we @@ -802,10 +802,7 @@ * bug; we let that slide in math.pow() (which currently * reflects all platform accidents), but not for Python's **. */ - if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) { - /* XXX the "iw == iw" was to weed out NaNs. This - * XXX doesn't actually work on all platforms. - */ + if (iv == -1.0 && Py_IS_FINITE(iw)) { /* Return 1 if iw is even, -1 if iw is odd; there's * no guarantee that any C integral type is big * enough to hold iw, so we have to check this Modified: python/trunk/PC/pyconfig.h ============================================================================== --- python/trunk/PC/pyconfig.h (original) +++ python/trunk/PC/pyconfig.h Thu May 25 17:53:30 2006 @@ -162,6 +162,7 @@ #include #define Py_IS_NAN _isnan #define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) +#define Py_IS_FINITE(X) _finite(X) #endif /* _MSC_VER */ From python-checkins at python.org Thu May 25 17:57:04 2006 From: python-checkins at python.org (richard.tew) Date: Thu, 25 May 2006 17:57:04 +0200 (CEST) Subject: [Python-checkins] r46218 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060525155704.4FF1F1E400B@bag.python.org> Author: richard.tew Date: Thu May 25 17:56:59 2006 New Revision: 46218 Modified: sandbox/trunk/stringbench/stringbench.py Log: Add a string formatting test. Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Thu May 25 17:56:59 2006 @@ -738,6 +738,34 @@ s_replace(from_str, to_str) +# CCP does a lot of this, for internationalisation of ingame messages. +_format = "The %(thing)s is %(place)s the %(location)s." +_format_dict = { "thing":"THING", "place":"PLACE", "location":"LOCATION", } +_format_unicode = unicode(_format) +_format_dict_unicode = dict([ (unicode(k), unicode(v)) for (k,v) in _format_dict.iteritems() ]) + +def _get_format(STR): + if STR is unicode: + return _format_unicode + if STR is str: + return _format + raise AssertionError + +def _get_format_dict(STR): + if STR is unicode: + return _format_dict_unicode + if STR is str: + return _format_dict + raise AssertionError + +# Formatting. + at bench('"The %(k1)s is %(k2)s the %(k3)s."%{"k1":"x","k2":"y","k3":"z",}', + 'formatting a string type with a dict', 1000) +def format_with_dict(STR): + s = _get_format(STR) + d = _get_format_dict(STR) + for x in _RANGE_1000: + s % d # end of benchmarks From buildbot at python.org Thu May 25 18:05:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 16:05:46 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060525160546.55E1F1E400B@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/753 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 18:06:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 16:06:45 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060525160645.6A80E1E400B@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/839 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 18:09:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 16:09:39 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060525160939.2D8BE1E400B@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/527 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 18:10:14 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 18:10:14 +0200 (CEST) Subject: [Python-checkins] r46219 - python/trunk/Objects/stringobject.c Message-ID: <20060525161014.62AF11E400B@bag.python.org> Author: fredrik.lundh Date: Thu May 25 18:10:12 2006 New Revision: 46219 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: _toupper/_tolower is a SUSv2 thing; fall back on ISO C versions if they're not defined. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 18:10:12 2006 @@ -2033,6 +2033,11 @@ \n\ Return a copy of the string S converted to lowercase."); +/* _tolower and _toupper are defined by SUSv2, but they're not ISO C */ +#ifndef _tolower +#define _tolower tolower +#endif + static PyObject * string_lower(PyStringObject *self) { @@ -2062,6 +2067,10 @@ \n\ Return a copy of the string S converted to uppercase."); +#ifndef _toupper +#define _toupper toupper +#endif + static PyObject * string_upper(PyStringObject *self) { From mal at egenix.com Thu May 25 18:17:55 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 25 May 2006 18:17:55 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605250826m13dc994i82319f7d17b8f608@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <1f7befae0605240342g1d63ffd5w5f2f77f8b6c0dbd3@mail.gmail.com> <44743C3D.2000409@egenix.com> <4475501F.1030106@v.loewis.de> <4475CBA2.6010708@egenix.com> <1f7befae0605250826m13dc994i82319f7d17b8f608@mail.gmail.com> Message-ID: <4475D8B3.9080504@egenix.com> Tim Peters wrote: > [M.-A. Lemburg] >> Hmm, then I don't understand why I get weird results from the >> GetProcessTimes() API. >> >> I'll have to do some more testing. While converting the IDLE interactive session into a usable test script, I found that the IDLE interface must have been playing some tricks on me: running the module on its own created more reasonable results. I've attached the script below. I'm not sure whether the 100ns interval mentioned in the win32 docs is correct. The times I'm getting is 2.25 seconds for the load part on Linux and 0.295 seconds on Windows. It's possible that the values returned for UserTime and KernelTime are in fact micro-seconds. >> It's possible that the Windows API has a different understanding >> of what "user time" refers to than e.g. Linux does. > > It might be helpful to post the code you're using, and describe what > you did with it in sufficient detail so that others could confirm or > deny they see the same thing on their Windows box. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 25 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: time_clock.py Url: http://mail.python.org/pipermail/python-checkins/attachments/20060525/e60c1a26/attachment.asc From jimjjewett at gmail.com Thu May 25 18:21:09 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 25 May 2006 12:21:09 -0400 Subject: [Python-checkins] r46216 - python/trunk/Objects/stringobject.c In-Reply-To: <20060525154946.66EED1E400B@bag.python.org> References: <20060525154946.66EED1E400B@bag.python.org> Message-ID: On 5/25/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Thu May 25 17:49:45 2006 > New Revision: 46216 > > Modified: > python/trunk/Objects/stringobject.c > Log: > needforspeed: make new upper/lower work properly for single-character > strings too... (thanks to georg brandl for spotting the exact problem > faster than anyone else) ============================================================================== > --- python/trunk/Objects/stringobject.c (original) > +++ python/trunk/Objects/stringobject.c Thu May 25 17:49:45 2006 > @@ -2040,14 +2040,16 @@ > Py_ssize_t i, n = PyString_GET_SIZE(self); > PyObject *newobj; > > - newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); > + newobj = PyString_FromStringAndSize(NULL, n); > if (!newobj) > return NULL; > > s = PyString_AS_STRING(newobj); > > + memcpy(s, PyString_AS_STRING(self), n); Doesn't PyString_FromStringAndSize already fill newobj with a copy of the current string? > + > for (i = 0; i < n; i++) { > - char c = Py_CHARMASK(s[i]); > + int c = Py_CHARMASK(s[i]); > if (isupper(c)) > s[i] = _tolower(c); > } Do you want to check that any characters actually changed, and just return an incremented self otherwise? -jJ From python-checkins at python.org Thu May 25 18:23:16 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 18:23:16 +0200 (CEST) Subject: [Python-checkins] r46220 - python/trunk/Include/pyport.h Message-ID: <20060525162316.EE7011E400B@bag.python.org> Author: andrew.kuchling Date: Thu May 25 18:23:15 2006 New Revision: 46220 Modified: python/trunk/Include/pyport.h Log: Fix comment typos Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Thu May 25 18:23:15 2006 @@ -297,7 +297,7 @@ /* Py_IS_INFINITY(X) * Return 1 if float or double arg is an infinity, else 0. - * This some archicetcures (windows) have intrisics for this, so a special + * Some architectures (Windows) have intrisics for this, so a special * macro for this particular test is useful */ #ifndef Py_IS_FINITE From buildbot at python.org Thu May 25 18:27:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 16:27:21 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060525162722.2070B1E400B@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/771 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 18:30:53 2006 From: python-checkins at python.org (andrew.dalke) Date: Thu, 25 May 2006 18:30:53 +0200 (CEST) Subject: [Python-checkins] r46221 - python/trunk/Lib/test/string_tests.py Message-ID: <20060525163053.2A0F21E401E@bag.python.org> Author: andrew.dalke Date: Thu May 25 18:30:52 2006 New Revision: 46221 Modified: python/trunk/Lib/test/string_tests.py Log: Added tests for implementation error we came up with in the need for speed sprint. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Thu May 25 18:30:52 2006 @@ -882,6 +882,25 @@ else: self.checkcall(format, "__mod__", value) + def test_inplace_rewrites(self): + # Check that strings don't copy and modify cached single-character strings + self.checkequal('a', 'A', 'lower') + self.checkequal(True, 'A', 'isupper') + self.checkequal('A', 'a', 'upper') + self.checkequal(True, 'a', 'islower') + + self.checkequal('a', 'A', 'replace', 'A', 'a') + self.checkequal(True, 'A', 'isupper') + + self.checkequal('A', 'a', 'capitalize') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'swapcase') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'title') + self.checkequal(True, 'a', 'islower') + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and From python-checkins at python.org Thu May 25 18:34:55 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 18:34:55 +0200 (CEST) Subject: [Python-checkins] r46222 - python/trunk/Include/pyport.h Message-ID: <20060525163455.6BCA41E400B@bag.python.org> Author: andrew.kuchling Date: Thu May 25 18:34:54 2006 New Revision: 46222 Modified: python/trunk/Include/pyport.h Log: Fix another typo Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Thu May 25 18:34:54 2006 @@ -297,7 +297,7 @@ /* Py_IS_INFINITY(X) * Return 1 if float or double arg is an infinity, else 0. - * Some architectures (Windows) have intrisics for this, so a special + * Some architectures (Windows) have intrinsics for this, so a special * macro for this particular test is useful */ #ifndef Py_IS_FINITE From python-checkins at python.org Thu May 25 18:39:28 2006 From: python-checkins at python.org (kristjan.jonsson) Date: Thu, 25 May 2006 18:39:28 +0200 (CEST) Subject: [Python-checkins] r46223 - python/trunk/Include/pyport.h Message-ID: <20060525163928.B41FB1E400B@bag.python.org> Author: kristjan.jonsson Date: Thu May 25 18:39:27 2006 New Revision: 46223 Modified: python/trunk/Include/pyport.h Log: Fix incorrect documentation for the Py_IS_FINITE(X) macro. Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Thu May 25 18:39:27 2006 @@ -295,9 +295,9 @@ #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) #endif -/* Py_IS_INFINITY(X) - * Return 1 if float or double arg is an infinity, else 0. - * Some architectures (Windows) have intrinsics for this, so a special +/* Py_IS_FINITE(X) + * Return 1 if float or double arg is neither infinite nor NAN, else 0. + * Some compilers (e.g. VisualStudio) have intrisics for this, so a special * macro for this particular test is useful */ #ifndef Py_IS_FINITE From fredrik at pythonware.com Thu May 25 18:40:58 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 25 May 2006 18:40:58 +0200 Subject: [Python-checkins] r46216 - python/trunk/Objects/stringobject.c In-Reply-To: References: <20060525154946.66EED1E400B@bag.python.org> Message-ID: Jim Jewett wrote: >> - newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); >> + newobj = PyString_FromStringAndSize(NULL, n); >> if (!newobj) >> return NULL; >> >> s = PyString_AS_STRING(newobj); >> >> + memcpy(s, PyString_AS_STRING(self), n); > > Doesn't PyString_FromStringAndSize already fill newobj with a copy of > the current string? the problem is that if you pass in a char pointer as the first argument, you may get back a reference an existing Python string object... From python-checkins at python.org Thu May 25 18:46:55 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 18:46:55 +0200 (CEST) Subject: [Python-checkins] r46224 - in python/trunk: Lib/test/string_tests.py Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060525164655.ED21E1E400C@bag.python.org> Author: fredrik.lundh Date: Thu May 25 18:46:54 2006 New Revision: 46224 Modified: python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: check for overflow in replace (from Andrew Dalke) Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Thu May 25 18:46:54 2006 @@ -555,15 +555,14 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) -### Commented out until the underlying libraries are fixed -## def test_replace_overflow(self): -## # Check for overflow checking on 32 bit machines -## if sys.maxint != 2147483647: -## return -## A2_16 = "A" * (2**16) -## self.checkraises(OverflowError, A2_16, "replace", "", A2_16) -## self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) -## self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) + def test_replace_overflow(self): + # Check for overflow checking on 32 bit machines + if sys.maxint != 2147483647: + return + A2_16 = "A" * (2**16) + self.checkraises(OverflowError, A2_16, "replace", "", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) def test_zfill(self): self.checkequal('123', '123', 'zfill', 2) Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 18:46:54 2006 @@ -2460,6 +2460,7 @@ char *out_s; char *new_s; Py_ssize_t nfound, offset, new_len; + Py_ssize_t product, delta; if (len == 0 || (pat_len == 0 && sub_len == 0) || pat_len > len) goto return_same; @@ -2473,7 +2474,24 @@ if (nfound == 0) goto return_same; - new_len = len + nfound*(sub_len - pat_len); + delta = (sub_len - pat_len); + if (delta == 0) { + new_len = len; + } else { + product = nfound * (sub_len - pat_len); + if ((product / (sub_len - pat_len)) != nfound) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + new_len = len + product; + if (new_len < 0) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + } + if (new_len == 0) { /* Have to allocate something for the caller to free(). */ out_s = (char *)PyMem_MALLOC(1); @@ -2578,7 +2596,8 @@ new_s = mymemreplace(str,len,sub,sub_len,repl,repl_len,count,&out_len); if (new_s == NULL) { - PyErr_NoMemory(); + if (!PyErr_Occurred()) + PyErr_NoMemory(); return NULL; } if (out_len == -1) { Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Thu May 25 18:46:54 2006 @@ -3866,9 +3866,11 @@ for some more background, see: http://effbot.org/stringlib */ /* note: fastsearch may access s[n], which isn't a problem when using - Python's ordinary string types. also, the count mode returns -1 if - there cannot possible be a match in the target string, and 0 if it - has actually checked for matches. */ + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possible be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ #define FAST_COUNT 0 #define FAST_SEARCH 1 @@ -4862,6 +4864,7 @@ } else { Py_ssize_t n, i; + Py_ssize_t product, new_size, delta; Py_UNICODE *p; /* replace strings */ @@ -4870,7 +4873,25 @@ n = maxcount; if (n == 0) goto nothing; - u = _PyUnicode_New(self->length + n * (str2->length - str1->length)); + /* new_size = self->length + n * (str2->length - str1->length)); */ + delta = (str2->length - str1->length); + if (delta == 0) { + new_size = self->length; + } else { + product = n * (str2->length - str1->length); + if ((product / (str2->length - str1->length)) != n) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + new_size = self->length + product; + if (new_size < 0) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + } + u = _PyUnicode_New(new_size); if (!u) return NULL; i = 0; From python-checkins at python.org Thu May 25 19:05:04 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 19:05:04 +0200 (CEST) Subject: [Python-checkins] r46225 - sandbox/trunk/newstruct/Modules/_newstruct.c Message-ID: <20060525170504.09B501E400C@bag.python.org> Author: bob.ippolito Date: Thu May 25 19:05:03 2006 New Revision: 46225 Modified: sandbox/trunk/newstruct/Modules/_newstruct.c Log: use int instead of long when possible, use PyLong_From*LongLong Modified: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- sandbox/trunk/newstruct/Modules/_newstruct.c (original) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Thu May 25 19:05:03 2006 @@ -284,6 +284,8 @@ { unsigned int x; memcpy((char *)&x, p, sizeof x); + if (x <= INT_MAX) + return PyInt_FromLong((long)x); return PyLong_FromUnsignedLong((unsigned long)x); } @@ -300,6 +302,8 @@ { unsigned long x; memcpy((char *)&x, p, sizeof x); + if (x <= INT_MAX) + return PyInt_FromLong((long)x); return PyLong_FromUnsignedLong(x); } @@ -313,6 +317,8 @@ { PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); } @@ -321,6 +327,8 @@ { unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); return PyLong_FromUnsignedLongLong(x); } @@ -584,28 +592,52 @@ do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else + if (x <= INT_MAX) return PyInt_FromLong((long)x); + return PyLong_FromUnsignedLong(x); } static PyObject * bu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 1 /* signed */); +#endif } static PyObject * bu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 0 /* signed */); +#endif } static PyObject * @@ -750,28 +782,52 @@ do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else + if (x <= INT_MAX) return PyInt_FromLong((long)x); + return PyLong_FromUnsignedLong((long)x); } static PyObject * lu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 1 /* signed */); +#endif } static PyObject * lu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (--i > 0); + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 0 /* signed */); +#endif } static PyObject * From python-checkins at python.org Thu May 25 19:08:15 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 19:08:15 +0200 (CEST) Subject: [Python-checkins] r46226 - python/trunk/Objects/stringobject.c Message-ID: <20060525170815.1D7751E4018@bag.python.org> Author: fredrik.lundh Date: Thu May 25 19:08:14 2006 New Revision: 46226 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: new replace implementation by Andrew Dalke. replace is now about 3x faster on my machine, for the replace tests from string- bench. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 19:08:14 2006 @@ -2379,175 +2379,623 @@ } -/* What follows is used for implementing replace(). Perry Stoll. */ +#define FORWARD 1 +#define REVERSE -1 -/* - mymemfind +/* find and count characters and substrings */ - strstr replacement for arbitrary blocks of memory. +/* Don't call if length < 2 */ +#define Py_STRING_MATCH(target, offset, pattern, length) \ + (target[offset] == pattern[0] && \ + target[offset+length-1] == pattern[length-1] && \ + !memcmp(target+offset+1, pattern+1, length-2) ) + +#define findchar(target, target_len, c) \ + ((char *)memchr((const void *)(target), c, target_len)) + +/* String ops must return a string. */ +/* If the object is subclass of string, create a copy */ +static PyStringObject * +return_self(PyStringObject *self) +{ + if (PyString_CheckExact(self)) { + Py_INCREF(self); + return self; + } + return (PyStringObject *)PyString_FromStringAndSize( + PyString_AS_STRING(self), + PyString_GET_SIZE(self)); +} - Locates the first occurrence in the memory pointed to by MEM of the - contents of memory pointed to by PAT. Returns the index into MEM if - found, or -1 if not found. If len of PAT is greater than length of - MEM, the function returns -1. -*/ static Py_ssize_t -mymemfind(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len) +countchar(char *target, int target_len, char c) { - register Py_ssize_t ii; + Py_ssize_t count=0; + char *start=target; + char *end=target+target_len; - /* pattern can not occur in the last pat_len-1 chars */ - len -= pat_len; + while ( (start=findchar(start, end-start, c)) != NULL ) { + count++; + start += 1; + } - for (ii = 0; ii <= len; ii++) { - if (mem[ii] == pat[0] && memcmp(&mem[ii], pat, pat_len) == 0) { - return ii; - } + return count; +} + +static Py_ssize_t +findstring(char *target, Py_ssize_t target_len, + char *pattern, Py_ssize_t pattern_len, + Py_ssize_t start, + Py_ssize_t end, + int direction) +{ + if (start < 0) { + start += target_len; + if (start < 0) + start = 0; + } + if (end > target_len) { + end = target_len; + } else if (end < 0) { + end += target_len; + if (end < 0) + end = 0; + } + + /* zero-length substrings always match at the first attempt */ + if (pattern_len == 0) + return (direction > 0) ? start : end; + + end -= pattern_len; + + if (direction < 0) { + for (; end >= start; end--) + if (Py_STRING_MATCH(target, end, pattern, pattern_len)) + return end; + } else { + for (; start <= end; start++) + if (Py_STRING_MATCH(target, start, pattern, pattern_len)) + return start; } return -1; } -/* - mymemcnt +Py_ssize_t +countstring(char *target, Py_ssize_t target_len, + char *pattern, Py_ssize_t pattern_len, + Py_ssize_t start, + Py_ssize_t end, + int direction) +{ + Py_ssize_t count=0; + + if (start < 0) { + start += target_len; + if (start < 0) + start = 0; + } + if (end > target_len) { + end = target_len; + } else if (end < 0) { + end += target_len; + if (end < 0) + end = 0; + } + + /* zero-length substrings match everywhere */ + if (pattern_len == 0) + return target_len+1; + + end -= pattern_len; + + if (direction < 0) { + for (; end >= start; end--) + if (Py_STRING_MATCH(target, end, pattern, pattern_len)) { + count++; + end -= pattern_len-1; + } + } else { + for (; start <= end; start++) + if (Py_STRING_MATCH(target, start, pattern, pattern_len)) { + count++; + start += pattern_len-1; + } + } + return count; +} + - Return the number of distinct times PAT is found in MEM. - meaning mem=1111 and pat==11 returns 2. - mem=11111 and pat==11 also return 2. - */ -static Py_ssize_t -mymemcnt(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len) -{ - register Py_ssize_t offset = 0; - Py_ssize_t nfound = 0; +/* Algorithms for difference cases of string replacement */ - while (len >= 0) { - offset = mymemfind(mem, len, pat, pat_len); - if (offset == -1) +/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ +static PyStringObject * +replace_interleave(PyStringObject *self, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *self_s, *to_s, *result_s; + Py_ssize_t self_len, to_len, result_len; + Py_ssize_t count, i, product; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + to_len = PyString_GET_SIZE(to); + + /* 1 at the end plus 1 after every character */ + count = self_len+1; + if (maxcount < count) + count = maxcount; + + /* Check for overflow */ + /* result_len = count * to_len + self_len; */ + product = count * to_len; + if (product / to_len != count) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + result_len = product + self_len; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + + if (! (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) ) + return NULL; + + self_s = PyString_AS_STRING(self); + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + result_s = PyString_AS_STRING(result); + + /* TODO: special case single character, which doesn't need memcpy */ + + /* Lay the first one down (guaranteed this will occur) */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + count -= 1; + + for (i=0; i=1, len(from)==1, to="", maxcount>=1 */ +static PyStringObject * +replace_delete_single_character(PyStringObject *self, + char from_c, Py_ssize_t maxcount) +{ + char *self_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, result_len; + Py_ssize_t count; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + self_s = PyString_AS_STRING(self); + + count = countchar(self_s, self_len, from_c); + if (count == 0) { + return return_self(self); + } + if (count > maxcount) + count = maxcount; + + result_len = self_len - count; /* from_len == 1 */ + assert(result_len>=0); + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) break; - mem += offset + pat_len; - len -= offset + pat_len; - nfound++; + memcpy(result_s, start, next-start); + result_s += (next-start); + start = next+1; } - return nfound; + memcpy(result_s, start, end-start); + + return result; } -/* - mymemreplace +/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ - Return a string in which all occurrences of PAT in memory STR are - replaced with SUB. +static PyStringObject * +replace_delete_substring(PyStringObject *self, PyStringObject *from, + Py_ssize_t maxcount) { + char *self_s, *from_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, from_len, result_len; + Py_ssize_t count, offset; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + self_s = PyString_AS_STRING(self); + from_len = PyString_GET_SIZE(from); + from_s = PyString_AS_STRING(from); + + count = countstring(self_s, self_len, + from_s, from_len, + 0, self_len, 1); + + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches */ + return return_self(self); + } + + result_len = self_len - (count * from_len); + assert (result_len>=0); + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL ) + return NULL; + + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); + if (offset == -1) + break; + next = start + offset; + + memcpy(result_s, start, next-start); + + result_s += (next-start); + start = next+from_len; + } + memcpy(result_s, start, end-start); + return result; +} - If length of PAT is less than length of STR or there are no occurrences - of PAT in STR, then the original string is returned. Otherwise, a new - string is allocated here and returned. +/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ +static PyStringObject * +replace_single_character_in_place(PyStringObject *self, + char from_c, char to_c, + Py_ssize_t maxcount) +{ + char *self_s, *result_s, *start, *end, *next; + Py_ssize_t self_len; + PyStringObject *result; + + /* The result string will be the same size */ + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + next = findchar(self_s, self_len, from_c); + + if (next == NULL) { + /* No matches; return the original string */ + return return_self(self); + } + + /* Need to make a new string */ + result = (PyStringObject *) PyString_FromStringAndSize(self_s, self_len); + if (result == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + /* change everything in-place, starting with this one */ + start = result_s + (next-self_s); + *start = to_c; + start++; + end = result_s + self_len; + + while (--maxcount > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) + break; + *next = to_c; + start = next+1; + } + + return result; +} - on return, out_len is: - the length of output string, or - -1 if the input string is returned, or - unchanged if an error occurs (no memory). +/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_substring_in_place(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *result_s, *start, *end; + char *self_s, *from_s, *to_s; + Py_ssize_t self_len, from_len, offset; + PyStringObject *result; + + /* The result string will be the same size */ + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + from_s = PyString_AS_STRING(from); + from_len = PyString_GET_SIZE(from); + to_s = PyString_AS_STRING(to); + + offset = findstring(self_s, self_len, + from_s, from_len, + 0, self_len, FORWARD); + + if (offset == -1) { + /* No matches; return the original string */ + return return_self(self); + } + + /* Need to make a new string */ + result = (PyStringObject *) PyString_FromStringAndSize(self_s, self_len); + if (result == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + /* change everything in-place, starting with this one */ + start = result_s + offset; + memcpy(start, to_s, from_len); + start += from_len; + end = result_s + self_len; + + while ( --maxcount > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); + if (offset==-1) + break; + memcpy(start+offset, to_s, from_len); + start += offset+from_len; + } + + return result; +} - return value is: - the new string allocated locally, or - NULL if an error occurred. -*/ -static char * -mymemreplace(const char *str, Py_ssize_t len, /* input string */ - const char *pat, Py_ssize_t pat_len, /* pattern string to find */ - const char *sub, Py_ssize_t sub_len, /* substitution string */ - Py_ssize_t count, /* number of replacements */ - Py_ssize_t *out_len) -{ - char *out_s; - char *new_s; - Py_ssize_t nfound, offset, new_len; - Py_ssize_t product, delta; - - if (len == 0 || (pat_len == 0 && sub_len == 0) || pat_len > len) - goto return_same; - - /* find length of output string */ - nfound = (pat_len > 0) ? mymemcnt(str, len, pat, pat_len) : len + 1; - if (count < 0) - count = PY_SSIZE_T_MAX; - else if (nfound > count) - nfound = count; - if (nfound == 0) - goto return_same; - - delta = (sub_len - pat_len); - if (delta == 0) { - new_len = len; - } else { - product = nfound * (sub_len - pat_len); - if ((product / (sub_len - pat_len)) != nfound) { - PyErr_SetString(PyExc_OverflowError, - "replace string is too long"); - return NULL; - } - new_len = len + product; - if (new_len < 0) { - PyErr_SetString(PyExc_OverflowError, - "replace string is too long"); - return NULL; - } - } +/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_single_character(PyStringObject *self, + char from_c, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *self_s, *to_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, to_len, result_len; + Py_ssize_t count, product; + PyStringObject *result; + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + count = countchar(self_s, self_len, from_c); + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + + /* use the difference between current and new, hence the "-1" */ + /* result_len = self_len + count * (to_len-1) */ + product = count * (to_len-1); + if (product / (to_len-1) != count) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + result_len = self_len + product; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) + break; + + if (next == start) { + /* replace with the 'to' */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + start += 1; + } else { + /* copy the unchanged old then the 'to' */ + memcpy(result_s, start, next-start); + result_s += (next-start); + memcpy(result_s, to_s, to_len); + result_s += to_len; + start = next+1; + } + } + /* Copy the remainder of the remaining string */ + memcpy(result_s, start, end-start); + + return result; +} - if (new_len == 0) { - /* Have to allocate something for the caller to free(). */ - out_s = (char *)PyMem_MALLOC(1); - if (out_s == NULL) - return NULL; - out_s[0] = '\0'; +/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_substring(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) { + char *self_s, *from_s, *to_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, from_len, to_len, result_len; + Py_ssize_t count, offset, product; + PyStringObject *result; + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + from_s = PyString_AS_STRING(from); + from_len = PyString_GET_SIZE(from); + + count = countstring(self_s, self_len, + from_s, from_len, + 0, self_len, FORWARD); + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + + /* Check for overflow */ + /* result_len = self_len + count * (to_len-from_len) */ + product = count * (to_len-from_len); + if (product / (to_len-from_len) != count) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; } - else { - assert(new_len > 0); - new_s = (char *)PyMem_MALLOC(new_len); - if (new_s == NULL) - return NULL; - out_s = new_s; + result_len = self_len + product; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); + if (offset == -1) + break; + next = start+offset; + if (next == start) { + /* replace with the 'to' */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + start += from_len; + } else { + /* copy the unchanged old then the 'to' */ + memcpy(result_s, start, next-start); + result_s += (next-start); + memcpy(result_s, to_s, to_len); + result_s += to_len; + start = next+from_len; + } + } + /* Copy the remainder of the remaining string */ + memcpy(result_s, start, end-start); + + return result; +} - if (pat_len > 0) { - for (; nfound > 0; --nfound) { - /* find index of next instance of pattern */ - offset = mymemfind(str, len, pat, pat_len); - if (offset == -1) - break; - - /* copy non matching part of input string */ - memcpy(new_s, str, offset); - str += offset + pat_len; - len -= offset + pat_len; - - /* copy substitute into the output string */ - new_s += offset; - memcpy(new_s, sub, sub_len); - new_s += sub_len; - } - /* copy any remaining values into output string */ - if (len > 0) - memcpy(new_s, str, len); + +static PyStringObject * +replace(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) +{ + Py_ssize_t from_len, to_len; + + if (maxcount < 0) { + maxcount = PY_SSIZE_T_MAX; + } else if (maxcount == 0 || PyString_GET_SIZE(self) == 0) { + /* nothing to do; return the original string */ + return return_self(self); + } + + from_len = PyString_GET_SIZE(from); + to_len = PyString_GET_SIZE(to); + + if (maxcount == 0 || + (from_len == 0 && to_len == 0)) { + /* nothing to do; return the original string */ + return return_self(self); + } + + /* Handle zero-length special cases */ + + if (from_len == 0) { + /* insert the 'to' string everywhere. */ + /* >>> "Python".replace("", ".") */ + /* '.P.y.t.h.o.n.' */ + return replace_interleave(self, to, maxcount); + } + + /* Except for "".replace("", "A") == "A" there is no way beyond this */ + /* point for an empty self string to generate a non-empty string */ + /* Special case so the remaining code always gets a non-empty string */ + if (PyString_GET_SIZE(self) == 0) { + return return_self(self); + } + + if (to_len == 0) { + /* delete all occurances of 'from' string */ + if (from_len == 1) { + return replace_delete_single_character( + self, PyString_AS_STRING(from)[0], maxcount); + } else { + return replace_delete_substring(self, from, maxcount); } - else { - for (;;++str, --len) { - memcpy(new_s, sub, sub_len); - new_s += sub_len; - if (--nfound <= 0) { - memcpy(new_s, str, len); - break; - } - *new_s++ = *str; - } + } + + /* Handle special case where both strings have the same length */ + + if (from_len == to_len) { + if (from_len == 1) { + return replace_single_character_in_place( + self, + PyString_AS_STRING(from)[0], + PyString_AS_STRING(to)[0], + maxcount); + } else { + return replace_substring_in_place( + self, from, to, maxcount); } } - *out_len = new_len; - return out_s; - return_same: - *out_len = -1; - return (char *)str; /* cast away const */ + /* Otherwise use the more generic algorithms */ + if (from_len == 1) { + return replace_single_character(self, PyString_AS_STRING(from)[0], + to, maxcount); + } else { + /* len('from')>=2, len('to')>=1 */ + return replace_substring(self, from, to, maxcount); + } } - PyDoc_STRVAR(replace__doc__, "S.replace (old, new[, count]) -> string\n\ \n\ @@ -2558,67 +3006,42 @@ static PyObject * string_replace(PyStringObject *self, PyObject *args) { - const char *str = PyString_AS_STRING(self), *sub, *repl; - char *new_s; - const Py_ssize_t len = PyString_GET_SIZE(self); - Py_ssize_t sub_len, repl_len, out_len; Py_ssize_t count = -1; - PyObject *newobj; - PyObject *subobj, *replobj; + PyObject *from, *to; + char *tmp_s; + Py_ssize_t tmp_len; - if (!PyArg_ParseTuple(args, "OO|n:replace", - &subobj, &replobj, &count)) + if (!PyArg_ParseTuple(args, "OO|n:replace", &from, &to, &count)) return NULL; - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - sub_len = PyString_GET_SIZE(subobj); + if (PyString_Check(from)) { + /* Can this be made a '!check' after the Unicode check? */ } #ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) + if (PyUnicode_Check(from)) return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); + from, to, count); #endif - else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) + else if (PyObject_AsCharBuffer(from, &tmp_s, &tmp_len)) return NULL; - if (PyString_Check(replobj)) { - repl = PyString_AS_STRING(replobj); - repl_len = PyString_GET_SIZE(replobj); + if (PyString_Check(to)) { + /* Can this be made a '!check' after the Unicode check? */ } #ifdef Py_USING_UNICODE - else if (PyUnicode_Check(replobj)) + else if (PyUnicode_Check(to)) return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); + from, to, count); #endif - else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len)) + else if (PyObject_AsCharBuffer(to, &tmp_s, &tmp_len)) return NULL; - new_s = mymemreplace(str,len,sub,sub_len,repl,repl_len,count,&out_len); - if (new_s == NULL) { - if (!PyErr_Occurred()) - PyErr_NoMemory(); - return NULL; - } - if (out_len == -1) { - if (PyString_CheckExact(self)) { - /* we're returning another reference to self */ - newobj = (PyObject*)self; - Py_INCREF(newobj); - } - else { - newobj = PyString_FromStringAndSize(str, len); - if (newobj == NULL) - return NULL; - } - } - else { - newobj = PyString_FromStringAndSize(new_s, out_len); - PyMem_FREE(new_s); - } - return newobj; + return (PyObject *)replace((PyStringObject *) self, + (PyStringObject *) from, + (PyStringObject *) to, count); } +/** End DALKE **/ PyDoc_STRVAR(startswith__doc__, "S.startswith(prefix[, start[, end]]) -> bool\n\ From thomas at python.org Thu May 25 19:33:28 2006 From: thomas at python.org (Thomas Wouters) Date: Thu, 25 May 2006 19:33:28 +0200 Subject: [Python-checkins] r46225 - sandbox/trunk/newstruct/Modules/_newstruct.c In-Reply-To: <20060525170504.09B501E400C@bag.python.org> References: <20060525170504.09B501E400C@bag.python.org> Message-ID: <9e804ac0605251033q111b222cx5623fd13017a1ba9@mail.gmail.com> On 5/25/06, bob.ippolito wrote: > + if (x <= INT_MAX) > + return PyInt_FromLong((long)x); This ought to be LONG_MAX instead of INT_MAX; PyInts hold C longs, not C ints. There's only a difference on LP64 architectures (all 64-bit architectures except Win64, basically) but testing for INT_MAX would be pessimistic there. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060525/38f7bca0/attachment.html From python-checkins at python.org Thu May 25 19:34:04 2006 From: python-checkins at python.org (tim.peters) Date: Thu, 25 May 2006 19:34:04 +0200 (CEST) Subject: [Python-checkins] r46227 - in python/trunk: Include/longobject.h Objects/longobject.c Python/mystrtoul.c Message-ID: <20060525173404.C20721E400B@bag.python.org> Author: tim.peters Date: Thu May 25 19:34:03 2006 New Revision: 46227 Modified: python/trunk/Include/longobject.h python/trunk/Objects/longobject.c python/trunk/Python/mystrtoul.c Log: A new table to help string->integer conversion was added yesterday to both mystrtoul.c and longobject.c. Share the table instead. Also cut its size by 64 entries (they had been used for an inscrutable trick originally, but the code no longer tries to use that trick). Modified: python/trunk/Include/longobject.h ============================================================================== --- python/trunk/Include/longobject.h (original) +++ python/trunk/Include/longobject.h Thu May 25 19:34:03 2006 @@ -25,6 +25,7 @@ PyAPI_FUNC(Py_ssize_t) _PyLong_AsSsize_t(PyObject *); PyAPI_FUNC(PyObject *) _PyLong_FromSize_t(size_t); PyAPI_FUNC(PyObject *) _PyLong_FromSsize_t(Py_ssize_t); +PyAPI_DATA(int) _PyLong_DigitValue[256]; /* _PyLong_AsScaledDouble returns a double x and an exponent e such that the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0. Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Thu May 25 19:34:03 2006 @@ -1304,7 +1304,14 @@ return (PyObject *)str; } -static int digval[] = { +/* Table of digit values for 8-bit string -> integer conversion. + * '0' maps to 0, ..., '9' maps to 9. + * 'a' and 'A' map to 10, ..., 'z' and 'Z' map to 35. + * All other indices map to 37. + * Note that when converting a base B string, a char c is a legitimate + * base B digit iff _PyLong_DigitValue[Py_CHARMASK(c)] < B. + */ +int _PyLong_DigitValue[256] = { 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, @@ -1321,14 +1328,6 @@ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 }; /* *str points to the first digit in a string of base `base` digits. base @@ -1355,7 +1354,7 @@ n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - while (digval[Py_CHARMASK(*p)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base) ++p; *str = p; n = (p - start) * bits_per_char; @@ -1376,7 +1375,7 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k = digval[Py_CHARMASK(*p)]; + int k = _PyLong_DigitValue[Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1503,7 +1502,7 @@ /* Find length of the string of numeric characters. */ scan = str; - while (digval[Py_CHARMASK(*scan)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base) ++scan; /* Create a long object that can contain the largest possible @@ -1527,10 +1526,10 @@ /* Work ;-) */ while (str < scan) { /* grab up to convwidth digits from the input string */ - c = (digit)digval[Py_CHARMASK(*str++)]; + c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)]; for (i = 1; i < convwidth && str != scan; ++i, ++str) { c = (twodigits)(c * base + - digval[Py_CHARMASK(*str)]); + _PyLong_DigitValue[Py_CHARMASK(*str)]); assert(c < BASE); } Modified: python/trunk/Python/mystrtoul.c ============================================================================== --- python/trunk/Python/mystrtoul.c (original) +++ python/trunk/Python/mystrtoul.c Thu May 25 19:34:03 2006 @@ -75,34 +75,6 @@ 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */ 6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */ -/* char-to-digit conversion for bases 2-36; all non-digits are 37 */ -static int digitlookup[] = { - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, - 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, - 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 -}; - /* ** strtoul ** This is a general purpose routine for converting @@ -167,7 +139,7 @@ ovlimit = digitlimit[base]; /* do the conversion until non-digit character encountered */ - while ((c = digitlookup[Py_CHARMASK(*str)]) < base) { + while ((c = _PyLong_DigitValue[Py_CHARMASK(*str)]) < base) { if (ovlimit > 0) /* no overflow check required */ result = result * base + c; else { /* requires overflow check */ @@ -204,7 +176,7 @@ overflowed: if (ptr) { /* spool through remaining digit characters */ - while (digitlookup[Py_CHARMASK(*str)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base) ++str; *ptr = str; } From buildbot at python.org Thu May 25 19:40:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 17:40:53 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060525174053.7D7DE1E400C@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/774 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 19:43:11 2006 From: python-checkins at python.org (andrew.dalke) Date: Thu, 25 May 2006 19:43:11 +0200 (CEST) Subject: [Python-checkins] r46228 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060525174311.0F36B1E4023@bag.python.org> Author: andrew.dalke Date: Thu May 25 19:43:10 2006 New Revision: 46228 Modified: sandbox/trunk/stringbench/stringbench.py Log: Added benchmarks for lower() and upper() methods. Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Thu May 25 19:43:10 2006 @@ -767,6 +767,43 @@ for x in _RANGE_1000: s % d + +#### Upper- and lower- case conversion + + at bench('"Where in the world is Carmen San Deigo?".lower()', + "case conversion -- rare", 1000) +def lower_conversion_rare(STR): + s = STR("Where in the world is Carmen San Deigo?") + s_lower = s.lower + for x in _RANGE_1000: + s_lower() + + at bench('"WHERE IN THE WORLD IS CARMEN SAN DEIGO?".lower()', + "case conversion -- dense", 1000) +def lower_conversion_dense(STR): + s = STR("WHERE IN THE WORLD IS CARMEN SAN DEIGO?") + s_lower = s.lower + for x in _RANGE_1000: + s_lower() + + + at bench('"wHERE IN THE WORLD IS cARMEN sAN dEIGO?".upper()', + "case conversion -- rare", 1000) +def upper_conversion_rare(STR): + s = STR("Where in the world is Carmen San Deigo?") + s_upper = s.upper + for x in _RANGE_1000: + s_upper() + + at bench('"where in the world is carmen san deigo?".upper()', + "case conversion -- dense", 1000) +def upper_conversion_dense(STR): + s = STR("where in the world is carmen san deigo?") + s_upper = s.upper + for x in _RANGE_1000: + s_upper() + + # end of benchmarks ################# From buildbot at python.org Thu May 25 19:45:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 17:45:10 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060525174510.7CAED1E401C@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/756 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,fredrik.lundh,kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 19:48:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 17:48:16 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060525174816.A6F961E400B@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/674 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 19:52:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 17:52:40 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060525175240.9B26D1E400C@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/494 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,fredrik.lundh,kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 19:53:01 2006 From: python-checkins at python.org (andrew.dalke) Date: Thu, 25 May 2006 19:53:01 +0200 (CEST) Subject: [Python-checkins] r46229 - python/trunk/Objects/stringobject.c Message-ID: <20060525175301.5E53F1E400C@bag.python.org> Author: andrew.dalke Date: Thu May 25 19:53:00 2006 New Revision: 46229 Modified: python/trunk/Objects/stringobject.c Log: Fixed problem identified by Georg. The special-case in-place code for replace made a copy of the string using PyString_FromStringAndSize(s, n) and modify the copied string in-place. However, 1 (and 0) character strings are shared from a cache. This cause "A".replace("A", "a") to change the cached version of "A" -- used by everyone. Now may the copy with NULL as the string and do the memcpy manually. I've added regression tests to check if this happens in the future. Perhaps there should be a PyString_Copy for this case? Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 19:53:00 2006 @@ -2692,10 +2692,11 @@ } /* Need to make a new string */ - result = (PyStringObject *) PyString_FromStringAndSize(self_s, self_len); + result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len); if (result == NULL) return NULL; result_s = PyString_AS_STRING(result); + memcpy(result_s, self_s, self_len); /* change everything in-place, starting with this one */ start = result_s + (next-self_s); @@ -2745,10 +2746,12 @@ } /* Need to make a new string */ - result = (PyStringObject *) PyString_FromStringAndSize(self_s, self_len); + result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len); if (result == NULL) return NULL; result_s = PyString_AS_STRING(result); + memcpy(result_s, self_s, self_len); + /* change everything in-place, starting with this one */ start = result_s + offset; From jimjjewett at gmail.com Thu May 25 19:53:43 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 25 May 2006 13:53:43 -0400 Subject: [Python-checkins] r46216 - python/trunk/Objects/stringobject.c In-Reply-To: References: <20060525154946.66EED1E400B@bag.python.org> Message-ID: On 5/25/06, Fredrik Lundh wrote: > Jim Jewett wrote: > > >> - newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); > >> + newobj = PyString_FromStringAndSize(NULL, n); > >> if (!newobj) > >> return NULL; > >> > >> s = PyString_AS_STRING(newobj); > >> > >> + memcpy(s, PyString_AS_STRING(self), n); > > > > Doesn't PyString_FromStringAndSize already fill newobj with a copy of > > the current string? > > the problem is that if you pass in a char pointer as the first argument, > you may get back a reference an existing Python string object... I understand that this was fixing that bug; I'm just not sure why this is the right solution. Why not just special-case the single-character strings instead? -jJ From python-checkins at python.org Thu May 25 19:55:32 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 19:55:32 +0200 (CEST) Subject: [Python-checkins] r46230 - python/trunk/Objects/stringobject.c Message-ID: <20060525175532.DCF571E400C@bag.python.org> Author: fredrik.lundh Date: Thu May 25 19:55:31 2006 New Revision: 46230 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: use "fastsearch" for count. this results in a 3x speedup for the related stringbench tests. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 19:55:31 2006 @@ -5,6 +5,18 @@ #include +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) /* this is taken from _sre.c */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define LOCAL(type) static inline type +#else +#define LOCAL(type) static type +#endif + #ifdef COUNT_ALLOCS int null_strings, one_strings; #endif @@ -763,6 +775,108 @@ return 0; } +/* -------------------------------------------------------------------- */ +/* Helpers */ + +#define USE_FAST /* experimental fast search implementation */ + +/* XXX - this code is copied from unicodeobject.c. we really should + refactor the core implementations (see _sre.c for how this can be + done), but that'll have to wait -- fredrik */ + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possible be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +LOCAL(Py_ssize_t) + fastsearch(const unsigned char* s, Py_ssize_t n, const unsigned char* p, + Py_ssize_t m, int mode) +{ + long mask; + int skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m <= 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else { + i = i + skip; + continue; + } + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +/* -------------------------------------------------------------------- */ /* Methods */ static int @@ -2177,7 +2291,7 @@ static PyObject * string_count(PyStringObject *self, PyObject *args) { - const char *s = PyString_AS_STRING(self), *sub, *t; + const char *s = PyString_AS_STRING(self), *sub; Py_ssize_t len = PyString_GET_SIZE(self), n; Py_ssize_t i = 0, last = PY_SSIZE_T_MAX; Py_ssize_t m, r; @@ -2210,8 +2324,14 @@ if (n == 0) return PyInt_FromSsize_t(m-i); +#ifdef USE_FAST + r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); + if (r < 0) + r = 0; /* no match */ +#else r = 0; while (i < m) { + const char *t if (!memcmp(s+i, sub, n)) { r++; i += n; @@ -2225,6 +2345,7 @@ break; i = t - s; } +#endif return PyInt_FromSsize_t(r); } From buildbot at python.org Thu May 25 19:58:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 17:58:22 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060525175822.894D01E400B@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/465 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,fredrik.lundh,kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 20:02:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 18:02:50 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060525180250.812EA1E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/777 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 20:03:26 2006 From: python-checkins at python.org (andrew.dalke) Date: Thu, 25 May 2006 20:03:26 +0200 (CEST) Subject: [Python-checkins] r46231 - python/trunk/Objects/unicodeobject.c Message-ID: <20060525180326.49ED41E400B@bag.python.org> Author: andrew.dalke Date: Thu May 25 20:03:25 2006 New Revision: 46231 Modified: python/trunk/Objects/unicodeobject.c Log: Code had returned an ssize_t, upcast to long, then converted with PyInt_FromLong. Now using PyInt_FromSsize_t. Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Thu May 25 20:03:25 2006 @@ -5306,7 +5306,7 @@ if (end < 0) end = 0; - result = PyInt_FromLong((long) count(self, start, end, substring)); + result = PyInt_FromSsize_t(count(self, start, end, substring)); Py_DECREF(substring); return result; From fredrik at pythonware.com Thu May 25 20:02:49 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 25 May 2006 20:02:49 +0200 Subject: [Python-checkins] r46216 - python/trunk/Objects/stringobject.c In-Reply-To: References: <20060525154946.66EED1E400B@bag.python.org> Message-ID: Jim Jewett wrote: > I understand that this was fixing that bug; I'm just not sure why this > is the right solution. > > Why not just special-case the single-character strings instead? from the documentation: "If 'str' is non-NULL then the resulting PyString object must be treated as immutable and you must not fill in nor alter the data yourself, since the strings may be shared." From python-checkins at python.org Thu May 25 20:07:51 2006 From: python-checkins at python.org (sean.reifschneider) Date: Thu, 25 May 2006 20:07:51 +0200 (CEST) Subject: [Python-checkins] r46232 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060525180751.58DEF1E400B@bag.python.org> Author: sean.reifschneider Date: Thu May 25 20:07:50 2006 New Revision: 46232 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding some tests Richard requested. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Thu May 25 20:07:50 2006 @@ -208,8 +208,10 @@ unlink(TESTFN) # test that exception attributes are happy. +try: str(u'Hello \u00E1') +except Exception, e: sampleUnicodeEncodeError = e try: unicode('\xff') -except Exception, e: sampleUnicodeError = e +except Exception, e: sampleUnicodeDecodeError = e exceptionList = [ ( BaseException, (), { 'message' : '', 'args' : () }), ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), @@ -245,7 +247,14 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None, 'text' : None }), - ( sampleUnicodeError, + ( UnicodeError, ( ), + { 'message' : '', 'args' : (), }), + ( sampleUnicodeEncodeError, + { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : u'Hello \xe1', + 'start' : 6, 'reason' : 'ordinal not in range(128)' }), + ( sampleUnicodeDecodeError, { 'message' : '', 'args' : ('ascii', '\xff', 0, 1, 'ordinal not in range(128)'), 'encoding' : 'ascii', 'object' : '\xff', @@ -271,7 +280,7 @@ else: raise apply(args[0], args[1]) except BaseException, e: for checkArgName in expected.keys(): - if getattr(e, checkArgName) != expected[checkArgName]: + if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]): raise TestFailed('Checking exception arguments, exception ' '"%s", attribute "%s" expected %s got %s.' % ( repr(e), checkArgName, From python-checkins at python.org Thu May 25 20:11:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 20:11:18 +0200 (CEST) Subject: [Python-checkins] r46233 - python/trunk/Objects/stringobject.c Message-ID: <20060525181118.409EA1E400B@bag.python.org> Author: andrew.kuchling Date: Thu May 25 20:11:16 2006 New Revision: 46233 Modified: python/trunk/Objects/stringobject.c Log: Comment typo Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 20:11:16 2006 @@ -791,7 +791,7 @@ /* note: fastsearch may access s[n], which isn't a problem when using Python's ordinary string types, but may cause problems if you're using this code in other contexts. also, the count mode returns -1 - if there cannot possible be a match in the target string, and 0 if + if there cannot possibly be a match in the target string, and 0 if it has actually checked for matches, but didn't find any. callers beware! */ From buildbot at python.org Thu May 25 20:15:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 18:15:17 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060525181517.DBB7C1E4018@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/753 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 20:18:39 2006 From: python-checkins at python.org (andrew.dalke) Date: Thu, 25 May 2006 20:18:39 +0200 (CEST) Subject: [Python-checkins] r46234 - python/trunk/Objects/stringobject.c Message-ID: <20060525181839.BE6771E400B@bag.python.org> Author: andrew.dalke Date: Thu May 25 20:18:39 2006 New Revision: 46234 Modified: python/trunk/Objects/stringobject.c Log: Added overflow test for adding two (very) large strings where the new string is over max Py_ssize_t. I have no way to test it on my box or any box I have access to. At least it doesn't break anything. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 20:18:39 2006 @@ -1023,7 +1023,7 @@ static PyObject * string_concat(register PyStringObject *a, register PyObject *bb) { - register size_t size; + register Py_ssize_t size; register PyStringObject *op; if (!PyString_Check(bb)) { #ifdef Py_USING_UNICODE @@ -1047,7 +1047,12 @@ return (PyObject *)a; } size = a->ob_size + b->ob_size; - /* XXX check overflow */ + if (size < 0) { + PyErr_SetString(PyExc_OverflowError, + "strings are too large to concat"); + return NULL; + } + /* Inline PyObject_NewVar */ op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); if (op == NULL) From python-checkins at python.org Thu May 25 20:20:23 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 20:20:23 +0200 (CEST) Subject: [Python-checkins] r46235 - python/trunk/Objects/longobject.c Message-ID: <20060525182023.C43731E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 20:20:23 2006 New Revision: 46235 Modified: python/trunk/Objects/longobject.c Log: Faster path for PyLong_FromLongLong, using PyLong_FromLong algorithm Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Thu May 25 20:20:23 2006 @@ -844,11 +844,36 @@ PyObject * PyLong_FromLongLong(PY_LONG_LONG ival) { - PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); + PyLongObject *v; + unsigned PY_LONG_LONG t; /* unsigned so >> doesn't propagate sign bit */ + int ndigits = 0; + int negative = 0; + + if (ival < 0) { + ival = -ival; + negative = 1; + } + + /* Count the number of Python digits. + We used to pick 5 ("big enough for anything"), but that's a + waste of time and space given that 5*15 = 75 bits are rarely + needed. */ + t = (unsigned PY_LONG_LONG)ival; + while (t) { + ++ndigits; + t >>= SHIFT; + } + v = _PyLong_New(ndigits); + if (v != NULL) { + digit *p = v->ob_digit; + v->ob_size = negative ? -ndigits : ndigits; + t = (unsigned PY_LONG_LONG)ival; + while (t) { + *p++ = (digit)(t & MASK); + t >>= SHIFT; + } + } + return (PyObject *)v; } /* Create a new long int object from a C unsigned PY_LONG_LONG int. */ @@ -856,11 +881,26 @@ PyObject * PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival) { - unsigned PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); + PyLongObject *v; + unsigned PY_LONG_LONG t; + int ndigits = 0; + + /* Count the number of Python digits. */ + t = (unsigned PY_LONG_LONG)ival; + while (t) { + ++ndigits; + t >>= SHIFT; + } + v = _PyLong_New(ndigits); + if (v != NULL) { + digit *p = v->ob_digit; + v->ob_size = ndigits; + while (ival) { + *p++ = (digit)(ival & MASK); + ival >>= SHIFT; + } + } + return (PyObject *)v; } /* Create a new long int object from a C Py_ssize_t. */ From buildbot at python.org Thu May 25 20:25:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 18:25:13 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060525182513.4FF251E400B@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/432 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 20:25:28 2006 From: python-checkins at python.org (martin.blais) Date: Thu, 25 May 2006 20:25:28 +0200 (CEST) Subject: [Python-checkins] r46236 - in python/branches/blais-bytebuf: Lib/hotbuf.py Lib/test/test_hotbuf.py Lib/test/test_struct.py Modules/_hotbuf.c Modules/_struct.c Message-ID: <20060525182528.450441E400B@bag.python.org> Author: martin.blais Date: Thu May 25 20:25:26 2006 New Revision: 46236 Modified: python/branches/blais-bytebuf/Lib/hotbuf.py python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Lib/test/test_struct.py python/branches/blais-bytebuf/Modules/_hotbuf.c python/branches/blais-bytebuf/Modules/_struct.c Log: Added struct.pack_to implementation. Modified: python/branches/blais-bytebuf/Lib/hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/hotbuf.py Thu May 25 20:25:26 2006 @@ -10,15 +10,5 @@ _long = Struct('l') class hotbuf(_hotbuf): - - def getlong( self ): - r = _long.unpack_from(self, 0) - self.setposition(self.position + _long.size) - return r - -## def putlong( self ): -## s = _long.pack(0) -## self.setposition(self.position + _long.size) -## return - + pass Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Thu May 25 20:25:26 2006 @@ -7,13 +7,16 @@ # from hotbuf import hotbuf +from struct import Struct import unittest from test import test_support CAPACITY = 1024 MSG = 'Martin Blais was here scribble scribble.' - +# Note: we don't use floats because comparisons will cause precision errors due +# to the binary conversion. +fmt = Struct('llci') class HotbufTestCase(unittest.TestCase): @@ -75,6 +78,13 @@ b.setposition(10) self.assertEquals(b.remaining(), 94) + # Play with advance. + self.assertEquals(b.position, 10) + b.advance(32) + self.assertEquals(b.position, 42) + + self.assertRaises(IndexError, b.advance, CAPACITY) + def test_compact( self ): b = hotbuf(CAPACITY) @@ -137,9 +147,28 @@ def test_compare( self ): b = hotbuf(CAPACITY) -## FIXME we need a few methods to be able to write strings into and out of it + def test_pack( self ): + ARGS = 42, 16, '@', 3 + # Pack to a string. + s = fmt.pack(*ARGS) + # Pack directly into the buffer and compare the strings. + b = hotbuf(CAPACITY) + fmt.pack_to(b, 0, *ARGS) + b.setlimit(len(s)) + self.assertEquals(str(b), s) + def test_unpack( self ): + ARGS = 42, 16, '@', 3 + b = hotbuf(CAPACITY) + + # Pack normally and put that string in the buffer. + s = fmt.pack(*ARGS) + b.putstr(s) + + # Unpack directly from the buffer and compare. + b.flip() + self.assertEquals(fmt.unpack_from(b), ARGS) def test_main(): Modified: python/branches/blais-bytebuf/Lib/test/test_struct.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_struct.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_struct.py Thu May 25 20:25:26 2006 @@ -1,5 +1,8 @@ from test.test_support import TestFailed, verbose, verify +import test.test_support import struct +import array +import unittest import sys ISBIGENDIAN = sys.byteorder == "big" @@ -438,31 +441,6 @@ test_705836() -def test_unpack_from(): - test_string = 'abcd01234' - fmt = '4s' - s = struct.Struct(fmt) - for cls in (str, buffer): - data = cls(test_string) - assert s.unpack_from(data) == ('abcd',) - assert s.unpack_from(data, 2) == ('cd01',) - assert s.unpack_from(data, 4) == ('0123',) - for i in xrange(6): - assert s.unpack_from(data, i) == (data[i:i+4],) - for i in xrange(6, len(test_string) + 1): - simple_err(s.unpack_from, data, i) - for cls in (str, buffer): - data = cls(test_string) - assert struct.unpack_from(fmt, data) == ('abcd',) - assert struct.unpack_from(fmt, data, 2) == ('cd01',) - assert struct.unpack_from(fmt, data, 4) == ('0123',) - for i in xrange(6): - assert struct.unpack_from(fmt, data, i) == (data[i:i+4],) - for i in xrange(6, len(test_string) + 1): - simple_err(struct.unpack_from, fmt, data, i) - -test_unpack_from() - def test_1229380(): for endian in ('', '>', '<'): for cls in (int, long): @@ -478,3 +456,60 @@ if 0: # TODO: bug #1229380 test_1229380() + +class PackBufferTestCase(unittest.TestCase): + """ + Test the packing methods that work on buffers. + """ + + def test_unpack_from( self ): + test_string = 'abcd01234' + fmt = '4s' + s = struct.Struct(fmt) + for cls in (str, buffer): + data = cls(test_string) + self.assertEquals(s.unpack_from(data), ('abcd',)) + self.assertEquals(s.unpack_from(data, 2), ('cd01',)) + self.assertEquals(s.unpack_from(data, 4), ('0123',)) + for i in xrange(6): + self.assertEquals(s.unpack_from(data, i), (data[i:i+4],)) + for i in xrange(6, len(test_string) + 1): + simple_err(s.unpack_from, data, i) + for cls in (str, buffer): + data = cls(test_string) + self.assertEquals(struct.unpack_from(fmt, data), ('abcd',)) + self.assertEquals(struct.unpack_from(fmt, data, 2), ('cd01',)) + self.assertEquals(struct.unpack_from(fmt, data, 4), ('0123',)) + for i in xrange(6): + self.assertEquals(struct.unpack_from(fmt, data, i), + (data[i:i+4],)) + for i in xrange(6, len(test_string) + 1): + simple_err(struct.unpack_from, fmt, data, i) + + def test_pack_to( self ): + test_string = 'Reykjavik rocks, eow!' + writable_buf = array.array('c', ' '*100) + fmt = '21s' + s = struct.Struct(fmt) + + # Test without offset + s.pack_to(writable_buf, 0, test_string) + from_buf = writable_buf.tostring()[:len(test_string)] + self.assertEquals(from_buf, test_string) + + # Test with offset. + s.pack_to(writable_buf, 10, test_string) + from_buf = writable_buf.tostring()[:len(test_string)+10] + self.assertEquals(from_buf, (test_string[:10] + test_string)) + + # Go beyond boundaries. + small_buf = array.array('c', ' '*10) + self.assertRaises(struct.error, s.pack_to, small_buf, 0, test_string) + self.assertRaises(struct.error, s.pack_to, small_buf, 2, test_string) + +def test_main(): + test.test_support.run_unittest(PackBufferTestCase) + +if __name__ == "__main__": + test_main() + Modified: python/branches/blais-bytebuf/Modules/_hotbuf.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_hotbuf.c (original) +++ python/branches/blais-bytebuf/Modules/_hotbuf.c Thu May 25 20:25:26 2006 @@ -188,10 +188,14 @@ static PyObject * hotbuf_repr(PyHotbufObject *self) { - return PyString_FromFormat("", - self->b_ptr, - self->b_capacity, - self); + return PyString_FromFormat( + "", + self->b_mark, + self->b_position, + self->b_limit, + self->b_capacity, + self->b_ptr, + self); } /* @@ -619,12 +623,12 @@ /* Check and extract input string */ if ( arg == NULL || !PyString_Check(arg) ) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_TypeError, "incorrect input type, require string"); return NULL; } instring = PyString_AsString(arg); - len = strlen(instring); + len = PyString_GET_SIZE(arg); CHECK_LIMIT_ERROR(len); Modified: python/branches/blais-bytebuf/Modules/_struct.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_struct.c (original) +++ python/branches/blais-bytebuf/Modules/_struct.c Thu May 25 20:25:26 2006 @@ -15,10 +15,10 @@ typedef int Py_ssize_t; #endif - +/* Forward declarations */ +static Py_ssize_t convertbuffer(PyObject *, void **p); /* The translation function for each format character is table driven */ - typedef struct _formatdef { char format; int size; @@ -1227,50 +1227,36 @@ return s_unpack_internal(soself, buffer + offset); } -PyDoc_STRVAR(s_pack__doc__, -"pack(v1, v2, ...) -> string\n\ -\n\ -Return a string containing values v1, v2, ... packed according to this\n\ -Struct's format. See struct.__doc__ for more on format strings."); -static PyObject * -s_pack(PyObject *self, PyObject *args) +/* + * Guts of the pack function. + * + * Takes a struct object, a tuple of arguments, and offset in that tuple of + * argument for where to start processing the arguments for packing, and a + * character buffer for writing the packed string. The caller must insure + * that the buffer may contain the required length for packing the arguments. + * 0 is returned on success, 1 is returned if there is an error. + * + */ +static int +s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf) { - PyStructObject *soself; - PyObject *result; - char *restart; formatcode *code; Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (args == NULL || !PyTuple_Check(args) || - PyTuple_GET_SIZE(args) != soself->s_len) - { - PyErr_Format(StructError, - "pack requires exactly %d arguments", soself->s_len); - return NULL; - } - - result = PyString_FromStringAndSize((char *)NULL, soself->s_size); - if (result == NULL) - return NULL; - - restart = PyString_AS_STRING(result); - memset(restart, '\0', soself->s_size); - i = 0; + + memset(buf, '\0', soself->s_size); + i = offset; for (code = soself->s_codes; code->fmtdef != NULL; code++) { Py_ssize_t n; PyObject *v; const formatdef *e = code->fmtdef; - char *res = restart + code->offset; + char *res = buf + code->offset; if (e->format == 's') { v = PyTuple_GET_ITEM(args, i++); if (!PyString_Check(v)) { PyErr_SetString(StructError, "argument for 's' must be a string"); - goto fail; + return -1; } n = PyString_GET_SIZE(v); if (n > code->size) @@ -1282,7 +1268,7 @@ if (!PyString_Check(v)) { PyErr_SetString(StructError, "argument for 'p' must be a string"); - goto fail; + return -1; } n = PyString_GET_SIZE(v); if (n > (code->size - 1)) @@ -1295,16 +1281,141 @@ } else { v = PyTuple_GET_ITEM(args, i++); if (e->pack(res, v, e) < 0) - goto fail; + return -1; } } + /* Success */ + return 0; +} + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See struct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + + /* Validate arguments. */ + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + /* Allocate a new string */ + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + /* Call the guts */ + if ( s_pack_internal(soself, args, 0, PyString_AS_STRING(result)) != 0 ) { + Py_DECREF(result); + return NULL; + } + return result; +} -fail: - Py_DECREF(result); - return NULL; +PyDoc_STRVAR(s_pack_to__doc__, +"pack_to(buffer, offset, v1, v2, ...)\n\ +\n\ +Pack the values v2, v2, ... according to this Struct's format, write \n\ +the packed bytes into the given buffer at the given offset. Note that \n\ +the offset is not an optional argument. See struct.__doc__ for \n\ +more on format strings."); + +static PyObject * +s_pack_to(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + char *buffer; + Py_ssize_t buffer_len, offset; + + /* Validate arguments. +1 is for the first arg as buffer. */ + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != (soself->s_len + 2)) + { + PyErr_Format(StructError, + "pack_to requires exactly %d arguments", + (soself->s_len + 2)); + return NULL; + } + + /* Extract a writable memory buffer from the first argument */ + buffer_len = convertbuffer(PyTuple_GET_ITEM(args, 0), (void**)&buffer); + if (buffer_len < 0) + return NULL; + + /* Extract the offset from the first argument */ + offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1)); + + /* Support negative offsets. */ + if (offset < 0) + offset += buffer_len; + + /* Check boundaries */ + if (offset < 0 || (buffer_len - offset) < soself->s_size) { + PyErr_Format(StructError, + "pack_to requires a buffer of at least %d bytes", + soself->s_size); + return NULL; + } + /* Call the guts */ + if ( s_pack_internal(soself, args, 2, buffer + offset) != 0 ) { + return NULL; + } + + return Py_None; +} + +/* + * Important Note: this is a slightly modified copy of + * getargs.c:convertbuffer(). All we want to achieve is to convert a PyObject + * into a writeable buffer. We should seriously consider adding this function + * to the API somehow. + */ +static Py_ssize_t +convertbuffer(PyObject *arg, void **p) +{ + PyBufferProcs *pb = arg->ob_type->tp_as_buffer; + Py_ssize_t count; + if (pb == NULL || + pb->bf_getreadbuffer == NULL || + pb->bf_getsegcount == NULL) { + + PyErr_SetString(StructError, + "string or read-only buffer"); + return -1; + } + + if ((*pb->bf_getsegcount)(arg, NULL) != 1) { + + PyErr_SetString(StructError, + "string or single-segment read-only buffer"); + return -1; + } + + if ((count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0) { + PyErr_SetString(StructError, "(unspecified)"); + } + + return count; } @@ -1312,6 +1423,7 @@ static struct PyMethodDef s_methods[] = { {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, + {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ From python-checkins at python.org Thu May 25 20:42:40 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 20:42:40 +0200 (CEST) Subject: [Python-checkins] r46237 - sandbox/trunk/newstruct/Modules/_newstruct.c Message-ID: <20060525184240.7F46E1E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 20:42:40 2006 New Revision: 46237 Modified: sandbox/trunk/newstruct/Modules/_newstruct.c Log: little endian buglet Modified: sandbox/trunk/newstruct/Modules/_newstruct.c ============================================================================== --- sandbox/trunk/newstruct/Modules/_newstruct.c (original) +++ sandbox/trunk/newstruct/Modules/_newstruct.c Thu May 25 20:42:40 2006 @@ -795,7 +795,7 @@ int i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); - } while (--i > 0); + } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) x |= -(x & (1L << (8 * f->size - 1))); @@ -818,7 +818,7 @@ int i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); - } while (--i > 0); + } while (i > 0); if (x <= INT_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); return PyLong_FromUnsignedLongLong(x); From python-checkins at python.org Thu May 25 20:44:10 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 25 May 2006 20:44:10 +0200 (CEST) Subject: [Python-checkins] r46238 - python/trunk/Lib/popen2.py Message-ID: <20060525184410.387FC1E400B@bag.python.org> Author: georg.brandl Date: Thu May 25 20:44:09 2006 New Revision: 46238 Modified: python/trunk/Lib/popen2.py Log: Guard the _active.remove() call to avoid errors when there is no _active list. Modified: python/trunk/Lib/popen2.py ============================================================================== --- python/trunk/Lib/popen2.py (original) +++ python/trunk/Lib/popen2.py Thu May 25 20:44:09 2006 @@ -72,8 +72,9 @@ # In case the child hasn't been waited on, check if it's done. self.poll(_deadstate=sys.maxint) if self.sts < 0: - # Child is still running, keep us alive until we can wait on it. - _active.append(self) + if _active: + # Child is still running, keep us alive until we can wait on it. + _active.append(self) def _run_child(self, cmd): if isinstance(cmd, basestring): From python-checkins at python.org Thu May 25 20:44:29 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 20:44:29 +0200 (CEST) Subject: [Python-checkins] r46239 - python/trunk/Objects/stringobject.c Message-ID: <20060525184429.E09F41E400B@bag.python.org> Author: fredrik.lundh Date: Thu May 25 20:44:29 2006 New Revision: 46239 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: use fastsearch also for find/index and contains. the related tests are now about 10x faster. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 20:44:29 2006 @@ -1149,10 +1149,14 @@ { char *s = PyString_AS_STRING(a); const char *sub = PyString_AS_STRING(el); - char *last; Py_ssize_t len_sub = PyString_GET_SIZE(el); +#ifdef USE_FAST + Py_ssize_t pos; +#else + char *last; Py_ssize_t shortsub; char firstchar, lastchar; +#endif if (!PyString_CheckExact(el)) { #ifdef Py_USING_UNICODE @@ -1168,6 +1172,14 @@ if (len_sub == 0) return 1; + +#ifdef USE_FAST + pos = fastsearch( + s, PyString_GET_SIZE(a), + sub, len_sub, FAST_SEARCH + ); + return (pos != -1); +#else /* last points to one char beyond the start of the rightmost substring. When s 0) ? i : last; + if (dir > 0) { + Py_ssize_t pos = fastsearch(s + i, last - i, sub, n, + FAST_SEARCH); + if (pos < 0) + return pos; + return pos + i; + } +#endif if (dir > 0) { if (n == 0 && i <= last) return (long)i; From python-checkins at python.org Thu May 25 20:44:50 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 20:44:50 +0200 (CEST) Subject: [Python-checkins] r46240 - python/trunk/Modules/_struct.c Message-ID: <20060525184450.673BE1E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 20:44:50 2006 New Revision: 46240 Modified: python/trunk/Modules/_struct.c Log: Struct now unpacks to PY_LONG_LONG directly when possible, also include #ifdef'ed out code that will return int instead of long when in bounds (not active since it's an API and doc change) Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 20:44:50 2006 @@ -15,6 +15,12 @@ typedef int Py_ssize_t; #endif +/* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the + struct API to return int instead of long when possible. This is + often a significant performance improvement. */ +/* +#define PY_USE_INT_WHEN_POSSIBLE 1 +*/ /* The translation function for each format character is table driven */ @@ -284,6 +290,10 @@ { unsigned int x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) + return PyInt_FromLong((long)x); +#endif return PyLong_FromUnsignedLong((unsigned long)x); } @@ -300,6 +310,10 @@ { unsigned long x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) + return PyInt_FromLong((long)x); +#endif return PyLong_FromUnsignedLong(x); } @@ -313,6 +327,10 @@ { PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif return PyLong_FromLongLong(x); } @@ -321,6 +339,10 @@ { unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif return PyLong_FromUnsignedLongLong(x); } @@ -584,28 +606,58 @@ do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) return PyInt_FromLong((long)x); +#endif + return PyLong_FromUnsignedLong(x); } static PyObject * bu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 1 /* signed */); +#endif } static PyObject * bu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 0 /* signed */); +#endif } static PyObject * @@ -750,28 +802,58 @@ do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) return PyInt_FromLong((long)x); +#endif + return PyLong_FromUnsignedLong((long)x); } static PyObject * lu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= INT_MIN && x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 1 /* signed */); +#endif } static PyObject * lu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= INT_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 0 /* signed */); +#endif } static PyObject * From buildbot at python.org Thu May 25 20:46:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 18:46:57 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060525184657.54E531E400B@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/185 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,fredrik.lundh,kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 20:47:15 2006 From: python-checkins at python.org (jack.diederich) Date: Thu, 25 May 2006 20:47:15 +0200 (CEST) Subject: [Python-checkins] r46241 - python/trunk/Objects/stringobject.c Message-ID: <20060525184715.72C1F1E400B@bag.python.org> Author: jack.diederich Date: Thu May 25 20:47:15 2006 New Revision: 46241 Modified: python/trunk/Objects/stringobject.c Log: * eliminate warning by reverting tmp_s type to 'const char*' Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 20:47:15 2006 @@ -3161,7 +3161,7 @@ { Py_ssize_t count = -1; PyObject *from, *to; - char *tmp_s; + const char *tmp_s; Py_ssize_t tmp_len; if (!PyArg_ParseTuple(args, "OO|n:replace", &from, &to, &count)) From python-checkins at python.org Thu May 25 21:03:22 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 21:03:22 +0200 (CEST) Subject: [Python-checkins] r46242 - python/trunk/Modules/_struct.c Message-ID: <20060525190322.C4CCA1E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 21:03:19 2006 New Revision: 46242 Modified: python/trunk/Modules/_struct.c Log: Fix Cygwin compiler issue Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 21:03:19 2006 @@ -1416,7 +1416,7 @@ static PyTypeObject PyStructType = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "Struct", sizeof(PyStructObject), @@ -1467,6 +1467,10 @@ if (m == NULL) return; + PyStructType.ob_type = &PyType_Type; + if (PyType_Ready(&PyStructType) < 0) + return; + /* Add some symbolic constants to the module */ if (StructError == NULL) { StructError = PyErr_NewException("struct.error", NULL, NULL); From python-checkins at python.org Thu May 25 21:15:28 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 21:15:28 +0200 (CEST) Subject: [Python-checkins] r46243 - python/trunk/Modules/_struct.c Message-ID: <20060525191528.3CD5B1E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 21:15:27 2006 New Revision: 46243 Modified: python/trunk/Modules/_struct.c Log: fix a struct regression where long would be returned for short unsigned integers Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 21:15:27 2006 @@ -609,6 +609,9 @@ #ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= INT_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong(x); } @@ -805,6 +808,9 @@ #ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= INT_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong((long)x); } From python-checkins at python.org Thu May 25 21:15:34 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 25 May 2006 21:15:34 +0200 (CEST) Subject: [Python-checkins] r46244 - in python/trunk: Modules/cPickle.c Modules/gcmodule.c Modules/parsermodule.c Objects/classobject.c Objects/typeobject.c Objects/weakrefobject.c Python/ceval.c Python/import.c Message-ID: <20060525191534.A52C21E400B@bag.python.org> Author: georg.brandl Date: Thu May 25 21:15:31 2006 New Revision: 46244 Modified: python/trunk/Modules/cPickle.c python/trunk/Modules/gcmodule.c python/trunk/Modules/parsermodule.c python/trunk/Objects/classobject.c python/trunk/Objects/typeobject.c python/trunk/Objects/weakrefobject.c python/trunk/Python/ceval.c python/trunk/Python/import.c Log: Replace PyObject_CallFunction calls with only object args with PyObject_CallFunctionObjArgs, which is 30% faster. Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Thu May 25 21:15:31 2006 @@ -3073,8 +3073,8 @@ "pickles are not supported."); return NULL; } - return PyObject_CallFunction(fc, "OO", py_module_name, - py_global_name); + return PyObject_CallFunctionObjArgs(fc, py_module_name, + py_global_name, NULL); } module = PySys_GetObject("modules"); Modified: python/trunk/Modules/gcmodule.c ============================================================================== --- python/trunk/Modules/gcmodule.c (original) +++ python/trunk/Modules/gcmodule.c Thu May 25 21:15:31 2006 @@ -603,7 +603,7 @@ assert(callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = PyObject_CallFunction(callback, "O", wr); + temp = PyObject_CallFunctionObjArgs(callback, wr, NULL); if (temp == NULL) PyErr_WriteUnraisable(callback); else Modified: python/trunk/Modules/parsermodule.c ============================================================================== --- python/trunk/Modules/parsermodule.c (original) +++ python/trunk/Modules/parsermodule.c Thu May 25 21:15:31 2006 @@ -3267,8 +3267,8 @@ && (pickler != NULL)) { PyObject *res; - res = PyObject_CallFunction(func, "OOO", &PyST_Type, pickler, - pickle_constructor); + res = PyObject_CallFunctionObjArgs(func, &PyST_Type, pickler, + pickle_constructor, NULL); Py_XDECREF(res); } Py_XDECREF(func); Modified: python/trunk/Objects/classobject.c ============================================================================== --- python/trunk/Objects/classobject.c (original) +++ python/trunk/Objects/classobject.c Thu May 25 21:15:31 2006 @@ -81,12 +81,9 @@ if (!PyClass_Check(base)) { if (PyCallable_Check( (PyObject *) base->ob_type)) - return PyObject_CallFunction( + return PyObject_CallFunctionObjArgs( (PyObject *) base->ob_type, - "OOO", - name, - bases, - dict); + name, bases, dict, NULL); PyErr_SetString(PyExc_TypeError, "PyClass_New: base must be a class"); return NULL; Modified: python/trunk/Objects/typeobject.c ============================================================================== --- python/trunk/Objects/typeobject.c (original) +++ python/trunk/Objects/typeobject.c Thu May 25 21:15:31 2006 @@ -4641,10 +4641,10 @@ (void *)PyObject_GenericGetAttr)) res = PyObject_GenericGetAttr(self, name); else - res = PyObject_CallFunction(getattribute, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattribute, self, name, NULL); if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); - res = PyObject_CallFunction(getattr, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattr, self, name, NULL); } return res; } @@ -4781,7 +4781,7 @@ obj = Py_None; if (type == NULL) type = Py_None; - return PyObject_CallFunction(get, "OOO", self, obj, type); + return PyObject_CallFunctionObjArgs(get, self, obj, type, NULL); } static int @@ -5728,8 +5728,8 @@ if (su->ob_type != &PySuper_Type) /* If su is an instance of a (strict) subclass of super, call its type */ - return PyObject_CallFunction((PyObject *)su->ob_type, - "OO", su->type, obj); + return PyObject_CallFunctionObjArgs((PyObject *)su->ob_type, + su->type, obj, NULL); else { /* Inline the common case */ PyTypeObject *obj_type = supercheck(su->type, obj); Modified: python/trunk/Objects/weakrefobject.c ============================================================================== --- python/trunk/Objects/weakrefobject.c (original) +++ python/trunk/Objects/weakrefobject.c Thu May 25 21:15:31 2006 @@ -851,7 +851,7 @@ static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunction(callback, "O", ref); + PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); if (cbresult == NULL) PyErr_WriteUnraisable(callback); Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Thu May 25 21:15:31 2006 @@ -4053,7 +4053,7 @@ metaclass = (PyObject *) &PyClass_Type; Py_INCREF(metaclass); } - result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods); + result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); Py_DECREF(metaclass); if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { /* A type error here likely means that the user passed Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Thu May 25 21:15:31 2006 @@ -1043,7 +1043,7 @@ PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = PyObject_CallFunction(hook, "O", p); + importer = PyObject_CallFunctionObjArgs(hook, p, NULL); if (importer != NULL) break; @@ -2499,8 +2499,8 @@ goto err; /* Call the _import__ function with the proper argument list */ - r = PyObject_CallFunction(import, "OOOO", - module_name, globals, globals, silly_list); + r = PyObject_CallFunctionObjArgs(import, module_name, globals, + globals, silly_list, NULL); err: Py_XDECREF(globals); From python-checkins at python.org Thu May 25 21:19:06 2006 From: python-checkins at python.org (fredrik.lundh) Date: Thu, 25 May 2006 21:19:06 +0200 (CEST) Subject: [Python-checkins] r46245 - python/trunk/Objects/stringobject.c Message-ID: <20060525191906.229271E400B@bag.python.org> Author: fredrik.lundh Date: Thu May 25 21:19:05 2006 New Revision: 46245 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: use insert+reverse instead of append Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 21:19:05 2006 @@ -1461,18 +1461,6 @@ else \ Py_DECREF(str); -#define SPLIT_INSERT(data, left, right) \ - str = PyString_FromStringAndSize((data) + (left), \ - (right) - (left)); \ - if (str == NULL) \ - goto onError; \ - if (PyList_Insert(list, 0, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - static PyObject * split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { @@ -1632,15 +1620,17 @@ if (j > i) { if (maxsplit-- <= 0) break; - SPLIT_INSERT(s, i + 1, j + 1); + SPLIT_APPEND(s, i + 1, j + 1); while (i >= 0 && isspace(Py_CHARMASK(s[i]))) i--; j = i; } } if (j >= 0) { - SPLIT_INSERT(s, 0, j + 1); + SPLIT_APPEND(s, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: Py_DECREF(list); @@ -1661,14 +1651,16 @@ if (s[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_INSERT(s, i + 1, j + 1); + SPLIT_APPEND(s, i + 1, j + 1); j = i = i - 1; } else i--; } if (j >= -1) { - SPLIT_INSERT(s, 0, j + 1); + SPLIT_APPEND(s, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: From buildbot at python.org Thu May 25 21:19:47 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 19:19:47 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian trunk Message-ID: <20060525191947.43CFE1E400B@bag.python.org> The Buildbot has detected a new failure of MIPS Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%2520trunk/builds/150 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,fredrik.lundh,kristjan.jonsson,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From fredrik at pythonware.com Thu May 25 21:22:51 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 25 May 2006 21:22:51 +0200 Subject: [Python-checkins] r46245 - python/trunk/Objects/stringobject.c In-Reply-To: <20060525191906.229271E400B@bag.python.org> References: <20060525191906.229271E400B@bag.python.org> Message-ID: > needforspeed: use insert+reverse instead of append I meant "use append+reverse instead of insert", of course. doing things the other way around is *slow*... From brett at python.org Thu May 25 21:25:43 2006 From: brett at python.org (Brett Cannon) Date: Thu, 25 May 2006 12:25:43 -0700 Subject: [Python-checkins] r46245 - python/trunk/Objects/stringobject.c In-Reply-To: References: <20060525191906.229271E400B@bag.python.org> Message-ID: If you want to edit the log message, see http://www.python.org/dev/faq/#how-can-i-edit-the-log-message-of-a-committed-revision. -Brett On 5/25/06, Fredrik Lundh wrote: > > > needforspeed: use insert+reverse instead of append > > I meant "use append+reverse instead of insert", of course. doing things > the other way around is *slow*... > > > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060525/395a98d9/attachment.html From python-checkins at python.org Thu May 25 21:33:38 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 21:33:38 +0200 (CEST) Subject: [Python-checkins] r46246 - python/trunk/Modules/_struct.c Message-ID: <20060525193338.F05A61E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 21:33:38 2006 New Revision: 46246 Modified: python/trunk/Modules/_struct.c Log: Use LONG_MIN and LONG_MAX to check Python integer bounds instead of the incorrect INT_MIN and INT_MAX Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 21:33:38 2006 @@ -291,7 +291,7 @@ unsigned int x; memcpy((char *)&x, p, sizeof x); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong((unsigned long)x); @@ -311,7 +311,7 @@ unsigned long x; memcpy((char *)&x, p, sizeof x); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong(x); @@ -328,7 +328,7 @@ PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x >= INT_MIN && x <= INT_MAX) + if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); #endif return PyLong_FromLongLong(x); @@ -340,7 +340,7 @@ unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); #endif return PyLong_FromUnsignedLongLong(x); @@ -607,7 +607,7 @@ x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong((long)x); #else if (SIZEOF_LONG > f->size) @@ -629,7 +629,7 @@ if (SIZEOF_LONG_LONG > f->size) x |= -(x & (1L << (8 * f->size - 1))); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x >= INT_MIN && x <= INT_MAX) + if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); #endif return PyLong_FromLongLong(x); @@ -651,7 +651,7 @@ x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); #endif return PyLong_FromUnsignedLongLong(x); @@ -806,7 +806,7 @@ x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong((long)x); #else if (SIZEOF_LONG > f->size) @@ -828,7 +828,7 @@ if (SIZEOF_LONG_LONG > f->size) x |= -(x & (1L << (8 * f->size - 1))); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x >= INT_MIN && x <= INT_MAX) + if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); #endif return PyLong_FromLongLong(x); @@ -850,7 +850,7 @@ x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); #ifdef PY_USE_INT_WHEN_POSSIBLE - if (x <= INT_MAX) + if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); #endif return PyLong_FromUnsignedLongLong(x); @@ -1477,14 +1477,17 @@ if (PyType_Ready(&PyStructType) < 0) return; + /* Add some symbolic constants to the module */ if (StructError == NULL) { StructError = PyErr_NewException("struct.error", NULL, NULL); if (StructError == NULL) return; } + Py_INCREF(StructError); PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); } From buildbot at python.org Thu May 25 21:38:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 19:38:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060525193804.B88801E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/780 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,georg.brandl,jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 21:43:04 2006 From: python-checkins at python.org (richard.jones) Date: Thu, 25 May 2006 21:43:04 +0200 (CEST) Subject: [Python-checkins] r46247 - in python/branches/sreifschneider-newnewexcept: Makefile.pre.in Objects/exceptions.c Python/exceptions.c Message-ID: <20060525194304.CF03E1E401C@bag.python.org> Author: richard.jones Date: Thu May 25 21:43:03 2006 New Revision: 46247 Removed: python/branches/sreifschneider-newnewexcept/Python/exceptions.c Modified: python/branches/sreifschneider-newnewexcept/Makefile.pre.in python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Transitioning Exceptions over to being PyTypeObjects rather than faked-class PyObjects. Doesn't currently work - this is just to checkpoint that the bulk of the work has been done and now we're debugging. Modified: python/branches/sreifschneider-newnewexcept/Makefile.pre.in ============================================================================== --- python/branches/sreifschneider-newnewexcept/Makefile.pre.in (original) +++ python/branches/sreifschneider-newnewexcept/Makefile.pre.in Thu May 25 21:43:03 2006 @@ -240,7 +240,6 @@ Python/asdl.o \ Python/ast.o \ Python/bltinmodule.o \ - Python/exceptions.o \ Python/ceval.o \ Python/compile.o \ Python/codecs.o \ @@ -289,6 +288,7 @@ Objects/complexobject.o \ Objects/descrobject.o \ Objects/enumobject.o \ + Objects/exceptions.o \ Objects/genobject.o \ Objects/fileobject.o \ Objects/floatobject.o \ Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Thu May 25 21:43:03 2006 @@ -1,3 +1,7 @@ +#define PY_SSIZE_T_CLEAN +#include +#include "structmember.h" +#include "osdefs.h" /* * BaseException @@ -65,55 +69,31 @@ #ifdef Py_USING_UNICODE static PyObject * -BaseException_unicode(PyObject *self, PyObject *args) +BaseException_unicode(BaseExceptionObject *self, PyObject *args) { - Py_ssize_t args_len; - - if (!PyArg_ParseTuple(args, "O:__unicode__", &self)) - return NULL; - - args_len = PySequence_Size(self->args); - if (args_len < 0) { - return NULL; - } - - if (args_len == 0) { - return PyUnicode_FromUnicode(NULL, 0); - } - else if (args_len == 1) { - PyObject *temp = PySequence_GetItem(self->args, 0); - PyObject *unicode_obj; - - if (!temp) { - return NULL; - } - unicode_obj = PyObject_Unicode(temp); - Py_DECREF(temp); - return unicode_obj; - } - else { - PyObject *unicode_obj = PyObject_Unicode(self->args); - - return unicode_obj; - } + PyObject *temp = PySequence_GetItem(self->args, 0); + PyObject *unicode_obj; + if (!temp) { + return NULL; + } + unicode_obj = PyObject_Unicode(temp); + Py_DECREF(temp); + return unicode_obj; } #endif /* Py_USING_UNICODE */ static PyObject * -BaseException_repr(PyObject *self) +BaseException_repr(BaseExceptionObject *self) { Py_ssize_t args_len; PyObject *repr_suffix; PyObject *repr; - - if (!PyArg_ParseTuple(args, "O:__repr__", &self)) - return NULL; args_len = PySequence_Length(self->args); if (args_len < 0) { return NULL; } - + if (args_len == 0) { repr_suffix = PyString_FromString("()"); if (!repr_suffix) @@ -123,7 +103,6 @@ PyObject *args_repr = PyObject_Repr(self->args); if (!args_repr) return NULL; - repr_suffix = args_repr; } @@ -138,28 +117,22 @@ } static PyObject * -BaseException_getitem(PyObject *self, PyObject *args) +BaseException_getitem(BaseExceptionObject *self, Py_ssize_t index) { - PyObject *out; - PyObject *index; - - if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) - return NULL; - - return PyObject_GetItem(self->args, index); + return PySequence_GetItem(self->args, index); } static PySequenceMethods BaseException_as_sequence = { - 0 sq_length; - 0 sq_concat; - 0 sq_repeat; - BaseException_getitem sq_item; - 0 sq_slice; - 0 sq_ass_item; - 0 sq_ass_slice; - 0 sq_contains; - 0 sq_inplace_concat; - 0 sq_inplace_repeat; + 0, /* sq_length; */ + 0, /* sq_concat; */ + 0, /* sq_repeat; */ + (ssizeargfunc)BaseException_getitem, /* sq_item; */ + 0, /* sq_slice; */ + 0, /* sq_ass_item; */ + 0, /* sq_ass_slice; */ + 0, /* sq_contains; */ + 0, /* sq_inplace_concat; */ + 0 /* sq_inplace_repeat; */ }; static PyMemberDef BaseException_members[] = { @@ -169,20 +142,23 @@ }; static PyMethodDef BaseException_methods[] = { +#ifdef Py_USING_UNICODE {"__unicode__", (PyCFunction)BaseException_unicode, METH_O }, +#endif {NULL, NULL, 0, NULL}, }; -static PyTypeObject BaseExceptionType = { +static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "exceptions.BaseException", /*tp_name*/ sizeof(BaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ - BaseException_dealloc, /*tp_dealloc*/ + (destructor)BaseException_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ + 0, /* tp_compare; */ (reprfunc)BaseException_repr, /*tp_repr*/ 0, /*tp_as_number*/ &BaseException_as_sequence, /*tp_as_sequence*/ @@ -213,64 +189,85 @@ 0, /* tp_alloc */ 0, /* tp_new */ }; +/* the CPython API expects exceptions to be (PyObject *) - both a hold-over +from the previous implmentation and also allowing Python objects to be used +in the API */ +PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException; #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \ -static PyTypeObject EXCNAMEType = { \ +static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ "exceptions.EXCNAME", \ sizeof(BaseExceptionObject), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, &EXCBASE, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, 0, 0, 0, 0,\ -}; +}; \ +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; -#define ComplexExtendsException(EXCBASE, EXCNAME, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCINIT, EXCNEW, EXCSTR, EXCDOC) \ -static PyTypeObject EXCNAMEType = { \ +#define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \ +static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ "exceptions.EXCNAME", \ - sizeof(EXCNAMEObject), \ - 0, EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, EXCSTR, 0, 0, 0, \ + sizeof(EXCSTORE), \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ - 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &EXCBASE, \ - 0, 0, 0, 0, EXCINIT, 0, EXCNEW,\ -}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ + 0, 0, 0, 0, 0, 0, 0,\ +}; \ +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; + +#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCINIT, EXCNEW, EXCSTR, EXCDOC) \ +static PyTypeObject _PyExc_ ## EXCNAME = { \ + PyObject_HEAD_INIT(NULL) \ + 0, \ + "exceptions.EXCNAME", \ + sizeof(EXCSTORE), 0, \ + (destructor)EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + (reprfunc)EXCSTR, 0, 0, 0, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ + EXCDOC, \ + 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ + 0, 0, 0, 0, (initproc)EXCINIT, 0, (newfunc)EXCNEW,\ +}; \ +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; /* * Exception extends BaseException */ -SimpleExtendsException(BaseExceptionType, Exception, "Common base class for all non-exit exceptions.") +SimpleExtendsException(PyExc_BaseException, Exception, "Common base class for all non-exit exceptions.") /* * StandardError extends Exception */ -SimpleExtendsException(ExceptionType, StandardError, -"Base class for all standard Python exceptions that do not represent" -"interpreter exiting."); +SimpleExtendsException(PyExc_Exception, StandardError, + "Base class for all standard Python exceptions that do not represent\n" + "interpreter exiting."); /* * TypeError extends StandardError */ -SimpleExtendsException(StandardErrorType, TypeError, "Inappropriate argument type."); +SimpleExtendsException(PyExc_StandardError, TypeError, "Inappropriate argument type."); /* * StopIteration extends Exception */ -SimpleExtendsException(ExceptionType, StopIteration, "Signal the end from iterator.next()."); +SimpleExtendsException(PyExc_Exception, StopIteration, "Signal the end from iterator.next()."); /* * GeneratorExit extends Exception */ -SimpleExtendsException(ExceptionType, GeneratorExit, "Request that a generator exit."); +SimpleExtendsException(PyExc_Exception, GeneratorExit, "Request that a generator exit."); /* @@ -313,19 +310,18 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(BaseExceptionType, SystemExit, SystemExit_dealloc, 0, SystemExit_members, SystemExit_init, 0, "Request to exit from the interpreter."); - +ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExitObject, SystemExit_dealloc, 0, SystemExit_members, SystemExit_init, 0, 0, "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException */ -SimpleExtendsException(BaseExceptionType, KeyboardInterrupt, "Program interrupted by user."); +SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, "Program interrupted by user."); /* * ImportError extends StandardError */ -SimpleExtendsException(StandardErrorType, ImportError, "Import can't find module, or can't find name in module."); +SimpleExtendsException(PyExc_StandardError, ImportError, "Import can't find module, or can't find name in module."); /* @@ -335,20 +331,20 @@ PyObject_HEAD PyObject *args; PyObject *message; - PyObject *errno; + PyObject *myerrno; PyObject *strerror; PyObject *filename; } EnvironmentErrorObject; static int -EnvironmentError_init(PyObject *self, PyObject *args, PyObject *kwds) +EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *subslice = NULL; if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) return -1; - self->errno = Py_None; + self->myerrno = Py_None; Py_INCREF(Py_None); self->strerror = Py_None; Py_INCREF(Py_None); @@ -368,8 +364,8 @@ * means we need our own __str__() which prints out the filename * when it was supplied. */ - self->errno = PySequence_GetItem(args, 0); - if (!self->errno) goto finally; + self->myerrno = PySequence_GetItem(args, 0); + if (!self->myerrno) goto finally; self->strerror = PySequence_GetItem(args, 1); if (!self->strerror) goto finally; self->filename = PySequence_GetItem(args, 2); @@ -387,8 +383,8 @@ /* Used when PyErr_SetFromErrno() is called and no filename * argument is given. */ - self->errno = PySequence_GetItem(args, 0); - if (!self->errno) goto finally; + self->myerrno = PySequence_GetItem(args, 0); + if (!self->myerrno) goto finally; self->strerror = PySequence_GetItem(args, 1); if (!self->strerror) goto finally; return 0; @@ -400,7 +396,7 @@ finally: Py_XDECREF(subslice); - Py_XDECREF(self->errno); + Py_XDECREF(self->myerrno); Py_XDECREF(self->strerror); Py_XDECREF(self->filename); return -1; @@ -410,17 +406,17 @@ EnvironmentError_dealloc(EnvironmentErrorObject *self) { BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->errno); + Py_DECREF(self->myerrno); Py_DECREF(self->strerror); Py_DECREF(self->filename); } static PyObject * -EnvironmentError_str(PyObject *self) +EnvironmentError_str(EnvironmentErrorObject *self) { PyObject *rtnval = NULL; - if (filename != Py_None) { + if (self->filename != Py_None) { PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); PyObject *repr = PyObject_Repr(self->filename); PyObject *tuple = PyTuple_New(3); @@ -432,29 +428,26 @@ return NULL; } - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + PyTuple_SET_ITEM(tuple, 1, self->strerror); PyTuple_SET_ITEM(tuple, 2, repr); rtnval = PyString_Format(fmt, tuple); Py_DECREF(fmt); Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; } - else if (PyObject_IsTrue(self->errno) && PyObject_IsTrue(self->strerror)) { + else if (PyObject_IsTrue(self->myerrno) && PyObject_IsTrue(self->strerror)) { PyObject *fmt = PyString_FromString("[Errno %s] %s"); PyObject *tuple = PyTuple_New(2); if (!fmt || !tuple) { Py_XDECREF(fmt); Py_XDECREF(tuple); - goto finally; + return NULL; } - PyTuple_SET_ITEM(tuple, 0, self->errno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); PyTuple_SET_ITEM(tuple, 1, self->strerror); rtnval = PyString_Format(fmt, tuple); @@ -463,7 +456,7 @@ Py_DECREF(tuple); } else - rtnval = BaseException_str_(self); + rtnval = BaseException_str((BaseExceptionObject *)self); return rtnval; } @@ -471,25 +464,25 @@ static PyMemberDef EnvironmentError_members[] = { {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), 0, "exception arguments"}, {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, "exception message"}, - {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, errno), 0, "exception code"}, + {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, myerrno), 0, "exception code"}, {"strerror", T_OBJECT, offsetof(EnvironmentErrorObject, strerror), 0, "exception code"}, {"filename", T_OBJECT, offsetof(EnvironmentErrorObject, filename), 0, "exception code"}, {NULL} /* Sentinel */ }; -ComplexExtendsException(StandardErrorType, EnvironmentError, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_init, EnvironmentError_str, "Base class for I/O related errors."); +ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentErrorObject, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_init, 0, EnvironmentError_str, "Base class for I/O related errors."); /* * IOError extends EnvironmentError */ -SimpleExtendsException(EnvironmentErrorType, IOError, "I/O operation failed."); +MiddlingExtendsException(PyExc_EnvironmentError, IOError, EnvironmentErrorObject, "I/O operation failed."); /* * OSError extends EnvironmentError */ -SimpleExtendsException(EnvironmentErrorType, OSError, "OS system call failed."); +MiddlingExtendsException(PyExc_EnvironmentError, OSError, EnvironmentErrorObject, "OS system call failed."); /* @@ -502,7 +495,7 @@ PyObject_HEAD PyObject *args; PyObject *message; - PyObject *errno; + PyObject *myerrno; PyObject *strerror; PyObject *filename; PyObject *winerror; @@ -519,18 +512,18 @@ /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ - errcode = PyInt_AsLong(self->errno); + errcode = PyInt_AsLong(self->myerrno); if (!errcode == -1 && PyErr_Occurred()) goto failed; posix_errno = winerror_to_errno(errcode); - self->winerror = self->errno; + self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); if (!o_errcode) goto failed; - self->errno = o_errcode; + self->myerrno = o_errcode; return 0; failed: @@ -554,18 +547,18 @@ if (!fmt || !repr) goto finally; - tuple = PyTuple_Pack(3, sellf->errno, self->strerror, repr); + tuple = PyTuple_Pack(3, sellf->myerrno, self->strerror, repr); if (!tuple) goto finally; rtnval = PyString_Format(fmt, tuple); } - else if (PyObject_IsTrue(self->errno) && PyObject_IsTrue(self->strerror)) { + else if (PyObject_IsTrue(self->myerrno) && PyObject_IsTrue(self->strerror)) { fmt = PyString_FromString("[Error %s] %s"); if (!fmt) goto finally; - tuple = PyTuple_Pack(2, self->errno, self->strerror); + tuple = PyTuple_Pack(2, self->myerrno, self->strerror); if (!tuple) goto finally; @@ -587,14 +580,14 @@ static PyMemberDef WindowsError_members[] = { {"args", T_OBJECT, offsetof(WindowsErrorObject, args), 0, "exception arguments"}, {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, "exception message"}, - {"errno", T_OBJECT, offsetof(WindowsErrorObject, errno), 0, "exception code"}, + {"errno", T_OBJECT, offsetof(WindowsErrorObject, myerrno), 0, "exception code"}, {"strerror", T_OBJECT, offsetof(WindowsErrorObject, strerror), 0, "exception code"}, {"filename", T_OBJECT, offsetof(WindowsErrorObject, filename), 0, "exception code"}, {"winerror", T_OBJECT, offsetof(WindowsErrorObject, winerror), 0, "windows exception code"}, {NULL} /* Sentinel */ }; -ComplexExtendsException(OSErrorType, WindowsError, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_init, WindowsError_str, "MS-Windows OS system call failed."); +ComplexExtendsException(PyExc_OSError, WindowsError, WindowsErrorObject, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_init, WindowsError_str, "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ @@ -603,47 +596,46 @@ * VMSError extends OSError (I think) */ #ifdef __VMS -SimpleExtendsException(OSErrorType, VMSError, "OpenVMS OS system call failed."); +MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentErrorObject, "OpenVMS OS system call failed."); #endif /* * EOFError extends StandardError */ -SimpleExtendsException(StandardErrorType, EOFError, "Read beyond end of file."); +SimpleExtendsException(PyExc_StandardError, EOFError, "Read beyond end of file."); /* * RuntimeError extends StandardError */ -SimpleExtendsException(StandardErrorType, RuntimeError, "Unspecified run-time error."); +SimpleExtendsException(PyExc_StandardError, RuntimeError, "Unspecified run-time error."); /* * NotImplementedError extends RuntimeError */ -SimpleExtendsException(RuntimeErrorType, NotImplementedError, "Method or function hasn't been implemented yet."); +SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, "Method or function hasn't been implemented yet."); /* * NameError extends StandardError */ -SimpleExtendsException(StandardErrorType, NameError, "Name not found globally."); +SimpleExtendsException(PyExc_StandardError, NameError, "Name not found globally."); /* * UnboundLocalError extends NameError */ -SimpleExtendsException(NameErrorType, UnboundLocalError, "Local name referenced but not bound to a value."); +SimpleExtendsException(PyExc_NameError, UnboundLocalError, "Local name referenced but not bound to a value."); /* * AttributeError extends StandardError */ -SimpleExtendsException(StandardErrorType, AttributeError, "Attribute not found."); +SimpleExtendsException(PyExc_StandardError, AttributeError, "Attribute not found."); /* * SyntaxError extends StandardError */ - typedef struct { PyObject_HEAD PyObject *args; @@ -657,12 +649,12 @@ } SyntaxErrorObject; static int -SyntaxError_init(PyObject *self, PyObject *args, PyObject *kwds) +SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *info = NULL; Py_ssize_t lenargs; - if (BaseException_init(self, args, kwds) == -1 ) + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1 ) return -1; self->msg = self->filename = self->lineno = self->offset = @@ -709,7 +701,6 @@ SyntaxError_dealloc(SyntaxErrorObject *self) { BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->code); Py_DECREF(self->msg); Py_DECREF(self->filename); Py_DECREF(self->lineno); @@ -739,7 +730,7 @@ static PyObject * -SyntaxError_str(PyObject *self) +SyntaxError_str(SyntaxErrorObject *self) { PyObject *str; PyObject *result; @@ -792,8 +783,816 @@ return result; } -ComplexExtendsException(StandardErrorType, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_init, SyntaxError_str, "Invalid syntax."); +static PyMemberDef SyntaxError_members[] = { + {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, "exception message"}, + {"msg", T_OBJECT, offsetof(SyntaxErrorObject, msg), 0, "exception msg"}, + {"filename", T_OBJECT, offsetof(SyntaxErrorObject, filename), 0, "exception filename"}, + {"lineno", T_OBJECT, offsetof(SyntaxErrorObject, lineno), 0, "exception lineno"}, + {"offset", T_OBJECT, offsetof(SyntaxErrorObject, offset), 0, "exception offset"}, + {"text", T_OBJECT, offsetof(SyntaxErrorObject, text), 0, "exception text"}, + {"print_file_and_line", T_OBJECT, offsetof(SyntaxErrorObject, print_file_and_line), 0, "exception print_file_and_line"}, + {NULL} /* Sentinel */ +}; + +ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxErrorObject, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_init, 0, SyntaxError_str, "Invalid syntax."); + + +/* + * IndentationError extends SyntaxError + */ +MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxErrorObject, "Improper indentation."); + + +/* + * TabError extends IndentationError + */ +MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxErrorObject, "Improper mixture of spaces and tabs."); + + +/* + * LookupError extends StandardError + */ + SimpleExtendsException(PyExc_StandardError, LookupError, "Base class for lookup errors."); + + +/* + * IndexError extends LookupError + */ +SimpleExtendsException(PyExc_LookupError, IndexError, "Sequence index out of range."); + + +/* + * KeyError extends LookupError + */ +static PyObject * +KeyError_str(BaseExceptionObject *self) +{ + /* If args is a tuple of exactly one item, apply repr to args[0]. + This is done so that e.g. the exception raised by {}[''] prints + KeyError: '' + rather than the confusing + KeyError + alone. The downside is that if KeyError is raised with an explanatory + string, that string will be displayed in quotes. Too bad. + If args is anything else, use the default BaseException__str__(). + */ + if (PyTuple_Check(self->args) && PyTuple_GET_SIZE(self->args) == 1) { + PyObject *key = PyTuple_GET_ITEM(self->args, 0); + return PyObject_Repr(key); + } + return BaseException_str(self); +} + +ComplexExtendsException(PyExc_LookupError, KeyError, BaseExceptionObject, 0, 0, 0, 0, 0, KeyError_str, "Mapping key not found."); + + +/* + * ValueError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, ValueError, "Inappropriate argument value (of correct type)."); + +/* + * UnicodeError extends ValueError + */ + +SimpleExtendsException(PyExc_ValueError, UnicodeError, "Unicode related error."); + +#ifdef Py_USING_UNICODE +typedef struct { + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + PyObject *start; + PyObject *end; + PyObject *reason; +} UnicodeErrorObject; + +static +int get_int(PyObject *attr, Py_ssize_t *value, const char *name) +{ + if (PyInt_Check(attr)) { + *value = PyInt_AS_LONG(attr); + } else if (PyLong_Check(attr)) { + *value = (size_t)PyLong_AsLongLong(attr); + if (*value == -1) + return -1; + } else { + PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); + return -1; + } + return 0; +} + +static +int set_ssize_t(PyObject **attr, Py_ssize_t value) +{ + PyObject *obj = PyInt_FromSsize_t(value); + if (!obj) + return -1; + Py_XDECREF(*attr); + *attr = obj; + return 0; +} + +static +PyObject *get_string(PyObject *attr, const char *name) +{ + if (!PyString_Check(attr)) { + PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); + return NULL; + } + Py_INCREF(attr); + return attr; +} + + +static +int set_string(PyObject **attr, const char *value) +{ + PyObject *obj = PyString_FromString(value); + if (!obj) + return -1; + Py_XDECREF(*attr); + *attr = obj; + return 0; +} + + +static +PyObject *get_unicode(PyObject *attr, const char *name) +{ + if (!PyUnicode_Check(attr)) { + PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); + return NULL; + } + Py_INCREF(attr); + return attr; +} + +PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); +} + +PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); +} + +PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) +{ + return get_unicode(((UnicodeErrorObject *)exc)->object, "object"); +} + +PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->object, "object"); +} + +PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) +{ + return get_unicode(((UnicodeErrorObject *)exc)->object, "object"); +} + +int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) +{ + if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { + Py_ssize_t size; + size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*start<0) + *start = 0; /*XXX check for values <0*/ + if (*start>=size) + *start = size-1; + return 0; + } + return -1; +} + + +int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) +{ + if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { + Py_ssize_t size; + size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*start<0) + *start = 0; + if (*start>=size) + *start = size-1; + return 0; + } + return -1; +} + + +int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) +{ + return PyUnicodeEncodeError_GetStart(exc, start); +} + + +int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); +} + + +int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); +} + + +int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); +} + + +int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) +{ + if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { + Py_ssize_t size; + size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + return 0; + } + return -1; +} + + +int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) +{ + if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { + Py_ssize_t size; + size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + return 0; + } + return -1; +} + + +int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) +{ + return PyUnicodeEncodeError_GetEnd(exc, start); +} + + +int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); +} + + +int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); +} + + +int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) +{ + return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); +} + +PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); +} + + +PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); +} + + +PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) +{ + return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); +} + + +int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) +{ + return set_string(&((UnicodeErrorObject *)exc)->reason, reason); +} + + +int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) +{ + return set_string(&((UnicodeErrorObject *)exc)->reason, reason); +} + + +int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) +{ + return set_string(&((UnicodeErrorObject *)exc)->reason, reason); +} + + +static int +UnicodeError_init(UnicodeErrorObject *self, PyObject *args, PyTypeObject *objecttype) +{ + if (BaseException_init((BaseExceptionObject *)self, args, NULL) == -1 ) + return -1; + + if (!PyArg_ParseTuple(args, "O!O!O!O!O!", + &PyString_Type, &self->encoding, + objecttype, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) + return -1; + + Py_INCREF(self->encoding); + Py_INCREF(self->object); + Py_INCREF(self->start); + Py_INCREF(self->end); + Py_INCREF(self->reason); + + return 0; +} + +static void +UnicodeError_dealloc(UnicodeErrorObject *self) +{ + BaseException_dealloc((BaseExceptionObject *)self); + Py_DECREF(self->encoding); + Py_DECREF(self->object); + Py_DECREF(self->start); + Py_DECREF(self->end); + Py_DECREF(self->reason); +} + + +/* + * UnicodeEncodeError extends UnicodeError + */ +static int +UnicodeEncodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +{ + return UnicodeError_init(self, args, &PyUnicode_Type); +} + +static PyObject * +UnicodeEncodeError_str(PyObject *self) +{ + Py_ssize_t start; + Py_ssize_t end; + + if (PyUnicodeEncodeError_GetStart(self, &start)) + return NULL; + + if (PyUnicodeEncodeError_GetEnd(self, &end)) + return NULL; + + if (end==start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( + "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + badchar_str, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); + } + return PyString_FromFormat( + "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + start, + (end-1), + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); +} + +ComplexExtendsException(PyExc_UnicodeError, UnicodeEncodeError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeEncodeError_init, 0, UnicodeEncodeError_str, "Unicode encoding error."); +PyObject * PyUnicodeEncodeError_Create( + const char *encoding, const Py_UNICODE *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) +{ + return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", + encoding, object, length, start, end, reason); +} + + +/* + * UnicodeDecodeError extends UnicodeError + */ +static int +UnicodeDecodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +{ + return UnicodeError_init(self, args, &PyString_Type); +} + +static PyObject * +UnicodeDecodeError_str(PyObject *self) +{ + Py_ssize_t start; + Py_ssize_t end; + + if (PyUnicodeDecodeError_GetStart(self, &start)) + return NULL; + + if (PyUnicodeDecodeError_GetEnd(self, &end)) + return NULL; + + if (end==start+1) { + /* FromFormat does not support %02x, so format that separately */ + char byte[4]; + PyOS_snprintf(byte, sizeof(byte), "%02x", + ((int)PyString_AS_STRING(((UnicodeErrorObject *)self)->object)[start])&0xff); + return PyString_FromFormat( + "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + byte, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); + } + return PyString_FromFormat( + "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + start, + (end-1), + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); +} + +ComplexExtendsException(PyExc_UnicodeError, UnicodeDecodeError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeDecodeError_init, 0, UnicodeDecodeError_str, "Unicode decoding error."); + +PyObject * PyUnicodeDecodeError_Create( + const char *encoding, const char *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) +{ + assert(length < INT_MAX); + assert(start < INT_MAX); + assert(end < INT_MAX); + return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns", + encoding, object, length, start, end, reason); +} + + +/* + * UnicodeTranslateError extends UnicodeError + */ +static int +UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +{ + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1 ) + return -1; + + if (!PyArg_ParseTuple(args, "O!O!O!O!", + &PyUnicode_Type, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) + return -1; + + self->encoding = Py_None; + Py_INCREF(self->encoding); + Py_INCREF(self->object); + Py_INCREF(self->start); + Py_INCREF(self->end); + Py_INCREF(self->reason); + + return 0; +} + + +static PyObject * +UnicodeTranslateError_str(PyObject *self) +{ + Py_ssize_t start; + Py_ssize_t end; + + if (PyUnicodeTranslateError_GetStart(self, &start)) + return NULL; + + if (PyUnicodeTranslateError_GetEnd(self, &end)) + return NULL; + + if (end==start+1) { + int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( + "can't translate character u'\\%s' in position %zd: %.400s", + badchar_str, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); + } + return PyString_FromFormat( + "can't translate characters in position %zd-%zd: %.400s", + start, + (end-1), + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); +} + +ComplexExtendsException(PyExc_UnicodeError, UnicodeTranslateError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeTranslateError_init, 0, UnicodeTranslateError_str, "Unicode translation error."); + +PyObject * PyUnicodeTranslateError_Create( + const Py_UNICODE *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) +{ + return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", + object, length, start, end, reason); +} +#endif -/* WE'RE HALF WAY! WOO! */ +/* + * AssertionError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, AssertionError, "Assertion failed."); + + +/* + * ArithmeticError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, ArithmeticError, "Base class for arithmetic errors."); + + +/* + * FloatingPointError extends ArithmeticError + */ +SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, "Floating point operation failed."); + + +/* + * OverflowError extends ArithmeticError + */ +SimpleExtendsException(PyExc_ArithmeticError, OverflowError, "Result too large to be represented."); + + +/* + * ZeroDivisionError extends ArithmeticError + */ +SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, "Second argument to a division or modulo operation was zero."); + + +/* + * SystemError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, SystemError, + "Internal error in the Python interpreter.\n" + "\n" + "Please report this to the Python maintainer, along with the traceback,\n" + "the Python version, and the hardware/OS platform and version."); + + +/* + * ReferenceError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, ReferenceError, "Weak ref proxy used after referent went away."); + + +/* + * MemoryError extends StandardError + */ +SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory."); + + +/* Warning category docstrings */ + +/* + * Warning extends Exception + */ +SimpleExtendsException(PyExc_Exception, Warning, "Base class for warning categories."); + + +/* + * UserWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, UserWarning, "Base class for warnings generated by user code."); + + +/* + * DeprecationWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, DeprecationWarning, "Base class for warnings about deprecated features."); + + +/* + * PendingDeprecationWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, PendingDeprecationWarning, + "Base class for warnings about features which will be deprecated\n" + "in the future."); + + +/* + * SyntaxWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, SyntaxWarning, "Base class for warnings about dubious syntax."); + + +/* + * OverflowWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, OverflowWarning, "Base class for warnings about numeric overflow. Won't exist in Python 2.5."); + + +/* + * RuntimeWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, RuntimeWarning, "Base class for warnings about dubious runtime behavior."); + + +/* + * FutureWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, FutureWarning, + "Base class for warnings about constructs that will change semantically\n" + "in the future."); + + +/* + * ImportWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, ImportWarning, "Base class for warnings about probable mistakes in module imports"); + + +/* Pre-computed MemoryError instance. Best to create this as early as + * possible and not wait until a MemoryError is actually raised! + */ +PyObject *PyExc_MemoryErrorInst=NULL; + +/* module global functions */ +static PyMethodDef functions[] = { + /* Sentinel */ + {NULL, NULL} +}; + + +#define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ + Py_FatalError("exceptions bootstrapping error."); + +#define POST_INIT(TYPE) Py_INCREF(PyExc_ ## TYPE); \ + PyModule_AddObject(m, "TYPE", PyExc_ ## TYPE); \ + if (PyDict_SetItemString(bdict, "TYPE", PyExc_ ## TYPE)) \ + Py_FatalError("Module dictionary insertion problem."); + +PyMODINIT_FUNC +_PyExc_Init(void) +{ + PyObject *m, *bltinmod, *bdict; + + bltinmod = PyImport_ImportModule("__builtin__"); + if (bltinmod == NULL) + Py_FatalError("exceptions bootstrapping error."); + bdict = PyModule_GetDict(bltinmod); + if (bdict == NULL) + Py_FatalError("exceptions bootstrapping error."); + + PRE_INIT(BaseException) + PRE_INIT(Exception) + PRE_INIT(StandardError) + PRE_INIT(TypeError) + PRE_INIT(StopIteration) + PRE_INIT(GeneratorExit) + PRE_INIT(SystemExit) + PRE_INIT(KeyboardInterrupt) + PRE_INIT(ImportError) + PRE_INIT(EnvironmentError) + PRE_INIT(IOError) + PRE_INIT(OSError) +#ifdef MS_WINDOWS + PRE_INIT(WindowsError) +#endif +#ifdef __VMS + PRE_INIT(VMSError) +#endif + PRE_INIT(EOFError) + PRE_INIT(RuntimeError) + PRE_INIT(NotImplementedError) + PRE_INIT(NameError) + PRE_INIT(UnboundLocalError) + PRE_INIT(AttributeError) + PRE_INIT(SyntaxError) + PRE_INIT(IndentationError) + PRE_INIT(TabError) + PRE_INIT(LookupError) + PRE_INIT(IndexError) + PRE_INIT(KeyError) + PRE_INIT(ValueError) + PRE_INIT(UnicodeError) +#ifdef Py_USING_UNICODE + PRE_INIT(UnicodeEncodeError) + PRE_INIT(UnicodeDecodeError) + PRE_INIT(UnicodeTranslateError) +#endif + PRE_INIT(AssertionError) + PRE_INIT(ArithmeticError) + PRE_INIT(FloatingPointError) + PRE_INIT(OverflowError) + PRE_INIT(ZeroDivisionError) + PRE_INIT(SystemError) + PRE_INIT(ReferenceError) + PRE_INIT(MemoryError) + PRE_INIT(Warning) + PRE_INIT(UserWarning) + PRE_INIT(DeprecationWarning) + PRE_INIT(PendingDeprecationWarning) + PRE_INIT(SyntaxWarning) + PRE_INIT(OverflowWarning) + PRE_INIT(RuntimeWarning) + PRE_INIT(FutureWarning) + PRE_INIT(ImportWarning) + + m = Py_InitModule("exceptions", functions); + if (m == NULL) return; + + POST_INIT(BaseException) + POST_INIT(Exception) + POST_INIT(StandardError) + POST_INIT(TypeError) + POST_INIT(StopIteration) + POST_INIT(GeneratorExit) + POST_INIT(SystemExit) + POST_INIT(KeyboardInterrupt) + POST_INIT(ImportError) + POST_INIT(EnvironmentError) + POST_INIT(IOError) + POST_INIT(OSError) +#ifdef MS_WINDOWS + POST_INIT(WindowsError) +#endif +#ifdef __VMS + POST_INIT(VMSError) +#endif + POST_INIT(EOFError) + POST_INIT(RuntimeError) + POST_INIT(NotImplementedError) + POST_INIT(NameError) + POST_INIT(UnboundLocalError) + POST_INIT(AttributeError) + POST_INIT(SyntaxError) + POST_INIT(IndentationError) + POST_INIT(TabError) + POST_INIT(LookupError) + POST_INIT(IndexError) + POST_INIT(KeyError) + POST_INIT(ValueError) + POST_INIT(UnicodeError) +#ifdef Py_USING_UNICODE + POST_INIT(UnicodeEncodeError) + POST_INIT(UnicodeDecodeError) + POST_INIT(UnicodeTranslateError) +#endif + POST_INIT(AssertionError) + POST_INIT(ArithmeticError) + POST_INIT(FloatingPointError) + POST_INIT(OverflowError) + POST_INIT(ZeroDivisionError) + POST_INIT(SystemError) + POST_INIT(ReferenceError) + POST_INIT(MemoryError) + POST_INIT(Warning) + POST_INIT(UserWarning) + POST_INIT(DeprecationWarning) + POST_INIT(PendingDeprecationWarning) + POST_INIT(SyntaxWarning) + POST_INIT(OverflowWarning) + POST_INIT(RuntimeWarning) + POST_INIT(FutureWarning) + POST_INIT(ImportWarning) + + PyExc_MemoryErrorInst = PyType_GenericNew(PyExc_MemoryError, NULL, NULL); + if (!PyExc_MemoryErrorInst) + Py_FatalError("Cannot pre-allocate MemoryError instance\n"); + + Py_DECREF(bdict); + Py_DECREF(bltinmod); +} + +void +_PyExc_Fini(void) +{ + Py_XDECREF(PyExc_MemoryErrorInst); + PyExc_MemoryErrorInst = NULL; +} Deleted: /python/branches/sreifschneider-newnewexcept/Python/exceptions.c ============================================================================== --- /python/branches/sreifschneider-newnewexcept/Python/exceptions.c Thu May 25 21:43:03 2006 +++ (empty file) @@ -1,2032 +0,0 @@ -/* This module provides the suite of standard class-based exceptions for - * Python's builtin module. This is a complete C implementation of what, - * in Python 1.5.2, was contained in the exceptions.py module. The problem - * there was that if exceptions.py could not be imported for some reason, - * the entire interpreter would abort. - * - * By moving the exceptions into C and statically linking, we can guarantee - * that the standard exceptions will always be available. - * - * - * written by Fredrik Lundh - * modifications, additions, cleanups, and proofreading by Barry Warsaw - * - * Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. - */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "osdefs.h" - -/* Caution: MS Visual C++ 6 errors if a single string literal exceeds - * 2Kb. So the module docstring has been broken roughly in half, using - * compile-time literal concatenation. - */ - -/* NOTE: If the exception class hierarchy changes, don't forget to update - * Doc/lib/libexcs.tex! - */ - -PyDoc_STRVAR(module__doc__, -"Python's standard exception class hierarchy.\n\ -\n\ -Exceptions found here are defined both in the exceptions module and the \n\ -built-in namespace. It is recommended that user-defined exceptions inherit \n\ -from Exception. See the documentation for the exception inheritance hierarchy.\n\ -" - - /* keep string pieces "small" */ -/* XXX(bcannon): exception hierarchy in Lib/test/exception_hierarchy.txt */ -); - - -/* Helper function for populating a dictionary with method wrappers. */ -static int -populate_methods(PyObject *klass, PyMethodDef *methods) -{ - PyObject *module; - int status = -1; - - if (!methods) - return 0; - - module = PyString_FromString("exceptions"); - if (!module) - return 0; - while (methods->ml_name) { - /* get a wrapper for the built-in function */ - PyObject *func = PyCFunction_NewEx(methods, NULL, module); - PyObject *meth; - - if (!func) - goto status; - - /* turn the function into an unbound method */ - if (!(meth = PyMethod_New(func, NULL, klass))) { - Py_DECREF(func); - goto status; - } - - /* add method to dictionary */ - status = PyObject_SetAttrString(klass, methods->ml_name, meth); - Py_DECREF(meth); - Py_DECREF(func); - - /* stop now if an error occurred, otherwise do the next method */ - if (status) - goto status; - - methods++; - } - status = 0; - status: - Py_DECREF(module); - return status; -} - - - -/* This function is used to create all subsequent exception classes. */ -static int -make_class(PyObject **klass, PyObject *base, - char *name, PyMethodDef *methods, - char *docstr) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (docstr) { - if (!(str = PyString_FromString(docstr))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - } - - if (!(*klass = PyErr_NewException(name, base, dict))) - goto finally; - - if (populate_methods(*klass, methods)) { - Py_DECREF(*klass); - *klass = NULL; - goto finally; - } - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - return status; -} - - -/* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */ -static PyObject * -get_self(PyObject *args) -{ - PyObject *self = PyTuple_GetItem(args, 0); - if (!self) { - /* Watch out for being called to early in the bootstrapping process */ - if (PyExc_TypeError) { - PyErr_SetString(PyExc_TypeError, - "unbound method must be called with instance as first argument"); - } - return NULL; - } - return self; -} - - - -/* Notes on bootstrapping the exception classes. - * - * First thing we create is the base class for all exceptions, called - * appropriately BaseException. Creation of this class makes no - * assumptions about the existence of any other exception class -- except - * for TypeError, which can conditionally exist. - * - * Next, Exception is created since it is the common subclass for the rest of - * the needed exceptions for this bootstrapping to work. StandardError is - * created (which is quite simple) followed by - * TypeError, because the instantiation of other exceptions can potentially - * throw a TypeError. Once these exceptions are created, all the others - * can be created in any order. See the static exctable below for the - * explicit bootstrap order. - * - * All classes after BaseException can be created using PyErr_NewException(). - */ - -PyDoc_STRVAR(BaseException__doc__, "Common base class for all exceptions"); - -/* - Set args and message attributes. - - Assumes self and args have already been set properly with set_self, etc. -*/ -static int -set_args_and_message(PyObject *self, PyObject *args) -{ - PyObject *message_val; - Py_ssize_t args_len = PySequence_Length(args); - - if (args_len < 0) - return 0; - - /* set args */ - if (PyObject_SetAttrString(self, "args", args) < 0) - return 0; - - /* set message */ - if (args_len == 1) - message_val = PySequence_GetItem(args, 0); - else - message_val = PyString_FromString(""); - if (!message_val) - return 0; - - if (PyObject_SetAttrString(self, "message", message_val) < 0) { - Py_DECREF(message_val); - return 0; - } - - Py_DECREF(message_val); - return 1; -} - -static PyObject * -BaseException__init__(PyObject *self, PyObject *args) -{ - if (!(self = get_self(args))) - return NULL; - - /* set args and message attribute */ - args = PySequence_GetSlice(args, 1, PySequence_Length(args)); - if (!args) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - Py_DECREF(args); - Py_RETURN_NONE; -} - - -static PyObject * -BaseException__str__(PyObject *_self, PyObject *self) -{ - PyObject *out, *args; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - switch (PySequence_Size(args)) { - case 0: - out = PyString_FromString(""); - break; - case 1: - { - PyObject *tmp = PySequence_GetItem(args, 0); - if (tmp) { - out = PyObject_Str(tmp); - Py_DECREF(tmp); - } - else - out = NULL; - break; - } - case -1: - PyErr_Clear(); - /* Fall through */ - default: - out = PyObject_Str(args); - break; - } - - Py_DECREF(args); - return out; -} - -#ifdef Py_USING_UNICODE -static PyObject * -BaseException__unicode__(PyObject *self, PyObject *args) -{ - Py_ssize_t args_len; - - if (!PyArg_ParseTuple(args, "O:__unicode__", &self)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - args_len = PySequence_Size(args); - if (args_len < 0) { - Py_DECREF(args); - return NULL; - } - - if (args_len == 0) { - Py_DECREF(args); - return PyUnicode_FromUnicode(NULL, 0); - } - else if (args_len == 1) { - PyObject *temp = PySequence_GetItem(args, 0); - PyObject *unicode_obj; - - if (!temp) { - Py_DECREF(args); - return NULL; - } - Py_DECREF(args); - unicode_obj = PyObject_Unicode(temp); - Py_DECREF(temp); - return unicode_obj; - } - else { - PyObject *unicode_obj = PyObject_Unicode(args); - - Py_DECREF(args); - return unicode_obj; - } -} -#endif /* Py_USING_UNICODE */ - -static PyObject * -BaseException__repr__(PyObject *self, PyObject *args) -{ - PyObject *args_attr; - Py_ssize_t args_len; - PyObject *repr_suffix; - PyObject *repr; - - if (!PyArg_ParseTuple(args, "O:__repr__", &self)) - return NULL; - - args_attr = PyObject_GetAttrString(self, "args"); - if (!args_attr) - return NULL; - - args_len = PySequence_Length(args_attr); - if (args_len < 0) { - Py_DECREF(args_attr); - return NULL; - } - - if (args_len == 0) { - Py_DECREF(args_attr); - repr_suffix = PyString_FromString("()"); - if (!repr_suffix) - return NULL; - } - else { - PyObject *args_repr = PyObject_Repr(args_attr); - Py_DECREF(args_attr); - if (!args_repr) - return NULL; - - repr_suffix = args_repr; - } - - repr = PyString_FromString(self->ob_type->tp_name); - if (!repr) { - Py_DECREF(repr_suffix); - return NULL; - } - - PyString_ConcatAndDel(&repr, repr_suffix); - return repr; -} - -static PyObject * -BaseException__getitem__(PyObject *self, PyObject *args) -{ - PyObject *out; - PyObject *index; - - if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - out = PyObject_GetItem(args, index); - Py_DECREF(args); - return out; -} - - -static PyMethodDef -BaseException_methods[] = { - /* methods for the BaseException class */ - {"__getitem__", BaseException__getitem__, METH_VARARGS}, - {"__repr__", BaseException__repr__, METH_VARARGS}, - {"__str__", BaseException__str__, METH_O}, -#ifdef Py_USING_UNICODE - {"__unicode__", BaseException__unicode__, METH_VARARGS}, -#endif /* Py_USING_UNICODE */ - {"__init__", BaseException__init__, METH_VARARGS}, - {NULL, NULL } -}; - - -static int -make_BaseException(char *modulename) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - PyObject *name = NULL; - PyObject *emptytuple = NULL; - PyObject *argstuple = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (!(str = PyString_FromString(modulename))) - goto finally; - if (PyDict_SetItemString(dict, "__module__", str)) - goto finally; - Py_DECREF(str); - - if (!(str = PyString_FromString(BaseException__doc__))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - - if (!(name = PyString_FromString("BaseException"))) - goto finally; - - if (!(emptytuple = PyTuple_New(0))) - goto finally; - - if (!(argstuple = PyTuple_Pack(3, name, emptytuple, dict))) - goto finally; - - if (!(PyExc_BaseException = PyType_Type.tp_new(&PyType_Type, argstuple, - NULL))) - goto finally; - - /* Now populate the dictionary with the method suite */ - if (populate_methods(PyExc_BaseException, BaseException_methods)) - /* Don't need to reclaim PyExc_BaseException here because that'll - * happen during interpreter shutdown. - */ - goto finally; - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - Py_XDECREF(name); - Py_XDECREF(emptytuple); - Py_XDECREF(argstuple); - return status; -} - - - -PyDoc_STRVAR(Exception__doc__, "Common base class for all non-exit exceptions."); - -PyDoc_STRVAR(StandardError__doc__, -"Base class for all standard Python exceptions that do not represent" -"interpreter exiting."); - -PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type."); - -PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); -PyDoc_STRVAR(GeneratorExit__doc__, "Request that a generator exit."); - - - -PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); - - -static PyObject * -SystemExit__init__(PyObject *self, PyObject *args) -{ - PyObject *code; - int status; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - /* set code attribute */ - switch (PySequence_Size(args)) { - case 0: - Py_INCREF(Py_None); - code = Py_None; - break; - case 1: - code = PySequence_GetItem(args, 0); - break; - case -1: - PyErr_Clear(); - /* Fall through */ - default: - Py_INCREF(args); - code = args; - break; - } - - status = PyObject_SetAttrString(self, "code", code); - Py_DECREF(code); - Py_DECREF(args); - if (status < 0) - return NULL; - - Py_RETURN_NONE; -} - - -static PyMethodDef SystemExit_methods[] = { - { "__init__", SystemExit__init__, METH_VARARGS}, - {NULL, NULL} -}; - - - -PyDoc_STRVAR(KeyboardInterrupt__doc__, "Program interrupted by user."); - -PyDoc_STRVAR(ImportError__doc__, -"Import can't find module, or can't find name in module."); - - - -PyDoc_STRVAR(EnvironmentError__doc__, "Base class for I/O related errors."); - - -static PyObject * -EnvironmentError__init__(PyObject *self, PyObject *args) -{ - PyObject *item0 = NULL; - PyObject *item1 = NULL; - PyObject *item2 = NULL; - PyObject *subslice = NULL; - PyObject *rtnval = NULL; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (PyObject_SetAttrString(self, "errno", Py_None) || - PyObject_SetAttrString(self, "strerror", Py_None) || - PyObject_SetAttrString(self, "filename", Py_None)) - { - goto finally; - } - - switch (PySequence_Size(args)) { - case 3: - /* Where a function has a single filename, such as open() or some - * of the os module functions, PyErr_SetFromErrnoWithFilename() is - * called, giving a third argument which is the filename. But, so - * that old code using in-place unpacking doesn't break, e.g.: - * - * except IOError, (errno, strerror): - * - * we hack args so that it only contains two items. This also - * means we need our own __str__() which prints out the filename - * when it was supplied. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - item2 = PySequence_GetItem(args, 2); - if (!item0 || !item1 || !item2) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1) || - PyObject_SetAttrString(self, "filename", item2)) - { - goto finally; - } - - subslice = PySequence_GetSlice(args, 0, 2); - if (!subslice || PyObject_SetAttrString(self, "args", subslice)) - goto finally; - break; - - case 2: - /* Used when PyErr_SetFromErrno() is called and no filename - * argument is given. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - if (!item0 || !item1) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1)) - { - goto finally; - } - break; - - case -1: - PyErr_Clear(); - break; - } - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - Py_XDECREF(item0); - Py_XDECREF(item1); - Py_XDECREF(item2); - Py_XDECREF(subslice); - return rtnval; -} - - -static PyObject * -EnvironmentError__str__(PyObject *originalself, PyObject *self) -{ - PyObject *filename; - PyObject *serrno; - PyObject *strerror; - PyObject *rtnval = NULL; - - filename = PyObject_GetAttrString(self, "filename"); - serrno = PyObject_GetAttrString(self, "errno"); - strerror = PyObject_GetAttrString(self, "strerror"); - if (!filename || !serrno || !strerror) - goto finally; - - if (filename != Py_None) { - PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); - PyObject *repr = PyObject_Repr(filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - PyTuple_SET_ITEM(tuple, 2, repr); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - PyObject *fmt = PyString_FromString("[Errno %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else - /* The original Python code said: - * - * return StandardError.__str__(self) - * - * but there is no StandardError__str__() function; we happen to - * know that's just a pass through to BaseException__str__(). - */ - rtnval = BaseException__str__(originalself, self); - - finally: - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); - return rtnval; -} - - -static -PyMethodDef EnvironmentError_methods[] = { - {"__init__", EnvironmentError__init__, METH_VARARGS}, - {"__str__", EnvironmentError__str__, METH_O}, - {NULL, NULL} -}; - -PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); - -PyDoc_STRVAR(OSError__doc__, "OS system call failed."); - -#ifdef MS_WINDOWS -#include "errmap.h" - -PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); - -static PyObject * -WindowsError__init__(PyObject *self, PyObject *args) -{ - PyObject *o_errcode, *result; - long errcode, posix_errno; - result = EnvironmentError__init__(self, args); - if (!result) - return NULL; - self = get_self(args); - if (!self) - goto failed; - /* Set errno to the POSIX errno, and winerror to the Win32 - error code. */ - o_errcode = PyObject_GetAttrString(self, "errno"); - if (!o_errcode) - goto failed; - errcode = PyInt_AsLong(o_errcode); - if (!errcode == -1 && PyErr_Occurred()) - goto failed; - posix_errno = winerror_to_errno(errcode); - if (PyObject_SetAttrString(self, "winerror", o_errcode) < 0) - goto failed; - Py_DECREF(o_errcode); - o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) - goto failed; - if (PyObject_SetAttrString(self, "errno", o_errcode) < 0) - goto failed; - Py_DECREF(o_errcode); - return result; -failed: - /* Could not set errno. */ - Py_XDECREF(o_errcode); - Py_DECREF(result); - return NULL; -} - -static PyObject * -WindowsError__str__(PyObject *originalself, PyObject *self) -{ - PyObject *filename; - PyObject *serrno; - PyObject *strerror; - PyObject *repr = NULL; - PyObject *fmt = NULL; - PyObject *tuple = NULL; - PyObject *rtnval = NULL; - - filename = PyObject_GetAttrString(self, "filename"); - serrno = PyObject_GetAttrString(self, "winerror"); - strerror = PyObject_GetAttrString(self, "strerror"); - if (!filename || !serrno || !strerror) - goto finally; - - if (filename != Py_None) { - fmt = PyString_FromString("[Error %s] %s: %s"); - repr = PyObject_Repr(filename); - if (!fmt || !repr) - goto finally; - - - tuple = PyTuple_Pack(3, serrno, strerror, repr); - if (!tuple) - goto finally; - - rtnval = PyString_Format(fmt, tuple); - } - else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - fmt = PyString_FromString("[Error %s] %s"); - if (!fmt) - goto finally; - - tuple = PyTuple_Pack(2, serrno, strerror); - if (!tuple) - goto finally; - - rtnval = PyString_Format(fmt, tuple); - } - else - rtnval = EnvironmentError__str__(originalself, self); - - finally: - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); - Py_XDECREF(repr); - Py_XDECREF(fmt); - Py_XDECREF(tuple); - return rtnval; -} - -static -PyMethodDef WindowsError_methods[] = { - {"__init__", WindowsError__init__, METH_VARARGS}, - {"__str__", WindowsError__str__, METH_O}, - {NULL, NULL} -}; -#endif /* MS_WINDOWS */ - -#ifdef __VMS -static char -VMSError__doc__[] = "OpenVMS OS system call failed."; -#endif - -PyDoc_STRVAR(EOFError__doc__, "Read beyond end of file."); - -PyDoc_STRVAR(RuntimeError__doc__, "Unspecified run-time error."); - -PyDoc_STRVAR(NotImplementedError__doc__, -"Method or function hasn't been implemented yet."); - -PyDoc_STRVAR(NameError__doc__, "Name not found globally."); - -PyDoc_STRVAR(UnboundLocalError__doc__, -"Local name referenced but not bound to a value."); - -PyDoc_STRVAR(AttributeError__doc__, "Attribute not found."); - - - -PyDoc_STRVAR(SyntaxError__doc__, "Invalid syntax."); - - -static int -SyntaxError__classinit__(PyObject *klass) -{ - int retval = 0; - PyObject *emptystring = PyString_FromString(""); - - /* Additional class-creation time initializations */ - if (!emptystring || - PyObject_SetAttrString(klass, "msg", emptystring) || - PyObject_SetAttrString(klass, "filename", Py_None) || - PyObject_SetAttrString(klass, "lineno", Py_None) || - PyObject_SetAttrString(klass, "offset", Py_None) || - PyObject_SetAttrString(klass, "text", Py_None) || - PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) - { - retval = -1; - } - Py_XDECREF(emptystring); - return retval; -} - - -static PyObject * -SyntaxError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - Py_ssize_t lenargs; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - lenargs = PySequence_Size(args); - if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - int status; - - if (!item0) - goto finally; - status = PyObject_SetAttrString(self, "msg", item0); - Py_DECREF(item0); - if (status) - goto finally; - } - if (lenargs == 2) { - PyObject *info = PySequence_GetItem(args, 1); - PyObject *filename = NULL, *lineno = NULL; - PyObject *offset = NULL, *text = NULL; - int status = 1; - - if (!info) - goto finally; - - filename = PySequence_GetItem(info, 0); - if (filename != NULL) { - lineno = PySequence_GetItem(info, 1); - if (lineno != NULL) { - offset = PySequence_GetItem(info, 2); - if (offset != NULL) { - text = PySequence_GetItem(info, 3); - if (text != NULL) { - status = - PyObject_SetAttrString(self, "filename", filename) - || PyObject_SetAttrString(self, "lineno", lineno) - || PyObject_SetAttrString(self, "offset", offset) - || PyObject_SetAttrString(self, "text", text); - Py_DECREF(text); - } - Py_DECREF(offset); - } - Py_DECREF(lineno); - } - Py_DECREF(filename); - } - Py_DECREF(info); - - if (status) - goto finally; - } - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -/* This is called "my_basename" instead of just "basename" to avoid name - conflicts with glibc; basename is already prototyped if _GNU_SOURCE is - defined, and Python does define that. */ -static char * -my_basename(char *name) -{ - char *cp = name; - char *result = name; - - if (name == NULL) - return "???"; - while (*cp != '\0') { - if (*cp == SEP) - result = cp + 1; - ++cp; - } - return result; -} - - -static PyObject * -SyntaxError__str__(PyObject *_self, PyObject *self) -{ - PyObject *msg; - PyObject *str; - PyObject *filename, *lineno, *result; - - if (!(msg = PyObject_GetAttrString(self, "msg"))) - return NULL; - - str = PyObject_Str(msg); - Py_DECREF(msg); - result = str; - - /* XXX -- do all the additional formatting with filename and - lineno here */ - - if (str != NULL && PyString_Check(str)) { - int have_filename = 0; - int have_lineno = 0; - char *buffer = NULL; - - if ((filename = PyObject_GetAttrString(self, "filename")) != NULL) - have_filename = PyString_Check(filename); - else - PyErr_Clear(); - - if ((lineno = PyObject_GetAttrString(self, "lineno")) != NULL) - have_lineno = PyInt_Check(lineno); - else - PyErr_Clear(); - - if (have_filename || have_lineno) { - Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; - if (have_filename) - bufsize += PyString_GET_SIZE(filename); - - buffer = (char *)PyMem_MALLOC(bufsize); - if (buffer != NULL) { - if (have_filename && have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename)), - PyInt_AsLong(lineno)); - else if (have_filename) - PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename))); - else if (have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(lineno)); - - result = PyString_FromString(buffer); - PyMem_FREE(buffer); - - if (result == NULL) - result = str; - else - Py_DECREF(str); - } - } - Py_XDECREF(filename); - Py_XDECREF(lineno); - } - return result; -} - - -static PyMethodDef SyntaxError_methods[] = { - {"__init__", SyntaxError__init__, METH_VARARGS}, - {"__str__", SyntaxError__str__, METH_O}, - {NULL, NULL} -}; - - -static PyObject * -KeyError__str__(PyObject *_self, PyObject *self) -{ - PyObject *argsattr; - PyObject *result; - - argsattr = PyObject_GetAttrString(self, "args"); - if (!argsattr) - return NULL; - - /* If args is a tuple of exactly one item, apply repr to args[0]. - This is done so that e.g. the exception raised by {}[''] prints - KeyError: '' - rather than the confusing - KeyError - alone. The downside is that if KeyError is raised with an explanatory - string, that string will be displayed in quotes. Too bad. - If args is anything else, use the default BaseException__str__(). - */ - if (PyTuple_Check(argsattr) && PyTuple_GET_SIZE(argsattr) == 1) { - PyObject *key = PyTuple_GET_ITEM(argsattr, 0); - result = PyObject_Repr(key); - } - else - result = BaseException__str__(_self, self); - - Py_DECREF(argsattr); - return result; -} - -static PyMethodDef KeyError_methods[] = { - {"__str__", KeyError__str__, METH_O}, - {NULL, NULL} -}; - - -#ifdef Py_USING_UNICODE -static -int get_int(PyObject *exc, const char *name, Py_ssize_t *value) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return -1; - if (PyInt_Check(attr)) { - *value = PyInt_AS_LONG(attr); - } else if (PyLong_Check(attr)) { - *value = (size_t)PyLong_AsLongLong(attr); - if (*value == -1) { - Py_DECREF(attr); - return -1; - } - } else { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - Py_DECREF(attr); - return -1; - } - Py_DECREF(attr); - return 0; -} - - -static -int set_ssize_t(PyObject *exc, const char *name, Py_ssize_t value) -{ - PyObject *obj = PyInt_FromSsize_t(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - -static -PyObject *get_string(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyString_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - - -static -int set_string(PyObject *exc, const char *name, const char *value) -{ - PyObject *obj = PyString_FromString(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - - -static -PyObject *get_unicode(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyUnicode_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - -PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) -{ - return get_string(exc, "object"); -} - -PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*start<0) - *start = 0; /*XXX check for values <0*/ - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - return PyUnicodeEncodeError_GetStart(exc, start); -} - - -int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) -{ - return PyUnicodeEncodeError_GetEnd(exc, start); -} - - -int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -static PyObject * -UnicodeError__init__(PyObject *self, PyObject *args, PyTypeObject *objecttype) -{ - PyObject *rtnval = NULL; - PyObject *encoding; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &encoding, - objecttype, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "encoding", encoding)) - goto finally; - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeEncodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyUnicode_Type); -} - -static PyObject * -UnicodeEncodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeEncodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeEncodeError_GetObject(self))) - goto error; - - if (PyUnicodeEncodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeEncodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeEncodeError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - result = PyString_FromFormat( - "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(encodingObj), - badchar_str, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", - PyString_AS_STRING(encodingObj), - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeEncodeError_methods[] = { - {"__init__", UnicodeEncodeError__init__, METH_VARARGS}, - {"__str__", UnicodeEncodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeEncodeError_Create( - const char *encoding, const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeDecodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyString_Type); -} - -static PyObject * -UnicodeDecodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeDecodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeDecodeError_GetObject(self))) - goto error; - - if (PyUnicodeDecodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeDecodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeDecodeError_GetReason(self))) - goto error; - - if (end==start+1) { - /* FromFormat does not support %02x, so format that separately */ - char byte[4]; - PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(objectObj)[start])&0xff); - result = PyString_FromFormat( - "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(encodingObj), - byte, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", - PyString_AS_STRING(encodingObj), - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeDecodeError_methods[] = { - {"__init__", UnicodeDecodeError__init__, METH_VARARGS}, - {"__str__", UnicodeDecodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeDecodeError_Create( - const char *encoding, const char *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - assert(length < INT_MAX); - assert(start < INT_MAX); - assert(end < INT_MAX); - return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeTranslateError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - rtnval = Py_None; - Py_INCREF(rtnval); - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeTranslateError__str__(PyObject *self, PyObject *arg) -{ - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(objectObj = PyUnicodeTranslateError_GetObject(self))) - goto error; - - if (PyUnicodeTranslateError_GetStart(self, &start)) - goto error; - - if (PyUnicodeTranslateError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeTranslateError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - result = PyString_FromFormat( - "can't translate character u'\\%s' in position %zd: %.400s", - badchar_str, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "can't translate characters in position %zd-%zd: %.400s", - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - return result; -} - -static PyMethodDef UnicodeTranslateError_methods[] = { - {"__init__", UnicodeTranslateError__init__, METH_VARARGS}, - {"__str__", UnicodeTranslateError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeTranslateError_Create( - const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", - object, length, start, end, reason); -} -#endif - - - -/* Exception doc strings */ - -PyDoc_STRVAR(AssertionError__doc__, "Assertion failed."); - -PyDoc_STRVAR(LookupError__doc__, "Base class for lookup errors."); - -PyDoc_STRVAR(IndexError__doc__, "Sequence index out of range."); - -PyDoc_STRVAR(KeyError__doc__, "Mapping key not found."); - -PyDoc_STRVAR(ArithmeticError__doc__, "Base class for arithmetic errors."); - -PyDoc_STRVAR(OverflowError__doc__, "Result too large to be represented."); - -PyDoc_STRVAR(ZeroDivisionError__doc__, -"Second argument to a division or modulo operation was zero."); - -PyDoc_STRVAR(FloatingPointError__doc__, "Floating point operation failed."); - -PyDoc_STRVAR(ValueError__doc__, -"Inappropriate argument value (of correct type)."); - -PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error."); - -#ifdef Py_USING_UNICODE -PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error."); - -PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error."); - -PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error."); -#endif - -PyDoc_STRVAR(SystemError__doc__, -"Internal error in the Python interpreter.\n\ -\n\ -Please report this to the Python maintainer, along with the traceback,\n\ -the Python version, and the hardware/OS platform and version."); - -PyDoc_STRVAR(ReferenceError__doc__, -"Weak ref proxy used after referent went away."); - -PyDoc_STRVAR(MemoryError__doc__, "Out of memory."); - -PyDoc_STRVAR(IndentationError__doc__, "Improper indentation."); - -PyDoc_STRVAR(TabError__doc__, "Improper mixture of spaces and tabs."); - -/* Warning category docstrings */ - -PyDoc_STRVAR(Warning__doc__, "Base class for warning categories."); - -PyDoc_STRVAR(UserWarning__doc__, -"Base class for warnings generated by user code."); - -PyDoc_STRVAR(DeprecationWarning__doc__, -"Base class for warnings about deprecated features."); - -PyDoc_STRVAR(PendingDeprecationWarning__doc__, -"Base class for warnings about features which will be deprecated " -"in the future."); - -PyDoc_STRVAR(SyntaxWarning__doc__, -"Base class for warnings about dubious syntax."); - -PyDoc_STRVAR(OverflowWarning__doc__, -"Base class for warnings about numeric overflow. Won't exist in Python 2.5."); - -PyDoc_STRVAR(RuntimeWarning__doc__, -"Base class for warnings about dubious runtime behavior."); - -PyDoc_STRVAR(FutureWarning__doc__, -"Base class for warnings about constructs that will change semantically " -"in the future."); - -PyDoc_STRVAR(ImportWarning__doc__, -"Base class for warnings about probable mistakes in module imports"); - - -/* module global functions */ -static PyMethodDef functions[] = { - /* Sentinel */ - {NULL, NULL} -}; - - - -/* Global C API defined exceptions */ - -PyObject *PyExc_BaseException; -PyObject *PyExc_Exception; -PyObject *PyExc_StopIteration; -PyObject *PyExc_GeneratorExit; -PyObject *PyExc_StandardError; -PyObject *PyExc_ArithmeticError; -PyObject *PyExc_LookupError; - -PyObject *PyExc_AssertionError; -PyObject *PyExc_AttributeError; -PyObject *PyExc_EOFError; -PyObject *PyExc_FloatingPointError; -PyObject *PyExc_EnvironmentError; -PyObject *PyExc_IOError; -PyObject *PyExc_OSError; -PyObject *PyExc_ImportError; -PyObject *PyExc_IndexError; -PyObject *PyExc_KeyError; -PyObject *PyExc_KeyboardInterrupt; -PyObject *PyExc_MemoryError; -PyObject *PyExc_NameError; -PyObject *PyExc_OverflowError; -PyObject *PyExc_RuntimeError; -PyObject *PyExc_NotImplementedError; -PyObject *PyExc_SyntaxError; -PyObject *PyExc_IndentationError; -PyObject *PyExc_TabError; -PyObject *PyExc_ReferenceError; -PyObject *PyExc_SystemError; -PyObject *PyExc_SystemExit; -PyObject *PyExc_UnboundLocalError; -PyObject *PyExc_UnicodeError; -PyObject *PyExc_UnicodeEncodeError; -PyObject *PyExc_UnicodeDecodeError; -PyObject *PyExc_UnicodeTranslateError; -PyObject *PyExc_TypeError; -PyObject *PyExc_ValueError; -PyObject *PyExc_ZeroDivisionError; -#ifdef MS_WINDOWS -PyObject *PyExc_WindowsError; -#endif -#ifdef __VMS -PyObject *PyExc_VMSError; -#endif - -/* Pre-computed MemoryError instance. Best to create this as early as - * possible and not wait until a MemoryError is actually raised! - */ -PyObject *PyExc_MemoryErrorInst; - -/* Predefined warning categories */ -PyObject *PyExc_Warning; -PyObject *PyExc_UserWarning; -PyObject *PyExc_DeprecationWarning; -PyObject *PyExc_PendingDeprecationWarning; -PyObject *PyExc_SyntaxWarning; -/* PyExc_OverflowWarning should be removed for Python 2.5 */ -PyObject *PyExc_OverflowWarning; -PyObject *PyExc_RuntimeWarning; -PyObject *PyExc_FutureWarning; -PyObject *PyExc_ImportWarning; - - - -/* mapping between exception names and their PyObject ** */ -static struct { - char *name; - PyObject **exc; - PyObject **base; /* NULL == PyExc_StandardError */ - char *docstr; - PyMethodDef *methods; - int (*classinit)(PyObject *); -} exctable[] = { - /* - * The first four classes MUST appear in exactly this order - */ - {"BaseException", &PyExc_BaseException}, - {"Exception", &PyExc_Exception, &PyExc_BaseException, Exception__doc__}, - {"StopIteration", &PyExc_StopIteration, &PyExc_Exception, - StopIteration__doc__}, - {"GeneratorExit", &PyExc_GeneratorExit, &PyExc_Exception, - GeneratorExit__doc__}, - {"StandardError", &PyExc_StandardError, &PyExc_Exception, - StandardError__doc__}, - {"TypeError", &PyExc_TypeError, 0, TypeError__doc__}, - /* - * The rest appear in depth-first order of the hierarchy - */ - {"SystemExit", &PyExc_SystemExit, &PyExc_BaseException, SystemExit__doc__, - SystemExit_methods}, - {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, &PyExc_BaseException, - KeyboardInterrupt__doc__}, - {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, - {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, - EnvironmentError_methods}, - {"IOError", &PyExc_IOError, &PyExc_EnvironmentError, IOError__doc__}, - {"OSError", &PyExc_OSError, &PyExc_EnvironmentError, OSError__doc__}, -#ifdef MS_WINDOWS - {"WindowsError", &PyExc_WindowsError, &PyExc_OSError, -WindowsError__doc__, WindowsError_methods}, -#endif /* MS_WINDOWS */ -#ifdef __VMS - {"VMSError", &PyExc_VMSError, &PyExc_OSError, - VMSError__doc__}, -#endif - {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, - {"RuntimeError", &PyExc_RuntimeError, 0, RuntimeError__doc__}, - {"NotImplementedError", &PyExc_NotImplementedError, - &PyExc_RuntimeError, NotImplementedError__doc__}, - {"NameError", &PyExc_NameError, 0, NameError__doc__}, - {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, - UnboundLocalError__doc__}, - {"AttributeError", &PyExc_AttributeError, 0, AttributeError__doc__}, - {"SyntaxError", &PyExc_SyntaxError, 0, SyntaxError__doc__, - SyntaxError_methods, SyntaxError__classinit__}, - {"IndentationError", &PyExc_IndentationError, &PyExc_SyntaxError, - IndentationError__doc__}, - {"TabError", &PyExc_TabError, &PyExc_IndentationError, - TabError__doc__}, - {"AssertionError", &PyExc_AssertionError, 0, AssertionError__doc__}, - {"LookupError", &PyExc_LookupError, 0, LookupError__doc__}, - {"IndexError", &PyExc_IndexError, &PyExc_LookupError, - IndexError__doc__}, - {"KeyError", &PyExc_KeyError, &PyExc_LookupError, - KeyError__doc__, KeyError_methods}, - {"ArithmeticError", &PyExc_ArithmeticError, 0, ArithmeticError__doc__}, - {"OverflowError", &PyExc_OverflowError, &PyExc_ArithmeticError, - OverflowError__doc__}, - {"ZeroDivisionError", &PyExc_ZeroDivisionError, &PyExc_ArithmeticError, - ZeroDivisionError__doc__}, - {"FloatingPointError", &PyExc_FloatingPointError, &PyExc_ArithmeticError, - FloatingPointError__doc__}, - {"ValueError", &PyExc_ValueError, 0, ValueError__doc__}, - {"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__}, -#ifdef Py_USING_UNICODE - {"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError, - UnicodeEncodeError__doc__, UnicodeEncodeError_methods}, - {"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError, - UnicodeDecodeError__doc__, UnicodeDecodeError_methods}, - {"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError, - UnicodeTranslateError__doc__, UnicodeTranslateError_methods}, -#endif - {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, - {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, - {"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__}, - /* Warning categories */ - {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, - {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, - {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning, - DeprecationWarning__doc__}, - {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning, - PendingDeprecationWarning__doc__}, - {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, - /* OverflowWarning should be removed for Python 2.5 */ - {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, - OverflowWarning__doc__}, - {"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning, - RuntimeWarning__doc__}, - {"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning, - FutureWarning__doc__}, - {"ImportWarning", &PyExc_ImportWarning, &PyExc_Warning, - ImportWarning__doc__}, - /* Sentinel */ - {NULL} -}; - - - -void -_PyExc_Init(void) -{ - char *modulename = "exceptions"; - Py_ssize_t modnamesz = strlen(modulename); - int i; - PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args; - - me = Py_InitModule(modulename, functions); - if (me == NULL) - goto err; - mydict = PyModule_GetDict(me); - if (mydict == NULL) - goto err; - bltinmod = PyImport_ImportModule("__builtin__"); - if (bltinmod == NULL) - goto err; - bdict = PyModule_GetDict(bltinmod); - if (bdict == NULL) - goto err; - doc = PyString_FromString(module__doc__); - if (doc == NULL) - goto err; - - i = PyDict_SetItemString(mydict, "__doc__", doc); - Py_DECREF(doc); - if (i < 0) { - err: - Py_FatalError("exceptions bootstrapping error."); - return; - } - - /* This is the base class of all exceptions, so make it first. */ - if (make_BaseException(modulename) || - PyDict_SetItemString(mydict, "BaseException", PyExc_BaseException) || - PyDict_SetItemString(bdict, "BaseException", PyExc_BaseException)) - { - Py_FatalError("Base class `BaseException' could not be created."); - } - - /* Now we can programmatically create all the remaining exceptions. - * Remember to start the loop at 1 to skip Exceptions. - */ - for (i=1; exctable[i].name; i++) { - int status; - char *cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2); - PyObject *base; - - (void)strcpy(cname, modulename); - (void)strcat(cname, "."); - (void)strcat(cname, exctable[i].name); - - if (exctable[i].base == 0) - base = PyExc_StandardError; - else - base = *exctable[i].base; - - status = make_class(exctable[i].exc, base, cname, - exctable[i].methods, - exctable[i].docstr); - - PyMem_DEL(cname); - - if (status) - Py_FatalError("Standard exception classes could not be created."); - - if (exctable[i].classinit) { - status = (*exctable[i].classinit)(*exctable[i].exc); - if (status) - Py_FatalError("An exception class could not be initialized."); - } - - /* Now insert the class into both this module and the __builtin__ - * module. - */ - if (PyDict_SetItemString(mydict, exctable[i].name, *exctable[i].exc) || - PyDict_SetItemString(bdict, exctable[i].name, *exctable[i].exc)) - { - Py_FatalError("Module dictionary insertion problem."); - } - } - - /* Now we need to pre-allocate a MemoryError instance */ - args = PyTuple_New(0); - if (!args || - !(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args))) - { - Py_FatalError("Cannot pre-allocate MemoryError instance\n"); - } - Py_DECREF(args); - - /* We're done with __builtin__ */ - Py_DECREF(bltinmod); -} - - -void -_PyExc_Fini(void) -{ - int i; - - Py_XDECREF(PyExc_MemoryErrorInst); - PyExc_MemoryErrorInst = NULL; - - for (i=0; exctable[i].name; i++) { - /* clear the class's dictionary, freeing up circular references - * between the class and its methods. - */ - PyObject* cdict = PyObject_GetAttrString(*exctable[i].exc, "__dict__"); - PyDict_Clear(cdict); - Py_DECREF(cdict); - - /* Now decref the exception class */ - Py_XDECREF(*exctable[i].exc); - *exctable[i].exc = NULL; - } -} From buildbot at python.org Thu May 25 21:43:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 19:43:50 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060525194350.313421E400B@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/779 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,georg.brandl,jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 21:56:57 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 21:56:57 +0200 (CEST) Subject: [Python-checkins] r46248 - python/trunk/Modules/_struct.c Message-ID: <20060525195657.22E211E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 21:56:56 2006 New Revision: 46248 Modified: python/trunk/Modules/_struct.c Log: Use faster struct pack/unpack functions for the endian table that matches the host's Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 21:56:56 2006 @@ -572,13 +572,13 @@ {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, #ifdef HAVE_LONG_LONG {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, #endif + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, {0} }; @@ -1477,6 +1477,30 @@ if (PyType_Ready(&PyStructType) < 0) return; + /* Check endian and swap in faster functions */ + { + int one = 1; + formatdef *native = native_table; + formatdef *other, *ptr; + if ((int)*(unsigned char*)&one) + other = lilendian_table; + else + other = bigendian_table; + while (native->format != '\0' && other->format != '\0') { + ptr = other; + while (ptr->format != '\0') { + if (ptr->format == native->format) { + ptr->pack = native->pack; + ptr->unpack = native->unpack; + if (ptr == other) + other++; + break; + } + ptr++; + } + native++; + } + } /* Add some symbolic constants to the module */ if (StructError == NULL) { From python-checkins at python.org Thu May 25 21:59:58 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 21:59:58 +0200 (CEST) Subject: [Python-checkins] r46249 - in python/trunk/Modules/_ctypes/libffi: configure configure.ac fficonfig.h.in fficonfig.py.in src/powerpc/darwin.S src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c src/prep_cif.c src/x86/ffitarget.h Message-ID: <20060525195958.1ADF71E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 21:59:56 2006 New Revision: 46249 Modified: python/trunk/Modules/_ctypes/libffi/configure python/trunk/Modules/_ctypes/libffi/configure.ac python/trunk/Modules/_ctypes/libffi/fficonfig.h.in python/trunk/Modules/_ctypes/libffi/fficonfig.py.in python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin.S python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S python/trunk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c python/trunk/Modules/_ctypes/libffi/src/prep_cif.c python/trunk/Modules/_ctypes/libffi/src/x86/ffitarget.h Log: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) Modified: python/trunk/Modules/_ctypes/libffi/configure ============================================================================== --- python/trunk/Modules/_ctypes/libffi/configure (original) +++ python/trunk/Modules/_ctypes/libffi/configure Thu May 25 21:59:56 2006 @@ -3483,6 +3483,7 @@ TARGETDIR="unknown" case "$host" in +i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; i*86-*-solaris2.1[0-9]*) TARGET=X86_64; TARGETDIR=x86;; @@ -5243,6 +5244,9 @@ esac + + + if test x$TARGET = xSPARC; then echo "$as_me:$LINENO: checking assembler and linker support unaligned pc related relocs" >&5 echo $ECHO_N "checking assembler and linker support unaligned pc related relocs... $ECHO_C" >&6 @@ -5470,7 +5474,15 @@ ac_config_commands="$ac_config_commands src" - ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h" +TARGETINCDIR=$TARGETDIR +case $host in +*-*-darwin*) + TARGETINCDIR="darwin" + ;; +esac + + + ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" @@ -6017,7 +6029,7 @@ # Handling of arguments. "include/ffi.h" ) CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; "fficonfig.py" ) CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; - "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;; + "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ;; "include/ffi_common.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; "include" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; "src" ) CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;; Modified: python/trunk/Modules/_ctypes/libffi/configure.ac ============================================================================== --- python/trunk/Modules/_ctypes/libffi/configure.ac (original) +++ python/trunk/Modules/_ctypes/libffi/configure.ac Thu May 25 21:59:56 2006 @@ -21,6 +21,7 @@ TARGETDIR="unknown" case "$host" in +i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; i*86-*-solaris2.1[[0-9]]*) TARGET=X86_64; TARGETDIR=x86;; @@ -99,6 +100,24 @@ AC_SUBST(HAVE_LONG_DOUBLE) AC_C_BIGENDIAN +AH_VERBATIM([WORDS_BIGENDIAN], +[ +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). + + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. +*/ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else +#ifndef __LITTLE_ENDIAN__ +#undef WORDS_BIGENDIAN +#endif +#endif]) + if test x$TARGET = xSPARC; then AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs], @@ -201,7 +220,15 @@ test -d src/$TARGETDIR || mkdir src/$TARGETDIR ], [TARGETDIR="$TARGETDIR"]) -AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) +TARGETINCDIR=$TARGETDIR +case $host in +*-*-darwin*) + TARGETINCDIR="darwin" + ;; +esac + + +AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h) AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h) AC_CONFIG_FILES(include/ffi.h fficonfig.py) Modified: python/trunk/Modules/_ctypes/libffi/fficonfig.h.in ============================================================================== --- python/trunk/Modules/_ctypes/libffi/fficonfig.h.in (original) +++ python/trunk/Modules/_ctypes/libffi/fficonfig.h.in Thu May 25 21:59:56 2006 @@ -114,9 +114,22 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS + /* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ + first (like Motorola and SPARC, unlike Intel and VAX). + + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. +*/ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else +#ifndef __LITTLE_ENDIAN__ #undef WORDS_BIGENDIAN +#endif +#endif #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE Modified: python/trunk/Modules/_ctypes/libffi/fficonfig.py.in ============================================================================== --- python/trunk/Modules/_ctypes/libffi/fficonfig.py.in (original) +++ python/trunk/Modules/_ctypes/libffi/fficonfig.py.in Thu May 25 21:59:56 2006 @@ -6,6 +6,7 @@ 'MIPS_IRIX': ['src/mips/ffi.c', 'src/mips/o32.S', 'src/mips/n32.S'], 'MIPS_LINUX': ['src/mips/ffi.c', 'src/mips/o32.S'], 'X86': ['src/x86/ffi.c', 'src/x86/sysv.S'], + 'X86_DARWIN': ['src/x86/ffi_darwin.c', 'src/x86/darwin.S'], 'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'], 'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'], 'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'], @@ -26,6 +27,17 @@ 'PA': ['src/pa/linux.S', 'src/pa/ffi.c'], } +# Build all darwin related files on all supported darwin architectures, this +# makes it easier to build universal binaries. +if 0: + all_darwin = ('X86_DARWIN', 'POWERPC_DARWIN') + all_darwin_files = [] + for pn in all_darwin: + all_darwin_files.extend(ffi_platforms[pn]) + for pn in all_darwin: + ffi_platforms[pn] = all_darwin_files + del all_darwin, all_darwin_files, pn + ffi_srcdir = '@srcdir@' ffi_sources += ffi_platforms['@MKTARGET@'] ffi_sources = [os.path.join('@srcdir@', f) for f in ffi_sources] Modified: python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin.S ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin.S (original) +++ python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin.S Thu May 25 21:59:56 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 2000 John Hornkvist Copyright (c) 2004 Free Software Foundation, Inc. @@ -243,3 +244,4 @@ .align LOG2_GPR_BYTES LLFB0$non_lazy_ptr: .g_long LFB0 +#endif Modified: python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S (original) +++ python/trunk/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S Thu May 25 21:59:56 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- darwin_closure.S - Copyright (c) 2002, 2003, 2004, Free Software Foundation, Inc. based on ppc_closure.S @@ -315,3 +316,4 @@ .align LOG2_GPR_BYTES LLFB1$non_lazy_ptr: .g_long LFB1 +#endif Modified: python/trunk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c (original) +++ python/trunk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Thu May 25 21:59:56 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating @@ -767,3 +768,4 @@ /* Tell ffi_closure_ASM to perform return type promotions. */ return cif->rtype->type; } +#endif Modified: python/trunk/Modules/_ctypes/libffi/src/prep_cif.c ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/prep_cif.c (original) +++ python/trunk/Modules/_ctypes/libffi/src/prep_cif.c Thu May 25 21:59:56 2006 @@ -55,11 +55,29 @@ /* Perform a sanity check on the argument type */ FFI_ASSERT_VALID_TYPE(*ptr); +#ifdef POWERPC_DARWIN + { + int curalign; + + curalign = (*ptr)->alignment; + if (ptr != &(arg->elements[0])) { + if (curalign > 4 && curalign != 16) { + curalign = 4; + } + } + arg->size = ALIGN(arg->size, curalign); + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > curalign) ? + arg->alignment : curalign; + } +#else arg->size = ALIGN(arg->size, (*ptr)->alignment); arg->size += (*ptr)->size; arg->alignment = (arg->alignment > (*ptr)->alignment) ? arg->alignment : (*ptr)->alignment; +#endif ptr++; } @@ -89,6 +107,19 @@ /* Perform machine independent ffi_cif preparation, then call machine dependent routine. */ +#ifdef X86_DARWIN +static inline int struct_on_stack(int size) +{ + if (size > 8) return 1; + /* This is not what the ABI says, but is what is really implemented */ + switch (size) { + case 1: case 2: case 4: case 8: return 0; + return 1; + } +} +#endif + + ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, ffi_abi abi, unsigned int nargs, /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, @@ -124,6 +155,10 @@ #ifdef SPARC && (cif->abi != FFI_V9 || cif->rtype->size > 32) #endif +#ifdef X86_DARWIN + + && (struct_on_stack(cif->rtype->size)) +#endif ) bytes = STACK_ARG_SIZE(sizeof(void*)); #endif @@ -139,7 +174,16 @@ check after the initialization. */ FFI_ASSERT_VALID_TYPE(*ptr); -#if !defined __x86_64__ && !defined S390 && !defined PA +#if defined(X86_DARWIN) + { + int align = (*ptr)->alignment; + if (align > 4) align = 4; + if ((align - 1) & bytes) + bytes = ALIGN(bytes, align); + bytes += STACK_ARG_SIZE((*ptr)->size); + } + +#elif !defined __x86_64__ && !defined S390 && !defined PA #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT && ((*ptr)->size > 16 || cif->abi != FFI_V9)) Modified: python/trunk/Modules/_ctypes/libffi/src/x86/ffitarget.h ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/x86/ffitarget.h (original) +++ python/trunk/Modules/_ctypes/libffi/src/x86/ffitarget.h Thu May 25 21:59:56 2006 @@ -51,7 +51,7 @@ #endif /* ---- Intel x86 and AMD x86-64 - */ -#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) +#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) FFI_SYSV, FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ #ifdef __i386__ From python-checkins at python.org Thu May 25 22:07:04 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 25 May 2006 22:07:04 +0200 (CEST) Subject: [Python-checkins] r46250 - sandbox/trunk/Doc/functional.rst Message-ID: <20060525200704.E23961E400B@bag.python.org> Author: andrew.kuchling Date: Thu May 25 22:07:04 2006 New Revision: 46250 Modified: sandbox/trunk/Doc/functional.rst Log: Add paragraph about sets; write half of itertools section; untabify Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Thu May 25 22:07:04 2006 @@ -215,10 +215,10 @@ Y must be an iterator or some object for which ``iter()`` can create an iterator. These two statements are equivalent:: - for i in iter(obj): + for i in iter(obj): print i - for i in obj: + for i in obj: print i Iterators can be materialized as lists or tuples by using the ``list()`` or ``tuple()`` @@ -302,10 +302,15 @@ read each line of a file like this:: for line in file: - # do something for each line - ... + # do something for each line + ... -XXX sets +Sets can take their contents from an iterable and let you iterate over +the set's elements:: + + S = set((2, 3, 5, 7, 11, 13)) + for i in S: + print i @@ -324,11 +329,11 @@ a stream of strings with the following list comprehension:: line_list = [' line 1\n', 'line 2 \n', ...] - stripped_list = [line.strip() for line in line_list] + stripped_list = [line.strip() for line in line_list] You can select only certain elements by adding an ``"if"`` condition:: - stripped_list = [line.strip() for line in line_list + stripped_list = [line.strip() for line in line_list if line != ""] Note that in all case the resulting ``stripped_list`` is a Python list @@ -339,10 +344,10 @@ List comprehensions have the form:: [ expression for expr in sequence1 - for expr2 in sequence2 - for expr3 in sequence3 ... - for exprN in sequenceN - if condition ] + for expr2 in sequence2 + for expr3 in sequence3 ... + for exprN in sequenceN + if condition ] The elements of the generated list will be the successive values of ``expression``. The final ``if`` clause is @@ -360,13 +365,13 @@ Python code:: for expr1 in sequence1: - for expr2 in sequence2: - ... - for exprN in sequenceN: - if (condition): - # Append the value of - # the expression to the - # resulting list. + for expr2 in sequence2: + ... + for exprN in sequenceN: + if (condition): + # Append the value of + # the expression to the + # resulting list. This means that when there are multiple ``for...in`` clauses, the resulting list will be equal to the product of the @@ -412,8 +417,8 @@ Here's the simplest example of a generator function:: def generate_ints(N): - for i in range(N): - yield i + for i in range(N): + yield i Any function containing a ``yield`` keyword is a generator function; this is detected by Python's bytecode compiler which compiles the @@ -475,12 +480,12 @@ # A recursive generator that generates Tree leaves in in-order. def inorder(t): - if t: - for x in inorder(t.left): - yield x - yield t.label - for x in inorder(t.right): - yield x + if t: + for x in inorder(t.left): + yield x + yield t.label + for x in inorder(t.right): + yield x Two other examples in ``test_generators.py`` produce solutions for the N-Queens problem (placing N queens on an NxN @@ -531,14 +536,14 @@ :: def counter (maximum): - i = 0 - while i < maximum: - val = (yield i) - # If value provided, change counter - if val is not None: - i = val - else: - i += 1 + i = 0 + while i < maximum: + val = (yield i) + # If value provided, change counter + if val is not None: + i = val + else: + i += 1 And here's an example of changing the counter: @@ -554,7 +559,7 @@ >>> print it.next() Traceback (most recent call last): File ``t.py'', line 15, in ? - print it.next() + print it.next() StopIteration Because ``yield`` will often be returning ``None``, you @@ -595,37 +600,178 @@ The itertools module ----------------------- -Small functions and the lambda statement ----------------------------------------------- +The ``itertools`` module contains a number of commonly-used iterators +as well as functions for combining iterators. This section will +introduce the module's contents using small examples. + +``itertools.count(n)`` returns an infinite stream of +integers, increasing by 1 each time. You can optionally supply the +starting number, which defaults to 0:: + + itertools.count() => + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... + itertools.count(10) => + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... + +``itertools.cycle(iter)`` saves a copy of the contents of a provided +iterable and returns a new iterator that returns its elements from +first to last, and then repeats these elements infinitely. + +:: + + itertools.cycle([1,2,3,4,5]) => + 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ... + +``itertools.repeat(elem, [n])`` returns the provided element ``n`` +times, or returns the element endlessly if ``n`` is not provided. + +:: + + itertools.repeat('abc') => + abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ... + itertools.repeat('abc', 5) => + abc, abc, abc, abc, abc + +``itertools.chain(iterA, iterB, ...)`` takes an arbitrary number of +iterables as input, and returns all the elements of the first iterator, +then all the elements of the second, until all of the iterables +have been exhausted. + +:: + + itertools.chain(['a', 'b', 'c'], (1, 2, 3)) => + a, b, c, 1, 2, 3 + +``itertools.izip(iterA, iterB, ...)`` takes one element from each iterable +and returns them in a tuple:: + + itertools.izip(['a', 'b', 'c'], (1, 2, 3)) => + ('a', 1), ('b', 2), ('c', 3) + +This iterator is intended to be used with iterables that are all of +the same length. If the iterables are of different lengths, +the resulting stream will be the same length as the shortest iterable. +Unfortunately, if you passed in any iterators as arguments, +an element may have been taken from the longer iterators +and discarded, meaning that you can't keep using them; if you do, +you risk skipping a discarded element. + +:: + + itertools.izip(['a', 'b'], (1, 2, 3)) => + ('a', 1), ('b', 2) + + +``itertools.islice(iter, [start], stop, [step])`` returns a stream +that's a slice of the iterator. It can return the first ``stop`` +elements. If you supply a starting index, you'll get ``stop-start`` +elements, and if you supply a value for ``step` elements will be +skipped. Unlike Python's string and list slicing, you can't use +negative values for ``start``, ``stop``, or ``step``. + +:: + + itertools.islice(range(10), 8) => + 0, 1, 2, 3, 4, 5, 6, 7 + itertools.islice(range(10), 2, 8) => + 2, 3, 4, 5, 6, 7 + itertools.islice(range(10), 2, 8, 2) => + 2, 4, 6 + +``itertools.tee(iter, [n])`` replicates an iterator; it returns ``n`` +independent iterators that will all return the contents of the source +iterator. If you don't supply a value for ``n``, the default is 2. +Replicating iterators requires saving some of the contents of the source +iterator, so this can consume significant memory if the iterator is large +and one of the new iterators is consumed more than the others. + +:: + + itertools.tee( itertools.count() ) => + iterA, iterB + + where iterA -> + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... + + and iterB -> + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... + + +Two functions are for calling other functions on the contents of an +iterable. + +``itertools.imap(f, iterA, iterB, ...)`` returns +a stream containing ``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), +f(iterA[2], iterB[2]), ...``:: + + itertools.imap(operator.add, [5, 6, 5], [1, 2, 3]) => + 6, 8, 8 + +(The ``operator`` module contains a set of functions +corresponding to Python's operators. Some examples are +``operator.add(a, b)`` (adds two values), +``operator.ne(a, b)`` (same as ``a!=b``), +and +``operator.attrgetter('id')`` (returns a callable that +fetches the ``"id"`` attribute), + +``itertools.starmap(func, iter)`` assumes that the iterable will +return a stream of tuples, and calls ``f()`` using these tuples as the +arguments:: + + itertools.starmap(os.path.join, + [('/usr', 'bin', 'java'), ('/bin', 'python'), + ('/usr', 'bin', 'perl'),('/usr', 'bin', 'ruby')]) + => + /usr/bin/java, /bin/python, /usr/bin/perl, /usr/bin/ruby + + + +.. comment + + ifilter + ifilterfalse + takewhile + dropwhile + groupby + Built-in functions ---------------------------------------------- map(), filter(), reduce() +os.walk() + +Small functions and the lambda statement +---------------------------------------------- +XXX + +The functools modules +---------------------------------------------- .. comment Introduction - Idea of FP - Programs built out of functions - Functions are strictly input-output, no internal state - Opposed to OO programming, where objects have state - - Why FP? - Formal provability - Assignment is difficult to reason about - Not very relevant to Python - Modularity - Small functions that do one thing - Debuggability: - Easy to test due to lack of state - Easy to verify output from intermediate steps - Composability - You assemble a toolbox of functions that can be mixed + Idea of FP + Programs built out of functions + Functions are strictly input-output, no internal state + Opposed to OO programming, where objects have state + + Why FP? + Formal provability + Assignment is difficult to reason about + Not very relevant to Python + Modularity + Small functions that do one thing + Debuggability: + Easy to test due to lack of state + Easy to verify output from intermediate steps + Composability + You assemble a toolbox of functions that can be mixed Tackling a problem - Need a significant example + Need a significant example Iterators Generators @@ -633,6 +779,16 @@ List comprehensions Small functions and the lambda statement Built-in functions - map - filter - reduce + map + filter + reduce + +.. comment + + import itertools + def print_iter(it): + slice = itertools.islice(it, 10) + for elem in slice[:-1]: + sys.stdout.write(str(elem)) + sys.stdout.write(', ') + print elem[-1] From python-checkins at python.org Thu May 25 22:21:21 2006 From: python-checkins at python.org (sean.reifschneider) Date: Thu, 25 May 2006 22:21:21 +0200 (CEST) Subject: [Python-checkins] r46251 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060525202121.4C33A1E400B@bag.python.org> Author: sean.reifschneider Date: Thu May 25 22:21:20 2006 New Revision: 46251 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding Exception heirarchy test. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Thu May 25 22:21:20 2006 @@ -247,7 +247,7 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None, 'text' : None }), - ( UnicodeError, ( ), + ( UnicodeError, (), { 'message' : '', 'args' : (), }), ( sampleUnicodeEncodeError, { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, @@ -286,3 +286,70 @@ ( repr(e), checkArgName, repr(expected[checkArgName]), repr(getattr(e, checkArgName)) )) + + +# test exception heirarchy +osErrorChildren = [] +try: osErrorChildren.append(VMSError) +except: pass +try: osErrorChildren.append(WindowsError) +except: pass +osErrorChildren = tuple(osErrorChildren) +exceptionHeirarchy = \ + ( SystemExit, + KeyboardInterrupt, + Exception, + ( GeneratorExit, + StopIteration, + StandardError, + ( ArithmeticError, + ( FloatingPointError, + OverflowError, + ZeroDivisionError, ), + AssertionError, + AttributeError, + EnvironmentError, + ( IOError, + OSError, + osErrorChildren, ), + EOFError, + ImportError, + LookupError, + ( IndexError, + KeyError, ), + MemoryError, + NameError, + ( UnboundLocalError, ), + ReferenceError, + RuntimeError, + ( NotImplementedError, ), + SyntaxError, + ( IndentationError, + ( TabError, ), ), + SystemError, + TypeError, + ValueError, + ( UnicodeError, + ( UnicodeDecodeError, + UnicodeEncodeError, + UnicodeTranslateError, ), ), ), + Warning, + ( DeprecationWarning, + PendingDeprecationWarning, + RuntimeWarning, + SyntaxWarning, + UserWarning, + FutureWarning, + OverflowWarning, + ImportWarning, ), ), ) +def checkChildren(parent, children): + lastChild = None + for child in children: + if type(child) == type(tuple()): + checkChildren(lastChild, child) + else: + if not issubclass(child, parent): + raise TestFailed('Exception "%s" is not a subclass of "%s"' + % ( repr(child), repr(parent) )) + lastChild = child +checkChildren(BaseException, exceptionHeirarchy) From python-checkins at python.org Thu May 25 22:28:10 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 25 May 2006 22:28:10 +0200 (CEST) Subject: [Python-checkins] r46252 - python/trunk/Doc/api/newtypes.tex Message-ID: <20060525202810.A72641E400C@bag.python.org> Author: georg.brandl Date: Thu May 25 22:28:10 2006 New Revision: 46252 Modified: python/trunk/Doc/api/newtypes.tex Log: Someone seems to just have copy-pasted the docs of tp_compare to tp_richcompare ;) Modified: python/trunk/Doc/api/newtypes.tex ============================================================================== --- python/trunk/Doc/api/newtypes.tex (original) +++ python/trunk/Doc/api/newtypes.tex Thu May 25 22:28:10 2006 @@ -990,10 +990,10 @@ An optional pointer to the rich comparison function. The signature is the same as for \cfunction{PyObject_RichCompare()}. - The function should return \code{1} if the requested comparison - returns true, \code{0} if it returns false. It should return - \code{-1} and set an exception condition when an error occurred - during the comparison. + The function should return the result of the comparison (usually + \code{Py_True} or \code{Py_False}). If the comparison is undefined, + it must return \code{Py_NotImplemented}, if another error occurred + it must return \code{NULL} and set an exception condition. This field is inherited by subtypes together with \member{tp_compare} and \member{tp_hash}: a subtype inherits all From neal at metaslash.com Thu May 25 22:15:53 2006 From: neal at metaslash.com (Neal Norwitz) Date: Thu, 25 May 2006 16:15:53 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (2) Message-ID: <20060525201553.GA16367@python.psfb.org> ----------------------------------------------- Modules/Setup.dist is newer than Modules/Setup; check to make sure you have all the updates you need in your Modules/Setup file. Usually, copying Setup.dist to Setup will work. ----------------------------------------------- Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c Translating labels ... gcc -pthread -c -fno-strict-aliasing -g -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Python/graminit.o Python/graminit.c gcc -pthread -c -fno-strict-aliasing -g -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -DSVNVERSION=\"`LANG=C svnversion .`\" -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c rm -f libpython2.5.a ar cr libpython2.5.a Modules/getbuildinfo.o ar cr libpython2.5.a Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/parsetok.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Parser/myreadline.o Parser/tokenizer.o ar cr libpython2.5.a Objects/abstract.o Objects/boolobject.o Objects/bufferobject.o Objects/cellobject.o Objects/classobject.o Objects/cobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/intobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/methodobject.o Objects/moduleobject.o Objects/object.o Objects/obmalloc.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/stringobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/weakrefobject.o Objects/unicodeobject.o Objects/unicodectype.o ar cr libpython2.5.a Python/Python-ast.o Python/asdl.o Python/ast.o Python/bltinmodule.o Python/exceptions.o Python/ceval.o Python/compile.o Python/codecs.o Python/errors.o Python/frozen.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getmtime.o Python/getplatform.o Python/getversion.o Python/graminit.o Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o Python/mystrtoul.o Python/mysnprintf.o Python/pyarena.o Python/pyfpe.o Python/pystate.o Python/pythonrun.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/traceback.o Python/getopt.o Python/pystrtod.o Python/dynload_shlib.o Python/thread.o ar cr libpython2.5.a Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o ar cr libpython2.5.a Modules/threadmodule.o Modules/signalmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/zipimport.o Modules/symtablemodule.o Modules/xxsubtype.o ranlib libpython2.5.a gcc -pthread -Xlinker -export-dynamic -o python \ Modules/python.o \ libpython2.5.a -lpthread -ldl -lutil -lm libpython2.5.a(posixmodule.o)(.text+0x464e): In function `posix_tmpnam': Modules/posixmodule.c:6687: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp' libpython2.5.a(posixmodule.o)(.text+0x4596): In function `posix_tempnam': Modules/posixmodule.c:6642: warning: the use of `tempnam' is dangerous, better use `mkstemp' case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [33785 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8453 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test test_float failed -- errors occurred; run in verbose mode for details test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_float 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [423304 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test test_float failed -- errors occurred; run in verbose mode for details test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functional test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8458 refs] [8458 refs] [8458 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [8794 refs] [8794 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8669 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] [8453 refs] this bit of output is from a test of stdout in a different process ... [8453 refs] [8453 refs] [8669 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8453 refs] [8453 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8453 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 284 tests OK. 1 test failed: test_float 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [422734 refs] make: *** [test] Error 1 From brett at python.org Thu May 25 22:35:25 2006 From: brett at python.org (Brett Cannon) Date: Thu, 25 May 2006 13:35:25 -0700 Subject: [Python-checkins] r46251 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py In-Reply-To: <20060525202121.4C33A1E400B@bag.python.org> References: <20060525202121.4C33A1E400B@bag.python.org> Message-ID: This is actually unneeded; see test_pep352.py for the test of the hierarchy. it reads Lib/test/exception_hierarchy.txt and checks that the hierarchy in that file matches what is in Python. -Brett On 5/25/06, sean.reifschneider wrote: > > Author: sean.reifschneider > Date: Thu May 25 22:21:20 2006 > New Revision: 46251 > > Modified: > python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > Log: > Adding Exception heirarchy test. > > > Modified: > python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > > ============================================================================== > --- > python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > (original) > +++ > python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > Thu May 25 22:21:20 2006 > @@ -247,7 +247,7 @@ > 'print_file_and_line' : None, 'msg' : 'msgStr', > 'filename' : None, 'lineno' : None, 'offset' : None, > 'text' : None }), > - ( UnicodeError, ( ), > + ( UnicodeError, (), > { 'message' : '', 'args' : (), }), > ( sampleUnicodeEncodeError, > { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, > @@ -286,3 +286,70 @@ > ( repr(e), checkArgName, > repr(expected[checkArgName]), > repr(getattr(e, checkArgName)) )) > + > + > +# test exception heirarchy > +osErrorChildren = [] > +try: osErrorChildren.append(VMSError) > +except: pass > +try: osErrorChildren.append(WindowsError) > +except: pass > +osErrorChildren = tuple(osErrorChildren) > +exceptionHeirarchy = \ > + ( SystemExit, > + KeyboardInterrupt, > + Exception, > + ( GeneratorExit, > + StopIteration, > + StandardError, > + ( ArithmeticError, > + ( FloatingPointError, > + OverflowError, > + ZeroDivisionError, ), > + AssertionError, > + AttributeError, > + EnvironmentError, > + ( IOError, > + OSError, > + osErrorChildren, ), > + EOFError, > + ImportError, > + LookupError, > + ( IndexError, > + KeyError, ), > + MemoryError, > + NameError, > + ( UnboundLocalError, ), > + ReferenceError, > + RuntimeError, > + ( NotImplementedError, ), > + SyntaxError, > + ( IndentationError, > + ( TabError, ), ), > + SystemError, > + TypeError, > + ValueError, > + ( UnicodeError, > + ( UnicodeDecodeError, > + UnicodeEncodeError, > + UnicodeTranslateError, ), ), ), > + Warning, > + ( DeprecationWarning, > + PendingDeprecationWarning, > + RuntimeWarning, > + SyntaxWarning, > + UserWarning, > + FutureWarning, > + OverflowWarning, > + ImportWarning, ), ), ) > +def checkChildren(parent, children): > + lastChild = None > + for child in children: > + if type(child) == type(tuple()): > + checkChildren(lastChild, child) > + else: > + if not issubclass(child, parent): > + raise TestFailed('Exception "%s" is not a subclass of > "%s"' > + % ( repr(child), repr(parent) )) > + lastChild = child > +checkChildren(BaseException, exceptionHeirarchy) > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060525/a244cc02/attachment.html From buildbot at python.org Thu May 25 22:38:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 20:38:40 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060525203841.03D331E400B@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/499 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 22:41:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 20:41:58 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060525204158.C98B11E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/782 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu May 25 22:44:08 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 25 May 2006 22:44:08 +0200 (CEST) Subject: [Python-checkins] r46253 - python/trunk/Python/pystrtod.c Message-ID: <20060525204408.D6E021E400B@bag.python.org> Author: brett.cannon Date: Thu May 25 22:44:08 2006 New Revision: 46253 Modified: python/trunk/Python/pystrtod.c Log: Swap out bare malloc()/free() use for PyMem_MALLOC()/PyMem_FREE() . Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Thu May 25 22:44:08 2006 @@ -101,7 +101,7 @@ char *copy, *c; /* We need to convert the '.' to the locale specific decimal point */ - copy = (char *)malloc(end - nptr + 1 + decimal_point_len); + copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len); c = copy; memcpy(c, nptr, decimal_point_pos - nptr); @@ -122,7 +122,7 @@ fail_pos = (char *)nptr + (fail_pos - copy); } - free(copy); + PyMem_FREE(copy); } else { From tim.peters at gmail.com Thu May 25 22:48:49 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 20:48:49 +0000 Subject: [Python-checkins] r46253 - python/trunk/Python/pystrtod.c In-Reply-To: <20060525204408.D6E021E400B@bag.python.org> References: <20060525204408.D6E021E400B@bag.python.org> Message-ID: <1f7befae0605251348i6b795f09u186c071474743d80@mail.gmail.com> > Author: brett.cannon > Date: Thu May 25 22:44:08 2006 > New Revision: 46253 > > Modified: > python/trunk/Python/pystrtod.c > Log: > Swap out bare malloc()/free() use for PyMem_MALLOC()/PyMem_FREE() . > > > Modified: python/trunk/Python/pystrtod.c > ============================================================================== > --- python/trunk/Python/pystrtod.c (original) > +++ python/trunk/Python/pystrtod.c Thu May 25 22:44:08 2006 > @@ -101,7 +101,7 @@ > char *copy, *c; > > /* We need to convert the '.' to the locale specific decimal point */ > - copy = (char *)malloc(end - nptr + 1 + decimal_point_len); > + copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len); > > c = copy; > memcpy(c, nptr, decimal_point_pos - nptr); Note that this missed a genuine (but pre-existing) bug: we can't _assume_ malloc (of any flavor) returns a non-NULL pointer. From python-checkins at python.org Thu May 25 22:52:39 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 22:52:39 +0200 (CEST) Subject: [Python-checkins] r46254 - python/trunk/Objects/stringobject.c Message-ID: <20060525205239.97A461E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 22:52:38 2006 New Revision: 46254 Modified: python/trunk/Objects/stringobject.c Log: squelch gcc4 darwin/x86 compiler warnings Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Thu May 25 22:52:38 2006 @@ -799,7 +799,7 @@ #define FAST_SEARCH 1 LOCAL(Py_ssize_t) - fastsearch(const unsigned char* s, Py_ssize_t n, const unsigned char* p, + fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) { long mask; From rhettinger at ewtllc.com Thu May 25 22:59:11 2006 From: rhettinger at ewtllc.com (Raymond Hettinger) Date: Thu, 25 May 2006 13:59:11 -0700 Subject: [Python-checkins] r46250 - sandbox/trunk/Doc/functional.rst In-Reply-To: <20060525200704.E23961E400B@bag.python.org> References: <20060525200704.E23961E400B@bag.python.org> Message-ID: <44761A9F.8030500@ewtllc.com> Inserted below are a few ideas that you may or may not want to include as part of a tutorial of functionals. >+``itertools.count(n)`` returns an infinite stream of >+integers, increasing by 1 each time. You can optionally supply the >+starting number, which defaults to 0:: >+ >+ itertools.count() => >+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... >+ itertools.count(10) => >+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... > > count() is typically used to feed consecutive numbers into other itertools. For example: imap(f, count()) --> f(0), f(1), f(2), . . . Since count() is an infinite iterator, one of the enclosing functions is typically responsible for termination. For example, izip() will terminate whenever one of its input streams is exhausted, so you can write a variant of enumerate with: izip(count(1), 'abc') --> (1,'a'), (2,'b'), (3,'c') StopIteration. This same thought applies to other infinite iterators like repeat(value) or cycle(seq). >+ >+``itertools.repeat(elem, [n])`` returns the provided element ``n`` >+times, or returns the element endlessly if ``n`` is not provided. >+ >+:: >+ >+ itertools.repeat('abc') => >+ abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ... >+ itertools.repeat('abc', 5) => >+ abc, abc, abc, abc, abc > > One common use is supplying a stream of constants to multi-valued functions. For example, to create consecutive powers of three: imap(pow, repeat(3), xrange(10)) --> 3**0, 3**1, 3**2, ..., 3**9 It can also be useful in speed critical fixed-length loops that do not need an index: for _ in repeat(None, 10): print "hello" # Ten hellos >+ >+``itertools.chain(iterA, iterB, ...)`` takes an arbitrary number of >+iterables as input, and returns all the elements of the first iterator, >+then all the elements of the second, until all of the iterables >+have been exhausted. >+ >+:: >+ >+ itertools.chain(['a', 'b', 'c'], (1, 2, 3)) => >+ a, b, c, 1, 2, 3 > > One obvious use is removing one level of for-loops when iterating over multiple sequences: for s in s1, s2, s3: for x in s: print f(x) simplifies to: for x in chain(s1, s2, s3): print f(x) Another use for chain() is to pad sequences with a fill value: s = 'ABC' t = 'uvwxyz' zip(chain(s, repeat('-', 3), t) Another variant on that theme is padding a short sequence with fill values so that zip() can form the sequence into a two dimensional array: >>> s = range(11) >>> zip(*[iter(chain(s, repeat(0,5)))]*5) [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 0, 0, 0, 0)] >+ >+``itertools.izip(iterA, iterB, ...)`` takes one element from each iterable >+and returns them in a tuple:: >+ >+ itertools.izip(['a', 'b', 'c'], (1, 2, 3)) => >+ ('a', 1), ('b', 2), ('c', 3) >+ >+This iterator is intended to be used with iterables that are all of >+the same length. If the iterables are of different lengths, >+the resulting stream will be the same length as the shortest iterable. >+Unfortunately, if you passed in any iterators as arguments, >+an element may have been taken from the longer iterators >+and discarded, meaning that you can't keep using them; if you do, >+you risk skipping a discarded element. >+ >+:: >+ >+ itertools.izip(['a', 'b'], (1, 2, 3)) => >+ ('a', 1), ('b', 2) > > The izip() tool is typically used in for-loops to have lock-step iteration over multiple sequences: for x, y in izip(xseries, yseries): print 'Coordinate', x, y Used with a for-loop, the izip() tool typically outperforms its built-in zip() counterpart. The izip() tool can be used with the * operator to have the effect of a matrix transpose: >>> m = [(1,2,3), (4,5,6)] >>> list(izip(*m)) [(1, 4), (2, 5), (3, 6)] There is another * operator trick to make zip() or izip() serve as a data grouper: >>> zip(*[iter(s)]*3) [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11)] If you want more of these kinds of comments or examples, let me know and I'll cover the rest of the tools. Raymond From jimjjewett at gmail.com Thu May 25 23:00:45 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 25 May 2006 17:00:45 -0400 Subject: [Python-checkins] r46247 - in python/branches/sreifschneider-newnewexcept: Makefile.pre.in Objects/exceptions.c Python/exceptions.c In-Reply-To: <20060525194304.CF03E1E401C@bag.python.org> References: <20060525194304.CF03E1E401C@bag.python.org> Message-ID: On 5/25/06, richard.jones wrote: > Author: richard.jones > Date: Thu May 25 21:43:03 2006 > New Revision: 46247 > > Removed: > python/branches/sreifschneider-newnewexcept/Python/exceptions.c > Modified: > python/branches/sreifschneider-newnewexcept/Makefile.pre.in > python/branches/sreifschneider-newnewexcept/Objects/exceptions.c > Log: > Transitioning Exceptions over to being PyTypeObjects rather than > faked-class PyObjects. > > Doesn't currently work - this is just to checkpoint that the bulk of the > work has been done and now we're debugging. > Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c > ============================================================================== > --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) > +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Thu May 25 21:43:03 2006 > @@ -65,55 +69,31 @@ > > #ifdef Py_USING_UNICODE > static PyObject * > -BaseException_unicode(PyObject *self, PyObject *args) > +BaseException_unicode(BaseExceptionObject *self, PyObject *args) > { ... > + PyObject *temp = PySequence_GetItem(self->args, 0); > + PyObject *unicode_obj; Do these have to go in the other order, because of a C89 requirement about declarations before operations? > +/* > + * OverflowWarning extends Warning > + */ > +SimpleExtendsException(PyExc_Warning, OverflowWarning, "Base class for warnings about numeric overflow. Won't exist in Python 2.5."); Take it out now? -jJ From python-checkins at python.org Thu May 25 23:09:45 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 23:09:45 +0200 (CEST) Subject: [Python-checkins] r46255 - python/trunk/Modules/_struct.c Message-ID: <20060525210945.DB1F91E400B@bag.python.org> Author: bob.ippolito Date: Thu May 25 23:09:45 2006 New Revision: 46255 Modified: python/trunk/Modules/_struct.c Log: fix test_float regression and 64-bit size mismatch issue Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu May 25 23:09:45 2006 @@ -1486,14 +1486,28 @@ other = lilendian_table; else other = bigendian_table; + /* Scan through the native table, find a matching + entry in the endian table and swap in the + native implementations whenever possible + (64-bit platforms may not have "standard" sizes) */ while (native->format != '\0' && other->format != '\0') { ptr = other; while (ptr->format != '\0') { if (ptr->format == native->format) { - ptr->pack = native->pack; - ptr->unpack = native->unpack; + /* Match faster when formats are + listed in the same order */ if (ptr == other) other++; + /* Only use the trick if the + size matches */ + if (ptr->size != native->size) + break; + /* Skip float and double, could be + "unknown" float format */ + if (ptr->format == 'd' || ptr->format == 'f') + break; + ptr->pack = native->pack; + ptr->unpack = native->unpack; break; } ptr++; From tim.peters at gmail.com Thu May 25 23:11:47 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 21:11:47 +0000 Subject: [Python-checkins] r46247 - in python/branches/sreifschneider-newnewexcept: Makefile.pre.in Objects/exceptions.c Python/exceptions.c In-Reply-To: References: <20060525194304.CF03E1E401C@bag.python.org> Message-ID: <1f7befae0605251411qdf731dar8bfc4b20ad54d6b1@mail.gmail.com> >> + PyObject *temp = PySequence_GetItem(self->args, 0); >> + PyObject *unicode_obj; [Jim Jewett] > Do these have to go in the other order, because of a C89 requirement > about declarations before operations? No; they're both declarations, and that's fine. This would violate C89: PyObject *temp; temp = PySequence_GetItem(self->args, 0); PyObject *unicode_obj; That split the declarations, and that's not allowed. From python-checkins at python.org Thu May 25 23:12:00 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 25 May 2006 23:12:00 +0200 (CEST) Subject: [Python-checkins] r46256 - python/trunk/Doc/api/abstract.tex Message-ID: <20060525211200.D207F1E400C@bag.python.org> Author: georg.brandl Date: Thu May 25 23:11:56 2006 New Revision: 46256 Modified: python/trunk/Doc/api/abstract.tex Log: Add a x-ref to newer calling APIs. Modified: python/trunk/Doc/api/abstract.tex ============================================================================== --- python/trunk/Doc/api/abstract.tex (original) +++ python/trunk/Doc/api/abstract.tex Thu May 25 23:11:56 2006 @@ -260,6 +260,8 @@ result of the call on success, or \NULL{} on failure. This is the equivalent of the Python expression \samp{apply(\var{callable}, \var{args})} or \samp{\var{callable}(*\var{args})}. + Note that if you only pass \ctype{PyObject *} args, + \cfunction{PyObject_CallFunctionObjArgs} is a faster alternative. \bifuncindex{apply} \end{cfuncdesc} @@ -274,6 +276,8 @@ indicating that no arguments are provided. Returns the result of the call on success, or \NULL{} on failure. This is the equivalent of the Python expression \samp{\var{o}.\var{method}(\var{args})}. + Note that if you only pass \ctype{PyObject *} args, + \cfunction{PyObject_CallMethodObjArgs} is a faster alternative. \end{cfuncdesc} From buildbot at python.org Thu May 25 23:16:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 21:16:46 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060525211646.91C061E4022@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/758 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu May 25 23:18:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 21:18:10 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060525211810.1EFD11E4020@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/532 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From jimjjewett at gmail.com Thu May 25 23:20:19 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 25 May 2006 17:20:19 -0400 Subject: [Python-checkins] r46250 - sandbox/trunk/Doc/functional.rst In-Reply-To: <44761A9F.8030500@ewtllc.com> References: <20060525200704.E23961E400B@bag.python.org> <44761A9F.8030500@ewtllc.com> Message-ID: On 5/25/06, Raymond Hettinger wrote: > Inserted below are a few ideas that you may or may not want to include > as part of a tutorial of functionals. > Another variant on that theme is padding a short sequence with fill > values so that zip() can form the sequence into a two dimensional array: > > >>> s = range(11) > >>> zip(*[iter(chain(s, repeat(0,5)))]*5) > [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 0, 0, 0, 0)] It is not at all obvious what this one does. If you do use it, then please put it after the rest of the izip section, including the call-three-times-and-unpack example. > >>> zip(*[iter(s)]*3) so that the parts other than chain and repeat don't seem as magical. -jJ From python-checkins at python.org Thu May 25 23:30:54 2006 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 25 May 2006 23:30:54 +0200 (CEST) Subject: [Python-checkins] r46257 - python/trunk/Modules/_ctypes/libffi/src/prep_cif.c Message-ID: <20060525213054.001C11E401F@bag.python.org> Author: ronald.oussoren Date: Thu May 25 23:30:54 2006 New Revision: 46257 Modified: python/trunk/Modules/_ctypes/libffi/src/prep_cif.c Log: Fix minor typo in prep_cif.c Modified: python/trunk/Modules/_ctypes/libffi/src/prep_cif.c ============================================================================== --- python/trunk/Modules/_ctypes/libffi/src/prep_cif.c (original) +++ python/trunk/Modules/_ctypes/libffi/src/prep_cif.c Thu May 25 23:30:54 2006 @@ -114,8 +114,8 @@ /* This is not what the ABI says, but is what is really implemented */ switch (size) { case 1: case 2: case 4: case 8: return 0; - return 1; } + return 1; } #endif From python-checkins at python.org Thu May 25 23:31:05 2006 From: python-checkins at python.org (sean.reifschneider) Date: Thu, 25 May 2006 23:31:05 +0200 (CEST) Subject: [Python-checkins] r46258 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060525213105.4B8051E4028@bag.python.org> Author: sean.reifschneider Date: Thu May 25 23:31:04 2006 New Revision: 46258 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Adding IOErrors for Richard's testing. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Thu May 25 23:31:04 2006 @@ -219,6 +219,11 @@ ( BaseException, ('foo', 1), { 'message' : '', 'args' : ( 'foo', 1 ) }), ( SystemExit, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), 'code' : 'foo' }), + ( IOError, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), }), + ( IOError, ('foo', 'bar'), { 'message' : '', + 'args' : ('foo', 'bar'), }), + ( IOError, ('foo', 'bar', 'baz'), + { 'message' : '', 'args' : ('foo', 'bar'), }), ( EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', From python-checkins at python.org Thu May 25 23:33:12 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 25 May 2006 23:33:12 +0200 (CEST) Subject: [Python-checkins] r46259 - python/trunk/Lib/test/test_grp.py Message-ID: <20060525213312.396531E400C@bag.python.org> Author: brett.cannon Date: Thu May 25 23:33:11 2006 New Revision: 46259 Modified: python/trunk/Lib/test/test_grp.py Log: Change test_values so that it compares the lowercasing of group names since getgrall() can return all lowercase names while getgrgid() returns proper casing. Discovered on Ubuntu 5.04 (custom). Modified: python/trunk/Lib/test/test_grp.py ============================================================================== --- python/trunk/Lib/test/test_grp.py (original) +++ python/trunk/Lib/test/test_grp.py Thu May 25 23:33:11 2006 @@ -31,7 +31,10 @@ self.assertEqual(e2.gr_gid, e.gr_gid) e2 = grp.getgrnam(e.gr_name) self.check_value(e2) - self.assertEqual(e2.gr_name, e.gr_name) + # There are instances where getgrall() returns group names in + # lowercase while getgrgid() returns proper casing. + # Discovered on Ubuntu 5.04 (custom). + self.assertEqual(e2.gr_name.lower(), e.gr_name.lower()) def test_errors(self): self.assertRaises(TypeError, grp.getgrgid) From python-checkins at python.org Thu May 25 23:49:13 2006 From: python-checkins at python.org (richard.jones) Date: Thu, 25 May 2006 23:49:13 +0200 (CEST) Subject: [Python-checkins] r46260 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060525214913.E1CEC1E400B@bag.python.org> Author: richard.jones Date: Thu May 25 23:49:13 2006 New Revision: 46260 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: another checkpoint Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Thu May 25 23:49:13 2006 @@ -12,26 +12,39 @@ PyObject *message; } BaseExceptionObject; -static int -BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +static PyObject * +BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - /* we just want to store off the args as they are */ - self->args = args; - Py_INCREF(args); + BaseExceptionObject *self; - if (PySequence_Length(args) == 1) - self->message = PySequence_GetItem(args, 0); + self = (BaseExceptionObject *)type->tp_alloc(type, 0); + + self->args = self->message = NULL; + + if (!args) { + self->args = PyTuple_New(0); + if (!self->args) { + Py_DECREF(self); + return NULL; + } + } + else + self->args = args; + Py_INCREF(self->args); + + if (PySequence_Length(self->args) == 1) + self->message = PySequence_GetItem(self->args, 0); else self->message = PyString_FromString(""); - return 0; + return (PyObject *)self; } static void BaseException_dealloc(BaseExceptionObject *self) { - Py_DECREF(self->args); - Py_DECREF(self->message); + Py_XDECREF(self->args); + Py_XDECREF(self->message); } @@ -185,9 +198,9 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc)BaseException_init, /* tp_init */ + 0, /* tp_init */ 0, /* tp_alloc */ - 0, /* tp_new */ + BaseException_new, /* tp_new */ }; /* the CPython API expects exceptions to be (PyObject *) - both a hold-over from the previous implmentation and also allowing Python objects to be used @@ -198,13 +211,13 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions.EXCNAME", \ + "exceptions." # EXCNAME, \ sizeof(BaseExceptionObject), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, 0, 0, 0,\ + 0, 0, 0, 0, 0, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -212,28 +225,28 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions.EXCNAME", \ - sizeof(EXCSTORE), \ + "exceptions." # EXCNAME, \ + sizeof(EXCSTORE ## Object), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, 0, 0, 0,\ + 0, 0, 0, 0, 0, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; -#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCINIT, EXCNEW, EXCSTR, EXCDOC) \ +#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions.EXCNAME", \ - sizeof(EXCSTORE), 0, \ + "exceptions." # EXCNAME, \ + sizeof(EXCSTORE ## Object), 0, \ (destructor)EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, (initproc)EXCINIT, 0, (newfunc)EXCNEW,\ + 0, 0, 0, 0, 0, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -280,11 +293,14 @@ PyObject *code; } SystemExitObject; -static int -SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) +static PyObject * +SystemExit_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) - return -1; + SystemExitObject *self; + + self = (SystemExitObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; if (PySequence_Length(args) == 1) self->code = PySequence_GetItem(args, 0); @@ -293,7 +309,7 @@ Py_INCREF(Py_None); } - return 0; + return (PyObject *)self; } static void @@ -310,7 +326,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExitObject, SystemExit_dealloc, 0, SystemExit_members, SystemExit_init, 0, 0, "Request to exit from the interpreter."); +ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException @@ -336,13 +352,15 @@ PyObject *filename; } EnvironmentErrorObject; -static int -EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) +static PyObject * +EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *subslice = NULL; + EnvironmentErrorObject *self = NULL; - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) - return -1; + self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; self->myerrno = Py_None; Py_INCREF(Py_None); @@ -375,9 +393,9 @@ if (!subslice) goto finally; - Py_DECREF(self->args); /* drop old ref set by base class init */ + Py_DECREF(self->args); /* replacing args */ self->args = subslice; - return 0; + return (PyObject *)self; case 2: /* Used when PyErr_SetFromErrno() is called and no filename @@ -387,19 +405,17 @@ if (!self->myerrno) goto finally; self->strerror = PySequence_GetItem(args, 1); if (!self->strerror) goto finally; - return 0; + return (PyObject *)self; case -1: PyErr_Clear(); - return 0; } + return (PyObject *)self; finally: Py_XDECREF(subslice); - Py_XDECREF(self->myerrno); - Py_XDECREF(self->strerror); - Py_XDECREF(self->filename); - return -1; + Py_XDECREF(self); + return NULL; } static void @@ -470,19 +486,19 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentErrorObject, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_init, 0, EnvironmentError_str, "Base class for I/O related errors."); +ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_str, "Base class for I/O related errors."); /* * IOError extends EnvironmentError */ -MiddlingExtendsException(PyExc_EnvironmentError, IOError, EnvironmentErrorObject, "I/O operation failed."); +MiddlingExtendsException(PyExc_EnvironmentError, IOError, EnvironmentError, "I/O operation failed."); /* * OSError extends EnvironmentError */ -MiddlingExtendsException(PyExc_EnvironmentError, OSError, EnvironmentErrorObject, "OS system call failed."); +MiddlingExtendsException(PyExc_EnvironmentError, OSError, EnvironmentError, "OS system call failed."); /* @@ -501,13 +517,15 @@ PyObject *winerror; } WindowsErrorObject; -static int -WindowsError_init(PyObject *self, PyObject *args, PyObject *kwds) +static PyObject * +WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *o_errcode = NULL; + WindowsErrorObject *self = NULL; long posix_errno; - if (EnvironmentError_init(self, args, kwds) == -1 ) + self = (WindowsErrorObject *)EnvironmentError_new(type, args, kwds); + if (!self) return -1; /* Set errno to the POSIX errno, and winerror to the Win32 @@ -525,11 +543,12 @@ self->myerrno = o_errcode; - return 0; + return self; failed: /* Could not set errno. */ Py_XDECREF(o_errcode); - return -1; + Py_XDECREF(self); + return NULL; } @@ -587,7 +606,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_OSError, WindowsError, WindowsErrorObject, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_init, WindowsError_str, "MS-Windows OS system call failed."); +ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_str, "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ @@ -596,7 +615,7 @@ * VMSError extends OSError (I think) */ #ifdef __VMS -MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentErrorObject, "OpenVMS OS system call failed."); +MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError, "OpenVMS OS system call failed."); #endif @@ -648,14 +667,16 @@ PyObject *print_file_and_line; } SyntaxErrorObject; -static int -SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) +static PyObject * +SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *info = NULL; + SyntaxErrorObject *self = NULL; Py_ssize_t lenargs; - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1 ) - return -1; + self = (SyntaxErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; self->msg = self->filename = self->lineno = self->offset = self->text = NULL; @@ -683,17 +704,12 @@ self->text = PySequence_GetItem(info, 3); if (!self->text) goto finally; } - return 0; + return (PyObject *)self; finally: Py_XDECREF(info); - Py_XDECREF(self->msg); - Py_XDECREF(self->filename); - Py_XDECREF(self->lineno); - Py_XDECREF(self->offset); - Py_XDECREF(self->text); - Py_XDECREF(self->print_file_and_line); - return -1; + Py_XDECREF(self); + return NULL; } @@ -701,12 +717,12 @@ SyntaxError_dealloc(SyntaxErrorObject *self) { BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->msg); - Py_DECREF(self->filename); - Py_DECREF(self->lineno); - Py_DECREF(self->offset); - Py_DECREF(self->text); - Py_DECREF(self->print_file_and_line); + Py_XDECREF(self->msg); + Py_XDECREF(self->filename); + Py_XDECREF(self->lineno); + Py_XDECREF(self->offset); + Py_XDECREF(self->text); + Py_XDECREF(self->print_file_and_line); } /* This is called "my_basename" instead of just "basename" to avoid name @@ -746,8 +762,9 @@ int have_lineno = 0; char *buffer = NULL; - have_filename = PyString_Check(self->filename); - have_lineno = PyInt_Check(self->lineno); + have_filename = (self->filename != NULL) && + PyString_Check(self->filename); + have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno); if (have_filename || have_lineno) { Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; @@ -795,19 +812,19 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxErrorObject, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_init, 0, SyntaxError_str, "Invalid syntax."); +ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); /* * IndentationError extends SyntaxError */ -MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxErrorObject, "Improper indentation."); +MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, "Improper indentation."); /* * TabError extends IndentationError */ -MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxErrorObject, "Improper mixture of spaces and tabs."); +MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, "Improper mixture of spaces and tabs."); /* @@ -844,7 +861,7 @@ return BaseException_str(self); } -ComplexExtendsException(PyExc_LookupError, KeyError, BaseExceptionObject, 0, 0, 0, 0, 0, KeyError_str, "Mapping key not found."); +ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, 0, KeyError_str, "Mapping key not found."); /* @@ -1100,19 +1117,27 @@ } -static int -UnicodeError_init(UnicodeErrorObject *self, PyObject *args, PyTypeObject *objecttype) +static PyObject * +UnicodeError_new(PyTypeObject *type, PyObject *args, PyTypeObject *objecttype) { - if (BaseException_init((BaseExceptionObject *)self, args, NULL) == -1 ) - return -1; + UnicodeErrorObject *self; + + self = (UnicodeErrorObject *)BaseException_new(type, args, NULL); + if (!self) + return NULL; + + self->encoding = self->object = self->start = self->end = + self->reason = NULL; if (!PyArg_ParseTuple(args, "O!O!O!O!O!", &PyString_Type, &self->encoding, objecttype, &self->object, &PyInt_Type, &self->start, &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) - return -1; + &PyString_Type, &self->reason)) { + Py_DECREF(self); + return NULL; + } Py_INCREF(self->encoding); Py_INCREF(self->object); @@ -1120,28 +1145,39 @@ Py_INCREF(self->end); Py_INCREF(self->reason); - return 0; + return (PyObject *)self; } static void UnicodeError_dealloc(UnicodeErrorObject *self) { BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->encoding); - Py_DECREF(self->object); - Py_DECREF(self->start); - Py_DECREF(self->end); - Py_DECREF(self->reason); + Py_XDECREF(self->encoding); + Py_XDECREF(self->object); + Py_XDECREF(self->start); + Py_XDECREF(self->end); + Py_XDECREF(self->reason); } +static PyMemberDef UnicodeError_members[] = { + {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), 0, "exception arguments"}, + {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, "exception message"}, + {"encoding", T_OBJECT, offsetof(UnicodeErrorObject, encoding), 0, "exception encoding"}, + {"object", T_OBJECT, offsetof(UnicodeErrorObject, object), 0, "exception object"}, + {"start", T_OBJECT, offsetof(UnicodeErrorObject, start), 0, "exception start"}, + {"end", T_OBJECT, offsetof(UnicodeErrorObject, end), 0, "exception end"}, + {"reason", T_OBJECT, offsetof(UnicodeErrorObject, reason), 0, "exception reason"}, + {NULL} /* Sentinel */ +}; + /* * UnicodeEncodeError extends UnicodeError */ -static int -UnicodeEncodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +static PyObject * +UnicodeEncodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - return UnicodeError_init(self, args, &PyUnicode_Type); + return UnicodeError_new(type, args, &PyUnicode_Type); } static PyObject * @@ -1182,7 +1218,19 @@ ); } -ComplexExtendsException(PyExc_UnicodeError, UnicodeEncodeError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeEncodeError_init, 0, UnicodeEncodeError_str, "Unicode encoding error."); +static PyTypeObject _PyExc_UnicodeEncodeError = { + PyObject_HEAD_INIT(NULL) + 0, + "exceptions.UnicodeEncodeError", + sizeof(UnicodeErrorObject), 0, + (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (reprfunc)UnicodeEncodeError_str, 0, 0, 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + "Unicode encoding error.", + 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, + 0, 0, 0, 0, 0, 0, UnicodeEncodeError_new, +}; +PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; PyObject * PyUnicodeEncodeError_Create( const char *encoding, const Py_UNICODE *object, Py_ssize_t length, @@ -1196,10 +1244,10 @@ /* * UnicodeDecodeError extends UnicodeError */ -static int -UnicodeDecodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +static PyObject * +UnicodeDecodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - return UnicodeError_init(self, args, &PyString_Type); + return UnicodeError_new(type, args, &PyString_Type); } static PyObject * @@ -1236,7 +1284,19 @@ ); } -ComplexExtendsException(PyExc_UnicodeError, UnicodeDecodeError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeDecodeError_init, 0, UnicodeDecodeError_str, "Unicode decoding error."); +static PyTypeObject _PyExc_UnicodeDecodeError = { + PyObject_HEAD_INIT(NULL) + 0, + "exceptions.UnicodeDecodeError", + sizeof(UnicodeErrorObject), 0, + (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (reprfunc)UnicodeDecodeError_str, 0, 0, 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + "Unicode decoding error.", + 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, + 0, 0, 0, 0, 0, 0, UnicodeDecodeError_new, +}; +PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; PyObject * PyUnicodeDecodeError_Create( const char *encoding, const char *object, Py_ssize_t length, @@ -1253,18 +1313,23 @@ /* * UnicodeTranslateError extends UnicodeError */ -static int -UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +static PyObject * +UnicodeTranslateError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1 ) - return -1; + UnicodeErrorObject *self = NULL; + + self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; if (!PyArg_ParseTuple(args, "O!O!O!O!", &PyUnicode_Type, &self->object, &PyInt_Type, &self->start, &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) - return -1; + &PyString_Type, &self->reason)) { + Py_DECREF(self); + return NULL; + } self->encoding = Py_None; Py_INCREF(self->encoding); @@ -1273,7 +1338,7 @@ Py_INCREF(self->end); Py_INCREF(self->reason); - return 0; + return (PyObject *)self; } @@ -1313,7 +1378,19 @@ ); } -ComplexExtendsException(PyExc_UnicodeError, UnicodeTranslateError, UnicodeErrorObject, UnicodeError_dealloc, 0, 0, UnicodeTranslateError_init, 0, UnicodeTranslateError_str, "Unicode translation error."); +static PyTypeObject _PyExc_UnicodeTranslateError = { + PyObject_HEAD_INIT(NULL) + 0, + "exceptions.UnicodeTranslateError", + sizeof(UnicodeErrorObject), 0, + (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (reprfunc)UnicodeTranslateError_str, 0, 0, 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + "Unicode decoding error.", + 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, + 0, 0, 0, 0, 0, 0, UnicodeTranslateError_new, +}; +PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; PyObject * PyUnicodeTranslateError_Create( const Py_UNICODE *object, Py_ssize_t length, @@ -1453,8 +1530,8 @@ Py_FatalError("exceptions bootstrapping error."); #define POST_INIT(TYPE) Py_INCREF(PyExc_ ## TYPE); \ - PyModule_AddObject(m, "TYPE", PyExc_ ## TYPE); \ - if (PyDict_SetItemString(bdict, "TYPE", PyExc_ ## TYPE)) \ + PyModule_AddObject(m, # TYPE, PyExc_ ## TYPE); \ + if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \ Py_FatalError("Module dictionary insertion problem."); PyMODINIT_FUNC @@ -1582,7 +1659,7 @@ POST_INIT(FutureWarning) POST_INIT(ImportWarning) - PyExc_MemoryErrorInst = PyType_GenericNew(PyExc_MemoryError, NULL, NULL); + PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL); if (!PyExc_MemoryErrorInst) Py_FatalError("Cannot pre-allocate MemoryError instance\n"); From python-checkins at python.org Thu May 25 23:50:17 2006 From: python-checkins at python.org (tim.peters) Date: Thu, 25 May 2006 23:50:17 +0200 (CEST) Subject: [Python-checkins] r46261 - in python/trunk: Misc/NEWS Modules/timemodule.c Message-ID: <20060525215017.9A5AA1E400B@bag.python.org> Author: tim.peters Date: Thu May 25 23:50:17 2006 New Revision: 46261 Modified: python/trunk/Misc/NEWS python/trunk/Modules/timemodule.c Log: Some Win64 pre-release in 2000 didn't support QueryPerformanceCounter(), but we believe Win64 does support it now. So use in time.clock(). It would be peachy if someone with a Win64 box tried this ;-) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu May 25 23:50:17 2006 @@ -64,6 +64,10 @@ - Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. As a result, these functions now raise WindowsError instead of OSError. +- ``time.clock()`` on Win64 should use the high-performance Windows + ``QueryPerformanceCounter()`` now (as was already the case on 32-bit + Windows platforms). + - Calling Tk_Init twice is refused if the first call failed as that may deadlock. Modified: python/trunk/Modules/timemodule.c ============================================================================== --- python/trunk/Modules/timemodule.c (original) +++ python/trunk/Modules/timemodule.c Thu May 25 23:50:17 2006 @@ -63,11 +63,10 @@ #endif /* MS_WINDOWS */ #endif /* !__WATCOMC__ || __QNX__ */ -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) +#if defined(MS_WINDOWS) && !defined(__BORLANDC__) /* Win32 has better clock replacement - XXX Win64 does not yet, but might when the platform matures. */ #undef HAVE_CLOCK /* We have our own version down below */ -#endif /* MS_WINDOWS && !MS_WIN64 */ +#endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #if defined(PYOS_OS2) #define INCL_DOS @@ -821,7 +820,7 @@ SetConsoleCtrlHandler( PyCtrlHandler, TRUE); #endif /* MS_WINDOWS */ if (!initialized) { - PyStructSequence_InitType(&StructTimeType, + PyStructSequence_InitType(&StructTimeType, &struct_time_type_desc); } Py_INCREF(&StructTimeType); From python-checkins at python.org Thu May 25 23:52:19 2006 From: python-checkins at python.org (tim.peters) Date: Thu, 25 May 2006 23:52:19 +0200 (CEST) Subject: [Python-checkins] r46262 - python/trunk/Lib/test/string_tests.py Message-ID: <20060525215219.DDD331E400B@bag.python.org> Author: tim.peters Date: Thu May 25 23:52:19 2006 New Revision: 46262 Modified: python/trunk/Lib/test/string_tests.py Log: Whitespace normalization. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Thu May 25 23:52:19 2006 @@ -887,13 +887,13 @@ self.checkequal(True, 'A', 'isupper') self.checkequal('A', 'a', 'upper') self.checkequal(True, 'a', 'islower') - + self.checkequal('a', 'A', 'replace', 'A', 'a') self.checkequal(True, 'A', 'isupper') self.checkequal('A', 'a', 'capitalize') self.checkequal(True, 'a', 'islower') - + self.checkequal('A', 'a', 'swapcase') self.checkequal(True, 'a', 'islower') From python-checkins at python.org Thu May 25 23:58:06 2006 From: python-checkins at python.org (bob.ippolito) Date: Thu, 25 May 2006 23:58:06 +0200 (CEST) Subject: [Python-checkins] r46263 - in python/trunk/Modules/_ctypes/libffi/src: darwin darwin/ffitarget.h x86/darwin.S x86/ffi_darwin.c Message-ID: <20060525215806.2F1D91E400C@bag.python.org> Author: bob.ippolito Date: Thu May 25 23:58:05 2006 New Revision: 46263 Added: python/trunk/Modules/_ctypes/libffi/src/darwin/ python/trunk/Modules/_ctypes/libffi/src/darwin/ffitarget.h (contents, props changed) python/trunk/Modules/_ctypes/libffi/src/x86/darwin.S python/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c (contents, props changed) Log: Add missing files from x86 darwin ctypes patch Added: python/trunk/Modules/_ctypes/libffi/src/darwin/ffitarget.h ============================================================================== --- (empty file) +++ python/trunk/Modules/_ctypes/libffi/src/darwin/ffitarget.h Thu May 25 23:58:05 2006 @@ -0,0 +1,25 @@ +/* + * This file is for MacOSX only. Dispatch to the right architecture include + * file based on the current archictecture (instead of relying on a symlink + * created by configure). This makes is possible to build a univeral binary + * of ctypes in one go. + */ +#if defined(__i386__) + +#ifndef X86_DARWIN +#define X86_DARWIN +#endif +#undef POWERPC_DARWIN + +#include "../src/x86/ffitarget.h" + +#elif defined(__ppc__) + +#ifndef POWERPC_DARWIN +#define POWERPC_DARWIN +#endif +#undef X86_DARWIN + +#include "../src/powerpc/ffitarget.h" + +#endif Added: python/trunk/Modules/_ctypes/libffi/src/x86/darwin.S ============================================================================== --- (empty file) +++ python/trunk/Modules/_ctypes/libffi/src/x86/darwin.S Thu May 25 23:58:05 2006 @@ -0,0 +1,195 @@ +#ifdef __i386__ +/* ----------------------------------------------------------------------- + darwin.S - Copyright (c) 1996, 1998, 2001, 2002, 2003 Red Hat, Inc. + + X86 Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +/* + * This file is based on sysv.S and then hacked up by Ronald who hasn't done + * assembly programming in 8 years. + */ + +#ifndef __x86_64__ + +#define LIBFFI_ASM +#include +#include + +.text + +.globl _ffi_prep_args + +.align 4 +.globl _ffi_call_SYSV + +_ffi_call_SYSV: +.LFB1: + pushl %ebp +.LCFI0: + movl %esp,%ebp +.LCFI1: + /* Make room for all of the new args. */ + movl 16(%ebp),%ecx + subl %ecx,%esp + + movl %esp,%eax + + /* Place all of the ffi_prep_args in position */ + pushl 12(%ebp) + pushl %eax + call *8(%ebp) + + /* Return stack to previous state and call the function */ + addl $8,%esp + + call *28(%ebp) + + /* Remove the space we pushed for the args */ + movl 16(%ebp),%ecx + addl %ecx,%esp + + /* Load %ecx with the return type code */ + movl 20(%ebp),%ecx + + /* If the return value pointer is NULL, assume no return value. */ + cmpl $0,24(%ebp) + jne retint + + /* Even if there is no space for the return value, we are + obliged to handle floating-point values. */ + cmpl $FFI_TYPE_FLOAT,%ecx + jne noretval + fstp %st(0) + + jmp epilogue + +retint: + cmpl $FFI_TYPE_INT,%ecx + jne retfloat + /* Load %ecx with the pointer to storage for the return value */ + movl 24(%ebp),%ecx + movl %eax,0(%ecx) + jmp epilogue + +retfloat: + cmpl $FFI_TYPE_FLOAT,%ecx + jne retdouble + /* Load %ecx with the pointer to storage for the return value */ + movl 24(%ebp),%ecx + fstps (%ecx) + jmp epilogue + +retdouble: + cmpl $FFI_TYPE_DOUBLE,%ecx + jne retlongdouble + /* Load %ecx with the pointer to storage for the return value */ + movl 24(%ebp),%ecx + fstpl (%ecx) + jmp epilogue + +retlongdouble: + cmpl $FFI_TYPE_LONGDOUBLE,%ecx + jne retint64 + /* Load %ecx with the pointer to storage for the return value */ + movl 24(%ebp),%ecx + fstpt (%ecx) + jmp epilogue + +retint64: + cmpl $FFI_TYPE_SINT64,%ecx + jne retstruct + /* Load %ecx with the pointer to storage for the return value */ + movl 24(%ebp),%ecx + movl %eax,0(%ecx) + movl %edx,4(%ecx) + +retstruct: + /* Nothing to do! */ + +noretval: +epilogue: + movl %ebp,%esp + popl %ebp + ret +.LFE1: +.ffi_call_SYSV_end: +#if 0 + .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV +#endif + +#if 0 + .section .eh_frame,EH_FRAME_FLAGS, at progbits +.Lframe1: + .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ +.LSCIE1: + .long 0x0 /* CIE Identifier Tag */ + .byte 0x1 /* CIE Version */ +#ifdef __PIC__ + .ascii "zR\0" /* CIE Augmentation */ +#else + .ascii "\0" /* CIE Augmentation */ +#endif + .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */ + .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */ + .byte 0x8 /* CIE RA Column */ +#ifdef __PIC__ + .byte 0x1 /* .uleb128 0x1; Augmentation size */ + .byte 0x1b /* FDE Encoding (pcrel sdata4) */ +#endif + .byte 0xc /* DW_CFA_def_cfa */ + .byte 0x4 /* .uleb128 0x4 */ + .byte 0x4 /* .uleb128 0x4 */ + .byte 0x88 /* DW_CFA_offset, column 0x8 */ + .byte 0x1 /* .uleb128 0x1 */ + .align 4 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 /* FDE Length */ +.LASFDE1: + .long .LASFDE1-.Lframe1 /* FDE CIE offset */ +#ifdef __PIC__ + .long .LFB1-. /* FDE initial location */ +#else + .long .LFB1 /* FDE initial location */ +#endif + .long .LFE1-.LFB1 /* FDE address range */ +#ifdef __PIC__ + .byte 0x0 /* .uleb128 0x0; Augmentation size */ +#endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI0-.LFB1 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x8 /* .uleb128 0x8 */ + .byte 0x85 /* DW_CFA_offset, column 0x5 */ + .byte 0x2 /* .uleb128 0x2 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI1-.LCFI0 + .byte 0xd /* DW_CFA_def_cfa_register */ + .byte 0x5 /* .uleb128 0x5 */ + .align 4 +.LEFDE1: +#endif + +#endif /* ifndef __x86_64__ */ + +#endif /* defined __i386__ */ Added: python/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c ============================================================================== --- (empty file) +++ python/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c Thu May 25 23:58:05 2006 @@ -0,0 +1,610 @@ +# ifdef __i386__ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 1996, 1998, 1999, 2001 Red Hat, Inc. + Copyright (c) 2002 Ranjit Mathew + Copyright (c) 2002 Bo Thorsen + Copyright (c) 2002 Roger Sayle + + x86 Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#ifndef __x86_64__ + +#include +#include + +#include + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +/*@-exportheader@*/ +void ffi_prep_args(char *stack, extended_cif *ecif); + +static inline int retval_on_stack(ffi_type* tp) +{ + if (tp->type == FFI_TYPE_STRUCT) { + int sz = tp->size; + if (sz > 8) { + return 1; + } + switch (sz) { + case 1: case 2: case 4: case 8: return 0; + default: return 1; + } + } + return 0; +} + + +void ffi_prep_args(char *stack, extended_cif *ecif) +/*@=exportheader@*/ +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + if (retval_on_stack(ecif->cif->rtype)) { + *(void **) argp = ecif->rvalue; + argp += 4; + } + + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + i != 0; + i--, p_arg++) + { + size_t z; + + /* Align if necessary */ + if ((sizeof(int) - 1) & (unsigned) argp) + argp = (char *) ALIGN(argp, sizeof(int)); + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_SINT32: + *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv); + break; + + case FFI_TYPE_UINT32: + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + break; + + case FFI_TYPE_STRUCT: + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + break; + + default: + FFI_ASSERT(0); + } + } + else + { + memcpy(argp, *p_argv, z); + } + p_argv++; + argp += z; + } + + return; +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* Set the return type flag */ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: +#if !defined(X86_WIN32) + case FFI_TYPE_STRUCT: +#endif + case FFI_TYPE_SINT64: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + cif->flags = (unsigned) cif->rtype->type; + break; + + case FFI_TYPE_UINT64: + cif->flags = FFI_TYPE_SINT64; + break; + +#if defined X86_WIN32 + + case FFI_TYPE_STRUCT: + if (cif->rtype->size == 1) + { + cif->flags = FFI_TYPE_SINT8; /* same as char size */ + } + else if (cif->rtype->size == 2) + { + cif->flags = FFI_TYPE_SINT16; /* same as short size */ + } + else if (cif->rtype->size == 4) + { + cif->flags = FFI_TYPE_INT; /* same as int type */ + } + else if (cif->rtype->size == 8) + { + cif->flags = FFI_TYPE_SINT64; /* same as int64 type */ + } + else + { + cif->flags = FFI_TYPE_STRUCT; + } + break; +#endif + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + /* Darwin: The stack needs to be aligned to a multiple of 16 bytes */ +#if 0 + cif->bytes = (cif->bytes + 15) & ~0xF; +#endif + + return FFI_OK; +} + +/*@-declundef@*/ +/*@-exportheader@*/ +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)(void)); +/*@=declundef@*/ +/*@=exportheader@*/ + +#ifdef X86_WIN32 +/*@-declundef@*/ +/*@-exportheader@*/ +extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)(void)); +/*@=declundef@*/ +/*@=exportheader@*/ +#endif /* X86_WIN32 */ + +void ffi_call(/*@dependent@*/ ffi_cif *cif, + void (*fn)(), + /*@out@*/ void *rvalue, + /*@dependent@*/ void **avalue) +{ + extended_cif ecif; + int flags; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && retval_on_stack(cif->rtype)) + { + /*@-sysunrecog@*/ + ecif.rvalue = alloca(cif->rtype->size); + /*@=sysunrecog@*/ + } + else + ecif.rvalue = rvalue; + + flags = cif->flags; + if (flags == FFI_TYPE_STRUCT) { + if (cif->rtype->size == 8) { + flags = FFI_TYPE_SINT64; + } else if (cif->rtype->size == 4) { + flags = FFI_TYPE_INT; + } else if (cif->rtype->size == 2) { + flags = FFI_TYPE_INT; + } else if (cif->rtype->size == 1) { + flags = FFI_TYPE_INT; + } + } + + + switch (cif->abi) + { + case FFI_SYSV: + /*@-usedef@*/ + /* To avoid changing the assembly code make sure the size of the argument + * block is a multiple of 16. Then add 8 to compensate for local variables + * in ffi_call_SYSV. + */ + ffi_call_SYSV(ffi_prep_args, &ecif, ALIGN(cif->bytes, 16) +8, + flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#ifdef X86_WIN32 + case FFI_STDCALL: + /*@-usedef@*/ + ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#endif /* X86_WIN32 */ + default: + FFI_ASSERT(0); + break; + } +} + + +/** private members **/ + +static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, + void** args, ffi_cif* cif); +static void ffi_closure_SYSV (ffi_closure *) + __attribute__ ((regparm(1))); +#if !FFI_NO_RAW_API +static void ffi_closure_raw_SYSV (ffi_raw_closure *) + __attribute__ ((regparm(1))); +#endif + +/* This function is jumped to by the trampoline */ + +static void +ffi_closure_SYSV (closure) + ffi_closure *closure; +{ + // this is our return value storage + long double res; + + // our various things... + ffi_cif *cif; + void **arg_area; + unsigned short rtype; + void *resp = (void*)&res; + void *args = __builtin_dwarf_cfa (); + + cif = closure->cif; + arg_area = (void**) alloca (cif->nargs * sizeof (void*)); + + /* this call will initialize ARG_AREA, such that each + * element in that array points to the corresponding + * value on the stack; and if the function returns + * a structure, it will re-set RESP to point to the + * structure return address. */ + + ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif); + + (closure->fun) (cif, resp, arg_area, closure->user_data); + + rtype = cif->flags; + + if (!retval_on_stack(cif->rtype) && cif->flags == FFI_TYPE_STRUCT) { + if (cif->rtype->size == 8) { + rtype = FFI_TYPE_SINT64; + } else { + rtype = FFI_TYPE_INT; + } + } + + /* now, do a generic return based on the value of rtype */ + if (rtype == FFI_TYPE_INT) + { + asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); + } + else if (rtype == FFI_TYPE_FLOAT) + { + asm ("flds (%0)" : : "r" (resp) : "st" ); + } + else if (rtype == FFI_TYPE_DOUBLE) + { + asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); + } + else if (rtype == FFI_TYPE_LONGDOUBLE) + { + asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); + } + else if (rtype == FFI_TYPE_SINT64) + { + asm ("movl 0(%0),%%eax;" + "movl 4(%0),%%edx" + : : "r"(resp) + : "eax", "edx"); + } +#ifdef X86_WIN32 + else if (rtype == FFI_TYPE_SINT8) /* 1-byte struct */ + { + asm ("movsbl (%0),%%eax" : : "r" (resp) : "eax"); + } + else if (rtype == FFI_TYPE_SINT16) /* 2-bytes struct */ + { + asm ("movswl (%0),%%eax" : : "r" (resp) : "eax"); + } +#endif +} + +/*@-exportheader@*/ +static void +ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, + void **avalue, ffi_cif *cif) +/*@=exportheader@*/ +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + if (retval_on_stack(cif->rtype)) { + *rvalue = *(void **) argp; + argp += 4; + } + + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) + { + size_t z; + + /* Align if necessary */ + if ((sizeof(int) - 1) & (unsigned) argp) { + argp = (char *) ALIGN(argp, sizeof(int)); + } + + z = (*p_arg)->size; + + /* because we're little endian, this is what it turns into. */ + + *p_argv = (void*) argp; + + p_argv++; + argp += z; + } + + return; +} + +/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ + +#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ +({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned int __dis = __fun - ((unsigned int) __tramp + FFI_TRAMPOLINE_SIZE); \ + *(unsigned char*) &__tramp[0] = 0xb8; \ + *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \ + *(unsigned char *) &__tramp[5] = 0xe9; \ + *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \ + }) + + +/* the cif must already be prep'ed */ + +ffi_status +ffi_prep_closure (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data) +{ + FFI_ASSERT (cif->abi == FFI_SYSV); + + FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ + &ffi_closure_SYSV, \ + (void*)closure); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + +/* ------- Native raw API support -------------------------------- */ + +#if !FFI_NO_RAW_API + +static void +ffi_closure_raw_SYSV (closure) + ffi_raw_closure *closure; +{ + // this is our return value storage + long double res; + + // our various things... + ffi_raw *raw_args; + ffi_cif *cif; + unsigned short rtype; + void *resp = (void*)&res; + + /* get the cif */ + cif = closure->cif; + + /* the SYSV/X86 abi matches the RAW API exactly, well.. almost */ + raw_args = (ffi_raw*) __builtin_dwarf_cfa (); + + (closure->fun) (cif, resp, raw_args, closure->user_data); + + rtype = cif->flags; + + /* now, do a generic return based on the value of rtype */ + if (rtype == FFI_TYPE_INT) + { + asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); + } + else if (rtype == FFI_TYPE_FLOAT) + { + asm ("flds (%0)" : : "r" (resp) : "st" ); + } + else if (rtype == FFI_TYPE_DOUBLE) + { + asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); + } + else if (rtype == FFI_TYPE_LONGDOUBLE) + { + asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); + } + else if (rtype == FFI_TYPE_SINT64) + { + asm ("movl 0(%0),%%eax; movl 4(%0),%%edx" + : : "r"(resp) + : "eax", "edx"); + } +} + + + + +ffi_status +ffi_prep_raw_closure (ffi_raw_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data) +{ + int i; + + FFI_ASSERT (cif->abi == FFI_SYSV); + + // we currently don't support certain kinds of arguments for raw + // closures. This should be implemented by a separate assembly language + // routine, since it would require argument processing, something we + // don't do now for performance. + + for (i = cif->nargs-1; i >= 0; i--) + { + FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT); + FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE); + } + + + FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV, + (void*)closure); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + +static void +ffi_prep_args_raw(char *stack, extended_cif *ecif) +{ + memcpy (stack, ecif->avalue, ecif->cif->bytes); +} + +/* we borrow this routine from libffi (it must be changed, though, to + * actually call the function passed in the first argument. as of + * libffi-1.20, this is not the case.) + */ + +extern void +ffi_call_SYSV(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)()); + +#ifdef X86_WIN32 +extern void +ffi_call_STDCALL(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)()); +#endif /* X86_WIN32 */ + +void +ffi_raw_call(/*@dependent@*/ ffi_cif *cif, + void (*fn)(), + /*@out@*/ void *rvalue, + /*@dependent@*/ ffi_raw *fake_avalue) +{ + extended_cif ecif; + void **avalue = (void **)fake_avalue; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && retval_on_stack(cif->rtype)) + { + /*@-sysunrecog@*/ + ecif.rvalue = alloca(cif->rtype->size); + /*@=sysunrecog@*/ + } + else + ecif.rvalue = rvalue; + + + switch (cif->abi) + { + case FFI_SYSV: + /*@-usedef@*/ + ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#ifdef X86_WIN32 + case FFI_STDCALL: + /*@-usedef@*/ + ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#endif /* X86_WIN32 */ + default: + FFI_ASSERT(0); + break; + } +} + +#endif + +#endif /* __x86_64__ */ + +#endif /* __i386__ */ From python-checkins at python.org Fri May 26 00:00:15 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 26 May 2006 00:00:15 +0200 (CEST) Subject: [Python-checkins] r46264 - python/trunk/Modules/grpmodule.c Message-ID: <20060525220015.0D1791E4018@bag.python.org> Author: brett.cannon Date: Fri May 26 00:00:14 2006 New Revision: 46264 Modified: python/trunk/Modules/grpmodule.c Log: Move over to use of METH_O and METH_NOARGS. Modified: python/trunk/Modules/grpmodule.c ============================================================================== --- python/trunk/Modules/grpmodule.c (original) +++ python/trunk/Modules/grpmodule.c Fri May 26 00:00:14 2006 @@ -84,12 +84,18 @@ } static PyObject * -grp_getgrgid(PyObject *self, PyObject *args) +grp_getgrgid(PyObject *self, PyObject *pyo_id) { + PyObject *py_int_id; unsigned int gid; struct group *p; - if (!PyArg_ParseTuple(args, "I:getgrgid", &gid)) - return NULL; + + py_int_id = PyNumber_Int(pyo_id); + if (!py_int_id) + return NULL; + gid = PyInt_AS_LONG(py_int_id); + Py_DECREF(py_int_id); + if ((p = getgrgid(gid)) == NULL) { PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid); return NULL; @@ -98,27 +104,33 @@ } static PyObject * -grp_getgrnam(PyObject *self, PyObject *args) +grp_getgrnam(PyObject *self, PyObject *pyo_name) { + PyObject *py_str_name; char *name; struct group *p; - if (!PyArg_ParseTuple(args, "s:getgrnam", &name)) - return NULL; + + py_str_name = PyObject_Str(pyo_name); + if (!py_str_name) + return NULL; + name = PyString_AS_STRING(py_str_name); + if ((p = getgrnam(name)) == NULL) { PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name); + Py_DECREF(py_str_name); return NULL; } + + Py_DECREF(py_str_name); return mkgrent(p); } static PyObject * -grp_getgrall(PyObject *self, PyObject *args) +grp_getgrall(PyObject *self, PyObject *ignore) { PyObject *d; struct group *p; - if (!PyArg_ParseTuple(args, ":getgrall")) - return NULL; if ((d = PyList_New(0)) == NULL) return NULL; setgrent(); @@ -136,15 +148,15 @@ } static PyMethodDef grp_methods[] = { - {"getgrgid", grp_getgrgid, METH_VARARGS, + {"getgrgid", grp_getgrgid, METH_O, "getgrgid(id) -> tuple\n\ Return the group database entry for the given numeric group ID. If\n\ id is not valid, raise KeyError."}, - {"getgrnam", grp_getgrnam, METH_VARARGS, + {"getgrnam", grp_getgrnam, METH_O, "getgrnam(name) -> tuple\n\ Return the group database entry for the given group name. If\n\ name is not valid, raise KeyError."}, - {"getgrall", grp_getgrall, METH_VARARGS, + {"getgrall", grp_getgrall, METH_NOARGS, "getgrall() -> list of tuples\n\ Return a list of all available group entries, in arbitrary order."}, {NULL, NULL} /* sentinel */ From buildbot at python.org Fri May 26 00:06:38 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 22:06:38 +0000 Subject: [Python-checkins] buildbot failure in x86 W2k trunk Message-ID: <20060525220638.2A1561E400B@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/786 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters BUILD FAILED: failed compile sincerely, -The Buildbot From fredrik at pythonware.com Fri May 26 00:17:34 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 00:17:34 +0200 Subject: [Python-checkins] whatever happened to string.partition ? Message-ID: does anyone remember? given what we're currently working on, implementing it would take roughly no time at all. do people still think it's a good idea ? From buildbot at python.org Fri May 26 00:19:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 22:19:13 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20060525221913.6DD821E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/786 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,brett.cannon,tim.peters BUILD FAILED: failed compile sincerely, -The Buildbot From fredrik at pythonware.com Fri May 26 00:18:27 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 00:18:27 +0200 Subject: [Python-checkins] buildbot failure in x86 W2k trunk In-Reply-To: <20060525220638.2A1561E400B@bag.python.org> References: <20060525220638.2A1561E400B@bag.python.org> Message-ID: buildbot at python.org wrote: > The Buildbot has detected a new failure of x86 W2k trunk. > Full details are available at: > http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/786 > > Buildbot URL: http://www.python.org/dev/buildbot/all/ > > Build Reason: > Build Source Stamp: [branch trunk] HEAD > Blamelist: tim.peters muhaha! From mwh at python.net Fri May 26 00:22:45 2006 From: mwh at python.net (Michael Hudson) Date: Thu, 25 May 2006 23:22:45 +0100 Subject: [Python-checkins] r46248 - python/trunk/Modules/_struct.c In-Reply-To: <20060525195657.22E211E400B@bag.python.org> (bob ippolito's message of "Thu, 25 May 2006 21:56:57 +0200 (CEST)") References: <20060525195657.22E211E400B@bag.python.org> Message-ID: <2mr72h3ft6.fsf@starship.python.net> "bob.ippolito" writes: > Author: bob.ippolito > Date: Thu May 25 21:56:56 2006 > New Revision: 46248 > > Modified: > python/trunk/Modules/_struct.c > Log: > Use faster struct pack/unpack functions for the endian table that > matches the host's Waa, be a little careful here; it is at least potentially possible that struct.pack(' References: <20060525220638.2A1561E400B@bag.python.org> Message-ID: On 5/25/06, Fredrik Lundh wrote: > > buildbot at python.org wrote: > > > The Buildbot has detected a new failure of x86 W2k trunk. > > Full details are available at: > > http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/786 > > > > Buildbot URL: http://www.python.org/dev/buildbot/all/ > > > > Build Reason: > > Build Source Stamp: [branch trunk] HEAD > > Blamelist: tim.peters > > muhaha! I have to admit it was nice to look at Buildbot and notice that the XP failures started with Tim and are not my fault. =) -Brett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060525/7f41eb35/attachment.htm From rhettinger at ewtllc.com Fri May 26 00:23:51 2006 From: rhettinger at ewtllc.com (Raymond Hettinger) Date: Thu, 25 May 2006 15:23:51 -0700 Subject: [Python-checkins] whatever happened to string.partition ? In-Reply-To: References: Message-ID: <44762E77.3080303@ewtllc.com> Fredrik Lundh wrote: >does anyone remember? given what we're currently working on, >implementing it would take roughly no time at all. do people still >think it's a good idea ? > > > > > Yes. It went to my todo list and is awaiting some free raymond-cycles to finish it up. I've been task saturated of late but would like to get this a number of other patches complete for Py2.5. Also, Crutcher had long ago posted a patch for exec/eval to accept generic mapping arguments. If someone like Tim or /F has the time, feel free to pick it up. Raymond From python-checkins at python.org Fri May 26 00:25:25 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 00:25:25 +0200 (CEST) Subject: [Python-checkins] r46265 - python/trunk/Modules/timemodule.c Message-ID: <20060525222525.9FC921E400F@bag.python.org> Author: tim.peters Date: Fri May 26 00:25:25 2006 New Revision: 46265 Modified: python/trunk/Modules/timemodule.c Log: Repair idiot typo, and complete the job of trying to use the Windows time.clock() implementation on Win64. Modified: python/trunk/Modules/timemodule.c ============================================================================== --- python/trunk/Modules/timemodule.c (original) +++ python/trunk/Modules/timemodule.c Fri May 26 00:25:25 2006 @@ -64,8 +64,8 @@ #endif /* !__WATCOMC__ || __QNX__ */ #if defined(MS_WINDOWS) && !defined(__BORLANDC__) -/* Win32 has better clock replacement -#undef HAVE_CLOCK /* We have our own version down below */ +/* Win32 has better clock replacement; we have our own version below. */ +#undef HAVE_CLOCK #endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #if defined(PYOS_OS2) @@ -161,7 +161,7 @@ } #endif /* HAVE_CLOCK */ -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) +#if defined(MS_WINDOWS) && !defined(__BORLANDC__) /* Due to Mark Hammond and Tim Peters */ static PyObject * time_clock(PyObject *self, PyObject *args) @@ -190,7 +190,7 @@ } #define HAVE_CLOCK /* So it gets included in the methods */ -#endif /* MS_WINDOWS && !MS_WIN64 */ +#endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #ifdef HAVE_CLOCK PyDoc_STRVAR(clock_doc, From mwh at python.net Fri May 26 00:26:30 2006 From: mwh at python.net (Michael Hudson) Date: Thu, 25 May 2006 23:26:30 +0100 Subject: [Python-checkins] r46248 - python/trunk/Modules/_struct.c In-Reply-To: <2mr72h3ft6.fsf@starship.python.net> (Michael Hudson's message of "Thu, 25 May 2006 23:22:45 +0100") References: <20060525195657.22E211E400B@bag.python.org> <2mr72h3ft6.fsf@starship.python.net> Message-ID: <2mmzd53fmx.fsf@starship.python.net> Michael Hudson writes: > "bob.ippolito" writes: > >> Author: bob.ippolito >> Date: Thu May 25 21:56:56 2006 >> New Revision: 46248 >> >> Modified: >> python/trunk/Modules/_struct.c >> Log: >> Use faster struct pack/unpack functions for the endian table that >> matches the host's > > Waa, be a little careful here; it is at least potentially possible > that struct.pack(' different output, even when the endianness would suggest they should > be the same, because the ' produce an IEEE 8 byte double even if that's not what the host > uses natively. "Never mind!" -- I see test_float found this out for you already. Unit tests are great :) Cheers, mwh -- Exam invigilation - it doesn't come much harder than that, esp if the book you're reading turns out to be worse than expected. -- Dirk Bruere, sci.physics.research From python-checkins at python.org Fri May 26 00:28:46 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 00:28:46 +0200 (CEST) Subject: [Python-checkins] r46266 - python/trunk/Objects/longobject.c Message-ID: <20060525222846.614E61E400B@bag.python.org> Author: tim.peters Date: Fri May 26 00:28:46 2006 New Revision: 46266 Modified: python/trunk/Objects/longobject.c Log: Patch #1494387: SVN longobject.c compiler warnings The SIGCHECK macro defined here has always been bizarre, but it apparently causes compiler warnings on "Sun Studio 11". I believe the warnings are bogus, but it doesn't hurt to make the macro definition saner. Bugfix candidate (but I'm not going to bother). Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Fri May 26 00:28:46 2006 @@ -40,7 +40,7 @@ #define SIGCHECK(PyTryBlock) \ if (--_Py_Ticker < 0) { \ _Py_Ticker = _Py_CheckInterval; \ - if (PyErr_CheckSignals()) { PyTryBlock; } \ + if (PyErr_CheckSignals()) PyTryBlock \ } /* Normalize (remove leading zeros from) a long int object. From fredrik at pythonware.com Fri May 26 00:31:49 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 00:31:49 +0200 Subject: [Python-checkins] whatever happened to string.partition ? In-Reply-To: <44762E77.3080303@ewtllc.com> References: <44762E77.3080303@ewtllc.com> Message-ID: Raymond Hettinger wrote: >> does anyone remember? given what we're currently working on, >> implementing it would take roughly no time at all. do people still >> think it's a good idea ? > Yes. It went to my todo list and is awaiting some free raymond-cycles > to finish it up. I've been task saturated of late but would like to get > this a number of other patches complete for Py2.5. no need to wait for any raymond-cycles here; just point me to the latest version of the proposal, and it'll be in the trunk within 30 minutes. From tim.peters at gmail.com Fri May 26 00:34:05 2006 From: tim.peters at gmail.com (Tim Peters) Date: Thu, 25 May 2006 22:34:05 +0000 Subject: [Python-checkins] buildbot failure in x86 W2k trunk In-Reply-To: References: <20060525220638.2A1561E400B@bag.python.org> Message-ID: <1f7befae0605251534p349328cdq8712578bcf12771a@mail.gmail.com> > buildbot at python.org wrote: >> The Buildbot has detected a new failure of x86 W2k trunk. >> Full details are available at: >> http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/786 >> >> Buildbot URL: http://www.python.org/dev/buildbot/all/ >> >> Build Reason: >> Build Source Stamp: [branch trunk] HEAD >> Blamelist: tim.peters [/F] > muhaha! Oh, come on. The _real_ timbot went to bed hours ago, as you well know. The fake timbot made such a trivial change he didn't even bother to compile timemodule.c before checking it in, not noticing that it actually made the module uncompiliable on Windows. We all know the real timbot would never do that. Apology accepted ;-) From steve at holdenweb.com Fri May 26 00:36:24 2006 From: steve at holdenweb.com (Steve Holden) Date: Thu, 25 May 2006 23:36:24 +0100 Subject: [Python-checkins] This In-Reply-To: <44762E77.3080303@ewtllc.com> References: <44762E77.3080303@ewtllc.com> Message-ID: <44763168.4030308@holdenweb.com> Raymond Hettinger wrote: > Fredrik Lundh wrote: > > >>does anyone remember? given what we're currently working on, >>implementing it would take roughly no time at all. do people still >>think it's a good idea ? >> >> >> >> >> > > > Yes. It went to my todo list and is awaiting some free raymond-cycles > to finish it up. I've been task saturated of late but would like to get > this a number of other patches complete for Py2.5. > > Also, Crutcher had long ago posted a patch for exec/eval to accept > generic mapping arguments. If someone like Tim or /F has the time, > feel free to pick it up. > This reminds me I am tasked with trying to find out what the interface to timeit.py is supposed to look like. Raymond, your name has been mentioned as someone who took part int he discussions. Google hasn't given me a lot to go on. Anyone? [Follow-ups to python-dev would be best, I suspect]. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From fredrik at pythonware.com Fri May 26 00:36:17 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 00:36:17 +0200 Subject: [Python-checkins] whatever happened to string.partition ? In-Reply-To: References: <44762E77.3080303@ewtllc.com> Message-ID: Fredrik Lundh wrote: > no need to wait for any raymond-cycles here; just point me to the latest > version of the proposal, and it'll be in the trunk within 30 minutes. are these still valid? http://mail.python.org/pipermail/python-dev/2005-August/055764.html http://mail.python.org/pipermail/python-dev/2005-August/055770.html From rhettinger at ewtllc.com Fri May 26 00:45:27 2006 From: rhettinger at ewtllc.com (Raymond Hettinger) Date: Thu, 25 May 2006 15:45:27 -0700 Subject: [Python-checkins] whatever happened to string.partition ? In-Reply-To: References: <44762E77.3080303@ewtllc.com> Message-ID: <44763387.80308@ewtllc.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060525/108269cb/attachment.html From rhettinger at ewtllc.com Fri May 26 00:49:43 2006 From: rhettinger at ewtllc.com (Raymond Hettinger) Date: Thu, 25 May 2006 15:49:43 -0700 Subject: [Python-checkins] This In-Reply-To: <44763168.4030308@holdenweb.com> References: <44762E77.3080303@ewtllc.com> <44763168.4030308@holdenweb.com> Message-ID: <44763487.3080908@ewtllc.com> Steve Holden wrote: > > This reminds me I am tasked with trying to find out what the interface > to timeit.py is supposed to look like. Raymond, your name has been > mentioned as someone who took part int he discussions. Google hasn't > given me a lot to go on. Anyone? > IIRC, Guido's words were that too much to the smarts in timeit.py were in the command-line interface and not in the Timer object were in should be. So, this should be a simple refactoring exercise to expose more of the existing API. No inventiveness is required. While you're at it, please document the import trick or testing existing code without copying it in to a text string. Raymond From fredrik at pythonware.com Fri May 26 00:56:28 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 00:56:28 +0200 Subject: [Python-checkins] whatever happened to string.partition ? In-Reply-To: <44763387.80308@ewtllc.com> References: <44762E77.3080303@ewtllc.com> <44763387.80308@ewtllc.com> Message-ID: Raymond Hettinger wrote: > IIRC, Skip had developed a smart version that returned lazy string > objects that kept a reference and pointers to the original string > (instead of making its own copy of the string components). The string > subclass would expand itself and free the reference if necessary for a > subsequent string operation. The main purpose was to handle the cases > where one fragment of the other was never used or just had a length > check. Also it was helpful when partition was used lisp-style to > repeatedly break-off head/tail fragments. that sounds nice in theory, but I completely fail to see how that can be implemented without ripping out the existing string object and replacing it with something entirely different, or (via horrible macro tricks) slow down virtually all other use of PyStringObject. skip? was this a real design or a Py3K bluesky idea? From python-checkins at python.org Fri May 26 01:25:40 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 01:25:40 +0200 (CEST) Subject: [Python-checkins] r46267 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060525232540.57CAF1E400B@bag.python.org> Author: richard.jones Date: Fri May 26 01:25:39 2006 New Revision: 46267 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Now runs unit tests without dumping core or a Fatal Error, so I'm retiring for the night. Fixing the unit tests is next on the agenda. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 01:25:39 2006 @@ -40,6 +40,31 @@ return (PyObject *)self; } +static int +BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +{ + if (!args) { + self->args = PyTuple_New(0); + if (!self->args) { + return -1; + } + } + else + self->args = args; + Py_INCREF(self->args); + + if (PySequence_Length(self->args) == 1) + self->message = PySequence_GetItem(self->args, 0); + else + self->message = PyString_FromString(""); + if (!self->message) { + Py_DECREF(self->args); + return -1; + } + + return 0; +} + static void BaseException_dealloc(BaseExceptionObject *self) { @@ -217,7 +242,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, 0, 0, BaseException_new,\ + 0, 0, 0, 0, (initproc)BaseException_init, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -231,7 +256,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, 0, 0, EXCSTORE ## _new,\ + 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -246,7 +271,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ EXCDOC, \ 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, 0, 0, EXCSTORE ## _new,\ + 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -312,6 +337,19 @@ return (PyObject *)self; } +static int +SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) +{ + if (PySequence_Length(args) == 1) + self->code = PySequence_GetItem(args, 0); + else { + self->code = Py_None; + Py_INCREF(Py_None); + } + + return 0; +} + static void SystemExit_dealloc(SystemExitObject *self) { @@ -352,22 +390,11 @@ PyObject *filename; } EnvironmentErrorObject; -static PyObject * -EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static int +_EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, + PyObject *kwds) { PyObject *subslice = NULL; - EnvironmentErrorObject *self = NULL; - - self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - self->myerrno = Py_None; - Py_INCREF(Py_None); - self->strerror = Py_None; - Py_INCREF(Py_None); - self->filename = Py_None; - Py_INCREF(Py_None); switch (PySequence_Size(args)) { case 3: @@ -383,39 +410,63 @@ * when it was supplied. */ self->myerrno = PySequence_GetItem(args, 0); - if (!self->myerrno) goto finally; + if (!self->myerrno) return -1; self->strerror = PySequence_GetItem(args, 1); - if (!self->strerror) goto finally; + if (!self->strerror) return -1; self->filename = PySequence_GetItem(args, 2); - if (!self->filename) goto finally; + if (!self->filename) return -1; subslice = PySequence_GetSlice(args, 0, 2); if (!subslice) - goto finally; + return -1; Py_DECREF(self->args); /* replacing args */ self->args = subslice; - return (PyObject *)self; + return 0; case 2: /* Used when PyErr_SetFromErrno() is called and no filename * argument is given. */ self->myerrno = PySequence_GetItem(args, 0); - if (!self->myerrno) goto finally; + if (!self->myerrno) return -1; self->strerror = PySequence_GetItem(args, 1); - if (!self->strerror) goto finally; - return (PyObject *)self; + if (!self->strerror) return -1; + return 0; case -1: PyErr_Clear(); } + return 0; +} + +static PyObject * +EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + EnvironmentErrorObject *self = NULL; + + self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; + + self->myerrno = Py_None; + Py_INCREF(Py_None); + self->strerror = Py_None; + Py_INCREF(Py_None); + self->filename = Py_None; + Py_INCREF(Py_None); + + if (_EnvironmentError_init(self, args, kwds) == -1) { + PyErr_Clear(); + } return (PyObject *)self; +} - finally: - Py_XDECREF(subslice); - Py_XDECREF(self); - return NULL; +static int +EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, + PyObject *kwds) +{ + return _EnvironmentError_init(self, args, kwds); } static void @@ -526,7 +577,7 @@ self = (WindowsErrorObject *)EnvironmentError_new(type, args, kwds); if (!self) - return -1; + return NULL; /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ @@ -551,6 +602,31 @@ return NULL; } +static int +WindowsError_init(WindowsErrorObject *self, PyObject *args, PyObject *kwds) +{ + if (EnvironmentError_init((EnvironmentErrorObject *)self, args, + kwds) == -1) + return -1; + + /* Set errno to the POSIX errno, and winerror to the Win32 + error code. */ + errcode = PyInt_AsLong(self->myerrno); + if (!errcode == -1 && PyErr_Occurred()) + return -1; + posix_errno = winerror_to_errno(errcode); + + self->winerror = self->myerrno; + + o_errcode = PyInt_FromLong(posix_errno); + if (!o_errcode) + return -1; + + self->myerrno = o_errcode; + + return 0; +} + static PyObject * WindowsError_str(PyObject *self) @@ -667,12 +743,37 @@ PyObject *print_file_and_line; } SyntaxErrorObject; +static int +_SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *info = NULL; + Py_ssize_t lenargs; + + lenargs = PySequence_Size(args); + if (lenargs >= 1) { + PyObject *item0 = PySequence_GetItem(args, 0); + if (!item0) return -1; + self->msg = item0; + } + if (lenargs == 2) { + info = PySequence_GetItem(args, 1); + if (!info) return -1; + self->filename = PySequence_GetItem(info, 0); + if (!self->filename) return -1; + self->lineno = PySequence_GetItem(info, 1); + if (!self->lineno) return -1; + self->offset = PySequence_GetItem(info, 2); + if (!self->offset) return -1; + self->text = PySequence_GetItem(info, 3); + if (!self->text) return -1; + } + return 0; +} + static PyObject * SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *info = NULL; SyntaxErrorObject *self = NULL; - Py_ssize_t lenargs; self = (SyntaxErrorObject *)BaseException_new(type, args, kwds); if (!self) @@ -686,32 +787,17 @@ self->print_file_and_line = Py_None; Py_INCREF(Py_None); - lenargs = PySequence_Size(args); - if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - if (!item0) goto finally; - self->msg = item0; - } - if (lenargs == 2) { - info = PySequence_GetItem(args, 1); - if (!info) goto finally; - self->filename = PySequence_GetItem(info, 0); - if (!self->filename) goto finally; - self->lineno = PySequence_GetItem(info, 1); - if (!self->lineno) goto finally; - self->offset = PySequence_GetItem(info, 2); - if (!self->offset) goto finally; - self->text = PySequence_GetItem(info, 3); - if (!self->text) goto finally; - } - return (PyObject *)self; + if (_SyntaxError_init(self, args, kwds) == -1) + PyErr_Clear(); - finally: - Py_XDECREF(info); - Py_XDECREF(self); - return NULL; + return (PyObject *)self; } +static int +SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) +{ + return _SyntaxError_init(self, args, kwds); +} static void SyntaxError_dealloc(SyntaxErrorObject *self) @@ -890,6 +976,11 @@ static int get_int(PyObject *attr, Py_ssize_t *value, const char *name) { + if (!attr) { + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + return -1; + } + if (PyInt_Check(attr)) { *value = PyInt_AS_LONG(attr); } else if (PyLong_Check(attr)) { @@ -917,6 +1008,11 @@ static PyObject *get_string(PyObject *attr, const char *name) { + if (!attr) { + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + return NULL; + } + if (!PyString_Check(attr)) { PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); return NULL; @@ -941,6 +1037,11 @@ static PyObject *get_unicode(PyObject *attr, const char *name) { + if (!attr) { + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + return NULL; + } + if (!PyUnicode_Check(attr)) { PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); return NULL; @@ -1118,23 +1219,34 @@ static PyObject * -UnicodeError_new(PyTypeObject *type, PyObject *args, PyTypeObject *objecttype) +UnicodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) { UnicodeErrorObject *self; + Py_ssize_t n; - self = (UnicodeErrorObject *)BaseException_new(type, args, NULL); + self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; self->encoding = self->object = self->start = self->end = self->reason = NULL; + n = PySequence_Size(args); + if (n == -1 && PyErr_Occurred()) { + Py_DECREF(self); + return NULL; + } + if (n == 0) + return (PyObject *)self; + if (!PyArg_ParseTuple(args, "O!O!O!O!O!", &PyString_Type, &self->encoding, objecttype, &self->object, &PyInt_Type, &self->start, &PyInt_Type, &self->end, &PyString_Type, &self->reason)) { + self->encoding = self->object = self->start = self->end = + self->reason = NULL; Py_DECREF(self); return NULL; } @@ -1148,6 +1260,29 @@ return (PyObject *)self; } +static int +UnicodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) +{ + if (!PyArg_ParseTuple(args, "O!O!O!O!O!", + &PyString_Type, &self->encoding, + objecttype, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { + self->encoding = self->object = self->start = self->end = + self->reason = NULL; + return -1; + } + + Py_INCREF(self->encoding); + Py_INCREF(self->object); + Py_INCREF(self->start); + Py_INCREF(self->end); + Py_INCREF(self->reason); + + return 0; +} + static void UnicodeError_dealloc(UnicodeErrorObject *self) { @@ -1177,7 +1312,13 @@ static PyObject * UnicodeEncodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - return UnicodeError_new(type, args, &PyUnicode_Type); + return UnicodeError_new(type, args, kwds, &PyUnicode_Type); +} + +static int +UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyUnicode_Type); } static PyObject * @@ -1228,7 +1369,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, "Unicode encoding error.", 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, 0, 0, UnicodeEncodeError_new, + 0, 0, 0, 0, (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -1247,7 +1388,13 @@ static PyObject * UnicodeDecodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - return UnicodeError_new(type, args, &PyString_Type); + return UnicodeError_new(type, args, kwds, &PyString_Type); +} + +static int +UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyString_Type); } static PyObject * @@ -1294,7 +1441,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, "Unicode decoding error.", 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, 0, 0, UnicodeDecodeError_new, + 0, 0, 0, 0, (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -1317,16 +1464,29 @@ UnicodeTranslateError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { UnicodeErrorObject *self = NULL; + Py_ssize_t n; self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; + self->encoding = self->object = self->start = self->end = + self->reason = NULL; + + n = PySequence_Size(args); + if (n == -1 && PyErr_Occurred()) { + Py_DECREF(self); + return NULL; + } + if (n == 0) + return (PyObject *)self; + if (!PyArg_ParseTuple(args, "O!O!O!O!", &PyUnicode_Type, &self->object, &PyInt_Type, &self->start, &PyInt_Type, &self->end, &PyString_Type, &self->reason)) { + self->object = self->start = self->end = self->reason = NULL; Py_DECREF(self); return NULL; } @@ -1341,6 +1501,28 @@ return (PyObject *)self; } +static int +UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +{ + if (!PyArg_ParseTuple(args, "O!O!O!O!", + &PyUnicode_Type, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { + self->object = self->start = self->end = self->reason = NULL; + return -1; + } + + self->encoding = Py_None; + Py_INCREF(self->encoding); + Py_INCREF(self->object); + Py_INCREF(self->start); + Py_INCREF(self->end); + Py_INCREF(self->reason); + + return 0; +} + static PyObject * UnicodeTranslateError_str(PyObject *self) @@ -1388,7 +1570,7 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, "Unicode decoding error.", 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, 0, 0, UnicodeTranslateError_new, + 0, 0, 0, 0, (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; From python-checkins at python.org Fri May 26 01:27:54 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 01:27:54 +0200 (CEST) Subject: [Python-checkins] r46268 - python/trunk/Objects/stringobject.c Message-ID: <20060525232754.49C4C1E400B@bag.python.org> Author: fredrik.lundh Date: Fri May 26 01:27:53 2006 New Revision: 46268 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: partition for 8-bit strings. for some simple tests, this is on par with a corresponding find, and nearly twice as fast as split(sep, 1) full tests, a unicode version, and documentation will follow to- morrow. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 01:27:53 2006 @@ -799,8 +799,7 @@ #define FAST_SEARCH 1 LOCAL(Py_ssize_t) - fastsearch(const char* s, Py_ssize_t n, const char* p, - Py_ssize_t m, int mode) +fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) { long mask; int skip, count = 0; @@ -860,10 +859,8 @@ /* miss: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) i = i + m; - else { + else i = i + skip; - continue; - } } else { /* skip: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) @@ -1601,6 +1598,68 @@ return NULL; } +PyDoc_STRVAR(partition__doc__, +"S.partition(sep) -> (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, and returns the part before it,\n\ +the separator itself, and the part after it. If the separator is not\n\ +found, returns S and two empty strings."); + +static PyObject * +string_partition(PyStringObject *self, PyObject *args) +{ + Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; + const char *str = PyString_AS_STRING(self), *sep; + PyObject *sepobj; + PyObject * out; + + if (!PyArg_ParseTuple(args, "O:partition", &sepobj)) + return NULL; + if (PyString_Check(sepobj)) { + sep = PyString_AS_STRING(sepobj); + sep_len = PyString_GET_SIZE(sepobj); + } +#ifdef Py_USING_UNICODE_NOTYET + else if (PyUnicode_Check(sepobj)) + return PyUnicode_Partition((PyObject *)self, sepobj); +#endif + else if (PyObject_AsCharBuffer(sepobj, &sep, &sep_len)) + return NULL; + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + return NULL; + } + + out = PyTuple_New(3); + if (!out) + return NULL; + + pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); + if (pos < 0) { + Py_INCREF(self); + PyTuple_SET_ITEM(out, 0, (PyObject*) self); + Py_INCREF(nullstring); + PyTuple_SET_ITEM(out, 1, (PyObject*) nullstring); + Py_INCREF(nullstring); + PyTuple_SET_ITEM(out, 2, (PyObject*) nullstring); + } else { + Py_INCREF(sepobj); + PyTuple_SET_ITEM(out, 0, PyString_FromStringAndSize(str, pos)); + PyTuple_SET_ITEM(out, 1, sepobj); + PyTuple_SET_ITEM(out, 2, + PyString_FromStringAndSize(str + sep_len + pos, + len - sep_len - pos) + ); + if (PyErr_Occurred()) { + Py_DECREF(out); + return NULL; + } + } + + return out; +} + static PyObject * rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { @@ -3910,6 +3969,8 @@ {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, {"endswith", (PyCFunction)string_endswith, METH_VARARGS, endswith__doc__}, + {"partition", (PyCFunction)string_partition, METH_VARARGS, + partition__doc__}, {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, {"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__}, From buildbot at python.org Fri May 26 01:37:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 25 May 2006 23:37:02 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060525233702.70DA21E400B@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/299 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,bob.ippolito,brett.cannon,fredrik.lundh,georg.brandl,jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 02:24:23 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 02:24:23 +0200 (CEST) Subject: [Python-checkins] r46269 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526002423.F12CB1E400B@bag.python.org> Author: georg.brandl Date: Fri May 26 02:24:23 2006 New Revision: 46269 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Review; add some comments. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 02:24:23 2006 @@ -12,6 +12,15 @@ PyObject *message; } BaseExceptionObject; +/* GB: - PyTuple_* would be faster than PySequence_* + - should use PyDoc_STR() macros for docstrings + - I don't know, but it may be that the exceptions + have to be GC objects + - If you want to allow normal attribute access, + I think you can use PyObject_GenericGetAttr etc. + in the tp_getattr... slots. +*/ + static PyObject * BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -30,12 +39,14 @@ } else self->args = args; + /* GB: Isn't the tuple INCREFd twice? */ Py_INCREF(self->args); if (PySequence_Length(self->args) == 1) self->message = PySequence_GetItem(self->args, 0); else - self->message = PyString_FromString(""); + self->message = PyString_FromString(""); + /* GB: error check */ return (PyObject *)self; } @@ -51,16 +62,17 @@ } else self->args = args; + /* GB: tuple/INCREF */ Py_INCREF(self->args); if (PySequence_Length(self->args) == 1) self->message = PySequence_GetItem(self->args, 0); else - self->message = PyString_FromString(""); - if (!self->message) { - Py_DECREF(self->args); - return -1; - } + self->message = PyString_FromString(""); + if (!self->message) { + Py_DECREF(self->args); + return -1; + } return 0; } @@ -70,6 +82,7 @@ { Py_XDECREF(self->args); Py_XDECREF(self->message); + /* GB: call tp_free? */ } @@ -105,6 +118,7 @@ } +/* GB: does _unicode have/need an argument? */ #ifdef Py_USING_UNICODE static PyObject * BaseException_unicode(BaseExceptionObject *self, PyObject *args) @@ -330,7 +344,7 @@ if (PySequence_Length(args) == 1) self->code = PySequence_GetItem(args, 0); else { - self->code = Py_None; + self->code = Py_None; Py_INCREF(Py_None); } @@ -353,6 +367,7 @@ static void SystemExit_dealloc(SystemExitObject *self) { + /* GB: shouldn't the decref come first? */ BaseException_dealloc((BaseExceptionObject *)self); Py_DECREF(self->code); } @@ -412,6 +427,8 @@ self->myerrno = PySequence_GetItem(args, 0); if (!self->myerrno) return -1; self->strerror = PySequence_GetItem(args, 1); + /* GB: in error cases, you're leaking refs to myerrno etc. + and perhaps you should be clearing self->... too on error */ if (!self->strerror) return -1; self->filename = PySequence_GetItem(args, 2); if (!self->filename) return -1; @@ -420,6 +437,7 @@ if (!subslice) return -1; + /* GB: can it be that self->args is NULL? */ Py_DECREF(self->args); /* replacing args */ self->args = subslice; return 0; @@ -457,11 +475,13 @@ Py_INCREF(Py_None); if (_EnvironmentError_init(self, args, kwds) == -1) { + /* GB: why clear the error? */ PyErr_Clear(); } return (PyObject *)self; } +/* GB: what's that function doing? */ static int EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) @@ -494,7 +514,7 @@ Py_XDECREF(tuple); return NULL; } - +/* GB: PyTuple_SET_ITEM steals references, so you may need to INCREF first */ PyTuple_SET_ITEM(tuple, 0, self->myerrno); PyTuple_SET_ITEM(tuple, 1, self->strerror); PyTuple_SET_ITEM(tuple, 2, repr); @@ -513,7 +533,7 @@ Py_XDECREF(tuple); return NULL; } - +/* GB: same here */ PyTuple_SET_ITEM(tuple, 0, self->myerrno); PyTuple_SET_ITEM(tuple, 1, self->strerror); @@ -581,11 +601,13 @@ /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ + /* GB: where is errcode declared? */ errcode = PyInt_AsLong(self->myerrno); if (!errcode == -1 && PyErr_Occurred()) goto failed; posix_errno = winerror_to_errno(errcode); + /* INCREF? */ self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); @@ -605,6 +627,7 @@ static int WindowsError_init(WindowsErrorObject *self, PyObject *args, PyObject *kwds) { + /* GB: same: errcode */ if (EnvironmentError_init((EnvironmentErrorObject *)self, args, kwds) == -1) return -1; @@ -642,11 +665,12 @@ if (!fmt || !repr) goto finally; - tuple = PyTuple_Pack(3, sellf->myerrno, self->strerror, repr); + tuple = PyTuple_Pack(3, self->myerrno, self->strerror, repr); if (!tuple) goto finally; rtnval = PyString_Format(fmt, tuple); + /* GB: tuple must be DECREFd */ } else if (PyObject_IsTrue(self->myerrno) && PyObject_IsTrue(self->strerror)) { fmt = PyString_FromString("[Error %s] %s"); @@ -658,11 +682,13 @@ goto finally; rtnval = PyString_Format(fmt, tuple); + /* GB: tuple must be DECREFd */ } else rtnval = EnvironmentError_str(self); finally: + /* GB: where is filename, serrno and strerror declared? */ Py_XDECREF(filename); Py_XDECREF(serrno); Py_XDECREF(strerror); @@ -787,6 +813,7 @@ self->print_file_and_line = Py_None; Py_INCREF(Py_None); + /* GB: why clear the error? some fields can still be NULL */ if (_SyntaxError_init(self, args, kwds) == -1) PyErr_Clear(); @@ -844,44 +871,44 @@ lineno here */ if (str != NULL && PyString_Check(str)) { - int have_filename = 0; - int have_lineno = 0; - char *buffer = NULL; + int have_filename = 0; + int have_lineno = 0; + char *buffer = NULL; have_filename = (self->filename != NULL) && PyString_Check(self->filename); have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno); - if (have_filename || have_lineno) { - Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; - if (have_filename) - bufsize += PyString_GET_SIZE(self->filename); - - buffer = (char *)PyMem_MALLOC(bufsize); - if (buffer != NULL) { - if (have_filename && have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename)), - PyInt_AsLong(self->lineno)); - else if (have_filename) - PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename))); - else if (have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(self->lineno)); - - result = PyString_FromString(buffer); - PyMem_FREE(buffer); - - if (result == NULL) - result = str; - else - Py_DECREF(str); - } - } + if (have_filename || have_lineno) { + Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; + if (have_filename) + bufsize += PyString_GET_SIZE(self->filename); + + buffer = (char *)PyMem_MALLOC(bufsize); + if (buffer != NULL) { + if (have_filename && have_lineno) + PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename)), + PyInt_AsLong(self->lineno)); + else if (have_filename) + PyOS_snprintf(buffer, bufsize, "%s (%s)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename))); + else if (have_lineno) + PyOS_snprintf(buffer, bufsize, "%s (line %ld)", + PyString_AS_STRING(str), + PyInt_AsLong(self->lineno)); + + result = PyString_FromString(buffer); + PyMem_FREE(buffer); + + if (result == NULL) + result = str; + else + Py_DECREF(str); + } + } } return result; } @@ -941,8 +968,8 @@ If args is anything else, use the default BaseException__str__(). */ if (PyTuple_Check(self->args) && PyTuple_GET_SIZE(self->args) == 1) { - PyObject *key = PyTuple_GET_ITEM(self->args, 0); - return PyObject_Repr(key); + PyObject *key = PyTuple_GET_ITEM(self->args, 0); + return PyObject_Repr(key); } return BaseException_str(self); } @@ -984,6 +1011,8 @@ if (PyInt_Check(attr)) { *value = PyInt_AS_LONG(attr); } else if (PyLong_Check(attr)) { + /* GB: why not casting to Py_ssize_t? Can we be sure that LongLong + isn't larger than Py_ssize_t? */ *value = (size_t)PyLong_AsLongLong(attr); if (*value == -1) return -1; @@ -1050,6 +1079,7 @@ return attr; } +/* GB: Can't this be done more easily with a PyMemberDef? */ PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) { return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); From python-checkins at python.org Fri May 26 03:24:34 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 03:24:34 +0200 (CEST) Subject: [Python-checkins] r46270 - in python/branches/blais-bytebuf: Lib/hotbuf.py Lib/test/test_hotbuf.py Modules/_hotbuf.c Message-ID: <20060526012434.E86AD1E402B@bag.python.org> Author: martin.blais Date: Fri May 26 03:24:33 2006 New Revision: 46270 Modified: python/branches/blais-bytebuf/Lib/hotbuf.py python/branches/blais-bytebuf/Lib/test/test_hotbuf.py python/branches/blais-bytebuf/Modules/_hotbuf.c Log: hotbufferola: Added support for pack_to() and fixed may bugs. Modified: python/branches/blais-bytebuf/Lib/hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/hotbuf.py Fri May 26 03:24:33 2006 @@ -10,5 +10,20 @@ _long = Struct('l') class hotbuf(_hotbuf): - pass + + def pack( self, structobj, *values ): + """ + Pack using the given Struct object 'structobj', the remaining arguments. + """ + structobj.pack_to(self, 0, *values) + self.advance(structobj.size) + + def unpack( self, structobj ): + """ + Pack using the given Struct object 'structobj', the remaining arguments. + """ + values = structobj.unpack_from(self, 0) + self.advance(structobj.size) + return values + Modified: python/branches/blais-bytebuf/Lib/test/test_hotbuf.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_hotbuf.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_hotbuf.py Fri May 26 03:24:33 2006 @@ -94,6 +94,14 @@ b.compact() self.assertEquals((b.position, b.limit, b.mark), (100, CAPACITY, -1)) + + # Compare the text that gets compacted. + b.clear() + b.setposition(100) + b.putstr(MSG) + b.setposition(100) + b.compact() + self.assertEquals(str(b), MSG) def test_byte( self ): b = hotbuf(256) @@ -131,6 +139,13 @@ # Test underflow. self.assertRaises(IndexError, b.getstr, 1000) + # Test getting the rest of the string. + b.clear() + b.putstr(MSG) + b.flip() + s = b.getstr() + self.assertEquals(s, MSG) + def test_conversion( self ): b = hotbuf(CAPACITY) @@ -170,6 +185,12 @@ b.flip() self.assertEquals(fmt.unpack_from(b), ARGS) + def test_zerolen( self ): + b = hotbuf(CAPACITY) + b.setlimit(0) + self.assertEquals(str(b), '') + self.assertEquals(b.getstr(), '') + def test_main(): test_support.run_unittest(HotbufTestCase) @@ -177,3 +198,4 @@ if __name__ == "__main__": test_main() + Modified: python/branches/blais-bytebuf/Modules/_hotbuf.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_hotbuf.c (original) +++ python/branches/blais-bytebuf/Modules/_hotbuf.c Fri May 26 03:24:33 2006 @@ -9,11 +9,7 @@ PyAPI_DATA(PyTypeObject) PyHotbuf_Type; -#define PyHotbuf_Check(op) ((op)->ob_type == &PyHotbuf_Type) - -#define Py_END_OF_HOTBUF (-1) - -PyAPI_FUNC(PyObject *) PyHotbuf_New(Py_ssize_t size); +#define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) @@ -52,7 +48,7 @@ PyObject_HEAD /* Base pointer location */ - void* b_ptr; + void* b_ptr; /* Total size in bytes of the area that we can access. The allocated memory must be at least as large as this size. */ @@ -63,10 +59,10 @@ */ /* The current position in the buffer. */ - int b_position; + Py_ssize_t b_position; /* The limit position in the buffer. */ - int b_limit; + Py_ssize_t b_limit; /* The mark. From the Java Buffer docs: @@ -80,7 +76,7 @@ The mark is set to -1 to indicate that the mark is unset. */ - int b_mark; + Py_ssize_t b_mark; } PyHotbufObject; @@ -90,73 +86,71 @@ * true if there was no error. */ -/* - * Create a new hotbuf where we allocate the memory ourselves. - */ -PyObject * -PyHotbuf_New(Py_ssize_t capacity) -{ - PyObject *o; - PyHotbufObject * b; - - if (capacity < 0) { - PyErr_SetString(PyExc_ValueError, - "capacity must be zero or positive"); - return NULL; - } - - /* FIXME: check for overflow in multiply */ - o = (PyObject *)PyObject_MALLOC(sizeof(*b) + capacity); - if ( o == NULL ) - return PyErr_NoMemory(); - b = (PyHotbufObject *) PyObject_INIT(o, &PyHotbuf_Type); - - /* We setup the memory buffer to be right after the object itself. */ - b->b_ptr = (void *)(b + 1); - b->b_position = 0; - b->b_mark = -1; - b->b_limit = capacity; - b->b_capacity = capacity; - - return o; -} /* Methods */ /* - * Constructor. + * Constructor. Note that we allocate the memory ourselves, unlike + * the buffer object. */ static PyObject * hotbuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) { - Py_ssize_t size = -1; + Py_ssize_t capacity = -1; + PyObject *ptr; + PyHotbufObject *new; if (!_PyArg_NoKeywords("hotbuf()", kw)) return NULL; - if (!PyArg_ParseTuple(args, "n:hotbuf", &size)) + if (!PyArg_ParseTuple(args, "n:hotbuf", &capacity)) return NULL; - if ( size <= 0 ) { + if ( capacity <= 0 ) { PyErr_SetString(PyExc_ValueError, - "size must be greater than zero"); + "capacity must be greater than zero"); return NULL; } - return PyHotbuf_New(size); + /* Allocate the buffer of data */ + ptr = (void*) PyObject_MALLOC(capacity); + if ( ptr == NULL ) { + return PyErr_NoMemory(); + } + + /* Allocate the Python object itself. */ + new = (PyHotbufObject *) type->tp_alloc(type, 0); + if (new == NULL) { + PyObject_FREE(ptr); + return NULL; + } + + /* Initialize the members */ + new->b_ptr = ptr; + new->b_position = 0; + new->b_mark = -1; + new->b_limit = capacity; + new->b_capacity = capacity; + + return (PyObject*)new; } + /* * Destructor. */ + static void hotbuf_dealloc(PyHotbufObject *self) { /* Note: by virtue of the memory buffer being allocated with the PyObject itself, this frees the buffer as well. */ - PyObject_DEL(self); + PyObject_FREE(self->b_ptr); + self->b_ptr = NULL; + self->ob_type->tp_free(self); } + /* * Comparison. We compare the active windows, not the entire allocated buffer * memory. @@ -192,7 +186,7 @@ "", self->b_mark, self->b_position, - self->b_limit, + self->b_limit, self->b_capacity, self->b_ptr, self); @@ -204,9 +198,7 @@ static PyObject * hotbuf_str(PyHotbufObject *self) { - if ( self->b_position == self->b_limit ) { - return Py_None; - } + assert( self->b_position <= self->b_limit ); return PyString_FromStringAndSize( (const char *)(self->b_ptr + self->b_position), self->b_limit - self->b_position); @@ -228,7 +220,7 @@ static PyObject* hotbuf_setposition(PyHotbufObject *self, PyObject* arg) { - int newposition; + Py_ssize_t newposition; newposition = PyInt_AsLong(arg); if (newposition == -1 && PyErr_Occurred()) @@ -247,7 +239,7 @@ if ( self->b_mark > self->b_position ) self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -262,17 +254,17 @@ static PyObject* hotbuf_advance(PyHotbufObject *self, PyObject* arg) { - int nbytes; - int newposition; + Py_ssize_t nbytes; + Py_ssize_t newposition; nbytes = PyInt_AsLong(arg); if (nbytes == -1 && PyErr_Occurred()) return NULL; newposition = self->b_position + nbytes; - if ( newposition > self->b_capacity ) { + if ( newposition > self->b_limit ) { PyErr_SetString(PyExc_IndexError, - "position must be smaller than capacity"); + "position must be smaller than limit"); return NULL; } @@ -283,7 +275,7 @@ if ( self->b_mark > self->b_position ) self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -299,7 +291,7 @@ static PyObject* hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) { - int newlimit; + Py_ssize_t newlimit; newlimit = PyInt_AsLong(arg); if (newlimit == -1 && PyErr_Occurred()) @@ -323,7 +315,7 @@ if ( self->b_mark > self->b_position ) self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -336,7 +328,7 @@ hotbuf_setmark(PyHotbufObject *self) { self->b_mark = self->b_position; - return Py_None; + Py_RETURN_NONE; } @@ -384,7 +376,7 @@ self->b_position = 0; self->b_limit = self->b_capacity; self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -413,7 +405,7 @@ self->b_limit = self->b_position; self->b_position = 0; self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -437,7 +429,7 @@ { self->b_position = 0; self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -456,9 +448,7 @@ PyDoc_STRVAR(compact__doc__, "B.compact()\n\ \n\ -public abstract ByteBuffer compact()\n\ -\n\ -Compacts this buffer (optional operation).\n\ +Compacts this buffer.\n\ \n\ The bytes between the buffer's current position and its limit, if\n\ any, are copied to the beginning of the buffer. That is, the byte\n\ @@ -489,7 +479,7 @@ static PyObject* hotbuf_compact(PyHotbufObject *self) { - int length; + Py_ssize_t length; /* Calculate the number of bytes in the active window */ length = self->b_limit - self->b_position; @@ -504,7 +494,7 @@ self->b_limit = self->b_capacity; self->b_mark = -1; - return Py_None; + Py_RETURN_NONE; } @@ -568,28 +558,39 @@ CHECK_LIMIT_ERROR(sizeof(byte)); *(unsigned char*)(self->b_ptr + self->b_position) = byte; self->b_position += sizeof(byte); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(getstr__doc__, -"B.getstr(nbytes) -> data\n\ +"B.getstr([nbytes]) -> data\n\ \n\ -Extract a string of 'nbytes' bytes from the buffer and advance the \n\ -position accordingly.\n\ +Extract a string of 'nbytes' bytes from the buffer and advance the\n\ +position accordingly. If 'nbytes' is not specified, get the string\n\ +up to the limit.\n\ An IndexError is raised if the position is at the end of the buffer."); static PyObject* -hotbuf_getstr(PyHotbufObject *self, PyObject* arg) +hotbuf_getstr(PyHotbufObject *self, PyObject* args) { - int len; + Py_ssize_t len = -1; PyObject* s; /* Extract the given number of bytes */ - len = PyInt_AsLong(arg); - if (len == -1 && PyErr_Occurred()) + if (!PyArg_ParseTuple(args, "|n:hotbuf", &len)) return NULL; - + + /* Validate positive */ + if (len == -1) { + /* Using default value. */ + len = self->b_limit - self->b_position; + } + else if (len < 0) { + PyErr_SetString(PyExc_ValueError, + "length must be zero or positive"); + return NULL; + } + CHECK_LIMIT_ERROR(len); /* Extract the string object from the buffer */ @@ -619,7 +620,7 @@ hotbuf_putstr(PyHotbufObject *self, PyObject* arg) { char *instring; - int len; + Py_ssize_t len; /* Check and extract input string */ if ( arg == NULL || !PyString_Check(arg) ) { @@ -633,12 +634,12 @@ CHECK_LIMIT_ERROR(len); /* Copy the string into the buffer */ - memcpy(self->b_ptr, instring, len); + memcpy(self->b_ptr + self->b_position, instring, len); /* Advance the position */ self->b_position += len; - return Py_None; + Py_RETURN_NONE; } @@ -649,7 +650,8 @@ */ /* - * Returns the buffer for reading or writing. + * Returns the buffer for reading or writing. Important! We only + * deliver the portion in the active window. */ static Py_ssize_t hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) @@ -660,8 +662,8 @@ return -1; } - *pp = self->b_ptr; - return self->b_capacity; + *pp = self->b_ptr + self->b_position; + return self->b_limit - self->b_position; } static Py_ssize_t @@ -675,14 +677,7 @@ static Py_ssize_t hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) { - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent hotbuf segment"); - return -1; - } - - *pp = (const char *)self->b_ptr; - return self->b_capacity; + return hotbuf_getwritebuf(self, idx, (void**)pp); } @@ -694,6 +689,7 @@ static Py_ssize_t hotbuf_length(PyHotbufObject *self) { + /* Note: this is the same as 'remaining'. */ assert(self->b_position <= self->b_limit); return self->b_limit - self->b_position; } @@ -749,7 +745,7 @@ {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, get__doc__}, {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, - {"getstr", (PyCFunction)hotbuf_getstr, METH_O, getstr__doc__}, + {"getstr", (PyCFunction)hotbuf_getstr, METH_VARARGS, getstr__doc__}, {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, {NULL, NULL} /* sentinel */ }; @@ -809,8 +805,9 @@ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ - 0, /* tp_alloc */ + PyType_GenericAlloc, /* tp_alloc */ hotbuf_new, /* tp_new */ + PyObject_Del, /* tp_free */ }; From python-checkins at python.org Fri May 26 03:46:23 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 03:46:23 +0200 (CEST) Subject: [Python-checkins] r46271 - python/trunk/Misc/developers.txt Message-ID: <20060526014623.0916F1E400B@bag.python.org> Author: andrew.kuchling Date: Fri May 26 03:46:22 2006 New Revision: 46271 Modified: python/trunk/Misc/developers.txt Log: Add Soc student Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Fri May 26 03:46:22 2006 @@ -18,10 +18,11 @@ ------------------- - 2006 Summer of Code entries: Matt Fleming was added on 25 May 2006 - by AMK; he'll be working on enhancing the Python debugger. SoC - developers are expected to work primarily in nondist/sandbox or on a - branch of their own, and will have their work reviewed before - changes are accepted into the trunk. + by AMK; he'll be working on enhancing the Python debugger. Jackilyn + Hoxworth was added on 25 May 2005 by AMK; she'll be adding logging + to the standard library. SoC developers are expected to work + primarily in nondist/sandbox or on a branch of their own, and will + have their work reviewed before changes are accepted into the trunk. - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. From buildbot at python.org Fri May 26 04:15:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 02:15:05 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526021505.12EB01E400C@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/790 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 04:24:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 02:24:32 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060526022432.DE99D1E400C@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/789 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 04:55:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 02:55:55 +0000 Subject: [Python-checkins] buildbot failure in PPC64 Debian 2.4 Message-ID: <20060526025555.D22661E400C@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.4/builds/5 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: fred.drake,george.yoshida BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From nnorwitz at gmail.com Fri May 26 08:01:40 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 25 May 2006 23:01:40 -0700 Subject: [Python-checkins] r46214 - python/trunk/Objects/stringobject.c In-Reply-To: <20060525152203.C5F8A1E400B@bag.python.org> References: <20060525152203.C5F8A1E400B@bag.python.org> Message-ID: On 5/25/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Thu May 25 17:22:03 2006 > New Revision: 46214 > > > Modified: python/trunk/Objects/stringobject.c > ============================================================================== > --- python/trunk/Objects/stringobject.c (original) > +++ python/trunk/Objects/stringobject.c Thu May 25 17:22:03 2006 > @@ -2036,26 +2036,25 @@ > static PyObject * > string_lower(PyStringObject *self) > { > - char *s = PyString_AS_STRING(self), *s_new; > + char *s; > Py_ssize_t i, n = PyString_GET_SIZE(self); > PyObject *newobj; > > - newobj = PyString_FromStringAndSize(NULL, n); > - if (newobj == NULL) > + newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n); > + if (!newobj) > return NULL; > - s_new = PyString_AsString(newobj); > + > + s = PyString_AS_STRING(newobj); > + > for (i = 0; i < n; i++) { > - int c = Py_CHARMASK(*s++); > - if (isupper(c)) { > - *s_new = tolower(c); > - } else > - *s_new = c; > - s_new++; > + char c = Py_CHARMASK(s[i]); > + if (isupper(c)) > + s[i] = _tolower(c); > } I believe c should be an int rather than a char. There seem to be many occurrences of using int in stringobject.c already. It might be faster to always use tolower rather than checking isupper. n From nnorwitz at gmail.com Fri May 26 08:19:43 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 25 May 2006 23:19:43 -0700 Subject: [Python-checkins] r46230 - python/trunk/Objects/stringobject.c In-Reply-To: <20060525175532.DCF571E400C@bag.python.org> References: <20060525175532.DCF571E400C@bag.python.org> Message-ID: See my previous comments on this code in unicodeobject.c. In particular, count needs to be a Py_ssize_t. If you've already fixed, sorry, I'm trying to catch up on mail. :-( n -- On 5/25/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Thu May 25 19:55:31 2006 > New Revision: 46230 > > Modified: > python/trunk/Objects/stringobject.c > Log: > needforspeed: use "fastsearch" for count. this results in a 3x speedup > for the related stringbench tests. > > > > Modified: python/trunk/Objects/stringobject.c > ============================================================================== > --- python/trunk/Objects/stringobject.c (original) > +++ python/trunk/Objects/stringobject.c Thu May 25 19:55:31 2006 > @@ -5,6 +5,18 @@ > > #include > > +#undef USE_INLINE /* XXX - set via configure? */ > + > +#if defined(_MSC_VER) /* this is taken from _sre.c */ > +#pragma warning(disable: 4710) > +/* fastest possible local call under MSVC */ > +#define LOCAL(type) static __inline type __fastcall > +#elif defined(USE_INLINE) > +#define LOCAL(type) static inline type > +#else > +#define LOCAL(type) static type > +#endif > + > #ifdef COUNT_ALLOCS > int null_strings, one_strings; > #endif > @@ -763,6 +775,108 @@ > return 0; > } > > +/* -------------------------------------------------------------------- */ > +/* Helpers */ > + > +#define USE_FAST /* experimental fast search implementation */ > + > +/* XXX - this code is copied from unicodeobject.c. we really should > + refactor the core implementations (see _sre.c for how this can be > + done), but that'll have to wait -- fredrik */ > + > +/* fast search/count implementation, based on a mix between boyer- > + moore and horspool, with a few more bells and whistles on the top. > + for some more background, see: http://effbot.org/stringlib */ > + > +/* note: fastsearch may access s[n], which isn't a problem when using > + Python's ordinary string types, but may cause problems if you're > + using this code in other contexts. also, the count mode returns -1 > + if there cannot possible be a match in the target string, and 0 if > + it has actually checked for matches, but didn't find any. callers > + beware! */ > + > +#define FAST_COUNT 0 > +#define FAST_SEARCH 1 > + > +LOCAL(Py_ssize_t) > + fastsearch(const unsigned char* s, Py_ssize_t n, const unsigned char* p, > + Py_ssize_t m, int mode) > +{ > + long mask; > + int skip, count = 0; > + Py_ssize_t i, j, mlast, w; > + > + w = n - m; > + > + if (w < 0) > + return -1; > + > + /* look for special cases */ > + if (m <= 1) { > + if (m <= 0) > + return -1; > + /* use special case for 1-character strings */ > + if (mode == FAST_COUNT) { > + for (i = 0; i < n; i++) > + if (s[i] == p[0]) > + count++; > + return count; > + } else { > + for (i = 0; i < n; i++) > + if (s[i] == p[0]) > + return i; > + } > + return -1; > + } > + > + mlast = m - 1; > + > + /* create compressed boyer-moore delta 1 table */ > + skip = mlast - 1; > + /* process pattern[:-1] */ > + for (mask = i = 0; i < mlast; i++) { > + mask |= (1 << (p[i] & 0x1F)); > + if (p[i] == p[mlast]) > + skip = mlast - i - 1; > + } > + /* process pattern[-1] outside the loop */ > + mask |= (1 << (p[mlast] & 0x1F)); > + > + for (i = 0; i <= w; i++) { > + /* note: using mlast in the skip path slows things down on x86 */ > + if (s[i+m-1] == p[m-1]) { > + /* candidate match */ > + for (j = 0; j < mlast; j++) > + if (s[i+j] != p[j]) > + break; > + if (j == mlast) { > + /* got a match! */ > + if (mode != FAST_COUNT) > + return i; > + count++; > + i = i + mlast; > + continue; > + } > + /* miss: check if next character is part of pattern */ > + if (!(mask & (1 << (s[i+m] & 0x1F)))) > + i = i + m; > + else { > + i = i + skip; > + continue; > + } > + } else { > + /* skip: check if next character is part of pattern */ > + if (!(mask & (1 << (s[i+m] & 0x1F)))) > + i = i + m; > + } > + } > + > + if (mode != FAST_COUNT) > + return -1; > + return count; > +} > + > +/* -------------------------------------------------------------------- */ > /* Methods */ > > static int > @@ -2177,7 +2291,7 @@ > static PyObject * > string_count(PyStringObject *self, PyObject *args) > { > - const char *s = PyString_AS_STRING(self), *sub, *t; > + const char *s = PyString_AS_STRING(self), *sub; > Py_ssize_t len = PyString_GET_SIZE(self), n; > Py_ssize_t i = 0, last = PY_SSIZE_T_MAX; > Py_ssize_t m, r; > @@ -2210,8 +2324,14 @@ > if (n == 0) > return PyInt_FromSsize_t(m-i); > > +#ifdef USE_FAST > + r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); > + if (r < 0) > + r = 0; /* no match */ > +#else > r = 0; > while (i < m) { > + const char *t > if (!memcmp(s+i, sub, n)) { > r++; > i += n; > @@ -2225,6 +2345,7 @@ > break; > i = t - s; > } > +#endif > return PyInt_FromSsize_t(r); > } > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From nnorwitz at gmail.com Fri May 26 08:33:00 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 25 May 2006 23:33:00 -0700 Subject: [Python-checkins] r46268 - python/trunk/Objects/stringobject.c In-Reply-To: <20060525232754.49C4C1E400B@bag.python.org> References: <20060525232754.49C4C1E400B@bag.python.org> Message-ID: Why not use METH_O so the PyArgs_ParseTuple() call is not necessary? n -- On 5/25/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Fri May 26 01:27:53 2006 > New Revision: 46268 > > Modified: > python/trunk/Objects/stringobject.c > Log: > needforspeed: partition for 8-bit strings. for some simple tests, > this is on par with a corresponding find, and nearly twice as fast > as split(sep, 1) > > full tests, a unicode version, and documentation will follow to- > morrow. > > > > Modified: python/trunk/Objects/stringobject.c > ============================================================================== > --- python/trunk/Objects/stringobject.c (original) > +++ python/trunk/Objects/stringobject.c Fri May 26 01:27:53 2006 > @@ -799,8 +799,7 @@ > #define FAST_SEARCH 1 > > LOCAL(Py_ssize_t) > - fastsearch(const char* s, Py_ssize_t n, const char* p, > - Py_ssize_t m, int mode) > +fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) > { > long mask; > int skip, count = 0; > @@ -860,10 +859,8 @@ > /* miss: check if next character is part of pattern */ > if (!(mask & (1 << (s[i+m] & 0x1F)))) > i = i + m; > - else { > + else > i = i + skip; > - continue; > - } > } else { > /* skip: check if next character is part of pattern */ > if (!(mask & (1 << (s[i+m] & 0x1F)))) > @@ -1601,6 +1598,68 @@ > return NULL; > } > > +PyDoc_STRVAR(partition__doc__, > +"S.partition(sep) -> (head, sep, tail)\n\ > +\n\ > +Searches for the separator sep in S, and returns the part before it,\n\ > +the separator itself, and the part after it. If the separator is not\n\ > +found, returns S and two empty strings."); > + > +static PyObject * > +string_partition(PyStringObject *self, PyObject *args) > +{ > + Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; > + const char *str = PyString_AS_STRING(self), *sep; > + PyObject *sepobj; > + PyObject * out; > + > + if (!PyArg_ParseTuple(args, "O:partition", &sepobj)) > + return NULL; > + if (PyString_Check(sepobj)) { > + sep = PyString_AS_STRING(sepobj); > + sep_len = PyString_GET_SIZE(sepobj); > + } > +#ifdef Py_USING_UNICODE_NOTYET > + else if (PyUnicode_Check(sepobj)) > + return PyUnicode_Partition((PyObject *)self, sepobj); > +#endif > + else if (PyObject_AsCharBuffer(sepobj, &sep, &sep_len)) > + return NULL; > + > + if (sep_len == 0) { > + PyErr_SetString(PyExc_ValueError, "empty separator"); > + return NULL; > + } > + > + out = PyTuple_New(3); > + if (!out) > + return NULL; > + > + pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); > + if (pos < 0) { > + Py_INCREF(self); > + PyTuple_SET_ITEM(out, 0, (PyObject*) self); > + Py_INCREF(nullstring); > + PyTuple_SET_ITEM(out, 1, (PyObject*) nullstring); > + Py_INCREF(nullstring); > + PyTuple_SET_ITEM(out, 2, (PyObject*) nullstring); > + } else { > + Py_INCREF(sepobj); > + PyTuple_SET_ITEM(out, 0, PyString_FromStringAndSize(str, pos)); > + PyTuple_SET_ITEM(out, 1, sepobj); > + PyTuple_SET_ITEM(out, 2, > + PyString_FromStringAndSize(str + sep_len + pos, > + len - sep_len - pos) > + ); > + if (PyErr_Occurred()) { > + Py_DECREF(out); > + return NULL; > + } > + } > + > + return out; > +} > + > static PyObject * > rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) > { > @@ -3910,6 +3969,8 @@ > {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, > {"endswith", (PyCFunction)string_endswith, METH_VARARGS, > endswith__doc__}, > + {"partition", (PyCFunction)string_partition, METH_VARARGS, > + partition__doc__}, > {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, > {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, > {"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__}, > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Fri May 26 10:41:26 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 10:41:26 +0200 (CEST) Subject: [Python-checkins] r46272 - python/trunk/Lib/idlelib/configHelpSourceEdit.py Message-ID: <20060526084126.340FB1E4002@bag.python.org> Author: ronald.oussoren Date: Fri May 26 10:41:25 2006 New Revision: 46272 Modified: python/trunk/Lib/idlelib/configHelpSourceEdit.py Log: Without this patch OSX users couldn't add new help sources because the code tried to update one item in a tuple. Modified: python/trunk/Lib/idlelib/configHelpSourceEdit.py ============================================================================== --- python/trunk/Lib/idlelib/configHelpSourceEdit.py (original) +++ python/trunk/Lib/idlelib/configHelpSourceEdit.py Fri May 26 10:41:25 2006 @@ -151,6 +151,7 @@ pass else: # Mac Safari insists on using the URI form for local files + self.result = list(self.result) self.result[1] = "file://" + path self.destroy() From python-checkins at python.org Fri May 26 10:54:29 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 10:54:29 +0200 (CEST) Subject: [Python-checkins] r46273 - in python/trunk: Doc/lib/libstdtypes.tex Include/unicodeobject.h Lib/test/string_tests.py Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060526085429.9472C1E4002@bag.python.org> Author: fredrik.lundh Date: Fri May 26 10:54:28 2006 New Revision: 46273 Modified: python/trunk/Doc/lib/libstdtypes.tex python/trunk/Include/unicodeobject.h python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: partition implementation, part two. feel free to improve the documentation and the docstrings. Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Fri May 26 10:54:28 2006 @@ -727,6 +727,14 @@ \versionchanged[Support for the \var{chars} argument]{2.2.2} \end{methoddesc} +\begin{methoddesc}[string]{partition}{sep} +Splits the string at the \var{sep}, and return a 3-tuple containing +the part before the separator, the separator itself, and the part +after the separator. If the separator is not found, return a 3-tuple +containing the string itself, followed by two empty strings. +\versionadded{2.5} +\end{methoddesc} + \begin{methoddesc}[string]{replace}{old, new\optional{, count}} Return a copy of the string with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Fri May 26 10:54:28 2006 @@ -184,6 +184,7 @@ # define PyUnicode_GetMax PyUnicodeUCS2_GetMax # define PyUnicode_GetSize PyUnicodeUCS2_GetSize # define PyUnicode_Join PyUnicodeUCS2_Join +# define PyUnicode_Partition PyUnicodeUCS2_Partition # define PyUnicode_Replace PyUnicodeUCS2_Replace # define PyUnicode_Resize PyUnicodeUCS2_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding @@ -259,6 +260,7 @@ # define PyUnicode_GetMax PyUnicodeUCS4_GetMax # define PyUnicode_GetSize PyUnicodeUCS4_GetSize # define PyUnicode_Join PyUnicodeUCS4_Join +# define PyUnicode_Partition PyUnicodeUCS4_Partition # define PyUnicode_Replace PyUnicodeUCS4_Replace # define PyUnicode_Resize PyUnicodeUCS4_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding @@ -1018,6 +1020,13 @@ int keepends /* If true, line end markers are included */ ); +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + /* Split a string giving a list of Unicode strings. If sep is NULL, splitting will be done at all whitespace Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 10:54:28 2006 @@ -900,6 +900,21 @@ self.checkequal('A', 'a', 'title') self.checkequal(True, 'a', 'islower') + def test_partition(self): + + self.checkequal(('this', ' is ', 'the partition method'), + 'this is the partition method', 'partition', ' is ') + + # from raymond's original specification + S = 'http://www.python.org' + self.checkequal(('http', '://', 'www.python.org'), S, 'partition', '://') + self.checkequal(('http://www.python.org', '', ''), S, 'partition', '?') + self.checkequal(('', 'http://', 'www.python.org'), S, 'partition', 'http://') + self.checkequal(('http://www.python.', 'org', ''), S, 'partition', 'org') + + self.checkraises(ValueError, S, 'partition', '') + self.checkraises(TypeError, S, 'partition', None) + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 10:54:28 2006 @@ -1610,20 +1610,20 @@ { Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; const char *str = PyString_AS_STRING(self), *sep; - PyObject *sepobj; + PyObject *sep_obj; PyObject * out; - if (!PyArg_ParseTuple(args, "O:partition", &sepobj)) + if (!PyArg_ParseTuple(args, "O:partition", &sep_obj)) return NULL; - if (PyString_Check(sepobj)) { - sep = PyString_AS_STRING(sepobj); - sep_len = PyString_GET_SIZE(sepobj); + if (PyString_Check(sep_obj)) { + sep = PyString_AS_STRING(sep_obj); + sep_len = PyString_GET_SIZE(sep_obj); } -#ifdef Py_USING_UNICODE_NOTYET - else if (PyUnicode_Check(sepobj)) - return PyUnicode_Partition((PyObject *)self, sepobj); +#ifdef Py_USING_UNICODE + else if (PyUnicode_Check(sep_obj)) + return PyUnicode_Partition((PyObject *)self, sep_obj); #endif - else if (PyObject_AsCharBuffer(sepobj, &sep, &sep_len)) + else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; if (sep_len == 0) { @@ -1644,13 +1644,13 @@ Py_INCREF(nullstring); PyTuple_SET_ITEM(out, 2, (PyObject*) nullstring); } else { - Py_INCREF(sepobj); + PyObject* obj; PyTuple_SET_ITEM(out, 0, PyString_FromStringAndSize(str, pos)); - PyTuple_SET_ITEM(out, 1, sepobj); - PyTuple_SET_ITEM(out, 2, - PyString_FromStringAndSize(str + sep_len + pos, - len - sep_len - pos) - ); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + pos += sep_len; + obj = PyString_FromStringAndSize(str + pos, len - pos); + PyTuple_SET_ITEM(out, 2, obj); if (PyErr_Occurred()) { Py_DECREF(out); return NULL; Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 10:54:28 2006 @@ -4,6 +4,9 @@ modified by Marc-Andre Lemburg according to the Unicode Integration Proposal (see file Misc/unicode.txt). +Major speed upgrades to the method implementations at the Reykjavik +NeedForSpeed sprint, by Fredrik Lundh and Andrew Dalke. + Copyright (c) Corporation for National Research Initiatives. -------------------------------------------------------------------- @@ -193,6 +196,7 @@ /* Resizing shared object (unicode_empty or single character objects) in-place is not allowed. Use PyUnicode_Resize() instead ! */ + if (unicode == unicode_empty || (unicode->length == 1 && unicode->str[0] < 256U && @@ -202,8 +206,11 @@ return -1; } - /* We allocate one more byte to make sure the string is - Ux0000 terminated -- XXX is this needed ? */ + /* We allocate one more byte to make sure the string is Ux0000 terminated. + The overallocation is also used by fastsearch, which assumes that it's + safe to look at str[length] (without makeing any assumptions about what + it contains). */ + oldstr = unicode->str; PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1); if (!unicode->str) { @@ -3859,8 +3866,6 @@ /* --- Helpers ------------------------------------------------------------ */ -#define USE_FAST /* experimental fast search implementation */ - /* fast search/count implementation, based on a mix between boyer- moore and horspool, with a few more bells and whistles on the top. for some more background, see: http://effbot.org/stringlib */ @@ -3936,10 +3941,8 @@ /* miss: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) i = i + m; - else { + else i = i + skip; - continue; - } } else { /* skip: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) @@ -3973,23 +3976,13 @@ if (substring->length == 0) return (end - start + 1); -#ifdef USE_FAST count = fastsearch( PyUnicode_AS_UNICODE(self) + start, end - start, substring->str, substring->length, FAST_COUNT ); + if (count < 0) count = 0; /* no match */ -#else - end -= substring->length; - - while (start <= end) - if (Py_UNICODE_MATCH(self, start, substring)) { - count++; - start += substring->length; - } else - start++; -#endif return count; } @@ -4040,30 +4033,19 @@ if (substring->length == 0) return (direction > 0) ? start : end; -#ifdef USE_FAST if (direction > 0) { Py_ssize_t pos = fastsearch( PyUnicode_AS_UNICODE(self) + start, end - start, substring->str, substring->length, FAST_SEARCH ); - if (pos < 0) - return pos; - return pos + start; - } -#endif - - end -= substring->length; - - if (direction < 0) { + if (pos >= 0) + return pos + start; + } else { + end -= substring->length; for (; end >= start; end--) if (Py_UNICODE_MATCH(self, end, substring)) return end; - } else { - for (; start <= end; start++) - if (Py_UNICODE_MATCH(self, start, substring)) - return start; } - return -1; } @@ -5167,11 +5149,8 @@ PyObject *element) { PyUnicodeObject *u, *v; - int result; Py_ssize_t size; -#ifdef USE_FAST Py_ssize_t pos; -#endif /* Coerce the two arguments */ v = (PyUnicodeObject *) PyUnicode_FromObject(element); @@ -5189,44 +5168,19 @@ size = PyUnicode_GET_SIZE(v); if (!size) { - result = 1; + pos = 0; goto done; } -#ifdef USE_FAST pos = fastsearch( PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), PyUnicode_AS_UNICODE(v), size, FAST_SEARCH ); - result = (pos != -1); -#else - result = 0; - - if (size == 1) { - Py_UNICODE chr = PyUnicode_AS_UNICODE(v)[0]; - Py_UNICODE* ptr = PyUnicode_AS_UNICODE(u); - Py_UNICODE* end = ptr + PyUnicode_GET_SIZE(u); - for (; ptr < end; ptr++) { - if (*ptr == chr) { - result = 1; - break; - } - } - } else { - Py_ssize_t start = 0; - Py_ssize_t end = PyUnicode_GET_SIZE(u) - size; - for (; start <= end; start++) - if (Py_UNICODE_MATCH(u, start, v)) { - result = 1; - break; - } - } -#endif done: Py_DECREF(u); Py_DECREF(v); - return result; + return (pos != -1); } /* Concat to string or Unicode object giving a new Unicode object. */ @@ -6335,6 +6289,84 @@ return PyUnicode_Split((PyObject *)self, substring, maxcount); } +PyObject * +PyUnicode_Partition(PyObject *str_in, PyObject *sep_in) +{ + PyObject* str_obj; + PyObject* sep_obj; + Py_UNICODE *str, *sep; + Py_ssize_t len, sep_len, pos; + PyObject* out; + + str_obj = PyUnicode_FromObject(str_in); + if (!str_obj) + return NULL; + sep_obj = PyUnicode_FromObject(sep_in); + if (!sep_obj) + goto error; + + str = PyUnicode_AS_UNICODE(str_obj); + len = PyUnicode_GET_SIZE(str_obj); + + sep = PyUnicode_AS_UNICODE(sep_obj); + sep_len = PyUnicode_GET_SIZE(sep_obj); + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + goto error; + } + + out = PyTuple_New(3); + if (!out) + goto error; + + pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); + if (pos < 0) { + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); + Py_INCREF(unicode_empty); + PyTuple_SET_ITEM(out, 1, (PyObject*) unicode_empty); + Py_INCREF(unicode_empty); + PyTuple_SET_ITEM(out, 2, (PyObject*) unicode_empty); + } else { + PyObject* obj; + PyTuple_SET_ITEM(out, 0, PyUnicode_FromUnicode(str, pos)); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + obj = PyUnicode_FromUnicode(str + sep_len + pos, len - sep_len - pos); + PyTuple_SET_ITEM(out, 2, obj); + if (PyErr_Occurred()) { + Py_DECREF(out); + goto error; + } + } + + return out; + +error: + Py_XDECREF(sep_obj); + Py_DECREF(str_obj); + return NULL; +} + +PyDoc_STRVAR(partition__doc__, +"S.partition(sep) -> (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, and returns the part before it,\n\ +the separator itself, and the part after it. If the separator is not\n\ +found, returns S and two empty strings."); + +static PyObject* +unicode_partition(PyUnicodeObject *self, PyObject *args) +{ + PyObject *separator; + + if (!PyArg_ParseTuple(args, "O:partition", &separator)) + return NULL; + + return PyUnicode_Partition((PyObject *)self, separator); +} + PyObject *PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) @@ -6588,6 +6620,7 @@ {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__doc__}, {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, + {"partition", (PyCFunction) unicode_partition, METH_VARARGS, partition__doc__}, {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, From python-checkins at python.org Fri May 26 11:05:55 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 11:05:55 +0200 (CEST) Subject: [Python-checkins] r46274 - python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060526090555.2A0051E401A@bag.python.org> Author: georg.brandl Date: Fri May 26 11:05:54 2006 New Revision: 46274 Modified: python/trunk/Doc/lib/libstdtypes.tex Log: Clarify docs for str.partition(). Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Fri May 26 11:05:54 2006 @@ -728,10 +728,11 @@ \end{methoddesc} \begin{methoddesc}[string]{partition}{sep} -Splits the string at the \var{sep}, and return a 3-tuple containing -the part before the separator, the separator itself, and the part -after the separator. If the separator is not found, return a 3-tuple -containing the string itself, followed by two empty strings. +Splits the string at the first occurence of \var{sep}, and return +a 3-tuple containing the part before the separator, the separator +itself, and the part after the separator. If the separator is not +found, return a 3-tuple containing the string itself, followed by +two empty strings. \versionadded{2.5} \end{methoddesc} From python-checkins at python.org Fri May 26 11:13:43 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 11:13:43 +0200 (CEST) Subject: [Python-checkins] r46275 - python/branches/release24-maint/Lib/plat-mac/applesingle.py Message-ID: <20060526091343.5AA021E4002@bag.python.org> Author: ronald.oussoren Date: Fri May 26 11:13:42 2006 New Revision: 46275 Modified: python/branches/release24-maint/Lib/plat-mac/applesingle.py Log: backport of byteorder issues in applesingle Modified: python/branches/release24-maint/Lib/plat-mac/applesingle.py ============================================================================== --- python/branches/release24-maint/Lib/plat-mac/applesingle.py (original) +++ python/branches/release24-maint/Lib/plat-mac/applesingle.py Fri May 26 11:13:42 2006 @@ -25,14 +25,14 @@ pass # File header format: magic, version, unused, number of entries -AS_HEADER_FORMAT="LL16sh" +AS_HEADER_FORMAT=">LL16sh" AS_HEADER_LENGTH=26 # The flag words for AppleSingle AS_MAGIC=0x00051600 AS_VERSION=0x00020000 # Entry header format: id, offset, length -AS_ENTRY_FORMAT="lll" +AS_ENTRY_FORMAT=">lll" AS_ENTRY_LENGTH=12 # The id values From python-checkins at python.org Fri May 26 11:22:19 2006 From: python-checkins at python.org (sean.reifschneider) Date: Fri, 26 May 2006 11:22:19 +0200 (CEST) Subject: [Python-checkins] r46276 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060526092219.6A24A1E4002@bag.python.org> Author: sean.reifschneider Date: Fri May 26 11:22:19 2006 New Revision: 46276 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Removing the exception heirarchy test, Brett clue-by-foured me. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 11:22:19 2006 @@ -291,70 +291,3 @@ ( repr(e), checkArgName, repr(expected[checkArgName]), repr(getattr(e, checkArgName)) )) - - -# test exception heirarchy -osErrorChildren = [] -try: osErrorChildren.append(VMSError) -except: pass -try: osErrorChildren.append(WindowsError) -except: pass -osErrorChildren = tuple(osErrorChildren) -exceptionHeirarchy = \ - ( SystemExit, - KeyboardInterrupt, - Exception, - ( GeneratorExit, - StopIteration, - StandardError, - ( ArithmeticError, - ( FloatingPointError, - OverflowError, - ZeroDivisionError, ), - AssertionError, - AttributeError, - EnvironmentError, - ( IOError, - OSError, - osErrorChildren, ), - EOFError, - ImportError, - LookupError, - ( IndexError, - KeyError, ), - MemoryError, - NameError, - ( UnboundLocalError, ), - ReferenceError, - RuntimeError, - ( NotImplementedError, ), - SyntaxError, - ( IndentationError, - ( TabError, ), ), - SystemError, - TypeError, - ValueError, - ( UnicodeError, - ( UnicodeDecodeError, - UnicodeEncodeError, - UnicodeTranslateError, ), ), ), - Warning, - ( DeprecationWarning, - PendingDeprecationWarning, - RuntimeWarning, - SyntaxWarning, - UserWarning, - FutureWarning, - OverflowWarning, - ImportWarning, ), ), ) -def checkChildren(parent, children): - lastChild = None - for child in children: - if type(child) == type(tuple()): - checkChildren(lastChild, child) - else: - if not issubclass(child, parent): - raise TestFailed('Exception "%s" is not a subclass of "%s"' - % ( repr(child), repr(parent) )) - lastChild = child -checkChildren(BaseException, exceptionHeirarchy) From buildbot at python.org Fri May 26 11:31:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 09:31:52 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526093153.0ED381E4002@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/792 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 11:35:32 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 11:35:32 +0200 (CEST) Subject: [Python-checkins] r46277 - sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h Message-ID: <20060526093532.761801E4002@bag.python.org> Author: georg.brandl Date: Fri May 26 11:35:31 2006 New Revision: 46277 Modified: sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.h Log: Checkpoint. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Fri May 26 11:35:31 2006 @@ -7,11 +7,15 @@ /* Notable incompatibilities between this and the original decimal.py: - Rounding constants are integers. - - There's handle method on the exceptions. + - There's no handle method on the exceptions. - Special values are represented by special sign values, so the results of as_tuple() differ. - Many internal "underscore" methods are not accessible on the object. +*/ +/* This is not yet optimized C code, but mostly translated + Python that was not really made for translating, though + it originally should have been. */ #include "Python.h" @@ -27,10 +31,6 @@ #define contextobject PyDecimalContextObject #define decimalobject PyDecimalObject -/* for context->flags, ->traps, ->ignored */ -#define ISFLAGSET(f, b) (((f) >> b) & 1) -#define SETFLAG(f, b) (f |= (1 << b)) -#define UNSETFLAG(f, b) (f ^= (1 << b)) /* Checks */ @@ -129,6 +129,38 @@ static PyObject *errors[NUMSIGNALS+NUMCONDITIONS]; +/* for context->flags, ->traps, ->ignored *************************************/ + +/* XXX: lazy error checking */ +static int +_is_flag_set(PyObject *d, int f) +{ + PyObject *item = PyDict_GetItem(d, errors[f]); + if (item) + return PyObject_IsTrue(item); + return 0; +} + +static int +_set_flag(PyObject *d, int f, int v) +{ + PyObject *i = PyInt_FromLong(v); + PyObject *item; + int res = 0; + + if (!i) return -1; + item = PyDict_GetItem(d, errors[f]); + if (item) + res = PyObject_IsTrue(item); + + if (PyDict_SetItem(d, errors[f], i) < 0) + res = -1; + Py_DECREF(i); + return res; +} + + + /* Forwarding ****************************************************************/ static contextobject *getcontext(void); @@ -142,18 +174,22 @@ static PyObject *decimal_str(decimalobject *); static PyObject *_do_decimal_str(decimalobject *, contextobject *, int); static decimalobject *_new_decimalobj(PyTypeObject *, long, char, long); +static decimalobject *_do_decimal_subtract(decimalobject *, decimalobject *, contextobject *); +static contextobject *context_shallow_copy(contextobject *); +static PyObject *context_ignore_all_flags(contextobject *); +static decimalobject *_do_decimal_absolute(decimalobject *, contextobject *, int); /* Exception handlers *********************************************************/ /* Raise the exception if signal is trapped and not ignored. */ -#define HANDLE_ERROR(ctx, cond, expl, onerror) \ - int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ - if (! ISFLAGSET(ctx->ignored, err)) { \ - SETFLAG(ctx->flags, err); \ - if (ISFLAGSET(ctx->traps, err)) { \ - PyErr_SetString(errors[err], (expl ? expl : "")); \ - return onerror; \ - } \ +#define HANDLE_ERROR(ctx, cond, expl, onerror) \ + int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ + if (! _is_flag_set(ctx->ignored, err)) { \ + _set_flag(ctx->flags, err, 1); \ + if (_is_flag_set(ctx->traps, err)) { \ + PyErr_SetString(errors[err], (expl ? expl : "")); \ + return onerror; \ + } \ } @@ -321,24 +357,30 @@ _new_decimalobj(PyTypeObject *type, long ndigits, char sign, long exp) { decimalobject *new; - char *arr; + char *arr = NULL; + if (ndigits > LONG_MAX) { PyErr_NoMemory(); return NULL; } + arr = PyObject_MALLOC(ndigits); if (!arr) { PyErr_NoMemory(); - return NULL; + goto err; } new = (decimalobject *)type->tp_alloc(type, 0); if (new == NULL) - return NULL; + goto err; new->sign = sign; new->exp = exp; new->ob_size = ndigits; new->digits = arr; return new; + + err: + if (arr) PyObject_FREE(arr); + return NULL; } /* shortcut for use in methods */ @@ -608,7 +650,7 @@ if (prec == -1) prec = ctx->prec; - if (rounding < 0 || rounding > ROUND_CEILING) { + if (!VALID_ROUND(rounding)) { PyErr_SetString(PyExc_ValueError, "invalid rounding mode"); return NULL; } @@ -827,7 +869,7 @@ return NULL; if (handle_Subnormal(ctx, NULL) != 0) goto err; - if (ISFLAGSET(ctx->flags, S_INEXACT)) { + if (_is_flag_set(ctx->flags, S_INEXACT)) { if (handle_Underflow(ctx, NULL) != 0) goto err; } @@ -978,19 +1020,159 @@ } +/* Returns -1, 0, 1. No special error return code, must check + PyErr_Occurred() */ +static int +_do_real_decimal_compare(decimalobject *self, decimalobject *other, + contextobject *ctx) +{ + long adj1, adj2; + long i, minsize; + decimalobject *longer, *ans; + contextobject *ctx2; + + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan; + if (_check_nans(self, other, ctx, &nan) != 0) { + Py_XDECREF(nan); + /* comparisons with NaN always report self>other */ + return 1; + } + } + + /* If both are 0, sign comparison isn't correct. */ + if (!decimal_nonzero(self) && !decimal_nonzero(other)) + return 0; + + /* If different signs, neg one is less */ + if ((other->sign & 1) && !(self->sign & 1)) + return 1; + if ((self->sign & 1) && !(other->sign & 1)) + return -1; + + adj1 = ADJUSTED(self); + adj2 = ADJUSTED(other); + + if (adj1 == adj2) { + if (self->ob_size <= other->ob_size) { + minsize = self->ob_size; + longer = other; + } else { + minsize = other->ob_size; + longer = self; + } + + for (i = 0; i < minsize; i++) { + if (self->digits[i] != other->digits[i]) + goto next; + } + /* Okay, now the remaining digits of the longer + one must consist of only digits. */ + for (i = minsize; i < longer->ob_size; i++) + if (longer->digits[i] != 0) + goto next; + /* All digits match, so they're equal. */ + return 0; + } + + next: + /* Adjusted sizes are not equal. */ + if (adj1 > adj2 && self->digits[0] != 0) + return 1 - 2*(self->sign & 1); /* 0 -> 1, 1 -> -1 */ + else if (adj1 < adj2 && other->digits[0] != 0) + return 1 - 2*(other->sign & 1); + + ctx2 = context_shallow_copy(ctx); + if (!ctx2) return 0; /* error */ + + ctx2->rounding = ROUND_UP; /* away from 0 */ + if (context_ignore_all_flags(ctx2) == NULL) + return 0; /* error */ + + /* XXX: WTF? */ + ans = _do_decimal_subtract(self, other, ctx2); + if (!ans) return 0; + + if (decimal_nonzero(ans)) + i = 0; + else if (ans->sign & 1) + i = -1; + else + i = 1; + Py_DECREF(ans); + return i; +} + static decimalobject * _do_decimal_compare(decimalobject *self, decimalobject *other, contextobject *ctx) { - /* XXX */ + int res; + if (ISSPECIAL(self) || (decimal_nonzero(other) && + ISSPECIAL(other))) { + decimalobject *nan; + if (_check_nans(self, other, ctx, &nan) != 0) + return nan; + } + + res = _do_real_decimal_compare(self, other, ctx); + return (decimalobject *)decimal_from_long(self->ob_type, res); } DECIMAL_BINARY_FUNC(compare) + +static PyObject * +decimal_richcompare(decimalobject *self, decimalobject *other, + int op) +{ + int res; + contextobject *ctx; + ctx = getcontext(); + if (!ctx) return NULL; + + other = (decimalobject *)_convert_to_decimal(self->ob_type, + (PyObject *)other, + ctx, 0); + if (other == Py_NotImplemented) return other; + + res = _do_real_decimal_compare(self, other, ctx); + Py_DECREF(other); + if (PyErr_Occurred()) + return NULL; + + if ( (res == 0 && (op == Py_EQ || op == Py_LE || op == Py_GT)) || + (res == -1 && (op == Py_NE || op == Py_LT || op == Py_LE)) || + (res == 1 && (op == Py_NE || op == Py_GT || op == Py_GE))) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + static decimalobject * _do_decimal_max(decimalobject *self, decimalobject *other, contextobject *ctx) { - /* XXX */ + decimalobject *ans, *cmp; + + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan; + int sn = GETNAN(self); + int so = GETNAN(other); + if (sn || so) { + if (so == 1 && sn != 2) { + Py_INCREF(self); + return self; + } else if (sn == 1 && so != 2) { + Py_INCREF(other); + return other; + } + } + if (_check_nans(self, other, ctx, &nan) != 0) + return nan; + } + + } DECIMAL_BINARY_FUNC(max) @@ -999,6 +1181,7 @@ contextobject *ctx) { /* XXX */ + Py_RETURN_NONE; } DECIMAL_BINARY_FUNC(min) @@ -1091,6 +1274,7 @@ _do_decimal_remainder_near(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_BINARY_FUNC(remainder_near) @@ -1143,6 +1327,7 @@ static decimalobject * _do_decimal_sqrt(decimalobject *self, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_UNARY_FUNC(sqrt) @@ -1170,13 +1355,12 @@ Py_INCREF(self); return self; } - rnd = ISFLAGSET(ctx->ignored, S_ROUNDED); - inex = ISFLAGSET(ctx->ignored, S_INEXACT); - SETFLAG(ctx->ignored, S_ROUNDED); - SETFLAG(ctx->ignored, S_INEXACT); + /* XXX: slow? */ + rnd = _set_flag(ctx->ignored, S_ROUNDED, 1); + inex =_set_flag(ctx->ignored, S_INEXACT, 1); ans = _decimal_rescale(self, 0, ctx, rounding, 1); - if (!rnd) UNSETFLAG(ctx->ignored, S_ROUNDED); - if (!inex) UNSETFLAG(ctx->ignored, S_INEXACT); + if (!rnd) _set_flag(ctx->ignored, S_ROUNDED, rnd); + if (!inex) _set_flag(ctx->ignored, S_INEXACT, inex); return ans; } @@ -1500,6 +1684,35 @@ } #undef SANITY_CHECK +/* XXX */ +static PyObject * +decimal_round(decimalobject *self, PyObject *args) +{ + contextobject *ctx = NULL; + long prec = -1, rnd = -1; + if (!PyArg_ParseTuple(args, "|llO", &prec, &rnd, &ctx)) + return NULL; + ENSURE_CONTEXT("_round", ctx); + if (prec == -1) prec = ctx->prec; + if (rnd == -1) rnd = ctx->rounding; + + return _decimal_round(self, prec, ctx, rnd); +} + +static PyObject * +decimal_XXX_abs(decimalobject *self, PyObject *args) +{ + int round = -1; + contextobject *ctx; + + if (!PyArg_ParseTuple(args, "|iO", &round, &ctx)) + return NULL; + ENSURE_CONTEXT("abs", ctx); + if (round == -1) + round = ctx->rounding; + return _do_decimal_absolute(self, ctx, round); +} + static PyMethodDef decimal_methods[] = { {"adjusted", (PyCFunction)decimal_adjusted, METH_NOARGS, @@ -1561,6 +1774,10 @@ METH_NOARGS}, {"__deepcopy__", decimal_deepcopy, METH_O}, + /* XXX */ + {"_round", (PyCFunction)decimal_round, + METH_VARARGS}, + {"abs__", (PyCFunction)decimal_XXX_abs, METH_VARARGS}, {NULL, NULL} }; @@ -1596,10 +1813,79 @@ _do_decimal_add(decimalobject *self, decimalobject *other, contextobject *ctx) { + int shouldround, sign, negativezero = 0; + long exp, oexp; + decimalobject *res, *res2; + + if (ISSPECIAL(self) || ISSPECIAL(other)) { + decimalobject *nan; + if (_check_nans(self, other, ctx, &nan) != 0) + return nan; + if (ISINF(self)) { + if (((self->sign&1) != (other->sign&1)) && + ISINF(other)) + return handle_InvalidOperation(self->ob_type, ctx, + "-INF + INF", NULL); + return _decimal_get_copy(self); + } else if (ISINF(other)) { + return _decimal_get_copy(other); + } + + + } + + shouldround = (ctx->rounding_dec == ALWAYS_ROUND); + exp = (self->exp < other->exp ? self->exp : other->exp); + + if (ctx->rounding == ROUND_FLOOR && + (self->sign & 1) != (other->sign & 1)) + negativezero = 1; + + if (!decimal_nonzero(self) && !decimal_nonzero(other)) { + if (negativezero) + sign = 1; + else if (self->sign < other->sign) + sign = self->sign; + else + sign = other->sign; + res = _new_decimalobj(self->ob_type, 1, sign, exp); + if (!res) return NULL; + res->digits[0] = 0; + return res; + } + if (!decimal_nonzero(self)) { + oexp = other->exp - ctx->prec - 1; + exp = (exp > oexp ? exp : oexp); + res = _decimal_rescale(other, exp, ctx, 0); + if (!res) return NULL; + if (shouldround) { + res2 = _decimal_fix(res, ctx); + Py_DECREF(res); + return res2; + } else { + return res; + } + } + if (!decimal_nonzero(other)) { + oexp = self->exp - ctx->prec - 1; + exp = (exp > oexp ? exp : oexp); + res = _decimal_rescale(self, exp, ctx, 0); + if (!res) return NULL; + if (shouldround) { + res2 = _decimal_fix(res, ctx); + Py_DECREF(res); + return res2; + } else { + return res; + } + } + /* XXX */ + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_add) + static decimalobject * _do_decimal_subtract(decimalobject *self, decimalobject *other, contextobject *ctx) @@ -1627,17 +1913,21 @@ } DECIMAL_SPECIAL_2FUNC(decimal_subtract) + static decimalobject * _do_decimal_multiply(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_multiply) + static decimalobject * _do_decimal_divide(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_divide) @@ -1646,43 +1936,55 @@ _do_decimal_floor_div(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_floor_div) + static decimalobject * _do_decimal_true_div(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_true_div) + static decimalobject * _do_decimal_remainder(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_remainder) + static decimalobject * _do_decimal_divmod(decimalobject *self, decimalobject *other, contextobject *ctx) { + Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_divmod) + static decimalobject * _do_decimal_power(decimalobject *self, decimalobject *other, - decimalobject *modulo, contextobject *ctx) + decimalobject *modulo, contextobject *ctx) { + Py_RETURN_NONE; } + static PyObject * decimal_power(PyObject *self, PyObject *other, PyObject *modulo) { decimalobject *res; contextobject *ctx = getcontext(); if (!ctx) return NULL; + other = _convert_to_decimal(self->ob_type, other, ctx, 0); if (other == NULL || other == Py_NotImplemented) return other; + if (modulo == Py_None) { Py_INCREF(modulo); } else { @@ -1785,16 +2087,18 @@ ctx2 = context_copy(ctx); if (!ctx2) return NULL; ctx2->rounding_dec = NEVER_ROUND; + ctx = ctx2; } if (self->sign & 1) - ans = _do_decimal_negative(self, ctx2); + ans = _do_decimal_negative(self, ctx); else - ans = _do_decimal_positive(self, ctx2); + ans = _do_decimal_positive(self, ctx); Py_XDECREF(ctx2); return ans; } + static PyObject * decimal_absolute(PyObject *self) { @@ -1828,6 +2132,7 @@ return res; } + /* Convert to int, truncating. */ static PyObject * decimal_int(decimalobject *self) @@ -1867,7 +2172,8 @@ if (self->sign & 1) res = -res; return PyInt_FromLong(res); } - + + static PyObject * decimal_float(decimalobject *self) { @@ -1880,6 +2186,7 @@ return res; } + static int decimal_nonzero(decimalobject *self) { @@ -1891,6 +2198,7 @@ return 0; } + static PyNumberMethods decimal_as_number = { decimal_add, /* nb_add */ decimal_subtract, /* nb_subtract */ @@ -1935,13 +2243,6 @@ }; -static PyObject * -decimal_richcompare(decimalobject *a, decimalobject *b, int op) -{ - /* XXX */ - return NULL; -} - int _decimal_isint(decimalobject *d) { @@ -1960,6 +2261,7 @@ return 1; } + static void decimal_dealloc(decimalobject *d) { @@ -1967,6 +2269,7 @@ d->ob_type->tp_free(d); } + static decimalobject * _decimal_fromliteralnan(PyTypeObject *type, char *str, long len, contextobject *ctx) { @@ -2023,11 +2326,13 @@ return new; } + static char *infinities[] = { "inf", "infinity", "+inf", "+infinity", "-inf", "-infinity", 0 }; + static decimalobject * _decimal_fromliteralinfinity(PyTypeObject *type, char *str) { @@ -2053,6 +2358,7 @@ return NULL; } + static decimalobject * _decimal_fromliteral(PyTypeObject *type, char *str, long len, contextobject *ctx) { @@ -2197,12 +2503,14 @@ return (PyObject *)new; } + PyObject * PyDecimal_FromLong(long value) { return decimal_from_long(&PyDecimal_DecimalType, value); } + /* convert from a 3-tuple of (sign, digits, exp) */ static PyObject * decimal_from_sequence(PyTypeObject *type, PyObject *seq) @@ -2273,12 +2581,14 @@ return NULL; } + PyObject * PyDecimal_FromSequence(PyObject *seq) { return decimal_from_sequence(&PyDecimal_DecimalType, seq); } + static decimalobject * _decimal_from_pylong(PyTypeObject *type, PyObject *val, contextobject *ctx) { @@ -2303,7 +2613,6 @@ return res; } -static PyObject *decimal_new(PyTypeObject *, PyObject *, PyObject *); static PyObject * decimal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -2379,6 +2688,7 @@ return NULL; } + static PyObject * decimal_repr(decimalobject *d) { @@ -2396,6 +2706,7 @@ return res; } + static long decimal_hash(decimalobject *d) { @@ -2440,6 +2751,7 @@ return hash; } + /* XXX: just for debugging? */ static PyMemberDef _decimal_members[] = { {"_sign", T_INT, offsetof(decimalobject, sign), 0}, @@ -2447,6 +2759,7 @@ {NULL} }; + static PyObject * _decimal_get_int(decimalobject *self) { @@ -2459,6 +2772,7 @@ return tup; } + static int _decimal_set_int(decimalobject *self, PyObject *value) { @@ -2497,6 +2811,7 @@ return 0; } + static PyObject * _decimal_is_special(decimalobject *self) { @@ -2506,6 +2821,7 @@ Py_RETURN_FALSE; } + static PyGetSetDef _decimal_getset[] = { {"_int", (getter)_decimal_get_int, (setter)_decimal_set_int}, {"_is_special", (getter)_decimal_is_special, 0}, @@ -2539,7 +2855,7 @@ decimal_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* XXX: activate when it's implemented (richcmpfunc)decimal_richcompare,*/ /* tp_richcompare */ + (richcmpfunc)decimal_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -2651,14 +2967,50 @@ /* Context object ************************************************************/ static contextobject * -_new_contextobj(long prec, int rounding, int rounding_dec, int traps, - int flags, long Emin, long Emax, int capitals, - int clamp, int ignored) +_new_contextobj(long prec, int rounding, int rounding_dec, PyObject *traps, + PyObject *flags, long Emin, long Emax, int capitals, + int clamp, PyObject *ignored, int copy_dicts) { contextobject *new; + PyObject *f = NULL, *t = NULL, *i = NULL; + new = (contextobject *)PyObject_NEW(contextobject, &PyDecimal_DecimalContextType); if (new == NULL) return NULL; + + if (!flags) { + f = PyDict_New(); + } else if (copy_dicts) { + f = PyDict_Copy(flags); + } else { + f = flags; + Py_INCREF(f); + } + if (!f) goto err; + + if (!traps) { + t = PyDict_New(); + } else if (copy_dicts) { + t = PyDict_Copy(traps); + } else { + t = traps; + Py_INCREF(t); + } + if (!t) goto err; + + if (!ignored) { + i = PyDict_New(); + } else if (copy_dicts) { + i = PyDict_Copy(ignored); + } else { + i = ignored; + Py_INCREF(i); + } + if (!i) goto err; + + new->flags = f; + new->traps = t; + new->ignored = i; new->prec = prec; new->rounding = rounding; new->rounding_dec = rounding_dec; @@ -2666,64 +3018,15 @@ new->Emax = Emax; new->capitals = capitals; new->clamp = clamp; - new->flags = flags; - new->traps = traps; - new->ignored = ignored; return new; -} - -/* Context properties *********************************************************/ - - -static PyObject * -_dict_from_bitmask(int bitmask) -{ - PyObject *dict = NULL, *val, *dp; - int i, res; - - dict = PyDict_New(); - if (!dict) return NULL; - for (i = 0; i < NUMSIGNALS; i++) { - val = PyInt_FromLong(ISFLAGSET(bitmask, i)); - if (!val) goto err; - res = PyDict_SetItem(dict, errors[i], val); - Py_DECREF(val); - if (val < 0) goto err; - } - dp = PyDictProxy_New(dict); - Py_DECREF(dict); - return dp; - + err: - Py_XDECREF(dict); + Py_XDECREF(f); + Py_XDECREF(t); + Py_XDECREF(i); return NULL; -} - -static PyObject * -context_get_flags(contextobject *self) -{ - return _dict_from_bitmask(self->flags); } -static PyObject * -context_get_traps(contextobject *self) -{ - return _dict_from_bitmask(self->traps); -} - -static PyObject * -context_get_ignored(contextobject *self) -{ - return _dict_from_bitmask(self->ignored); -} - -static PyGetSetDef context_getset[] = { - {"flags", (getter)context_get_flags, (setter)0}, - {"traps", (getter)context_get_traps, (setter)0}, - {"_ignored", (getter)context_get_ignored, (setter)0}, - {NULL} -}; - /* Context methods ************************************************************/ static PyObject * @@ -2733,14 +3036,21 @@ Py_RETURN_NONE; } -/* As a C Context doesn't have mutable attributes, this is the - same as Context._shallow_copy. */ + +static contextobject * +context_shallow_copy(contextobject *ctx) +{ + return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, ctx->traps, + ctx->flags, ctx->Emin, ctx->Emax, ctx->capitals, ctx->clamp, + ctx->ignored, 0); +} + static contextobject * context_copy(contextobject *ctx) { return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, ctx->traps, ctx->flags, ctx->Emin, ctx->Emax, ctx->capitals, ctx->clamp, - ctx->ignored); + ctx->ignored, 1); } static decimalobject * @@ -2986,52 +3296,41 @@ static PyObject * context_reduce(contextobject *self) { - PyObject *flags = NULL, *traps = NULL, *ignored = NULL; - PyObject *res = NULL; - - flags = context_get_flags(self); - if (!flags) goto err; - traps = context_get_traps(self); - if (!traps) goto err; - ignored = context_get_ignored(self); - if (!ignored) goto err; - - res = Py_BuildValue("(O(liiOOlliiO))", self->ob_type, - self->prec, self->rounding, - self->rounding_dec, traps, flags, self->Emin, - self->Emax, self->capitals, self->clamp, - ignored); - - err: - Py_XDECREF(flags); - Py_XDECREF(traps); - Py_XDECREF(ignored); - return res; + return Py_BuildValue("(O(liiOOlliiO))", self->ob_type, + self->prec, self->rounding, + self->rounding_dec, self->traps, self->flags, + self->Emin, self->Emax, self->capitals, + self->clamp, self->ignored); } static PyObject * context_ignore_flags(contextobject *self, PyObject *args) { PyObject *flag, *ret_flags; - Py_ssize_t i, j; + long i, j; /* NB, unlike regard_flags this doesn't accept a sequence as the first element and regard_flags returns a list-ized version of its arguments instead of None */ + ret_flags = PyList_New(0); if (ret_flags == NULL) return NULL; + for (i = 0; i < PyTuple_GET_SIZE(args); i++) { flag = PyTuple_GET_ITEM(args, i); for (j = 0; j < NUMSIGNALS; j++) { if (errors[j] == flag) { - SETFLAG(self->ignored, j); - Py_INCREF(flag); - PyList_SET_ITEM(ret_flags, i, flag); + _set_flag(self->ignored, j, 1); + if (PyList_Append(ret_flags, flag) < 0) { + Py_DECREF(ret_flags); + return NULL; + } break; } } + /* No DECREF of flag here. */ if (j == NUMSIGNALS) { Py_DECREF(ret_flags); PyErr_SetString(PyExc_ValueError, "arguments must be valid flags"); @@ -3044,27 +3343,33 @@ static PyObject * context_ignore_all_flags(contextobject *self) { - PyObject *allflags, *flag; + PyObject *allflags, *flag, *res; int i = 0; allflags = PyTuple_New(NUMSIGNALS); if (allflags == NULL) return NULL; - + for (i = 0; i < NUMSIGNALS; i++) { flag = errors[i]; Py_INCREF(flag); PyTuple_SET_ITEM(allflags, i, flag); } - return context_ignore_flags(self, allflags); + res = context_ignore_flags(self, allflags); + Py_DECREF(allflags); + return res; } static PyObject * context_regard_flags(contextobject *self, PyObject *args) { PyObject *flag, *flags; - Py_ssize_t i, j; + long i, j; + if (PyTuple_GET_SIZE(args) <= 0) { + PyErr_BadInternalCall(); + return NULL; + } /* regard_flags allows a list of flags as the first arg */ flags = PyTuple_GET_ITEM(args, 0); if (PyTuple_GET_SIZE(args) != 1 && !PySequence_Check(flags)) @@ -3074,10 +3379,11 @@ flag = PySequence_GetItem(flags, i); for (j = 0; j < NUMSIGNALS; j++) { if (flag == errors[j]) { - UNSETFLAG(self->ignored, j); + _set_flag(self->ignored, j, 0); break; } } + Py_DECREF(flag); if (j == NUMSIGNALS) { PyErr_SetString(PyExc_ValueError, "arguments must be valid flags"); return NULL; @@ -3090,7 +3396,6 @@ context_set_rounding_decision(contextobject *self, PyObject *args) { int old_dec, new_dec; - PyObject *ret; if (!PyArg_ParseTuple(args, "i:_set_rounding_decision", &new_dec)) return NULL; @@ -3101,16 +3406,13 @@ old_dec = self->rounding_dec; self->rounding_dec = new_dec; - ret = PyInt_FromLong((long)old_dec); - if (ret == NULL) - return NULL; - return ret; + return PyInt_FromLong((long)old_dec); } + static PyObject * context_set_rounding(contextobject *self, PyObject *args) { int old_round, new_round; - PyObject *ret; if (!PyArg_ParseTuple(args, "i:_set_rounding", &new_round)) return NULL; @@ -3120,10 +3422,7 @@ } old_round = self->rounding; self->rounding = new_round; - ret = PyInt_FromLong((long)old_round); - if (ret == NULL) - return NULL; - return ret; + return PyInt_FromLong((long)old_round); } static PyObject * @@ -3217,7 +3516,7 @@ PyObject *rest = NULL; PyObject *handler; PyObject *dummy; - int flag = -1; + int errindex = -1, condindex = -1; int i; if (!PyArg_ParseTuple(args, "O|OO:_raise_error", &condition, &explanation, &rest)) @@ -3228,10 +3527,11 @@ return NULL; - if (explanation == NULL && !PyArg_ParseTupleAndKeywords(dummy, kwds, +/* if (explanation == NULL && !PyArg_ParseTupleAndKeywords(dummy, kwds, "O:_raise_error", kwlist, &explanation)) return NULL; +*/ if ((condition == ConversionSyntax) || (condition == DivisionImpossible) || @@ -3242,27 +3542,21 @@ /* reuse the condition */ handler = condition; } - for (i = 0; i < NUMSIGNALS; i++) { - if (errors[i] == handler) { - flag = i; - break; - } + /* The condition handle is called based on condition, + the exception on handler. */ + for (i = 0; i < NUMSIGNALS+NUMCONDITIONS; i++) { + if (errors[i] == condition) + condindex = i; + if (errors[i] == handler) + errindex = i; } - if (ISFLAGSET(self->ignored, flag)) { - return _do_context_error_dispatch(flag, args); + if (_is_flag_set(self->ignored, errindex)) { + return _do_context_error_dispatch(condindex, args); } else { - SETFLAG(self->ignored, flag); - if (!ISFLAGSET(self->traps, flag)) { - for (i = 0; i < NUMSIGNALS; i++) { - if (errors[i] == condition) { - flag = i; - break; - } - } - return _do_context_error_dispatch(flag, args); - - } + _set_flag(self->flags, errindex, 1); + if (!_is_flag_set(self->traps, errindex)) + return _do_context_error_dispatch(condindex, args); } PyErr_SetString(handler, PyString_AsString(explanation)); return NULL; @@ -3335,7 +3629,7 @@ METH_VARARGS | METH_KEYWORDS}, {"__copy__", (PyCFunction)context_copy, METH_NOARGS}, - {"_shallow_copy", (PyCFunction)context_copy, + {"_shallow_copy", (PyCFunction)context_shallow_copy, METH_NOARGS}, {"__reduce__", (PyCFunction)context_reduce, METH_NOARGS}, @@ -3347,18 +3641,21 @@ static void -context_dealloc(PyObject *c) +context_dealloc(contextobject *c) { + Py_DECREF(c->flags); + Py_DECREF(c->traps); + Py_DECREF(c->ignored); c->ob_type->tp_free(c); } #define TEST_AND_CAT(num, name) \ - if (ISFLAGSET(self->flags, num)) { \ + if (_is_flag_set(self->flags, num)) { \ strcat(flags, name); \ strcat(flags, ", "); \ flaglen += strlen(name) + 2; \ } \ - if (ISFLAGSET(self->traps, num)) { \ + if (_is_flag_set(self->traps, num)) { \ strcat(traps, name); \ strcat(traps, ", "); \ traplen += strlen(name) + 2; \ @@ -3442,8 +3739,10 @@ long Emin = LONG_MAX, Emax = LONG_MIN; int rounding = -1, rounding_dec = -1, capitals = -1, clamp = 0; PyObject *pytraps = NULL, *pyflags = NULL, *pyignored = NULL; - PyObject *tmp; - int traps = 0, flags = 0, ignored = 0; + PyObject *tmp, *res = NULL; + PyObject *_traps = NULL; + PyObject *_flags = NULL; + PyObject *_ignored = NULL; int i, j; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|nbbOOnnbbO:Context", kwlist, @@ -3451,83 +3750,96 @@ &pyflags, &Emin, &Emax, &capitals, &clamp, &pyignored)) return NULL; - + if (pytraps == NULL) { - traps = PyDecimal_DefaultContext->traps; - } else if (!PyDict_Check(pytraps)) { - for (i = 0; i < NUMSIGNALS; i++) { - j = PySequence_Contains(pytraps, errors[i]); - if (j == -1) - return NULL; - else if (j == 1) - SETFLAG(traps, i); - } + _traps = PyDict_Copy(PyDecimal_DefaultContext->traps); + if (!_traps) goto err; } else { - for (i = 0; i < NUMSIGNALS; i++) { - j = PyDict_Contains(pytraps, errors[i]); - if (j == -1) - return NULL; - else if (j == 0) - continue; - tmp = PyDict_GetItem(pytraps, errors[i]); - if (!tmp) - return NULL; - j = PyObject_IsTrue(tmp); - if (j == -1) - return NULL; - else if (j == 1) - SETFLAG(traps, i); + _traps = PyDict_New(); + if (!_traps) goto err; + if (!PyDict_Check(pytraps)) { + + for (i = 0; i < NUMSIGNALS; i++) { + j = PySequence_Contains(pytraps, errors[i]); + if (j == -1) + goto err; + else if (j == 1) + _set_flag(_traps, i, 1); + } + } else { + for (i = 0; i < NUMSIGNALS; i++) { + j = PyDict_Contains(pytraps, errors[i]); + if (j == -1) + goto err; + else if (j == 0) + continue; + tmp = PyDict_GetItem(pytraps, errors[i]); + if (!tmp) + goto err; + j = PyObject_IsTrue(tmp); + if (j == -1) + goto err; + else if (j == 1) + _set_flag(_traps, i, 1); + } } } + _flags = PyDict_New(); + if (!_flags) goto err; + if (pyflags == NULL) { /* don't copy flags from default context */ } else if (PyDict_Check(pyflags)) { for (i = 0; i < NUMSIGNALS; i++) { j = PyDict_Contains(pyflags, errors[i]); if (j == -1) - return NULL; + goto err; else if (j == 0) continue; tmp = PyDict_GetItem(pyflags, errors[i]); if (!tmp) - return NULL; + goto err; j = PyObject_IsTrue(tmp); if (j == -1) - return NULL; + goto err; else if (j == 1) - SETFLAG(flags, i); + _set_flag(_flags, i, 1); } } else { PyErr_SetString(PyExc_TypeError, "initial flags must be a dict"); - return NULL; + goto err; } + + _ignored = PyDict_New(); + if (!_ignored) goto err; + if (pyignored == NULL) { /* don't copy ignored flags from default context */ } else if (!PyDict_Check(pyignored)) { for (i = 0; i < NUMSIGNALS; i++) { j = PySequence_Contains(pyignored, errors[i]); if (j == -1) - return NULL; + goto err; else if (j == 1) - SETFLAG(ignored, i); + _set_flag(_ignored, i, 1); } } else { for (i = 0; i < NUMSIGNALS; i++) { j = PyDict_Contains(pyignored, errors[i]); if (j == -1) - return NULL; + goto err; else if (j == 0) continue; tmp = PyDict_GetItem(pyignored, errors[i]); if (!tmp) - return NULL; + goto err; j = PyObject_IsTrue(tmp); if (j == -1) - return NULL; + goto err; else if (j == 1) - SETFLAG(ignored, i); + _set_flag(_ignored, i, 1); } } @@ -3559,9 +3871,14 @@ clamp = clamp & 1; - return (PyObject *)_new_contextobj(prec, rounding, rounding_dec, traps, - flags, Emin, Emax, capitals, clamp, - ignored); + res = (PyObject *)_new_contextobj(prec, rounding, rounding_dec, _traps, + _flags, Emin, Emax, capitals, clamp, + _ignored, 0); + err: + Py_XDECREF(_flags); + Py_XDECREF(_traps); + Py_XDECREF(_ignored); + return res; } @@ -3575,6 +3892,9 @@ {"rounding", T_INT, OFF(rounding), 0}, {"_rounding_decision", T_INT, OFF(rounding_dec), 0}, {"_clamp", T_INT, OFF(clamp), 0}, + {"flags", T_OBJECT_EX, OFF(flags), 0}, + {"traps", T_OBJECT_EX, OFF(traps), 0}, + {"_ignored", T_OBJECT_EX, OFF(ignored), 0}, {NULL} }; @@ -3610,7 +3930,7 @@ 0, /* tp_iternext */ context_methods, /* tp_methods */ context_members, /* tp_members */ - context_getset, /* tp_getset */ + 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ @@ -3700,8 +4020,11 @@ PyObject *m; /* a module object */ PyObject *tup; contextobject *ctx; - int traps = 0; + PyObject *traps; + traps = PyDict_New(); + if (!traps) return; + m = Py_InitModule3(MODULE_NAME, module_methods, "Fast implementation of decimal arithmetic."); if (m == NULL) @@ -3718,12 +4041,53 @@ Py_INCREF(&PyDecimal_DecimalContextType); PyModule_AddObject(m, "Context", (PyObject *) &PyDecimal_DecimalContextType); + ADD_CONST(m, ROUND_DOWN); + ADD_CONST(m, ROUND_UP); + ADD_CONST(m, ROUND_HALF_DOWN); + ADD_CONST(m, ROUND_HALF_EVEN); + ADD_CONST(m, ROUND_HALF_UP); + ADD_CONST(m, ROUND_FLOOR); + ADD_CONST(m, ROUND_CEILING); + ADD_CONST(m, ALWAYS_ROUND); + ADD_CONST(m, NEVER_ROUND); + + INIT_EXC(m, DecimalException, PyExc_ArithmeticError); + INIT_EXC(m, Clamped, DecimalException); + INIT_EXC(m, InvalidOperation, DecimalException); + INIT_EXC(m, ConversionSyntax, InvalidOperation); + INIT_EXC(m, DivisionImpossible, InvalidOperation); + INIT_EXC_WITH_2TUPLE(m, DivisionUndefined, + InvalidOperation, PyExc_ZeroDivisionError); + INIT_EXC(m, InvalidContext, InvalidOperation); + INIT_EXC_WITH_2TUPLE(m, DivisionByZero, + DecimalException, PyExc_ZeroDivisionError); + INIT_EXC(m, Inexact, DecimalException); + INIT_EXC(m, Rounded, DecimalException); + INIT_EXC(m, Subnormal, DecimalException); + INIT_EXC_WITH_2TUPLE(m, Overflow, Rounded, Inexact); + INIT_EXC_WITH_3TUPLE(m, Underflow, + Rounded, Inexact, Subnormal); + + errors[S_INV_OPERATION] = InvalidOperation; + errors[S_DIV_BY_ZERO] = DivisionByZero; + errors[S_CLAMPED] = Clamped; + errors[S_INEXACT] = Inexact; + errors[S_ROUNDED] = Rounded; + errors[S_SUBNORMAL] = Subnormal; + errors[S_OVERFLOW] = Overflow; + errors[S_UNDERFLOW] = Underflow; + errors[C_INV_CONTEXT] = InvalidContext; + errors[C_CONV_SYNTAX] = ConversionSyntax; + errors[C_DIV_IMPOSSIBLE]= DivisionImpossible; + errors[C_DIV_UNDEFINED] = DivisionUndefined; + /* initialize default Context objects */ - SETFLAG(traps, S_DIV_BY_ZERO); - SETFLAG(traps, S_OVERFLOW); - SETFLAG(traps, S_INV_OPERATION); + _set_flag(traps, S_DIV_BY_ZERO, 1); + _set_flag(traps, S_OVERFLOW, 1); + _set_flag(traps, S_INV_OPERATION, 1); PyDecimal_DefaultContext = _new_contextobj(28, ROUND_HALF_EVEN, ALWAYS_ROUND, - traps, 0, -999999999L, 999999999L, 1, 0, 0); + traps, NULL, -999999999L, 999999999L, + 1, 0, NULL, 1); if (!PyDecimal_DefaultContext) return; if (PyModule_AddObject(m, "DefaultContext", @@ -3731,11 +4095,12 @@ return; /* add flags for BasicContext */ - SETFLAG(traps, S_CLAMPED); - SETFLAG(traps, S_UNDERFLOW); + _set_flag(traps, S_CLAMPED, 1); + _set_flag(traps, S_UNDERFLOW, 1); PyDecimal_BasicContext = _new_contextobj(9, ROUND_HALF_UP, ALWAYS_ROUND, - traps, 0, -999999999L, 999999999L, 1, 0, 0); + traps, NULL, -999999999L, 999999999L, + 1, 0, NULL, 1); if (!PyDecimal_BasicContext) return; if (PyModule_AddObject(m, "BasicContext", @@ -3743,7 +4108,8 @@ return; PyDecimal_ExtendedContext = _new_contextobj(9, ROUND_HALF_EVEN, ALWAYS_ROUND, - 0, 0, -999999999L, 999999999L, 1, 0, 0); + NULL, NULL, -999999999L, 999999999L, + 1, 0, NULL, 1); if (!PyDecimal_ExtendedContext) return; if (PyModule_AddObject(m, "ExtendedContext", @@ -3769,43 +4135,4 @@ if (PyModule_AddObject(m, "negInf", (PyObject *)PyDecimal_NegInf) < 0) return; - ADD_CONST(m, ROUND_DOWN); - ADD_CONST(m, ROUND_UP); - ADD_CONST(m, ROUND_HALF_DOWN); - ADD_CONST(m, ROUND_HALF_EVEN); - ADD_CONST(m, ROUND_HALF_UP); - ADD_CONST(m, ROUND_FLOOR); - ADD_CONST(m, ROUND_CEILING); - ADD_CONST(m, ALWAYS_ROUND); - ADD_CONST(m, NEVER_ROUND); - - INIT_EXC(m, DecimalException, PyExc_ArithmeticError); - INIT_EXC(m, Clamped, DecimalException); - INIT_EXC(m, InvalidOperation, DecimalException); - INIT_EXC(m, ConversionSyntax, InvalidOperation); - INIT_EXC(m, DivisionImpossible, InvalidOperation); - INIT_EXC_WITH_2TUPLE(m, DivisionUndefined, - InvalidOperation, PyExc_ZeroDivisionError); - INIT_EXC(m, InvalidContext, InvalidOperation); - INIT_EXC_WITH_2TUPLE(m, DivisionByZero, - DecimalException, PyExc_ZeroDivisionError); - INIT_EXC(m, Inexact, DecimalException); - INIT_EXC(m, Rounded, DecimalException); - INIT_EXC(m, Subnormal, DecimalException); - INIT_EXC_WITH_2TUPLE(m, Overflow, Rounded, Inexact); - INIT_EXC_WITH_3TUPLE(m, Underflow, - Rounded, Inexact, Subnormal); - - errors[S_INV_OPERATION] = InvalidOperation; - errors[S_DIV_BY_ZERO] = DivisionByZero; - errors[S_CLAMPED] = Clamped; - errors[S_INEXACT] = Inexact; - errors[S_ROUNDED] = Rounded; - errors[S_SUBNORMAL] = Subnormal; - errors[S_OVERFLOW] = Overflow; - errors[S_UNDERFLOW] = Underflow; - errors[C_INV_CONTEXT] = InvalidContext; - errors[C_CONV_SYNTAX] = ConversionSyntax; - errors[C_DIV_IMPOSSIBLE]= DivisionImpossible; - errors[C_DIV_UNDEFINED] = DivisionUndefined; } Modified: sandbox/trunk/decimal-c/decimal.h ============================================================================== --- sandbox/trunk/decimal-c/decimal.h (original) +++ sandbox/trunk/decimal-c/decimal.h Fri May 26 11:35:31 2006 @@ -35,10 +35,10 @@ long Emin; long Emax; - /* signal handling -- these are bit fields */ - int traps; /* if a signal is trapped */ - int ignored; /* if a signal is ignored completely */ - int flags; /* if a signal has occurred, but not been trapped */ + /* signal handling -- these are dicts */ + PyObject *traps; /* if a signal is trapped */ + PyObject *flags; /* if a signal has occurred, but not been trapped */ + PyObject *ignored; /* if a signal is ignored completely */ } PyDecimalContextObject; static PyTypeObject PyDecimal_DecimalContextType; @@ -57,9 +57,9 @@ /* static constants **********************************************************/ -static PyObject *PyDecimal_NaN; -static PyObject *PyDecimal_Inf; -static PyObject *PyDecimal_NegInf; +static PyDecimalObject *PyDecimal_NaN; +static PyDecimalObject *PyDecimal_Inf; +static PyDecimalObject *PyDecimal_NegInf; static PyDecimalContextObject *PyDecimal_DefaultContext; static PyDecimalContextObject *PyDecimal_BasicContext; From buildbot at python.org Fri May 26 11:45:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 09:45:15 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060526094515.9C1231E4018@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/30 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 11:46:59 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 11:46:59 +0200 (CEST) Subject: [Python-checkins] r46278 - python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Message-ID: <20060526094659.CDBDC1E401E@bag.python.org> Author: fredrik.lundh Date: Fri May 26 11:46:59 2006 New Revision: 46278 Modified: python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: use METH_O for argument handling, which made partition some ~15% faster for the current tests (which is noticable faster than a corre- sponding find call). thanks to neal-who-never-sleeps for the tip. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 11:46:59 2006 @@ -1606,15 +1606,12 @@ found, returns S and two empty strings."); static PyObject * -string_partition(PyStringObject *self, PyObject *args) +string_partition(PyStringObject *self, PyObject *sep_obj) { Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; const char *str = PyString_AS_STRING(self), *sep; - PyObject *sep_obj; PyObject * out; - if (!PyArg_ParseTuple(args, "O:partition", &sep_obj)) - return NULL; if (PyString_Check(sep_obj)) { sep = PyString_AS_STRING(sep_obj); sep_len = PyString_GET_SIZE(sep_obj); @@ -3969,8 +3966,7 @@ {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, {"endswith", (PyCFunction)string_endswith, METH_VARARGS, endswith__doc__}, - {"partition", (PyCFunction)string_partition, METH_VARARGS, - partition__doc__}, + {"partition", (PyCFunction)string_partition, METH_O, partition__doc__}, {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, {"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__}, Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 11:46:59 2006 @@ -6357,13 +6357,8 @@ found, returns S and two empty strings."); static PyObject* -unicode_partition(PyUnicodeObject *self, PyObject *args) +unicode_partition(PyUnicodeObject *self, PyObject *separator) { - PyObject *separator; - - if (!PyArg_ParseTuple(args, "O:partition", &separator)) - return NULL; - return PyUnicode_Partition((PyObject *)self, separator); } @@ -6620,7 +6615,7 @@ {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__doc__}, {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, - {"partition", (PyCFunction) unicode_partition, METH_VARARGS, partition__doc__}, + {"partition", (PyCFunction) unicode_partition, METH_O, partition__doc__}, {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, From buildbot at python.org Fri May 26 11:51:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 09:51:11 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060526095111.E19C41E4022@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/791 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 12:12:33 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 12:12:33 +0200 (CEST) Subject: [Python-checkins] r46279 - peps/trunk/pep-0007.txt Message-ID: <20060526101233.2A39E1E4002@bag.python.org> Author: georg.brandl Date: Fri May 26 12:12:32 2006 New Revision: 46279 Modified: peps/trunk/pep-0007.txt Log: New C files in 2.x are using 4-space indents, too. Modified: peps/trunk/pep-0007.txt ============================================================================== --- peps/trunk/pep-0007.txt (original) +++ peps/trunk/pep-0007.txt Fri May 26 12:12:32 2006 @@ -47,7 +47,8 @@ Code lay-out - Use single-tab indents, where a tab is worth 8 spaces. - (For Python 3000, see the section Python 3000 below.) + (For Python 3000 and entirely new source files, see the section + Python 3000 below.) - No line should be longer than 79 characters. If this and the previous rule together don't give you enough room to code, your @@ -195,9 +196,9 @@ Python 3000 - In Python 3000, we'll switch to a different indentation style: - 4 spaces per indent, all spaces (no tabs in any file). The - rest will remain the same. + In Python 3000 (and in the 2.x series, in new source files), + we'll switch to a different indentation style: 4 spaces per indent, + all spaces (no tabs in any file). The rest will remain the same. References From buildbot at python.org Fri May 26 12:18:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 10:18:49 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.4 Message-ID: <20060526101849.A2A321E4020@bag.python.org> The Buildbot has detected a new failure of x86 gentoo 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%25202.4/builds/136 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 12:27:17 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 12:27:17 +0200 (CEST) Subject: [Python-checkins] r46280 - python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Message-ID: <20060526102717.ECE3E1E4002@bag.python.org> Author: fredrik.lundh Date: Fri May 26 12:27:17 2006 New Revision: 46280 Modified: python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: use Py_ssize_t for the fastsearch counter and skip length (thanks, neal!). and yes, I've verified that this doesn't slow things down ;-) Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 12:27:17 2006 @@ -802,7 +802,7 @@ fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) { long mask; - int skip, count = 0; + Py_ssize_t skip, count = 0; Py_ssize_t i, j, mlast, w; w = n - m; Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 12:27:17 2006 @@ -3884,7 +3884,7 @@ fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) { long mask; - int skip, count = 0; + Py_ssize_t skip, count = 0; Py_ssize_t i, j, mlast, w; w = n - m; From python-checkins at python.org Fri May 26 12:32:16 2006 From: python-checkins at python.org (sean.reifschneider) Date: Fri, 26 May 2006 12:32:16 +0200 (CEST) Subject: [Python-checkins] r46281 - python/branches/sreifschneider-newnewexcept/Lib/test/output/test_logging Message-ID: <20060526103216.1D4071E4002@bag.python.org> Author: sean.reifschneider Date: Fri May 26 12:32:14 2006 New Revision: 46281 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/output/test_logging Log: Changing the exception test output to look for "type" instead of "class". Modified: python/branches/sreifschneider-newnewexcept/Lib/test/output/test_logging ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/output/test_logging (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/output/test_logging Fri May 26 12:32:14 2006 @@ -488,12 +488,12 @@ -- log_test4 begin --------------------------------------------------- config0: ok. config1: ok. -config2: -config3: +config2: +config3: -- log_test4 end --------------------------------------------------- -- log_test5 begin --------------------------------------------------- ERROR:root:just testing -... Don't panic! +... Don't panic! -- log_test5 end --------------------------------------------------- -- logrecv output begin --------------------------------------------------- ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) From buildbot at python.org Fri May 26 12:33:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 10:33:57 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian 2.4 Message-ID: <20060526103357.DF2CF1E400C@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.4/builds/6 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 12:34:01 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 12:34:01 +0200 (CEST) Subject: [Python-checkins] r46282 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060526103401.3F1AB1E400F@bag.python.org> Author: andrew.dalke Date: Fri May 26 12:34:00 2006 New Revision: 46282 Modified: sandbox/trunk/stringbench/stringbench.py Log: Added benchmarks for split() and rsplit(). Includes human text for the huge case. Fixed 2000 newline autogenerated text to be correct, and include more whitespace. Handle case when no tests are run (had a divide by zero error) Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Fri May 26 12:34:00 2006 @@ -325,12 +325,66 @@ #### split tests + at bench('("Here are some words. "*2).split()', "split whitespace (small)", 1000) +def whitespace_split(STR): + s = STR("Here are some words. "*2) + s_split = s.split + for x in _RANGE_1000: + s_split() + + at bench('("Here are some words. "*2).rsplit()', "split whitespace (small)", 1000) +def whitespace_rsplit(STR): + s = STR("Here are some words. "*2) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit() + +human_text = """\ +Python is a dynamic object-oriented programming language that can be +used for many kinds of software development. It offers strong support +for integration with other languages and tools, comes with extensive +standard libraries, and can be learned in a few days. Many Python +programmers report substantial productivity gains and feel the language +encourages the development of higher quality, more maintainable code. + +Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm +Handhelds, and Nokia mobile phones. Python has also been ported to the +Java and .NET virtual machines. + +Python is distributed under an OSI-approved open source license that +makes it free to use, even for commercial products. +"""*50 +human_text_unicode = unicode(human_text) +def _get_human_text(STR): + if STR is unicode: + return human_text_unicode + if STR is str: + return human_text + raise AssertionError + + at bench('human_text.split()', "split whitespace (huge)", 100) +def whitespace_split_huge(STR): + s = _get_human_text(STR) + s_split = s.split + for x in _RANGE_100: + s_split() + + at bench('human_text.rsplit()', "split whitespace (huge)", 100) +def whitespace_rsplit_huge(STR): + s = _get_human_text(STR) + s_rsplit = s.rsplit + for x in _RANGE_100: + s_rsplit() + + + @bench('"this\\nis\\na\\ntest\\n".split("\\n")', "split newlines", 1000) def newlines_split(STR): s = STR("this\nis\na\ntest\n") s_split = s.split for x in _RANGE_1000: s_split("\n") + @bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines", 1000) def newlines_rsplit(STR): @@ -351,13 +405,18 @@ def _make_2000_lines(): import random r = random.Random(100) - s = "".join(map(str, range(32, 128))) + chars = map(chr, range(32, 128)) + i = 0 + while i < len(chars): + chars[i] = " " + i += r.randrange(9) + s = "".join(chars) s = s*4 words = [] for i in range(2000): - start = r.randrange(0, 26) + start = r.randrange(96) n = r.randint(5, 65) - words.append(s[start:n]) + words.append(s[start:start+n]) return "\n".join(words)+"\n" _text_with_2000_lines = _make_2000_lines() @@ -861,9 +920,12 @@ str_total += str_time uni_total += uni_time - print "%.2f\t%.2f\t%.1f\t%s" % ( - 1000*str_total, 1000*uni_total, 100.*str_total/uni_total, - "TOTAL") + if str_total == uni_total == 0.0: + print "That was zippy!" + else: + print "%.2f\t%.2f\t%.1f\t%s" % ( + 1000*str_total, 1000*uni_total, 100.*str_total/uni_total, + "TOTAL") if __name__ == "__main__": main() From python-checkins at python.org Fri May 26 12:37:01 2006 From: python-checkins at python.org (sean.reifschneider) Date: Fri, 26 May 2006 12:37:01 +0200 (CEST) Subject: [Python-checkins] r46283 - python/branches/sreifschneider-newnewexcept/Lib/codeop.py Message-ID: <20060526103701.901B91E4002@bag.python.org> Author: sean.reifschneider Date: Fri May 26 12:37:01 2006 New Revision: 46283 Modified: python/branches/sreifschneider-newnewexcept/Lib/codeop.py Log: Changing the exception comparison to use repr, they no longer have __dict__. Modified: python/branches/sreifschneider-newnewexcept/Lib/codeop.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/codeop.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/codeop.py Fri May 26 12:37:01 2006 @@ -95,15 +95,7 @@ if code: return code - try: - e1 = err1.__dict__ - except AttributeError: - e1 = err1 - try: - e2 = err2.__dict__ - except AttributeError: - e2 = err2 - if not code1 and e1 == e2: + if not code1 and repr(err1) == repr(err2): raise SyntaxError, err1 def _compile(source, filename, symbol): From python-checkins at python.org Fri May 26 13:03:58 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 13:03:58 +0200 (CEST) Subject: [Python-checkins] r46284 - in python/branches/blais-bytebuf: Doc/api/abstract.tex Doc/api/newtypes.tex Doc/lib/libstdtypes.tex Include/longobject.h Include/pyport.h Include/unicodeobject.h Lib/idlelib/configHelpSourceEdit.py Lib/popen2.py Lib/test/string_tests.py Lib/test/test_grp.py Misc/NEWS Misc/developers.txt Modules/_ctypes/libffi/configure Modules/_ctypes/libffi/configure.ac Modules/_ctypes/libffi/fficonfig.h.in Modules/_ctypes/libffi/fficonfig.py.in Modules/_ctypes/libffi/src/darwin Modules/_ctypes/libffi/src/powerpc/darwin.S Modules/_ctypes/libffi/src/powerpc/darwin_closure.S Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Modules/_ctypes/libffi/src/prep_cif.c Modules/_ctypes/libffi/src/x86/darwin.S Modules/_ctypes/libffi/src/x86/ffi_darwin.c Modules/_ctypes/libffi/src/x86/ffitarget.h Modules/_struct.c Modules/cPickle.c Modules/gcmodule.c Modules/grpmodule.c Modules/parsermodule.c Modules/timemodule.c Objects/classobject.c Objects/floatobject.c Objects/longobject.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c PC/pyconfig.h Python/ceval.c Python/import.c Python/mystrtoul.c Python/pystrtod.c Message-ID: <20060526110358.4BDBE1E4002@bag.python.org> Author: martin.blais Date: Fri May 26 13:03:30 2006 New Revision: 46284 Added: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/darwin/ - copied from r46282, python/trunk/Modules/_ctypes/libffi/src/darwin/ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/darwin.S - copied unchanged from r46282, python/trunk/Modules/_ctypes/libffi/src/x86/darwin.S python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/ffi_darwin.c - copied unchanged from r46282, python/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c Modified: python/branches/blais-bytebuf/Doc/api/abstract.tex python/branches/blais-bytebuf/Doc/api/newtypes.tex python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex python/branches/blais-bytebuf/Include/longobject.h python/branches/blais-bytebuf/Include/pyport.h python/branches/blais-bytebuf/Include/unicodeobject.h python/branches/blais-bytebuf/Lib/idlelib/configHelpSourceEdit.py python/branches/blais-bytebuf/Lib/popen2.py python/branches/blais-bytebuf/Lib/test/string_tests.py python/branches/blais-bytebuf/Lib/test/test_grp.py python/branches/blais-bytebuf/Misc/NEWS python/branches/blais-bytebuf/Misc/developers.txt python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure.ac python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.h.in python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.py.in python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin.S python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/prep_cif.c python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/ffitarget.h python/branches/blais-bytebuf/Modules/_struct.c python/branches/blais-bytebuf/Modules/cPickle.c python/branches/blais-bytebuf/Modules/gcmodule.c python/branches/blais-bytebuf/Modules/grpmodule.c python/branches/blais-bytebuf/Modules/parsermodule.c python/branches/blais-bytebuf/Modules/timemodule.c python/branches/blais-bytebuf/Objects/classobject.c python/branches/blais-bytebuf/Objects/floatobject.c python/branches/blais-bytebuf/Objects/longobject.c python/branches/blais-bytebuf/Objects/stringobject.c python/branches/blais-bytebuf/Objects/typeobject.c python/branches/blais-bytebuf/Objects/unicodeobject.c python/branches/blais-bytebuf/Objects/weakrefobject.c python/branches/blais-bytebuf/PC/pyconfig.h python/branches/blais-bytebuf/Python/ceval.c python/branches/blais-bytebuf/Python/import.c python/branches/blais-bytebuf/Python/mystrtoul.c python/branches/blais-bytebuf/Python/pystrtod.c Log: Updated branch bytebuf to 46281 Modified: python/branches/blais-bytebuf/Doc/api/abstract.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/api/abstract.tex (original) +++ python/branches/blais-bytebuf/Doc/api/abstract.tex Fri May 26 13:03:30 2006 @@ -260,6 +260,8 @@ result of the call on success, or \NULL{} on failure. This is the equivalent of the Python expression \samp{apply(\var{callable}, \var{args})} or \samp{\var{callable}(*\var{args})}. + Note that if you only pass \ctype{PyObject *} args, + \cfunction{PyObject_CallFunctionObjArgs} is a faster alternative. \bifuncindex{apply} \end{cfuncdesc} @@ -274,6 +276,8 @@ indicating that no arguments are provided. Returns the result of the call on success, or \NULL{} on failure. This is the equivalent of the Python expression \samp{\var{o}.\var{method}(\var{args})}. + Note that if you only pass \ctype{PyObject *} args, + \cfunction{PyObject_CallMethodObjArgs} is a faster alternative. \end{cfuncdesc} Modified: python/branches/blais-bytebuf/Doc/api/newtypes.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/api/newtypes.tex (original) +++ python/branches/blais-bytebuf/Doc/api/newtypes.tex Fri May 26 13:03:30 2006 @@ -990,10 +990,10 @@ An optional pointer to the rich comparison function. The signature is the same as for \cfunction{PyObject_RichCompare()}. - The function should return \code{1} if the requested comparison - returns true, \code{0} if it returns false. It should return - \code{-1} and set an exception condition when an error occurred - during the comparison. + The function should return the result of the comparison (usually + \code{Py_True} or \code{Py_False}). If the comparison is undefined, + it must return \code{Py_NotImplemented}, if another error occurred + it must return \code{NULL} and set an exception condition. This field is inherited by subtypes together with \member{tp_compare} and \member{tp_hash}: a subtype inherits all Modified: python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex (original) +++ python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex Fri May 26 13:03:30 2006 @@ -727,6 +727,15 @@ \versionchanged[Support for the \var{chars} argument]{2.2.2} \end{methoddesc} +\begin{methoddesc}[string]{partition}{sep} +Splits the string at the first occurence of \var{sep}, and return +a 3-tuple containing the part before the separator, the separator +itself, and the part after the separator. If the separator is not +found, return a 3-tuple containing the string itself, followed by +two empty strings. +\versionadded{2.5} +\end{methoddesc} + \begin{methoddesc}[string]{replace}{old, new\optional{, count}} Return a copy of the string with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument Modified: python/branches/blais-bytebuf/Include/longobject.h ============================================================================== --- python/branches/blais-bytebuf/Include/longobject.h (original) +++ python/branches/blais-bytebuf/Include/longobject.h Fri May 26 13:03:30 2006 @@ -25,6 +25,7 @@ PyAPI_FUNC(Py_ssize_t) _PyLong_AsSsize_t(PyObject *); PyAPI_FUNC(PyObject *) _PyLong_FromSize_t(size_t); PyAPI_FUNC(PyObject *) _PyLong_FromSsize_t(Py_ssize_t); +PyAPI_DATA(int) _PyLong_DigitValue[256]; /* _PyLong_AsScaledDouble returns a double x and an exponent e such that the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0. Modified: python/branches/blais-bytebuf/Include/pyport.h ============================================================================== --- python/branches/blais-bytebuf/Include/pyport.h (original) +++ python/branches/blais-bytebuf/Include/pyport.h Fri May 26 13:03:30 2006 @@ -295,6 +295,15 @@ #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) #endif +/* Py_IS_FINITE(X) + * Return 1 if float or double arg is neither infinite nor NAN, else 0. + * Some compilers (e.g. VisualStudio) have intrisics for this, so a special + * macro for this particular test is useful + */ +#ifndef Py_IS_FINITE +#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) +#endif + /* HUGE_VAL is supposed to expand to a positive double infinity. Python * uses Py_HUGE_VAL instead because some platforms are broken in this * respect. We used to embed code in pyport.h to try to worm around that, Modified: python/branches/blais-bytebuf/Include/unicodeobject.h ============================================================================== --- python/branches/blais-bytebuf/Include/unicodeobject.h (original) +++ python/branches/blais-bytebuf/Include/unicodeobject.h Fri May 26 13:03:30 2006 @@ -184,6 +184,7 @@ # define PyUnicode_GetMax PyUnicodeUCS2_GetMax # define PyUnicode_GetSize PyUnicodeUCS2_GetSize # define PyUnicode_Join PyUnicodeUCS2_Join +# define PyUnicode_Partition PyUnicodeUCS2_Partition # define PyUnicode_Replace PyUnicodeUCS2_Replace # define PyUnicode_Resize PyUnicodeUCS2_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding @@ -259,6 +260,7 @@ # define PyUnicode_GetMax PyUnicodeUCS4_GetMax # define PyUnicode_GetSize PyUnicodeUCS4_GetSize # define PyUnicode_Join PyUnicodeUCS4_Join +# define PyUnicode_Partition PyUnicodeUCS4_Partition # define PyUnicode_Replace PyUnicodeUCS4_Replace # define PyUnicode_Resize PyUnicodeUCS4_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding @@ -1018,6 +1020,13 @@ int keepends /* If true, line end markers are included */ ); +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + /* Split a string giving a list of Unicode strings. If sep is NULL, splitting will be done at all whitespace Modified: python/branches/blais-bytebuf/Lib/idlelib/configHelpSourceEdit.py ============================================================================== --- python/branches/blais-bytebuf/Lib/idlelib/configHelpSourceEdit.py (original) +++ python/branches/blais-bytebuf/Lib/idlelib/configHelpSourceEdit.py Fri May 26 13:03:30 2006 @@ -151,6 +151,7 @@ pass else: # Mac Safari insists on using the URI form for local files + self.result = list(self.result) self.result[1] = "file://" + path self.destroy() Modified: python/branches/blais-bytebuf/Lib/popen2.py ============================================================================== --- python/branches/blais-bytebuf/Lib/popen2.py (original) +++ python/branches/blais-bytebuf/Lib/popen2.py Fri May 26 13:03:30 2006 @@ -72,8 +72,9 @@ # In case the child hasn't been waited on, check if it's done. self.poll(_deadstate=sys.maxint) if self.sts < 0: - # Child is still running, keep us alive until we can wait on it. - _active.append(self) + if _active: + # Child is still running, keep us alive until we can wait on it. + _active.append(self) def _run_child(self, cmd): if isinstance(cmd, basestring): Modified: python/branches/blais-bytebuf/Lib/test/string_tests.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/string_tests.py (original) +++ python/branches/blais-bytebuf/Lib/test/string_tests.py Fri May 26 13:03:30 2006 @@ -555,15 +555,14 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) -### Commented out until the underlying libraries are fixed -## def test_replace_overflow(self): -## # Check for overflow checking on 32 bit machines -## if sys.maxint != 2147483647: -## return -## A2_16 = "A" * (2**16) -## self.checkraises(OverflowError, A2_16, "replace", "", A2_16) -## self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) -## self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) + def test_replace_overflow(self): + # Check for overflow checking on 32 bit machines + if sys.maxint != 2147483647: + return + A2_16 = "A" * (2**16) + self.checkraises(OverflowError, A2_16, "replace", "", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) def test_zfill(self): self.checkequal('123', '123', 'zfill', 2) @@ -882,6 +881,40 @@ else: self.checkcall(format, "__mod__", value) + def test_inplace_rewrites(self): + # Check that strings don't copy and modify cached single-character strings + self.checkequal('a', 'A', 'lower') + self.checkequal(True, 'A', 'isupper') + self.checkequal('A', 'a', 'upper') + self.checkequal(True, 'a', 'islower') + + self.checkequal('a', 'A', 'replace', 'A', 'a') + self.checkequal(True, 'A', 'isupper') + + self.checkequal('A', 'a', 'capitalize') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'swapcase') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'title') + self.checkequal(True, 'a', 'islower') + + def test_partition(self): + + self.checkequal(('this', ' is ', 'the partition method'), + 'this is the partition method', 'partition', ' is ') + + # from raymond's original specification + S = 'http://www.python.org' + self.checkequal(('http', '://', 'www.python.org'), S, 'partition', '://') + self.checkequal(('http://www.python.org', '', ''), S, 'partition', '?') + self.checkequal(('', 'http://', 'www.python.org'), S, 'partition', 'http://') + self.checkequal(('http://www.python.', 'org', ''), S, 'partition', 'org') + + self.checkraises(ValueError, S, 'partition', '') + self.checkraises(TypeError, S, 'partition', None) + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and Modified: python/branches/blais-bytebuf/Lib/test/test_grp.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_grp.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_grp.py Fri May 26 13:03:30 2006 @@ -31,7 +31,10 @@ self.assertEqual(e2.gr_gid, e.gr_gid) e2 = grp.getgrnam(e.gr_name) self.check_value(e2) - self.assertEqual(e2.gr_name, e.gr_name) + # There are instances where getgrall() returns group names in + # lowercase while getgrgid() returns proper casing. + # Discovered on Ubuntu 5.04 (custom). + self.assertEqual(e2.gr_name.lower(), e.gr_name.lower()) def test_errors(self): self.assertRaises(TypeError, grp.getgrgid) Modified: python/branches/blais-bytebuf/Misc/NEWS ============================================================================== --- python/branches/blais-bytebuf/Misc/NEWS (original) +++ python/branches/blais-bytebuf/Misc/NEWS Fri May 26 13:03:30 2006 @@ -64,6 +64,10 @@ - Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}. As a result, these functions now raise WindowsError instead of OSError. +- ``time.clock()`` on Win64 should use the high-performance Windows + ``QueryPerformanceCounter()`` now (as was already the case on 32-bit + Windows platforms). + - Calling Tk_Init twice is refused if the first call failed as that may deadlock. Modified: python/branches/blais-bytebuf/Misc/developers.txt ============================================================================== --- python/branches/blais-bytebuf/Misc/developers.txt (original) +++ python/branches/blais-bytebuf/Misc/developers.txt Fri May 26 13:03:30 2006 @@ -18,10 +18,11 @@ ------------------- - 2006 Summer of Code entries: Matt Fleming was added on 25 May 2006 - by AMK; he'll be working on enhancing the Python debugger. SoC - developers are expected to work primarily in nondist/sandbox or on a - branch of their own, and will have their work reviewed before - changes are accepted into the trunk. + by AMK; he'll be working on enhancing the Python debugger. Jackilyn + Hoxworth was added on 25 May 2005 by AMK; she'll be adding logging + to the standard library. SoC developers are expected to work + primarily in nondist/sandbox or on a branch of their own, and will + have their work reviewed before changes are accepted into the trunk. - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure Fri May 26 13:03:30 2006 @@ -3483,6 +3483,7 @@ TARGETDIR="unknown" case "$host" in +i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; i*86-*-solaris2.1[0-9]*) TARGET=X86_64; TARGETDIR=x86;; @@ -5243,6 +5244,9 @@ esac + + + if test x$TARGET = xSPARC; then echo "$as_me:$LINENO: checking assembler and linker support unaligned pc related relocs" >&5 echo $ECHO_N "checking assembler and linker support unaligned pc related relocs... $ECHO_C" >&6 @@ -5470,7 +5474,15 @@ ac_config_commands="$ac_config_commands src" - ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h" +TARGETINCDIR=$TARGETDIR +case $host in +*-*-darwin*) + TARGETINCDIR="darwin" + ;; +esac + + + ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" @@ -6017,7 +6029,7 @@ # Handling of arguments. "include/ffi.h" ) CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; "fficonfig.py" ) CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; - "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;; + "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ;; "include/ffi_common.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; "include" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; "src" ) CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;; Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure.ac ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure.ac (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/configure.ac Fri May 26 13:03:30 2006 @@ -21,6 +21,7 @@ TARGETDIR="unknown" case "$host" in +i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; i*86-*-solaris2.1[[0-9]]*) TARGET=X86_64; TARGETDIR=x86;; @@ -99,6 +100,24 @@ AC_SUBST(HAVE_LONG_DOUBLE) AC_C_BIGENDIAN +AH_VERBATIM([WORDS_BIGENDIAN], +[ +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). + + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. +*/ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else +#ifndef __LITTLE_ENDIAN__ +#undef WORDS_BIGENDIAN +#endif +#endif]) + if test x$TARGET = xSPARC; then AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs], @@ -201,7 +220,15 @@ test -d src/$TARGETDIR || mkdir src/$TARGETDIR ], [TARGETDIR="$TARGETDIR"]) -AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) +TARGETINCDIR=$TARGETDIR +case $host in +*-*-darwin*) + TARGETINCDIR="darwin" + ;; +esac + + +AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h) AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h) AC_CONFIG_FILES(include/ffi.h fficonfig.py) Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.h.in ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.h.in (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.h.in Fri May 26 13:03:30 2006 @@ -114,9 +114,22 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS + /* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ + first (like Motorola and SPARC, unlike Intel and VAX). + + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. +*/ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else +#ifndef __LITTLE_ENDIAN__ #undef WORDS_BIGENDIAN +#endif +#endif #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.py.in ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.py.in (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/fficonfig.py.in Fri May 26 13:03:30 2006 @@ -6,6 +6,7 @@ 'MIPS_IRIX': ['src/mips/ffi.c', 'src/mips/o32.S', 'src/mips/n32.S'], 'MIPS_LINUX': ['src/mips/ffi.c', 'src/mips/o32.S'], 'X86': ['src/x86/ffi.c', 'src/x86/sysv.S'], + 'X86_DARWIN': ['src/x86/ffi_darwin.c', 'src/x86/darwin.S'], 'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'], 'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'], 'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'], @@ -26,6 +27,17 @@ 'PA': ['src/pa/linux.S', 'src/pa/ffi.c'], } +# Build all darwin related files on all supported darwin architectures, this +# makes it easier to build universal binaries. +if 0: + all_darwin = ('X86_DARWIN', 'POWERPC_DARWIN') + all_darwin_files = [] + for pn in all_darwin: + all_darwin_files.extend(ffi_platforms[pn]) + for pn in all_darwin: + ffi_platforms[pn] = all_darwin_files + del all_darwin, all_darwin_files, pn + ffi_srcdir = '@srcdir@' ffi_sources += ffi_platforms['@MKTARGET@'] ffi_sources = [os.path.join('@srcdir@', f) for f in ffi_sources] Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin.S ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin.S (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin.S Fri May 26 13:03:30 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 2000 John Hornkvist Copyright (c) 2004 Free Software Foundation, Inc. @@ -243,3 +244,4 @@ .align LOG2_GPR_BYTES LLFB0$non_lazy_ptr: .g_long LFB0 +#endif Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S Fri May 26 13:03:30 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- darwin_closure.S - Copyright (c) 2002, 2003, 2004, Free Software Foundation, Inc. based on ppc_closure.S @@ -315,3 +316,4 @@ .align LOG2_GPR_BYTES LLFB1$non_lazy_ptr: .g_long LFB1 +#endif Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Fri May 26 13:03:30 2006 @@ -1,3 +1,4 @@ +#ifdef __ppc__ /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating @@ -767,3 +768,4 @@ /* Tell ffi_closure_ASM to perform return type promotions. */ return cif->rtype->type; } +#endif Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/prep_cif.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/prep_cif.c (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/prep_cif.c Fri May 26 13:03:30 2006 @@ -55,11 +55,29 @@ /* Perform a sanity check on the argument type */ FFI_ASSERT_VALID_TYPE(*ptr); +#ifdef POWERPC_DARWIN + { + int curalign; + + curalign = (*ptr)->alignment; + if (ptr != &(arg->elements[0])) { + if (curalign > 4 && curalign != 16) { + curalign = 4; + } + } + arg->size = ALIGN(arg->size, curalign); + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > curalign) ? + arg->alignment : curalign; + } +#else arg->size = ALIGN(arg->size, (*ptr)->alignment); arg->size += (*ptr)->size; arg->alignment = (arg->alignment > (*ptr)->alignment) ? arg->alignment : (*ptr)->alignment; +#endif ptr++; } @@ -89,6 +107,19 @@ /* Perform machine independent ffi_cif preparation, then call machine dependent routine. */ +#ifdef X86_DARWIN +static inline int struct_on_stack(int size) +{ + if (size > 8) return 1; + /* This is not what the ABI says, but is what is really implemented */ + switch (size) { + case 1: case 2: case 4: case 8: return 0; + } + return 1; +} +#endif + + ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, ffi_abi abi, unsigned int nargs, /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, @@ -124,6 +155,10 @@ #ifdef SPARC && (cif->abi != FFI_V9 || cif->rtype->size > 32) #endif +#ifdef X86_DARWIN + + && (struct_on_stack(cif->rtype->size)) +#endif ) bytes = STACK_ARG_SIZE(sizeof(void*)); #endif @@ -139,7 +174,16 @@ check after the initialization. */ FFI_ASSERT_VALID_TYPE(*ptr); -#if !defined __x86_64__ && !defined S390 && !defined PA +#if defined(X86_DARWIN) + { + int align = (*ptr)->alignment; + if (align > 4) align = 4; + if ((align - 1) & bytes) + bytes = ALIGN(bytes, align); + bytes += STACK_ARG_SIZE((*ptr)->size); + } + +#elif !defined __x86_64__ && !defined S390 && !defined PA #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT && ((*ptr)->size > 16 || cif->abi != FFI_V9)) Modified: python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/ffitarget.h ============================================================================== --- python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/ffitarget.h (original) +++ python/branches/blais-bytebuf/Modules/_ctypes/libffi/src/x86/ffitarget.h Fri May 26 13:03:30 2006 @@ -51,7 +51,7 @@ #endif /* ---- Intel x86 and AMD x86-64 - */ -#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) +#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) FFI_SYSV, FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ #ifdef __i386__ Modified: python/branches/blais-bytebuf/Modules/_struct.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_struct.c (original) +++ python/branches/blais-bytebuf/Modules/_struct.c Fri May 26 13:03:30 2006 @@ -18,6 +18,14 @@ /* Forward declarations */ static Py_ssize_t convertbuffer(PyObject *, void **p); +/* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the + struct API to return int instead of long when possible. This is + often a significant performance improvement. */ +/* +#define PY_USE_INT_WHEN_POSSIBLE 1 +*/ + + /* The translation function for each format character is table driven */ typedef struct _formatdef { char format; @@ -284,6 +292,10 @@ { unsigned int x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) + return PyInt_FromLong((long)x); +#endif return PyLong_FromUnsignedLong((unsigned long)x); } @@ -300,6 +312,10 @@ { unsigned long x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) + return PyInt_FromLong((long)x); +#endif return PyLong_FromUnsignedLong(x); } @@ -313,6 +329,10 @@ { PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= LONG_MIN && x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif return PyLong_FromLongLong(x); } @@ -321,6 +341,10 @@ { unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif return PyLong_FromUnsignedLongLong(x); } @@ -550,13 +574,13 @@ {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, #ifdef HAVE_LONG_LONG {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, #endif + {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, + {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, + {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, {0} }; @@ -584,28 +608,61 @@ do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); +#endif + return PyLong_FromUnsignedLong(x); } static PyObject * bu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= LONG_MIN && x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 1 /* signed */); +#endif } static PyObject * bu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (*p++ & 0xFF); + } while (--i > 0); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 0, /* little-endian */ 0 /* signed */); +#endif } static PyObject * @@ -750,28 +807,61 @@ do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); +#endif + return PyLong_FromUnsignedLong((long)x); } static PyObject * lu_longlong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); + /* Extend the sign bit. */ + if (SIZEOF_LONG_LONG > f->size) + x |= -(x & (1L << (8 * f->size - 1))); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x >= LONG_MIN && x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); +#endif + return PyLong_FromLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 1 /* signed */); +#endif } static PyObject * lu_ulonglong(const char *p, const formatdef *f) { +#if HAVE_LONG_LONG + unsigned PY_LONG_LONG x = 0; + int i = f->size; + do { + x = (x<<8) | (p[--i] & 0xFF); + } while (i > 0); +#ifdef PY_USE_INT_WHEN_POSSIBLE + if (x <= LONG_MAX) + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); +#endif + return PyLong_FromUnsignedLongLong(x); +#else return _PyLong_FromByteArray((const unsigned char *)p, 8, 1, /* little-endian */ 0 /* signed */); +#endif } static PyObject * @@ -1446,7 +1536,7 @@ static PyTypeObject PyStructType = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "Struct", sizeof(PyStructObject), @@ -1497,14 +1587,59 @@ if (m == NULL) return; + PyStructType.ob_type = &PyType_Type; + if (PyType_Ready(&PyStructType) < 0) + return; + + /* Check endian and swap in faster functions */ + { + int one = 1; + formatdef *native = native_table; + formatdef *other, *ptr; + if ((int)*(unsigned char*)&one) + other = lilendian_table; + else + other = bigendian_table; + /* Scan through the native table, find a matching + entry in the endian table and swap in the + native implementations whenever possible + (64-bit platforms may not have "standard" sizes) */ + while (native->format != '\0' && other->format != '\0') { + ptr = other; + while (ptr->format != '\0') { + if (ptr->format == native->format) { + /* Match faster when formats are + listed in the same order */ + if (ptr == other) + other++; + /* Only use the trick if the + size matches */ + if (ptr->size != native->size) + break; + /* Skip float and double, could be + "unknown" float format */ + if (ptr->format == 'd' || ptr->format == 'f') + break; + ptr->pack = native->pack; + ptr->unpack = native->unpack; + break; + } + ptr++; + } + native++; + } + } + /* Add some symbolic constants to the module */ if (StructError == NULL) { StructError = PyErr_NewException("struct.error", NULL, NULL); if (StructError == NULL) return; } + Py_INCREF(StructError); PyModule_AddObject(m, "error", StructError); + Py_INCREF((PyObject*)&PyStructType); PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); } Modified: python/branches/blais-bytebuf/Modules/cPickle.c ============================================================================== --- python/branches/blais-bytebuf/Modules/cPickle.c (original) +++ python/branches/blais-bytebuf/Modules/cPickle.c Fri May 26 13:03:30 2006 @@ -3073,8 +3073,8 @@ "pickles are not supported."); return NULL; } - return PyObject_CallFunction(fc, "OO", py_module_name, - py_global_name); + return PyObject_CallFunctionObjArgs(fc, py_module_name, + py_global_name, NULL); } module = PySys_GetObject("modules"); Modified: python/branches/blais-bytebuf/Modules/gcmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/gcmodule.c (original) +++ python/branches/blais-bytebuf/Modules/gcmodule.c Fri May 26 13:03:30 2006 @@ -603,7 +603,7 @@ assert(callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = PyObject_CallFunction(callback, "O", wr); + temp = PyObject_CallFunctionObjArgs(callback, wr, NULL); if (temp == NULL) PyErr_WriteUnraisable(callback); else Modified: python/branches/blais-bytebuf/Modules/grpmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/grpmodule.c (original) +++ python/branches/blais-bytebuf/Modules/grpmodule.c Fri May 26 13:03:30 2006 @@ -84,12 +84,18 @@ } static PyObject * -grp_getgrgid(PyObject *self, PyObject *args) +grp_getgrgid(PyObject *self, PyObject *pyo_id) { + PyObject *py_int_id; unsigned int gid; struct group *p; - if (!PyArg_ParseTuple(args, "I:getgrgid", &gid)) - return NULL; + + py_int_id = PyNumber_Int(pyo_id); + if (!py_int_id) + return NULL; + gid = PyInt_AS_LONG(py_int_id); + Py_DECREF(py_int_id); + if ((p = getgrgid(gid)) == NULL) { PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid); return NULL; @@ -98,27 +104,33 @@ } static PyObject * -grp_getgrnam(PyObject *self, PyObject *args) +grp_getgrnam(PyObject *self, PyObject *pyo_name) { + PyObject *py_str_name; char *name; struct group *p; - if (!PyArg_ParseTuple(args, "s:getgrnam", &name)) - return NULL; + + py_str_name = PyObject_Str(pyo_name); + if (!py_str_name) + return NULL; + name = PyString_AS_STRING(py_str_name); + if ((p = getgrnam(name)) == NULL) { PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name); + Py_DECREF(py_str_name); return NULL; } + + Py_DECREF(py_str_name); return mkgrent(p); } static PyObject * -grp_getgrall(PyObject *self, PyObject *args) +grp_getgrall(PyObject *self, PyObject *ignore) { PyObject *d; struct group *p; - if (!PyArg_ParseTuple(args, ":getgrall")) - return NULL; if ((d = PyList_New(0)) == NULL) return NULL; setgrent(); @@ -136,15 +148,15 @@ } static PyMethodDef grp_methods[] = { - {"getgrgid", grp_getgrgid, METH_VARARGS, + {"getgrgid", grp_getgrgid, METH_O, "getgrgid(id) -> tuple\n\ Return the group database entry for the given numeric group ID. If\n\ id is not valid, raise KeyError."}, - {"getgrnam", grp_getgrnam, METH_VARARGS, + {"getgrnam", grp_getgrnam, METH_O, "getgrnam(name) -> tuple\n\ Return the group database entry for the given group name. If\n\ name is not valid, raise KeyError."}, - {"getgrall", grp_getgrall, METH_VARARGS, + {"getgrall", grp_getgrall, METH_NOARGS, "getgrall() -> list of tuples\n\ Return a list of all available group entries, in arbitrary order."}, {NULL, NULL} /* sentinel */ Modified: python/branches/blais-bytebuf/Modules/parsermodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/parsermodule.c (original) +++ python/branches/blais-bytebuf/Modules/parsermodule.c Fri May 26 13:03:30 2006 @@ -3267,8 +3267,8 @@ && (pickler != NULL)) { PyObject *res; - res = PyObject_CallFunction(func, "OOO", &PyST_Type, pickler, - pickle_constructor); + res = PyObject_CallFunctionObjArgs(func, &PyST_Type, pickler, + pickle_constructor, NULL); Py_XDECREF(res); } Py_XDECREF(func); Modified: python/branches/blais-bytebuf/Modules/timemodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/timemodule.c (original) +++ python/branches/blais-bytebuf/Modules/timemodule.c Fri May 26 13:03:30 2006 @@ -63,11 +63,10 @@ #endif /* MS_WINDOWS */ #endif /* !__WATCOMC__ || __QNX__ */ -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) -/* Win32 has better clock replacement - XXX Win64 does not yet, but might when the platform matures. */ -#undef HAVE_CLOCK /* We have our own version down below */ -#endif /* MS_WINDOWS && !MS_WIN64 */ +#if defined(MS_WINDOWS) && !defined(__BORLANDC__) +/* Win32 has better clock replacement; we have our own version below. */ +#undef HAVE_CLOCK +#endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #if defined(PYOS_OS2) #define INCL_DOS @@ -162,7 +161,7 @@ } #endif /* HAVE_CLOCK */ -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) +#if defined(MS_WINDOWS) && !defined(__BORLANDC__) /* Due to Mark Hammond and Tim Peters */ static PyObject * time_clock(PyObject *self, PyObject *args) @@ -191,7 +190,7 @@ } #define HAVE_CLOCK /* So it gets included in the methods */ -#endif /* MS_WINDOWS && !MS_WIN64 */ +#endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #ifdef HAVE_CLOCK PyDoc_STRVAR(clock_doc, @@ -821,7 +820,7 @@ SetConsoleCtrlHandler( PyCtrlHandler, TRUE); #endif /* MS_WINDOWS */ if (!initialized) { - PyStructSequence_InitType(&StructTimeType, + PyStructSequence_InitType(&StructTimeType, &struct_time_type_desc); } Py_INCREF(&StructTimeType); Modified: python/branches/blais-bytebuf/Objects/classobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/classobject.c (original) +++ python/branches/blais-bytebuf/Objects/classobject.c Fri May 26 13:03:30 2006 @@ -81,12 +81,9 @@ if (!PyClass_Check(base)) { if (PyCallable_Check( (PyObject *) base->ob_type)) - return PyObject_CallFunction( + return PyObject_CallFunctionObjArgs( (PyObject *) base->ob_type, - "OOO", - name, - bases, - dict); + name, bases, dict, NULL); PyErr_SetString(PyExc_TypeError, "PyClass_New: base must be a class"); return NULL; Modified: python/branches/blais-bytebuf/Objects/floatobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/floatobject.c (original) +++ python/branches/blais-bytebuf/Objects/floatobject.c Fri May 26 13:03:30 2006 @@ -384,7 +384,7 @@ if (PyFloat_Check(w)) j = PyFloat_AS_DOUBLE(w); - else if (Py_IS_INFINITY(i) || Py_IS_NAN(i)) { + else if (!Py_IS_FINITE(i)) { if (PyInt_Check(w) || PyLong_Check(w)) /* If i is an infinity, its magnitude exceeds any * finite integer, so it doesn't matter which int we @@ -802,10 +802,7 @@ * bug; we let that slide in math.pow() (which currently * reflects all platform accidents), but not for Python's **. */ - if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) { - /* XXX the "iw == iw" was to weed out NaNs. This - * XXX doesn't actually work on all platforms. - */ + if (iv == -1.0 && Py_IS_FINITE(iw)) { /* Return 1 if iw is even, -1 if iw is odd; there's * no guarantee that any C integral type is big * enough to hold iw, so we have to check this Modified: python/branches/blais-bytebuf/Objects/longobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/longobject.c (original) +++ python/branches/blais-bytebuf/Objects/longobject.c Fri May 26 13:03:30 2006 @@ -40,7 +40,7 @@ #define SIGCHECK(PyTryBlock) \ if (--_Py_Ticker < 0) { \ _Py_Ticker = _Py_CheckInterval; \ - if (PyErr_CheckSignals()) { PyTryBlock; } \ + if (PyErr_CheckSignals()) PyTryBlock \ } /* Normalize (remove leading zeros from) a long int object. @@ -844,11 +844,36 @@ PyObject * PyLong_FromLongLong(PY_LONG_LONG ival) { - PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); + PyLongObject *v; + unsigned PY_LONG_LONG t; /* unsigned so >> doesn't propagate sign bit */ + int ndigits = 0; + int negative = 0; + + if (ival < 0) { + ival = -ival; + negative = 1; + } + + /* Count the number of Python digits. + We used to pick 5 ("big enough for anything"), but that's a + waste of time and space given that 5*15 = 75 bits are rarely + needed. */ + t = (unsigned PY_LONG_LONG)ival; + while (t) { + ++ndigits; + t >>= SHIFT; + } + v = _PyLong_New(ndigits); + if (v != NULL) { + digit *p = v->ob_digit; + v->ob_size = negative ? -ndigits : ndigits; + t = (unsigned PY_LONG_LONG)ival; + while (t) { + *p++ = (digit)(t & MASK); + t >>= SHIFT; + } + } + return (PyObject *)v; } /* Create a new long int object from a C unsigned PY_LONG_LONG int. */ @@ -856,11 +881,26 @@ PyObject * PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival) { - unsigned PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); + PyLongObject *v; + unsigned PY_LONG_LONG t; + int ndigits = 0; + + /* Count the number of Python digits. */ + t = (unsigned PY_LONG_LONG)ival; + while (t) { + ++ndigits; + t >>= SHIFT; + } + v = _PyLong_New(ndigits); + if (v != NULL) { + digit *p = v->ob_digit; + v->ob_size = ndigits; + while (ival) { + *p++ = (digit)(ival & MASK); + ival >>= SHIFT; + } + } + return (PyObject *)v; } /* Create a new long int object from a C Py_ssize_t. */ @@ -1304,7 +1344,14 @@ return (PyObject *)str; } -static int digval[] = { +/* Table of digit values for 8-bit string -> integer conversion. + * '0' maps to 0, ..., '9' maps to 9. + * 'a' and 'A' map to 10, ..., 'z' and 'Z' map to 35. + * All other indices map to 37. + * Note that when converting a base B string, a char c is a legitimate + * base B digit iff _PyLong_DigitValue[Py_CHARMASK(c)] < B. + */ +int _PyLong_DigitValue[256] = { 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, @@ -1321,14 +1368,6 @@ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 }; /* *str points to the first digit in a string of base `base` digits. base @@ -1355,7 +1394,7 @@ n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - while (digval[Py_CHARMASK(*p)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base) ++p; *str = p; n = (p - start) * bits_per_char; @@ -1376,7 +1415,7 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k = digval[Py_CHARMASK(*p)]; + int k = _PyLong_DigitValue[Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1503,7 +1542,7 @@ /* Find length of the string of numeric characters. */ scan = str; - while (digval[Py_CHARMASK(*scan)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base) ++scan; /* Create a long object that can contain the largest possible @@ -1527,10 +1566,10 @@ /* Work ;-) */ while (str < scan) { /* grab up to convwidth digits from the input string */ - c = (digit)digval[Py_CHARMASK(*str++)]; + c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)]; for (i = 1; i < convwidth && str != scan; ++i, ++str) { c = (twodigits)(c * base + - digval[Py_CHARMASK(*str)]); + _PyLong_DigitValue[Py_CHARMASK(*str)]); assert(c < BASE); } Modified: python/branches/blais-bytebuf/Objects/stringobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/stringobject.c (original) +++ python/branches/blais-bytebuf/Objects/stringobject.c Fri May 26 13:03:30 2006 @@ -5,6 +5,18 @@ #include +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) /* this is taken from _sre.c */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define LOCAL(type) static inline type +#else +#define LOCAL(type) static type +#endif + #ifdef COUNT_ALLOCS int null_strings, one_strings; #endif @@ -763,6 +775,105 @@ return 0; } +/* -------------------------------------------------------------------- */ +/* Helpers */ + +#define USE_FAST /* experimental fast search implementation */ + +/* XXX - this code is copied from unicodeobject.c. we really should + refactor the core implementations (see _sre.c for how this can be + done), but that'll have to wait -- fredrik */ + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possibly be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +LOCAL(Py_ssize_t) +fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) +{ + long mask; + Py_ssize_t skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m <= 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else + i = i + skip; + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +/* -------------------------------------------------------------------- */ /* Methods */ static int @@ -909,7 +1020,7 @@ static PyObject * string_concat(register PyStringObject *a, register PyObject *bb) { - register size_t size; + register Py_ssize_t size; register PyStringObject *op; if (!PyString_Check(bb)) { #ifdef Py_USING_UNICODE @@ -933,7 +1044,12 @@ return (PyObject *)a; } size = a->ob_size + b->ob_size; - /* XXX check overflow */ + if (size < 0) { + PyErr_SetString(PyExc_OverflowError, + "strings are too large to concat"); + return NULL; + } + /* Inline PyObject_NewVar */ op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); if (op == NULL) @@ -1030,10 +1146,14 @@ { char *s = PyString_AS_STRING(a); const char *sub = PyString_AS_STRING(el); - char *last; Py_ssize_t len_sub = PyString_GET_SIZE(el); +#ifdef USE_FAST + Py_ssize_t pos; +#else + char *last; Py_ssize_t shortsub; char firstchar, lastchar; +#endif if (!PyString_CheckExact(el)) { #ifdef Py_USING_UNICODE @@ -1049,6 +1169,14 @@ if (len_sub == 0) return 1; + +#ifdef USE_FAST + pos = fastsearch( + s, PyString_GET_SIZE(a), + sub, len_sub, FAST_SEARCH + ); + return (pos != -1); +#else /* last points to one char beyond the start of the rightmost substring. When s (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, and returns the part before it,\n\ +the separator itself, and the part after it. If the separator is not\n\ +found, returns S and two empty strings."); + +static PyObject * +string_partition(PyStringObject *self, PyObject *sep_obj) +{ + Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; + const char *str = PyString_AS_STRING(self), *sep; + PyObject * out; + + if (PyString_Check(sep_obj)) { + sep = PyString_AS_STRING(sep_obj); + sep_len = PyString_GET_SIZE(sep_obj); + } +#ifdef Py_USING_UNICODE + else if (PyUnicode_Check(sep_obj)) + return PyUnicode_Partition((PyObject *)self, sep_obj); +#endif + else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) + return NULL; + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + return NULL; + } + + out = PyTuple_New(3); + if (!out) + return NULL; + + pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); + if (pos < 0) { + Py_INCREF(self); + PyTuple_SET_ITEM(out, 0, (PyObject*) self); + Py_INCREF(nullstring); + PyTuple_SET_ITEM(out, 1, (PyObject*) nullstring); + Py_INCREF(nullstring); + PyTuple_SET_ITEM(out, 2, (PyObject*) nullstring); + } else { + PyObject* obj; + PyTuple_SET_ITEM(out, 0, PyString_FromStringAndSize(str, pos)); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + pos += sep_len; + obj = PyString_FromStringAndSize(str + pos, len - pos); + PyTuple_SET_ITEM(out, 2, obj); + if (PyErr_Occurred()) { + Py_DECREF(out); + return NULL; + } + } + + return out; +} + static PyObject * rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { @@ -1500,15 +1676,17 @@ if (j > i) { if (maxsplit-- <= 0) break; - SPLIT_INSERT(s, i + 1, j + 1); + SPLIT_APPEND(s, i + 1, j + 1); while (i >= 0 && isspace(Py_CHARMASK(s[i]))) i--; j = i; } } if (j >= 0) { - SPLIT_INSERT(s, 0, j + 1); + SPLIT_APPEND(s, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: Py_DECREF(list); @@ -1529,14 +1707,16 @@ if (s[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_INSERT(s, i + 1, j + 1); + SPLIT_APPEND(s, i + 1, j + 1); j = i = i - 1; } else i--; } if (j >= -1) { - SPLIT_INSERT(s, 0, j + 1); + SPLIT_APPEND(s, 0, j + 1); } + if (PyList_Reverse(list) < 0) + goto onError; return list; onError: @@ -1776,6 +1956,17 @@ string_adjust_indices(&i, &last, len); +#ifdef USE_FAST + if (n == 0) + return (dir > 0) ? i : last; + if (dir > 0) { + Py_ssize_t pos = fastsearch(s + i, last - i, sub, n, + FAST_SEARCH); + if (pos < 0) + return pos; + return pos + i; + } +#endif if (dir > 0) { if (n == 0 && i <= last) return (long)i; @@ -2033,57 +2224,68 @@ \n\ Return a copy of the string S converted to lowercase."); +/* _tolower and _toupper are defined by SUSv2, but they're not ISO C */ +#ifndef _tolower +#define _tolower tolower +#endif + static PyObject * string_lower(PyStringObject *self) { - char *s = PyString_AS_STRING(self), *s_new; + char *s; Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; newobj = PyString_FromStringAndSize(NULL, n); - if (newobj == NULL) + if (!newobj) return NULL; - s_new = PyString_AsString(newobj); + + s = PyString_AS_STRING(newobj); + + memcpy(s, PyString_AS_STRING(self), n); + for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) { - *s_new = tolower(c); - } else - *s_new = c; - s_new++; + int c = Py_CHARMASK(s[i]); + if (isupper(c)) + s[i] = _tolower(c); } + return newobj; } - PyDoc_STRVAR(upper__doc__, "S.upper() -> string\n\ \n\ Return a copy of the string S converted to uppercase."); +#ifndef _toupper +#define _toupper toupper +#endif + static PyObject * string_upper(PyStringObject *self) { - char *s = PyString_AS_STRING(self), *s_new; + char *s; Py_ssize_t i, n = PyString_GET_SIZE(self); PyObject *newobj; newobj = PyString_FromStringAndSize(NULL, n); - if (newobj == NULL) + if (!newobj) return NULL; - s_new = PyString_AsString(newobj); + + s = PyString_AS_STRING(newobj); + + memcpy(s, PyString_AS_STRING(self), n); + for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - *s_new = toupper(c); - } else - *s_new = c; - s_new++; + int c = Py_CHARMASK(s[i]); + if (islower(c)) + s[i] = _toupper(c); } + return newobj; } - PyDoc_STRVAR(title__doc__, "S.title() -> string\n\ \n\ @@ -2166,7 +2368,7 @@ static PyObject * string_count(PyStringObject *self, PyObject *args) { - const char *s = PyString_AS_STRING(self), *sub, *t; + const char *s = PyString_AS_STRING(self), *sub; Py_ssize_t len = PyString_GET_SIZE(self), n; Py_ssize_t i = 0, last = PY_SSIZE_T_MAX; Py_ssize_t m, r; @@ -2199,8 +2401,14 @@ if (n == 0) return PyInt_FromSsize_t(m-i); +#ifdef USE_FAST + r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); + if (r < 0) + r = 0; /* no match */ +#else r = 0; while (i < m) { + const char *t if (!memcmp(s+i, sub, n)) { r++; i += n; @@ -2214,6 +2422,7 @@ break; i = t - s; } +#endif return PyInt_FromSsize_t(r); } @@ -2368,156 +2577,625 @@ } -/* What follows is used for implementing replace(). Perry Stoll. */ +#define FORWARD 1 +#define REVERSE -1 -/* - mymemfind +/* find and count characters and substrings */ - strstr replacement for arbitrary blocks of memory. +/* Don't call if length < 2 */ +#define Py_STRING_MATCH(target, offset, pattern, length) \ + (target[offset] == pattern[0] && \ + target[offset+length-1] == pattern[length-1] && \ + !memcmp(target+offset+1, pattern+1, length-2) ) + +#define findchar(target, target_len, c) \ + ((char *)memchr((const void *)(target), c, target_len)) + +/* String ops must return a string. */ +/* If the object is subclass of string, create a copy */ +static PyStringObject * +return_self(PyStringObject *self) +{ + if (PyString_CheckExact(self)) { + Py_INCREF(self); + return self; + } + return (PyStringObject *)PyString_FromStringAndSize( + PyString_AS_STRING(self), + PyString_GET_SIZE(self)); +} - Locates the first occurrence in the memory pointed to by MEM of the - contents of memory pointed to by PAT. Returns the index into MEM if - found, or -1 if not found. If len of PAT is greater than length of - MEM, the function returns -1. -*/ static Py_ssize_t -mymemfind(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len) +countchar(char *target, int target_len, char c) { - register Py_ssize_t ii; + Py_ssize_t count=0; + char *start=target; + char *end=target+target_len; - /* pattern can not occur in the last pat_len-1 chars */ - len -= pat_len; + while ( (start=findchar(start, end-start, c)) != NULL ) { + count++; + start += 1; + } - for (ii = 0; ii <= len; ii++) { - if (mem[ii] == pat[0] && memcmp(&mem[ii], pat, pat_len) == 0) { - return ii; - } + return count; +} + +static Py_ssize_t +findstring(char *target, Py_ssize_t target_len, + char *pattern, Py_ssize_t pattern_len, + Py_ssize_t start, + Py_ssize_t end, + int direction) +{ + if (start < 0) { + start += target_len; + if (start < 0) + start = 0; + } + if (end > target_len) { + end = target_len; + } else if (end < 0) { + end += target_len; + if (end < 0) + end = 0; + } + + /* zero-length substrings always match at the first attempt */ + if (pattern_len == 0) + return (direction > 0) ? start : end; + + end -= pattern_len; + + if (direction < 0) { + for (; end >= start; end--) + if (Py_STRING_MATCH(target, end, pattern, pattern_len)) + return end; + } else { + for (; start <= end; start++) + if (Py_STRING_MATCH(target, start, pattern, pattern_len)) + return start; } return -1; } -/* - mymemcnt +Py_ssize_t +countstring(char *target, Py_ssize_t target_len, + char *pattern, Py_ssize_t pattern_len, + Py_ssize_t start, + Py_ssize_t end, + int direction) +{ + Py_ssize_t count=0; + + if (start < 0) { + start += target_len; + if (start < 0) + start = 0; + } + if (end > target_len) { + end = target_len; + } else if (end < 0) { + end += target_len; + if (end < 0) + end = 0; + } + + /* zero-length substrings match everywhere */ + if (pattern_len == 0) + return target_len+1; + + end -= pattern_len; + + if (direction < 0) { + for (; end >= start; end--) + if (Py_STRING_MATCH(target, end, pattern, pattern_len)) { + count++; + end -= pattern_len-1; + } + } else { + for (; start <= end; start++) + if (Py_STRING_MATCH(target, start, pattern, pattern_len)) { + count++; + start += pattern_len-1; + } + } + return count; +} - Return the number of distinct times PAT is found in MEM. - meaning mem=1111 and pat==11 returns 2. - mem=11111 and pat==11 also return 2. - */ -static Py_ssize_t -mymemcnt(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len) -{ - register Py_ssize_t offset = 0; - Py_ssize_t nfound = 0; - while (len >= 0) { - offset = mymemfind(mem, len, pat, pat_len); +/* Algorithms for difference cases of string replacement */ + +/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ +static PyStringObject * +replace_interleave(PyStringObject *self, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *self_s, *to_s, *result_s; + Py_ssize_t self_len, to_len, result_len; + Py_ssize_t count, i, product; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + to_len = PyString_GET_SIZE(to); + + /* 1 at the end plus 1 after every character */ + count = self_len+1; + if (maxcount < count) + count = maxcount; + + /* Check for overflow */ + /* result_len = count * to_len + self_len; */ + product = count * to_len; + if (product / to_len != count) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + result_len = product + self_len; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + + if (! (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) ) + return NULL; + + self_s = PyString_AS_STRING(self); + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + result_s = PyString_AS_STRING(result); + + /* TODO: special case single character, which doesn't need memcpy */ + + /* Lay the first one down (guaranteed this will occur) */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + count -= 1; + + for (i=0; i=1, len(from)==1, to="", maxcount>=1 */ +static PyStringObject * +replace_delete_single_character(PyStringObject *self, + char from_c, Py_ssize_t maxcount) +{ + char *self_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, result_len; + Py_ssize_t count; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + self_s = PyString_AS_STRING(self); + + count = countchar(self_s, self_len, from_c); + if (count == 0) { + return return_self(self); + } + if (count > maxcount) + count = maxcount; + + result_len = self_len - count; /* from_len == 1 */ + assert(result_len>=0); + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) + break; + memcpy(result_s, start, next-start); + result_s += (next-start); + start = next+1; + } + memcpy(result_s, start, end-start); + + return result; +} + +/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ + +static PyStringObject * +replace_delete_substring(PyStringObject *self, PyStringObject *from, + Py_ssize_t maxcount) { + char *self_s, *from_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, from_len, result_len; + Py_ssize_t count, offset; + PyStringObject *result; + + self_len = PyString_GET_SIZE(self); + self_s = PyString_AS_STRING(self); + from_len = PyString_GET_SIZE(from); + from_s = PyString_AS_STRING(from); + + count = countstring(self_s, self_len, + from_s, from_len, + 0, self_len, 1); + + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches */ + return return_self(self); + } + + result_len = self_len - (count * from_len); + assert (result_len>=0); + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL ) + return NULL; + + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); if (offset == -1) break; - mem += offset + pat_len; - len -= offset + pat_len; - nfound++; + next = start + offset; + + memcpy(result_s, start, next-start); + + result_s += (next-start); + start = next+from_len; } - return nfound; + memcpy(result_s, start, end-start); + return result; } -/* - mymemreplace +/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ +static PyStringObject * +replace_single_character_in_place(PyStringObject *self, + char from_c, char to_c, + Py_ssize_t maxcount) +{ + char *self_s, *result_s, *start, *end, *next; + Py_ssize_t self_len; + PyStringObject *result; + + /* The result string will be the same size */ + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + next = findchar(self_s, self_len, from_c); + + if (next == NULL) { + /* No matches; return the original string */ + return return_self(self); + } + + /* Need to make a new string */ + result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len); + if (result == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + memcpy(result_s, self_s, self_len); + + /* change everything in-place, starting with this one */ + start = result_s + (next-self_s); + *start = to_c; + start++; + end = result_s + self_len; + + while (--maxcount > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) + break; + *next = to_c; + start = next+1; + } + + return result; +} - Return a string in which all occurrences of PAT in memory STR are - replaced with SUB. +/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_substring_in_place(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *result_s, *start, *end; + char *self_s, *from_s, *to_s; + Py_ssize_t self_len, from_len, offset; + PyStringObject *result; + + /* The result string will be the same size */ + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + from_s = PyString_AS_STRING(from); + from_len = PyString_GET_SIZE(from); + to_s = PyString_AS_STRING(to); + + offset = findstring(self_s, self_len, + from_s, from_len, + 0, self_len, FORWARD); + + if (offset == -1) { + /* No matches; return the original string */ + return return_self(self); + } + + /* Need to make a new string */ + result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len); + if (result == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + memcpy(result_s, self_s, self_len); - If length of PAT is less than length of STR or there are no occurrences - of PAT in STR, then the original string is returned. Otherwise, a new - string is allocated here and returned. - - on return, out_len is: - the length of output string, or - -1 if the input string is returned, or - unchanged if an error occurs (no memory). - - return value is: - the new string allocated locally, or - NULL if an error occurred. -*/ -static char * -mymemreplace(const char *str, Py_ssize_t len, /* input string */ - const char *pat, Py_ssize_t pat_len, /* pattern string to find */ - const char *sub, Py_ssize_t sub_len, /* substitution string */ - Py_ssize_t count, /* number of replacements */ - Py_ssize_t *out_len) -{ - char *out_s; - char *new_s; - Py_ssize_t nfound, offset, new_len; - - if (len == 0 || (pat_len == 0 && sub_len == 0) || pat_len > len) - goto return_same; - - /* find length of output string */ - nfound = (pat_len > 0) ? mymemcnt(str, len, pat, pat_len) : len + 1; - if (count < 0) - count = PY_SSIZE_T_MAX; - else if (nfound > count) - nfound = count; - if (nfound == 0) - goto return_same; - - new_len = len + nfound*(sub_len - pat_len); - if (new_len == 0) { - /* Have to allocate something for the caller to free(). */ - out_s = (char *)PyMem_MALLOC(1); - if (out_s == NULL) - return NULL; - out_s[0] = '\0'; + + /* change everything in-place, starting with this one */ + start = result_s + offset; + memcpy(start, to_s, from_len); + start += from_len; + end = result_s + self_len; + + while ( --maxcount > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); + if (offset==-1) + break; + memcpy(start+offset, to_s, from_len); + start += offset+from_len; } - else { - assert(new_len > 0); - new_s = (char *)PyMem_MALLOC(new_len); - if (new_s == NULL) - return NULL; - out_s = new_s; + + return result; +} - if (pat_len > 0) { - for (; nfound > 0; --nfound) { - /* find index of next instance of pattern */ - offset = mymemfind(str, len, pat, pat_len); - if (offset == -1) - break; +/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_single_character(PyStringObject *self, + char from_c, + PyStringObject *to, + Py_ssize_t maxcount) +{ + char *self_s, *to_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, to_len, result_len; + Py_ssize_t count, product; + PyStringObject *result; + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + + count = countchar(self_s, self_len, from_c); + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + + /* use the difference between current and new, hence the "-1" */ + /* result_len = self_len + count * (to_len-1) */ + product = count * (to_len-1); + if (product / (to_len-1) != count) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + result_len = self_len + product; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end-start, from_c); + if (next == NULL) + break; + + if (next == start) { + /* replace with the 'to' */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + start += 1; + } else { + /* copy the unchanged old then the 'to' */ + memcpy(result_s, start, next-start); + result_s += (next-start); + memcpy(result_s, to_s, to_len); + result_s += to_len; + start = next+1; + } + } + /* Copy the remainder of the remaining string */ + memcpy(result_s, start, end-start); + + return result; +} - /* copy non matching part of input string */ - memcpy(new_s, str, offset); - str += offset + pat_len; - len -= offset + pat_len; - - /* copy substitute into the output string */ - new_s += offset; - memcpy(new_s, sub, sub_len); - new_s += sub_len; - } - /* copy any remaining values into output string */ - if (len > 0) - memcpy(new_s, str, len); +/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ +static PyStringObject * +replace_substring(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) { + char *self_s, *from_s, *to_s, *result_s; + char *start, *next, *end; + Py_ssize_t self_len, from_len, to_len, result_len; + Py_ssize_t count, offset, product; + PyStringObject *result; + + self_s = PyString_AS_STRING(self); + self_len = PyString_GET_SIZE(self); + from_s = PyString_AS_STRING(from); + from_len = PyString_GET_SIZE(from); + + count = countstring(self_s, self_len, + from_s, from_len, + 0, self_len, FORWARD); + if (count > maxcount) + count = maxcount; + + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + to_s = PyString_AS_STRING(to); + to_len = PyString_GET_SIZE(to); + + /* Check for overflow */ + /* result_len = self_len + count * (to_len-from_len) */ + product = count * (to_len-from_len); + if (product / (to_len-from_len) != count) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + result_len = self_len + product; + if (result_len < 0) { + PyErr_SetString(PyExc_OverflowError, "replace string is too long"); + return NULL; + } + + if ( (result = (PyStringObject *) + PyString_FromStringAndSize(NULL, result_len)) == NULL) + return NULL; + result_s = PyString_AS_STRING(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = findstring(start, end-start, + from_s, from_len, + 0, end-start, FORWARD); + if (offset == -1) + break; + next = start+offset; + if (next == start) { + /* replace with the 'to' */ + memcpy(result_s, to_s, to_len); + result_s += to_len; + start += from_len; + } else { + /* copy the unchanged old then the 'to' */ + memcpy(result_s, start, next-start); + result_s += (next-start); + memcpy(result_s, to_s, to_len); + result_s += to_len; + start = next+from_len; } - else { - for (;;++str, --len) { - memcpy(new_s, sub, sub_len); - new_s += sub_len; - if (--nfound <= 0) { - memcpy(new_s, str, len); - break; - } - *new_s++ = *str; - } + } + /* Copy the remainder of the remaining string */ + memcpy(result_s, start, end-start); + + return result; +} + + +static PyStringObject * +replace(PyStringObject *self, + PyStringObject *from, + PyStringObject *to, + Py_ssize_t maxcount) +{ + Py_ssize_t from_len, to_len; + + if (maxcount < 0) { + maxcount = PY_SSIZE_T_MAX; + } else if (maxcount == 0 || PyString_GET_SIZE(self) == 0) { + /* nothing to do; return the original string */ + return return_self(self); + } + + from_len = PyString_GET_SIZE(from); + to_len = PyString_GET_SIZE(to); + + if (maxcount == 0 || + (from_len == 0 && to_len == 0)) { + /* nothing to do; return the original string */ + return return_self(self); + } + + /* Handle zero-length special cases */ + + if (from_len == 0) { + /* insert the 'to' string everywhere. */ + /* >>> "Python".replace("", ".") */ + /* '.P.y.t.h.o.n.' */ + return replace_interleave(self, to, maxcount); + } + + /* Except for "".replace("", "A") == "A" there is no way beyond this */ + /* point for an empty self string to generate a non-empty string */ + /* Special case so the remaining code always gets a non-empty string */ + if (PyString_GET_SIZE(self) == 0) { + return return_self(self); + } + + if (to_len == 0) { + /* delete all occurances of 'from' string */ + if (from_len == 1) { + return replace_delete_single_character( + self, PyString_AS_STRING(from)[0], maxcount); + } else { + return replace_delete_substring(self, from, maxcount); } } - *out_len = new_len; - return out_s; - return_same: - *out_len = -1; - return (char *)str; /* cast away const */ -} + /* Handle special case where both strings have the same length */ + + if (from_len == to_len) { + if (from_len == 1) { + return replace_single_character_in_place( + self, + PyString_AS_STRING(from)[0], + PyString_AS_STRING(to)[0], + maxcount); + } else { + return replace_substring_in_place( + self, from, to, maxcount); + } + } + /* Otherwise use the more generic algorithms */ + if (from_len == 1) { + return replace_single_character(self, PyString_AS_STRING(from)[0], + to, maxcount); + } else { + /* len('from')>=2, len('to')>=1 */ + return replace_substring(self, from, to, maxcount); + } +} PyDoc_STRVAR(replace__doc__, "S.replace (old, new[, count]) -> string\n\ @@ -2529,66 +3207,42 @@ static PyObject * string_replace(PyStringObject *self, PyObject *args) { - const char *str = PyString_AS_STRING(self), *sub, *repl; - char *new_s; - const Py_ssize_t len = PyString_GET_SIZE(self); - Py_ssize_t sub_len, repl_len, out_len; Py_ssize_t count = -1; - PyObject *newobj; - PyObject *subobj, *replobj; + PyObject *from, *to; + const char *tmp_s; + Py_ssize_t tmp_len; - if (!PyArg_ParseTuple(args, "OO|n:replace", - &subobj, &replobj, &count)) + if (!PyArg_ParseTuple(args, "OO|n:replace", &from, &to, &count)) return NULL; - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - sub_len = PyString_GET_SIZE(subobj); + if (PyString_Check(from)) { + /* Can this be made a '!check' after the Unicode check? */ } #ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) + if (PyUnicode_Check(from)) return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); + from, to, count); #endif - else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) + else if (PyObject_AsCharBuffer(from, &tmp_s, &tmp_len)) return NULL; - if (PyString_Check(replobj)) { - repl = PyString_AS_STRING(replobj); - repl_len = PyString_GET_SIZE(replobj); + if (PyString_Check(to)) { + /* Can this be made a '!check' after the Unicode check? */ } #ifdef Py_USING_UNICODE - else if (PyUnicode_Check(replobj)) + else if (PyUnicode_Check(to)) return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); + from, to, count); #endif - else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len)) + else if (PyObject_AsCharBuffer(to, &tmp_s, &tmp_len)) return NULL; - new_s = mymemreplace(str,len,sub,sub_len,repl,repl_len,count,&out_len); - if (new_s == NULL) { - PyErr_NoMemory(); - return NULL; - } - if (out_len == -1) { - if (PyString_CheckExact(self)) { - /* we're returning another reference to self */ - newobj = (PyObject*)self; - Py_INCREF(newobj); - } - else { - newobj = PyString_FromStringAndSize(str, len); - if (newobj == NULL) - return NULL; - } - } - else { - newobj = PyString_FromStringAndSize(new_s, out_len); - PyMem_FREE(new_s); - } - return newobj; + return (PyObject *)replace((PyStringObject *) self, + (PyStringObject *) from, + (PyStringObject *) to, count); } +/** End DALKE **/ PyDoc_STRVAR(startswith__doc__, "S.startswith(prefix[, start[, end]]) -> bool\n\ @@ -3312,6 +3966,7 @@ {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, {"endswith", (PyCFunction)string_endswith, METH_VARARGS, endswith__doc__}, + {"partition", (PyCFunction)string_partition, METH_O, partition__doc__}, {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, {"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__}, Modified: python/branches/blais-bytebuf/Objects/typeobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/typeobject.c (original) +++ python/branches/blais-bytebuf/Objects/typeobject.c Fri May 26 13:03:30 2006 @@ -4641,10 +4641,10 @@ (void *)PyObject_GenericGetAttr)) res = PyObject_GenericGetAttr(self, name); else - res = PyObject_CallFunction(getattribute, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattribute, self, name, NULL); if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); - res = PyObject_CallFunction(getattr, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattr, self, name, NULL); } return res; } @@ -4781,7 +4781,7 @@ obj = Py_None; if (type == NULL) type = Py_None; - return PyObject_CallFunction(get, "OOO", self, obj, type); + return PyObject_CallFunctionObjArgs(get, self, obj, type, NULL); } static int @@ -5728,8 +5728,8 @@ if (su->ob_type != &PySuper_Type) /* If su is an instance of a (strict) subclass of super, call its type */ - return PyObject_CallFunction((PyObject *)su->ob_type, - "OO", su->type, obj); + return PyObject_CallFunctionObjArgs((PyObject *)su->ob_type, + su->type, obj, NULL); else { /* Inline the common case */ PyTypeObject *obj_type = supercheck(su->type, obj); Modified: python/branches/blais-bytebuf/Objects/unicodeobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/unicodeobject.c (original) +++ python/branches/blais-bytebuf/Objects/unicodeobject.c Fri May 26 13:03:30 2006 @@ -4,6 +4,9 @@ modified by Marc-Andre Lemburg according to the Unicode Integration Proposal (see file Misc/unicode.txt). +Major speed upgrades to the method implementations at the Reykjavik +NeedForSpeed sprint, by Fredrik Lundh and Andrew Dalke. + Copyright (c) Corporation for National Research Initiatives. -------------------------------------------------------------------- @@ -193,6 +196,7 @@ /* Resizing shared object (unicode_empty or single character objects) in-place is not allowed. Use PyUnicode_Resize() instead ! */ + if (unicode == unicode_empty || (unicode->length == 1 && unicode->str[0] < 256U && @@ -202,8 +206,11 @@ return -1; } - /* We allocate one more byte to make sure the string is - Ux0000 terminated -- XXX is this needed ? */ + /* We allocate one more byte to make sure the string is Ux0000 terminated. + The overallocation is also used by fastsearch, which assumes that it's + safe to look at str[length] (without makeing any assumptions about what + it contains). */ + oldstr = unicode->str; PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1); if (!unicode->str) { @@ -3859,16 +3866,16 @@ /* --- Helpers ------------------------------------------------------------ */ -#define USE_FAST /* experimental fast search implementation */ - /* fast search/count implementation, based on a mix between boyer- moore and horspool, with a few more bells and whistles on the top. for some more background, see: http://effbot.org/stringlib */ /* note: fastsearch may access s[n], which isn't a problem when using - Python's ordinary string types. also, the count mode returns -1 if - there cannot possible be a match in the target string, and 0 if it - has actually checked for matches. */ + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possible be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ #define FAST_COUNT 0 #define FAST_SEARCH 1 @@ -3877,7 +3884,7 @@ fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) { long mask; - int skip, count = 0; + Py_ssize_t skip, count = 0; Py_ssize_t i, j, mlast, w; w = n - m; @@ -3934,10 +3941,8 @@ /* miss: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) i = i + m; - else { + else i = i + skip; - continue; - } } else { /* skip: check if next character is part of pattern */ if (!(mask & (1 << (s[i+m] & 0x1F)))) @@ -3971,23 +3976,13 @@ if (substring->length == 0) return (end - start + 1); -#ifdef USE_FAST count = fastsearch( PyUnicode_AS_UNICODE(self) + start, end - start, substring->str, substring->length, FAST_COUNT ); + if (count < 0) count = 0; /* no match */ -#else - end -= substring->length; - - while (start <= end) - if (Py_UNICODE_MATCH(self, start, substring)) { - count++; - start += substring->length; - } else - start++; -#endif return count; } @@ -4038,30 +4033,19 @@ if (substring->length == 0) return (direction > 0) ? start : end; -#ifdef USE_FAST if (direction > 0) { Py_ssize_t pos = fastsearch( PyUnicode_AS_UNICODE(self) + start, end - start, substring->str, substring->length, FAST_SEARCH ); - if (pos < 0) - return pos; - return pos + start; - } -#endif - - end -= substring->length; - - if (direction < 0) { + if (pos >= 0) + return pos + start; + } else { + end -= substring->length; for (; end >= start; end--) if (Py_UNICODE_MATCH(self, end, substring)) return end; - } else { - for (; start <= end; start++) - if (Py_UNICODE_MATCH(self, start, substring)) - return start; } - return -1; } @@ -4862,6 +4846,7 @@ } else { Py_ssize_t n, i; + Py_ssize_t product, new_size, delta; Py_UNICODE *p; /* replace strings */ @@ -4870,7 +4855,25 @@ n = maxcount; if (n == 0) goto nothing; - u = _PyUnicode_New(self->length + n * (str2->length - str1->length)); + /* new_size = self->length + n * (str2->length - str1->length)); */ + delta = (str2->length - str1->length); + if (delta == 0) { + new_size = self->length; + } else { + product = n * (str2->length - str1->length); + if ((product / (str2->length - str1->length)) != n) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + new_size = self->length + product; + if (new_size < 0) { + PyErr_SetString(PyExc_OverflowError, + "replace string is too long"); + return NULL; + } + } + u = _PyUnicode_New(new_size); if (!u) return NULL; i = 0; @@ -5146,11 +5149,8 @@ PyObject *element) { PyUnicodeObject *u, *v; - int result; Py_ssize_t size; -#ifdef USE_FAST Py_ssize_t pos; -#endif /* Coerce the two arguments */ v = (PyUnicodeObject *) PyUnicode_FromObject(element); @@ -5168,44 +5168,19 @@ size = PyUnicode_GET_SIZE(v); if (!size) { - result = 1; + pos = 0; goto done; } -#ifdef USE_FAST pos = fastsearch( PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), PyUnicode_AS_UNICODE(v), size, FAST_SEARCH ); - result = (pos != -1); -#else - result = 0; - - if (size == 1) { - Py_UNICODE chr = PyUnicode_AS_UNICODE(v)[0]; - Py_UNICODE* ptr = PyUnicode_AS_UNICODE(u); - Py_UNICODE* end = ptr + PyUnicode_GET_SIZE(u); - for (; ptr < end; ptr++) { - if (*ptr == chr) { - result = 1; - break; - } - } - } else { - Py_ssize_t start = 0; - Py_ssize_t end = PyUnicode_GET_SIZE(u) - size; - for (; start <= end; start++) - if (Py_UNICODE_MATCH(u, start, v)) { - result = 1; - break; - } - } -#endif done: Py_DECREF(u); Py_DECREF(v); - return result; + return (pos != -1); } /* Concat to string or Unicode object giving a new Unicode object. */ @@ -5285,7 +5260,7 @@ if (end < 0) end = 0; - result = PyInt_FromLong((long) count(self, start, end, substring)); + result = PyInt_FromSsize_t(count(self, start, end, substring)); Py_DECREF(substring); return result; @@ -6314,6 +6289,79 @@ return PyUnicode_Split((PyObject *)self, substring, maxcount); } +PyObject * +PyUnicode_Partition(PyObject *str_in, PyObject *sep_in) +{ + PyObject* str_obj; + PyObject* sep_obj; + Py_UNICODE *str, *sep; + Py_ssize_t len, sep_len, pos; + PyObject* out; + + str_obj = PyUnicode_FromObject(str_in); + if (!str_obj) + return NULL; + sep_obj = PyUnicode_FromObject(sep_in); + if (!sep_obj) + goto error; + + str = PyUnicode_AS_UNICODE(str_obj); + len = PyUnicode_GET_SIZE(str_obj); + + sep = PyUnicode_AS_UNICODE(sep_obj); + sep_len = PyUnicode_GET_SIZE(sep_obj); + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + goto error; + } + + out = PyTuple_New(3); + if (!out) + goto error; + + pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); + if (pos < 0) { + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); + Py_INCREF(unicode_empty); + PyTuple_SET_ITEM(out, 1, (PyObject*) unicode_empty); + Py_INCREF(unicode_empty); + PyTuple_SET_ITEM(out, 2, (PyObject*) unicode_empty); + } else { + PyObject* obj; + PyTuple_SET_ITEM(out, 0, PyUnicode_FromUnicode(str, pos)); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + obj = PyUnicode_FromUnicode(str + sep_len + pos, len - sep_len - pos); + PyTuple_SET_ITEM(out, 2, obj); + if (PyErr_Occurred()) { + Py_DECREF(out); + goto error; + } + } + + return out; + +error: + Py_XDECREF(sep_obj); + Py_DECREF(str_obj); + return NULL; +} + +PyDoc_STRVAR(partition__doc__, +"S.partition(sep) -> (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, and returns the part before it,\n\ +the separator itself, and the part after it. If the separator is not\n\ +found, returns S and two empty strings."); + +static PyObject* +unicode_partition(PyUnicodeObject *self, PyObject *separator) +{ + return PyUnicode_Partition((PyObject *)self, separator); +} + PyObject *PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) @@ -6567,6 +6615,7 @@ {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__doc__}, {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, + {"partition", (PyCFunction) unicode_partition, METH_O, partition__doc__}, {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, Modified: python/branches/blais-bytebuf/Objects/weakrefobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/weakrefobject.c (original) +++ python/branches/blais-bytebuf/Objects/weakrefobject.c Fri May 26 13:03:30 2006 @@ -851,7 +851,7 @@ static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunction(callback, "O", ref); + PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); if (cbresult == NULL) PyErr_WriteUnraisable(callback); Modified: python/branches/blais-bytebuf/PC/pyconfig.h ============================================================================== --- python/branches/blais-bytebuf/PC/pyconfig.h (original) +++ python/branches/blais-bytebuf/PC/pyconfig.h Fri May 26 13:03:30 2006 @@ -162,6 +162,7 @@ #include #define Py_IS_NAN _isnan #define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) +#define Py_IS_FINITE(X) _finite(X) #endif /* _MSC_VER */ Modified: python/branches/blais-bytebuf/Python/ceval.c ============================================================================== --- python/branches/blais-bytebuf/Python/ceval.c (original) +++ python/branches/blais-bytebuf/Python/ceval.c Fri May 26 13:03:30 2006 @@ -4053,7 +4053,7 @@ metaclass = (PyObject *) &PyClass_Type; Py_INCREF(metaclass); } - result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods); + result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); Py_DECREF(metaclass); if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { /* A type error here likely means that the user passed Modified: python/branches/blais-bytebuf/Python/import.c ============================================================================== --- python/branches/blais-bytebuf/Python/import.c (original) +++ python/branches/blais-bytebuf/Python/import.c Fri May 26 13:03:30 2006 @@ -1043,7 +1043,7 @@ PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = PyObject_CallFunction(hook, "O", p); + importer = PyObject_CallFunctionObjArgs(hook, p, NULL); if (importer != NULL) break; @@ -2499,8 +2499,8 @@ goto err; /* Call the _import__ function with the proper argument list */ - r = PyObject_CallFunction(import, "OOOO", - module_name, globals, globals, silly_list); + r = PyObject_CallFunctionObjArgs(import, module_name, globals, + globals, silly_list, NULL); err: Py_XDECREF(globals); Modified: python/branches/blais-bytebuf/Python/mystrtoul.c ============================================================================== --- python/branches/blais-bytebuf/Python/mystrtoul.c (original) +++ python/branches/blais-bytebuf/Python/mystrtoul.c Fri May 26 13:03:30 2006 @@ -75,34 +75,6 @@ 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */ 6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */ -/* char-to-digit conversion for bases 2-36; all non-digits are 37 */ -static int digitlookup[] = { - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 37, 37, 37, 37, 37, 37, - 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, - 37, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 -}; - /* ** strtoul ** This is a general purpose routine for converting @@ -167,7 +139,7 @@ ovlimit = digitlimit[base]; /* do the conversion until non-digit character encountered */ - while ((c = digitlookup[Py_CHARMASK(*str)]) < base) { + while ((c = _PyLong_DigitValue[Py_CHARMASK(*str)]) < base) { if (ovlimit > 0) /* no overflow check required */ result = result * base + c; else { /* requires overflow check */ @@ -204,7 +176,7 @@ overflowed: if (ptr) { /* spool through remaining digit characters */ - while (digitlookup[Py_CHARMASK(*str)] < base) + while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base) ++str; *ptr = str; } Modified: python/branches/blais-bytebuf/Python/pystrtod.c ============================================================================== --- python/branches/blais-bytebuf/Python/pystrtod.c (original) +++ python/branches/blais-bytebuf/Python/pystrtod.c Fri May 26 13:03:30 2006 @@ -101,7 +101,7 @@ char *copy, *c; /* We need to convert the '.' to the locale specific decimal point */ - copy = (char *)malloc(end - nptr + 1 + decimal_point_len); + copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len); c = copy; memcpy(c, nptr, decimal_point_pos - nptr); @@ -122,7 +122,7 @@ fail_pos = (char *)nptr + (fail_pos - copy); } - free(copy); + PyMem_FREE(copy); } else { From python-checkins at python.org Fri May 26 13:11:38 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 13:11:38 +0200 (CEST) Subject: [Python-checkins] r46285 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526111138.820D11E4002@bag.python.org> Author: andrew.dalke Date: Fri May 26 13:11:38 2006 New Revision: 46285 Modified: python/trunk/Lib/test/string_tests.py Log: Added a few more test cases for whitespace split. These strings have leading whitespace. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 13:11:38 2006 @@ -246,6 +246,13 @@ self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) + self.checkequal([], ' ', 'split') + self.checkequal(['a'], ' a ', 'split') + self.checkequal(['a', 'b'], ' a b ', 'split') + self.checkequal(['a', 'b '], ' a b ', 'split', None, 1) + self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) + self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) + # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1) From python-checkins at python.org Fri May 26 13:15:18 2006 From: python-checkins at python.org (jack.diederich) Date: Fri, 26 May 2006 13:15:18 +0200 (CEST) Subject: [Python-checkins] r46286 - python/trunk/Modules/itertoolsmodule.c Message-ID: <20060526111518.1E72E1E4011@bag.python.org> Author: jack.diederich Date: Fri May 26 13:15:17 2006 New Revision: 46286 Modified: python/trunk/Modules/itertoolsmodule.c Log: use Py_ssize_t in places that may need it Modified: python/trunk/Modules/itertoolsmodule.c ============================================================================== --- python/trunk/Modules/itertoolsmodule.c (original) +++ python/trunk/Modules/itertoolsmodule.c Fri May 26 13:15:17 2006 @@ -1093,10 +1093,10 @@ typedef struct { PyObject_HEAD PyObject *it; - long next; - long stop; - long step; - long cnt; + Py_ssize_t next; + Py_ssize_t stop; + Py_ssize_t step; + Py_ssize_t cnt; } isliceobject; static PyTypeObject islice_type; @@ -1105,7 +1105,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *seq; - long start=0, stop=-1, step=1; + Py_ssize_t start=0, stop=-1, step=1; PyObject *it, *a1=NULL, *a2=NULL, *a3=NULL; Py_ssize_t numargs; isliceobject *lz; @@ -1119,7 +1119,7 @@ numargs = PyTuple_Size(args); if (numargs == 2) { if (a1 != Py_None) { - stop = PyInt_AsLong(a1); + stop = PyInt_AsSsize_t(a1); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1130,11 +1130,11 @@ } } else { if (a1 != Py_None) - start = PyInt_AsLong(a1); + start = PyInt_AsSsize_t(a1); if (start == -1 && PyErr_Occurred()) PyErr_Clear(); if (a2 != Py_None) { - stop = PyInt_AsLong(a2); + stop = PyInt_AsSsize_t(a2); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1152,7 +1152,7 @@ if (a3 != NULL) { if (a3 != Py_None) - step = PyInt_AsLong(a3); + step = PyInt_AsSsize_t(a3); if (step == -1 && PyErr_Occurred()) PyErr_Clear(); } @@ -1202,7 +1202,7 @@ { PyObject *item; PyObject *it = lz->it; - long oldnext; + Py_ssize_t oldnext; PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); @@ -1600,8 +1600,8 @@ typedef struct { PyObject_HEAD - Py_ssize_t tuplesize; - long iternum; /* which iterator is active */ + Py_ssize_t tuplesize; + Py_ssize_t iternum; /* which iterator is active */ PyObject *ittuple; /* tuple of iterators */ } chainobject; @@ -1612,7 +1612,7 @@ { chainobject *lz; Py_ssize_t tuplesize = PySequence_Length(args); - int i; + Py_ssize_t i; PyObject *ittuple; if (!_PyArg_NoKeywords("chain()", kwds)) @@ -2033,7 +2033,7 @@ typedef struct { PyObject_HEAD - long cnt; + Py_ssize_t cnt; } countobject; static PyTypeObject count_type; @@ -2042,12 +2042,12 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { countobject *lz; - long cnt = 0; + Py_ssize_t cnt = 0; if (!_PyArg_NoKeywords("count()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "|l:count", &cnt)) + if (!PyArg_ParseTuple(args, "|n:count", &cnt)) return NULL; /* create countobject structure */ @@ -2062,13 +2062,13 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromLong(lz->cnt++); + return PyInt_FromSize_t(lz->cnt++); } static PyObject * count_repr(countobject *lz) { - return PyString_FromFormat("count(%ld)", lz->cnt); + return PyString_FromFormat("count(%zd)", lz->cnt); } PyDoc_STRVAR(count_doc, @@ -2138,7 +2138,7 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { izipobject *lz; - int i; + Py_ssize_t i; PyObject *ittuple; /* tuple of iterators */ PyObject *result; Py_ssize_t tuplesize = PySequence_Length(args); @@ -2212,7 +2212,7 @@ static PyObject * izip_next(izipobject *lz) { - int i; + Py_ssize_t i; Py_ssize_t tuplesize = lz->tuplesize; PyObject *result = lz->result; PyObject *it; @@ -2314,7 +2314,7 @@ typedef struct { PyObject_HEAD PyObject *element; - long cnt; + Py_ssize_t cnt; } repeatobject; static PyTypeObject repeat_type; @@ -2324,12 +2324,12 @@ { repeatobject *ro; PyObject *element; - long cnt = -1; + Py_ssize_t cnt = -1; if (!_PyArg_NoKeywords("repeat()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt)) + if (!PyArg_ParseTuple(args, "O|n:repeat", &element, &cnt)) return NULL; if (PyTuple_Size(args) == 2 && cnt < 0) @@ -2383,7 +2383,7 @@ result = PyString_FromFormat("repeat(%s)", PyString_AS_STRING(objrepr)); else - result = PyString_FromFormat("repeat(%s, %ld)", + result = PyString_FromFormat("repeat(%s, %zd)", PyString_AS_STRING(objrepr), ro->cnt); Py_DECREF(objrepr); return result; @@ -2396,7 +2396,7 @@ PyErr_SetString(PyExc_TypeError, "len() of unsized object"); return NULL; } - return PyInt_FromLong(ro->cnt); + return PyInt_FromSize_t(ro->cnt); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); From python-checkins at python.org Fri May 26 13:15:22 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 13:15:22 +0200 (CEST) Subject: [Python-checkins] r46287 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526111522.9EF261E4011@bag.python.org> Author: andrew.dalke Date: Fri May 26 13:15:22 2006 New Revision: 46287 Modified: python/trunk/Lib/test/string_tests.py Log: Added split whitespace checks for characters other than space. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 13:15:22 2006 @@ -252,6 +252,7 @@ self.checkequal(['a', 'b '], ' a b ', 'split', None, 1) self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) + self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split') # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') From python-checkins at python.org Fri May 26 13:17:56 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 13:17:56 +0200 (CEST) Subject: [Python-checkins] r46288 - python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile Message-ID: <20060526111756.3967B1E400D@bag.python.org> Author: ronald.oussoren Date: Fri May 26 13:17:55 2006 New Revision: 46288 Modified: python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile Log: Fix buglet in postinstall script, it would generate an invalid .cshrc file. Modified: python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile ============================================================================== --- python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile (original) +++ python/trunk/Mac/OSX/BuildScript/scripts/postflight.patch-profile Fri May 26 13:17:55 2006 @@ -41,7 +41,7 @@ echo "" >> "${HOME}/.cshrc" echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc" echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc" - echo "setenv path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" + echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" exit 0 ;; bash) From buildbot at python.org Fri May 26 13:19:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 11:19:06 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060526111906.A15491E400C@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/539 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 13:20:07 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 13:20:07 +0200 (CEST) Subject: [Python-checkins] r46289 - python/branches/blais-bytebuf/Modules/_struct.c Message-ID: <20060526112007.36CB81E400E@bag.python.org> Author: martin.blais Date: Fri May 26 13:20:06 2006 New Revision: 46289 Modified: python/branches/blais-bytebuf/Modules/_struct.c Log: Removed duplicated convertbuffer() call. Modified: python/branches/blais-bytebuf/Modules/_struct.c ============================================================================== --- python/branches/blais-bytebuf/Modules/_struct.c (original) +++ python/branches/blais-bytebuf/Modules/_struct.c Fri May 26 13:20:06 2006 @@ -15,8 +15,6 @@ typedef int Py_ssize_t; #endif -/* Forward declarations */ -static Py_ssize_t convertbuffer(PyObject *, void **p); /* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the struct API to return int instead of long when possible. This is @@ -1447,9 +1445,11 @@ } /* Extract a writable memory buffer from the first argument */ - buffer_len = convertbuffer(PyTuple_GET_ITEM(args, 0), (void**)&buffer); - if (buffer_len < 0) + if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), + (void**)&buffer, &buffer_len) == -1 ) { return NULL; + } + assert( buffer_len >= 0 ); /* Extract the offset from the first argument */ offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1)); @@ -1474,40 +1474,6 @@ return Py_None; } -/* - * Important Note: this is a slightly modified copy of - * getargs.c:convertbuffer(). All we want to achieve is to convert a PyObject - * into a writeable buffer. We should seriously consider adding this function - * to the API somehow. - */ -static Py_ssize_t -convertbuffer(PyObject *arg, void **p) -{ - PyBufferProcs *pb = arg->ob_type->tp_as_buffer; - Py_ssize_t count; - if (pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL) { - - PyErr_SetString(StructError, - "string or read-only buffer"); - return -1; - } - - if ((*pb->bf_getsegcount)(arg, NULL) != 1) { - - PyErr_SetString(StructError, - "string or single-segment read-only buffer"); - return -1; - } - - if ((count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0) { - PyErr_SetString(StructError, "(unspecified)"); - } - - return count; -} - /* List of functions */ From python-checkins at python.org Fri May 26 13:26:12 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 13:26:12 +0200 (CEST) Subject: [Python-checkins] r46290 - python/trunk/Lib/UserString.py Message-ID: <20060526112612.992541E4011@bag.python.org> Author: georg.brandl Date: Fri May 26 13:26:11 2006 New Revision: 46290 Modified: python/trunk/Lib/UserString.py Log: Add "partition" to UserString. Modified: python/trunk/Lib/UserString.py ============================================================================== --- python/trunk/Lib/UserString.py (original) +++ python/trunk/Lib/UserString.py Fri May 26 13:26:11 2006 @@ -102,6 +102,7 @@ return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) + def partition(self, sep): return self.data.partition(sep) def replace(self, old, new, maxsplit=-1): return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=sys.maxint): From python-checkins at python.org Fri May 26 13:29:39 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 13:29:39 +0200 (CEST) Subject: [Python-checkins] r46291 - in python/trunk: Include/pyport.h Python/ceval.c Message-ID: <20060526112939.E8DFC1E400C@bag.python.org> Author: fredrik.lundh Date: Fri May 26 13:29:39 2006 New Revision: 46291 Modified: python/trunk/Include/pyport.h python/trunk/Python/ceval.c Log: needforspeed: added Py_LOCAL macro, based on the LOCAL macro used for SRE and others. applied Py_LOCAL to relevant portion of ceval, which gives a 1-2% speedup on my machine. ymmv. Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Fri May 26 13:29:39 2006 @@ -137,6 +137,23 @@ # endif #endif +/* PY_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. It also enables + * inlining, where suitable. */ + +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) + /* ignore warnings if the compiler decides not to inline a function */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define Py_LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define Py_LOCAL(type) static inline type +#else +#define Py_LOCAL(type) static type +#endif + #include #include /* Moved here from the math section, before extern "C" */ Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Fri May 26 13:29:39 2006 @@ -30,7 +30,7 @@ #define READ_TIMESTAMP(var) ppc_getcounter(&var) -static void +Py_LOCAL(void) ppc_getcounter(uint64 *v) { register unsigned long tbu, tb, tbu2; @@ -83,44 +83,44 @@ /* Forward declarations */ #ifdef WITH_TSC -static PyObject *call_function(PyObject ***, int, uint64*, uint64*); +Py_LOCAL(PyObject *)call_function(PyObject ***, int, uint64*, uint64*); #else -static PyObject *call_function(PyObject ***, int); +Py_LOCAL(PyObject *)call_function(PyObject ***, int); #endif -static PyObject *fast_function(PyObject *, PyObject ***, int, int, int); -static PyObject *do_call(PyObject *, PyObject ***, int, int); -static PyObject *ext_do_call(PyObject *, PyObject ***, int, int, int); -static PyObject *update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -static PyObject *update_star_args(int, int, PyObject *, PyObject ***); -static PyObject *load_args(PyObject ***, int); +Py_LOCAL(PyObject *)fast_function(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *)do_call(PyObject *, PyObject ***, int, int); +Py_LOCAL(PyObject *)ext_do_call(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *)update_keyword_args(PyObject *, int, PyObject ***,PyObject *); +Py_LOCAL(PyObject *)update_star_args(int, int, PyObject *, PyObject ***); +Py_LOCAL(PyObject *)load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 #ifdef LLTRACE -static int lltrace; -static int prtrace(PyObject *, char *); +Py_LOCAL(int) lltrace; +Py_LOCAL(int) prtrace(PyObject *, char *); #endif -static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, +Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -static void call_trace_protected(Py_tracefunc, PyObject *, +Py_LOCAL(void) call_trace_protected(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); -static int maybe_call_line_trace(Py_tracefunc, PyObject *, +Py_LOCAL(void) call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); +Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *, PyFrameObject *, int *, int *, int *); -static PyObject *apply_slice(PyObject *, PyObject *, PyObject *); -static int assign_slice(PyObject *, PyObject *, +Py_LOCAL(PyObject *)apply_slice(PyObject *, PyObject *, PyObject *); +Py_LOCAL(int) assign_slice(PyObject *, PyObject *, PyObject *, PyObject *); -static PyObject *cmp_outcome(int, PyObject *, PyObject *); -static PyObject *import_from(PyObject *, PyObject *); -static int import_all_from(PyObject *, PyObject *); -static PyObject *build_class(PyObject *, PyObject *, PyObject *); -static int exec_statement(PyFrameObject *, +Py_LOCAL(PyObject *)cmp_outcome(int, PyObject *, PyObject *); +Py_LOCAL(PyObject *)import_from(PyObject *, PyObject *); +Py_LOCAL(int) import_all_from(PyObject *, PyObject *); +Py_LOCAL(PyObject *)build_class(PyObject *, PyObject *, PyObject *); +Py_LOCAL(int) exec_statement(PyFrameObject *, PyObject *, PyObject *, PyObject *); -static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); -static void reset_exc_info(PyThreadState *); -static void format_exc_check_arg(PyObject *, char *, PyObject *); -static PyObject *string_concatenate(PyObject *, PyObject *, +Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); +Py_LOCAL(void) reset_exc_info(PyThreadState *); +Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *); +Py_LOCAL(PyObject *)string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ @@ -477,7 +477,7 @@ }; static enum why_code do_raise(PyObject *, PyObject *, PyObject *); -static int unpack_iterable(PyObject *, int, PyObject **); +Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **); /* for manipulating the thread switch and periodic "stuff" - used to be per thread, now just a pair o' globals */ @@ -2888,7 +2888,7 @@ */ -static void +Py_LOCAL(void) set_exc_info(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { @@ -2933,7 +2933,7 @@ PySys_SetObject("exc_traceback", tb); } -static void +Py_LOCAL(void) reset_exc_info(PyThreadState *tstate) { PyFrameObject *frame; @@ -3080,7 +3080,7 @@ /* Iterate v argcnt times and store the results on the stack (via decreasing sp). Return 1 for success, 0 if error. */ -static int +Py_LOCAL(int) unpack_iterable(PyObject *v, int argcnt, PyObject **sp) { int i = 0; @@ -3127,7 +3127,7 @@ #ifdef LLTRACE -static int +Py_LOCAL(int) prtrace(PyObject *v, char *str) { printf("%s ", str); @@ -3138,7 +3138,7 @@ } #endif -static void +Py_LOCAL(void) call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) { PyObject *type, *value, *traceback, *arg; @@ -3164,7 +3164,7 @@ } } -static void +Py_LOCAL(void) call_trace_protected(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3181,7 +3181,7 @@ } } -static int +Py_LOCAL(int) call_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3216,7 +3216,7 @@ return result; } -static int +Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int *instr_lb, int *instr_ub, int *instr_prev) @@ -3444,7 +3444,7 @@ } } -static void +Py_LOCAL(void) err_args(PyObject *func, int flags, int nargs) { if (flags & METH_NOARGS) @@ -3491,7 +3491,7 @@ x = call; \ } -static PyObject * +Py_LOCAL(PyObject *) call_function(PyObject ***pp_stack, int oparg #ifdef WITH_TSC , uint64* pintr0, uint64* pintr1 @@ -3582,7 +3582,7 @@ done before evaluating the frame. */ -static PyObject * +Py_LOCAL(PyObject *) fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); @@ -3635,7 +3635,7 @@ PyFunction_GET_CLOSURE(func)); } -static PyObject * +Py_LOCAL(PyObject *) update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack, PyObject *func) { @@ -3675,7 +3675,7 @@ return kwdict; } -static PyObject * +Py_LOCAL(PyObject *) update_star_args(int nstack, int nstar, PyObject *stararg, PyObject ***pp_stack) { @@ -3700,7 +3700,7 @@ return callargs; } -static PyObject * +Py_LOCAL(PyObject *) load_args(PyObject ***pp_stack, int na) { PyObject *args = PyTuple_New(na); @@ -3715,7 +3715,7 @@ return args; } -static PyObject * +Py_LOCAL(PyObject *) do_call(PyObject *func, PyObject ***pp_stack, int na, int nk) { PyObject *callargs = NULL; @@ -3751,7 +3751,7 @@ return result; } -static PyObject * +Py_LOCAL(PyObject *) ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk) { int nstar = 0; @@ -3863,7 +3863,7 @@ PyType_HasFeature((x)->ob_type, Py_TPFLAGS_HAVE_INDEX) \ && (x)->ob_type->tp_as_number->nb_index)) -static PyObject * +Py_LOCAL(PyObject *) apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */ { PyTypeObject *tp = u->ob_type; @@ -3889,7 +3889,7 @@ } } -static int +Py_LOCAL(int) assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x) /* u[v:w] = x */ { @@ -3923,7 +3923,7 @@ } } -static PyObject * +Py_LOCAL(PyObject *) cmp_outcome(int op, register PyObject *v, register PyObject *w) { int res = 0; @@ -3956,7 +3956,7 @@ return v; } -static PyObject * +Py_LOCAL(PyObject *) import_from(PyObject *v, PyObject *name) { PyObject *x; @@ -3970,7 +3970,7 @@ return x; } -static int +Py_LOCAL(int) import_all_from(PyObject *locals, PyObject *v) { PyObject *all = PyObject_GetAttrString(v, "__all__"); @@ -4027,7 +4027,7 @@ return err; } -static PyObject * +Py_LOCAL(PyObject *) build_class(PyObject *methods, PyObject *bases, PyObject *name) { PyObject *metaclass = NULL, *result, *base; @@ -4079,7 +4079,7 @@ return result; } -static int +Py_LOCAL(int) exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, PyObject *locals) { @@ -4175,7 +4175,7 @@ return 0; } -static void +Py_LOCAL(void) format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj) { char *obj_str; @@ -4190,7 +4190,7 @@ PyErr_Format(exc, format_str, obj_str); } -static PyObject * +Py_LOCAL(PyObject *) string_concatenate(PyObject *v, PyObject *w, PyFrameObject *f, unsigned char *next_instr) { @@ -4265,7 +4265,7 @@ #ifdef DYNAMIC_EXECUTION_PROFILE -static PyObject * +Py_LOCAL(PyObject *) getarray(long a[256]) { int i; From python-checkins at python.org Fri May 26 13:37:21 2006 From: python-checkins at python.org (jack.diederich) Date: Fri, 26 May 2006 13:37:21 +0200 (CEST) Subject: [Python-checkins] r46292 - python/trunk/Tools/unicode/gencodec.py Message-ID: <20060526113721.A0C031E400C@bag.python.org> Author: jack.diederich Date: Fri May 26 13:37:20 2006 New Revision: 46292 Modified: python/trunk/Tools/unicode/gencodec.py Log: when generating python code prefer to generate valid python code Modified: python/trunk/Tools/unicode/gencodec.py ============================================================================== --- python/trunk/Tools/unicode/gencodec.py (original) +++ python/trunk/Tools/unicode/gencodec.py Fri May 26 13:37:20 2006 @@ -318,15 +318,15 @@ ### encodings module API def getregentry(): - return codecs.CodecInfo(( - name=%r, + return codecs.CodecInfo( Codec().encode, Codec().decode, + name=%r, streamwriter=StreamWriter, streamreader=StreamReader, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, - )) + ) ''' % encodingname.replace('_', '-')) # Add decoding table or map (with preference to the table) From python-checkins at python.org Fri May 26 13:38:16 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 13:38:16 +0200 (CEST) Subject: [Python-checkins] r46293 - in python/trunk: Include/pyport.h Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060526113816.CB7241E400C@bag.python.org> Author: fredrik.lundh Date: Fri May 26 13:38:15 2006 New Revision: 46293 Modified: python/trunk/Include/pyport.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: use Py_LOCAL also for string and unicode objects Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Fri May 26 13:38:15 2006 @@ -139,12 +139,17 @@ /* PY_LOCAL can be used instead of static to get the fastest possible calling * convention for functions that are local to a given module. It also enables - * inlining, where suitable. */ + * inlining, where suitable. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ #undef USE_INLINE /* XXX - set via configure? */ #if defined(_MSC_VER) - /* ignore warnings if the compiler decides not to inline a function */ +/* ignore warnings if the compiler decides not to inline a function */ #pragma warning(disable: 4710) /* fastest possible local call under MSVC */ #define Py_LOCAL(type) static __inline type __fastcall Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 13:38:15 2006 @@ -5,18 +5,6 @@ #include -#undef USE_INLINE /* XXX - set via configure? */ - -#if defined(_MSC_VER) /* this is taken from _sre.c */ -#pragma warning(disable: 4710) -/* fastest possible local call under MSVC */ -#define LOCAL(type) static __inline type __fastcall -#elif defined(USE_INLINE) -#define LOCAL(type) static inline type -#else -#define LOCAL(type) static type -#endif - #ifdef COUNT_ALLOCS int null_strings, one_strings; #endif @@ -798,7 +786,7 @@ #define FAST_COUNT 0 #define FAST_SEARCH 1 -LOCAL(Py_ssize_t) +Py_LOCAL(Py_ssize_t) fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) { long mask; Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 13:38:15 2006 @@ -49,18 +49,6 @@ #include #endif -#undef USE_INLINE /* XXX - set via configure? */ - -#if defined(_MSC_VER) /* this is taken from _sre.c */ -#pragma warning(disable: 4710) -/* fastest possible local call under MSVC */ -#define LOCAL(type) static __inline type __fastcall -#elif defined(USE_INLINE) -#define LOCAL(type) static inline type -#else -#define LOCAL(type) static type -#endif - /* Limit for the Unicode object free list */ #define MAX_UNICODE_FREELIST_SIZE 1024 @@ -153,7 +141,7 @@ #define BLOOM_LINEBREAK(ch)\ (BLOOM(bloom_linebreak, (ch)) && Py_UNICODE_ISLINEBREAK((ch))) -LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) +Py_LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) { /* calculate simple bloom-style bitmask for a given unicode string */ @@ -167,7 +155,7 @@ return mask; } -LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) +Py_LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) { Py_ssize_t i; @@ -2027,9 +2015,9 @@ */ -LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch) +Py_LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, + Py_ssize_t size, + Py_UNICODE ch) { /* like wcschr, but doesn't stop at NULL characters */ @@ -3880,7 +3868,7 @@ #define FAST_COUNT 0 #define FAST_SEARCH 1 -LOCAL(Py_ssize_t) +Py_LOCAL(Py_ssize_t) fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) { long mask; @@ -3955,10 +3943,10 @@ return count; } -LOCAL(Py_ssize_t) count(PyUnicodeObject *self, - Py_ssize_t start, - Py_ssize_t end, - PyUnicodeObject *substring) +Py_LOCAL(Py_ssize_t) count(PyUnicodeObject *self, + Py_ssize_t start, + Py_ssize_t end, + PyUnicodeObject *substring) { Py_ssize_t count = 0; From python-checkins at python.org Fri May 26 13:38:39 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 13:38:39 +0200 (CEST) Subject: [Python-checkins] r46294 - python/trunk/setup.py Message-ID: <20060526113839.F285E1E400C@bag.python.org> Author: ronald.oussoren Date: Fri May 26 13:38:39 2006 New Revision: 46294 Modified: python/trunk/setup.py Log: - Search the sqlite specific search directories after the normal include directories when looking for the version of sqlite to use. - On OSX: * Extract additional include and link directories from the CFLAGS and LDFLAGS, if the user has bothered to specify them we might as wel use them. * Add '-Wl,-search_paths_first' to the extra_link_args for readline and sqlite. This makes it possible to use a static library to override the system provided dynamic library. Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Fri May 26 13:38:39 2006 @@ -317,6 +317,23 @@ if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] + if platform == 'darwin': + # This should work on any unixy platform ;-) + # If the user has bothered specifying additional -I and -L flags + # in OPT and LDFLAGS we might as well use them here. + # NOTE: using shlex.split would technically be more correct, but + # also gives a bootstrap problem. Let's hope nobody uses directories + # with whitespace in the name to store libraries. + cflags, ldflags = sysconfig.get_config_vars( + 'CFLAGS', 'LDFLAGS') + for item in cflags.split(): + if item.startswith('-I'): + inc_dirs.append(item[2:]) + + for item in ldflags.split(): + if item.startswith('-L'): + lib_dirs.append(item[2:]) + # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] if platform in ['darwin', 'beos', 'mac']: @@ -459,6 +476,16 @@ if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom readline gets picked up + # before the (broken) dynamic library in /usr/lib. + readline_extra_link_args = ('-Wl,-search_paths_first',) + else: + readline_extra_link_args = () + readline_libs = ['readline'] if self.compiler.find_library_file(lib_dirs, 'ncursesw'): @@ -474,6 +501,7 @@ readline_libs.append('termcap') exts.append( Extension('readline', ['readline.c'], library_dirs=['/usr/lib/termcap'], + extra_link_args=readline_extra_link_args, libraries=readline_libs) ) if platform not in ['mac']: # crypt module. @@ -708,7 +736,11 @@ MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) - for d in sqlite_inc_paths + inc_dirs: + + # Scan the default include directories before the SQLite specific + # ones. This allows one to override the copy of sqlite on OSX, + # where /usr/include contains an old version of sqlite. + for d in inc_dirs + sqlite_inc_paths: f = os.path.join(d, "sqlite3.h") if os.path.exists(f): if sqlite_setup_debug: print "sqlite: found %s"%f @@ -759,12 +791,24 @@ else: sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) + + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom sqlite gets picked up + # before the dynamic library in /usr/lib. + sqlite_extra_link_args = ('-Wl,-search_paths_first',) + else: + sqlite_extra_link_args = () + exts.append(Extension('_sqlite3', sqlite_srcs, define_macros=sqlite_defines, include_dirs=["Modules/_sqlite", sqlite_incdir], library_dirs=sqlite_libdir, runtime_library_dirs=sqlite_libdir, + extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) # Look for Berkeley db 1.85. Note that it is built as a different From python-checkins at python.org Fri May 26 13:43:27 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 13:43:27 +0200 (CEST) Subject: [Python-checkins] r46295 - python/trunk/Makefile.pre.in python/trunk/configure python/trunk/configure.in Message-ID: <20060526114327.797491E400C@bag.python.org> Author: ronald.oussoren Date: Fri May 26 13:43:26 2006 New Revision: 46295 Modified: python/trunk/Makefile.pre.in python/trunk/configure python/trunk/configure.in Log: Integrate installing a framework in the 'make install' target. Until now users had to use 'make frameworkinstall' to install python when it is configured with '--enable-framework'. This tends to confuse users that don't hunt for readme files hidden in platform specific directories :-) Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Fri May 26 13:43:26 2006 @@ -614,7 +614,7 @@ $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS) # Install everything -install: altinstall bininstall maninstall +install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@ # Install almost everything without disturbing previous versions altinstall: altbininstall libinstall inclinstall libainstall \ @@ -899,8 +899,10 @@ # subtargets install specific parts. Much of the actual work is offloaded to # the Makefile in Mac/OSX # -frameworkinstall: frameworkinstallframework \ - frameworkinstallapps frameworkinstallunixtools +# +# This target is here for backward compatiblity, previous versions of Python +# hadn't integrated framework installation in the normal install process. +frameworkinstall: install # On install, we re-make the framework # structure in the install location, /Library/Frameworks/ or the argument to Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Fri May 26 13:43:26 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 46010 . +# From configure.in Revision: 46046 . # 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 UNIVERSALSDK PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR SVNVERSION 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_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 UNIVERSALSDK PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR FRAMEWORKINSTALLFIRST FRAMEWORKINSTALLLAST MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR SVNVERSION 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. @@ -1443,6 +1443,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ;; *) @@ -1450,6 +1452,8 @@ PYTHONFRAMEWORKDIR=Python.framework PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR + FRAMEWORKINSTALLFIRST="frameworkinstallstructure" + FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION # Add makefiles for Mac specific code to the list of output @@ -1468,6 +1472,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= fi; @@ -1476,6 +1482,8 @@ + + ##AC_ARG_WITH(dyld, ## AC_HELP_STRING(--with-dyld, ## Use (OpenStep|Rhapsody) dynamic linker)) @@ -22541,6 +22549,8 @@ s, at PYTHONFRAMEWORKDIR@,$PYTHONFRAMEWORKDIR,;t t s, at PYTHONFRAMEWORKPREFIX@,$PYTHONFRAMEWORKPREFIX,;t t s, at PYTHONFRAMEWORKINSTALLDIR@,$PYTHONFRAMEWORKINSTALLDIR,;t t +s, at FRAMEWORKINSTALLFIRST@,$FRAMEWORKINSTALLFIRST,;t t +s, at FRAMEWORKINSTALLLAST@,$FRAMEWORKINSTALLLAST,;t t s, at MACHDEP@,$MACHDEP,;t t s, at SGI_ABI@,$SGI_ABI,;t t s, at EXTRAPLATDIR@,$EXTRAPLATDIR,;t t Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Fri May 26 13:43:26 2006 @@ -97,6 +97,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ;; *) @@ -104,6 +106,8 @@ PYTHONFRAMEWORKDIR=Python.framework PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR + FRAMEWORKINSTALLFIRST="frameworkinstallstructure" + FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION # Add makefiles for Mac specific code to the list of output @@ -117,12 +121,16 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ]) AC_SUBST(PYTHONFRAMEWORK) AC_SUBST(PYTHONFRAMEWORKDIR) AC_SUBST(PYTHONFRAMEWORKPREFIX) AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) +AC_SUBST(FRAMEWORKINSTALLFIRST) +AC_SUBST(FRAMEWORKINSTALLLAST) ##AC_ARG_WITH(dyld, ## AC_HELP_STRING(--with-dyld, From buildbot at python.org Fri May 26 13:47:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 11:47:27 +0000 Subject: [Python-checkins] buildbot failure in x86 W2k trunk Message-ID: <20060526114728.0E6631E400D@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/797 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl BUILD FAILED: failed compile sincerely, -The Buildbot From steve at holdenweb.com Fri May 26 13:48:10 2006 From: steve at holdenweb.com (Steve Holden) Date: Fri, 26 May 2006 12:48:10 +0100 Subject: [Python-checkins] [Fwd: Re: r46146 - sandbox/trunk/rjsh-pybench/pybench.py] Message-ID: <4476EAFA.1040600@holdenweb.com> Mats: Someone raised the question of whether QueryPerformanceCounter is available on various 64-bit platforms, and I promised I'd contact you to find out about Itanium. Any informnation you can offer on the whole topic of timing under 64-bit Windows would be helpful. regards Steve -------- Original Message -------- Subject: Re: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py Date: Thu, 25 May 2006 08:42:19 +0000 From: Tim Peters To: python-checkins at python.org [Tim] ... >> time.clock() has sub-microsecond resolution (better than a millionth >> of a second) on all flavors of Windows. [Martin v. L?wis] > Are you sure about that? It has a *scale* of sub-microseconds (100ns); > the resolution is unspecified. "Most" Windows boxes run on HW with a capable real-time counter. > clock() uses GetSystemTimeAsFileTime(). This likely reads some > kernel variable, and I very much doubt that this kernel variable > is updated every 100ns. For example, in ... Windoes clock() does, yes, but Python's time.clock() on Windows does not. See the source ;-) > ... > To get a finer time measurement, you should use QueryPerformanceCounter. > On x86 processors that support it, this uses rdtsc to fetch the > time-stamping counter: That's exactly what Python uses for time.clock() on Windows ... although I see it doesn't on Win64: #if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Win32 has better clock replacement XXX Win64 does not yet, but might when the platform matures. */ #undef HAVE_CLOCK /* We have our own version down below */ #endif /* MS_WINDOWS && !MS_WIN64 */ Do you know whether Win64 still has that limitation? _______________________________________________ Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From python-checkins at python.org Fri May 26 13:48:32 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 13:48:32 +0200 (CEST) Subject: [Python-checkins] r46296 - in python/branches/blais-bytebuf: Include/pyport.h Lib/UserString.py Lib/test/string_tests.py Mac/OSX/BuildScript/scripts/postflight.patch-profile Makefile.pre.in Modules/itertoolsmodule.c Objects/stringobject.c Objects/unicodeobject.c Python/ceval.c Tools/unicode/gencodec.py configure configure.in setup.py Message-ID: <20060526114832.A57751E400D@bag.python.org> Author: martin.blais Date: Fri May 26 13:48:16 2006 New Revision: 46296 Modified: python/branches/blais-bytebuf/Include/pyport.h python/branches/blais-bytebuf/Lib/UserString.py python/branches/blais-bytebuf/Lib/test/string_tests.py python/branches/blais-bytebuf/Mac/OSX/BuildScript/scripts/postflight.patch-profile python/branches/blais-bytebuf/Makefile.pre.in python/branches/blais-bytebuf/Modules/itertoolsmodule.c python/branches/blais-bytebuf/Objects/stringobject.c python/branches/blais-bytebuf/Objects/unicodeobject.c python/branches/blais-bytebuf/Python/ceval.c python/branches/blais-bytebuf/Tools/unicode/gencodec.py python/branches/blais-bytebuf/configure python/branches/blais-bytebuf/configure.in python/branches/blais-bytebuf/setup.py Log: Updated blais-bytebuf to 46295 Modified: python/branches/blais-bytebuf/Include/pyport.h ============================================================================== --- python/branches/blais-bytebuf/Include/pyport.h (original) +++ python/branches/blais-bytebuf/Include/pyport.h Fri May 26 13:48:16 2006 @@ -137,6 +137,28 @@ # endif #endif +/* PY_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. It also enables + * inlining, where suitable. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ + +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) +/* ignore warnings if the compiler decides not to inline a function */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define Py_LOCAL(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define Py_LOCAL(type) static inline type +#else +#define Py_LOCAL(type) static type +#endif + #include #include /* Moved here from the math section, before extern "C" */ Modified: python/branches/blais-bytebuf/Lib/UserString.py ============================================================================== --- python/branches/blais-bytebuf/Lib/UserString.py (original) +++ python/branches/blais-bytebuf/Lib/UserString.py Fri May 26 13:48:16 2006 @@ -102,6 +102,7 @@ return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) + def partition(self, sep): return self.data.partition(sep) def replace(self, old, new, maxsplit=-1): return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=sys.maxint): Modified: python/branches/blais-bytebuf/Lib/test/string_tests.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/string_tests.py (original) +++ python/branches/blais-bytebuf/Lib/test/string_tests.py Fri May 26 13:48:16 2006 @@ -246,6 +246,14 @@ self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) + self.checkequal([], ' ', 'split') + self.checkequal(['a'], ' a ', 'split') + self.checkequal(['a', 'b'], ' a b ', 'split') + self.checkequal(['a', 'b '], ' a b ', 'split', None, 1) + self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) + self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) + self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split') + # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1) Modified: python/branches/blais-bytebuf/Mac/OSX/BuildScript/scripts/postflight.patch-profile ============================================================================== --- python/branches/blais-bytebuf/Mac/OSX/BuildScript/scripts/postflight.patch-profile (original) +++ python/branches/blais-bytebuf/Mac/OSX/BuildScript/scripts/postflight.patch-profile Fri May 26 13:48:16 2006 @@ -41,7 +41,7 @@ echo "" >> "${HOME}/.cshrc" echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc" echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc" - echo "setenv path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" + echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" exit 0 ;; bash) Modified: python/branches/blais-bytebuf/Makefile.pre.in ============================================================================== --- python/branches/blais-bytebuf/Makefile.pre.in (original) +++ python/branches/blais-bytebuf/Makefile.pre.in Fri May 26 13:48:16 2006 @@ -614,7 +614,7 @@ $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS) # Install everything -install: altinstall bininstall maninstall +install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@ # Install almost everything without disturbing previous versions altinstall: altbininstall libinstall inclinstall libainstall \ @@ -899,8 +899,10 @@ # subtargets install specific parts. Much of the actual work is offloaded to # the Makefile in Mac/OSX # -frameworkinstall: frameworkinstallframework \ - frameworkinstallapps frameworkinstallunixtools +# +# This target is here for backward compatiblity, previous versions of Python +# hadn't integrated framework installation in the normal install process. +frameworkinstall: install # On install, we re-make the framework # structure in the install location, /Library/Frameworks/ or the argument to Modified: python/branches/blais-bytebuf/Modules/itertoolsmodule.c ============================================================================== --- python/branches/blais-bytebuf/Modules/itertoolsmodule.c (original) +++ python/branches/blais-bytebuf/Modules/itertoolsmodule.c Fri May 26 13:48:16 2006 @@ -1093,10 +1093,10 @@ typedef struct { PyObject_HEAD PyObject *it; - long next; - long stop; - long step; - long cnt; + Py_ssize_t next; + Py_ssize_t stop; + Py_ssize_t step; + Py_ssize_t cnt; } isliceobject; static PyTypeObject islice_type; @@ -1105,7 +1105,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *seq; - long start=0, stop=-1, step=1; + Py_ssize_t start=0, stop=-1, step=1; PyObject *it, *a1=NULL, *a2=NULL, *a3=NULL; Py_ssize_t numargs; isliceobject *lz; @@ -1119,7 +1119,7 @@ numargs = PyTuple_Size(args); if (numargs == 2) { if (a1 != Py_None) { - stop = PyInt_AsLong(a1); + stop = PyInt_AsSsize_t(a1); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1130,11 +1130,11 @@ } } else { if (a1 != Py_None) - start = PyInt_AsLong(a1); + start = PyInt_AsSsize_t(a1); if (start == -1 && PyErr_Occurred()) PyErr_Clear(); if (a2 != Py_None) { - stop = PyInt_AsLong(a2); + stop = PyInt_AsSsize_t(a2); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1152,7 +1152,7 @@ if (a3 != NULL) { if (a3 != Py_None) - step = PyInt_AsLong(a3); + step = PyInt_AsSsize_t(a3); if (step == -1 && PyErr_Occurred()) PyErr_Clear(); } @@ -1202,7 +1202,7 @@ { PyObject *item; PyObject *it = lz->it; - long oldnext; + Py_ssize_t oldnext; PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); @@ -1600,8 +1600,8 @@ typedef struct { PyObject_HEAD - Py_ssize_t tuplesize; - long iternum; /* which iterator is active */ + Py_ssize_t tuplesize; + Py_ssize_t iternum; /* which iterator is active */ PyObject *ittuple; /* tuple of iterators */ } chainobject; @@ -1612,7 +1612,7 @@ { chainobject *lz; Py_ssize_t tuplesize = PySequence_Length(args); - int i; + Py_ssize_t i; PyObject *ittuple; if (!_PyArg_NoKeywords("chain()", kwds)) @@ -2033,7 +2033,7 @@ typedef struct { PyObject_HEAD - long cnt; + Py_ssize_t cnt; } countobject; static PyTypeObject count_type; @@ -2042,12 +2042,12 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { countobject *lz; - long cnt = 0; + Py_ssize_t cnt = 0; if (!_PyArg_NoKeywords("count()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "|l:count", &cnt)) + if (!PyArg_ParseTuple(args, "|n:count", &cnt)) return NULL; /* create countobject structure */ @@ -2062,13 +2062,13 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromLong(lz->cnt++); + return PyInt_FromSize_t(lz->cnt++); } static PyObject * count_repr(countobject *lz) { - return PyString_FromFormat("count(%ld)", lz->cnt); + return PyString_FromFormat("count(%zd)", lz->cnt); } PyDoc_STRVAR(count_doc, @@ -2138,7 +2138,7 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { izipobject *lz; - int i; + Py_ssize_t i; PyObject *ittuple; /* tuple of iterators */ PyObject *result; Py_ssize_t tuplesize = PySequence_Length(args); @@ -2212,7 +2212,7 @@ static PyObject * izip_next(izipobject *lz) { - int i; + Py_ssize_t i; Py_ssize_t tuplesize = lz->tuplesize; PyObject *result = lz->result; PyObject *it; @@ -2314,7 +2314,7 @@ typedef struct { PyObject_HEAD PyObject *element; - long cnt; + Py_ssize_t cnt; } repeatobject; static PyTypeObject repeat_type; @@ -2324,12 +2324,12 @@ { repeatobject *ro; PyObject *element; - long cnt = -1; + Py_ssize_t cnt = -1; if (!_PyArg_NoKeywords("repeat()", kwds)) return NULL; - if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt)) + if (!PyArg_ParseTuple(args, "O|n:repeat", &element, &cnt)) return NULL; if (PyTuple_Size(args) == 2 && cnt < 0) @@ -2383,7 +2383,7 @@ result = PyString_FromFormat("repeat(%s)", PyString_AS_STRING(objrepr)); else - result = PyString_FromFormat("repeat(%s, %ld)", + result = PyString_FromFormat("repeat(%s, %zd)", PyString_AS_STRING(objrepr), ro->cnt); Py_DECREF(objrepr); return result; @@ -2396,7 +2396,7 @@ PyErr_SetString(PyExc_TypeError, "len() of unsized object"); return NULL; } - return PyInt_FromLong(ro->cnt); + return PyInt_FromSize_t(ro->cnt); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/blais-bytebuf/Objects/stringobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/stringobject.c (original) +++ python/branches/blais-bytebuf/Objects/stringobject.c Fri May 26 13:48:16 2006 @@ -5,18 +5,6 @@ #include -#undef USE_INLINE /* XXX - set via configure? */ - -#if defined(_MSC_VER) /* this is taken from _sre.c */ -#pragma warning(disable: 4710) -/* fastest possible local call under MSVC */ -#define LOCAL(type) static __inline type __fastcall -#elif defined(USE_INLINE) -#define LOCAL(type) static inline type -#else -#define LOCAL(type) static type -#endif - #ifdef COUNT_ALLOCS int null_strings, one_strings; #endif @@ -798,7 +786,7 @@ #define FAST_COUNT 0 #define FAST_SEARCH 1 -LOCAL(Py_ssize_t) +Py_LOCAL(Py_ssize_t) fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) { long mask; Modified: python/branches/blais-bytebuf/Objects/unicodeobject.c ============================================================================== --- python/branches/blais-bytebuf/Objects/unicodeobject.c (original) +++ python/branches/blais-bytebuf/Objects/unicodeobject.c Fri May 26 13:48:16 2006 @@ -49,18 +49,6 @@ #include #endif -#undef USE_INLINE /* XXX - set via configure? */ - -#if defined(_MSC_VER) /* this is taken from _sre.c */ -#pragma warning(disable: 4710) -/* fastest possible local call under MSVC */ -#define LOCAL(type) static __inline type __fastcall -#elif defined(USE_INLINE) -#define LOCAL(type) static inline type -#else -#define LOCAL(type) static type -#endif - /* Limit for the Unicode object free list */ #define MAX_UNICODE_FREELIST_SIZE 1024 @@ -153,7 +141,7 @@ #define BLOOM_LINEBREAK(ch)\ (BLOOM(bloom_linebreak, (ch)) && Py_UNICODE_ISLINEBREAK((ch))) -LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) +Py_LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) { /* calculate simple bloom-style bitmask for a given unicode string */ @@ -167,7 +155,7 @@ return mask; } -LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) +Py_LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) { Py_ssize_t i; @@ -2027,9 +2015,9 @@ */ -LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, - Py_ssize_t size, - Py_UNICODE ch) +Py_LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, + Py_ssize_t size, + Py_UNICODE ch) { /* like wcschr, but doesn't stop at NULL characters */ @@ -3880,7 +3868,7 @@ #define FAST_COUNT 0 #define FAST_SEARCH 1 -LOCAL(Py_ssize_t) +Py_LOCAL(Py_ssize_t) fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) { long mask; @@ -3955,10 +3943,10 @@ return count; } -LOCAL(Py_ssize_t) count(PyUnicodeObject *self, - Py_ssize_t start, - Py_ssize_t end, - PyUnicodeObject *substring) +Py_LOCAL(Py_ssize_t) count(PyUnicodeObject *self, + Py_ssize_t start, + Py_ssize_t end, + PyUnicodeObject *substring) { Py_ssize_t count = 0; Modified: python/branches/blais-bytebuf/Python/ceval.c ============================================================================== --- python/branches/blais-bytebuf/Python/ceval.c (original) +++ python/branches/blais-bytebuf/Python/ceval.c Fri May 26 13:48:16 2006 @@ -30,7 +30,7 @@ #define READ_TIMESTAMP(var) ppc_getcounter(&var) -static void +Py_LOCAL(void) ppc_getcounter(uint64 *v) { register unsigned long tbu, tb, tbu2; @@ -83,44 +83,44 @@ /* Forward declarations */ #ifdef WITH_TSC -static PyObject *call_function(PyObject ***, int, uint64*, uint64*); +Py_LOCAL(PyObject *)call_function(PyObject ***, int, uint64*, uint64*); #else -static PyObject *call_function(PyObject ***, int); +Py_LOCAL(PyObject *)call_function(PyObject ***, int); #endif -static PyObject *fast_function(PyObject *, PyObject ***, int, int, int); -static PyObject *do_call(PyObject *, PyObject ***, int, int); -static PyObject *ext_do_call(PyObject *, PyObject ***, int, int, int); -static PyObject *update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -static PyObject *update_star_args(int, int, PyObject *, PyObject ***); -static PyObject *load_args(PyObject ***, int); +Py_LOCAL(PyObject *)fast_function(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *)do_call(PyObject *, PyObject ***, int, int); +Py_LOCAL(PyObject *)ext_do_call(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *)update_keyword_args(PyObject *, int, PyObject ***,PyObject *); +Py_LOCAL(PyObject *)update_star_args(int, int, PyObject *, PyObject ***); +Py_LOCAL(PyObject *)load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 #ifdef LLTRACE -static int lltrace; -static int prtrace(PyObject *, char *); +Py_LOCAL(int) lltrace; +Py_LOCAL(int) prtrace(PyObject *, char *); #endif -static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, +Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -static void call_trace_protected(Py_tracefunc, PyObject *, +Py_LOCAL(void) call_trace_protected(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); -static int maybe_call_line_trace(Py_tracefunc, PyObject *, +Py_LOCAL(void) call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); +Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *, PyFrameObject *, int *, int *, int *); -static PyObject *apply_slice(PyObject *, PyObject *, PyObject *); -static int assign_slice(PyObject *, PyObject *, +Py_LOCAL(PyObject *)apply_slice(PyObject *, PyObject *, PyObject *); +Py_LOCAL(int) assign_slice(PyObject *, PyObject *, PyObject *, PyObject *); -static PyObject *cmp_outcome(int, PyObject *, PyObject *); -static PyObject *import_from(PyObject *, PyObject *); -static int import_all_from(PyObject *, PyObject *); -static PyObject *build_class(PyObject *, PyObject *, PyObject *); -static int exec_statement(PyFrameObject *, +Py_LOCAL(PyObject *)cmp_outcome(int, PyObject *, PyObject *); +Py_LOCAL(PyObject *)import_from(PyObject *, PyObject *); +Py_LOCAL(int) import_all_from(PyObject *, PyObject *); +Py_LOCAL(PyObject *)build_class(PyObject *, PyObject *, PyObject *); +Py_LOCAL(int) exec_statement(PyFrameObject *, PyObject *, PyObject *, PyObject *); -static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); -static void reset_exc_info(PyThreadState *); -static void format_exc_check_arg(PyObject *, char *, PyObject *); -static PyObject *string_concatenate(PyObject *, PyObject *, +Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); +Py_LOCAL(void) reset_exc_info(PyThreadState *); +Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *); +Py_LOCAL(PyObject *)string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ @@ -477,7 +477,7 @@ }; static enum why_code do_raise(PyObject *, PyObject *, PyObject *); -static int unpack_iterable(PyObject *, int, PyObject **); +Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **); /* for manipulating the thread switch and periodic "stuff" - used to be per thread, now just a pair o' globals */ @@ -2888,7 +2888,7 @@ */ -static void +Py_LOCAL(void) set_exc_info(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { @@ -2933,7 +2933,7 @@ PySys_SetObject("exc_traceback", tb); } -static void +Py_LOCAL(void) reset_exc_info(PyThreadState *tstate) { PyFrameObject *frame; @@ -3080,7 +3080,7 @@ /* Iterate v argcnt times and store the results on the stack (via decreasing sp). Return 1 for success, 0 if error. */ -static int +Py_LOCAL(int) unpack_iterable(PyObject *v, int argcnt, PyObject **sp) { int i = 0; @@ -3127,7 +3127,7 @@ #ifdef LLTRACE -static int +Py_LOCAL(int) prtrace(PyObject *v, char *str) { printf("%s ", str); @@ -3138,7 +3138,7 @@ } #endif -static void +Py_LOCAL(void) call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) { PyObject *type, *value, *traceback, *arg; @@ -3164,7 +3164,7 @@ } } -static void +Py_LOCAL(void) call_trace_protected(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3181,7 +3181,7 @@ } } -static int +Py_LOCAL(int) call_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3216,7 +3216,7 @@ return result; } -static int +Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int *instr_lb, int *instr_ub, int *instr_prev) @@ -3444,7 +3444,7 @@ } } -static void +Py_LOCAL(void) err_args(PyObject *func, int flags, int nargs) { if (flags & METH_NOARGS) @@ -3491,7 +3491,7 @@ x = call; \ } -static PyObject * +Py_LOCAL(PyObject *) call_function(PyObject ***pp_stack, int oparg #ifdef WITH_TSC , uint64* pintr0, uint64* pintr1 @@ -3582,7 +3582,7 @@ done before evaluating the frame. */ -static PyObject * +Py_LOCAL(PyObject *) fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); @@ -3635,7 +3635,7 @@ PyFunction_GET_CLOSURE(func)); } -static PyObject * +Py_LOCAL(PyObject *) update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack, PyObject *func) { @@ -3675,7 +3675,7 @@ return kwdict; } -static PyObject * +Py_LOCAL(PyObject *) update_star_args(int nstack, int nstar, PyObject *stararg, PyObject ***pp_stack) { @@ -3700,7 +3700,7 @@ return callargs; } -static PyObject * +Py_LOCAL(PyObject *) load_args(PyObject ***pp_stack, int na) { PyObject *args = PyTuple_New(na); @@ -3715,7 +3715,7 @@ return args; } -static PyObject * +Py_LOCAL(PyObject *) do_call(PyObject *func, PyObject ***pp_stack, int na, int nk) { PyObject *callargs = NULL; @@ -3751,7 +3751,7 @@ return result; } -static PyObject * +Py_LOCAL(PyObject *) ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk) { int nstar = 0; @@ -3863,7 +3863,7 @@ PyType_HasFeature((x)->ob_type, Py_TPFLAGS_HAVE_INDEX) \ && (x)->ob_type->tp_as_number->nb_index)) -static PyObject * +Py_LOCAL(PyObject *) apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */ { PyTypeObject *tp = u->ob_type; @@ -3889,7 +3889,7 @@ } } -static int +Py_LOCAL(int) assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x) /* u[v:w] = x */ { @@ -3923,7 +3923,7 @@ } } -static PyObject * +Py_LOCAL(PyObject *) cmp_outcome(int op, register PyObject *v, register PyObject *w) { int res = 0; @@ -3956,7 +3956,7 @@ return v; } -static PyObject * +Py_LOCAL(PyObject *) import_from(PyObject *v, PyObject *name) { PyObject *x; @@ -3970,7 +3970,7 @@ return x; } -static int +Py_LOCAL(int) import_all_from(PyObject *locals, PyObject *v) { PyObject *all = PyObject_GetAttrString(v, "__all__"); @@ -4027,7 +4027,7 @@ return err; } -static PyObject * +Py_LOCAL(PyObject *) build_class(PyObject *methods, PyObject *bases, PyObject *name) { PyObject *metaclass = NULL, *result, *base; @@ -4079,7 +4079,7 @@ return result; } -static int +Py_LOCAL(int) exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, PyObject *locals) { @@ -4175,7 +4175,7 @@ return 0; } -static void +Py_LOCAL(void) format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj) { char *obj_str; @@ -4190,7 +4190,7 @@ PyErr_Format(exc, format_str, obj_str); } -static PyObject * +Py_LOCAL(PyObject *) string_concatenate(PyObject *v, PyObject *w, PyFrameObject *f, unsigned char *next_instr) { @@ -4265,7 +4265,7 @@ #ifdef DYNAMIC_EXECUTION_PROFILE -static PyObject * +Py_LOCAL(PyObject *) getarray(long a[256]) { int i; Modified: python/branches/blais-bytebuf/Tools/unicode/gencodec.py ============================================================================== --- python/branches/blais-bytebuf/Tools/unicode/gencodec.py (original) +++ python/branches/blais-bytebuf/Tools/unicode/gencodec.py Fri May 26 13:48:16 2006 @@ -318,15 +318,15 @@ ### encodings module API def getregentry(): - return codecs.CodecInfo(( - name=%r, + return codecs.CodecInfo( Codec().encode, Codec().decode, + name=%r, streamwriter=StreamWriter, streamreader=StreamReader, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, - )) + ) ''' % encodingname.replace('_', '-')) # Add decoding table or map (with preference to the table) Modified: python/branches/blais-bytebuf/configure ============================================================================== --- python/branches/blais-bytebuf/configure (original) +++ python/branches/blais-bytebuf/configure Fri May 26 13:48:16 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 46010 . +# From configure.in Revision: 46046 . # 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 UNIVERSALSDK PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR SVNVERSION 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_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 UNIVERSALSDK PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR FRAMEWORKINSTALLFIRST FRAMEWORKINSTALLLAST MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR SVNVERSION 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. @@ -1443,6 +1443,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ;; *) @@ -1450,6 +1452,8 @@ PYTHONFRAMEWORKDIR=Python.framework PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR + FRAMEWORKINSTALLFIRST="frameworkinstallstructure" + FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION # Add makefiles for Mac specific code to the list of output @@ -1468,6 +1472,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= fi; @@ -1476,6 +1482,8 @@ + + ##AC_ARG_WITH(dyld, ## AC_HELP_STRING(--with-dyld, ## Use (OpenStep|Rhapsody) dynamic linker)) @@ -22541,6 +22549,8 @@ s, at PYTHONFRAMEWORKDIR@,$PYTHONFRAMEWORKDIR,;t t s, at PYTHONFRAMEWORKPREFIX@,$PYTHONFRAMEWORKPREFIX,;t t s, at PYTHONFRAMEWORKINSTALLDIR@,$PYTHONFRAMEWORKINSTALLDIR,;t t +s, at FRAMEWORKINSTALLFIRST@,$FRAMEWORKINSTALLFIRST,;t t +s, at FRAMEWORKINSTALLLAST@,$FRAMEWORKINSTALLLAST,;t t s, at MACHDEP@,$MACHDEP,;t t s, at SGI_ABI@,$SGI_ABI,;t t s, at EXTRAPLATDIR@,$EXTRAPLATDIR,;t t Modified: python/branches/blais-bytebuf/configure.in ============================================================================== --- python/branches/blais-bytebuf/configure.in (original) +++ python/branches/blais-bytebuf/configure.in Fri May 26 13:48:16 2006 @@ -97,6 +97,8 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ;; *) @@ -104,6 +106,8 @@ PYTHONFRAMEWORKDIR=Python.framework PYTHONFRAMEWORKPREFIX=$enableval PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR + FRAMEWORKINSTALLFIRST="frameworkinstallstructure" + FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION # Add makefiles for Mac specific code to the list of output @@ -117,12 +121,16 @@ PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= enable_framework= ]) AC_SUBST(PYTHONFRAMEWORK) AC_SUBST(PYTHONFRAMEWORKDIR) AC_SUBST(PYTHONFRAMEWORKPREFIX) AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) +AC_SUBST(FRAMEWORKINSTALLFIRST) +AC_SUBST(FRAMEWORKINSTALLLAST) ##AC_ARG_WITH(dyld, ## AC_HELP_STRING(--with-dyld, Modified: python/branches/blais-bytebuf/setup.py ============================================================================== --- python/branches/blais-bytebuf/setup.py (original) +++ python/branches/blais-bytebuf/setup.py Fri May 26 13:48:16 2006 @@ -317,6 +317,23 @@ if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] + if platform == 'darwin': + # This should work on any unixy platform ;-) + # If the user has bothered specifying additional -I and -L flags + # in OPT and LDFLAGS we might as well use them here. + # NOTE: using shlex.split would technically be more correct, but + # also gives a bootstrap problem. Let's hope nobody uses directories + # with whitespace in the name to store libraries. + cflags, ldflags = sysconfig.get_config_vars( + 'CFLAGS', 'LDFLAGS') + for item in cflags.split(): + if item.startswith('-I'): + inc_dirs.append(item[2:]) + + for item in ldflags.split(): + if item.startswith('-L'): + lib_dirs.append(item[2:]) + # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] if platform in ['darwin', 'beos', 'mac']: @@ -463,6 +480,16 @@ if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom readline gets picked up + # before the (broken) dynamic library in /usr/lib. + readline_extra_link_args = ('-Wl,-search_paths_first',) + else: + readline_extra_link_args = () + readline_libs = ['readline'] if self.compiler.find_library_file(lib_dirs, 'ncursesw'): @@ -478,6 +505,7 @@ readline_libs.append('termcap') exts.append( Extension('readline', ['readline.c'], library_dirs=['/usr/lib/termcap'], + extra_link_args=readline_extra_link_args, libraries=readline_libs) ) if platform not in ['mac']: # crypt module. @@ -712,7 +740,11 @@ MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) - for d in sqlite_inc_paths + inc_dirs: + + # Scan the default include directories before the SQLite specific + # ones. This allows one to override the copy of sqlite on OSX, + # where /usr/include contains an old version of sqlite. + for d in inc_dirs + sqlite_inc_paths: f = os.path.join(d, "sqlite3.h") if os.path.exists(f): if sqlite_setup_debug: print "sqlite: found %s"%f @@ -763,12 +795,24 @@ else: sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) + + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom sqlite gets picked up + # before the dynamic library in /usr/lib. + sqlite_extra_link_args = ('-Wl,-search_paths_first',) + else: + sqlite_extra_link_args = () + exts.append(Extension('_sqlite3', sqlite_srcs, define_macros=sqlite_defines, include_dirs=["Modules/_sqlite", sqlite_incdir], library_dirs=sqlite_libdir, runtime_library_dirs=sqlite_libdir, + extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) # Look for Berkeley db 1.85. Note that it is built as a different From python-checkins at python.org Fri May 26 13:54:10 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 13:54:10 +0200 (CEST) Subject: [Python-checkins] r46297 - in python/trunk: Include/pyport.h Python/ceval.c Message-ID: <20060526115410.4378E1E4010@bag.python.org> Author: fredrik.lundh Date: Fri May 26 13:54:04 2006 New Revision: 46297 Modified: python/trunk/Include/pyport.h python/trunk/Python/ceval.c Log: needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive" LOCAL inlining; also added some missing whitespace Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Fri May 26 13:54:04 2006 @@ -141,6 +141,10 @@ * convention for functions that are local to a given module. It also enables * inlining, where suitable. * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, a more + * "aggressive" inlining is enabled. This may lead to code bloat, and may + * slow things down for those reasons. Use with care. + * * NOTE: You can only use this for functions that are entirely local to a * module; functions that are exported via method tables, callbacks, etc, * should keep using static. @@ -149,6 +153,10 @@ #undef USE_INLINE /* XXX - set via configure? */ #if defined(_MSC_VER) +#if defined(PY_LOCAL_AGGRESSIVE) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif /* ignore warnings if the compiler decides not to inline a function */ #pragma warning(disable: 4710) /* fastest possible local call under MSVC */ Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Fri May 26 13:54:04 2006 @@ -6,6 +6,9 @@ XXX document it! */ +/* enable more aggressive local inlining (platform dependent) */ +#define PY_LOCAL_AGGRESSIVE + #include "Python.h" #include "code.h" @@ -16,6 +19,11 @@ #include +#if defined(_MSC_VER) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif + #ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -83,16 +91,16 @@ /* Forward declarations */ #ifdef WITH_TSC -Py_LOCAL(PyObject *)call_function(PyObject ***, int, uint64*, uint64*); +Py_LOCAL(PyObject *) call_function(PyObject ***, int, uint64*, uint64*); #else -Py_LOCAL(PyObject *)call_function(PyObject ***, int); +Py_LOCAL(PyObject *) call_function(PyObject ***, int); #endif -Py_LOCAL(PyObject *)fast_function(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *)do_call(PyObject *, PyObject ***, int, int); -Py_LOCAL(PyObject *)ext_do_call(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *)update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -Py_LOCAL(PyObject *)update_star_args(int, int, PyObject *, PyObject ***); -Py_LOCAL(PyObject *)load_args(PyObject ***, int); +Py_LOCAL(PyObject *) fast_function(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *) do_call(PyObject *, PyObject ***, int, int); +Py_LOCAL(PyObject *) ext_do_call(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *) update_keyword_args(PyObject *, int, PyObject ***,PyObject *); +Py_LOCAL(PyObject *) update_star_args(int, int, PyObject *, PyObject ***); +Py_LOCAL(PyObject *) load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 @@ -108,19 +116,19 @@ Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *, PyFrameObject *, int *, int *, int *); -Py_LOCAL(PyObject *)apply_slice(PyObject *, PyObject *, PyObject *); +Py_LOCAL(PyObject *) apply_slice(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) assign_slice(PyObject *, PyObject *, PyObject *, PyObject *); -Py_LOCAL(PyObject *)cmp_outcome(int, PyObject *, PyObject *); -Py_LOCAL(PyObject *)import_from(PyObject *, PyObject *); +Py_LOCAL(PyObject *) cmp_outcome(int, PyObject *, PyObject *); +Py_LOCAL(PyObject *) import_from(PyObject *, PyObject *); Py_LOCAL(int) import_all_from(PyObject *, PyObject *); -Py_LOCAL(PyObject *)build_class(PyObject *, PyObject *, PyObject *); +Py_LOCAL(PyObject *) build_class(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) exec_statement(PyFrameObject *, PyObject *, PyObject *, PyObject *); Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); Py_LOCAL(void) reset_exc_info(PyThreadState *); Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *); -Py_LOCAL(PyObject *)string_concatenate(PyObject *, PyObject *, +Py_LOCAL(PyObject *) string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ @@ -476,7 +484,7 @@ WHY_YIELD = 0x0040 /* 'yield' operator */ }; -static enum why_code do_raise(PyObject *, PyObject *, PyObject *); +Py_LOCAL(enum why_code) do_raise(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **); /* for manipulating the thread switch and periodic "stuff" - used to be @@ -2971,7 +2979,7 @@ /* Logic for the raise statement (too complicated for inlining). This *consumes* a reference count to each of its arguments. */ -static enum why_code +Py_LOCAL(enum why_code) do_raise(PyObject *type, PyObject *value, PyObject *tb) { if (type == NULL) { From buildbot at python.org Fri May 26 13:58:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 11:58:14 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20060526115814.D28FC1E400C@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/795 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl,jack.diederich,ronald.oussoren BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Fri May 26 14:01:44 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 14:01:44 +0200 (CEST) Subject: [Python-checkins] r46298 - python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060526120144.BFDF81E4019@bag.python.org> Author: andrew.kuchling Date: Fri May 26 14:01:44 2006 New Revision: 46298 Modified: python/trunk/Doc/lib/libstdtypes.tex Log: Typo fixes Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Fri May 26 14:01:44 2006 @@ -728,7 +728,7 @@ \end{methoddesc} \begin{methoddesc}[string]{partition}{sep} -Splits the string at the first occurence of \var{sep}, and return +Split the string at the first occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by From python-checkins at python.org Fri May 26 14:01:49 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 14:01:49 +0200 (CEST) Subject: [Python-checkins] r46299 - python/trunk/Python/ceval.c Message-ID: <20060526120149.01A241E4019@bag.python.org> Author: fredrik.lundh Date: Fri May 26 14:01:49 2006 New Revision: 46299 Modified: python/trunk/Python/ceval.c Log: Py_LOCAL shouldn't be used for data; it works for some .NET 2003 compilers, but Trent's copy thinks that it's an anachronism... Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Fri May 26 14:01:49 2006 @@ -105,7 +105,7 @@ #define CALL_FLAG_KW 2 #ifdef LLTRACE -Py_LOCAL(int) lltrace; +static int lltrace; Py_LOCAL(int) prtrace(PyObject *, char *); #endif Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *, From python-checkins at python.org Fri May 26 14:03:29 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 14:03:29 +0200 (CEST) Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c Message-ID: <20060526120329.9A9671E400C@bag.python.org> Author: martin.blais Date: Fri May 26 14:03:27 2006 New Revision: 46300 Modified: python/trunk/Lib/socket.py python/trunk/Lib/test/test_socket.py python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c python/trunk/Modules/arraymodule.c python/trunk/Modules/socketmodule.c Log: Support for buffer protocol for socket and struct. * Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer protocol (send and sendto already did). * Added struct.pack_to(), that is the corresponding buffer compatible method to unpack_from(). * Fixed minor typos in arraymodule. Modified: python/trunk/Lib/socket.py ============================================================================== --- python/trunk/Lib/socket.py (original) +++ python/trunk/Lib/socket.py Fri May 26 14:03:27 2006 @@ -140,7 +140,9 @@ __doc__ = _realsocket.__doc__ - __slots__ = ["_sock", "send", "recv", "sendto", "recvfrom", + __slots__ = ["_sock", + "recv", "recv_buf", "recvfrom_buf", + "send", "sendto", "recvfrom", "__weakref__"] def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): @@ -149,8 +151,10 @@ self._sock = _sock self.send = self._sock.send self.recv = self._sock.recv + self.recv_buf = self._sock.recv_buf self.sendto = self._sock.sendto self.recvfrom = self._sock.recvfrom + self.recvfrom_buf = self._sock.recvfrom_buf def close(self): self._sock = _closedsocket() Modified: python/trunk/Lib/test/test_socket.py ============================================================================== --- python/trunk/Lib/test/test_socket.py (original) +++ python/trunk/Lib/test/test_socket.py Fri May 26 14:03:27 2006 @@ -9,6 +9,7 @@ import thread, threading import Queue import sys +import array from weakref import proxy PORT = 50007 @@ -852,8 +853,38 @@ self.assertRaises(socket.error, s.bind, address) +class BufferIOTest(SocketConnectedTest): + """ + Test the buffer versions of socket.recv() and socket.send(). + """ + def __init__(self, methodName='runTest'): + SocketConnectedTest.__init__(self, methodName=methodName) + + def testRecvBuf(self): + buf = array.array('c', ' '*1024) + nbytes = self.cli_conn.recv_buf(buf) + self.assertEqual(nbytes, len(MSG)) + msg = buf.tostring()[:len(MSG)] + self.assertEqual(msg, MSG) + + def _testRecvBuf(self): + buf = buffer(MSG) + self.serv_conn.send(buf) + + def testRecvFromBuf(self): + buf = array.array('c', ' '*1024) + nbytes, addr = self.cli_conn.recvfrom_buf(buf) + self.assertEqual(nbytes, len(MSG)) + msg = buf.tostring()[:len(MSG)] + self.assertEqual(msg, MSG) + + def _testRecvFromBuf(self): + buf = buffer(MSG) + self.serv_conn.send(buf) + def test_main(): - tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions] + tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions, + BufferIOTest] if sys.platform != 'mac': tests.extend([ BasicUDPTest, UDPTimeoutTest ]) Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Fri May 26 14:03:27 2006 @@ -1,5 +1,8 @@ from test.test_support import TestFailed, verbose, verify +import test.test_support import struct +import array +import unittest import sys ISBIGENDIAN = sys.byteorder == "big" @@ -438,31 +441,6 @@ test_705836() -def test_unpack_from(): - test_string = 'abcd01234' - fmt = '4s' - s = struct.Struct(fmt) - for cls in (str, buffer): - data = cls(test_string) - assert s.unpack_from(data) == ('abcd',) - assert s.unpack_from(data, 2) == ('cd01',) - assert s.unpack_from(data, 4) == ('0123',) - for i in xrange(6): - assert s.unpack_from(data, i) == (data[i:i+4],) - for i in xrange(6, len(test_string) + 1): - simple_err(s.unpack_from, data, i) - for cls in (str, buffer): - data = cls(test_string) - assert struct.unpack_from(fmt, data) == ('abcd',) - assert struct.unpack_from(fmt, data, 2) == ('cd01',) - assert struct.unpack_from(fmt, data, 4) == ('0123',) - for i in xrange(6): - assert struct.unpack_from(fmt, data, i) == (data[i:i+4],) - for i in xrange(6, len(test_string) + 1): - simple_err(struct.unpack_from, fmt, data, i) - -test_unpack_from() - def test_1229380(): for endian in ('', '>', '<'): for cls in (int, long): @@ -478,3 +456,60 @@ if 0: # TODO: bug #1229380 test_1229380() + +class PackBufferTestCase(unittest.TestCase): + """ + Test the packing methods that work on buffers. + """ + + def test_unpack_from( self ): + test_string = 'abcd01234' + fmt = '4s' + s = struct.Struct(fmt) + for cls in (str, buffer): + data = cls(test_string) + self.assertEquals(s.unpack_from(data), ('abcd',)) + self.assertEquals(s.unpack_from(data, 2), ('cd01',)) + self.assertEquals(s.unpack_from(data, 4), ('0123',)) + for i in xrange(6): + self.assertEquals(s.unpack_from(data, i), (data[i:i+4],)) + for i in xrange(6, len(test_string) + 1): + simple_err(s.unpack_from, data, i) + for cls in (str, buffer): + data = cls(test_string) + self.assertEquals(struct.unpack_from(fmt, data), ('abcd',)) + self.assertEquals(struct.unpack_from(fmt, data, 2), ('cd01',)) + self.assertEquals(struct.unpack_from(fmt, data, 4), ('0123',)) + for i in xrange(6): + self.assertEquals(struct.unpack_from(fmt, data, i), + (data[i:i+4],)) + for i in xrange(6, len(test_string) + 1): + simple_err(struct.unpack_from, fmt, data, i) + + def test_pack_to( self ): + test_string = 'Reykjavik rocks, eow!' + writable_buf = array.array('c', ' '*100) + fmt = '21s' + s = struct.Struct(fmt) + + # Test without offset + s.pack_to(writable_buf, 0, test_string) + from_buf = writable_buf.tostring()[:len(test_string)] + self.assertEquals(from_buf, test_string) + + # Test with offset. + s.pack_to(writable_buf, 10, test_string) + from_buf = writable_buf.tostring()[:len(test_string)+10] + self.assertEquals(from_buf, (test_string[:10] + test_string)) + + # Go beyond boundaries. + small_buf = array.array('c', ' '*10) + self.assertRaises(struct.error, s.pack_to, small_buf, 0, test_string) + self.assertRaises(struct.error, s.pack_to, small_buf, 2, test_string) + +def test_main(): + test.test_support.run_unittest(PackBufferTestCase) + +if __name__ == "__main__": + test_main() + Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 14:03:27 2006 @@ -15,6 +15,7 @@ typedef int Py_ssize_t; #endif + /* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the struct API to return int instead of long when possible. This is often a significant performance improvement. */ @@ -24,7 +25,6 @@ /* The translation function for each format character is table driven */ - typedef struct _formatdef { char format; int size; @@ -1315,50 +1315,36 @@ return s_unpack_internal(soself, buffer + offset); } -PyDoc_STRVAR(s_pack__doc__, -"pack(v1, v2, ...) -> string\n\ -\n\ -Return a string containing values v1, v2, ... packed according to this\n\ -Struct's format. See struct.__doc__ for more on format strings."); -static PyObject * -s_pack(PyObject *self, PyObject *args) +/* + * Guts of the pack function. + * + * Takes a struct object, a tuple of arguments, and offset in that tuple of + * argument for where to start processing the arguments for packing, and a + * character buffer for writing the packed string. The caller must insure + * that the buffer may contain the required length for packing the arguments. + * 0 is returned on success, 1 is returned if there is an error. + * + */ +static int +s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf) { - PyStructObject *soself; - PyObject *result; - char *restart; formatcode *code; Py_ssize_t i; - - soself = (PyStructObject *)self; - assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); - if (args == NULL || !PyTuple_Check(args) || - PyTuple_GET_SIZE(args) != soself->s_len) - { - PyErr_Format(StructError, - "pack requires exactly %d arguments", soself->s_len); - return NULL; - } - - result = PyString_FromStringAndSize((char *)NULL, soself->s_size); - if (result == NULL) - return NULL; - - restart = PyString_AS_STRING(result); - memset(restart, '\0', soself->s_size); - i = 0; + + memset(buf, '\0', soself->s_size); + i = offset; for (code = soself->s_codes; code->fmtdef != NULL; code++) { Py_ssize_t n; PyObject *v; const formatdef *e = code->fmtdef; - char *res = restart + code->offset; + char *res = buf + code->offset; if (e->format == 's') { v = PyTuple_GET_ITEM(args, i++); if (!PyString_Check(v)) { PyErr_SetString(StructError, "argument for 's' must be a string"); - goto fail; + return -1; } n = PyString_GET_SIZE(v); if (n > code->size) @@ -1370,7 +1356,7 @@ if (!PyString_Check(v)) { PyErr_SetString(StructError, "argument for 'p' must be a string"); - goto fail; + return -1; } n = PyString_GET_SIZE(v); if (n > (code->size - 1)) @@ -1383,16 +1369,109 @@ } else { v = PyTuple_GET_ITEM(args, i++); if (e->pack(res, v, e) < 0) - goto fail; + return -1; } } + /* Success */ + return 0; +} + + +PyDoc_STRVAR(s_pack__doc__, +"pack(v1, v2, ...) -> string\n\ +\n\ +Return a string containing values v1, v2, ... packed according to this\n\ +Struct's format. See struct.__doc__ for more on format strings."); + +static PyObject * +s_pack(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + PyObject *result; + + /* Validate arguments. */ + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != soself->s_len) + { + PyErr_Format(StructError, + "pack requires exactly %d arguments", soself->s_len); + return NULL; + } + + /* Allocate a new string */ + result = PyString_FromStringAndSize((char *)NULL, soself->s_size); + if (result == NULL) + return NULL; + + /* Call the guts */ + if ( s_pack_internal(soself, args, 0, PyString_AS_STRING(result)) != 0 ) { + Py_DECREF(result); + return NULL; + } + return result; +} -fail: - Py_DECREF(result); - return NULL; +PyDoc_STRVAR(s_pack_to__doc__, +"pack_to(buffer, offset, v1, v2, ...)\n\ +\n\ +Pack the values v2, v2, ... according to this Struct's format, write \n\ +the packed bytes into the given buffer at the given offset. Note that \n\ +the offset is not an optional argument. See struct.__doc__ for \n\ +more on format strings."); + +static PyObject * +s_pack_to(PyObject *self, PyObject *args) +{ + PyStructObject *soself; + char *buffer; + Py_ssize_t buffer_len, offset; + + /* Validate arguments. +1 is for the first arg as buffer. */ + soself = (PyStructObject *)self; + assert(PyStruct_Check(self)); + assert(soself->s_codes != NULL); + if (args == NULL || !PyTuple_Check(args) || + PyTuple_GET_SIZE(args) != (soself->s_len + 2)) + { + PyErr_Format(StructError, + "pack_to requires exactly %d arguments", + (soself->s_len + 2)); + return NULL; + } + + /* Extract a writable memory buffer from the first argument */ + if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), + (void**)&buffer, &buffer_len) == -1 ) { + return NULL; + } + assert( buffer_len >= 0 ); + + /* Extract the offset from the first argument */ + offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1)); + + /* Support negative offsets. */ + if (offset < 0) + offset += buffer_len; + + /* Check boundaries */ + if (offset < 0 || (buffer_len - offset) < soself->s_size) { + PyErr_Format(StructError, + "pack_to requires a buffer of at least %d bytes", + soself->s_size); + return NULL; + } + /* Call the guts */ + if ( s_pack_internal(soself, args, 2, buffer + offset) != 0 ) { + return NULL; + } + + return Py_None; } @@ -1400,6 +1479,7 @@ static struct PyMethodDef s_methods[] = { {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, + {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ Modified: python/trunk/Modules/arraymodule.c ============================================================================== --- python/trunk/Modules/arraymodule.c (original) +++ python/trunk/Modules/arraymodule.c Fri May 26 14:03:27 2006 @@ -1975,9 +1975,9 @@ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)array_repr, /* tp_repr */ - 0, /* tp_as _number*/ - &array_as_sequence, /* tp_as _sequence*/ - &array_as_mapping, /* tp_as _mapping*/ + 0, /* tp_as_number*/ + &array_as_sequence, /* tp_as_sequence*/ + &array_as_mapping, /* tp_as_mapping*/ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Fri May 26 14:03:27 2006 @@ -104,7 +104,10 @@ listen(n) -- start listening for incoming connections\n\ makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\ recv(buflen[, flags]) -- receive data\n\ -recvfrom(buflen[, flags]) -- receive data and sender's address\n\ +recv_buf(buffer[, nbytes[, flags]]) -- receive data (into a buffer)\n\ +recvfrom(buflen[, flags]) -- receive data and sender\'s address\n\ +recvfrom_buf(buffer[, nbytes, [, flags])\n\ + -- receive data and sender\'s address (into a buffer)\n\ sendall(data[, flags]) -- send all data\n\ send(data[, flags]) -- send data, may not send all of it\n\ sendto(data[, flags], addr) -- send data to a given address\n\ @@ -205,7 +208,7 @@ functions are declared correctly if compiling with MIPSPro 7.x in ANSI C mode (default) */ -/* XXX Using _SGIAPI is the wrong thing, +/* XXX Using _SGIAPI is the wrong thing, but I don't know what the right thing is. */ #undef _SGIAPI /* to avoid warning */ #define _SGIAPI 1 @@ -223,8 +226,8 @@ #include #endif -/* Irix 6.5 fails to define this variable at all. This is needed - for both GCC and SGI's compiler. I'd say that the SGI headers +/* Irix 6.5 fails to define this variable at all. This is needed + for both GCC and SGI's compiler. I'd say that the SGI headers are just busted. Same thing for Solaris. */ #if (defined(__sgi) || defined(sun)) && !defined(INET_ADDRSTRLEN) #define INET_ADDRSTRLEN 16 @@ -1194,10 +1197,10 @@ args->ob_type->tp_name); return 0; } - if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", + if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; - result = setipaddr(host, (struct sockaddr *)addr, + result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); if (result < 0) @@ -1225,12 +1228,12 @@ args->ob_type->tp_name); return 0; } - if (!PyArg_ParseTuple(args, "eti|ii", + if (!PyArg_ParseTuple(args, "eti|ii", "idna", &host, &port, &flowinfo, &scope_id)) { return 0; } - result = setipaddr(host, (struct sockaddr *)addr, + result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); if (result < 0) @@ -1839,7 +1842,7 @@ int res_size = sizeof res; /* It must be in the exception set */ assert(FD_ISSET(s->sock_fd, &fds_exc)); - if (0 == getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR, + if (0 == getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR, (char *)&res, &res_size)) /* getsockopt also clears WSAGetLastError, so reset it back. */ @@ -2135,95 +2138,126 @@ #endif /* NO_DUP */ - -/* s.recv(nbytes [,flags]) method */ - -static PyObject * -sock_recv(PySocketSockObject *s, PyObject *args) +/* + * This is the guts of the recv() and recv_buf() methods, which reads into a + * char buffer. If you have any inc/def ref to do to the objects that contain + * the buffer, do it in the caller. This function returns the number of bytes + * succesfully read. If there was an error, it returns -1. Note that it is + * also possible that we return a number of bytes smaller than the request + * bytes. + */ +static int +sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags) { - int len, n = 0, flags = 0, timeout; - PyObject *buf; + int timeout, outlen = 0; #ifdef __VMS - int read_length; + int remaining, nread; char *read_buf; #endif - if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) - return NULL; - - if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); - return NULL; + if (!IS_SELECTABLE(s)) { + select_error(); + return -1; } - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) - return NULL; - - if (!IS_SELECTABLE(s)) - return select_error(); - #ifndef __VMS Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); + outlen = recv(s->sock_fd, cbuf, len, flags); Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + if (outlen < 0) { + /* Note: the call to errorhandler() ALWAYS indirectly returned + NULL, so ignore its return value */ + s->errorhandler(); + return -1; } - if (n != len) - _PyString_Resize(&buf, n); #else - read_buf = PyString_AsString(buf); - read_length = len; - while (read_length != 0) { + read_buf = cbuf; + remaining = len; + while (remaining != 0) { unsigned int segment; - segment = read_length /SEGMENT_SIZE; + segment = remaining /SEGMENT_SIZE; if (segment != 0) { segment = SEGMENT_SIZE; } else { - segment = read_length; + segment = remaining; } Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - n = recv(s->sock_fd, read_buf, segment, flags); + nread = recv(s->sock_fd, read_buf, segment, flags); Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + if (nread < 0) { + s->errorhandler(); + return -1; } - if (n != read_length) { - read_buf += n; + if (nread != remaining) { + read_buf += nread; break; } - read_length -= segment; + remaining -= segment; read_buf += segment; } - if (_PyString_Resize(&buf, (read_buf - PyString_AsString(buf))) < 0) - { - return NULL; - } + outlen = read_buf - cbuf; #endif /* !__VMS */ + + return outlen; +} + + +/* s.recv(nbytes [,flags]) method */ + +static PyObject * +sock_recv(PySocketSockObject *s, PyObject *args) +{ + int recvlen, flags = 0, outlen; + PyObject *buf; + + if (!PyArg_ParseTuple(args, "i|i:recv", &recvlen, &flags)) + return NULL; + + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); + return NULL; + } + + /* Allocate a new string. */ + buf = PyString_FromStringAndSize((char *) 0, recvlen); + if (buf == NULL) + return NULL; + + /* Call the guts */ + outlen = sock_recv_guts(s, PyString_AsString(buf), recvlen, flags); + if (outlen < 0) { + /* An error occured, release the string and return an + error. */ + Py_DECREF(buf); + return NULL; + } + if (outlen != recvlen) { + /* We did not read as many bytes as we anticipated, resize the + string if possible and be succesful. */ + if (_PyString_Resize(&buf, outlen) < 0) + /* Oopsy, not so succesful after all. */ + return NULL; + } + return buf; } @@ -2236,29 +2270,90 @@ the remote end is closed and all data is read, return the empty string."); -/* s.recvfrom(nbytes [,flags]) method */ +/* s.recv_buf(buffer, [nbytes [,flags]]) method */ -static PyObject * -sock_recvfrom(PySocketSockObject *s, PyObject *args) +static PyObject* +sock_recv_buf(PySocketSockObject *s, PyObject *args, PyObject *kwds) { - sock_addr_t addrbuf; - PyObject *buf = NULL; - PyObject *addr = NULL; - PyObject *ret = NULL; - int len, n = 0, flags = 0, timeout; - socklen_t addrlen; + static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; - if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) + int recvlen = 0, flags = 0, readlen; + char *buf; + int buflen; + + /* Get the buffer's memory */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recv", kwlist, + &buf, &buflen, &recvlen, &flags)) return NULL; + assert(buf != 0 && buflen > 0); - if (!getsockaddrlen(s, &addrlen)) + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); return NULL; - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) + } + if (recvlen == 0) { + /* If nbytes was not specified, use the buffer's length */ + recvlen = buflen; + } + + /* Check if the buffer is large enough */ + if (buflen < recvlen) { + PyErr_SetString(PyExc_ValueError, + "buffer too small for requested bytes"); return NULL; + } - if (!IS_SELECTABLE(s)) - return select_error(); + /* Call the guts */ + readlen = sock_recv_guts(s, buf, recvlen, flags); + if (readlen < 0) { + /* Return an error. */ + return NULL; + } + + /* Return the number of bytes read. Note that we do not do anything + special here in the case that readlen < recvlen. */ + return PyInt_FromLong(readlen); +} + +PyDoc_STRVAR(recv_buf_doc, +"recv_buf(buffer, [nbytes[, flags]]) -> nbytes_read\n\ +\n\ +A version of recv() that stores its data into a buffer rather than creating \n\ +a new string. Receive up to buffersize bytes from the socket. If buffersize \n\ +is not specified (or 0), receive up to the size available in the given buffer.\n\ +\n\ +See recv() for documentation about the flags."); + + +/* + * This is the guts of the recv() and recv_buf() methods, which reads into a + * char buffer. If you have any inc/def ref to do to the objects that contain + * the buffer, do it in the caller. This function returns the number of bytes + * succesfully read. If there was an error, it returns -1. Note that it is + * also possible that we return a number of bytes smaller than the request + * bytes. + * + * 'addr' is a return value for the address object. Note that you must decref + * it yourself. + */ +static int +sock_recvfrom_guts(PySocketSockObject *s, char* cbuf, int len, int flags, + PyObject** addr) +{ + sock_addr_t addrbuf; + int n = 0, timeout; + socklen_t addrlen; + + *addr = NULL; + + if (!getsockaddrlen(s, &addrlen)) + return -1; + + if (!IS_SELECTABLE(s)) { + select_error(); + return -1; + } Py_BEGIN_ALLOW_THREADS memset(&addrbuf, 0, addrlen); @@ -2266,41 +2361,71 @@ if (!timeout) { #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (struct sockaddr *) &addrbuf, &addrlen); #else - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, + n = recvfrom(s->sock_fd, cbuf, len, flags, (struct sockaddr *) &addrbuf, &addrlen); #endif } Py_END_ALLOW_THREADS if (timeout) { - Py_DECREF(buf); PyErr_SetString(socket_timeout, "timed out"); - return NULL; + return -1; } if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); + s->errorhandler(); + return -1; } - if (n != len && _PyString_Resize(&buf, n) < 0) + if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addrlen, s->sock_proto))) + return -1; + + return n; +} + +/* s.recvfrom(nbytes [,flags]) method */ + +static PyObject * +sock_recvfrom(PySocketSockObject *s, PyObject *args) +{ + PyObject *buf = NULL; + PyObject *addr = NULL; + PyObject *ret = NULL; + int recvlen, outlen, flags = 0; + + if (!PyArg_ParseTuple(args, "i|i:recvfrom", &recvlen, &flags)) + return NULL; + + buf = PyString_FromStringAndSize((char *) 0, recvlen); + if (buf == NULL) return NULL; - if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, - addrlen, s->sock_proto))) + outlen = sock_recvfrom_guts(s, PyString_AS_STRING(buf), + recvlen, flags, &addr); + if (outlen < 0) { goto finally; + } + + if (outlen != recvlen) { + /* We did not read as many bytes as we anticipated, resize the + string if possible and be succesful. */ + if (_PyString_Resize(&buf, outlen) < 0) + /* Oopsy, not so succesful after all. */ + goto finally; + } ret = PyTuple_Pack(2, buf, addr); finally: - Py_XDECREF(addr); Py_XDECREF(buf); + Py_XDECREF(addr); return ret; } @@ -2309,6 +2434,57 @@ \n\ Like recv(buffersize, flags) but also return the sender's address info."); + +/* s.recvfrom_buf(buffer[, nbytes [,flags]]) method */ + +static PyObject * +sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds) +{ + static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; + + int recvlen = 0, flags = 0, readlen; + char *buf; + int buflen; + + PyObject *addr = NULL; + PyObject *ret = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recvfrom", kwlist, + &buf, &buflen, &recvlen, &flags)) + return NULL; + assert(buf != 0 && buflen > 0); + + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recv"); + return NULL; + } + if (recvlen == 0) { + /* If nbytes was not specified, use the buffer's length */ + recvlen = buflen; + } + + readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); + if (readlen < 0) { + /* Return an error */ + goto finally; + } + + /* Return the number of bytes read and the address. Note that we do + not do anything special here in the case that readlen < recvlen. */ + ret = PyTuple_Pack(2, PyInt_FromLong(readlen), addr); + +finally: + Py_XDECREF(addr); + return ret; +} + +PyDoc_STRVAR(recvfrom_buf_doc, +"recvfrom_buf(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\ +\n\ +Like recv_buf(buffer[, nbytes[, flags]]) but also return the sender's address info."); + + /* s.send(data [,flags]) method */ static PyObject * @@ -2503,59 +2679,63 @@ /* List of methods for socket objects */ static PyMethodDef sock_methods[] = { - {"accept", (PyCFunction)sock_accept, METH_NOARGS, - accept_doc}, - {"bind", (PyCFunction)sock_bind, METH_O, - bind_doc}, - {"close", (PyCFunction)sock_close, METH_NOARGS, - close_doc}, - {"connect", (PyCFunction)sock_connect, METH_O, - connect_doc}, - {"connect_ex", (PyCFunction)sock_connect_ex, METH_O, - connect_ex_doc}, + {"accept", (PyCFunction)sock_accept, METH_NOARGS, + accept_doc}, + {"bind", (PyCFunction)sock_bind, METH_O, + bind_doc}, + {"close", (PyCFunction)sock_close, METH_NOARGS, + close_doc}, + {"connect", (PyCFunction)sock_connect, METH_O, + connect_doc}, + {"connect_ex", (PyCFunction)sock_connect_ex, METH_O, + connect_ex_doc}, #ifndef NO_DUP - {"dup", (PyCFunction)sock_dup, METH_NOARGS, - dup_doc}, + {"dup", (PyCFunction)sock_dup, METH_NOARGS, + dup_doc}, #endif - {"fileno", (PyCFunction)sock_fileno, METH_NOARGS, - fileno_doc}, + {"fileno", (PyCFunction)sock_fileno, METH_NOARGS, + fileno_doc}, #ifdef HAVE_GETPEERNAME - {"getpeername", (PyCFunction)sock_getpeername, - METH_NOARGS, getpeername_doc}, + {"getpeername", (PyCFunction)sock_getpeername, + METH_NOARGS, getpeername_doc}, #endif - {"getsockname", (PyCFunction)sock_getsockname, - METH_NOARGS, getsockname_doc}, - {"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS, - getsockopt_doc}, - {"listen", (PyCFunction)sock_listen, METH_O, - listen_doc}, + {"getsockname", (PyCFunction)sock_getsockname, + METH_NOARGS, getsockname_doc}, + {"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS, + getsockopt_doc}, + {"listen", (PyCFunction)sock_listen, METH_O, + listen_doc}, #ifndef NO_DUP - {"makefile", (PyCFunction)sock_makefile, METH_VARARGS, - makefile_doc}, + {"makefile", (PyCFunction)sock_makefile, METH_VARARGS, + makefile_doc}, #endif - {"recv", (PyCFunction)sock_recv, METH_VARARGS, - recv_doc}, - {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, - recvfrom_doc}, - {"send", (PyCFunction)sock_send, METH_VARARGS, - send_doc}, - {"sendall", (PyCFunction)sock_sendall, METH_VARARGS, - sendall_doc}, - {"sendto", (PyCFunction)sock_sendto, METH_VARARGS, - sendto_doc}, - {"setblocking", (PyCFunction)sock_setblocking, METH_O, - setblocking_doc}, - {"settimeout", (PyCFunction)sock_settimeout, METH_O, - settimeout_doc}, - {"gettimeout", (PyCFunction)sock_gettimeout, METH_NOARGS, - gettimeout_doc}, - {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, - setsockopt_doc}, - {"shutdown", (PyCFunction)sock_shutdown, METH_O, - shutdown_doc}, + {"recv", (PyCFunction)sock_recv, METH_VARARGS, + recv_doc}, + {"recv_buf", (PyCFunction)sock_recv_buf, METH_VARARGS | METH_KEYWORDS, + recv_buf_doc}, + {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, + recvfrom_doc}, + {"recvfrom_buf", (PyCFunction)sock_recvfrom_buf, METH_VARARGS | METH_KEYWORDS, + recvfrom_buf_doc}, + {"send", (PyCFunction)sock_send, METH_VARARGS, + send_doc}, + {"sendall", (PyCFunction)sock_sendall, METH_VARARGS, + sendall_doc}, + {"sendto", (PyCFunction)sock_sendto, METH_VARARGS, + sendto_doc}, + {"setblocking", (PyCFunction)sock_setblocking, METH_O, + setblocking_doc}, + {"settimeout", (PyCFunction)sock_settimeout, METH_O, + settimeout_doc}, + {"gettimeout", (PyCFunction)sock_gettimeout, METH_NOARGS, + gettimeout_doc}, + {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, + setsockopt_doc}, + {"shutdown", (PyCFunction)sock_shutdown, METH_O, + shutdown_doc}, #ifdef RISCOS - {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O, - sleeptaskw_doc}, + {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O, + sleeptaskw_doc}, #endif {NULL, NULL} /* sentinel */ }; @@ -3401,7 +3581,7 @@ if (strcmp(ip_addr, "255.255.255.255") == 0) { packed_addr = 0xFFFFFFFF; } else { - + packed_addr = inet_addr(ip_addr); if (packed_addr == INADDR_NONE) { /* invalid address */ @@ -3476,7 +3656,7 @@ "can't use AF_INET6, IPv6 is disabled"); return NULL; } -#endif +#endif retval = inet_pton(af, ip, packed); if (retval < 0) { @@ -3499,7 +3679,7 @@ return NULL; } } - + PyDoc_STRVAR(inet_ntop_doc, "inet_ntop(af, packed_ip) -> string formatted IP address\n\ \n\ @@ -3517,7 +3697,7 @@ #else char ip[INET_ADDRSTRLEN + 1]; #endif - + /* Guarantee NUL-termination for PyString_FromString() below */ memset((void *) &ip[0], '\0', sizeof(ip)); @@ -3595,7 +3775,7 @@ } else if (PyString_Check(hobj)) { hptr = PyString_AsString(hobj); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "getaddrinfo() argument 1 must be string or None"); return NULL; } From python-checkins at python.org Fri May 26 14:07:42 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 14:07:42 +0200 (CEST) Subject: [Python-checkins] r46301 - in python/branches/sreifschneider-newnewexcept: Lib/warnings.py Objects/exceptions.c Message-ID: <20060526120742.5FC691E4019@bag.python.org> Author: richard.jones Date: Fri May 26 14:07:41 2006 New Revision: 46301 Modified: python/branches/sreifschneider-newnewexcept/Lib/warnings.py python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: fold in changes suggested by Georg Modified: python/branches/sreifschneider-newnewexcept/Lib/warnings.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/warnings.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/warnings.py Fri May 26 14:07:41 2006 @@ -261,6 +261,4 @@ # Module initialization _processoptions(sys.warnoptions) -# XXX OverflowWarning should go away for Python 2.5. -simplefilter("ignore", category=OverflowWarning, append=1) simplefilter("ignore", category=PendingDeprecationWarning, append=1) Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 14:07:41 2006 @@ -12,47 +12,15 @@ PyObject *message; } BaseExceptionObject; -/* GB: - PyTuple_* would be faster than PySequence_* - - should use PyDoc_STR() macros for docstrings - - I don't know, but it may be that the exceptions +/* GB: - I don't know, but it may be that the exceptions have to be GC objects - If you want to allow normal attribute access, I think you can use PyObject_GenericGetAttr etc. in the tp_getattr... slots. */ -static PyObject * -BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - BaseExceptionObject *self; - - self = (BaseExceptionObject *)type->tp_alloc(type, 0); - - self->args = self->message = NULL; - - if (!args) { - self->args = PyTuple_New(0); - if (!self->args) { - Py_DECREF(self); - return NULL; - } - } - else - self->args = args; - /* GB: Isn't the tuple INCREFd twice? */ - Py_INCREF(self->args); - - if (PySequence_Length(self->args) == 1) - self->message = PySequence_GetItem(self->args, 0); - else - self->message = PyString_FromString(""); - /* GB: error check */ - - return (PyObject *)self; -} - static int -BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +_BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) { if (!args) { self->args = PyTuple_New(0); @@ -60,29 +28,51 @@ return -1; } } - else + else { self->args = args; - /* GB: tuple/INCREF */ - Py_INCREF(self->args); + Py_INCREF(self->args); + } if (PySequence_Length(self->args) == 1) self->message = PySequence_GetItem(self->args, 0); else self->message = PyString_FromString(""); if (!self->message) { - Py_DECREF(self->args); return -1; } return 0; } +static PyObject * +BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + BaseExceptionObject *self; + + self = (BaseExceptionObject *)type->tp_alloc(type, 0); + + self->args = self->message = NULL; + + if (_BaseException_init(self, args, kwds) == -1) { + Py_DECREF(self); + return NULL; + } + + return (PyObject *)self; +} + +static int +BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +{ + return _BaseException_init(self, args, kwds); +} + static void BaseException_dealloc(BaseExceptionObject *self) { - Py_XDECREF(self->args); - Py_XDECREF(self->message); - /* GB: call tp_free? */ + Py_CLEAR(self->args); + Py_CLEAR(self->message); + self->ob_type->tp_free((PyObject *)self); } @@ -91,20 +81,20 @@ { PyObject *out; - switch (PySequence_Size(self->args)) { + switch (PySequence_Length(self->args)) { case 0: out = PyString_FromString(""); break; case 1: { - PyObject *tmp = PySequence_GetItem(self->args, 0); - if (tmp) { - out = PyObject_Str(tmp); - Py_DECREF(tmp); - } - else - out = NULL; - break; + PyObject *tmp = PySequence_GetItem(self->args, 0); + if (tmp) { + out = PyObject_Str(tmp); + Py_DECREF(tmp); + } + else + out = NULL; + break; } case -1: PyErr_Clear(); @@ -118,54 +108,46 @@ } -/* GB: does _unicode have/need an argument? */ #ifdef Py_USING_UNICODE static PyObject * -BaseException_unicode(BaseExceptionObject *self, PyObject *args) +BaseException_unicode(BaseExceptionObject *self) { - PyObject *temp = PySequence_GetItem(self->args, 0); - PyObject *unicode_obj; - if (!temp) { - return NULL; - } - unicode_obj = PyObject_Unicode(temp); - Py_DECREF(temp); - return unicode_obj; + return PyObject_Unicode(self->args); } #endif /* Py_USING_UNICODE */ static PyObject * BaseException_repr(BaseExceptionObject *self) { - Py_ssize_t args_len; - PyObject *repr_suffix; - PyObject *repr; - - args_len = PySequence_Length(self->args); - if (args_len < 0) { - return NULL; - } - - if (args_len == 0) { - repr_suffix = PyString_FromString("()"); - if (!repr_suffix) - return NULL; - } - else { - PyObject *args_repr = PyObject_Repr(self->args); - if (!args_repr) - return NULL; - repr_suffix = args_repr; - } - - repr = PyString_FromString(self->ob_type->tp_name); - if (!repr) { - Py_DECREF(repr_suffix); - return NULL; - } + Py_ssize_t args_len; + PyObject *repr_suffix; + PyObject *repr; - PyString_ConcatAndDel(&repr, repr_suffix); - return repr; + args_len = PySequence_Length(self->args); + if (args_len < 0) { + return NULL; + } + + if (args_len == 0) { + repr_suffix = PyString_FromString("()"); + if (!repr_suffix) + return NULL; + } + else { + PyObject *args_repr = PyObject_Repr(self->args); + if (!args_repr) + return NULL; + repr_suffix = args_repr; + } + + repr = PyString_FromString(self->ob_type->tp_name); + if (!repr) { + Py_DECREF(repr_suffix); + return NULL; + } + + PyString_ConcatAndDel(&repr, repr_suffix); + return repr; } static PyObject * @@ -175,22 +157,24 @@ } static PySequenceMethods BaseException_as_sequence = { - 0, /* sq_length; */ - 0, /* sq_concat; */ - 0, /* sq_repeat; */ - (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ - 0, /* sq_ass_item; */ - 0, /* sq_ass_slice; */ - 0, /* sq_contains; */ - 0, /* sq_inplace_concat; */ - 0 /* sq_inplace_repeat; */ + 0, /* sq_length; */ + 0, /* sq_concat; */ + 0, /* sq_repeat; */ + (ssizeargfunc)BaseException_getitem, /* sq_item; */ + 0, /* sq_slice; */ + 0, /* sq_ass_item; */ + 0, /* sq_ass_slice; */ + 0, /* sq_contains; */ + 0, /* sq_inplace_concat; */ + 0 /* sq_inplace_repeat; */ }; static PyMemberDef BaseException_members[] = { - {"args", T_OBJECT, offsetof(BaseExceptionObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, "exception message"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(BaseExceptionObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, + PyDoc_STR("exception message")}, + {NULL} /* Sentinel */ }; static PyMethodDef BaseException_methods[] = { @@ -222,13 +206,13 @@ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Common base class for all exceptions", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ + PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ BaseException_methods, /* tp_methods */ BaseException_members, /* tp_members */ 0, /* tp_getset */ @@ -254,7 +238,7 @@ sizeof(BaseExceptionObject), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - EXCDOC, \ + PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, 0, (initproc)BaseException_init, 0, BaseException_new,\ }; \ @@ -268,7 +252,7 @@ sizeof(EXCSTORE ## Object), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - EXCDOC, \ + PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -283,7 +267,7 @@ (destructor)EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - EXCDOC, \ + PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -326,12 +310,30 @@ * SystemExit extends BaseException */ typedef struct { - PyObject_HEAD - PyObject *args; - PyObject *message; - PyObject *code; + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *code; } SystemExitObject; +static int +_SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) +{ + Py_ssize_t size = PySequence_Length(args); + + if (size == 1) + self->code = PySequence_GetItem(args, 0); + else if (size > 1) { + self->code = args; + Py_INCREF(Py_None); + } + else { + self->code = Py_None; + Py_INCREF(Py_None); + } + return 0; +} + static PyObject * SystemExit_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -341,11 +343,9 @@ if (!self) return NULL; - if (PySequence_Length(args) == 1) - self->code = PySequence_GetItem(args, 0); - else { - self->code = Py_None; - Py_INCREF(Py_None); + if (_SystemExit_init(self, args, kwds) == -1) { + Py_DECREF(self); + return NULL; } return (PyObject *)self; @@ -354,29 +354,24 @@ static int SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) { - if (PySequence_Length(args) == 1) - self->code = PySequence_GetItem(args, 0); - else { - self->code = Py_None; - Py_INCREF(Py_None); - } - - return 0; + return _SystemExit_init(self, args, kwds); } static void SystemExit_dealloc(SystemExitObject *self) { - /* GB: shouldn't the decref come first? */ + Py_CLEAR(self->code); BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->code); } static PyMemberDef SystemExit_members[] = { - {"args", T_OBJECT, offsetof(SystemExitObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, "exception message"}, - {"code", T_OBJECT, offsetof(SystemExitObject, code), 0, "exception code"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(SystemExitObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, + PyDoc_STR("exception message")}, + {"code", T_OBJECT, offsetof(SystemExitObject, code), 0, + PyDoc_STR("exception code")}, + {NULL} /* Sentinel */ }; ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, "Request to exit from the interpreter."); @@ -397,63 +392,56 @@ * EnvironmentError extends StandardError */ typedef struct { - PyObject_HEAD - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; } EnvironmentErrorObject; +/* Where a function has a single filename, such as open() or some + * of the os module functions, PyErr_SetFromErrnoWithFilename() is + * called, giving a third argument which is the filename. But, so + * that old code using in-place unpacking doesn't break, e.g.: + * + * except IOError, (errno, strerror): + * + * we hack args so that it only contains two items. This also + * means we need our own __str__() which prints out the filename + * when it was supplied. + */ static int _EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { + PyObject *myerrno, *strerror, *filename; PyObject *subslice = NULL; + + if (!PyArg_ParseTuple(args, "OO|O", &myerrno, &strerror, &filename)) { + return -1; + } - switch (PySequence_Size(args)) { - case 3: - /* Where a function has a single filename, such as open() or some - * of the os module functions, PyErr_SetFromErrnoWithFilename() is - * called, giving a third argument which is the filename. But, so - * that old code using in-place unpacking doesn't break, e.g.: - * - * except IOError, (errno, strerror): - * - * we hack args so that it only contains two items. This also - * means we need our own __str__() which prints out the filename - * when it was supplied. - */ - self->myerrno = PySequence_GetItem(args, 0); - if (!self->myerrno) return -1; - self->strerror = PySequence_GetItem(args, 1); - /* GB: in error cases, you're leaking refs to myerrno etc. - and perhaps you should be clearing self->... too on error */ - if (!self->strerror) return -1; - self->filename = PySequence_GetItem(args, 2); - if (!self->filename) return -1; + Py_DECREF(self->myerrno); /* replacing */ + self->myerrno = myerrno; + Py_INCREF(self->myerrno); + + Py_DECREF(self->strerror); /* replacing */ + self->strerror = strerror; + Py_INCREF(self->strerror); + + /* self->filename will remain Py_None otherwise */ + if (filename != NULL) { + Py_DECREF(self->filename); /* replacing */ + self->filename = filename; + Py_INCREF(self->filename); - subslice = PySequence_GetSlice(args, 0, 2); - if (!subslice) - return -1; + subslice = PyTuple_GetSlice(args, 0, 2); + if (!subslice) + return -1; - /* GB: can it be that self->args is NULL? */ Py_DECREF(self->args); /* replacing args */ self->args = subslice; - return 0; - - case 2: - /* Used when PyErr_SetFromErrno() is called and no filename - * argument is given. - */ - self->myerrno = PySequence_GetItem(args, 0); - if (!self->myerrno) return -1; - self->strerror = PySequence_GetItem(args, 1); - if (!self->strerror) return -1; - return 0; - - case -1: - PyErr_Clear(); } return 0; } @@ -475,13 +463,11 @@ Py_INCREF(Py_None); if (_EnvironmentError_init(self, args, kwds) == -1) { - /* GB: why clear the error? */ - PyErr_Clear(); + return NULL; } return (PyObject *)self; } -/* GB: what's that function doing? */ static int EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) @@ -492,10 +478,10 @@ static void EnvironmentError_dealloc(EnvironmentErrorObject *self) { + Py_CLEAR(self->myerrno); + Py_CLEAR(self->strerror); + Py_CLEAR(self->filename); BaseException_dealloc((BaseExceptionObject *)self); - Py_DECREF(self->myerrno); - Py_DECREF(self->strerror); - Py_DECREF(self->filename); } static PyObject * @@ -504,57 +490,66 @@ PyObject *rtnval = NULL; if (self->filename != Py_None) { - PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); - PyObject *repr = PyObject_Repr(self->filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); - return NULL; - } -/* GB: PyTuple_SET_ITEM steals references, so you may need to INCREF first */ - PyTuple_SET_ITEM(tuple, 0, self->myerrno); - PyTuple_SET_ITEM(tuple, 1, self->strerror); - PyTuple_SET_ITEM(tuple, 2, repr); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - } - else if (PyObject_IsTrue(self->myerrno) && PyObject_IsTrue(self->strerror)) { - PyObject *fmt = PyString_FromString("[Errno %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); - return NULL; - } -/* GB: same here */ - PyTuple_SET_ITEM(tuple, 0, self->myerrno); - PyTuple_SET_ITEM(tuple, 1, self->strerror); + PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); + PyObject *repr = PyObject_Repr(self->filename); + PyObject *tuple = PyTuple_New(3); + + if (!fmt || !repr || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(repr); + Py_XDECREF(tuple); + return NULL; + } + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + Py_INCREF(repr); + PyTuple_SET_ITEM(tuple, 2, repr); + + rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); + Py_DECREF(tuple); + } + else if (PyObject_IsTrue(self->myerrno) && + PyObject_IsTrue(self->strerror)) { + PyObject *fmt = PyString_FromString("[Errno %s] %s"); + PyObject *tuple = PyTuple_New(2); + + if (!fmt || !tuple) { + Py_XDECREF(fmt); + Py_XDECREF(tuple); + return NULL; + } + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); - rtnval = PyString_Format(fmt, tuple); + rtnval = PyString_Format(fmt, tuple); - Py_DECREF(fmt); - Py_DECREF(tuple); + Py_DECREF(fmt); + Py_DECREF(tuple); } else - rtnval = BaseException_str((BaseExceptionObject *)self); + rtnval = BaseException_str((BaseExceptionObject *)self); return rtnval; } static PyMemberDef EnvironmentError_members[] = { - {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, "exception message"}, - {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, myerrno), 0, "exception code"}, - {"strerror", T_OBJECT, offsetof(EnvironmentErrorObject, strerror), 0, "exception code"}, - {"filename", T_OBJECT, offsetof(EnvironmentErrorObject, filename), 0, "exception code"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, + PyDoc_STR("exception message")}, + {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, myerrno), 0, + PyDoc_STR("exception code")}, + {"strerror", T_OBJECT, offsetof(EnvironmentErrorObject, strerror), 0, + PyDoc_STR("exception code")}, + {"filename", T_OBJECT, offsetof(EnvironmentErrorObject, filename), 0, + PyDoc_STR("exception code")}, + {NULL} /* Sentinel */ }; ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_str, "Base class for I/O related errors."); @@ -579,75 +574,78 @@ #include "errmap.h" typedef struct { - PyObject_HEAD - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; - PyObject *winerror; + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; } WindowsErrorObject; static PyObject * WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *o_errcode = NULL; - WindowsErrorObject *self = NULL; - long posix_errno; + PyObject *o_errcode = NULL; + PyObject *errcode = NULL; + WindowsErrorObject *self = NULL; + long posix_errno; - self = (WindowsErrorObject *)EnvironmentError_new(type, args, kwds); - if (!self) - return NULL; + self = (WindowsErrorObject *)EnvironmentError_new(type, args, kwds); + if (!self) + return NULL; + + /* Set errno to the POSIX errno, and winerror to the Win32 + error code. */ + errcode = PyInt_AsLong(self->myerrno); + if (!errcode == -1 && PyErr_Occurred()) + return NULL; + posix_errno = winerror_to_errno(errcode); - /* Set errno to the POSIX errno, and winerror to the Win32 - error code. */ - /* GB: where is errcode declared? */ - errcode = PyInt_AsLong(self->myerrno); - if (!errcode == -1 && PyErr_Occurred()) - goto failed; - posix_errno = winerror_to_errno(errcode); - - /* INCREF? */ - self->winerror = self->myerrno; - - o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) - goto failed; + self->winerror = self->myerrno; - self->myerrno = o_errcode; + o_errcode = PyInt_FromLong(posix_errno); + if (!o_errcode) + goto failed; - return self; + self->myerrno = o_errcode; + + return self; failed: - /* Could not set errno. */ - Py_XDECREF(o_errcode); - Py_XDECREF(self); - return NULL; + /* Could not set errno. */ + Py_XDECREF(o_errcode); + Py_XDECREF(self); + return NULL; } static int WindowsError_init(WindowsErrorObject *self, PyObject *args, PyObject *kwds) { - /* GB: same: errcode */ - if (EnvironmentError_init((EnvironmentErrorObject *)self, args, - kwds) == -1) - return -1; + PyObject *o_errcode = NULL; + PyObject *errcode = NULL; + + if (EnvironmentError_init((EnvironmentErrorObject *)self, args, kwds) == -1) + return -1; - /* Set errno to the POSIX errno, and winerror to the Win32 - error code. */ - errcode = PyInt_AsLong(self->myerrno); - if (!errcode == -1 && PyErr_Occurred()) - return -1; - posix_errno = winerror_to_errno(errcode); - - self->winerror = self->myerrno; - - o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) - return -1; + /* Set errno to the POSIX errno, and winerror to the Win32 + error code. */ + errcode = PyInt_AsLong(self->myerrno); + if (!errcode == -1 && PyErr_Occurred()) + return -1; + posix_errno = winerror_to_errno(errcode); - self->myerrno = o_errcode; + self->winerror = self->myerrno; - return 0; + o_errcode = PyInt_FromLong(posix_errno); + if (!o_errcode) { + Py_DECREF(errcode); + return -1; + } + + self->myerrno = o_errcode; + + Py_DECREF(errcode); + return 0; } @@ -660,32 +658,33 @@ PyObject *rtnval = NULL; if (self->filename != Py_None) { - fmt = PyString_FromString("[Error %s] %s: %s"); - repr = PyObject_Repr(self->filename); - if (!fmt || !repr) - goto finally; - - tuple = PyTuple_Pack(3, self->myerrno, self->strerror, repr); - if (!tuple) - goto finally; - - rtnval = PyString_Format(fmt, tuple); - /* GB: tuple must be DECREFd */ - } - else if (PyObject_IsTrue(self->myerrno) && PyObject_IsTrue(self->strerror)) { - fmt = PyString_FromString("[Error %s] %s"); - if (!fmt) - goto finally; - - tuple = PyTuple_Pack(2, self->myerrno, self->strerror); - if (!tuple) - goto finally; + fmt = PyString_FromString("[Error %s] %s: %s"); + repr = PyObject_Repr(self->filename); + if (!fmt || !repr) + goto finally; + + tuple = PyTuple_Pack(3, self->myerrno, self->strerror, repr); + if (!tuple) + goto finally; + + rtnval = PyString_Format(fmt, tuple); + Py_DECREF(tuple); + } + else if (PyObject_IsTrue(self->myerrno) && + PyObject_IsTrue(self->strerror)) { + fmt = PyString_FromString("[Error %s] %s"); + if (!fmt) + goto finally; + + tuple = PyTuple_Pack(2, self->myerrno, self->strerror); + if (!tuple) + goto finally; - rtnval = PyString_Format(fmt, tuple); - /* GB: tuple must be DECREFd */ + rtnval = PyString_Format(fmt, tuple); + Py_DECREF(tuple); } else - rtnval = EnvironmentError_str(self); + rtnval = EnvironmentError_str(self); finally: /* GB: where is filename, serrno and strerror declared? */ @@ -699,13 +698,19 @@ } static PyMemberDef WindowsError_members[] = { - {"args", T_OBJECT, offsetof(WindowsErrorObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, "exception message"}, - {"errno", T_OBJECT, offsetof(WindowsErrorObject, myerrno), 0, "exception code"}, - {"strerror", T_OBJECT, offsetof(WindowsErrorObject, strerror), 0, "exception code"}, - {"filename", T_OBJECT, offsetof(WindowsErrorObject, filename), 0, "exception code"}, - {"winerror", T_OBJECT, offsetof(WindowsErrorObject, winerror), 0, "windows exception code"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(WindowsErrorObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, + PyDoc_STR("exception message")}, + {"errno", T_OBJECT, offsetof(WindowsErrorObject, myerrno), 0, + PyDoc_STR("exception code")}, + {"strerror", T_OBJECT, offsetof(WindowsErrorObject, strerror), 0, + PyDoc_STR("exception code")}, + {"filename", T_OBJECT, offsetof(WindowsErrorObject, filename), 0, + PyDoc_STR("exception code")}, + {"winerror", T_OBJECT, offsetof(WindowsErrorObject, winerror), 0, + PyDoc_STR("windows exception code")}, + {NULL} /* Sentinel */ }; ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_str, "MS-Windows OS system call failed."); @@ -758,38 +763,41 @@ * SyntaxError extends StandardError */ typedef struct { - PyObject_HEAD - PyObject *args; - PyObject *message; - PyObject *msg; - PyObject *filename; - PyObject *lineno; - PyObject *offset; - PyObject *text; - PyObject *print_file_and_line; + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; } SyntaxErrorObject; static int _SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *info = NULL; - Py_ssize_t lenargs; + Py_ssize_t lenargs = PySequence_Length(args); - lenargs = PySequence_Size(args); if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - if (!item0) return -1; - self->msg = item0; + PyObject *item0 = PySequence_GetItem(args, 0); + if (!item0) return -1; + self->msg = item0; } if (lenargs == 2) { info = PySequence_GetItem(args, 1); - if (!info) return -1; - self->filename = PySequence_GetItem(info, 0); + if (!info) return -1; + + self->filename = PySequence_GetItem(info, 0); if (!self->filename) return -1; + self->lineno = PySequence_GetItem(info, 1); if (!self->lineno) return -1; + self->offset = PySequence_GetItem(info, 2); if (!self->offset) return -1; + self->text = PySequence_GetItem(info, 3); if (!self->text) return -1; } @@ -813,9 +821,8 @@ self->print_file_and_line = Py_None; Py_INCREF(Py_None); - /* GB: why clear the error? some fields can still be NULL */ if (_SyntaxError_init(self, args, kwds) == -1) - PyErr_Clear(); + return NULL; return (PyObject *)self; } @@ -829,13 +836,13 @@ static void SyntaxError_dealloc(SyntaxErrorObject *self) { + Py_CLEAR(self->msg); + Py_CLEAR(self->filename); + Py_CLEAR(self->lineno); + Py_CLEAR(self->offset); + Py_CLEAR(self->text); + Py_CLEAR(self->print_file_and_line); BaseException_dealloc((BaseExceptionObject *)self); - Py_XDECREF(self->msg); - Py_XDECREF(self->filename); - Py_XDECREF(self->lineno); - Py_XDECREF(self->offset); - Py_XDECREF(self->text); - Py_XDECREF(self->print_file_and_line); } /* This is called "my_basename" instead of just "basename" to avoid name @@ -844,17 +851,17 @@ static char * my_basename(char *name) { - char *cp = name; - char *result = name; + char *cp = name; + char *result = name; - if (name == NULL) - return "???"; - while (*cp != '\0') { - if (*cp == SEP) - result = cp + 1; - ++cp; - } - return result; + if (name == NULL) + return "???"; + while (*cp != '\0') { + if (*cp == SEP) + result = cp + 1; + ++cp; + } + return result; } @@ -888,17 +895,17 @@ if (buffer != NULL) { if (have_filename && have_lineno) PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename)), - PyInt_AsLong(self->lineno)); + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename)), + PyInt_AsLong(self->lineno)); else if (have_filename) PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename))); + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename))); else if (have_lineno) PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(self->lineno)); + PyString_AS_STRING(str), + PyInt_AsLong(self->lineno)); result = PyString_FromString(buffer); PyMem_FREE(buffer); @@ -914,15 +921,24 @@ } static PyMemberDef SyntaxError_members[] = { - {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, "exception message"}, - {"msg", T_OBJECT, offsetof(SyntaxErrorObject, msg), 0, "exception msg"}, - {"filename", T_OBJECT, offsetof(SyntaxErrorObject, filename), 0, "exception filename"}, - {"lineno", T_OBJECT, offsetof(SyntaxErrorObject, lineno), 0, "exception lineno"}, - {"offset", T_OBJECT, offsetof(SyntaxErrorObject, offset), 0, "exception offset"}, - {"text", T_OBJECT, offsetof(SyntaxErrorObject, text), 0, "exception text"}, - {"print_file_and_line", T_OBJECT, offsetof(SyntaxErrorObject, print_file_and_line), 0, "exception print_file_and_line"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, + PyDoc_STR("exception message")}, + {"msg", T_OBJECT, offsetof(SyntaxErrorObject, msg), 0, + PyDoc_STR("exception msg")}, + {"filename", T_OBJECT, offsetof(SyntaxErrorObject, filename), 0, + PyDoc_STR("exception filename")}, + {"lineno", T_OBJECT, offsetof(SyntaxErrorObject, lineno), 0, + PyDoc_STR("exception lineno")}, + {"offset", T_OBJECT, offsetof(SyntaxErrorObject, offset), 0, + PyDoc_STR("exception offset")}, + {"text", T_OBJECT, offsetof(SyntaxErrorObject, text), 0, + PyDoc_STR("exception text")}, + {"print_file_and_line", T_OBJECT, + offsetof(SyntaxErrorObject, print_file_and_line), 0, + PyDoc_STR("exception print_file_and_line")}, + {NULL} /* Sentinel */ }; ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); @@ -1004,21 +1020,19 @@ int get_int(PyObject *attr, Py_ssize_t *value, const char *name) { if (!attr) { - PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); return -1; } if (PyInt_Check(attr)) { *value = PyInt_AS_LONG(attr); } else if (PyLong_Check(attr)) { - /* GB: why not casting to Py_ssize_t? Can we be sure that LongLong - isn't larger than Py_ssize_t? */ - *value = (size_t)PyLong_AsLongLong(attr); - if (*value == -1) - return -1; + *value = PyLong_AsLongLong(attr); + if (*value == -1) + return -1; } else { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - return -1; + PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); + return -1; } return 0; } @@ -1028,7 +1042,7 @@ { PyObject *obj = PyInt_FromSsize_t(value); if (!obj) - return -1; + return -1; Py_XDECREF(*attr); *attr = obj; return 0; @@ -1038,13 +1052,13 @@ PyObject *get_string(PyObject *attr, const char *name) { if (!attr) { - PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); return NULL; } if (!PyString_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); - return NULL; + PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); + return NULL; } Py_INCREF(attr); return attr; @@ -1056,7 +1070,7 @@ { PyObject *obj = PyString_FromString(value); if (!obj) - return -1; + return -1; Py_XDECREF(*attr); *attr = obj; return 0; @@ -1067,19 +1081,18 @@ PyObject *get_unicode(PyObject *attr, const char *name) { if (!attr) { - PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); + PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); return NULL; } if (!PyUnicode_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); - return NULL; + PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); + return NULL; } Py_INCREF(attr); return attr; } -/* GB: Can't this be done more easily with a PyMemberDef? */ PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) { return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); @@ -1108,13 +1121,13 @@ int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); - if (*start<0) - *start = 0; /*XXX check for values <0*/ - if (*start>=size) - *start = size-1; - return 0; + Py_ssize_t size; + size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*start<0) + *start = 0; /*XXX check for values <0*/ + if (*start>=size) + *start = size-1; + return 0; } return -1; } @@ -1123,13 +1136,13 @@ int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) { if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { - Py_ssize_t size; - size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - return 0; + Py_ssize_t size; + size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*start<0) + *start = 0; + if (*start>=size) + *start = size-1; + return 0; } return -1; } @@ -1162,13 +1175,13 @@ int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - return 0; + Py_ssize_t size; + size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + return 0; } return -1; } @@ -1177,13 +1190,13 @@ int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { - Py_ssize_t size; - size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - return 0; + Py_ssize_t size; + size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + if (*end<1) + *end = 1; + if (*end>size) + *end = size; + return 0; } return -1; } @@ -1261,7 +1274,7 @@ self->encoding = self->object = self->start = self->end = self->reason = NULL; - n = PySequence_Size(args); + n = PySequence_Length(args); if (n == -1 && PyErr_Occurred()) { Py_DECREF(self); return NULL; @@ -1270,15 +1283,15 @@ return (PyObject *)self; if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &self->encoding, - objecttype, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { + &PyString_Type, &self->encoding, + objecttype, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { self->encoding = self->object = self->start = self->end = self->reason = NULL; Py_DECREF(self); - return NULL; + return NULL; } Py_INCREF(self->encoding); @@ -1294,14 +1307,14 @@ UnicodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) { if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &self->encoding, - objecttype, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { + &PyString_Type, &self->encoding, + objecttype, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { self->encoding = self->object = self->start = self->end = self->reason = NULL; - return -1; + return -1; } Py_INCREF(self->encoding); @@ -1316,23 +1329,30 @@ static void UnicodeError_dealloc(UnicodeErrorObject *self) { + Py_CLEAR(self->encoding); + Py_CLEAR(self->object); + Py_CLEAR(self->start); + Py_CLEAR(self->end); + Py_CLEAR(self->reason); BaseException_dealloc((BaseExceptionObject *)self); - Py_XDECREF(self->encoding); - Py_XDECREF(self->object); - Py_XDECREF(self->start); - Py_XDECREF(self->end); - Py_XDECREF(self->reason); } static PyMemberDef UnicodeError_members[] = { - {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), 0, "exception arguments"}, - {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, "exception message"}, - {"encoding", T_OBJECT, offsetof(UnicodeErrorObject, encoding), 0, "exception encoding"}, - {"object", T_OBJECT, offsetof(UnicodeErrorObject, object), 0, "exception object"}, - {"start", T_OBJECT, offsetof(UnicodeErrorObject, start), 0, "exception start"}, - {"end", T_OBJECT, offsetof(UnicodeErrorObject, end), 0, "exception end"}, - {"reason", T_OBJECT, offsetof(UnicodeErrorObject, reason), 0, "exception reason"}, - {NULL} /* Sentinel */ + {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), 0, + PyDoc_STR("exception arguments")}, + {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, + PyDoc_STR("exception message")}, + {"encoding", T_OBJECT, offsetof(UnicodeErrorObject, encoding), 0, + PyDoc_STR("exception encoding")}, + {"object", T_OBJECT, offsetof(UnicodeErrorObject, object), 0, + PyDoc_STR("exception object")}, + {"start", T_OBJECT, offsetof(UnicodeErrorObject, start), 0, + PyDoc_STR("exception start")}, + {"end", T_OBJECT, offsetof(UnicodeErrorObject, end), 0, + PyDoc_STR("exception end")}, + {"reason", T_OBJECT, offsetof(UnicodeErrorObject, reason), 0, + PyDoc_STR("exception reason")}, + {NULL} /* Sentinel */ }; @@ -1358,27 +1378,27 @@ Py_ssize_t end; if (PyUnicodeEncodeError_GetStart(self, &start)) - return NULL; + return NULL; if (PyUnicodeEncodeError_GetEnd(self, &end)) - return NULL; + return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - return PyString_FromFormat( - "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), - badchar_str, - start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) - ); + int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( + "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + badchar_str, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", @@ -1397,18 +1417,18 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - "Unicode encoding error.", + PyDoc_STR("Unicode encoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, 0, (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; PyObject * PyUnicodeEncodeError_Create( - const char *encoding, const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) + const char *encoding, const Py_UNICODE *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) { return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", - encoding, object, length, start, end, reason); + encoding, object, length, start, end, reason); } @@ -1434,30 +1454,30 @@ Py_ssize_t end; if (PyUnicodeDecodeError_GetStart(self, &start)) - return NULL; + return NULL; if (PyUnicodeDecodeError_GetEnd(self, &end)) - return NULL; + return NULL; if (end==start+1) { - /* FromFormat does not support %02x, so format that separately */ - char byte[4]; - PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(((UnicodeErrorObject *)self)->object)[start])&0xff); - return PyString_FromFormat( - "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), - byte, - start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) - ); + /* FromFormat does not support %02x, so format that separately */ + char byte[4]; + PyOS_snprintf(byte, sizeof(byte), "%02x", + ((int)PyString_AS_STRING(((UnicodeErrorObject *)self)->object)[start])&0xff); + return PyString_FromFormat( + "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + byte, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( - "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), - start, - (end-1), - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", + PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + start, + (end-1), + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) ); } @@ -1469,21 +1489,21 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - "Unicode decoding error.", + PyDoc_STR("Unicode decoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, 0, (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; PyObject * PyUnicodeDecodeError_Create( - const char *encoding, const char *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) + const char *encoding, const char *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) { - assert(length < INT_MAX); - assert(start < INT_MAX); - assert(end < INT_MAX); + assert(length < INT_MAX); + assert(start < INT_MAX); + assert(end < INT_MAX); return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns", - encoding, object, length, start, end, reason); + encoding, object, length, start, end, reason); } @@ -1503,7 +1523,7 @@ self->encoding = self->object = self->start = self->end = self->reason = NULL; - n = PySequence_Size(args); + n = PySequence_Length(args); if (n == -1 && PyErr_Occurred()) { Py_DECREF(self); return NULL; @@ -1512,13 +1532,13 @@ return (PyObject *)self; if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { + &PyUnicode_Type, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { self->object = self->start = self->end = self->reason = NULL; Py_DECREF(self); - return NULL; + return NULL; } self->encoding = Py_None; @@ -1535,12 +1555,12 @@ UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) { if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { + &PyUnicode_Type, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { self->object = self->start = self->end = self->reason = NULL; - return -1; + return -1; } self->encoding = Py_None; @@ -1561,32 +1581,32 @@ Py_ssize_t end; if (PyUnicodeTranslateError_GetStart(self, &start)) - return NULL; + return NULL; if (PyUnicodeTranslateError_GetEnd(self, &end)) - return NULL; + return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - return PyString_FromFormat( + int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( "can't translate character u'\\%s' in position %zd: %.400s", - badchar_str, - start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) - ); + badchar_str, + start, + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( - "can't translate characters in position %zd-%zd: %.400s", - start, - (end-1), - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + "can't translate characters in position %zd-%zd: %.400s", + start, + (end-1), + PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) ); } @@ -1598,18 +1618,18 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - "Unicode decoding error.", + PyDoc_STR("Unicode decoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, 0, (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; PyObject * PyUnicodeTranslateError_Create( - const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) + const Py_UNICODE *object, Py_ssize_t length, + Py_ssize_t start, Py_ssize_t end, const char *reason) { return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", - object, length, start, end, reason); + object, length, start, end, reason); } #endif @@ -1701,12 +1721,6 @@ /* - * OverflowWarning extends Warning - */ -SimpleExtendsException(PyExc_Warning, OverflowWarning, "Base class for warnings about numeric overflow. Won't exist in Python 2.5."); - - -/* * RuntimeWarning extends Warning */ SimpleExtendsException(PyExc_Warning, RuntimeWarning, "Base class for warnings about dubious runtime behavior."); @@ -1753,10 +1767,10 @@ bltinmod = PyImport_ImportModule("__builtin__"); if (bltinmod == NULL) - Py_FatalError("exceptions bootstrapping error."); + Py_FatalError("exceptions bootstrapping error."); bdict = PyModule_GetDict(bltinmod); if (bdict == NULL) - Py_FatalError("exceptions bootstrapping error."); + Py_FatalError("exceptions bootstrapping error."); PRE_INIT(BaseException) PRE_INIT(Exception) @@ -1808,7 +1822,6 @@ PRE_INIT(DeprecationWarning) PRE_INIT(PendingDeprecationWarning) PRE_INIT(SyntaxWarning) - PRE_INIT(OverflowWarning) PRE_INIT(RuntimeWarning) PRE_INIT(FutureWarning) PRE_INIT(ImportWarning) @@ -1866,14 +1879,13 @@ POST_INIT(DeprecationWarning) POST_INIT(PendingDeprecationWarning) POST_INIT(SyntaxWarning) - POST_INIT(OverflowWarning) POST_INIT(RuntimeWarning) POST_INIT(FutureWarning) POST_INIT(ImportWarning) PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL); if (!PyExc_MemoryErrorInst) - Py_FatalError("Cannot pre-allocate MemoryError instance\n"); + Py_FatalError("Cannot pre-allocate MemoryError instance\n"); Py_DECREF(bdict); Py_DECREF(bltinmod); From python-checkins at python.org Fri May 26 14:23:22 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 14:23:22 +0200 (CEST) Subject: [Python-checkins] r46302 - in python/trunk/Mac/OSX: BuildScript/build-installer.py Dist Extras.ReadMe.txt Extras.install.py IDLE/Makefile.in IDLE/idlemain.py README fixversions.py sample_sitecustomize.py Message-ID: <20060526122322.1497D1E400C@bag.python.org> Author: ronald.oussoren Date: Fri May 26 14:23:20 2006 New Revision: 46302 Removed: python/trunk/Mac/OSX/Dist/ python/trunk/Mac/OSX/fixversions.py python/trunk/Mac/OSX/sample_sitecustomize.py Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py python/trunk/Mac/OSX/Extras.ReadMe.txt python/trunk/Mac/OSX/Extras.install.py python/trunk/Mac/OSX/IDLE/Makefile.in python/trunk/Mac/OSX/IDLE/idlemain.py python/trunk/Mac/OSX/README Log: - Remove previous version of the binary distribution script for OSX - Some small bugfixes for the IDLE.app wrapper - Tweaks to build-installer to ensure that python gets build in the right way, including sqlite3. - Updated readme files Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py ============================================================================== --- python/trunk/Mac/OSX/BuildScript/build-installer.py (original) +++ python/trunk/Mac/OSX/BuildScript/build-installer.py Fri May 26 14:23:20 2006 @@ -591,10 +591,10 @@ version = getVersion() print "Running configure..." - runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L'%s/libraries/usr/local/lib OPT='-g -O3 -I'%s/libraries/usr/local/include 2>&1"%( + runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( shellQuote(os.path.join(SRCDIR, 'configure')), - shellQuote(SDKPATH), shellQuote(WORKDIR), - shellQuote(WORKDIR))) + shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], + shellQuote(WORKDIR)[1:-1])) print "Running make" runCommand("make") @@ -839,6 +839,7 @@ writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist')) for fn in os.listdir('resources'): + if fn == '.svn': continue if fn.endswith('.jpg'): shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn)) else: Modified: python/trunk/Mac/OSX/Extras.ReadMe.txt ============================================================================== --- python/trunk/Mac/OSX/Extras.ReadMe.txt (original) +++ python/trunk/Mac/OSX/Extras.ReadMe.txt Fri May 26 14:23:20 2006 @@ -3,12 +3,3 @@ You should be aware that these are not Macintosh-specific but are shared among Python on all platforms, so there are some that only run on Windows or Unix or another platform, and/or make little sense on a Macintosh. - -Some examples can be run from within the PythonIDE, but many will require -that you start them from the command line or with PythonLauncher. In the -latter case, you can supply any needed command line arguments by holding -the "alt" key while dragging the script to PythonLauncher, or while -double-clicking the script if PythonLauncher is set as the default application -to open Python scripts with. See "Changing the application that opens a file" -in Mac Help for information on making PythonLauncher the default application. - Modified: python/trunk/Mac/OSX/Extras.install.py ============================================================================== --- python/trunk/Mac/OSX/Extras.install.py (original) +++ python/trunk/Mac/OSX/Extras.install.py Fri May 26 14:23:20 2006 @@ -12,6 +12,7 @@ if name == 'CVS': return 0 if name == '.cvsignore': return 0 if name == '.DS_store': return 0 + if name == '.svn': return 0 if name.endswith('~'): return 0 if name.endswith('.BAK'): return 0 if name.endswith('.pyc'): return 0 Modified: python/trunk/Mac/OSX/IDLE/Makefile.in ============================================================================== --- python/trunk/Mac/OSX/IDLE/Makefile.in (original) +++ python/trunk/Mac/OSX/IDLE/Makefile.in Fri May 26 14:23:20 2006 @@ -38,7 +38,7 @@ $(srcdir)/../Icons/IDLE.icns $(srcdir)/idlemain.py \ $(srcdir)/../Icons/PythonSource.icns \ $(srcdir)/../Icons/PythonCompiled.icns - rm -fr PythonLauncher.app + rm -fr IDLE.app $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \ --builddir=. \ --name=IDLE \ Modified: python/trunk/Mac/OSX/IDLE/idlemain.py ============================================================================== --- python/trunk/Mac/OSX/IDLE/idlemain.py (original) +++ python/trunk/Mac/OSX/IDLE/idlemain.py Fri May 26 14:23:20 2006 @@ -7,7 +7,7 @@ # Change the current directory the user's home directory, that way we'll get # a more useful default location in the open/save dialogs. -os.chdir(os.expanduser('~')) +os.chdir(os.path.expanduser('~/Documents')) # Make sure sys.executable points to the python interpreter inside the Modified: python/trunk/Mac/OSX/README ============================================================================== --- python/trunk/Mac/OSX/README (original) +++ python/trunk/Mac/OSX/README Fri May 26 14:23:20 2006 @@ -1,29 +1,57 @@ +============ +MacOSX Notes +============ + +This document provides a quick overview of some Mac OS X specific features in +the Python distribution. + + +Building and using a universal binary of Python on Mac OS X +=========================================================== + +1. What is a universal binary +----------------------------- + +A universal binary build of Python contains object code for both PPC and i386 +and can therefore run at native speed on both classic powerpc based macs and +the newer intel based macs. + +2. How do I build a universal binary +------------------------------------ + +You can enable universal binaries by specifying the "--enable-universalsdk" +flag to configure:: + + $ ./configure --enable-universalsdk + $ make + $ make install + +This flag can be used a framework build of python, but also with a classic +unix build. Either way you will have to build python on Mac OS X 10.4 (or later) +with Xcode 2.1 (or later). You also have to install the 10.4u SDK when +installing Xcode. + + Building and using a framework-based Python on Mac OS X. --------------------------------------------------------- +======================================================== -This document provides a quick introduction to framework-based Python, its -advantages, and how to build it. 1. Why would I want a framework Python instead of a normal static Python? -------------------------------------------------------------------------- The main reason is because you want to create GUI programs in Python. With the -exception of X11/XDarwin-based GUI toolkits it appears that all GUI programs -need to be run from a fullblown MacOSX application (a ".app" bundle). +exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run +from a fullblown MacOSX application (a ".app" bundle). While it is technically possible to create a .app without using frameworks you will have to do the work yourself if you really want this. A second reason for using frameworks is that they put Python-related items in -only two places: /Library/Framework/Python.framework and /Applications/MacPython-2.3. -This simplifies matters for users installing Python from a binary distribution -if they want to get rid of it again. Moreover, due to the way frameworks work -a user without admin privileges can install a binary distribution in his or -her home directory without recompilation. - -Incidentally, the procedure described here is also the procedure that is -used to create the MacPython binary installer, so the information here -should theoretically allow you to rebuild that. +only two places: "/Library/Framework/Python.framework" and +"/Applications/MacPython 2.5". This simplifies matters for users installing +Python from a binary distribution if they want to get rid of it again. Moreover, +due to the way frameworks work a user without admin privileges can install a +binary distribution in his or her home directory without recompilation. 2. How does a framework Python differ from a normal static Python? ------------------------------------------------------------------ @@ -37,44 +65,40 @@ 3. Do I need extra packages? ---------------------------- -Yes, probably. If you want to be able to use the PythonIDE you will need to -get Waste, an all-singing-all-dancing TextEdit replacement, from -www.merzwaren.com. It will unpack into a folder named something like "Waste -2.1 Distribution". Make a symlink called "waste" to this folder, somewhere -beside your Python source distribution (it can be "../waste", "../../waste", -etc). - -If you want Tkinter support you need to get the OSX AquaTk distribution. If +Yes, probably. If you want Tkinter support you need to get the OSX AquaTk +distribution, this is installed by default on Mac OS X 10.4 or later. If you want wxPython you need to get that. If you want Cocoa you need to get -pyobjc. Because all these are currently in a state of flux please refer to -http://www.cwi.nl/~jack/macpython.html, which should contain pointers to more -information. +PyObjC. 4. How do I build a framework Python? ------------------------------------- This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -/Applications/MacPython-2.3, and a hidden helper application Python.app inside the -Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. -In addition it has a target "installmacsubtree" that installs the relevant -portions of the Mac subtree into the Python.framework. +"/Applications/MacPython 2.3", and a hidden helper application Python.app +inside the Python.framework, and unix tools "python" and "pythonw" into +/usr/local/bin. In addition it has a target "installmacsubtree" that installs +the relevant portions of the Mac subtree into the Python.framework. It is normally invoked indirectly through the main Makefile, as the last step in the sequence -1. ./configure --enable-framework -2. make -3. make frameworkinstall + + 1. ./configure --enable-framework + + 2. make + + 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/Python and the unix tools in /usr/local/bin. +the applications in /Applications/MacPython 2.5 and the unix tools in +/usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will then -also be deposited in $HOME. This is sub-optimal for the unix tools, which you -would want in $HOME/bin, but there is no easy way to fix this right now. +The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will +then also be deposited in $HOME. This is sub-optimal for the unix tools, which +you would want in $HOME/bin, but there is no easy way to fix this right now. Note that there are no references to the actual locations in the code or resource files, so you are free to move things around afterwards. For example, @@ -89,18 +113,13 @@ normal frameworkinstall which installs the Demo and Tools directories into /Applications/MacPython-2.3, this is useful for binary distributions. -If you want to run the Makefile here directly, in stead of through the main -Makefile, you will have to pass various variable-assignments. Read the -beginning of the Makefile for details. +What do all these programs do? +=============================== - -5. What do all these programs do? ---------------------------------- - -PythonIDE.app is an integrated development environment for Python: editor, +"IDLE.app" is an integrated development environment for Python: editor, debugger, etc. -PythonLauncher.app is a helper application that will handle things when you +"PythonLauncher.app" is a helper application that will handle things when you double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal window and runs the scripts with the normal command-line Python. For the latter it runs the script in the Python.app interpreter so the script can do @@ -108,7 +127,7 @@ script to set runtime options. These options can be set once and for all through PythonLauncher's preferences dialog. -BuildApplet.app creates an applet from a Python script. Drop the script on it +"BuildApplet.app" creates an applet from a Python script. Drop the script on it and out comes a full-featured MacOS application. There is much more to this, to be supplied later. Some useful (but outdated) info can be found in Mac/Demo. @@ -116,43 +135,27 @@ The commandline scripts /usr/local/bin/python and pythonw can be used to run non-GUI and GUI python scripts from the command line, respectively. -6. How do I create a binary distribution? ------------------------------------------ +How do I create a binary distribution? +====================================== -First go to Mac/OSX and run "python fixversions.py -a" with the Python -you are going to distribute. This will fix the version numbers and copyright -strings in the various Info.plist files. - -Go to the Mac/OSX/Dist directory. There you find a script "build" that -does all the work: it configures and builds a framework Python, installs -it, creates the installer package file and packs this in a DMG image. +Go to the directory "Mac/OSX/BuildScript". There you'll find a script +"build-installer.py" that does all the work. This will download and build +a number of 3th-party libaries, configures and builds a framework Python, +installs it, creates the installer pacakge files and then packs this in a +DMG image. + +The script will build a universal binary, you'll therefore have to run this +script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed. All of this is normally done completely isolated in /tmp/_py, so it does not use your normal build directory nor does it install into /. -Because the build script locates the Python source tree relative to its own -pathname you may have to run it with a full pathname. If you are debugging your -install you can pass one argument: the pathname where the build directory -is located (i.e. where configure and make will be run), then this directory -will be saved between runs of the build script. Do *not* specify your normal -build directory here. - -build will ask you whether you have updated the readme file, and it will offer -to include the full documentation in the installer. That option has not -been used for a while, and it may not work. - -If you need to execute code on the client machine after installing Python -you can add this to resources/postflight. If you need to do even stranger things -you have to read Apple's documentation on PackageMaker and read the source -of Mac/scripts/buildpkg.py. - -7. Odds and ends. ------------------ - -The PythonLauncher is actually an Objective C Cocoa app built with Project -Builder. It could be a Python program, except for the fact that pyobjc is not -a part of the core distribution, and is not completely finished yet as of this -writing. +Because of the way the script locates the files it needs you have to run it +from within the BuildScript directory. The script accepts a number of +command-line arguments, run it with --help for more information. + +Odds and ends +============= Something to take note of is that the ".rsrc" files in the distribution are not actually resource files, they're AppleSingle encoded resource files. The @@ -161,3 +164,4 @@ files. Jack Jansen, Jack.Jansen at cwi.nl, 15-Jul-2004. + Ronald Oussoren, RonaldOussoren at mac.com, 26-May-2006 Deleted: /python/trunk/Mac/OSX/fixversions.py ============================================================================== --- /python/trunk/Mac/OSX/fixversions.py Fri May 26 14:23:20 2006 +++ (empty file) @@ -1,69 +0,0 @@ -"""fixversions - Fix version numbers in .plist files to match current -python version and date""" - -import sys -import os -import time -import plistlib - -SHORTVERSION = "%d.%d" % (sys.version_info[0], sys.version_info[1]) -if sys.version_info[2]: - SHORTVERSION = SHORTVERSION + ".%d" % sys.version_info[2] -if sys.version_info[3] != 'final': - SHORTVERSION = SHORTVERSION + "%s%d" % (sys.version_info[3], sys.version_info[4]) - -COPYRIGHT = "(c) %d Python Software Foundation." % time.gmtime()[0] - -LONGVERSION = SHORTVERSION + ", " + COPYRIGHT - -def fix(file): - plist = plistlib.Plist.fromFile(file) - changed = False - if plist.has_key("CFBundleGetInfoString") and \ - plist["CFBundleGetInfoString"] != LONGVERSION: - plist["CFBundleGetInfoString"] = LONGVERSION - changed = True - if plist.has_key("CFBundleLongVersionString") and \ - plist["CFBundleLongVersionString"] != LONGVERSION: - plist["CFBundleLongVersionString"] = LONGVERSION - changed = True - if plist.has_key("NSHumanReadableCopyright") and \ - plist["NSHumanReadableCopyright"] != COPYRIGHT: - plist["NSHumanReadableCopyright"] = COPYRIGHT - changed = True - if plist.has_key("CFBundleVersion") and \ - plist["CFBundleVersion"] != SHORTVERSION: - plist["CFBundleVersion"] = SHORTVERSION - changed = True - if plist.has_key("CFBundleShortVersionString") and \ - plist["CFBundleShortVersionString"] != SHORTVERSION: - plist["CFBundleShortVersionString"] = SHORTVERSION - changed = True - if changed: - os.rename(file, file + '~') - plist.write(file) - -def main(): - if len(sys.argv) < 2: - print "Usage: %s plistfile ..." % sys.argv[0] - print "or: %s -a fix standard Python plist files" - sys.exit(1) - if sys.argv[1] == "-a": - files = [ - "../OSXResources/app/Info.plist", - "../OSXResources/framework/version.plist", - "../Tools/IDE/PackageManager.plist", - "../Tools/IDE/PythonIDE.plist", - "../scripts/BuildApplet.plist" - ] - if not os.path.exists(files[0]): - print "%s -a must be run from Mac/OSX directory" - sys.exit(1) - else: - files = sys.argv[1:] - for file in files: - fix(file) - sys.exit(0) - -if __name__ == "__main__": - main() Deleted: /python/trunk/Mac/OSX/sample_sitecustomize.py ============================================================================== --- /python/trunk/Mac/OSX/sample_sitecustomize.py Fri May 26 14:23:20 2006 +++ (empty file) @@ -1,6 +0,0 @@ -import sys -import os -_maclib = os.path.join(sys.prefix, 'Mac', 'Lib') -_scriptlib = os.path.join(_maclib, 'lib-scriptpackages') -sys.path.append(_maclib) -sys.path.append(_scriptlib) From python-checkins at python.org Fri May 26 14:23:23 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 14:23:23 +0200 (CEST) Subject: [Python-checkins] r46303 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060526122323.E95F31E4010@bag.python.org> Author: richard.jones Date: Fri May 26 14:23:23 2006 New Revision: 46303 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: OverflowWarning has gone away Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 14:23:23 2006 @@ -81,17 +81,6 @@ except NameError: pass r(OverflowError) -# XXX -# Obscure: in 2.2 and 2.3, this test relied on changing OverflowWarning -# into an error, in order to trigger OverflowError. In 2.4, OverflowWarning -# should no longer be generated, so the focus of the test shifts to showing -# that OverflowError *isn't* generated. OverflowWarning should be gone -# in Python 2.5, and then the filterwarnings() call, and this comment, -# should go away. -warnings.filterwarnings("error", "", OverflowWarning, __name__) -x = 1 -for dummy in range(128): - x += x # this simply shouldn't blow up r(RuntimeError) print '(not used any more?)' From python-checkins at python.org Fri May 26 14:24:43 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 14:24:43 +0200 (CEST) Subject: [Python-checkins] r46304 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526122443.3B4EC1E400C@bag.python.org> Author: richard.jones Date: Fri May 26 14:24:42 2006 New Revision: 46304 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: fix num of args issue Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 14:24:42 2006 @@ -417,6 +417,10 @@ { PyObject *myerrno, *strerror, *filename; PyObject *subslice = NULL; + + if (PySequence_Length(args) <= 1) { + return 0; + } if (!PyArg_ParseTuple(args, "OO|O", &myerrno, &strerror, &filename)) { return -1; @@ -472,6 +476,7 @@ EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init(self, args, kwds) == -1) return -1; return _EnvironmentError_init(self, args, kwds); } @@ -830,6 +835,7 @@ static int SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init(self, args, kwds) == -1) return -1; return _SyntaxError_init(self, args, kwds); } @@ -1006,14 +1012,14 @@ #ifdef Py_USING_UNICODE typedef struct { - PyObject_HEAD - PyObject *args; - PyObject *message; - PyObject *encoding; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; + PyObject_HEAD + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + PyObject *start; + PyObject *end; + PyObject *reason; } UnicodeErrorObject; static @@ -1368,6 +1374,7 @@ static int UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init(self, args, kwds) == -1) return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyUnicode_Type); } @@ -1444,6 +1451,7 @@ static int UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init(self, args, kwds) == -1) return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyString_Type); } @@ -1554,13 +1562,15 @@ static int UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init(self, args, kwds) == -1) return -1; + if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { + &PyUnicode_Type, &self->object, + &PyInt_Type, &self->start, + &PyInt_Type, &self->end, + &PyString_Type, &self->reason)) { self->object = self->start = self->end = self->reason = NULL; - return -1; + return -1; } self->encoding = Py_None; From python-checkins at python.org Fri May 26 14:26:22 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 14:26:22 +0200 (CEST) Subject: [Python-checkins] r46305 - python/trunk/Lib/test/test_struct.py Message-ID: <20060526122622.30C651E400C@bag.python.org> Author: tim.peters Date: Fri May 26 14:26:21 2006 New Revision: 46305 Modified: python/trunk/Lib/test/test_struct.py Log: Whitespace normalization. Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Fri May 26 14:26:21 2006 @@ -509,7 +509,6 @@ def test_main(): test.test_support.run_unittest(PackBufferTestCase) - + if __name__ == "__main__": test_main() - From python-checkins at python.org Fri May 26 14:27:39 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 14:27:39 +0200 (CEST) Subject: [Python-checkins] r46306 - in python: bippolito-newstruct branches/bippolito-newstruct Message-ID: <20060526122739.3F8AB1E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 14:27:38 2006 New Revision: 46306 Added: python/branches/bippolito-newstruct/ - copied from r46305, python/bippolito-newstruct/ Removed: python/bippolito-newstruct/ Log: move branch to the right place From python-checkins at python.org Fri May 26 14:28:15 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 14:28:15 +0200 (CEST) Subject: [Python-checkins] r46307 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526122815.ED1181E400C@bag.python.org> Author: andrew.dalke Date: Fri May 26 14:28:15 2006 New Revision: 46307 Modified: python/trunk/Lib/test/string_tests.py Log: I like tests. The new split functions use a preallocated list. Added tests which exceed the preallocation size, to exercise list appends/resizes. Also added more edge case tests. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 14:28:15 2006 @@ -243,6 +243,8 @@ self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, + sys.maxint-1) self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) @@ -253,27 +255,53 @@ self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split') + aaa = ' a '*20 + self.checkequal(['a']*20, aaa, 'split') + self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1) + self.checkequal(['a']*19 + ["a "], aaa, 'split', None, 19) # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') + self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1) self.checkequal(['a', 'b', 'c|d'], 'a|b|c|d', 'split', '|', 2) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', + sys.maxint-2) self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2) self.checkequal(['endcase ', ''], 'endcase |', 'split', '|') + self.checkequal(['', ' startcase'], '| startcase', 'split', '|') + self.checkequal(['', 'bothcase', ''], '|bothcase|', 'split', '|') self.checkequal(['a', '', 'b\x00c\x00d'], 'a\x00\x00b\x00c\x00d', 'split', '\x00', 2) + self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|') + self.checkequal(['a']*15 +['a|a|a|a|a'], + ('a|'*20)[:-1], 'split', '|', 15) + # by string self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//') self.checkequal(['a', 'b//c//d'], 'a//b//c//d', 'split', '//', 1) self.checkequal(['a', 'b', 'c//d'], 'a//b//c//d', 'split', '//', 2) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', + sys.maxint-10) self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0) self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2) self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') + self.checkequal(['', ''], 'aaa', 'split', 'aaa') + self.checkequal(['aaa'], 'aaa', 'split', 'aaa', 0) + self.checkequal(['ab', 'ab'], 'abbaab', 'split', 'ba') + self.checkequal(['aaaa'], 'aaaa', 'split', 'aab') + self.checkequal([''], '', 'split', 'aaa') + self.checkequal(['aa'], 'aa', 'split', 'aaa') + + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH') + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19) + self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4], + 'split', 'BLAH', 18) # mixed use of str and unicode self.checkequal([u'a', u'b', u'c d'], 'a b c d', 'split', u' ', 2) @@ -281,6 +309,10 @@ # argument type self.checkraises(TypeError, 'hello', 'split', 42, 42, 42) + # null case + self.checkraises(ValueError, 'hello', 'split', '') + self.checkraises(ValueError, 'hello', 'split', '', 0) + def test_rsplit(self): self.checkequal(['this', 'is', 'the', 'rsplit', 'function'], 'this is the rsplit function', 'rsplit') From tim.peters at gmail.com Fri May 26 14:28:34 2006 From: tim.peters at gmail.com (Tim Peters) Date: Fri, 26 May 2006 12:28:34 +0000 Subject: [Python-checkins] r46303 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py In-Reply-To: <20060526122323.E95F31E4010@bag.python.org> References: <20060526122323.E95F31E4010@bag.python.org> Message-ID: <1f7befae0605260528n2433e653mfd6cefb6f7d6c1b2@mail.gmail.com> > Author: richard.jones > Date: Fri May 26 14:23:23 2006 > New Revision: 46303 > > Modified: > python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > Log: > OverflowWarning has gone away > > Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py > ============================================================================== > --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) > +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 14:23:23 2006 > @@ -81,17 +81,6 @@ > except NameError: pass > > r(OverflowError) > -# XXX > -# Obscure: in 2.2 and 2.3, this test relied on changing OverflowWarning > -# into an error, in order to trigger OverflowError. In 2.4, OverflowWarning > -# should no longer be generated, so the focus of the test shifts to showing > -# that OverflowError *isn't* generated. OverflowWarning should be gone > -# in Python 2.5, and then the filterwarnings() call, and this comment, > -# should go away. > -warnings.filterwarnings("error", "", OverflowWarning, __name__) > -x = 1 > -for dummy in range(128): > - x += x # this simply shouldn't blow up The code after warnings.filterwarnings should be restored: we're still testing that OverflowError _isn't_ raised. From python-checkins at python.org Fri May 26 14:31:03 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 14:31:03 +0200 (CEST) Subject: [Python-checkins] r46308 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526123103.E99B21E400C@bag.python.org> Author: andrew.dalke Date: Fri May 26 14:31:00 2006 New Revision: 46308 Modified: python/trunk/Lib/test/string_tests.py Log: Test cases for off-by-one errors in string split with multicharacter pattern. Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 14:31:00 2006 @@ -297,6 +297,8 @@ self.checkequal(['aaaa'], 'aaaa', 'split', 'aab') self.checkequal([''], '', 'split', 'aaa') self.checkequal(['aa'], 'aa', 'split', 'aaa') + self.checkequal(['A', 'bobb'], 'Abbobbbobb', 'split', 'bbobb') + self.checkequal(['A', 'B', ''], 'AbbobbBbbobb', 'split', 'bbobb') self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH') self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19) From python-checkins at python.org Fri May 26 14:31:21 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 14:31:21 +0200 (CEST) Subject: [Python-checkins] r46309 - python/trunk/Mac/OSX/BuildScript/build-installer.py Message-ID: <20060526123121.5DD5D1E400C@bag.python.org> Author: tim.peters Date: Fri May 26 14:31:20 2006 New Revision: 46309 Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py Log: Whitespace normalization. Modified: python/trunk/Mac/OSX/BuildScript/build-installer.py ============================================================================== --- python/trunk/Mac/OSX/BuildScript/build-installer.py (original) +++ python/trunk/Mac/OSX/BuildScript/build-installer.py Fri May 26 14:31:20 2006 @@ -593,7 +593,7 @@ print "Running configure..." runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( shellQuote(os.path.join(SRCDIR, 'configure')), - shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], + shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) print "Running make" From python-checkins at python.org Fri May 26 14:34:20 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 14:34:20 +0200 (CEST) Subject: [Python-checkins] r46310 - in python/branches/sreifschneider-newnewexcept: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060526123420.069461E400C@bag.python.org> Author: richard.jones Date: Fri May 26 14:34:18 2006 New Revision: 46310 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: fix Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 14:34:18 2006 @@ -25,7 +25,7 @@ raise exc("spam") except exc, err: buf = str(err) - print buf +# print buf def r(thing): test_raise_catch(thing) @@ -269,6 +269,7 @@ for args in exceptionList: expected = args[-1] + print args try: if len(args) == 2: raise args[0] else: raise apply(args[0], args[1]) Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 14:34:18 2006 @@ -415,7 +415,7 @@ _EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { - PyObject *myerrno, *strerror, *filename; + PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL; PyObject *subslice = NULL; if (PySequence_Length(args) <= 1) { @@ -425,7 +425,6 @@ if (!PyArg_ParseTuple(args, "OO|O", &myerrno, &strerror, &filename)) { return -1; } - Py_DECREF(self->myerrno); /* replacing */ self->myerrno = myerrno; Py_INCREF(self->myerrno); @@ -476,7 +475,8 @@ EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init(self, args, kwds) == -1) return -1; + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; return _EnvironmentError_init(self, args, kwds); } @@ -835,7 +835,8 @@ static int SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init(self, args, kwds) == -1) return -1; + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; return _SyntaxError_init(self, args, kwds); } @@ -1374,7 +1375,8 @@ static int UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init(self, args, kwds) == -1) return -1; + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyUnicode_Type); } @@ -1451,7 +1453,8 @@ static int UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init(self, args, kwds) == -1) return -1; + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyString_Type); } @@ -1562,7 +1565,8 @@ static int UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init(self, args, kwds) == -1) return -1; + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; if (!PyArg_ParseTuple(args, "O!O!O!O!", &PyUnicode_Type, &self->object, From python-checkins at python.org Fri May 26 14:34:35 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 14:34:35 +0200 (CEST) Subject: [Python-checkins] r46311 - in python/branches/blais-bytebuf: Doc/lib/libstdtypes.tex Include/pyport.h Lib/test/test_socket.py Python/ceval.c Message-ID: <20060526123435.A7DA81E400C@bag.python.org> Author: martin.blais Date: Fri May 26 14:34:33 2006 New Revision: 46311 Modified: python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex python/branches/blais-bytebuf/Include/pyport.h python/branches/blais-bytebuf/Lib/test/test_socket.py python/branches/blais-bytebuf/Python/ceval.c Log: Updated blais-bytebuf to new Modified: python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex (original) +++ python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex Fri May 26 14:34:33 2006 @@ -728,7 +728,7 @@ \end{methoddesc} \begin{methoddesc}[string]{partition}{sep} -Splits the string at the first occurence of \var{sep}, and return +Split the string at the first occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by Modified: python/branches/blais-bytebuf/Include/pyport.h ============================================================================== --- python/branches/blais-bytebuf/Include/pyport.h (original) +++ python/branches/blais-bytebuf/Include/pyport.h Fri May 26 14:34:33 2006 @@ -141,6 +141,10 @@ * convention for functions that are local to a given module. It also enables * inlining, where suitable. * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, a more + * "aggressive" inlining is enabled. This may lead to code bloat, and may + * slow things down for those reasons. Use with care. + * * NOTE: You can only use this for functions that are entirely local to a * module; functions that are exported via method tables, callbacks, etc, * should keep using static. @@ -149,6 +153,10 @@ #undef USE_INLINE /* XXX - set via configure? */ #if defined(_MSC_VER) +#if defined(PY_LOCAL_AGGRESSIVE) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif /* ignore warnings if the compiler decides not to inline a function */ #pragma warning(disable: 4710) /* fastest possible local call under MSVC */ Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py ============================================================================== --- python/branches/blais-bytebuf/Lib/test/test_socket.py (original) +++ python/branches/blais-bytebuf/Lib/test/test_socket.py Fri May 26 14:34:33 2006 @@ -10,7 +10,6 @@ import Queue import sys import array -import hotbuf from weakref import proxy PORT = 50007 @@ -853,7 +852,6 @@ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.assertRaises(socket.error, s.bind, address) - class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). @@ -861,117 +859,31 @@ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) - def testRecv(self): - # Receive into the buffer of an array class. + def testRecvBuf(self): buf = array.array('c', ' '*1024) nbytes = self.cli_conn.recv_buf(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) - def _testRecv(self): - # Send using a read-only buffer. + def _testRecvBuf(self): buf = buffer(MSG) self.serv_conn.send(buf) - def testRecv2(self): - # Receive into a hotbuf. - buf = hotbuf.hotbuf(1024) - nbytes = self.cli_conn.recv_buf(buf) - self.assertEqual(nbytes, len(MSG)) - msg = str(buf)[:len(MSG)] - self.assertEqual(msg, MSG) - - def _testRecv2(self): - # Send using a hotbuf. -## FIXME: todo -## buf = hotbuf.hotbuf(MSG) - self.serv_conn.send(MSG) - -## def testOverFlowRecv(self): -## # Testing receive in chunks over TCP -## seg1 = self.cli_conn.recv(len(MSG) - 3) -## seg2 = self.cli_conn.recv(1024) -## msg = seg1 + seg2 -## self.assertEqual(msg, MSG) - -## def _testOverFlowRecv(self): -## self.serv_conn.send(MSG) - - def testRecvFrom(self): - # Testing large recvfrom() over TCP + def testRecvFromBuf(self): buf = array.array('c', ' '*1024) nbytes, addr = self.cli_conn.recvfrom_buf(buf) self.assertEqual(nbytes, len(MSG)) msg = buf.tostring()[:len(MSG)] self.assertEqual(msg, MSG) - def _testRecvFrom(self): + def _testRecvFromBuf(self): buf = buffer(MSG) self.serv_conn.send(buf) - def testRecvFrom2(self): - # Testing large recvfrom() over TCP - buf = hotbuf.hotbuf(1024) - nbytes, addr = self.cli_conn.recvfrom_buf(buf) - self.assertEqual(nbytes, len(MSG)) - msg = str(buf)[:len(MSG)] - self.assertEqual(msg, MSG) - - def _testRecvFrom2(self): - # Send using a hotbuf. -## FIXME: todo -## buf = hotbuf.hotbuf(MSG) - self.serv_conn.send(MSG) - -## def testOverFlowRecvFrom(self): -## # Testing recvfrom() in chunks over TCP -## seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) -## seg2, addr = self.cli_conn.recvfrom(1024) -## msg = seg1 + seg2 -## self.assertEqual(msg, MSG) - -## def _testOverFlowRecvFrom(self): -## self.serv_conn.send(MSG) - -## def testSendAll(self): -## # Testing sendall() with a 2048 byte string over TCP -## msg = '' -## while 1: -## read = self.cli_conn.recv(1024) -## if not read: -## break -## msg += read -## self.assertEqual(msg, 'f' * 2048) - -## def _testSendAll(self): -## big_chunk = 'f' * 2048 -## self.serv_conn.sendall(big_chunk) - -## def testFromFd(self): -## # Testing fromfd() -## if not hasattr(socket, "fromfd"): -## return # On Windows, this doesn't exist -## fd = self.cli_conn.fileno() -## sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) -## msg = sock.recv(1024) -## self.assertEqual(msg, MSG) - -## def _testFromFd(self): -## self.serv_conn.send(MSG) - -## def testShutdown(self): -## # Testing shutdown() -## msg = self.cli_conn.recv(1024) -## self.assertEqual(msg, MSG) - -## def _testShutdown(self): -## self.serv_conn.send(MSG) -## self.serv_conn.shutdown(2) - - def test_main(): - tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions] + tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions, + BufferIOTest] if sys.platform != 'mac': tests.extend([ BasicUDPTest, UDPTimeoutTest ]) @@ -988,9 +900,6 @@ tests.append(TestLinuxAbstractNamespace) test_support.run_unittest(*tests) -def test_main2(): - tests = [BufferIOTest] - test_support.run_unittest(*tests) - if __name__ == "__main__": - test_main2() + test_main() + Modified: python/branches/blais-bytebuf/Python/ceval.c ============================================================================== --- python/branches/blais-bytebuf/Python/ceval.c (original) +++ python/branches/blais-bytebuf/Python/ceval.c Fri May 26 14:34:33 2006 @@ -6,6 +6,9 @@ XXX document it! */ +/* enable more aggressive local inlining (platform dependent) */ +#define PY_LOCAL_AGGRESSIVE + #include "Python.h" #include "code.h" @@ -16,6 +19,11 @@ #include +#if defined(_MSC_VER) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif + #ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -83,21 +91,21 @@ /* Forward declarations */ #ifdef WITH_TSC -Py_LOCAL(PyObject *)call_function(PyObject ***, int, uint64*, uint64*); +Py_LOCAL(PyObject *) call_function(PyObject ***, int, uint64*, uint64*); #else -Py_LOCAL(PyObject *)call_function(PyObject ***, int); +Py_LOCAL(PyObject *) call_function(PyObject ***, int); #endif -Py_LOCAL(PyObject *)fast_function(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *)do_call(PyObject *, PyObject ***, int, int); -Py_LOCAL(PyObject *)ext_do_call(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *)update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -Py_LOCAL(PyObject *)update_star_args(int, int, PyObject *, PyObject ***); -Py_LOCAL(PyObject *)load_args(PyObject ***, int); +Py_LOCAL(PyObject *) fast_function(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *) do_call(PyObject *, PyObject ***, int, int); +Py_LOCAL(PyObject *) ext_do_call(PyObject *, PyObject ***, int, int, int); +Py_LOCAL(PyObject *) update_keyword_args(PyObject *, int, PyObject ***,PyObject *); +Py_LOCAL(PyObject *) update_star_args(int, int, PyObject *, PyObject ***); +Py_LOCAL(PyObject *) load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 #ifdef LLTRACE -Py_LOCAL(int) lltrace; +static int lltrace; Py_LOCAL(int) prtrace(PyObject *, char *); #endif Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *, @@ -108,19 +116,19 @@ Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *, PyFrameObject *, int *, int *, int *); -Py_LOCAL(PyObject *)apply_slice(PyObject *, PyObject *, PyObject *); +Py_LOCAL(PyObject *) apply_slice(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) assign_slice(PyObject *, PyObject *, PyObject *, PyObject *); -Py_LOCAL(PyObject *)cmp_outcome(int, PyObject *, PyObject *); -Py_LOCAL(PyObject *)import_from(PyObject *, PyObject *); +Py_LOCAL(PyObject *) cmp_outcome(int, PyObject *, PyObject *); +Py_LOCAL(PyObject *) import_from(PyObject *, PyObject *); Py_LOCAL(int) import_all_from(PyObject *, PyObject *); -Py_LOCAL(PyObject *)build_class(PyObject *, PyObject *, PyObject *); +Py_LOCAL(PyObject *) build_class(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) exec_statement(PyFrameObject *, PyObject *, PyObject *, PyObject *); Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); Py_LOCAL(void) reset_exc_info(PyThreadState *); Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *); -Py_LOCAL(PyObject *)string_concatenate(PyObject *, PyObject *, +Py_LOCAL(PyObject *) string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ @@ -476,7 +484,7 @@ WHY_YIELD = 0x0040 /* 'yield' operator */ }; -static enum why_code do_raise(PyObject *, PyObject *, PyObject *); +Py_LOCAL(enum why_code) do_raise(PyObject *, PyObject *, PyObject *); Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **); /* for manipulating the thread switch and periodic "stuff" - used to be @@ -2971,7 +2979,7 @@ /* Logic for the raise statement (too complicated for inlining). This *consumes* a reference count to each of its arguments. */ -static enum why_code +Py_LOCAL(enum why_code) do_raise(PyObject *type, PyObject *value, PyObject *tb) { if (type == NULL) { From python-checkins at python.org Fri May 26 14:37:16 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 14:37:16 +0200 (CEST) Subject: [Python-checkins] r46312 - python/branches/blais-bytebuf sandbox/trunk/hotbuf Message-ID: <20060526123716.0FFDA1E400C@bag.python.org> Author: martin.blais Date: Fri May 26 14:37:15 2006 New Revision: 46312 Added: sandbox/trunk/hotbuf/ - copied from r46311, python/branches/blais-bytebuf/ Removed: python/branches/blais-bytebuf/ Log: Moving the hotbuffer branch (for fast network I/O) into the sandbox. From python-checkins at python.org Fri May 26 14:39:49 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 14:39:49 +0200 (CEST) Subject: [Python-checkins] r46313 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060526123949.DBE0F1E400C@bag.python.org> Author: andrew.kuchling Date: Fri May 26 14:39:48 2006 New Revision: 46313 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add str.partition() Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri May 26 14:39:48 2006 @@ -1042,6 +1042,27 @@ print d[3], d[4] # Prints 0, 0 \end{verbatim} +\item Both 8-bit and Unicode strings have a new \method{partition(sep)} method. +The \method{find(S)} method is often used to get an index which is +then used to slice the string and obtain the pieces that are before +and after the separator. \method{partition(sep)} condenses this +pattern into a single method call that returns a 3-tuple containing +the substring before the separator, the separator itself, and the +substring after the separator. If the separator isn't found, the +first element of the tuple is the entire string and the other two +elements are empty. Some examples: + +\begin{verbatim} +>>> ('http://www.python.org').partition('://') +('http', '://', 'www.python.org') +>>> (u'Subject: a quick question').partition(':') +(u'Subject', u':', u' a quick question') +>>> ('file:/usr/share/doc/index.html').partition('://') +('file:/usr/share/doc/index.html', '', '') +\end{verbatim} + +(Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) + \item The \function{min()} and \function{max()} built-in functions gained a \code{key} keyword parameter analogous to the \code{key} argument for \method{sort()}. This parameter supplies a function that From python-checkins at python.org Fri May 26 14:52:54 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 14:52:54 +0200 (CEST) Subject: [Python-checkins] r46314 - python/trunk/Lib/binhex.py Message-ID: <20060526125254.3A0B31E401F@bag.python.org> Author: bob.ippolito Date: Fri May 26 14:52:53 2006 New Revision: 46314 Modified: python/trunk/Lib/binhex.py Log: quick hack to fix busted binhex test Modified: python/trunk/Lib/binhex.py ============================================================================== --- python/trunk/Lib/binhex.py (original) +++ python/trunk/Lib/binhex.py Fri May 26 14:52:53 2006 @@ -217,7 +217,11 @@ def _writecrc(self): # XXXX Should this be here?? # self.crc = binascii.crc_hqx('\0\0', self.crc) - self.ofp.write(struct.pack('>h', self.crc)) + if self.crc < 0: + fmt = '>h' + else: + fmt = '>H' + self.ofp.write(struct.pack(fmt, self.crc)) self.crc = 0 def write(self, data): From amk at amk.ca Fri May 26 15:09:16 2006 From: amk at amk.ca (A.M. Kuchling) Date: Fri, 26 May 2006 09:09:16 -0400 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: <20060526120329.9A9671E400C@bag.python.org> References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: <20060526130916.GB27892@rogue.amk.ca> On Fri, May 26, 2006 at 02:03:29PM +0200, martin.blais wrote: > python/trunk/Lib/socket.py > python/trunk/Lib/test/test_socket.py > python/trunk/Lib/test/test_struct.py > python/trunk/Modules/_struct.c > python/trunk/Modules/arraymodule.c > python/trunk/Modules/socketmodule.c > Log: > Support for buffer protocol for socket and struct. Please don't forget to document these new methods in libsocket.tex and libstruct.tex. --amk From python-checkins at python.org Fri May 26 15:04:31 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 15:04:31 +0200 (CEST) Subject: [Python-checkins] r46315 - in python/branches/sreifschneider-newnewexcept: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060526130431.D27F71E400C@bag.python.org> Author: richard.jones Date: Fri May 26 15:04:30 2006 New Revision: 46315 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: may add arbitrary attrs to exceptions now Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 15:04:30 2006 @@ -269,7 +269,6 @@ for args in exceptionList: expected = args[-1] - print args try: if len(args) == 2: raise args[0] else: raise apply(args[0], args[1]) Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 15:04:30 2006 @@ -8,6 +8,7 @@ */ typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; } BaseExceptionObject; @@ -53,6 +54,12 @@ self->args = self->message = NULL; + self->dict = PyDict_New(); + if (self->dict == NULL) { + Py_DECREF(self); + return NULL; + } + if (_BaseException_init(self, args, kwds) == -1) { Py_DECREF(self); return NULL; @@ -70,6 +77,7 @@ static void BaseException_dealloc(BaseExceptionObject *self) { + Py_CLEAR(self->dict); Py_CLEAR(self->args); Py_CLEAR(self->message); self->ob_type->tp_free((PyObject *)self); @@ -186,44 +194,44 @@ static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "exceptions.BaseException", /*tp_name*/ - sizeof(BaseExceptionObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ + 0, /*ob_size*/ + "exceptions.BaseException", /*tp_name*/ + sizeof(BaseExceptionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ (destructor)BaseException_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /* tp_compare; */ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /* tp_compare; */ (reprfunc)BaseException_repr, /*tp_repr*/ - 0, /*tp_as_number*/ + 0, /*tp_as_number*/ &BaseException_as_sequence, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ (reprfunc)BaseException_str, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro*/ + 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - BaseException_methods, /* tp_methods */ - BaseException_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - BaseException_new, /* tp_new */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BaseException_methods, /* tp_methods */ + BaseException_members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + offsetof(BaseExceptionObject, dict), /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + BaseException_new, /* tp_new */ }; /* the CPython API expects exceptions to be (PyObject *) - both a hold-over from the previous implmentation and also allowing Python objects to be used @@ -240,7 +248,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, (initproc)BaseException_init, 0, BaseException_new,\ + 0, 0, 0, offsetof(BaseExceptionObject, dict), \ + (initproc)BaseException_init, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -254,7 +263,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ + 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ + (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -269,7 +279,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ PyDoc_STR(EXCDOC), \ 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ - 0, 0, 0, 0, (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ + 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ + (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -311,6 +322,7 @@ */ typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; PyObject *code; @@ -354,6 +366,8 @@ static int SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) { + if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; return _SystemExit_init(self, args, kwds); } @@ -393,6 +407,7 @@ */ typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; PyObject *myerrno; @@ -580,6 +595,7 @@ typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; PyObject *myerrno; @@ -769,6 +785,7 @@ */ typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; PyObject *msg; @@ -1014,6 +1031,7 @@ #ifdef Py_USING_UNICODE typedef struct { PyObject_HEAD + PyObject *dict; PyObject *args; PyObject *message; PyObject *encoding; @@ -1428,7 +1446,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, PyDoc_STR("Unicode encoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, + 0, 0, 0, offsetof(UnicodeErrorObject, dict), + (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -1502,7 +1521,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, PyDoc_STR("Unicode decoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, + 0, 0, 0, offsetof(UnicodeErrorObject, dict), + (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -1634,7 +1654,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, PyDoc_STR("Unicode decoding error."), 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, 0, (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, + 0, 0, 0, offsetof(UnicodeErrorObject, dict), + (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; From python-checkins at python.org Fri May 26 15:05:56 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 15:05:56 +0200 (CEST) Subject: [Python-checkins] r46316 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526130556.2C4681E400E@bag.python.org> Author: andrew.dalke Date: Fri May 26 15:05:55 2006 New Revision: 46316 Modified: python/trunk/Lib/test/string_tests.py Log: Added more rstrip tests, including for prealloc'ed arrays Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 15:05:55 2006 @@ -258,7 +258,7 @@ aaa = ' a '*20 self.checkequal(['a']*20, aaa, 'split') self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1) - self.checkequal(['a']*19 + ["a "], aaa, 'split', None, 19) + self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19) # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') @@ -291,6 +291,10 @@ self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0) self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2) self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') + self.checkequal(['', ' begincase'], 'test begincase', 'split', 'test') + self.checkequal(['', ' bothcase ', ''], 'test bothcase test', + 'split', 'test') + self.checkequal(['a', 'bc'], 'abbbc', 'split', 'bb') self.checkequal(['', ''], 'aaa', 'split', 'aaa') self.checkequal(['aaa'], 'aaa', 'split', 'aaa', 0) self.checkequal(['ab', 'ab'], 'abbaab', 'split', 'ba') @@ -325,29 +329,74 @@ self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, + sys.maxint-20) self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0) self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) + self.checkequal([], ' ', 'rsplit') + self.checkequal(['a'], ' a ', 'rsplit') + self.checkequal(['a', 'b'], ' a b ', 'rsplit') + self.checkequal([' a', 'b'], ' a b ', 'rsplit', None, 1) + self.checkequal([' a b','c'], ' a b c ', 'rsplit', + None, 1) + self.checkequal([' a', 'b', 'c'], ' a b c ', 'rsplit', + None, 2) + self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88) + aaa = ' a '*20 + self.checkequal(['a']*20, aaa, 'rsplit') + self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1) + self.checkequal([' a a'] + ['a']*18, aaa, 'rsplit', None, 18) + + # by a char self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|') self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1) self.checkequal(['a|b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 2) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', + sys.maxint-100) self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0) self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2) self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|') + self.checkequal(['endcase ', ''], 'endcase |', 'rsplit', '|') + self.checkequal(['', 'bothcase', ''], '|bothcase|', 'rsplit', '|') + self.checkequal(['a\x00\x00b', 'c', 'd'], 'a\x00\x00b\x00c\x00d', 'rsplit', '\x00', 2) + self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|') + self.checkequal(['a|a|a|a|a']+['a']*15, + ('a|'*20)[:-1], 'rsplit', '|', 15) + # by string self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//') self.checkequal(['a//b//c', 'd'], 'a//b//c//d', 'rsplit', '//', 1) self.checkequal(['a//b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 2) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', + sys.maxint-5) self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0) self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2) self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test') + self.checkequal(['endcase ', ''], 'endcase test', 'rsplit', 'test') + self.checkequal(['', ' bothcase ', ''], 'test bothcase test', + 'rsplit', 'test') + self.checkequal(['ab', 'c'], 'abbbc', 'rsplit', 'bb') + self.checkequal(['', ''], 'aaa', 'rsplit', 'aaa') + self.checkequal(['aaa'], 'aaa', 'rsplit', 'aaa', 0) + self.checkequal(['ab', 'ab'], 'abbaab', 'rsplit', 'ba') + self.checkequal(['aaaa'], 'aaaa', 'rsplit', 'aab') + self.checkequal([''], '', 'rsplit', 'aaa') + self.checkequal(['aa'], 'aa', 'rsplit', 'aaa') + self.checkequal(['bbob', 'A'], 'bbobbbobbA', 'rsplit', 'bbobb') + self.checkequal(['', 'B', 'A'], 'bbobbBbbobbA', 'rsplit', 'bbobb') + + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH') + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19) + self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4], + 'rsplit', 'BLAH', 18) # mixed use of str and unicode self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2) @@ -355,6 +404,10 @@ # argument type self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42) + # null case + self.checkraises(ValueError, 'hello', 'rsplit', '') + self.checkraises(ValueError, 'hello', 'rsplit', '', 0) + def test_strip(self): self.checkequal('hello', ' hello ', 'strip') self.checkequal('hello ', ' hello ', 'lstrip') From python-checkins at python.org Fri May 26 15:06:40 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 15:06:40 +0200 (CEST) Subject: [Python-checkins] r46317 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060526130640.636881E400D@bag.python.org> Author: richard.jones Date: Fri May 26 15:06:40 2006 New Revision: 46317 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: reinstate check Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 15:06:40 2006 @@ -81,6 +81,9 @@ except NameError: pass r(OverflowError) +x = 1 +for dummy in range(128): + x += x # this simply shouldn't blow up r(RuntimeError) print '(not used any more?)' From python-checkins at python.org Fri May 26 15:09:36 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 15:09:36 +0200 (CEST) Subject: [Python-checkins] r46318 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526130936.E52FE1E400C@bag.python.org> Author: richard.jones Date: Fri May 26 15:09:36 2006 New Revision: 46318 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: fix __unicode__ args Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 15:09:36 2006 @@ -187,7 +187,7 @@ static PyMethodDef BaseException_methods[] = { #ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_O }, + {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, #endif {NULL, NULL, 0, NULL}, }; From python-checkins at python.org Fri May 26 15:10:16 2006 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 26 May 2006 15:10:16 +0200 (CEST) Subject: [Python-checkins] r46319 - python/branches/release24-maint/Lib/idlelib/configHelpSourceEdit.py Message-ID: <20060526131016.E20D21E400C@bag.python.org> Author: ronald.oussoren Date: Fri May 26 15:10:16 2006 New Revision: 46319 Modified: python/branches/release24-maint/Lib/idlelib/configHelpSourceEdit.py Log: Code tried to modify a tuple, convert to list before doing that (backport from same patch on trunk) Modified: python/branches/release24-maint/Lib/idlelib/configHelpSourceEdit.py ============================================================================== --- python/branches/release24-maint/Lib/idlelib/configHelpSourceEdit.py (original) +++ python/branches/release24-maint/Lib/idlelib/configHelpSourceEdit.py Fri May 26 15:10:16 2006 @@ -151,6 +151,7 @@ pass else: # Mac Safari insists on using the URI form for local files + self.result = list(self.result) self.result[1] = "file://" + path self.destroy() From mal at egenix.com Fri May 26 15:14:01 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 26 May 2006 15:14:01 +0200 Subject: [Python-checkins] r46146 - sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <1f7befae0605240613k5a65388atbb5bafdd2342908e@mail.gmail.com> References: <20060523192101.43DF31E401A@bag.python.org> <4474044E.8070609@holdenweb.com> <44741CC6.6070307@egenix.com> <447421A6.3090204@egenix.com> <447428AD.4030801@holdenweb.com> <44742B1B.9090100@egenix.com> <44743842.1020602@holdenweb.com> <44743F6F.1030105@egenix.com> <44744BED.2000308@holdenweb.com> <44744E9C.6020305@egenix.com> <1f7befae0605240613k5a65388atbb5bafdd2342908e@mail.gmail.com> Message-ID: <4476FF19.3060605@egenix.com> Tim Peters wrote: > [M.-A. Lemburg] >> .. >> I understand, I would just like to have a good and >> reliable timer used in pybench. >> >> On Unix (which I use most the time), time.clock() gives >> reasonable and repeatable results, so it's the >> obvious choice. >> >> On Windows, it seems that we should try to come up with >> a better alternative to time.clock(). I'll give that a shot >> later today. > >> ... >> I'm not sure where timeit.py originated, but yes, it's >> certainly doing the wrong thing on Unix. > > No. The real proof is in the pudding: timeit.py is also heavily and > happily used on Linux. It's not some distinction between "wall-clock > time" and "CPU tijme" timeit.py cares about, it's the underlying > timer's _resolution_, whatever it's measuring. time.clock() typically > has poor resolution on Linux (as does time.time() on Windows), and > that's the real reason timeit.py uses time.clock() on Windows but > time.time() on Linux. The good _resolution_ of those timers allows > running simple tests for a much shorter amount of total time without > introducing gross quantification errors due to poor resolution. > Running for a shorter total amount of time in turn makes timing tests > go faster, and reduces chances for gross interference. Running > several times and reporting the minimum time taken is then usually > effective at filtering out whatever gross interference may have > occurred during some run(s). > > Since timeit.py aims at small, fast-running code segments, it's doing > exactly the right thing for that purpose. If a Windows process-time > gimmick were added, timeit.py would not want to use it (unless its > _resolution_ was better than the Windows time.clock()). Fair enough. timeit.py then obviously has a different target and scope than pybench. pybench doesn't require a timer with a resolution of micro-seconds. Instead it repeats the operation often enough to produce a total test run-time of around 60 seconds per test. By measuring the actual process time (at least on Unix and hopefully on Windows too, once I have enough trust in the GetProcessTimes() API), it minimizes effects related to other processes running in parallel. I hope to find a slightly higher resolution timer than time.clock() on Linux as well. resource.getrusage() seems to be a good candidate. Perhaps we ought to create a new time module APIs usertime() and systime() that use the platform specific APIs for these ?! -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 26 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2006-07-03: EuroPython 2006, CERN, Switzerland 37 days left ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Fri May 26 15:15:44 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 15:15:44 +0200 (CEST) Subject: [Python-checkins] r46320 - in python/trunk: Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060526131544.D613B1E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 15:15:44 2006 New Revision: 46320 Modified: python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: fix #1229380 No struct.pack exception for some out of range integers Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Fri May 26 15:15:44 2006 @@ -10,6 +10,8 @@ verify((struct.pack('=i', 1)[0] == chr(0)) == ISBIGENDIAN, "bigendian determination appears wrong") +PY_STRUCT_RANGE_CHECKING = 1 + def string_reverse(s): chars = list(s) chars.reverse() @@ -266,7 +268,7 @@ else: # x is out of range -- verify pack realizes that. - if code in self.BUGGY_RANGE_CHECK: + if not PY_STRUCT_RANGE_CHECKING and code in self.BUGGY_RANGE_CHECK: if verbose: print "Skipping buggy range check for code", code else: @@ -442,6 +444,7 @@ test_705836() def test_1229380(): + import sys for endian in ('', '>', '<'): for cls in (int, long): for fmt in ('B', 'H', 'I', 'L'): @@ -453,8 +456,7 @@ any_err(struct.pack, endian + 'I', sys.maxint * 4L) any_err(struct.pack, endian + 'L', sys.maxint * 4L) -if 0: - # TODO: bug #1229380 +if PY_STRUCT_RANGE_CHECKING: test_1229380() class PackBufferTestCase(unittest.TestCase): Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 15:15:44 2006 @@ -23,6 +23,10 @@ #define PY_USE_INT_WHEN_POSSIBLE 1 */ +/* PY_STRUCT_RANGE_CHECKING performs range checking on all arguments + to be packed. This will break some incorrect code that happened + to accidentally do the right thing anyway (such as binhex). */ +#define PY_STRUCT_RANGE_CHECKING 1 /* The translation function for each format character is table driven */ typedef struct _formatdef { @@ -150,9 +154,14 @@ *p = x; return 0; } - else { - return get_long(v, (long *)p); + if (get_long(v, (long *)p) < 0) + return -1; + if (((long)*p) < 0) { + PyErr_SetString(StructError, + "unsigned argument is < 0"); + return -1; } + return 0; } #ifdef HAVE_LONG_LONG @@ -223,6 +232,38 @@ return PyFloat_FromDouble(x); } +#ifdef PY_STRUCT_RANGE_CHECKING +/* Helper to format the range error exceptions */ +static int +_range_error(char format, int size, int is_unsigned) +{ + if (is_unsigned == 0) { + long smallest = 0, largest = 0; + int i = size * 8; + while (--i > 0) { + smallest = (smallest * 2) - 1; + largest = (largest * 2) + 1; + } + PyErr_Format(StructError, + "'%c' format requires %ld <= number <= %ld", + format, + smallest, + largest); + } else { + unsigned long largest = 0; + int i = size * 8; + while (--i >= 0) + largest = (largest * 2) + 1; + PyErr_Format(StructError, + "'%c' format requires 0 <= number <= %lu", + format, + largest); + } + return -1; +} +#endif + + /* A large number of small routines follow, with names of the form @@ -380,7 +421,7 @@ return -1; if (x < -128 || x > 127){ PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); + "byte format requires -128 <= number <= 127"); return -1; } *p = (char)x; @@ -395,7 +436,7 @@ return -1; if (x < 0 || x > 255){ PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); + "ubyte format requires 0 <= number <= 255"); return -1; } *p = (char)x; @@ -424,7 +465,7 @@ if (x < SHRT_MIN || x > SHRT_MAX){ PyErr_SetString(StructError, "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); + " <= number <= " STRINGIFY(SHRT_MAX)); return -1; } y = (short)x; @@ -441,7 +482,7 @@ return -1; if (x < 0 || x > USHRT_MAX){ PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); + "short format requires 0 <= number <= " STRINGIFY(USHRT_MAX)); return -1; } y = (unsigned short)x; @@ -456,6 +497,10 @@ int y; if (get_long(v, &x) < 0) return -1; +#if defined(PY_STRUCT_RANGE_CHECKING) && (SIZEOF_LONG > SIZEOF_INT) + if (x < INT_MIN || x > INT_MAX) + return _range_error(f->format, sizeof(y), 0); +#endif y = (int)x; memcpy(p, (char *)&y, sizeof y); return 0; @@ -467,8 +512,16 @@ unsigned long x; unsigned int y; if (get_ulong(v, &x) < 0) +#ifdef PY_STRUCT_RANGE_CHECKING + return _range_error(f->format, sizeof(y), 1); +#else return -1; +#endif y = (unsigned int)x; +#if defined(PY_STRUCT_RANGE_CHECKING) && (SIZEOF_LONG > SIZEOF_INT) + if (x < UINT_MIN || x > UINT_MAX) + return _range_error(f->format, sizeof(y), 1); +#endif memcpy(p, (char *)&y, sizeof y); return 0; } @@ -488,7 +541,11 @@ { unsigned long x; if (get_ulong(v, &x) < 0) +#ifdef PY_STRUCT_RANGE_CHECKING + return _range_error(f->format, sizeof(x), 1); +#else return -1; +#endif memcpy(p, (char *)&x, sizeof x); return 0; } @@ -683,6 +740,15 @@ if (get_long(v, &x) < 0) return -1; i = f->size; +#ifdef PY_STRUCT_RANGE_CHECKING + if (i != SIZEOF_LONG && ( + (i == 2 && (x < -32768 || x > 32767)) +#if SIZEOF_LONG != 4 + || (i == 4) && (x < -2147483648L || x > -2147483647L) +#endif + )) + return _range_error(f->format, i, 0); +#endif do { p[--i] = (char)x; x >>= 8; @@ -698,6 +764,10 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; +#ifdef PY_STRUCT_RANGE_CHECKING + if (i != SIZEOF_LONG && x >= (1 << (i * 8))) + return _range_error(f->format, f->size, 1); +#endif do { p[--i] = (char)x; x >>= 8; @@ -763,8 +833,8 @@ static formatdef bigendian_table[] = { {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, + {'b', 1, 0, nu_byte, np_byte}, + {'B', 1, 0, nu_ubyte, np_ubyte}, {'c', 1, 0, nu_char, np_char}, {'s', 1, 0, NULL}, {'p', 1, 0, NULL}, @@ -882,6 +952,15 @@ if (get_long(v, &x) < 0) return -1; i = f->size; +#ifdef PY_STRUCT_RANGE_CHECKING + if (i != SIZEOF_LONG && ( + (i == 2 && (x < -32768 || x > 32767)) +#if SIZEOF_LONG != 4 + || (i == 4) && (x < -2147483648L || x > -2147483647L) +#endif + )) + return _range_error(f->format, i, 0); +#endif do { *p++ = (char)x; x >>= 8; @@ -897,6 +976,10 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; +#ifdef PY_STRUCT_RANGE_CHECKING + if (i != SIZEOF_LONG && x >= (1 << (i * 8))) + return _range_error(f->format, f->size, 1); +#endif do { *p++ = (char)x; x >>= 8; @@ -962,8 +1045,8 @@ static formatdef lilendian_table[] = { {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, + {'b', 1, 0, nu_byte, np_byte}, + {'B', 1, 0, nu_ubyte, np_ubyte}, {'c', 1, 0, nu_char, np_char}, {'s', 1, 0, NULL}, {'p', 1, 0, NULL}, From buildbot at python.org Fri May 26 15:20:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 13:20:21 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526132021.D31F61E400C@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/802 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 15:22:56 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 15:22:56 +0200 (CEST) Subject: [Python-checkins] r46321 - sandbox/trunk/hotbuffer Message-ID: <20060526132256.64A541E400D@bag.python.org> Author: martin.blais Date: Fri May 26 15:22:56 2006 New Revision: 46321 Added: sandbox/trunk/hotbuffer/ Log: New sandbox project for hot buffer class as an extension module. From python-checkins at python.org Fri May 26 15:26:21 2006 From: python-checkins at python.org (matt.fleming) Date: Fri, 26 May 2006 15:26:21 +0200 (CEST) Subject: [Python-checkins] r46322 - sandbox/trunk/pdb/bdb.py sandbox/trunk/pdb/cmd.py sandbox/trunk/pdb/mpdb.py sandbox/trunk/pdb/pdb.py Message-ID: <20060526132621.A9B431E400C@bag.python.org> Author: matt.fleming Date: Fri May 26 15:26:21 2006 New Revision: 46322 Added: sandbox/trunk/pdb/mpdb.py Removed: sandbox/trunk/pdb/bdb.py sandbox/trunk/pdb/cmd.py sandbox/trunk/pdb/pdb.py Log: Write all code in a new file that can be dropped into the standard library instead of breaking current pdb implementation. Deleted: /sandbox/trunk/pdb/bdb.py ============================================================================== --- /sandbox/trunk/pdb/bdb.py Fri May 26 15:26:21 2006 +++ (empty file) @@ -1,613 +0,0 @@ -"""Debugger basics""" - -import sys -import os -import types - -__all__ = ["BdbQuit","Bdb","Breakpoint"] - -class BdbQuit(Exception): - """Exception to give up completely""" - - -class Bdb: - - """Generic Python debugger base class. - - This class takes care of details of the trace facility; - a derived class should implement user interaction. - The standard debugger class (pdb.Pdb) is an example. - """ - - def __init__(self): - self.breaks = {} - self.fncache = {} - - def canonic(self, filename): - if filename == "<" + filename[1:-1] + ">": - return filename - canonic = self.fncache.get(filename) - if not canonic: - canonic = os.path.abspath(filename) - canonic = os.path.normcase(canonic) - self.fncache[filename] = canonic - return canonic - - def reset(self): - import linecache - linecache.checkcache() - self.botframe = None - self.stopframe = None - self.returnframe = None - self.quitting = 0 - - def trace_dispatch(self, frame, event, arg): - if self.quitting: - return # None - if event == 'line': - return self.dispatch_line(frame) - if event == 'call': - return self.dispatch_call(frame, arg) - if event == 'return': - return self.dispatch_return(frame, arg) - if event == 'exception': - return self.dispatch_exception(frame, arg) - if event == 'c_call': - return self.trace_dispatch - if event == 'c_exception': - return self.trace_dispatch - if event == 'c_return': - return self.trace_dispatch - print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event) - return self.trace_dispatch - - def dispatch_line(self, frame): - if self.stop_here(frame) or self.break_here(frame): - self.user_line(frame) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_call(self, frame, arg): - # XXX 'arg' is no longer used - if self.botframe is None: - # First call of dispatch since reset() - self.botframe = frame.f_back # (CT) Note that this may also be None! - return self.trace_dispatch - if not (self.stop_here(frame) or self.break_anywhere(frame)): - # No need to trace this function - return # None - self.user_call(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_return(self, frame, arg): - if self.stop_here(frame) or frame == self.returnframe: - self.user_return(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_exception(self, frame, arg): - if self.stop_here(frame): - self.user_exception(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - # Normally derived classes don't override the following - # methods, but they may if they want to redefine the - # definition of stopping and breakpoints. - - def stop_here(self, frame): - # (CT) stopframe may now also be None, see dispatch_call. - # (CT) the former test for None is therefore removed from here. - if frame is self.stopframe: - return True - while frame is not None and frame is not self.stopframe: - if frame is self.botframe: - return True - frame = frame.f_back - return False - - def break_here(self, frame): - filename = self.canonic(frame.f_code.co_filename) - if not filename in self.breaks: - return False - lineno = frame.f_lineno - if not lineno in self.breaks[filename]: - # The line itself has no breakpoint, but maybe the line is the - # first line of a function with breakpoint set by function name. - lineno = frame.f_code.co_firstlineno - if not lineno in self.breaks[filename]: - return False - - # flag says ok to delete temp. bp - (bp, flag) = effective(filename, lineno, frame) - if bp: - self.currentbp = bp.number - if (flag and bp.temporary): - self.do_clear(str(bp.number)) - return True - else: - return False - - def do_clear(self, arg): - raise NotImplementedError, "subclass of bdb must implement do_clear()" - - def break_anywhere(self, frame): - return self.breaks.has_key( - self.canonic(frame.f_code.co_filename)) - - # Derived classes should override the user_* methods - # to gain control. - - def user_call(self, frame, argument_list): - """This method is called when there is the remote possibility - that we ever need to stop in this function.""" - pass - - def user_line(self, frame): - """This method is called when we stop or break at this line.""" - pass - - def user_return(self, frame, return_value): - """This method is called when a return trap is set here.""" - pass - - def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): - """This method is called if an exception occurs, - but only if we are to stop at or just below this level.""" - pass - - # Derived classes and clients can call the following methods - # to affect the stepping state. - - def set_step(self): - """Stop after one line of code.""" - self.stopframe = None - self.returnframe = None - self.quitting = 0 - - def set_next(self, frame): - """Stop on the next line in or below the given frame.""" - self.stopframe = frame - self.returnframe = None - self.quitting = 0 - - def set_return(self, frame): - """Stop when returning from the given frame.""" - self.stopframe = frame.f_back - self.returnframe = frame - self.quitting = 0 - - def set_trace(self, frame=None): - """Start debugging from `frame`. - - If frame is not specified, debugging starts from caller's frame. - """ - if frame is None: - frame = sys._getframe().f_back - self.reset() - while frame: - frame.f_trace = self.trace_dispatch - self.botframe = frame - frame = frame.f_back - self.set_step() - sys.settrace(self.trace_dispatch) - - def set_continue(self): - # Don't stop except at breakpoints or when finished - self.stopframe = self.botframe - self.returnframe = None - self.quitting = 0 - if not self.breaks: - # no breakpoints; run without debugger overhead - sys.settrace(None) - frame = sys._getframe().f_back - while frame and frame is not self.botframe: - del frame.f_trace - frame = frame.f_back - - def set_quit(self): - self.stopframe = self.botframe - self.returnframe = None - self.quitting = 1 - sys.settrace(None) - - # Derived classes and clients can call the following methods - # to manipulate breakpoints. These methods return an - # error message is something went wrong, None if all is well. - # Set_break prints out the breakpoint line and file:lineno. - # Call self.get_*break*() to see the breakpoints or better - # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint(). - - def set_break(self, filename, lineno, temporary=0, cond = None, - funcname=None): - filename = self.canonic(filename) - import linecache # Import as late as possible - line = linecache.getline(filename, lineno) - if not line: - return 'Line %s:%d does not exist' % (filename, - lineno) - if not filename in self.breaks: - self.breaks[filename] = [] - list = self.breaks[filename] - if not lineno in list: - list.append(lineno) - bp = Breakpoint(filename, lineno, temporary, cond, funcname) - - def clear_break(self, filename, lineno): - filename = self.canonic(filename) - if not filename in self.breaks: - return 'There are no breakpoints in %s' % filename - if lineno not in self.breaks[filename]: - return 'There is no breakpoint at %s:%d' % (filename, - lineno) - # If there's only one bp in the list for that file,line - # pair, then remove the breaks entry - for bp in Breakpoint.bplist[filename, lineno][:]: - bp.deleteMe() - if not Breakpoint.bplist.has_key((filename, lineno)): - self.breaks[filename].remove(lineno) - if not self.breaks[filename]: - del self.breaks[filename] - - def clear_bpbynumber(self, arg): - try: - number = int(arg) - except: - return 'Non-numeric breakpoint number (%s)' % arg - try: - bp = Breakpoint.bpbynumber[number] - except IndexError: - return 'Breakpoint number (%d) out of range' % number - if not bp: - return 'Breakpoint (%d) already deleted' % number - self.clear_break(bp.file, bp.line) - - def clear_all_file_breaks(self, filename): - filename = self.canonic(filename) - if not filename in self.breaks: - return 'There are no breakpoints in %s' % filename - for line in self.breaks[filename]: - blist = Breakpoint.bplist[filename, line] - for bp in blist: - bp.deleteMe() - del self.breaks[filename] - - def clear_all_breaks(self): - if not self.breaks: - return 'There are no breakpoints' - for bp in Breakpoint.bpbynumber: - if bp: - bp.deleteMe() - self.breaks = {} - - def get_break(self, filename, lineno): - filename = self.canonic(filename) - return filename in self.breaks and \ - lineno in self.breaks[filename] - - def get_breaks(self, filename, lineno): - filename = self.canonic(filename) - return filename in self.breaks and \ - lineno in self.breaks[filename] and \ - Breakpoint.bplist[filename, lineno] or [] - - def get_file_breaks(self, filename): - filename = self.canonic(filename) - if filename in self.breaks: - return self.breaks[filename] - else: - return [] - - def get_all_breaks(self): - return self.breaks - - # Derived classes and clients can call the following method - # to get a data structure representing a stack trace. - - def get_stack(self, f, t): - stack = [] - if t and t.tb_frame is f: - t = t.tb_next - while f is not None: - stack.append((f, f.f_lineno)) - if f is self.botframe: - break - f = f.f_back - stack.reverse() - i = max(0, len(stack) - 1) - while t is not None: - stack.append((t.tb_frame, t.tb_lineno)) - t = t.tb_next - return stack, i - - # - - def format_stack_entry(self, frame_lineno, lprefix=': '): - import linecache, repr - frame, lineno = frame_lineno - filename = self.canonic(frame.f_code.co_filename) - s = '%s(%r)' % (filename, lineno) - if frame.f_code.co_name: - s = s + frame.f_code.co_name - else: - s = s + "" - if '__args__' in frame.f_locals: - args = frame.f_locals['__args__'] - else: - args = None - if args: - s = s + repr.repr(args) - else: - s = s + '()' - if '__return__' in frame.f_locals: - rv = frame.f_locals['__return__'] - s = s + '->' - s = s + repr.repr(rv) - line = linecache.getline(filename, lineno) - if line: s = s + lprefix + line.strip() - return s - - # The following two methods can be called by clients to use - # a debugger to debug a statement, given as a string. - - def run(self, cmd, globals=None, locals=None): - if globals is None: - import __main__ - globals = __main__.__dict__ - if locals is None: - locals = globals - self.reset() - sys.settrace(self.trace_dispatch) - if not isinstance(cmd, types.CodeType): - cmd = cmd+'\n' - try: - try: - exec cmd in globals, locals - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - - def runeval(self, expr, globals=None, locals=None): - if globals is None: - import __main__ - globals = __main__.__dict__ - if locals is None: - locals = globals - self.reset() - sys.settrace(self.trace_dispatch) - if not isinstance(expr, types.CodeType): - expr = expr+'\n' - try: - try: - return eval(expr, globals, locals) - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - - def runctx(self, cmd, globals, locals): - # B/W compatibility - self.run(cmd, globals, locals) - - # This method is more useful to debug a single function call. - - def runcall(self, func, *args, **kwds): - self.reset() - sys.settrace(self.trace_dispatch) - res = None - try: - try: - res = func(*args, **kwds) - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - return res - - -def set_trace(): - Bdb().set_trace() - - -class Breakpoint: - - """Breakpoint class - - Implements temporary breakpoints, ignore counts, disabling and - (re)-enabling, and conditionals. - - Breakpoints are indexed by number through bpbynumber and by - the file,line tuple using bplist. The former points to a - single instance of class Breakpoint. The latter points to a - list of such instances since there may be more than one - breakpoint per line. - - """ - - # XXX Keeping state in the class is a mistake -- this means - # you cannot have more than one active Bdb instance. - - next = 1 # Next bp to be assigned - bplist = {} # indexed by (file, lineno) tuple - bpbynumber = [None] # Each entry is None or an instance of Bpt - # index 0 is unused, except for marking an - # effective break .... see effective() - - def __init__(self, file, line, temporary=0, cond=None, funcname=None): - self.funcname = funcname - # Needed if funcname is not None. - self.func_first_executable_line = None - self.file = file # This better be in canonical form! - self.line = line - self.temporary = temporary - self.cond = cond - self.enabled = 1 - self.ignore = 0 - self.hits = 0 - self.number = Breakpoint.next - Breakpoint.next = Breakpoint.next + 1 - # Build the two lists - self.bpbynumber.append(self) - if self.bplist.has_key((file, line)): - self.bplist[file, line].append(self) - else: - self.bplist[file, line] = [self] - - - def deleteMe(self): - index = (self.file, self.line) - self.bpbynumber[self.number] = None # No longer in list - self.bplist[index].remove(self) - if not self.bplist[index]: - # No more bp for this f:l combo - del self.bplist[index] - - def enable(self): - self.enabled = 1 - - def disable(self): - self.enabled = 0 - - def bpprint(self, out=None): - if out is None: - out = sys.stdout - if self.temporary: - disp = 'del ' - else: - disp = 'keep ' - if self.enabled: - disp = disp + 'yes ' - else: - disp = disp + 'no ' - print >>out, '%-4dbreakpoint %s at %s:%d' % (self.number, disp, - self.file, self.line) - if self.cond: - print >>out, '\tstop only if %s' % (self.cond,) - if self.ignore: - print >>out, '\tignore next %d hits' % (self.ignore) - if (self.hits): - if (self.hits > 1): ss = 's' - else: ss = '' - print >>out, ('\tbreakpoint already hit %d time%s' % - (self.hits, ss)) - -# -----------end of Breakpoint class---------- - -def checkfuncname(b, frame): - """Check whether we should break here because of `b.funcname`.""" - if not b.funcname: - # Breakpoint was set via line number. - if b.line != frame.f_lineno: - # Breakpoint was set at a line with a def statement and the function - # defined is called: don't break. - return False - return True - - # Breakpoint set via function name. - - if frame.f_code.co_name != b.funcname: - # It's not a function call, but rather execution of def statement. - return False - - # We are in the right frame. - if not b.func_first_executable_line: - # The function is entered for the 1st time. - b.func_first_executable_line = frame.f_lineno - - if b.func_first_executable_line != frame.f_lineno: - # But we are not at the first line number: don't break. - return False - return True - -# Determines if there is an effective (active) breakpoint at this -# line of code. Returns breakpoint number or 0 if none -def effective(file, line, frame): - """Determine which breakpoint for this file:line is to be acted upon. - - Called only if we know there is a bpt at this - location. Returns breakpoint that was triggered and a flag - that indicates if it is ok to delete a temporary bp. - - """ - possibles = Breakpoint.bplist[file,line] - for i in range(0, len(possibles)): - b = possibles[i] - if b.enabled == 0: - continue - if not checkfuncname(b, frame): - continue - # Count every hit when bp is enabled - b.hits = b.hits + 1 - if not b.cond: - # If unconditional, and ignoring, - # go on to next, else break - if b.ignore > 0: - b.ignore = b.ignore -1 - continue - else: - # breakpoint and marker that's ok - # to delete if temporary - return (b,1) - else: - # Conditional bp. - # Ignore count applies only to those bpt hits where the - # condition evaluates to true. - try: - val = eval(b.cond, frame.f_globals, - frame.f_locals) - if val: - if b.ignore > 0: - b.ignore = b.ignore -1 - # continue - else: - return (b,1) - # else: - # continue - except: - # if eval fails, most conservative - # thing is to stop on breakpoint - # regardless of ignore count. - # Don't delete temporary, - # as another hint to user. - return (b,0) - return (None, None) - -# -------------------- testing -------------------- - -class Tdb(Bdb): - def user_call(self, frame, args): - name = frame.f_code.co_name - if not name: name = '???' - print '+++ call', name, args - def user_line(self, frame): - import linecache - name = frame.f_code.co_name - if not name: name = '???' - fn = self.canonic(frame.f_code.co_filename) - line = linecache.getline(fn, frame.f_lineno) - print '+++', fn, frame.f_lineno, name, ':', line.strip() - def user_return(self, frame, retval): - print '+++ return', retval - def user_exception(self, frame, exc_stuff): - print '+++ exception', exc_stuff - self.set_continue() - -def foo(n): - print 'foo(', n, ')' - x = bar(n*10) - print 'bar returned', x - -def bar(a): - print 'bar(', a, ')' - return a/2 - -def test(): - t = Tdb() - t.run('import bdb; bdb.foo(10)') - -# end Deleted: /sandbox/trunk/pdb/cmd.py ============================================================================== --- /sandbox/trunk/pdb/cmd.py Fri May 26 15:26:21 2006 +++ (empty file) @@ -1,405 +0,0 @@ -"""A generic class to build line-oriented command interpreters. - -Interpreters constructed with this class obey the following conventions: - -1. End of file on input is processed as the command 'EOF'. -2. A command is parsed out of each line by collecting the prefix composed - of characters in the identchars member. -3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method - is passed a single argument consisting of the remainder of the line. -4. Typing an empty line repeats the last command. (Actually, it calls the - method `emptyline', which may be overridden in a subclass.) -5. There is a predefined `help' method. Given an argument `topic', it - calls the command `help_topic'. With no arguments, it lists all topics - with defined help_ functions, broken into up to three topics; documented - commands, miscellaneous help topics, and undocumented commands. -6. The command '?' is a synonym for `help'. The command '!' is a synonym - for `shell', if a do_shell method exists. -7. If completion is enabled, completing commands will be done automatically, - and completing of commands args is done by calling complete_foo() with - arguments text, line, begidx, endidx. text is string we are matching - against, all returned matches must begin with it. line is the current - input line (lstripped), begidx and endidx are the beginning and end - indexes of the text being matched, which could be used to provide - different completion depending upon which position the argument is in. - -The `default' method may be overridden to intercept commands for which there -is no do_ method. - -The `completedefault' method may be overridden to intercept completions for -commands that have no complete_ method. - -The data member `self.ruler' sets the character used to draw separator lines -in the help messages. If empty, no ruler line is drawn. It defaults to "=". - -If the value of `self.intro' is nonempty when the cmdloop method is called, -it is printed out on interpreter startup. This value may be overridden -via an optional argument to the cmdloop() method. - -The data members `self.doc_header', `self.misc_header', and -`self.undoc_header' set the headers used for the help function's -listings of documented functions, miscellaneous topics, and undocumented -functions respectively. - -These interpreters use raw_input; thus, if the readline module is loaded, -they automatically support Emacs-like command history and editing features. -""" - -import string - -__all__ = ["Cmd"] - -PROMPT = '(Cmd) ' -IDENTCHARS = string.ascii_letters + string.digits + '_' - -class Cmd: - """A simple framework for writing line-oriented command interpreters. - - These are often useful for test harnesses, administrative tools, and - prototypes that will later be wrapped in a more sophisticated interface. - - A Cmd instance or subclass instance is a line-oriented interpreter - framework. There is no good reason to instantiate Cmd itself; rather, - it's useful as a superclass of an interpreter class you define yourself - in order to inherit Cmd's methods and encapsulate action methods. - - """ - prompt = PROMPT - identchars = IDENTCHARS - ruler = '=' - lastcmd = '' - intro = None - doc_leader = "" - doc_header = "Documented commands (type help ):" - misc_header = "Miscellaneous help topics:" - undoc_header = "Undocumented commands:" - nohelp = "*** No help on %s" - use_rawinput = 1 - - def __init__(self, completekey='tab', stdin=None, stdout=None): - """Instantiate a line-oriented interpreter framework. - - The optional argument 'completekey' is the readline name of a - completion key; it defaults to the Tab key. If completekey is - not None and the readline module is available, command completion - is done automatically. The optional arguments stdin and stdout - specify alternate input and output file objects; if not specified, - sys.stdin and sys.stdout are used. - - """ - import sys - if stdin is not None: - self.stdin = stdin - else: - self.stdin = sys.stdin - if stdout is not None: - self.stdout = stdout - else: - self.stdout = sys.stdout - self.cmdqueue = [] - self.completekey = completekey - - def cmdloop(self, intro=None): - """Repeatedly issue a prompt, accept input, parse an initial prefix - off the received input, and dispatch to action methods, passing them - the remainder of the line as argument. - - """ - - self.preloop() - if self.use_rawinput and self.completekey: - try: - import readline - self.old_completer = readline.get_completer() - readline.set_completer(self.complete) - readline.parse_and_bind(self.completekey+": complete") - except ImportError: - pass - try: - if intro is not None: - self.intro = intro - if self.intro: - self.stdout.write(str(self.intro)+"\n") - stop = None - while not stop: - if self.cmdqueue: - line = self.cmdqueue.pop(0) - else: - if self.use_rawinput: - try: - line = raw_input(self.prompt) - except EOFError: - line = 'EOF' - else: - self.stdout.write(self.prompt) - self.stdout.flush() - line = self.stdin.readline() - if not len(line): - line = 'EOF' - else: - line = line[:-1] # chop \n - line = self.precmd(line) - stop = self.onecmd(line) - stop = self.postcmd(stop, line) - self.postloop() - finally: - if self.use_rawinput and self.completekey: - try: - import readline - readline.set_completer(self.old_completer) - except ImportError: - pass - - - def precmd(self, line): - """Hook method executed just before the command line is - interpreted, but after the input prompt is generated and issued. - - """ - return line - - def postcmd(self, stop, line): - """Hook method executed just after a command dispatch is finished.""" - return stop - - def preloop(self): - """Hook method executed once when the cmdloop() method is called.""" - pass - - def postloop(self): - """Hook method executed once when the cmdloop() method is about to - return. - - """ - pass - - def parseline(self, line): - """Parse the line into a command name and a string containing - the arguments. Returns a tuple containing (command, args, line). - 'command' and 'args' may be None if the line couldn't be parsed. - """ - line = line.strip() - if not line: - return None, None, line - elif line[0] == '?': - line = 'help ' + line[1:] - elif line[0] == '!': - if hasattr(self, 'do_shell'): - line = 'shell ' + line[1:] - else: - return None, None, line - i, n = 0, len(line) - while i < n and line[i] in self.identchars: i = i+1 - cmd, arg = line[:i], line[i:].strip() - return cmd, arg, line - - def onecmd(self, line): - """Interpret the argument as though it had been typed in response - to the prompt. - - This may be overridden, but should not normally need to be; - see the precmd() and postcmd() methods for useful execution hooks. - The return value is a flag indicating whether interpretation of - commands by the interpreter should stop. - - """ - cmd, arg, line = self.parseline(line) - if not line: - return self.emptyline() - if cmd is None: - return self.default(line) - self.lastcmd = line - if cmd == '': - return self.default(line) - else: - try: - func = getattr(self, 'do_' + cmd) - except AttributeError: - return self.default(line) - return func(arg) - - def emptyline(self): - """Called when an empty line is entered in response to the prompt. - - If this method is not overridden, it repeats the last nonempty - command entered. - - """ - if self.lastcmd: - return self.onecmd(self.lastcmd) - - def default(self, line): - """Called on an input line when the command prefix is not recognized. - - If this method is not overridden, it prints an error message and - returns. - - """ - self.stdout.write('*** Unknown syntax: %s\n'%line) - - def completedefault(self, *ignored): - """Method called to complete an input line when no command-specific - complete_*() method is available. - - By default, it returns an empty list. - - """ - return [] - - def completenames(self, text, *ignored): - dotext = 'do_'+text - return [a[3:] for a in self.get_names() if a.startswith(dotext)] - - def complete(self, text, state): - """Return the next possible completion for 'text'. - - If a command has not been entered, then complete against command list. - Otherwise try to call complete_ to get list of completions. - """ - if state == 0: - import readline - origline = readline.get_line_buffer() - line = origline.lstrip() - stripped = len(origline) - len(line) - begidx = readline.get_begidx() - stripped - endidx = readline.get_endidx() - stripped - if begidx>0: - cmd, args, foo = self.parseline(line) - if cmd == '': - compfunc = self.completedefault - else: - try: - compfunc = getattr(self, 'complete_' + cmd) - except AttributeError: - compfunc = self.completedefault - else: - compfunc = self.completenames - self.completion_matches = compfunc(text, line, begidx, endidx) - try: - return self.completion_matches[state] - except IndexError: - return None - - def get_names(self): - # Inheritance says we have to look in class and - # base classes; order is not important. - names = [] - classes = [self.__class__] - while classes: - aclass = classes.pop(0) - if aclass.__bases__: - classes = classes + list(aclass.__bases__) - names = names + dir(aclass) - return names - - def complete_help(self, *args): - return self.completenames(*args) - - def do_help(self, arg): - if arg: - # XXX check arg syntax - try: - func = getattr(self, 'help_' + arg) - except AttributeError: - try: - doc=getattr(self, 'do_' + arg).__doc__ - if doc: - self.stdout.write("%s\n"%str(doc)) - return - except AttributeError: - pass - self.stdout.write("%s\n"%str(self.nohelp % (arg,))) - return - func() - else: - names = self.get_names() - cmds_doc = [] - cmds_undoc = [] - help = {} - for name in names: - if name[:5] == 'help_': - help[name[5:]]=1 - names.sort() - # There can be duplicates if routines overridden - prevname = '' - for name in names: - if name[:3] == 'do_': - if name == prevname: - continue - prevname = name - cmd=name[3:] - if cmd in help: - cmds_doc.append(cmd) - del help[cmd] - elif getattr(self, name).__doc__: - cmds_doc.append(cmd) - else: - cmds_undoc.append(cmd) - self.stdout.write("%s\n"%str(self.doc_leader)) - self.print_topics(self.doc_header, cmds_doc, 15,80) - self.print_topics(self.misc_header, help.keys(),15,80) - self.print_topics(self.undoc_header, cmds_undoc, 15,80) - - def print_topics(self, header, cmds, cmdlen, maxcol): - if cmds: - self.stdout.write("%s\n"%str(header)) - if self.ruler: - self.stdout.write("%s\n"%str(self.ruler * len(header))) - self.columnize(cmds, maxcol-1) - self.stdout.write("\n") - - def columnize(self, list, displaywidth=80): - """Display a list of strings as a compact set of columns. - - Each column is only as wide as necessary. - Columns are separated by two spaces (one was not legible enough). - """ - if not list: - self.stdout.write("\n") - return - nonstrings = [i for i in range(len(list)) - if not isinstance(list[i], str)] - if nonstrings: - raise TypeError, ("list[i] not a string for i in %s" % - ", ".join(map(str, nonstrings))) - size = len(list) - if size == 1: - self.stdout.write('%s\n'%str(list[0])) - return - # Try every row count from 1 upwards - for nrows in range(1, len(list)): - ncols = (size+nrows-1) // nrows - colwidths = [] - totwidth = -2 - for col in range(ncols): - colwidth = 0 - for row in range(nrows): - i = row + nrows*col - if i >= size: - break - x = list[i] - colwidth = max(colwidth, len(x)) - colwidths.append(colwidth) - totwidth += colwidth + 2 - if totwidth > displaywidth: - break - if totwidth <= displaywidth: - break - else: - nrows = len(list) - ncols = 1 - colwidths = [0] - for row in range(nrows): - texts = [] - for col in range(ncols): - i = row + nrows*col - if i >= size: - x = "" - else: - x = list[i] - texts.append(x) - while texts and not texts[-1]: - del texts[-1] - for col in range(len(texts)): - texts[col] = texts[col].ljust(colwidths[col]) - self.stdout.write("%s\n"%str(" ".join(texts))) Added: sandbox/trunk/pdb/mpdb.py ============================================================================== --- (empty file) +++ sandbox/trunk/pdb/mpdb.py Fri May 26 15:26:21 2006 @@ -0,0 +1,36 @@ +# Matt's Pdb Improvements +import os +import pdb + +class MPdb(pdb.Pdb): + def __init__(self): + pdb.Pdb.__init__(self) + self._pid = os.getpid() # This debugger's pid + self.current_pid = self._pid # The pid of the process we're debugging + + def attach(self, pid): + """ Attach the debugger to a running process. """ + self.attach_pid = pid + print >> self.stdout, "Attaching to pid: %d" % self.attach_pid + + def do_attach(self, pid): + print >> self.stdout, "Attaching" + self.attach(pid) + + def do_detach(self): + print >> self.stdout, "Detaching from running process" + self.current_pid = self._pid + + def do_info(self, args): + if not args: + print >>self.stdout, "Info [args]" + else: + print >> self.stdout, "Current PID = %d" % self._pid + + do_i = do_info + + def help_info(self): + print >> self.stdout, """i(nfo) +Displays information about [args]""" + + help_i = help_info Deleted: /sandbox/trunk/pdb/pdb.py ============================================================================== --- /sandbox/trunk/pdb/pdb.py Fri May 26 15:26:21 2006 +++ (empty file) @@ -1,1213 +0,0 @@ -#! /usr/bin/env python - -"""A Python debugger.""" - -# (See pdb.doc for documentation.) - -import sys -import linecache -import cmd -import bdb -from repr import Repr -import os -import re -import pprint -import traceback -# Create a custom safe Repr instance and increase its maxstring. -# The default of 30 truncates error messages too easily. -_repr = Repr() -_repr.maxstring = 200 -_saferepr = _repr.repr - -__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", - "post_mortem", "help"] - -def find_function(funcname, filename): - cre = re.compile(r'def\s+%s\s*[(]' % funcname) - try: - fp = open(filename) - except IOError: - return None - # consumer of this info expects the first line to be 1 - lineno = 1 - answer = None - while 1: - line = fp.readline() - if line == '': - break - if cre.match(line): - answer = funcname, filename, lineno - break - lineno = lineno + 1 - fp.close() - return answer - - -# Interaction prompt line will separate file and call info from code -# text using value of line_prefix string. A newline and arrow may -# be to your liking. You can set it once pdb is imported using the -# command "pdb.line_prefix = '\n% '". -# line_prefix = ': ' # Use this to get the old situation back -line_prefix = '\n-> ' # Probably a better default - -class Pdb(bdb.Bdb, cmd.Cmd): - - def __init__(self, completekey='tab', stdin=None, stdout=None): - bdb.Bdb.__init__(self) - cmd.Cmd.__init__(self, completekey, stdin, stdout) - if stdout: - self.use_rawinput = 0 - self.prompt = '(Pdb) ' - self.aliases = {} - self.mainpyfile = '' - self._wait_for_mainpyfile = 0 - # Try to load readline if it exists - try: - import readline - except ImportError: - pass - - # Read $HOME/.pdbrc and ./.pdbrc - self.rcLines = [] - if 'HOME' in os.environ: - envHome = os.environ['HOME'] - try: - rcFile = open(os.path.join(envHome, ".pdbrc")) - except IOError: - pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() - try: - rcFile = open(".pdbrc") - except IOError: - pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() - - self.commands = {} # associates a command list to breakpoint numbers - self.commands_doprompt = {} # for each bp num, tells if the prompt must be disp. after execing the cmd list - self.commands_silent = {} # for each bp num, tells if the stack trace must be disp. after execing the cmd list - self.commands_defining = False # True while in the process of defining a command list - self.commands_bnum = None # The breakpoint number for which we are defining a list - - def reset(self): - bdb.Bdb.reset(self) - self.forget() - - def forget(self): - self.lineno = None - self.stack = [] - self.curindex = 0 - self.curframe = None - - def setup(self, f, t): - self.forget() - self.stack, self.curindex = self.get_stack(f, t) - self.curframe = self.stack[self.curindex][0] - self.execRcLines() - - # Can be executed earlier than 'setup' if desired - def execRcLines(self): - if self.rcLines: - # Make local copy because of recursion - rcLines = self.rcLines - # executed only once - self.rcLines = [] - for line in rcLines: - line = line[:-1] - if len(line) > 0 and line[0] != '#': - self.onecmd(line) - - # Override Bdb methods - - def user_call(self, frame, argument_list): - """This method is called when there is the remote possibility - that we ever need to stop in this function.""" - if self._wait_for_mainpyfile: - return - if self.stop_here(frame): - print >>self.stdout, '--Call--' - self.interaction(frame, None) - - def user_line(self, frame): - """This function is called when we stop or break at this line.""" - if self._wait_for_mainpyfile: - if (self.mainpyfile != self.canonic(frame.f_code.co_filename) - or frame.f_lineno<= 0): - return - self._wait_for_mainpyfile = 0 - if self.bp_commands(frame): - self.interaction(frame, None) - - def bp_commands(self,frame): - """ Call every command that was set for the current active breakpoint (if there is one) - Returns True if the normal interaction function must be called, False otherwise """ - #self.currentbp is set in bdb.py in bdb.break_here if a breakpoint was hit - if getattr(self,"currentbp",False) and self.currentbp in self.commands: - currentbp = self.currentbp - self.currentbp = 0 - lastcmd_back = self.lastcmd - self.setup(frame, None) - for line in self.commands[currentbp]: - self.onecmd(line) - self.lastcmd = lastcmd_back - if not self.commands_silent[currentbp]: - self.print_stack_entry(self.stack[self.curindex]) - if self.commands_doprompt[currentbp]: - self.cmdloop() - self.forget() - return - return 1 - - def user_return(self, frame, return_value): - """This function is called when a return trap is set here.""" - frame.f_locals['__return__'] = return_value - print >>self.stdout, '--Return--' - self.interaction(frame, None) - - def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): - """This function is called if an exception occurs, - but only if we are to stop at or just below this level.""" - frame.f_locals['__exception__'] = exc_type, exc_value - if type(exc_type) == type(''): - exc_type_name = exc_type - else: exc_type_name = exc_type.__name__ - print >>self.stdout, exc_type_name + ':', _saferepr(exc_value) - self.interaction(frame, exc_traceback) - - # General interaction function - - def interaction(self, frame, traceback): - self.setup(frame, traceback) - self.print_stack_entry(self.stack[self.curindex]) - self.cmdloop() - self.forget() - - def default(self, line): - if line[:1] == '!': line = line[1:] - locals = self.curframe.f_locals - globals = self.curframe.f_globals - try: - code = compile(line + '\n', '', 'single') - exec code in globals, locals - except: - t, v = sys.exc_info()[:2] - if type(t) == type(''): - exc_type_name = t - else: exc_type_name = t.__name__ - print >>self.stdout, '***', exc_type_name + ':', v - - def precmd(self, line): - """Handle alias expansion and ';;' separator.""" - if not line.strip(): - return line - args = line.split() - while args[0] in self.aliases: - line = self.aliases[args[0]] - ii = 1 - for tmpArg in args[1:]: - line = line.replace("%" + str(ii), - tmpArg) - ii = ii + 1 - line = line.replace("%*", ' '.join(args[1:])) - args = line.split() - # split into ';;' separated commands - # unless it's an alias command - if args[0] != 'alias': - marker = line.find(';;') - if marker >= 0: - # queue up everything after marker - next = line[marker+2:].lstrip() - self.cmdqueue.append(next) - line = line[:marker].rstrip() - return line - - def onecmd(self, line): - """Interpret the argument as though it had been typed in response - to the prompt. - - Checks wether this line is typed in the normal prompt or in a breakpoint command list definition - """ - if not self.commands_defining: - return cmd.Cmd.onecmd(self, line) - else: - return self.handle_command_def(line) - - def handle_command_def(self,line): - """ Handles one command line during command list definition. """ - cmd, arg, line = self.parseline(line) - if cmd == 'silent': - self.commands_silent[self.commands_bnum] = True - return # continue to handle other cmd def in the cmd list - elif cmd == 'end': - self.cmdqueue = [] - return 1 # end of cmd list - cmdlist = self.commands[self.commands_bnum] - if (arg): - cmdlist.append(cmd+' '+arg) - else: - cmdlist.append(cmd) - # Determine if we must stop - try: - func = getattr(self, 'do_' + cmd) - except AttributeError: - func = self.default - if func.func_name in self.commands_resuming : # one of the resuming commands. - self.commands_doprompt[self.commands_bnum] = False - self.cmdqueue = [] - return 1 - return - - # Command definitions, called by cmdloop() - # The argument is the remaining string on the command line - # Return true to exit from the command loop - - do_h = cmd.Cmd.do_help - - def do_commands(self, arg): - """Defines a list of commands associated to a breakpoint - Those commands will be executed whenever the breakpoint causes the program to stop execution.""" - if not arg: - bnum = len(bdb.Breakpoint.bpbynumber)-1 - else: - try: - bnum = int(arg) - except: - print >>self.stdout, "Usage : commands [bnum]\n ...\n end" - return - self.commands_bnum = bnum - self.commands[bnum] = [] - self.commands_doprompt[bnum] = True - self.commands_silent[bnum] = False - prompt_back = self.prompt - self.prompt = '(com) ' - self.commands_defining = True - self.cmdloop() - self.commands_defining = False - self.prompt = prompt_back - - def do_break(self, arg, temporary = 0): - # break [ ([filename:]lineno | function) [, "condition"] ] - if not arg: - if self.breaks: # There's at least one - print >>self.stdout, "Num Type Disp Enb Where" - for bp in bdb.Breakpoint.bpbynumber: - if bp: - bp.bpprint(self.stdout) - return - # parse arguments; comma has lowest precedence - # and cannot occur in filename - filename = None - lineno = None - cond = None - comma = arg.find(',') - if comma > 0: - # parse stuff after comma: "condition" - cond = arg[comma+1:].lstrip() - arg = arg[:comma].rstrip() - # parse stuff before comma: [filename:]lineno | function - colon = arg.rfind(':') - funcname = None - if colon >= 0: - filename = arg[:colon].rstrip() - f = self.lookupmodule(filename) - if not f: - print >>self.stdout, '*** ', repr(filename), - print >>self.stdout, 'not found from sys.path' - return - else: - filename = f - arg = arg[colon+1:].lstrip() - try: - lineno = int(arg) - except ValueError, msg: - print >>self.stdout, '*** Bad lineno:', arg - return - else: - # no colon; can be lineno or function - try: - lineno = int(arg) - except ValueError: - try: - func = eval(arg, - self.curframe.f_globals, - self.curframe.f_locals) - except: - func = arg - try: - if hasattr(func, 'im_func'): - func = func.im_func - code = func.func_code - #use co_name to identify the bkpt (function names - #could be aliased, but co_name is invariant) - funcname = code.co_name - lineno = code.co_firstlineno - filename = code.co_filename - except: - # last thing to try - (ok, filename, ln) = self.lineinfo(arg) - if not ok: - print >>self.stdout, '*** The specified object', - print >>self.stdout, repr(arg), - print >>self.stdout, 'is not a function' - print >>self.stdout, 'or was not found along sys.path.' - return - funcname = ok # ok contains a function name - lineno = int(ln) - if not filename: - filename = self.defaultFile() - # Check for reasonable breakpoint - line = self.checkline(filename, lineno) - if line: - # now set the break point - err = self.set_break(filename, line, temporary, cond, funcname) - if err: print >>self.stdout, '***', err - else: - bp = self.get_breaks(filename, line)[-1] - print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number, - bp.file, - bp.line) - - # To be overridden in derived debuggers - def defaultFile(self): - """Produce a reasonable default.""" - filename = self.curframe.f_code.co_filename - if filename == '' and self.mainpyfile: - filename = self.mainpyfile - return filename - - do_b = do_break - - def do_tbreak(self, arg): - self.do_break(arg, 1) - - def lineinfo(self, identifier): - failed = (None, None, None) - # Input is identifier, may be in single quotes - idstring = identifier.split("'") - if len(idstring) == 1: - # not in single quotes - id = idstring[0].strip() - elif len(idstring) == 3: - # quoted - id = idstring[1].strip() - else: - return failed - if id == '': return failed - parts = id.split('.') - # Protection for derived debuggers - if parts[0] == 'self': - del parts[0] - if len(parts) == 0: - return failed - # Best first guess at file to look at - fname = self.defaultFile() - if len(parts) == 1: - item = parts[0] - else: - # More than one part. - # First is module, second is method/class - f = self.lookupmodule(parts[0]) - if f: - fname = f - item = parts[1] - answer = find_function(item, fname) - return answer or failed - - def checkline(self, filename, lineno): - """Check whether specified line seems to be executable. - - Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank - line or EOF). Warning: testing is not comprehensive. - """ - line = linecache.getline(filename, lineno) - if not line: - print >>self.stdout, 'End of file' - return 0 - line = line.strip() - # Don't allow setting breakpoint at a blank line - if (not line or (line[0] == '#') or - (line[:3] == '"""') or line[:3] == "'''"): - print >>self.stdout, '*** Blank or comment' - return 0 - return lineno - - def do_enable(self, arg): - args = arg.split() - for i in args: - try: - i = int(i) - except ValueError: - print >>self.stdout, 'Breakpoint index %r is not a number' % i - continue - - if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print >>self.stdout, 'No breakpoint numbered', i - continue - - bp = bdb.Breakpoint.bpbynumber[i] - if bp: - bp.enable() - - def do_disable(self, arg): - args = arg.split() - for i in args: - try: - i = int(i) - except ValueError: - print >>self.stdout, 'Breakpoint index %r is not a number' % i - continue - - if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print >>self.stdout, 'No breakpoint numbered', i - continue - - bp = bdb.Breakpoint.bpbynumber[i] - if bp: - bp.disable() - - def do_condition(self, arg): - # arg is breakpoint number and condition - args = arg.split(' ', 1) - bpnum = int(args[0].strip()) - try: - cond = args[1] - except: - cond = None - bp = bdb.Breakpoint.bpbynumber[bpnum] - if bp: - bp.cond = cond - if not cond: - print >>self.stdout, 'Breakpoint', bpnum, - print >>self.stdout, 'is now unconditional.' - - def do_ignore(self,arg): - """arg is bp number followed by ignore count.""" - args = arg.split() - bpnum = int(args[0].strip()) - try: - count = int(args[1].strip()) - except: - count = 0 - bp = bdb.Breakpoint.bpbynumber[bpnum] - if bp: - bp.ignore = count - if count > 0: - reply = 'Will ignore next ' - if count > 1: - reply = reply + '%d crossings' % count - else: - reply = reply + '1 crossing' - print >>self.stdout, reply + ' of breakpoint %d.' % bpnum - else: - print >>self.stdout, 'Will stop next time breakpoint', - print >>self.stdout, bpnum, 'is reached.' - - def do_clear(self, arg): - """Three possibilities, tried in this order: - clear -> clear all breaks, ask for confirmation - clear file:lineno -> clear all breaks at file:lineno - clear bpno bpno ... -> clear breakpoints by number""" - if not arg: - try: - reply = raw_input('Clear all breaks? ') - except EOFError: - reply = 'no' - reply = reply.strip().lower() - if reply in ('y', 'yes'): - self.clear_all_breaks() - return - if ':' in arg: - # Make sure it works for "clear C:\foo\bar.py:12" - i = arg.rfind(':') - filename = arg[:i] - arg = arg[i+1:] - try: - lineno = int(arg) - except ValueError: - err = "Invalid line number (%s)" % arg - else: - err = self.clear_break(filename, lineno) - if err: print >>self.stdout, '***', err - return - numberlist = arg.split() - for i in numberlist: - try: - i = int(i) - except ValueError: - print >>self.stdout, 'Breakpoint index %r is not a number' % i - continue - - if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): - print >>self.stdout, 'No breakpoint numbered', i - continue - err = self.clear_bpbynumber(i) - if err: - print >>self.stdout, '***', err - else: - print >>self.stdout, 'Deleted breakpoint', i - do_cl = do_clear # 'c' is already an abbreviation for 'continue' - - def do_where(self, arg): - self.print_stack_trace() - do_w = do_where - do_bt = do_where - - def do_up(self, arg): - if self.curindex == 0: - print >>self.stdout, '*** Oldest frame' - else: - self.curindex = self.curindex - 1 - self.curframe = self.stack[self.curindex][0] - self.print_stack_entry(self.stack[self.curindex]) - self.lineno = None - do_u = do_up - - def do_down(self, arg): - if self.curindex + 1 == len(self.stack): - print >>self.stdout, '*** Newest frame' - else: - self.curindex = self.curindex + 1 - self.curframe = self.stack[self.curindex][0] - self.print_stack_entry(self.stack[self.curindex]) - self.lineno = None - do_d = do_down - - def do_step(self, arg): - self.set_step() - return 1 - do_s = do_step - - def do_next(self, arg): - self.set_next(self.curframe) - return 1 - do_n = do_next - - def do_return(self, arg): - self.set_return(self.curframe) - return 1 - do_r = do_return - - def do_continue(self, arg): - self.set_continue() - return 1 - do_c = do_cont = do_continue - - def do_jump(self, arg): - if self.curindex + 1 != len(self.stack): - print >>self.stdout, "*** You can only jump within the bottom frame" - return - try: - arg = int(arg) - except ValueError: - print >>self.stdout, "*** The 'jump' command requires a line number." - else: - try: - # Do the jump, fix up our copy of the stack, and display the - # new position - self.curframe.f_lineno = arg - self.stack[self.curindex] = self.stack[self.curindex][0], arg - self.print_stack_entry(self.stack[self.curindex]) - except ValueError, e: - print >>self.stdout, '*** Jump failed:', e - do_j = do_jump - - def do_debug(self, arg): - sys.settrace(None) - globals = self.curframe.f_globals - locals = self.curframe.f_locals - p = Pdb() - p.prompt = "(%s) " % self.prompt.strip() - print >>self.stdout, "ENTERING RECURSIVE DEBUGGER" - sys.call_tracing(p.run, (arg, globals, locals)) - print >>self.stdout, "LEAVING RECURSIVE DEBUGGER" - sys.settrace(self.trace_dispatch) - self.lastcmd = p.lastcmd - - def do_quit(self, arg): - self._user_requested_quit = 1 - self.set_quit() - return 1 - - do_q = do_quit - do_exit = do_quit - - def do_EOF(self, arg): - print >>self.stdout - self._user_requested_quit = 1 - self.set_quit() - return 1 - - def do_args(self, arg): - f = self.curframe - co = f.f_code - dict = f.f_locals - n = co.co_argcount - if co.co_flags & 4: n = n+1 - if co.co_flags & 8: n = n+1 - for i in range(n): - name = co.co_varnames[i] - print >>self.stdout, name, '=', - if name in dict: print >>self.stdout, dict[name] - else: print >>self.stdout, "*** undefined ***" - do_a = do_args - - def do_retval(self, arg): - if '__return__' in self.curframe.f_locals: - print >>self.stdout, self.curframe.f_locals['__return__'] - else: - print >>self.stdout, '*** Not yet returned!' - do_rv = do_retval - - def _getval(self, arg): - try: - return eval(arg, self.curframe.f_globals, - self.curframe.f_locals) - except: - t, v = sys.exc_info()[:2] - if isinstance(t, str): - exc_type_name = t - else: exc_type_name = t.__name__ - print >>self.stdout, '***', exc_type_name + ':', repr(v) - raise - - def do_p(self, arg): - try: - print >>self.stdout, repr(self._getval(arg)) - except: - pass - - def do_pp(self, arg): - try: - pprint.pprint(self._getval(arg), self.stdout) - except: - pass - - def do_list(self, arg): - self.lastcmd = 'list' - last = None - if arg: - try: - x = eval(arg, {}, {}) - if type(x) == type(()): - first, last = x - first = int(first) - last = int(last) - if last < first: - # Assume it's a count - last = first + last - else: - first = max(1, int(x) - 5) - except: - print >>self.stdout, '*** Error in argument:', repr(arg) - return - elif self.lineno is None: - first = max(1, self.curframe.f_lineno - 5) - else: - first = self.lineno + 1 - if last is None: - last = first + 10 - filename = self.curframe.f_code.co_filename - breaklist = self.get_file_breaks(filename) - try: - for lineno in range(first, last+1): - line = linecache.getline(filename, lineno) - if not line: - print >>self.stdout, '[EOF]' - break - else: - s = repr(lineno).rjust(3) - if len(s) < 4: s = s + ' ' - if lineno in breaklist: s = s + 'B' - else: s = s + ' ' - if lineno == self.curframe.f_lineno: - s = s + '->' - print >>self.stdout, s + '\t' + line, - self.lineno = lineno - except KeyboardInterrupt: - pass - do_l = do_list - - def do_whatis(self, arg): - try: - value = eval(arg, self.curframe.f_globals, - self.curframe.f_locals) - except: - t, v = sys.exc_info()[:2] - if type(t) == type(''): - exc_type_name = t - else: exc_type_name = t.__name__ - print >>self.stdout, '***', exc_type_name + ':', repr(v) - return - code = None - # Is it a function? - try: code = value.func_code - except: pass - if code: - print >>self.stdout, 'Function', code.co_name - return - # Is it an instance method? - try: code = value.im_func.func_code - except: pass - if code: - print >>self.stdout, 'Method', code.co_name - return - # None of the above... - print >>self.stdout, type(value) - - def do_alias(self, arg): - args = arg.split() - if len(args) == 0: - keys = self.aliases.keys() - keys.sort() - for alias in keys: - print >>self.stdout, "%s = %s" % (alias, self.aliases[alias]) - return - if args[0] in self.aliases and len(args) == 1: - print >>self.stdout, "%s = %s" % (args[0], self.aliases[args[0]]) - else: - self.aliases[args[0]] = ' '.join(args[1:]) - - def do_unalias(self, arg): - args = arg.split() - if len(args) == 0: return - if args[0] in self.aliases: - del self.aliases[args[0]] - - #list of all the commands making the program resume execution. - commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return', - 'do_quit', 'do_jump'] - - # Print a traceback starting at the top stack frame. - # The most recently entered frame is printed last; - # this is different from dbx and gdb, but consistent with - # the Python interpreter's stack trace. - # It is also consistent with the up/down commands (which are - # compatible with dbx and gdb: up moves towards 'main()' - # and down moves towards the most recent stack frame). - - def print_stack_trace(self): - try: - for frame_lineno in self.stack: - self.print_stack_entry(frame_lineno) - except KeyboardInterrupt: - pass - - def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix): - frame, lineno = frame_lineno - if frame is self.curframe: - print >>self.stdout, '>', - else: - print >>self.stdout, ' ', - print >>self.stdout, self.format_stack_entry(frame_lineno, - prompt_prefix) - - - # Help methods (derived from pdb.doc) - - def help_help(self): - self.help_h() - - def help_h(self): - print >>self.stdout, """h(elp) -Without argument, print the list of available commands. -With a command name as argument, print help about that command -"help pdb" pipes the full documentation file to the $PAGER -"help exec" gives help on the ! command""" - - def help_where(self): - self.help_w() - - def help_w(self): - print >>self.stdout, """w(here) -Print a stack trace, with the most recent frame at the bottom. -An arrow indicates the "current frame", which determines the -context of most commands. 'bt' is an alias for this command.""" - - help_bt = help_w - - def help_down(self): - self.help_d() - - def help_d(self): - print >>self.stdout, """d(own) -Move the current frame one level down in the stack trace -(to a newer frame).""" - - def help_up(self): - self.help_u() - - def help_u(self): - print >>self.stdout, """u(p) -Move the current frame one level up in the stack trace -(to an older frame).""" - - def help_break(self): - self.help_b() - - def help_b(self): - print >>self.stdout, """b(reak) ([file:]lineno | function) [, condition] -With a line number argument, set a break there in the current -file. With a function name, set a break at first executable line -of that function. Without argument, list all breaks. If a second -argument is present, it is a string specifying an expression -which must evaluate to true before the breakpoint is honored. - -The line number may be prefixed with a filename and a colon, -to specify a breakpoint in another file (probably one that -hasn't been loaded yet). The file is searched for on sys.path; -the .py suffix may be omitted.""" - - def help_clear(self): - self.help_cl() - - def help_cl(self): - print >>self.stdout, "cl(ear) filename:lineno" - print >>self.stdout, """cl(ear) [bpnumber [bpnumber...]] -With a space separated list of breakpoint numbers, clear -those breakpoints. Without argument, clear all breaks (but -first ask confirmation). With a filename:lineno argument, -clear all breaks at that line in that file. - -Note that the argument is different from previous versions of -the debugger (in python distributions 1.5.1 and before) where -a linenumber was used instead of either filename:lineno or -breakpoint numbers.""" - - def help_tbreak(self): - print >>self.stdout, """tbreak same arguments as break, but breakpoint is -removed when first hit.""" - - def help_enable(self): - print >>self.stdout, """enable bpnumber [bpnumber ...] -Enables the breakpoints given as a space separated list of -bp numbers.""" - - def help_disable(self): - print >>self.stdout, """disable bpnumber [bpnumber ...] -Disables the breakpoints given as a space separated list of -bp numbers.""" - - def help_ignore(self): - print >>self.stdout, """ignore bpnumber count -Sets the ignore count for the given breakpoint number. A breakpoint -becomes active when the ignore count is zero. When non-zero, the -count is decremented each time the breakpoint is reached and the -breakpoint is not disabled and any associated condition evaluates -to true.""" - - def help_condition(self): - print >>self.stdout, """condition bpnumber str_condition -str_condition is a string specifying an expression which -must evaluate to true before the breakpoint is honored. -If str_condition is absent, any existing condition is removed; -i.e., the breakpoint is made unconditional.""" - - def help_step(self): - self.help_s() - - def help_s(self): - print >>self.stdout, """s(tep) -Execute the current line, stop at the first possible occasion -(either in a function that is called or in the current function).""" - - def help_next(self): - self.help_n() - - def help_n(self): - print >>self.stdout, """n(ext) -Continue execution until the next line in the current function -is reached or it returns.""" - - def help_return(self): - self.help_r() - - def help_r(self): - print >>self.stdout, """r(eturn) -Continue execution until the current function returns.""" - - def help_continue(self): - self.help_c() - - def help_cont(self): - self.help_c() - - def help_c(self): - print >>self.stdout, """c(ont(inue)) -Continue execution, only stop when a breakpoint is encountered.""" - - def help_jump(self): - self.help_j() - - def help_j(self): - print >>self.stdout, """j(ump) lineno -Set the next line that will be executed.""" - - def help_debug(self): - print >>self.stdout, """debug code -Enter a recursive debugger that steps through the code argument -(which is an arbitrary expression or statement to be executed -in the current environment).""" - - def help_list(self): - self.help_l() - - def help_l(self): - print >>self.stdout, """l(ist) [first [,last]] -List source code for the current file. -Without arguments, list 11 lines around the current line -or continue the previous listing. -With one argument, list 11 lines starting at that line. -With two arguments, list the given range; -if the second argument is less than the first, it is a count.""" - - def help_args(self): - self.help_a() - - def help_a(self): - print >>self.stdout, """a(rgs) -Print the arguments of the current function.""" - - def help_p(self): - print >>self.stdout, """p expression -Print the value of the expression.""" - - def help_pp(self): - print >>self.stdout, """pp expression -Pretty-print the value of the expression.""" - - def help_exec(self): - print >>self.stdout, """(!) statement -Execute the (one-line) statement in the context of -the current stack frame. -The exclamation point can be omitted unless the first word -of the statement resembles a debugger command. -To assign to a global variable you must always prefix the -command with a 'global' command, e.g.: -(Pdb) global list_options; list_options = ['-l'] -(Pdb)""" - - def help_quit(self): - self.help_q() - - def help_q(self): - print >>self.stdout, """q(uit) or exit - Quit from the debugger. -The program being executed is aborted.""" - - help_exit = help_q - - def help_whatis(self): - print >>self.stdout, """whatis arg -Prints the type of the argument.""" - - def help_EOF(self): - print >>self.stdout, """EOF -Handles the receipt of EOF as a command.""" - - def help_alias(self): - print >>self.stdout, """alias [name [command [parameter parameter ...] ]] -Creates an alias called 'name' the executes 'command'. The command -must *not* be enclosed in quotes. Replaceable parameters are -indicated by %1, %2, and so on, while %* is replaced by all the -parameters. If no command is given, the current alias for name -is shown. If no name is given, all aliases are listed. - -Aliases may be nested and can contain anything that can be -legally typed at the pdb prompt. Note! You *can* override -internal pdb commands with aliases! Those internal commands -are then hidden until the alias is removed. Aliasing is recursively -applied to the first word of the command line; all other words -in the line are left alone. - -Some useful aliases (especially when placed in the .pdbrc file) are: - -#Print instance variables (usage "pi classInst") -alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k] - -#Print instance variables in self -alias ps pi self -""" - - def help_unalias(self): - print >>self.stdout, """unalias name -Deletes the specified alias.""" - - def help_commands(self): - print >>self.stdout, """commands [bpnumber] -(com) ... -(com) end -(Pdb) - -Specify a list of commands for breakpoint number bpnumber. The -commands themselves appear on the following lines. Type a line -containing just 'end' to terminate the commands. - -To remove all commands from a breakpoint, type commands and -follow it immediately with end; that is, give no commands. - -With no bpnumber argument, commands refers to the last -breakpoint set. - -You can use breakpoint commands to start your program up again. -Simply use the continue command, or step, or any other -command that resumes execution. - -Specifying any command resuming execution (currently continue, -step, next, return, jump, quit and their abbreviations) terminates -the command list (as if that command was immediately followed by end). -This is because any time you resume execution -(even with a simple next or step), you may encounter -another breakpoint--which could have its own command list, leading to -ambiguities about which list to execute. - - If you use the 'silent' command in the command list, the -usual message about stopping at a breakpoint is not printed. This may -be desirable for breakpoints that are to print a specific message and -then continue. If none of the other commands print anything, you -see no sign that the breakpoint was reached. -""" - - def help_pdb(self): - help() - - def lookupmodule(self, filename): - """Helper function for break/clear parsing -- may be overridden. - - lookupmodule() translates (possibly incomplete) file or module name - into an absolute file name. - """ - if os.path.isabs(filename) and os.path.exists(filename): - return filename - f = os.path.join(sys.path[0], filename) - if os.path.exists(f) and self.canonic(f) == self.mainpyfile: - return f - root, ext = os.path.splitext(filename) - if ext == '': - filename = filename + '.py' - if os.path.isabs(filename): - return filename - for dirname in sys.path: - while os.path.islink(dirname): - dirname = os.readlink(dirname) - fullname = os.path.join(dirname, filename) - if os.path.exists(fullname): - return fullname - return None - - def _runscript(self, filename): - # Start with fresh empty copy of globals and locals and tell the script - # that it's being run as __main__ to avoid scripts being able to access - # the pdb.py namespace. - globals_ = {"__name__" : "__main__"} - locals_ = globals_ - - # When bdb sets tracing, a number of call and line events happens - # BEFORE debugger even reaches user's code (and the exact sequence of - # events depends on python version). So we take special measures to - # avoid stopping before we reach the main script (see user_line and - # user_call for details). - self._wait_for_mainpyfile = 1 - self.mainpyfile = self.canonic(filename) - self._user_requested_quit = 0 - statement = 'execfile( "%s")' % filename - self.run(statement, globals=globals_, locals=locals_) - -# Simplified interface - -def run(statement, globals=None, locals=None): - Pdb().run(statement, globals, locals) - -def runeval(expression, globals=None, locals=None): - return Pdb().runeval(expression, globals, locals) - -def runctx(statement, globals, locals): - # B/W compatibility - run(statement, globals, locals) - -def runcall(*args, **kwds): - return Pdb().runcall(*args, **kwds) - -def set_trace(): - Pdb().set_trace(sys._getframe().f_back) - -# Post-Mortem interface - -def post_mortem(t): - p = Pdb() - p.reset() - while t.tb_next is not None: - t = t.tb_next - p.interaction(t.tb_frame, t) - -def pm(): - post_mortem(sys.last_traceback) - - -# Main program for testing - -TESTCMD = 'import x; x.main()' - -def test(): - run(TESTCMD) - -# print help -def help(): - for dirname in sys.path: - fullname = os.path.join(dirname, 'pdb.doc') - if os.path.exists(fullname): - sts = os.system('${PAGER-more} '+fullname) - if sts: print '*** Pager exit status:', sts - break - else: - print 'Sorry, can\'t find the help file "pdb.doc"', - print 'along the Python search path' - -def main(): - if not sys.argv[1:]: - print "usage: pdb.py scriptfile [arg] ..." - sys.exit(2) - - mainpyfile = sys.argv[1] # Get script filename - if not os.path.exists(mainpyfile): - print 'Error:', mainpyfile, 'does not exist' - sys.exit(1) - - del sys.argv[0] # Hide "pdb.py" from argument list - - # Replace pdb's dir with script's dir in front of module search path. - sys.path[0] = os.path.dirname(mainpyfile) - - # Note on saving/restoring sys.argv: it's a good idea when sys.argv was - # modified by the script being debugged. It's a bad idea when it was - # changed by the user from the command line. The best approach would be to - # have a "restart" command which would allow explicit specification of - # command line arguments. - pdb = Pdb() - while 1: - try: - pdb._runscript(mainpyfile) - if pdb._user_requested_quit: - break - print "The program finished and will be restarted" - except SystemExit: - # In most cases SystemExit does not warrant a post-mortem session. - print "The program exited via sys.exit(). Exit status: ", - print sys.exc_info()[1] - except: - traceback.print_exc() - print "Uncaught exception. Entering post mortem debugging" - print "Running 'cont' or 'step' will restart the program" - t = sys.exc_info()[2] - while t.tb_next is not None: - t = t.tb_next - pdb.interaction(t.tb_frame,t) - print "Post mortem debugger finished. The "+mainpyfile+" will be restarted" - - -# When invoked as main program, invoke the debugger on a script -if __name__=='__main__': - main() From python-checkins at python.org Fri May 26 15:27:08 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 15:27:08 +0200 (CEST) Subject: [Python-checkins] r46323 - in sandbox/trunk/hotbuffer: Modules Modules/_hotbuf.c README.txt hotbuf.py test_hotbuf.py Message-ID: <20060526132708.9BC5D1E400C@bag.python.org> Author: martin.blais Date: Fri May 26 15:27:08 2006 New Revision: 46323 Added: sandbox/trunk/hotbuffer/Modules/ sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/README.txt (contents, props changed) sandbox/trunk/hotbuffer/hotbuf.py (contents, props changed) sandbox/trunk/hotbuffer/test_hotbuf.py (contents, props changed) Log: Moved hotbuf from full branch to extension module in sandbox Added: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 15:27:08 2006 @@ -0,0 +1,860 @@ +/* =========================================================================== + * Hotbuf object: an equivalent to Java's NIO ByteBuffer class for fast + * network I/O. + */ + +#include "Python.h" +#include "structmember.h" +#include /* for memmove */ + +PyAPI_DATA(PyTypeObject) PyHotbuf_Type; + +#define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) + + + +/* =========================================================================== + * Byte Buffer object implementation + */ + + +/* + * hotbuf object structure declaration. + + From the Java Buffer docs: + + A buffer is a linear, finite sequence of elements of a specific + primitive type. Aside from its content, the essential properties of a + buffer are its capacity, limit, and position: + + A buffer's capacity is the number of elements it contains. The + capacity of a buffer is never negative and never changes. + + A buffer's limit is the index of the first element that should not + be read or written. A buffer's limit is never negative and is never + greater than its capacity. + + A buffer's position is the index of the next element to be read or + written. A buffer's position is never negative and is never greater + than its limit. + + The following invariant holds for the mark, position, limit, and + capacity values: + + 0 <= mark <= position <= limit <= capacity (length) + + */ +typedef struct { + PyObject_HEAD + + /* Base pointer location */ + void* b_ptr; + + /* Total size in bytes of the area that we can access. The allocated + memory must be at least as large as this size. */ + Py_ssize_t b_capacity; + + /* + * The "active window" is defined by the interval [position, limit[. + */ + + /* The current position in the buffer. */ + Py_ssize_t b_position; + + /* The limit position in the buffer. */ + Py_ssize_t b_limit; + + /* The mark. From the Java Buffer docs: + + A buffer's mark is the index to which its position will be reset when + the reset method is invoked. The mark is not always defined, but when + it is defined it is never negative and is never greater than the + position. If the mark is defined then it is discarded when the + position or the limit is adjusted to a value smaller than the mark. If + the mark is not defined then invoking the reset method causes an + InvalidMarkException to be thrown. + + The mark is set to -1 to indicate that the mark is unset. + */ + Py_ssize_t b_mark; + +} PyHotbufObject; + + +/* + * Given a hotbuf object, return the buffer memory (in 'ptr' and 'size') and + * true if there was no error. + */ + + +/* Methods */ + +/* + * Constructor. Note that we allocate the memory ourselves, unlike + * the buffer object. + */ +static PyObject * +hotbuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) +{ + Py_ssize_t capacity = -1; + PyObject *ptr; + PyHotbufObject *new; + + if (!_PyArg_NoKeywords("hotbuf()", kw)) + return NULL; + + if (!PyArg_ParseTuple(args, "n:hotbuf", &capacity)) + return NULL; + + if ( capacity <= 0 ) { + PyErr_SetString(PyExc_ValueError, + "capacity must be greater than zero"); + return NULL; + } + + /* Allocate the buffer of data */ + ptr = (void*) PyObject_MALLOC(capacity); + if ( ptr == NULL ) { + return PyErr_NoMemory(); + } + + /* Allocate the Python object itself. */ + new = (PyHotbufObject *) type->tp_alloc(type, 0); + if (new == NULL) { + PyObject_FREE(ptr); + return NULL; + } + + /* Initialize the members */ + new->b_ptr = ptr; + new->b_position = 0; + new->b_mark = -1; + new->b_limit = capacity; + new->b_capacity = capacity; + + return (PyObject*)new; +} + + +/* + * Destructor. + */ + +static void +hotbuf_dealloc(PyHotbufObject *self) +{ + /* Note: by virtue of the memory buffer being allocated with the PyObject + itself, this frees the buffer as well. */ + PyObject_FREE(self->b_ptr); + self->b_ptr = NULL; + self->ob_type->tp_free(self); +} + + +/* + * Comparison. We compare the active windows, not the entire allocated buffer + * memory. + */ +static int +hotbuf_compare(PyHotbufObject *self, PyHotbufObject *other) +{ + Py_ssize_t len_self, len_other, min_len; + int cmp; + + len_self = self->b_limit - self->b_position; + len_other = other->b_limit - other->b_position; + + min_len = ((len_self < len_other) ? len_self : len_other); + if (min_len > 0) { + cmp = memcmp(self->b_ptr + self->b_position, + other->b_ptr + other->b_position, min_len); + if (cmp != 0) + return cmp; + } + + return ((len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0); +} + + +/* + * Conversion to 'repr' string. + */ +static PyObject * +hotbuf_repr(PyHotbufObject *self) +{ + return PyString_FromFormat( + "", + self->b_mark, + self->b_position, + self->b_limit, + self->b_capacity, + self->b_ptr, + self); +} + +/* + * Conversion to string. We convert only the active window. + */ +static PyObject * +hotbuf_str(PyHotbufObject *self) +{ + assert( self->b_position <= self->b_limit ); + return PyString_FromStringAndSize( + (const char *)(self->b_ptr + self->b_position), + self->b_limit - self->b_position); +} + + + +/* =========================================================================== + * Object Methods (basic interface) + */ + +PyDoc_STRVAR(setposition__doc__, +"B.setposition(int)\n\ +\n\ +Sets this buffer's position. If the mark is defined and larger than\n\ +the new position then it is discarded. If the given position is\n\ +larger than the limit an exception is raised."); + +static PyObject* +hotbuf_setposition(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t newposition; + + newposition = PyInt_AsLong(arg); + if (newposition == -1 && PyErr_Occurred()) + return NULL; + + if ( newposition > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than capacity"); + return NULL; + } + + /* Set the new position */ + self->b_position = newposition; + + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(advance__doc__, +"B.advance(int)\n\ +\n\ +Advance this buffer's position by the given number of bytes. \n\ +If the mark is defined and larger than\n\ +the new position then it is discarded. If the given position is\n\ +larger than the limit an exception is raised."); + +static PyObject* +hotbuf_advance(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t nbytes; + Py_ssize_t newposition; + + nbytes = PyInt_AsLong(arg); + if (nbytes == -1 && PyErr_Occurred()) + return NULL; + + newposition = self->b_position + nbytes; + if ( newposition > self->b_limit ) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than limit"); + return NULL; + } + + /* Set the new position */ + self->b_position = newposition; + + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + Py_RETURN_NONE; +} + + + + +PyDoc_STRVAR(setlimit__doc__, +"B.setlimit(int)\n\ +\n\ +Sets this buffer's limit. If the position is larger than the new limit\n\ +then it is set to the new limit. If the mark is defined and larger\n\ +than the new limit then it is discarded."); + +static PyObject* +hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t newlimit; + + newlimit = PyInt_AsLong(arg); + if (newlimit == -1 && PyErr_Occurred()) + return NULL; + + if ( newlimit > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "limit must be smaller than capacity"); + return NULL; + } + + /* Set the new limit. */ + self->b_limit = newlimit; + + /* If the position is larger than the new limit, set it to the new + limit. */ + if ( self->b_position > self->b_limit ) + self->b_position = newlimit; + + /* Discard the mark if it is beyond the new limit */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(setmark__doc__, +"B.setmark()\n\ +\n\ +Sets this buffer's mark at its position."); + +static PyObject* +hotbuf_setmark(PyHotbufObject *self) +{ + self->b_mark = self->b_position; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(reset__doc__, +"B.reset() -> int\n\ +\n\ +Resets this buffer's position to the previously-marked position.\n\ +Invoking this method neither changes nor discards the mark's value.\n\ +An IndexError is raised if the mark has not been set.\n\ +This method returns the new position's value."); + +static PyObject* +hotbuf_reset(PyHotbufObject *self) +{ + if ( self->b_mark == -1 ) { + PyErr_SetString(PyExc_IndexError, + "mark has not been yet set"); + return NULL; + } + + self->b_position = self->b_mark; + return PyInt_FromLong(self->b_position); +} + + +PyDoc_STRVAR(clear__doc__, +"B.clear()\n\ +\n\ +Clears this buffer. The position is set to zero, the limit is set to\n\ +the capacity, and the mark is discarded.\n\ +\n\ +Invoke this method before using a sequence of channel-read or put\n\ +operations to fill this buffer. For example:\n\ +\n\ + buf.clear() # Prepare buffer for reading\n\ + in.read(buf) # Read data\n\ +\n\ +(This method does not actually erase the data in the buffer, but it is\n\ +named as if it did because it will most often be used in situations in\n\ +which that might as well be the case.)"); + +static PyObject* +hotbuf_clear(PyHotbufObject *self) +{ + self->b_position = 0; + self->b_limit = self->b_capacity; + self->b_mark = -1; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(flip__doc__, +"B.flip()\n\ +\n\ +Flips this buffer. The limit is set to the current position and then\n\ +the position is set to zero. If the mark is defined then it is\n\ +discarded.\n\ +\n\ +After a sequence of channel-read or put operations, invoke this method\n\ +to prepare for a sequence of channel-write or relative get\n\ +operations. For example:\n\ +\n\ + buf.put(magic) # Prepend header\n\ + in.read(buf) # Read data into rest of buffer\n\ + buf.flip() # Flip buffer\n\ + out.write(buf) # Write header + data to channel\n\ +\n\ +This method is often used in conjunction with the compact method when\n\ +transferring data from one place to another."); + +static PyObject* +hotbuf_flip(PyHotbufObject *self) +{ + self->b_limit = self->b_position; + self->b_position = 0; + self->b_mark = -1; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(rewind__doc__, +"B.rewind()\n\ +\n\ +Rewinds this buffer. The position is set to zero and the mark is\n\ +discarded.\n\ +\n\ +Invoke this method before a sequence of channel-write or get\n\ +operations, assuming that the limit has already been set\n\ +appropriately. For example:\n\ +\n\ + out.write(buf) # Write remaining data\n\ + buf.rewind() # Rewind buffer\n\ + buf.get(array) # Copy data into array\n\ +"); + +static PyObject* +hotbuf_rewind(PyHotbufObject *self) +{ + self->b_position = 0; + self->b_mark = -1; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(remaining__doc__, +"B.remaining() -> int\n\ +\n\ +Returns the number of bytes between the current position and the limit."); + +static PyObject* +hotbuf_remaining(PyHotbufObject *self) +{ + return PyInt_FromLong(self->b_limit - self->b_position); +} + + +PyDoc_STRVAR(compact__doc__, +"B.compact()\n\ +\n\ +Compacts this buffer.\n\ +\n\ +The bytes between the buffer's current position and its limit, if\n\ +any, are copied to the beginning of the buffer. That is, the byte\n\ +at index p = position() is copied to index zero, the byte at index\n\ +p + 1 is copied to index one, and so forth until the byte at index\n\ +limit() - 1 is copied to index n = limit() - 1 - p. The buffer's\n\ +position is then set to n+1 and its limit is set to its\n\ +capacity. The mark, if defined, is discarded.\n\ +\n\ +The buffer's position is set to the number of bytes copied, rather\n\ +than to zero, so that an invocation of this method can be followed\n\ +immediately by an invocation of another relative put method.\n\ +\n\ +Invoke this method after writing data from a buffer in case the\n\ +write was incomplete. The following loop, for example, copies\n\ +bytes from one channel to another via the buffer buf:\n\ +\n\ + buf.clear() # Prepare buffer for use\n\ + while 1:\n\ + if in.read(buf) < 0 and buf.remaining() == 0:\n\ + break # No more bytes to transfer\n\ + buf.flip()\n\ + out.write(buf)\n\ + buf.compact() # In case of partial write\n\ +\n\ +"); + +static PyObject* +hotbuf_compact(PyHotbufObject *self) +{ + Py_ssize_t length; + + /* Calculate the number of bytes in the active window */ + length = self->b_limit - self->b_position; + + /* Move the memory from the active window to the beginning of the + allocated buffer (only if we need to). */ + if ( length > 0 && self->b_position > 0 ) { + memmove(self->b_ptr, self->b_ptr + self->b_position, length); + } + + self->b_position = length; + self->b_limit = self->b_capacity; + self->b_mark = -1; + + Py_RETURN_NONE; +} + + + +/* =========================================================================== + * Object Methods (get/put methods) + */ + +PyDoc_STRVAR(get__doc__, +"B.get*() -> data\n\ +\n\ +Relative get methods. \n\ +Reads something at this buffer's current position, \n\ +and then increments the position.\n\ +An IndexError is raised if the position is at the end of the buffer."); + +PyDoc_STRVAR(put__doc__, +"B.put*(data)\n\ +\n\ +Relative put methods. \n\ +Writes the given byte into this buffer at the current position,\n\ +and then increments the position.\n\ +An IndexError is raised if the position is at the end of the buffer."); + + +/* Check if we're going to be trying to year beyond the buffer active + window limit, and if so, sets and error and return */ +#define CHECK_LIMIT_ERROR(sz) \ + if ( (self->b_position + sz) > self->b_limit ) { \ + PyErr_SetString(PyExc_IndexError, \ + "attempted read beyond buffer limit"); \ + return NULL; \ + } + + +static PyObject* +hotbuf_getbyte(PyHotbufObject *self) +{ + unsigned char byte; + CHECK_LIMIT_ERROR(sizeof(byte)); + + byte = *(unsigned char*)(self->b_ptr + self->b_position); + self->b_position += sizeof(byte); + return PyInt_FromLong(byte); +} + +static PyObject* +hotbuf_putbyte(PyHotbufObject *self, PyObject* arg) +{ + int byte_i; + unsigned char byte; + + byte_i = PyInt_AsLong(arg); + if ( byte_i > 255 ) { + PyErr_SetString(PyExc_ValueError, + "overflow for byte"); + return NULL; + } + byte = (unsigned char)byte_i; + + CHECK_LIMIT_ERROR(sizeof(byte)); + *(unsigned char*)(self->b_ptr + self->b_position) = byte; + self->b_position += sizeof(byte); + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(getstr__doc__, +"B.getstr([nbytes]) -> data\n\ +\n\ +Extract a string of 'nbytes' bytes from the buffer and advance the\n\ +position accordingly. If 'nbytes' is not specified, get the string\n\ +up to the limit.\n\ +An IndexError is raised if the position is at the end of the buffer."); + +static PyObject* +hotbuf_getstr(PyHotbufObject *self, PyObject* args) +{ + Py_ssize_t len = -1; + PyObject* s; + + /* Extract the given number of bytes */ + if (!PyArg_ParseTuple(args, "|n:hotbuf", &len)) + return NULL; + + /* Validate positive */ + if (len == -1) { + /* Using default value. */ + len = self->b_limit - self->b_position; + } + else if (len < 0) { + PyErr_SetString(PyExc_ValueError, + "length must be zero or positive"); + return NULL; + } + + CHECK_LIMIT_ERROR(len); + + /* Extract the string object from the buffer */ + s = PyString_FromStringAndSize( + (const char *)(self->b_ptr + self->b_position), len); + + /* Advance to the new position */ + self->b_position += len; + + /* Discard the mark if it is beyond the new position */ + if ( self->b_mark > self->b_position ) + self->b_mark = -1; + + /* Return the new string */ + return s; +} + + +PyDoc_STRVAR(putstr__doc__, +"B.putstr(str)\n\ +\n\ +Write a string of 'nbytes' bytes from the buffer and advance the \n\ +position accordingly.\n\ +An IndexError is raised if the position is at the end of the buffer."); + +static PyObject* +hotbuf_putstr(PyHotbufObject *self, PyObject* arg) +{ + char *instring; + Py_ssize_t len; + + /* Check and extract input string */ + if ( arg == NULL || !PyString_Check(arg) ) { + PyErr_SetString(PyExc_TypeError, + "incorrect input type, require string"); + return NULL; + } + instring = PyString_AsString(arg); + len = PyString_GET_SIZE(arg); + + CHECK_LIMIT_ERROR(len); + + /* Copy the string into the buffer */ + memcpy(self->b_ptr + self->b_position, instring, len); + + /* Advance the position */ + self->b_position += len; + + Py_RETURN_NONE; +} + + + + +/* =========================================================================== + * Buffer protocol methods + */ + +/* + * Returns the buffer for reading or writing. Important! We only + * deliver the portion in the active window. + */ +static Py_ssize_t +hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) +{ + if ( idx != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent hotbuf segment"); + return -1; + } + + *pp = self->b_ptr + self->b_position; + return self->b_limit - self->b_position; +} + +static Py_ssize_t +hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) +{ + if (lenp) + *lenp = self->b_capacity; + return 1; +} + +static Py_ssize_t +hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) +{ + return hotbuf_getwritebuf(self, idx, (void**)pp); +} + + + +/* =========================================================================== + * Sequence methods + */ + +static Py_ssize_t +hotbuf_length(PyHotbufObject *self) +{ + /* Note: this is the same as 'remaining'. */ + assert(self->b_position <= self->b_limit); + return self->b_limit - self->b_position; +} + + + +/* =========================================================================== + * Object interfaces declaration + */ + + +PyDoc_STRVAR(hotbuf_doc, +"hotbuf(capacity) -> hotbuf\n\ +\n\ +Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ +\n\ +hotbuf is a C encapsulation of a fixed-size buffer of bytes in memory.\n\ +One can read and write objects of different primitive types directly\n\ +into it, without having to convert from/to strings. Also, this is\n\ +meant for the network I/O functions (recv, recvfrom, send, sendto) to\n\ +read/write directly into without having to create temporary strings.\n\ +\n\ +Note that hotbuf is a direct Python equivalent of Java's NIO\n\ +ByteBuffer class."); + + + +#define OFF(x) offsetof(PyHotbufObject, x) + +static PyMemberDef hotbuf_members[] = { + {"capacity", T_INT, OFF(b_capacity), RO, + "buffer's capacity, it's total allocated size"}, + {"position", T_INT, OFF(b_position), RO, + "buffer's position"}, + {"limit", T_INT, OFF(b_limit), RO, + "buffer's limit"}, + {"mark", T_INT, OFF(b_mark), RO, + "buffer's mark, -1 if not set"}, + {NULL} /* Sentinel */ +}; + +static PyMethodDef +hotbuf_methods[] = { + {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, + {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, + {"advance", (PyCFunction)hotbuf_advance, METH_O, advance__doc__}, + {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, + {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, + {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, + {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, + {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, + {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, + {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, get__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, + {"getstr", (PyCFunction)hotbuf_getstr, METH_VARARGS, getstr__doc__}, + {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, + {NULL, NULL} /* sentinel */ +}; + +static PySequenceMethods hotbuf_as_sequence = { + (lenfunc)hotbuf_length, /*sq_length*/ + 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ + 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ + 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ + 0 /*(ssizessizeargfunc)hotbuf_slice*/, /*sq_slice*/ + 0 /*(ssizeobjargproc)hotbuf_ass_item*/, /*sq_ass_item*/ + 0 /*(ssizessizeobjargproc)hotbuf_ass_slice*/, /*sq_ass_slice*/ +}; + +static PyBufferProcs hotbuf_as_buffer = { + (readbufferproc)hotbuf_getwritebuf, + (writebufferproc)hotbuf_getwritebuf, + (segcountproc)hotbuf_getsegcount, + (charbufferproc)hotbuf_getcharbuf, +}; + +static PyTypeObject PyHotbuf_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "_hotbuf._hotbuf", + sizeof(PyHotbufObject), + 0, + (destructor)hotbuf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)hotbuf_compare, /* tp_compare */ + (reprfunc)hotbuf_repr, /* tp_repr */ + 0, /* tp_as_number */ + &hotbuf_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)hotbuf_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + &hotbuf_as_buffer, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + hotbuf_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + hotbuf_methods, /* tp_methods */ + hotbuf_members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + hotbuf_new, /* tp_new */ + PyObject_Del, /* tp_free */ +}; + + + +/* =========================================================================== + * Install Module + */ + +PyDoc_STRVAR(module_doc, + "This module defines an object type which can represent a fixed size\n\ +buffer of bytes in momery, from which you can directly read and into\n\ +which you can directly write objects in various other types. This is\n\ +used to avoid buffer copies in network I/O as much as possible. For\n\ +example, socket recv() can directly fill a byte buffer's memory and\n\ +send() can read the data to be sent from one as well.\n\ +\n\ +In addition, a byte buffer has two pointers within it, that delimit\n\ +an active slice, the current \"position\" and the \"limit\". The\n\ +active region of a byte buffer is located within these boundaries.\n\ +\n\ +This class is heaviliy inspired from Java's NIO Hotbuffer class.\n\ +\n\ +The constructor is:\n\ +\n\ +hotbuf(nbytes) -- create a new hotbuf\n\ +"); + + +/* No functions in array module. */ +static PyMethodDef a_methods[] = { + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + + +PyMODINIT_FUNC +init_hotbuf(void) +{ + PyObject *m; + + PyHotbuf_Type.ob_type = &PyType_Type; + m = Py_InitModule3("_hotbuf", a_methods, module_doc); + if (m == NULL) + return; + + Py_INCREF((PyObject *)&PyHotbuf_Type); + PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); + Py_INCREF((PyObject *)&PyHotbuf_Type); + PyModule_AddObject(m, "_hotbuf", (PyObject *)&PyHotbuf_Type); +} + Added: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/README.txt Fri May 26 15:27:08 2006 @@ -0,0 +1,113 @@ +====================================================================== + Fast I/O Buffers for Network Access Without Copy/String Creation +====================================================================== + +:Updated Revision: 46090, 46193, 46211, 46281, 46284, 46295, 46311 +:Author: Martin Blais +:Abstract: + + A buffer class similar to Java NIO ByteBuffer that is meant to be used for + network I/O that avoids creating temporary strings and from which binary data + can be directly decoded. + + + +* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC + +* We need to make the client more easily remove the calls to remaining() + +* FIXME make it possible to read from a file directly into a hotbuf!! + +* Write a smallish PEP about it +* Measure performance results before all of this +* Move the branch to the sandbox + +* FIXME we need to find a way to automatically advance position without doing it + in Python + +* FIXME remove Py_XDECREF where possible + +* FIXME implement the file protocol (read(), write()) on the buffer object + +* We need to be able to convert from ascii formats, e.g. long with an offset + (Runar, the long conversions) + +* Change the mark stuff + + * setmark() to save both the position and limit + * remove the special behaviours of the mark being discarded + * reset() should reset both the position and the limit + * setmark() becomes push(), reset() becomes pop() + + + +For reading from and writing to network buffers. + +Look at: + +* Java ByteBuffer class +* SocketChannel +* nio classes + + +Maybe rename to ?seribuf?, or ?netbuf?? + + +TODO +==== +- How do we automatically advance the pointer on pack and unpack? + + +- Add hash function +- Add support for some of the other sequence methods. +- Perhaps implement returning the buffer object itself from some of + the methods in order to allow chaining of operations on a single line. +- Implement a resize function +- Maybe remove the API methods declared at the top. +- Add support for big vs. little endian + + +Pending Issues +============== +- Should we support weakrefs? + + +Java NIO / ByteBuffer +===================== + +We need to provide position/limit/mark/reset + + A buffer is a linear, finite sequence of elements of a specific primitive + type. Aside from its content, the essential properties of a buffer are its + capacity, limit, and position: + + A buffer's capacity is the number of elements it contains. The capacity of a + buffer is never negative and never changes. + + A buffer's limit is the index of the first element that should not be read + or written. A buffer's limit is never negative and is never greater than its + capacity. + + A buffer's position is the index of the next element to be read or + written. A buffer's position is never negative and is never greater than its + limit. + + +Invariants +---------- + +The following invariant holds for the mark, position, limit, and capacity values: + + 0 <= mark <= position <= limit <= capacity + +A newly-created buffer always has a position of zero and a mark that is +undefined. The initial limit may be zero, or it may be some other value that +depends upon the type of the buffer and the manner in which it is +constructed. The initial content of a buffer is, in general, undefined. + +Implementation +-------------- + +* Write extensive documentation + + Added: sandbox/trunk/hotbuffer/hotbuf.py ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/hotbuf.py Fri May 26 15:27:08 2006 @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +""" +A buffer class for fast I/O. +""" + +from _hotbuf import _hotbuf +from struct import Struct + +_long = Struct('l') + +class hotbuf(_hotbuf): + + def pack( self, structobj, *values ): + """ + Pack using the given Struct object 'structobj', the remaining arguments. + """ + structobj.pack_to(self, 0, *values) + self.advance(structobj.size) + + def unpack( self, structobj ): + """ + Pack using the given Struct object 'structobj', the remaining arguments. + """ + values = structobj.unpack_from(self, 0) + self.advance(structobj.size) + return values + + Added: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 15:27:08 2006 @@ -0,0 +1,201 @@ +# Test the hotbuf module. +# +# $Id$ +# +# Copyright (C) 2006 Martin Blais +# Licensed to PSF under a Contributor Agreement. +# + +from hotbuf import hotbuf +from struct import Struct +import unittest +from test import test_support + + +CAPACITY = 1024 +MSG = 'Martin Blais was here scribble scribble.' +# Note: we don't use floats because comparisons will cause precision errors due +# to the binary conversion. +fmt = Struct('llci') + +class HotbufTestCase(unittest.TestCase): + + def test_base( self ): + # Create a new hotbuf + self.assertRaises(ValueError, hotbuf, -1) + self.assertRaises(ValueError, hotbuf, 0) + b = hotbuf(CAPACITY) + self.assertEquals(len(b), CAPACITY) + self.assertEquals(b.capacity, CAPACITY) + + # Play with the position + assert b.position == 0 + b.setposition(10) + self.assertEquals(b.position, 10) + self.assertRaises(IndexError, b.setposition, CAPACITY + 1) + + # Play with the limit + assert b.limit == CAPACITY + b.setlimit(CAPACITY - 10) + self.assertEquals(b.limit, CAPACITY - 10) + self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + b.setlimit(b.position - 1) + self.assertEquals(b.position, b.limit) + + # Play with reset before the mark has been set. + self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + + # Play with the mark + b.setposition(10) + b.setlimit(100) + b.setmark() + b.setposition(15) + self.assertEquals(b.mark, 10) + + # Play with clear + b.clear() + self.assertEquals((b.position, b.limit, b.mark), + (0, CAPACITY, -1)) + + # Play with flip. + b.setposition(42) + b.setlimit(104) + b.setmark() + b.flip() + self.assertEquals((b.position, b.limit, b.mark), + (0, 42, -1)) + + # Play with rewind. + b.setposition(42) + b.setlimit(104) + b.setmark() + b.rewind() + self.assertEquals((b.position, b.limit, b.mark), + (0, 104, -1)) + + # Play with remaining. + self.assertEquals(b.remaining(), 104) + b.setposition(10) + self.assertEquals(b.remaining(), 94) + + # Play with advance. + self.assertEquals(b.position, 10) + b.advance(32) + self.assertEquals(b.position, 42) + + self.assertRaises(IndexError, b.advance, CAPACITY) + + def test_compact( self ): + b = hotbuf(CAPACITY) + + b.setposition(100) + b.setlimit(200) + m = b.mark + b.compact() + self.assertEquals((b.position, b.limit, b.mark), + (100, CAPACITY, -1)) + + # Compare the text that gets compacted. + b.clear() + b.setposition(100) + b.putstr(MSG) + b.setposition(100) + b.compact() + self.assertEquals(str(b), MSG) + + def test_byte( self ): + b = hotbuf(256) + + # Fill up the buffer with bytes. + for x in xrange(256): + b.putbyte(x) + + # Test overflow. + self.assertRaises(IndexError, b.putbyte, 42) + + # Read all data from the buffer. + b.flip() + for x in xrange(256): + nx = b.getbyte() + assert nx == x + + # Test underflow. + self.assertRaises(IndexError, b.putbyte, 42) + + def test_str( self ): + b = hotbuf(256) + + # Write into the buffer + b.putstr(MSG) + b.flip() + + # Read back and assert message + self.assertEquals(b.getstr(len(MSG)), MSG) + + # Test overflow. + b.flip() + self.assertRaises(IndexError, b.putstr, ' ' * 1000) + + # Test underflow. + self.assertRaises(IndexError, b.getstr, 1000) + + # Test getting the rest of the string. + b.clear() + b.putstr(MSG) + b.flip() + s = b.getstr() + self.assertEquals(s, MSG) + + def test_conversion( self ): + b = hotbuf(CAPACITY) + + b.setposition(100) + b.setlimit(132) + + self.assertEquals(len(b), 32) + s = str(b) + self.assertEquals(len(s), 32) + + r = repr(b) + self.assert_(r.startswith(' Author: martin.blais Date: Fri May 26 15:28:03 2006 New Revision: 46324 Removed: sandbox/trunk/hotbuf/ Log: Removing hotbuf sandbox project as full python repo copy. From python-checkins at python.org Fri May 26 15:39:18 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 15:39:18 +0200 (CEST) Subject: [Python-checkins] r46325 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060526133918.3A74C1E400C@bag.python.org> Author: tim.peters Date: Fri May 26 15:39:17 2006 New Revision: 46325 Modified: python/trunk/Lib/test/test_tarfile.py Log: Use open() to open files (was using file()). Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Fri May 26 15:39:17 2006 @@ -87,7 +87,7 @@ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = file(os.path.join(dirname(), filename), "rU").readlines() + lines1 = open(os.path.join(dirname(), filename), "rU").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") @@ -97,7 +97,7 @@ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = file(os.path.join(dirname(), filename), "rU").readlines() + lines1 = open(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") @@ -108,7 +108,7 @@ if self.sep != "|": filename = "0-REGTYPE" self.tar.extract(filename, dirname()) - data = file(os.path.join(dirname(), filename), "rb").read() + data = open(os.path.join(dirname(), filename), "rb").read() tarinfo = self.tar.getmember(filename) fobj = self.tar.extractfile(tarinfo) @@ -156,7 +156,7 @@ tarinfo = tarfile.TarInfo("directory/") tarinfo.type = tarfile.REGTYPE - fobj = file(filename, "w") + fobj = open(filename, "w") fobj.write(tarinfo.tobuf()) fobj.close() @@ -286,10 +286,10 @@ def test_file(self): path = os.path.join(self.tmpdir, "file") - file(path, "w") + open(path, "w") tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 0) - file(path, "w").write("aaa") + open(path, "w").write("aaa") tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 3) @@ -440,7 +440,7 @@ self.assert_(tarinfo.linkname == name, "linkname wrong") def test_truncated_longname(self): - fobj = StringIO.StringIO(file(tarname()).read(1024)) + fobj = StringIO.StringIO(open(tarname()).read(1024)) tar = tarfile.open(name="foo.tar", fileobj=fobj) self.assert_(len(tar.getmembers()) == 0, "") @@ -480,7 +480,7 @@ if os.path.exists(self.bar): os.remove(self.bar) - file(self.foo, "w").write("foo") + open(self.foo, "w").write("foo") self.tar.add(self.foo) def test_add_twice(self): @@ -565,10 +565,10 @@ def test_main(): if gzip: # create testtar.tar.gz - gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) + gzip.open(tarname("gz"), "wb").write(open(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 - bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) + bz2.BZ2File(tarname("bz2"), "wb").write(open(tarname(), "rb").read()) tests = [ FileModeTest, From python-checkins at python.org Fri May 26 15:55:38 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 15:55:38 +0200 (CEST) Subject: [Python-checkins] r46326 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060526135538.E30B91E400C@bag.python.org> Author: andrew.dalke Date: Fri May 26 15:55:38 2006 New Revision: 46326 Modified: sandbox/trunk/stringbench/stringbench.py Log: benchmark tests for a single split Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Fri May 26 15:55:38 2006 @@ -339,6 +339,24 @@ for x in _RANGE_1000: s_rsplit() + at bench('("Here are some words. "*2).split(None, 1)', + "split 1 whitespace", 1000) +def whitespace_split_1(STR): + s = STR("Here are some words. "*2) + s_split = s.split + N = None + for x in _RANGE_1000: + s_split(N, 1) + + at bench('("Here are some words. "*2).rsplit(None, 1)', + "split 1 whitespace", 1000) +def whitespace_rsplit_1(STR): + s = STR("Here are some words. "*2) + s_rsplit = s.rsplit + N = None + for x in _RANGE_1000: + s_rsplit(N, 1) + human_text = """\ Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support From python-checkins at python.org Fri May 26 16:00:46 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 16:00:46 +0200 (CEST) Subject: [Python-checkins] r46327 - python/trunk/Objects/stringobject.c Message-ID: <20060526140046.6EA9C1E4023@bag.python.org> Author: andrew.dalke Date: Fri May 26 16:00:45 2006 New Revision: 46327 Modified: python/trunk/Objects/stringobject.c Log: Changes to string.split/rsplit on whitespace to preallocate space in the results list. Originally it allocated 0 items and used the list growth during append. Now it preallocates 12 items so the first few appends don't need list reallocs. ("Here are some words ."*2).split(None, 1) is 7% faster ("Here are some words ."*2).split() is is 15% faster (Your milage may vary, see dealership for details.) File parsing like this for line in f: count += len(line.split()) is also about 15% faster. There is a slowdown of about 3% for large strings because of the additional overhead of checking if the append is to a preallocated region of the list or not. This will be the rare case. It could be improved with special case code but we decided it was not useful enough. There is a cost of 12*sizeof(PyObject *) bytes per list. For the normal case of file parsing this is not a problem because of the lists have a short lifetime. We have not come up with cases where this is a problem in real life. I chose 12 because human text averages about 11 words per line in books, one of my data sets averages 6.2 words with a final peak at 11 words per line, and I work with a tab delimited data set with 8 tabs per line (or 9 words per line). 12 encompasses all of these. Also changed the last rstrip code to append then reverse, rather than doing insert(0). The strip() and rstrip() times are now comparable. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 16:00:45 2006 @@ -1434,6 +1434,20 @@ #define STRIPNAME(i) (stripformat[i]+3) + +/* Overallocate the initial list to reduce the number of reallocs for small + split sizes. Eg, "A A A A A A A A A A".split() (10 elements) has three + resizes, to sizes 4, 8, then 16. Most observed string splits are for human + text (roughly 11 words per line) and field delimited data (usually 1-10 + fields). For large strings the split algorithms are bandwidth limited + so increasing the preallocation likely will not improve things.*/ + +#define MAX_PREALLOC 12 + +/* 5 splits gives 6 elements */ +#define PREALLOC_SIZE(maxsplit) \ + (maxsplit >= MAX_PREALLOC ? MAX_PREALLOC : maxsplit+1) + #define SPLIT_APPEND(data, left, right) \ str = PyString_FromStringAndSize((data) + (left), \ (right) - (left)); \ @@ -1446,12 +1460,32 @@ else \ Py_DECREF(str); +#define SPLIT_ADD(data, left, right) \ + str = PyString_FromStringAndSize((data) + (left), \ + (right) - (left)); \ + if (str == NULL) \ + goto onError; \ + if (count < MAX_PREALLOC) { \ + PyList_SET_ITEM(list, count, str); \ + } else { \ + if (PyList_Append(list, str)) { \ + Py_DECREF(str); \ + goto onError; \ + } \ + else \ + Py_DECREF(str); \ + } \ + count++; + +/* Always force the list to the expected size. */ +#define FIX_PREALLOC_SIZE(list) ((PyListObject *)list)->ob_size = count; + static PyObject * split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { - Py_ssize_t i, j; + Py_ssize_t i, j, count=0; PyObject *str; - PyObject *list = PyList_New(0); + PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit)); if (list == NULL) return NULL; @@ -1465,15 +1499,16 @@ if (j < i) { if (maxsplit-- <= 0) break; - SPLIT_APPEND(s, j, i); + SPLIT_ADD(s, j, i); while (i < len && isspace(Py_CHARMASK(s[i]))) i++; j = i; } } if (j < len) { - SPLIT_APPEND(s, j, len); + SPLIT_ADD(s, j, len); } + FIX_PREALLOC_SIZE(list); return list; onError: Py_DECREF(list); @@ -1483,25 +1518,27 @@ static PyObject * split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { - register Py_ssize_t i, j; + register Py_ssize_t i, j, count=0; PyObject *str; - PyObject *list = PyList_New(0); + PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); if (list == NULL) return NULL; for (i = j = 0; i < len; ) { + /* TODO: Use findchar/memchr for this? */ if (s[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_APPEND(s, j, i); + SPLIT_ADD(s, j, i); i = j = i + 1; } else i++; } if (j <= len) { - SPLIT_APPEND(s, j, len); + SPLIT_ADD(s, j, len); } + FIX_PREALLOC_SIZE(list); return list; onError: @@ -1521,10 +1558,9 @@ string_split(PyStringObject *self, PyObject *args) { Py_ssize_t len = PyString_GET_SIZE(self), n, i, j; - int err; - Py_ssize_t maxsplit = -1; + Py_ssize_t maxsplit = -1, count=0; const char *s = PyString_AS_STRING(self), *sub; - PyObject *list, *item, *subobj = Py_None; + PyObject *list, *str, *subobj = Py_None; if (!PyArg_ParseTuple(args, "|On:split", &subobj, &maxsplit)) return NULL; @@ -1550,38 +1586,27 @@ else if (n == 1) return split_char(s, len, sub[0], maxsplit); - list = PyList_New(0); + list = PyList_New(PREALLOC_SIZE(maxsplit)); if (list == NULL) return NULL; i = j = 0; while (i+n <= len) { + /* TODO: Use Py_STRING_MATCH */ if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { if (maxsplit-- <= 0) break; - item = PyString_FromStringAndSize(s+j, i-j); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; + SPLIT_ADD(s, j, i); i = j = i + n; } else i++; } - item = PyString_FromStringAndSize(s+j, len-j); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; - + SPLIT_ADD(s, j, len); + FIX_PREALLOC_SIZE(list); return list; - fail: + onError: Py_DECREF(list); return NULL; } @@ -1648,9 +1673,9 @@ static PyObject * rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { - Py_ssize_t i, j; + Py_ssize_t i, j, count=0; PyObject *str; - PyObject *list = PyList_New(0); + PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit)); if (list == NULL) return NULL; @@ -1664,15 +1689,16 @@ if (j > i) { if (maxsplit-- <= 0) break; - SPLIT_APPEND(s, i + 1, j + 1); + SPLIT_ADD(s, i + 1, j + 1); while (i >= 0 && isspace(Py_CHARMASK(s[i]))) i--; j = i; } } if (j >= 0) { - SPLIT_APPEND(s, 0, j + 1); + SPLIT_ADD(s, 0, j + 1); } + FIX_PREALLOC_SIZE(list); if (PyList_Reverse(list) < 0) goto onError; return list; @@ -1684,9 +1710,9 @@ static PyObject * rsplit_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { - register Py_ssize_t i, j; + register Py_ssize_t i, j, count=0; PyObject *str; - PyObject *list = PyList_New(0); + PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); if (list == NULL) return NULL; @@ -1695,14 +1721,15 @@ if (s[i] == ch) { if (maxcount-- <= 0) break; - SPLIT_APPEND(s, i + 1, j + 1); + SPLIT_ADD(s, i + 1, j + 1); j = i = i - 1; } else i--; } if (j >= -1) { - SPLIT_APPEND(s, 0, j + 1); + SPLIT_ADD(s, 0, j + 1); } + FIX_PREALLOC_SIZE(list); if (PyList_Reverse(list) < 0) goto onError; return list; @@ -1725,10 +1752,9 @@ string_rsplit(PyStringObject *self, PyObject *args) { Py_ssize_t len = PyString_GET_SIZE(self), n, i, j; - int err; - Py_ssize_t maxsplit = -1; + Py_ssize_t maxsplit = -1, count=0; const char *s = PyString_AS_STRING(self), *sub; - PyObject *list, *item, *subobj = Py_None; + PyObject *list, *str, *subobj = Py_None; if (!PyArg_ParseTuple(args, "|On:rsplit", &subobj, &maxsplit)) return NULL; @@ -1754,7 +1780,7 @@ else if (n == 1) return rsplit_char(s, len, sub[0], maxsplit); - list = PyList_New(0); + list = PyList_New(PREALLOC_SIZE(maxsplit)); if (list == NULL) return NULL; @@ -1764,30 +1790,20 @@ if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { if (maxsplit-- <= 0) break; - item = PyString_FromStringAndSize(s+i+n, j-i-n); - if (item == NULL) - goto fail; - err = PyList_Insert(list, 0, item); - Py_DECREF(item); - if (err < 0) - goto fail; + SPLIT_ADD(s, i+n, j); j = i; i -= n; } else i--; } - item = PyString_FromStringAndSize(s, j); - if (item == NULL) - goto fail; - err = PyList_Insert(list, 0, item); - Py_DECREF(item); - if (err < 0) - goto fail; - + SPLIT_ADD(s, 0, j); + FIX_PREALLOC_SIZE(list); + if (PyList_Reverse(list) < 0) + goto onError; return list; - fail: +onError: Py_DECREF(list); return NULL; } @@ -3925,6 +3941,9 @@ } #undef SPLIT_APPEND +#undef SPLIT_ADD +#undef MAX_PREALLOC +#undef PREALLOC_SIZE static PyObject * string_getnewargs(PyStringObject *v) From python-checkins at python.org Fri May 26 16:02:05 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 16:02:05 +0200 (CEST) Subject: [Python-checkins] r46328 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060526140205.91B171E400D@bag.python.org> Author: tim.peters Date: Fri May 26 16:02:05 2006 New Revision: 46328 Modified: python/trunk/Lib/test/test_tarfile.py Log: Explicitly close files. I'm trying to stop the frequent spurious test_tarfile failures on Windows buildbots, but it's hard to know how since the regrtest failure output is useless here, and it never fails when a buildbot slave runs test_tarfile the second time in verbose mode. Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Fri May 26 16:02:05 2006 @@ -87,7 +87,9 @@ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = open(os.path.join(dirname(), filename), "rU").readlines() + f = open(os.path.join(dirname(), filename), "rU") + lines1 = f.readlines() + f.close() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") @@ -97,7 +99,9 @@ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = open(os.path.join(dirname(), filename), "rU").readlines() + f = open(os.path.join(dirname(), filename), "rU") + lines1 = f.readlines() + f.close() lines2 = [line for line in self.tar.extractfile(filename)] self.assert_(lines1 == lines2, "ExFileObject iteration does not work correctly") @@ -108,7 +112,9 @@ if self.sep != "|": filename = "0-REGTYPE" self.tar.extract(filename, dirname()) - data = open(os.path.join(dirname(), filename), "rb").read() + f = open(os.path.join(dirname(), filename), "rb") + data = f.read() + f.close() tarinfo = self.tar.getmember(filename) fobj = self.tar.extractfile(tarinfo) @@ -210,6 +216,7 @@ self.assert_(v2 is not None, "stream.extractfile() failed") self.assert_(v1.read() == v2.read(), "stream extraction failed") + tar.close() stream.close() class ReadDetectTest(ReadTest): @@ -286,10 +293,13 @@ def test_file(self): path = os.path.join(self.tmpdir, "file") - open(path, "w") + f = open(path, "w") + f.close() tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 0) - open(path, "w").write("aaa") + f = open(path, "w") + f.write("aaa") + f.close() tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 3) @@ -440,9 +450,12 @@ self.assert_(tarinfo.linkname == name, "linkname wrong") def test_truncated_longname(self): - fobj = StringIO.StringIO(open(tarname()).read(1024)) + f = open(tarname()) + fobj = StringIO.StringIO(f.read(1024)) + f.close() tar = tarfile.open(name="foo.tar", fileobj=fobj) self.assert_(len(tar.getmembers()) == 0, "") + tar.close() class ExtractHardlinkTest(BaseTest): @@ -480,7 +493,9 @@ if os.path.exists(self.bar): os.remove(self.bar) - open(self.foo, "w").write("foo") + f = open(self.foo, "w") + f.write("foo") + f.close() self.tar.add(self.foo) def test_add_twice(self): @@ -563,12 +578,20 @@ del WriteStreamTestGzip def test_main(): + # Create archive. + f = open(tarname(), "rb") + fguts = f.read() + f.close() if gzip: # create testtar.tar.gz - gzip.open(tarname("gz"), "wb").write(open(tarname(), "rb").read()) + tar = gzip.open(tarname("gz"), "wb") + tar.write(fguts) + tar.close() if bz2: # create testtar.tar.bz2 - bz2.BZ2File(tarname("bz2"), "wb").write(open(tarname(), "rb").read()) + tar = bz2.BZ2File(tarname("bz2"), "wb") + tar.write(fguts) + tar.close() tests = [ FileModeTest, From python-checkins at python.org Fri May 26 16:03:41 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 16:03:41 +0200 (CEST) Subject: [Python-checkins] r46329 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060526140341.8D5071E400C@bag.python.org> Author: andrew.kuchling Date: Fri May 26 16:03:41 2006 New Revision: 46329 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add buffer support for struct, socket Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri May 26 16:03:41 2006 @@ -1495,20 +1495,52 @@ In Python code, netlink addresses are represented as a tuple of 2 integers, \code{(\var{pid}, \var{group_mask})}. -Socket objects also gained accessor methods \method{getfamily()}, -\method{gettype()}, and \method{getproto()} methods to retrieve the -family, type, and protocol values for the socket. +Two new methods on socket objects, \method{recv_buf(\var{buffer})} and +\method{recvfrom_buf(\var{buffer})}, store the received data in an object +that supports the buffer protocol instead of returning the data as a +string. This means you can put the data directly into an array or a +memory-mapped file. + +Socket objects also gained \method{getfamily()}, \method{gettype()}, +and \method{getproto()} accessor methods to retrieve the family, type, +and protocol values for the socket. \item New module: the \module{spwd} module provides functions for accessing the shadow password database on systems that support shadow passwords. +\Item The \module{struct} is now faster because it +compiles format strings into \class{Struct} objects +with \method{pack()} and \method{unpack()} methods. This is similar +to how the \module{re} module lets you create compiled regular +expression objects. You can still use the module-level +\function{pack()} and \function{unpack()} functions; they'll create +\class{Struct} objects and cache them. Or you can use +\class{Struct} instances directly: + +\begin{verbatim} +s = struct.Struct('ih3s') + +data = s.pack(1972, 187, 'abc') +year, number, name = s.unpack(data) +\end{verbatim} + +You can also pack and unpack data to and from buffer objects directly +using the \method{pack_to(\var{buffer}, \var{offset}, \var{v1}, +\var{v2}, ...)} and \method{unpack_from(\var{buffer}, \var{offset})} +methods. This lets you store data directly into an array or a +memory-mapped file. + +(\class{Struct} objects were implemented by Bob Ippolito at the +NeedForSpeed sprint. Support for buffer objects was added by Martin +Blais, also at the NeedForSpeed sprint.) + \item The Python developers switched from CVS to Subversion during the 2.5 -development process. Information about the exact build version is -available as the \code{sys.subversion} variable, a 3-tuple -of \code{(\var{interpreter-name}, \var{branch-name}, \var{revision-range})}. -For example, at the time of writing -my copy of 2.5 was reporting \code{('CPython', 'trunk', '45313:45315')}. +development process. Information about the exact build version is +available as the \code{sys.subversion} variable, a 3-tuple of +\code{(\var{interpreter-name}, \var{branch-name}, +\var{revision-range})}. For example, at the time of writing my copy +of 2.5 was reporting \code{('CPython', 'trunk', '45313:45315')}. This information is also available to C extensions via the \cfunction{Py_GetBuildInfo()} function that returns a From python-checkins at python.org Fri May 26 16:04:20 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 16:04:20 +0200 (CEST) Subject: [Python-checkins] r46330 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060526140420.797A41E400C@bag.python.org> Author: andrew.kuchling Date: Fri May 26 16:04:19 2006 New Revision: 46330 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Typo fix Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri May 26 16:04:19 2006 @@ -1509,7 +1509,7 @@ accessing the shadow password database on systems that support shadow passwords. -\Item The \module{struct} is now faster because it +\item The \module{struct} is now faster because it compiles format strings into \class{Struct} objects with \method{pack()} and \method{unpack()} methods. This is similar to how the \module{re} module lets you create compiled regular From python-checkins at python.org Fri May 26 16:07:24 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 16:07:24 +0200 (CEST) Subject: [Python-checkins] r46331 - in python/trunk: Lib/distutils/ccompiler.py Modules/_ctypes/libffi/fficonfig.py.in Message-ID: <20060526140724.0D8BB1E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 16:07:23 2006 New Revision: 46331 Modified: python/trunk/Lib/distutils/ccompiler.py python/trunk/Modules/_ctypes/libffi/fficonfig.py.in Log: Fix distutils so that libffi will cross-compile between darwin/x86 and darwin/ppc Modified: python/trunk/Lib/distutils/ccompiler.py ============================================================================== --- python/trunk/Lib/distutils/ccompiler.py (original) +++ python/trunk/Lib/distutils/ccompiler.py Fri May 26 16:07:23 2006 @@ -15,7 +15,6 @@ from distutils.file_util import move_file from distutils.dir_util import mkpath from distutils.dep_util import newer_pairwise, newer_group -from distutils.sysconfig import python_build from distutils.util import split_quoted, execute from distutils import log @@ -368,7 +367,7 @@ # Get the list of expected output (object) files objects = self.object_filenames(sources, - strip_dir=python_build, + strip_dir=0, output_dir=outdir) assert len(objects) == len(sources) @@ -475,8 +474,7 @@ which source files can be skipped. """ # Get the list of expected output (object) files - objects = self.object_filenames(sources, strip_dir=python_build, - output_dir=output_dir) + objects = self.object_filenames(sources, output_dir=output_dir) assert len(objects) == len(sources) if self.force: Modified: python/trunk/Modules/_ctypes/libffi/fficonfig.py.in ============================================================================== --- python/trunk/Modules/_ctypes/libffi/fficonfig.py.in (original) +++ python/trunk/Modules/_ctypes/libffi/fficonfig.py.in Fri May 26 16:07:23 2006 @@ -29,7 +29,7 @@ # Build all darwin related files on all supported darwin architectures, this # makes it easier to build universal binaries. -if 0: +if 1: all_darwin = ('X86_DARWIN', 'POWERPC_DARWIN') all_darwin_files = [] for pn in all_darwin: From python-checkins at python.org Fri May 26 16:21:03 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 16:21:03 +0200 (CEST) Subject: [Python-checkins] r46332 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526142103.6E5371E400E@bag.python.org> Author: richard.jones Date: Fri May 26 16:21:02 2006 New Revision: 46332 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: fix object initialisation Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 16:21:02 2006 @@ -3,6 +3,8 @@ #include "structmember.h" #include "osdefs.h" +#define MAKE_IT_NONE(x) (x) = Py_None; Py_INCREF(Py_None); + /* * BaseException */ @@ -20,47 +22,28 @@ in the tp_getattr... slots. */ -static int -_BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) -{ - if (!args) { - self->args = PyTuple_New(0); - if (!self->args) { - return -1; - } - } - else { - self->args = args; - Py_INCREF(self->args); - } - - if (PySequence_Length(self->args) == 1) - self->message = PySequence_GetItem(self->args, 0); - else - self->message = PyString_FromString(""); - if (!self->message) { - return -1; - } - - return 0; -} - static PyObject * BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { BaseExceptionObject *self; self = (BaseExceptionObject *)type->tp_alloc(type, 0); + self->args = self->message = self->dict = NULL; - self->args = self->message = NULL; + self->args = PyTuple_New(0); + if (!self->args) { + Py_DECREF(self); + return NULL; + } - self->dict = PyDict_New(); - if (self->dict == NULL) { + self->message = PyString_FromString(""); + if (!self->message) { Py_DECREF(self); return NULL; } - if (_BaseException_init(self, args, kwds) == -1) { + self->dict = PyDict_New(); + if (self->dict == NULL) { Py_DECREF(self); return NULL; } @@ -71,7 +54,18 @@ static int BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) { - return _BaseException_init(self, args, kwds); + if (args) { + Py_DECREF(self->args); + self->args = args; + Py_INCREF(self->args); + } + + if (PySequence_Length(self->args) == 1) { + Py_DECREF(self->message); + self->message = PySequence_GetItem(self->args, 0); + } + + return 0; } static void @@ -115,15 +109,6 @@ return out; } - -#ifdef Py_USING_UNICODE -static PyObject * -BaseException_unicode(BaseExceptionObject *self) -{ - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ - static PyObject * BaseException_repr(BaseExceptionObject *self) { @@ -185,13 +170,6 @@ {NULL} /* Sentinel */ }; -static PyMethodDef BaseException_methods[] = { -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif - {NULL, NULL, 0, NULL}, -}; - static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ @@ -221,7 +199,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BaseException_methods, /* tp_methods */ + 0, /* tp_methods */ BaseException_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -229,7 +207,7 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(BaseExceptionObject, dict), /* tp_dictoffset */ - 0, /* tp_init */ + (initproc)BaseException_init, /* tp_init */ 0, /* tp_alloc */ BaseException_new, /* tp_new */ }; @@ -268,7 +246,7 @@ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; -#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \ +#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMEMBERS, EXCSTR, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ @@ -278,7 +256,7 @@ (reprfunc)EXCSTR, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ PyDoc_STR(EXCDOC), \ - 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ + 0, 0, 0, 0, 0, 0, 0, EXCMEMBERS, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -328,24 +306,6 @@ PyObject *code; } SystemExitObject; -static int -_SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) -{ - Py_ssize_t size = PySequence_Length(args); - - if (size == 1) - self->code = PySequence_GetItem(args, 0); - else if (size > 1) { - self->code = args; - Py_INCREF(Py_None); - } - else { - self->code = Py_None; - Py_INCREF(Py_None); - } - return 0; -} - static PyObject * SystemExit_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -355,10 +315,8 @@ if (!self) return NULL; - if (_SystemExit_init(self, args, kwds) == -1) { - Py_DECREF(self); - return NULL; - } + self->code = Py_None; + Py_INCREF(Py_None); return (PyObject *)self; } @@ -366,9 +324,21 @@ static int SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + Py_ssize_t size = PySequence_Length(args); + + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) return -1; - return _SystemExit_init(self, args, kwds); + + if (size == 1) { + Py_DECREF(self->code); + self->code = PySequence_GetItem(args, 0); + } + else if (size > 1) { + Py_DECREF(self->code); + self->code = args; + Py_INCREF(args); + } + return 0; } static void @@ -388,7 +358,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, "Request to exit from the interpreter."); +ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, SystemExit_members, 0, "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException @@ -415,6 +385,26 @@ PyObject *filename; } EnvironmentErrorObject; + +static PyObject * +EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + EnvironmentErrorObject *self = NULL; + + self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; + + self->myerrno = Py_None; + Py_INCREF(Py_None); + self->strerror = Py_None; + Py_INCREF(Py_None); + self->filename = Py_None; + Py_INCREF(Py_None); + + return (PyObject *)self; +} + /* Where a function has a single filename, such as open() or some * of the os module functions, PyErr_SetFromErrnoWithFilename() is * called, giving a third argument which is the filename. But, so @@ -427,12 +417,15 @@ * when it was supplied. */ static int -_EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, +EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL; PyObject *subslice = NULL; + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; + if (PySequence_Length(args) <= 1) { return 0; } @@ -464,37 +457,6 @@ return 0; } -static PyObject * -EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - EnvironmentErrorObject *self = NULL; - - self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - self->myerrno = Py_None; - Py_INCREF(Py_None); - self->strerror = Py_None; - Py_INCREF(Py_None); - self->filename = Py_None; - Py_INCREF(Py_None); - - if (_EnvironmentError_init(self, args, kwds) == -1) { - return NULL; - } - return (PyObject *)self; -} - -static int -EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, - PyObject *kwds) -{ - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) - return -1; - return _EnvironmentError_init(self, args, kwds); -} - static void EnvironmentError_dealloc(EnvironmentErrorObject *self) { @@ -572,7 +534,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, 0, EnvironmentError_members, EnvironmentError_str, "Base class for I/O related errors."); +ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_members, EnvironmentError_str, "Base class for I/O related errors."); /* @@ -734,7 +696,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, EnvironmentError_dealloc, 0, WindowsError_members, WindowsError_str, "MS-Windows OS system call failed."); +ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, EnvironmentError_dealloc, WindowsError_members, WindowsError_str, "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ @@ -796,67 +758,69 @@ PyObject *print_file_and_line; } SyntaxErrorObject; +static PyObject * +SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + SyntaxErrorObject *self = NULL; + + self = (SyntaxErrorObject *)BaseException_new(type, args, kwds); + if (!self) + return NULL; + + self->msg = self->filename = self->lineno = self->offset = + self->text = NULL; + + MAKE_IT_NONE(self->msg) + MAKE_IT_NONE(self->filename) + MAKE_IT_NONE(self->lineno) + MAKE_IT_NONE(self->offset) + MAKE_IT_NONE(self->text) + + /* this is always None - yes, I know it doesn't seem to be used + anywhere, but it was in the previous implementation */ + MAKE_IT_NONE(self->print_file_and_line) + + return (PyObject *)self; +} + static int -_SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) +SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *info = NULL; Py_ssize_t lenargs = PySequence_Length(args); + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + return -1; + if (lenargs >= 1) { PyObject *item0 = PySequence_GetItem(args, 0); if (!item0) return -1; + Py_DECREF(self->msg); self->msg = item0; } if (lenargs == 2) { info = PySequence_GetItem(args, 1); if (!info) return -1; + Py_DECREF(self->filename); self->filename = PySequence_GetItem(info, 0); if (!self->filename) return -1; + Py_DECREF(self->lineno); self->lineno = PySequence_GetItem(info, 1); if (!self->lineno) return -1; + Py_DECREF(self->offset); self->offset = PySequence_GetItem(info, 2); if (!self->offset) return -1; + Py_DECREF(self->text); self->text = PySequence_GetItem(info, 3); if (!self->text) return -1; } return 0; } -static PyObject * -SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - SyntaxErrorObject *self = NULL; - - self = (SyntaxErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - self->msg = self->filename = self->lineno = self->offset = - self->text = NULL; - - /* this is always None - yes, I know it doesn't seem to be used - anywhere, but it was in the previous implementation */ - self->print_file_and_line = Py_None; - Py_INCREF(Py_None); - - if (_SyntaxError_init(self, args, kwds) == -1) - return NULL; - - return (PyObject *)self; -} - -static int -SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) -{ - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) - return -1; - return _SyntaxError_init(self, args, kwds); -} - static void SyntaxError_dealloc(SyntaxErrorObject *self) { @@ -965,7 +929,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); +ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, SyntaxError_members, SyntaxError_str, "Invalid syntax."); /* @@ -1014,7 +978,7 @@ return BaseException_str(self); } -ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, 0, KeyError_str, "Mapping key not found."); +ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, KeyError_str, "Mapping key not found."); /* @@ -1290,40 +1254,16 @@ UnicodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) { UnicodeErrorObject *self; - Py_ssize_t n; self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; - self->encoding = self->object = self->start = self->end = - self->reason = NULL; - - n = PySequence_Length(args); - if (n == -1 && PyErr_Occurred()) { - Py_DECREF(self); - return NULL; - } - if (n == 0) - return (PyObject *)self; - - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &self->encoding, - objecttype, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { - self->encoding = self->object = self->start = self->end = - self->reason = NULL; - Py_DECREF(self); - return NULL; - } - - Py_INCREF(self->encoding); - Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); - Py_INCREF(self->reason); + MAKE_IT_NONE(self->encoding); + MAKE_IT_NONE(self->object); + MAKE_IT_NONE(self->start); + MAKE_IT_NONE(self->end); + MAKE_IT_NONE(self->reason); return (PyObject *)self; } @@ -1393,7 +1333,7 @@ static int UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyUnicode_Type); } @@ -1472,7 +1412,7 @@ static int UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) return -1; return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyString_Type); } @@ -1545,39 +1485,16 @@ UnicodeTranslateError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { UnicodeErrorObject *self = NULL; - Py_ssize_t n; self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; - self->encoding = self->object = self->start = self->end = - self->reason = NULL; - - n = PySequence_Length(args); - if (n == -1 && PyErr_Occurred()) { - Py_DECREF(self); - return NULL; - } - if (n == 0) - return (PyObject *)self; - - if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &self->object, - &PyInt_Type, &self->start, - &PyInt_Type, &self->end, - &PyString_Type, &self->reason)) { - self->object = self->start = self->end = self->reason = NULL; - Py_DECREF(self); - return NULL; - } - - self->encoding = Py_None; - Py_INCREF(self->encoding); - Py_INCREF(self->object); - Py_INCREF(self->start); - Py_INCREF(self->end); - Py_INCREF(self->reason); + MAKE_IT_NONE(self->encoding); + MAKE_IT_NONE(self->object); + MAKE_IT_NONE(self->start); + MAKE_IT_NONE(self->end); + MAKE_IT_NONE(self->reason); return (PyObject *)self; } @@ -1585,9 +1502,14 @@ static int UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) { - if (_BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) return -1; + Py_CLEAR(self->object); + Py_CLEAR(self->start); + Py_CLEAR(self->end); + Py_CLEAR(self->reason); + if (!PyArg_ParseTuple(args, "O!O!O!O!", &PyUnicode_Type, &self->object, &PyInt_Type, &self->start, @@ -1597,8 +1519,6 @@ return -1; } - self->encoding = Py_None; - Py_INCREF(self->encoding); Py_INCREF(self->object); Py_INCREF(self->start); Py_INCREF(self->end); @@ -1786,7 +1706,6 @@ {NULL, NULL} }; - #define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ Py_FatalError("exceptions bootstrapping error."); From python-checkins at python.org Fri May 26 16:23:22 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 16:23:22 +0200 (CEST) Subject: [Python-checkins] r46333 - python/trunk/Modules/_struct.c Message-ID: <20060526142322.35C4C1E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 16:23:21 2006 New Revision: 46333 Modified: python/trunk/Modules/_struct.c Log: Fix _struct typo that broke some 64-bit platforms Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 16:23:21 2006 @@ -519,7 +519,7 @@ #endif y = (unsigned int)x; #if defined(PY_STRUCT_RANGE_CHECKING) && (SIZEOF_LONG > SIZEOF_INT) - if (x < UINT_MIN || x > UINT_MAX) + if (x > UINT_MAX) return _range_error(f->format, sizeof(y), 1); #endif memcpy(p, (char *)&y, sizeof y); From python-checkins at python.org Fri May 26 16:24:53 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 16:24:53 +0200 (CEST) Subject: [Python-checkins] r46334 - sandbox/trunk/rjsh-pybench/Arithmetic.py sandbox/trunk/rjsh-pybench/Calls.py sandbox/trunk/rjsh-pybench/Constructs.py sandbox/trunk/rjsh-pybench/Dict.py sandbox/trunk/rjsh-pybench/Empty.py sandbox/trunk/rjsh-pybench/Exceptions.py sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Instances.py sandbox/trunk/rjsh-pybench/Lists.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/Numbers.py sandbox/trunk/rjsh-pybench/Strings.py sandbox/trunk/rjsh-pybench/Tuples.py sandbox/trunk/rjsh-pybench/Unicode.py sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526142453.321621E4010@bag.python.org> Author: steve.holden Date: Fri May 26 16:24:51 2006 New Revision: 46334 Added: sandbox/trunk/rjsh-pybench/Empty.py (contents, props changed) Modified: sandbox/trunk/rjsh-pybench/Arithmetic.py sandbox/trunk/rjsh-pybench/Calls.py sandbox/trunk/rjsh-pybench/Constructs.py sandbox/trunk/rjsh-pybench/Dict.py sandbox/trunk/rjsh-pybench/Exceptions.py sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Instances.py sandbox/trunk/rjsh-pybench/Lists.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/Numbers.py sandbox/trunk/rjsh-pybench/Strings.py sandbox/trunk/rjsh-pybench/Tuples.py sandbox/trunk/rjsh-pybench/Unicode.py sandbox/trunk/rjsh-pybench/pybench.py Log: Adjust rounds count to make test take roughly euqal time. Allow comparisons between runs with different warp factors. Add an empty test (even though it doesn't tell us much). Modified: sandbox/trunk/rjsh-pybench/Arithmetic.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Arithmetic.py (original) +++ sandbox/trunk/rjsh-pybench/Arithmetic.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 120000 + rounds = 12000*21 def test(self): @@ -159,7 +159,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 100000 + rounds = 10000*30 def test(self): @@ -314,7 +314,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 120000 + rounds = 12000*30 def test(self): @@ -470,7 +470,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 30000 + rounds = 3000*32 def test(self): @@ -625,7 +625,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 40000 + rounds = 4000*27 def test(self): Modified: sandbox/trunk/rjsh-pybench/Calls.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Calls.py (original) +++ sandbox/trunk/rjsh-pybench/Calls.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(1+4+4+2) - rounds = 60000 + rounds = 6000*22 def test(self): @@ -113,7 +113,7 @@ version = 0.4 operations = 5*(2+5+5+5) - rounds = 30000 + rounds = 3000*24 def test(self): @@ -234,7 +234,7 @@ version = 0.3 operations = 5*(6 + 5 + 4) - rounds = 20000 + rounds = 2000*27 def test(self): @@ -376,7 +376,7 @@ version = 0.3 operations = 5 - rounds = 50000 + rounds = 5000*21 def test(self): Modified: sandbox/trunk/rjsh-pybench/Constructs.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Constructs.py (original) +++ sandbox/trunk/rjsh-pybench/Constructs.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 30*3 # hard to say... - rounds = 150000 + rounds = 15000*27 def test(self): @@ -471,7 +471,7 @@ version = 0.3 operations = 1000*10*5 - rounds = 150 + rounds = 540 def test(self): @@ -496,7 +496,7 @@ version = 0.1 operations = 5 * 5 - rounds = 8000 + rounds = 800*25 def test(self): Modified: sandbox/trunk/rjsh-pybench/Dict.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Dict.py (original) +++ sandbox/trunk/rjsh-pybench/Dict.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(5 + 5) - rounds = 60000 + rounds = 6000*24 def test(self): @@ -79,7 +79,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 20000*30 def test(self): @@ -257,7 +257,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 20000*19 def test(self): @@ -346,7 +346,7 @@ version = 0.3 operations = 5*(6 + 6 + 6 + 6) - rounds = 50000 + rounds = 5000*44 def test(self): Added: sandbox/trunk/rjsh-pybench/Empty.py ============================================================================== --- (empty file) +++ sandbox/trunk/rjsh-pybench/Empty.py Fri May 26 16:24:51 2006 @@ -0,0 +1,23 @@ +from pybench import Test + +class EmptyTest(Test): + """This is just here as a potential measure of repeatability.""" + + version = 0.3 + operations = 1 + rounds = 60000 + + def test(self): + + l = [] + for i in xrange(self.rounds): + pass + + + def calibrate(self): + + l = [] + + for i in xrange(self.rounds): + pass + Modified: sandbox/trunk/rjsh-pybench/Exceptions.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Exceptions.py (original) +++ sandbox/trunk/rjsh-pybench/Exceptions.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 2 + 3 - rounds = 60000 + rounds = 6000*25 def test(self): @@ -44,7 +44,7 @@ version = 0.1 operations = 15 * 10 - rounds = 200000 + rounds = 20000*16 def test(self): Modified: sandbox/trunk/rjsh-pybench/Imports.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Imports.py (original) +++ sandbox/trunk/rjsh-pybench/Imports.py Fri May 26 16:24:51 2006 @@ -8,7 +8,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 2000*15 def test(self): @@ -53,7 +53,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 2000*20 def test(self): @@ -97,7 +97,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 2000*17 def test(self): Modified: sandbox/trunk/rjsh-pybench/Instances.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Instances.py (original) +++ sandbox/trunk/rjsh-pybench/Instances.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.2 operations = 3 + 7 + 4 - rounds = 60000 + rounds = 6000*17 def test(self): Modified: sandbox/trunk/rjsh-pybench/Lists.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Lists.py (original) +++ sandbox/trunk/rjsh-pybench/Lists.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5* (6 + 6 + 6) - rounds = 60000 + rounds = 6000*45 def test(self): @@ -132,7 +132,7 @@ version = 0.4 operations = 25*(3+1+2+1) - rounds = 400 + rounds = 40*45 def test(self): @@ -169,7 +169,7 @@ version = 0.3 operations = 5*(1+ 6 + 6 + 3 + 1) - rounds = 60000 + rounds = 6000*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/Lookups.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Lookups.py (original) +++ sandbox/trunk/rjsh-pybench/Lookups.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 10000*16 def test(self): @@ -185,7 +185,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 10000*20 def test(self): @@ -371,7 +371,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 10000*14 def test(self): @@ -559,7 +559,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 10000*22 def test(self): @@ -747,7 +747,7 @@ version = 0.3 operations = 5*(3*5 + 3*5) - rounds = 70000 + rounds = 7000*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/Numbers.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Numbers.py (original) +++ sandbox/trunk/rjsh-pybench/Numbers.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 30 * 5 - rounds = 120000 + rounds = 12000*21 def test(self): @@ -200,7 +200,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 6000*27 def test(self): @@ -396,7 +396,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 6000*16 def test(self): @@ -592,7 +592,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 6000*24 def test(self): Modified: sandbox/trunk/rjsh-pybench/Strings.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Strings.py (original) +++ sandbox/trunk/rjsh-pybench/Strings.py Fri May 26 16:24:51 2006 @@ -87,7 +87,7 @@ version = 0.2 operations = 10 * 5 - rounds = 200000 + rounds = 20000*22 def test(self): @@ -169,7 +169,7 @@ version = 0.1 operations = 10 * 5 - rounds = 200000 + rounds = 20000*28 def test(self): @@ -251,7 +251,7 @@ version = 0.1 operations = 10 * 5 - rounds = 80000 + rounds = 8000*32 def test(self): @@ -326,7 +326,7 @@ version = 0.1 operations = 5 * 7 - rounds = 100000 + rounds = 10000*15 def test(self): @@ -389,7 +389,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 70000 + rounds = 140000 def test(self): @@ -462,7 +462,7 @@ version = 0.1 operations = 10 * 7 - rounds = 80000 + rounds = 8000*24 def test(self): Modified: sandbox/trunk/rjsh-pybench/Tuples.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Tuples.py (original) +++ sandbox/trunk/rjsh-pybench/Tuples.py Fri May 26 16:24:51 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 3 * 25 * 10 * 7 - rounds = 400 + rounds = 40*15 def test(self): @@ -272,7 +272,7 @@ version = 0.3 operations = 5*(1 + 3 + 6 + 2) - rounds = 80000 + rounds = 8000*16 def test(self): Modified: sandbox/trunk/rjsh-pybench/Unicode.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Unicode.py (original) +++ sandbox/trunk/rjsh-pybench/Unicode.py Fri May 26 16:24:51 2006 @@ -10,7 +10,7 @@ version = 0.1 operations = 10 * 5 - rounds = 60000 + rounds = 6000*7 def test(self): @@ -92,7 +92,7 @@ version = 0.1 operations = 10 * 5 - rounds = 150000 + rounds = 15000*17 def test(self): @@ -174,7 +174,7 @@ version = 0.1 operations = 10 * 5 - rounds = 80000 + rounds = 8000*12 def test(self): @@ -310,7 +310,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 10000 + rounds = 1000*15 def test(self): @@ -383,7 +383,7 @@ version = 0.1 operations = 5 * 9 - rounds = 100000 + rounds = 10000*25 def test(self): @@ -460,7 +460,7 @@ version = 0.1 operations = 5 * 8 - rounds = 100000 + rounds = 10000*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 16:24:51 2006 @@ -35,7 +35,7 @@ """ # Version number -__version__ = '1.3' +__version__ = '1.4' # # NOTE: Use xrange for all test loops unless you want to face @@ -115,13 +115,15 @@ # Misc. internal variables last_timing = (0,0,0) # last timing (real,run,calibration) warp = 1 # warp factor this test uses - cruns = 0 # number of calibration runs + cruns = 20 # number of calibration runs overhead = None # list of calibration timings def __init__(self,warp=1): if warp > 1: self.rounds = self.rounds / warp + if self.rounds == 0: + self.rounds = 1 self.warp = warp self.times = [] self.overhead = [] @@ -183,9 +185,13 @@ def stat(self): - """ Returns two value: average time per run and average per - operation. + """ Returns four values: + minimum round time + average time per round + average time per operation + average overhead time + XXX Should this take warp factors into account? """ runs = len(self.times) if runs == 0: @@ -200,7 +206,7 @@ else: # use self.last_timing - not too accurate ov_avg = self.last_timing[2] - return mintime,avg,op_avg,ov_avg + return mintime, avg, op_avg, ov_avg ### Load Setup @@ -225,7 +231,7 @@ self.tests = {} self.version = 0.31 - def load_tests(self,setupmod,warp=1, limitnames=""): + def load_tests(self, setupmod, warp=1, limitnames="", verbose=0): self.warp = warp if limitnames: @@ -233,7 +239,7 @@ else: limitnames = None tests = self.tests - print 'Searching for tests...' + print 'Searching for tests ...', setupmod.__dict__.values() for c in setupmod.__dict__.values(): if not hasattr(c,'is_a_test'): @@ -246,8 +252,12 @@ tests[name] = c(warp) l = tests.keys() l.sort() - for t in l: - print ' ',t + if verbose: + print + for t in l: + print ' ',t + else: + print len(l), "found" print def run(self, verbose): @@ -259,6 +269,7 @@ print roundtime = clock() for i in range(self.rounds): + roundstarttime = clock() if verbose: print ' Round %-25i real abs overhead' % (i+1) for j in range(len(tests)): @@ -274,7 +285,7 @@ ((clock() - roundtime)/(i+1)) print else: - print '%d ... done'%i + print '%d done in %.3f seconds' % (i+1, (clock() - roundstarttime)) self.roundtime = (clock() - roundtime) / self.rounds print @@ -305,8 +316,8 @@ tests.sort() compatible = 1 totalmintime = other_totalmintime = 0 - for name,t in tests: - mintime,avg,op_avg,ov_avg = t.stat() + for name, t in tests: + mintime, avg, op_avg, ov_avg = t.stat() totalmintime += mintime try: other = compare_to.tests[name] @@ -314,24 +325,27 @@ other = None if other and other.version == t.version and \ other.operations == t.operations: - mintime1,avg1,op_avg1,ov_avg1 = other.stat() + mintime1, avg1, op_avg1, ov_avg1 = other.stat() other_totalmintime += mintime1 - diff = (mintime/mintime1 - 1.0)*100.0 + diff = ((mintime*self.warp)/(mintime1*other.warp) - 1.0)*100.0 if hidenoise and abs(qop_avg) < 10: diff = '' else: diff = '%+7.2f%%' % diff else: - qavg,diff = 'n/a', 'n/a' + qavg, diff = 'n/a', 'n/a' compatible = 0 print '%30s: %8.2f ms %8.2f ms %8.2f ms %8s' % \ - (name,mintime*1000.0,mintime1*1000.0, avg*1000.0,diff) + (name,mintime*1000.0,mintime1*1000.0 * compare_to.warp/self.warp, avg*1000.0,diff) print '-'*77 + # + # Summarise test results + # if compatible and compare_to.roundtime > 0 and \ compare_to.version == self.version: print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ ('Notional minimum round time', totalmintime * 1000.0, - other_totalmintime * 1000.0, + other_totalmintime * 1000.0 * compare_to.warp/self.warp, ((totalmintime*self.warp)/ (other_totalmintime*compare_to.warp)-1.0)*100.0) else: @@ -479,7 +493,7 @@ # Create benchmark object bench = Benchmark() bench.rounds = rounds - bench.load_tests(Setup,warp,limitnames) + bench.load_tests(Setup, warp, limitnames, verbose) try: bench.run(verbose) except KeyboardInterrupt: From python-checkins at python.org Fri May 26 16:29:35 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 16:29:35 +0200 (CEST) Subject: [Python-checkins] r46335 - python/trunk/Modules/_struct.c Message-ID: <20060526142935.7D9F31E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 16:29:35 2006 New Revision: 46335 Modified: python/trunk/Modules/_struct.c Log: Enable PY_USE_INT_WHEN_POSSIBLE in struct Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 16:29:35 2006 @@ -16,12 +16,10 @@ #endif -/* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the +/* PY_USE_INT_WHEN_POSSIBLE is a flag that changes the struct API to return int instead of long when possible. This is often a significant performance improvement. */ -/* #define PY_USE_INT_WHEN_POSSIBLE 1 -*/ /* PY_STRUCT_RANGE_CHECKING performs range checking on all arguments to be packed. This will break some incorrect code that happened From python-checkins at python.org Fri May 26 16:33:34 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 16:33:34 +0200 (CEST) Subject: [Python-checkins] r46336 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526143334.598D71E400C@bag.python.org> Author: richard.jones Date: Fri May 26 16:33:34 2006 New Revision: 46336 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: exception names historically don't have 'exceptions.' in them Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 16:33:34 2006 @@ -173,7 +173,7 @@ static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "exceptions.BaseException", /*tp_name*/ + "BaseException", /*tp_name*/ sizeof(BaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)BaseException_dealloc, /*tp_dealloc*/ @@ -220,7 +220,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions." # EXCNAME, \ + # EXCNAME, \ sizeof(BaseExceptionObject), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ @@ -235,7 +235,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions." # EXCNAME, \ + # EXCNAME, \ sizeof(EXCSTORE ## Object), \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ @@ -250,7 +250,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - "exceptions." # EXCNAME, \ + # EXCNAME, \ sizeof(EXCSTORE ## Object), 0, \ (destructor)EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ @@ -1379,7 +1379,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "exceptions.UnicodeEncodeError", + "UnicodeEncodeError", sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1454,7 +1454,7 @@ static PyTypeObject _PyExc_UnicodeDecodeError = { PyObject_HEAD_INIT(NULL) 0, - "exceptions.UnicodeDecodeError", + "UnicodeDecodeError", sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, @@ -1567,7 +1567,7 @@ static PyTypeObject _PyExc_UnicodeTranslateError = { PyObject_HEAD_INIT(NULL) 0, - "exceptions.UnicodeTranslateError", + "UnicodeTranslateError", sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, From python-checkins at python.org Fri May 26 16:37:14 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 16:37:14 +0200 (CEST) Subject: [Python-checkins] r46337 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060526143714.663DA1E400C@bag.python.org> Author: richard.jones Date: Fri May 26 16:37:13 2006 New Revision: 46337 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: fix Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Fri May 26 16:37:13 2006 @@ -25,7 +25,7 @@ raise exc("spam") except exc, err: buf = str(err) -# print buf + print buf def r(thing): test_raise_catch(thing) From buildbot at python.org Fri May 26 16:41:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 14:41:37 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060526144138.078D61E400C@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/800 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From mal at egenix.com Fri May 26 16:56:09 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 26 May 2006 16:56:09 +0200 Subject: [Python-checkins] r46334 - sandbox/trunk/rjsh-pybench/Arithmetic.py sandbox/trunk/rjsh-pybench/Calls.py sandbox/trunk/rjsh-pybench/Constructs.py sandbox/trunk/rjsh-pybench/Dict.py sandbox/trunk/rjsh-pybench/Empty.py sandbox/trunk/rjsh-pybench/Exceptions.py sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Instances.py sandbox/trunk/rjsh-pybench/Lists.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/Numbers.py sandbox/trunk/rjsh-pybench/Strings.py sandbox/trunk/rjsh-pybench/Tuples.py sandbox/trunk/rjsh-pybench/Unicode.py sandbox/trunk/rjsh-pybench/pybench.py In-Reply-To: <20060526142453.321621E4010@bag.python.org> References: <20060526142453.321621E4010@bag.python.org> Message-ID: <44771709.5030608@egenix.com> steve.holden wrote: > Author: steve.holden > Date: Fri May 26 16:24:51 2006 > New Revision: 46334 > > Added: > sandbox/trunk/rjsh-pybench/Empty.py (contents, props changed) > Modified: > sandbox/trunk/rjsh-pybench/Arithmetic.py > sandbox/trunk/rjsh-pybench/Calls.py > sandbox/trunk/rjsh-pybench/Constructs.py > sandbox/trunk/rjsh-pybench/Dict.py > sandbox/trunk/rjsh-pybench/Exceptions.py > sandbox/trunk/rjsh-pybench/Imports.py > sandbox/trunk/rjsh-pybench/Instances.py > sandbox/trunk/rjsh-pybench/Lists.py > sandbox/trunk/rjsh-pybench/Lookups.py > sandbox/trunk/rjsh-pybench/Numbers.py > sandbox/trunk/rjsh-pybench/Strings.py > sandbox/trunk/rjsh-pybench/Tuples.py > sandbox/trunk/rjsh-pybench/Unicode.py > sandbox/trunk/rjsh-pybench/pybench.py > Log: > Adjust rounds count to make test take roughly euqal time. When adjusting these, you also need to adjust the version numbers of the tests - otherwise comparisons would compare apples and oranges. > - def load_tests(self,setupmod,warp=1, limitnames=""): > + def load_tests(self, setupmod, warp=1, limitnames="", verbose=0): > > self.warp = warp > if limitnames: > @@ -233,7 +239,7 @@ > else: > limitnames = None > tests = self.tests > - print 'Searching for tests...' > + print 'Searching for tests ...', I think this should also be silenced using verbose. > setupmod.__dict__.values() > for c in setupmod.__dict__.values(): > if not hasattr(c,'is_a_test'): > @@ -246,8 +252,12 @@ > tests[name] = c(warp) > l = tests.keys() > l.sort() > - for t in l: > - print ' ',t > + if verbose: > + print > + for t in l: > + print ' ',t > + else: > + print len(l), "found" > print -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 26 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From python-checkins at python.org Fri May 26 16:57:26 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 16:57:26 +0200 (CEST) Subject: [Python-checkins] r46338 - sandbox/trunk/rjsh-pybench/Arithmetic.py sandbox/trunk/rjsh-pybench/Calls.py sandbox/trunk/rjsh-pybench/Constructs.py sandbox/trunk/rjsh-pybench/Dict.py sandbox/trunk/rjsh-pybench/Exceptions.py sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Instances.py sandbox/trunk/rjsh-pybench/Lists.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/Numbers.py sandbox/trunk/rjsh-pybench/Strings.py sandbox/trunk/rjsh-pybench/Tuples.py sandbox/trunk/rjsh-pybench/Unicode.py sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526145726.C16781E400C@bag.python.org> Author: steve.holden Date: Fri May 26 16:57:25 2006 New Revision: 46338 Modified: sandbox/trunk/rjsh-pybench/Arithmetic.py sandbox/trunk/rjsh-pybench/Calls.py sandbox/trunk/rjsh-pybench/Constructs.py sandbox/trunk/rjsh-pybench/Dict.py sandbox/trunk/rjsh-pybench/Exceptions.py sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Instances.py sandbox/trunk/rjsh-pybench/Lists.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/Numbers.py sandbox/trunk/rjsh-pybench/Strings.py sandbox/trunk/rjsh-pybench/Tuples.py sandbox/trunk/rjsh-pybench/Unicode.py sandbox/trunk/rjsh-pybench/pybench.py Log: Tweak round counts to give a more reasonable basic test time. Modified: sandbox/trunk/rjsh-pybench/Arithmetic.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Arithmetic.py (original) +++ sandbox/trunk/rjsh-pybench/Arithmetic.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 12000*21 + rounds = 1200*21 def test(self): @@ -159,7 +159,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 10000*30 + rounds = 1000*30 def test(self): @@ -314,7 +314,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 12000*30 + rounds = 1200*30 def test(self): @@ -470,7 +470,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 3000*32 + rounds = 300*32 def test(self): @@ -625,7 +625,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 4000*27 + rounds = 400*27 def test(self): Modified: sandbox/trunk/rjsh-pybench/Calls.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Calls.py (original) +++ sandbox/trunk/rjsh-pybench/Calls.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(1+4+4+2) - rounds = 6000*22 + rounds = 600*22 def test(self): @@ -113,7 +113,7 @@ version = 0.4 operations = 5*(2+5+5+5) - rounds = 3000*24 + rounds = 300*24 def test(self): @@ -234,7 +234,7 @@ version = 0.3 operations = 5*(6 + 5 + 4) - rounds = 2000*27 + rounds = 200*27 def test(self): @@ -376,7 +376,7 @@ version = 0.3 operations = 5 - rounds = 5000*21 + rounds = 500*21 def test(self): Modified: sandbox/trunk/rjsh-pybench/Constructs.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Constructs.py (original) +++ sandbox/trunk/rjsh-pybench/Constructs.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 30*3 # hard to say... - rounds = 15000*27 + rounds = 1500*27 def test(self): @@ -471,7 +471,7 @@ version = 0.3 operations = 1000*10*5 - rounds = 540 + rounds = 100 def test(self): @@ -496,7 +496,7 @@ version = 0.1 operations = 5 * 5 - rounds = 800*25 + rounds = 80*25 def test(self): Modified: sandbox/trunk/rjsh-pybench/Dict.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Dict.py (original) +++ sandbox/trunk/rjsh-pybench/Dict.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(5 + 5) - rounds = 6000*24 + rounds = 600*24 def test(self): @@ -79,7 +79,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 20000*30 + rounds = 2000*30 def test(self): @@ -168,7 +168,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 20000 def test(self): @@ -257,7 +257,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 20000*19 + rounds = 2000*19 def test(self): @@ -346,7 +346,7 @@ version = 0.3 operations = 5*(6 + 6 + 6 + 6) - rounds = 5000*44 + rounds = 500*44 def test(self): Modified: sandbox/trunk/rjsh-pybench/Exceptions.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Exceptions.py (original) +++ sandbox/trunk/rjsh-pybench/Exceptions.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 2 + 3 - rounds = 6000*25 + rounds = 600*25 def test(self): @@ -44,7 +44,7 @@ version = 0.1 operations = 15 * 10 - rounds = 20000*16 + rounds = 2000*16 def test(self): Modified: sandbox/trunk/rjsh-pybench/Imports.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Imports.py (original) +++ sandbox/trunk/rjsh-pybench/Imports.py Fri May 26 16:57:25 2006 @@ -8,7 +8,7 @@ version = 0.1 operations = 5 * 5 - rounds = 2000*15 + rounds = 200*15 def test(self): @@ -53,7 +53,7 @@ version = 0.1 operations = 5 * 5 - rounds = 2000*20 + rounds = 200*20 def test(self): @@ -97,7 +97,7 @@ version = 0.1 operations = 5 * 5 - rounds = 2000*17 + rounds = 200*17 def test(self): Modified: sandbox/trunk/rjsh-pybench/Instances.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Instances.py (original) +++ sandbox/trunk/rjsh-pybench/Instances.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.2 operations = 3 + 7 + 4 - rounds = 6000*17 + rounds = 600*17 def test(self): Modified: sandbox/trunk/rjsh-pybench/Lists.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Lists.py (original) +++ sandbox/trunk/rjsh-pybench/Lists.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5* (6 + 6 + 6) - rounds = 6000*45 + rounds = 600*45 def test(self): @@ -132,7 +132,7 @@ version = 0.4 operations = 25*(3+1+2+1) - rounds = 40*45 + rounds = 4*45 def test(self): @@ -169,7 +169,7 @@ version = 0.3 operations = 5*(1+ 6 + 6 + 3 + 1) - rounds = 6000*15 + rounds = 600*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/Lookups.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Lookups.py (original) +++ sandbox/trunk/rjsh-pybench/Lookups.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 10000*16 + rounds = 1000*16 def test(self): @@ -185,7 +185,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 10000*20 + rounds = 1000*20 def test(self): @@ -371,7 +371,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 10000*14 + rounds = 100*14 def test(self): @@ -559,7 +559,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 10000*22 + rounds = 1000*22 def test(self): @@ -747,7 +747,7 @@ version = 0.3 operations = 5*(3*5 + 3*5) - rounds = 7000*15 + rounds = 700*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/Numbers.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Numbers.py (original) +++ sandbox/trunk/rjsh-pybench/Numbers.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 30 * 5 - rounds = 12000*21 + rounds = 1200*21 def test(self): @@ -200,7 +200,7 @@ version = 0.1 operations = 30 * 5 - rounds = 6000*27 + rounds = 600*27 def test(self): @@ -396,7 +396,7 @@ version = 0.1 operations = 30 * 5 - rounds = 6000*16 + rounds = 600*16 def test(self): @@ -592,7 +592,7 @@ version = 0.1 operations = 30 * 5 - rounds = 6000*24 + rounds = 600*24 def test(self): Modified: sandbox/trunk/rjsh-pybench/Strings.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Strings.py (original) +++ sandbox/trunk/rjsh-pybench/Strings.py Fri May 26 16:57:25 2006 @@ -5,7 +5,7 @@ version = 0.1 operations = 10 * 5 - rounds = 60000 + rounds = 6000 def test(self): @@ -87,7 +87,7 @@ version = 0.2 operations = 10 * 5 - rounds = 20000*22 + rounds = 2000*22 def test(self): @@ -169,7 +169,7 @@ version = 0.1 operations = 10 * 5 - rounds = 20000*28 + rounds = 2000*28 def test(self): @@ -251,7 +251,7 @@ version = 0.1 operations = 10 * 5 - rounds = 8000*32 + rounds = 800*32 def test(self): @@ -326,7 +326,7 @@ version = 0.1 operations = 5 * 7 - rounds = 10000*15 + rounds = 1000*15 def test(self): @@ -389,7 +389,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 140000 + rounds = 14000 def test(self): @@ -462,7 +462,7 @@ version = 0.1 operations = 10 * 7 - rounds = 8000*24 + rounds = 800*24 def test(self): Modified: sandbox/trunk/rjsh-pybench/Tuples.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Tuples.py (original) +++ sandbox/trunk/rjsh-pybench/Tuples.py Fri May 26 16:57:25 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 3 * 25 * 10 * 7 - rounds = 40*15 + rounds = 100 def test(self): @@ -272,7 +272,7 @@ version = 0.3 operations = 5*(1 + 3 + 6 + 2) - rounds = 8000*16 + rounds = 800*16 def test(self): Modified: sandbox/trunk/rjsh-pybench/Unicode.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Unicode.py (original) +++ sandbox/trunk/rjsh-pybench/Unicode.py Fri May 26 16:57:25 2006 @@ -10,7 +10,7 @@ version = 0.1 operations = 10 * 5 - rounds = 6000*7 + rounds = 600*7 def test(self): @@ -92,7 +92,7 @@ version = 0.1 operations = 10 * 5 - rounds = 15000*17 + rounds = 1500*17 def test(self): @@ -174,7 +174,7 @@ version = 0.1 operations = 10 * 5 - rounds = 8000*12 + rounds = 800*12 def test(self): @@ -249,7 +249,7 @@ version = 0.1 operations = 5 * 7 - rounds = 100000 + rounds = 10000 def test(self): @@ -310,7 +310,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 1000*15 + rounds = 100*15 def test(self): @@ -383,7 +383,7 @@ version = 0.1 operations = 5 * 9 - rounds = 10000*25 + rounds = 1000*25 def test(self): @@ -460,7 +460,7 @@ version = 0.1 operations = 5 * 8 - rounds = 10000*15 + rounds = 1000*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 16:57:25 2006 @@ -56,13 +56,6 @@ except ImportError: import pickle -if sys.platform == "win32": - # On Windows, the best timer is time.clock() - default_timer = time.clock -else: - # On most other platforms the best timer is time.time() - default_timer = time.time - ### Test baseclass class Test: @@ -105,7 +98,7 @@ # Number of rounds to execute per test run. This should be # adjusted to a figure that results in a test run-time of between # 20-50 seconds. - rounds = 100000 + rounds = 10000 ### Internal variables @@ -142,7 +135,7 @@ """ test = self.test calibrate = self.calibrate - clock = default_timer + clock = time.clock cruns = self.cruns # first calibrate offset = 0.0 @@ -265,7 +258,7 @@ tests = self.tests.items() tests.sort() clock = time.clock - print 'Running %i round(s) of the suite: ' % self.rounds + print 'Running %i round(s) of the suite: ' % self.rounds, 'at warp factor', self.warp print roundtime = clock() for i in range(self.rounds): From python-checkins at python.org Fri May 26 17:03:27 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 17:03:27 +0200 (CEST) Subject: [Python-checkins] r46339 - sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526150327.23EFB1E400D@bag.python.org> Author: steve.holden Date: Fri May 26 17:03:21 2006 New Revision: 46339 Modified: sandbox/trunk/rjsh-pybench/Imports.py sandbox/trunk/rjsh-pybench/Lookups.py sandbox/trunk/rjsh-pybench/pybench.py Log: More round count tweaks and output polishing. Modified: sandbox/trunk/rjsh-pybench/Imports.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Imports.py (original) +++ sandbox/trunk/rjsh-pybench/Imports.py Fri May 26 17:03:21 2006 @@ -8,7 +8,7 @@ version = 0.1 operations = 5 * 5 - rounds = 200*15 + rounds = 2000*15 def test(self): Modified: sandbox/trunk/rjsh-pybench/Lookups.py ============================================================================== --- sandbox/trunk/rjsh-pybench/Lookups.py (original) +++ sandbox/trunk/rjsh-pybench/Lookups.py Fri May 26 17:03:21 2006 @@ -371,7 +371,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100*14 + rounds = 1000*14 def test(self): Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 17:03:21 2006 @@ -258,7 +258,7 @@ tests = self.tests.items() tests.sort() clock = time.clock - print 'Running %i round(s) of the suite: ' % self.rounds, 'at warp factor', self.warp + print 'Running %i round(s) of the suite at warp factor %i:' % (self.rounds, self.warp) print roundtime = clock() for i in range(self.rounds): From python-checkins at python.org Fri May 26 17:11:02 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 17:11:02 +0200 (CEST) Subject: [Python-checkins] r46340 - python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Message-ID: <20060526151102.46E671E400C@bag.python.org> Author: georg.brandl Date: Fri May 26 17:11:01 2006 New Revision: 46340 Modified: python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Log: Fix name printing. Modified: python/branches/sreifschneider-newnewexcept/Python/pythonrun.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/pythonrun.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Fri May 26 17:11:01 2006 @@ -1139,12 +1139,12 @@ err = PyFile_WriteString("", f); else { char* modstr = PyString_AsString(moduleName); - Py_DECREF(moduleName); - if (modstr && strcmp(modstr, "exceptions")) + if (modstr && strcmp(modstr, "__builtin__")) { err = PyFile_WriteString(modstr, f); err += PyFile_WriteString(".", f); } + Py_DECREF(moduleName); } if (err == 0) { if (className == NULL) From python-checkins at python.org Fri May 26 17:16:19 2006 From: python-checkins at python.org (sean.reifschneider) Date: Fri, 26 May 2006 17:16:19 +0200 (CEST) Subject: [Python-checkins] r46341 - python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Message-ID: <20060526151619.820CE1E400C@bag.python.org> Author: sean.reifschneider Date: Fri May 26 17:16:19 2006 New Revision: 46341 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Log: Removing OverflowWarning to match Richard's changes. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/exception_hierarchy.txt Fri May 26 17:16:19 2006 @@ -44,5 +44,4 @@ +-- SyntaxWarning +-- UserWarning +-- FutureWarning - +-- OverflowWarning [not generated by the interpreter] +-- ImportWarning From python-checkins at python.org Fri May 26 17:20:17 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 17:20:17 +0200 (CEST) Subject: [Python-checkins] r46342 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c python/branches/sreifschneider-newnewexcept/Objects/object.c Message-ID: <20060526152017.E9FE51E400F@bag.python.org> Author: richard.jones Date: Fri May 26 17:20:17 2006 New Revision: 46342 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c python/branches/sreifschneider-newnewexcept/Objects/object.c Log: reinstate unicode Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 17:20:17 2006 @@ -143,6 +143,26 @@ return repr; } +#ifdef Py_USING_UNICODE +/* while this method generates fairly uninspired output, it a least + * guarantees that we can display exceptions that have unicode attributes + */ +static PyObject * +BaseException_unicode(BaseExceptionObject *self) +{ + return PyObject_Unicode(self->args); +} +#endif /* Py_USING_UNICODE */ + +static PyMethodDef BaseException_methods[] = { +#ifdef Py_USING_UNICODE + {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, +#endif + {NULL, NULL, 0, NULL}, +}; + + + static PyObject * BaseException_getitem(BaseExceptionObject *self, Py_ssize_t index) { @@ -187,11 +207,11 @@ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ - (reprfunc)BaseException_str, /*tp_str*/ + (reprfunc)BaseException_str, /*tp_str*/ PyObject_GenericGetAttr, /*tp_getattro*/ PyObject_GenericSetAttr, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -199,7 +219,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - 0, /* tp_methods */ + BaseException_methods, /* tp_methods */ BaseException_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ Modified: python/branches/sreifschneider-newnewexcept/Objects/object.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/object.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/object.c Fri May 26 17:20:17 2006 @@ -1076,7 +1076,6 @@ PyObject_GetAttrString(PyObject *v, const char *name) { PyObject *w, *res; - if (v->ob_type->tp_getattr != NULL) return (*v->ob_type->tp_getattr)(v, (char*)name); w = PyString_InternFromString(name); From python-checkins at python.org Fri May 26 17:21:04 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 17:21:04 +0200 (CEST) Subject: [Python-checkins] r46343 - python/trunk/Objects/stringobject.c Message-ID: <20060526152104.E13F71E401D@bag.python.org> Author: andrew.dalke Date: Fri May 26 17:21:01 2006 New Revision: 46343 Modified: python/trunk/Objects/stringobject.c Log: Eeked out another 3% or so performance in split whitespace by cleaning up the algorithm. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 17:21:01 2006 @@ -1460,7 +1460,7 @@ else \ Py_DECREF(str); -#define SPLIT_ADD(data, left, right) \ +#define SPLIT_ADD(data, left, right) { \ str = PyString_FromStringAndSize((data) + (left), \ (right) - (left)); \ if (str == NULL) \ @@ -1475,11 +1475,16 @@ else \ Py_DECREF(str); \ } \ - count++; + count++; } /* Always force the list to the expected size. */ #define FIX_PREALLOC_SIZE(list) ((PyListObject *)list)->ob_size = count; +#define SKIP_SPACE(s, i, len) { while (i=0 && isspace(Py_CHARMASK(s[i]))) i--; } +#define RSKIP_NONSPACE(s, i) { while (i>=0 && !isspace(Py_CHARMASK(s[i]))) i--; } + static PyObject * split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { @@ -1490,23 +1495,22 @@ if (list == NULL) return NULL; - for (i = j = 0; i < len; ) { - while (i < len && isspace(Py_CHARMASK(s[i]))) - i++; - j = i; - while (i < len && !isspace(Py_CHARMASK(s[i]))) - i++; - if (j < i) { - if (maxsplit-- <= 0) - break; - SPLIT_ADD(s, j, i); - while (i < len && isspace(Py_CHARMASK(s[i]))) - i++; - j = i; - } + i = j = 0; + + while (maxsplit-- > 0) { + SKIP_SPACE(s, i, len); + if (i==len) break; + j = i; i++; + SKIP_NONSPACE(s, i, len); + SPLIT_ADD(s, j, i); } - if (j < len) { - SPLIT_ADD(s, j, len); + + if (i < len) { + /* Only occurs when maxsplit was reached */ + /* Skip any remaining whitespace and copy to end of string */ + SKIP_SPACE(s, i, len); + if (i != len) + SPLIT_ADD(s, i, len); } FIX_PREALLOC_SIZE(list); return list; @@ -1680,23 +1684,22 @@ if (list == NULL) return NULL; - for (i = j = len - 1; i >= 0; ) { - while (i >= 0 && isspace(Py_CHARMASK(s[i]))) - i--; - j = i; - while (i >= 0 && !isspace(Py_CHARMASK(s[i]))) - i--; - if (j > i) { - if (maxsplit-- <= 0) - break; - SPLIT_ADD(s, i + 1, j + 1); - while (i >= 0 && isspace(Py_CHARMASK(s[i]))) - i--; - j = i; - } - } - if (j >= 0) { - SPLIT_ADD(s, 0, j + 1); + i = j = len-1; + + while (maxsplit-- > 0) { + RSKIP_SPACE(s, i); + if (i<0) break; + j = i; i--; + RSKIP_NONSPACE(s, i); + SPLIT_ADD(s, i + 1, j + 1); + } + if (i >= 0) { + /* Only occurs when maxsplit was reached */ + /* Skip any remaining whitespace and copy to beginning of string */ + RSKIP_SPACE(s, i); + if (i >= 0) + SPLIT_ADD(s, 0, i + 1); + } FIX_PREALLOC_SIZE(list); if (PyList_Reverse(list) < 0) From facundobatista at gmail.com Fri May 26 17:28:03 2006 From: facundobatista at gmail.com (Facundo Batista) Date: Fri, 26 May 2006 12:28:03 -0300 Subject: [Python-checkins] [Python-Dev] This In-Reply-To: <44763487.3080908@ewtllc.com> References: <44762E77.3080303@ewtllc.com> <44763168.4030308@holdenweb.com> <44763487.3080908@ewtllc.com> Message-ID: 2006/5/25, Raymond Hettinger : > IIRC, Guido's words were that too much to the smarts in timeit.py were > in the command-line interface and not in the Timer object were in should > be. Just end user experience's two cents here (btw, this line is correct at English level?) I found myself a lot of times going to command line to test a function, just to use timeit.py, because doing that from the interactive interpreter was more complicated. Maybe should exist some "quick measure method" like, >>> import timeit >>> timeit.no_effort(some_function_defined_before) Regards, -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ From python-checkins at python.org Fri May 26 17:28:48 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 17:28:48 +0200 (CEST) Subject: [Python-checkins] r46344 - sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526152848.AE2561E400E@bag.python.org> Author: steve.holden Date: Fri May 26 17:28:48 2006 New Revision: 46344 Modified: sandbox/trunk/rjsh-pybench/pybench.py Log: Tweak verbose output. Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 17:28:48 2006 @@ -232,7 +232,8 @@ else: limitnames = None tests = self.tests - print 'Searching for tests ...', + if verbose: + print 'Searching for tests ...', setupmod.__dict__.values() for c in setupmod.__dict__.values(): if not hasattr(c,'is_a_test'): @@ -248,9 +249,8 @@ if verbose: print for t in l: - print ' ',t - else: - print len(l), "found" + print ' ', t + print len(l), "tests found" print def run(self, verbose): From python-checkins at python.org Fri May 26 17:48:19 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 17:48:19 +0200 (CEST) Subject: [Python-checkins] r46345 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/setup.py sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060526154819.1AD401E401D@bag.python.org> Author: martin.blais Date: Fri May 26 17:48:18 2006 New Revision: 46345 Added: sandbox/trunk/hotbuffer/setup.py (contents, props changed) Modified: sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Fri May 26 17:48:18 2006 @@ -10,104 +10,73 @@ network I/O that avoids creating temporary strings and from which binary data can be directly decoded. +.. contents:: +.. + 1 TODO + 1.1 Features + 1.2 Document + 1.3 Convert from ASCII formats + 2 Notes on the Java NIO / ByteBuffer - -* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC -* We need to make the client more easily remove the calls to remaining() +TODO +==== -* FIXME make it possible to read from a file directly into a hotbuf!! +* Run oprofile on the code -* Write a smallish PEP about it -* Measure performance results before all of this -* Move the branch to the sandbox +* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC -* FIXME we need to find a way to automatically advance position without doing it - in Python +* We need to make the client more easily remove the calls to remaining() -* FIXME remove Py_XDECREF where possible +* Make it possible to read from a file directly into a hotbuf -* FIXME implement the file protocol (read(), write()) on the buffer object + - implement the file protocol (read(), write()) on the buffer object + - is there a file protocol? -* We need to be able to convert from ascii formats, e.g. long with an offset - (Runar, the long conversions) +Features +-------- -* Change the mark stuff +* Change the mark, this will make the loop easier to understand * setmark() to save both the position and limit * remove the special behaviours of the mark being discarded * reset() should reset both the position and the limit * setmark() becomes push(), reset() becomes pop() - - -For reading from and writing to network buffers. - -Look at: - -* Java ByteBuffer class -* SocketChannel -* nio classes - - -Maybe rename to ?seribuf?, or ?netbuf?? - - -TODO -==== -- How do we automatically advance the pointer on pack and unpack? - - - Add hash function + - Add support for some of the other sequence methods. + - Perhaps implement returning the buffer object itself from some of + the methods in order to allow chaining of operations on a single line. -- Implement a resize function -- Maybe remove the API methods declared at the top. -- Add support for big vs. little endian +- Implement a resize function -Pending Issues -============== - Should we support weakrefs? -Java NIO / ByteBuffer -===================== +Document +-------- -We need to provide position/limit/mark/reset - - A buffer is a linear, finite sequence of elements of a specific primitive - type. Aside from its content, the essential properties of a buffer are its - capacity, limit, and position: - - A buffer's capacity is the number of elements it contains. The capacity of a - buffer is never negative and never changes. - - A buffer's limit is the index of the first element that should not be read - or written. A buffer's limit is never negative and is never greater than its - capacity. - - A buffer's position is the index of the next element to be read or - written. A buffer's position is never negative and is never greater than its - limit. +* Write a smallish PEP about it +* Remove Py_XDECREF where possible -Invariants ----------- +Convert from ASCII formats +-------------------------- -The following invariant holds for the mark, position, limit, and capacity values: +* We need to be able to convert from ascii formats, e.g. long with an offset + (Runar, the long conversions) - 0 <= mark <= position <= limit <= capacity -A newly-created buffer always has a position of zero and a mark that is -undefined. The initial limit may be zero, or it may be some other value that -depends upon the type of the buffer and the manner in which it is -constructed. The initial content of a buffer is, in general, undefined. -Implementation --------------- +Notes on the Java NIO / ByteBuffer +================================== -* Write extensive documentation +Inspired from the interaction of: +* Java ByteBuffer class +* SocketChannel +* NIO classes Added: sandbox/trunk/hotbuffer/setup.py ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/setup.py Fri May 26 17:48:18 2006 @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +from distutils.core import setup, Extension + +VERSION = '1.0' +DESCRIPTION = "Fast I/O buffers for binary protocols" +LONG_DESCRIPTION = """ +A buffer class similar to Java NIO ByteBuffer that is meant to be used for +network I/O that avoids creating temporary strings and from which binary data +can be directly decoded. +""" + +CLASSIFIERS = filter(None, map(str.strip, +""" +Environment :: Console +Intended Audience :: Developers +License :: OSI Approved :: MIT License +Natural Language :: English +Programming Language :: Python +Topic :: Software Development :: Libraries :: Python Modules +""".splitlines())) + +setup( + name="hotbuf", + version=VERSION, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + classifiers=CLASSIFIERS, + author="Martin Blais", + author_email="blais at furius.ca", + url="http://furius.ca/python/hotbuf", + license="PSF License", + py_modules=['hotbuf'], + ext_modules=[ + Extension("_hotbuf", ["Modules/_hotbuf.c"]), + ], +) + Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 17:48:18 2006 @@ -99,8 +99,10 @@ b.clear() b.setposition(100) b.putstr(MSG) + b.setlimit(b.position) b.setposition(100) b.compact() + b.flip() self.assertEquals(str(b), MSG) def test_byte( self ): From python-checkins at python.org Fri May 26 17:51:52 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 17:51:52 +0200 (CEST) Subject: [Python-checkins] r46346 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526155152.3E6941E400C@bag.python.org> Author: richard.jones Date: Fri May 26 17:51:51 2006 New Revision: 46346 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: better unicode representation Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 17:51:51 2006 @@ -150,6 +150,18 @@ static PyObject * BaseException_unicode(BaseExceptionObject *self) { + if (PySequence_Length(self->args) == 0) + return PyUnicode_FromUnicode(NULL, 0); + if (PySequence_Length(self->args) == 1) { + PyObject *temp = PySequence_GetItem(self->args, 0); + PyObject *unicode_obj; + if (!temp) { + return NULL; + } + unicode_obj = PyObject_Unicode(temp); + Py_DECREF(temp); + return unicode_obj; + } return PyObject_Unicode(self->args); } #endif /* Py_USING_UNICODE */ From python-checkins at python.org Fri May 26 17:57:17 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 17:57:17 +0200 (CEST) Subject: [Python-checkins] r46347 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526155717.659BD1E400C@bag.python.org> Author: georg.brandl Date: Fri May 26 17:57:16 2006 New Revision: 46347 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Add pickling support to exceptions. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 17:57:16 2006 @@ -143,6 +143,14 @@ return repr; } +/* Pickling support */ +static PyObject * +BaseException_reduce(BaseExceptionObject *self) +{ + return PyTuple_Pack(3, self->ob_type, self->args, self->dict); +} + + #ifdef Py_USING_UNICODE /* while this method generates fairly uninspired output, it a least * guarantees that we can display exceptions that have unicode attributes @@ -167,6 +175,7 @@ #endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { + {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, #ifdef Py_USING_UNICODE {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, #endif @@ -195,13 +204,16 @@ }; static PyMemberDef BaseException_members[] = { - {"args", T_OBJECT, offsetof(BaseExceptionObject, args), 0, + {"args", T_OBJECT, offsetof(BaseExceptionObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, PyDoc_STR("exception message")}, + {"__dict__", T_OBJECT_EX, offsetof(BaseExceptionObject, dict), RO, + PyDoc_STR("instance dictionary")}, {NULL} /* Sentinel */ }; + static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ @@ -278,7 +290,7 @@ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; -#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMEMBERS, EXCSTR, EXCDOC) \ +#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ @@ -288,7 +300,7 @@ (reprfunc)EXCSTR, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ PyDoc_STR(EXCDOC), \ - 0, 0, 0, 0, 0, 0, 0, EXCMEMBERS, 0, &_ ## EXCBASE, \ + 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -381,7 +393,7 @@ } static PyMemberDef SystemExit_members[] = { - {"args", T_OBJECT, offsetof(SystemExitObject, args), 0, + {"args", T_OBJECT, offsetof(SystemExitObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, PyDoc_STR("exception message")}, @@ -390,7 +402,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, SystemExit_members, 0, "Request to exit from the interpreter."); +ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException @@ -553,7 +565,7 @@ } static PyMemberDef EnvironmentError_members[] = { - {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), 0, + {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, PyDoc_STR("exception message")}, @@ -566,7 +578,35 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_members, EnvironmentError_str, "Base class for I/O related errors."); + +static PyObject * +EnvironmentError_reduce(EnvironmentErrorObject *self) +{ + PyObject *args = self->args; + /* self->args is only the first two real arguments if there was a + * file name given to EnvironmentError. */ + if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) != 2) + if (self->filename != Py_None) { + args = PyTuple_New(3); + if (!args) return NULL; + PyTuple_SET_ITEM(args, 0, PyTuple_GetItem(self->args, 0)); + PyTuple_SET_ITEM(args, 1, PyTuple_GetItem(self->args, 1)); + Py_INCREF(self->filename); + PyTuple_SET_ITEM(args, 2, self->filename); + } + return PyTuple_Pack(3, self->ob_type, args, self->dict); +} + + +static PyMethodDef EnvironmentError_methods[] = { + {"__reduce__", (PyCFunction)EnvironmentError_reduce, METH_NOARGS}, + {NULL} +}; + +ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, \ + EnvironmentError_dealloc, EnvironmentError_methods, \ + EnvironmentError_members, EnvironmentError_str, \ + "Base class for I/O related errors."); /* @@ -713,7 +753,7 @@ } static PyMemberDef WindowsError_members[] = { - {"args", T_OBJECT, offsetof(WindowsErrorObject, args), 0, + {"args", T_OBJECT, offsetof(WindowsErrorObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, PyDoc_STR("exception message")}, @@ -941,7 +981,7 @@ } static PyMemberDef SyntaxError_members[] = { - {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), 0, + {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, PyDoc_STR("exception message")}, @@ -961,7 +1001,7 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, SyntaxError_members, SyntaxError_str, "Invalid syntax."); +ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); /* @@ -1010,7 +1050,7 @@ return BaseException_str(self); } -ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, KeyError_str, "Mapping key not found."); +ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, 0, KeyError_str, "Mapping key not found."); /* @@ -1335,7 +1375,7 @@ } static PyMemberDef UnicodeError_members[] = { - {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), 0, + {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), RO, PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, PyDoc_STR("exception message")}, From python-checkins at python.org Fri May 26 18:07:54 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 18:07:54 +0200 (CEST) Subject: [Python-checkins] r46348 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526160754.0D1F11E400C@bag.python.org> Author: georg.brandl Date: Fri May 26 18:07:53 2006 New Revision: 46348 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Fix refcount issues. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 18:07:53 2006 @@ -583,18 +583,35 @@ EnvironmentError_reduce(EnvironmentErrorObject *self) { PyObject *args = self->args; + PyObject *res = NULL, *tmp; /* self->args is only the first two real arguments if there was a * file name given to EnvironmentError. */ - if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) != 2) - if (self->filename != Py_None) { - args = PyTuple_New(3); - if (!args) return NULL; - PyTuple_SET_ITEM(args, 0, PyTuple_GetItem(self->args, 0)); - PyTuple_SET_ITEM(args, 1, PyTuple_GetItem(self->args, 1)); - Py_INCREF(self->filename); - PyTuple_SET_ITEM(args, 2, self->filename); - } - return PyTuple_Pack(3, self->ob_type, args, self->dict); + if (PyTuple_Check(args) && + PyTuple_GET_SIZE(args) == 2 && + self->filename != Py_None) { + + args = PyTuple_New(3); + if (!args) return NULL; + + tmp = PyTuple_GetItem(self->args, 0); + if (!tmp) goto finish; + Py_INCREF(tmp); + PyTuple_SET_ITEM(args, 0, tmp); + + tmp = PyTuple_GetItem(self->args, 1); + if (!tmp) goto finish; + Py_INCREF(tmp); + PyTuple_SET_ITEM(args, 1, tmp); + + Py_INCREF(self->filename); + PyTuple_SET_ITEM(args, 2, self->filename); + } else { + Py_INCREF(args); + } + res = PyTuple_Pack(3, self->ob_type, args, self->dict); + finish: + Py_DECREF(args); + return res; } From python-checkins at python.org Fri May 26 18:11:33 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 18:11:33 +0200 (CEST) Subject: [Python-checkins] r46349 - sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526161133.962AA1E400D@bag.python.org> Author: steve.holden Date: Fri May 26 18:11:33 2006 New Revision: 46349 Modified: sandbox/trunk/rjsh-pybench/pybench.py Log: Check broken version in for debugging. Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 18:11:33 2006 @@ -423,7 +423,7 @@ limitnames = self.values['-t'] verbose = self.values['-v'] nosyscheck = self.values['--no-syscheck'] - + print 'PYBENCH',__version__ # Switch off GC From python-checkins at python.org Fri May 26 18:14:32 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 18:14:32 +0200 (CEST) Subject: [Python-checkins] r46350 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526161432.475B61E400C@bag.python.org> Author: georg.brandl Date: Fri May 26 18:14:31 2006 New Revision: 46350 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Make dict a lazy attribute. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 18:14:31 2006 @@ -42,12 +42,9 @@ return NULL; } - self->dict = PyDict_New(); - if (self->dict == NULL) { - Py_DECREF(self); - return NULL; - } - + /* the dict is created on the fly in PyObject_GenericSetAttr */ + self->dict = NULL; + return (PyObject *)self; } @@ -208,24 +205,40 @@ PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, PyDoc_STR("exception message")}, - {"__dict__", T_OBJECT_EX, offsetof(BaseExceptionObject, dict), RO, - PyDoc_STR("instance dictionary")}, {NULL} /* Sentinel */ }; +static PyObject * +BaseException_get_dict(BaseExceptionObject *self) +{ + if (self->dict == NULL) { + self->dict = PyDict_New(); + if (!self->dict) + return NULL; + } + Py_INCREF(self->dict); + return self->dict; +} + +static PyGetSetDef BaseException_getset[] = { + {"__dict__", (getter)BaseException_get_dict, 0}, + {NULL}, +}; + + static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "BaseException", /*tp_name*/ - sizeof(BaseExceptionObject), /*tp_basicsize*/ + "BaseException", /*tp_name*/ + sizeof(BaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)BaseException_dealloc, /*tp_dealloc*/ + (destructor)BaseException_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /* tp_compare; */ - (reprfunc)BaseException_repr, /*tp_repr*/ + (reprfunc)BaseException_repr, /*tp_repr*/ 0, /*tp_as_number*/ &BaseException_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -245,12 +258,12 @@ 0, /* tp_iternext */ BaseException_methods, /* tp_methods */ BaseException_members, /* tp_members */ - 0, /* tp_getset */ + BaseException_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BaseExceptionObject, dict), /* tp_dictoffset */ + offsetof(BaseExceptionObject, dict), /* tp_dictoffset */ (initproc)BaseException_init, /* tp_init */ 0, /* tp_alloc */ BaseException_new, /* tp_new */ From python-checkins at python.org Fri May 26 18:15:51 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 18:15:51 +0200 (CEST) Subject: [Python-checkins] r46351 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c hotbuf.py test_hotbuf.py Message-ID: <20060526161551.182AA1E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 18:15:50 2006 New Revision: 46351 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/hotbuf.py sandbox/trunk/hotbuffer/test_hotbuf.py Log: rewrite hotbuf.unpack in C Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 18:15:50 2006 @@ -7,7 +7,7 @@ #include "structmember.h" #include /* for memmove */ -PyAPI_DATA(PyTypeObject) PyHotbuf_Type; +static PyTypeObject PyHotbuf_Type; #define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) @@ -86,6 +86,28 @@ * true if there was no error. */ +/* Internal Methods */ + +static int +hotbuf_advance_internal(PyHotbufObject *self, Py_ssize_t nbytes) +{ + Py_ssize_t newposition = self->b_position + nbytes; + if (newposition > self->b_limit) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than limit"); + return -1; + } + + /* Set the new position */ + self->b_position = newposition; + + /* Discard the mark if it is beyond the new position */ + if (self->b_mark > self->b_position) + self->b_mark = -1; + + return 0; +} + /* Methods */ @@ -254,26 +276,12 @@ static PyObject* hotbuf_advance(PyHotbufObject *self, PyObject* arg) { - Py_ssize_t nbytes; - Py_ssize_t newposition; - - nbytes = PyInt_AsLong(arg); + Py_ssize_t nbytes = PyInt_AsLong(arg); if (nbytes == -1 && PyErr_Occurred()) return NULL; - newposition = self->b_position + nbytes; - if ( newposition > self->b_limit ) { - PyErr_SetString(PyExc_IndexError, - "position must be smaller than limit"); + if (hotbuf_advance_internal(self, nbytes) < 0) return NULL; - } - - /* Set the new position */ - self->b_position = newposition; - - /* Discard the mark if it is beyond the new position */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; Py_RETURN_NONE; } @@ -642,7 +650,62 @@ Py_RETURN_NONE; } +PyDoc_STRVAR(unpack__doc__, +"B.unpack(structobj) -> v1, v2, ...\n\ +\n\ +Unpack the given structure directly from this buffer and advance\n\ +the position accordingly."); +static PyObject* +hotbuf_unpack(PyHotbufObject *self, PyObject* structobj) +{ + static PyObject *str_size = NULL; + static PyObject *str_unpack_from = NULL; + Py_ssize_t len = -1; + PyObject *size_obj; + PyObject *result; + + if (str_size == NULL) { + str_size = PyString_InternFromString("size"); + if (str_size == NULL) + return NULL; + } + + if (str_unpack_from == NULL) { + str_unpack_from = PyString_InternFromString("unpack_from"); + if (str_unpack_from == NULL) + return NULL; + } + + if (structobj == NULL) { + PyErr_SetString(PyExc_TypeError, + "unpack requires a single struct argument"); + return NULL; + } + + size_obj = PyObject_GetAttr(structobj, str_size); + if (size_obj == NULL) { + PyErr_SetString(PyExc_TypeError, + "unpack requires a single struct argument"); + } + + len = PyInt_AsLong(size_obj); + if (len < 0) + PyErr_SetString(PyExc_TypeError, + "unpack requires a single struct argument"); + + result = PyObject_CallMethodObjArgs(structobj, str_unpack_from, self, NULL); + + if (result == NULL) + return NULL; + + if (hotbuf_advance_internal(self, len) < 0) { + Py_DECREF(result); + result = NULL; + } + + return result; +} /* =========================================================================== @@ -747,6 +810,7 @@ {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, {"getstr", (PyCFunction)hotbuf_getstr, METH_VARARGS, getstr__doc__}, {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, + {"unpack", (PyCFunction)hotbuf_unpack, METH_O, unpack__doc__}, {NULL, NULL} /* sentinel */ }; @@ -768,7 +832,7 @@ }; static PyTypeObject PyHotbuf_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "_hotbuf._hotbuf", sizeof(PyHotbufObject), @@ -852,6 +916,9 @@ if (m == NULL) return; + if (PyType_Ready(&PyHotbuf_Type) < 0) + return; + Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Py_INCREF((PyObject *)&PyHotbuf_Type); Modified: sandbox/trunk/hotbuffer/hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/hotbuf.py (original) +++ sandbox/trunk/hotbuffer/hotbuf.py Fri May 26 18:15:50 2006 @@ -17,13 +17,3 @@ """ structobj.pack_to(self, 0, *values) self.advance(structobj.size) - - def unpack( self, structobj ): - """ - Pack using the given Struct object 'structobj', the remaining arguments. - """ - values = structobj.unpack_from(self, 0) - self.advance(structobj.size) - return values - - Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 18:15:50 2006 @@ -175,6 +175,19 @@ b.setlimit(len(s)) self.assertEquals(str(b), s) + def test_pack_method(self): + ARGS = 42, 16, '@', 3 + # Pack to a string. + s = fmt.pack(*ARGS) + + # Pack directly into the buffer and compare the strings. + b = hotbuf(CAPACITY) + b.setlimit(len(s)) + b.pack(fmt, *ARGS) + self.assertEquals(b.position, fmt.size) + b.flip() + self.assertEquals(str(b), s) + def test_unpack( self ): ARGS = 42, 16, '@', 3 b = hotbuf(CAPACITY) @@ -187,6 +200,19 @@ b.flip() self.assertEquals(fmt.unpack_from(b), ARGS) + def test_unpack_method( self ): + ARGS = 42, 16, '@', 3 + b = hotbuf(CAPACITY) + + # Pack normally and put that string in the buffer. + s = fmt.pack(*ARGS) + b.putstr(s) + + # Unpack directly from the buffer and compare. + b.flip() + self.assertEquals(b.unpack(fmt), ARGS) + self.assertEquals(b.position, fmt.size) + def test_zerolen( self ): b = hotbuf(CAPACITY) b.setlimit(0) From python-checkins at python.org Fri May 26 18:22:53 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 18:22:53 +0200 (CEST) Subject: [Python-checkins] r46352 - python/trunk/Lib/test/string_tests.py Message-ID: <20060526162253.52A541E401C@bag.python.org> Author: andrew.dalke Date: Fri May 26 18:22:52 2006 New Revision: 46352 Modified: python/trunk/Lib/test/string_tests.py Log: Test for more edge strip cases; leading and trailing separator gets removed even with strip(..., 0) Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 18:22:52 2006 @@ -246,6 +246,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, sys.maxint-1) self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) + self.checkequal(['a b c d'], ' a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) self.checkequal([], ' ', 'split') @@ -332,6 +333,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, sys.maxint-20) self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0) + self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0) self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) self.checkequal([], ' ', 'rsplit') From python-checkins at python.org Fri May 26 18:23:10 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 18:23:10 +0200 (CEST) Subject: [Python-checkins] r46353 - sandbox/trunk/rjsh-pybench/pybench.py Message-ID: <20060526162310.5E8681E400F@bag.python.org> Author: steve.holden Date: Fri May 26 18:23:10 2006 New Revision: 46353 Modified: sandbox/trunk/rjsh-pybench/pybench.py Log: Fix option handling bug. Modified: sandbox/trunk/rjsh-pybench/pybench.py ============================================================================== --- sandbox/trunk/rjsh-pybench/pybench.py (original) +++ sandbox/trunk/rjsh-pybench/pybench.py Fri May 26 18:23:10 2006 @@ -421,7 +421,7 @@ warp = self.values['-w'] nogc = self.values['--no-gc'] limitnames = self.values['-t'] - verbose = self.values['-v'] + verbose = self.verbose nosyscheck = self.values['--no-syscheck'] print 'PYBENCH',__version__ From python-checkins at python.org Fri May 26 18:23:29 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 18:23:29 +0200 (CEST) Subject: [Python-checkins] r46354 - python/trunk/Modules/_struct.c Message-ID: <20060526162329.30DC61E400C@bag.python.org> Author: bob.ippolito Date: Fri May 26 18:23:28 2006 New Revision: 46354 Modified: python/trunk/Modules/_struct.c Log: fix signed/unsigned mismatch in struct Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 18:23:28 2006 @@ -763,7 +763,7 @@ return -1; i = f->size; #ifdef PY_STRUCT_RANGE_CHECKING - if (i != SIZEOF_LONG && x >= (1 << (i * 8))) + if (i != SIZEOF_LONG && x >= (1 << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); #endif do { @@ -975,7 +975,7 @@ return -1; i = f->size; #ifdef PY_STRUCT_RANGE_CHECKING - if (i != SIZEOF_LONG && x >= (1 << (i * 8))) + if (i != SIZEOF_LONG && x >= (1 << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); #endif do { From python-checkins at python.org Fri May 26 18:28:00 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 18:28:00 +0200 (CEST) Subject: [Python-checkins] r46355 - python/trunk/Tools/pybench/Arithmetic.py python/trunk/Tools/pybench/Calls.py python/trunk/Tools/pybench/Constructs.py python/trunk/Tools/pybench/Dict.py python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/Exceptions.py python/trunk/Tools/pybench/Imports.py python/trunk/Tools/pybench/Instances.py python/trunk/Tools/pybench/Lists.py python/trunk/Tools/pybench/Lookups.py python/trunk/Tools/pybench/NewInstances.py python/trunk/Tools/pybench/Numbers.py python/trunk/Tools/pybench/Setup.py python/trunk/Tools/pybench/Strings.py python/trunk/Tools/pybench/Tuples.py python/trunk/Tools/pybench/Unicode.py python/trunk/Tools/pybench/pybench.py Message-ID: <20060526162800.C43C21E400C@bag.python.org> Author: steve.holden Date: Fri May 26 18:27:59 2006 New Revision: 46355 Added: python/trunk/Tools/pybench/Empty.py (contents, props changed) python/trunk/Tools/pybench/NewInstances.py (contents, props changed) Modified: python/trunk/Tools/pybench/Arithmetic.py python/trunk/Tools/pybench/Calls.py python/trunk/Tools/pybench/Constructs.py python/trunk/Tools/pybench/Dict.py python/trunk/Tools/pybench/Exceptions.py python/trunk/Tools/pybench/Imports.py python/trunk/Tools/pybench/Instances.py python/trunk/Tools/pybench/Lists.py python/trunk/Tools/pybench/Lookups.py python/trunk/Tools/pybench/Numbers.py python/trunk/Tools/pybench/Setup.py python/trunk/Tools/pybench/Strings.py python/trunk/Tools/pybench/Tuples.py python/trunk/Tools/pybench/Unicode.py python/trunk/Tools/pybench/pybench.py Log: Add -t option to allow easy test selection. Action verbose option correctly. Tweak operation counts. Add empty and new instances tests. Enable comparisons across different warp factors. Change version. Modified: python/trunk/Tools/pybench/Arithmetic.py ============================================================================== --- python/trunk/Tools/pybench/Arithmetic.py (original) +++ python/trunk/Tools/pybench/Arithmetic.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 120000 + rounds = 1200*21 def test(self): @@ -159,7 +159,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 100000 + rounds = 1000*30 def test(self): @@ -314,7 +314,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 120000 + rounds = 1200*30 def test(self): @@ -470,7 +470,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 30000 + rounds = 300*32 def test(self): @@ -625,7 +625,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 40000 + rounds = 400*27 def test(self): Modified: python/trunk/Tools/pybench/Calls.py ============================================================================== --- python/trunk/Tools/pybench/Calls.py (original) +++ python/trunk/Tools/pybench/Calls.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(1+4+4+2) - rounds = 60000 + rounds = 600*22 def test(self): @@ -113,7 +113,7 @@ version = 0.4 operations = 5*(2+5+5+5) - rounds = 30000 + rounds = 300*24 def test(self): @@ -234,7 +234,7 @@ version = 0.3 operations = 5*(6 + 5 + 4) - rounds = 20000 + rounds = 200*27 def test(self): @@ -376,7 +376,7 @@ version = 0.3 operations = 5 - rounds = 50000 + rounds = 500*21 def test(self): Modified: python/trunk/Tools/pybench/Constructs.py ============================================================================== --- python/trunk/Tools/pybench/Constructs.py (original) +++ python/trunk/Tools/pybench/Constructs.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 30*3 # hard to say... - rounds = 150000 + rounds = 1500*27 def test(self): @@ -471,7 +471,7 @@ version = 0.3 operations = 1000*10*5 - rounds = 150 + rounds = 100 def test(self): @@ -496,7 +496,7 @@ version = 0.1 operations = 5 * 5 - rounds = 8000 + rounds = 80*25 def test(self): Modified: python/trunk/Tools/pybench/Dict.py ============================================================================== --- python/trunk/Tools/pybench/Dict.py (original) +++ python/trunk/Tools/pybench/Dict.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(5 + 5) - rounds = 60000 + rounds = 600*24 def test(self): @@ -79,7 +79,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 2000*30 def test(self): @@ -168,7 +168,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 20000 def test(self): @@ -257,7 +257,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 200000 + rounds = 2000*19 def test(self): @@ -346,7 +346,7 @@ version = 0.3 operations = 5*(6 + 6 + 6 + 6) - rounds = 50000 + rounds = 500*44 def test(self): Added: python/trunk/Tools/pybench/Empty.py ============================================================================== --- (empty file) +++ python/trunk/Tools/pybench/Empty.py Fri May 26 18:27:59 2006 @@ -0,0 +1,23 @@ +from pybench import Test + +class EmptyTest(Test): + """This is just here as a potential measure of repeatability.""" + + version = 0.3 + operations = 1 + rounds = 60000 + + def test(self): + + l = [] + for i in xrange(self.rounds): + pass + + + def calibrate(self): + + l = [] + + for i in xrange(self.rounds): + pass + Modified: python/trunk/Tools/pybench/Exceptions.py ============================================================================== --- python/trunk/Tools/pybench/Exceptions.py (original) +++ python/trunk/Tools/pybench/Exceptions.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 2 + 3 - rounds = 60000 + rounds = 600*25 def test(self): @@ -44,7 +44,7 @@ version = 0.1 operations = 15 * 10 - rounds = 200000 + rounds = 2000*16 def test(self): Modified: python/trunk/Tools/pybench/Imports.py ============================================================================== --- python/trunk/Tools/pybench/Imports.py (original) +++ python/trunk/Tools/pybench/Imports.py Fri May 26 18:27:59 2006 @@ -8,7 +8,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 2000*15 def test(self): @@ -53,7 +53,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 200*20 def test(self): @@ -97,7 +97,7 @@ version = 0.1 operations = 5 * 5 - rounds = 20000 + rounds = 200*17 def test(self): Modified: python/trunk/Tools/pybench/Instances.py ============================================================================== --- python/trunk/Tools/pybench/Instances.py (original) +++ python/trunk/Tools/pybench/Instances.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.2 operations = 3 + 7 + 4 - rounds = 60000 + rounds = 600*17 def test(self): Modified: python/trunk/Tools/pybench/Lists.py ============================================================================== --- python/trunk/Tools/pybench/Lists.py (original) +++ python/trunk/Tools/pybench/Lists.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5* (6 + 6 + 6) - rounds = 60000 + rounds = 600*45 def test(self): @@ -132,7 +132,7 @@ version = 0.4 operations = 25*(3+1+2+1) - rounds = 400 + rounds = 4*45 def test(self): @@ -169,7 +169,7 @@ version = 0.3 operations = 5*(1+ 6 + 6 + 3 + 1) - rounds = 60000 + rounds = 600*15 def test(self): Modified: python/trunk/Tools/pybench/Lookups.py ============================================================================== --- python/trunk/Tools/pybench/Lookups.py (original) +++ python/trunk/Tools/pybench/Lookups.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 1000*16 def test(self): @@ -185,7 +185,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 1000*20 def test(self): @@ -371,7 +371,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 1000*14 def test(self): @@ -559,7 +559,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 100000 + rounds = 1000*22 def test(self): @@ -747,7 +747,7 @@ version = 0.3 operations = 5*(3*5 + 3*5) - rounds = 70000 + rounds = 700*15 def test(self): Added: python/trunk/Tools/pybench/NewInstances.py ============================================================================== --- (empty file) +++ python/trunk/Tools/pybench/NewInstances.py Fri May 26 18:27:59 2006 @@ -0,0 +1,66 @@ +from pybench import Test + +class CreateNewInstances(Test): + + version = 0.1 + operations = 3 + 7 + 4 + rounds = 60000 + + def test(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + o = c() + o1 = c() + o2 = c() + p = d(i,i,3) + p1 = d(i,i,3) + p2 = d(i,3,3) + p3 = d(3,i,3) + p4 = d(i,i,i) + p5 = d(3,i,3) + p6 = d(i,i,i) + q = e(i,i,3) + q1 = e(i,i,3) + q2 = e(i,i,3) + q3 = e(i,i) + + def calibrate(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + pass Modified: python/trunk/Tools/pybench/Numbers.py ============================================================================== --- python/trunk/Tools/pybench/Numbers.py (original) +++ python/trunk/Tools/pybench/Numbers.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 30 * 5 - rounds = 120000 + rounds = 1200*21 def test(self): @@ -200,7 +200,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 600*27 def test(self): @@ -396,7 +396,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 600*16 def test(self): @@ -592,7 +592,7 @@ version = 0.1 operations = 30 * 5 - rounds = 60000 + rounds = 600*24 def test(self): Modified: python/trunk/Tools/pybench/Setup.py ============================================================================== --- python/trunk/Tools/pybench/Setup.py (original) +++ python/trunk/Tools/pybench/Setup.py Fri May 26 18:27:59 2006 @@ -17,11 +17,16 @@ Warp_factor = 20 # Import tests +#from Empty import * from Arithmetic import * from Calls import * from Constructs import * from Lookups import * from Instances import * +try: + from NewInstances import * +except: + print "Cannot test new-style objects" from Lists import * from Tuples import * from Dict import * Modified: python/trunk/Tools/pybench/Strings.py ============================================================================== --- python/trunk/Tools/pybench/Strings.py (original) +++ python/trunk/Tools/pybench/Strings.py Fri May 26 18:27:59 2006 @@ -5,7 +5,7 @@ version = 0.1 operations = 10 * 5 - rounds = 60000 + rounds = 6000 def test(self): @@ -87,7 +87,7 @@ version = 0.2 operations = 10 * 5 - rounds = 200000 + rounds = 2000*22 def test(self): @@ -169,7 +169,7 @@ version = 0.1 operations = 10 * 5 - rounds = 200000 + rounds = 2000*28 def test(self): @@ -251,7 +251,7 @@ version = 0.1 operations = 10 * 5 - rounds = 80000 + rounds = 800*32 def test(self): @@ -326,7 +326,7 @@ version = 0.1 operations = 5 * 7 - rounds = 100000 + rounds = 1000*15 def test(self): @@ -389,7 +389,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 70000 + rounds = 14000 def test(self): @@ -462,7 +462,7 @@ version = 0.1 operations = 10 * 7 - rounds = 80000 + rounds = 800*24 def test(self): Modified: python/trunk/Tools/pybench/Tuples.py ============================================================================== --- python/trunk/Tools/pybench/Tuples.py (original) +++ python/trunk/Tools/pybench/Tuples.py Fri May 26 18:27:59 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 3 * 25 * 10 * 7 - rounds = 400 + rounds = 100 def test(self): @@ -272,7 +272,7 @@ version = 0.3 operations = 5*(1 + 3 + 6 + 2) - rounds = 80000 + rounds = 800*16 def test(self): Modified: python/trunk/Tools/pybench/Unicode.py ============================================================================== --- python/trunk/Tools/pybench/Unicode.py (original) +++ python/trunk/Tools/pybench/Unicode.py Fri May 26 18:27:59 2006 @@ -10,7 +10,7 @@ version = 0.1 operations = 10 * 5 - rounds = 60000 + rounds = 600*7 def test(self): @@ -92,7 +92,7 @@ version = 0.1 operations = 10 * 5 - rounds = 150000 + rounds = 1500*17 def test(self): @@ -174,7 +174,7 @@ version = 0.1 operations = 10 * 5 - rounds = 80000 + rounds = 800*12 def test(self): @@ -249,7 +249,7 @@ version = 0.1 operations = 5 * 7 - rounds = 100000 + rounds = 10000 def test(self): @@ -310,7 +310,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 10000 + rounds = 100*15 def test(self): @@ -383,7 +383,7 @@ version = 0.1 operations = 5 * 9 - rounds = 100000 + rounds = 1000*25 def test(self): @@ -460,7 +460,7 @@ version = 0.1 operations = 5 * 8 - rounds = 100000 + rounds = 1000*15 def test(self): Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri May 26 18:27:59 2006 @@ -35,7 +35,7 @@ """ # Version number -__version__ = '1.3' +__version__ = '1.4' # # NOTE: Use xrange for all test loops unless you want to face @@ -98,7 +98,7 @@ # Number of rounds to execute per test run. This should be # adjusted to a figure that results in a test run-time of between # 20-50 seconds. - rounds = 100000 + rounds = 10000 ### Internal variables @@ -115,6 +115,8 @@ if warp > 1: self.rounds = self.rounds / warp + if self.rounds == 0: + self.rounds = 1 self.warp = warp self.times = [] self.overhead = [] @@ -137,12 +139,13 @@ cruns = self.cruns # first calibrate offset = 0.0 - for i in range(cruns): - t = clock() - calibrate() - t = clock() - t - offset = offset + t - offset = offset / cruns + if cruns: + for i in range(cruns): + t = clock() + calibrate() + t = clock() - t + offset = offset + t + offset = offset / cruns # now the real thing t = clock() test() @@ -175,13 +178,18 @@ def stat(self): - """ Returns two value: average time per run and average per - operation. + """ Returns four values: + minimum round time + average time per round + average time per operation + average overhead time + XXX Should this take warp factors into account? """ runs = len(self.times) if runs == 0: return 0,0 + mintime = min(self.times) totaltime = reduce(operator.add,self.times,0.0) avg = totaltime / float(runs) op_avg = totaltime / float(runs * self.rounds * self.operations) @@ -191,7 +199,7 @@ else: # use self.last_timing - not too accurate ov_avg = self.last_timing[2] - return avg,op_avg,ov_avg + return mintime, avg, op_avg, ov_avg ### Load Setup @@ -210,105 +218,132 @@ roundtime = 0 # Average round time version = None # Benchmark version number (see __init__) # as float x.yy - starttime = None # Benchmark start time def __init__(self): self.tests = {} self.version = 0.31 - def load_tests(self,setupmod,warp=1): + def load_tests(self, setupmod, warp=1, limitnames="", verbose=0): self.warp = warp + if limitnames: + limitnames = re.compile(limitnames, re.I) + else: + limitnames = None tests = self.tests - print 'Searching for tests...' + if verbose: + print 'Searching for tests ...', setupmod.__dict__.values() for c in setupmod.__dict__.values(): - if hasattr(c,'is_a_test') and c.__name__ != 'Test': - tests[c.__name__] = c(warp) + if not hasattr(c,'is_a_test'): + continue + name = c.__name__ + if name == 'Test': + continue + if limitnames is not None and limitnames.search(name) is None: + continue + tests[name] = c(warp) l = tests.keys() l.sort() - for t in l: - print ' ',t + if verbose: + print + for t in l: + print ' ', t + print len(l), "tests found" print - def run(self): + def run(self, verbose): tests = self.tests.items() tests.sort() clock = time.clock - print 'Running %i round(s) of the suite: ' % self.rounds + print 'Running %i round(s) of the suite at warp factor %i:' % (self.rounds, self.warp) print - self.starttime = time.time() roundtime = clock() for i in range(self.rounds): - print ' Round %-25i real abs overhead' % (i+1) + roundstarttime = clock() + if verbose: + print ' Round %-25i real abs overhead' % (i+1) for j in range(len(tests)): name,t = tests[j] - print '%30s:' % name, + if verbose: + print '%30s:' % name, t.run() - print ' %.3fr %.3fa %.3fo' % t.last_timing - print ' ----------------------' - print ' Average round time: %.3f seconds' % \ - ((clock() - roundtime)/(i+1)) - print + if verbose: + print ' %.3fr %.3fa %.3fo' % t.last_timing + if verbose: + print ' ----------------------' + print ' Average round time: %.3f seconds' % \ + ((clock() - roundtime)/(i+1)) + print + else: + print '%d done in %.3f seconds' % (i+1, (clock() - roundstarttime)) self.roundtime = (clock() - roundtime) / self.rounds print def print_stat(self, compare_to=None, hidenoise=0): if not compare_to: - print '%-30s per run per oper. overhead' % 'Tests:' - print '-'*72 + print '%-30s min run avg run per oprn overhead' % 'Tests:' + print '-'*77 tests = self.tests.items() tests.sort() + totalmintime = 0 for name,t in tests: - avg,op_avg,ov_avg = t.stat() - print '%30s: %10.2f ms %7.2f us %7.2f ms' % \ - (name,avg*1000.0,op_avg*1000000.0,ov_avg*1000.0) - print '-'*72 - print '%30s: %10.2f ms' % \ - ('Average round time',self.roundtime * 1000.0) + mintime,avg,op_avg,ov_avg = t.stat() + totalmintime += mintime + print '%30s: %9.2f ms %9.2f ms %6.2f us %6.2f' % \ + (name,mintime*1000.0,avg*1000.0,op_avg*1000000.0,ov_avg*1000.0) + print '-'*77 + print '%30s: %9.2f ms' % \ + ('Notional minimum round time', totalmintime * 1000.0) else: - print '%-30s per run per oper. diff *)' % \ + print 'Comparing with: %s (rounds=%i, warp=%i)' % \ + (compare_to.name,compare_to.rounds,compare_to.warp) + print '%-30s min run cmp run avg run diff' % \ 'Tests:' - print '-'*72 + print '-'*77 tests = self.tests.items() tests.sort() compatible = 1 - for name,t in tests: - avg,op_avg,ov_avg = t.stat() + totalmintime = other_totalmintime = 0 + for name, t in tests: + mintime, avg, op_avg, ov_avg = t.stat() + totalmintime += mintime try: other = compare_to.tests[name] except KeyError: other = None if other and other.version == t.version and \ other.operations == t.operations: - avg1,op_avg1,ov_avg1 = other.stat() - qop_avg = (op_avg/op_avg1-1.0)*100.0 + mintime1, avg1, op_avg1, ov_avg1 = other.stat() + other_totalmintime += mintime1 + diff = ((mintime*self.warp)/(mintime1*other.warp) - 1.0)*100.0 if hidenoise and abs(qop_avg) < 10: - qop_avg = '' + diff = '' else: - qop_avg = '%+7.2f%%' % qop_avg + diff = '%+7.2f%%' % diff else: - qavg,qop_avg = 'n/a', 'n/a' + qavg, diff = 'n/a', 'n/a' compatible = 0 - print '%30s: %10.2f ms %7.2f us %8s' % \ - (name,avg*1000.0,op_avg*1000000.0,qop_avg) - print '-'*72 + print '%30s: %8.2f ms %8.2f ms %8.2f ms %8s' % \ + (name,mintime*1000.0,mintime1*1000.0 * compare_to.warp/self.warp, avg*1000.0,diff) + print '-'*77 + # + # Summarise test results + # if compatible and compare_to.roundtime > 0 and \ compare_to.version == self.version: - print '%30s: %10.2f ms %+7.2f%%' % \ - ('Average round time',self.roundtime * 1000.0, - ((self.roundtime*self.warp)/ - (compare_to.roundtime*compare_to.warp)-1.0)*100.0) + print '%30s: %8.2f ms %8.2f ms %+7.2f%%' % \ + ('Notional minimum round time', totalmintime * 1000.0, + other_totalmintime * 1000.0 * compare_to.warp/self.warp, + ((totalmintime*self.warp)/ + (other_totalmintime*compare_to.warp)-1.0)*100.0) else: - print '%30s: %10.2f ms n/a' % \ - ('Average round time',self.roundtime * 1000.0) - print - print '*) measured against: %s (rounds=%i, warp=%i)' % \ - (compare_to.name,compare_to.rounds,compare_to.warp) + print '%30s: %9.2f ms n/a' % \ + ('Notional minimum round time', totalmintime * 1000.0) print def print_machine(): @@ -339,7 +374,12 @@ SwitchOption('-S','show statistics of benchmarks',0), ArgumentOption('-w','set warp factor to arg',Setup.Warp_factor), SwitchOption('-d','hide noise in compares', 0), + SwitchOption('-v','verbose output (not recommended)', 0), SwitchOption('--no-gc','disable garbage collection', 0), + SwitchOption('--no-syscheck', + '"disable" sys check interval (set to sys.maxint)', 0), + ArgumentOption('-t', 'tests containing substring', ''), + ArgumentOption('-C', 'number of calibration runs (default 0)', '') ] about = """\ @@ -380,6 +420,11 @@ hidenoise = self.values['-d'] warp = self.values['-w'] nogc = self.values['--no-gc'] + limitnames = self.values['-t'] + verbose = self.verbose + nosyscheck = self.values['--no-syscheck'] + + print 'PYBENCH',__version__ # Switch off GC if nogc: @@ -390,8 +435,13 @@ else: if self.values['--no-gc']: gc.disable() + print 'NO GC' + + # maximise sys check interval + if nosyscheck: + sys.setcheckinterval(sys.maxint) + print 'CHECKINTERVAL =', sys.maxint - print 'PYBENCH',__version__ print if not compare_to: @@ -436,9 +486,9 @@ # Create benchmark object bench = Benchmark() bench.rounds = rounds - bench.load_tests(Setup,warp) + bench.load_tests(Setup, warp, limitnames, verbose) try: - bench.run() + bench.run(verbose) except KeyboardInterrupt: print print '*** KeyboardInterrupt -- Aborting' From python-checkins at python.org Fri May 26 18:32:42 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 18:32:42 +0200 (CEST) Subject: [Python-checkins] r46356 - python/trunk/Objects/stringobject.c Message-ID: <20060526163242.B93A91E400C@bag.python.org> Author: fredrik.lundh Date: Fri May 26 18:32:42 2006 New Revision: 46356 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: use Py_LOCAL on a few more locals in stringobject.c Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 18:32:42 2006 @@ -1,6 +1,7 @@ /* String object implementation */ #define PY_SSIZE_T_CLEAN + #include "Python.h" #include @@ -1485,7 +1486,7 @@ #define RSKIP_SPACE(s, i) { while (i>=0 && isspace(Py_CHARMASK(s[i]))) i--; } #define RSKIP_NONSPACE(s, i) { while (i>=0 && !isspace(Py_CHARMASK(s[i]))) i--; } -static PyObject * +Py_LOCAL(PyObject *) split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { Py_ssize_t i, j, count=0; @@ -1519,7 +1520,7 @@ return NULL; } -static PyObject * +Py_LOCAL(PyObject *) split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { register Py_ssize_t i, j, count=0; @@ -1674,7 +1675,7 @@ return out; } -static PyObject * +Py_LOCAL(PyObject *) rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { Py_ssize_t i, j, count=0; @@ -1710,7 +1711,7 @@ return NULL; } -static PyObject * +Py_LOCAL(PyObject *) rsplit_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { register Py_ssize_t i, j, count=0; @@ -1923,7 +1924,7 @@ return string_join((PyStringObject *)sep, x); } -static void +Py_LOCAL(void) string_adjust_indices(Py_ssize_t *start, Py_ssize_t *end, Py_ssize_t len) { if (*end > len) @@ -1938,7 +1939,7 @@ *start = 0; } -static Py_ssize_t +Py_LOCAL(Py_ssize_t) string_find_internal(PyStringObject *self, PyObject *args, int dir) { const char *s = PyString_AS_STRING(self), *sub; @@ -2074,7 +2075,7 @@ } -static PyObject * +Py_LOCAL(PyObject *) do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj) { char *s = PyString_AS_STRING(self); @@ -2107,7 +2108,7 @@ } -static PyObject * +Py_LOCAL(PyObject *) do_strip(PyStringObject *self, int striptype) { char *s = PyString_AS_STRING(self); @@ -2137,7 +2138,7 @@ } -static PyObject * +Py_LOCAL(PyObject *) do_argstrip(PyStringObject *self, int striptype, PyObject *args) { PyObject *sep = NULL; @@ -2600,7 +2601,7 @@ /* String ops must return a string. */ /* If the object is subclass of string, create a copy */ -static PyStringObject * +Py_LOCAL(PyStringObject *) return_self(PyStringObject *self) { if (PyString_CheckExact(self)) { @@ -2612,7 +2613,7 @@ PyString_GET_SIZE(self)); } -static Py_ssize_t +Py_LOCAL(Py_ssize_t) countchar(char *target, int target_len, char c) { Py_ssize_t count=0; @@ -2627,7 +2628,7 @@ return count; } -static Py_ssize_t +Py_LOCAL(Py_ssize_t) findstring(char *target, Py_ssize_t target_len, char *pattern, Py_ssize_t pattern_len, Py_ssize_t start, @@ -2665,7 +2666,7 @@ return -1; } -Py_ssize_t +Py_LOCAL(Py_ssize_t) countstring(char *target, Py_ssize_t target_len, char *pattern, Py_ssize_t pattern_len, Py_ssize_t start, @@ -2713,7 +2714,7 @@ /* Algorithms for difference cases of string replacement */ /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_interleave(PyStringObject *self, PyStringObject *to, Py_ssize_t maxcount) @@ -2776,7 +2777,7 @@ /* Special case for deleting a single character */ /* len(self)>=1, len(from)==1, to="", maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_delete_single_character(PyStringObject *self, char from_c, Py_ssize_t maxcount) { @@ -2821,7 +2822,7 @@ /* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_delete_substring(PyStringObject *self, PyStringObject *from, Py_ssize_t maxcount) { char *self_s, *from_s, *result_s; @@ -2876,7 +2877,7 @@ } /* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_single_character_in_place(PyStringObject *self, char from_c, char to_c, Py_ssize_t maxcount) @@ -2921,7 +2922,7 @@ } /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_substring_in_place(PyStringObject *self, PyStringObject *from, PyStringObject *to, @@ -2978,7 +2979,7 @@ } /* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_single_character(PyStringObject *self, char from_c, PyStringObject *to, @@ -3051,7 +3052,7 @@ } /* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ -static PyStringObject * +Py_LOCAL(PyStringObject *) replace_substring(PyStringObject *self, PyStringObject *from, PyStringObject *to, @@ -3129,7 +3130,7 @@ } -static PyStringObject * +Py_LOCAL(PyStringObject *) replace(PyStringObject *self, PyStringObject *from, PyStringObject *to, @@ -3490,7 +3491,7 @@ return u; } -static PyObject * +Py_LOCAL(PyObject *) pad(PyStringObject *self, Py_ssize_t left, Py_ssize_t right, char fill) { PyObject *u; @@ -4241,7 +4242,7 @@ /* Helpers for formatstring */ -static PyObject * +Py_LOCAL(PyObject *) getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx) { Py_ssize_t argidx = *p_argidx; @@ -4270,7 +4271,7 @@ #define F_ALT (1<<3) #define F_ZERO (1<<4) -static int +Py_LOCAL(int) formatfloat(char *buf, size_t buflen, int flags, int prec, int type, PyObject *v) { @@ -4457,7 +4458,7 @@ return result; } -static int +Py_LOCAL(int) formatint(char *buf, size_t buflen, int flags, int prec, int type, PyObject *v) { @@ -4529,7 +4530,7 @@ return (int)strlen(buf); } -static int +Py_LOCAL(int) formatchar(char *buf, size_t buflen, PyObject *v) { /* presume that the buffer is at least 2 characters long */ From python-checkins at python.org Fri May 26 18:42:45 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 26 May 2006 18:42:45 +0200 (CEST) Subject: [Python-checkins] r46357 - python/trunk/Doc/lib/lib.tex python/trunk/Doc/lib/libctypesref.tex Message-ID: <20060526164245.3CDF11E400C@bag.python.org> Author: thomas.heller Date: Fri May 26 18:42:44 2006 New Revision: 46357 Added: python/trunk/Doc/lib/libctypesref.tex (contents, props changed) Modified: python/trunk/Doc/lib/lib.tex Log: For now, I gave up with automatic conversion of reST to Python-latex, so I'm writing this in latex now. Skeleton for the ctypes reference. Modified: python/trunk/Doc/lib/lib.tex ============================================================================== --- python/trunk/Doc/lib/lib.tex (original) +++ python/trunk/Doc/lib/lib.tex Fri May 26 18:42:44 2006 @@ -245,6 +245,7 @@ \input{libplatform} \input{liberrno} \input{libctypes} +\input{libctypesref} \input{libsomeos} % Optional Operating System Services \input{libselect} Added: python/trunk/Doc/lib/libctypesref.tex ============================================================================== --- (empty file) +++ python/trunk/Doc/lib/libctypesref.tex Fri May 26 18:42:44 2006 @@ -0,0 +1,206 @@ +\subsection{ctypes reference\label{ctypes-reference}} + +\begin{funcdesc}{addressof}{obj} +\end{funcdesc} + +\begin{funcdesc}{alignment}{obj_or_type} +\end{funcdesc} + +\begin{excclassdesc}{ArgumentError}{} +\end{excclassdesc} + +\begin{classdesc}{BigEndianStructure}{} +\end{classdesc} + +\begin{funcdesc}{byref}{obj} +\end{funcdesc} + +\begin{classdesc}{c_byte}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_char}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_char_p}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_double}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_float}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_int}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_int16}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_int32}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_int64}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_int8}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_long}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_longlong}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_short}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_size_t}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_ubyte}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_uint}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_uint16}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_uint32}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_uint64}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_uint8}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_ulong}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_ulonglong}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_ushort}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_void_p}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_wchar}{\optional{value}} +\end{classdesc} + +\begin{classdesc}{c_wchar_p}{\optional{value}} +\end{classdesc} + +\begin{funcdesc}{cast}{obj, type} +\end{funcdesc} + +\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None} +\end{classdesc} + +\begin{datadesc}{cdll} +\end{datadesc} + +\begin{funcdesc}{CFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{create_string_buffer}{init\optional{, size}} +\end{funcdesc} + +\begin{funcdesc}{create_unicode_buffer}{init\optional{, size}} +\end{funcdesc} + +\begin{funcdesc}{DllCanUnloadNow}{} +\end{funcdesc} + +\begin{funcdesc}{DllGetClassObject}{} +\end{funcdesc} + +\begin{funcdesc}{FormatError}{} +\end{funcdesc} + +\begin{funcdesc}{GetLastError}{} +\end{funcdesc} + +\begin{classdesc}{HRESULT}{} +\end{classdesc} + +\begin{classdesc}{LibraryLoader}{dlltype} +\end{classdesc} + +\begin{classdesc}{LittleEndianStructure}{} +\end{classdesc} + +\begin{funcdesc}{memmove}{dst, src, count} +\end{funcdesc} + +\begin{funcdesc}{memset}{dst, c, count} +\end{funcdesc} + +\begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None} +\end{classdesc} + +\begin{datadesc}{oledll} +\end{datadesc} + +\begin{funcdesc}{POINTER}{} +\end{funcdesc} + +\begin{funcdesc}{pointer}{} +\end{funcdesc} + +\begin{classdesc}{py_object}{} +\end{classdesc} + +\begin{classdesc}{PyDLL}{name, mode=RTLD_LOCAL, handle=None} +\end{classdesc} + +\begin{datadesc}{pydll}{} +\end{datadesc} + +\begin{funcdesc}{PYFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{pythonapi}{} +\end{funcdesc} + +\begin{funcdesc}{resize}{} +\end{funcdesc} + +\begin{datadesc}{RTLD_GLOBAL} +\end{datadesc} + +\begin{datadesc}{RTLD_LOCAL} +\end{datadesc} + +\begin{funcdesc}{set_conversion_mode}{} +\end{funcdesc} + +\begin{funcdesc}{sizeof}{} +\end{funcdesc} + +\begin{funcdesc}{string_at}{address} +\end{funcdesc} + +\begin{classdesc}{Structure}{} +\end{classdesc} + +\begin{classdesc}{Union}{} +\end{classdesc} + +\begin{classdesc}{WinDLL}{name, mode=RTLD_LOCAL, handle=None} +\end{classdesc} + +\begin{datadesc}{windll} +\end{datadesc} + +\begin{funcdesc}{WinError}{} +\end{funcdesc} + +\begin{funcdesc}{WINFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{wstring_at}{address} +\end{funcdesc} + From buildbot at python.org Fri May 26 18:47:25 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 16:47:25 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060526164726.179811E400E@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/544 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 18:49:29 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 18:49:29 +0200 (CEST) Subject: [Python-checkins] r46358 - python/trunk/Modules/_struct.c Message-ID: <20060526164929.1905A1E400C@bag.python.org> Author: tim.peters Date: Fri May 26 18:49:28 2006 New Revision: 46358 Modified: python/trunk/Modules/_struct.c Log: Repair Windows compiler warnings about mixing signed and unsigned integral types in comparisons. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 18:49:28 2006 @@ -763,7 +763,7 @@ return -1; i = f->size; #ifdef PY_STRUCT_RANGE_CHECKING - if (i != SIZEOF_LONG && x >= (1 << (((unsigned int)i) * 8))) + if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); #endif do { @@ -975,7 +975,7 @@ return -1; i = f->size; #ifdef PY_STRUCT_RANGE_CHECKING - if (i != SIZEOF_LONG && x >= (1 << (((unsigned int)i) * 8))) + if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); #endif do { From python-checkins at python.org Fri May 26 18:52:04 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 18:52:04 +0200 (CEST) Subject: [Python-checkins] r46359 - python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/pybench.py Message-ID: <20060526165204.D0AF81E401E@bag.python.org> Author: tim.peters Date: Fri May 26 18:52:04 2006 New Revision: 46359 Modified: python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/pybench.py Log: Whitespace normalization. Modified: python/trunk/Tools/pybench/Empty.py ============================================================================== --- python/trunk/Tools/pybench/Empty.py (original) +++ python/trunk/Tools/pybench/Empty.py Fri May 26 18:52:04 2006 @@ -20,4 +20,3 @@ for i in xrange(self.rounds): pass - Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri May 26 18:52:04 2006 @@ -423,7 +423,7 @@ limitnames = self.values['-t'] verbose = self.verbose nosyscheck = self.values['--no-syscheck'] - + print 'PYBENCH',__version__ # Switch off GC From python-checkins at python.org Fri May 26 18:53:04 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 18:53:04 +0200 (CEST) Subject: [Python-checkins] r46360 - python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/NewInstances.py Message-ID: <20060526165304.56A2F1E400C@bag.python.org> Author: tim.peters Date: Fri May 26 18:53:04 2006 New Revision: 46360 Modified: python/trunk/Tools/pybench/Empty.py (contents, props changed) python/trunk/Tools/pybench/NewInstances.py (props changed) Log: Add missing svn:eol-style property to text files. Modified: python/trunk/Tools/pybench/Empty.py ============================================================================== --- python/trunk/Tools/pybench/Empty.py (original) +++ python/trunk/Tools/pybench/Empty.py Fri May 26 18:53:04 2006 @@ -1,22 +1,22 @@ -from pybench import Test - -class EmptyTest(Test): - """This is just here as a potential measure of repeatability.""" - - version = 0.3 - operations = 1 - rounds = 60000 - - def test(self): - - l = [] - for i in xrange(self.rounds): - pass - - - def calibrate(self): - - l = [] - - for i in xrange(self.rounds): - pass +from pybench import Test + +class EmptyTest(Test): + """This is just here as a potential measure of repeatability.""" + + version = 0.3 + operations = 1 + rounds = 60000 + + def test(self): + + l = [] + for i in xrange(self.rounds): + pass + + + def calibrate(self): + + l = [] + + for i in xrange(self.rounds): + pass From guido at python.org Fri May 26 18:56:17 2006 From: guido at python.org (Guido van Rossum) Date: Fri, 26 May 2006 09:56:17 -0700 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: <20060526120329.9A9671E400C@bag.python.org> References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: On 5/26/06, martin.blais wrote: > Log: > Support for buffer protocol for socket and struct. > > * Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer > protocol (send and sendto already did). > > * Added struct.pack_to(), that is the corresponding buffer compatible method to > unpack_from(). Hm... The file object has a similar method readinto(). Perhaps the methods introduced here could follow that lead instead of using two different new naming conventions? -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Fri May 26 19:02:06 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 19:02:06 +0200 (CEST) Subject: [Python-checkins] r46361 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526170206.2E06D1E400C@bag.python.org> Author: richard.jones Date: Fri May 26 19:02:04 2006 New Revision: 46361 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: support GC Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 19:02:04 2006 @@ -61,19 +61,34 @@ Py_DECREF(self->message); self->message = PySequence_GetItem(self->args, 0); } - return 0; } -static void -BaseException_dealloc(BaseExceptionObject *self) +int +BaseException_clear(BaseExceptionObject *self) { Py_CLEAR(self->dict); Py_CLEAR(self->args); Py_CLEAR(self->message); + return 0; +} + +static void +BaseException_dealloc(BaseExceptionObject *self) +{ + BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } +int +BaseException_traverse(BaseExceptionObject *self, visitproc visit, void *arg) +{ + if (self->dict) + Py_VISIT(self->dict); + Py_VISIT(self->args); + Py_VISIT(self->message); + return 0; +} static PyObject * BaseException_str(BaseExceptionObject *self) @@ -248,10 +263,10 @@ PyObject_GenericGetAttr, /*tp_getattro*/ PyObject_GenericSetAttr, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ + (traverseproc)BaseException_traverse, /* tp_traverse */ + (inquiry)BaseException_clear, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ @@ -279,10 +294,11 @@ 0, \ # EXCNAME, \ sizeof(BaseExceptionObject), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - PyDoc_STR(EXCDOC), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ + 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ + PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ + (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(BaseExceptionObject, dict), \ (initproc)BaseException_init, 0, BaseException_new,\ }; \ @@ -294,10 +310,11 @@ 0, \ # EXCNAME, \ sizeof(EXCSTORE ## Object), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - PyDoc_STR(EXCDOC), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ + 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ + PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ + (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -309,11 +326,12 @@ 0, \ # EXCNAME, \ sizeof(EXCSTORE ## Object), 0, \ - (destructor)EXCDEALLOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, \ - PyDoc_STR(EXCDOC), \ - 0, 0, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_ ## EXCBASE, \ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ + PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \ + (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \ + EXCMEMBERS, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ @@ -398,11 +416,25 @@ return 0; } +int +SystemExit_clear(SystemExitObject *self) +{ + Py_CLEAR(self->code); + return BaseException_clear((BaseExceptionObject *)self); +} + static void SystemExit_dealloc(SystemExitObject *self) { - Py_CLEAR(self->code); - BaseException_dealloc((BaseExceptionObject *)self); + SystemExit_clear(self); + self->ob_type->tp_free((PyObject *)self); +} + +int +SystemExit_traverse(SystemExitObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->code); + return BaseException_traverse((BaseExceptionObject *)self, visit, arg); } static PyMemberDef SystemExit_members[] = { @@ -514,13 +546,30 @@ return 0; } -static void -EnvironmentError_dealloc(EnvironmentErrorObject *self) +int +EnvironmentError_clear(EnvironmentErrorObject *self) { Py_CLEAR(self->myerrno); Py_CLEAR(self->strerror); Py_CLEAR(self->filename); - BaseException_dealloc((BaseExceptionObject *)self); + return BaseException_clear((BaseExceptionObject *)self); +} + +static void +EnvironmentError_dealloc(EnvironmentErrorObject *self) +{ + EnvironmentError_clear(self); + self->ob_type->tp_free((PyObject *)self); +} + +int +EnvironmentError_traverse(EnvironmentErrorObject *self, visitproc visit, + void *arg) +{ + Py_VISIT(self->myerrno); + Py_VISIT(self->strerror); + Py_VISIT(self->filename); + return BaseException_traverse((BaseExceptionObject *)self, visit, arg); } static PyObject * @@ -668,6 +717,33 @@ PyObject *winerror; } WindowsErrorObject; +int +WindowsError_clear(WindowsErrorObject *self) +{ + Py_CLEAR(self->myerrno); + Py_CLEAR(self->strerror); + Py_CLEAR(self->filename); + Py_CLEAR(self->winerror); + return BaseException_clear((BaseExceptionObject *)self); +} + +static void +WindowsError_dealloc(WindowsErrorObject *self) +{ + WindowsError_clear(self); + self->ob_type->tp_free((PyObject *)self); +} + +int +WindowsError_traverse(WindowsErrorObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->myerrno); + Py_VISIT(self->strerror); + Py_VISIT(self->filename); + Py_VISIT(self->winerror); + return BaseException_traverse((BaseExceptionObject *)self, visit, arg) +} + static PyObject * WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -923,8 +999,8 @@ return 0; } -static void -SyntaxError_dealloc(SyntaxErrorObject *self) +int +SyntaxError_clear(SyntaxErrorObject *self) { Py_CLEAR(self->msg); Py_CLEAR(self->filename); @@ -932,7 +1008,26 @@ Py_CLEAR(self->offset); Py_CLEAR(self->text); Py_CLEAR(self->print_file_and_line); - BaseException_dealloc((BaseExceptionObject *)self); + return BaseException_clear((BaseExceptionObject *)self); +} + +static void +SyntaxError_dealloc(SyntaxErrorObject *self) +{ + SyntaxError_clear(self); + self->ob_type->tp_free((PyObject *)self); +} + +int +SyntaxError_traverse(SyntaxErrorObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->msg); + Py_VISIT(self->filename); + Py_VISIT(self->lineno); + Py_VISIT(self->offset); + Py_VISIT(self->text); + Py_VISIT(self->print_file_and_line); + return BaseException_traverse((BaseExceptionObject *)self, visit, arg); } /* This is called "my_basename" instead of just "basename" to avoid name @@ -1393,15 +1488,33 @@ return 0; } -static void -UnicodeError_dealloc(UnicodeErrorObject *self) +int +UnicodeError_clear(UnicodeErrorObject *self) { Py_CLEAR(self->encoding); Py_CLEAR(self->object); Py_CLEAR(self->start); Py_CLEAR(self->end); Py_CLEAR(self->reason); - BaseException_dealloc((BaseExceptionObject *)self); + return BaseException_clear((BaseExceptionObject *)self); +} + +static void +UnicodeError_dealloc(UnicodeErrorObject *self) +{ + UnicodeError_clear(self); + self->ob_type->tp_free((PyObject *)self); +} + +int +UnicodeError_traverse(UnicodeErrorObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->encoding); + Py_VISIT(self->object); + Py_VISIT(self->start); + Py_VISIT(self->end); + Py_VISIT(self->reason); + return BaseException_traverse((BaseExceptionObject *)self, visit, arg); } static PyMemberDef UnicodeError_members[] = { @@ -1485,10 +1598,10 @@ sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - PyDoc_STR("Unicode encoding error."), - 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, offsetof(UnicodeErrorObject, dict), + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + PyDoc_STR("Unicode encoding error."), (traverseproc)BaseException_traverse, + (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -1560,10 +1673,10 @@ sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - PyDoc_STR("Unicode decoding error."), - 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, offsetof(UnicodeErrorObject, dict), + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + PyDoc_STR("Unicode decoding error."), (traverseproc)BaseException_traverse, + (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -1673,10 +1786,10 @@ sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - PyDoc_STR("Unicode decoding error."), - 0, 0, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, - 0, 0, 0, offsetof(UnicodeErrorObject, dict), + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; From python-checkins at python.org Fri May 26 19:04:59 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 19:04:59 +0200 (CEST) Subject: [Python-checkins] r46362 - in python/trunk/Objects: stringlib stringlib/README.txt stringlib/fastsearch.h stringobject.c unicodeobject.c Message-ID: <20060526170459.BCFA11E400C@bag.python.org> Author: fredrik.lundh Date: Fri May 26 19:04:58 2006 New Revision: 46362 Added: python/trunk/Objects/stringlib/ python/trunk/Objects/stringlib/README.txt (contents, props changed) python/trunk/Objects/stringlib/fastsearch.h (contents, props changed) Modified: python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring (in progress) Added: python/trunk/Objects/stringlib/README.txt ============================================================================== --- (empty file) +++ python/trunk/Objects/stringlib/README.txt Fri May 26 19:04:58 2006 @@ -0,0 +1,5 @@ +bits shared by the stringobject and unicodeobject implementations (and +possibly other modules, in a not too distant future). + +the stuff in here is included into relevant places; see the individual +source files for details. Added: python/trunk/Objects/stringlib/fastsearch.h ============================================================================== --- (empty file) +++ python/trunk/Objects/stringlib/fastsearch.h Fri May 26 19:04:58 2006 @@ -0,0 +1,97 @@ +/* stringlib: fastsearch implementation */ + +#ifndef STRINGLIB_FASTSEARCH_H +#define STRINGLIB_FASTSEARCH_H + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possible be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +Py_LOCAL(Py_ssize_t) +fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n, + const STRINGLIB_CHAR* p, Py_ssize_t m, + int mode) +{ + long mask; + Py_ssize_t skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m <= 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else + i = i + skip; + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +#endif Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 19:04:58 2006 @@ -765,102 +765,17 @@ } /* -------------------------------------------------------------------- */ -/* Helpers */ +/* stringlib components */ -#define USE_FAST /* experimental fast search implementation */ +#define USE_FAST -/* XXX - this code is copied from unicodeobject.c. we really should - refactor the core implementations (see _sre.c for how this can be - done), but that'll have to wait -- fredrik */ - -/* fast search/count implementation, based on a mix between boyer- - moore and horspool, with a few more bells and whistles on the top. - for some more background, see: http://effbot.org/stringlib */ - -/* note: fastsearch may access s[n], which isn't a problem when using - Python's ordinary string types, but may cause problems if you're - using this code in other contexts. also, the count mode returns -1 - if there cannot possibly be a match in the target string, and 0 if - it has actually checked for matches, but didn't find any. callers - beware! */ - -#define FAST_COUNT 0 -#define FAST_SEARCH 1 - -Py_LOCAL(Py_ssize_t) -fastsearch(const char* s, Py_ssize_t n, const char* p, Py_ssize_t m, int mode) -{ - long mask; - Py_ssize_t skip, count = 0; - Py_ssize_t i, j, mlast, w; - - w = n - m; - - if (w < 0) - return -1; - - /* look for special cases */ - if (m <= 1) { - if (m <= 0) - return -1; - /* use special case for 1-character strings */ - if (mode == FAST_COUNT) { - for (i = 0; i < n; i++) - if (s[i] == p[0]) - count++; - return count; - } else { - for (i = 0; i < n; i++) - if (s[i] == p[0]) - return i; - } - return -1; - } +#ifdef USE_FAST - mlast = m - 1; +#define STRINGLIB_CHAR char - /* create compressed boyer-moore delta 1 table */ - skip = mlast - 1; - /* process pattern[:-1] */ - for (mask = i = 0; i < mlast; i++) { - mask |= (1 << (p[i] & 0x1F)); - if (p[i] == p[mlast]) - skip = mlast - i - 1; - } - /* process pattern[-1] outside the loop */ - mask |= (1 << (p[mlast] & 0x1F)); - - for (i = 0; i <= w; i++) { - /* note: using mlast in the skip path slows things down on x86 */ - if (s[i+m-1] == p[m-1]) { - /* candidate match */ - for (j = 0; j < mlast; j++) - if (s[i+j] != p[j]) - break; - if (j == mlast) { - /* got a match! */ - if (mode != FAST_COUNT) - return i; - count++; - i = i + mlast; - continue; - } - /* miss: check if next character is part of pattern */ - if (!(mask & (1 << (s[i+m] & 0x1F)))) - i = i + m; - else - i = i + skip; - } else { - /* skip: check if next character is part of pattern */ - if (!(mask & (1 << (s[i+m] & 0x1F)))) - i = i + m; - } - } +#include "stringlib/fastsearch.h" - if (mode != FAST_COUNT) - return -1; - return count; -} +#endif /* -------------------------------------------------------------------- */ /* Methods */ @@ -2416,7 +2331,7 @@ #else r = 0; while (i < m) { - const char *t + const char *t; if (!memcmp(s+i, sub, n)) { r++; i += n; Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 19:04:58 2006 @@ -3854,94 +3854,9 @@ /* --- Helpers ------------------------------------------------------------ */ -/* fast search/count implementation, based on a mix between boyer- - moore and horspool, with a few more bells and whistles on the top. - for some more background, see: http://effbot.org/stringlib */ - -/* note: fastsearch may access s[n], which isn't a problem when using - Python's ordinary string types, but may cause problems if you're - using this code in other contexts. also, the count mode returns -1 - if there cannot possible be a match in the target string, and 0 if - it has actually checked for matches, but didn't find any. callers - beware! */ - -#define FAST_COUNT 0 -#define FAST_SEARCH 1 - -Py_LOCAL(Py_ssize_t) -fastsearch(Py_UNICODE* s, Py_ssize_t n, Py_UNICODE* p, Py_ssize_t m, int mode) -{ - long mask; - Py_ssize_t skip, count = 0; - Py_ssize_t i, j, mlast, w; +#define STRINGLIB_CHAR Py_UNICODE - w = n - m; - - if (w < 0) - return -1; - - /* look for special cases */ - if (m <= 1) { - if (m <= 0) - return -1; - /* use special case for 1-character strings */ - if (mode == FAST_COUNT) { - for (i = 0; i < n; i++) - if (s[i] == p[0]) - count++; - return count; - } else { - for (i = 0; i < n; i++) - if (s[i] == p[0]) - return i; - } - return -1; - } - - mlast = m - 1; - - /* create compressed boyer-moore delta 1 table */ - skip = mlast - 1; - /* process pattern[:-1] */ - for (mask = i = 0; i < mlast; i++) { - mask |= (1 << (p[i] & 0x1F)); - if (p[i] == p[mlast]) - skip = mlast - i - 1; - } - /* process pattern[-1] outside the loop */ - mask |= (1 << (p[mlast] & 0x1F)); - - for (i = 0; i <= w; i++) { - /* note: using mlast in the skip path slows things down on x86 */ - if (s[i+m-1] == p[m-1]) { - /* candidate match */ - for (j = 0; j < mlast; j++) - if (s[i+j] != p[j]) - break; - if (j == mlast) { - /* got a match! */ - if (mode != FAST_COUNT) - return i; - count++; - i = i + mlast; - continue; - } - /* miss: check if next character is part of pattern */ - if (!(mask & (1 << (s[i+m] & 0x1F)))) - i = i + m; - else - i = i + skip; - } else { - /* skip: check if next character is part of pattern */ - if (!(mask & (1 << (s[i+m] & 0x1F)))) - i = i + m; - } - } - - if (mode != FAST_COUNT) - return -1; - return count; -} +#include "stringlib/fastsearch.h" Py_LOCAL(Py_ssize_t) count(PyUnicodeObject *self, Py_ssize_t start, From python-checkins at python.org Fri May 26 19:18:34 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 26 May 2006 19:18:34 +0200 (CEST) Subject: [Python-checkins] r46363 - python/trunk/Doc/lib/libctypesref.tex Message-ID: <20060526171834.84F791E4029@bag.python.org> Author: thomas.heller Date: Fri May 26 19:18:33 2006 New Revision: 46363 Modified: python/trunk/Doc/lib/libctypesref.tex Log: Write some docs. Modified: python/trunk/Doc/lib/libctypesref.tex ============================================================================== --- python/trunk/Doc/lib/libctypesref.tex (original) +++ python/trunk/Doc/lib/libctypesref.tex Fri May 26 19:18:33 2006 @@ -1,9 +1,17 @@ \subsection{ctypes reference\label{ctypes-reference}} +ctypes defines a lot of C compatible datatypes, and also allows to +define your own types. Among other things, a ctypes type instance +holds a memory block that contains C compatible data. + \begin{funcdesc}{addressof}{obj} +Returns the address of the memory buffer as integer. \var{obj} must +be an instance of a ctypes type. \end{funcdesc} \begin{funcdesc}{alignment}{obj_or_type} +Returns the alignment requirements of a ctypes type. +\var{obj_or_type} must be a ctypes type or an instance. \end{funcdesc} \begin{excclassdesc}{ArgumentError}{} @@ -13,48 +21,80 @@ \end{classdesc} \begin{funcdesc}{byref}{obj} +Returns a light-weight pointer to \var{obj}, which must be an instance +of a ctypes type. The returned object can only be used as a foreign +function call parameter. It behaves similar to \code{pointer(obj)}, +but the construction is a lot faster. \end{funcdesc} \begin{classdesc}{c_byte}{\optional{value}} +Represents a C \code{signed char} datatype, and interprets the value +as small integer. The constructor accepts an optional integer +initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_char}{\optional{value}} +Represents a C \code{char} datatype, and interprets the value as a +single character. The constructor accepts an optional string +initializer, the length of the string must be exactly one character. \end{classdesc} \begin{classdesc}{c_char_p}{\optional{value}} \end{classdesc} \begin{classdesc}{c_double}{\optional{value}} +Represents a C \code{double} datatype. The constructor accepts an +optional float initializer. \end{classdesc} \begin{classdesc}{c_float}{\optional{value}} +Represents a C \code{double} datatype. The constructor accepts an +optional float initializer. \end{classdesc} \begin{classdesc}{c_int}{\optional{value}} +Represents a C \code{signed int} datatype. The constructor accepts an +optional integer initializer; no overflow checking is done. On +platforms where \code{sizeof(int) == sizeof(long)} \var{c_int} is an +alias to \var{c_long}. \end{classdesc} \begin{classdesc}{c_int16}{\optional{value}} +Represents a C 16-bit \code{signed int} datatype. Usually an alias +for \var{c_short}. \end{classdesc} \begin{classdesc}{c_int32}{\optional{value}} +Represents a C 32-bit \code{signed int} datatype. Usually an alias +for \code{c_int}. \end{classdesc} \begin{classdesc}{c_int64}{\optional{value}} +Represents a C 64-bit \code{signed int} datatype. Usually an alias +for \code{c_longlong}. \end{classdesc} \begin{classdesc}{c_int8}{\optional{value}} +Represents a C 8-bit \code{signed int} datatype. Usually an alias for \code{c_byte}. \end{classdesc} \begin{classdesc}{c_long}{\optional{value}} +Represents a C \code{signed long} datatype. The constructor accepts +an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_longlong}{\optional{value}} +Represents a C \code{signed long long} datatype. The constructor +accepts an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_short}{\optional{value}} +Represents a C \code{signed short} datatype. The constructor accepts +an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_size_t}{\optional{value}} +Represents a C \code{size_t} datatype. \end{classdesc} \begin{classdesc}{c_ubyte}{\optional{value}} From python-checkins at python.org Fri May 26 19:22:39 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 19:22:39 +0200 (CEST) Subject: [Python-checkins] r46364 - in python/trunk/Objects: stringlib/partition.h stringobject.c unicodeobject.c Message-ID: <20060526172239.3903D1E400D@bag.python.org> Author: fredrik.lundh Date: Fri May 26 19:22:38 2006 New Revision: 46364 Added: python/trunk/Objects/stringlib/partition.h (contents, props changed) Modified: python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring (in progress) Added: python/trunk/Objects/stringlib/partition.h ============================================================================== --- (empty file) +++ python/trunk/Objects/stringlib/partition.h Fri May 26 19:22:38 2006 @@ -0,0 +1,50 @@ +/* stringlib: partition implementation */ + +#ifndef STRINGLIB_PARTITION_H +#define STRINGLIB_PARTITION_H + +#include "stringlib/fastsearch.h" + +Py_LOCAL(PyObject*) +partition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, + PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) +{ + PyObject* out; + Py_ssize_t pos; + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + return NULL; + } + + out = PyTuple_New(3); + if (!out) + return NULL; + + pos = fastsearch(str, str_len, sep, sep_len, FAST_SEARCH); + + if (pos < 0) { + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); + Py_INCREF(STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + return out; + } + + PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + pos += sep_len; + PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); + + if (PyErr_Occurred()) { + Py_DECREF(out); + return NULL; + } + + return out; +} + +#endif Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 19:22:38 2006 @@ -772,8 +772,11 @@ #ifdef USE_FAST #define STRINGLIB_CHAR char +#define STRINGLIB_NEW PyString_FromStringAndSize +#define STRINGLIB_EMPTY nullstring #include "stringlib/fastsearch.h" +#include "stringlib/partition.h" #endif @@ -1541,9 +1544,8 @@ static PyObject * string_partition(PyStringObject *self, PyObject *sep_obj) { - Py_ssize_t len = PyString_GET_SIZE(self), sep_len, pos; + Py_ssize_t str_len = PyString_GET_SIZE(self), sep_len; const char *str = PyString_AS_STRING(self), *sep; - PyObject * out; if (PyString_Check(sep_obj)) { sep = PyString_AS_STRING(sep_obj); @@ -1556,38 +1558,7 @@ else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; - if (sep_len == 0) { - PyErr_SetString(PyExc_ValueError, "empty separator"); - return NULL; - } - - out = PyTuple_New(3); - if (!out) - return NULL; - - pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); - if (pos < 0) { - Py_INCREF(self); - PyTuple_SET_ITEM(out, 0, (PyObject*) self); - Py_INCREF(nullstring); - PyTuple_SET_ITEM(out, 1, (PyObject*) nullstring); - Py_INCREF(nullstring); - PyTuple_SET_ITEM(out, 2, (PyObject*) nullstring); - } else { - PyObject* obj; - PyTuple_SET_ITEM(out, 0, PyString_FromStringAndSize(str, pos)); - Py_INCREF(sep_obj); - PyTuple_SET_ITEM(out, 1, sep_obj); - pos += sep_len; - obj = PyString_FromStringAndSize(str + pos, len - pos); - PyTuple_SET_ITEM(out, 2, obj); - if (PyErr_Occurred()) { - Py_DECREF(out); - return NULL; - } - } - - return out; + return partition((PyObject*)self, str, str_len, sep_obj, sep, sep_len); } Py_LOCAL(PyObject *) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 19:22:38 2006 @@ -3856,7 +3856,13 @@ #define STRINGLIB_CHAR Py_UNICODE +#define STRINGLIB_NEW PyUnicode_FromUnicode + +#define STRINGLIB_EMPTY unicode_empty + #include "stringlib/fastsearch.h" +#include "stringlib/partition.h" + Py_LOCAL(Py_ssize_t) count(PyUnicodeObject *self, Py_ssize_t start, @@ -6197,59 +6203,26 @@ { PyObject* str_obj; PyObject* sep_obj; - Py_UNICODE *str, *sep; - Py_ssize_t len, sep_len, pos; PyObject* out; - + str_obj = PyUnicode_FromObject(str_in); if (!str_obj) return NULL; sep_obj = PyUnicode_FromObject(sep_in); - if (!sep_obj) - goto error; - - str = PyUnicode_AS_UNICODE(str_obj); - len = PyUnicode_GET_SIZE(str_obj); - - sep = PyUnicode_AS_UNICODE(sep_obj); - sep_len = PyUnicode_GET_SIZE(sep_obj); - - if (sep_len == 0) { - PyErr_SetString(PyExc_ValueError, "empty separator"); - goto error; - } - - out = PyTuple_New(3); - if (!out) - goto error; - - pos = fastsearch(str, len, sep, sep_len, FAST_SEARCH); - if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); - Py_INCREF(unicode_empty); - PyTuple_SET_ITEM(out, 1, (PyObject*) unicode_empty); - Py_INCREF(unicode_empty); - PyTuple_SET_ITEM(out, 2, (PyObject*) unicode_empty); - } else { - PyObject* obj; - PyTuple_SET_ITEM(out, 0, PyUnicode_FromUnicode(str, pos)); - Py_INCREF(sep_obj); - PyTuple_SET_ITEM(out, 1, sep_obj); - obj = PyUnicode_FromUnicode(str + sep_len + pos, len - sep_len - pos); - PyTuple_SET_ITEM(out, 2, obj); - if (PyErr_Occurred()) { - Py_DECREF(out); - goto error; - } + if (!sep_obj) { + Py_DECREF(str_obj); + return NULL; } - return out; + out = partition( + str_obj, PyUnicode_AS_UNICODE(str_obj), PyUnicode_GET_SIZE(str_obj), + sep_obj, PyUnicode_AS_UNICODE(sep_obj), PyUnicode_GET_SIZE(sep_obj) + ); -error: - Py_XDECREF(sep_obj); + Py_DECREF(sep_obj); Py_DECREF(str_obj); - return NULL; + + return out; } PyDoc_STRVAR(partition__doc__, From python-checkins at python.org Fri May 26 19:25:28 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 19:25:28 +0200 (CEST) Subject: [Python-checkins] r46365 - in sandbox/trunk/hotbuffer: Modules Modules/_hotbuf.c README.txt test_hotbuf.py Message-ID: <20060526172528.C69471E4020@bag.python.org> Author: martin.blais Date: Fri May 26 19:25:28 2006 New Revision: 46365 Modified: sandbox/trunk/hotbuffer/ (props changed) sandbox/trunk/hotbuffer/Modules/ (props changed) sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Modified API of the hotbuffer. Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 19:25:28 2006 @@ -21,29 +21,30 @@ /* * hotbuf object structure declaration. - From the Java Buffer docs: + From the Java Buffer docs: - A buffer is a linear, finite sequence of elements of a specific - primitive type. Aside from its content, the essential properties of a - buffer are its capacity, limit, and position: + A buffer is a linear, finite sequence of elements of a specific + primitive type. Aside from its content, the essential properties of a + buffer are its capacity, limit, and position: - A buffer's capacity is the number of elements it contains. The - capacity of a buffer is never negative and never changes. + A buffer's capacity is the number of elements it contains. The + capacity of a buffer is never negative and never changes. - A buffer's limit is the index of the first element that should not - be read or written. A buffer's limit is never negative and is never - greater than its capacity. + A buffer's limit is the index of the first element that should not + be read or written. A buffer's limit is never negative and is never + greater than its capacity. - A buffer's position is the index of the next element to be read or - written. A buffer's position is never negative and is never greater - than its limit. + A buffer's position is the index of the next element to be read or + written. A buffer's position is never negative and is never greater + than its limit. - The following invariant holds for the mark, position, limit, and - capacity values: + The following invariant holds for the position, limit, and + capacity values: - 0 <= mark <= position <= limit <= capacity (length) + 0 <= position <= limit <= capacity + 0 <= mark_position <= mark_limit <= capacity - */ +*/ typedef struct { PyObject_HEAD @@ -64,19 +65,12 @@ /* The limit position in the buffer. */ Py_ssize_t b_limit; - /* The mark. From the Java Buffer docs: - - A buffer's mark is the index to which its position will be reset when - the reset method is invoked. The mark is not always defined, but when - it is defined it is never negative and is never greater than the - position. If the mark is defined then it is discarded when the - position or the limit is adjusted to a value smaller than the mark. If - the mark is not defined then invoking the reset method causes an - InvalidMarkException to be thrown. - - The mark is set to -1 to indicate that the mark is unset. + /* The mark (position and limit), which save the current position and + limit on save(), to be reset later with restore(). The mark variables are + set to -1 to indicate that the mark is unset. */ - Py_ssize_t b_mark; + Py_ssize_t b_mark_position; + Py_ssize_t b_mark_limit; } PyHotbufObject; @@ -91,21 +85,17 @@ static int hotbuf_advance_internal(PyHotbufObject *self, Py_ssize_t nbytes) { - Py_ssize_t newposition = self->b_position + nbytes; - if (newposition > self->b_limit) { - PyErr_SetString(PyExc_IndexError, - "position must be smaller than limit"); - return -1; - } - - /* Set the new position */ - self->b_position = newposition; - - /* Discard the mark if it is beyond the new position */ - if (self->b_mark > self->b_position) - self->b_mark = -1; + Py_ssize_t newposition = self->b_position + nbytes; + if (newposition > self->b_limit) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than limit"); + return -1; + } - return 0; + /* Set the new position */ + self->b_position = newposition; + + return 0; } @@ -150,8 +140,9 @@ /* Initialize the members */ new->b_ptr = ptr; new->b_position = 0; - new->b_mark = -1; new->b_limit = capacity; + new->b_mark_position = -1; + new->b_mark_limit = -1; new->b_capacity = capacity; return (PyObject*)new; @@ -205,11 +196,12 @@ hotbuf_repr(PyHotbufObject *self) { return PyString_FromFormat( - "", - self->b_mark, + "", self->b_position, self->b_limit, self->b_capacity, + self->b_mark_position, + self->b_mark_limit, self->b_ptr, self); } @@ -233,10 +225,9 @@ */ PyDoc_STRVAR(setposition__doc__, -"B.setposition(int)\n\ + "B.setposition(int)\n\ \n\ -Sets this buffer's position. If the mark is defined and larger than\n\ -the new position then it is discarded. If the given position is\n\ +Sets this buffer's position. If the given position is\n\ larger than the limit an exception is raised."); static PyObject* @@ -257,21 +248,16 @@ /* Set the new position */ self->b_position = newposition; - /* Discard the mark if it is beyond the new position */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; - Py_RETURN_NONE; } PyDoc_STRVAR(advance__doc__, -"B.advance(int)\n\ + "B.advance(int)\n\ \n\ Advance this buffer's position by the given number of bytes. \n\ -If the mark is defined and larger than\n\ -the new position then it is discarded. If the given position is\n\ -larger than the limit an exception is raised."); +If the given position is larger than the limit an exception \n\ +is raised."); static PyObject* hotbuf_advance(PyHotbufObject *self, PyObject* arg) @@ -290,11 +276,10 @@ PyDoc_STRVAR(setlimit__doc__, -"B.setlimit(int)\n\ + "B.setlimit(int)\n\ \n\ Sets this buffer's limit. If the position is larger than the new limit\n\ -then it is set to the new limit. If the mark is defined and larger\n\ -than the new limit then it is discarded."); +then it is set to the new limit."); static PyObject* hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) @@ -319,51 +304,105 @@ if ( self->b_position > self->b_limit ) self->b_position = newlimit; - /* Discard the mark if it is beyond the new limit */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(setwindow__doc__, + "B.setwindow(int)\n\ +\n\ +Sets this buffer's limit to be beyond position by the given\n\ +number number of bytes. If the limit is larger than the \n\ +capacity an IndexError is raised."); + +static PyObject* +hotbuf_setwindow(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t window; + Py_ssize_t newlimit; + + window = PyInt_AsLong(arg); + if (window == -1 && PyErr_Occurred()) + return NULL; + + newlimit = self->b_position + window; + if ( newlimit > self->b_capacity ) { + PyErr_SetString(PyExc_IndexError, + "limit must be smaller than capacity"); + return NULL; + } + + /* Set the new limit. */ + self->b_limit = newlimit; Py_RETURN_NONE; } -PyDoc_STRVAR(setmark__doc__, -"B.setmark()\n\ +PyDoc_STRVAR(save__doc__, + "B.save()\n\ \n\ -Sets this buffer's mark at its position."); +Save this buffer's position and limit for later."); static PyObject* -hotbuf_setmark(PyHotbufObject *self) +hotbuf_save(PyHotbufObject *self) { - self->b_mark = self->b_position; + self->b_mark_position = self->b_position; + self->b_mark_limit = self->b_limit; Py_RETURN_NONE; } -PyDoc_STRVAR(reset__doc__, -"B.reset() -> int\n\ +PyDoc_STRVAR(restore__doc__, + "B.restore([advbytes]) -> int\n\ \n\ -Resets this buffer's position to the previously-marked position.\n\ -Invoking this method neither changes nor discards the mark's value.\n\ -An IndexError is raised if the mark has not been set.\n\ -This method returns the new position's value."); +Resets this buffer's position to the previously-marked\n\ +position and limit. Invoking this method neither changes nor\n\ +discards the mark's value. An IndexError is raised if the\n\ +mark has not been set. This method returns the new\n\ +position's value. If you specify a number of bytes via \n\ +'advbytes', the method advances the position by that many bytes."); static PyObject* -hotbuf_reset(PyHotbufObject *self) +hotbuf_restore(PyHotbufObject *self, PyObject* args) { - if ( self->b_mark == -1 ) { + Py_ssize_t advbytes = 0; + Py_ssize_t newposition = -1; + + /* Validate that the mark is set. */ + if ( self->b_mark_position == -1 || self->b_mark_limit == -1 ) { PyErr_SetString(PyExc_IndexError, "mark has not been yet set"); return NULL; } - self->b_position = self->b_mark; - return PyInt_FromLong(self->b_position); + /* Extract and validate advbytes */ + if (!PyArg_ParseTuple(args, "|n:hotbuf", &advbytes)) + return NULL; + + if (advbytes < 0) { + PyErr_SetString(PyExc_ValueError, + "advbytes must be a positive number"); + return NULL; + } + + /* Validate the new position, if specified */ + newposition = self->b_mark_position + advbytes; + if (newposition > self->b_limit) { + PyErr_SetString(PyExc_IndexError, + "new position must be smaller than limit"); + return NULL; + } + + self->b_position = newposition; + self->b_limit = self->b_mark_limit; + + return PyInt_FromLong(newposition); } PyDoc_STRVAR(clear__doc__, -"B.clear()\n\ + "B.clear()\n\ \n\ Clears this buffer. The position is set to zero, the limit is set to\n\ the capacity, and the mark is discarded.\n\ @@ -383,13 +422,13 @@ { self->b_position = 0; self->b_limit = self->b_capacity; - self->b_mark = -1; + self->b_mark_position = self->b_mark_limit = -1; Py_RETURN_NONE; } PyDoc_STRVAR(flip__doc__, -"B.flip()\n\ + "B.flip()\n\ \n\ Flips this buffer. The limit is set to the current position and then\n\ the position is set to zero. If the mark is defined then it is\n\ @@ -412,16 +451,15 @@ { self->b_limit = self->b_position; self->b_position = 0; - self->b_mark = -1; + self->b_mark_position = self->b_mark_limit = -1; Py_RETURN_NONE; } PyDoc_STRVAR(rewind__doc__, -"B.rewind()\n\ + "B.rewind()\n\ \n\ -Rewinds this buffer. The position is set to zero and the mark is\n\ -discarded.\n\ +Rewinds this buffer. The position is set to zero.\n\ \n\ Invoke this method before a sequence of channel-write or get\n\ operations, assuming that the limit has already been set\n\ @@ -436,13 +474,12 @@ hotbuf_rewind(PyHotbufObject *self) { self->b_position = 0; - self->b_mark = -1; Py_RETURN_NONE; } PyDoc_STRVAR(remaining__doc__, -"B.remaining() -> int\n\ + "B.remaining() -> int\n\ \n\ Returns the number of bytes between the current position and the limit."); @@ -454,7 +491,7 @@ PyDoc_STRVAR(compact__doc__, -"B.compact()\n\ + "B.compact()\n\ \n\ Compacts this buffer.\n\ \n\ @@ -500,7 +537,7 @@ self->b_position = length; self->b_limit = self->b_capacity; - self->b_mark = -1; + self->b_mark_position = self->b_mark_limit = -1; Py_RETURN_NONE; } @@ -512,7 +549,7 @@ */ PyDoc_STRVAR(get__doc__, -"B.get*() -> data\n\ + "B.get*() -> data\n\ \n\ Relative get methods. \n\ Reads something at this buffer's current position, \n\ @@ -520,7 +557,7 @@ An IndexError is raised if the position is at the end of the buffer."); PyDoc_STRVAR(put__doc__, -"B.put*(data)\n\ + "B.put*(data)\n\ \n\ Relative put methods. \n\ Writes the given byte into this buffer at the current position,\n\ @@ -571,7 +608,7 @@ PyDoc_STRVAR(getstr__doc__, -"B.getstr([nbytes]) -> data\n\ + "B.getstr([nbytes]) -> data\n\ \n\ Extract a string of 'nbytes' bytes from the buffer and advance the\n\ position accordingly. If 'nbytes' is not specified, get the string\n\ @@ -608,17 +645,13 @@ /* Advance to the new position */ self->b_position += len; - /* Discard the mark if it is beyond the new position */ - if ( self->b_mark > self->b_position ) - self->b_mark = -1; - /* Return the new string */ return s; } PyDoc_STRVAR(putstr__doc__, -"B.putstr(str)\n\ + "B.putstr(str)\n\ \n\ Write a string of 'nbytes' bytes from the buffer and advance the \n\ position accordingly.\n\ @@ -651,7 +684,7 @@ } PyDoc_STRVAR(unpack__doc__, -"B.unpack(structobj) -> v1, v2, ...\n\ + "B.unpack(structobj) -> v1, v2, ...\n\ \n\ Unpack the given structure directly from this buffer and advance\n\ the position accordingly."); @@ -694,7 +727,8 @@ PyErr_SetString(PyExc_TypeError, "unpack requires a single struct argument"); - result = PyObject_CallMethodObjArgs(structobj, str_unpack_from, self, NULL); + result = PyObject_CallMethodObjArgs(structobj, + str_unpack_from, self, NULL); if (result == NULL) return NULL; @@ -765,7 +799,7 @@ PyDoc_STRVAR(hotbuf_doc, -"hotbuf(capacity) -> hotbuf\n\ + "hotbuf(capacity) -> hotbuf\n\ \n\ Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ \n\ @@ -789,8 +823,10 @@ "buffer's position"}, {"limit", T_INT, OFF(b_limit), RO, "buffer's limit"}, - {"mark", T_INT, OFF(b_mark), RO, - "buffer's mark, -1 if not set"}, + {"mark_position", T_INT, OFF(b_mark_position), RO, + "buffer's mark position, -1 if not set"}, + {"mark_limit", T_INT, OFF(b_mark_limit), RO, + "buffer's mark limit, -1 if not set"}, {NULL} /* Sentinel */ }; @@ -800,8 +836,9 @@ {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, {"advance", (PyCFunction)hotbuf_advance, METH_O, advance__doc__}, {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, - {"setmark", (PyCFunction)hotbuf_setmark, METH_NOARGS, setmark__doc__}, - {"reset", (PyCFunction)hotbuf_reset, METH_NOARGS, reset__doc__}, + {"setwindow", (PyCFunction)hotbuf_setwindow, METH_O, setwindow__doc__}, + {"save", (PyCFunction)hotbuf_save, METH_NOARGS, save__doc__}, + {"restore", (PyCFunction)hotbuf_restore, METH_VARARGS, restore__doc__}, {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, @@ -916,8 +953,8 @@ if (m == NULL) return; - if (PyType_Ready(&PyHotbuf_Type) < 0) - return; + if (PyType_Ready(&PyHotbuf_Type) < 0) + return; Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Fri May 26 19:25:28 2006 @@ -36,6 +36,10 @@ Features -------- +* Use descriptors rather than function calls to set the limit, etc. + +* Add restore() to the tests. + * Change the mark, this will make the loop easier to understand * setmark() to save both the position and limit @@ -55,6 +59,8 @@ - Should we support weakrefs? +* Add with protocol for guards + Document -------- Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 19:25:28 2006 @@ -48,30 +48,30 @@ # Play with the mark b.setposition(10) b.setlimit(100) - b.setmark() + b.save() b.setposition(15) - self.assertEquals(b.mark, 10) + self.assertEquals(b.mark_position, 10) # Play with clear b.clear() - self.assertEquals((b.position, b.limit, b.mark), + self.assertEquals((b.position, b.limit, b.mark_position), (0, CAPACITY, -1)) # Play with flip. b.setposition(42) b.setlimit(104) - b.setmark() + b.save() b.flip() - self.assertEquals((b.position, b.limit, b.mark), + self.assertEquals((b.position, b.limit, b.mark_position), (0, 42, -1)) # Play with rewind. b.setposition(42) b.setlimit(104) - b.setmark() + b.save() b.rewind() - self.assertEquals((b.position, b.limit, b.mark), - (0, 104, -1)) + self.assertEquals((b.position, b.limit, b.mark_position), + (0, 104, 42)) # Play with remaining. self.assertEquals(b.remaining(), 104) @@ -85,14 +85,22 @@ self.assertRaises(IndexError, b.advance, CAPACITY) + # Play with setwindow() + b.clear() + b.setwindow(12) + self.assertEquals((b.position, b.limit), (0, 12)) + b.advance(3) + b.setwindow(12) + self.assertEquals((b.position, b.limit), (3, 15)) + def test_compact( self ): b = hotbuf(CAPACITY) b.setposition(100) b.setlimit(200) - m = b.mark + m = b.mark_position b.compact() - self.assertEquals((b.position, b.limit, b.mark), + self.assertEquals((b.position, b.limit, b.mark_position), (100, CAPACITY, -1)) # Compare the text that gets compacted. @@ -227,3 +235,5 @@ test_main() + +## FIXME TODO add restore() in test. From python-checkins at python.org Fri May 26 19:26:40 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 19:26:40 +0200 (CEST) Subject: [Python-checkins] r46366 - python/trunk/Objects/stringobject.c Message-ID: <20060526172640.3CAF81E4027@bag.python.org> Author: fredrik.lundh Date: Fri May 26 19:26:39 2006 New Revision: 46366 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: cleanup Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 19:26:39 2006 @@ -1544,8 +1544,8 @@ static PyObject * string_partition(PyStringObject *self, PyObject *sep_obj) { - Py_ssize_t str_len = PyString_GET_SIZE(self), sep_len; - const char *str = PyString_AS_STRING(self), *sep; + const char *sep; + Py_ssize_t sep_len; if (PyString_Check(sep_obj)) { sep = PyString_AS_STRING(sep_obj); @@ -1553,12 +1553,16 @@ } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep_obj)) - return PyUnicode_Partition((PyObject *)self, sep_obj); + return PyUnicode_Partition((PyObject *) self, sep_obj); #endif else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; - return partition((PyObject*)self, str, str_len, sep_obj, sep, sep_len); + return partition( + (PyObject*) self, + PyString_AS_STRING(self), PyString_GET_SIZE(self), + sep_obj, sep, sep_len + ); } Py_LOCAL(PyObject *) From python-checkins at python.org Fri May 26 19:31:41 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 19:31:41 +0200 (CEST) Subject: [Python-checkins] r46367 - python/trunk/Objects/stringobject.c Message-ID: <20060526173141.021D91E401E@bag.python.org> Author: fredrik.lundh Date: Fri May 26 19:31:41 2006 New Revision: 46367 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: remove remaining USE_FAST macros; if fastsearch was broken, someone would have noticed by now ;-) Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 19:31:41 2006 @@ -767,10 +767,6 @@ /* -------------------------------------------------------------------- */ /* stringlib components */ -#define USE_FAST - -#ifdef USE_FAST - #define STRINGLIB_CHAR char #define STRINGLIB_NEW PyString_FromStringAndSize #define STRINGLIB_EMPTY nullstring @@ -778,8 +774,6 @@ #include "stringlib/fastsearch.h" #include "stringlib/partition.h" -#endif - /* -------------------------------------------------------------------- */ /* Methods */ @@ -1054,13 +1048,7 @@ char *s = PyString_AS_STRING(a); const char *sub = PyString_AS_STRING(el); Py_ssize_t len_sub = PyString_GET_SIZE(el); -#ifdef USE_FAST Py_ssize_t pos; -#else - char *last; - Py_ssize_t shortsub; - char firstchar, lastchar; -#endif if (!PyString_CheckExact(el)) { #ifdef Py_USING_UNICODE @@ -1077,35 +1065,12 @@ if (len_sub == 0) return 1; -#ifdef USE_FAST pos = fastsearch( s, PyString_GET_SIZE(a), sub, len_sub, FAST_SEARCH ); + return (pos != -1); -#else - /* last points to one char beyond the start of the rightmost - substring. When s 0) ? i : last; if (dir > 0) { @@ -1863,17 +1827,7 @@ if (pos < 0) return pos; return pos + i; - } -#endif - if (dir > 0) { - if (n == 0 && i <= last) - return (long)i; - last -= n; - for (; i <= last; ++i) - if (s[i] == sub[0] && memcmp(&s[i], sub, n) == 0) - return (long)i; - } - else { + } else { Py_ssize_t j; if (n == 0 && i <= last) @@ -2299,28 +2253,9 @@ if (n == 0) return PyInt_FromSsize_t(m-i); -#ifdef USE_FAST r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); if (r < 0) r = 0; /* no match */ -#else - r = 0; - while (i < m) { - const char *t; - if (!memcmp(s+i, sub, n)) { - r++; - i += n; - } else { - i++; - } - if (i >= m) - break; - t = (const char *)memchr(s+i, sub[0], m-i); - if (t == NULL) - break; - i = t - s; - } -#endif return PyInt_FromSsize_t(r); } From buildbot at python.org Fri May 26 19:32:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:32:24 +0000 Subject: [Python-checkins] buildbot failure in x86 gentoo trunk Message-ID: <20060526173224.4CF131E400C@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/883 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 19:32:47 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:32:47 +0000 Subject: [Python-checkins] buildbot failure in PPC64 Debian trunk Message-ID: <20060526173247.261511E400C@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/42 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 19:33:18 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:33:18 +0000 Subject: [Python-checkins] buildbot failure in ppc Debian unstable trunk Message-ID: <20060526173318.5B3311E400C@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/521 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 19:36:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:36:24 +0000 Subject: [Python-checkins] buildbot failure in x86 OpenBSD trunk Message-ID: <20060526173624.AA0951E4019@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/707 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Fri May 26 19:41:33 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 19:41:33 +0200 (CEST) Subject: [Python-checkins] r46368 - python/trunk/Tools/pybench/pybench.py Message-ID: <20060526174133.2C8F51E4020@bag.python.org> Author: steve.holden Date: Fri May 26 19:41:32 2006 New Revision: 46368 Modified: python/trunk/Tools/pybench/pybench.py Log: Use minimum calibration time rather than avergae to avoid the illusion of negative run times. Halt with an error if run times go below 10 ms, indicating that results will be unreliable. Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri May 26 19:41:32 2006 @@ -126,7 +126,7 @@ self.operations = self.operations self.rounds = self.rounds - def run(self): + def run(self, cruns): """ Run the test in two phases: first calibrate, then do the actual test. Be careful to keep the calibration @@ -136,20 +136,23 @@ test = self.test calibrate = self.calibrate clock = time.clock - cruns = self.cruns # first calibrate - offset = 0.0 + t = clock() + calibrate() + offset = clock() - t if cruns: - for i in range(cruns): + for i in range(cruns-1): t = clock() calibrate() t = clock() - t - offset = offset + t - offset = offset / cruns + if t < offset: + offset = t # now the real thing t = clock() test() t = clock() - t + if t < 0.01: + sys.exit("Lower warp required: test times < 10 ms are unreliable") self.last_timing = (t-offset,t,offset) self.times.append(t-offset) @@ -253,7 +256,7 @@ print len(l), "tests found" print - def run(self, verbose): + def run(self, verbose, cruns): tests = self.tests.items() tests.sort() @@ -266,10 +269,10 @@ if verbose: print ' Round %-25i real abs overhead' % (i+1) for j in range(len(tests)): - name,t = tests[j] + name, t = tests[j] if verbose: print '%30s:' % name, - t.run() + t.run(cruns) if verbose: print ' %.3fr %.3fa %.3fo' % t.last_timing if verbose: @@ -379,7 +382,7 @@ SwitchOption('--no-syscheck', '"disable" sys check interval (set to sys.maxint)', 0), ArgumentOption('-t', 'tests containing substring', ''), - ArgumentOption('-C', 'number of calibration runs (default 0)', '') + ArgumentOption('-C', 'number of calibration runs (default 20)', 20) ] about = """\ @@ -423,7 +426,9 @@ limitnames = self.values['-t'] verbose = self.verbose nosyscheck = self.values['--no-syscheck'] - + cruns = self.values['-C'] + print "CRUNS:", cruns + print 'PYBENCH',__version__ # Switch off GC @@ -488,7 +493,7 @@ bench.rounds = rounds bench.load_tests(Setup, warp, limitnames, verbose) try: - bench.run(verbose) + bench.run(verbose, cruns) except KeyboardInterrupt: print print '*** KeyboardInterrupt -- Aborting' From python-checkins at python.org Fri May 26 19:47:01 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 19:47:01 +0200 (CEST) Subject: [Python-checkins] r46369 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c Message-ID: <20060526174701.136BE1E4010@bag.python.org> Author: bob.ippolito Date: Fri May 26 19:47:00 2006 New Revision: 46369 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Log: use tp_getset instead of tp_members Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 19:47:00 2006 @@ -816,22 +816,97 @@ #define OFF(x) offsetof(PyHotbufObject, x) -static PyMemberDef hotbuf_members[] = { - {"capacity", T_INT, OFF(b_capacity), RO, - "buffer's capacity, it's total allocated size"}, - {"position", T_INT, OFF(b_position), RO, - "buffer's position"}, - {"limit", T_INT, OFF(b_limit), RO, - "buffer's limit"}, - {"mark_position", T_INT, OFF(b_mark_position), RO, - "buffer's mark position, -1 if not set"}, - {"mark_limit", T_INT, OFF(b_mark_limit), RO, - "buffer's mark limit, -1 if not set"}, - {NULL} /* Sentinel */ +/* + Hotbuf Getters and setters +*/ + +static PyObject * +hotbuf_get_capacity(PyHotbufObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->b_capacity); +} + +static PyObject * +hotbuf_get_position(PyHotbufObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->b_position); +} + +static int +hotbuf_set_position(PyHotbufObject *self, PyObject *arg, void *unused) +{ + Py_ssize_t newposition; + + newposition = PyInt_AsSsize_t(arg); + if (newposition == -1 && PyErr_Occurred()) + return -1; + + if (newposition > self->b_capacity) { + PyErr_SetString(PyExc_IndexError, + "position must be smaller than capacity"); + return -1; + } + + /* Set the new position */ + self->b_position = newposition; + + return 0; +} + +static PyObject * +hotbuf_get_limit(PyHotbufObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->b_limit); +} + +static int +hotbuf_set_limit(PyHotbufObject *self, PyObject *arg, void *unused) +{ + Py_ssize_t newlimit; + + newlimit = PyInt_AsSsize_t(arg); + if (newlimit == -1 && PyErr_Occurred()) + return -1; + + if (newlimit > self->b_capacity) { + PyErr_SetString(PyExc_IndexError, + "limit must be smaller than capacity"); + return -1; + } + + /* Set the new limit */ + self->b_limit = newlimit; + + /* If the position is larger than the new limit, set it to the new + limit. */ + if (self->b_position > self->b_limit) + self->b_position = newlimit; + + return 0; +} + +static PyObject * +hotbuf_get_mark_position(PyHotbufObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->b_mark_position); +} + +static PyObject * +hotbuf_get_mark_limit(PyHotbufObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->b_mark_limit); +} + +static PyGetSetDef hotbuf_getsetlist[] = { + {"capacity", (getter)hotbuf_get_capacity, (setter)NULL, "buffer's capacity", NULL}, + {"position", (getter)hotbuf_get_position, (setter)hotbuf_set_position, "buffer's position", NULL}, + {"limit", (getter)hotbuf_get_limit, (setter)hotbuf_set_limit, "buffer's limit", NULL}, + {"mark_position", (getter)hotbuf_get_mark_position, (setter)NULL, "buffer's mark_position, -1 if not set", NULL}, + {"mark_limit", (getter)hotbuf_get_mark_limit, (setter)NULL, "buffer's mark_limit, -1 if not set", NULL}, + {NULL} }; -static PyMethodDef -hotbuf_methods[] = { +static PyMethodDef hotbuf_methods[] = { {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, {"advance", (PyCFunction)hotbuf_advance, METH_O, advance__doc__}, @@ -898,8 +973,8 @@ 0, /* tp_iter */ 0, /* tp_iternext */ hotbuf_methods, /* tp_methods */ - hotbuf_members, /* tp_members */ - 0, /* tp_getset */ + 0, /* tp_members */ + hotbuf_getsetlist, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ From python-checkins at python.org Fri May 26 19:47:41 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 26 May 2006 19:47:41 +0200 (CEST) Subject: [Python-checkins] r46370 - python/trunk/Doc/lib/libctypesref.tex Message-ID: <20060526174741.2824E1E401A@bag.python.org> Author: thomas.heller Date: Fri May 26 19:47:40 2006 New Revision: 46370 Modified: python/trunk/Doc/lib/libctypesref.tex Log: Reordered, and wrote more docs. Modified: python/trunk/Doc/lib/libctypesref.tex ============================================================================== --- python/trunk/Doc/lib/libctypesref.tex (original) +++ python/trunk/Doc/lib/libctypesref.tex Fri May 26 19:47:40 2006 @@ -1,8 +1,7 @@ \subsection{ctypes reference\label{ctypes-reference}} -ctypes defines a lot of C compatible datatypes, and also allows to -define your own types. Among other things, a ctypes type instance -holds a memory block that contains C compatible data. +% functions +\subsubsection{ctypes functions} \begin{funcdesc}{addressof}{obj} Returns the address of the memory buffer as integer. \var{obj} must @@ -17,9 +16,6 @@ \begin{excclassdesc}{ArgumentError}{} \end{excclassdesc} -\begin{classdesc}{BigEndianStructure}{} -\end{classdesc} - \begin{funcdesc}{byref}{obj} Returns a light-weight pointer to \var{obj}, which must be an instance of a ctypes type. The returned object can only be used as a foreign @@ -27,6 +23,118 @@ but the construction is a lot faster. \end{funcdesc} +\begin{funcdesc}{cast}{obj, type} +\end{funcdesc} + +\begin{funcdesc}{CFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{create_string_buffer}{init_or_size\optional{, size}} +This function creates a mutable character buffer. The returned object +is a ctypes array of \code{c_char}. + +\var{init_or_size} must be an integer which specifies the size of the +array, or a string which will be used to initialize the array items. + +If a string is specified as first argument, the buffer is made one +item larger than the length of the string so that the last element in +the array is a NUL termination character. An integer can be passed as +second argument which allows to specify the size of the array if the +length of the string should not be used. + +If the first parameter is a unicode string, it is converted into an +8-bit string according to ctypes conversion rules. +\end{funcdesc} + +\begin{funcdesc}{create_unicode_buffer}{init_or_size\optional{, size}} +This function creates a mutable unicode character buffer. The +returned object is a ctypes array of \code{c_wchar}. + +\var{init_or_size} must be an integer which specifies the size of the +array, or a unicode string which will be used to initialize the array +items. + +If a unicode string is specified as first argument, the buffer is made +one item larger than the length of the string so that the last element +in the array is a NUL termination character. An integer can be passed +as second argument which allows to specify the size of the array if +the length of the string should not be used. + +If the first parameter is a 8-bit string, it is converted into an +unicode string according to ctypes conversion rules. +\end{funcdesc} + +\begin{funcdesc}{DllCanUnloadNow}{} +Windows only: This function is a hook which allows to implement +inprocess COM servers with ctypes. It is called from the +\code{DllCanUnloadNow} exported function that the \code{_ctypes} +extension module exports. +\end{funcdesc} + +\begin{funcdesc}{DllGetClassObject}{} +Windows only: This function is a hook which allows to implement +inprocess COM servers with ctypes. It is called from the +\code{DllGetClassObject} exported function that the \code{_ctypes} +extension module exports. +\end{funcdesc} + +\begin{funcdesc}{FormatError}{} +Windows only: +\end{funcdesc} + +\begin{funcdesc}{GetLastError}{} +Windows only: +\end{funcdesc} + +\begin{funcdesc}{memmove}{dst, src, count} +\end{funcdesc} + +\begin{funcdesc}{memset}{dst, c, count} +\end{funcdesc} + +\begin{funcdesc}{POINTER}{} +\end{funcdesc} + +\begin{funcdesc}{pointer}{} +\end{funcdesc} + +\begin{funcdesc}{PYFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{pythonapi}{} +\end{funcdesc} + +\begin{funcdesc}{resize}{} +\end{funcdesc} + +\begin{funcdesc}{set_conversion_mode}{} +\end{funcdesc} + +\begin{funcdesc}{sizeof}{} +\end{funcdesc} + +\begin{funcdesc}{string_at}{address} +\end{funcdesc} + +\begin{funcdesc}{WinError}{} +\end{funcdesc} + +\begin{funcdesc}{WINFUNCTYPE}{restype, *argtypes} +\end{funcdesc} + +\begin{funcdesc}{wstring_at}{address} +\end{funcdesc} + +% data types +\subsubsection{data types} + +ctypes defines a lot of C compatible datatypes, and also allows to +define your own types. Among other things, a ctypes type instance +holds a memory block that contains C compatible data. + +% simple data types +\subsubsection{simple data types} + \begin{classdesc}{c_byte}{\optional{value}} Represents a C \code{signed char} datatype, and interprets the value as small integer. The constructor accepts an optional integer @@ -133,35 +241,28 @@ \begin{classdesc}{c_wchar_p}{\optional{value}} \end{classdesc} -\begin{funcdesc}{cast}{obj, type} -\end{funcdesc} +% structured data types +\subsubsection{structured data types} -\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None} +\begin{classdesc}{BigEndianStructure}{} \end{classdesc} -\begin{datadesc}{cdll} -\end{datadesc} - -\begin{funcdesc}{CFUNCTYPE}{restype, *argtypes} -\end{funcdesc} +\begin{classdesc}{LittleEndianStructure}{} +\end{classdesc} -\begin{funcdesc}{create_string_buffer}{init\optional{, size}} -\end{funcdesc} +\begin{classdesc}{Structure}{} +\end{classdesc} -\begin{funcdesc}{create_unicode_buffer}{init\optional{, size}} -\end{funcdesc} +\begin{classdesc}{Union}{} +\end{classdesc} -\begin{funcdesc}{DllCanUnloadNow}{} -\end{funcdesc} -\begin{funcdesc}{DllGetClassObject}{} -\end{funcdesc} -\begin{funcdesc}{FormatError}{} -\end{funcdesc} +\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None} +\end{classdesc} -\begin{funcdesc}{GetLastError}{} -\end{funcdesc} +\begin{datadesc}{cdll} +\end{datadesc} \begin{classdesc}{HRESULT}{} \end{classdesc} @@ -169,27 +270,12 @@ \begin{classdesc}{LibraryLoader}{dlltype} \end{classdesc} -\begin{classdesc}{LittleEndianStructure}{} -\end{classdesc} - -\begin{funcdesc}{memmove}{dst, src, count} -\end{funcdesc} - -\begin{funcdesc}{memset}{dst, c, count} -\end{funcdesc} - \begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None} \end{classdesc} \begin{datadesc}{oledll} \end{datadesc} -\begin{funcdesc}{POINTER}{} -\end{funcdesc} - -\begin{funcdesc}{pointer}{} -\end{funcdesc} - \begin{classdesc}{py_object}{} \end{classdesc} @@ -199,48 +285,15 @@ \begin{datadesc}{pydll}{} \end{datadesc} -\begin{funcdesc}{PYFUNCTYPE}{restype, *argtypes} -\end{funcdesc} - -\begin{funcdesc}{pythonapi}{} -\end{funcdesc} - -\begin{funcdesc}{resize}{} -\end{funcdesc} - \begin{datadesc}{RTLD_GLOBAL} \end{datadesc} \begin{datadesc}{RTLD_LOCAL} \end{datadesc} -\begin{funcdesc}{set_conversion_mode}{} -\end{funcdesc} - -\begin{funcdesc}{sizeof}{} -\end{funcdesc} - -\begin{funcdesc}{string_at}{address} -\end{funcdesc} - -\begin{classdesc}{Structure}{} -\end{classdesc} - -\begin{classdesc}{Union}{} -\end{classdesc} - \begin{classdesc}{WinDLL}{name, mode=RTLD_LOCAL, handle=None} \end{classdesc} \begin{datadesc}{windll} \end{datadesc} -\begin{funcdesc}{WinError}{} -\end{funcdesc} - -\begin{funcdesc}{WINFUNCTYPE}{restype, *argtypes} -\end{funcdesc} - -\begin{funcdesc}{wstring_at}{address} -\end{funcdesc} - From buildbot at python.org Fri May 26 19:48:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:48:02 +0000 Subject: [Python-checkins] buildbot failure in ia64 Debian unstable trunk Message-ID: <20060526174802.EA60B1E4006@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/495 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 19:50:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:50:32 +0000 Subject: [Python-checkins] buildbot failure in sparc solaris10 gcc trunk Message-ID: <20060526175032.56DAB1E4006@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/782 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 19:52:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 17:52:15 +0000 Subject: [Python-checkins] buildbot failure in g4 osx.4 trunk Message-ID: <20060526175215.989AD1E4006@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/778 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From guido at python.org Fri May 26 19:53:16 2006 From: guido at python.org (Guido van Rossum) Date: Fri, 26 May 2006 10:53:16 -0700 Subject: [Python-checkins] r46364 - in python/trunk/Objects: stringlib/partition.h stringobject.c unicodeobject.c In-Reply-To: <20060526172239.3903D1E400D@bag.python.org> References: <20060526172239.3903D1E400D@bag.python.org> Message-ID: FYI, I get a compilation error since (approximately) this checkin: gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I../Include -DPy_BUILD_CORE -o Objects/stringobject.o ../Objects/stringobject.c In file included from ../Objects/stringobject.c:775: ../Objects/stringlib/partition.h:6:34: stringlib/fastsearch.h: No such file or directory make: *** [Objects/stringobject.o] Error 1 This may be inherent to the refactoring-in-progress, or it may be due to my habit of building in a subdirectory of the source tree (so I can switch quickly between regular and debug builds). AFAIK that is still a supported setup. Changing the #include in partition.h from #include "stringlib/fastsearch.h" to #include "fastsearch.h" seems to fix this, but I don't know if that fixes it for you. --Guido On 5/26/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Fri May 26 19:22:38 2006 > New Revision: 46364 > > Added: > python/trunk/Objects/stringlib/partition.h (contents, props changed) > Modified: > python/trunk/Objects/stringobject.c > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: stringlib refactoring (in progress) -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Fri May 26 20:00:26 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 20:00:26 +0200 (CEST) Subject: [Python-checkins] r46371 - in python/branches/sreifschneider-newnewexcept: Lib/ctypes/test/test_structures.py Lib/test/test_codeccallbacks.py Modules/cPickle.c Objects/exceptions.c Python/errors.c Python/pythonrun.c Message-ID: <20060526180026.2B3241E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 20:00:24 2006 New Revision: 46371 Modified: python/branches/sreifschneider-newnewexcept/Lib/ctypes/test/test_structures.py python/branches/sreifschneider-newnewexcept/Lib/test/test_codeccallbacks.py python/branches/sreifschneider-newnewexcept/Modules/cPickle.c python/branches/sreifschneider-newnewexcept/Objects/exceptions.c python/branches/sreifschneider-newnewexcept/Python/errors.c python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Log: Fix naming issues and make the rest of the tests pass. Modified: python/branches/sreifschneider-newnewexcept/Lib/ctypes/test/test_structures.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/ctypes/test/test_structures.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/ctypes/test/test_structures.py Fri May 26 20:00:24 2006 @@ -294,20 +294,20 @@ # In Python 2.5, Exception is a new-style class, and the repr changed if issubclass(Exception, object): self.failUnlessEqual(msg, - "(Phone) : " + "(Phone) : " "expected string or Unicode object, int found") else: self.failUnlessEqual(msg, - "(Phone) exceptions.TypeError: " + "(Phone) TypeError: " "expected string or Unicode object, int found") cls, msg = self.get_except(Person, "Someone", ("a", "b", "c")) self.failUnlessEqual(cls, RuntimeError) if issubclass(Exception, object): self.failUnlessEqual(msg, - "(Phone) : too many initializers") + "(Phone) : too many initializers") else: - self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers") + self.failUnlessEqual(msg, "(Phone) ValueError: too many initializers") def get_except(self, func, *args): Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_codeccallbacks.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_codeccallbacks.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_codeccallbacks.py Fri May 26 20:00:24 2006 @@ -18,30 +18,12 @@ self.pos = len(exc.object) return (u"", oldpos) -# A UnicodeEncodeError object without a start attribute -class NoStartUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.start - # A UnicodeEncodeError object with a bad start attribute class BadStartUnicodeEncodeError(UnicodeEncodeError): def __init__(self): UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") self.start = [] -# A UnicodeEncodeError object without an end attribute -class NoEndUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.end - -# A UnicodeEncodeError object without an object attribute -class NoObjectUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.object - # A UnicodeEncodeError object with a bad object attribute class BadObjectUnicodeEncodeError(UnicodeEncodeError): def __init__(self): @@ -478,55 +460,15 @@ UnicodeError("ouch") ) self.assertRaises( - AttributeError, - codecs.replace_errors, - NoStartUnicodeEncodeError() - ) - self.assertRaises( - TypeError, - codecs.replace_errors, - BadStartUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoObjectUnicodeEncodeError() - ) - self.assertRaises( TypeError, codecs.replace_errors, BadObjectUnicodeEncodeError() ) self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeDecodeError() - ) - self.assertRaises( TypeError, codecs.replace_errors, BadObjectUnicodeDecodeError() ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoStartUnicodeTranslateError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeTranslateError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoObjectUnicodeTranslateError() - ) # With the correct exception, "replace" returns an "?" or u"\ufffd" replacement self.assertEquals( codecs.replace_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")), @@ -565,21 +507,6 @@ codecs.xmlcharrefreplace_errors, UnicodeTranslateError(u"\u3042", 0, 1, "ouch") ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoStartUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoEndUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoObjectUnicodeEncodeError() - ) # Use the correct exception cs = (0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, 0x3042) s = "".join(unichr(c) for c in cs) Modified: python/branches/sreifschneider-newnewexcept/Modules/cPickle.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Modules/cPickle.c (original) +++ python/branches/sreifschneider-newnewexcept/Modules/cPickle.c Fri May 26 20:00:24 2006 @@ -5625,7 +5625,6 @@ if (!( t=PyDict_New())) return -1; if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" "def __str__(self):\n" " return self.args and ('%s' % self.args[0]) or '(what)'\n", Py_file_input, @@ -5645,7 +5644,6 @@ if (!( t=PyDict_New())) return -1; if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" "def __str__(self):\n" " a=self.args\n" " a=a and type(a[0]) or '(what)'\n" Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 20:00:24 2006 @@ -4,6 +4,7 @@ #include "osdefs.h" #define MAKE_IT_NONE(x) (x) = Py_None; Py_INCREF(Py_None); +#define EXC_MODULE_NAME "exceptions." /* * BaseException @@ -127,6 +128,8 @@ Py_ssize_t args_len; PyObject *repr_suffix; PyObject *repr; + char *name; + char *dot; args_len = PySequence_Length(self->args); if (args_len < 0) { @@ -145,7 +148,11 @@ repr_suffix = args_repr; } - repr = PyString_FromString(self->ob_type->tp_name); + name = (char *)self->ob_type->tp_name; + dot = strrchr(name, '.'); + if (dot != NULL) name = dot+1; + + repr = PyString_FromString(name); if (!repr) { Py_DECREF(repr_suffix); return NULL; @@ -216,8 +223,6 @@ }; static PyMemberDef BaseException_members[] = { - {"args", T_OBJECT, offsetof(BaseExceptionObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, PyDoc_STR("exception message")}, {NULL} /* Sentinel */ @@ -236,8 +241,51 @@ return self->dict; } +static int +BaseException_set_dict(BaseExceptionObject *self, PyObject *val) +{ + if (val == NULL) { + PyErr_SetString(PyExc_TypeError, "__dict__ may not be deleted"); + return -1; + } + if (!PyDict_Check(val)) { + PyErr_SetString(PyExc_TypeError, "__dict__ must be a dictionary"); + return -1; + } + Py_CLEAR(self->dict); + Py_INCREF(val); + self->dict = val; + return 0; +} + +static PyObject * +BaseException_get_args(BaseExceptionObject *self) +{ + if (self->args == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + Py_INCREF(self->args); + return self->args; +} + +static int +BaseException_set_args(BaseExceptionObject *self, PyObject *val) +{ + PyObject *seq; + if (val == NULL) { + PyErr_SetString(PyExc_TypeError, "args may not be deleted"); + return -1; + } + seq = PySequence_Tuple(val); + if (!seq) return -1; + self->args = seq; + return 0; +} + static PyGetSetDef BaseException_getset[] = { - {"__dict__", (getter)BaseException_get_dict, 0}, + {"__dict__", (getter)BaseException_get_dict, (setter)BaseException_set_dict}, + {"args", (getter)BaseException_get_args, (setter)BaseException_set_args}, {NULL}, }; @@ -245,7 +293,7 @@ static PyTypeObject _PyExc_BaseException = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "BaseException", /*tp_name*/ + EXC_MODULE_NAME "BaseException", /*tp_name*/ sizeof(BaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)BaseException_dealloc, /*tp_dealloc*/ @@ -292,7 +340,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - # EXCNAME, \ + EXC_MODULE_NAME # EXCNAME, \ sizeof(BaseExceptionObject), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, \ @@ -308,7 +356,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - # EXCNAME, \ + EXC_MODULE_NAME # EXCNAME, \ sizeof(EXCSTORE ## Object), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, \ @@ -324,7 +372,7 @@ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ 0, \ - # EXCNAME, \ + EXC_MODULE_NAME # EXCNAME, \ sizeof(EXCSTORE ## Object), 0, \ (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ @@ -438,8 +486,6 @@ } static PyMemberDef SystemExit_members[] = { - {"args", T_OBJECT, offsetof(SystemExitObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, PyDoc_STR("exception message")}, {"code", T_OBJECT, offsetof(SystemExitObject, code), 0, @@ -627,8 +673,6 @@ } static PyMemberDef EnvironmentError_members[] = { - {"args", T_OBJECT, offsetof(EnvironmentErrorObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, PyDoc_STR("exception message")}, {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, myerrno), 0, @@ -859,8 +903,6 @@ } static PyMemberDef WindowsError_members[] = { - {"args", T_OBJECT, offsetof(WindowsErrorObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, PyDoc_STR("exception message")}, {"errno", T_OBJECT, offsetof(WindowsErrorObject, myerrno), 0, @@ -1106,8 +1148,6 @@ } static PyMemberDef SyntaxError_members[] = { - {"args", T_OBJECT, offsetof(SyntaxErrorObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, PyDoc_STR("exception message")}, {"msg", T_OBJECT, offsetof(SyntaxErrorObject, msg), 0, @@ -1308,7 +1348,10 @@ { if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { Py_ssize_t size; - size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + PyObject *obj = get_unicode(((UnicodeErrorObject *)exc)->object, + "object"); + if (!obj) return -1; + size = PyUnicode_GET_SIZE(obj); if (*start<0) *start = 0; /*XXX check for values <0*/ if (*start>=size) @@ -1323,7 +1366,10 @@ { if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { Py_ssize_t size; - size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + PyObject *obj = get_string(((UnicodeErrorObject *)exc)->object, + "object"); + if (!obj) return -1; + size = PyString_GET_SIZE(obj); if (*start<0) *start = 0; if (*start>=size) @@ -1362,7 +1408,10 @@ { if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { Py_ssize_t size; - size = PyUnicode_GET_SIZE(((UnicodeErrorObject *)exc)->object); + PyObject *obj = get_unicode(((UnicodeErrorObject *)exc)->object, + "object"); + if (!obj) return -1; + size = PyUnicode_GET_SIZE(obj); if (*end<1) *end = 1; if (*end>size) @@ -1377,7 +1426,10 @@ { if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { Py_ssize_t size; - size = PyString_GET_SIZE(((UnicodeErrorObject *)exc)->object); + PyObject *obj = get_string(((UnicodeErrorObject *)exc)->object, + "object"); + if (!obj) return -1; + size = PyString_GET_SIZE(obj); if (*end<1) *end = 1; if (*end>size) @@ -1518,8 +1570,6 @@ } static PyMemberDef UnicodeError_members[] = { - {"args", T_OBJECT, offsetof(UnicodeErrorObject, args), RO, - PyDoc_STR("exception arguments")}, {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, PyDoc_STR("exception message")}, {"encoding", T_OBJECT, offsetof(UnicodeErrorObject, encoding), 0, @@ -1669,7 +1719,7 @@ static PyTypeObject _PyExc_UnicodeDecodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeDecodeError", + EXC_MODULE_NAME "UnicodeDecodeError", sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, @@ -1782,7 +1832,7 @@ static PyTypeObject _PyExc_UnicodeTranslateError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeTranslateError", + EXC_MODULE_NAME "UnicodeTranslateError", sizeof(UnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/errors.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/errors.c Fri May 26 20:00:24 2006 @@ -557,9 +557,6 @@ if (PyDict_SetItemString(dict, "__module__", modulename) != 0) goto failure; } - classname = PyString_FromString(dot+1); - if (classname == NULL) - goto failure; if (PyTuple_Check(base)) { bases = base; /* INCREF as we create a new ref in the else branch */ @@ -569,7 +566,9 @@ if (bases == NULL) goto failure; } - result = PyClass_New(bases, dict, classname); + /*result = PyClass_New(bases, dict, classname);*/ + result = PyObject_CallFunction(&PyType_Type, "sOO", + dot+1, bases, dict); failure: Py_XDECREF(bases); Py_XDECREF(mydict); @@ -590,6 +589,9 @@ PyFile_WriteString("Exception ", f); if (t) { char* className = PyExceptionClass_Name(t); + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; PyObject* moduleName = PyObject_GetAttrString(t, "__module__"); Modified: python/branches/sreifschneider-newnewexcept/Python/pythonrun.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/pythonrun.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Fri May 26 20:00:24 2006 @@ -1084,7 +1084,8 @@ Py_XDECREF(tb); } -void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) +void +PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) { int err = 0; PyObject *f = PySys_GetObject("stderr"); @@ -1132,6 +1133,9 @@ } else if (PyExceptionClass_Check(exception)) { char* className = PyExceptionClass_Name(exception); + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; PyObject* moduleName = PyObject_GetAttrString(exception, "__module__"); @@ -1139,7 +1143,7 @@ err = PyFile_WriteString("", f); else { char* modstr = PyString_AsString(moduleName); - if (modstr && strcmp(modstr, "__builtin__")) + if (modstr && strcmp(modstr, "exceptions")) { err = PyFile_WriteString(modstr, f); err += PyFile_WriteString(".", f); From fredrik at pythonware.com Fri May 26 20:02:38 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 26 May 2006 20:02:38 +0200 Subject: [Python-checkins] r46364 - in python/trunk/Objects: stringlib/partition.h stringobject.c unicodeobject.c In-Reply-To: References: <20060526172239.3903D1E400D@bag.python.org> Message-ID: Guido van Rossum wrote: > This may be inherent to the refactoring-in-progress, or it may be due > to my habit of building in a subdirectory of the source tree (so I can > switch quickly between regular and debug builds). AFAIK that is still > a supported setup. > > Changing the #include in partition.h from > > #include "stringlib/fastsearch.h" > > to > > #include "fastsearch.h" > > seems to fix this, but I don't know if that fixes it for you. looks reasonable. sorry for the breakage. From python-checkins at python.org Fri May 26 20:03:32 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 20:03:32 +0200 (CEST) Subject: [Python-checkins] r46372 - in python/trunk: Lib/pkgutil.py Misc/NEWS Python/import.c Message-ID: <20060526180332.5EFCA1E401B@bag.python.org> Author: georg.brandl Date: Fri May 26 20:03:31 2006 New Revision: 46372 Modified: python/trunk/Lib/pkgutil.py python/trunk/Misc/NEWS python/trunk/Python/import.c Log: Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache valid and invalid file paths for the built-in import machinery which leads to fewer open calls on startup. Also fix issue with PEP 302 style import hooks which lead to more open() calls than necessary. Modified: python/trunk/Lib/pkgutil.py ============================================================================== --- python/trunk/Lib/pkgutil.py (original) +++ python/trunk/Lib/pkgutil.py Fri May 26 20:03:31 2006 @@ -340,11 +340,13 @@ importer = None sys.path_importer_cache.setdefault(path_item, importer) - if importer is None: + # The boolean values are used for caching valid and invalid + # file paths for the built-in import machinery + if importer in (None, True, False): try: importer = ImpImporter(path_item) except ImportError: - pass + importer = None return importer Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri May 26 20:03:31 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Patch #921466: sys.path_importer_cache is now used to cache valid and + invalid file paths for the built-in import machinery which leads to + fewer open calls on startup. + - Patch #1442927: ``long(str, base)`` is now up to 6x faster for non-power- of-2 bases. The largest speedup is for inputs with about 1000 decimal digits. Conversion from non-power-of-2 bases remains quadratic-time in Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Fri May 26 20:03:31 2006 @@ -1240,7 +1240,33 @@ if (importer == NULL) return NULL; /* Note: importer is a borrowed reference */ - if (importer != Py_None) { + if (importer == Py_False) { + /* Cached as not being a valid dir. */ + Py_XDECREF(copy); + continue; + } + else if (importer == Py_True) { + /* Cached as being a valid dir, so just + * continue below. */ + } + else if (importer == Py_None) { + /* No importer was found, so it has to be a file. + * Check if the directory is valid. */ +#ifdef HAVE_STAT + if (stat(buf, &statbuf) != 0) { + /* Directory does not exist. */ + PyDict_SetItem(path_importer_cache, + v, Py_False); + Py_XDECREF(copy); + continue; + } else { + PyDict_SetItem(path_importer_cache, + v, Py_True); + } +#endif + } + else { + /* A real import hook importer was found. */ PyObject *loader; loader = PyObject_CallMethod(importer, "find_module", @@ -1253,9 +1279,11 @@ return &importhookdescr; } Py_DECREF(loader); + Py_XDECREF(copy); + continue; } - /* no hook was successful, use builtin import */ } + /* no hook was found, use builtin import */ if (len > 0 && buf[len-1] != SEP #ifdef ALTSEP From python-checkins at python.org Fri May 26 20:05:35 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 20:05:35 +0200 (CEST) Subject: [Python-checkins] r46373 - python/trunk/Objects/stringlib/partition.h Message-ID: <20060526180535.06C251E400E@bag.python.org> Author: fredrik.lundh Date: Fri May 26 20:05:34 2006 New Revision: 46373 Modified: python/trunk/Objects/stringlib/partition.h Log: removed unnecessary include Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Fri May 26 20:05:34 2006 @@ -3,8 +3,6 @@ #ifndef STRINGLIB_PARTITION_H #define STRINGLIB_PARTITION_H -#include "stringlib/fastsearch.h" - Py_LOCAL(PyObject*) partition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) From python-checkins at python.org Fri May 26 20:06:40 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 20:06:40 +0200 (CEST) Subject: [Python-checkins] r46374 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c Message-ID: <20060526180640.77BE21E400D@bag.python.org> Author: bob.ippolito Date: Fri May 26 20:06:40 2006 New Revision: 46374 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Log: ssize_t fixes Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 20:06:40 2006 @@ -3,10 +3,18 @@ * network I/O. */ +#define PY_SSIZE_T_CLEAN + #include "Python.h" #include "structmember.h" #include /* for memmove */ +#if PY_VERSION_HEX < 0x02050000 +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#endif + static PyTypeObject PyHotbuf_Type; #define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) @@ -235,7 +243,7 @@ { Py_ssize_t newposition; - newposition = PyInt_AsLong(arg); + newposition = PyInt_AsSsize_t(arg); if (newposition == -1 && PyErr_Occurred()) return NULL; @@ -262,7 +270,7 @@ static PyObject* hotbuf_advance(PyHotbufObject *self, PyObject* arg) { - Py_ssize_t nbytes = PyInt_AsLong(arg); + Py_ssize_t nbytes = PyInt_AsSsize_t(arg); if (nbytes == -1 && PyErr_Occurred()) return NULL; @@ -286,7 +294,7 @@ { Py_ssize_t newlimit; - newlimit = PyInt_AsLong(arg); + newlimit = PyInt_AsSsize_t(arg); if (newlimit == -1 && PyErr_Occurred()) return NULL; @@ -321,7 +329,7 @@ Py_ssize_t window; Py_ssize_t newlimit; - window = PyInt_AsLong(arg); + window = PyInt_AsSsize_t(arg); if (window == -1 && PyErr_Occurred()) return NULL; @@ -486,7 +494,7 @@ static PyObject* hotbuf_remaining(PyHotbufObject *self) { - return PyInt_FromLong(self->b_limit - self->b_position); + return PyInt_FromSsize_t(self->b_limit - self->b_position); } @@ -722,7 +730,7 @@ "unpack requires a single struct argument"); } - len = PyInt_AsLong(size_obj); + len = PyInt_AsSsize_t(size_obj); if (len < 0) PyErr_SetString(PyExc_TypeError, "unpack requires a single struct argument"); From buildbot at python.org Fri May 26 20:07:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:07:30 +0000 Subject: [Python-checkins] buildbot failure in alpha Tru64 5.1 trunk Message-ID: <20060526180730.5A8601E4006@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/546 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden,thomas.heller,tim.peters BUILD FAILED: failed compile sincerely, -The Buildbot From buildbot at python.org Fri May 26 20:10:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:10:52 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) trunk Message-ID: <20060526181052.D51501E400F@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/449 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden,thomas.heller BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Fri May 26 20:10:56 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 20:10:56 +0200 (CEST) Subject: [Python-checkins] r46375 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c Message-ID: <20060526181056.EB8AB1E4006@bag.python.org> Author: bob.ippolito Date: Fri May 26 20:10:56 2006 New Revision: 46375 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Log: Python 2.4 compatibility Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 20:10:56 2006 @@ -13,6 +13,13 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN +#define PyInt_FromSsize_t PyInt_FromLong +#define PyInt_AsSsize_t PyInt_AsLong +#define lenfunc inquiry +#define readbufferproc getreadbufferproc +#define writebufferproc getwritebufferproc +#define charbufferproc getcharbufferproc +#define segcountproc getsegcountproc #endif static PyTypeObject PyHotbuf_Type; From python-checkins at python.org Fri May 26 20:13:38 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 20:13:38 +0200 (CEST) Subject: [Python-checkins] r46376 - in python/branches/sreifschneider-newnewexcept: Objects/exceptions.c Python/errors.c Message-ID: <20060526181338.B375C1E400C@bag.python.org> Author: richard.jones Date: Fri May 26 20:13:38 2006 New Revision: 46376 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c python/branches/sreifschneider-newnewexcept/Python/errors.c Log: StopIteration as singleton Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 20:13:38 2006 @@ -16,18 +16,21 @@ PyObject *message; } BaseExceptionObject; -/* GB: - I don't know, but it may be that the exceptions - have to be GC objects - - If you want to allow normal attribute access, - I think you can use PyObject_GenericGetAttr etc. - in the tp_getattr... slots. -*/ +static PyTypeObject _PyExc_StopIteration; +PyObject *PyExc_StopIterationInst; static PyObject * BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { BaseExceptionObject *self; + /* Make StopIteration be a singleton as often as we can */ + if ((args == NULL || PyTuple_GET_SIZE(args) == 0) && + PyExc_StopIterationInst != NULL && + type == &_PyExc_StopIteration) { + return PyExc_StopIterationInst; + } + self = (BaseExceptionObject *)type->tp_alloc(type, 0); self->args = self->message = self->dict = NULL; @@ -1965,6 +1968,9 @@ */ PyObject *PyExc_MemoryErrorInst=NULL; +/* Make StopIteration be a singleton as often as we can */ +PyObject *PyExc_StopIterationInst=NULL; + /* module global functions */ static PyMethodDef functions[] = { /* Sentinel */ @@ -1984,13 +1990,6 @@ { PyObject *m, *bltinmod, *bdict; - bltinmod = PyImport_ImportModule("__builtin__"); - if (bltinmod == NULL) - Py_FatalError("exceptions bootstrapping error."); - bdict = PyModule_GetDict(bltinmod); - if (bdict == NULL) - Py_FatalError("exceptions bootstrapping error."); - PRE_INIT(BaseException) PRE_INIT(Exception) PRE_INIT(StandardError) @@ -2048,6 +2047,13 @@ m = Py_InitModule("exceptions", functions); if (m == NULL) return; + bltinmod = PyImport_ImportModule("__builtin__"); + if (bltinmod == NULL) + Py_FatalError("exceptions bootstrapping error."); + bdict = PyModule_GetDict(bltinmod); + if (bdict == NULL) + Py_FatalError("exceptions bootstrapping error."); + POST_INIT(BaseException) POST_INIT(Exception) POST_INIT(StandardError) @@ -2106,6 +2112,11 @@ if (!PyExc_MemoryErrorInst) Py_FatalError("Cannot pre-allocate MemoryError instance\n"); + PyExc_StopIterationInst = BaseException_new(&_PyExc_StopIteration, NULL, + NULL); + if (!PyExc_StopIterationInst) + Py_FatalError("Cannot pre-allocate StopIteration instance\n"); + Py_DECREF(bdict); Py_DECREF(bltinmod); } Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/errors.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/errors.c Fri May 26 20:13:38 2006 @@ -567,7 +567,7 @@ goto failure; } /*result = PyClass_New(bases, dict, classname);*/ - result = PyObject_CallFunction(&PyType_Type, "sOO", + result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO", dot+1, bases, dict); failure: Py_XDECREF(bases); From python-checkins at python.org Fri May 26 20:15:39 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 20:15:39 +0200 (CEST) Subject: [Python-checkins] r46377 - in python/trunk: Include/unicodeobject.h Objects/stringlib/fastsearch.h Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060526181539.D55701E400F@bag.python.org> Author: fredrik.lundh Date: Fri May 26 20:15:38 2006 New Revision: 46377 Modified: python/trunk/Include/unicodeobject.h python/trunk/Objects/stringlib/fastsearch.h python/trunk/Objects/stringlib/partition.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: added rpartition implementation Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Fri May 26 20:15:38 2006 @@ -185,11 +185,12 @@ # define PyUnicode_GetSize PyUnicodeUCS2_GetSize # define PyUnicode_Join PyUnicodeUCS2_Join # define PyUnicode_Partition PyUnicodeUCS2_Partition +# define PyUnicode_RPartition PyUnicodeUCS2_RPartition +# define PyUnicode_RSplit PyUnicodeUCS2_RSplit # define PyUnicode_Replace PyUnicodeUCS2_Replace # define PyUnicode_Resize PyUnicodeUCS2_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding # define PyUnicode_Split PyUnicodeUCS2_Split -# define PyUnicode_RSplit PyUnicodeUCS2_RSplit # define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines # define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch # define PyUnicode_Translate PyUnicodeUCS2_Translate @@ -261,6 +262,8 @@ # define PyUnicode_GetSize PyUnicodeUCS4_GetSize # define PyUnicode_Join PyUnicodeUCS4_Join # define PyUnicode_Partition PyUnicodeUCS4_Partition +# define PyUnicode_RPartition PyUnicodeUCS4_RPartition +# define PyUnicode_RSplit PyUnicodeUCS4_RSplit # define PyUnicode_Replace PyUnicodeUCS4_Replace # define PyUnicode_Resize PyUnicodeUCS4_Resize # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding @@ -1027,6 +1030,14 @@ PyObject *sep /* String separator */ ); +/* Partition a string using a given separator, searching from the end of the + string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_RPartition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + /* Split a string giving a list of Unicode strings. If sep is NULL, splitting will be done at all whitespace Modified: python/trunk/Objects/stringlib/fastsearch.h ============================================================================== --- python/trunk/Objects/stringlib/fastsearch.h (original) +++ python/trunk/Objects/stringlib/fastsearch.h Fri May 26 20:15:38 2006 @@ -95,3 +95,10 @@ } #endif + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Fri May 26 20:15:38 2006 @@ -5,7 +5,7 @@ Py_LOCAL(PyObject*) partition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, - PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) + PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) { PyObject* out; Py_ssize_t pos; @@ -45,4 +45,64 @@ return out; } +Py_LOCAL(PyObject*) +rpartition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, + PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) +{ + PyObject* out; + Py_ssize_t pos; + + if (sep_len == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + return NULL; + } + + out = PyTuple_New(3); + if (!out) + return NULL; + + /* XXX - create reversefastsearch helper! */ + if (sep_len == 0) + pos = str_len; + else { + Py_ssize_t j; + pos = -1; + for (j = str_len - sep_len; j >= 0; --j) + if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) { + pos = j; + break; + } + } + + if (pos < 0) { + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); + Py_INCREF(STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + return out; + } + + PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); + Py_INCREF(sep_obj); + PyTuple_SET_ITEM(out, 1, sep_obj); + pos += sep_len; + PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); + + if (PyErr_Occurred()) { + Py_DECREF(out); + return NULL; + } + + return out; +} + #endif + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 20:15:38 2006 @@ -768,7 +768,10 @@ /* stringlib components */ #define STRINGLIB_CHAR char + #define STRINGLIB_NEW PyString_FromStringAndSize +#define STRINGLIB_CMP memcmp + #define STRINGLIB_EMPTY nullstring #include "stringlib/fastsearch.h" @@ -1530,6 +1533,37 @@ ); } +PyDoc_STRVAR(rpartition__doc__, +"S.rpartition(sep) -> (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, starting at the end of S, and returns\n\ +the part before it, the separator itself, and the part after it. If the\n\ +separator is not found, returns S and two empty strings."); + +static PyObject * +string_rpartition(PyStringObject *self, PyObject *sep_obj) +{ + const char *sep; + Py_ssize_t sep_len; + + if (PyString_Check(sep_obj)) { + sep = PyString_AS_STRING(sep_obj); + sep_len = PyString_GET_SIZE(sep_obj); + } +#ifdef Py_USING_UNICODE + else if (PyUnicode_Check(sep_obj)) + return PyUnicode_Partition((PyObject *) self, sep_obj); +#endif + else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) + return NULL; + + return rpartition( + (PyObject*) self, + PyString_AS_STRING(self), PyString_GET_SIZE(self), + sep_obj, sep, sep_len + ); +} + Py_LOCAL(PyObject *) rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { @@ -3810,6 +3844,8 @@ {"rfind", (PyCFunction)string_rfind, METH_VARARGS, rfind__doc__}, {"rindex", (PyCFunction)string_rindex, METH_VARARGS, rindex__doc__}, {"rstrip", (PyCFunction)string_rstrip, METH_VARARGS, rstrip__doc__}, + {"rpartition", (PyCFunction)string_rpartition, METH_O, + rpartition__doc__}, {"startswith", (PyCFunction)string_startswith, METH_VARARGS, startswith__doc__}, {"strip", (PyCFunction)string_strip, METH_VARARGS, strip__doc__}, Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 20:15:38 2006 @@ -3858,6 +3858,14 @@ #define STRINGLIB_NEW PyUnicode_FromUnicode +Py_LOCAL(int) +STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) +{ + if (str[0] == other[0]) + return 0; + return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE)); +} + #define STRINGLIB_EMPTY unicode_empty #include "stringlib/fastsearch.h" @@ -6225,6 +6233,34 @@ return out; } + +PyObject * +PyUnicode_RPartition(PyObject *str_in, PyObject *sep_in) +{ + PyObject* str_obj; + PyObject* sep_obj; + PyObject* out; + + str_obj = PyUnicode_FromObject(str_in); + if (!str_obj) + return NULL; + sep_obj = PyUnicode_FromObject(sep_in); + if (!sep_obj) { + Py_DECREF(str_obj); + return NULL; + } + + out = rpartition( + str_obj, PyUnicode_AS_UNICODE(str_obj), PyUnicode_GET_SIZE(str_obj), + sep_obj, PyUnicode_AS_UNICODE(sep_obj), PyUnicode_GET_SIZE(sep_obj) + ); + + Py_DECREF(sep_obj); + Py_DECREF(str_obj); + + return out; +} + PyDoc_STRVAR(partition__doc__, "S.partition(sep) -> (head, sep, tail)\n\ \n\ @@ -6238,6 +6274,19 @@ return PyUnicode_Partition((PyObject *)self, separator); } +PyDoc_STRVAR(rpartition__doc__, +"S.rpartition(sep) -> (head, sep, tail)\n\ +\n\ +Searches for the separator sep in S, starting at the end of S, and returns\n\ +the part before it, the separator itself, and the part after it. If the\n\ +separator is not found, returns S and two empty strings."); + +static PyObject* +unicode_rpartition(PyUnicodeObject *self, PyObject *separator) +{ + return PyUnicode_RPartition((PyObject *)self, separator); +} + PyObject *PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) @@ -6502,6 +6551,7 @@ {"rindex", (PyCFunction) unicode_rindex, METH_VARARGS, rindex__doc__}, {"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__}, {"rstrip", (PyCFunction) unicode_rstrip, METH_VARARGS, rstrip__doc__}, + {"rpartition", (PyCFunction) unicode_rpartition, METH_O, rpartition__doc__}, {"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS, splitlines__doc__}, {"strip", (PyCFunction) unicode_strip, METH_VARARGS, strip__doc__}, {"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__}, From python-checkins at python.org Fri May 26 20:16:01 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 20:16:01 +0200 (CEST) Subject: [Python-checkins] r46378 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526181601.CDE721E401C@bag.python.org> Author: richard.jones Date: Fri May 26 20:16:00 2006 New Revision: 46378 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: oops Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 20:16:00 2006 @@ -28,6 +28,7 @@ if ((args == NULL || PyTuple_GET_SIZE(args) == 0) && PyExc_StopIterationInst != NULL && type == &_PyExc_StopIteration) { + Py_INCREF(PyExc_StopIterationInst); return PyExc_StopIterationInst; } From jimjjewett at gmail.com Fri May 26 20:16:28 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 26 May 2006 14:16:28 -0400 Subject: [Python-checkins] r46273 - in python/trunk: Doc/lib/libstdtypes.tex Include/unicodeobject.h Lib/test/string_tests.py Objects/stringobject.c Objects/unicodeobject.c In-Reply-To: <20060526085429.9472C1E4002@bag.python.org> References: <20060526085429.9472C1E4002@bag.python.org> Message-ID: On 5/26/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Fri May 26 10:54:28 2006 > New Revision: 46273 > > Modified: > python/trunk/Doc/lib/libstdtypes.tex > python/trunk/Include/unicodeobject.h > python/trunk/Lib/test/string_tests.py > python/trunk/Objects/stringobject.c > python/trunk/Objects/unicodeobject.c > Log: > needforspeed: partition implementation, part two. > > feel free to improve the documentation and the docstrings. > > > > Modified: python/trunk/Doc/lib/libstdtypes.tex > ============================================================================== > --- python/trunk/Doc/lib/libstdtypes.tex (original) > +++ python/trunk/Doc/lib/libstdtypes.tex Fri May 26 10:54:28 2006 > @@ -727,6 +727,14 @@ > \versionchanged[Support for the \var{chars} argument]{2.2.2} > \end{methoddesc} > > +\begin{methoddesc}[string]{partition}{sep} > +Splits the string at the \var{sep}, and return a 3-tuple containing > +the part before the separator, the separator itself, and the part > +after the separator. If the separator is not found, return a 3-tuple > +containing the string itself, followed by two empty strings. > +\versionadded{2.5} > +\end{methoddesc} > + I think this may be where the string views came in. Instead of returning a tuple of funny strings, it could return an instance of a class that knew about views, and held a reference to the original string. p.head (or p[0]) p.sep (or p[1]) p.tail (or p[2]) would be properties that created the new string only if/when that particular attribute was needed. It probably isn't worth doing until the compiler can see that p.tail is only used for another partition, and can then skip creating the intermediate object. -jJ From python-checkins at python.org Fri May 26 20:20:17 2006 From: python-checkins at python.org (richard.jones) Date: Fri, 26 May 2006 20:20:17 +0200 (CEST) Subject: [Python-checkins] r46379 - in python/branches/sreifschneider-newnewexcept: Doc/tut/tut.tex Include/pyerrors.h Message-ID: <20060526182017.859A91E4006@bag.python.org> Author: richard.jones Date: Fri May 26 20:20:16 2006 New Revision: 46379 Modified: python/branches/sreifschneider-newnewexcept/Doc/tut/tut.tex python/branches/sreifschneider-newnewexcept/Include/pyerrors.h Log: remove references to OverflowWarning Modified: python/branches/sreifschneider-newnewexcept/Doc/tut/tut.tex ============================================================================== --- python/branches/sreifschneider-newnewexcept/Doc/tut/tut.tex (original) +++ python/branches/sreifschneider-newnewexcept/Doc/tut/tut.tex Fri May 26 20:20:16 2006 @@ -2711,7 +2711,7 @@ 'FloatingPointError', 'FutureWarning', 'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', - 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', + 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', Modified: python/branches/sreifschneider-newnewexcept/Include/pyerrors.h ============================================================================== --- python/branches/sreifschneider-newnewexcept/Include/pyerrors.h (original) +++ python/branches/sreifschneider-newnewexcept/Include/pyerrors.h Fri May 26 20:20:16 2006 @@ -104,8 +104,6 @@ PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; -/* PyExc_OverflowWarning will go away for Python 2.5 */ -PyAPI_DATA(PyObject *) PyExc_OverflowWarning; PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; PyAPI_DATA(PyObject *) PyExc_FutureWarning; PyAPI_DATA(PyObject *) PyExc_ImportWarning; From python-checkins at python.org Fri May 26 20:24:17 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 20:24:17 +0200 (CEST) Subject: [Python-checkins] r46380 - in python/trunk: Doc/lib/libstdtypes.tex Lib/test/string_tests.py Objects/unicodeobject.c Message-ID: <20060526182417.639101E4019@bag.python.org> Author: fredrik.lundh Date: Fri May 26 20:24:15 2006 New Revision: 46380 Modified: python/trunk/Doc/lib/libstdtypes.tex python/trunk/Lib/test/string_tests.py python/trunk/Objects/unicodeobject.c Log: needspeed: rpartition documentation, tests, and a bug fixes. feel free to add more tests and improve the documentation. Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Fri May 26 20:24:15 2006 @@ -763,6 +763,15 @@ \versionchanged[Support for the \var{fillchar} argument]{2.4} \end{methoddesc} +\begin{methoddesc}[string]{rpartition}{sep} +Split the string at the last occurrence of \var{sep}, and return +a 3-tuple containing the part before the separator, the separator +itself, and the part after the separator. If the separator is not +found, return a 3-tuple containing the string itself, followed by +two empty strings. +\versionadded{2.5} +\end{methoddesc} + \begin{methoddesc}[string]{rsplit}{\optional{sep \optional{,maxsplit}}} Return a list of the words in the string, using \var{sep} as the delimiter string. If \var{maxsplit} is given, at most \var{maxsplit} Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Fri May 26 20:24:15 2006 @@ -999,8 +999,8 @@ def test_partition(self): - self.checkequal(('this', ' is ', 'the partition method'), - 'this is the partition method', 'partition', ' is ') + self.checkequal(('this is the par', 'ti', 'tion method'), + 'this is the partition method', 'partition', 'ti') # from raymond's original specification S = 'http://www.python.org' @@ -1012,6 +1012,21 @@ self.checkraises(ValueError, S, 'partition', '') self.checkraises(TypeError, S, 'partition', None) + def test_rpartition(self): + + self.checkequal(('this is the rparti', 'ti', 'on method'), + 'this is the rpartition method', 'rpartition', 'ti') + + # from raymond's original specification + S = 'http://www.python.org' + self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') + self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') + self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') + + self.checkraises(ValueError, S, 'rpartition', '') + self.checkraises(TypeError, S, 'rpartition', None) + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 20:24:15 2006 @@ -3861,8 +3861,8 @@ Py_LOCAL(int) STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) { - if (str[0] == other[0]) - return 0; + if (str[0] != other[0]) + return 1; return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE)); } From python-checkins at python.org Fri May 26 20:26:21 2006 From: python-checkins at python.org (steve.holden) Date: Fri, 26 May 2006 20:26:21 +0200 (CEST) Subject: [Python-checkins] r46381 - python/trunk/Tools/pybench/Arithmetic.py python/trunk/Tools/pybench/Calls.py python/trunk/Tools/pybench/Constructs.py python/trunk/Tools/pybench/Dict.py python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/Exceptions.py python/trunk/Tools/pybench/Imports.py python/trunk/Tools/pybench/Instances.py python/trunk/Tools/pybench/Lists.py python/trunk/Tools/pybench/Lookups.py python/trunk/Tools/pybench/NewInstances.py python/trunk/Tools/pybench/Numbers.py python/trunk/Tools/pybench/Setup.py python/trunk/Tools/pybench/Strings.py python/trunk/Tools/pybench/Tuples.py python/trunk/Tools/pybench/Unicode.py python/trunk/Tools/pybench/pybench.py Message-ID: <20060526182621.E7D8A1E401D@bag.python.org> Author: steve.holden Date: Fri May 26 20:26:21 2006 New Revision: 46381 Removed: python/trunk/Tools/pybench/Empty.py python/trunk/Tools/pybench/NewInstances.py Modified: python/trunk/Tools/pybench/Arithmetic.py python/trunk/Tools/pybench/Calls.py python/trunk/Tools/pybench/Constructs.py python/trunk/Tools/pybench/Dict.py python/trunk/Tools/pybench/Exceptions.py python/trunk/Tools/pybench/Imports.py python/trunk/Tools/pybench/Instances.py python/trunk/Tools/pybench/Lists.py python/trunk/Tools/pybench/Lookups.py python/trunk/Tools/pybench/Numbers.py python/trunk/Tools/pybench/Setup.py python/trunk/Tools/pybench/Strings.py python/trunk/Tools/pybench/Tuples.py python/trunk/Tools/pybench/Unicode.py python/trunk/Tools/pybench/pybench.py Log: Revert tests to MAL's original round sizes to retiain comparability from long ago and far away. Stop calling this pybench 1.4 because it isn't. Remove the empty test, which was a bad idea. Modified: python/trunk/Tools/pybench/Arithmetic.py ============================================================================== --- python/trunk/Tools/pybench/Arithmetic.py (original) +++ python/trunk/Tools/pybench/Arithmetic.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 1200*21 + rounds = 120000 def test(self): @@ -159,7 +159,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 1000*30 + rounds = 100000 def test(self): @@ -314,7 +314,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 1200*30 + rounds = 120000 def test(self): @@ -470,7 +470,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 300*32 + rounds = 30000 def test(self): @@ -625,7 +625,7 @@ version = 0.3 operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) - rounds = 400*27 + rounds = 40000 def test(self): Modified: python/trunk/Tools/pybench/Calls.py ============================================================================== --- python/trunk/Tools/pybench/Calls.py (original) +++ python/trunk/Tools/pybench/Calls.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(1+4+4+2) - rounds = 600*22 + rounds = 60000 def test(self): @@ -113,7 +113,7 @@ version = 0.4 operations = 5*(2+5+5+5) - rounds = 300*24 + rounds = 30000 def test(self): @@ -234,7 +234,7 @@ version = 0.3 operations = 5*(6 + 5 + 4) - rounds = 200*27 + rounds = 20000 def test(self): @@ -376,7 +376,7 @@ version = 0.3 operations = 5 - rounds = 500*21 + rounds = 50000 def test(self): Modified: python/trunk/Tools/pybench/Constructs.py ============================================================================== --- python/trunk/Tools/pybench/Constructs.py (original) +++ python/trunk/Tools/pybench/Constructs.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 30*3 # hard to say... - rounds = 1500*27 + rounds = 150000 def test(self): @@ -471,7 +471,7 @@ version = 0.3 operations = 1000*10*5 - rounds = 100 + rounds = 150 def test(self): @@ -496,7 +496,7 @@ version = 0.1 operations = 5 * 5 - rounds = 80*25 + rounds = 8000 def test(self): Modified: python/trunk/Tools/pybench/Dict.py ============================================================================== --- python/trunk/Tools/pybench/Dict.py (original) +++ python/trunk/Tools/pybench/Dict.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(5 + 5) - rounds = 600*24 + rounds = 60000 def test(self): @@ -79,7 +79,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 2000*30 + rounds = 200000 def test(self): @@ -168,7 +168,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 20000 + rounds = 200000 def test(self): @@ -257,7 +257,7 @@ version = 0.1 operations = 5*(6 + 6) - rounds = 2000*19 + rounds = 200000 def test(self): @@ -346,7 +346,7 @@ version = 0.3 operations = 5*(6 + 6 + 6 + 6) - rounds = 500*44 + rounds = 50000 def test(self): Deleted: /python/trunk/Tools/pybench/Empty.py ============================================================================== --- /python/trunk/Tools/pybench/Empty.py Fri May 26 20:26:21 2006 +++ (empty file) @@ -1,22 +0,0 @@ -from pybench import Test - -class EmptyTest(Test): - """This is just here as a potential measure of repeatability.""" - - version = 0.3 - operations = 1 - rounds = 60000 - - def test(self): - - l = [] - for i in xrange(self.rounds): - pass - - - def calibrate(self): - - l = [] - - for i in xrange(self.rounds): - pass Modified: python/trunk/Tools/pybench/Exceptions.py ============================================================================== --- python/trunk/Tools/pybench/Exceptions.py (original) +++ python/trunk/Tools/pybench/Exceptions.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 2 + 3 - rounds = 600*25 + rounds = 60000 def test(self): @@ -44,7 +44,7 @@ version = 0.1 operations = 15 * 10 - rounds = 2000*16 + rounds = 200000 def test(self): Modified: python/trunk/Tools/pybench/Imports.py ============================================================================== --- python/trunk/Tools/pybench/Imports.py (original) +++ python/trunk/Tools/pybench/Imports.py Fri May 26 20:26:21 2006 @@ -8,7 +8,7 @@ version = 0.1 operations = 5 * 5 - rounds = 2000*15 + rounds = 20000 def test(self): @@ -53,7 +53,7 @@ version = 0.1 operations = 5 * 5 - rounds = 200*20 + rounds = 20000 def test(self): @@ -97,7 +97,7 @@ version = 0.1 operations = 5 * 5 - rounds = 200*17 + rounds = 20000 def test(self): Modified: python/trunk/Tools/pybench/Instances.py ============================================================================== --- python/trunk/Tools/pybench/Instances.py (original) +++ python/trunk/Tools/pybench/Instances.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.2 operations = 3 + 7 + 4 - rounds = 600*17 + rounds = 60000 def test(self): Modified: python/trunk/Tools/pybench/Lists.py ============================================================================== --- python/trunk/Tools/pybench/Lists.py (original) +++ python/trunk/Tools/pybench/Lists.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5* (6 + 6 + 6) - rounds = 600*45 + rounds = 60000 def test(self): @@ -132,7 +132,7 @@ version = 0.4 operations = 25*(3+1+2+1) - rounds = 4*45 + rounds = 400 def test(self): @@ -169,7 +169,7 @@ version = 0.3 operations = 5*(1+ 6 + 6 + 3 + 1) - rounds = 600*15 + rounds = 60000 def test(self): Modified: python/trunk/Tools/pybench/Lookups.py ============================================================================== --- python/trunk/Tools/pybench/Lookups.py (original) +++ python/trunk/Tools/pybench/Lookups.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 1000*16 + rounds = 100000 def test(self): @@ -185,7 +185,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 1000*20 + rounds = 100000 def test(self): @@ -371,7 +371,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 1000*14 + rounds = 100000 def test(self): @@ -559,7 +559,7 @@ version = 0.3 operations = 5*(12 + 12) - rounds = 1000*22 + rounds = 100000 def test(self): @@ -747,7 +747,7 @@ version = 0.3 operations = 5*(3*5 + 3*5) - rounds = 700*15 + rounds = 70000 def test(self): Deleted: /python/trunk/Tools/pybench/NewInstances.py ============================================================================== --- /python/trunk/Tools/pybench/NewInstances.py Fri May 26 20:26:21 2006 +++ (empty file) @@ -1,66 +0,0 @@ -from pybench import Test - -class CreateNewInstances(Test): - - version = 0.1 - operations = 3 + 7 + 4 - rounds = 60000 - - def test(self): - - class c(object): - pass - - class d(object): - def __init__(self,a,b,c): - self.a = a - self.b = b - self.c = c - - class e(object): - def __init__(self,a,b,c=4): - self.a = a - self.b = b - self.c = c - self.d = a - self.e = b - self.f = c - - for i in xrange(self.rounds): - o = c() - o1 = c() - o2 = c() - p = d(i,i,3) - p1 = d(i,i,3) - p2 = d(i,3,3) - p3 = d(3,i,3) - p4 = d(i,i,i) - p5 = d(3,i,3) - p6 = d(i,i,i) - q = e(i,i,3) - q1 = e(i,i,3) - q2 = e(i,i,3) - q3 = e(i,i) - - def calibrate(self): - - class c(object): - pass - - class d(object): - def __init__(self,a,b,c): - self.a = a - self.b = b - self.c = c - - class e(object): - def __init__(self,a,b,c=4): - self.a = a - self.b = b - self.c = c - self.d = a - self.e = b - self.f = c - - for i in xrange(self.rounds): - pass Modified: python/trunk/Tools/pybench/Numbers.py ============================================================================== --- python/trunk/Tools/pybench/Numbers.py (original) +++ python/trunk/Tools/pybench/Numbers.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.1 operations = 30 * 5 - rounds = 1200*21 + rounds = 120000 def test(self): @@ -200,7 +200,7 @@ version = 0.1 operations = 30 * 5 - rounds = 600*27 + rounds = 60000 def test(self): @@ -396,7 +396,7 @@ version = 0.1 operations = 30 * 5 - rounds = 600*16 + rounds = 60000 def test(self): @@ -592,7 +592,7 @@ version = 0.1 operations = 30 * 5 - rounds = 600*24 + rounds = 60000 def test(self): Modified: python/trunk/Tools/pybench/Setup.py ============================================================================== --- python/trunk/Tools/pybench/Setup.py (original) +++ python/trunk/Tools/pybench/Setup.py Fri May 26 20:26:21 2006 @@ -17,7 +17,6 @@ Warp_factor = 20 # Import tests -#from Empty import * from Arithmetic import * from Calls import * from Constructs import * Modified: python/trunk/Tools/pybench/Strings.py ============================================================================== --- python/trunk/Tools/pybench/Strings.py (original) +++ python/trunk/Tools/pybench/Strings.py Fri May 26 20:26:21 2006 @@ -5,7 +5,7 @@ version = 0.1 operations = 10 * 5 - rounds = 6000 + rounds = 60000 def test(self): @@ -87,7 +87,7 @@ version = 0.2 operations = 10 * 5 - rounds = 2000*22 + rounds = 200000 def test(self): @@ -169,7 +169,7 @@ version = 0.1 operations = 10 * 5 - rounds = 2000*28 + rounds = 200000 def test(self): @@ -251,7 +251,7 @@ version = 0.1 operations = 10 * 5 - rounds = 800*32 + rounds = 80000 def test(self): @@ -326,7 +326,7 @@ version = 0.1 operations = 5 * 7 - rounds = 1000*15 + rounds = 100000 def test(self): @@ -389,7 +389,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 14000 + rounds = 70000 def test(self): @@ -462,7 +462,7 @@ version = 0.1 operations = 10 * 7 - rounds = 800*24 + rounds = 80000 def test(self): Modified: python/trunk/Tools/pybench/Tuples.py ============================================================================== --- python/trunk/Tools/pybench/Tuples.py (original) +++ python/trunk/Tools/pybench/Tuples.py Fri May 26 20:26:21 2006 @@ -4,7 +4,7 @@ version = 0.31 operations = 3 * 25 * 10 * 7 - rounds = 100 + rounds = 400 def test(self): @@ -272,7 +272,7 @@ version = 0.3 operations = 5*(1 + 3 + 6 + 2) - rounds = 800*16 + rounds = 80000 def test(self): Modified: python/trunk/Tools/pybench/Unicode.py ============================================================================== --- python/trunk/Tools/pybench/Unicode.py (original) +++ python/trunk/Tools/pybench/Unicode.py Fri May 26 20:26:21 2006 @@ -10,7 +10,7 @@ version = 0.1 operations = 10 * 5 - rounds = 600*7 + rounds = 60000 def test(self): @@ -92,7 +92,7 @@ version = 0.1 operations = 10 * 5 - rounds = 1500*17 + rounds = 150000 def test(self): @@ -174,7 +174,7 @@ version = 0.1 operations = 10 * 5 - rounds = 800*12 + rounds = 80000 def test(self): @@ -249,7 +249,7 @@ version = 0.1 operations = 5 * 7 - rounds = 10000 + rounds = 100000 def test(self): @@ -310,7 +310,7 @@ version = 0.1 operations = 3 * (5 + 4 + 2 + 1) - rounds = 100*15 + rounds = 10000 def test(self): @@ -383,7 +383,7 @@ version = 0.1 operations = 5 * 9 - rounds = 1000*25 + rounds = 100000 def test(self): @@ -460,7 +460,7 @@ version = 0.1 operations = 5 * 8 - rounds = 1000*15 + rounds = 100000 def test(self): Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri May 26 20:26:21 2006 @@ -35,7 +35,7 @@ """ # Version number -__version__ = '1.4' +__version__ = '1.3' # # NOTE: Use xrange for all test loops unless you want to face From buildbot at python.org Fri May 26 20:27:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:27:49 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060526182749.53F3A1E4006@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/887 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 20:28:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:28:07 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060526182807.5D00A1E4006@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/711 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 20:31:30 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 20:31:30 +0200 (CEST) Subject: [Python-checkins] r46382 - python/branches/tim-exc_sanity Message-ID: <20060526183130.E8B941E401C@bag.python.org> Author: tim.peters Date: Fri May 26 20:31:30 2006 New Revision: 46382 Added: python/branches/tim-exc_sanity/ - copied from r46381, python/trunk/ Log: This started as work on patch 1145039, but trying to ensure and exploit a stronger invariant: http://mail.python.org/pipermail/python-dev/2006-May/065231.html Alas, there are problems, some due to pre-existing errors: http://mail.python.org/pipermail/python-dev/2006-May/065248.html Putting this aside for now. From python-checkins at python.org Fri May 26 20:31:49 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 20:31:49 +0200 (CEST) Subject: [Python-checkins] r46383 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526183149.2E2CC1E401E@bag.python.org> Author: georg.brandl Date: Fri May 26 20:31:48 2006 New Revision: 46383 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Making StopIteration a singleton didn't give a notable speedup. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 20:31:48 2006 @@ -16,22 +16,11 @@ PyObject *message; } BaseExceptionObject; -static PyTypeObject _PyExc_StopIteration; -PyObject *PyExc_StopIterationInst; - static PyObject * BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { BaseExceptionObject *self; - /* Make StopIteration be a singleton as often as we can */ - if ((args == NULL || PyTuple_GET_SIZE(args) == 0) && - PyExc_StopIterationInst != NULL && - type == &_PyExc_StopIteration) { - Py_INCREF(PyExc_StopIterationInst); - return PyExc_StopIterationInst; - } - self = (BaseExceptionObject *)type->tp_alloc(type, 0); self->args = self->message = self->dict = NULL; @@ -1969,9 +1958,6 @@ */ PyObject *PyExc_MemoryErrorInst=NULL; -/* Make StopIteration be a singleton as often as we can */ -PyObject *PyExc_StopIterationInst=NULL; - /* module global functions */ static PyMethodDef functions[] = { /* Sentinel */ @@ -2113,11 +2099,6 @@ if (!PyExc_MemoryErrorInst) Py_FatalError("Cannot pre-allocate MemoryError instance\n"); - PyExc_StopIterationInst = BaseException_new(&_PyExc_StopIteration, NULL, - NULL); - if (!PyExc_StopIterationInst) - Py_FatalError("Cannot pre-allocate StopIteration instance\n"); - Py_DECREF(bdict); Py_DECREF(bltinmod); } From jimjjewett at gmail.com Fri May 26 20:32:48 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 26 May 2006 14:32:48 -0400 Subject: [Python-checkins] r46291 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: <20060526112939.E8DFC1E400C@bag.python.org> References: <20060526112939.E8DFC1E400C@bag.python.org> Message-ID: Could you add some comments on testing for USE_INLINE right after undefining it? I'm assuming that the #undef either fails, or unmasks a higher-scope definition, but I don't have much confidence in that assumption. -jJ On 5/26/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Fri May 26 13:29:39 2006 > New Revision: 46291 > > Modified: > python/trunk/Include/pyport.h > python/trunk/Python/ceval.c > Log: > needforspeed: added Py_LOCAL macro, based on the LOCAL macro used > for SRE and others. applied Py_LOCAL to relevant portion of ceval, > which gives a 1-2% speedup on my machine. ymmv. > > > > Modified: python/trunk/Include/pyport.h > ============================================================================== > --- python/trunk/Include/pyport.h (original) > +++ python/trunk/Include/pyport.h Fri May 26 13:29:39 2006 > @@ -137,6 +137,23 @@ > # endif > #endif > > +/* PY_LOCAL can be used instead of static to get the fastest possible calling > + * convention for functions that are local to a given module. It also enables > + * inlining, where suitable. */ > + > +#undef USE_INLINE /* XXX - set via configure? */ > + > +#if defined(_MSC_VER) > + /* ignore warnings if the compiler decides not to inline a function */ > +#pragma warning(disable: 4710) > +/* fastest possible local call under MSVC */ > +#define Py_LOCAL(type) static __inline type __fastcall > +#elif defined(USE_INLINE) > +#define Py_LOCAL(type) static inline type > +#else > +#define Py_LOCAL(type) static type > +#endif > + From python-checkins at python.org Fri May 26 20:33:10 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 20:33:10 +0200 (CEST) Subject: [Python-checkins] r46384 - in python/branches/tim-exc_sanity: Doc/api/exceptions.tex Python/ceval.c Python/errors.c Message-ID: <20060526183310.F32521E4006@bag.python.org> Author: tim.peters Date: Fri May 26 20:33:09 2006 New Revision: 46384 Modified: python/branches/tim-exc_sanity/Doc/api/exceptions.tex python/branches/tim-exc_sanity/Python/ceval.c python/branches/tim-exc_sanity/Python/errors.c Log: Part way there, but code still blows up. Modified: python/branches/tim-exc_sanity/Doc/api/exceptions.tex ============================================================================== --- python/branches/tim-exc_sanity/Doc/api/exceptions.tex (original) +++ python/branches/tim-exc_sanity/Doc/api/exceptions.tex Fri May 26 20:33:09 2006 @@ -124,7 +124,9 @@ \begin{cfuncdesc}{void}{PyErr_SetObject}{PyObject *type, PyObject *value} This function is similar to \cfunction{PyErr_SetString()} but lets you specify an arbitrary Python object for the ``value'' of the - exception. + exception. Passing \NULL{} for \var{value} is treated as + if \cdata{Py_None} were passed instead. + \versionchanged[Treating \NULL{} as \cdata{Py_None} was added]{2.5} \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyErr_Format}{PyObject *exception, Modified: python/branches/tim-exc_sanity/Python/ceval.c ============================================================================== --- python/branches/tim-exc_sanity/Python/ceval.c (original) +++ python/branches/tim-exc_sanity/Python/ceval.c Fri May 26 20:33:09 2006 @@ -24,7 +24,7 @@ #pragma optimize("agtw", on) #endif -#ifndef WITH_TSC +#ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -49,7 +49,7 @@ asm volatile ("mftbu %0" : "=r" (tbu2)); if (__builtin_expect(tbu != tbu2, 0)) goto loop; - /* The slightly peculiar way of writing the next lines is + /* The slightly peculiar way of writing the next lines is compiled better by GCC than any other way I tried. */ ((long*)(v))[0] = tbu; ((long*)(v))[1] = tb; @@ -62,7 +62,7 @@ #endif -void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, +void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, uint64 loop0, uint64 loop1, uint64 intr0, uint64 intr1) { uint64 intr, inst, loop; @@ -567,7 +567,7 @@ inst0 -- beginning of switch statement for opcode dispatch inst1 -- end of switch statement (may be skipped) loop0 -- the top of the mainloop - loop1 -- place where control returns again to top of mainloop + loop1 -- place where control returns again to top of mainloop (may be skipped) intr1 -- beginning of long interruption intr2 -- end of long interruption @@ -768,7 +768,7 @@ why = WHY_EXCEPTION; goto on_error; } - + for (;;) { #ifdef WITH_TSC if (inst1 == 0) { @@ -2218,7 +2218,7 @@ re-raising the exception. (But non-local gotos should still be resumed.) */ - + x = TOP(); u = SECOND(); if (PyInt_Check(u) || u == Py_None) { @@ -2581,7 +2581,12 @@ } } - reset_exc_info(tstate); + if (tstate->frame->f_exc_type != NULL) + reset_exc_info(tstate); + else { + assert(tstate->frame->f_exc_value == NULL); + assert(tstate->frame->f_exc_traceback == NULL); + } /* pop frame */ exit_eval_frame: @@ -2900,29 +2905,34 @@ set_exc_info(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyFrameObject *frame; + PyFrameObject *frame = tstate->frame; PyObject *tmp_type, *tmp_value, *tmp_tb; - frame = tstate->frame; + assert(type != NULL); + assert(value != NULL); + assert(tb != NULL); + if (frame->f_exc_type == NULL) { - /* This frame didn't catch an exception before */ - /* Save previous exception of this thread in this frame */ - if (tstate->exc_type == NULL) { - Py_INCREF(Py_None); - tstate->exc_type = Py_None; - } - tmp_value = frame->f_exc_value; - tmp_tb = frame->f_exc_traceback; - Py_XINCREF(tstate->exc_type); - Py_XINCREF(tstate->exc_value); - Py_XINCREF(tstate->exc_traceback); - frame->f_exc_type = tstate->exc_type; - frame->f_exc_value = tstate->exc_value; - frame->f_exc_traceback = tstate->exc_traceback; - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); + /* This frame didn't catch an exception before. */ + assert(frame->f_exc_value == NULL); + assert(frame->f_exc_traceback == NULL); + /* Save previous exception of this thread in this frame. */ + if (tstate->exc_type != NULL) { + assert(tstate->exc_value != NULL); + assert(tstate->exc_traceback != NULL); + Py_INCREF(tstate->exc_type); + Py_INCREF(tstate->exc_value); + Py_INCREF(tstate->exc_traceback); + frame->f_exc_type = tstate->exc_type; + frame->f_exc_value = tstate->exc_value; + frame->f_exc_traceback = tstate->exc_traceback; + } + else { + assert(tstate->exc_value == NULL); + assert(tstate->exc_traceback == NULL); + } } - /* Set new exception for this thread */ + /* Set new exception for this thread. */ tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; @@ -2935,6 +2945,7 @@ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); + /* For b/w compatibility */ PySys_SetObject("exc_type", type); PySys_SetObject("exc_value", value); @@ -2944,37 +2955,43 @@ Py_LOCAL(void) reset_exc_info(PyThreadState *tstate) { - PyFrameObject *frame; + PyFrameObject *frame = tstate->frame; PyObject *tmp_type, *tmp_value, *tmp_tb; - frame = tstate->frame; - if (frame->f_exc_type != NULL) { - /* This frame caught an exception */ - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - Py_INCREF(frame->f_exc_type); - Py_XINCREF(frame->f_exc_value); - Py_XINCREF(frame->f_exc_traceback); - tstate->exc_type = frame->f_exc_type; - tstate->exc_value = frame->f_exc_value; - tstate->exc_traceback = frame->f_exc_traceback; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", frame->f_exc_type); - PySys_SetObject("exc_value", frame->f_exc_value); - PySys_SetObject("exc_traceback", frame->f_exc_traceback); - } + + /* That this frame caught an exception is a precondition. */ + assert(frame->f_exc_type != NULL); + assert(frame->f_exc_value != NULL); + assert(frame->f_exc_traceback != NULL); + + /* Copy exception info back into the thread state. */ + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + Py_INCREF(frame->f_exc_type); + Py_INCREF(frame->f_exc_value); + Py_INCREF(frame->f_exc_traceback); + tstate->exc_type = frame->f_exc_type; + tstate->exc_value = frame->f_exc_value; + tstate->exc_traceback = frame->f_exc_traceback; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); + + /* For b/w compatibility. */ + PySys_SetObject("exc_type", frame->f_exc_type); + PySys_SetObject("exc_value", frame->f_exc_value); + PySys_SetObject("exc_traceback", frame->f_exc_traceback); + + /* Clear the frame's exception info. */ tmp_type = frame->f_exc_type; tmp_value = frame->f_exc_value; tmp_tb = frame->f_exc_traceback; frame->f_exc_type = NULL; frame->f_exc_value = NULL; frame->f_exc_traceback = NULL; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); + Py_DECREF(tmp_type); + Py_DECREF(tmp_value); + Py_DECREF(tmp_tb); } /* Logic for the raise statement (too complicated for inlining). @@ -3846,7 +3863,7 @@ Py_ssize_t x; if (PyInt_Check(v)) { x = PyInt_AsSsize_t(v); - } + } else if (v->ob_type->tp_as_number && PyType_HasFeature(v->ob_type, Py_TPFLAGS_HAVE_INDEX) && v->ob_type->tp_as_number->nb_index) { @@ -4064,7 +4081,7 @@ result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); Py_DECREF(metaclass); if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { - /* A type error here likely means that the user passed + /* A type error here likely means that the user passed in a base that was not a class (such the random module instead of the random.random type). Help them out with by augmenting the error message with more information.*/ @@ -4204,7 +4221,7 @@ { /* This function implements 'variable += expr' when both arguments are strings. */ - + if (v->ob_refcnt == 2) { /* In the common case, there are 2 references to the value * stored in 'variable' when the += is performed: one on the Modified: python/branches/tim-exc_sanity/Python/errors.c ============================================================================== --- python/branches/tim-exc_sanity/Python/errors.c (original) +++ python/branches/tim-exc_sanity/Python/errors.c Fri May 26 20:33:09 2006 @@ -52,8 +52,13 @@ void PyErr_SetObject(PyObject *exception, PyObject *value) { + /* ho ho ho! blows up _while_ initializing exceptions + assert(exception != NULL); */ + if (value == NULL) + value = Py_None; + /* Py_INCREF(exception); */ Py_XINCREF(exception); - Py_XINCREF(value); + Py_INCREF(value); PyErr_Restore(exception, value, (PyObject *)NULL); } @@ -138,13 +143,11 @@ return; } - /* If PyErr_SetNone() was used, the value will have been actually - set to NULL. + assert(value != NULL); + assert(tb != NULL); + /* XXX this triggers + assert(*tb != NULL); */ - if (!value) { - value = Py_None; - Py_INCREF(value); - } if (PyExceptionInstance_Check(value)) inclass = PyExceptionInstance_Class(value); From python-checkins at python.org Fri May 26 20:33:36 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 20:33:36 +0200 (CEST) Subject: [Python-checkins] r46385 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c hotbuf.py test_hotbuf.py Message-ID: <20060526183336.0F4B51E4006@bag.python.org> Author: bob.ippolito Date: Fri May 26 20:33:35 2006 New Revision: 46385 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/hotbuf.py sandbox/trunk/hotbuffer/test_hotbuf.py Log: change IndexError to HotbufOverflow Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 20:33:35 2006 @@ -23,6 +23,7 @@ #endif static PyTypeObject PyHotbuf_Type; +static PyObject *HotbufOverflow = NULL; #define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) @@ -102,7 +103,7 @@ { Py_ssize_t newposition = self->b_position + nbytes; if (newposition > self->b_limit) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "position must be smaller than limit"); return -1; } @@ -255,7 +256,7 @@ return NULL; if ( newposition > self->b_capacity ) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "position must be smaller than capacity"); return NULL; } @@ -306,7 +307,7 @@ return NULL; if ( newlimit > self->b_capacity ) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "limit must be smaller than capacity"); return NULL; } @@ -328,7 +329,7 @@ \n\ Sets this buffer's limit to be beyond position by the given\n\ number number of bytes. If the limit is larger than the \n\ -capacity an IndexError is raised."); +capacity an HotbufOverflow is raised."); static PyObject* hotbuf_setwindow(PyHotbufObject *self, PyObject* arg) @@ -342,7 +343,7 @@ newlimit = self->b_position + window; if ( newlimit > self->b_capacity ) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "limit must be smaller than capacity"); return NULL; } @@ -373,7 +374,7 @@ \n\ Resets this buffer's position to the previously-marked\n\ position and limit. Invoking this method neither changes nor\n\ -discards the mark's value. An IndexError is raised if the\n\ +discards the mark's value. An HotbufOverflow is raised if the\n\ mark has not been set. This method returns the new\n\ position's value. If you specify a number of bytes via \n\ 'advbytes', the method advances the position by that many bytes."); @@ -386,7 +387,7 @@ /* Validate that the mark is set. */ if ( self->b_mark_position == -1 || self->b_mark_limit == -1 ) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "mark has not been yet set"); return NULL; } @@ -404,7 +405,7 @@ /* Validate the new position, if specified */ newposition = self->b_mark_position + advbytes; if (newposition > self->b_limit) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "new position must be smaller than limit"); return NULL; } @@ -569,7 +570,7 @@ Relative get methods. \n\ Reads something at this buffer's current position, \n\ and then increments the position.\n\ -An IndexError is raised if the position is at the end of the buffer."); +An HotbufOverflow is raised if the position is at the end of the buffer."); PyDoc_STRVAR(put__doc__, "B.put*(data)\n\ @@ -577,14 +578,14 @@ Relative put methods. \n\ Writes the given byte into this buffer at the current position,\n\ and then increments the position.\n\ -An IndexError is raised if the position is at the end of the buffer."); +An HotbufOverflow is raised if the position is at the end of the buffer."); /* Check if we're going to be trying to year beyond the buffer active window limit, and if so, sets and error and return */ #define CHECK_LIMIT_ERROR(sz) \ if ( (self->b_position + sz) > self->b_limit ) { \ - PyErr_SetString(PyExc_IndexError, \ + PyErr_SetString(HotbufOverflow, \ "attempted read beyond buffer limit"); \ return NULL; \ } @@ -628,7 +629,7 @@ Extract a string of 'nbytes' bytes from the buffer and advance the\n\ position accordingly. If 'nbytes' is not specified, get the string\n\ up to the limit.\n\ -An IndexError is raised if the position is at the end of the buffer."); +An HotbufOverflow is raised if the position is at the end of the buffer."); static PyObject* hotbuf_getstr(PyHotbufObject *self, PyObject* args) @@ -670,7 +671,7 @@ \n\ Write a string of 'nbytes' bytes from the buffer and advance the \n\ position accordingly.\n\ -An IndexError is raised if the position is at the end of the buffer."); +An HotbufOverflow is raised if the position is at the end of the buffer."); static PyObject* hotbuf_putstr(PyHotbufObject *self, PyObject* arg) @@ -857,7 +858,7 @@ return -1; if (newposition > self->b_capacity) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "position must be smaller than capacity"); return -1; } @@ -884,7 +885,7 @@ return -1; if (newlimit > self->b_capacity) { - PyErr_SetString(PyExc_IndexError, + PyErr_SetString(HotbufOverflow, "limit must be smaller than capacity"); return -1; } @@ -1046,6 +1047,13 @@ if (PyType_Ready(&PyHotbuf_Type) < 0) return; + if (HotbufOverflow == NULL) { + HotbufOverflow = PyErr_NewException("hotbuf.HotbufOverflow", NULL, NULL); + if (HotbufOverflow == NULL) + return; + } + Py_INCREF(HotbufOverflow); + PyModule_AddObject(m, "HotbufOverflow", HotbufOverflow); Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Py_INCREF((PyObject *)&PyHotbuf_Type); Modified: sandbox/trunk/hotbuffer/hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/hotbuf.py (original) +++ sandbox/trunk/hotbuffer/hotbuf.py Fri May 26 20:33:35 2006 @@ -4,7 +4,7 @@ A buffer class for fast I/O. """ -from _hotbuf import _hotbuf +from _hotbuf import _hotbuf, HotbufOverflow from struct import Struct _long = Struct('l') Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 20:33:35 2006 @@ -6,7 +6,7 @@ # Licensed to PSF under a Contributor Agreement. # -from hotbuf import hotbuf +from hotbuf import hotbuf, HotbufOverflow from struct import Struct import unittest from test import test_support @@ -32,18 +32,18 @@ assert b.position == 0 b.setposition(10) self.assertEquals(b.position, 10) - self.assertRaises(IndexError, b.setposition, CAPACITY + 1) + self.assertRaises(HotbufOverflow, b.setposition, CAPACITY + 1) # Play with the limit assert b.limit == CAPACITY b.setlimit(CAPACITY - 10) self.assertEquals(b.limit, CAPACITY - 10) - self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + self.assertRaises(HotbufOverflow, b.setlimit, CAPACITY + 1) b.setlimit(b.position - 1) self.assertEquals(b.position, b.limit) # Play with reset before the mark has been set. - self.assertRaises(IndexError, b.setlimit, CAPACITY + 1) + self.assertRaises(HotbufOverflow, b.setlimit, CAPACITY + 1) # Play with the mark b.setposition(10) @@ -83,7 +83,7 @@ b.advance(32) self.assertEquals(b.position, 42) - self.assertRaises(IndexError, b.advance, CAPACITY) + self.assertRaises(HotbufOverflow, b.advance, CAPACITY) # Play with setwindow() b.clear() @@ -121,7 +121,7 @@ b.putbyte(x) # Test overflow. - self.assertRaises(IndexError, b.putbyte, 42) + self.assertRaises(HotbufOverflow, b.putbyte, 42) # Read all data from the buffer. b.flip() @@ -130,7 +130,7 @@ assert nx == x # Test underflow. - self.assertRaises(IndexError, b.putbyte, 42) + self.assertRaises(HotbufOverflow, b.putbyte, 42) def test_str( self ): b = hotbuf(256) @@ -144,10 +144,10 @@ # Test overflow. b.flip() - self.assertRaises(IndexError, b.putstr, ' ' * 1000) + self.assertRaises(HotbufOverflow, b.putstr, ' ' * 1000) # Test underflow. - self.assertRaises(IndexError, b.getstr, 1000) + self.assertRaises(HotbufOverflow, b.getstr, 1000) # Test getting the rest of the string. b.clear() From python-checkins at python.org Fri May 26 20:40:09 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 20:40:09 +0200 (CEST) Subject: [Python-checkins] r46386 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c Message-ID: <20060526184009.ABA771E4006@bag.python.org> Author: bob.ippolito Date: Fri May 26 20:40:09 2006 New Revision: 46386 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Log: return HotbufOverflow instead of struct.error on overflow Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 20:40:09 2006 @@ -743,6 +743,8 @@ PyErr_SetString(PyExc_TypeError, "unpack requires a single struct argument"); + CHECK_LIMIT_ERROR(len); + result = PyObject_CallMethodObjArgs(structobj, str_unpack_from, self, NULL); From python-checkins at python.org Fri May 26 20:41:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 20:41:18 +0200 (CEST) Subject: [Python-checkins] r46387 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060526184118.AB9361E4006@bag.python.org> Author: andrew.kuchling Date: Fri May 26 20:41:18 2006 New Revision: 46387 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add rpartition() and path caching Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri May 26 20:41:18 2006 @@ -1042,15 +1042,22 @@ print d[3], d[4] # Prints 0, 0 \end{verbatim} -\item Both 8-bit and Unicode strings have a new \method{partition(sep)} method. +\item Both 8-bit and Unicode strings have new \method{partition(sep)} +and \method{rpartition(sep)} methods that simplify a common use case. The \method{find(S)} method is often used to get an index which is then used to slice the string and obtain the pieces that are before -and after the separator. \method{partition(sep)} condenses this +and after the separator. + +\method{partition(sep)} condenses this pattern into a single method call that returns a 3-tuple containing the substring before the separator, the separator itself, and the substring after the separator. If the separator isn't found, the first element of the tuple is the entire string and the other two -elements are empty. Some examples: +elements are empty. \method{rpartition(sep)} also returns a 3-tuple +but starts searching from the end of the string; the \samp{r} stands +for 'reverse'. + +Some examples: \begin{verbatim} >>> ('http://www.python.org').partition('://') @@ -1059,6 +1066,8 @@ (u'Subject', u':', u' a quick question') >>> ('file:/usr/share/doc/index.html').partition('://') ('file:/usr/share/doc/index.html', '', '') +>>> 'www.python.org'.rpartition('.') +('www.python', '.', 'org') \end{verbatim} (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) @@ -1192,6 +1201,12 @@ and reduce memory usage a bit. (Contributed by Neal Norwitz.) % Patch 1337051 +\item Importing now caches the paths tried, recording whether +they exist or not so that the interpreter makes fewer +\cfunction{open()} and \cfunction{stat()} calls on startup. +(Contributed by Martin von~L\"owis and Georg Brandl.) +% Patch 921466 + \end{itemize} The net result of the 2.5 optimizations is that Python 2.5 runs the From buildbot at python.org Fri May 26 20:42:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:42:49 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Debian unstable trunk Message-ID: <20060526184249.94E801E4006@bag.python.org> The Buildbot has detected a new failure of ia64 Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Debian%2520unstable%2520trunk/builds/497 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 20:45:56 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:45:56 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060526184556.9281A1E4006@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/784 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 20:48:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 18:48:06 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526184806.91A8A1E400F@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/813 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 21:02:11 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 21:02:11 +0200 (CEST) Subject: [Python-checkins] r46388 - python/trunk/Objects/stringobject.c Message-ID: <20060526190211.414791E401E@bag.python.org> Author: andrew.dalke Date: Fri May 26 21:02:09 2006 New Revision: 46388 Modified: python/trunk/Objects/stringobject.c Log: substring split now uses /F's fast string matching algorithm. (If compiled without FAST search support, changed the pre-memcmp test to check the last character as well as the first. This gave a 25% speedup for my test case.) Rewrote the split algorithms so they stop when maxsplit gets to 0. Previously they did a string match first then checked if the maxsplit was reached. The new way prevents a needless string search. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 21:02:09 2006 @@ -1322,6 +1322,13 @@ #define STRIPNAME(i) (stripformat[i]+3) +/* Don't call if length < 2 */ +#define Py_STRING_MATCH(target, offset, pattern, length) \ + (target[offset] == pattern[0] && \ + target[offset+length-1] == pattern[length-1] && \ + !memcmp(target+offset+1, pattern+1, length-2) ) + + /* Overallocate the initial list to reduce the number of reallocs for small split sizes. Eg, "A A A A A A A A A A".split() (10 elements) has three resizes, to sizes 4, 8, then 16. Most observed string splits are for human @@ -1416,18 +1423,19 @@ if (list == NULL) return NULL; - for (i = j = 0; i < len; ) { - /* TODO: Use findchar/memchr for this? */ - if (s[i] == ch) { - if (maxcount-- <= 0) + i = j = 0; + while ((j < len) && (maxcount-- > 0)) { + for(; j 0) { + pos = fastsearch(s+i, len-i, sub, n, FAST_SEARCH); + if (pos < 0) + break; + j = i+pos; + SPLIT_ADD(s, i, j); + i = j + n; + + } +#else i = j = 0; - while (i+n <= len) { - /* TODO: Use Py_STRING_MATCH */ - if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { - if (maxsplit-- <= 0) + while ((j+n <= len) && (maxsplit-- > 0)) { + for (; j+n <= len; j++) { + if (Py_STRING_MATCH(s, j, sub, n)) { + SPLIT_ADD(s, i, j); + i = j = j + n; break; - SPLIT_ADD(s, j, i); - i = j = i + n; + } } - else - i++; } - SPLIT_ADD(s, j, len); +#endif + SPLIT_ADD(s, i, len); FIX_PREALLOC_SIZE(list); return list; @@ -1610,14 +1632,15 @@ if (list == NULL) return NULL; - for (i = j = len - 1; i >= 0; ) { - if (s[i] == ch) { - if (maxcount-- <= 0) + i = j = len - 1; + while ((i >= 0) && (maxcount-- > 0)) { + for (; i >= 0; i--) { + if (s[i] == ch) { + SPLIT_ADD(s, i + 1, j + 1); + j = i = i - 1; break; - SPLIT_ADD(s, i + 1, j + 1); - j = i = i - 1; - } else - i--; + } + } } if (j >= -1) { SPLIT_ADD(s, 0, j + 1); @@ -1679,16 +1702,16 @@ j = len; i = j - n; - while (i >= 0) { - if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { - if (maxsplit-- <= 0) + + while ( (i >= 0) && (maxsplit-- > 0) ) { + for (; i>=0; i--) { + if (Py_STRING_MATCH(s, i, sub, n)) { + SPLIT_ADD(s, i + n, j); + j = i; + i -= n; break; - SPLIT_ADD(s, i+n, j); - j = i; - i -= n; + } } - else - i--; } SPLIT_ADD(s, 0, j); FIX_PREALLOC_SIZE(list); @@ -2449,12 +2472,6 @@ /* find and count characters and substrings */ -/* Don't call if length < 2 */ -#define Py_STRING_MATCH(target, offset, pattern, length) \ - (target[offset] == pattern[0] && \ - target[offset+length-1] == pattern[length-1] && \ - !memcmp(target+offset+1, pattern+1, length-2) ) - #define findchar(target, target_len, c) \ ((char *)memchr((const void *)(target), c, target_len)) From python-checkins at python.org Fri May 26 21:03:31 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 26 May 2006 21:03:31 +0200 (CEST) Subject: [Python-checkins] r46389 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060526190331.6FA781E400C@bag.python.org> Author: phillip.eby Date: Fri May 26 21:03:28 2006 New Revision: 46389 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Don't make things warnings that aren't; update info text for --multi-version. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri May 26 21:03:28 2006 @@ -496,7 +496,7 @@ self.local_index.add(dist) self.install_egg_scripts(dist) self.installed_projects[dist.key] = dist - log.warn(self.installation_report(requirement, dist, *info)) + log.info(self.installation_report(requirement, dist, *info)) if not deps and not self.always_copy: return elif requirement is not None and dist.key != requirement.key: @@ -649,7 +649,7 @@ # Now run it, and return the result if self.editable: - log.warn(self.report_editable(spec, setup_script)) + log.info(self.report_editable(spec, setup_script)) return [] else: return self.build_and_install(setup_script, setup_base) @@ -865,10 +865,10 @@ if self.multi_version and not self.no_report: msg += """ -Because this distribution was installed --multi-version or --install-dir, -before you can import modules from this package in an application, you -will need to 'import pkg_resources' and then use a 'require()' call -similar to one of these examples, in order to select the desired version: +Because this distribution was installed --multi-version, before you can +import modules from this package in an application, you will need to +'import pkg_resources' and then use a 'require()' call similar to one of +these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version From python-checkins at python.org Fri May 26 21:04:31 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 26 May 2006 21:04:31 +0200 (CEST) Subject: [Python-checkins] r46390 - sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Message-ID: <20060526190431.A14B41E4006@bag.python.org> Author: phillip.eby Date: Fri May 26 21:04:31 2006 New Revision: 46390 Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Don't make things warnings that aren't; update info text for --multi-version. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri May 26 21:04:31 2006 @@ -496,7 +496,7 @@ self.local_index.add(dist) self.install_egg_scripts(dist) self.installed_projects[dist.key] = dist - log.warn(self.installation_report(requirement, dist, *info)) + log.info(self.installation_report(requirement, dist, *info)) if not deps and not self.always_copy: return elif requirement is not None and dist.key != requirement.key: @@ -649,7 +649,7 @@ # Now run it, and return the result if self.editable: - log.warn(self.report_editable(spec, setup_script)) + log.info(self.report_editable(spec, setup_script)) return [] else: return self.build_and_install(setup_script, setup_base) @@ -865,10 +865,10 @@ if self.multi_version and not self.no_report: msg += """ -Because this distribution was installed --multi-version or --install-dir, -before you can import modules from this package in an application, you -will need to 'import pkg_resources' and then use a 'require()' call -similar to one of these examples, in order to select the desired version: +Because this distribution was installed --multi-version, before you can +import modules from this package in an application, you will need to +'import pkg_resources' and then use a 'require()' call similar to one of +these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version From python-checkins at python.org Fri May 26 21:04:48 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 26 May 2006 21:04:48 +0200 (CEST) Subject: [Python-checkins] r46391 - python/trunk/Misc/Vim/vimrc Message-ID: <20060526190448.A175E1E4006@bag.python.org> Author: brett.cannon Date: Fri May 26 21:04:47 2006 New Revision: 46391 Modified: python/trunk/Misc/Vim/vimrc Log: Change C spacing to 4 spaces by default to match PEP 7 for new C files. Modified: python/trunk/Misc/Vim/vimrc ============================================================================== --- python/trunk/Misc/Vim/vimrc (original) +++ python/trunk/Misc/Vim/vimrc Fri May 26 21:04:47 2006 @@ -21,7 +21,7 @@ " Python: 4 spaces " C: tab (8 spaces) au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead,BufNewFile *.c,*.h set shiftwidth=8 +au BufRead,BufNewFile *.c,*.h set shiftwidth=4 " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. From python-checkins at python.org Fri May 26 21:04:48 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 21:04:48 +0200 (CEST) Subject: [Python-checkins] r46392 - python/trunk/Doc/api/exceptions.tex Message-ID: <20060526190448.A3D6F1E400C@bag.python.org> Author: georg.brandl Date: Fri May 26 21:04:47 2006 New Revision: 46392 Modified: python/trunk/Doc/api/exceptions.tex Log: Exception isn't the root of all exception classes anymore. Modified: python/trunk/Doc/api/exceptions.tex ============================================================================== --- python/trunk/Doc/api/exceptions.tex (original) +++ python/trunk/Doc/api/exceptions.tex Fri May 26 21:04:47 2006 @@ -336,8 +336,9 @@ The \var{name} argument must be the name of the new exception, a C string of the form \code{module.class}. The \var{base} and \var{dict} arguments are normally \NULL. This creates a class - object derived from the root for all exceptions, the built-in name - \exception{Exception} (accessible in C as \cdata{PyExc_Exception}). + object derived from \exception{Exception} (accessible in C as + \cdata{PyExc_Exception}). + The \member{__module__} attribute of the new class is set to the first part (up to the last dot) of the \var{name} argument, and the class name is set to the last part (after the last dot). The From martin at v.loewis.de Fri May 26 21:05:55 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 26 May 2006 21:05:55 +0200 Subject: [Python-checkins] r46375 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c In-Reply-To: <20060526181056.EB8AB1E4006@bag.python.org> References: <20060526181056.EB8AB1E4006@bag.python.org> Message-ID: <44775193.9030907@v.loewis.de> bob.ippolito wrote: > +#define lenfunc inquiry > +#define readbufferproc getreadbufferproc > +#define writebufferproc getwritebufferproc > +#define charbufferproc getcharbufferproc > +#define segcountproc getsegcountproc I would like to advise against these. Instead, I would write the patch below. Regards, Martin Index: _hotbuf.c =================================================================== --- _hotbuf.c (Revision 46387) +++ _hotbuf.c (Arbeitskopie) @@ -15,11 +15,6 @@ #define PY_SSIZE_T_MIN INT_MIN #define PyInt_FromSsize_t PyInt_FromLong #define PyInt_AsSsize_t PyInt_AsLong -#define lenfunc inquiry -#define readbufferproc getreadbufferproc -#define writebufferproc getwritebufferproc -#define charbufferproc getcharbufferproc -#define segcountproc getsegcountproc #endif static PyTypeObject PyHotbuf_Type; @@ -769,8 +764,9 @@ * deliver the portion in the active window. */ static Py_ssize_t -hotbuf_getwritebuf(PyHotbufObject *self, Py_ssize_t idx, void **pp) +hotbuf_getwritebuf(PyObject *self, Py_ssize_t idx, void **pp) { + PyyHotbufObject *self = (yHotbufObject*)self; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, "accessing non-existent hotbuf segment"); @@ -782,15 +778,16 @@ } static Py_ssize_t -hotbuf_getsegcount(PyHotbufObject *self, Py_ssize_t *lenp) +hotbuf_getsegcount(PyObject *self, Py_ssize_t *lenp) { + PyHotbufObject *self = (PyHotbufObject*)self; if (lenp) *lenp = self->b_capacity; return 1; } static Py_ssize_t -hotbuf_getcharbuf(PyHotbufObject *self, Py_ssize_t idx, const char **pp) +hotbuf_getcharbuf(PyObject *self, Py_ssize_t idx, const char **pp) { return hotbuf_getwritebuf(self, idx, (void**)pp); } @@ -802,8 +799,9 @@ */ static Py_ssize_t -hotbuf_length(PyHotbufObject *self) +hotbuf_length(PyObject *_self) { + PyHotbufObject *self = (PyHotbufObject*)_self; /* Note: this is the same as 'remaining'. */ assert(self->b_position <= self->b_limit); return self->b_limit - self->b_position; @@ -945,7 +943,7 @@ }; static PySequenceMethods hotbuf_as_sequence = { - (lenfunc)hotbuf_length, /*sq_length*/ + hotbuf_length, /*sq_length*/ 0 /* (binaryfunc)hotbuf_concat */, /*sq_concat*/ 0 /* (ssizeargfunc)hotbuf_repeat */, /*sq_repeat*/ 0 /* (ssizeargfunc)hotbuf_item */, /*sq_item*/ @@ -955,10 +953,10 @@ }; static PyBufferProcs hotbuf_as_buffer = { - (readbufferproc)hotbuf_getwritebuf, - (writebufferproc)hotbuf_getwritebuf, - (segcountproc)hotbuf_getsegcount, - (charbufferproc)hotbuf_getcharbuf, + hotbuf_getwritebuf, + hotbuf_getwritebuf, + hotbuf_getsegcount, + hotbuf_getcharbuf, }; static PyTypeObject PyHotbuf_Type = { From buildbot at python.org Fri May 26 21:06:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 19:06:48 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060526190648.A616A1E4023@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/526 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 21:12:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 19:12:40 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060526191240.93E731E4006@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/46 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 21:13:41 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 21:13:41 +0200 (CEST) Subject: [Python-checkins] r46394 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c Modules/fastsearch.h test_hotbuf.py Message-ID: <20060526191341.B3FDB1E4006@bag.python.org> Author: bob.ippolito Date: Fri May 26 21:13:40 2006 New Revision: 46394 Added: sandbox/trunk/hotbuffer/Modules/fastsearch.h (contents, props changed) Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/test_hotbuf.py Log: add fast find and count functions Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 21:13:40 2006 @@ -20,7 +20,13 @@ #define writebufferproc getwritebufferproc #define charbufferproc getcharbufferproc #define segcountproc getsegcountproc +#ifndef Py_LOCAL(rval) +#define Py_LOCAL static rval #endif +#endif + +#define STRINGLIB_CHAR char +#include "fastsearch.h" static PyTypeObject PyHotbuf_Type; static PyObject *HotbufOverflow = NULL; @@ -685,7 +691,7 @@ "incorrect input type, require string"); return NULL; } - instring = PyString_AsString(arg); + instring = PyString_AS_STRING(arg); len = PyString_GET_SIZE(arg); CHECK_LIMIT_ERROR(len); @@ -759,6 +765,65 @@ return result; } +PyDoc_STRVAR(find__doc__, +"B.find(sub) -> int\n\ +\n\ +Return the lowest index in S where substring sub is found,\n\ +such that sub is contained within the current window.\n\ +\n\ +Return -1 on failure."); + +static PyObject* +hotbuf_find(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t result; + + /* Check and extract input string */ + if ( arg == NULL || !PyString_Check(arg) ) { + PyErr_SetString(PyExc_TypeError, + "incorrect input type, require string"); + return NULL; + } + + result = fastsearch(self->b_ptr + self->b_position, + self->b_limit - self->b_position, + PyString_AS_STRING(arg), + PyString_GET_SIZE(arg), + FAST_SEARCH); + + return PyInt_FromSsize_t(result); +} + +PyDoc_STRVAR(count__doc__, +"B.count(sub) -> int\n\ +\n\ +Return the number of occurrences of substring sub in\n\ +the current window."); + +static PyObject* +hotbuf_count(PyHotbufObject *self, PyObject* arg) +{ + Py_ssize_t result; + + /* Check and extract input string */ + if ( arg == NULL || !PyString_Check(arg) ) { + PyErr_SetString(PyExc_TypeError, + "incorrect input type, require string"); + return NULL; + } + + result = fastsearch(self->b_ptr + self->b_position, + self->b_limit - self->b_position, + PyString_AS_STRING(arg), + PyString_GET_SIZE(arg), + FAST_COUNT); + + if (result == -1) + result = 0; + + return PyInt_FromSsize_t(result); +} + /* =========================================================================== * Buffer protocol methods @@ -941,6 +1006,8 @@ {"getstr", (PyCFunction)hotbuf_getstr, METH_VARARGS, getstr__doc__}, {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, {"unpack", (PyCFunction)hotbuf_unpack, METH_O, unpack__doc__}, + {"find", (PyCFunction)hotbuf_find, METH_O, find__doc__}, + {"count", (PyCFunction)hotbuf_count, METH_O, count__doc__}, {NULL, NULL} /* sentinel */ }; Added: sandbox/trunk/hotbuffer/Modules/fastsearch.h ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/Modules/fastsearch.h Fri May 26 21:13:40 2006 @@ -0,0 +1,104 @@ +/* stringlib: fastsearch implementation */ + +#ifndef STRINGLIB_FASTSEARCH_H +#define STRINGLIB_FASTSEARCH_H + +/* fast search/count implementation, based on a mix between boyer- + moore and horspool, with a few more bells and whistles on the top. + for some more background, see: http://effbot.org/stringlib */ + +/* note: fastsearch may access s[n], which isn't a problem when using + Python's ordinary string types, but may cause problems if you're + using this code in other contexts. also, the count mode returns -1 + if there cannot possible be a match in the target string, and 0 if + it has actually checked for matches, but didn't find any. callers + beware! */ + +#define FAST_COUNT 0 +#define FAST_SEARCH 1 + +Py_LOCAL(Py_ssize_t) +fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n, + const STRINGLIB_CHAR* p, Py_ssize_t m, + int mode) +{ + long mask; + Py_ssize_t skip, count = 0; + Py_ssize_t i, j, mlast, w; + + w = n - m; + + if (w < 0) + return -1; + + /* look for special cases */ + if (m <= 1) { + if (m <= 0) + return -1; + /* use special case for 1-character strings */ + if (mode == FAST_COUNT) { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + count++; + return count; + } else { + for (i = 0; i < n; i++) + if (s[i] == p[0]) + return i; + } + return -1; + } + + mlast = m - 1; + + /* create compressed boyer-moore delta 1 table */ + skip = mlast - 1; + /* process pattern[:-1] */ + for (mask = i = 0; i < mlast; i++) { + mask |= (1 << (p[i] & 0x1F)); + if (p[i] == p[mlast]) + skip = mlast - i - 1; + } + /* process pattern[-1] outside the loop */ + mask |= (1 << (p[mlast] & 0x1F)); + + for (i = 0; i <= w; i++) { + /* note: using mlast in the skip path slows things down on x86 */ + if (s[i+m-1] == p[m-1]) { + /* candidate match */ + for (j = 0; j < mlast; j++) + if (s[i+j] != p[j]) + break; + if (j == mlast) { + /* got a match! */ + if (mode != FAST_COUNT) + return i; + count++; + i = i + mlast; + continue; + } + /* miss: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + else + i = i + skip; + } else { + /* skip: check if next character is part of pattern */ + if (!(mask & (1 << (s[i+m] & 0x1F)))) + i = i + m; + } + } + + if (mode != FAST_COUNT) + return -1; + return count; +} + +#endif + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 21:13:40 2006 @@ -227,6 +227,55 @@ self.assertEquals(str(b), '') self.assertEquals(b.getstr(), '') + def test_count(self): + b = hotbuf(CAPACITY) + b.putstr('abcddddd') + b.flip() + b.limit = 3 + self.assertEquals(b.count('ab'), 1) + self.assertEquals(b.count('d'), 0) + self.assertEquals(b.count('1' * 100), 0) + b.limit = 4 + self.assertEquals(b.count('ab'), 1) + self.assertEquals(b.count('d'), 1) + self.assertEquals(b.count('1' * 100), 0) + b.limit = 5 + self.assertEquals(b.count('ab'), 1) + self.assertEquals(b.count('d'), 2) + self.assertEquals(b.count('1' * 100), 0) + b.advance(1) + self.assertEquals(b.count('ab'), 0) + self.assertEquals(b.count('d'), 2) + self.assertEquals(b.count('1' * 100), 0) + b.limit += 1 + self.assertEquals(b.count('ab'), 0) + self.assertEquals(b.count('d'), 3) + self.assertEquals(b.count('1' * 100), 0) + + def test_find(self): + b = hotbuf(CAPACITY) + b.putstr('abcddddd') + b.flip() + b.limit = 3 + self.assertEquals(b.find('ab'), 0) + self.assertEquals(b.find('d'), -1) + self.assertEquals(b.find('1' * 100), -1) + b.limit = 4 + self.assertEquals(b.find('ab'), 0) + self.assertEquals(b.find('d'), 3) + self.assertEquals(b.find('1' * 100), -1) + b.limit = 5 + self.assertEquals(b.find('ab'), 0) + self.assertEquals(b.find('d'), 3) + self.assertEquals(b.find('1' * 100), -1) + b.advance(1) + self.assertEquals(b.find('ab'), -1) + self.assertEquals(b.find('d'), 2) + self.assertEquals(b.find('1' * 100), -1) + b.limit += 1 + self.assertEquals(b.find('ab'), -1) + self.assertEquals(b.find('d'), 2) + self.assertEquals(b.find('1' * 100), -1) def test_main(): test_support.run_unittest(HotbufTestCase) From buildbot at python.org Fri May 26 21:16:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 19:16:40 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060526191641.163941E4006@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/807 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,steve.holden Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 21:17:03 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 19:17:03 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060526191703.A5ADE1E4006@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/450 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh,georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 21:22:20 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 21:22:20 +0200 (CEST) Subject: [Python-checkins] r46396 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c hotbuf.py test_hotbuf.py Message-ID: <20060526192220.369041E4006@bag.python.org> Author: bob.ippolito Date: Fri May 26 21:22:19 2006 New Revision: 46396 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/hotbuf.py sandbox/trunk/hotbuffer/test_hotbuf.py Log: change to BoundaryError Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 21:22:19 2006 @@ -29,7 +29,7 @@ #include "fastsearch.h" static PyTypeObject PyHotbuf_Type; -static PyObject *HotbufOverflow = NULL; +static PyObject *BoundaryError = NULL; #define PyHotbuf_Check(op) PyObject_TypeCheck((op), &PyHotbuf_Type) @@ -109,7 +109,7 @@ { Py_ssize_t newposition = self->b_position + nbytes; if (newposition > self->b_limit) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "position must be smaller than limit"); return -1; } @@ -262,7 +262,7 @@ return NULL; if ( newposition > self->b_capacity ) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "position must be smaller than capacity"); return NULL; } @@ -313,7 +313,7 @@ return NULL; if ( newlimit > self->b_capacity ) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "limit must be smaller than capacity"); return NULL; } @@ -335,7 +335,7 @@ \n\ Sets this buffer's limit to be beyond position by the given\n\ number number of bytes. If the limit is larger than the \n\ -capacity an HotbufOverflow is raised."); +capacity an BoundaryError is raised."); static PyObject* hotbuf_setwindow(PyHotbufObject *self, PyObject* arg) @@ -349,7 +349,7 @@ newlimit = self->b_position + window; if ( newlimit > self->b_capacity ) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "limit must be smaller than capacity"); return NULL; } @@ -380,7 +380,7 @@ \n\ Resets this buffer's position to the previously-marked\n\ position and limit. Invoking this method neither changes nor\n\ -discards the mark's value. An HotbufOverflow is raised if the\n\ +discards the mark's value. An BoundaryError is raised if the\n\ mark has not been set. This method returns the new\n\ position's value. If you specify a number of bytes via \n\ 'advbytes', the method advances the position by that many bytes."); @@ -393,7 +393,7 @@ /* Validate that the mark is set. */ if ( self->b_mark_position == -1 || self->b_mark_limit == -1 ) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "mark has not been yet set"); return NULL; } @@ -411,7 +411,7 @@ /* Validate the new position, if specified */ newposition = self->b_mark_position + advbytes; if (newposition > self->b_limit) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "new position must be smaller than limit"); return NULL; } @@ -576,7 +576,7 @@ Relative get methods. \n\ Reads something at this buffer's current position, \n\ and then increments the position.\n\ -An HotbufOverflow is raised if the position is at the end of the buffer."); +An BoundaryError is raised if the position is at the end of the buffer."); PyDoc_STRVAR(put__doc__, "B.put*(data)\n\ @@ -584,14 +584,14 @@ Relative put methods. \n\ Writes the given byte into this buffer at the current position,\n\ and then increments the position.\n\ -An HotbufOverflow is raised if the position is at the end of the buffer."); +An BoundaryError is raised if the position is at the end of the buffer."); /* Check if we're going to be trying to year beyond the buffer active window limit, and if so, sets and error and return */ #define CHECK_LIMIT_ERROR(sz) \ if ( (self->b_position + sz) > self->b_limit ) { \ - PyErr_SetString(HotbufOverflow, \ + PyErr_SetString(BoundaryError, \ "attempted read beyond buffer limit"); \ return NULL; \ } @@ -635,7 +635,7 @@ Extract a string of 'nbytes' bytes from the buffer and advance the\n\ position accordingly. If 'nbytes' is not specified, get the string\n\ up to the limit.\n\ -An HotbufOverflow is raised if the position is at the end of the buffer."); +An BoundaryError is raised if the position is at the end of the buffer."); static PyObject* hotbuf_getstr(PyHotbufObject *self, PyObject* args) @@ -677,7 +677,7 @@ \n\ Write a string of 'nbytes' bytes from the buffer and advance the \n\ position accordingly.\n\ -An HotbufOverflow is raised if the position is at the end of the buffer."); +An BoundaryError is raised if the position is at the end of the buffer."); static PyObject* hotbuf_putstr(PyHotbufObject *self, PyObject* arg) @@ -925,7 +925,7 @@ return -1; if (newposition > self->b_capacity) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "position must be smaller than capacity"); return -1; } @@ -952,7 +952,7 @@ return -1; if (newlimit > self->b_capacity) { - PyErr_SetString(HotbufOverflow, + PyErr_SetString(BoundaryError, "limit must be smaller than capacity"); return -1; } @@ -1116,13 +1116,13 @@ if (PyType_Ready(&PyHotbuf_Type) < 0) return; - if (HotbufOverflow == NULL) { - HotbufOverflow = PyErr_NewException("hotbuf.HotbufOverflow", NULL, NULL); - if (HotbufOverflow == NULL) + if (BoundaryError == NULL) { + BoundaryError = PyErr_NewException("hotbuf.BoundaryError", NULL, NULL); + if (BoundaryError == NULL) return; } - Py_INCREF(HotbufOverflow); - PyModule_AddObject(m, "HotbufOverflow", HotbufOverflow); + Py_INCREF(BoundaryError); + PyModule_AddObject(m, "BoundaryError", BoundaryError); Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Py_INCREF((PyObject *)&PyHotbuf_Type); Modified: sandbox/trunk/hotbuffer/hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/hotbuf.py (original) +++ sandbox/trunk/hotbuffer/hotbuf.py Fri May 26 21:22:19 2006 @@ -4,7 +4,7 @@ A buffer class for fast I/O. """ -from _hotbuf import _hotbuf, HotbufOverflow +from _hotbuf import _hotbuf, BoundaryError from struct import Struct _long = Struct('l') @@ -15,5 +15,8 @@ """ Pack using the given Struct object 'structobj', the remaining arguments. """ + size = structobj.size + if size > len(self): + raise BoundaryError("attempted to write beyond buffer limit") structobj.pack_to(self, 0, *values) - self.advance(structobj.size) + self.advance(size) Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 21:22:19 2006 @@ -6,7 +6,7 @@ # Licensed to PSF under a Contributor Agreement. # -from hotbuf import hotbuf, HotbufOverflow +from hotbuf import hotbuf, BoundaryError from struct import Struct import unittest from test import test_support @@ -32,18 +32,18 @@ assert b.position == 0 b.setposition(10) self.assertEquals(b.position, 10) - self.assertRaises(HotbufOverflow, b.setposition, CAPACITY + 1) + self.assertRaises(BoundaryError, b.setposition, CAPACITY + 1) # Play with the limit assert b.limit == CAPACITY b.setlimit(CAPACITY - 10) self.assertEquals(b.limit, CAPACITY - 10) - self.assertRaises(HotbufOverflow, b.setlimit, CAPACITY + 1) + self.assertRaises(BoundaryError, b.setlimit, CAPACITY + 1) b.setlimit(b.position - 1) self.assertEquals(b.position, b.limit) # Play with reset before the mark has been set. - self.assertRaises(HotbufOverflow, b.setlimit, CAPACITY + 1) + self.assertRaises(BoundaryError, b.setlimit, CAPACITY + 1) # Play with the mark b.setposition(10) @@ -83,7 +83,7 @@ b.advance(32) self.assertEquals(b.position, 42) - self.assertRaises(HotbufOverflow, b.advance, CAPACITY) + self.assertRaises(BoundaryError, b.advance, CAPACITY) # Play with setwindow() b.clear() @@ -121,7 +121,7 @@ b.putbyte(x) # Test overflow. - self.assertRaises(HotbufOverflow, b.putbyte, 42) + self.assertRaises(BoundaryError, b.putbyte, 42) # Read all data from the buffer. b.flip() @@ -130,7 +130,7 @@ assert nx == x # Test underflow. - self.assertRaises(HotbufOverflow, b.putbyte, 42) + self.assertRaises(BoundaryError, b.putbyte, 42) def test_str( self ): b = hotbuf(256) @@ -144,10 +144,10 @@ # Test overflow. b.flip() - self.assertRaises(HotbufOverflow, b.putstr, ' ' * 1000) + self.assertRaises(BoundaryError, b.putstr, ' ' * 1000) # Test underflow. - self.assertRaises(HotbufOverflow, b.getstr, 1000) + self.assertRaises(BoundaryError, b.getstr, 1000) # Test getting the rest of the string. b.clear() From python-checkins at python.org Fri May 26 21:23:22 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 21:23:22 +0200 (CEST) Subject: [Python-checkins] r46397 - python/trunk/Lib/UserString.py Message-ID: <20060526192322.0145D1E4006@bag.python.org> Author: fredrik.lundh Date: Fri May 26 21:23:21 2006 New Revision: 46397 Modified: python/trunk/Lib/UserString.py Log: added rpartition method to UserString class Modified: python/trunk/Lib/UserString.py ============================================================================== --- python/trunk/Lib/UserString.py (original) +++ python/trunk/Lib/UserString.py Fri May 26 21:23:21 2006 @@ -102,7 +102,8 @@ return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) - def partition(self, sep): return self.data.partition(sep) + def partition(self, sep): + return self.data.partition(sep) def replace(self, old, new, maxsplit=-1): return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=sys.maxint): @@ -111,6 +112,8 @@ return self.data.rindex(sub, start, end) def rjust(self, width, *args): return self.__class__(self.data.rjust(width, *args)) + def rpartition(self, sep): + return self.data.rpartition(sep) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=-1): return self.data.split(sep, maxsplit) From buildbot at python.org Fri May 26 21:24:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 19:24:00 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060526192400.AA4101E401A@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/781 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,fredrik.lundh,steve.holden Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 21:24:54 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 21:24:54 +0200 (CEST) Subject: [Python-checkins] r46398 - in python/trunk/Objects: stringlib/count.h stringlib/find.h stringlib/partition.h stringobject.c unicodeobject.c Message-ID: <20060526192454.BD5CF1E4006@bag.python.org> Author: fredrik.lundh Date: Fri May 26 21:24:53 2006 New Revision: 46398 Added: python/trunk/Objects/stringlib/count.h (contents, props changed) python/trunk/Objects/stringlib/find.h (contents, props changed) Modified: python/trunk/Objects/stringlib/partition.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring, continued. added count and find helpers; updated unicodeobject to use stringlib_count Added: python/trunk/Objects/stringlib/count.h ============================================================================== --- (empty file) +++ python/trunk/Objects/stringlib/count.h Fri May 26 21:24:53 2006 @@ -0,0 +1,34 @@ +/* stringlib: count implementation */ + +#ifndef STRINGLIB_COUNT_H +#define STRINGLIB_COUNT_H + +#ifndef STRINGLIB_FASTSEARCH_H +#error must include "stringlib/fastsearch.h" before including this module +#endif + +Py_LOCAL(Py_ssize_t) +stringlib_count(const STRINGLIB_CHAR* str, Py_ssize_t str_len, + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) +{ + Py_ssize_t count; + + if (sub_len == 0) + return str_len + 1; + + count = fastsearch(str, str_len, sub, sub_len, FAST_COUNT); + + if (count < 0) + count = 0; /* no match */ + + return count; +} + +#endif + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Added: python/trunk/Objects/stringlib/find.h ============================================================================== --- (empty file) +++ python/trunk/Objects/stringlib/find.h Fri May 26 21:24:53 2006 @@ -0,0 +1,49 @@ +/* stringlib: find/index implementation */ + +#ifndef STRINGLIB_FIND_H +#define STRINGLIB_FIND_H + +#ifndef STRINGLIB_FASTSEARCH_H +#error must include "stringlib/fastsearch.h" before including this module +#endif + +Py_LOCAL(Py_ssize_t) +stringlib_find(const STRINGLIB_CHAR* str, Py_ssize_t str_len, + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) +{ + if (sub_len == 0) + return 0; + + return fastsearch(str, str_len, sub, sub_len, FAST_SEARCH); +} + +Py_LOCAL(Py_ssize_t) +stringlib_rfind(const STRINGLIB_CHAR* str, Py_ssize_t str_len, + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) +{ + Py_ssize_t pos; + + /* XXX - create reversefastsearch helper! */ + if (sub_len == 0) + pos = str_len; + else { + Py_ssize_t j; + pos = -1; + for (j = str_len - sub_len; j >= 0; --j) + if (STRINGLIB_CMP(str+j, sub, sub_len) == 0) { + pos = j; + break; + } + } + + return pos; +} + +#endif + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Fri May 26 21:24:53 2006 @@ -3,9 +3,15 @@ #ifndef STRINGLIB_PARTITION_H #define STRINGLIB_PARTITION_H +#ifndef STRINGLIB_FASTSEARCH_H +#error must include "stringlib/fastsearch.h" before including this module +#endif + Py_LOCAL(PyObject*) -partition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, - PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) +stringlib_partition( + PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, + PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len + ) { PyObject* out; Py_ssize_t pos; @@ -46,8 +52,10 @@ } Py_LOCAL(PyObject*) -rpartition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, - PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) +stringlib_rpartition( + PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, + PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len + ) { PyObject* out; Py_ssize_t pos; Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 21:24:53 2006 @@ -1548,7 +1548,7 @@ else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; - return partition( + return stringlib_partition( (PyObject*) self, PyString_AS_STRING(self), PyString_GET_SIZE(self), sep_obj, sep, sep_len @@ -1579,7 +1579,7 @@ else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; - return rpartition( + return stringlib_rpartition( (PyObject*) self, PyString_AS_STRING(self), PyString_GET_SIZE(self), sep_obj, sep, sep_len Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 21:24:53 2006 @@ -3869,63 +3869,47 @@ #define STRINGLIB_EMPTY unicode_empty #include "stringlib/fastsearch.h" -#include "stringlib/partition.h" +#include "stringlib/count.h" +#include "stringlib/find.h" +#include "stringlib/partition.h" -Py_LOCAL(Py_ssize_t) count(PyUnicodeObject *self, +Py_ssize_t PyUnicode_Count(PyObject *str, + PyObject *substr, Py_ssize_t start, - Py_ssize_t end, - PyUnicodeObject *substring) + Py_ssize_t end) { - Py_ssize_t count = 0; + Py_ssize_t result; + PyUnicodeObject* str_obj; + PyUnicodeObject* sub_obj; + + str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str); + if (!str_obj) + return -1; + sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); + if (!sub_obj) { + Py_DECREF(str_obj); + return -1; + } if (start < 0) - start += self->length; + start += str_obj->length; if (start < 0) start = 0; - if (end > self->length) - end = self->length; + if (end > str_obj->length) + end = str_obj->length; if (end < 0) - end += self->length; + end += str_obj->length; if (end < 0) end = 0; - if (substring->length == 0) - return (end - start + 1); - - count = fastsearch( - PyUnicode_AS_UNICODE(self) + start, end - start, - substring->str, substring->length, FAST_COUNT + result = stringlib_count( + str_obj->str + start, end - start, sub_obj->str, sub_obj->length ); - if (count < 0) - count = 0; /* no match */ - - return count; -} - -Py_ssize_t PyUnicode_Count(PyObject *str, - PyObject *substr, - Py_ssize_t start, - Py_ssize_t end) -{ - Py_ssize_t result; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return -1; - substr = PyUnicode_FromObject(substr); - if (substr == NULL) { - Py_DECREF(str); - return -1; - } - - result = count((PyUnicodeObject *)str, - start, end, - (PyUnicodeObject *)substr); + Py_DECREF(sub_obj); + Py_DECREF(str_obj); - Py_DECREF(str); - Py_DECREF(substr); return result; } @@ -4767,7 +4751,7 @@ Py_UNICODE *p; /* replace strings */ - n = count(self, 0, self->length, str1); + n = stringlib_count(self->str, self->length, str1->str, str1->length); if (n > maxcount) n = maxcount; if (n == 0) @@ -5162,7 +5146,7 @@ return NULL; substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); + (PyObject *)substring); if (substring == NULL) return NULL; @@ -5177,9 +5161,13 @@ if (end < 0) end = 0; - result = PyInt_FromSsize_t(count(self, start, end, substring)); + result = PyInt_FromSsize_t( + stringlib_count(self->str + start, end - start, + substring->str, substring->length) + ); Py_DECREF(substring); + return result; } @@ -6222,7 +6210,7 @@ return NULL; } - out = partition( + out = stringlib_partition( str_obj, PyUnicode_AS_UNICODE(str_obj), PyUnicode_GET_SIZE(str_obj), sep_obj, PyUnicode_AS_UNICODE(sep_obj), PyUnicode_GET_SIZE(sep_obj) ); @@ -6250,7 +6238,7 @@ return NULL; } - out = rpartition( + out = stringlib_rpartition( str_obj, PyUnicode_AS_UNICODE(str_obj), PyUnicode_GET_SIZE(str_obj), sep_obj, PyUnicode_AS_UNICODE(sep_obj), PyUnicode_GET_SIZE(sep_obj) ); From python-checkins at python.org Fri May 26 21:25:58 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 21:25:58 +0200 (CEST) Subject: [Python-checkins] r46399 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060526192558.78E521E4006@bag.python.org> Author: martin.blais Date: Fri May 26 21:25:58 2006 New Revision: 46399 Modified: sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Added tests for nonzero and restore Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Fri May 26 21:25:58 2006 @@ -14,17 +14,18 @@ .. 1 TODO 1.1 Features - 1.2 Document - 1.3 Convert from ASCII formats + 1.2 Ideas + 1.3 Document + 1.4 Convert from ASCII formats 2 Notes on the Java NIO / ByteBuffer TODO ==== -* Run oprofile on the code +* Make push() and pop() instead of save() and restore() -* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC +* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC * We need to make the client more easily remove the calls to remaining() @@ -40,6 +41,8 @@ * Add restore() to the tests. +* Implement pack() in C + * Change the mark, this will make the loop easier to understand * setmark() to save both the position and limit @@ -61,7 +64,19 @@ * Add with protocol for guards +Ideas +----- + +- (From Bob): Automatically do the compact-and-read when something hits the + limit of the buffer. To discriminate between coding errors (i.e. a message + parsing much more than it should) and hitting the end of the file, different + exceptions would be needed. + +- Write the loop in C, compacting and windowing as you go, calling a function to + process for each message. + + Document -------- Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 21:25:58 2006 @@ -52,6 +52,16 @@ b.setposition(15) self.assertEquals(b.mark_position, 10) + # Play with restore + b.setposition(10) + b.setlimit(100) + b.save() + b.setposition(0) + b.setlimit(b.capacity) + b.restore() + self.assertEquals((b.position, b.limit), + (10, 100)) + # Play with clear b.clear() self.assertEquals((b.position, b.limit, b.mark_position), @@ -277,12 +287,16 @@ self.assertEquals(b.find('d'), 2) self.assertEquals(b.find('1' * 100), -1) + def test_nonzero(self): + b = hotbuf(CAPACITY) + self.assertEquals(bool(b), True) + b.setposition(b.limit) + self.assertEquals(bool(b), False) + + def test_main(): test_support.run_unittest(HotbufTestCase) if __name__ == "__main__": test_main() - - -## FIXME TODO add restore() in test. From python-checkins at python.org Fri May 26 21:29:06 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 21:29:06 +0200 (CEST) Subject: [Python-checkins] r46400 - python/trunk/Objects/unicodeobject.c Message-ID: <20060526192906.07B471E4006@bag.python.org> Author: fredrik.lundh Date: Fri May 26 21:29:05 2006 New Revision: 46400 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring: use stringlib/find for unicode find Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 21:29:05 2006 @@ -3951,27 +3951,49 @@ } Py_ssize_t PyUnicode_Find(PyObject *str, - PyObject *substr, - Py_ssize_t start, - Py_ssize_t end, - int direction) + PyObject *substr, + Py_ssize_t start, + Py_ssize_t end, + int direction) { Py_ssize_t result; + PyUnicodeObject* str_obj; + PyUnicodeObject* sub_obj; - str = PyUnicode_FromObject(str); - if (str == NULL) + str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str); + if (!str) return -2; - substr = PyUnicode_FromObject(substr); - if (substr == NULL) { - Py_DECREF(str); + sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); + if (!sub_obj) { + Py_DECREF(str_obj); return -2; } - result = findstring((PyUnicodeObject *)str, - (PyUnicodeObject *)substr, - start, end, direction); - Py_DECREF(str); - Py_DECREF(substr); + if (start < 0) + start += str_obj->length; + if (start < 0) + start = 0; + if (end > str_obj->length) + end = str_obj->length; + if (end < 0) + end += str_obj->length; + if (end < 0) + end = 0; + + if (direction > 0) + result = stringlib_find( + str_obj->str + start, end - start, sub_obj->str, sub_obj->length + ); + else + result = stringlib_rfind( + str_obj->str + start, end - start, sub_obj->str, sub_obj->length + ); + + if (result >= 0) + result += start; + + Py_DECREF(str_obj); + Py_DECREF(sub_obj); return result; } From python-checkins at python.org Fri May 26 21:29:45 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 21:29:45 +0200 (CEST) Subject: [Python-checkins] r46401 - in python/branches/sreifschneider-newnewexcept: Objects/exceptions.c PCbuild/pythoncore.vcproj Python/errors.c Python/pythonrun.c Message-ID: <20060526192945.AE33B1E4006@bag.python.org> Author: tim.peters Date: Fri May 26 21:29:45 2006 New Revision: 46401 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c python/branches/sreifschneider-newnewexcept/PCbuild/pythoncore.vcproj python/branches/sreifschneider-newnewexcept/Python/errors.c python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Log: Some fixes to help this work on Windows. Not there yet. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 21:29:45 2006 @@ -778,14 +778,14 @@ Py_VISIT(self->strerror); Py_VISIT(self->filename); Py_VISIT(self->winerror); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg) + return BaseException_traverse((BaseExceptionObject *)self, visit, arg); } static PyObject * WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *o_errcode = NULL; - PyObject *errcode = NULL; + long errcode; WindowsErrorObject *self = NULL; long posix_errno; @@ -808,7 +808,7 @@ self->myerrno = o_errcode; - return self; + return (PyObject *)self; failed: /* Could not set errno. */ Py_XDECREF(o_errcode); @@ -820,7 +820,8 @@ WindowsError_init(WindowsErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *o_errcode = NULL; - PyObject *errcode = NULL; + long errcode; + long posix_errno; if (EnvironmentError_init((EnvironmentErrorObject *)self, args, kwds) == -1) return -1; @@ -835,20 +836,17 @@ self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) { - Py_DECREF(errcode); + if (!o_errcode) return -1; - } self->myerrno = o_errcode; - Py_DECREF(errcode); return 0; } static PyObject * -WindowsError_str(PyObject *self) +WindowsError_str(WindowsErrorObject *self) { PyObject *repr = NULL; PyObject *fmt = NULL; @@ -882,13 +880,9 @@ Py_DECREF(tuple); } else - rtnval = EnvironmentError_str(self); + rtnval = EnvironmentError_str((EnvironmentErrorObject *)self); finally: - /* GB: where is filename, serrno and strerror declared? */ - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); Py_XDECREF(repr); Py_XDECREF(fmt); Py_XDECREF(tuple); @@ -909,7 +903,14 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, EnvironmentError_dealloc, WindowsError_members, WindowsError_str, "MS-Windows OS system call failed."); +ComplexExtendsException(PyExc_OSError, + WindowsError, + WindowsError, + WindowsError_dealloc, + WindowsError_members, + WindowsError_str, + "MS-Windows OS system call failed.", + 1); #endif /* MS_WINDOWS */ Modified: python/branches/sreifschneider-newnewexcept/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/sreifschneider-newnewexcept/PCbuild/pythoncore.vcproj (original) +++ python/branches/sreifschneider-newnewexcept/PCbuild/pythoncore.vcproj Fri May 26 21:29:45 2006 @@ -494,7 +494,7 @@ RelativePath="..\Python\errors.c"> + RelativePath="..\Objects\exceptions.c"> Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/errors.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/errors.c Fri May 26 21:29:45 2006 @@ -589,11 +589,11 @@ PyFile_WriteString("Exception ", f); if (t) { char* className = PyExceptionClass_Name(t); + PyObject* moduleName; char *dot = strrchr(className, '.'); if (dot != NULL) className = dot+1; - PyObject* moduleName = - PyObject_GetAttrString(t, "__module__"); + moduleName = PyObject_GetAttrString(t, "__module__"); if (moduleName == NULL) PyFile_WriteString("", f); Modified: python/branches/sreifschneider-newnewexcept/Python/pythonrun.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/pythonrun.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/pythonrun.c Fri May 26 21:29:45 2006 @@ -1134,10 +1134,10 @@ else if (PyExceptionClass_Check(exception)) { char* className = PyExceptionClass_Name(exception); char *dot = strrchr(className, '.'); + PyObject* moduleName; if (dot != NULL) className = dot+1; - PyObject* moduleName = - PyObject_GetAttrString(exception, "__module__"); + moduleName = PyObject_GetAttrString(exception, "__module__"); if (moduleName == NULL) err = PyFile_WriteString("", f); From python-checkins at python.org Fri May 26 21:30:54 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 21:30:54 +0200 (CEST) Subject: [Python-checkins] r46402 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c Message-ID: <20060526193054.D8C221E400E@bag.python.org> Author: bob.ippolito Date: Fri May 26 21:30:54 2006 New Revision: 46402 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Log: python 2.4 fix Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 21:30:54 2006 @@ -20,9 +20,7 @@ #define writebufferproc getwritebufferproc #define charbufferproc getcharbufferproc #define segcountproc getsegcountproc -#ifndef Py_LOCAL(rval) -#define Py_LOCAL static rval -#endif +#define Py_LOCAL(type) static type #endif #define STRINGLIB_CHAR char From python-checkins at python.org Fri May 26 21:33:03 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 21:33:03 +0200 (CEST) Subject: [Python-checkins] r46403 - python/trunk/Objects/unicodeobject.c Message-ID: <20060526193303.B257A1E4006@bag.python.org> Author: fredrik.lundh Date: Fri May 26 21:33:03 2006 New Revision: 46403 Modified: python/trunk/Objects/unicodeobject.c Log: needforspeed: use a macro to fix slice indexes Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 21:33:03 2006 @@ -3874,6 +3874,19 @@ #include "stringlib/find.h" #include "stringlib/partition.h" +/* helper macro to fixup start/end slice values */ +#define FIX_START_END(obj) \ + if (start < 0) \ + start += (obj)->length; \ + if (start < 0) \ + start = 0; \ + if (end > (obj)->length) \ + end = (obj)->length; \ + if (end < 0) \ + end += (obj)->length; \ + if (end < 0) \ + end = 0; + Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, @@ -3892,16 +3905,7 @@ return -1; } - if (start < 0) - start += str_obj->length; - if (start < 0) - start = 0; - if (end > str_obj->length) - end = str_obj->length; - if (end < 0) - end += str_obj->length; - if (end < 0) - end = 0; + FIX_START_END(str_obj); result = stringlib_count( str_obj->str + start, end - start, sub_obj->str, sub_obj->length @@ -3919,17 +3923,7 @@ Py_ssize_t end, int direction) { - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; + FIX_START_END(self); if (substring->length == 0) return (direction > 0) ? start : end; @@ -3969,16 +3963,7 @@ return -2; } - if (start < 0) - start += str_obj->length; - if (start < 0) - start = 0; - if (end > str_obj->length) - end = str_obj->length; - if (end < 0) - end += str_obj->length; - if (end < 0) - end = 0; + FIX_START_END(str_obj); if (direction > 0) result = stringlib_find( @@ -4004,20 +3989,10 @@ Py_ssize_t end, int direction) { - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - if (substring->length == 0) return 1; - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; + FIX_START_END(self); end -= substring->length; if (end < start) @@ -5172,16 +5147,7 @@ if (substring == NULL) return NULL; - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; + FIX_START_END(self); result = PyInt_FromSsize_t( stringlib_count(self->str + start, end - start, From python-checkins at python.org Fri May 26 21:43:46 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 26 May 2006 21:43:46 +0200 (CEST) Subject: [Python-checkins] r46404 - python/trunk/Doc/lib/libctypesref.tex Message-ID: <20060526194346.92D3E1E4006@bag.python.org> Author: thomas.heller Date: Fri May 26 21:43:45 2006 New Revision: 46404 Modified: python/trunk/Doc/lib/libctypesref.tex Log: Write more docs. Modified: python/trunk/Doc/lib/libctypesref.tex ============================================================================== --- python/trunk/Doc/lib/libctypesref.tex (original) +++ python/trunk/Doc/lib/libctypesref.tex Fri May 26 21:43:45 2006 @@ -1,5 +1,6 @@ \subsection{ctypes reference\label{ctypes-reference}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % functions \subsubsection{ctypes functions} @@ -14,6 +15,8 @@ \end{funcdesc} \begin{excclassdesc}{ArgumentError}{} +This exception is raised when a foreign function call cannot convert +one of the passed arguments. \end{excclassdesc} \begin{funcdesc}{byref}{obj} @@ -24,9 +27,33 @@ \end{funcdesc} \begin{funcdesc}{cast}{obj, type} +This function is similar to the cast operator in C. It returns a new +instance of \var{type} which points to the same memory block as +\code{obj}. \code{type} must be a pointer type, and \code{obj} + must be an object that can be interpreted as a pointer. \end{funcdesc} +% XXX separate section for CFUNCTYPE, WINFUNCTYPE, PYFUNCTYPE? + \begin{funcdesc}{CFUNCTYPE}{restype, *argtypes} +This is a factory function that returns a function prototype. The +function prototype describes a function that has a result type of +\code{restype}, and accepts arguments as specified by \code{argtypes}. +The function prototype can be used to construct several kinds of +functions, depending on how the prototype is called. + +The prototypes returned by \code{CFUNCTYPE} or \code{PYFUNCTYPE} +create functions that use the standard C calling convention, +prototypes returned from \code{WINFUNCTYPE} (on Windows) use the +\code{__stdcall} calling convention. + +Functions created by calling the \code{CFUNCTYPE} and +\code{WINFUNCTYPE} prototypes release the Python GIL +before entering the foreign function, and acquire it back after +leaving the function code. + +% XXX differences between CFUNCTYPE / WINFUNCTYPE / PYFUNCTYPE + \end{funcdesc} \begin{funcdesc}{create_string_buffer}{init_or_size\optional{, size}} @@ -67,35 +94,52 @@ \begin{funcdesc}{DllCanUnloadNow}{} Windows only: This function is a hook which allows to implement inprocess COM servers with ctypes. It is called from the -\code{DllCanUnloadNow} exported function that the \code{_ctypes} -extension module exports. +\code{DllCanUnloadNow} function that the \code{_ctypes} +extension dll exports. \end{funcdesc} \begin{funcdesc}{DllGetClassObject}{} Windows only: This function is a hook which allows to implement inprocess COM servers with ctypes. It is called from the -\code{DllGetClassObject} exported function that the \code{_ctypes} -extension module exports. +\code{DllGetClassObject} function that the \code{_ctypes} +extension dll exports. \end{funcdesc} -\begin{funcdesc}{FormatError}{} -Windows only: +\begin{funcdesc}{FormatError}{\optional{code}} +Windows only: Returns a textual description of the error code. If no +error code is specified, the last error code is used by calling the +Windows api function \code{GetLastError}. \end{funcdesc} \begin{funcdesc}{GetLastError}{} -Windows only: +Windows only: Returns the last error code set by Windows in the +calling thread. \end{funcdesc} \begin{funcdesc}{memmove}{dst, src, count} +Same as the standard C \code{memmove} library function: copies +\var{count} bytes from \code{src} to \code{dst}. \code{dst} and +\code{src} must be integers or ctypes instances that can be converted to pointers. \end{funcdesc} \begin{funcdesc}{memset}{dst, c, count} +Same as the standard C \code{memset} library function: fills the +memory clock at address \code{dst} with \var{count} bytes of value +\var{c}. \var{dst} must be an integer specifying an address, or a ctypes instance. \end{funcdesc} -\begin{funcdesc}{POINTER}{} +\begin{funcdesc}{POINTER}{type} +This factory function creates and returns a new ctypes pointer type. +Pointer types are cached an reused internally, so calling this +function repeatedly is cheap. \var{type} must be a ctypes type. \end{funcdesc} -\begin{funcdesc}{pointer}{} +\begin{funcdesc}{pointer}{obj} +This function creates a new pointer instance, pointing to \var{obj}. +The returned object is of the type \code{POINTER(type(obj))}. + +Note: If you just want to pass a pointer to an object to a foreign +function call, you should use \code{byref(obj)} which is much faster. \end{funcdesc} \begin{funcdesc}{PYFUNCTYPE}{restype, *argtypes} @@ -104,27 +148,56 @@ \begin{funcdesc}{pythonapi}{} \end{funcdesc} -\begin{funcdesc}{resize}{} -\end{funcdesc} - -\begin{funcdesc}{set_conversion_mode}{} -\end{funcdesc} - -\begin{funcdesc}{sizeof}{} -\end{funcdesc} - -\begin{funcdesc}{string_at}{address} -\end{funcdesc} - -\begin{funcdesc}{WinError}{} +\begin{funcdesc}{resize}{obj, size} +This function resizes the internal memory buffer of \var{obj}, which +must be an instance of a ctypes type. It is not possible to make the +buffer smaller than the native size of the objects type, as given by +\code{sizeof(type(obj))}, but it is possible to enlarge the buffer. +\end{funcdesc} + +\begin{funcdesc}{set_conversion_mode}{encoding, errors} +This function sets the rules that ctypes objects use when converting +between 8-bit strings and unicode strings. \var{encoding} must be a +string specifying an encoding, like 'utf-8' or 'mbcs', \var{errors} +must be a string specifying the error handling on encoding/decoding +errors. Examples of possible values are ``strict'', ``replace'', or +``ignore''. + +\code{set_conversion_mode} returns a 2-tuple containing the previous +conversion rules. On windows, the initial conversion rules are +\code{('mbcs', 'ignore')}, on other systems \code{('ascii', 'strict')}. +\end{funcdesc} + +\begin{funcdesc}{sizeof}{obj_or_type} +Returns the size in bytes of a ctypes type or instance memory buffer. +Does the same as the C sizeof() function. +\end{funcdesc} + +\begin{funcdesc}{string_at}{address\optional{size}} +This function returns the string starting at memory address +\var{address}. If \var{size} is specified, it is used as size, +otherwise the string is assumed to be zero-terminated. +\end{funcdesc} + +\begin{funcdesc}{WinError}{code=None, descr=None} +Windows only: this function is probably the worst-named thing in +ctypes. It creates an instance of \code{WindowsError}. If \var{code} +is not specified, \code{GetLastError} is called to determine the error +code. If \var{descr} is not spcified, \var{FormatError} is called to +get a textual description of the error. \end{funcdesc} \begin{funcdesc}{WINFUNCTYPE}{restype, *argtypes} \end{funcdesc} \begin{funcdesc}{wstring_at}{address} +This function returns the wide character string starting at memory +address \var{address} as unicode string. If \var{size} is specified, +it is used as size, otherwise the string is assumed to be +zero-terminated. \end{funcdesc} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % data types \subsubsection{data types} @@ -132,9 +205,47 @@ define your own types. Among other things, a ctypes type instance holds a memory block that contains C compatible data. +\begin{classdesc}{_ctypes._CData}{} +This non-public class is the base class of all ctypes data types. It +is mentioned here because it contains the common methods of the ctypes +data types. +\end{classdesc} + +Common methods of ctypes data types, these are all class methods (to +be exact, they are methods of the metaclass): + +\begin{methoddesc}{from_address}{address} +This method returns a ctypes type instance using the memory specified +by \code{address}. +\end{methoddesc} + +\begin{methoddesc}{from_param}{obj} +This method adapts \code{obj} to a ctypes type. +\end{methoddesc} + +\begin{methoddesc}{in_dll}{name, library} +This method returns a ctypes type instance exported by a shared +library. \var{name} is the name of the symbol that exports the data, +\var{library} is the loaded shared library. +\end{methoddesc} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % simple data types \subsubsection{simple data types} +\begin{classdesc}{_ctypes._SimpleCData}{} +This non-public class is the base class of all ctypes data types. It +is mentioned here because it contains the common attributes of the +ctypes data types. +\end{classdesc} + +\begin{memberdesc}{value} +This attribute contains the actual value of the instance. For integer +types, it is an integer. +\end{memberdesc} + +Here are the simple ctypes data types: + \begin{classdesc}{c_byte}{\optional{value}} Represents a C \code{signed char} datatype, and interprets the value as small integer. The constructor accepts an optional integer @@ -148,6 +259,10 @@ \end{classdesc} \begin{classdesc}{c_char_p}{\optional{value}} +Represents a C \code{char *} datatype, which must be a pointer to a +zero-terminated string. The constructor accepts an integer address, +or a string. +% XXX Explain the difference to POINTER(c_char) \end{classdesc} \begin{classdesc}{c_double}{\optional{value}} @@ -206,41 +321,78 @@ \end{classdesc} \begin{classdesc}{c_ubyte}{\optional{value}} +Represents a C \code{unsigned char} datatype, and interprets the value +as small integer. The constructor accepts an optional integer +initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_uint}{\optional{value}} +Represents a C \code{unsigned int} datatype. The constructor accepts +an optional integer initializer; no overflow checking is done. On +platforms where \code{sizeof(int) == sizeof(long)} \var{c_int} is an +alias to \var{c_long}. \end{classdesc} \begin{classdesc}{c_uint16}{\optional{value}} +Represents a C 16-bit \code{unsigned int} datatype. Usually an alias +for \code{c_ushort}. \end{classdesc} \begin{classdesc}{c_uint32}{\optional{value}} +Represents a C 32-bit \code{unsigned int} datatype. Usually an alias +for \code{c_uint}. \end{classdesc} \begin{classdesc}{c_uint64}{\optional{value}} +Represents a C 64-bit \code{unsigned int} datatype. Usually an alias +for \code{c_ulonglong}. \end{classdesc} \begin{classdesc}{c_uint8}{\optional{value}} +Represents a C 8-bit \code{unsigned int} datatype. Usually an alias +for \code{c_ubyte}. \end{classdesc} \begin{classdesc}{c_ulong}{\optional{value}} +Represents a C \code{unsigned long} datatype. The constructor accepts +an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_ulonglong}{\optional{value}} +Represents a C \code{unsigned long long} datatype. The constructor +accepts an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_ushort}{\optional{value}} +Represents a C \code{unsigned short} datatype. The constructor accepts +an optional integer initializer; no overflow checking is done. \end{classdesc} \begin{classdesc}{c_void_p}{\optional{value}} +Represents a C \code{void *} type. The value is represented as +integer. The constructor accepts an optional integer initializer. \end{classdesc} \begin{classdesc}{c_wchar}{\optional{value}} +Represents a C \code{wchar_t} datatype, and interprets the value as a +single character unicode string. The constructor accepts an optional +string initializer, the length of the string must be exactly one +character. \end{classdesc} \begin{classdesc}{c_wchar_p}{\optional{value}} +Represents a C \code{wchar_t *} datatype, which must be a pointer to a +zero-terminated wide character string. The constructor accepts an +integer address, or a string. +% XXX Explain the difference to POINTER(c_wchar) +\end{classdesc} + +\begin{classdesc}{HRESULT}{} +Windows only: Represents a \code{HRESULT} value, which contains +success or error information for a function or method call. \end{classdesc} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % structured data types \subsubsection{structured data types} @@ -251,12 +403,17 @@ \end{classdesc} \begin{classdesc}{Structure}{} +Base class for Structure data types. + \end{classdesc} \begin{classdesc}{Union}{} \end{classdesc} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% libraries +\subsubsection{libraries} \begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None} \end{classdesc} @@ -264,10 +421,11 @@ \begin{datadesc}{cdll} \end{datadesc} -\begin{classdesc}{HRESULT}{} -\end{classdesc} - \begin{classdesc}{LibraryLoader}{dlltype} + +\begin{memberdesc}{LoadLibrary}{name, mode=RTLD_LOCAL, handle=None} +\end{memberdesc} + \end{classdesc} \begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None} From python-checkins at python.org Fri May 26 21:44:27 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 21:44:27 +0200 (CEST) Subject: [Python-checkins] r46405 - in python/branches/sreifschneider-newnewexcept: Include/pyerrors.h Objects/exceptions.c Message-ID: <20060526194427.CECFD1E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 21:44:27 2006 New Revision: 46405 Modified: python/branches/sreifschneider-newnewexcept/Include/pyerrors.h python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Reformat and move structures to header file. Modified: python/branches/sreifschneider-newnewexcept/Include/pyerrors.h ============================================================================== --- python/branches/sreifschneider-newnewexcept/Include/pyerrors.h (original) +++ python/branches/sreifschneider-newnewexcept/Include/pyerrors.h Fri May 26 21:44:27 2006 @@ -4,6 +4,72 @@ extern "C" { #endif +/* Error objects */ + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; +PyObject *message; +} PyBaseExceptionObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +#ifdef Py_USING_UNICODE +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + PyObject *start; + PyObject *end; + PyObject *reason; +} PyUnicodeErrorObject; +#endif + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; +} PyEnvironmentErrorObject; + +#ifdef MS_WINDOWS +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; +} PyWindowsErrorObject; +#endif /* Error handling definitions */ Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 21:44:27 2006 @@ -9,19 +9,12 @@ /* * BaseException */ -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; -} BaseExceptionObject; - static PyObject * BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - BaseExceptionObject *self; + PyBaseExceptionObject *self; - self = (BaseExceptionObject *)type->tp_alloc(type, 0); + self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); self->args = self->message = self->dict = NULL; self->args = PyTuple_New(0); @@ -43,7 +36,7 @@ } static int -BaseException_init(BaseExceptionObject *self, PyObject *args, PyObject *kwds) +BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) { if (args) { Py_DECREF(self->args); @@ -59,7 +52,7 @@ } int -BaseException_clear(BaseExceptionObject *self) +BaseException_clear(PyBaseExceptionObject *self) { Py_CLEAR(self->dict); Py_CLEAR(self->args); @@ -68,14 +61,14 @@ } static void -BaseException_dealloc(BaseExceptionObject *self) +BaseException_dealloc(PyBaseExceptionObject *self) { BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } int -BaseException_traverse(BaseExceptionObject *self, visitproc visit, void *arg) +BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg) { if (self->dict) Py_VISIT(self->dict); @@ -85,7 +78,7 @@ } static PyObject * -BaseException_str(BaseExceptionObject *self) +BaseException_str(PyBaseExceptionObject *self) { PyObject *out; @@ -116,7 +109,7 @@ } static PyObject * -BaseException_repr(BaseExceptionObject *self) +BaseException_repr(PyBaseExceptionObject *self) { Py_ssize_t args_len; PyObject *repr_suffix; @@ -157,7 +150,7 @@ /* Pickling support */ static PyObject * -BaseException_reduce(BaseExceptionObject *self) +BaseException_reduce(PyBaseExceptionObject *self) { return PyTuple_Pack(3, self->ob_type, self->args, self->dict); } @@ -168,7 +161,7 @@ * guarantees that we can display exceptions that have unicode attributes */ static PyObject * -BaseException_unicode(BaseExceptionObject *self) +BaseException_unicode(PyBaseExceptionObject *self) { if (PySequence_Length(self->args) == 0) return PyUnicode_FromUnicode(NULL, 0); @@ -197,7 +190,7 @@ static PyObject * -BaseException_getitem(BaseExceptionObject *self, Py_ssize_t index) +BaseException_getitem(PyBaseExceptionObject *self, Py_ssize_t index) { return PySequence_GetItem(self->args, index); } @@ -216,14 +209,14 @@ }; static PyMemberDef BaseException_members[] = { - {"message", T_OBJECT, offsetof(BaseExceptionObject, message), 0, + {"message", T_OBJECT, offsetof(PyBaseExceptionObject, message), 0, PyDoc_STR("exception message")}, {NULL} /* Sentinel */ }; static PyObject * -BaseException_get_dict(BaseExceptionObject *self) +BaseException_get_dict(PyBaseExceptionObject *self) { if (self->dict == NULL) { self->dict = PyDict_New(); @@ -235,7 +228,7 @@ } static int -BaseException_set_dict(BaseExceptionObject *self, PyObject *val) +BaseException_set_dict(PyBaseExceptionObject *self, PyObject *val) { if (val == NULL) { PyErr_SetString(PyExc_TypeError, "__dict__ may not be deleted"); @@ -252,7 +245,7 @@ } static PyObject * -BaseException_get_args(BaseExceptionObject *self) +BaseException_get_args(PyBaseExceptionObject *self) { if (self->args == NULL) { Py_INCREF(Py_None); @@ -263,7 +256,7 @@ } static int -BaseException_set_args(BaseExceptionObject *self, PyObject *val) +BaseException_set_args(PyBaseExceptionObject *self, PyObject *val) { PyObject *seq; if (val == NULL) { @@ -287,7 +280,7 @@ PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ EXC_MODULE_NAME "BaseException", /*tp_name*/ - sizeof(BaseExceptionObject), /*tp_basicsize*/ + sizeof(PyBaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)BaseException_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ @@ -319,7 +312,7 @@ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BaseExceptionObject, dict), /* tp_dictoffset */ + offsetof(PyBaseExceptionObject, dict), /* tp_dictoffset */ (initproc)BaseException_init, /* tp_init */ 0, /* tp_alloc */ BaseException_new, /* tp_new */ @@ -334,13 +327,13 @@ PyObject_HEAD_INIT(NULL) \ 0, \ EXC_MODULE_NAME # EXCNAME, \ - sizeof(BaseExceptionObject), \ + sizeof(PyBaseExceptionObject), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, offsetof(BaseExceptionObject, dict), \ + 0, 0, 0, offsetof(PyBaseExceptionObject, dict), \ (initproc)BaseException_init, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -350,13 +343,13 @@ PyObject_HEAD_INIT(NULL) \ 0, \ EXC_MODULE_NAME # EXCNAME, \ - sizeof(EXCSTORE ## Object), \ + sizeof(Py ## EXCSTORE ## Object), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ - 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ + 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -366,14 +359,14 @@ PyObject_HEAD_INIT(NULL) \ 0, \ EXC_MODULE_NAME # EXCNAME, \ - sizeof(EXCSTORE ## Object), 0, \ + sizeof(Py ## EXCSTORE ## Object), 0, \ (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ (reprfunc)EXCSTR, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \ (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \ EXCMEMBERS, 0, &_ ## EXCBASE, \ - 0, 0, 0, offsetof(EXCSTORE ## Object, dict), \ + 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; @@ -382,7 +375,8 @@ /* * Exception extends BaseException */ -SimpleExtendsException(PyExc_BaseException, Exception, "Common base class for all non-exit exceptions.") +SimpleExtendsException(PyExc_BaseException, Exception, + "Common base class for all non-exit exceptions.") /* @@ -396,38 +390,33 @@ /* * TypeError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, TypeError, "Inappropriate argument type."); +SimpleExtendsException(PyExc_StandardError, TypeError, + "Inappropriate argument type."); /* * StopIteration extends Exception */ -SimpleExtendsException(PyExc_Exception, StopIteration, "Signal the end from iterator.next()."); +SimpleExtendsException(PyExc_Exception, StopIteration, + "Signal the end from iterator.next()."); /* * GeneratorExit extends Exception */ -SimpleExtendsException(PyExc_Exception, GeneratorExit, "Request that a generator exit."); +SimpleExtendsException(PyExc_Exception, GeneratorExit, + "Request that a generator exit."); /* * SystemExit extends BaseException */ -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *code; -} SystemExitObject; - static PyObject * SystemExit_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - SystemExitObject *self; + PySystemExitObject *self; - self = (SystemExitObject *)BaseException_new(type, args, kwds); + self = (PySystemExitObject *)BaseException_new(type, args, kwds); if (!self) return NULL; @@ -438,11 +427,11 @@ } static int -SystemExit_init(SystemExitObject *self, PyObject *args, PyObject *kwds) +SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) { Py_ssize_t size = PySequence_Length(args); - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; if (size == 1) { @@ -458,68 +447,62 @@ } int -SystemExit_clear(SystemExitObject *self) +SystemExit_clear(PySystemExitObject *self) { Py_CLEAR(self->code); - return BaseException_clear((BaseExceptionObject *)self); + return BaseException_clear((PyBaseExceptionObject *)self); } static void -SystemExit_dealloc(SystemExitObject *self) +SystemExit_dealloc(PySystemExitObject *self) { SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } int -SystemExit_traverse(SystemExitObject *self, visitproc visit, void *arg) +SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg) { Py_VISIT(self->code); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } static PyMemberDef SystemExit_members[] = { - {"message", T_OBJECT, offsetof(SystemExitObject, message), 0, + {"message", T_OBJECT, offsetof(PySystemExitObject, message), 0, PyDoc_STR("exception message")}, - {"code", T_OBJECT, offsetof(SystemExitObject, code), 0, + {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0, PyDoc_STR("exception code")}, {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, "Request to exit from the interpreter."); +ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, + SystemExit_dealloc, 0, SystemExit_members, 0, + "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException */ -SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, "Program interrupted by user."); +SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, + "Program interrupted by user."); /* * ImportError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, ImportError, "Import can't find module, or can't find name in module."); +SimpleExtendsException(PyExc_StandardError, ImportError, + "Import can't find module, or can't find name in module."); /* * EnvironmentError extends StandardError */ -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; -} EnvironmentErrorObject; - static PyObject * EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - EnvironmentErrorObject *self = NULL; + PyEnvironmentErrorObject *self = NULL; - self = (EnvironmentErrorObject *)BaseException_new(type, args, kwds); + self = (PyEnvironmentErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; @@ -545,13 +528,13 @@ * when it was supplied. */ static int -EnvironmentError_init(EnvironmentErrorObject *self, PyObject *args, +EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL; PyObject *subslice = NULL; - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; if (PySequence_Length(args) <= 1) { @@ -586,33 +569,33 @@ } int -EnvironmentError_clear(EnvironmentErrorObject *self) +EnvironmentError_clear(PyEnvironmentErrorObject *self) { Py_CLEAR(self->myerrno); Py_CLEAR(self->strerror); Py_CLEAR(self->filename); - return BaseException_clear((BaseExceptionObject *)self); + return BaseException_clear((PyBaseExceptionObject *)self); } static void -EnvironmentError_dealloc(EnvironmentErrorObject *self) +EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } int -EnvironmentError_traverse(EnvironmentErrorObject *self, visitproc visit, +EnvironmentError_traverse(PyEnvironmentErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->myerrno); Py_VISIT(self->strerror); Py_VISIT(self->filename); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } static PyObject * -EnvironmentError_str(EnvironmentErrorObject *self) +EnvironmentError_str(PyEnvironmentErrorObject *self) { PyObject *rtnval = NULL; @@ -660,33 +643,33 @@ Py_DECREF(tuple); } else - rtnval = BaseException_str((BaseExceptionObject *)self); + rtnval = BaseException_str((PyBaseExceptionObject *)self); return rtnval; } static PyMemberDef EnvironmentError_members[] = { - {"message", T_OBJECT, offsetof(EnvironmentErrorObject, message), 0, + {"message", T_OBJECT, offsetof(PyEnvironmentErrorObject, message), 0, PyDoc_STR("exception message")}, - {"errno", T_OBJECT, offsetof(EnvironmentErrorObject, myerrno), 0, + {"errno", T_OBJECT, offsetof(PyEnvironmentErrorObject, myerrno), 0, PyDoc_STR("exception code")}, - {"strerror", T_OBJECT, offsetof(EnvironmentErrorObject, strerror), 0, + {"strerror", T_OBJECT, offsetof(PyEnvironmentErrorObject, strerror), 0, PyDoc_STR("exception code")}, - {"filename", T_OBJECT, offsetof(EnvironmentErrorObject, filename), 0, + {"filename", T_OBJECT, offsetof(PyEnvironmentErrorObject, filename), 0, PyDoc_STR("exception code")}, {NULL} /* Sentinel */ }; static PyObject * -EnvironmentError_reduce(EnvironmentErrorObject *self) +EnvironmentError_reduce(PyEnvironmentErrorObject *self) { PyObject *args = self->args; PyObject *res = NULL, *tmp; /* self->args is only the first two real arguments if there was a * file name given to EnvironmentError. */ if (PyTuple_Check(args) && - PyTuple_GET_SIZE(args) == 2 && + PyTuple_GET_SIZE(args) == 2 && self->filename != Py_None) { args = PyTuple_New(3); @@ -719,22 +702,25 @@ {NULL} }; -ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, \ - EnvironmentError_dealloc, EnvironmentError_methods, \ - EnvironmentError_members, EnvironmentError_str, \ +ComplexExtendsException(PyExc_StandardError, EnvironmentError, + EnvironmentError, EnvironmentError_dealloc, + EnvironmentError_methods, EnvironmentError_members, + EnvironmentError_str, "Base class for I/O related errors."); /* * IOError extends EnvironmentError */ -MiddlingExtendsException(PyExc_EnvironmentError, IOError, EnvironmentError, "I/O operation failed."); +MiddlingExtendsException(PyExc_EnvironmentError, IOError, + EnvironmentError, "I/O operation failed."); /* * OSError extends EnvironmentError */ -MiddlingExtendsException(PyExc_EnvironmentError, OSError, EnvironmentError, "OS system call failed."); +MiddlingExtendsException(PyExc_EnvironmentError, OSError, + EnvironmentError, "OS system call failed."); /* @@ -743,42 +729,31 @@ #ifdef MS_WINDOWS #include "errmap.h" -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; - PyObject *winerror; -} WindowsErrorObject; - int -WindowsError_clear(WindowsErrorObject *self) +WindowsError_clear(PyWindowsErrorObject *self) { Py_CLEAR(self->myerrno); Py_CLEAR(self->strerror); Py_CLEAR(self->filename); Py_CLEAR(self->winerror); - return BaseException_clear((BaseExceptionObject *)self); + return BaseException_clear((PyBaseExceptionObject *)self); } static void -WindowsError_dealloc(WindowsErrorObject *self) +WindowsError_dealloc(PyWindowsErrorObject *self) { WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } int -WindowsError_traverse(WindowsErrorObject *self, visitproc visit, void *arg) +WindowsError_traverse(PyWindowsErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->myerrno); Py_VISIT(self->strerror); Py_VISIT(self->filename); Py_VISIT(self->winerror); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } static PyObject * @@ -786,10 +761,10 @@ { PyObject *o_errcode = NULL; long errcode; - WindowsErrorObject *self = NULL; + PyWindowsErrorObject *self = NULL; long posix_errno; - self = (WindowsErrorObject *)EnvironmentError_new(type, args, kwds); + self = (PyWindowsErrorObject *)EnvironmentError_new(type, args, kwds); if (!self) return NULL; @@ -817,13 +792,13 @@ } static int -WindowsError_init(WindowsErrorObject *self, PyObject *args, PyObject *kwds) +WindowsError_init(PyWindowsErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *o_errcode = NULL; long errcode; - long posix_errno; + long posix_errno; - if (EnvironmentError_init((EnvironmentErrorObject *)self, args, kwds) == -1) + if (EnvironmentError_init((PyEnvironmentErrorObject *)self, args, kwds) == -1) return -1; /* Set errno to the POSIX errno, and winerror to the Win32 @@ -846,7 +821,7 @@ static PyObject * -WindowsError_str(WindowsErrorObject *self) +WindowsError_str(PyWindowsErrorObject *self) { PyObject *repr = NULL; PyObject *fmt = NULL; @@ -890,27 +865,27 @@ } static PyMemberDef WindowsError_members[] = { - {"message", T_OBJECT, offsetof(WindowsErrorObject, message), 0, + {"message", T_OBJECT, offsetof(PyWindowsErrorObject, message), 0, PyDoc_STR("exception message")}, - {"errno", T_OBJECT, offsetof(WindowsErrorObject, myerrno), 0, + {"errno", T_OBJECT, offsetof(PyWindowsErrorObject, myerrno), 0, PyDoc_STR("exception code")}, - {"strerror", T_OBJECT, offsetof(WindowsErrorObject, strerror), 0, + {"strerror", T_OBJECT, offsetof(PyWindowsErrorObject, strerror), 0, PyDoc_STR("exception code")}, - {"filename", T_OBJECT, offsetof(WindowsErrorObject, filename), 0, + {"filename", T_OBJECT, offsetof(PyWindowsErrorObject, filename), 0, PyDoc_STR("exception code")}, - {"winerror", T_OBJECT, offsetof(WindowsErrorObject, winerror), 0, + {"winerror", T_OBJECT, offsetof(PyWindowsErrorObject, winerror), 0, PyDoc_STR("windows exception code")}, {NULL} /* Sentinel */ }; ComplexExtendsException(PyExc_OSError, - WindowsError, - WindowsError, - WindowsError_dealloc, - WindowsError_members, - WindowsError_str, - "MS-Windows OS system call failed.", - 1); + WindowsError, + WindowsError, + WindowsError_dealloc, + 0, + WindowsError_members, + WindowsError_str, + "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ @@ -919,65 +894,59 @@ * VMSError extends OSError (I think) */ #ifdef __VMS -MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError, "OpenVMS OS system call failed."); +MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError, + "OpenVMS OS system call failed."); #endif /* * EOFError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, EOFError, "Read beyond end of file."); +SimpleExtendsException(PyExc_StandardError, EOFError, + "Read beyond end of file."); /* * RuntimeError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, RuntimeError, "Unspecified run-time error."); +SimpleExtendsException(PyExc_StandardError, RuntimeError, + "Unspecified run-time error."); /* * NotImplementedError extends RuntimeError */ -SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, "Method or function hasn't been implemented yet."); +SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, + "Method or function hasn't been implemented yet."); /* * NameError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, NameError, "Name not found globally."); +SimpleExtendsException(PyExc_StandardError, NameError, + "Name not found globally."); /* * UnboundLocalError extends NameError */ -SimpleExtendsException(PyExc_NameError, UnboundLocalError, "Local name referenced but not bound to a value."); +SimpleExtendsException(PyExc_NameError, UnboundLocalError, + "Local name referenced but not bound to a value."); /* * AttributeError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, AttributeError, "Attribute not found."); +SimpleExtendsException(PyExc_StandardError, AttributeError, + "Attribute not found."); /* * SyntaxError extends StandardError */ -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *msg; - PyObject *filename; - PyObject *lineno; - PyObject *offset; - PyObject *text; - PyObject *print_file_and_line; -} SyntaxErrorObject; - static PyObject * SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - SyntaxErrorObject *self = NULL; + PySyntaxErrorObject *self = NULL; - self = (SyntaxErrorObject *)BaseException_new(type, args, kwds); + self = (PySyntaxErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; @@ -998,12 +967,12 @@ } static int -SyntaxError_init(SyntaxErrorObject *self, PyObject *args, PyObject *kwds) +SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *info = NULL; Py_ssize_t lenargs = PySequence_Length(args); - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; if (lenargs >= 1) { @@ -1036,7 +1005,7 @@ } int -SyntaxError_clear(SyntaxErrorObject *self) +SyntaxError_clear(PySyntaxErrorObject *self) { Py_CLEAR(self->msg); Py_CLEAR(self->filename); @@ -1044,18 +1013,18 @@ Py_CLEAR(self->offset); Py_CLEAR(self->text); Py_CLEAR(self->print_file_and_line); - return BaseException_clear((BaseExceptionObject *)self); + return BaseException_clear((PyBaseExceptionObject *)self); } static void -SyntaxError_dealloc(SyntaxErrorObject *self) +SyntaxError_dealloc(PySyntaxErrorObject *self) { SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } int -SyntaxError_traverse(SyntaxErrorObject *self, visitproc visit, void *arg) +SyntaxError_traverse(PySyntaxErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->msg); Py_VISIT(self->filename); @@ -1063,7 +1032,7 @@ Py_VISIT(self->offset); Py_VISIT(self->text); Py_VISIT(self->print_file_and_line); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } /* This is called "my_basename" instead of just "basename" to avoid name @@ -1087,7 +1056,7 @@ static PyObject * -SyntaxError_str(SyntaxErrorObject *self) +SyntaxError_str(PySyntaxErrorObject *self) { PyObject *str; PyObject *result; @@ -1142,56 +1111,62 @@ } static PyMemberDef SyntaxError_members[] = { - {"message", T_OBJECT, offsetof(SyntaxErrorObject, message), 0, + {"message", T_OBJECT, offsetof(PySyntaxErrorObject, message), 0, PyDoc_STR("exception message")}, - {"msg", T_OBJECT, offsetof(SyntaxErrorObject, msg), 0, + {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0, PyDoc_STR("exception msg")}, - {"filename", T_OBJECT, offsetof(SyntaxErrorObject, filename), 0, + {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0, PyDoc_STR("exception filename")}, - {"lineno", T_OBJECT, offsetof(SyntaxErrorObject, lineno), 0, + {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0, PyDoc_STR("exception lineno")}, - {"offset", T_OBJECT, offsetof(SyntaxErrorObject, offset), 0, + {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0, PyDoc_STR("exception offset")}, - {"text", T_OBJECT, offsetof(SyntaxErrorObject, text), 0, + {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), 0, PyDoc_STR("exception text")}, {"print_file_and_line", T_OBJECT, - offsetof(SyntaxErrorObject, print_file_and_line), 0, + offsetof(PySyntaxErrorObject, print_file_and_line), 0, PyDoc_STR("exception print_file_and_line")}, {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str, "Invalid syntax."); +ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, + SyntaxError_dealloc, 0, SyntaxError_members, + SyntaxError_str, "Invalid syntax."); /* * IndentationError extends SyntaxError */ -MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, "Improper indentation."); +MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, + "Improper indentation."); /* * TabError extends IndentationError */ -MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, "Improper mixture of spaces and tabs."); +MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, + "Improper mixture of spaces and tabs."); /* * LookupError extends StandardError */ - SimpleExtendsException(PyExc_StandardError, LookupError, "Base class for lookup errors."); +SimpleExtendsException(PyExc_StandardError, LookupError, + "Base class for lookup errors."); /* * IndexError extends LookupError */ -SimpleExtendsException(PyExc_LookupError, IndexError, "Sequence index out of range."); +SimpleExtendsException(PyExc_LookupError, IndexError, + "Sequence index out of range."); /* * KeyError extends LookupError */ static PyObject * -KeyError_str(BaseExceptionObject *self) +KeyError_str(PyBaseExceptionObject *self) { /* If args is a tuple of exactly one item, apply repr to args[0]. This is done so that e.g. the exception raised by {}[''] prints @@ -1209,35 +1184,26 @@ return BaseException_str(self); } -ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, 0, 0, 0, KeyError_str, "Mapping key not found."); +ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, + 0, 0, 0, KeyError_str, "Mapping key not found."); /* * ValueError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, ValueError, "Inappropriate argument value (of correct type)."); +SimpleExtendsException(PyExc_StandardError, ValueError, + "Inappropriate argument value (of correct type)."); /* * UnicodeError extends ValueError */ -SimpleExtendsException(PyExc_ValueError, UnicodeError, "Unicode related error."); +SimpleExtendsException(PyExc_ValueError, UnicodeError, + "Unicode related error."); #ifdef Py_USING_UNICODE -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *encoding; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; -} UnicodeErrorObject; - -static -int get_int(PyObject *attr, Py_ssize_t *value, const char *name) +static int +get_int(PyObject *attr, Py_ssize_t *value, const char *name) { if (!attr) { PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); @@ -1257,8 +1223,8 @@ return 0; } -static -int set_ssize_t(PyObject **attr, Py_ssize_t value) +static int +set_ssize_t(PyObject **attr, Py_ssize_t value) { PyObject *obj = PyInt_FromSsize_t(value); if (!obj) @@ -1268,8 +1234,8 @@ return 0; } -static -PyObject *get_string(PyObject *attr, const char *name) +static PyObject * +get_string(PyObject *attr, const char *name) { if (!attr) { PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); @@ -1285,8 +1251,8 @@ } -static -int set_string(PyObject **attr, const char *value) +static int +set_string(PyObject **attr, const char *value) { PyObject *obj = PyString_FromString(value); if (!obj) @@ -1297,8 +1263,8 @@ } -static -PyObject *get_unicode(PyObject *attr, const char *name) +static PyObject * +get_unicode(PyObject *attr, const char *name) { if (!attr) { PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); @@ -1306,43 +1272,50 @@ } if (!PyUnicode_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); + PyErr_Format(PyExc_TypeError, + "%.200s attribute must be unicode", name); return NULL; } Py_INCREF(attr); return attr; } -PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) +PyObject * +PyUnicodeEncodeError_GetEncoding(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); + return get_string(((PyUnicodeErrorObject *)exc)->encoding, "encoding"); } -PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) +PyObject * +PyUnicodeDecodeError_GetEncoding(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->encoding, "encoding"); + return get_string(((PyUnicodeErrorObject *)exc)->encoding, "encoding"); } -PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) +PyObject * +PyUnicodeEncodeError_GetObject(PyObject *exc) { - return get_unicode(((UnicodeErrorObject *)exc)->object, "object"); + return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); } -PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) +PyObject * +PyUnicodeDecodeError_GetObject(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->object, "object"); + return get_string(((PyUnicodeErrorObject *)exc)->object, "object"); } -PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) +PyObject * +PyUnicodeTranslateError_GetObject(PyObject *exc) { - return get_unicode(((UnicodeErrorObject *)exc)->object, "object"); + return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); } -int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) +int +PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { + if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { Py_ssize_t size; - PyObject *obj = get_unicode(((UnicodeErrorObject *)exc)->object, + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); if (!obj) return -1; size = PyUnicode_GET_SIZE(obj); @@ -1356,11 +1329,12 @@ } -int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) +int +PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) { - if (!get_int(((UnicodeErrorObject *)exc)->start, start, "start")) { + if (!get_int(((PyUnicodeErrorObject *)exc)->start, start, "start")) { Py_ssize_t size; - PyObject *obj = get_string(((UnicodeErrorObject *)exc)->object, + PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object"); if (!obj) return -1; size = PyString_GET_SIZE(obj); @@ -1374,35 +1348,40 @@ } -int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) +int +PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) { return PyUnicodeEncodeError_GetStart(exc, start); } -int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) +int +PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); } -int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) +int +PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); } -int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) +int +PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->start, start); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->start, start); } -int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) +int +PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { + if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { Py_ssize_t size; - PyObject *obj = get_unicode(((UnicodeErrorObject *)exc)->object, + PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); if (!obj) return -1; size = PyUnicode_GET_SIZE(obj); @@ -1416,11 +1395,12 @@ } -int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) +int +PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) { - if (!get_int(((UnicodeErrorObject *)exc)->end, end, "end")) { + if (!get_int(((PyUnicodeErrorObject *)exc)->end, end, "end")) { Py_ssize_t size; - PyObject *obj = get_string(((UnicodeErrorObject *)exc)->object, + PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object"); if (!obj) return -1; size = PyString_GET_SIZE(obj); @@ -1434,71 +1414,82 @@ } -int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) +int +PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) { return PyUnicodeEncodeError_GetEnd(exc, start); } -int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) +int +PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); } -int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) +int +PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); } -int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) +int +PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) { - return set_ssize_t(&((UnicodeErrorObject *)exc)->end, end); + return set_ssize_t(&((PyUnicodeErrorObject *)exc)->end, end); } -PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) +PyObject * +PyUnicodeEncodeError_GetReason(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); + return get_string(((PyUnicodeErrorObject *)exc)->reason, "reason"); } -PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) +PyObject * +PyUnicodeDecodeError_GetReason(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); + return get_string(((PyUnicodeErrorObject *)exc)->reason, "reason"); } -PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) +PyObject * +PyUnicodeTranslateError_GetReason(PyObject *exc) { - return get_string(((UnicodeErrorObject *)exc)->reason, "reason"); + return get_string(((PyUnicodeErrorObject *)exc)->reason, "reason"); } -int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) +int +PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) { - return set_string(&((UnicodeErrorObject *)exc)->reason, reason); + return set_string(&((PyUnicodeErrorObject *)exc)->reason, reason); } -int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) +int +PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) { - return set_string(&((UnicodeErrorObject *)exc)->reason, reason); + return set_string(&((PyUnicodeErrorObject *)exc)->reason, reason); } -int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) +int +PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) { - return set_string(&((UnicodeErrorObject *)exc)->reason, reason); + return set_string(&((PyUnicodeErrorObject *)exc)->reason, reason); } static PyObject * -UnicodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) +UnicodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds, + PyTypeObject *objecttype) { - UnicodeErrorObject *self; + PyUnicodeErrorObject *self; - self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); + self = (PyUnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; @@ -1512,7 +1503,8 @@ } static int -UnicodeError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) +UnicodeError_init(PyUnicodeErrorObject *self, PyObject *args, PyObject *kwds, + PyTypeObject *objecttype) { if (!PyArg_ParseTuple(args, "O!O!O!O!O!", &PyString_Type, &self->encoding, @@ -1535,46 +1527,46 @@ } int -UnicodeError_clear(UnicodeErrorObject *self) +UnicodeError_clear(PyUnicodeErrorObject *self) { Py_CLEAR(self->encoding); Py_CLEAR(self->object); Py_CLEAR(self->start); Py_CLEAR(self->end); Py_CLEAR(self->reason); - return BaseException_clear((BaseExceptionObject *)self); + return BaseException_clear((PyBaseExceptionObject *)self); } static void -UnicodeError_dealloc(UnicodeErrorObject *self) +UnicodeError_dealloc(PyUnicodeErrorObject *self) { UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } int -UnicodeError_traverse(UnicodeErrorObject *self, visitproc visit, void *arg) +UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->encoding); Py_VISIT(self->object); Py_VISIT(self->start); Py_VISIT(self->end); Py_VISIT(self->reason); - return BaseException_traverse((BaseExceptionObject *)self, visit, arg); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } static PyMemberDef UnicodeError_members[] = { - {"message", T_OBJECT, offsetof(UnicodeErrorObject, message), 0, + {"message", T_OBJECT, offsetof(PyUnicodeErrorObject, message), 0, PyDoc_STR("exception message")}, - {"encoding", T_OBJECT, offsetof(UnicodeErrorObject, encoding), 0, + {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0, PyDoc_STR("exception encoding")}, - {"object", T_OBJECT, offsetof(UnicodeErrorObject, object), 0, + {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, PyDoc_STR("exception object")}, - {"start", T_OBJECT, offsetof(UnicodeErrorObject, start), 0, + {"start", T_OBJECT, offsetof(PyUnicodeErrorObject, start), 0, PyDoc_STR("exception start")}, - {"end", T_OBJECT, offsetof(UnicodeErrorObject, end), 0, + {"end", T_OBJECT, offsetof(PyUnicodeErrorObject, end), 0, PyDoc_STR("exception end")}, - {"reason", T_OBJECT, offsetof(UnicodeErrorObject, reason), 0, + {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, PyDoc_STR("exception reason")}, {NULL} /* Sentinel */ }; @@ -1592,9 +1584,10 @@ static int UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyUnicode_Type); + return UnicodeError_init((PyUnicodeErrorObject *)self, args, + kwds, &PyUnicode_Type); } static PyObject * @@ -1610,7 +1603,7 @@ return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; char badchar_str[20]; if (badchar <= 0xff) PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); @@ -1620,18 +1613,18 @@ PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); return PyString_FromFormat( "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), badchar_str, start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } return PyString_FromFormat( "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), start, (end-1), - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } @@ -1639,18 +1632,19 @@ PyObject_HEAD_INIT(NULL) 0, "UnicodeEncodeError", - sizeof(UnicodeErrorObject), 0, + sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode encoding error."), (traverseproc)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; -PyObject * PyUnicodeEncodeError_Create( +PyObject * +PyUnicodeEncodeError_Create( const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) { @@ -1671,9 +1665,10 @@ static int UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) { - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - return UnicodeError_init((UnicodeErrorObject *)self, args, kwds, &PyString_Type); + return UnicodeError_init((PyUnicodeErrorObject *)self, args, + kwds, &PyString_Type); } static PyObject * @@ -1692,21 +1687,21 @@ /* FromFormat does not support %02x, so format that separately */ char byte[4]; PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(((UnicodeErrorObject *)self)->object)[start])&0xff); + ((int)PyString_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start])&0xff); return PyString_FromFormat( "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), byte, start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } return PyString_FromFormat( "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", - PyString_AS_STRING(((UnicodeErrorObject *)self)->encoding), + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), start, (end-1), - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } @@ -1714,18 +1709,19 @@ PyObject_HEAD_INIT(NULL) 0, EXC_MODULE_NAME "UnicodeDecodeError", - sizeof(UnicodeErrorObject), 0, + sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode decoding error."), (traverseproc)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; -PyObject * PyUnicodeDecodeError_Create( +PyObject * +PyUnicodeDecodeError_Create( const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) { @@ -1743,9 +1739,9 @@ static PyObject * UnicodeTranslateError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - UnicodeErrorObject *self = NULL; + PyUnicodeErrorObject *self = NULL; - self = (UnicodeErrorObject *)BaseException_new(type, args, kwds); + self = (PyUnicodeErrorObject *)BaseException_new(type, args, kwds); if (!self) return NULL; @@ -1759,9 +1755,10 @@ } static int -UnicodeTranslateError_init(UnicodeErrorObject *self, PyObject *args, PyObject *kwds) +UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args, + PyObject *kwds) { - if (BaseException_init((BaseExceptionObject *)self, args, kwds) == -1) + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; Py_CLEAR(self->object); @@ -1800,7 +1797,7 @@ return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((UnicodeErrorObject *)self)->object)[start]; + int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; char badchar_str[20]; if (badchar <= 0xff) PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); @@ -1812,14 +1809,14 @@ "can't translate character u'\\%s' in position %zd: %.400s", badchar_str, start, - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } return PyString_FromFormat( "can't translate characters in position %zd-%zd: %.400s", start, (end-1), - PyString_AS_STRING(((UnicodeErrorObject *)self)->reason) + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) ); } @@ -1827,18 +1824,19 @@ PyObject_HEAD_INIT(NULL) 0, EXC_MODULE_NAME "UnicodeTranslateError", - sizeof(UnicodeErrorObject), 0, + sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(UnicodeErrorObject, dict), + 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; -PyObject * PyUnicodeTranslateError_Create( +PyObject * +PyUnicodeTranslateError_Create( const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) { @@ -1851,31 +1849,36 @@ /* * AssertionError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, AssertionError, "Assertion failed."); +SimpleExtendsException(PyExc_StandardError, AssertionError, + "Assertion failed."); /* * ArithmeticError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, ArithmeticError, "Base class for arithmetic errors."); +SimpleExtendsException(PyExc_StandardError, ArithmeticError, + "Base class for arithmetic errors."); /* * FloatingPointError extends ArithmeticError */ -SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, "Floating point operation failed."); +SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, + "Floating point operation failed."); /* * OverflowError extends ArithmeticError */ -SimpleExtendsException(PyExc_ArithmeticError, OverflowError, "Result too large to be represented."); +SimpleExtendsException(PyExc_ArithmeticError, OverflowError, + "Result too large to be represented."); /* * ZeroDivisionError extends ArithmeticError */ -SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, "Second argument to a division or modulo operation was zero."); +SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, + "Second argument to a division or modulo operation was zero."); /* @@ -1891,7 +1894,8 @@ /* * ReferenceError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, ReferenceError, "Weak ref proxy used after referent went away."); +SimpleExtendsException(PyExc_StandardError, ReferenceError, + "Weak ref proxy used after referent went away."); /* @@ -1905,19 +1909,22 @@ /* * Warning extends Exception */ -SimpleExtendsException(PyExc_Exception, Warning, "Base class for warning categories."); +SimpleExtendsException(PyExc_Exception, Warning, + "Base class for warning categories."); /* * UserWarning extends Warning */ -SimpleExtendsException(PyExc_Warning, UserWarning, "Base class for warnings generated by user code."); +SimpleExtendsException(PyExc_Warning, UserWarning, + "Base class for warnings generated by user code."); /* * DeprecationWarning extends Warning */ -SimpleExtendsException(PyExc_Warning, DeprecationWarning, "Base class for warnings about deprecated features."); +SimpleExtendsException(PyExc_Warning, DeprecationWarning, + "Base class for warnings about deprecated features."); /* @@ -1931,13 +1938,15 @@ /* * SyntaxWarning extends Warning */ -SimpleExtendsException(PyExc_Warning, SyntaxWarning, "Base class for warnings about dubious syntax."); +SimpleExtendsException(PyExc_Warning, SyntaxWarning, + "Base class for warnings about dubious syntax."); /* * RuntimeWarning extends Warning */ -SimpleExtendsException(PyExc_Warning, RuntimeWarning, "Base class for warnings about dubious runtime behavior."); +SimpleExtendsException(PyExc_Warning, RuntimeWarning, + "Base class for warnings about dubious runtime behavior."); /* @@ -1951,7 +1960,8 @@ /* * ImportWarning extends Warning */ -SimpleExtendsException(PyExc_Warning, ImportWarning, "Base class for warnings about probable mistakes in module imports"); +SimpleExtendsException(PyExc_Warning, ImportWarning, + "Base class for warnings about probable mistakes in module imports"); /* Pre-computed MemoryError instance. Best to create this as early as From python-checkins at python.org Fri May 26 21:48:08 2006 From: python-checkins at python.org (fredrik.lundh) Date: Fri, 26 May 2006 21:48:08 +0200 (CEST) Subject: [Python-checkins] r46406 - in python/trunk/Objects: stringlib/find.h stringobject.c unicodeobject.c Message-ID: <20060526194808.893C51E400C@bag.python.org> Author: fredrik.lundh Date: Fri May 26 21:48:07 2006 New Revision: 46406 Modified: python/trunk/Objects/stringlib/find.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring: use stringlib/find for string find Modified: python/trunk/Objects/stringlib/find.h ============================================================================== --- python/trunk/Objects/stringlib/find.h (original) +++ python/trunk/Objects/stringlib/find.h Fri May 26 21:48:07 2006 @@ -9,29 +9,38 @@ Py_LOCAL(Py_ssize_t) stringlib_find(const STRINGLIB_CHAR* str, Py_ssize_t str_len, - const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, + Py_ssize_t offset) { + Py_ssize_t pos; + if (sub_len == 0) - return 0; + return offset; + + pos = fastsearch(str, str_len, sub, sub_len, FAST_SEARCH); - return fastsearch(str, str_len, sub, sub_len, FAST_SEARCH); + if (pos >= 0) + pos += offset; + + return pos; } Py_LOCAL(Py_ssize_t) stringlib_rfind(const STRINGLIB_CHAR* str, Py_ssize_t str_len, - const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, + Py_ssize_t offset) { Py_ssize_t pos; /* XXX - create reversefastsearch helper! */ if (sub_len == 0) - pos = str_len; + pos = str_len + offset; else { Py_ssize_t j; pos = -1; for (j = str_len - sub_len; j >= 0; --j) if (STRINGLIB_CMP(str+j, sub, sub_len) == 0) { - pos = j; + pos = j + offset; break; } } Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 21:48:07 2006 @@ -775,6 +775,8 @@ #define STRINGLIB_EMPTY nullstring #include "stringlib/fastsearch.h" + +#include "stringlib/find.h" #include "stringlib/partition.h" /* -------------------------------------------------------------------- */ @@ -1876,25 +1878,10 @@ string_adjust_indices(&i, &last, len); - if (n == 0) - return (dir > 0) ? i : last; - if (dir > 0) { - Py_ssize_t pos = fastsearch(s + i, last - i, sub, n, - FAST_SEARCH); - if (pos < 0) - return pos; - return pos + i; - } else { - Py_ssize_t j; - - if (n == 0 && i <= last) - return last; - for (j = last-n; j >= i; --j) - if (s[j] == sub[0] && memcmp(&s[j], sub, n) == 0) - return j; - } - - return -1; + if (dir > 0) + return stringlib_find(s+i, last-i, sub, n, i); + else + return stringlib_rfind(s+i, last-i, sub, n, i); } Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 21:48:07 2006 @@ -3967,16 +3967,15 @@ if (direction > 0) result = stringlib_find( - str_obj->str + start, end - start, sub_obj->str, sub_obj->length + str_obj->str + start, end - start, sub_obj->str, sub_obj->length, + start ); else result = stringlib_rfind( - str_obj->str + start, end - start, sub_obj->str, sub_obj->length + str_obj->str + start, end - start, sub_obj->str, sub_obj->length, + start ); - if (result >= 0) - result += start; - Py_DECREF(str_obj); Py_DECREF(sub_obj); return result; From jimjjewett at gmail.com Fri May 26 21:50:15 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 26 May 2006 15:50:15 -0400 Subject: [Python-checkins] r46369 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c In-Reply-To: <20060526174701.136BE1E4010@bag.python.org> References: <20060526174701.136BE1E4010@bag.python.org> Message-ID: On 5/26/06, bob.ippolito wrote: > Author: bob.ippolito > Date: Fri May 26 19:47:00 2006 > New Revision: 46369 > > Modified: > sandbox/trunk/hotbuffer/Modules/_hotbuf.c > Log: > use tp_getset instead of tp_members > > Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c Are there plans for the unused pointers? For instance, are you planning to keep different positions for reading and writing? > +static PyObject * > +hotbuf_get_position(PyHotbufObject *self, void *unused) > +{ > + return PyInt_FromSsize_t(self->b_position); > +} From python-checkins at python.org Fri May 26 21:51:13 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 26 May 2006 21:51:13 +0200 (CEST) Subject: [Python-checkins] r46407 - python/trunk/Objects/unicodeobject.c Message-ID: <20060526195113.7A0281E4023@bag.python.org> Author: andrew.kuchling Date: Fri May 26 21:51:10 2006 New Revision: 46407 Modified: python/trunk/Objects/unicodeobject.c Log: Comment typo Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Fri May 26 21:51:10 2006 @@ -196,7 +196,7 @@ /* We allocate one more byte to make sure the string is Ux0000 terminated. The overallocation is also used by fastsearch, which assumes that it's - safe to look at str[length] (without makeing any assumptions about what + safe to look at str[length] (without making any assumptions about what it contains). */ oldstr = unicode->str; From python-checkins at python.org Fri May 26 21:59:05 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 21:59:05 +0200 (CEST) Subject: [Python-checkins] r46408 - python/branches/sreifschneider-newnewexcept/Python/errors.c Message-ID: <20060526195905.3F20F1E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 21:59:04 2006 New Revision: 46408 Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c Log: Some simplifications. Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Python/errors.c (original) +++ python/branches/sreifschneider-newnewexcept/Python/errors.c Fri May 26 21:59:04 2006 @@ -566,7 +566,7 @@ if (bases == NULL) goto failure; } - /*result = PyClass_New(bases, dict, classname);*/ + /* Create a real new-style class. */ result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO", dot+1, bases, dict); failure: @@ -643,15 +643,11 @@ return 0; } else { - PyObject *args, *res; + PyObject *res; if (category == NULL) category = PyExc_RuntimeWarning; - args = Py_BuildValue("(sO)", message, category); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); + res = PyObject_CallFunction(func, "sO", message, category); if (res == NULL) return -1; Py_DECREF(res); @@ -679,18 +675,14 @@ return 0; } else { - PyObject *args, *res; + PyObject *res; if (category == NULL) category = PyExc_RuntimeWarning; if (registry == NULL) registry = Py_None; - args = Py_BuildValue("(sOsizO)", message, category, - filename, lineno, module, registry); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); + res = PyObject_CallFunction(func, "sOsizO", message, category, + filename, lineno, module, registry); if (res == NULL) return -1; Py_DECREF(res); @@ -711,7 +703,8 @@ /* add attributes for the line number and filename for the error */ PyErr_Fetch(&exc, &v, &tb); PyErr_NormalizeException(&exc, &v, &tb); - /* XXX check that it is, indeed, a syntax error */ + /* XXX check that it is, indeed, a syntax error. It might not + * be, though. */ tmp = PyInt_FromLong(lineno); if (tmp == NULL) PyErr_Clear(); From python-checkins at python.org Fri May 26 22:04:45 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 22:04:45 +0200 (CEST) Subject: [Python-checkins] r46409 - in python/trunk: Modules/_ctypes/_ctypes.c Python/ast.c Python/compile.c Message-ID: <20060526200445.421B41E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 22:04:44 2006 New Revision: 46409 Modified: python/trunk/Modules/_ctypes/_ctypes.c python/trunk/Python/ast.c python/trunk/Python/compile.c Log: Replace Py_BuildValue("OO") by PyTuple_Pack. Modified: python/trunk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes.c (original) +++ python/trunk/Modules/_ctypes/_ctypes.c Fri May 26 22:04:44 2006 @@ -2185,7 +2185,7 @@ only it's object list. So we create a tuple, containing b_objects list PLUS the array itself, and return that! */ - return Py_BuildValue("(OO)", keep, value); + return PyTuple_Pack(2, keep, value); } PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Fri May 26 22:04:44 2006 @@ -107,7 +107,7 @@ Py_DECREF(errstr); return; } - value = Py_BuildValue("(OO)", errstr, tmp); + value = PyTuple_Pack(2, errstr, tmp); Py_DECREF(errstr); Py_DECREF(tmp); if (!value) Modified: python/trunk/Python/compile.c ============================================================================== --- python/trunk/Python/compile.c (original) +++ python/trunk/Python/compile.c Fri May 26 22:04:44 2006 @@ -334,7 +334,7 @@ return NULL; } k = PyList_GET_ITEM(list, i); - k = Py_BuildValue("(OO)", k, k->ob_type); + k = PyTuple_Pack(2, k, k->ob_type); if (k == NULL || PyDict_SetItem(dict, k, v) < 0) { Py_XDECREF(k); Py_DECREF(v); @@ -377,7 +377,7 @@ return NULL; } i++; - tuple = Py_BuildValue("(OO)", k, k->ob_type); + tuple = PyTuple_Pack(2, k, k->ob_type); if (!tuple || PyDict_SetItem(dest, tuple, item) < 0) { Py_DECREF(item); Py_DECREF(dest); @@ -1841,7 +1841,7 @@ compiler_lookup_arg(PyObject *dict, PyObject *name) { PyObject *k, *v; - k = Py_BuildValue("(OO)", name, name->ob_type); + k = PyTuple_Pack(2, name, name->ob_type); if (k == NULL) return -1; v = PyDict_GetItem(dict, k); From python-checkins at python.org Fri May 26 22:06:03 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 22:06:03 +0200 (CEST) Subject: [Python-checkins] r46410 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526200603.E69E41E4006@bag.python.org> Author: tim.peters Date: Fri May 26 22:06:03 2006 New Revision: 46410 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: More Windows fixes. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 22:06:03 2006 @@ -855,7 +855,7 @@ Py_DECREF(tuple); } else - rtnval = EnvironmentError_str((EnvironmentErrorObject *)self); + rtnval = EnvironmentError_str((PyEnvironmentErrorObject *)self); finally: Py_XDECREF(repr); @@ -1213,8 +1213,8 @@ if (PyInt_Check(attr)) { *value = PyInt_AS_LONG(attr); } else if (PyLong_Check(attr)) { - *value = PyLong_AsLongLong(attr); - if (*value == -1) + *value = _PyLong_AsSsize_t(attr); + if (*value == -1 && PyErr_Occurred()) return -1; } else { PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); From python-checkins at python.org Fri May 26 22:14:47 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 22:14:47 +0200 (CEST) Subject: [Python-checkins] r46411 - python/trunk/Doc/ref/ref2.tex Message-ID: <20060526201447.A74601E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 22:14:47 2006 New Revision: 46411 Modified: python/trunk/Doc/ref/ref2.tex Log: Patch #1492218: document None being a constant. Modified: python/trunk/Doc/ref/ref2.tex ============================================================================== --- python/trunk/Doc/ref/ref2.tex (original) +++ python/trunk/Doc/ref/ref2.tex Fri May 26 22:14:47 2006 @@ -319,16 +319,18 @@ % When adding keywords, use reswords.py for reformatting -Note that although the identifier \code{as} can be used as part of the -syntax of \keyword{import} statements, it is not currently a reserved -word by default.) +\versionchanged[\constant{None} became a constant and is now +recognized by the compiler as a name for the built-in object +\constant{None}. Although it is not a keyword, you cannot assign +a different object to it]{2.4} \versionchanged[Both \keyword{as} and \keyword{with} are only recognized -when the \code{with_statement} feature has been enabled. It will always -be enabled in Python 2.6. See section~\ref{with} for details]{2.5} +when the \code{with_statement} future feature has been enabled. +It will always be enabled in Python 2.6. See section~\ref{with} for +details. Note that using \keyword{as} and \keyword{with} as identifiers +will always issue a warning, even when the \code{with_statement} future +directive is not in effect]{2.5} -In some future version of Python, the identifier \code{None} will -become a keyword. \subsection{Reserved classes of identifiers\label{id-classes}} From python-checkins at python.org Fri May 26 22:16:27 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 22:16:27 +0200 (CEST) Subject: [Python-checkins] r46412 - python/branches/release24-maint/Doc/ref/ref2.tex Message-ID: <20060526201627.18A9C1E4006@bag.python.org> Author: georg.brandl Date: Fri May 26 22:16:26 2006 New Revision: 46412 Modified: python/branches/release24-maint/Doc/ref/ref2.tex Log: Patch #1492218: document None being a constant. Modified: python/branches/release24-maint/Doc/ref/ref2.tex ============================================================================== --- python/branches/release24-maint/Doc/ref/ref2.tex (original) +++ python/branches/release24-maint/Doc/ref/ref2.tex Fri May 26 22:16:26 2006 @@ -322,8 +322,12 @@ syntax of \keyword{import} statements, it is not currently a reserved word. -In some future version of Python, the identifiers \code{as} and -\code{None} will both become keywords. +In Python 2.6, the identifier \code{as} will become a keyword. + +\versionchanged[\constant{None} became a constant and is now +recognized by the compiler as a name for the builtin object +\constant{None}. Although it is not a keyword, you cannot assign +a different object to it]{2.4} \subsection{Reserved classes of identifiers\label{id-classes}} From python-checkins at python.org Fri May 26 22:17:10 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 22:17:10 +0200 (CEST) Subject: [Python-checkins] r46413 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060526201710.352FA1E4006@bag.python.org> Author: andrew.dalke Date: Fri May 26 22:17:09 2006 New Revision: 46413 Modified: sandbox/trunk/stringbench/stringbench.py Log: Added more tests to stress various string operations. Added command-line options: -8 or --8-bit only time 8-bit strings -u or --unicode only time unicode strings -R or --skip-re skip doing the regular expression benchmarks Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Fri May 26 22:17:09 2006 @@ -7,18 +7,33 @@ import re import sys import datetime +import optparse print sys.version print datetime.datetime.now() REPEAT = 1 REPEAT = 3 +#REPEAT = 7 if __name__ != "__main__": raise SystemExit("Must run as main program") +parser = optparse.OptionParser() +parser.add_option("-R", "--skip-re", dest="skip_re", + action="store_true", + help="skip regular expression tests") +parser.add_option("-8", "--8-bit", dest="str_only", + action="store_true", + help="only do 8-bit string benchmarks") +parser.add_option("-u", "--unicode", dest="unicode_only", + action="store_true", + help="only do Unicode string benchmarks") + + _RANGE_1000 = range(1000) _RANGE_100 = range(100) +_RANGE_10 = range(10) def bench(s, group, repeat_count): def blah(f): @@ -29,6 +44,9 @@ return f return blah +def uses_re(f): + f.uses_re = True + ####### 'in' comparisons @bench('"A" in "A"*1000', "early match, single character", 1000) @@ -77,6 +95,7 @@ s2 in s1 # Try with regex + at uses_re @bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*500+s+"E")', "late match, 100 characters", 100) def re_test_slow_match_100_characters(STR): @@ -91,7 +110,7 @@ #### same tests as 'in' but use 'find' -# Add rfind +# XXX: TODO: Add rfind @@ -472,21 +491,40 @@ ## split text on "--" characters @bench( '"this--is--a--test--of--the--emergency--broadcast--system".split("--")', - "split on multicharacter seperator", 1000) -def split_multichar_sep(STR): + "split on multicharacter separator (small)", 1000) +def split_multichar_sep_small(STR): s = STR("this--is--a--test--of--the--emergency--broadcast--system") s_split = s.split for x in _RANGE_1000: s_split("--") @bench( '"this--is--a--test--of--the--emergency--broadcast--system".rsplit("--")', - "split on multicharacter seperator", 1000) -def rsplit_multichar_sep(STR): + "split on multicharacter separator (small)", 1000) +def rsplit_multichar_sep_small(STR): s = STR("this--is--a--test--of--the--emergency--broadcast--system") s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("--") +## split dna text on "ACTAT" characters + at bench('dna.split("ACTAT")', + "split on multicharacter separator (dna)", 100) +def split_multichar_sep_dna(STR): + s = _get_dna(STR) + s_split = s.split + for x in _RANGE_100: + s_split("ACTAT") + + at bench('dna.rsplit("ACTAT")', + "split on multicharacter separator (dna)", 100) +def rsplit_multichar_sep_dna(STR): + s = _get_dna(STR) + s_rsplit = s.rsplit + for x in _RANGE_100: + s_rsplit("ACTAT") + + + ## split with limits GFF3_example = "\t".join([ @@ -739,6 +777,7 @@ for x in _RANGE_1000: s_replace(from_str, to_str) + at uses_re @bench('re.sub(" ", "\\t", "This is a test"', 'replace single character', 1000) def replace_single_character_re(STR): @@ -759,6 +798,7 @@ for x in _RANGE_100: s_replace(from_str, to_str) + at uses_re @bench('re.sub("\\n", " ", "...text.with.2000.lines...")', 'replace single character, big string', 100) def replace_single_character_big_re(STR): @@ -815,6 +855,38 @@ s_replace(from_str, to_str) +big_s = "A" + ("Z"*1024*1024) +big_s_unicode = unicode(big_s) +def _get_big_s(STR): + if STR is unicode: return big_s_unicode + if STR is str: return big_s + raise AssertionError + +# The older replace implementation counted all matches in +# the string even when it only neeed to make one replacement. + at bench('("A" + ("Z"*1024*1024)).replace("A", "BB", 1)', + 'quick replace single character match', 10) +def quick_replace_single_match(STR): + s = _get_big_s(STR) + from_str = STR("A") + to_str = STR("BB") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str, 1) + + at bench('("A" + ("Z"*1024*1024)).replace("AZZ", "BBZZ", 1)', + 'quick replace multiple character match', 10) +def quick_replace_multiple_match(STR): + s = _get_big_s(STR) + from_str = STR("AZZ") + to_str = STR("BBZZ") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str, 1) + + +#### + # CCP does a lot of this, for internationalisation of ingame messages. _format = "The %(thing)s is %(place)s the %(location)s." _format_dict = { "thing":"THING", "place":"PLACE", "location":"LOCATION", } @@ -902,7 +974,9 @@ return min(times) / number def main(): - test_names = sys.argv[1:] + (options, test_names) = parser.parse_args() + if options.str_only and options.unicode_only: + raise SystemExit("Only one of --8-bit and --unicode are allowed") bench_functions = [] for (k,v) in globals().items(): @@ -914,6 +988,9 @@ else: # Not selected, ignore continue + if options.skip_re and hasattr(v, "uses_re"): + continue + bench_functions.append( (v.group, k, v) ) bench_functions.sort() @@ -927,12 +1004,22 @@ print "="*10, title for (_, k, v) in group: if hasattr(v, "is_bench"): - str_time = BenchTimer("__main__.%s(str)" % (k,), - "import __main__").best(REPEAT) - uni_time = BenchTimer("__main__.%s(unicode)" % (k,), - "import __main__").best(REPEAT) + if not options.unicode_only: + str_time = BenchTimer("__main__.%s(str)" % (k,), + "import __main__").best(REPEAT) + else: + str_time = 0.0 + if not options.str_only: + uni_time = BenchTimer("__main__.%s(unicode)" % (k,), + "import __main__").best(REPEAT) + else: + uni_time = 0.0 + try: + average = str_time/uni_time + except ZeroDivisionError: + average = 0.0 print "%.2f\t%.2f\t%.1f\t%s (*%d)" % ( - 1000*str_time, 1000*uni_time, 100.*str_time/uni_time, + 1000*str_time, 1000*uni_time, 100.*average, v.comment, v.repeat_count) str_total += str_time @@ -941,8 +1028,12 @@ if str_total == uni_total == 0.0: print "That was zippy!" else: + try: + average = str_time/uni_time + except ZeroDivisionError: + average = 0.0 print "%.2f\t%.2f\t%.1f\t%s" % ( - 1000*str_total, 1000*uni_total, 100.*str_total/uni_total, + 1000*str_total, 1000*uni_total, 100.*average, "TOTAL") if __name__ == "__main__": From python-checkins at python.org Fri May 26 22:21:39 2006 From: python-checkins at python.org (martin.blais) Date: Fri, 26 May 2006 22:21:39 +0200 (CEST) Subject: [Python-checkins] r46414 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c README.txt test_hotbuf.py use_cases.py Message-ID: <20060526202139.2202B1E4006@bag.python.org> Author: martin.blais Date: Fri May 26 22:21:38 2006 New Revision: 46414 Added: sandbox/trunk/hotbuffer/use_cases.py (contents, props changed) Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Removed remaining. Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Fri May 26 22:21:38 2006 @@ -498,18 +498,6 @@ } -PyDoc_STRVAR(remaining__doc__, - "B.remaining() -> int\n\ -\n\ -Returns the number of bytes between the current position and the limit."); - -static PyObject* -hotbuf_remaining(PyHotbufObject *self) -{ - return PyInt_FromSsize_t(self->b_limit - self->b_position); -} - - PyDoc_STRVAR(compact__doc__, "B.compact()\n\ \n\ @@ -867,8 +855,6 @@ static Py_ssize_t hotbuf_length(PyHotbufObject *self) { - /* Note: this is the same as 'remaining'. */ - assert(self->b_position <= self->b_limit); return self->b_limit - self->b_position; } @@ -997,7 +983,6 @@ {"restore", (PyCFunction)hotbuf_restore, METH_VARARGS, restore__doc__}, {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, - {"remaining", (PyCFunction)hotbuf_remaining, METH_NOARGS, remaining__doc__}, {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, get__doc__}, {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Fri May 26 22:21:38 2006 @@ -23,24 +23,25 @@ TODO ==== -* Make push() and pop() instead of save() and restore() +* Remove the advbytes argument to pop() -* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC - -* We need to make the client more easily remove the calls to remaining() +* Make push() and pop() instead of save() and restore(), use a C stack + internally. * Make it possible to read from a file directly into a hotbuf - - implement the file protocol (read(), write()) on the buffer object + - implement the file protocol (read(), write()) on the hotbuf object - is there a file protocol? +* We need to select between PyObject_MALLOC and PyObject_MEMMALLOC + + + Features -------- * Use descriptors rather than function calls to set the limit, etc. -* Add restore() to the tests. - * Implement pack() in C * Change the mark, this will make the loop easier to understand Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 22:21:38 2006 @@ -84,9 +84,9 @@ (0, 104, 42)) # Play with remaining. - self.assertEquals(b.remaining(), 104) + self.assertEquals(len(b), 104) b.setposition(10) - self.assertEquals(b.remaining(), 94) + self.assertEquals(len(b), 94) # Play with advance. self.assertEquals(b.position, 10) Added: sandbox/trunk/hotbuffer/use_cases.py ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/use_cases.py Fri May 26 22:21:38 2006 @@ -0,0 +1,120 @@ +#!/usr/bin/env python + +""" +Use cases for the hot buffer. +""" + + +#------------------------------------------------------------------------------- +# Case 1: parsing netstrings, not using exceptions. + + # Loop over the entire input. + while 1: + # Loop over all the messages in the current buffer. + while hot: + # Read the length and parse the message. + length = hot.getbyte() # No error can occur here, since we're + # still hot. + if len(hot) < length: + # Rollback the length byte and exit the loop to fill the buffer + # with new data. + hot.advance(-1) + break + + # Save the current window and window around the message content. + hot.push(1, length) + + # Parse the message. + # + # - We are insured to be able to read all the message here because + # we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your transactions. + + # (your code) + + # Pop the message window and advance beyond the length. + hot.pop() + hot.advance(length + 1) + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + +#------------------------------------------------------------------------------- +# Case 2: parsing netstrings, using exceptions. This is more or less the same +# as Case 1, but without checking the length from Python, but the length is +# automatically checked by push(). + + while 1: + # Catch when we hit the boundary. + try: + # Loop over all the messages in the current buffer. + while hot: + # Read the length. + length = hot.getbyte() # This may raise + hot.push(1, length) # This may raise as well + + # Parse the message. + # + # - We are insured to be able to read all the message here + # because we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your transactions. + + # (your code) + + # Pop the message window and advance beyond the length. + hot.pop() + hot.advance(length + 1) + else: + raise hotbuf.BoundaryError + + except hotbuf.BoundaryError: + # Rollback the failed transaction. + hot.pop() + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + +#------------------------------------------------------------------------------- +# Case 3: arbitrary formats, may hit the boundary, cannot detect programming +# errors. + + while 1: + # Catch when we hit the boundary. + try: + # Loop over all the messages in the current buffer. + while hot: + hot.push() + + # Parse the message. + # + # - We are insured to be able to read all the message here + # because we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your transactions. + + # (your code) + + # Pop the safe window and leave the current position and limit + # alone. + hot.pop(False) + else: + raise hotbuf.BoundaryError + + except hotbuf.BoundaryError: + # Rollback the failed transaction. + hot.pop() + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + From python-checkins at python.org Fri May 26 22:22:51 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 May 2006 22:22:51 +0200 (CEST) Subject: [Python-checkins] r46415 - python/trunk/Objects/classobject.c Message-ID: <20060526202251.070BE1E4019@bag.python.org> Author: georg.brandl Date: Fri May 26 22:22:50 2006 New Revision: 46415 Modified: python/trunk/Objects/classobject.c Log: Simplify calling. Modified: python/trunk/Objects/classobject.c ============================================================================== --- python/trunk/Objects/classobject.c (original) +++ python/trunk/Objects/classobject.c Fri May 26 22:22:50 2006 @@ -1072,21 +1072,15 @@ static PyObject * instance_item(PyInstanceObject *inst, Py_ssize_t i) { - PyObject *func, *arg, *res; + PyObject *func, *res; if (getitemstr == NULL) getitemstr = PyString_InternFromString("__getitem__"); func = instance_getattr(inst, getitemstr); if (func == NULL) return NULL; - arg = Py_BuildValue("(n)", i); - if (arg == NULL) { - Py_DECREF(func); - return NULL; - } - res = PyEval_CallObject(func, arg); + res = PyObject_CallFunction(func, "n", i); Py_DECREF(func); - Py_DECREF(arg); return res; } From python-checkins at python.org Fri May 26 22:25:23 2006 From: python-checkins at python.org (andrew.dalke) Date: Fri, 26 May 2006 22:25:23 +0200 (CEST) Subject: [Python-checkins] r46416 - python/trunk/Objects/stringobject.c Message-ID: <20060526202523.2AC341E4010@bag.python.org> Author: andrew.dalke Date: Fri May 26 22:25:22 2006 New Revision: 46416 Modified: python/trunk/Objects/stringobject.c Log: Added limits to the replace code so it does not count all of the matching patterns in a string, only the number needed by the max limit. Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Fri May 26 22:25:22 2006 @@ -2477,7 +2477,7 @@ } Py_LOCAL(Py_ssize_t) -countchar(char *target, int target_len, char c) + countchar(char *target, int target_len, char c, Py_ssize_t maxcount) { Py_ssize_t count=0; char *start=target; @@ -2485,9 +2485,10 @@ while ( (start=findchar(start, end-start, c)) != NULL ) { count++; + if (count >= maxcount) + break; start += 1; } - return count; } @@ -2534,7 +2535,7 @@ char *pattern, Py_ssize_t pattern_len, Py_ssize_t start, Py_ssize_t end, - int direction) + int direction, Py_ssize_t maxcount) { Py_ssize_t count=0; @@ -2552,21 +2553,26 @@ } /* zero-length substrings match everywhere */ - if (pattern_len == 0) - return target_len+1; + if (pattern_len == 0 || maxcount == 0) { + if (target_len+1 < maxcount) + return target_len+1; + return maxcount; + } end -= pattern_len; - if (direction < 0) { - for (; end >= start; end--) + for (; (end >= start); end--) if (Py_STRING_MATCH(target, end, pattern, pattern_len)) { count++; + if (--maxcount <= 0) break; end -= pattern_len-1; } } else { - for (; start <= end; start++) + for (; (start <= end); start++) if (Py_STRING_MATCH(target, start, pattern, pattern_len)) { count++; + if (--maxcount <= 0) + break; start += pattern_len-1; } } @@ -2653,12 +2659,10 @@ self_len = PyString_GET_SIZE(self); self_s = PyString_AS_STRING(self); - count = countchar(self_s, self_len, from_c); + count = countchar(self_s, self_len, from_c, maxcount); if (count == 0) { return return_self(self); } - if (count > maxcount) - count = maxcount; result_len = self_len - count; /* from_len == 1 */ assert(result_len>=0); @@ -2701,10 +2705,8 @@ count = countstring(self_s, self_len, from_s, from_len, - 0, self_len, 1); - - if (count > maxcount) - count = maxcount; + 0, self_len, 1, + maxcount); if (count == 0) { /* no matches */ @@ -2857,9 +2859,7 @@ self_s = PyString_AS_STRING(self); self_len = PyString_GET_SIZE(self); - count = countchar(self_s, self_len, from_c); - if (count > maxcount) - count = maxcount; + count = countchar(self_s, self_len, from_c, maxcount); if (count == 0) { /* no matches, return unchanged */ @@ -2933,10 +2933,7 @@ count = countstring(self_s, self_len, from_s, from_len, - 0, self_len, FORWARD); - if (count > maxcount) - count = maxcount; - + 0, self_len, FORWARD, maxcount); if (count == 0) { /* no matches, return unchanged */ return return_self(self); From python-checkins at python.org Fri May 26 22:25:23 2006 From: python-checkins at python.org (bob.ippolito) Date: Fri, 26 May 2006 22:25:23 +0200 (CEST) Subject: [Python-checkins] r46417 - in python/trunk: Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060526202523.D7B341E4018@bag.python.org> Author: bob.ippolito Date: Fri May 26 22:25:23 2006 New Revision: 46417 Modified: python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: enable all of the struct tests, use ssize_t, fix some whitespace Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Fri May 26 22:25:23 2006 @@ -323,7 +323,7 @@ else: # x is out of range -- verify pack realizes that. - if code in self.BUGGY_RANGE_CHECK: + if not PY_STRUCT_RANGE_CHECKING and code in self.BUGGY_RANGE_CHECK: if verbose: print "Skipping buggy range check for code", code else: Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Fri May 26 22:25:23 2006 @@ -3,6 +3,8 @@ /* New version supporting byte order, alignment and size options, character strings, and unsigned numbers */ +#define PY_SSIZE_T_CLEAN + #include "Python.h" #include "structseq.h" #include "structmember.h" @@ -29,8 +31,8 @@ /* The translation function for each format character is table driven */ typedef struct _formatdef { char format; - int size; - int alignment; + Py_ssize_t size; + Py_ssize_t alignment; PyObject* (*unpack)(const char *, const struct _formatdef *); int (*pack)(char *, PyObject *, @@ -39,16 +41,16 @@ typedef struct _formatcode { const struct _formatdef *fmtdef; - int offset; - int size; + Py_ssize_t offset; + Py_ssize_t size; } formatcode; /* Struct object interface */ typedef struct { PyObject_HEAD - int s_size; - int s_len; + Py_ssize_t s_size; + Py_ssize_t s_len; formatcode *s_codes; PyObject *s_format; PyObject *weakreflist; /* List of weak references */ @@ -233,11 +235,11 @@ #ifdef PY_STRUCT_RANGE_CHECKING /* Helper to format the range error exceptions */ static int -_range_error(char format, int size, int is_unsigned) +_range_error(char format, Py_ssize_t size, int is_unsigned) { if (is_unsigned == 0) { long smallest = 0, largest = 0; - int i = size * 8; + Py_ssize_t i = size * 8; while (--i > 0) { smallest = (smallest * 2) - 1; largest = (largest * 2) + 1; @@ -249,7 +251,7 @@ largest); } else { unsigned long largest = 0; - int i = size * 8; + Py_ssize_t i = size * 8; while (--i >= 0) largest = (largest * 2) + 1; PyErr_Format(StructError, @@ -265,7 +267,7 @@ /* A large number of small routines follow, with names of the form - [bln][up]_TYPE + [bln][up]_TYPE [bln] distiguishes among big-endian, little-endian and native. [pu] distiguishes between pack (to struct) and unpack (from struct). @@ -643,7 +645,7 @@ bu_int(const char *p, const formatdef *f) { long x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); @@ -657,7 +659,7 @@ bu_uint(const char *p, const formatdef *f) { unsigned long x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); @@ -676,7 +678,7 @@ { #if HAVE_LONG_LONG PY_LONG_LONG x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); @@ -701,7 +703,7 @@ { #if HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); @@ -734,7 +736,7 @@ bp_int(char *p, PyObject *v, const formatdef *f) { long x; - int i; + Py_ssize_t i; if (get_long(v, &x) < 0) return -1; i = f->size; @@ -758,7 +760,7 @@ bp_uint(char *p, PyObject *v, const formatdef *f) { unsigned long x; - int i; + Py_ssize_t i; if (get_ulong(v, &x) < 0) return -1; i = f->size; @@ -855,7 +857,7 @@ lu_int(const char *p, const formatdef *f) { long x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); @@ -869,7 +871,7 @@ lu_uint(const char *p, const formatdef *f) { unsigned long x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); @@ -888,7 +890,7 @@ { #if HAVE_LONG_LONG PY_LONG_LONG x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); @@ -913,7 +915,7 @@ { #if HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; - int i = f->size; + Py_ssize_t i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); @@ -946,7 +948,7 @@ lp_int(char *p, PyObject *v, const formatdef *f) { long x; - int i; + Py_ssize_t i; if (get_long(v, &x) < 0) return -1; i = f->size; @@ -970,7 +972,7 @@ lp_uint(char *p, PyObject *v, const formatdef *f) { unsigned long x; - int i; + Py_ssize_t i; if (get_ulong(v, &x) < 0) return -1; i = f->size; @@ -1107,7 +1109,7 @@ /* Align a size according to a format code */ static int -align(int size, int c, const formatdef *e) +align(Py_ssize_t size, char c, const formatdef *e) { if (e->format == c) { if (e->alignment) { @@ -1132,7 +1134,7 @@ const char *s; const char *fmt; char c; - int size, len, num, itemsize, x; + Py_ssize_t size, len, num, itemsize, x; fmt = PyString_AS_STRING(self->s_format); @@ -1267,7 +1269,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, &o_format)) - return -1; + return -1; Py_INCREF(o_format); Py_XDECREF(soself->s_format); @@ -1345,7 +1347,7 @@ if (inputstr == NULL || !PyString_Check(inputstr) || PyString_GET_SIZE(inputstr) != soself->s_size) { PyErr_Format(StructError, - "unpack requires a string argument of length %d", soself->s_size); + "unpack requires a string argument of length %zd", soself->s_size); return NULL; } return s_unpack_internal(soself, PyString_AS_STRING(inputstr)); @@ -1376,7 +1378,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, &buffer, &buffer_len, &offset)) - return NULL; + return NULL; if (buffer == NULL) { PyErr_Format(StructError, @@ -1389,7 +1391,7 @@ if (offset < 0 || (buffer_len - offset) < soself->s_size) { PyErr_Format(StructError, - "unpack_from requires a buffer of at least %d bytes", + "unpack_from requires a buffer of at least %zd bytes", soself->s_size); return NULL; } @@ -1479,7 +1481,7 @@ PyTuple_GET_SIZE(args) != soself->s_len) { PyErr_Format(StructError, - "pack requires exactly %d arguments", soself->s_len); + "pack requires exactly %zd arguments", soself->s_len); return NULL; } @@ -1520,29 +1522,29 @@ PyTuple_GET_SIZE(args) != (soself->s_len + 2)) { PyErr_Format(StructError, - "pack_to requires exactly %d arguments", + "pack_to requires exactly %zd arguments", (soself->s_len + 2)); return NULL; } /* Extract a writable memory buffer from the first argument */ - if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), - (void**)&buffer, &buffer_len) == -1 ) { + if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), + (void**)&buffer, &buffer_len) == -1 ) { return NULL; - } - assert( buffer_len >= 0 ); + } + assert( buffer_len >= 0 ); /* Extract the offset from the first argument */ offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1)); - /* Support negative offsets. */ + /* Support negative offsets. */ if (offset < 0) offset += buffer_len; /* Check boundaries */ if (offset < 0 || (buffer_len - offset) < soself->s_size) { PyErr_Format(StructError, - "pack_to requires a buffer of at least %d bytes", + "pack_to requires a buffer of at least %zd bytes", soself->s_size); return NULL; } @@ -1555,12 +1557,24 @@ return Py_None; } +static PyObject * +s_get_format(PyStructObject *self, void *unused) +{ + Py_INCREF(self->s_format); + return self->s_format; +} + +static PyObject * +s_get_size(PyStructObject *self, void *unused) +{ + return PyInt_FromSsize_t(self->s_size); +} /* List of functions */ static struct PyMethodDef s_methods[] = { {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, - {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, + {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ @@ -1570,17 +1584,12 @@ #define OFF(x) offsetof(PyStructObject, x) -static PyMemberDef s_memberlist[] = { - {"format", T_OBJECT, OFF(s_format), RO, - "struct format string"}, - {"size", T_INT, OFF(s_size), RO, - "struct size in bytes"}, - {"_len", T_INT, OFF(s_len), RO, - "number of items expected in tuple"}, - {NULL} /* Sentinel */ +static PyGetSetDef s_getsetlist[] = { + {"format", (getter)s_get_format, (setter)NULL, "buffer's capacity", NULL}, + {"size", (getter)s_get_size, (setter)NULL, "buffer's position", NULL}, + {NULL} /* sentinel */ }; - static PyTypeObject PyStructType = { PyObject_HEAD_INIT(NULL) @@ -1588,7 +1597,7 @@ "Struct", sizeof(PyStructObject), 0, - (destructor)s_dealloc, /* tp_dealloc */ + (destructor)s_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -1600,29 +1609,29 @@ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ - s__doc__, /* tp_doc */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS,/* tp_flags */ + s__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(PyStructObject, weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - s_methods, /* tp_methods */ - s_memberlist, /* tp_members */ - 0, /* tp_getset */ + s_methods, /* tp_methods */ + NULL, /* tp_members */ + s_getsetlist, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - s_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - s_new, /* tp_new */ - PyObject_Del, /* tp_free */ + s_init, /* tp_init */ + PyType_GenericAlloc,/* tp_alloc */ + s_new, /* tp_new */ + PyObject_Del, /* tp_free */ }; /* Module initialization */ From bob at redivi.com Fri May 26 22:30:28 2006 From: bob at redivi.com (Bob Ippolito) Date: Fri, 26 May 2006 20:30:28 +0000 Subject: [Python-checkins] r46369 - sandbox/trunk/hotbuffer/Modules/_hotbuf.c In-Reply-To: References: <20060526174701.136BE1E4010@bag.python.org> Message-ID: On May 26, 2006, at 7:50 PM, Jim Jewett wrote: > On 5/26/06, bob.ippolito wrote: >> Author: bob.ippolito >> Date: Fri May 26 19:47:00 2006 >> New Revision: 46369 >> >> Modified: >> sandbox/trunk/hotbuffer/Modules/_hotbuf.c >> Log: >> use tp_getset instead of tp_members >> >> Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c > > Are there plans for the unused pointers? > For instance, are you planning to keep different positions for reading > and writing? No. The pointers are in the function signature for tp_getset entries. -bob From python-checkins at python.org Fri May 26 22:56:56 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 22:56:56 +0200 (CEST) Subject: [Python-checkins] r46418 - python/trunk/Misc/developers.txt Message-ID: <20060526205656.F1DDA1E4006@bag.python.org> Author: tim.peters Date: Fri May 26 22:56:56 2006 New Revision: 46418 Modified: python/trunk/Misc/developers.txt Log: Record Iceland sprint attendees. Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Fri May 26 22:56:56 2006 @@ -24,6 +24,22 @@ primarily in nondist/sandbox or on a branch of their own, and will have their work reviewed before changes are accepted into the trunk. +- SVN access granted to the "Need for Speed" Iceland sprint attendees, + between May 17 and 21, 2006, by Tim Peters. All work is to be done + in new sandbox projects or on new branches, with merging to the + trunk as approved: + + Andrew Dalke + Christian Tismer + Jack Diederich + John Benediktsson + Kristján V. Jónsson + Martin Blais + Richard Emslie + Richard Jones + Runar Petursson + Steve Holden + - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. From buildbot at python.org Fri May 26 23:03:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 21:03:36 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526210337.0D2801E4006@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/818 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 23:20:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 21:20:17 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060526212017.D2FE51E401A@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/72 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Fri May 26 23:25:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 21:25:31 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060526212531.E22391E401D@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/106 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 23:26:10 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 23:26:10 +0200 (CEST) Subject: [Python-checkins] r46419 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526212610.24A991E4006@bag.python.org> Author: tim.peters Date: Fri May 26 23:26:09 2006 New Revision: 46419 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: WindowsError_new(): Removed needless initializations. Richard & Georg: this is in fact where the "an integer is required" error is coming from, via the WindowsError_new line: errcode = PyInt_AsLong(self->myerrno); self->myerrno is Py_None at this point, so PyInt_AsLong() complains. It looks like the function being called at the time was ntpath.isfile. Knowing that, I can reproduce it easily: >>> import os.path [27025 refs] >>> os.path.isfile('abc') False XXX undetected error Traceback (most recent call last): File "", line 1, in TypeError: an integer is required Note the "XXX undetected error"! That comes out of ceval.c. Your turn ;-) Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 23:26:09 2006 @@ -759,9 +759,9 @@ static PyObject * WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *o_errcode = NULL; + PyObject *o_errcode; long errcode; - PyWindowsErrorObject *self = NULL; + PyWindowsErrorObject *self; long posix_errno; self = (PyWindowsErrorObject *)EnvironmentError_new(type, args, kwds); From python-checkins at python.org Fri May 26 23:30:35 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 23:30:35 +0200 (CEST) Subject: [Python-checkins] r46420 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060526213035.78B471E4006@bag.python.org> Author: tim.peters Date: Fri May 26 23:30:35 2006 New Revision: 46420 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: WindowsError_new(): Fixed some goofy errors. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Fri May 26 23:30:35 2006 @@ -759,7 +759,7 @@ static PyObject * WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *o_errcode; + PyObject *o_errcode = NULL; long errcode; PyWindowsErrorObject *self; long posix_errno; @@ -771,8 +771,8 @@ /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ errcode = PyInt_AsLong(self->myerrno); - if (!errcode == -1 && PyErr_Occurred()) - return NULL; + if (errcode == -1 && PyErr_Occurred()) + goto failed; posix_errno = winerror_to_errno(errcode); self->winerror = self->myerrno; From buildbot at python.org Fri May 26 23:48:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 21:48:32 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060526214832.915BE1E4006@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/31 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri May 26 23:51:14 2006 From: python-checkins at python.org (tim.peters) Date: Fri, 26 May 2006 23:51:14 +0200 (CEST) Subject: [Python-checkins] r46421 - python/trunk/Tools/pybench/pybench.py Message-ID: <20060526215114.247CC1E401F@bag.python.org> Author: tim.peters Date: Fri May 26 23:51:13 2006 New Revision: 46421 Modified: python/trunk/Tools/pybench/pybench.py Log: Whitespace normalization. Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri May 26 23:51:13 2006 @@ -428,7 +428,7 @@ nosyscheck = self.values['--no-syscheck'] cruns = self.values['-C'] print "CRUNS:", cruns - + print 'PYBENCH',__version__ # Switch off GC From neal at metaslash.com Sat May 27 00:00:00 2006 From: neal at metaslash.com (Neal Norwitz) Date: Fri, 26 May 2006 18:00:00 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060526220000.GA17364@python.psfb.org> test_filecmp leaked [13, 0, 0] references test_socket leaked [1, 1, 1] references test_struct leaked [-2, -2, -2] references test_threadedtempfile leaked [-83, 0, 0] references test_threading_local leaked [91, -91, 0] references test_urllib2 leaked [143, -110, -33] references From python-checkins at python.org Sat May 27 00:17:54 2006 From: python-checkins at python.org (steve.holden) Date: Sat, 27 May 2006 00:17:54 +0200 (CEST) Subject: [Python-checkins] r46422 - python/trunk/Misc/developers.txt Message-ID: <20060526221754.D53341E4006@bag.python.org> Author: steve.holden Date: Sat May 27 00:17:54 2006 New Revision: 46422 Modified: python/trunk/Misc/developers.txt Log: Add Richard Tew to developers Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Sat May 27 00:17:54 2006 @@ -39,6 +39,7 @@ Richard Jones Runar Petursson Steve Holden + Richard M. Tew - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP update access. From steve at holdenweb.com Sat May 27 00:21:01 2006 From: steve at holdenweb.com (Steve Holden) Date: Fri, 26 May 2006 23:21:01 +0100 Subject: [Python-checkins] r46418 - python/trunk/Misc/developers.txt In-Reply-To: <20060526205656.F1DDA1E4006@bag.python.org> References: <20060526205656.F1DDA1E4006@bag.python.org> Message-ID: <44777F4D.7090806@holdenweb.com> Tim: I've added Richard Tew to the list, though I don't know whether he ever provided you with a key, as we have an agreement from him. We don't have an agreement from Martin (I'll seek one tomorrow) or Christian (whom I think has already provided one, having been a committer for a while already. regards Steve tim.peters wrote: > Author: tim.peters > Date: Fri May 26 22:56:56 2006 > New Revision: 46418 > > Modified: > python/trunk/Misc/developers.txt > Log: > Record Iceland sprint attendees. > > > Modified: python/trunk/Misc/developers.txt > ============================================================================== > --- python/trunk/Misc/developers.txt (original) > +++ python/trunk/Misc/developers.txt Fri May 26 22:56:56 2006 > @@ -24,6 +24,22 @@ > primarily in nondist/sandbox or on a branch of their own, and will > have their work reviewed before changes are accepted into the trunk. > > +- SVN access granted to the "Need for Speed" Iceland sprint attendees, > + between May 17 and 21, 2006, by Tim Peters. All work is to be done > + in new sandbox projects or on new branches, with merging to the > + trunk as approved: > + > + Andrew Dalke > + Christian Tismer > + Jack Diederich > + John Benediktsson > + Kristj?n V. J?nsson > + Martin Blais > + Richard Emslie > + Richard Jones > + Runar Petursson > + Steve Holden > + > - Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP > update access. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From python-checkins at python.org Sat May 27 00:33:20 2006 From: python-checkins at python.org (steve.holden) Date: Sat, 27 May 2006 00:33:20 +0200 (CEST) Subject: [Python-checkins] r46423 - python/trunk/Tools/pybench/README python/trunk/Tools/pybench/pybench.py Message-ID: <20060526223320.A14EB1E4006@bag.python.org> Author: steve.holden Date: Sat May 27 00:33:20 2006 New Revision: 46423 Modified: python/trunk/Tools/pybench/README python/trunk/Tools/pybench/pybench.py Log: Update help text and documentaition. Modified: python/trunk/Tools/pybench/README ============================================================================== --- python/trunk/Tools/pybench/README (original) +++ python/trunk/Tools/pybench/README Sat May 27 00:33:20 2006 @@ -46,6 +46,9 @@ -w arg set warp factor to arg (20) -d hide noise in compares (0) --no-gc disable garbage collection (0) + --no-syscheck "disable" sys check interval (set to sys.maxint) (0) + -t arg tests containing substring () + -C arg number of calibration runs (20) -v generate verbose output -h show this help text --help show this help text @@ -366,6 +369,14 @@ automatically add them to the benchmark suite. +Breaking Comparability +---------------------- + +If a change is made to any individual test that means it is no +longer strcitly comparable with previous runs, the '.version' class +variable should be updated. Therefafter, comparisons with previous +versions of the test will list as "n/a" to reflect the change. + Have fun, -- Marc-Andre Lemburg Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Sat May 27 00:33:20 2006 @@ -382,7 +382,7 @@ SwitchOption('--no-syscheck', '"disable" sys check interval (set to sys.maxint)', 0), ArgumentOption('-t', 'tests containing substring', ''), - ArgumentOption('-C', 'number of calibration runs (default 20)', 20) + ArgumentOption('-C', 'number of calibration runs', 20) ] about = """\ From tim.peters at gmail.com Sat May 27 00:38:44 2006 From: tim.peters at gmail.com (Tim Peters) Date: Fri, 26 May 2006 22:38:44 +0000 Subject: [Python-checkins] r46418 - python/trunk/Misc/developers.txt In-Reply-To: <44777F4D.7090806@holdenweb.com> References: <20060526205656.F1DDA1E4006@bag.python.org> <44777F4D.7090806@holdenweb.com> Message-ID: <1f7befae0605261538j4d98a7e1rb13cac76694ee517@mail.gmail.com> [Steve Holden] > I've added Richard Tew to the list, though I don't know whether he ever > provided you with a key, as we have an agreement from him. MvL added Richard on 10 April, atlhough it looks like he didn't add a note to developers.txt about that. > We don't have an agreement from Martin (I'll seek one tomorrow) Or we kill him ;-) > or Christian (whom I think has already provided one, having been a > committer for a while already. Christian's fine already; he just hadn't bothered to transfer his commit privs from SourceForge before now. In short, everyone's fine save Martin. From python-checkins at python.org Sat May 27 00:39:28 2006 From: python-checkins at python.org (steve.holden) Date: Sat, 27 May 2006 00:39:28 +0200 (CEST) Subject: [Python-checkins] r46424 - python/trunk/Tools/pybench/README Message-ID: <20060526223928.30B3B1E4006@bag.python.org> Author: steve.holden Date: Sat May 27 00:39:27 2006 New Revision: 46424 Modified: python/trunk/Tools/pybench/README Log: Blasted typos ... Modified: python/trunk/Tools/pybench/README ============================================================================== --- python/trunk/Tools/pybench/README (original) +++ python/trunk/Tools/pybench/README Sat May 27 00:39:27 2006 @@ -373,7 +373,7 @@ ---------------------- If a change is made to any individual test that means it is no -longer strcitly comparable with previous runs, the '.version' class +longer strictly comparable with previous runs, the '.version' class variable should be updated. Therefafter, comparisons with previous versions of the test will list as "n/a" to reflect the change. From buildbot at python.org Sat May 27 00:44:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 22:44:28 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060526224428.E5E4C1E4006@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/821 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: steve.holden Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 00:49:03 2006 From: python-checkins at python.org (andrew.dalke) Date: Sat, 27 May 2006 00:49:03 +0200 (CEST) Subject: [Python-checkins] r46425 - python/trunk/Objects/stringobject.c Message-ID: <20060526224903.DEC111E4006@bag.python.org> Author: andrew.dalke Date: Sat May 27 00:49:03 2006 New Revision: 46425 Modified: python/trunk/Objects/stringobject.c Log: Added description of why splitlines doesn't use the prealloc strategy Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 27 00:49:03 2006 @@ -3768,6 +3768,14 @@ data = PyString_AS_STRING(self); len = PyString_GET_SIZE(self); + /* This does not use the preallocated list because splitlines is + usually run with hundreds of newlines. The overhead of + switching between PyList_SET_ITEM and append causes about a + 2-3% slowdown for that common case. A smarter implementation + could move the if check out, so the SET_ITEMs are done first + and the appends only done when the prealloc buffer is full. + That's too much work for little gain.*/ + list = PyList_New(0); if (!list) goto onError; From python-checkins at python.org Sat May 27 01:14:38 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 01:14:38 +0200 (CEST) Subject: [Python-checkins] r46426 - in python/trunk: Include/frameobject.h Python/ceval.c Message-ID: <20060526231438.AE8921E4006@bag.python.org> Author: tim.peters Date: Sat May 27 01:14:37 2006 New Revision: 46426 Modified: python/trunk/Include/frameobject.h python/trunk/Python/ceval.c Log: Patch 1145039. set_exc_info(), reset_exc_info(): By exploiting the likely (who knows?) invariant that when an exception's `type` is NULL, its `value` and `traceback` are also NULL, save some cycles in heavily-executed code. This is a "a kronar saved is a kronar earned" patch: the speedup isn't reliably measurable, but it obviously does reduce the operation count in the normal (no exception raised) path through PyEval_EvalFrameEx(). The tim-exc_sanity branch tries to push this harder, but is still blowing up (at least in part due to pre-existing subtle bugs that appear to have no other visible consequences!). Not a bugfix candidate. Modified: python/trunk/Include/frameobject.h ============================================================================== --- python/trunk/Include/frameobject.h (original) +++ python/trunk/Include/frameobject.h Sat May 27 01:14:37 2006 @@ -26,7 +26,16 @@ to the current stack top. */ PyObject **f_stacktop; PyObject *f_trace; /* Trace function */ + + /* If an exception is raised in this frame, the next three are used to + * record the exception info (if any) originally in the thread state. See + * comments before set_exc_info() -- it's not obvious. + * Invariant: if _type is NULL, then so are _value and _traceback. + * Desired invariant: all three are NULL, or all three are non-NULL. That + * one isn't currently true, but "should be". + */ PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; + PyThreadState *f_tstate; int f_lasti; /* Last instruction if called */ /* As of 2.3 f_lineno is only valid when tracing is active (i.e. when Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Sat May 27 01:14:37 2006 @@ -24,7 +24,7 @@ #pragma optimize("agtw", on) #endif -#ifndef WITH_TSC +#ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -49,7 +49,7 @@ asm volatile ("mftbu %0" : "=r" (tbu2)); if (__builtin_expect(tbu != tbu2, 0)) goto loop; - /* The slightly peculiar way of writing the next lines is + /* The slightly peculiar way of writing the next lines is compiled better by GCC than any other way I tried. */ ((long*)(v))[0] = tbu; ((long*)(v))[1] = tb; @@ -62,7 +62,7 @@ #endif -void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, +void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, uint64 loop0, uint64 loop1, uint64 intr0, uint64 intr1) { uint64 intr, inst, loop; @@ -567,7 +567,7 @@ inst0 -- beginning of switch statement for opcode dispatch inst1 -- end of switch statement (may be skipped) loop0 -- the top of the mainloop - loop1 -- place where control returns again to top of mainloop + loop1 -- place where control returns again to top of mainloop (may be skipped) intr1 -- beginning of long interruption intr2 -- end of long interruption @@ -768,7 +768,7 @@ why = WHY_EXCEPTION; goto on_error; } - + for (;;) { #ifdef WITH_TSC if (inst1 == 0) { @@ -2218,7 +2218,7 @@ re-raising the exception. (But non-local gotos should still be resumed.) */ - + x = TOP(); u = SECOND(); if (PyInt_Check(u) || u == Py_None) { @@ -2581,7 +2581,12 @@ } } - reset_exc_info(tstate); + if (tstate->frame->f_exc_type != NULL) + reset_exc_info(tstate); + else { + assert(tstate->frame->f_exc_value == NULL); + assert(tstate->frame->f_exc_traceback == NULL); + } /* pop frame */ exit_eval_frame: @@ -2846,6 +2851,7 @@ - Once an exception is caught by an except clause, it is transferred from tstate->curexc_ZZZ to tstate->exc_ZZZ, from which sys.exc_info() can pick it up. This is the primary task of set_exc_info(). + XXX That can't be right: set_exc_info() doesn't look at tstate->curexc_ZZZ. - Now let me explain the complicated dance with frame->f_exc_ZZZ. @@ -2900,33 +2906,33 @@ set_exc_info(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyFrameObject *frame; + PyFrameObject *frame = tstate->frame; PyObject *tmp_type, *tmp_value, *tmp_tb; - frame = tstate->frame; + assert(type != NULL); + assert(frame != NULL); if (frame->f_exc_type == NULL) { - /* This frame didn't catch an exception before */ - /* Save previous exception of this thread in this frame */ + assert(frame->f_exc_value == NULL); + assert(frame->f_exc_traceback == NULL); + /* This frame didn't catch an exception before. */ + /* Save previous exception of this thread in this frame. */ if (tstate->exc_type == NULL) { + /* XXX Why is this set to Py_None? */ Py_INCREF(Py_None); tstate->exc_type = Py_None; } - tmp_value = frame->f_exc_value; - tmp_tb = frame->f_exc_traceback; - Py_XINCREF(tstate->exc_type); + Py_INCREF(tstate->exc_type); Py_XINCREF(tstate->exc_value); Py_XINCREF(tstate->exc_traceback); frame->f_exc_type = tstate->exc_type; frame->f_exc_value = tstate->exc_value; frame->f_exc_traceback = tstate->exc_traceback; - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); } - /* Set new exception for this thread */ + /* Set new exception for this thread. */ tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; - Py_XINCREF(type); + Py_INCREF(type); Py_XINCREF(value); Py_XINCREF(tb); tstate->exc_type = type; @@ -2946,33 +2952,42 @@ { PyFrameObject *frame; PyObject *tmp_type, *tmp_value, *tmp_tb; + + /* It's a precondition that the thread state's frame caught an + * exception -- verify in a debug build. + */ + assert(tstate != NULL); frame = tstate->frame; - if (frame->f_exc_type != NULL) { - /* This frame caught an exception */ - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - Py_INCREF(frame->f_exc_type); - Py_XINCREF(frame->f_exc_value); - Py_XINCREF(frame->f_exc_traceback); - tstate->exc_type = frame->f_exc_type; - tstate->exc_value = frame->f_exc_value; - tstate->exc_traceback = frame->f_exc_traceback; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", frame->f_exc_type); - PySys_SetObject("exc_value", frame->f_exc_value); - PySys_SetObject("exc_traceback", frame->f_exc_traceback); - } + assert(frame != NULL); + assert(frame->f_exc_type != NULL); + + /* Copy the frame's exception info back to the thread state. */ + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + Py_INCREF(frame->f_exc_type); + Py_XINCREF(frame->f_exc_value); + Py_XINCREF(frame->f_exc_traceback); + tstate->exc_type = frame->f_exc_type; + tstate->exc_value = frame->f_exc_value; + tstate->exc_traceback = frame->f_exc_traceback; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); + + /* For b/w compatibility */ + PySys_SetObject("exc_type", frame->f_exc_type); + PySys_SetObject("exc_value", frame->f_exc_value); + PySys_SetObject("exc_traceback", frame->f_exc_traceback); + + /* Clear the frame's exception info. */ tmp_type = frame->f_exc_type; tmp_value = frame->f_exc_value; tmp_tb = frame->f_exc_traceback; frame->f_exc_type = NULL; frame->f_exc_value = NULL; frame->f_exc_traceback = NULL; - Py_XDECREF(tmp_type); + Py_DECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } @@ -3846,7 +3861,7 @@ Py_ssize_t x; if (PyInt_Check(v)) { x = PyInt_AsSsize_t(v); - } + } else if (v->ob_type->tp_as_number && PyType_HasFeature(v->ob_type, Py_TPFLAGS_HAVE_INDEX) && v->ob_type->tp_as_number->nb_index) { @@ -4064,7 +4079,7 @@ result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); Py_DECREF(metaclass); if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { - /* A type error here likely means that the user passed + /* A type error here likely means that the user passed in a base that was not a class (such the random module instead of the random.random type). Help them out with by augmenting the error message with more information.*/ @@ -4204,7 +4219,7 @@ { /* This function implements 'variable += expr' when both arguments are strings. */ - + if (v->ob_refcnt == 2) { /* In the common case, there are 2 references to the value * stored in 'variable' when the += is performed: one on the From amk at amk.ca Sat May 27 01:35:39 2006 From: amk at amk.ca (A.M. Kuchling) Date: Fri, 26 May 2006 19:35:39 -0400 Subject: [Python-checkins] r46250 - sandbox/trunk/Doc/functional.rst In-Reply-To: <44761A9F.8030500@ewtllc.com> References: <20060525200704.E23961E400B@bag.python.org> <44761A9F.8030500@ewtllc.com> Message-ID: <20060526233539.GB28149@rogue.amk.ca> On Thu, May 25, 2006 at 01:59:11PM -0700, Raymond Hettinger wrote: > Inserted below are a few ideas that you may or may not want to include > as part of a tutorial of functionals. Thanks! I'll save a copy of your posting for reference when I start writing larger examples. My current plan is to finish the itertools section and then write a section on map/filter/reduce/lambda that also uses small trivial examples as illustrations. Once those sections are complete, a final section will examine an entire program in functional style (haven't decided what this program will do yet). It's unlikely that I can construct an application that allows showing every possible use of the itertools. Maybe there should be a cookbook section. Or maybe it's better to put such things on ActiveState's cookbook site. Hm. --amk From tjreedy at udel.edu Fri May 26 19:25:03 2006 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 26 May 2006 13:25:03 -0400 Subject: [Python-checkins] This References: <44762E77.3080303@ewtllc.com><44763168.4030308@holdenweb.com> <44763487.3080908@ewtllc.com> Message-ID: "Facundo Batista" wrote in message news:e04bdf310605260828q7e5cb00mf97ee0d95fc094e8 at mail.gmail.com... > Just end user experience's two cents here > (btw, this line is correct at English level?) Since you asked...your question would be better written "is this line correct English?" And the line before, while not formal English of the kind needed, say, for Decimal docs, works well enough for me as an expression of an informal conversational thought. > Maybe should exist some "quick measure method" like, Maybe *there* should.... [This is one situation where English is wordier than, for instance, Spanish.] Terry Jan Reedy From buildbot at python.org Sat May 27 01:32:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 26 May 2006 23:32:32 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060526233232.A1AA31E400C@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/814 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,steve.holden Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 02:32:41 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 27 May 2006 02:32:41 +0200 (CEST) Subject: [Python-checkins] r46427 - sandbox/trunk/Doc/functional.rst Message-ID: <20060527003241.B378B1E4006@bag.python.org> Author: andrew.kuchling Date: Sat May 27 02:32:40 2006 New Revision: 46427 Modified: sandbox/trunk/Doc/functional.rst Log: Describe more functions Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Sat May 27 02:32:40 2006 @@ -725,14 +725,54 @@ => /usr/bin/java, /bin/python, /usr/bin/perl, /usr/bin/ruby +Another group of functions chooses a subset of an iterator's elements +based on a **predicate**, a function that returns the truth value of +some condition. + +``itertools.ifilter(predicate, iter)`` returns all the elements for +which the predicate returns true:: + + def is_even(x): + return (x % 2) == 0 + + itertools.ifilter(is_even, itertools.count()) => + 0, 2, 4, 6, 8, 10, 12, 14, ... + +``itertools.ifilterfalse(predicate, iter)`` is the opposite, +returning all elements for which the predicate returns false:: + + itertools.ifilterfalse(is_even, itertools.count()) => + 1, 3, 5, 7, 9, 11, 13, 15, ... + +``itertools.takewhile(predicate, iter)`` returns elements for as long +as the predicate returns true. Once the predicate returns false, +the iterator will signal the end of its results. + +:: + + def less_than_10(x): + return (x < 10) + + itertools.takewhile(less_than_10, itertools.count()) => + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +``itertools.dropwhile(predicate, iter)`` discards elements while the +predicate returns true, and then returns the rest of the iterable's +results. + +:: + + itertools.dropwhile(less_than_10, itertools.count()) => + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... + + + + + .. comment - ifilter - ifilterfalse - takewhile - dropwhile groupby From python-checkins at python.org Sat May 27 02:49:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 27 May 2006 02:49:18 +0200 (CEST) Subject: [Python-checkins] r46428 - sandbox/trunk/Doc/functional.rst Message-ID: <20060527004918.E422C1E4006@bag.python.org> Author: andrew.kuchling Date: Sat May 27 02:49:18 2006 New Revision: 46428 Modified: sandbox/trunk/Doc/functional.rst Log: Describe groupby() Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Sat May 27 02:49:18 2006 @@ -766,14 +766,44 @@ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... - - - - - -.. comment - - groupby +The last function, ``itertools.groupby(iter, key_func=None)``, is the +most complicated. ``key_func(elem)`` is a function that can compute a +key value for each element returned by the iterable. If you don't +supply a key function, the key is simply each element itself. + +``groupby()`` collects all the consecutive elements from the +underlying iterable that have the same key value, and returns a stream +of 2-tuples containing a key value and an iterator for the elements +with that key. + +:: + + city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'), + ('Anchorage', 'AK'), ('Nome', 'AK'), + ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'), + ... + ] + + def get_state ((city, state)): + return state + + itertools.groupby(city_list, get_state) => + ('AL', iterator-1), + ('AK', iterator-2), + ('AZ', iterator-3), ... + + where + iterator-1 => + ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL') + iterator-2 => + ('Anchorage', 'AK'), ('Nome', 'AK') + iterator-3 => + ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ') + +``groupby()`` assumes that the underlying iterable's contents will +already be sorted based on the key. Note that the returned iterators +also use the underlying iterable, so you have to consume the results +of iterator-1 before requesting iterator-2 and its corresponding key. Built-in functions @@ -787,7 +817,7 @@ XXX -The functools modules +The functools module ---------------------------------------------- .. comment From python-checkins at python.org Sat May 27 02:51:52 2006 From: python-checkins at python.org (steve.holden) Date: Sat, 27 May 2006 02:51:52 +0200 (CEST) Subject: [Python-checkins] r46429 - python/trunk/Tools/pybench/NewInstances.py Message-ID: <20060527005152.D348C1E4006@bag.python.org> Author: steve.holden Date: Sat May 27 02:51:52 2006 New Revision: 46429 Added: python/trunk/Tools/pybench/NewInstances.py (contents, props changed) Log: Reinstate new-style object tests. Added: python/trunk/Tools/pybench/NewInstances.py ============================================================================== --- (empty file) +++ python/trunk/Tools/pybench/NewInstances.py Sat May 27 02:51:52 2006 @@ -0,0 +1,66 @@ +from pybench import Test + +class CreateNewInstances(Test): + + version = 0.1 + operations = 3 + 7 + 4 + rounds = 60000 + + def test(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + o = c() + o1 = c() + o2 = c() + p = d(i,i,3) + p1 = d(i,i,3) + p2 = d(i,3,3) + p3 = d(3,i,3) + p4 = d(i,i,i) + p5 = d(3,i,3) + p6 = d(i,i,i) + q = e(i,i,3) + q1 = e(i,i,3) + q2 = e(i,i,3) + q3 = e(i,i) + + def calibrate(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + pass From steve at holdenweb.com Sat May 27 03:19:16 2006 From: steve at holdenweb.com (Steve Holden) Date: Sat, 27 May 2006 02:19:16 +0100 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk In-Reply-To: <20060526224428.E5E4C1E4006@bag.python.org> References: <20060526224428.E5E4C1E4006@bag.python.org> Message-ID: <4477A914.9060105@holdenweb.com> buildbot at python.org wrote: > The Buildbot has detected a new failure of x86 W2k trunk. > Full details are available at: > http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/821 > > Buildbot URL: http://www.python.org/dev/buildbot/all/ > > Build Reason: > Build Source Stamp: [branch trunk] HEAD > Blamelist: steve.holden > > Build Had Warnings: warnings test > > sincerely, > -The Buildbot > Right. I change Misc/developers.txt and suddenly the test breakage is *my* fault? That's hard. Personally, I blame Trent Mick. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden From nnorwitz at gmail.com Sat May 27 03:33:47 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 26 May 2006 18:33:47 -0700 Subject: [Python-checkins] r46297 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: <20060526115410.4378E1E4010@bag.python.org> References: <20060526115410.4378E1E4010@bag.python.org> Message-ID: On 5/26/06, fredrik.lundh wrote: > Author: fredrik.lundh > Date: Fri May 26 13:54:04 2006 > New Revision: 46297 > > Modified: python/trunk/Include/pyport.h > ============================================================================== > --- python/trunk/Include/pyport.h (original) > +++ python/trunk/Include/pyport.h Fri May 26 13:54:04 2006 > @@ -149,6 +153,10 @@ > #undef USE_INLINE /* XXX - set via configure? */ > > #if defined(_MSC_VER) > +#if defined(PY_LOCAL_AGGRESSIVE) > +/* enable more aggressive optimization for visual studio */ > +#pragma optimize("agtw", on) > +#endif > /* ignore warnings if the compiler decides not to inline a function */ > #pragma warning(disable: 4710) > /* fastest possible local call under MSVC */ > > Modified: python/trunk/Python/ceval.c > ============================================================================== > --- python/trunk/Python/ceval.c (original) > +++ python/trunk/Python/ceval.c Fri May 26 13:54:04 2006 > @@ -6,6 +6,9 @@ > XXX document it! > */ > > +/* enable more aggressive local inlining (platform dependent) */ > +#define PY_LOCAL_AGGRESSIVE > + > #include "Python.h" > > #include "code.h" > @@ -16,6 +19,11 @@ > > #include > > +#if defined(_MSC_VER) > +/* enable more aggressive optimization for visual studio */ > +#pragma optimize("agtw", on) > +#endif > + > #ifndef WITH_TSC > > #define READ_TIMESTAMP(var) Since the pragma was aded in pyport.h, is it also necessary here in ceval.c? n From python-checkins at python.org Sat May 27 07:18:57 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 27 May 2006 07:18:57 +0200 (CEST) Subject: [Python-checkins] r46430 - python/trunk/Modules/itertoolsmodule.c Message-ID: <20060527051857.BFF421E4006@bag.python.org> Author: neal.norwitz Date: Sat May 27 07:18:57 2006 New Revision: 46430 Modified: python/trunk/Modules/itertoolsmodule.c Log: Fix compiler warning (and whitespace) on Mac OS 10.4. (A lot of this code looked duplicated, I wonder if a utility function could help reduce the duplication here.) Modified: python/trunk/Modules/itertoolsmodule.c ============================================================================== --- python/trunk/Modules/itertoolsmodule.c (original) +++ python/trunk/Modules/itertoolsmodule.c Sat May 27 07:18:57 2006 @@ -1621,7 +1621,7 @@ /* obtain iterators */ assert(PyTuple_Check(args)); ittuple = PyTuple_New(tuplesize); - if(ittuple == NULL) + if (ittuple == NULL) return NULL; for (i=0; i < tuplesize; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); @@ -1629,7 +1629,7 @@ if (it == NULL) { if (PyErr_ExceptionMatches(PyExc_TypeError)) PyErr_Format(PyExc_TypeError, - "chain argument #%d must support iteration", + "chain argument #%zd must support iteration", i+1); Py_DECREF(ittuple); return NULL; @@ -2151,7 +2151,7 @@ /* obtain iterators */ ittuple = PyTuple_New(tuplesize); - if(ittuple == NULL) + if (ittuple == NULL) return NULL; for (i=0; i < tuplesize; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); @@ -2159,7 +2159,7 @@ if (it == NULL) { if (PyErr_ExceptionMatches(PyExc_TypeError)) PyErr_Format(PyExc_TypeError, - "izip argument #%d must support iteration", + "izip argument #%zd must support iteration", i+1); Py_DECREF(ittuple); return NULL; From python-checkins at python.org Sat May 27 07:21:30 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 27 May 2006 07:21:30 +0200 (CEST) Subject: [Python-checkins] r46431 - in python/trunk/Objects: stringlib/partition.h unicodeobject.c Message-ID: <20060527052130.EEEE51E401C@bag.python.org> Author: neal.norwitz Date: Sat May 27 07:21:30 2006 New Revision: 46431 Modified: python/trunk/Objects/stringlib/partition.h python/trunk/Objects/unicodeobject.c Log: Fix Coverity warnings. - Check the correct variable (str_obj, not str) for NULL - sep_len was already verified it wasn't 0 Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Sat May 27 07:21:30 2006 @@ -58,7 +58,7 @@ ) { PyObject* out; - Py_ssize_t pos; + Py_ssize_t pos, j; if (sep_len == 0) { PyErr_SetString(PyExc_ValueError, "empty separator"); @@ -70,17 +70,12 @@ return NULL; /* XXX - create reversefastsearch helper! */ - if (sep_len == 0) - pos = str_len; - else { - Py_ssize_t j; pos = -1; for (j = str_len - sep_len; j >= 0; --j) if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) { pos = j; break; } - } if (pos < 0) { Py_INCREF(str_obj); Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 07:21:30 2006 @@ -3955,7 +3955,7 @@ PyUnicodeObject* sub_obj; str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str); - if (!str) + if (!str_obj) return -2; sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); if (!sub_obj) { From martin at v.loewis.de Sat May 27 08:28:20 2006 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sat, 27 May 2006 08:28:20 +0200 Subject: [Python-checkins] r46418 - python/trunk/Misc/developers.txt In-Reply-To: <44777F4D.7090806@holdenweb.com> References: <20060526205656.F1DDA1E4006@bag.python.org> <44777F4D.7090806@holdenweb.com> Message-ID: <4477F184.3090706@v.loewis.de> Steve Holden wrote: > I've added Richard Tew to the list, though I don't know whether he ever > provided you with a key, as we have an agreement from him. We don't have > an agreement from Martin (I'll seek one tomorrow) or Christian (whom I > think has already provided one, having been a committer for a while already. He got access to the repository because he needs to write to Stackless. Whether he also wants/needs to write to Python, I don't know. Regards, Martin From buildbot at python.org Sat May 27 08:37:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 27 May 2006 06:37:07 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060527063707.37A571E4006@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/555 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 10:36:54 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 27 May 2006 10:36:54 +0200 (CEST) Subject: [Python-checkins] r46432 - in python/trunk: Doc/api/concrete.tex Lib/test/test_unicodedata.py Misc/NEWS Modules/unicodedata.c Objects/unicodectype.c Objects/unicodeobject.c Message-ID: <20060527083654.2C0041E4006@bag.python.org> Author: martin.v.loewis Date: Sat May 27 10:36:52 2006 New Revision: 46432 Modified: python/trunk/Doc/api/concrete.tex python/trunk/Lib/test/test_unicodedata.py python/trunk/Misc/NEWS python/trunk/Modules/unicodedata.c python/trunk/Objects/unicodectype.c python/trunk/Objects/unicodeobject.c Log: Patch 1494554: Update numeric properties to Unicode 4.1. Modified: python/trunk/Doc/api/concrete.tex ============================================================================== --- python/trunk/Doc/api/concrete.tex (original) +++ python/trunk/Doc/api/concrete.tex Sat May 27 10:36:52 2006 @@ -965,7 +965,7 @@ \end{cfuncdesc} \begin{cfuncdesc}{double}{Py_UNICODE_TONUMERIC}{Py_UNICODE ch} - Return the character \var{ch} converted to a (positive) double. + Return the character \var{ch} converted to a double. Return \code{-1.0} if this is not possible. This macro does not raise exceptions. \end{cfuncdesc} Modified: python/trunk/Lib/test/test_unicodedata.py ============================================================================== --- python/trunk/Lib/test/test_unicodedata.py (original) +++ python/trunk/Lib/test/test_unicodedata.py Sat May 27 10:36:52 2006 @@ -16,7 +16,7 @@ class UnicodeMethodsTest(unittest.TestCase): # update this, if the database changes - expectedchecksum = 'a6555cd209d960dcfa17bfdce0c96d91cfa9a9ba' + expectedchecksum = 'c198ed264497f108434b3f576d4107237221cc8a' def test_method_checksum(self): h = hashlib.sha1() @@ -75,7 +75,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest): # update this, if the database changes - expectedchecksum = 'b45b79f3203ee1a896d9b5655484adaff5d4964b' + expectedchecksum = '4e389f97e9f88b8b7ab743121fd643089116f9f2' def test_function_checksum(self): data = [] Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat May 27 10:36:52 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Patch #1494554: Update unicodedata.numeric and unicode.isnumeric to + Unicode 4.1. + - Patch #921466: sys.path_importer_cache is now used to cache valid and invalid file paths for the built-in import machinery which leads to fewer open calls on startup. Modified: python/trunk/Modules/unicodedata.c ============================================================================== --- python/trunk/Modules/unicodedata.c (original) +++ python/trunk/Modules/unicodedata.c Sat May 27 10:36:52 2006 @@ -209,7 +209,7 @@ if (old->category_changed == 0) { /* unassigned */ have_old = 1; - rc = -1; + rc = -1.0; } else if (old->decimal_changed != 0xFF) { have_old = 1; @@ -219,7 +219,7 @@ if (!have_old) rc = Py_UNICODE_TONUMERIC(*PyUnicode_AS_UNICODE(v)); - if (rc < 0) { + if (rc == -1.0) { if (defobj == NULL) { PyErr_SetString(PyExc_ValueError, "not a numeric character"); return NULL; Modified: python/trunk/Objects/unicodectype.c ============================================================================== --- python/trunk/Objects/unicodectype.c (original) +++ python/trunk/Objects/unicodectype.c Sat May 27 10:36:52 2006 @@ -140,20 +140,48 @@ double _PyUnicode_ToNumeric(Py_UNICODE ch) { switch (ch) { + case 0x0F33: + return (double) -1 / 2; + case 0x17F0: case 0x3007: +#ifdef Py_UNICODE_WIDE + case 0x1018A: +#endif return (double) 0; case 0x09F4: + case 0x17F1: case 0x215F: case 0x2160: case 0x2170: case 0x3021: + case 0x3192: + case 0x3220: case 0x3280: +#ifdef Py_UNICODE_WIDE + case 0x10107: + case 0x10142: + case 0x10158: + case 0x10159: + case 0x1015A: + case 0x10320: + case 0x103D1: +#endif return (double) 1; case 0x00BD: + case 0x0F2A: + case 0x2CFD: +#ifdef Py_UNICODE_WIDE + case 0x10141: + case 0x10175: + case 0x10176: +#endif return (double) 1 / 2; case 0x2153: return (double) 1 / 3; case 0x00BC: +#ifdef Py_UNICODE_WIDE + case 0x10140: +#endif return (double) 1 / 4; case 0x2155: return (double) 1 / 5; @@ -168,92 +196,201 @@ case 0x2469: case 0x247D: case 0x2491: + case 0x24FE: case 0x277F: case 0x2789: case 0x2793: case 0x3038: + case 0x3229: case 0x3289: +#ifdef Py_UNICODE_WIDE + case 0x10110: + case 0x10149: + case 0x10150: + case 0x10157: + case 0x10160: + case 0x10161: + case 0x10162: + case 0x10163: + case 0x10164: + case 0x10322: + case 0x103D3: + case 0x10A44: +#endif return (double) 10; case 0x0BF1: case 0x137B: case 0x216D: case 0x217D: +#ifdef Py_UNICODE_WIDE + case 0x10119: + case 0x1014B: + case 0x10152: + case 0x1016A: + case 0x103D5: + case 0x10A46: +#endif return (double) 100; case 0x0BF2: case 0x216F: case 0x217F: case 0x2180: +#ifdef Py_UNICODE_WIDE + case 0x10122: + case 0x1014D: + case 0x10154: + case 0x10171: + case 0x10A47: +#endif return (double) 1000; case 0x137C: case 0x2182: +#ifdef Py_UNICODE_WIDE + case 0x1012B: + case 0x10155: +#endif return (double) 10000; case 0x216A: case 0x217A: case 0x246A: case 0x247E: case 0x2492: + case 0x24EB: return (double) 11; + case 0x0F2F: + return (double) 11 / 2; case 0x216B: case 0x217B: case 0x246B: case 0x247F: case 0x2493: + case 0x24EC: return (double) 12; case 0x246C: case 0x2480: case 0x2494: + case 0x24ED: return (double) 13; + case 0x0F30: + return (double) 13 / 2; case 0x246D: case 0x2481: case 0x2495: + case 0x24EE: return (double) 14; case 0x246E: case 0x2482: case 0x2496: + case 0x24EF: return (double) 15; + case 0x0F31: + return (double) 15 / 2; case 0x09F9: case 0x246F: case 0x2483: case 0x2497: + case 0x24F0: return (double) 16; case 0x16EE: case 0x2470: case 0x2484: case 0x2498: + case 0x24F1: return (double) 17; + case 0x0F32: + return (double) 17 / 2; case 0x16EF: case 0x2471: case 0x2485: case 0x2499: + case 0x24F2: return (double) 18; case 0x16F0: case 0x2472: case 0x2486: case 0x249A: + case 0x24F3: return (double) 19; case 0x09F5: + case 0x17F2: case 0x2161: case 0x2171: case 0x3022: + case 0x3193: + case 0x3221: case 0x3281: +#ifdef Py_UNICODE_WIDE + case 0x10108: + case 0x1015B: + case 0x1015C: + case 0x1015D: + case 0x1015E: + case 0x103D2: +#endif return (double) 2; case 0x2154: +#ifdef Py_UNICODE_WIDE + case 0x10177: +#endif return (double) 2 / 3; case 0x2156: - return (double) 2 / 5; + return (double) 2 / 5; case 0x1373: case 0x2473: case 0x2487: case 0x249B: + case 0x24F4: case 0x3039: - return (double) 20; +#ifdef Py_UNICODE_WIDE + case 0x10111: + case 0x103D4: + case 0x10A45: +#endif + return (double) 20; +#ifdef Py_UNICODE_WIDE + case 0x1011A: + return (double) 200; + case 0x10123: + return (double) 2000; + case 0x1012C: + return (double) 20000; +#endif + case 0x3251: + return (double) 21; + case 0x3252: + return (double) 22; + case 0x3253: + return (double) 23; + case 0x3254: + return (double) 24; + case 0x3255: + return (double) 25; + case 0x3256: + return (double) 26; + case 0x3257: + return (double) 27; + case 0x3258: + return (double) 28; + case 0x3259: + return (double) 29; case 0x09F6: + case 0x17F3: case 0x2162: case 0x2172: case 0x3023: + case 0x3194: + case 0x3222: case 0x3282: +#ifdef Py_UNICODE_WIDE + case 0x10109: +#endif return (double) 3; + case 0x0F2B: + return (double) 3 / 2; case 0x00BE: +#ifdef Py_UNICODE_WIDE + case 0x10178: +#endif return (double) 3 / 4; case 0x2157: return (double) 3 / 5; @@ -261,22 +398,103 @@ return (double) 3 / 8; case 0x1374: case 0x303A: + case 0x325A: +#ifdef Py_UNICODE_WIDE + case 0x10112: + case 0x10165: +#endif return (double) 30; +#ifdef Py_UNICODE_WIDE + case 0x1011B: + case 0x1016B: + return (double) 300; + case 0x10124: + return (double) 3000; + case 0x1012D: + return (double) 30000; +#endif + case 0x325B: + return (double) 31; + case 0x325C: + return (double) 32; + case 0x325D: + return (double) 33; + case 0x325E: + return (double) 34; + case 0x325F: + return (double) 35; + case 0x32B1: + return (double) 36; + case 0x32B2: + return (double) 37; + case 0x32B3: + return (double) 38; + case 0x32B4: + return (double) 39; case 0x09F7: + case 0x17F4: case 0x2163: case 0x2173: case 0x3024: + case 0x3195: + case 0x3223: case 0x3283: +#ifdef Py_UNICODE_WIDE + case 0x1010A: +#endif return (double) 4; case 0x2158: return (double) 4 / 5; case 0x1375: - return (double) 40; + case 0x32B5: +#ifdef Py_UNICODE_WIDE + case 0x10113: +#endif + return (double) 40; +#ifdef Py_UNICODE_WIDE + case 0x1011C: + return (double) 400; + case 0x10125: + return (double) 4000; + case 0x1012E: + return (double) 40000; +#endif + case 0x32B6: + return (double) 41; + case 0x32B7: + return (double) 42; + case 0x32B8: + return (double) 43; + case 0x32B9: + return (double) 44; + case 0x32BA: + return (double) 45; + case 0x32BB: + return (double) 46; + case 0x32BC: + return (double) 47; + case 0x32BD: + return (double) 48; + case 0x32BE: + return (double) 49; + case 0x17F5: case 0x2164: case 0x2174: case 0x3025: + case 0x3224: case 0x3284: +#ifdef Py_UNICODE_WIDE + case 0x1010B: + case 0x10143: + case 0x10148: + case 0x1014F: + case 0x1015F: + case 0x10173: + case 0x10321: +#endif return (double) 5; + case 0x0F2C: + return (double) 5 / 2; case 0x215A: return (double) 5 / 6; case 0x215D: @@ -284,42 +502,147 @@ case 0x1376: case 0x216C: case 0x217C: + case 0x32BF: +#ifdef Py_UNICODE_WIDE + case 0x10114: + case 0x10144: + case 0x1014A: + case 0x10151: + case 0x10166: + case 0x10167: + case 0x10168: + case 0x10169: + case 0x10174: + case 0x10323: +#endif return (double) 50; case 0x216E: case 0x217E: +#ifdef Py_UNICODE_WIDE + case 0x1011D: + case 0x10145: + case 0x1014C: + case 0x10153: + case 0x1016C: + case 0x1016D: + case 0x1016E: + case 0x1016F: + case 0x10170: +#endif return (double) 500; case 0x2181: +#ifdef Py_UNICODE_WIDE + case 0x10126: + case 0x10146: + case 0x1014E: + case 0x10172: +#endif return (double) 5000; +#ifdef Py_UNICODE_WIDE + case 0x1012F: + case 0x10147: + case 0x10156: + return (double) 50000; +#endif + case 0x17F6: case 0x2165: case 0x2175: case 0x3026: + case 0x3225: case 0x3285: +#ifdef Py_UNICODE_WIDE + case 0x1010C: +#endif return (double) 6; case 0x1377: +#ifdef Py_UNICODE_WIDE + case 0x10115: +#endif return (double) 60; +#ifdef Py_UNICODE_WIDE + case 0x1011E: + return (double) 600; + case 0x10127: + return (double) 6000; + case 0x10130: + return (double) 60000; +#endif + case 0x17F7: case 0x2166: case 0x2176: case 0x3027: + case 0x3226: case 0x3286: +#ifdef Py_UNICODE_WIDE + case 0x1010D: +#endif return (double) 7; + case 0x0F2D: + return (double) 7 / 2; case 0x215E: return (double) 7 / 8; case 0x1378: +#ifdef Py_UNICODE_WIDE + case 0x10116: +#endif return (double) 70; +#ifdef Py_UNICODE_WIDE + case 0x1011F: + return (double) 700; + case 0x10128: + return (double) 7000; + case 0x10131: + return (double) 70000; +#endif + case 0x17F8: case 0x2167: case 0x2177: case 0x3028: + case 0x3227: case 0x3287: +#ifdef Py_UNICODE_WIDE + case 0x1010E: +#endif return (double) 8; case 0x1379: +#ifdef Py_UNICODE_WIDE + case 0x10117: +#endif return (double) 80; +#ifdef Py_UNICODE_WIDE + case 0x10120: + return (double) 800; + case 0x10129: + return (double) 8000; + case 0x10132: + return (double) 80000; +#endif + case 0x17F9: case 0x2168: case 0x2178: case 0x3029: + case 0x3228: case 0x3288: +#ifdef Py_UNICODE_WIDE + case 0x1010F: +#endif return (double) 9; + case 0x0F2E: + return (double) 9 / 2; case 0x137A: +#ifdef Py_UNICODE_WIDE + case 0x10118: +#endif return (double) 90; +#ifdef Py_UNICODE_WIDE + case 0x10121: + case 0x1034A: + return (double) 900; + case 0x1012A: + return (double) 9000; + case 0x10133: + return (double) 90000; +#endif default: return (double) _PyUnicode_ToDigit(ch); } @@ -327,9 +650,7 @@ int _PyUnicode_IsNumeric(Py_UNICODE ch) { - if (_PyUnicode_ToNumeric(ch) < 0.0) - return 0; - return 1; + return _PyUnicode_ToNumeric(ch) != -1.0; } #ifndef WANT_WCTYPE_FUNCTIONS Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 10:36:52 2006 @@ -2376,6 +2376,7 @@ end = s + size; while (s < end) { + *p = *(Py_UNICODE*)s; memcpy(p, s, sizeof(Py_UNICODE)); /* We have to sanity check the raw data, otherwise doom looms for some malformed UCS-4 data. */ From python-checkins at python.org Sat May 27 10:54:30 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 27 May 2006 10:54:30 +0200 (CEST) Subject: [Python-checkins] r46433 - python/trunk/Modules/_codecsmodule.c Message-ID: <20060527085430.390A71E4006@bag.python.org> Author: martin.v.loewis Date: Sat May 27 10:54:29 2006 New Revision: 46433 Modified: python/trunk/Modules/_codecsmodule.c Log: Explain why 'consumed' is initialized. Modified: python/trunk/Modules/_codecsmodule.c ============================================================================== --- python/trunk/Modules/_codecsmodule.c (original) +++ python/trunk/Modules/_codecsmodule.c Sat May 27 10:54:29 2006 @@ -319,12 +319,11 @@ if (!PyArg_ParseTuple(args, "t#|zi:utf_16_decode", &data, &size, &errors, &final)) return NULL; - /* XXX Why is consumed initialized to size? mvl */ if (size < 0) { PyErr_SetString(PyExc_ValueError, "negative argument"); return 0; } - consumed = size; + consumed = size; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, final ? NULL : &consumed); if (decoded == NULL) @@ -348,12 +347,11 @@ &data, &size, &errors, &final)) return NULL; - /* XXX Why is consumed initialized to size? mvl */ if (size < 0) { PyErr_SetString(PyExc_ValueError, "negative argument"); return 0; } - consumed = size; + consumed = size; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, final ? NULL : &consumed); if (decoded == NULL) @@ -377,12 +375,11 @@ if (!PyArg_ParseTuple(args, "t#|zi:utf_16_be_decode", &data, &size, &errors, &final)) return NULL; - /* XXX Why is consumed initialized to size? mvl */ if (size < 0) { PyErr_SetString(PyExc_ValueError, "negative argument"); return 0; } - consumed = size; + consumed = size; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, final ? NULL : &consumed); if (decoded == NULL) @@ -413,12 +410,11 @@ if (!PyArg_ParseTuple(args, "t#|zii:utf_16_ex_decode", &data, &size, &errors, &byteorder, &final)) return NULL; - /* XXX Why is consumed initialized to size? mvl */ if (size < 0) { PyErr_SetString(PyExc_ValueError, "negative argument"); return 0; } - consumed = size; + consumed = size; /* This is overwritten unless final is true. */ unicode = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder, final ? NULL : &consumed); if (unicode == NULL) From neal at metaslash.com Sat May 27 11:14:39 2006 From: neal at metaslash.com (Neal Norwitz) Date: Sat, 27 May 2006 05:14:39 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060527091439.GA23396@python.psfb.org> test_socket leaked [1, 1, 1] references test_struct leaked [-2, -2, -2] references test_threadedtempfile leaked [7, 0, 0] references test_threading_local leaked [0, -91, 0] references test_urllib2 leaked [143, -110, -33] references From richard at commonground.com.au Sat May 27 10:46:26 2006 From: richard at commonground.com.au (Richard Jones) Date: Sat, 27 May 2006 08:46:26 +0000 Subject: [Python-checkins] r46420 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c In-Reply-To: <20060526213035.78B471E4006@bag.python.org> References: <20060526213035.78B471E4006@bag.python.org> Message-ID: <3813ED7C-5552-4FE9-A210-B95E62B08B9A@commonground.com.au> On 26/05/2006, at 9:30 PM, tim.peters wrote: > @@ -771,8 +771,8 @@ > /* Set errno to the POSIX errno, and winerror to the Win32 > error code. */ > errcode = PyInt_AsLong(self->myerrno); > - if (!errcode == -1 && PyErr_Occurred()) > - return NULL; > + if (errcode == -1 && PyErr_Occurred()) > + goto failed; > posix_errno = winerror_to_errno(errcode); > > self->winerror = self->myerrno; I presume this was our "XXX undetected error"? Richard From python-checkins at python.org Sat May 27 11:54:12 2006 From: python-checkins at python.org (richard.jones) Date: Sat, 27 May 2006 11:54:12 +0200 (CEST) Subject: [Python-checkins] r46434 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060527095412.7E1491E4006@bag.python.org> Author: richard.jones Date: Sat May 27 11:54:11 2006 New Revision: 46434 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: windows fixes Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 11:54:11 2006 @@ -768,6 +768,12 @@ if (!self) return NULL; + if (self->myerrno == Py_None) { + self->winerror = self->myerrno; + Py_INCREF(self->winerror); + return (PyObject *)self; + } + /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ errcode = PyInt_AsLong(self->myerrno); @@ -798,16 +804,25 @@ long errcode; long posix_errno; - if (EnvironmentError_init((PyEnvironmentErrorObject *)self, args, kwds) == -1) + if (EnvironmentError_init((PyEnvironmentErrorObject *)self, args, kwds) + == -1) return -1; + if (self->myerrno == Py_None) { + Py_DECREF(self->winerror); + self->winerror = self->myerrno; + Py_INCREF(self->winerror); + return 0; + } + /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ errcode = PyInt_AsLong(self->myerrno); - if (!errcode == -1 && PyErr_Occurred()) + if (errcode == -1 && PyErr_Occurred()) return -1; posix_errno = winerror_to_errno(errcode); + Py_XDECREF(self->winerror); self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); From python-checkins at python.org Sat May 27 11:58:14 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 11:58:14 +0200 (CEST) Subject: [Python-checkins] r46435 - in sandbox/trunk/hotbuffer: README.txt ref ref/Buffer.html ref/ByteBuffer.html test_hotbuf.py use_cases.py Message-ID: <20060527095814.D56E11E4006@bag.python.org> Author: martin.blais Date: Sat May 27 11:58:13 2006 New Revision: 46435 Added: sandbox/trunk/hotbuffer/ref/ sandbox/trunk/hotbuffer/ref/Buffer.html (contents, props changed) sandbox/trunk/hotbuffer/ref/ByteBuffer.html (contents, props changed) Removed: sandbox/trunk/hotbuffer/use_cases.py Modified: sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Use cases added to test file Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Sat May 27 11:58:13 2006 @@ -13,57 +13,49 @@ .. contents:: .. 1 TODO - 1.1 Features + 1.1 Other Features 1.2 Ideas - 1.3 Document - 1.4 Convert from ASCII formats - 2 Notes on the Java NIO / ByteBuffer + 1.3 Documentation TODO ==== -* Remove the advbytes argument to pop() +* Remove the advbytes argument to pop(), it is confusing. -* Make push() and pop() instead of save() and restore(), use a C stack - internally. +* Remove the mark, save() and restore(). * Make it possible to read from a file directly into a hotbuf - implement the file protocol (read(), write()) on the hotbuf object - is there a file protocol? -* We need to select between PyObject_MALLOC and PyObject_MEMMALLOC - +* Implement relative get/put methods that don't increment the position. +* Implement absolute get/put methods. -Features --------- - -* Use descriptors rather than function calls to set the limit, etc. +* We need to select between PyObject_MALLOC and PyObject_MEMMALLOC * Implement pack() in C -* Change the mark, this will make the loop easier to understand +* Add support for some of the other sequence methods. - * setmark() to save both the position and limit - * remove the special behaviours of the mark being discarded - * reset() should reset both the position and the limit - * setmark() becomes push(), reset() becomes pop() +* Add methods to parse ints, longs, floats and doubles directly from the buffer + contents, without using a temporary string. -- Add hash function +* Write a small PEP about this, when all is said and done. -- Add support for some of the other sequence methods. +Other Features +-------------- -- Perhaps implement returning the buffer object itself from some of +- Consider the implications of adding a hash function - the methods in order to allow chaining of operations on a single line. - -- Implement a resize function +- Maybe implement a resize function - Should we support weakrefs? -* Add with protocol for guards +- Add with protocol for guards + Ideas ----- @@ -77,28 +69,3 @@ process for each message. - -Document --------- - -* Write a smallish PEP about it - -* Remove Py_XDECREF where possible - -Convert from ASCII formats --------------------------- - -* We need to be able to convert from ascii formats, e.g. long with an offset - (Runar, the long conversions) - - - -Notes on the Java NIO / ByteBuffer -================================== - -Inspired from the interaction of: - -* Java ByteBuffer class -* SocketChannel -* NIO classes - Added: sandbox/trunk/hotbuffer/ref/Buffer.html ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/ref/Buffer.html Sat May 27 11:58:13 2006 @@ -0,0 +1,295 @@ + + + + + + + + + + + +Sun Microsystems + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+Skip to Content + +Java +Solaris +Communities + +Sun Store + + + +Join SDN +My Profile +Why Join? + +
+
+
+ + + + + +
+
+ +
+ + + + + + + + + + + +
» search tips 
+
+ + + +
+
+ + + + + + + + + + + + +
+ +
+ 
+ + + +
Page Not Found 
+ + + + + + + + +
+ + + + + + + + +
We are sorry, the page you have requested was not found on our system. Based +upon the url that you requested, we would like to recommend pages that match your requested url. +If you prefer, you may navigate through our site or use our search for your page.
+
+

If you are certain that this URL is valid, please send us +feedback +about the broken link. +

+
+
+ + + +
+Your URL:   http://java.sun.com/j2se/1.5.0/docs/api/java/nio/Buffer.html#reset() +

+Recommended URLs to try:
+
+
+
+ +Java Technology
+The home of Java Products & Technologies
+http://java.sun.com/index.jsp

+ +
+ +API
+Java API Index
+http://java.sun.com/reference/api/index.html

+ +
+ +Documentation
+Reference Documentaion
+http://java.sun.com/reference/docs/index.html

+ +
+ +J2SE
+Java 2 Platform, Standard Edition (J2SE) provides a complete environment for applications development on desktops and servers.
+http://java.sun.com/j2se/index.jsp

+ +
+ +
+ 
+ + + +
+
+ +
+ + + + + +
Search for your page
+If you prefer, we have suggested words that you may wish use to search our site.

+ +
+URL Requested:   http://java.sun.com/j2se/1.5.0/docs/api/java/nio/Buffer.html#reset()
+ 
+ + +
+ 
+ +
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +

+

+
 +
+
+ + + + + + Added: sandbox/trunk/hotbuffer/ref/ByteBuffer.html ============================================================================== --- (empty file) +++ sandbox/trunk/hotbuffer/ref/ByteBuffer.html Sat May 27 11:58:13 2006 @@ -0,0 +1,2477 @@ + + + + + + + +ByteBuffer (Java 2 Platform SE 5.0) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+JavaTM 2 Platform
Standard Ed. 5.0
+
+ + + +
+ +

+ +java.nio +
+Class ByteBuffer

+
+java.lang.Object
+  extended by java.nio.Buffer
+      extended by java.nio.ByteBuffer
+
+
+
All Implemented Interfaces:
Comparable<ByteBuffer>
+
+
+
Direct Known Subclasses:
MappedByteBuffer
+
+
+
+
public abstract class ByteBuffer
extends Buffer
implements Comparable<ByteBuffer>
+ + +

+A byte buffer. + +

This class defines six categories of operations upon + byte buffers: + +

    + +
  • Absolute and relative get and + put methods that read and write + single bytes;

  • + +
  • Relative bulk get + methods that transfer contiguous sequences of bytes from this buffer + into an array;

  • + +
  • Relative bulk put + methods that transfer contiguous sequences of bytes from a + byte array or some other byte + buffer into this buffer;

  • + + + +
  • Absolute and relative get + and put methods that read and + write values of other primitive types, translating them to and from + sequences of bytes in a particular byte order;

  • + +
  • Methods for creating view buffers, + which allow a byte buffer to be viewed as a buffer containing values of + some other primitive type; and

  • + + + +
  • Methods for compacting, duplicating, and slicing a byte buffer.

  • + +
+ +

Byte buffers can be created either by allocation, which allocates space for the buffer's + + + + content, or by wrapping an + existing byte array into a buffer. + + + + + + + + + + + + +

Direct vs. non-direct buffers

+ +

A byte buffer is either direct or non-direct. Given a + direct byte buffer, the Java virtual machine will make a best effort to + perform native I/O operations directly upon it. That is, it will attempt to + avoid copying the buffer's content to (or from) an intermediate buffer + before (or after) each invocation of one of the underlying operating + system's native I/O operations. + +

A direct byte buffer may be created by invoking the allocateDirect factory method of this class. The + buffers returned by this method typically have somewhat higher allocation + and deallocation costs than non-direct buffers. The contents of direct + buffers may reside outside of the normal garbage-collected heap, and so + their impact upon the memory footprint of an application might not be + obvious. It is therefore recommended that direct buffers be allocated + primarily for large, long-lived buffers that are subject to the underlying + system's native I/O operations. In general it is best to allocate direct + buffers only when they yield a measureable gain in program performance. + +

A direct byte buffer may also be created by mapping a region of a file + directly into memory. An implementation of the Java platform may optionally + support the creation of direct byte buffers from native code via JNI. If an + instance of one of these kinds of buffers refers to an inaccessible region + of memory then an attempt to access that region will not change the buffer's + content and will cause an unspecified exception to be thrown either at the + time of the access or at some later time. + +

Whether a byte buffer is direct or non-direct may be determined by + invoking its isDirect method. This method is provided so + that explicit buffer management can be done in performance-critical code. + + + +

Access to binary data

+ +

This class defines methods for reading and writing values of all other + primitive types, except boolean. Primitive values are translated + to (or from) sequences of bytes according to the buffer's current byte + order, which may be retrieved and modified via the order + methods. Specific byte orders are represented by instances of the ByteOrder class. The initial order of a byte buffer is always BIG_ENDIAN. + +

For access to heterogeneous binary data, that is, sequences of values of + different types, this class defines a family of absolute and relative + get and put methods for each type. For 32-bit floating-point + values, for example, this class defines: + +

+ float  getFloat()
+ float  getFloat(int index)
+  void  putFloat(float f)
+  void  putFloat(int index, float f)
+ +

Corresponding methods are defined for the types char, + short, int, long, and double. The index + parameters of the absolute get and put methods are in terms of + bytes rather than of the type being read or written. + + + +

For access to homogeneous binary data, that is, sequences of values of + the same type, this class defines methods that can create views of a + given byte buffer. A view buffer is simply another buffer whose + content is backed by the byte buffer. Changes to the byte buffer's content + will be visible in the view buffer, and vice versa; the two buffers' + position, limit, and mark values are independent. The asFloatBuffer method, for example, creates an instance of + the FloatBuffer class that is backed by the byte buffer upon which + the method is invoked. Corresponding view-creation methods are defined for + the types char, short, int, long, and + double. + +

View buffers have three important advantages over the families of + type-specific get and put methods described above: + +

    + +
  • A view buffer is indexed not in terms of bytes but rather in terms + of the type-specific size of its values;

  • + +
  • A view buffer provides relative bulk get and put + methods that can transfer contiguous sequences of values between a buffer + and an array or some other buffer of the same type; and

  • + +
  • A view buffer is potentially much more efficient because it will + be direct if, and only if, its backing byte buffer is direct.

  • + +
+ +

The byte order of a view buffer is fixed to be that of its byte buffer + at the time that the view is created.

+ + + + + + + + + + + + + + + + + + + + + + + + + +

Invocation chaining

+ + +

Methods in this class that do not otherwise have a value to return are + specified to return the buffer upon which they are invoked. This allows + method invocations to be chained. + + + + The sequence of statements + +

+ bb.putInt(0xCAFEBABE);
+ bb.putShort(3);
+ bb.putShort(45);
+ + can, for example, be replaced by the single statement + +
+ bb.putInt(0xCAFEBABE).putShort(3).putShort(45);
+

+ +

+

+
Since:
+
1.4
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static ByteBufferallocate(int capacity) + +
+          Allocates a new byte buffer.
+static ByteBufferallocateDirect(int capacity) + +
+          Allocates a new direct byte buffer.
+ byte[]array() + +
+          Returns the byte array that backs this + buffer  (optional operation).
+ intarrayOffset() + +
+          Returns the offset within this buffer's backing array of the first + element of the buffer  (optional operation).
+abstract  CharBufferasCharBuffer() + +
+          Creates a view of this byte buffer as a char buffer.
+abstract  DoubleBufferasDoubleBuffer() + +
+          Creates a view of this byte buffer as a double buffer.
+abstract  FloatBufferasFloatBuffer() + +
+          Creates a view of this byte buffer as a float buffer.
+abstract  IntBufferasIntBuffer() + +
+          Creates a view of this byte buffer as an int buffer.
+abstract  LongBufferasLongBuffer() + +
+          Creates a view of this byte buffer as a long buffer.
+abstract  ByteBufferasReadOnlyBuffer() + +
+          Creates a new, read-only byte buffer that shares this buffer's + content.
+abstract  ShortBufferasShortBuffer() + +
+          Creates a view of this byte buffer as a short buffer.
+abstract  ByteBuffercompact() + +
+          Compacts this buffer  (optional operation).
+ intcompareTo(ByteBuffer that) + +
+          Compares this buffer to another.
+abstract  ByteBufferduplicate() + +
+          Creates a new byte buffer that shares this buffer's content.
+ booleanequals(Object ob) + +
+          Tells whether or not this buffer is equal to another object.
+abstract  byteget() + +
+          Relative get method.
+ ByteBufferget(byte[] dst) + +
+          Relative bulk get method.
+ ByteBufferget(byte[] dst, + int offset, + int length) + +
+          Relative bulk get method.
+abstract  byteget(int index) + +
+          Absolute get method.
+abstract  chargetChar() + +
+          Relative get method for reading a char value.
+abstract  chargetChar(int index) + +
+          Absolute get method for reading a char value.
+abstract  doublegetDouble() + +
+          Relative get method for reading a double value.
+abstract  doublegetDouble(int index) + +
+          Absolute get method for reading a double value.
+abstract  floatgetFloat() + +
+          Relative get method for reading a float value.
+abstract  floatgetFloat(int index) + +
+          Absolute get method for reading a float value.
+abstract  intgetInt() + +
+          Relative get method for reading an int value.
+abstract  intgetInt(int index) + +
+          Absolute get method for reading an int value.
+abstract  longgetLong() + +
+          Relative get method for reading a long value.
+abstract  longgetLong(int index) + +
+          Absolute get method for reading a long value.
+abstract  shortgetShort() + +
+          Relative get method for reading a short value.
+abstract  shortgetShort(int index) + +
+          Absolute get method for reading a short value.
+ booleanhasArray() + +
+          Tells whether or not this buffer is backed by an accessible byte + array.
+ inthashCode() + +
+          Returns the current hash code of this buffer.
+abstract  booleanisDirect() + +
+          Tells whether or not this byte buffer is direct.
+ ByteOrderorder() + +
+          Retrieves this buffer's byte order.
+ ByteBufferorder(ByteOrder bo) + +
+          Modifies this buffer's byte order.
+abstract  ByteBufferput(byte b) + +
+          Relative put method  (optional operation).
+ ByteBufferput(byte[] src) + +
+          Relative bulk put method  (optional operation).
+ ByteBufferput(byte[] src, + int offset, + int length) + +
+          Relative bulk put method  (optional operation).
+ ByteBufferput(ByteBuffer src) + +
+          Relative bulk put method  (optional operation).
+abstract  ByteBufferput(int index, + byte b) + +
+          Absolute put method  (optional operation).
+abstract  ByteBufferputChar(char value) + +
+          Relative put method for writing a char + value  (optional operation).
+abstract  ByteBufferputChar(int index, + char value) + +
+          Absolute put method for writing a char + value  (optional operation).
+abstract  ByteBufferputDouble(double value) + +
+          Relative put method for writing a double + value  (optional operation).
+abstract  ByteBufferputDouble(int index, + double value) + +
+          Absolute put method for writing a double + value  (optional operation).
+abstract  ByteBufferputFloat(float value) + +
+          Relative put method for writing a float + value  (optional operation).
+abstract  ByteBufferputFloat(int index, + float value) + +
+          Absolute put method for writing a float + value  (optional operation).
+abstract  ByteBufferputInt(int value) + +
+          Relative put method for writing an int + value  (optional operation).
+abstract  ByteBufferputInt(int index, + int value) + +
+          Absolute put method for writing an int + value  (optional operation).
+abstract  ByteBufferputLong(int index, + long value) + +
+          Absolute put method for writing a long + value  (optional operation).
+abstract  ByteBufferputLong(long value) + +
+          Relative put method for writing a long + value  (optional operation).
+abstract  ByteBufferputShort(int index, + short value) + +
+          Absolute put method for writing a short + value  (optional operation).
+abstract  ByteBufferputShort(short value) + +
+          Relative put method for writing a short + value  (optional operation).
+abstract  ByteBufferslice() + +
+          Creates a new byte buffer whose content is a shared subsequence of + this buffer's content.
+ StringtoString() + +
+          Returns a string summarizing the state of this buffer.
+static ByteBufferwrap(byte[] array) + +
+          Wraps a byte array into a buffer.
+static ByteBufferwrap(byte[] array, + int offset, + int length) + +
+          Wraps a byte array into a buffer.
+ + + + + + + +
Methods inherited from class java.nio.Buffer
capacity, clear, flip, hasRemaining, isReadOnly, limit, limit, mark, position, position, remaining, reset, rewind
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+allocateDirect

+
+public static ByteBuffer allocateDirect(int capacity)
+
+
Allocates a new direct byte buffer. + +

The new buffer's position will be zero, its limit will be its + capacity, and its mark will be undefined. Whether or not it has a + backing array is unspecified.

+

+

+
+
+
+
Parameters:
capacity - The new buffer's capacity, in bytes +
Returns:
The new byte buffer +
Throws: +
IllegalArgumentException - If the capacity is a negative integer
+
+
+
+ +

+allocate

+
+public static ByteBuffer allocate(int capacity)
+
+
Allocates a new byte buffer. + +

The new buffer's position will be zero, its limit will be its + capacity, and its mark will be undefined. It will have a backing array, and its array + offset will be zero. +

+

+
+
+
+
Parameters:
capacity - The new buffer's capacity, in bytes +
Returns:
The new byte buffer +
Throws: +
IllegalArgumentException - If the capacity is a negative integer
+
+
+
+ +

+wrap

+
+public static ByteBuffer wrap(byte[] array,
+                              int offset,
+                              int length)
+
+
Wraps a byte array into a buffer. + +

The new buffer will be backed by the given byte array; + that is, modifications to the buffer will cause the array to be modified + and vice versa. The new buffer's capacity will be + array.length, its position will be offset, its limit + will be offset + length, and its mark will be undefined. Its + backing array will be the given array, and + its array offset will be zero.

+

+

+
+
+
+
Parameters:
array - The array that will back the new buffer
offset - The offset of the subarray to be used; must be non-negative and + no larger than array.length. The new buffer's position + will be set to this value.
length - The length of the subarray to be used; + must be non-negative and no larger than + array.length - offset. + The new buffer's limit will be set to offset + length. +
Returns:
The new byte buffer +
Throws: +
IndexOutOfBoundsException - If the preconditions on the offset and length + parameters do not hold
+
+
+
+ +

+wrap

+
+public static ByteBuffer wrap(byte[] array)
+
+
Wraps a byte array into a buffer. + +

The new buffer will be backed by the given byte array; + that is, modifications to the buffer will cause the array to be modified + and vice versa. The new buffer's capacity and limit will be + array.length, its position will be zero, and its mark will be + undefined. Its backing array will be the + given array, and its array offset will + be zero.

+

+

+
+
+
+
Parameters:
array - The array that will back this buffer +
Returns:
The new byte buffer
+
+
+
+ +

+slice

+
+public abstract ByteBuffer slice()
+
+
Creates a new byte buffer whose content is a shared subsequence of + this buffer's content. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer, and its mark + will be undefined. The new buffer will be direct if, and only if, this + buffer is direct, and it will be read-only if, and only if, this buffer + is read-only.

+

+

+
+
+
+ +
Returns:
The new byte buffer
+
+
+
+ +

+duplicate

+
+public abstract ByteBuffer duplicate()
+
+
Creates a new byte buffer that shares this buffer's content. + +

The content of the new buffer will be that of this buffer. Changes + to this buffer's content will be visible in the new buffer, and vice + versa; the two buffers' position, limit, and mark values will be + independent. + +

The new buffer's capacity, limit, position, and mark values will be + identical to those of this buffer. The new buffer will be direct if, + and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
The new byte buffer
+
+
+
+ +

+asReadOnlyBuffer

+
+public abstract ByteBuffer asReadOnlyBuffer()
+
+
Creates a new, read-only byte buffer that shares this buffer's + content. + +

The content of the new buffer will be that of this buffer. Changes + to this buffer's content will be visible in the new buffer; the new + buffer itself, however, will be read-only and will not allow the shared + content to be modified. The two buffers' position, limit, and mark + values will be independent. + +

The new buffer's capacity, limit, position, and mark values will be + identical to those of this buffer. + +

If this buffer is itself read-only then this method behaves in + exactly the same way as the duplicate method.

+

+

+
+
+
+ +
Returns:
The new, read-only byte buffer
+
+
+
+ +

+get

+
+public abstract byte get()
+
+
Relative get method. Reads the byte at this buffer's + current position, and then increments the position.

+

+

+
+
+
+ +
Returns:
The byte at the buffer's current position +
Throws: +
BufferUnderflowException - If the buffer's current position is not smaller than its limit
+
+
+
+ +

+put

+
+public abstract ByteBuffer put(byte b)
+
+
Relative put method  (optional operation). + +

Writes the given byte into this buffer at the current + position, and then increments the position.

+

+

+
+
+
+
Parameters:
b - The byte to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If this buffer's current position is not smaller than its limit +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+get

+
+public abstract byte get(int index)
+
+
Absolute get method. Reads the byte at the given + index.

+

+

+
+
+
+
Parameters:
index - The index from which the byte will be read +
Returns:
The byte at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit
+
+
+
+ +

+put

+
+public abstract ByteBuffer put(int index,
+                               byte b)
+
+
Absolute put method  (optional operation). + +

Writes the given byte into this buffer at the given + index.

+

+

+
+
+
+
Parameters:
index - The index at which the byte will be written
b - The byte value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+get

+
+public ByteBuffer get(byte[] dst,
+                      int offset,
+                      int length)
+
+
Relative bulk get method. + +

This method transfers bytes from this buffer into the given + destination array. If there are fewer bytes remaining in the + buffer than are required to satisfy the request, that is, if + length > remaining(), then no + bytes are transferred and a BufferUnderflowException is + thrown. + +

Otherwise, this method copies length bytes from this + buffer into the given array, starting at the current position of this + buffer and at the given offset in the array. The position of this + buffer is then incremented by length. + +

In other words, an invocation of this method of the form + src.get(dst, off, len) has exactly the same effect as + the loop + +

+     for (int i = off; i < off + len; i++)
+         dst[i] = src.get(); 
+ + except that it first checks that there are sufficient bytes in + this buffer and it is potentially much more efficient.

+

+

+
+
+
+
Parameters:
dst - The array into which bytes are to be written
offset - The offset within the array of the first byte to be + written; must be non-negative and no larger than + dst.length
length - The maximum number of bytes to be written to the given + array; must be non-negative and no larger than + dst.length - offset +
Returns:
This buffer +
Throws: +
BufferUnderflowException - If there are fewer than length bytes + remaining in this buffer +
IndexOutOfBoundsException - If the preconditions on the offset and length + parameters do not hold
+
+
+
+ +

+get

+
+public ByteBuffer get(byte[] dst)
+
+
Relative bulk get method. + +

This method transfers bytes from this buffer into the given + destination array. An invocation of this method of the form + src.get(a) behaves in exactly the same way as the invocation + +

+     src.get(a, 0, a.length) 
+

+

+
+
+
+ +
Returns:
This buffer +
Throws: +
BufferUnderflowException - If there are fewer than length bytes + remaining in this buffer
+
+
+
+ +

+put

+
+public ByteBuffer put(ByteBuffer src)
+
+
Relative bulk put method  (optional operation). + +

This method transfers the bytes remaining in the given source + buffer into this buffer. If there are more bytes remaining in the + source buffer than in this buffer, that is, if + src.remaining() > remaining(), + then no bytes are transferred and a BufferOverflowException is thrown. + +

Otherwise, this method copies + n = src.remaining() bytes from the given + buffer into this buffer, starting at each buffer's current position. + The positions of both buffers are then incremented by n. + +

In other words, an invocation of this method of the form + dst.put(src) has exactly the same effect as the loop + +

+     while (src.hasRemaining())
+         dst.put(src.get()); 
+ + except that it first checks that there is sufficient space in this + buffer and it is potentially much more efficient.

+

+

+
+
+
+
Parameters:
src - The source buffer from which bytes are to be read; + must not be this buffer +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there is insufficient space in this buffer + for the remaining bytes in the source buffer +
IllegalArgumentException - If the source buffer is this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+put

+
+public ByteBuffer put(byte[] src,
+                      int offset,
+                      int length)
+
+
Relative bulk put method  (optional operation). + +

This method transfers bytes into this buffer from the given + source array. If there are more bytes to be copied from the array + than remain in this buffer, that is, if + length > remaining(), then no + bytes are transferred and a BufferOverflowException is + thrown. + +

Otherwise, this method copies length bytes from the + given array into this buffer, starting at the given offset in the array + and at the current position of this buffer. The position of this buffer + is then incremented by length. + +

In other words, an invocation of this method of the form + dst.put(src, off, len) has exactly the same effect as + the loop + +

+     for (int i = off; i < off + len; i++)
+         dst.put(a[i]); 
+ + except that it first checks that there is sufficient space in this + buffer and it is potentially much more efficient.

+

+

+
+
+
+
Parameters:
src - The array from which bytes are to be read
offset - The offset within the array of the first byte to be read; + must be non-negative and no larger than array.length
length - The number of bytes to be read from the given array; + must be non-negative and no larger than + array.length - offset +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there is insufficient space in this buffer +
IndexOutOfBoundsException - If the preconditions on the offset and length + parameters do not hold +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+put

+
+public final ByteBuffer put(byte[] src)
+
+
Relative bulk put method  (optional operation). + +

This method transfers the entire content of the given source + byte array into this buffer. An invocation of this method of the + form dst.put(a) behaves in exactly the same way as the + invocation + +

+     dst.put(a, 0, a.length) 
+

+

+
+
+
+ +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there is insufficient space in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+hasArray

+
+public final boolean hasArray()
+
+
Tells whether or not this buffer is backed by an accessible byte + array. + +

If this method returns true then the array + and arrayOffset methods may safely be invoked. +

+

+

+
+
+
+ +
Returns:
true if, and only if, this buffer + is backed by an array and is not read-only
+
+
+
+ +

+array

+
+public final byte[] array()
+
+
Returns the byte array that backs this + buffer  (optional operation). + +

Modifications to this buffer's content will cause the returned + array's content to be modified, and vice versa. + +

Invoke the hasArray method before invoking this + method in order to ensure that this buffer has an accessible backing + array.

+

+

+
+
+
+ +
Returns:
The array that backs this buffer +
Throws: +
ReadOnlyBufferException - If this buffer is backed by an array but is read-only +
UnsupportedOperationException - If this buffer is not backed by an accessible array
+
+
+
+ +

+arrayOffset

+
+public final int arrayOffset()
+
+
Returns the offset within this buffer's backing array of the first + element of the buffer  (optional operation). + +

If this buffer is backed by an array then buffer position p + corresponds to array index p + arrayOffset(). + +

Invoke the hasArray method before invoking this + method in order to ensure that this buffer has an accessible backing + array.

+

+

+
+
+
+ +
Returns:
The offset within this buffer's array + of the first element of the buffer +
Throws: +
ReadOnlyBufferException - If this buffer is backed by an array but is read-only +
UnsupportedOperationException - If this buffer is not backed by an accessible array
+
+
+
+ +

+compact

+
+public abstract ByteBuffer compact()
+
+
Compacts this buffer  (optional operation). + +

The bytes between the buffer's current position and its limit, + if any, are copied to the beginning of the buffer. That is, the + byte at index p = position() is copied + to index zero, the byte at index p + 1 is copied + to index one, and so forth until the byte at index + limit() - 1 is copied to index + n = limit() - 1 - p. + The buffer's position is then set to n+1 and its limit is set to + its capacity. The mark, if defined, is discarded. + +

The buffer's position is set to the number of bytes copied, + rather than to zero, so that an invocation of this method can be + followed immediately by an invocation of another relative put + method.

+ + + +

Invoke this method after writing data from a buffer in case the + write was incomplete. The following loop, for example, copies bytes + from one channel to another via the buffer buf: + +

+ buf.clear();          // Prepare buffer for use
+ for (;;) {
+     if (in.read(buf) < 0 && !buf.hasRemaining())
+         break;        // No more bytes to transfer
+     buf.flip();
+     out.write(buf);
+     buf.compact();    // In case of partial write
+ }
+

+

+
+
+
+ +
Returns:
This buffer +
Throws: +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+isDirect

+
+public abstract boolean isDirect()
+
+
Tells whether or not this byte buffer is direct.

+

+

+
+
+
+ +
Returns:
true if, and only if, this buffer is direct
+
+
+
+ +

+toString

+
+public String toString()
+
+
Returns a string summarizing the state of this buffer.

+

+

+
Overrides:
toString in class Object
+
+
+ +
Returns:
A summary string
+
+
+
+ +

+hashCode

+
+public int hashCode()
+
+
Returns the current hash code of this buffer. + +

The hash code of a byte buffer depends only upon its remaining + elements; that is, upon the elements from position() up to, and + including, the element at limit() - 1. + +

Because buffer hash codes are content-dependent, it is inadvisable + to use buffers as keys in hash maps or similar data structures unless it + is known that their contents will not change.

+

+

+
Overrides:
hashCode in class Object
+
+
+ +
Returns:
The current hash code of this buffer
See Also:
Object.equals(java.lang.Object), +Hashtable
+
+
+
+ +

+equals

+
+public boolean equals(Object ob)
+
+
Tells whether or not this buffer is equal to another object. + +

Two byte buffers are equal if, and only if, + +

    + +
  1. They have the same element type,

  2. + +
  3. They have the same number of remaining elements, and +

  4. + +
  5. The two sequences of remaining elements, considered + independently of their starting positions, are pointwise equal. +

  6. + +
+ +

A byte buffer is not equal to any other type of object.

+

+

+
Overrides:
equals in class Object
+
+
+
Parameters:
ob - The object to which this buffer is to be compared +
Returns:
true if, and only if, this buffer is equal to the + given object
See Also:
Object.hashCode(), +Hashtable
+
+
+
+ +

+compareTo

+
+public int compareTo(ByteBuffer that)
+
+
Compares this buffer to another. + +

Two byte buffers are compared by comparing their sequences of + remaining elements lexicographically, without regard to the starting + position of each sequence within its corresponding buffer. + +

A byte buffer is not comparable to any other type of object. +

+

+
Specified by:
compareTo in interface Comparable<ByteBuffer>
+
+
+
Parameters:
that - the Object to be compared. +
Returns:
A negative integer, zero, or a positive integer as this buffer + is less than, equal to, or greater than the given buffer
+
+
+
+ +

+order

+
+public final ByteOrder order()
+
+
Retrieves this buffer's byte order. + +

The byte order is used when reading or writing multibyte values, and + when creating buffers that are views of this byte buffer. The order of + a newly-created byte buffer is always BIG_ENDIAN.

+

+

+
+
+
+ +
Returns:
This buffer's byte order
+
+
+
+ +

+order

+
+public final ByteBuffer order(ByteOrder bo)
+
+
Modifies this buffer's byte order.

+

+

+
+
+
+
Parameters:
bo - The new byte order, + either BIG_ENDIAN + or LITTLE_ENDIAN +
Returns:
This buffer
+
+
+
+ +

+getChar

+
+public abstract char getChar()
+
+
Relative get method for reading a char value. + +

Reads the next two bytes at this buffer's current position, + composing them into a char value according to the current byte order, + and then increments the position by two.

+

+

+
+
+
+ +
Returns:
The char value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than two bytes + remaining in this buffer
+
+
+
+ +

+putChar

+
+public abstract ByteBuffer putChar(char value)
+
+
Relative put method for writing a char + value  (optional operation). + +

Writes two bytes containing the given char value, in the + current byte order, into this buffer at the current position, and then + increments the position by two.

+

+

+
+
+
+
Parameters:
value - The char value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than two bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getChar

+
+public abstract char getChar(int index)
+
+
Absolute get method for reading a char value. + +

Reads two bytes at the given index, composing them into a + char value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The char value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus one
+
+
+
+ +

+putChar

+
+public abstract ByteBuffer putChar(int index,
+                                   char value)
+
+
Absolute put method for writing a char + value  (optional operation). + +

Writes two bytes containing the given char value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The char value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus one +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asCharBuffer

+
+public abstract CharBuffer asCharBuffer()
+
+
Creates a view of this byte buffer as a char buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + two, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new char buffer
+
+
+
+ +

+getShort

+
+public abstract short getShort()
+
+
Relative get method for reading a short value. + +

Reads the next two bytes at this buffer's current position, + composing them into a short value according to the current byte order, + and then increments the position by two.

+

+

+
+
+
+ +
Returns:
The short value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than two bytes + remaining in this buffer
+
+
+
+ +

+putShort

+
+public abstract ByteBuffer putShort(short value)
+
+
Relative put method for writing a short + value  (optional operation). + +

Writes two bytes containing the given short value, in the + current byte order, into this buffer at the current position, and then + increments the position by two.

+

+

+
+
+
+
Parameters:
value - The short value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than two bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getShort

+
+public abstract short getShort(int index)
+
+
Absolute get method for reading a short value. + +

Reads two bytes at the given index, composing them into a + short value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The short value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus one
+
+
+
+ +

+putShort

+
+public abstract ByteBuffer putShort(int index,
+                                    short value)
+
+
Absolute put method for writing a short + value  (optional operation). + +

Writes two bytes containing the given short value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The short value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus one +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asShortBuffer

+
+public abstract ShortBuffer asShortBuffer()
+
+
Creates a view of this byte buffer as a short buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + two, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new short buffer
+
+
+
+ +

+getInt

+
+public abstract int getInt()
+
+
Relative get method for reading an int value. + +

Reads the next four bytes at this buffer's current position, + composing them into an int value according to the current byte order, + and then increments the position by four.

+

+

+
+
+
+ +
Returns:
The int value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than four bytes + remaining in this buffer
+
+
+
+ +

+putInt

+
+public abstract ByteBuffer putInt(int value)
+
+
Relative put method for writing an int + value  (optional operation). + +

Writes four bytes containing the given int value, in the + current byte order, into this buffer at the current position, and then + increments the position by four.

+

+

+
+
+
+
Parameters:
value - The int value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than four bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getInt

+
+public abstract int getInt(int index)
+
+
Absolute get method for reading an int value. + +

Reads four bytes at the given index, composing them into a + int value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The int value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus three
+
+
+
+ +

+putInt

+
+public abstract ByteBuffer putInt(int index,
+                                  int value)
+
+
Absolute put method for writing an int + value  (optional operation). + +

Writes four bytes containing the given int value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The int value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus three +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asIntBuffer

+
+public abstract IntBuffer asIntBuffer()
+
+
Creates a view of this byte buffer as an int buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + four, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new int buffer
+
+
+
+ +

+getLong

+
+public abstract long getLong()
+
+
Relative get method for reading a long value. + +

Reads the next eight bytes at this buffer's current position, + composing them into a long value according to the current byte order, + and then increments the position by eight.

+

+

+
+
+
+ +
Returns:
The long value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than eight bytes + remaining in this buffer
+
+
+
+ +

+putLong

+
+public abstract ByteBuffer putLong(long value)
+
+
Relative put method for writing a long + value  (optional operation). + +

Writes eight bytes containing the given long value, in the + current byte order, into this buffer at the current position, and then + increments the position by eight.

+

+

+
+
+
+
Parameters:
value - The long value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than eight bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getLong

+
+public abstract long getLong(int index)
+
+
Absolute get method for reading a long value. + +

Reads eight bytes at the given index, composing them into a + long value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The long value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus seven
+
+
+
+ +

+putLong

+
+public abstract ByteBuffer putLong(int index,
+                                   long value)
+
+
Absolute put method for writing a long + value  (optional operation). + +

Writes eight bytes containing the given long value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The long value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus seven +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asLongBuffer

+
+public abstract LongBuffer asLongBuffer()
+
+
Creates a view of this byte buffer as a long buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + eight, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new long buffer
+
+
+
+ +

+getFloat

+
+public abstract float getFloat()
+
+
Relative get method for reading a float value. + +

Reads the next four bytes at this buffer's current position, + composing them into a float value according to the current byte order, + and then increments the position by four.

+

+

+
+
+
+ +
Returns:
The float value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than four bytes + remaining in this buffer
+
+
+
+ +

+putFloat

+
+public abstract ByteBuffer putFloat(float value)
+
+
Relative put method for writing a float + value  (optional operation). + +

Writes four bytes containing the given float value, in the + current byte order, into this buffer at the current position, and then + increments the position by four.

+

+

+
+
+
+
Parameters:
value - The float value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than four bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getFloat

+
+public abstract float getFloat(int index)
+
+
Absolute get method for reading a float value. + +

Reads four bytes at the given index, composing them into a + float value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The float value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus three
+
+
+
+ +

+putFloat

+
+public abstract ByteBuffer putFloat(int index,
+                                    float value)
+
+
Absolute put method for writing a float + value  (optional operation). + +

Writes four bytes containing the given float value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The float value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus three +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asFloatBuffer

+
+public abstract FloatBuffer asFloatBuffer()
+
+
Creates a view of this byte buffer as a float buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + four, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new float buffer
+
+
+
+ +

+getDouble

+
+public abstract double getDouble()
+
+
Relative get method for reading a double value. + +

Reads the next eight bytes at this buffer's current position, + composing them into a double value according to the current byte order, + and then increments the position by eight.

+

+

+
+
+
+ +
Returns:
The double value at the buffer's current position +
Throws: +
BufferUnderflowException - If there are fewer than eight bytes + remaining in this buffer
+
+
+
+ +

+putDouble

+
+public abstract ByteBuffer putDouble(double value)
+
+
Relative put method for writing a double + value  (optional operation). + +

Writes eight bytes containing the given double value, in the + current byte order, into this buffer at the current position, and then + increments the position by eight.

+

+

+
+
+
+
Parameters:
value - The double value to be written +
Returns:
This buffer +
Throws: +
BufferOverflowException - If there are fewer than eight bytes + remaining in this buffer +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+getDouble

+
+public abstract double getDouble(int index)
+
+
Absolute get method for reading a double value. + +

Reads eight bytes at the given index, composing them into a + double value according to the current byte order.

+

+

+
+
+
+
Parameters:
index - The index from which the bytes will be read +
Returns:
The double value at the given index +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus seven
+
+
+
+ +

+putDouble

+
+public abstract ByteBuffer putDouble(int index,
+                                     double value)
+
+
Absolute put method for writing a double + value  (optional operation). + +

Writes eight bytes containing the given double value, in the + current byte order, into this buffer at the given index.

+

+

+
+
+
+
Parameters:
index - The index at which the bytes will be written
value - The double value to be written +
Returns:
This buffer +
Throws: +
IndexOutOfBoundsException - If index is negative + or not smaller than the buffer's limit, + minus seven +
ReadOnlyBufferException - If this buffer is read-only
+
+
+
+ +

+asDoubleBuffer

+
+public abstract DoubleBuffer asDoubleBuffer()
+
+
Creates a view of this byte buffer as a double buffer. + +

The content of the new buffer will start at this buffer's current + position. Changes to this buffer's content will be visible in the new + buffer, and vice versa; the two buffers' position, limit, and mark + values will be independent. + +

The new buffer's position will be zero, its capacity and its limit + will be the number of bytes remaining in this buffer divided by + eight, and its mark will be undefined. The new buffer will be direct + if, and only if, this buffer is direct, and it will be read-only if, and + only if, this buffer is read-only.

+

+

+
+
+
+ +
Returns:
A new double buffer
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+JavaTM 2 Platform
Standard Ed. 5.0
+
+ + + +
+Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy. + + Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 11:58:13 2006 @@ -9,17 +9,21 @@ from hotbuf import hotbuf, BoundaryError from struct import Struct import unittest +from cStringIO import StringIO from test import test_support - CAPACITY = 1024 MSG = 'Martin Blais was here scribble scribble.' -# Note: we don't use floats because comparisons will cause precision errors due -# to the binary conversion. -fmt = Struct('llci') + +#------------------------------------------------------------------------ +# class HotbufTestCase(unittest.TestCase): + # Note: we don't use floats because comparisons will cause precision + # errors due to the binary conversion. + fmt = Struct('llci') + def test_base( self ): # Create a new hotbuf self.assertRaises(ValueError, hotbuf, -1) @@ -112,7 +116,7 @@ b.compact() self.assertEquals((b.position, b.limit, b.mark_position), (100, CAPACITY, -1)) - + # Compare the text that gets compacted. b.clear() b.setposition(100) @@ -151,11 +155,11 @@ # Read back and assert message self.assertEquals(b.getstr(len(MSG)), MSG) - + # Test overflow. b.flip() self.assertRaises(BoundaryError, b.putstr, ' ' * 1000) - + # Test underflow. self.assertRaises(BoundaryError, b.getstr, 1000) @@ -165,7 +169,7 @@ b.flip() s = b.getstr() self.assertEquals(s, MSG) - + def test_conversion( self ): b = hotbuf(CAPACITY) @@ -178,31 +182,31 @@ r = repr(b) self.assert_(r.startswith(' 1: + if hot.getbyte(end - 2) == '\r': + backup = 2 + + # Restrict the window to the current line + hot.position = mark_position # reset + hot.limit = end - backup + + # Process the line. + process_line(hot) + + # Advance the buffer window to the rest of the + # buffer after the line + mark_position = hot.position = end + hot.limit(abslimit) + + break + + # If the buffer is empty, get out + if not hot: + break + + # Set the position to the last marker + hot.position = mark_position # reset + + # Read more data in the buffer. +## FIXME: we need to support reading from a file directly into the +## buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + hot.putstr(s) + + def test_newline_delim_data( self ): + """ + Test for newline-delimited data. + """ + inp = StringIO(self.data1) + hot = hotbuf(CAPACITY) + + lineidx = [0] + def assert_lines( hot ): + "Assert the lines we process are the ones we expect." + print hot + self.assertEquals(hot, self.lines1[lineidx[0]]) + lineidx[0] += 1 + + self.parse_newline_delim(hot, inp.read, assert_lines) + + +#------------------------------------------------------------------------ +# + def _test_netstrings( self ): + """ + Use case for netstrings. + """ + + # Loop over the entire input. + while 1: + # Save the current limit. + abslimit = hot.limit + + # Loop over all the messages in the current buffer. + while hot: + # Read the length and parse the message. + length = hot.getbyte() # No error can occur here, since we're + # still hot. + if len(hot) < length: + # Rollback the length byte and exit the loop to fill + # the buffer with new data. + hot.position -= 1 # advance(-1) + break + + # Window around the message content. + limit = hot.limit = hot.position + length + + # Parse the message. + # + # - We are insured to be able to read all the message + # here because we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your transactions. + + process_message(hot) + + # Advance beyond the message. + hot.position = limit + hot.limit = abslimit + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + +## FIXME review the version with exceptions, would it be faster to just +## hit the boundary? I would prefer letting the boundary be + + while 1: + # Catch when we hit the boundary. + try: + # Loop over all the messages in the current buffer. + while hot: + # Read the length. + length = hot.getbyte() # This never raises since + # we're hot. + + mark_position = hot.position + mark_limit = hot.limit + hot.limit = hot.position + length + saved = True + + # Parse the message. + # + # - We are insured to be able to read all the message + # here because we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your + # transactions. + + process_message(hot) + + # Pop the message window and advance beyond the + # length. + hot.position = hot.limit + saved = False + else: + # Raise an exception, triggering a filling of the + # buffer + raise hotbuf.BoundaryError + + except hotbuf.BoundaryError: + # Rollback the failed transaction, if there was one. + if saved: + hot.position = mark_position + hot.limit = mark_limit + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + + + + + def _test_detect_boundary( self ): + """ + Use case for arbitraty formats, where we do not set a limit for + the processing window, and where attempting to get bytes outside + the boundary will result in getting more data from the input. + + This implies that the processing code should be able to rollback + and prepare to reprocess a partially processed item in case this + happens. + """ + + while 1: + # Catch when we hit the boundary. + try: + # Loop over all the messages in the current buffer. + while hot: + # Save the current window in case of error + mark_position = hot.position + mark_limit = hot.limit + saved = True + + # Parse the message. + # + # - We are insured to be able to read all the message + # here because we checked for the length. + # - Exceptions will be programming errors. + # - You never need to deal with rollback of your + # transactions. + + # (your code) + + # Pop the saved window + else: + raise hotbuf.BoundaryError + + except hotbuf.BoundaryError: + # Rollback the failed transaction, if there was one. + if saved: + hot.position = mark_position + hot.limit = mark_limit + + # Compact and read the next chunk of the buffer. + hot.compact() + s = read(len(hot)) + if not s: + break # Finished the input, exit. + + def _test_multiple_sockets( self ): + """ + Use case for an event-based dispatcher, that may read its input + from multiple sockets. + """ +## FIXME TODO + + + + + + +#------------------------------------------------------------------------ +# def test_main(): test_support.run_unittest(HotbufTestCase) + #test_support.run_unittest(HotbufUseCases) if __name__ == "__main__": test_main() Deleted: /sandbox/trunk/hotbuffer/use_cases.py ============================================================================== --- /sandbox/trunk/hotbuffer/use_cases.py Sat May 27 11:58:13 2006 +++ (empty file) @@ -1,120 +0,0 @@ -#!/usr/bin/env python - -""" -Use cases for the hot buffer. -""" - - -#------------------------------------------------------------------------------- -# Case 1: parsing netstrings, not using exceptions. - - # Loop over the entire input. - while 1: - # Loop over all the messages in the current buffer. - while hot: - # Read the length and parse the message. - length = hot.getbyte() # No error can occur here, since we're - # still hot. - if len(hot) < length: - # Rollback the length byte and exit the loop to fill the buffer - # with new data. - hot.advance(-1) - break - - # Save the current window and window around the message content. - hot.push(1, length) - - # Parse the message. - # - # - We are insured to be able to read all the message here because - # we checked for the length. - # - Exceptions will be programming errors. - # - You never need to deal with rollback of your transactions. - - # (your code) - - # Pop the message window and advance beyond the length. - hot.pop() - hot.advance(length + 1) - - # Compact and read the next chunk of the buffer. - hot.compact() - s = read(len(hot)) - if not s: - break # Finished the input, exit. - -#------------------------------------------------------------------------------- -# Case 2: parsing netstrings, using exceptions. This is more or less the same -# as Case 1, but without checking the length from Python, but the length is -# automatically checked by push(). - - while 1: - # Catch when we hit the boundary. - try: - # Loop over all the messages in the current buffer. - while hot: - # Read the length. - length = hot.getbyte() # This may raise - hot.push(1, length) # This may raise as well - - # Parse the message. - # - # - We are insured to be able to read all the message here - # because we checked for the length. - # - Exceptions will be programming errors. - # - You never need to deal with rollback of your transactions. - - # (your code) - - # Pop the message window and advance beyond the length. - hot.pop() - hot.advance(length + 1) - else: - raise hotbuf.BoundaryError - - except hotbuf.BoundaryError: - # Rollback the failed transaction. - hot.pop() - - # Compact and read the next chunk of the buffer. - hot.compact() - s = read(len(hot)) - if not s: - break # Finished the input, exit. - -#------------------------------------------------------------------------------- -# Case 3: arbitrary formats, may hit the boundary, cannot detect programming -# errors. - - while 1: - # Catch when we hit the boundary. - try: - # Loop over all the messages in the current buffer. - while hot: - hot.push() - - # Parse the message. - # - # - We are insured to be able to read all the message here - # because we checked for the length. - # - Exceptions will be programming errors. - # - You never need to deal with rollback of your transactions. - - # (your code) - - # Pop the safe window and leave the current position and limit - # alone. - hot.pop(False) - else: - raise hotbuf.BoundaryError - - except hotbuf.BoundaryError: - # Rollback the failed transaction. - hot.pop() - - # Compact and read the next chunk of the buffer. - hot.compact() - s = read(len(hot)) - if not s: - break # Finished the input, exit. - From python-checkins at python.org Sat May 27 12:05:11 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 12:05:11 +0200 (CEST) Subject: [Python-checkins] r46436 - in python/trunk/Objects: stringlib/README.txt stringlib/find.h stringobject.c unicodeobject.c Message-ID: <20060527100511.D6B071E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 12:05:10 2006 New Revision: 46436 Modified: python/trunk/Objects/stringlib/README.txt python/trunk/Objects/stringlib/find.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: more stringlib refactoring Modified: python/trunk/Objects/stringlib/README.txt ============================================================================== --- python/trunk/Objects/stringlib/README.txt (original) +++ python/trunk/Objects/stringlib/README.txt Sat May 27 12:05:10 2006 @@ -3,3 +3,32 @@ the stuff in here is included into relevant places; see the individual source files for details. + +-------------------------------------------------------------------- +the following defines used by the different modules: + +STRINGLIB_CHAR + + the type used to hold a character (char or Py_UNICODE) + +STRINGLIB_EMPTY + + a PyObject representing the empty string + +int STRINGLIB_CMP(STRINGLIB_CHAR*, STRINGLIB_CHAR*, Py_ssize_t) + + compares two strings. returns 0 if they match, and non-zero if not. + +Py_ssize_t STRINGLIB_LEN(PyObject*) + + returns the length of the given string object (which must be of the + right type) + +PyObject* STRINGLIB_NEW(STRINGLIB_CHAR*, Py_ssize_t) + + creates a new string object + +STRINGLIB_CHAR* STRINGLIB_STR(PyObject*) + + returns the pointer to the character data for the given string + object (which must be of the right type) Modified: python/trunk/Objects/stringlib/find.h ============================================================================== --- python/trunk/Objects/stringlib/find.h (original) +++ python/trunk/Objects/stringlib/find.h Sat May 27 12:05:10 2006 @@ -48,6 +48,39 @@ return pos; } +#ifdef STRINGLIB_STR + +Py_LOCAL(Py_ssize_t) +stringlib_find_obj(PyObject* str, PyObject* sub, + Py_ssize_t start, Py_ssize_t end) +{ + return stringlib_find( + STRINGLIB_STR(str) + start, end - start, + STRINGLIB_STR(sub), STRINGLIB_LEN(sub), start + ); +} + +Py_LOCAL(int) +stringlib_contains_obj(PyObject* str, PyObject* sub) +{ + return stringlib_find( + STRINGLIB_STR(str), STRINGLIB_LEN(str), + STRINGLIB_STR(sub), STRINGLIB_LEN(sub), 0 + ) != -1; +} + +Py_LOCAL(Py_ssize_t) +stringlib_rfind_obj(PyObject* str, PyObject* sub, + Py_ssize_t start, Py_ssize_t end) +{ + return stringlib_rfind( + STRINGLIB_STR(str) + start, end - start, + STRINGLIB_STR(sub), STRINGLIB_LEN(sub), start + ); +} + +#endif + #endif /* Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 27 12:05:10 2006 @@ -690,6 +690,9 @@ return NULL; } +/* -------------------------------------------------------------------- */ +/* object api */ + static Py_ssize_t string_getsize(register PyObject *op) { @@ -765,22 +768,23 @@ } /* -------------------------------------------------------------------- */ -/* stringlib components */ +/* Methods */ #define STRINGLIB_CHAR char -#define STRINGLIB_NEW PyString_FromStringAndSize #define STRINGLIB_CMP memcmp +#define STRINGLIB_LEN PyString_GET_SIZE +#define STRINGLIB_NEW PyString_FromStringAndSize +#define STRINGLIB_STR PyString_AS_STRING #define STRINGLIB_EMPTY nullstring #include "stringlib/fastsearch.h" +#include "stringlib/count.h" #include "stringlib/find.h" #include "stringlib/partition.h" -/* -------------------------------------------------------------------- */ -/* Methods */ static int string_print(PyStringObject *op, FILE *fp, int flags) @@ -1048,49 +1052,36 @@ } static int -string_contains(PyObject *a, PyObject *el) +string_contains(PyObject *str_obj, PyObject *sub_obj) { - char *s = PyString_AS_STRING(a); - const char *sub = PyString_AS_STRING(el); - Py_ssize_t len_sub = PyString_GET_SIZE(el); - Py_ssize_t pos; - - if (!PyString_CheckExact(el)) { + if (!PyString_CheckExact(sub_obj)) { #ifdef Py_USING_UNICODE - if (PyUnicode_Check(el)) - return PyUnicode_Contains(a, el); + if (PyUnicode_Check(sub_obj)) + return PyUnicode_Contains(str_obj, sub_obj); #endif - if (!PyString_Check(el)) { + if (!PyString_Check(sub_obj)) { PyErr_SetString(PyExc_TypeError, "'in ' requires string as left operand"); return -1; } } - if (len_sub == 0) - return 1; - - pos = fastsearch( - s, PyString_GET_SIZE(a), - sub, len_sub, FAST_SEARCH - ); - - return (pos != -1); + return stringlib_contains_obj(str_obj, sub_obj); } static PyObject * string_item(PyStringObject *a, register Py_ssize_t i) { + char pchar; PyObject *v; - char *pchar; if (i < 0 || i >= a->ob_size) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } - pchar = a->ob_sval + i; - v = (PyObject *)characters[*pchar & UCHAR_MAX]; + pchar = a->ob_sval[i]; + v = (PyObject *)characters[pchar & UCHAR_MAX]; if (v == NULL) - v = PyString_FromStringAndSize(pchar, 1); + v = PyString_FromStringAndSize(&pchar, 1); else { #ifdef COUNT_ALLOCS one_strings++; @@ -1166,9 +1157,8 @@ int _PyString_Eq(PyObject *o1, PyObject *o2) { - PyStringObject *a, *b; - a = (PyStringObject*)o1; - b = (PyStringObject*)o2; + PyStringObject *a = (PyStringObject*) o1; + PyStringObject *b = (PyStringObject*) o2; return a->ob_size == b->ob_size && *a->ob_sval == *b->ob_sval && memcmp(a->ob_sval, b->ob_sval, a->ob_size) == 0; @@ -2264,43 +2254,37 @@ static PyObject * string_count(PyStringObject *self, PyObject *args) { - const char *s = PyString_AS_STRING(self), *sub; - Py_ssize_t len = PyString_GET_SIZE(self), n; - Py_ssize_t i = 0, last = PY_SSIZE_T_MAX; - Py_ssize_t m, r; - PyObject *subobj; + PyObject *sub_obj; + const char *str = PyString_AS_STRING(self), *sub; + Py_ssize_t sub_len; + Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; - if (!PyArg_ParseTuple(args, "O|O&O&:count", &subobj, - _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) + if (!PyArg_ParseTuple(args, "O|O&O&:count", &sub_obj, + _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); + if (PyString_Check(sub_obj)) { + sub = PyString_AS_STRING(sub_obj); + sub_len = PyString_GET_SIZE(sub_obj); } #ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) { + else if (PyUnicode_Check(sub_obj)) { Py_ssize_t count; - count = PyUnicode_Count((PyObject *)self, subobj, i, last); + count = PyUnicode_Count((PyObject *)self, sub_obj, start, end); if (count == -1) return NULL; else - return PyInt_FromLong((long) count); + return PyInt_FromSsize_t(count); } #endif - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) + else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len)) return NULL; - string_adjust_indices(&i, &last, len); + string_adjust_indices(&start, &end, PyString_GET_SIZE(self)); - m = last + 1 - n; - if (n == 0) - return PyInt_FromSsize_t(m-i); - - r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); - if (r < 0) - r = 0; /* no match */ - return PyInt_FromSsize_t(r); + return PyInt_FromSsize_t( + stringlib_count(str + start, end - start, sub, sub_len) + ); } PyDoc_STRVAR(swapcase__doc__, @@ -2477,7 +2461,7 @@ } Py_LOCAL(Py_ssize_t) - countchar(char *target, int target_len, char c, Py_ssize_t maxcount) +countchar(char *target, int target_len, char c, Py_ssize_t maxcount) { Py_ssize_t count=0; char *start=target; @@ -2580,7 +2564,7 @@ } -/* Algorithms for difference cases of string replacement */ +/* Algorithms for different cases of string replacement */ /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ Py_LOCAL(PyStringObject *) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 12:05:10 2006 @@ -3857,7 +3857,9 @@ #define STRINGLIB_CHAR Py_UNICODE +#define STRINGLIB_LEN PyUnicode_GET_SIZE #define STRINGLIB_NEW PyUnicode_FromUnicode +#define STRINGLIB_STR PyUnicode_AS_UNICODE Py_LOCAL(int) STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) @@ -3918,67 +3920,33 @@ return result; } -static Py_ssize_t findstring(PyUnicodeObject *self, - PyUnicodeObject *substring, - Py_ssize_t start, - Py_ssize_t end, - int direction) -{ - FIX_START_END(self); - - if (substring->length == 0) - return (direction > 0) ? start : end; - - if (direction > 0) { - Py_ssize_t pos = fastsearch( - PyUnicode_AS_UNICODE(self) + start, end - start, - substring->str, substring->length, FAST_SEARCH - ); - if (pos >= 0) - return pos + start; - } else { - end -= substring->length; - for (; end >= start; end--) - if (Py_UNICODE_MATCH(self, end, substring)) - return end; - } - return -1; -} - Py_ssize_t PyUnicode_Find(PyObject *str, - PyObject *substr, + PyObject *sub, Py_ssize_t start, Py_ssize_t end, int direction) { Py_ssize_t result; - PyUnicodeObject* str_obj; - PyUnicodeObject* sub_obj; - str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str); - if (!str_obj) + str = PyUnicode_FromObject(str); + if (!str) return -2; - sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); - if (!sub_obj) { - Py_DECREF(str_obj); + sub = PyUnicode_FromObject(sub); + if (!sub) { + Py_DECREF(str); return -2; } - FIX_START_END(str_obj); + FIX_START_END((PyUnicodeObject*) str); if (direction > 0) - result = stringlib_find( - str_obj->str + start, end - start, sub_obj->str, sub_obj->length, - start - ); + result = stringlib_find_obj(str, sub, start, end); else - result = stringlib_rfind( - str_obj->str + start, end - start, sub_obj->str, sub_obj->length, - start - ); + result = stringlib_rfind_obj(str, sub, start, end); + + Py_DECREF(str); + Py_DECREF(sub); - Py_DECREF(str_obj); - Py_DECREF(sub_obj); return result; } @@ -5046,39 +5014,29 @@ int PyUnicode_Contains(PyObject *container, PyObject *element) { - PyUnicodeObject *u, *v; - Py_ssize_t size; - Py_ssize_t pos; + PyObject *str, *sub; + int result; /* Coerce the two arguments */ - v = (PyUnicodeObject *) PyUnicode_FromObject(element); - if (!v) { + sub = PyUnicode_FromObject(element); + if (!sub) { PyErr_SetString(PyExc_TypeError, "'in ' requires string as left operand"); return -1; } - u = (PyUnicodeObject *) PyUnicode_FromObject(container); - if (!u) { - Py_DECREF(v); + str = PyUnicode_FromObject(container); + if (!str) { + Py_DECREF(sub); return -1; } - size = PyUnicode_GET_SIZE(v); - if (!size) { - pos = 0; - goto done; - } + result = stringlib_contains_obj(str, sub); - pos = fastsearch( - PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), - PyUnicode_AS_UNICODE(v), size, FAST_SEARCH - ); + Py_DECREF(str); + Py_DECREF(sub); -done: - Py_DECREF(u); - Py_DECREF(v); - return (pos != -1); + return result; } /* Concat to string or Unicode object giving a new Unicode object. */ @@ -5305,23 +5263,26 @@ static PyObject * unicode_find(PyUnicodeObject *self, PyObject *args) { - PyUnicodeObject *substring; + PyObject *substring; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *result; + Py_ssize_t result; if (!PyArg_ParseTuple(args, "O|O&O&:find", &substring, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) + + substring = PyUnicode_FromObject(substring); + if (!substring) return NULL; - result = PyInt_FromSsize_t(findstring(self, substring, start, end, 1)); + FIX_START_END(self); + + result = stringlib_find_obj((PyObject*) self, substring, start, end); Py_DECREF(substring); - return result; + + return PyInt_FromSsize_t(result); } static PyObject * @@ -5371,7 +5332,7 @@ unicode_index(PyUnicodeObject *self, PyObject *args) { Py_ssize_t result; - PyUnicodeObject *substring; + PyObject *substring; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; @@ -5379,18 +5340,21 @@ _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) + substring = PyUnicode_FromObject(substring); + if (!substring) return NULL; - result = findstring(self, substring, start, end, 1); + FIX_START_END(self); + + result = stringlib_find_obj((PyObject*) self, substring, start, end); Py_DECREF(substring); + if (result < 0) { PyErr_SetString(PyExc_ValueError, "substring not found"); return NULL; } + return PyInt_FromSsize_t(result); } @@ -6038,23 +6002,25 @@ static PyObject * unicode_rfind(PyUnicodeObject *self, PyObject *args) { - PyUnicodeObject *substring; + PyObject *substring; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *result; + Py_ssize_t result; if (!PyArg_ParseTuple(args, "O|O&O&:rfind", &substring, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) + substring = PyUnicode_FromObject(substring); + if (!substring) return NULL; - result = PyInt_FromSsize_t(findstring(self, substring, start, end, -1)); + FIX_START_END(self); + + result = stringlib_rfind_obj((PyObject*)self, substring, start, end); Py_DECREF(substring); - return result; + + return PyInt_FromSsize_t(result); } PyDoc_STRVAR(rindex__doc__, @@ -6065,22 +6031,24 @@ static PyObject * unicode_rindex(PyUnicodeObject *self, PyObject *args) { - Py_ssize_t result; - PyUnicodeObject *substring; + PyObject *substring; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; + Py_ssize_t result; if (!PyArg_ParseTuple(args, "O|O&O&:rindex", &substring, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) + substring = PyUnicode_FromObject(substring); + if (!substring) return NULL; - result = findstring(self, substring, start, end, -1); + FIX_START_END(self); + + result = stringlib_rfind_obj((PyObject*)self, substring, start, end); Py_DECREF(substring); + if (result < 0) { PyErr_SetString(PyExc_ValueError, "substring not found"); return NULL; From python-checkins at python.org Sat May 27 12:37:46 2006 From: python-checkins at python.org (andrew.dalke) Date: Sat, 27 May 2006 12:37:46 +0200 (CEST) Subject: [Python-checkins] r46437 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060527103746.5EAF91E4006@bag.python.org> Author: andrew.dalke Date: Sat May 27 12:37:45 2006 New Revision: 46437 Modified: sandbox/trunk/stringbench/stringbench.py Log: As I mentioned in a previous submit, the total numbers are meaningless. Well, not quite meaningless, but not dirctly interpretable. I did not weight the different timings so the results are highly biased for operations on long string or with long repeats. I've rescaled some of the tests to bring things into closer agreement with what I think are important. Things are now less meaningless, but still have high bogosity. Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Sat May 27 12:37:45 2006 @@ -32,6 +32,7 @@ _RANGE_1000 = range(1000) +_RANGE_1000 = range(1000) _RANGE_100 = range(100) _RANGE_10 = range(10) @@ -271,21 +272,21 @@ #### Benchmark join @bench('"A".join("")', - "join empty string, with 1 character sep", 1000) + "join empty string, with 1 character sep", 100) def join_empty_single(STR): sep = STR("A") s2 = STR("") sep_join = sep.join - for x in _RANGE_1000: + for x in _RANGE_100: sep_join(s2) @bench('"ABCDE".join("")', - "join empty string, with 5 character sep", 1000) + "join empty string, with 5 character sep", 100) def join_empty_5(STR): sep = STR("ABCDE") s2 = STR("") sep_join = sep.join - for x in _RANGE_1000: + for x in _RANGE_100: sep_join(s2) @bench('"A".join("ABC..Z")', @@ -324,20 +325,20 @@ for x in _RANGE_1000: sep_join(s2) - at bench('"A".join(["Bob"]*1000))', - "join list of 1000 words, with 1 character sep", 1000) -def join_1000_words_single(STR): + at bench('"A".join(["Bob"]*100))', + "join list of 100 words, with 1 character sep", 1000) +def join_100_words_single(STR): sep = STR("A") - s2 = [STR("Bob")]*1000 + s2 = [STR("Bob")]*100 sep_join = sep.join for x in _RANGE_1000: sep_join(s2) - at bench('"ABCDE".join(["Bob"]*1000))', - "join list of 1000 words, with 5 character sep", 1000) -def join_1000_words_5(STR): + at bench('"ABCDE".join(["Bob"]*100))', + "join list of 100 words, with 5 character sep", 1000) +def join_100_words_5(STR): sep = STR("ABCDE") - s2 = [STR("Bob")]*1000 + s2 = [STR("Bob")]*100 sep_join = sep.join for x in _RANGE_1000: sep_join(s2) @@ -390,7 +391,7 @@ Python is distributed under an OSI-approved open source license that makes it free to use, even for commercial products. -"""*50 +"""*25 human_text_unicode = unicode(human_text) def _get_human_text(STR): if STR is unicode: @@ -399,18 +400,18 @@ return human_text raise AssertionError - at bench('human_text.split()', "split whitespace (huge)", 100) + at bench('human_text.split()', "split whitespace (huge)", 10) def whitespace_split_huge(STR): s = _get_human_text(STR) s_split = s.split - for x in _RANGE_100: + for x in _RANGE_10: s_split() - at bench('human_text.rsplit()', "split whitespace (huge)", 100) + at bench('human_text.rsplit()', "split whitespace (huge)", 10) def whitespace_rsplit_huge(STR): s = _get_human_text(STR) s_rsplit = s.rsplit - for x in _RANGE_100: + for x in _RANGE_10: s_rsplit() @@ -466,25 +467,25 @@ raise AssertionError - at bench('"...text...".split("\\n")', "split 2000 newlines", 100) + at bench('"...text...".split("\\n")', "split 2000 newlines", 10) def newlines_split_2000(STR): s = _get_2000_lines(STR) s_split = s.split - for x in _RANGE_100: + for x in _RANGE_10: s_split("\n") - at bench('"...text...".rsplit("\\n")', "split 2000 newlines", 100) + at bench('"...text...".rsplit("\\n")', "split 2000 newlines", 10) def newlines_rsplit_2000(STR): s = _get_2000_lines(STR) s_rsplit = s.rsplit - for x in _RANGE_100: + for x in _RANGE_10: s_rsplit("\n") - at bench('"...text...".splitlines()', "split 2000 newlines", 100) + at bench('"...text...".splitlines()', "split 2000 newlines", 10) def newlines_splitlines_2000(STR): s = _get_2000_lines(STR) s_splitlines = s.splitlines - for x in _RANGE_100: + for x in _RANGE_10: s_splitlines() @@ -508,19 +509,19 @@ ## split dna text on "ACTAT" characters @bench('dna.split("ACTAT")', - "split on multicharacter separator (dna)", 100) + "split on multicharacter separator (dna)", 10) def split_multichar_sep_dna(STR): s = _get_dna(STR) s_split = s.split - for x in _RANGE_100: + for x in _RANGE_10: s_split("ACTAT") @bench('dna.rsplit("ACTAT")', - "split on multicharacter separator (dna)", 100) + "split on multicharacter separator (dna)", 10) def rsplit_multichar_sep_dna(STR): s = _get_dna(STR) s_rsplit = s.rsplit - for x in _RANGE_100: + for x in _RANGE_10: s_rsplit("ACTAT") @@ -562,11 +563,11 @@ #### Count characters @bench('...text.with.2000.newlines.count("\\n")', - "count newlines", 100) + "count newlines", 10) def count_newlines(STR): s = _get_2000_lines(STR) s_count = s.count - for x in _RANGE_100: + for x in _RANGE_10: s_count("\n") # Orchid sequences concatenated, from Biopython @@ -623,7 +624,7 @@ GGGAGGATCATTGTTGAGATCACATAATAATTGATCGAGGTAATCTGGAGGATCTGCATATTTTGGTCAC """ _dna = "".join(_dna.splitlines()) -_dna = _dna * 50 +_dna = _dna * 25 _dna_unicode = unicode(_dna) def _get_dna(STR): @@ -633,11 +634,11 @@ return _dna raise AssertionError - at bench('dna.count("AACT")', "count AACT substrings in DNA example", 100) + at bench('dna.count("AACT")', "count AACT substrings in DNA example", 10) def count_aact(STR): seq = _get_dna(STR) seq_count = seq.count - for x in _RANGE_100: + for x in _RANGE_10: seq_count("AACT") ##### startswith and endswith @@ -800,35 +801,35 @@ @uses_re @bench('re.sub("\\n", " ", "...text.with.2000.lines...")', - 'replace single character, big string', 100) + 'replace single character, big string', 10) def replace_single_character_big_re(STR): s = _get_2000_lines(STR) pat = re.compile(STR("\n")) to_str = STR(" ") pat_sub = pat.sub - for x in _RANGE_100: + for x in _RANGE_10: pat_sub(to_str, s) @bench('dna.replace("ATC", "ATT")', - 'replace multiple characters, dna', 100) + 'replace multiple characters, dna', 10) def replace_multiple_characters_dna(STR): seq = _get_dna(STR) from_str = STR("ATC") to_str = STR("ATT") seq_replace = seq.replace - for x in _RANGE_100: + for x in _RANGE_10: seq_replace(from_str, to_str) # This changes the total number of character @bench('"...text.with.2000.newlines.', - 'replace multiple characters, big string', 100) + 'replace multiple characters, big string', 10) def replace_multiple_character_big(STR): s = _get_2000_lines(STR) from_str = STR("\n") to_str = STR("\r\n") s_replace = s.replace - for x in _RANGE_100: + for x in _RANGE_10: s_replace(from_str, to_str) # This increases the character count @@ -855,7 +856,7 @@ s_replace(from_str, to_str) -big_s = "A" + ("Z"*1024*1024) +big_s = "A" + ("Z"*128*1024) big_s_unicode = unicode(big_s) def _get_big_s(STR): if STR is unicode: return big_s_unicode @@ -864,7 +865,7 @@ # The older replace implementation counted all matches in # the string even when it only neeed to make one replacement. - at bench('("A" + ("Z"*1024*1024)).replace("A", "BB", 1)', + at bench('("A" + ("Z"*128*1024)).replace("A", "BB", 1)', 'quick replace single character match', 10) def quick_replace_single_match(STR): s = _get_big_s(STR) @@ -874,7 +875,7 @@ for x in _RANGE_10: s_replace(from_str, to_str, 1) - at bench('("A" + ("Z"*1024*1024)).replace("AZZ", "BBZZ", 1)', + at bench('("A" + ("Z"*128*1024)).replace("AZZ", "BBZZ", 1)', 'quick replace multiple character match', 10) def quick_replace_multiple_match(STR): s = _get_big_s(STR) @@ -919,35 +920,35 @@ #### Upper- and lower- case conversion - at bench('"Where in the world is Carmen San Deigo?".lower()', + at bench('("Where in the world is Carmen San Deigo?"*10).lower()', "case conversion -- rare", 1000) def lower_conversion_rare(STR): - s = STR("Where in the world is Carmen San Deigo?") + s = STR("Where in the world is Carmen San Deigo?"*10) s_lower = s.lower for x in _RANGE_1000: s_lower() - at bench('"WHERE IN THE WORLD IS CARMEN SAN DEIGO?".lower()', + at bench('("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower()', "case conversion -- dense", 1000) def lower_conversion_dense(STR): - s = STR("WHERE IN THE WORLD IS CARMEN SAN DEIGO?") + s = STR("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10) s_lower = s.lower for x in _RANGE_1000: s_lower() - at bench('"wHERE IN THE WORLD IS cARMEN sAN dEIGO?".upper()', + at bench('("wHERE IN THE WORLD IS cARMEN sAN dEIGO?"*10).upper()', "case conversion -- rare", 1000) def upper_conversion_rare(STR): - s = STR("Where in the world is Carmen San Deigo?") + s = STR("Where in the world is Carmen San Deigo?"*10) s_upper = s.upper for x in _RANGE_1000: s_upper() - at bench('"where in the world is carmen san deigo?".upper()', + at bench('("where in the world is carmen san deigo?"*10).upper()', "case conversion -- dense", 1000) def upper_conversion_dense(STR): - s = STR("where in the world is carmen san deigo?") + s = STR("where in the world is carmen san deigo?"*10) s_upper = s.upper for x in _RANGE_1000: s_upper() From python-checkins at python.org Sat May 27 12:39:49 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 12:39:49 +0200 (CEST) Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c Message-ID: <20060527103949.6437A1E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 12:39:48 2006 New Revision: 46438 Modified: python/trunk/Include/pyport.h python/trunk/Python/ceval.c Log: needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in- lining killed performance on certain Intel boxes, and the "aggressive" macro itself gives most of the benefits on others. Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Sat May 27 12:39:48 2006 @@ -137,13 +137,17 @@ # endif #endif -/* PY_LOCAL can be used instead of static to get the fastest possible calling - * convention for functions that are local to a given module. It also enables - * inlining, where suitable. +/* Py_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. * - * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, a more - * "aggressive" inlining is enabled. This may lead to code bloat, and may - * slow things down for those reasons. Use with care. + * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, + * for platforms that support that. + * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more + * "aggressive" inlining/optimizaion is enabled for the entire module. This + * may lead to code bloat, and may slow things down for those reasons. It may + * also lead to errors, if the code relies on pointer aliasing. Use with + * care. * * NOTE: You can only use this for functions that are entirely local to a * module; functions that are exported via method tables, callbacks, etc, @@ -160,11 +164,14 @@ /* ignore warnings if the compiler decides not to inline a function */ #pragma warning(disable: 4710) /* fastest possible local call under MSVC */ -#define Py_LOCAL(type) static __inline type __fastcall +#define Py_LOCAL(type) static type __fastcall +#define Py_LOCAL_INLINE(type) static __inline type __fastcall #elif defined(USE_INLINE) -#define Py_LOCAL(type) static inline type +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static inline type #else #define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static type #endif #include Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Sat May 27 12:39:48 2006 @@ -6,7 +6,7 @@ XXX document it! */ -/* enable more aggressive local inlining (platform dependent) */ +/* enable more aggressive intra-module optimizations, where available */ #define PY_LOCAL_AGGRESSIVE #include "Python.h" @@ -19,11 +19,6 @@ #include -#if defined(_MSC_VER) -/* enable more aggressive optimization for visual studio */ -#pragma optimize("agtw", on) -#endif - #ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -38,7 +33,7 @@ #define READ_TIMESTAMP(var) ppc_getcounter(&var) -Py_LOCAL(void) +static void ppc_getcounter(uint64 *v) { register unsigned long tbu, tb, tbu2; @@ -91,44 +86,44 @@ /* Forward declarations */ #ifdef WITH_TSC -Py_LOCAL(PyObject *) call_function(PyObject ***, int, uint64*, uint64*); +static PyObject * call_function(PyObject ***, int, uint64*, uint64*); #else -Py_LOCAL(PyObject *) call_function(PyObject ***, int); +static PyObject * call_function(PyObject ***, int); #endif -Py_LOCAL(PyObject *) fast_function(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *) do_call(PyObject *, PyObject ***, int, int); -Py_LOCAL(PyObject *) ext_do_call(PyObject *, PyObject ***, int, int, int); -Py_LOCAL(PyObject *) update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -Py_LOCAL(PyObject *) update_star_args(int, int, PyObject *, PyObject ***); -Py_LOCAL(PyObject *) load_args(PyObject ***, int); +static PyObject * fast_function(PyObject *, PyObject ***, int, int, int); +static PyObject * do_call(PyObject *, PyObject ***, int, int); +static PyObject * ext_do_call(PyObject *, PyObject ***, int, int, int); +static PyObject * update_keyword_args(PyObject *, int, PyObject ***,PyObject *); +static PyObject * update_star_args(int, int, PyObject *, PyObject ***); +static PyObject * load_args(PyObject ***, int); #define CALL_FLAG_VAR 1 #define CALL_FLAG_KW 2 #ifdef LLTRACE static int lltrace; -Py_LOCAL(int) prtrace(PyObject *, char *); +static int prtrace(PyObject *, char *); #endif -Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *, +static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -Py_LOCAL(void) call_trace_protected(Py_tracefunc, PyObject *, +static void call_trace_protected(Py_tracefunc, PyObject *, PyFrameObject *, int, PyObject *); -Py_LOCAL(void) call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); -Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *, +static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); +static int maybe_call_line_trace(Py_tracefunc, PyObject *, PyFrameObject *, int *, int *, int *); -Py_LOCAL(PyObject *) apply_slice(PyObject *, PyObject *, PyObject *); -Py_LOCAL(int) assign_slice(PyObject *, PyObject *, +static PyObject * apply_slice(PyObject *, PyObject *, PyObject *); +static int assign_slice(PyObject *, PyObject *, PyObject *, PyObject *); -Py_LOCAL(PyObject *) cmp_outcome(int, PyObject *, PyObject *); -Py_LOCAL(PyObject *) import_from(PyObject *, PyObject *); -Py_LOCAL(int) import_all_from(PyObject *, PyObject *); -Py_LOCAL(PyObject *) build_class(PyObject *, PyObject *, PyObject *); -Py_LOCAL(int) exec_statement(PyFrameObject *, +static PyObject * cmp_outcome(int, PyObject *, PyObject *); +static PyObject * import_from(PyObject *, PyObject *); +static int import_all_from(PyObject *, PyObject *); +static PyObject * build_class(PyObject *, PyObject *, PyObject *); +static int exec_statement(PyFrameObject *, PyObject *, PyObject *, PyObject *); -Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); -Py_LOCAL(void) reset_exc_info(PyThreadState *); -Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *); -Py_LOCAL(PyObject *) string_concatenate(PyObject *, PyObject *, +static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); +static void reset_exc_info(PyThreadState *); +static void format_exc_check_arg(PyObject *, char *, PyObject *); +static PyObject * string_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ @@ -484,8 +479,8 @@ WHY_YIELD = 0x0040 /* 'yield' operator */ }; -Py_LOCAL(enum why_code) do_raise(PyObject *, PyObject *, PyObject *); -Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **); +static enum why_code do_raise(PyObject *, PyObject *, PyObject *); +static int unpack_iterable(PyObject *, int, PyObject **); /* for manipulating the thread switch and periodic "stuff" - used to be per thread, now just a pair o' globals */ @@ -2902,7 +2897,7 @@ */ -Py_LOCAL(void) +static void set_exc_info(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { @@ -2947,7 +2942,7 @@ PySys_SetObject("exc_traceback", tb); } -Py_LOCAL(void) +static void reset_exc_info(PyThreadState *tstate) { PyFrameObject *frame; @@ -2994,7 +2989,7 @@ /* Logic for the raise statement (too complicated for inlining). This *consumes* a reference count to each of its arguments. */ -Py_LOCAL(enum why_code) +static enum why_code do_raise(PyObject *type, PyObject *value, PyObject *tb) { if (type == NULL) { @@ -3103,7 +3098,7 @@ /* Iterate v argcnt times and store the results on the stack (via decreasing sp). Return 1 for success, 0 if error. */ -Py_LOCAL(int) +static int unpack_iterable(PyObject *v, int argcnt, PyObject **sp) { int i = 0; @@ -3150,7 +3145,7 @@ #ifdef LLTRACE -Py_LOCAL(int) +static int prtrace(PyObject *v, char *str) { printf("%s ", str); @@ -3161,7 +3156,7 @@ } #endif -Py_LOCAL(void) +static void call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) { PyObject *type, *value, *traceback, *arg; @@ -3187,7 +3182,7 @@ } } -Py_LOCAL(void) +static void call_trace_protected(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3204,7 +3199,7 @@ } } -Py_LOCAL(int) +static int call_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { @@ -3239,7 +3234,7 @@ return result; } -Py_LOCAL(int) +static int maybe_call_line_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, int *instr_lb, int *instr_ub, int *instr_prev) @@ -3467,7 +3462,7 @@ } } -Py_LOCAL(void) +static void err_args(PyObject *func, int flags, int nargs) { if (flags & METH_NOARGS) @@ -3514,7 +3509,7 @@ x = call; \ } -Py_LOCAL(PyObject *) +static PyObject * call_function(PyObject ***pp_stack, int oparg #ifdef WITH_TSC , uint64* pintr0, uint64* pintr1 @@ -3605,7 +3600,7 @@ done before evaluating the frame. */ -Py_LOCAL(PyObject *) +static PyObject * fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); @@ -3658,7 +3653,7 @@ PyFunction_GET_CLOSURE(func)); } -Py_LOCAL(PyObject *) +static PyObject * update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack, PyObject *func) { @@ -3698,7 +3693,7 @@ return kwdict; } -Py_LOCAL(PyObject *) +static PyObject * update_star_args(int nstack, int nstar, PyObject *stararg, PyObject ***pp_stack) { @@ -3723,7 +3718,7 @@ return callargs; } -Py_LOCAL(PyObject *) +static PyObject * load_args(PyObject ***pp_stack, int na) { PyObject *args = PyTuple_New(na); @@ -3738,7 +3733,7 @@ return args; } -Py_LOCAL(PyObject *) +static PyObject * do_call(PyObject *func, PyObject ***pp_stack, int na, int nk) { PyObject *callargs = NULL; @@ -3774,7 +3769,7 @@ return result; } -Py_LOCAL(PyObject *) +static PyObject * ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk) { int nstar = 0; @@ -3886,7 +3881,7 @@ PyType_HasFeature((x)->ob_type, Py_TPFLAGS_HAVE_INDEX) \ && (x)->ob_type->tp_as_number->nb_index)) -Py_LOCAL(PyObject *) +static PyObject * apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */ { PyTypeObject *tp = u->ob_type; @@ -3912,7 +3907,7 @@ } } -Py_LOCAL(int) +static int assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x) /* u[v:w] = x */ { @@ -3946,7 +3941,7 @@ } } -Py_LOCAL(PyObject *) +static PyObject * cmp_outcome(int op, register PyObject *v, register PyObject *w) { int res = 0; @@ -3979,7 +3974,7 @@ return v; } -Py_LOCAL(PyObject *) +static PyObject * import_from(PyObject *v, PyObject *name) { PyObject *x; @@ -3993,7 +3988,7 @@ return x; } -Py_LOCAL(int) +static int import_all_from(PyObject *locals, PyObject *v) { PyObject *all = PyObject_GetAttrString(v, "__all__"); @@ -4050,7 +4045,7 @@ return err; } -Py_LOCAL(PyObject *) +static PyObject * build_class(PyObject *methods, PyObject *bases, PyObject *name) { PyObject *metaclass = NULL, *result, *base; @@ -4102,7 +4097,7 @@ return result; } -Py_LOCAL(int) +static int exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, PyObject *locals) { @@ -4198,7 +4193,7 @@ return 0; } -Py_LOCAL(void) +static void format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj) { char *obj_str; @@ -4213,7 +4208,7 @@ PyErr_Format(exc, format_str, obj_str); } -Py_LOCAL(PyObject *) +static PyObject * string_concatenate(PyObject *v, PyObject *w, PyFrameObject *f, unsigned char *next_instr) { @@ -4288,7 +4283,7 @@ #ifdef DYNAMIC_EXECUTION_PROFILE -Py_LOCAL(PyObject *) +static PyObject * getarray(long a[256]) { int i; From amk at amk.ca Sat May 27 12:47:29 2006 From: amk at amk.ca (A.M. Kuchling) Date: Sat, 27 May 2006 06:47:29 -0400 Subject: [Python-checkins] r46432 - in python/trunk: Doc/api/concrete.tex Lib/test/test_unicodedata.py Misc/NEWS Modules/unicodedata.c Objects/unicodectype.c Objects/unicodeobject.c In-Reply-To: <20060527083654.2C0041E4006@bag.python.org> References: <20060527083654.2C0041E4006@bag.python.org> Message-ID: <20060527104729.GA656@Andrew-iBook2.local> On Sat, May 27, 2006 at 10:36:54AM +0200, martin.v.loewis wrote: > --- python/trunk/Objects/unicodeobject.c (original) > +++ python/trunk/Objects/unicodeobject.c Sat May 27 10:36:52 2006 > @@ -2376,6 +2376,7 @@ > end = s + size; > > while (s < end) { > + *p = *(Py_UNICODE*)s; > memcpy(p, s, sizeof(Py_UNICODE)); > /* We have to sanity check the raw data, otherwise doom looms for > some malformed UCS-4 data. */ Was this a debugging change that slipped in, or is something going on here (perhaps to fix an alignment-related issue)? If the character is copied by the assignment, is the memcpy() just below it necessary? --amk From python-checkins at python.org Sat May 27 13:04:37 2006 From: python-checkins at python.org (andrew.dalke) Date: Sat, 27 May 2006 13:04:37 +0200 (CEST) Subject: [Python-checkins] r46439 - python/trunk/Objects/unicodeobject.c Message-ID: <20060527110437.0D83D1E400C@bag.python.org> Author: andrew.dalke Date: Sat May 27 13:04:36 2006 New Revision: 46439 Modified: python/trunk/Objects/unicodeobject.c Log: fixed typo Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 13:04:36 2006 @@ -233,7 +233,7 @@ { register PyUnicodeObject *unicode; - /* Optimization fo empty strings */ + /* Optimization for empty strings */ if (length == 0 && unicode_empty != NULL) { Py_INCREF(unicode_empty); return unicode_empty; From python-checkins at python.org Sat May 27 13:07:50 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 27 May 2006 13:07:50 +0200 (CEST) Subject: [Python-checkins] r46440 - python/trunk/Objects/unicodeobject.c Message-ID: <20060527110750.5FB3E1E4006@bag.python.org> Author: martin.v.loewis Date: Sat May 27 13:07:49 2006 New Revision: 46440 Modified: python/trunk/Objects/unicodeobject.c Log: Revert bogus change committed in 46432 to this file. Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 13:07:49 2006 @@ -2376,7 +2376,6 @@ end = s + size; while (s < end) { - *p = *(Py_UNICODE*)s; memcpy(p, s, sizeof(Py_UNICODE)); /* We have to sanity check the raw data, otherwise doom looms for some malformed UCS-4 data. */ From martin at v.loewis.de Sat May 27 13:08:27 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 27 May 2006 13:08:27 +0200 Subject: [Python-checkins] r46432 - in python/trunk: Doc/api/concrete.tex Lib/test/test_unicodedata.py Misc/NEWS Modules/unicodedata.c Objects/unicodectype.c Objects/unicodeobject.c In-Reply-To: <20060527104729.GA656@Andrew-iBook2.local> References: <20060527083654.2C0041E4006@bag.python.org> <20060527104729.GA656@Andrew-iBook2.local> Message-ID: <4478332B.3080609@v.loewis.de> A.M. Kuchling wrote: > Was this a debugging change that slipped in, or is something going on > here (perhaps to fix an alignment-related issue)? It was a debugging change. I reverted it; thanks for noticing. Regards, Martin From python-checkins at python.org Sat May 27 13:14:34 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 13:14:34 +0200 (CEST) Subject: [Python-checkins] r46441 - in python/branches/sreifschneider-newnewexcept: Include/pyerrors.h Objects/exceptions.c Message-ID: <20060527111434.B2B4E1E4006@bag.python.org> Author: georg.brandl Date: Sat May 27 13:14:34 2006 New Revision: 46441 Modified: python/branches/sreifschneider-newnewexcept/Include/pyerrors.h python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Refactor some duplicated code. Modified: python/branches/sreifschneider-newnewexcept/Include/pyerrors.h ============================================================================== --- python/branches/sreifschneider-newnewexcept/Include/pyerrors.h (original) +++ python/branches/sreifschneider-newnewexcept/Include/pyerrors.h Sat May 27 13:14:34 2006 @@ -10,7 +10,7 @@ PyObject_HEAD PyObject *dict; PyObject *args; -PyObject *message; + PyObject *message; } PyBaseExceptionObject; typedef struct { Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 13:14:34 2006 @@ -15,7 +15,8 @@ PyBaseExceptionObject *self; self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); - self->args = self->message = self->dict = NULL; + /* the dict is created on the fly in PyObject_GenericSetAttr */ + self->message = self->dict = NULL; self->args = PyTuple_New(0); if (!self->args) { @@ -29,24 +30,20 @@ return NULL; } - /* the dict is created on the fly in PyObject_GenericSetAttr */ - self->dict = NULL; - return (PyObject *)self; } static int BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) { - if (args) { - Py_DECREF(self->args); - self->args = args; - Py_INCREF(self->args); - } + Py_DECREF(self->args); + self->args = args; + Py_INCREF(self->args); - if (PySequence_Length(self->args) == 1) { + if (PyTuple_GET_SIZE(self->args) == 1) { Py_DECREF(self->message); - self->message = PySequence_GetItem(self->args, 0); + self->message = PyTuple_GET_ITEM(self->args, 0); + Py_INCREF(self->message); } return 0; } @@ -420,8 +417,7 @@ if (!self) return NULL; - self->code = Py_None; - Py_INCREF(Py_None); + MAKE_IT_NONE(self->code); return (PyObject *)self; } @@ -429,20 +425,17 @@ static int SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) { - Py_ssize_t size = PySequence_Length(args); + Py_ssize_t size = PyTuple_GET_SIZE(args); if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (size == 1) { - Py_DECREF(self->code); - self->code = PySequence_GetItem(args, 0); - } - else if (size > 1) { - Py_DECREF(self->code); + Py_DECREF(self->code); + if (size == 1) + self->code = PyTuple_GET_ITEM(args, 0); + else if (size > 1) self->code = args; - Py_INCREF(args); - } + Py_INCREF(self->code); return 0; } @@ -537,11 +530,12 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PySequence_Length(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1) { return 0; } - if (!PyArg_ParseTuple(args, "OO|O", &myerrno, &strerror, &filename)) { + if (!PyArg_UnpackTuple(args, "EnvironmentError", 2, 3, + &myerrno, &strerror, &filename)) { return -1; } Py_DECREF(self->myerrno); /* replacing */ @@ -965,9 +959,6 @@ if (!self) return NULL; - self->msg = self->filename = self->lineno = self->offset = - self->text = NULL; - MAKE_IT_NONE(self->msg) MAKE_IT_NONE(self->filename) MAKE_IT_NONE(self->lineno) @@ -985,36 +976,36 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *info = NULL; - Py_ssize_t lenargs = PySequence_Length(args); + Py_ssize_t lenargs = PyTuple_GET_SIZE(args); if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - if (!item0) return -1; Py_DECREF(self->msg); - self->msg = item0; + self->msg = PyTuple_GET_ITEM(args, 0); + Py_INCREF(self->msg); } if (lenargs == 2) { - info = PySequence_GetItem(args, 1); + info = PyTuple_GET_ITEM(args, 1); + info = PySequence_Tuple(info); if (!info) return -1; Py_DECREF(self->filename); - self->filename = PySequence_GetItem(info, 0); - if (!self->filename) return -1; + self->filename = PyTuple_GET_ITEM(info, 0); + Py_INCREF(self->filename); Py_DECREF(self->lineno); - self->lineno = PySequence_GetItem(info, 1); - if (!self->lineno) return -1; + self->lineno = PyTuple_GET_ITEM(info, 1); + Py_INCREF(self->lineno); Py_DECREF(self->offset); - self->offset = PySequence_GetItem(info, 2); - if (!self->offset) return -1; + self->offset = PyTuple_GET_ITEM(info, 2); + Py_INCREF(self->offset); Py_DECREF(self->text); - self->text = PySequence_GetItem(info, 3); - if (!self->text) return -1; + self->text = PyTuple_GET_ITEM(info, 3); + Py_INCREF(self->text); } return 0; } From python-checkins at python.org Sat May 27 13:22:58 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 13:22:58 +0200 (CEST) Subject: [Python-checkins] r46442 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060527112258.BF7511E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 13:22:58 2006 New Revision: 46442 Modified: sandbox/trunk/stringbench/stringbench.py Log: whitespace normalization Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Sat May 27 13:22:58 2006 @@ -107,7 +107,7 @@ search = pat.search for x in _RANGE_100: search(s1) - + #### same tests as 'in' but use 'find' @@ -170,7 +170,7 @@ # Skip the ones which fail because that would include exception overhead. # Add rindex tests. - + @bench('("A"*1000).index("A")', "early match, single character", 1000) def index_test_quick_match_single_character(STR): s1 = STR("A" * 1000) @@ -231,7 +231,7 @@ s = STR("ABCDE") for x in _RANGE_1000: s * 1000 - + # + for concat @bench('"Andrew"+"Dalke"', "concat two strings", 1000) @@ -423,14 +423,14 @@ for x in _RANGE_1000: s_split("\n") - + @bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines", 1000) def newlines_rsplit(STR): s = STR("this\nis\na\ntest\n") s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\n") - + @bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines", 1000) def newlines_splitlines(STR): s = STR("this\nis\na\ntest\n") @@ -439,7 +439,7 @@ s_splitlines() ## split text with 2000 newlines - + def _make_2000_lines(): import random r = random.Random(100) @@ -465,7 +465,7 @@ if STR is str: return _text_with_2000_lines raise AssertionError - + @bench('"...text...".split("\\n")', "split 2000 newlines", 10) def newlines_split_2000(STR): @@ -473,14 +473,14 @@ s_split = s.split for x in _RANGE_10: s_split("\n") - + @bench('"...text...".rsplit("\\n")', "split 2000 newlines", 10) def newlines_rsplit_2000(STR): s = _get_2000_lines(STR) s_rsplit = s.rsplit for x in _RANGE_10: s_rsplit("\n") - + @bench('"...text...".splitlines()', "split 2000 newlines", 10) def newlines_splitlines_2000(STR): s = _get_2000_lines(STR) @@ -515,7 +515,7 @@ s_split = s.split for x in _RANGE_10: s_split("ACTAT") - + @bench('dna.rsplit("ACTAT")', "split on multicharacter separator (dna)", 10) def rsplit_multichar_sep_dna(STR): @@ -538,21 +538,21 @@ s_split = s.split for x in _RANGE_1000: s_split("\t") - + @bench('GFF3_example.split("\\t", 8)', "tab split", 1000) def tab_split_limit(STR): s = STR(GFF3_example) s_split = s.split for x in _RANGE_1000: s_split("\t", 8) - + @bench('GFF3_example.rsplit("\\t")', "tab split", 1000) def tab_rsplit_no_limit(STR): s = STR(GFF3_example) s_rsplit = s.rsplit for x in _RANGE_1000: s_rsplit("\t") - + @bench('GFF3_example.rsplit("\\t", 8)', "tab split", 1000) def tab_rsplit_limit(STR): s = STR(GFF3_example) @@ -766,7 +766,7 @@ for x in _RANGE_1000: s_lstrip() - + #### replace @bench('"This is a test".replace(" ", "\\t")', 'replace single character', 1000) @@ -978,7 +978,7 @@ (options, test_names) = parser.parse_args() if options.str_only and options.unicode_only: raise SystemExit("Only one of --8-bit and --unicode are allowed") - + bench_functions = [] for (k,v) in globals().items(): if hasattr(v, "is_bench"): @@ -991,7 +991,7 @@ continue if options.skip_re and hasattr(v, "uses_re"): continue - + bench_functions.append( (v.group, k, v) ) bench_functions.sort() @@ -1039,4 +1039,4 @@ if __name__ == "__main__": main() - + From python-checkins at python.org Sat May 27 13:23:46 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 13:23:46 +0200 (CEST) Subject: [Python-checkins] r46443 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060527112346.4FE6C1E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 13:23:46 2006 New Revision: 46443 Modified: sandbox/trunk/stringbench/stringbench.py Log: fixed total ratio calculation Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Sat May 27 13:23:46 2006 @@ -1030,7 +1030,7 @@ print "That was zippy!" else: try: - average = str_time/uni_time + average = str_total/uni_total except ZeroDivisionError: average = 0.0 print "%.2f\t%.2f\t%.1f\t%s" % ( From python-checkins at python.org Sat May 27 13:26:34 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 27 May 2006 13:26:34 +0200 (CEST) Subject: [Python-checkins] r46444 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060527112634.5377F1E401C@bag.python.org> Author: andrew.kuchling Date: Sat May 27 13:26:33 2006 New Revision: 46444 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add Py_LOCAL macros Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat May 27 13:26:33 2006 @@ -2036,6 +2036,18 @@ \code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}. (Contributed by Barry Warsaw.) +\item Two new macros can be used to indicate C functions that are +local to the current file so that a faster calling convention can be +used. \cfunction{Py_LOCAL(\var{type})} declares the function as +returning a value of the specified \var{type} and uses a fast-calling +qualifier. \cfunction{Py_LOCAL_INLINE(\var{type})} does the same thing +and also requests the function be inlined. If +\cfunction{PY_LOCAL_AGGRESSIVE} is defined before \file{python.h} is +included, a set of more aggressive optimizations are enabled for the +module; you should benchmark the results to find out if these +optimizations actually make the code faster. (Contributed by Fredrik +Lundh at the NeedForSpeed sprint.) + \item \cfunction{PyErr_NewException(\var{name}, \var{base}, \var{dict})} can now accept a tuple of base classes as its \var{base} argument. (Contributed by Georg Brandl.) From python-checkins at python.org Sat May 27 13:35:35 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 13:35:35 +0200 (CEST) Subject: [Python-checkins] r46446 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060527113535.5D4AF1E400F@bag.python.org> Author: georg.brandl Date: Sat May 27 13:35:35 2006 New Revision: 46446 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Prettier error for errno not being an integer. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 13:35:35 2006 @@ -771,8 +771,12 @@ /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ errcode = PyInt_AsLong(self->myerrno); - if (errcode == -1 && PyErr_Occurred()) + if (errcode == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_TypeError) + /* give a clearer error message */ + PyErr_SetString(PyExc_TypeError, "errno has to be an integer"); goto failed; + } posix_errno = winerror_to_errno(errcode); self->winerror = self->myerrno; From python-checkins at python.org Sat May 27 13:36:38 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 13:36:38 +0200 (CEST) Subject: [Python-checkins] r46447 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c README.txt hotbuf.py test_hotbuf.py Message-ID: <20060527113638.7DC6B1E4006@bag.python.org> Author: martin.blais Date: Sat May 27 13:36:37 2006 New Revision: 46447 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/hotbuf.py sandbox/trunk/hotbuffer/test_hotbuf.py Log: Simplified and revamped the hot buffer Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Sat May 27 13:36:37 2006 @@ -34,7 +34,7 @@ /* =========================================================================== - * Byte Buffer object implementation + * Object declaration */ @@ -62,7 +62,6 @@ capacity values: 0 <= position <= limit <= capacity - 0 <= mark_position <= mark_limit <= capacity */ typedef struct { @@ -85,45 +84,55 @@ /* The limit position in the buffer. */ Py_ssize_t b_limit; - /* The mark (position and limit), which save the current position and - limit on save(), to be reset later with restore(). The mark variables are - set to -1 to indicate that the mark is unset. - */ - Py_ssize_t b_mark_position; - Py_ssize_t b_mark_limit; - } PyHotbufObject; -/* - * Given a hotbuf object, return the buffer memory (in 'ptr' and 'size') and - * true if there was no error. + +/* =========================================================================== + * Private Declarations */ -/* Internal Methods */ - -static int -hotbuf_advance_internal(PyHotbufObject *self, Py_ssize_t nbytes) -{ - Py_ssize_t newposition = self->b_position + nbytes; - if (newposition > self->b_limit) { - PyErr_SetString(BoundaryError, - "position must be smaller than limit"); - return -1; +/* + * Inline error check for the given position, check that it is within the + * buffer's limits, if not return error. + */ +#define CHECK_LIMIT_RETURN(pos, eval) \ + if ( pos < 0 ) { \ + PyErr_SetString(BoundaryError, \ + "attempted access before buffer"); \ + return eval; \ + } \ + if ( pos > self->b_limit ) { \ + PyErr_SetString(BoundaryError, \ + "attempted access beyond buffer limit"); \ + return eval; \ + } + +#define CHECK_CAPACITY_RETURN(pos, eval) \ + if ( pos < 0 ) { \ + PyErr_SetString(BoundaryError, \ + "attempted access before buffer"); \ + return eval; \ + } \ + if ( pos > self->b_capacity ) { \ + PyErr_SetString(BoundaryError, \ + "attempted access beyond buffer"); \ + return eval; \ } - /* Set the new position */ - self->b_position = newposition; - - return 0; -} +/* + * Calculate the size of the buffer window between position and limit + */ +#define WINDOW_LENGTH(self) self->b_limit - self->b_position -/* Methods */ + +/* =========================================================================== + * Constructors / Destructors + */ /* - * Constructor. Note that we allocate the memory ourselves, unlike - * the buffer object. + * Constructor. Note that we allocate memory here. */ static PyObject * hotbuf_new(PyTypeObject *type, PyObject *args, PyObject *kw) @@ -149,7 +158,7 @@ if ( ptr == NULL ) { return PyErr_NoMemory(); } - + /* Allocate the Python object itself. */ new = (PyHotbufObject *) type->tp_alloc(type, 0); if (new == NULL) { @@ -159,11 +168,10 @@ /* Initialize the members */ new->b_ptr = ptr; + new->b_capacity = capacity; + new->b_position = 0; new->b_limit = capacity; - new->b_mark_position = -1; - new->b_mark_limit = -1; - new->b_capacity = capacity; return (PyObject*)new; } @@ -172,7 +180,6 @@ /* * Destructor. */ - static void hotbuf_dealloc(PyHotbufObject *self) { @@ -184,6 +191,11 @@ } + +/* =========================================================================== + * Public (Exposed) Declarations + */ + /* * Comparison. We compare the active windows, not the entire allocated buffer * memory. @@ -194,8 +206,8 @@ Py_ssize_t len_self, len_other, min_len; int cmp; - len_self = self->b_limit - self->b_position; - len_other = other->b_limit - other->b_position; + len_self = WINDOW_LENGTH(self); + len_other = WINDOW_LENGTH(other); min_len = ((len_self < len_other) ? len_self : len_other); if (min_len > 0) { @@ -216,12 +228,10 @@ hotbuf_repr(PyHotbufObject *self) { return PyString_FromFormat( - "", + "", self->b_position, self->b_limit, self->b_capacity, - self->b_mark_position, - self->b_mark_limit, self->b_ptr, self); } @@ -234,8 +244,7 @@ { assert( self->b_position <= self->b_limit ); return PyString_FromStringAndSize( - (const char *)(self->b_ptr + self->b_position), - self->b_limit - self->b_position); + (const char *)(self->b_ptr + self->b_position), WINDOW_LENGTH(self)); } @@ -244,188 +253,48 @@ * Object Methods (basic interface) */ -PyDoc_STRVAR(setposition__doc__, - "B.setposition(int)\n\ -\n\ -Sets this buffer's position. If the given position is\n\ -larger than the limit an exception is raised."); - -static PyObject* -hotbuf_setposition(PyHotbufObject *self, PyObject* arg) -{ - Py_ssize_t newposition; - - newposition = PyInt_AsSsize_t(arg); - if (newposition == -1 && PyErr_Occurred()) - return NULL; - - if ( newposition > self->b_capacity ) { - PyErr_SetString(BoundaryError, - "position must be smaller than capacity"); - return NULL; - } - - /* Set the new position */ - self->b_position = newposition; - - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(advance__doc__, - "B.advance(int)\n\ -\n\ -Advance this buffer's position by the given number of bytes. \n\ -If the given position is larger than the limit an exception \n\ -is raised."); - -static PyObject* -hotbuf_advance(PyHotbufObject *self, PyObject* arg) -{ - Py_ssize_t nbytes = PyInt_AsSsize_t(arg); - if (nbytes == -1 && PyErr_Occurred()) - return NULL; - - if (hotbuf_advance_internal(self, nbytes) < 0) - return NULL; - - Py_RETURN_NONE; -} - - - - -PyDoc_STRVAR(setlimit__doc__, - "B.setlimit(int)\n\ -\n\ -Sets this buffer's limit. If the position is larger than the new limit\n\ -then it is set to the new limit."); - -static PyObject* -hotbuf_setlimit(PyHotbufObject *self, PyObject* arg) -{ - Py_ssize_t newlimit; - - newlimit = PyInt_AsSsize_t(arg); - if (newlimit == -1 && PyErr_Occurred()) - return NULL; - - if ( newlimit > self->b_capacity ) { - PyErr_SetString(BoundaryError, - "limit must be smaller than capacity"); - return NULL; - } - - /* Set the new limit. */ - self->b_limit = newlimit; - - /* If the position is larger than the new limit, set it to the new - limit. */ - if ( self->b_position > self->b_limit ) - self->b_position = newlimit; - - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(setwindow__doc__, - "B.setwindow(int)\n\ +PyDoc_STRVAR(setlen__doc__, +"B.setlen(int)\n\ \n\ Sets this buffer's limit to be beyond position by the given\n\ number number of bytes. If the limit is larger than the \n\ capacity an BoundaryError is raised."); static PyObject* -hotbuf_setwindow(PyHotbufObject *self, PyObject* arg) -{ - Py_ssize_t window; - Py_ssize_t newlimit; - - window = PyInt_AsSsize_t(arg); - if (window == -1 && PyErr_Occurred()) - return NULL; - - newlimit = self->b_position + window; - if ( newlimit > self->b_capacity ) { - PyErr_SetString(BoundaryError, - "limit must be smaller than capacity"); - return NULL; - } - - /* Set the new limit. */ - self->b_limit = newlimit; - - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(save__doc__, - "B.save()\n\ -\n\ -Save this buffer's position and limit for later."); - -static PyObject* -hotbuf_save(PyHotbufObject *self) -{ - self->b_mark_position = self->b_position; - self->b_mark_limit = self->b_limit; - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(restore__doc__, - "B.restore([advbytes]) -> int\n\ -\n\ -Resets this buffer's position to the previously-marked\n\ -position and limit. Invoking this method neither changes nor\n\ -discards the mark's value. An BoundaryError is raised if the\n\ -mark has not been set. This method returns the new\n\ -position's value. If you specify a number of bytes via \n\ -'advbytes', the method advances the position by that many bytes."); - -static PyObject* -hotbuf_restore(PyHotbufObject *self, PyObject* args) +hotbuf_setlen(PyHotbufObject *self, PyObject* arg) { - Py_ssize_t advbytes = 0; - Py_ssize_t newposition = -1; + Py_ssize_t window_size = -1; + Py_ssize_t new_limit; - /* Validate that the mark is set. */ - if ( self->b_mark_position == -1 || self->b_mark_limit == -1 ) { - PyErr_SetString(BoundaryError, - "mark has not been yet set"); + /* Read and validate the window size */ + window_size = PyInt_AsSsize_t(arg); + if (window_size == -1 && PyErr_Occurred()) return NULL; - } - - /* Extract and validate advbytes */ - if (!PyArg_ParseTuple(args, "|n:hotbuf", &advbytes)) - return NULL; - - if (advbytes < 0) { - PyErr_SetString(PyExc_ValueError, - "advbytes must be a positive number"); + if (window_size < 0) { + PyErr_SetString(BoundaryError, "window size must be positive"); return NULL; } - /* Validate the new position, if specified */ - newposition = self->b_mark_position + advbytes; - if (newposition > self->b_limit) { + /* Validate the new limit */ + new_limit = self->b_position + window_size; + if ( new_limit > self->b_capacity ) { PyErr_SetString(BoundaryError, - "new position must be smaller than limit"); + "new limit is beyond buffer"); return NULL; } - self->b_position = newposition; - self->b_limit = self->b_mark_limit; + /* Set the new limit. */ + self->b_limit = new_limit; - return PyInt_FromLong(newposition); + Py_RETURN_NONE; } PyDoc_STRVAR(clear__doc__, - "B.clear()\n\ +"B.clear()\n\ \n\ Clears this buffer. The position is set to zero, the limit is set to\n\ -the capacity, and the mark is discarded.\n\ +the capacity.\n\ \n\ Invoke this method before using a sequence of channel-read or put\n\ operations to fill this buffer. For example:\n\ @@ -442,17 +311,15 @@ { self->b_position = 0; self->b_limit = self->b_capacity; - self->b_mark_position = self->b_mark_limit = -1; Py_RETURN_NONE; } PyDoc_STRVAR(flip__doc__, - "B.flip()\n\ +"B.flip()\n\ \n\ Flips this buffer. The limit is set to the current position and then\n\ -the position is set to zero. If the mark is defined then it is\n\ -discarded.\n\ +the position is set to zero. \n\ \n\ After a sequence of channel-read or put operations, invoke this method\n\ to prepare for a sequence of channel-write or relative get\n\ @@ -471,35 +338,12 @@ { self->b_limit = self->b_position; self->b_position = 0; - self->b_mark_position = self->b_mark_limit = -1; - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(rewind__doc__, - "B.rewind()\n\ -\n\ -Rewinds this buffer. The position is set to zero.\n\ -\n\ -Invoke this method before a sequence of channel-write or get\n\ -operations, assuming that the limit has already been set\n\ -appropriately. For example:\n\ -\n\ - out.write(buf) # Write remaining data\n\ - buf.rewind() # Rewind buffer\n\ - buf.get(array) # Copy data into array\n\ -"); - -static PyObject* -hotbuf_rewind(PyHotbufObject *self) -{ - self->b_position = 0; Py_RETURN_NONE; } PyDoc_STRVAR(compact__doc__, - "B.compact()\n\ +"B.compact()\n\ \n\ Compacts this buffer.\n\ \n\ @@ -509,7 +353,7 @@ p + 1 is copied to index one, and so forth until the byte at index\n\ limit() - 1 is copied to index n = limit() - 1 - p. The buffer's\n\ position is then set to n+1 and its limit is set to its\n\ -capacity. The mark, if defined, is discarded.\n\ +capacity.\n\ \n\ The buffer's position is set to the number of bytes copied, rather\n\ than to zero, so that an invocation of this method can be followed\n\ @@ -535,7 +379,7 @@ Py_ssize_t length; /* Calculate the number of bytes in the active window */ - length = self->b_limit - self->b_position; + length = WINDOW_LENGTH(self); /* Move the memory from the active window to the beginning of the allocated buffer (only if we need to). */ @@ -545,7 +389,6 @@ self->b_position = length; self->b_limit = self->b_capacity; - self->b_mark_position = self->b_mark_limit = -1; Py_RETURN_NONE; } @@ -556,50 +399,47 @@ * Object Methods (get/put methods) */ -PyDoc_STRVAR(get__doc__, - "B.get*() -> data\n\ -\n\ -Relative get methods. \n\ -Reads something at this buffer's current position, \n\ -and then increments the position.\n\ -An BoundaryError is raised if the position is at the end of the buffer."); - -PyDoc_STRVAR(put__doc__, - "B.put*(data)\n\ +PyDoc_STRVAR(getbyte__doc__, +"B.getbyte() -> data\n\ \n\ -Relative put methods. \n\ -Writes the given byte into this buffer at the current position,\n\ +Reads a byte at this buffer's current position, \n\ and then increments the position.\n\ -An BoundaryError is raised if the position is at the end of the buffer."); - - -/* Check if we're going to be trying to year beyond the buffer active - window limit, and if so, sets and error and return */ -#define CHECK_LIMIT_ERROR(sz) \ - if ( (self->b_position + sz) > self->b_limit ) { \ - PyErr_SetString(BoundaryError, \ - "attempted read beyond buffer limit"); \ - return NULL; \ - } - +A BoundaryError is raised if the position is at the end of the buffer."); static PyObject* hotbuf_getbyte(PyHotbufObject *self) { unsigned char byte; - CHECK_LIMIT_ERROR(sizeof(byte)); + Py_ssize_t new_position; + + /* Validate new position */ + new_position = self->b_position + sizeof(byte); + + CHECK_LIMIT_RETURN(new_position, NULL); + /* Read the byte and return it */ byte = *(unsigned char*)(self->b_ptr + self->b_position); - self->b_position += sizeof(byte); + self->b_position = new_position; + return PyInt_FromLong(byte); } + +PyDoc_STRVAR(putbyte__doc__, +"B.putbyte(byte)\n\ +\n\ +Writes the given byte into this buffer at the current position,\n\ +and then increment the position.\n\ +A BoundaryError is raised if the position is at the end of the buffer."); + static PyObject* hotbuf_putbyte(PyHotbufObject *self, PyObject* arg) { int byte_i; unsigned char byte; + Py_ssize_t new_position; + /* Parse, validate and convert the byte to be written */ byte_i = PyInt_AsLong(arg); if ( byte_i > 255 ) { PyErr_SetString(PyExc_ValueError, @@ -608,15 +448,81 @@ } byte = (unsigned char)byte_i; - CHECK_LIMIT_ERROR(sizeof(byte)); + /* Validate the new position */ + new_position = self->b_position + sizeof(byte); + CHECK_LIMIT_RETURN(new_position, NULL); + + /* Write the byte and advance the position */ *(unsigned char*)(self->b_ptr + self->b_position) = byte; - self->b_position += sizeof(byte); + self->b_position = new_position; + Py_RETURN_NONE; +} + + +PyDoc_STRVAR(getbyterel__doc__, +"B.getbyterel(offset) -> data\n\ +\n\ +Reads a byte at the given offset calculated from position. \n\ +This does then not increment the position."); + +static PyObject* +hotbuf_getbyterel(PyHotbufObject *self, PyObject* args) +{ + Py_ssize_t offset; + Py_ssize_t read_position; + + /* Extract the offset */ + if (!PyArg_ParseTuple(args, "n:hotbuf", &offset)) + return NULL; + + /* Validate position */ + read_position = self->b_position + offset; + CHECK_LIMIT_RETURN(read_position, NULL); + + /* Note that we do not increment, on purpose. */ + return PyInt_FromLong(*(unsigned char*)(read_position)); +} + + +PyDoc_STRVAR(putbyterel__doc__, +"B.putbyterel(offset, byte) -> data\n\ +\n\ +Writes a byte at the given offset calculated from position. \n\ +This does then not increment the position."); + +static PyObject* +hotbuf_putbyterel(PyHotbufObject *self, PyObject* args) +{ + Py_ssize_t offset = -1; + Py_ssize_t write_position; + int byte_i; + unsigned char byte; + + /* Extract the offset and byte */ + if (!PyArg_ParseTuple(args, "ni:hotbuf", &offset, &byte_i)) + return NULL; + + /* Validate position */ + write_position = self->b_position + offset; + CHECK_LIMIT_RETURN(write_position, NULL); + + /* Validate the byte value */ + if ( byte_i > 255 ) { + PyErr_SetString(PyExc_ValueError, + "overflow for byte"); + return NULL; + } + byte = (unsigned char)byte_i; + + /* Write the byte and return */ + *(unsigned char*)(self->b_ptr + write_position) = byte; + Py_RETURN_NONE; } PyDoc_STRVAR(getstr__doc__, - "B.getstr([nbytes]) -> data\n\ +"B.getstr([nbytes]) -> data\n\ \n\ Extract a string of 'nbytes' bytes from the buffer and advance the\n\ position accordingly. If 'nbytes' is not specified, get the string\n\ @@ -636,7 +542,7 @@ /* Validate positive */ if (len == -1) { /* Using default value. */ - len = self->b_limit - self->b_position; + len = WINDOW_LENGTH(self); } else if (len < 0) { PyErr_SetString(PyExc_ValueError, @@ -644,7 +550,7 @@ return NULL; } - CHECK_LIMIT_ERROR(len); + CHECK_LIMIT_RETURN(self->b_position + len, NULL); /* Extract the string object from the buffer */ s = PyString_FromStringAndSize( @@ -659,7 +565,7 @@ PyDoc_STRVAR(putstr__doc__, - "B.putstr(str)\n\ +"B.putstr(str)\n\ \n\ Write a string of 'nbytes' bytes from the buffer and advance the \n\ position accordingly.\n\ @@ -680,7 +586,7 @@ instring = PyString_AS_STRING(arg); len = PyString_GET_SIZE(arg); - CHECK_LIMIT_ERROR(len); + CHECK_LIMIT_RETURN(self->b_position + len, NULL); /* Copy the string into the buffer */ memcpy(self->b_ptr + self->b_position, instring, len); @@ -692,7 +598,7 @@ } PyDoc_STRVAR(unpack__doc__, - "B.unpack(structobj) -> v1, v2, ...\n\ +"B.unpack(structobj) -> v1, v2, ...\n\ \n\ Unpack the given structure directly from this buffer and advance\n\ the position accordingly."); @@ -705,6 +611,7 @@ Py_ssize_t len = -1; PyObject *size_obj; PyObject *result; + Py_ssize_t new_position; if (str_size == NULL) { str_size = PyString_InternFromString("size"); @@ -729,25 +636,30 @@ PyErr_SetString(PyExc_TypeError, "unpack requires a single struct argument"); } - + len = PyInt_AsSsize_t(size_obj); if (len < 0) PyErr_SetString(PyExc_TypeError, "unpack requires a single struct argument"); - - CHECK_LIMIT_ERROR(len); - - result = PyObject_CallMethodObjArgs(structobj, + + CHECK_LIMIT_RETURN(self->b_position + len, NULL); + + result = PyObject_CallMethodObjArgs(structobj, str_unpack_from, self, NULL); - + if (result == NULL) return NULL; - - if (hotbuf_advance_internal(self, len) < 0) { + + /* Advance beyond the packed data */ + new_position = self->b_position + len; + if ( new_position > self->b_limit ) { + PyErr_SetString(BoundaryError, + "attempted access beyond buffer limit"); Py_DECREF(result); - result = NULL; + return NULL; } - + self->b_position = new_position; + return result; } @@ -772,7 +684,7 @@ } result = fastsearch(self->b_ptr + self->b_position, - self->b_limit - self->b_position, + WINDOW_LENGTH(self), PyString_AS_STRING(arg), PyString_GET_SIZE(arg), FAST_SEARCH); @@ -799,7 +711,7 @@ } result = fastsearch(self->b_ptr + self->b_position, - self->b_limit - self->b_position, + WINDOW_LENGTH(self), PyString_AS_STRING(arg), PyString_GET_SIZE(arg), FAST_COUNT); @@ -810,6 +722,7 @@ return PyInt_FromSsize_t(result); } + /* =========================================================================== * Buffer protocol methods @@ -829,7 +742,7 @@ } *pp = self->b_ptr + self->b_position; - return self->b_limit - self->b_position; + return WINDOW_LENGTH(self); } static Py_ssize_t @@ -855,38 +768,15 @@ static Py_ssize_t hotbuf_length(PyHotbufObject *self) { - return self->b_limit - self->b_position; + return WINDOW_LENGTH(self); } /* =========================================================================== - * Object interfaces declaration + * Getters and setters */ - -PyDoc_STRVAR(hotbuf_doc, - "hotbuf(capacity) -> hotbuf\n\ -\n\ -Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ -\n\ -hotbuf is a C encapsulation of a fixed-size buffer of bytes in memory.\n\ -One can read and write objects of different primitive types directly\n\ -into it, without having to convert from/to strings. Also, this is\n\ -meant for the network I/O functions (recv, recvfrom, send, sendto) to\n\ -read/write directly into without having to create temporary strings.\n\ -\n\ -Note that hotbuf is a direct Python equivalent of Java's NIO\n\ -ByteBuffer class."); - - - -#define OFF(x) offsetof(PyHotbufObject, x) - -/* - Hotbuf Getters and setters -*/ - static PyObject * hotbuf_get_capacity(PyHotbufObject *self, void *unused) { @@ -902,20 +792,16 @@ static int hotbuf_set_position(PyHotbufObject *self, PyObject *arg, void *unused) { - Py_ssize_t newposition; + Py_ssize_t new_position; - newposition = PyInt_AsSsize_t(arg); - if (newposition == -1 && PyErr_Occurred()) + new_position = PyInt_AsSsize_t(arg); + if (new_position == -1 && PyErr_Occurred()) return -1; - if (newposition > self->b_capacity) { - PyErr_SetString(BoundaryError, - "position must be smaller than capacity"); - return -1; - } + CHECK_LIMIT_RETURN(new_position, -1); /* Set the new position */ - self->b_position = newposition; + self->b_position = new_position; return 0; } @@ -929,68 +815,79 @@ static int hotbuf_set_limit(PyHotbufObject *self, PyObject *arg, void *unused) { - Py_ssize_t newlimit; + Py_ssize_t new_limit; - newlimit = PyInt_AsSsize_t(arg); - if (newlimit == -1 && PyErr_Occurred()) + new_limit = PyInt_AsSsize_t(arg); + if (new_limit == -1 && PyErr_Occurred()) return -1; - if (newlimit > self->b_capacity) { - PyErr_SetString(BoundaryError, - "limit must be smaller than capacity"); - return -1; - } + CHECK_CAPACITY_RETURN(new_limit, -1); /* Set the new limit */ - self->b_limit = newlimit; + self->b_limit = new_limit; /* If the position is larger than the new limit, set it to the new limit. */ - if (self->b_position > self->b_limit) - self->b_position = newlimit; + if (self->b_position > self->b_limit) { + self->b_position = new_limit; + } return 0; } -static PyObject * -hotbuf_get_mark_position(PyHotbufObject *self, void *unused) -{ - return PyInt_FromSsize_t(self->b_mark_position); -} -static PyObject * -hotbuf_get_mark_limit(PyHotbufObject *self, void *unused) -{ - return PyInt_FromSsize_t(self->b_mark_limit); -} + +/* =========================================================================== + * Interfaces Declarations + */ + +PyDoc_STRVAR(hotbuf_doc, +"hotbuf(capacity) -> hotbuf\n\ +\n\ +Return a new hotbuf with a buffer of fixed size 'capacity'.\n\ +\n\ +hotbuf is a C encapsulation of a fixed-size buffer of bytes in memory.\n\ +One can read and write objects of different primitive types directly\n\ +into it, without having to convert from/to strings. Also, this is\n\ +meant for the network I/O functions (recv, recvfrom, send, sendto) to\n\ +read/write directly into without having to create temporary strings.\n\ +\n\ +Note that hotbuf is a direct Python equivalent of Java's NIO\n\ +ByteBuffer class."); + static PyGetSetDef hotbuf_getsetlist[] = { - {"capacity", (getter)hotbuf_get_capacity, (setter)NULL, "buffer's capacity", NULL}, - {"position", (getter)hotbuf_get_position, (setter)hotbuf_set_position, "buffer's position", NULL}, - {"limit", (getter)hotbuf_get_limit, (setter)hotbuf_set_limit, "buffer's limit", NULL}, - {"mark_position", (getter)hotbuf_get_mark_position, (setter)NULL, "buffer's mark_position, -1 if not set", NULL}, - {"mark_limit", (getter)hotbuf_get_mark_limit, (setter)NULL, "buffer's mark_limit, -1 if not set", NULL}, + {"capacity", (getter)hotbuf_get_capacity, (setter)NULL, + "buffer's capacity", NULL}, + {"position", (getter)hotbuf_get_position, (setter)hotbuf_set_position, + "buffer's position", NULL}, + {"limit", (getter)hotbuf_get_limit, (setter)hotbuf_set_limit, + "buffer's limit", NULL}, {NULL} }; static PyMethodDef hotbuf_methods[] = { {"clear", (PyCFunction)hotbuf_clear, METH_NOARGS, clear__doc__}, - {"setposition", (PyCFunction)hotbuf_setposition, METH_O, setposition__doc__}, - {"advance", (PyCFunction)hotbuf_advance, METH_O, advance__doc__}, - {"setlimit", (PyCFunction)hotbuf_setlimit, METH_O, setlimit__doc__}, - {"setwindow", (PyCFunction)hotbuf_setwindow, METH_O, setwindow__doc__}, - {"save", (PyCFunction)hotbuf_save, METH_NOARGS, save__doc__}, - {"restore", (PyCFunction)hotbuf_restore, METH_VARARGS, restore__doc__}, + {"setlen", (PyCFunction)hotbuf_setlen, METH_O, setlen__doc__}, + {"flip", (PyCFunction)hotbuf_flip, METH_NOARGS, flip__doc__}, - {"rewind", (PyCFunction)hotbuf_rewind, METH_NOARGS, rewind__doc__}, {"compact", (PyCFunction)hotbuf_compact, METH_NOARGS, compact__doc__}, - {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, get__doc__}, - {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, put__doc__}, + + {"getbyte", (PyCFunction)hotbuf_getbyte, METH_NOARGS, getbyte__doc__}, + {"putbyte", (PyCFunction)hotbuf_putbyte, METH_O, putbyte__doc__}, + + {"getbyterel", (PyCFunction)hotbuf_getbyterel, METH_O, + getbyterel__doc__}, + {"putbyterel", (PyCFunction)hotbuf_putbyterel, METH_VARARGS, + putbyterel__doc__}, + {"getstr", (PyCFunction)hotbuf_getstr, METH_VARARGS, getstr__doc__}, {"putstr", (PyCFunction)hotbuf_putstr, METH_O, putstr__doc__}, + {"unpack", (PyCFunction)hotbuf_unpack, METH_O, unpack__doc__}, {"find", (PyCFunction)hotbuf_find, METH_O, find__doc__}, {"count", (PyCFunction)hotbuf_count, METH_O, count__doc__}, + {NULL, NULL} /* sentinel */ }; @@ -1061,7 +958,7 @@ */ PyDoc_STRVAR(module_doc, - "This module defines an object type which can represent a fixed size\n\ +"This module defines an object type which can represent a fixed size\n\ buffer of bytes in momery, from which you can directly read and into\n\ which you can directly write objects in various other types. This is\n\ used to avoid buffer copies in network I/O as much as possible. For\n\ @@ -1099,16 +996,19 @@ if (PyType_Ready(&PyHotbuf_Type) < 0) return; - if (BoundaryError == NULL) { - BoundaryError = PyErr_NewException("hotbuf.BoundaryError", NULL, NULL); - if (BoundaryError == NULL) - return; - } - Py_INCREF(BoundaryError); - PyModule_AddObject(m, "BoundaryError", BoundaryError); + if (BoundaryError == NULL) { + BoundaryError = PyErr_NewException( + "hotbuf.BoundaryError", NULL, NULL); + if (BoundaryError == NULL) + return; + } + Py_INCREF(BoundaryError); + PyModule_AddObject(m, "BoundaryError", BoundaryError); + Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "HotbufType", (PyObject *)&PyHotbuf_Type); Py_INCREF((PyObject *)&PyHotbuf_Type); PyModule_AddObject(m, "_hotbuf", (PyObject *)&PyHotbuf_Type); } + Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Sat May 27 13:36:37 2006 @@ -25,10 +25,12 @@ * Remove the mark, save() and restore(). +* Implement the entire string protocol, since that will be a fast to contents + * Make it possible to read from a file directly into a hotbuf - implement the file protocol (read(), write()) on the hotbuf object - - is there a file protocol? + - euh, is there a file protocol? * Implement relative get/put methods that don't increment the position. @@ -45,6 +47,8 @@ * Write a small PEP about this, when all is said and done. + + Other Features -------------- Modified: sandbox/trunk/hotbuffer/hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/hotbuf.py (original) +++ sandbox/trunk/hotbuffer/hotbuf.py Sat May 27 13:36:37 2006 @@ -19,4 +19,5 @@ if size > len(self): raise BoundaryError("attempted to write beyond buffer limit") structobj.pack_to(self, 0, *values) - self.advance(size) + self.position += size + Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 13:36:37 2006 @@ -33,96 +33,75 @@ self.assertEquals(b.capacity, CAPACITY) # Play with the position - assert b.position == 0 - b.setposition(10) + b.limit = 100 + self.assertEquals(b.position, 0) + b.position = 10 self.assertEquals(b.position, 10) - self.assertRaises(BoundaryError, b.setposition, CAPACITY + 1) + self.assertEquals(len(b), 90) + b.position = b.limit + self.assertEquals(b.position, b.limit) + def setposition( b, val ): + b.position = val + self.assertRaises(BoundaryError, setposition, b, -1) + self.assertRaises(BoundaryError, setposition, b, b.limit + 1) + self.assertRaises(BoundaryError, setposition, b, CAPACITY + 1) # Play with the limit - assert b.limit == CAPACITY - b.setlimit(CAPACITY - 10) - self.assertEquals(b.limit, CAPACITY - 10) - self.assertRaises(BoundaryError, b.setlimit, CAPACITY + 1) - b.setlimit(b.position - 1) + b.position = 10 + b.limit = 100 + self.assertEquals(b.limit, 100) + b.limit = 110 + self.assertEquals(b.limit, 110) + def setlimit( b, val ): + b.limit = val + self.assertRaises(BoundaryError, setlimit, b, CAPACITY + 1) + b.limit = b.position - 1 self.assertEquals(b.position, b.limit) - # Play with reset before the mark has been set. - self.assertRaises(BoundaryError, b.setlimit, CAPACITY + 1) - - # Play with the mark - b.setposition(10) - b.setlimit(100) - b.save() - b.setposition(15) - self.assertEquals(b.mark_position, 10) - - # Play with restore - b.setposition(10) - b.setlimit(100) - b.save() - b.setposition(0) - b.setlimit(b.capacity) - b.restore() - self.assertEquals((b.position, b.limit), - (10, 100)) - # Play with clear b.clear() - self.assertEquals((b.position, b.limit, b.mark_position), - (0, CAPACITY, -1)) + self.assertEquals((b.position, b.limit), (0, CAPACITY)) # Play with flip. - b.setposition(42) - b.setlimit(104) - b.save() - b.flip() - self.assertEquals((b.position, b.limit, b.mark_position), - (0, 42, -1)) - - # Play with rewind. - b.setposition(42) - b.setlimit(104) - b.save() - b.rewind() - self.assertEquals((b.position, b.limit, b.mark_position), - (0, 104, 42)) - - # Play with remaining. - self.assertEquals(len(b), 104) - b.setposition(10) - self.assertEquals(len(b), 94) + b.position = 42 + b.limit = 104 + b.flip() + self.assertEquals((b.position, b.limit), (0, 42)) + + # Play with length. + self.assertEquals(len(b), 42) + b.position = 10 + self.assertEquals(len(b), 32) # Play with advance. self.assertEquals(b.position, 10) - b.advance(32) + b.position += 32 self.assertEquals(b.position, 42) - self.assertRaises(BoundaryError, b.advance, CAPACITY) + self.assertRaises(BoundaryError, setposition, b, CAPACITY) - # Play with setwindow() + # Play with setlen() b.clear() - b.setwindow(12) + b.setlen(12) self.assertEquals((b.position, b.limit), (0, 12)) - b.advance(3) - b.setwindow(12) + b.position += 3 + b.setlen(12) self.assertEquals((b.position, b.limit), (3, 15)) def test_compact( self ): b = hotbuf(CAPACITY) - b.setposition(100) - b.setlimit(200) - m = b.mark_position + b.position = 100 + b.limit = 200 b.compact() - self.assertEquals((b.position, b.limit, b.mark_position), - (100, CAPACITY, -1)) + self.assertEquals((b.position, b.limit), (100, CAPACITY)) # Compare the text that gets compacted. b.clear() - b.setposition(100) + b.position = 100 b.putstr(MSG) - b.setlimit(b.position) - b.setposition(100) + b.limit = b.position + b.position = 100 b.compact() b.flip() self.assertEquals(str(b), MSG) @@ -173,8 +152,8 @@ def test_conversion( self ): b = hotbuf(CAPACITY) - b.setposition(100) - b.setlimit(132) + b.position = 100 + b.limit = 132 self.assertEquals(len(b), 32) s = str(b) @@ -194,7 +173,7 @@ # Pack directly into the buffer and compare the strings. b = hotbuf(CAPACITY) self.fmt.pack_to(b, 0, *ARGS) - b.setlimit(len(s)) + b.limit = len(s) self.assertEquals(str(b), s) def test_pack_method(self): @@ -204,7 +183,7 @@ # Pack directly into the buffer and compare the strings. b = hotbuf(CAPACITY) - b.setlimit(len(s)) + b.limit = len(s) b.pack(self.fmt, *ARGS) self.assertEquals(b.position, self.fmt.size) b.flip() @@ -237,7 +216,7 @@ def test_zerolen( self ): b = hotbuf(CAPACITY) - b.setlimit(0) + b.limit = 0 self.assertEquals(str(b), '') self.assertEquals(b.getstr(), '') @@ -257,7 +236,7 @@ self.assertEquals(b.count('ab'), 1) self.assertEquals(b.count('d'), 2) self.assertEquals(b.count('1' * 100), 0) - b.advance(1) + b.position += 1 self.assertEquals(b.count('ab'), 0) self.assertEquals(b.count('d'), 2) self.assertEquals(b.count('1' * 100), 0) @@ -282,7 +261,7 @@ self.assertEquals(b.find('ab'), 0) self.assertEquals(b.find('d'), 3) self.assertEquals(b.find('1' * 100), -1) - b.advance(1) + b.position += 1 self.assertEquals(b.find('ab'), -1) self.assertEquals(b.find('d'), 2) self.assertEquals(b.find('1' * 100), -1) @@ -294,7 +273,7 @@ def test_nonzero(self): b = hotbuf(CAPACITY) self.assertEquals(bool(b), True) - b.setposition(b.limit) + b.position = b.limit self.assertEquals(bool(b), False) @@ -419,6 +398,8 @@ """ Use case for newline-delimited data. """ + newline, cr = ord('\n'), ord('\r') + # Initiallly put some data into the buffer. hot.putstr(read(len(hot))) @@ -428,18 +409,25 @@ abslimit = hot.limit mark_position = hot.position # setmark + print 1, repr(hot) + + # Loop over the current buffer contents while hot: # Save the starting position start = hot.position + print 2, repr(hot) + ## FIXME we need to replace what follows by the hot.find method, the ## overhead of funcall for every char is too high # Loop over all characters while 1: + print 3, repr(hot) + # If we got to the end of the line - if hot.getbyte() == '\n': + if hot.getbyte() == newline: # Process the line we found # Calculate how much characters are needed to @@ -448,7 +436,7 @@ backup = 1 # Make sure we don't look before the first char if end - start > 1: - if hot.getbyte(end - 2) == '\r': + if hot.getbyte(end - 2) == cr: backup = 2 # Restrict the window to the current line @@ -469,6 +457,8 @@ if not hot: break + print 4, repr(hot) + # Set the position to the last marker hot.position = mark_position # reset @@ -487,7 +477,7 @@ """ inp = StringIO(self.data1) hot = hotbuf(CAPACITY) - + lineidx = [0] def assert_lines( hot ): "Assert the lines we process are the ones we expect." From python-checkins at python.org Sat May 27 13:37:40 2006 From: python-checkins at python.org (richard.tew) Date: Sat, 27 May 2006 13:37:40 +0200 (CEST) Subject: [Python-checkins] r46448 - python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Message-ID: <20060527113740.D5B5A1E4006@bag.python.org> Author: richard.tew Date: Sat May 27 13:37:40 2006 New Revision: 46448 Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Log: Fix for WindowsError test arguments. Modified: python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py ============================================================================== --- python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py (original) +++ python/branches/sreifschneider-newnewexcept/Lib/test/test_exceptions.py Sat May 27 13:37:40 2006 @@ -263,11 +263,11 @@ ] try: exceptionList.append( - ( WindowsError, ('errnoStr', 'strErrorStr', 'filenameStr'), - { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + ( WindowsError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), 'strerror' : 'strErrorStr', - 'errno' : 'errnoStr', 'filename' : 'filenameStr', - 'winerror' : 'foo' })) + 'errno' : 22, 'filename' : 'filenameStr', + 'winerror' : 1 })) except NameError: pass for args in exceptionList: From python-checkins at python.org Sat May 27 13:41:47 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 13:41:47 +0200 (CEST) Subject: [Python-checkins] r46449 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060527114147.C74441E4006@bag.python.org> Author: tim.peters Date: Sat May 27 13:41:47 2006 New Revision: 46449 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Typo repair. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 13:41:47 2006 @@ -772,7 +772,7 @@ error code. */ errcode = PyInt_AsLong(self->myerrno); if (errcode == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError) + if (PyErr_ExceptionMatches(PyExc_TypeError)) /* give a clearer error message */ PyErr_SetString(PyExc_TypeError, "errno has to be an integer"); goto failed; From python-checkins at python.org Sat May 27 13:47:13 2006 From: python-checkins at python.org (bob.ippolito) Date: Sat, 27 May 2006 13:47:13 +0200 (CEST) Subject: [Python-checkins] r46450 - python/trunk/Modules/_struct.c Message-ID: <20060527114713.0D77A1E4006@bag.python.org> Author: bob.ippolito Date: Sat May 27 13:47:12 2006 New Revision: 46450 Modified: python/trunk/Modules/_struct.c Log: Remove the range checking and int usage #defines from _struct and strip out the now-dead code Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Sat May 27 13:47:12 2006 @@ -17,17 +17,6 @@ typedef int Py_ssize_t; #endif - -/* PY_USE_INT_WHEN_POSSIBLE is a flag that changes the - struct API to return int instead of long when possible. This is - often a significant performance improvement. */ -#define PY_USE_INT_WHEN_POSSIBLE 1 - -/* PY_STRUCT_RANGE_CHECKING performs range checking on all arguments - to be packed. This will break some incorrect code that happened - to accidentally do the right thing anyway (such as binhex). */ -#define PY_STRUCT_RANGE_CHECKING 1 - /* The translation function for each format character is table driven */ typedef struct _formatdef { char format; @@ -232,7 +221,6 @@ return PyFloat_FromDouble(x); } -#ifdef PY_STRUCT_RANGE_CHECKING /* Helper to format the range error exceptions */ static int _range_error(char format, Py_ssize_t size, int is_unsigned) @@ -261,7 +249,6 @@ } return -1; } -#endif @@ -331,10 +318,8 @@ { unsigned int x; memcpy((char *)&x, p, sizeof x); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong((long)x); -#endif return PyLong_FromUnsignedLong((unsigned long)x); } @@ -351,10 +336,8 @@ { unsigned long x; memcpy((char *)&x, p, sizeof x); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong((long)x); -#endif return PyLong_FromUnsignedLong(x); } @@ -368,10 +351,8 @@ { PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); -#endif return PyLong_FromLongLong(x); } @@ -380,10 +361,8 @@ { unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); -#endif return PyLong_FromUnsignedLongLong(x); } @@ -497,7 +476,7 @@ int y; if (get_long(v, &x) < 0) return -1; -#if defined(PY_STRUCT_RANGE_CHECKING) && (SIZEOF_LONG > SIZEOF_INT) +#if (SIZEOF_LONG > SIZEOF_INT) if (x < INT_MIN || x > INT_MAX) return _range_error(f->format, sizeof(y), 0); #endif @@ -512,13 +491,9 @@ unsigned long x; unsigned int y; if (get_ulong(v, &x) < 0) -#ifdef PY_STRUCT_RANGE_CHECKING return _range_error(f->format, sizeof(y), 1); -#else - return -1; -#endif y = (unsigned int)x; -#if defined(PY_STRUCT_RANGE_CHECKING) && (SIZEOF_LONG > SIZEOF_INT) +#if (SIZEOF_LONG > SIZEOF_INT) if (x > UINT_MAX) return _range_error(f->format, sizeof(y), 1); #endif @@ -541,11 +516,7 @@ { unsigned long x; if (get_ulong(v, &x) < 0) -#ifdef PY_STRUCT_RANGE_CHECKING return _range_error(f->format, sizeof(x), 1); -#else - return -1; -#endif memcpy(p, (char *)&x, sizeof x); return 0; } @@ -663,20 +634,15 @@ do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong((long)x); -#else - if (SIZEOF_LONG > f->size) - return PyInt_FromLong((long)x); -#endif return PyLong_FromUnsignedLong(x); } static PyObject * bu_longlong(const char *p, const formatdef *f) { -#if HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG PY_LONG_LONG x = 0; Py_ssize_t i = f->size; do { @@ -685,10 +651,8 @@ /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) x |= -(x & (1L << (8 * f->size - 1))); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); -#endif return PyLong_FromLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -701,16 +665,14 @@ static PyObject * bu_ulonglong(const char *p, const formatdef *f) { -#if HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; Py_ssize_t i = f->size; do { x = (x<<8) | (*p++ & 0xFF); } while (--i > 0); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); -#endif return PyLong_FromUnsignedLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -740,15 +702,13 @@ if (get_long(v, &x) < 0) return -1; i = f->size; -#ifdef PY_STRUCT_RANGE_CHECKING if (i != SIZEOF_LONG && ( (i == 2 && (x < -32768 || x > 32767)) -#if SIZEOF_LONG != 4 +#if (SIZEOF_LONG != 4) || (i == 4) && (x < -2147483648L || x > -2147483647L) #endif )) return _range_error(f->format, i, 0); -#endif do { p[--i] = (char)x; x >>= 8; @@ -764,10 +724,8 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; -#ifdef PY_STRUCT_RANGE_CHECKING if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); -#endif do { p[--i] = (char)x; x >>= 8; @@ -875,20 +833,15 @@ do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong((long)x); -#else - if (SIZEOF_LONG > f->size) - return PyInt_FromLong((long)x); -#endif return PyLong_FromUnsignedLong((long)x); } static PyObject * lu_longlong(const char *p, const formatdef *f) { -#if HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG PY_LONG_LONG x = 0; Py_ssize_t i = f->size; do { @@ -897,10 +850,8 @@ /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) x |= -(x & (1L << (8 * f->size - 1))); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); -#endif return PyLong_FromLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -913,16 +864,14 @@ static PyObject * lu_ulonglong(const char *p, const formatdef *f) { -#if HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; Py_ssize_t i = f->size; do { x = (x<<8) | (p[--i] & 0xFF); } while (i > 0); -#ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); -#endif return PyLong_FromUnsignedLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -952,15 +901,13 @@ if (get_long(v, &x) < 0) return -1; i = f->size; -#ifdef PY_STRUCT_RANGE_CHECKING if (i != SIZEOF_LONG && ( (i == 2 && (x < -32768 || x > 32767)) -#if SIZEOF_LONG != 4 +#if (SIZEOF_LONG != 4) || (i == 4) && (x < -2147483648L || x > -2147483647L) #endif )) return _range_error(f->format, i, 0); -#endif do { *p++ = (char)x; x >>= 8; @@ -976,10 +923,8 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; -#ifdef PY_STRUCT_RANGE_CHECKING if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) return _range_error(f->format, f->size, 1); -#endif do { *p++ = (char)x; x >>= 8; From python-checkins at python.org Sat May 27 13:53:45 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 13:53:45 +0200 (CEST) Subject: [Python-checkins] r46451 - in sandbox/trunk/hotbuffer: Modules/_hotbuf.c README.txt test_hotbuf.py Message-ID: <20060527115345.DB6D01E4006@bag.python.org> Author: martin.blais Date: Sat May 27 13:53:45 2006 New Revision: 46451 Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Fixed a few bugs and line delimited use case. Modified: sandbox/trunk/hotbuffer/Modules/_hotbuf.c ============================================================================== --- sandbox/trunk/hotbuffer/Modules/_hotbuf.c (original) +++ sandbox/trunk/hotbuffer/Modules/_hotbuf.c Sat May 27 13:53:45 2006 @@ -466,13 +466,14 @@ This does then not increment the position."); static PyObject* -hotbuf_getbyterel(PyHotbufObject *self, PyObject* args) +hotbuf_getbyterel(PyHotbufObject *self, PyObject* arg) { - Py_ssize_t offset; + Py_ssize_t offset = -1; Py_ssize_t read_position; /* Extract the offset */ - if (!PyArg_ParseTuple(args, "n:hotbuf", &offset)) + offset = PyInt_AsSsize_t(arg); + if (offset == -1 && PyErr_Occurred()) return NULL; /* Validate position */ @@ -480,7 +481,7 @@ CHECK_LIMIT_RETURN(read_position, NULL); /* Note that we do not increment, on purpose. */ - return PyInt_FromLong(*(unsigned char*)(read_position)); + return PyInt_FromLong(*(unsigned char*)(self->b_ptr + read_position)); } Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Sat May 27 13:53:45 2006 @@ -21,6 +21,11 @@ TODO ==== +* Should getbyterel() implement getting negative offsets from the end of the + window? + + - BTW getbyterel() should be implemented using the slicing operators + * Remove the advbytes argument to pop(), it is confusing. * Remove the mark, save() and restore(). Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 13:53:45 2006 @@ -402,6 +402,7 @@ # Initiallly put some data into the buffer. hot.putstr(read(len(hot))) + hot.flip() # Look over the entire input. while 1: @@ -409,23 +410,16 @@ abslimit = hot.limit mark_position = hot.position # setmark - print 1, repr(hot) - - # Loop over the current buffer contents while hot: # Save the starting position start = hot.position - print 2, repr(hot) - ## FIXME we need to replace what follows by the hot.find method, the ## overhead of funcall for every char is too high # Loop over all characters while 1: - print 3, repr(hot) - # If we got to the end of the line if hot.getbyte() == newline: # Process the line we found @@ -434,9 +428,10 @@ # backup to remove the EOL marker end = hot.position backup = 1 + # Make sure we don't look before the first char if end - start > 1: - if hot.getbyte(end - 2) == cr: + if hot.getbyterel(-2) == cr: backup = 2 # Restrict the window to the current line @@ -448,8 +443,8 @@ # Advance the buffer window to the rest of the # buffer after the line + hot.limit = abslimit mark_position = hot.position = end - hot.limit(abslimit) break @@ -457,8 +452,6 @@ if not hot: break - print 4, repr(hot) - # Set the position to the last marker hot.position = mark_position # reset @@ -470,6 +463,7 @@ if not s: break # Finished the input, exit. hot.putstr(s) + hot.flip() def test_newline_delim_data( self ): """ @@ -481,8 +475,7 @@ lineidx = [0] def assert_lines( hot ): "Assert the lines we process are the ones we expect." - print hot - self.assertEquals(hot, self.lines1[lineidx[0]]) + self.assertEquals(str(hot), self.lines1[lineidx[0]]) lineidx[0] += 1 self.parse_newline_delim(hot, inp.read, assert_lines) @@ -647,7 +640,7 @@ # def test_main(): test_support.run_unittest(HotbufTestCase) - #test_support.run_unittest(HotbufUseCases) + test_support.run_unittest(HotbufUseCases) if __name__ == "__main__": test_main() From python-checkins at python.org Sat May 27 13:54:45 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 13:54:45 +0200 (CEST) Subject: [Python-checkins] r46452 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060527115445.C03C21E4006@bag.python.org> Author: tim.peters Date: Sat May 27 13:54:45 2006 New Revision: 46452 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Shouldn't decref the module dict. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 13:54:45 2006 @@ -2120,7 +2120,6 @@ if (!PyExc_MemoryErrorInst) Py_FatalError("Cannot pre-allocate MemoryError instance\n"); - Py_DECREF(bdict); Py_DECREF(bltinmod); } From python-checkins at python.org Sat May 27 13:55:20 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 13:55:20 +0200 (CEST) Subject: [Python-checkins] r46453 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Message-ID: <20060527115520.E91AC1E4010@bag.python.org> Author: georg.brandl Date: Sat May 27 13:55:20 2006 New Revision: 46453 Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Log: Remove some superfluous XDECREFs. Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c ============================================================================== --- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c (original) +++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Sat May 27 13:55:20 2006 @@ -790,8 +790,7 @@ return (PyObject *)self; failed: /* Could not set errno. */ - Py_XDECREF(o_errcode); - Py_XDECREF(self); + Py_DECREF(self); return NULL; } @@ -820,7 +819,7 @@ return -1; posix_errno = winerror_to_errno(errcode); - Py_XDECREF(self->winerror); + Py_DECREF(self->winerror); self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); @@ -2057,10 +2056,10 @@ bltinmod = PyImport_ImportModule("__builtin__"); if (bltinmod == NULL) - Py_FatalError("exceptions bootstrapping error."); + Py_FatalError("exceptions bootstrapping error."); bdict = PyModule_GetDict(bltinmod); if (bdict == NULL) - Py_FatalError("exceptions bootstrapping error."); + Py_FatalError("exceptions bootstrapping error."); POST_INIT(BaseException) POST_INIT(Exception) From bob at redivi.com Sat May 27 14:06:58 2006 From: bob at redivi.com (Bob Ippolito) Date: Sat, 27 May 2006 12:06:58 +0000 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: On May 26, 2006, at 4:56 PM, Guido van Rossum wrote: > On 5/26/06, martin.blais wrote: >> Log: >> Support for buffer protocol for socket and struct. >> >> * Added socket.recv_buf() and socket.recvfrom_buf() methods, that >> use the buffer >> protocol (send and sendto already did). >> >> * Added struct.pack_to(), that is the corresponding buffer >> compatible method to >> unpack_from(). > > Hm... The file object has a similar method readinto(). Perhaps the > methods introduced here could follow that lead instead of using two > different new naming conventions? (speaking specifically about struct and not socket) pack_to and unpack_from are named as such because they work with objects that support the buffer API (not file-like-objects). I couldn't find any existing convention for objects that manipulate buffers in such a way. If there is an existing convention then I'd be happy to rename these. "readinto" seems to imply that some kind of position is being incremented. Grammatically it only works if it's implemented on all buffer objects, but in this case it's implemented on the Struct type. -bob From amk at amk.ca Sat May 27 14:14:50 2006 From: amk at amk.ca (A.M. Kuchling) Date: Sat, 27 May 2006 08:14:50 -0400 Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: <20060527103949.6437A1E4006@bag.python.org> References: <20060527103949.6437A1E4006@bag.python.org> Message-ID: <20060527121450.GA7023@rogue.amk.ca> On Sat, May 27, 2006 at 12:39:49PM +0200, fredrik.lundh wrote: > +/* Py_LOCAL can be used instead of static to get the fastest possible calling > + * convention for functions that are local to a given module. I've attached a patch that makes Py_LOCAL use a GCC attribute on x86 that supposedly passes some parameters in registers. On my machine the difference seems to be in the noise (sometimes faster, sometimes slower), but perhaps Fredrik or Andrew would like to try it; they're probably very good at benchmarking the string types by now. --amk -------------- next part -------------- Index: Include/pyport.h =================================================================== --- Include/pyport.h (revision 46443) +++ Include/pyport.h (working copy) @@ -157,6 +157,7 @@ #undef USE_INLINE /* XXX - set via configure? */ #if defined(_MSC_VER) +/* Platform-specific case: Visual Studio */ #if defined(PY_LOCAL_AGGRESSIVE) /* enable more aggressive optimization for visual studio */ #pragma optimize("agtw", on) @@ -166,10 +167,24 @@ /* fastest possible local call under MSVC */ #define Py_LOCAL(type) static type __fastcall #define Py_LOCAL_INLINE(type) static __inline type __fastcall + +#elif defined(__i386__) && defined(__GNUC__) +/* Platform-specific case: GCC on x86 */ + +#if defined(USE_INLINE) +#define Py_LOCAL(type) static type Py_GCC_ATTRIBUTE((regparm(3))) +#define Py_LOCAL_INLINE(type) static inline type Py_GCC_ATTRIBUTE((regparm(3))) +#else +#define Py_LOCAL(type) static type Py_GCC_ATTRIBUTE((regparm(3))) +#define Py_LOCAL_INLINE(type) static type Py_GCC_ATTRIBUTE((regparm(3))) +#endif + #elif defined(USE_INLINE) +/* Generic case: inline is enabled */ #define Py_LOCAL(type) static type #define Py_LOCAL_INLINE(type) static inline type #else +/* Generic case */ #define Py_LOCAL(type) static type #define Py_LOCAL_INLINE(type) static type #endif From python-checkins at python.org Sat May 27 14:11:36 2006 From: python-checkins at python.org (bob.ippolito) Date: Sat, 27 May 2006 14:11:36 +0200 (CEST) Subject: [Python-checkins] r46454 - in python/trunk: Lib/struct.py Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060527121136.027DD1E4011@bag.python.org> Author: bob.ippolito Date: Sat May 27 14:11:36 2006 New Revision: 46454 Modified: python/trunk/Lib/struct.py python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: Fix up struct docstrings, add struct.pack_to function for symmetry Modified: python/trunk/Lib/struct.py ============================================================================== --- python/trunk/Lib/struct.py (original) +++ python/trunk/Lib/struct.py Sat May 27 14:11:36 2006 @@ -62,6 +62,18 @@ o = _compile(fmt) return o.pack(*args) +def pack_to(fmt, buf, offset, *args): + """ + Pack the values v2, v2, ... according to fmt, write + the packed bytes into the writable buffer buf starting at offset. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack_to(buf, offset, *args) + def unpack(fmt, s): """ Unpack the string, containing packed C structure data, according Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Sat May 27 14:11:36 2006 @@ -509,6 +509,28 @@ self.assertRaises(struct.error, s.pack_to, small_buf, 0, test_string) self.assertRaises(struct.error, s.pack_to, small_buf, 2, test_string) + def test_pack_to_fn( self ): + test_string = 'Reykjavik rocks, eow!' + writable_buf = array.array('c', ' '*100) + fmt = '21s' + pack_to = lambda *args: struct.pack_to(fmt, *args) + + # Test without offset + pack_to(writable_buf, 0, test_string) + from_buf = writable_buf.tostring()[:len(test_string)] + self.assertEquals(from_buf, test_string) + + # Test with offset. + pack_to(writable_buf, 10, test_string) + from_buf = writable_buf.tostring()[:len(test_string)+10] + self.assertEquals(from_buf, (test_string[:10] + test_string)) + + # Go beyond boundaries. + small_buf = array.array('c', ' '*10) + self.assertRaises(struct.error, pack_to, small_buf, 0, test_string) + self.assertRaises(struct.error, pack_to, small_buf, 2, test_string) + + def test_main(): test.test_support.run_unittest(PackBufferTestCase) Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Sat May 27 14:11:36 2006 @@ -1277,7 +1277,7 @@ PyDoc_STRVAR(s_unpack__doc__, -"unpack(str) -> (v1, v2, ...)\n\ +"S.unpack(str) -> (v1, v2, ...)\n\ \n\ Return tuple containing values unpacked according to this Struct's format.\n\ Requires len(str) == self.size. See struct.__doc__ for more on format\n\ @@ -1299,7 +1299,7 @@ } PyDoc_STRVAR(s_unpack_from__doc__, -"unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\ +"S.unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\ \n\ Return tuple containing values unpacked according to this Struct's format.\n\ Unlike unpack, unpack_from can unpack values from any object supporting\n\ @@ -1407,7 +1407,7 @@ PyDoc_STRVAR(s_pack__doc__, -"pack(v1, v2, ...) -> string\n\ +"S.pack(v1, v2, ...) -> string\n\ \n\ Return a string containing values v1, v2, ... packed according to this\n\ Struct's format. See struct.__doc__ for more on format strings."); @@ -1445,11 +1445,11 @@ } PyDoc_STRVAR(s_pack_to__doc__, -"pack_to(buffer, offset, v1, v2, ...)\n\ +"S.pack_to(buffer, offset, v1, v2, ...)\n\ \n\ Pack the values v2, v2, ... according to this Struct's format, write \n\ -the packed bytes into the given buffer at the given offset. Note that \n\ -the offset is not an optional argument. See struct.__doc__ for \n\ +the packed bytes into the writable buffer buf starting at offset. Note\n\ +that the offset is not an optional argument. See struct.__doc__ for \n\ more on format strings."); static PyObject * @@ -1530,8 +1530,8 @@ #define OFF(x) offsetof(PyStructObject, x) static PyGetSetDef s_getsetlist[] = { - {"format", (getter)s_get_format, (setter)NULL, "buffer's capacity", NULL}, - {"size", (getter)s_get_size, (setter)NULL, "buffer's position", NULL}, + {"format", (getter)s_get_format, (setter)NULL, "struct format string", NULL}, + {"size", (getter)s_get_size, (setter)NULL, "struct size in bytes", NULL}, {NULL} /* sentinel */ }; From buildbot at python.org Sat May 27 14:18:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 27 May 2006 12:18:15 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060527121815.4330B1E400C@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/833 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat May 27 14:20:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 27 May 2006 12:20:30 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060527122030.9F2E01E4006@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/823 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 14:23:57 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 14:23:57 +0200 (CEST) Subject: [Python-checkins] r46455 - sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060527122357.639011E4006@bag.python.org> Author: martin.blais Date: Sat May 27 14:23:56 2006 New Revision: 46455 Modified: sandbox/trunk/hotbuffer/test_hotbuf.py Log: Optimized the newline delimited use case. Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 14:23:56 2006 @@ -389,9 +389,7 @@ knowledge. There are many constraint networks that implement the same set of constraints, and the user must choose from the set of mathematically equivalent networks a -suitable network to specify a particular computation. - -""" +suitable network to specify a particular computation.""" lines1 = map(str.strip, data1.splitlines()) def parse_newline_delim( self, hot, read, process_line ): @@ -399,7 +397,7 @@ Use case for newline-delimited data. """ newline, cr = ord('\n'), ord('\r') - + # Initiallly put some data into the buffer. hot.putstr(read(len(hot))) hot.flip() @@ -412,48 +410,33 @@ # Loop over the current buffer contents while hot: - # Save the starting position - start = hot.position + # Loop over all characters + # If we got to the end of the line + nidx = hot.find('\n') + if nidx != -1: + # Calculate how much characters are needed to + # backup to remove the EOL marker + backup = 0 + + # Make sure we don't look before the first char + if nidx > 0: + if hot.getbyterel(nidx - 1) == cr: + backup = 1 -## FIXME we need to replace what follows by the hot.find method, the -## overhead of funcall for every char is too high + # Restrict the window to the current line + hot.position = mark_position + hot.limit = mark_position + nidx - backup - # Loop over all characters - while 1: - # If we got to the end of the line - if hot.getbyte() == newline: - # Process the line we found - - # Calculate how much characters are needed to - # backup to remove the EOL marker - end = hot.position - backup = 1 - - # Make sure we don't look before the first char - if end - start > 1: - if hot.getbyterel(-2) == cr: - backup = 2 - - # Restrict the window to the current line - hot.position = mark_position # reset - hot.limit = end - backup - - # Process the line. - process_line(hot) - - # Advance the buffer window to the rest of the - # buffer after the line - hot.limit = abslimit - mark_position = hot.position = end - - break - - # If the buffer is empty, get out - if not hot: - break + # Process the line. + process_line(hot) - # Set the position to the last marker - hot.position = mark_position # reset + # Advance the buffer window to the rest of the + # buffer after the line + hot.limit = abslimit + hot.position += nidx + 1 + mark_position = hot.position + else: + break # Read more data in the buffer. ## FIXME: we need to support reading from a file directly into the @@ -461,17 +444,23 @@ hot.compact() s = read(len(hot)) if not s: + hot.flip() break # Finished the input, exit. hot.putstr(s) hot.flip() + # Process the little bit at the end. + if hot: + process_line(hot) + + def test_newline_delim_data( self ): """ Test for newline-delimited data. """ inp = StringIO(self.data1) - hot = hotbuf(CAPACITY) - + hot = hotbuf(256) + lineidx = [0] def assert_lines( hot ): "Assert the lines we process are the ones we expect." From python-checkins at python.org Sat May 27 14:29:26 2006 From: python-checkins at python.org (richard.jones) Date: Sat, 27 May 2006 14:29:26 +0200 (CEST) Subject: [Python-checkins] r46456 - in python/trunk: Doc/tut/tut.tex Include/pyerrors.h Lib/codeop.py Lib/ctypes/test/test_structures.py Lib/test/exception_hierarchy.txt Lib/test/output/test_logging Lib/test/test_codeccallbacks.py Lib/test/test_exceptions.py Lib/warnings.py Makefile.pre.in Modules/cPickle.c Objects/exceptions.c PCbuild/pythoncore.vcproj Python/errors.c Python/exceptions.c Python/pythonrun.c Message-ID: <20060527122926.85D731E4006@bag.python.org> Author: richard.jones Date: Sat May 27 14:29:24 2006 New Revision: 46456 Added: python/trunk/Objects/exceptions.c (props changed) - copied unchanged from r46453, python/branches/sreifschneider-newnewexcept/Objects/exceptions.c Removed: python/trunk/Python/exceptions.c Modified: python/trunk/Doc/tut/tut.tex python/trunk/Include/pyerrors.h python/trunk/Lib/codeop.py python/trunk/Lib/ctypes/test/test_structures.py python/trunk/Lib/test/exception_hierarchy.txt python/trunk/Lib/test/output/test_logging python/trunk/Lib/test/test_codeccallbacks.py python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/warnings.py python/trunk/Makefile.pre.in python/trunk/Modules/cPickle.c python/trunk/PCbuild/pythoncore.vcproj python/trunk/Python/errors.c python/trunk/Python/pythonrun.c Log: Conversion of exceptions over from faked-up classes to new-style C types. Modified: python/trunk/Doc/tut/tut.tex ============================================================================== --- python/trunk/Doc/tut/tut.tex (original) +++ python/trunk/Doc/tut/tut.tex Sat May 27 14:29:24 2006 @@ -2711,7 +2711,7 @@ 'FloatingPointError', 'FutureWarning', 'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', - 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', + 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', Modified: python/trunk/Include/pyerrors.h ============================================================================== --- python/trunk/Include/pyerrors.h (original) +++ python/trunk/Include/pyerrors.h Sat May 27 14:29:24 2006 @@ -4,6 +4,72 @@ extern "C" { #endif +/* Error objects */ + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; +} PyBaseExceptionObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +#ifdef Py_USING_UNICODE +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + PyObject *start; + PyObject *end; + PyObject *reason; +} PyUnicodeErrorObject; +#endif + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; +} PyEnvironmentErrorObject; + +#ifdef MS_WINDOWS +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; +} PyWindowsErrorObject; +#endif /* Error handling definitions */ @@ -104,8 +170,6 @@ PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; -/* PyExc_OverflowWarning will go away for Python 2.5 */ -PyAPI_DATA(PyObject *) PyExc_OverflowWarning; PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; PyAPI_DATA(PyObject *) PyExc_FutureWarning; PyAPI_DATA(PyObject *) PyExc_ImportWarning; Modified: python/trunk/Lib/codeop.py ============================================================================== --- python/trunk/Lib/codeop.py (original) +++ python/trunk/Lib/codeop.py Sat May 27 14:29:24 2006 @@ -95,15 +95,7 @@ if code: return code - try: - e1 = err1.__dict__ - except AttributeError: - e1 = err1 - try: - e2 = err2.__dict__ - except AttributeError: - e2 = err2 - if not code1 and e1 == e2: + if not code1 and repr(err1) == repr(err2): raise SyntaxError, err1 def _compile(source, filename, symbol): Modified: python/trunk/Lib/ctypes/test/test_structures.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_structures.py (original) +++ python/trunk/Lib/ctypes/test/test_structures.py Sat May 27 14:29:24 2006 @@ -294,20 +294,20 @@ # In Python 2.5, Exception is a new-style class, and the repr changed if issubclass(Exception, object): self.failUnlessEqual(msg, - "(Phone) : " + "(Phone) : " "expected string or Unicode object, int found") else: self.failUnlessEqual(msg, - "(Phone) exceptions.TypeError: " + "(Phone) TypeError: " "expected string or Unicode object, int found") cls, msg = self.get_except(Person, "Someone", ("a", "b", "c")) self.failUnlessEqual(cls, RuntimeError) if issubclass(Exception, object): self.failUnlessEqual(msg, - "(Phone) : too many initializers") + "(Phone) : too many initializers") else: - self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers") + self.failUnlessEqual(msg, "(Phone) ValueError: too many initializers") def get_except(self, func, *args): Modified: python/trunk/Lib/test/exception_hierarchy.txt ============================================================================== --- python/trunk/Lib/test/exception_hierarchy.txt (original) +++ python/trunk/Lib/test/exception_hierarchy.txt Sat May 27 14:29:24 2006 @@ -15,6 +15,7 @@ | | +-- IOError | | +-- OSError | | +-- WindowsError (Windows) + | | +-- VMSError (VMS) | +-- EOFError | +-- ImportError | +-- LookupError @@ -43,5 +44,4 @@ +-- SyntaxWarning +-- UserWarning +-- FutureWarning - +-- OverflowWarning [not generated by the interpreter] +-- ImportWarning Modified: python/trunk/Lib/test/output/test_logging ============================================================================== --- python/trunk/Lib/test/output/test_logging (original) +++ python/trunk/Lib/test/output/test_logging Sat May 27 14:29:24 2006 @@ -488,12 +488,12 @@ -- log_test4 begin --------------------------------------------------- config0: ok. config1: ok. -config2: -config3: +config2: +config3: -- log_test4 end --------------------------------------------------- -- log_test5 begin --------------------------------------------------- ERROR:root:just testing -... Don't panic! +... Don't panic! -- log_test5 end --------------------------------------------------- -- logrecv output begin --------------------------------------------------- ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) Modified: python/trunk/Lib/test/test_codeccallbacks.py ============================================================================== --- python/trunk/Lib/test/test_codeccallbacks.py (original) +++ python/trunk/Lib/test/test_codeccallbacks.py Sat May 27 14:29:24 2006 @@ -18,30 +18,12 @@ self.pos = len(exc.object) return (u"", oldpos) -# A UnicodeEncodeError object without a start attribute -class NoStartUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.start - # A UnicodeEncodeError object with a bad start attribute class BadStartUnicodeEncodeError(UnicodeEncodeError): def __init__(self): UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") self.start = [] -# A UnicodeEncodeError object without an end attribute -class NoEndUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.end - -# A UnicodeEncodeError object without an object attribute -class NoObjectUnicodeEncodeError(UnicodeEncodeError): - def __init__(self): - UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") - del self.object - # A UnicodeEncodeError object with a bad object attribute class BadObjectUnicodeEncodeError(UnicodeEncodeError): def __init__(self): @@ -478,55 +460,15 @@ UnicodeError("ouch") ) self.assertRaises( - AttributeError, - codecs.replace_errors, - NoStartUnicodeEncodeError() - ) - self.assertRaises( - TypeError, - codecs.replace_errors, - BadStartUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoObjectUnicodeEncodeError() - ) - self.assertRaises( TypeError, codecs.replace_errors, BadObjectUnicodeEncodeError() ) self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeDecodeError() - ) - self.assertRaises( TypeError, codecs.replace_errors, BadObjectUnicodeDecodeError() ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoStartUnicodeTranslateError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoEndUnicodeTranslateError() - ) - self.assertRaises( - AttributeError, - codecs.replace_errors, - NoObjectUnicodeTranslateError() - ) # With the correct exception, "replace" returns an "?" or u"\ufffd" replacement self.assertEquals( codecs.replace_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")), @@ -565,21 +507,6 @@ codecs.xmlcharrefreplace_errors, UnicodeTranslateError(u"\u3042", 0, 1, "ouch") ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoStartUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoEndUnicodeEncodeError() - ) - self.assertRaises( - AttributeError, - codecs.xmlcharrefreplace_errors, - NoObjectUnicodeEncodeError() - ) # Use the correct exception cs = (0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, 0x3042) s = "".join(unichr(c) for c in cs) Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Sat May 27 14:29:24 2006 @@ -81,14 +81,6 @@ except NameError: pass r(OverflowError) -# XXX -# Obscure: in 2.2 and 2.3, this test relied on changing OverflowWarning -# into an error, in order to trigger OverflowError. In 2.4, OverflowWarning -# should no longer be generated, so the focus of the test shifts to showing -# that OverflowError *isn't* generated. OverflowWarning should be gone -# in Python 2.5, and then the filterwarnings() call, and this comment, -# should go away. -warnings.filterwarnings("error", "", OverflowWarning, __name__) x = 1 for dummy in range(128): x += x # this simply shouldn't blow up @@ -206,3 +198,88 @@ test_capi2() unlink(TESTFN) + +# test that exception attributes are happy. +try: str(u'Hello \u00E1') +except Exception, e: sampleUnicodeEncodeError = e +try: unicode('\xff') +except Exception, e: sampleUnicodeDecodeError = e +exceptionList = [ + ( BaseException, (), { 'message' : '', 'args' : () }), + ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), + ( BaseException, ('foo', ), { 'message' : 'foo', 'args' : ( 'foo', ) }), + ( BaseException, ('foo', 1), { 'message' : '', 'args' : ( 'foo', 1 ) }), + ( SystemExit, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), + 'code' : 'foo' }), + ( IOError, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), }), + ( IOError, ('foo', 'bar'), { 'message' : '', + 'args' : ('foo', 'bar'), }), + ( IOError, ('foo', 'bar', 'baz'), + { 'message' : '', 'args' : ('foo', 'bar'), }), + ( EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 'errnoStr', 'filename' : 'filenameStr' }), + ( EnvironmentError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), + 'strerror' : 'strErrorStr', 'errno' : 1, + 'filename' : 'filenameStr' }), + ( SyntaxError, ('msgStr',), + { 'message' : 'msgStr', 'args' : ('msgStr', ), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', + 'textStr')), + { 'message' : '', 'args' : ('msgStr', ('filenameStr', + 'linenoStr', 'offsetStr', 'textStr' )), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : 'filenameStr', 'lineno' : 'linenoStr', + 'offset' : 'offsetStr', 'text' : 'textStr' }), + ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', + 'textStr', 'print_file_and_lineStr'), + { 'message' : '', 'args' : ('msgStr', 'filenameStr', + 'linenoStr', 'offsetStr', 'textStr', + 'print_file_and_lineStr'), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( UnicodeError, (), + { 'message' : '', 'args' : (), }), + ( sampleUnicodeEncodeError, + { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : u'Hello \xe1', + 'start' : 6, 'reason' : 'ordinal not in range(128)' }), + ( sampleUnicodeDecodeError, + { 'message' : '', 'args' : ('ascii', '\xff', 0, 1, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : '\xff', + 'start' : 0, 'reason' : 'ordinal not in range(128)' }), + ( UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), + { 'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), + 'object' : u'\u3042', 'reason' : 'ouch', + 'start' : 0, 'end' : 1 }), + ] +try: + exceptionList.append( + ( WindowsError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 22, 'filename' : 'filenameStr', + 'winerror' : 1 })) +except NameError: pass + +for args in exceptionList: + expected = args[-1] + try: + if len(args) == 2: raise args[0] + else: raise apply(args[0], args[1]) + except BaseException, e: + for checkArgName in expected.keys(): + if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]): + raise TestFailed('Checking exception arguments, exception ' + '"%s", attribute "%s" expected %s got %s.' % + ( repr(e), checkArgName, + repr(expected[checkArgName]), + repr(getattr(e, checkArgName)) )) Modified: python/trunk/Lib/warnings.py ============================================================================== --- python/trunk/Lib/warnings.py (original) +++ python/trunk/Lib/warnings.py Sat May 27 14:29:24 2006 @@ -261,6 +261,4 @@ # Module initialization _processoptions(sys.warnoptions) -# XXX OverflowWarning should go away for Python 2.5. -simplefilter("ignore", category=OverflowWarning, append=1) simplefilter("ignore", category=PendingDeprecationWarning, append=1) Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Sat May 27 14:29:24 2006 @@ -240,7 +240,6 @@ Python/asdl.o \ Python/ast.o \ Python/bltinmodule.o \ - Python/exceptions.o \ Python/ceval.o \ Python/compile.o \ Python/codecs.o \ @@ -289,6 +288,7 @@ Objects/complexobject.o \ Objects/descrobject.o \ Objects/enumobject.o \ + Objects/exceptions.o \ Objects/genobject.o \ Objects/fileobject.o \ Objects/floatobject.o \ Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Sat May 27 14:29:24 2006 @@ -5625,7 +5625,6 @@ if (!( t=PyDict_New())) return -1; if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" "def __str__(self):\n" " return self.args and ('%s' % self.args[0]) or '(what)'\n", Py_file_input, @@ -5645,7 +5644,6 @@ if (!( t=PyDict_New())) return -1; if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" "def __str__(self):\n" " a=self.args\n" " a=a and type(a[0]) or '(what)'\n" Modified: python/trunk/PCbuild/pythoncore.vcproj ============================================================================== --- python/trunk/PCbuild/pythoncore.vcproj (original) +++ python/trunk/PCbuild/pythoncore.vcproj Sat May 27 14:29:24 2006 @@ -494,7 +494,7 @@ RelativePath="..\Python\errors.c"> + RelativePath="..\Objects\exceptions.c"> Modified: python/trunk/Python/errors.c ============================================================================== --- python/trunk/Python/errors.c (original) +++ python/trunk/Python/errors.c Sat May 27 14:29:24 2006 @@ -557,9 +557,6 @@ if (PyDict_SetItemString(dict, "__module__", modulename) != 0) goto failure; } - classname = PyString_FromString(dot+1); - if (classname == NULL) - goto failure; if (PyTuple_Check(base)) { bases = base; /* INCREF as we create a new ref in the else branch */ @@ -569,7 +566,9 @@ if (bases == NULL) goto failure; } - result = PyClass_New(bases, dict, classname); + /* Create a real new-style class. */ + result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO", + dot+1, bases, dict); failure: Py_XDECREF(bases); Py_XDECREF(mydict); @@ -590,8 +589,11 @@ PyFile_WriteString("Exception ", f); if (t) { char* className = PyExceptionClass_Name(t); - PyObject* moduleName = - PyObject_GetAttrString(t, "__module__"); + PyObject* moduleName; + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; + moduleName = PyObject_GetAttrString(t, "__module__"); if (moduleName == NULL) PyFile_WriteString("", f); @@ -641,15 +643,11 @@ return 0; } else { - PyObject *args, *res; + PyObject *res; if (category == NULL) category = PyExc_RuntimeWarning; - args = Py_BuildValue("(sO)", message, category); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); + res = PyObject_CallFunction(func, "sO", message, category); if (res == NULL) return -1; Py_DECREF(res); @@ -677,18 +675,14 @@ return 0; } else { - PyObject *args, *res; + PyObject *res; if (category == NULL) category = PyExc_RuntimeWarning; if (registry == NULL) registry = Py_None; - args = Py_BuildValue("(sOsizO)", message, category, - filename, lineno, module, registry); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); + res = PyObject_CallFunction(func, "sOsizO", message, category, + filename, lineno, module, registry); if (res == NULL) return -1; Py_DECREF(res); @@ -709,7 +703,8 @@ /* add attributes for the line number and filename for the error */ PyErr_Fetch(&exc, &v, &tb); PyErr_NormalizeException(&exc, &v, &tb); - /* XXX check that it is, indeed, a syntax error */ + /* XXX check that it is, indeed, a syntax error. It might not + * be, though. */ tmp = PyInt_FromLong(lineno); if (tmp == NULL) PyErr_Clear(); Deleted: /python/trunk/Python/exceptions.c ============================================================================== --- /python/trunk/Python/exceptions.c Sat May 27 14:29:24 2006 +++ (empty file) @@ -1,2032 +0,0 @@ -/* This module provides the suite of standard class-based exceptions for - * Python's builtin module. This is a complete C implementation of what, - * in Python 1.5.2, was contained in the exceptions.py module. The problem - * there was that if exceptions.py could not be imported for some reason, - * the entire interpreter would abort. - * - * By moving the exceptions into C and statically linking, we can guarantee - * that the standard exceptions will always be available. - * - * - * written by Fredrik Lundh - * modifications, additions, cleanups, and proofreading by Barry Warsaw - * - * Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. - */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "osdefs.h" - -/* Caution: MS Visual C++ 6 errors if a single string literal exceeds - * 2Kb. So the module docstring has been broken roughly in half, using - * compile-time literal concatenation. - */ - -/* NOTE: If the exception class hierarchy changes, don't forget to update - * Doc/lib/libexcs.tex! - */ - -PyDoc_STRVAR(module__doc__, -"Python's standard exception class hierarchy.\n\ -\n\ -Exceptions found here are defined both in the exceptions module and the \n\ -built-in namespace. It is recommended that user-defined exceptions inherit \n\ -from Exception. See the documentation for the exception inheritance hierarchy.\n\ -" - - /* keep string pieces "small" */ -/* XXX(bcannon): exception hierarchy in Lib/test/exception_hierarchy.txt */ -); - - -/* Helper function for populating a dictionary with method wrappers. */ -static int -populate_methods(PyObject *klass, PyMethodDef *methods) -{ - PyObject *module; - int status = -1; - - if (!methods) - return 0; - - module = PyString_FromString("exceptions"); - if (!module) - return 0; - while (methods->ml_name) { - /* get a wrapper for the built-in function */ - PyObject *func = PyCFunction_NewEx(methods, NULL, module); - PyObject *meth; - - if (!func) - goto status; - - /* turn the function into an unbound method */ - if (!(meth = PyMethod_New(func, NULL, klass))) { - Py_DECREF(func); - goto status; - } - - /* add method to dictionary */ - status = PyObject_SetAttrString(klass, methods->ml_name, meth); - Py_DECREF(meth); - Py_DECREF(func); - - /* stop now if an error occurred, otherwise do the next method */ - if (status) - goto status; - - methods++; - } - status = 0; - status: - Py_DECREF(module); - return status; -} - - - -/* This function is used to create all subsequent exception classes. */ -static int -make_class(PyObject **klass, PyObject *base, - char *name, PyMethodDef *methods, - char *docstr) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (docstr) { - if (!(str = PyString_FromString(docstr))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - } - - if (!(*klass = PyErr_NewException(name, base, dict))) - goto finally; - - if (populate_methods(*klass, methods)) { - Py_DECREF(*klass); - *klass = NULL; - goto finally; - } - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - return status; -} - - -/* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */ -static PyObject * -get_self(PyObject *args) -{ - PyObject *self = PyTuple_GetItem(args, 0); - if (!self) { - /* Watch out for being called to early in the bootstrapping process */ - if (PyExc_TypeError) { - PyErr_SetString(PyExc_TypeError, - "unbound method must be called with instance as first argument"); - } - return NULL; - } - return self; -} - - - -/* Notes on bootstrapping the exception classes. - * - * First thing we create is the base class for all exceptions, called - * appropriately BaseException. Creation of this class makes no - * assumptions about the existence of any other exception class -- except - * for TypeError, which can conditionally exist. - * - * Next, Exception is created since it is the common subclass for the rest of - * the needed exceptions for this bootstrapping to work. StandardError is - * created (which is quite simple) followed by - * TypeError, because the instantiation of other exceptions can potentially - * throw a TypeError. Once these exceptions are created, all the others - * can be created in any order. See the static exctable below for the - * explicit bootstrap order. - * - * All classes after BaseException can be created using PyErr_NewException(). - */ - -PyDoc_STRVAR(BaseException__doc__, "Common base class for all exceptions"); - -/* - Set args and message attributes. - - Assumes self and args have already been set properly with set_self, etc. -*/ -static int -set_args_and_message(PyObject *self, PyObject *args) -{ - PyObject *message_val; - Py_ssize_t args_len = PySequence_Length(args); - - if (args_len < 0) - return 0; - - /* set args */ - if (PyObject_SetAttrString(self, "args", args) < 0) - return 0; - - /* set message */ - if (args_len == 1) - message_val = PySequence_GetItem(args, 0); - else - message_val = PyString_FromString(""); - if (!message_val) - return 0; - - if (PyObject_SetAttrString(self, "message", message_val) < 0) { - Py_DECREF(message_val); - return 0; - } - - Py_DECREF(message_val); - return 1; -} - -static PyObject * -BaseException__init__(PyObject *self, PyObject *args) -{ - if (!(self = get_self(args))) - return NULL; - - /* set args and message attribute */ - args = PySequence_GetSlice(args, 1, PySequence_Length(args)); - if (!args) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - Py_DECREF(args); - Py_RETURN_NONE; -} - - -static PyObject * -BaseException__str__(PyObject *_self, PyObject *self) -{ - PyObject *out, *args; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - switch (PySequence_Size(args)) { - case 0: - out = PyString_FromString(""); - break; - case 1: - { - PyObject *tmp = PySequence_GetItem(args, 0); - if (tmp) { - out = PyObject_Str(tmp); - Py_DECREF(tmp); - } - else - out = NULL; - break; - } - case -1: - PyErr_Clear(); - /* Fall through */ - default: - out = PyObject_Str(args); - break; - } - - Py_DECREF(args); - return out; -} - -#ifdef Py_USING_UNICODE -static PyObject * -BaseException__unicode__(PyObject *self, PyObject *args) -{ - Py_ssize_t args_len; - - if (!PyArg_ParseTuple(args, "O:__unicode__", &self)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - args_len = PySequence_Size(args); - if (args_len < 0) { - Py_DECREF(args); - return NULL; - } - - if (args_len == 0) { - Py_DECREF(args); - return PyUnicode_FromUnicode(NULL, 0); - } - else if (args_len == 1) { - PyObject *temp = PySequence_GetItem(args, 0); - PyObject *unicode_obj; - - if (!temp) { - Py_DECREF(args); - return NULL; - } - Py_DECREF(args); - unicode_obj = PyObject_Unicode(temp); - Py_DECREF(temp); - return unicode_obj; - } - else { - PyObject *unicode_obj = PyObject_Unicode(args); - - Py_DECREF(args); - return unicode_obj; - } -} -#endif /* Py_USING_UNICODE */ - -static PyObject * -BaseException__repr__(PyObject *self, PyObject *args) -{ - PyObject *args_attr; - Py_ssize_t args_len; - PyObject *repr_suffix; - PyObject *repr; - - if (!PyArg_ParseTuple(args, "O:__repr__", &self)) - return NULL; - - args_attr = PyObject_GetAttrString(self, "args"); - if (!args_attr) - return NULL; - - args_len = PySequence_Length(args_attr); - if (args_len < 0) { - Py_DECREF(args_attr); - return NULL; - } - - if (args_len == 0) { - Py_DECREF(args_attr); - repr_suffix = PyString_FromString("()"); - if (!repr_suffix) - return NULL; - } - else { - PyObject *args_repr = PyObject_Repr(args_attr); - Py_DECREF(args_attr); - if (!args_repr) - return NULL; - - repr_suffix = args_repr; - } - - repr = PyString_FromString(self->ob_type->tp_name); - if (!repr) { - Py_DECREF(repr_suffix); - return NULL; - } - - PyString_ConcatAndDel(&repr, repr_suffix); - return repr; -} - -static PyObject * -BaseException__getitem__(PyObject *self, PyObject *args) -{ - PyObject *out; - PyObject *index; - - if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - out = PyObject_GetItem(args, index); - Py_DECREF(args); - return out; -} - - -static PyMethodDef -BaseException_methods[] = { - /* methods for the BaseException class */ - {"__getitem__", BaseException__getitem__, METH_VARARGS}, - {"__repr__", BaseException__repr__, METH_VARARGS}, - {"__str__", BaseException__str__, METH_O}, -#ifdef Py_USING_UNICODE - {"__unicode__", BaseException__unicode__, METH_VARARGS}, -#endif /* Py_USING_UNICODE */ - {"__init__", BaseException__init__, METH_VARARGS}, - {NULL, NULL } -}; - - -static int -make_BaseException(char *modulename) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - PyObject *name = NULL; - PyObject *emptytuple = NULL; - PyObject *argstuple = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (!(str = PyString_FromString(modulename))) - goto finally; - if (PyDict_SetItemString(dict, "__module__", str)) - goto finally; - Py_DECREF(str); - - if (!(str = PyString_FromString(BaseException__doc__))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - - if (!(name = PyString_FromString("BaseException"))) - goto finally; - - if (!(emptytuple = PyTuple_New(0))) - goto finally; - - if (!(argstuple = PyTuple_Pack(3, name, emptytuple, dict))) - goto finally; - - if (!(PyExc_BaseException = PyType_Type.tp_new(&PyType_Type, argstuple, - NULL))) - goto finally; - - /* Now populate the dictionary with the method suite */ - if (populate_methods(PyExc_BaseException, BaseException_methods)) - /* Don't need to reclaim PyExc_BaseException here because that'll - * happen during interpreter shutdown. - */ - goto finally; - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - Py_XDECREF(name); - Py_XDECREF(emptytuple); - Py_XDECREF(argstuple); - return status; -} - - - -PyDoc_STRVAR(Exception__doc__, "Common base class for all non-exit exceptions."); - -PyDoc_STRVAR(StandardError__doc__, -"Base class for all standard Python exceptions that do not represent" -"interpreter exiting."); - -PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type."); - -PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); -PyDoc_STRVAR(GeneratorExit__doc__, "Request that a generator exit."); - - - -PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); - - -static PyObject * -SystemExit__init__(PyObject *self, PyObject *args) -{ - PyObject *code; - int status; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - /* set code attribute */ - switch (PySequence_Size(args)) { - case 0: - Py_INCREF(Py_None); - code = Py_None; - break; - case 1: - code = PySequence_GetItem(args, 0); - break; - case -1: - PyErr_Clear(); - /* Fall through */ - default: - Py_INCREF(args); - code = args; - break; - } - - status = PyObject_SetAttrString(self, "code", code); - Py_DECREF(code); - Py_DECREF(args); - if (status < 0) - return NULL; - - Py_RETURN_NONE; -} - - -static PyMethodDef SystemExit_methods[] = { - { "__init__", SystemExit__init__, METH_VARARGS}, - {NULL, NULL} -}; - - - -PyDoc_STRVAR(KeyboardInterrupt__doc__, "Program interrupted by user."); - -PyDoc_STRVAR(ImportError__doc__, -"Import can't find module, or can't find name in module."); - - - -PyDoc_STRVAR(EnvironmentError__doc__, "Base class for I/O related errors."); - - -static PyObject * -EnvironmentError__init__(PyObject *self, PyObject *args) -{ - PyObject *item0 = NULL; - PyObject *item1 = NULL; - PyObject *item2 = NULL; - PyObject *subslice = NULL; - PyObject *rtnval = NULL; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (PyObject_SetAttrString(self, "errno", Py_None) || - PyObject_SetAttrString(self, "strerror", Py_None) || - PyObject_SetAttrString(self, "filename", Py_None)) - { - goto finally; - } - - switch (PySequence_Size(args)) { - case 3: - /* Where a function has a single filename, such as open() or some - * of the os module functions, PyErr_SetFromErrnoWithFilename() is - * called, giving a third argument which is the filename. But, so - * that old code using in-place unpacking doesn't break, e.g.: - * - * except IOError, (errno, strerror): - * - * we hack args so that it only contains two items. This also - * means we need our own __str__() which prints out the filename - * when it was supplied. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - item2 = PySequence_GetItem(args, 2); - if (!item0 || !item1 || !item2) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1) || - PyObject_SetAttrString(self, "filename", item2)) - { - goto finally; - } - - subslice = PySequence_GetSlice(args, 0, 2); - if (!subslice || PyObject_SetAttrString(self, "args", subslice)) - goto finally; - break; - - case 2: - /* Used when PyErr_SetFromErrno() is called and no filename - * argument is given. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - if (!item0 || !item1) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1)) - { - goto finally; - } - break; - - case -1: - PyErr_Clear(); - break; - } - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - Py_XDECREF(item0); - Py_XDECREF(item1); - Py_XDECREF(item2); - Py_XDECREF(subslice); - return rtnval; -} - - -static PyObject * -EnvironmentError__str__(PyObject *originalself, PyObject *self) -{ - PyObject *filename; - PyObject *serrno; - PyObject *strerror; - PyObject *rtnval = NULL; - - filename = PyObject_GetAttrString(self, "filename"); - serrno = PyObject_GetAttrString(self, "errno"); - strerror = PyObject_GetAttrString(self, "strerror"); - if (!filename || !serrno || !strerror) - goto finally; - - if (filename != Py_None) { - PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); - PyObject *repr = PyObject_Repr(filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - PyTuple_SET_ITEM(tuple, 2, repr); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - PyObject *fmt = PyString_FromString("[Errno %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else - /* The original Python code said: - * - * return StandardError.__str__(self) - * - * but there is no StandardError__str__() function; we happen to - * know that's just a pass through to BaseException__str__(). - */ - rtnval = BaseException__str__(originalself, self); - - finally: - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); - return rtnval; -} - - -static -PyMethodDef EnvironmentError_methods[] = { - {"__init__", EnvironmentError__init__, METH_VARARGS}, - {"__str__", EnvironmentError__str__, METH_O}, - {NULL, NULL} -}; - -PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); - -PyDoc_STRVAR(OSError__doc__, "OS system call failed."); - -#ifdef MS_WINDOWS -#include "errmap.h" - -PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); - -static PyObject * -WindowsError__init__(PyObject *self, PyObject *args) -{ - PyObject *o_errcode, *result; - long errcode, posix_errno; - result = EnvironmentError__init__(self, args); - if (!result) - return NULL; - self = get_self(args); - if (!self) - goto failed; - /* Set errno to the POSIX errno, and winerror to the Win32 - error code. */ - o_errcode = PyObject_GetAttrString(self, "errno"); - if (!o_errcode) - goto failed; - errcode = PyInt_AsLong(o_errcode); - if (!errcode == -1 && PyErr_Occurred()) - goto failed; - posix_errno = winerror_to_errno(errcode); - if (PyObject_SetAttrString(self, "winerror", o_errcode) < 0) - goto failed; - Py_DECREF(o_errcode); - o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) - goto failed; - if (PyObject_SetAttrString(self, "errno", o_errcode) < 0) - goto failed; - Py_DECREF(o_errcode); - return result; -failed: - /* Could not set errno. */ - Py_XDECREF(o_errcode); - Py_DECREF(result); - return NULL; -} - -static PyObject * -WindowsError__str__(PyObject *originalself, PyObject *self) -{ - PyObject *filename; - PyObject *serrno; - PyObject *strerror; - PyObject *repr = NULL; - PyObject *fmt = NULL; - PyObject *tuple = NULL; - PyObject *rtnval = NULL; - - filename = PyObject_GetAttrString(self, "filename"); - serrno = PyObject_GetAttrString(self, "winerror"); - strerror = PyObject_GetAttrString(self, "strerror"); - if (!filename || !serrno || !strerror) - goto finally; - - if (filename != Py_None) { - fmt = PyString_FromString("[Error %s] %s: %s"); - repr = PyObject_Repr(filename); - if (!fmt || !repr) - goto finally; - - - tuple = PyTuple_Pack(3, serrno, strerror, repr); - if (!tuple) - goto finally; - - rtnval = PyString_Format(fmt, tuple); - } - else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - fmt = PyString_FromString("[Error %s] %s"); - if (!fmt) - goto finally; - - tuple = PyTuple_Pack(2, serrno, strerror); - if (!tuple) - goto finally; - - rtnval = PyString_Format(fmt, tuple); - } - else - rtnval = EnvironmentError__str__(originalself, self); - - finally: - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); - Py_XDECREF(repr); - Py_XDECREF(fmt); - Py_XDECREF(tuple); - return rtnval; -} - -static -PyMethodDef WindowsError_methods[] = { - {"__init__", WindowsError__init__, METH_VARARGS}, - {"__str__", WindowsError__str__, METH_O}, - {NULL, NULL} -}; -#endif /* MS_WINDOWS */ - -#ifdef __VMS -static char -VMSError__doc__[] = "OpenVMS OS system call failed."; -#endif - -PyDoc_STRVAR(EOFError__doc__, "Read beyond end of file."); - -PyDoc_STRVAR(RuntimeError__doc__, "Unspecified run-time error."); - -PyDoc_STRVAR(NotImplementedError__doc__, -"Method or function hasn't been implemented yet."); - -PyDoc_STRVAR(NameError__doc__, "Name not found globally."); - -PyDoc_STRVAR(UnboundLocalError__doc__, -"Local name referenced but not bound to a value."); - -PyDoc_STRVAR(AttributeError__doc__, "Attribute not found."); - - - -PyDoc_STRVAR(SyntaxError__doc__, "Invalid syntax."); - - -static int -SyntaxError__classinit__(PyObject *klass) -{ - int retval = 0; - PyObject *emptystring = PyString_FromString(""); - - /* Additional class-creation time initializations */ - if (!emptystring || - PyObject_SetAttrString(klass, "msg", emptystring) || - PyObject_SetAttrString(klass, "filename", Py_None) || - PyObject_SetAttrString(klass, "lineno", Py_None) || - PyObject_SetAttrString(klass, "offset", Py_None) || - PyObject_SetAttrString(klass, "text", Py_None) || - PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) - { - retval = -1; - } - Py_XDECREF(emptystring); - return retval; -} - - -static PyObject * -SyntaxError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - Py_ssize_t lenargs; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - lenargs = PySequence_Size(args); - if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - int status; - - if (!item0) - goto finally; - status = PyObject_SetAttrString(self, "msg", item0); - Py_DECREF(item0); - if (status) - goto finally; - } - if (lenargs == 2) { - PyObject *info = PySequence_GetItem(args, 1); - PyObject *filename = NULL, *lineno = NULL; - PyObject *offset = NULL, *text = NULL; - int status = 1; - - if (!info) - goto finally; - - filename = PySequence_GetItem(info, 0); - if (filename != NULL) { - lineno = PySequence_GetItem(info, 1); - if (lineno != NULL) { - offset = PySequence_GetItem(info, 2); - if (offset != NULL) { - text = PySequence_GetItem(info, 3); - if (text != NULL) { - status = - PyObject_SetAttrString(self, "filename", filename) - || PyObject_SetAttrString(self, "lineno", lineno) - || PyObject_SetAttrString(self, "offset", offset) - || PyObject_SetAttrString(self, "text", text); - Py_DECREF(text); - } - Py_DECREF(offset); - } - Py_DECREF(lineno); - } - Py_DECREF(filename); - } - Py_DECREF(info); - - if (status) - goto finally; - } - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -/* This is called "my_basename" instead of just "basename" to avoid name - conflicts with glibc; basename is already prototyped if _GNU_SOURCE is - defined, and Python does define that. */ -static char * -my_basename(char *name) -{ - char *cp = name; - char *result = name; - - if (name == NULL) - return "???"; - while (*cp != '\0') { - if (*cp == SEP) - result = cp + 1; - ++cp; - } - return result; -} - - -static PyObject * -SyntaxError__str__(PyObject *_self, PyObject *self) -{ - PyObject *msg; - PyObject *str; - PyObject *filename, *lineno, *result; - - if (!(msg = PyObject_GetAttrString(self, "msg"))) - return NULL; - - str = PyObject_Str(msg); - Py_DECREF(msg); - result = str; - - /* XXX -- do all the additional formatting with filename and - lineno here */ - - if (str != NULL && PyString_Check(str)) { - int have_filename = 0; - int have_lineno = 0; - char *buffer = NULL; - - if ((filename = PyObject_GetAttrString(self, "filename")) != NULL) - have_filename = PyString_Check(filename); - else - PyErr_Clear(); - - if ((lineno = PyObject_GetAttrString(self, "lineno")) != NULL) - have_lineno = PyInt_Check(lineno); - else - PyErr_Clear(); - - if (have_filename || have_lineno) { - Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; - if (have_filename) - bufsize += PyString_GET_SIZE(filename); - - buffer = (char *)PyMem_MALLOC(bufsize); - if (buffer != NULL) { - if (have_filename && have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename)), - PyInt_AsLong(lineno)); - else if (have_filename) - PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename))); - else if (have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(lineno)); - - result = PyString_FromString(buffer); - PyMem_FREE(buffer); - - if (result == NULL) - result = str; - else - Py_DECREF(str); - } - } - Py_XDECREF(filename); - Py_XDECREF(lineno); - } - return result; -} - - -static PyMethodDef SyntaxError_methods[] = { - {"__init__", SyntaxError__init__, METH_VARARGS}, - {"__str__", SyntaxError__str__, METH_O}, - {NULL, NULL} -}; - - -static PyObject * -KeyError__str__(PyObject *_self, PyObject *self) -{ - PyObject *argsattr; - PyObject *result; - - argsattr = PyObject_GetAttrString(self, "args"); - if (!argsattr) - return NULL; - - /* If args is a tuple of exactly one item, apply repr to args[0]. - This is done so that e.g. the exception raised by {}[''] prints - KeyError: '' - rather than the confusing - KeyError - alone. The downside is that if KeyError is raised with an explanatory - string, that string will be displayed in quotes. Too bad. - If args is anything else, use the default BaseException__str__(). - */ - if (PyTuple_Check(argsattr) && PyTuple_GET_SIZE(argsattr) == 1) { - PyObject *key = PyTuple_GET_ITEM(argsattr, 0); - result = PyObject_Repr(key); - } - else - result = BaseException__str__(_self, self); - - Py_DECREF(argsattr); - return result; -} - -static PyMethodDef KeyError_methods[] = { - {"__str__", KeyError__str__, METH_O}, - {NULL, NULL} -}; - - -#ifdef Py_USING_UNICODE -static -int get_int(PyObject *exc, const char *name, Py_ssize_t *value) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return -1; - if (PyInt_Check(attr)) { - *value = PyInt_AS_LONG(attr); - } else if (PyLong_Check(attr)) { - *value = (size_t)PyLong_AsLongLong(attr); - if (*value == -1) { - Py_DECREF(attr); - return -1; - } - } else { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - Py_DECREF(attr); - return -1; - } - Py_DECREF(attr); - return 0; -} - - -static -int set_ssize_t(PyObject *exc, const char *name, Py_ssize_t value) -{ - PyObject *obj = PyInt_FromSsize_t(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - -static -PyObject *get_string(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyString_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - - -static -int set_string(PyObject *exc, const char *name, const char *value) -{ - PyObject *obj = PyString_FromString(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - - -static -PyObject *get_unicode(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyUnicode_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - -PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) -{ - return get_string(exc, "object"); -} - -PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*start<0) - *start = 0; /*XXX check for values <0*/ - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) -{ - return PyUnicodeEncodeError_GetStart(exc, start); -} - - -int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) -{ - return set_ssize_t(exc, "start", start); -} - - -int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - Py_ssize_t size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) -{ - return PyUnicodeEncodeError_GetEnd(exc, start); -} - - -int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) -{ - return set_ssize_t(exc, "end", end); -} - - -PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -static PyObject * -UnicodeError__init__(PyObject *self, PyObject *args, PyTypeObject *objecttype) -{ - PyObject *rtnval = NULL; - PyObject *encoding; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &encoding, - objecttype, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "encoding", encoding)) - goto finally; - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeEncodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyUnicode_Type); -} - -static PyObject * -UnicodeEncodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeEncodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeEncodeError_GetObject(self))) - goto error; - - if (PyUnicodeEncodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeEncodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeEncodeError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - result = PyString_FromFormat( - "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(encodingObj), - badchar_str, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", - PyString_AS_STRING(encodingObj), - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeEncodeError_methods[] = { - {"__init__", UnicodeEncodeError__init__, METH_VARARGS}, - {"__str__", UnicodeEncodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeEncodeError_Create( - const char *encoding, const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeDecodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyString_Type); -} - -static PyObject * -UnicodeDecodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeDecodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeDecodeError_GetObject(self))) - goto error; - - if (PyUnicodeDecodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeDecodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeDecodeError_GetReason(self))) - goto error; - - if (end==start+1) { - /* FromFormat does not support %02x, so format that separately */ - char byte[4]; - PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(objectObj)[start])&0xff); - result = PyString_FromFormat( - "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(encodingObj), - byte, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", - PyString_AS_STRING(encodingObj), - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeDecodeError_methods[] = { - {"__init__", UnicodeDecodeError__init__, METH_VARARGS}, - {"__str__", UnicodeDecodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeDecodeError_Create( - const char *encoding, const char *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - assert(length < INT_MAX); - assert(start < INT_MAX); - assert(end < INT_MAX); - return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeTranslateError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!set_args_and_message(self, args)) { - Py_DECREF(args); - return NULL; - } - - if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - rtnval = Py_None; - Py_INCREF(rtnval); - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeTranslateError__str__(PyObject *self, PyObject *arg) -{ - PyObject *objectObj = NULL; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reasonObj = NULL; - PyObject *result = NULL; - - self = arg; - - if (!(objectObj = PyUnicodeTranslateError_GetObject(self))) - goto error; - - if (PyUnicodeTranslateError_GetStart(self, &start)) - goto error; - - if (PyUnicodeTranslateError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeTranslateError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - result = PyString_FromFormat( - "can't translate character u'\\%s' in position %zd: %.400s", - badchar_str, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - result = PyString_FromFormat( - "can't translate characters in position %zd-%zd: %.400s", - start, - (end-1), - PyString_AS_STRING(reasonObj) - ); - } - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - return result; -} - -static PyMethodDef UnicodeTranslateError_methods[] = { - {"__init__", UnicodeTranslateError__init__, METH_VARARGS}, - {"__str__", UnicodeTranslateError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeTranslateError_Create( - const Py_UNICODE *object, Py_ssize_t length, - Py_ssize_t start, Py_ssize_t end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", - object, length, start, end, reason); -} -#endif - - - -/* Exception doc strings */ - -PyDoc_STRVAR(AssertionError__doc__, "Assertion failed."); - -PyDoc_STRVAR(LookupError__doc__, "Base class for lookup errors."); - -PyDoc_STRVAR(IndexError__doc__, "Sequence index out of range."); - -PyDoc_STRVAR(KeyError__doc__, "Mapping key not found."); - -PyDoc_STRVAR(ArithmeticError__doc__, "Base class for arithmetic errors."); - -PyDoc_STRVAR(OverflowError__doc__, "Result too large to be represented."); - -PyDoc_STRVAR(ZeroDivisionError__doc__, -"Second argument to a division or modulo operation was zero."); - -PyDoc_STRVAR(FloatingPointError__doc__, "Floating point operation failed."); - -PyDoc_STRVAR(ValueError__doc__, -"Inappropriate argument value (of correct type)."); - -PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error."); - -#ifdef Py_USING_UNICODE -PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error."); - -PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error."); - -PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error."); -#endif - -PyDoc_STRVAR(SystemError__doc__, -"Internal error in the Python interpreter.\n\ -\n\ -Please report this to the Python maintainer, along with the traceback,\n\ -the Python version, and the hardware/OS platform and version."); - -PyDoc_STRVAR(ReferenceError__doc__, -"Weak ref proxy used after referent went away."); - -PyDoc_STRVAR(MemoryError__doc__, "Out of memory."); - -PyDoc_STRVAR(IndentationError__doc__, "Improper indentation."); - -PyDoc_STRVAR(TabError__doc__, "Improper mixture of spaces and tabs."); - -/* Warning category docstrings */ - -PyDoc_STRVAR(Warning__doc__, "Base class for warning categories."); - -PyDoc_STRVAR(UserWarning__doc__, -"Base class for warnings generated by user code."); - -PyDoc_STRVAR(DeprecationWarning__doc__, -"Base class for warnings about deprecated features."); - -PyDoc_STRVAR(PendingDeprecationWarning__doc__, -"Base class for warnings about features which will be deprecated " -"in the future."); - -PyDoc_STRVAR(SyntaxWarning__doc__, -"Base class for warnings about dubious syntax."); - -PyDoc_STRVAR(OverflowWarning__doc__, -"Base class for warnings about numeric overflow. Won't exist in Python 2.5."); - -PyDoc_STRVAR(RuntimeWarning__doc__, -"Base class for warnings about dubious runtime behavior."); - -PyDoc_STRVAR(FutureWarning__doc__, -"Base class for warnings about constructs that will change semantically " -"in the future."); - -PyDoc_STRVAR(ImportWarning__doc__, -"Base class for warnings about probable mistakes in module imports"); - - -/* module global functions */ -static PyMethodDef functions[] = { - /* Sentinel */ - {NULL, NULL} -}; - - - -/* Global C API defined exceptions */ - -PyObject *PyExc_BaseException; -PyObject *PyExc_Exception; -PyObject *PyExc_StopIteration; -PyObject *PyExc_GeneratorExit; -PyObject *PyExc_StandardError; -PyObject *PyExc_ArithmeticError; -PyObject *PyExc_LookupError; - -PyObject *PyExc_AssertionError; -PyObject *PyExc_AttributeError; -PyObject *PyExc_EOFError; -PyObject *PyExc_FloatingPointError; -PyObject *PyExc_EnvironmentError; -PyObject *PyExc_IOError; -PyObject *PyExc_OSError; -PyObject *PyExc_ImportError; -PyObject *PyExc_IndexError; -PyObject *PyExc_KeyError; -PyObject *PyExc_KeyboardInterrupt; -PyObject *PyExc_MemoryError; -PyObject *PyExc_NameError; -PyObject *PyExc_OverflowError; -PyObject *PyExc_RuntimeError; -PyObject *PyExc_NotImplementedError; -PyObject *PyExc_SyntaxError; -PyObject *PyExc_IndentationError; -PyObject *PyExc_TabError; -PyObject *PyExc_ReferenceError; -PyObject *PyExc_SystemError; -PyObject *PyExc_SystemExit; -PyObject *PyExc_UnboundLocalError; -PyObject *PyExc_UnicodeError; -PyObject *PyExc_UnicodeEncodeError; -PyObject *PyExc_UnicodeDecodeError; -PyObject *PyExc_UnicodeTranslateError; -PyObject *PyExc_TypeError; -PyObject *PyExc_ValueError; -PyObject *PyExc_ZeroDivisionError; -#ifdef MS_WINDOWS -PyObject *PyExc_WindowsError; -#endif -#ifdef __VMS -PyObject *PyExc_VMSError; -#endif - -/* Pre-computed MemoryError instance. Best to create this as early as - * possible and not wait until a MemoryError is actually raised! - */ -PyObject *PyExc_MemoryErrorInst; - -/* Predefined warning categories */ -PyObject *PyExc_Warning; -PyObject *PyExc_UserWarning; -PyObject *PyExc_DeprecationWarning; -PyObject *PyExc_PendingDeprecationWarning; -PyObject *PyExc_SyntaxWarning; -/* PyExc_OverflowWarning should be removed for Python 2.5 */ -PyObject *PyExc_OverflowWarning; -PyObject *PyExc_RuntimeWarning; -PyObject *PyExc_FutureWarning; -PyObject *PyExc_ImportWarning; - - - -/* mapping between exception names and their PyObject ** */ -static struct { - char *name; - PyObject **exc; - PyObject **base; /* NULL == PyExc_StandardError */ - char *docstr; - PyMethodDef *methods; - int (*classinit)(PyObject *); -} exctable[] = { - /* - * The first four classes MUST appear in exactly this order - */ - {"BaseException", &PyExc_BaseException}, - {"Exception", &PyExc_Exception, &PyExc_BaseException, Exception__doc__}, - {"StopIteration", &PyExc_StopIteration, &PyExc_Exception, - StopIteration__doc__}, - {"GeneratorExit", &PyExc_GeneratorExit, &PyExc_Exception, - GeneratorExit__doc__}, - {"StandardError", &PyExc_StandardError, &PyExc_Exception, - StandardError__doc__}, - {"TypeError", &PyExc_TypeError, 0, TypeError__doc__}, - /* - * The rest appear in depth-first order of the hierarchy - */ - {"SystemExit", &PyExc_SystemExit, &PyExc_BaseException, SystemExit__doc__, - SystemExit_methods}, - {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, &PyExc_BaseException, - KeyboardInterrupt__doc__}, - {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, - {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, - EnvironmentError_methods}, - {"IOError", &PyExc_IOError, &PyExc_EnvironmentError, IOError__doc__}, - {"OSError", &PyExc_OSError, &PyExc_EnvironmentError, OSError__doc__}, -#ifdef MS_WINDOWS - {"WindowsError", &PyExc_WindowsError, &PyExc_OSError, -WindowsError__doc__, WindowsError_methods}, -#endif /* MS_WINDOWS */ -#ifdef __VMS - {"VMSError", &PyExc_VMSError, &PyExc_OSError, - VMSError__doc__}, -#endif - {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, - {"RuntimeError", &PyExc_RuntimeError, 0, RuntimeError__doc__}, - {"NotImplementedError", &PyExc_NotImplementedError, - &PyExc_RuntimeError, NotImplementedError__doc__}, - {"NameError", &PyExc_NameError, 0, NameError__doc__}, - {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, - UnboundLocalError__doc__}, - {"AttributeError", &PyExc_AttributeError, 0, AttributeError__doc__}, - {"SyntaxError", &PyExc_SyntaxError, 0, SyntaxError__doc__, - SyntaxError_methods, SyntaxError__classinit__}, - {"IndentationError", &PyExc_IndentationError, &PyExc_SyntaxError, - IndentationError__doc__}, - {"TabError", &PyExc_TabError, &PyExc_IndentationError, - TabError__doc__}, - {"AssertionError", &PyExc_AssertionError, 0, AssertionError__doc__}, - {"LookupError", &PyExc_LookupError, 0, LookupError__doc__}, - {"IndexError", &PyExc_IndexError, &PyExc_LookupError, - IndexError__doc__}, - {"KeyError", &PyExc_KeyError, &PyExc_LookupError, - KeyError__doc__, KeyError_methods}, - {"ArithmeticError", &PyExc_ArithmeticError, 0, ArithmeticError__doc__}, - {"OverflowError", &PyExc_OverflowError, &PyExc_ArithmeticError, - OverflowError__doc__}, - {"ZeroDivisionError", &PyExc_ZeroDivisionError, &PyExc_ArithmeticError, - ZeroDivisionError__doc__}, - {"FloatingPointError", &PyExc_FloatingPointError, &PyExc_ArithmeticError, - FloatingPointError__doc__}, - {"ValueError", &PyExc_ValueError, 0, ValueError__doc__}, - {"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__}, -#ifdef Py_USING_UNICODE - {"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError, - UnicodeEncodeError__doc__, UnicodeEncodeError_methods}, - {"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError, - UnicodeDecodeError__doc__, UnicodeDecodeError_methods}, - {"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError, - UnicodeTranslateError__doc__, UnicodeTranslateError_methods}, -#endif - {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, - {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, - {"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__}, - /* Warning categories */ - {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, - {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, - {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning, - DeprecationWarning__doc__}, - {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning, - PendingDeprecationWarning__doc__}, - {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, - /* OverflowWarning should be removed for Python 2.5 */ - {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, - OverflowWarning__doc__}, - {"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning, - RuntimeWarning__doc__}, - {"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning, - FutureWarning__doc__}, - {"ImportWarning", &PyExc_ImportWarning, &PyExc_Warning, - ImportWarning__doc__}, - /* Sentinel */ - {NULL} -}; - - - -void -_PyExc_Init(void) -{ - char *modulename = "exceptions"; - Py_ssize_t modnamesz = strlen(modulename); - int i; - PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args; - - me = Py_InitModule(modulename, functions); - if (me == NULL) - goto err; - mydict = PyModule_GetDict(me); - if (mydict == NULL) - goto err; - bltinmod = PyImport_ImportModule("__builtin__"); - if (bltinmod == NULL) - goto err; - bdict = PyModule_GetDict(bltinmod); - if (bdict == NULL) - goto err; - doc = PyString_FromString(module__doc__); - if (doc == NULL) - goto err; - - i = PyDict_SetItemString(mydict, "__doc__", doc); - Py_DECREF(doc); - if (i < 0) { - err: - Py_FatalError("exceptions bootstrapping error."); - return; - } - - /* This is the base class of all exceptions, so make it first. */ - if (make_BaseException(modulename) || - PyDict_SetItemString(mydict, "BaseException", PyExc_BaseException) || - PyDict_SetItemString(bdict, "BaseException", PyExc_BaseException)) - { - Py_FatalError("Base class `BaseException' could not be created."); - } - - /* Now we can programmatically create all the remaining exceptions. - * Remember to start the loop at 1 to skip Exceptions. - */ - for (i=1; exctable[i].name; i++) { - int status; - char *cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2); - PyObject *base; - - (void)strcpy(cname, modulename); - (void)strcat(cname, "."); - (void)strcat(cname, exctable[i].name); - - if (exctable[i].base == 0) - base = PyExc_StandardError; - else - base = *exctable[i].base; - - status = make_class(exctable[i].exc, base, cname, - exctable[i].methods, - exctable[i].docstr); - - PyMem_DEL(cname); - - if (status) - Py_FatalError("Standard exception classes could not be created."); - - if (exctable[i].classinit) { - status = (*exctable[i].classinit)(*exctable[i].exc); - if (status) - Py_FatalError("An exception class could not be initialized."); - } - - /* Now insert the class into both this module and the __builtin__ - * module. - */ - if (PyDict_SetItemString(mydict, exctable[i].name, *exctable[i].exc) || - PyDict_SetItemString(bdict, exctable[i].name, *exctable[i].exc)) - { - Py_FatalError("Module dictionary insertion problem."); - } - } - - /* Now we need to pre-allocate a MemoryError instance */ - args = PyTuple_New(0); - if (!args || - !(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args))) - { - Py_FatalError("Cannot pre-allocate MemoryError instance\n"); - } - Py_DECREF(args); - - /* We're done with __builtin__ */ - Py_DECREF(bltinmod); -} - - -void -_PyExc_Fini(void) -{ - int i; - - Py_XDECREF(PyExc_MemoryErrorInst); - PyExc_MemoryErrorInst = NULL; - - for (i=0; exctable[i].name; i++) { - /* clear the class's dictionary, freeing up circular references - * between the class and its methods. - */ - PyObject* cdict = PyObject_GetAttrString(*exctable[i].exc, "__dict__"); - PyDict_Clear(cdict); - Py_DECREF(cdict); - - /* Now decref the exception class */ - Py_XDECREF(*exctable[i].exc); - *exctable[i].exc = NULL; - } -} Modified: python/trunk/Python/pythonrun.c ============================================================================== --- python/trunk/Python/pythonrun.c (original) +++ python/trunk/Python/pythonrun.c Sat May 27 14:29:24 2006 @@ -1084,7 +1084,8 @@ Py_XDECREF(tb); } -void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) +void +PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) { int err = 0; PyObject *f = PySys_GetObject("stderr"); @@ -1132,19 +1133,22 @@ } else if (PyExceptionClass_Check(exception)) { char* className = PyExceptionClass_Name(exception); - PyObject* moduleName = - PyObject_GetAttrString(exception, "__module__"); + char *dot = strrchr(className, '.'); + PyObject* moduleName; + if (dot != NULL) + className = dot+1; + moduleName = PyObject_GetAttrString(exception, "__module__"); if (moduleName == NULL) err = PyFile_WriteString("", f); else { char* modstr = PyString_AsString(moduleName); - Py_DECREF(moduleName); if (modstr && strcmp(modstr, "exceptions")) { err = PyFile_WriteString(modstr, f); err += PyFile_WriteString(".", f); } + Py_DECREF(moduleName); } if (err == 0) { if (className == NULL) From python-checkins at python.org Sat May 27 14:30:26 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 14:30:26 +0200 (CEST) Subject: [Python-checkins] r46457 - python/trunk/Misc/NEWS Message-ID: <20060527123026.63E601E4006@bag.python.org> Author: georg.brandl Date: Sat May 27 14:30:25 2006 New Revision: 46457 Modified: python/trunk/Misc/NEWS Log: Add news item for new-style exception class branch merge. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat May 27 14:30:25 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Builtin exceptions are now full-blown new-style classes instead of + instances pretending to be classes, which speeds up exception handling + by about 80% in comparison to 2.5a2. + - Patch #1494554: Update unicodedata.numeric and unicode.isnumeric to Unicode 4.1. From martin at v.loewis.de Sat May 27 14:35:24 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 27 May 2006 14:35:24 +0200 Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: <20060527121450.GA7023@rogue.amk.ca> References: <20060527103949.6437A1E4006@bag.python.org> <20060527121450.GA7023@rogue.amk.ca> Message-ID: <4478478C.6060709@v.loewis.de> A.M. Kuchling wrote: > I've attached a patch that makes Py_LOCAL use a GCC attribute on x86 > that supposedly passes some parameters in registers. On my machine > the difference seems to be in the noise (sometimes faster, sometimes > slower), but perhaps Fredrik or Andrew would like to try it; they're > probably very good at benchmarking the string types by now. It doesn't make any difference at all for 4.0: the assembly files are identical. Most of the functions declared regparm get inlined, anyway, either because they are small, or because they are called only once. For the functions that don't get inlined (e.g. fastsearch), gcc 4.0 will automatically apply regparm to a function if it is "local" (i.e. it is static and its address is never taken). So at least for gcc 4, the patch is redundant. Not sure how long gcc has been doing that, but it must have been a few years. Regards, Martin From python-checkins at python.org Sat May 27 14:36:53 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 14:36:53 +0200 (CEST) Subject: [Python-checkins] r46458 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060527123653.F1CA11E4006@bag.python.org> Author: tim.peters Date: Sat May 27 14:36:53 2006 New Revision: 46458 Modified: python/trunk/Lib/test/test_tarfile.py Log: More random thrashing trying to understand spurious Windows failures. Who's keeping a bz2 file open? Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Sat May 27 14:36:53 2006 @@ -633,7 +633,19 @@ if gzip: os.remove(tarname("gz")) if bz2: - os.remove(tarname("bz2")) + # Grrr. This frequently blows up on the Windows buildbot + # slaves. No idea why. Adding more output to try to guess + # something. Can't reproduce at will. + import time, sys + for dummy in range(10): + try: + os.remove(tarname("bz2")) + except OSError, msg: + print >> sys.stderr, \ + "test_tarfile final cleanup crapped out %s" % msg + time.sleep(1) + else: + break if os.path.exists(dirname()): shutil.rmtree(dirname()) if os.path.exists(tmpname()): From fredrik at pythonware.com Sat May 27 15:20:58 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 27 May 2006 15:20:58 +0200 Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: <4478478C.6060709@v.loewis.de> References: <20060527103949.6437A1E4006@bag.python.org> <20060527121450.GA7023@rogue.amk.ca> <4478478C.6060709@v.loewis.de> Message-ID: Martin v. L?wis wrote: > It doesn't make any difference at all for 4.0: the assembly files are > identical. > > Most of the functions declared regparm get inlined, anyway, either > because they are small, or because they are called only once. > > For the functions that don't get inlined (e.g. fastsearch), gcc 4.0 > will automatically apply regparm to a function if it is "local" (i.e. it > is static and its address is never taken). which might explain the *slowdown* we're seeing in GCC 4.X. as reported by Georg: With GCC 4.1.1: Python 2.4.4 trunk: 41493 Python 2.5.0 a2: 41322 Python 2.5 trunk: 42553 With GCC 3.4.6: Python 2.4.4 trunk: 41322 Python 2.5.0 a2: 43478 Python 2.5 trunk: 45045 we got similar slowdowns on Windows/Pentium after Py_LOCAL-ifying ceval for Visual C. is there an easy way to switch this off on a file-by-file basis ? From python-checkins at python.org Sat May 27 15:33:20 2006 From: python-checkins at python.org (andrew.dalke) Date: Sat, 27 May 2006 15:33:20 +0200 (CEST) Subject: [Python-checkins] r46459 - sandbox/trunk/stringbench/stringbench.py Message-ID: <20060527133320.248C41E4006@bag.python.org> Author: andrew.dalke Date: Sat May 27 15:33:19 2006 New Revision: 46459 Modified: sandbox/trunk/stringbench/stringbench.py Log: Changed the timings for the longer tests so they don't take so long. Fixed duplicate function names and comment strings. Modified: sandbox/trunk/stringbench/stringbench.py ============================================================================== --- sandbox/trunk/stringbench/stringbench.py (original) +++ sandbox/trunk/stringbench/stringbench.py Sat May 27 15:33:19 2006 @@ -36,8 +36,13 @@ _RANGE_100 = range(100) _RANGE_10 = range(10) +dups = {} def bench(s, group, repeat_count): def blah(f): + if f.__name__ in dups: + raise AssertionError("Multiple functions with same name: %r" % + (f.__name__,)) + dups[f.__name__] = 1 f.comment = s f.is_bench = True f.group = group @@ -79,29 +84,29 @@ for x in _RANGE_1000: s2 in s1 - at bench('"BC" in ("AB"*1000+"C")', "late match, two characters", 1000) + at bench('"BC" in ("AB"*300+"C")', "late match, two characters", 1000) def in_test_slow_match_two_characters(STR): - s1 = STR("AB" * 1000+"C") + s1 = STR("AB" * 300+"C") s2 = STR("BC") for x in _RANGE_1000: s2 in s1 - at bench('s="ABC"*33; s in ((s+"D")*500+s+"E")', + at bench('s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E")', "late match, 100 characters", 100) def in_test_slow_match_100_characters(STR): m = STR("ABC"*33) - s1 = (m+"D")*500 + m+"E" + s1 = (m+"D")*300 + m+"E" s2 = m+"E" for x in _RANGE_100: s2 in s1 # Try with regex @uses_re - at bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*500+s+"E")', + at bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*300+s+"E")', "late match, 100 characters", 100) def re_test_slow_match_100_characters(STR): m = STR("ABC"*33) - s1 = (m+"D")*500 + m+"E" + s1 = (m+"D")*300 + m+"E" s2 = m+"E" pat = re.compile(s2) search = pat.search @@ -148,9 +153,9 @@ for x in _RANGE_1000: s1_find(s2) - at bench('"BC" in ("AB"*1000+"C")', "late match, two characters", 1000) + at bench('("AB"*300+"C").find("BC")', "late match, two characters", 1000) def find_test_slow_match_two_characters(STR): - s1 = STR("AB" * 1000+"C") + s1 = STR("AB" * 300+"C") s2 = STR("BC") s1_find = s1.find for x in _RANGE_1000: @@ -188,9 +193,9 @@ for x in _RANGE_1000: s1_index(s2) - at bench('("AB"*1000+"C").index("BC")', "late match, two characters", 1000) + at bench('("AB"*300+"C").index("BC")', "late match, two characters", 1000) def index_test_slow_match_two_characters(STR): - s1 = STR("AB" * 1000+"C") + s1 = STR("AB" * 300+"C") s2 = STR("BC") s1_index = s1.index for x in _RANGE_1000: @@ -243,7 +248,7 @@ @bench('s1+s2+s3+s4+...+s20', "concat 20 strings of words length 4 to 15", 1000) -def concat_two_strings(STR): +def concat_many_strings(STR): s1=STR('TIXSGYNREDCVBHJ') s2=STR('PUMTLXBZVDO') s3=STR('FVZNJ') @@ -790,13 +795,13 @@ pat_sub(to_str, s) @bench('"...text.with.2000.lines...replace("\\n", " ")', - 'replace single character, big string', 100) + 'replace single character, big string', 10) def replace_single_character_big(STR): s = _get_2000_lines(STR) from_str = STR("\n") to_str = STR(" ") s_replace = s.replace - for x in _RANGE_100: + for x in _RANGE_10: s_replace(from_str, to_str) @uses_re @@ -821,26 +826,15 @@ for x in _RANGE_10: seq_replace(from_str, to_str) -# This changes the total number of character - at bench('"...text.with.2000.newlines.', - 'replace multiple characters, big string', 10) -def replace_multiple_character_big(STR): - s = _get_2000_lines(STR) - from_str = STR("\n") - to_str = STR("\r\n") - s_replace = s.replace - for x in _RANGE_10: - s_replace(from_str, to_str) - # This increases the character count @bench('"...text.with.2000.newlines...replace("\\n", "\\r\\n")', - 'replace multiple characters, big string', 100) + 'replace and expand multiple characters, big string', 10) def replace_multiple_character_big(STR): s = _get_2000_lines(STR) from_str = STR("\n") to_str = STR("\r\n") s_replace = s.replace - for x in _RANGE_100: + for x in _RANGE_10: s_replace(from_str, to_str) @@ -1030,11 +1024,11 @@ print "That was zippy!" else: try: - average = str_total/uni_total + ratio = str_time/uni_time except ZeroDivisionError: - average = 0.0 + ratio = 0.0 print "%.2f\t%.2f\t%.1f\t%s" % ( - 1000*str_total, 1000*uni_total, 100.*average, + 1000*str_total, 1000*uni_total, 100.*ratio, "TOTAL") if __name__ == "__main__": From amk at amk.ca Sat May 27 15:49:13 2006 From: amk at amk.ca (A.M. Kuchling) Date: Sat, 27 May 2006 09:49:13 -0400 Subject: [Python-checkins] r46458 - python/trunk/Lib/test/test_tarfile.py In-Reply-To: <20060527123653.F1CA11E4006@bag.python.org> References: <20060527123653.F1CA11E4006@bag.python.org> Message-ID: <20060527134913.GA7418@rogue.amk.ca> On Sat, May 27, 2006 at 02:36:53PM +0200, tim.peters wrote: > More random thrashing trying to understand spurious > Windows failures. Who's keeping a bz2 file open? In tarfile.py, the BZ2Proxy class has this method: def close(self): if self.mode == "w": raw = self.bz2obj.flush() self.fileobj.write(raw) self.fileobj.close() So it'll only close if the mode is write; perhaps the .close() call should be moved outside of the 'if'. --amk From python-checkins at python.org Sat May 27 15:44:37 2006 From: python-checkins at python.org (andrew.kuchling) Date: Sat, 27 May 2006 15:44:37 +0200 (CEST) Subject: [Python-checkins] r46460 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060527134437.C30EE1E4006@bag.python.org> Author: andrew.kuchling Date: Sat May 27 15:44:37 2006 New Revision: 46460 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Mention new-style exceptions Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat May 27 15:44:37 2006 @@ -1201,6 +1201,12 @@ and reduce memory usage a bit. (Contributed by Neal Norwitz.) % Patch 1337051 +\item Python's built-in exceptions are now new-style classes, a change +that speeds up instantiation considerably. Exception handling in +Python 2.5 is therefore about 30\% faster than in 2.4. +(Contributed by Richard Jones and Sean Reifschneider at the +NeedForSpeed sprint.) + \item Importing now caches the paths tried, recording whether they exist or not so that the interpreter makes fewer \cfunction{open()} and \cfunction{stat()} calls on startup. From python-checkins at python.org Sat May 27 15:50:43 2006 From: python-checkins at python.org (richard.jones) Date: Sat, 27 May 2006 15:50:43 +0200 (CEST) Subject: [Python-checkins] r46461 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060527135043.1BCF61E4018@bag.python.org> Author: richard.jones Date: Sat May 27 15:50:42 2006 New Revision: 46461 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: credit where credit is due Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat May 27 15:50:42 2006 @@ -1204,8 +1204,8 @@ \item Python's built-in exceptions are now new-style classes, a change that speeds up instantiation considerably. Exception handling in Python 2.5 is therefore about 30\% faster than in 2.4. -(Contributed by Richard Jones and Sean Reifschneider at the -NeedForSpeed sprint.) +(Contributed by Richard Jones, Georg Brandl and Sean Reifschneider at +the NeedForSpeed sprint.) \item Importing now caches the paths tried, recording whether they exist or not so that the interpreter makes fewer From amk at amk.ca Sat May 27 16:04:11 2006 From: amk at amk.ca (A.M. Kuchling) Date: Sat, 27 May 2006 10:04:11 -0400 Subject: [Python-checkins] r46461 - python/trunk/Doc/whatsnew/whatsnew25.tex In-Reply-To: <20060527135043.1BCF61E4018@bag.python.org> References: <20060527135043.1BCF61E4018@bag.python.org> Message-ID: <20060527140411.GA7429@rogue.amk.ca> On Sat, May 27, 2006 at 03:50:43PM +0200, richard.jones wrote: > credit where credit is due Thanks! --amk From python-checkins at python.org Sat May 27 16:02:03 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 16:02:03 +0200 (CEST) Subject: [Python-checkins] r46462 - python/trunk/Lib/tarfile.py Message-ID: <20060527140203.CDB871E4006@bag.python.org> Author: georg.brandl Date: Sat May 27 16:02:03 2006 New Revision: 46462 Modified: python/trunk/Lib/tarfile.py Log: Always close BZ2Proxy object. Remove unnecessary struct usage. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Sat May 27 16:02:03 2006 @@ -132,15 +132,11 @@ #--------------------------------------------------------- # Some useful functions #--------------------------------------------------------- -def nts(s): - """Convert a null-terminated string buffer to a python string. - """ - return s.rstrip(NUL) def stn(s, length): """Convert a python string to a null-terminated string buffer. """ - return struct.pack("%ds" % (length - 1), s) + NUL + return s[:length-1] + (length - len(s) - 1) * NUL + NUL def nti(s): """Convert a number field to a python number. @@ -616,7 +612,7 @@ if self.mode == "w": raw = self.bz2obj.flush() self.fileobj.write(raw) - self.fileobj.close() + self.fileobj.close() # class _BZ2Proxy #------------------------ @@ -828,7 +824,7 @@ tarinfo = cls() tarinfo.buf = buf - tarinfo.name = nts(buf[0:100]) + tarinfo.name = buf[0:100].rstrip(NUL) tarinfo.mode = nti(buf[100:108]) tarinfo.uid = nti(buf[108:116]) tarinfo.gid = nti(buf[116:124]) @@ -836,9 +832,9 @@ tarinfo.mtime = nti(buf[136:148]) tarinfo.chksum = nti(buf[148:156]) tarinfo.type = buf[156:157] - tarinfo.linkname = nts(buf[157:257]) - tarinfo.uname = nts(buf[265:297]) - tarinfo.gname = nts(buf[297:329]) + tarinfo.linkname = buf[157:257].rstrip(NUL) + tarinfo.uname = buf[265:297].rstrip(NUL) + tarinfo.gname = buf[297:329].rstrip(NUL) tarinfo.devmajor = nti(buf[329:337]) tarinfo.devminor = nti(buf[337:345]) tarinfo.prefix = buf[345:500] @@ -1790,7 +1786,8 @@ # The prefix field is used for filenames > 100 in # the POSIX standard. # name = prefix + '/' + name - tarinfo.name = normpath(os.path.join(nts(tarinfo.prefix), tarinfo.name)) + tarinfo.name = normpath(os.path.join(tarinfo.prefix.rstrip(NUL), + tarinfo.name)) # Directory names should have a '/' at the end. if tarinfo.isdir(): @@ -1855,9 +1852,9 @@ # the longname information. next.offset = tarinfo.offset if tarinfo.type == GNUTYPE_LONGNAME: - next.name = nts(buf) + next.name = buf.rstrip(NUL) elif tarinfo.type == GNUTYPE_LONGLINK: - next.linkname = nts(buf) + next.linkname = buf.rstrip(NUL) return next From python-checkins at python.org Sat May 27 16:13:15 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 16:13:15 +0200 (CEST) Subject: [Python-checkins] r46463 - python/trunk/Lib/test/test_tarfile.py Message-ID: <20060527141315.159781E4006@bag.python.org> Author: tim.peters Date: Sat May 27 16:13:13 2006 New Revision: 46463 Modified: python/trunk/Lib/test/test_tarfile.py Log: The cheery optimism of old age. Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Sat May 27 16:13:13 2006 @@ -633,19 +633,7 @@ if gzip: os.remove(tarname("gz")) if bz2: - # Grrr. This frequently blows up on the Windows buildbot - # slaves. No idea why. Adding more output to try to guess - # something. Can't reproduce at will. - import time, sys - for dummy in range(10): - try: - os.remove(tarname("bz2")) - except OSError, msg: - print >> sys.stderr, \ - "test_tarfile final cleanup crapped out %s" % msg - time.sleep(1) - else: - break + os.remove(tarname("bz2")) if os.path.exists(dirname()): shutil.rmtree(dirname()) if os.path.exists(tmpname()): From python-checkins at python.org Sat May 27 16:16:41 2006 From: python-checkins at python.org (andrew.dalke) Date: Sat, 27 May 2006 16:16:41 +0200 (CEST) Subject: [Python-checkins] r46464 - python/trunk/Objects/stringobject.c Message-ID: <20060527141641.4F2961E4006@bag.python.org> Author: andrew.dalke Date: Sat May 27 16:16:40 2006 New Revision: 46464 Modified: python/trunk/Objects/stringobject.c Log: cleanup - removed trailing whitespace Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 27 16:16:40 2006 @@ -1364,7 +1364,7 @@ count++; } /* Always force the list to the expected size. */ -#define FIX_PREALLOC_SIZE(list) ((PyListObject *)list)->ob_size = count; +#define FIX_PREALLOC_SIZE(list) ((PyListObject *)list)->ob_size = count; #define SKIP_SPACE(s, i, len) { while (i References: <20060527103949.6437A1E4006@bag.python.org> <20060527121450.GA7023@rogue.amk.ca> <4478478C.6060709@v.loewis.de> Message-ID: On May 27, 2006, at 1:20 PM, Fredrik Lundh wrote: > Martin v. L?wis wrote: > >> It doesn't make any difference at all for 4.0: the assembly files are >> identical. >> >> Most of the functions declared regparm get inlined, anyway, either >> because they are small, or because they are called only once. >> >> For the functions that don't get inlined (e.g. fastsearch), gcc 4.0 >> will automatically apply regparm to a function if it is >> "local" (i.e. it >> is static and its address is never taken). > > > which might explain the *slowdown* we're seeing in GCC 4.X. as > reported > by Georg: > > With GCC 4.1.1: > > Python 2.4.4 trunk: 41493 > Python 2.5.0 a2: 41322 > Python 2.5 trunk: 42553 > > With GCC 3.4.6: > > Python 2.4.4 trunk: 41322 > Python 2.5.0 a2: 43478 > Python 2.5 trunk: 45045 > > we got similar slowdowns on Windows/Pentium after Py_LOCAL-ifying > ceval > for Visual C. > > is there an easy way to switch this off on a file-by-file basis ? function-by-function.. noinline This function attribute prevents a function from being considered for inlining. http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html -bob From python-checkins at python.org Sat May 27 16:41:56 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 16:41:56 +0200 (CEST) Subject: [Python-checkins] r46465 - python/trunk/Objects/exceptions.c Message-ID: <20060527144156.8A7D21E4006@bag.python.org> Author: georg.brandl Date: Sat May 27 16:41:55 2006 New Revision: 46465 Modified: python/trunk/Objects/exceptions.c Log: Remove spurious semicolons after macro invocations. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sat May 27 16:41:55 2006 @@ -381,28 +381,28 @@ */ SimpleExtendsException(PyExc_Exception, StandardError, "Base class for all standard Python exceptions that do not represent\n" - "interpreter exiting."); + "interpreter exiting.") /* * TypeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, TypeError, - "Inappropriate argument type."); + "Inappropriate argument type.") /* * StopIteration extends Exception */ SimpleExtendsException(PyExc_Exception, StopIteration, - "Signal the end from iterator.next()."); + "Signal the end from iterator.next().") /* * GeneratorExit extends Exception */ SimpleExtendsException(PyExc_Exception, GeneratorExit, - "Request that a generator exit."); + "Request that a generator exit.") /* @@ -470,20 +470,20 @@ ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, - "Request to exit from the interpreter."); + "Request to exit from the interpreter.") /* * KeyboardInterrupt extends BaseException */ SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, - "Program interrupted by user."); + "Program interrupted by user.") /* * ImportError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ImportError, - "Import can't find module, or can't find name in module."); + "Import can't find module, or can't find name in module.") /* @@ -700,21 +700,21 @@ EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, EnvironmentError_str, - "Base class for I/O related errors."); + "Base class for I/O related errors.") /* * IOError extends EnvironmentError */ MiddlingExtendsException(PyExc_EnvironmentError, IOError, - EnvironmentError, "I/O operation failed."); + EnvironmentError, "I/O operation failed.") /* * OSError extends EnvironmentError */ MiddlingExtendsException(PyExc_EnvironmentError, OSError, - EnvironmentError, "OS system call failed."); + EnvironmentError, "OS system call failed.") /* @@ -897,7 +897,7 @@ 0, WindowsError_members, WindowsError_str, - "MS-Windows OS system call failed."); + "MS-Windows OS system call failed.") #endif /* MS_WINDOWS */ @@ -907,7 +907,7 @@ */ #ifdef __VMS MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError, - "OpenVMS OS system call failed."); + "OpenVMS OS system call failed.") #endif @@ -915,39 +915,39 @@ * EOFError extends StandardError */ SimpleExtendsException(PyExc_StandardError, EOFError, - "Read beyond end of file."); + "Read beyond end of file.") /* * RuntimeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, RuntimeError, - "Unspecified run-time error."); + "Unspecified run-time error.") /* * NotImplementedError extends RuntimeError */ SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, - "Method or function hasn't been implemented yet."); + "Method or function hasn't been implemented yet.") /* * NameError extends StandardError */ SimpleExtendsException(PyExc_StandardError, NameError, - "Name not found globally."); + "Name not found globally.") /* * UnboundLocalError extends NameError */ SimpleExtendsException(PyExc_NameError, UnboundLocalError, - "Local name referenced but not bound to a value."); + "Local name referenced but not bound to a value.") /* * AttributeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, AttributeError, - "Attribute not found."); + "Attribute not found.") /* @@ -1140,35 +1140,35 @@ ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, - SyntaxError_str, "Invalid syntax."); + SyntaxError_str, "Invalid syntax.") /* * IndentationError extends SyntaxError */ MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, - "Improper indentation."); + "Improper indentation.") /* * TabError extends IndentationError */ MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, - "Improper mixture of spaces and tabs."); + "Improper mixture of spaces and tabs.") /* * LookupError extends StandardError */ SimpleExtendsException(PyExc_StandardError, LookupError, - "Base class for lookup errors."); + "Base class for lookup errors.") /* * IndexError extends LookupError */ SimpleExtendsException(PyExc_LookupError, IndexError, - "Sequence index out of range."); + "Sequence index out of range.") /* @@ -1194,21 +1194,21 @@ } ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, - 0, 0, 0, KeyError_str, "Mapping key not found."); + 0, 0, 0, KeyError_str, "Mapping key not found.") /* * ValueError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ValueError, - "Inappropriate argument value (of correct type)."); + "Inappropriate argument value (of correct type).") /* * UnicodeError extends ValueError */ SimpleExtendsException(PyExc_ValueError, UnicodeError, - "Unicode related error."); + "Unicode related error.") #ifdef Py_USING_UNICODE static int @@ -1859,35 +1859,35 @@ * AssertionError extends StandardError */ SimpleExtendsException(PyExc_StandardError, AssertionError, - "Assertion failed."); + "Assertion failed.") /* * ArithmeticError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ArithmeticError, - "Base class for arithmetic errors."); + "Base class for arithmetic errors.") /* * FloatingPointError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, - "Floating point operation failed."); + "Floating point operation failed.") /* * OverflowError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, OverflowError, - "Result too large to be represented."); + "Result too large to be represented.") /* * ZeroDivisionError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, - "Second argument to a division or modulo operation was zero."); + "Second argument to a division or modulo operation was zero.") /* @@ -1897,20 +1897,20 @@ "Internal error in the Python interpreter.\n" "\n" "Please report this to the Python maintainer, along with the traceback,\n" - "the Python version, and the hardware/OS platform and version."); + "the Python version, and the hardware/OS platform and version.") /* * ReferenceError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ReferenceError, - "Weak ref proxy used after referent went away."); + "Weak ref proxy used after referent went away.") /* * MemoryError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory."); +SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory.") /* Warning category docstrings */ @@ -1919,21 +1919,21 @@ * Warning extends Exception */ SimpleExtendsException(PyExc_Exception, Warning, - "Base class for warning categories."); + "Base class for warning categories.") /* * UserWarning extends Warning */ SimpleExtendsException(PyExc_Warning, UserWarning, - "Base class for warnings generated by user code."); + "Base class for warnings generated by user code.") /* * DeprecationWarning extends Warning */ SimpleExtendsException(PyExc_Warning, DeprecationWarning, - "Base class for warnings about deprecated features."); + "Base class for warnings about deprecated features.") /* @@ -1941,21 +1941,21 @@ */ SimpleExtendsException(PyExc_Warning, PendingDeprecationWarning, "Base class for warnings about features which will be deprecated\n" - "in the future."); + "in the future.") /* * SyntaxWarning extends Warning */ SimpleExtendsException(PyExc_Warning, SyntaxWarning, - "Base class for warnings about dubious syntax."); + "Base class for warnings about dubious syntax.") /* * RuntimeWarning extends Warning */ SimpleExtendsException(PyExc_Warning, RuntimeWarning, - "Base class for warnings about dubious runtime behavior."); + "Base class for warnings about dubious runtime behavior.") /* @@ -1963,14 +1963,14 @@ */ SimpleExtendsException(PyExc_Warning, FutureWarning, "Base class for warnings about constructs that will change semantically\n" - "in the future."); + "in the future.") /* * ImportWarning extends Warning */ SimpleExtendsException(PyExc_Warning, ImportWarning, - "Base class for warnings about probable mistakes in module imports"); + "Base class for warnings about probable mistakes in module imports") /* Pre-computed MemoryError instance. Best to create this as early as From python-checkins at python.org Sat May 27 16:43:55 2006 From: python-checkins at python.org (sean.reifschneider) Date: Sat, 27 May 2006 16:43:55 +0200 (CEST) Subject: [Python-checkins] r46466 - in sandbox/trunk/pybch: Tests Tests/Arithmetic.py Tests/Calls.py Tests/Constructs.py Tests/Dict.py Tests/Exceptions.py Tests/Imports.py Tests/Instances.py Tests/Lists.py Tests/Lookups.py Tests/NewInstances.py Tests/Numbers.py Tests/Strings.py Tests/TestHelpers.py Tests/Tuples.py Tests/Unicode.py Tests/__init__.py pybch.py Message-ID: <20060527144355.743961E4006@bag.python.org> Author: sean.reifschneider Date: Sat May 27 16:43:53 2006 New Revision: 46466 Added: sandbox/trunk/pybch/ sandbox/trunk/pybch/Tests/ sandbox/trunk/pybch/Tests/Arithmetic.py sandbox/trunk/pybch/Tests/Calls.py sandbox/trunk/pybch/Tests/Constructs.py sandbox/trunk/pybch/Tests/Dict.py sandbox/trunk/pybch/Tests/Exceptions.py sandbox/trunk/pybch/Tests/Imports.py sandbox/trunk/pybch/Tests/Instances.py sandbox/trunk/pybch/Tests/Lists.py sandbox/trunk/pybch/Tests/Lookups.py sandbox/trunk/pybch/Tests/NewInstances.py (contents, props changed) sandbox/trunk/pybch/Tests/Numbers.py sandbox/trunk/pybch/Tests/Strings.py sandbox/trunk/pybch/Tests/TestHelpers.py sandbox/trunk/pybch/Tests/Tuples.py sandbox/trunk/pybch/Tests/Unicode.py sandbox/trunk/pybch/Tests/__init__.py sandbox/trunk/pybch/pybch.py (contents, props changed) Log: Initial version of another benchmarking thingie. Added: sandbox/trunk/pybch/Tests/Arithmetic.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Arithmetic.py Sat May 27 16:43:53 2006 @@ -0,0 +1,737 @@ +from TestHelpers import Test + +class SimpleIntegerArithmetic(Test): + operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) + def test(self): + + for i in xrange(self.rounds): + + a = 2 + b = 3 + c = 3 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + +#class SimpleFloatArithmetic(Test): # Disabled test because of stability reasons. +class SimpleFloatArithmetic: # Disabled test because of stability reasons. + operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) + def test(self): + + for i in xrange(self.rounds): + + a = 2.1 + b = 3.3332 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2.1 + b = 3.3332 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2.1 + b = 3.3332 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2.1 + b = 3.3332 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2.1 + b = 3.3332 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + +class SimpleIntFloatArithmetic(Test): + operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) + + def test(self): + + for i in xrange(self.rounds): + + a = 2 + b = 3 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + b = 3 + c = 3.14159 + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + +class SimpleLongArithmetic(Test): + operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) + + def test(self): + + for i in xrange(self.rounds): + + a = 2220001L + b = 100001L + c = 30005L + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2220001L + b = 100001L + c = 30005L + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2220001L + b = 100001L + c = 30005L + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2220001L + b = 100001L + c = 30005L + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2220001L + b = 100001L + c = 30005L + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + +class SimpleComplexArithmetic(Test): + operations = 5 * (3 + 5 + 5 + 3 + 3 + 3) + + def test(self): + + for i in xrange(self.rounds): + + a = 2 + 3j + b = 2.5 + 4.5j + c = 1.2 + 6.2j + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + 3j + b = 2.5 + 4.5j + c = 1.2 + 6.2j + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + 3j + b = 2.5 + 4.5j + c = 1.2 + 6.2j + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + 3j + b = 2.5 + 4.5j + c = 1.2 + 6.2j + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b + + a = 2 + 3j + b = 2.5 + 4.5j + c = 1.2 + 6.2j + + c = a + b + c = b + c + c = c + a + c = a + b + c = b + c + + c = c - a + c = a - b + c = b - c + c = c - a + c = b - c + + c = a / b + c = b / a + c = c / b + + c = a * b + c = b * a + c = c * b + + c = a / b + c = b / a + c = c / b Added: sandbox/trunk/pybch/Tests/Calls.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Calls.py Sat May 27 16:43:53 2006 @@ -0,0 +1,405 @@ +from TestHelpers import Test + +class PythonFunctionCalls(Test): + + version = 0.3 + operations = 5*(1+4+4+2) + + def test(self): + + global f,f1,g,h + + # define functions + def f(): + pass + + def f1(x): + pass + + def g(a,b,c): + return a,b,c + + def h(a,b,c,d=1,e=2,f=3): + return d,e,f + + # do calls + for i in xrange(self.rounds): + + f() + f1(i) + f1(i) + f1(i) + f1(i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + h(i,i,3,i,i) + h(i,i,i,2,i,3) + + f() + f1(i) + f1(i) + f1(i) + f1(i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + h(i,i,3,i,i) + h(i,i,i,2,i,3) + + f() + f1(i) + f1(i) + f1(i) + f1(i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + h(i,i,3,i,i) + h(i,i,i,2,i,3) + + f() + f1(i) + f1(i) + f1(i) + f1(i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + h(i,i,3,i,i) + h(i,i,i,2,i,3) + + f() + f1(i) + f1(i) + f1(i) + f1(i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + g(i,i,i) + h(i,i,3,i,i) + h(i,i,i,2,i,3) + + def calibrate(self): + + global f,f1,g,h + + # define functions + def f(): + pass + + def f1(x): + pass + + def g(a,b,c): + return a,b,c + + def h(a,b,c,d=1,e=2,f=3): + return d,e,f + + # do calls + for i in xrange(self.rounds): + pass + +### + +class BuiltinFunctionCalls(Test): + + version = 0.4 + operations = 5*(2+5+5+5) + + def test(self): + + # localize functions + f0 = globals + f1 = hash + f2 = cmp + f3 = range + + # do calls + for i in xrange(self.rounds): + + f0() + f0() + f1(i) + f1(i) + f1(i) + f1(i) + f1(i) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + + f0() + f0() + f1(i) + f1(i) + f1(i) + f1(i) + f1(i) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + + f0() + f0() + f1(i) + f1(i) + f1(i) + f1(i) + f1(i) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + + f0() + f0() + f1(i) + f1(i) + f1(i) + f1(i) + f1(i) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + + f0() + f0() + f1(i) + f1(i) + f1(i) + f1(i) + f1(i) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f2(1,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + f3(1,3,2) + + def calibrate(self): + + # localize functions + f0 = dir + f1 = hash + f2 = range + f3 = range + + # do calls + for i in xrange(self.rounds): + pass + +### + +class PythonMethodCalls(Test): + + version = 0.3 + operations = 5*(6 + 5 + 4) + + def test(self): + + class c: + + x = 2 + s = 'string' + + def f(self): + + return self.x + + def j(self,a,b): + + self.y = a + self.t = b + return self.y + + def k(self,a,b,c=3): + + self.y = a + self.s = b + self.t = c + + o = c() + + for i in xrange(self.rounds): + + o.f() + o.f() + o.f() + o.f() + o.f() + o.f() + o.j(i,i) + o.j(i,i) + o.j(i,2) + o.j(i,2) + o.j(2,2) + o.k(i,i) + o.k(i,2) + o.k(i,2,3) + o.k(i,i,c=4) + + o.f() + o.f() + o.f() + o.f() + o.f() + o.f() + o.j(i,i) + o.j(i,i) + o.j(i,2) + o.j(i,2) + o.j(2,2) + o.k(i,i) + o.k(i,2) + o.k(i,2,3) + o.k(i,i,c=4) + + o.f() + o.f() + o.f() + o.f() + o.f() + o.f() + o.j(i,i) + o.j(i,i) + o.j(i,2) + o.j(i,2) + o.j(2,2) + o.k(i,i) + o.k(i,2) + o.k(i,2,3) + o.k(i,i,c=4) + + o.f() + o.f() + o.f() + o.f() + o.f() + o.f() + o.j(i,i) + o.j(i,i) + o.j(i,2) + o.j(i,2) + o.j(2,2) + o.k(i,i) + o.k(i,2) + o.k(i,2,3) + o.k(i,i,c=4) + + o.f() + o.f() + o.f() + o.f() + o.f() + o.f() + o.j(i,i) + o.j(i,i) + o.j(i,2) + o.j(i,2) + o.j(2,2) + o.k(i,i) + o.k(i,2) + o.k(i,2,3) + o.k(i,i,c=4) + + def calibrate(self): + + class c: + + x = 2 + s = 'string' + + def f(self): + + return self.x + + def j(self,a,b): + + self.y = a + self.t = b + + def k(self,a,b,c=3): + + self.y = a + self.s = b + self.t = c + + o = c + + for i in xrange(self.rounds): + pass + +### + +class Recursion(Test): + + version = 0.3 + operations = 5 + + def test(self): + + global f + + def f(x): + + if x > 1: + return f(x-1) + return 1 + + for i in xrange(self.rounds): + f(10) + f(10) + f(10) + f(10) + f(10) + + def calibrate(self): + + global f + + def f(x): + + if x > 0: + return f(x-1) + return 1 + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Constructs.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Constructs.py Sat May 27 16:43:53 2006 @@ -0,0 +1,561 @@ +from TestHelpers import Test + +class IfThenElse(Test): + + version = 0.31 + operations = 30*3 # hard to say... + + def test(self): + + a,b,c = 1,2,3 + for i in xrange(self.rounds): + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + if a == 1: + if b == 2: + if c != 3: + c = 3 + b = 3 + else: + c = 2 + elif b == 3: + b = 2 + a = 2 + elif a == 2: + a = 3 + else: + a = 1 + + def calibrate(self): + + a,b,c = 1,2,3 + for i in xrange(self.rounds): + pass + +class NestedForLoops(Test): + + version = 0.3 + operations = 1000*10*5 + + def test(self): + + l1 = range(1000) + l2 = range(10) + l3 = range(5) + for i in xrange(self.rounds): + for i in l1: + for j in l2: + for k in l3: + pass + + def calibrate(self): + + l1 = range(1000) + l2 = range(10) + l3 = range(5) + for i in xrange(self.rounds): + pass + +class ForLoops(Test): + + version = 0.1 + operations = 5 * 5 + + def test(self): + + l1 = range(100) + for i in xrange(self.rounds): + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + for i in l1: + pass + + def calibrate(self): + + l1 = range(1000) + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Dict.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Dict.py Sat May 27 16:43:53 2006 @@ -0,0 +1,497 @@ +from TestHelpers import Test + +class DictCreation(Test): + + version = 0.3 + operations = 5*(5 + 5) + + def test(self): + + for i in xrange(self.rounds): + + d1 = {} + d2 = {} + d3 = {} + d4 = {} + d5 = {} + + d1 = {1:2,3:4,5:6} + d2 = {2:3,4:5,6:7} + d3 = {3:4,5:6,7:8} + d4 = {4:5,6:7,8:9} + d5 = {6:7,8:9,10:11} + + d1 = {} + d2 = {} + d3 = {} + d4 = {} + d5 = {} + + d1 = {1:2,3:4,5:6} + d2 = {2:3,4:5,6:7} + d3 = {3:4,5:6,7:8} + d4 = {4:5,6:7,8:9} + d5 = {6:7,8:9,10:11} + + d1 = {} + d2 = {} + d3 = {} + d4 = {} + d5 = {} + + d1 = {1:2,3:4,5:6} + d2 = {2:3,4:5,6:7} + d3 = {3:4,5:6,7:8} + d4 = {4:5,6:7,8:9} + d5 = {6:7,8:9,10:11} + + d1 = {} + d2 = {} + d3 = {} + d4 = {} + d5 = {} + + d1 = {1:2,3:4,5:6} + d2 = {2:3,4:5,6:7} + d3 = {3:4,5:6,7:8} + d4 = {4:5,6:7,8:9} + d5 = {6:7,8:9,10:11} + + d1 = {} + d2 = {} + d3 = {} + d4 = {} + d5 = {} + + d1 = {1:2,3:4,5:6} + d2 = {2:3,4:5,6:7} + d3 = {3:4,5:6,7:8} + d4 = {4:5,6:7,8:9} + d5 = {6:7,8:9,10:11} + + def calibrate(self): + + for i in xrange(self.rounds): + pass + +class DictWithStringKeys(Test): + + version = 0.1 + operations = 5*(6 + 6) + + def test(self): + + d = {} + + for i in xrange(self.rounds): + + d['abc'] = 1 + d['def'] = 2 + d['ghi'] = 3 + d['jkl'] = 4 + d['mno'] = 5 + d['pqr'] = 6 + + d['abc'] + d['def'] + d['ghi'] + d['jkl'] + d['mno'] + d['pqr'] + + d['abc'] = 1 + d['def'] = 2 + d['ghi'] = 3 + d['jkl'] = 4 + d['mno'] = 5 + d['pqr'] = 6 + + d['abc'] + d['def'] + d['ghi'] + d['jkl'] + d['mno'] + d['pqr'] + + d['abc'] = 1 + d['def'] = 2 + d['ghi'] = 3 + d['jkl'] = 4 + d['mno'] = 5 + d['pqr'] = 6 + + d['abc'] + d['def'] + d['ghi'] + d['jkl'] + d['mno'] + d['pqr'] + + d['abc'] = 1 + d['def'] = 2 + d['ghi'] = 3 + d['jkl'] = 4 + d['mno'] = 5 + d['pqr'] = 6 + + d['abc'] + d['def'] + d['ghi'] + d['jkl'] + d['mno'] + d['pqr'] + + d['abc'] = 1 + d['def'] = 2 + d['ghi'] = 3 + d['jkl'] = 4 + d['mno'] = 5 + d['pqr'] = 6 + + d['abc'] + d['def'] + d['ghi'] + d['jkl'] + d['mno'] + d['pqr'] + + def calibrate(self): + + d = {} + + for i in xrange(self.rounds): + pass + +class DictWithFloatKeys(Test): + + version = 0.1 + operations = 5*(6 + 6) + + def test(self): + + d = {} + + for i in xrange(self.rounds): + + d[1.234] = 1 + d[2.345] = 2 + d[3.456] = 3 + d[4.567] = 4 + d[5.678] = 5 + d[6.789] = 6 + + d[1.234] + d[2.345] + d[3.456] + d[4.567] + d[5.678] + d[6.789] + + d[1.234] = 1 + d[2.345] = 2 + d[3.456] = 3 + d[4.567] = 4 + d[5.678] = 5 + d[6.789] = 6 + + d[1.234] + d[2.345] + d[3.456] + d[4.567] + d[5.678] + d[6.789] + + d[1.234] = 1 + d[2.345] = 2 + d[3.456] = 3 + d[4.567] = 4 + d[5.678] = 5 + d[6.789] = 6 + + d[1.234] + d[2.345] + d[3.456] + d[4.567] + d[5.678] + d[6.789] + + d[1.234] = 1 + d[2.345] = 2 + d[3.456] = 3 + d[4.567] = 4 + d[5.678] = 5 + d[6.789] = 6 + + d[1.234] + d[2.345] + d[3.456] + d[4.567] + d[5.678] + d[6.789] + + d[1.234] = 1 + d[2.345] = 2 + d[3.456] = 3 + d[4.567] = 4 + d[5.678] = 5 + d[6.789] = 6 + + d[1.234] + d[2.345] + d[3.456] + d[4.567] + d[5.678] + d[6.789] + + def calibrate(self): + + d = {} + + for i in xrange(self.rounds): + pass + +class DictWithIntegerKeys(Test): + + version = 0.1 + operations = 5*(6 + 6) + + def test(self): + + d = {} + + for i in xrange(self.rounds): + + d[1] = 1 + d[2] = 2 + d[3] = 3 + d[4] = 4 + d[5] = 5 + d[6] = 6 + + d[1] + d[2] + d[3] + d[4] + d[5] + d[6] + + d[1] = 1 + d[2] = 2 + d[3] = 3 + d[4] = 4 + d[5] = 5 + d[6] = 6 + + d[1] + d[2] + d[3] + d[4] + d[5] + d[6] + + d[1] = 1 + d[2] = 2 + d[3] = 3 + d[4] = 4 + d[5] = 5 + d[6] = 6 + + d[1] + d[2] + d[3] + d[4] + d[5] + d[6] + + d[1] = 1 + d[2] = 2 + d[3] = 3 + d[4] = 4 + d[5] = 5 + d[6] = 6 + + d[1] + d[2] + d[3] + d[4] + d[5] + d[6] + + d[1] = 1 + d[2] = 2 + d[3] = 3 + d[4] = 4 + d[5] = 5 + d[6] = 6 + + d[1] + d[2] + d[3] + d[4] + d[5] + d[6] + + def calibrate(self): + + d = {} + + for i in xrange(self.rounds): + pass + +class SimpleDictManipulation(Test): + + version = 0.3 + operations = 5*(6 + 6 + 6 + 6) + + def test(self): + + d = {} + + for i in xrange(self.rounds): + + d[0] = 3 + d[1] = 4 + d[2] = 5 + d[3] = 3 + d[4] = 4 + d[5] = 5 + + x = d[0] + x = d[1] + x = d[2] + x = d[3] + x = d[4] + x = d[5] + + d.has_key(0) + d.has_key(2) + d.has_key(4) + d.has_key(6) + d.has_key(8) + d.has_key(10) + + del d[0] + del d[1] + del d[2] + del d[3] + del d[4] + del d[5] + + d[0] = 3 + d[1] = 4 + d[2] = 5 + d[3] = 3 + d[4] = 4 + d[5] = 5 + + x = d[0] + x = d[1] + x = d[2] + x = d[3] + x = d[4] + x = d[5] + + d.has_key(0) + d.has_key(2) + d.has_key(4) + d.has_key(6) + d.has_key(8) + d.has_key(10) + + del d[0] + del d[1] + del d[2] + del d[3] + del d[4] + del d[5] + + d[0] = 3 + d[1] = 4 + d[2] = 5 + d[3] = 3 + d[4] = 4 + d[5] = 5 + + x = d[0] + x = d[1] + x = d[2] + x = d[3] + x = d[4] + x = d[5] + + d.has_key(0) + d.has_key(2) + d.has_key(4) + d.has_key(6) + d.has_key(8) + d.has_key(10) + + del d[0] + del d[1] + del d[2] + del d[3] + del d[4] + del d[5] + + d[0] = 3 + d[1] = 4 + d[2] = 5 + d[3] = 3 + d[4] = 4 + d[5] = 5 + + x = d[0] + x = d[1] + x = d[2] + x = d[3] + x = d[4] + x = d[5] + + d.has_key(0) + d.has_key(2) + d.has_key(4) + d.has_key(6) + d.has_key(8) + d.has_key(10) + + del d[0] + del d[1] + del d[2] + del d[3] + del d[4] + del d[5] + + d[0] = 3 + d[1] = 4 + d[2] = 5 + d[3] = 3 + d[4] = 4 + d[5] = 5 + + x = d[0] + x = d[1] + x = d[2] + x = d[3] + x = d[4] + x = d[5] + + d.has_key(0) + d.has_key(2) + d.has_key(4) + d.has_key(6) + d.has_key(8) + d.has_key(10) + + del d[0] + del d[1] + del d[2] + del d[3] + del d[4] + del d[5] + + def calibrate(self): + + d = {} + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Exceptions.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Exceptions.py Sat May 27 16:43:53 2006 @@ -0,0 +1,677 @@ +from TestHelpers import Test + +class TryRaiseExcept(Test): + + version = 0.1 + operations = 2 + 3 + + def test(self): + + error = ValueError + + for i in xrange(self.rounds): + try: + raise error + except: + pass + try: + raise error + except: + pass + try: + raise error,"something" + except: + pass + try: + raise error,"something" + except: + pass + try: + raise error,"something" + except: + pass + + def calibrate(self): + + error = ValueError + + for i in xrange(self.rounds): + pass + + +class TryExcept(Test): + + version = 0.1 + operations = 15 * 10 + + def test(self): + + for i in xrange(self.rounds): + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + try: + pass + except: + pass + + def calibrate(self): + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Imports.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Imports.py Sat May 27 16:43:53 2006 @@ -0,0 +1,135 @@ +from TestHelpers import Test + +# First imports: +import os +import package.submodule + +class SecondImport(Test): + + version = 0.1 + operations = 5 * 5 + + def test(self): + + for i in xrange(self.rounds): + import os + import os + import os + import os + import os + + import os + import os + import os + import os + import os + + import os + import os + import os + import os + import os + + import os + import os + import os + import os + import os + + import os + import os + import os + import os + import os + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class SecondPackageImport(Test): + + version = 0.1 + operations = 5 * 5 + + def test(self): + + for i in xrange(self.rounds): + import package + import package + import package + import package + import package + + import package + import package + import package + import package + import package + + import package + import package + import package + import package + import package + + import package + import package + import package + import package + import package + + import package + import package + import package + import package + import package + + def calibrate(self): + + for i in xrange(self.rounds): + pass + +class SecondSubmoduleImport(Test): + + version = 0.1 + operations = 5 * 5 + + def test(self): + + for i in xrange(self.rounds): + import package.submodule + import package.submodule + import package.submodule + import package.submodule + import package.submodule + + import package.submodule + import package.submodule + import package.submodule + import package.submodule + import package.submodule + + import package.submodule + import package.submodule + import package.submodule + import package.submodule + import package.submodule + + import package.submodule + import package.submodule + import package.submodule + import package.submodule + import package.submodule + + import package.submodule + import package.submodule + import package.submodule + import package.submodule + import package.submodule + + def calibrate(self): + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Instances.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Instances.py Sat May 27 16:43:53 2006 @@ -0,0 +1,65 @@ +from TestHelpers import Test + +class CreateInstances(Test): + + version = 0.2 + operations = 3 + 7 + 4 + + def test(self): + + class c: + pass + + class d: + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e: + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + o = c() + o1 = c() + o2 = c() + p = d(i,i,3) + p1 = d(i,i,3) + p2 = d(i,3,3) + p3 = d(3,i,3) + p4 = d(i,i,i) + p5 = d(3,i,3) + p6 = d(i,i,i) + q = e(i,i,3) + q1 = e(i,i,3) + q2 = e(i,i,3) + q3 = e(i,i) + + def calibrate(self): + + class c: + pass + + class d: + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e: + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Lists.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Lists.py Sat May 27 16:43:53 2006 @@ -0,0 +1,288 @@ +from TestHelpers import Test + +class SimpleListManipulation(Test): + + version = 0.3 + operations = 5* (6 + 6 + 6) + + def test(self): + + l = [] + + for i in xrange(self.rounds): + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + x = l[0] + x = l[1] + x = l[2] + x = l[3] + x = l[4] + x = l[5] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + x = l[0] + x = l[1] + x = l[2] + x = l[3] + x = l[4] + x = l[5] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + x = l[0] + x = l[1] + x = l[2] + x = l[3] + x = l[4] + x = l[5] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + x = l[0] + x = l[1] + x = l[2] + x = l[3] + x = l[4] + x = l[5] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + x = l[0] + x = l[1] + x = l[2] + x = l[3] + x = l[4] + x = l[5] + + if len(l) > 10000: + # cut down the size + del l[:] + + def calibrate(self): + + l = [] + + for i in xrange(self.rounds): + pass + +class ListSlicing(Test): + + version = 0.4 + operations = 25*(3+1+2+1) + + def test(self): + + n = range(100) + r = range(25) + + for i in xrange(self.rounds): + + l = range(100) + + for j in r: + + m = l[50:] + m = l[:25] + m = l[50:55] + l[:3] = n + m = l[:-1] + m = l[1:] + l[-1:] = n + + def calibrate(self): + + n = range(100) + r = range(25) + + for i in xrange(self.rounds): + + l = range(100) + + for j in r: + pass + +class SmallLists(Test): + + version = 0.3 + operations = 5*(1+ 6 + 6 + 3 + 1) + + def test(self): + + for i in xrange(self.rounds): + + l = [] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + l[:3] = [1,2,3] + m = l[:-1] + m = l[1:] + + l[-1:] = [4,5,6] + + l = [] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + l[:3] = [1,2,3] + m = l[:-1] + m = l[1:] + + l[-1:] = [4,5,6] + + l = [] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + l[:3] = [1,2,3] + m = l[:-1] + m = l[1:] + + l[-1:] = [4,5,6] + + l = [] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + l[:3] = [1,2,3] + m = l[:-1] + m = l[1:] + + l[-1:] = [4,5,6] + + l = [] + + l.append(2) + l.append(3) + l.append(4) + l.append(2) + l.append(3) + l.append(4) + + l[0] = 3 + l[1] = 4 + l[2] = 5 + l[3] = 3 + l[4] = 4 + l[5] = 5 + + l[:3] = [1,2,3] + m = l[:-1] + m = l[1:] + + l[-1:] = [4,5,6] + + def calibrate(self): + + for i in xrange(self.rounds): + l = [] Added: sandbox/trunk/pybch/Tests/Lookups.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Lookups.py Sat May 27 16:43:53 2006 @@ -0,0 +1,940 @@ +from TestHelpers import Test + +class SpecialClassAttribute(Test): + + version = 0.3 + operations = 5*(12 + 12) + + def test(self): + + class c: + pass + + for i in xrange(self.rounds): + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + c.__a = 2 + c.__b = 3 + c.__c = 4 + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + x = c.__a + x = c.__b + x = c.__c + + def calibrate(self): + + class c: + pass + + for i in xrange(self.rounds): + pass + +class NormalClassAttribute(Test): + + version = 0.3 + operations = 5*(12 + 12) + + def test(self): + + class c: + pass + + for i in xrange(self.rounds): + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + c.a = 2 + c.b = 3 + c.c = 4 + + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + x = c.a + x = c.b + x = c.c + + def calibrate(self): + + class c: + pass + + for i in xrange(self.rounds): + pass + +class SpecialInstanceAttribute(Test): + + version = 0.3 + operations = 5*(12 + 12) + + def test(self): + + class c: + pass + o = c() + + for i in xrange(self.rounds): + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + o.__a__ = 2 + o.__b__ = 3 + o.__c__ = 4 + + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + x = o.__a__ + x = o.__b__ + x = o.__c__ + + def calibrate(self): + + class c: + pass + o = c() + + for i in xrange(self.rounds): + pass + +class NormalInstanceAttribute(Test): + + version = 0.3 + operations = 5*(12 + 12) + + def test(self): + + class c: + pass + o = c() + + for i in xrange(self.rounds): + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + o.a = 2 + o.b = 3 + o.c = 4 + + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + x = o.a + x = o.b + x = o.c + + def calibrate(self): + + class c: + pass + o = c() + + for i in xrange(self.rounds): + pass + +class BuiltinMethodLookup(Test): + + version = 0.3 + operations = 5*(3*5 + 3*5) + + def test(self): + + l = [] + d = {} + + for i in xrange(self.rounds): + + l.append + l.append + l.append + l.append + l.append + + l.insert + l.insert + l.insert + l.insert + l.insert + + l.sort + l.sort + l.sort + l.sort + l.sort + + d.has_key + d.has_key + d.has_key + d.has_key + d.has_key + + d.items + d.items + d.items + d.items + d.items + + d.get + d.get + d.get + d.get + d.get + + l.append + l.append + l.append + l.append + l.append + + l.insert + l.insert + l.insert + l.insert + l.insert + + l.sort + l.sort + l.sort + l.sort + l.sort + + d.has_key + d.has_key + d.has_key + d.has_key + d.has_key + + d.items + d.items + d.items + d.items + d.items + + d.get + d.get + d.get + d.get + d.get + + l.append + l.append + l.append + l.append + l.append + + l.insert + l.insert + l.insert + l.insert + l.insert + + l.sort + l.sort + l.sort + l.sort + l.sort + + d.has_key + d.has_key + d.has_key + d.has_key + d.has_key + + d.items + d.items + d.items + d.items + d.items + + d.get + d.get + d.get + d.get + d.get + + l.append + l.append + l.append + l.append + l.append + + l.insert + l.insert + l.insert + l.insert + l.insert + + l.sort + l.sort + l.sort + l.sort + l.sort + + d.has_key + d.has_key + d.has_key + d.has_key + d.has_key + + d.items + d.items + d.items + d.items + d.items + + d.get + d.get + d.get + d.get + d.get + + l.append + l.append + l.append + l.append + l.append + + l.insert + l.insert + l.insert + l.insert + l.insert + + l.sort + l.sort + l.sort + l.sort + l.sort + + d.has_key + d.has_key + d.has_key + d.has_key + d.has_key + + d.items + d.items + d.items + d.items + d.items + + d.get + d.get + d.get + d.get + d.get + + def calibrate(self): + + l = [] + d = {} + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/NewInstances.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/NewInstances.py Sat May 27 16:43:53 2006 @@ -0,0 +1,65 @@ +from TestHelpers import Test + +class CreateNewInstances(Test): + + version = 0.1 + operations = 3 + 7 + 4 + + def test(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + o = c() + o1 = c() + o2 = c() + p = d(i,i,3) + p1 = d(i,i,3) + p2 = d(i,3,3) + p3 = d(3,i,3) + p4 = d(i,i,i) + p5 = d(3,i,3) + p6 = d(i,i,i) + q = e(i,i,3) + q1 = e(i,i,3) + q2 = e(i,i,3) + q3 = e(i,i) + + def calibrate(self): + + class c(object): + pass + + class d(object): + def __init__(self,a,b,c): + self.a = a + self.b = b + self.c = c + + class e(object): + def __init__(self,a,b,c=4): + self.a = a + self.b = b + self.c = c + self.d = a + self.e = b + self.f = c + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Numbers.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Numbers.py Sat May 27 16:43:53 2006 @@ -0,0 +1,780 @@ +from TestHelpers import Test + +class CompareIntegers(Test): + + version = 0.1 + operations = 30 * 5 + + def test(self): + + for i in xrange(self.rounds): + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + 2 < 3 + 2 > 3 + 2 == 3 + 2 > 3 + 2 < 3 + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class CompareFloats(Test): + + version = 0.1 + operations = 30 * 5 + + def test(self): + + for i in xrange(self.rounds): + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + 2.1 < 3.31 + 2.1 > 3.31 + 2.1 == 3.31 + 2.1 > 3.31 + 2.1 < 3.31 + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class CompareFloatsIntegers(Test): + + version = 0.1 + operations = 30 * 5 + + def test(self): + + for i in xrange(self.rounds): + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + 2.1 < 4 + 2.1 > 4 + 2.1 == 4 + 2.1 > 4 + 2.1 < 4 + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class CompareLongs(Test): + + version = 0.1 + operations = 30 * 5 + + def test(self): + + for i in xrange(self.rounds): + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + 1234567890L < 3456789012345L + 1234567890L > 3456789012345L + 1234567890L == 3456789012345L + 1234567890L > 3456789012345L + 1234567890L < 3456789012345L + + def calibrate(self): + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Strings.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Strings.py Sat May 27 16:43:53 2006 @@ -0,0 +1,555 @@ +from TestHelpers import Test +from string import join + +class ConcatStrings(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + # Make sure the strings are *not* interned + s = join(map(str,range(100))) + t = join(map(str,range(1,101))) + + for i in xrange(self.rounds): + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + def calibrate(self): + + s = join(map(str,range(100))) + t = join(map(str,range(1,101))) + + for i in xrange(self.rounds): + pass + + +class CompareStrings(Test): + + version = 0.2 + operations = 10 * 5 + + def test(self): + + # Make sure the strings are *not* interned + s = join(map(str,range(10))) + t = join(map(str,range(10))) + "abc" + + for i in xrange(self.rounds): + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + def calibrate(self): + + s = join(map(str,range(10))) + t = join(map(str,range(10))) + "abc" + + for i in xrange(self.rounds): + pass + + +class CompareInternedStrings(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + # Make sure the strings *are* interned + s = intern(join(map(str,range(10)))) + t = s + + for i in xrange(self.rounds): + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + t == s + t == s + t >= s + t > s + t < s + + def calibrate(self): + + s = intern(join(map(str,range(10)))) + t = s + + for i in xrange(self.rounds): + pass + + +class CreateStringsWithConcat(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + for i in xrange(self.rounds): + s = 'om' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class StringSlicing(Test): + + version = 0.1 + operations = 5 * 7 + + def test(self): + + s = join(map(str,range(100))) + + for i in xrange(self.rounds): + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + def calibrate(self): + + s = join(map(str,range(100))) + + for i in xrange(self.rounds): + pass + +### String methods + +if hasattr('', 'lower'): + + class StringMappings(Test): + + version = 0.1 + operations = 3 * (5 + 4 + 2 + 1) + + def test(self): + + s = join(map(chr,range(20)),'') + t = join(map(chr,range(50)),'') + u = join(map(chr,range(100)),'') + v = join(map(chr,range(256)),'') + + for i in xrange(self.rounds): + + s.lower() + s.lower() + s.lower() + s.lower() + s.lower() + + s.upper() + s.upper() + s.upper() + s.upper() + s.upper() + + s.title() + s.title() + s.title() + s.title() + s.title() + + t.lower() + t.lower() + t.lower() + t.lower() + + t.upper() + t.upper() + t.upper() + t.upper() + + t.title() + t.title() + t.title() + t.title() + + u.lower() + u.lower() + + u.upper() + u.upper() + + u.title() + u.title() + + v.lower() + + v.upper() + + v.title() + + def calibrate(self): + + s = join(map(chr,range(20)),'') + t = join(map(chr,range(50)),'') + u = join(map(chr,range(100)),'') + v = join(map(chr,range(256)),'') + + for i in xrange(self.rounds): + pass + + class StringPredicates(Test): + + version = 0.1 + operations = 10 * 7 + + def test(self): + + data = ('abc', '123', ' ', '\xe4\xf6\xfc', '\xdf'*10) + len_data = len(data) + + for i in xrange(self.rounds): + s = data[i % len_data] + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdigit() + s.islower() + s.isspace() + s.istitle() + s.isupper() + + def calibrate(self): + + data = ('abc', '123', ' ', '\u1234\u2345\u3456', '\uFFFF'*10) + data = ('abc', '123', ' ', '\xe4\xf6\xfc', '\xdf'*10) + len_data = len(data) + + for i in xrange(self.rounds): + s = data[i % len_data] Added: sandbox/trunk/pybch/Tests/TestHelpers.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/TestHelpers.py Sat May 27 16:43:53 2006 @@ -0,0 +1,43 @@ +import time + +class Test: + rounds = None + is_a_test = 1 + verbose = 0 + def cowlibrate(self): + self.rounds = 100 + successfulRounds = 0 + while 1: + time.sleep(self.passSleepTime) + start = self.timer() + self.test() + elapsed = self.timer() - start + if self.verbose > 3: print elapsed, self.rounds, successfulRounds + if (elapsed >= self.runtimeTarget - self.runtimeAccuracyTarget + and elapsed <= self.runtimeTarget + + self.runtimeAccuracyTarget): + successfulRounds = successfulRounds + 1 + if successfulRounds > 10: break + else: + successfulRounds = 0 + self.rounds = int(self.rounds * + (self.runtimeTarget / elapsed) * + (1 + (self.runtimeAccuracyTarget * 2))) + + def run(self): + fastestTime = None + sinceFastest = 0 + lap = 0 + while sinceFastest < self.requiredStablePasses: + lap = lap + 1 + time.sleep(self.passSleepTime) + start = self.timer() + self.test() + elapsed = self.timer() - start + if self.verbose > 3: print lap, elapsed, fastestTime + if fastestTime == None or elapsed < fastestTime: + fastestTime = elapsed + sinceFastest = 0 + sinceFastest = sinceFastest + 1 + + return(fastestTime) Added: sandbox/trunk/pybch/Tests/Tuples.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Tuples.py Sat May 27 16:43:53 2006 @@ -0,0 +1,362 @@ +from TestHelpers import Test + +class TupleSlicing(Test): + + version = 0.31 + operations = 3 * 25 * 10 * 7 + + def test(self): + + r = range(25) + + for i in xrange(self.rounds): + + t = tuple(range(100)) + + for j in r: + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + m = t[50:] + m = t[:25] + m = t[50:55] + m = t[:-1] + m = t[1:] + m = t[-10:] + m = t[:10] + + def calibrate(self): + + r = range(25) + + for i in xrange(self.rounds): + + t = tuple(range(100)) + + for j in r: + + pass + +class SmallTuples(Test): + + version = 0.3 + operations = 5*(1 + 3 + 6 + 2) + + def test(self): + + for i in xrange(self.rounds): + + t = (1,2,3,4,5,6) + + a,b,c,d,e,f = t + a,b,c,d,e,f = t + a,b,c,d,e,f = t + + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + + l = list(t) + t = tuple(l) + + t = (1,2,3,4,5,6) + + a,b,c,d,e,f = t + a,b,c,d,e,f = t + a,b,c,d,e,f = t + + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + + l = list(t) + t = tuple(l) + + t = (1,2,3,4,5,6) + + a,b,c,d,e,f = t + a,b,c,d,e,f = t + a,b,c,d,e,f = t + + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + + l = list(t) + t = tuple(l) + + t = (1,2,3,4,5,6) + + a,b,c,d,e,f = t + a,b,c,d,e,f = t + a,b,c,d,e,f = t + + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + + l = list(t) + t = tuple(l) + + t = (1,2,3,4,5,6) + + a,b,c,d,e,f = t + a,b,c,d,e,f = t + a,b,c,d,e,f = t + + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + a,b,c = t[:3] + + l = list(t) + t = tuple(l) + + def calibrate(self): + + for i in xrange(self.rounds): + pass Added: sandbox/trunk/pybch/Tests/Unicode.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/Unicode.py Sat May 27 16:43:53 2006 @@ -0,0 +1,535 @@ +try: + unicode +except NameError: + raise ImportError + +from TestHelpers import Test +from string import join + +class ConcatUnicode(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + # Make sure the strings are *not* interned + s = unicode(join(map(str,range(100)))) + t = unicode(join(map(str,range(1,101)))) + + for i in xrange(self.rounds): + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + t + s + t + s + t + s + t + s + t + s + + def calibrate(self): + + s = unicode(join(map(str,range(100)))) + t = unicode(join(map(str,range(1,101)))) + + for i in xrange(self.rounds): + pass + + +class CompareUnicode(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + # Make sure the strings are *not* interned + s = unicode(join(map(str,range(10)))) + t = unicode(join(map(str,range(10))) + "abc") + + for i in xrange(self.rounds): + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + t < s + t > s + t == s + t > s + t < s + + def calibrate(self): + + s = unicode(join(map(str,range(10)))) + t = unicode(join(map(str,range(10))) + "abc") + + for i in xrange(self.rounds): + pass + + +class CreateUnicodeWithConcat(Test): + + version = 0.1 + operations = 10 * 5 + + def test(self): + + for i in xrange(self.rounds): + s = u'om' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + s = s + u'xax' + s = s + u'xbx' + s = s + u'xcx' + s = s + u'xdx' + s = s + u'xex' + + def calibrate(self): + + for i in xrange(self.rounds): + pass + + +class UnicodeSlicing(Test): + + version = 0.1 + operations = 5 * 7 + + def test(self): + + s = unicode(join(map(str,range(100)))) + + for i in xrange(self.rounds): + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + s[50:] + s[:25] + s[50:55] + s[-1:] + s[:1] + s[2:] + s[11:-11] + + def calibrate(self): + + s = unicode(join(map(str,range(100)))) + + for i in xrange(self.rounds): + pass + +### String methods + +class UnicodeMappings(Test): + + version = 0.1 + operations = 3 * (5 + 4 + 2 + 1) + + def test(self): + + s = join(map(unichr,range(20)),'') + t = join(map(unichr,range(100)),'') + u = join(map(unichr,range(500)),'') + v = join(map(unichr,range(1000)),'') + + for i in xrange(self.rounds): + + s.lower() + s.lower() + s.lower() + s.lower() + s.lower() + + s.upper() + s.upper() + s.upper() + s.upper() + s.upper() + + s.title() + s.title() + s.title() + s.title() + s.title() + + t.lower() + t.lower() + t.lower() + t.lower() + + t.upper() + t.upper() + t.upper() + t.upper() + + t.title() + t.title() + t.title() + t.title() + + u.lower() + u.lower() + + u.upper() + u.upper() + + u.title() + u.title() + + v.lower() + + v.upper() + + v.title() + + def calibrate(self): + + s = join(map(unichr,range(20)),'') + t = join(map(unichr,range(100)),'') + u = join(map(unichr,range(500)),'') + v = join(map(unichr,range(1000)),'') + + for i in xrange(self.rounds): + pass + +class UnicodePredicates(Test): + + version = 0.1 + operations = 5 * 9 + + def test(self): + + data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10) + len_data = len(data) + + for i in xrange(self.rounds): + s = data[i % len_data] + + s.isalnum() + s.isalpha() + s.isdecimal() + s.isdigit() + s.islower() + s.isnumeric() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdecimal() + s.isdigit() + s.islower() + s.isnumeric() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdecimal() + s.isdigit() + s.islower() + s.isnumeric() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdecimal() + s.isdigit() + s.islower() + s.isnumeric() + s.isspace() + s.istitle() + s.isupper() + + s.isalnum() + s.isalpha() + s.isdecimal() + s.isdigit() + s.islower() + s.isnumeric() + s.isspace() + s.istitle() + s.isupper() + + def calibrate(self): + + data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10) + len_data = len(data) + + for i in xrange(self.rounds): + s = data[i % len_data] + +try: + import unicodedata +except ImportError: + pass +else: + class UnicodeProperties(Test): + + version = 0.1 + operations = 5 * 8 + + def test(self): + + data = (u'a', u'1', u' ', u'\u1234', u'\uFFFF') + len_data = len(data) + digit = unicodedata.digit + numeric = unicodedata.numeric + decimal = unicodedata.decimal + category = unicodedata.category + bidirectional = unicodedata.bidirectional + decomposition = unicodedata.decomposition + mirrored = unicodedata.mirrored + combining = unicodedata.combining + + for i in xrange(self.rounds): + + c = data[i % len_data] + + digit(c, None) + numeric(c, None) + decimal(c, None) + category(c) + bidirectional(c) + decomposition(c) + mirrored(c) + combining(c) + + digit(c, None) + numeric(c, None) + decimal(c, None) + category(c) + bidirectional(c) + decomposition(c) + mirrored(c) + combining(c) + + digit(c, None) + numeric(c, None) + decimal(c, None) + category(c) + bidirectional(c) + decomposition(c) + mirrored(c) + combining(c) + + digit(c, None) + numeric(c, None) + decimal(c, None) + category(c) + bidirectional(c) + decomposition(c) + mirrored(c) + combining(c) + + digit(c, None) + numeric(c, None) + decimal(c, None) + category(c) + bidirectional(c) + decomposition(c) + mirrored(c) + combining(c) + + def calibrate(self): + + data = (u'a', u'1', u' ', u'\u1234', u'\uFFFF') + len_data = len(data) + digit = unicodedata.digit + numeric = unicodedata.numeric + decimal = unicodedata.decimal + category = unicodedata.category + bidirectional = unicodedata.bidirectional + decomposition = unicodedata.decomposition + mirrored = unicodedata.mirrored + combining = unicodedata.combining + + for i in xrange(self.rounds): + + c = data[i % len_data] Added: sandbox/trunk/pybch/Tests/__init__.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/__init__.py Sat May 27 16:43:53 2006 @@ -0,0 +1,17 @@ +testModules = [ +# 'Arithmetic', + 'Calls', + 'Constructs', + 'Dict', + 'Exceptions', + 'Imports', + 'Instances', + 'Lists', + 'Lookups', + 'NewInstances', + 'Numbers', + 'Strings', + 'TestHelpers', + 'Tuples', + 'Unicode', + ] Added: sandbox/trunk/pybch/pybch.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/pybch.py Sat May 27 16:43:53 2006 @@ -0,0 +1,146 @@ +#!/usr/bin/env python +# +# Copyright (c) 2006, Sean Reifschneider, tummy.com, ltd. +# All Rights Reserved. + +import time, sys, pickle, os + +verbose = 4 + +###################### +def rusageTimer(self): + import resource + return(resource.getrusage(resource.RUSAGE_SELF)[0]) + + +######################### +def getEnvironmentInfo(): + import re + reg = re.compile(r'^(?P\S+)\s+\((?P[^\)]+)\).*\s*\[' + r'(?P[^\]]+)\]', re.M) + m = reg.match(sys.version) + if not m: raise ValueError, 'Could not parse sys.version' + results = m.groupdict() + results['host'] = os.uname()[1] + return(results) + + +######################## +def shortifyTestName(s): + #if s[:6] == 'Tests.': s = s[6:] + s = s.split('.')[-1] + return(s) + + +######################################################### +def compareResults(testResults, verbose, compareResults): + # display comparison results + print ('Comparing %(version)s (%(build)s)' + % compareResults['environment']) + print (' to %(version)s (%(build)s)' + % compareResults['environment']) + print ('Comparing [%(environment)s] on %(host)s' + % compareResults['environment']) + print (' to [%(environment)s] on %(host)s' + % compareResults['environment']) + print + + # get list of tests + testList = map(lambda x: ( shortifyTestName(str(x[0][1])), x[0], x[1] ), + testResults['results'].items()) + testList.sort() + + # print individual results + overallDiff = 0.0 + overallSpeedups = 0.0 + overallSlowdowns = 0.0 + for testSource in testList: + testCompare = [ None, None, compareResults['results'][testSource[1]] ] + sourceAverage = (reduce(lambda x,y: x+y, testSource[2], 0) + / len(testSource[2])) + compareAverage = (reduce(lambda x,y: x+y, testCompare[2], 0) + / len(testCompare[2])) + + # calculate averages + sourceAverages = [] + for n in testSource[2]: + sourceAverages.append(n / sourceAverage * 100.0) + compareAverages = [] + for n in testCompare[2]: + compareAverages.append(n / compareAverage * 100.0) + + sourceAveragesStr = ' '.join(map(lambda x: '%5.1f%%' + % x, sourceAverages)) + compareAveragesStr = ' '.join(map(lambda x: '%5.1f%%' + % x, compareAverages)) + + difference = min(testCompare[2]) - min(testSource[2]) + overallDiff = overallDiff + difference + if difference > 0: + overallSlowdowns = overallSlowdowns + difference + if difference < 0: + overallSpeedups = overallSpeedups + difference + + print '%-30s %s' % ( testSource[0], sourceAveragesStr ) + print '%-30s %s -> %5.1f%%' % ( '', compareAveragesStr, difference ) + + print '=' * 78 + print '%68s %5.1f%%' % ( 'Overall difference:', overallDiff ) + print '%68s %5.1f%%' % ( 'Overall speedups:', overallSpeedups ) + print '%68s %5.1f%%' % ( 'Overall slowdowns:', overallSlowdowns ) + + +################################## +if sys.argv[1] == '-r': + # load results from a file + testResults = pickle.load(open(sys.argv[2], 'r')) + sys.argv = sys.argv[:1] + sys.argv[3:] +else: + if len(sys.argv) != 3 or sys.argv[1] != '-f': + raise ValueError, 'You must specify "-f "' + + # run tests locally + import Tests + testResults = {} + for moduleName in Tests.testModules: + if verbose >= 3: print moduleName + exec('from Tests import %s' % moduleName) + module = eval(moduleName) + for testClass in module.__dict__.values(): + if (not hasattr(testClass, 'is_a_test') + or 'TestHelpers' in str(testClass)): + continue + + # set up test + if verbose >= 1: print 'Test:', moduleName, testClass + test = testClass() + test.timer = time.time + test.runtimeTarget = 0.5 + test.runtimeAccuracyTarget = 0.025 + test.requiredStablePasses = 10 + test.passSleepTime = 0.1 + test.verbose = verbose + + # run test + if verbose >= 2: print 'Calibrating...' + test.cowlibrate() + if verbose >= 3: print 'Calibrated to %d rounds' % test.rounds + + if verbose >= 2: print 'Running tests...' + first = None + passResults = [] + while len(passResults) < 5: + latest = test.run() + passResults.append(latest) + if first == None: first = latest + if verbose >= 3: print ' %3.2f' % ((first / latest) * 100) + testResults[( moduleName, str(testClass) )] = passResults + +# deal with results +if sys.argv[1] == '-f': + environment = getEnvironmentInfo() + pickle.dump({ 'environment' : environment, 'results' : testResults }, + open(sys.argv[2], 'w')) +if sys.argv[1] == '-c': + compareResults(testResults, verbose, pickle.load(open(sys.argv[2], 'r'))) +sys.exit(0) From python-checkins at python.org Sat May 27 16:52:25 2006 From: python-checkins at python.org (sean.reifschneider) Date: Sat, 27 May 2006 16:52:25 +0200 (CEST) Subject: [Python-checkins] r46467 - sandbox/trunk/pybch/README Message-ID: <20060527145225.9061F1E4006@bag.python.org> Author: sean.reifschneider Date: Sat May 27 16:52:25 2006 New Revision: 46467 Added: sandbox/trunk/pybch/README Log: Adding a README to pybch. Added: sandbox/trunk/pybch/README ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/README Sat May 27 16:52:25 2006 @@ -0,0 +1,27 @@ +pybch +Sean Reifschneider +Many tests taken from pybench by Marc-Andre Lemburg + + +This is another benchmarking program for Python. It uses the benchmarks +from pybench, but it tries to have much more stable results. Like, +comparing two runs using the same Python should produce roughly 0.0% +differences. + +To run, first do: + + pybch.py -w filename + +Then do: + + pybch.py -c filename + +The first will write "filename", and the second will generate a comparison +against the first. You can also do: + + pybch -w filename + pybch -w filename2 + pybch -r filename -c filename2 + +Note that on Unix you should probably run it as root and do "nice -n -20 +pybch" to run it. From buildbot at python.org Sat May 27 16:57:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 27 May 2006 14:57:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060527145744.646481E4006@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/839 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 16:58:21 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 16:58:21 +0200 (CEST) Subject: [Python-checkins] r46468 - in python/trunk/Objects: stringlib/count.h stringlib/fastsearch.h stringlib/find.h stringlib/partition.h stringobject.c unicodeobject.c Message-ID: <20060527145821.B2EDF1E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 16:58:20 2006 New Revision: 46468 Modified: python/trunk/Objects/stringlib/count.h python/trunk/Objects/stringlib/fastsearch.h python/trunk/Objects/stringlib/find.h python/trunk/Objects/stringlib/partition.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: needforspeed: replace improvements, changed to Py_LOCAL_INLINE where appropriate Modified: python/trunk/Objects/stringlib/count.h ============================================================================== --- python/trunk/Objects/stringlib/count.h (original) +++ python/trunk/Objects/stringlib/count.h Sat May 27 16:58:20 2006 @@ -7,7 +7,7 @@ #error must include "stringlib/fastsearch.h" before including this module #endif -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) stringlib_count(const STRINGLIB_CHAR* str, Py_ssize_t str_len, const STRINGLIB_CHAR* sub, Py_ssize_t sub_len) { Modified: python/trunk/Objects/stringlib/fastsearch.h ============================================================================== --- python/trunk/Objects/stringlib/fastsearch.h (original) +++ python/trunk/Objects/stringlib/fastsearch.h Sat May 27 16:58:20 2006 @@ -17,7 +17,7 @@ #define FAST_COUNT 0 #define FAST_SEARCH 1 -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n, const STRINGLIB_CHAR* p, Py_ssize_t m, int mode) Modified: python/trunk/Objects/stringlib/find.h ============================================================================== --- python/trunk/Objects/stringlib/find.h (original) +++ python/trunk/Objects/stringlib/find.h Sat May 27 16:58:20 2006 @@ -7,7 +7,7 @@ #error must include "stringlib/fastsearch.h" before including this module #endif -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) stringlib_find(const STRINGLIB_CHAR* str, Py_ssize_t str_len, const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, Py_ssize_t offset) @@ -25,7 +25,7 @@ return pos; } -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) stringlib_rfind(const STRINGLIB_CHAR* str, Py_ssize_t str_len, const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, Py_ssize_t offset) @@ -50,7 +50,7 @@ #ifdef STRINGLIB_STR -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) stringlib_find_obj(PyObject* str, PyObject* sub, Py_ssize_t start, Py_ssize_t end) { @@ -60,7 +60,7 @@ ); } -Py_LOCAL(int) +Py_LOCAL_INLINE(int) stringlib_contains_obj(PyObject* str, PyObject* sub) { return stringlib_find( @@ -69,7 +69,7 @@ ) != -1; } -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) stringlib_rfind_obj(PyObject* str, PyObject* sub, Py_ssize_t start, Py_ssize_t end) { Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Sat May 27 16:58:20 2006 @@ -7,7 +7,7 @@ #error must include "stringlib/fastsearch.h" before including this module #endif -Py_LOCAL(PyObject*) +Py_LOCAL_INLINE(PyObject*) stringlib_partition( PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len @@ -51,7 +51,7 @@ return out; } -Py_LOCAL(PyObject*) +Py_LOCAL_INLINE(PyObject*) stringlib_rpartition( PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 27 16:58:20 2006 @@ -1371,7 +1371,7 @@ #define RSKIP_SPACE(s, i) { while (i>=0 && isspace(Py_CHARMASK(s[i]))) i--; } #define RSKIP_NONSPACE(s, i) { while (i>=0 && !isspace(Py_CHARMASK(s[i]))) i--; } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { Py_ssize_t i, j, count=0; @@ -1405,7 +1405,7 @@ return NULL; } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { register Py_ssize_t i, j, count=0; @@ -1578,7 +1578,7 @@ ); } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit) { Py_ssize_t i, j, count=0; @@ -1614,7 +1614,7 @@ return NULL; } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) rsplit_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { register Py_ssize_t i, j, count=0; @@ -1828,7 +1828,7 @@ return string_join((PyStringObject *)sep, x); } -Py_LOCAL(void) +Py_LOCAL_INLINE(void) string_adjust_indices(Py_ssize_t *start, Py_ssize_t *end, Py_ssize_t len) { if (*end > len) @@ -1843,7 +1843,7 @@ *start = 0; } -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) string_find_internal(PyStringObject *self, PyObject *args, int dir) { const char *s = PyString_AS_STRING(self), *sub; @@ -1953,7 +1953,7 @@ } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj) { char *s = PyString_AS_STRING(self); @@ -1986,7 +1986,7 @@ } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) do_strip(PyStringObject *self, int striptype) { char *s = PyString_AS_STRING(self); @@ -2016,7 +2016,7 @@ } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) do_argstrip(PyStringObject *self, int striptype, PyObject *args) { PyObject *sep = NULL; @@ -2460,7 +2460,7 @@ PyString_GET_SIZE(self)); } -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) countchar(char *target, int target_len, char c, Py_ssize_t maxcount) { Py_ssize_t count=0; @@ -2514,7 +2514,7 @@ return -1; } -Py_LOCAL(Py_ssize_t) +Py_LOCAL_INLINE(Py_ssize_t) countstring(char *target, Py_ssize_t target_len, char *pattern, Py_ssize_t pattern_len, Py_ssize_t start, @@ -3335,7 +3335,7 @@ return u; } -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) pad(PyStringObject *self, Py_ssize_t left, Py_ssize_t right, char fill) { PyObject *u; @@ -4096,7 +4096,7 @@ /* Helpers for formatstring */ -Py_LOCAL(PyObject *) +Py_LOCAL_INLINE(PyObject *) getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx) { Py_ssize_t argidx = *p_argidx; @@ -4125,7 +4125,7 @@ #define F_ALT (1<<3) #define F_ZERO (1<<4) -Py_LOCAL(int) +Py_LOCAL_INLINE(int) formatfloat(char *buf, size_t buflen, int flags, int prec, int type, PyObject *v) { @@ -4312,7 +4312,7 @@ return result; } -Py_LOCAL(int) +Py_LOCAL_INLINE(int) formatint(char *buf, size_t buflen, int flags, int prec, int type, PyObject *v) { @@ -4384,7 +4384,7 @@ return (int)strlen(buf); } -Py_LOCAL(int) +Py_LOCAL_INLINE(int) formatchar(char *buf, size_t buflen, PyObject *v) { /* presume that the buffer is at least 2 characters long */ Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 16:58:20 2006 @@ -141,7 +141,7 @@ #define BLOOM_LINEBREAK(ch)\ (BLOOM(bloom_linebreak, (ch)) && Py_UNICODE_ISLINEBREAK((ch))) -Py_LOCAL(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) +Py_LOCAL_INLINE(BLOOM_MASK) make_bloom_mask(Py_UNICODE* ptr, Py_ssize_t len) { /* calculate simple bloom-style bitmask for a given unicode string */ @@ -155,7 +155,7 @@ return mask; } -Py_LOCAL(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) +Py_LOCAL_INLINE(int) unicode_member(Py_UNICODE chr, Py_UNICODE* set, Py_ssize_t setlen) { Py_ssize_t i; @@ -2015,7 +2015,7 @@ */ -Py_LOCAL(const Py_UNICODE *) findchar(const Py_UNICODE *s, +Py_LOCAL_INLINE(const Py_UNICODE *) findchar(const Py_UNICODE *s, Py_ssize_t size, Py_UNICODE ch) { @@ -3860,7 +3860,7 @@ #define STRINGLIB_NEW PyUnicode_FromUnicode #define STRINGLIB_STR PyUnicode_AS_UNICODE -Py_LOCAL(int) +Py_LOCAL_INLINE(int) STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) { if (str[0] != other[0]) @@ -4710,7 +4710,7 @@ } } else { - Py_ssize_t n, i; + Py_ssize_t n, i, j, e; Py_ssize_t product, new_size, delta; Py_UNICODE *p; @@ -4743,21 +4743,35 @@ return NULL; i = 0; p = u->str; + e = self->length - str1->length; if (str1->length > 0) { - while (i <= self->length - str1->length) - if (Py_UNICODE_MATCH(self, i, str1)) { - /* replace string segment */ + while (n-- > 0) { + /* look for next match */ + j = i; + while (j <= e) { + if (Py_UNICODE_MATCH(self, j, str1)) + break; + j++; + } + if (j > i) { + if (j > e) + break; + /* copy unchanged part [i:j] */ + Py_UNICODE_COPY(p, self->str+i, j-i); + p += j - i; + } + /* copy substitution string */ + if (str2->length > 0) { Py_UNICODE_COPY(p, str2->str, str2->length); p += str2->length; - i += str1->length; - if (--n <= 0) { - /* copy remaining part */ - Py_UNICODE_COPY(p, self->str+i, self->length-i); - break; - } - } else - *p++ = self->str[i++]; + } + i = j + str1->length; + } + if (i < self->length) + /* copy tail [i:] */ + Py_UNICODE_COPY(p, self->str+i, self->length-i); } else { + /* interleave */ while (n > 0) { Py_UNICODE_COPY(p, str2->str, str2->length); p += str2->length; From buildbot at python.org Sat May 27 17:07:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 27 May 2006 15:07:53 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060527150753.503F41E4006@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/817 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.dalke,andrew.kuchling,bob.ippolito,brett.cannon,fred.drake,fredrik.lundh,georg.brandl,jack.diederich,kristjan.jonsson,martin.blais,martin.v.loewis,neal.norwitz,richard.jones,ronald.oussoren,steve.holden,thomas.heller,thomas.wouters,tim.peters,walter.doerwald Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat May 27 17:20:23 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 17:20:23 +0200 (CEST) Subject: [Python-checkins] r46469 - in python/trunk/Objects: stringlib/find.h unicodeobject.c Message-ID: <20060527152023.4F7661E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 17:20:22 2006 New Revision: 46469 Modified: python/trunk/Objects/stringlib/find.h python/trunk/Objects/unicodeobject.c Log: needforspeed: stringlib refactoring: changed find_obj to find_slice, to enable use from stringobject Modified: python/trunk/Objects/stringlib/find.h ============================================================================== --- python/trunk/Objects/stringlib/find.h (original) +++ python/trunk/Objects/stringlib/find.h Sat May 27 17:20:22 2006 @@ -48,18 +48,49 @@ return pos; } -#ifdef STRINGLIB_STR - Py_LOCAL_INLINE(Py_ssize_t) -stringlib_find_obj(PyObject* str, PyObject* sub, - Py_ssize_t start, Py_ssize_t end) +stringlib_find_slice(const STRINGLIB_CHAR* str, Py_ssize_t str_len, + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, + Py_ssize_t start, Py_ssize_t end) { + if (start < 0) + start += str_len; + if (start < 0) + start = 0; + if (end > str_len) + end = str_len; + if (end < 0) + end += str_len; + if (end < 0) + end = 0; + return stringlib_find( - STRINGLIB_STR(str) + start, end - start, - STRINGLIB_STR(sub), STRINGLIB_LEN(sub), start + str + start, end - start, + sub, sub_len, start ); } +Py_LOCAL_INLINE(Py_ssize_t) +stringlib_rfind_slice(const STRINGLIB_CHAR* str, Py_ssize_t str_len, + const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, + Py_ssize_t start, Py_ssize_t end) +{ + if (start < 0) + start += str_len; + if (start < 0) + start = 0; + if (end > str_len) + end = str_len; + if (end < 0) + end += str_len; + if (end < 0) + end = 0; + + return stringlib_rfind(str + start, end - start, sub, sub_len, start); +} + +#ifdef STRINGLIB_STR + Py_LOCAL_INLINE(int) stringlib_contains_obj(PyObject* str, PyObject* sub) { @@ -69,19 +100,9 @@ ) != -1; } -Py_LOCAL_INLINE(Py_ssize_t) -stringlib_rfind_obj(PyObject* str, PyObject* sub, - Py_ssize_t start, Py_ssize_t end) -{ - return stringlib_rfind( - STRINGLIB_STR(str) + start, end - start, - STRINGLIB_STR(sub), STRINGLIB_LEN(sub), start - ); -} - -#endif +#endif /* STRINGLIB_STR */ -#endif +#endif /* STRINGLIB_FIND_H */ /* Local variables: Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Sat May 27 17:20:22 2006 @@ -3936,12 +3936,18 @@ return -2; } - FIX_START_END((PyUnicodeObject*) str); - if (direction > 0) - result = stringlib_find_obj(str, sub, start, end); + result = stringlib_find_slice( + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), + PyUnicode_AS_UNICODE(sub), PyUnicode_GET_SIZE(sub), + start, end + ); else - result = stringlib_rfind_obj(str, sub, start, end); + result = stringlib_rfind_slice( + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), + PyUnicode_AS_UNICODE(sub), PyUnicode_GET_SIZE(sub), + start, end + ); Py_DECREF(str); Py_DECREF(sub); @@ -5284,14 +5290,15 @@ if (!PyArg_ParseTuple(args, "O|O&O&:find", &substring, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = PyUnicode_FromObject(substring); if (!substring) return NULL; - FIX_START_END(self); - - result = stringlib_find_obj((PyObject*) self, substring, start, end); + result = stringlib_find_slice( + PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), + PyUnicode_AS_UNICODE(substring), PyUnicode_GET_SIZE(substring), + start, end + ); Py_DECREF(substring); @@ -5352,14 +5359,15 @@ if (!PyArg_ParseTuple(args, "O|O&O&:index", &substring, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; - substring = PyUnicode_FromObject(substring); if (!substring) return NULL; - FIX_START_END(self); - - result = stringlib_find_obj((PyObject*) self, substring, start, end); + result = stringlib_find_slice( + PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), + PyUnicode_AS_UNICODE(substring), PyUnicode_GET_SIZE(substring), + start, end + ); Py_DECREF(substring); @@ -6027,9 +6035,11 @@ if (!substring) return NULL; - FIX_START_END(self); - - result = stringlib_rfind_obj((PyObject*)self, substring, start, end); + result = stringlib_rfind_slice( + PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), + PyUnicode_AS_UNICODE(substring), PyUnicode_GET_SIZE(substring), + start, end + ); Py_DECREF(substring); @@ -6056,9 +6066,11 @@ if (!substring) return NULL; - FIX_START_END(self); - - result = stringlib_rfind_obj((PyObject*)self, substring, start, end); + result = stringlib_rfind_slice( + PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), + PyUnicode_AS_UNICODE(substring), PyUnicode_GET_SIZE(substring), + start, end + ); Py_DECREF(substring); From python-checkins at python.org Sat May 27 17:26:20 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sat, 27 May 2006 17:26:20 +0200 (CEST) Subject: [Python-checkins] r46470 - python/trunk/Objects/stringobject.c Message-ID: <20060527152620.5ABAB1E4006@bag.python.org> Author: fredrik.lundh Date: Sat May 27 17:26:19 2006 New Revision: 46470 Modified: python/trunk/Objects/stringobject.c Log: needforspeed: stringlib refactoring: use find_slice for stringobject Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sat May 27 17:26:19 2006 @@ -1846,32 +1846,35 @@ Py_LOCAL_INLINE(Py_ssize_t) string_find_internal(PyStringObject *self, PyObject *args, int dir) { - const char *s = PyString_AS_STRING(self), *sub; - Py_ssize_t len = PyString_GET_SIZE(self); - Py_ssize_t n, i = 0, last = PY_SSIZE_T_MAX; PyObject *subobj; + const char *sub; + Py_ssize_t sub_len; + Py_ssize_t start=0, end=PY_SSIZE_T_MAX; /* XXX ssize_t i */ - if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", - &subobj, _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) + if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", &subobj, + _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return -2; if (PyString_Check(subobj)) { sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); + sub_len = PyString_GET_SIZE(subobj); } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) - return PyUnicode_Find((PyObject *)self, subobj, i, last, dir); + return PyUnicode_Find( + (PyObject *)self, subobj, start, end, dir); #endif - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) + else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) return -2; - string_adjust_indices(&i, &last, len); - if (dir > 0) - return stringlib_find(s+i, last-i, sub, n, i); + return stringlib_find_slice( + PyString_AS_STRING(self), PyString_GET_SIZE(self), + sub, sub_len, start, end); else - return stringlib_rfind(s+i, last-i, sub, n, i); + return stringlib_rfind_slice( + PyString_AS_STRING(self), PyString_GET_SIZE(self), + sub, sub_len, start, end); } From python-checkins at python.org Sat May 27 17:38:58 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 27 May 2006 17:38:58 +0200 (CEST) Subject: [Python-checkins] r46471 - sandbox/trunk/decimal-c/Makefile sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Message-ID: <20060527153858.6E4551E4006@bag.python.org> Author: georg.brandl Date: Sat May 27 17:38:57 2006 New Revision: 46471 Modified: sandbox/trunk/decimal-c/Makefile sandbox/trunk/decimal-c/_decimal.c sandbox/trunk/decimal-c/decimal.py Log: Add (hopefully) helpful comments for Mateusz. Modified: sandbox/trunk/decimal-c/Makefile ============================================================================== --- sandbox/trunk/decimal-c/Makefile (original) +++ sandbox/trunk/decimal-c/Makefile Sat May 27 17:38:57 2006 @@ -1,11 +1,16 @@ # change PYTHON_25 to point to a 2.5 HEAD build -PYTHON_25=../python-rw/python +# (a fairly recent HEAD is necessary) +PYTHON_25=../../../python/python -all: module test +all: module run module: $(PYTHON_25) setup.py build cp build/lib*/_decimal.so . clean: rm -rf build/ -test: +test: module $(PYTHON_25) test_decimal.py +run: module + $(PYTHON_25) -i -c "import _decimal; CD = _decimal.Decimal; import decimal; D = decimal.Decimal" +debug: module + ddd $(PYTHON_25) Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Sat May 27 17:38:57 2006 @@ -2,20 +2,65 @@ * * Partly written for the Need for Speed sprint in * Iceland by Georg Brandl and Jack Diederich. + * + * Copyrighted to the Python Software Foundation. */ /* Notable incompatibilities between this and the original decimal.py: - Rounding constants are integers. - There's no handle method on the exceptions. + - Context methods don't accept keyword arguments (they're all + called a and b anyways). - Special values are represented by special sign values, so the results of as_tuple() differ. - Many internal "underscore" methods are not accessible on the object. -*/ + - In principle, exponents and the number of digits are unbounded in + Python decimals, since they could use long integers. While that's + praiseworthy, it's also not very speedy ;) + - The Python version sometimes gets the context in the middle of + a method which leads to some calls succeeding even if there is + no valid context. + + Notable kludges necessary retain some compatibility: + + - decimal.py Contexts used to have three dicts, traps, flags and + _ignored, to store whether an error occurred or whether to + raise an exception in this case. I started with them being bitmasks + until we realized that Python code expects them to be dicts and + wants to modify those, so we added back dictobjects to decimalobject. + I guess that this causes slowdown here and there, and the proper way + to do this is to subclass dict to call back some method on assignment. + (This is better done in Python code, I guess.) + - Some internal methods (names starting with underscores) have been + added as a method to the C objects to allow the overlay Python + module to use them. They should be removed from that list, along + with the wrapper functions parsing the Python arguments, once every- + thing is coded in C. + - Some special (__xxx__) methods in the Python code took additional + arguments used internally. Since that's not possible, there's a + _do_decimal_xxx along with a decimal_xxx, see below. + + + This is not yet optimized C code, but mostly translated Python that + was not really made for translating, though it originally should have been. + + Areas which need improvement are marked with XXX throughout the code. + + The functions could use some more comments, I sometimes didn't even transfer + every comment in the Python version. Refcounting and more complicated + structure make even more comments necessary. + + Each function whose name doesn't start with an underscore is supposed to be + stowed in some TypeObject struct. + + Note that the argument and return types of functions are also not very + consistent. Casting things around is necessary, but I'm not always sure + where the right place for that to happen is. (If anyone calls C a strongly + typed language again, hit him on the head.) -/* This is not yet optimized C code, but mostly translated - Python that was not really made for translating, though - it originally should have been. + We were undecided whether to offer a public C API (PyDecimal_FromString etc.) + If you want to do this, look at the datetime module. */ #include "Python.h" @@ -25,6 +70,7 @@ /* helpful macros ************************************************************/ +/* if we later decide to call this module "squeaky" */ #define MODULE_NAME "_decimal" #define INITFUNC_NAME init_decimal @@ -44,7 +90,7 @@ /* Exponent calculations */ -/* XXX: overflow? */ +/* XXX: overflow checking? */ #define ETINY(ctx) ((ctx)->Emin - (ctx)->prec + 1) #define ETOP(ctx) ((ctx)->Emax - (ctx)->prec + 1) #define ADJUSTED(dec) ((dec)->exp + (dec)->ob_size - 1) @@ -53,6 +99,9 @@ /* sign values */ +/* Since we do (decimal->sign & 1) all over the place, it is important + that negative signs have the first bit set. */ + #define SIGN_POS 0 #define SIGN_NEG 1 @@ -82,6 +131,9 @@ /* Context signals */ +/* The naming (conditions vs. signals vs. errors vs. exceptions) + is not very consistent. */ + #define NUMSIGNALS 8 #define S_CLAMPED 0 @@ -95,7 +147,7 @@ /* Other conditions. If they occur and raise an exception, it will be InvalidOperation. Also, context->flags, ->traps and - ->ignored will only contain bits for the signals defined above. + ->ignored will only contain entries for the signals defined above. */ #define NUMCONDITIONS 4 @@ -163,6 +215,8 @@ /* Forwarding ****************************************************************/ +/* some of them could be removed if the functions were declared + in the right order */ static contextobject *getcontext(void); static int setcontext(contextobject *); static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *); @@ -181,7 +235,9 @@ /* Exception handlers *********************************************************/ -/* Raise the exception if signal is trapped and not ignored. */ +/* Raise the exception with expl if cond is trapped and not ignored. + When raising, return onerror. +*/ #define HANDLE_ERROR(ctx, cond, expl, onerror) \ int err = (cond >= NUMSIGNALS ? S_INV_OPERATION : cond); \ if (! _is_flag_set(ctx->ignored, err)) { \ @@ -352,6 +408,13 @@ /* Decimal object methods *****************************************************/ +/* NB: "type" is the real type of the object we're creating here. + + The first version didn't take a "type" arg and just used + &PyDecimal_DecimalType instead. That's a bad idea since it doesn't allow + for subclassing, so we're forced to carry around a typeobject everywhere + where we might create new decimalobjects. +*/ static decimalobject * _new_decimalobj(PyTypeObject *type, long ndigits, char sign, long exp) @@ -520,7 +583,7 @@ } /* Actually round half up. Returns a new reference, either on tmp - * or a new decimalobject, and steals one reference on tmp in turn + * or a new decimalobject, but steals one reference on tmp in turn * if it was passed in so that you can just return _do_round_half_up(...) * without DECREFing tmp afterwards. */ @@ -623,13 +686,15 @@ return _round_down(self, prec, expdiff, ctx); } +/* Mapping rounding constants to functions. Since in C this can be indexed with + any value, it's important to check the rounding constants before! */ typedef decimalobject*(*round_func)(decimalobject *, long, long, contextobject *); static round_func round_funcs[] = { _round_down, _round_up, _round_half_down, _round_half_even, _round_half_up, _round_floor, _round_ceiling }; -/* default: prec=-1, rounding=-1 (use context), see the ROUND_* constants */ +/* default: prec=-1, rounding=-1 (use context values), see the ROUND_* constants */ static decimalobject * _decimal_round(decimalobject *self, long prec, contextobject *ctx, int rounding) { @@ -973,9 +1038,13 @@ return Py_NotImplemented; } +/* Often-used context lists. */ static char *ctxkwlist[] = {"context", 0}; static char *decctxkwlist[] = {"other", "context", 0}; + +/* Make sure that dec is a decimal. Needs to have a contextobject named + "ctx" around. */ #define ENSURE_DECIMAL(methname, dec, type) \ dec = (decimalobject *)_convert_to_decimal(type, (PyObject *)dec, ctx, 1); \ if (!dec) { \ @@ -983,6 +1052,8 @@ return NULL; \ } +/* Make sure that ctx is a valid context. This is commonly used after a + PyArg_Parse... which might leave ctx NULL. */ #define ENSURE_CONTEXT(methname, ctx) \ if (ctx == NULL) { \ if (!(ctx = getcontext())) return NULL; \ @@ -991,6 +1062,16 @@ return NULL; \ } +/* Define some wrappers that parse Python arguments and call the respective + C functions. Unfortunately, that's not possible for methods that have a + strange signature. + + XXX: should the _do_... functions be declared inline? (there actually + is a new macro called Py_LOCAL for this). +*/ + +/* Define a Decimal method with one argument (the context). + The _do_* version is then called with a valid context. */ #define DECIMAL_UNARY_FUNC(methname) \ static PyObject * \ decimal_##methname(decimalobject *self, PyObject *args, PyObject *kwds) \ @@ -1002,6 +1083,10 @@ return (PyObject *)_do_decimal_##methname(self, ctx); \ } +/* Define a Decimal method with two arguments (another decimal which might + also be an integer and a context). + The _do_* version is then called with an actual decimalobject and the + context. */ #define DECIMAL_BINARY_FUNC(methname) \ static PyObject * \ decimal_##methname(decimalobject *self, PyObject *args, PyObject *kwds) \ @@ -1021,7 +1106,7 @@ /* Returns -1, 0, 1. No special error return code, must check - PyErr_Occurred() */ + for that with PyErr_Occurred(). */ static int _do_real_decimal_compare(decimalobject *self, decimalobject *other, contextobject *ctx) @@ -1172,10 +1257,11 @@ return nan; } - + /* XXX */ } DECIMAL_BINARY_FUNC(max) + static decimalobject * _do_decimal_min(decimalobject *self, decimalobject *other, contextobject *ctx) @@ -1185,6 +1271,7 @@ } DECIMAL_BINARY_FUNC(min) + /* strip trailing 0s, change anything equal to 0 to 0e0 */ static decimalobject * _do_decimal_normalize(decimalobject *self, contextobject *ctx) @@ -1218,8 +1305,8 @@ } DECIMAL_UNARY_FUNC(normalize) -/* Quantize self so that its exponent is the same as the exponent of another. */ +/* Quantize self so that its exponent is the same as the exponent of another. */ static decimalobject * _do_decimal_quantize(decimalobject *self, decimalobject *other, contextobject *ctx, int rounding, int watchexp) @@ -1242,6 +1329,7 @@ return _decimal_rescale(self, other->exp, ctx, rounding, watchexp); } + static decimalobject * decimal_quantize(decimalobject *self, PyObject *args, PyObject *kwds) { @@ -1274,6 +1362,7 @@ _do_decimal_remainder_near(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_BINARY_FUNC(remainder_near) @@ -1364,6 +1453,7 @@ return ans; } + static PyObject * decimal_to_integral(decimalobject *self, PyObject *args, PyObject *kwds) { @@ -1405,6 +1495,8 @@ return self; } + +/* Contents of Decimal are also immutable. */ static PyObject * decimal_deepcopy(PyObject *self, PyObject *memo) { @@ -1412,8 +1504,8 @@ return self; } -/* For internal use, this does what Python code achieves - with "Decimal(self)". */ + +/* For internal use; this does what Python code achieves with "Decimal(self)". */ static decimalobject * _decimal_get_copy(decimalobject *self) { @@ -1428,6 +1520,7 @@ return new; } + static PyObject * decimal_adjusted(decimalobject *self) { @@ -1438,6 +1531,7 @@ return PyInt_FromSsize_t(ADJUSTED(self)); } + static PyObject * decimal_as_tuple(decimalobject *self) { @@ -1459,12 +1553,15 @@ return res; } + +/* Stringizing and formatting handling */ + /* max length of output is len(str(max_long)) + len(str(max_long)) + len(".") + len("-") */ #define FORMAT_SIZE 50 -#define SANITY_CHECK(x) assert((x) < end); +#define SANITY_CHECK(x) assert((x) < end) static PyObject * decimal_special_str(decimalobject *d) @@ -1501,6 +1598,7 @@ return PyString_FromString(outbuf); } + static PyObject * decimal_eng_zero_str(decimalobject *d, contextobject *context) { @@ -1548,18 +1646,21 @@ return PyString_FromString(p); } + PyObject * PyDecimal_Str(PyObject *self, PyObject *args, PyObject *kwds) { return _do_decimal_str((decimalobject *)self, NULL, 0); } + static PyObject * decimal_str(decimalobject *d) { return _do_decimal_str(d, NULL, 0); } + static PyObject * _do_decimal_str(decimalobject *d, contextobject *context, int engineering) { @@ -1684,9 +1785,9 @@ } #undef SANITY_CHECK -/* XXX */ + static PyObject * -decimal_round(decimalobject *self, PyObject *args) +decimal_XXX_round(decimalobject *self, PyObject *args) { contextobject *ctx = NULL; long prec = -1, rnd = -1; @@ -1774,17 +1875,22 @@ METH_NOARGS}, {"__deepcopy__", decimal_deepcopy, METH_O}, - /* XXX */ - {"_round", (PyCFunction)decimal_round, + /* XXX: only helper methods below */ + {"_round", (PyCFunction)decimal_XXX_round, METH_VARARGS}, {"abs__", (PyCFunction)decimal_XXX_abs, METH_VARARGS}, {NULL, NULL} }; + static char decimal_doc[] = PyDoc_STR("Floating point class for decimal arithmetic."); +/* Declare a "special" (double-underscore) method with two arguments for use + in PyNumberMethods slots. As this can take any objects, but other code + in this module wants to call some of those methods too, this wrapper + is a convenience */ #define DECIMAL_SPECIAL_2FUNC(func) \ static PyObject * \ func (PyObject *self, PyObject *other) { \ @@ -1799,6 +1905,7 @@ return (PyObject *)res; \ } +/* Same for one-argument methods. */ #define DECIMAL_SPECIAL_1FUNC(func) \ static PyObject * \ func (PyObject *self) { \ @@ -1918,6 +2025,7 @@ _do_decimal_multiply(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_multiply) @@ -1927,6 +2035,7 @@ _do_decimal_divide(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_divide) @@ -1936,6 +2045,7 @@ _do_decimal_floor_div(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_floor_div) @@ -1945,6 +2055,7 @@ _do_decimal_true_div(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_true_div) @@ -1954,6 +2065,7 @@ _do_decimal_remainder(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_remainder) @@ -1963,6 +2075,7 @@ _do_decimal_divmod(decimalobject *self, decimalobject *other, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } DECIMAL_SPECIAL_2FUNC(decimal_divmod) @@ -1972,6 +2085,7 @@ _do_decimal_power(decimalobject *self, decimalobject *other, decimalobject *modulo, contextobject *ctx) { + /* XXX */ Py_RETURN_NONE; } @@ -2199,6 +2313,8 @@ } +/* Trying to avoid casting if not necessary prevents wrong function + signatures. */ static PyNumberMethods decimal_as_number = { decimal_add, /* nb_add */ decimal_subtract, /* nb_subtract */ @@ -2327,11 +2443,13 @@ } +/* Possible spellings for Infinity. (The first character decides the sign) */ static char *infinities[] = { "inf", "infinity", "+inf", "+infinity", "-inf", "-infinity", 0 }; +/* Decimal constructing functions. */ static decimalobject * _decimal_fromliteralinfinity(PyTypeObject *type, char *str) @@ -2411,8 +2529,7 @@ goto err; } while (*++p); -calculate: - + calculate: if (dend < len) exp = atol(str + dend + 1); if (dpos >= 0) @@ -2430,7 +2547,7 @@ /* it's a zero */ dend = (dpos == ipos ? ipos+2 : ipos+1); -finish: + finish: ndigits = dend - ipos - (dpos<0 ? 0 : 1); new = _new_decimalobj(type, ndigits, sign, exp); if (!new) @@ -2443,10 +2560,11 @@ } return new; -err: + err: return handle_ConversionSyntax(type, ctx, "invalid literal for Decimal"); } + static PyObject * decimal_from_string(PyTypeObject *type, char *buffer, long buf_len, contextobject *ctx) @@ -2464,12 +2582,14 @@ return (PyObject *)_decimal_fromliteral(type, buffer, buf_len, ctx); } + PyObject * PyDecimal_FromString(char *buffer, long buf_len, contextobject *ctx) { return decimal_from_string(&PyDecimal_DecimalType, buffer, buf_len, ctx); } + static PyObject * decimal_from_long(PyTypeObject *type, long value) { @@ -2752,7 +2872,7 @@ } -/* XXX: just for debugging? */ +/* XXX: just for debugging, or should we keep those? */ static PyMemberDef _decimal_members[] = { {"_sign", T_INT, offsetof(decimalobject, sign), 0}, {"_exp", T_LONG, offsetof(decimalobject, exp), 0}, @@ -2844,7 +2964,7 @@ &decimal_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)decimal_hash, /* tp_hash */ + (hashfunc)decimal_hash, /* tp_hash */ 0, /* tp_call */ (reprfunc)decimal_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ @@ -2878,7 +2998,13 @@ #ifdef WITH_THREAD -/* Get the context for the current thread. This returns a borrowed reference. */ +/* XXX: No idea if it's actually that easy to get a thread-local context object + working. I intended to let Tim Peters double-check this, but now it's + your turn ;) +*/ + +/* Get the context for the current thread. This returns a borrowed reference + since we don't have to DECREF it in about every function then. */ static contextobject * getcontext(void) { @@ -2914,6 +3040,7 @@ return ctx; } + static int setcontext(contextobject *ctx) { @@ -2931,7 +3058,7 @@ return 0; } -#else +#else /* WITH_THREAD */ static PyObject *current_context; @@ -2966,6 +3093,8 @@ /* Context object ************************************************************/ +/* XXX: This is not safe for subclassing yet. */ + static contextobject * _new_contextobj(long prec, int rounding, int rounding_dec, PyObject *traps, PyObject *flags, long Emin, long Emax, int capitals, @@ -2974,7 +3103,8 @@ contextobject *new; PyObject *f = NULL, *t = NULL, *i = NULL; - new = (contextobject *)PyObject_NEW(contextobject, &PyDecimal_DecimalContextType); + new = (contextobject *)PyObject_NEW(contextobject, + &PyDecimal_DecimalContextType); if (new == NULL) return NULL; @@ -3040,19 +3170,22 @@ static contextobject * context_shallow_copy(contextobject *ctx) { - return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, ctx->traps, - ctx->flags, ctx->Emin, ctx->Emax, ctx->capitals, ctx->clamp, - ctx->ignored, 0); + return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, + ctx->traps, ctx->flags, ctx->Emin, ctx->Emax, + ctx->capitals, ctx->clamp, ctx->ignored, 0); } + static contextobject * context_copy(contextobject *ctx) { - return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, ctx->traps, - ctx->flags, ctx->Emin, ctx->Emax, ctx->capitals, ctx->clamp, - ctx->ignored, 1); + return _new_contextobj(ctx->prec, ctx->rounding, ctx->rounding_dec, + ctx->traps, ctx->flags, ctx->Emin, ctx->Emax, + ctx->capitals, ctx->clamp, ctx->ignored, 1); + /* Note the difference: ^ */ } + static decimalobject * context_create_decimal(contextobject *self, PyObject *args, PyObject *kwds) { @@ -3100,12 +3233,16 @@ return PyInt_FromSsize_t(ETINY(self)); } + static PyObject * context_Etop(contextobject *self) { return PyInt_FromSsize_t(ETOP(self)); } + +/* Define context functions that just call Decimal methods with a + context argument of self. */ #define CONTEXT_UNARY_FUNC(name, decname) \ static PyObject * \ context_##name(contextobject *self, PyObject *a) { \ @@ -3119,6 +3256,7 @@ return res; \ } + #define CONTEXT_BINARY_FUNC(name, decname) \ static PyObject * \ context_##name(contextobject *self, PyObject *args) { \ @@ -3137,6 +3275,7 @@ return res; \ } + /* helper so that we can use the CONTEXT_UNARY_FUNC macro above */ #define _do_decimal_abs_with_round(a, b) \ _do_decimal_absolute(a, b, 1) @@ -3296,6 +3435,7 @@ static PyObject * context_reduce(contextobject *self) { + /* Yes, it seems to be as simple as that. */ return Py_BuildValue("(O(liiOOlliiO))", self->ob_type, self->prec, self->rounding, self->rounding_dec, self->traps, self->flags, @@ -3303,6 +3443,7 @@ self->clamp, self->ignored); } + static PyObject * context_ignore_flags(contextobject *self, PyObject *args) { @@ -3340,6 +3481,7 @@ return ret_flags; } + static PyObject * context_ignore_all_flags(contextobject *self) { @@ -3360,6 +3502,7 @@ return res; } + static PyObject * context_regard_flags(contextobject *self, PyObject *args) { @@ -3392,6 +3535,7 @@ Py_RETURN_NONE; } + static PyObject * context_set_rounding_decision(contextobject *self, PyObject *args) { @@ -3409,6 +3553,7 @@ return PyInt_FromLong((long)old_dec); } + static PyObject * context_set_rounding(contextobject *self, PyObject *args) { @@ -3425,6 +3570,10 @@ return PyInt_FromLong((long)old_round); } + +/* XXX: context_raise_error and friends should really vanish after there's + no more Python code calling them. */ + static PyObject * _do_context_error_dispatch(int flag, PyObject *args) { @@ -3561,6 +3710,16 @@ PyErr_SetString(handler, PyString_AsString(explanation)); return NULL; } + + +/* XXX: no docstrings here, yet. The doctests of the original Python + Context methods must be transferred to some + other test module, because keeping them in here is a mess. + There might actually be a doctest function that does this. +*/ + +/* XXX: all that PyCFunction casting might not be necessary */ + static PyMethodDef context_methods[] = { {"clear_flags", (PyCFunction)context_clear_flags, METH_NOARGS}, @@ -3636,6 +3795,7 @@ {NULL, NULL} }; + static char context_doc[] = PyDoc_STR("Contains the context for a Decimal instance."); @@ -3649,6 +3809,7 @@ c->ob_type->tp_free(c); } + #define TEST_AND_CAT(num, name) \ if (_is_flag_set(self->flags, num)) { \ strcat(flags, name); \ @@ -3722,6 +3883,7 @@ #undef TEST_AND_CAT + static long context_hash(PyObject *c) { @@ -3729,6 +3891,7 @@ return -1; } + static PyObject * context_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -3898,6 +4061,9 @@ {NULL} }; + +/* XXX: If the dicts stay, Context might need to become a GC type */ + static PyTypeObject PyDecimal_DecimalContextType = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ @@ -3954,6 +4120,7 @@ return ctx; } + static PyObject * module_setcontext(PyObject *self, PyObject *args, PyObject *kwds) { @@ -3985,6 +4152,7 @@ else Py_RETURN_NONE; } + static PyMethodDef module_methods[] = { {"getcontext", (PyCFunction)module_getcontext, METH_NOARGS}, {"setcontext", (PyCFunction)module_setcontext, METH_VARARGS | METH_KEYWORDS}, @@ -4136,3 +4304,5 @@ return; } + +/* Yay! */ Modified: sandbox/trunk/decimal-c/decimal.py ============================================================================== --- sandbox/trunk/decimal-c/decimal.py (original) +++ sandbox/trunk/decimal-c/decimal.py Sat May 27 17:38:57 2006 @@ -1,119 +1,3 @@ -# Copyright (c) 2004 Python Software Foundation. -# All rights reserved. - -# Written by Eric Price -# and Facundo Batista -# and Raymond Hettinger -# and Aahz -# and Tim Peters - -# This module is currently Py2.3 compatible and should be kept that way -# unless a major compelling advantage arises. IOW, 2.3 compatibility is -# strongly preferred, but not guaranteed. - -# Also, this module should be kept in sync with the latest updates of -# the IBM specification as it evolves. Those updates will be treated -# as bug fixes (deviation from the spec is a compatibility, usability -# bug) and will be backported. At this point the spec is stabilizing -# and the updates are becoming fewer, smaller, and less significant. - -""" -This is a Py2.3 implementation of decimal floating point arithmetic based on -the General Decimal Arithmetic Specification: - - www2.hursley.ibm.com/decimal/decarith.html - -and IEEE standard 854-1987: - - www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html - -Decimal floating point has finite precision with arbitrarily large bounds. - -The purpose of the module is to support arithmetic using familiar -"schoolhouse" rules and to avoid the some of tricky representation -issues associated with binary floating point. The package is especially -useful for financial applications or for contexts where users have -expectations that are at odds with binary floating point (for instance, -in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead -of the expected Decimal("0.00") returned by decimal floating point). - -Here are some examples of using the decimal module: - ->>> from decimal import * ->>> setcontext(ExtendedContext) ->>> Decimal(0) -Decimal("0") ->>> Decimal("1") -Decimal("1") ->>> Decimal("-.0123") -Decimal("-0.0123") ->>> Decimal(123456) -Decimal("123456") ->>> Decimal("123.45e12345678901234567890") -Decimal("1.2345E+12345678901234567892") ->>> Decimal("1.33") + Decimal("1.27") -Decimal("2.60") ->>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41") -Decimal("-2.20") ->>> dig = Decimal(1) ->>> print dig / Decimal(3) -0.333333333 ->>> getcontext().prec = 18 ->>> print dig / Decimal(3) -0.333333333333333333 ->>> print dig.sqrt() -1 ->>> print Decimal(3).sqrt() -1.73205080756887729 ->>> print Decimal(3) ** 123 -4.85192780976896427E+58 ->>> inf = Decimal(1) / Decimal(0) ->>> print inf -Infinity ->>> neginf = Decimal(-1) / Decimal(0) ->>> print neginf --Infinity ->>> print neginf + inf -NaN ->>> print neginf * inf --Infinity ->>> print dig / 0 -Infinity ->>> getcontext().traps[DivisionByZero] = 1 ->>> print dig / 0 -Traceback (most recent call last): - ... - ... - ... -DivisionByZero: x / 0 ->>> c = Context() ->>> c.traps[InvalidOperation] = 0 ->>> print c.flags[InvalidOperation] -0 ->>> c.divide(Decimal(0), Decimal(0)) -Decimal("NaN") ->>> c.traps[InvalidOperation] = 1 ->>> print c.flags[InvalidOperation] -1 ->>> c.flags[InvalidOperation] = 0 ->>> print c.flags[InvalidOperation] -0 ->>> print c.divide(Decimal(0), Decimal(0)) -Traceback (most recent call last): - ... - ... - ... -InvalidOperation: 0 / 0 ->>> print c.flags[InvalidOperation] -1 ->>> c.flags[InvalidOperation] = 0 ->>> c.traps[InvalidOperation] = 0 ->>> print c.divide(Decimal(0), Decimal(0)) -NaN ->>> print c.flags[InvalidOperation] -1 ->>> -""" __all__ = [ # Two major classes @@ -136,14 +20,7 @@ import copy as _copy -# #Rounding -# ROUND_DOWN = 'ROUND_DOWN' -# ROUND_HALF_UP = 'ROUND_HALF_UP' -# ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' -# ROUND_CEILING = 'ROUND_CEILING' -# ROUND_FLOOR = 'ROUND_FLOOR' -# ROUND_UP = 'ROUND_UP' -# ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' +import _decimal # #Rounding decision (not part of the public API) # NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY @@ -384,89 +261,14 @@ ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_FLOOR, \ ROUND_CEILING, ALWAYS_ROUND, NEVER_ROUND -##### Context Functions ####################################### -# The getcontext() and setcontext() function manage access to a thread-local -# current context. Py2.4 offers direct support for thread locals. If that -# is not available, use threading.currentThread() which is slower but will -# work for older Pythons. If threads are not part of the build, create a -# mock threading object with threading.local() returning the module namespace. - -#try: -# import threading -#except ImportError: -# # Python was compiled without threads; create a mock object instead -# import sys -# class MockThreading: -# def local(self, sys=sys): -# return sys.modules[__name__] -# threading = MockThreading() -# del sys, MockThreading -# -#try: -# threading.local -# -#except AttributeError: -# -# #To fix reloading, force it to create a new context -# #Old contexts have different exceptions in their dicts, making problems. -# if hasattr(threading.currentThread(), '__decimal_context__'): -# del threading.currentThread().__decimal_context__ -# -# def setcontext(context): -# """Set this thread's context to context.""" -# if context in (DefaultContext, BasicContext, ExtendedContext): -# context = context.copy() -# context.clear_flags() -# threading.currentThread().__decimal_context__ = context -# -# def getcontext(): -# """Returns this thread's context. -# -# If this thread does not yet have a context, returns -# a new context and sets this thread's context. -# New contexts are copies of DefaultContext. -# """ -# try: -# return threading.currentThread().__decimal_context__ -# except AttributeError: -# context = Context() -# threading.currentThread().__decimal_context__ = context -# return context -# -#else: -# -# local = threading.local() -# if hasattr(local, '__decimal_context__'): -# del local.__decimal_context__ -# -# def getcontext(_local=local): -# """Returns this thread's context. -# -# If this thread does not yet have a context, returns -# a new context and sets this thread's context. -# New contexts are copies of DefaultContext. -# """ -# try: -# return _local.__decimal_context__ -# except AttributeError: -# context = Context() -# _local.__decimal_context__ = context -# return context -# -# def setcontext(context, _local=local): -# """Set this thread's context to context.""" -# if context in (DefaultContext, BasicContext, ExtendedContext): -# context = context.copy() -# context.clear_flags() -# _local.__decimal_context__ = context -# -# del threading, local # Don't contaminate the namespace -# +# ##### Useful Constants (internal use only) #################### -##### Decimal class ########################################### +from _decimal import Inf, negInf, NaN -import _decimal +Infsign = (Inf, negInf) + +##### Decimal class ########################################### getcontext = _decimal.getcontext setcontext = _decimal.setcontext @@ -474,150 +276,13 @@ class Decimal(_decimal.Decimal): """Floating point class for decimal arithmetic.""" - # Generally, the value of the Decimal instance is given by - # (-1)**_sign * _int * 10**_exp - # Special values are signified by _is_special == True - - # HACK: to get support for converting WorkRep instances + # to get support for converting WorkRep instances def __new__(cls, value="0", context=None): if isinstance(value, _WorkRep): value = (value.sign, tuple(map(int, str(value.int))), int(value.exp)) return _decimal.Decimal.__new__(cls, value, context) - -# # We're immutable, so use __new__ not __init__ -# def __new__(cls, value="0", context=None): -# """Create a decimal point instance. -# -# >>> Decimal('3.14') # string input -# Decimal("3.14") -# >>> Decimal((0, (3, 1, 4), -2)) # tuple input (sign, digit_tuple, exponent) -# Decimal("3.14") -# >>> Decimal(314) # int or long -# Decimal("314") -# >>> Decimal(Decimal(314)) # another decimal instance -# Decimal("314") -# """ -# -# self = _decimal.Decimal.__new__(cls) -# self._is_special = False -# -# # From an internal working value -# if isinstance(value, _WorkRep): -# self._sign = value.sign -# self._int = tuple(map(int, str(value.int))) -# self._exp = int(value.exp) -# return self -# -# # From another decimal -# if isinstance(value, Decimal): -# self._exp = value._exp -# self._sign = value._sign -# self._int = value._int -# self._is_special = value._is_special -# return self -# -# # From an integer -# if isinstance(value, (int,long)): -# if value >= 0: -# self._sign = 0 -# else: -# self._sign = 1 -# self._exp = 0 -# self._int = tuple(map(int, str(abs(value)))) -# return self -# -# # tuple/list conversion (possibly from as_tuple()) -# if isinstance(value, (list,tuple)): -# if len(value) != 3: -# raise ValueError, 'Invalid arguments' -# if value[0] not in (0,1): -# raise ValueError, 'Invalid sign' -# for digit in value[1]: -# if not isinstance(digit, (int,long)) or digit < 0: -# raise ValueError, "The second value in the tuple must be composed of non negative integer elements." -# -# self._sign = value[0] -# self._int = tuple(value[1]) -# if value[2] in ('F','n','N'): -# self._exp = value[2] -# self._is_special = True -# else: -# self._exp = int(value[2]) -# return self -# -# if isinstance(value, float): -# raise TypeError("Cannot convert float to Decimal. " + -# "First convert the float to a string") -# -# # Other argument types may require the context during interpretation -# if context is None: -# context = getcontext() -# -# # From a string -# # REs insist on real strings, so we can too. -# if isinstance(value, basestring): -# if _isinfinity(value): -# self._exp = 'F' -# self._int = (0,) -# self._is_special = True -# if _isinfinity(value) == 1: -# self._sign = 0 -# else: -# self._sign = 1 -# return self -# if _isnan(value): -# sig, sign, diag = _isnan(value) -# self._is_special = True -# if len(diag) > context.prec: #Diagnostic info too long -# self._sign, self._int, self._exp = \ -# context._raise_error(ConversionSyntax) -# return self -# if sig == 1: -# self._exp = 'n' #qNaN -# else: #sig == 2 -# self._exp = 'N' #sNaN -# self._sign = sign -# self._int = tuple(map(int, diag)) #Diagnostic info -# return self -# try: -# self._sign, self._int, self._exp = _string2exact(value) -# except ValueError: -# self._is_special = True -# self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) -# return self -# -# raise TypeError("Cannot convert %r to Decimal" % value) - -# def _isnan(self): -# """Returns whether the number is not actually one. - -# 0 if a number -# 1 if NaN -# 2 if sNaN -# """ -# if self._is_special: -# exp = self._exp -# if exp == 'n': -# return 1 -# elif exp == 'N': -# return 2 -# return 0 - -# def _isinfinity(self): -# """Returns whether the number is infinite - -# 0 if finite or not a number -# 1 if +INF -# -1 if -INF -# """ -# if self._exp == 'F': -# if self._sign: -# return -1 -# return 1 -# return 0 - def _isnan(self): if self._sign in (4, 5): return 1 if self._sign in (6, 7): return 2 @@ -658,198 +323,188 @@ return other return 0 - def __nonzero__(self): - """Is the number non-zero? - - 0 if self == 0 - 1 if self != 0 - """ - if self._is_special: - return 1 - return sum(self._int) != 0 - - 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) - if ans: - return 1 # Comparison involving NaN's always reports self > other - - # INF = INF - return cmp(self._isinfinity(), other._isinfinity()) - - if not self and not other: - return 0 #If both 0, sign comparison isn't certain. - - #If different signs, neg one is less - if other._sign < self._sign: - return -1 - if self._sign < other._sign: - return 1 - - self_adjusted = self.adjusted() - other_adjusted = other.adjusted() - if self_adjusted == other_adjusted and \ - self._int + (0,)*(self._exp - other._exp) == \ - other._int + (0,)*(other._exp - self._exp): - return 0 #equal, except in precision. ([0]*(-x) = []) - elif self_adjusted > other_adjusted and self._int[0] != 0: - return (-1)**self._sign - elif self_adjusted < other_adjusted and other._int[0] != 0: - return -((-1)**self._sign) - - # Need to round, so make sure we have a valid context - if context is None: - context = getcontext() - - context = context._shallow_copy() - rounding = context._set_rounding(ROUND_UP) #round away from 0 - - flags = context._ignore_all_flags() - res = self.__sub__(other, context=context) - - context._regard_flags(*flags) - - context.rounding = rounding - - if not res: - return 0 - elif res._sign: - return -1 - return 1 - - def __eq__(self, other): - if not isinstance(other, (Decimal, int, long)): - return NotImplemented - return self.__cmp__(other) == 0 - - def __ne__(self, other): - if not isinstance(other, (Decimal, int, long)): - return NotImplemented - return self.__cmp__(other) != 0 - - def compare(self, other, context=None): - """Compares one to another. - - -1 => a < b - 0 => a = b - 1 => a > b - NaN => one is NaN - 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): - ans = self._check_nans(other, context) - if ans: - return ans - - return Decimal(self.__cmp__(other, context)) - - def __hash__(self): - """x.__hash__() <==> hash(x)""" - # Decimal integers must hash the same as the ints - # Non-integer decimals are normalized and hashed as strings - # Normalization assures that hash(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) - assert self.__nonzero__() # '-0' handled by integer case - return hash(str(self.normalize())) - - def as_tuple(self): - """Represents the number as a triple tuple. - - To show the internals exactly as they are. - """ - return (self._sign, self._int, self._exp) - - def __repr__(self): - """Represents the number as an instance of Decimal.""" - # Invariant: eval(repr(d)) == d - return 'Decimal("%s")' % str(self) - - def __neg__(self, context=None): - """Returns a copy with the sign switched. - - Rounds, if it has reason. - """ - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans +# 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) +# if ans: +# return 1 # Comparison involving NaN's always reports self > other + +# # INF = INF +# return cmp(self._isinfinity(), other._isinfinity()) + +# if not self and not other: +# return 0 #If both 0, sign comparison isn't certain. + +# #If different signs, neg one is less +# if other._sign < self._sign: +# return -1 +# if self._sign < other._sign: +# return 1 - if not self: - # -Decimal('0') is Decimal('0'), not Decimal('-0') - sign = 0 - elif self._sign: - sign = 0 - else: - sign = 1 +# self_adjusted = self.adjusted() +# other_adjusted = other.adjusted() +# if self_adjusted == other_adjusted and \ +# self._int + (0,)*(self._exp - other._exp) == \ +# other._int + (0,)*(other._exp - self._exp): +# return 0 #equal, except in precision. ([0]*(-x) = []) +# elif self_adjusted > other_adjusted and self._int[0] != 0: +# return (-1)**self._sign +# elif self_adjusted < other_adjusted and other._int[0] != 0: +# return -((-1)**self._sign) + +# # Need to round, so make sure we have a valid context +# if context is None: +# context = getcontext() + +# context = context._shallow_copy() +# rounding = context._set_rounding(ROUND_UP) #round away from 0 + +# flags = context._ignore_all_flags() +# res = self.__sub__(other, context=context) + +# context._regard_flags(*flags) + +# context.rounding = rounding + +# if not res: +# return 0 +# elif res._sign: +# return -1 +# return 1 + +# def __eq__(self, other): +# if not isinstance(other, (Decimal, int, long)): +# return NotImplemented +# return self.__cmp__(other) == 0 + +# def __ne__(self, other): +# if not isinstance(other, (Decimal, int, long)): +# return NotImplemented +# return self.__cmp__(other) != 0 + +# def compare(self, other, context=None): +# """Compares one to another. + +# -1 => a < b +# 0 => a = b +# 1 => a > b +# NaN => one is NaN +# 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): +# ans = self._check_nans(other, context) +# if ans: +# return ans + +# return Decimal(self.__cmp__(other, context)) + +# def __hash__(self): +# """x.__hash__() <==> hash(x)""" +# # Decimal integers must hash the same as the ints +# # Non-integer decimals are normalized and hashed as strings +# # Normalization assures that hash(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) +# assert self.__nonzero__() # '-0' handled by integer case +# return hash(str(self.normalize())) - if context is None: - context = getcontext() - if context._rounding_decision == ALWAYS_ROUND: - return Decimal((sign, self._int, self._exp))._fix(context) - return Decimal( (sign, self._int, self._exp)) +# def as_tuple(self): +# """Represents the number as a triple tuple. - def __pos__(self, context=None): - """Returns a copy, unless it is a sNaN. +# To show the internals exactly as they are. +# """ +# return (self._sign, self._int, self._exp) - Rounds the number (if more then precision digits) - """ - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans +# def __repr__(self): +# """Represents the number as an instance of Decimal.""" +# # Invariant: eval(repr(d)) == d +# return 'Decimal("%s")' % str(self) - sign = self._sign - if not self: - # + (-0) = 0 - sign = 0 +# def __neg__(self, context=None): +# """Returns a copy with the sign switched. - if context is None: - context = getcontext() +# Rounds, if it has reason. +# """ +# if self._is_special: +# ans = self._check_nans(context=context) +# if ans: +# return ans + +# if not self: +# # -Decimal('0') is Decimal('0'), not Decimal('-0') +# sign = 0 +# elif self._sign: +# sign = 0 +# else: +# sign = 1 + +# if context is None: +# context = getcontext() +# if context._rounding_decision == ALWAYS_ROUND: +# return Decimal((sign, self._int, self._exp))._fix(context) +# return Decimal( (sign, self._int, self._exp)) - if context._rounding_decision == ALWAYS_ROUND: - ans = self._fix(context) - else: - ans = Decimal(self) - ans._sign = sign - return ans +# def __pos__(self, context=None): +# """Returns a copy, unless it is a sNaN. - def __abs__(self, round=1, context=None): - """Returns the absolute value of self. +# Rounds the number (if more then precision digits) +# """ +# if self._is_special: +# ans = self._check_nans(context=context) +# if ans: +# return ans + +# sign = self._sign +# if not self: +# # + (-0) = 0 +# sign = 0 + +# if context is None: +# context = getcontext() + +# if context._rounding_decision == ALWAYS_ROUND: +# ans = self._fix(context) +# else: +# ans = Decimal(self) +# ans._sign = sign +# return ans - If the second argument is 0, do not round. - """ - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans +# def __abs__(self, round=1, context=None): +# """Returns the absolute value of self. - if not round: - if context is None: - context = getcontext() - context = context._shallow_copy() - context._set_rounding_decision(NEVER_ROUND) - - if self._sign: - ans = self.__neg__(context=context) - else: - ans = self.__pos__(context=context) +# If the second argument is 0, do not round. +# """ +# if self._is_special: +# ans = self._check_nans(context=context) +# if ans: +# return ans + +# if not round: +# if context is None: +# context = getcontext() +# context = context._shallow_copy() +# context._set_rounding_decision(NEVER_ROUND) + +# if self._sign: +# ans = self.__neg__(context=context) +# else: +# ans = self.__pos__(context=context) - return ans +# return ans def __add__(self, other, context=None): """Returns self + other. @@ -1160,7 +815,7 @@ #If we're dividing into ints, and self < other, stop. #self.__abs__(0) does not round. - if divmod and (self.__abs__(0, context) < other.__abs__(0, context)): + if divmod and (self.abs__(0, context) < other.abs__(0, context)): if divmod == 1 or divmod == 3: exp = min(self._exp, other._exp) @@ -1343,7 +998,7 @@ decrease = not side._iseven() rounding = context._set_rounding_decision(NEVER_ROUND) - side = side.__abs__(context=context) + side = side.abs__(-1, context) context._set_rounding_decision(rounding) s1, s2 = r._sign, comparison._sign @@ -1375,33 +1030,33 @@ return other return other.__floordiv__(self, context=context) - def __float__(self): - """Float representation.""" - return float(str(self)) +# def __float__(self): +# """Float representation.""" +# return float(str(self)) - def __int__(self): - """Converts self to an int, truncating if necessary.""" - if self._is_special: - if self._isnan(): - context = getcontext() - return context._raise_error(InvalidContext) - elif self._isinfinity(): - raise OverflowError, "Cannot convert infinity to long" - if self._exp >= 0: - s = ''.join(map(str, self._int)) + '0'*self._exp - else: - s = ''.join(map(str, self._int))[:self._exp] - if s == '': - s = '0' - sign = '-'*self._sign - return int(sign + s) +# def __int__(self): +# """Converts self to an int, truncating if necessary.""" +# if self._is_special: +# if self._isnan(): +# context = getcontext() +# return context._raise_error(InvalidContext) +# elif self._isinfinity(): +# raise OverflowError, "Cannot convert infinity to long" +# if self._exp >= 0: +# s = ''.join(map(str, self._int)) + '0'*self._exp +# else: +# s = ''.join(map(str, self._int))[:self._exp] +# if s == '': +# s = '0' +# sign = '-'*self._sign +# return int(sign + s) - def __long__(self): - """Converts to a long. +# def __long__(self): +# """Converts to a long. - Equivalent to long(int(self)) - """ - return long(self.__int__()) +# Equivalent to long(int(self)) +# """ +# return long(self.__int__()) def _fix(self, context): """Round if it is necessary to keep self within prec precision. @@ -1419,7 +1074,7 @@ prec = context.prec ans = self._fixexponents(context) if len(ans._int) > prec: - ans = ans._round(prec, context=context) + ans = ans._round(prec, -1, context) ans = ans._fixexponents(context) return ans @@ -1466,156 +1121,156 @@ return context._raise_error(Overflow, 'above Emax', ans._sign) return ans - def _round(self, prec=None, rounding=None, context=None): - """Returns a rounded version of self. - - You can specify the precision or rounding method. Otherwise, the - context determines it. - """ - - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans - - if self._isinfinity(): - return Decimal(self) - - if context is None: - context = getcontext() - - if rounding is None: - rounding = context.rounding - if prec is None: - prec = context.prec - - if not self: - if prec <= 0: - dig = (0,) - exp = len(self._int) - prec + self._exp - else: - dig = (0,) * prec - exp = len(self._int) + self._exp - prec - ans = Decimal((self._sign, dig, exp)) - context._raise_error(Rounded) - return ans - - if prec == 0: - temp = Decimal(self) - temp._int = (0,)+temp._int - prec = 1 - elif prec < 0: - exp = self._exp + len(self._int) - prec - 1 - temp = Decimal( (self._sign, (0, 1), exp)) - prec = 1 - else: - temp = Decimal(self) +# def _round(self, prec=None, rounding=-1, context=None): +# """Returns a rounded version of self. - numdigits = len(temp._int) - if prec == numdigits: - return temp - - # See if we need to extend precision - expdiff = prec - numdigits - if expdiff > 0: - tmp = list(temp._int) - tmp.extend([0] * expdiff) - ans = Decimal( (temp._sign, tmp, temp._exp - expdiff)) - return ans - - #OK, but maybe all the lost digits are 0. - lostdigits = self._int[expdiff:] - if lostdigits == (0,) * len(lostdigits): - ans = Decimal( (temp._sign, temp._int[:prec], temp._exp - expdiff)) - #Rounded, but not Inexact - context._raise_error(Rounded) - return ans - - # Okay, let's round and lose data - - this_function = getattr(temp, self._pick_rounding_function[rounding]) - #Now we've got the rounding function - - if prec != context.prec: - context = context._shallow_copy() - context.prec = prec - ans = this_function(prec, expdiff, context) - context._raise_error(Rounded) - context._raise_error(Inexact, 'Changed in rounding') - - return ans - - _pick_rounding_function = {} - - def _round_down(self, prec, expdiff, context): - """Also known as round-towards-0, truncate.""" - return Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) - - def _round_half_up(self, prec, expdiff, context, tmp = None): - """Rounds 5 up (away from 0)""" - - if tmp is None: - tmp = Decimal( (self._sign,self._int[:prec], self._exp - expdiff)) - if self._int[prec] >= 5: - tmp = tmp._increment(round=0, context=context) - if len(tmp._int) > prec: - return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) - return tmp - - def _round_half_even(self, prec, expdiff, context): - """Round 5 to even, rest to nearest.""" - - tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) - half = (self._int[prec] == 5) - if half: - for digit in self._int[prec+1:]: - if digit != 0: - half = 0 - break - if half: - if self._int[prec-1] & 1 == 0: - return tmp - return self._round_half_up(prec, expdiff, context, tmp) - - def _round_half_down(self, prec, expdiff, context): - """Round 5 down""" - - tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) - half = (self._int[prec] == 5) - if half: - for digit in self._int[prec+1:]: - if digit != 0: - half = 0 - break - if half: - return tmp - return self._round_half_up(prec, expdiff, context, tmp) - - def _round_up(self, prec, expdiff, context): - """Rounds away from 0.""" - tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) - for digit in self._int[prec:]: - if digit != 0: - tmp = tmp._increment(round=1, context=context) - if len(tmp._int) > prec: - return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) - else: - return tmp - return tmp - - def _round_ceiling(self, prec, expdiff, context): - """Rounds up (not away from 0 if negative.)""" - if self._sign: - return self._round_down(prec, expdiff, context) - else: - return self._round_up(prec, expdiff, context) +# You can specify the precision or rounding method. Otherwise, the +# context determines it. +# """ - def _round_floor(self, prec, expdiff, context): - """Rounds down (not towards 0 if negative)""" - if not self._sign: - return self._round_down(prec, expdiff, context) - else: - return self._round_up(prec, expdiff, context) +# if self._is_special: +# ans = self._check_nans(context=context) +# if ans: +# return ans + +# if self._isinfinity(): +# return Decimal(self) + +# if context is None: +# context = getcontext() + +# if rounding is None: +# rounding = context.rounding +# if prec is None: +# prec = context.prec + +# if not self: +# if prec <= 0: +# dig = (0,) +# exp = len(self._int) - prec + self._exp +# else: +# dig = (0,) * prec +# exp = len(self._int) + self._exp - prec +# ans = Decimal((self._sign, dig, exp)) +# context._raise_error(Rounded) +# return ans + +# if prec == 0: +# temp = Decimal(self) +# temp._int = (0,)+temp._int +# prec = 1 +# elif prec < 0: +# exp = self._exp + len(self._int) - prec - 1 +# temp = Decimal( (self._sign, (0, 1), exp)) +# prec = 1 +# else: +# temp = Decimal(self) + +# numdigits = len(temp._int) +# if prec == numdigits: +# return temp + +# # See if we need to extend precision +# expdiff = prec - numdigits +# if expdiff > 0: +# tmp = list(temp._int) +# tmp.extend([0] * expdiff) +# ans = Decimal( (temp._sign, tmp, temp._exp - expdiff)) +# return ans + +# #OK, but maybe all the lost digits are 0. +# lostdigits = self._int[expdiff:] +# if lostdigits == (0,) * len(lostdigits): +# ans = Decimal( (temp._sign, temp._int[:prec], temp._exp - expdiff)) +# #Rounded, but not Inexact +# context._raise_error(Rounded) +# return ans + +# # Okay, let's round and lose data + +# this_function = getattr(temp, self._pick_rounding_function[rounding]) +# #Now we've got the rounding function + +# if prec != context.prec: +# context = context._shallow_copy() +# context.prec = prec +# ans = this_function(prec, expdiff, context) +# context._raise_error(Rounded) +# context._raise_error(Inexact, 'Changed in rounding') + +# return ans + +# _pick_rounding_function = {} + +# def _round_down(self, prec, expdiff, context): +# """Also known as round-towards-0, truncate.""" +# return Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) + +# def _round_half_up(self, prec, expdiff, context, tmp = None): +# """Rounds 5 up (away from 0)""" + +# if tmp is None: +# tmp = Decimal( (self._sign,self._int[:prec], self._exp - expdiff)) +# if self._int[prec] >= 5: +# tmp = tmp._increment(round=0, context=context) +# if len(tmp._int) > prec: +# return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) +# return tmp + +# def _round_half_even(self, prec, expdiff, context): +# """Round 5 to even, rest to nearest.""" + +# tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) +# half = (self._int[prec] == 5) +# if half: +# for digit in self._int[prec+1:]: +# if digit != 0: +# half = 0 +# break +# if half: +# if self._int[prec-1] & 1 == 0: +# return tmp +# return self._round_half_up(prec, expdiff, context, tmp) + +# def _round_half_down(self, prec, expdiff, context): +# """Round 5 down""" + +# tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff)) +# half = (self._int[prec] == 5) +# if half: +# for digit in self._int[prec+1:]: +# if digit != 0: +# half = 0 +# break +# if half: +# return tmp +# return self._round_half_up(prec, expdiff, context, tmp) + +# def _round_up(self, prec, expdiff, context): +# """Rounds away from 0.""" +# tmp = Decimal( (self._sign, self._int[:prec], self._exp - expdiff) ) +# for digit in self._int[prec:]: +# if digit != 0: +# tmp = tmp._increment(round=1, context=context) +# if len(tmp._int) > prec: +# return Decimal( (tmp._sign, tmp._int[:-1], tmp._exp + 1)) +# else: +# return tmp +# return tmp + +# def _round_ceiling(self, prec, expdiff, context): +# """Rounds up (not away from 0 if negative.)""" +# if self._sign: +# return self._round_down(prec, expdiff, context) +# else: +# return self._round_up(prec, expdiff, context) + +# def _round_floor(self, prec, expdiff, context): +# """Rounds down (not towards 0 if negative)""" +# if not self._sign: +# return self._round_down(prec, expdiff, context) +# else: +# return self._round_up(prec, expdiff, context) def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) @@ -1715,60 +1370,60 @@ return other return other.__pow__(self, context=context) - def normalize(self, context=None): - """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" - - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans - - dup = self._fix(context) - if dup._isinfinity(): - return dup - - if not dup: - return Decimal( (dup._sign, (0,), 0) ) - end = len(dup._int) - exp = dup._exp - while dup._int[end-1] == 0: - exp += 1 - end -= 1 - return Decimal( (dup._sign, dup._int[:end], exp) ) +# def normalize(self, context=None): +# """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" +# if self._is_special: +# ans = self._check_nans(context=context) +# if ans: +# return ans + +# dup = self._fix(context) +# if dup._isinfinity(): +# return dup + +# if not dup: +# return Decimal( (dup._sign, (0,), 0) ) +# end = len(dup._int) +# exp = dup._exp +# while dup._int[end-1] == 0: +# exp += 1 +# end -= 1 +# return Decimal( (dup._sign, dup._int[:end], exp) ) - def quantize(self, exp, rounding=None, context=None, watchexp=1): - """Quantize self so its exponent is the same as that of exp. - Similar to self._rescale(exp._exp) but with error checking. - """ - if self._is_special or exp._is_special: - ans = self._check_nans(exp, context) - if ans: - return ans +# def quantize(self, exp, rounding=-1, context=None, watchexp=1): +# """Quantize self so its exponent is the same as that of exp. - if exp._isinfinity() or self._isinfinity(): - if exp._isinfinity() and self._isinfinity(): - return self #if both are inf, it is OK - if context is None: - context = getcontext() - return context._raise_error(InvalidOperation, - 'quantize with one INF') - return self._rescale(exp._exp, rounding, context, watchexp) +# Similar to self._rescale(exp._exp) but with error checking. +# """ +# if self._is_special or exp._is_special: +# ans = self._check_nans(exp, context) +# if ans: +# return ans + +# if exp._isinfinity() or self._isinfinity(): +# if exp._isinfinity() and self._isinfinity(): +# return self #if both are inf, it is OK +# if context is None: +# context = getcontext() +# return context._raise_error(InvalidOperation, +# 'quantize with one INF') +# return self._rescale(exp._exp, rounding, context, watchexp) - def same_quantum(self, other): - """Test whether self and other have the same exponent. +# def same_quantum(self, other): +# """Test whether self and other have the same exponent. - same as self._exp == other._exp, except NaN == sNaN - """ - if self._is_special or other._is_special: - if self._isnan() or other._isnan(): - return self._isnan() and other._isnan() and True - if self._isinfinity() or other._isinfinity(): - return self._isinfinity() and other._isinfinity() and True - return self._exp == other._exp +# same as self._exp == other._exp, except NaN == sNaN +# """ +# if self._is_special or other._is_special: +# if self._isnan() or other._isnan(): +# return self._isnan() and other._isnan() and True +# if self._isinfinity() or other._isinfinity(): +# return self._isinfinity() and other._isinfinity() and True +# return self._exp == other._exp - def _rescale(self, exp, rounding=None, context=None, watchexp=1): + def _rescale(self, exp, rounding=-1, context=None, watchexp=1): """Rescales so that the exponent is exp. exp = exp to scale to (an integer) @@ -1810,7 +1465,7 @@ tmp._exp = -digits + tmp._exp tmp._int = (0,1) digits = 1 - tmp = tmp._round(digits, rounding, context=context) + tmp = tmp._round(digits, rounding, context) if tmp._int[0] == 0 and len(tmp._int) > 1: tmp._int = tmp._int[1:] @@ -1823,20 +1478,20 @@ return context._raise_error(InvalidOperation, 'rescale(a, INF)') return tmp - def to_integral(self, rounding=None, context=None): - """Rounds to the nearest integer, without raising inexact, rounded.""" - if self._is_special: - ans = self._check_nans(context=context) - if ans: - return ans - if self._exp >= 0: - return self - if context is None: - context = getcontext() - flags = context._ignore_flags(Rounded, Inexact) - ans = self._rescale(0, rounding, context=context) - context._regard_flags(flags) - return ans + #def to_integral(self, rounding=None, context=None): + # """Rounds to the nearest integer, without raising inexact, rounded.""" + # if self._is_special: + # ans = self._check_nans(context=context) + # if ans: + # return ans + # if self._exp >= 0: + # return self + # if context is None: + # context = getcontext() + # flags = context._ignore_flags(Rounded, Inexact) + # ans = self._rescale(0, rounding, context=context) + # context._regard_flags(flags) + # return ans def sqrt(self, context=None): """Return the square root of self. @@ -2071,40 +1726,28 @@ return 1 return self._int[-1+self._exp] & 1 == 0 - def adjusted(self): - """Return the adjusted exponent of self""" - try: - return self._exp + len(self._int) - 1 - #If NaN or Infinity, self._exp is string - except TypeError: - return 0 +# def adjusted(self): +# """Return the adjusted exponent of self""" +# try: +# return self._exp + len(self._int) - 1 +# #If NaN or Infinity, self._exp is string +# except TypeError: +# return 0 - # support for pickling, copy, and deepcopy - def __reduce__(self): - return (self.__class__, (str(self),)) - - def __copy__(self): - if type(self) == Decimal: - return self # I'm immutable; therefore I am my own clone - return self.__class__(str(self)) - - def __deepcopy__(self, memo): - if type(self) == Decimal: - return self # My components are also immutable - return self.__class__(str(self)) ##### Context class ########################################### +from _decimal import Context -# get rounding method function: -rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')] -for name in rounding_functions: - #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. - globalname = name[1:].upper() - val = globals()[globalname] - Decimal._pick_rounding_function[val] = name +# # get rounding method function: +# rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')] +# for name in rounding_functions: +# #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. +# globalname = name[1:].upper() +# val = globals()[globalname] +# Decimal._pick_rounding_function[val] = name -del name, val, globalname, rounding_functions +# del name, val, globalname, rounding_functions class ContextManager(object): """Helper class to simplify Context management. @@ -2130,504 +1773,6 @@ def __exit__(self, t, v, tb): setcontext(self.saved_context) -class Context(_decimal.Context): - """Contains the context for a Decimal instance. - - Contains: - prec - precision (for use in rounding, division, square roots..) - rounding - rounding type. (how you round) - _rounding_decision - ALWAYS_ROUND, NEVER_ROUND -- do you round? - traps - If traps[exception] = 1, then the exception is - raised when it is caused. Otherwise, a value is - substituted in. - flags - When an exception is caused, flags[exception] is incremented. - (Whether or not the trap_enabler is set) - Should be reset by user of Decimal instance. - Emin - Minimum exponent - Emax - Maximum exponent - capitals - If 1, 1*10^1 is printed as 1E+1. - If 0, printed as 1e1 - _clamp - If 1, change exponents if too high (Default 0) - """ - - def __repr__(self): - """Show the current context.""" - s = [] - s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d' % vars(self)) - s.append('flags=[' + ', '.join([f.__name__ for f, v in self.flags.items() if v]) + ']') - s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') - return ', '.join(s) + ')' - - def create_decimal(self, num='0'): - """Creates a new Decimal instance but using self as context.""" - d = Decimal(num, context=self) - return d._fix(self) - - #Methods - def abs(self, a): - """Returns the absolute value of the operand. - - If the operand is negative, the result is the same as using the minus - operation on the operand. Otherwise, the result is the same as using - the plus operation on the operand. - - >>> ExtendedContext.abs(Decimal('2.1')) - Decimal("2.1") - >>> ExtendedContext.abs(Decimal('-100')) - Decimal("100") - >>> ExtendedContext.abs(Decimal('101.5')) - Decimal("101.5") - >>> ExtendedContext.abs(Decimal('-101.5')) - Decimal("101.5") - """ - return a.__abs__(context=self) - - def add(self, a, b): - """Return the sum of the two operands. - - >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) - Decimal("19.00") - >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) - Decimal("1.02E+4") - """ - return a.__add__(b, context=self) - - def _apply(self, a): - return str(a._fix(self)) - - def compare(self, a, b): - """Compares values numerically. - - If the signs of the operands differ, a value representing each operand - ('-1' if the operand is less than zero, '0' if the operand is zero or - negative zero, or '1' if the operand is greater than zero) is used in - place of that operand for the comparison instead of the actual - operand. - - The comparison is then effected by subtracting the second operand from - the first and then returning a value according to the result of the - subtraction: '-1' if the result is less than zero, '0' if the result is - zero or negative zero, or '1' if the result is greater than zero. - - >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) - Decimal("-1") - >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) - Decimal("0") - >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) - Decimal("0") - >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) - Decimal("1") - >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) - Decimal("1") - >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) - Decimal("-1") - """ - return a.compare(b, context=self) - - def divide(self, a, b): - """Decimal division in a specified context. - - >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) - Decimal("0.333333333") - >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) - Decimal("0.666666667") - >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) - Decimal("2.5") - >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) - Decimal("0.1") - >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) - Decimal("1") - >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) - Decimal("4.00") - >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) - Decimal("1.20") - >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) - Decimal("10") - >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) - Decimal("1000") - >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) - Decimal("1.20E+6") - """ - return a.__div__(b, context=self) - - def divide_int(self, a, b): - """Divides two numbers and returns the integer part of the result. - - >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) - Decimal("0") - >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) - Decimal("3") - >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) - Decimal("3") - """ - return a.__floordiv__(b, context=self) - - def divmod(self, a, b): - return a.__divmod__(b, context=self) - - def max(self, a,b): - """max compares two values numerically and returns the maximum. - - If either operand is a NaN then the general rules apply. - Otherwise, the operands are compared as as though by the compare - operation. If they are numerically equal then the left-hand operand - is chosen as the result. Otherwise the maximum (closer to positive - infinity) of the two operands is chosen as the result. - - >>> ExtendedContext.max(Decimal('3'), Decimal('2')) - Decimal("3") - >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) - Decimal("3") - >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) - Decimal("1") - >>> ExtendedContext.max(Decimal('7'), Decimal('NaN')) - Decimal("7") - """ - return a.max(b, context=self) - - def min(self, a,b): - """min compares two values numerically and returns the minimum. - - If either operand is a NaN then the general rules apply. - Otherwise, the operands are compared as as though by the compare - operation. If they are numerically equal then the left-hand operand - is chosen as the result. Otherwise the minimum (closer to negative - infinity) of the two operands is chosen as the result. - - >>> ExtendedContext.min(Decimal('3'), Decimal('2')) - Decimal("2") - >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) - Decimal("-10") - >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) - Decimal("1.0") - >>> ExtendedContext.min(Decimal('7'), Decimal('NaN')) - Decimal("7") - """ - return a.min(b, context=self) - - def minus(self, a): - """Minus corresponds to unary prefix minus in Python. - - The operation is evaluated using the same rules as subtract; the - operation minus(a) is calculated as subtract('0', a) where the '0' - has the same exponent as the operand. - - >>> ExtendedContext.minus(Decimal('1.3')) - Decimal("-1.3") - >>> ExtendedContext.minus(Decimal('-1.3')) - Decimal("1.3") - """ - return a.__neg__(context=self) - - def multiply(self, a, b): - """multiply multiplies two operands. - - If either operand is a special value then the general rules apply. - Otherwise, the operands are multiplied together ('long multiplication'), - resulting in a number which may be as long as the sum of the lengths - of the two operands. - - >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) - Decimal("3.60") - >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) - Decimal("21") - >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) - Decimal("0.72") - >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) - Decimal("-0.0") - >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) - Decimal("4.28135971E+11") - """ - return a.__mul__(b, context=self) - - def normalize(self, a): - """normalize reduces an operand to its simplest form. - - Essentially a plus operation with all trailing zeros removed from the - result. - - >>> ExtendedContext.normalize(Decimal('2.1')) - Decimal("2.1") - >>> ExtendedContext.normalize(Decimal('-2.0')) - Decimal("-2") - >>> ExtendedContext.normalize(Decimal('1.200')) - Decimal("1.2") - >>> ExtendedContext.normalize(Decimal('-120')) - Decimal("-1.2E+2") - >>> ExtendedContext.normalize(Decimal('120.00')) - Decimal("1.2E+2") - >>> ExtendedContext.normalize(Decimal('0.00')) - Decimal("0") - """ - return a.normalize(context=self) - - def plus(self, a): - """Plus corresponds to unary prefix plus in Python. - - The operation is evaluated using the same rules as add; the - operation plus(a) is calculated as add('0', a) where the '0' - has the same exponent as the operand. - - >>> ExtendedContext.plus(Decimal('1.3')) - Decimal("1.3") - >>> ExtendedContext.plus(Decimal('-1.3')) - Decimal("-1.3") - """ - return a.__pos__(context=self) - - def power(self, a, b, modulo=None): - """Raises a to the power of b, to modulo if given. - - The right-hand operand must be a whole number whose integer part (after - any exponent has been applied) has no more than 9 digits and whose - fractional part (if any) is all zeros before any rounding. The operand - may be positive, negative, or zero; if negative, the absolute value of - the power is used, and the left-hand operand is inverted (divided into - 1) before use. - - If the increased precision needed for the intermediate calculations - exceeds the capabilities of the implementation then an Invalid operation - condition is raised. - - If, when raising to a negative power, an underflow occurs during the - division into 1, the operation is not halted at that point but - continues. - - >>> ExtendedContext.power(Decimal('2'), Decimal('3')) - Decimal("8") - >>> ExtendedContext.power(Decimal('2'), Decimal('-3')) - Decimal("0.125") - >>> ExtendedContext.power(Decimal('1.7'), Decimal('8')) - Decimal("69.7575744") - >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-2')) - Decimal("0") - >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-1')) - Decimal("0") - >>> ExtendedContext.power(Decimal('Infinity'), Decimal('0')) - Decimal("1") - >>> ExtendedContext.power(Decimal('Infinity'), Decimal('1')) - Decimal("Infinity") - >>> ExtendedContext.power(Decimal('Infinity'), Decimal('2')) - Decimal("Infinity") - >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-2')) - Decimal("0") - >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-1')) - Decimal("-0") - >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('0')) - Decimal("1") - >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('1')) - Decimal("-Infinity") - >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('2')) - Decimal("Infinity") - >>> ExtendedContext.power(Decimal('0'), Decimal('0')) - Decimal("NaN") - """ - return a.__pow__(b, modulo, context=self) - - def quantize(self, a, b): - """Returns a value equal to 'a' (rounded) and having the exponent of 'b'. - - The coefficient of the result is derived from that of the left-hand - operand. It may be rounded using the current rounding setting (if the - exponent is being increased), multiplied by a positive power of ten (if - the exponent is being decreased), or is unchanged (if the exponent is - already equal to that of the right-hand operand). - - Unlike other operations, if the length of the coefficient after the - quantize operation would be greater than precision then an Invalid - operation condition is raised. This guarantees that, unless there is an - error condition, the exponent of the result of a quantize is always - equal to that of the right-hand operand. - - Also unlike other operations, quantize will never raise Underflow, even - if the result is subnormal and inexact. - - >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) - Decimal("2.170") - >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) - Decimal("2.17") - >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) - Decimal("2.2") - >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) - Decimal("2") - >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) - Decimal("0E+1") - >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) - Decimal("-Infinity") - >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) - Decimal("NaN") - >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) - Decimal("-0") - >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) - Decimal("-0E+5") - >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) - Decimal("NaN") - >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) - Decimal("NaN") - >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) - Decimal("217.0") - >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) - Decimal("217") - >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) - Decimal("2.2E+2") - >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) - Decimal("2E+2") - """ - return a.quantize(b, context=self) - - def remainder(self, a, b): - """Returns the remainder from integer division. - - The result is the residue of the dividend after the operation of - calculating integer division as described for divide-integer, rounded to - precision digits if necessary. The sign of the result, if non-zero, is - the same as that of the original dividend. - - This operation will fail under the same conditions as integer division - (that is, if integer division on the same two operands would fail, the - remainder cannot be calculated). - - >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) - Decimal("2.1") - >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) - Decimal("1") - >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) - Decimal("-1") - >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) - Decimal("0.2") - >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) - Decimal("0.1") - >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) - Decimal("1.0") - """ - return a.__mod__(b, context=self) - - def remainder_near(self, a, b): - """Returns to be "a - b * n", where n is the integer nearest the exact - value of "x / b" (if two integers are equally near then the even one - is chosen). If the result is equal to 0 then its sign will be the - sign of a. - - This operation will fail under the same conditions as integer division - (that is, if integer division on the same two operands would fail, the - remainder cannot be calculated). - - >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) - Decimal("-0.9") - >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) - Decimal("-2") - >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) - Decimal("1") - >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) - Decimal("-1") - >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) - Decimal("0.2") - >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) - Decimal("0.1") - >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) - Decimal("-0.3") - """ - return a.remainder_near(b, context=self) - - def same_quantum(self, a, b): - """Returns True if the two operands have the same exponent. - - The result is never affected by either the sign or the coefficient of - either operand. - - >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) - False - >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01')) - True - >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1')) - False - >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) - True - """ - return a.same_quantum(b) - - def sqrt(self, a): - """Returns the square root of a non-negative number to context precision. - - If the result must be inexact, it is rounded using the round-half-even - algorithm. - - >>> ExtendedContext.sqrt(Decimal('0')) - Decimal("0") - >>> ExtendedContext.sqrt(Decimal('-0')) - Decimal("-0") - >>> ExtendedContext.sqrt(Decimal('0.39')) - Decimal("0.624499800") - >>> ExtendedContext.sqrt(Decimal('100')) - Decimal("10") - >>> ExtendedContext.sqrt(Decimal('1')) - Decimal("1") - >>> ExtendedContext.sqrt(Decimal('1.0')) - Decimal("1.0") - >>> ExtendedContext.sqrt(Decimal('1.00')) - Decimal("1.0") - >>> ExtendedContext.sqrt(Decimal('7')) - Decimal("2.64575131") - >>> ExtendedContext.sqrt(Decimal('10')) - Decimal("3.16227766") - >>> ExtendedContext.prec - 9 - """ - return a.sqrt(context=self) - - def subtract(self, a, b): - """Return the difference between the two operands. - - >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) - Decimal("0.23") - >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) - Decimal("0.00") - >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) - Decimal("-0.77") - """ - return a.__sub__(b, context=self) - - def to_eng_string(self, a): - """Converts a number to a string, using scientific notation. - - The operation is not affected by the context. - """ - return a.to_eng_string(context=self) - - def to_sci_string(self, a): - """Converts a number to a string, using scientific notation. - - The operation is not affected by the context. - """ - return a.__str__(context=self) - - def to_integral(self, a): - """Rounds to an integer. - - When the operand has a negative exponent, the result is the same - as using the quantize() operation using the given operand as the - left-hand-operand, 1E+0 as the right-hand-operand, and the precision - of the operand as the precision setting, except that no flags will - be set. The rounding mode is taken from the context. - - >>> ExtendedContext.to_integral(Decimal('2.1')) - Decimal("2") - >>> ExtendedContext.to_integral(Decimal('100')) - Decimal("100") - >>> ExtendedContext.to_integral(Decimal('100.0')) - Decimal("100") - >>> ExtendedContext.to_integral(Decimal('101.5')) - Decimal("102") - >>> ExtendedContext.to_integral(Decimal('-101.5')) - Decimal("-102") - >>> ExtendedContext.to_integral(Decimal('10E+5')) - Decimal("1.0E+6") - >>> ExtendedContext.to_integral(Decimal('7.89E+77')) - Decimal("7.89E+77") - >>> ExtendedContext.to_integral(Decimal('-Inf')) - Decimal("-Infinity") - """ - return a.to_integral(context=self) from _decimal import BasicContext, ExtendedContext, \ DefaultContext @@ -2662,7 +1807,6 @@ __str__ = __repr__ - def _normalize(op1, op2, shouldround = 0, prec = 0): """Normalizes op1, op2 to have the same exp and length of coefficient. @@ -2783,125 +1927,3 @@ return (2, sign, num[4:].lstrip('0')) return 0 - -# ##### Setup Specific Contexts ################################ - -# # The default context prototype used by Context() -# # Is mutable, so that new contexts can have different default values - -# DefaultContext = Context( -# prec=28, rounding=ROUND_HALF_EVEN, -# traps=[DivisionByZero, Overflow, InvalidOperation], -# flags=[], -# _rounding_decision=ALWAYS_ROUND, -# Emax=999999999, -# Emin=-999999999, -# capitals=1 -# ) - -# # Pre-made alternate contexts offered by the specification -# # Don't change these; the user should be able to select these -# # contexts and be able to reproduce results from other implementations -# # of the spec. - -# BasicContext = Context( -# prec=9, rounding=ROUND_HALF_UP, -# traps=[DivisionByZero, Overflow, InvalidOperation, Clamped, Underflow], -# flags=[], -# ) - -# ExtendedContext = Context( -# prec=9, rounding=ROUND_HALF_EVEN, -# traps=[], -# flags=[], -# ) - - -# ##### Useful Constants (internal use only) #################### - -from _decimal import Inf, negInf, NaN - -# #Reusable defaults -# Inf = Decimal('Inf') -# negInf = Decimal('-Inf') - -# #Infsign[sign] is infinity w/ that sign -Infsign = (Inf, negInf) - -# NaN = Decimal('NaN') - - - - -# ##### crud for parsing strings ################################# -# import re - -# # There's an optional sign at the start, and an optional exponent -# # at the end. The exponent has an optional sign and at least one -# # digit. In between, must have either at least one digit followed -# # by an optional fraction, or a decimal point followed by at least -# # one digit. Yuck. - -# _parser = re.compile(r""" -# # \s* -# (?P[-+])? -# ( -# (?P\d+) (\. (?P\d*))? -# | -# \. (?P\d+) -# ) -# ([eE](?P[-+]? \d+))? -# # \s* -# $ -# """, re.VERBOSE).match #Uncomment the \s* to allow leading or trailing spaces. - -# del re - -# # return sign, n, p s.t. float string value == -1**sign * n * 10**p exactly - -# def _string2exact(s): -# m = _parser(s) -# if m is None: -# raise ValueError("invalid literal for Decimal: %r" % s) - -# if m.group('sign') == "-": -# sign = 1 -# else: -# sign = 0 - -# exp = m.group('exp') -# if exp is None: -# exp = 0 -# else: -# exp = int(exp) - -# intpart = m.group('int') -# if intpart is None: -# intpart = "" -# fracpart = m.group('onlyfrac') -# else: -# fracpart = m.group('frac') -# if fracpart is None: -# fracpart = "" - -# exp -= len(fracpart) - -# mantissa = intpart + fracpart -# tmp = map(int, mantissa) -# backup = tmp -# while tmp and tmp[0] == 0: -# del tmp[0] - -# # It's a zero -# if not tmp: -# if backup: -# return (sign, tuple(backup), exp) -# return (sign, (0,), exp) -# mantissa = tuple(tmp) - -# return (sign, mantissa, exp) - - -if __name__ == '__main__': - import doctest, sys - doctest.testmod(sys.modules[__name__]) From python-checkins at python.org Sat May 27 17:44:35 2006 From: python-checkins at python.org (jack.diederich) Date: Sat, 27 May 2006 17:44:35 +0200 (CEST) Subject: [Python-checkins] r46473 - python/trunk/Modules/_sre.c Message-ID: <20060527154435.82C941E4006@bag.python.org> Author: jack.diederich Date: Sat May 27 17:44:34 2006 New Revision: 46473 Modified: python/trunk/Modules/_sre.c Log: needforspeed: use PyObject_MALLOC instead of system malloc for small allocations. Use PyMem_MALLOC for larger (1k+) chunks. 1%-2% speedup. Modified: python/trunk/Modules/_sre.c ============================================================================== --- python/trunk/Modules/_sre.c (original) +++ python/trunk/Modules/_sre.c Sat May 27 17:44:34 2006 @@ -254,7 +254,7 @@ data_stack_dealloc(SRE_STATE* state) { if (state->data_stack) { - free(state->data_stack); + PyMem_FREE(state->data_stack); state->data_stack = NULL; } state->data_stack_size = state->data_stack_base = 0; @@ -270,7 +270,7 @@ void* stack; cursize = minsize+minsize/4+1024; TRACE(("allocate/grow stack %d\n", cursize)); - stack = realloc(state->data_stack, cursize); + stack = PyMem_REALLOC(state->data_stack, cursize); if (!stack) { data_stack_dealloc(state); return SRE_ERROR_MEMORY; @@ -1163,7 +1163,7 @@ ctx->pattern[1], ctx->pattern[2])); /* install new repeat context */ - ctx->u.rep = (SRE_REPEAT*) malloc(sizeof(*ctx->u.rep)); + ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep)); ctx->u.rep->count = -1; ctx->u.rep->pattern = ctx->pattern; ctx->u.rep->prev = state->repeat; @@ -1173,7 +1173,7 @@ state->ptr = ctx->ptr; DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]); state->repeat = ctx->u.rep->prev; - free(ctx->u.rep); + PyObject_FREE(ctx->u.rep); if (ret) { RETURN_ON_ERROR(ret); From python-checkins at python.org Sat May 27 17:53:49 2006 From: python-checkins at python.org (bob.ippolito) Date: Sat, 27 May 2006 17:53:49 +0200 (CEST) Subject: [Python-checkins] r46474 - python/trunk/Modules/_struct.c Message-ID: <20060527155349.DF9531E4006@bag.python.org> Author: bob.ippolito Date: Sat May 27 17:53:49 2006 New Revision: 46474 Modified: python/trunk/Modules/_struct.c Log: fix struct regression on 64-bit platforms Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Sat May 27 17:53:49 2006 @@ -318,9 +318,13 @@ { unsigned int x; memcpy((char *)&x, p, sizeof x); - if (x <= LONG_MAX) +#if (SIZEOF_LONG > SIZEOF_INT) + return PyInt_FromLong((long)x); +#else + if (x <= ((unsigned int)LONG_MAX)) return PyInt_FromLong((long)x); return PyLong_FromUnsignedLong((unsigned long)x); +#endif } static PyObject * @@ -477,7 +481,7 @@ if (get_long(v, &x) < 0) return -1; #if (SIZEOF_LONG > SIZEOF_INT) - if (x < INT_MIN || x > INT_MAX) + if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX))) return _range_error(f->format, sizeof(y), 0); #endif y = (int)x; @@ -494,7 +498,7 @@ return _range_error(f->format, sizeof(y), 1); y = (unsigned int)x; #if (SIZEOF_LONG > SIZEOF_INT) - if (x > UINT_MAX) + if (x > ((unsigned long)UINT_MAX)) return _range_error(f->format, sizeof(y), 1); #endif memcpy(p, (char *)&y, sizeof y); @@ -622,7 +626,7 @@ } while (--i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); + x |= -(x & (1L << ((8 * f->size) - 1))); return PyInt_FromLong(x); } @@ -650,7 +654,7 @@ } while (--i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) - x |= -(x & (1L << (8 * f->size - 1))); + x |= -(x & (1L << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); @@ -702,13 +706,14 @@ if (get_long(v, &x) < 0) return -1; i = f->size; - if (i != SIZEOF_LONG && ( - (i == 2 && (x < -32768 || x > 32767)) + if (i != SIZEOF_LONG) { + if ((i == 2) && (x < -32768 || x > 32767)) + return _range_error(f->format, i, 0); #if (SIZEOF_LONG != 4) - || (i == 4) && (x < -2147483648L || x > -2147483647L) + else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) + return _range_error(f->format, i, 0); #endif - )) - return _range_error(f->format, i, 0); + } do { p[--i] = (char)x; x >>= 8; @@ -724,8 +729,12 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; - if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) - return _range_error(f->format, f->size, 1); + if (i != SIZEOF_LONG) { + unsigned long maxint = 1; + maxint <<= (unsigned long)(i * 8); + if (x >= maxint) + return _range_error(f->format, f->size, 1); + } do { p[--i] = (char)x; x >>= 8; @@ -821,7 +830,7 @@ } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); + x |= -(x & (1L << ((8 * f->size) - 1))); return PyInt_FromLong(x); } @@ -849,7 +858,7 @@ } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) - x |= -(x & (1L << (8 * f->size - 1))); + x |= -(x & (1L << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); @@ -901,13 +910,14 @@ if (get_long(v, &x) < 0) return -1; i = f->size; - if (i != SIZEOF_LONG && ( - (i == 2 && (x < -32768 || x > 32767)) + if (i != SIZEOF_LONG) { + if ((i == 2) && (x < -32768 || x > 32767)) + return _range_error(f->format, i, 0); #if (SIZEOF_LONG != 4) - || (i == 4) && (x < -2147483648L || x > -2147483647L) + else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) + return _range_error(f->format, i, 0); #endif - )) - return _range_error(f->format, i, 0); + } do { *p++ = (char)x; x >>= 8; @@ -923,8 +933,12 @@ if (get_ulong(v, &x) < 0) return -1; i = f->size; - if (i != SIZEOF_LONG && x >= (1U << (((unsigned int)i) * 8))) - return _range_error(f->format, f->size, 1); + if (i != SIZEOF_LONG) { + unsigned long maxint = 1; + maxint <<= (unsigned long)(i * 8); + if (x >= maxint) + return _range_error(f->format, f->size, 1); + } do { *p++ = (char)x; x >>= 8; @@ -1273,7 +1287,7 @@ fail: Py_DECREF(result); return NULL; -}; +} PyDoc_STRVAR(s_unpack__doc__, From thomas at python.org Sat May 27 18:03:21 2006 From: thomas at python.org (Thomas Wouters) Date: Sat, 27 May 2006 18:03:21 +0200 Subject: [Python-checkins] r46465 - python/trunk/Objects/exceptions.c In-Reply-To: <20060527144156.8A7D21E4006@bag.python.org> References: <20060527144156.8A7D21E4006@bag.python.org> Message-ID: <9e804ac0605270903r41cf3d56saf677de974262e53@mail.gmail.com> On 5/27/06, georg.brandl wrote: > > Author: georg.brandl > Date: Sat May 27 16:41:55 2006 > New Revision: 46465 > > Modified: > python/trunk/Objects/exceptions.c > Log: > Remove spurious semicolons after macro invocations. - "interpreter exiting."); > + "interpreter exiting.") Ehm, why? The semicolons at least make it look like normal C (and it helps indenters and syntax highlighters, not to mention human readers.) If the macro doesn't like being followed by a semicolon, I think the macro should be fixed, not the callsites ;-) -- Thomas Wouters < thomas at python.org> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060527/31118073/attachment.html From python-checkins at python.org Sat May 27 18:07:29 2006 From: python-checkins at python.org (richard.jones) Date: Sat, 27 May 2006 18:07:29 +0200 (CEST) Subject: [Python-checkins] r46475 - python/trunk/Objects/exceptions.c Message-ID: <20060527160729.126C01E4006@bag.python.org> Author: richard.jones Date: Sat May 27 18:07:28 2006 New Revision: 46475 Modified: python/trunk/Objects/exceptions.c Log: doc string additions and tweaks Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sat May 27 18:07:28 2006 @@ -6,6 +6,18 @@ #define MAKE_IT_NONE(x) (x) = Py_None; Py_INCREF(Py_None); #define EXC_MODULE_NAME "exceptions." +/* NOTE: If the exception class hierarchy changes, don't forget to update + * Lib/test/exception_hierarchy.txt + */ + +PyDoc_STRVAR(exceptions_doc, "Python's standard exception class hierarchy.\n\ +\n\ +Exceptions found here are defined both in the exceptions module and the\n\ +built-in namespace. It is recommended that user-defined exceptions\n\ +inherit from Exception. See the documentation for the exception\n\ +inheritance hierarchy.\n\ +"); + /* * BaseException */ @@ -646,11 +658,11 @@ {"message", T_OBJECT, offsetof(PyEnvironmentErrorObject, message), 0, PyDoc_STR("exception message")}, {"errno", T_OBJECT, offsetof(PyEnvironmentErrorObject, myerrno), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("exception errno")}, {"strerror", T_OBJECT, offsetof(PyEnvironmentErrorObject, strerror), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("exception strerror")}, {"filename", T_OBJECT, offsetof(PyEnvironmentErrorObject, filename), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("exception filename")}, {NULL} /* Sentinel */ }; @@ -880,13 +892,13 @@ {"message", T_OBJECT, offsetof(PyWindowsErrorObject, message), 0, PyDoc_STR("exception message")}, {"errno", T_OBJECT, offsetof(PyWindowsErrorObject, myerrno), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("POSIX exception code")}, {"strerror", T_OBJECT, offsetof(PyWindowsErrorObject, strerror), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("exception strerror")}, {"filename", T_OBJECT, offsetof(PyWindowsErrorObject, filename), 0, - PyDoc_STR("exception code")}, + PyDoc_STR("exception filename")}, {"winerror", T_OBJECT, offsetof(PyWindowsErrorObject, winerror), 0, - PyDoc_STR("windows exception code")}, + PyDoc_STR("Win32 exception code")}, {NULL} /* Sentinel */ }; @@ -2051,7 +2063,8 @@ PRE_INIT(FutureWarning) PRE_INIT(ImportWarning) - m = Py_InitModule("exceptions", functions); + m = Py_InitModule4("exceptions", functions, exceptions_doc, + (PyObject *)NULL, PYTHON_API_VERSION); if (m == NULL) return; bltinmod = PyImport_ImportModule("__builtin__"); From python-checkins at python.org Sat May 27 18:14:47 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 18:14:47 +0200 (CEST) Subject: [Python-checkins] r46476 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060527161447.B71D81E4006@bag.python.org> Author: martin.blais Date: Sat May 27 18:14:47 2006 New Revision: 46476 Modified: sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Implemented use case for netstrings. Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Sat May 27 18:14:47 2006 @@ -21,37 +21,42 @@ TODO ==== -* Should getbyterel() implement getting negative offsets from the end of the - window? - - - BTW getbyterel() should be implemented using the slicing operators - -* Remove the advbytes argument to pop(), it is confusing. - -* Remove the mark, save() and restore(). - -* Implement the entire string protocol, since that will be a fast to contents +* Should getbyterel() implement getting negative offsets from the + end of the window rather than move backwards from the current + position? I think it should. + +* Implement the entire string protocol, since that will be a fast + path to contents (no dict lookup is necessary) + + * Also, getbyterel() should be implemented using the slicing + operators, but you need to check if they allow returning an int + rather than a string. * Make it possible to read from a file directly into a hotbuf - - implement the file protocol (read(), write()) on the hotbuf object - - euh, is there a file protocol? - -* Implement relative get/put methods that don't increment the position. - -* Implement absolute get/put methods. + - Implement fromfile() and tofile() on the hotbuf object + - Check if there a tp_file protocol and if there is, use that + instead to provide the interface. -* We need to select between PyObject_MALLOC and PyObject_MEMMALLOC +* Implement absolute get/put methods (getabs(n), putabs(n, data)) -* Implement pack() in C +* The hot buffer can unpack in C, similarly implement pack() in C. -* Add support for some of the other sequence methods. +* Implement some of the other sequence methods. -* Add methods to parse ints, longs, floats and doubles directly from the buffer - contents, without using a temporary string. +* Add methods to parse ints, longs, floats and doubles directly + from/to the buffer contents, without using a temporary string. + getlong(), putlong(), etc. -* Write a small PEP about this, when all is said and done. +* Documentation: write a small PEP about this, when all is said and + done. + + - hot buffers are really just a fancy string that can change on top of a + fixed-allocated memory buffer, and should provide the same interface + - Note for common use cases: the buffer should have at least the + size of the minimal line/message that you may ever encounter, + otherwise you will have to write special parsing routines. Other Features Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 18:14:47 2006 @@ -7,7 +7,7 @@ # from hotbuf import hotbuf, BoundaryError -from struct import Struct +from struct import Struct, pack import unittest from cStringIO import StringIO from test import test_support @@ -365,38 +365,11 @@ on your application and the side-effects that may have occurred. """ - data1 = """ -Most programming languages, including Lisp, are organized -around computing the values of mathematical -functions. Expression-oriented languages (such as Lisp, -Fortran, and Algol) capitalize on the ``pun'' that an -expression that describes the value of a function may also -be interpreted as a means of computing that value. Because -of this, most programming languages are strongly biased -toward unidirectional computations (computations with -well-defined inputs and outputs). There are, however, -radically different programming languages that relax this -bias. We saw one such example in section 3.3.5, where the -objects of computation were arithmetic constraints. In a -constraint system the direction and the order of -computation are not so well specified; in carrying out a -computation the system must therefore provide more detailed -``how to'' knowledge than would be the case with an -ordinary arithmetic computation. - -This does not mean, however, that the user is released -altogether from the responsibility of providing imperative -knowledge. There are many constraint networks that -implement the same set of constraints, and the user must -choose from the set of mathematically equivalent networks a -suitable network to specify a particular computation.""" - lines1 = map(str.strip, data1.splitlines()) - def parse_newline_delim( self, hot, read, process_line ): """ Use case for newline-delimited data. """ - newline, cr = ord('\n'), ord('\r') + cr = ord('\r') # Initiallly put some data into the buffer. hot.putstr(read(len(hot))) @@ -439,8 +412,6 @@ break # Read more data in the buffer. -## FIXME: we need to support reading from a file directly into the -## buffer. hot.compact() s = read(len(hot)) if not s: @@ -453,29 +424,59 @@ if hot: process_line(hot) - def test_newline_delim_data( self ): """ Test for newline-delimited data. """ - inp = StringIO(self.data1) + inp = StringIO(self.data_nldelim) hot = hotbuf(256) lineidx = [0] def assert_lines( hot ): "Assert the lines we process are the ones we expect." - self.assertEquals(str(hot), self.lines1[lineidx[0]]) + self.assertEquals(str(hot), self.lines_nldelim[lineidx[0]]) lineidx[0] += 1 self.parse_newline_delim(hot, inp.read, assert_lines) + data_nldelim = """ +Most programming languages, including Lisp, are organized +around computing the values of mathematical +functions. Expression-oriented languages (such as Lisp, +Fortran, and Algol) capitalize on the ``pun'' that an +expression that describes the value of a function may also +be interpreted as a means of computing that value. Because +of this, most programming languages are strongly biased +toward unidirectional computations (computations with +well-defined inputs and outputs). There are, however, +radically different programming languages that relax this +bias. We saw one such example in section 3.3.5, where the +objects of computation were arithmetic constraints. In a +constraint system the direction and the order of +computation are not so well specified; in carrying out a +computation the system must therefore provide more detailed +``how to'' knowledge than would be the case with an +ordinary arithmetic computation. -#------------------------------------------------------------------------ -# - def _test_netstrings( self ): +This does not mean, however, that the user is released +altogether from the responsibility of providing imperative +knowledge. There are many constraint networks that +implement the same set of constraints, and the user must +choose from the set of mathematically equivalent networks a +suitable network to specify a particular computation.""" + + lines_nldelim = map(str.strip, data_nldelim.splitlines()) + + + #--------------------------------------------------------------------------- + + def parse_netstrings( self, hot, read, process_msg ): """ Use case for netstrings. """ + # Initiallly put some data into the buffer. + hot.putstr(read(len(hot))) + hot.flip() # Loop over the entire input. while 1: @@ -503,7 +504,7 @@ # - Exceptions will be programming errors. # - You never need to deal with rollback of your transactions. - process_message(hot) + process_msg(hot) # Advance beyond the message. hot.position = limit @@ -514,58 +515,60 @@ s = read(len(hot)) if not s: break # Finished the input, exit. + hot.putstr(s) + hot.flip() -## FIXME review the version with exceptions, would it be faster to just -## hit the boundary? I would prefer letting the boundary be - - while 1: - # Catch when we hit the boundary. - try: - # Loop over all the messages in the current buffer. - while hot: - # Read the length. - length = hot.getbyte() # This never raises since - # we're hot. - - mark_position = hot.position - mark_limit = hot.limit - hot.limit = hot.position + length - saved = True - - # Parse the message. - # - # - We are insured to be able to read all the message - # here because we checked for the length. - # - Exceptions will be programming errors. - # - You never need to deal with rollback of your - # transactions. - - process_message(hot) - - # Pop the message window and advance beyond the - # length. - hot.position = hot.limit - saved = False - else: - # Raise an exception, triggering a filling of the - # buffer - raise hotbuf.BoundaryError - - except hotbuf.BoundaryError: - # Rollback the failed transaction, if there was one. - if saved: - hot.position = mark_position - hot.limit = mark_limit - - # Compact and read the next chunk of the buffer. - hot.compact() - s = read(len(hot)) - if not s: - break # Finished the input, exit. - + def test_netstrings( self ): + """ + Test for parsing netstrings. + """ + inp = StringIO(self.packed_netstrings) + hot = hotbuf(256) + msgidx = [0] + def assert_msg( hot ): + "Assert the messages we process are the ones we expect." + msg = str(hot) + l = len(hot) + msgtype = chr(hot.getbyte()) + expected = self.expected_messages[msgidx[0]] + self.assertEquals(msg, expected) + msgidx[0] = (msgidx[0] + 1) % len(self.data_netstrings) + + + self.parse_netstrings(hot, inp.read, assert_msg) + + # + # Test data for netstrings. + # + + # Formats for packing/unpacking. + data_fmts = dict( (x[0], Struct(x[1])) for x in (('A', 'h l f'), + ('B', 'd d d'), + ('C', 'I L l c')) ) + + # Expected data. + data_netstrings = ( + ('A', (47, 23, 3.14159217)), + ('B', (1.23, 4.232, 6.433)), + ('A', (43, 239, 4.243232)), + ('C', (100, 101L, 12, 'b')), + ('B', (22.3232, 5.343, 4.3323)), + ) + + # Test data. + expected_messages, packed_netstrings = [], '' + for i in xrange(100): + for msgtype, data in data_netstrings: + stru = data_fmts[msgtype] + msg = pack('b', ord(msgtype)) + stru.pack(*data) + expected_messages.append(msg) + netstring = pack('b', len(msg)) + msg + packed_netstrings += netstring + #--------------------------------------------------------------------------- + def _test_detect_boundary( self ): """ Use case for arbitraty formats, where we do not set a limit for From python-checkins at python.org Sat May 27 18:15:11 2006 From: python-checkins at python.org (richard.jones) Date: Sat, 27 May 2006 18:15:11 +0200 (CEST) Subject: [Python-checkins] r46477 - python/trunk/Objects/exceptions.c Message-ID: <20060527161511.B49F91E400C@bag.python.org> Author: richard.jones Date: Sat May 27 18:15:11 2006 New Revision: 46477 Modified: python/trunk/Objects/exceptions.c Log: move semicolons Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sat May 27 18:15:11 2006 @@ -331,6 +331,9 @@ in the API */ PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException; +/* note these macros omit the last semicolon so the macro invocation may + * include it and not look strange. + */ #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ PyObject_HEAD_INIT(NULL) \ @@ -345,7 +348,7 @@ 0, 0, 0, offsetof(PyBaseExceptionObject, dict), \ (initproc)BaseException_init, 0, BaseException_new,\ }; \ -PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME #define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ @@ -361,7 +364,7 @@ 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ -PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME #define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ @@ -378,14 +381,14 @@ 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ }; \ -PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME; +PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME /* * Exception extends BaseException */ SimpleExtendsException(PyExc_BaseException, Exception, - "Common base class for all non-exit exceptions.") + "Common base class for all non-exit exceptions."); /* @@ -393,28 +396,28 @@ */ SimpleExtendsException(PyExc_Exception, StandardError, "Base class for all standard Python exceptions that do not represent\n" - "interpreter exiting.") + "interpreter exiting."); /* * TypeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, TypeError, - "Inappropriate argument type.") + "Inappropriate argument type."); /* * StopIteration extends Exception */ SimpleExtendsException(PyExc_Exception, StopIteration, - "Signal the end from iterator.next().") + "Signal the end from iterator.next()."); /* * GeneratorExit extends Exception */ SimpleExtendsException(PyExc_Exception, GeneratorExit, - "Request that a generator exit.") + "Request that a generator exit."); /* @@ -482,20 +485,20 @@ ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0, - "Request to exit from the interpreter.") + "Request to exit from the interpreter."); /* * KeyboardInterrupt extends BaseException */ SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, - "Program interrupted by user.") + "Program interrupted by user."); /* * ImportError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ImportError, - "Import can't find module, or can't find name in module.") + "Import can't find module, or can't find name in module."); /* @@ -712,21 +715,21 @@ EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, EnvironmentError_str, - "Base class for I/O related errors.") + "Base class for I/O related errors."); /* * IOError extends EnvironmentError */ MiddlingExtendsException(PyExc_EnvironmentError, IOError, - EnvironmentError, "I/O operation failed.") + EnvironmentError, "I/O operation failed."); /* * OSError extends EnvironmentError */ MiddlingExtendsException(PyExc_EnvironmentError, OSError, - EnvironmentError, "OS system call failed.") + EnvironmentError, "OS system call failed."); /* @@ -902,14 +905,9 @@ {NULL} /* Sentinel */ }; -ComplexExtendsException(PyExc_OSError, - WindowsError, - WindowsError, - WindowsError_dealloc, - 0, - WindowsError_members, - WindowsError_str, - "MS-Windows OS system call failed.") +ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError, + WindowsError_dealloc, 0, WindowsError_members, + WindowsError_str, "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ @@ -919,7 +917,7 @@ */ #ifdef __VMS MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError, - "OpenVMS OS system call failed.") + "OpenVMS OS system call failed."); #endif @@ -927,39 +925,39 @@ * EOFError extends StandardError */ SimpleExtendsException(PyExc_StandardError, EOFError, - "Read beyond end of file.") + "Read beyond end of file."); /* * RuntimeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, RuntimeError, - "Unspecified run-time error.") + "Unspecified run-time error."); /* * NotImplementedError extends RuntimeError */ SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, - "Method or function hasn't been implemented yet.") + "Method or function hasn't been implemented yet."); /* * NameError extends StandardError */ SimpleExtendsException(PyExc_StandardError, NameError, - "Name not found globally.") + "Name not found globally."); /* * UnboundLocalError extends NameError */ SimpleExtendsException(PyExc_NameError, UnboundLocalError, - "Local name referenced but not bound to a value.") + "Local name referenced but not bound to a value."); /* * AttributeError extends StandardError */ SimpleExtendsException(PyExc_StandardError, AttributeError, - "Attribute not found.") + "Attribute not found."); /* @@ -1152,35 +1150,35 @@ ComplexExtendsException(PyExc_StandardError, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, - SyntaxError_str, "Invalid syntax.") + SyntaxError_str, "Invalid syntax."); /* * IndentationError extends SyntaxError */ MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, - "Improper indentation.") + "Improper indentation."); /* * TabError extends IndentationError */ MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, - "Improper mixture of spaces and tabs.") + "Improper mixture of spaces and tabs."); /* * LookupError extends StandardError */ SimpleExtendsException(PyExc_StandardError, LookupError, - "Base class for lookup errors.") + "Base class for lookup errors."); /* * IndexError extends LookupError */ SimpleExtendsException(PyExc_LookupError, IndexError, - "Sequence index out of range.") + "Sequence index out of range."); /* @@ -1206,21 +1204,21 @@ } ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, - 0, 0, 0, KeyError_str, "Mapping key not found.") + 0, 0, 0, KeyError_str, "Mapping key not found."); /* * ValueError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ValueError, - "Inappropriate argument value (of correct type).") + "Inappropriate argument value (of correct type)."); /* * UnicodeError extends ValueError */ SimpleExtendsException(PyExc_ValueError, UnicodeError, - "Unicode related error.") + "Unicode related error."); #ifdef Py_USING_UNICODE static int @@ -1871,35 +1869,35 @@ * AssertionError extends StandardError */ SimpleExtendsException(PyExc_StandardError, AssertionError, - "Assertion failed.") + "Assertion failed."); /* * ArithmeticError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ArithmeticError, - "Base class for arithmetic errors.") + "Base class for arithmetic errors."); /* * FloatingPointError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, - "Floating point operation failed.") + "Floating point operation failed."); /* * OverflowError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, OverflowError, - "Result too large to be represented.") + "Result too large to be represented."); /* * ZeroDivisionError extends ArithmeticError */ SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, - "Second argument to a division or modulo operation was zero.") + "Second argument to a division or modulo operation was zero."); /* @@ -1909,20 +1907,20 @@ "Internal error in the Python interpreter.\n" "\n" "Please report this to the Python maintainer, along with the traceback,\n" - "the Python version, and the hardware/OS platform and version.") + "the Python version, and the hardware/OS platform and version."); /* * ReferenceError extends StandardError */ SimpleExtendsException(PyExc_StandardError, ReferenceError, - "Weak ref proxy used after referent went away.") + "Weak ref proxy used after referent went away."); /* * MemoryError extends StandardError */ -SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory.") +SimpleExtendsException(PyExc_StandardError, MemoryError, "Out of memory."); /* Warning category docstrings */ @@ -1931,21 +1929,21 @@ * Warning extends Exception */ SimpleExtendsException(PyExc_Exception, Warning, - "Base class for warning categories.") + "Base class for warning categories."); /* * UserWarning extends Warning */ SimpleExtendsException(PyExc_Warning, UserWarning, - "Base class for warnings generated by user code.") + "Base class for warnings generated by user code."); /* * DeprecationWarning extends Warning */ SimpleExtendsException(PyExc_Warning, DeprecationWarning, - "Base class for warnings about deprecated features.") + "Base class for warnings about deprecated features."); /* @@ -1953,21 +1951,21 @@ */ SimpleExtendsException(PyExc_Warning, PendingDeprecationWarning, "Base class for warnings about features which will be deprecated\n" - "in the future.") + "in the future."); /* * SyntaxWarning extends Warning */ SimpleExtendsException(PyExc_Warning, SyntaxWarning, - "Base class for warnings about dubious syntax.") + "Base class for warnings about dubious syntax."); /* * RuntimeWarning extends Warning */ SimpleExtendsException(PyExc_Warning, RuntimeWarning, - "Base class for warnings about dubious runtime behavior.") + "Base class for warnings about dubious runtime behavior."); /* @@ -1975,14 +1973,14 @@ */ SimpleExtendsException(PyExc_Warning, FutureWarning, "Base class for warnings about constructs that will change semantically\n" - "in the future.") + "in the future."); /* * ImportWarning extends Warning */ SimpleExtendsException(PyExc_Warning, ImportWarning, - "Base class for warnings about probable mistakes in module imports") + "Base class for warnings about probable mistakes in module imports"); /* Pre-computed MemoryError instance. Best to create this as early as From richard at commonground.com.au Sat May 27 18:15:01 2006 From: richard at commonground.com.au (Richard Jones) Date: Sat, 27 May 2006 16:15:01 +0000 Subject: [Python-checkins] r46465 - python/trunk/Objects/exceptions.c In-Reply-To: <9e804ac0605270903r41cf3d56saf677de974262e53@mail.gmail.com> References: <20060527144156.8A7D21E4006@bag.python.org> <9e804ac0605270903r41cf3d56saf677de974262e53@mail.gmail.com> Message-ID: On 27/05/2006, at 4:03 PM, Thomas Wouters wrote: > Ehm, why? The semicolons at least make it look like normal C (and > it helps indenters and syntax highlighters, not to mention human > readers.) If the macro doesn't like being followed by a semicolon, > I think the macro should be fixed, not the callsites ;-) Done. Richard From python-checkins at python.org Sat May 27 18:32:49 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 27 May 2006 18:32:49 +0200 (CEST) Subject: [Python-checkins] r46478 - python/trunk/Doc/ref/ref3.tex python/trunk/Doc/ref/ref5.tex Message-ID: <20060527163249.7F1391E4006@bag.python.org> Author: george.yoshida Date: Sat May 27 18:32:44 2006 New Revision: 46478 Modified: python/trunk/Doc/ref/ref3.tex python/trunk/Doc/ref/ref5.tex Log: minor markup nits Modified: python/trunk/Doc/ref/ref3.tex ============================================================================== --- python/trunk/Doc/ref/ref3.tex (original) +++ python/trunk/Doc/ref/ref3.tex Sat May 27 18:32:44 2006 @@ -1983,9 +1983,9 @@ \end{methoddesc} \begin{methoddesc}[numeric object]{__index__}{self} -Called to implement operator.index(). Also called whenever Python -needs an integer object (such as in slicing). Must return an integer -(int or long). +Called to implement \function{operator.index()}. Also called whenever +Python needs an integer object (such as in slicing). Must return an +integer (int or long). \versionadded{2.5} \end{methoddesc} Modified: python/trunk/Doc/ref/ref5.tex ============================================================================== --- python/trunk/Doc/ref/ref5.tex (original) +++ python/trunk/Doc/ref/ref5.tex Sat May 27 18:32:44 2006 @@ -391,7 +391,8 @@ A slicing selects a range of items in a sequence object (e.g., a string, tuple or list). Slicings may be used as expressions or as -targets in assignment or del statements. The syntax for a slicing: +targets in assignment or \keyword{del} statements. The syntax for a +slicing: \obindex{sequence} \obindex{string} \obindex{tuple} From python-checkins at python.org Sat May 27 18:32:51 2006 From: python-checkins at python.org (sean.reifschneider) Date: Sat, 27 May 2006 18:32:51 +0200 (CEST) Subject: [Python-checkins] r46479 - in sandbox/trunk/pybch: Tests/TestHelpers.py Tests/__init__.py Tests/stringbench.py pybch.py Message-ID: <20060527163251.CE79D1E4006@bag.python.org> Author: sean.reifschneider Date: Sat May 27 18:32:49 2006 New Revision: 46479 Added: sandbox/trunk/pybch/Tests/stringbench.py (contents, props changed) Modified: sandbox/trunk/pybch/Tests/TestHelpers.py sandbox/trunk/pybch/Tests/__init__.py sandbox/trunk/pybch/pybch.py Log: Adding stringbench, and all tests seem to succeed. Modified: sandbox/trunk/pybch/Tests/TestHelpers.py ============================================================================== --- sandbox/trunk/pybch/Tests/TestHelpers.py (original) +++ sandbox/trunk/pybch/Tests/TestHelpers.py Sat May 27 18:32:49 2006 @@ -4,6 +4,7 @@ rounds = None is_a_test = 1 verbose = 0 + requireCowlibrationRounds = 10 def cowlibrate(self): self.rounds = 100 successfulRounds = 0 @@ -17,7 +18,7 @@ and elapsed <= self.runtimeTarget + self.runtimeAccuracyTarget): successfulRounds = successfulRounds + 1 - if successfulRounds > 10: break + if successfulRounds > self.requireCowlibrationRounds: break else: successfulRounds = 0 self.rounds = int(self.rounds * Modified: sandbox/trunk/pybch/Tests/__init__.py ============================================================================== --- sandbox/trunk/pybch/Tests/__init__.py (original) +++ sandbox/trunk/pybch/Tests/__init__.py Sat May 27 18:32:49 2006 @@ -1,10 +1,10 @@ testModules = [ -# 'Arithmetic', + 'Arithmetic', 'Calls', 'Constructs', 'Dict', 'Exceptions', - 'Imports', + #'Imports', 'Instances', 'Lists', 'Lookups', @@ -14,4 +14,5 @@ 'TestHelpers', 'Tuples', 'Unicode', + 'stringbench', ] Added: sandbox/trunk/pybch/Tests/stringbench.py ============================================================================== --- (empty file) +++ sandbox/trunk/pybch/Tests/stringbench.py Sat May 27 18:32:49 2006 @@ -0,0 +1,1570 @@ + +# Various microbenchmarks comparing unicode and byte string performance + +import timeit +import itertools +import operator +import re +import sys +import datetime +import optparse +from TestHelpers import Test + +print sys.version +print datetime.datetime.now() + +REPEAT = 1 +REPEAT = 3 +#REPEAT = 7 + +_RANGE_1000 = range(1) +_RANGE_1000 = range(1) +_RANGE_100 = range(1) +_RANGE_10 = range(1) + +dups = {} +def bench(s, group, repeat_count): + def blah(f): + if f.__name__ in dups: + raise AssertionError("Multiple functions with same name: %r" % + (f.__name__,)) + dups[f.__name__] = 1 + f.comment = s + f.is_bench = True + f.group = group + f.repeat_count = repeat_count + return f + return blah + +def uses_re(f): + f.uses_re = True + +####### 'in' comparisons + + at bench('"A" in "A"*1000', "early match, single character", 1000) +def in_test_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + for x in _RANGE_1000: + s2 in s1 + + at bench('"B" in "A"*1000', "no match, single character", 1000) +def in_test_no_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("B") + for x in _RANGE_1000: + s2 in s1 + + + at bench('"AB" in "AB"*1000', "early match, two characters", 1000) +def in_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + for x in _RANGE_1000: + s2 in s1 + + at bench('"BC" in "AB"*1000', "no match, two characters", 1000) +def in_test_no_match_two_character(STR): + s1 = STR("AB" * 1000) + s2 = STR("BC") + for x in _RANGE_1000: + s2 in s1 + + at bench('"BC" in ("AB"*300+"C")', "late match, two characters", 1000) +def in_test_slow_match_two_characters(STR): + s1 = STR("AB" * 300+"C") + s2 = STR("BC") + for x in _RANGE_1000: + s2 in s1 + + at bench('s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E")', + "late match, 100 characters", 100) +def in_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*300 + m+"E" + s2 = m+"E" + for x in _RANGE_100: + s2 in s1 + +# Try with regex + at uses_re + at bench('s="ABC"*33; re.compile(s+"D").search((s+"D")*300+s+"E")', + "late match, 100 characters", 100) +def re_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*300 + m+"E" + s2 = m+"E" + pat = re.compile(s2) + search = pat.search + for x in _RANGE_100: + search(s1) + + +#### same tests as 'in' but use 'find' + +# XXX: TODO: Add rfind + + + + at bench('("A"*1000).find("A")', "early match, single character", 1000) +def find_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('("A"*1000).find("B")', "no match, single character", 1000) +def find_test_no_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("B") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + + at bench('("AB"*1000).find("AB")', "early match, two characters", 1000) +def find_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('("AB"*1000).find("BC")', "no match, two characters", 1000) +def find_test_no_match_two_character(STR): + s1 = STR("AB" * 1000) + s2 = STR("BC") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('("AB"*300+"C").find("BC")', "late match, two characters", 1000) +def find_test_slow_match_two_characters(STR): + s1 = STR("AB" * 300+"C") + s2 = STR("BC") + s1_find = s1.find + for x in _RANGE_1000: + s1_find(s2) + + at bench('s="ABC"*33; ((s+"D")*500+s+"E").find(s)', + "late match, 100 characters", 100) +def find_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + s1_find = s1.find + for x in _RANGE_100: + s1_find(s2) + +#### Now with index. +# Skip the ones which fail because that would include exception overhead. +# Add rindex tests. + + + at bench('("A"*1000).index("A")', "early match, single character", 1000) +def index_test_quick_match_single_character(STR): + s1 = STR("A" * 1000) + s2 = STR("A") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + + at bench('("AB"*1000).index("AB")', "early match, two characters", 1000) +def index_test_quick_match_two_characters(STR): + s1 = STR("AB" * 1000) + s2 = STR("AB") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + at bench('("AB"*300+"C").index("BC")', "late match, two characters", 1000) +def index_test_slow_match_two_characters(STR): + s1 = STR("AB" * 300+"C") + s2 = STR("BC") + s1_index = s1.index + for x in _RANGE_1000: + s1_index(s2) + + at bench('s="ABC"*33; ((s+"D")*500+s+"E").index(s)', + "late match, 100 characters", 100) +def index_test_slow_match_100_characters(STR): + m = STR("ABC"*33) + s1 = (m+"D")*500 + m+"E" + s2 = m+"E" + s1_index = s1.index + for x in _RANGE_100: + s1_index(s2) + +#### Benchmark the operator-based methods + + at bench('"A"*10', "repeat 1 character 10 times", 1000) +def repeat_single_10_times(STR): + s = STR("A") + for x in _RANGE_1000: + s * 10 + + at bench('"A"*1000', "repeat 1 character 1000 times", 1000) +def repeat_single_1000_times(STR): + s = STR("A") + for x in _RANGE_1000: + s * 1000 + + at bench('"ABCDE"*10', "repeat 5 characters 10 times", 1000) +def repeat_5_10_times(STR): + s = STR("ABCDE") + for x in _RANGE_1000: + s * 10 + + at bench('"ABCDE"*1000', "repeat 5 characters 1000 times", 1000) +def repeat_5_1000_times(STR): + s = STR("ABCDE") + for x in _RANGE_1000: + s * 1000 + +# + for concat + + at bench('"Andrew"+"Dalke"', "concat two strings", 1000) +def concat_two_strings(STR): + s1 = STR("Andrew") + s2 = STR("Dalke") + for x in _RANGE_1000: + s1+s2 + + at bench('s1+s2+s3+s4+...+s20', "concat 20 strings of words length 4 to 15", + 1000) +def concat_many_strings(STR): + s1=STR('TIXSGYNREDCVBHJ') + s2=STR('PUMTLXBZVDO') + s3=STR('FVZNJ') + s4=STR('OGDXUW') + s5=STR('WEIMRNCOYVGHKB') + s6=STR('FCQTNMXPUZH') + s7=STR('TICZJYRLBNVUEAK') + s8=STR('REYB') + s9=STR('PWUOQ') + s10=STR('EQHCMKBS') + s11=STR('AEVDFOH') + s12=STR('IFHVD') + s13=STR('JGTCNLXWOHQ') + s14=STR('ITSKEPYLROZAWXF') + s15=STR('THEK') + s16=STR('GHPZFBUYCKMNJIT') + s17=STR('JMUZ') + s18=STR('WLZQMTB') + s19=STR('KPADCBW') + s20=STR('TNJHZQAGBU') + for x in _RANGE_1000: + (s1 + s2+ s3+ s4+ s5+ s6+ s7+ s8+ s9+s10+ + s11+s12+s13+s14+s15+s16+s17+s18+s19+s20) + + +#### Benchmark join + + at bench('"A".join("")', + "join empty string, with 1 character sep", 100) +def join_empty_single(STR): + sep = STR("A") + s2 = STR("") + sep_join = sep.join + for x in _RANGE_100: + sep_join(s2) + + at bench('"ABCDE".join("")', + "join empty string, with 5 character sep", 100) +def join_empty_5(STR): + sep = STR("ABCDE") + s2 = STR("") + sep_join = sep.join + for x in _RANGE_100: + sep_join(s2) + + at bench('"A".join("ABC..Z")', + "join string with 26 characters, with 1 character sep", 1000) +def join_alphabet_single(STR): + sep = STR("A") + s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join("ABC..Z")', + "join string with 26 characters, with 5 character sep", 1000) +def join_alphabet_5(STR): + sep = STR("ABCDE") + s2 = STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ") + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"A".join(list("ABC..Z"))', + "join list of 26 characters, with 1 character sep", 1000) +def join_alphabet_list_single(STR): + sep = STR("A") + s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join(list("ABC..Z"))', + "join list of 26 characters, with 5 character sep", 1000) +def join_alphabet_list_five(STR): + sep = STR("ABCDE") + s2 = list(STR("ABCDEFGHIJKLMnOPQRSTUVWXYZ")) + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"A".join(["Bob"]*100))', + "join list of 100 words, with 1 character sep", 1000) +def join_100_words_single(STR): + sep = STR("A") + s2 = [STR("Bob")]*100 + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + + at bench('"ABCDE".join(["Bob"]*100))', + "join list of 100 words, with 5 character sep", 1000) +def join_100_words_5(STR): + sep = STR("ABCDE") + s2 = [STR("Bob")]*100 + sep_join = sep.join + for x in _RANGE_1000: + sep_join(s2) + +#### split tests + + at bench('("Here are some words. "*2).split()', "split whitespace (small)", 1000) +def whitespace_split(STR): + s = STR("Here are some words. "*2) + s_split = s.split + for x in _RANGE_1000: + s_split() + + at bench('("Here are some words. "*2).rsplit()', "split whitespace (small)", 1000) +def whitespace_rsplit(STR): + s = STR("Here are some words. "*2) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit() + + at bench('("Here are some words. "*2).split(None, 1)', + "split 1 whitespace", 1000) +def whitespace_split_1(STR): + s = STR("Here are some words. "*2) + s_split = s.split + N = None + for x in _RANGE_1000: + s_split(N, 1) + + at bench('("Here are some words. "*2).rsplit(None, 1)', + "split 1 whitespace", 1000) +def whitespace_rsplit_1(STR): + s = STR("Here are some words. "*2) + s_rsplit = s.rsplit + N = None + for x in _RANGE_1000: + s_rsplit(N, 1) + +human_text = """\ +Python is a dynamic object-oriented programming language that can be +used for many kinds of software development. It offers strong support +for integration with other languages and tools, comes with extensive +standard libraries, and can be learned in a few days. Many Python +programmers report substantial productivity gains and feel the language +encourages the development of higher quality, more maintainable code. + +Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm +Handhelds, and Nokia mobile phones. Python has also been ported to the +Java and .NET virtual machines. + +Python is distributed under an OSI-approved open source license that +makes it free to use, even for commercial products. +"""*25 +human_text_unicode = unicode(human_text) +def _get_human_text(STR): + if STR is unicode: + return human_text_unicode + if STR is str: + return human_text + raise AssertionError + + at bench('human_text.split()', "split whitespace (huge)", 10) +def whitespace_split_huge(STR): + s = _get_human_text(STR) + s_split = s.split + for x in _RANGE_10: + s_split() + + at bench('human_text.rsplit()', "split whitespace (huge)", 10) +def whitespace_rsplit_huge(STR): + s = _get_human_text(STR) + s_rsplit = s.rsplit + for x in _RANGE_10: + s_rsplit() + + + + at bench('"this\\nis\\na\\ntest\\n".split("\\n")', "split newlines", 1000) +def newlines_split(STR): + s = STR("this\nis\na\ntest\n") + s_split = s.split + for x in _RANGE_1000: + s_split("\n") + + + at bench('"this\\nis\\na\\ntest\\n".rsplit("\\n")', "split newlines", 1000) +def newlines_rsplit(STR): + s = STR("this\nis\na\ntest\n") + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\n") + + at bench('"this\\nis\\na\\ntest\\n".splitlines()', "split newlines", 1000) +def newlines_splitlines(STR): + s = STR("this\nis\na\ntest\n") + s_splitlines = s.splitlines + for x in _RANGE_1000: + s_splitlines() + +## split text with 2000 newlines + +def _make_2000_lines(): + import random + r = random.Random(100) + chars = map(chr, range(32, 128)) + i = 0 + while i < len(chars): + chars[i] = " " + i += r.randrange(9) + s = "".join(chars) + s = s*4 + words = [] + for i in range(2000): + start = r.randrange(96) + n = r.randint(5, 65) + words.append(s[start:start+n]) + return "\n".join(words)+"\n" + +_text_with_2000_lines = _make_2000_lines() +_text_with_2000_lines_unicode = unicode(_text_with_2000_lines) +def _get_2000_lines(STR): + if STR is unicode: + return _text_with_2000_lines_unicode + if STR is str: + return _text_with_2000_lines + raise AssertionError + + + at bench('"...text...".split("\\n")', "split 2000 newlines", 10) +def newlines_split_2000(STR): + s = _get_2000_lines(STR) + s_split = s.split + for x in _RANGE_10: + s_split("\n") + + at bench('"...text...".rsplit("\\n")', "split 2000 newlines", 10) +def newlines_rsplit_2000(STR): + s = _get_2000_lines(STR) + s_rsplit = s.rsplit + for x in _RANGE_10: + s_rsplit("\n") + + at bench('"...text...".splitlines()', "split 2000 newlines", 10) +def newlines_splitlines_2000(STR): + s = _get_2000_lines(STR) + s_splitlines = s.splitlines + for x in _RANGE_10: + s_splitlines() + + +## split text on "--" characters + at bench( + '"this--is--a--test--of--the--emergency--broadcast--system".split("--")', + "split on multicharacter separator (small)", 1000) +def split_multichar_sep_small(STR): + s = STR("this--is--a--test--of--the--emergency--broadcast--system") + s_split = s.split + for x in _RANGE_1000: + s_split("--") + at bench( + '"this--is--a--test--of--the--emergency--broadcast--system".rsplit("--")', + "split on multicharacter separator (small)", 1000) +def rsplit_multichar_sep_small(STR): + s = STR("this--is--a--test--of--the--emergency--broadcast--system") + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("--") + +## split dna text on "ACTAT" characters + at bench('dna.split("ACTAT")', + "split on multicharacter separator (dna)", 10) +def split_multichar_sep_dna(STR): + s = _get_dna(STR) + s_split = s.split + for x in _RANGE_10: + s_split("ACTAT") + + at bench('dna.rsplit("ACTAT")', + "split on multicharacter separator (dna)", 10) +def rsplit_multichar_sep_dna(STR): + s = _get_dna(STR) + s_rsplit = s.rsplit + for x in _RANGE_10: + s_rsplit("ACTAT") + + + +## split with limits + +GFF3_example = "\t".join([ + "I", "Genomic_canonical", "region", "357208", "396183", ".", "+", ".", + "ID=Sequence:R119;note=Clone R119%3B Genbank AF063007;Name=R119"]) + + at bench('GFF3_example.split("\\t")', "tab split", 1000) +def tab_split_no_limit(STR): + s = STR(GFF3_example) + s_split = s.split + for x in _RANGE_1000: + s_split("\t") + + at bench('GFF3_example.split("\\t", 8)', "tab split", 1000) +def tab_split_limit(STR): + s = STR(GFF3_example) + s_split = s.split + for x in _RANGE_1000: + s_split("\t", 8) + + at bench('GFF3_example.rsplit("\\t")', "tab split", 1000) +def tab_rsplit_no_limit(STR): + s = STR(GFF3_example) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\t") + + at bench('GFF3_example.rsplit("\\t", 8)', "tab split", 1000) +def tab_rsplit_limit(STR): + s = STR(GFF3_example) + s_rsplit = s.rsplit + for x in _RANGE_1000: + s_rsplit("\t", 8) + +#### Count characters + + at bench('...text.with.2000.newlines.count("\\n")', + "count newlines", 10) +def count_newlines(STR): + s = _get_2000_lines(STR) + s_count = s.count + for x in _RANGE_10: + s_count("\n") + +# Orchid sequences concatenated, from Biopython +_dna = """ +CGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGGGTT +AATCTGGAGGATCTGTTTACTTTGGTCACCCATGAGCATTTGCTGTTGAAGTGACCTAGAATTGCCATCG +AGCCTCCTTGGGAGCTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGCAGTTTTGCTCCAAGTCGTT +TGACACATAATTGGTGAAGGGGGTGGCATCCTTCCCTGACCCTCCCCCAACTATTTTTTTAACAACTCTC +AGCAACGGAGACTCAGTCTTCGGCAAATGCGATAAATGGTGTGAATTGCAGAATCCCGTGCACCATCGAG +TCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCTGCCTGGGCATTGCGAGTCATAT +CTCTCCCTTAACGAGGCTGTCCATACATACTGTTCAGCCGGTGCGGATGTGAGTTTGGCCCCTTGTTCTT +TGGTACGGGGGGTCTAAGAGCTGCATGGGCTTTTGATGGTCCTAAATACGGCAAGAGGTGGACGAACTAT +GCTACAACAAAATTGTTGTGCAGAGGCCCCGGGTTGTCGTATTAGATGGGCCACCGTAATCTGAAGACCC +TTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGGCCATTTGGTTGCGACCCCAGGTCAG +GTGAGCAACAGCTGTCGTAACAAGGTTTCCGTAGGGTGAACTGCGGAAGGATCATTGTTGAGATCACATA +ATAATTGATCGAGTTAATCTGGAGGATCTGTTTACTTGGGTCACCCATGGGCATTTGCTGTTGAAGTGAC +CTAGATTTGCCATCGAGCCTCCTTGGGAGCATCCTTGTTGGCGATATCTAAACCCTCAATTTTTCCCCCA +ATCAAATTACACAAAATTGGTGGAGGGGGTGGCATTCTTCCCTTACCCTCCCCCAAATATTTTTTTAACA +ACTCTCAGCAACGGATATCTCAGCTCTTGCATCGATGAAGAACCCACCGAAATGCGATAAATGGTGTGAA +TTGCAGAATCCCGTGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACG +CCTGCCTGGGCATTGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACATACTGTTCAGCCGGTGCG +GATGTGAGTTTGGCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGATGCATGGGCTTTTGATGGTCCTAA +ATACGGCAAGAGGTGGACGAACTATGCTACAACAAAATTGTTGTGCAAAGGCCCCGGGTTGTCGTATAAG +ATGGGCCACCGATATCTGAAGACCCTTTTGGACCCCATTGGAGCCCATCAACCCATGTCAGTTGATGGCC +ATTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGA +GTTAATCTGGAGGATCTGTTTACTTGGGTCACCCATGGGCATTTGCTGTTGAAGTGACCTAGATTTGCCA +TCGAGCCTCCTTGGGAGCTTTCTTGTTGGCGATATCTAAACCCTTGCCCGGCAGAGTTTTGGGAATCCCG +TGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCTGCCTGGGCAT +TGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACACACCTGTTCAGCCGGTGCGGATGTGAGTTTG +GCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGCTGCATGGGCTTTTGATGGTCCTAAATACGGCAAGAG +GTGGACGAACTATGCTACAACAAAATTGTTGTGCAAAGGCCCCGGGTTGTCGTATTAGATGGGCCACCAT +AATCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGGCCATTTGGTTGC +GACCCAGTCAGGTGAGGGTAGGTGAACCTGCGGAAGGATCATTGTTGAGATCACATAATAATTGATCGAG +TTAATCTGGAGGATCTGTTTACTTTGGTCACCCATGGGCATTTGCTGTTGAAGTGACCTAGATTTGCCAT +CGAGCCTCCTTGGGAGCTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGGAGTTTGGCGCCAAGTCA +TATGACACATAATTGGTGAAGGGGGTGGCATCCTGCCCTGACCCTCCCCAAATTATTTTTTTAACAACTC +TCAGCAACGGATATCTCGGCTCTTGCATCGATGAAGAACGCAGCGAAATGCGATAAATGGTGTGAATTGC +AGAATCCCGTGAACCATCGAGTCTTTGGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCACGCCT +GCCTGGGCATTGGGAATCATATCTCTCCCCTAACGAGGCTATCCAAACATACTGTTCATCCGGTGCGGAT +GTGAGTTTGGCCCCTTGTTCTTTGGTACCGGGGGTCTAAGAGCTGCATGGGCATTTGATGGTCCTCAAAA +CGGCAAGAGGTGGACGAACTATGCCACAACAAAATTGTTGTCCCAAGGCCCCGGGTTGTCGTATTAGATG +GGCCACCGTAACCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATGACCA +TTTGTTGCGACCCCAGTCAGCTGAGCAACCCGCTGAGTGGAAGGTCATTGCCGATATCACATAATAATTG +ATCGAGTTAATCTGGAGGATCTGTTTACTTGGTCACCCATGAGCATTTGCTGTTGAAGTGACCTAGATTT +GCCATCGAGCCTCCTTGGGAGTTTTCTTGTTGGCGAGATCTAAACCCTTGCCCGGCGGAGTTGTGCGCCA +AGTCATATGACACATAATTGGTGAAGGGGGTGGCATCCTGCCCTGACCCTCCCCAAATTATTTTTTTAAC +AACTCTCAGCAACGGATATCTCGGCTCTTGCATCGATGAAGAACGCAGCGAAATGCGATAAATGGTGTGA +ATTGCAGAATCCCGTGAACCATCGAGTCTTTGAACGCAAGTTGCGCCCGAGGCCATCAGGCCAAGGGCAC +GCCTGCCTGGGCATTGCGAGTCATATCTCTCCCTTAACGAGGCTGTCCATACATACTGTTCATCCGGTGC +GGATGTGAGTTTGGCCCCTTGTTCTTTGGTACGGGGGGTCTAAGAGCTGCATGGGCATTTGATGGTCCTC +AAAACGGCAAGAGGTGGACGAACTATGCTACAACCAAATTGTTGTCCCAAGGCCCCGGGTTGTCGTATTA +GATGGGCCACCGTAACCTGAAGACCCTTTTGAACCCCATTGGAGGCCCATCAACCCATGATCAGTTGATG +ACCATGTGTTGCGACCCCAGTCAGCTGAGCAACGCGCTGAGCGTAACAAGGTTTCCGTAGGTGGACCTCC +GGGAGGATCATTGTTGAGATCACATAATAATTGATCGAGGTAATCTGGAGGATCTGCATATTTTGGTCAC +""" +_dna = "".join(_dna.splitlines()) +_dna = _dna * 25 +_dna_unicode = unicode(_dna) + +def _get_dna(STR): + if STR is unicode: + return _dna_unicode + if STR is str: + return _dna + raise AssertionError + + at bench('dna.count("AACT")', "count AACT substrings in DNA example", 10) +def count_aact(STR): + seq = _get_dna(STR) + seq_count = seq.count + for x in _RANGE_10: + seq_count("AACT") + +##### startswith and endswith + + at bench('"Andrew".startswith("A")', 'startswith single character', 1000) +def startswith_single(STR): + s1 = STR("Andrew") + s2 = STR("A") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + at bench('"Andrew".startswith("Andrew")', 'startswith multiple characters', + 1000) +def startswith_multiple(STR): + s1 = STR("Andrew") + s2 = STR("Andrew") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + at bench('"Andrew".startswith("Anders")', + 'startswith multiple characters - not!', 1000) +def startswith_multiple_not(STR): + s1 = STR("Andrew") + s2 = STR("Anders") + s1_startswith = s1.startswith + for x in _RANGE_1000: + s1_startswith(s2) + + +# endswith + + at bench('"Andrew".endswith("w")', 'endswith single character', 1000) +def endswith_single(STR): + s1 = STR("Andrew") + s2 = STR("w") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + + at bench('"Andrew".endswith("Andrew")', 'endswith multiple characters', 1000) +def endswith_multiple(STR): + s1 = STR("Andrew") + s2 = STR("Andrew") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + + at bench('"Andrew".endswith("Anders")', + 'endswith multiple characters - not!', 1000) +def endswith_multiple_not(STR): + s1 = STR("Andrew") + s2 = STR("Anders") + s1_endswith = s1.endswith + for x in _RANGE_1000: + s1_endswith(s2) + +#### Strip + + at bench('"Hello!\\n".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_right(STR): + s = STR("Hello!\n") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"Hello!\\n".rstrip()', 'strip terminal newline', 1000) +def terminal_newline_rstrip(STR): + s = STR("Hello!\n") + s_rstrip = s.rstrip + for x in _RANGE_1000: + s_rstrip() + + at bench('"\\nHello!".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_left(STR): + s = STR("\nHello!") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"\\nHello!\\n".strip()', 'strip terminal newline', 1000) +def terminal_newline_strip_both(STR): + s = STR("\nHello!\n") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"\\nHello!".rstrip()', 'strip terminal newline', 1000) +def terminal_newline_lstrip(STR): + s = STR("\nHello!") + s_lstrip = s.lstrip + for x in _RANGE_1000: + s_lstrip() + +# Strip multiple spaces or tabs + + at bench('"Hello\\t \\t".strip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_strip(STR): + s = STR("Hello\t \t!") + s_strip = s.strip + for x in _RANGE_1000: + s_strip() + + at bench('"Hello\\t \\t".rstrip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_rstrip(STR): + s = STR("Hello!\t \t") + s_rstrip = s.rstrip + for x in _RANGE_1000: + s_rstrip() + + at bench('"\\t \\tHello".rstrip()', 'strip terminal spaces and tabs', 1000) +def terminal_space_lstrip(STR): + s = STR("\t \tHello!") + s_lstrip = s.lstrip + for x in _RANGE_1000: + s_lstrip() + + +#### replace + at bench('"This is a test".replace(" ", "\\t")', 'replace single character', + 1000) +def replace_single_character(STR): + s = STR("This is a test!") + from_str = STR(" ") + to_str = STR("\t") + s_replace = s.replace + for x in _RANGE_1000: + s_replace(from_str, to_str) + + at uses_re + at bench('re.sub(" ", "\\t", "This is a test"', 'replace single character', + 1000) +def replace_single_character_re(STR): + s = STR("This is a test!") + pat = re.compile(STR(" ")) + to_str = STR("\t") + pat_sub = pat.sub + for x in _RANGE_1000: + pat_sub(to_str, s) + + at bench('"...text.with.2000.lines...replace("\\n", " ")', + 'replace single character, big string', 10) +def replace_single_character_big(STR): + s = _get_2000_lines(STR) + from_str = STR("\n") + to_str = STR(" ") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str) + + at uses_re + at bench('re.sub("\\n", " ", "...text.with.2000.lines...")', + 'replace single character, big string', 10) +def replace_single_character_big_re(STR): + s = _get_2000_lines(STR) + pat = re.compile(STR("\n")) + to_str = STR(" ") + pat_sub = pat.sub + for x in _RANGE_10: + pat_sub(to_str, s) + + + at bench('dna.replace("ATC", "ATT")', + 'replace multiple characters, dna', 10) +def replace_multiple_characters_dna(STR): + seq = _get_dna(STR) + from_str = STR("ATC") + to_str = STR("ATT") + seq_replace = seq.replace + for x in _RANGE_10: + seq_replace(from_str, to_str) + +# This increases the character count + at bench('"...text.with.2000.newlines...replace("\\n", "\\r\\n")', + 'replace and expand multiple characters, big string', 10) +def replace_multiple_character_big(STR): + s = _get_2000_lines(STR) + from_str = STR("\n") + to_str = STR("\r\n") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str) + + +# This decreases the character count + at bench('"When shall we three meet again?".replace("ee", "")', + 'replace/remove multiple characters', 1000) +def replace_multiple_character_remove(STR): + s = STR("When shall we three meet again?") + from_str = STR("ee") + to_str = STR("") + s_replace = s.replace + for x in _RANGE_1000: + s_replace(from_str, to_str) + + +big_s = "A" + ("Z"*128*1024) +big_s_unicode = unicode(big_s) +def _get_big_s(STR): + if STR is unicode: return big_s_unicode + if STR is str: return big_s + raise AssertionError + +# The older replace implementation counted all matches in +# the string even when it only neeed to make one replacement. + at bench('("A" + ("Z"*128*1024)).replace("A", "BB", 1)', + 'quick replace single character match', 10) +def quick_replace_single_match(STR): + s = _get_big_s(STR) + from_str = STR("A") + to_str = STR("BB") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str, 1) + + at bench('("A" + ("Z"*128*1024)).replace("AZZ", "BBZZ", 1)', + 'quick replace multiple character match', 10) +def quick_replace_multiple_match(STR): + s = _get_big_s(STR) + from_str = STR("AZZ") + to_str = STR("BBZZ") + s_replace = s.replace + for x in _RANGE_10: + s_replace(from_str, to_str, 1) + + +#### + +# CCP does a lot of this, for internationalisation of ingame messages. +_format = "The %(thing)s is %(place)s the %(location)s." +_format_dict = { "thing":"THING", "place":"PLACE", "location":"LOCATION", } +_format_unicode = unicode(_format) +_format_dict_unicode = dict([ (unicode(k), unicode(v)) for (k,v) in _format_dict.iteritems() ]) + +def _get_format(STR): + if STR is unicode: + return _format_unicode + if STR is str: + return _format + raise AssertionError + +def _get_format_dict(STR): + if STR is unicode: + return _format_dict_unicode + if STR is str: + return _format_dict + raise AssertionError + +# Formatting. + at bench('"The %(k1)s is %(k2)s the %(k3)s."%{"k1":"x","k2":"y","k3":"z",}', + 'formatting a string type with a dict', 1000) +def format_with_dict(STR): + s = _get_format(STR) + d = _get_format_dict(STR) + for x in _RANGE_1000: + s % d + + +#### Upper- and lower- case conversion + + at bench('("Where in the world is Carmen San Deigo?"*10).lower()', + "case conversion -- rare", 1000) +def lower_conversion_rare(STR): + s = STR("Where in the world is Carmen San Deigo?"*10) + s_lower = s.lower + for x in _RANGE_1000: + s_lower() + + at bench('("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower()', + "case conversion -- dense", 1000) +def lower_conversion_dense(STR): + s = STR("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10) + s_lower = s.lower + for x in _RANGE_1000: + s_lower() + + + at bench('("wHERE IN THE WORLD IS cARMEN sAN dEIGO?"*10).upper()', + "case conversion -- rare", 1000) +def upper_conversion_rare(STR): + s = STR("Where in the world is Carmen San Deigo?"*10) + s_upper = s.upper + for x in _RANGE_1000: + s_upper() + + at bench('("where in the world is carmen san deigo?"*10).upper()', + "case conversion -- dense", 1000) +def upper_conversion_dense(STR): + s = STR("where in the world is carmen san deigo?"*10) + s_upper = s.upper + for x in _RANGE_1000: + s_upper() + + +# end of benchmarks + +################# + +class BenchTimer(timeit.Timer): + def best(self, repeat=1): + for i in range(1, 10): + number = 10**i + try: + x = self.timeit(number) + except: + self.print_exc() + raise + if x > 0.2: + break + times = [x] + for i in range(1, repeat): + times.append(self.timeit(number)) + return min(times) / number + +def main(): + (options, test_names) = parser.parse_args() + if options.str_only and options.unicode_only: + raise SystemExit("Only one of --8-bit and --unicode are allowed") + + bench_functions = [] + for (k,v) in globals().items(): + if hasattr(v, "is_bench"): + if test_names: + for name in test_names: + if name in v.group: + break + else: + # Not selected, ignore + continue + if options.skip_re and hasattr(v, "uses_re"): + continue + + bench_functions.append( (v.group, k, v) ) + bench_functions.sort() + + print "string\tunicode" + print "(in ms)\t(in ms)\t%\tcomment" + + str_total = uni_total = 0.0 + + for title, group in itertools.groupby(bench_functions, + operator.itemgetter(0)): + print 'class', title.replace(' ', '_').replace('-', '_') + '_Str', '(Test):' + print ' def test(self):' + groupList = list(group) + for g in groupList: + s = repr(g).split('= 2: print 'Running tests...' first = None passResults = [] - while len(passResults) < 5: + while len(passResults) < 1: latest = test.run() passResults.append(latest) if first == None: first = latest From python-checkins at python.org Sat May 27 18:34:51 2006 From: python-checkins at python.org (martin.blais) Date: Sat, 27 May 2006 18:34:51 +0200 (CEST) Subject: [Python-checkins] r46480 - sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060527163451.A540A1E4006@bag.python.org> Author: martin.blais Date: Sat May 27 18:34:51 2006 New Revision: 46480 Modified: sandbox/trunk/hotbuffer/test_hotbuf.py Log: Longer netstrings test Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sat May 27 18:34:51 2006 @@ -567,6 +567,8 @@ packed_netstrings += netstring + + #--------------------------------------------------------------------------- def _test_detect_boundary( self ): @@ -579,7 +581,6 @@ and prepare to reprocess a partially processed item in case this happens. """ - while 1: # Catch when we hit the boundary. try: @@ -615,6 +616,12 @@ s = read(len(hot)) if not s: break # Finished the input, exit. + hot.putstr(s) + hot.flip() + + + + #--------------------------------------------------------------------------- def _test_multiple_sockets( self ): """ From python-checkins at python.org Sat May 27 18:35:15 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:35:15 +0200 (CEST) Subject: [Python-checkins] r46481 - python/branches/tim-doctest-branch Message-ID: <20060527163515.A4D7F1E4006@bag.python.org> Author: tim.peters Date: Sat May 27 18:35:15 2006 New Revision: 46481 Removed: python/branches/tim-doctest-branch/ Log: This was all merged into the trunk long ago. From python-checkins at python.org Sat May 27 18:35:31 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 27 May 2006 18:35:31 +0200 (CEST) Subject: [Python-checkins] r46482 - python/branches/release24-maint/Doc/ref/ref5.tex Message-ID: <20060527163531.A0BDD1E4006@bag.python.org> Author: george.yoshida Date: Sat May 27 18:35:31 2006 New Revision: 46482 Modified: python/branches/release24-maint/Doc/ref/ref5.tex Log: minor markup nits Modified: python/branches/release24-maint/Doc/ref/ref5.tex ============================================================================== --- python/branches/release24-maint/Doc/ref/ref5.tex (original) +++ python/branches/release24-maint/Doc/ref/ref5.tex Sat May 27 18:35:31 2006 @@ -392,7 +392,8 @@ A slicing selects a range of items in a sequence object (e.g., a string, tuple or list). Slicings may be used as expressions or as -targets in assignment or del statements. The syntax for a slicing: +targets in assignment or \keyword{del} statements. The syntax for a +slicing: \obindex{sequence} \obindex{string} \obindex{tuple} From python-checkins at python.org Sat May 27 18:36:22 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:36:22 +0200 (CEST) Subject: [Python-checkins] r46483 - python/branches/sreifschneider-newnewexcept Message-ID: <20060527163622.357651E400C@bag.python.org> Author: tim.peters Date: Sat May 27 18:36:21 2006 New Revision: 46483 Removed: python/branches/sreifschneider-newnewexcept/ Log: This was merged to the trunk. From python-checkins at python.org Sat May 27 18:37:02 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:37:02 +0200 (CEST) Subject: [Python-checkins] r46484 - python/branches/rjones-funccall Message-ID: <20060527163702.51F421E4006@bag.python.org> Author: tim.peters Date: Sat May 27 18:37:02 2006 New Revision: 46484 Removed: python/branches/rjones-funccall/ Log: This was merged to the trunk. From python-checkins at python.org Sat May 27 18:39:19 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:39:19 +0200 (CEST) Subject: [Python-checkins] r46485 - python/branches/steve-notracing Message-ID: <20060527163919.86B8A1E4006@bag.python.org> Author: tim.peters Date: Sat May 27 18:39:19 2006 New Revision: 46485 Removed: python/branches/steve-notracing/ Log: This is adequately reproduced by a patch on SF. From python-checkins at python.org Sat May 27 18:41:20 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:41:20 +0200 (CEST) Subject: [Python-checkins] r46486 - python/branches/runar-longslice-branch Message-ID: <20060527164120.72CC31E4006@bag.python.org> Author: tim.peters Date: Sat May 27 18:41:20 2006 New Revision: 46486 Removed: python/branches/runar-longslice-branch/ Log: The string->integer part was already committed, and we're not going to actively pursue the other parts now. From python-checkins at python.org Sat May 27 18:48:06 2006 From: python-checkins at python.org (tim.peters) Date: Sat, 27 May 2006 18:48:06 +0200 (CEST) Subject: [Python-checkins] r46487 - python/branches/bippolito-newstruct Message-ID: <20060527164806.BFDD91E4006@bag.python.org> Author: tim.peters Date: Sat May 27 18:48:06 2006 New Revision: 46487 Removed: python/branches/bippolito-newstruct/ Log: This work was merged to the trunk. From python-checkins at python.org Sat May 27 18:51:46 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 27 May 2006 18:51:46 +0200 (CEST) Subject: [Python-checkins] r46488 - python/trunk/Doc/ref/ref5.tex Message-ID: <20060527165146.158E61E4006@bag.python.org> Author: george.yoshida Date: Sat May 27 18:51:43 2006 New Revision: 46488 Modified: python/trunk/Doc/ref/ref5.tex Log: End of Ch.3 is now about "with statement". Avoid obsolescence by directly referring to the section. Modified: python/trunk/Doc/ref/ref5.tex ============================================================================== --- python/trunk/Doc/ref/ref5.tex (original) +++ python/trunk/Doc/ref/ref5.tex Sat May 27 18:51:43 2006 @@ -22,9 +22,9 @@ When a description of an arithmetic operator below uses the phrase ``the numeric arguments are converted to a common type,'' the -arguments are coerced using the coercion rules listed at the end of -chapter \ref{datamodel}. If both arguments are standard numeric -types, the following coercions are applied: +arguments are coerced using the coercion rules listed at +~\ref{coercion-rules}. If both arguments are standard numeric types, +the following coercions are applied: \begin{itemize} \item If either argument is a complex number, the other is converted From python-checkins at python.org Sat May 27 19:09:18 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 27 May 2006 19:09:18 +0200 (CEST) Subject: [Python-checkins] r46489 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060527170918.78B591E4006@bag.python.org> Author: george.yoshida Date: Sat May 27 19:09:17 2006 New Revision: 46489 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: fix typo Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat May 27 19:09:17 2006 @@ -1583,7 +1583,7 @@ \item The \module{unicodedata} module has been updated to use version 4.1.0 of the Unicode character database. Version 3.2.0 is required by some specifications, so it's still available as -\member{unicodedata.db_3_2_0}. +\member{unicodedata.ucd_3_2_0}. \item The \module{webbrowser} module received a number of enhancements. From python-checkins at python.org Sat May 27 20:19:22 2006 From: python-checkins at python.org (thomas.wouters) Date: Sat, 27 May 2006 20:19:22 +0200 (CEST) Subject: [Python-checkins] r46490 - python/branches/p3yk Message-ID: <20060527181922.EE5271E4006@bag.python.org> Author: thomas.wouters Date: Sat May 27 20:19:22 2006 New Revision: 46490 Modified: python/branches/p3yk/ (props changed) Log: Prep for initial svnmerge.py run. From neal at metaslash.com Sat May 27 23:06:11 2006 From: neal at metaslash.com (Neal Norwitz) Date: Sat, 27 May 2006 17:06:11 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (101) Message-ID: <20060527210611.GA16985@python.psfb.org> test_builtin leaked [130, 130, 130] references test_exceptions leaked [77, 77, 77] references test_anydbm leaked [84, 84, 84] references test_bisect leaked [144, 144, 144] references test_bz2 leaked [6, 6, 6] references test_cfgparser leaked [18, 18, 18] references test_charmapcodec leaked [5, 5, 5] references test_code leaked [24, 24, 24] references test_codeccallbacks leaked [10772, 10772, 10772] references test_codecencodings_cn leaked [282, 282, 282] references test_codecencodings_hk leaked [96, 96, 96] references test_codecencodings_jp leaked [490, 490, 490] references test_codecencodings_kr leaked [288, 288, 288] references test_codecencodings_tw leaked [96, 96, 96] references test_codecmaps_cn leaked [18, 18, 18] references test_codecmaps_hk leaked [9, 9, 9] references test_codecmaps_jp leaked [45, 45, 45] references test_codecmaps_kr leaked [27, 27, 27] references test_codecmaps_tw leaked [18, 18, 18] references test_codecs leaked [445, 445, 445] references test_codeop leaked [873, 873, 873] references test_coding leaked [20, 20, 20] references test_compile leaked [245, 245, 245] references test_contextlib leaked [3, 3, 3] references test_cookie leaked [222, 222, 222] references test_cookielib leaked [12, 12, 12] references test_csv leaked [9, 9, 9] references test_dbm leaked [21, 21, 21] references test_decimal leaked [834, 834, 834] references test_decorators leaked [20, 20, 20] references test_deque leaked [306, 306, 306] references test_descrtut leaked [168, 168, 168] references test_difflib leaked [126, 126, 126] references test_dircache leaked [6, 6, 6] references test_distutils leaked [60, 60, 60] references test_doctest leaked [2091, 2091, 2091] references test_doctest2 leaked [72, 72, 72] references test_dumbdbm leaked [153, 153, 153] references test_dummy_thread leaked [1, 1, 1] references test_email leaked [1271, 1271, 1271] references test_email_renamed leaked [1271, 1271, 1271] references test_eof leaked [10, 10, 10] references test_file leaked [6, 6, 6] references test_filecmp leaked [3, 3, 3] references test_fileinput leaked [24, 24, 24] references test_future leaked [15, 15, 15] references test_generators leaked [179, 179, 179] references test_genexps leaked [38, 38, 38] references test_getargs leaked [5, 5, 5] references test_getopt leaked [18, 18, 18] references test_gettext leaked [168, 168, 168] references test_glob leaked [174, 174, 174] references test_itertools leaked [516, 516, 516] references test_mailbox leaked [1575, 1575, 1575] references test_mhlib leaked [204, 204, 204] references test_minidom leaked [5, 5, 5] references test_mmap leaked [3, 3, 3] references test_multibytecodec leaked [40, 40, 40] references test_normalization leaked [3, 3, 3] references test_os leaked [30, 30, 30] references test_parser leaked [5, 5, 5] references test_pep352 leaked [28, 28, 28] references test_pickle leaked [618, 618, 618] references test_pickletools leaked [186, 186, 186] references test_pkgimport leaked [20, 20, 20] references test_platform leaked [9, 9, 9] references test_poll leaked [3, 3, 3] references test_posix leaked [3, 3, 3] references test_posixpath leaked [42, 42, 42] references test_pty leaked [3, 3, 3] references test_resource leaked [3, 3, 3] references test_rgbimg leaked [111, 111, 111] references test_runpy leaked [9, 9, 9] references test_sets leaked [6, 6, 6] references test_shelve leaked [972, 972, 972] references test_shutil leaked [21, 21, 21] references test_site leaked [45, 45, 45] references test_socket leaked [1, 1, 1] references test_sqlite leaked [27, 27, 27] references test_struct leaked [-4, -4, -4] references test_subprocess leaked [9, 9, 9] references test_syntax leaked [276, 276, 276] references test_tarfile leaked [249, 249, 249] references test_tempfile leaked [318, 318, 318] references test_threadedtempfile leaked [0, 0, -10] references test_threading_local leaked [-79, 12, 12] references test_tokenize leaked [30, 30, 30] references test_traceback leaked [21, 21, 21] references test_ucn leaked [20, 20, 20] references test_unicode leaked [84, 84, 84] references test_unittest leaked [18, 18, 18] references test_unpack leaked [18, 18, 18] references test_urllib leaked [10, 10, 10] references test_urllib2 leaked [1250, 997, 1074] references test_urllib2net leaked [23, 23, 23] references test_urllibnet leaked [14, 14, 14] references test_uu leaked [6, 6, 6] references test_weakref leaked [480, 480, 480] references test_whichdb leaked [69, 69, 69] references test_with leaked [30, 30, 30] references test_xml_etree leaked [214, 214, 214] references test_xml_etree_c leaked [199, 199, 199] references test_xmlrpc leaked [50, 50, 50] references test_zipfile leaked [3, 3, 3] references test_zipimport leaked [60, 60, 60] references test_ctypes leaked [64, 64, 64] references test_inspect leaked [6, 6, 6] references test_grammar leaked [55, 55, 55] references From python-checkins at python.org Sun May 28 01:42:24 2006 From: python-checkins at python.org (barry.warsaw) Date: Sun, 28 May 2006 01:42:24 +0200 (CEST) Subject: [Python-checkins] r46492 - in sandbox/trunk/emailpkg: 2_5 3_0 4_0 4_0/email Message-ID: <20060527234224.3BA131E4004@bag.python.org> Author: barry.warsaw Date: Sun May 28 01:42:23 2006 New Revision: 46492 Removed: sandbox/trunk/emailpkg/4_0/email/ Modified: sandbox/trunk/emailpkg/2_5/ (props changed) sandbox/trunk/emailpkg/3_0/ (props changed) sandbox/trunk/emailpkg/4_0/ (props changed) Log: Change svn;externals links to use unauthenticated http urls. Also link 4_0/email to the Python trunk as an external. From python-checkins at python.org Sun May 28 01:47:33 2006 From: python-checkins at python.org (barry.warsaw) Date: Sun, 28 May 2006 01:47:33 +0200 (CEST) Subject: [Python-checkins] r46493 - in sandbox/trunk/emailpkg: 2_5 3_0 4_0 Message-ID: <20060527234733.C22531E4004@bag.python.org> Author: barry.warsaw Date: Sun May 28 01:47:33 2006 New Revision: 46493 Modified: sandbox/trunk/emailpkg/2_5/ (props changed) sandbox/trunk/emailpkg/3_0/ (props changed) sandbox/trunk/emailpkg/4_0/ (props changed) Log: Oops! Fix http urls From python-checkins at python.org Sun May 28 02:36:45 2006 From: python-checkins at python.org (matt.fleming) Date: Sun, 28 May 2006 02:36:45 +0200 (CEST) Subject: [Python-checkins] r46494 - sandbox/trunk/pdb/README.txt sandbox/trunk/pdb/mpdb.py Message-ID: <20060528003645.38FD11E4004@bag.python.org> Author: matt.fleming Date: Sun May 28 02:36:42 2006 New Revision: 46494 Added: sandbox/trunk/pdb/README.txt Modified: sandbox/trunk/pdb/mpdb.py Log: Pdb uses a simpe socket-based implementation to attach a debugger console to a debugee. Added: sandbox/trunk/pdb/README.txt ============================================================================== --- (empty file) +++ sandbox/trunk/pdb/README.txt Sun May 28 02:36:42 2006 @@ -0,0 +1,21 @@ +-=[Pdb Improvements]=- + +-=[Author: Matt Fleming ]=- +-=[Mentor: Robert L. Bernstein]=- + +-=[Abstract]=- +This project is part of a Google Summer of Code 2006 project. Many people +have stated that they would like to see improvements in pdb. This projects +aims to correct this wish. + +-=[TODO]=- +* make help command work +* sort out the namespace corruption - + """ + c:\soc\pdb\test.py(3)x() + -> print c[i+1], i + (MPdb)p i + *** NameError: + """ + + Modified: sandbox/trunk/pdb/mpdb.py ============================================================================== --- sandbox/trunk/pdb/mpdb.py (original) +++ sandbox/trunk/pdb/mpdb.py Sun May 28 02:36:42 2006 @@ -1,36 +1,248 @@ -# Matt's Pdb Improvements +# Pdb Improvements +# +# This is a Google Summer of Code project +# Student: Matthew J. Fleming +# Mentor: Robert L. Bernstein + +import cmd import os +from optparse import OptionParser import pdb +import socket +import sys +import traceback +import thread + +# Need custom safe Repr just like pdb +_saferepr = pdb._repr.repr +line_prefix = '\n-> ' class MPdb(pdb.Pdb): def __init__(self): pdb.Pdb.__init__(self) - self._pid = os.getpid() # This debugger's pid - self.current_pid = self._pid # The pid of the process we're debugging + self.fd = sys.stdout # The file descriptor we're writing output to + self.prompt = '(MPdb)' + + def read(self): + """ Read a line from our input stream/socket. """ + try: + line = raw_input(self.prompt) + except EOFError: + line = 'EOF' + return line + +class DebuggerConsoleConnected(Exception): pass + +# Below are the classes that allow MPdb instances to be debugged locally and +# remotely by a debugger running in a different process +class MPdbServer(MPdb): + def __init__(self): + MPdb.__init__(self) + self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.debugger_list = [] + self.attached = False + + def listen(self, port): + self.port = port + self._sock.bind((self.host, self.port)) + self._sock.listen(1) # Only one debugger is allowed control + self.thread_handle = thread.start_new_thread(self.accept, ()) + + def accept(self): + c, a = self._sock.accept() + print "\n\nDebugger attached..\n" + self.debugger_list.append((c,a)) + self.fd = self.debugger_list[-1][0].makefile("w") + self.attached = True + # We've got a debugger console attached so we hijack stdout + self.old_stdout = os.dup(1) + os.close(1) + sys.stdout = self.fd + # XXX Need a way to enter the current 'waiting' on stdin for input + # and start reading from the debugger console - def attach(self, pid): - """ Attach the debugger to a running process. """ - self.attach_pid = pid - print >> self.stdout, "Attaching to pid: %d" % self.attach_pid - - def do_attach(self, pid): - print >> self.stdout, "Attaching" - self.attach(pid) - - def do_detach(self): - print >> self.stdout, "Detaching from running process" - self.current_pid = self._pid - - def do_info(self, args): - if not args: - print >>self.stdout, "Info [args]" + def cmdloop(self): + self.preloop() + stop = None + while not stop: + if self.cmdqueue: + line = self.cmdqueue.pop(0) + else: + line = self.read() + if not len(line): + line = 'EOF' + line = self.precmd(line) + stop = self.onecmd(line) + stop = self.postcmd(stop, line) + # Force stdout flush its contents + sys.stdout.flush() + self.postloop() + + def read(self): + # We need to check whether we've actually been attached to yet + if self.attached: + line = self.debugger_list[-1][0].recv(1024) + return line else: - print >> self.stdout, "Current PID = %d" % self._pid + line = raw_input(self.prompt) + return line + +class LMPdbServer(MPdbServer): + """ A local debugee which can only communicate with a debugger running + on the localhost. + """ + def __init__(self): + MPdbServer.__init__(self) + self.host = 'localhost' - do_i = do_info +class MPdbConsole(cmd.Cmd): + def __init__(self): + cmd.Cmd.__init__(self, stdin=None, stdout=None) + self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.attached = False + self.prompt = '(MPdb)' + self.lastcmd = "" + + def connect(self, host, port): + self._sock.connect((host, port)) + self.th_r = thread.start_new_thread(self.recv, ()) + + def do_attach(self, args): + if self.attached: + print "Already attached to a debugger.." + return None + h = args.split(" ") + self.connect(h[0], int(h[1])) + print "Attaching..\n" + self.attached = True + + def help_attach(self): + print """attach [host] [port] + Attach to a debugging session at [host] on [port].""" + + def cmdloop(self): + """ Repeatedly issue a prompt and accept input from a debugger + console. All commands (apart from the 'attach' and 'help' commands) + are sent to an attached debugee. + """ + print self.prompt, + stop = None + while not stop: + line = self.input() + if not len(line): + line = 'EOF' + if self.attached: + self.send(line) + else: + if 'attach' in line: + line = line.split(' ') + line = line[1:] + line = line[0] + " " + line[1] + self.do_attach(line) + elif 'help' in line: + self.help_attach() + else: + print "Not currently attached to a debugger..\n" + continue + self.postloop() + + def send(self, line): + """ Send the line to the debugee server for parsing and execution. """ + self._sock.send(line) + + def input(self): + """ This method will be changed later. """ + line = raw_input() + # Hitting enter repeatedly should execute the last command + if line is not '': + self.lastcmd = line + elif line is '': + if self.lastcmd is '': + print "No previous command.. \n" + line = 'EOF' + else: + line = self.lastcmd + return line + + def recv(self): + """ Receive all data being sent from the debugee. """ + while 1: + data = self._sock.recv(1024) + if data: + print data, + print self.prompt, + + def close(self): + self._sock.close() + +def main(options): + opts = options[0] + args = options[1] + if not args: + print 'usage: mpdb.py scriptfile [arg] ... ' + sys.exit(1) + mainpyfile = args[0] + if not os.path.exists(mainpyfile): + print 'Error:', mainpyfile, 'does not exist' + sys.exit(1) + if opts.debugger: + # We may be local or remote but we're still a debugger console + # This console acts differently to everything else, for now, it's just + # a glorified telnet client that works _properly_ with our server + mpdb = MPdbConsole() + # All we can actually do is issue commands and receieve the result + mpdb.cmdloop() + else: + if opts.local_debugee: + mpdb = LMPdbServer() + mpdb.listen(7000) + elif opts.remote_debugee: + pass + else: + # Regular interactive debugger session + mpdb = MPdb() + while 1: + try: + mpdb._runscript(mainpyfile) + if mpdb._user_requested_quit: + break + print "The program finished and will be restarted" + except SystemExit: + # In most cases SystemExit does not warrant a post-mortem session. + print "The program exited via sys.exit(). " + \ + "Exit status:",sys.exc_info()[1] + except: + print traceback.format_exc() + print "Uncaught exception. Entering post mortem debugging" + print "Running 'cont' or 'step' will restart the program" + t = sys.exc_info()[2] + while t.tb_next is not None: + t = t.tb_next + mpdb.interaction(t.tb_frame,t) + print "Post mortem debugger finished. The " + \ + mainpyfile + " will be restarted" + +# A utility function to parse the options from the command line +def parse_opts(): + parser = OptionParser() + parser.add_option("-s", "--script", dest="scriptname", + help="The script to debug") + parser.add_option("-l", "--local-debugee", dest="local_debugee", + action="store_true", + help="This script is to be debugged locally, from " + \ + "another process") + parser.add_option("-r", "--remote-debugee", dest="remote_debugee", + action="store_true", + help="This script is to be debugged by a remote " + \ + "debugger") + parser.add_option("-d", "--debugger", dest="debugger", + action="store_true", + help="Invoke the debugger.") + (options, args) = parser.parse_args() + # We don't currently support any arguments + return (options,args) + +if __name__ == '__main__': + main(parse_opts()) - def help_info(self): - print >> self.stdout, """i(nfo) -Displays information about [args]""" - help_i = help_info From python-checkins at python.org Sun May 28 03:52:41 2006 From: python-checkins at python.org (tim.peters) Date: Sun, 28 May 2006 03:52:41 +0200 (CEST) Subject: [Python-checkins] r46495 - in python/trunk: PCbuild8/_bsddb.vcproj PCbuild8/_ctypes.vcproj PCbuild8/_ctypes_test.vcproj PCbuild8/_elementtree.vcproj PCbuild8/_msi.vcproj PCbuild8/_socket.vcproj PCbuild8/_sqlite3.vcproj PCbuild8/_ssl.vcproj PCbuild8/_testcapi.vcproj PCbuild8/_tkinter.vcproj PCbuild8/build_ssl.py PCbuild8/bz2.vcproj PCbuild8/field3.py PCbuild8/make_buildinfo.c PCbuild8/make_buildinfo.vcproj PCbuild8/make_versioninfo.vcproj PCbuild8/pcbuild.sln PCbuild8/pyexpat.vcproj PCbuild8/python.vcproj PCbuild8/pythoncore.vcproj PCbuild8/pythoncore_link.txt PCbuild8/pythoncore_pgo.vcproj PCbuild8/pythoncore_pgo_link.txt PCbuild8/pythonw.vcproj PCbuild8/readme.txt PCbuild8/rmpyc.py PCbuild8/select.vcproj PCbuild8/unicodedata.vcproj PCbuild8/w9xpopen.vcproj PCbuild8/winsound.vcproj Tools/pybench/NewInstances.py Message-ID: <20060528015241.4C0691E4004@bag.python.org> Author: tim.peters Date: Sun May 28 03:52:38 2006 New Revision: 46495 Modified: python/trunk/PCbuild8/_bsddb.vcproj (contents, props changed) python/trunk/PCbuild8/_ctypes.vcproj (contents, props changed) python/trunk/PCbuild8/_ctypes_test.vcproj (contents, props changed) python/trunk/PCbuild8/_elementtree.vcproj (contents, props changed) python/trunk/PCbuild8/_msi.vcproj (contents, props changed) python/trunk/PCbuild8/_socket.vcproj (contents, props changed) python/trunk/PCbuild8/_sqlite3.vcproj (contents, props changed) python/trunk/PCbuild8/_ssl.vcproj (contents, props changed) python/trunk/PCbuild8/_testcapi.vcproj (contents, props changed) python/trunk/PCbuild8/_tkinter.vcproj (contents, props changed) python/trunk/PCbuild8/build_ssl.py (contents, props changed) python/trunk/PCbuild8/bz2.vcproj (contents, props changed) python/trunk/PCbuild8/field3.py (contents, props changed) python/trunk/PCbuild8/make_buildinfo.c (contents, props changed) python/trunk/PCbuild8/make_buildinfo.vcproj (contents, props changed) python/trunk/PCbuild8/make_versioninfo.vcproj (contents, props changed) python/trunk/PCbuild8/pcbuild.sln (contents, props changed) python/trunk/PCbuild8/pyexpat.vcproj (contents, props changed) python/trunk/PCbuild8/python.vcproj (contents, props changed) python/trunk/PCbuild8/pythoncore.vcproj (contents, props changed) python/trunk/PCbuild8/pythoncore_link.txt (contents, props changed) python/trunk/PCbuild8/pythoncore_pgo.vcproj (contents, props changed) python/trunk/PCbuild8/pythoncore_pgo_link.txt (contents, props changed) python/trunk/PCbuild8/pythonw.vcproj (contents, props changed) python/trunk/PCbuild8/readme.txt (contents, props changed) python/trunk/PCbuild8/rmpyc.py (contents, props changed) python/trunk/PCbuild8/select.vcproj (contents, props changed) python/trunk/PCbuild8/unicodedata.vcproj (contents, props changed) python/trunk/PCbuild8/w9xpopen.vcproj (contents, props changed) python/trunk/PCbuild8/winsound.vcproj (contents, props changed) python/trunk/Tools/pybench/NewInstances.py (props changed) Log: Added missing svn:eol-style property to text files. Modified: python/trunk/PCbuild8/_bsddb.vcproj ============================================================================== --- python/trunk/PCbuild8/_bsddb.vcproj (original) +++ python/trunk/PCbuild8/_bsddb.vcproj Sun May 28 03:52:38 2006 @@ -1,385 +1,385 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_ctypes.vcproj ============================================================================== --- python/trunk/PCbuild8/_ctypes.vcproj (original) +++ python/trunk/PCbuild8/_ctypes.vcproj Sun May 28 03:52:38 2006 @@ -1,408 +1,408 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_ctypes_test.vcproj ============================================================================== --- python/trunk/PCbuild8/_ctypes_test.vcproj (original) +++ python/trunk/PCbuild8/_ctypes_test.vcproj Sun May 28 03:52:38 2006 @@ -1,367 +1,367 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_elementtree.vcproj ============================================================================== --- python/trunk/PCbuild8/_elementtree.vcproj (original) +++ python/trunk/PCbuild8/_elementtree.vcproj Sun May 28 03:52:38 2006 @@ -1,390 +1,390 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_msi.vcproj ============================================================================== --- python/trunk/PCbuild8/_msi.vcproj (original) +++ python/trunk/PCbuild8/_msi.vcproj Sun May 28 03:52:38 2006 @@ -1,375 +1,375 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_socket.vcproj ============================================================================== --- python/trunk/PCbuild8/_socket.vcproj (original) +++ python/trunk/PCbuild8/_socket.vcproj Sun May 28 03:52:38 2006 @@ -1,381 +1,381 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_sqlite3.vcproj ============================================================================== --- python/trunk/PCbuild8/_sqlite3.vcproj (original) +++ python/trunk/PCbuild8/_sqlite3.vcproj Sun May 28 03:52:38 2006 @@ -1,414 +1,414 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_ssl.vcproj ============================================================================== --- python/trunk/PCbuild8/_ssl.vcproj (original) +++ python/trunk/PCbuild8/_ssl.vcproj Sun May 28 03:52:38 2006 @@ -1,121 +1,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_testcapi.vcproj ============================================================================== --- python/trunk/PCbuild8/_testcapi.vcproj (original) +++ python/trunk/PCbuild8/_testcapi.vcproj Sun May 28 03:52:38 2006 @@ -1,374 +1,374 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/_tkinter.vcproj ============================================================================== --- python/trunk/PCbuild8/_tkinter.vcproj (original) +++ python/trunk/PCbuild8/_tkinter.vcproj Sun May 28 03:52:38 2006 @@ -1,389 +1,389 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/build_ssl.py ============================================================================== --- python/trunk/PCbuild8/build_ssl.py (original) +++ python/trunk/PCbuild8/build_ssl.py Sun May 28 03:52:38 2006 @@ -1,163 +1,163 @@ -# Script for building the _ssl module for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for _ssl.pyd itself. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PCBuild directory. -# -# it should configure and build SSL, then build the ssl Python extension -# without intervention. - -import os, sys, re - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen(perl + ' -e "use Win32;"') - fh.read() - rc = fh.close() - if rc: - continue - return perl - print "Can not find a suitable PERL:" - if perls: - print " the following perl interpreters were found:" - for p in perls: - print " ", p - print " None of these versions appear suitable for building OpenSSL" - else: - print " NO perl interpreters were found on this machine at all!" - print " Please install ActivePerl and ensure it appears on your path" - print "The Python SSL module was not built" - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - s = os.path.abspath(s) - fnames = os.listdir(s) - except os.error: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print "Found an SSL directory at '%s'" % (best_name,) - else: - print "Could not find an SSL directory in '%s'" % (sources,) - return best_name - -def main(): - debug = "-d" in sys.argv - build_all = "-a" in sys.argv - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl is None: - sys.exit(1) - - print "Found a working perl at '%s'" % (perl,) - # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("../..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \ - not os.path.isfile(os.path.join(ssl_dir, "d32.mak")): - print "Creating the makefiles..." - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.split(perl)[0] + \ - os.pathsep + \ - os.environ["PATH"] - # ms\32all.bat will reconfigure OpenSSL and then try to build - # all outputs (debug/nondebug/dll/lib). So we filter the file - # to exclude any "nmake" commands and then execute. - tempname = "ms\\32all_py.bat" - - in_bat = open("ms\\32all.bat") - temp_bat = open(tempname,"w") - while 1: - cmd = in_bat.readline() - print 'cmd', repr(cmd) - if not cmd: break - if cmd.strip()[:5].lower() == "nmake": - continue - temp_bat.write(cmd) - in_bat.close() - temp_bat.close() - os.system(tempname) - try: - os.remove(tempname) - except: - pass - - # Now run make. - print "Executing nmake over the ssl makefiles..." - if debug: - rc = os.system("nmake /nologo -f d32.mak") - if rc: - print "Executing d32.mak failed" - print rc - sys.exit(rc) - else: - rc = os.system("nmake /nologo -f 32.mak") - if rc: - print "Executing 32.mak failed" - print rc - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=%s" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) - sys.exit(rc) - -if __name__=='__main__': - main() +# Script for building the _ssl module for Windows. +# Uses Perl to setup the OpenSSL environment correctly +# and build OpenSSL, then invokes a simple nmake session +# for _ssl.pyd itself. + +# THEORETICALLY, you can: +# * Unpack the latest SSL release one level above your main Python source +# directory. It is likely you will already find the zlib library and +# any other external packages there. +# * Install ActivePerl and ensure it is somewhere on your path. +# * Run this script from the PCBuild directory. +# +# it should configure and build SSL, then build the ssl Python extension +# without intervention. + +import os, sys, re + +# Find all "foo.exe" files on the PATH. +def find_all_on_path(filename, extras = None): + entries = os.environ["PATH"].split(os.pathsep) + ret = [] + for p in entries: + fname = os.path.abspath(os.path.join(p, filename)) + if os.path.isfile(fname) and fname not in ret: + ret.append(fname) + if extras: + for p in extras: + fname = os.path.abspath(os.path.join(p, filename)) + if os.path.isfile(fname) and fname not in ret: + ret.append(fname) + return ret + +# Find a suitable Perl installation for OpenSSL. +# cygwin perl does *not* work. ActivePerl does. +# Being a Perl dummy, the simplest way I can check is if the "Win32" package +# is available. +def find_working_perl(perls): + for perl in perls: + fh = os.popen(perl + ' -e "use Win32;"') + fh.read() + rc = fh.close() + if rc: + continue + return perl + print "Can not find a suitable PERL:" + if perls: + print " the following perl interpreters were found:" + for p in perls: + print " ", p + print " None of these versions appear suitable for building OpenSSL" + else: + print " NO perl interpreters were found on this machine at all!" + print " Please install ActivePerl and ensure it appears on your path" + print "The Python SSL module was not built" + return None + +# Locate the best SSL directory given a few roots to look into. +def find_best_ssl_dir(sources): + candidates = [] + for s in sources: + try: + s = os.path.abspath(s) + fnames = os.listdir(s) + except os.error: + fnames = [] + for fname in fnames: + fqn = os.path.join(s, fname) + if os.path.isdir(fqn) and fname.startswith("openssl-"): + candidates.append(fqn) + # Now we have all the candidates, locate the best. + best_parts = [] + best_name = None + for c in candidates: + parts = re.split("[.-]", os.path.basename(c))[1:] + # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers + if len(parts) >= 4: + continue + if parts > best_parts: + best_parts = parts + best_name = c + if best_name is not None: + print "Found an SSL directory at '%s'" % (best_name,) + else: + print "Could not find an SSL directory in '%s'" % (sources,) + return best_name + +def main(): + debug = "-d" in sys.argv + build_all = "-a" in sys.argv + make_flags = "" + if build_all: + make_flags = "-a" + # perl should be on the path, but we also look in "\perl" and "c:\\perl" + # as "well known" locations + perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) + perl = find_working_perl(perls) + if perl is None: + sys.exit(1) + + print "Found a working perl at '%s'" % (perl,) + # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. + ssl_dir = find_best_ssl_dir(("../..",)) + if ssl_dir is None: + sys.exit(1) + + old_cd = os.getcwd() + try: + os.chdir(ssl_dir) + # If the ssl makefiles do not exist, we invoke Perl to generate them. + if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \ + not os.path.isfile(os.path.join(ssl_dir, "d32.mak")): + print "Creating the makefiles..." + # Put our working Perl at the front of our path + os.environ["PATH"] = os.path.split(perl)[0] + \ + os.pathsep + \ + os.environ["PATH"] + # ms\32all.bat will reconfigure OpenSSL and then try to build + # all outputs (debug/nondebug/dll/lib). So we filter the file + # to exclude any "nmake" commands and then execute. + tempname = "ms\\32all_py.bat" + + in_bat = open("ms\\32all.bat") + temp_bat = open(tempname,"w") + while 1: + cmd = in_bat.readline() + print 'cmd', repr(cmd) + if not cmd: break + if cmd.strip()[:5].lower() == "nmake": + continue + temp_bat.write(cmd) + in_bat.close() + temp_bat.close() + os.system(tempname) + try: + os.remove(tempname) + except: + pass + + # Now run make. + print "Executing nmake over the ssl makefiles..." + if debug: + rc = os.system("nmake /nologo -f d32.mak") + if rc: + print "Executing d32.mak failed" + print rc + sys.exit(rc) + else: + rc = os.system("nmake /nologo -f 32.mak") + if rc: + print "Executing 32.mak failed" + print rc + sys.exit(rc) + finally: + os.chdir(old_cd) + # And finally, we can build the _ssl module itself for Python. + defs = "SSL_DIR=%s" % (ssl_dir,) + if debug: + defs = defs + " " + "DEBUG=1" + rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) + sys.exit(rc) + +if __name__=='__main__': + main() Modified: python/trunk/PCbuild8/bz2.vcproj ============================================================================== --- python/trunk/PCbuild8/bz2.vcproj (original) +++ python/trunk/PCbuild8/bz2.vcproj Sun May 28 03:52:38 2006 @@ -1,390 +1,390 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/field3.py ============================================================================== --- python/trunk/PCbuild8/field3.py (original) +++ python/trunk/PCbuild8/field3.py Sun May 28 03:52:38 2006 @@ -1,35 +1,35 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print " * For %s," % string -print " * PY_MICRO_VERSION = %d" % micro -print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) -print " * PY_RELEASE_SERIAL = %d" % serial -print " *" - -field3 = micro * 1000 + levelnum * 10 + serial - -print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) -print " */" -print "#define FIELD3", field3 +# An absurd workaround for the lack of arithmetic in MS's resource compiler. +# After building Python, run this, then paste the output into the appropriate +# part of PC\python_nt.rc. +# Example output: +# +# * For 2.3a0, +# * PY_MICRO_VERSION = 0 +# * PY_RELEASE_LEVEL = 'alpha' = 0xA +# * PY_RELEASE_SERIAL = 1 +# * +# * and 0*1000 + 10*10 + 1 = 101. +# */ +# #define FIELD3 101 + +import sys + +major, minor, micro, level, serial = sys.version_info +levelnum = {'alpha': 0xA, + 'beta': 0xB, + 'candidate': 0xC, + 'final': 0xF, + }[level] +string = sys.version.split()[0] # like '2.3a0' + +print " * For %s," % string +print " * PY_MICRO_VERSION = %d" % micro +print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) +print " * PY_RELEASE_SERIAL = %d" % serial +print " *" + +field3 = micro * 1000 + levelnum * 10 + serial + +print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) +print " */" +print "#define FIELD3", field3 Modified: python/trunk/PCbuild8/make_buildinfo.c ============================================================================== --- python/trunk/PCbuild8/make_buildinfo.c (original) +++ python/trunk/PCbuild8/make_buildinfo.c Sun May 28 03:52:38 2006 @@ -1,92 +1,92 @@ -#include -#include -#include -#include - -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\Modules\\getbuildinfo.c instead. - - Currently, subwcrev.exe is found from the registry entries - of TortoiseSVN. - - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. - -*/ - -int make_buildinfo2() -{ - struct _stat st; - HKEY hTortoise; - char command[500]; - DWORD type, size; - if (_stat(".svn", &st) < 0) - return 0; - /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ - if (_stat("no_subwcrev", &st) == 0) - return 0; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && - RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) - /* Tortoise not installed */ - return 0; - command[0] = '"'; /* quote the path to the executable */ - size = sizeof(command) - 1; - if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || - type != REG_SZ) - /* Registry corrupted */ - return 0; - strcat(command, "bin\\subwcrev.exe"); - if (_stat(command+1, &st) < 0) - /* subwcrev.exe not part of the release */ - return 0; - strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); - puts(command); fflush(stdout); - if (system(command) < 0) - return 0; - return 1; -} - -int main(int argc, char*argv[]) -{ - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } - - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) - return EXIT_FAILURE; - return 0; +#include +#include +#include +#include + +/* This file creates the getbuildinfo.o object, by first + invoking subwcrev.exe (if found), and then invoking cl.exe. + As a side effect, it might generate PCBuild\getbuildinfo2.c + also. If this isn't a subversion checkout, or subwcrev isn't + found, it compiles ..\\Modules\\getbuildinfo.c instead. + + Currently, subwcrev.exe is found from the registry entries + of TortoiseSVN. + + No attempt is made to place getbuildinfo.o into the proper + binary directory. This isn't necessary, as this tool is + invoked as a pre-link step for pythoncore, so that overwrites + any previous getbuildinfo.o. + +*/ + +int make_buildinfo2() +{ + struct _stat st; + HKEY hTortoise; + char command[500]; + DWORD type, size; + if (_stat(".svn", &st) < 0) + return 0; + /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ + if (_stat("no_subwcrev", &st) == 0) + return 0; + if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && + RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) + /* Tortoise not installed */ + return 0; + command[0] = '"'; /* quote the path to the executable */ + size = sizeof(command) - 1; + if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || + type != REG_SZ) + /* Registry corrupted */ + return 0; + strcat(command, "bin\\subwcrev.exe"); + if (_stat(command+1, &st) < 0) + /* subwcrev.exe not part of the release */ + return 0; + strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + puts(command); fflush(stdout); + if (system(command) < 0) + return 0; + return 1; +} + +int main(int argc, char*argv[]) +{ + char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; + int do_unlink, result; + if (argc != 2) { + fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); + return EXIT_FAILURE; + } + if (strcmp(argv[1], "Release") == 0) { + strcat(command, "-MD "); + } + else if (strcmp(argv[1], "Debug") == 0) { + strcat(command, "-D_DEBUG -MDd "); + } + else if (strcmp(argv[1], "ReleaseItanium") == 0) { + strcat(command, "-MD /USECL:MS_ITANIUM "); + } + else if (strcmp(argv[1], "ReleaseAMD64") == 0) { + strcat(command, "-MD "); + strcat(command, "-MD /USECL:MS_OPTERON "); + } + else { + fprintf(stderr, "unsupported configuration %s\n", argv[1]); + return EXIT_FAILURE; + } + + if ((do_unlink = make_buildinfo2())) + strcat(command, "getbuildinfo2.c -DSUBWCREV "); + else + strcat(command, "..\\Modules\\getbuildinfo.c"); + strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC"); + puts(command); fflush(stdout); + result = system(command); + if (do_unlink) + unlink("getbuildinfo2.c"); + if (result < 0) + return EXIT_FAILURE; + return 0; } \ No newline at end of file Modified: python/trunk/PCbuild8/make_buildinfo.vcproj ============================================================================== --- python/trunk/PCbuild8/make_buildinfo.vcproj (original) +++ python/trunk/PCbuild8/make_buildinfo.vcproj Sun May 28 03:52:38 2006 @@ -1,188 +1,188 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/make_versioninfo.vcproj ============================================================================== --- python/trunk/PCbuild8/make_versioninfo.vcproj (original) +++ python/trunk/PCbuild8/make_versioninfo.vcproj Sun May 28 03:52:38 2006 @@ -1,207 +1,207 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/pcbuild.sln ============================================================================== --- python/trunk/PCbuild8/pcbuild.sln (original) +++ python/trunk/PCbuild8/pcbuild.sln Sun May 28 03:52:38 2006 @@ -1,185 +1,185 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" - ProjectSection(ProjectDependencies) = postProject - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{97239A56-DBC0-41D2-BC14-C87D9B97D63B}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "w9xpopen", "w9xpopen.vcproj", "{E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{51F35FAE-FB92-4B2C-9187-1542C065AD77}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{F22F40F4-D318-40DC-96B3-88DC81CE0894}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{8CF334D9-4F82-42EB-97AF-83592C5AFD2F}" - ProjectSection(ProjectDependencies) = postProject - {F22F40F4-D318-40DC-96B3-88DC81CE0894} = {F22F40F4-D318-40DC-96B3-88DC81CE0894} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{2FF0A312-22F9-4C34-B070-842916DE27A9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8B172265-1F31-4880-A29C-11A4B7A80172}" - ProjectSection(SolutionItems) = preProject - ..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c - readme.txt = readme.txt - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore_pgo", "pythoncore_pgo.vcproj", "{8B59C1FF-2439-4BE9-9F24-84D4982D28D4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - ReleaseAMD64|Win32 = ReleaseAMD64|Win32 - ReleaseItanium|Win32 = ReleaseItanium|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.ActiveCfg = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.Build.0 = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.ActiveCfg = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.ActiveCfg = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.Build.0 = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.ActiveCfg = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.ActiveCfg = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.Build.0 = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.ActiveCfg = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.Build.0 = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.ActiveCfg = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.ActiveCfg = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.Build.0 = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.ActiveCfg = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.ActiveCfg = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.Build.0 = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.ActiveCfg = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.ActiveCfg = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.Build.0 = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.ActiveCfg = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.Build.0 = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.ActiveCfg = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" + ProjectSection(ProjectDependencies) = postProject + {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{97239A56-DBC0-41D2-BC14-C87D9B97D63B}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "w9xpopen", "w9xpopen.vcproj", "{E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{51F35FAE-FB92-4B2C-9187-1542C065AD77}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{F22F40F4-D318-40DC-96B3-88DC81CE0894}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{8CF334D9-4F82-42EB-97AF-83592C5AFD2F}" + ProjectSection(ProjectDependencies) = postProject + {F22F40F4-D318-40DC-96B3-88DC81CE0894} = {F22F40F4-D318-40DC-96B3-88DC81CE0894} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{2FF0A312-22F9-4C34-B070-842916DE27A9}" + ProjectSection(ProjectDependencies) = postProject + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8B172265-1F31-4880-A29C-11A4B7A80172}" + ProjectSection(SolutionItems) = preProject + ..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c + readme.txt = readme.txt + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore_pgo", "pythoncore_pgo.vcproj", "{8B59C1FF-2439-4BE9-9F24-84D4982D28D4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + ReleaseAMD64|Win32 = ReleaseAMD64|Win32 + ReleaseItanium|Win32 = ReleaseItanium|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.ActiveCfg = Debug|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.Build.0 = Debug|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.ActiveCfg = Debug|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.Build.0 = Debug|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.ActiveCfg = Debug|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.Build.0 = Debug|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.Build.0 = Debug|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.Build.0 = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.ActiveCfg = Debug|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.Build.0 = Debug|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.ActiveCfg = Debug|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.Build.0 = Debug|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.ActiveCfg = Debug|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.Build.0 = Debug|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.ActiveCfg = Debug|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.Build.0 = Debug|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.ActiveCfg = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.Build.0 = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.ActiveCfg = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.Build.0 = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.Build.0 = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Modified: python/trunk/PCbuild8/pyexpat.vcproj ============================================================================== --- python/trunk/PCbuild8/pyexpat.vcproj (original) +++ python/trunk/PCbuild8/pyexpat.vcproj Sun May 28 03:52:38 2006 @@ -1,393 +1,393 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/python.vcproj ============================================================================== --- python/trunk/PCbuild8/python.vcproj (original) +++ python/trunk/PCbuild8/python.vcproj Sun May 28 03:52:38 2006 @@ -1,400 +1,400 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/pythoncore.vcproj ============================================================================== --- python/trunk/PCbuild8/pythoncore.vcproj (original) +++ python/trunk/PCbuild8/pythoncore.vcproj Sun May 28 03:52:38 2006 @@ -1,1103 +1,1103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/pythoncore_link.txt ============================================================================== --- python/trunk/PCbuild8/pythoncore_link.txt (original) +++ python/trunk/PCbuild8/pythoncore_link.txt Sun May 28 03:52:38 2006 @@ -1,311 +1,311 @@ -/OUT:"./python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\./python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\python25.pgd" /BASE:"0x1e000000" /IMPLIB:".\./python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore\adler32.obj" - -".\x86-temp-release\pythoncore\compress.obj" - -".\x86-temp-release\pythoncore\crc32.obj" - -".\x86-temp-release\pythoncore\deflate.obj" - -".\x86-temp-release\pythoncore\gzio.obj" - -".\x86-temp-release\pythoncore\infback.obj" - -".\x86-temp-release\pythoncore\inffast.obj" - -".\x86-temp-release\pythoncore\inflate.obj" - -".\x86-temp-release\pythoncore\inftrees.obj" - -".\x86-temp-release\pythoncore\trees.obj" - -".\x86-temp-release\pythoncore\uncompr.obj" - -".\x86-temp-release\pythoncore\zlibmodule.obj" - -".\x86-temp-release\pythoncore\zutil.obj" - -".\x86-temp-release\pythoncore\_bisectmodule.obj" - -".\x86-temp-release\pythoncore\_codecs_cn.obj" - -".\x86-temp-release\pythoncore\_codecs_hk.obj" - -".\x86-temp-release\pythoncore\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore\_codecs_jp.obj" - -".\x86-temp-release\pythoncore\_codecs_kr.obj" - -".\x86-temp-release\pythoncore\_codecs_tw.obj" - -".\x86-temp-release\pythoncore\_codecsmodule.obj" - -".\x86-temp-release\pythoncore\_csv.obj" - -".\x86-temp-release\pythoncore\_heapqmodule.obj" - -".\x86-temp-release\pythoncore\_hotshot.obj" - -".\x86-temp-release\pythoncore\_localemodule.obj" - -".\x86-temp-release\pythoncore\_lsprof.obj" - -".\x86-temp-release\pythoncore\_randommodule.obj" - -".\x86-temp-release\pythoncore\_sre.obj" - -".\x86-temp-release\pythoncore\_subprocess.obj" - -".\x86-temp-release\pythoncore\_weakref.obj" - -".\x86-temp-release\pythoncore\_winreg.obj" - -".\x86-temp-release\pythoncore\abstract.obj" - -".\x86-temp-release\pythoncore\acceler.obj" - -".\x86-temp-release\pythoncore\arraymodule.obj" - -".\x86-temp-release\pythoncore\asdl.obj" - -".\x86-temp-release\pythoncore\ast.obj" - -".\x86-temp-release\pythoncore\audioop.obj" - -".\x86-temp-release\pythoncore\binascii.obj" - -".\x86-temp-release\pythoncore\bitset.obj" - -".\x86-temp-release\pythoncore\bltinmodule.obj" - -".\x86-temp-release\pythoncore\boolobject.obj" - -".\x86-temp-release\pythoncore\bufferobject.obj" - -".\x86-temp-release\pythoncore\cellobject.obj" - -".\x86-temp-release\pythoncore\ceval.obj" - -".\x86-temp-release\pythoncore\classobject.obj" - -".\x86-temp-release\pythoncore\cmathmodule.obj" - -".\x86-temp-release\pythoncore\cobject.obj" - -".\x86-temp-release\pythoncore\codecs.obj" - -".\x86-temp-release\pythoncore\codeobject.obj" - -".\x86-temp-release\pythoncore\collectionsmodule.obj" - -".\x86-temp-release\pythoncore\compile.obj" - -".\x86-temp-release\pythoncore\complexobject.obj" - -".\x86-temp-release\pythoncore\config.obj" - -".\x86-temp-release\pythoncore\cPickle.obj" - -".\x86-temp-release\pythoncore\cStringIO.obj" - -".\x86-temp-release\pythoncore\datetimemodule.obj" - -".\x86-temp-release\pythoncore\descrobject.obj" - -".\x86-temp-release\pythoncore\dictobject.obj" - -".\x86-temp-release\pythoncore\dl_nt.obj" - -".\x86-temp-release\pythoncore\dynload_win.obj" - -".\x86-temp-release\pythoncore\enumobject.obj" - -".\x86-temp-release\pythoncore\errnomodule.obj" - -".\x86-temp-release\pythoncore\errors.obj" - -".\x86-temp-release\pythoncore\exceptions.obj" - -".\x86-temp-release\pythoncore\fileobject.obj" - -".\x86-temp-release\pythoncore\firstsets.obj" - -".\x86-temp-release\pythoncore\floatobject.obj" - -".\x86-temp-release\pythoncore\frameobject.obj" - -".\x86-temp-release\pythoncore\frozen.obj" - -".\x86-temp-release\pythoncore\funcobject.obj" - -".\x86-temp-release\pythoncore\functionalmodule.obj" - -".\x86-temp-release\pythoncore\future.obj" - -".\x86-temp-release\pythoncore\gcmodule.obj" - -".\x86-temp-release\pythoncore\genobject.obj" - -".\x86-temp-release\pythoncore\getargs.obj" - -".\x86-temp-release\pythoncore\getcompiler.obj" - -".\x86-temp-release\pythoncore\getcopyright.obj" - -".\x86-temp-release\pythoncore\getmtime.obj" - -".\x86-temp-release\pythoncore\getopt.obj" - -".\x86-temp-release\pythoncore\getpathp.obj" - -".\x86-temp-release\pythoncore\getplatform.obj" - -".\x86-temp-release\pythoncore\getversion.obj" - -".\x86-temp-release\pythoncore\graminit.obj" - -".\x86-temp-release\pythoncore\grammar.obj" - -".\x86-temp-release\pythoncore\grammar1.obj" - -".\x86-temp-release\pythoncore\imageop.obj" - -".\x86-temp-release\pythoncore\import.obj" - -".\x86-temp-release\pythoncore\import_nt.obj" - -".\x86-temp-release\pythoncore\importdl.obj" - -".\x86-temp-release\pythoncore\intobject.obj" - -".\x86-temp-release\pythoncore\iterobject.obj" - -".\x86-temp-release\pythoncore\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore\listnode.obj" - -".\x86-temp-release\pythoncore\listobject.obj" - -".\x86-temp-release\pythoncore\longobject.obj" - -".\x86-temp-release\pythoncore\main.obj" - -".\x86-temp-release\pythoncore\marshal.obj" - -".\x86-temp-release\pythoncore\mathmodule.obj" - -".\x86-temp-release\pythoncore\md5.obj" - -".\x86-temp-release\pythoncore\md5module.obj" - -".\x86-temp-release\pythoncore\metagrammar.obj" - -".\x86-temp-release\pythoncore\methodobject.obj" - -".\x86-temp-release\pythoncore\mmapmodule.obj" - -".\x86-temp-release\pythoncore\modsupport.obj" - -".\x86-temp-release\pythoncore\moduleobject.obj" - -".\x86-temp-release\pythoncore\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore\multibytecodec.obj" - -".\x86-temp-release\pythoncore\myreadline.obj" - -".\x86-temp-release\pythoncore\mysnprintf.obj" - -".\x86-temp-release\pythoncore\mystrtoul.obj" - -".\x86-temp-release\pythoncore\node.obj" - -".\x86-temp-release\pythoncore\object.obj" - -".\x86-temp-release\pythoncore\obmalloc.obj" - -".\x86-temp-release\pythoncore\operator.obj" - -".\x86-temp-release\pythoncore\parser.obj" - -".\x86-temp-release\pythoncore\parsermodule.obj" - -".\x86-temp-release\pythoncore\parsetok.obj" - -".\x86-temp-release\pythoncore\posixmodule.obj" - -".\x86-temp-release\pythoncore\pyarena.obj" - -".\x86-temp-release\pythoncore\pyfpe.obj" - -".\x86-temp-release\pythoncore\pystate.obj" - -".\x86-temp-release\pythoncore\pystrtod.obj" - -".\x86-temp-release\pythoncore\Python-ast.obj" - -".\x86-temp-release\pythoncore\python_nt.res" - -".\x86-temp-release\pythoncore\pythonrun.obj" - -".\x86-temp-release\pythoncore\rangeobject.obj" - -".\x86-temp-release\pythoncore\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore\rotatingtree.obj" - -".\x86-temp-release\pythoncore\setobject.obj" - -".\x86-temp-release\pythoncore\sha256module.obj" - -".\x86-temp-release\pythoncore\sha512module.obj" - -".\x86-temp-release\pythoncore\shamodule.obj" - -".\x86-temp-release\pythoncore\signalmodule.obj" - -".\x86-temp-release\pythoncore\sliceobject.obj" - -".\x86-temp-release\pythoncore\stringobject.obj" - -".\x86-temp-release\pythoncore\stropmodule.obj" - -".\x86-temp-release\pythoncore\structmember.obj" - -".\x86-temp-release\pythoncore\_struct.obj" - -".\x86-temp-release\pythoncore\structseq.obj" - -".\x86-temp-release\pythoncore\symtable.obj" - -".\x86-temp-release\pythoncore\symtablemodule.obj" - -".\x86-temp-release\pythoncore\sysmodule.obj" - -".\x86-temp-release\pythoncore\thread.obj" - -".\x86-temp-release\pythoncore\threadmodule.obj" - -".\x86-temp-release\pythoncore\timemodule.obj" - -".\x86-temp-release\pythoncore\tokenizer.obj" - -".\x86-temp-release\pythoncore\traceback.obj" - -".\x86-temp-release\pythoncore\tupleobject.obj" - -".\x86-temp-release\pythoncore\typeobject.obj" - -".\x86-temp-release\pythoncore\unicodectype.obj" - -".\x86-temp-release\pythoncore\unicodeobject.obj" - -".\x86-temp-release\pythoncore\weakrefobject.obj" - -".\x86-temp-release\pythoncore\xxsubtype.obj" - -".\x86-temp-release\pythoncore\yuvconvert.obj" - +/OUT:"./python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\./python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\python25.pgd" /BASE:"0x1e000000" /IMPLIB:".\./python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib + +".\x86-temp-release\pythoncore\adler32.obj" + +".\x86-temp-release\pythoncore\compress.obj" + +".\x86-temp-release\pythoncore\crc32.obj" + +".\x86-temp-release\pythoncore\deflate.obj" + +".\x86-temp-release\pythoncore\gzio.obj" + +".\x86-temp-release\pythoncore\infback.obj" + +".\x86-temp-release\pythoncore\inffast.obj" + +".\x86-temp-release\pythoncore\inflate.obj" + +".\x86-temp-release\pythoncore\inftrees.obj" + +".\x86-temp-release\pythoncore\trees.obj" + +".\x86-temp-release\pythoncore\uncompr.obj" + +".\x86-temp-release\pythoncore\zlibmodule.obj" + +".\x86-temp-release\pythoncore\zutil.obj" + +".\x86-temp-release\pythoncore\_bisectmodule.obj" + +".\x86-temp-release\pythoncore\_codecs_cn.obj" + +".\x86-temp-release\pythoncore\_codecs_hk.obj" + +".\x86-temp-release\pythoncore\_codecs_iso2022.obj" + +".\x86-temp-release\pythoncore\_codecs_jp.obj" + +".\x86-temp-release\pythoncore\_codecs_kr.obj" + +".\x86-temp-release\pythoncore\_codecs_tw.obj" + +".\x86-temp-release\pythoncore\_codecsmodule.obj" + +".\x86-temp-release\pythoncore\_csv.obj" + +".\x86-temp-release\pythoncore\_heapqmodule.obj" + +".\x86-temp-release\pythoncore\_hotshot.obj" + +".\x86-temp-release\pythoncore\_localemodule.obj" + +".\x86-temp-release\pythoncore\_lsprof.obj" + +".\x86-temp-release\pythoncore\_randommodule.obj" + +".\x86-temp-release\pythoncore\_sre.obj" + +".\x86-temp-release\pythoncore\_subprocess.obj" + +".\x86-temp-release\pythoncore\_weakref.obj" + +".\x86-temp-release\pythoncore\_winreg.obj" + +".\x86-temp-release\pythoncore\abstract.obj" + +".\x86-temp-release\pythoncore\acceler.obj" + +".\x86-temp-release\pythoncore\arraymodule.obj" + +".\x86-temp-release\pythoncore\asdl.obj" + +".\x86-temp-release\pythoncore\ast.obj" + +".\x86-temp-release\pythoncore\audioop.obj" + +".\x86-temp-release\pythoncore\binascii.obj" + +".\x86-temp-release\pythoncore\bitset.obj" + +".\x86-temp-release\pythoncore\bltinmodule.obj" + +".\x86-temp-release\pythoncore\boolobject.obj" + +".\x86-temp-release\pythoncore\bufferobject.obj" + +".\x86-temp-release\pythoncore\cellobject.obj" + +".\x86-temp-release\pythoncore\ceval.obj" + +".\x86-temp-release\pythoncore\classobject.obj" + +".\x86-temp-release\pythoncore\cmathmodule.obj" + +".\x86-temp-release\pythoncore\cobject.obj" + +".\x86-temp-release\pythoncore\codecs.obj" + +".\x86-temp-release\pythoncore\codeobject.obj" + +".\x86-temp-release\pythoncore\collectionsmodule.obj" + +".\x86-temp-release\pythoncore\compile.obj" + +".\x86-temp-release\pythoncore\complexobject.obj" + +".\x86-temp-release\pythoncore\config.obj" + +".\x86-temp-release\pythoncore\cPickle.obj" + +".\x86-temp-release\pythoncore\cStringIO.obj" + +".\x86-temp-release\pythoncore\datetimemodule.obj" + +".\x86-temp-release\pythoncore\descrobject.obj" + +".\x86-temp-release\pythoncore\dictobject.obj" + +".\x86-temp-release\pythoncore\dl_nt.obj" + +".\x86-temp-release\pythoncore\dynload_win.obj" + +".\x86-temp-release\pythoncore\enumobject.obj" + +".\x86-temp-release\pythoncore\errnomodule.obj" + +".\x86-temp-release\pythoncore\errors.obj" + +".\x86-temp-release\pythoncore\exceptions.obj" + +".\x86-temp-release\pythoncore\fileobject.obj" + +".\x86-temp-release\pythoncore\firstsets.obj" + +".\x86-temp-release\pythoncore\floatobject.obj" + +".\x86-temp-release\pythoncore\frameobject.obj" + +".\x86-temp-release\pythoncore\frozen.obj" + +".\x86-temp-release\pythoncore\funcobject.obj" + +".\x86-temp-release\pythoncore\functionalmodule.obj" + +".\x86-temp-release\pythoncore\future.obj" + +".\x86-temp-release\pythoncore\gcmodule.obj" + +".\x86-temp-release\pythoncore\genobject.obj" + +".\x86-temp-release\pythoncore\getargs.obj" + +".\x86-temp-release\pythoncore\getcompiler.obj" + +".\x86-temp-release\pythoncore\getcopyright.obj" + +".\x86-temp-release\pythoncore\getmtime.obj" + +".\x86-temp-release\pythoncore\getopt.obj" + +".\x86-temp-release\pythoncore\getpathp.obj" + +".\x86-temp-release\pythoncore\getplatform.obj" + +".\x86-temp-release\pythoncore\getversion.obj" + +".\x86-temp-release\pythoncore\graminit.obj" + +".\x86-temp-release\pythoncore\grammar.obj" + +".\x86-temp-release\pythoncore\grammar1.obj" + +".\x86-temp-release\pythoncore\imageop.obj" + +".\x86-temp-release\pythoncore\import.obj" + +".\x86-temp-release\pythoncore\import_nt.obj" + +".\x86-temp-release\pythoncore\importdl.obj" + +".\x86-temp-release\pythoncore\intobject.obj" + +".\x86-temp-release\pythoncore\iterobject.obj" + +".\x86-temp-release\pythoncore\itertoolsmodule.obj" + +".\x86-temp-release\pythoncore\listnode.obj" + +".\x86-temp-release\pythoncore\listobject.obj" + +".\x86-temp-release\pythoncore\longobject.obj" + +".\x86-temp-release\pythoncore\main.obj" + +".\x86-temp-release\pythoncore\marshal.obj" + +".\x86-temp-release\pythoncore\mathmodule.obj" + +".\x86-temp-release\pythoncore\md5.obj" + +".\x86-temp-release\pythoncore\md5module.obj" + +".\x86-temp-release\pythoncore\metagrammar.obj" + +".\x86-temp-release\pythoncore\methodobject.obj" + +".\x86-temp-release\pythoncore\mmapmodule.obj" + +".\x86-temp-release\pythoncore\modsupport.obj" + +".\x86-temp-release\pythoncore\moduleobject.obj" + +".\x86-temp-release\pythoncore\msvcrtmodule.obj" + +".\x86-temp-release\pythoncore\multibytecodec.obj" + +".\x86-temp-release\pythoncore\myreadline.obj" + +".\x86-temp-release\pythoncore\mysnprintf.obj" + +".\x86-temp-release\pythoncore\mystrtoul.obj" + +".\x86-temp-release\pythoncore\node.obj" + +".\x86-temp-release\pythoncore\object.obj" + +".\x86-temp-release\pythoncore\obmalloc.obj" + +".\x86-temp-release\pythoncore\operator.obj" + +".\x86-temp-release\pythoncore\parser.obj" + +".\x86-temp-release\pythoncore\parsermodule.obj" + +".\x86-temp-release\pythoncore\parsetok.obj" + +".\x86-temp-release\pythoncore\posixmodule.obj" + +".\x86-temp-release\pythoncore\pyarena.obj" + +".\x86-temp-release\pythoncore\pyfpe.obj" + +".\x86-temp-release\pythoncore\pystate.obj" + +".\x86-temp-release\pythoncore\pystrtod.obj" + +".\x86-temp-release\pythoncore\Python-ast.obj" + +".\x86-temp-release\pythoncore\python_nt.res" + +".\x86-temp-release\pythoncore\pythonrun.obj" + +".\x86-temp-release\pythoncore\rangeobject.obj" + +".\x86-temp-release\pythoncore\rgbimgmodule.obj" + +".\x86-temp-release\pythoncore\rotatingtree.obj" + +".\x86-temp-release\pythoncore\setobject.obj" + +".\x86-temp-release\pythoncore\sha256module.obj" + +".\x86-temp-release\pythoncore\sha512module.obj" + +".\x86-temp-release\pythoncore\shamodule.obj" + +".\x86-temp-release\pythoncore\signalmodule.obj" + +".\x86-temp-release\pythoncore\sliceobject.obj" + +".\x86-temp-release\pythoncore\stringobject.obj" + +".\x86-temp-release\pythoncore\stropmodule.obj" + +".\x86-temp-release\pythoncore\structmember.obj" + +".\x86-temp-release\pythoncore\_struct.obj" + +".\x86-temp-release\pythoncore\structseq.obj" + +".\x86-temp-release\pythoncore\symtable.obj" + +".\x86-temp-release\pythoncore\symtablemodule.obj" + +".\x86-temp-release\pythoncore\sysmodule.obj" + +".\x86-temp-release\pythoncore\thread.obj" + +".\x86-temp-release\pythoncore\threadmodule.obj" + +".\x86-temp-release\pythoncore\timemodule.obj" + +".\x86-temp-release\pythoncore\tokenizer.obj" + +".\x86-temp-release\pythoncore\traceback.obj" + +".\x86-temp-release\pythoncore\tupleobject.obj" + +".\x86-temp-release\pythoncore\typeobject.obj" + +".\x86-temp-release\pythoncore\unicodectype.obj" + +".\x86-temp-release\pythoncore\unicodeobject.obj" + +".\x86-temp-release\pythoncore\weakrefobject.obj" + +".\x86-temp-release\pythoncore\xxsubtype.obj" + +".\x86-temp-release\pythoncore\yuvconvert.obj" + ".\x86-temp-release\pythoncore\zipimport.obj" \ No newline at end of file Modified: python/trunk/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- python/trunk/PCbuild8/pythoncore_pgo.vcproj (original) +++ python/trunk/PCbuild8/pythoncore_pgo.vcproj Sun May 28 03:52:38 2006 @@ -1,781 +1,781 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- python/trunk/PCbuild8/pythoncore_pgo_link.txt (original) +++ python/trunk/PCbuild8/pythoncore_pgo_link.txt Sun May 28 03:52:38 2006 @@ -1,311 +1,311 @@ -/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore_pgo\adler32.obj" - -".\x86-temp-release\pythoncore_pgo\compress.obj" - -".\x86-temp-release\pythoncore_pgo\crc32.obj" - -".\x86-temp-release\pythoncore_pgo\deflate.obj" - -".\x86-temp-release\pythoncore_pgo\gzio.obj" - -".\x86-temp-release\pythoncore_pgo\infback.obj" - -".\x86-temp-release\pythoncore_pgo\inffast.obj" - -".\x86-temp-release\pythoncore_pgo\inflate.obj" - -".\x86-temp-release\pythoncore_pgo\inftrees.obj" - -".\x86-temp-release\pythoncore_pgo\trees.obj" - -".\x86-temp-release\pythoncore_pgo\uncompr.obj" - -".\x86-temp-release\pythoncore_pgo\zlibmodule.obj" - -".\x86-temp-release\pythoncore_pgo\zutil.obj" - -".\x86-temp-release\pythoncore_pgo\_bisectmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_cn.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_hk.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_jp.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_kr.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_tw.obj" - -".\x86-temp-release\pythoncore_pgo\_codecsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_csv.obj" - -".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_hotshot.obj" - -".\x86-temp-release\pythoncore_pgo\_localemodule.obj" - -".\x86-temp-release\pythoncore_pgo\_lsprof.obj" - -".\x86-temp-release\pythoncore_pgo\_randommodule.obj" - -".\x86-temp-release\pythoncore_pgo\_sre.obj" - -".\x86-temp-release\pythoncore_pgo\_struct.obj" - -".\x86-temp-release\pythoncore_pgo\_subprocess.obj" - -".\x86-temp-release\pythoncore_pgo\_weakref.obj" - -".\x86-temp-release\pythoncore_pgo\_winreg.obj" - -".\x86-temp-release\pythoncore_pgo\abstract.obj" - -".\x86-temp-release\pythoncore_pgo\acceler.obj" - -".\x86-temp-release\pythoncore_pgo\arraymodule.obj" - -".\x86-temp-release\pythoncore_pgo\asdl.obj" - -".\x86-temp-release\pythoncore_pgo\ast.obj" - -".\x86-temp-release\pythoncore_pgo\audioop.obj" - -".\x86-temp-release\pythoncore_pgo\binascii.obj" - -".\x86-temp-release\pythoncore_pgo\bitset.obj" - -".\x86-temp-release\pythoncore_pgo\bltinmodule.obj" - -".\x86-temp-release\pythoncore_pgo\boolobject.obj" - -".\x86-temp-release\pythoncore_pgo\bufferobject.obj" - -".\x86-temp-release\pythoncore_pgo\cellobject.obj" - -".\x86-temp-release\pythoncore_pgo\ceval.obj" - -".\x86-temp-release\pythoncore_pgo\classobject.obj" - -".\x86-temp-release\pythoncore_pgo\cmathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\cobject.obj" - -".\x86-temp-release\pythoncore_pgo\codecs.obj" - -".\x86-temp-release\pythoncore_pgo\codeobject.obj" - -".\x86-temp-release\pythoncore_pgo\collectionsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\compile.obj" - -".\x86-temp-release\pythoncore_pgo\complexobject.obj" - -".\x86-temp-release\pythoncore_pgo\config.obj" - -".\x86-temp-release\pythoncore_pgo\cPickle.obj" - -".\x86-temp-release\pythoncore_pgo\cStringIO.obj" - -".\x86-temp-release\pythoncore_pgo\datetimemodule.obj" - -".\x86-temp-release\pythoncore_pgo\descrobject.obj" - -".\x86-temp-release\pythoncore_pgo\dictobject.obj" - -".\x86-temp-release\pythoncore_pgo\dl_nt.obj" - -".\x86-temp-release\pythoncore_pgo\dynload_win.obj" - -".\x86-temp-release\pythoncore_pgo\enumobject.obj" - -".\x86-temp-release\pythoncore_pgo\errnomodule.obj" - -".\x86-temp-release\pythoncore_pgo\errors.obj" - -".\x86-temp-release\pythoncore_pgo\exceptions.obj" - -".\x86-temp-release\pythoncore_pgo\fileobject.obj" - -".\x86-temp-release\pythoncore_pgo\firstsets.obj" - -".\x86-temp-release\pythoncore_pgo\floatobject.obj" - -".\x86-temp-release\pythoncore_pgo\frameobject.obj" - -".\x86-temp-release\pythoncore_pgo\frozen.obj" - -".\x86-temp-release\pythoncore_pgo\funcobject.obj" - -".\x86-temp-release\pythoncore_pgo\functionalmodule.obj" - -".\x86-temp-release\pythoncore_pgo\future.obj" - -".\x86-temp-release\pythoncore_pgo\gcmodule.obj" - -".\x86-temp-release\pythoncore_pgo\genobject.obj" - -".\x86-temp-release\pythoncore_pgo\getargs.obj" - -".\x86-temp-release\pythoncore_pgo\getcompiler.obj" - -".\x86-temp-release\pythoncore_pgo\getcopyright.obj" - -".\x86-temp-release\pythoncore_pgo\getmtime.obj" - -".\x86-temp-release\pythoncore_pgo\getopt.obj" - -".\x86-temp-release\pythoncore_pgo\getpathp.obj" - -".\x86-temp-release\pythoncore_pgo\getplatform.obj" - -".\x86-temp-release\pythoncore_pgo\getversion.obj" - -".\x86-temp-release\pythoncore_pgo\graminit.obj" - -".\x86-temp-release\pythoncore_pgo\grammar.obj" - -".\x86-temp-release\pythoncore_pgo\grammar1.obj" - -".\x86-temp-release\pythoncore_pgo\imageop.obj" - -".\x86-temp-release\pythoncore_pgo\import.obj" - -".\x86-temp-release\pythoncore_pgo\import_nt.obj" - -".\x86-temp-release\pythoncore_pgo\importdl.obj" - -".\x86-temp-release\pythoncore_pgo\intobject.obj" - -".\x86-temp-release\pythoncore_pgo\iterobject.obj" - -".\x86-temp-release\pythoncore_pgo\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\listnode.obj" - -".\x86-temp-release\pythoncore_pgo\listobject.obj" - -".\x86-temp-release\pythoncore_pgo\longobject.obj" - -".\x86-temp-release\pythoncore_pgo\main.obj" - -".\x86-temp-release\pythoncore_pgo\marshal.obj" - -".\x86-temp-release\pythoncore_pgo\mathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\md5.obj" - -".\x86-temp-release\pythoncore_pgo\md5module.obj" - -".\x86-temp-release\pythoncore_pgo\metagrammar.obj" - -".\x86-temp-release\pythoncore_pgo\methodobject.obj" - -".\x86-temp-release\pythoncore_pgo\mmapmodule.obj" - -".\x86-temp-release\pythoncore_pgo\modsupport.obj" - -".\x86-temp-release\pythoncore_pgo\moduleobject.obj" - -".\x86-temp-release\pythoncore_pgo\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore_pgo\multibytecodec.obj" - -".\x86-temp-release\pythoncore_pgo\myreadline.obj" - -".\x86-temp-release\pythoncore_pgo\mysnprintf.obj" - -".\x86-temp-release\pythoncore_pgo\mystrtoul.obj" - -".\x86-temp-release\pythoncore_pgo\node.obj" - -".\x86-temp-release\pythoncore_pgo\object.obj" - -".\x86-temp-release\pythoncore_pgo\obmalloc.obj" - -".\x86-temp-release\pythoncore_pgo\operator.obj" - -".\x86-temp-release\pythoncore_pgo\parser.obj" - -".\x86-temp-release\pythoncore_pgo\parsermodule.obj" - -".\x86-temp-release\pythoncore_pgo\parsetok.obj" - -".\x86-temp-release\pythoncore_pgo\posixmodule.obj" - -".\x86-temp-release\pythoncore_pgo\pyarena.obj" - -".\x86-temp-release\pythoncore_pgo\pyfpe.obj" - -".\x86-temp-release\pythoncore_pgo\pystate.obj" - -".\x86-temp-release\pythoncore_pgo\pystrtod.obj" - -".\x86-temp-release\pythoncore_pgo\Python-ast.obj" - -".\x86-temp-release\pythoncore_pgo\python_nt.res" - -".\x86-temp-release\pythoncore_pgo\pythonrun.obj" - -".\x86-temp-release\pythoncore_pgo\rangeobject.obj" - -".\x86-temp-release\pythoncore_pgo\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore_pgo\rotatingtree.obj" - -".\x86-temp-release\pythoncore_pgo\setobject.obj" - -".\x86-temp-release\pythoncore_pgo\sha256module.obj" - -".\x86-temp-release\pythoncore_pgo\sha512module.obj" - -".\x86-temp-release\pythoncore_pgo\shamodule.obj" - -".\x86-temp-release\pythoncore_pgo\signalmodule.obj" - -".\x86-temp-release\pythoncore_pgo\sliceobject.obj" - -".\x86-temp-release\pythoncore_pgo\stringobject.obj" - -".\x86-temp-release\pythoncore_pgo\stropmodule.obj" - -".\x86-temp-release\pythoncore_pgo\structmember.obj" - -".\x86-temp-release\pythoncore_pgo\structseq.obj" - -".\x86-temp-release\pythoncore_pgo\symtable.obj" - -".\x86-temp-release\pythoncore_pgo\symtablemodule.obj" - -".\x86-temp-release\pythoncore_pgo\sysmodule.obj" - -".\x86-temp-release\pythoncore_pgo\thread.obj" - -".\x86-temp-release\pythoncore_pgo\threadmodule.obj" - -".\x86-temp-release\pythoncore_pgo\timemodule.obj" - -".\x86-temp-release\pythoncore_pgo\tokenizer.obj" - -".\x86-temp-release\pythoncore_pgo\traceback.obj" - -".\x86-temp-release\pythoncore_pgo\tupleobject.obj" - -".\x86-temp-release\pythoncore_pgo\typeobject.obj" - -".\x86-temp-release\pythoncore_pgo\unicodectype.obj" - -".\x86-temp-release\pythoncore_pgo\unicodeobject.obj" - -".\x86-temp-release\pythoncore_pgo\weakrefobject.obj" - -".\x86-temp-release\pythoncore_pgo\xxsubtype.obj" - -".\x86-temp-release\pythoncore_pgo\yuvconvert.obj" - -".\x86-temp-release\pythoncore_pgo\zipimport.obj" +/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib + +".\x86-temp-release\pythoncore_pgo\adler32.obj" + +".\x86-temp-release\pythoncore_pgo\compress.obj" + +".\x86-temp-release\pythoncore_pgo\crc32.obj" + +".\x86-temp-release\pythoncore_pgo\deflate.obj" + +".\x86-temp-release\pythoncore_pgo\gzio.obj" + +".\x86-temp-release\pythoncore_pgo\infback.obj" + +".\x86-temp-release\pythoncore_pgo\inffast.obj" + +".\x86-temp-release\pythoncore_pgo\inflate.obj" + +".\x86-temp-release\pythoncore_pgo\inftrees.obj" + +".\x86-temp-release\pythoncore_pgo\trees.obj" + +".\x86-temp-release\pythoncore_pgo\uncompr.obj" + +".\x86-temp-release\pythoncore_pgo\zlibmodule.obj" + +".\x86-temp-release\pythoncore_pgo\zutil.obj" + +".\x86-temp-release\pythoncore_pgo\_bisectmodule.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_cn.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_hk.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_iso2022.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_jp.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_kr.obj" + +".\x86-temp-release\pythoncore_pgo\_codecs_tw.obj" + +".\x86-temp-release\pythoncore_pgo\_codecsmodule.obj" + +".\x86-temp-release\pythoncore_pgo\_csv.obj" + +".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" + +".\x86-temp-release\pythoncore_pgo\_hotshot.obj" + +".\x86-temp-release\pythoncore_pgo\_localemodule.obj" + +".\x86-temp-release\pythoncore_pgo\_lsprof.obj" + +".\x86-temp-release\pythoncore_pgo\_randommodule.obj" + +".\x86-temp-release\pythoncore_pgo\_sre.obj" + +".\x86-temp-release\pythoncore_pgo\_struct.obj" + +".\x86-temp-release\pythoncore_pgo\_subprocess.obj" + +".\x86-temp-release\pythoncore_pgo\_weakref.obj" + +".\x86-temp-release\pythoncore_pgo\_winreg.obj" + +".\x86-temp-release\pythoncore_pgo\abstract.obj" + +".\x86-temp-release\pythoncore_pgo\acceler.obj" + +".\x86-temp-release\pythoncore_pgo\arraymodule.obj" + +".\x86-temp-release\pythoncore_pgo\asdl.obj" + +".\x86-temp-release\pythoncore_pgo\ast.obj" + +".\x86-temp-release\pythoncore_pgo\audioop.obj" + +".\x86-temp-release\pythoncore_pgo\binascii.obj" + +".\x86-temp-release\pythoncore_pgo\bitset.obj" + +".\x86-temp-release\pythoncore_pgo\bltinmodule.obj" + +".\x86-temp-release\pythoncore_pgo\boolobject.obj" + +".\x86-temp-release\pythoncore_pgo\bufferobject.obj" + +".\x86-temp-release\pythoncore_pgo\cellobject.obj" + +".\x86-temp-release\pythoncore_pgo\ceval.obj" + +".\x86-temp-release\pythoncore_pgo\classobject.obj" + +".\x86-temp-release\pythoncore_pgo\cmathmodule.obj" + +".\x86-temp-release\pythoncore_pgo\cobject.obj" + +".\x86-temp-release\pythoncore_pgo\codecs.obj" + +".\x86-temp-release\pythoncore_pgo\codeobject.obj" + +".\x86-temp-release\pythoncore_pgo\collectionsmodule.obj" + +".\x86-temp-release\pythoncore_pgo\compile.obj" + +".\x86-temp-release\pythoncore_pgo\complexobject.obj" + +".\x86-temp-release\pythoncore_pgo\config.obj" + +".\x86-temp-release\pythoncore_pgo\cPickle.obj" + +".\x86-temp-release\pythoncore_pgo\cStringIO.obj" + +".\x86-temp-release\pythoncore_pgo\datetimemodule.obj" + +".\x86-temp-release\pythoncore_pgo\descrobject.obj" + +".\x86-temp-release\pythoncore_pgo\dictobject.obj" + +".\x86-temp-release\pythoncore_pgo\dl_nt.obj" + +".\x86-temp-release\pythoncore_pgo\dynload_win.obj" + +".\x86-temp-release\pythoncore_pgo\enumobject.obj" + +".\x86-temp-release\pythoncore_pgo\errnomodule.obj" + +".\x86-temp-release\pythoncore_pgo\errors.obj" + +".\x86-temp-release\pythoncore_pgo\exceptions.obj" + +".\x86-temp-release\pythoncore_pgo\fileobject.obj" + +".\x86-temp-release\pythoncore_pgo\firstsets.obj" + +".\x86-temp-release\pythoncore_pgo\floatobject.obj" + +".\x86-temp-release\pythoncore_pgo\frameobject.obj" + +".\x86-temp-release\pythoncore_pgo\frozen.obj" + +".\x86-temp-release\pythoncore_pgo\funcobject.obj" + +".\x86-temp-release\pythoncore_pgo\functionalmodule.obj" + +".\x86-temp-release\pythoncore_pgo\future.obj" + +".\x86-temp-release\pythoncore_pgo\gcmodule.obj" + +".\x86-temp-release\pythoncore_pgo\genobject.obj" + +".\x86-temp-release\pythoncore_pgo\getargs.obj" + +".\x86-temp-release\pythoncore_pgo\getcompiler.obj" + +".\x86-temp-release\pythoncore_pgo\getcopyright.obj" + +".\x86-temp-release\pythoncore_pgo\getmtime.obj" + +".\x86-temp-release\pythoncore_pgo\getopt.obj" + +".\x86-temp-release\pythoncore_pgo\getpathp.obj" + +".\x86-temp-release\pythoncore_pgo\getplatform.obj" + +".\x86-temp-release\pythoncore_pgo\getversion.obj" + +".\x86-temp-release\pythoncore_pgo\graminit.obj" + +".\x86-temp-release\pythoncore_pgo\grammar.obj" + +".\x86-temp-release\pythoncore_pgo\grammar1.obj" + +".\x86-temp-release\pythoncore_pgo\imageop.obj" + +".\x86-temp-release\pythoncore_pgo\import.obj" + +".\x86-temp-release\pythoncore_pgo\import_nt.obj" + +".\x86-temp-release\pythoncore_pgo\importdl.obj" + +".\x86-temp-release\pythoncore_pgo\intobject.obj" + +".\x86-temp-release\pythoncore_pgo\iterobject.obj" + +".\x86-temp-release\pythoncore_pgo\itertoolsmodule.obj" + +".\x86-temp-release\pythoncore_pgo\listnode.obj" + +".\x86-temp-release\pythoncore_pgo\listobject.obj" + +".\x86-temp-release\pythoncore_pgo\longobject.obj" + +".\x86-temp-release\pythoncore_pgo\main.obj" + +".\x86-temp-release\pythoncore_pgo\marshal.obj" + +".\x86-temp-release\pythoncore_pgo\mathmodule.obj" + +".\x86-temp-release\pythoncore_pgo\md5.obj" + +".\x86-temp-release\pythoncore_pgo\md5module.obj" + +".\x86-temp-release\pythoncore_pgo\metagrammar.obj" + +".\x86-temp-release\pythoncore_pgo\methodobject.obj" + +".\x86-temp-release\pythoncore_pgo\mmapmodule.obj" + +".\x86-temp-release\pythoncore_pgo\modsupport.obj" + +".\x86-temp-release\pythoncore_pgo\moduleobject.obj" + +".\x86-temp-release\pythoncore_pgo\msvcrtmodule.obj" + +".\x86-temp-release\pythoncore_pgo\multibytecodec.obj" + +".\x86-temp-release\pythoncore_pgo\myreadline.obj" + +".\x86-temp-release\pythoncore_pgo\mysnprintf.obj" + +".\x86-temp-release\pythoncore_pgo\mystrtoul.obj" + +".\x86-temp-release\pythoncore_pgo\node.obj" + +".\x86-temp-release\pythoncore_pgo\object.obj" + +".\x86-temp-release\pythoncore_pgo\obmalloc.obj" + +".\x86-temp-release\pythoncore_pgo\operator.obj" + +".\x86-temp-release\pythoncore_pgo\parser.obj" + +".\x86-temp-release\pythoncore_pgo\parsermodule.obj" + +".\x86-temp-release\pythoncore_pgo\parsetok.obj" + +".\x86-temp-release\pythoncore_pgo\posixmodule.obj" + +".\x86-temp-release\pythoncore_pgo\pyarena.obj" + +".\x86-temp-release\pythoncore_pgo\pyfpe.obj" + +".\x86-temp-release\pythoncore_pgo\pystate.obj" + +".\x86-temp-release\pythoncore_pgo\pystrtod.obj" + +".\x86-temp-release\pythoncore_pgo\Python-ast.obj" + +".\x86-temp-release\pythoncore_pgo\python_nt.res" + +".\x86-temp-release\pythoncore_pgo\pythonrun.obj" + +".\x86-temp-release\pythoncore_pgo\rangeobject.obj" + +".\x86-temp-release\pythoncore_pgo\rgbimgmodule.obj" + +".\x86-temp-release\pythoncore_pgo\rotatingtree.obj" + +".\x86-temp-release\pythoncore_pgo\setobject.obj" + +".\x86-temp-release\pythoncore_pgo\sha256module.obj" + +".\x86-temp-release\pythoncore_pgo\sha512module.obj" + +".\x86-temp-release\pythoncore_pgo\shamodule.obj" + +".\x86-temp-release\pythoncore_pgo\signalmodule.obj" + +".\x86-temp-release\pythoncore_pgo\sliceobject.obj" + +".\x86-temp-release\pythoncore_pgo\stringobject.obj" + +".\x86-temp-release\pythoncore_pgo\stropmodule.obj" + +".\x86-temp-release\pythoncore_pgo\structmember.obj" + +".\x86-temp-release\pythoncore_pgo\structseq.obj" + +".\x86-temp-release\pythoncore_pgo\symtable.obj" + +".\x86-temp-release\pythoncore_pgo\symtablemodule.obj" + +".\x86-temp-release\pythoncore_pgo\sysmodule.obj" + +".\x86-temp-release\pythoncore_pgo\thread.obj" + +".\x86-temp-release\pythoncore_pgo\threadmodule.obj" + +".\x86-temp-release\pythoncore_pgo\timemodule.obj" + +".\x86-temp-release\pythoncore_pgo\tokenizer.obj" + +".\x86-temp-release\pythoncore_pgo\traceback.obj" + +".\x86-temp-release\pythoncore_pgo\tupleobject.obj" + +".\x86-temp-release\pythoncore_pgo\typeobject.obj" + +".\x86-temp-release\pythoncore_pgo\unicodectype.obj" + +".\x86-temp-release\pythoncore_pgo\unicodeobject.obj" + +".\x86-temp-release\pythoncore_pgo\weakrefobject.obj" + +".\x86-temp-release\pythoncore_pgo\xxsubtype.obj" + +".\x86-temp-release\pythoncore_pgo\yuvconvert.obj" + +".\x86-temp-release\pythoncore_pgo\zipimport.obj" Modified: python/trunk/PCbuild8/pythonw.vcproj ============================================================================== --- python/trunk/PCbuild8/pythonw.vcproj (original) +++ python/trunk/PCbuild8/pythonw.vcproj Sun May 28 03:52:38 2006 @@ -1,386 +1,386 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/readme.txt ============================================================================== --- python/trunk/PCbuild8/readme.txt (original) +++ python/trunk/PCbuild8/readme.txt Sun May 28 03:52:38 2006 @@ -1,423 +1,423 @@ -Building Python using VC++ 8.0 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -95, 98 and NT. It requires Microsoft Visual C++ 8.0 -(a.k.a. Visual Studio 2005). -(For other Windows platforms and compilers, see ../PC/readme.txt.) - -All you need to do is open the workspace "pcbuild.sln" in MSVC++, select -the Debug or Release setting (using "Solution Configuration" from -the "Standard" toolbar"), and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python25.{dll, lib} in Release mode) - NOTE: in previous releases, this subproject was - named after the release number, e.g. python20. - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement, or are running a Python core buildbot - test slave; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python25_d.dll, python_d.exe, parser_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -pythoncore_pgo - .dll and .lib, a variant of pythoncore that is optimized through a - Profile Guided Optimization (PGO), employing pybench as the profile - case to optimize for. The results are produced as a python25.{dll,lib} - in the subfolder 'pythoncore_pgo'. To use this instead of the - standard Python dll place this dll with the python.exe. -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_socket - socketmodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PCbuilds's parent -directory; for example, if your PCbuild is .......\dist\src\PCbuild\, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. - - Get source - ---------- - In the dist directory, run - svn export http://svn.python.org/projects/external/tcl8.4.12 - svn export http://svn.python.org/projects/external/tk8.4.12 - svn export http://svn.python.org/projects/external/tix-8.4.0 - - Build Tcl first (done here w/ MSVC 7.1 on Windows XP) - --------------- - Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 - -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" - to get a shell window with the correct environment settings - cd dist\tcl8.4.12\win - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - Optional: run tests, via - nmake -f makefile.vc test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0 - Sourced 129 Test Files. - - Build Tk - -------- - cd dist\tk8.4.12\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Optional: run tests, via - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 - Sourced 91 Test Files. - Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test - - Built Tix - --------- - cd dist\tix-8.4.0\win - nmake -f python.mak - nmake -f python.mak install - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://sources.redhat.com/bzip2/ - Download the source from the python.org copy into the dist - directory: - - svn export http://svn.python.org/projects/external/bzip2-1.0.3 - - A custom pre-link step in the bz2 project settings should manage to - build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is - linked in PCbuild\. - However, the bz2 project is not smart enough to remove anything under - bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib - you need to clean up bzip2-1.0.3\ by hand. - - The build step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - - All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python - project links in. - - -_bsddb - To use the version of bsddb that Python is built with by default, invoke - (in the dist directory) - - svn export http://svn.python.org/projects/external/db-4.4.20 - - - Then open a VS.NET 2003 shell, and invoke: - - devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Release /project db_static - - and do that a second time for a Debug build too: - - devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static - - Alternatively, if you want to start with the original sources, - go to Sleepycat's download page: - http://www.sleepycat.com/downloads/releasehistorybdb.html - - and download version 4.4.20. - - With or without strong cryptography? You can choose either with or - without strong cryptography, as per the instructions below. By - default, Python is built and distributed WITHOUT strong crypto. - - Unpack the sources; if you downloaded the non-crypto version, rename - the directory from db-4.4.20.NC to db-4.4.20. - - Now apply any patches that apply to your version. - - Open - dist\db-4.4.20\docs\index.html - - and follow the "Windows->Building Berkeley DB with Visual C++ .NET" - instructions for building the Sleepycat - software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. - Build the "db_static" project, for "Release" mode. - - To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py - is then enabled. Running in verbose mode may be helpful. - - XXX The test_bsddb3 tests don't always pass, on Windows (according to - XXX me) or on Linux (according to Barry). (I had much better luck - XXX on Win2K than on Win98SE.) The common failure mode across platforms - XXX is - XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable - XXX to join the environment') - XXX - XXX and it appears timing-dependent. On Win2K I also saw this once: - XXX - XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ... - XXX Exception in thread reader 1: - XXX Traceback (most recent call last): - XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap - XXX self.run() - XXX File "C:\Code\python\lib\threading.py", line 399, in run - XXX apply(self.__target, self.__args, self.__kwargs) - XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in - XXX readerThread - XXX rec = c.next() - XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed - XXX to resolve a deadlock') - XXX - XXX I'm told that DBLockDeadlockError is expected at times. It - XXX doesn't cause a test to fail when it happens (exceptions in - XXX threads are invisible to unittest). - - Building for Win64: - - open a VS.NET 2003 command prompt - - run the SDK setenv.cmd script, passing /RETAIL and the target - architecture (/SRV64 for Itanium, /X64 for AMD64) - - build BerkeleyDB with the solution configuration matching the - target ("Release IA64" for Itanium, "Release AMD64" for AMD64), e.g. - devenv db-4.4.20\build_win32\Berkeley_DB.sln /build "Release AMD64" /project db_static /useenv - -_sqlite3 - Python wrapper for SQLite library. - - Get the source code through - - svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - - To use the extension module in a Python build tree, copy sqlite3.dll into - the PCbuild folder. - -_ssl - Python wrapper for the secure sockets library. - - Get the source code through - - svn export http://svn.python.org/projects/external/openssl-0.9.8a - - Alternatively, get the latest version from http://www.openssl.org. - You can (theoretically) use any version of OpenSSL you like - the - build process will automatically select the latest version. - - You must also install ActivePerl from - http://www.activestate.com/Products/ActivePerl/ - as this is used by the OpenSSL build process. Complain to them . - - The MSVC project simply invokes PCBuild/build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - -Building for Itanium --------------------- - -The project files support a ReleaseItanium configuration which creates -Win64/Itanium binaries. For this to work, you need to install the Platform -SDK, in particular the 64-bit support. This includes an Itanium compiler -(future releases of the SDK likely include an AMD64 compiler as well). -In addition, you need the Visual Studio plugin for external C compilers, -from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to -locate the proper target compiler, and convert compiler options -accordingly. The project files require atleast version 0.8. - -Building for AMD64 ------------------- - -The build process for the ReleaseAMD64 configuration is very similar -to the Itanium configuration; make sure you use the latest version of -vsextcomp. - -Building Python Using the free MS Toolkit Compiler --------------------------------------------------- - -The build process for Visual C++ can be used almost unchanged with the free MS -Toolkit Compiler. This provides a way of building Python using freely -available software. - -Requirements - - To build Python, the following tools are required: - - * The Visual C++ Toolkit Compiler - from http://msdn.microsoft.com/visualc/vctoolkit2003/ - * A recent Platform SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a - * The .NET 1.1 SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d - - [Does anyone have better URLs for the last 2 of these?] - - The toolkit compiler is needed as it is an optimising compiler (the - compiler supplied with the .NET SDK is a non-optimising version). The - platform SDK is needed to provide the Windows header files and libraries - (the Windows 2003 Server SP1 edition, typical install, is known to work - - other configurations or versions are probably fine as well). The .NET 1.1 - SDK is needed because it contains a version of msvcrt.dll which links to - the msvcr71.dll CRT. Note that the .NET 2.0 SDK is NOT acceptable, as it - references msvcr80.dll. - - All of the above items should be installed as normal. - - If you intend to build the openssl (needed for the _ssl extension) you - will need the C runtime sources installed as part of the platform SDK. - - In addition, you will need Nant, available from - http://nant.sourceforge.net. The 0.85 release candidate 3 version is known - to work. This is the latest released version at the time of writing. Later - "nightly build" versions are known NOT to work - it is not clear at - present whether future released versions will work. - -Setting up the environment - - Start a platform SDK "build environment window" from the start menu. The - "Windows XP 32-bit retail" version is known to work. - - Add the following directories to your PATH: - * The toolkit compiler directory - * The SDK "Win64" binaries directory - * The Nant directory - Add to your INCLUDE environment variable: - * The toolkit compiler INCLUDE directory - Add to your LIB environment variable: - * The toolkit compiler LIB directory - * The .NET SDK Visual Studio 2003 VC7\lib directory - - The following commands should set things up as you need them: - - rem Set these values according to where you installed the software - set TOOLKIT=C:\Program Files\Microsoft Visual C++ Toolkit 2003 - set SDK=C:\Program Files\Microsoft Platform SDK - set NET=C:\Program Files\Microsoft Visual Studio .NET 2003 - set NANT=C:\Utils\Nant - - set PATH=%TOOLKIT%\bin;%PATH%;%SDK%\Bin\win64;%NANT%\bin - set INCLUDE=%TOOLKIT%\include;%INCLUDE% - set LIB=%TOOLKIT%\lib;%NET%\VC7\lib;%LIB% - - The "win64" directory from the SDK is added to supply executables such as - "cvtres" and "lib", which are not available elsewhere. The versions in the - "win64" directory are 32-bit programs, so they are fine to use here. - - That's it. To build Python (the core only, no binary extensions which - depend on external libraries) you just need to issue the command - - nant -buildfile:python.build all - - from within the PCBuild directory. - -Extension modules - - To build those extension modules which require external libraries - (_tkinter, bz2, _bsddb, _sqlite3, _ssl) you can follow the instructions - for the Visual Studio build above, with a few minor modifications. These - instructions have only been tested using the sources in the Python - subversion repository - building from original sources should work, but - has not been tested. - - For each extension module you wish to build, you should remove the - associated include line from the excludeprojects section of pc.build. - - The changes required are: - - _tkinter - The tix makefile (tix-8.4.0\win\makefile.vc) must be modified to - remove references to TOOLS32. The relevant lines should be changed to - read: - cc32 = cl.exe - link32 = link.exe - include32 = - The remainder of the build instructions will work as given. - - bz2 - No changes are needed - - _bsddb - The file db.build should be copied from the Python PCBuild directory - to the directory db-4.4.20\build_win32. - - The file db_static.vcproj in db-4.4.20\build_win32 should be edited to - remove the string "$(SolutionDir)" - this occurs in 2 places, only - relevant for 64-bit builds. (The edit is required as otherwise, nant - wants to read the solution file, which is not in a suitable form). - - The bsddb library can then be build with the command - nant -buildfile:db.build all - run from the db-4.4.20\build_win32 directory. - - _sqlite3 - No changes are needed. However, in order for the tests to succeed, a - copy of sqlite3.dll must be downloaded, and placed alongside - python.exe. - - _ssl - The documented build process works as written. However, it needs a - copy of the file setargv.obj, which is not supplied in the platform - SDK. However, the sources are available (in the crt source code). To - build setargv.obj, proceed as follows: - - Copy setargv.c, cruntime.h and internal.h from %SDK%\src\crt to a - temporary directory. - Compile using "cl /c /I. /MD /D_CRTBLD setargv.c" - Copy the resulting setargv.obj to somewhere on your LIB environment - (%SDK%\lib is a reasonable place). - - With setargv.obj in place, the standard build process should work - fine. - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. +Building Python using VC++ 8.0 +------------------------------------- +This directory is used to build Python for Win32 platforms, e.g. Windows +95, 98 and NT. It requires Microsoft Visual C++ 8.0 +(a.k.a. Visual Studio 2005). +(For other Windows platforms and compilers, see ../PC/readme.txt.) + +All you need to do is open the workspace "pcbuild.sln" in MSVC++, select +the Debug or Release setting (using "Solution Configuration" from +the "Standard" toolbar"), and build the projects. + +The proper order to build subprojects: + +1) pythoncore (this builds the main Python DLL and library files, + python25.{dll, lib} in Release mode) + NOTE: in previous releases, this subproject was + named after the release number, e.g. python20. + +2) python (this builds the main Python executable, + python.exe in Release mode) + +3) the other subprojects, as desired or needed (note: you probably don't + want to build most of the other subprojects, unless you're building an + entire Python distribution from scratch, or specifically making changes + to the subsystems they implement, or are running a Python core buildbot + test slave; see SUBPROJECTS below) + +When using the Debug setting, the output files have a _d added to +their name: python25_d.dll, python_d.exe, parser_d.pyd, and so on. + +SUBPROJECTS +----------- +These subprojects should build out of the box. Subprojects other than the +main ones (pythoncore, python, pythonw) generally build a DLL (renamed to +.pyd) from a specific module so that users don't have to load the code +supporting that module unless they import the module. + +pythoncore + .dll and .lib +pythoncore_pgo + .dll and .lib, a variant of pythoncore that is optimized through a + Profile Guided Optimization (PGO), employing pybench as the profile + case to optimize for. The results are produced as a python25.{dll,lib} + in the subfolder 'pythoncore_pgo'. To use this instead of the + standard Python dll place this dll with the python.exe. +python + .exe +pythonw + pythonw.exe, a variant of python.exe that doesn't pop up a DOS box +_socket + socketmodule.c +_testcapi + tests of the Python C API, run via Lib/test/test_capi.py, and + implemented by module Modules/_testcapimodule.c +pyexpat + Python wrapper for accelerated XML parsing, which incorporates stable + code from the Expat project: http://sourceforge.net/projects/expat/ +select + selectmodule.c +unicodedata + large tables of Unicode data +winsound + play sounds (typically .wav files) under Windows + +The following subprojects will generally NOT build out of the box. They +wrap code Python doesn't control, and you'll need to download the base +packages first and unpack them into siblings of PCbuilds's parent +directory; for example, if your PCbuild is .......\dist\src\PCbuild\, +unpack into new subdirectories of dist\. + +_tkinter + Python wrapper for the Tk windowing system. Requires building + Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. + + Get source + ---------- + In the dist directory, run + svn export http://svn.python.org/projects/external/tcl8.4.12 + svn export http://svn.python.org/projects/external/tk8.4.12 + svn export http://svn.python.org/projects/external/tix-8.4.0 + + Build Tcl first (done here w/ MSVC 7.1 on Windows XP) + --------------- + Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 + -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" + to get a shell window with the correct environment settings + cd dist\tcl8.4.12\win + nmake -f makefile.vc + nmake -f makefile.vc INSTALLDIR=..\..\tcltk install + + XXX Should we compile with OPTS=threads? + + Optional: run tests, via + nmake -f makefile.vc test + + On WinXP Pro, wholly up to date as of 30-Aug-2004: + all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0 + Sourced 129 Test Files. + + Build Tk + -------- + cd dist\tk8.4.12\win + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install + + XXX Should we compile with OPTS=threads? + + XXX Our installer copies a lot of stuff out of the Tcl/Tk install + XXX directory. Is all of that really needed for Python use of Tcl/Tk? + + Optional: run tests, via + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test + + On WinXP Pro, wholly up to date as of 30-Aug-2004: + all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 + Sourced 91 Test Files. + Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test + + Built Tix + --------- + cd dist\tix-8.4.0\win + nmake -f python.mak + nmake -f python.mak install + +bz2 + Python wrapper for the libbz2 compression library. Homepage + http://sources.redhat.com/bzip2/ + Download the source from the python.org copy into the dist + directory: + + svn export http://svn.python.org/projects/external/bzip2-1.0.3 + + A custom pre-link step in the bz2 project settings should manage to + build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is + linked in PCbuild\. + However, the bz2 project is not smart enough to remove anything under + bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib + you need to clean up bzip2-1.0.3\ by hand. + + The build step shouldn't yield any warnings or errors, and should end + by displaying 6 blocks each terminated with + FC: no differences encountered + + All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python + project links in. + + +_bsddb + To use the version of bsddb that Python is built with by default, invoke + (in the dist directory) + + svn export http://svn.python.org/projects/external/db-4.4.20 + + + Then open a VS.NET 2003 shell, and invoke: + + devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Release /project db_static + + and do that a second time for a Debug build too: + + devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static + + Alternatively, if you want to start with the original sources, + go to Sleepycat's download page: + http://www.sleepycat.com/downloads/releasehistorybdb.html + + and download version 4.4.20. + + With or without strong cryptography? You can choose either with or + without strong cryptography, as per the instructions below. By + default, Python is built and distributed WITHOUT strong crypto. + + Unpack the sources; if you downloaded the non-crypto version, rename + the directory from db-4.4.20.NC to db-4.4.20. + + Now apply any patches that apply to your version. + + Open + dist\db-4.4.20\docs\index.html + + and follow the "Windows->Building Berkeley DB with Visual C++ .NET" + instructions for building the Sleepycat + software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. + Build the "db_static" project, for "Release" mode. + + To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py + is then enabled. Running in verbose mode may be helpful. + + XXX The test_bsddb3 tests don't always pass, on Windows (according to + XXX me) or on Linux (according to Barry). (I had much better luck + XXX on Win2K than on Win98SE.) The common failure mode across platforms + XXX is + XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable + XXX to join the environment') + XXX + XXX and it appears timing-dependent. On Win2K I also saw this once: + XXX + XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ... + XXX Exception in thread reader 1: + XXX Traceback (most recent call last): + XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap + XXX self.run() + XXX File "C:\Code\python\lib\threading.py", line 399, in run + XXX apply(self.__target, self.__args, self.__kwargs) + XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in + XXX readerThread + XXX rec = c.next() + XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed + XXX to resolve a deadlock') + XXX + XXX I'm told that DBLockDeadlockError is expected at times. It + XXX doesn't cause a test to fail when it happens (exceptions in + XXX threads are invisible to unittest). + + Building for Win64: + - open a VS.NET 2003 command prompt + - run the SDK setenv.cmd script, passing /RETAIL and the target + architecture (/SRV64 for Itanium, /X64 for AMD64) + - build BerkeleyDB with the solution configuration matching the + target ("Release IA64" for Itanium, "Release AMD64" for AMD64), e.g. + devenv db-4.4.20\build_win32\Berkeley_DB.sln /build "Release AMD64" /project db_static /useenv + +_sqlite3 + Python wrapper for SQLite library. + + Get the source code through + + svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 + + To use the extension module in a Python build tree, copy sqlite3.dll into + the PCbuild folder. + +_ssl + Python wrapper for the secure sockets library. + + Get the source code through + + svn export http://svn.python.org/projects/external/openssl-0.9.8a + + Alternatively, get the latest version from http://www.openssl.org. + You can (theoretically) use any version of OpenSSL you like - the + build process will automatically select the latest version. + + You must also install ActivePerl from + http://www.activestate.com/Products/ActivePerl/ + as this is used by the OpenSSL build process. Complain to them . + + The MSVC project simply invokes PCBuild/build_ssl.py to perform + the build. This Python script locates and builds your OpenSSL + installation, then invokes a simple makefile to build the final .pyd. + + build_ssl.py attempts to catch the most common errors (such as not + being able to find OpenSSL sources, or not being able to find a Perl + that works with OpenSSL) and give a reasonable error message. + If you have a problem that doesn't seem to be handled correctly + (eg, you know you have ActivePerl but we can't find it), please take + a peek at build_ssl.py and suggest patches. Note that build_ssl.py + should be able to be run directly from the command-line. + + build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do + this by hand. + +Building for Itanium +-------------------- + +The project files support a ReleaseItanium configuration which creates +Win64/Itanium binaries. For this to work, you need to install the Platform +SDK, in particular the 64-bit support. This includes an Itanium compiler +(future releases of the SDK likely include an AMD64 compiler as well). +In addition, you need the Visual Studio plugin for external C compilers, +from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to +locate the proper target compiler, and convert compiler options +accordingly. The project files require atleast version 0.8. + +Building for AMD64 +------------------ + +The build process for the ReleaseAMD64 configuration is very similar +to the Itanium configuration; make sure you use the latest version of +vsextcomp. + +Building Python Using the free MS Toolkit Compiler +-------------------------------------------------- + +The build process for Visual C++ can be used almost unchanged with the free MS +Toolkit Compiler. This provides a way of building Python using freely +available software. + +Requirements + + To build Python, the following tools are required: + + * The Visual C++ Toolkit Compiler + from http://msdn.microsoft.com/visualc/vctoolkit2003/ + * A recent Platform SDK + from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a + * The .NET 1.1 SDK + from http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d + + [Does anyone have better URLs for the last 2 of these?] + + The toolkit compiler is needed as it is an optimising compiler (the + compiler supplied with the .NET SDK is a non-optimising version). The + platform SDK is needed to provide the Windows header files and libraries + (the Windows 2003 Server SP1 edition, typical install, is known to work - + other configurations or versions are probably fine as well). The .NET 1.1 + SDK is needed because it contains a version of msvcrt.dll which links to + the msvcr71.dll CRT. Note that the .NET 2.0 SDK is NOT acceptable, as it + references msvcr80.dll. + + All of the above items should be installed as normal. + + If you intend to build the openssl (needed for the _ssl extension) you + will need the C runtime sources installed as part of the platform SDK. + + In addition, you will need Nant, available from + http://nant.sourceforge.net. The 0.85 release candidate 3 version is known + to work. This is the latest released version at the time of writing. Later + "nightly build" versions are known NOT to work - it is not clear at + present whether future released versions will work. + +Setting up the environment + + Start a platform SDK "build environment window" from the start menu. The + "Windows XP 32-bit retail" version is known to work. + + Add the following directories to your PATH: + * The toolkit compiler directory + * The SDK "Win64" binaries directory + * The Nant directory + Add to your INCLUDE environment variable: + * The toolkit compiler INCLUDE directory + Add to your LIB environment variable: + * The toolkit compiler LIB directory + * The .NET SDK Visual Studio 2003 VC7\lib directory + + The following commands should set things up as you need them: + + rem Set these values according to where you installed the software + set TOOLKIT=C:\Program Files\Microsoft Visual C++ Toolkit 2003 + set SDK=C:\Program Files\Microsoft Platform SDK + set NET=C:\Program Files\Microsoft Visual Studio .NET 2003 + set NANT=C:\Utils\Nant + + set PATH=%TOOLKIT%\bin;%PATH%;%SDK%\Bin\win64;%NANT%\bin + set INCLUDE=%TOOLKIT%\include;%INCLUDE% + set LIB=%TOOLKIT%\lib;%NET%\VC7\lib;%LIB% + + The "win64" directory from the SDK is added to supply executables such as + "cvtres" and "lib", which are not available elsewhere. The versions in the + "win64" directory are 32-bit programs, so they are fine to use here. + + That's it. To build Python (the core only, no binary extensions which + depend on external libraries) you just need to issue the command + + nant -buildfile:python.build all + + from within the PCBuild directory. + +Extension modules + + To build those extension modules which require external libraries + (_tkinter, bz2, _bsddb, _sqlite3, _ssl) you can follow the instructions + for the Visual Studio build above, with a few minor modifications. These + instructions have only been tested using the sources in the Python + subversion repository - building from original sources should work, but + has not been tested. + + For each extension module you wish to build, you should remove the + associated include line from the excludeprojects section of pc.build. + + The changes required are: + + _tkinter + The tix makefile (tix-8.4.0\win\makefile.vc) must be modified to + remove references to TOOLS32. The relevant lines should be changed to + read: + cc32 = cl.exe + link32 = link.exe + include32 = + The remainder of the build instructions will work as given. + + bz2 + No changes are needed + + _bsddb + The file db.build should be copied from the Python PCBuild directory + to the directory db-4.4.20\build_win32. + + The file db_static.vcproj in db-4.4.20\build_win32 should be edited to + remove the string "$(SolutionDir)" - this occurs in 2 places, only + relevant for 64-bit builds. (The edit is required as otherwise, nant + wants to read the solution file, which is not in a suitable form). + + The bsddb library can then be build with the command + nant -buildfile:db.build all + run from the db-4.4.20\build_win32 directory. + + _sqlite3 + No changes are needed. However, in order for the tests to succeed, a + copy of sqlite3.dll must be downloaded, and placed alongside + python.exe. + + _ssl + The documented build process works as written. However, it needs a + copy of the file setargv.obj, which is not supplied in the platform + SDK. However, the sources are available (in the crt source code). To + build setargv.obj, proceed as follows: + + Copy setargv.c, cruntime.h and internal.h from %SDK%\src\crt to a + temporary directory. + Compile using "cl /c /I. /MD /D_CRTBLD setargv.c" + Copy the resulting setargv.obj to somewhere on your LIB environment + (%SDK%\lib is a reasonable place). + + With setargv.obj in place, the standard build process should work + fine. + +YOUR OWN EXTENSION DLLs +----------------------- +If you want to create your own extension module DLL, there's an example +with easy-to-follow instructions in ../PC/example/; read the file +readme.txt there first. Modified: python/trunk/PCbuild8/rmpyc.py ============================================================================== --- python/trunk/PCbuild8/rmpyc.py (original) +++ python/trunk/PCbuild8/rmpyc.py Sun May 28 03:52:38 2006 @@ -1,25 +1,25 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" +# Remove all the .pyc and .pyo files under ../Lib. + + +def deltree(root): + import os + from os.path import join + + npyc = npyo = 0 + for root, dirs, files in os.walk(root): + for name in files: + delete = False + if name.endswith('.pyc'): + delete = True + npyc += 1 + elif name.endswith('.pyo'): + delete = True + npyo += 1 + + if delete: + os.remove(join(root, name)) + + return npyc, npyo + +npyc, npyo = deltree("../Lib") +print npyc, ".pyc deleted,", npyo, ".pyo deleted" Modified: python/trunk/PCbuild8/select.vcproj ============================================================================== --- python/trunk/PCbuild8/select.vcproj (original) +++ python/trunk/PCbuild8/select.vcproj Sun May 28 03:52:38 2006 @@ -1,382 +1,382 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/unicodedata.vcproj ============================================================================== --- python/trunk/PCbuild8/unicodedata.vcproj (original) +++ python/trunk/PCbuild8/unicodedata.vcproj Sun May 28 03:52:38 2006 @@ -1,371 +1,371 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/w9xpopen.vcproj ============================================================================== --- python/trunk/PCbuild8/w9xpopen.vcproj (original) +++ python/trunk/PCbuild8/w9xpopen.vcproj Sun May 28 03:52:38 2006 @@ -1,185 +1,185 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/winsound.vcproj ============================================================================== --- python/trunk/PCbuild8/winsound.vcproj (original) +++ python/trunk/PCbuild8/winsound.vcproj Sun May 28 03:52:38 2006 @@ -1,375 +1,375 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From nnorwitz at gmail.com Sun May 28 04:22:09 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 27 May 2006 19:22:09 -0700 Subject: [Python-checkins] r46240 - python/trunk/Modules/_struct.c In-Reply-To: <20060525184450.673BE1E400B@bag.python.org> References: <20060525184450.673BE1E400B@bag.python.org> Message-ID: All occurrences of *p & 0xFF where p is a char* should use Py_CHARMASK(). On 5/25/06, bob.ippolito wrote: > Author: bob.ippolito > Date: Thu May 25 20:44:50 2006 > New Revision: 46240 > > Modified: > python/trunk/Modules/_struct.c > Log: > Struct now unpacks to PY_LONG_LONG directly when possible, also include #ifdef'ed out code that will return int instead of long when in bounds (not active since it's an API and doc change) > > Modified: python/trunk/Modules/_struct.c > ============================================================================== > --- python/trunk/Modules/_struct.c (original) > +++ python/trunk/Modules/_struct.c Thu May 25 20:44:50 2006 > @@ -15,6 +15,12 @@ > typedef int Py_ssize_t; > #endif > > +/* PY_USE_INT_WHEN_POSSIBLE is an experimental flag that changes the > + struct API to return int instead of long when possible. This is > + often a significant performance improvement. */ > +/* > +#define PY_USE_INT_WHEN_POSSIBLE 1 > +*/ > > > /* The translation function for each format character is table driven */ > @@ -284,6 +290,10 @@ > { > unsigned int x; > memcpy((char *)&x, p, sizeof x); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > + return PyInt_FromLong((long)x); > +#endif > return PyLong_FromUnsignedLong((unsigned long)x); > } > > @@ -300,6 +310,10 @@ > { > unsigned long x; > memcpy((char *)&x, p, sizeof x); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > + return PyInt_FromLong((long)x); > +#endif > return PyLong_FromUnsignedLong(x); > } > > @@ -313,6 +327,10 @@ > { > PY_LONG_LONG x; > memcpy((char *)&x, p, sizeof x); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x >= INT_MIN && x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); > +#endif > return PyLong_FromLongLong(x); > } > > @@ -321,6 +339,10 @@ > { > unsigned PY_LONG_LONG x; > memcpy((char *)&x, p, sizeof x); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); > +#endif > return PyLong_FromUnsignedLongLong(x); > } > > @@ -584,28 +606,58 @@ > do { > x = (x<<8) | (*p++ & 0xFF); > } while (--i > 0); > - if (f->size >= 4) > - return PyLong_FromUnsignedLong(x); > - else > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > return PyInt_FromLong((long)x); > +#endif > + return PyLong_FromUnsignedLong(x); > } > > static PyObject * > bu_longlong(const char *p, const formatdef *f) > { > +#if HAVE_LONG_LONG > + PY_LONG_LONG x = 0; > + int i = f->size; > + do { > + x = (x<<8) | (*p++ & 0xFF); > + } while (--i > 0); > + /* Extend the sign bit. */ > + if (SIZEOF_LONG_LONG > f->size) > + x |= -(x & (1L << (8 * f->size - 1))); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x >= INT_MIN && x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); > +#endif > + return PyLong_FromLongLong(x); > +#else > return _PyLong_FromByteArray((const unsigned char *)p, > 8, > 0, /* little-endian */ > 1 /* signed */); > +#endif > } > > static PyObject * > bu_ulonglong(const char *p, const formatdef *f) > { > +#if HAVE_LONG_LONG > + unsigned PY_LONG_LONG x = 0; > + int i = f->size; > + do { > + x = (x<<8) | (*p++ & 0xFF); > + } while (--i > 0); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); > +#endif > + return PyLong_FromUnsignedLongLong(x); > +#else > return _PyLong_FromByteArray((const unsigned char *)p, > 8, > 0, /* little-endian */ > 0 /* signed */); > +#endif > } > > static PyObject * > @@ -750,28 +802,58 @@ > do { > x = (x<<8) | (p[--i] & 0xFF); > } while (i > 0); > - if (f->size >= 4) > - return PyLong_FromUnsignedLong(x); > - else > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > return PyInt_FromLong((long)x); > +#endif > + return PyLong_FromUnsignedLong((long)x); > } > > static PyObject * > lu_longlong(const char *p, const formatdef *f) > { > +#if HAVE_LONG_LONG > + PY_LONG_LONG x = 0; > + int i = f->size; > + do { > + x = (x<<8) | (p[--i] & 0xFF); > + } while (i > 0); > + /* Extend the sign bit. */ > + if (SIZEOF_LONG_LONG > f->size) > + x |= -(x & (1L << (8 * f->size - 1))); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x >= INT_MIN && x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); > +#endif > + return PyLong_FromLongLong(x); > +#else > return _PyLong_FromByteArray((const unsigned char *)p, > 8, > 1, /* little-endian */ > 1 /* signed */); > +#endif > } > > static PyObject * > lu_ulonglong(const char *p, const formatdef *f) > { > +#if HAVE_LONG_LONG > + unsigned PY_LONG_LONG x = 0; > + int i = f->size; > + do { > + x = (x<<8) | (p[--i] & 0xFF); > + } while (i > 0); > +#ifdef PY_USE_INT_WHEN_POSSIBLE > + if (x <= INT_MAX) > + return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); > +#endif > + return PyLong_FromUnsignedLongLong(x); > +#else > return _PyLong_FromByteArray((const unsigned char *)p, > 8, > 1, /* little-endian */ > 0 /* signed */); > +#endif > } > > static PyObject * > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From tim.peters at gmail.com Sun May 28 04:52:15 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sun, 28 May 2006 02:52:15 +0000 Subject: [Python-checkins] r46240 - python/trunk/Modules/_struct.c In-Reply-To: References: <20060525184450.673BE1E400B@bag.python.org> Message-ID: <1f7befae0605271952h74ad34d2rc2f4233f5443a4e1@mail.gmail.com> [Neal Norwitz] > All occurrences of *p & 0xFF where p is a char* should use Py_CHARMASK(). Better is to declare p as "unsigned char *" to begin with -- then no tricks are needed. We have the Py_CHARMASK() irritation because public API functions were originallly defined as taking plain "char *" arguments, leaving it ambiguous for no real reason (and possibly under the seemingly sane expectation that no compiler would decide to that the unqualified char type was signed -- heh). The functions in _struct.c are private to that module, so are free to declare what they intend without the backward compatibility headaches public API functions suffer. From neal at metaslash.com Sun May 28 11:05:34 2006 From: neal at metaslash.com (Neal Norwitz) Date: Sun, 28 May 2006 05:05:34 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (101) Message-ID: <20060528090534.GA5026@python.psfb.org> test_builtin leaked [130, 130, 130] references test_exceptions leaked [77, 77, 77] references test_anydbm leaked [84, 84, 84] references test_bisect leaked [144, 144, 144] references test_bz2 leaked [6, 6, 6] references test_cfgparser leaked [18, 18, 18] references test_charmapcodec leaked [5, 5, 5] references test_code leaked [24, 24, 24] references test_codeccallbacks leaked [10772, 10772, 10772] references test_codecencodings_cn leaked [282, 282, 282] references test_codecencodings_hk leaked [96, 96, 96] references test_codecencodings_jp leaked [490, 490, 490] references test_codecencodings_kr leaked [288, 288, 288] references test_codecencodings_tw leaked [96, 96, 96] references test_codecmaps_cn leaked [18, 18, 18] references test_codecmaps_hk leaked [9, 9, 9] references test_codecmaps_jp leaked [45, 45, 45] references test_codecmaps_kr leaked [27, 27, 27] references test_codecmaps_tw leaked [18, 18, 18] references test_codecs leaked [445, 445, 445] references test_codeop leaked [873, 873, 873] references test_coding leaked [20, 20, 20] references test_compile leaked [245, 245, 245] references test_contextlib leaked [3, 3, 3] references test_cookie leaked [222, 222, 222] references test_cookielib leaked [12, 12, 12] references test_csv leaked [9, 9, 9] references test_dbm leaked [21, 21, 21] references test_decimal leaked [834, 834, 834] references test_decorators leaked [20, 20, 20] references test_deque leaked [306, 306, 306] references test_descrtut leaked [168, 168, 168] references test_difflib leaked [126, 126, 126] references test_dircache leaked [6, 6, 6] references test_distutils leaked [60, 60, 60] references test_doctest leaked [2091, 2091, 2091] references test_doctest2 leaked [72, 72, 72] references test_dumbdbm leaked [153, 153, 153] references test_dummy_thread leaked [1, 1, 1] references test_email leaked [1271, 1271, 1271] references test_email_renamed leaked [1271, 1271, 1271] references test_eof leaked [10, 10, 10] references test_file leaked [6, 6, 6] references test_filecmp leaked [3, 3, 3] references test_fileinput leaked [24, 24, 24] references test_future leaked [15, 15, 15] references test_generators leaked [179, 179, 179] references test_genexps leaked [38, 38, 38] references test_getargs leaked [5, 5, 5] references test_getopt leaked [18, 18, 18] references test_gettext leaked [168, 168, 168] references test_glob leaked [174, 174, 174] references test_itertools leaked [516, 516, 516] references test_mailbox leaked [1575, 1575, 1575] references test_mhlib leaked [204, 204, 204] references test_minidom leaked [5, 5, 5] references test_mmap leaked [3, 3, 3] references test_multibytecodec leaked [40, 40, 40] references test_normalization leaked [3, 3, 3] references test_os leaked [30, 30, 30] references test_parser leaked [5, 5, 5] references test_pep352 leaked [28, 28, 28] references test_pickle leaked [618, 618, 618] references test_pickletools leaked [186, 186, 186] references test_pkgimport leaked [20, 20, 20] references test_platform leaked [9, 9, 9] references test_poll leaked [3, 3, 3] references test_posix leaked [3, 3, 3] references test_posixpath leaked [42, 42, 42] references test_pty leaked [3, 3, 3] references test_resource leaked [3, 3, 3] references test_rgbimg leaked [111, 111, 111] references test_runpy leaked [9, 9, 9] references test_sets leaked [6, 6, 6] references test_shelve leaked [972, 972, 972] references test_shutil leaked [21, 21, 21] references test_site leaked [45, 45, 45] references test_socket leaked [1, 1, 1] references test_sqlite leaked [27, 27, 27] references test_struct leaked [-4, -4, -4] references test_subprocess leaked [9, 9, 9] references test_syntax leaked [276, 276, 276] references test_tarfile leaked [249, 249, 249] references test_tempfile leaked [318, 318, 318] references test_threading_local leaked [-79, 12, 12] references test_tokenize leaked [30, 30, 30] references test_traceback leaked [21, 21, 21] references test_ucn leaked [20, 20, 20] references test_unicode leaked [84, 84, 84] references test_unittest leaked [18, 18, 18] references test_unpack leaked [18, 18, 18] references test_urllib leaked [10, 10, 10] references test_urllib2 leaked [1250, 997, 1074] references test_urllib2net leaked [23, 23, 23] references test_urllibnet leaked [14, 14, 14] references test_uu leaked [6, 6, 6] references test_weakref leaked [480, 480, 480] references test_whichdb leaked [69, 69, 69] references test_with leaked [30, 30, 30] references test_xml_etree leaked [214, 214, 214] references test_xml_etree_c leaked [199, 199, 199] references test_xmlrpc leaked [50, 50, 50] references test_zipfile leaked [3, 3, 3] references test_zipimport leaked [60, 60, 60] references test_ctypes leaked [64, 64, 64] references test_inspect leaked [6, 6, 6] references test_grammar leaked [55, 55, 55] references From python-checkins at python.org Sun May 28 12:32:02 2006 From: python-checkins at python.org (sean.reifschneider) Date: Sun, 28 May 2006 12:32:02 +0200 (CEST) Subject: [Python-checkins] r46496 - in sandbox/trunk/pybch: Tests/stringbench.py pybch.py Message-ID: <20060528103202.502DE1E4007@bag.python.org> Author: sean.reifschneider Date: Sun May 28 12:32:01 2006 New Revision: 46496 Modified: sandbox/trunk/pybch/Tests/stringbench.py sandbox/trunk/pybch/pybch.py Log: Latest version of pybch code before I travel. Modified: sandbox/trunk/pybch/Tests/stringbench.py ============================================================================== --- sandbox/trunk/pybch/Tests/stringbench.py (original) +++ sandbox/trunk/pybch/Tests/stringbench.py Sun May 28 12:32:01 2006 @@ -10,9 +10,6 @@ import optparse from TestHelpers import Test -print sys.version -print datetime.datetime.now() - REPEAT = 1 REPEAT = 3 #REPEAT = 7 Modified: sandbox/trunk/pybch/pybch.py ============================================================================== --- sandbox/trunk/pybch/pybch.py (original) +++ sandbox/trunk/pybch/pybch.py Sun May 28 12:32:01 2006 @@ -6,6 +6,7 @@ import time, sys, pickle, os verbose = 4 +verbose = 0 ###################### def rusageTimer(self): @@ -125,6 +126,8 @@ if verbose >= 2: print 'Calibrating...' test.cowlibrate() if verbose >= 3: print 'Calibrated to %d rounds' % test.rounds + print '%s.rounds = %d' % ( testClass, test.rounds ) + continue if verbose >= 2: print 'Running tests...' first = None From python-checkins at python.org Sun May 28 12:41:30 2006 From: python-checkins at python.org (tim.peters) Date: Sun, 28 May 2006 12:41:30 +0200 (CEST) Subject: [Python-checkins] r46497 - python/trunk/Python/errors.c python/trunk/Python/pythonrun.c Message-ID: <20060528104130.88AA71E4006@bag.python.org> Author: tim.peters Date: Sun May 28 12:41:29 2006 New Revision: 46497 Modified: python/trunk/Python/errors.c python/trunk/Python/pythonrun.c Log: PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste bug in both: `className` was referenced before being checked for NULL. Modified: python/trunk/Python/errors.c ============================================================================== --- python/trunk/Python/errors.c (original) +++ python/trunk/Python/errors.c Sun May 28 12:41:29 2006 @@ -588,13 +588,16 @@ if (f != NULL) { PyFile_WriteString("Exception ", f); if (t) { - char* className = PyExceptionClass_Name(t); PyObject* moduleName; - char *dot = strrchr(className, '.'); - if (dot != NULL) - className = dot+1; - moduleName = PyObject_GetAttrString(t, "__module__"); + char* className = PyExceptionClass_Name(t); + if (className != NULL) { + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; + } + + moduleName = PyObject_GetAttrString(t, "__module__"); if (moduleName == NULL) PyFile_WriteString("", f); else { Modified: python/trunk/Python/pythonrun.c ============================================================================== --- python/trunk/Python/pythonrun.c (original) +++ python/trunk/Python/pythonrun.c Sun May 28 12:41:29 2006 @@ -663,7 +663,7 @@ /* Parse input from a file and execute it */ int -PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, +PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) { if (filename == NULL) @@ -744,7 +744,7 @@ ps2 = PyString_AsString(w); } arena = PyArena_New(); - mod = PyParser_ASTFromFile(fp, filename, + mod = PyParser_ASTFromFile(fp, filename, Py_single_input, ps1, ps2, flags, &errcode, arena); Py_XDECREF(v); @@ -1132,13 +1132,15 @@ /* Don't do anything else */ } else if (PyExceptionClass_Check(exception)) { - char* className = PyExceptionClass_Name(exception); - char *dot = strrchr(className, '.'); PyObject* moduleName; - if (dot != NULL) - className = dot+1; - moduleName = PyObject_GetAttrString(exception, "__module__"); + char* className = PyExceptionClass_Name(exception); + if (className != NULL) { + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; + } + moduleName = PyObject_GetAttrString(exception, "__module__"); if (moduleName == NULL) err = PyFile_WriteString("", f); else { @@ -1184,7 +1186,7 @@ } PyObject * -PyRun_StringFlags(const char *str, int start, PyObject *globals, +PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) { PyObject *ret = NULL; @@ -1231,7 +1233,7 @@ } static PyObject * -run_pyc_file(FILE *fp, const char *filename, PyObject *globals, +run_pyc_file(FILE *fp, const char *filename, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) { PyCodeObject *co; @@ -1300,13 +1302,13 @@ /* Preferred access to parser is through AST. */ mod_ty -PyParser_ASTFromString(const char *s, const char *filename, int start, +PyParser_ASTFromString(const char *s, const char *filename, int start, PyCompilerFlags *flags, PyArena *arena) { mod_ty mod; perrdetail err; node *n = PyParser_ParseStringFlagsFilename(s, filename, - &_PyParser_Grammar, start, &err, + &_PyParser_Grammar, start, &err, PARSER_FLAGS(flags)); if (n) { mod = PyAST_FromNode(n, flags, filename, arena); @@ -1320,7 +1322,7 @@ } mod_ty -PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, +PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena) { @@ -1351,7 +1353,7 @@ start, NULL, NULL, &err, flags); if (n == NULL) err_input(&err); - + return n; } From python-checkins at python.org Sun May 28 14:06:47 2006 From: python-checkins at python.org (fredrik.lundh) Date: Sun, 28 May 2006 14:06:47 +0200 (CEST) Subject: [Python-checkins] r46499 - in python/trunk: Include/pyport.h Include/unicodeobject.h Objects/stringobject.c Message-ID: <20060528120647.BE9B41E4006@bag.python.org> Author: fredrik.lundh Date: Sun May 28 14:06:46 2006 New Revision: 46499 Modified: python/trunk/Include/pyport.h python/trunk/Include/unicodeobject.h python/trunk/Objects/stringobject.c Log: needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only), and use it for string copy operations. this gives a 20% speedup on some string benchmarks. Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Sun May 28 14:06:46 2006 @@ -174,6 +174,27 @@ #define Py_LOCAL_INLINE(type) static type #endif +/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks + * are often very short. While most platforms have highly optimized code for + * large transfers, the setup costs for memcpy are often quite high. MEMCPY + * solves this by doing short copies "in line". + */ + +#if defined(_MSC_VER) +#define Py_MEMCPY(target, source, length) do { \ + size_t i_, n_ = (length); \ + char *t_ = (void*) (target); \ + const char *s_ = (void*) (source); \ + if (n_ >= 16) \ + memcpy(t_, s_, n_); \ + else \ + for (i_ = 0; i_ < n_; i_++) \ + t_[i_] = s_[i_]; \ + } while (0) +#else +#define Py_MEMCPY memcpy +#endif + #include #include /* Moved here from the math section, before extern "C" */ Modified: python/trunk/Include/unicodeobject.h ============================================================================== --- python/trunk/Include/unicodeobject.h (original) +++ python/trunk/Include/unicodeobject.h Sun May 28 14:06:46 2006 @@ -357,15 +357,8 @@ Py_UNICODE_ISDIGIT(ch) || \ Py_UNICODE_ISNUMERIC(ch)) -/* memcpy has a considerable setup overhead on many platforms; use a - loop for short strings (the "16" below is pretty arbitary) */ -#define Py_UNICODE_COPY(target, source, length) do\ - {Py_ssize_t i_; Py_UNICODE *t_ = (target); const Py_UNICODE *s_ = (source);\ - if (length > 16)\ - memcpy(t_, s_, (length)*sizeof(Py_UNICODE));\ - else\ - for (i_ = 0; i_ < (length); i_++) t_[i_] = s_[i_];\ - } while (0) +#define Py_UNICODE_COPY(target, source, length) \ + Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) #define Py_UNICODE_FILL(target, value, length) do\ {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Sun May 28 14:06:46 2006 @@ -23,7 +23,6 @@ */ static PyObject *interned; - /* For both PyString_FromString() and PyString_FromStringAndSize(), the parameter `size' denotes number of characters to allocate, not counting any @@ -80,7 +79,7 @@ op->ob_shash = -1; op->ob_sstate = SSTATE_NOT_INTERNED; if (str != NULL) - memcpy(op->ob_sval, str, size); + Py_MEMCPY(op->ob_sval, str, size); op->ob_sval[size] = '\0'; /* share short strings */ if (size == 0) { @@ -134,7 +133,7 @@ PyObject_INIT_VAR(op, &PyString_Type, size); op->ob_shash = -1; op->ob_sstate = SSTATE_NOT_INTERNED; - memcpy(op->ob_sval, str, size+1); + Py_MEMCPY(op->ob_sval, str, size+1); /* share short strings */ if (size == 0) { PyObject *t = (PyObject *)op; @@ -162,7 +161,7 @@ PyObject* string; #ifdef VA_LIST_IS_ARRAY - memcpy(count, vargs, sizeof(va_list)); + Py_MEMCPY(count, vargs, sizeof(va_list)); #else #ifdef __va_copy __va_copy(count, vargs); @@ -304,7 +303,7 @@ i = strlen(p); if (n > 0 && i > n) i = n; - memcpy(s, p, i); + Py_MEMCPY(s, p, i); s += i; break; case 'p': @@ -583,7 +582,7 @@ assert(PyString_Check(w)); r = PyString_AS_STRING(w); rn = PyString_GET_SIZE(w); - memcpy(p, r, rn); + Py_MEMCPY(p, r, rn); p += rn; Py_DECREF(w); s = t; @@ -967,8 +966,8 @@ PyObject_INIT_VAR(op, &PyString_Type, size); op->ob_shash = -1; op->ob_sstate = SSTATE_NOT_INTERNED; - memcpy(op->ob_sval, a->ob_sval, a->ob_size); - memcpy(op->ob_sval + a->ob_size, b->ob_sval, b->ob_size); + Py_MEMCPY(op->ob_sval, a->ob_sval, a->ob_size); + Py_MEMCPY(op->ob_sval + a->ob_size, b->ob_sval, b->ob_size); op->ob_sval[size] = '\0'; return (PyObject *) op; #undef b @@ -1017,12 +1016,12 @@ } i = 0; if (i < size) { - memcpy(op->ob_sval, a->ob_sval, a->ob_size); + Py_MEMCPY(op->ob_sval, a->ob_sval, a->ob_size); i = a->ob_size; } while (i < size) { j = (i <= size-i) ? i : size-i; - memcpy(op->ob_sval+i, op->ob_sval, j); + Py_MEMCPY(op->ob_sval+i, op->ob_sval, j); i += j; } return (PyObject *) op; @@ -1808,10 +1807,10 @@ size_t n; item = PySequence_Fast_GET_ITEM(seq, i); n = PyString_GET_SIZE(item); - memcpy(p, PyString_AS_STRING(item), n); + Py_MEMCPY(p, PyString_AS_STRING(item), n); p += n; if (i < seqlen - 1) { - memcpy(p, sep, seplen); + Py_MEMCPY(p, sep, seplen); p += seplen; } } @@ -1851,7 +1850,6 @@ Py_ssize_t sub_len; Py_ssize_t start=0, end=PY_SSIZE_T_MAX; - /* XXX ssize_t i */ if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", &subobj, _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return -2; @@ -1865,6 +1863,8 @@ (PyObject *)self, subobj, start, end, dir); #endif else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) + /* XXX - the "expected a character buffer object" is pretty + confusing for a non-expert. remap to something else ? */ return -2; if (dir > 0) @@ -2131,7 +2131,7 @@ s = PyString_AS_STRING(newobj); - memcpy(s, PyString_AS_STRING(self), n); + Py_MEMCPY(s, PyString_AS_STRING(self), n); for (i = 0; i < n; i++) { int c = Py_CHARMASK(s[i]); @@ -2164,7 +2164,7 @@ s = PyString_AS_STRING(newobj); - memcpy(s, PyString_AS_STRING(self), n); + Py_MEMCPY(s, PyString_AS_STRING(self), n); for (i = 0; i < n; i++) { int c = Py_CHARMASK(s[i]); @@ -2615,18 +2615,18 @@ /* TODO: special case single character, which doesn't need memcpy */ /* Lay the first one down (guaranteed this will occur) */ - memcpy(result_s, to_s, to_len); + Py_MEMCPY(result_s, to_s, to_len); result_s += to_len; count -= 1; for (i=0; itp_alloc(type, n); if (pnew != NULL) { - memcpy(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1); + Py_MEMCPY(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1); ((PyStringObject *)pnew)->ob_shash = ((PyStringObject *)tmp)->ob_shash; ((PyStringObject *)pnew)->ob_sstate = SSTATE_NOT_INTERNED; @@ -4792,7 +4792,7 @@ *res++ = *pbuf++; } } - memcpy(res, pbuf, len); + Py_MEMCPY(res, pbuf, len); res += len; rescnt -= len; while (--width >= len) { From python-checkins at python.org Sun May 28 17:20:43 2006 From: python-checkins at python.org (martin.blais) Date: Sun, 28 May 2006 17:20:43 +0200 (CEST) Subject: [Python-checkins] r46500 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Message-ID: <20060528152043.2D4771E4006@bag.python.org> Author: martin.blais Date: Sun May 28 17:20:42 2006 New Revision: 46500 Modified: sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py Log: Minor bug fix and added docs Modified: sandbox/trunk/hotbuffer/README.txt ============================================================================== --- sandbox/trunk/hotbuffer/README.txt (original) +++ sandbox/trunk/hotbuffer/README.txt Sun May 28 17:20:42 2006 @@ -13,9 +13,9 @@ .. contents:: .. 1 TODO - 1.1 Other Features - 1.2 Ideas - 1.3 Documentation + 1.1 Question + 1.2 Other Features + 1.3 Ideas TODO @@ -38,6 +38,15 @@ - Check if there a tp_file protocol and if there is, use that instead to provide the interface. + See file_read() from fileobject.c, you need to make it file_read_guts() and + create file_read() that allocates a string like before, but also add + file_readbuf() that reads directly into a writable buffer. + + Note the presence of readinto() as well, as present but deprecated. Search + the ML for readinto()'s story. + +* Fix the changes to struct and socket with the right types: + * Implement absolute get/put methods (getabs(n), putabs(n, data)) * The hot buffer can unpack in C, similarly implement pack() in C. @@ -58,6 +67,29 @@ size of the minimal line/message that you may ever encounter, otherwise you will have to write special parsing routines. +Question +-------- + +* In the buffer protocol, what is the difference between the + read-only/read-write buffer interfaces and the char-buffer interface? + + > + > In the buffer protocol, there are four functions:: + > + > typedef int (*getreadbufferproc)(PyObject *, int, void **); + > typedef int (*getwritebufferproc)(PyObject *, int, void **); + > typedef int (*getsegcountproc)(PyObject *, int *); + > typedef int (*getcharbufferproc)(PyObject *, int, char **); + > + > What is the difference between the read-only/read-write and the char-buffer + > functions? (apart from the type) What was the original intention of this + > interface? + > + > Also, why is there a Py_ssize_t version of this? + > + + + Other Features -------------- Modified: sandbox/trunk/hotbuffer/test_hotbuf.py ============================================================================== --- sandbox/trunk/hotbuffer/test_hotbuf.py (original) +++ sandbox/trunk/hotbuffer/test_hotbuf.py Sun May 28 17:20:42 2006 @@ -486,8 +486,8 @@ # Loop over all the messages in the current buffer. while hot: # Read the length and parse the message. - length = hot.getbyte() # No error can occur here, since we're - # still hot. + # No error can occur here, since we're hot. + length = hot.getbyte() if len(hot) < length: # Rollback the length byte and exit the loop to fill # the buffer with new data. @@ -514,10 +514,15 @@ hot.compact() s = read(len(hot)) if not s: + hot.flip() break # Finished the input, exit. hot.putstr(s) hot.flip() + # Process a truncated message. Maybe pass a truncated=1 flag? + if hot: + process_msg(hot) + def test_netstrings( self ): """ Test for parsing netstrings. From python-checkins at python.org Sun May 28 17:51:40 2006 From: python-checkins at python.org (michael.hudson) Date: Sun, 28 May 2006 17:51:40 +0200 (CEST) Subject: [Python-checkins] r46501 - python/trunk/Objects/exceptions.c Message-ID: <20060528155140.B755B1E4006@bag.python.org> Author: michael.hudson Date: Sun May 28 17:51:40 2006 New Revision: 46501 Modified: python/trunk/Objects/exceptions.c Log: Quality control, meet exceptions.c. Fix a number of problems with the need for speed code: One is doing this sort of thing: Py_DECREF(self->field); self->field = newval; Py_INCREF(self->field); without being very sure that self->field doesn't start with a value that has a __del__, because that almost certainly can lead to segfaults. As self->args is constrained to be an exact tuple we may as well exploit this fact consistently. This leads to quite a lot of simplification (and, hey, probably better performance). Add some error checking in places lacking it. Fix some rather strange indentation in the Unicode code. Delete some trailing whitespace. More to come, I haven't fixed all the reference leaks yet... Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sun May 28 17:51:40 2006 @@ -36,7 +36,7 @@ return NULL; } - self->message = PyString_FromString(""); + self->message = PyString_FromString(""); if (!self->message) { Py_DECREF(self); return NULL; @@ -53,9 +53,9 @@ Py_INCREF(self->args); if (PyTuple_GET_SIZE(self->args) == 1) { - Py_DECREF(self->message); + Py_CLEAR(self->message); self->message = PyTuple_GET_ITEM(self->args, 0); - Py_INCREF(self->message); + Py_INCREF(self->message); } return 0; } @@ -79,8 +79,7 @@ int BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg) { - if (self->dict) - Py_VISIT(self->dict); + Py_VISIT(self->dict); Py_VISIT(self->args); Py_VISIT(self->message); return 0; @@ -91,24 +90,13 @@ { PyObject *out; - switch (PySequence_Length(self->args)) { + switch (PyTuple_GET_SIZE(self->args)) { case 0: out = PyString_FromString(""); break; case 1: - { - PyObject *tmp = PySequence_GetItem(self->args, 0); - if (tmp) { - out = PyObject_Str(tmp); - Py_DECREF(tmp); - } - else - out = NULL; + out = PyObject_Str(PyTuple_GET_ITEM(self->args, 0)); break; - } - case -1: - PyErr_Clear(); - /* Fall through */ default: out = PyObject_Str(self->args); break; @@ -120,28 +108,14 @@ static PyObject * BaseException_repr(PyBaseExceptionObject *self) { - Py_ssize_t args_len; PyObject *repr_suffix; PyObject *repr; char *name; char *dot; - args_len = PySequence_Length(self->args); - if (args_len < 0) { + repr_suffix = PyObject_Repr(self->args); + if (!repr_suffix) return NULL; - } - - if (args_len == 0) { - repr_suffix = PyString_FromString("()"); - if (!repr_suffix) - return NULL; - } - else { - PyObject *args_repr = PyObject_Repr(self->args); - if (!args_repr) - return NULL; - repr_suffix = args_repr; - } name = (char *)self->ob_type->tp_name; dot = strrchr(name, '.'); @@ -172,18 +146,10 @@ static PyObject * BaseException_unicode(PyBaseExceptionObject *self) { - if (PySequence_Length(self->args) == 0) + if (PyTuple_GET_SIZE(self->args) == 0) return PyUnicode_FromUnicode(NULL, 0); - if (PySequence_Length(self->args) == 1) { - PyObject *temp = PySequence_GetItem(self->args, 0); - PyObject *unicode_obj; - if (!temp) { - return NULL; - } - unicode_obj = PyObject_Unicode(temp); - Py_DECREF(temp); - return unicode_obj; - } + if (PyTuple_GET_SIZE(self->args) == 1) + return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); return PyObject_Unicode(self->args); } #endif /* Py_USING_UNICODE */ @@ -394,7 +360,7 @@ /* * StandardError extends Exception */ -SimpleExtendsException(PyExc_Exception, StandardError, +SimpleExtendsException(PyExc_Exception, StandardError, "Base class for all standard Python exceptions that do not represent\n" "interpreter exiting."); @@ -445,7 +411,9 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - Py_DECREF(self->code); + if (size == 0) + return 0; + Py_CLEAR(self->code); if (size == 1) self->code = PyTuple_GET_ITEM(args, 0); else if (size > 1) @@ -514,12 +482,9 @@ if (!self) return NULL; - self->myerrno = Py_None; - Py_INCREF(Py_None); - self->strerror = Py_None; - Py_INCREF(Py_None); - self->filename = Py_None; - Py_INCREF(Py_None); + MAKE_IT_NONE(self->myerrno); + MAKE_IT_NONE(self->strerror); + MAKE_IT_NONE(self->filename); return (PyObject *)self; } @@ -548,22 +513,22 @@ if (PyTuple_GET_SIZE(args) <= 1) { return 0; } - - if (!PyArg_UnpackTuple(args, "EnvironmentError", 2, 3, + + if (!PyArg_UnpackTuple(args, "EnvironmentError", 2, 3, &myerrno, &strerror, &filename)) { return -1; } - Py_DECREF(self->myerrno); /* replacing */ + Py_CLEAR(self->myerrno); /* replacing */ self->myerrno = myerrno; Py_INCREF(self->myerrno); - Py_DECREF(self->strerror); /* replacing */ + Py_CLEAR(self->strerror); /* replacing */ self->strerror = strerror; Py_INCREF(self->strerror); /* self->filename will remain Py_None otherwise */ if (filename != NULL) { - Py_DECREF(self->filename); /* replacing */ + Py_CLEAR(self->filename); /* replacing */ self->filename = filename; Py_INCREF(self->filename); @@ -606,6 +571,9 @@ static PyObject * EnvironmentError_str(PyEnvironmentErrorObject *self) { + /* XXX this needs to be rewritten to cope with any of self->filename, + self->strerror and self->myerrno being NULL. + */ PyObject *rtnval = NULL; if (self->filename != Py_None) { @@ -677,20 +645,17 @@ PyObject *res = NULL, *tmp; /* self->args is only the first two real arguments if there was a * file name given to EnvironmentError. */ - if (PyTuple_Check(args) && - PyTuple_GET_SIZE(args) == 2 && - self->filename != Py_None) { + if (PyTuple_GET_SIZE(args) == 2 && + self->filename != Py_None) { args = PyTuple_New(3); if (!args) return NULL; - - tmp = PyTuple_GetItem(self->args, 0); - if (!tmp) goto finish; + + tmp = PyTuple_GET_ITEM(self->args, 0); Py_INCREF(tmp); PyTuple_SET_ITEM(args, 0, tmp); - - tmp = PyTuple_GetItem(self->args, 1); - if (!tmp) goto finish; + + tmp = PyTuple_GET_ITEM(self->args, 1); Py_INCREF(tmp); PyTuple_SET_ITEM(args, 1, tmp); @@ -700,7 +665,6 @@ Py_INCREF(args); } res = PyTuple_Pack(3, self->ob_type, args, self->dict); - finish: Py_DECREF(args); return res; } @@ -714,14 +678,14 @@ ComplexExtendsException(PyExc_StandardError, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, - EnvironmentError_str, + EnvironmentError_str, "Base class for I/O related errors."); /* * IOError extends EnvironmentError */ -MiddlingExtendsException(PyExc_EnvironmentError, IOError, +MiddlingExtendsException(PyExc_EnvironmentError, IOError, EnvironmentError, "I/O operation failed."); @@ -783,6 +747,9 @@ return (PyObject *)self; } + /* XXX this is dead code, surely? EnvironmentError_new always sets + self->myerrno to None! */ + /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ errcode = PyInt_AsLong(self->myerrno); @@ -850,6 +817,8 @@ static PyObject * WindowsError_str(PyWindowsErrorObject *self) { + /* XXX this probably also needs to be rewritten to cope with NULL-ness of + the fields */ PyObject *repr = NULL; PyObject *fmt = NULL; PyObject *tuple = NULL; @@ -995,7 +964,7 @@ return -1; if (lenargs >= 1) { - Py_DECREF(self->msg); + Py_CLEAR(self->msg); self->msg = PyTuple_GET_ITEM(args, 0); Py_INCREF(self->msg); } @@ -1004,21 +973,30 @@ info = PySequence_Tuple(info); if (!info) return -1; - Py_DECREF(self->filename); + if (PyTuple_GET_SIZE(info) != 4) { + /* not a very good error message, but it's what Python 2.4 gives */ + PyErr_SetString(PyExc_IndexError, "tuple index out of range"); + Py_DECREF(info); + return -1; + } + + Py_CLEAR(self->filename); self->filename = PyTuple_GET_ITEM(info, 0); Py_INCREF(self->filename); - Py_DECREF(self->lineno); + Py_CLEAR(self->lineno); self->lineno = PyTuple_GET_ITEM(info, 1); Py_INCREF(self->lineno); - Py_DECREF(self->offset); + Py_CLEAR(self->offset); self->offset = PyTuple_GET_ITEM(info, 2); Py_INCREF(self->offset); - Py_DECREF(self->text); + Py_CLEAR(self->text); self->text = PyTuple_GET_ITEM(info, 3); Py_INCREF(self->text); + + Py_DECREF(info); } return 0; } @@ -1091,7 +1069,7 @@ int have_lineno = 0; char *buffer = NULL; - have_filename = (self->filename != NULL) && + have_filename = (self->filename != NULL) && PyString_Check(self->filename); have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno); @@ -1196,9 +1174,8 @@ string, that string will be displayed in quotes. Too bad. If args is anything else, use the default BaseException__str__(). */ - if (PyTuple_Check(self->args) && PyTuple_GET_SIZE(self->args) == 1) { - PyObject *key = PyTuple_GET_ITEM(self->args, 0); - return PyObject_Repr(key); + if (PyTuple_GET_SIZE(self->args) == 1) { + return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0)); } return BaseException_str(self); } @@ -1531,7 +1508,7 @@ &PyInt_Type, &self->start, &PyInt_Type, &self->end, &PyString_Type, &self->reason)) { - self->encoding = self->object = self->start = self->end = + self->encoding = self->object = self->start = self->end = self->reason = NULL; return -1; } @@ -1616,27 +1593,27 @@ Py_ssize_t end; if (PyUnicodeEncodeError_GetStart(self, &start)) - return NULL; + return NULL; if (PyUnicodeEncodeError_GetEnd(self, &end)) - return NULL; + return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - return PyString_FromFormat( - "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), - badchar_str, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) - ); + int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( + "'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s", + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), + badchar_str, + start, + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( "'%.400s' codec can't encode characters in position %zd-%zd: %.400s", @@ -1668,7 +1645,7 @@ Py_ssize_t start, Py_ssize_t end, const char *reason) { return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", - encoding, object, length, start, end, reason); + encoding, object, length, start, end, reason); } @@ -1703,17 +1680,17 @@ return NULL; if (end==start+1) { - /* FromFormat does not support %02x, so format that separately */ - char byte[4]; - PyOS_snprintf(byte, sizeof(byte), "%02x", - ((int)PyString_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start])&0xff); - return PyString_FromFormat( - "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), - byte, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) - ); + /* FromFormat does not support %02x, so format that separately */ + char byte[4]; + PyOS_snprintf(byte, sizeof(byte), "%02x", + ((int)PyString_AS_STRING(((PyUnicodeErrorObject *)self)->object)[start])&0xff); + return PyString_FromFormat( + "'%.400s' codec can't decode byte 0x%s in position %zd: %.400s", + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->encoding), + byte, + start, + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( "'%.400s' codec can't decode bytes in position %zd-%zd: %.400s", @@ -1748,7 +1725,7 @@ assert(start < INT_MAX); assert(end < INT_MAX); return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns", - encoding, object, length, start, end, reason); + encoding, object, length, start, end, reason); } @@ -1793,7 +1770,7 @@ self->object = self->start = self->end = self->reason = NULL; return -1; } - + Py_INCREF(self->object); Py_INCREF(self->start); Py_INCREF(self->end); @@ -1810,26 +1787,26 @@ Py_ssize_t end; if (PyUnicodeTranslateError_GetStart(self, &start)) - return NULL; + return NULL; if (PyUnicodeTranslateError_GetEnd(self, &end)) - return NULL; + return NULL; if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; - char badchar_str[20]; - if (badchar <= 0xff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); - else if (badchar <= 0xffff) - PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); - else - PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); - return PyString_FromFormat( + int badchar = (int)PyUnicode_AS_UNICODE(((PyUnicodeErrorObject *)self)->object)[start]; + char badchar_str[20]; + if (badchar <= 0xff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "x%02x", badchar); + else if (badchar <= 0xffff) + PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar); + else + PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar); + return PyString_FromFormat( "can't translate character u'\\%s' in position %zd: %.400s", - badchar_str, - start, - PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) - ); + badchar_str, + start, + PyString_AS_STRING(((PyUnicodeErrorObject *)self)->reason) + ); } return PyString_FromFormat( "can't translate characters in position %zd-%zd: %.400s", @@ -1860,7 +1837,7 @@ Py_ssize_t start, Py_ssize_t end, const char *reason) { return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", - object, length, start, end, reason); + object, length, start, end, reason); } #endif @@ -2003,7 +1980,7 @@ Py_FatalError("Module dictionary insertion problem."); PyMODINIT_FUNC -_PyExc_Init(void) +_PyExc_Init(void) { PyObject *m, *bltinmod, *bdict; From python-checkins at python.org Sun May 28 18:39:11 2006 From: python-checkins at python.org (george.yoshida) Date: Sun, 28 May 2006 18:39:11 +0200 (CEST) Subject: [Python-checkins] r46502 - in python/trunk: Doc/lib/libdoctest.tex Lib/doctest.py Lib/test/test_doctest.py Lib/test/test_doctest4.txt Misc/NEWS Message-ID: <20060528163911.761A31E4006@bag.python.org> Author: george.yoshida Date: Sun May 28 18:39:09 2006 New Revision: 46502 Added: python/trunk/Lib/test/test_doctest4.txt Modified: python/trunk/Doc/lib/libdoctest.tex python/trunk/Lib/doctest.py python/trunk/Lib/test/test_doctest.py python/trunk/Misc/NEWS Log: Patch #1080727: add "encoding" parameter to doctest.DocFileSuite Contributed by Bjorn Tillenius. Modified: python/trunk/Doc/lib/libdoctest.tex ============================================================================== --- python/trunk/Doc/lib/libdoctest.tex (original) +++ python/trunk/Doc/lib/libdoctest.tex Sun May 28 18:39:09 2006 @@ -868,7 +868,7 @@ globs}\optional{, verbose}\optional{, report}\optional{, optionflags}\optional{, extraglobs}\optional{, raise_on_error}\optional{, - parser}} + parser}\optional{, encoding}} All arguments except \var{filename} are optional, and should be specified in keyword form. @@ -941,7 +941,13 @@ subclass) that should be used to extract tests from the files. It defaults to a normal parser (i.e., \code{\class{DocTestParser}()}). + Optional argument \var{encoding} specifies an encoding that should + be used to convert the file to unicode. + \versionadded{2.4} + + \versionchanged[The parameter \var{encoding} was added]{2.5} + \end{funcdesc} \begin{funcdesc}{testmod}{\optional{m}\optional{, name}\optional{, @@ -1061,7 +1067,8 @@ \begin{funcdesc}{DocFileSuite}{\optional{module_relative}\optional{, package}\optional{, setUp}\optional{, tearDown}\optional{, globs}\optional{, - optionflags}\optional{, parser}} + optionflags}\optional{, parser}\optional{, + encoding}} Convert doctest tests from one or more text files to a \class{\refmodule{unittest}.TestSuite}. @@ -1128,11 +1135,17 @@ subclass) that should be used to extract tests from the files. It defaults to a normal parser (i.e., \code{\class{DocTestParser}()}). + Optional argument \var{encoding} specifies an encoding that should + be used to convert the file to unicode. + \versionadded{2.4} \versionchanged[The global \code{__file__} was added to the globals provided to doctests loaded from a text file using \function{DocFileSuite()}]{2.5} + + \versionchanged[The parameter \var{encoding} was added]{2.5} + \end{funcdesc} \begin{funcdesc}{DocTestSuite}{\optional{module}\optional{, Modified: python/trunk/Lib/doctest.py ============================================================================== --- python/trunk/Lib/doctest.py (original) +++ python/trunk/Lib/doctest.py Sun May 28 18:39:09 2006 @@ -1869,7 +1869,8 @@ def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, - extraglobs=None, raise_on_error=False, parser=DocTestParser()): + extraglobs=None, raise_on_error=False, parser=DocTestParser(), + encoding=None): """ Test examples in the given file. Return (#failures, #tests). @@ -1935,6 +1936,9 @@ Optional keyword arg "parser" specifies a DocTestParser (or subclass) that should be used to extract tests from the files. + Optional keyword arg "encoding" specifies an encoding that should + be used to convert the file to unicode. + Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master @@ -1969,6 +1973,9 @@ else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) + if encoding is not None: + text = text.decode(encoding) + # Read the file, convert it to a test, and run it. test = parser.get_doctest(text, globs, name, filename, 0) runner.run(test) @@ -2339,7 +2346,8 @@ ) def DocFileTest(path, module_relative=True, package=None, - globs=None, parser=DocTestParser(), **options): + globs=None, parser=DocTestParser(), + encoding=None, **options): if globs is None: globs = {} else: @@ -2357,6 +2365,10 @@ # Find the file and read it. name = os.path.basename(path) + + # If an encoding is specified, use it to convert the file to unicode + if encoding is not None: + doc = doc.decode(encoding) # Convert it to a test, and wrap it in a DocFileCase. test = parser.get_doctest(doc, globs, name, path, 0) @@ -2414,6 +2426,9 @@ parser A DocTestParser (or subclass) that should be used to extract tests from the files. + + encoding + An encoding that will be used to convert the files to unicode. """ suite = unittest.TestSuite() Modified: python/trunk/Lib/test/test_doctest.py ============================================================================== --- python/trunk/Lib/test/test_doctest.py (original) +++ python/trunk/Lib/test/test_doctest.py Sun May 28 18:39:09 2006 @@ -1937,9 +1937,10 @@ >>> import unittest >>> suite = doctest.DocFileSuite('test_doctest.txt', - ... 'test_doctest2.txt') + ... 'test_doctest2.txt', + ... 'test_doctest4.txt') >>> suite.run(unittest.TestResult()) - + The test files are looked for in the directory containing the calling module. A package keyword argument can be provided to @@ -1948,9 +1949,10 @@ >>> import unittest >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', + ... 'test_doctest4.txt', ... package='test') >>> suite.run(unittest.TestResult()) - + '/' should be used as a path separator. It will be converted to a native separator at run time: @@ -1995,19 +1997,21 @@ >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', + ... 'test_doctest4.txt', ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) - + In this case, we supplied a missing favorite color. You can provide doctest options: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', + ... 'test_doctest4.txt', ... optionflags=doctest.DONT_ACCEPT_BLANKLINE, ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) - + And, you can provide setUp and tearDown functions: @@ -2025,9 +2029,10 @@ >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', + ... 'test_doctest4.txt', ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) - + But the tearDown restores sanity: @@ -2060,6 +2065,17 @@ >>> suite.run(unittest.TestResult()) + If the tests contain non-ASCII characters, we have to specify which + encoding the file is encoded with. We do so by using the `encoding` + parameter: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... 'test_doctest4.txt', + ... encoding='utf-8') + >>> suite.run(unittest.TestResult()) + + """ def test_trailing_space_in_test(): @@ -2266,6 +2282,32 @@ Traceback (most recent call last): UnexpectedException: ... >>> doctest.master = None # Reset master. + +If the tests contain non-ASCII characters, the tests might fail, since +it's unknown which encoding is used. The encoding can be specified +using the optional keyword argument `encoding`: + + >>> doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS + ********************************************************************** + File "...", line 7, in test_doctest4.txt + Failed example: + u'...' + Expected: + u'f\xf6\xf6' + Got: + u'f\xc3\xb6\xc3\xb6' + ********************************************************************** + ... + ********************************************************************** + 1 items had failures: + 2 of 4 in test_doctest4.txt + ***Test Failed*** 2 failures. + (2, 4) + >>> doctest.master = None # Reset master. + + >>> doctest.testfile('test_doctest4.txt', encoding='utf-8') + (0, 4) + >>> doctest.master = None # Reset master. """ # old_test1, ... used to live in doctest.py, but cluttered it. Note Added: python/trunk/Lib/test/test_doctest4.txt ============================================================================== --- (empty file) +++ python/trunk/Lib/test/test_doctest4.txt Sun May 28 18:39:09 2006 @@ -0,0 +1,17 @@ +This is a sample doctest in a text file that contains non-ASCII characters. +This file is encoded using UTF-8. + +In order to get this test to pass, we have to manually specify the +encoding. + + >>> u'f??' + u'f\xf6\xf6' + + >>> u'b?r' + u'b\u0105r' + + >>> 'f??' + 'f\xc3\xb6\xc3\xb6' + + >>> 'b?r' + 'b\xc4\x85r' Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun May 28 18:39:09 2006 @@ -85,6 +85,8 @@ Library ------- +- Patch #1080727: add "encoding" parameter to doctest.DocFileSuite. + - Patch #1281707: speed up gzip.readline. - Patch #1180296: Two new functions were added to the locale module: From python-checkins at python.org Sun May 28 18:57:44 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 28 May 2006 18:57:44 +0200 (CEST) Subject: [Python-checkins] r46503 - in python/trunk: PC/icons PC/icons/baselogo.svg PC/icons/source.xar Tools/msi/msi.py Message-ID: <20060528165744.D36011E4006@bag.python.org> Author: martin.v.loewis Date: Sun May 28 18:57:38 2006 New Revision: 46503 Added: python/trunk/PC/icons/ python/trunk/PC/icons/baselogo.svg (contents, props changed) python/trunk/PC/icons/source.xar (contents, props changed) Modified: python/trunk/Tools/msi/msi.py Log: Rest of patch #1490384: Commit icon source, remove claim that Erik von Blokland is the author of the installer picture. Added: python/trunk/PC/icons/baselogo.svg ============================================================================== --- (empty file) +++ python/trunk/PC/icons/baselogo.svg Sun May 28 18:57:38 2006 @@ -0,0 +1,609 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: python/trunk/PC/icons/source.xar ============================================================================== Binary file. No diff available. Modified: python/trunk/Tools/msi/msi.py ============================================================================== --- python/trunk/Tools/msi/msi.py (original) +++ python/trunk/Tools/msi/msi.py Sun May 28 18:57:38 2006 @@ -455,10 +455,6 @@ exit_dialog.cancel("Cancel", "Back", active = 0) exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003, "Special Windows thanks to:\n" - " LettError, Erik van Blokland, for the \n" - " Python for Windows graphic.\n" - " http://www.letterror.com/\n" - "\n" " Mark Hammond, without whose years of freely \n" " shared Windows expertise, Python for Windows \n" " would still be Python for DOS.") From martin at v.loewis.de Sun May 28 19:08:45 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 28 May 2006 19:08:45 +0200 Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: References: <20060527103949.6437A1E4006@bag.python.org> <20060527121450.GA7023@rogue.amk.ca> <4478478C.6060709@v.loewis.de> Message-ID: <4479D91D.7060809@v.loewis.de> Fredrik Lundh wrote: > is there an easy way to switch this off on a file-by-file basis ? It's easy to switch this off on a per-function basis, by declaring the function as regparm(0), or not declaring it static. I could not find a way to turn this off for an entire single file. Regards, Martin From martin at v.loewis.de Sun May 28 19:12:06 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 28 May 2006 19:12:06 +0200 Subject: [Python-checkins] r46438 - in python/trunk: Include/pyport.h Python/ceval.c In-Reply-To: References: <20060527103949.6437A1E4006@bag.python.org> <20060527121450.GA7023@rogue.amk.ca> <4478478C.6060709@v.loewis.de> Message-ID: <4479D9E6.1060900@v.loewis.de> Bob Ippolito wrote: > function-by-function.. > > noinline > This function attribute prevents a function from being considered > for inlining. > > http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html This doesn't affect the calling convention, though - even if the function is noinline, it still may auto-regparm. Regards, Martin From martin at v.loewis.de Sun May 28 19:17:07 2006 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sun, 28 May 2006 19:17:07 +0200 Subject: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj python/trunk/PCbuild8/_msi.vcproj python/trunk/PCbuild8/_socket.vcproj python/trunk/PCbuild8/_sqlite3.vcproj python/trunk/PCbuild8/_ssl.mak python/trunk/PCbuild8/_ssl.vcproj python/trunk/PCbuild8/_testcapi.vcproj python/trunk/PCbuild8/_tkinter.vcproj python/trunk/PCbuild8/build_ssl.py python/trunk/PCbuild8/bz2.vcproj python/trunk/PCbuild8/db.build python/trunk/PCbuild8/field3.py python/trunk/PCbuild8/installer.bmp python/trunk/PCbuild8/make_buildinfo.c python/trunk/PCbuild8/make_buildinfo.vcproj python/trunk/PCbuild8/make_versioninfo.vcproj python/trunk/PCbuild8/pcbuild.sln python/trunk/PCbuild8/pyexpat.vcproj python/trunk/PCbuild8/python.build python/trunk/PCbuild8/python.iss python/trunk/PCbuild8/python.vcproj python/trunk/PCbuild8/python20.wse python/trunk/PCbuild8/pythoncore.vcproj python/trunk/PCbuild8/pythoncore_link.txt python/trunk/PCbuild8/pythoncore_pgo.vcproj python/trunk/PCbuild8/pythoncore_pgo_link.txt python/trunk/PCbuild8/pythonw.vcproj python/trunk/PCbuild8/readme.txt python/trunk/PCbuild8/rmpyc.py python/trunk/PCbuild8/rt.bat python/trunk/PCbuild8/select.vcproj python/trunk/PCbuild8/unicodedata.vcproj python/trunk/PCbuild8/w9xpopen.vcproj python/trunk/PCbuild8/winsound.vcproj In-Reply-To: <20060527154135.D276C1E4006@bag.python.org> References: <20060527154135.D276C1E4006@bag.python.org> Message-ID: <4479DB13.6070905@v.loewis.de> kristjan.jonsson wrote: > Add a PCBuild8 build directory for building with Visual Studio .NET > 2005. Contains a special project to perform profile guided > optimizations on the pythoncore.dll, by instrumenting and running > pybench.py Who is going to maintain that? Regards, Martin From martin at v.loewis.de Sun May 28 19:39:03 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 28 May 2006 19:39:03 +0200 Subject: [Python-checkins] r46499 - in python/trunk: Include/pyport.h Include/unicodeobject.h Objects/stringobject.c In-Reply-To: <20060528120647.BE9B41E4006@bag.python.org> References: <20060528120647.BE9B41E4006@bag.python.org> Message-ID: <4479E037.9000302@v.loewis.de> fredrik.lundh wrote: > needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only), > and use it for string copy operations. this gives a 20% speedup on some > string benchmarks. Shouldn't this better use #pragma intrinsic(memcpy) Regards, Martin From python-checkins at python.org Sun May 28 19:40:30 2006 From: python-checkins at python.org (michael.hudson) Date: Sun, 28 May 2006 19:40:30 +0200 (CEST) Subject: [Python-checkins] r46504 - python/trunk/Objects/exceptions.c Message-ID: <20060528174030.2D7C71E400E@bag.python.org> Author: michael.hudson Date: Sun May 28 19:40:29 2006 New Revision: 46504 Modified: python/trunk/Objects/exceptions.c Log: Quality control, meet exceptions.c, round two. Make some functions that should have been static static. Fix a bunch of refleaks by fixing the definition of MiddlingExtendsException. Remove all the __new__ implementations apart from BaseException_new. Rewrite most code that needs it to cope with NULL fields (such code could get excercised anyway, the __new__-removal just makes it more likely). This involved editing the code for WindowsError, which I can't test. This fixes all the refleaks in at least the start of a regrtest -R :: run. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sun May 28 19:40:29 2006 @@ -60,7 +60,7 @@ return 0; } -int +static int BaseException_clear(PyBaseExceptionObject *self) { Py_CLEAR(self->dict); @@ -76,7 +76,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg) { Py_VISIT(self->dict); @@ -322,13 +322,13 @@ 0, \ EXC_MODULE_NAME # EXCNAME, \ sizeof(Py ## EXCSTORE ## Object), \ - 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, \ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ - PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ - (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ + PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \ + (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ - (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ + (initproc)EXCSTORE ## _init, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME @@ -345,7 +345,7 @@ (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \ EXCMEMBERS, 0, &_ ## EXCBASE, \ 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ - (initproc)EXCSTORE ## _init, 0, EXCSTORE ## _new,\ + (initproc)EXCSTORE ## _init, 0, BaseException_new,\ }; \ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME @@ -389,19 +389,6 @@ /* * SystemExit extends BaseException */ -static PyObject * -SystemExit_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySystemExitObject *self; - - self = (PySystemExitObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - MAKE_IT_NONE(self->code); - - return (PyObject *)self; -} static int SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) @@ -422,7 +409,7 @@ return 0; } -int +static int SystemExit_clear(PySystemExitObject *self) { Py_CLEAR(self->code); @@ -436,7 +423,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg) { Py_VISIT(self->code); @@ -473,22 +460,6 @@ * EnvironmentError extends StandardError */ -static PyObject * -EnvironmentError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyEnvironmentErrorObject *self = NULL; - - self = (PyEnvironmentErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - MAKE_IT_NONE(self->myerrno); - MAKE_IT_NONE(self->strerror); - MAKE_IT_NONE(self->filename); - - return (PyObject *)self; -} - /* Where a function has a single filename, such as open() or some * of the os module functions, PyErr_SetFromErrnoWithFilename() is * called, giving a third argument which is the filename. But, so @@ -542,7 +513,7 @@ return 0; } -int +static int EnvironmentError_clear(PyEnvironmentErrorObject *self) { Py_CLEAR(self->myerrno); @@ -558,7 +529,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int EnvironmentError_traverse(PyEnvironmentErrorObject *self, visitproc visit, void *arg) { @@ -571,26 +542,46 @@ static PyObject * EnvironmentError_str(PyEnvironmentErrorObject *self) { - /* XXX this needs to be rewritten to cope with any of self->filename, - self->strerror and self->myerrno being NULL. - */ PyObject *rtnval = NULL; - if (self->filename != Py_None) { - PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); - PyObject *repr = PyObject_Repr(self->filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); + if (self->filename) { + PyObject *fmt; + PyObject *repr; + PyObject *tuple; + + fmt = PyString_FromString("[Errno %s] %s: %s"); + if (!fmt) + return NULL; + + repr = PyObject_Repr(self->filename); + if (!repr) { + Py_DECREF(fmt); return NULL; } - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); - Py_INCREF(self->strerror); - PyTuple_SET_ITEM(tuple, 1, self->strerror); + tuple = PyTuple_New(3); + if (!tuple) { + Py_DECREF(repr); + Py_DECREF(fmt); + return NULL; + } + + if (self->myerrno) { + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 0, Py_None); + } + if (self->strerror) { + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); + } + Py_INCREF(repr); PyTuple_SET_ITEM(tuple, 2, repr); @@ -599,20 +590,36 @@ Py_DECREF(fmt); Py_DECREF(tuple); } - else if (PyObject_IsTrue(self->myerrno) && - PyObject_IsTrue(self->strerror)) { - PyObject *fmt = PyString_FromString("[Errno %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); + else if (self->myerrno && self->strerror) { + PyObject *fmt; + PyObject *tuple; + + fmt = PyString_FromString("[Errno %s] %s"); + if (!fmt) return NULL; + + tuple = PyTuple_New(2); + if (!tuple) { + Py_DECREF(fmt); + return NULL; + } + + if (self->myerrno) { + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 0, Py_None); + } + if (self->strerror) { + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); } - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); - Py_INCREF(self->strerror); - PyTuple_SET_ITEM(tuple, 1, self->strerror); rtnval = PyString_Format(fmt, tuple); @@ -645,9 +652,7 @@ PyObject *res = NULL, *tmp; /* self->args is only the first two real arguments if there was a * file name given to EnvironmentError. */ - if (PyTuple_GET_SIZE(args) == 2 && - self->filename != Py_None) { - + if (PyTuple_GET_SIZE(args) == 2 && self->filename) { args = PyTuple_New(3); if (!args) return NULL; @@ -702,7 +707,7 @@ #ifdef MS_WINDOWS #include "errmap.h" -int +static int WindowsError_clear(PyWindowsErrorObject *self) { Py_CLEAR(self->myerrno); @@ -719,7 +724,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int WindowsError_traverse(PyWindowsErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->myerrno); @@ -729,53 +734,6 @@ return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } -static PyObject * -WindowsError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *o_errcode = NULL; - long errcode; - PyWindowsErrorObject *self; - long posix_errno; - - self = (PyWindowsErrorObject *)EnvironmentError_new(type, args, kwds); - if (!self) - return NULL; - - if (self->myerrno == Py_None) { - self->winerror = self->myerrno; - Py_INCREF(self->winerror); - return (PyObject *)self; - } - - /* XXX this is dead code, surely? EnvironmentError_new always sets - self->myerrno to None! */ - - /* Set errno to the POSIX errno, and winerror to the Win32 - error code. */ - errcode = PyInt_AsLong(self->myerrno); - if (errcode == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - /* give a clearer error message */ - PyErr_SetString(PyExc_TypeError, "errno has to be an integer"); - goto failed; - } - posix_errno = winerror_to_errno(errcode); - - self->winerror = self->myerrno; - - o_errcode = PyInt_FromLong(posix_errno); - if (!o_errcode) - goto failed; - - self->myerrno = o_errcode; - - return (PyObject *)self; -failed: - /* Could not set errno. */ - Py_DECREF(self); - return NULL; -} - static int WindowsError_init(PyWindowsErrorObject *self, PyObject *args, PyObject *kwds) { @@ -787,12 +745,8 @@ == -1) return -1; - if (self->myerrno == Py_None) { - Py_DECREF(self->winerror); - self->winerror = self->myerrno; - Py_INCREF(self->winerror); + if (self->myerrno == NULL) return 0; - } /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ @@ -801,7 +755,7 @@ return -1; posix_errno = winerror_to_errno(errcode); - Py_DECREF(self->winerror); + Py_CLEAR(self->winerror); self->winerror = self->myerrno; o_errcode = PyInt_FromLong(posix_errno); @@ -817,46 +771,93 @@ static PyObject * WindowsError_str(PyWindowsErrorObject *self) { - /* XXX this probably also needs to be rewritten to cope with NULL-ness of - the fields */ - PyObject *repr = NULL; - PyObject *fmt = NULL; - PyObject *tuple = NULL; PyObject *rtnval = NULL; - if (self->filename != Py_None) { + if (self->filename) { + PyObject *fmt; + PyObject *repr; + PyObject *tuple; + fmt = PyString_FromString("[Error %s] %s: %s"); + if (!fmt) + return NULL; + repr = PyObject_Repr(self->filename); - if (!fmt || !repr) - goto finally; + if (!repr) { + Py_DECREF(fmt); + return NULL; + } + tuple = PyTuple_New(3); + if (!tuple) { + Py_DECREF(repr); + Py_DECREF(fmt); + return NULL; + } - tuple = PyTuple_Pack(3, self->myerrno, self->strerror, repr); - if (!tuple) - goto finally; + if (self->myerrno) { + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 0, Py_None); + } + if (self->strerror) { + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); + } + + Py_INCREF(repr); + PyTuple_SET_ITEM(tuple, 2, repr); rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); Py_DECREF(tuple); } - else if (PyObject_IsTrue(self->myerrno) && - PyObject_IsTrue(self->strerror)) { + else if (self->myerrno && self->strerror) { + PyObject *fmt; + PyObject *tuple; + fmt = PyString_FromString("[Error %s] %s"); if (!fmt) - goto finally; + return NULL; - tuple = PyTuple_Pack(2, self->myerrno, self->strerror); - if (!tuple) - goto finally; + tuple = PyTuple_New(2); + if (!tuple) { + Py_DECREF(fmt); + return NULL; + } + + if (self->myerrno) { + Py_INCREF(self->myerrno); + PyTuple_SET_ITEM(tuple, 0, self->myerrno); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 0, Py_None); + } + if (self->strerror) { + Py_INCREF(self->strerror); + PyTuple_SET_ITEM(tuple, 1, self->strerror); + } + else { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); + } rtnval = PyString_Format(fmt, tuple); + + Py_DECREF(fmt); Py_DECREF(tuple); } else - rtnval = EnvironmentError_str((PyEnvironmentErrorObject *)self); + rtnval = EnvironmentError_str((PyEnvironmentErrorObject *)self); - finally: - Py_XDECREF(repr); - Py_XDECREF(fmt); - Py_XDECREF(tuple); return rtnval; } @@ -932,27 +933,6 @@ /* * SyntaxError extends StandardError */ -static PyObject * -SyntaxError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySyntaxErrorObject *self = NULL; - - self = (PySyntaxErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - MAKE_IT_NONE(self->msg) - MAKE_IT_NONE(self->filename) - MAKE_IT_NONE(self->lineno) - MAKE_IT_NONE(self->offset) - MAKE_IT_NONE(self->text) - - /* this is always None - yes, I know it doesn't seem to be used - anywhere, but it was in the previous implementation */ - MAKE_IT_NONE(self->print_file_and_line) - - return (PyObject *)self; -} static int SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) @@ -1001,7 +981,7 @@ return 0; } -int +static int SyntaxError_clear(PySyntaxErrorObject *self) { Py_CLEAR(self->msg); @@ -1020,7 +1000,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int SyntaxError_traverse(PySyntaxErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->msg); @@ -1058,7 +1038,10 @@ PyObject *str; PyObject *result; - str = PyObject_Str(self->msg); + if (self->msg) + str = PyObject_Str(self->msg); + else + str = PyObject_Str(Py_None); result = str; /* XXX -- do all the additional formatting with filename and @@ -1479,29 +1462,16 @@ } -static PyObject * -UnicodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds, - PyTypeObject *objecttype) -{ - PyUnicodeErrorObject *self; - - self = (PyUnicodeErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - MAKE_IT_NONE(self->encoding); - MAKE_IT_NONE(self->object); - MAKE_IT_NONE(self->start); - MAKE_IT_NONE(self->end); - MAKE_IT_NONE(self->reason); - - return (PyObject *)self; -} - static int UnicodeError_init(PyUnicodeErrorObject *self, PyObject *args, PyObject *kwds, PyTypeObject *objecttype) { + Py_CLEAR(self->encoding); + Py_CLEAR(self->object); + Py_CLEAR(self->start); + Py_CLEAR(self->end); + Py_CLEAR(self->reason); + if (!PyArg_ParseTuple(args, "O!O!O!O!O!", &PyString_Type, &self->encoding, objecttype, &self->object, @@ -1522,7 +1492,7 @@ return 0; } -int +static int UnicodeError_clear(PyUnicodeErrorObject *self) { Py_CLEAR(self->encoding); @@ -1540,7 +1510,7 @@ self->ob_type->tp_free((PyObject *)self); } -int +static int UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg) { Py_VISIT(self->encoding); @@ -1571,11 +1541,6 @@ /* * UnicodeEncodeError extends UnicodeError */ -static PyObject * -UnicodeEncodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - return UnicodeError_new(type, args, kwds, &PyUnicode_Type); -} static int UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) @@ -1635,7 +1600,7 @@ PyDoc_STR("Unicode encoding error."), (traverseproc)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeEncodeError_init, 0, UnicodeEncodeError_new, + (initproc)UnicodeEncodeError_init, 0, BaseException_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -1652,11 +1617,6 @@ /* * UnicodeDecodeError extends UnicodeError */ -static PyObject * -UnicodeDecodeError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - return UnicodeError_new(type, args, kwds, &PyString_Type); -} static int UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) @@ -1712,7 +1672,7 @@ PyDoc_STR("Unicode decoding error."), (traverseproc)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeDecodeError_init, 0, UnicodeDecodeError_new, + (initproc)UnicodeDecodeError_init, 0, BaseException_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -1732,23 +1692,6 @@ /* * UnicodeTranslateError extends UnicodeError */ -static PyObject * -UnicodeTranslateError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyUnicodeErrorObject *self = NULL; - - self = (PyUnicodeErrorObject *)BaseException_new(type, args, kwds); - if (!self) - return NULL; - - MAKE_IT_NONE(self->encoding); - MAKE_IT_NONE(self->object); - MAKE_IT_NONE(self->start); - MAKE_IT_NONE(self->end); - MAKE_IT_NONE(self->reason); - - return (PyObject *)self; -} static int UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args, @@ -1827,7 +1770,7 @@ PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeTranslateError_init, 0, UnicodeTranslateError_new, + (initproc)UnicodeTranslateError_init, 0, BaseException_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; From python-checkins at python.org Sun May 28 19:46:58 2006 From: python-checkins at python.org (marc-andre.lemburg) Date: Sun, 28 May 2006 19:46:58 +0200 (CEST) Subject: [Python-checkins] r46505 - python/trunk/Tools/pybench/systimes.py Message-ID: <20060528174658.748AD1E4006@bag.python.org> Author: marc-andre.lemburg Date: Sun May 28 19:46:58 2006 New Revision: 46505 Added: python/trunk/Tools/pybench/systimes.py (contents, props changed) Log: Initial version of systimes - a module to provide platform dependent performance measurements. The module is currently just a proof-of-concept implementation, but will integrated into pybench once it is stable enough. License: pybench license. Author: Marc-Andre Lemburg. Added: python/trunk/Tools/pybench/systimes.py ============================================================================== --- (empty file) +++ python/trunk/Tools/pybench/systimes.py Sun May 28 19:46:58 2006 @@ -0,0 +1,197 @@ +#!/usr/bin/env python + +""" systimes() user and system timer implementations for use by + pybench. + + This module implements various different strategies for measuring + performance timings. It tries to choose the best available method + based on the platforma and available tools. + + On Windows, it is recommended to have the Mark Hammond win32 + package installed. Alternatively, the Thomas Heller ctypes + packages can also be used. + + On Unix systems, the standard resource module provides the highest + resolution timings. Unfortunately, it is not available on all Unix + platforms. + + If no supported timing methods based on process time can be found, + the module reverts to the highest resolution wall-time timer + instead. The system time part will then always be 0.0. + + The module exports one public API: + + def systimes(): + + Return the current timer values for measuring user and system + time as tuple of seconds (user_time, system_time). + + Copyright (c) 2006, Marc-Andre Lemburg (mal at egenix.com). See the + documentation for further information on copyrights, or contact + the author. All Rights Reserved. + +""" +import time, sys, struct + +# +# Note: Please keep this module compatible to Python 1.5.2. +# +# TODOs: +# +# * Add ctypes wrapper for new clock_gettime() real-time POSIX APIs; +# these will then provide nano-second resolution where available. +# +# * Add a function that returns the resolution of systimes() +# values, ie. systimesres(). +# + +### Choose an implementation + +SYSTIMES_IMPLEMENTATION = None +USE_CTYPES_GETPROCESSTIMES = 'cytpes GetProcessTimes() wrapper' +USE_WIN32PROCESS_GETPROCESSTIMES = 'win32process.GetProcessTimes()' +USE_RESOURCE_GETRUSAGE = 'resource.getrusage()' +USE_PROCESS_TIME_CLOCK = 'time.clock() (process time)' +USE_WALL_TIME_CLOCK = 'time.clock() (wall-time)' +USE_WALL_TIME_TIME = 'time.time() (wall-time)' + +if sys.platform[:3] == 'win': + # Windows platform + try: + import win32process + except ImportError: + try: + import ctypes + except ImportError: + # Use the wall-time implementation time.clock(), since this + # is the highest resolution clock available on Windows + SYSTIMES_IMPLEMENTATION = USE_WALL_TIME_CLOCK + else: + SYSTIMES_IMPLEMENTATION = USE_CTYPES_GETPROCESSTIMES + else: + SYSTIMES_IMPLEMENTATION = USE_WIN32PROCESS_GETPROCESSTIMES +else: + # All other platforms + try: + import resource + except ImportError: + pass + else: + SYSTIMES_IMPLEMENTATION = USE_RESOURCE_GETRUSAGE + +# Fall-back solution +if SYSTIMES_IMPLEMENTATION is None: + # Check whether we can use time.clock() as approximation + # for systimes() + start = time.clock() + time.sleep(0.1) + stop = time.clock() + if stop - start < 0.001: + # Looks like time.clock() is usable (and measures process + # time) + SYSTIMES_IMPLEMENTATION = USE_PROCESS_TIME_CLOCK + else: + # Use wall-time implementation time.time() since this provides + # the highest resolution clock on most systems + SYSTIMES_IMPLEMENTATION = USE_WALL_TIME_TIME + +### Implementations + +def getrusage_systimes(): + return resource.getrusage(resource.RUSAGE_SELF)[:2] + +def process_time_clock_systimes(): + return (time.clock(), 0.0) + +def wall_time_clock_systimes(): + return (time.clock(), 0.0) + +def wall_time_time_systimes(): + return (time.time(), 0.0) + +# Number of clock ticks per second for the values returned +# by GetProcessTimes() on Windows. +# +# Note: Ticks returned by GetProcessTimes() are micro-seconds on +# Windows XP (though the docs say 100ns intervals) +WIN32_PROCESS_TIMES_TICKS_PER_SECOND = 10e6 + +def win32process_getprocesstimes_systimes(): + d = win32process.GetProcessTimes(win32process.GetCurrentProcess()) + # Note: I'm not sure whether KernelTime on Windows is the same as + # system time on Unix - I've yet to see a non-zero value for + # KernelTime on Windows. + return (d['UserTime'] / WIN32_PROCESS_TIMES_TICKS_PER_SECOND, + d['KernelTime'] / WIN32_PROCESS_TIMES_TICKS_PER_SECOND) + +def ctypes_getprocesstimes_systimes(): + creationtime = ctypes.c_ulonglong() + exittime = ctypes.c_ulonglong() + kerneltime = ctypes.c_ulonglong() + usertime = ctypes.c_ulonglong() + rc = ctypes.windll.kernel32.GetProcessTimes( + ctypes.windll.kernel32.GetCurrentProcess(), + ctypes.byref(creationtime), + ctypes.byref(exittime), + ctypes.byref(kerneltime), + ctypes.byref(usertime)) + if not rc: + raise TypeError('GetProcessTimes() returned an error') + return (usertime.value / WIN32_PROCESS_TIMES_TICKS_PER_SECOND, + kerneltime.value / WIN32_PROCESS_TIMES_TICKS_PER_SECOND) + +# Select the default for the systimes() function + +if SYSTIMES_IMPLEMENTATION is USE_RESOURCE_GETRUSAGE: + systimes = getrusage_systimes + +elif SYSTIMES_IMPLEMENTATION is USE_PROCESS_TIME_CLOCK: + systimes = process_time_clock_systimes + +elif SYSTIMES_IMPLEMENTATION is USE_WALL_TIME_CLOCK: + systimes = wall_time_clock_systimes + +elif SYSTIMES_IMPLEMENTATION is USE_WALL_TIME_TIME: + systimes = wall_time_time_systimes + +elif SYSTIMES_IMPLEMENTATION is USE_WIN32PROCESS_GETPROCESSTIMES: + systimes = win32process_getprocesstimes_systimes + +elif SYSTIMES_IMPLEMENTATION is USE_CTYPES_GETPROCESSTIMES: + systimes = ctypes_getprocesstimes_systimes + +else: + raise TypeError('no suitable systimes() implementation found') + +### Testing + +def some_workload(): + x = 0L + for i in xrange(10000000L): + x = x + 1L + +def test_workload(): + print 'Testing systimes() under load conditions' + t0 = systimes() + some_workload() + t1 = systimes() + print 'before:', t0 + print 'after:', t1 + print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) + print + +def test_idle(): + print 'Testing systimes() under idle conditions' + t0 = systimes() + time.sleep(1) + t1 = systimes() + print 'before:', t0 + print 'after:', t1 + print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) + print + +if __name__ == '__main__': + print 'Using %s as timer' % SYSTIMES_IMPLEMENTATION + print + test_workload() + test_idle() From python-checkins at python.org Sun May 28 20:15:45 2006 From: python-checkins at python.org (armin.rigo) Date: Sun, 28 May 2006 20:15:45 +0200 (CEST) Subject: [Python-checkins] r46506 - in python/branches/release24-maint/Lib: base64.py doctest.py optparse.py test/test_csv.py test/test_itertools.py test/test_optparse.py test/test_urllib2.py test/test_weakref.py Message-ID: <20060528181545.281EC1E4010@bag.python.org> Author: armin.rigo Date: Sun May 28 20:15:43 2006 New Revision: 46506 Modified: python/branches/release24-maint/Lib/base64.py python/branches/release24-maint/Lib/doctest.py python/branches/release24-maint/Lib/optparse.py python/branches/release24-maint/Lib/test/test_csv.py python/branches/release24-maint/Lib/test/test_itertools.py python/branches/release24-maint/Lib/test/test_optparse.py python/branches/release24-maint/Lib/test/test_urllib2.py python/branches/release24-maint/Lib/test/test_weakref.py Log: Remove various dependencies on dictionary order in the standard library tests, and one (clearly an oversight, potentially critical) in the standard library itself - base64.py. test_extcall is an output test which still needs to be fixed somehow. Forwardporting candidate... Modified: python/branches/release24-maint/Lib/base64.py ============================================================================== --- python/branches/release24-maint/Lib/base64.py (original) +++ python/branches/release24-maint/Lib/base64.py Sun May 28 20:15:43 2006 @@ -126,7 +126,9 @@ 8: 'I', 17: 'R', 26: '2', } -_b32tab = [v for v in _b32alphabet.values()] +_b32tab = _b32alphabet.items() +_b32tab.sort() +_b32tab = [v for k, v in _b32tab] _b32rev = dict([(v, long(k)) for k, v in _b32alphabet.items()]) Modified: python/branches/release24-maint/Lib/doctest.py ============================================================================== --- python/branches/release24-maint/Lib/doctest.py (original) +++ python/branches/release24-maint/Lib/doctest.py Sun May 28 20:15:43 2006 @@ -1044,12 +1044,13 @@ >>> tests = DocTestFinder().find(_TestClass) >>> runner = DocTestRunner(verbose=False) + >>> tests.sort(key = lambda test: test.name) >>> for test in tests: - ... print runner.run(test) - (0, 2) - (0, 1) - (0, 2) - (0, 2) + ... print test.name, '->', runner.run(test) + _TestClass -> (0, 2) + _TestClass.__init__ -> (0, 2) + _TestClass.get -> (0, 2) + _TestClass.square -> (0, 1) The `summarize` method prints a summary of all the test cases that have been run by the runner, and returns an aggregated `(f, t)` Modified: python/branches/release24-maint/Lib/optparse.py ============================================================================== --- python/branches/release24-maint/Lib/optparse.py (original) +++ python/branches/release24-maint/Lib/optparse.py Sun May 28 20:15:43 2006 @@ -547,8 +547,10 @@ else: setattr(self, attr, None) if attrs: + attrs = attrs.keys() + attrs.sort() raise OptionError( - "invalid keyword arguments: %s" % ", ".join(attrs.keys()), + "invalid keyword arguments: %s" % ", ".join(attrs), self) @@ -1556,6 +1558,7 @@ raise BadOptionError(_("no such option: %s") % s) else: # More than one possible completion: ambiguous prefix. + possibilities.sort() raise BadOptionError(_("ambiguous option: %s (%s?)") % (s, ", ".join(possibilities))) Modified: python/branches/release24-maint/Lib/test/test_csv.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_csv.py (original) +++ python/branches/release24-maint/Lib/test/test_csv.py Sun May 28 20:15:43 2006 @@ -760,7 +760,10 @@ def test_delimiters(self): sniffer = csv.Sniffer() dialect = sniffer.sniff(self.sample3) - self.assertEqual(dialect.delimiter, "0") + # given that all three lines in sample3 are equal, + # I think that any character could have been 'guessed' as the + # delimiter, depending on dictionary order + self.assert_(dialect.delimiter in self.sample3) dialect = sniffer.sniff(self.sample3, delimiters="?,") self.assertEqual(dialect.delimiter, "?") dialect = sniffer.sniff(self.sample3, delimiters="/,") Modified: python/branches/release24-maint/Lib/test/test_itertools.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_itertools.py (original) +++ python/branches/release24-maint/Lib/test/test_itertools.py Sun May 28 20:15:43 2006 @@ -758,7 +758,7 @@ >>> from operator import itemgetter >>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3) ->>> di = sorted(d.iteritems(), key=itemgetter(1)) +>>> di = sorted(sorted(d.iteritems()), key=itemgetter(1)) >>> for k, g in groupby(di, itemgetter(1)): ... print k, map(itemgetter(0), g) ... Modified: python/branches/release24-maint/Lib/test/test_optparse.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_optparse.py (original) +++ python/branches/release24-maint/Lib/test/test_optparse.py Sun May 28 20:15:43 2006 @@ -212,7 +212,7 @@ def test_attr_invalid(self): self.assertOptionError( - "option -b: invalid keyword arguments: foo, bar", + "option -b: invalid keyword arguments: bar, foo", ["-b"], {'foo': None, 'bar': None}) def test_action_invalid(self): @@ -675,9 +675,8 @@ def test_ambiguous_option(self): self.parser.add_option("--foz", action="store", type="string", dest="foo") - possibilities = ", ".join({"--foz": None, "--foo": None}.keys()) self.assertParseFail(["--f=bar"], - "ambiguous option: --f (%s?)" % possibilities) + "ambiguous option: --f (--foo, --foz?)") def test_short_and_long_option_split(self): @@ -1477,10 +1476,9 @@ def test_match_abbrev_error(self): s = "--f" wordmap = {"--foz": None, "--foo": None, "--fie": None} - possibilities = ", ".join(wordmap.keys()) self.assertRaises( _match_abbrev, (s, wordmap), None, - BadOptionError, "ambiguous option: --f (%s?)" % possibilities) + BadOptionError, "ambiguous option: --f (--fie, --foo, --foz?)") def _testclasses(): Modified: python/branches/release24-maint/Lib/test/test_urllib2.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_urllib2.py (original) +++ python/branches/release24-maint/Lib/test/test_urllib2.py Sun May 28 20:15:43 2006 @@ -447,6 +447,7 @@ self.method = method self.selector = url self.req_headers += headers.items() + self.req_headers.sort() if body: self.data = body if self.raise_on_endheaders: Modified: python/branches/release24-maint/Lib/test/test_weakref.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_weakref.py (original) +++ python/branches/release24-maint/Lib/test/test_weakref.py Sun May 28 20:15:43 2006 @@ -1009,8 +1009,8 @@ ... >>> obj = Dict(red=1, green=2, blue=3) # this object is weak referencable >>> r = weakref.ref(obj) ->>> print r() -{'blue': 3, 'green': 2, 'red': 1} +>>> print r() is obj +True >>> import weakref >>> class Object: From python-checkins at python.org Sun May 28 21:13:18 2006 From: python-checkins at python.org (armin.rigo) Date: Sun, 28 May 2006 21:13:18 +0200 (CEST) Subject: [Python-checkins] r46507 - in python/trunk/Lib: base64.py doctest.py optparse.py test/test_csv.py test/test_itertools.py test/test_optparse.py test/test_urllib2.py test/test_weakref.py Message-ID: <20060528191318.71E121E4006@bag.python.org> Author: armin.rigo Date: Sun May 28 21:13:17 2006 New Revision: 46507 Modified: python/trunk/Lib/base64.py python/trunk/Lib/doctest.py python/trunk/Lib/optparse.py python/trunk/Lib/test/test_csv.py python/trunk/Lib/test/test_itertools.py python/trunk/Lib/test/test_optparse.py python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/test/test_weakref.py Log: ("Forward-port" of r46506) Remove various dependencies on dictionary order in the standard library tests, and one (clearly an oversight, potentially critical) in the standard library itself - base64.py. Remaining open issues: * test_extcall is an output test, messy to make robust * tarfile.py has a potential bug here, but I'm not familiar enough with this code. Filed in as SF bug #1496501. * urllib2.HTTPPasswordMgr() returns a random result if there is more than one matching root path. I'm asking python-dev for clarification... Modified: python/trunk/Lib/base64.py ============================================================================== --- python/trunk/Lib/base64.py (original) +++ python/trunk/Lib/base64.py Sun May 28 21:13:17 2006 @@ -126,7 +126,9 @@ 8: 'I', 17: 'R', 26: '2', } -_b32tab = [v for v in _b32alphabet.values()] +_b32tab = _b32alphabet.items() +_b32tab.sort() +_b32tab = [v for k, v in _b32tab] _b32rev = dict([(v, long(k)) for k, v in _b32alphabet.items()]) Modified: python/trunk/Lib/doctest.py ============================================================================== --- python/trunk/Lib/doctest.py (original) +++ python/trunk/Lib/doctest.py Sun May 28 21:13:17 2006 @@ -1056,12 +1056,13 @@ >>> tests = DocTestFinder().find(_TestClass) >>> runner = DocTestRunner(verbose=False) + >>> tests.sort(key = lambda test: test.name) >>> for test in tests: - ... print runner.run(test) - (0, 2) - (0, 1) - (0, 2) - (0, 2) + ... print test.name, '->', runner.run(test) + _TestClass -> (0, 2) + _TestClass.__init__ -> (0, 2) + _TestClass.get -> (0, 2) + _TestClass.square -> (0, 1) The `summarize` method prints a summary of all the test cases that have been run by the runner, and returns an aggregated `(f, t)` Modified: python/trunk/Lib/optparse.py ============================================================================== --- python/trunk/Lib/optparse.py (original) +++ python/trunk/Lib/optparse.py Sun May 28 21:13:17 2006 @@ -611,8 +611,10 @@ else: setattr(self, attr, None) if attrs: + attrs = attrs.keys() + attrs.sort() raise OptionError( - "invalid keyword arguments: %s" % ", ".join(attrs.keys()), + "invalid keyword arguments: %s" % ", ".join(attrs), self) @@ -1661,6 +1663,7 @@ raise BadOptionError(s) else: # More than one possible completion: ambiguous prefix. + possibilities.sort() raise AmbiguousOptionError(s, possibilities) Modified: python/trunk/Lib/test/test_csv.py ============================================================================== --- python/trunk/Lib/test/test_csv.py (original) +++ python/trunk/Lib/test/test_csv.py Sun May 28 21:13:17 2006 @@ -875,7 +875,10 @@ def test_delimiters(self): sniffer = csv.Sniffer() dialect = sniffer.sniff(self.sample3) - self.assertEqual(dialect.delimiter, "0") + # given that all three lines in sample3 are equal, + # I think that any character could have been 'guessed' as the + # delimiter, depending on dictionary order + self.assert_(dialect.delimiter in self.sample3) dialect = sniffer.sniff(self.sample3, delimiters="?,") self.assertEqual(dialect.delimiter, "?") dialect = sniffer.sniff(self.sample3, delimiters="/,") Modified: python/trunk/Lib/test/test_itertools.py ============================================================================== --- python/trunk/Lib/test/test_itertools.py (original) +++ python/trunk/Lib/test/test_itertools.py Sun May 28 21:13:17 2006 @@ -766,7 +766,7 @@ >>> from operator import itemgetter >>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3) ->>> di = sorted(d.iteritems(), key=itemgetter(1)) +>>> di = sorted(sorted(d.iteritems()), key=itemgetter(1)) >>> for k, g in groupby(di, itemgetter(1)): ... print k, map(itemgetter(0), g) ... Modified: python/trunk/Lib/test/test_optparse.py ============================================================================== --- python/trunk/Lib/test/test_optparse.py (original) +++ python/trunk/Lib/test/test_optparse.py Sun May 28 21:13:17 2006 @@ -230,7 +230,7 @@ def test_attr_invalid(self): self.assertOptionError( - "option -b: invalid keyword arguments: foo, bar", + "option -b: invalid keyword arguments: bar, foo", ["-b"], {'foo': None, 'bar': None}) def test_action_invalid(self): @@ -718,9 +718,8 @@ def test_ambiguous_option(self): self.parser.add_option("--foz", action="store", type="string", dest="foo") - possibilities = ", ".join({"--foz": None, "--foo": None}.keys()) self.assertParseFail(["--f=bar"], - "ambiguous option: --f (%s?)" % possibilities) + "ambiguous option: --f (--foo, --foz?)") def test_short_and_long_option_split(self): @@ -1537,10 +1536,9 @@ def test_match_abbrev_error(self): s = "--f" wordmap = {"--foz": None, "--foo": None, "--fie": None} - possibilities = ", ".join(wordmap.keys()) self.assertRaises( _match_abbrev, (s, wordmap), None, - BadOptionError, "ambiguous option: --f (%s?)" % possibilities) + BadOptionError, "ambiguous option: --f (--fie, --foo, --foz?)") class TestParseNumber(BaseTest): Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Sun May 28 21:13:17 2006 @@ -560,6 +560,7 @@ self.method = method self.selector = url self.req_headers += headers.items() + self.req_headers.sort() if body: self.data = body if self.raise_on_endheaders: Modified: python/trunk/Lib/test/test_weakref.py ============================================================================== --- python/trunk/Lib/test/test_weakref.py (original) +++ python/trunk/Lib/test/test_weakref.py Sun May 28 21:13:17 2006 @@ -1053,8 +1053,8 @@ ... >>> obj = Dict(red=1, green=2, blue=3) # this object is weak referencable >>> r = weakref.ref(obj) ->>> print r() -{'blue': 3, 'green': 2, 'red': 1} +>>> print r() is obj +True >>> import weakref >>> class Object: From fredrik at pythonware.com Sun May 28 21:50:44 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 28 May 2006 21:50:44 +0200 Subject: [Python-checkins] r46499 - in python/trunk: Include/pyport.h Include/unicodeobject.h Objects/stringobject.c In-Reply-To: <4479E037.9000302@v.loewis.de> References: <20060528120647.BE9B41E4006@bag.python.org> <4479E037.9000302@v.loewis.de> Message-ID: Martin v. L?wis wrote: >> needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only), >> and use it for string copy operations. this gives a 20% speedup on some >> string benchmarks. > > Shouldn't this better use > > #pragma intrinsic(memcpy) in theory, yes. but in practice, things look a bit different, at least on this machine (using visual studio .net 2003 enterprise): 43.2 intrinsic memcpy 43.4 memcpy 39.1 Py_MEMCPY as in trunk 39.2 Py_MEMCPY + intrinsic memcpy (using one of the stringbench replace benchmarks, best of 3 runs on a T2300 dual core) sure looks like memcpy is always intrinsic. From python-checkins at python.org Sun May 28 22:11:45 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 May 2006 22:11:45 +0200 (CEST) Subject: [Python-checkins] r46508 - python/trunk/Python/import.c Message-ID: <20060528201145.EFB201E4006@bag.python.org> Author: georg.brandl Date: Sun May 28 22:11:45 2006 New Revision: 46508 Modified: python/trunk/Python/import.c Log: The empty string is a valid import path. (fixes #1496539) Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Sun May 28 22:11:45 2006 @@ -1251,9 +1251,11 @@ } else if (importer == Py_None) { /* No importer was found, so it has to be a file. - * Check if the directory is valid. */ + * Check if the directory is valid. + * Note that the empty string is a valid path, but + * not stat'able, hence the check for len. */ #ifdef HAVE_STAT - if (stat(buf, &statbuf) != 0) { + if (len && stat(buf, &statbuf) != 0) { /* Directory does not exist. */ PyDict_SetItem(path_importer_cache, v, Py_False); From python-checkins at python.org Sun May 28 22:23:13 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 May 2006 22:23:13 +0200 (CEST) Subject: [Python-checkins] r46509 - in python/trunk: Lib/test/test_urllib2.py Lib/urllib2.py Misc/NEWS Message-ID: <20060528202313.476581E4006@bag.python.org> Author: georg.brandl Date: Sun May 28 22:23:12 2006 New Revision: 46509 Modified: python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/urllib2.py python/trunk/Misc/NEWS Log: Patch #1496206: urllib2 PasswordMgr ./. default ports Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Sun May 28 22:23:12 2006 @@ -76,10 +76,11 @@ >>> mgr.find_user_password("c", "http://example.com/bar") ('bar', 'nini') - Currently, we use the highest-level path where more than one match: + Actually, this is really undefined ATM +## Currently, we use the highest-level path where more than one match: - >>> mgr.find_user_password("Some Realm", "http://example.com/ni") - ('joe', 'password') +## >>> mgr.find_user_password("Some Realm", "http://example.com/ni") +## ('joe', 'password') Use latest add_password() in case of conflict: @@ -110,6 +111,53 @@ pass +def test_password_manager_default_port(self): + """ + >>> mgr = urllib2.HTTPPasswordMgr() + >>> add = mgr.add_password + + The point to note here is that we can't guess the default port if there's + no scheme. This applies to both add_password and find_user_password. + + >>> add("f", "http://g.example.com:80", "10", "j") + >>> add("g", "http://h.example.com", "11", "k") + >>> add("h", "i.example.com:80", "12", "l") + >>> add("i", "j.example.com", "13", "m") + >>> mgr.find_user_password("f", "g.example.com:100") + (None, None) + >>> mgr.find_user_password("f", "g.example.com:80") + ('10', 'j') + >>> mgr.find_user_password("f", "g.example.com") + (None, None) + >>> mgr.find_user_password("f", "http://g.example.com:100") + (None, None) + >>> mgr.find_user_password("f", "http://g.example.com:80") + ('10', 'j') + >>> mgr.find_user_password("f", "http://g.example.com") + ('10', 'j') + >>> mgr.find_user_password("g", "h.example.com") + ('11', 'k') + >>> mgr.find_user_password("g", "h.example.com:80") + ('11', 'k') + >>> mgr.find_user_password("g", "http://h.example.com:80") + ('11', 'k') + >>> mgr.find_user_password("h", "i.example.com") + (None, None) + >>> mgr.find_user_password("h", "i.example.com:80") + ('12', 'l') + >>> mgr.find_user_password("h", "http://i.example.com:80") + ('12', 'l') + >>> mgr.find_user_password("i", "j.example.com") + ('13', 'm') + >>> mgr.find_user_password("i", "j.example.com:80") + (None, None) + >>> mgr.find_user_password("i", "http://j.example.com") + ('13', 'm') + >>> mgr.find_user_password("i", "http://j.example.com:80") + (None, None) + + """ + class MockOpener: addheaders = [] def open(self, req, data=None): Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Sun May 28 22:23:12 2006 @@ -695,32 +695,45 @@ # uri could be a single URI or a sequence if isinstance(uri, basestring): uri = [uri] - uri = tuple(map(self.reduce_uri, uri)) if not realm in self.passwd: self.passwd[realm] = {} - self.passwd[realm][uri] = (user, passwd) + for default_port in True, False: + reduced_uri = tuple( + [self.reduce_uri(u, default_port) for u in uri]) + self.passwd[realm][reduced_uri] = (user, passwd) def find_user_password(self, realm, authuri): domains = self.passwd.get(realm, {}) - authuri = self.reduce_uri(authuri) - for uris, authinfo in domains.iteritems(): - for uri in uris: - if self.is_suburi(uri, authuri): - return authinfo + for default_port in True, False: + reduced_authuri = self.reduce_uri(authuri, default_port) + for uris, authinfo in domains.iteritems(): + for uri in uris: + if self.is_suburi(uri, reduced_authuri): + return authinfo return None, None - def reduce_uri(self, uri): - """Accept netloc or URI and extract only the netloc and path""" + def reduce_uri(self, uri, default_port=True): + """Accept authority or URI and extract only the authority and path.""" + # note HTTP URLs do not have a userinfo component parts = urlparse.urlsplit(uri) if parts[1]: # URI - return parts[1], parts[2] or '/' - elif parts[0]: - # host:port - return uri, '/' + scheme = parts[0] + authority = parts[1] + path = parts[2] or '/' else: - # host - return parts[2], '/' + # host or host:port + scheme = None + authority = uri + path = '/' + host, port = splitport(authority) + if default_port and port is None and scheme is not None: + dport = {"http": 80, + "https": 443, + }.get(scheme) + if dport is not None: + authority = "%s:%d" % (host, dport) + return authority, path def is_suburi(self, base, test): """Check if test is below base in a URI tree Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun May 28 22:23:12 2006 @@ -85,6 +85,9 @@ Library ------- +- Patch #1496206: improve urllib2 handling of passwords with respect to + default HTTP and HTTPS ports. + - Patch #1080727: add "encoding" parameter to doctest.DocFileSuite. - Patch #1281707: speed up gzip.readline. From buildbot at python.org Sun May 28 22:30:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 28 May 2006 20:30:00 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060528203000.5940B1E4006@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/74 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: armin.rigo Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sun May 28 22:57:10 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 May 2006 22:57:10 +0200 (CEST) Subject: [Python-checkins] r46510 - python/trunk/Objects/exceptions.c Message-ID: <20060528205710.138221E4006@bag.python.org> Author: georg.brandl Date: Sun May 28 22:57:09 2006 New Revision: 46510 Modified: python/trunk/Objects/exceptions.c Log: Fix refleaks in UnicodeError get and set methods. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sun May 28 22:57:09 2006 @@ -1,3 +1,9 @@ +/* + * New exceptions.c written in Iceland by Richard Jones and Georg Brandl. + * + * Thanks go to Tim Peters and Michael Hudson for debugging. + */ + #define PY_SSIZE_T_CLEAN #include #include "structmember.h" @@ -1037,56 +1043,57 @@ { PyObject *str; PyObject *result; + int have_filename = 0; + int have_lineno = 0; + char *buffer = NULL; if (self->msg) str = PyObject_Str(self->msg); else str = PyObject_Str(Py_None); - result = str; + if (!str) return NULL; + /* Don't fiddle with non-string return (shouldn't happen anyway) */ + if (!PyString_Check(str)) return str; /* XXX -- do all the additional formatting with filename and lineno here */ - if (str != NULL && PyString_Check(str)) { - int have_filename = 0; - int have_lineno = 0; - char *buffer = NULL; - - have_filename = (self->filename != NULL) && - PyString_Check(self->filename); - have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno); - - if (have_filename || have_lineno) { - Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; - if (have_filename) - bufsize += PyString_GET_SIZE(self->filename); - - buffer = (char *)PyMem_MALLOC(bufsize); - if (buffer != NULL) { - if (have_filename && have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename)), - PyInt_AsLong(self->lineno)); - else if (have_filename) - PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(self->filename))); - else if (have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(self->lineno)); - - result = PyString_FromString(buffer); - PyMem_FREE(buffer); - - if (result == NULL) - result = str; - else - Py_DECREF(str); - } - } - } + have_filename = (self->filename != NULL) && + PyString_Check(self->filename); + have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno); + + if (!have_filename && !have_lineno) + return str; + + Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; + if (have_filename) + bufsize += PyString_GET_SIZE(self->filename); + + buffer = PyMem_MALLOC(bufsize); + if (buffer == NULL) + return str; + + if (have_filename && have_lineno) + PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename)), + PyInt_AsLong(self->lineno)); + else if (have_filename) + PyOS_snprintf(buffer, bufsize, "%s (%s)", + PyString_AS_STRING(str), + my_basename(PyString_AS_STRING(self->filename))); + else /* only have_lineno */ + PyOS_snprintf(buffer, bufsize, "%s (line %ld)", + PyString_AS_STRING(str), + PyInt_AsLong(self->lineno)); + + result = PyString_FromString(buffer); + PyMem_FREE(buffer); + + if (result == NULL) + result = str; + else + Py_DECREF(str); return result; } @@ -1208,7 +1215,7 @@ PyObject *obj = PyInt_FromSsize_t(value); if (!obj) return -1; - Py_XDECREF(*attr); + Py_CLEAR(*attr); *attr = obj; return 0; } @@ -1236,7 +1243,7 @@ PyObject *obj = PyString_FromString(value); if (!obj) return -1; - Py_XDECREF(*attr); + Py_CLEAR(*attr); *attr = obj; return 0; } @@ -1302,6 +1309,7 @@ *start = 0; /*XXX check for values <0*/ if (*start>=size) *start = size-1; + Py_DECREF(obj); return 0; } return -1; @@ -1321,6 +1329,7 @@ *start = 0; if (*start>=size) *start = size-1; + Py_DECREF(obj); return 0; } return -1; @@ -1368,6 +1377,7 @@ *end = 1; if (*end>size) *end = size; + Py_DECREF(obj); return 0; } return -1; @@ -1387,6 +1397,7 @@ *end = 1; if (*end>size) *end = size; + Py_DECREF(obj); return 0; } return -1; @@ -1630,8 +1641,8 @@ static PyObject * UnicodeDecodeError_str(PyObject *self) { - Py_ssize_t start; - Py_ssize_t end; + Py_ssize_t start = 0; + Py_ssize_t end = 0; if (PyUnicodeDecodeError_GetStart(self, &start)) return NULL; From buildbot at python.org Sun May 28 23:04:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 28 May 2006 21:04:01 +0000 Subject: [Python-checkins] buildbot failure in x86 W2k trunk Message-ID: <20060528210401.50EB31E400E@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/857 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Sun May 28 23:19:04 2006 From: python-checkins at python.org (michael.hudson) Date: Sun, 28 May 2006 23:19:04 +0200 (CEST) Subject: [Python-checkins] r46511 - python/trunk/Objects/exceptions.c Message-ID: <20060528211904.22AA61E4007@bag.python.org> Author: michael.hudson Date: Sun May 28 23:19:03 2006 New Revision: 46511 Modified: python/trunk/Objects/exceptions.c Log: use the UnicodeError traversal and clearing functions in UnicodeError subclasses. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sun May 28 23:19:03 2006 @@ -1608,8 +1608,8 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode encoding error."), (traverseproc)BaseException_traverse, - (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, + PyDoc_STR("Unicode encoding error."), (traverseproc)UnicodeError_traverse, + (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeEncodeError_init, 0, BaseException_new, }; @@ -1680,8 +1680,8 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeDecodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)BaseException_traverse, - (inquiry)BaseException_clear, 0, 0, 0, 0, 0, UnicodeError_members, + PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeDecodeError_init, 0, BaseException_new, }; From buildbot at python.org Sun May 28 23:21:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 28 May 2006 21:21:11 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20060528212111.F32411E4007@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/844 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Sun May 28 23:32:12 2006 From: python-checkins at python.org (thomas.wouters) Date: Sun, 28 May 2006 23:32:12 +0200 (CEST) Subject: [Python-checkins] r46512 - python/trunk/Objects/exceptions.c Message-ID: <20060528213212.9F80F1E4007@bag.python.org> Author: thomas.wouters Date: Sun May 28 23:32:12 2006 New Revision: 46512 Modified: python/trunk/Objects/exceptions.c Log: Make last patch valid C89 so Windows compilers can deal with it. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sun May 28 23:32:12 2006 @@ -1046,6 +1046,7 @@ int have_filename = 0; int have_lineno = 0; char *buffer = NULL; + Py_ssize_t bufsize; if (self->msg) str = PyObject_Str(self->msg); @@ -1065,7 +1066,7 @@ if (!have_filename && !have_lineno) return str; - Py_ssize_t bufsize = PyString_GET_SIZE(str) + 64; + bufsize = PyString_GET_SIZE(str) + 64; if (have_filename) bufsize += PyString_GET_SIZE(self->filename); From python-checkins at python.org Sun May 28 23:42:54 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 May 2006 23:42:54 +0200 (CEST) Subject: [Python-checkins] r46513 - python/trunk/Modules/_struct.c Message-ID: <20060528214254.806C11E4007@bag.python.org> Author: georg.brandl Date: Sun May 28 23:42:54 2006 New Revision: 46513 Modified: python/trunk/Modules/_struct.c Log: Fix ref-antileak in _struct.c which eventually lead to deallocating None. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Sun May 28 23:42:54 2006 @@ -1513,7 +1513,7 @@ return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject * From python-checkins at python.org Sun May 28 23:57:36 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 May 2006 23:57:36 +0200 (CEST) Subject: [Python-checkins] r46514 - in python/trunk: Mac/Modules/dlg/_Dlgmodule.c Mac/Modules/dlg/dlgsupport.py Mac/Modules/file/_Filemodule.c Mac/Modules/file/filesupport.py Python/import.c Message-ID: <20060528215736.2B0CA1E4006@bag.python.org> Author: georg.brandl Date: Sun May 28 23:57:35 2006 New Revision: 46514 Modified: python/trunk/Mac/Modules/dlg/_Dlgmodule.c python/trunk/Mac/Modules/dlg/dlgsupport.py python/trunk/Mac/Modules/file/_Filemodule.c python/trunk/Mac/Modules/file/filesupport.py python/trunk/Python/import.c Log: Correct None refcount issue in Mac modules. (Are they still used?) Modified: python/trunk/Mac/Modules/dlg/_Dlgmodule.c ============================================================================== --- python/trunk/Mac/Modules/dlg/_Dlgmodule.c (original) +++ python/trunk/Mac/Modules/dlg/_Dlgmodule.c Sun May 28 23:57:35 2006 @@ -139,7 +139,7 @@ PyObject *DlgObj_New(DialogPtr itself) { DialogObject *it; - if (itself == NULL) return Py_None; + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } it = PyObject_NEW(DialogObject, &Dialog_Type); if (it == NULL) return NULL; it->ob_itself = itself; Modified: python/trunk/Mac/Modules/dlg/dlgsupport.py ============================================================================== --- python/trunk/Mac/Modules/dlg/dlgsupport.py (original) +++ python/trunk/Mac/Modules/dlg/dlgsupport.py Sun May 28 23:57:35 2006 @@ -202,7 +202,7 @@ Output("SetWRefCon(GetDialogWindow(itself), (long)it);") def outputCheckNewArg(self): - Output("if (itself == NULL) return Py_None;") + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") def outputCheckConvertArg(self): Output("if (v == Py_None) { *p_itself = NULL; return 1; }") Modified: python/trunk/Mac/Modules/file/_Filemodule.c ============================================================================== --- python/trunk/Mac/Modules/file/_Filemodule.c (original) +++ python/trunk/Mac/Modules/file/_Filemodule.c Sun May 28 23:57:35 2006 @@ -153,7 +153,7 @@ static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself) { FSCatalogInfoObject *it; - if (itself == NULL) return Py_None; + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type); if (it == NULL) return NULL; it->ob_itself = *itself; Modified: python/trunk/Mac/Modules/file/filesupport.py ============================================================================== --- python/trunk/Mac/Modules/file/filesupport.py (original) +++ python/trunk/Mac/Modules/file/filesupport.py Sun May 28 23:57:35 2006 @@ -475,7 +475,7 @@ self.argref = "*" # Store FSSpecs, but pass them by address def outputCheckNewArg(self): - Output("if (itself == NULL) return Py_None;") + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") def output_tp_newBody(self): Output("PyObject *self;"); Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Sun May 28 23:57:35 2006 @@ -2059,7 +2059,7 @@ /* Return the package that an import is being performed in. If globals comes from the module foo.bar.bat (not itself a package), this returns the sys.modules entry for foo.bar. If globals is from a package's __init__.py, - the package's entry in sys.modules is returned. + the package's entry in sys.modules is returned, as a borrowed reference. The *name* of the returned package is returned in buf, with the length of the name in *p_buflen. From python-checkins at python.org Mon May 29 00:07:09 2006 From: python-checkins at python.org (armin.rigo) Date: Mon, 29 May 2006 00:07:09 +0200 (CEST) Subject: [Python-checkins] r46515 - python/trunk/Lib/test/regrtest.py Message-ID: <20060528220709.30C211E4006@bag.python.org> Author: armin.rigo Date: Mon May 29 00:07:08 2006 New Revision: 46515 Modified: python/trunk/Lib/test/regrtest.py Log: A clearer error message when passing -R to regrtest.py with release builds of Python. Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Mon May 29 00:07:08 2006 @@ -513,6 +513,9 @@ else: cfp = cStringIO.StringIO() if huntrleaks: + if not hasattr(sys, 'gettotalrefcount'): + raise Exception("Tracking reference leaks requires a debug build " + "of Python") refrep = open(huntrleaks[2], "a") try: save_stdout = sys.stdout From python-checkins at python.org Mon May 29 00:14:05 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 00:14:05 +0200 (CEST) Subject: [Python-checkins] r46516 - python/trunk/Modules/_sre.c Message-ID: <20060528221405.701391E4003@bag.python.org> Author: georg.brandl Date: Mon May 29 00:14:04 2006 New Revision: 46516 Modified: python/trunk/Modules/_sre.c Log: Fix C function calling conventions in _sre module. Modified: python/trunk/Modules/_sre.c ============================================================================== --- python/trunk/Modules/_sre.c (original) +++ python/trunk/Modules/_sre.c Mon May 29 00:14:04 2006 @@ -1623,7 +1623,7 @@ static PyObject*pattern_scanner(PatternObject*, PyObject*); static PyObject * -sre_codesize(PyObject* self, PyObject* args) +sre_codesize(PyObject* self) { return Py_BuildValue("i", sizeof(SRE_CODE)); } @@ -2467,15 +2467,12 @@ } static PyObject* -pattern_copy(PatternObject* self, PyObject* args) +pattern_copy(PatternObject* self) { #ifdef USE_BUILTIN_COPY PatternObject* copy; int offset; - if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) - return NULL; - copy = PyObject_NEW_VAR(PatternObject, &Pattern_Type, self->codesize); if (!copy) return NULL; @@ -2498,16 +2495,12 @@ } static PyObject* -pattern_deepcopy(PatternObject* self, PyObject* args) +pattern_deepcopy(PatternObject* self, PyObject* memo) { #ifdef USE_BUILTIN_COPY PatternObject* copy; - PyObject* memo; - if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) - return NULL; - - copy = (PatternObject*) pattern_copy(self, Py_None); + copy = (PatternObject*) pattern_copy(self); if (!copy) return NULL; @@ -2578,8 +2571,8 @@ pattern_finditer_doc}, #endif {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS}, - {"__copy__", (PyCFunction) pattern_copy, METH_VARARGS}, - {"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_VARARGS}, + {"__copy__", (PyCFunction) pattern_copy, METH_NOARGS}, + {"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O}, {NULL, NULL} }; @@ -2772,12 +2765,8 @@ } static PyObject* -match_expand(MatchObject* self, PyObject* args) +match_expand(MatchObject* self, PyObject* ptemplate) { - PyObject* ptemplate; - if (!PyArg_ParseTuple(args, "O:expand", &ptemplate)) - return NULL; - /* delegate to Python code */ return call( SRE_PY_MODULE, "_expand", @@ -3019,15 +3008,12 @@ } static PyObject* -match_copy(MatchObject* self, PyObject* args) +match_copy(MatchObject* self) { #ifdef USE_BUILTIN_COPY MatchObject* copy; int slots, offset; - if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) - return NULL; - slots = 2 * (self->pattern->groups+1); copy = PyObject_NEW_VAR(MatchObject, &Match_Type, slots); @@ -3053,16 +3039,12 @@ } static PyObject* -match_deepcopy(MatchObject* self, PyObject* args) +match_deepcopy(MatchObject* self, PyObject* memo) { #ifdef USE_BUILTIN_COPY MatchObject* copy; - PyObject* memo; - if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) - return NULL; - - copy = (MatchObject*) match_copy(self, Py_None); + copy = (MatchObject*) match_copy(self); if (!copy) return NULL; @@ -3086,9 +3068,9 @@ {"span", (PyCFunction) match_span, METH_VARARGS}, {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS}, {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS}, - {"expand", (PyCFunction) match_expand, METH_VARARGS}, - {"__copy__", (PyCFunction) match_copy, METH_VARARGS}, - {"__deepcopy__", (PyCFunction) match_deepcopy, METH_VARARGS}, + {"expand", (PyCFunction) match_expand, METH_O}, + {"__copy__", (PyCFunction) match_copy, METH_NOARGS}, + {"__deepcopy__", (PyCFunction) match_deepcopy, METH_O}, {NULL, NULL} }; @@ -3243,7 +3225,7 @@ } static PyObject* -scanner_match(ScannerObject* self, PyObject* args) +scanner_match(ScannerObject* self) { SRE_STATE* state = &self->state; PyObject* match; @@ -3274,7 +3256,7 @@ static PyObject* -scanner_search(ScannerObject* self, PyObject* args) +scanner_search(ScannerObject* self) { SRE_STATE* state = &self->state; PyObject* match; @@ -3304,10 +3286,8 @@ } static PyMethodDef scanner_methods[] = { - /* FIXME: use METH_OLDARGS instead of 0 or fix to use METH_VARARGS */ - /* METH_OLDARGS is not in Python 1.5.2 */ - {"match", (PyCFunction) scanner_match, 0}, - {"search", (PyCFunction) scanner_search, 0}, + {"match", (PyCFunction) scanner_match, METH_NOARGS}, + {"search", (PyCFunction) scanner_search, METH_NOARGS}, {NULL, NULL} }; @@ -3373,7 +3353,7 @@ static PyMethodDef _functions[] = { {"compile", _compile, METH_VARARGS}, - {"getcodesize", sre_codesize, METH_VARARGS}, + {"getcodesize", sre_codesize, METH_NOARGS}, {"getlower", sre_getlower, METH_VARARGS}, {NULL, NULL} }; From mwh at python.net Mon May 29 00:28:56 2006 From: mwh at python.net (Michael Hudson) Date: Sun, 28 May 2006 23:28:56 +0100 Subject: [Python-checkins] r46516 - python/trunk/Modules/_sre.c In-Reply-To: <20060528221405.701391E4003@bag.python.org> (georg brandl's message of "Mon, 29 May 2006 00:14:05 +0200 (CEST)") References: <20060528221405.701391E4003@bag.python.org> Message-ID: <2m64jpzsuv.fsf@starship.python.net> "georg.brandl" writes: > Author: georg.brandl > Date: Mon May 29 00:14:04 2006 > New Revision: 46516 > > Modified: > python/trunk/Modules/_sre.c > Log: > Fix C function calling conventions in _sre module. > > > > Modified: python/trunk/Modules/_sre.c > ============================================================================== > --- python/trunk/Modules/_sre.c (original) > +++ python/trunk/Modules/_sre.c Mon May 29 00:14:04 2006 > @@ -1623,7 +1623,7 @@ > static PyObject*pattern_scanner(PatternObject*, PyObject*); > > static PyObject * > -sre_codesize(PyObject* self, PyObject* args) > +sre_codesize(PyObject* self) > { This is the wrong declaration for a NOARGS function (see line 3538 of ceval.c if you don't believe me, or comments on python.org/sf/660559). Cheers, mwh -- Just point your web browser at http://www.python.org/search/ and look for "program", "doesn't", "work", or "my". Whenever you find someone else whose program didn't work, don't do what they did. Repeat as needed. -- Tim Peters, on python-help, 16 Jun 1998 From python-checkins at python.org Mon May 29 00:34:51 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 00:34:51 +0200 (CEST) Subject: [Python-checkins] r46517 - python/trunk/Modules/audioop.c Message-ID: <20060528223451.E39961E4003@bag.python.org> Author: georg.brandl Date: Mon May 29 00:34:51 2006 New Revision: 46517 Modified: python/trunk/Modules/audioop.c Log: Convert audioop over to METH_VARARGS. Modified: python/trunk/Modules/audioop.c ============================================================================== --- python/trunk/Modules/audioop.c (original) +++ python/trunk/Modules/audioop.c Mon May 29 00:34:51 2006 @@ -302,7 +302,7 @@ int len, size, val = 0; int i; - if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &size, &i) ) + if ( !PyArg_ParseTuple(args, "s#ii:getsample", &cp, &len, &size, &i) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -326,7 +326,7 @@ int i; int max = 0; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -350,7 +350,7 @@ int i; int min = 0x7fffffff, max = -0x7fffffff; - if (!PyArg_Parse(args, "(s#i)", &cp, &len, &size)) + if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size)) return NULL; if (size != 1 && size != 2 && size != 4) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -374,7 +374,7 @@ int i; double avg = 0.0; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:avg", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -401,7 +401,7 @@ int i; double sum_squares = 0.0; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -472,7 +472,8 @@ double aj_m1, aj_lm1; double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor; - if ( !PyArg_Parse(args, "(s#s#)", &cp1, &len1, &cp2, &len2) ) + if ( !PyArg_ParseTuple(args, "s#s#:findfit", + &cp1, &len1, &cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -528,7 +529,8 @@ int len1, len2; double sum_ri_2, sum_aij_ri, result; - if ( !PyArg_Parse(args, "(s#s#)", &cp1, &len1, &cp2, &len2) ) + if ( !PyArg_ParseTuple(args, "s#s#:findfactor", + &cp1, &len1, &cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -560,7 +562,7 @@ double aj_m1, aj_lm1; double result, best_result; - if ( !PyArg_Parse(args, "(s#i)", &cp1, &len1, &len2) ) + if ( !PyArg_ParseTuple(args, "s#i:findmax", &cp1, &len1, &len2) ) return 0; if ( len1 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -605,7 +607,7 @@ double avg = 0.0; int diff, prevdiff, extremediff, nextreme = 0; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:avgpp", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -662,7 +664,7 @@ int max = 0; int diff, prevdiff, extremediff; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:maxpp", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -713,7 +715,7 @@ int i; int prevval, ncross; - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:cross", &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4 ) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -741,7 +743,7 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#id)", &cp, &len, &size, &factor ) ) + if ( !PyArg_ParseTuple(args, "s#id:mul", &cp, &len, &size, &factor ) ) return 0; if ( size == 1 ) maxval = (double) 0x7f; @@ -782,7 +784,8 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#idd)", &cp, &len, &size, &fac1, &fac2 ) ) + if ( !PyArg_ParseTuple(args, "s#idd:tomono", + &cp, &len, &size, &fac1, &fac2 ) ) return 0; if ( size == 1 ) maxval = (double) 0x7f; @@ -826,7 +829,8 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#idd)", &cp, &len, &size, &fac1, &fac2 ) ) + if ( !PyArg_ParseTuple(args, "s#idd:tostereo", + &cp, &len, &size, &fac1, &fac2 ) ) return 0; if ( size == 1 ) maxval = (double) 0x7f; @@ -877,7 +881,7 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#s#i)", + if ( !PyArg_ParseTuple(args, "s#s#i:add", &cp1, &len1, &cp2, &len2, &size ) ) return 0; @@ -931,7 +935,7 @@ int i; int bias; - if ( !PyArg_Parse(args, "(s#ii)", + if ( !PyArg_ParseTuple(args, "s#ii:bias", &cp, &len, &size , &bias) ) return 0; @@ -967,7 +971,7 @@ PyObject *rv; int i, j; - if ( !PyArg_Parse(args, "(s#i)", + if ( !PyArg_ParseTuple(args, "s#i:reverse", &cp, &len, &size) ) return 0; @@ -1004,7 +1008,7 @@ PyObject *rv; int i, j; - if ( !PyArg_Parse(args, "(s#ii)", + if ( !PyArg_ParseTuple(args, "s#ii:lin2lin", &cp, &len, &size, &size2) ) return 0; @@ -1053,8 +1057,9 @@ weightA = 1; weightB = 0; - if (!PyArg_ParseTuple(args, "s#iiiiO|ii:ratecv", &cp, &len, &size, &nchannels, - &inrate, &outrate, &state, &weightA, &weightB)) + if (!PyArg_ParseTuple(args, "s#iiiiO|ii:ratecv", &cp, &len, &size, + &nchannels, &inrate, &outrate, &state, + &weightA, &weightB)) return NULL; if (size != 1 && size != 2 && size != 4) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -1117,7 +1122,8 @@ } for (chan = 0; chan < nchannels; chan++) { if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan), - "ii:ratecv",&prev_i[chan],&cur_i[chan])) + "ii:ratecv", &prev_i[chan], + &cur_i[chan])) goto exit; } } @@ -1235,9 +1241,9 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) - return 0; + if ( !PyArg_ParseTuple(args, "s#i:lin2ulaw", + &cp, &len, &size) ) + return 0 ; if ( size != 1 && size != 2 && size != 4) { PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); @@ -1269,8 +1275,8 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:ulaw2lin", + &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4) { @@ -1303,8 +1309,8 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:lin2alaw", + &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4) { @@ -1337,8 +1343,8 @@ PyObject *rv; int i; - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) + if ( !PyArg_ParseTuple(args, "s#i:alaw2lin", + &cp, &len, &size) ) return 0; if ( size != 1 && size != 2 && size != 4) { @@ -1372,8 +1378,8 @@ PyObject *rv, *state, *str; int i, outputbuffer = 0, bufferstep; - if ( !PyArg_Parse(args, "(s#iO)", - &cp, &len, &size, &state) ) + if ( !PyArg_ParseTuple(args, "s#iO:lin2adpcm", + &cp, &len, &size, &state) ) return 0; @@ -1393,7 +1399,7 @@ valpred = 0; step = 7; index = 0; - } else if ( !PyArg_Parse(state, "(ii)", &valpred, &index) ) + } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) ) return 0; step = stepsizeTable[index]; @@ -1480,8 +1486,8 @@ PyObject *rv, *str, *state; int i, inputbuffer = 0, bufferstep; - if ( !PyArg_Parse(args, "(s#iO)", - &cp, &len, &size, &state) ) + if ( !PyArg_ParseTuple(args, "s#iO:adpcm2lin", + &cp, &len, &size, &state) ) return 0; if ( size != 1 && size != 2 && size != 4) { @@ -1495,7 +1501,7 @@ valpred = 0; step = 7; index = 0; - } else if ( !PyArg_Parse(state, "(ii)", &valpred, &index) ) + } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) ) return 0; str = PyString_FromStringAndSize(NULL, len*size*2); @@ -1562,30 +1568,30 @@ } static PyMethodDef audioop_methods[] = { - { "max", audioop_max, METH_OLDARGS }, - { "minmax", audioop_minmax, METH_OLDARGS }, - { "avg", audioop_avg, METH_OLDARGS }, - { "maxpp", audioop_maxpp, METH_OLDARGS }, - { "avgpp", audioop_avgpp, METH_OLDARGS }, - { "rms", audioop_rms, METH_OLDARGS }, - { "findfit", audioop_findfit, METH_OLDARGS }, - { "findmax", audioop_findmax, METH_OLDARGS }, - { "findfactor", audioop_findfactor, METH_OLDARGS }, - { "cross", audioop_cross, METH_OLDARGS }, - { "mul", audioop_mul, METH_OLDARGS }, - { "add", audioop_add, METH_OLDARGS }, - { "bias", audioop_bias, METH_OLDARGS }, - { "ulaw2lin", audioop_ulaw2lin, METH_OLDARGS }, - { "lin2ulaw", audioop_lin2ulaw, METH_OLDARGS }, - { "alaw2lin", audioop_alaw2lin, METH_OLDARGS }, - { "lin2alaw", audioop_lin2alaw, METH_OLDARGS }, - { "lin2lin", audioop_lin2lin, METH_OLDARGS }, - { "adpcm2lin", audioop_adpcm2lin, METH_OLDARGS }, - { "lin2adpcm", audioop_lin2adpcm, METH_OLDARGS }, - { "tomono", audioop_tomono, METH_OLDARGS }, - { "tostereo", audioop_tostereo, METH_OLDARGS }, - { "getsample", audioop_getsample, METH_OLDARGS }, - { "reverse", audioop_reverse, METH_OLDARGS }, + { "max", audioop_max, METH_VARARGS }, + { "minmax", audioop_minmax, METH_VARARGS }, + { "avg", audioop_avg, METH_VARARGS }, + { "maxpp", audioop_maxpp, METH_VARARGS }, + { "avgpp", audioop_avgpp, METH_VARARGS }, + { "rms", audioop_rms, METH_VARARGS }, + { "findfit", audioop_findfit, METH_VARARGS }, + { "findmax", audioop_findmax, METH_VARARGS }, + { "findfactor", audioop_findfactor, METH_VARARGS }, + { "cross", audioop_cross, METH_VARARGS }, + { "mul", audioop_mul, METH_VARARGS }, + { "add", audioop_add, METH_VARARGS }, + { "bias", audioop_bias, METH_VARARGS }, + { "ulaw2lin", audioop_ulaw2lin, METH_VARARGS }, + { "lin2ulaw", audioop_lin2ulaw, METH_VARARGS }, + { "alaw2lin", audioop_alaw2lin, METH_VARARGS }, + { "lin2alaw", audioop_lin2alaw, METH_VARARGS }, + { "lin2lin", audioop_lin2lin, METH_VARARGS }, + { "adpcm2lin", audioop_adpcm2lin, METH_VARARGS }, + { "lin2adpcm", audioop_lin2adpcm, METH_VARARGS }, + { "tomono", audioop_tomono, METH_VARARGS }, + { "tostereo", audioop_tostereo, METH_VARARGS }, + { "getsample", audioop_getsample, METH_VARARGS }, + { "reverse", audioop_reverse, METH_VARARGS }, { "ratecv", audioop_ratecv, METH_VARARGS }, { 0, 0 } }; From python-checkins at python.org Mon May 29 00:38:57 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 00:38:57 +0200 (CEST) Subject: [Python-checkins] r46518 - python/trunk/Modules/_sre.c Message-ID: <20060528223857.811D01E4003@bag.python.org> Author: georg.brandl Date: Mon May 29 00:38:57 2006 New Revision: 46518 Modified: python/trunk/Modules/_sre.c Log: METH_NOARGS functions do get called with two args. Modified: python/trunk/Modules/_sre.c ============================================================================== --- python/trunk/Modules/_sre.c (original) +++ python/trunk/Modules/_sre.c Mon May 29 00:38:57 2006 @@ -1623,7 +1623,7 @@ static PyObject*pattern_scanner(PatternObject*, PyObject*); static PyObject * -sre_codesize(PyObject* self) +sre_codesize(PyObject* self, PyObject *unused) { return Py_BuildValue("i", sizeof(SRE_CODE)); } @@ -2467,7 +2467,7 @@ } static PyObject* -pattern_copy(PatternObject* self) +pattern_copy(PatternObject* self, PyObject *unused) { #ifdef USE_BUILTIN_COPY PatternObject* copy; @@ -3008,7 +3008,7 @@ } static PyObject* -match_copy(MatchObject* self) +match_copy(MatchObject* self, PyObject *unused) { #ifdef USE_BUILTIN_COPY MatchObject* copy; @@ -3225,7 +3225,7 @@ } static PyObject* -scanner_match(ScannerObject* self) +scanner_match(ScannerObject* self, PyObject *unused) { SRE_STATE* state = &self->state; PyObject* match; @@ -3256,7 +3256,7 @@ static PyObject* -scanner_search(ScannerObject* self) +scanner_search(ScannerObject* self, PyObject *unused) { SRE_STATE* state = &self->state; PyObject* match; From g.brandl at gmx.net Mon May 29 00:40:20 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 28 May 2006 22:40:20 +0000 Subject: [Python-checkins] r46516 - python/trunk/Modules/_sre.c In-Reply-To: <2m64jpzsuv.fsf@starship.python.net> References: <20060528221405.701391E4003@bag.python.org> <2m64jpzsuv.fsf@starship.python.net> Message-ID: Michael Hudson wrote: > "georg.brandl" writes: > >> Author: georg.brandl >> Date: Mon May 29 00:14:04 2006 >> New Revision: 46516 >> >> Modified: >> python/trunk/Modules/_sre.c >> Log: >> Fix C function calling conventions in _sre module. >> >> >> >> Modified: python/trunk/Modules/_sre.c >> ============================================================================== >> --- python/trunk/Modules/_sre.c (original) >> +++ python/trunk/Modules/_sre.c Mon May 29 00:14:04 2006 >> @@ -1623,7 +1623,7 @@ >> static PyObject*pattern_scanner(PatternObject*, PyObject*); >> >> static PyObject * >> -sre_codesize(PyObject* self, PyObject* args) >> +sre_codesize(PyObject* self) >> { > > This is the wrong declaration for a NOARGS function (see line 3538 of > ceval.c if you don't believe me, or comments on python.org/sf/660559). Well, why shouldn't I... fixed. Georg From mwh at python.net Mon May 29 00:49:06 2006 From: mwh at python.net (Michael Hudson) Date: Sun, 28 May 2006 23:49:06 +0100 Subject: [Python-checkins] r46516 - python/trunk/Modules/_sre.c In-Reply-To: (Georg Brandl's message of "Sun, 28 May 2006 22:40:20 +0000") References: <20060528221405.701391E4003@bag.python.org> <2m64jpzsuv.fsf@starship.python.net> Message-ID: <2m1wudzrx9.fsf@starship.python.net> Georg Brandl writes: >> This is the wrong declaration for a NOARGS function (see line 3538 of >> ceval.c if you don't believe me, or comments on python.org/sf/660559). > > Well, why shouldn't I... fixed. Dunno, it's late, I'm not making sense and I should be in bed. Thanks for the quick fixes today :) Cheers, mwh -- ZAPHOD: Listen three eyes, don't try to outweird me, I get stranger things than you free with my breakfast cereal. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From g.brandl at gmx.net Mon May 29 01:08:14 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 28 May 2006 23:08:14 +0000 Subject: [Python-checkins] r46516 - python/trunk/Modules/_sre.c In-Reply-To: <2m1wudzrx9.fsf@starship.python.net> References: <20060528221405.701391E4003@bag.python.org> <2m64jpzsuv.fsf@starship.python.net> <2m1wudzrx9.fsf@starship.python.net> Message-ID: Michael Hudson wrote: > Georg Brandl writes: > >>> This is the wrong declaration for a NOARGS function (see line 3538 of >>> ceval.c if you don't believe me, or comments on python.org/sf/660559). >> >> Well, why shouldn't I... fixed. > > Dunno, it's late, I'm not making sense and I should be in bed. Thanks > for the quick fixes today :) My pleasure, or even more, my duty as a newly-appointed bot ;) Georg From buildbot at python.org Mon May 29 01:14:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 28 May 2006 23:14:07 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) trunk Message-ID: <20060528231407.C34B81E4003@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/475 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: armin.rigo,georg.brandl BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From jimjjewett at gmail.com Mon May 29 01:31:47 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Sun, 28 May 2006 19:31:47 -0400 Subject: [Python-checkins] r46427 - sandbox/trunk/Doc/functional.rst In-Reply-To: <20060527003241.B378B1E4006@bag.python.org> References: <20060527003241.B378B1E4006@bag.python.org> Message-ID: I think the dropwhile and takewhile examples should demonstrate whether a true/false sticks. So itertools.takewhile(is_even, itertools.count()) => 0 2 would pass, but it doesn't get there, because the 1 stops it itertools.dropwhile(is_even, itertools.count()) => 1, 2, 3 because once the is_even(1) is false, the predicate stops checking. -jJ On 5/26/06, andrew.kuchling wrote: > Author: andrew.kuchling > Date: Sat May 27 02:32:40 2006 > New Revision: 46427 > > Modified: > sandbox/trunk/Doc/functional.rst > Log: > Describe more functions > > Modified: sandbox/trunk/Doc/functional.rst > ============================================================================== > --- sandbox/trunk/Doc/functional.rst (original) > +++ sandbox/trunk/Doc/functional.rst Sat May 27 02:32:40 2006 > @@ -725,14 +725,54 @@ > => > /usr/bin/java, /bin/python, /usr/bin/perl, /usr/bin/ruby > > +Another group of functions chooses a subset of an iterator's elements > +based on a **predicate**, a function that returns the truth value of > +some condition. > + > +``itertools.ifilter(predicate, iter)`` returns all the elements for > +which the predicate returns true:: > + > + def is_even(x): > + return (x % 2) == 0 > + > + itertools.ifilter(is_even, itertools.count()) => > + 0, 2, 4, 6, 8, 10, 12, 14, ... > + > +``itertools.ifilterfalse(predicate, iter)`` is the opposite, > +returning all elements for which the predicate returns false:: > + > + itertools.ifilterfalse(is_even, itertools.count()) => > + 1, 3, 5, 7, 9, 11, 13, 15, ... > + > +``itertools.takewhile(predicate, iter)`` returns elements for as long > +as the predicate returns true. Once the predicate returns false, > +the iterator will signal the end of its results. > + > +:: > + > + def less_than_10(x): > + return (x < 10) > + > + itertools.takewhile(less_than_10, itertools.count()) => > + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 > + > +``itertools.dropwhile(predicate, iter)`` discards elements while the > +predicate returns true, and then returns the rest of the iterable's > +results. > + > +:: > + > + itertools.dropwhile(less_than_10, itertools.count()) => > + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... > + > + > + > + > + > > > .. comment > > - ifilter > - ifilterfalse > - takewhile > - dropwhile > groupby > > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From buildbot at python.org Mon May 29 02:25:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 29 May 2006 00:25:12 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060529002512.511CB1E4011@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/818 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Mon May 29 06:15:06 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 28 May 2006 21:15:06 -0700 Subject: [Python-checkins] r46499 - in python/trunk: Include/pyport.h Include/unicodeobject.h Objects/stringobject.c In-Reply-To: References: <20060528120647.BE9B41E4006@bag.python.org> <4479E037.9000302@v.loewis.de> Message-ID: On 5/28/06, Fredrik Lundh wrote: > > >> needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only), > >> and use it for string copy operations. this gives a 20% speedup on some > >> string benchmarks. How about extending this to list and tuple at least (for memset)? Frame init does a memset, while tuple init does a loop. I'm sure there are other places that could make a diff. getargs, obmalloc, maybe. Note that in non-optimizing builds, memset/memcpy are much faster than the corresponding loops. At least that was my experience on Linux/gcc when profiling. n From nnorwitz at gmail.com Mon May 29 07:39:56 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 28 May 2006 22:39:56 -0700 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: <20060526120329.9A9671E400C@bag.python.org> References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: In the future, please try to do whitespace changes in a separate checkin. Also, unrelated changes should go in a separate checkin. Don't forget AMK's comment about adding doc. Other comments inline. On 5/26/06, martin.blais wrote: > Author: martin.blais > Date: Fri May 26 14:03:27 2006 > New Revision: 46300 > > Modified: > python/trunk/Lib/socket.py > python/trunk/Lib/test/test_socket.py > python/trunk/Lib/test/test_struct.py > python/trunk/Modules/_struct.c > python/trunk/Modules/arraymodule.c > python/trunk/Modules/socketmodule.c > Log: > Support for buffer protocol for socket and struct. > > * Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer > protocol (send and sendto already did). > > * Added struct.pack_to(), that is the corresponding buffer compatible method to > unpack_from(). > > * Fixed minor typos in arraymodule. > > > > > Modified: python/trunk/Lib/test/test_struct.py > ============================================================================== > --- python/trunk/Lib/test/test_struct.py (original) > +++ python/trunk/Lib/test/test_struct.py Fri May 26 14:03:27 2006 > def test_1229380(): > for endian in ('', '>', '<'): > for cls in (int, long): > @@ -478,3 +456,60 @@ > if 0: > # TODO: bug #1229380 > test_1229380() > + > +class PackBufferTestCase(unittest.TestCase): [...] > +def test_main(): > + test.test_support.run_unittest(PackBufferTestCase) > + > +if __name__ == "__main__": > + test_main() I don't think this really works to have both tests that follow the old-style (test on import) and unittest. It will create problems for finding refleaks and possibly other parts of regtest. It would be great if you could convert the rest of the tests in this file to use unittest. Barring that, I think the new test should use the old style. Or you could create a new file. > Modified: python/trunk/Modules/_struct.c > ============================================================================== > --- python/trunk/Modules/_struct.c (original) > +++ python/trunk/Modules/_struct.c Fri May 26 14:03:27 2006 > +PyDoc_STRVAR(s_pack__doc__, > +"pack(v1, v2, ...) -> string\n\ > +\n\ > +Return a string containing values v1, v2, ... packed according to this\n\ > +Struct's format. See struct.__doc__ for more on format strings."); > + > +static PyObject * > +s_pack(PyObject *self, PyObject *args) > +{ > + PyStructObject *soself; > + PyObject *result; > + > + /* Validate arguments. */ > + soself = (PyStructObject *)self; > + assert(PyStruct_Check(self)); > + assert(soself->s_codes != NULL); > + if (args == NULL || !PyTuple_Check(args) || > + PyTuple_GET_SIZE(args) != soself->s_len) I realize this code was here before in a different place, but args is guaranteed to be a non-NULL tuple, so there's no reason to check those. You still need to verify the size. > +static PyObject * > +s_pack_to(PyObject *self, PyObject *args) > +{ > + PyStructObject *soself; > + char *buffer; > + Py_ssize_t buffer_len, offset; > + > + /* Validate arguments. +1 is for the first arg as buffer. */ > + soself = (PyStructObject *)self; > + assert(PyStruct_Check(self)); > + assert(soself->s_codes != NULL); > + if (args == NULL || !PyTuple_Check(args) || > + PyTuple_GET_SIZE(args) != (soself->s_len + 2)) Same deal. > + { > + PyErr_Format(StructError, > + "pack_to requires exactly %d arguments", > + (soself->s_len + 2)); s_len is a Py_ssize_t, the format needs to be %zd. This is probably elsewhere too. > + return NULL; > + } > + > + /* Extract a writable memory buffer from the first argument */ > + if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), > + (void**)&buffer, &buffer_len) == -1 ) { > + return NULL; > + } > + assert( buffer_len >= 0 ); > + > + /* Extract the offset from the first argument */ > + offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1)); AsLong or AsSizeT? > + > + /* Support negative offsets. */ > + if (offset < 0) > + offset += buffer_len; > + > + /* Check boundaries */ > + if (offset < 0 || (buffer_len - offset) < soself->s_size) { > + PyErr_Format(StructError, > + "pack_to requires a buffer of at least %d bytes", > + soself->s_size); %zd > @@ -1400,6 +1479,7 @@ > > static struct PyMethodDef s_methods[] = { > {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, > + {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, s_pack_to doesn't need to be casted to a PyCFunction, it's signature is already correct. You can probably remove all the casts. > {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, > {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, > {NULL, NULL} /* sentinel */ > Modified: python/trunk/Modules/socketmodule.c > ============================================================================== > --- python/trunk/Modules/socketmodule.c (original) > +++ python/trunk/Modules/socketmodule.c Fri May 26 14:03:27 2006 > +static PyObject * > +sock_recv(PySocketSockObject *s, PyObject *args) > +{ > + int recvlen, flags = 0, outlen; > + PyObject *buf; > + > + if (!PyArg_ParseTuple(args, "i|i:recv", &recvlen, &flags)) > + return NULL; Note: it looks like recv takes size_t for the len and returns an ssize_t on Unix. It might be nice to use the same interface here. This would apply to the other network APIs too. > + if (recvlen < 0) { > + PyErr_SetString(PyExc_ValueError, > + "negative buffersize in recv"); > + return NULL; > + } > + > + /* Allocate a new string. */ > + buf = PyString_FromStringAndSize((char *) 0, recvlen); > + if (buf == NULL) > + return NULL; > + > + /* Call the guts */ > + outlen = sock_recv_guts(s, PyString_AsString(buf), recvlen, flags); Should use AS_STRING since this will return a valid pointer. It's faster and better static analysis can be done on it. It also points out that you know this is a string. > +static PyObject * > +sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds) [...] > + readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); > + if (readlen < 0) { > + /* Return an error */ > + goto finally; > + } > + > + /* Return the number of bytes read and the address. Note that we do > + not do anything special here in the case that readlen < recvlen. */ > + ret = PyTuple_Pack(2, PyInt_FromLong(readlen), addr); > + > +finally: > + Py_XDECREF(addr); > + return ret; Why not just do the Tuple_Pack if readlne >= 0? Hmmm, doesn't this leak a ref? n From mwh at python.net Mon May 29 10:04:26 2006 From: mwh at python.net (Michael Hudson) Date: Mon, 29 May 2006 09:04:26 +0100 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: (Neal Norwitz's message of "Sun, 28 May 2006 22:39:56 -0700") References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: <2mwtc5xnn9.fsf@starship.python.net> "Neal Norwitz" writes: >> +static PyObject * >> +sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds) > > [...] > >> + readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); >> + if (readlen < 0) { >> + /* Return an error */ >> + goto finally; >> + } >> + >> + /* Return the number of bytes read and the address. Note that we do >> + not do anything special here in the case that readlen < recvlen. */ >> + ret = PyTuple_Pack(2, PyInt_FromLong(readlen), addr); >> + >> +finally: >> + Py_XDECREF(addr); >> + return ret; > > Why not just do the Tuple_Pack if readlne >= 0? Hmmm, doesn't this leak a ref? Something does: test_socket leaked [1, 1, 1, 1] references test_urllib2net leaked [1, 1, 1, 1] references Cheers, mwh -- ARTHUR: Why are there three of you? LINTILLAS: Why is there only one of you? ARTHUR: Er... Could I have notice of that question? -- The Hitch-Hikers Guide to the Galaxy, Episode 11 From neal at metaslash.com Mon May 29 11:05:44 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 29 May 2006 05:05:44 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060529090544.GA15018@python.psfb.org> test_dummy_thread leaked [1, 1, 1] references test_socket leaked [1, 1, 1] references test_threadedtempfile leaked [83, 0, 0] references test_threading_local leaked [-91, 0, 0] references test_urllib2 leaked [91, -41, -41] references test_urllib2net leaked [1, 1, 1] references From python-checkins at python.org Mon May 29 11:46:52 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 11:46:52 +0200 (CEST) Subject: [Python-checkins] r46519 - in python/trunk: Modules/socketmodule.c Objects/exceptions.c Message-ID: <20060529094652.971F11E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 11:46:51 2006 New Revision: 46519 Modified: python/trunk/Modules/socketmodule.c python/trunk/Objects/exceptions.c Log: Fix refleak in socketmodule. Replace bogus Py_BuildValue calls. Fix refleak in exceptions. Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Mon May 29 11:46:51 2006 @@ -2472,7 +2472,7 @@ /* Return the number of bytes read and the address. Note that we do not do anything special here in the case that readlen < recvlen. */ - ret = PyTuple_Pack(2, PyInt_FromLong(readlen), addr); + ret = Py_BuildValue("lO", readlen, addr); finally: Py_XDECREF(addr); @@ -4364,8 +4364,10 @@ PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO); #endif PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM); - PyModule_AddObject(m, "BDADDR_ANY", Py_BuildValue("s", "00:00:00:00:00:00")); - PyModule_AddObject(m, "BDADDR_LOCAL", Py_BuildValue("s", "00:00:00:FF:FF:FF")); + PyModule_AddObject(m, "BDADDR_ANY", + PyString_FromString("00:00:00:00:00:00")); + PyModule_AddObject(m, "BDADDR_LOCAL", + PyString_FromString("00:00:00:FF:FF:FF")); #endif #ifdef HAVE_NETPACKET_PACKET_H Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Mon May 29 11:46:51 2006 @@ -246,6 +246,7 @@ } seq = PySequence_Tuple(val); if (!seq) return -1; + Py_CLEAR(self->args); self->args = seq; return 0; } From buildbot at python.org Mon May 29 12:38:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 29 May 2006 10:38:46 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060529103846.B2AAC1E4005@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/476 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 29 14:43:14 2006 From: python-checkins at python.org (nick.coghlan) Date: Mon, 29 May 2006 14:43:14 +0200 (CEST) Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule.c PC/VC6/pythoncore.dsp PC/config.c PCbuild/pythoncore.vcproj setup.py Message-ID: <20060529124314.3C7591E4005@bag.python.org> Author: nick.coghlan Date: Mon May 29 14:43:05 2006 New Revision: 46520 Added: python/trunk/Doc/lib/libfunctools.tex - copied, changed from r46519, python/trunk/Doc/lib/libfunctional.tex python/trunk/Lib/test/test_functools.py - copied, changed from r46519, python/trunk/Lib/test/test_functional.py python/trunk/Modules/_functoolsmodule.c - copied, changed from r46519, python/trunk/Modules/functionalmodule.c Removed: python/trunk/Doc/lib/libfunctional.tex python/trunk/Lib/test/test_functional.py python/trunk/Modules/functionalmodule.c Modified: python/trunk/Doc/Makefile.deps python/trunk/Doc/lib/lib.tex python/trunk/Misc/NEWS python/trunk/PC/VC6/pythoncore.dsp python/trunk/PC/config.c python/trunk/PCbuild/pythoncore.vcproj python/trunk/setup.py Log: Apply modified version of Collin Winter's patch #1478788 Renames functional extension module to _functools and adds a Python functools module so that utility functions like update_wrapper can be added easily. Modified: python/trunk/Doc/Makefile.deps ============================================================================== --- python/trunk/Doc/Makefile.deps (original) +++ python/trunk/Doc/Makefile.deps Mon May 29 14:43:05 2006 @@ -262,6 +262,7 @@ lib/libsimplexmlrpc.tex \ lib/libdocxmlrpc.tex \ lib/libpyexpat.tex \ + lib/libfunctools.tex \ lib/xmldom.tex \ lib/xmldomminidom.tex \ lib/xmldompulldom.tex \ Modified: python/trunk/Doc/lib/lib.tex ============================================================================== --- python/trunk/Doc/lib/lib.tex (original) +++ python/trunk/Doc/lib/lib.tex Mon May 29 14:43:05 2006 @@ -129,8 +129,8 @@ % Functions, Functional, Generators and Iterators % XXX intro functional \input{libitertools} -\input{libfunctional} -\input{liboperator} % from runtime - better with itertools and functional +\input{libfunctools} +\input{liboperator} % from runtime - better with itertools and functools % ============= Deleted: /python/trunk/Doc/lib/libfunctional.tex ============================================================================== --- /python/trunk/Doc/lib/libfunctional.tex Mon May 29 14:43:05 2006 +++ (empty file) @@ -1,81 +0,0 @@ -\section{\module{functional} --- - Higher order functions and operations on callable objects.} - -\declaremodule{standard}{functional} % standard library, in Python - -\moduleauthor{Peter Harris}{scav at blueyonder.co.uk} -\moduleauthor{Raymond Hettinger}{python at rcn.com} -\sectionauthor{Peter Harris}{scav at blueyonder.co.uk} - -\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 -be treated as a function for the purposes of this module. - - -The \module{functional} module defines the following function: - -\begin{funcdesc}{partial}{func\optional{,*args}\optional{, **keywords}} -Return a new \class{partial} object which when called will behave like -\var{func} called with the positional arguments \var{args} and keyword -arguments \var{keywords}. If more arguments are supplied to the call, they -are appended to \var{args}. If additional keyword arguments are supplied, -they extend and override \var{keywords}. Roughly equivalent to: - \begin{verbatim} - def partial(func, *args, **keywords): - def newfunc(*fargs, **fkeywords): - newkeywords = keywords.copy() - newkeywords.update(fkeywords) - return func(*(args + fargs), **newkeywords) - newfunc.func = func - newfunc.args = args - newfunc.keywords = keywords - return newfunc - \end{verbatim} - -The \function{partial} is used for partial function application which -``freezes'' some portion of a function's arguments and/or keywords -resulting in a new object with a simplified signature. For example, -\function{partial} can be used to create a callable that behaves like -the \function{int} function where the \var{base} argument defaults to -two: - \begin{verbatim} - >>> basetwo = partial(int, base=2) - >>> basetwo.__doc__ = 'Convert base 2 string to an int.' - >>> basetwo('10010') - 18 - \end{verbatim} -\end{funcdesc} - - - -\subsection{\class{partial} Objects \label{partial-objects}} - - -\class{partial} objects are callable objects created by \function{partial()}. -They have three read-only attributes: - -\begin{memberdesc}[callable]{func}{} -A callable object or function. Calls to the \class{partial} object will -be forwarded to \member{func} with new arguments and keywords. -\end{memberdesc} - -\begin{memberdesc}[tuple]{args}{} -The leftmost positional arguments that will be prepended to the -positional arguments provided to a \class{partial} object call. -\end{memberdesc} - -\begin{memberdesc}[dict]{keywords}{} -The keyword arguments that will be supplied when the \class{partial} object -is called. -\end{memberdesc} - -\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. Copied: python/trunk/Doc/lib/libfunctools.tex (from r46519, python/trunk/Doc/lib/libfunctional.tex) ============================================================================== --- python/trunk/Doc/lib/libfunctional.tex (original) +++ python/trunk/Doc/lib/libfunctools.tex Mon May 29 14:43:05 2006 @@ -1,7 +1,7 @@ -\section{\module{functional} --- +\section{\module{functools} --- Higher order functions and operations on callable objects.} -\declaremodule{standard}{functional} % standard library, in Python +\declaremodule{standard}{functools} % standard library, in Python \moduleauthor{Peter Harris}{scav at blueyonder.co.uk} \moduleauthor{Raymond Hettinger}{python at rcn.com} @@ -11,12 +11,12 @@ \versionadded{2.5} -The \module{functional} module is for higher-order functions: functions +The \module{functools} module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module. -The \module{functional} module defines the following function: +The \module{functools} module defines the following function: \begin{funcdesc}{partial}{func\optional{,*args}\optional{, **keywords}} Return a new \class{partial} object which when called will behave like Deleted: /python/trunk/Lib/test/test_functional.py ============================================================================== --- /python/trunk/Lib/test/test_functional.py Mon May 29 14:43:05 2006 +++ (empty file) @@ -1,177 +0,0 @@ -import functional -import unittest -from test import test_support -from weakref import proxy - - at staticmethod -def PythonPartial(func, *args, **keywords): - 'Pure Python approximation of partial()' - def newfunc(*fargs, **fkeywords): - newkeywords = keywords.copy() - newkeywords.update(fkeywords) - return func(*(args + fargs), **newkeywords) - newfunc.func = func - newfunc.args = args - newfunc.keywords = keywords - return newfunc - -def capture(*args, **kw): - """capture all positional and keyword arguments""" - return args, kw - -class TestPartial(unittest.TestCase): - - thetype = functional.partial - - def test_basic_examples(self): - p = self.thetype(capture, 1, 2, a=10, b=20) - self.assertEqual(p(3, 4, b=30, c=40), - ((1, 2, 3, 4), dict(a=10, b=30, c=40))) - p = self.thetype(map, lambda x: x*10) - self.assertEqual(p([1,2,3,4]), [10, 20, 30, 40]) - - def test_attributes(self): - p = self.thetype(capture, 1, 2, a=10, b=20) - # attributes should be readable - self.assertEqual(p.func, capture) - self.assertEqual(p.args, (1, 2)) - self.assertEqual(p.keywords, dict(a=10, b=20)) - # attributes should not be writable - if not isinstance(self.thetype, type): - return - self.assertRaises(TypeError, setattr, p, 'func', map) - self.assertRaises(TypeError, setattr, p, 'args', (1, 2)) - self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2)) - - def test_argument_checking(self): - self.assertRaises(TypeError, self.thetype) # need at least a func arg - try: - self.thetype(2)() - except TypeError: - pass - else: - self.fail('First arg not checked for callability') - - def test_protection_of_callers_dict_argument(self): - # a caller's dictionary should not be altered by partial - def func(a=10, b=20): - return a - d = {'a':3} - p = self.thetype(func, a=5) - self.assertEqual(p(**d), 3) - self.assertEqual(d, {'a':3}) - p(b=7) - self.assertEqual(d, {'a':3}) - - def test_arg_combinations(self): - # exercise special code paths for zero args in either partial - # object or the caller - p = self.thetype(capture) - self.assertEqual(p(), ((), {})) - self.assertEqual(p(1,2), ((1,2), {})) - p = self.thetype(capture, 1, 2) - self.assertEqual(p(), ((1,2), {})) - self.assertEqual(p(3,4), ((1,2,3,4), {})) - - def test_kw_combinations(self): - # exercise special code paths for no keyword args in - # either the partial object or the caller - p = self.thetype(capture) - self.assertEqual(p(), ((), {})) - self.assertEqual(p(a=1), ((), {'a':1})) - p = self.thetype(capture, a=1) - self.assertEqual(p(), ((), {'a':1})) - self.assertEqual(p(b=2), ((), {'a':1, 'b':2})) - # keyword args in the call override those in the partial object - self.assertEqual(p(a=3, b=2), ((), {'a':3, 'b':2})) - - def test_positional(self): - # make sure positional arguments are captured correctly - for args in [(), (0,), (0,1), (0,1,2), (0,1,2,3)]: - p = self.thetype(capture, *args) - expected = args + ('x',) - got, empty = p('x') - self.failUnless(expected == got and empty == {}) - - def test_keyword(self): - # make sure keyword arguments are captured correctly - for a in ['a', 0, None, 3.5]: - p = self.thetype(capture, a=a) - expected = {'a':a,'x':None} - empty, got = p(x=None) - self.failUnless(expected == got and empty == ()) - - def test_no_side_effects(self): - # make sure there are no side effects that affect subsequent calls - p = self.thetype(capture, 0, a=1) - args1, kw1 = p(1, b=2) - self.failUnless(args1 == (0,1) and kw1 == {'a':1,'b':2}) - args2, kw2 = p() - self.failUnless(args2 == (0,) and kw2 == {'a':1}) - - def test_error_propagation(self): - def f(x, y): - x / y - self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0)) - self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0) - self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) - self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) - - 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') - - 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 - -class TestPartialSubclass(TestPartial): - - thetype = PartialSubclass - - -class TestPythonPartial(TestPartial): - - thetype = PythonPartial - - - -def test_main(verbose=None): - import sys - test_classes = ( - TestPartial, - TestPartialSubclass, - TestPythonPartial, - ) - test_support.run_unittest(*test_classes) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in xrange(len(counts)): - test_support.run_unittest(*test_classes) - gc.collect() - counts[i] = sys.gettotalrefcount() - print counts - -if __name__ == '__main__': - test_main(verbose=True) Copied: python/trunk/Lib/test/test_functools.py (from r46519, python/trunk/Lib/test/test_functional.py) ============================================================================== --- python/trunk/Lib/test/test_functional.py (original) +++ python/trunk/Lib/test/test_functools.py Mon May 29 14:43:05 2006 @@ -1,4 +1,4 @@ -import functional +import functools import unittest from test import test_support from weakref import proxy @@ -21,7 +21,7 @@ class TestPartial(unittest.TestCase): - thetype = functional.partial + thetype = functools.partial def test_basic_examples(self): p = self.thetype(capture, 1, 2, a=10, b=20) @@ -140,7 +140,7 @@ join = self.thetype(''.join) self.assertEqual(join(data), '0123456789') -class PartialSubclass(functional.partial): +class PartialSubclass(functools.partial): pass class TestPartialSubclass(TestPartial): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 29 14:43:05 2006 @@ -4,10 +4,10 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.5 alpha 3? +What's New in Python 2.5 beta 1? ================================= -*Release date: XX-MAY-2006* +*Release date: XX-JUN-2006* Core and builtins ----------------- @@ -62,6 +62,11 @@ Extension Modules ----------------- +- Patch #1478788 (modified version): The functional extension module has + been renamed to _functools and a functools Python wrapper module added. + This provides a home for additional function related utilities that are + not specifically about functional programming. See PEP 309. + - Patch #1493701: performance enhancements for struct module. - Patch #1490224: time.altzone is now set correctly on Cygwin. @@ -82,6 +87,7 @@ - Calling Tk_Init twice is refused if the first call failed as that may deadlock. + Library ------- @@ -142,6 +148,8 @@ Documentation ------------- + + What's New in Python 2.5 alpha 2? ================================= Copied: python/trunk/Modules/_functoolsmodule.c (from r46519, python/trunk/Modules/functionalmodule.c) ============================================================================== --- python/trunk/Modules/functionalmodule.c (original) +++ python/trunk/Modules/_functoolsmodule.c Mon May 29 14:43:05 2006 @@ -2,10 +2,10 @@ #include "Python.h" #include "structmember.h" -/* Functional module written and maintained +/* _functools module written and maintained by Hye-Shik Chang with adaptations by Raymond Hettinger - Copyright (c) 2004, 2005 Python Software Foundation. + Copyright (c) 2004, 2005, 2006 Python Software Foundation. All rights reserved. */ @@ -199,7 +199,7 @@ static PyTypeObject partial_type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ - "functional.partial", /* tp_name */ + "functools.partial", /* tp_name */ sizeof(partialobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -245,14 +245,14 @@ /* module level code ********************************************************/ PyDoc_STRVAR(module_doc, -"Tools for functional programming."); +"Tools that operate on functions."); static PyMethodDef module_methods[] = { {NULL, NULL} /* sentinel */ }; PyMODINIT_FUNC -initfunctional(void) +init_functools(void) { int i; PyObject *m; @@ -262,7 +262,7 @@ NULL }; - m = Py_InitModule3("functional", module_methods, module_doc); + m = Py_InitModule3("_functools", module_methods, module_doc); if (m == NULL) return; Deleted: /python/trunk/Modules/functionalmodule.c ============================================================================== --- /python/trunk/Modules/functionalmodule.c Mon May 29 14:43:05 2006 +++ (empty file) @@ -1,277 +0,0 @@ - -#include "Python.h" -#include "structmember.h" - -/* Functional module written and maintained - by Hye-Shik Chang - with adaptations by Raymond Hettinger - Copyright (c) 2004, 2005 Python Software Foundation. - All rights reserved. -*/ - -/* partial object **********************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *fn; - PyObject *args; - PyObject *kw; - PyObject *dict; - PyObject *weakreflist; /* List of weak references */ -} partialobject; - -static PyTypeObject partial_type; - -static PyObject * -partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *func; - partialobject *pto; - - if (PyTuple_GET_SIZE(args) < 1) { - PyErr_SetString(PyExc_TypeError, - "type 'partial' takes at least one argument"); - return NULL; - } - - func = PyTuple_GET_ITEM(args, 0); - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, - "the first argument must be callable"); - return NULL; - } - - /* create partialobject structure */ - pto = (partialobject *)type->tp_alloc(type, 0); - if (pto == NULL) - return NULL; - - pto->fn = func; - Py_INCREF(func); - pto->args = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); - if (pto->args == NULL) { - pto->kw = NULL; - Py_DECREF(pto); - return NULL; - } - if (kw != NULL) { - pto->kw = PyDict_Copy(kw); - if (pto->kw == NULL) { - Py_DECREF(pto); - return NULL; - } - } else { - pto->kw = Py_None; - Py_INCREF(Py_None); - } - - pto->weakreflist = NULL; - pto->dict = NULL; - - return (PyObject *)pto; -} - -static void -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); -} - -static PyObject * -partial_call(partialobject *pto, PyObject *args, PyObject *kw) -{ - PyObject *ret; - PyObject *argappl = NULL, *kwappl = NULL; - - assert (PyCallable_Check(pto->fn)); - assert (PyTuple_Check(pto->args)); - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); - - if (PyTuple_GET_SIZE(pto->args) == 0) { - argappl = args; - Py_INCREF(args); - } else if (PyTuple_GET_SIZE(args) == 0) { - argappl = pto->args; - Py_INCREF(pto->args); - } else { - argappl = PySequence_Concat(pto->args, args); - if (argappl == NULL) - return NULL; - } - - if (pto->kw == Py_None) { - kwappl = kw; - Py_XINCREF(kw); - } else { - kwappl = PyDict_Copy(pto->kw); - if (kwappl == NULL) { - Py_DECREF(argappl); - return NULL; - } - if (kw != NULL) { - if (PyDict_Merge(kwappl, kw, 1) != 0) { - Py_DECREF(argappl); - Py_DECREF(kwappl); - return NULL; - } - } - } - - ret = PyObject_Call(pto->fn, argappl, kwappl); - Py_DECREF(argappl); - Py_XDECREF(kwappl); - return ret; -} - -static int -partial_traverse(partialobject *pto, visitproc visit, void *arg) -{ - Py_VISIT(pto->fn); - Py_VISIT(pto->args); - Py_VISIT(pto->kw); - Py_VISIT(pto->dict); - return 0; -} - -PyDoc_STRVAR(partial_doc, -"partial(func, *args, **keywords) - new function with partial application\n\ - of the given arguments and keywords.\n"); - -#define OFF(x) offsetof(partialobject, x) -static PyMemberDef partial_memberlist[] = { - {"func", T_OBJECT, OFF(fn), READONLY, - "function object to use in future partial calls"}, - {"args", T_OBJECT, OFF(args), READONLY, - "tuple of arguments to future partial calls"}, - {"keywords", T_OBJECT, OFF(kw), READONLY, - "dictionary of keyword arguments to future partial calls"}, - {NULL} /* Sentinel */ -}; - -static 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 partial_getsetlist[] = { - {"__dict__", (getter)partial_get_dict, (setter)partial_set_dict}, - {NULL} /* Sentinel */ -}; - -static PyTypeObject partial_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "functional.partial", /* tp_name */ - sizeof(partialobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)partial_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)partial_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ - partial_doc, /* tp_doc */ - (traverseproc)partial_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(partialobject, weakreflist), /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - partial_memberlist, /* tp_members */ - partial_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - offsetof(partialobject, dict), /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - partial_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* module level code ********************************************************/ - -PyDoc_STRVAR(module_doc, -"Tools for functional programming."); - -static PyMethodDef module_methods[] = { - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initfunctional(void) -{ - int i; - PyObject *m; - char *name; - PyTypeObject *typelist[] = { - &partial_type, - NULL - }; - - m = Py_InitModule3("functional", module_methods, module_doc); - if (m == NULL) - return; - - for (i=0 ; typelist[i] != NULL ; i++) { - if (PyType_Ready(typelist[i]) < 0) - return; - name = strchr(typelist[i]->tp_name, '.'); - assert (name != NULL); - Py_INCREF(typelist[i]); - PyModule_AddObject(m, name+1, (PyObject *)typelist[i]); - } -} Modified: python/trunk/PC/VC6/pythoncore.dsp ============================================================================== Binary files. No diff available. Modified: python/trunk/PC/config.c ============================================================================== --- python/trunk/PC/config.c (original) +++ python/trunk/PC/config.c Mon May 29 14:43:05 2006 @@ -54,7 +54,7 @@ extern void init_winreg(void); extern void init_struct(void); extern void initdatetime(void); -extern void initfunctional(void); +extern void init_functools(void); extern void initzlib(void); extern void init_multibytecodec(void); @@ -132,7 +132,7 @@ {"_winreg", init_winreg}, {"_struct", init_struct}, {"datetime", initdatetime}, - {"functional", initfunctional}, + {"_functools", init_functools}, {"xxsubtype", initxxsubtype}, {"zipimport", initzipimport}, Modified: python/trunk/PCbuild/pythoncore.vcproj ============================================================================== --- python/trunk/PCbuild/pythoncore.vcproj (original) +++ python/trunk/PCbuild/pythoncore.vcproj Mon May 29 14:43:05 2006 @@ -515,10 +515,7 @@ RelativePath="..\Objects\funcobject.c"> - - + RelativePath="..\Modules\_functoolsmodule.c"> Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Mon May 29 14:43:05 2006 @@ -377,8 +377,8 @@ exts.append( Extension("_heapq", ["_heapqmodule.c"]) ) # operator.add() and similar goodies exts.append( Extension('operator', ['operator.c']) ) - # functional - exts.append( Extension("functional", ["functionalmodule.c"]) ) + # _functools + exts.append( Extension("_functools", ["_functoolsmodule.c"]) ) # Python C API test module exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) # profilers (_lsprof is for cProfile.py) From python-checkins at python.org Mon May 29 14:49:04 2006 From: python-checkins at python.org (nick.coghlan) Date: Mon, 29 May 2006 14:49:04 +0200 (CEST) Subject: [Python-checkins] r46521 - peps/trunk/pep-0309.txt peps/trunk/pep-0356.txt Message-ID: <20060529124904.EE91A1E4005@bag.python.org> Author: nick.coghlan Date: Mon May 29 14:49:03 2006 New Revision: 46521 Modified: peps/trunk/pep-0309.txt peps/trunk/pep-0356.txt Log: functional has been renamed to functools and alpha 3 was skipped Modified: peps/trunk/pep-0309.txt ============================================================================== --- peps/trunk/pep-0309.txt (original) +++ peps/trunk/pep-0309.txt Mon May 29 14:49:03 2006 @@ -8,7 +8,21 @@ Content-Type: text/x-rst Created: 08-Feb-2003 Python-Version: 2.5 -Post-History: 10-Feb-2003, 27-Feb-2003, 22-Feb-2004 +Post-History: 10-Feb-2003, 27-Feb-2003, 22-Feb-2004, 28-Apr-2006 + + +Note +==== + +Following the acceptance of this PEP, further discussion on python-dev and +comp.lang.python revealed a desire for several tools that operated on +function objects, but were not related to functional programming. Rather +than create a new module for these tools, it was agreed [1]_ that the +"functional" module be renamed to "functools" to reflect its newly-widened +focus. + +References in this PEP to a "functional" module have been left in for +historical reasons. Abstract @@ -100,7 +114,7 @@ return self.fn(*(self.args + args), **d) (A recipe similar to this has been in the Python Cookbook for some -time [1]_.) +time [3]_.) Note that when the object is called as though it were a function, positional arguments are appended to those provided to the @@ -269,10 +283,12 @@ References ========== -.. [1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 +.. [1] http://mail.python.org/pipermail/python-dev/2006-March/062290.html .. [2] Patches 931005_, 931007_, and 931010_. +.. [3] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 + .. _931005: http://www.python.org/sf/931005 .. _931007: http://www.python.org/sf/931007 .. _931010: http://www.python.org/sf/931010 Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Mon May 29 14:49:03 2006 @@ -38,7 +38,7 @@ alpha 1: April 5, 2006 [completed] alpha 2: April 27, 2006 [completed] - alpha 3: May 25, 2006 [planned] + alpha 3: ------------- [skipped] beta 1: June 14, 2006 [planned] beta 2: July 6, 2006 [planned] rc 1: July 27, 2006 [planned] @@ -106,7 +106,12 @@ Each feature below should implemented prior to beta1 or will require BDFL approval for inclusion in 2.5. - - Add @decorator decorator to functional, rename to functools? + - Add update_wrapper function to functools (approved by BDFL) + http://mail.python.org/pipermail/python-dev/2006-May/064775.html + (Owner: Nick Coghlan - patches with tests & docs welcome, though ;) + + - Add @wraps(f) decorator factory to functools? + (see comment in functools Python module) - Modules under consideration for inclusion: From g.brandl at gmx.net Mon May 29 15:08:09 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Mon, 29 May 2006 15:08:09 +0200 Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule.c PC/VC6/pythoncore.dsp PC/config.c PCbuild/pythoncore.vcproj setup.py In-Reply-To: <20060529124314.3C7591E4005@bag.python.org> References: <20060529124314.3C7591E4005@bag.python.org> Message-ID: nick.coghlan wrote: > Author: nick.coghlan > Date: Mon May 29 14:43:05 2006 > New Revision: 46520 > > Added: > python/trunk/Doc/lib/libfunctools.tex > - copied, changed from r46519, python/trunk/Doc/lib/libfunctional.tex > python/trunk/Lib/test/test_functools.py > - copied, changed from r46519, python/trunk/Lib/test/test_functional.py > python/trunk/Modules/_functoolsmodule.c > - copied, changed from r46519, python/trunk/Modules/functionalmodule.c > Removed: > python/trunk/Doc/lib/libfunctional.tex > python/trunk/Lib/test/test_functional.py > python/trunk/Modules/functionalmodule.c > Modified: > python/trunk/Doc/Makefile.deps > python/trunk/Doc/lib/lib.tex > python/trunk/Misc/NEWS > python/trunk/PC/VC6/pythoncore.dsp > python/trunk/PC/config.c > python/trunk/PCbuild/pythoncore.vcproj > python/trunk/setup.py > Log: > Apply modified version of Collin Winter's patch #1478788 Isn't Lib/functools.py missing? Georg From python-checkins at python.org Mon May 29 15:53:16 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 15:53:16 +0200 (CEST) Subject: [Python-checkins] r46522 - python/trunk/Modules/fmmodule.c Message-ID: <20060529135316.EAFC61E4006@bag.python.org> Author: georg.brandl Date: Mon May 29 15:53:16 2006 New Revision: 46522 Modified: python/trunk/Modules/fmmodule.c Log: Convert fmmodule to METH_VARARGS. Modified: python/trunk/Modules/fmmodule.c ============================================================================== --- python/trunk/Modules/fmmodule.c (original) +++ python/trunk/Modules/fmmodule.c Mon May 29 15:53:16 2006 @@ -41,7 +41,7 @@ fh_scalefont(fhobject *self, PyObject *args) { double size; - if (!PyArg_Parse(args, "d", &size)) + if (!PyArg_ParseTuple(args, "d", &size)) return NULL; return newfhobject(fmscalefont(self->fh_fh, size)); } @@ -112,21 +112,21 @@ fh_getstrwidth(fhobject *self, PyObject *args) { char *str; - if (!PyArg_Parse(args, "s", &str)) + if (!PyArg_ParseTuple(args, "s", &str)) return NULL; return PyInt_FromLong(fmgetstrwidth(self->fh_fh, str)); } static PyMethodDef fh_methods[] = { - {"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS}, + {"scalefont", (PyCFunction)fh_scalefont, METH_VARARGS}, {"setfont", (PyCFunction)fh_setfont, METH_NOARGS}, {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS}, {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS}, {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS}, #if 0 - {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS}, + {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_VARARGS}, #endif - {"getstrwidth", (PyCFunction)fh_getstrwidth, METH_OLDARGS}, + {"getstrwidth", (PyCFunction)fh_getstrwidth, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; @@ -173,7 +173,7 @@ fm_findfont(PyObject *self, PyObject *args) { char *str; - if (!PyArg_Parse(args, "s", &str)) + if (!PyArg_ParseTuple(args, "s", &str)) return NULL; return newfhobject(fmfindfont(str)); } @@ -182,7 +182,7 @@ fm_prstr(PyObject *self, PyObject *args) { char *str; - if (!PyArg_Parse(args, "s", &str)) + if (!PyArg_ParseTuple(args, "s", &str)) return NULL; fmprstr(str); Py_INCREF(Py_None); @@ -230,7 +230,7 @@ fm_setpath(PyObject *self, PyObject *args) { char *str; - if (!PyArg_Parse(args, "s", &str)) + if (!PyArg_ParseTuple(args, "s", &str)) return NULL; fmsetpath(str); Py_INCREF(Py_None); @@ -245,10 +245,10 @@ static PyMethodDef fm_methods[] = { {"init", fm_init, METH_NOARGS}, - {"findfont", fm_findfont, METH_OLDARGS}, + {"findfont", fm_findfont, METH_VARARGS}, {"enumerate", fm_enumerate, METH_NOARGS}, - {"prstr", fm_prstr, METH_OLDARGS}, - {"setpath", fm_setpath, METH_OLDARGS}, + {"prstr", fm_prstr, METH_VARARGS}, + {"setpath", fm_setpath, METH_VARARGS}, {"fontpath", fm_fontpath, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; From python-checkins at python.org Mon May 29 16:13:22 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 16:13:22 +0200 (CEST) Subject: [Python-checkins] r46523 - python/trunk/Python/errors.c Message-ID: <20060529141322.4D3A81E4006@bag.python.org> Author: georg.brandl Date: Mon May 29 16:13:21 2006 New Revision: 46523 Modified: python/trunk/Python/errors.c Log: Fix #1494605. Modified: python/trunk/Python/errors.c ============================================================================== --- python/trunk/Python/errors.c (original) +++ python/trunk/Python/errors.c Mon May 29 16:13:21 2006 @@ -728,7 +728,8 @@ tmp = PyErr_ProgramText(filename, lineno); if (tmp) { - PyObject_SetAttrString(v, "text", tmp); + if (PyObject_SetAttrString(v, "text", tmp)) + PyErr_Clear(); Py_DECREF(tmp); } } From python-checkins at python.org Mon May 29 16:28:05 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 16:28:05 +0200 (CEST) Subject: [Python-checkins] r46524 - python/trunk/Python/pystrtod.c Message-ID: <20060529142805.A28C81E4006@bag.python.org> Author: georg.brandl Date: Mon May 29 16:28:05 2006 New Revision: 46524 Modified: python/trunk/Python/pystrtod.c Log: Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671. Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Mon May 29 16:28:05 2006 @@ -31,6 +31,7 @@ * is returned (according to the sign of the value), and %ERANGE is * stored in %errno. If the correct value would cause underflow, * zero is returned and %ERANGE is stored in %errno. + * If memory allocation fails, %ENOMEM is stored in %errno. * * This function resets %errno before calling strtod() so that * you can reliably detect overflow and underflow. @@ -102,6 +103,12 @@ /* We need to convert the '.' to the locale specific decimal point */ copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len); + if (copy == NULL) { + if (endptr) + *endptr = nptr; + errno = ENOMEM; + return val; + } c = copy; memcpy(c, nptr, decimal_point_pos - nptr); From python-checkins at python.org Mon May 29 16:33:56 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 16:33:56 +0200 (CEST) Subject: [Python-checkins] r46525 - python/trunk/Python/pystrtod.c Message-ID: <20060529143356.190171E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 16:33:55 2006 New Revision: 46525 Modified: python/trunk/Python/pystrtod.c Log: Fix compiler warning. Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Mon May 29 16:33:55 2006 @@ -105,7 +105,7 @@ copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len); if (copy == NULL) { if (endptr) - *endptr = nptr; + *endptr = (char *)nptr; errno = ENOMEM; return val; } From python-checkins at python.org Mon May 29 16:39:00 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 16:39:00 +0200 (CEST) Subject: [Python-checkins] r46526 - python/trunk/Lib/pyclbr.py Message-ID: <20060529143900.AF43E1E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 16:39:00 2006 New Revision: 46526 Modified: python/trunk/Lib/pyclbr.py Log: Fix #1494787 (pyclbr counts whitespace as superclass name) Modified: python/trunk/Lib/pyclbr.py ============================================================================== --- python/trunk/Lib/pyclbr.py (original) +++ python/trunk/Lib/pyclbr.py Mon May 29 16:39:00 2006 @@ -42,7 +42,7 @@ import sys import imp import tokenize # Python tokenizer -from token import NAME, DEDENT, NEWLINE +from token import NAME, DEDENT, NEWLINE, OP from operator import itemgetter __all__ = ["readmodule", "readmodule_ex", "Class", "Function"] @@ -219,8 +219,10 @@ break elif token == ',' and level == 1: pass - else: + # only use NAME and OP (== dot) tokens for type name + elif tokentype in (NAME, OP) and level == 1: super.append(token) + # expressions in the base list are not supported inherit = names cur_class = Class(fullmodule, class_name, inherit, file, lineno) if not stack: From python-checkins at python.org Mon May 29 17:47:29 2006 From: python-checkins at python.org (bob.ippolito) Date: Mon, 29 May 2006 17:47:29 +0200 (CEST) Subject: [Python-checkins] r46527 - python/trunk/Modules/_struct.c Message-ID: <20060529154729.F1F631E4005@bag.python.org> Author: bob.ippolito Date: Mon May 29 17:47:29 2006 New Revision: 46527 Modified: python/trunk/Modules/_struct.c Log: simplify the struct code a bit (no functional changes) Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Mon May 29 17:47:29 2006 @@ -223,28 +223,28 @@ /* Helper to format the range error exceptions */ static int -_range_error(char format, Py_ssize_t size, int is_unsigned) +_range_error(formatdef *f, int is_unsigned) { if (is_unsigned == 0) { long smallest = 0, largest = 0; - Py_ssize_t i = size * 8; + Py_ssize_t i = f->size * 8; while (--i > 0) { smallest = (smallest * 2) - 1; largest = (largest * 2) + 1; } PyErr_Format(StructError, "'%c' format requires %ld <= number <= %ld", - format, + f->format, smallest, largest); } else { unsigned long largest = 0; - Py_ssize_t i = size * 8; + Py_ssize_t i = f->size * 8; while (--i >= 0) largest = (largest * 2) + 1; PyErr_Format(StructError, "'%c' format requires 0 <= number <= %lu", - format, + f->format, largest); } return -1; @@ -482,7 +482,7 @@ return -1; #if (SIZEOF_LONG > SIZEOF_INT) if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX))) - return _range_error(f->format, sizeof(y), 0); + return _range_error(f, 0); #endif y = (int)x; memcpy(p, (char *)&y, sizeof y); @@ -495,11 +495,11 @@ unsigned long x; unsigned int y; if (get_ulong(v, &x) < 0) - return _range_error(f->format, sizeof(y), 1); + return _range_error(f, 1); y = (unsigned int)x; #if (SIZEOF_LONG > SIZEOF_INT) if (x > ((unsigned long)UINT_MAX)) - return _range_error(f->format, sizeof(y), 1); + return _range_error(f, 1); #endif memcpy(p, (char *)&y, sizeof y); return 0; @@ -520,7 +520,7 @@ { unsigned long x; if (get_ulong(v, &x) < 0) - return _range_error(f->format, sizeof(x), 1); + return _range_error(f, 1); memcpy(p, (char *)&x, sizeof x); return 0; } @@ -621,8 +621,9 @@ { long x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (*p++ & 0xFF); + x = (x<<8) | *bytes++; } while (--i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) @@ -635,8 +636,9 @@ { unsigned long x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (*p++ & 0xFF); + x = (x<<8) | *bytes++; } while (--i > 0); if (x <= LONG_MAX) return PyInt_FromLong((long)x); @@ -649,8 +651,9 @@ #ifdef HAVE_LONG_LONG PY_LONG_LONG x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (*p++ & 0xFF); + x = (x<<8) | *bytes++; } while (--i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) @@ -672,8 +675,9 @@ #ifdef HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (*p++ & 0xFF); + x = (x<<8) | *bytes++; } while (--i > 0); if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); @@ -708,10 +712,10 @@ i = f->size; if (i != SIZEOF_LONG) { if ((i == 2) && (x < -32768 || x > 32767)) - return _range_error(f->format, i, 0); + return _range_error(f, 0); #if (SIZEOF_LONG != 4) else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) - return _range_error(f->format, i, 0); + return _range_error(f, 0); #endif } do { @@ -733,7 +737,7 @@ unsigned long maxint = 1; maxint <<= (unsigned long)(i * 8); if (x >= maxint) - return _range_error(f->format, f->size, 1); + return _range_error(f, 1); } do { p[--i] = (char)x; @@ -825,8 +829,9 @@ { long x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (p[--i] & 0xFF); + x = (x<<8) | bytes[--i]; } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) @@ -839,8 +844,9 @@ { unsigned long x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (p[--i] & 0xFF); + x = (x<<8) | bytes[--i]; } while (i > 0); if (x <= LONG_MAX) return PyInt_FromLong((long)x); @@ -853,8 +859,9 @@ #ifdef HAVE_LONG_LONG PY_LONG_LONG x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (p[--i] & 0xFF); + x = (x<<8) | bytes[--i]; } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) @@ -876,8 +883,9 @@ #ifdef HAVE_LONG_LONG unsigned PY_LONG_LONG x = 0; Py_ssize_t i = f->size; + const unsigned char *bytes = (const unsigned char *)p; do { - x = (x<<8) | (p[--i] & 0xFF); + x = (x<<8) | bytes[--i]; } while (i > 0); if (x <= LONG_MAX) return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); @@ -912,10 +920,10 @@ i = f->size; if (i != SIZEOF_LONG) { if ((i == 2) && (x < -32768 || x > 32767)) - return _range_error(f->format, i, 0); + return _range_error(f, 0); #if (SIZEOF_LONG != 4) else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) - return _range_error(f->format, i, 0); + return _range_error(f, 0); #endif } do { @@ -937,7 +945,7 @@ unsigned long maxint = 1; maxint <<= (unsigned long)(i * 8); if (x >= maxint) - return _range_error(f->format, f->size, 1); + return _range_error(f, 1); } do { *p++ = (char)x; From python-checkins at python.org Mon May 29 19:59:49 2006 From: python-checkins at python.org (armin.rigo) Date: Mon, 29 May 2006 19:59:49 +0200 (CEST) Subject: [Python-checkins] r46528 - python/trunk/Modules/_struct.c Message-ID: <20060529175949.AC6A51E4005@bag.python.org> Author: armin.rigo Date: Mon May 29 19:59:47 2006 New Revision: 46528 Modified: python/trunk/Modules/_struct.c Log: Silence a warning. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Mon May 29 19:59:47 2006 @@ -223,7 +223,7 @@ /* Helper to format the range error exceptions */ static int -_range_error(formatdef *f, int is_unsigned) +_range_error(const formatdef *f, int is_unsigned) { if (is_unsigned == 0) { long smallest = 0, largest = 0; From buildbot at python.org Mon May 29 21:27:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 29 May 2006 19:27:48 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin trunk Message-ID: <20060529192748.94D731E4005@bag.python.org> The Buildbot has detected a new failure of x86 cygwin trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%2520trunk/builds/616 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: armin.rigo Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon May 29 21:39:46 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 21:39:46 +0200 (CEST) Subject: [Python-checkins] r46529 - in python/trunk: Modules/binascii.c Modules/mmapmodule.c Objects/classobject.c Objects/object.c Message-ID: <20060529193946.DC44A1E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 21:39:45 2006 New Revision: 46529 Modified: python/trunk/Modules/binascii.c python/trunk/Modules/mmapmodule.c python/trunk/Objects/classobject.c python/trunk/Objects/object.c Log: Correct some value converting strangenesses. Modified: python/trunk/Modules/binascii.c ============================================================================== --- python/trunk/Modules/binascii.c (original) +++ python/trunk/Modules/binascii.c Mon May 29 21:39:45 2006 @@ -644,7 +644,7 @@ /* Empty string is a special case */ if ( in_len == 0 ) - return Py_BuildValue("s", ""); + return PyString_FromString(""); /* Allocate a buffer of reasonable size. Resized when needed */ out_len = in_len*2; Modified: python/trunk/Modules/mmapmodule.c ============================================================================== --- python/trunk/Modules/mmapmodule.c (original) +++ python/trunk/Modules/mmapmodule.c Mon May 29 21:39:45 2006 @@ -477,7 +477,7 @@ CHECK_VALID(NULL); if (!PyArg_ParseTuple(args, ":tell")) return NULL; - return Py_BuildValue("l", (long) self->pos); + return PyInt_FromLong((long) self->pos); } static PyObject * @@ -493,7 +493,7 @@ return NULL; } else { #ifdef MS_WINDOWS - return Py_BuildValue("l", (long) + return PyInt_FromLong((long) FlushViewOfFile(self->data+offset, size)); #endif /* MS_WINDOWS */ #ifdef UNIX @@ -505,7 +505,7 @@ PyErr_SetFromErrno(mmap_module_error); return NULL; } - return Py_BuildValue("l", (long) 0); + return PyInt_FromLong(0); #endif /* UNIX */ } } Modified: python/trunk/Objects/classobject.c ============================================================================== --- python/trunk/Objects/classobject.c (original) +++ python/trunk/Objects/classobject.c Mon May 29 21:39:45 2006 @@ -1136,9 +1136,9 @@ if (func == NULL) return -1; if (item == NULL) - arg = Py_BuildValue("i", i); + arg = PyInt_FromSsize_t(i); else - arg = Py_BuildValue("(iO)", i, item); + arg = Py_BuildValue("(nO)", i, item); if (arg == NULL) { Py_DECREF(func); return -1; Modified: python/trunk/Objects/object.c ============================================================================== --- python/trunk/Objects/object.c (original) +++ python/trunk/Objects/object.c Mon May 29 21:39:45 2006 @@ -112,7 +112,7 @@ if (result == NULL) return NULL; for (tp = type_list; tp; tp = tp->tp_next) { - v = Py_BuildValue("(siii)", tp->tp_name, tp->tp_allocs, + v = Py_BuildValue("(snnn)", tp->tp_name, tp->tp_allocs, tp->tp_frees, tp->tp_maxalloc); if (v == NULL) { Py_DECREF(result); From buildbot at python.org Mon May 29 21:47:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 29 May 2006 19:47:39 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20060529194739.6B7B21E4013@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/857 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From guido at python.org Mon May 29 21:59:32 2006 From: guido at python.org (Guido van Rossum) Date: Mon, 29 May 2006 12:59:32 -0700 Subject: [Python-checkins] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: [python-checkins] > >> * Added socket.recv_buf() and socket.recvfrom_buf() methods, that > >> use the buffer > >> protocol (send and sendto already did). > >> > >> * Added struct.pack_to(), that is the corresponding buffer > >> compatible method to > >> unpack_from(). [Guido] > > Hm... The file object has a similar method readinto(). Perhaps the > > methods introduced here could follow that lead instead of using two > > different new naming conventions? On 5/27/06, Bob Ippolito wrote: > (speaking specifically about struct and not socket) > > pack_to and unpack_from are named as such because they work with objects > that support the buffer API (not file-like-objects). I couldn't find any > existing convention for objects that manipulate buffers in such a way. Actually, .readinto() is the convention I started long ago (at the time the buffer was introduced. > If there is an existing convention then I'd be happy to rename these. > > "readinto" seems to imply that some kind of position is being > incremented. No -- it's like read() but instead of returning a new object it reads "into" an object you pass. > Grammatically it only works if it's implemented on all buffer > objects, but > in this case it's implemented on the Struct type. It looks like .pack_to(, ) is similar to .readinto() in that the buffer object receives the result of packing / reading. (Files don't have a writefrom() method because write() can be polymorphic. read() can't be due to the asymmetry in the API. I guess struct objects are different.) -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Mon May 29 22:27:44 2006 From: python-checkins at python.org (nick.coghlan) Date: Mon, 29 May 2006 22:27:44 +0200 (CEST) Subject: [Python-checkins] r46530 - python/trunk/Lib/functools.py Message-ID: <20060529202744.A72D91E4005@bag.python.org> Author: nick.coghlan Date: Mon May 29 22:27:44 2006 New Revision: 46530 Added: python/trunk/Lib/functools.py (contents, props changed) Log: When adding a module like functools, it helps to let SVN know about the file. Added: python/trunk/Lib/functools.py ============================================================================== --- (empty file) +++ python/trunk/Lib/functools.py Mon May 29 22:27:44 2006 @@ -0,0 +1,26 @@ +"""functools.py - Tools for working with functions +""" +# Python module wrapper for _functools C module +# to allow utilities written in Python to be added +# to the functools module. +# Written by Nick Coghlan +# Copyright (c) 2006 Python Software Foundation. + +from _functools import partial +__all__ = [ + "partial", +] + +# Still to come here (need to write tests and docs): +# update_wrapper - utility function to transfer basic function +# metadata to wrapper functions +# WRAPPER_ASSIGNMENTS & WRAPPER_UPDATES - defaults args to above +# (update_wrapper has been approved by BDFL) +# wraps - decorator factory equivalent to: +# def wraps(f): +# return partial(update_wrapper, wrapped=f) +# +# The wraps function makes it easy to avoid the bug that afflicts the +# decorator example in the python-dev email proposing the +# update_wrapper function: +# http://mail.python.org/pipermail/python-dev/2006-May/064775.html \ No newline at end of file From ncoghlan at gmail.com Mon May 29 22:29:37 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 30 May 2006 06:29:37 +1000 Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule.c PC/VC6/pythoncore.dsp PC/config.c PCbuild/pythoncore.vcproj setup.py In-Reply-To: References: <20060529124314.3C7591E4005@bag.python.org> Message-ID: <447B59B1.9070600@gmail.com> Georg Brandl wrote: > nick.coghlan wrote: >> Author: nick.coghlan >> Date: Mon May 29 14:43:05 2006 >> New Revision: 46520 >> >> Added: >> python/trunk/Doc/lib/libfunctools.tex >> - copied, changed from r46519, python/trunk/Doc/lib/libfunctional.tex >> python/trunk/Lib/test/test_functools.py >> - copied, changed from r46519, python/trunk/Lib/test/test_functional.py >> python/trunk/Modules/_functoolsmodule.c >> - copied, changed from r46519, python/trunk/Modules/functionalmodule.c >> Removed: >> python/trunk/Doc/lib/libfunctional.tex >> python/trunk/Lib/test/test_functional.py >> python/trunk/Modules/functionalmodule.c >> Modified: >> python/trunk/Doc/Makefile.deps >> python/trunk/Doc/lib/lib.tex >> python/trunk/Misc/NEWS >> python/trunk/PC/VC6/pythoncore.dsp >> python/trunk/PC/config.c >> python/trunk/PCbuild/pythoncore.vcproj >> python/trunk/setup.py >> Log: >> Apply modified version of Collin Winter's patch #1478788 > > Isn't Lib/functools.py missing? Why yes, yes it is. . . the Windows buildbots staying green fooled me (we should probably do something about that misleading ImportError -> TestSkipped -> green buildbot behaviour. . . ) Fixed in 46530. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From python-checkins at python.org Mon May 29 22:52:54 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 22:52:54 +0200 (CEST) Subject: [Python-checkins] r46531 - in python/trunk: Doc/lib/liburllib2.tex Lib/test/test_urllib2.py Lib/urllib2.py Message-ID: <20060529205254.B0B4E1E400C@bag.python.org> Author: georg.brandl Date: Mon May 29 22:52:54 2006 New Revision: 46531 Modified: python/trunk/Doc/lib/liburllib2.tex python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/urllib2.py Log: Patches #1497027 and #972322: try HTTP digest auth first, and watch out for handler name collisions. Modified: python/trunk/Doc/lib/liburllib2.tex ============================================================================== --- python/trunk/Doc/lib/liburllib2.tex (original) +++ python/trunk/Doc/lib/liburllib2.tex Mon May 29 22:52:54 2006 @@ -65,9 +65,7 @@ Beginning in Python 2.3, a \class{BaseHandler} subclass may also change its \member{handler_order} member variable to modify its -position in the handlers list. Besides \class{ProxyHandler}, which has -\member{handler_order} of \code{100}, all handlers currently have it -set to \code{500}. +position in the handlers list. \end{funcdesc} Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Mon May 29 22:52:54 2006 @@ -318,6 +318,27 @@ class OpenerDirectorTests(unittest.TestCase): + def test_badly_named_methods(self): + # test work-around for three methods that accidentally follow the + # naming conventions for handler methods + # (*_open() / *_request() / *_response()) + + # These used to call the accidentally-named methods, causing a + # TypeError in real code; here, returning self from these mock + # methods would either cause no exception, or AttributeError. + + from urllib2 import URLError + + o = OpenerDirector() + meth_spec = [ + [("do_open", "return self"), ("proxy_open", "return self")], + [("redirect_request", "return self")], + ] + handlers = add_ordered_mock_handlers(o, meth_spec) + o.add_handler(urllib2.UnknownHandler()) + for scheme in "do", "proxy", "redirect": + self.assertRaises(URLError, o.open, scheme+"://example.com/") + def test_handled(self): # handler returning non-None means no more handlers will be called o = OpenerDirector() @@ -807,6 +828,8 @@ realm = "ACME Widget Store" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) + opener.add_handler(auth_handler) + opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", @@ -822,6 +845,8 @@ realm = "ACME Networks" http_handler = MockHTTPHandler( 407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm) + opener.add_handler(auth_handler) + opener.add_handler(http_handler) self._test_basic_auth(opener, auth_handler, "Proxy-authorization", realm, http_handler, password_manager, "http://acme.example.com:3128/protected", @@ -833,29 +858,53 @@ # response (http://python.org/sf/1479302), where it should instead # return None to allow another handler (especially # HTTPBasicAuthHandler) to handle the response. + + # Also (http://python.org/sf/14797027, RFC 2617 section 1.2), we must + # try digest first (since it's the strongest auth scheme), so we record + # order of calls here to check digest comes first: + class RecordingOpenerDirector(OpenerDirector): + def __init__(self): + OpenerDirector.__init__(self) + self.recorded = [] + def record(self, info): + self.recorded.append(info) class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler): - handler_order = 400 # strictly before HTTPBasicAuthHandler - opener = OpenerDirector() + def http_error_401(self, *args, **kwds): + self.parent.record("digest") + urllib2.HTTPDigestAuthHandler.http_error_401(self, + *args, **kwds) + class TestBasicAuthHandler(urllib2.HTTPBasicAuthHandler): + def http_error_401(self, *args, **kwds): + self.parent.record("basic") + urllib2.HTTPBasicAuthHandler.http_error_401(self, + *args, **kwds) + + opener = RecordingOpenerDirector() password_manager = MockPasswordManager() digest_handler = TestDigestAuthHandler(password_manager) - basic_handler = urllib2.HTTPBasicAuthHandler(password_manager) - opener.add_handler(digest_handler) + basic_handler = TestBasicAuthHandler(password_manager) realm = "ACME Networks" http_handler = MockHTTPHandler( 401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm) + opener.add_handler(basic_handler) + opener.add_handler(digest_handler) + opener.add_handler(http_handler) + + # check basic auth isn't blocked by digest handler failing self._test_basic_auth(opener, basic_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", "http://acme.example.com/protected", ) + # check digest was tried before basic (twice, because + # _test_basic_auth called .open() twice) + self.assertEqual(opener.recorded, ["digest", "basic"]*2) def _test_basic_auth(self, opener, auth_handler, auth_header, realm, http_handler, password_manager, request_url, protected_url): import base64, httplib user, password = "wile", "coyote" - opener.add_handler(auth_handler) - opener.add_handler(http_handler) # .add_password() fed through to password manager auth_handler.add_password(realm, request_url, user, password) Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Mon May 29 22:52:54 2006 @@ -297,6 +297,10 @@ def add_handler(self, handler): added = False for meth in dir(handler): + if meth in ["redirect_request", "do_open", "proxy_open"]: + # oops, coincidental match + continue + i = meth.find("_") protocol = meth[:i] condition = meth[i+1:] @@ -768,6 +772,10 @@ # www-authenticate header. should probably be a lot more careful # in parsing them to extract multiple alternatives + # XXX could pre-emptively send auth info already accepted (RFC 2617, + # end of section 2, and section 1.2 immediately after "credentials" + # production). + def __init__(self, password_mgr=None): if password_mgr is None: password_mgr = HTTPPasswordMgr() @@ -977,6 +985,7 @@ """ auth_header = 'Authorization' + handler_order = 490 # before Basic auth def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] @@ -989,6 +998,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): auth_header = 'Proxy-Authorization' + handler_order = 490 # before Basic auth def http_error_407(self, req, fp, code, msg, headers): host = req.get_host() From python-checkins at python.org Mon May 29 22:57:02 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 22:57:02 +0200 (CEST) Subject: [Python-checkins] r46532 - python/trunk/Misc/NEWS Message-ID: <20060529205702.06A081E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 22:57:01 2006 New Revision: 46532 Modified: python/trunk/Misc/NEWS Log: Add News entry for last commit. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon May 29 22:57:01 2006 @@ -91,6 +91,9 @@ Library ------- +- Patch #1497027: try HTTP digest auth before basic auth in urllib2 + (thanks for J. J. Lee). + - Patch #1496206: improve urllib2 handling of passwords with respect to default HTTP and HTTPS ports. From python-checkins at python.org Mon May 29 23:04:58 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 23:04:58 +0200 (CEST) Subject: [Python-checkins] r46533 - in python/trunk: Modules/_bsddb.c Modules/_codecsmodule.c Modules/_hashopenssl.c Modules/_hotshot.c Modules/_localemodule.c Modules/_sre.c Modules/cPickle.c Modules/cjkcodecs/multibytecodec.c Modules/dbmmodule.c Modules/gdbmmodule.c Modules/linuxaudiodev.c Modules/mmapmodule.c Modules/ossaudiodev.c Modules/posixmodule.c Modules/pyexpat.c Modules/resource.c Modules/selectmodule.c Modules/sha256module.c Modules/sha512module.c Modules/shamodule.c Modules/socketmodule.c Modules/syslogmodule.c Modules/threadmodule.c Modules/timemodule.c Objects/genobject.c Python/sysmodule.c Message-ID: <20060529210458.9D0B61E4005@bag.python.org> Author: georg.brandl Date: Mon May 29 23:04:52 2006 New Revision: 46533 Modified: python/trunk/Modules/_bsddb.c python/trunk/Modules/_codecsmodule.c python/trunk/Modules/_hashopenssl.c python/trunk/Modules/_hotshot.c python/trunk/Modules/_localemodule.c python/trunk/Modules/_sre.c python/trunk/Modules/cPickle.c python/trunk/Modules/cjkcodecs/multibytecodec.c python/trunk/Modules/dbmmodule.c python/trunk/Modules/gdbmmodule.c python/trunk/Modules/linuxaudiodev.c python/trunk/Modules/mmapmodule.c python/trunk/Modules/ossaudiodev.c python/trunk/Modules/posixmodule.c python/trunk/Modules/pyexpat.c python/trunk/Modules/resource.c python/trunk/Modules/selectmodule.c python/trunk/Modules/sha256module.c python/trunk/Modules/sha512module.c python/trunk/Modules/shamodule.c python/trunk/Modules/socketmodule.c python/trunk/Modules/syslogmodule.c python/trunk/Modules/threadmodule.c python/trunk/Modules/timemodule.c python/trunk/Objects/genobject.c python/trunk/Python/sysmodule.c Log: Make use of METH_O and METH_NOARGS where possible. Use Py_UnpackTuple instead of PyArg_ParseTuple where possible. Modified: python/trunk/Modules/_bsddb.c ============================================================================== --- python/trunk/Modules/_bsddb.c (original) +++ python/trunk/Modules/_bsddb.c Mon May 29 23:04:52 2006 @@ -1041,7 +1041,7 @@ DBT key, data; DB_TXN *txn = NULL; - if (!PyArg_ParseTuple(args, "O|O:append", &dataobj, &txnobj)) + if (!PyArg_UnpackTuple(args, "append", 1, 2, &dataobj, &txnobj)) return NULL; CHECK_DB_NOT_CLOSED(self); @@ -2895,7 +2895,7 @@ PyObject* txnobj = NULL; DB_TXN *txn = NULL; - if (!PyArg_ParseTuple(args,"|O:keys", &txnobj)) + if (!PyArg_UnpackTuple(args, "keys", 0, 1, &txnobj)) return NULL; if (!checkTxnObj(txnobj, &txn)) return NULL; @@ -2909,7 +2909,7 @@ PyObject* txnobj = NULL; DB_TXN *txn = NULL; - if (!PyArg_ParseTuple(args,"|O:items", &txnobj)) + if (!PyArg_UnpackTuple(args, "items", 0, 1, &txnobj)) return NULL; if (!checkTxnObj(txnobj, &txn)) return NULL; @@ -2923,7 +2923,7 @@ PyObject* txnobj = NULL; DB_TXN *txn = NULL; - if (!PyArg_ParseTuple(args,"|O:values", &txnobj)) + if (!PyArg_UnpackTuple(args, "values", 0, 1, &txnobj)) return NULL; if (!checkTxnObj(txnobj, &txn)) return NULL; Modified: python/trunk/Modules/_codecsmodule.c ============================================================================== --- python/trunk/Modules/_codecsmodule.c (original) +++ python/trunk/Modules/_codecsmodule.c Mon May 29 23:04:52 2006 @@ -48,21 +48,12 @@ a tuple of functions (encoder, decoder, stream_reader, stream_writer)."); static -PyObject *codec_register(PyObject *self, PyObject *args) +PyObject *codec_register(PyObject *self, PyObject *search_function) { - PyObject *search_function; - - if (!PyArg_ParseTuple(args, "O:register", &search_function)) - goto onError; - if (PyCodec_Register(search_function)) - goto onError; - - Py_INCREF(Py_None); - return Py_None; + return NULL; - onError: - return NULL; + Py_RETURN_NONE; } PyDoc_STRVAR(lookup__doc__, @@ -77,12 +68,9 @@ char *encoding; if (!PyArg_ParseTuple(args, "s:lookup", &encoding)) - goto onError; + return NULL; return _PyCodec_Lookup(encoding); - - onError: - return NULL; } PyDoc_STRVAR(encode__doc__, @@ -116,13 +104,7 @@ #endif /* Encode via the codec registry */ - v = PyCodec_Encode(v, encoding, errors); - if (v == NULL) - goto onError; - return v; - - onError: - return NULL; + return PyCodec_Encode(v, encoding, errors); } PyDoc_STRVAR(decode__doc__, @@ -156,13 +138,7 @@ #endif /* Decode via the codec registry */ - v = PyCodec_Decode(v, encoding, errors); - if (v == NULL) - goto onError; - return v; - - onError: - return NULL; + return PyCodec_Decode(v, encoding, errors); } /* --- Helpers ------------------------------------------------------------ */ @@ -171,22 +147,11 @@ PyObject *codec_tuple(PyObject *unicode, Py_ssize_t len) { - PyObject *v,*w; - + PyObject *v; if (unicode == NULL) - return NULL; - v = PyTuple_New(2); - if (v == NULL) { - Py_DECREF(unicode); - return NULL; - } - PyTuple_SET_ITEM(v,0,unicode); - w = PyInt_FromSsize_t(len); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyTuple_SET_ITEM(v,1,w); + return NULL; + v = Py_BuildValue("On", unicode, len); + Py_DECREF(unicode); return v; } @@ -419,7 +384,7 @@ final ? NULL : &consumed); if (unicode == NULL) return NULL; - tuple = Py_BuildValue("Oii", unicode, consumed, byteorder); + tuple = Py_BuildValue("Oni", unicode, consumed, byteorder); Py_DECREF(unicode); return tuple; } @@ -604,8 +569,8 @@ return NULL; v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), - 0, - 0, + 0, + 0, errors), PyUnicode_GET_SIZE(str)); Py_DECREF(str); @@ -876,8 +841,7 @@ return NULL; if (PyCodec_RegisterError(name, handler)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(lookup_error__doc__, @@ -899,7 +863,7 @@ /* --- Module API --------------------------------------------------------- */ static PyMethodDef _codecs_functions[] = { - {"register", codec_register, METH_VARARGS, + {"register", codec_register, METH_O, register__doc__}, {"lookup", codec_lookup, METH_VARARGS, lookup__doc__}, Modified: python/trunk/Modules/_hashopenssl.c ============================================================================== --- python/trunk/Modules/_hashopenssl.c (original) +++ python/trunk/Modules/_hashopenssl.c Mon May 29 23:04:52 2006 @@ -77,13 +77,10 @@ PyDoc_STRVAR(EVP_copy__doc__, "Return a copy of the hash object."); static PyObject * -EVP_copy(EVPobject *self, PyObject *args) +EVP_copy(EVPobject *self, PyObject *unused) { EVPobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) - return NULL; - if ( (newobj = newEVPobject(self->name))==NULL) return NULL; @@ -95,16 +92,13 @@ "Return the digest value as a string of binary data."); static PyObject * -EVP_digest(EVPobject *self, PyObject *args) +EVP_digest(EVPobject *self, PyObject *unused) { unsigned char digest[EVP_MAX_MD_SIZE]; EVP_MD_CTX temp_ctx; PyObject *retval; unsigned int digest_size; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - EVP_MD_CTX_copy(&temp_ctx, &self->ctx); digest_size = EVP_MD_CTX_size(&temp_ctx); EVP_DigestFinal(&temp_ctx, digest, NULL); @@ -118,7 +112,7 @@ "Return the digest value as a string of hexadecimal digits."); static PyObject * -EVP_hexdigest(EVPobject *self, PyObject *args) +EVP_hexdigest(EVPobject *self, PyObject *unused) { unsigned char digest[EVP_MAX_MD_SIZE]; EVP_MD_CTX temp_ctx; @@ -126,9 +120,6 @@ char *hex_digest; unsigned int i, j, digest_size; - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - /* Get the raw (binary) digest value */ EVP_MD_CTX_copy(&temp_ctx, &self->ctx); digest_size = EVP_MD_CTX_size(&temp_ctx); @@ -182,9 +173,9 @@ static PyMethodDef EVP_methods[] = { {"update", (PyCFunction)EVP_update, METH_VARARGS, EVP_update__doc__}, - {"digest", (PyCFunction)EVP_digest, METH_VARARGS, EVP_digest__doc__}, - {"hexdigest", (PyCFunction)EVP_hexdigest, METH_VARARGS, EVP_hexdigest__doc__}, - {"copy", (PyCFunction)EVP_copy, METH_VARARGS, EVP_copy__doc__}, + {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__}, + {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__}, + {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/_hotshot.c ============================================================================== --- python/trunk/Modules/_hotshot.c (original) +++ python/trunk/Modules/_hotshot.c Mon May 29 23:04:52 2006 @@ -1058,7 +1058,7 @@ PyObject *callkw = NULL; PyObject *callable; - if (PyArg_ParseTuple(args, "O|OO:runcall", + if (PyArg_UnpackTuple(args, "runcall", 1, 3, &callable, &callargs, &callkw)) { if (is_available(self)) { do_start(self); @@ -1575,23 +1575,18 @@ ; static PyObject * -hotshot_resolution(PyObject *unused, PyObject *args) +hotshot_resolution(PyObject *self, PyObject *unused) { - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, ":resolution")) { - if (timeofday_diff == 0) { - calibrate(); - calibrate(); - calibrate(); - } + if (timeofday_diff == 0) { + calibrate(); + calibrate(); + calibrate(); + } #ifdef MS_WINDOWS - result = Py_BuildValue("ii", timeofday_diff, frequency.LowPart); + return Py_BuildValue("ii", timeofday_diff, frequency.LowPart); #else - result = Py_BuildValue("ii", timeofday_diff, rusage_diff); + return Py_BuildValue("ii", timeofday_diff, rusage_diff); #endif - } - return result; } @@ -1599,7 +1594,7 @@ {"coverage", hotshot_coverage, METH_VARARGS, coverage__doc__}, {"profiler", hotshot_profiler, METH_VARARGS, profiler__doc__}, {"logreader", hotshot_logreader, METH_VARARGS, logreader__doc__}, - {"resolution", hotshot_resolution, METH_VARARGS, resolution__doc__}, + {"resolution", hotshot_resolution, METH_NOARGS, resolution__doc__}, {NULL, NULL} }; Modified: python/trunk/Modules/_localemodule.c ============================================================================== --- python/trunk/Modules/_localemodule.c (original) +++ python/trunk/Modules/_localemodule.c Mon May 29 23:04:52 2006 @@ -281,7 +281,7 @@ wchar_t *ws1 = NULL, *ws2 = NULL; int rel1 = 0, rel2 = 0, len1, len2; - if (!PyArg_ParseTuple(args, "OO:strcoll", &os1, &os2)) + if (!PyArg_UnpackTuple(args, "strcoll", 2, 2, &os1, &os2)) return NULL; /* If both arguments are byte strings, use strcoll. */ if (PyString_Check(os1) && PyString_Check(os2)) Modified: python/trunk/Modules/_sre.c ============================================================================== --- python/trunk/Modules/_sre.c (original) +++ python/trunk/Modules/_sre.c Mon May 29 23:04:52 2006 @@ -2891,7 +2891,7 @@ int index; PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:start", &index_)) + if (!PyArg_UnpackTuple(args, "start", 0, 1, &index_)) return NULL; index = match_getindex(self, index_); @@ -2914,7 +2914,7 @@ int index; PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:end", &index_)) + if (!PyArg_UnpackTuple(args, "end", 0, 1, &index_)) return NULL; index = match_getindex(self, index_); @@ -2964,7 +2964,7 @@ int index; PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:span", &index_)) + if (!PyArg_UnpackTuple(args, "span", 0, 1, &index_)) return NULL; index = match_getindex(self, index_); Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Mon May 29 23:04:52 2006 @@ -5110,29 +5110,23 @@ static PyObject * -Unpickler_load(Unpicklerobject *self, PyObject *args) +Unpickler_load(Unpicklerobject *self, PyObject *unused) { - if (!( PyArg_ParseTuple(args, ":load"))) - return NULL; - return load(self); } static PyObject * -Unpickler_noload(Unpicklerobject *self, PyObject *args) +Unpickler_noload(Unpicklerobject *self, PyObject *unused) { - if (!( PyArg_ParseTuple(args, ":noload"))) - return NULL; - return noload(self); } static struct PyMethodDef Unpickler_methods[] = { - {"load", (PyCFunction)Unpickler_load, METH_VARARGS, + {"load", (PyCFunction)Unpickler_load, METH_NOARGS, PyDoc_STR("load() -- Load a pickle") }, - {"noload", (PyCFunction)Unpickler_noload, METH_VARARGS, + {"noload", (PyCFunction)Unpickler_noload, METH_NOARGS, PyDoc_STR( "noload() -- not load a pickle, but go through most of the motions\n" "\n" @@ -5214,12 +5208,8 @@ static PyObject * -get_Unpickler(PyObject *self, PyObject *args) +get_Unpickler(PyObject *self, PyObject *file) { - PyObject *file; - - if (!( PyArg_ParseTuple(args, "O:Unpickler", &file))) - return NULL; return (PyObject *)newUnpicklerobject(file); } @@ -5428,13 +5418,10 @@ /* load(fileobj). */ static PyObject * -cpm_load(PyObject *self, PyObject *args) +cpm_load(PyObject *self, PyObject *ob) { Unpicklerobject *unpickler = 0; - PyObject *ob, *res = NULL; - - if (!( PyArg_ParseTuple(args, "O:load", &ob))) - goto finally; + PyObject *res = NULL; if (!( unpickler = newUnpicklerobject(ob))) goto finally; @@ -5519,7 +5506,7 @@ "See the Pickler docstring for the meaning of optional argument proto.") }, - {"load", (PyCFunction)cpm_load, METH_VARARGS, + {"load", (PyCFunction)cpm_load, METH_O, PyDoc_STR("load(file) -- Load a pickle from the given file")}, {"loads", (PyCFunction)cpm_loads, METH_VARARGS, @@ -5550,7 +5537,7 @@ "object, or any other custom object that meets this interface.\n") }, - {"Unpickler", (PyCFunction)get_Unpickler, METH_VARARGS, + {"Unpickler", (PyCFunction)get_Unpickler, METH_O, PyDoc_STR("Unpickler(file) -- Create an unpickler.")}, { NULL, NULL } Modified: python/trunk/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/trunk/Modules/cjkcodecs/multibytecodec.c (original) +++ python/trunk/Modules/cjkcodecs/multibytecodec.c Mon May 29 23:04:52 2006 @@ -1302,7 +1302,7 @@ PyObject *sizeobj = NULL; Py_ssize_t size; - if (!PyArg_ParseTuple(args, "|O:read", &sizeobj)) + if (!PyArg_UnpackTuple(args, "read", 0, 1, &sizeobj)) return NULL; if (sizeobj == Py_None || sizeobj == NULL) @@ -1323,7 +1323,7 @@ PyObject *sizeobj = NULL; Py_ssize_t size; - if (!PyArg_ParseTuple(args, "|O:readline", &sizeobj)) + if (!PyArg_UnpackTuple(args, "readline", 0, 1, &sizeobj)) return NULL; if (sizeobj == Py_None || sizeobj == NULL) @@ -1344,7 +1344,7 @@ PyObject *sizehintobj = NULL, *r, *sr; Py_ssize_t sizehint; - if (!PyArg_ParseTuple(args, "|O:readlines", &sizehintobj)) + if (!PyArg_UnpackTuple(args, "readlines", 0, 1, &sizehintobj)) return NULL; if (sizehintobj == Py_None || sizehintobj == NULL) @@ -1532,13 +1532,8 @@ } static PyObject * -mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *args) +mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *strobj) { - PyObject *strobj; - - if (!PyArg_ParseTuple(args, "O:write", &strobj)) - return NULL; - if (mbstreamwriter_iwrite(self, strobj)) return NULL; else @@ -1546,14 +1541,11 @@ } static PyObject * -mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *args) +mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *lines) { - PyObject *lines, *strobj; + PyObject *strobj; int i, r; - if (!PyArg_ParseTuple(args, "O:writelines", &lines)) - return NULL; - if (!PySequence_Check(lines)) { PyErr_SetString(PyExc_TypeError, "arg must be a sequence object"); @@ -1676,9 +1668,9 @@ static struct PyMethodDef mbstreamwriter_methods[] = { {"write", (PyCFunction)mbstreamwriter_write, - METH_VARARGS, NULL}, + METH_O, NULL}, {"writelines", (PyCFunction)mbstreamwriter_writelines, - METH_VARARGS, NULL}, + METH_O, NULL}, {"reset", (PyCFunction)mbstreamwriter_reset, METH_NOARGS, NULL}, {NULL, NULL}, Modified: python/trunk/Modules/dbmmodule.c ============================================================================== --- python/trunk/Modules/dbmmodule.c (original) +++ python/trunk/Modules/dbmmodule.c Mon May 29 23:04:52 2006 @@ -168,10 +168,8 @@ }; static PyObject * -dbm__close(register dbmobject *dp, PyObject *args) +dbm__close(register dbmobject *dp, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; if (dp->di_dbm) dbm_close(dp->di_dbm); dp->di_dbm = NULL; @@ -180,14 +178,12 @@ } static PyObject * -dbm_keys(register dbmobject *dp, PyObject *args) +dbm_keys(register dbmobject *dp, PyObject *unused) { register PyObject *v, *item; datum key; int err; - if (!PyArg_ParseTuple(args, ":keys")) - return NULL; check_dbmobject_open(dp); v = PyList_New(0); if (v == NULL) @@ -277,9 +273,9 @@ } static PyMethodDef dbm_methods[] = { - {"close", (PyCFunction)dbm__close, METH_VARARGS, + {"close", (PyCFunction)dbm__close, METH_NOARGS, "close()\nClose the database."}, - {"keys", (PyCFunction)dbm_keys, METH_VARARGS, + {"keys", (PyCFunction)dbm_keys, METH_NOARGS, "keys() -> list\nReturn a list of all keys in the database."}, {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, "has_key(key} -> boolean\nReturn true iff key is in the database."}, Modified: python/trunk/Modules/gdbmmodule.c ============================================================================== --- python/trunk/Modules/gdbmmodule.c (original) +++ python/trunk/Modules/gdbmmodule.c Mon May 29 23:04:52 2006 @@ -189,10 +189,8 @@ Closes the database."); static PyObject * -dbm_close(register dbmobject *dp, PyObject *args) +dbm_close(register dbmobject *dp, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; if (dp->di_dbm) gdbm_close(dp->di_dbm); dp->di_dbm = NULL; @@ -205,7 +203,7 @@ Get a list of all keys in the database."); static PyObject * -dbm_keys(register dbmobject *dp, PyObject *args) +dbm_keys(register dbmobject *dp, PyObject *unused) { register PyObject *v, *item; datum key, nextkey; @@ -215,9 +213,6 @@ PyErr_BadInternalCall(); return NULL; } - if (!PyArg_ParseTuple(args, ":keys")) - return NULL; - check_dbmobject_open(dp); v = PyList_New(0); @@ -269,13 +264,11 @@ returns the starting key."); static PyObject * -dbm_firstkey(register dbmobject *dp, PyObject *args) +dbm_firstkey(register dbmobject *dp, PyObject *unused) { register PyObject *v; datum key; - if (!PyArg_ParseTuple(args, ":firstkey")) - return NULL; check_dbmobject_open(dp); key = gdbm_firstkey(dp->di_dbm); if (key.dptr) { @@ -330,10 +323,8 @@ kept and reused as new (key,value) pairs are added."); static PyObject * -dbm_reorganize(register dbmobject *dp, PyObject *args) +dbm_reorganize(register dbmobject *dp, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":reorganize")) - return NULL; check_dbmobject_open(dp); errno = 0; if (gdbm_reorganize(dp->di_dbm) < 0) { @@ -353,10 +344,8 @@ any unwritten data to be written to the disk."); static PyObject * -dbm_sync(register dbmobject *dp, PyObject *args) +dbm_sync(register dbmobject *dp, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":sync")) - return NULL; check_dbmobject_open(dp); gdbm_sync(dp->di_dbm); Py_INCREF(Py_None); @@ -364,13 +353,13 @@ } static PyMethodDef dbm_methods[] = { - {"close", (PyCFunction)dbm_close, METH_VARARGS, dbm_close__doc__}, - {"keys", (PyCFunction)dbm_keys, METH_VARARGS, dbm_keys__doc__}, + {"close", (PyCFunction)dbm_close, METH_NOARGS, dbm_close__doc__}, + {"keys", (PyCFunction)dbm_keys, METH_NOARGS, dbm_keys__doc__}, {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, dbm_has_key__doc__}, - {"firstkey", (PyCFunction)dbm_firstkey,METH_VARARGS, dbm_firstkey__doc__}, + {"firstkey", (PyCFunction)dbm_firstkey,METH_NOARGS, dbm_firstkey__doc__}, {"nextkey", (PyCFunction)dbm_nextkey, METH_VARARGS, dbm_nextkey__doc__}, - {"reorganize",(PyCFunction)dbm_reorganize,METH_VARARGS, dbm_reorganize__doc__}, - {"sync", (PyCFunction)dbm_sync, METH_VARARGS, dbm_sync__doc__}, + {"reorganize",(PyCFunction)dbm_reorganize,METH_NOARGS, dbm_reorganize__doc__}, + {"sync", (PyCFunction)dbm_sync, METH_NOARGS, dbm_sync__doc__}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/linuxaudiodev.c ============================================================================== --- python/trunk/Modules/linuxaudiodev.c (original) +++ python/trunk/Modules/linuxaudiodev.c Mon May 29 23:04:52 2006 @@ -219,24 +219,18 @@ } static PyObject * -lad_close(lad_t *self, PyObject *args) +lad_close(lad_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (self->x_fd >= 0) { close(self->x_fd); self->x_fd = -1; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * -lad_fileno(lad_t *self, PyObject *args) +lad_fileno(lad_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; return PyInt_FromLong(self->x_fd); } @@ -341,13 +335,11 @@ /* bufsize returns the size of the hardware audio buffer in number of samples */ static PyObject * -lad_bufsize(lad_t *self, PyObject *args) +lad_bufsize(lad_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { PyErr_SetFromErrno(LinuxAudioError); return NULL; @@ -362,14 +354,11 @@ /* obufcount returns the number of samples that are available in the hardware for playing */ static PyObject * -lad_obufcount(lad_t *self, PyObject *args) +lad_obufcount(lad_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":obufcount")) - return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { PyErr_SetFromErrno(LinuxAudioError); return NULL; @@ -385,14 +374,11 @@ /* obufcount returns the number of samples that can be played without blocking */ static PyObject * -lad_obuffree(lad_t *self, PyObject *args) +lad_obuffree(lad_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":obuffree")) - return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { PyErr_SetFromErrno(LinuxAudioError); return NULL; @@ -406,27 +392,21 @@ /* Flush the device */ static PyObject * -lad_flush(lad_t *self, PyObject *args) +lad_flush(lad_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":flush")) return NULL; - if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) { PyErr_SetFromErrno(LinuxAudioError); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * -lad_getptr(lad_t *self, PyObject *args) +lad_getptr(lad_t *self, PyObject *unused) { count_info info; int req; - if (!PyArg_ParseTuple(args, ":getptr")) - return NULL; - if (self->x_mode == O_RDONLY) req = SNDCTL_DSP_GETIPTR; else @@ -443,12 +423,12 @@ { "write", (PyCFunction)lad_write, METH_VARARGS }, { "setparameters", (PyCFunction)lad_setparameters, METH_VARARGS }, { "bufsize", (PyCFunction)lad_bufsize, METH_VARARGS }, - { "obufcount", (PyCFunction)lad_obufcount, METH_VARARGS }, - { "obuffree", (PyCFunction)lad_obuffree, METH_VARARGS }, - { "flush", (PyCFunction)lad_flush, METH_VARARGS }, - { "close", (PyCFunction)lad_close, METH_VARARGS }, - { "fileno", (PyCFunction)lad_fileno, METH_VARARGS }, - { "getptr", (PyCFunction)lad_getptr, METH_VARARGS }, + { "obufcount", (PyCFunction)lad_obufcount, METH_NOARGS }, + { "obuffree", (PyCFunction)lad_obuffree, METH_NOARGS }, + { "flush", (PyCFunction)lad_flush, METH_NOARGS }, + { "close", (PyCFunction)lad_close, METH_NOARGS }, + { "fileno", (PyCFunction)lad_fileno, METH_NOARGS }, + { "getptr", (PyCFunction)lad_getptr, METH_NOARGS }, { NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/mmapmodule.c ============================================================================== --- python/trunk/Modules/mmapmodule.c (original) +++ python/trunk/Modules/mmapmodule.c Mon May 29 23:04:52 2006 @@ -114,10 +114,8 @@ } static PyObject * -mmap_close_method(mmap_object *self, PyObject *args) +mmap_close_method(mmap_object *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; #ifdef MS_WINDOWS /* For each resource we maintain, we need to check the value is valid, and if so, free the resource @@ -175,11 +173,9 @@ static PyObject * mmap_read_byte_method(mmap_object *self, - PyObject *args) + PyObject *unused) { CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":read_byte")) - return NULL; if (self->pos < self->size) { char value = self->data[self->pos]; self->pos += 1; @@ -192,7 +188,7 @@ static PyObject * mmap_read_line_method(mmap_object *self, - PyObject *args) + PyObject *unused) { char *start = self->data+self->pos; char *eof = self->data+self->size; @@ -200,8 +196,6 @@ PyObject *result; CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":readline")) - return NULL; eol = memchr(start, '\n', self->size - self->pos); if (!eol) @@ -332,11 +326,9 @@ static PyObject * mmap_size_method(mmap_object *self, - PyObject *args) + PyObject *unused) { CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":size")) - return NULL; #ifdef MS_WINDOWS if (self->file_handle != INVALID_HANDLE_VALUE) { @@ -472,11 +464,9 @@ } static PyObject * -mmap_tell_method(mmap_object *self, PyObject *args) +mmap_tell_method(mmap_object *self, PyObject *unused) { CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":tell")) - return NULL; return PyInt_FromLong((long) self->pos); } @@ -578,17 +568,17 @@ } static struct PyMethodDef mmap_object_methods[] = { - {"close", (PyCFunction) mmap_close_method, METH_VARARGS}, + {"close", (PyCFunction) mmap_close_method, METH_NOARGS}, {"find", (PyCFunction) mmap_find_method, METH_VARARGS}, {"flush", (PyCFunction) mmap_flush_method, METH_VARARGS}, {"move", (PyCFunction) mmap_move_method, METH_VARARGS}, {"read", (PyCFunction) mmap_read_method, METH_VARARGS}, - {"read_byte", (PyCFunction) mmap_read_byte_method, METH_VARARGS}, - {"readline", (PyCFunction) mmap_read_line_method, METH_VARARGS}, + {"read_byte", (PyCFunction) mmap_read_byte_method, METH_NOARGS}, + {"readline", (PyCFunction) mmap_read_line_method, METH_NOARGS}, {"resize", (PyCFunction) mmap_resize_method, METH_VARARGS}, {"seek", (PyCFunction) mmap_seek_method, METH_VARARGS}, - {"size", (PyCFunction) mmap_size_method, METH_VARARGS}, - {"tell", (PyCFunction) mmap_tell_method, METH_VARARGS}, + {"size", (PyCFunction) mmap_size_method, METH_NOARGS}, + {"tell", (PyCFunction) mmap_tell_method, METH_NOARGS}, {"write", (PyCFunction) mmap_write_method, METH_VARARGS}, {"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS}, {NULL, NULL} /* sentinel */ Modified: python/trunk/Modules/ossaudiodev.c ============================================================================== --- python/trunk/Modules/ossaudiodev.c (original) +++ python/trunk/Modules/ossaudiodev.c Mon May 29 23:04:52 2006 @@ -296,12 +296,10 @@ */ static PyObject * -oss_nonblock(oss_audio_t *self, PyObject *args) +oss_nonblock(oss_audio_t *self, PyObject *unused) { /* Hmmm: it doesn't appear to be possible to return to blocking mode once we're in non-blocking mode! */ - if (!PyArg_ParseTuple(args, ":nonblock")) - return NULL; if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) return PyErr_SetFromErrno(PyExc_IOError); Py_INCREF(Py_None); @@ -315,11 +313,9 @@ } static PyObject * -oss_getfmts(oss_audio_t *self, PyObject *args) +oss_getfmts(oss_audio_t *self, PyObject *unused) { int mask; - if (!PyArg_ParseTuple(args, ":getfmts")) - return NULL; if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1) return PyErr_SetFromErrno(PyExc_IOError); return PyInt_FromLong(mask); @@ -459,11 +455,8 @@ } static PyObject * -oss_close(oss_audio_t *self, PyObject *args) +oss_close(oss_audio_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (self->fd >= 0) { Py_BEGIN_ALLOW_THREADS close(self->fd); @@ -475,10 +468,8 @@ } static PyObject * -oss_fileno(oss_audio_t *self, PyObject *args) +oss_fileno(oss_audio_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; return PyInt_FromLong(self->fd); } @@ -578,13 +569,11 @@ /* bufsize returns the size of the hardware audio buffer in number of samples */ static PyObject * -oss_bufsize(oss_audio_t *self, PyObject *args) +oss_bufsize(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; @@ -599,14 +588,11 @@ /* obufcount returns the number of samples that are available in the hardware for playing */ static PyObject * -oss_obufcount(oss_audio_t *self, PyObject *args) +oss_obufcount(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":obufcount")) - return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; @@ -622,14 +608,11 @@ /* obufcount returns the number of samples that can be played without blocking */ static PyObject * -oss_obuffree(oss_audio_t *self, PyObject *args) +oss_obuffree(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; - if (!PyArg_ParseTuple(args, ":obuffree")) - return NULL; - if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; @@ -642,14 +625,11 @@ } static PyObject * -oss_getptr(oss_audio_t *self, PyObject *args) +oss_getptr(oss_audio_t *self, PyObject *unused) { count_info info; int req; - if (!PyArg_ParseTuple(args, ":getptr")) - return NULL; - if (self->mode == O_RDONLY) req = SNDCTL_DSP_GETIPTR; else @@ -667,11 +647,8 @@ */ static PyObject * -oss_mixer_close(oss_mixer_t *self, PyObject *args) +oss_mixer_close(oss_mixer_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (self->fd >= 0) { close(self->fd); self->fd = -1; @@ -681,10 +658,8 @@ } static PyObject * -oss_mixer_fileno(oss_mixer_t *self, PyObject *args) +oss_mixer_fileno(oss_mixer_t *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; return PyInt_FromLong(self->fd); } @@ -782,13 +757,13 @@ { "read", (PyCFunction)oss_read, METH_VARARGS }, { "write", (PyCFunction)oss_write, METH_VARARGS }, { "writeall", (PyCFunction)oss_writeall, METH_VARARGS }, - { "close", (PyCFunction)oss_close, METH_VARARGS }, - { "fileno", (PyCFunction)oss_fileno, METH_VARARGS }, + { "close", (PyCFunction)oss_close, METH_NOARGS }, + { "fileno", (PyCFunction)oss_fileno, METH_NOARGS }, /* Simple ioctl wrappers */ - { "nonblock", (PyCFunction)oss_nonblock, METH_VARARGS }, + { "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS }, { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS }, - { "getfmts", (PyCFunction)oss_getfmts, METH_VARARGS }, + { "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS }, { "channels", (PyCFunction)oss_channels, METH_VARARGS }, { "speed", (PyCFunction)oss_speed, METH_VARARGS }, { "sync", (PyCFunction)oss_sync, METH_VARARGS }, @@ -797,10 +772,10 @@ /* Convenience methods -- wrap a couple of ioctls together */ { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS }, - { "bufsize", (PyCFunction)oss_bufsize, METH_VARARGS }, - { "obufcount", (PyCFunction)oss_obufcount, METH_VARARGS }, - { "obuffree", (PyCFunction)oss_obuffree, METH_VARARGS }, - { "getptr", (PyCFunction)oss_getptr, METH_VARARGS }, + { "bufsize", (PyCFunction)oss_bufsize, METH_NOARGS }, + { "obufcount", (PyCFunction)oss_obufcount, METH_NOARGS }, + { "obuffree", (PyCFunction)oss_obuffree, METH_NOARGS }, + { "getptr", (PyCFunction)oss_getptr, METH_NOARGS }, /* Aliases for backwards compatibility */ { "flush", (PyCFunction)oss_sync, METH_VARARGS }, @@ -810,8 +785,8 @@ static PyMethodDef oss_mixer_methods[] = { /* Regular file method - OSS mixers are ioctl-only interface */ - { "close", (PyCFunction)oss_mixer_close, METH_VARARGS }, - { "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS }, + { "close", (PyCFunction)oss_mixer_close, METH_NOARGS }, + { "fileno", (PyCFunction)oss_mixer_fileno, METH_NOARGS }, /* Simple ioctl wrappers */ { "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS }, Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Mon May 29 23:04:52 2006 @@ -5282,14 +5282,11 @@ Set the groups of the current process to list."); static PyObject * -posix_setgroups(PyObject *self, PyObject *args) +posix_setgroups(PyObject *self, PyObject *groups) { - PyObject *groups; int i, len; gid_t grouplist[MAX_GROUPS]; - if (!PyArg_ParseTuple(args, "O:setgid", &groups)) - return NULL; if (!PySequence_Check(groups)) { PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence"); return NULL; @@ -8020,7 +8017,7 @@ {"setgid", posix_setgid, METH_VARARGS, posix_setgid__doc__}, #endif /* HAVE_SETGID */ #ifdef HAVE_SETGROUPS - {"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__}, + {"setgroups", posix_setgroups, METH_O, posix_setgroups__doc__}, #endif /* HAVE_SETGROUPS */ #ifdef HAVE_GETPGID {"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__}, Modified: python/trunk/Modules/pyexpat.c ============================================================================== --- python/trunk/Modules/pyexpat.c (original) +++ python/trunk/Modules/pyexpat.c Mon May 29 23:04:52 2006 @@ -981,16 +981,12 @@ Parse XML data from file-like object."); static PyObject * -xmlparse_ParseFile(xmlparseobject *self, PyObject *args) +xmlparse_ParseFile(xmlparseobject *self, PyObject *f) { int rv = 1; - PyObject *f; FILE *fp; PyObject *readmethod = NULL; - if (!PyArg_ParseTuple(args, "O:ParseFile", &f)) - return NULL; - if (PyFile_Check(f)) { fp = PyFile_AsFile(f); } @@ -1062,11 +1058,8 @@ Return base URL string for the parser."); static PyObject * -xmlparse_GetBase(xmlparseobject *self, PyObject *args) +xmlparse_GetBase(xmlparseobject *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":GetBase")) - return NULL; - return Py_BuildValue("z", XML_GetBase(self->itself)); } @@ -1077,29 +1070,21 @@ for an element with many attributes), not all of the text may be available."); static PyObject * -xmlparse_GetInputContext(xmlparseobject *self, PyObject *args) +xmlparse_GetInputContext(xmlparseobject *self, PyObject *unused) { - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, ":GetInputContext")) { - if (self->in_callback) { - int offset, size; - const char *buffer - = XML_GetInputContext(self->itself, &offset, &size); - - if (buffer != NULL) - result = PyString_FromStringAndSize(buffer + offset, size - offset); - else { - result = Py_None; - Py_INCREF(result); - } - } - else { - result = Py_None; - Py_INCREF(result); - } + if (self->in_callback) { + int offset, size; + const char *buffer + = XML_GetInputContext(self->itself, &offset, &size); + + if (buffer != NULL) + return PyString_FromStringAndSize(buffer + offset, + size - offset); + else + Py_RETURN_NONE; } - return result; + else + Py_RETURN_NONE; } PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__, @@ -1228,7 +1213,7 @@ PyObject *flagobj = NULL; XML_Bool flag = XML_TRUE; enum XML_Error rc; - if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj)) + if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj)) return NULL; if (flagobj != NULL) flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE; @@ -1245,17 +1230,17 @@ {"Parse", (PyCFunction)xmlparse_Parse, METH_VARARGS, xmlparse_Parse__doc__}, {"ParseFile", (PyCFunction)xmlparse_ParseFile, - METH_VARARGS, xmlparse_ParseFile__doc__}, + METH_O, xmlparse_ParseFile__doc__}, {"SetBase", (PyCFunction)xmlparse_SetBase, METH_VARARGS, xmlparse_SetBase__doc__}, {"GetBase", (PyCFunction)xmlparse_GetBase, - METH_VARARGS, xmlparse_GetBase__doc__}, + METH_NOARGS, xmlparse_GetBase__doc__}, {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate, METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__}, {"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing, METH_VARARGS, xmlparse_SetParamEntityParsing__doc__}, {"GetInputContext", (PyCFunction)xmlparse_GetInputContext, - METH_VARARGS, xmlparse_GetInputContext__doc__}, + METH_NOARGS, xmlparse_GetInputContext__doc__}, #if XML_COMBINED_VERSION >= 19505 {"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD, METH_VARARGS, xmlparse_UseForeignDTD__doc__}, Modified: python/trunk/Modules/resource.c ============================================================================== --- python/trunk/Modules/resource.c (original) +++ python/trunk/Modules/resource.c Mon May 29 23:04:52 2006 @@ -194,12 +194,9 @@ } static PyObject * -resource_getpagesize(PyObject *self, PyObject *args) +resource_getpagesize(PyObject *self, PyObject *unused) { long pagesize = 0; - if (!PyArg_ParseTuple(args, ":getpagesize")) - return NULL; - #if defined(HAVE_GETPAGESIZE) pagesize = getpagesize(); #elif defined(HAVE_SYSCONF) @@ -221,7 +218,7 @@ {"getrusage", resource_getrusage, METH_VARARGS}, {"getrlimit", resource_getrlimit, METH_VARARGS}, {"setrlimit", resource_setrlimit, METH_VARARGS}, - {"getpagesize", resource_getpagesize, METH_VARARGS}, + {"getpagesize", resource_getpagesize, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/selectmodule.c ============================================================================== --- python/trunk/Modules/selectmodule.c (original) +++ python/trunk/Modules/selectmodule.c Mon May 29 23:04:52 2006 @@ -218,7 +218,7 @@ int n; /* convert arguments */ - if (!PyArg_ParseTuple(args, "OOO|O:select", + if (!PyArg_UnpackTuple(args, "select", 3, 4, &ifdlist, &ofdlist, &efdlist, &tout)) return NULL; @@ -415,15 +415,11 @@ Remove a file descriptor being tracked by the polling object."); static PyObject * -poll_unregister(pollObject *self, PyObject *args) +poll_unregister(pollObject *self, PyObject *o) { - PyObject *o, *key; + PyObject *key; int fd; - if (!PyArg_ParseTuple(args, "O:unregister", &o)) { - return NULL; - } - fd = PyObject_AsFileDescriptor( o ); if (fd == -1) return NULL; @@ -459,7 +455,7 @@ int timeout = 0, poll_result, i, j; PyObject *value = NULL, *num = NULL; - if (!PyArg_ParseTuple(args, "|O:poll", &tout)) { + if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) { return NULL; } @@ -548,7 +544,7 @@ {"register", (PyCFunction)poll_register, METH_VARARGS, poll_register_doc}, {"unregister", (PyCFunction)poll_unregister, - METH_VARARGS, poll_unregister_doc}, + METH_O, poll_unregister_doc}, {"poll", (PyCFunction)poll_poll, METH_VARARGS, poll_poll_doc}, {NULL, NULL} /* sentinel */ @@ -614,16 +610,9 @@ unregistering file descriptors, and then polling them for I/O events."); static PyObject * -select_poll(PyObject *self, PyObject *args) +select_poll(PyObject *self, PyObject *unused) { - pollObject *rv; - - if (!PyArg_ParseTuple(args, ":poll")) - return NULL; - rv = newPollObject(); - if ( rv == NULL ) - return NULL; - return (PyObject *)rv; + return (PyObject *)newPollObject(); } #ifdef __APPLE__ @@ -684,7 +673,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, #if defined(HAVE_POLL) - {"poll", select_poll, METH_VARARGS, poll_doc}, + {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ {0, 0}, /* sentinel */ }; Modified: python/trunk/Modules/sha256module.c ============================================================================== --- python/trunk/Modules/sha256module.c (original) +++ python/trunk/Modules/sha256module.c Mon May 29 23:04:52 2006 @@ -405,14 +405,10 @@ PyDoc_STRVAR(SHA256_copy__doc__, "Return a copy of the hash object."); static PyObject * -SHA256_copy(SHAobject *self, PyObject *args) +SHA256_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } - if (((PyObject*)self)->ob_type == &SHA256type) { if ( (newobj = newSHA256object())==NULL) return NULL; @@ -429,14 +425,11 @@ "Return the digest value as a string of binary data."); static PyObject * -SHA256_digest(SHAobject *self, PyObject *args) +SHA256_digest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - SHAcopy(self, &temp); sha_final(digest, &temp); return PyString_FromStringAndSize((const char *)digest, self->digestsize); @@ -446,7 +439,7 @@ "Return the digest value as a string of hexadecimal digits."); static PyObject * -SHA256_hexdigest(SHAobject *self, PyObject *args) +SHA256_hexdigest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -454,9 +447,6 @@ char *hex_digest; int i, j; - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - /* Get the raw (binary) digest value */ SHAcopy(self, &temp); sha_final(digest, &temp); @@ -503,9 +493,9 @@ } static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA256_copy, METH_VARARGS, SHA256_copy__doc__}, - {"digest", (PyCFunction)SHA256_digest, METH_VARARGS, SHA256_digest__doc__}, - {"hexdigest", (PyCFunction)SHA256_hexdigest, METH_VARARGS, SHA256_hexdigest__doc__}, + {"copy", (PyCFunction)SHA256_copy, METH_NOARGS, SHA256_copy__doc__}, + {"digest", (PyCFunction)SHA256_digest, METH_NOARGS, SHA256_digest__doc__}, + {"hexdigest", (PyCFunction)SHA256_hexdigest, METH_NOARGS, SHA256_hexdigest__doc__}, {"update", (PyCFunction)SHA256_update, METH_VARARGS, SHA256_update__doc__}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/sha512module.c ============================================================================== --- python/trunk/Modules/sha512module.c (original) +++ python/trunk/Modules/sha512module.c Mon May 29 23:04:52 2006 @@ -471,14 +471,10 @@ PyDoc_STRVAR(SHA512_copy__doc__, "Return a copy of the hash object."); static PyObject * -SHA512_copy(SHAobject *self, PyObject *args) +SHA512_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } - if (((PyObject*)self)->ob_type == &SHA512type) { if ( (newobj = newSHA512object())==NULL) return NULL; @@ -495,14 +491,11 @@ "Return the digest value as a string of binary data."); static PyObject * -SHA512_digest(SHAobject *self, PyObject *args) +SHA512_digest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - SHAcopy(self, &temp); sha512_final(digest, &temp); return PyString_FromStringAndSize((const char *)digest, self->digestsize); @@ -512,7 +505,7 @@ "Return the digest value as a string of hexadecimal digits."); static PyObject * -SHA512_hexdigest(SHAobject *self, PyObject *args) +SHA512_hexdigest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -520,9 +513,6 @@ char *hex_digest; int i, j; - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - /* Get the raw (binary) digest value */ SHAcopy(self, &temp); sha512_final(digest, &temp); @@ -538,7 +528,7 @@ } /* Make hex version of the digest */ - for(i=j=0; idigestsize; i++) { + for (i=j=0; idigestsize; i++) { char c; c = (digest[i] >> 4) & 0xf; c = (c>9) ? c+'a'-10 : c + '0'; @@ -569,9 +559,9 @@ } static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA512_copy, METH_VARARGS, SHA512_copy__doc__}, - {"digest", (PyCFunction)SHA512_digest, METH_VARARGS, SHA512_digest__doc__}, - {"hexdigest", (PyCFunction)SHA512_hexdigest, METH_VARARGS, SHA512_hexdigest__doc__}, + {"copy", (PyCFunction)SHA512_copy, METH_NOARGS, SHA512_copy__doc__}, + {"digest", (PyCFunction)SHA512_digest, METH_NOARGS, SHA512_digest__doc__}, + {"hexdigest", (PyCFunction)SHA512_hexdigest, METH_NOARGS, SHA512_hexdigest__doc__}, {"update", (PyCFunction)SHA512_update, METH_VARARGS, SHA512_update__doc__}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/shamodule.c ============================================================================== --- python/trunk/Modules/shamodule.c (original) +++ python/trunk/Modules/shamodule.c Mon May 29 23:04:52 2006 @@ -358,13 +358,10 @@ PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); static PyObject * -SHA_copy(SHAobject *self, PyObject *args) +SHA_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } if ( (newobj = newSHAobject())==NULL) return NULL; @@ -376,14 +373,11 @@ "Return the digest value as a string of binary data."); static PyObject * -SHA_digest(SHAobject *self, PyObject *args) +SHA_digest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - SHAcopy(self, &temp); sha_final(digest, &temp); return PyString_FromStringAndSize((const char *)digest, sizeof(digest)); @@ -393,7 +387,7 @@ "Return the digest value as a string of hexadecimal digits."); static PyObject * -SHA_hexdigest(SHAobject *self, PyObject *args) +SHA_hexdigest(SHAobject *self, PyObject *unused) { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -401,9 +395,6 @@ char *hex_digest; int i, j; - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - /* Get the raw (binary) digest value */ SHAcopy(self, &temp); sha_final(digest, &temp); @@ -450,9 +441,9 @@ } static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA_copy, METH_VARARGS, SHA_copy__doc__}, - {"digest", (PyCFunction)SHA_digest, METH_VARARGS, SHA_digest__doc__}, - {"hexdigest", (PyCFunction)SHA_hexdigest, METH_VARARGS, SHA_hexdigest__doc__}, + {"copy", (PyCFunction)SHA_copy, METH_NOARGS, SHA_copy__doc__}, + {"digest", (PyCFunction)SHA_digest, METH_NOARGS, SHA_digest__doc__}, + {"hexdigest", (PyCFunction)SHA_hexdigest, METH_NOARGS, SHA_hexdigest__doc__}, {"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Mon May 29 23:04:52 2006 @@ -2889,12 +2889,10 @@ /*ARGSUSED*/ static PyObject * -socket_gethostname(PyObject *self, PyObject *args) +socket_gethostname(PyObject *self, PyObject *unused) { char buf[1024]; int res; - if (!PyArg_ParseTuple(args, ":gethostname")) - return NULL; Py_BEGIN_ALLOW_THREADS res = gethostname(buf, (int) sizeof buf - 1); Py_END_ALLOW_THREADS @@ -3986,13 +3984,13 @@ {"gethostbyaddr", socket_gethostbyaddr, METH_VARARGS, gethostbyaddr_doc}, {"gethostname", socket_gethostname, - METH_VARARGS, gethostname_doc}, + METH_NOARGS, gethostname_doc}, {"getservbyname", socket_getservbyname, METH_VARARGS, getservbyname_doc}, {"getservbyport", socket_getservbyport, METH_VARARGS, getservbyport_doc}, {"getprotobyname", socket_getprotobyname, - METH_VARARGS,getprotobyname_doc}, + METH_VARARGS, getprotobyname_doc}, #ifndef NO_DUP {"fromfd", socket_fromfd, METH_VARARGS, fromfd_doc}, Modified: python/trunk/Modules/syslogmodule.c ============================================================================== --- python/trunk/Modules/syslogmodule.c (original) +++ python/trunk/Modules/syslogmodule.c Mon May 29 23:04:52 2006 @@ -98,10 +98,8 @@ } static PyObject * -syslog_closelog(PyObject *self, PyObject *args) +syslog_closelog(PyObject *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":closelog")) - return NULL; closelog(); Py_XDECREF(S_ident_o); S_ident_o = NULL; @@ -146,7 +144,7 @@ static PyMethodDef syslog_methods[] = { {"openlog", syslog_openlog, METH_VARARGS}, - {"closelog", syslog_closelog, METH_VARARGS}, + {"closelog", syslog_closelog, METH_NOARGS}, {"syslog", syslog_syslog, METH_VARARGS}, {"setlogmask", syslog_setlogmask, METH_VARARGS}, {"LOG_MASK", syslog_log_mask, METH_VARARGS}, Modified: python/trunk/Modules/threadmodule.c ============================================================================== --- python/trunk/Modules/threadmodule.c (original) +++ python/trunk/Modules/threadmodule.c Mon May 29 23:04:52 2006 @@ -456,7 +456,8 @@ struct bootstate *boot; long ident; - if (!PyArg_ParseTuple(fargs, "OO|O:start_new_thread", &func, &args, &keyw)) + if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3, + &func, &args, &keyw)) return NULL; if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, Modified: python/trunk/Modules/timemodule.c ============================================================================== --- python/trunk/Modules/timemodule.c (original) +++ python/trunk/Modules/timemodule.c Mon May 29 23:04:52 2006 @@ -123,11 +123,9 @@ } static PyObject * -time_time(PyObject *self, PyObject *args) +time_time(PyObject *self, PyObject *unused) { double secs; - if (!PyArg_ParseTuple(args, ":time")) - return NULL; secs = floattime(); if (secs == 0.0) { PyErr_SetFromErrno(PyExc_IOError); @@ -153,10 +151,8 @@ #endif static PyObject * -time_clock(PyObject *self, PyObject *args) +time_clock(PyObject *self, PyObject *unused) { - if (!PyArg_ParseTuple(args, ":clock")) - return NULL; return PyFloat_FromDouble(((double)clock()) / CLOCKS_PER_SEC); } #endif /* HAVE_CLOCK */ @@ -164,16 +160,13 @@ #if defined(MS_WINDOWS) && !defined(__BORLANDC__) /* Due to Mark Hammond and Tim Peters */ static PyObject * -time_clock(PyObject *self, PyObject *args) +time_clock(PyObject *self, PyObject *unused) { static LARGE_INTEGER ctrStart; static double divisor = 0.0; LARGE_INTEGER now; double diff; - if (!PyArg_ParseTuple(args, ":clock")) - return NULL; - if (divisor == 0.0) { LARGE_INTEGER freq; QueryPerformanceCounter(&ctrStart); @@ -509,7 +502,7 @@ PyObject *tup = NULL; struct tm buf; char *p; - if (!PyArg_ParseTuple(args, "|O:asctime", &tup)) + if (!PyArg_UnpackTuple(args, "asctime", 0, 1, &tup)) return NULL; if (tup == NULL) { time_t tt = time(NULL); @@ -536,7 +529,7 @@ time_t tt; char *p; - if (!PyArg_ParseTuple(args, "|O:ctime", &ot)) + if (!PyArg_UnpackTuple(args, "ctime", 0, 1, &ot)) return NULL; if (ot == NULL || ot == Py_None) tt = time(NULL); @@ -567,13 +560,10 @@ #ifdef HAVE_MKTIME static PyObject * -time_mktime(PyObject *self, PyObject *args) +time_mktime(PyObject *self, PyObject *tup) { - PyObject *tup; struct tm buf; time_t tt; - if (!PyArg_ParseTuple(args, "O:mktime", &tup)) - return NULL; tt = time(&tt); buf = *localtime(&tt); if (!gettmarg(tup, &buf)) @@ -597,13 +587,10 @@ void inittimezone(PyObject *module); static PyObject * -time_tzset(PyObject *self, PyObject *args) +time_tzset(PyObject *self, PyObject *unused) { PyObject* m; - if (!PyArg_ParseTuple(args, ":tzset")) - return NULL; - m = PyImport_ImportModule("time"); if (m == NULL) { return NULL; @@ -722,9 +709,9 @@ static PyMethodDef time_methods[] = { - {"time", time_time, METH_VARARGS, time_doc}, + {"time", time_time, METH_NOARGS, time_doc}, #ifdef HAVE_CLOCK - {"clock", time_clock, METH_VARARGS, clock_doc}, + {"clock", time_clock, METH_NOARGS, clock_doc}, #endif {"sleep", time_sleep, METH_VARARGS, sleep_doc}, {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, @@ -732,14 +719,14 @@ {"asctime", time_asctime, METH_VARARGS, asctime_doc}, {"ctime", time_ctime, METH_VARARGS, ctime_doc}, #ifdef HAVE_MKTIME - {"mktime", time_mktime, METH_VARARGS, mktime_doc}, + {"mktime", time_mktime, METH_O, mktime_doc}, #endif #ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif {"strptime", time_strptime, METH_VARARGS, strptime_doc}, #ifdef HAVE_WORKING_TZSET - {"tzset", time_tzset, METH_VARARGS, tzset_doc}, + {"tzset", time_tzset, METH_NOARGS, tzset_doc}, #endif {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Objects/genobject.c ============================================================================== --- python/trunk/Objects/genobject.c (original) +++ python/trunk/Objects/genobject.c Mon May 29 23:04:52 2006 @@ -216,7 +216,7 @@ PyObject *tb = NULL; PyObject *val = NULL; - if (!PyArg_ParseTuple(args, "O|OO:throw", &typ, &val, &tb)) + if (!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)) return NULL; /* First, check the traceback argument, replacing None with Modified: python/trunk/Python/sysmodule.c ============================================================================== --- python/trunk/Python/sysmodule.c (original) +++ python/trunk/Python/sysmodule.c Mon May 29 23:04:52 2006 @@ -200,7 +200,7 @@ sys_exit(PyObject *self, PyObject *args) { PyObject *exit_code = 0; - if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) + if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code)) return NULL; /* Raise SystemExit so callers may catch it or clean up. */ PyErr_SetObject(PyExc_SystemExit, exit_code); @@ -672,7 +672,7 @@ sys_call_tracing(PyObject *self, PyObject *args) { PyObject *func, *funcargs; - if (!PyArg_ParseTuple(args, "OO:call_tracing", &func, &funcargs)) + if (!PyArg_UnpackTuple(args, "call_tracing", 2, 2, &func, &funcargs)) return NULL; return _PyEval_CallTracing(func, funcargs); } From python-checkins at python.org Mon May 29 23:58:43 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 29 May 2006 23:58:43 +0200 (CEST) Subject: [Python-checkins] r46534 - in python/trunk: Mac/Modules/gestaltmodule.c Modules/flmodule.c Modules/mathmodule.c PC/_subprocess.c PC/example_nt/example.c Python/marshal.c RISCOS/Modules/riscosmodule.c RISCOS/Modules/swimodule.c Message-ID: <20060529215843.6A4871E4007@bag.python.org> Author: georg.brandl Date: Mon May 29 23:58:42 2006 New Revision: 46534 Modified: python/trunk/Mac/Modules/gestaltmodule.c python/trunk/Modules/flmodule.c python/trunk/Modules/mathmodule.c python/trunk/PC/_subprocess.c python/trunk/PC/example_nt/example.c python/trunk/Python/marshal.c python/trunk/RISCOS/Modules/riscosmodule.c python/trunk/RISCOS/Modules/swimodule.c Log: Convert more modules to METH_VARARGS. Modified: python/trunk/Mac/Modules/gestaltmodule.c ============================================================================== --- python/trunk/Mac/Modules/gestaltmodule.c (original) +++ python/trunk/Mac/Modules/gestaltmodule.c Mon May 29 23:58:42 2006 @@ -35,7 +35,7 @@ OSErr iErr; OSType selector; long response; - if (!PyArg_Parse(args, "O&", PyMac_GetOSType, &selector)) + if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector)) return NULL; iErr = Gestalt ( selector, &response ); if (iErr != 0) @@ -44,7 +44,7 @@ } static struct PyMethodDef gestalt_methods[] = { - {"gestalt", gestalt_gestalt}, + {"gestalt", gestalt_gestalt, METH_VARARGS}, {NULL, NULL} /* Sentinel */ }; Modified: python/trunk/Modules/flmodule.c ============================================================================== --- python/trunk/Modules/flmodule.c (original) +++ python/trunk/Modules/flmodule.c Mon May 29 23:58:42 2006 @@ -148,22 +148,21 @@ static PyObject * generic_set_call_back(genericobject *g, PyObject *args) { - if (args == NULL) { + if (PyTuple_GET_SIZE(args) == 0) { Py_XDECREF(g->ob_callback); Py_XDECREF(g->ob_callback_arg); g->ob_callback = NULL; g->ob_callback_arg = NULL; } else { - if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) { - PyErr_BadArgument(); - return NULL; - } + PyObject *a, *b; + if (!PyArg_UnpackTuple(args, "set_call_back", 2, 2, &a, &b) + return NULL; Py_XDECREF(g->ob_callback); Py_XDECREF(g->ob_callback_arg); - g->ob_callback = PyTuple_GetItem(args, 0); + g->ob_callback = a; Py_INCREF(g->ob_callback); - g->ob_callback_arg = PyTuple_GetItem(args, 1); + g->ob_callback_arg = b; Py_INCREF(g->ob_callback_arg); } Py_INCREF(Py_None); @@ -250,7 +249,7 @@ } static PyMethodDef generic_methods[] = { - {"set_call_back", (PyCFunction)generic_set_call_back, METH_OLDARGS}, + {"set_call_back", (PyCFunction)generic_set_call_back, METH_VARARGS}, {"delete_object", (PyCFunction)generic_delete_object, METH_NOARGS}, {"show_object", (PyCFunction)generic_show_object, METH_NOARGS}, {"hide_object", (PyCFunction)generic_hide_object, METH_NOARGS}, @@ -261,7 +260,7 @@ #endif {"activate_object", (PyCFunction)generic_activate_object, METH_NOARGS}, {"deactivate_object", (PyCFunction)generic_deactivate_object, METH_NOARGS}, - {"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_OLDARGS}, + {"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/mathmodule.c ============================================================================== --- python/trunk/Modules/mathmodule.c (original) +++ python/trunk/Modules/mathmodule.c Mon May 29 23:58:42 2006 @@ -277,12 +277,8 @@ If the base not specified, returns the natural logarithm (base e) of x."); static PyObject * -math_log10(PyObject *self, PyObject *args) +math_log10(PyObject *self, PyObject *arg) { - PyObject *arg; - - if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg)) - return NULL; return loghelper(args, log10, "d:log10", arg); } @@ -332,7 +328,7 @@ {"hypot", math_hypot, METH_VARARGS, math_hypot_doc}, {"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc}, {"log", math_log, METH_VARARGS, math_log_doc}, - {"log10", math_log10, METH_VARARGS, math_log10_doc}, + {"log10", math_log10, METH_O, math_log10_doc}, {"modf", math_modf, METH_VARARGS, math_modf_doc}, {"pow", math_pow, METH_VARARGS, math_pow_doc}, {"radians", math_radians, METH_VARARGS, math_radians_doc}, Modified: python/trunk/PC/_subprocess.c ============================================================================== --- python/trunk/PC/_subprocess.c (original) +++ python/trunk/PC/_subprocess.c Mon May 29 23:58:42 2006 @@ -108,8 +108,8 @@ } static PyMethodDef sp_handle_methods[] = { - {"Detach", (PyCFunction) sp_handle_detach, 1}, - {"Close", (PyCFunction) sp_handle_close, 1}, + {"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS}, + {"Close", (PyCFunction) sp_handle_close, METH_VARARGS}, {NULL, NULL} }; Modified: python/trunk/PC/example_nt/example.c ============================================================================== --- python/trunk/PC/example_nt/example.c (original) +++ python/trunk/PC/example_nt/example.c Mon May 29 23:58:42 2006 @@ -9,7 +9,7 @@ } static PyMethodDef example_methods[] = { - {"foo", ex_foo, 1, "foo() doc string"}, + {"foo", ex_foo, METH_VARARGS, "foo() doc string"}, {NULL, NULL} }; Modified: python/trunk/Python/marshal.c ============================================================================== --- python/trunk/Python/marshal.c (original) +++ python/trunk/Python/marshal.c Mon May 29 23:58:42 2006 @@ -1073,12 +1073,10 @@ } static PyObject * -marshal_load(PyObject *self, PyObject *args) +marshal_load(PyObject *self, PyObject *f) { RFILE rf; - PyObject *f, *result; - if (!PyArg_ParseTuple(args, "O:load", &f)) - return NULL; + PyObject *result; if (!PyFile_Check(f)) { PyErr_SetString(PyExc_TypeError, "marshal.load() arg must be file"); @@ -1121,7 +1119,7 @@ static PyMethodDef marshal_methods[] = { {"dump", marshal_dump, METH_VARARGS}, - {"load", marshal_load, METH_VARARGS}, + {"load", marshal_load, METH_O}, {"dumps", marshal_dumps, METH_VARARGS}, {"loads", marshal_loads, METH_VARARGS}, {NULL, NULL} /* sentinel */ Modified: python/trunk/RISCOS/Modules/riscosmodule.c ============================================================================== --- python/trunk/RISCOS/Modules/riscosmodule.c (original) +++ python/trunk/RISCOS/Modules/riscosmodule.c Mon May 29 23:58:42 2006 @@ -31,39 +31,50 @@ /* RISCOS file commands */ -static PyObject *riscos_remove(PyObject *self,PyObject *args) -{ char *path1; - if (!PyArg_Parse(args, "s", &path1)) return NULL; +static PyObject * +riscos_remove(PyObject *self, PyObject *args) +{ + char *path1; + if (!PyArg_ParseTuple(args, "s:remove", &path1)) return NULL; if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_rename(PyObject *self,PyObject *args) -{ char *path1, *path2; - if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL; +static PyObject * +riscos_rename(PyObject *self, PyObject *args) +{ + char *path1, *path2; + if (!PyArg_ParseTuple(args, "ss:rename", &path1, &path2)) + return NULL; if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_system(PyObject *self,PyObject *args) -{ char *command; - if (!PyArg_Parse(args, "s", &command)) return NULL; +static PyObject * +riscos_system(PyObject *self, PyObject *args) +{ + char *command; + if (!PyArg_ParseTuple(args, "s:system", &command)) return NULL; return PyInt_FromLong(system(command)); } -static PyObject *riscos_chdir(PyObject *self,PyObject *args) -{ char *path; - if (!PyArg_Parse(args, "s", &path)) return NULL; +static PyObject * +riscos_chdir(PyObject *self, PyObject *args) +{ + char *path; + if (!PyArg_ParseTuple(args, "s:chdir", &path)) return NULL; e=xosfscontrol_dir(path); if(e) return riscos_oserror(); Py_INCREF(Py_None); return Py_None; } -static PyObject *canon(char *path) -{ int len; +static PyObject * +canon(char *path) +{ + int len; PyObject *obj; char *buf; e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len); @@ -78,32 +89,39 @@ return riscos_oserror(); } -static PyObject *riscos_getcwd(PyObject *self,PyObject *args) -{ if(!PyArg_NoArgs(args)) return NULL; - return canon("@"); +static PyObject * +riscos_getcwd(PyObject *self, PyObject *unused) +{ + return canon("@"); } -static PyObject *riscos_expand(PyObject *self,PyObject *args) -{ char *path; - if (!PyArg_Parse(args, "s", &path)) return NULL; +static PyObject * +riscos_expand(PyObject *self, PyObject *args) +{ + char *path; + if (!PyArg_ParseTuple(args, "s:expand", &path)) return NULL; return canon(path); } -static PyObject *riscos_mkdir(PyObject *self,PyObject *args) -{ char *path; - int mode; - if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) return NULL; - e=xosfile_create_dir(path,0); - if(e) return riscos_oserror(); +static PyObject * +riscos_mkdir(PyObject *self, PyObject *args) +{ + char *path; + int mode; + if (!PyArg_ParseTuple(args, "s|i:mkdir", &path, &mode)) return NULL; + e=xosfile_create_dir(path,0); + if(e) return riscos_oserror(); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_listdir(PyObject *self,PyObject *args) -{ char *path,buf[256]; - PyObject *d, *v; - int c=0,count; - if (!PyArg_Parse(args, "s", &path)) return NULL; +static PyObject * +riscos_listdir(PyObject *self, PyObject *args) +{ + char *path,buf[256]; + PyObject *d, *v; + int c=0,count; + if (!PyArg_ParseTuple(args, "s:listdir", &path)) return NULL; d=PyList_New(0); if(!d) return NULL; for(;;) @@ -158,14 +176,15 @@ static PyTypeObject StatResultType; -static PyObject *riscos_stat(PyObject *self,PyObject *args) +static PyObject * +riscos_stat(PyObject *self, PyObject *args) { PyObject *v; char *path; int ob,len; bits t=0; bits ld,ex,at,ft,mode; - if (!PyArg_Parse(args, "s", &path)) return NULL; + if (!PyArg_ParseTuple(args, "s:stat", &path)) return NULL; e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft); if(e) return riscos_oserror(); switch (ob) @@ -207,13 +226,15 @@ return v; } -static PyObject *riscos_chmod(PyObject *self,PyObject *args) -{ char *path; - bits mode; - bits attr; - attr=(mode&0x700)>>8; - attr|=(mode&7)<<4; - if (!PyArg_Parse(args, "(si)", &path,(int*)&mode)) return NULL; +static PyObject * +riscos_chmod(PyObject *self,PyObject *args) +{ + char *path; + bits mode; + bits attr; + attr=(mode&0x700)>>8; + attr|=(mode&7)<<4; + if (!PyArg_ParseTuple(args, "si:chmod", &path,(int*)&mode)) return NULL; e=xosfile_write_attr(path,attr); if(e) return riscos_oserror(); Py_INCREF(Py_None); @@ -221,7 +242,8 @@ } -static PyObject *riscos_utime(PyObject *self,PyObject *args) +static PyObject * +riscos_utime(PyObject *self, PyObject *args) { char *path; long atime, mtime; @@ -274,35 +296,42 @@ return Py_None; } -static PyObject *riscos_settype(PyObject *self,PyObject *args) -{ char *path,*name; - int type; - if (!PyArg_Parse(args, "(si)", &path,&type)) - { PyErr_Clear(); - if (!PyArg_Parse(args, "(ss)", &path,&name)) return NULL; +static PyObject * +riscos_settype(PyObject *self, PyObject *args) +{ + char *path,*name; + int type; + if (!PyArg_ParseTuple(args, "si:settype", &path,&type)) + { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "ss:settype", &path,&name)) return NULL; e=xosfscontrol_file_type_from_string(name,(bits*)&type); if(e) return riscos_oserror(); } - e=xosfile_set_type(path,type); - if(e) return riscos_oserror(); + e=xosfile_set_type(path,type); + if(e) return riscos_oserror(); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_getenv(PyObject *self,PyObject *args) -{ char *name,*value; - if(!PyArg_Parse(args,"s",&name)) return NULL; +static PyObject * +riscos_getenv(PyObject *self, PyObject *args) +{ + char *name,*value; + if(!PyArg_ParseTuple(args,"s:getenv",&name)) return NULL; value=getenv(name); if(value) return PyString_FromString(value); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_putenv(PyObject *self,PyObject *args) -{ char *name,*value; +static PyObject * +riscos_putenv(PyObject *self, PyObject *args) +{ + char *name,*value; int len; os_var_type type=os_VARTYPE_LITERAL_STRING; - if(!PyArg_ParseTuple(args,"ss|i",&name,&value,&type)) return NULL; + if(!PyArg_ParseTuple(args,"ss|i:putenv",&name,&value,&type)) return NULL; if(type!=os_VARTYPE_STRING&&type!=os_VARTYPE_MACRO&&type!=os_VARTYPE_EXPANDED &&type!=os_VARTYPE_LITERAL_STRING) return riscos_error("Bad putenv type"); @@ -315,22 +344,26 @@ return Py_None; } -static PyObject *riscos_delenv(PyObject *self,PyObject *args) -{ char *name; - if(!PyArg_Parse(args,"s",&name)) return NULL; +static PyObject * +riscos_delenv(PyObject *self, PyObject *args) +{ + char *name; + if(!PyArg_ParseTuple(args,"s:delenv",&name)) return NULL; e=xos_set_var_val(name,NULL,-1,0,0,0,0); if(e) return riscos_oserror(); Py_INCREF(Py_None); return Py_None; } -static PyObject *riscos_getenvdict(PyObject *self,PyObject *args) -{ PyObject *dict; +static PyObject * +riscos_getenvdict(PyObject *self, PyObject *args) +{ + PyObject *dict; char value[257]; char *which="*"; int size; char *context=NULL; - if(!PyArg_ParseTuple(args,"|s",&which)) return NULL; + if(!PyArg_ParseTuple(args,"|s:getenvdict",&which)) return NULL; dict = PyDict_New(); if (!dict) return NULL; /* XXX This part ignores errors */ @@ -348,25 +381,25 @@ static PyMethodDef riscos_methods[] = { - {"unlink", riscos_remove}, - {"remove", riscos_remove}, - {"rename", riscos_rename}, - {"system", riscos_system}, - {"rmdir", riscos_remove}, - {"chdir", riscos_chdir}, - {"getcwd", riscos_getcwd}, - {"expand", riscos_expand}, - {"mkdir", riscos_mkdir,1}, - {"listdir", riscos_listdir}, - {"stat", riscos_stat}, - {"lstat", riscos_stat}, - {"chmod", riscos_chmod}, - {"utime", riscos_utime}, - {"settype", riscos_settype}, - {"getenv", riscos_getenv}, - {"putenv", riscos_putenv}, - {"delenv", riscos_delenv}, - {"getenvdict", riscos_getenvdict,1}, + {"unlink", riscos_remove, METH_VARARGS}, + {"remove", riscos_remove, METH_VARARGS}, + {"rename", riscos_rename, METH_VARARGS}, + {"system", riscos_system, METH_VARARGS}, + {"rmdir", riscos_remove, METH_VARARGS}, + {"chdir", riscos_chdir, METH_VARARGS}, + {"getcwd", riscos_getcwd, METH_NOARGS}, + {"expand", riscos_expand, METH_VARARGS}, + {"mkdir", riscos_mkdir, METH_VARARGS}, + {"listdir", riscos_listdir, METH_VARARGS}, + {"stat", riscos_stat, METH_VARARGS}, + {"lstat", riscos_stat, METH_VARARGS}, + {"chmod", riscos_chmod, METH_VARARGS}, + {"utime", riscos_utime, METH_VARARGS}, + {"settype", riscos_settype, METH_VARARGS}, + {"getenv", riscos_getenv, METH_VARARGS}, + {"putenv", riscos_putenv, METH_VARARGS}, + {"delenv", riscos_delenv, METH_VARARGS}, + {"getenvdict", riscos_getenvdict, METH_VARARGS}, {NULL, NULL} /* Sentinel */ }; Modified: python/trunk/RISCOS/Modules/swimodule.c ============================================================================== --- python/trunk/RISCOS/Modules/swimodule.c (original) +++ python/trunk/RISCOS/Modules/swimodule.c Mon May 29 23:58:42 2006 @@ -552,14 +552,14 @@ static PyMethodDef SwiMethods[]= -{ { "swi", swi_swi,1}, - { "block", PyBlock_New,1}, - { "register", PyRegister,1}, - { "string", swi_string,METH_VARARGS, swi_string__doc__}, - { "integer", swi_integer,METH_VARARGS, swi_integer__doc__}, - { "integers", swi_integers,METH_VARARGS, swi_integers__doc__}, - { "tuples", swi_tuples,METH_VARARGS, swi_tuples__doc__}, - { "tuple", swi_tuple,METH_VARARGS, swi_tuple__doc__}, +{ { "swi", swi_swi, METH_VARARGS}, + { "block", PyBlock_New, METH_VARARGS}, + { "register", PyRegister, METH_VARARGS}, + { "string", swi_string, METH_VARARGS, swi_string__doc__}, + { "integer", swi_integer, METH_VARARGS, swi_integer__doc__}, + { "integers", swi_integers, METH_VARARGS, swi_integers__doc__}, + { "tuples", swi_tuples, METH_VARARGS, swi_tuples__doc__}, + { "tuple", swi_tuple, METH_VARARGS, swi_tuple__doc__}, { NULL,NULL,0,NULL} /* Sentinel */ }; From python-checkins at python.org Tue May 30 00:00:31 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 00:00:31 +0200 (CEST) Subject: [Python-checkins] r46535 - python/trunk/Modules/mathmodule.c Message-ID: <20060529220031.281861E4005@bag.python.org> Author: georg.brandl Date: Tue May 30 00:00:30 2006 New Revision: 46535 Modified: python/trunk/Modules/mathmodule.c Log: Whoops. Modified: python/trunk/Modules/mathmodule.c ============================================================================== --- python/trunk/Modules/mathmodule.c (original) +++ python/trunk/Modules/mathmodule.c Tue May 30 00:00:30 2006 @@ -277,8 +277,12 @@ If the base not specified, returns the natural logarithm (base e) of x."); static PyObject * -math_log10(PyObject *self, PyObject *arg) +math_log10(PyObject *self, PyObject *args) { + PyObject *arg; + + if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg)) + return NULL; return loghelper(args, log10, "d:log10", arg); } @@ -328,7 +332,7 @@ {"hypot", math_hypot, METH_VARARGS, math_hypot_doc}, {"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc}, {"log", math_log, METH_VARARGS, math_log_doc}, - {"log10", math_log10, METH_O, math_log10_doc}, + {"log10", math_log10, METH_VARARGS, math_log10_doc}, {"modf", math_modf, METH_VARARGS, math_modf_doc}, {"pow", math_pow, METH_VARARGS, math_pow_doc}, {"radians", math_radians, METH_VARARGS, math_radians_doc}, From python-checkins at python.org Tue May 30 00:42:07 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 30 May 2006 00:42:07 +0200 (CEST) Subject: [Python-checkins] r46536 - in python/trunk: Lib/test/string_tests.py Objects/stringlib/count.h Message-ID: <20060529224207.CB1BC1E4005@bag.python.org> Author: fredrik.lundh Date: Tue May 30 00:42:07 2006 New Revision: 46536 Modified: python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringlib/count.h Log: fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on the current behaviour ;-) Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Tue May 30 00:42:07 2006 @@ -106,10 +106,18 @@ self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(0, 'aaa', 'count', 'b') + self.checkequal(2, 'aaa', 'count', 'a', 1) + self.checkequal(0, 'aaa', 'count', 'a', 10) self.checkequal(1, 'aaa', 'count', 'a', -1) self.checkequal(3, 'aaa', 'count', 'a', -10) + self.checkequal(1, 'aaa', 'count', 'a', 0, 1) + self.checkequal(3, 'aaa', 'count', 'a', 0, 10) self.checkequal(2, 'aaa', 'count', 'a', 0, -1) self.checkequal(0, 'aaa', 'count', 'a', 0, -10) + self.checkequal(3, 'aaa', 'count', '', 1) + self.checkequal(1, 'aaa', 'count', '', 10) + self.checkequal(2, 'aaa', 'count', '', -1) + self.checkequal(4, 'aaa', 'count', '', -10) self.checkraises(TypeError, 'hello', 'count') self.checkraises(TypeError, 'hello', 'count', 42) Modified: python/trunk/Objects/stringlib/count.h ============================================================================== --- python/trunk/Objects/stringlib/count.h (original) +++ python/trunk/Objects/stringlib/count.h Tue May 30 00:42:07 2006 @@ -13,8 +13,11 @@ { Py_ssize_t count; - if (sub_len == 0) + if (sub_len == 0) { + if (str_len < 0) + return 1; /* start >= len(str) */ return str_len + 1; + } count = fastsearch(str, str_len, sub, sub_len, FAST_COUNT); From python-checkins at python.org Tue May 30 00:55:49 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 30 May 2006 00:55:49 +0200 (CEST) Subject: [Python-checkins] r46537 - in python/trunk: Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060529225549.448D41E4005@bag.python.org> Author: bob.ippolito Date: Tue May 30 00:55:48 2006 New Revision: 46537 Modified: python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly) Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Tue May 30 00:55:48 2006 @@ -3,6 +3,7 @@ import struct import array import unittest +import warnings import sys ISBIGENDIAN = sys.byteorder == "big" @@ -10,7 +11,14 @@ verify((struct.pack('=i', 1)[0] == chr(0)) == ISBIGENDIAN, "bigendian determination appears wrong") -PY_STRUCT_RANGE_CHECKING = 1 +try: + import _struct +except ImportError: + PY_STRUCT_RANGE_CHECKING = 0 + PY_STRUCT_WRAPPING = 1 +else: + PY_STRUCT_RANGE_CHECKING = getattr(_struct, '_PY_STRUCT_RANGE_CHECKING', 0) + PY_STRUCT_WRAPPING = getattr(_struct, '_PY_STRUCT_WRAPPING', 0) def string_reverse(s): chars = list(s) @@ -35,12 +43,29 @@ def any_err(func, *args): try: func(*args) - except (struct.error, OverflowError, TypeError): + except (struct.error, TypeError): pass else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) +def deprecated_err(func, *args): + warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) + warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) + try: + try: + func(*args) + except (struct.error, TypeError): + pass + except DeprecationWarning: + if not PY_STRUCT_WRAPPING: + raise TestFailed, "%s%s expected to raise struct.error" % ( + func.__name__, args) + else: + raise TestFailed, "%s%s did not raise error" % ( + func.__name__, args) + finally: + warnings.resetwarnings() simple_err(struct.calcsize, 'Z') @@ -272,8 +297,8 @@ if verbose: print "Skipping buggy range check for code", code else: - any_err(pack, ">" + code, x) - any_err(pack, "<" + code, x) + deprecated_err(pack, ">" + code, x) + deprecated_err(pack, "<" + code, x) # Much the same for unsigned. code = self.unsigned_code @@ -327,8 +352,8 @@ if verbose: print "Skipping buggy range check for code", code else: - any_err(pack, ">" + code, x) - any_err(pack, "<" + code, x) + deprecated_err(pack, ">" + code, x) + deprecated_err(pack, "<" + code, x) def run(self): from random import randrange @@ -448,13 +473,13 @@ for endian in ('', '>', '<'): for cls in (int, long): for fmt in ('B', 'H', 'I', 'L'): - any_err(struct.pack, endian + fmt, cls(-1)) + deprecated_err(struct.pack, endian + fmt, cls(-1)) - any_err(struct.pack, endian + 'B', cls(300)) - any_err(struct.pack, endian + 'H', cls(70000)) + deprecated_err(struct.pack, endian + 'B', cls(300)) + deprecated_err(struct.pack, endian + 'H', cls(70000)) - any_err(struct.pack, endian + 'I', sys.maxint * 4L) - any_err(struct.pack, endian + 'L', sys.maxint * 4L) + deprecated_err(struct.pack, endian + 'I', sys.maxint * 4L) + deprecated_err(struct.pack, endian + 'L', sys.maxint * 4L) if PY_STRUCT_RANGE_CHECKING: test_1229380() Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Tue May 30 00:55:48 2006 @@ -17,6 +17,20 @@ typedef int Py_ssize_t; #endif +/* If PY_STRUCT_WRAPPING is defined, the struct module will wrap all input + numbers for explicit endians such that they fit in the given type, much + like explicit casting in C. A warning will be raised if the number did + not originally fit within the range of the requested type. If it is + not defined, then all range errors and overflow will be struct.error + exceptions. */ + +#define PY_STRUCT_WRAPPING 1 + +#ifdef PY_STRUCT_WRAPPING +static PyObject *pylong_ulong_mask = NULL; +static PyObject *pyint_zero = NULL; +#endif + /* The translation function for each format character is table driven */ typedef struct _formatdef { char format; @@ -195,6 +209,75 @@ #endif +#ifdef PY_STRUCT_WRAPPING + +/* Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_wrapped_long(PyObject *v, long *p) +{ + if (get_long(v, p) < 0) { + if (PyLong_Check(v) && PyErr_ExceptionMatches(PyExc_OverflowError)) { + PyObject *wrapped; + long x; + PyErr_Clear(); + if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer wrapping is deprecated") < 0) + return -1; + wrapped = PyNumber_And(v, pylong_ulong_mask); + if (wrapped == NULL) + return -1; + x = (long)PyLong_AsUnsignedLong(wrapped); + Py_DECREF(wrapped); + if (x == -1 && PyErr_Occurred()) + return -1; + *p = x; + } else { + return -1; + } + } + return 0; +} + +static int +get_wrapped_ulong(PyObject *v, unsigned long *p) +{ + long x = (long)PyLong_AsUnsignedLong(v); + if (x == -1 && PyErr_Occurred()) { + PyObject *wrapped; + PyErr_Clear(); + wrapped = PyNumber_And(v, pylong_ulong_mask); + if (wrapped == NULL) + return -1; + if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer wrapping is deprecated") < 0) { + Py_DECREF(wrapped); + return -1; + } + x = (long)PyLong_AsUnsignedLong(wrapped); + Py_DECREF(wrapped); + if (x == -1 && PyErr_Occurred()) + return -1; + } + *p = (unsigned long)x; + return 0; +} + +#define RANGE_ERROR(x, f, flag, mask) \ + do { \ + if (_range_error(f, flag) < 0) \ + return -1; \ + else \ + (x) &= (mask); \ + } while (0) + +#else + +#define get_wrapped_long get_long +#define get_wrapped_ulong get_ulong +#define RANGE_ERROR(x, f, flag, mask) return _range_error(f, flag) + +#endif + /* Floating point helpers */ static PyObject * @@ -247,6 +330,25 @@ f->format, largest); } +#ifdef PY_STRUCT_WRAPPING + { + PyObject *ptype, *pvalue, *ptraceback; + PyObject *msg; + int rval; + PyErr_Fetch(&ptype, &pvalue, &ptraceback); + assert(pvalue != NULL); + msg = PyObject_Str(pvalue); + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + if (msg == NULL) + return -1; + rval = PyErr_Warn(PyExc_DeprecationWarning, PyString_AS_STRING(msg)); + Py_DECREF(msg); + if (rval == 0) + return 0; + } +#endif return -1; } @@ -707,15 +809,19 @@ { long x; Py_ssize_t i; - if (get_long(v, &x) < 0) + if (get_wrapped_long(v, &x) < 0) return -1; i = f->size; if (i != SIZEOF_LONG) { if ((i == 2) && (x < -32768 || x > 32767)) - return _range_error(f, 0); + RANGE_ERROR(x, f, 0, 0xffffL); #if (SIZEOF_LONG != 4) else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) - return _range_error(f, 0); + RANGE_ERROR(x, f, 0, 0xffffffffL); +#endif +#ifdef PY_STRUCT_WRAPPING + else if ((i == 1) && (x < -128 || x > 127)) + RANGE_ERROR(x, f, 0, 0xffL); #endif } do { @@ -730,14 +836,14 @@ { unsigned long x; Py_ssize_t i; - if (get_ulong(v, &x) < 0) + if (get_wrapped_ulong(v, &x) < 0) return -1; i = f->size; if (i != SIZEOF_LONG) { unsigned long maxint = 1; maxint <<= (unsigned long)(i * 8); if (x >= maxint) - return _range_error(f, 1); + RANGE_ERROR(x, f, 1, maxint - 1); } do { p[--i] = (char)x; @@ -804,8 +910,14 @@ static formatdef bigendian_table[] = { {'x', 1, 0, NULL}, +#ifdef PY_STRUCT_WRAPPING + /* Native packers do range checking without wrapping. */ + {'b', 1, 0, nu_byte, bp_int}, + {'B', 1, 0, nu_ubyte, bp_uint}, +#else {'b', 1, 0, nu_byte, np_byte}, {'B', 1, 0, nu_ubyte, np_ubyte}, +#endif {'c', 1, 0, nu_char, np_char}, {'s', 1, 0, NULL}, {'p', 1, 0, NULL}, @@ -915,15 +1027,19 @@ { long x; Py_ssize_t i; - if (get_long(v, &x) < 0) + if (get_wrapped_long(v, &x) < 0) return -1; i = f->size; if (i != SIZEOF_LONG) { if ((i == 2) && (x < -32768 || x > 32767)) - return _range_error(f, 0); + RANGE_ERROR(x, f, 0, 0xffffL); #if (SIZEOF_LONG != 4) else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) - return _range_error(f, 0); + RANGE_ERROR(x, f, 0, 0xffffffffL); +#endif +#ifdef PY_STRUCT_WRAPPING + else if ((i == 1) && (x < -128 || x > 127)) + RANGE_ERROR(x, f, 0, 0xffL); #endif } do { @@ -938,14 +1054,14 @@ { unsigned long x; Py_ssize_t i; - if (get_ulong(v, &x) < 0) + if (get_wrapped_ulong(v, &x) < 0) return -1; i = f->size; if (i != SIZEOF_LONG) { unsigned long maxint = 1; maxint <<= (unsigned long)(i * 8); if (x >= maxint) - return _range_error(f, 1); + RANGE_ERROR(x, f, 1, maxint - 1); } do { *p++ = (char)x; @@ -1012,8 +1128,14 @@ static formatdef lilendian_table[] = { {'x', 1, 0, NULL}, +#ifdef PY_STRUCT_WRAPPING + /* Native packers do range checking without wrapping. */ + {'b', 1, 0, nu_byte, lp_int}, + {'B', 1, 0, nu_ubyte, lp_uint}, +#else {'b', 1, 0, nu_byte, np_byte}, {'B', 1, 0, nu_ubyte, np_ubyte}, +#endif {'c', 1, 0, nu_char, np_char}, {'s', 1, 0, NULL}, {'p', 1, 0, NULL}, @@ -1418,8 +1540,12 @@ *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); } else { v = PyTuple_GET_ITEM(args, i++); - if (e->pack(res, v, e) < 0) + if (e->pack(res, v, e) < 0) { + if (PyLong_Check(v) && PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_SetString(StructError, + "long too large to convert to int"); return -1; + } } } @@ -1614,6 +1740,26 @@ if (PyType_Ready(&PyStructType) < 0) return; +#ifdef PY_STRUCT_WRAPPING + if (pyint_zero == NULL) { + pyint_zero = PyInt_FromLong(0); + if (pyint_zero == NULL) + return; + } + if (pylong_ulong_mask == NULL) { +#if (SIZEOF_LONG == 4) + pylong_ulong_mask = PyLong_FromString("FFFFFFFF", NULL, 16); +#else + pylong_ulong_mask = PyLong_FromString("FFFFFFFFFFFFFFFF", NULL, 16); +#endif + if (pylong_ulong_mask == NULL) + return; + } + +#else + /* This speed trick can't be used until wrapping goes away, because + native endian always raises exceptions instead of wrapping. */ + /* Check endian and swap in faster functions */ { int one = 1; @@ -1652,6 +1798,7 @@ native++; } } +#endif /* Add some symbolic constants to the module */ if (StructError == NULL) { @@ -1665,4 +1812,9 @@ Py_INCREF((PyObject*)&PyStructType); PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); + + PyModule_AddIntConstant(m, "_PY_STRUCT_RANGE_CHECKING", 1); +#ifdef PY_STRUCT_WRAPPING + PyModule_AddIntConstant(m, "_PY_STRUCT_WRAPPING", 1); +#endif } From python-checkins at python.org Tue May 30 01:05:05 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 30 May 2006 01:05:05 +0200 (CEST) Subject: [Python-checkins] r46538 - sandbox/trunk/structbench sandbox/trunk/structbench/bench_struct.py Message-ID: <20060529230505.C872C1E4005@bag.python.org> Author: bob.ippolito Date: Tue May 30 01:05:05 2006 New Revision: 46538 Added: sandbox/trunk/structbench/ sandbox/trunk/structbench/bench_struct.py (contents, props changed) Log: struct benchmarks Added: sandbox/trunk/structbench/bench_struct.py ============================================================================== --- (empty file) +++ sandbox/trunk/structbench/bench_struct.py Tue May 30 01:05:05 2006 @@ -0,0 +1,83 @@ +import struct +# A representative set of formats from the stdlib +FORMATS = [(s, struct.calcsize(s)) for s in +""" +d +>l +>L +>h +!HHB +>h +>ii +>H +>L +4I +II +L +>L +d +P +lxxxxlxxxxlhh +hhlllii +hhllhh +l +L +148b +148B +356B +356b +L +>f +>d +>l +<4s4H2lH +<4s4B4HlLL5HLl +<4s2B4HlLL2H + Author: bob.ippolito Date: Tue May 30 02:26:01 2006 New Revision: 46539 Modified: python/trunk/Lib/aifc.py Log: Add a length check to aifc to ensure it doesn't write a bogus file Modified: python/trunk/Lib/aifc.py ============================================================================== --- python/trunk/Lib/aifc.py (original) +++ python/trunk/Lib/aifc.py Tue May 30 02:26:01 2006 @@ -201,6 +201,8 @@ f.write(struct.pack('>L', x)) def _write_string(f, s): + if len(s) > 255: + raise ValueError("string exceeds maximum pstring length") f.write(chr(len(s))) f.write(s) if len(s) & 1 == 0: From neal at metaslash.com Mon May 29 22:12:43 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 29 May 2006 16:12:43 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (2) Message-ID: <20060529201243.GA7963@python.psfb.org> ----------------------------------------------- Modules/Setup.dist is newer than Modules/Setup; check to make sure you have all the updates you need in your Modules/Setup file. Usually, copying Setup.dist to Setup will work. ----------------------------------------------- case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [34112 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8662 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_strftime test_string test test_string failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/test_string.py", line 16, in checkequal realresult AssertionError: 1 != -6 test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/test_unicode.py", line 97, in test_count string_tests.CommonTest.test_count(self) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport /home/neal/python/trunk/Lib/test/test_zipimport.py:91: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py ["__dummy__"]) test_zlib /home/neal/python/trunk/Lib/test/test_zlib.py:3: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py import zlib 281 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [424640 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_strftime test_string test test_string failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/test_string.py", line 16, in checkequal realresult AssertionError: 1 != -6 test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/test_unicode.py", line 97, in test_count string_tests.CommonTest.test_count(self) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport /home/neal/python/trunk/Lib/test/test_zipimport.py:91: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py ["__dummy__"]) test_zlib /home/neal/python/trunk/Lib/test/test_zlib.py:3: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py import zlib 281 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [424068 refs] make: *** [test] Error 1 From neal at metaslash.com Mon May 29 23:18:27 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 29 May 2006 17:18:27 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20060529211827.GA13218@python.psfb.org> test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socketserver test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_strftime test_string test test_string failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/test_string.py", line 16, in checkequal realresult AssertionError: 1 != -6 test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- Traceback (most recent call last): File "/home/neal/python/trunk/Lib/test/test_unicode.py", line 97, in test_count string_tests.CommonTest.test_count(self) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 118, in test_count self.checkequal(1, 'aaa', 'count', '', 10) File "/home/neal/python/trunk/Lib/test/string_tests.py", line 56, in checkequal realresult AssertionError: 1 != -6 test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport /home/neal/python/trunk/Lib/test/test_zipimport.py:91: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py ["__dummy__"]) test_zlib /home/neal/python/trunk/Lib/test/test_zlib.py:3: ImportWarning: Not importing directory '/home/neal/python/trunk/Modules/zlib': missing __init__.py import zlib 287 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 21 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_gl test_imgfile test_ioctl test_macfs test_macostools test_nis test_pep277 test_plistlib test_scriptpackages test_startfile test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [431356 refs] From python-checkins at python.org Tue May 30 04:25:26 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 04:25:26 +0200 (CEST) Subject: [Python-checkins] r46540 - python/trunk/Lib/test/test_struct.py Message-ID: <20060530022526.4A3A51E4013@bag.python.org> Author: tim.peters Date: Tue May 30 04:25:25 2006 New Revision: 46540 Modified: python/trunk/Lib/test/test_struct.py Log: deprecated_err(): Stop bizarre warning messages when the tests are run in the order: test_genexps (or any other doctest-based test) test_struct test_doctest The `warnings` module needs an advertised way to save/restore its internal filter list. Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Tue May 30 04:25:25 2006 @@ -50,8 +50,12 @@ func.__name__, args) def deprecated_err(func, *args): + # The `warnings` module doesn't have an advertised way to restore + # its filter list. Cheat. + save_warnings_filters = warnings.filters[:] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) - warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) + warnings.filterwarnings("error", r""".*format requires.*""", + DeprecationWarning) try: try: func(*args) @@ -65,7 +69,7 @@ raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: - warnings.resetwarnings() + warnings.filters[:] = save_warnings_filters[:] simple_err(struct.calcsize, 'Z') From python-checkins at python.org Tue May 30 04:26:46 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 04:26:46 +0200 (CEST) Subject: [Python-checkins] r46541 - in python/trunk: Lib/doctest.py Lib/functools.py Tools/pybench/systimes.py Message-ID: <20060530022646.C32DD1E4006@bag.python.org> Author: tim.peters Date: Tue May 30 04:26:46 2006 New Revision: 46541 Modified: python/trunk/Lib/doctest.py python/trunk/Lib/functools.py python/trunk/Tools/pybench/systimes.py Log: Whitespace normalization. Modified: python/trunk/Lib/doctest.py ============================================================================== --- python/trunk/Lib/doctest.py (original) +++ python/trunk/Lib/doctest.py Tue May 30 04:26:46 2006 @@ -1939,7 +1939,7 @@ Optional keyword arg "encoding" specifies an encoding that should be used to convert the file to unicode. - + Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master @@ -2366,7 +2366,7 @@ # Find the file and read it. name = os.path.basename(path) - + # If an encoding is specified, use it to convert the file to unicode if encoding is not None: doc = doc.decode(encoding) @@ -2427,7 +2427,7 @@ parser A DocTestParser (or subclass) that should be used to extract tests from the files. - + encoding An encoding that will be used to convert the files to unicode. """ Modified: python/trunk/Lib/functools.py ============================================================================== --- python/trunk/Lib/functools.py (original) +++ python/trunk/Lib/functools.py Tue May 30 04:26:46 2006 @@ -23,4 +23,4 @@ # The wraps function makes it easy to avoid the bug that afflicts the # decorator example in the python-dev email proposing the # update_wrapper function: -# http://mail.python.org/pipermail/python-dev/2006-May/064775.html \ No newline at end of file +# http://mail.python.org/pipermail/python-dev/2006-May/064775.html Modified: python/trunk/Tools/pybench/systimes.py ============================================================================== --- python/trunk/Tools/pybench/systimes.py (original) +++ python/trunk/Tools/pybench/systimes.py Tue May 30 04:26:46 2006 @@ -179,7 +179,7 @@ print 'after:', t1 print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) print - + def test_idle(): print 'Testing systimes() under idle conditions' t0 = systimes() From python-checkins at python.org Tue May 30 04:30:32 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 04:30:32 +0200 (CEST) Subject: [Python-checkins] r46542 - python/trunk/Lib/test/test_doctest4.txt Message-ID: <20060530023032.A57021E4005@bag.python.org> Author: tim.peters Date: Tue May 30 04:30:30 2006 New Revision: 46542 Modified: python/trunk/Lib/test/test_doctest4.txt (props changed) Log: Set a binary svn:mime-type property on this UTF-8 encoded file. From python-checkins at python.org Tue May 30 05:18:59 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 05:18:59 +0200 (CEST) Subject: [Python-checkins] r46543 - python/trunk/Modules/socketmodule.c Message-ID: <20060530031859.A8ED71E4005@bag.python.org> Author: neal.norwitz Date: Tue May 30 05:18:50 2006 New Revision: 46543 Modified: python/trunk/Modules/socketmodule.c Log: Simplify further by using AddStringConstant Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Tue May 30 05:18:50 2006 @@ -4362,10 +4362,8 @@ PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO); #endif PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM); - PyModule_AddObject(m, "BDADDR_ANY", - PyString_FromString("00:00:00:00:00:00")); - PyModule_AddObject(m, "BDADDR_LOCAL", - PyString_FromString("00:00:00:FF:FF:FF")); + PyModule_AddStringConstant(m, "BDADDR_ANY", "00:00:00:00:00:00"); + PyModule_AddStringConstant(m, "BDADDR_LOCAL", "00:00:00:FF:FF:FF"); #endif #ifdef HAVE_NETPACKET_PACKET_H From buildbot at python.org Tue May 30 05:40:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 03:40:17 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060530034017.014B21E400E@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/861 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 06:16:26 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 06:16:26 +0200 (CEST) Subject: [Python-checkins] r46544 - in python/trunk: Include/dictobject.h Objects/dictobject.c Message-ID: <20060530041626.4E43B1E4006@bag.python.org> Author: tim.peters Date: Tue May 30 06:16:25 2006 New Revision: 46544 Modified: python/trunk/Include/dictobject.h python/trunk/Objects/dictobject.c Log: Convert relevant dict internals to Py_ssize_t. I don't have a box with nearly enough RAM, or an OS, that could get close to tickling this, though (requires a dict w/ at least 2**31 entries). Modified: python/trunk/Include/dictobject.h ============================================================================== --- python/trunk/Include/dictobject.h (original) +++ python/trunk/Include/dictobject.h Tue May 30 06:16:25 2006 @@ -8,7 +8,7 @@ /* Dictionary object type -- mapping from hashable object to object */ /* The distribution includes a separate file, Objects/dictnotes.txt, - describing explorations into dictionary design and optimization. + describing explorations into dictionary design and optimization. It covers typical dictionary use patterns, the parameters for tuning dictionaries, and several ideas for possible optimizations. */ @@ -48,7 +48,11 @@ #define PyDict_MINSIZE 8 typedef struct { - long me_hash; /* cached hash code of me_key */ + /* Cached hash code of me_key. Note that hash codes are C longs. + * We have to use Py_ssize_t instead because dict_popitem() abuses + * me_hash to hold a search finger. + */ + Py_ssize_t me_hash; PyObject *me_key; PyObject *me_value; } PyDictEntry; @@ -65,14 +69,14 @@ typedef struct _dictobject PyDictObject; struct _dictobject { PyObject_HEAD - int ma_fill; /* # Active + # Dummy */ - int ma_used; /* # Active */ + Py_ssize_t ma_fill; /* # Active + # Dummy */ + Py_ssize_t ma_used; /* # Active */ /* The table contains ma_mask + 1 slots, and that's a power of 2. * We store the mask instead of the size because the mask is more * frequently needed. */ - int ma_mask; + Py_ssize_t ma_mask; /* ma_table points to ma_smalltable for small tables, else to * additional malloc'ed memory. ma_table is never NULL! This rule Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 06:16:25 2006 @@ -110,6 +110,16 @@ masked); and the dictobject struct required a member to hold the table's polynomial. In Tim's experiments the current scheme ran faster, produced equally good collision statistics, needed less code & used less memory. + +Theoretical Python 2.5 headache: hash codes are only C "long", but +sizeof(Py_ssize_t) > sizeof(long) may be possible. In that case, and if a +dict is genuinely huge, then only the slots directly reachable via indexing +by a C long can be the first slot in a probe sequence. The probe sequence +will still eventually reach every slot in the table, but the collision rate +on initial probes may be much higher than this scheme was designed for. +Getting a hash code as fat as Py_ssize_t is the only real cure. But in +practice, this probably won't make a lick of difference for many years (at +which point everyone will have terabytes of RAM on 64-bit boxes). */ /* Object used as dummy key to fill deleted entries */ @@ -228,7 +238,7 @@ register Py_ssize_t i; register size_t perturb; register dictentry *freeslot; - register unsigned int mask = mp->ma_mask; + register Py_ssize_t mask = mp->ma_mask; dictentry *ep0 = mp->ma_table; register dictentry *ep; register int restore_error; @@ -339,7 +349,7 @@ register Py_ssize_t i; register size_t perturb; register dictentry *freeslot; - register unsigned int mask = mp->ma_mask; + register Py_ssize_t mask = mp->ma_mask; dictentry *ep0 = mp->ma_table; register dictentry *ep; @@ -413,7 +423,7 @@ Py_DECREF(dummy); } ep->me_key = key; - ep->me_hash = hash; + ep->me_hash = (Py_ssize_t)hash; ep->me_value = value; mp->ma_used++; } @@ -425,11 +435,11 @@ actually be smaller than the old one. */ static int -dictresize(dictobject *mp, int minused) +dictresize(dictobject *mp, Py_ssize_t minused) { - int newsize; + Py_ssize_t newsize; dictentry *oldtable, *newtable, *ep; - int i; + Py_ssize_t i; int is_oldtable_malloced; dictentry small_copy[PyDict_MINSIZE]; @@ -537,7 +547,7 @@ { register dictobject *mp; register long hash; - register int n_used; + register Py_ssize_t n_used; if (!PyDict_Check(op)) { PyErr_BadInternalCall(); @@ -568,14 +578,14 @@ * Quadrupling the size improves average dictionary sparseness * (reducing collisions) at the cost of some memory and iteration * speed (which loops over every possible entry). It also halves - * the number of expensive resize operations in a growing dictionary. +| * the number of expensive resize operations in a growing dictionary. * * Very large dictionaries (over 50K items) use doubling instead. * This may help applications with severe memory constraints. */ if (!(mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2)) return 0; - return dictresize(mp, (mp->ma_used>50000 ? mp->ma_used*2 : mp->ma_used*4)); + return dictresize(mp, (mp->ma_used > 50000 ? 2 : 4) * mp->ma_used); } int @@ -619,10 +629,10 @@ dictobject *mp; dictentry *ep, *table; int table_is_malloced; - int fill; + Py_ssize_t fill; dictentry small_copy[PyDict_MINSIZE]; #ifdef Py_DEBUG - int i, n; + Py_ssize_t i, n; #endif if (!PyDict_Check(op)) @@ -685,7 +695,7 @@ /* * Iterate over a dict. Use like so: * - * int i; + * Py_ssize_t i; * PyObject *key, *value; * i = 0; # important! i should not otherwise be changed by you * while (PyDict_Next(yourdict, &i, &key, &value)) { @@ -701,7 +711,7 @@ PyDict_Next(PyObject *op, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) { register Py_ssize_t i; - register int mask; + register Py_ssize_t mask; register dictentry *ep; if (!PyDict_Check(op)) @@ -729,7 +739,7 @@ dict_dealloc(register dictobject *mp) { register dictentry *ep; - int fill = mp->ma_fill; + Py_ssize_t fill = mp->ma_fill; PyObject_GC_UnTrack(mp); Py_TRASHCAN_SAFE_BEGIN(mp) for (ep = mp->ma_table; fill > 0; ep++) { @@ -751,10 +761,10 @@ static int dict_print(register dictobject *mp, register FILE *fp, register int flags) { - register int i; - register int any; + register Py_ssize_t i; + register Py_ssize_t any; - i = Py_ReprEnter((PyObject*)mp); + i = (int)Py_ReprEnter((PyObject*)mp); if (i != 0) { if (i < 0) return i; @@ -896,7 +906,7 @@ PyObject *missing; static PyObject *missing_str = NULL; if (missing_str == NULL) - missing_str = + missing_str = PyString_InternFromString("__missing__"); missing = _PyType_Lookup(mp->ob_type, missing_str); if (missing != NULL) @@ -930,9 +940,9 @@ dict_keys(register dictobject *mp) { register PyObject *v; - register int i, j; + register Py_ssize_t i, j; dictentry *ep; - int mask, n; + Py_ssize_t mask, n; again: n = mp->ma_used; @@ -964,9 +974,9 @@ dict_values(register dictobject *mp) { register PyObject *v; - register int i, j; + register Py_ssize_t i, j; dictentry *ep; - int mask, n; + Py_ssize_t mask, n; again: n = mp->ma_used; @@ -998,8 +1008,8 @@ dict_items(register dictobject *mp) { register PyObject *v; - register int i, j, n; - int mask; + register Py_ssize_t i, j, n; + Py_ssize_t mask; PyObject *item, *key, *value; dictentry *ep; @@ -1132,7 +1142,7 @@ PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override) { PyObject *it; /* iter(seq2) */ - int i; /* index into seq2 of current element */ + Py_ssize_t i; /* index into seq2 of current element */ PyObject *item; /* seq2[i] */ PyObject *fast; /* item as a 2-tuple or 2-list */ @@ -1195,7 +1205,7 @@ i = -1; Return: Py_DECREF(it); - return i; + return (int)i; } int @@ -1208,7 +1218,7 @@ PyDict_Merge(PyObject *a, PyObject *b, int override) { register PyDictObject *mp, *other; - register int i; + register Py_ssize_t i; dictentry *entry; /* We accept for the argument either a concrete dictionary object, @@ -1247,7 +1257,8 @@ PyDict_GetItem(a, entry->me_key) == NULL)) { Py_INCREF(entry->me_key); Py_INCREF(entry->me_value); - insertdict(mp, entry->me_key, entry->me_hash, + insertdict(mp, entry->me_key, + (long)entry->me_hash, entry->me_value); } } @@ -1376,7 +1387,8 @@ { PyObject *akey = NULL; /* smallest key in a s.t. a[akey] != b[akey] */ PyObject *aval = NULL; /* a[akey] */ - int i, cmp; + Py_ssize_t i; + int cmp; for (i = 0; i <= a->ma_mask; i++) { PyObject *thiskey, *thisaval, *thisbval; @@ -1399,7 +1411,7 @@ * find its associated value anymore; or * maybe it is but the compare deleted the * a[thiskey] entry. - */ +| */ Py_DECREF(thiskey); continue; } @@ -1499,7 +1511,7 @@ static int dict_equal(dictobject *a, dictobject *b) { - int i; + Py_ssize_t i; if (a->ma_used != b->ma_used) /* can't be equal if # of entries differ */ @@ -1673,7 +1685,7 @@ static PyObject * dict_popitem(dictobject *mp) { - int i = 0; + Py_ssize_t i = 0; dictentry *ep; PyObject *res; @@ -1683,7 +1695,7 @@ * happened, the result would be an infinite loop (searching for an * entry that no longer exists). Note that the usual popitem() * idiom is "while d: k, v = d.popitem()". so needing to throw the - * tuple away if the dict *is* empty isn't a significant + * tuple away if the dict *is* empty isn't a significant * inefficiency -- possible, but unlikely in practice. */ res = PyTuple_New(2); @@ -1699,11 +1711,11 @@ * field of slot 0 to hold a search finger: * If slot 0 has a value, use slot 0. * Else slot 0 is being used to hold a search finger, - * and we use its hash value as the first index to look. +| * and we use its hash value as the first index to look. */ ep = &mp->ma_table[0]; if (ep->me_value == NULL) { - i = (int)ep->me_hash; + i = ep->me_hash; /* The hash field may be a real hash value, or it may be a * legit search finger, or it may be a once-legit search * finger that's out of bounds now because it wrapped around @@ -2035,10 +2047,10 @@ typedef struct { PyObject_HEAD dictobject *di_dict; /* Set to NULL when iterator is exhausted */ - int di_used; - int di_pos; + Py_ssize_t di_used; + Py_ssize_t di_pos; PyObject* di_result; /* reusable result tuple for iteritems */ - long len; + Py_ssize_t len; } dictiterobject; static PyObject * @@ -2076,10 +2088,10 @@ static PyObject * dictiter_len(dictiterobject *di) { - long len = 0; + Py_ssize_t len = 0; if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used) len = di->len; - return PyInt_FromLong(len); + return PyInt_FromSize_t(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); @@ -2092,7 +2104,7 @@ static PyObject *dictiter_iternextkey(dictiterobject *di) { PyObject *key; - register int i, mask; + register Py_ssize_t i, mask; register dictentry *ep; dictobject *d = di->di_dict; @@ -2165,7 +2177,7 @@ static PyObject *dictiter_iternextvalue(dictiterobject *di) { PyObject *value; - register int i, mask; + register Py_ssize_t i, mask; register dictentry *ep; dictobject *d = di->di_dict; @@ -2238,7 +2250,7 @@ static PyObject *dictiter_iternextitem(dictiterobject *di) { PyObject *key, *value, *result = di->di_result; - register int i, mask; + register Py_ssize_t i, mask; register dictentry *ep; dictobject *d = di->di_dict; From python-checkins at python.org Tue May 30 06:19:21 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 06:19:21 +0200 (CEST) Subject: [Python-checkins] r46545 - python/trunk/Objects/dictobject.c Message-ID: <20060530041921.5E9C11E4005@bag.python.org> Author: neal.norwitz Date: Tue May 30 06:19:21 2006 New Revision: 46545 Modified: python/trunk/Objects/dictobject.c Log: Remove stray | in comment Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 06:19:21 2006 @@ -578,7 +578,7 @@ * Quadrupling the size improves average dictionary sparseness * (reducing collisions) at the cost of some memory and iteration * speed (which loops over every possible entry). It also halves -| * the number of expensive resize operations in a growing dictionary. + * the number of expensive resize operations in a growing dictionary. * * Very large dictionaries (over 50K items) use doubling instead. * This may help applications with severe memory constraints. From python-checkins at python.org Tue May 30 06:25:08 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 06:25:08 +0200 (CEST) Subject: [Python-checkins] r46546 - python/trunk/Objects/dictobject.c Message-ID: <20060530042508.E93D51E400D@bag.python.org> Author: neal.norwitz Date: Tue May 30 06:25:05 2006 New Revision: 46546 Modified: python/trunk/Objects/dictobject.c Log: Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 06:25:05 2006 @@ -764,7 +764,7 @@ register Py_ssize_t i; register Py_ssize_t any; - i = (int)Py_ReprEnter((PyObject*)mp); + i = Py_SAFE_DOWNCAST(Py_ReprEnter((PyObject*)mp), Py_ssize_t, int); if (i != 0) { if (i < 0) return i; @@ -1172,14 +1172,14 @@ if (PyErr_ExceptionMatches(PyExc_TypeError)) PyErr_Format(PyExc_TypeError, "cannot convert dictionary update " - "sequence element #%d to a sequence", + "sequence element #%zd to a sequence", i); goto Fail; } n = PySequence_Fast_GET_SIZE(fast); if (n != 2) { PyErr_Format(PyExc_ValueError, - "dictionary update sequence element #%d " + "dictionary update sequence element #%zd " "has length %zd; 2 is required", i, n); goto Fail; @@ -1205,7 +1205,7 @@ i = -1; Return: Py_DECREF(it); - return (int)i; + return Py_SAFE_DOWNCAST(i, Py_ssize_t, int); } int @@ -1411,7 +1411,7 @@ * find its associated value anymore; or * maybe it is but the compare deleted the * a[thiskey] entry. -| */ + */ Py_DECREF(thiskey); continue; } @@ -1711,7 +1711,7 @@ * field of slot 0 to hold a search finger: * If slot 0 has a value, use slot 0. * Else slot 0 is being used to hold a search finger, -| * and we use its hash value as the first index to look. + * and we use its hash value as the first index to look. */ ep = &mp->ma_table[0]; if (ep->me_value == NULL) { From python-checkins at python.org Tue May 30 06:43:24 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 06:43:24 +0200 (CEST) Subject: [Python-checkins] r46547 - python/trunk/Objects/dictobject.c Message-ID: <20060530044324.40E7B1E4005@bag.python.org> Author: neal.norwitz Date: Tue May 30 06:43:23 2006 New Revision: 46547 Modified: python/trunk/Objects/dictobject.c Log: No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 06:43:23 2006 @@ -764,7 +764,7 @@ register Py_ssize_t i; register Py_ssize_t any; - i = Py_SAFE_DOWNCAST(Py_ReprEnter((PyObject*)mp), Py_ssize_t, int); + i = Py_ReprEnter((PyObject*)mp); if (i != 0) { if (i < 0) return i; From buildbot at python.org Tue May 30 06:54:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 04:54:20 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060530045420.8BFE91E4005@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/508 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From tim.peters at gmail.com Tue May 30 07:03:06 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 30 May 2006 01:03:06 -0400 Subject: [Python-checkins] r46546 - python/trunk/Objects/dictobject.c In-Reply-To: <20060530042508.E93D51E400D@bag.python.org> References: <20060530042508.E93D51E400D@bag.python.org> Message-ID: <1f7befae0605292203n1603c214p91f8407fbdd8e5b6@mail.gmail.com> > Author: neal.norwitz > Date: Tue May 30 06:25:05 2006 > New Revision: 46546 > > Modified: > python/trunk/Objects/dictobject.c > Log: > Use Py_SAFE_DOWNCAST for safety. It's not needed here, and this will actually cause debug-build failures: > - i = (int)Py_ReprEnter((PyObject*)mp); > + i = Py_SAFE_DOWNCAST(Py_ReprEnter((PyObject*)mp), Py_ssize_t, int); because the macro evaluates its first argument more than once (and will increment the repr depth counter as a side effect each time, so that the function doesn't return the same value each time). > Fix format strings. Good catch! Thank you. > Remove 2 more stray | in comment Grrrr. My desktop box apparently missed me so much last week that its keyboard developed this weird stutter. I'm not actually pressing "|"! The keyboard just spits one out at times, perhaps expressing its happiness at being used again. It will get over it. From python-checkins at python.org Tue May 30 07:05:00 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 07:05:00 +0200 (CEST) Subject: [Python-checkins] r46548 - python/trunk/Objects/dictobject.c Message-ID: <20060530050500.490301E4005@bag.python.org> Author: tim.peters Date: Tue May 30 07:04:59 2006 New Revision: 46548 Modified: python/trunk/Objects/dictobject.c Log: dict_print(): Explicitly narrow the return value from a (possibly) wider variable. Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 07:04:59 2006 @@ -767,7 +767,7 @@ i = Py_ReprEnter((PyObject*)mp); if (i != 0) { if (i < 0) - return i; + return (int)i; fprintf(fp, "{...}"); return 0; } From nnorwitz at gmail.com Tue May 30 07:12:33 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 29 May 2006 22:12:33 -0700 Subject: [Python-checkins] r46546 - python/trunk/Objects/dictobject.c In-Reply-To: <1f7befae0605292203n1603c214p91f8407fbdd8e5b6@mail.gmail.com> References: <20060530042508.E93D51E400D@bag.python.org> <1f7befae0605292203n1603c214p91f8407fbdd8e5b6@mail.gmail.com> Message-ID: On 5/29/06, Tim Peters wrote: > > Author: neal.norwitz > > Date: Tue May 30 06:25:05 2006 > > New Revision: 46546 > > > > Modified: > > python/trunk/Objects/dictobject.c > > Log: > > Use Py_SAFE_DOWNCAST for safety. > > It's not needed here, and this will actually cause debug-build failures: I first noticed it wasn't needed when I was reviewing my own checkin. :-) I fixed (removed) it. I see you fixed another place that required a cast, shouldn't that really use Py_SAFE_DOWNCAST? n From tim.peters at gmail.com Tue May 30 07:18:49 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 30 May 2006 01:18:49 -0400 Subject: [Python-checkins] r46546 - python/trunk/Objects/dictobject.c In-Reply-To: References: <20060530042508.E93D51E400D@bag.python.org> <1f7befae0605292203n1603c214p91f8407fbdd8e5b6@mail.gmail.com> Message-ID: <1f7befae0605292218l2b9a70e6rdd387c13e4238112@mail.gmail.com> [Neal] > I first noticed it wasn't needed when I was reviewing my own checkin. > :-) I fixed (removed) it. I see you fixed another place that > required a cast, shouldn't that really use Py_SAFE_DOWNCAST? Not really needed, since Py_ReprEnter currently returns an int: register Py_ssize_t i; register Py_ssize_t any; i = Py_ReprEnter((PyObject*)mp); if (i != 0) { if (i < 0) return (int)i; The value of i isn't going to stop fitting in an int just because it gets compared to 0 ;-) I suppose what would _really_ be clearer is declaring an additional int variable here. `i` just happens to be reused now, for conceptually different purposes, in this block of code and the rest of the routine. From python-checkins at python.org Tue May 30 07:23:59 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 07:23:59 +0200 (CEST) Subject: [Python-checkins] r46549 - python/trunk/Objects/dictobject.c Message-ID: <20060530052359.82CE51E4005@bag.python.org> Author: tim.peters Date: Tue May 30 07:23:59 2006 New Revision: 46549 Modified: python/trunk/Objects/dictobject.c Log: dict_print(): So that Neal & I don't spend the rest of our lives taking turns rewriting code that works ;-), get rid of casting illusions by declaring a new variable with the obvious type. Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue May 30 07:23:59 2006 @@ -763,11 +763,12 @@ { register Py_ssize_t i; register Py_ssize_t any; + int status; - i = Py_ReprEnter((PyObject*)mp); - if (i != 0) { - if (i < 0) - return (int)i; + status = Py_ReprEnter((PyObject*)mp); + if (status != 0) { + if (status < 0) + return status; fprintf(fp, "{...}"); return 0; } From buildbot at python.org Tue May 30 07:55:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 05:55:13 +0000 Subject: [Python-checkins] buildbot failure in amd64 gentoo trunk Message-ID: <20060530055513.C9D1B1E4005@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/864 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Tue May 30 08:02:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 06:02:12 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060530060212.520841E4005@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/594 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 09:04:56 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 09:04:56 +0200 (CEST) Subject: [Python-checkins] r46550 - python/trunk/Objects/exceptions.c Message-ID: <20060530070456.5C60B1E4005@bag.python.org> Author: georg.brandl Date: Tue May 30 09:04:55 2006 New Revision: 46550 Modified: python/trunk/Objects/exceptions.c Log: Restore exception pickle support. #1497319. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Tue May 30 09:04:55 2006 @@ -141,7 +141,17 @@ static PyObject * BaseException_reduce(PyBaseExceptionObject *self) { - return PyTuple_Pack(3, self->ob_type, self->args, self->dict); + if (self->args && self->dict) + return PyTuple_Pack(3, self->ob_type, self->args, self->dict); + else if (self->args) + return PyTuple_Pack(2, self->ob_type, self->args); + else { + PyObject *res, *tup = PyTuple_New(0); + if (!tup) return NULL; + res = PyTuple_Pack(2, self->ob_type, tup); + Py_DECREF(tup); + return res; + } } From python-checkins at python.org Tue May 30 09:13:35 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 09:13:35 +0200 (CEST) Subject: [Python-checkins] r46551 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060530071335.51C6F1E4005@bag.python.org> Author: georg.brandl Date: Tue May 30 09:13:29 2006 New Revision: 46551 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Objects/exceptions.c Log: Add a test case for exception pickling. args is never NULL. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Tue May 30 09:13:29 2006 @@ -270,6 +270,8 @@ 'winerror' : 1 })) except NameError: pass +import pickle, random + for args in exceptionList: expected = args[-1] try: @@ -283,3 +285,14 @@ ( repr(e), checkArgName, repr(expected[checkArgName]), repr(getattr(e, checkArgName)) )) + + # test for pickling support + new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) + for checkArgName in expected.keys(): + if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]): + raise TestFailed('Checking unpickled exception arguments, ' + 'exception ' + '"%s", attribute "%s" expected %s got %s.' % + ( repr(e), checkArgName, + repr(expected[checkArgName]), + repr(getattr(e, checkArgName)) )) Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Tue May 30 09:13:29 2006 @@ -143,15 +143,8 @@ { if (self->args && self->dict) return PyTuple_Pack(3, self->ob_type, self->args, self->dict); - else if (self->args) + else return PyTuple_Pack(2, self->ob_type, self->args); - else { - PyObject *res, *tup = PyTuple_New(0); - if (!tup) return NULL; - res = PyTuple_Pack(2, self->ob_type, tup); - Py_DECREF(tup); - return res; - } } @@ -667,6 +660,7 @@ { PyObject *args = self->args; PyObject *res = NULL, *tmp; + /* self->args is only the first two real arguments if there was a * file name given to EnvironmentError. */ if (PyTuple_GET_SIZE(args) == 2 && self->filename) { @@ -683,10 +677,13 @@ Py_INCREF(self->filename); PyTuple_SET_ITEM(args, 2, self->filename); - } else { + } else Py_INCREF(args); - } - res = PyTuple_Pack(3, self->ob_type, args, self->dict); + + if (self->dict) + res = PyTuple_Pack(3, self->ob_type, args, self->dict); + else + res = PyTuple_Pack(2, self->ob_type, args); Py_DECREF(args); return res; } From python-checkins at python.org Tue May 30 09:21:11 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 09:21:11 +0200 (CEST) Subject: [Python-checkins] r46552 - python/trunk/Lib/test/test_repr.py Message-ID: <20060530072111.4AD321E4008@bag.python.org> Author: neal.norwitz Date: Tue May 30 09:21:10 2006 New Revision: 46552 Modified: python/trunk/Lib/test/test_repr.py Log: Don't fail if the (sub)pkgname already exist. Modified: python/trunk/Lib/test/test_repr.py ============================================================================== --- python/trunk/Lib/test/test_repr.py (original) +++ python/trunk/Lib/test/test_repr.py Tue May 30 09:21:10 2006 @@ -5,6 +5,7 @@ import sys import os +import shutil import unittest from test.test_support import run_unittest @@ -198,8 +199,10 @@ self.pkgname = os.path.join(longname) self.subpkgname = os.path.join(longname, longname) # Make the package and subpackage + shutil.rmtree(self.pkgname, ignore_errors=True) os.mkdir(self.pkgname) touch(os.path.join(self.pkgname, '__init__'+os.extsep+'py')) + shutil.rmtree(self.subpkgname, ignore_errors=True) os.mkdir(self.subpkgname) touch(os.path.join(self.subpkgname, '__init__'+os.extsep+'py')) # Remember where we are From python-checkins at python.org Tue May 30 09:34:46 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 09:34:46 +0200 (CEST) Subject: [Python-checkins] r46553 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060530073446.7F2FD1E4009@bag.python.org> Author: georg.brandl Date: Tue May 30 09:34:45 2006 New Revision: 46553 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Objects/exceptions.c Log: Disallow keyword args for exceptions. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Tue May 30 09:34:45 2006 @@ -296,3 +296,10 @@ ( repr(e), checkArgName, repr(expected[checkArgName]), repr(getattr(e, checkArgName)) )) + +try: + BaseException(a=1) +except TypeErrror: + pass +else: + raise TestFailed("BaseException shouldn't take keyword args") Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Tue May 30 09:34:45 2006 @@ -32,6 +32,9 @@ { PyBaseExceptionObject *self; + if (!_PyArg_NoKeywords("BaseException", kwds)) + return NULL; + self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); /* the dict is created on the fly in PyObject_GenericSetAttr */ self->message = self->dict = NULL; From python-checkins at python.org Tue May 30 09:36:55 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 30 May 2006 09:36:55 +0200 (CEST) Subject: [Python-checkins] r46554 - python/trunk/Makefile.pre.in Message-ID: <20060530073655.444331E4006@bag.python.org> Author: neal.norwitz Date: Tue May 30 09:36:54 2006 New Revision: 46554 Modified: python/trunk/Makefile.pre.in Log: I'm impatient. I think this will fix a few more problems with the buildbots. I'm not sure this is the best approach, but I can't think of anything better. If this creates problems, feel free to revert, but I think it's safe and should make things a little better. Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Tue May 30 09:36:54 2006 @@ -594,8 +594,17 @@ $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall +# These two force rules are only used for buildbottest. +# - cleanup tries to cleanup after broken tests. +# - setup ensures that we are using the latest version of Modules/Setup.dist. +forcecleanup: + -rm -rf $(srcdir)/@test* + +forcesetup: + cp $(srcdir)/Modules/Setup.dist $(srcdir)/Modules/Setup + # Like testall, but with a single pass only -buildbottest: all platform +buildbottest: forcecleanup forcesetup all platform $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ From buildbot at python.org Tue May 30 09:54:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 07:54:43 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060530075443.C43A31E4005@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/866 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 30 10:00:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 08:00:02 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060530080002.7861C1E4005@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/964 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 30 10:14:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 08:14:59 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060530081459.5421F1E4005@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/887 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 10:17:01 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 10:17:01 +0200 (CEST) Subject: [Python-checkins] r46555 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060530081701.BE50A1E4006@bag.python.org> Author: georg.brandl Date: Tue May 30 10:17:00 2006 New Revision: 46555 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Objects/exceptions.c Log: Do the check for no keyword arguments in __init__ so that subclasses of Exception can be supplied keyword args Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Tue May 30 10:17:00 2006 @@ -299,7 +299,7 @@ try: BaseException(a=1) -except TypeErrror: +except TypeError: pass else: raise TestFailed("BaseException shouldn't take keyword args") Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Tue May 30 10:17:00 2006 @@ -32,9 +32,6 @@ { PyBaseExceptionObject *self; - if (!_PyArg_NoKeywords("BaseException", kwds)) - return NULL; - self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); /* the dict is created on the fly in PyObject_GenericSetAttr */ self->message = self->dict = NULL; @@ -57,6 +54,9 @@ static int BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) { + if (!_PyArg_NoKeywords(self->ob_type->tp_name, kwds)) + return -1; + Py_DECREF(self->args); self->args = args; Py_INCREF(self->args); From buildbot at python.org Tue May 30 10:24:54 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 08:24:54 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060530082455.0EECE1E4005@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/840 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 30 10:32:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 08:32:12 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060530083212.6748E1E4005@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/591 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 30 10:47:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 08:47:02 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060530084702.441B61E4005@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/873 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 10:47:25 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 30 May 2006 10:47:25 +0200 (CEST) Subject: [Python-checkins] r46556 - in python/trunk/Lib/test: output/test_exceptions test_exceptions.py Message-ID: <20060530084725.495601E4005@bag.python.org> Author: georg.brandl Date: Tue May 30 10:47:19 2006 New Revision: 46556 Removed: python/trunk/Lib/test/output/test_exceptions Modified: python/trunk/Lib/test/test_exceptions.py Log: Convert test_exceptions to unittest. Deleted: /python/trunk/Lib/test/output/test_exceptions ============================================================================== --- /python/trunk/Lib/test/output/test_exceptions Tue May 30 10:47:19 2006 +++ (empty file) @@ -1,52 +0,0 @@ -test_exceptions -5. Built-in exceptions -spam -AttributeError -spam -EOFError -spam -IOError -spam -ImportError -spam -IndexError -'spam' -KeyError -spam -KeyboardInterrupt -(not testable in a script) -spam -MemoryError -(not safe to test) -spam -NameError -spam -OverflowError -spam -RuntimeError -(not used any more?) -spam -SyntaxError -'continue' not supported inside 'finally' clause -ok -'continue' not properly in loop -ok -'continue' not properly in loop -ok -spam -IndentationError -spam -TabError -spam -SystemError -(hard to reproduce) -spam -SystemExit -spam -TypeError -spam -ValueError -spam -ZeroDivisionError -spam -Exception Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Tue May 30 10:47:19 2006 @@ -1,305 +1,295 @@ # Python test set -- part 5, built-in exceptions -from test.test_support import TestFailed, TESTFN, unlink -from types import ClassType +from test.test_support import TESTFN, unlink, run_unittest import warnings import sys, traceback, os +import unittest -print '5. Built-in exceptions' # XXX This is not really enough, each *operation* should be tested! -# Reloading the built-in exceptions module failed prior to Py2.2, while it -# should act the same as reloading built-in sys. -try: - import exceptions - reload(exceptions) -except ImportError, e: - raise TestFailed, e - -def test_raise_catch(exc): - try: - raise exc, "spam" - except exc, err: - buf = str(err) - try: - raise exc("spam") - except exc, err: - buf = str(err) - print buf - -def r(thing): - test_raise_catch(thing) - print getattr(thing, '__name__', thing) - -r(AttributeError) -import sys -try: x = sys.undefined_attribute -except AttributeError: pass - -r(EOFError) -import sys -fp = open(TESTFN, 'w') -fp.close() -fp = open(TESTFN, 'r') -savestdin = sys.stdin -try: - try: - sys.stdin = fp - x = raw_input() - except EOFError: - pass -finally: - sys.stdin = savestdin - fp.close() - -r(IOError) -try: open('this file does not exist', 'r') -except IOError: pass - -r(ImportError) -try: import undefined_module -except ImportError: pass - -r(IndexError) -x = [] -try: a = x[10] -except IndexError: pass - -r(KeyError) -x = {} -try: a = x['key'] -except KeyError: pass - -r(KeyboardInterrupt) -print '(not testable in a script)' - -r(MemoryError) -print '(not safe to test)' - -r(NameError) -try: x = undefined_variable -except NameError: pass - -r(OverflowError) -x = 1 -for dummy in range(128): - x += x # this simply shouldn't blow up - -r(RuntimeError) -print '(not used any more?)' - -r(SyntaxError) -try: exec '/\n' -except SyntaxError: pass - -# make sure the right exception message is raised for each of these -# code fragments: - -def ckmsg(src, msg): - try: - compile(src, '', 'exec') - except SyntaxError, e: - print e.msg - if e.msg == msg: - print "ok" - else: - print "expected:", msg - else: - print "failed to get expected SyntaxError" - -s = '''\ -while 1: - try: - pass - finally: - continue -''' -if sys.platform.startswith('java'): - print "'continue' not supported inside 'finally' clause" - print "ok" -else: - ckmsg(s, "'continue' not supported inside 'finally' clause") -s = '''\ -try: - continue -except: - pass -''' -ckmsg(s, "'continue' not properly in loop") -ckmsg("continue\n", "'continue' not properly in loop") - -r(IndentationError) - -r(TabError) -# can only be tested under -tt, and is the only test for -tt -#try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n", '', 'exec') -#except TabError: pass -#else: raise TestFailed - -r(SystemError) -print '(hard to reproduce)' - -r(SystemExit) -import sys -try: sys.exit(0) -except SystemExit: pass - -r(TypeError) -try: [] + () -except TypeError: pass - -r(ValueError) -try: x = chr(10000) -except ValueError: pass - -r(ZeroDivisionError) -try: x = 1/0 -except ZeroDivisionError: pass - -r(Exception) -try: x = 1/0 -except Exception, e: pass - -# test that setting an exception at the C level works even if the -# exception object can't be constructed. - -class BadException: - def __init__(self): - raise RuntimeError, "can't instantiate BadException" - -def test_capi1(): - import _testcapi - try: - _testcapi.raise_exception(BadException, 1) - except TypeError, err: - exc, err, tb = sys.exc_info() - co = tb.tb_frame.f_code - assert co.co_name == "test_capi1" - assert co.co_filename.endswith('test_exceptions'+os.extsep+'py') - else: - print "Expected exception" - -def test_capi2(): - import _testcapi - try: - _testcapi.raise_exception(BadException, 0) - except RuntimeError, err: - exc, err, tb = sys.exc_info() - co = tb.tb_frame.f_code - assert co.co_name == "__init__" - assert co.co_filename.endswith('test_exceptions'+os.extsep+'py') - co2 = tb.tb_frame.f_back.f_code - assert co2.co_name == "test_capi2" - else: - print "Expected exception" - -if not sys.platform.startswith('java'): - test_capi1() - test_capi2() - -unlink(TESTFN) - -# test that exception attributes are happy. -try: str(u'Hello \u00E1') -except Exception, e: sampleUnicodeEncodeError = e -try: unicode('\xff') -except Exception, e: sampleUnicodeDecodeError = e -exceptionList = [ - ( BaseException, (), { 'message' : '', 'args' : () }), - ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), - ( BaseException, ('foo', ), { 'message' : 'foo', 'args' : ( 'foo', ) }), - ( BaseException, ('foo', 1), { 'message' : '', 'args' : ( 'foo', 1 ) }), - ( SystemExit, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), - 'code' : 'foo' }), - ( IOError, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), }), - ( IOError, ('foo', 'bar'), { 'message' : '', - 'args' : ('foo', 'bar'), }), - ( IOError, ('foo', 'bar', 'baz'), - { 'message' : '', 'args' : ('foo', 'bar'), }), - ( EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), - { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), - 'strerror' : 'strErrorStr', - 'errno' : 'errnoStr', 'filename' : 'filenameStr' }), - ( EnvironmentError, (1, 'strErrorStr', 'filenameStr'), - { 'message' : '', 'args' : (1, 'strErrorStr'), - 'strerror' : 'strErrorStr', 'errno' : 1, - 'filename' : 'filenameStr' }), - ( SyntaxError, ('msgStr',), - { 'message' : 'msgStr', 'args' : ('msgStr', ), - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : None, 'lineno' : None, 'offset' : None, - 'text' : None }), - ( SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', - 'textStr')), - { 'message' : '', 'args' : ('msgStr', ('filenameStr', - 'linenoStr', 'offsetStr', 'textStr' )), - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : 'filenameStr', 'lineno' : 'linenoStr', - 'offset' : 'offsetStr', 'text' : 'textStr' }), - ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', - 'textStr', 'print_file_and_lineStr'), - { 'message' : '', 'args' : ('msgStr', 'filenameStr', - 'linenoStr', 'offsetStr', 'textStr', - 'print_file_and_lineStr'), - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : None, 'lineno' : None, 'offset' : None, - 'text' : None }), - ( UnicodeError, (), - { 'message' : '', 'args' : (), }), - ( sampleUnicodeEncodeError, - { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)' }), - ( sampleUnicodeDecodeError, - { 'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)' }), - ( UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), - { 'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), - 'object' : u'\u3042', 'reason' : 'ouch', - 'start' : 0, 'end' : 1 }), - ] -try: - exceptionList.append( - ( WindowsError, (1, 'strErrorStr', 'filenameStr'), - { 'message' : '', 'args' : (1, 'strErrorStr'), - 'strerror' : 'strErrorStr', - 'errno' : 22, 'filename' : 'filenameStr', - 'winerror' : 1 })) -except NameError: pass - -import pickle, random - -for args in exceptionList: - expected = args[-1] - try: - if len(args) == 2: raise args[0] - else: raise apply(args[0], args[1]) - except BaseException, e: - for checkArgName in expected.keys(): - if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]): - raise TestFailed('Checking exception arguments, exception ' - '"%s", attribute "%s" expected %s got %s.' % - ( repr(e), checkArgName, - repr(expected[checkArgName]), - repr(getattr(e, checkArgName)) )) +class ExceptionTests(unittest.TestCase): + + def testReload(self): + # Reloading the built-in exceptions module failed prior to Py2.2, while it + # should act the same as reloading built-in sys. + try: + import exceptions + reload(exceptions) + except ImportError, e: + self.fail("reloading exceptions: %s" % e) + + def raise_catch(self, exc, excname): + try: + raise exc, "spam" + except exc, err: + buf1 = str(err) + try: + raise exc("spam") + except exc, err: + buf2 = str(err) + self.assertEquals(buf1, buf2) + self.assertEquals(exc.__name__, excname) + + def testRaising(self): + self.raise_catch(AttributeError, "AttributeError") + self.assertRaises(AttributeError, getattr, sys, "undefined_attribute") + + self.raise_catch(EOFError, "EOFError") + fp = open(TESTFN, 'w') + fp.close() + fp = open(TESTFN, 'r') + savestdin = sys.stdin + try: + try: + sys.stdin = fp + x = raw_input() + except EOFError: + pass + finally: + sys.stdin = savestdin + fp.close() + unlink(TESTFN) + + self.raise_catch(IOError, "IOError") + self.assertRaises(IOError, open, 'this file does not exist', 'r') + + self.raise_catch(ImportError, "ImportError") + self.assertRaises(ImportError, __import__, "undefined_module") + + self.raise_catch(IndexError, "IndexError") + x = [] + self.assertRaises(IndexError, x.__getitem__, 10) + + self.raise_catch(KeyError, "KeyError") + x = {} + self.assertRaises(KeyError, x.__getitem__, 'key') + + self.raise_catch(KeyboardInterrupt, "KeyboardInterrupt") + + self.raise_catch(MemoryError, "MemoryError") + + self.raise_catch(NameError, "NameError") + try: x = undefined_variable + except NameError: pass + + self.raise_catch(OverflowError, "OverflowError") + x = 1 + for dummy in range(128): + x += x # this simply shouldn't blow up + + self.raise_catch(RuntimeError, "RuntimeError") + + self.raise_catch(SyntaxError, "SyntaxError") + try: exec '/\n' + except SyntaxError: pass + + self.raise_catch(IndentationError, "IndentationError") + + self.raise_catch(TabError, "TabError") + # can only be tested under -tt, and is the only test for -tt + #try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n", '', 'exec') + #except TabError: pass + #else: self.fail("TabError not raised") + + self.raise_catch(SystemError, "SystemError") + + self.raise_catch(SystemExit, "SystemExit") + self.assertRaises(SystemExit, sys.exit, 0) + + self.raise_catch(TypeError, "TypeError") + try: [] + () + except TypeError: pass + + self.raise_catch(ValueError, "ValueError") + self.assertRaises(ValueError, chr, 10000) + + self.raise_catch(ZeroDivisionError, "ZeroDivisionError") + try: x = 1/0 + except ZeroDivisionError: pass + + self.raise_catch(Exception, "Exception") + try: x = 1/0 + except Exception, e: pass + + def testSyntaxErrorMessage(self): + """make sure the right exception message is raised for each of + these code fragments""" + + def ckmsg(src, msg): + try: + compile(src, '', 'exec') + except SyntaxError, e: + if e.msg != msg: + self.fail("expected %s, got %s" % (msg, e.msg)) + else: + self.fail("failed to get expected SyntaxError") + + s = '''while 1: + try: + pass + finally: + continue''' + + if not sys.platform.startswith('java'): + ckmsg(s, "'continue' not supported inside 'finally' clause") + + s = '''if 1: + try: + continue + except: + pass''' + + ckmsg(s, "'continue' not properly in loop") + ckmsg("continue\n", "'continue' not properly in loop") + + def testSettingException(self): + """test that setting an exception at the C level works even if the + exception object can't be constructed.""" + + class BadException: + def __init__(self_): + raise RuntimeError, "can't instantiate BadException" + + def test_capi1(): + import _testcapi + try: + _testcapi.raise_exception(BadException, 1) + except TypeError, err: + exc, err, tb = sys.exc_info() + co = tb.tb_frame.f_code + self.assertEquals(co.co_name, "test_capi1") + self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) + else: + self.fail("Expected exception") + + def test_capi2(): + import _testcapi + try: + _testcapi.raise_exception(BadException, 0) + except RuntimeError, err: + exc, err, tb = sys.exc_info() + co = tb.tb_frame.f_code + self.assertEquals(co.co_name, "__init__") + self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) + co2 = tb.tb_frame.f_back.f_code + self.assertEquals(co2.co_name, "test_capi2") + else: + self.fail("Expected exception") + + if not sys.platform.startswith('java'): + test_capi1() + test_capi2() + + def testAttributes(self): + """test that exception attributes are happy.""" + try: str(u'Hello \u00E1') + except Exception, e: sampleUnicodeEncodeError = e + + try: unicode('\xff') + except Exception, e: sampleUnicodeDecodeError = e - # test for pickling support - new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) - for checkArgName in expected.keys(): - if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]): - raise TestFailed('Checking unpickled exception arguments, ' - 'exception ' - '"%s", attribute "%s" expected %s got %s.' % - ( repr(e), checkArgName, - repr(expected[checkArgName]), - repr(getattr(e, checkArgName)) )) - -try: - BaseException(a=1) -except TypeError: - pass -else: - raise TestFailed("BaseException shouldn't take keyword args") + exceptionList = [ + ( BaseException, (), { 'message' : '', 'args' : () }), + ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), + ( BaseException, ('foo', ), { 'message' : 'foo', 'args' : ( 'foo', ) }), + ( BaseException, ('foo', 1), { 'message' : '', 'args' : ( 'foo', 1 ) }), + ( SystemExit, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), + 'code' : 'foo' }), + ( IOError, ('foo',), { 'message' : 'foo', 'args' : ( 'foo', ), }), + ( IOError, ('foo', 'bar'), { 'message' : '', + 'args' : ('foo', 'bar'), }), + ( IOError, ('foo', 'bar', 'baz'), + { 'message' : '', 'args' : ('foo', 'bar'), }), + ( EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : ('errnoStr', 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 'errnoStr', 'filename' : 'filenameStr' }), + ( EnvironmentError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), + 'strerror' : 'strErrorStr', 'errno' : 1, + 'filename' : 'filenameStr' }), + ( SyntaxError, ('msgStr',), + { 'message' : 'msgStr', 'args' : ('msgStr', ), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', + 'textStr')), + { 'message' : '', 'args' : ('msgStr', ('filenameStr', + 'linenoStr', 'offsetStr', 'textStr' )), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : 'filenameStr', 'lineno' : 'linenoStr', + 'offset' : 'offsetStr', 'text' : 'textStr' }), + ( SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', + 'textStr', 'print_file_and_lineStr'), + { 'message' : '', 'args' : ('msgStr', 'filenameStr', + 'linenoStr', 'offsetStr', 'textStr', + 'print_file_and_lineStr'), + 'print_file_and_line' : None, 'msg' : 'msgStr', + 'filename' : None, 'lineno' : None, 'offset' : None, + 'text' : None }), + ( UnicodeError, (), + { 'message' : '', 'args' : (), }), + ( sampleUnicodeEncodeError, + { 'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : u'Hello \xe1', + 'start' : 6, 'reason' : 'ordinal not in range(128)' }), + ( sampleUnicodeDecodeError, + { 'message' : '', 'args' : ('ascii', '\xff', 0, 1, + 'ordinal not in range(128)'), + 'encoding' : 'ascii', 'object' : '\xff', + 'start' : 0, 'reason' : 'ordinal not in range(128)' }), + ( UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), + { 'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), + 'object' : u'\u3042', 'reason' : 'ouch', + 'start' : 0, 'end' : 1 }), + ] + try: + exceptionList.append( + ( WindowsError, (1, 'strErrorStr', 'filenameStr'), + { 'message' : '', 'args' : (1, 'strErrorStr'), + 'strerror' : 'strErrorStr', + 'errno' : 22, 'filename' : 'filenameStr', + 'winerror' : 1 })) + except NameError: pass + + import pickle, random + + for args in exceptionList: + expected = args[-1] + try: + if len(args) == 2: raise args[0] + else: raise apply(args[0], args[1]) + except BaseException, e: + for checkArgName in expected.keys(): + self.assertEquals(repr(getattr(e, checkArgName)), + repr(expected[checkArgName]), + 'exception "%s", attribute "%s"' % + (repr(e), checkArgName)) + + # test for pickling support + new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) + for checkArgName in expected.keys(): + self.assertEquals(repr(getattr(e, checkArgName)), + repr(expected[checkArgName]), + 'pickled exception "%s", attribute "%s' % + (repr(e), checkArgName)) + + def testKeywordArgs(self): + """test that builtin exception don't take keyword args, + but user-defined subclasses can if they want""" + self.assertRaises(TypeError, BaseException, a=1) + class DerivedException(BaseException): + def __init__(self, fancy_arg): + BaseException.__init__(self) + self.fancy_arg = fancy_arg + + x = DerivedException(fancy_arg=42) + self.assertEquals(x.fancy_arg, 42) + +def test_main(): + run_unittest(ExceptionTests) + +if __name__ == '__main__': + test_main() From buildbot at python.org Tue May 30 13:17:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 11:17:10 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060530111710.26E931E4005@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/325 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 14:52:01 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 30 May 2006 14:52:01 +0200 (CEST) Subject: [Python-checkins] r46557 - python/trunk/Misc/developers.txt Message-ID: <20060530125201.986D81E4005@bag.python.org> Author: andrew.kuchling Date: Tue May 30 14:52:01 2006 New Revision: 46557 Modified: python/trunk/Misc/developers.txt Log: Add SoC name, and reorganize this section a bit Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Tue May 30 14:52:01 2006 @@ -17,13 +17,19 @@ Permissions History ------------------- -- 2006 Summer of Code entries: Matt Fleming was added on 25 May 2006 - by AMK; he'll be working on enhancing the Python debugger. Jackilyn - Hoxworth was added on 25 May 2005 by AMK; she'll be adding logging - to the standard library. SoC developers are expected to work +- 2006 Summer of Code entries: SoC developers are expected to work primarily in nondist/sandbox or on a branch of their own, and will have their work reviewed before changes are accepted into the trunk. + - Matt Fleming was added on 25 May 2006 by AMK; he'll be working on + enhancing the Python debugger. + + - Jackilyn Hoxworth was added on 25 May 2006 by AMK; she'll be adding logging + to the standard library. + + - Mateusz Rukowicz was added on 30 May 2006 by AMK; he'll be + translating the decimal module into C. + - SVN access granted to the "Need for Speed" Iceland sprint attendees, between May 17 and 21, 2006, by Tim Peters. All work is to be done in new sandbox projects or on new branches, with merging to the From python-checkins at python.org Tue May 30 15:08:43 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 30 May 2006 15:08:43 +0200 (CEST) Subject: [Python-checkins] r46558 - sandbox/trunk/Doc/functional.rst Message-ID: <20060530130843.E470D1E4005@bag.python.org> Author: andrew.kuchling Date: Tue May 30 15:08:43 2006 New Revision: 46558 Modified: sandbox/trunk/Doc/functional.rst Log: Add two more examples for takewhile() and dropwhile() Modified: sandbox/trunk/Doc/functional.rst ============================================================================== --- sandbox/trunk/Doc/functional.rst (original) +++ sandbox/trunk/Doc/functional.rst Tue May 30 15:08:43 2006 @@ -756,6 +756,9 @@ itertools.takewhile(less_than_10, itertools.count()) => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + itertools.takewhile(is_even, itertools.count()) => + 0 + ``itertools.dropwhile(predicate, iter)`` discards elements while the predicate returns true, and then returns the rest of the iterable's results. @@ -765,6 +768,9 @@ itertools.dropwhile(less_than_10, itertools.count()) => 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ... + itertools.dropwhile(is_even, itertools.count()) => + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... + The last function, ``itertools.groupby(iter, key_func=None)``, is the most complicated. ``key_func(elem)`` is a function that can compute a @@ -820,6 +826,15 @@ The functools module ---------------------------------------------- + +Acknowledgements +------------------------------ + +The author would like to thank the following people for offering +suggestions, corrections and assistance with various drafts of this +article: Jim Jewett. + + .. comment Introduction From python-checkins at python.org Tue May 30 17:53:35 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 30 May 2006 17:53:35 +0200 (CEST) Subject: [Python-checkins] r46559 - python/trunk/Objects/longobject.c Message-ID: <20060530155335.4A7CF1E4005@bag.python.org> Author: tim.peters Date: Tue May 30 17:53:34 2006 New Revision: 46559 Modified: python/trunk/Objects/longobject.c Log: PyLong_FromString(): Continued fraction analysis (explained in a new comment) suggests there are almost certainly large input integers in all non-binary input bases for which one Python digit too few is initally allocated to hold the final result. Instead of assert-failing when that happens, allocate more space. Alas, I estimate it would take a few days to find a specific such case, so this isn't backed up by a new test (not to mention that such a case may take hours to run, since conversion time is quadratic in the number of digits, and preliminary attempts suggested that the smallest such inputs contain at least a million digits). Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Tue May 30 17:53:34 2006 @@ -1509,6 +1509,57 @@ (((c0*B + c1)*B + c2)*B + c3)*B + ... ))) + c_n-1 where B = convmultmax_base[base]. + +Error analysis: as above, the number of Python digits `n` needed is worst- +case + + n >= N * log(B)/log(BASE) + +where `N` is the number of input digits in base `B`. This is computed via + + size_z = (Py_ssize_t)((scan - str) * log_base_BASE[base]) + 1; + +below. Two numeric concerns are how much space this can waste, and whether +the computed result can be too small. To be concrete, assume BASE = 2**15, +which is the default (and it's unlikely anyone changes that). + +Waste isn't a problem: provided the first input digit isn't 0, the difference +between the worst-case input with N digits and the smallest input with N +digits is about a factor of B, but B is small compared to BASE so at most +one allocated Python digit can remain unused on that count. If +N*log(B)/log(BASE) is mathematically an exact integer, then truncating that +and adding 1 returns a result 1 larger than necessary. However, that can't +happen: whenever B is a power of 2, long_from_binary_base() is called +instead, and it's impossible for B**i to be an integer power of 2**15 when +B is not a power of 2 (i.e., it's impossible for N*log(B)/log(BASE) to be +an exact integer when B is not a power of 2, since B**i has a prime factor +other than 2 in that case, but (2**15)**j's only prime factor is 2). + +The computed result can be too small if the true value of N*log(B)/log(BASE) +is a little bit larger than an exact integer, but due to roundoff errors (in +computing log(B), log(BASE), their quotient, and/or multiplying that by N) +yields a numeric result a little less than that integer. Unfortunately, "how +close can a transcendental function get to an integer over some range?" +questions are generally theoretically intractable. Computer analysis via +continued fractions is practical: expand log(B)/log(BASE) via continued +fractions, giving a sequence i/j of "the best" rational approximations. Then +j*log(B)/log(BASE) is approximately equal to (the integer) i. This shows that +we can get very close to being in trouble, but very rarely. For example, +76573 is a denominator in one of the continued-fraction approximations to +log(10)/log(2**15), and indeed: + + >>> log(10)/log(2**15)*76573 + 16958.000000654003 + +is very close to an integer. If we were working with IEEE single-precision, +rounding errors could kill us. Finding worst cases in IEEE double-precision +requires better-than-double-precision log() functions, and Tim didn't bother. +Instead the code checks to see whether the allocated space is enough as each +new Python digit is added, and copies the whole thing to a larger long if not. +This should happen extremely rarely, and in fact I don't have a test case +that triggers it(!). Instead the code was tested by artificially allocating +just 1 digit at the start, so that the copying code was exercised for every +digit beyond the first. ***/ register twodigits c; /* current input character */ Py_ssize_t size_z; @@ -1551,6 +1602,8 @@ * being stored into. */ size_z = (Py_ssize_t)((scan - str) * log_base_BASE[base]) + 1; + /* Uncomment next line to test exceedingly rare copy code */ + /* size_z = 1; */ assert(size_z > 0); z = _PyLong_New(size_z); if (z == NULL) @@ -1594,9 +1647,27 @@ /* carry off the current end? */ if (c) { assert(c < BASE); - assert(z->ob_size < size_z); - *pz = (digit)c; - ++z->ob_size; + if (z->ob_size < size_z) { + *pz = (digit)c; + ++z->ob_size; + } + else { + PyLongObject *tmp; + /* Extremely rare. Get more space. */ + assert(z->ob_size == size_z); + tmp = _PyLong_New(size_z + 1); + if (tmp == NULL) { + Py_DECREF(z); + return NULL; + } + memcpy(tmp->ob_digit, + z->ob_digit, + sizeof(digit) * size_z); + Py_DECREF(z); + z = tmp; + z->ob_digit[size_z] = (digit)c; + ++size_z; + } } } } From buildbot at python.org Tue May 30 19:09:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 17:09:30 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060530170930.80B771E4005@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/497 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 19:11:49 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 30 May 2006 19:11:49 +0200 (CEST) Subject: [Python-checkins] r46560 - in python/trunk: Lib/test/string_tests.py Objects/stringlib/find.h Message-ID: <20060530171149.0CD151E4019@bag.python.org> Author: fredrik.lundh Date: Tue May 30 19:11:48 2006 New Revision: 46560 Modified: python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringlib/find.h Log: changed find/rfind to return -1 for matches outside the source string Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Tue May 30 19:11:48 2006 @@ -154,6 +154,10 @@ self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1) self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4) + self.checkequal(0, 'abc', 'find', '', 0) + self.checkequal(3, 'abc', 'find', '', 3) + self.checkequal(-1, 'abc', 'find', '', 4) + self.checkraises(TypeError, 'hello', 'find') self.checkraises(TypeError, 'hello', 'find', 42) @@ -188,6 +192,10 @@ self.checkequal(0, 'abcdefghiabc', 'rfind', 'abcd') self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz') + self.checkequal(3, 'abc', 'rfind', '', 0) + self.checkequal(3, 'abc', 'rfind', '', 3) + self.checkequal(-1, 'abc', 'rfind', '', 4) + self.checkraises(TypeError, 'hello', 'rfind') self.checkraises(TypeError, 'hello', 'rfind', 42) Modified: python/trunk/Objects/stringlib/find.h ============================================================================== --- python/trunk/Objects/stringlib/find.h (original) +++ python/trunk/Objects/stringlib/find.h Tue May 30 19:11:48 2006 @@ -14,8 +14,11 @@ { Py_ssize_t pos; - if (sub_len == 0) + if (sub_len == 0) { + if (str_len < 0) + return -1; return offset; + } pos = fastsearch(str, str_len, sub, sub_len, FAST_SEARCH); @@ -30,22 +33,20 @@ const STRINGLIB_CHAR* sub, Py_ssize_t sub_len, Py_ssize_t offset) { - Py_ssize_t pos; - /* XXX - create reversefastsearch helper! */ - if (sub_len == 0) - pos = str_len + offset; - else { - Py_ssize_t j; - pos = -1; + if (sub_len == 0) { + if (str_len < 0) + return -1; + return str_len + offset; + } else { + Py_ssize_t j, pos = -1; for (j = str_len - sub_len; j >= 0; --j) if (STRINGLIB_CMP(str+j, sub, sub_len) == 0) { pos = j + offset; break; } + return pos; } - - return pos; } Py_LOCAL_INLINE(Py_ssize_t) From buildbot at python.org Tue May 30 19:32:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 17:32:50 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060530173250.1CBFC1E4005@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/872 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue May 30 19:37:56 2006 From: python-checkins at python.org (bob.ippolito) Date: Tue, 30 May 2006 19:37:56 +0200 (CEST) Subject: [Python-checkins] r46561 - in python/trunk: Lib/test/test_struct.py Modules/_struct.c Message-ID: <20060530173756.63D3E1E4005@bag.python.org> Author: bob.ippolito Date: Tue May 30 19:37:54 2006 New Revision: 46561 Modified: python/trunk/Lib/test/test_struct.py python/trunk/Modules/_struct.c Log: Change wrapping terminology to overflow masking Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Tue May 30 19:37:54 2006 @@ -15,10 +15,10 @@ import _struct except ImportError: PY_STRUCT_RANGE_CHECKING = 0 - PY_STRUCT_WRAPPING = 1 + PY_STRUCT_OVERFLOW_MASKING = 1 else: PY_STRUCT_RANGE_CHECKING = getattr(_struct, '_PY_STRUCT_RANGE_CHECKING', 0) - PY_STRUCT_WRAPPING = getattr(_struct, '_PY_STRUCT_WRAPPING', 0) + PY_STRUCT_OVERFLOW_MASKING = getattr(_struct, '_PY_STRUCT_OVERFLOW_MASKING', 0) def string_reverse(s): chars = list(s) @@ -62,7 +62,7 @@ except (struct.error, TypeError): pass except DeprecationWarning: - if not PY_STRUCT_WRAPPING: + if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Tue May 30 19:37:54 2006 @@ -17,16 +17,16 @@ typedef int Py_ssize_t; #endif -/* If PY_STRUCT_WRAPPING is defined, the struct module will wrap all input +/* If PY_STRUCT_OVERFLOW_MASKING is defined, the struct module will wrap all input numbers for explicit endians such that they fit in the given type, much like explicit casting in C. A warning will be raised if the number did not originally fit within the range of the requested type. If it is not defined, then all range errors and overflow will be struct.error exceptions. */ -#define PY_STRUCT_WRAPPING 1 +#define PY_STRUCT_OVERFLOW_MASKING 1 -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING static PyObject *pylong_ulong_mask = NULL; static PyObject *pyint_zero = NULL; #endif @@ -209,7 +209,7 @@ #endif -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING /* Helper routine to get a Python integer and raise the appropriate error if it isn't one */ @@ -222,7 +222,7 @@ PyObject *wrapped; long x; PyErr_Clear(); - if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer wrapping is deprecated") < 0) + if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer overflow masking is deprecated") < 0) return -1; wrapped = PyNumber_And(v, pylong_ulong_mask); if (wrapped == NULL) @@ -249,7 +249,7 @@ wrapped = PyNumber_And(v, pylong_ulong_mask); if (wrapped == NULL) return -1; - if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer wrapping is deprecated") < 0) { + if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer overflow masking is deprecated") < 0) { Py_DECREF(wrapped); return -1; } @@ -330,7 +330,7 @@ f->format, largest); } -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING { PyObject *ptype, *pvalue, *ptraceback; PyObject *msg; @@ -819,7 +819,7 @@ else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) RANGE_ERROR(x, f, 0, 0xffffffffL); #endif -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING else if ((i == 1) && (x < -128 || x > 127)) RANGE_ERROR(x, f, 0, 0xffL); #endif @@ -910,8 +910,8 @@ static formatdef bigendian_table[] = { {'x', 1, 0, NULL}, -#ifdef PY_STRUCT_WRAPPING - /* Native packers do range checking without wrapping. */ +#ifdef PY_STRUCT_OVERFLOW_MASKING + /* Native packers do range checking without overflow masking. */ {'b', 1, 0, nu_byte, bp_int}, {'B', 1, 0, nu_ubyte, bp_uint}, #else @@ -1037,7 +1037,7 @@ else if ((i == 4) && (x < -2147483648L || x > 2147483647L)) RANGE_ERROR(x, f, 0, 0xffffffffL); #endif -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING else if ((i == 1) && (x < -128 || x > 127)) RANGE_ERROR(x, f, 0, 0xffL); #endif @@ -1128,8 +1128,8 @@ static formatdef lilendian_table[] = { {'x', 1, 0, NULL}, -#ifdef PY_STRUCT_WRAPPING - /* Native packers do range checking without wrapping. */ +#ifdef PY_STRUCT_OVERFLOW_MASKING + /* Native packers do range checking without overflow masking. */ {'b', 1, 0, nu_byte, lp_int}, {'B', 1, 0, nu_ubyte, lp_uint}, #else @@ -1740,7 +1740,7 @@ if (PyType_Ready(&PyStructType) < 0) return; -#ifdef PY_STRUCT_WRAPPING +#ifdef PY_STRUCT_OVERFLOW_MASKING if (pyint_zero == NULL) { pyint_zero = PyInt_FromLong(0); if (pyint_zero == NULL) @@ -1757,8 +1757,8 @@ } #else - /* This speed trick can't be used until wrapping goes away, because - native endian always raises exceptions instead of wrapping. */ + /* This speed trick can't be used until overflow masking goes away, because + native endian always raises exceptions instead of overflow masking. */ /* Check endian and swap in faster functions */ { @@ -1814,7 +1814,7 @@ PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); PyModule_AddIntConstant(m, "_PY_STRUCT_RANGE_CHECKING", 1); -#ifdef PY_STRUCT_WRAPPING - PyModule_AddIntConstant(m, "_PY_STRUCT_WRAPPING", 1); +#ifdef PY_STRUCT_OVERFLOW_MASKING + PyModule_AddIntConstant(m, "_PY_STRUCT_OVERFLOW_MASKING", 1); #endif } From python-checkins at python.org Tue May 30 19:39:58 2006 From: python-checkins at python.org (fredrik.lundh) Date: Tue, 30 May 2006 19:39:58 +0200 (CEST) Subject: [Python-checkins] r46562 - in python/trunk: Lib/test/string_tests.py Objects/stringlib/count.h Message-ID: <20060530173958.E25241E401D@bag.python.org> Author: fredrik.lundh Date: Tue May 30 19:39:58 2006 New Revision: 46562 Modified: python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringlib/count.h Log: changed count to return 0 for slices outside the source string Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Tue May 30 19:39:58 2006 @@ -115,7 +115,8 @@ self.checkequal(2, 'aaa', 'count', 'a', 0, -1) self.checkequal(0, 'aaa', 'count', 'a', 0, -10) self.checkequal(3, 'aaa', 'count', '', 1) - self.checkequal(1, 'aaa', 'count', '', 10) + self.checkequal(1, 'aaa', 'count', '', 3) + self.checkequal(0, 'aaa', 'count', '', 10) self.checkequal(2, 'aaa', 'count', '', -1) self.checkequal(4, 'aaa', 'count', '', -10) Modified: python/trunk/Objects/stringlib/count.h ============================================================================== --- python/trunk/Objects/stringlib/count.h (original) +++ python/trunk/Objects/stringlib/count.h Tue May 30 19:39:58 2006 @@ -15,7 +15,7 @@ if (sub_len == 0) { if (str_len < 0) - return 1; /* start >= len(str) */ + return 0; /* start > len(str) */ return str_len + 1; } From python-checkins at python.org Tue May 30 19:56:29 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 30 May 2006 19:56:29 +0200 (CEST) Subject: [Python-checkins] r46563 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060530175629.361751E4005@bag.python.org> Author: phillip.eby Date: Tue May 30 19:56:27 2006 New Revision: 46563 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Fix a problem w/relative path generation if you install an egg whose name begins with 'import'. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Tue May 30 19:56:27 2006 @@ -1394,7 +1394,7 @@ def make_relative(self,path): if normalize_path(os.path.dirname(path))==self.basedir: - return os.path.basename(path) + return os.path.join(os.curdir, os.path.basename(path)) return path @@ -1551,3 +1551,8 @@ distclass=DistributionWithoutHelpCommands, **kw ) ) + + + + + From python-checkins at python.org Tue May 30 19:58:48 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 30 May 2006 19:58:48 +0200 (CEST) Subject: [Python-checkins] r46564 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20060530175848.1E6E11E4005@bag.python.org> Author: phillip.eby Date: Tue May 30 19:58:47 2006 New Revision: 46564 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Construct ``.pth`` file paths in such a way that installing an egg whose name begins with ``import`` doesn't cause a syntax error. Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Tue May 30 19:58:47 2006 @@ -1100,6 +1100,9 @@ ``PYTHONPATH`` directory with ``--multi-version``, unless an ``easy-install.pth`` file is already in use there. + * Construct ``.pth`` file paths in such a way that installing an egg whose + name begins with ``import`` doesn't cause a syntax error. + 0.6b1 * Better ambiguity management: accept ``#egg`` name/version even if processing what appears to be a correctly-named distutils file, and ignore ``.egg`` Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Tue May 30 19:58:47 2006 @@ -1355,7 +1355,7 @@ """Write changed .pth file back to disk""" if not self.dirty: return - + data = '\n'.join(map(self.make_relative,self.paths)) if data: log.debug("Saving %s", self.filename) @@ -1394,7 +1394,7 @@ def make_relative(self,path): if normalize_path(os.path.dirname(path))==self.basedir: - return os.path.basename(path) + return os.path.join(os.curdir, os.path.basename(path)) return path @@ -1432,7 +1432,7 @@ del zdc[p] return - + def get_script_args(dist, executable=sys_executable): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) From buildbot at python.org Tue May 30 20:13:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 18:13:40 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060530181340.A2EC01E4012@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/533 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue May 30 20:29:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 18:29:42 +0000 Subject: [Python-checkins] buildbot failure in x86 cygwin 2.4 Message-ID: <20060530182942.9B2551E4005@bag.python.org> The Buildbot has detected a new failure of x86 cygwin 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%25202.4/builds/80 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'Zooko': To see if it works. Build Source Stamp: [branch release-24-maint] HEAD Blamelist: BUILD FAILED: failed svn sincerely, -The Buildbot From python-checkins at python.org Tue May 30 20:35:15 2006 From: python-checkins at python.org (mateusz.rukowicz) Date: Tue, 30 May 2006 20:35:15 +0200 (CEST) Subject: [Python-checkins] r46565 - sandbox/trunk/decimal-c/_decimal.c Message-ID: <20060530183515.467701E4005@bag.python.org> Author: mateusz.rukowicz Date: Tue May 30 20:35:14 2006 New Revision: 46565 Modified: sandbox/trunk/decimal-c/_decimal.c Log: Some memleaks fix. Modified: sandbox/trunk/decimal-c/_decimal.c ============================================================================== --- sandbox/trunk/decimal-c/_decimal.c (original) +++ sandbox/trunk/decimal-c/_decimal.c Tue May 30 20:35:14 2006 @@ -1963,7 +1963,7 @@ if (!decimal_nonzero(self)) { oexp = other->exp - ctx->prec - 1; exp = (exp > oexp ? exp : oexp); - res = _decimal_rescale(other, exp, ctx, 0); + res = _decimal_rescale(other, exp, ctx, 0, 1); if (!res) return NULL; if (shouldround) { res2 = _decimal_fix(res, ctx); @@ -1976,7 +1976,7 @@ if (!decimal_nonzero(other)) { oexp = self->exp - ctx->prec - 1; exp = (exp > oexp ? exp : oexp); - res = _decimal_rescale(self, exp, ctx, 0); + res = _decimal_rescale(self, exp, ctx, 0, 1); if (!res) return NULL; if (shouldround) { res2 = _decimal_fix(res, ctx); @@ -2646,18 +2646,18 @@ } else { tup = PySequence_Tuple(seq); if (!tup) - return NULL; + goto err; } if (PyTuple_GET_SIZE(tup) != 3) { PyErr_SetString(PyExc_ValueError, "Invalid arguments"); - return NULL; + goto err; } if (!PyArg_ParseTuple(tup, "iOl", &sign, &digits, &exp)) - return NULL; + goto err; if (sign < 0 || sign > 7) { PyErr_SetString(PyExc_ValueError, "Invalid sign"); - return NULL; + goto err; } digtup = PySequence_Tuple(digits); if (!digtup) { @@ -2671,22 +2671,22 @@ long x = PyInt_AsLong(item); if (x < 0 || x > 9) { PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x); - return NULL; + goto err; } new->digits[i] = (signed char)x; } else if (PyLong_Check(item)) { long x = PyLong_AsLong(item); if (x == -1 && PyErr_Occurred()) - return NULL; + goto err; if (x < 0 || x > 9) { PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x); - return NULL; + return err; } new->digits[i] = (signed char)x; } else { PyErr_SetString(PyExc_ValueError, "The second value in the tuple " "must be composed of non negative integer elements."); - return NULL; + return err; } } From python-checkins at python.org Tue May 30 21:07:52 2006 From: python-checkins at python.org (mateusz.rukowicz) Date: Tue, 30 May 2006 21:07:52 +0200 (CEST) Subject: [Python-checkins] r46566 - sandbox/trunk/decimal-c/Makefile Message-ID: <20060530190752.D8C5D1E4005@bag.python.org> Author: mateusz.rukowicz Date: Tue May 30 21:07:52 2006 New Revision: 46566 Modified: sandbox/trunk/decimal-c/Makefile Log: Now make debug produces module without -O3. Modified: sandbox/trunk/decimal-c/Makefile ============================================================================== --- sandbox/trunk/decimal-c/Makefile (original) +++ sandbox/trunk/decimal-c/Makefile Tue May 30 21:07:52 2006 @@ -1,16 +1,24 @@ # change PYTHON_25 to point to a 2.5 HEAD build # (a fairly recent HEAD is necessary) -PYTHON_25=../../../python/python +PYTHON_25=../../python/python +PYTH_DIR=../../python -all: module run -module: +all: _decimal.o _decimal.so run +module: $(PYTHON_25) setup.py build cp build/lib*/_decimal.so . clean: rm -rf build/ -test: module + rm _decimal.o _decimal.so >& /dev/null +test: _decimal.so $(PYTHON_25) test_decimal.py -run: module - $(PYTHON_25) -i -c "import _decimal; CD = _decimal.Decimal; import decimal; D = decimal.Decimal" -debug: module - ddd $(PYTHON_25) +run: _decimal.so + $(PYTHON_25) -i run.py +debug: _decimal.so + gdb $(PYTHON_25) + +_decimal.o: _decimal.c decimal.h + gcc -pthread -fno-strict-aliasing -DNDEBUG -g -Wall -Wstrict-prototypes -fPIC -I${PYTH_DIR}/Include -I${PYTH_DIR} -c _decimal.c -o _decimal.o +_decimal.so: _decimal.o + gcc -pthread -shared _decimal.o -o _decimal.so + From python-checkins at python.org Tue May 30 21:09:23 2006 From: python-checkins at python.org (mateusz.rukowicz) Date: Tue, 30 May 2006 21:09:23 +0200 (CEST) Subject: [Python-checkins] r46567 - sandbox/trunk/decimal-c/run.py Message-ID: <20060530190923.4C21E1E4005@bag.python.org> Author: mateusz.rukowicz Date: Tue May 30 21:09:23 2006 New Revision: 46567 Added: sandbox/trunk/decimal-c/run.py (contents, props changed) Log: Run it to make sure . is in module paths. Added: sandbox/trunk/decimal-c/run.py ============================================================================== --- (empty file) +++ sandbox/trunk/decimal-c/run.py Tue May 30 21:09:23 2006 @@ -0,0 +1,4 @@ +import _decimal +CD = _decimal.Decimal +import decimal +D = decimal.Decimal From jimjjewett at gmail.com Tue May 30 21:10:14 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Tue, 30 May 2006 15:10:14 -0400 Subject: [Python-checkins] r46514 - in python/trunk: Mac/Modules/dlg/_Dlgmodule.c Mac/Modules/dlg/dlgsupport.py Mac/Modules/file/_Filemodule.c Mac/Modules/file/filesupport.py Python/import.c In-Reply-To: <20060528215736.2B0CA1E4006@bag.python.org> References: <20060528215736.2B0CA1E4006@bag.python.org> Message-ID: Why didn't you use the Py_RETURN_NONE macro here? (I notice that you did use it in your previous checkin, fixing the anti-leak in struct.) -jJ On 5/28/06, georg.brandl wrote: > Author: georg.brandl > Date: Sun May 28 23:57:35 2006 > New Revision: 46514 > > Modified: > python/trunk/Mac/Modules/dlg/_Dlgmodule.c > python/trunk/Mac/Modules/dlg/dlgsupport.py > python/trunk/Mac/Modules/file/_Filemodule.c > python/trunk/Mac/Modules/file/filesupport.py > python/trunk/Python/import.c > Log: > Correct None refcount issue in Mac modules. (Are they > still used?) > > > > Modified: python/trunk/Mac/Modules/dlg/_Dlgmodule.c > ============================================================================== > --- python/trunk/Mac/Modules/dlg/_Dlgmodule.c (original) > +++ python/trunk/Mac/Modules/dlg/_Dlgmodule.c Sun May 28 23:57:35 2006 > @@ -139,7 +139,7 @@ > PyObject *DlgObj_New(DialogPtr itself) > { > DialogObject *it; > - if (itself == NULL) return Py_None; > + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } > it = PyObject_NEW(DialogObject, &Dialog_Type); > if (it == NULL) return NULL; > it->ob_itself = itself; > > Modified: python/trunk/Mac/Modules/dlg/dlgsupport.py > ============================================================================== > --- python/trunk/Mac/Modules/dlg/dlgsupport.py (original) > +++ python/trunk/Mac/Modules/dlg/dlgsupport.py Sun May 28 23:57:35 2006 > @@ -202,7 +202,7 @@ > Output("SetWRefCon(GetDialogWindow(itself), (long)it);") > > def outputCheckNewArg(self): > - Output("if (itself == NULL) return Py_None;") > + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") > > def outputCheckConvertArg(self): > Output("if (v == Py_None) { *p_itself = NULL; return 1; }") > > Modified: python/trunk/Mac/Modules/file/_Filemodule.c > ============================================================================== > --- python/trunk/Mac/Modules/file/_Filemodule.c (original) > +++ python/trunk/Mac/Modules/file/_Filemodule.c Sun May 28 23:57:35 2006 > @@ -153,7 +153,7 @@ > static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself) > { > FSCatalogInfoObject *it; > - if (itself == NULL) return Py_None; > + if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } > it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type); > if (it == NULL) return NULL; > it->ob_itself = *itself; > > Modified: python/trunk/Mac/Modules/file/filesupport.py > ============================================================================== > --- python/trunk/Mac/Modules/file/filesupport.py (original) > +++ python/trunk/Mac/Modules/file/filesupport.py Sun May 28 23:57:35 2006 > @@ -475,7 +475,7 @@ > self.argref = "*" # Store FSSpecs, but pass them by address > > def outputCheckNewArg(self): > - Output("if (itself == NULL) return Py_None;") > + Output("if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }") > > def output_tp_newBody(self): > Output("PyObject *self;"); > > Modified: python/trunk/Python/import.c > ============================================================================== > --- python/trunk/Python/import.c (original) > +++ python/trunk/Python/import.c Sun May 28 23:57:35 2006 > @@ -2059,7 +2059,7 @@ > /* Return the package that an import is being performed in. If globals comes > from the module foo.bar.bat (not itself a package), this returns the > sys.modules entry for foo.bar. If globals is from a package's __init__.py, > - the package's entry in sys.modules is returned. > + the package's entry in sys.modules is returned, as a borrowed reference. > > The *name* of the returned package is returned in buf, with the length of > the name in *p_buflen. > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From g.brandl at gmx.net Tue May 30 21:27:09 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Tue, 30 May 2006 21:27:09 +0200 Subject: [Python-checkins] r46514 - in python/trunk: Mac/Modules/dlg/_Dlgmodule.c Mac/Modules/dlg/dlgsupport.py Mac/Modules/file/_Filemodule.c Mac/Modules/file/filesupport.py Python/import.c In-Reply-To: References: <20060528215736.2B0CA1E4006@bag.python.org> Message-ID: Jim Jewett wrote: > Why didn't you use the Py_RETURN_NONE macro here? (I notice that you > did use it in your previous checkin, fixing the anti-leak in struct.) Temporary amnesia, I guess ;) Georg From jimjjewett at gmail.com Tue May 30 21:46:21 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Tue, 30 May 2006 15:46:21 -0400 Subject: [Python-checkins] r46544 - in python/trunk: Include/dictobject.h Objects/dictobject.c In-Reply-To: <20060530041626.4E43B1E4006@bag.python.org> References: <20060530041626.4E43B1E4006@bag.python.org> Message-ID: Why is this being done now? I see the advantage of being able to use larger dictionaries if you do have the RAM, and want a few huge in-memory databases instead of a large number of small objects, *and* aren't using something else for that database. I also see a disadvantage in making all dictionary instances a little bit larger. I think even for the huge RAM case, "lots of little objects" might be a more common case. Even for the single-honkin-dict, would it make sense to have an extra search finger member instead of increasing the size of every bucket? -jJ On 5/30/06, tim.peters wrote: > Author: tim.peters > Date: Tue May 30 06:16:25 2006 > New Revision: 46544 > > Modified: > python/trunk/Include/dictobject.h > python/trunk/Objects/dictobject.c > Log: > Convert relevant dict internals to Py_ssize_t. > > I don't have a box with nearly enough RAM, or an OS, > that could get close to tickling this, though (requires > a dict w/ at least 2**31 entries). > > > Modified: python/trunk/Include/dictobject.h > ============================================================================== > --- python/trunk/Include/dictobject.h (original) > +++ python/trunk/Include/dictobject.h Tue May 30 06:16:25 2006 > @@ -8,7 +8,7 @@ > /* Dictionary object type -- mapping from hashable object to object */ > > /* The distribution includes a separate file, Objects/dictnotes.txt, > - describing explorations into dictionary design and optimization. > + describing explorations into dictionary design and optimization. > It covers typical dictionary use patterns, the parameters for > tuning dictionaries, and several ideas for possible optimizations. > */ > @@ -48,7 +48,11 @@ > #define PyDict_MINSIZE 8 > > typedef struct { > - long me_hash; /* cached hash code of me_key */ > + /* Cached hash code of me_key. Note that hash codes are C longs. > + * We have to use Py_ssize_t instead because dict_popitem() abuses > + * me_hash to hold a search finger. > + */ > + Py_ssize_t me_hash; > PyObject *me_key; > PyObject *me_value; > } PyDictEntry; From buildbot at python.org Tue May 30 22:00:54 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 20:00:54 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060530200055.176531E400F@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/247 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: bob.ippolito,fredrik.lundh Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 31 00:12:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 30 May 2006 22:12:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin 2.4 Message-ID: <20060530221234.691B81E4005@bag.python.org> The Buildbot has detected a new failure of x86 cygwin 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%25202.4/builds/81 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'Zooko': To see if it works. Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Wed May 31 00:08:31 2006 From: martin at v.loewis.de (martin at v.loewis.de) Date: Wed, 31 May 2006 00:08:31 +0200 Subject: [Python-checkins] r46544 - in python/trunk:Include/dictobject.h Objects/dictobject.c In-Reply-To: References: <20060530041626.4E43B1E4006@bag.python.org> Message-ID: <1149026911.447cc25f04c99@www.domainfactory-webmail.de> Zitat von Jim Jewett : > Why is this being done now? Because it is correct; otherwise, truncation may occur. > I also see a disadvantage in making all dictionary instances a little > bit larger. What do you mean by "all"? On a 32-bit system, there won't be a change because sizeof(long)==sizeof(Py_ssize_t). Actually, on a 64-bit system, there won't be a change in memory usage, either, because me_hash is followed by me_key, and me_key is 8-aligned. So there is currently 4 bytes of padding between me_hash and me_key; with the patch, the padding is gone. Regards, Martin From python-checkins at python.org Wed May 31 01:28:03 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 31 May 2006 01:28:03 +0200 (CEST) Subject: [Python-checkins] r46568 - python/trunk/Lib/test/test_exceptions.py Message-ID: <20060530232803.6AC0D1E4005@bag.python.org> Author: tim.peters Date: Wed May 31 01:28:02 2006 New Revision: 46568 Modified: python/trunk/Lib/test/test_exceptions.py Log: Whitespace normalization. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Wed May 31 01:28:02 2006 @@ -31,7 +31,7 @@ self.assertEquals(exc.__name__, excname) def testRaising(self): - self.raise_catch(AttributeError, "AttributeError") + self.raise_catch(AttributeError, "AttributeError") self.assertRaises(AttributeError, getattr, sys, "undefined_attribute") self.raise_catch(EOFError, "EOFError") @@ -184,10 +184,10 @@ """test that exception attributes are happy.""" try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e - + try: unicode('\xff') except Exception, e: sampleUnicodeDecodeError = e - + exceptionList = [ ( BaseException, (), { 'message' : '', 'args' : () }), ( BaseException, (1, ), { 'message' : 1, 'args' : ( 1, ) }), @@ -267,7 +267,7 @@ repr(expected[checkArgName]), 'exception "%s", attribute "%s"' % (repr(e), checkArgName)) - + # test for pickling support new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) for checkArgName in expected.keys(): From tim.peters at gmail.com Wed May 31 02:00:31 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 30 May 2006 20:00:31 -0400 Subject: [Python-checkins] r46544 - in python/trunk: Include/dictobject.h Objects/dictobject.c In-Reply-To: References: <20060530041626.4E43B1E4006@bag.python.org> Message-ID: <1f7befae0605301700y20556855y9488ffdec066faae@mail.gmail.com> [Jim Jewett] > Why is this being done now? Because yeserday was the first day I could make sufficient time for it. The C API dict functions were converted to Py_ssize_t a few months ago, but the dict internals weren't changed to match at the time. Now they have been. It was a correctness issue to leave them mis-matched (although I don't have a box on which failure modes can be provoked, ways to do so were obvious). > I see the advantage of being able to use larger dictionaries if you do > have the RAM, and want a few huge in-memory databases instead of a > large number of small objects, *and* aren't using something else for > that database. > > I also see a disadvantage in making all dictionary instances a little > bit larger. There's no size difference on 32-bit boxes. On 64-bit boxes there's at worst a small relative increase. Don't overlook that PyDictObject was a large object, and especially on 64-bit boxes. Changing 3 members from int to Py_ssize_t in the PyDictObject struct makes an empty dict on a 64-bit box perhaps 4% larger (I don't have a 64-bit box to check that on -- if you do, print sizeof(PyDictObject) before and after to find out). > I think even for the huge RAM case, "lots of little objects" might be > a more common case. > > Even for the single-honkin-dict, would it make sense to have an extra > search finger member instead of increasing the size of every bucket? You're talking about the effect of changing the PyDictEntry struct's me_hash member from long to Py_ssize_t? If so, I believe that makes no size difference on any box. The only known platform on which sizeof(Py_ssize_t) > sizeof(long) is Win64, so the only known platform on which that change could possibly increase the PyDictEntry struct;s size is Win64. But that struct is going to be 8-byte aligned on Win64 because it also contains 8-byte pointers on Win64, so PyDictEntry previously had 4 unused pad bytes on Win64. The net effect of the change on Win64 is to make use of those 4 unused bytes. If it did increase the size of PyDictEntry, then yes, crafting a different search-finger hack would be attractive. I'm not sure I'd bother just for Win64, though ;-) From neal at metaslash.com Tue May 30 22:11:54 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 30 May 2006 16:11:54 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (2) Message-ID: <20060530201154.GA5368@python.psfb.org> case $MAKEFLAGS in \ *-s*) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-g -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext db.h: found (4, 1) in /usr/include db lib: using (4, 1) db-4.1 sqlite: found /usr/include/sqlite3.h /usr/include/sqlite3.h: version 3.2.1 INFO: Can't locate Tcl/Tk libs and/or headers running build_scripts [34112 refs] ./python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform [8662 refs] find ./Lib -name '*.py[co]' -print | xargs rm -f ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- errors occurred in test.test_str.StrTest test_strftime test_string test test_string failed -- errors occurred; run in verbose mode for details test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- errors occurred in test.test_unicode.UnicodeTest test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 281 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [425379 refs] make: [test] Error 1 (ignored) ./python -E -tt ./Lib/test/regrtest.py -l test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socket_ssl skipped -- Use of the `network' resource not enabled test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- errors occurred in test.test_str.StrTest test_strftime test_string test test_string failed -- errors occurred; run in verbose mode for details test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- errors occurred in test.test_unicode.UnicodeTest test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 281 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 30 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_gl test_imgfile test_ioctl test_linuxaudiodev test_macfs test_macostools test_nis test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [424800 refs] make: *** [test] Error 1 From tim.peters at gmail.com Wed May 31 03:35:07 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 30 May 2006 21:35:07 -0400 Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule. Message-ID: <1f7befae0605301835r4f62fb65udf3c144a69eccfce@mail.gmail.com> [Nick Coghlan] > ... (we should probably do something about that misleading ImportError -> > TestSkipped -> green buildbot behaviour. . . ) I looked at that briefly a few weeks back and gave up. Seemed the sanest thing was to entirely stop treating ImportError as "test skipped", and rewrite tests that legimately _may_ get skipped to catch expected ImportErrors and change them to TestSkipped themselves. A bit of framework might help; e.g., a test that expects to get skipped due to failing imports on some platforms could define a module-level list bound to a conventional name containing the names of the modules whose import failure should be treated as TestSkipped, and then regrtest.py could be taught to check import errors against the test module's list (if any). In the case du jour, test_functools.py presumably wouldn't define that list, so that any ImportError it raised would be correctly treated as test failure. From tim.peters at gmail.com Wed May 31 03:50:38 2006 From: tim.peters at gmail.com (Tim Peters) Date: Tue, 30 May 2006 21:50:38 -0400 Subject: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj pytho Message-ID: <1f7befae0605301850t70b5b7cal45b983906a4c0cb4@mail.gmail.com> [kristjan.jonsson] |>> Add a PCBuild8 build directory for building with Visual Studio .NET >> 2005. Contains a special project to perform profile guided >> optimizations on the pythoncore.dll, by instrumenting and running >> pybench.py [Martin v. L?wis] > Who is going to maintain that? I'm copying Kristj?n directly since I doubt he's still following the python-checkins list actively enough to notice that replies "to him" actually just go to python-checkins. Kristj?n is actively using that directory in his business, so he's maintaining it for now. At the NFS sprint he demonstrated significant speedups via exploiting profile-guided optimization, so it should of substantial interest over time. If everyone loses interest, fine, then it becomes like PC/VC6/ and RISCOS/ and ... in the meantime, it doesn't get in the way of anything I ever do <0.5 wink>. From neal at metaslash.com Tue May 30 23:17:35 2006 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 30 May 2006 17:17:35 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20060530211735.GA10640@python.psfb.org> test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [8667 refs] [8667 refs] [8667 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [9015 refs] [9015 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socketserver test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test test_str failed -- errors occurred in test.test_str.StrTest test_strftime test_string test test_string failed -- errors occurred; run in verbose mode for details test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8878 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] [8662 refs] this bit of output is from a test of stdout in a different process ... [8662 refs] [8662 refs] [8878 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [8662 refs] [8662 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [8662 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test test_unicode failed -- errors occurred in test.test_unicode.UnicodeTest test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test test_userstring failed -- errors occurred; run in verbose mode for details test_uu test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipimport test_zlib 287 tests OK. 4 tests failed: test_str test_string test_unicode test_userstring 21 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_gl test_imgfile test_ioctl test_macfs test_macostools test_nis test_pep277 test_plistlib test_scriptpackages test_startfile test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound 1 skip unexpected on linux2: test_ioctl [432083 refs] From python-checkins at python.org Wed May 31 04:19:55 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 31 May 2006 04:19:55 +0200 (CEST) Subject: [Python-checkins] r46569 - python/trunk/Doc/lib/libtime.tex Message-ID: <20060531021955.B3B5C1E4005@bag.python.org> Author: brett.cannon Date: Wed May 31 04:19:54 2006 New Revision: 46569 Modified: python/trunk/Doc/lib/libtime.tex Log: Clarify wording on default values for strptime(); defaults are used when better values cannot be inferred. Closes bug #1496315. Modified: python/trunk/Doc/lib/libtime.tex ============================================================================== --- python/trunk/Doc/lib/libtime.tex (original) +++ python/trunk/Doc/lib/libtime.tex Wed May 31 04:19:54 2006 @@ -314,7 +314,8 @@ according to \var{format}, \exception{ValueError} is raised. If the string to be parsed has excess data after parsing, \exception{ValueError} is raised. The default values used to fill in -any missing data are \code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} . +any missing data when more accurate values cannot be inferred are +\code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} . Support for the \code{\%Z} directive is based on the values contained in \code{tzname} and whether \code{daylight} is true. Because of this, From python-checkins at python.org Wed May 31 04:22:02 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 31 May 2006 04:22:02 +0200 (CEST) Subject: [Python-checkins] r46570 - python/branches/release24-maint/Doc/lib/libtime.tex Message-ID: <20060531022202.AC8CF1E4005@bag.python.org> Author: brett.cannon Date: Wed May 31 04:22:02 2006 New Revision: 46570 Modified: python/branches/release24-maint/Doc/lib/libtime.tex Log: Clarify wording about how default values in strptime() are used. Backport of fix for bug #1496315. Modified: python/branches/release24-maint/Doc/lib/libtime.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libtime.tex (original) +++ python/branches/release24-maint/Doc/lib/libtime.tex Wed May 31 04:22:02 2006 @@ -314,7 +314,8 @@ according to \var{format}, \exception{ValueError} is raised. If the string to be parsed has excess data after parsing, \exception{ValueError} is raised. The default values used to fill in -any missing data are \code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} . +any missing data when more accurate values canot be inferred are +\code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} . Support for the \code{\%Z} directive is based on the values contained in \code{tzname} and whether \code{daylight} is true. Because of this, From buildbot at python.org Wed May 31 04:27:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 02:27:13 +0000 Subject: [Python-checkins] buildbot failure in x86 XP-2 trunk Message-ID: <20060531022713.39A401E4005@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/518 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Wed May 31 04:27:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 02:27:13 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian trunk Message-ID: <20060531022713.3B59D1E4006@bag.python.org> The Buildbot has detected a new failure of MIPS Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%2520trunk/builds/175 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Wed May 31 04:29:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 02:29:02 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060531022902.A1C321E4005@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/536 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 31 04:40:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 02:40:49 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060531024049.4863E1E4005@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/875 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 31 07:54:51 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 31 May 2006 07:54:51 +0200 (CEST) Subject: [Python-checkins] r46571 - peps/trunk/pep-0000.txt peps/trunk/pep-0360.txt Message-ID: <20060531055451.374E61E4007@bag.python.org> Author: brett.cannon Date: Wed May 31 07:54:49 2006 New Revision: 46571 Added: peps/trunk/pep-0360.txt (contents, props changed) Modified: peps/trunk/pep-0000.txt Log: Add Externally Maintained Packages PEP (PEP 360). Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Wed May 31 07:54:49 2006 @@ -65,6 +65,7 @@ I 333 Python Web Server Gateway Interface v1.0 Eby I 339 Design of the CPython Compiler Cannon I 356 Python 2.5 Release Schedule Norwitz, et al + I 360 Externally Maintained Packages Cannon I 3100 Python 3.0 Plans Kuchling, Cannon Accepted PEPs (accepted; may not be implemented yet) @@ -420,6 +421,7 @@ SF 357 Allowing Any Object to be Used for Slicing Oliphant S 358 The "bytes" Object Schemenauer SW 359 The "make" Statement Bethard + I 360 Externally Maintained Packages Cannon SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes P 3000 Python 3000 GvR Added: peps/trunk/pep-0360.txt ============================================================================== --- (empty file) +++ peps/trunk/pep-0360.txt Wed May 31 07:54:49 2006 @@ -0,0 +1,149 @@ +PEP: 360 +Title: Externally Maintained Packages +Version: $Revision$ +Last-Modified: $Date$ +Author: Brett Cannon +Status: Active +Type: Informational +Content-Type: text/x-rst +Created: 30-May-2006 + + +Abstract +======== + +There are many great pieces of Python software developed outside of +the Python standard library (aka, stdlib). Sometimes it makes sense +to incorporate these externally maintained packages into the stdlib in +order to fill a gap in the tools provided by Python. + +But by having the packages maintained externally it means Python's +developers do not have direct control over the packages' evolution and +maintenance. Some package developers prefer to have bug reports and +patches go through them first instead of being directly applied to +Python's repository. + +This PEP is meant to record details of packages in the stdlib that are +maintained outside of Python's repository. Specifically, it is meant +to keep track of any specific maintenance needs for each package. It +also is meant to allow people to know which version of a package is +released with which version of Python. + + +Externally Maintained Packages +============================== + +The section title is the name of the package as known outside of the +Python standard library. The "standard library name" is what the +package is named within Python. The "contact person" is the Python +developer in charge of maintaining the package. The +"synchronisation history" lists what external version of the package +was included in each version of Python (if different from the previous +Python release). + + +ctypes +------ +- Web page + http://starship.python.net/crew/theller/ctypes/ +- Standard library name + ctypes +- Contact person + Thomas Heller +- Synchronisation history + * 0.9.9.6 (2.5) + +Bugs can be reported to either the Python tracker [#python-tracker]_ +or the ctypes tracker [#ctypes-tracker]_ and assigned to +Thomas Heller. + + +ElementTree +----------- +- Web page + http://effbot.org/zone/element-index.htm +- Standard library name + xml.etree +- Contact person + Fredrik Lundh +- Synchronisation history + * 1.2.6 [ElementTree] / 1.0.5 [cElementTree] (2.5) + +Patches should not be directly applied to Python HEAD, but instead +reported to the Python tracker [#python-tracker]_ (critical bug fixes +are the exception). Bugs should also be reported to the Python +tracker. Both bugs and patches should be assigned to Fredrik Lundh. + + +Expat XML parser +---------------- +- Web page + http://www.libexpat.org/ +- Standard library name + N/A (this refers to the parser itself, and not the Python + bindings) +- Contact person + None +- Synchronisation history + * 1.95.8 (2.4) + * 1.95.7 (2.3) + + +Optik +----- +- Web site + http://optik.sourceforge.net/ +- Standard library name + optparse +- Contact person + Greg Ward +- Synchronisation history + * 1.5.1 (2.5) + * 1.5a1 (2.4) + * 1.4 (2.3) + + +pysqlite +-------- +- Web site + http://www.sqlite.org/ +- Standard library name + sqlite3 +- Contact person + Gerhard H?ring +- Synchronisation history + * 2.2.2 (2.5) + +Bugs should be reported to the pysqlite bug +tracker [#pysqlite-tracker]_ as well as any patches that are not +deemed critical. + + +References +========== + +.. [#python-tracker] Python tracker + (http://sourceforge.net/tracker/?group_id=5470) + +.. [#ctypes-tracker] ctypes tracker + (http://sourceforge.net/tracker/?group_id=71702) + +.. [#pysqlite-tracker] pysqlite tracker + (http://pysqlite.org/) + + +Copyright +========= + +This document has been placed in the public domain. + + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: From brett at python.org Wed May 31 08:03:09 2006 From: brett at python.org (Brett Cannon) Date: Tue, 30 May 2006 23:03:09 -0700 Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule. In-Reply-To: <1f7befae0605301835r4f62fb65udf3c144a69eccfce@mail.gmail.com> References: <1f7befae0605301835r4f62fb65udf3c144a69eccfce@mail.gmail.com> Message-ID: On 5/30/06, Tim Peters wrote: > > [Nick Coghlan] > > ... (we should probably do something about that misleading ImportError > -> > > TestSkipped -> green buildbot behaviour. . . ) > > I looked at that briefly a few weeks back and gave up. Seemed the > sanest thing was to entirely stop treating ImportError as "test > skipped", and rewrite tests that legimately _may_ get skipped to catch > expected ImportErrors and change them to TestSkipped themselves. > > A bit of framework might help; e.g., a test that expects to get > skipped due to failing imports on some platforms could define a > module-level list bound to a conventional name containing the names of > the modules whose import failure should be treated as TestSkipped, and > then regrtest.py could be taught to check import errors against the > test module's list (if any). Where would this list be stored? If the import fails the module is not imported, so how do you get access to the list? It could be some function that *must* be called before any imports that registers with test.test_support what modules it can not be able to import and then check that way. Otherwise the list would just have to be external to all tests (which might not be so bad to have a master list of modules we think can be skipped on various platforms and then what modules can fail on import for what tests). -Brett In the case du jour, test_functools.py presumably wouldn't define that > list, so that any ImportError it raised would be correctly treated as > test failure. > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060530/32a66316/attachment.htm From python-checkins at python.org Wed May 31 09:43:28 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 31 May 2006 09:43:28 +0200 (CEST) Subject: [Python-checkins] r46572 - python/trunk/Modules/_struct.c Message-ID: <20060531074328.F0CD71E4007@bag.python.org> Author: neal.norwitz Date: Wed May 31 09:43:27 2006 New Revision: 46572 Modified: python/trunk/Modules/_struct.c Log: Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64 Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Wed May 31 09:43:27 2006 @@ -309,24 +309,24 @@ _range_error(const formatdef *f, int is_unsigned) { if (is_unsigned == 0) { - long smallest = 0, largest = 0; + Py_ssize_t smallest, largest = 0; Py_ssize_t i = f->size * 8; while (--i > 0) { - smallest = (smallest * 2) - 1; largest = (largest * 2) + 1; } + smallest = -largest - 1; PyErr_Format(StructError, - "'%c' format requires %ld <= number <= %ld", + "'%c' format requires %zd <= number <= %zd", f->format, smallest, largest); } else { - unsigned long largest = 0; + size_t largest = 0; Py_ssize_t i = f->size * 8; while (--i >= 0) largest = (largest * 2) + 1; PyErr_Format(StructError, - "'%c' format requires 0 <= number <= %lu", + "'%c' format requires 0 <= number <= %zu", f->format, largest); } From python-checkins at python.org Wed May 31 10:01:08 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 31 May 2006 10:01:08 +0200 (CEST) Subject: [Python-checkins] r46573 - python/trunk/Makefile.pre.in Message-ID: <20060531080108.CA1A61E4008@bag.python.org> Author: neal.norwitz Date: Wed May 31 10:01:08 2006 New Revision: 46573 Modified: python/trunk/Makefile.pre.in Log: Revert last checkin, it is better to do make distclean Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Wed May 31 10:01:08 2006 @@ -594,17 +594,8 @@ $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall -# These two force rules are only used for buildbottest. -# - cleanup tries to cleanup after broken tests. -# - setup ensures that we are using the latest version of Modules/Setup.dist. -forcecleanup: - -rm -rf $(srcdir)/@test* - -forcesetup: - cp $(srcdir)/Modules/Setup.dist $(srcdir)/Modules/Setup - # Like testall, but with a single pass only -buildbottest: forcecleanup forcesetup all platform +buildbottest: all platform $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ From buildbot at python.org Wed May 31 10:22:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 08:22:05 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060531082205.AF1B81E4007@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/877 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 31 11:02:48 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 31 May 2006 11:02:48 +0200 (CEST) Subject: [Python-checkins] r46574 - python/trunk/Lib/test/test_struct.py Message-ID: <20060531090248.6E2EC1E4007@bag.python.org> Author: neal.norwitz Date: Wed May 31 11:02:44 2006 New Revision: 46574 Modified: python/trunk/Lib/test/test_struct.py Log: On 64-bit platforms running test_struct after test_tarfile would fail since the deprecation warning wouldn't be raised. Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Wed May 31 11:02:44 2006 @@ -53,6 +53,12 @@ # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] + # Grrr, we need this function to warn every time. Without removing + # the warningregistry, running test_tarfile then test_struct would fail + # on 64-bit platforms. + globals = func.func_globals + if '__warningregistry__' in globals: + del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) From buildbot at python.org Wed May 31 11:19:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 09:19:39 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060531091939.A806A1E4012@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/538 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From blais at furius.ca Wed May 31 12:35:39 2006 From: blais at furius.ca (Martin Blais) Date: Wed, 31 May 2006 06:35:39 -0400 Subject: [Python-checkins] [Python-Dev] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: References: <20060526120329.9A9671E400C@bag.python.org> Message-ID: <8393fff0605310335o12b2b26ew43ba63cfd69c26e9@mail.gmail.com> On 5/29/06, Guido van Rossum wrote: > [python-checkins] > > >> * Added socket.recv_buf() and socket.recvfrom_buf() methods, that > > >> use the buffer > > >> protocol (send and sendto already did). > > >> > > >> * Added struct.pack_to(), that is the corresponding buffer > > >> compatible method to > > >> unpack_from(). > > [Guido] > > > Hm... The file object has a similar method readinto(). Perhaps the > > > methods introduced here could follow that lead instead of using two > > > different new naming conventions? > > On 5/27/06, Bob Ippolito wrote: > > (speaking specifically about struct and not socket) > > > > pack_to and unpack_from are named as such because they work with objects > > that support the buffer API (not file-like-objects). I couldn't find any > > existing convention for objects that manipulate buffers in such a way. > > Actually, .readinto() is the convention I > started long ago (at the time the buffer was introduced. > > > If there is an existing convention then I'd be happy to rename these. > > > > "readinto" seems to imply that some kind of position is being > > incremented. > > No -- it's like read() but instead of returning a new object it reads > "into" an object you pass. > > > Grammatically it only works if it's implemented on all buffer > > objects, but > > in this case it's implemented on the Struct type. > > It looks like .pack_to(, ) is > similar to .readinto() in that the buffer > object receives the result of packing / reading. So I assume you're suggesting the following renames: pack_to -> packinto recv_buf -> recvinto recvfrom_buf -> recvfrominto (I don't like that last one very much. I'll go ahead and make those renames once I return.) From kristjan at ccpgames.com Wed May 31 12:34:49 2006 From: kristjan at ccpgames.com (=?iso-8859-1?Q?Kristj=E1n_V=2E_J=F3nsson?=) Date: Wed, 31 May 2006 10:34:49 -0000 Subject: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj pytho Message-ID: <129CEF95A523704B9D46959C922A28000282A8ED@nemesis.central.ccp.cc> Hi there. Well, I was sort of hoping that it would "maintain itself" in an open source manner, but if it needs an official maintainter, we can do that. Particularly, we are interested in input from the community on how better to set up the projects in VS to perform the profile-guilded optimization step with minimal user input. Our current approach relies on a file called pythoncore_pgo_link.txt which needs to be manually updated when the project changes significantly. Martin, you have been doing work on getting python to be officially supported with VC 8. I remember that we discussed this at the pycon sprint. My VC8 build of 2.5 indeed did crash in the regression suite. I have some ideas on how to fix the C runtime problem. I will try some things locally and then bounce them off you and Tim. Cheers, Kristjan p.s. do you think I ought to subscribe to python-checkins? -----Original Message----- From: Tim Peters [mailto:tim.peters at gmail.com] Sent: 31. ma? 2006 01:51 To: Martin v. L?wis; Kristj?n V. J?nsson Cc: kristjan.jonsson Subject: Re: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj pytho [kristjan.jonsson] |>> Add a PCBuild8 build directory for building with Visual Studio .NET >> 2005. Contains a special project to perform profile guided >> optimizations on the pythoncore.dll, by instrumenting and running >> pybench.py [Martin v. L?wis] > Who is going to maintain that? I'm copying Kristj?n directly since I doubt he's still following the python-checkins list actively enough to notice that replies "to him" actually just go to python-checkins. Kristj?n is actively using that directory in his business, so he's maintaining it for now. At the NFS sprint he demonstrated significant speedups via exploiting profile-guided optimization, so it should of substantial interest over time. If everyone loses interest, fine, then it becomes like PC/VC6/ and RISCOS/ and ... in the meantime, it doesn't get in the way of anything I ever do <0.5 wink>. From python-checkins at python.org Wed May 31 13:37:59 2006 From: python-checkins at python.org (thomas.heller) Date: Wed, 31 May 2006 13:37:59 +0200 (CEST) Subject: [Python-checkins] r46575 - python/trunk/Modules/_ctypes/_ctypes.c Message-ID: <20060531113759.438241E4002@bag.python.org> Author: thomas.heller Date: Wed May 31 13:37:58 2006 New Revision: 46575 Modified: python/trunk/Modules/_ctypes/_ctypes.c Log: PyTuple_Pack is not available in Python 2.3, but ctypes must stay compatible with that. Modified: python/trunk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes.c (original) +++ python/trunk/Modules/_ctypes/_ctypes.c Wed May 31 13:37:58 2006 @@ -2185,7 +2185,7 @@ only it's object list. So we create a tuple, containing b_objects list PLUS the array itself, and return that! */ - return PyTuple_Pack(2, keep, value); + return Py_BuildValue("(OO)", keep, value); } PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", From tim.peters at gmail.com Wed May 31 14:40:35 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 31 May 2006 08:40:35 -0400 Subject: [Python-checkins] r46520 - in python/trunk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libfunctional.tex Doc/lib/libfunctools.tex Lib/test/test_functional.py Lib/test/test_functools.py Misc/NEWS Modules/_functoolsmodule.c Modules/functionalmodule. In-Reply-To: References: <1f7befae0605301835r4f62fb65udf3c144a69eccfce@mail.gmail.com> Message-ID: <1f7befae0605310540j7b399cb9h9168be64ccc25d72@mail.gmail.com> [Brett Cannon] > Where would this list be stored? If the import fails the module is not > imported, so how do you get access to the list? Oh, details ;-) > It could be some function that *must* be called before any imports > that registers with test.test_support what modules it can not be > able to import and then check that way. That would work. Or the list could be stored in a stylized comment, which regrtest.py sucks up via searching the source when it catches an import error. > Otherwise the list would just have to be external to all tests (which > might not be so bad to have a master list of modules we think can > be skipped on various platforms and then what modules can fail on > import for what tests). That can work too. The only thing that can't work is the current scheme. A hole is that whether an import failure should mean "test skipped" also depends on the platform, like that test_startfile should suffer an import failure unless you're on Windows (in which case it should not). It can also depend on how the platform is configured (e.g., test_bsddb3 or test_zipimport depend on whether you've installed external libraries). But I'm happy to take improvement over perfection. From python-checkins at python.org Wed May 31 15:18:57 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 31 May 2006 15:18:57 +0200 (CEST) Subject: [Python-checkins] r46576 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060531131857.3E1981E4002@bag.python.org> Author: andrew.kuchling Date: Wed May 31 15:18:56 2006 New Revision: 46576 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: 'functional' module was renamed to 'functools' Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Wed May 31 15:18:56 2006 @@ -125,7 +125,7 @@ %====================================================================== \section{PEP 309: Partial Function Application\label{pep-309}} -The \module{functional} module is intended to contain tools for +The \module{functools} module is intended to contain tools for functional-style programming. Currently it only contains a \class{partial()} function, but new functions will probably be added in future versions of Python. @@ -136,7 +136,7 @@ you could create a new function \code{g(b, c)} that was equivalent to \code{f(1, b, c)}. This is called ``partial function application'', and is provided by the \class{partial} class in the new -\module{functional} module. +\module{functools} module. The constructor for \class{partial} takes the arguments \code{(\var{function}, \var{arg1}, \var{arg2}, ... @@ -147,18 +147,18 @@ Here's a small but realistic example: \begin{verbatim} -import functional +import functools def log (message, subsystem): "Write the contents of 'message' to the specified subsystem." print '%s: %s' % (subsystem, message) ... -server_log = functional.partial(log, subsystem='server') +server_log = functools.partial(log, subsystem='server') server_log('Unable to open socket') \end{verbatim} -Here's another example, from a program that uses PyGTk. Here a +Here's another example, from a program that uses PyGTK. Here a context-sensitive pop-up menu is being constructed dynamically. The callback provided for the menu option is a partially applied version of the \method{open_item()} method, where the first argument has been @@ -170,7 +170,7 @@ def open_item(self, path): ... def init (self): - open_func = functional.partial(self.open_item, item_path) + open_func = functools.partial(self.open_item, item_path) popup_menu.append( ("Open", open_func, 1) ) \end{verbatim} From buildbot at python.org Wed May 31 15:26:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 13:26:40 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060531132640.495F81E4011@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/253 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: thomas.heller Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 31 15:34:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 13:34:45 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060531133445.7AF261E4002@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/541 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 31 15:35:42 2006 From: python-checkins at python.org (kristjan.jonsson) Date: Wed, 31 May 2006 15:35:42 +0200 (CEST) Subject: [Python-checkins] r46577 - python/trunk/PCbuild8/make_versioninfo.vcproj python/trunk/PCbuild8/pcbuild.sln python/trunk/PCbuild8/pythoncore.vcproj python/trunk/PCbuild8/pythoncore_link.txt python/trunk/PCbuild8/pythoncore_pgo.vcproj python/trunk/PCbuild8/pythoncore_pgo_link.txt Message-ID: <20060531133542.286DC1E400F@bag.python.org> Author: kristjan.jonsson Date: Wed May 31 15:35:41 2006 New Revision: 46577 Removed: python/trunk/PCbuild8/pythoncore_link.txt Modified: python/trunk/PCbuild8/make_versioninfo.vcproj python/trunk/PCbuild8/pcbuild.sln python/trunk/PCbuild8/pythoncore.vcproj python/trunk/PCbuild8/pythoncore_pgo.vcproj python/trunk/PCbuild8/pythoncore_pgo_link.txt Log: Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation Modified: python/trunk/PCbuild8/make_versioninfo.vcproj ============================================================================== --- python/trunk/PCbuild8/make_versioninfo.vcproj (original) +++ python/trunk/PCbuild8/make_versioninfo.vcproj Wed May 31 15:35:41 2006 @@ -1,13 +1,10 @@ + + @@ -690,7 +694,7 @@ > - - - - Deleted: /python/trunk/PCbuild8/pythoncore_link.txt ============================================================================== --- /python/trunk/PCbuild8/pythoncore_link.txt Wed May 31 15:35:41 2006 +++ (empty file) @@ -1,311 +0,0 @@ -/OUT:"./python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\./python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\python25.pgd" /BASE:"0x1e000000" /IMPLIB:".\./python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore\adler32.obj" - -".\x86-temp-release\pythoncore\compress.obj" - -".\x86-temp-release\pythoncore\crc32.obj" - -".\x86-temp-release\pythoncore\deflate.obj" - -".\x86-temp-release\pythoncore\gzio.obj" - -".\x86-temp-release\pythoncore\infback.obj" - -".\x86-temp-release\pythoncore\inffast.obj" - -".\x86-temp-release\pythoncore\inflate.obj" - -".\x86-temp-release\pythoncore\inftrees.obj" - -".\x86-temp-release\pythoncore\trees.obj" - -".\x86-temp-release\pythoncore\uncompr.obj" - -".\x86-temp-release\pythoncore\zlibmodule.obj" - -".\x86-temp-release\pythoncore\zutil.obj" - -".\x86-temp-release\pythoncore\_bisectmodule.obj" - -".\x86-temp-release\pythoncore\_codecs_cn.obj" - -".\x86-temp-release\pythoncore\_codecs_hk.obj" - -".\x86-temp-release\pythoncore\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore\_codecs_jp.obj" - -".\x86-temp-release\pythoncore\_codecs_kr.obj" - -".\x86-temp-release\pythoncore\_codecs_tw.obj" - -".\x86-temp-release\pythoncore\_codecsmodule.obj" - -".\x86-temp-release\pythoncore\_csv.obj" - -".\x86-temp-release\pythoncore\_heapqmodule.obj" - -".\x86-temp-release\pythoncore\_hotshot.obj" - -".\x86-temp-release\pythoncore\_localemodule.obj" - -".\x86-temp-release\pythoncore\_lsprof.obj" - -".\x86-temp-release\pythoncore\_randommodule.obj" - -".\x86-temp-release\pythoncore\_sre.obj" - -".\x86-temp-release\pythoncore\_subprocess.obj" - -".\x86-temp-release\pythoncore\_weakref.obj" - -".\x86-temp-release\pythoncore\_winreg.obj" - -".\x86-temp-release\pythoncore\abstract.obj" - -".\x86-temp-release\pythoncore\acceler.obj" - -".\x86-temp-release\pythoncore\arraymodule.obj" - -".\x86-temp-release\pythoncore\asdl.obj" - -".\x86-temp-release\pythoncore\ast.obj" - -".\x86-temp-release\pythoncore\audioop.obj" - -".\x86-temp-release\pythoncore\binascii.obj" - -".\x86-temp-release\pythoncore\bitset.obj" - -".\x86-temp-release\pythoncore\bltinmodule.obj" - -".\x86-temp-release\pythoncore\boolobject.obj" - -".\x86-temp-release\pythoncore\bufferobject.obj" - -".\x86-temp-release\pythoncore\cellobject.obj" - -".\x86-temp-release\pythoncore\ceval.obj" - -".\x86-temp-release\pythoncore\classobject.obj" - -".\x86-temp-release\pythoncore\cmathmodule.obj" - -".\x86-temp-release\pythoncore\cobject.obj" - -".\x86-temp-release\pythoncore\codecs.obj" - -".\x86-temp-release\pythoncore\codeobject.obj" - -".\x86-temp-release\pythoncore\collectionsmodule.obj" - -".\x86-temp-release\pythoncore\compile.obj" - -".\x86-temp-release\pythoncore\complexobject.obj" - -".\x86-temp-release\pythoncore\config.obj" - -".\x86-temp-release\pythoncore\cPickle.obj" - -".\x86-temp-release\pythoncore\cStringIO.obj" - -".\x86-temp-release\pythoncore\datetimemodule.obj" - -".\x86-temp-release\pythoncore\descrobject.obj" - -".\x86-temp-release\pythoncore\dictobject.obj" - -".\x86-temp-release\pythoncore\dl_nt.obj" - -".\x86-temp-release\pythoncore\dynload_win.obj" - -".\x86-temp-release\pythoncore\enumobject.obj" - -".\x86-temp-release\pythoncore\errnomodule.obj" - -".\x86-temp-release\pythoncore\errors.obj" - -".\x86-temp-release\pythoncore\exceptions.obj" - -".\x86-temp-release\pythoncore\fileobject.obj" - -".\x86-temp-release\pythoncore\firstsets.obj" - -".\x86-temp-release\pythoncore\floatobject.obj" - -".\x86-temp-release\pythoncore\frameobject.obj" - -".\x86-temp-release\pythoncore\frozen.obj" - -".\x86-temp-release\pythoncore\funcobject.obj" - -".\x86-temp-release\pythoncore\functionalmodule.obj" - -".\x86-temp-release\pythoncore\future.obj" - -".\x86-temp-release\pythoncore\gcmodule.obj" - -".\x86-temp-release\pythoncore\genobject.obj" - -".\x86-temp-release\pythoncore\getargs.obj" - -".\x86-temp-release\pythoncore\getcompiler.obj" - -".\x86-temp-release\pythoncore\getcopyright.obj" - -".\x86-temp-release\pythoncore\getmtime.obj" - -".\x86-temp-release\pythoncore\getopt.obj" - -".\x86-temp-release\pythoncore\getpathp.obj" - -".\x86-temp-release\pythoncore\getplatform.obj" - -".\x86-temp-release\pythoncore\getversion.obj" - -".\x86-temp-release\pythoncore\graminit.obj" - -".\x86-temp-release\pythoncore\grammar.obj" - -".\x86-temp-release\pythoncore\grammar1.obj" - -".\x86-temp-release\pythoncore\imageop.obj" - -".\x86-temp-release\pythoncore\import.obj" - -".\x86-temp-release\pythoncore\import_nt.obj" - -".\x86-temp-release\pythoncore\importdl.obj" - -".\x86-temp-release\pythoncore\intobject.obj" - -".\x86-temp-release\pythoncore\iterobject.obj" - -".\x86-temp-release\pythoncore\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore\listnode.obj" - -".\x86-temp-release\pythoncore\listobject.obj" - -".\x86-temp-release\pythoncore\longobject.obj" - -".\x86-temp-release\pythoncore\main.obj" - -".\x86-temp-release\pythoncore\marshal.obj" - -".\x86-temp-release\pythoncore\mathmodule.obj" - -".\x86-temp-release\pythoncore\md5.obj" - -".\x86-temp-release\pythoncore\md5module.obj" - -".\x86-temp-release\pythoncore\metagrammar.obj" - -".\x86-temp-release\pythoncore\methodobject.obj" - -".\x86-temp-release\pythoncore\mmapmodule.obj" - -".\x86-temp-release\pythoncore\modsupport.obj" - -".\x86-temp-release\pythoncore\moduleobject.obj" - -".\x86-temp-release\pythoncore\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore\multibytecodec.obj" - -".\x86-temp-release\pythoncore\myreadline.obj" - -".\x86-temp-release\pythoncore\mysnprintf.obj" - -".\x86-temp-release\pythoncore\mystrtoul.obj" - -".\x86-temp-release\pythoncore\node.obj" - -".\x86-temp-release\pythoncore\object.obj" - -".\x86-temp-release\pythoncore\obmalloc.obj" - -".\x86-temp-release\pythoncore\operator.obj" - -".\x86-temp-release\pythoncore\parser.obj" - -".\x86-temp-release\pythoncore\parsermodule.obj" - -".\x86-temp-release\pythoncore\parsetok.obj" - -".\x86-temp-release\pythoncore\posixmodule.obj" - -".\x86-temp-release\pythoncore\pyarena.obj" - -".\x86-temp-release\pythoncore\pyfpe.obj" - -".\x86-temp-release\pythoncore\pystate.obj" - -".\x86-temp-release\pythoncore\pystrtod.obj" - -".\x86-temp-release\pythoncore\Python-ast.obj" - -".\x86-temp-release\pythoncore\python_nt.res" - -".\x86-temp-release\pythoncore\pythonrun.obj" - -".\x86-temp-release\pythoncore\rangeobject.obj" - -".\x86-temp-release\pythoncore\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore\rotatingtree.obj" - -".\x86-temp-release\pythoncore\setobject.obj" - -".\x86-temp-release\pythoncore\sha256module.obj" - -".\x86-temp-release\pythoncore\sha512module.obj" - -".\x86-temp-release\pythoncore\shamodule.obj" - -".\x86-temp-release\pythoncore\signalmodule.obj" - -".\x86-temp-release\pythoncore\sliceobject.obj" - -".\x86-temp-release\pythoncore\stringobject.obj" - -".\x86-temp-release\pythoncore\stropmodule.obj" - -".\x86-temp-release\pythoncore\structmember.obj" - -".\x86-temp-release\pythoncore\_struct.obj" - -".\x86-temp-release\pythoncore\structseq.obj" - -".\x86-temp-release\pythoncore\symtable.obj" - -".\x86-temp-release\pythoncore\symtablemodule.obj" - -".\x86-temp-release\pythoncore\sysmodule.obj" - -".\x86-temp-release\pythoncore\thread.obj" - -".\x86-temp-release\pythoncore\threadmodule.obj" - -".\x86-temp-release\pythoncore\timemodule.obj" - -".\x86-temp-release\pythoncore\tokenizer.obj" - -".\x86-temp-release\pythoncore\traceback.obj" - -".\x86-temp-release\pythoncore\tupleobject.obj" - -".\x86-temp-release\pythoncore\typeobject.obj" - -".\x86-temp-release\pythoncore\unicodectype.obj" - -".\x86-temp-release\pythoncore\unicodeobject.obj" - -".\x86-temp-release\pythoncore\weakrefobject.obj" - -".\x86-temp-release\pythoncore\xxsubtype.obj" - -".\x86-temp-release\pythoncore\yuvconvert.obj" - -".\x86-temp-release\pythoncore\zipimport.obj" \ No newline at end of file Modified: python/trunk/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- python/trunk/PCbuild8/pythoncore_pgo.vcproj (original) +++ python/trunk/PCbuild8/pythoncore_pgo.vcproj Wed May 31 15:35:41 2006 @@ -68,7 +68,7 @@ + + @@ -383,7 +387,7 @@ > - - @@ -638,7 +638,7 @@ > Modified: python/trunk/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- python/trunk/PCbuild8/pythoncore_pgo_link.txt (original) +++ python/trunk/PCbuild8/pythoncore_pgo_link.txt Wed May 31 15:35:41 2006 @@ -1,4 +1,4 @@ -/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:"c:\pydev\PCbuild\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib +/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:".\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\x86-temp-release\pythoncore_pgo\adler32.obj" @@ -44,6 +44,8 @@ ".\x86-temp-release\pythoncore_pgo\_csv.obj" +".\x86-temp-release\pythoncore_pgo\_functoolsmodule.obj" + ".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" ".\x86-temp-release\pythoncore_pgo\_hotshot.obj" @@ -142,8 +144,6 @@ ".\x86-temp-release\pythoncore_pgo\funcobject.obj" -".\x86-temp-release\pythoncore_pgo\functionalmodule.obj" - ".\x86-temp-release\pythoncore_pgo\future.obj" ".\x86-temp-release\pythoncore_pgo\gcmodule.obj" From buildbot at python.org Wed May 31 15:38:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 13:38:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060531133834.7A2B41E4002@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/522 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 31 16:08:49 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 31 May 2006 16:08:49 +0200 (CEST) Subject: [Python-checkins] r46578 - in python/trunk: Doc/lib/libsimplexmlrpc.tex Lib/DocXMLRPCServer.py Lib/SimpleXMLRPCServer.py Message-ID: <20060531140849.8F9041E4002@bag.python.org> Author: andrew.kuchling Date: Wed May 31 16:08:48 2006 New Revision: 46578 Modified: python/trunk/Doc/lib/libsimplexmlrpc.tex python/trunk/Lib/DocXMLRPCServer.py python/trunk/Lib/SimpleXMLRPCServer.py Log: [Bug #1473048] SimpleXMLRPCServer and DocXMLRPCServer don't look at the path of the HTTP request at all; you can POST or GET from / or /RPC2 or /blahblahblah with the same results. Security scanners that look for /cgi-bin/phf will therefore report lots of vulnerabilities. Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class, and report a 404 error if the path isn't on the allowed list. Possibly-controversial aspect of this change: the default makes only '/' and '/RPC2' legal. Maybe this will break people's applications (though I doubt it). We could just set the default to an empty tuple, which would exactly match the current behaviour. Modified: python/trunk/Doc/lib/libsimplexmlrpc.tex ============================================================================== --- python/trunk/Doc/lib/libsimplexmlrpc.tex (original) +++ python/trunk/Doc/lib/libsimplexmlrpc.tex Wed May 31 16:08:48 2006 @@ -111,6 +111,15 @@ Registers the XML-RPC multicall function system.multicall. \end{methoddesc} +\begin{memberdesc}[SimpleXMLRPCServer]{rpc_paths} +An attribute value that must be a tuple listing valid path portions of +the URL for receiving XML-RPC requests. Requests posted to other +paths will result in a 404 ``no such page'' HTTP error. If this +tuple is empty, all paths will be considered valid. +The default value is \code{('/', '/RPC2')}. + \versionadded{2.5} +\end{memberdesc} + Example: \begin{verbatim} Modified: python/trunk/Lib/DocXMLRPCServer.py ============================================================================== --- python/trunk/Lib/DocXMLRPCServer.py (original) +++ python/trunk/Lib/DocXMLRPCServer.py Wed May 31 16:08:48 2006 @@ -227,6 +227,10 @@ Interpret all HTTP GET requests as requests for server documentation. """ + # Check that the path is legal + if not self.is_rpc_path_valid(): + self.report_404() + return response = self.server.generate_html_documentation() self.send_response(200) Modified: python/trunk/Lib/SimpleXMLRPCServer.py ============================================================================== --- python/trunk/Lib/SimpleXMLRPCServer.py (original) +++ python/trunk/Lib/SimpleXMLRPCServer.py Wed May 31 16:08:48 2006 @@ -423,6 +423,17 @@ XML-RPC requests. """ + # Class attribute listing the accessible path components; + # paths not on this list will result in a 404 error. + rpc_paths = ('/', '/RPC2') + + def is_rpc_path_valid(self): + if self.rpc_paths: + return self.path in self.rpc_paths + else: + # If .rpc_paths is empty, just assume all paths are legal + return True + def do_POST(self): """Handles the HTTP POST request. @@ -430,6 +441,11 @@ which are forwarded to the server's _dispatch method for handling. """ + # Check that the path is legal + if not self.is_rpc_path_valid(): + self.report_404() + return + try: # Get arguments by reading body of request. # We read this in chunks to avoid straining @@ -468,6 +484,18 @@ self.wfile.flush() self.connection.shutdown(1) + def report_404 (self): + # Report a 404 error + self.send_response(404) + response = 'No such page' + self.send_header("Content-type", "text/plain") + self.send_header("Content-length", str(len(response))) + self.end_headers() + self.wfile.write(response) + # shut down the connection + self.wfile.flush() + self.connection.shutdown(1) + def log_request(self, code='-', size='-'): """Selectively log an accepted request.""" From guido at python.org Wed May 31 16:10:22 2006 From: guido at python.org (Guido van Rossum) Date: Wed, 31 May 2006 07:10:22 -0700 Subject: [Python-checkins] [Python-Dev] r46300 - in python/trunk: Lib/socket.py Lib/test/test_socket.py Lib/test/test_struct.py Modules/_struct.c Modules/arraymodule.c Modules/socketmodule.c In-Reply-To: <8393fff0605310335o12b2b26ew43ba63cfd69c26e9@mail.gmail.com> References: <20060526120329.9A9671E400C@bag.python.org> <8393fff0605310335o12b2b26ew43ba63cfd69c26e9@mail.gmail.com> Message-ID: On 5/31/06, Martin Blais wrote: > So I assume you're suggesting the following renames: > > pack_to -> packinto > recv_buf -> recvinto > recvfrom_buf -> recvfrominto > > (I don't like that last one very much. > I'll go ahead and make those renames once I return.) You could add an underscore before _into. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-checkins at python.org Wed May 31 16:12:48 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 31 May 2006 16:12:48 +0200 (CEST) Subject: [Python-checkins] r46579 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060531141248.083441E4002@bag.python.org> Author: andrew.kuchling Date: Wed May 31 16:12:47 2006 New Revision: 46579 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Mention SimpleXMLRPCServer change Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Wed May 31 16:12:47 2006 @@ -1508,6 +1508,14 @@ (Patch from Robert Kiendl.) % Patch #1472854 +\item The \module{SimpleXMLRPCServer} and \module{DocXMLRPCServer} +classes now have a \member{rpc_paths} attribute that constrains +XML-RPC operations to a limited set of URL paths; the default is +to allow only \code{'/'} and \code{'/RPC2'}. Setting +\member{rpc_paths} to \code{None} or an empty tuple disables +this path checking. +% Bug #1473048 + \item The \module{socket} module now supports \constant{AF_NETLINK} sockets on Linux, thanks to a patch from Philippe Biondi. Netlink sockets are a Linux-specific mechanism for communications @@ -2163,6 +2171,13 @@ arguments instead. The modules also no longer accept the deprecated \var{bin} keyword parameter. +\item Library: The \module{SimpleXMLRPCServer} and \module{DocXMLRPCServer} +classes now have a \member{rpc_paths} attribute that constrains +XML-RPC operations to a limited set of URL paths; the default is +to allow only \code{'/'} and \code{'/RPC2'}. Setting +\member{rpc_paths} to \code{None} or an empty tuple disables +this path checking. + \item C API: Many functions now use \ctype{Py_ssize_t} instead of \ctype{int} to allow processing more data on 64-bit machines. Extension code may need to make the same change to avoid From tim.peters at gmail.com Wed May 31 16:22:07 2006 From: tim.peters at gmail.com (Tim Peters) Date: Wed, 31 May 2006 10:22:07 -0400 Subject: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj pytho In-Reply-To: <129CEF95A523704B9D46959C922A28000282A8ED@nemesis.central.ccp.cc> References: <129CEF95A523704B9D46959C922A28000282A8ED@nemesis.central.ccp.cc> Message-ID: <1f7befae0605310722y33626560x57e0b92db49a637f@mail.gmail.com> [Kristj?n V. J?nsson, on PCbuild8/] > Well, I was sort of hoping that it would "maintain itself" in an open source > manner, It may or may not -- depends on user interest. So far you appear to be the only one playing in this directory, which may or may not change (I expect it will, but can't know that). > but if it needs an official maintainter, we can do that. It should have a maintainer at least at the start. That can't, e.g., be me, since I don't have .NET 2005 and have no current plan to acquire it. You're elected :-) > Particularly, we are interested in input from the community on how better to > set up the projects in VS to perform the profile-guilded optimization step with > minimal user input. Our current approach relies on a file called > pythoncore_pgo_link.txt which needs to be manually updated when the project > changes significantly. Starting a discussion on comp.lang.python should find people interested in working on that. > Martin, you have been doing work on getting python to be officially supported > with VC 8. I remember that we discussed this at the pycon sprint. My VC8 build > of 2.5 indeed did crash in the regression suite. I have some ideas on how to fix > the C runtime problem. I will try some things locally and then bounce them off > you and Tim. The python-dev mailing list is appropriate for that (mailing lists generally work better than private email for hammering out tech problems -- more eyeballs, more aggregate knowledge and "spare time" to tap). > ... > p.s. do you think I ought to subscribe to python-checkins? Everyone at the Iceland sprint was requested to do so in one of the messages to the NFS list before the sprint. So long as you continue making checkins, yes, you should stay subscribed to python-checkins (and python-dev), because that's where replies to checkin messages end up. From python-checkins at python.org Wed May 31 16:28:08 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 31 May 2006 16:28:08 +0200 (CEST) Subject: [Python-checkins] r46580 - python/trunk/Modules/_struct.c Message-ID: <20060531142808.90D991E4002@bag.python.org> Author: tim.peters Date: Wed May 31 16:28:07 2006 New Revision: 46580 Modified: python/trunk/Modules/_struct.c Log: Trimmed trailing whitespace. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Wed May 31 16:28:07 2006 @@ -1219,7 +1219,7 @@ const formatdef *f; const formatdef *e; formatcode *codes; - + const char *s; const char *fmt; char c; @@ -1228,7 +1228,7 @@ fmt = PyString_AS_STRING(self->s_format); f = whichtable((char **)&fmt); - + s = fmt; size = 0; len = 0; @@ -1256,7 +1256,7 @@ e = getentry(c, f); if (e == NULL) return -1; - + switch (c) { case 's': /* fall through */ case 'p': len++; break; @@ -1283,7 +1283,7 @@ return -1; } self->s_codes = codes; - + s = fmt; size = 0; while ((c = *s++) != '\0') { @@ -1300,7 +1300,7 @@ num = 1; e = getentry(c, f); - + size = align(size, c, e); if (c == 's' || c == 'p') { codes->offset = size; @@ -1323,7 +1323,7 @@ codes->fmtdef = NULL; codes->offset = size; codes->size = 0; - + return 0; } @@ -1363,7 +1363,7 @@ Py_INCREF(o_format); Py_XDECREF(soself->s_format); soself->s_format = o_format; - + ret = prepare_s(soself); return ret; } @@ -1432,7 +1432,7 @@ { PyStructObject *soself = (PyStructObject *)self; assert(PyStruct_Check(self)); - assert(soself->s_codes != NULL); + assert(soself->s_codes != NULL); if (inputstr == NULL || !PyString_Check(inputstr) || PyString_GET_SIZE(inputstr) != soself->s_size) { PyErr_Format(StructError, @@ -1474,7 +1474,7 @@ "unpack_from requires a buffer argument"); return NULL; } - + if (offset < 0) offset += buffer_len; @@ -1548,7 +1548,7 @@ } } } - + /* Success */ return 0; } @@ -1577,12 +1577,12 @@ "pack requires exactly %zd arguments", soself->s_len); return NULL; } - + /* Allocate a new string */ result = PyString_FromStringAndSize((char *)NULL, soself->s_size); if (result == NULL) return NULL; - + /* Call the guts */ if ( s_pack_internal(soself, args, 0, PyString_AS_STRING(result)) != 0 ) { Py_DECREF(result); @@ -1615,14 +1615,14 @@ PyTuple_GET_SIZE(args) != (soself->s_len + 2)) { PyErr_Format(StructError, - "pack_to requires exactly %zd arguments", + "pack_to requires exactly %zd arguments", (soself->s_len + 2)); return NULL; } /* Extract a writable memory buffer from the first argument */ - if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), - (void**)&buffer, &buffer_len) == -1 ) { + if ( PyObject_AsWriteBuffer(PyTuple_GET_ITEM(args, 0), + (void**)&buffer, &buffer_len) == -1 ) { return NULL; } assert( buffer_len >= 0 ); @@ -1641,7 +1641,7 @@ soself->s_size); return NULL; } - + /* Call the guts */ if ( s_pack_internal(soself, args, 2, buffer + offset) != 0 ) { return NULL; @@ -1667,7 +1667,7 @@ static struct PyMethodDef s_methods[] = { {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__}, - {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, + {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__}, {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__}, {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__}, {NULL, NULL} /* sentinel */ @@ -1756,10 +1756,10 @@ return; } -#else +#else /* This speed trick can't be used until overflow masking goes away, because native endian always raises exceptions instead of overflow masking. */ - + /* Check endian and swap in faster functions */ { int one = 1; @@ -1781,7 +1781,7 @@ listed in the same order */ if (ptr == other) other++; - /* Only use the trick if the + /* Only use the trick if the size matches */ if (ptr->size != native->size) break; @@ -1799,7 +1799,7 @@ } } #endif - + /* Add some symbolic constants to the module */ if (StructError == NULL) { StructError = PyErr_NewException("struct.error", NULL, NULL); @@ -1812,7 +1812,7 @@ Py_INCREF((PyObject*)&PyStructType); PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType); - + PyModule_AddIntConstant(m, "_PY_STRUCT_RANGE_CHECKING", 1); #ifdef PY_STRUCT_OVERFLOW_MASKING PyModule_AddIntConstant(m, "_PY_STRUCT_OVERFLOW_MASKING", 1); From python-checkins at python.org Wed May 31 17:33:23 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 31 May 2006 17:33:23 +0200 (CEST) Subject: [Python-checkins] r46581 - python/trunk/Modules/_struct.c Message-ID: <20060531153323.4F3F21E4002@bag.python.org> Author: tim.peters Date: Wed May 31 17:33:22 2006 New Revision: 46581 Modified: python/trunk/Modules/_struct.c Log: _range_error(): Speed and simplify (there's no real need for loops here). Assert that size_t is actually big enough, and that f->size is at least one. Wrap a long line. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Wed May 31 17:33:22 2006 @@ -308,26 +308,27 @@ static int _range_error(const formatdef *f, int is_unsigned) { - if (is_unsigned == 0) { - Py_ssize_t smallest, largest = 0; - Py_ssize_t i = f->size * 8; - while (--i > 0) { - largest = (largest * 2) + 1; - } - smallest = -largest - 1; + /* ulargest is the largest unsigned value with f->size bytes. + * Note that the simpler: + * ((size_t)1 << (f->size * 8)) - 1 + * doesn't work when f->size == size_t because C doesn't define what + * happens when a left shift count is >= the number of bits in the + * integer being shifted; e.g., on some boxes it doesn't shift at + * all when they're equal. + */ + const size_t ulargest = (size_t)-1 >> ((SIZEOF_SIZE_T - f->size)*8); + assert(f->size >= 1 && f->size <= SIZEOF_SIZE_T); + if (is_unsigned) PyErr_Format(StructError, - "'%c' format requires %zd <= number <= %zd", + "'%c' format requires 0 <= number <= %zu", f->format, - smallest, - largest); - } else { - size_t largest = 0; - Py_ssize_t i = f->size * 8; - while (--i >= 0) - largest = (largest * 2) + 1; + ulargest); + else { + const Py_ssize_t largest = (Py_ssize_t)(ulargest >> 1); PyErr_Format(StructError, - "'%c' format requires 0 <= number <= %zu", + "'%c' format requires %zd <= number <= %zd", f->format, + ~ largest, largest); } #ifdef PY_STRUCT_OVERFLOW_MASKING @@ -343,7 +344,8 @@ Py_XDECREF(ptraceback); if (msg == NULL) return -1; - rval = PyErr_Warn(PyExc_DeprecationWarning, PyString_AS_STRING(msg)); + rval = PyErr_Warn(PyExc_DeprecationWarning, + PyString_AS_STRING(msg)); Py_DECREF(msg); if (rval == 0) return 0; From python-checkins at python.org Wed May 31 17:34:37 2006 From: python-checkins at python.org (tim.peters) Date: Wed, 31 May 2006 17:34:37 +0200 (CEST) Subject: [Python-checkins] r46582 - python/trunk/Modules/_struct.c Message-ID: <20060531153437.6170A1E4002@bag.python.org> Author: tim.peters Date: Wed May 31 17:34:37 2006 New Revision: 46582 Modified: python/trunk/Modules/_struct.c Log: Repaired error in new comment. Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Wed May 31 17:34:37 2006 @@ -311,10 +311,10 @@ /* ulargest is the largest unsigned value with f->size bytes. * Note that the simpler: * ((size_t)1 << (f->size * 8)) - 1 - * doesn't work when f->size == size_t because C doesn't define what - * happens when a left shift count is >= the number of bits in the - * integer being shifted; e.g., on some boxes it doesn't shift at - * all when they're equal. + * doesn't work when f->size == sizeof(size_t) because C doesn't + * define what happens when a left shift count is >= the number of + * bits in the integer being shifted; e.g., on some boxes it doesn't + * shift at all when they're equal. */ const size_t ulargest = (size_t)-1 >> ((SIZEOF_SIZE_T - f->size)*8); assert(f->size >= 1 && f->size <= SIZEOF_SIZE_T); From buildbot at python.org Wed May 31 18:09:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 16:09:15 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060531160915.9280D1E4007@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/255 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,kristjan.jonsson,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed May 31 18:47:23 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 31 May 2006 16:47:23 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060531164723.395621E4007@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/544 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed May 31 20:19:56 2006 From: python-checkins at python.org (bob.ippolito) Date: Wed, 31 May 2006 20:19:56 +0200 (CEST) Subject: [Python-checkins] r46583 - sandbox/trunk/structbench/structformats.txt Message-ID: <20060531181956.F0E261E4007@bag.python.org> Author: bob.ippolito Date: Wed May 31 20:19:56 2006 New Revision: 46583 Added: sandbox/trunk/structbench/structformats.txt (contents, props changed) Log: text file listing the sources for the formats that I compiled the benchmark from Added: sandbox/trunk/structbench/structformats.txt ============================================================================== --- (empty file) +++ sandbox/trunk/structbench/structformats.txt Wed May 31 20:19:56 2006 @@ -0,0 +1,75 @@ +# pickletools +d +# aifc +>l +>L +>h +# base64 +!HHB +# binhex +>h +>ii +>H +# chunk +>L +4I +II +# gzip +L +# logging.handlers +>L +# pickle +d +# platform +P +# posixfile +lxxxxlxxxxlhh +hhlllii +hhllhh +# tarfile +l +L +148b +148B +356B +356b +L +>f +>d +>l +# zipfile +<4s4H2lH +<4s4B4HlLL5HLl +<4s2B4HlLL2H + References: <1f7befae0605301835r4f62fb65udf3c144a69eccfce@mail.gmail.com> <1f7befae0605310540j7b399cb9h9168be64ccc25d72@mail.gmail.com> Message-ID: On 5/31/06, Tim Peters wrote: > > [Brett Cannon] > > Where would this list be stored? If the import fails the module is not > > imported, so how do you get access to the list? > > Oh, details ;-) > It could be some function that *must* be called before any imports > > that registers with test.test_support what modules it can not be > > able to import and then check that way. > > That would work. Or the list could be stored in a stylized comment, > which regrtest.py sucks up via searching the source when it catches an > import error. That could work as well, although I am personally not a fan of requiring special formatting in comments. Another option is a custom, test-only import function that returns a module object and raises TestSkipped if the import fails. That would allow us to not catch ImportError and be very explicit about what imports can fail and not be an issue. > Otherwise the list would just have to be external to all tests (which > > might not be so bad to have a master list of modules we think can > > be skipped on various platforms and then what modules can fail on > > import for what tests). > > That can work too. The only thing that can't work is the current scheme. Nope. A hole is that whether an import failure should mean "test skipped" > also depends on the platform, like that test_startfile should suffer > an import failure unless you're on Windows (in which case it should > not). It can also depend on how the platform is configured (e.g., > test_bsddb3 or test_zipimport depend on whether you've installed > external libraries). But I'm happy to take improvement over > perfection. > OK, this should get kicked over to python-dev [which I am bcc:ing on this]. It looks like we need to have the testing framework have a way to mark tests that are implementation-specific (so that non-CPython interpreters can skip them), a better way to mark platform-specific tests, and a way to specify which imports failing signifies that a test just should not run compared to an actual error existing. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060531/224afe76/attachment.htm From martin at v.loewis.de Wed May 31 22:52:11 2006 From: martin at v.loewis.de (martin at v.loewis.de) Date: Wed, 31 May 2006 22:52:11 +0200 Subject: [Python-checkins] r46472 - python/trunk/PCbuild8 python/trunk/PCbuild8/Uninstal.wse python/trunk/PCbuild8/_bsddb.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj pytho In-Reply-To: <129CEF95A523704B9D46959C922A28000282A8ED@nemesis.central.ccp.cc> References: <129CEF95A523704B9D46959C922A28000282A8ED@nemesis.central.ccp.cc> Message-ID: <1149108731.447e01fb8520c@www.domainfactory-webmail.de> Zitat von "Kristj?n V. J?nsson" : > Well, I was sort of hoping that it would "maintain itself" in an open source > manner, but if it needs an official maintainter, we can do that. That could happen. Of course, we would still need somebody to decide whether a certain contributed patch should be applied to that directory or not. > Particularly, we are interested in input from the community on how better to > set up the projects in VS to perform the profile-guilded optimization step > with minimal user input. Our current approach relies on a file called > pythoncore_pgo_link.txt which needs to be manually updated when the project > changes significantly. I doubt you get much feedback from the community on that detail; you would probably need to actively collect feedback. > Martin, you have been doing work on getting python to be officially supported > with VC 8. I remember that we discussed this at the pycon sprint. My VC8 > build of 2.5 indeed did crash in the regression suite. I have some ideas on > how to fix the C runtime problem. I will try some things locally and then > bounce them off you and Tim. There was the signal problem which got resolved (even before the sprint IIRC); I haven't done anything on VC8 runtime errors since. For example, it still "should" crash when you are passing an unsupported fopen() mode. > p.s. do you think I ought to subscribe to python-checkins? No. I personally didn't for quite a long time. I'll just remember to CC you the next time. Regards, Martin