From jackjansen at users.sourceforge.net Sat Nov 1 17:28:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Nov 1 17:28:25 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PythonIDEMain.py, 1.35, 1.35.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv9059 Modified Files: Tag: release23-maint PythonIDEMain.py Log Message: Two related fixes: - The code for setting the working directory to $HOME was both incorrect and in the wrong place, fixed. - On OSX the default location for IDE scripts is now $HOME/Library/Python/IDE-Scripts. Together, these solve the problem that some people had (but, curiously enough, only some) that the IDE crashed at startup because it couldn't create "/Scripts". Index: PythonIDEMain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDEMain.py,v retrieving revision 1.35 retrieving revision 1.35.8.1 diff -C2 -d -r1.35 -r1.35.8.1 *** PythonIDEMain.py 6 May 2003 14:28:31 -0000 1.35 --- PythonIDEMain.py 1 Nov 2003 22:28:19 -0000 1.35.8.1 *************** *** 33,36 **** --- 33,42 ---- def __init__(self): + if sys.platform == "darwin": + if len(sys.argv) > 1 and sys.argv[1].startswith("-psn"): + home = os.getenv("HOME") + if home: + os.chdir(home) + print "We are in", os.getcwd() self.preffilepath = os.path.join("Python", "PythonIDE preferences") Wapplication.Application.__init__(self, 'Pide') *************** *** 50,58 **** import PyConsole, PyEdit Splash.wait() - if sys.platform == "darwin": - if sys.argv and sys.argv[0].startswith("-psn"): - home = os.getenv("HOME") - if home: - os.chdir(home) # With -D option (OSX command line only) keep stderr, for debugging the IDE # itself. --- 56,59 ---- *************** *** 141,147 **** path = os.path.join(os.getcwd(), "Mac", "IDE scripts") if not os.path.exists(path): ! path = os.path.join(os.getcwd(), "Scripts") if not os.path.exists(path): ! os.mkdir(path) f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w") f.close() --- 142,151 ---- path = os.path.join(os.getcwd(), "Mac", "IDE scripts") if not os.path.exists(path): ! if sys.platform == "darwin": ! path = os.path.join(os.getenv("HOME"), "Library", "Python", "IDE-Scripts") ! else: ! path = os.path.join(os.getcwd(), "Scripts") if not os.path.exists(path): ! os.makedirs(path) f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w") f.close() From jackjansen at users.sourceforge.net Sat Nov 1 17:30:52 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Nov 1 17:30:56 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PythonIDE.py, 1.13, 1.13.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv9402/Tools/IDE Modified Files: Tag: release23-maint PythonIDE.py Log Message: - In PythonIDE, add the Tools/IDE directory as the second entry in sys.path in stead of as the first, leaving PythonIDE.app/Contents/Resources as the first one. - When building the IDE for use with Apple-provided MacPython add PythonIDEMain.py to the Resources folder. Together these two makes fixes to PythonIDEMain available to Panther users. Index: PythonIDE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.py,v retrieving revision 1.13 retrieving revision 1.13.8.1 diff -C2 -d -r1.13 -r1.13.8.1 *** PythonIDE.py 3 May 2003 00:31:35 -0000 1.13 --- PythonIDE.py 1 Nov 2003 22:30:50 -0000 1.13.8.1 *************** *** 50,54 **** ide_path = sys.argv[0] if ide_path not in sys.path: ! sys.path.insert(0, ide_path) --- 50,54 ---- ide_path = sys.argv[0] if ide_path not in sys.path: ! sys.path.insert(1, ide_path) From jackjansen at users.sourceforge.net Sat Nov 1 17:30:52 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Nov 1 17:30:57 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile.panther, 1.1.2.1, 1.1.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv9402/OSX Modified Files: Tag: release23-maint Makefile.panther Log Message: - In PythonIDE, add the Tools/IDE directory as the second entry in sys.path in stead of as the first, leaving PythonIDE.app/Contents/Resources as the first one. - When building the IDE for use with Apple-provided MacPython add PythonIDEMain.py to the Resources folder. Together these two makes fixes to PythonIDEMain available to Panther users. Index: Makefile.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Attic/Makefile.panther,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** Makefile.panther 29 Aug 2003 22:46:25 -0000 1.1.2.1 --- Makefile.panther 1 Nov 2003 22:30:50 -0000 1.1.2.2 *************** *** 24,27 **** --- 24,30 ---- BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) + # Add the extra file to the resources. This is to work around a bugs in + # PythonIDEMain.py in the original 2.3. + cp ../Tools/IDE/PythonIDEMain.py $(DESDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: From jackjansen at users.sourceforge.net Sat Nov 1 18:14:44 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Nov 1 18:14:47 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PythonIDE.plist, 1.2.6.1, 1.2.6.2 PythonIDEMain.py, 1.35.8.1, 1.35.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv17711 Modified Files: Tag: release23-maint PythonIDE.plist PythonIDEMain.py Log Message: Allow for the documentation to be inside PythonIDE as well as in the Python.app inside the framework (the original location for 2.3). This enables us to install the documentation on Panther too. Index: PythonIDE.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.plist,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -C2 -d -r1.2.6.1 -r1.2.6.2 *** PythonIDE.plist 29 Sep 2003 15:11:31 -0000 1.2.6.1 --- PythonIDE.plist 1 Nov 2003 23:14:41 -0000 1.2.6.2 *************** *** 36,39 **** --- 36,48 ---- 2.3.2 + CFBundleHelpBookFolder + + PythonDocumentation + + CFBundleHelpBookName + Python Help + CFBundleHelpTOCFile + index.html + CFBundleIconFile PythonIDE.icns Index: PythonIDEMain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDEMain.py,v retrieving revision 1.35.8.1 retrieving revision 1.35.8.2 diff -C2 -d -r1.35.8.1 -r1.35.8.2 *** PythonIDEMain.py 1 Nov 2003 22:28:19 -0000 1.35.8.1 --- PythonIDEMain.py 1 Nov 2003 23:14:41 -0000 1.35.8.2 *************** *** 38,42 **** if home: os.chdir(home) - print "We are in", os.getcwd() self.preffilepath = os.path.join("Python", "PythonIDE preferences") Wapplication.Application.__init__(self, 'Pide') --- 38,41 ---- *************** *** 456,464 **** # And as AHRegisterHelpBook wants a bundle (with the right bits in # the plist file) we refer it to Python.app python_app = os.path.join(sys.prefix, 'Resources/Python.app') ! help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation') ! doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation') ! has_help = os.path.isdir(help_source) ! has_doc = os.path.isdir(doc_source) if has_help or has_doc: try: --- 455,483 ---- # And as AHRegisterHelpBook wants a bundle (with the right bits in # the plist file) we refer it to Python.app + # + # To make matters worse we have to look in two places: first in the IDE + # itself, then in the Python application inside the framework. + has_help = False + has_doc = False + ide_path_components = sys.argv[0].split("/") + if ide_path_components[-3:] == ["Contents", "Resources", "PythonIDE.py"]: + ide_app = "/".join(ide_path_components[:-3]) + help_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/Documentation') + doc_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/PythonDocumentation') + has_help = os.path.isdir(help_source) + has_doc = os.path.isdir(doc_source) + if has_help or has_doc: + try: + from Carbon import AH + AH.AHRegisterHelpBook(ide_app) + except (ImportError, MacOS.Error), arg: + pass # W.Message("Cannot register Python Documentation: %s" % str(arg)) python_app = os.path.join(sys.prefix, 'Resources/Python.app') ! if not has_help: ! help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation') ! has_help = os.path.isdir(help_source) ! if not has_doc: ! doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation') ! has_doc = os.path.isdir(doc_source) if has_help or has_doc: try: From jackjansen at users.sourceforge.net Sat Nov 1 20:11:11 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Nov 1 20:11:14 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.14, 1.14.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv5745 Modified Files: Tag: release23-maint PackageManager.py Log Message: Remember the scroll position when rebuilding the browser (as we do far too often). Fixes #824430. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -C2 -d -r1.14 -r1.14.4.1 *** PackageManager.py 21 Jul 2003 22:11:07 -0000 1.14 --- PackageManager.py 2 Nov 2003 01:11:09 -0000 1.14.4.1 *************** *** 367,370 **** --- 367,371 ---- def updatestatus(self): + topcell = self.w.packagebrowser.gettopcell() sel = self.w.packagebrowser.getselection() data = self.getbrowserdata(self.w.hidden_button.get()) *************** *** 397,400 **** --- 398,402 ---- self.w.force_button.enable(1) self.w.user_button.enable(1) + self.w.packagebrowser.settopcell(topcell) def listhit(self, *args, **kwargs): From rhettinger at users.sourceforge.net Sun Nov 2 00:37:46 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 2 00:37:50 2003 Subject: [Python-checkins] python/dist/src/Objects enumobject.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv7077 Modified Files: enumobject.c Log Message: Use PyTuple_Pack() to simplify enumerate(). Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** enumobject.c 28 May 2003 14:05:34 -0000 1.7 --- enumobject.c 2 Nov 2003 05:37:44 -0000 1.8 *************** *** 32,36 **** return NULL; } ! en->en_result = PyTuple_New(2); if (en->en_result == NULL) { Py_DECREF(en->en_sit); --- 32,36 ---- return NULL; } ! en->en_result = PyTuple_Pack(2, Py_None, Py_None); if (en->en_result == NULL) { Py_DECREF(en->en_sit); *************** *** 38,45 **** return NULL; } - Py_INCREF(Py_None); - PyTuple_SET_ITEM(en->en_result, 0, Py_None); - Py_INCREF(Py_None); - PyTuple_SET_ITEM(en->en_result, 1, Py_None); return (PyObject *)en; } --- 38,41 ---- From rhettinger at users.sourceforge.net Sun Nov 2 02:12:06 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 2 02:12:09 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv16525 Modified Files: pep-0322.txt Log Message: Three PEP updates: * Correct the pure python implementation. * Link to an implementation patch on SF. * Remove the proposed application of __reverse__ to enumerate(). Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0322.txt 30 Oct 2003 07:41:20 -0000 1.10 --- pep-0322.txt 2 Nov 2003 07:12:04 -0000 1.11 *************** *** 68,76 **** def reversed(x): ! try: ! return x.__reversed__() ! except AttributeError: ! pass ! if hasattr(x, "has_key"): raise ValueError("mappings do not support reverse iteration") i = len(x) --- 68,75 ---- def reversed(x): ! if hasattr(x, 'reversed'): ! for elem x.__reversed__(): ! yield x ! if hasattr(x, 'keys'): raise ValueError("mappings do not support reverse iteration") i = len(x) *************** *** 82,85 **** --- 81,86 ---- compatible. + A C implementation and unit tests are at: http://www.python.org/sf/834422 + Alternative Method Names *************** *** 102,111 **** __getitem__() and __len__() but still have some useful way of providing reverse iteration. - - For example, using this protocol, *enumerate()* can be extended to - support reversal whenever the underlying iterator supports it also:: - - >>> list(reversed(enumerate("abc"))) - [(2, 'c'), (1, 'b'), (0, 'a')] --- 103,106 ---- From greg at users.sourceforge.net Sun Nov 2 03:06:32 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 03:06:36 2003 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv22559/Modules Modified Files: _bsddb.c Log Message: Fix a tuple memory leak when raising DB, DBEnv and DBCursor "object has been closed" exceptions. Adds a DBCursorClosedError exception in the closed cursor case for future use in fixing the legacy bsddb interface deadlock problems due to its use of cursors with DB_INIT_LOCK | DB_THREAD support enabled. Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** _bsddb.c 1 Oct 2003 06:48:51 -0000 1.21 --- _bsddb.c 2 Nov 2003 08:06:29 -0000 1.22 *************** *** 149,152 **** --- 149,153 ---- static PyObject* DBError; /* Base class, all others derive from this */ + static PyObject* DBCursorClosedError; /* raised when trying to use a closed cursor object */ static PyObject* DBKeyEmptyError; /* DB_KEYEMPTY */ static PyObject* DBKeyExistError; /* DB_KEYEXIST */ *************** *** 259,283 **** #define RETURN_NONE() Py_INCREF(Py_None); return Py_None; ! #define CHECK_DB_NOT_CLOSED(dbobj) \ ! if (dbobj->db == NULL) { \ ! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ ! "DB object has been closed")); \ ! return NULL; \ } ! #define CHECK_ENV_NOT_CLOSED(env) \ ! if (env->db_env == NULL) { \ ! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ ! "DBEnv object has been closed"));\ ! return NULL; \ ! } ! #define CHECK_CURSOR_NOT_CLOSED(curs) \ ! if (curs->dbc == NULL) { \ ! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ ! "DBCursor object has been closed"));\ ! return NULL; \ ! } --- 260,280 ---- #define RETURN_NONE() Py_INCREF(Py_None); return Py_None; ! #define _CHECK_OBJECT_NOT_CLOSED(nonNull, pyErrObj, name) \ ! if ((nonNull) == NULL) { \ ! PyObject *errTuple = NULL; \ ! errTuple = Py_BuildValue("(is)", 0, #name " object has been closed"); \ ! PyErr_SetObject((pyErrObj), errTuple); \ ! Py_DECREF(errTuple); \ ! return NULL; \ } ! #define CHECK_DB_NOT_CLOSED(dbobj) \ ! _CHECK_OBJECT_NOT_CLOSED(dbobj->db, DBError, DB) ! #define CHECK_ENV_NOT_CLOSED(env) \ ! _CHECK_OBJECT_NOT_CLOSED(env->db_env, DBError, DBEnv) + #define CHECK_CURSOR_NOT_CLOSED(curs) \ + _CHECK_OBJECT_NOT_CLOSED(curs->dbc, DBCursorClosedError, DBCursor) *************** *** 4718,4721 **** --- 4715,4719 ---- MAKE_EX(DBIncompleteError); #endif + MAKE_EX(DBCursorClosedError); MAKE_EX(DBKeyEmptyError); MAKE_EX(DBKeyExistError); From greg at users.sourceforge.net Sun Nov 2 04:10:18 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 04:10:24 2003 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv30540/Modules Modified Files: _bsddb.c Log Message: * Fix the singlethreaded deadlocks occurring in the simple bsddb interface. * Add support for multiple iterator/generator objects at once on the simple bsddb _DBWithCursor interface. Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** _bsddb.c 2 Nov 2003 08:06:29 -0000 1.22 --- _bsddb.c 2 Nov 2003 09:10:15 -0000 1.23 *************** *** 94,98 **** #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) ! #define PY_BSDDB_VERSION "4.2.2" static char *rcs_id = "$Id$"; --- 94,98 ---- #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) ! #define PY_BSDDB_VERSION "4.2.3" static char *rcs_id = "$Id$"; From greg at users.sourceforge.net Sun Nov 2 04:10:18 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 04:10:26 2003 Subject: [Python-checkins] python/dist/src/Lib/bsddb __init__.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1:/tmp/cvs-serv30540/Lib/bsddb Modified Files: __init__.py Log Message: * Fix the singlethreaded deadlocks occurring in the simple bsddb interface. * Add support for multiple iterator/generator objects at once on the simple bsddb _DBWithCursor interface. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** __init__.py 27 Sep 2003 23:00:19 -0000 1.10 --- __init__.py 2 Nov 2003 09:10:16 -0000 1.11 *************** *** 71,88 **** def __iter__(self): try: ! yield self.first()[0] ! next = self.next while 1: ! yield next()[0] except _bsddb.DBNotFoundError: return def iteritems(self): try: ! yield self.first() ! next = self.next while 1: ! yield next() except _bsddb.DBNotFoundError: return """ --- 71,142 ---- def __iter__(self): try: ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur ! ! # since we're only returning keys, we call the cursor ! # methods with flags=0, dlen=0, dofs=0 ! curkey = cur.first(0,0,0)[0] ! yield curkey ! ! next = cur.next while 1: ! try: ! curkey = next(0,0,0)[0] ! yield curkey ! except _bsddb.DBCursorClosedError: ! # our cursor object was closed since we last yielded ! # create a new one and attempt to reposition to the ! # right place ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur ! # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this set call. ! try: ! cur.set(curkey,0,0,0) ! except _bsddb.DBCursorClosedError: ! # halt iteration on race condition... ! raise _bsddb.DBNotFoundError ! next = cur.next except _bsddb.DBNotFoundError: + try: + del self._iter_cursors[str(cur)] + except KeyError: + pass return def iteritems(self): try: ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur ! ! kv = cur.first() ! curkey = kv[0] ! yield kv ! ! next = cur.next while 1: ! try: ! kv = next() ! curkey = kv[0] ! yield kv ! except _bsddb.DBCursorClosedError: ! # our cursor object was closed since we last yielded ! # create a new one and attempt to reposition to the ! # right place ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur ! # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this set call. ! try: ! cur.set(curkey,0,0,0) ! except _bsddb.DBCursorClosedError: ! # halt iteration on race condition... ! raise _bsddb.DBNotFoundError ! next = cur.next except _bsddb.DBNotFoundError: + try: + del self._iter_cursors[str(cur)] + except KeyError: + pass return """ *************** *** 98,110 **** def __init__(self, db): self.db = db - self.dbc = None self.db.set_get_returns_none(0) def __del__(self): self.close() def _checkCursor(self): if self.dbc is None: self.dbc = self.db.cursor() def _checkOpen(self): --- 152,202 ---- def __init__(self, db): self.db = db self.db.set_get_returns_none(0) + # FIXME-20031101-greg: I believe there is still the potential + # for deadlocks in a multithreaded environment if someone + # attempts to use the any of the cursor interfaces in one + # thread while doing a put or delete in another thread. The + # reason is that _checkCursor and _closeCursors are not atomic + # operations. Doing our own locking around self.dbc, + # self.saved_dbc_key and self._iter_cursors could prevent this. + # TODO: A test case demonstrating the problem needs to be written. + + # self.dbc is a DBCursor object used to implement the + # first/next/previous/last/set_location methods. + self.dbc = None + self.saved_dbc_key = None + + # a collection of all DBCursor objects currently allocated + # by the _iter_mixin interface. + self._iter_cursors = {} + + def __del__(self): self.close() + def _get_dbc(self): + return self.dbc + def _checkCursor(self): if self.dbc is None: self.dbc = self.db.cursor() + if self.saved_dbc_key is not None: + self.dbc.set(self.saved_dbc_key) + self.saved_dbc_key = None + + # This method is needed for all non-cursor DB calls to avoid + # BerkeleyDB deadlocks (due to being opened with DB_INIT_LOCK + # and DB_THREAD to be thread safe) when intermixing database + # operations that use the cursor internally with those that don't. + def _closeCursors(self, save=True): + if self.dbc: + c = self.dbc + self.dbc = None + if save: + self.saved_dbc_key = c.current(0,0,0)[0] + c.close() + del c + map(lambda c: c.close(), self._iter_cursors.values()) def _checkOpen(self): *************** *** 125,135 **** --- 217,230 ---- def __setitem__(self, key, value): self._checkOpen() + self._closeCursors() self.db[key] = value def __delitem__(self, key): self._checkOpen() + self._closeCursors() del self.db[key] def close(self): + self._closeCursors(save=False) if self.dbc is not None: self.dbc.close() From greg at users.sourceforge.net Sun Nov 2 04:10:18 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 04:10:29 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_bsddb.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv30540/Lib/test Modified Files: test_bsddb.py Log Message: * Fix the singlethreaded deadlocks occurring in the simple bsddb interface. * Add support for multiple iterator/generator objects at once on the simple bsddb _DBWithCursor interface. Index: test_bsddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bsddb.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_bsddb.py 13 Sep 2003 05:51:09 -0000 1.14 --- test_bsddb.py 2 Nov 2003 09:10:16 -0000 1.15 *************** *** 3,7 **** Adapted to unittest format and expanded scope by Raymond Hettinger """ ! import os import bsddb import dbhash # Just so we know it's imported --- 3,7 ---- Adapted to unittest format and expanded scope by Raymond Hettinger """ ! import os, sys import bsddb import dbhash # Just so we know it's imported *************** *** 93,96 **** --- 93,147 ---- self.f.clear() self.assertEqual(len(self.f), 0) + + def test__no_deadlock_first(self, debug=0): + # do this so that testers can see what function we're in in + # verbose mode when we deadlock. + sys.stdout.flush() + + # in pybsddb's _DBWithCursor this causes an internal DBCursor + # object is created. Other test_ methods in this class could + # inadvertently cause the deadlock but an explicit test is needed. + if debug: print "A" + k,v = self.f.first() + if debug: print "B", k + self.f[k] = "deadlock. do not pass go. do not collect $200." + if debug: print "C" + # if the bsddb implementation leaves the DBCursor open during + # the database write and locking+threading support is enabled + # the cursor's read lock will deadlock the write lock request.. + + # test the iterator interface (if present) + if hasattr(self, 'iteritems'): + if debug: print "D" + k,v = self.f.iteritems() + if debug: print "E" + self.f[k] = "please don't deadlock" + if debug: print "F" + while 1: + try: + k,v = self.f.iteritems() + except StopIteration: + break + if debug: print "F2" + + i = iter(self.f) + if debug: print "G" + while i: + try: + if debug: print "H" + k = i.next() + if debug: print "I" + self.f[k] = "deadlocks-r-us" + if debug: print "J" + except StopIteration: + i = None + if debug: print "K" + + # test the legacy cursor interface mixed with writes + self.assert_(self.f.first()[0] in self.d) + k = self.f.next()[0] + self.assert_(k in self.d) + self.f[k] = "be gone with ye deadlocks" + self.assert_(self.f[k], "be gone with ye deadlocks") def test_popitem(self): From rhettinger at users.sourceforge.net Sun Nov 2 04:47:08 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 2 04:47:10 2003 Subject: [Python-checkins] python/dist/src/Lib posixpath.py, 1.62, 1.63 SimpleXMLRPCServer.py, 1.7, 1.8 trace.py, 1.15, 1.16 platform.py, 1.7, 1.8 xmlrpclib.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv2423 Modified Files: posixpath.py SimpleXMLRPCServer.py trace.py platform.py xmlrpclib.py Log Message: SF patch #834015: Remove imports of unused modules (Contributed by George Yoshida.) Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** posixpath.py 17 Jul 2003 15:11:49 -0000 1.62 --- posixpath.py 2 Nov 2003 09:47:05 -0000 1.63 *************** *** 11,15 **** """ - import sys import os import stat --- 11,14 ---- Index: SimpleXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleXMLRPCServer.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SimpleXMLRPCServer.py 29 Jun 2003 04:19:37 -0000 1.7 --- SimpleXMLRPCServer.py 2 Nov 2003 09:47:05 -0000 1.8 *************** *** 105,109 **** import BaseHTTPServer import sys - import types import os --- 105,108 ---- Index: trace.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/trace.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** trace.py 14 Oct 2003 20:12:06 -0000 1.15 --- trace.py 2 Nov 2003 09:47:05 -0000 1.16 *************** *** 47,51 **** import linecache - import marshal import os import re --- 47,50 ---- Index: platform.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/platform.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** platform.py 11 Aug 2003 11:08:49 -0000 1.7 --- platform.py 2 Nov 2003 09:47:05 -0000 1.8 *************** *** 1083,1087 **** """ global _sys_version_cache - import time if _sys_version_cache is not None: --- 1083,1086 ---- Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** xmlrpclib.py 31 Oct 2003 13:49:36 -0000 1.31 --- xmlrpclib.py 2 Nov 2003 09:47:05 -0000 1.32 *************** *** 110,114 **** ServerProxy Represents a logical connection to an XML-RPC server ! MultiCall Executor of boxcared xmlrpc requests Boolean boolean wrapper to generate a "boolean" XML-RPC value DateTime dateTime wrapper for an ISO 8601 string or time tuple or --- 110,114 ---- ServerProxy Represents a logical connection to an XML-RPC server ! MultiCall Executor of boxcared xmlrpc requests Boolean boolean wrapper to generate a "boolean" XML-RPC value DateTime dateTime wrapper for an ISO 8601 string or time tuple or *************** *** 895,899 **** """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" ! for i in results: if type(i) == type({}): --- 895,899 ---- """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" ! for i in results: if type(i) == type({}): *************** *** 904,908 **** raise ValueError,\ "unexpected type in multicall result" ! class MultiCall: """server -> a object used to boxcar method calls --- 904,908 ---- raise ValueError,\ "unexpected type in multicall result" ! class MultiCall: """server -> a object used to boxcar method calls *************** *** 921,932 **** add_result, address = multicall() """ ! def __init__(self, server): self.__server = server self.__call_list = [] ! def __repr__(self): return "" % id(self) ! __str__ = __repr__ --- 921,932 ---- add_result, address = multicall() """ ! def __init__(self, server): self.__server = server self.__call_list = [] ! def __repr__(self): return "" % id(self) ! __str__ = __repr__ *************** *** 940,944 **** return MultiCallIterator(self.__server.system.multicall(marshalled_list)) ! # -------------------------------------------------------------------- # convenience functions --- 940,944 ---- return MultiCallIterator(self.__server.system.multicall(marshalled_list)) ! # -------------------------------------------------------------------- # convenience functions *************** *** 1072,1076 **** raises a Fault exception. """ - import sys p, u = getparser() p.feed(data) --- 1072,1075 ---- *************** *** 1393,1397 **** __str__ = __repr__ ! def __getattr__(self, name): # magic method dispatcher --- 1392,1396 ---- __str__ = __repr__ ! def __getattr__(self, name): # magic method dispatcher From rhettinger at users.sourceforge.net Sun Nov 2 04:50:58 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 2 04:51:01 2003 Subject: [Python-checkins] python/dist/src/Doc/lib liboperator.tex, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv2858 Modified Files: liboperator.tex Log Message: SF patch #834444: add versionadd to new functions (Contributed by George Yoshida.) Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** liboperator.tex 21 Feb 2003 05:42:13 -0000 1.27 --- liboperator.tex 2 Nov 2003 09:50:56 -0000 1.28 *************** *** 67,74 **** --- 67,76 ---- \begin{funcdesc}{is_}{a, b} Return \code{\var{a} is \var{b}}. Tests object identity. + \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{is_not}{a, b} Return \code{\var{a} is not \var{b}}. Tests object identity. + \versionadded{2.3} \end{funcdesc} From rhettinger at users.sourceforge.net Sun Nov 2 04:52:41 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 2 04:52:43 2003 Subject: [Python-checkins] python/dist/src/Doc/lib liboperator.tex, 1.27, 1.27.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3183 Modified Files: Tag: release23-maint liboperator.tex Log Message: SF patch #834444: add versionadd to new functions (Contributed by George Yoshida.) Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.27 retrieving revision 1.27.12.1 diff -C2 -d -r1.27 -r1.27.12.1 *** liboperator.tex 21 Feb 2003 05:42:13 -0000 1.27 --- liboperator.tex 2 Nov 2003 09:52:38 -0000 1.27.12.1 *************** *** 67,74 **** --- 67,76 ---- \begin{funcdesc}{is_}{a, b} Return \code{\var{a} is \var{b}}. Tests object identity. + \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{is_not}{a, b} Return \code{\var{a} is not \var{b}}. Tests object identity. + \versionadded{2.3} \end{funcdesc} From aleax at users.sourceforge.net Sun Nov 2 11:11:50 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 11:11:54 2003 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex, 1.76.10.1, 1.76.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1:/tmp/cvs-serv30385/ref Modified Files: Tag: release23-maint ref5.tex Log Message: clarified (in the 5.14 summary) that tests and comparisons all chain, added a specific \ref to 5.9 in lieu of previous vague "see above". Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.76.10.1 retrieving revision 1.76.10.2 diff -C2 -d -r1.76.10.1 -r1.76.10.2 *** ref5.tex 19 Oct 2003 07:31:15 -0000 1.76.10.1 --- ref5.tex 2 Nov 2003 16:11:48 -0000 1.76.10.2 *************** *** 1069,1075 **** Operators in the same box have the same precedence. Unless the syntax is explicitly given, operators are binary. Operators in the same box ! group left to right (except for comparisons, which chain from left to ! right --- see above, and exponentiation, which groups from right to ! left). \begin{tableii}{c|l}{textrm}{Operator}{Description} --- 1069,1075 ---- Operators in the same box have the same precedence. Unless the syntax is explicitly given, operators are binary. Operators in the same box ! group left to right (except for comparisons, including tests, which all ! have the same precedence and chain from left to right --- see section ! \ref{comparisons} -- and exponentiation, which groups from right to left). \begin{tableii}{c|l}{textrm}{Operator}{Description} From aleax at users.sourceforge.net Sun Nov 2 11:31:25 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 11:31:28 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libcgi.tex, 1.40.10.1, 1.40.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv1322 Modified Files: Tag: release23-maint libcgi.tex Log Message: Avoid giving advice that's bad for security, as per SF bug #823515 Index: libcgi.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgi.tex,v retrieving revision 1.40.10.1 retrieving revision 1.40.10.2 diff -C2 -d -r1.40.10.1 -r1.40.10.2 *** libcgi.tex 11 Aug 2003 23:43:04 -0000 1.40.10.1 --- libcgi.tex 2 Nov 2003 16:31:22 -0000 1.40.10.2 *************** *** 599,603 **** \item When reading or writing external files, make sure they can be read ! or written by every user on the system. \item Don't try to give a CGI script a set-uid mode. This doesn't work on --- 599,605 ---- \item When reading or writing external files, make sure they can be read ! or written by the userid under which your CGI script will be running: ! this is typically the userid under which the web server is running, or some ! explicitly specified userid for a web server's \samp{suexec} feature. \item Don't try to give a CGI script a set-uid mode. This doesn't work on From aleax at users.sourceforge.net Sun Nov 2 11:51:41 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 11:51:44 2003 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.79.8.1,1.79.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv4521 Modified Files: Tag: release23-maint httplib.py Log Message: fixed obvious bug in _send_header as per SF bug #831271 Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.79.8.1 retrieving revision 1.79.8.2 diff -C2 -d -r1.79.8.1 -r1.79.8.2 *** httplib.py 27 Oct 2003 14:07:42 -0000 1.79.8.1 --- httplib.py 2 Nov 2003 16:51:38 -0000 1.79.8.2 *************** *** 727,733 **** # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is ! # harder because field names are case insensitive. ! if 'Host' in (headers ! or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: --- 727,732 ---- # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is ! # more delicate because field names are case insensitive. ! if 'host' in [k.lower() for k in headers]: self.putrequest(method, url, skip_host=1) else: From aleax at users.sourceforge.net Sun Nov 2 12:11:05 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 12:11:11 2003 Subject: [Python-checkins] python/dist/src/Include object.h,2.121,2.121.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv8122 Modified Files: Tag: release23-maint object.h Log Message: fixed buggy comment as per SF bug #827856 Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.121 retrieving revision 2.121.8.1 diff -C2 -d -r2.121 -r2.121.8.1 *** object.h 23 May 2003 12:47:36 -0000 2.121 --- object.h 2 Nov 2003 17:11:03 -0000 2.121.8.1 *************** *** 696,704 **** Functions that create an object set the reference count to 1; such new objects must be stored somewhere or destroyed again with Py_DECREF(). ! Functions that 'store' objects such as PyTuple_SetItem() and ! PyDict_SetItemString() don't increment the reference count of the object, since the most frequent use is to store a fresh object. Functions that 'retrieve' ! objects such as PyTuple_GetItem() and PyDict_GetItemString() also don't increment the reference count, since most frequently the object is only looked at --- 696,704 ---- Functions that create an object set the reference count to 1; such new objects must be stored somewhere or destroyed again with Py_DECREF(). ! Some functions that 'store' objects, such as PyTuple_SetItem() and ! PyList_SetItem(), don't increment the reference count of the object, since the most frequent use is to store a fresh object. Functions that 'retrieve' ! objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also don't increment the reference count, since most frequently the object is only looked at *************** *** 706,715 **** must call Py_INCREF() explicitly. ! NOTE: functions that 'consume' a reference count like ! PyList_SetItemString() even consume the reference if the object wasn't ! stored, to simplify error handling. It seems attractive to make other functions that take an object as ! argument consume a reference count; however this may quickly get confusing (even the current practice is already confusing). Consider it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at --- 706,715 ---- must call Py_INCREF() explicitly. ! NOTE: functions that 'consume' a reference count, like ! PyList_SetItem(), consume the reference even if the object wasn't ! successfully stored, to simplify error handling. It seems attractive to make other functions that take an object as ! argument consume a reference count; however, this may quickly get confusing (even the current practice is already confusing). Consider it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at From aleax at users.sourceforge.net Sun Nov 2 13:11:56 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 13:11:58 2003 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.56,1.56.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv21988 Modified Files: Tag: release23-maint tempfile.py Log Message: fixed wrong error checking on fcntl call as per SF bug # 821896 Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.56 retrieving revision 1.56.4.1 diff -C2 -d -r1.56 -r1.56.4.1 *** tempfile.py 22 Jul 2003 02:50:01 -0000 1.56 --- tempfile.py 2 Nov 2003 18:11:53 -0000 1.56.4.1 *************** *** 48,53 **** else: def _set_cloexec(fd): ! flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! if flags >= 0: # flags read successfully, modify flags |= _fcntl.FD_CLOEXEC --- 48,54 ---- else: def _set_cloexec(fd): ! try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! except IOError: pass ! else: # flags read successfully, modify flags |= _fcntl.FD_CLOEXEC From aleax at users.sourceforge.net Sun Nov 2 14:38:26 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 14:38:33 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libpyclbr.tex, 1.3, 1.3.46.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv7979/lib Modified Files: Tag: release23-maint libpyclbr.tex Log Message: fix SF bug # 812818 Index: libpyclbr.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyclbr.tex,v retrieving revision 1.3 retrieving revision 1.3.46.1 diff -C2 -d -r1.3 -r1.3.46.1 *** libpyclbr.tex 29 Jun 1999 15:43:02 -0000 1.3 --- libpyclbr.tex 2 Nov 2003 19:38:24 -0000 1.3.46.1 *************** *** 9,16 **** The \module{pyclbr} can be used to determine some limited information ! about the classes and methods defined in a module. The information provided is sufficient to implement a traditional three-pane class browser. The information is extracted from the source code rather ! than from an imported module, so this module is safe to use with untrusted source code. This restriction makes it impossible to use this module with modules not implemented in Python, including many --- 9,17 ---- The \module{pyclbr} can be used to determine some limited information ! about the classes, methods and top-level functions ! defined in a module. The information provided is sufficient to implement a traditional three-pane class browser. The information is extracted from the source code rather ! than by importing the module, so this module is safe to use with untrusted source code. This restriction makes it impossible to use this module with modules not implemented in Python, including many *************** *** 28,36 **** \end{funcdesc} \subsection{Class Descriptor Objects \label{pyclbr-class-objects}} The class descriptor objects used as values in the dictionary returned ! by \function{readmodule()} provide the following data members: --- 29,48 ---- \end{funcdesc} + \begin{funcdesc}{readmodule_ex}{module\optional{, path}} + % The 'inpackage' parameter appears to be for internal use only.... + Like \function{readmodule()}, but the returned dictionary, in addition + to mapping class names to class descriptor objects, also maps + top-level function names to function descriptor objects. Moreover, if + the module being read is a package, the key \code{'__path__'} in the + returned dictionary has as its value a list which contains the package + search path. + \end{funcdesc} + \subsection{Class Descriptor Objects \label{pyclbr-class-objects}} The class descriptor objects used as values in the dictionary returned ! by \function{readmodule()} and \function{readmodule_ex()} ! provide the following data members: *************** *** 57,65 **** \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the class statement defining the class. \end{memberdesc} \begin{memberdesc}[class descriptor]{lineno} ! The line number of the class statement within the file named by \member{file}. \end{memberdesc} --- 69,101 ---- \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the \code{class} statement defining the class. \end{memberdesc} \begin{memberdesc}[class descriptor]{lineno} ! The line number of the \code{class} statement within the file named by ! \member{file}. ! \end{memberdesc} ! ! \subsection{Function Descriptor Objects \label{pyclbr-function-objects}} ! ! The function descriptor objects used as values in the dictionary returned ! by \function{readmodule_ex()} provide the following data members: ! ! ! \begin{memberdesc}[function descriptor]{module} ! The name of the module defining the function described by the function ! descriptor. ! \end{memberdesc} ! ! \begin{memberdesc}[function descriptor]{name} ! The name of the function. ! \end{memberdesc} ! ! \begin{memberdesc}[function descriptor]{file} ! Name of the file containing the \code{def} statement defining the function. ! \end{memberdesc} ! ! \begin{memberdesc}[function descriptor]{lineno} ! The line number of the \code{def} statement within the file named by \member{file}. \end{memberdesc} From aleax at users.sourceforge.net Sun Nov 2 14:39:16 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 2 14:39:20 2003 Subject: [Python-checkins] python/dist/src/Lib pyclbr.py,1.30,1.30.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv8103 Modified Files: Tag: release23-maint pyclbr.py Log Message: fix comments/docstring problems related to SF bug # 821818 Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.30 retrieving revision 1.30.14.1 diff -C2 -d -r1.30 -r1.30.14.1 *** pyclbr.py 3 Dec 2002 08:14:35 -0000 1.30 --- pyclbr.py 2 Nov 2003 19:39:14 -0000 1.30.14.1 *************** *** 8,18 **** where module is the name of a Python module, and path is an optional list of directories where the module is to be searched. If present, ! path is prepended to the system search path sys.path. The return ! value is a dictionary. The keys of the dictionary are the names of ! the classes defined in the module (including classes that are defined ! via the from XXX import YYY construct). The values are class ! instances of the class Class defined here. One special key/value pair ! is present for packages: the key '__path__' has a list as its value ! which contains the package search path. A class is described by the class Class in this module. Instances --- 8,24 ---- where module is the name of a Python module, and path is an optional list of directories where the module is to be searched. If present, ! path is prepended to the system search path sys.path. The return value ! is a dictionary. The keys of the dictionary are the names of the ! classes and top-level functions defined in the module (including ones ! that are defined via the from XXX import YYY construct). The values are ! instances of the classes Class and Function defined here. One special ! key/value pair is present for packages: the key '__path__' has as its ! value a list which contains the package search path. ! ! (For compatibility, a function readmodule is also defined: it works just ! like readmodule_ex, but the dictionary it returns has only key/value ! pairs whose value is an instance of class Class, _not_ ones for which it ! would be an instance of Function. nor the special key/value pair for key ! '__path__' as described in the previous paragraph). A class is described by the class Class in this module. Instances *************** *** 35,41 **** Instances of this class have the following instance variables: module -- the module name ! name -- the name of the class ! file -- the file in which the class was defined ! lineno -- the line in the file on which the class statement occurred """ --- 41,47 ---- Instances of this class have the following instance variables: module -- the module name ! name -- the name of the function ! file -- the file in which the function was defined ! lineno -- the line in the file on which the def statement occurred """ From greg at users.sourceforge.net Sun Nov 2 20:04:43 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 20:04:47 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_bsddb.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv10424/Lib/test Modified Files: test_bsddb.py Log Message: * Use weakref's of DBCursor objects for the iterator cursors to avoid a memory leak that would've occurred for all iterators that were destroyed before having iterated until they raised StopIteration. * Simplify some code. * Add new test cases to check for the memleak and ensure that mixing iteration with modification of the values for existing keys works. Index: test_bsddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bsddb.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_bsddb.py 2 Nov 2003 09:10:16 -0000 1.15 --- test_bsddb.py 3 Nov 2003 01:04:41 -0000 1.16 *************** *** 4,7 **** --- 4,8 ---- """ import os, sys + import copy import bsddb import dbhash # Just so we know it's imported *************** *** 65,68 **** --- 66,119 ---- self.assertSetEquals(d.iteritems(), f.iteritems()) + def test_iter_while_modifying_values(self): + if not hasattr(self.f, '__iter__'): + return + + di = iter(self.d) + while 1: + try: + key = di.next() + self.d[key] = 'modified '+key + except StopIteration: + break + + # it should behave the same as a dict. modifying values + # of existing keys should not break iteration. (adding + # or removing keys should) + fi = iter(self.f) + while 1: + try: + key = fi.next() + self.f[key] = 'modified '+key + except StopIteration: + break + + self.test_mapping_iteration_methods() + + def test_iteritems_while_modifying_values(self): + if not hasattr(self.f, 'iteritems'): + return + + di = self.d.iteritems() + while 1: + try: + k, v = di.next() + self.d[k] = 'modified '+v + except StopIteration: + break + + # it should behave the same as a dict. modifying values + # of existing keys should not break iteration. (adding + # or removing keys should) + fi = self.f.iteritems() + while 1: + try: + k, v = fi.next() + self.f[k] = 'modified '+v + except StopIteration: + break + + self.test_mapping_iteration_methods() + def test_first_next_looping(self): items = [self.f.first()] *************** *** 112,118 **** # test the iterator interface (if present) ! if hasattr(self, 'iteritems'): if debug: print "D" ! k,v = self.f.iteritems() if debug: print "E" self.f[k] = "please don't deadlock" --- 163,170 ---- # test the iterator interface (if present) ! if hasattr(self.f, 'iteritems'): if debug: print "D" ! i = self.f.iteritems() ! k,v = i.next() if debug: print "E" self.f[k] = "please don't deadlock" *************** *** 120,124 **** while 1: try: ! k,v = self.f.iteritems() except StopIteration: break --- 172,176 ---- while 1: try: ! k,v = i.next() except StopIteration: break *************** *** 144,147 **** --- 196,220 ---- self.f[k] = "be gone with ye deadlocks" self.assert_(self.f[k], "be gone with ye deadlocks") + + def test_for_cursor_memleak(self): + if not hasattr(self.f, 'iteritems'): + return + + # do the bsddb._DBWithCursor _iter_mixin internals leak cursors? + nc1 = len(self.f._cursor_refs) + # create iterator + i = self.f.iteritems() + nc2 = len(self.f._cursor_refs) + # use the iterator (should run to the first yeild, creating the cursor) + k, v = i.next() + nc3 = len(self.f._cursor_refs) + # destroy the iterator; this should cause the weakref callback + # to remove the cursor object from self.f._cursor_refs + del i + nc4 = len(self.f._cursor_refs) + + self.assertEqual(nc1, nc2) + self.assertEqual(nc1, nc4) + self.assert_(nc3 == nc1+1) def test_popitem(self): From greg at users.sourceforge.net Sun Nov 2 20:04:43 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 20:04:48 2003 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv10424/Modules Modified Files: _bsddb.c Log Message: * Use weakref's of DBCursor objects for the iterator cursors to avoid a memory leak that would've occurred for all iterators that were destroyed before having iterated until they raised StopIteration. * Simplify some code. * Add new test cases to check for the memleak and ensure that mixing iteration with modification of the values for existing keys works. Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** _bsddb.c 2 Nov 2003 09:10:15 -0000 1.23 --- _bsddb.c 3 Nov 2003 01:04:41 -0000 1.24 *************** *** 85,88 **** --- 85,89 ---- /* --------------------------------------------------------------------- */ + #include /* for offsetof() */ #include #include *************** *** 93,98 **** /* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */ #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) ! #define PY_BSDDB_VERSION "4.2.3" static char *rcs_id = "$Id$"; --- 94,102 ---- /* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */ #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) + #if DB_VERSION_MINOR > 9 + #error "eek! DBVER can't handle minor versions > 9" + #endif ! #define PY_BSDDB_VERSION "4.2.4" static char *rcs_id = "$Id$"; *************** *** 185,188 **** --- 189,198 ---- /* Structure definitions */ + #if PYTHON_API_VERSION >= 1010 /* python >= 2.1 support weak references */ + #define HAVE_WEAKREF + #else + #undef HAVE_WEAKREF + #endif + struct behaviourFlags { /* What is the default behaviour when DB->get or DBCursor->get returns a *************** *** 195,199 **** #define DEFAULT_GET_RETURNS_NONE 1 ! #define DEFAULT_CURSOR_SET_RETURNS_NONE 0 /* 0 in pybsddb < 4.2, python < 2.4 */ typedef struct { --- 205,209 ---- #define DEFAULT_GET_RETURNS_NONE 1 ! #define DEFAULT_CURSOR_SET_RETURNS_NONE 1 /* 0 in pybsddb < 4.2, python < 2.4 */ typedef struct { *************** *** 225,228 **** --- 235,241 ---- DBC* dbc; DBObject* mydb; + #ifdef HAVE_WEAKREF + PyObject *in_weakreflist; /* List of weak references */ + #endif } DBCursorObject; *************** *** 761,764 **** --- 774,780 ---- self->dbc = dbc; self->mydb = db; + #ifdef HAVE_WEAKREF + self->in_weakreflist = NULL; + #endif Py_INCREF(self->mydb); return self; *************** *** 770,773 **** --- 786,796 ---- { int err; + + #ifdef HAVE_WEAKREF + if (self->in_weakreflist != NULL) { + PyObject_ClearWeakRefs((PyObject *) self); + } + #endif + if (self->dbc != NULL) { MYDB_BEGIN_ALLOW_THREADS; *************** *** 4253,4256 **** --- 4276,4292 ---- 0, /*tp_as_mapping*/ 0, /*tp_hash*/ + #ifdef HAVE_WEAKREF + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + offsetof(DBCursorObject, in_weakreflist), /* tp_weaklistoffset */ + #endif }; From greg at users.sourceforge.net Sun Nov 2 20:04:43 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Sun Nov 2 20:04:50 2003 Subject: [Python-checkins] python/dist/src/Lib/bsddb __init__.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1:/tmp/cvs-serv10424/Lib/bsddb Modified Files: __init__.py Log Message: * Use weakref's of DBCursor objects for the iterator cursors to avoid a memory leak that would've occurred for all iterators that were destroyed before having iterated until they raised StopIteration. * Simplify some code. * Add new test cases to check for the memleak and ensure that mixing iteration with modification of the values for existing keys works. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** __init__.py 2 Nov 2003 09:10:16 -0000 1.11 --- __init__.py 3 Nov 2003 01:04:41 -0000 1.12 *************** *** 68,115 **** exec """ import UserDict class _iter_mixin(UserDict.DictMixin): def __iter__(self): try: ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur # since we're only returning keys, we call the cursor # methods with flags=0, dlen=0, dofs=0 ! curkey = cur.first(0,0,0)[0] ! yield curkey next = cur.next while 1: try: ! curkey = next(0,0,0)[0] ! yield curkey except _bsddb.DBCursorClosedError: ! # our cursor object was closed since we last yielded ! # create a new one and attempt to reposition to the ! # right place ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this set call. ! try: ! cur.set(curkey,0,0,0) ! except _bsddb.DBCursorClosedError: ! # halt iteration on race condition... ! raise _bsddb.DBNotFoundError next = cur.next except _bsddb.DBNotFoundError: ! try: ! del self._iter_cursors[str(cur)] ! except KeyError: ! pass return def iteritems(self): try: ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur kv = cur.first() ! curkey = kv[0] yield kv --- 68,123 ---- exec """ import UserDict + from weakref import ref class _iter_mixin(UserDict.DictMixin): + def _make_iter_cursor(self): + cur = self.db.cursor() + key = id(cur) + self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key)) + return cur + + def _gen_cref_cleaner(self, key): + # use generate the function for the weakref callback here + # to ensure that we do not hold a strict reference to cur + # in the callback. + return lambda ref: self._cursor_refs.pop(key, None) + def __iter__(self): try: ! cur = self._make_iter_cursor() ! ! # FIXME-20031102-greg: race condition. cursor could ! # be closed by another thread before this call. # since we're only returning keys, we call the cursor # methods with flags=0, dlen=0, dofs=0 ! key = cur.first(0,0,0)[0] ! yield key next = cur.next while 1: try: ! key = next(0,0,0)[0] ! yield key except _bsddb.DBCursorClosedError: ! cur = self._make_iter_cursor() # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this call. ! cur.set(key,0,0,0) next = cur.next except _bsddb.DBNotFoundError: ! return ! except _bsddb.DBCursorClosedError: ! # the database was modified during iteration. abort. return def iteritems(self): try: ! cur = self._make_iter_cursor() ! ! # FIXME-20031102-greg: race condition. cursor could ! # be closed by another thread before this call. kv = cur.first() ! key = kv[0] yield kv *************** *** 118,142 **** try: kv = next() ! curkey = kv[0] yield kv except _bsddb.DBCursorClosedError: ! # our cursor object was closed since we last yielded ! # create a new one and attempt to reposition to the ! # right place ! cur = self.db.cursor() ! self._iter_cursors[str(cur)] = cur # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this set call. ! try: ! cur.set(curkey,0,0,0) ! except _bsddb.DBCursorClosedError: ! # halt iteration on race condition... ! raise _bsddb.DBNotFoundError next = cur.next except _bsddb.DBNotFoundError: ! try: ! del self._iter_cursors[str(cur)] ! except KeyError: ! pass return """ --- 126,141 ---- try: kv = next() ! key = kv[0] yield kv except _bsddb.DBCursorClosedError: ! cur = self._make_iter_cursor() # FIXME-20031101-greg: race condition. cursor could ! # be closed by another thread before this call. ! cur.set(key,0,0,0) next = cur.next except _bsddb.DBNotFoundError: ! return ! except _bsddb.DBCursorClosedError: ! # the database was modified during iteration. abort. return """ *************** *** 160,164 **** # reason is that _checkCursor and _closeCursors are not atomic # operations. Doing our own locking around self.dbc, ! # self.saved_dbc_key and self._iter_cursors could prevent this. # TODO: A test case demonstrating the problem needs to be written. --- 159,163 ---- # reason is that _checkCursor and _closeCursors are not atomic # operations. Doing our own locking around self.dbc, ! # self.saved_dbc_key and self._cursor_refs could prevent this. # TODO: A test case demonstrating the problem needs to be written. *************** *** 170,182 **** # a collection of all DBCursor objects currently allocated # by the _iter_mixin interface. ! self._iter_cursors = {} ! def __del__(self): self.close() - def _get_dbc(self): - return self.dbc - def _checkCursor(self): if self.dbc is None: --- 169,177 ---- # a collection of all DBCursor objects currently allocated # by the _iter_mixin interface. ! self._cursor_refs = {} def __del__(self): self.close() def _checkCursor(self): if self.dbc is None: *************** *** 198,202 **** c.close() del c ! map(lambda c: c.close(), self._iter_cursors.values()) def _checkOpen(self): --- 193,200 ---- c.close() del c ! for cref in self._cursor_refs.values(): ! c = cref() ! if c is not None: ! c.close() def _checkOpen(self): From rhettinger at users.sourceforge.net Mon Nov 3 12:56:42 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 3 12:56:46 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv24655 Modified Files: pep-0322.txt Log Message: Remove the revrange() proposal. Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pep-0322.txt 2 Nov 2003 07:12:04 -0000 1.11 --- pep-0322.txt 3 Nov 2003 17:56:40 -0000 1.12 *************** *** 160,174 **** - Active Alternative - ================== - - A simpler, but limited alternative is to create a builtin that takes - the same arguments as *range()* but returns a reverse iterator over the - range. The idea is that much of the benefit of *reversed()* comes - reducing the intellectual effort it takes to express the arguments for - [x]range() when going backwards. A good name is needed for this - alternative -- *revrange()* is cleanest so far. - - Rejected Alternatives ===================== --- 160,163 ---- From jhylton at users.sourceforge.net Mon Nov 3 15:58:30 2003 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Mon Nov 3 15:58:34 2003 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.161,2.162 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv30652 Modified Files: listobject.c Log Message: Fix compiler warning about possible use of n without assignment. Also fix use of n for two different variables in two different blocks. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -d -r2.161 -r2.162 *** listobject.c 29 Oct 2003 06:54:43 -0000 2.161 --- listobject.c 3 Nov 2003 20:58:28 -0000 2.162 *************** *** 1849,1853 **** int reverse = 0; PyObject *keyfunc = NULL; ! int i, n; PyObject *key, *value, *kvpair; static char *kwlist[] = {"cmp", "key", "reverse", 0}; --- 1849,1853 ---- int reverse = 0; PyObject *keyfunc = NULL; ! int i, len = 0; PyObject *key, *value, *kvpair; static char *kwlist[] = {"cmp", "key", "reverse", 0}; *************** *** 1872,1879 **** if (keyfunc != NULL) { ! n = PyList_GET_SIZE(self); ! for (i=0 ; i Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv7098 Modified Files: pep-0322.txt Log Message: Aahz requested that the principal objection be clearly identified. Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pep-0322.txt 3 Nov 2003 17:56:40 -0000 1.12 --- pep-0322.txt 3 Nov 2003 21:31:53 -0000 1.13 *************** *** 105,108 **** --- 105,117 ---- + Discussion + ========== + + The case against adoption of the PEP is a desire to keep the number of + builtin functions small. This needs to weighed against the simplicity + and convenience of having it as builtin instead of being tucked away in + some other namespace. + + Real World Use Cases ==================== From greg at users.sourceforge.net Mon Nov 3 16:35:33 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Mon Nov 3 16:35:38 2003 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv7748/Modules Modified Files: _bsddb.c Log Message: * SF patch 835100 - C++ // comments are not allowed. Use /* */ Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** _bsddb.c 3 Nov 2003 01:04:41 -0000 1.24 --- _bsddb.c 3 Nov 2003 21:35:31 -0000 1.25 *************** *** 1561,1569 **** RETURN_IF_ERR(); ! // FIXME: this is a buggy interface. The returned cursor ! // contains internal references to the passed in cursors ! // but does not hold python references to them or prevent ! // them from being closed prematurely. This can cause ! // python to crash when things are done in the wrong order. return (PyObject*) newDBCursorObject(dbc, self); } --- 1561,1569 ---- RETURN_IF_ERR(); ! /* FIXME: this is a buggy interface. The returned cursor ! contains internal references to the passed in cursors ! but does not hold python references to them or prevent ! them from being closed prematurely. This can cause ! python to crash when things are done in the wrong order. */ return (PyObject*) newDBCursorObject(dbc, self); } *************** *** 2947,2951 **** PyObject* retval; ! // the caller did this: CHECK_CURSOR_NOT_CLOSED(self); if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) return NULL; --- 2947,2951 ---- PyObject* retval; ! /* the caller did this: CHECK_CURSOR_NOT_CLOSED(self); */ if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) return NULL; *************** *** 2995,2999 **** return NULL; ! // if the cursor is closed, self->mydb may be invalid CHECK_CURSOR_NOT_CLOSED(self); --- 2995,2999 ---- return NULL; ! /* if the cursor is closed, self->mydb may be invalid */ CHECK_CURSOR_NOT_CLOSED(self); *************** *** 3044,3048 **** return NULL; ! // if the cursor is closed, self->mydb may be invalid CHECK_CURSOR_NOT_CLOSED(self); --- 3044,3048 ---- return NULL; ! /* if the cursor is closed, self->mydb may be invalid */ CHECK_CURSOR_NOT_CLOSED(self); From greg at users.sourceforge.net Mon Nov 3 16:37:45 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Mon Nov 3 16:37:48 2003 Subject: [Python-checkins] python/dist/src/Modules _bsddb.c,1.17,1.17.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv8150/Modules Modified Files: Tag: release23-branch _bsddb.c Log Message: * SF patch 835100 - C++ // comments are not allowed. use /* */ Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.17 retrieving revision 1.17.4.1 diff -C2 -d -r1.17 -r1.17.4.1 *** _bsddb.c 15 Jul 2003 19:12:54 -0000 1.17 --- _bsddb.c 3 Nov 2003 21:37:43 -0000 1.17.4.1 *************** *** 1541,1549 **** RETURN_IF_ERR(); ! // FIXME: this is a buggy interface. The returned cursor ! // contains internal references to the passed in cursors ! // but does not hold python references to them or prevent ! // them from being closed prematurely. This can cause ! // python to crash when things are done in the wrong order. return (PyObject*) newDBCursorObject(dbc, self); } --- 1541,1549 ---- RETURN_IF_ERR(); ! /* FIXME: this is a buggy interface. The returned cursor ! contains internal references to the passed in cursors ! but does not hold python references to them or prevent ! them from being closed prematurely. This can cause ! python to crash when things are done in the wrong order. */ return (PyObject*) newDBCursorObject(dbc, self); } *************** *** 2916,2920 **** PyObject* retval; ! // the caller did this: CHECK_CURSOR_NOT_CLOSED(self); if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) return NULL; --- 2916,2920 ---- PyObject* retval; ! /* the caller did this: CHECK_CURSOR_NOT_CLOSED(self); */ if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) return NULL; *************** *** 2964,2968 **** return NULL; ! // if the cursor is closed, self->mydb may be invalid CHECK_CURSOR_NOT_CLOSED(self); --- 2964,2968 ---- return NULL; ! /* if the cursor is closed, self->mydb may be invalid */ CHECK_CURSOR_NOT_CLOSED(self); *************** *** 2980,2984 **** return NULL; ! // if the cursor is closed, self->mydb may be invalid CHECK_CURSOR_NOT_CLOSED(self); --- 2980,2984 ---- return NULL; ! /* if the cursor is closed, self->mydb may be invalid */ CHECK_CURSOR_NOT_CLOSED(self); From anthonybaxter at users.sourceforge.net Tue Nov 4 08:53:40 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Nov 4 08:53:45 2003 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.53.6.1,1.53.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv1660 Modified Files: Tag: release23-maint urllib2.py Log Message: backport of 1.56 Apply patch 823328 -- support for rfc 2617 digestion authentication. This fixes the current (broken) digest auth code. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.53.6.1 retrieving revision 1.53.6.2 diff -C2 -d -r1.53.6.1 -r1.53.6.2 *** urllib2.py 20 Oct 2003 14:34:46 -0000 1.53.6.1 --- urllib2.py 4 Nov 2003 13:53:38 -0000 1.53.6.2 *************** *** 88,107 **** # check digest against correct (i.e. non-apache) implementation ! import socket import httplib import inspect - import re - import base64 - import urlparse import md5 import mimetypes import mimetools import rfc822 ! import ftplib import sys import time ! import os ! import gopherlib ! import posixpath try: --- 88,109 ---- # check digest against correct (i.e. non-apache) implementation ! import base64 ! import ftplib ! import gopherlib import httplib import inspect import md5 import mimetypes import mimetools + import os + import posixpath + import random + import re import rfc822 ! import sha ! import socket import sys import time ! import urlparse try: *************** *** 110,119 **** from StringIO import StringIO - try: - import sha - except ImportError: - # need 1.5.2 final - sha = None - # not sure how many of these need to be gotten rid of from urllib import unwrap, unquote, splittype, splithost, \ --- 112,115 ---- *************** *** 121,131 **** splitattr, ftpwrapper, noheaders ! # support for proxies via environment variables ! from urllib import getproxies ! ! # support for FileHandler ! from urllib import localhost, url2pathname ! __version__ = "2.0a1" _opener = None --- 117,124 ---- splitattr, ftpwrapper, noheaders ! # support for FileHandler, proxies via environment variables ! from urllib import localhost, url2pathname, getproxies ! __version__ = "2.1" _opener = None *************** *** 677,681 **** --- 670,697 ---- + def randombytes(n): + """Return n random bytes.""" + # Use /dev/urandom if it is available. Fall back to random module + # if not. It might be worthwhile to extend this function to use + # other platform-specific mechanisms for getting random bytes. + if os.path.exists("/dev/urandom"): + f = open("/dev/urandom") + s = f.read(n) + f.close() + return s + else: + L = [chr(random.randrange(0, 256)) for i in range(n)] + return "".join(L) + class AbstractDigestAuthHandler: + # Digest authentication is specified in RFC 2617. + + # XXX The client does not inspect the Authentication-Info header + # in a successful response. + + # XXX It should be possible to test this implementation against + # a mock server that just generates a static set of challenges. + + # XXX qop="auth-int" supports is shaky def __init__(self, passwd=None): *************** *** 684,694 **** self.passwd = passwd self.add_password = self.passwd.add_password ! def http_error_auth_reqed(self, authreq, host, req, headers): ! authreq = headers.get(self.auth_header, None) if authreq: ! kind = authreq.split()[0] ! if kind == 'Digest': return self.retry_http_digest_auth(req, authreq) def retry_http_digest_auth(self, req, auth): --- 700,728 ---- self.passwd = passwd self.add_password = self.passwd.add_password + self.retried = 0 + self.nonce_count = 0 ! def reset_retry_count(self): ! self.retried = 0 ! ! def http_error_auth_reqed(self, auth_header, host, req, headers): ! authreq = headers.get(auth_header, None) ! if self.retried > 5: ! # Don't fail endlessly - if we failed once, we'll probably ! # fail a second time. Hm. Unless the Password Manager is ! # prompting for the information. Crap. This isn't great ! # but it's better than the current 'repeat until recursion ! # depth exceeded' approach ! raise HTTPError(req.get_full_url(), 401, "digest auth failed", ! headers, None) ! else: ! self.retried += 1 if authreq: ! 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): *************** *** 704,711 **** --- 738,756 ---- return resp + def get_cnonce(self, nonce): + # The cnonce-value is an opaque + # quoted string value provided by the client and used by both client + # and server to avoid chosen plaintext attacks, to provide mutual + # authentication, and to provide some message integrity protection. + # This isn't a fabulous effort, but it's probably Good Enough. + dig = sha.new("%s:%s:%s:%s" % (self.nonce_count, nonce, time.ctime(), + randombytes(8))).hexdigest() + return dig[:16] + def get_authorization(self, req, chal): try: realm = chal['realm'] nonce = chal['nonce'] + qop = chal.get('qop') algorithm = chal.get('algorithm', 'MD5') # mod_digest doesn't send an opaque, even though it isn't *************** *** 719,724 **** return None ! user, pw = self.passwd.find_user_password(realm, ! req.get_full_url()) if user is None: return None --- 764,768 ---- return None ! user, pw = self.passwd.find_user_password(realm, req.get_full_url()) if user is None: return None *************** *** 734,738 **** # XXX selector: what about proxies and full urls req.get_selector()) ! respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) # XXX should the partial digests be encoded too? --- 778,793 ---- # XXX selector: what about proxies and full urls req.get_selector()) ! if qop == 'auth': ! self.nonce_count += 1 ! ncvalue = '%08x' % self.nonce_count ! cnonce = self.get_cnonce(nonce) ! noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, H(A2)) ! respdig = KD(H(A1), noncebit) ! elif qop is None: ! respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) ! else: ! # XXX handle auth-int. ! pass ! # XXX should the partial digests be encoded too? *************** *** 746,749 **** --- 801,806 ---- if algorithm != 'MD5': base = base + ', algorithm="%s"' % algorithm + if qop: + base = base + ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce) return base *************** *** 751,759 **** # lambdas assume digest modules are imported at the top level if algorithm == 'MD5': ! H = lambda x, e=encode_digest:e(md5.new(x).digest()) elif algorithm == 'SHA': ! H = lambda x, e=encode_digest:e(sha.new(x).digest()) # XXX MD5-sess ! KD = lambda s, d, H=H: H("%s:%s" % (s, d)) return H, KD --- 808,816 ---- # lambdas assume digest modules are imported at the top level if algorithm == 'MD5': ! H = lambda x: md5.new(x).hexdigest() elif algorithm == 'SHA': ! H = lambda x: sha.new(x).hexdigest() # XXX MD5-sess ! KD = lambda s, d: H("%s:%s" % (s, d)) return H, KD *************** *** 774,778 **** def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] ! self.http_error_auth_reqed('www-authenticate', host, req, headers) --- 831,838 ---- def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] ! retry = self.http_error_auth_reqed('www-authenticate', ! host, req, headers) ! self.reset_retry_count() ! return retry *************** *** 783,798 **** def http_error_407(self, req, fp, code, msg, headers): host = req.get_host() ! self.http_error_auth_reqed('proxy-authenticate', host, req, headers) ! ! ! def encode_digest(digest): ! hexrep = [] ! for c in digest: ! n = (ord(c) >> 4) & 0xf ! hexrep.append(hex(n)[-1]) ! n = ord(c) & 0xf ! hexrep.append(hex(n)[-1]) ! return ''.join(hexrep) ! class AbstractHTTPHandler(BaseHandler): --- 843,850 ---- def http_error_407(self, req, fp, code, msg, headers): host = req.get_host() ! retry = self.http_error_auth_reqed('proxy-authenticate', ! host, req, headers) ! self.reset_retry_count() ! return retry class AbstractHTTPHandler(BaseHandler): From anthonybaxter at users.sourceforge.net Tue Nov 4 09:11:03 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Nov 4 09:11:08 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_re.py, 1.45, 1.45.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv4403 Modified Files: Tag: release23-maint test_re.py Log Message: get tests working again. partial backport of 1.46 - I fixed the recursive tests that used to fail, but left test_re_groupref_exists disabled, as it fails on the release23-maint branch. Maybe something else needs to be backported? Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.45 retrieving revision 1.45.6.1 diff -C2 -d -r1.45 -r1.45.6.1 *** test_re.py 2 Jul 2003 20:03:04 -0000 1.45 --- test_re.py 4 Nov 2003 14:11:01 -0000 1.45.6.1 *************** *** 170,174 **** def test_re_groupref_exists(self): ! return # not yet self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(), ('(', 'a')) --- 170,174 ---- def test_re_groupref_exists(self): ! return # not yet self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(), ('(', 'a')) *************** *** 406,411 **** 20003) self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001) ! # non-simple '*?' still recurses and hits the recursion limit ! self.assertRaises(RuntimeError, re.search, '(a|b)*?c', 10000*'ab'+'cd') def test_bug_612074(self): --- 406,413 ---- 20003) self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001) ! # non-simple '*?' still used to hit the recursion limit, before the ! # non-recursive scheme was implemented. ! self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001) ! def test_bug_612074(self): *************** *** 414,422 **** def test_stack_overflow(self): ! # nasty case that overflows the straightforward recursive # implementation of repeated groups. ! self.assertRaises(RuntimeError, re.match, '(x)*', 50000*'x') ! self.assertRaises(RuntimeError, re.match, '(x)*y', 50000*'x'+'y') ! self.assertRaises(RuntimeError, re.match, '(x)*?y', 50000*'x'+'y') def test_scanner(self): --- 416,424 ---- def test_stack_overflow(self): ! # nasty cases that used to overflow the straightforward recursive # implementation of repeated groups. ! self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x') ! self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x') ! self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x') def test_scanner(self): From anthonybaxter at users.sourceforge.net Tue Nov 4 09:35:51 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Nov 4 09:35:56 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.883,1.884 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv8915 Modified Files: NEWS Log Message: missing news entry Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.883 retrieving revision 1.884 diff -C2 -d -r1.883 -r1.884 *** NEWS 31 Oct 2003 13:49:36 -0000 1.883 --- NEWS 4 Nov 2003 14:35:49 -0000 1.884 *************** *** 145,148 **** --- 145,150 ---- and removed in Py2.4. + - Bug #823328: urllib2.py's HTTP Digest Auth support works again. + Tools/Demos ----------- From anthonybaxter at users.sourceforge.net Tue Nov 4 09:38:54 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Nov 4 09:38:56 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.70,1.831.4.71 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv9393 Modified Files: Tag: release23-maint NEWS Log Message: note new sre algorithm Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.70 retrieving revision 1.831.4.71 diff -C2 -d -r1.831.4.70 -r1.831.4.71 *** NEWS 31 Oct 2003 10:01:35 -0000 1.831.4.70 --- NEWS 4 Nov 2003 14:38:51 -0000 1.831.4.71 *************** *** 34,37 **** --- 34,41 ---- - Bug #814613: INET_ADDRSTRLEN fix needed for all compilers on SGI + - The sre module (which underlies the re module) now uses a non-recursive + algorithm for matching. A bunch of ugly REs that used to fail with a + RuntimeError will now work. + Library ------- *************** *** 43,48 **** - Bug #780461: platform.mac_ver() raised MacOSError exception under OS X. ! - Bug #812202: random.randrange() returned only even numbers for range lengths above 2**53. What's New in Python 2.3.2 (final)? --- 47,54 ---- - Bug #780461: platform.mac_ver() raised MacOSError exception under OS X. ! - Bug #812202: random.randrange() returned only even numbers for range lengths above 2**53. + + - Bug #823328: urllib2's HTTP Digest Auth support works again. What's New in Python 2.3.2 (final)? From anthonybaxter at users.sourceforge.net Tue Nov 4 09:40:42 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Nov 4 09:40:44 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.71,1.831.4.72 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv10122 Modified Files: Tag: release23-maint NEWS Log Message: include bug number Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.71 retrieving revision 1.831.4.72 diff -C2 -d -r1.831.4.71 -r1.831.4.72 *** NEWS 4 Nov 2003 14:38:51 -0000 1.831.4.71 --- NEWS 4 Nov 2003 14:40:39 -0000 1.831.4.72 *************** *** 36,40 **** - The sre module (which underlies the re module) now uses a non-recursive algorithm for matching. A bunch of ugly REs that used to fail with a ! RuntimeError will now work. Library --- 36,40 ---- - The sre module (which underlies the re module) now uses a non-recursive algorithm for matching. A bunch of ugly REs that used to fail with a ! RuntimeError will now work. See Bug #757624 Library From jackjansen at users.sourceforge.net Tue Nov 4 15:33:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 15:33:12 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app/Resources/English.lproj InfoPlist.strings, 1.5.6.1, 1.5.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj In directory sc8-pr-cvs1:/tmp/cvs-serv13656/app/Resources/English.lproj Modified Files: Tag: release23-maint InfoPlist.strings Log Message: InfoPlist.strings files should be UTF-16, not plain ASCII. Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj/InfoPlist.strings,v retrieving revision 1.5.6.1 retrieving revision 1.5.6.2 diff -C2 -d -r1.5.6.1 -r1.5.6.2 Binary files /tmp/cvs8WiTyX and /tmp/cvs4Q9IUK differ From jackjansen at users.sourceforge.net Tue Nov 4 15:33:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 15:33:15 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/framework/English.lproj InfoPlist.strings, 1.2.6.1, 1.2.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/framework/English.lproj In directory sc8-pr-cvs1:/tmp/cvs-serv13656/framework/English.lproj Modified Files: Tag: release23-maint InfoPlist.strings Log Message: InfoPlist.strings files should be UTF-16, not plain ASCII. Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/framework/English.lproj/InfoPlist.strings,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -C2 -d -r1.2.6.1 -r1.2.6.2 Binary files /tmp/cvslJb158 and /tmp/cvsqfhqY7 differ From jackjansen at users.sourceforge.net Tue Nov 4 16:03:02 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:03:08 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile.panther, 1.1.2.2, 1.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv19025 Modified Files: Tag: release23-maint Makefile.panther Log Message: Files used for second build of MacPython for Panther additions. Index: Makefile.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Attic/Makefile.panther,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** Makefile.panther 1 Nov 2003 22:30:50 -0000 1.1.2.2 --- Makefile.panther 4 Nov 2003 21:02:59 -0000 1.1.2.3 *************** *** 26,30 **** # Add the extra file to the resources. This is to work around a bugs in # PythonIDEMain.py in the original 2.3. ! cp ../Tools/IDE/PythonIDEMain.py $(DESDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: --- 26,30 ---- # Add the extra file to the resources. This is to work around a bugs in # PythonIDEMain.py in the original 2.3. ! cp ../Tools/IDE/PythonIDEMain.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: From jackjansen at users.sourceforge.net Tue Nov 4 16:03:03 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:03:10 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist build.panther, 1.1.2.2, 1.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1:/tmp/cvs-serv19025/Dist Modified Files: Tag: release23-maint build.panther Log Message: Files used for second build of MacPython for Panther additions. Index: build.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/Attic/build.panther,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** build.panther 5 Sep 2003 22:09:14 -0000 1.1.2.2 --- build.panther 4 Nov 2003 21:03:00 -0000 1.1.2.3 *************** *** 9,13 **** PYVERSION=2.3 PYVER=2.3 ! BUILDNUM=1 DOCLEANUP=no --- 9,13 ---- PYVERSION=2.3 PYVER=2.3 ! BUILDNUM=2 DOCLEANUP=no From jackjansen at users.sourceforge.net Tue Nov 4 16:03:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:03:12 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources.panther ReadMe.txt, 1.1.2.2, 1.1.2.3 Welcome.rtf, 1.1.2.2, 1.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther In directory sc8-pr-cvs1:/tmp/cvs-serv19025/Dist/resources.panther Modified Files: Tag: release23-maint ReadMe.txt Welcome.rtf Log Message: Files used for second build of MacPython for Panther additions. Index: ReadMe.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther/Attic/ReadMe.txt,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** ReadMe.txt 5 Sep 2003 22:09:14 -0000 1.1.2.2 --- ReadMe.txt 4 Nov 2003 21:03:01 -0000 1.1.2.3 *************** *** 1,4 **** ! This package will install MacPython 2.3 for Mac OS X ! 10.3 beta (build 7B53 or later). Installation requires approximately 3.3 MB of disk --- 1,4 ---- ! This package will install the second build of ! the MacPython 2.3 additions for Mac OS X 10.3. Installation requires approximately 3.3 MB of disk *************** *** 11,18 **** This installer does not contain a Python engine, as Apple already includes that in 10.3. It does contain ! a set of programs to allow easy ! access to it for Mac users (an integrated development ! environment, a Python extension package manager) and ! the waste module. The installer puts the applications in MacPython-2.3 in --- 11,17 ---- This installer does not contain a Python engine, as Apple already includes that in 10.3. It does contain ! a set of programs to allow easy access to it for Mac ! users (an integrated development environment, a Python ! extension package manager) and the waste module. The installer puts the applications in MacPython-2.3 in *************** *** 22,25 **** --- 21,31 ---- you started quickly with MacPython and contains references to other documentation. + + Changes since the first build: + - The startup crash of the IDE some people experienced + has been fixed. The IDE Scripts folder is now in + ~/Library/Python/IDE-Scripts. + - The full Python documentation can now be installed + through the Package Manager. More information on MacPython can be found at Index: Welcome.rtf =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther/Attic/Welcome.rtf,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** Welcome.rtf 5 Sep 2003 22:09:14 -0000 1.1.2.2 --- Welcome.rtf 4 Nov 2003 21:03:01 -0000 1.1.2.3 *************** *** 5,12 **** \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural ! \f0\fs24 \cf0 This package will install \f1\b MacPython 2.3 ! \f0\b0 for ! \f1\b Mac OS X 10.3 beta (7B53 or later) \f0\b0 . \ \ --- 5,12 ---- \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural ! \f0\fs24 \cf0 This package will install the second build of the \f1\b MacPython 2.3 ! \f0\b0 additions for ! \f1\b Mac OS X 10.3 \f0\b0 . \ \ From jackjansen at users.sourceforge.net Tue Nov 4 16:04:24 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:04:34 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.plist, NONE, 1.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv19197/Tools/IDE Added Files: Tag: release23-maint PackageManager.plist Log Message: Various fixes to make the standard applets have a correct version number, and to make BuildApplet have an icon again (albeit a quickly converted OS9 icon). --- NEW FILE: PackageManager.plist --- CFBundleDevelopmentRegion English CFBundleDocumentTypes CFBundleExecutable PackageManager CFBundleGetInfoString 2.3.2, (c) 2003 Python Software Foundation. CFBundleLongVersionString 2.3.2, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString 2.3.2 CFBundleIconFile PackageManager.icns CFBundleIdentifier org.python.pythonide CFBundleInfoDictionaryVersion 6.0 CFBundleName PythonIDE CFBundlePackageType APPL CFBundleSignature Pide CFBundleVersion 2.3.2 LSRequiresCarbon CSResourcesFileMapped From jackjansen at users.sourceforge.net Tue Nov 4 16:04:24 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:04:36 2003 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplet.icns, NONE, 1.1.2.1 BuildApplet.plist, NONE, 1.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv19197/scripts Added Files: Tag: release23-maint BuildApplet.icns BuildApplet.plist Log Message: Various fixes to make the standard applets have a correct version number, and to make BuildApplet have an icon again (albeit a quickly converted OS9 icon). --- NEW FILE: BuildApplet.icns --- (This appears to be a binary file; contents omitted.) --- NEW FILE: BuildApplet.plist --- CFBundleDevelopmentRegion English CFBundleDocumentTypes CFBundleTypeExtensions py CFBundleTypeIconFile PythonSource.icns CFBundleTypeName Python Module CFBundleTypeOSTypes TEXT CFBundleTypeRole Viewer CFBundleExecutable BuildApplet CFBundleGetInfoString 2.3.2, (c) 2003 Python Software Foundation. CFBundleLongVersionString 2.3.2, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString 2.3.2 CFBundleIconFile BuildApplet.icns CFBundleIdentifier org.python.buildapplet CFBundleInfoDictionaryVersion 6.0 CFBundleName PythonIDE CFBundlePackageType APPL CFBundleSignature Pide CFBundleVersion 2.3.2 LSRequiresCarbon CSResourcesFileMapped From jackjansen at users.sourceforge.net Tue Nov 4 16:04:24 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:04:37 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile,1.50,1.50.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv19197/OSX Modified Files: Tag: release23-maint Makefile Log Message: Various fixes to make the standard applets have a correct version number, and to make BuildApplet have an icon again (albeit a quickly converted OS9 icon). Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.50 retrieving revision 1.50.4.1 diff -C2 -d -r1.50 -r1.50.4.1 *** Makefile 23 Jul 2003 10:49:17 -0000 1.50 --- Makefile 4 Nov 2003 21:04:21 -0000 1.50.4.1 *************** *** 135,138 **** --- 135,139 ---- --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ --iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \ + --plist $(srcdir)/Mac/Tools/IDE/PackageManager.plist \ --creator Pimp build; \ $(BUILDPYTHON) $(bundlebuilder) \ *************** *** 142,145 **** --- 143,147 ---- --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ --iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \ + --plist $(srcdir)/Mac/Tools/IDE/PackageManager.plist \ --creator Pimp build; \ fi From jackjansen at users.sourceforge.net Tue Nov 4 16:15:25 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 16:15:29 2003 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.136.6.1, 1.136.6.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv21414 Modified Files: Tag: release23-maint Makefile.pre.in Log Message: $(prefix) wasn't communicated to Mac/OSX/Makefile for all targets. Fixed. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.136.6.1 retrieving revision 1.136.6.2 diff -C2 -d -r1.136.6.1 -r1.136.6.2 *** Makefile.pre.in 20 Sep 2003 10:50:28 -0000 1.136.6.1 --- Makefile.pre.in 4 Nov 2003 21:15:22 -0000 1.136.6.2 *************** *** 868,872 **** $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installapps \ $(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ ! srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) # This install the unix python and pythonw tools in /usr/local/bin --- 868,872 ---- $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installapps \ $(RUNSHARED) BUILDPYTHON=./$(BUILDPYTHON) DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ ! srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix) # This install the unix python and pythonw tools in /usr/local/bin *************** *** 874,878 **** $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installunixtools \ DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ ! srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) # This installs the Demos and Tools into the applications directory. --- 874,878 ---- $(MAKE) -f $(srcdir)/Mac/OSX/Makefile installunixtools \ DIRMODE=$(DIRMODE) FILEMODE=$(FILEMODE) \ ! srcdir=$(srcdir) builddir=. DESTDIR=$(DESTDIR) prefix=$(prefix) # This installs the Demos and Tools into the applications directory. From jackjansen at users.sourceforge.net Tue Nov 4 17:45:19 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 4 17:45:26 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile, 1.50.4.1, 1.50.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv8344/OSX Modified Files: Tag: release23-maint Makefile Log Message: Temporary "fix" for the fact that pbxbuild is replaced with xcodebuild on Panther: make it a variable. Changing the variable has to be done by hand, for now, that remains to be worked on. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.50.4.1 retrieving revision 1.50.4.2 diff -C2 -d -r1.50.4.1 -r1.50.4.2 *** Makefile 4 Nov 2003 21:04:21 -0000 1.50.4.1 --- Makefile 4 Nov 2003 22:45:16 -0000 1.50.4.2 *************** *** 11,14 **** --- 11,19 ---- DESTDIR= + # For 10.2: + #PBXBUILD=pbxbuild + # For 10.3: + PBXBUILD=xcodebuild + # These are normally glimpsed from the previous set bindir=/usr/local/bin *************** *** 59,63 **** install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ ! pbxbuild -target PythonLauncher -buildstyle Deployment install \ DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH) --- 64,68 ---- install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ ! $(PBXBUILD) -target PythonLauncher -buildstyle Deployment install \ DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH) From rhettinger at users.sourceforge.net Tue Nov 4 19:19:09 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 4 19:19:12 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv25339 Modified Files: pep-0322.txt Log Message: Record Jeremy Fincher's naming suggestion. Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0322.txt 3 Nov 2003 21:31:53 -0000 1.13 --- pep-0322.txt 5 Nov 2003 00:19:06 -0000 1.14 *************** *** 87,90 **** --- 87,91 ---- ======================== + * *reviter* -- Jeremy Fincher's suggestion matches use of iter() * *ireverse* -- uses the itertools naming convention * *inreverse* -- no one seems to like this one except me From jhylton at users.sourceforge.net Wed Nov 5 12:29:37 2003 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Wed Nov 5 12:30:35 2003 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.371,2.372 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv23179 Modified Files: ceval.c Log Message: Make undetected error on stack unwind a fatal error. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.371 retrieving revision 2.372 diff -C2 -d -r2.371 -r2.372 *** ceval.c 28 Oct 2003 12:05:48 -0000 2.371 --- ceval.c 5 Nov 2003 17:29:35 -0000 2.372 *************** *** 2307,2314 **** /* This check is expensive! */ if (PyErr_Occurred()) { ! fprintf(stderr, ! "XXX undetected error (why=%d)\n", ! why); ! why = WHY_EXCEPTION; } } --- 2307,2314 ---- /* This check is expensive! */ if (PyErr_Occurred()) { ! char buf[1024]; ! sprintf(buf, "Stack unwind with exception " ! "set and why=%d", why); ! Py_FatalError(buf); } } From nascheme at users.sourceforge.net Wed Nov 5 18:03:03 2003 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Wed Nov 5 18:03:07 2003 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38, 1.39 traceback.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv27582/Lib Modified Files: threading.py traceback.py Log Message: Add traceback.format_exc(). Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** threading.py 1 Jul 2003 20:01:55 -0000 1.38 --- threading.py 5 Nov 2003 23:02:59 -0000 1.39 *************** *** 9,15 **** raise - from StringIO import StringIO as _StringIO from time import time as _time, sleep as _sleep ! from traceback import print_exc as _print_exc # Rename some stuff so "from threading import *" is safe --- 9,14 ---- raise from time import time as _time, sleep as _sleep ! from traceback import format_exc as _format_exc # Rename some stuff so "from threading import *" is safe *************** *** 441,448 **** if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) - s = _StringIO() - _print_exc(file=s) _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), s.getvalue())) else: if __debug__: --- 440,445 ---- if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) else: if __debug__: Index: traceback.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** traceback.py 15 Aug 2002 14:59:00 -0000 1.28 --- traceback.py 5 Nov 2003 23:03:00 -0000 1.29 *************** *** 7,12 **** __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_exception_only', 'format_list', 'format_stack', ! 'format_tb', 'print_exc', 'print_exception', 'print_last', ! 'print_stack', 'print_tb', 'tb_lineno'] def _print(file, str='', terminator='\n'): --- 7,12 ---- __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_exception_only', 'format_list', 'format_stack', ! 'format_tb', 'print_exc', 'format_exc', 'print_exception', ! 'print_last', 'print_stack', 'print_tb', 'tb_lineno'] def _print(file, str='', terminator='\n'): *************** *** 211,214 **** --- 211,224 ---- finally: etype = value = tb = None + + + def format_exc(limit=None): + """Like print_exc() but return a string.""" + try: + etype, value, tb = sys.exc_info() + return ''.join(format_exception(etype, value, tb, limit)) + finally: + etype = value = tb = None + def print_last(limit=None, file=None): From nascheme at users.sourceforge.net Wed Nov 5 18:03:04 2003 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Wed Nov 5 18:03:10 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.884,1.885 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv27582/Misc Modified Files: NEWS Log Message: Add traceback.format_exc(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.884 retrieving revision 1.885 diff -C2 -d -r1.884 -r1.885 *** NEWS 4 Nov 2003 14:35:49 -0000 1.884 --- NEWS 5 Nov 2003 23:03:00 -0000 1.885 *************** *** 102,105 **** --- 102,108 ---- ------- + - traceback.format_exc has been added (similar to print_exc but it returns + a string). + - xmlrpclib.MultiCall has been added. From nascheme at users.sourceforge.net Wed Nov 5 18:03:31 2003 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Wed Nov 5 18:03:34 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libtraceback.tex, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv27582/Doc/lib Modified Files: libtraceback.tex Log Message: Add traceback.format_exc(). Index: libtraceback.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtraceback.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** libtraceback.tex 30 Jan 2003 22:22:59 -0000 1.17 --- libtraceback.tex 5 Nov 2003 23:02:58 -0000 1.18 *************** *** 49,52 **** --- 49,57 ---- \end{funcdesc} + \begin{funcdesc}{format_exc}{\optional{limit\optional{, file}}} + This is like \code{print_exc(\var{limit})} but returns a string + instead of printing to a file. + \end{funcdesc} + \begin{funcdesc}{print_last}{\optional{limit\optional{, file}}} This is a shorthand for \code{print_exception(sys.last_type, From rhettinger at users.sourceforge.net Wed Nov 5 22:27:24 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 5 22:27:27 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv10501 Modified Files: pep-0322.txt Log Message: Take the __reversed__ protocol out of the pep. It's champions can argue their case elsewhere. Good luck to them. Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0322.txt 5 Nov 2003 00:19:06 -0000 1.14 --- pep-0322.txt 6 Nov 2003 03:27:22 -0000 1.15 *************** *** 95,109 **** - Custom Reverse - ============== - - Objects may optionally provide a *__reversed__* method that returns - a custom reverse iterator. - - This allows *reverse()* to be applied to objects that do not have - __getitem__() and __len__() but still have some useful way of - providing reverse iteration. - - Discussion ========== --- 95,98 ---- From gvanrossum at users.sourceforge.net Thu Nov 6 00:32:16 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Nov 6 00:32:19 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv27454 Modified Files: pep-0322.txt Log Message: Remove vestigial reference to __reversed__. Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** pep-0322.txt 6 Nov 2003 03:27:22 -0000 1.15 --- pep-0322.txt 6 Nov 2003 05:32:14 -0000 1.16 *************** *** 68,74 **** def reversed(x): - if hasattr(x, 'reversed'): - for elem x.__reversed__(): - yield x if hasattr(x, 'keys'): raise ValueError("mappings do not support reverse iteration") --- 68,71 ---- From theller at python.net Thu Nov 6 05:31:11 2003 From: theller at python.net (Thomas Heller) Date: Thu Nov 6 05:31:32 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libtraceback.tex, 1.17, 1.18 In-Reply-To: (nascheme@users.sourceforge.net's message of "Wed, 05 Nov 2003 15:03:31 -0800") References: Message-ID: nascheme@users.sourceforge.net writes: > Update of /cvsroot/python/python/dist/src/Doc/lib > In directory sc8-pr-cvs1:/tmp/cvs-serv27582/Doc/lib > > Modified Files: > libtraceback.tex > Log Message: > Add traceback.format_exc(). > > > Index: libtraceback.tex > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtraceback.tex,v > retrieving revision 1.17 > retrieving revision 1.18 > diff -C2 -d -r1.17 -r1.18 > *** libtraceback.tex 30 Jan 2003 22:22:59 -0000 1.17 > --- libtraceback.tex 5 Nov 2003 23:02:58 -0000 1.18 > *************** > *** 49,52 **** > --- 49,57 ---- > \end{funcdesc} > > + \begin{funcdesc}{format_exc}{\optional{limit\optional{, file}}} > + This is like \code{print_exc(\var{limit})} but returns a string > + instead of printing to a file. > + \end{funcdesc} > + Shouldn't there be a 'new in Python 2.4' note here? I don't remember how this is spelled in LaTeX. Thomas From rhettinger at users.sourceforge.net Thu Nov 6 07:22:40 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 07:22:43 2003 Subject: [Python-checkins] python/nondist/peps pep-0322.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv30713 Modified Files: pep-0322.txt Log Message: Record conditional acceptance of the PEP Index: pep-0322.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pep-0322.txt 6 Nov 2003 05:32:14 -0000 1.16 --- pep-0322.txt 6 Nov 2003 12:22:37 -0000 1.17 *************** *** 4,8 **** Last-Modified: $Date$ Author: Raymond Hettinger ! Status: Draft Type: Standards Track Content-Type: text/x-rst --- 4,8 ---- Last-Modified: $Date$ Author: Raymond Hettinger ! Status: Accepted Type: Standards Track Content-Type: text/x-rst *************** *** 79,82 **** --- 79,89 ---- A C implementation and unit tests are at: http://www.python.org/sf/834422 + + BDFL Pronouncement + ================== + + This PEP has been conditionally accepted for Py2.4. The condition means + that if the function is found to be useless, it can be removed before + Py2.4b1. From anthonybaxter at users.sourceforge.net Thu Nov 6 08:40:48 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Nov 6 08:40:52 2003 Subject: [Python-checkins] python/dist/src/Lib repr.py,1.15,1.15.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv12406/Lib Modified Files: Tag: release23-maint repr.py Log Message: On RH10, the PIE additions to gcc mean that id() can sometimes be a very large 32 bit int, which comes out as a negative int. Workaround this to prevent warnings from the test suite. Index: repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/repr.py,v retrieving revision 1.15 retrieving revision 1.15.12.1 diff -C2 -d -r1.15 -r1.15.12.1 *** repr.py 5 Feb 2003 18:29:33 -0000 1.15 --- repr.py 6 Nov 2003 13:40:45 -0000 1.15.12.1 *************** *** 3,6 **** --- 3,8 ---- __all__ = ["Repr","repr"] + import sys + class Repr: def __init__(self): *************** *** 102,107 **** # exceptions -- then make up something except: ! return '<' + x.__class__.__name__ + ' instance at ' + \ ! hex(id(x))[2:] + '>' if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) --- 104,111 ---- # exceptions -- then make up something except: ! # On some systems (RH10) id() can be a negative number. ! # work around this. ! MAX = 2L*sys.maxint+1 ! return '<' + x.__class__.__name__ + ' instance at %x>'%(id(x)&MAX) if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) From anthonybaxter at users.sourceforge.net Thu Nov 6 08:40:48 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Nov 6 08:40:54 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_repr.py, 1.16, 1.16.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv12406/Lib/test Modified Files: Tag: release23-maint test_repr.py Log Message: On RH10, the PIE additions to gcc mean that id() can sometimes be a very large 32 bit int, which comes out as a negative int. Workaround this to prevent warnings from the test suite. Index: test_repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_repr.py,v retrieving revision 1.16 retrieving revision 1.16.14.1 diff -C2 -d -r1.16 -r1.16.14.1 *** test_repr.py 5 Feb 2003 18:29:33 -0000 1.16 --- test_repr.py 6 Nov 2003 13:40:46 -0000 1.16.14.1 *************** *** 89,93 **** i3 = ClassWithFailingRepr() ! eq(r(i3), (""%id(i3))) s = r(ClassWithFailingRepr) --- 89,96 ---- i3 = ClassWithFailingRepr() ! # On some systems (RH10) id() can be a negative number. ! # work around this. ! MAX = 2L*sys.maxint+1 ! eq(r(i3), (""%(id(i3)&MAX))) s = r(ClassWithFailingRepr) From anthonybaxter at users.sourceforge.net Thu Nov 6 08:57:51 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Nov 6 08:57:55 2003 Subject: [Python-checkins] python/dist/src/Lib asyncore.py, 1.40.12.1, 1.40.12.2 tarfile.py, 1.8.12.1, 1.8.12.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv15263 Modified Files: Tag: release23-maint asyncore.py tarfile.py Log Message: On RH10, the PIE additions to gcc mean that id() can sometimes be a very large 32 bit int, which comes out as a negative int. Workaround this to prevent warnings from the test suite and the std lib. Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.40.12.1 retrieving revision 1.40.12.2 diff -C2 -d -r1.40.12.1 -r1.40.12.2 *** asyncore.py 20 Oct 2003 14:34:45 -0000 1.40.12.1 --- asyncore.py 6 Nov 2003 13:57:49 -0000 1.40.12.2 *************** *** 228,232 **** except TypeError: status.append(repr(self.addr)) ! return '<%s at %#x>' % (' '.join(status), id(self)) def add_channel(self, map=None): --- 228,235 ---- except TypeError: status.append(repr(self.addr)) ! # On some systems (RH10) id() can be a negative number. ! # work around this. ! MAX = 2L*sys.maxint+1 ! return '<%s at %#x>' % (' '.join(status), id(self)&MAX) def add_channel(self, map=None): Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.8.12.1 retrieving revision 1.8.12.2 diff -C2 -d -r1.8.12.1 -r1.8.12.2 *** tarfile.py 24 Oct 2003 17:47:57 -0000 1.8.12.1 --- tarfile.py 6 Nov 2003 13:57:49 -0000 1.8.12.2 *************** *** 650,654 **** def __repr__(self): ! return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) def frombuf(cls, buf): --- 650,658 ---- def __repr__(self): ! # On some systems (RH10) id() can be a negative number. ! # work around this. ! MAX = 2L*sys.maxint+1 ! return "<%s %r at %#x>" % (self.__class__.__name__,self.name, ! id(self)&MAX) def frombuf(cls, buf): From anthonybaxter at users.sourceforge.net Thu Nov 6 08:57:52 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Nov 6 08:57:57 2003 Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py, 1.51, 1.51.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory sc8-pr-cvs1:/tmp/cvs-serv15263/xml/dom Modified Files: Tag: release23-maint minidom.py Log Message: On RH10, the PIE additions to gcc mean that id() can sometimes be a very large 32 bit int, which comes out as a negative int. Workaround this to prevent warnings from the test suite and the std lib. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.51 retrieving revision 1.51.10.1 diff -C2 -d -r1.51 -r1.51.10.1 *** minidom.py 6 Apr 2003 09:01:07 -0000 1.51 --- minidom.py 6 Nov 2003 13:57:49 -0000 1.51.10.1 *************** *** 15,18 **** --- 15,19 ---- """ + import sys import xml.dom *************** *** 795,799 **** def __repr__(self): ! return "" % (self.tagName, id(self)) def writexml(self, writer, indent="", addindent="", newl=""): --- 796,803 ---- def __repr__(self): ! # On some systems (RH10) id() can be a negative number. ! # work around this. ! MAX = 2L*sys.maxint+1 ! return "" % (self.tagName, id(self)&MAX) def writexml(self, writer, indent="", addindent="", newl=""): From rhettinger at users.sourceforge.net Thu Nov 6 09:06:48 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:06:52 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.150,1.151 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Doc/lib Modified Files: libfuncs.tex Log Message: Implement and apply PEP 322, reverse iteration Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.150 retrieving revision 1.151 diff -C2 -d -r1.150 -r1.151 *** libfuncs.tex 13 Oct 2003 17:52:35 -0000 1.150 --- libfuncs.tex 6 Nov 2003 14:06:46 -0000 1.151 *************** *** 881,884 **** --- 881,892 ---- \end{funcdesc} + \begin{funcdesc}{reversed}{seq} + Return a reverse iterator. \var{seq} must be an object which + supports the sequence protocol (the __len__() method and the + \method{__getitem__()} method with integer arguments starting at + \code{0}). + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{round}{x\optional{, n}} Return the floating point value \var{x} rounded to \var{n} digits From rhettinger at users.sourceforge.net Thu Nov 6 09:06:48 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:06:54 2003 Subject: [Python-checkins] python/dist/src/Include enumobject.h,2.2,2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Include Modified Files: enumobject.h Log Message: Implement and apply PEP 322, reverse iteration Index: enumobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/enumobject.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** enumobject.h 12 Aug 2002 07:21:56 -0000 2.2 --- enumobject.h 6 Nov 2003 14:06:46 -0000 2.3 *************** *** 9,12 **** --- 9,13 ---- PyAPI_DATA(PyTypeObject) PyEnum_Type; + PyAPI_DATA(PyTypeObject) PyReversed_Type; #ifdef __cplusplus From rhettinger at users.sourceforge.net Thu Nov 6 09:06:49 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:06:55 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.885,1.886 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Misc Modified Files: NEWS Log Message: Implement and apply PEP 322, reverse iteration Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.885 retrieving revision 1.886 diff -C2 -d -r1.885 -r1.886 *** NEWS 5 Nov 2003 23:03:00 -0000 1.885 --- NEWS 6 Nov 2003 14:06:47 -0000 1.886 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Added a reversed() builtin function that returns a reverse iterator + over a sequence. + - CObjects are now mutable (on the C level) through PyCObject_SetVoidPtr. From rhettinger at users.sourceforge.net Thu Nov 6 09:06:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:06:57 2003 Subject: [Python-checkins] python/dist/src/Objects enumobject.c, 1.8, 1.9 rangeobject.c, 2.48, 2.49 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Objects Modified Files: enumobject.c rangeobject.c Log Message: Implement and apply PEP 322, reverse iteration Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** enumobject.c 2 Nov 2003 05:37:44 -0000 1.8 --- enumobject.c 6 Nov 2003 14:06:47 -0000 1.9 *************** *** 156,157 **** --- 156,282 ---- PyObject_GC_Del, /* tp_free */ }; + + /* Reversed Object ***************************************************************/ + + typedef struct { + PyObject_HEAD + long index; + PyObject* seq; + } reversedobject; + + static PyObject * + reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + long n; + PyObject *seq; + reversedobject *ro; + + if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq)) + return NULL; + + /* Special case optimization for xrange */ + if (PyRange_Check(seq)) + return PyObject_CallMethod(seq, "__reversed__", NULL); + + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, + "argument to reversed() must be a sequence"); + return NULL; + } + + n = PySequence_Size(seq); + if (n == -1) + return NULL; + + ro = (reversedobject *)type->tp_alloc(type, 0); + if (ro == NULL) + return NULL; + + ro->index = n-1; + Py_INCREF(seq); + ro->seq = seq; + return (PyObject *)ro; + } + + static void + reversed_dealloc(reversedobject *ro) + { + PyObject_GC_UnTrack(ro); + Py_XDECREF(ro->seq); + ro->ob_type->tp_free(ro); + } + + static int + reversed_traverse(reversedobject *ro, visitproc visit, void *arg) + { + if (ro->seq) + return visit((PyObject *)(ro->seq), arg); + return 0; + } + + static PyObject * + reversed_next(reversedobject *ro) + { + PyObject *item; + + if (ro->index < 0) + return NULL; + + assert(PySequence_Check(ro->seq)); + item = PySequence_GetItem(ro->seq, ro->index); + if (item == NULL) + return NULL; + + ro->index--; + return item; + } + + PyDoc_STRVAR(reversed_doc, + "reverse(sequence) -> reverse iterator over values of the sequence\n" + "\n" + "Return a reverse iterator"); + + PyTypeObject PyReversed_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "reversed", /* tp_name */ + sizeof(reversedobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)reversed_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + reversed_doc, /* tp_doc */ + (traverseproc)reversed_traverse,/* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)reversed_next, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + reversed_new, /* tp_new */ + PyObject_GC_Del, /* tp_free */ + }; Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.48 retrieving revision 2.49 diff -C2 -d -r2.48 -r2.49 *** rangeobject.c 17 Mar 2003 19:46:11 -0000 2.48 --- rangeobject.c 6 Nov 2003 14:06:47 -0000 2.49 *************** *** 172,175 **** --- 172,184 ---- static PyObject * range_iter(PyObject *seq); + static PyObject * range_reverse(PyObject *seq); + + PyDoc_STRVAR(reverse_doc, + "Returns a reverse iterator."); + + static PyMethodDef range_methods[] = { + {"__reversed__", (PyCFunction)range_reverse, METH_NOARGS, reverse_doc}, + {NULL, NULL} /* sentinel */ + }; PyTypeObject PyRange_Type = { *************** *** 202,206 **** (getiterfunc)range_iter, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ --- 211,215 ---- (getiterfunc)range_iter, /* tp_iter */ 0, /* tp_iternext */ ! range_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ *************** *** 243,246 **** --- 252,281 ---- it->step = ((rangeobject *)seq)->step; it->len = ((rangeobject *)seq)->len; + return (PyObject *)it; + } + + static PyObject * + range_reverse(PyObject *seq) + { + rangeiterobject *it; + long start, step, len; + + if (!PyRange_Check(seq)) { + PyErr_BadInternalCall(); + return NULL; + } + it = PyObject_New(rangeiterobject, &Pyrangeiter_Type); + if (it == NULL) + return NULL; + + start = ((rangeobject *)seq)->start; + step = ((rangeobject *)seq)->step; + len = ((rangeobject *)seq)->len; + + it->index = 0; + it->start = start + (len-1) * step; + it->step = -step; + it->len = len; + return (PyObject *)it; } From rhettinger at users.sourceforge.net Thu Nov 6 09:06:49 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:07:01 2003 Subject: [Python-checkins] python/dist/src/Lib heapq.py, 1.18, 1.19 mhlib.py, 1.35, 1.36 platform.py, 1.8, 1.9 random.py, 1.57, 1.58 rfc822.py, 1.74, 1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Lib Modified Files: heapq.py mhlib.py platform.py random.py rfc822.py Log Message: Implement and apply PEP 322, reverse iteration Index: heapq.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/heapq.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** heapq.py 20 Oct 2003 14:01:49 -0000 1.18 --- heapq.py 6 Nov 2003 14:06:46 -0000 1.19 *************** *** 166,170 **** # j-1 is the largest, which is n//2 - 1. If n is odd = 2*j+1, this is # (2*j+1-1)/2 = j so j-1 is the largest, and that's again n//2-1. ! for i in xrange(n//2 - 1, -1, -1): _siftup(x, i) --- 166,170 ---- # j-1 is the largest, which is n//2 - 1. If n is odd = 2*j+1, this is # (2*j+1-1)/2 = j so j-1 is the largest, and that's again n//2-1. ! for i in reversed(xrange(n//2)): _siftup(x, i) Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** mhlib.py 27 Feb 2003 20:14:35 -0000 1.35 --- mhlib.py 6 Nov 2003 14:06:46 -0000 1.36 *************** *** 976,981 **** f.putsequences(seqs) do('f.getsequences()') ! testfolders.reverse() ! for t in testfolders: do('mh.deletefolder(%s)' % `t`) do('mh.getcontext()') context = mh.getcontext() --- 976,980 ---- f.putsequences(seqs) do('f.getsequences()') ! for t in reversed(testfolders): do('mh.deletefolder(%s)' % `t`) do('mh.getcontext()') context = mh.getcontext() Index: platform.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/platform.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** platform.py 2 Nov 2003 09:47:05 -0000 1.8 --- platform.py 6 Nov 2003 14:06:47 -0000 1.9 *************** *** 202,206 **** # Check for slackware verson tag file (thanks to Greg Andruk) verfiles = os.listdir('/usr/lib/setup') ! for n in range(len(verfiles)-1, -1, -1): if verfiles[n][:14] != 'slack-version-': del verfiles[n] --- 202,206 ---- # Check for slackware verson tag file (thanks to Greg Andruk) verfiles = os.listdir('/usr/lib/setup') ! for n in reversed(xrange(len(verfiles))): if verfiles[n][:14] != 'slack-version-': del verfiles[n] Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** random.py 12 Oct 2003 17:14:11 -0000 1.57 --- random.py 6 Nov 2003 14:06:47 -0000 1.58 *************** *** 254,258 **** if random is None: random = self.random ! for i in xrange(len(x)-1, 0, -1): # pick an element in x[:i+1] with which to exchange x[i] j = int(random() * (i+1)) --- 254,258 ---- if random is None: random = self.random ! for i in reversed(xrange(1, len(x))): # pick an element in x[:i+1] with which to exchange x[i] j = int(random() * (i+1)) Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** rfc822.py 11 Sep 2002 02:32:14 -0000 1.74 --- rfc822.py 6 Nov 2003 14:06:47 -0000 1.75 *************** *** 422,427 **** if hit: list.append(i) ! list.reverse() ! for i in list: del self.headers[i] --- 422,426 ---- if hit: list.append(i) ! for i in reversed(list): del self.headers[i] From rhettinger at users.sourceforge.net Thu Nov 6 09:06:49 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:07:02 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_enumerate.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Lib/test Modified Files: test_enumerate.py Log Message: Implement and apply PEP 322, reverse iteration Index: test_enumerate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_enumerate.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_enumerate.py 29 May 2003 07:20:29 -0000 1.6 --- test_enumerate.py 6 Nov 2003 14:06:47 -0000 1.7 *************** *** 125,131 **** res = zip(range(20000), seq) def test_main(verbose=None): ! testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig) test_support.run_unittest(*testclasses) --- 125,149 ---- res = zip(range(20000), seq) + class TestReversed(unittest.TestCase): + + def test_simple(self): + class A: + def __getitem__(self, i): + if i < 5: + return str(i) + raise StopIteration + def __len__(self): + return 5 + for data in 'abc', range(5), tuple(enumerate('abc')), A(), xrange(1,17,5): + self.assertEqual(list(data)[::-1], list(reversed(data))) + self.assertRaises(TypeError, reversed, {}) + + def test_xrange_optimization(self): + x = xrange(1) + self.assertEqual(type(reversed(x)), type(iter(x))) def test_main(verbose=None): ! testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig, ! TestReversed) test_support.run_unittest(*testclasses) From rhettinger at users.sourceforge.net Thu Nov 6 09:06:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:07:04 2003 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.301,2.302 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv17028/Python Modified Files: bltinmodule.c Log Message: Implement and apply PEP 322, reverse iteration Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.301 retrieving revision 2.302 diff -C2 -d -r2.301 -r2.302 *** bltinmodule.c 25 Oct 2003 23:24:14 -0000 2.301 --- bltinmodule.c 6 Nov 2003 14:06:48 -0000 2.302 *************** *** 2122,2125 **** --- 2122,2126 ---- SETBUILTIN("long", &PyLong_Type); SETBUILTIN("object", &PyBaseObject_Type); + SETBUILTIN("reversed", &PyReversed_Type); SETBUILTIN("slice", &PySlice_Type); SETBUILTIN("staticmethod", &PyStaticMethod_Type); From rhettinger at users.sourceforge.net Thu Nov 6 09:07:19 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 09:07:23 2003 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.257,1.258 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv17182 Modified Files: pep-0000.txt Log Message: Implement and apply PEP 322, reverse iteration Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.257 retrieving revision 1.258 diff -C2 -d -r1.257 -r1.258 *** pep-0000.txt 28 Oct 2003 18:06:32 -0000 1.257 --- pep-0000.txt 6 Nov 2003 14:07:17 -0000 1.258 *************** *** 119,123 **** S 319 Python Synchronize/Asynchronize Block Pelletier S 321 Date/Time Parsing and Formatting Kuchling - S 322 Reverse Iteration Hettinger S 323 Copyable Iterators Martelli S 754 IEEE 754 Floating Point Special Values Warnes --- 119,122 ---- *************** *** 161,164 **** --- 160,164 ---- SF 293 Codec Error Handling Callbacks Dörwald SF 311 Simplified GIL Acquisition for Extensions Hammond + SF 322 Reverse Iteration Hettinger Empty PEPs (or containing only an abstract) *************** *** 338,342 **** I 320 Python 2.4 Release Schedule Warsaw S 321 Date/Time Parsing and Formatting Kuchling ! S 322 Reverse Iteration Hettinger SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes --- 338,342 ---- I 320 Python 2.4 Release Schedule Warsaw S 321 Date/Time Parsing and Formatting Kuchling ! SF 322 Reverse Iteration Hettinger SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes From loewis at users.sourceforge.net Thu Nov 6 15:47:46 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 15:47:52 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.72,1.831.4.73 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv3011/Misc Modified Files: Tag: release23-maint NEWS Log Message: Overallocate target buffer for normalization more early. Fixes #834676. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.72 retrieving revision 1.831.4.73 diff -C2 -d -r1.831.4.72 -r1.831.4.73 *** NEWS 4 Nov 2003 14:40:39 -0000 1.831.4.72 --- NEWS 6 Nov 2003 20:47:43 -0000 1.831.4.73 *************** *** 19,22 **** --- 19,24 ---- ----------------- + - Bug #834676: Fix crashes when normalizing Hangul syllables. + - Bug #703198: Ignore "b" and "t" in os.popen on Unix. From loewis at users.sourceforge.net Thu Nov 6 15:47:46 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 15:47:55 2003 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c, 2.28, 2.28.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv3011/Modules Modified Files: Tag: release23-maint unicodedata.c Log Message: Overallocate target buffer for normalization more early. Fixes #834676. Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.28 retrieving revision 2.28.10.1 diff -C2 -d -r2.28 -r2.28.10.1 *** unicodedata.c 28 Feb 2003 03:14:37 -0000 2.28 --- unicodedata.c 6 Nov 2003 20:47:43 -0000 2.28.10.1 *************** *** 312,321 **** while(stackptr) { Py_UNICODE code = stack[--stackptr]; ! if (!space) { ! space = PyString_GET_SIZE(result) + 10; ! if (PyUnicode_Resize(&result, space) == -1) return NULL; ! o = PyUnicode_AS_UNICODE(result) + space - 10; ! space = 10; } /* Hangul Decomposition. */ --- 312,323 ---- while(stackptr) { Py_UNICODE code = stack[--stackptr]; ! /* Hangul Decomposition adds three characters in ! a single step, so we need atleast that much room. */ ! if (space < 3) { ! int newsize = PyString_GET_SIZE(result) + 10; ! space += 10; ! if (PyUnicode_Resize(&result, newsize) == -1) return NULL; ! o = PyUnicode_AS_UNICODE(result) + newsize - space; } /* Hangul Decomposition. */ From loewis at users.sourceforge.net Thu Nov 6 15:47:45 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 15:47:57 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_normalization.py, 1.7.8.1, 1.7.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv3011/Lib/test Modified Files: Tag: release23-maint test_normalization.py Log Message: Overallocate target buffer for normalization more early. Fixes #834676. Index: test_normalization.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_normalization.py,v retrieving revision 1.7.8.1 retrieving revision 1.7.8.2 diff -C2 -d -r1.7.8.1 -r1.7.8.2 *** test_normalization.py 5 Aug 2003 05:59:47 -0000 1.7.8.1 --- test_normalization.py 6 Nov 2003 20:47:42 -0000 1.7.8.2 *************** *** 85,88 **** --- 85,91 ---- assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c + # Check for bug 834676 + normalize('NFC',u'\ud55c\uae00') + if __name__ == "__main__": test_main() From loewis at users.sourceforge.net Thu Nov 6 15:47:59 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 15:48:04 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_normalization.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv3149/Lib/test Modified Files: test_normalization.py Log Message: Overallocate target buffer for normalization more early. Fixes #834676. Backported to 2.3. Index: test_normalization.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_normalization.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_normalization.py 5 Aug 2003 05:59:13 -0000 1.8 --- test_normalization.py 6 Nov 2003 20:47:57 -0000 1.9 *************** *** 85,88 **** --- 85,91 ---- assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c + # Check for bug 834676 + normalize('NFC',u'\ud55c\uae00') + if __name__ == "__main__": test_main() From loewis at users.sourceforge.net Thu Nov 6 15:47:59 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 15:48:48 2003 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.28,2.29 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv3149/Modules Modified Files: unicodedata.c Log Message: Overallocate target buffer for normalization more early. Fixes #834676. Backported to 2.3. Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** unicodedata.c 28 Feb 2003 03:14:37 -0000 2.28 --- unicodedata.c 6 Nov 2003 20:47:57 -0000 2.29 *************** *** 312,321 **** while(stackptr) { Py_UNICODE code = stack[--stackptr]; ! if (!space) { ! space = PyString_GET_SIZE(result) + 10; ! if (PyUnicode_Resize(&result, space) == -1) return NULL; ! o = PyUnicode_AS_UNICODE(result) + space - 10; ! space = 10; } /* Hangul Decomposition. */ --- 312,323 ---- while(stackptr) { Py_UNICODE code = stack[--stackptr]; ! /* Hangul Decomposition adds three characters in ! a single step, so we need atleast that much room. */ ! if (space < 3) { ! int newsize = PyString_GET_SIZE(result) + 10; ! space += 10; ! if (PyUnicode_Resize(&result, newsize) == -1) return NULL; ! o = PyUnicode_AS_UNICODE(result) + newsize - space; } /* Hangul Decomposition. */ From loewis at users.sourceforge.net Thu Nov 6 16:07:49 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 16:07:54 2003 Subject: [Python-checkins] python/dist/src/Doc/api intro.tex, 1.3.24.1, 1.3.24.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv7179 Modified Files: Tag: release23-maint intro.tex Log Message: Patch #837322: Clarify owning, borrowing, stealing. Index: intro.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/intro.tex,v retrieving revision 1.3.24.1 retrieving revision 1.3.24.2 diff -C2 -d -r1.3.24.1 -r1.3.24.2 *** intro.tex 13 Oct 2003 17:48:23 -0000 1.3.24.1 --- intro.tex 6 Nov 2003 21:07:47 -0000 1.3.24.2 *************** *** 170,179 **** The reference count behavior of functions in the Python/C API is best ! explained in terms of \emph{ownership of references}. Note that we ! talk of owning references, never of owning objects; objects are always ! shared! When a function owns a reference, it has to dispose of it ! properly --- either by passing ownership on (usually to its caller) or ! by calling \cfunction{Py_DECREF()} or \cfunction{Py_XDECREF()}. When ! a function passes ownership of a reference on to its caller, the caller is said to receive a \emph{new} reference. When no ownership is transferred, the caller is said to \emph{borrow} the reference. --- 170,183 ---- The reference count behavior of functions in the Python/C API is best ! explained in terms of \emph{ownership of references}. Ownership ! pertains to references, never to objects (objects are not owned: they ! are always shared). "Owning a reference" means being responsible for ! calling Py_DECREF on it when the reference is no longer needed. ! Ownership can also be transferred, meaning that the code that receives ! ownership of the reference then becomes responsible for eventually ! decref'ing it by calling \cfunction{Py_DECREF()} or ! \cfunction{Py_XDECREF()} when it's no longer needed --or passing on ! this responsibility (usually to its caller). ! When a function passes ownership of a reference on to its caller, the caller is said to receive a \emph{new} reference. When no ownership is transferred, the caller is said to \emph{borrow} the reference. From loewis at users.sourceforge.net Thu Nov 6 16:08:14 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 6 16:08:20 2003 Subject: [Python-checkins] python/dist/src/Doc/api intro.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv7298 Modified Files: intro.tex Log Message: Patch #837322: Clarify owning, borrowing, stealing. Backported to 2.3. Index: intro.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/intro.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** intro.tex 13 Oct 2003 17:47:30 -0000 1.4 --- intro.tex 6 Nov 2003 21:08:11 -0000 1.5 *************** *** 170,179 **** The reference count behavior of functions in the Python/C API is best ! explained in terms of \emph{ownership of references}. Note that we ! talk of owning references, never of owning objects; objects are always ! shared! When a function owns a reference, it has to dispose of it ! properly --- either by passing ownership on (usually to its caller) or ! by calling \cfunction{Py_DECREF()} or \cfunction{Py_XDECREF()}. When ! a function passes ownership of a reference on to its caller, the caller is said to receive a \emph{new} reference. When no ownership is transferred, the caller is said to \emph{borrow} the reference. --- 170,183 ---- The reference count behavior of functions in the Python/C API is best ! explained in terms of \emph{ownership of references}. Ownership ! pertains to references, never to objects (objects are not owned: they ! are always shared). "Owning a reference" means being responsible for ! calling Py_DECREF on it when the reference is no longer needed. ! Ownership can also be transferred, meaning that the code that receives ! ownership of the reference then becomes responsible for eventually ! decref'ing it by calling \cfunction{Py_DECREF()} or ! \cfunction{Py_XDECREF()} when it's no longer needed --or passing on ! this responsibility (usually to its caller). ! When a function passes ownership of a reference on to its caller, the caller is said to receive a \emph{new} reference. When no ownership is transferred, the caller is said to \emph{borrow} the reference. From rhettinger at users.sourceforge.net Thu Nov 6 20:31:00 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 6 20:31:05 2003 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.209,1.210 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1:/tmp/cvs-serv24004 Modified Files: tut.tex Log Message: Add a new looping idiom Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.209 retrieving revision 1.210 diff -C2 -d -r1.209 -r1.210 *** tut.tex 25 Oct 2003 14:15:54 -0000 1.209 --- tut.tex 7 Nov 2003 01:30:58 -0000 1.210 *************** *** 2163,2166 **** --- 2163,2181 ---- \end{verbatim} + To loop over a sequence in reverse, first specify the sequence + in a forward direction and then call the \function{reversed()} + function. + + \begin{verbatim} + >>> for i in reversed(xrange(1,10,2)): + ... print i + ... + 9 + 7 + 5 + 3 + 1 + \end{verbatim} + \section{More on Conditions \label{conditions}} From mwh at users.sourceforge.net Fri Nov 7 06:45:36 2003 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Fri Nov 7 06:45:40 2003 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1:/tmp/cvs-serv10476 Modified Files: extending.tex Log Message: Fix the problem addressed by patch [ 819012 ] Fix for former/latter confusion in Extending documentation although not by using supplied patch. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** extending.tex 8 Sep 2003 19:01:04 -0000 1.25 --- extending.tex 7 Nov 2003 11:45:34 -0000 1.26 *************** *** 820,824 **** \cfunction{free()}. In \Cpp, the operators \keyword{new} and \keyword{delete} are used with essentially the same meaning and ! we'll restrict the following discussion to the latter. Every block of memory allocated with \cfunction{malloc()} should --- 820,824 ---- \cfunction{free()}. In \Cpp, the operators \keyword{new} and \keyword{delete} are used with essentially the same meaning and ! we'll restrict the following discussion to the C case. Every block of memory allocated with \cfunction{malloc()} should From mwh at users.sourceforge.net Fri Nov 7 07:11:18 2003 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Fri Nov 7 07:11:20 2003 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex, 1.24.10.1, 1.24.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1:/tmp/cvs-serv14010 Modified Files: Tag: release23-maint extending.tex Log Message: Backport of 1.26: Fix the problem addressed by patch [ 819012 ] Fix for former/latter confusion in Extending documentation although not by using supplied patch. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.24.10.1 retrieving revision 1.24.10.2 diff -C2 -d -r1.24.10.1 -r1.24.10.2 *** extending.tex 8 Sep 2003 19:01:57 -0000 1.24.10.1 --- extending.tex 7 Nov 2003 12:11:16 -0000 1.24.10.2 *************** *** 820,824 **** \cfunction{free()}. In \Cpp, the operators \keyword{new} and \keyword{delete} are used with essentially the same meaning and ! we'll restrict the following discussion to the latter. Every block of memory allocated with \cfunction{malloc()} should --- 820,824 ---- \cfunction{free()}. In \Cpp, the operators \keyword{new} and \keyword{delete} are used with essentially the same meaning and ! we'll restrict the following discussion to the C case. Every block of memory allocated with \cfunction{malloc()} should From mwh at users.sourceforge.net Fri Nov 7 07:25:55 2003 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Fri Nov 7 07:25:59 2003 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex, 1.11.6.2, 1.11.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1:/tmp/cvs-serv15894 Modified Files: Tag: release22-maint extending.tex Log Message: Backport of 1.26: Fix the problem addressed by patch [ 819012 ] Fix for former/latter confusion in Extending documentation although not by using supplied patch. Though this backport actually includes the fix that caused the problem in the first place! Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.11.6.2 retrieving revision 1.11.6.3 diff -C2 -d -r1.11.6.2 -r1.11.6.3 *** extending.tex 16 May 2002 13:47:00 -0000 1.11.6.2 --- extending.tex 7 Nov 2003 12:25:53 -0000 1.11.6.3 *************** *** 1175,1186 **** \label{refcounts}} ! In languages like C or \Cpp, the programmer is responsible for ! dynamic allocation and deallocation of memory on the heap. In C, ! this is done using the functions \cfunction{malloc()} and ! \cfunction{free()}. In \Cpp, the operators \keyword{new} and ! \keyword{delete} are used with essentially the same meaning; they are ! actually implemented using \cfunction{malloc()} and ! \cfunction{free()}, so we'll restrict the following discussion to the ! latter. Every block of memory allocated with \cfunction{malloc()} should --- 1175,1184 ---- \label{refcounts}} ! In languages like C or \Cpp, the programmer is responsible for dynamic ! allocation and deallocation of memory on the heap. In C, this is done ! using the functions \cfunction{malloc()} and \cfunction{free()}. In ! \Cpp, the operators \keyword{new} and \keyword{delete} are used with ! essentially the same meaning so we'll restrict the following ! discussion to the C case. Every block of memory allocated with \cfunction{malloc()} should From rhettinger at users.sourceforge.net Fri Nov 7 10:38:12 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 7 10:38:16 2003 Subject: [Python-checkins] python/dist/src/Objects enumobject.c, 1.9, 1.10 listobject.c, 2.162, 2.163 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv17927 Modified Files: enumobject.c listobject.c Log Message: Optimize reversed(list) using a custom iterator. Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** enumobject.c 6 Nov 2003 14:06:47 -0000 1.9 --- enumobject.c 7 Nov 2003 15:38:08 -0000 1.10 *************** *** 175,180 **** return NULL; ! /* Special case optimization for xrange */ ! if (PyRange_Check(seq)) return PyObject_CallMethod(seq, "__reversed__", NULL); --- 175,180 ---- return NULL; ! /* Special case optimization for xrange and lists */ ! if (PyRange_Check(seq) || PyList_Check(seq)) return PyObject_CallMethod(seq, "__reversed__", NULL); Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -d -r2.162 -r2.163 *** listobject.c 3 Nov 2003 20:58:28 -0000 2.162 --- listobject.c 7 Nov 2003 15:38:09 -0000 2.163 *************** *** 2350,2353 **** --- 2350,2358 ---- } + static PyObject *list_iter(PyObject *seq); + static PyObject *list_reversed(PyListObject* seq, PyObject* unused); + + PyDoc_STRVAR(reversed_doc, + "L.__reversed__() -- return a reverse iterator over the list"); PyDoc_STRVAR(append_doc, "L.append(object) -- append object to end"); *************** *** 2374,2377 **** --- 2379,2383 ---- static PyMethodDef list_methods[] = { + {"__reversed__",(PyCFunction)list_reversed, METH_NOARGS, reversed_doc}, {"append", (PyCFunction)listappend, METH_O, append_doc}, {"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc}, *************** *** 2405,2410 **** "list(sequence) -> new list initialized from sequence's items"); - static PyObject *list_iter(PyObject *seq); - static PyObject * list_subscript(PyListObject* self, PyObject* item) --- 2411,2414 ---- *************** *** 2760,2762 **** --- 2764,2856 ---- 0, /* tp_descr_get */ 0, /* tp_descr_set */ + }; + + /*********************** List Reverse Iterator **************************/ + + typedef struct { + PyObject_HEAD + long it_index; + PyListObject *it_seq; + } listreviterobject; + + PyTypeObject PyListRevIter_Type; + + static PyObject * + list_reversed(PyListObject *seq, PyObject *unused) + { + listreviterobject *it; + + it = PyObject_GC_New(listreviterobject, &PyListRevIter_Type); + if (it == NULL) + return NULL; + assert(PyList_Check(seq)); + it->it_index = PyList_GET_SIZE(seq) - 1; + Py_INCREF(seq); + it->it_seq = seq; + PyObject_GC_Track(it); + return (PyObject *)it; + } + + static void + listreviter_dealloc(listreviterobject *it) + { + PyObject_GC_UnTrack(it); + Py_XDECREF(it->it_seq); + PyObject_GC_Del(it); + } + + static int + listreviter_traverse(listreviterobject *it, visitproc visit, void *arg) + { + if (it->it_seq == NULL) + return 0; + return visit((PyObject *)it->it_seq, arg); + } + + static PyObject * + listreviter_next(listreviterobject *it) + { + PyObject *item = NULL; + + assert(PyList_Check(it->it_seq)); + if (it->it_index >= 0) { + assert(it->it_index < PyList_GET_SIZE(it->it_seq)); + item = PyList_GET_ITEM(it->it_seq, it->it_index); + it->it_index--; + Py_INCREF(item); + } + return item; + } + + PyTypeObject PyListRevIter_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "listreverseiterator", /* tp_name */ + sizeof(listreviterobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)listreviter_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + 0, /* tp_doc */ + (traverseproc)listreviter_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)listreviter_next, /* tp_iternext */ + 0, }; From rhettinger at users.sourceforge.net Sat Nov 8 05:24:40 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:24:46 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.886,1.887 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv3893/Misc Modified Files: NEWS Log Message: Convert heapq.py to a C implementation. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.886 retrieving revision 1.887 diff -C2 -d -r1.886 -r1.887 *** NEWS 6 Nov 2003 14:06:47 -0000 1.886 --- NEWS 8 Nov 2003 10:24:37 -0000 1.887 *************** *** 105,108 **** --- 105,110 ---- ------- + - heapq.py has been converted to C for improved performance + - traceback.format_exc has been added (similar to print_exc but it returns a string). From rhettinger at users.sourceforge.net Sat Nov 8 05:24:38 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:24:50 2003 Subject: [Python-checkins] python/dist/src/Lib heapq.py,1.19,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv3893/Lib Removed Files: heapq.py Log Message: Convert heapq.py to a C implementation. --- heapq.py DELETED --- From rhettinger at users.sourceforge.net Sat Nov 8 05:24:40 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:24:54 2003 Subject: [Python-checkins] python/dist/src/PC config.c,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1:/tmp/cvs-serv3893/PC Modified Files: config.c Log Message: Convert heapq.py to a C implementation. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** config.c 18 Apr 2003 10:51:14 -0000 1.39 --- config.c 8 Nov 2003 10:24:38 -0000 1.40 *************** *** 47,50 **** --- 47,51 ---- extern void init_random(void); extern void inititertools(void); + extern void initheapq(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ *************** *** 99,102 **** --- 100,104 ---- {"_hotshot", init_hotshot}, {"_random", init_random}, + {"heapq", initheapq}, {"itertools", inititertools}, From rhettinger at users.sourceforge.net Sat Nov 8 05:24:39 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:24:58 2003 Subject: [Python-checkins] python/dist/src/Lib/test test___all__.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv3893/Lib/test Modified Files: test___all__.py Log Message: Convert heapq.py to a C implementation. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** test___all__.py 16 Sep 2003 04:37:39 -0000 1.35 --- test___all__.py 8 Nov 2003 10:24:36 -0000 1.36 *************** *** 101,105 **** self.check_all("gopherlib") self.check_all("gzip") - self.check_all("heapq") self.check_all("htmllib") self.check_all("httplib") --- 101,104 ---- From rhettinger at users.sourceforge.net Sat Nov 8 05:24:41 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:25:03 2003 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1:/tmp/cvs-serv3893/PCbuild Modified Files: pythoncore.dsp Log Message: Convert heapq.py to a C implementation. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** pythoncore.dsp 31 Jul 2003 02:06:22 -0000 1.49 --- pythoncore.dsp 8 Nov 2003 10:24:38 -0000 1.50 *************** *** 299,302 **** --- 299,306 ---- # Begin Source File + SOURCE=..\Modules\heapqmodule.c + # End Source File + # Begin Source File + SOURCE=..\Modules\imageop.c # End Source File From rhettinger at users.sourceforge.net Sat Nov 8 05:24:40 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:25:07 2003 Subject: [Python-checkins] python/dist/src/Modules heapqmodule.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv3893/Modules Added Files: heapqmodule.c Log Message: Convert heapq.py to a C implementation. --- NEW FILE: heapqmodule.c --- (This appears to be a binary file; contents omitted.) From rhettinger at users.sourceforge.net Sat Nov 8 05:25:09 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 05:25:18 2003 Subject: [Python-checkins] python/dist/src setup.py,1.175,1.176 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv3893 Modified Files: setup.py Log Message: Convert heapq.py to a C implementation. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.175 retrieving revision 1.176 diff -C2 -d -r1.175 -r1.176 *** setup.py 24 Oct 2003 18:26:26 -0000 1.175 --- setup.py 8 Nov 2003 10:24:35 -0000 1.176 *************** *** 323,326 **** --- 323,328 ---- # fast iterator tools implemented in C exts.append( Extension("itertools", ["itertoolsmodule.c"]) ) + # heapq + exts.append( Extension("heapq", ["heapqmodule.c"]) ) # operator.add() and similar goodies exts.append( Extension('operator', ['operator.c']) ) From rhettinger at users.sourceforge.net Sat Nov 8 06:35:25 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 06:35:29 2003 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.163,2.164 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv17187 Modified Files: listobject.c Log Message: Minor code fixup. Make sure that len reflects the current list size. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.163 retrieving revision 2.164 diff -C2 -d -r2.163 -r2.164 *** listobject.c 7 Nov 2003 15:38:09 -0000 2.163 --- listobject.c 8 Nov 2003 11:35:22 -0000 2.164 *************** *** 1969,1972 **** --- 1969,1973 ---- if (keyfunc != NULL) { + len = PyList_GET_SIZE(self); for (i=0 ; i < len ; i++) { kvpair = PyList_GET_ITEM(self, i); From rhettinger at users.sourceforge.net Sat Nov 8 06:40:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 06:40:19 2003 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1:/tmp/cvs-serv17883 Modified Files: handlers.py Log Message: SF bug #835457: Small typo in logging documentation Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** handlers.py 27 Jun 2003 21:43:39 -0000 1.7 --- handlers.py 8 Nov 2003 11:40:03 -0000 1.8 *************** *** 97,101 **** Output the record to the file, catering for rollover as described ! in setRollover(). """ if self.maxBytes > 0: # are we rolling over? --- 97,101 ---- Output the record to the file, catering for rollover as described ! in doRollover(). """ if self.maxBytes > 0: # are we rolling over? From rhettinger at users.sourceforge.net Sat Nov 8 06:41:34 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 06:41:38 2003 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.7, 1.7.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1:/tmp/cvs-serv18171 Modified Files: Tag: release23-maint handlers.py Log Message: SF bug #835457: Small typo in logging documentation Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.7 retrieving revision 1.7.8.1 diff -C2 -d -r1.7 -r1.7.8.1 *** handlers.py 27 Jun 2003 21:43:39 -0000 1.7 --- handlers.py 8 Nov 2003 11:41:32 -0000 1.7.8.1 *************** *** 97,101 **** Output the record to the file, catering for rollover as described ! in setRollover(). """ if self.maxBytes > 0: # are we rolling over? --- 97,101 ---- Output the record to the file, catering for rollover as described ! in doRollover(). """ if self.maxBytes > 0: # are we rolling over? From rhettinger at users.sourceforge.net Sat Nov 8 06:58:46 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 06:58:50 2003 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.164,2.165 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv20227 Modified Files: listobject.c Log Message: Improve the reverse list iterator to free memory as soon as the iterator is exhausted. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.164 retrieving revision 2.165 diff -C2 -d -r2.164 -r2.165 *** listobject.c 8 Nov 2003 11:35:22 -0000 2.164 --- listobject.c 8 Nov 2003 11:58:44 -0000 2.165 *************** *** 2772,2776 **** PyObject_HEAD long it_index; ! PyListObject *it_seq; } listreviterobject; --- 2772,2776 ---- PyObject_HEAD long it_index; ! PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ } listreviterobject; *************** *** 2820,2823 **** --- 2820,2826 ---- it->it_index--; Py_INCREF(item); + } else if (it->it_seq != NULL) { + Py_DECREF(it->it_seq); + it->it_seq = NULL; } return item; From rhettinger at users.sourceforge.net Sat Nov 8 07:39:55 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 8 07:39:59 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_descrtut.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv27066 Modified Files: test_descrtut.py Log Message: Update test to handle list.__reversed__(). Index: test_descrtut.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_descrtut.py 29 Oct 2003 07:23:57 -0000 1.17 --- test_descrtut.py 8 Nov 2003 12:39:53 -0000 1.18 *************** *** 213,216 **** --- 213,217 ---- '__reduce_ex__', '__repr__', + '__reversed__', '__rmul__', '__setattr__', From akuchling at users.sourceforge.net Sat Nov 8 10:58:51 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Nov 8 10:58:56 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv24543 Modified Files: whatsnew24.tex Log Message: Add some recent changes Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** whatsnew24.tex 21 Oct 2003 12:48:23 -0000 1.5 --- whatsnew24.tex 8 Nov 2003 15:58:49 -0000 1.6 *************** *** 28,33 **** %====================================================================== ! % Large, PEP-level features and changes should be described here. --- 28,58 ---- %====================================================================== + \section{PEP 322: Reverse Iteration} ! A new built-in function, \function{reversed(seq)}, takes a sequence ! and returns an iterator that returns the elements of the sequence ! in reverse order. ! ! \begin{verbatim} ! >>> for i in reversed([1,2,3]): ! ... print i ! ... ! 3 ! 2 ! 1 ! \end{verbatim} ! ! Note that \function{reversed()} only accepts sequences, not arbitrary ! iterators. If you want to reverse an iterator, convert it to ! a list or tuple with \function{list()} or \function{tuple()}. ! ! \begin{verbatim} ! >>> input = open('/etc/passwd', 'r') ! >>> for line in reversed(list(input)): ! ... print line ! ... ! root:*:0:0:System Administrator:/var/root:/bin/tcsh ! ... ! \end{verbatim} *************** *** 77,80 **** --- 102,122 ---- \code{L.sort(reverse=True)}. + \item The list type gained a \method{sorted(iterable)} method that + returns the elements of the iterable as a sorted list. It also accepts + the \var{cmp}, \var{key}, and \var{reverse} keyword arguments, same as + the \method{sort()} method. An example usage: + + \begin{verbatim} + >>> L = [9,7,8,3,2,4,1,6,5] + >>> list.sorted(L) + [1, 2, 3, 4, 5, 6, 7, 8, 9] + >>> L + [9, 7, 8, 3, 2, 4, 1, 6, 5] + >>> + \end{verbatim} + + Note that the original list is unchanged; the list returned by + \method{sorted()} is a newly-created one. + \item The \function{zip()} built-in function and \function{itertools.izip()} now return an empty list instead of raising a \exception{TypeError} exception if called *************** *** 114,117 **** --- 156,162 ---- supports transparency, this makes it possible to use a transparent background. (Contributed by J\"org Lehmann.) + + \item The \module{heapq} module is no longer implemented in Python, + having been converted into C. \item The \module{random} module has a new method called \method{getrandbits(N)} From akuchling at users.sourceforge.net Sat Nov 8 11:05:41 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Nov 8 11:05:43 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv25488 Modified Files: whatsnew24.tex Log Message: Add 'see also' section pointing to the PEP Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** whatsnew24.tex 8 Nov 2003 15:58:49 -0000 1.6 --- whatsnew24.tex 8 Nov 2003 16:05:37 -0000 1.7 *************** *** 56,59 **** --- 56,64 ---- \end{verbatim} + \begin{seealso} + \seepep{322}{Reverse Iteration}{Written and implemented by Raymond Hettinger.} + + \end{seealso} + %====================================================================== From python at rcn.com Sat Nov 8 11:51:21 2003 From: python at rcn.com (Raymond Hettinger) Date: Sat Nov 8 11:51:35 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.5, 1.6 In-Reply-To: Message-ID: <000c01c3a618$8a61d880$1e23a044@oemcomputer> > ! A new built-in function, \function{reversed(seq)}, takes a sequence > ! and returns an iterator that returns the elements of the sequence > ! in reverse order. > ! > ! \begin{verbatim} > ! >>> for i in reversed([1,2,3]): > ! ... print i > ! ... > ! 3 > ! 2 > ! 1 > ! \end{verbatim} > ! > ! Note that \function{reversed()} only accepts sequences, not arbitrary > ! iterators. If you want to reverse an iterator, convert it to > ! a list or tuple with \function{list()} or \function{tuple()}. > ! > ! \begin{verbatim} > ! >>> input = open('/etc/passwd', 'r') > ! >>> for line in reversed(list(input)): > ! ... print line > ! ... > ! root:*:0:0:System Administrator:/var/root:/bin/tcsh > ! ... > ! \end{verbatim} It would be nice to present the new features in light of what makes them desirable. "for elem in reversed(mylist)" wins in readability, speed, and memory performance over "mylist.reverse(); for elem in mylist" or "for elem in mylist[::-1]". The readability win is predicated on the notion that half-open intervals are easier to understand as in the forwards direction. 'xrange(n//2, 0, -1)' is not as instantly understandable as reversed(xrange(1, n//2)). Using the newer form, anyone can quickly identify the first element, last element, and number of steps. > + \item The list type gained a \method{sorted(iterable)} method that > + returns the elements of the iterable as a sorted list. It also accepts > + the \var{cmp}, \var{key}, and \var{reverse} keyword arguments, same as > + the \method{sort()} method. An example usage: > + > + \begin{verbatim} > + >>> L = [9,7,8,3,2,4,1,6,5] > + >>> list.sorted(L) > + [1, 2, 3, 4, 5, 6, 7, 8, 9] > + >>> L > + [9, 7, 8, 3, 2, 4, 1, 6, 5] > + >>> > + \end{verbatim} > + > + Note that the original list is unchanged; the list returned by > + \method{sorted()} is a newly-created one. The keys points here are that 1) any iterable may be used as an input and 2) list.sorted() is an in-line expression which allows it to be used in function arguments, lambda expressions, list comprehensions, and for-loop specifications: genTodoList(today, list.sorted(tasks, key=prioritize)) getlargest = lambda x: list.sorted(x)[-1] x = [myfunc(v) for v in list.sorted(mydict.itervalues())] for key in list.sorted(mydict): . . . > + \item The \module{heapq} module is no longer implemented in Python, > + having been converted into C. And it now runs about 10 times faster which makes it viable for industrial strength applications. > \item The \module{random} module has a new method called > \method{getrandbits(N)} Formerly, there was no O(n) method for generating large random numbers. The new method supports random.randrange() that arbitrarily large numbers can be generated (important for public key cryptography and prime number generation). From bcannon at users.sourceforge.net Sat Nov 8 23:15:32 2003 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Nov 8 23:15:36 2003 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv11045/Doc/api Modified Files: concrete.tex Log Message: Document Py_RETURN_NONE. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** concrete.tex 26 Oct 2003 17:20:07 -0000 1.30 --- concrete.tex 9 Nov 2003 04:15:30 -0000 1.31 *************** *** 98,101 **** --- 98,105 ---- \end{cvardesc} + \begin{csimplemacrodesc}{Py_RETURN_NONE} + Properly handles returning \cvar{Py_None} from within a C function. + \end{csimplemacrodesc} + \section{Numeric Objects \label{numericObjects}} From aleax at users.sourceforge.net Sun Nov 9 11:31:20 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:31:30 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libcgi.tex,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv10344 Modified Files: libcgi.tex Log Message: Avoid giving advice that's bad for security, as per SF bug #823515 (same as commit of Sun Nov 2 to the release23-maint branch) Index: libcgi.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgi.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** libcgi.tex 12 Aug 2003 00:01:14 -0000 1.41 --- libcgi.tex 9 Nov 2003 16:31:18 -0000 1.42 *************** *** 599,603 **** \item When reading or writing external files, make sure they can be read ! or written by every user on the system. \item Don't try to give a CGI script a set-uid mode. This doesn't work on --- 599,605 ---- \item When reading or writing external files, make sure they can be read ! or written by the userid under which your CGI script will be running: ! this is typically the userid under which the web server is running, or some ! explicitly specified userid for a web server's \samp{suexec} feature. \item Don't try to give a CGI script a set-uid mode. This doesn't work on From aleax at users.sourceforge.net Sun Nov 9 11:32:56 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:32:59 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libpyclbr.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv10557 Modified Files: libpyclbr.tex Log Message: Add docs for readmodule_ex and its function-descriptors, fixing sf bug#812818. (same as commit of Sun Nov 2 to the release23-maint branch) Index: libpyclbr.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyclbr.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libpyclbr.tex 29 Jun 1999 15:43:02 -0000 1.3 --- libpyclbr.tex 9 Nov 2003 16:32:54 -0000 1.4 *************** *** 9,16 **** The \module{pyclbr} can be used to determine some limited information ! about the classes and methods defined in a module. The information provided is sufficient to implement a traditional three-pane class browser. The information is extracted from the source code rather ! than from an imported module, so this module is safe to use with untrusted source code. This restriction makes it impossible to use this module with modules not implemented in Python, including many --- 9,17 ---- The \module{pyclbr} can be used to determine some limited information ! about the classes, methods and top-level functions ! defined in a module. The information provided is sufficient to implement a traditional three-pane class browser. The information is extracted from the source code rather ! than by importing the module, so this module is safe to use with untrusted source code. This restriction makes it impossible to use this module with modules not implemented in Python, including many *************** *** 28,36 **** \end{funcdesc} \subsection{Class Descriptor Objects \label{pyclbr-class-objects}} The class descriptor objects used as values in the dictionary returned ! by \function{readmodule()} provide the following data members: --- 29,48 ---- \end{funcdesc} + \begin{funcdesc}{readmodule_ex}{module\optional{, path}} + % The 'inpackage' parameter appears to be for internal use only.... + Like \function{readmodule()}, but the returned dictionary, in addition + to mapping class names to class descriptor objects, also maps + top-level function names to function descriptor objects. Moreover, if + the module being read is a package, the key \code{'__path__'} in the + returned dictionary has as its value a list which contains the package + search path. + \end{funcdesc} + \subsection{Class Descriptor Objects \label{pyclbr-class-objects}} The class descriptor objects used as values in the dictionary returned ! by \function{readmodule()} and \function{readmodule_ex()} ! provide the following data members: *************** *** 57,65 **** \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the class statement defining the class. \end{memberdesc} \begin{memberdesc}[class descriptor]{lineno} ! The line number of the class statement within the file named by \member{file}. \end{memberdesc} --- 69,102 ---- \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the \code(class} statement defining the class. \end{memberdesc} \begin{memberdesc}[class descriptor]{lineno} ! The line number of the \code{class} statement within the file named by \member{file}. \end{memberdesc} + + \subsection{Function Descriptor Objects \label{pyclbr-function-objects}} + + The function descriptor objects used as values in the dictionary returned + by \function{readmodule_ex()} provide the following data members: + + + \begin{memberdesc}[function descriptor]{module} + The name of the module defining the function described by the function + descriptor. + \end{memberdesc} + + \begin{memberdesc}[function descriptor]{name} + The name of the function. + \end{memberdesc} + + \begin{memberdesc}[function descriptor]{file} + Name of the file containing the \code{def} statement defining the function. + \end{memberdesc} + + \begin{memberdesc}[function descriptor]{lineno} + The line number of the \code{def} statement within the file named by + \member{file}. + \end{memberdesc} + From aleax at users.sourceforge.net Sun Nov 9 11:33:58 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:34:29 2003 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1:/tmp/cvs-serv10850 Modified Files: ref5.tex Log Message: clarified (in the 5.14 summary) that tests and comparisons all chain, added a specific \ref to 5.9 in lieu of previous vague "see above". (same as commit of Sun Nov 2 to the release23-maint branch) Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** ref5.tex 19 Oct 2003 07:32:24 -0000 1.78 --- ref5.tex 9 Nov 2003 16:33:56 -0000 1.79 *************** *** 1069,1075 **** Operators in the same box have the same precedence. Unless the syntax is explicitly given, operators are binary. Operators in the same box ! group left to right (except for comparisons, which chain from left to ! right --- see above, and exponentiation, which groups from right to ! left). \begin{tableii}{c|l}{textrm}{Operator}{Description} --- 1069,1075 ---- Operators in the same box have the same precedence. Unless the syntax is explicitly given, operators are binary. Operators in the same box ! group left to right (except for comparisons, including tests, which all ! have the same precedence and chain from left to right --- see section ! \ref{comparisons} -- and exponentiation, which groups from right to left). \begin{tableii}{c|l}{textrm}{Operator}{Description} From aleax at users.sourceforge.net Sun Nov 9 11:38:42 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:38:44 2003 Subject: [Python-checkins] python/dist/src/Include object.h,2.124,2.125 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv11701 Modified Files: object.h Log Message: fixed buggy comment as per SF bug #827856 (same as commit of Sun Nov 2 to the release23-maint branch) Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.124 retrieving revision 2.125 diff -C2 -d -r2.124 -r2.125 *** object.h 19 Oct 2003 22:58:11 -0000 2.124 --- object.h 9 Nov 2003 16:38:39 -0000 2.125 *************** *** 699,707 **** Functions that create an object set the reference count to 1; such new objects must be stored somewhere or destroyed again with Py_DECREF(). ! Functions that 'store' objects such as PyTuple_SetItem() and ! PyDict_SetItemString() don't increment the reference count of the object, since the most frequent use is to store a fresh object. Functions that 'retrieve' ! objects such as PyTuple_GetItem() and PyDict_GetItemString() also don't increment the reference count, since most frequently the object is only looked at --- 699,707 ---- Functions that create an object set the reference count to 1; such new objects must be stored somewhere or destroyed again with Py_DECREF(). ! Some functions that 'store' objects, such as PyTuple_SetItem() and ! PyList_SetItem(), don't increment the reference count of the object, since the most frequent use is to store a fresh object. Functions that 'retrieve' ! objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also don't increment the reference count, since most frequently the object is only looked at *************** *** 709,718 **** must call Py_INCREF() explicitly. ! NOTE: functions that 'consume' a reference count like ! PyList_SetItemString() even consume the reference if the object wasn't ! stored, to simplify error handling. It seems attractive to make other functions that take an object as ! argument consume a reference count; however this may quickly get confusing (even the current practice is already confusing). Consider it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at --- 709,718 ---- must call Py_INCREF() explicitly. ! NOTE: functions that 'consume' a reference count, like ! PyList_SetItem(), consume the reference even if the object wasn't ! successfully stored, to simplify error handling. It seems attractive to make other functions that take an object as ! argument consume a reference count; however, this may quickly get confusing (even the current practice is already confusing). Consider it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at From aleax at users.sourceforge.net Sun Nov 9 11:41:40 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:41:43 2003 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv12432 Modified Files: httplib.py Log Message: fixed obvious bug in _send_header as per SF bug #831271 (same as commit of Sun Nov 2 to the release23-maint branch) Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** httplib.py 27 Oct 2003 14:07:53 -0000 1.80 --- httplib.py 9 Nov 2003 16:41:38 -0000 1.81 *************** *** 728,733 **** # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. ! if 'Host' in (headers ! or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: --- 728,732 ---- # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. ! if 'host' in [k.lower() for k in headers]: self.putrequest(method, url, skip_host=1) else: From aleax at users.sourceforge.net Sun Nov 9 11:44:11 2003 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Nov 9 11:44:15 2003 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv12851 Modified Files: tempfile.py Log Message: fixed wrong error checking on fcntl call as per SF bug # 821896 (same as commit of Sun Nov 2 to the release23-maint branch) Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** tempfile.py 12 Oct 2003 17:37:01 -0000 1.57 --- tempfile.py 9 Nov 2003 16:44:09 -0000 1.58 *************** *** 48,53 **** else: def _set_cloexec(fd): ! flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! if flags >= 0: # flags read successfully, modify flags |= _fcntl.FD_CLOEXEC --- 48,54 ---- else: def _set_cloexec(fd): ! try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) ! except IOError: pass ! else: # flags read successfully, modify flags |= _fcntl.FD_CLOEXEC From gvanrossum at users.sourceforge.net Sun Nov 9 21:16:39 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 9 21:16:43 2003 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv14329 Modified Files: tempfile.py Log Message: mktemp() shouldn't rely on os.path.exists(), which can return False if the file is a symlink. Instead, use os.lstat directly, if it exists; fall back on os.stat or the built-in open. Thanks to Iustin Pop. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** tempfile.py 9 Nov 2003 16:44:09 -0000 1.58 --- tempfile.py 10 Nov 2003 02:16:36 -0000 1.59 *************** *** 85,88 **** --- 85,110 ---- _once_lock = _allocate_lock() + if hasattr(_os, "lstat"): + _stat = _os.lstat + elif hasattr(_os, "stat"): + _stat = _os.stat + else: + # Fallback. All we need is something that raises os.error if the + # file doesn't exist. + def _stat(fn): + try: + f = open(fn) + except IOError: + raise _os.error + f.close() + + def _exists(fn): + try: + _stat(fn) + except _os.error: + return False + else: + return True + class _RandomNameSequence: """An instance of _RandomNameSequence generates an endless *************** *** 340,344 **** name = names.next() file = _os.path.join(dir, prefix + name + suffix) ! if not _os.path.exists(file): return file --- 362,366 ---- name = names.next() file = _os.path.join(dir, prefix + name + suffix) ! if not _exists(file): return file From gvanrossum at users.sourceforge.net Sun Nov 9 21:27:21 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 9 21:27:25 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.887, 1.888 ACKS, 1.252, 1.253 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv15783 Modified Files: NEWS ACKS Log Message: Plug tempfile.mktemp() hole (Iustin Pop). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.887 retrieving revision 1.888 diff -C2 -d -r1.887 -r1.888 *** NEWS 8 Nov 2003 10:24:37 -0000 1.887 --- NEWS 10 Nov 2003 02:27:19 -0000 1.888 *************** *** 105,108 **** --- 105,111 ---- ------- + - Plugged a minor hole in tempfile.mktemp() due to the use of + os.path.exists(), switched to using os.lstat() directly if possible. + - heapq.py has been converted to C for improved performance Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.252 retrieving revision 1.253 diff -C2 -d -r1.252 -r1.253 *** ACKS 31 Oct 2003 12:52:35 -0000 1.252 --- ACKS 10 Nov 2003 02:27:19 -0000 1.253 *************** *** 436,439 **** --- 436,440 ---- François Pinard Michael Piotrowski + Iustin Pop John Popplewell Amrit Prem From loewis at users.sourceforge.net Mon Nov 10 01:35:38 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:35:44 2003 Subject: [Python-checkins] python/dist/src configure, 1.429, 1.430 configure.in, 1.439, 1.440 pyconfig.h.in, 1.86, 1.87 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv15661 Modified Files: configure configure.in pyconfig.h.in Log Message: Patch #839038: Add getsid(2). Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.429 retrieving revision 1.430 diff -C2 -d -r1.429 -r1.430 *** configure 31 Oct 2003 15:42:07 -0000 1.429 --- configure 10 Nov 2003 06:35:36 -0000 1.430 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.438 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.439 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. *************** *** 13097,13104 **** for ac_func in alarm chown clock confstr ctermid execv \ fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ ! getpriority getpwent getwd \ kill killpg lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ --- 13097,13105 ---- + for ac_func in alarm chown clock confstr ctermid execv \ fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ ! getpriority getpwent getsid getwd \ kill killpg lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.439 retrieving revision 1.440 diff -C2 -d -r1.439 -r1.440 *** configure.in 31 Oct 2003 15:42:07 -0000 1.439 --- configure.in 10 Nov 2003 06:35:36 -0000 1.440 *************** *** 2075,2079 **** fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ ! getpriority getpwent getwd \ kill killpg lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ --- 2075,2079 ---- fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ ! getpriority getpwent getsid getwd \ kill killpg lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** pyconfig.h.in 25 Sep 2003 14:50:29 -0000 1.86 --- pyconfig.h.in 10 Nov 2003 06:35:36 -0000 1.87 *************** *** 127,130 **** --- 127,133 ---- #undef HAVE_FSTATVFS + /* Define if you have the 'fsync' function. */ + #undef HAVE_FSYNC + /* Define to 1 if you have the `ftell64' function. */ #undef HAVE_FTELL64 *************** *** 199,202 **** --- 202,208 ---- #undef HAVE_GETPWENT + /* Define to 1 if you have the `getsid' function. */ + #undef HAVE_GETSID + /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY *************** *** 486,492 **** #undef HAVE_SYMLINK - /* Define if you have the 'fsync' function. */ - #undef HAVE_FSYNC - /* Define to 1 if you have the `sysconf' function. */ #undef HAVE_SYSCONF --- 492,495 ---- *************** *** 617,621 **** /* Define if you have a useable wchar_t type defined in wchar.h; useable means ! wchar_t must be 16-bit unsigned type. (see Include/unicodeobject.h). */ #undef HAVE_USABLE_WCHAR_T --- 620,625 ---- /* Define if you have a useable wchar_t type defined in wchar.h; useable means ! wchar_t must be an unsigned type with at least 16 bits. (see ! Include/unicodeobject.h). */ #undef HAVE_USABLE_WCHAR_T From loewis at users.sourceforge.net Mon Nov 10 01:35:39 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:35:47 2003 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.307, 2.308 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv15661/Modules Modified Files: posixmodule.c Log Message: Patch #839038: Add getsid(2). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.307 retrieving revision 2.308 diff -C2 -d -r2.307 -r2.308 *** posixmodule.c 31 Oct 2003 10:01:53 -0000 2.307 --- posixmodule.c 10 Nov 2003 06:35:36 -0000 2.308 *************** *** 4756,4759 **** --- 4756,4778 ---- + #ifdef HAVE_GETSID + PyDoc_STRVAR(posix_getsid__doc__, + "getsid(pid) -> sid\n\n\ + Call the system call getsid()."); + + static PyObject * + posix_getsid(PyObject *self, PyObject *args) + { + int pid, sid; + if (!PyArg_ParseTuple(args, "i:getsid", &pid)) + return NULL; + sid = getsid(pid); + if (sid < 0) + return posix_error(); + return PyInt_FromLong((long)sid); + } + #endif /* HAVE_GETSID */ + + #ifdef HAVE_SETSID PyDoc_STRVAR(posix_setsid__doc__, *************** *** 7021,7024 **** --- 7040,7046 ---- {"waitpid", posix_waitpid, METH_VARARGS, posix_waitpid__doc__}, #endif /* HAVE_WAITPID */ + #ifdef HAVE_GETSID + {"getsid", posix_getsid, METH_VARARGS, posix_getsid__doc__}, + #endif /* HAVE_GETSID */ #ifdef HAVE_SETSID {"setsid", posix_setsid, METH_NOARGS, posix_setsid__doc__}, From loewis at users.sourceforge.net Mon Nov 10 01:35:38 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:35:49 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.130,1.131 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv15661/Doc/lib Modified Files: libos.tex Log Message: Patch #839038: Add getsid(2). Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -d -r1.130 -r1.131 *** libos.tex 10 Sep 2003 00:11:28 -0000 1.130 --- libos.tex 10 Nov 2003 06:35:36 -0000 1.131 *************** *** 255,258 **** --- 255,264 ---- \end{funcdesc} + \begin{funcdesc}{getsid}{pid} + Calls the system call \cfunction{getsid()}. See the \UNIX{} manual + for the semantics. + Availability: \UNIX. + \end{funcdesc} + \begin{funcdesc}{setsid}{} Calls the system call \cfunction{setsid()}. See the \UNIX{} manual From loewis at users.sourceforge.net Mon Nov 10 01:44:46 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:44:48 2003 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv16560/Lib Modified Files: imaplib.py Log Message: Patch #798297: Add IMAP THREAD command. Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** imaplib.py 29 Jun 2003 04:21:43 -0000 1.64 --- imaplib.py 10 Nov 2003 06:44:44 -0000 1.65 *************** *** 70,73 **** --- 70,74 ---- 'STORE': ('SELECTED',), 'SUBSCRIBE': ('AUTH', 'SELECTED'), + 'THREAD': ('SELECTED',), 'UID': ('SELECTED',), 'UNSUBSCRIBE': ('AUTH', 'SELECTED'), *************** *** 678,681 **** --- 679,692 ---- """ return self._simple_command('SUBSCRIBE', mailbox) + + + def thread(self, threading_algorithm, charset, *search_criteria): + """IMAPrev1 extension THREAD command. + + (type, [data]) = .thread(threading_alogrithm, charset, search_criteria, ...) + """ + name = 'THREAD' + typ, dat = self._simple_command(name, threading_algorithm, charset, *search_criteria) + return self._untagged_response(typ, dat, name) From loewis at users.sourceforge.net Mon Nov 10 01:44:46 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:44:50 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16560/Doc/lib Modified Files: libimaplib.tex Log Message: Patch #798297: Add IMAP THREAD command. Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** libimaplib.tex 27 Mar 2003 16:59:38 -0000 1.24 --- libimaplib.tex 10 Nov 2003 06:44:43 -0000 1.25 *************** *** 356,359 **** --- 356,381 ---- \end{methoddesc} + \begin{methoddesc}{thread}{threading_algorithm, charset, search_criterion\optional{, ...}} + The \code{thread} command is a variant of \code{search} with threading semantics for + the results. Returned data contains a space + separated list of thread members. + + Thread members consist of zero or more messages numbers, delimited by spaces, + indicating successive parent and child. + + Thread has two arguments before the \var{search_criterion} + argument(s); a \var{threading_algorithm}, and the searching \var{charset}. + Note that unlike \code{search}, the searching \var{charset} argument is mandatory. + There is also a \code{uid thread} command which corresponds to \code{thread} the way + that \code{uid search} corresponds to \code{search}. + The \code{thread} command first searches the mailbox for messages that + match the given searching criteria using the charset argument for + the interpretation of strings in the searching criteria. It thren + returns the matching messages threaded according to the specified + threading algorithm. + + This is an \samp{IMAP4rev1} extension command. \versionadded{2.4} + \end{methoddesc} + \begin{methoddesc}{uid}{command, arg\optional{, ...}} Execute command args with messages identified by UID, rather than From loewis at users.sourceforge.net Mon Nov 10 01:44:46 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:44:52 2003 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.253, 1.254 NEWS, 1.888, 1.889 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv16560/Misc Modified Files: ACKS NEWS Log Message: Patch #798297: Add IMAP THREAD command. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.253 retrieving revision 1.254 diff -C2 -d -r1.253 -r1.254 *** ACKS 10 Nov 2003 02:27:19 -0000 1.253 --- ACKS 10 Nov 2003 06:44:44 -0000 1.254 *************** *** 138,141 **** --- 138,142 ---- Roger Dev Toby Dickenson + Yves Dionne Daniel Dittmar Walter Dörwald Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.888 retrieving revision 1.889 diff -C2 -d -r1.888 -r1.889 *** NEWS 10 Nov 2003 02:27:19 -0000 1.888 --- NEWS 10 Nov 2003 06:44:44 -0000 1.889 *************** *** 58,61 **** --- 58,63 ---- ----------------- + - os.getsid was added. + - The pwd module incorrectly advertised its struct type as struct_pwent; this has been renamed to struct_passwd. (The old name *************** *** 104,107 **** --- 106,111 ---- Library ------- + + - imaplib.IMAP4.thread was added. - Plugged a minor hole in tempfile.mktemp() due to the use of From loewis at users.sourceforge.net Mon Nov 10 01:46:18 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Nov 10 01:46:21 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.131,1.132 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv17186/Doc/lib Modified Files: libos.tex Log Message: Mention that getsid is new in 2.4. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** libos.tex 10 Nov 2003 06:35:36 -0000 1.131 --- libos.tex 10 Nov 2003 06:46:15 -0000 1.132 *************** *** 258,262 **** Calls the system call \cfunction{getsid()}. See the \UNIX{} manual for the semantics. ! Availability: \UNIX. \end{funcdesc} --- 258,262 ---- Calls the system call \cfunction{getsid()}. See the \UNIX{} manual for the semantics. ! Availability: \UNIX. \versionadded{2.4} \end{funcdesc} From fdrake at users.sourceforge.net Mon Nov 10 09:43:01 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Nov 10 09:43:04 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfileinput.tex, 1.6, 1.6.36.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv29352 Modified Files: Tag: release23-maint libfileinput.tex Log Message: add missing "if" Index: libfileinput.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfileinput.tex,v retrieving revision 1.6 retrieving revision 1.6.36.1 diff -C2 -d -r1.6 -r1.6.36.1 *** libfileinput.tex 9 May 2001 03:24:55 -0000 1.6 --- libfileinput.tex 10 Nov 2003 14:42:58 -0000 1.6.36.1 *************** *** 78,82 **** \begin{funcdesc}{isfirstline}{} ! Returns true the line just read is the first line of its file, otherwise returns false. \end{funcdesc} --- 78,82 ---- \begin{funcdesc}{isfirstline}{} ! Returns true if the line just read is the first line of its file, otherwise returns false. \end{funcdesc} From fdrake at users.sourceforge.net Mon Nov 10 09:43:18 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Nov 10 09:43:21 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfileinput.tex,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv29465 Modified Files: libfileinput.tex Log Message: add missing "if" Index: libfileinput.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfileinput.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libfileinput.tex 9 May 2001 03:24:55 -0000 1.6 --- libfileinput.tex 10 Nov 2003 14:43:16 -0000 1.7 *************** *** 78,82 **** \begin{funcdesc}{isfirstline}{} ! Returns true the line just read is the first line of its file, otherwise returns false. \end{funcdesc} --- 78,82 ---- \begin{funcdesc}{isfirstline}{} ! Returns true if the line just read is the first line of its file, otherwise returns false. \end{funcdesc} From fdrake at users.sourceforge.net Mon Nov 10 09:48:51 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Nov 10 09:48:55 2003 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv30597 Modified Files: concrete.tex Log Message: fix use of undefined markup Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** concrete.tex 9 Nov 2003 04:15:30 -0000 1.31 --- concrete.tex 10 Nov 2003 14:48:48 -0000 1.32 *************** *** 99,103 **** \begin{csimplemacrodesc}{Py_RETURN_NONE} ! Properly handles returning \cvar{Py_None} from within a C function. \end{csimplemacrodesc} --- 99,103 ---- \begin{csimplemacrodesc}{Py_RETURN_NONE} ! Properly handles returning \cdata{Py_None} from within a C function. \end{csimplemacrodesc} From fdrake at users.sourceforge.net Mon Nov 10 09:50:56 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Nov 10 09:51:00 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libpyclbr.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv31047 Modified Files: libpyclbr.tex Log Message: fix typo in markup Index: libpyclbr.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyclbr.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libpyclbr.tex 9 Nov 2003 16:32:54 -0000 1.4 --- libpyclbr.tex 10 Nov 2003 14:50:54 -0000 1.5 *************** *** 69,73 **** \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the \code(class} statement defining the class. \end{memberdesc} --- 69,73 ---- \begin{memberdesc}[class descriptor]{file} ! Name of the file containing the \code{class} statement defining the class. \end{memberdesc} From tamapat at zwallet.com Wed Nov 12 02:38:07 2003 From: tamapat at zwallet.com (PAT TAMA) Date: Mon Nov 10 20:16:54 2003 Subject: [Python-checkins] python-checkins, SOLICITATION FOR YOUR PARTNERSHIP Message-ID: <0HO5000G1PRKBM@florencia.telecaqueta.com.co> >From Mr. PATRICK TAMA. Attention I am Mr. Patrick Tama and my sister is Miss Rose Tama, we are the children of Late Chief Paul Tama from Sierra Leone. I am writing you in absolute confidence primarily to seek your assistance to transfer our cash of Ten Million Dollars ($10,000.000.00) now in the custody of a private Security trust firm In Europe,the money is in trunk boxes deposited and declared as Family valuables by my late father as a matter of fact the company does not know the content as money, although my father made them to understand that the boxes belongs to his foreign partner. Source of the Funds: My late father Chief Paul Tama, a native of Mende District in the Northern province of Sierra Leone, was the General Manager of Sierra Leone mining coporation (S.L.M.C.) Freetown. According to my father, this money was the income accrued from Mining Corporation's over draft and minor sales. Before the peak of the civil war between the rebels forces of Major Paul Koroma and the combined forces of ECOMOG peace keeping operation that almost destroyed my country, following the forceful removal from power of the civilian elected President Ahmed Tejan Kabbah by the rebels. My father had already made arrangement for his family(talking about)my mother, my little sister and myself to be evacuated to The Netherlands with the CERTIFICATE OF DEPOSIT he made with a security firm in Europe through the aid of U.N evacuation team. During the war in my country, and following the indiscriminate Looting of Public and Government properties by the rebel forces, the Sierra Leone mining corporation was one of the targets looted and it was destroyed. My father including other top Government functionaries were attacked and killed by the rebels in November 2000 because of his relationship with the civilian Government of Ahmed Tejan Kabbah. As a result of my father's death and with the news of my uncle's Involvement in the air crash in January, it dashed our hopes of survival. The untimely deaths caused my mother's heart failure and other related complications which later lead to her death in the hospital after we had spent a lot of money on her early this year. Now my 18 year old sister and I are alone in this country suffering without any care or help. Without any relation, we are now like refugees and orphans. Our only hope now is in you and the boxes deposited in the Security Firm, to this effect, I humbly solicit your assistance in the Following ways. 1. To assist me claim this boxes from the security Firm as our beneficiary. 2. To transfer this money (USD$10M) in your name to your country. 3. To make a good arrangement for a joint business investment on our Behalf in your country and you, our Adviser/ Manager For your assistance, I have agreed with my younger sister that 20% of the total amount will be for your effort and another 10 % to cover all the expenses that may be incurred during the business transaction, Lastly, I urge you to keep this transaction strictly confidential as no one knows our where about. Please as you show your willingness; Forward to us your full name, address and Tel/ Fax numbers, company name and address (if any) to me via my private email address as indicated below, this is for security reasons as I will only be accessing my private email. Earnestly awaiting your response. Thanks. May God bless you as you assist us Mr. Patrick Tama From nascheme at users.sourceforge.net Tue Nov 11 14:39:19 2003 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Tue Nov 11 15:05:09 2003 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.75,1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv9373/Lib Modified Files: rfc822.py Log Message: Make Message.__str__ more efficient. Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** rfc822.py 6 Nov 2003 14:06:47 -0000 1.75 --- rfc822.py 11 Nov 2003 19:39:17 -0000 1.76 *************** *** 461,468 **** def __str__(self): ! str = '' ! for hdr in self.headers: ! str = str + hdr ! return str --- 461,465 ---- def __str__(self): ! return ''.join(self.headers) From rhettinger at users.sourceforge.net Wed Nov 12 09:32:28 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 09:32:32 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv16547/Lib/test Modified Files: test_itertools.py Log Message: Improve the implementation of itertools.tee(). Formerly, underlying queue was implemented in terms of two lists. The new queue is a series of singly-linked fixed length lists. The new implementation runs much faster, supports multi-way tees, and allows tees of tees without additional memory costs. The root ideas for this structure were contributed by Andrew Koenig and Guido van Rossum. Index: test_itertools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_itertools.py 26 Oct 2003 15:34:50 -0000 1.24 --- test_itertools.py 12 Nov 2003 14:32:25 -0000 1.25 *************** *** 201,205 **** def test_tee(self): ! n = 100 def irange(n): for i in xrange(n): --- 201,205 ---- def test_tee(self): ! n = 200 def irange(n): for i in xrange(n): *************** *** 218,231 **** a, b = tee(irange(n)) # test dealloc of leading iterator ! self.assertEqual(a.next(), 0) ! self.assertEqual(a.next(), 1) del a self.assertEqual(list(b), range(n)) a, b = tee(irange(n)) # test dealloc of trailing iterator ! self.assertEqual(a.next(), 0) ! self.assertEqual(a.next(), 1) del b ! self.assertEqual(list(a), range(2, n)) for j in xrange(5): # test randomly interleaved --- 218,231 ---- a, b = tee(irange(n)) # test dealloc of leading iterator ! for i in xrange(100): ! self.assertEqual(a.next(), i) del a self.assertEqual(list(b), range(n)) a, b = tee(irange(n)) # test dealloc of trailing iterator ! for i in xrange(100): ! self.assertEqual(a.next(), i) del b ! self.assertEqual(list(a), range(100, n)) for j in xrange(5): # test randomly interleaved *************** *** 240,258 **** self.assertEqual(lists[1], range(n)) self.assertRaises(TypeError, tee) self.assertRaises(TypeError, tee, 3) self.assertRaises(TypeError, tee, [1,2], 'x') ! try: ! class A(tee): pass ! except TypeError: ! pass ! else: ! self.fail("tee constructor should not be subclassable") - # tee_iterator should not be instantiable - a, b = tee(xrange(10)) - self.assertRaises(TypeError, type(a)) - self.assert_(a is iter(a)) # tee_iterator should support __iter__ def test_StopIteration(self): --- 240,268 ---- self.assertEqual(lists[1], range(n)) + # test argument format checking self.assertRaises(TypeError, tee) self.assertRaises(TypeError, tee, 3) self.assertRaises(TypeError, tee, [1,2], 'x') + self.assertRaises(TypeError, tee, [1,2], 3, 'x') ! # tee object should be instantiable ! a, b = tee('abc') ! c = type(a)('def') ! self.assertEqual(list(c), list('def')) ! ! # test long-lagged and multi-way split ! a, b, c = tee(xrange(2000), 3) ! for i in xrange(100): ! self.assertEqual(a.next(), i) ! self.assertEqual(list(b), range(2000)) ! self.assertEqual([c.next(), c.next()], range(2)) ! self.assertEqual(list(a), range(100,2000)) ! self.assertEqual(list(c), range(2,2000)) ! ! # tee pass-through to copyable iterator ! a, b = tee('abc') ! c, d = tee(a) ! self.assert_(a is c) def test_StopIteration(self): *************** *** 318,328 **** self.makecycle(starmap(lambda *t: t, [(a,a)]*2), a) - def test_tee(self): - a = [] - p, q = t = tee([a]*2) - a += [a, p, q, t] - p.next() - del a, p, q, t - def R(seqn): 'Regular generator' --- 328,331 ---- *************** *** 627,631 **** ... "s -> (s0,s1), (s1,s2), (s2, s3), ..." ... a, b = tee(iterable) ! ... return izip(a, islice(b, 1, None)) This is not part of the examples but it tests to make sure the definitions --- 630,638 ---- ... "s -> (s0,s1), (s1,s2), (s2, s3), ..." ... a, b = tee(iterable) ! ... try: ! ... b.next() ! ... except StopIteration: ! ... pass ! ... return izip(a, b) This is not part of the examples but it tests to make sure the definitions From rhettinger at users.sourceforge.net Wed Nov 12 09:32:28 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 09:32:35 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16547/Doc/lib Modified Files: libitertools.tex Log Message: Improve the implementation of itertools.tee(). Formerly, underlying queue was implemented in terms of two lists. The new queue is a series of singly-linked fixed length lists. The new implementation runs much faster, supports multi-way tees, and allows tees of tees without additional memory costs. The root ideas for this structure were contributed by Andrew Koenig and Guido van Rossum. Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** libitertools.tex 26 Oct 2003 15:34:50 -0000 1.21 --- libitertools.tex 12 Nov 2003 14:32:25 -0000 1.22 *************** *** 282,288 **** \end{funcdesc} ! \begin{funcdesc}{tee}{iterable} ! Return two independent iterators from a single iterable. ! Equivalent to: \begin{verbatim} --- 282,288 ---- \end{funcdesc} ! \begin{funcdesc}{tee}{iterable\optional{, n=2}} ! Return \var{n} independent iterators from a single iterable. ! The case where \var{n} is two is equivalent to: \begin{verbatim} *************** *** 300,303 **** --- 300,307 ---- \end{verbatim} + Note, once \function{tee()} has made a split, the original \var{iterable} + should not be used anywhere else; otherwise, the \var{iterable} could get + advanced without the tee objects being informed. + Note, this member of the toolkit may require significant auxiliary storage (depending on how much temporary data needs to be stored). *************** *** 409,413 **** "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) ! return izip(a, islice(b, 1, None)) \end{verbatim} --- 413,421 ---- "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) ! try: ! b.next() ! except StopIteration: ! pass ! return izip(a, b) \end{verbatim} From rhettinger at users.sourceforge.net Wed Nov 12 09:32:28 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 09:32:38 2003 Subject: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv16547/Modules Modified Files: itertoolsmodule.c Log Message: Improve the implementation of itertools.tee(). Formerly, underlying queue was implemented in terms of two lists. The new queue is a series of singly-linked fixed length lists. The new implementation runs much faster, supports multi-way tees, and allows tees of tees without additional memory costs. The root ideas for this structure were contributed by Andrew Koenig and Guido van Rossum. Index: itertoolsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** itertoolsmodule.c 28 Oct 2003 07:32:28 -0000 1.25 --- itertoolsmodule.c 12 Nov 2003 14:32:26 -0000 1.26 *************** *** 8,127 **** */ ! /* independent iterator object supporting the tee object ***************/ ! ! /* The tee object maintains a queue of data seen by the leading iterator ! but not seen by the trailing iterator. When the leading iterator ! gets data from PyIter_Next() it appends a copy to the inbasket stack. ! When the trailing iterator needs data, it is popped from the outbasket ! stack. If the outbasket stack is empty, then it is filled from the ! inbasket (i.e. the queue is implemented using two stacks so that only ! O(n) operations like append() and pop() are used to access data and ! calls to reverse() never move any data element more than once). ! If one of the independent iterators gets deallocated, it sets tee's ! save_mode to zero so that future calls to PyIter_Next() stop getting ! saved to the queue (because there is no longer a second iterator that ! may need the data). */ typedef struct { PyObject_HEAD PyObject *it; ! PyObject *inbasket; ! PyObject *outbasket; ! int save_mode; ! int num_seen; ! } teeobject; typedef struct { PyObject_HEAD ! teeobject *tee; ! int num_seen; ! } iiobject; ! static PyTypeObject ii_type; static PyObject * ! ii_next(iiobject *lz) { ! teeobject *to = lz->tee; ! PyObject *result, *tmp; ! int n; ! if (lz->num_seen == to->num_seen) { ! /* This instance is leading, use iter to get more data */ ! result = PyIter_Next(to->it); ! if (result == NULL) ! return NULL; ! if (to->save_mode) ! if(PyList_Append(to->inbasket, result) == -1){ ! Py_DECREF(result); ! return NULL; ! } ! to->num_seen++; ! lz->num_seen++; ! return result; ! } ! /* This instance is trailing, get data from the queue */ ! if (PyList_GET_SIZE(to->outbasket) == 0) { ! /* outbasket is empty, so refill from the inbasket */ ! tmp = to->outbasket; ! to->outbasket = to->inbasket; ! to->inbasket = tmp; ! PyList_Reverse(to->outbasket); ! } ! /* Pop result from to->outbasket */ ! n = PyList_GET_SIZE(to->outbasket); ! assert(n>0); ! result = PyList_GET_ITEM(to->outbasket, n-1); ! Py_INCREF(result); ! if (PyList_SetSlice(to->outbasket, n-1, n, NULL) == -1) { ! Py_DECREF(result); ! return NULL; ! } ! lz->num_seen++; ! return result; } ! static void ! ii_dealloc(iiobject *ii) { ! teeobject *to = ii->tee; ! int n; ! PyObject_GC_UnTrack(ii); ! ii->tee->save_mode = 0; /* Stop saving data */ ! if (ii->num_seen < to->num_seen) { ! /* It is the trailing iterator being freed; this means ! that the stored queue data is no longer needed */ ! n = PyList_GET_SIZE(to->inbasket); ! PyList_SetSlice(to->inbasket, 0, n, NULL); ! n = PyList_GET_SIZE(to->outbasket); ! PyList_SetSlice(to->outbasket, 0, n, NULL); } ! Py_XDECREF(ii->tee); ! PyObject_GC_Del(ii); } ! static int ! ii_traverse(iiobject *ii, visitproc visit, void *arg) { ! if (ii->tee) ! return visit((PyObject *)(ii->tee), arg); ! return 0; } ! PyDoc_STRVAR(ii_doc, "Independent iterator created by tee(iterable)."); ! static PyTypeObject ii_type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "itertools.tee_iterator", /* tp_name */ ! sizeof(iiobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ ! (destructor)ii_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ --- 8,107 ---- */ ! /* tee object and with supporting function and objects ***************/ ! /* The teedataobject pre-allocates space for LINKCELLS number of objects. ! To help the object fit neatly inside cache lines (space for 16 to 32 ! pointers), the value should be a multiple of 16 minus space for ! the other structure members including PyHEAD overhead. The larger the ! value, the less memory overhead per object and the less time spent ! allocating/deallocating new links. The smaller the number, the less ! wasted space and the more rapid freeing of older data. */ + #define LINKCELLS 57 typedef struct { PyObject_HEAD PyObject *it; ! int numread; ! PyObject *nextlink; ! PyObject *(values[LINKCELLS]); ! } teedataobject; typedef struct { PyObject_HEAD ! teedataobject *dataobj; ! int index; ! } teeobject; ! static PyTypeObject teedataobject_type; static PyObject * ! teedataobject_new(PyObject *it) { ! teedataobject *tdo; ! tdo = PyObject_New(teedataobject, &teedataobject_type); ! if (tdo == NULL) ! return NULL; ! tdo->numread = 0; ! tdo->nextlink = NULL; ! Py_INCREF(it); ! tdo->it = it; ! return (PyObject *)tdo; ! } ! static PyObject * ! teedataobject_jumplink(teedataobject *tdo) ! { ! if (tdo->nextlink == NULL) ! tdo->nextlink = teedataobject_new(tdo->it); ! Py_INCREF(tdo->nextlink); ! return tdo->nextlink; } ! static PyObject * ! teedataobject_getitem(teedataobject *tdo, int i) { ! PyObject *value; ! assert(i < LINKCELLS); ! if (i < tdo->numread) ! value = tdo->values[i]; ! else { ! /* this is the lead iterator, so fetch more data */ ! assert(i == tdo->numread); ! value = PyIter_Next(tdo->it); ! if (value == NULL) ! return NULL; ! tdo->numread++; ! tdo->values[i] = value; } ! Py_INCREF(value); ! return value; } ! static void ! teedataobject_dealloc(teedataobject *tdo) { ! int i; ! ! for (i=0 ; inumread ; i++) ! Py_DECREF(tdo->values[i]); ! Py_XDECREF(tdo->it); ! Py_XDECREF(tdo->nextlink); ! PyObject_Del(tdo); } ! PyDoc_STRVAR(teedataobject_doc, "Data container common to multiple tee objects."); ! static PyTypeObject teedataobject_type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "itertools.tee_dataobject", /* tp_name */ ! sizeof(teedataobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ ! (destructor)teedataobject_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ *************** *** 138,247 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! ii_doc, /* tp_doc */ ! (traverseproc)ii_traverse, /* tp_traverse */ ! 0, /* tp_clear */ ! 0, /* tp_richcompare */ ! 0, /* tp_weaklistoffset */ ! PyObject_SelfIter, /* tp_iter */ ! (iternextfunc)ii_next, /* tp_iternext */ ! 0, /* tp_methods */ }; - /* tee object **********************************************************/ static PyTypeObject tee_type; static PyObject * ! tee_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ! PyObject *it = NULL; ! PyObject *iterable; ! PyObject *inbasket = NULL, *outbasket = NULL, *result = NULL; ! teeobject *to = NULL; ! int i; ! if (!PyArg_UnpackTuple(args, "tee", 1, 1, &iterable)) return NULL; ! it = PyObject_GetIter(iterable); ! if (it == NULL) goto fail; ! ! inbasket = PyList_New(0); ! if (inbasket == NULL) goto fail; ! outbasket = PyList_New(0); ! if (outbasket == NULL) goto fail; ! to = PyObject_GC_New(teeobject, &tee_type); ! if (to == NULL) goto fail; ! to->it = it; ! to->inbasket = inbasket; ! to->outbasket = outbasket; ! to->save_mode = 1; ! to->num_seen = 0; ! PyObject_GC_Track(to); ! /* create independent iterators */ ! result = PyTuple_New(2); ! if (result == NULL) goto fail; ! for (i=0 ; i<2 ; i++) { ! iiobject *indep_it = PyObject_GC_New(iiobject, &ii_type); ! if (indep_it == NULL) goto fail; ! Py_INCREF(to); ! indep_it->tee = to; ! indep_it->num_seen = 0; ! PyObject_GC_Track(indep_it); ! PyTuple_SET_ITEM(result, i, (PyObject *)indep_it); } ! goto succeed; ! fail: Py_XDECREF(it); ! Py_XDECREF(inbasket); ! Py_XDECREF(outbasket); ! Py_XDECREF(result); ! succeed: ! Py_XDECREF(to); ! return result; } ! static void ! tee_dealloc(teeobject *to) { ! PyObject_GC_UnTrack(to); ! Py_XDECREF(to->inbasket); ! Py_XDECREF(to->outbasket); ! Py_XDECREF(to->it); ! PyObject_GC_Del(to); } ! static int ! tee_traverse(teeobject *to, visitproc visit, void *arg) { ! int err; ! ! if (to->it) { ! err = visit(to->it, arg); ! if (err) ! return err; ! } ! if (to->inbasket) { ! err = visit(to->inbasket, arg); ! if (err) ! return err; ! } ! if (to->outbasket) { ! err = visit(to->outbasket, arg); ! if (err) ! return err; ! } ! return 0; } ! PyDoc_STRVAR(tee_doc, ! "tee(iterable) --> (it1, it2)\n\ ! \n\ ! Split the iterable into two independent iterables."); static PyTypeObject tee_type = { --- 118,211 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /* tp_flags */ ! teedataobject_doc, /* tp_doc */ ! 0, /* tp_traverse */ }; static PyTypeObject tee_type; static PyObject * ! tee_next(teeobject *to) { ! PyObject *value, *link; ! if (to->index >= LINKCELLS) { ! link = teedataobject_jumplink(to->dataobj); ! Py_XDECREF(to->dataobj); ! to->dataobj = (teedataobject *)link; ! to->index = 0; ! } ! value = teedataobject_getitem(to->dataobj, to->index); ! if (value == NULL) return NULL; + to->index++; + return value; + } ! static PyObject * ! tee_copy(teeobject *to) ! { ! teeobject *newto; ! newto = PyObject_New(teeobject, &tee_type); ! if (newto == NULL) ! return NULL; ! Py_INCREF(to->dataobj); ! newto->dataobj = to->dataobj; ! newto->index = to->index; ! return (PyObject *)newto; ! } ! PyDoc_STRVAR(teecopy_doc, "Returns an independent iterator."); ! static PyObject * ! tee_fromiterable(PyObject *iterable) ! { ! teeobject *to; ! PyObject *it = NULL; ! it = PyObject_GetIter(iterable); ! if (it == NULL) ! return NULL; ! if (PyObject_TypeCheck(it, &tee_type)) { ! to = (teeobject *)tee_copy((teeobject *)it); ! goto done; } ! ! to = PyObject_New(teeobject, &tee_type); ! if (to == NULL) ! goto done; ! to->dataobj = (teedataobject *)teedataobject_new(it); ! to->index = 0; ! done: Py_XDECREF(it); ! return (PyObject *)to; } ! static PyObject * ! tee_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! PyObject *iterable; ! ! if (!PyArg_UnpackTuple(args, "tee", 1, 1, &iterable)) ! return NULL; ! return tee_fromiterable(iterable); } ! static void ! tee_dealloc(teeobject *to) { ! Py_XDECREF(to->dataobj); ! PyObject_Del(to); } ! PyDoc_STRVAR(teeobject_doc, ! "Iterator wrapped to make it copyable"); ! ! static PyMethodDef tee_methods[] = { ! {"__copy__", (PyCFunction)tee_copy, METH_NOARGS, teecopy_doc}, ! {NULL, NULL} /* sentinel */ ! }; static PyTypeObject tee_type = { *************** *** 267,279 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ ! tee_doc, /* tp_doc */ ! (traverseproc)tee_traverse, /* 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 */ --- 231,243 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /* tp_flags */ ! teeobject_doc, /* tp_doc */ ! 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! PyObject_SelfIter, /* tp_iter */ ! (iternextfunc)tee_next, /* tp_iternext */ ! tee_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ *************** *** 286,291 **** --- 250,299 ---- 0, /* tp_alloc */ tee_new, /* tp_new */ + PyObject_Del, /* tp_free */ }; + static PyObject * + tee(PyObject *self, PyObject *args) + { + int i, n=2; + PyObject *it, *iterable, *copyable, *result; + + if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + return NULL; + result = PyTuple_New(n); + if (result == NULL) + return NULL; + if (n == 0) + return result; + it = PyObject_GetIter(iterable); + if (it == NULL) { + Py_DECREF(result); + return NULL; + } + if (!PyObject_HasAttrString(it, "__copy__")) { + copyable = tee_fromiterable(it); + Py_DECREF(it); + if (copyable == NULL) { + Py_DECREF(result); + return NULL; + } + } else + copyable = it; + PyTuple_SET_ITEM(result, 0, copyable); + for (i=1 ; i tuple of n independent iterators."); + + /* cycle object **********************************************************/ *************** *** 2092,2096 **** imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n\ starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\ ! tee(it) --> (it1, it2) splits one iterator into two \n\ chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... \n\ takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\ --- 2100,2104 ---- imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n\ starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\ ! tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n\ chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... \n\ takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\ *************** *** 2099,2102 **** --- 2107,2115 ---- + static PyMethodDef module_methods[] = { + {"tee", (PyCFunction)tee, METH_VARARGS, tee_doc}, + {NULL, NULL} /* sentinel */ + }; + PyMODINIT_FUNC inititertools(void) *************** *** 2106,2110 **** char *name; PyTypeObject *typelist[] = { - &tee_type, &cycle_type, &dropwhile_type, --- 2119,2122 ---- *************** *** 2122,2126 **** }; ! m = Py_InitModule3("itertools", NULL, module_doc); for (i=0 ; typelist[i] != NULL ; i++) { --- 2134,2138 ---- }; ! m = Py_InitModule3("itertools", module_methods, module_doc); for (i=0 ; typelist[i] != NULL ; i++) { *************** *** 2132,2134 **** --- 2144,2152 ---- PyModule_AddObject(m, name+1, (PyObject *)typelist[i]); } + + if (PyType_Ready(&teedataobject_type) < 0) + return; + if (PyType_Ready(&tee_type) < 0) + return; + } From rhettinger at users.sourceforge.net Wed Nov 12 10:21:22 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 10:21:27 2003 Subject: [Python-checkins] python/dist/src/Lib sets.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv27517 Modified Files: sets.py Log Message: Improve backwards compatibility code to handle True/False. Index: sets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** sets.py 8 Sep 2003 19:16:36 -0000 1.47 --- sets.py 12 Nov 2003 15:21:20 -0000 1.48 *************** *** 74,77 **** --- 74,81 ---- if not predicate(x): yield x + try: + True, False + except NameError: + True, False = (0==0, 0!=0) __all__ = ['BaseSet', 'Set', 'ImmutableSet'] From rhettinger at users.sourceforge.net Wed Nov 12 10:22:00 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 10:22:03 2003 Subject: [Python-checkins] python/dist/src/Lib sets.py,1.44.8.4,1.44.8.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv27620 Modified Files: Tag: release23-maint sets.py Log Message: Improve backwards compatibility code to handle True/False. Index: sets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v retrieving revision 1.44.8.4 retrieving revision 1.44.8.5 diff -C2 -d -r1.44.8.4 -r1.44.8.5 *** sets.py 22 Sep 2003 04:42:56 -0000 1.44.8.4 --- sets.py 12 Nov 2003 15:21:57 -0000 1.44.8.5 *************** *** 74,77 **** --- 74,81 ---- if not predicate(x): yield x + try: + True, False + except NameError: + True, False = (0==0, 0!=0) __all__ = ['BaseSet', 'Set', 'ImmutableSet'] From guido at python.org Wed Nov 12 11:08:12 2003 From: guido at python.org (Guido van Rossum) Date: Wed Nov 12 11:08:21 2003 Subject: [Python-checkins] python/dist/src/Lib sets.py,1.47,1.48 In-Reply-To: Your message of "Wed, 12 Nov 2003 07:21:22 PST." References: Message-ID: <200311121608.hACG8Cd20609@12-236-54-216.client.attbi.com> > Modified Files: > sets.py > Log Message: > Improve backwards compatibility code to handle True/False. > > Index: sets.py > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v > retrieving revision 1.47 > retrieving revision 1.48 > diff -C2 -d -r1.47 -r1.48 > *** sets.py 8 Sep 2003 19:16:36 -0000 1.47 > --- sets.py 12 Nov 2003 15:21:20 -0000 1.48 > *************** > *** 74,77 **** > --- 74,81 ---- > if not predicate(x): > yield x > + try: > + True, False > + except NameError: > + True, False = (0==0, 0!=0) > > __all__ = ['BaseSet', 'Set', 'ImmutableSet'] What's this doing in the 2.4 CVS? --Guido van Rossum (home page: http://www.python.org/~guido/) From rhettinger at users.sourceforge.net Wed Nov 12 11:27:52 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 11:27:58 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv7273 Modified Files: whatsnew24.tex Log Message: Present each feature in terms of what makes it useful or desirable. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** whatsnew24.tex 8 Nov 2003 16:05:37 -0000 1.7 --- whatsnew24.tex 12 Nov 2003 16:27:50 -0000 1.8 *************** *** 80,85 **** \var{key} should be a single-argument function that takes a list element and returns a comparison key for the element. The list is ! then sorted using the comparison keys. The following example sorts a list ! case-insensitively: \begin{verbatim} --- 80,85 ---- \var{key} should be a single-argument function that takes a list element and returns a comparison key for the element. The list is ! then sorted using the comparison keys. The following example sorts a ! list case-insensitively: \begin{verbatim} *************** *** 102,130 **** \var{cmp} will call the method twice for each comparison. The \var{reverse} parameter should have a Boolean value. If the value is \constant{True}, the list will be sorted into reverse order. Instead ! of \code{L.sort() ; L.reverse()}, you can now write ! \code{L.sort(reverse=True)}. ! \item The list type gained a \method{sorted(iterable)} method that ! returns the elements of the iterable as a sorted list. It also accepts ! the \var{cmp}, \var{key}, and \var{reverse} keyword arguments, same as ! the \method{sort()} method. An example usage: \begin{verbatim} >>> L = [9,7,8,3,2,4,1,6,5] ! >>> list.sorted(L) ! [1, 2, 3, 4, 5, 6, 7, 8, 9] ! >>> L ! [9, 7, 8, 3, 2, 4, 1, 6, 5] ! >>> \end{verbatim} - Note that the original list is unchanged; the list returned by - \method{sorted()} is a newly-created one. ! \item The \function{zip()} built-in function and \function{itertools.izip()} now return an empty list ! instead of raising a \exception{TypeError} exception if called ! with no arguments. \end{itemize} --- 102,170 ---- \var{cmp} will call the method twice for each comparison. + Note, for simple key functions and comparison functions, it is often + possible to avoid the \keyword{lambda} expression by using an unbound + method instead. For example, the above case-insensitive sort is best + coded as: + + \begin{verbatim} + >>> L.sort(key=str.lower) + >>> L + ['A', 'b', 'c', 'D'] + \end{verbatim} + The \var{reverse} parameter should have a Boolean value. If the value is \constant{True}, the list will be sorted into reverse order. Instead ! of \code{L.sort(lambda x,y: cmp(y.score, x.score))}, you can now write: ! \code{L.sort(key = lambda x: x.score, reverse=True)}. ! The results of sorting are now guaranteed to be stable. This means that ! two entries with equal keys will be returned in the same order as ! they were input. ! ! ! \item The list type gained a \method{sorted(iterable)} method that works ! like the in-place \method{sort()} method but has been made suitable for ! use in expressions. The differences are: ! \begin{itemize} ! \item the input make be any iterable; ! \item a copy is sorted, leaving the original intact; and ! \item the expression returns the new sorted copy ! \end{itemize} \begin{verbatim} >>> L = [9,7,8,3,2,4,1,6,5] ! >>> [10+i for i in list.sorted(L)] # usable in a list comprehension ! [11, 12, 13, 14, 15, 16, 17, 18, 19] ! >>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged ! [9,7,8,3,2,4,1,6,5] ! >>> list.sorted('Monte Python') # any iterable may be an input ! [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] ! >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5) ! >>> for k, v in list.sorted(colormap.iteritems()): ! ... print k, v ! ... ! black 4 ! blue 2 ! green 3 ! red 1 ! yellow 5 ! \end{verbatim} ! \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} ! exception if called with no arguments. This makes the functions more ! suitable for use with variable length argument lists: ! ! \begin{verbatim} ! >>> def transpose(array): ! ... return zip(*array) ! ... ! >>> transpose([(1,2,3), (4,5,6)]) ! [(1, 4), (2, 5), (3, 6)] ! >>> transpose([]) ! [] ! \end{verbatim} \end{itemize} *************** *** 162,170 **** (Contributed by J\"org Lehmann.) ! \item The \module{heapq} module is no longer implemented in Python, ! having been converted into C. \item The \module{random} module has a new method called \method{getrandbits(N)} ! which returns an N-bit long integer. \item The regular expression language accepted by the \module{re} module --- 202,214 ---- (Contributed by J\"org Lehmann.) ! \item The \module{heapq} module has been converted to C. The resulting ! ten-fold improvement in speed makes the module suitable for handling ! high volumes of data. \item The \module{random} module has a new method called \method{getrandbits(N)} ! which returns an N-bit long integer. This method supports the existing ! \method{randrange()} method, making it possible to efficiently generate ! arbitrarily large random numbers (suitable for prime number generation in ! RSA applications). \item The regular expression language accepted by the \module{re} module *************** *** 232,238 **** \begin{itemize} ! \item The \function{zip()} built-in function and \function{itertools.izip()} now return an empty list ! instead of raising a \exception{TypeError} exception if called ! with no arguments. \item \function{dircache.listdir()} now passes exceptions to the caller --- 276,282 ---- \begin{itemize} ! \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} ! exception if called with no arguments. \item \function{dircache.listdir()} now passes exceptions to the caller From rhettinger at users.sourceforge.net Wed Nov 12 11:39:32 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 11:39:36 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv9727 Modified Files: whatsnew24.tex Log Message: Explain the advantages of reversed. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** whatsnew24.tex 12 Nov 2003 16:27:50 -0000 1.8 --- whatsnew24.tex 12 Nov 2003 16:39:30 -0000 1.9 *************** *** 35,39 **** \begin{verbatim} ! >>> for i in reversed([1,2,3]): ... print i ... --- 35,39 ---- \begin{verbatim} ! >>> for i in reversed(xrange(1,4)): ... print i ... *************** *** 43,49 **** \end{verbatim} Note that \function{reversed()} only accepts sequences, not arbitrary ! iterators. If you want to reverse an iterator, convert it to ! a list or tuple with \function{list()} or \function{tuple()}. \begin{verbatim} --- 43,52 ---- \end{verbatim} + Compared to extended slicing, \code{range(1,4)[::-1]}, \function{reversed()} + is easier to read, runs faster, and uses substantially less memory. + Note that \function{reversed()} only accepts sequences, not arbitrary ! iterators. If you want to reverse an iterator, first convert it to ! a list with \function{list()}. \begin{verbatim} From rhettinger at users.sourceforge.net Wed Nov 12 11:42:12 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 11:43:45 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv10430 Modified Files: whatsnew24.tex Log Message: Fix typo Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** whatsnew24.tex 12 Nov 2003 16:39:30 -0000 1.9 --- whatsnew24.tex 12 Nov 2003 16:42:10 -0000 1.10 *************** *** 130,135 **** use in expressions. The differences are: \begin{itemize} ! \item the input make be any iterable; ! \item a copy is sorted, leaving the original intact; and \item the expression returns the new sorted copy \end{itemize} --- 130,135 ---- use in expressions. The differences are: \begin{itemize} ! \item the input may be any iterable; ! \item a newly formed copy is sorted, leaving the original intact; and \item the expression returns the new sorted copy \end{itemize} From tim_one at users.sourceforge.net Wed Nov 12 14:30:38 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 14:30:50 2003 Subject: [Python-checkins] python/dist/src/PCbuild pyexpat.dsp,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1:/tmp/cvs-serv17999/PCbuild Modified Files: pyexpat.dsp Log Message: pyexpat stopped building on Windows -- whining about the lack of a HAVE_MEMMOVE define. Just defined it on the cmdline (it doesn't include Python.h, and Fred doesn't want to change the code). Index: pyexpat.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pyexpat.dsp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pyexpat.dsp 26 Jan 2003 12:17:52 -0000 1.12 --- pyexpat.dsp 12 Nov 2003 19:30:36 -0000 1.13 *************** *** 45,49 **** F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 45,49 ---- F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 73,77 **** F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "HAVE_EXPAT_H" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 73,77 ---- F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 From rhettinger at users.sourceforge.net Wed Nov 12 15:02:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 15:02:19 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj - New directory Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv24100/setobj Log Message: Directory /cvsroot/python/python/nondist/sandbox/setobj added to the repository From rhettinger at users.sourceforge.net Wed Nov 12 15:06:26 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 15:06:29 2003 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1:/tmp/cvs-serv24822/decimal Modified Files: test_Decimal.py Log Message: Setup sandbox for builtin set() and frozenset() types Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_Decimal.py 12 Aug 2003 23:04:23 -0000 1.3 --- test_Decimal.py 12 Nov 2003 20:06:24 -0000 1.4 *************** *** 6,10 **** from test.test_support import TestSkipped, run_unittest - TESTDATADIR = 'tests' dir = os.curdir + os.sep + TESTDATADIR + os.sep --- 6,9 ---- From rhettinger at users.sourceforge.net Wed Nov 12 15:06:26 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 15:06:31 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, NONE, 1.1 setup.py, NONE, 1.1 test_set.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv24822/setobj Added Files: setobject.c setup.py test_set.py Log Message: Setup sandbox for builtin set() and frozenset() types --- NEW FILE: setobject.c --- #include "Python.h" /* setmodule written and maintained by Raymond D. Hettinger derived from sets.py written by Greg V. Wilson, Alex Martelli, Guido van Rossum, Raymond Hettinger, and Tim Peters. This module introduces two new builtin types, set() and frozenset(). Based on user feedback from sets.py, there is no automatic conversion between the two types. Copyright (c) 2003 Python Software Foundation. All rights reserved. */ /* set object **********************************************************/ typedef struct { PyObject_HEAD PyObject *data; } setobject; static PyTypeObject set_type; static PyObject * set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *data; PyObject *it; PyObject *iterable = NULL; PyObject *item; setobject *so; if (!PyArg_UnpackTuple(args, "set", 0, 1, &iterable)) return NULL; /* Get iterator. */ it = PyObject_GetIter(iterable); if (it == NULL) return NULL; data = PyDict_New(); if (data == NULL) { Py_DECREF(data); return NULL; } while (iterable != NULL) { item = PyIter_Next(it); if (item == NULL) break; // XXX add error checking if (PyDict_SetItem(data, item, Py_None) == -1) { Py_DECREF(it); Py_DECREF(data); PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; } Py_DECREF(item); } Py_DECREF(it); /* create setobject structure */ so = (setobject *)type->tp_alloc(type, 0); if (so == NULL) { Py_DECREF(data); return NULL; } so->data = data; return (PyObject *)so; } static void set_dealloc(setobject *so) { PyObject_GC_UnTrack(so); Py_XDECREF(so->data); so->ob_type->tp_free(so); } static int set_traverse(setobject *so, visitproc visit, void *arg) { if (so->data) return visit(so->data, arg); return 0; } static PyObject * set_iter(setobject *so) { return PyObject_GetIter(so->data); } PyDoc_STRVAR(set_doc, "set(iterable) --> set object\n\ \n\ Build an unordered collection."); static PyTypeObject set_type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "set.set", /* tp_name */ sizeof(setobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)set_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ set_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; /* module level code ********************************************************/ PyDoc_STRVAR(module_doc, "Functional tools for creating and using sets.\n\ \n\ set(iterable) --> new mutuable set \n\ frozenset(iterable) --> new immutable set \n\ "); PyMODINIT_FUNC initset(void) { PyObject *m; if (PyType_Ready(&set_type) < 0) return; m = Py_InitModule3("set", NULL, module_doc); Py_INCREF(&set_type); PyModule_AddObject(m, "set", (PyObject *)&set_type); } --- NEW FILE: setup.py --- from distutils.core import setup, Extension setup(name="set", ext_modules=[Extension("set", ["setobject.c"])]) --- NEW FILE: test_set.py --- from set import set import unittest from test import test_support class TestBasicOps(unittest.TestCase): def test_uniquification(self): s = set('abracadabra') result = list.sorted(s) self.assertEqual(result, list('abcdr')) def test_main(verbose=None): from test import test_sets test_support.run_unittest(TestBasicOps) if __name__ == "__main__": test_main(verbose=True) From rhettinger at users.sourceforge.net Wed Nov 12 15:38:44 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 15:38:48 2003 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1:/tmp/cvs-serv32533 Modified Files: test_Decimal.py Log Message: Revert the previous (harmless) change which got included with the sandbox set-up for setobject.c. Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_Decimal.py 12 Nov 2003 20:06:24 -0000 1.4 --- test_Decimal.py 12 Nov 2003 20:38:41 -0000 1.5 *************** *** 6,9 **** --- 6,10 ---- from test.test_support import TestSkipped, run_unittest + TESTDATADIR = 'tests' dir = os.curdir + os.sep + TESTDATADIR + os.sep From tim_one at users.sourceforge.net Wed Nov 12 15:43:30 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 15:43:33 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.889,1.890 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv32659/Misc Modified Files: NEWS Log Message: SF bug 840829: weakref callbacks and gc corrupt memory. subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.889 retrieving revision 1.890 diff -C2 -d -r1.889 -r1.890 *** NEWS 10 Nov 2003 06:44:44 -0000 1.889 --- NEWS 12 Nov 2003 20:43:28 -0000 1.890 *************** *** 13,16 **** --- 13,22 ---- ----------------- + - Critical bugfix, for SF bug 840829: if cyclic garbage collection + happened to occur during a weakref callback for a new-style class + instance, subtle memory corruption was the result (in a release build; + in a debug build, a segfault occurred reliably very soon after). + This has been repaired. + - Added a reversed() builtin function that returns a reverse iterator over a sequence. From tim_one at users.sourceforge.net Wed Nov 12 15:43:30 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 15:43:35 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv32659/Lib/test Modified Files: test_weakref.py Log Message: SF bug 840829: weakref callbacks and gc corrupt memory. subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** test_weakref.py 14 Jul 2003 21:37:17 -0000 1.28 --- test_weakref.py 12 Nov 2003 20:43:27 -0000 1.29 *************** *** 299,302 **** --- 299,322 ---- self.fail("exception not properly restored") + def test_sf_bug_840829(self): + # "weakref callbacks and gc corrupt memory" + # subtype_dealloc erroneously exposed a new-style instance + # already in the process of getting deallocated to gc, + # causing double-deallocation if the instance had a weakref + # callback that triggered gc. + # If the bug exists, there probably won't be an obvious symptom + # in a release build. In a debug build, a segfault will occur + # when the second attempt to remove the instance from the "list + # of all objects" occurs. + + import gc + + class C(object): + pass + + c = C() + wr = weakref.ref(c, lambda ignore: gc.collect()) + del c + class Object: From tim_one at users.sourceforge.net Wed Nov 12 15:43:30 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 15:43:41 2003 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.250,2.251 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv32659/Objects Modified Files: typeobject.c Log Message: SF bug 840829: weakref callbacks and gc corrupt memory. subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.250 retrieving revision 2.251 diff -C2 -d -r2.250 -r2.251 *** typeobject.c 20 Oct 2003 14:01:54 -0000 2.250 --- typeobject.c 12 Nov 2003 20:43:28 -0000 2.251 *************** *** 640,644 **** Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Find the nearest base with a different tp_dealloc */ --- 640,648 ---- Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. The weakref callback ! * (if any) may trigger GC, and if self is tracked at that point, ! * it will look like trash to GC and GC will try to delete it ! * again. Double-deallocation is a subtle disaster. ! */ /* Find the nearest base with a different tp_dealloc */ *************** *** 655,658 **** --- 659,663 ---- if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); + _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Maybe call finalizer; exit early if resurrected */ From rhettinger at users.sourceforge.net Wed Nov 12 17:46:48 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 17:46:54 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.1, 1.2 test_set.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv28486 Modified Files: setobject.c test_set.py Log Message: Add __len__, __contains__, copy, and union. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** setobject.c 12 Nov 2003 20:06:24 -0000 1.1 --- setobject.c 12 Nov 2003 22:46:45 -0000 1.2 *************** *** 94,97 **** --- 94,184 ---- } + static int + set_len(setobject *so) + { + return PyDict_Size(so->data); + } + + static int + set_contains(setobject *so, PyObject *key) + { + return so->data->ob_type->tp_as_sequence->sq_contains(so->data, key); + } + + static PyObject * + set_copy(setobject *so) + { + PyObject *data; + + data = PyDict_Copy(so->data); + if (data == NULL) + return NULL; + + so = (setobject *)PyObject_GC_New(setobject, &set_type); + if (so == NULL) { + Py_DECREF(data); + return NULL; + } + so->data = data; + return (PyObject *)so; + } + + PyDoc_STRVAR(copy_doc, "Return a shallow copy of a set."); + + static PyObject * + set_union(setobject *so, PyObject *other) + { + setobject *result; + PyObject *item, *data, *it; + + result = (setobject *)set_copy(so); + it = PyObject_GetIter(other); + if (it == NULL) { + Py_DECREF(result); + return NULL; + } + data = result->data; + while (1) { + item = PyIter_Next(it); + if (item == NULL) + break; // XXX add error checking + if (PyDict_SetItem(data, item, Py_None) == -1) { + Py_DECREF(it); + Py_DECREF(result); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + Py_DECREF(item); + } + return (PyObject *)result; + } + + PyDoc_STRVAR(union_doc, + """Return the union of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in either set.)\n"); + + static PySequenceMethods set_as_sequence = { + (inquiry)set_len, /* sq_length */ + 0, /* sq_concat */ + 0, /* sq_repeat */ + 0, /* sq_item */ + 0, /* sq_slice */ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc)set_contains, /* sq_contains */ + }; + + static PyMethodDef set_methods[] = { + {"copy", (PyCFunction)set_copy, METH_NOARGS, + copy_doc}, + {"__copy__", (PyCFunction)set_copy, METH_NOARGS, + copy_doc}, + {"union", (PyCFunction)set_union, METH_O, + union_doc}, + {NULL, NULL} /* sentinel */ + }; + PyDoc_STRVAR(set_doc, "set(iterable) --> set object\n\ *************** *** 102,106 **** PyObject_HEAD_INIT(NULL) 0, /* ob_size */ ! "set.set", /* tp_name */ sizeof(setobject), /* tp_basicsize */ 0, /* tp_itemsize */ --- 189,193 ---- PyObject_HEAD_INIT(NULL) 0, /* ob_size */ ! "set", /* tp_name */ sizeof(setobject), /* tp_basicsize */ 0, /* tp_itemsize */ *************** *** 113,117 **** 0, /* tp_repr */ 0, /* tp_as_number */ ! 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ --- 200,204 ---- 0, /* tp_repr */ 0, /* tp_as_number */ ! &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ *************** *** 130,134 **** (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ --- 217,221 ---- (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ ! set_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_set.py 12 Nov 2003 20:06:24 -0000 1.1 --- test_set.py 12 Nov 2003 22:46:45 -0000 1.2 *************** *** 5,12 **** class TestBasicOps(unittest.TestCase): def test_uniquification(self): ! s = set('abracadabra') ! result = list.sorted(s) ! self.assertEqual(result, list('abcdr')) --- 5,31 ---- class TestBasicOps(unittest.TestCase): + def setUp(self): + word = 'abracadabra' + self.otherword = 'alacazam' + self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + self.s = set(word) + self.d = dict.fromkeys(word) + def test_uniquification(self): ! actual = list.sorted(self.s) ! expected = list.sorted(self.d) ! self.assertEqual(actual, expected) ! ! def test_len(self): ! self.assertEqual(len(self.s), len(self.d)) ! ! def test_contains(self): ! for c in self.letters: ! self.assertEqual(c in self.s, c in self.d) ! ! def test_union(self): ! u = self.s.union(self.otherword) ! for c in self.letters: ! self.assertEqual(c in u, c in self.d or c in self.otherword) From tim_one at users.sourceforge.net Wed Nov 12 20:17:57 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 20:18:03 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.73,1.831.4.74 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv22584/Misc Modified Files: Tag: release23-maint NEWS Log Message: Backport of fix for SF bug 840829, memory corruption in some cases of weakref callbacks. This is a critical bugfix. It's already been fixed on the trunk (2.4 development). I don't intend to backport it to the 22 line, but if a 2.2.4 ever gets released, this should be in it. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.73 retrieving revision 1.831.4.74 diff -C2 -d -r1.831.4.73 -r1.831.4.74 *** NEWS 6 Nov 2003 20:47:43 -0000 1.831.4.73 --- NEWS 13 Nov 2003 01:17:55 -0000 1.831.4.74 *************** *** 13,16 **** --- 13,22 ---- ----------------- + - Critical bugfix, for SF bug 840829: if cyclic garbage collection + happened to occur during a weakref callback for a new-style class + instance, subtle memory corruption could result (in a release build; + in a debug build, a segfault occurred reliably very soon after). + This has been repaired. + - Patch #820195: object.__contains__() now returns True or False instead of 1 or 0. *************** *** 37,41 **** - The sre module (which underlies the re module) now uses a non-recursive ! algorithm for matching. A bunch of ugly REs that used to fail with a RuntimeError will now work. See Bug #757624 --- 43,47 ---- - The sre module (which underlies the re module) now uses a non-recursive ! algorithm for matching. A bunch of ugly REs that used to fail with a RuntimeError will now work. See Bug #757624 *************** *** 156,160 **** - The bsddb module and dbhash module now support the iterator and ! mapping protocols. - Bug #711632: Reset all state members in HTMLParser.reset. --- 162,166 ---- - The bsddb module and dbhash module now support the iterator and ! mapping protocols. - Bug #711632: Reset all state members in HTMLParser.reset. From tim_one at users.sourceforge.net Wed Nov 12 20:17:57 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 20:18:07 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.28, 1.28.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv22584/Lib/test Modified Files: Tag: release23-maint test_weakref.py Log Message: Backport of fix for SF bug 840829, memory corruption in some cases of weakref callbacks. This is a critical bugfix. It's already been fixed on the trunk (2.4 development). I don't intend to backport it to the 22 line, but if a 2.2.4 ever gets released, this should be in it. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.28 retrieving revision 1.28.6.1 diff -C2 -d -r1.28 -r1.28.6.1 *** test_weakref.py 14 Jul 2003 21:37:17 -0000 1.28 --- test_weakref.py 13 Nov 2003 01:17:55 -0000 1.28.6.1 *************** *** 299,302 **** --- 299,322 ---- self.fail("exception not properly restored") + def test_sf_bug_840829(self): + # "weakref callbacks and gc corrupt memory" + # subtype_dealloc erroneously exposed a new-style instance + # already in the process of getting deallocated to gc, + # causing double-deallocation if the instance had a weakref + # callback that triggered gc. + # If the bug exists, there probably won't be an obvious symptom + # in a release build. In a debug build, a segfault will occur + # when the second attempt to remove the instance from the "list + # of all objects" occurs. + + import gc + + class C(object): + pass + + c = C() + wr = weakref.ref(c, lambda ignore: gc.collect()) + del c + class Object: From tim_one at users.sourceforge.net Wed Nov 12 20:17:57 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Nov 12 20:18:09 2003 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.241.6.4, 2.241.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv22584/Objects Modified Files: Tag: release23-maint typeobject.c Log Message: Backport of fix for SF bug 840829, memory corruption in some cases of weakref callbacks. This is a critical bugfix. It's already been fixed on the trunk (2.4 development). I don't intend to backport it to the 22 line, but if a 2.2.4 ever gets released, this should be in it. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.241.6.4 retrieving revision 2.241.6.5 diff -C2 -d -r2.241.6.4 -r2.241.6.5 *** typeobject.c 20 Oct 2003 14:34:47 -0000 2.241.6.4 --- typeobject.c 13 Nov 2003 01:17:55 -0000 2.241.6.5 *************** *** 640,644 **** Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Find the nearest base with a different tp_dealloc */ --- 640,648 ---- Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. The weakref callback ! * (if any) may trigger GC, and if self is tracked at that point, ! * it will look like trash to GC and GC will try to delete it ! * again. Double-deallocation is a subtle disaster. ! */ /* Find the nearest base with a different tp_dealloc */ *************** *** 655,658 **** --- 659,663 ---- if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); + _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Maybe call finalizer; exit early if resurrected */ From rhettinger at users.sourceforge.net Wed Nov 12 21:34:17 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 12 21:37:08 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.2, 1.3 test_set.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv3886 Modified Files: setobject.c test_set.py Log Message: Add intersection. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** setobject.c 12 Nov 2003 22:46:45 -0000 1.2 --- setobject.c 13 Nov 2003 02:34:15 -0000 1.3 *************** *** 14,17 **** --- 14,22 ---- */ + /* Fast dictionary access macros */ + + #define DICT_CONTAINS(d, k) d->ob_type->tp_as_sequence->sq_contains(d, k) + + /* set object **********************************************************/ *************** *** 23,42 **** static PyTypeObject set_type; static PyObject * ! set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *data; PyObject *it; - PyObject *iterable = NULL; PyObject *item; setobject *so; - if (!PyArg_UnpackTuple(args, "set", 0, 1, &iterable)) - return NULL; - /* Get iterator. */ ! it = PyObject_GetIter(iterable); ! if (it == NULL) ! return NULL; data = PyDict_New(); --- 28,46 ---- static PyTypeObject set_type; + static PyObject * ! make_new_set(PyTypeObject *type, PyObject *iterable) { PyObject *data; PyObject *it; PyObject *item; setobject *so; /* Get iterator. */ ! if (iterable != NULL) { ! it = PyObject_GetIter(iterable); ! if (it == NULL) ! return NULL; ! } data = PyDict_New(); *************** *** 72,75 **** --- 76,89 ---- } + static PyObject * + set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + PyObject *iterable = NULL; + + if (!PyArg_UnpackTuple(args, "set", 0, 1, &iterable)) + return NULL; + return make_new_set(type, iterable); + } + static void set_dealloc(setobject *so) *************** *** 103,107 **** set_contains(setobject *so, PyObject *key) { ! return so->data->ob_type->tp_as_sequence->sq_contains(so->data, key); } --- 117,122 ---- set_contains(setobject *so, PyObject *key) { ! return DICT_CONTAINS(so->data, key); ! //return so->data->ob_type->tp_as_sequence->sq_contains(so->data, key); } *************** *** 160,163 **** --- 175,218 ---- (i.e. all elements that are in either set.)\n"); + static PyObject * + set_intersection(setobject *so, PyObject *other) + { + setobject *result; + PyObject *item, *selfdata, *tgtdata, *it; + + result = make_new_set(&set_type, NULL); + if (result == NULL) + return NULL; + + it = PyObject_GetIter(other); + if (it == NULL) { + Py_DECREF(result); + return NULL; + } + + selfdata = so->data; + tgtdata = result->data; + while ((item = PyIter_Next(it)) != NULL) { + if (DICT_CONTAINS(selfdata, item)) { + if (PyDict_SetItem(tgtdata, item, Py_None) == -1) { + Py_DECREF(it); + Py_DECREF(result); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + } + Py_DECREF(item); + } + Py_DECREF(it); + return (PyObject *)result; + } + + PyDoc_STRVAR(intersection_doc, + """Return the intersection of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in both sets.)\n"); + + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 176,179 **** --- 231,236 ---- {"__copy__", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, + {"intersection",(PyCFunction)set_intersection, METH_O, + intersection_doc}, {"union", (PyCFunction)set_union, METH_O, union_doc}, Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_set.py 12 Nov 2003 22:46:45 -0000 1.2 --- test_set.py 13 Nov 2003 02:34:15 -0000 1.3 *************** *** 29,32 **** --- 29,36 ---- self.assertEqual(c in u, c in self.d or c in self.otherword) + def test_intersection(self): + i = self.s.intersection(self.otherword) + for c in self.letters: + self.assertEqual(c in i, c in self.d and c in self.otherword) def test_main(verbose=None): From loewis at users.sourceforge.net Thu Nov 13 02:42:15 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 13 02:42:18 2003 Subject: [Python-checkins] python/dist/src/Python pythonrun.c, 2.195.6.2, 2.195.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv16903/Python Modified Files: Tag: release23-maint pythonrun.c Log Message: Patch #804543: strdup saved locales. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.195.6.2 retrieving revision 2.195.6.3 diff -C2 -d -r2.195.6.2 -r2.195.6.3 *** pythonrun.c 11 Aug 2003 12:21:40 -0000 2.195.6.2 --- pythonrun.c 13 Nov 2003 07:42:13 -0000 2.195.6.3 *************** *** 236,240 **** stdin and stdout if these are terminals. */ ! saved_locale = setlocale(LC_CTYPE, NULL); setlocale(LC_CTYPE, ""); codeset = nl_langinfo(CODESET); --- 236,240 ---- stdin and stdout if these are terminals. */ ! saved_locale = strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, ""); codeset = nl_langinfo(CODESET); *************** *** 251,254 **** --- 251,255 ---- codeset = NULL; setlocale(LC_CTYPE, saved_locale); + free(saved_locale); if (codeset) { From loewis at users.sourceforge.net Thu Nov 13 02:42:15 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 13 02:42:21 2003 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.64,2.64.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv16903/Modules Modified Files: Tag: release23-maint readline.c Log Message: Patch #804543: strdup saved locales. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.64 retrieving revision 2.64.6.1 diff -C2 -d -r2.64 -r2.64.6.1 *** readline.c 17 Jul 2003 16:26:58 -0000 2.64 --- readline.c 13 Nov 2003 07:42:13 -0000 2.64.6.1 *************** *** 591,595 **** { #ifdef SAVE_LOCALE ! char *saved_locale = setlocale(LC_CTYPE, NULL); #endif --- 591,595 ---- { #ifdef SAVE_LOCALE ! char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); #endif *************** *** 632,635 **** --- 632,636 ---- #ifdef SAVE_LOCALE setlocale(LC_CTYPE, saved_locale); /* Restore locale */ + free(saved_locale); #endif } From loewis at users.sourceforge.net Thu Nov 13 02:43:23 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 13 02:43:26 2003 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.65,2.66 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv17201/Modules Modified Files: readline.c Log Message: Patch #804543: strdup saved locales. Backported to 2.3. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -d -r2.65 -r2.66 *** readline.c 20 Sep 2003 16:08:33 -0000 2.65 --- readline.c 13 Nov 2003 07:43:21 -0000 2.66 *************** *** 612,616 **** { #ifdef SAVE_LOCALE ! char *saved_locale = setlocale(LC_CTYPE, NULL); #endif --- 612,616 ---- { #ifdef SAVE_LOCALE ! char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); #endif *************** *** 653,656 **** --- 653,657 ---- #ifdef SAVE_LOCALE setlocale(LC_CTYPE, saved_locale); /* Restore locale */ + free(saved_locale); #endif } From loewis at users.sourceforge.net Thu Nov 13 02:43:23 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 13 02:43:28 2003 Subject: [Python-checkins] python/dist/src/Python pythonrun.c,2.198,2.199 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv17201/Python Modified Files: pythonrun.c Log Message: Patch #804543: strdup saved locales. Backported to 2.3. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.198 retrieving revision 2.199 diff -C2 -d -r2.198 -r2.199 *** pythonrun.c 12 Oct 2003 19:09:37 -0000 2.198 --- pythonrun.c 13 Nov 2003 07:43:21 -0000 2.199 *************** *** 236,240 **** stdin and stdout if these are terminals. */ ! saved_locale = setlocale(LC_CTYPE, NULL); setlocale(LC_CTYPE, ""); codeset = nl_langinfo(CODESET); --- 236,240 ---- stdin and stdout if these are terminals. */ ! saved_locale = strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, ""); codeset = nl_langinfo(CODESET); *************** *** 251,254 **** --- 251,255 ---- codeset = NULL; setlocale(LC_CTYPE, saved_locale); + free(saved_locale); if (codeset) { From loewis at users.sourceforge.net Thu Nov 13 02:45:41 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 13 02:45:44 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_glob.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv17555/Lib/test Modified Files: test_glob.py Log Message: Patch #839877: Remove unused lambda expression. Index: test_glob.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_glob.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_glob.py 2 May 2003 09:06:26 -0000 1.5 --- test_glob.py 13 Nov 2003 07:45:39 -0000 1.6 *************** *** 67,71 **** def test_glob_literal(self): eq = self.assertSequencesEqual_noorder - np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a'), [self.norm('a')]) eq(self.glob('a', 'D'), [self.norm('a', 'D')]) --- 67,70 ---- *************** *** 75,79 **** def test_glob_one_directory(self): eq = self.assertSequencesEqual_noorder - np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a*'), map(self.norm, ['a', 'aab', 'aaa'])) eq(self.glob('*a'), map(self.norm, ['a', 'aaa'])) --- 74,77 ---- *************** *** 84,88 **** def test_glob_nested_directory(self): eq = self.assertSequencesEqual_noorder - np = lambda *f: norm(self.tempdir, *f) if os.path.normcase("abCD") == "abCD": # case-sensitive filesystem --- 82,85 ---- *************** *** 96,100 **** def test_glob_directory_names(self): eq = self.assertSequencesEqual_noorder - np = lambda *f: norm(self.tempdir, *f) eq(self.glob('*', 'D'), [self.norm('a', 'D')]) eq(self.glob('*', '*a'), []) --- 93,96 ---- From greg at users.sourceforge.net Thu Nov 13 03:30:05 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Thu Nov 13 03:30:09 2003 Subject: [Python-checkins] python/dist/src setup.py,1.176,1.177 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv24858 Modified Files: setup.py Log Message: remove "support" for BerkeleyDB 3.1, it hasn't worked for a long time Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.176 retrieving revision 1.177 diff -C2 -d -r1.176 -r1.177 *** setup.py 8 Nov 2003 10:24:35 -0000 1.176 --- setup.py 13 Nov 2003 08:30:02 -0000 1.177 *************** *** 471,482 **** # # This requires the Sleepycat DB code. The earliest supported version ! # of that library is 3.1, the latest supported version is 4.2. A list # of available releases can be found at # # http://www.sleepycat.com/update/index.html - # - # NOTE: 3.1 is only partially supported; expect the extended bsddb module - # test suite to show failures due to some missing methods and behaviours - # in BerkeleyDB 3.1. # when sorted in reverse order, keys for this dict must appear in the --- 471,478 ---- # # This requires the Sleepycat DB code. The earliest supported version ! # of that library is 3.2, the latest supported version is 4.2. A list # of available releases can be found at # # http://www.sleepycat.com/update/index.html # when sorted in reverse order, keys for this dict must appear in the *************** *** 501,508 **** '/usr/include/db4', )}, ! 'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db3',), 'libdirs': ('/usr/local/BerkeleyDB.3.3/lib', '/usr/local/BerkeleyDB.3.2/lib', - '/usr/local/BerkeleyDB.3.1/lib', '/usr/local/lib', '/opt/sfw/lib', --- 497,503 ---- '/usr/include/db4', )}, ! 'db3': {'libs': ('db-3.3', 'db-3.2', 'db3',), 'libdirs': ('/usr/local/BerkeleyDB.3.3/lib', '/usr/local/BerkeleyDB.3.2/lib', '/usr/local/lib', '/opt/sfw/lib', *************** *** 511,515 **** 'incdirs': ('/usr/local/BerkeleyDB.3.3/include', '/usr/local/BerkeleyDB.3.2/include', - '/usr/local/BerkeleyDB.3.1/include', '/usr/local/include/db3', '/opt/sfw/include/db3', --- 506,509 ---- From greg at users.sourceforge.net Thu Nov 13 03:30:05 2003 From: greg at users.sourceforge.net (greg@users.sourceforge.net) Date: Thu Nov 13 03:30:12 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libbsddb.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv24858/Doc/lib Modified Files: libbsddb.tex Log Message: remove "support" for BerkeleyDB 3.1, it hasn't worked for a long time Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libbsddb.tex 16 Sep 2003 21:45:22 -0000 1.13 --- libbsddb.tex 13 Nov 2003 08:30:03 -0000 1.14 *************** *** 16,21 **** Starting with Python 2.3 the \module{bsddb} module requires the ! Berkeley DB library version 3.1 or later (it is known to work with 3.1 ! thru 4.1 at the time of this writing). \begin{seealso} --- 16,21 ---- Starting with Python 2.3 the \module{bsddb} module requires the ! Berkeley DB library version 3.2 or later (it is known to work with 3.2 ! thru 4.2 at the time of this writing). \begin{seealso} From rhettinger at users.sourceforge.net Thu Nov 13 06:31:08 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 06:31:16 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.3, 1.4 test_set.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv24710 Modified Files: setobject.c test_set.py Log Message: Add difference and symmetric_difference Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** setobject.c 13 Nov 2003 02:34:15 -0000 1.3 --- setobject.c 13 Nov 2003 11:31:04 -0000 1.4 *************** *** 154,161 **** } data = result->data; ! while (1) { ! item = PyIter_Next(it); ! if (item == NULL) ! break; // XXX add error checking if (PyDict_SetItem(data, item, Py_None) == -1) { Py_DECREF(it); --- 154,158 ---- } data = result->data; ! while ((item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_None) == -1) { Py_DECREF(it); *************** *** 181,185 **** PyObject *item, *selfdata, *tgtdata, *it; ! result = make_new_set(&set_type, NULL); if (result == NULL) return NULL; --- 178,182 ---- PyObject *item, *selfdata, *tgtdata, *it; ! result = (setobject *)make_new_set(&set_type, NULL); if (result == NULL) return NULL; *************** *** 215,218 **** --- 212,297 ---- + static PyObject * + set_difference(setobject *so, PyObject *other) + { + setobject *result; + PyObject *item, *tgtdata, *it; + + result = (setobject *)set_copy(so); + if (result == NULL) + return NULL; + + it = PyObject_GetIter(other); + if (it == NULL) { + Py_DECREF(result); + return NULL; + } + + tgtdata = result->data; + while ((item = PyIter_Next(it)) != NULL) { + if (PyDict_DelItem(tgtdata, item) == -1) + PyErr_Clear(); + Py_DECREF(item); + } + Py_DECREF(it); + return (PyObject *)result; + } + + PyDoc_STRVAR(difference_doc, + """Return the difference of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in the first set but not the second.)\n"); + + static PyObject * + set_symmetric_difference(setobject *so, PyObject *other) + { + setobject *result, *otherset; + PyObject *item, *selfdata, *otherdata, *tgtdata, *it; + + selfdata = so->data; + + result = (setobject *)set_copy(so); + if (result == NULL) + return NULL; + tgtdata = result->data; + + otherset = (setobject *)make_new_set(&set_type, other); + if (otherset == NULL) { + Py_DECREF(result); + return NULL; + } + otherdata = otherset->data; + + it = PyObject_GetIter(otherdata); + if (it == NULL) { + Py_DECREF(otherset); + Py_DECREF(result); + return NULL; + } + + while ((item = PyIter_Next(it)) != NULL) { + if (PyDict_DelItem(tgtdata, item) == -1) { + PyErr_Clear(); + if (PyDict_SetItem(tgtdata, item, Py_None) == -1) { + Py_DECREF(it); + Py_DECREF(otherset); + Py_DECREF(result); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + } + Py_DECREF(item); + } + + Py_DECREF(otherset); + return (PyObject *)result; + } + + PyDoc_STRVAR(symmetric_difference_doc, + """Return the symmetric difference of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in exactly one of the sets.)\n"); + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 231,236 **** --- 310,319 ---- {"__copy__", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, + {"difference",(PyCFunction)set_difference, METH_O, + difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, + {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, + symmetric_difference_doc}, {"union", (PyCFunction)set_union, METH_O, union_doc}, Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_set.py 13 Nov 2003 02:34:15 -0000 1.3 --- test_set.py 13 Nov 2003 11:31:04 -0000 1.4 *************** *** 34,37 **** --- 34,47 ---- self.assertEqual(c in i, c in self.d and c in self.otherword) + def test_difference(self): + i = self.s.difference(self.otherword) + for c in self.letters: + self.assertEqual(c in i, c in self.d and c not in self.otherword) + + def test_symmetric_difference(self): + i = self.s.symmetric_difference(self.otherword) + for c in self.letters: + self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) + def test_main(verbose=None): from test import test_sets From tim_one at users.sourceforge.net Thu Nov 13 10:52:27 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 10:52:33 2003 Subject: [Python-checkins] python/dist/src/PCbuild pyexpat.dsp, 1.12, 1.12.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1:/tmp/cvs-serv10296/PCbuild Modified Files: Tag: release23-maint pyexpat.dsp Log Message: #define HAVE_MEMMOVE on the cmdline for the pyexpat project; it doesn't include Python.h, Fred doesn't want the source code changed, and it won't compile on Windows otherwise. Index: pyexpat.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pyexpat.dsp,v retrieving revision 1.12 retrieving revision 1.12.12.1 diff -C2 -d -r1.12 -r1.12.12.1 *** pyexpat.dsp 26 Jan 2003 12:17:52 -0000 1.12 --- pyexpat.dsp 13 Nov 2003 15:52:25 -0000 1.12.12.1 *************** *** 45,49 **** F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 45,49 ---- F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 73,77 **** F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "HAVE_EXPAT_H" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 73,77 ---- F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 From rhettinger at users.sourceforge.net Thu Nov 13 12:14:39 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 12:14:45 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.4, 1.5 test_set.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv29508 Modified Files: setobject.c test_set.py Log Message: Split into set() and frozenset(). Add __hash__(). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** setobject.c 13 Nov 2003 11:31:04 -0000 1.4 --- setobject.c 13 Nov 2003 17:14:37 -0000 1.5 *************** *** 27,31 **** static PyTypeObject set_type; ! static PyObject * --- 27,31 ---- static PyTypeObject set_type; ! static PyTypeObject frozenset_type; static PyObject * *************** *** 118,122 **** { return DICT_CONTAINS(so->data, key); - //return so->data->ob_type->tp_as_sequence->sq_contains(so->data, key); } --- 118,121 ---- *************** *** 130,134 **** return NULL; ! so = (setobject *)PyObject_GC_New(setobject, &set_type); if (so == NULL) { Py_DECREF(data); --- 129,133 ---- return NULL; ! so = (setobject *)PyObject_GC_New(setobject, so->ob_type); if (so == NULL) { Py_DECREF(data); *************** *** 178,182 **** PyObject *item, *selfdata, *tgtdata, *it; ! result = (setobject *)make_new_set(&set_type, NULL); if (result == NULL) return NULL; --- 177,181 ---- PyObject *item, *selfdata, *tgtdata, *it; ! result = (setobject *)make_new_set(so->ob_type, NULL); if (result == NULL) return NULL; *************** *** 256,260 **** tgtdata = result->data; ! otherset = (setobject *)make_new_set(&set_type, other); if (otherset == NULL) { Py_DECREF(result); --- 255,259 ---- tgtdata = result->data; ! otherset = (setobject *)make_new_set(so->ob_type, other); if (otherset == NULL) { Py_DECREF(result); *************** *** 294,297 **** --- 293,321 ---- (i.e. all elements that are in exactly one of the sets.)\n"); + static long + set_nohash(PyObject *self) + { + PyErr_SetString(PyExc_TypeError, "set objects are unhashable"); + return -1; + } + + static long + frozenset_hash(PyObject *so) + { + PyObject *it, *item; + long hash = 0; + + it = PyObject_GetIter(((setobject *)so)->data); + if (it == NULL) + return -1; + + while ((item = PyIter_Next(it)) != NULL) { + hash ^= PyObject_Hash(item); + Py_DECREF(item); + } + Py_DECREF(it); + return hash; + } + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 305,308 **** --- 329,334 ---- }; + /* set object ********************************************************/ + static PyMethodDef set_methods[] = { {"copy", (PyCFunction)set_copy, METH_NOARGS, *************** *** 342,346 **** &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ --- 368,372 ---- &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! set_nohash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ *************** *** 371,374 **** --- 397,469 ---- }; + /* frozenset object ********************************************************/ + + + static PyMethodDef frozenset_methods[] = { + {"copy", (PyCFunction)set_copy, METH_NOARGS, + copy_doc}, + {"__copy__", (PyCFunction)set_copy, METH_NOARGS, + copy_doc}, + {"difference",(PyCFunction)set_difference, METH_O, + difference_doc}, + {"intersection",(PyCFunction)set_intersection, METH_O, + intersection_doc}, + {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, + symmetric_difference_doc}, + {"union", (PyCFunction)set_union, METH_O, + union_doc}, + {NULL, NULL} /* sentinel */ + }; + + PyDoc_STRVAR(frozenset_doc, + "frozenset(iterable) --> frozenset object\n\ + \n\ + Build an immutable unordered collection."); + + static PyTypeObject frozenset_type = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "frozenset", /* tp_name */ + sizeof(setobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)set_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &set_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + frozenset_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_HAVE_GC | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + frozenset_doc, /* tp_doc */ + (traverseproc)set_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc)set_iter, /* tp_iter */ + 0, /* tp_iternext */ + frozenset_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + set_new, /* tp_new */ + PyObject_GC_Del, /* tp_free */ + }; + *************** *** 388,396 **** PyObject *m; - if (PyType_Ready(&set_type) < 0) - return; m = Py_InitModule3("set", NULL, module_doc); Py_INCREF(&set_type); PyModule_AddObject(m, "set", (PyObject *)&set_type); } --- 483,496 ---- PyObject *m; m = Py_InitModule3("set", NULL, module_doc); + if (PyType_Ready(&set_type) < 0) + return; Py_INCREF(&set_type); PyModule_AddObject(m, "set", (PyObject *)&set_type); + + if (PyType_Ready(&frozenset_type) < 0) + return; + Py_INCREF(&frozenset_type); + PyModule_AddObject(m, "frozenset", (PyObject *)&frozenset_type); } Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_set.py 13 Nov 2003 11:31:04 -0000 1.4 --- test_set.py 13 Nov 2003 17:14:37 -0000 1.5 *************** *** 1,7 **** ! from set import set import unittest from test import test_support ! class TestBasicOps(unittest.TestCase): def setUp(self): --- 1,8 ---- ! from set import set, frozenset import unittest from test import test_support ! class TestJointOps(unittest.TestCase): ! # Tests common to both set and frozenset def setUp(self): *************** *** 9,13 **** self.otherword = 'alacazam' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ! self.s = set(word) self.d = dict.fromkeys(word) --- 10,14 ---- self.otherword = 'alacazam' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ! self.s = self.thetype(word) self.d = dict.fromkeys(word) *************** *** 28,31 **** --- 29,33 ---- for c in self.letters: self.assertEqual(c in u, c in self.d or c in self.otherword) + self.assertEqual(type(u), self.thetype) def test_intersection(self): *************** *** 33,36 **** --- 35,39 ---- for c in self.letters: self.assertEqual(c in i, c in self.d and c in self.otherword) + self.assertEqual(type(i), self.thetype) def test_difference(self): *************** *** 38,41 **** --- 41,45 ---- for c in self.letters: self.assertEqual(c in i, c in self.d and c not in self.otherword) + self.assertEqual(type(i), self.thetype) def test_symmetric_difference(self): *************** *** 43,50 **** for c in self.letters: self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) def test_main(verbose=None): from test import test_sets ! test_support.run_unittest(TestBasicOps) if __name__ == "__main__": --- 47,70 ---- for c in self.letters: self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) + self.assertEqual(type(i), self.thetype) + + class TestSet(TestJointOps): + thetype = set + + def test_hash(self): + self.assertRaises(TypeError, hash, self.s) + + class TestFrozenSet(TestJointOps): + thetype = frozenset + + def test_hash(self): + self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) def test_main(verbose=None): from test import test_sets ! test_support.run_unittest( ! TestSet, ! TestFrozenSet, ! ) if __name__ == "__main__": From rhettinger at users.sourceforge.net Thu Nov 13 12:47:30 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 12:47:38 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.5, 1.6 test_set.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv3693 Modified Files: setobject.c test_set.py Log Message: Add __eq__() and __ne__(). Test set of frozen sets. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** setobject.c 13 Nov 2003 17:14:37 -0000 1.5 --- setobject.c 13 Nov 2003 17:47:28 -0000 1.6 *************** *** 17,21 **** #define DICT_CONTAINS(d, k) d->ob_type->tp_as_sequence->sq_contains(d, k) ! /* set object **********************************************************/ --- 17,21 ---- #define DICT_CONTAINS(d, k) d->ob_type->tp_as_sequence->sq_contains(d, k) ! #define IS_SET(so) (so->ob_type == &set_type || so->ob_type == &frozenset_type) /* set object **********************************************************/ *************** *** 318,321 **** --- 318,339 ---- } + static PyObject * + set_richcompare(PyObject *v, PyObject *w, int op) + { + PyObject *res; + + if (op == Py_EQ && ! IS_SET(w)) + res = Py_False; + else if (op == Py_NE && ! IS_SET(w)) + res = Py_True; + else if (op == Py_EQ || op == Py_NE) + res = PyObject_RichCompare(((setobject *)v)->data, + ((setobject *)w)->data, op); + else + res = Py_NotImplemented; + Py_INCREF(res); + return res; + } + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 379,383 **** (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ ! 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ --- 397,401 ---- (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ ! (richcmpfunc)set_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_set.py 13 Nov 2003 17:14:37 -0000 1.5 --- test_set.py 13 Nov 2003 17:47:28 -0000 1.6 *************** *** 61,64 **** --- 61,71 ---- self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) + class TestSetsOfSets(unittest.TestCase): + + def testSetOfFrozensets(set): + t = map(frozenset, ['abcdef', 'bcd', 'bdcb', 'fed', 'fedccba']) + s = set(t) + self.assertEqual(len(s), 3) + def test_main(verbose=None): from test import test_sets From rhettinger at users.sourceforge.net Thu Nov 13 14:21:24 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 14:21:30 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.6, 1.7 test_set.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv25102 Modified Files: setobject.c test_set.py Log Message: Add __repr__(). Enable test for sets of frozen sets. Fix richcompare. Use Py_True over Py_None. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** setobject.c 13 Nov 2003 17:47:28 -0000 1.6 --- setobject.c 13 Nov 2003 19:21:22 -0000 1.7 *************** *** 54,58 **** if (item == NULL) break; // XXX add error checking ! if (PyDict_SetItem(data, item, Py_None) == -1) { Py_DECREF(it); Py_DECREF(data); --- 54,58 ---- if (item == NULL) break; // XXX add error checking ! if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(data); *************** *** 154,158 **** data = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_SetItem(data, item, Py_None) == -1) { Py_DECREF(it); Py_DECREF(result); --- 154,158 ---- data = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(result); *************** *** 191,195 **** while ((item = PyIter_Next(it)) != NULL) { if (DICT_CONTAINS(selfdata, item)) { ! if (PyDict_SetItem(tgtdata, item, Py_None) == -1) { Py_DECREF(it); Py_DECREF(result); --- 191,195 ---- while ((item = PyIter_Next(it)) != NULL) { if (DICT_CONTAINS(selfdata, item)) { ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(result); *************** *** 272,276 **** if (PyDict_DelItem(tgtdata, item) == -1) { PyErr_Clear(); ! if (PyDict_SetItem(tgtdata, item, Py_None) == -1) { Py_DECREF(it); Py_DECREF(otherset); --- 272,276 ---- if (PyDict_DelItem(tgtdata, item) == -1) { PyErr_Clear(); ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(otherset); *************** *** 323,332 **** PyObject *res; ! if (op == Py_EQ && ! IS_SET(w)) res = Py_False; ! else if (op == Py_NE && ! IS_SET(w)) res = Py_True; ! else if (op == Py_EQ || op == Py_NE) ! res = PyObject_RichCompare(((setobject *)v)->data, ((setobject *)w)->data, op); else --- 323,332 ---- PyObject *res; ! if (op == Py_EQ && !IS_SET(w)) res = Py_False; ! else if (op == Py_NE && !IS_SET(w)) res = Py_True; ! else if (op == Py_EQ || op == Py_NE) ! return PyObject_RichCompare(((setobject *)v)->data, ((setobject *)w)->data, op); else *************** *** 334,338 **** Py_INCREF(res); return res; ! } static PySequenceMethods set_as_sequence = { --- 334,353 ---- Py_INCREF(res); return res; ! } ! ! static PyObject * ! set_repr(setobject *so) ! { ! PyObject *keys, *result, *listrepr; ! ! keys = PyDict_Keys(so->data); ! listrepr = PyObject_Repr(keys); ! Py_DECREF(keys); ! ! result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, ! PyString_AS_STRING(listrepr)); ! Py_DECREF(listrepr); ! return result; ! } static PySequenceMethods set_as_sequence = { *************** *** 382,386 **** 0, /* tp_setattr */ 0, /* tp_compare */ ! 0, /* tp_repr */ 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ --- 397,401 ---- 0, /* tp_setattr */ 0, /* tp_compare */ ! (reprfunc)set_repr, /* tp_repr */ 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ *************** *** 451,455 **** 0, /* tp_setattr */ 0, /* tp_compare */ ! 0, /* tp_repr */ 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ --- 466,470 ---- 0, /* tp_setattr */ 0, /* tp_compare */ ! (reprfunc)set_repr, /* tp_repr */ 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ *************** *** 466,470 **** (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ ! 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ --- 481,485 ---- (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ ! (richcmpfunc)set_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_set.py 13 Nov 2003 17:47:28 -0000 1.6 --- test_set.py 13 Nov 2003 19:21:22 -0000 1.7 *************** *** 49,52 **** --- 49,63 ---- self.assertEqual(type(i), self.thetype) + def test_equality(self): + self.assertEqual(self.thetype('abcb'), set('bcac')) + self.assertEqual(self.thetype('abcb'), frozenset('bcac')) + self.assertNotEqual(self.thetype('abc'), set('def')) + self.assertNotEqual(self.thetype('abc'), frozenset('def')) + + def test_setOfFrozensets(self): + t = map(frozenset, ['abcdef', 'bcd', 'bdcb', 'fed', 'fedccba']) + s = self.thetype(t) + self.assertEqual(len(s), 3) + class TestSet(TestJointOps): thetype = set *************** *** 61,70 **** self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) - class TestSetsOfSets(unittest.TestCase): - - def testSetOfFrozensets(set): - t = map(frozenset, ['abcdef', 'bcd', 'bdcb', 'fed', 'fedccba']) - s = set(t) - self.assertEqual(len(s), 3) def test_main(verbose=None): --- 72,75 ---- From rhettinger at users.sourceforge.net Thu Nov 13 15:59:14 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 15:59:21 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.7, 1.8 test_set.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv15675 Modified Files: setobject.c test_set.py Log Message: Add __cmp__() and non-mutating operators: & | ^ -. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** setobject.c 13 Nov 2003 19:21:22 -0000 1.7 --- setobject.c 13 Nov 2003 20:59:12 -0000 1.8 *************** *** 33,37 **** { PyObject *data; ! PyObject *it; PyObject *item; setobject *so; --- 33,37 ---- { PyObject *data; ! PyObject *it = NULL; PyObject *item; setobject *so; *************** *** 46,54 **** data = PyDict_New(); if (data == NULL) { ! Py_DECREF(data); return NULL; } ! while (iterable != NULL) { item = PyIter_Next(it); if (item == NULL) --- 46,54 ---- data = PyDict_New(); if (data == NULL) { ! Py_DECREF(it); return NULL; } ! while (it != NULL) { item = PyIter_Next(it); if (item == NULL) *************** *** 63,67 **** Py_DECREF(item); } ! Py_DECREF(it); /* create setobject structure */ --- 63,67 ---- Py_DECREF(item); } ! Py_XDECREF(it); /* create setobject structure */ *************** *** 172,175 **** --- 172,185 ---- static PyObject * + set_or(setobject *so, PyObject *other) + { + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + return set_union(so, other); + } + + static PyObject * set_intersection(setobject *so, PyObject *other) { *************** *** 197,201 **** "all set entries must be immutable"); return NULL; ! } } Py_DECREF(item); --- 207,211 ---- "all set entries must be immutable"); return NULL; ! } } Py_DECREF(item); *************** *** 205,208 **** --- 215,228 ---- } + static PyObject * + set_and(setobject *so, PyObject *other) + { + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + return set_intersection(so, other); + } + PyDoc_STRVAR(intersection_doc, """Return the intersection of two sets as a new set.\n\ *************** *** 243,246 **** --- 263,276 ---- static PyObject * + set_sub(setobject *so, PyObject *other) + { + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + return set_difference(so, other); + } + + static PyObject * set_symmetric_difference(setobject *so, PyObject *other) { *************** *** 293,296 **** --- 323,336 ---- (i.e. all elements that are in exactly one of the sets.)\n"); + static PyObject * + set_xor(setobject *so, PyObject *other) + { + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + return set_symmetric_difference(so, other); + } + static long set_nohash(PyObject *self) *************** *** 300,303 **** --- 340,350 ---- } + static int + set_nocmp(PyObject *self) + { + PyErr_SetString(PyExc_TypeError, "cannot compare sets using cmp()"); + return -1; + } + static long frozenset_hash(PyObject *so) *************** *** 315,319 **** } Py_DECREF(it); ! return hash; } --- 362,366 ---- } Py_DECREF(it); ! return hash; /* XXX Consider caching the hash value to save recomputations */ } *************** *** 380,383 **** --- 427,450 ---- }; + static PyNumberMethods set_as_number = { + 0, /*nb_add*/ + (binaryfunc)set_sub, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + (binaryfunc)set_and, /*nb_and*/ + (binaryfunc)set_xor, /*nb_xor*/ + (binaryfunc)set_or, /*nb_or*/ + }; + PyDoc_STRVAR(set_doc, "set(iterable) --> set object\n\ *************** *** 396,402 **** 0, /* tp_getattr */ 0, /* tp_setattr */ ! 0, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ ! 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ --- 463,469 ---- 0, /* tp_getattr */ 0, /* tp_setattr */ ! (cmpfunc)set_nocmp, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ ! &set_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ *************** *** 449,452 **** --- 516,539 ---- }; + static PyNumberMethods frozenset_as_number = { + 0, /*nb_add*/ + (binaryfunc)set_sub, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + (binaryfunc)set_and, /*nb_and*/ + (binaryfunc)set_xor, /*nb_xor*/ + (binaryfunc)set_or, /*nb_or*/ + }; + PyDoc_STRVAR(frozenset_doc, "frozenset(iterable) --> frozenset object\n\ *************** *** 465,471 **** 0, /* tp_getattr */ 0, /* tp_setattr */ ! 0, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ ! 0, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ --- 552,558 ---- 0, /* tp_getattr */ 0, /* tp_setattr */ ! (cmpfunc)set_nocmp, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ ! &frozenset_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_set.py 13 Nov 2003 19:21:22 -0000 1.7 --- test_set.py 13 Nov 2003 20:59:12 -0000 1.8 *************** *** 31,34 **** --- 31,44 ---- self.assertEqual(type(u), self.thetype) + def test_or(self): + i = self.s.union(self.otherword) + self.assertEqual(self.s | self.thetype(self.otherword), i) + try: + self.s | self.otherword + except TypeError: + pass + else: + self.fail("s|t did not screen-out general iterables") + def test_intersection(self): i = self.s.intersection(self.otherword) *************** *** 37,40 **** --- 47,60 ---- self.assertEqual(type(i), self.thetype) + def test_and(self): + i = self.s.intersection(self.otherword) + self.assertEqual(self.s & self.thetype(self.otherword), i) + try: + self.s & self.otherword + except TypeError: + pass + else: + self.fail("s&t did not screen-out general iterables") + def test_difference(self): i = self.s.difference(self.otherword) *************** *** 43,46 **** --- 63,76 ---- self.assertEqual(type(i), self.thetype) + def test_sub(self): + i = self.s.difference(self.otherword) + self.assertEqual(self.s - self.thetype(self.otherword), i) + try: + self.s - self.otherword + except TypeError: + pass + else: + self.fail("s-t did not screen-out general iterables") + def test_symmetric_difference(self): i = self.s.symmetric_difference(self.otherword) *************** *** 49,52 **** --- 79,92 ---- self.assertEqual(type(i), self.thetype) + def test_xor(self): + i = self.s.symmetric_difference(self.otherword) + self.assertEqual(self.s ^ self.thetype(self.otherword), i) + try: + self.s ^ self.otherword + except TypeError: + pass + else: + self.fail("s^t did not screen-out general iterables") + def test_equality(self): self.assertEqual(self.thetype('abcb'), set('bcac')) *************** *** 59,62 **** --- 99,105 ---- s = self.thetype(t) self.assertEqual(len(s), 3) + + def test_compare(self): + self.assertRaises(TypeError, self.s.__cmp__, self.s) class TestSet(TestJointOps): From akuchling at users.sourceforge.net Thu Nov 13 16:33:29 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Nov 13 16:33:36 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv22893 Modified Files: whatsnew24.tex Log Message: Various edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** whatsnew24.tex 12 Nov 2003 16:42:10 -0000 1.10 --- whatsnew24.tex 13 Nov 2003 21:33:26 -0000 1.11 *************** *** 105,110 **** \var{cmp} will call the method twice for each comparison. ! Note, for simple key functions and comparison functions, it is often ! possible to avoid the \keyword{lambda} expression by using an unbound method instead. For example, the above case-insensitive sort is best coded as: --- 105,110 ---- \var{cmp} will call the method twice for each comparison. ! For simple key functions and comparison functions, it is often ! possible to avoid a \keyword{lambda} expression by using an unbound method instead. For example, the above case-insensitive sort is best coded as: *************** *** 121,128 **** \code{L.sort(key = lambda x: x.score, reverse=True)}. ! The results of sorting are now guaranteed to be stable. This means that ! two entries with equal keys will be returned in the same order as ! they were input. ! \item The list type gained a \method{sorted(iterable)} method that works --- 121,129 ---- \code{L.sort(key = lambda x: x.score, reverse=True)}. ! The results of sorting are now guaranteed to be stable. This means ! that two entries with equal keys will be returned in the same order as ! they were input. For example, you can sort a list of people by name, ! and then sort the list by age, resulting in a list sorted by age where ! people with the same age are in name-sorted order. \item The list type gained a \method{sorted(iterable)} method that works *************** *** 144,147 **** --- 145,149 ---- [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5) + >>> # Lists the contents of the dict sorted by key values >>> for k, v in list.sorted(colormap.iteritems()): ... print k, v *************** *** 294,298 **** The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: . \end{document} --- 296,300 ---- The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Raymond Hettinger. \end{document} From tim_one at users.sourceforge.net Thu Nov 13 16:59:34 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 16:59:46 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.29, 1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv28210/Lib/test Modified Files: test_weakref.py Log Message: subtype_dealloc(): A more complete fix for critical bug 840829 + expanded the test case with a piece that needs the more-complete fix. I'll backport this to 2.3 maint. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_weakref.py 12 Nov 2003 20:43:27 -0000 1.29 --- test_weakref.py 13 Nov 2003 21:59:31 -0000 1.30 *************** *** 319,322 **** --- 319,341 ---- del c + # There endeth the first part. It gets worse. + del wr + + c1 = C() + c1.i = C() + wr = weakref.ref(c1.i, lambda ignore: gc.collect()) + + c2 = C() + c2.c1 = c1 + del c1 # still alive because c2 points to it + + # Now when subtype_dealloc gets called on c2, it's not enough just + # that c2 is immune from gc while the weakref callbacks associated + # with c2 execute (there are none in this 2nd half of the test, btw). + # subtype_dealloc goes on to call the base classes' deallocs too, + # so any gc triggered by weakref callbacks associated with anything + # torn down by a base class dealloc can also trigger double + # deallocation of c2. + del c2 class Object: From tim_one at users.sourceforge.net Thu Nov 13 16:59:35 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 16:59:51 2003 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.251,2.252 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv28210/Objects Modified Files: typeobject.c Log Message: subtype_dealloc(): A more complete fix for critical bug 840829 + expanded the test case with a piece that needs the more-complete fix. I'll backport this to 2.3 maint. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.251 retrieving revision 2.252 diff -C2 -d -r2.251 -r2.252 *** typeobject.c 12 Nov 2003 20:43:28 -0000 2.251 --- typeobject.c 13 Nov 2003 21:59:32 -0000 2.252 *************** *** 640,647 **** Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. The weakref callback ! * (if any) may trigger GC, and if self is tracked at that point, ! * it will look like trash to GC and GC will try to delete it ! * again. Double-deallocation is a subtle disaster. */ --- 640,647 ---- Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. weakref callbacks ! * (if any, and whether directly here or indirectly in something we ! * call) may trigger GC, and if self is tracked at that point, it ! * will look like trash to GC and GC will try to delete self again. */ *************** *** 659,669 **** if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); - _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Maybe call finalizer; exit early if resurrected */ if (type->tp_del) { type->tp_del(self); if (self->ob_refcnt > 0) ! goto endlabel; } --- 659,671 ---- if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); /* Maybe call finalizer; exit early if resurrected */ if (type->tp_del) { + _PyObject_GC_TRACK(self); type->tp_del(self); if (self->ob_refcnt > 0) ! goto endlabel; /* resurrected */ ! else ! _PyObject_GC_UNTRACK(self); } *************** *** 690,693 **** --- 692,696 ---- /* Finalize GC if the base doesn't do GC and we do */ + _PyObject_GC_TRACK(self); if (!PyType_IS_GC(base)) _PyObject_GC_UNTRACK(self); *************** *** 730,733 **** --- 733,746 ---- trashcan begin GC track + + Q. Why did the last question say "immediately GC-track again"? + It's nowhere near immediately. + + A. Because the code *used* to re-track immediately. Bad Idea. + self has a refcount of 0, and if gc ever gets its hands on it + (which can happen if any weakref callback gets invoked), it + looks like trash to gc too, and gc also tries to delete self + then. But we're already deleting self. Double dealloction is + a subtle disaster. Q. Why the bizarre (net-zero) manipulation of From rhettinger at users.sourceforge.net Thu Nov 13 17:24:00 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 17:24:07 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.8, 1.9 test_set.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv1423 Modified Files: setobject.c test_set.py Log Message: Add issubset(), issuperset() and the related comparison operators. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** setobject.c 13 Nov 2003 20:59:12 -0000 1.8 --- setobject.c 13 Nov 2003 22:23:58 -0000 1.9 *************** *** 16,20 **** /* Fast dictionary access macros */ ! #define DICT_CONTAINS(d, k) d->ob_type->tp_as_sequence->sq_contains(d, k) #define IS_SET(so) (so->ob_type == &set_type || so->ob_type == &frozenset_type) --- 16,20 ---- /* Fast dictionary access macros */ ! #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) #define IS_SET(so) (so->ob_type == &set_type || so->ob_type == &frozenset_type) *************** *** 167,171 **** PyDoc_STRVAR(union_doc, ! """Return the union of two sets as a new set.\n\ \n\ (i.e. all elements that are in either set.)\n"); --- 167,171 ---- PyDoc_STRVAR(union_doc, ! "Return the union of two sets as a new set.\n\ \n\ (i.e. all elements that are in either set.)\n"); *************** *** 226,230 **** PyDoc_STRVAR(intersection_doc, ! """Return the intersection of two sets as a new set.\n\ \n\ (i.e. all elements that are in both sets.)\n"); --- 226,230 ---- PyDoc_STRVAR(intersection_doc, ! "Return the intersection of two sets as a new set.\n\ \n\ (i.e. all elements that are in both sets.)\n"); *************** *** 258,262 **** PyDoc_STRVAR(difference_doc, ! """Return the difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in the first set but not the second.)\n"); --- 258,262 ---- PyDoc_STRVAR(difference_doc, ! "Return the difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in the first set but not the second.)\n"); *************** *** 319,323 **** PyDoc_STRVAR(symmetric_difference_doc, ! """Return the symmetric difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in exactly one of the sets.)\n"); --- 319,323 ---- PyDoc_STRVAR(symmetric_difference_doc, ! "Return the symmetric difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in exactly one of the sets.)\n"); *************** *** 333,336 **** --- 333,382 ---- } + PyObject * + set_issubset(setobject *so, PyObject *other) + { + PyObject *otherdata, *it, *item; + + if (!IS_SET(other)) { + PyErr_SetString(PyExc_TypeError, "can only compare to a set"); + return NULL; + } + if (set_len(so) > set_len((setobject *)other)) { + Py_INCREF(Py_False); + return Py_False; + } + + it = PyObject_GetIter(so->data); + if (it == NULL) + return NULL; + + otherdata = ((setobject *)other)->data; + while ((item = PyIter_Next(it)) != NULL) { + if (!DICT_CONTAINS(otherdata, item)) { + Py_DECREF(it); + Py_DECREF(item); + Py_INCREF(Py_False); + return Py_False; + } + Py_DECREF(item); + } + Py_INCREF(Py_True); + return Py_True; + } + + PyDoc_STRVAR(issubset_doc, "Report whether another set contains this set."); + + PyObject * + set_issuperset(setobject *so, PyObject *other) + { + if (!IS_SET(other)) { + PyErr_SetString(PyExc_TypeError, "can only compare to a set"); + return NULL; + } + return set_issubset((setobject *)other, (PyObject *)so); + } + + PyDoc_STRVAR(issuperset_doc, "Report whether another set contains this set."); + static long set_nohash(PyObject *self) *************** *** 369,384 **** { PyObject *res; ! if (op == Py_EQ && !IS_SET(w)) res = Py_False; else if (op == Py_NE && !IS_SET(w)) res = Py_True; ! else if (op == Py_EQ || op == Py_NE) return PyObject_RichCompare(((setobject *)v)->data, ((setobject *)w)->data, op); ! else ! res = Py_NotImplemented; ! Py_INCREF(res); ! return res; } --- 415,448 ---- { PyObject *res; ! if (op == Py_EQ && !IS_SET(w)) res = Py_False; else if (op == Py_NE && !IS_SET(w)) res = Py_True; ! ! switch (op) { ! case Py_EQ: ! case Py_NE: return PyObject_RichCompare(((setobject *)v)->data, ((setobject *)w)->data, op); ! case Py_LE: ! return set_issubset((setobject *)v, w); ! case Py_GE: ! return set_issuperset((setobject *)v, w); ! case Py_LT: ! if (set_len(v) >= set_len((setobject *)w)) { ! Py_INCREF(Py_False); ! return Py_False; ! } ! return set_issubset((setobject *)v, w); ! case Py_GT: ! if (set_len(v) <= set_len((setobject *)w)) { ! Py_INCREF(Py_False); ! return Py_False; ! } ! return set_issuperset((setobject *)v, w); ! } ! Py_INCREF(Py_NotImplemented); ! return Py_NotImplemented; } *************** *** 420,423 **** --- 484,491 ---- {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, + {"issubset",(PyCFunction)set_issubset, METH_O, + issubset_doc}, + {"issuperset",(PyCFunction)set_issuperset, METH_O, + issuperset_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, *************** *** 509,512 **** --- 577,584 ---- {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, + {"issubset",(PyCFunction)set_issubset, METH_O, + issubset_doc}, + {"issuperset",(PyCFunction)set_issuperset, METH_O, + issuperset_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_set.py 13 Nov 2003 20:59:12 -0000 1.8 --- test_set.py 13 Nov 2003 22:23:58 -0000 1.9 *************** *** 103,106 **** --- 103,118 ---- self.assertRaises(TypeError, self.s.__cmp__, self.s) + def test_sub_and_super(self): + p, q, r = map(self.thetype, ['ab', 'abcde', 'def']) + self.assert_(p < q) + self.assert_(p <= q) + self.assert_(q <= q) + self.assert_(q > p) + self.assert_(q >= p) + self.failIf(q < r) + self.failIf(q <= r) + self.failIf(q > r) + self.failIf(q >= r) + class TestSet(TestJointOps): thetype = set From tim_one at users.sourceforge.net Thu Nov 13 17:48:44 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 17:48:52 2003 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.241.6.5, 2.241.6.6 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv6372/Objects Modified Files: Tag: release23-maint typeobject.c Log Message: subtype_dealloc(): A more complete fix for critical bug 840829 + expanded the test case with a piece that needs the more-complete fix. I don't intend to backport this beyond 2.3 maint. It's a critical bugfix, and should be backported to 2.2, 2.1, ..., if more releases in those lines get made. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.241.6.5 retrieving revision 2.241.6.6 diff -C2 -d -r2.241.6.5 -r2.241.6.6 *** typeobject.c 13 Nov 2003 01:17:55 -0000 2.241.6.5 --- typeobject.c 13 Nov 2003 22:48:42 -0000 2.241.6.6 *************** *** 640,647 **** Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. The weakref callback ! * (if any) may trigger GC, and if self is tracked at that point, ! * it will look like trash to GC and GC will try to delete it ! * again. Double-deallocation is a subtle disaster. */ --- 640,647 ---- Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; ! /* DO NOT restore GC tracking at this point. weakref callbacks ! * (if any, and whether directly here or indirectly in something we ! * call) may trigger GC, and if self is tracked at that point, it ! * will look like trash to GC and GC will try to delete self again. */ *************** *** 659,669 **** if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); - _PyObject_GC_TRACK(self); /* We'll untrack for real later */ /* Maybe call finalizer; exit early if resurrected */ if (type->tp_del) { type->tp_del(self); if (self->ob_refcnt > 0) ! goto endlabel; } --- 659,671 ---- if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); /* Maybe call finalizer; exit early if resurrected */ if (type->tp_del) { + _PyObject_GC_TRACK(self); type->tp_del(self); if (self->ob_refcnt > 0) ! goto endlabel; /* resurrected */ ! else ! _PyObject_GC_UNTRACK(self); } *************** *** 689,697 **** } ! /* Finalize GC if the base doesn't do GC and we do */ ! if (!PyType_IS_GC(base)) ! _PyObject_GC_UNTRACK(self); ! ! /* Call the base tp_dealloc() */ assert(basedealloc); basedealloc(self); --- 691,699 ---- } ! /* Call the base tp_dealloc(); first retrack self if ! * basedealloc knows about gc. ! */ ! if (PyType_IS_GC(base)) ! _PyObject_GC_TRACK(self); assert(basedealloc); basedealloc(self); *************** *** 730,733 **** --- 732,745 ---- trashcan begin GC track + + Q. Why did the last question say "immediately GC-track again"? + It's nowhere near immediately. + + A. Because the code *used* to re-track immediately. Bad Idea. + self has a refcount of 0, and if gc ever gets its hands on it + (which can happen if any weakref callback gets invoked), it + looks like trash to gc too, and gc also tries to delete self + then. But we're already deleting self. Double dealloction is + a subtle disaster. Q. Why the bizarre (net-zero) manipulation of From tim_one at users.sourceforge.net Thu Nov 13 17:48:44 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 17:48:56 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.28.6.1, 1.28.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv6372/Lib/test Modified Files: Tag: release23-maint test_weakref.py Log Message: subtype_dealloc(): A more complete fix for critical bug 840829 + expanded the test case with a piece that needs the more-complete fix. I don't intend to backport this beyond 2.3 maint. It's a critical bugfix, and should be backported to 2.2, 2.1, ..., if more releases in those lines get made. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.28.6.1 retrieving revision 1.28.6.2 diff -C2 -d -r1.28.6.1 -r1.28.6.2 *** test_weakref.py 13 Nov 2003 01:17:55 -0000 1.28.6.1 --- test_weakref.py 13 Nov 2003 22:48:42 -0000 1.28.6.2 *************** *** 319,322 **** --- 319,341 ---- del c + # There endeth the first part. It gets worse. + del wr + + c1 = C() + c1.i = C() + wr = weakref.ref(c1.i, lambda ignore: gc.collect()) + + c2 = C() + c2.c1 = c1 + del c1 # still alive because c2 points to it + + # Now when subtype_dealloc gets called on c2, it's not enough just + # that c2 is immune from gc while the weakref callbacks associated + # with c2 execute (there are none in this 2nd half of the test, btw). + # subtype_dealloc goes on to call the base classes' deallocs too, + # so any gc triggered by weakref callbacks associated with anything + # torn down by a base class dealloc can also trigger double + # deallocation of c2. + del c2 class Object: From tim_one at users.sourceforge.net Thu Nov 13 17:50:02 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 17:50:07 2003 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.252,2.253 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv6761/Objects Modified Files: typeobject.c Log Message: subtype_dealloc(): Simplified overly contorted retracking logic. With this change, I think subtype_dealloc is actually a smidgen less obscure than it was in 2.3 -- we got rid of a negation in an "if" . Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.252 retrieving revision 2.253 diff -C2 -d -r2.252 -r2.253 *** typeobject.c 13 Nov 2003 21:59:32 -0000 2.252 --- typeobject.c 13 Nov 2003 22:50:00 -0000 2.253 *************** *** 691,700 **** } ! /* Finalize GC if the base doesn't do GC and we do */ ! _PyObject_GC_TRACK(self); ! if (!PyType_IS_GC(base)) ! _PyObject_GC_UNTRACK(self); ! ! /* Call the base tp_dealloc() */ assert(basedealloc); basedealloc(self); --- 691,699 ---- } ! /* Call the base tp_dealloc(); first retrack self if ! * basedealloc knows about gc. ! */ ! if (PyType_IS_GC(base)) ! _PyObject_GC_TRACK(self); assert(basedealloc); basedealloc(self); From rhettinger at users.sourceforge.net Thu Nov 13 18:18:37 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 13 18:18:40 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.9, 1.10 test_set.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv12829 Modified Files: setobject.c test_set.py Log Message: Add clear(), add(), remove(), and discard(). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** setobject.c 13 Nov 2003 22:23:58 -0000 1.9 --- setobject.c 13 Nov 2003 23:18:34 -0000 1.10 *************** *** 412,416 **** static PyObject * ! set_richcompare(PyObject *v, PyObject *w, int op) { PyObject *res; --- 412,416 ---- static PyObject * ! set_richcompare(setobject *v, PyObject *w, int op) { PyObject *res; *************** *** 462,465 **** --- 462,517 ---- } + static PyObject * + set_clear(setobject *so) + { + PyDict_Clear(so->data); + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(clear_doc, "Remove all elements from this set."); + + static PyObject * + set_add(setobject *so, PyObject *item) + { + if (PyDict_SetItem(so->data, item, Py_True) == -1) + return NULL; + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(add_doc, + "Add an element to a set.\n\ + \n\ + This has no effect if the element is already present."); + + static PyObject * + set_remove(setobject *so, PyObject *item) + { + if (PyDict_DelItem(so->data, item) == -1) + return NULL; + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(remove_doc, + "Remove an element from a set; it must be a member.\n\ + \n\ + If the element is not a member, raise a KeyError."); + + static PyObject * + set_discard(setobject *so, PyObject *item) + { + if (PyDict_DelItem(so->data, item) == -1) + PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(discard_doc, + "Remove an element from a set if it is a member.\n\ + \n\ + If the element is not a member, do nothing."); + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 476,491 **** static PyMethodDef set_methods[] = { {"copy", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, {"__copy__", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, ! {"difference",(PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, ! {"issubset",(PyCFunction)set_issubset, METH_O, issubset_doc}, ! {"issuperset",(PyCFunction)set_issuperset, METH_O, issuperset_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, --- 528,551 ---- static PyMethodDef set_methods[] = { + {"add", (PyCFunction)set_add, METH_O, + add_doc}, + {"clear", (PyCFunction)set_clear, METH_NOARGS, + clear_doc}, {"copy", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, {"__copy__", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, ! {"discard", (PyCFunction)set_discard, METH_O, ! discard_doc}, ! {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, ! {"issubset", (PyCFunction)set_issubset, METH_O, issubset_doc}, ! {"issuperset", (PyCFunction)set_issuperset, METH_O, issuperset_doc}, + {"remove", (PyCFunction)set_remove, METH_O, + remove_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_set.py 13 Nov 2003 22:23:58 -0000 1.9 --- test_set.py 13 Nov 2003 23:18:34 -0000 1.10 *************** *** 121,124 **** --- 121,142 ---- self.assertRaises(TypeError, hash, self.s) + def test_clear(self): + self.s.clear() + self.assertEqual(self.s, set([])) + + def test_add(self): + self.s.add('Q') + self.assert_('Q' in self.s) + + def test_remove(self): + self.s.remove('a') + self.assert_('a' not in self.s) + self.assertRaises(KeyError, self.s.remove, 'Q') + + def test_discard(self): + self.s.discard('a') + self.assert_('a' not in self.s) + self.s.discard('Q') + class TestFrozenSet(TestJointOps): thetype = frozenset From tim_one at users.sourceforge.net Thu Nov 13 19:01:24 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 13 19:01:33 2003 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.72,2.73 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv21198/Modules Modified Files: gcmodule.c Log Message: update_refs(): assert that incoming refcounts aren't 0. The comment for this function has always claimed that was true, but it wasn't verified before. For the latest batch of "double deallocation" bugs (stemming from weakref callbacks invoked by way of subtype_dealloc), this assert would have triggered (instead of waiting for _Py_ForgetReference to die with a segfault later). Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -d -r2.72 -r2.73 *** gcmodule.c 4 Sep 2003 11:59:50 -0000 2.72 --- gcmodule.c 14 Nov 2003 00:01:17 -0000 2.73 *************** *** 215,218 **** --- 215,237 ---- assert(gc->gc.gc_refs == GC_REACHABLE); gc->gc.gc_refs = FROM_GC(gc)->ob_refcnt; + /* Python's cyclic gc should never see an incoming refcount + * of 0: if something decref'ed to 0, it should have been + * deallocated immediately at that time. + * Possible cause (if the assert triggers): a tp_dealloc + * routine left a gc-aware object tracked during its teardown + * phase, and did something-- or allowed something to happen -- + * that called back into Python. gc can trigger then, and may + * see the still-tracked dying object. Before this assert + * was added, such mistakes went on to allow gc to try to + * delete the object again. In a debug build, that caused + * a mysterious segfault, when _Py_ForgetReference tried + * to remove the object from the doubly-linked list of all + * objects a second time. In a release build, an actual + * double deallocation occurred, which leads to corruption + * of the allocator's internal bookkeeping pointers. That's + * so serious that maybe this should be a release-build + * check instead of an assert? + */ + assert(gc->gc.gc_refs != 0); } } From theller at users.sourceforge.net Fri Nov 14 05:23:06 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 05:23:12 2003 Subject: [Python-checkins] python/dist/src/Lib modulefinder.py,1.7,1.7.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv16442 Modified Files: Tag: release23-maint modulefinder.py Log Message: SF #841977 - modulefinder fails to find extension modules in packages The find_all_submodules() method in modulefinder only looks for *.py, *.pyc, and *.pyo files. Python extension modules are only found if they are referenced in import statements somewhere. This patch uses the actual list from imp.get_suffixes(). Backported to release-maint23. Index: modulefinder.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/modulefinder.py,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** modulefinder.py 18 Jul 2003 15:31:40 -0000 1.7 --- modulefinder.py 14 Nov 2003 10:23:03 -0000 1.7.6.1 *************** *** 211,215 **** return modules = {} ! suffixes = [".py", ".pyc", ".pyo"] for dir in m.__path__: try: --- 211,220 ---- return modules = {} ! # 'suffixes' used to be a list hardcoded to [".py", ".pyc", ".pyo"]. ! # But we must also collect Python extension modules - although ! # we cannot separate normal dlls from Python extensions. ! suffixes = [] ! for triple in imp.get_suffixes(): ! suffixes.append(triple[0]) for dir in m.__path__: try: From theller at users.sourceforge.net Fri Nov 14 05:27:31 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 05:27:35 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.74,1.831.4.75 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv17208 Modified Files: Tag: release23-maint NEWS Log Message: Mention patch #841977: modulefinder didn't find extension modules in packages Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.74 retrieving revision 1.831.4.75 diff -C2 -d -r1.831.4.74 -r1.831.4.75 *** NEWS 13 Nov 2003 01:17:55 -0000 1.831.4.74 --- NEWS 14 Nov 2003 10:27:26 -0000 1.831.4.75 *************** *** 49,52 **** --- 49,55 ---- ------- + - Patch #841977: modulefinder didn't find extension modules + in packages + - Bug #792101: Add missing file operations for httplib.SSLFile. From theller at users.sourceforge.net Fri Nov 14 05:28:44 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 05:28:57 2003 Subject: [Python-checkins] python/dist/src/Lib modulefinder.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv17380 Modified Files: modulefinder.py Log Message: SF #841977 - modulefinder fails to find extension modules in packages The find_all_submodules() method in modulefinder only looks for *.py, *.pyc, and *.pyo files. Python extension modules are only found if they are referenced in import statements somewhere. This patch uses the actual list from imp.get_suffixes(). Backported myself. Index: modulefinder.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/modulefinder.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** modulefinder.py 18 Jul 2003 15:31:40 -0000 1.7 --- modulefinder.py 14 Nov 2003 10:28:42 -0000 1.8 *************** *** 211,215 **** return modules = {} ! suffixes = [".py", ".pyc", ".pyo"] for dir in m.__path__: try: --- 211,220 ---- return modules = {} ! # 'suffixes' used to be a list hardcoded to [".py", ".pyc", ".pyo"]. ! # But we must also collect Python extension modules - although ! # we cannot separate normal dlls from Python extensions. ! suffixes = [] ! for triple in imp.get_suffixes(): ! suffixes.append(triple[0]) for dir in m.__path__: try: From theller at users.sourceforge.net Fri Nov 14 05:33:23 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 05:33:27 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.890,1.891 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv18199 Modified Files: NEWS Log Message: Mention patch #841977: modulefinder didn't find extension modules in packages Backported to release-maint23 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.890 retrieving revision 1.891 diff -C2 -d -r1.890 -r1.891 *** NEWS 12 Nov 2003 20:43:28 -0000 1.890 --- NEWS 14 Nov 2003 10:33:20 -0000 1.891 *************** *** 113,116 **** --- 113,118 ---- ------- + - Patch #841977: modulefinder didn't find extension modules in packages + - imaplib.IMAP4.thread was added. From rhettinger at users.sourceforge.net Fri Nov 14 08:54:28 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 14 08:54:40 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.10, 1.11 test_set.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv20089 Modified Files: setobject.c test_set.py Log Message: Add pop() and the in-place operations Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** setobject.c 13 Nov 2003 23:18:34 -0000 1.10 --- setobject.c 14 Nov 2003 13:54:26 -0000 1.11 *************** *** 172,175 **** --- 172,201 ---- static PyObject * + set_union_update(setobject *so, PyObject *other) + { + PyObject *item, *data, *it; + + it = PyObject_GetIter(other); + if (it == NULL) + return NULL; + data = so->data; + + while ((item = PyIter_Next(it)) != NULL) { + if (PyDict_SetItem(data, item, Py_True) == -1) { + Py_DECREF(it); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + Py_DECREF(item); + } + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(union_update_doc, + "Update a set with the union of itself and another."); + + static PyObject * set_or(setobject *so, PyObject *other) { *************** *** 182,185 **** --- 208,228 ---- static PyObject * + set_ior(setobject *so, PyObject *other) + { + PyObject *result; + + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + result = set_union_update(so, other); + if (result == NULL) + return NULL; + Py_DECREF(result); + Py_INCREF(so); + return (PyObject *)so; + } + + static PyObject * set_intersection(setobject *so, PyObject *other) { *************** *** 215,218 **** --- 258,305 ---- } + PyDoc_STRVAR(intersection_doc, + "Return the intersection of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in both sets.)\n"); + + static PyObject * + set_intersection_update(setobject *so, PyObject *other) + { + PyObject *item, *selfdata, *it, *newdict, *tmp; + + newdict = PyDict_New(); + if (newdict == NULL) + return newdict; + + it = PyObject_GetIter(other); + if (it == NULL) { + Py_DECREF(newdict); + return NULL; + } + + selfdata = so->data; + while ((item = PyIter_Next(it)) != NULL) { + if (DICT_CONTAINS(selfdata, item)) { + if (PyDict_SetItem(newdict, item, Py_True) == -1) { + Py_DECREF(newdict); + Py_DECREF(it); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + } + Py_DECREF(item); + } + Py_DECREF(it); + tmp = so->data; + so->data = newdict; + Py_DECREF(tmp); + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(intersection_update_doc, + "Update a set with the intersection of itself and another."); + static PyObject * set_and(setobject *so, PyObject *other) *************** *** 225,233 **** } ! PyDoc_STRVAR(intersection_doc, ! "Return the intersection of two sets as a new set.\n\ ! \n\ ! (i.e. all elements that are in both sets.)\n"); static PyObject * --- 312,331 ---- } ! static PyObject * ! set_iand(setobject *so, PyObject *other) ! { ! PyObject *result; + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + result = set_intersection_update(so, other); + if (result == NULL) + return NULL; + Py_DECREF(result); + Py_INCREF(so); + return (PyObject *)so; + } static PyObject * *************** *** 263,266 **** --- 361,387 ---- static PyObject * + set_difference_update(setobject *so, PyObject *other) + { + PyObject *item, *tgtdata, *it; + + it = PyObject_GetIter(other); + if (it == NULL) + return NULL; + + tgtdata = so->data; + while ((item = PyIter_Next(it)) != NULL) { + if (PyDict_DelItem(tgtdata, item) == -1) + PyErr_Clear(); + Py_DECREF(item); + } + Py_DECREF(it); + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(difference_update_doc, + "Remove all elements of another set from this set."); + + static PyObject * set_sub(setobject *so, PyObject *other) { *************** *** 273,276 **** --- 394,414 ---- static PyObject * + set_isub(setobject *so, PyObject *other) + { + PyObject *result; + + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + result = set_difference_update(so, other); + if (result == NULL) + return NULL; + Py_DECREF(result); + Py_INCREF(so); + return (PyObject *)so; + } + + static PyObject * set_symmetric_difference(setobject *so, PyObject *other) { *************** *** 319,327 **** PyDoc_STRVAR(symmetric_difference_doc, ! "Return the symmetric difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in exactly one of the sets.)\n"); static PyObject * set_xor(setobject *so, PyObject *other) { --- 457,516 ---- PyDoc_STRVAR(symmetric_difference_doc, ! "Return the symmetric difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in exactly one of the sets.)\n"); static PyObject * + set_symmetric_difference_update(setobject *so, PyObject *other) + { + PyObject *item, *selfdata, *it, *otherdata; + setobject *otherset = NULL; + + selfdata = so->data; + + if (PyDict_Check(other)) + otherdata = other; + else if (IS_SET(other)) + otherdata = ((setobject *)other)->data; + else { + otherset = (setobject *)make_new_set(so->ob_type, other); + if (otherset == NULL) + return NULL; + otherdata = otherset->data; + } + + it = PyObject_GetIter(otherdata); + if (it == NULL) + return NULL; + + while ((item = PyIter_Next(it)) != NULL) { + if (DICT_CONTAINS(selfdata, item)) { + if (PyDict_DelItem(selfdata, item) == -1) { + Py_XDECREF(otherset); + Py_DECREF(it); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + } else { + if (PyDict_SetItem(selfdata, item, Py_True) == -1) { + Py_XDECREF(otherset); + Py_DECREF(it); + PyErr_SetString(PyExc_ValueError, + "all set entries must be immutable"); + return NULL; + } + } + Py_DECREF(item); + } + Py_DECREF(it); + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(symmetric_difference_update_doc, + "Update a set with the symmetric difference of itself and another."); + + static PyObject * set_xor(setobject *so, PyObject *other) { *************** *** 333,336 **** --- 522,542 ---- } + static PyObject * + set_ixor(setobject *so, PyObject *other) + { + PyObject *result; + + if (!IS_SET(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + result = set_symmetric_difference_update(so, other); + if (result == NULL) + return NULL; + Py_DECREF(result); + Py_INCREF(so); + return (PyObject *)so; + } + PyObject * set_issubset(setobject *so, PyObject *other) *************** *** 514,517 **** --- 720,741 ---- If the element is not a member, do nothing."); + static PyObject * + set_pop(setobject *so) + { + PyObject *key, *value; + int pos = 0; + + if (!PyDict_Next(so->data, &pos, &key, &value)) { + PyErr_SetString(PyExc_KeyError, "pop from an empty set"); + return NULL; + } + if (PyDict_DelItem(so->data, key) == -1) + PyErr_Clear(); + Py_INCREF(key); + return key; + } + + PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 540,555 **** --- 764,789 ---- {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, + {"difference_update", (PyCFunction)set_difference_update, METH_O, + difference_update_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, + {"intersection_update",(PyCFunction)set_intersection_update, METH_O, + intersection_update_doc}, {"issubset", (PyCFunction)set_issubset, METH_O, issubset_doc}, {"issuperset", (PyCFunction)set_issuperset, METH_O, issuperset_doc}, + {"pop", (PyCFunction)set_pop, METH_NOARGS, + pop_doc}, {"remove", (PyCFunction)set_remove, METH_O, remove_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, + {"symmetric_difference_update",(PyCFunction)set_symmetric_difference_update, METH_O, + symmetric_difference_update_doc}, {"union", (PyCFunction)set_union, METH_O, union_doc}, + {"union_update",(PyCFunction)set_union_update, METH_O, + union_update_doc}, {NULL, NULL} /* sentinel */ }; *************** *** 573,576 **** --- 807,827 ---- (binaryfunc)set_xor, /*nb_xor*/ (binaryfunc)set_or, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + (binaryfunc)set_isub, /*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*/ + (binaryfunc)set_iand, /*nb_inplace_and*/ + (binaryfunc)set_ixor, /*nb_inplace_xor*/ + (binaryfunc)set_ior, /*nb_inplace_or*/ }; Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_set.py 13 Nov 2003 23:18:34 -0000 1.10 --- test_set.py 14 Nov 2003 13:54:26 -0000 1.11 *************** *** 7,11 **** def setUp(self): ! word = 'abracadabra' self.otherword = 'alacazam' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' --- 7,11 ---- def setUp(self): ! self.word = word = 'abracadabra' self.otherword = 'alacazam' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' *************** *** 138,141 **** --- 138,210 ---- self.assert_('a' not in self.s) self.s.discard('Q') + + def test_pop(self): + for i in xrange(len(self.s)): + elem = self.s.pop() + self.assert_(elem not in self.s) + self.assertRaises(KeyError, self.s.pop) + + def test_union_update(self): + retval = self.s.union_update(self.otherword) + self.assertEqual(retval, None) + for c in (self.word + self.otherword): + self.assert_(c in self.s) + + def test_ior(self): + self.s |= set(self.otherword) + for c in (self.word + self.otherword): + self.assert_(c in self.s) + + def test_intersection_update(self): + retval = self.s.intersection_update(self.otherword) + self.assertEqual(retval, None) + for c in (self.word + self.otherword): + if c in self.otherword and c in self.word: + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + + def test_iand(self): + self.s &= set(self.otherword) + for c in (self.word + self.otherword): + if c in self.otherword and c in self.word: + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + + def test_difference_update(self): + retval = self.s.difference_update(self.otherword) + self.assertEqual(retval, None) + for c in (self.word + self.otherword): + if c in self.word and c not in self.otherword: + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + + def test_isub(self): + self.s -= set(self.otherword) + for c in (self.word + self.otherword): + if c in self.word and c not in self.otherword: + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + + def test_symmetric_difference_update(self): + retval = self.s.symmetric_difference_update(self.otherword) + self.assertEqual(retval, None) + for c in (self.word + self.otherword): + if (c in self.word) ^ (c in self.otherword): + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + + def test_ixor(self): + self.s ^= set(self.otherword) + for c in (self.word + self.otherword): + if (c in self.word) ^ (c in self.otherword): + self.assert_(c in self.s) + else: + self.assert_(c not in self.s) + class TestFrozenSet(TestJointOps): From theller at users.sourceforge.net Fri Nov 14 13:33:16 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 13:33:24 2003 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.74.4.5, 2.74.4.6 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv15408 Modified Files: Tag: release23-maint patchlevel.h Log Message: Set version to 2.3.3a0. It would be better if this would be done immediately after a release is out ;-) Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.74.4.5 retrieving revision 2.74.4.6 diff -C2 -d -r2.74.4.5 -r2.74.4.6 *** patchlevel.h 4 Oct 2003 02:53:10 -0000 2.74.4.5 --- patchlevel.h 14 Nov 2003 18:33:13 -0000 2.74.4.6 *************** *** 22,31 **** #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 3 ! #define PY_MICRO_VERSION 2 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL #define PY_RELEASE_SERIAL 0 /* Version as a string */ ! #define PY_VERSION "2.3.2+" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 22,31 ---- #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 3 ! #define PY_MICRO_VERSION 3 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA #define PY_RELEASE_SERIAL 0 /* Version as a string */ ! #define PY_VERSION "2.3.3a0" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From theller at users.sourceforge.net Fri Nov 14 14:07:25 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 14 14:07:32 2003 Subject: [Python-checkins] python/dist/src/PCbuild python20.wse, 1.133.4.4, 1.133.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1:/tmp/cvs-serv23017 Modified Files: Tag: release23-maint python20.wse Log Message: Set version to 2.3.3a0. It would be better if this would be done immediately after a release is out ;-) Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.133.4.4 retrieving revision 1.133.4.5 diff -C2 -d -r1.133.4.4 -r1.133.4.5 *** python20.wse 16 Oct 2003 19:02:46 -0000 1.133.4.4 --- python20.wse 14 Nov 2003 19:07:21 -0000 1.133.4.5 *************** *** 2,6 **** item: Global Version=9.0 ! Title=Python 2.3.2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=9.0 ! Title=Python 2.3.3a0 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 21,27 **** MIF PDF Version=1.0 MIF SMS Version=2.0 ! EXE Filename=Python-2.3.2.exe Dialogs Version=8 ! Version File=2.3.2 Version Description=Python Programming Language Version Copyright=©2001-2003 Python Software Foundation --- 21,27 ---- MIF PDF Version=1.0 MIF SMS Version=2.0 ! EXE Filename=Python-2.3.3a0.exe Dialogs Version=8 ! Version File=2.3.3a0 Version Description=Python Programming Language Version Copyright=©2001-2003 Python Software Foundation *************** *** 77,81 **** item: Set Variable Variable=PYVER_STRING ! Value=2.3.2 end item: Remark --- 77,81 ---- item: Set Variable Variable=PYVER_STRING ! Value=2.3.3a0 end item: Remark From rhettinger at users.sourceforge.net Fri Nov 14 17:07:15 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 14 17:07:23 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.11, 1.12 test_set.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv27514 Modified Files: setobject.c test_set.py Log Message: Add __reduce__() for pickle support Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** setobject.c 14 Nov 2003 13:54:26 -0000 1.11 --- setobject.c 14 Nov 2003 22:07:13 -0000 1.12 *************** *** 14,18 **** */ ! /* Fast dictionary access macros */ #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) --- 14,18 ---- */ ! /* Fast access macros */ #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) *************** *** 738,741 **** --- 738,756 ---- PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); + PyObject * + set_reduce(setobject *so) + { + PyObject *keys, *args, *result; + + keys = PyDict_Keys(so->data); + args = PyTuple_Pack(1, keys); + result = PyTuple_Pack(2, so->ob_type, args); + Py_DECREF(args); + Py_DECREF(keys); + return result; + } + + PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 776,779 **** --- 791,796 ---- {"pop", (PyCFunction)set_pop, METH_NOARGS, pop_doc}, + {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, + reduce_doc}, {"remove", (PyCFunction)set_remove, METH_O, remove_doc}, *************** *** 892,895 **** --- 909,914 ---- {"issuperset",(PyCFunction)set_issuperset, METH_O, issuperset_doc}, + {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, + reduce_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_set.py 14 Nov 2003 13:54:26 -0000 1.11 --- test_set.py 14 Nov 2003 22:07:13 -0000 1.12 *************** *** 2,5 **** --- 2,6 ---- import unittest from test import test_support + import pickle class TestJointOps(unittest.TestCase): *************** *** 114,117 **** --- 115,126 ---- self.failIf(q > r) self.failIf(q >= r) + + def test_pickling(self): + # Note, pickling requires set() and frozenset() to be builtins + __builtins__.__dict__['set'] = set + __builtins__.__dict__['frozenset'] = frozenset + p = pickle.dumps(self.s) + dup = pickle.loads(p) + self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup)) class TestSet(TestJointOps): From rhettinger at users.sourceforge.net Fri Nov 14 17:59:30 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 14 17:59:37 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.12, 1.13 test_set.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv4733 Modified Files: setobject.c test_set.py Log Message: Make sets and frozensets interoperable. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** setobject.c 14 Nov 2003 22:07:13 -0000 1.12 --- setobject.c 14 Nov 2003 22:59:27 -0000 1.13 *************** *** 870,874 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ set_doc, /* tp_doc */ --- 870,874 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE, /* tp_flags */ set_doc, /* tp_doc */ *************** *** 965,969 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ frozenset_doc, /* tp_doc */ --- 965,969 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE, /* tp_flags */ frozenset_doc, /* tp_doc */ Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_set.py 14 Nov 2003 22:07:13 -0000 1.12 --- test_set.py 14 Nov 2003 22:59:28 -0000 1.13 *************** *** 34,38 **** def test_or(self): i = self.s.union(self.otherword) ! self.assertEqual(self.s | self.thetype(self.otherword), i) try: self.s | self.otherword --- 34,39 ---- def test_or(self): i = self.s.union(self.otherword) ! self.assertEqual(self.s | set(self.otherword), i) ! self.assertEqual(self.s | frozenset(self.otherword), i) try: self.s | self.otherword *************** *** 50,54 **** def test_and(self): i = self.s.intersection(self.otherword) ! self.assertEqual(self.s & self.thetype(self.otherword), i) try: self.s & self.otherword --- 51,56 ---- def test_and(self): i = self.s.intersection(self.otherword) ! self.assertEqual(self.s & set(self.otherword), i) ! self.assertEqual(self.s & frozenset(self.otherword), i) try: self.s & self.otherword *************** *** 66,70 **** def test_sub(self): i = self.s.difference(self.otherword) ! self.assertEqual(self.s - self.thetype(self.otherword), i) try: self.s - self.otherword --- 68,73 ---- def test_sub(self): i = self.s.difference(self.otherword) ! self.assertEqual(self.s - set(self.otherword), i) ! self.assertEqual(self.s - frozenset(self.otherword), i) try: self.s - self.otherword *************** *** 82,86 **** def test_xor(self): i = self.s.symmetric_difference(self.otherword) ! self.assertEqual(self.s ^ self.thetype(self.otherword), i) try: self.s ^ self.otherword --- 85,90 ---- def test_xor(self): i = self.s.symmetric_difference(self.otherword) ! self.assertEqual(self.s ^ set(self.otherword), i) ! self.assertEqual(self.s ^ frozenset(self.otherword), i) try: self.s ^ self.otherword From rhettinger at users.sourceforge.net Fri Nov 14 18:20:21 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 14 18:20:32 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv8958 Modified Files: setobject.c Log Message: Make sure frozen sets only compute the hash once. Add error checking to __reduce__(). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** setobject.c 14 Nov 2003 22:59:27 -0000 1.13 --- setobject.c 14 Nov 2003 23:20:19 -0000 1.14 *************** *** 24,27 **** --- 24,28 ---- PyObject_HEAD PyObject *data; + long hash; /* only used by frozenset objects */ } setobject; *************** *** 72,75 **** --- 73,77 ---- } so->data = data; + so->hash = -1; return (PyObject *)so; *************** *** 604,607 **** --- 606,612 ---- PyObject *it, *item; long hash = 0; + + if (so->hash != -1) + return so->hash; it = PyObject_GetIter(((setobject *)so)->data); *************** *** 613,618 **** Py_DECREF(item); } Py_DECREF(it); ! return hash; /* XXX Consider caching the hash value to save recomputations */ } --- 618,624 ---- Py_DECREF(item); } + so->hash = hash; Py_DECREF(it); ! return hash; } *************** *** 741,751 **** set_reduce(setobject *so) { ! PyObject *keys, *args, *result; keys = PyDict_Keys(so->data); args = PyTuple_Pack(1, keys); result = PyTuple_Pack(2, so->ob_type, args); ! Py_DECREF(args); ! Py_DECREF(keys); return result; } --- 747,762 ---- set_reduce(setobject *so) { ! PyObject *keys=NULL, *args=NULL, *result=NULL; keys = PyDict_Keys(so->data); + if (keys == NULL) + goto done; args = PyTuple_Pack(1, keys); + if (args == NULL) + goto done; result = PyTuple_Pack(2, so->ob_type, args); ! done: ! Py_XDECREF(args); ! Py_XDECREF(keys); return result; } From rhettinger at users.sourceforge.net Sat Nov 15 07:33:04 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 07:33:08 2003 Subject: [Python-checkins] python/dist/src/Modules heapqmodule.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv18706 Modified Files: heapqmodule.c Log Message: Verify heappop argument is a list. Index: heapqmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/heapqmodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** heapqmodule.c 8 Nov 2003 10:24:38 -0000 1.1 --- heapqmodule.c 15 Nov 2003 12:33:01 -0000 1.2 *************** *** 120,123 **** --- 120,128 ---- int n; + if (!PyList_Check(heap)) { + PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); + return NULL; + } + /* # raises appropriate IndexError if heap is empty */ n = PyList_GET_SIZE(heap); From rhettinger at users.sourceforge.net Sat Nov 15 07:40:30 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 07:40:33 2003 Subject: [Python-checkins] python/dist/src/Modules heapqmodule.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv19689 Modified Files: heapqmodule.c Log Message: Change ValueErrors to TypeErrors and add PyList_Check() assertions. Index: heapqmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/heapqmodule.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** heapqmodule.c 15 Nov 2003 12:33:01 -0000 1.2 --- heapqmodule.c 15 Nov 2003 12:40:28 -0000 1.3 *************** *** 15,18 **** --- 15,19 ---- int cmp, parentpos; + assert(PyList_Check(heap)); if (pos >= PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_IndexError, "index out of range"); *************** *** 49,52 **** --- 50,54 ---- PyObject *newitem, *tmp; + assert(PyList_Check(heap)); endpos = PyList_GET_SIZE(heap); startpos = pos; *************** *** 98,102 **** if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); return NULL; } --- 100,104 ---- if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_TypeError, "heap argument must be a list"); return NULL; } *************** *** 121,125 **** if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); return NULL; } --- 123,127 ---- if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_TypeError, "heap argument must be a list"); return NULL; } *************** *** 160,164 **** if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); return NULL; } --- 162,166 ---- if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_TypeError, "heap argument must be a list"); return NULL; } *************** *** 193,197 **** if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); return NULL; } --- 195,199 ---- if (!PyList_Check(heap)) { ! PyErr_SetString(PyExc_TypeError, "heap argument must be a list"); return NULL; } From rhettinger at users.sourceforge.net Sat Nov 15 08:46:42 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 08:46:50 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.14, 1.15 test_set.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv29637 Modified Files: setobject.c test_set.py Log Message: Add code to test ref counting. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** setobject.c 14 Nov 2003 23:20:19 -0000 1.14 --- setobject.c 15 Nov 2003 13:46:39 -0000 1.15 *************** *** 602,606 **** static long ! frozenset_hash(PyObject *so) { PyObject *it, *item; --- 602,606 ---- static long ! frozenset_hash(setobject *so) { PyObject *it, *item; Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_set.py 14 Nov 2003 22:59:28 -0000 1.13 --- test_set.py 15 Nov 2003 13:46:39 -0000 1.14 *************** *** 229,237 **** def test_main(verbose=None): from test import test_sets ! test_support.run_unittest( TestSet, TestFrozenSet, ) if __name__ == "__main__": --- 229,250 ---- def test_main(verbose=None): + import sys from test import test_sets ! test_classes = ( TestSet, TestFrozenSet, ) + + 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__": From guido at python.org Sat Nov 15 10:43:55 2003 From: guido at python.org (Guido van Rossum) Date: Sat Nov 15 10:44:00 2003 Subject: [Python-checkins] python/dist/src/Modules heapqmodule.c,1.1,1.2 In-Reply-To: Your message of "Sat, 15 Nov 2003 04:33:04 PST." References: Message-ID: <200311151543.hAFFhtv13945@12-236-54-216.client.attbi.com> > + if (!PyList_Check(heap)) { > + PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); > + return NULL; > + } > + As Tim suggested, this should be a TypeError. --Guido van Rossum (home page: http://www.python.org/~guido/) From rhettinger at users.sourceforge.net Sat Nov 15 11:05:49 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 11:05:53 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.15, 1.16 test_set.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv20094 Modified Files: setobject.c test_set.py Log Message: Fixups from the first detailed review: * Make all functions static * Error check the iterator when IterNext returns NULL * Match all the docstrings back to sets.py * Verify refcounts in every function and error exit * Add test for set.copy() * Verify that all methods from sets.py were implemented (__deepcopy()__ is still open) (__getstate__() and __setstate__() were replaced by __reduce__()) Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** setobject.c 15 Nov 2003 13:46:39 -0000 1.15 --- setobject.c 15 Nov 2003 16:05:46 -0000 1.16 *************** *** 65,68 **** --- 65,72 ---- } Py_XDECREF(it); + if (PyErr_Occurred()) { + Py_DECREF(data); + return NULL; + } /* create setobject structure */ *************** *** 165,168 **** --- 169,177 ---- Py_DECREF(item); } + Py_DECREF(it); + if (PyErr_Occurred()) { + Py_DECREF(result); + return NULL; + } return (PyObject *)result; } *************** *** 171,175 **** "Return the union of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in either set.)\n"); static PyObject * --- 180,184 ---- "Return the union of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in either set.)"); static PyObject * *************** *** 192,197 **** Py_DECREF(item); } ! Py_INCREF(Py_None); ! return Py_None; } --- 201,208 ---- Py_DECREF(item); } ! Py_DECREF(it); ! if (PyErr_Occurred()) ! return NULL; ! Py_RETURN_NONE; } *************** *** 257,260 **** --- 268,275 ---- } Py_DECREF(it); + if (PyErr_Occurred()) { + Py_DECREF(result); + return NULL; + } return (PyObject *)result; } *************** *** 263,267 **** "Return the intersection of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in both sets.)\n"); static PyObject * --- 278,282 ---- "Return the intersection of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in both sets.)"); static PyObject * *************** *** 294,302 **** } Py_DECREF(it); tmp = so->data; so->data = newdict; Py_DECREF(tmp); ! Py_INCREF(Py_None); ! return Py_None; } --- 309,320 ---- } Py_DECREF(it); + if (PyErr_Occurred()) { + Py_DECREF(newdict); + return NULL; + } tmp = so->data; so->data = newdict; Py_DECREF(tmp); ! Py_RETURN_NONE; } *************** *** 354,357 **** --- 372,379 ---- } Py_DECREF(it); + if (PyErr_Occurred()) { + Py_DECREF(result); + return NULL; + } return (PyObject *)result; } *************** *** 360,364 **** "Return the difference of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in the first set but not the second.)\n"); static PyObject * --- 382,386 ---- "Return the difference of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in this set but not the other.)"); static PyObject * *************** *** 378,383 **** } Py_DECREF(it); ! Py_INCREF(Py_None); ! return Py_None; } --- 400,406 ---- } Py_DECREF(it); ! if (PyErr_Occurred()) ! return NULL; ! Py_RETURN_NONE; } *************** *** 453,458 **** Py_DECREF(item); } ! Py_DECREF(otherset); return (PyObject *)result; } --- 476,485 ---- Py_DECREF(item); } ! Py_DECREF(it); Py_DECREF(otherset); + if (PyErr_Occurred()) { + Py_DECREF(result); + return NULL; + } return (PyObject *)result; } *************** *** 461,465 **** "Return the symmetric difference of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in exactly one of the sets.)\n"); static PyObject * --- 488,492 ---- "Return the symmetric difference of two sets as a new set.\n\ \n\ ! (i.e. all elements that are in exactly one of the sets.)"); static PyObject * *************** *** 506,512 **** Py_DECREF(item); } Py_DECREF(it); ! Py_INCREF(Py_None); ! return Py_None; } --- 533,541 ---- Py_DECREF(item); } + Py_XDECREF(otherset); Py_DECREF(it); ! if (PyErr_Occurred()) ! return NULL; ! Py_RETURN_NONE; } *************** *** 541,545 **** } ! PyObject * set_issubset(setobject *so, PyObject *other) { --- 570,574 ---- } ! static PyObject * set_issubset(setobject *so, PyObject *other) { *************** *** 550,558 **** return NULL; } ! if (set_len(so) > set_len((setobject *)other)) { ! Py_INCREF(Py_False); ! return Py_False; ! } ! it = PyObject_GetIter(so->data); if (it == NULL) --- 579,585 ---- return NULL; } ! if (set_len(so) > set_len((setobject *)other)) ! Py_RETURN_FALSE; ! it = PyObject_GetIter(so->data); if (it == NULL) *************** *** 564,579 **** Py_DECREF(it); Py_DECREF(item); ! Py_INCREF(Py_False); ! return Py_False; } Py_DECREF(item); } ! Py_INCREF(Py_True); ! return Py_True; } PyDoc_STRVAR(issubset_doc, "Report whether another set contains this set."); ! PyObject * set_issuperset(setobject *so, PyObject *other) { --- 591,605 ---- Py_DECREF(it); Py_DECREF(item); ! Py_RETURN_FALSE; } Py_DECREF(item); } ! Py_DECREF(it); ! Py_RETURN_TRUE; } PyDoc_STRVAR(issubset_doc, "Report whether another set contains this set."); ! static PyObject * set_issuperset(setobject *so, PyObject *other) { *************** *** 585,589 **** } ! PyDoc_STRVAR(issuperset_doc, "Report whether another set contains this set."); static long --- 611,615 ---- } ! PyDoc_STRVAR(issuperset_doc, "Report whether this set contains another set."); static long *************** *** 602,608 **** static long ! frozenset_hash(setobject *so) { PyObject *it, *item; long hash = 0; --- 628,635 ---- static long ! frozenset_hash(PyObject *self) { PyObject *it, *item; + setobject *so = (setobject *)self; long hash = 0; *************** *** 626,636 **** set_richcompare(setobject *v, PyObject *w, int op) { - PyObject *res; - if (op == Py_EQ && !IS_SET(w)) ! res = Py_False; else if (op == Py_NE && !IS_SET(w)) ! res = Py_True; ! switch (op) { case Py_EQ: --- 653,660 ---- set_richcompare(setobject *v, PyObject *w, int op) { if (op == Py_EQ && !IS_SET(w)) ! Py_RETURN_FALSE; else if (op == Py_NE && !IS_SET(w)) ! Py_RETURN_TRUE; switch (op) { case Py_EQ: *************** *** 643,656 **** return set_issuperset((setobject *)v, w); case Py_LT: ! if (set_len(v) >= set_len((setobject *)w)) { ! Py_INCREF(Py_False); ! return Py_False; ! } return set_issubset((setobject *)v, w); case Py_GT: ! if (set_len(v) <= set_len((setobject *)w)) { ! Py_INCREF(Py_False); ! return Py_False; ! } return set_issuperset((setobject *)v, w); } --- 667,676 ---- return set_issuperset((setobject *)v, w); case Py_LT: ! if (set_len(v) >= set_len((setobject *)w)) ! Py_RETURN_FALSE; return set_issubset((setobject *)v, w); case Py_GT: ! if (set_len(v) <= set_len((setobject *)w)) ! Py_RETURN_FALSE; return set_issuperset((setobject *)v, w); } *************** *** 744,748 **** PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); ! PyObject * set_reduce(setobject *so) { --- 764,768 ---- PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); ! static PyObject * set_reduce(setobject *so) { Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_set.py 15 Nov 2003 13:46:39 -0000 1.14 --- test_set.py 15 Nov 2003 16:05:46 -0000 1.15 *************** *** 4,7 **** --- 4,14 ---- import pickle + class PassThru(Exception): + pass + + def check_pass_thru(): + raise PassThru + yield 1 + class TestJointOps(unittest.TestCase): # Tests common to both set and frozenset *************** *** 18,21 **** --- 25,29 ---- expected = list.sorted(self.d) self.assertEqual(actual, expected) + self.assertRaises(PassThru, self.thetype, check_pass_thru()) def test_len(self): *************** *** 26,29 **** --- 34,42 ---- self.assertEqual(c in self.s, c in self.d) + def test_copy(self): + dup = self.s.copy() + self.assertEqual(self.s, dup) + self.assertNotEqual(id(self.s), id(dup)) + def test_union(self): u = self.s.union(self.otherword) *************** *** 31,34 **** --- 44,48 ---- self.assertEqual(c in u, c in self.d or c in self.otherword) self.assertEqual(type(u), self.thetype) + self.assertRaises(PassThru, self.s.union, check_pass_thru()) def test_or(self): *************** *** 48,51 **** --- 62,66 ---- self.assertEqual(c in i, c in self.d and c in self.otherword) self.assertEqual(type(i), self.thetype) + self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) def test_and(self): *************** *** 65,68 **** --- 80,84 ---- self.assertEqual(c in i, c in self.d and c not in self.otherword) self.assertEqual(type(i), self.thetype) + self.assertRaises(PassThru, self.s.difference, check_pass_thru()) def test_sub(self): *************** *** 82,85 **** --- 98,102 ---- self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) self.assertEqual(type(i), self.thetype) + self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) def test_xor(self): *************** *** 95,102 **** def test_equality(self): ! self.assertEqual(self.thetype('abcb'), set('bcac')) ! self.assertEqual(self.thetype('abcb'), frozenset('bcac')) ! self.assertNotEqual(self.thetype('abc'), set('def')) ! self.assertNotEqual(self.thetype('abc'), frozenset('def')) def test_setOfFrozensets(self): --- 112,121 ---- def test_equality(self): ! self.assertEqual(self.s, set(self.word)) ! self.assertEqual(self.s, frozenset(self.word)) ! self.assertEqual(self.s == self.word, False) ! self.assertNotEqual(self.s, set(self.otherword)) ! self.assertNotEqual(self.s, frozenset(self.otherword)) ! self.assertEqual(self.s != self.word, True) def test_setOfFrozensets(self): *************** *** 163,166 **** --- 182,186 ---- for c in (self.word + self.otherword): self.assert_(c in self.s) + self.assertRaises(PassThru, self.s.union_update, check_pass_thru()) def test_ior(self): *************** *** 177,180 **** --- 197,201 ---- else: self.assert_(c not in self.s) + self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru()) def test_iand(self): *************** *** 194,197 **** --- 215,219 ---- else: self.assert_(c not in self.s) + self.assertRaises(PassThru, self.s.difference_update, check_pass_thru()) def test_isub(self): *************** *** 211,214 **** --- 233,237 ---- else: self.assert_(c not in self.s) + self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru()) def test_ixor(self): From rhettinger at users.sourceforge.net Sat Nov 15 14:24:41 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 14:24:48 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj test_set.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv21616 Modified Files: test_set.py Log Message: Add in all the tests from the original test_sets.py. Commented out two groups that fail. Will research and fix. Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_set.py 15 Nov 2003 16:05:46 -0000 1.15 --- test_set.py 15 Nov 2003 19:24:39 -0000 1.16 *************** *** 2,7 **** --- 2,13 ---- import unittest from test import test_support + import operator + import copy import pickle + # Note, pickling requires set() and frozenset() to be builtins + __builtins__.__dict__['set'] = set + __builtins__.__dict__['frozenset'] = frozenset + class PassThru(Exception): pass *************** *** 140,146 **** def test_pickling(self): - # Note, pickling requires set() and frozenset() to be builtins - __builtins__.__dict__['set'] = set - __builtins__.__dict__['frozenset'] = frozenset p = pickle.dumps(self.s) dup = pickle.loads(p) --- 146,149 ---- *************** *** 251,254 **** --- 254,1000 ---- + # Tests takes from test_sets.py ============================================= + + empty_set = set() + + #============================================================================== + + class TestBasicOps(unittest.TestCase): + + def test_repr(self): + if self.repr is not None: + self.assertEqual(`self.set`, self.repr) + + def test_length(self): + self.assertEqual(len(self.set), self.length) + + def test_self_equality(self): + self.assertEqual(self.set, self.set) + + def test_equivalent_equality(self): + self.assertEqual(self.set, self.dup) + + def test_copy(self): + self.assertEqual(self.set.copy(), self.dup) + + def test_self_union(self): + result = self.set | self.set + self.assertEqual(result, self.dup) + + def test_empty_union(self): + result = self.set | empty_set + self.assertEqual(result, self.dup) + + def test_union_empty(self): + result = empty_set | self.set + self.assertEqual(result, self.dup) + + def test_self_intersection(self): + result = self.set & self.set + self.assertEqual(result, self.dup) + + def test_empty_intersection(self): + result = self.set & empty_set + self.assertEqual(result, empty_set) + + def test_intersection_empty(self): + result = empty_set & self.set + self.assertEqual(result, empty_set) + + def test_self_symmetric_difference(self): + result = self.set ^ self.set + self.assertEqual(result, empty_set) + + def checkempty_symmetric_difference(self): + result = self.set ^ empty_set + self.assertEqual(result, self.set) + + def test_self_difference(self): + result = self.set - self.set + self.assertEqual(result, empty_set) + + def test_empty_difference(self): + result = self.set - empty_set + self.assertEqual(result, self.dup) + + def test_empty_difference_rev(self): + result = empty_set - self.set + self.assertEqual(result, empty_set) + + def test_iteration(self): + for v in self.set: + self.assert_(v in self.values) + + def test_pickling(self): + p = pickle.dumps(self.set) + copy = pickle.loads(p) + self.assertEqual(self.set, copy, + "%s != %s" % (self.set, copy)) + + #------------------------------------------------------------------------------ + + class TestBasicOpsEmpty(TestBasicOps): + def setUp(self): + self.case = "empty set" + self.values = [] + self.set = set(self.values) + self.dup = set(self.values) + self.length = 0 + self.repr = "set([])" + + #------------------------------------------------------------------------------ + + class TestBasicOpsSingleton(TestBasicOps): + def setUp(self): + self.case = "unit set (number)" + self.values = [3] + self.set = set(self.values) + self.dup = set(self.values) + self.length = 1 + self.repr = "set([3])" + + def test_in(self): + self.failUnless(3 in self.set) + + def test_not_in(self): + self.failUnless(2 not in self.set) + + #------------------------------------------------------------------------------ + + class TestBasicOpsTuple(TestBasicOps): + def setUp(self): + self.case = "unit set (tuple)" + self.values = [(0, "zero")] + self.set = set(self.values) + self.dup = set(self.values) + self.length = 1 + self.repr = "set([(0, 'zero')])" + + def test_in(self): + self.failUnless((0, "zero") in self.set) + + def test_not_in(self): + self.failUnless(9 not in self.set) + + #------------------------------------------------------------------------------ + + class TestBasicOpsTriple(TestBasicOps): + def setUp(self): + self.case = "triple set" + self.values = [0, "zero", operator.add] + self.set = set(self.values) + self.dup = set(self.values) + self.length = 3 + self.repr = None + + #============================================================================== + + def baditer(): + raise TypeError + yield True + + def gooditer(): + yield True + + class TestExceptionPropagation(unittest.TestCase): + """SF 628246: Set constructor should not trap iterator TypeErrors""" + + def test_instanceWithException(self): + self.assertRaises(TypeError, set, baditer()) + + def test_instancesWithoutException(self): + # All of these iterables should load without exception. + set([1,2,3]) + set((1,2,3)) + set({'one':1, 'two':2, 'three':3}) + set(xrange(3)) + set('abc') + set(gooditer()) + + #============================================================================== + + class TestSetOfSets(unittest.TestCase): + def test_constructor(self): + inner = frozenset([1]) + outer = set([inner]) + element = outer.pop() + self.assertEqual(type(element), frozenset) + outer.add(inner) # Rebuild set of sets with .add method + outer.remove(inner) + self.assertEqual(outer, set()) # Verify that remove worked + outer.discard(inner) # Absence of KeyError indicates working fine + + #============================================================================== + + class TestBinaryOps(unittest.TestCase): + def setUp(self): + self.set = set((2, 4, 6)) + + def test_eq(self): # SF bug 643115 + self.assertEqual(self.set, set({2:1,4:3,6:5})) + + def test_union_subset(self): + result = self.set | set([2]) + self.assertEqual(result, set((2, 4, 6))) + + def test_union_superset(self): + result = self.set | set([2, 4, 6, 8]) + self.assertEqual(result, set([2, 4, 6, 8])) + + def test_union_overlap(self): + result = self.set | set([3, 4, 5]) + self.assertEqual(result, set([2, 3, 4, 5, 6])) + + def test_union_non_overlap(self): + result = self.set | set([8]) + self.assertEqual(result, set([2, 4, 6, 8])) + + def test_intersection_subset(self): + result = self.set & set((2, 4)) + self.assertEqual(result, set((2, 4))) + + def test_intersection_superset(self): + result = self.set & set([2, 4, 6, 8]) + self.assertEqual(result, set([2, 4, 6])) + + def test_intersection_overlap(self): + result = self.set & set([3, 4, 5]) + self.assertEqual(result, set([4])) + + def test_intersection_non_overlap(self): + result = self.set & set([8]) + self.assertEqual(result, empty_set) + + def test_sym_difference_subset(self): + result = self.set ^ set((2, 4)) + self.assertEqual(result, set([6])) + + def test_sym_difference_superset(self): + result = self.set ^ set((2, 4, 6, 8)) + self.assertEqual(result, set([8])) + + def test_sym_difference_overlap(self): + result = self.set ^ set((3, 4, 5)) + self.assertEqual(result, set([2, 3, 5, 6])) + + def test_sym_difference_non_overlap(self): + result = self.set ^ set([8]) + self.assertEqual(result, set([2, 4, 6, 8])) + + ## def test_cmp(self): + ## a, b = set('a'), set('b') + ## self.assertRaises(TypeError, cmp, a, b) + ## + ## # You can view this as a buglet: cmp(a, a) does not raise TypeError, + ## # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True, + ## # which Python thinks is good enough to synthesize a cmp() result + ## # without calling __cmp__. + ## self.assertEqual(cmp(a, a), 0) + ## + ## self.assertRaises(TypeError, cmp, a, 12) + ## self.assertRaises(TypeError, cmp, "abc", a) + + #============================================================================== + + class TestUpdateOps(unittest.TestCase): + def setUp(self): + self.set = set((2, 4, 6)) + + def test_union_subset(self): + self.set |= set([2]) + self.assertEqual(self.set, set((2, 4, 6))) + + def test_union_superset(self): + self.set |= set([2, 4, 6, 8]) + self.assertEqual(self.set, set([2, 4, 6, 8])) + + def test_union_overlap(self): + self.set |= set([3, 4, 5]) + self.assertEqual(self.set, set([2, 3, 4, 5, 6])) + + def test_union_non_overlap(self): + self.set |= set([8]) + self.assertEqual(self.set, set([2, 4, 6, 8])) + + def test_union_method_call(self): + self.set.union_update(set([3, 4, 5])) + self.assertEqual(self.set, set([2, 3, 4, 5, 6])) + + def test_intersection_subset(self): + self.set &= set((2, 4)) + self.assertEqual(self.set, set((2, 4))) + + def test_intersection_superset(self): + self.set &= set([2, 4, 6, 8]) + self.assertEqual(self.set, set([2, 4, 6])) + + def test_intersection_overlap(self): + self.set &= set([3, 4, 5]) + self.assertEqual(self.set, set([4])) + + def test_intersection_non_overlap(self): + self.set &= set([8]) + self.assertEqual(self.set, empty_set) + + def test_intersection_method_call(self): + self.set.intersection_update(set([3, 4, 5])) + self.assertEqual(self.set, set([4])) + + def test_sym_difference_subset(self): + self.set ^= set((2, 4)) + self.assertEqual(self.set, set([6])) + + def test_sym_difference_superset(self): + self.set ^= set((2, 4, 6, 8)) + self.assertEqual(self.set, set([8])) + + def test_sym_difference_overlap(self): + self.set ^= set((3, 4, 5)) + self.assertEqual(self.set, set([2, 3, 5, 6])) + + def test_sym_difference_non_overlap(self): + self.set ^= set([8]) + self.assertEqual(self.set, set([2, 4, 6, 8])) + + def test_sym_difference_method_call(self): + self.set.symmetric_difference_update(set([3, 4, 5])) + self.assertEqual(self.set, set([2, 3, 5, 6])) + + def test_difference_subset(self): + self.set -= set((2, 4)) + self.assertEqual(self.set, set([6])) + + def test_difference_superset(self): + self.set -= set((2, 4, 6, 8)) + self.assertEqual(self.set, set([])) + + def test_difference_overlap(self): + self.set -= set((3, 4, 5)) + self.assertEqual(self.set, set([2, 6])) + + def test_difference_non_overlap(self): + self.set -= set([8]) + self.assertEqual(self.set, set([2, 4, 6])) + + def test_difference_method_call(self): + self.set.difference_update(set([3, 4, 5])) + self.assertEqual(self.set, set([2, 6])) + + #============================================================================== + + class TestMutate(unittest.TestCase): + def setUp(self): + self.values = ["a", "b", "c"] + self.set = set(self.values) + + def test_add_present(self): + self.set.add("c") + self.assertEqual(self.set, set("abc")) + + def test_add_absent(self): + self.set.add("d") + self.assertEqual(self.set, set("abcd")) + + def test_add_until_full(self): + tmp = set() + expected_len = 0 + for v in self.values: + tmp.add(v) + expected_len += 1 + self.assertEqual(len(tmp), expected_len) + self.assertEqual(tmp, self.set) + + def test_remove_present(self): + self.set.remove("b") + self.assertEqual(self.set, set("ac")) + + def test_remove_absent(self): + try: + self.set.remove("d") + self.fail("Removing missing element should have raised LookupError") + except LookupError: + pass + + def test_remove_until_empty(self): + expected_len = len(self.set) + for v in self.values: + self.set.remove(v) + expected_len -= 1 + self.assertEqual(len(self.set), expected_len) + + def test_discard_present(self): + self.set.discard("c") + self.assertEqual(self.set, set("ab")) + + def test_discard_absent(self): + self.set.discard("d") + self.assertEqual(self.set, set("abc")) + + def test_clear(self): + self.set.clear() + self.assertEqual(len(self.set), 0) + + def test_pop(self): + popped = {} + while self.set: + popped[self.set.pop()] = None + self.assertEqual(len(popped), len(self.values)) + for v in self.values: + self.failUnless(v in popped) + + def test_update_empty_tuple(self): + self.set.union_update(()) + self.assertEqual(self.set, set(self.values)) + + def test_update_unit_tuple_overlap(self): + self.set.union_update(("a",)) + self.assertEqual(self.set, set(self.values)) + + def test_update_unit_tuple_non_overlap(self): + self.set.union_update(("a", "z")) + self.assertEqual(self.set, set(self.values + ["z"])) + + #============================================================================== + + class TestSubsets(unittest.TestCase): + + case2method = {"<=": "issubset", + ">=": "issuperset", + } + + reverse = {"==": "==", + "!=": "!=", + "<": ">", + ">": "<", + "<=": ">=", + ">=": "<=", + } + + def test_issubset(self): + x = self.left + y = self.right + for case in "!=", "==", "<", "<=", ">", ">=": + expected = case in self.cases + # Test the binary infix spelling. + result = eval("x" + case + "y", locals()) + self.assertEqual(result, expected) + # Test the "friendly" method-name spelling, if one exists. + if case in TestSubsets.case2method: + method = getattr(x, TestSubsets.case2method[case]) + result = method(y) + self.assertEqual(result, expected) + + # Now do the same for the operands reversed. + rcase = TestSubsets.reverse[case] + result = eval("y" + rcase + "x", locals()) + self.assertEqual(result, expected) + if rcase in TestSubsets.case2method: + method = getattr(y, TestSubsets.case2method[rcase]) + result = method(x) + self.assertEqual(result, expected) + #------------------------------------------------------------------------------ + + class TestSubsetEqualEmpty(TestSubsets): + left = set() + right = set() + name = "both empty" + cases = "==", "<=", ">=" + + #------------------------------------------------------------------------------ + + class TestSubsetEqualNonEmpty(TestSubsets): + left = set([1, 2]) + right = set([1, 2]) + name = "equal pair" + cases = "==", "<=", ">=" + + #------------------------------------------------------------------------------ + + class TestSubsetEmptyNonEmpty(TestSubsets): + left = set() + right = set([1, 2]) + name = "one empty, one non-empty" + cases = "!=", "<", "<=" + + #------------------------------------------------------------------------------ + + class TestSubsetPartial(TestSubsets): + left = set([1]) + right = set([1, 2]) + name = "one a non-empty proper subset of other" + cases = "!=", "<", "<=" + + #------------------------------------------------------------------------------ + + class TestSubsetNonOverlap(TestSubsets): + left = set([1]) + right = set([2]) + name = "neither empty, neither contains" + cases = "!=" + + #============================================================================== + + class TestOnlySetsInBinaryOps(unittest.TestCase): + + def test_eq_ne(self): + # Unlike the others, this is testing that == and != *are* allowed. + self.assertEqual(self.other == self.set, False) + self.assertEqual(self.set == self.other, False) + self.assertEqual(self.other != self.set, True) + self.assertEqual(self.set != self.other, True) + + def test_ge_gt_le_lt(self): + self.assertRaises(TypeError, lambda: self.set < self.other) + self.assertRaises(TypeError, lambda: self.set <= self.other) + self.assertRaises(TypeError, lambda: self.set > self.other) + self.assertRaises(TypeError, lambda: self.set >= self.other) + + self.assertRaises(TypeError, lambda: self.other < self.set) + self.assertRaises(TypeError, lambda: self.other <= self.set) + self.assertRaises(TypeError, lambda: self.other > self.set) + self.assertRaises(TypeError, lambda: self.other >= self.set) + + def test_union_update_operator(self): + try: + self.set |= self.other + except TypeError: + pass + else: + self.fail("expected TypeError") + + def test_union_update(self): + if self.otherIsIterable: + self.set.union_update(self.other) + else: + self.assertRaises(TypeError, self.set.union_update, self.other) + + def test_union(self): + self.assertRaises(TypeError, lambda: self.set | self.other) + self.assertRaises(TypeError, lambda: self.other | self.set) + if self.otherIsIterable: + self.set.union(self.other) + else: + self.assertRaises(TypeError, self.set.union, self.other) + + def test_intersection_update_operator(self): + try: + self.set &= self.other + except TypeError: + pass + else: + self.fail("expected TypeError") + + def test_intersection_update(self): + if self.otherIsIterable: + self.set.intersection_update(self.other) + else: + self.assertRaises(TypeError, + self.set.intersection_update, + self.other) + + def test_intersection(self): + self.assertRaises(TypeError, lambda: self.set & self.other) + self.assertRaises(TypeError, lambda: self.other & self.set) + if self.otherIsIterable: + self.set.intersection(self.other) + else: + self.assertRaises(TypeError, self.set.intersection, self.other) + + def test_sym_difference_update_operator(self): + try: + self.set ^= self.other + except TypeError: + pass + else: + self.fail("expected TypeError") + + def test_sym_difference_update(self): + if self.otherIsIterable: + self.set.symmetric_difference_update(self.other) + else: + self.assertRaises(TypeError, + self.set.symmetric_difference_update, + self.other) + + def test_sym_difference(self): + self.assertRaises(TypeError, lambda: self.set ^ self.other) + self.assertRaises(TypeError, lambda: self.other ^ self.set) + if self.otherIsIterable: + self.set.symmetric_difference(self.other) + else: + self.assertRaises(TypeError, self.set.symmetric_difference, self.other) + + def test_difference_update_operator(self): + try: + self.set -= self.other + except TypeError: + pass + else: + self.fail("expected TypeError") + + def test_difference_update(self): + if self.otherIsIterable: + self.set.difference_update(self.other) + else: + self.assertRaises(TypeError, + self.set.difference_update, + self.other) + + def test_difference(self): + self.assertRaises(TypeError, lambda: self.set - self.other) + self.assertRaises(TypeError, lambda: self.other - self.set) + if self.otherIsIterable: + self.set.difference(self.other) + else: + self.assertRaises(TypeError, self.set.difference, self.other) + + #------------------------------------------------------------------------------ + + class TestOnlySetsNumeric(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = 19 + self.otherIsIterable = False + + #------------------------------------------------------------------------------ + + class TestOnlySetsDict(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = {1:2, 3:4} + self.otherIsIterable = True + + #------------------------------------------------------------------------------ + + class TestOnlySetsOperator(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = operator.add + self.otherIsIterable = False + + #------------------------------------------------------------------------------ + + class TestOnlySetsTuple(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = (2, 4, 6) + self.otherIsIterable = True + + #------------------------------------------------------------------------------ + + class TestOnlySetsString(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = 'abc' + self.otherIsIterable = True + + #------------------------------------------------------------------------------ + + class TestOnlySetsGenerator(TestOnlySetsInBinaryOps): + def setUp(self): + def gen(): + for i in xrange(0, 10, 2): + yield i + self.set = set((1, 2, 3)) + self.other = gen() + self.otherIsIterable = True + + #============================================================================== + + class TestCopying(unittest.TestCase): + + def test_copy(self): + dup = self.set.copy() + dup_list = list(dup); dup_list.sort() + set_list = list(self.set); set_list.sort() + self.assertEqual(len(dup_list), len(set_list)) + for i in range(len(dup_list)): + self.failUnless(dup_list[i] is set_list[i]) + + def test_deep_copy(self): + dup = copy.deepcopy(self.set) + ##print type(dup), `dup` + dup_list = list(dup); dup_list.sort() + set_list = list(self.set); set_list.sort() + self.assertEqual(len(dup_list), len(set_list)) + for i in range(len(dup_list)): + self.assertEqual(dup_list[i], set_list[i]) + + #------------------------------------------------------------------------------ + + class TestCopyingEmpty(TestCopying): + def setUp(self): + self.set = set() + + #------------------------------------------------------------------------------ + + class TestCopyingSingleton(TestCopying): + def setUp(self): + self.set = set(["hello"]) + + #------------------------------------------------------------------------------ + + class TestCopyingTriple(TestCopying): + def setUp(self): + self.set = set(["zero", 0, None]) + + #------------------------------------------------------------------------------ + + class TestCopyingTuple(TestCopying): + def setUp(self): + self.set = set([(1, 2)]) + + #------------------------------------------------------------------------------ + + class TestCopyingNested(TestCopying): + def setUp(self): + self.set = set([((1, 2), (3, 4))]) + + #============================================================================== + + class TestIdentities(unittest.TestCase): + def setUp(self): + self.a = set('abracadabra') + self.b = set('alacazam') + + def test_binopsVsSubsets(self): + a, b = self.a, self.b + self.assert_(a - b < a) + self.assert_(b - a < b) + self.assert_(a & b < a) + self.assert_(a & b < b) + self.assert_(a | b > a) + self.assert_(a | b > b) + self.assert_(a ^ b < a | b) + + def test_commutativity(self): + a, b = self.a, self.b + self.assertEqual(a&b, b&a) + self.assertEqual(a|b, b|a) + self.assertEqual(a^b, b^a) + if a != b: + self.assertNotEqual(a-b, b-a) + + def test_summations(self): + # check that sums of parts equal the whole + a, b = self.a, self.b + self.assertEqual((a-b)|(a&b)|(b-a), a|b) + self.assertEqual((a&b)|(a^b), a|b) + self.assertEqual(a|(b-a), a|b) + self.assertEqual((a-b)|b, a|b) + self.assertEqual((a-b)|(a&b), a) + self.assertEqual((b-a)|(a&b), b) + self.assertEqual((a-b)|(b-a), a^b) + + def test_exclusion(self): + # check that inverse operations show non-overlap + a, b, zero = self.a, self.b, set() + self.assertEqual((a-b)&b, zero) + self.assertEqual((b-a)&a, zero) + self.assertEqual((a&b)&(a^b), zero) + + #============================================================================== + + def test_main(verbose=None): import sys *************** *** 257,260 **** --- 1003,1032 ---- TestSet, TestFrozenSet, + TestBasicOpsEmpty, + TestBasicOpsSingleton, + TestBasicOpsTuple, + TestBasicOpsTriple, + TestExceptionPropagation, + TestSetOfSets, + TestBinaryOps, + TestUpdateOps, + TestMutate, + TestSubsetEqualEmpty, + TestSubsetEqualNonEmpty, + TestSubsetEmptyNonEmpty, + TestSubsetPartial, + TestSubsetNonOverlap, + ## TestOnlySetsNumeric, + ## TestOnlySetsDict, + ## TestOnlySetsOperator, + ## TestOnlySetsTuple, + ## TestOnlySetsString, + ## TestOnlySetsGenerator, + TestCopyingEmpty, + TestCopyingSingleton, + TestCopyingTriple, + TestCopyingTuple, + TestCopyingNested, + TestIdentities, ) From rhettinger at users.sourceforge.net Sat Nov 15 15:18:28 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 15:18:34 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.16, 1.17 test_set.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv30132 Modified Files: setobject.c test_set.py Log Message: * Catch non-set arguments to comparision operators. * Re-enable the related tests * Reorder the test class listing to match test_set.py * Narrow down the remaining problem to forms like: 3 & myset Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** setobject.c 15 Nov 2003 16:05:46 -0000 1.16 --- setobject.c 15 Nov 2003 20:18:26 -0000 1.17 *************** *** 657,660 **** --- 657,664 ---- else if (op == Py_NE && !IS_SET(w)) Py_RETURN_TRUE; + if (!IS_SET(w)) { + PyErr_SetString(PyExc_TypeError, "can only compare to a set"); + return NULL; + } switch (op) { case Py_EQ: Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_set.py 15 Nov 2003 19:24:39 -0000 1.16 --- test_set.py 15 Nov 2003 20:18:26 -0000 1.17 *************** *** 482,497 **** self.assertEqual(result, set([2, 4, 6, 8])) ! ## def test_cmp(self): ! ## a, b = set('a'), set('b') ! ## self.assertRaises(TypeError, cmp, a, b) ! ## ! ## # You can view this as a buglet: cmp(a, a) does not raise TypeError, ! ## # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True, ! ## # which Python thinks is good enough to synthesize a cmp() result ! ## # without calling __cmp__. ! ## self.assertEqual(cmp(a, a), 0) ! ## ! ## self.assertRaises(TypeError, cmp, a, 12) ! ## self.assertRaises(TypeError, cmp, "abc", a) #============================================================================== --- 482,497 ---- self.assertEqual(result, set([2, 4, 6, 8])) ! def test_cmp(self): ! a, b = set('a'), set('b') ! self.assertRaises(TypeError, cmp, a, b) ! ! # You can view this as a buglet: cmp(a, a) does not raise TypeError, ! # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True, ! # which Python thinks is good enough to synthesize a cmp() result ! # without calling __cmp__. ! self.assertEqual(cmp(a, a), 0) ! ! self.assertRaises(TypeError, cmp, a, 12) ! self.assertRaises(TypeError, cmp, "abc", a) #============================================================================== *************** *** 771,775 **** def test_union(self): self.assertRaises(TypeError, lambda: self.set | self.other) ! self.assertRaises(TypeError, lambda: self.other | self.set) if self.otherIsIterable: self.set.union(self.other) --- 771,775 ---- def test_union(self): self.assertRaises(TypeError, lambda: self.set | self.other) ! ## self.assertRaises(TypeError, lambda: self.other | self.set) if self.otherIsIterable: self.set.union(self.other) *************** *** 795,799 **** def test_intersection(self): self.assertRaises(TypeError, lambda: self.set & self.other) ! self.assertRaises(TypeError, lambda: self.other & self.set) if self.otherIsIterable: self.set.intersection(self.other) --- 795,799 ---- def test_intersection(self): self.assertRaises(TypeError, lambda: self.set & self.other) ! ## self.assertRaises(TypeError, lambda: self.other & self.set) if self.otherIsIterable: self.set.intersection(self.other) *************** *** 819,823 **** def test_sym_difference(self): self.assertRaises(TypeError, lambda: self.set ^ self.other) ! self.assertRaises(TypeError, lambda: self.other ^ self.set) if self.otherIsIterable: self.set.symmetric_difference(self.other) --- 819,823 ---- def test_sym_difference(self): self.assertRaises(TypeError, lambda: self.set ^ self.other) ! ## self.assertRaises(TypeError, lambda: self.other ^ self.set) if self.otherIsIterable: self.set.symmetric_difference(self.other) *************** *** 843,847 **** def test_difference(self): self.assertRaises(TypeError, lambda: self.set - self.other) ! self.assertRaises(TypeError, lambda: self.other - self.set) if self.otherIsIterable: self.set.difference(self.other) --- 843,847 ---- def test_difference(self): self.assertRaises(TypeError, lambda: self.set - self.other) ! ## self.assertRaises(TypeError, lambda: self.other - self.set) if self.otherIsIterable: self.set.difference(self.other) *************** *** 996,1000 **** #============================================================================== - def test_main(verbose=None): import sys --- 996,999 ---- *************** *** 1003,1012 **** TestSet, TestFrozenSet, TestBasicOpsEmpty, TestBasicOpsSingleton, TestBasicOpsTuple, TestBasicOpsTriple, - TestExceptionPropagation, - TestSetOfSets, TestBinaryOps, TestUpdateOps, --- 1002,1011 ---- TestSet, TestFrozenSet, + TestSetOfSets, + TestExceptionPropagation, TestBasicOpsEmpty, TestBasicOpsSingleton, TestBasicOpsTuple, TestBasicOpsTriple, TestBinaryOps, TestUpdateOps, *************** *** 1017,1026 **** TestSubsetPartial, TestSubsetNonOverlap, ! ## TestOnlySetsNumeric, ! ## TestOnlySetsDict, ! ## TestOnlySetsOperator, ! ## TestOnlySetsTuple, ! ## TestOnlySetsString, ! ## TestOnlySetsGenerator, TestCopyingEmpty, TestCopyingSingleton, --- 1016,1025 ---- TestSubsetPartial, TestSubsetNonOverlap, ! TestOnlySetsNumeric, ! TestOnlySetsDict, ! TestOnlySetsOperator, ! TestOnlySetsTuple, ! TestOnlySetsString, ! TestOnlySetsGenerator, TestCopyingEmpty, TestCopyingSingleton, From rhettinger at users.sourceforge.net Sat Nov 15 15:41:39 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 15:41:43 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.17, 1.18 test_set.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv1456 Modified Files: setobject.c test_set.py Log Message: Type check left-hand argument for binary operators. Re-enable related test. Now, all tests run without exception. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** setobject.c 15 Nov 2003 20:18:26 -0000 1.17 --- setobject.c 15 Nov 2003 20:41:37 -0000 1.18 *************** *** 51,58 **** } ! while (it != NULL) { ! item = PyIter_Next(it); ! if (item == NULL) ! break; // XXX add error checking if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); --- 51,55 ---- } ! while (it != NULL && (item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); *************** *** 187,190 **** --- 184,188 ---- PyObject *item, *data, *it; + printf("AAA"); it = PyObject_GetIter(other); if (it == NULL) *************** *** 213,217 **** set_or(setobject *so, PyObject *other) { ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 211,216 ---- set_or(setobject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { ! printf("YYY"); Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 325,329 **** set_and(setobject *so, PyObject *other) { ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 324,328 ---- set_and(setobject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 411,415 **** set_sub(setobject *so, PyObject *other) { ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 410,414 ---- set_sub(setobject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 546,550 **** set_xor(setobject *so, PyObject *other) { ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 545,549 ---- set_xor(setobject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_set.py 15 Nov 2003 20:18:26 -0000 1.17 --- test_set.py 15 Nov 2003 20:41:37 -0000 1.18 *************** *** 21,26 **** def setUp(self): ! self.word = word = 'abracadabra' ! self.otherword = 'alacazam' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' self.s = self.thetype(word) --- 21,26 ---- def setUp(self): ! self.word = word = 'simsalabim' ! self.otherword = 'madagascar' self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' self.s = self.thetype(word) *************** *** 771,775 **** def test_union(self): self.assertRaises(TypeError, lambda: self.set | self.other) ! ## self.assertRaises(TypeError, lambda: self.other | self.set) if self.otherIsIterable: self.set.union(self.other) --- 771,775 ---- def test_union(self): self.assertRaises(TypeError, lambda: self.set | self.other) ! self.assertRaises(TypeError, lambda: self.other | self.set) if self.otherIsIterable: self.set.union(self.other) *************** *** 795,799 **** def test_intersection(self): self.assertRaises(TypeError, lambda: self.set & self.other) ! ## self.assertRaises(TypeError, lambda: self.other & self.set) if self.otherIsIterable: self.set.intersection(self.other) --- 795,799 ---- def test_intersection(self): self.assertRaises(TypeError, lambda: self.set & self.other) ! self.assertRaises(TypeError, lambda: self.other & self.set) if self.otherIsIterable: self.set.intersection(self.other) *************** *** 819,823 **** def test_sym_difference(self): self.assertRaises(TypeError, lambda: self.set ^ self.other) ! ## self.assertRaises(TypeError, lambda: self.other ^ self.set) if self.otherIsIterable: self.set.symmetric_difference(self.other) --- 819,823 ---- def test_sym_difference(self): self.assertRaises(TypeError, lambda: self.set ^ self.other) ! self.assertRaises(TypeError, lambda: self.other ^ self.set) if self.otherIsIterable: self.set.symmetric_difference(self.other) *************** *** 843,847 **** def test_difference(self): self.assertRaises(TypeError, lambda: self.set - self.other) ! ## self.assertRaises(TypeError, lambda: self.other - self.set) if self.otherIsIterable: self.set.difference(self.other) --- 843,847 ---- def test_difference(self): self.assertRaises(TypeError, lambda: self.set - self.other) ! self.assertRaises(TypeError, lambda: self.other - self.set) if self.otherIsIterable: self.set.difference(self.other) From rhettinger at users.sourceforge.net Sat Nov 15 16:39:31 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 16:39:34 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv12492 Modified Files: setobject.c Log Message: Remove some debugging code. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** setobject.c 15 Nov 2003 20:41:37 -0000 1.18 --- setobject.c 15 Nov 2003 21:39:29 -0000 1.19 *************** *** 184,188 **** PyObject *item, *data, *it; - printf("AAA"); it = PyObject_GetIter(other); if (it == NULL) --- 184,187 ---- *************** *** 212,216 **** { if (!IS_SET(so) || !IS_SET(other)) { - printf("YYY"); Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 211,214 ---- From rhettinger at users.sourceforge.net Sat Nov 15 16:43:44 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 16:43:50 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj test_set.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv13207 Modified Files: test_set.py Log Message: Add tests from test_itertools.py that try-out many types of iterable input to constructors and methods that accept iterables. Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_set.py 15 Nov 2003 20:41:37 -0000 1.18 --- test_set.py 15 Nov 2003 21:43:42 -0000 1.19 *************** *** 994,997 **** --- 994,1114 ---- self.assertEqual((a&b)&(a^b), zero) + # Tests derived from test_itertools.py ======================================= + + def R(seqn): + 'Regular generator' + for i in seqn: + yield i + + class G: + 'Sequence using __getitem__' + def __init__(self, seqn): + self.seqn = seqn + def __getitem__(self, i): + return self.seqn[i] + + class I: + 'Sequence using iterator protocol' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + def next(self): + if self.i >= len(self.seqn): raise StopIteration + v = self.seqn[self.i] + self.i += 1 + return v + + class Ig: + 'Sequence using iterator protocol defined with a generator' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + for val in self.seqn: + yield val + + class X: + 'Missing __getitem__ and __iter__' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def next(self): + if self.i >= len(self.seqn): raise StopIteration + v = self.seqn[self.i] + self.i += 1 + return v + + class N: + 'Iterator missing next()' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + + class E: + 'Test propagation of exceptions' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + def next(self): + 3/0 + + class S: + 'Test immediate stop' + def __init__(self, seqn): + pass + def __iter__(self): + return self + def next(self): + raise StopIteration + + from itertools import chain, imap + def L(seqn): + 'Test multiple tiers of iterators' + return chain(imap(lambda x:x, R(Ig(G(seqn))))) + + class TestVariousIteratorArgs(unittest.TestCase): + + def test_constructor(self): + for cons in (set, frozenset): + for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): + for g in (G, I, Ig, S, L, R): + self.assertEqual(list.sorted(cons(g(s))), list.sorted(g(s))) + self.assertRaises(TypeError, cons , X(s)) + self.assertRaises(TypeError, cons , N(s)) + self.assertRaises(ZeroDivisionError, cons , E(s)) + + def test_inline_methods(self): + s = set('november') + for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'): + for meth in (s.union, s.intersection, s.difference, s.symmetric_difference): + for g in (G, I, Ig, L, R): + expected = meth(data) + actual = meth(G(data)) + self.assertEqual(list.sorted(actual), list.sorted(expected)) + self.assertRaises(TypeError, meth, X(s)) + self.assertRaises(TypeError, meth, N(s)) + self.assertRaises(ZeroDivisionError, meth, E(s)) + + def test_inplace_methods(self): + for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'): + for methname in ('union_update', 'intersection_update', + 'difference_update', 'symmetric_difference_update'): + for g in (G, I, Ig, S, L, R): + s = set('january') + t = set('january') + getattr(s, methname)(list(g(data))) + getattr(t, methname)(g(data)) + self.assertEqual(list.sorted(s), list.sorted(t)) + + self.assertRaises(TypeError, getattr(set('january'), methname), X(data)) + self.assertRaises(TypeError, getattr(set('january'), methname), N(data)) + self.assertRaises(ZeroDivisionError, getattr(set('january'), methname), E(data)) + #============================================================================== *************** *** 1028,1031 **** --- 1145,1149 ---- TestCopyingNested, TestIdentities, + TestVariousIteratorArgs, ) From rhettinger at users.sourceforge.net Sat Nov 15 17:36:22 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 17:36:32 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.19, 1.20 test_set.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv21728 Modified Files: setobject.c test_set.py Log Message: Handle error exits for unhashable elements. Add related tests. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** setobject.c 15 Nov 2003 21:39:29 -0000 1.19 --- setobject.c 15 Nov 2003 22:36:20 -0000 1.20 *************** *** 55,59 **** Py_DECREF(it); Py_DECREF(data); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 55,60 ---- Py_DECREF(it); Py_DECREF(data); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 160,164 **** Py_DECREF(it); Py_DECREF(result); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 161,166 ---- Py_DECREF(it); Py_DECREF(result); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 192,196 **** if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 194,199 ---- if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(it); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 257,261 **** Py_DECREF(it); Py_DECREF(result); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 260,265 ---- Py_DECREF(it); Py_DECREF(result); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 298,302 **** Py_DECREF(newdict); Py_DECREF(it); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 302,307 ---- Py_DECREF(newdict); Py_DECREF(it); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 364,369 **** tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) ! PyErr_Clear(); Py_DECREF(item); } --- 369,382 ---- tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) { ! if (PyErr_ExceptionMatches(PyExc_KeyError)) ! PyErr_Clear(); ! else { ! Py_DECREF(it); ! Py_DECREF(result); ! Py_DECREF(item); ! return NULL; ! } ! } Py_DECREF(item); } *************** *** 392,397 **** tgtdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) ! PyErr_Clear(); Py_DECREF(item); } --- 405,417 ---- tgtdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) { ! if (PyErr_ExceptionMatches(PyExc_KeyError)) ! PyErr_Clear(); ! else { ! Py_DECREF(it); ! Py_DECREF(item); ! return NULL; ! } ! } Py_DECREF(item); } *************** *** 466,470 **** Py_DECREF(otherset); Py_DECREF(result); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 486,491 ---- Py_DECREF(otherset); Py_DECREF(result); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 515,519 **** Py_XDECREF(otherset); Py_DECREF(it); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 536,541 ---- Py_XDECREF(otherset); Py_DECREF(it); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; *************** *** 523,527 **** Py_XDECREF(otherset); Py_DECREF(it); ! PyErr_SetString(PyExc_ValueError, "all set entries must be immutable"); return NULL; --- 545,550 ---- Py_XDECREF(otherset); Py_DECREF(it); ! Py_DECREF(item); ! PyErr_SetString(PyExc_TypeError, "all set entries must be immutable"); return NULL; Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_set.py 15 Nov 2003 21:43:42 -0000 1.19 --- test_set.py 15 Nov 2003 22:36:20 -0000 1.20 *************** *** 32,35 **** --- 32,36 ---- self.assertEqual(actual, expected) self.assertRaises(PassThru, self.thetype, check_pass_thru()) + self.assertRaises(TypeError, self.thetype, [[]]) def test_len(self): *************** *** 51,54 **** --- 52,56 ---- self.assertEqual(type(u), self.thetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) + self.assertRaises(TypeError, self.s.union, [[]]) def test_or(self): *************** *** 87,90 **** --- 89,93 ---- self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.difference, check_pass_thru()) + self.assertRaises(TypeError, self.s.difference, [[]]) def test_sub(self): *************** *** 105,108 **** --- 108,112 ---- self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) + self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) def test_xor(self): *************** *** 186,189 **** --- 190,194 ---- self.assert_(c in self.s) self.assertRaises(PassThru, self.s.union_update, check_pass_thru()) + self.assertRaises(TypeError, self.s.union_update, [[]]) def test_ior(self): *************** *** 201,204 **** --- 206,210 ---- self.assert_(c not in self.s) self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru()) + self.assertRaises(TypeError, self.s.intersection_update, [[]]) def test_iand(self): *************** *** 219,222 **** --- 225,229 ---- self.assert_(c not in self.s) self.assertRaises(PassThru, self.s.difference_update, check_pass_thru()) + self.assertRaises(TypeError, self.s.difference_update, [[]]) def test_isub(self): *************** *** 237,240 **** --- 244,248 ---- self.assert_(c not in self.s) self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru()) + self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) def test_ixor(self): From rhettinger at users.sourceforge.net Sat Nov 15 17:54:05 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 17:54:10 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.20, 1.21 test_set.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv24218 Modified Files: setobject.c test_set.py Log Message: Make sure the single argument methods also check for unhashable arguments. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** setobject.c 15 Nov 2003 22:36:20 -0000 1.20 --- setobject.c 15 Nov 2003 22:54:03 -0000 1.21 *************** *** 760,764 **** { if (PyDict_DelItem(so->data, item) == -1) ! PyErr_Clear(); Py_INCREF(Py_None); return Py_None; --- 760,767 ---- { if (PyDict_DelItem(so->data, item) == -1) ! if (PyErr_ExceptionMatches(PyExc_KeyError)) ! PyErr_Clear(); ! else ! return NULL; Py_INCREF(Py_None); return Py_None; Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_set.py 15 Nov 2003 22:36:20 -0000 1.20 --- test_set.py 15 Nov 2003 22:54:03 -0000 1.21 *************** *** 40,43 **** --- 40,44 ---- for c in self.letters: self.assertEqual(c in self.s, c in self.d) + self.assertRaises(TypeError, self.s.__contains__, [[]]) def test_copy(self): *************** *** 167,170 **** --- 168,172 ---- self.s.add('Q') self.assert_('Q' in self.s) + self.assertRaises(TypeError, self.s.add, []) def test_remove(self): *************** *** 172,175 **** --- 174,178 ---- self.assert_('a' not in self.s) self.assertRaises(KeyError, self.s.remove, 'Q') + self.assertRaises(TypeError, self.s.remove, []) def test_discard(self): *************** *** 177,180 **** --- 180,184 ---- self.assert_('a' not in self.s) self.s.discard('Q') + self.assertRaises(TypeError, self.s.discard, []) def test_pop(self): From rhettinger at users.sourceforge.net Sat Nov 15 21:22:40 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 21:22:45 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv23581 Modified Files: setobject.c Log Message: Don't re-use the save variable name in set_copy(). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** setobject.c 15 Nov 2003 22:54:03 -0000 1.21 --- setobject.c 16 Nov 2003 02:22:38 -0000 1.22 *************** *** 128,131 **** --- 128,132 ---- { PyObject *data; + setobject *newso; data = PyDict_Copy(so->data); *************** *** 133,143 **** return NULL; ! so = (setobject *)PyObject_GC_New(setobject, so->ob_type); ! if (so == NULL) { Py_DECREF(data); return NULL; } ! so->data = data; ! return (PyObject *)so; } --- 134,145 ---- return NULL; ! newso = (setobject *)PyObject_GC_New(setobject, so->ob_type); ! if (newso == NULL) { Py_DECREF(data); return NULL; } ! newso->data = data; ! newso->hash = so->hash; ! return (PyObject *)newso; } From rhettinger at users.sourceforge.net Sat Nov 15 21:33:56 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 21:33:59 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.22, 1.23 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv25116 Modified Files: setobject.c Log Message: Support subclassing in set_copy Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** setobject.c 16 Nov 2003 02:22:38 -0000 1.22 --- setobject.c 16 Nov 2003 02:33:54 -0000 1.23 *************** *** 134,138 **** return NULL; ! newso = (setobject *)PyObject_GC_New(setobject, so->ob_type); if (newso == NULL) { Py_DECREF(data); --- 134,139 ---- return NULL; ! ! newso = (setobject *)(so->ob_type->tp_alloc(so->ob_type, 0)); if (newso == NULL) { Py_DECREF(data); From rhettinger at users.sourceforge.net Sat Nov 15 21:41:36 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 21:41:38 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj cube.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv25907 Added Files: cube.py Log Message: Demo application of sets of sets by David Eppstein. Included in the sandbox to demonstrate the effectiveness of setobject.c for implementing graph algorithms. --- NEW FILE: cube.py --- try: from set import frozenset as ImmutableSet except ImportError: from sets import ImmutableSet def powerset(U): """Generates all subsets of a set or sequence U.""" U = iter(U) try: x = ImmutableSet([U.next()]) for S in powerset(U): yield S yield S | x except StopIteration: yield ImmutableSet() def cube(n): """Graph of n-dimensional hypercube.""" singletons = [ImmutableSet([x]) for x in range(n)] return dict([(x, ImmutableSet([x^s for s in singletons])) for x in powerset(range(n))]) def linegraph(G): """Graph, the vertices of which are edges of G, with two vertices being adjacent iff the corresponding edges share a vertex.""" L = {} for x in G: for y in G[x]: nx = [ImmutableSet([x,z]) for z in G[x] if z != y] ny = [ImmutableSet([y,z]) for z in G[y] if z != x] L[ImmutableSet([x,y])] = ImmutableSet(nx+ny) return L cuboctahedron = linegraph(cube(3)) print cuboctahedron From rhettinger at users.sourceforge.net Sat Nov 15 22:04:34 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 22:04:38 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.23, 1.24 test_set.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv28567 Modified Files: setobject.c test_set.py Log Message: * Added test for frozensets as dictionary keys. * Improve dict_pop() by grabbing the reference prior to item deletion. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** setobject.c 16 Nov 2003 02:33:54 -0000 1.23 --- setobject.c 16 Nov 2003 03:04:32 -0000 1.24 *************** *** 134,138 **** return NULL; - newso = (setobject *)(so->ob_type->tp_alloc(so->ob_type, 0)); if (newso == NULL) { --- 134,137 ---- *************** *** 786,792 **** return NULL; } - if (PyDict_DelItem(so->data, key) == -1) - PyErr_Clear(); Py_INCREF(key); return key; } --- 785,791 ---- return NULL; } Py_INCREF(key); + if (PyDict_DelItem(so->data, key) == -1) + PyErr_Clear(); return key; } Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_set.py 15 Nov 2003 22:54:03 -0000 1.21 --- test_set.py 16 Nov 2003 03:04:32 -0000 1.22 *************** *** 265,270 **** self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) ! # Tests takes from test_sets.py ============================================= empty_set = set() --- 265,283 ---- self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) + def test_frozen_as_dictkey(self): + seq = range(10) + list('abcdefg') + ['apple'] + key1 = frozenset(seq) + key2 = frozenset(reversed(seq)) + self.assertEqual(key1, key2) + self.assertNotEqual(id(key1), id(key2)) + d = {} + d[key1] = 42 + self.assertEqual(d[key2], 42) ! def test_hash_caching(self): ! f = frozenset('abcdcda') ! self.assertEqual(hash(f), hash(f)) ! ! # Tests taken from test_sets.py ============================================= empty_set = set() From rhettinger at users.sourceforge.net Sat Nov 15 22:10:42 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 15 22:10:47 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj automata.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv29107 Added Files: automata.py Log Message: Demo application of sets of sets by David Eppstein. Included in the sandbox to demonstrate the effectiveness of setobject.c for implementing NFA/DFA algorithms. Exercises set.ior(), set.pop(), set.add(), iteration, membership testing, and frozensets as members of both sets and dictionaries. --- NEW FILE: automata.py --- """automata.py Convert nondeterministic to deterministic finite automata. D. Eppstein, UC Irvine, November 2003. """ try: from set import frozenset as ImmutableSet, set as Set except ImportError: from sets import ImmutableSet, Set class InputError(Exception): pass class DFA: def __init__(self,Sigma,delta,S0,F): """Create deterministic finite automaton with alphabet Sigma, transition function delta(state,letter)->state, initial state S0, and predicate F(state)->boolean. The full sets of states and final states are determined implicitly from the delta and F functions. """ self.alphabet = ImmutableSet(Sigma) self.transition = delta self.initialState = S0 self.isfinal = F def states(self): """Generate all states of the DFA.""" explored = Set() unexplored = Set([self.initialState]) while unexplored: s = unexplored.pop() explored.add(s) yield s for c in self.alphabet: t = self.transition(s,c) if t not in explored: unexplored.add(t) def __call__(self,input): """Test whether input is accepted by the DFA.""" state = self.initialState for c in input: if c not in self.alphabet: raise InputError("Symbol " + repr(c) + " not in input alphabet") state = self.transition(state,c) return self.isfinal(state) class NFA: def __init__(self,Sigma,delta,S0,F): """Create nondeterministic finite automaton (without epsilon-transitions). Arguments are the same as for a deterministic finite automaton, except that the initial state and result of the transition function are both sets. """ self.alphabet = ImmutableSet(Sigma) self.transition = delta self.initialStates = ImmutableSet(S0) self.isfinal = F def setTransition(self,states,c): """States reachable from input set by input c.""" result = Set() for s in states: result |= self.transition(s,c) return ImmutableSet(result) def finalSet(self,states): """Test whether any of given set of states is final.""" for s in states: if self.isfinal(s): return True return False def makeDeterministic(self): """Convert NFA to DFA.""" return DFA(self.alphabet,self.setTransition, self.initialStates,self.finalSet) def __call__(self,input): """Test whether input is accepted by the NFA.""" return self.makeDeterministic()(input) # Example from Sipser, _Introduction to the Theory of Computation_ # (Preliminary Edition), Example 1.13, pages 47-48 if __name__ == "__main__": # state:(states for transition on 0, states for transition on 1) Sipser_1_13 = { 1: ([1], [1,2]), 2: ([3], [3]), 3: ([4], [4]), 4: ([], []), } def delta(s,i): return ImmutableSet(Sipser_1_13[s][int(i)]) def final(s): return s == 4 N2 = NFA("01",delta,[1],final) def test(input): print input,(N2(input) and "is" or "is not"),"in L(N2)" test("000100") test("0011") print print "Conversion to DFA:" print D2 = N2.makeDeterministic() for s in D2.states(): print s for c in "01": print " --[" + c + "]-->", D2.transition(s,c) From rhettinger at users.sourceforge.net Sun Nov 16 08:44:21 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 08:44:25 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libsets.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv18592 Modified Files: libsets.tex Log Message: Fix typo Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libsets.tex 17 Aug 2003 08:34:09 -0000 1.13 --- libsets.tex 16 Nov 2003 13:44:19 -0000 1.14 *************** *** 187,191 **** >>> employees.issuperset(engineers) True ! >>> for group in [engineers, programmers, management, employees]: ... group.discard('Susan') # unconditionally remove element ... print group --- 187,191 ---- >>> employees.issuperset(engineers) True ! >>> for group in [engineers, programmers, managers, employees]: ... group.discard('Susan') # unconditionally remove element ... print group From rhettinger at users.sourceforge.net Sun Nov 16 08:45:23 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 08:45:27 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libsets.tex, 1.11.16.1, 1.11.16.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv18799 Modified Files: Tag: release23-maint libsets.tex Log Message: Fix typo Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.11.16.1 retrieving revision 1.11.16.2 diff -C2 -d -r1.11.16.1 -r1.11.16.2 *** libsets.tex 17 Aug 2003 22:08:58 -0000 1.11.16.1 --- libsets.tex 16 Nov 2003 13:45:21 -0000 1.11.16.2 *************** *** 187,191 **** >>> employees.issuperset(engineers) True ! >>> for group in [engineers, programmers, management, employees]: ... group.discard('Susan') # unconditionally remove element ... print group --- 187,191 ---- >>> employees.issuperset(engineers) True ! >>> for group in [engineers, programmers, managers, employees]: ... group.discard('Susan') # unconditionally remove element ... print group From rhettinger at users.sourceforge.net Sun Nov 16 11:17:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:17:56 2003 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.138,1.139 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv13946 Modified Files: Makefile.pre.in Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** Makefile.pre.in 20 Sep 2003 10:50:48 -0000 1.138 --- Makefile.pre.in 16 Nov 2003 16:17:47 -0000 1.139 *************** *** 276,279 **** --- 276,280 ---- Objects/obmalloc.o \ Objects/rangeobject.o \ + Objects/setobject.o \ Objects/sliceobject.o \ Objects/stringobject.o \ *************** *** 501,504 **** --- 502,506 ---- Include/pythonrun.h \ Include/rangeobject.h \ + Include/setobject.h \ Include/sliceobject.h \ Include/stringobject.h \ From rhettinger at users.sourceforge.net Sun Nov 16 11:17:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:00 2003 Subject: [Python-checkins] python/dist/src/Include setobject.h, NONE, 2.1 Python.h, 2.57, 2.58 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Include Modified Files: Python.h Added Files: setobject.h Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. --- NEW FILE: setobject.h --- /* Set object interface */ #ifndef Py_SETOBJECT_H #define Py_SETOBJECT_H #ifdef __cplusplus extern "C" { #endif /* This data structure is shared by set and frozenset objects. */ typedef struct { PyObject_HEAD PyObject *data; long hash; /* only used by frozenset objects */ } PySetObject; PyAPI_DATA(PyTypeObject) PySet_Type; PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; #ifdef __cplusplus } #endif #endif /* !Py_SETOBJECT_H */ Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -d -r2.57 -r2.58 *** Python.h 12 Aug 2002 07:21:56 -0000 2.57 --- Python.h 16 Nov 2003 16:17:48 -0000 2.58 *************** *** 87,90 **** --- 87,91 ---- #include "dictobject.h" #include "enumobject.h" + #include "setobject.h" #include "methodobject.h" #include "moduleobject.h" From rhettinger at users.sourceforge.net Sun Nov 16 11:17:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:03 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.151,1.152 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Doc/lib Modified Files: libfuncs.tex Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** libfuncs.tex 6 Nov 2003 14:06:46 -0000 1.151 --- libfuncs.tex 16 Nov 2003 16:17:48 -0000 1.152 *************** *** 478,481 **** --- 478,492 ---- \end{funcdesc} + \begin{funcdesc}{frozenset}{\optional{iterable}} + Return a frozenset object whose elements are taken from \var{iterable}. + Frozensets are sets that have no update methods but can be hashed and + used as members of other sets or as dictionary keys. The elements of + a frozenset must be immutable themselves. To represent sets of sets, + the inner sets should also be \class{frozenset} objects. If + \var{iterable} is not specified, returns a new empty set, + \code{frozenset([])}. + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{getattr}{object, name\optional{, default}} Return the value of the named attributed of \var{object}. \var{name} *************** *** 896,899 **** --- 907,918 ---- are equally close, rounding is done away from 0 (so. for example, \code{round(0.5)} is \code{1.0} and \code{round(-0.5)} is \code{-1.0}). + \end{funcdesc} + + \begin{funcdesc}{set}{\optional{iterable}} + Return a set whose elements are taken from \var{iterable}. The elements + must be immutable. To represent sets of sets, the inner sets should + be \class{frozenset} objects. If \var{iterable} is not specified, + returns a new empty set, \code{set([])}. + \versionadded{2.4} \end{funcdesc} From rhettinger at users.sourceforge.net Sun Nov 16 11:17:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:05 2003 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.302,2.303 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Python Modified Files: bltinmodule.c Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.302 retrieving revision 2.303 diff -C2 -d -r2.302 -r2.303 *** bltinmodule.c 6 Nov 2003 14:06:48 -0000 2.302 --- bltinmodule.c 16 Nov 2003 16:17:49 -0000 2.303 *************** *** 2117,2120 **** --- 2117,2121 ---- SETBUILTIN("enumerate", &PyEnum_Type); SETBUILTIN("float", &PyFloat_Type); + SETBUILTIN("frozenset", &PyFrozenSet_Type); SETBUILTIN("property", &PyProperty_Type); SETBUILTIN("int", &PyInt_Type); *************** *** 2123,2126 **** --- 2124,2128 ---- SETBUILTIN("object", &PyBaseObject_Type); SETBUILTIN("reversed", &PyReversed_Type); + SETBUILTIN("set", &PySet_Type); SETBUILTIN("slice", &PySlice_Type); SETBUILTIN("staticmethod", &PyStaticMethod_Type); From rhettinger at users.sourceforge.net Sun Nov 16 11:17:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:09 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Objects Added Files: setobject.c Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. --- NEW FILE: setobject.c --- #include "Python.h" /* set object implementation written and maintained by Raymond D. Hettinger derived from sets.py written by Greg V. Wilson, Alex Martelli, Guido van Rossum, Raymond Hettinger, and Tim Peters. Copyright (c) 2003 Python Software Foundation. All rights reserved. */ /* Fast access macros */ #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) #define IS_SET(so) (so->ob_type == &PySet_Type || so->ob_type == &PyFrozenSet_Type) /* set object **********************************************************/ static PyObject * [...1034 lines suppressed...] frozenset_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)set_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ frozenset_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ set_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; From rhettinger at users.sourceforge.net Sun Nov 16 11:17:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:12 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.891,1.892 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Misc Modified Files: NEWS Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.891 retrieving revision 1.892 diff -C2 -d -r1.891 -r1.892 *** NEWS 14 Nov 2003 10:33:20 -0000 1.891 --- NEWS 16 Nov 2003 16:17:49 -0000 1.892 *************** *** 13,16 **** --- 13,18 ---- ----------------- + - Added two builtin types, set() and frozenset(). + - Critical bugfix, for SF bug 840829: if cyclic garbage collection happened to occur during a weakref callback for a new-style class From rhettinger at users.sourceforge.net Sun Nov 16 11:17:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:15 2003 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1:/tmp/cvs-serv13946/PCbuild Modified Files: pythoncore.dsp Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** pythoncore.dsp 8 Nov 2003 10:24:38 -0000 1.50 --- pythoncore.dsp 16 Nov 2003 16:17:49 -0000 1.51 *************** *** 468,471 **** --- 468,475 ---- # Begin Source File + SOURCE=..\Objects\setobject.c + # End Source File + # Begin Source File + SOURCE=..\Modules\shamodule.c # End Source File From rhettinger at users.sourceforge.net Sun Nov 16 11:17:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:18 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py, NONE, 1.1 regrtest.py, 1.147, 1.148 test___all__.py, 1.36, 1.37 test_builtin.py, 1.24, 1.25 test_enumerate.py, 1.7, 1.8 test_glob.py, 1.6, 1.7 test_pyclbr.py, 1.18, 1.19 test_random.py, 1.15, 1.16 test_sort.py, 1.6, 1.7 test_strptime.py, 1.23, 1.24 test_userdict.py, 1.16, 1.17 test_weakref.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Lib/test Modified Files: regrtest.py test___all__.py test_builtin.py test_enumerate.py test_glob.py test_pyclbr.py test_random.py test_sort.py test_strptime.py test_userdict.py test_weakref.py Added Files: test_set.py Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. --- NEW FILE: test_set.py --- import unittest from test import test_support import operator import copy import pickle class PassThru(Exception): pass def check_pass_thru(): raise PassThru yield 1 class TestJointOps(unittest.TestCase): # Tests common to both set and frozenset def setUp(self): self.word = word = 'simsalabim' self.otherword = 'madagascar' [...1144 lines suppressed...] TestCopyingTuple, TestCopyingNested, TestIdentities, TestVariousIteratorArgs, ) 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) Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** regrtest.py 13 Oct 2003 04:27:47 -0000 1.147 --- regrtest.py 16 Nov 2003 16:17:48 -0000 1.148 *************** *** 76,80 **** import cStringIO import warnings - from sets import Set # I see no other way to suppress these warnings; --- 76,79 ---- *************** *** 307,311 **** plat = sys.platform if e.isvalid(): ! surprise = Set(skipped) - e.getexpected() - Set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ --- 306,310 ---- plat = sys.platform if e.isvalid(): ! surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ *************** *** 949,953 **** if sys.platform in _expectations: s = _expectations[sys.platform] ! self.expected = Set(s.split()) if not os.path.supports_unicode_filenames: --- 948,952 ---- if sys.platform in _expectations: s = _expectations[sys.platform] ! self.expected = set(s.split()) if not os.path.supports_unicode_filenames: Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** test___all__.py 8 Nov 2003 10:24:36 -0000 1.36 --- test___all__.py 16 Nov 2003 16:17:48 -0000 1.37 *************** *** 3,7 **** from test.test_support import verify, verbose - from sets import Set import sys import warnings --- 3,6 ---- *************** *** 44,49 **** if names.has_key("__builtins__"): del names["__builtins__"] ! keys = Set(names) ! all = Set(sys.modules[modname].__all__) verify(keys==all, "%s != %s" % (keys, all)) --- 43,48 ---- if names.has_key("__builtins__"): del names["__builtins__"] ! keys = set(names) ! all = set(sys.modules[modname].__all__) verify(keys==all, "%s != %s" % (keys, all)) Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_builtin.py 28 Oct 2003 12:05:47 -0000 1.24 --- test_builtin.py 16 Nov 2003 16:17:48 -0000 1.25 *************** *** 3,7 **** import test.test_support, unittest from test.test_support import fcmp, have_unicode, TESTFN, unlink - from sets import Set import sys, warnings, cStringIO --- 3,6 ---- *************** *** 1105,1111 **** def test_vars(self): ! self.assertEqual(Set(vars()), Set(dir())) import sys ! self.assertEqual(Set(vars(sys)), Set(dir(sys))) self.assertEqual(self.get_vars_f0(), {}) self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2}) --- 1104,1110 ---- def test_vars(self): ! self.assertEqual(set(vars()), set(dir())) import sys ! self.assertEqual(set(vars(sys)), set(dir(sys))) self.assertEqual(self.get_vars_f0(), {}) self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2}) Index: test_enumerate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_enumerate.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_enumerate.py 6 Nov 2003 14:06:47 -0000 1.7 --- test_enumerate.py 16 Nov 2003 16:17:48 -0000 1.8 *************** *** 1,4 **** import unittest - from sets import Set from test import test_support --- 1,3 ---- *************** *** 106,111 **** # Tests an implementation detail where tuple is reused # whenever nothing else holds a reference to it ! self.assertEqual(len(Set(map(id, list(enumerate(self.seq))))), len(self.seq)) ! self.assertEqual(len(Set(map(id, enumerate(self.seq)))), min(1,len(self.seq))) class MyEnum(enumerate): --- 105,110 ---- # Tests an implementation detail where tuple is reused # whenever nothing else holds a reference to it ! self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq)) ! self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq))) class MyEnum(enumerate): Index: test_glob.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_glob.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_glob.py 13 Nov 2003 07:45:39 -0000 1.6 --- test_glob.py 16 Nov 2003 16:17:48 -0000 1.7 *************** *** 3,7 **** import glob import os - from sets import Set def mkdirs(fname): --- 3,6 ---- *************** *** 63,67 **** def assertSequencesEqual_noorder(self, l1, l2): ! self.assertEqual(Set(l1), Set(l2)) def test_glob_literal(self): --- 62,66 ---- def assertSequencesEqual_noorder(self, l1, l2): ! self.assertEqual(set(l1), set(l2)) def test_glob_literal(self): Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_pyclbr.py 2 May 2003 09:06:26 -0000 1.18 --- test_pyclbr.py 16 Nov 2003 16:17:48 -0000 1.19 *************** *** 8,12 **** import pyclbr from unittest import TestCase - from sets import Set # This next line triggers an error on old versions of pyclbr. --- 8,11 ---- *************** *** 25,29 **** def assertListEq(self, l1, l2, ignore): ''' succeed iff {l1} - {ignore} == {l2} - {ignore} ''' ! missing = (Set(l1) ^ Set(l2)) - Set(ignore) if missing: print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore) --- 24,28 ---- def assertListEq(self, l1, l2, ignore): ''' succeed iff {l1} - {ignore} == {l2} - {ignore} ''' ! missing = (set(l1) ^ set(l2)) - set(ignore) if missing: print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore) Index: test_random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_random.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_random.py 5 Oct 2003 09:09:15 -0000 1.15 --- test_random.py 16 Nov 2003 16:17:48 -0000 1.16 *************** *** 7,11 **** import warnings from math import log, exp, sqrt, pi - from sets import Set from test import test_support --- 7,10 ---- *************** *** 65,71 **** s = self.gen.sample(population, k) self.assertEqual(len(s), k) ! uniq = Set(s) self.assertEqual(len(uniq), k) ! self.failUnless(uniq <= Set(population)) self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0 --- 64,70 ---- s = self.gen.sample(population, k) self.assertEqual(len(s), k) ! uniq = set(s) self.assertEqual(len(uniq), k) ! self.failUnless(uniq <= set(population)) self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0 *************** *** 90,95 **** def test_sample_inputs(self): # SF bug #801342 -- population can be any iterable defining __len__() ! from sets import Set ! self.gen.sample(Set(range(20)), 2) self.gen.sample(range(20), 2) self.gen.sample(xrange(20), 2) --- 89,93 ---- def test_sample_inputs(self): # SF bug #801342 -- population can be any iterable defining __len__() ! self.gen.sample(set(range(20)), 2) self.gen.sample(range(20), 2) self.gen.sample(xrange(20), 2) *************** *** 257,262 **** def test_rangelimits(self): for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]: ! self.assertEqual(Set(range(start,stop)), ! Set([self.gen.randrange(start,stop) for i in xrange(100)])) def test_genrandbits(self): --- 255,260 ---- def test_rangelimits(self): for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]: ! self.assertEqual(set(range(start,stop)), ! set([self.gen.randrange(start,stop) for i in xrange(100)])) def test_genrandbits(self): *************** *** 365,369 **** def test__all__(self): # tests validity but not completeness of the __all__ list ! self.failUnless(Set(random.__all__) <= Set(dir(random))) def test_main(verbose=None): --- 363,367 ---- def test__all__(self): # tests validity but not completeness of the __all__ list ! self.failUnless(set(random.__all__) <= set(dir(random))) def test_main(verbose=None): Index: test_sort.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sort.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_sort.py 29 Oct 2003 06:54:42 -0000 1.6 --- test_sort.py 16 Nov 2003 16:17:48 -0000 1.7 *************** *** 2,6 **** import random from UserList import UserList - from sets import Set nerrors = 0 --- 2,5 ---- *************** *** 231,235 **** s = ''.join(dict.fromkeys(s).keys()) # unique letters only ! for T in [unicode, Set, list, tuple, dict.fromkeys]: self.assertEqual(list.sorted(s), list.sorted(T(s))) --- 230,234 ---- s = ''.join(dict.fromkeys(s).keys()) # unique letters only ! for T in [unicode, set, frozenset, list, tuple, dict.fromkeys]: self.assertEqual(list.sorted(s), list.sorted(T(s))) Index: test_strptime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_strptime.py 29 Aug 2003 02:28:54 -0000 1.23 --- test_strptime.py 16 Nov 2003 16:17:48 -0000 1.24 *************** *** 5,9 **** import locale import re - import sets import sys from test import test_support --- 5,8 ---- *************** *** 18,25 **** class LocaleTime_Tests(unittest.TestCase): """Tests for _strptime.LocaleTime. ! All values are lower-cased when stored in LocaleTime, so make sure to compare values after running ``lower`` on them. ! """ --- 17,24 ---- class LocaleTime_Tests(unittest.TestCase): """Tests for _strptime.LocaleTime. ! All values are lower-cased when stored in LocaleTime, so make sure to compare values after running ``lower`` on them. ! """ *************** *** 168,172 **** # Fixes bug #661354 test_locale = _strptime.LocaleTime() ! test_locale.timezone = (sets.ImmutableSet(), sets.ImmutableSet()) self.failUnless(_strptime.TimeRE(test_locale).pattern("%Z") == '', "with timezone == ('',''), TimeRE().pattern('%Z') != ''") --- 167,171 ---- # Fixes bug #661354 test_locale = _strptime.LocaleTime() ! test_locale.timezone = (frozenset(), frozenset()) self.failUnless(_strptime.TimeRE(test_locale).pattern("%Z") == '', "with timezone == ('',''), TimeRE().pattern('%Z') != ''") Index: test_userdict.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_userdict.py 2 May 2003 09:06:27 -0000 1.16 --- test_userdict.py 16 Nov 2003 16:17:48 -0000 1.17 *************** *** 2,7 **** import test.test_support, unittest - from sets import Set - import UserDict --- 2,5 ---- *************** *** 70,74 **** self.assert_(hasattr(iter, '__iter__')) x = list(iter) ! self.assert_(Set(x)==Set(lst)==Set(ref)) check_iterandlist(d.iterkeys(), d.keys(), self.reference.keys()) check_iterandlist(iter(d), d.keys(), self.reference.keys()) --- 68,72 ---- self.assert_(hasattr(iter, '__iter__')) x = list(iter) ! self.assert_(set(x)==set(lst)==set(ref)) check_iterandlist(d.iterkeys(), d.keys(), self.reference.keys()) check_iterandlist(iter(d), d.keys(), self.reference.keys()) *************** *** 243,247 **** ikeys.append(k) keys = u2.keys() ! self.assertEqual(Set(ikeys), Set(keys)) # Test setdefault --- 241,245 ---- ikeys.append(k) keys = u2.keys() ! self.assertEqual(set(ikeys), set(keys)) # Test setdefault Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_weakref.py 13 Nov 2003 21:59:31 -0000 1.30 --- test_weakref.py 16 Nov 2003 16:17:48 -0000 1.31 *************** *** 5,9 **** from test import test_support - from sets import Set --- 5,8 ---- *************** *** 393,397 **** items1 = dict.items() items2 = dict.copy().items() ! self.assert_(Set(items1) == Set(items2), "cloning of weak-keyed dictionary did not work!") del items1, items2 --- 392,396 ---- items1 = dict.items() items2 = dict.copy().items() ! self.assert_(set(items1) == set(items2), "cloning of weak-keyed dictionary did not work!") del items1, items2 From rhettinger at users.sourceforge.net Sun Nov 16 11:17:50 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:18:20 2003 Subject: [Python-checkins] python/dist/src/Lib _strptime.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Lib Modified Files: _strptime.py Log Message: * Migrate set() and frozenset() from the sandbox. * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming. Index: _strptime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_strptime.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** _strptime.py 16 Oct 2003 05:53:16 -0000 1.28 --- _strptime.py 16 Nov 2003 16:17:48 -0000 1.29 *************** *** 17,21 **** from re import IGNORECASE from datetime import date as datetime_date - from sets import ImmutableSet as sets_ImmutableSet try: from thread import allocate_lock as _thread_allocate_lock --- 17,20 ---- *************** *** 166,174 **** except AttributeError: pass ! no_saving = sets_ImmutableSet(["utc", "gmt", time.tzname[0].lower()]) if time.daylight: ! has_saving = sets_ImmutableSet([time.tzname[1].lower()]) else: ! has_saving = sets_ImmutableSet() self.timezone = (no_saving, has_saving) --- 165,173 ---- except AttributeError: pass ! no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()]) if time.daylight: ! has_saving = frozenset([time.tzname[1].lower()]) else: ! has_saving = frozenset() self.timezone = (no_saving, has_saving) From rhettinger at users.sourceforge.net Sun Nov 16 11:36:00 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:36:03 2003 Subject: [Python-checkins] python/nondist/sandbox/setobj automata.py, 1.1, 1.2 cube.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setobj In directory sc8-pr-cvs1:/tmp/cvs-serv18199 Modified Files: automata.py cube.py Log Message: Update the demo programs to use the builtins Index: automata.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/automata.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** automata.py 16 Nov 2003 03:10:40 -0000 1.1 --- automata.py 16 Nov 2003 16:35:58 -0000 1.2 *************** *** 5,13 **** """ - try: - from set import frozenset as ImmutableSet, set as Set - except ImportError: - from sets import ImmutableSet, Set - class InputError(Exception): pass --- 5,8 ---- *************** *** 20,24 **** functions. """ ! self.alphabet = ImmutableSet(Sigma) self.transition = delta self.initialState = S0 --- 15,19 ---- functions. """ ! self.alphabet = frozenset(Sigma) self.transition = delta self.initialState = S0 *************** *** 27,32 **** def states(self): """Generate all states of the DFA.""" ! explored = Set() ! unexplored = Set([self.initialState]) while unexplored: s = unexplored.pop() --- 22,27 ---- def states(self): """Generate all states of the DFA.""" ! explored = set() ! unexplored = set([self.initialState]) while unexplored: s = unexplored.pop() *************** *** 55,71 **** and result of the transition function are both sets. """ ! self.alphabet = ImmutableSet(Sigma) self.transition = delta ! self.initialStates = ImmutableSet(S0) self.isfinal = F def setTransition(self,states,c): """States reachable from input set by input c.""" ! result = Set() for s in states: result |= self.transition(s,c) ! return ImmutableSet(result) ! def finalSet(self,states): """Test whether any of given set of states is final.""" for s in states: --- 50,66 ---- and result of the transition function are both sets. """ ! self.alphabet = frozenset(Sigma) self.transition = delta ! self.initialStates = frozenset(S0) self.isfinal = F def setTransition(self,states,c): """States reachable from input set by input c.""" ! result = set() for s in states: result |= self.transition(s,c) ! return frozenset(result) ! def finalset(self,states): """Test whether any of given set of states is final.""" for s in states: *************** *** 77,81 **** """Convert NFA to DFA.""" return DFA(self.alphabet,self.setTransition, ! self.initialStates,self.finalSet) def __call__(self,input): --- 72,76 ---- """Convert NFA to DFA.""" return DFA(self.alphabet,self.setTransition, ! self.initialStates,self.finalset) def __call__(self,input): *************** *** 94,98 **** 4: ([], []), } ! def delta(s,i): return ImmutableSet(Sipser_1_13[s][int(i)]) def final(s): return s == 4 N2 = NFA("01",delta,[1],final) --- 89,93 ---- 4: ([], []), } ! def delta(s,i): return frozenset(Sipser_1_13[s][int(i)]) def final(s): return s == 4 N2 = NFA("01",delta,[1],final) Index: cube.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setobj/cube.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cube.py 16 Nov 2003 02:41:33 -0000 1.1 --- cube.py 16 Nov 2003 16:35:58 -0000 1.2 *************** *** 1,22 **** - try: - from set import frozenset as ImmutableSet - except ImportError: - from sets import ImmutableSet - def powerset(U): """Generates all subsets of a set or sequence U.""" U = iter(U) try: ! x = ImmutableSet([U.next()]) for S in powerset(U): yield S yield S | x except StopIteration: ! yield ImmutableSet() def cube(n): """Graph of n-dimensional hypercube.""" ! singletons = [ImmutableSet([x]) for x in range(n)] ! return dict([(x, ImmutableSet([x^s for s in singletons])) for x in powerset(range(n))]) --- 1,17 ---- def powerset(U): """Generates all subsets of a set or sequence U.""" U = iter(U) try: ! x = frozenset([U.next()]) for S in powerset(U): yield S yield S | x except StopIteration: ! yield frozenset() def cube(n): """Graph of n-dimensional hypercube.""" ! singletons = [frozenset([x]) for x in range(n)] ! return dict([(x, frozenset([x^s for s in singletons])) for x in powerset(range(n))]) *************** *** 28,34 **** for x in G: for y in G[x]: ! nx = [ImmutableSet([x,z]) for z in G[x] if z != y] ! ny = [ImmutableSet([y,z]) for z in G[y] if z != x] ! L[ImmutableSet([x,y])] = ImmutableSet(nx+ny) return L --- 23,29 ---- for x in G: for y in G[x]: ! nx = [frozenset([x,z]) for z in G[x] if z != y] ! ny = [frozenset([y,z]) for z in G[y] if z != x] ! L[frozenset([x,y])] = frozenset(nx+ny) return L From rhettinger at users.sourceforge.net Sun Nov 16 11:37:00 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 16 11:37:03 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv18338 Modified Files: setobject.c Log Message: Fix output spacing typo Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** setobject.c 16 Nov 2003 16:17:49 -0000 1.1 --- setobject.c 16 Nov 2003 16:36:58 -0000 1.2 *************** *** 723,727 **** firstpass = 0; else ! fprintf(fp, ","); if (PyObject_Print(item, fp, 0) != 0) { Py_DECREF(it); --- 723,727 ---- firstpass = 0; else ! fprintf(fp, ", "); if (PyObject_Print(item, fp, 0) != 0) { Py_DECREF(it); From barry at python.org Sun Nov 16 12:27:13 2003 From: barry at python.org (Barry Warsaw) Date: Sun Nov 16 12:27:21 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.151,1.152 In-Reply-To: References: Message-ID: <1069003633.990.106.camel@anthem> On Sun, 2003-11-16 at 11:17, rhettinger@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Doc/lib > In directory sc8-pr-cvs1:/tmp/cvs-serv13946/Doc/lib > > Modified Files: > libfuncs.tex > Log Message: > * Migrate set() and frozenset() from the sandbox. > * Install the unittests, docs, newsitem, include file, and makefile update. > * Exercise the new functions whereever sets.py was being used. > > Includes the docs for libfuncs.tex. Separate docs for the types are > forthcoming. Okay, I must have missed the discussion on these, but why are these so important that they should be in builtins? -Barry From rhettinger at users.sourceforge.net Mon Nov 17 11:42:34 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 17 11:42:40 2003 Subject: [Python-checkins] python/dist/src/Include setobject.h,2.1,2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv10398/Include Modified Files: setobject.h Log Message: Various fixups (most suggested by Armin Rigo). Index: setobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/setobject.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -d -r2.1 -r2.2 *** setobject.h 16 Nov 2003 16:17:48 -0000 2.1 --- setobject.h 17 Nov 2003 16:42:32 -0000 2.2 *************** *** 21,24 **** --- 21,30 ---- PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; + + #define PyAnySet_Check(ob) \ + ((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \ + PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \ + PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type)) + #ifdef __cplusplus } From rhettinger at users.sourceforge.net Mon Nov 17 11:42:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 17 11:42:45 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv10398/Lib/test Modified Files: test_set.py Log Message: Various fixups (most suggested by Armin Rigo). Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_set.py 16 Nov 2003 16:17:48 -0000 1.1 --- test_set.py 17 Nov 2003 16:42:33 -0000 1.2 *************** *** 153,156 **** --- 153,163 ---- thetype = set + def test_init(self): + s = set() + s.__init__(self.word) + self.assertEqual(s, set(self.word)) + s.__init__(self.otherword) + self.assertEqual(s, set(self.otherword)) + def test_hash(self): self.assertRaises(TypeError, hash, self.s) *************** *** 253,260 **** --- 260,277 ---- self.assert_(c not in self.s) + class SetSubclass(set): + pass + + class TestSetSubclass(TestSet): + thetype = SetSubclass class TestFrozenSet(TestJointOps): thetype = frozenset + def test_init(self): + s = frozenset() + s.__init__(self.word) + self.assertEqual(s, frozenset()) + def test_hash(self): self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) *************** *** 274,277 **** --- 291,300 ---- self.assertEqual(hash(f), hash(f)) + class FrozenSetSubclass(frozenset): + pass + + class TestFrozenSetSubclass(TestFrozenSet): + thetype = FrozenSetSubclass + # Tests taken from test_sets.py ============================================= *************** *** 1138,1142 **** --- 1161,1167 ---- test_classes = ( TestSet, + TestSetSubclass, TestFrozenSet, + TestFrozenSetSubclass, TestSetOfSets, TestExceptionPropagation, From rhettinger at users.sourceforge.net Mon Nov 17 11:42:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 17 11:42:50 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv10398/Objects Modified Files: setobject.c Log Message: Various fixups (most suggested by Armin Rigo). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** setobject.c 16 Nov 2003 16:36:58 -0000 1.2 --- setobject.c 17 Nov 2003 16:42:32 -0000 1.3 *************** *** 13,17 **** #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) - #define IS_SET(so) (so->ob_type == &PySet_Type || so->ob_type == &PyFrozenSet_Type) /* set object **********************************************************/ --- 13,16 ---- *************** *** 43,48 **** Py_DECREF(data); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 42,45 ---- *************** *** 68,72 **** static PyObject * ! set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *iterable = NULL; --- 65,69 ---- static PyObject * ! frozenset_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *iterable = NULL; *************** *** 77,80 **** --- 74,85 ---- } + static PyObject * + set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + PyObject *iterable = NULL; + + return make_new_set(type, NULL); + } + static void set_dealloc(PySetObject *so) *************** *** 140,143 **** --- 145,150 ---- result = (PySetObject *)set_copy(so); + if (result == NULL) + return NULL; it = PyObject_GetIter(other); if (it == NULL) { *************** *** 151,156 **** Py_DECREF(result); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 158,161 ---- *************** *** 184,189 **** Py_DECREF(it); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 189,192 ---- *************** *** 202,206 **** set_or(PySetObject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 205,209 ---- set_or(PySetObject *so, PyObject *other) { ! if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 214,218 **** PyObject *result; ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 217,221 ---- PyObject *result; ! if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 250,255 **** Py_DECREF(result); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 253,256 ---- *************** *** 292,297 **** Py_DECREF(it); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 293,296 ---- *************** *** 316,320 **** set_and(PySetObject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 315,319 ---- set_and(PySetObject *so, PyObject *other) { ! if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 328,332 **** PyObject *result; ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 327,331 ---- PyObject *result; ! if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 417,421 **** set_sub(PySetObject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 416,420 ---- set_sub(PySetObject *so, PyObject *other) { ! if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 429,433 **** PyObject *result; ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 428,432 ---- PyObject *result; ! if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 476,481 **** Py_DECREF(result); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 475,478 ---- *************** *** 507,511 **** if (PyDict_Check(other)) otherdata = other; ! else if (IS_SET(other)) otherdata = ((PySetObject *)other)->data; else { --- 504,508 ---- if (PyDict_Check(other)) otherdata = other; ! else if (PyAnySet_Check(other)) otherdata = ((PySetObject *)other)->data; else { *************** *** 526,531 **** Py_DECREF(it); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 523,526 ---- *************** *** 535,540 **** Py_DECREF(it); Py_DECREF(item); - PyErr_SetString(PyExc_TypeError, - "all set entries must be immutable"); return NULL; } --- 530,533 ---- *************** *** 555,559 **** set_xor(PySetObject *so, PyObject *other) { ! if (!IS_SET(so) || !IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 548,552 ---- set_xor(PySetObject *so, PyObject *other) { ! if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 567,571 **** PyObject *result; ! if (!IS_SET(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 560,564 ---- PyObject *result; ! if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 584,588 **** PyObject *otherdata, *it, *item; ! if (!IS_SET(other)) { PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; --- 577,581 ---- PyObject *otherdata, *it, *item; ! if (!PyAnySet_Check(other)) { PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; *************** *** 605,608 **** --- 598,603 ---- } Py_DECREF(it); + if (PyErr_Occurred()) + return NULL; Py_RETURN_TRUE; } *************** *** 613,617 **** set_issuperset(PySetObject *so, PyObject *other) { ! if (!IS_SET(other)) { PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; --- 608,612 ---- set_issuperset(PySetObject *so, PyObject *other) { ! if (!PyAnySet_Check(other)) { PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; *************** *** 654,659 **** Py_DECREF(item); } - so->hash = hash; Py_DECREF(it); return hash; } --- 649,656 ---- Py_DECREF(item); } Py_DECREF(it); + if (PyErr_Occurred()) + return -1; + so->hash = hash; return hash; } *************** *** 662,671 **** set_richcompare(PySetObject *v, PyObject *w, int op) { ! /* XXX factor out is_set test */ ! if (op == Py_EQ && !IS_SET(w)) ! Py_RETURN_FALSE; ! else if (op == Py_NE && !IS_SET(w)) ! Py_RETURN_TRUE; ! if (!IS_SET(w)) { PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; --- 659,667 ---- set_richcompare(PySetObject *v, PyObject *w, int op) { ! if(!PyAnySet_Check(w)) { ! if (op == Py_EQ) ! Py_RETURN_FALSE; ! if (op == Py_NE) ! Py_RETURN_TRUE; PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; *************** *** 699,704 **** --- 695,704 ---- keys = PyDict_Keys(so->data); + if (keys == NULL) + return NULL; listrepr = PyObject_Repr(keys); Py_DECREF(keys); + if (listrepr == NULL) + return NULL; result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, *************** *** 733,736 **** --- 733,738 ---- Py_DECREF(it); fprintf(fp, "])"); + if (PyErr_Occurred()) + return -1; return 0; } *************** *** 811,816 **** } Py_INCREF(key); ! if (PyDict_DelItem(so->data, key) == -1) ! PyErr_Clear(); return key; } --- 813,820 ---- } Py_INCREF(key); ! if (PyDict_DelItem(so->data, key) == -1) { ! Py_DECREF(key); ! return NULL; ! } return key; } *************** *** 838,841 **** --- 842,867 ---- PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); + static int + set_init(PySetObject *self, PyObject *args, PyObject *kwds) + { + PyObject *iterable = NULL; + PyObject *result; + + if (!PyAnySet_Check(self)) + return -1; + if (!PyArg_UnpackTuple(args, self->ob_type->tp_name, 0, 1, &iterable)) + return -1; + PyDict_Clear(self->data); + self->hash = -1; + if (iterable == NULL) + return 0; + result = set_union_update(self, iterable); + if (result != NULL) { + Py_DECREF(result); + return 0; + } + return -1; + } + static PySequenceMethods set_as_sequence = { (inquiry)set_len, /* sq_length */ *************** *** 972,976 **** 0, /* tp_descr_set */ 0, /* tp_dictoffset */ ! 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ set_new, /* tp_new */ --- 998,1002 ---- 0, /* tp_descr_set */ 0, /* tp_dictoffset */ ! (initproc)set_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ set_new, /* tp_new */ *************** *** 1069,1073 **** 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ ! set_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; --- 1095,1099 ---- 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ ! frozenset_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; From rhettinger at users.sourceforge.net Tue Nov 18 09:15:34 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 18 09:15:36 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv13579 Modified Files: setobject.c Log Message: Use PySequence_Contains() instead of direct access macro. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** setobject.c 17 Nov 2003 16:42:32 -0000 1.3 --- setobject.c 18 Nov 2003 14:15:31 -0000 1.4 *************** *** 10,19 **** */ - /* Fast access macros */ - - #define DICT_CONTAINS(d, k) (d->ob_type->tp_as_sequence->sq_contains(d, k)) - - /* set object **********************************************************/ - static PyObject * make_new_set(PyTypeObject *type, PyObject *iterable) --- 10,13 ---- *************** *** 113,117 **** set_contains(PySetObject *so, PyObject *key) { ! return DICT_CONTAINS(so->data, key); } --- 107,111 ---- set_contains(PySetObject *so, PyObject *key) { ! return PySequence_Contains(so->data, key); } *************** *** 248,252 **** tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (DICT_CONTAINS(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); --- 242,246 ---- tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); *************** *** 288,292 **** selfdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (DICT_CONTAINS(selfdata, item)) { if (PyDict_SetItem(newdict, item, Py_True) == -1) { Py_DECREF(newdict); --- 282,286 ---- selfdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_SetItem(newdict, item, Py_True) == -1) { Py_DECREF(newdict); *************** *** 518,522 **** while ((item = PyIter_Next(it)) != NULL) { ! if (DICT_CONTAINS(selfdata, item)) { if (PyDict_DelItem(selfdata, item) == -1) { Py_XDECREF(otherset); --- 512,516 ---- while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_DelItem(selfdata, item) == -1) { Py_XDECREF(otherset); *************** *** 590,594 **** otherdata = ((PySetObject *)other)->data; while ((item = PyIter_Next(it)) != NULL) { ! if (!DICT_CONTAINS(otherdata, item)) { Py_DECREF(it); Py_DECREF(item); --- 584,588 ---- otherdata = ((PySetObject *)other)->data; while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { Py_DECREF(it); Py_DECREF(item); From rhettinger at users.sourceforge.net Tue Nov 18 12:50:37 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 18 12:51:40 2003 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.210,1.211 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1:/tmp/cvs-serv23471 Modified Files: tut.tex Log Message: Documentation for set objects. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.210 retrieving revision 1.211 diff -C2 -d -r1.210 -r1.211 *** tut.tex 7 Nov 2003 01:30:58 -0000 1.210 --- tut.tex 18 Nov 2003 17:50:34 -0000 1.211 *************** *** 2054,2057 **** --- 2054,2094 ---- + \section{Sets \label{sets}} + + Python also includes a data type for \emph{sets}. A set is an unordered + collection with no duplicate elements. Basic uses include membership + testing and eliminating duplicate entries. Set objects also support + mathematical operations like union, intersection, difference, and + symmetric difference. + + Here is a brief demonstration: + + \begin{verbatim} + >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana'] + >>> fruits = set(basket) # create a set without duplicates + >>> fruits + set(['orange', 'pear', 'apple', 'banana']) + >>> 'orange' in fruits # fast membership testing + True + >>> 'crabgrass' in fruits + False + + >>> # Demonstrate set operations on unique letters from two words + ... + >>> a = set('abracadabra') + >>> b = set('alacazam') + >>> a # unique letters in a + set(['a', 'r', 'b', 'c', 'd']) + >>> a - b # letters in a but not in b + set(['r', 'd', 'b']) + >>> a | b # letters in either a or b + set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l']) + >>> a & b # letters in both a and b + set(['a', 'c']) + >>> a ^ b # letters in a or b but not both + set(['r', 'd', 'b', 'm', 'z', 'l']) + \end{verbatim} + + \section{Dictionaries \label{dictionaries}} From akuchling at users.sourceforge.net Tue Nov 18 13:58:39 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Nov 18 13:58:46 2003 Subject: [Python-checkins] python/nondist/peps pep-0321.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv6684 Modified Files: pep-0321.txt Log Message: Add a link Index: pep-0321.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0321.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0321.txt 28 Oct 2003 19:48:44 -0000 1.3 --- pep-0321.txt 18 Nov 2003 18:58:37 -0000 1.4 *************** *** 133,136 **** --- 133,137 ---- http://ringmaster.arc.nasa.gov/tools/time_formats.html http://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html + https://moin.conectiva.com.br/DateUtil From gvanrossum at users.sourceforge.net Tue Nov 18 14:27:23 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Nov 18 14:27:31 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv12550 Modified Files: setobject.c Log Message: Implement straightforward suggestions from gcc warnings (remove unused variable, add extra braces). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** setobject.c 18 Nov 2003 14:15:31 -0000 1.4 --- setobject.c 18 Nov 2003 19:27:19 -0000 1.5 *************** *** 71,76 **** set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *iterable = NULL; - return make_new_set(type, NULL); } --- 71,74 ---- *************** *** 782,790 **** set_discard(PySetObject *so, PyObject *item) { ! if (PyDict_DelItem(so->data, item) == -1) if (PyErr_ExceptionMatches(PyExc_KeyError)) PyErr_Clear(); else return NULL; Py_INCREF(Py_None); return Py_None; --- 780,789 ---- set_discard(PySetObject *so, PyObject *item) { ! if (PyDict_DelItem(so->data, item) == -1) { if (PyErr_ExceptionMatches(PyExc_KeyError)) PyErr_Clear(); else return NULL; + } Py_INCREF(Py_None); return Py_None; From loewis at users.sourceforge.net Tue Nov 18 14:46:27 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:46:32 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.892,1.893 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv16426/Misc Modified Files: NEWS Log Message: Patch #794400: Let PYTHONSTARTUP influence the compiler flags. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.892 retrieving revision 1.893 diff -C2 -d -r1.892 -r1.893 *** NEWS 16 Nov 2003 16:17:49 -0000 1.892 --- NEWS 18 Nov 2003 19:46:24 -0000 1.893 *************** *** 13,16 **** --- 13,18 ---- ----------------- + - Compiler flags set in PYTHONSTARTUP are now active in __main__. + - Added two builtin types, set() and frozenset(). From loewis at users.sourceforge.net Tue Nov 18 14:46:27 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:46:38 2003 Subject: [Python-checkins] python/dist/src/Modules main.c,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv16426/Modules Modified Files: main.c Log Message: Patch #794400: Let PYTHONSTARTUP influence the compiler flags. Index: main.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** main.c 20 Oct 2003 14:01:53 -0000 1.79 --- main.c 18 Nov 2003 19:46:25 -0000 1.80 *************** *** 118,121 **** --- 118,134 ---- } + static void RunStartupFile(PyCompilerFlags *cf) + { + char *startup = Py_GETENV("PYTHONSTARTUP"); + if (startup != NULL && startup[0] != '\0') { + FILE *fp = fopen(startup, "r"); + if (fp != NULL) { + (void) PyRun_SimpleFileExFlags(fp, startup, 0, cf); + PyErr_Clear(); + fclose(fp); + } + } + } + /* Main program */ *************** *** 402,414 **** else { if (filename == NULL && stdin_is_interactive) { ! char *startup = Py_GETENV("PYTHONSTARTUP"); ! if (startup != NULL && startup[0] != '\0') { ! FILE *fp = fopen(startup, "r"); ! if (fp != NULL) { ! (void) PyRun_SimpleFile(fp, startup); ! PyErr_Clear(); ! fclose(fp); ! } ! } } /* XXX */ --- 415,419 ---- else { if (filename == NULL && stdin_is_interactive) { ! RunStartupFile(&cf); } /* XXX */ From loewis at users.sourceforge.net Tue Nov 18 14:48:43 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:48:54 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.143.8.6, 1.143.8.7 libstring.tex, 1.52, 1.52.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16839/Doc/lib Modified Files: Tag: release23-maint libfuncs.tex libstring.tex Log Message: Patch #843088: Fix typos. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.143.8.6 retrieving revision 1.143.8.7 diff -C2 -d -r1.143.8.6 -r1.143.8.7 *** libfuncs.tex 13 Oct 2003 17:54:46 -0000 1.143.8.6 --- libfuncs.tex 18 Nov 2003 19:48:41 -0000 1.143.8.7 *************** *** 945,949 **** \end{funcdesc} ! \begin{funcdesc}{super}{type\optional{object-or-type}} Return the superclass of \var{type}. If the second argument is omitted the super object returned is unbound. If the second argument is an --- 945,949 ---- \end{funcdesc} ! \begin{funcdesc}{super}{type\optional{, object-or-type}} Return the superclass of \var{type}. If the second argument is omitted the super object returned is unbound. If the second argument is an Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.52 retrieving revision 1.52.8.1 diff -C2 -d -r1.52 -r1.52.8.1 *** libstring.tex 16 Jul 2003 05:11:27 -0000 1.52 --- libstring.tex 18 Nov 2003 19:48:41 -0000 1.52.8.1 *************** *** 301,308 **** \end{funcdesc} ! \begin{funcdesc}{replace}{str, old, new\optional{, maxsplit}} Return a copy of string \var{str} with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument ! \var{maxsplit} is given, the first \var{maxsplit} occurrences are replaced. \end{funcdesc} --- 301,308 ---- \end{funcdesc} ! \begin{funcdesc}{replace}{str, old, new\optional{, maxreplace}} Return a copy of string \var{str} with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument ! \var{maxreplace} is given, the first \var{maxreplace} occurrences are replaced. \end{funcdesc} From loewis at users.sourceforge.net Tue Nov 18 14:48:59 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:50:35 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.152, 1.153 libstring.tex, 1.52, 1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16909/Doc/lib Modified Files: libfuncs.tex libstring.tex Log Message: Patch #843088: Fix typos. Backported to 2.3. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -d -r1.152 -r1.153 *** libfuncs.tex 16 Nov 2003 16:17:48 -0000 1.152 --- libfuncs.tex 18 Nov 2003 19:48:57 -0000 1.153 *************** *** 972,976 **** \end{funcdesc} ! \begin{funcdesc}{super}{type\optional{object-or-type}} Return the superclass of \var{type}. If the second argument is omitted the super object returned is unbound. If the second argument is an --- 972,976 ---- \end{funcdesc} ! \begin{funcdesc}{super}{type\optional{, object-or-type}} Return the superclass of \var{type}. If the second argument is omitted the super object returned is unbound. If the second argument is an Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** libstring.tex 16 Jul 2003 05:11:27 -0000 1.52 --- libstring.tex 18 Nov 2003 19:48:57 -0000 1.53 *************** *** 301,308 **** \end{funcdesc} ! \begin{funcdesc}{replace}{str, old, new\optional{, maxsplit}} Return a copy of string \var{str} with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument ! \var{maxsplit} is given, the first \var{maxsplit} occurrences are replaced. \end{funcdesc} --- 301,308 ---- \end{funcdesc} ! \begin{funcdesc}{replace}{str, old, new\optional{, maxreplace}} Return a copy of string \var{str} with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument ! \var{maxreplace} is given, the first \var{maxreplace} occurrences are replaced. \end{funcdesc} From loewis at users.sourceforge.net Tue Nov 18 14:54:03 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:54:05 2003 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.136.6.2, 1.136.6.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv17924 Modified Files: Tag: release23-maint Makefile.pre.in Log Message: Patch #841807: Check whether a versioned libpython.so symlink is needed in altbininstall. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.136.6.2 retrieving revision 1.136.6.3 diff -C2 -d -r1.136.6.2 -r1.136.6.3 *** Makefile.pre.in 4 Nov 2003 21:15:22 -0000 1.136.6.2 --- Makefile.pre.in 18 Nov 2003 19:54:00 -0000 1.136.6.3 *************** *** 610,614 **** else \ $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ ! (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \ fi; \ else true; \ --- 610,616 ---- else \ $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ ! if test libpython$(VERSION)$(SO) != $(INSTSONAME); then \ ! (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \ ! fi \ fi; \ else true; \ From loewis at users.sourceforge.net Tue Nov 18 14:54:22 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:54:26 2003 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.139,1.140 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv18270 Modified Files: Makefile.pre.in Log Message: Patch #841807: Check whether a versioned libpython.so symlink is needed in altbininstall. Backported to 2.3. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** Makefile.pre.in 16 Nov 2003 16:17:47 -0000 1.139 --- Makefile.pre.in 18 Nov 2003 19:54:20 -0000 1.140 *************** *** 616,620 **** else \ $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ ! (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \ fi; \ else true; \ --- 616,622 ---- else \ $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ ! if test libpython$(VERSION)$(SO) != $(INSTSONAME); then \ ! (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \ ! fi \ fi; \ else true; \ From loewis at users.sourceforge.net Tue Nov 18 14:59:43 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 14:59:51 2003 Subject: [Python-checkins] python/dist/src configure, 1.416.4.10, 1.416.4.11 configure.in, 1.427.4.9, 1.427.4.10 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv18918 Modified Files: Tag: release23-maint configure configure.in Log Message: Patch #836434: Use dlopen/dlsym on AIX if available. Also disable _XOPEN_SOURCE on AIX 4. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.416.4.10 retrieving revision 1.416.4.11 diff -C2 -d -r1.416.4.10 -r1.416.4.11 *** configure 31 Oct 2003 15:41:46 -0000 1.416.4.10 --- configure 18 Nov 2003 19:59:36 -0000 1.416.4.11 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.427.4.8 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.3. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.427.4.9 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.3. *************** *** 1459,1462 **** --- 1459,1467 ---- FreeBSD/4.8* | Darwin/6* ) define_xopen_source=no;; + # On AIX 4, mbstate_t is defined only when _XOPEN_SOURCE == 500 but used in + # wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined or + # has another value. By not (re)defining it, the defaults come in place. + AIX/4) + define_xopen_source=no;; esac *************** *** 12973,12977 **** then case $ac_sys_system/$ac_sys_release in ! AIX*) DYNLOADFILE="dynload_aix.o";; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; --- 12978,12987 ---- then case $ac_sys_system/$ac_sys_release in ! AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c ! if test "$ac_cv_func_dlopen" = yes ! then DYNLOADFILE="dynload_shlib.o" ! else DYNLOADFILE="dynload_aix.o" ! fi ! ;; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.427.4.9 retrieving revision 1.427.4.10 diff -C2 -d -r1.427.4.9 -r1.427.4.10 *** configure.in 31 Oct 2003 15:41:49 -0000 1.427.4.9 --- configure.in 18 Nov 2003 19:59:39 -0000 1.427.4.10 *************** *** 157,160 **** --- 157,165 ---- FreeBSD/4.8* | Darwin/6* ) define_xopen_source=no;; + # On AIX 4, mbstate_t is defined only when _XOPEN_SOURCE == 500 but used in + # wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined or + # has another value. By not (re)defining it, the defaults come in place. + AIX/4) + define_xopen_source=no;; esac *************** *** 2025,2029 **** then case $ac_sys_system/$ac_sys_release in ! AIX*) DYNLOADFILE="dynload_aix.o";; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; --- 2030,2039 ---- then case $ac_sys_system/$ac_sys_release in ! AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c ! if test "$ac_cv_func_dlopen" = yes ! then DYNLOADFILE="dynload_shlib.o" ! else DYNLOADFILE="dynload_aix.o" ! fi ! ;; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; From loewis at users.sourceforge.net Tue Nov 18 15:00:51 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Nov 18 15:00:55 2003 Subject: [Python-checkins] python/dist/src configure, 1.430, 1.431 configure.in, 1.440, 1.441 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1:/tmp/cvs-serv19402 Modified Files: configure configure.in Log Message: Patch #836434: Use dlopen/dlsym on AIX if available. Also disable _XOPEN_SOURCE on AIX 4. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.430 retrieving revision 1.431 diff -C2 -d -r1.430 -r1.431 *** configure 10 Nov 2003 06:35:36 -0000 1.430 --- configure 18 Nov 2003 20:00:15 -0000 1.431 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.439 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.440 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. *************** *** 1459,1462 **** --- 1459,1467 ---- FreeBSD/4.8* | Darwin/6* ) define_xopen_source=no;; + # On AIX 4, mbstate_t is defined only when _XOPEN_SOURCE == 500 but used in + # wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined or + # has another value. By not (re)defining it, the defaults come in place. + AIX/4) + define_xopen_source=no;; esac *************** *** 12985,12989 **** then case $ac_sys_system/$ac_sys_release in ! AIX*) DYNLOADFILE="dynload_aix.o";; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; --- 12990,12999 ---- then case $ac_sys_system/$ac_sys_release in ! AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c ! if test "$ac_cv_func_dlopen" = yes ! then DYNLOADFILE="dynload_shlib.o" ! else DYNLOADFILE="dynload_aix.o" ! fi ! ;; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.440 retrieving revision 1.441 diff -C2 -d -r1.440 -r1.441 *** configure.in 10 Nov 2003 06:35:36 -0000 1.440 --- configure.in 18 Nov 2003 20:00:44 -0000 1.441 *************** *** 157,160 **** --- 157,165 ---- FreeBSD/4.8* | Darwin/6* ) define_xopen_source=no;; + # On AIX 4, mbstate_t is defined only when _XOPEN_SOURCE == 500 but used in + # wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined or + # has another value. By not (re)defining it, the defaults come in place. + AIX/4) + define_xopen_source=no;; esac *************** *** 2037,2041 **** then case $ac_sys_system/$ac_sys_release in ! AIX*) DYNLOADFILE="dynload_aix.o";; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; --- 2042,2051 ---- then case $ac_sys_system/$ac_sys_release in ! AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c ! if test "$ac_cv_func_dlopen" = yes ! then DYNLOADFILE="dynload_shlib.o" ! else DYNLOADFILE="dynload_aix.o" ! fi ! ;; BeOS*) DYNLOADFILE="dynload_beos.o";; hp*|HP*) DYNLOADFILE="dynload_hpux.o";; From jackjansen at users.sourceforge.net Tue Nov 18 17:36:15 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 18 17:37:52 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_applesingle.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv24912 Added Files: test_applesingle.py Log Message: Test the applesingle decoder. --- NEW FILE: test_applesingle.py --- # Copyright (C) 2003 Python Software Foundation import unittest import macostools import Carbon.File import MacOS import os import sys from test import test_support import struct import applesingle AS_MAGIC=0x00051600 AS_VERSION=0x00020000 dataforkdata = 'hello\r\0world\n' resourceforkdata = 'goodbye\ncruel\0world\r' applesingledata = struct.pack("ll16sh", AS_MAGIC, AS_VERSION, "foo", 2) + \ struct.pack("llllll", 1, 50, len(dataforkdata), 2, 50+len(dataforkdata), len(resourceforkdata)) + \ dataforkdata + \ resourceforkdata TESTFN2 = test_support.TESTFN + '2' class TestApplesingle(unittest.TestCase): def setUp(self): fp = open(test_support.TESTFN, 'w') fp.write(applesingledata) fp.close() def tearDown(self): try: os.unlink(test_support.TESTFN) except: pass try: os.unlink(TESTFN2) except: pass def compareData(self, isrf, data): if isrf: fp = MacOS.openrf(TESTFN2, '*rb') else: fp = open(TESTFN2, 'rb') filedata = fp.read(1000) self.assertEqual(data, filedata) def test_applesingle(self): try: os.unlink(TESTFN2) except: pass applesingle.decode(test_support.TESTFN, TESTFN2) self.compareData(False, dataforkdata) self.compareData(True, resourceforkdata) def test_applesingle_resonly(self): try: os.unlink(TESTFN2) except: pass applesingle.decode(test_support.TESTFN, TESTFN2, resonly=True) self.compareData(False, resourceforkdata) def test_main(): test_support.run_unittest(TestApplesingle) if __name__ == '__main__': test_main() From jvr at users.sourceforge.net Tue Nov 18 17:41:18 2003 From: jvr at users.sourceforge.net (jvr@users.sourceforge.net) Date: Tue Nov 18 17:42:45 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PyEdit.py, 1.43, 1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv25422 Modified Files: PyEdit.py Log Message: Fix for [ 782686 ]: new files used \r as the default line separator instead of os.linesep. Index: PyEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** PyEdit.py 9 May 2003 08:58:02 -0000 1.43 --- PyEdit.py 18 Nov 2003 22:41:16 -0000 1.44 *************** *** 58,76 **** self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) else: raise IOError, "file '%s' does not exist" % path self.path = path - if '\n' in text: - if string.find(text, '\r\n') >= 0: - self._eoln = '\r\n' - else: - self._eoln = '\n' - text = string.replace(text, self._eoln, '\r') - change = 0 - else: - change = 0 - self._eoln = '\r' - self.settings = {} if self.path: --- 58,73 ---- self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) + if '\n' in text: + if string.find(text, '\r\n') >= 0: + self._eoln = '\r\n' + else: + self._eoln = '\n' + text = string.replace(text, self._eoln, '\r') + else: + self._eoln = '\r' else: raise IOError, "file '%s' does not exist" % path self.path = path self.settings = {} if self.path: *************** *** 94,99 **** W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) self.setupwidgets(text) - if change > 0: - self.editgroup.editor.textchanged() if self.settings.has_key("selection"): --- 91,94 ---- From jvr at users.sourceforge.net Tue Nov 18 17:46:10 2003 From: jvr at users.sourceforge.net (jvr@users.sourceforge.net) Date: Tue Nov 18 17:46:14 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PyEdit.py, 1.43, 1.43.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv26902 Modified Files: Tag: release23-maint PyEdit.py Log Message: Backport of fix for [ 782686 ]: new files used \r as the default line separator instead of os.linesep. Index: PyEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v retrieving revision 1.43 retrieving revision 1.43.8.1 diff -C2 -d -r1.43 -r1.43.8.1 *** PyEdit.py 9 May 2003 08:58:02 -0000 1.43 --- PyEdit.py 18 Nov 2003 22:46:08 -0000 1.43.8.1 *************** *** 58,76 **** self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) else: raise IOError, "file '%s' does not exist" % path self.path = path - if '\n' in text: - if string.find(text, '\r\n') >= 0: - self._eoln = '\r\n' - else: - self._eoln = '\n' - text = string.replace(text, self._eoln, '\r') - change = 0 - else: - change = 0 - self._eoln = '\r' - self.settings = {} if self.path: --- 58,73 ---- self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) + if '\n' in text: + if string.find(text, '\r\n') >= 0: + self._eoln = '\r\n' + else: + self._eoln = '\n' + text = string.replace(text, self._eoln, '\r') + else: + self._eoln = '\r' else: raise IOError, "file '%s' does not exist" % path self.path = path self.settings = {} if self.path: *************** *** 94,99 **** W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) self.setupwidgets(text) - if change > 0: - self.editgroup.editor.textchanged() if self.settings.has_key("selection"): --- 91,94 ---- From jvr at users.sourceforge.net Tue Nov 18 18:00:58 2003 From: jvr at users.sourceforge.net (jvr@users.sourceforge.net) Date: Tue Nov 18 18:01:02 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_zipimport.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv29314 Modified Files: test_zipimport.py Log Message: Fix for [ 765456 ]: testAFakeZlib failed on platforms that use a statically linked zlib module, but since the problem it tests can't exist on these systems, simply skip it then. Will backport. Index: test_zipimport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipimport.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_zipimport.py 22 Jul 2003 18:10:02 -0000 1.10 --- test_zipimport.py 18 Nov 2003 23:00:55 -0000 1.11 *************** *** 96,99 **** --- 96,106 ---- # item in a list sorted by name, like unittest.makeSuite() does.) # + # This test fails on platforms on which the zlib module is + # statically linked, but the problem it tests for can't + # occur in that case (builtin modules are always found first), + # so we'll simply skip it then. Bug #765456. + # + if "zlib" in sys.builtin_module_names: + return if "zlib" in sys.modules: del sys.modules["zlib"] From jvr at users.sourceforge.net Tue Nov 18 18:04:30 2003 From: jvr at users.sourceforge.net (jvr@users.sourceforge.net) Date: Tue Nov 18 18:04:33 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_zipimport.py, 1.10, 1.10.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv30772 Modified Files: Tag: release23-maint test_zipimport.py Log Message: Backport of fix for [ 765456 ]: testAFakeZlib failed on platforms that use a statically linked zlib module, but since the problem it tests can't exist on these systems, simply skip it then. Index: test_zipimport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipimport.py,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** test_zipimport.py 22 Jul 2003 18:10:02 -0000 1.10 --- test_zipimport.py 18 Nov 2003 23:04:28 -0000 1.10.4.1 *************** *** 96,99 **** --- 96,106 ---- # item in a list sorted by name, like unittest.makeSuite() does.) # + # This test fails on platforms on which the zlib module is + # statically linked, but the problem it tests for can't + # occur in that case (builtin modules are always found first), + # so we'll simply skip it then. Bug #765456. + # + if "zlib" in sys.builtin_module_names: + return if "zlib" in sys.modules: del sys.modules["zlib"] From jackjansen at users.sourceforge.net Tue Nov 18 18:09:22 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Nov 18 18:09:27 2003 Subject: [Python-checkins] python/dist/src/Lib/plat-mac applesingle.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1:/tmp/cvs-serv29399 Modified Files: applesingle.py Log Message: Modified version by Bob Ippolito. It passes the just-added test_applesingle after some minor mods. Fixes #803498, but should NOT be backported because the original problem seems to be unreproducable. Index: applesingle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/applesingle.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** applesingle.py 9 Apr 2003 13:25:42 -0000 1.2 --- applesingle.py 18 Nov 2003 23:09:19 -0000 1.3 *************** *** 1,13 **** ! # applesingle - a module to decode AppleSingle files import struct - import MacOS import sys ! Error="applesingle.Error" ! ! verbose=0 # File header format: magic, version, unused, number of entries ! AS_HEADER_FORMAT="ll16sh" AS_HEADER_LENGTH=26 # The flag words for AppleSingle --- 1,30 ---- ! r"""Routines to decode AppleSingle files ! """ import struct import sys + try: + import MacOS + import Carbon.File + except: + class MacOS: + def openrf(path, mode): + return open(path + '.rsrc', mode) + openrf = classmethod(openrf) + class Carbon: + class File: + class FSSpec: + pass + class FSRef: + pass + class Alias: + pass ! # all of the errors in this module are really errors in the input ! # so I think it should test positive against ValueError. ! class Error(ValueError): ! pass # File header format: magic, version, unused, number of entries ! AS_HEADER_FORMAT="LL16sh" AS_HEADER_LENGTH=26 # The flag words for AppleSingle *************** *** 24,88 **** AS_IGNORE=(3,4,5,6,8,9,10,11,12,13,14,15) ! def decode(input, output, resonly=0): ! if type(input) == type(''): ! input = open(input, 'rb') ! # Should we also test for FSSpecs or FSRefs? ! header = input.read(AS_HEADER_LENGTH) ! try: ! magic, version, dummy, nentry = struct.unpack(AS_HEADER_FORMAT, header) ! except ValueError, arg: ! raise Error, "Unpack header error: %s"%arg ! if verbose: ! print 'Magic: 0x%8.8x'%magic ! print 'Version: 0x%8.8x'%version ! print 'Entries: %d'%nentry ! if magic != AS_MAGIC: ! raise Error, 'Unknown AppleSingle magic number 0x%8.8x'%magic ! if version != AS_VERSION: ! raise Error, 'Unknown AppleSingle version number 0x%8.8x'%version ! if nentry <= 0: ! raise Error, "AppleSingle file contains no forks" ! headers = [input.read(AS_ENTRY_LENGTH) for i in range(nentry)] ! didwork = 0 ! for hdr in headers: try: ! id, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr) except ValueError, arg: ! raise Error, "Unpack entry error: %s"%arg if verbose: ! print 'Fork %d, offset %d, length %d'%(id, offset, length) ! input.seek(offset) ! if length == 0: ! data = '' ! else: ! data = input.read(length) ! if len(data) != length: ! raise Error, 'Short read: expected %d bytes got %d'%(length, len(data)) ! if id == AS_DATAFORK: ! if verbose: ! print ' (data fork)' ! if not resonly: ! didwork = 1 ! fp = open(output, 'wb') ! fp.write(data) ! fp.close() ! elif id == AS_RESOURCEFORK: ! didwork = 1 if verbose: ! print ' (resource fork)' ! if resonly: ! fp = open(output, 'wb') ! else: ! fp = MacOS.openrf(output, 'wb') ! fp.write(data) fp.close() ! elif id in AS_IGNORE: ! if verbose: ! print ' (ignored)' else: ! raise Error, 'Unknown fork type %d'%id ! if not didwork: ! raise Error, 'No useful forks found' def _test(): if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4: --- 41,126 ---- AS_IGNORE=(3,4,5,6,8,9,10,11,12,13,14,15) ! class AppleSingle(object): ! datafork = None ! resourcefork = None ! ! def __init__(self, fileobj, verbose=False): ! header = fileobj.read(AS_HEADER_LENGTH) try: ! magic, version, ig, nentry = struct.unpack(AS_HEADER_FORMAT, header) except ValueError, arg: ! raise Error, "Unpack header error: %s" % (arg,) if verbose: ! print 'Magic: 0x%8.8x' % (magic,) ! print 'Version: 0x%8.8x' % (version,) ! print 'Entries: %d' % (nentry,) ! if magic != AS_MAGIC: ! raise Error, "Unknown AppleSingle magic number 0x%8.8x" % (magic,) ! if version != AS_VERSION: ! raise Error, "Unknown AppleSingle version number 0x%8.8x" % (version,) ! if nentry <= 0: ! raise Error, "AppleSingle file contains no forks" ! headers = [fileobj.read(AS_ENTRY_LENGTH) for i in xrange(nentry)] ! self.forks = [] ! for hdr in headers: ! try: ! restype, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr) ! except ValueError, arg: ! raise Error, "Unpack entry error: %s" % (arg,) if verbose: ! print "Fork %d, offset %d, length %d" % (restype, offset, length) ! fileobj.seek(offset) ! data = fileobj.read(length) ! if len(data) != length: ! raise Error, "Short read: expected %d bytes got %d" % (length, len(data)) ! self.forks.append((restype, data)) ! if restype == AS_DATAFORK: ! self.datafork = data ! elif restype == AS_RESOURCEFORK: ! self.resourcefork = data ! ! def tofile(self, path, resonly=False): ! outfile = open(path, 'wb') ! data = False ! if resonly: ! if self.resourcefork is None: ! raise Error, "No resource fork found" ! fp = open(path, 'wb') ! fp.write(self.resourcefork) fp.close() ! elif (self.resourcefork is None and self.datafork is None): ! raise Error, "No useful forks found" else: ! if self.datafork is not None: ! fp = open(path, 'wb') ! fp.write(self.datafork) ! fp.close() ! if self.resourcefork is not None: ! fp = MacOS.openrf(path, '*wb') ! fp.write(self.resourcefork) ! fp.close() ! ! def decode(infile, outpath, resonly=False, verbose=False): ! """decode(infile, outpath [, resonly=False, verbose=False]) ! ! Creates a decoded file from an AppleSingle encoded file. ! If resonly is True, then it will create a regular file at ! outpath containing only the resource fork from infile. ! Otherwise it will create an AppleDouble file at outpath ! with the data and resource forks from infile. On platforms ! without the MacOS module, it will create inpath and inpath+'.rsrc' ! with the data and resource forks respectively. ! ! """ ! if not hasattr(infile, 'read'): ! if isinstance(infile, Carbon.File.Alias): ! infile = infile.ResolveAlias()[0] ! if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)): ! infile = infile.as_pathname() ! infile = open(infile, 'rb') + as = AppleSingle(infile, verbose=verbose) + as.tofile(outpath, resonly=resonly) + def _test(): if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4: *************** *** 90,100 **** sys.exit(1) if sys.argv[1] == '-r': ! resonly = 1 del sys.argv[1] else: ! resonly = 0 decode(sys.argv[1], sys.argv[2], resonly=resonly) if __name__ == '__main__': _test() - \ No newline at end of file --- 128,137 ---- sys.exit(1) if sys.argv[1] == '-r': ! resonly = True del sys.argv[1] else: ! resonly = False decode(sys.argv[1], sys.argv[2], resonly=resonly) if __name__ == '__main__': _test() From bwarsaw at users.sourceforge.net Tue Nov 18 21:19:45 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Nov 18 21:19:49 2003 Subject: [Python-checkins] python/dist/src/Lib/email Generator.py, 1.21, 1.21.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1:/tmp/cvs-serv31002 Modified Files: Tag: release23-maint Generator.py Log Message: __init__(): The docstring was incorrect regarding how header wrapping gets done when maxheaderlen <> 0. The header really gets wrapped via the email.Header.Header class, which has a more sophisticated algorithm than just splitting on semi-colons. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.21 retrieving revision 1.21.8.1 diff -C2 -d -r1.21 -r1.21.8.1 *** Generator.py 24 Jun 2003 20:19:34 -0000 1.21 --- Generator.py 19 Nov 2003 02:19:43 -0000 1.21.8.1 *************** *** 71,79 **** Optional maxheaderlen specifies the longest length for a non-continued header. When a header line is longer (in characters, with tabs ! expanded to 8 spaces), than maxheaderlen, the header will be broken on ! semicolons and continued as per RFC 2822. If no semicolon is found, ! then the header is left alone. Set to zero to disable wrapping ! headers. Default is 78, as recommended (but not required by RFC ! 2822. """ self._fp = outfp --- 71,78 ---- Optional maxheaderlen specifies the longest length for a non-continued header. When a header line is longer (in characters, with tabs ! expanded to 8 spaces) than maxheaderlen, the header will split as ! defined in the Header class. Set maxheaderlen to zero to disable ! header wrapping. The default is 78, as recommended (but not required) ! by RFC 2822. """ self._fp = outfp From bwarsaw at users.sourceforge.net Tue Nov 18 21:20:17 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Nov 18 21:20:20 2003 Subject: [Python-checkins] python/dist/src/Doc/lib emailgenerator.tex, 1.6, 1.6.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv31131 Modified Files: Tag: release23-maint emailgenerator.tex Log Message: Generator's constructor: The documentation was incorrect regarding how header wrapping gets done when maxheaderlen <> 0. The header really gets wrapped via the email.Header.Header class, which has a more sophisticated algorithm than just splitting on semi-colons. Index: emailgenerator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/emailgenerator.tex,v retrieving revision 1.6 retrieving revision 1.6.16.1 diff -C2 -d -r1.6 -r1.6.16.1 *** emailgenerator.tex 1 Oct 2002 15:29:09 -0000 1.6 --- emailgenerator.tex 19 Nov 2003 02:20:14 -0000 1.6.16.1 *************** *** 41,47 **** non-continued header. When a header line is longer than \var{maxheaderlen} (in characters, with tabs expanded to 8 spaces), ! the header will be broken on semicolons and continued as per ! \rfc{2822}. If no semicolon is found, then the header is left alone. ! Set to zero to disable wrapping headers. Default is 78, as recommended (but not required) by \rfc{2822}. \end{classdesc} --- 41,46 ---- non-continued header. When a header line is longer than \var{maxheaderlen} (in characters, with tabs expanded to 8 spaces), ! the header will be split as defined in the \module{email.Header} ! class. Set to zero to disable header wrapping. The default is 78, as recommended (but not required) by \rfc{2822}. \end{classdesc} From bwarsaw at users.sourceforge.net Tue Nov 18 21:22:38 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Nov 18 21:22:41 2003 Subject: [Python-checkins] python/dist/src/Doc/lib emailgenerator.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv31417 Modified Files: emailgenerator.tex Log Message: Generator's constructor: The documentation was incorrect regarding how header wrapping gets done when maxheaderlen <> 0. The header really gets wrapped via the email.Header.Header class, which has a more sophisticated algorithm than just splitting on semi-colons. Index: emailgenerator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/emailgenerator.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** emailgenerator.tex 1 Oct 2002 15:29:09 -0000 1.6 --- emailgenerator.tex 19 Nov 2003 02:22:36 -0000 1.7 *************** *** 41,47 **** non-continued header. When a header line is longer than \var{maxheaderlen} (in characters, with tabs expanded to 8 spaces), ! the header will be broken on semicolons and continued as per ! \rfc{2822}. If no semicolon is found, then the header is left alone. ! Set to zero to disable wrapping headers. Default is 78, as recommended (but not required) by \rfc{2822}. \end{classdesc} --- 41,46 ---- non-continued header. When a header line is longer than \var{maxheaderlen} (in characters, with tabs expanded to 8 spaces), ! the header will be split as defined in the \module{email.Header} ! class. Set to zero to disable header wrapping. The default is 78, as recommended (but not required) by \rfc{2822}. \end{classdesc} From bwarsaw at users.sourceforge.net Tue Nov 18 21:23:04 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Nov 18 21:23:06 2003 Subject: [Python-checkins] python/dist/src/Lib/email Generator.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1:/tmp/cvs-serv31443 Modified Files: Generator.py Log Message: __init__(): The docstring was incorrect regarding how header wrapping gets done when maxheaderlen <> 0. The header really gets wrapped via the email.Header.Header class, which has a more sophisticated algorithm than just splitting on semi-colons. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Generator.py 24 Jun 2003 20:19:34 -0000 1.21 --- Generator.py 19 Nov 2003 02:23:01 -0000 1.22 *************** *** 71,79 **** Optional maxheaderlen specifies the longest length for a non-continued header. When a header line is longer (in characters, with tabs ! expanded to 8 spaces), than maxheaderlen, the header will be broken on ! semicolons and continued as per RFC 2822. If no semicolon is found, ! then the header is left alone. Set to zero to disable wrapping ! headers. Default is 78, as recommended (but not required by RFC ! 2822. """ self._fp = outfp --- 71,78 ---- Optional maxheaderlen specifies the longest length for a non-continued header. When a header line is longer (in characters, with tabs ! expanded to 8 spaces) than maxheaderlen, the header will split as ! defined in the Header class. Set maxheaderlen to zero to disable ! header wrapping. The default is 78, as recommended (but not required) ! by RFC 2822. """ self._fp = outfp From kbk at users.sourceforge.net Tue Nov 18 23:52:34 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Tue Nov 18 23:52:38 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.24, 1.25 run.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv19984 Modified Files: NEWS.txt run.py Log Message: - After an exception, run.py was not setting the exception vector. Noam Raphael suggested correcting this so pdb's postmortem pm() would work. IDLEfork Patch 844675 Modified: NEWS.txt run.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** NEWS.txt 14 Aug 2003 14:54:28 -0000 1.24 --- NEWS.txt 19 Nov 2003 04:52:32 -0000 1.25 *************** *** 4,7 **** --- 4,11 ---- *Release date: XX-XXX-2003* + - After an exception, run.py was not setting the exception vector. Noam + Raphael suggested correcting this so pdb's postmortem pm() would work. + IDLEfork Patch 844675 + - IDLE didn't start correctly when Python was installed in "Program Files" on W2K and XP. Python Bugs 780451, 784183 Index: run.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/run.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** run.py 22 Jun 2003 07:52:56 -0000 1.25 --- run.py 19 Nov 2003 04:52:32 -0000 1.26 *************** *** 112,116 **** flush_stdout() efile = sys.stderr ! typ, val, tb = sys.exc_info() tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' --- 112,117 ---- flush_stdout() efile = sys.stderr ! typ, val, tb = excinfo = sys.exc_info() ! sys.last_type, sys.last_value, sys.last_traceback = excinfo tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' From jackjansen at users.sourceforge.net Wed Nov 19 08:33:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:33:27 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv29633 Modified Files: Makefile Log Message: Upped version Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** Makefile 23 Jul 2003 10:49:17 -0000 1.50 --- Makefile 19 Nov 2003 13:33:19 -0000 1.51 *************** *** 3,7 **** # commandline in that case. ! VERSION=2.3 builddir = ../.. srcdir = ../.. --- 3,7 ---- # commandline in that case. ! VERSION=2.4 builddir = ../.. srcdir = ../.. From jackjansen at users.sourceforge.net Wed Nov 19 08:33:50 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:33:53 2003 Subject: [Python-checkins] python/dist/src/Mac/Distributions readme.txt, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory sc8-pr-cvs1:/tmp/cvs-serv29691 Modified Files: readme.txt Log Message: Added a site Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/readme.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** readme.txt 29 Apr 2003 21:49:30 -0000 1.10 --- readme.txt 19 Nov 2003 13:33:47 -0000 1.11 *************** *** 54,57 **** --- 54,58 ---- http://www.apple.com/downloads/macosx/submit http://www.versiontracker.com/ (userid Jack.Jansen@oratrix.com) + http://www.macshareware.net (userid jackjansen) Also, check out Stephan Deibels http://pythonology.org/market contact list - Open PythonX.Y.vct again, use the "remove compressed files" command to trim down From doerwalter at users.sourceforge.net Wed Nov 19 08:35:51 2003 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Wed Nov 19 08:35:54 2003 Subject: [Python-checkins] python/dist/src/Lib codeop.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv29941/Lib Modified Files: codeop.py Log Message: Fix typos. Index: codeop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** codeop.py 16 May 2003 01:24:30 -0000 1.7 --- codeop.py 19 Nov 2003 13:35:49 -0000 1.8 *************** *** 2,11 **** This module provides two interfaces, broadly similar to the builtin ! function compile(), that take progam text, a filename and a 'mode' and: ! - Return a code object if the command is complete and valid ! - Return None if the command is incomplete ! - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). --- 2,11 ---- This module provides two interfaces, broadly similar to the builtin ! function compile(), that takes program text, a filename and a 'mode' and: ! - Returns code object if the command is complete and valid ! - Returns None if the command is incomplete ! - Raises SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). From doerwalter at users.sourceforge.net Wed Nov 19 08:37:03 2003 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Wed Nov 19 08:37:05 2003 Subject: [Python-checkins] python/dist/src/Lib codeop.py,1.7,1.7.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv30176/Lib Modified Files: Tag: release23-maint codeop.py Log Message: Backport checkin: Fix typos. Index: codeop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v retrieving revision 1.7 retrieving revision 1.7.8.1 diff -C2 -d -r1.7 -r1.7.8.1 *** codeop.py 16 May 2003 01:24:30 -0000 1.7 --- codeop.py 19 Nov 2003 13:37:01 -0000 1.7.8.1 *************** *** 2,11 **** This module provides two interfaces, broadly similar to the builtin ! function compile(), that take progam text, a filename and a 'mode' and: ! - Return a code object if the command is complete and valid ! - Return None if the command is incomplete ! - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). --- 2,11 ---- This module provides two interfaces, broadly similar to the builtin ! function compile(), that takes program text, a filename and a 'mode' and: ! - Returns a code object if the command is complete and valid ! - Returns None if the command is incomplete ! - Raises SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). From jackjansen at users.sourceforge.net Wed Nov 19 08:37:24 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:37:27 2003 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplet.icns, 1.1, 1.2 BuildApplet.plist, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv30170 Added Files: BuildApplet.icns BuildApplet.plist Log Message: Ported from 23maint branch: add icons to BuildApplet. From jackjansen at users.sourceforge.net Wed Nov 19 08:45:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:45:34 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.plist, 1.1, 1.2 PackageManager.py, 1.14, 1.15 PythonIDE.plist, 1.2, 1.3 PythonIDE.py, 1.13, 1.14 PythonIDEMain.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv31188 Modified Files: PackageManager.py PythonIDE.plist PythonIDE.py PythonIDEMain.py Added Files: PackageManager.plist Log Message: Forward port of various fixes that were initially only done on the release23-maint branch: - Remember the scroll position when rebuilding the browser (as we do far too often). Fixes #824430. - Allow for the documentation to be inside PythonIDE as well as in the Python.app inside the framework (the original location for 2.3). - Updated version numbers - In PythonIDE, add the Tools/IDE directory as the second entry in sys.path in stead of as the first, leaving PythonIDE.app/Contents/Resources as the first one. - The code for setting the working directory to $HOME was both incorrect and in the wrong place, fixed. - On OSX the default location for IDE scripts is now $HOME/Library/Python/IDE-Scripts. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PackageManager.py 21 Jul 2003 22:11:07 -0000 1.14 --- PackageManager.py 19 Nov 2003 13:45:26 -0000 1.15 *************** *** 367,370 **** --- 367,371 ---- def updatestatus(self): + topcell = self.w.packagebrowser.gettopcell() sel = self.w.packagebrowser.getselection() data = self.getbrowserdata(self.w.hidden_button.get()) *************** *** 397,400 **** --- 398,402 ---- self.w.force_button.enable(1) self.w.user_button.enable(1) + self.w.packagebrowser.settopcell(topcell) def listhit(self, *args, **kwargs): Index: PythonIDE.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.plist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonIDE.plist 4 Jul 2003 13:06:14 -0000 1.2 --- PythonIDE.plist 19 Nov 2003 13:45:26 -0000 1.3 *************** *** 28,38 **** CFBundleGetInfoString ! 2.3, (c) 2003 Python Software Foundation. CFBundleLongVersionString ! 2.3, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString ! 2.3 CFBundleIconFile --- 28,47 ---- CFBundleGetInfoString ! 2.4a0, (c) 2003 Python Software Foundation. CFBundleLongVersionString ! 2.4a0, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString ! 2.4a0 ! ! CFBundleHelpBookFolder ! ! PythonDocumentation ! ! CFBundleHelpBookName ! Python Help ! CFBundleHelpTOCFile ! index.html CFBundleIconFile *************** *** 49,53 **** Pide CFBundleVersion ! 2.3 LSRequiresCarbon --- 58,62 ---- Pide CFBundleVersion ! 2.3.2 LSRequiresCarbon Index: PythonIDE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDE.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PythonIDE.py 3 May 2003 00:31:35 -0000 1.13 --- PythonIDE.py 19 Nov 2003 13:45:26 -0000 1.14 *************** *** 50,54 **** ide_path = sys.argv[0] if ide_path not in sys.path: ! sys.path.insert(0, ide_path) --- 50,54 ---- ide_path = sys.argv[0] if ide_path not in sys.path: ! sys.path.insert(1, ide_path) Index: PythonIDEMain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDEMain.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** PythonIDEMain.py 6 May 2003 14:28:31 -0000 1.35 --- PythonIDEMain.py 19 Nov 2003 13:45:26 -0000 1.36 *************** *** 33,36 **** --- 33,41 ---- def __init__(self): + if sys.platform == "darwin": + if len(sys.argv) > 1 and sys.argv[1].startswith("-psn"): + home = os.getenv("HOME") + if home: + os.chdir(home) self.preffilepath = os.path.join("Python", "PythonIDE preferences") Wapplication.Application.__init__(self, 'Pide') *************** *** 50,58 **** import PyConsole, PyEdit Splash.wait() - if sys.platform == "darwin": - if sys.argv and sys.argv[0].startswith("-psn"): - home = os.getenv("HOME") - if home: - os.chdir(home) # With -D option (OSX command line only) keep stderr, for debugging the IDE # itself. --- 55,58 ---- *************** *** 141,147 **** path = os.path.join(os.getcwd(), "Mac", "IDE scripts") if not os.path.exists(path): ! path = os.path.join(os.getcwd(), "Scripts") if not os.path.exists(path): ! os.mkdir(path) f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w") f.close() --- 141,150 ---- path = os.path.join(os.getcwd(), "Mac", "IDE scripts") if not os.path.exists(path): ! if sys.platform == "darwin": ! path = os.path.join(os.getenv("HOME"), "Library", "Python", "IDE-Scripts") ! else: ! path = os.path.join(os.getcwd(), "Scripts") if not os.path.exists(path): ! os.makedirs(path) f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w") f.close() *************** *** 452,460 **** # And as AHRegisterHelpBook wants a bundle (with the right bits in # the plist file) we refer it to Python.app python_app = os.path.join(sys.prefix, 'Resources/Python.app') ! help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation') ! doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation') ! has_help = os.path.isdir(help_source) ! has_doc = os.path.isdir(doc_source) if has_help or has_doc: try: --- 455,483 ---- # And as AHRegisterHelpBook wants a bundle (with the right bits in # the plist file) we refer it to Python.app + # + # To make matters worse we have to look in two places: first in the IDE + # itself, then in the Python application inside the framework. + has_help = False + has_doc = False + ide_path_components = sys.argv[0].split("/") + if ide_path_components[-3:] == ["Contents", "Resources", "PythonIDE.py"]: + ide_app = "/".join(ide_path_components[:-3]) + help_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/Documentation') + doc_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/PythonDocumentation') + has_help = os.path.isdir(help_source) + has_doc = os.path.isdir(doc_source) + if has_help or has_doc: + try: + from Carbon import AH + AH.AHRegisterHelpBook(ide_app) + except (ImportError, MacOS.Error), arg: + pass # W.Message("Cannot register Python Documentation: %s" % str(arg)) python_app = os.path.join(sys.prefix, 'Resources/Python.app') ! if not has_help: ! help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation') ! has_help = os.path.isdir(help_source) ! if not has_doc: ! doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation') ! has_doc = os.path.isdir(doc_source) if has_help or has_doc: try: From jackjansen at users.sourceforge.net Wed Nov 19 08:47:25 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:47:28 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/framework/English.lproj InfoPlist.strings, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/framework/English.lproj In directory sc8-pr-cvs1:/tmp/cvs-serv31964 Modified Files: InfoPlist.strings Log Message: This file is utf-16, not utf-8 (or ascii). Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/framework/English.lproj/InfoPlist.strings,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsVatzjx and /tmp/cvsQm3rsU differ From jackjansen at users.sourceforge.net Wed Nov 19 08:48:15 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:48:19 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/framework version.plist, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/framework In directory sc8-pr-cvs1:/tmp/cvs-serv32220 Modified Files: version.plist Log Message: Upped. Index: version.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/framework/version.plist,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** version.plist 4 Jul 2003 13:06:14 -0000 1.3 --- version.plist 19 Nov 2003 13:48:13 -0000 1.4 *************** *** 6,18 **** 1 CFBundleShortVersionString ! 2.3 CFBundleVersion ! 2.3 ProjectName Python ReleaseStatus ! final SourceVersion ! 2.3 --- 6,18 ---- 1 CFBundleShortVersionString ! 2.4a0 CFBundleVersion ! 2.4a0 ProjectName Python ReleaseStatus ! alfa SourceVersion ! 2.4a0 From jackjansen at users.sourceforge.net Wed Nov 19 08:49:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:49:36 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app/Resources/English.lproj InfoPlist.strings, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj In directory sc8-pr-cvs1:/tmp/cvs-serv32492 Modified Files: InfoPlist.strings Log Message: Upped version numbers, and converted to UTF-16. Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj/InfoPlist.strings,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvs0h61cZ and /tmp/cvsUnoOeO differ From jackjansen at users.sourceforge.net Wed Nov 19 08:50:23 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:50:29 2003 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app Info.plist, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app In directory sc8-pr-cvs1:/tmp/cvs-serv32651 Modified Files: Info.plist Log Message: Upped version Index: Info.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Info.plist,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Info.plist 4 Jul 2003 13:06:14 -0000 1.11 --- Info.plist 19 Nov 2003 13:50:21 -0000 1.12 *************** *** 22,32 **** CFBundleGetInfoString ! 2.3, (c) 2003 Python Software Foundation. CFBundleLongVersionString ! 2.3, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString ! 2.3 CFBundleHelpBookFolder --- 22,32 ---- CFBundleGetInfoString ! 2.4a0, (c) 2003 Python Software Foundation. CFBundleLongVersionString ! 2.4a0, (c) 2003 Python Software Foundation. NSHumanReadableCopyright Copyright 2003 Python Software Foundation. CFBundleShortVersionString ! 2.4a0 CFBundleHelpBookFolder *************** *** 53,57 **** PytX CFBundleVersion ! 2.3 LSRequiresCarbon --- 53,57 ---- PytX CFBundleVersion ! 2.4a0 LSRequiresCarbon From jackjansen at users.sourceforge.net Wed Nov 19 08:53:57 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:54:01 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist build,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1:/tmp/cvs-serv801 Modified Files: build Log Message: Moved various files over from the release23-maint branch. Index: build =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/build,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** build 23 Jul 2003 10:51:55 -0000 1.12 --- build 19 Nov 2003 13:53:55 -0000 1.13 *************** *** 6,12 **** # Script configs ! PYVERSION=2.3rc1plus ! PYVER=2.3 ! BUILDNUM=8 DOCLEANUP=no --- 6,12 ---- # Script configs ! PYVERSION=2.4a0 ! PYVER=2.4 ! BUILDNUM=1 DOCLEANUP=no *************** *** 134,138 **** # ...and then make a disk image containing the package. mv MacPython-OSX.pkg $DMGDIR/root ! cp $RESOURCEDIR/Welcome.txt $DMGDIR/root/README.txt $PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM --- 134,138 ---- # ...and then make a disk image containing the package. mv MacPython-OSX.pkg $DMGDIR/root ! cp $RESOURCEDIR/ReadMe.txt $DMGDIR/root/ReadMe.txt $PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM From jackjansen at users.sourceforge.net Wed Nov 19 08:53:57 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:54:04 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources ReadMe.txt, 1.1, 1.2 Welcome.rtf, 1.1, 1.2 Welcome.txt, 1.6, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources In directory sc8-pr-cvs1:/tmp/cvs-serv801/resources Added Files: ReadMe.txt Welcome.rtf Removed Files: Welcome.txt Log Message: Moved various files over from the release23-maint branch. --- Welcome.txt DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 08:56:45 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 08:56:53 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv1469 Modified Files: Makefile Log Message: Temporary fix for buildon on both Panther and Jaguar. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** Makefile 19 Nov 2003 13:33:19 -0000 1.51 --- Makefile 19 Nov 2003 13:56:40 -0000 1.52 *************** *** 10,13 **** --- 10,17 ---- BUILDPYTHON=$(builddir)/python.exe DESTDIR= + # For 10.2: + #PBXBUILD=pbxbuild + # For 10.3: + PBXBUILD=xcodebuild # These are normally glimpsed from the previous set *************** *** 59,63 **** install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ ! pbxbuild -target PythonLauncher -buildstyle Deployment install \ DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH) --- 63,67 ---- install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ ! $(PBXBUILD) -target PythonLauncher -buildstyle Deployment install \ DSTROOT=$(DESTDIR)/ INSTALL_PATH=$(PYTHONAPPSPATH) From jackjansen at users.sourceforge.net Wed Nov 19 09:33:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:04 2003 Subject: [Python-checkins] python/dist/src/Mac HISTORY, 1.1, NONE ReadMe, 1.48, NONE ReadMe-dev, 1.4, NONE ReadMe-src, 1.3, NONE _checkversion.py, 1.13, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory sc8-pr-cvs1:/tmp/cvs-serv7413 Removed Files: HISTORY ReadMe ReadMe-dev ReadMe-src _checkversion.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- HISTORY DELETED --- --- ReadMe DELETED --- --- ReadMe-dev DELETED --- --- ReadMe-src DELETED --- --- _checkversion.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:14 2003 Subject: [Python-checkins] python/dist/src/Mac/Compat sync.c,1.3,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Compat In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Compat Removed Files: sync.c Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- sync.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:19 2003 Subject: [Python-checkins] python/dist/src/Mac/Build HtmlRender.prj, 1.3, NONE PythonCore.axp, 1.1, NONE PythonCore.mcp, 1.44, NONE PythonInterpreter.mcp, 1.23, NONE PythonStandSmall.mcp, 1.50, NONE PythonStandalone.mcp, 1.24, NONE _CG.carbon.mcp, 1.7, NONE _CG.carbon.mcp.exp, 1.1, NONE _dummy_tkinter.mcp, 1.6, NONE _dummy_tkinter.mcp.exp, 1.3, NONE buildlibs.mcp, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Build Removed Files: HtmlRender.prj PythonCore.axp PythonCore.mcp PythonInterpreter.mcp PythonStandSmall.mcp PythonStandalone.mcp _CG.carbon.mcp _CG.carbon.mcp.exp _dummy_tkinter.mcp _dummy_tkinter.mcp.exp buildlibs.mcp Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- HtmlRender.prj DELETED --- --- PythonCore.axp DELETED --- --- PythonCore.mcp DELETED --- --- PythonInterpreter.mcp DELETED --- --- PythonStandSmall.mcp DELETED --- --- PythonStandalone.mcp DELETED --- --- _CG.carbon.mcp DELETED --- --- _CG.carbon.mcp.exp DELETED --- --- _dummy_tkinter.mcp DELETED --- --- _dummy_tkinter.mcp.exp DELETED --- --- buildlibs.mcp DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:23 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/AECaptureParser AECaptureParser.py, 1.2, NONE readme.txt, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/AECaptureParser In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/AECaptureParser Removed Files: AECaptureParser.py readme.txt Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- AECaptureParser.py DELETED --- --- readme.txt DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:07 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:27 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/BBPy/source BBPy.h, 1.1.1.1, NONE BBPy.rsrc, 1.2, NONE BBPy_lauch.c, 1.1.1.1, NONE BBPy_launch.c, 1.1.1.1, NONE BBPy_main.c, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/BBPy/source In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/BBPy/source Removed Files: BBPy.h BBPy.rsrc BBPy_lauch.c BBPy_launch.c BBPy_main.c Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- BBPy.h DELETED --- --- BBPy.rsrc DELETED --- --- BBPy_lauch.c DELETED --- --- BBPy_launch.c DELETED --- --- BBPy_main.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:07 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:30 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/BBPy PythonSlave.py, 1.4, NONE README, 1.4, NONE Run as Python, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/BBPy In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/BBPy Removed Files: PythonSlave.py README Run as Python Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- PythonSlave.py DELETED --- --- README DELETED --- --- Run as Python DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:35 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/BBPy/source/BB-stuff ExternalInterface.h, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/BBPy/source/BB-stuff In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/BBPy/source/BB-stuff Removed Files: ExternalInterface.h Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- ExternalInterface.h DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:38 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/BBPy.lm BBPy.c, 1.2, NONE BBPythonLM.mcp, 1.2, NONE BBpy.r, 1.1, NONE Python, 1.1, NONE Python Keywords.rsrc, 1.1, NONE PythonBBLM.txt, 1.3, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/BBPy.lm In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/BBPy.lm Removed Files: BBPy.c BBPythonLM.mcp BBpy.r Python Python Keywords.rsrc PythonBBLM.txt Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- BBPy.c DELETED --- --- BBPythonLM.mcp DELETED --- --- BBpy.r DELETED --- --- Python DELETED --- --- Python Keywords.rsrc DELETED --- --- PythonBBLM.txt DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:41 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/BBPy/source/BB stuff ExternalInterface.h, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/BBPy/source/BB stuff In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/BBPy/source/BB stuff Removed Files: ExternalInterface.h Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- stuff ExternalInterface.h DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:10 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:45 2003 Subject: [Python-checkins] python/dist/src/Mac/Distributions binary.exclude, 1.13, NONE binary.include, 1.23, NONE dev.exclude, 1.11, NONE dev.include, 1.29, NONE src.exclude, 1.8, NONE src.include, 1.8, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Distributions Removed Files: binary.exclude binary.include dev.exclude dev.include src.exclude src.include Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- binary.exclude DELETED --- --- binary.include DELETED --- --- dev.exclude DELETED --- --- dev.include DELETED --- --- src.exclude DELETED --- --- src.include DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:09 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:50 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/mpwsystem mpwsystem.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/mpwsystem In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/mpwsystem Removed Files: mpwsystem.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- mpwsystem.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:10 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:54 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/osam OSAm.c, 1.2, NONE OSAm.exp, 1.1.1.1, NONE OSAm.h, 1.1.1.1, NONE OSAm.prj, 1.4, NONE ScriptRunner.c, 1.3, NONE ScriptRunner.h, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/osam In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/osam Removed Files: OSAm.c OSAm.exp OSAm.h OSAm.prj ScriptRunner.c ScriptRunner.h Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- OSAm.c DELETED --- --- OSAm.exp DELETED --- --- OSAm.h DELETED --- --- OSAm.prj DELETED --- --- ScriptRunner.c DELETED --- --- ScriptRunner.h DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:09 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:57 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/Tabcleaner Tabcleaner.README, 1.1, NONE Tabcleaner.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/Tabcleaner In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/Tabcleaner Removed Files: Tabcleaner.README Tabcleaner.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Tabcleaner.README DELETED --- --- Tabcleaner.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:09 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:34:59 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/PythonDetector OpenPythonLib, 1.1, NONE OpenPythonLib with NS, 1.1, NONE PythonDetector, 1.1, NONE readme.txt, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/PythonDetector In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/PythonDetector Removed Files: OpenPythonLib OpenPythonLib with NS PythonDetector readme.txt Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- OpenPythonLib DELETED --- --- OpenPythonLib with NS DELETED --- --- PythonDetector DELETED --- --- readme.txt DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:09 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:03 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/Sherlock Python-FAQ.src, 1.2, NONE Python-docs.src, 1.1, NONE Python.src, 1.2, NONE readme.txt, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/Sherlock In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/Sherlock Removed Files: Python-FAQ.src Python-docs.src Python.src readme.txt Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Python-FAQ.src DELETED --- --- Python-docs.src DELETED --- --- Python.src DELETED --- --- readme.txt DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:06 2003 Subject: [Python-checkins] python/dist/src/Mac/Contrib/ImageHelpers ExtPixMapWrapper.py, 1.1, NONE ImageMac.py, 1.2, NONE MovieUtils.py, 1.3, NONE ReadMe, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Contrib/ImageHelpers In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Contrib/ImageHelpers Removed Files: ExtPixMapWrapper.py ImageMac.py MovieUtils.py ReadMe Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- ExtPixMapWrapper.py DELETED --- --- ImageMac.py DELETED --- --- MovieUtils.py DELETED --- --- ReadMe DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:14 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:11 2003 Subject: [Python-checkins] python/dist/src/Mac/Distributions/(vise) Python 2.3.vct, 1.6, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions/(vise) In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Distributions/(vise) Removed Files: Python 2.3.vct Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Python 2.3.vct DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:14 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:14 2003 Subject: [Python-checkins] python/dist/src/Mac/Lib dbmac.py, 1.3, NONE maccache.py, 1.4, NONE mactty.py, 1.1, NONE nsremote.py, 1.1, NONE preferences.py, 1.3, NONE py_resource.py, 1.4, NONE pythonprefs.py, 1.8, NONE quietconsole.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Lib Removed Files: dbmac.py maccache.py mactty.py nsremote.py preferences.py py_resource.py pythonprefs.py quietconsole.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- dbmac.py DELETED --- --- maccache.py DELETED --- --- mactty.py DELETED --- --- nsremote.py DELETED --- --- preferences.py DELETED --- --- py_resource.py DELETED --- --- pythonprefs.py DELETED --- --- quietconsole.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:15 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:17 2003 Subject: [Python-checkins] python/dist/src/Mac/Lib/test AEservertest.py, 1.5, NONE AEservertest.rsrc, 1.3, NONE aete.py, 1.4, NONE cmtest.py, 1.2, NONE ctbtest.py, 1.5, NONE dragtest.py, 1.2, NONE echo.py, 1.9, NONE fgbgtimetest.py, 1.1, NONE icgluetest.py, 1.4, NONE readme.txt, 1.1, NONE tell.py, 1.2, NONE test_finder_ae, 1.1, NONE test_setcontroldata.py, 1.2, NONE tlist.py, 1.6, NONE tsnd.py, 1.2, NONE tte.py, 1.2, NONE twin.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Lib/test Removed Files: AEservertest.py AEservertest.rsrc aete.py cmtest.py ctbtest.py dragtest.py echo.py fgbgtimetest.py icgluetest.py readme.txt tell.py test_finder_ae test_setcontroldata.py tlist.py tsnd.py tte.py twin.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- AEservertest.py DELETED --- --- AEservertest.rsrc DELETED --- --- aete.py DELETED --- --- cmtest.py DELETED --- --- ctbtest.py DELETED --- --- dragtest.py DELETED --- --- echo.py DELETED --- --- fgbgtimetest.py DELETED --- --- icgluetest.py DELETED --- --- readme.txt DELETED --- --- tell.py DELETED --- --- test_finder_ae DELETED --- --- test_setcontroldata.py DELETED --- --- tlist.py DELETED --- --- tsnd.py DELETED --- --- tte.py DELETED --- --- twin.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:14 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:20 2003 Subject: [Python-checkins] python/dist/src/Mac/Lib/mkcwproject __init__.py, 1.14, NONE cwtalker.py, 1.3, NONE cwxmlgen.py, 1.9, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Lib/mkcwproject Removed Files: __init__.py cwtalker.py cwxmlgen.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- __init__.py DELETED --- --- cwtalker.py DELETED --- --- cwxmlgen.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:15 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:24 2003 Subject: [Python-checkins] python/dist/src/Mac/Lib/mkcwproject/template-carbon template-alllibraries.xml, 1.2, NONE template-allsources.xml, 1.1, NONE template-grouplist.xml, 1.1, NONE template-grouplistlib.xml, 1.1, NONE template-linkorder.xml, 1.1, NONE template-linkorderlib.xml, 1.1, NONE template-searchdirs.xml, 1.1, NONE template.prj.xml, 1.6, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject/template-carbon In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Lib/mkcwproject/template-carbon Removed Files: template-alllibraries.xml template-allsources.xml template-grouplist.xml template-grouplistlib.xml template-linkorder.xml template-linkorderlib.xml template-searchdirs.xml template.prj.xml Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- template-alllibraries.xml DELETED --- --- template-allsources.xml DELETED --- --- template-grouplist.xml DELETED --- --- template-grouplistlib.xml DELETED --- --- template-linkorder.xml DELETED --- --- template-linkorderlib.xml DELETED --- --- template-searchdirs.xml DELETED --- --- template.prj.xml DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:16 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:27 2003 Subject: [Python-checkins] python/dist/src/Mac/Lib/test/mkcwproj mkcwtestmodule.c, 1.3, NONE testmkcwproj.py, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/test/mkcwproj In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Lib/test/mkcwproj Removed Files: mkcwtestmodule.c testmkcwproj.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- mkcwtestmodule.c DELETED --- --- testmkcwproj.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:16 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:31 2003 Subject: [Python-checkins] python/dist/src/Mac/MPW Build, 1.2, NONE Makefile, 1.8, NONE README, 1.5, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/MPW In directory sc8-pr-cvs1:/tmp/cvs-serv7413/MPW Removed Files: Build Makefile README Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Build DELETED --- --- Makefile DELETED --- --- README DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:17 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:34 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules Printingmodule.c, 1.4, NONE _dummy_tkinter.c, 1.1, NONE calldll.c, 1.9, NONE macconfig.c, 1.38, NONE macmodule.c, 1.54, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Modules Removed Files: Printingmodule.c _dummy_tkinter.c calldll.c macconfig.c macmodule.c Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Printingmodule.c DELETED --- --- _dummy_tkinter.c DELETED --- --- calldll.c DELETED --- --- macconfig.c DELETED --- --- macmodule.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:17 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:38 2003 Subject: [Python-checkins] python/dist/src/Mac/Python getapplbycreator.c, 1.3, NONE gusiconfig.cpp, 1.8, NONE macapplication.c, 1.12, NONE macgetargv.c, 1.28, NONE macgetcompiler.c, 1.19, NONE macgetpath.c, 1.28, NONE macgetplatform.c, 1.4, NONE macglue.c, 1.114, NONE macimport.c, 1.17, NONE macmain.c, 1.82, NONE macsetfiletype.c, 1.7, NONE macshlglue.c, 1.17, NONE pyGUSISIOUX.cp, 1.5, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Python In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Python Removed Files: getapplbycreator.c gusiconfig.cpp macapplication.c macgetargv.c macgetcompiler.c macgetpath.c macgetplatform.c macglue.c macimport.c macmain.c macsetfiletype.c macshlglue.c pyGUSISIOUX.cp Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- getapplbycreator.c DELETED --- --- gusiconfig.cpp DELETED --- --- macapplication.c DELETED --- --- macgetargv.c DELETED --- --- macgetcompiler.c DELETED --- --- macgetpath.c DELETED --- --- macgetplatform.c DELETED --- --- macglue.c DELETED --- --- macimport.c DELETED --- --- macmain.c DELETED --- --- macsetfiletype.c DELETED --- --- macshlglue.c DELETED --- --- pyGUSISIOUX.cp DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:17 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:42 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/htmlrender HtmlRendermodule.c, 1.4, NONE htmlscan.py, 1.4, NONE htmlsupport.py, 1.3, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/htmlrender In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Modules/htmlrender Removed Files: HtmlRendermodule.c htmlscan.py htmlsupport.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- HtmlRendermodule.c DELETED --- --- htmlscan.py DELETED --- --- htmlsupport.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:19 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:47 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/CGI BuildCGIApplet.py, 1.5, NONE BuildCGIApplet.rsrc, 1.5, NONE CGI_README.txt, 1.1, NONE PythonCGISlave.py, 1.2, NONE PythonCGISlave.rsrc, 1.5, NONE cgi.html, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/CGI In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Tools/CGI Removed Files: BuildCGIApplet.py BuildCGIApplet.rsrc CGI_README.txt PythonCGISlave.py PythonCGISlave.rsrc cgi.html Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- BuildCGIApplet.py DELETED --- --- BuildCGIApplet.rsrc DELETED --- --- CGI_README.txt DELETED --- --- PythonCGISlave.py DELETED --- --- PythonCGISlave.rsrc DELETED --- --- cgi.html DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:19 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:52 2003 Subject: [Python-checkins] python/dist/src/Mac/Resources Carbon.r, 1.3, NONE balloons.bh, 1.4, NONE bundle.rsrc, 1.13, NONE dialogs.rsrc, 1.18, NONE gusiprefs.rsrc, 1.3, NONE pythonpath.r, 1.16, NONE tkpython.rsrc, 1.6, NONE version.r, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Resources In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Resources Removed Files: Carbon.r balloons.bh bundle.rsrc dialogs.rsrc gusiprefs.rsrc pythonpath.r tkpython.rsrc version.r Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Carbon.r DELETED --- --- balloons.bh DELETED --- --- bundle.rsrc DELETED --- --- dialogs.rsrc DELETED --- --- gusiprefs.rsrc DELETED --- --- pythonpath.r DELETED --- --- tkpython.rsrc DELETED --- --- version.r DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:14 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:35:58 2003 Subject: [Python-checkins] python/dist/src/Mac/Include getapplbycreator.h, 1.5, NONE macbuildno.h, 1.27, NONE macdefs.h, 1.12, NONE pyconfig.h, 1.12, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Include Removed Files: getapplbycreator.h macbuildno.h macdefs.h pyconfig.h Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- getapplbycreator.h DELETED --- --- macbuildno.h DELETED --- --- macdefs.h DELETED --- --- pyconfig.h DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:19 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:36:03 2003 Subject: [Python-checkins] python/dist/src/Mac/Unsupported unshar.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Unsupported In directory sc8-pr-cvs1:/tmp/cvs-serv7413/Unsupported Removed Files: unshar.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- unshar.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:36:08 2003 Subject: [Python-checkins] python/dist/src/Mac/mwerks/malloc README, 1.2, NONE calloc.c, 1.1, NONE malloc.c, 1.12, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/mwerks/malloc In directory sc8-pr-cvs1:/tmp/cvs-serv7413/mwerks/malloc Removed Files: README calloc.c malloc.c Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- README DELETED --- --- calloc.c DELETED --- --- malloc.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:36:13 2003 Subject: [Python-checkins] python/dist/src/Mac/mwerks errno_unix.h, 1.7, NONE macuseshlstart.c, 1.3, NONE mwerks_nscarbon.pch, 1.1, NONE mwerks_nscarbon_config.h, 1.10, NONE mwerks_pyexpat_config.h, 1.2, NONE mwerks_shcarbon.pch, 1.1, NONE mwerks_shcarbon_config.h, 1.8, NONE mwerks_smcarbon.pch, 1.1, NONE mwerks_smcarbon_config.h, 1.1, NONE mwerks_thrcarbonsm_config.h, 1.6, NONE mwerks_threadsmall_config.h, 1.6, NONE mwerks_tkplugin_config.h, 1.8, NONE mwfopenrf.c, 1.5, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/mwerks In directory sc8-pr-cvs1:/tmp/cvs-serv7413/mwerks Removed Files: errno_unix.h macuseshlstart.c mwerks_nscarbon.pch mwerks_nscarbon_config.h mwerks_pyexpat_config.h mwerks_shcarbon.pch mwerks_shcarbon_config.h mwerks_smcarbon.pch mwerks_smcarbon_config.h mwerks_thrcarbonsm_config.h mwerks_threadsmall_config.h mwerks_tkplugin_config.h mwfopenrf.c Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- errno_unix.h DELETED --- --- macuseshlstart.c DELETED --- --- mwerks_nscarbon.pch DELETED --- --- mwerks_nscarbon_config.h DELETED --- --- mwerks_pyexpat_config.h DELETED --- --- mwerks_shcarbon.pch DELETED --- --- mwerks_shcarbon_config.h DELETED --- --- mwerks_smcarbon.pch DELETED --- --- mwerks_smcarbon_config.h DELETED --- --- mwerks_thrcarbonsm_config.h DELETED --- --- mwerks_threadsmall_config.h DELETED --- --- mwerks_tkplugin_config.h DELETED --- --- mwfopenrf.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:34:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:36:20 2003 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplication.py, 1.10, NONE BuildApplication.rsrc, 1.7, NONE ConfigurePython.py, 1.43, NONE ConfigurePython.rsrc, 1.16, NONE EditPythonPrefs.py, 1.29, NONE EditPythonPrefs.rsrc, 1.16, NONE EditPythonPrefsBH.bh, 1.4, NONE EditPythonPrefsBH.prj, 1.4, NONE EditPythonPrefsBH.rsrc, 1.6, NONE MkDistr.py, 1.11, NONE MkDistr.rsrc, 1.3, NONE MkDistr_ui.py, 1.15, NONE buildappbundle.py, 1.4, NONE crlf.py, 1.2, NONE findgremlins.py, 1.3, NONE fixfiletypes.py, 1.8, NONE fullbuild.py, 1.91, NONE fullbuild.rsrc, 1.8, NONE genpluginprojects.py, 1.41, NONE missingcarbonmethods.py, 1.4, NONE unweave.py, 1.4, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv7413/scripts Removed Files: BuildApplication.py BuildApplication.rsrc ConfigurePython.py ConfigurePython.rsrc EditPythonPrefs.py EditPythonPrefs.rsrc EditPythonPrefsBH.bh EditPythonPrefsBH.prj EditPythonPrefsBH.rsrc MkDistr.py MkDistr.rsrc MkDistr_ui.py buildappbundle.py crlf.py findgremlins.py fixfiletypes.py fullbuild.py fullbuild.rsrc genpluginprojects.py missingcarbonmethods.py unweave.py Log Message: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- BuildApplication.py DELETED --- --- BuildApplication.rsrc DELETED --- --- ConfigurePython.py DELETED --- --- ConfigurePython.rsrc DELETED --- --- EditPythonPrefs.py DELETED --- --- EditPythonPrefs.rsrc DELETED --- --- EditPythonPrefsBH.bh DELETED --- --- EditPythonPrefsBH.prj DELETED --- --- EditPythonPrefsBH.rsrc DELETED --- --- MkDistr.py DELETED --- --- MkDistr.rsrc DELETED --- --- MkDistr_ui.py DELETED --- --- buildappbundle.py DELETED --- --- crlf.py DELETED --- --- findgremlins.py DELETED --- --- fixfiletypes.py DELETED --- --- fullbuild.py DELETED --- --- fullbuild.rsrc DELETED --- --- genpluginprojects.py DELETED --- --- missingcarbonmethods.py DELETED --- --- unweave.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:54:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:55:23 2003 Subject: [Python-checkins] python/dist/src/Mac/Demo/printing PrintingDemo.py, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/printing In directory sc8-pr-cvs1:/tmp/cvs-serv11364/printing Removed Files: PrintingDemo.py Log Message: Removing the obvious OS9-only documents§ --- PrintingDemo.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:54:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:55:32 2003 Subject: [Python-checkins] python/dist/src/Mac/Demo/interslip InterslipLib.c, 1.1, NONE InterslipLib.h, 1.1, NONE interslipmodule.c, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/interslip In directory sc8-pr-cvs1:/tmp/cvs-serv11364/interslip Removed Files: InterslipLib.c InterslipLib.h interslipmodule.c Log Message: Removing the obvious OS9-only documents§ --- InterslipLib.c DELETED --- --- InterslipLib.h DELETED --- --- interslipmodule.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:54:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:55:36 2003 Subject: [Python-checkins] python/dist/src/Mac/Demo/embed demo.c, 1.3, NONE embeddemo.prj, 1.3, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/embed In directory sc8-pr-cvs1:/tmp/cvs-serv11364/embed Removed Files: demo.c embeddemo.prj Log Message: Removing the obvious OS9-only documents§ --- demo.c DELETED --- --- embeddemo.prj DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:54:26 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:55:42 2003 Subject: [Python-checkins] python/dist/src/Mac/Demo building.html, 1.34, NONE cgi.html, 1.5, NONE embed.html, 1.6, NONE freezing.html, 1.3, NONE mpwextensions.html, 1.1, NONE plugins.html, 1.4, NONE using.html, 1.13, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo In directory sc8-pr-cvs1:/tmp/cvs-serv11364 Removed Files: building.html cgi.html embed.html freezing.html mpwextensions.html plugins.html using.html Log Message: Removing the obvious OS9-only documents§ --- building.html DELETED --- --- cgi.html DELETED --- --- embed.html DELETED --- --- freezing.html DELETED --- --- mpwextensions.html DELETED --- --- plugins.html DELETED --- --- using.html DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:54:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:55:50 2003 Subject: [Python-checkins] python/dist/src/Mac/Demo/cgi cgitest.cgi.py, 1.1, NONE cgitest.cgi.rsrc, 1.4, NONE realcgitest.py, 1.4, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Demo/cgi In directory sc8-pr-cvs1:/tmp/cvs-serv11364/cgi Removed Files: cgitest.cgi.py cgitest.cgi.rsrc realcgitest.py Log Message: Removing the obvious OS9-only documents§ --- cgitest.cgi.py DELETED --- --- cgitest.cgi.rsrc DELETED --- --- realcgitest.py DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 09:55:35 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 09:56:27 2003 Subject: [Python-checkins] python/dist/src/Python dynload_mac.c,2.13,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv11751 Removed Files: dynload_mac.c Log Message: MacOS9 support is gone. --- dynload_mac.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 10:24:49 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:24:54 2003 Subject: [Python-checkins] python/dist/src/Python modsupport.c, 2.69, 2.70 mystrtoul.c, 2.21, 2.22 pythonrun.c, 2.199, 2.200 traceback.c, 2.40, 2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv18678/Python Modified Files: modsupport.c mystrtoul.c pythonrun.c traceback.c Log Message: Getting rid of support for the ancient Apple MPW compiler. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -d -r2.69 -r2.70 *** modsupport.c 24 Oct 2003 20:05:32 -0000 2.69 --- modsupport.c 19 Nov 2003 15:24:47 -0000 2.70 *************** *** 4,12 **** #include "Python.h" - #ifdef MPW /* MPW pushes 'extended' for float and double types with varargs */ - typedef extended va_double; - #else typedef double va_double; - #endif /* Package context -- the full module name for package imports */ --- 4,8 ---- Index: mystrtoul.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/mystrtoul.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** mystrtoul.c 1 Sep 2000 23:29:28 -0000 2.21 --- mystrtoul.c 19 Nov 2003 15:24:47 -0000 2.22 *************** *** 101,105 **** temp = result; result = result * base + c; - #ifndef MPW if(base == 10) { if(((long)(result - c) / base != (long)temp)) /* overflow */ --- 101,104 ---- *************** *** 110,114 **** ovf = 1; } - #endif str++; } --- 109,112 ---- Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.199 retrieving revision 2.200 diff -C2 -d -r2.199 -r2.200 *** pythonrun.c 13 Nov 2003 07:43:21 -0000 2.199 --- pythonrun.c 19 Nov 2003 15:24:47 -0000 2.200 *************** *** 1567,1582 **** } - #ifdef MPW - - /* Check for file descriptor connected to interactive device. - Pretend that stdin is always interactive, other files never. */ - - int - isatty(int fd) - { - return fd == fileno(stdin); - } - - #endif /* --- 1567,1570 ---- Index: traceback.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** traceback.c 22 Feb 2003 13:07:53 -0000 2.40 --- traceback.c 19 Nov 2003 15:24:47 -0000 2.41 *************** *** 148,158 **** if (filename == NULL || name == NULL) return -1; - #ifdef MPW - /* This is needed by MPW's File and Line commands */ - #define FMT " File \"%.500s\"; line %d # in %.500s\n" - #else /* This is needed by Emacs' compile command */ #define FMT " File \"%.500s\", line %d, in %.500s\n" - #endif xfp = fopen(filename, "r" PY_STDIOTEXTMODE); if (xfp == NULL) { --- 148,153 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:24:49 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:24:58 2003 Subject: [Python-checkins] python/dist/src/Modules main.c, 1.80, 1.81 mathmodule.c, 2.72, 2.73 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv18678/Modules Modified Files: main.c mathmodule.c Log Message: Getting rid of support for the ancient Apple MPW compiler. Index: main.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** main.c 18 Nov 2003 19:46:25 -0000 1.80 --- main.c 19 Nov 2003 15:24:46 -0000 1.81 *************** *** 328,332 **** _setmode(fileno(stdout), O_BINARY); #endif - #ifndef MPW #ifdef HAVE_SETVBUF setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ); --- 328,331 ---- *************** *** 338,347 **** setbuf(stderr, (char *)NULL); #endif /* !HAVE_SETVBUF */ - #else /* MPW */ - /* On MPW (3.2) unbuffered seems to hang */ - setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ); - #endif /* MPW */ } else if (Py_InteractiveFlag) { --- 337,340 ---- Index: mathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mathmodule.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -d -r2.72 -r2.73 *** mathmodule.c 12 Oct 2003 19:09:36 -0000 2.72 --- mathmodule.c 19 Nov 2003 15:24:46 -0000 2.73 *************** *** 122,132 **** FUNC2(hypot, hypot, "hypot(x,y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y).") - #ifdef MPW_3_1 /* This hack is needed for MPW 3.1 but not for 3.2 ... */ - FUNC2(pow, power, - "pow(x,y)\n\nReturn x**y (x to the power of y).") - #else FUNC2(pow, pow, "pow(x,y)\n\nReturn x**y (x to the power of y).") - #endif FUNC1(sin, sin, "sin(x)\n\nReturn the sine of x (measured in radians).") --- 122,127 ---- *************** *** 191,203 **** return NULL; errno = 0; - #ifdef MPW /* MPW C modf expects pointer to extended as second argument */ - { - extended e; - x = modf(x, &e); - y = e; - } - #else x = modf(x, &y); - #endif Py_SET_ERANGE_IF_OVERFLOW(x); if (errno && is_error(x)) --- 186,190 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:24:50 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:25:03 2003 Subject: [Python-checkins] python/dist/src/Objects object.c,2.211,2.212 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv18678/Objects Modified Files: object.c Log Message: Getting rid of support for the ancient Apple MPW compiler. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.211 retrieving revision 2.212 diff -C2 -d -r2.211 -r2.212 *** object.c 28 Oct 2003 12:05:47 -0000 2.211 --- object.c 19 Nov 2003 15:24:47 -0000 2.212 *************** *** 909,921 **** */ - #ifdef MPW /* MPW C modf expects pointer to extended as second argument */ - { - extended e; - fractpart = modf(v, &e); - intpart = e; - } - #else fractpart = modf(v, &intpart); - #endif if (fractpart == 0.0) { /* This must return the same hash as an equal int or long. */ --- 909,913 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:25:18 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:25:21 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules macosmodule.c, 1.66, 1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv18678/Mac/Modules Modified Files: macosmodule.c Log Message: Getting rid of support for the ancient Apple MPW compiler. Index: macosmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macosmodule.c,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** macosmodule.c 19 Mar 2003 22:51:42 -0000 1.66 --- macosmodule.c 19 Nov 2003 15:24:45 -0000 1.67 *************** *** 48,55 **** #endif - #ifdef MPW - #define bufferIsSmall -607 /*error returns from Post and Accept */ - #endif - /* ----------------------------------------------------- */ --- 48,51 ---- *************** *** 779,781 **** } - --- 775,776 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:25:18 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:25:24 2003 Subject: [Python-checkins] python/dist/src/Parser acceler.c, 2.19, 2.20 myreadline.c, 2.29, 2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1:/tmp/cvs-serv18678/Parser Modified Files: acceler.c myreadline.c Log Message: Getting rid of support for the ancient Apple MPW compiler. Index: acceler.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/acceler.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -d -r2.19 -r2.20 *** acceler.c 4 Aug 2002 06:26:49 -0000 2.19 --- acceler.c 19 Nov 2003 15:24:46 -0000 2.20 *************** *** 90,114 **** for (ibit = 0; ibit < g->g_ll.ll_nlabels; ibit++) { if (testbit(d1->d_first, ibit)) { - #ifdef applec - #define MPW_881_BUG /* Undefine if bug below is fixed */ - #endif - #ifdef MPW_881_BUG - /* In 881 mode MPW 3.1 has a code - generation bug which seems to - set the upper bits; fix this by - explicitly masking them off */ - int temp; - #endif if (accel[ibit] != -1) printf("XXX ambiguity!\n"); - #ifdef MPW_881_BUG - temp = 0xFFFF & - (a->a_arrow | (1 << 7) | - ((type - NT_OFFSET) << 8)); - accel[ibit] = temp; - #else accel[ibit] = a->a_arrow | (1 << 7) | ((type - NT_OFFSET) << 8); - #endif } } --- 90,97 ---- Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** myreadline.c 3 May 2003 09:14:53 -0000 2.29 --- myreadline.c 19 Nov 2003 15:24:46 -0000 2.30 *************** *** 124,134 **** break; } - #ifdef MPW - /* Hack for MPW C where the prompt comes right back in the input */ - /* XXX (Actually this would be rather nice on most systems...) */ - n = strlen(prompt); - if (strncmp(p, prompt, n) == 0) - memmove(p, p + n, strlen(p) - n + 1); - #endif n = strlen(p); while (n > 0 && p[n-1] != '\n') { --- 124,127 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:30:44 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:31:05 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules hfsplusmodule.c, 1.7, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv19916 Removed Files: hfsplusmodule.c Log Message: Gone: all this functionality is now in the Carbon.File and Folder modules. --- hfsplusmodule.c DELETED --- From jackjansen at users.sourceforge.net Wed Nov 19 10:32:48 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:32:53 2003 Subject: [Python-checkins] python/dist/src/Include pymactoolbox.h,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv20415/Include Modified Files: pymactoolbox.h Log Message: WITHOUT_FRAMEWORKS conditional code bites the dust: this was for pre-carbon MacOS9 support. Index: pymactoolbox.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymactoolbox.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pymactoolbox.h 27 May 2003 21:39:57 -0000 1.8 --- pymactoolbox.h 19 Nov 2003 15:32:46 -0000 1.9 *************** *** 8,30 **** #endif - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #else #include #include - #endif /* --- 8,13 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:32:48 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:32:58 2003 Subject: [Python-checkins] python/dist/src/Python mactoolboxglue.c, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv20415/Python Modified Files: mactoolboxglue.c Log Message: WITHOUT_FRAMEWORKS conditional code bites the dust: this was for pre-carbon MacOS9 support. Index: mactoolboxglue.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/mactoolboxglue.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** mactoolboxglue.c 27 May 2003 21:39:56 -0000 1.20 --- mactoolboxglue.c 19 Nov 2003 15:32:45 -0000 1.21 *************** *** 27,34 **** #include "pymactoolbox.h" - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #endif /* --- 27,30 ---- From jackjansen at users.sourceforge.net Wed Nov 19 10:32:49 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 10:33:03 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules ColorPickermodule.c, 1.5, 1.6 Nav.c, 1.26, 1.27 OSATerminology.c, 1.2, 1.3 gestaltmodule.c, 1.8, 1.9 icgluemodule.c, 1.11, 1.12 macosmodule.c, 1.67, 1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv20415/Mac/Modules Modified Files: ColorPickermodule.c Nav.c OSATerminology.c gestaltmodule.c icgluemodule.c macosmodule.c Log Message: WITHOUT_FRAMEWORKS conditional code bites the dust: this was for pre-carbon MacOS9 support. Index: ColorPickermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ColorPickermodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ColorPickermodule.c 16 Jun 2003 13:56:05 -0000 1.5 --- ColorPickermodule.c 19 Nov 2003 15:32:46 -0000 1.6 *************** *** 22,30 **** ******************************************************************/ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #include "Python.h" #include "macglue.h" --- 22,26 ---- Index: Nav.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/Nav.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Nav.c 17 Apr 2003 20:44:21 -0000 1.26 --- Nav.c 19 Nov 2003 15:32:46 -0000 1.27 *************** *** 33,41 **** #include "macglue.h" #include "pymactoolbox.h" - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif static PyObject *ErrorObject; --- 33,37 ---- Index: OSATerminology.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/OSATerminology.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OSATerminology.c 6 Mar 2003 23:02:59 -0000 1.2 --- OSATerminology.c 19 Nov 2003 15:32:46 -0000 1.3 *************** *** 10,18 **** #include "macglue.h" - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif static PyObject * --- 10,14 ---- Index: gestaltmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/gestaltmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gestaltmodule.c 4 Sep 2001 22:29:31 -0000 1.8 --- gestaltmodule.c 19 Nov 2003 15:32:46 -0000 1.9 *************** *** 28,37 **** #include "macglue.h" - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif static PyObject * --- 28,32 ---- Index: icgluemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icgluemodule.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** icgluemodule.c 12 Dec 2002 10:31:49 -0000 1.11 --- icgluemodule.c 19 Nov 2003 15:32:46 -0000 1.12 *************** *** 35,43 **** extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif static PyObject *ErrorObject; --- 35,39 ---- Index: macosmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macosmodule.c,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** macosmodule.c 19 Nov 2003 15:24:45 -0000 1.67 --- macosmodule.c 19 Nov 2003 15:32:46 -0000 1.68 *************** *** 29,42 **** #include "pythonresources.h" - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #include - #else #include #include - #endif static PyObject *MacOS_Error; /* Exception MacOS.Error */ --- 29,34 ---- From rhettinger at users.sourceforge.net Wed Nov 19 10:52:17 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 19 10:52:25 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.893,1.894 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv24005/Misc Modified Files: NEWS Log Message: Remove deprecation of sets.Set.update(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.893 retrieving revision 1.894 diff -C2 -d -r1.893 -r1.894 *** NEWS 18 Nov 2003 19:46:24 -0000 1.893 --- NEWS 19 Nov 2003 15:52:14 -0000 1.894 *************** *** 162,167 **** - sets.py now runs under Py2.2. In addition, the argument restrictions for most set methods (but not the operators) have been relaxed to ! allow any iterable. Also the Set.update() has been deprecated because ! it duplicates Set.union_update(). - _strptime.py now has a behind-the-scenes caching mechanism for the most --- 162,166 ---- - sets.py now runs under Py2.2. In addition, the argument restrictions for most set methods (but not the operators) have been relaxed to ! allow any iterable. - _strptime.py now has a behind-the-scenes caching mechanism for the most From rhettinger at users.sourceforge.net Wed Nov 19 10:52:17 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 19 10:52:30 2003 Subject: [Python-checkins] python/dist/src/Lib sets.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv24005/Lib Modified Files: sets.py Log Message: Remove deprecation of sets.Set.update(). Index: sets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** sets.py 12 Nov 2003 15:21:20 -0000 1.48 --- sets.py 19 Nov 2003 15:52:14 -0000 1.49 *************** *** 505,512 **** def update(self, iterable): """Add all values from an iterable (such as a list or file).""" - import warnings - warnings.warn("The update() method deprecated; " - "Use union_update() instead.", - DeprecationWarning, 2) self._update(iterable) --- 505,508 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:12:11 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:12:15 2003 Subject: [Python-checkins] python/dist/src/Lib/plat-mac bgenlocations.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1:/tmp/cvs-serv27736/Lib/plat-mac Modified Files: bgenlocations.py Log Message: Get rid of MacOS9 support. Paths are still hard-coded, that'll be fixed later. Index: bgenlocations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bgenlocations.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bgenlocations.py 12 Apr 2003 22:27:05 -0000 1.5 --- bgenlocations.py 19 Nov 2003 16:12:08 -0000 1.6 *************** *** 12,22 **** # Where bgen is. For unix-Python bgen isn't installed, so you have to refer to # the source tree here. ! if sys.platform == 'mac': ! # For MacPython we know where it is ! def _pardir(p): return os.path.split(p)[0] ! BGENDIR=os.path.join(sys.prefix, "Tools", "bgen", "bgen") ! else: ! # for unix-Python we don't know, please set it yourself. ! BGENDIR="/Users/jack/src/python/Tools/bgen/bgen" # --- 12,16 ---- # Where bgen is. For unix-Python bgen isn't installed, so you have to refer to # the source tree here. ! BGENDIR="/Users/jack/src/python/Tools/bgen/bgen" # *************** *** 26,34 **** # end of lines, so don't worry about that. # ! if sys.platform == 'mac': ! _MWERKSDIR="Moes:Applications (Mac OS 9):Metrowerks CodeWarrior 7.0:Metrowerks CodeWarrior" ! else: ! _MWERKSDIR="/Volumes/Moes/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/" ! INCLUDEDIR=os.path.join(_MWERKSDIR, "MacOS Support", "Universal", "Interfaces", "CIncludes") # --- 20,24 ---- # end of lines, so don't worry about that. # ! INCLUDEDIR="/Users/jack/src/Universal/Interfaces/CIncludes" # *************** *** 37,44 **** # your source directory, not your installed directory. # ! if sys.platform == 'mac': ! TOOLBOXDIR=os.path.join(sys.prefix, "Lib", "plat-mac", "Carbon") ! else: ! TOOLBOXDIR="/Users/jack/src/python/Lib/plat-mac/Carbon" # Creator for C files: --- 27,31 ---- # your source directory, not your installed directory. # ! TOOLBOXDIR="/Users/jack/src/python/Lib/plat-mac/Carbon" # Creator for C files: From jackjansen at users.sourceforge.net Wed Nov 19 11:13:55 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:13:58 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ah _AHmodule.c, 1.2, 1.3 ahsupport.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ah In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/ah Modified Files: _AHmodule.c ahsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _AHmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ah/_AHmodule.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _AHmodule.c 30 Aug 2002 23:02:09 -0000 1.2 --- _AHmodule.c 19 Nov 2003 16:13:22 -0000 1.3 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: ahsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ah/ahsupport.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ahsupport.py 30 Aug 2002 23:02:09 -0000 1.2 --- ahsupport.py 19 Nov 2003 16:13:23 -0000 1.3 *************** *** 21,29 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif """ --- 21,25 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:55 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:03 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ae _AEmodule.c, 1.19, 1.20 aesupport.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/ae Modified Files: _AEmodule.c aesupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _AEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/_AEmodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** _AEmodule.c 17 Jan 2003 23:11:17 -0000 1.19 --- _AEmodule.c 19 Nov 2003 16:13:22 -0000 1.20 *************** *** 15,21 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) --- 15,21 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) *************** *** 24,33 **** #define PyDoc_STR(x) (x) #endif - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 24,28 ---- Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** aesupport.py 17 Jan 2003 23:11:17 -0000 1.30 --- aesupport.py 19 Nov 2003 16:13:22 -0000 1.31 *************** *** 86,95 **** #define PyDoc_STR(x) (x) #endif - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 86,90 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:55 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:06 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/app _Appmodule.c, 1.17, 1.18 appsupport.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/app Modified Files: _Appmodule.c appsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Appmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/_Appmodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _Appmodule.c 23 Dec 2002 23:16:20 -0000 1.17 --- _Appmodule.c 19 Nov 2003 16:13:23 -0000 1.18 *************** *** 15,30 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif - --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: appsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/appsupport.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** appsupport.py 3 Dec 2002 23:40:19 -0000 1.17 --- appsupport.py 19 Nov 2003 16:13:23 -0000 1.18 *************** *** 80,89 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif - --- 80,84 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:56 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:12 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/carbonevt CarbonEvtsupport.py, 1.13, 1.14 _CarbonEvtmodule.c, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/carbonevt In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/carbonevt Modified Files: CarbonEvtsupport.py _CarbonEvtmodule.c Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: CarbonEvtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtsupport.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CarbonEvtsupport.py 23 Dec 2002 23:16:21 -0000 1.13 --- CarbonEvtsupport.py 19 Nov 2003 16:13:23 -0000 1.14 *************** *** 75,83 **** includestuff = r""" - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #include "macglue.h" --- 75,79 ---- Index: _CarbonEvtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/_CarbonEvtmodule.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _CarbonEvtmodule.c 23 Dec 2002 23:16:21 -0000 1.14 --- _CarbonEvtmodule.c 19 Nov 2003 16:13:23 -0000 1.15 *************** *** 6,14 **** - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #include "macglue.h" --- 6,10 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:57 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:17 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cg _CGmodule.c, 1.11, 1.12 cgsupport.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/cg Modified Files: _CGmodule.c cgsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** _CGmodule.c 23 Dec 2002 23:16:21 -0000 1.11 --- _CGmodule.c 19 Nov 2003 16:13:24 -0000 1.12 *************** *** 15,30 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #if !TARGET_API_MAC_OSX --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include #if !TARGET_API_MAC_OSX Index: cgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cgsupport.py 3 Dec 2002 23:40:19 -0000 1.6 --- cgsupport.py 19 Nov 2003 16:13:25 -0000 1.7 *************** *** 24,33 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #if !TARGET_API_MAC_OSX --- 24,28 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:56 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:21 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.22, 1.23 cfsupport.py, 1.23, 1.24 pycfbridge.c, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/cf Modified Files: _CFmodule.c cfsupport.py pycfbridge.c Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** _CFmodule.c 31 May 2003 22:09:33 -0000 1.22 --- _CFmodule.c 19 Nov 2003 16:13:24 -0000 1.23 *************** *** 21,36 **** - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #include - #include - #include - #include - #else #include - #endif #include "pycfbridge.h" --- 21,25 ---- Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** cfsupport.py 31 May 2003 22:09:33 -0000 1.23 --- cfsupport.py 19 Nov 2003 16:13:24 -0000 1.24 *************** *** 43,58 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #include - #include - #include - #include - #else #include - #endif #include "pycfbridge.h" --- 43,47 ---- Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pycfbridge.c 3 Mar 2003 13:19:44 -0000 1.7 --- pycfbridge.c 19 Nov 2003 16:13:24 -0000 1.8 *************** *** 3,17 **** */ - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #include - #include - #include - #else #include - #endif #include "Python.h" --- 3,7 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:57 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:25 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cm _Cmmodule.c, 1.15, 1.16 cmsupport.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cm In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/cm Modified Files: _Cmmodule.c cmsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Cmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/_Cmmodule.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _Cmmodule.c 23 Dec 2002 23:16:21 -0000 1.15 --- _Cmmodule.c 19 Nov 2003 16:13:25 -0000 1.16 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include #ifdef USE_TOOLBOX_OBJECT_GLUE Index: cmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/cmsupport.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cmsupport.py 3 Dec 2002 23:40:19 -0000 1.8 --- cmsupport.py 19 Nov 2003 16:13:25 -0000 1.9 *************** *** 22,30 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 22,26 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:57 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:28 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ctl _Ctlmodule.c, 1.24, 1.25 ctlsupport.py, 1.53, 1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ctl In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/ctl Modified Files: _Ctlmodule.c ctlsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Ctlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/_Ctlmodule.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** _Ctlmodule.c 23 Dec 2002 23:16:21 -0000 1.24 --- _Ctlmodule.c 19 Nov 2003 16:13:25 -0000 1.25 *************** *** 15,30 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include #ifdef USE_TOOLBOX_OBJECT_GLUE Index: ctlsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/ctlsupport.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ctlsupport.py 12 Dec 2002 10:31:50 -0000 1.53 --- ctlsupport.py 19 Nov 2003 16:13:25 -0000 1.54 *************** *** 114,123 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 114,118 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:58 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:31 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/evt _Evtmodule.c, 1.8, 1.9 evtsupport.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/evt In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/evt Modified Files: _Evtmodule.c evtsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Evtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/_Evtmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _Evtmodule.c 12 Dec 2002 10:31:50 -0000 1.8 --- _Evtmodule.c 19 Nov 2003 16:13:26 -0000 1.9 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: evtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/evtsupport.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** evtsupport.py 29 Nov 2002 23:40:43 -0000 1.16 --- evtsupport.py 19 Nov 2003 16:13:26 -0000 1.17 *************** *** 36,44 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif """ --- 36,40 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:58 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:35 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/drag _Dragmodule.c, 1.14, 1.15 dragsupport.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/drag In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/drag Modified Files: _Dragmodule.c dragsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Dragmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/_Dragmodule.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _Dragmodule.c 23 Dec 2002 23:16:22 -0000 1.14 --- _Dragmodule.c 19 Nov 2003 16:13:25 -0000 1.15 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* Callback glue routines */ --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include /* Callback glue routines */ Index: dragsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/dragsupport.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dragsupport.py 3 Dec 2002 23:40:20 -0000 1.12 --- dragsupport.py 19 Nov 2003 16:13:26 -0000 1.13 *************** *** 45,53 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* Callback glue routines */ --- 45,49 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:38 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/folder _Foldermodule.c, 1.1, 1.2 foldersupport.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/folder In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/folder Modified Files: _Foldermodule.c foldersupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Foldermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/folder/_Foldermodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _Foldermodule.c 22 Nov 2002 14:58:35 -0000 1.1 --- _Foldermodule.c 19 Nov 2003 16:13:27 -0000 1.2 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: foldersupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/folder/foldersupport.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** foldersupport.py 22 Nov 2002 14:58:35 -0000 1.1 --- foldersupport.py 19 Nov 2003 16:13:27 -0000 1.2 *************** *** 30,38 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif """ --- 30,34 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:41 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/help _Helpmodule.c, 1.8, 1.9 helpsupport.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/help In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/help Modified Files: _Helpmodule.c helpsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Helpmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/_Helpmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _Helpmodule.c 18 Nov 2002 15:26:38 -0000 1.8 --- _Helpmodule.c 19 Nov 2003 16:13:27 -0000 1.9 *************** *** 15,21 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) --- 15,21 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) *************** *** 24,32 **** #define PyDoc_STR(x) (x) #endif - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif static PyObject *Help_Error; --- 24,28 ---- Index: helpsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/helpsupport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** helpsupport.py 3 Dec 2002 23:40:20 -0000 1.9 --- helpsupport.py 19 Nov 2003 16:13:27 -0000 1.10 *************** *** 40,48 **** #define PyDoc_STR(x) (x) #endif - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif """ --- 40,44 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:44 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/fm _Fmmodule.c, 1.8, 1.9 fmsupport.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/fm Modified Files: _Fmmodule.c fmsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Fmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/_Fmmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _Fmmodule.c 12 Dec 2002 10:31:50 -0000 1.8 --- _Fmmodule.c 19 Nov 2003 16:13:27 -0000 1.9 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: fmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/fmsupport.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fmsupport.py 25 Mar 2002 00:31:53 -0000 1.6 --- fmsupport.py 19 Nov 2003 16:13:27 -0000 1.7 *************** *** 27,35 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 27,31 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:47 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/file _Filemodule.c, 1.19, 1.20 filesupport.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/file In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/file Modified Files: _Filemodule.c filesupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Filemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/_Filemodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** _Filemodule.c 21 Mar 2003 12:54:24 -0000 1.19 --- _Filemodule.c 19 Nov 2003 16:13:26 -0000 1.20 *************** *** 21,29 **** - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 21,25 ---- Index: filesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/filesupport.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** filesupport.py 21 Mar 2003 12:54:24 -0000 1.17 --- filesupport.py 19 Nov 2003 16:13:26 -0000 1.18 *************** *** 123,131 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 123,127 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:13:58 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:14:50 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/dlg _Dlgmodule.c, 1.18, 1.19 dlgsupport.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/dlg In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/dlg Modified Files: _Dlgmodule.c dlgsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Dlgmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/_Dlgmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _Dlgmodule.c 27 Feb 2003 22:50:49 -0000 1.18 --- _Dlgmodule.c 19 Nov 2003 16:13:25 -0000 1.19 *************** *** 21,29 **** - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 21,25 ---- Index: dlgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/dlgsupport.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** dlgsupport.py 13 Dec 2002 15:01:41 -0000 1.31 --- dlgsupport.py 19 Nov 2003 16:13:25 -0000 1.32 *************** *** 32,40 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 32,36 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:18:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:18:07 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ae aesupport.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory sc8-pr-cvs1:/tmp/cvs-serv29205/ae Modified Files: aesupport.py Log Message: PyDoc_STR is always defined nowadays (and has been for quite some time:-) Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** aesupport.py 19 Nov 2003 16:13:22 -0000 1.31 --- aesupport.py 19 Nov 2003 16:18:01 -0000 1.32 *************** *** 83,89 **** includestuff = includestuff + """ - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 83,86 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:18:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:18:14 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/waste wastesupport.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/waste In directory sc8-pr-cvs1:/tmp/cvs-serv29205/waste Modified Files: wastesupport.py Log Message: PyDoc_STR is always defined nowadays (and has been for quite some time:-) Index: wastesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastesupport.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** wastesupport.py 23 Dec 2002 23:16:25 -0000 1.21 --- wastesupport.py 19 Nov 2003 16:18:02 -0000 1.22 *************** *** 64,70 **** #include #include - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif /* Exported by Qdmodule.c: */ --- 64,67 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:18:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:18:25 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/help helpsupport.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/help In directory sc8-pr-cvs1:/tmp/cvs-serv29205/help Modified Files: helpsupport.py Log Message: PyDoc_STR is always defined nowadays (and has been for quite some time:-) Index: helpsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/helpsupport.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** helpsupport.py 19 Nov 2003 16:13:27 -0000 1.10 --- helpsupport.py 19 Nov 2003 16:18:02 -0000 1.11 *************** *** 37,43 **** includestuff = includestuff + """ - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include """ --- 37,40 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:18:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:18:32 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/res ressupport.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory sc8-pr-cvs1:/tmp/cvs-serv29205/res Modified Files: ressupport.py Log Message: PyDoc_STR is always defined nowadays (and has been for quite some time:-) Index: ressupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/ressupport.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ressupport.py 19 Nov 2003 16:13:33 -0000 1.25 --- ressupport.py 19 Nov 2003 16:18:02 -0000 1.26 *************** *** 26,32 **** includestuff = includestuff + """ - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 26,29 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:18:04 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:18:39 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/scrap scrapsupport.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/scrap In directory sc8-pr-cvs1:/tmp/cvs-serv29205/scrap Modified Files: scrapsupport.py Log Message: PyDoc_STR is always defined nowadays (and has been for quite some time:-) Index: scrapsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/scrap/scrapsupport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scrapsupport.py 19 Nov 2003 16:13:34 -0000 1.9 --- scrapsupport.py 19 Nov 2003 16:18:02 -0000 1.10 *************** *** 27,33 **** includestuff = includestuff + """ - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 27,30 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:05 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:34:12 2003 Subject: [Python-checkins] python/dist/src/Python mactoolboxglue.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Python Modified Files: mactoolboxglue.c Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: mactoolboxglue.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/mactoolboxglue.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** mactoolboxglue.c 19 Nov 2003 15:32:45 -0000 1.21 --- mactoolboxglue.c 19 Nov 2003 16:34:03 -0000 1.22 *************** *** 34,38 **** char *PyMac_getscript() { - #if TARGET_API_MAC_OSX CFStringEncoding enc = CFStringGetSystemEncoding(); static CFStringRef name = NULL; --- 34,37 ---- *************** *** 51,84 **** } return (char *)CFStringGetCStringPtr(name, 0); - #else - int font, script, lang; - font = 0; - font = GetSysFont(); - script = FontToScript(font); - switch (script) { - case smRoman: - lang = GetScriptVariable(script, smScriptLang); - if (lang == langIcelandic) - return "mac-iceland"; - else if (lang == langTurkish) - return "mac-turkish"; - else if (lang == langGreek) - return "mac-greek"; - else - return "mac-roman"; - break; - #if 0 - /* We don't have a codec for this, so don't return it */ - case smJapanese: - return "mac-japan"; - #endif - case smGreek: - return "mac-greek"; - case smCyrillic: - return "mac-cyrillic"; - default: - return "ascii"; /* better than nothing */ - } - #endif /* TARGET_API_MAC_OSX */ } --- 50,53 ---- *************** *** 178,182 **** - #if TARGET_API_MAC_OSX OSErr PyMac_GetFullPathname(FSSpec *fss, char *path, int len) --- 147,150 ---- *************** *** 216,220 **** } - #endif /* TARGET_API_MAC_OSX */ #ifdef WITH_NEXT_FRAMEWORK --- 184,187 ---- *************** *** 233,241 **** int success = 0; - #if TARGET_API_MAC_OSX CFURLPathStyle thePathStyle = kCFURLPOSIXPathStyle; - #else - CFURLPathStyle thePathStyle = kCFURLHFSPathStyle; - #endif /* Get a reference to our main bundle */ --- 200,204 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:05 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:34:20 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ae _AEmodule.c, 1.20, 1.21 aesupport.py, 1.32, 1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/ae Modified Files: _AEmodule.c aesupport.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _AEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/_AEmodule.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** _AEmodule.c 19 Nov 2003 16:13:22 -0000 1.20 --- _AEmodule.c 19 Nov 2003 16:34:03 -0000 1.21 *************** *** 21,27 **** - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 21,24 ---- *************** *** 45,54 **** if ( PyOS_InterruptOccurred() ) return 1; - #if !TARGET_API_MAC_OSX - if ( PyMac_HandleEvent(theEvent) < 0 ) { - PySys_WriteStderr("Exception in user event handler during AE processing\n"); - PyErr_Clear(); - } - #endif return 0; } --- 42,45 ---- Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** aesupport.py 19 Nov 2003 16:18:01 -0000 1.32 --- aesupport.py 19 Nov 2003 16:34:03 -0000 1.33 *************** *** 104,113 **** if ( PyOS_InterruptOccurred() ) return 1; - #if !TARGET_API_MAC_OSX - if ( PyMac_HandleEvent(theEvent) < 0 ) { - PySys_WriteStderr("Exception in user event handler during AE processing\\n"); - PyErr_Clear(); - } - #endif return 0; } --- 104,107 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:05 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:34:24 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules macosmodule.c, 1.68, 1.69 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules Modified Files: macosmodule.c Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: macosmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macosmodule.c,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** macosmodule.c 19 Nov 2003 15:32:46 -0000 1.68 --- macosmodule.c 19 Nov 2003 16:34:03 -0000 1.69 *************** *** 34,42 **** static PyObject *MacOS_Error; /* Exception MacOS.Error */ - #ifdef TARGET_API_MAC_OSX #define PATHNAMELEN 1024 - #else - #define PATHNAMELEN 256 - #endif /* ----------------------------------------------------- */ --- 34,38 ---- *************** *** 338,429 **** } - #if !TARGET_API_MAC_OSX - static char schedparams_doc[] = "Set/return mainloop interrupt check flag, etc"; - - /* - ** Set scheduler parameters - */ - static PyObject * - MacOS_SchedParams(PyObject *self, PyObject *args) - { - PyMacSchedParams old, new; - - PyMac_GetSchedParams(&old); - new = old; - if (!PyArg_ParseTuple(args, "|iiidd", &new.check_interrupt, &new.process_events, - &new.besocial, &new.check_interval, &new.bg_yield)) - return NULL; - PyMac_SetSchedParams(&new); - return Py_BuildValue("iiidd", old.check_interrupt, old.process_events, - old.besocial, old.check_interval, old.bg_yield); - } - - static char appswitch_doc[] = "Obsolete, use SchedParams"; - - /* Obsolete, for backward compatability */ - static PyObject * - MacOS_EnableAppswitch(PyObject *self, PyObject *args) - { - int new, old; - PyMacSchedParams schp; - - if (!PyArg_ParseTuple(args, "i", &new)) - return NULL; - PyMac_GetSchedParams(&schp); - if ( schp.process_events ) - old = 1; - else if ( schp.check_interrupt ) - old = 0; - else - old = -1; - if ( new > 0 ) { - schp.process_events = mDownMask|keyDownMask|osMask; - schp.check_interrupt = 1; - } else if ( new == 0 ) { - schp.process_events = 0; - schp.check_interrupt = 1; - } else { - schp.process_events = 0; - schp.check_interrupt = 0; - } - PyMac_SetSchedParams(&schp); - return Py_BuildValue("i", old); - } - - static char setevh_doc[] = "Set python event handler to be called in mainloop"; - - static PyObject * - MacOS_SetEventHandler(PyObject *self, PyObject *args) - { - PyObject *evh = NULL; - - if (!PyArg_ParseTuple(args, "|O", &evh)) - return NULL; - if (evh == Py_None) - evh = NULL; - if ( evh && !PyCallable_Check(evh) ) { - PyErr_SetString(PyExc_ValueError, "SetEventHandler argument must be callable"); - return NULL; - } - if ( !PyMac_SetEventHandler(evh) ) - return NULL; - Py_INCREF(Py_None); - return Py_None; - } - - static char handleev_doc[] = "Pass event to other interested parties like sioux"; - - static PyObject * - MacOS_HandleEvent(PyObject *self, PyObject *args) - { - EventRecord ev; - - if (!PyArg_ParseTuple(args, "O&", PyMac_GetEventRecord, &ev)) - return NULL; - PyMac_HandleEventIntern(&ev); - Py_INCREF(Py_None); - return Py_None; - } - #endif /* !TARGET_API_MAC_OSX */ static char geterr_doc[] = "Convert OSErr number to string"; --- 334,337 ---- *************** *** 524,528 **** return NULL; if (!rv) { - #if TARGET_API_MAC_OSX ProcessSerialNumber psn; --- 432,435 ---- *************** *** 544,550 **** } } - #else - rv = Py_True; - #endif } Py_INCREF(rv); --- 451,454 ---- *************** *** 620,700 **** } - #if !TARGET_API_MAC_OSX - static char FreeMem_doc[] = "Return the total amount of free space in the heap"; - - static PyObject * - MacOS_FreeMem(PyObject *self, PyObject *args) - { - long rv; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - rv = FreeMem(); - return Py_BuildValue("l", rv); - } - - static char MaxBlock_doc[] = "Return the largest contiguous block of free space in the heap"; - - static PyObject * - MacOS_MaxBlock(PyObject *self, PyObject *args) - { - long rv; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - rv = MaxBlock(); - return Py_BuildValue("l", rv); - } - - static char CompactMem_doc[] = "(wanted size)->actual largest block after compacting"; - - static PyObject * - MacOS_CompactMem(PyObject *self, PyObject *args) - { - long value; - long rv; - - if (!PyArg_ParseTuple(args, "l", &value)) - return NULL; - rv = CompactMem(value); - return Py_BuildValue("l", rv); - } - - static char KeepConsole_doc[] = "(flag) Keep console open 0:never, 1:on output 2:on error, 3:always"; - - static PyObject * - MacOS_KeepConsole(PyObject *self, PyObject *args) - { - int value; - - if (!PyArg_ParseTuple(args, "i", &value)) - return NULL; - PyMac_options.keep_console = value; - Py_INCREF(Py_None); - return Py_None; - } - - static char OutputSeen_doc[] = "Call to reset the 'unseen output' flag for the keep-console-open option"; - - static PyObject * - MacOS_OutputSeen(PyObject *self, PyObject *args) - { - if (!PyArg_ParseTuple(args, "")) - return NULL; - PyMac_OutputSeen(); - Py_INCREF(Py_None); - return Py_None; - } - #endif /* !TARGET_API_MAC_OSX */ static PyMethodDef MacOS_Methods[] = { {"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc}, {"SetCreatorAndType", MacOS_SetCreatorAndType, 1, setcrtp_doc}, - #if !TARGET_API_MAC_OSX - {"SchedParams", MacOS_SchedParams, 1, schedparams_doc}, - {"EnableAppswitch", MacOS_EnableAppswitch, 1, appswitch_doc}, - {"SetEventHandler", MacOS_SetEventHandler, 1, setevh_doc}, - {"HandleEvent", MacOS_HandleEvent, 1, handleev_doc}, - #endif {"GetErrorString", MacOS_GetErrorString, 1, geterr_doc}, {"openrf", MacOS_openrf, 1, openrf_doc}, --- 524,531 ---- *************** *** 704,714 **** {"SysBeep", MacOS_SysBeep, 1, SysBeep_doc}, {"WMAvailable", MacOS_WMAvailable, 1, WMAvailable_doc}, - #if !TARGET_API_MAC_OSX - {"FreeMem", MacOS_FreeMem, 1, FreeMem_doc}, - {"MaxBlock", MacOS_MaxBlock, 1, MaxBlock_doc}, - {"CompactMem", MacOS_CompactMem, 1, CompactMem_doc}, - {"KeepConsole", MacOS_KeepConsole, 1, KeepConsole_doc}, - {"OutputSeen", MacOS_OutputSeen, 1, OutputSeen_doc}, - #endif {NULL, NULL} /* Sentinel */ }; --- 535,538 ---- *************** *** 743,759 **** return; } - #if TARGET_API_MAC_OSX #define PY_RUNTIMEMODEL "macho" - #elif TARGET_API_MAC_CARBON - #define PY_RUNTIMEMODEL "carbon" - #else - #error "None of the TARGET_API_MAC_XXX I know about is set" - #endif if (PyDict_SetItemString(d, "runtimemodel", Py_BuildValue("s", PY_RUNTIMEMODEL)) != 0) return; ! #if !TARGET_API_MAC_OSX ! #define PY_LINKMODEL "cfm" ! #elif defined(WITH_NEXT_FRAMEWORK) #define PY_LINKMODEL "framework" #elif defined(Py_ENABLE_SHARED) --- 567,575 ---- return; } #define PY_RUNTIMEMODEL "macho" if (PyDict_SetItemString(d, "runtimemodel", Py_BuildValue("s", PY_RUNTIMEMODEL)) != 0) return; ! #if defined(WITH_NEXT_FRAMEWORK) #define PY_LINKMODEL "framework" #elif defined(Py_ENABLE_SHARED) From jackjansen at users.sourceforge.net Wed Nov 19 11:34:05 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:35:32 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cg _CGmodule.c, 1.12, 1.13 cgsupport.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/cg Modified Files: _CGmodule.c cgsupport.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** _CGmodule.c 19 Nov 2003 16:13:24 -0000 1.12 --- _CGmodule.c 19 Nov 2003 16:34:03 -0000 1.13 *************** *** 23,133 **** #include - #if !TARGET_API_MAC_OSX - /* This code is adapted from the CallMachOFramework demo at: - http://developer.apple.com/samplecode/Sample_Code/Runtime_Architecture/CallMachOFramework.htm - It allows us to call Mach-O functions from CFM apps. */ - - #include - #include "CFMLateImport.h" - - static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr) - // This routine finds a the named framework and creates a CFBundle - // object for it. It looks for the framework in the frameworks folder, - // as defined by the Folder Manager. Currently this is - // "/System/Library/Frameworks", but we recommend that you avoid hard coded - // paths to ensure future compatibility. - // - // You might think that you could use CFBundleGetBundleWithIdentifier but - // that only finds bundles that are already loaded into your context. - // That would work in the case of the System framework but it wouldn't - // work if you're using some other, less-obvious, framework. - { - OSStatus err; - FSRef frameworksFolderRef; - CFURLRef baseURL; - CFURLRef bundleURL; - - *bundlePtr = nil; - - baseURL = nil; - bundleURL = nil; - - // Find the frameworks folder and create a URL for it. - - err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef); - if (err == noErr) { - baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef); - if (baseURL == nil) { - err = coreFoundationUnknownErr; - } - } - - // Append the name of the framework to the URL. - - if (err == noErr) { - bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false); - if (bundleURL == nil) { - err = coreFoundationUnknownErr; - } - } - - // Create a bundle based on that URL and load the bundle into memory. - // We never unload the bundle, which is reasonable in this case because - // the sample assumes that you'll be calling functions from this - // framework throughout the life of your application. - - if (err == noErr) { - *bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL); - if (*bundlePtr == nil) { - err = coreFoundationUnknownErr; - } - } - if (err == noErr) { - if ( ! CFBundleLoadExecutable( *bundlePtr ) ) { - err = coreFoundationUnknownErr; - } - } - - // Clean up. - - if (err != noErr && *bundlePtr != nil) { - CFRelease(*bundlePtr); - *bundlePtr = nil; - } - if (bundleURL != nil) { - CFRelease(bundleURL); - } - if (baseURL != nil) { - CFRelease(baseURL); - } - - return err; - } - - - - // The CFMLateImport approach requires that you define a fragment - // initialisation routine that latches the fragment's connection - // ID and locator. If your code already has a fragment initialiser - // you will have to integrate the following into it. - - static CFragConnectionID gFragToFixConnID; - static FSSpec gFragToFixFile; - static CFragSystem7DiskFlatLocator gFragToFixLocator; - - extern OSErr FragmentInit(const CFragInitBlock *initBlock); - extern OSErr FragmentInit(const CFragInitBlock *initBlock) - { - __initialize(initBlock); /* call the "original" initializer */ - gFragToFixConnID = (CFragConnectionID) initBlock->closureID; - gFragToFixFile = *(initBlock->fragLocator.u.onDisk.fileSpec); - gFragToFixLocator = initBlock->fragLocator.u.onDisk; - gFragToFixLocator.fileSpec = &gFragToFixFile; - - return noErr; - } - - #endif - extern int GrafObj_Convert(PyObject *, GrafPtr *); --- 23,26 ---- *************** *** 1369,1389 **** - - #if !TARGET_API_MAC_OSX - CFBundleRef sysBundle; - OSStatus err; - - if (&LoadFrameworkBundle == NULL) { - PyErr_SetString(PyExc_ImportError, "CoreCraphics not supported"); - return; - } - err = LoadFrameworkBundle(CFSTR("ApplicationServices.framework"), &sysBundle); - if (err == noErr) - err = CFMLateImportBundle(&gFragToFixLocator, gFragToFixConnID, FragmentInit, "\pCGStubLib", sysBundle); - if (err != noErr) { - PyErr_SetString(PyExc_ImportError, "CoreCraphics not supported"); - return; - }; - #endif /* !TARGET_API_MAC_OSX */ --- 1262,1265 ---- Index: cgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cgsupport.py 19 Nov 2003 16:13:25 -0000 1.7 --- cgsupport.py 19 Nov 2003 16:34:03 -0000 1.8 *************** *** 26,136 **** #include - #if !TARGET_API_MAC_OSX - /* This code is adapted from the CallMachOFramework demo at: - http://developer.apple.com/samplecode/Sample_Code/Runtime_Architecture/CallMachOFramework.htm - It allows us to call Mach-O functions from CFM apps. */ - - #include - #include "CFMLateImport.h" - - static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr) - // This routine finds a the named framework and creates a CFBundle - // object for it. It looks for the framework in the frameworks folder, - // as defined by the Folder Manager. Currently this is - // "/System/Library/Frameworks", but we recommend that you avoid hard coded - // paths to ensure future compatibility. - // - // You might think that you could use CFBundleGetBundleWithIdentifier but - // that only finds bundles that are already loaded into your context. - // That would work in the case of the System framework but it wouldn't - // work if you're using some other, less-obvious, framework. - { - OSStatus err; - FSRef frameworksFolderRef; - CFURLRef baseURL; - CFURLRef bundleURL; - - *bundlePtr = nil; - - baseURL = nil; - bundleURL = nil; - - // Find the frameworks folder and create a URL for it. - - err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef); - if (err == noErr) { - baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef); - if (baseURL == nil) { - err = coreFoundationUnknownErr; - } - } - - // Append the name of the framework to the URL. - - if (err == noErr) { - bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false); - if (bundleURL == nil) { - err = coreFoundationUnknownErr; - } - } - - // Create a bundle based on that URL and load the bundle into memory. - // We never unload the bundle, which is reasonable in this case because - // the sample assumes that you'll be calling functions from this - // framework throughout the life of your application. - - if (err == noErr) { - *bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL); - if (*bundlePtr == nil) { - err = coreFoundationUnknownErr; - } - } - if (err == noErr) { - if ( ! CFBundleLoadExecutable( *bundlePtr ) ) { - err = coreFoundationUnknownErr; - } - } - - // Clean up. - - if (err != noErr && *bundlePtr != nil) { - CFRelease(*bundlePtr); - *bundlePtr = nil; - } - if (bundleURL != nil) { - CFRelease(bundleURL); - } - if (baseURL != nil) { - CFRelease(baseURL); - } - - return err; - } - - - - // The CFMLateImport approach requires that you define a fragment - // initialisation routine that latches the fragment's connection - // ID and locator. If your code already has a fragment initialiser - // you will have to integrate the following into it. - - static CFragConnectionID gFragToFixConnID; - static FSSpec gFragToFixFile; - static CFragSystem7DiskFlatLocator gFragToFixLocator; - - extern OSErr FragmentInit(const CFragInitBlock *initBlock); - extern OSErr FragmentInit(const CFragInitBlock *initBlock) - { - __initialize(initBlock); /* call the "original" initializer */ - gFragToFixConnID = (CFragConnectionID) initBlock->closureID; - gFragToFixFile = *(initBlock->fragLocator.u.onDisk.fileSpec); - gFragToFixLocator = initBlock->fragLocator.u.onDisk; - gFragToFixLocator.fileSpec = &gFragToFixFile; - - return noErr; - } - - #endif - extern int GrafObj_Convert(PyObject *, GrafPtr *); --- 26,29 ---- *************** *** 204,226 **** return 1; } - """ - - initstuff = initstuff + """ - #if !TARGET_API_MAC_OSX - CFBundleRef sysBundle; - OSStatus err; - - if (&LoadFrameworkBundle == NULL) { - PyErr_SetString(PyExc_ImportError, "CoreCraphics not supported"); - return; - } - err = LoadFrameworkBundle(CFSTR("ApplicationServices.framework"), &sysBundle); - if (err == noErr) - err = CFMLateImportBundle(&gFragToFixLocator, gFragToFixConnID, FragmentInit, "\pCGStubLib", sysBundle); - if (err != noErr) { - PyErr_SetString(PyExc_ImportError, "CoreCraphics not supported"); - return; - }; - #endif /* !TARGET_API_MAC_OSX */ """ --- 97,100 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:35:37 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/file _Filemodule.c, 1.20, 1.21 filescan.py, 1.8, 1.9 filesupport.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/file In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/file Modified Files: _Filemodule.c filescan.py filesupport.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _Filemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/_Filemodule.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** _Filemodule.c 19 Nov 2003 16:13:26 -0000 1.20 --- _Filemodule.c 19 Nov 2003 16:34:04 -0000 1.21 *************** *** 1758,1763 **** } - #if TARGET_API_MAC_OSX - static PyObject *FSRef_FNNotify(FSRefObject *_self, PyObject *_args) { --- 1758,1761 ---- *************** *** 1778,1782 **** return _res; } - #endif static PyObject *FSRef_FSNewAliasMinimal(FSRefObject *_self, PyObject *_args) --- 1776,1779 ---- *************** *** 1837,1860 **** PyObject *_res = NULL; - #if TARGET_API_MAC_OSX if (!PyArg_ParseTuple(_args, "")) return NULL; _res = FSRef_FSRefMakePath(_self, _args); - #else - char strbuf[1024]; - OSErr err; - FSSpec fss; - - if (!PyArg_ParseTuple(_args, "")) - return NULL; - if ( !PyMac_GetFSSpec((PyObject *)_self, &fss)) - return NULL; - err = PyMac_GetFullPathname(&fss, strbuf, sizeof(strbuf)); - if ( err ) { - PyMac_Error(err); - return NULL; - } - _res = PyString_FromString(strbuf); - #endif return _res; --- 1834,1840 ---- *************** *** 1888,1896 **** {"FSOpenFork", (PyCFunction)FSRef_FSOpenFork, 1, PyDoc_STR("(Buffer forkNameLength, SInt8 permissions) -> (SInt16 forkRefNum)")}, - - #if TARGET_API_MAC_OSX {"FNNotify", (PyCFunction)FSRef_FNNotify, 1, PyDoc_STR("(FNMessage message, OptionBits flags) -> None")}, - #endif {"FSNewAliasMinimal", (PyCFunction)FSRef_FSNewAliasMinimal, 1, PyDoc_STR("() -> (AliasHandle inAlias)")}, --- 1868,1873 ---- *************** *** 2727,2732 **** } - #if TARGET_API_MAC_OSX - static PyObject *File_FNNotifyByPath(PyObject *_self, PyObject *_args) { --- 2704,2707 ---- *************** *** 2749,2755 **** return _res; } - #endif - - #if TARGET_API_MAC_OSX static PyObject *File_FNNotifyAll(PyObject *_self, PyObject *_args) --- 2724,2727 ---- *************** *** 2770,2774 **** return _res; } - #endif static PyObject *File_NewAlias(PyObject *_self, PyObject *_args) --- 2742,2745 ---- *************** *** 3107,3120 **** {"FSPathMakeRef", (PyCFunction)File_FSPathMakeRef, 1, PyDoc_STR("(UInt8 * path) -> (FSRef ref, Boolean isDirectory)")}, - - #if TARGET_API_MAC_OSX {"FNNotifyByPath", (PyCFunction)File_FNNotifyByPath, 1, PyDoc_STR("(UInt8 * path, FNMessage message, OptionBits flags) -> None")}, - #endif - - #if TARGET_API_MAC_OSX {"FNNotifyAll", (PyCFunction)File_FNNotifyAll, 1, PyDoc_STR("(FNMessage message, OptionBits flags) -> None")}, - #endif {"NewAlias", (PyCFunction)File_NewAlias, 1, PyDoc_STR("(FSSpec fromFile, FSSpec target) -> (AliasHandle alias)")}, --- 3078,3085 ---- *************** *** 3168,3197 **** } PyErr_Clear(); - #if !TARGET_API_MAC_OSX - /* On OS9 we now try a pathname */ - if ( PyString_Check(v) ) { - /* It's a pathname */ - if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) ) - return 0; - refnum = 0; /* XXXX Should get CurWD here?? */ - parid = 0; - err = FSMakeFSSpec(refnum, parid, path, spec); - if ( err && err != fnfErr ) { - PyMac_Error(err); - return 0; - } - return 1; - } - PyErr_Clear(); - #endif /* Otherwise we try to go via an FSRef. On OSX we go all the way, ** on OS9 we accept only a real FSRef object */ - #if TARGET_API_MAC_OSX if ( PyMac_GetFSRef(v, &fsr) ) { - #else - if (FSRef_Check(v)) { - fsr = ((FSRefObject *)v)->ob_itself; - #endif err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL); if (err != noErr) { --- 3133,3140 ---- *************** *** 3201,3207 **** return 1; } - #if !TARGET_API_MAC_OSX - PyErr_SetString(PyExc_TypeError, "FSSpec, FSRef, pathname or (refnum, parid, path) required"); - #endif return 0; } --- 3144,3147 ---- *************** *** 3218,3222 **** } - #if TARGET_API_MAC_OSX /* On OSX we now try a pathname */ if ( PyString_Check(v) || PyUnicode_Check(v)) { --- 3158,3161 ---- *************** *** 3231,3242 **** } /* XXXX Should try unicode here too */ - #endif /* Otherwise we try to go via an FSSpec */ - #if TARGET_API_MAC_OSX if (FSSpec_Check(v)) { fss = ((FSSpecObject *)v)->ob_itself; - #else - if (PyMac_GetFSSpec(v, &fss)) { - #endif if ((err=FSpMakeFSRef(&fss, fsr)) == 0) return 1; --- 3170,3176 ---- Index: filescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/filescan.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** filescan.py 2 Feb 2003 23:00:21 -0000 1.8 --- filescan.py 19 Nov 2003 16:34:04 -0000 1.9 *************** *** 106,117 **** ] - def makegreylist(self): - return [ - ('#if TARGET_API_MAC_OSX', [ - 'FNNotifyAll', - 'FNNotifyByPath', - 'FNNotify', - ])] - def makeblacklisttypes(self): return [ --- 106,109 ---- Index: filesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/filesupport.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** filesupport.py 19 Nov 2003 16:13:26 -0000 1.18 --- filesupport.py 19 Nov 2003 16:34:04 -0000 1.19 *************** *** 226,255 **** } PyErr_Clear(); - #if !TARGET_API_MAC_OSX - /* On OS9 we now try a pathname */ - if ( PyString_Check(v) ) { - /* It's a pathname */ - if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) ) - return 0; - refnum = 0; /* XXXX Should get CurWD here?? */ - parid = 0; - err = FSMakeFSSpec(refnum, parid, path, spec); - if ( err && err != fnfErr ) { - PyMac_Error(err); - return 0; - } - return 1; - } - PyErr_Clear(); - #endif /* Otherwise we try to go via an FSRef. On OSX we go all the way, ** on OS9 we accept only a real FSRef object */ - #if TARGET_API_MAC_OSX if ( PyMac_GetFSRef(v, &fsr) ) { - #else - if (FSRef_Check(v)) { - fsr = ((FSRefObject *)v)->ob_itself; - #endif err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL); if (err != noErr) { --- 226,233 ---- *************** *** 259,265 **** return 1; } - #if !TARGET_API_MAC_OSX - PyErr_SetString(PyExc_TypeError, "FSSpec, FSRef, pathname or (refnum, parid, path) required"); - #endif return 0; } --- 237,240 ---- *************** *** 276,280 **** } - #if TARGET_API_MAC_OSX /* On OSX we now try a pathname */ if ( PyString_Check(v) || PyUnicode_Check(v)) { --- 251,254 ---- *************** *** 289,300 **** } /* XXXX Should try unicode here too */ - #endif /* Otherwise we try to go via an FSSpec */ - #if TARGET_API_MAC_OSX if (FSSpec_Check(v)) { fss = ((FSSpecObject *)v)->ob_itself; - #else - if (PyMac_GetFSSpec(v, &fss)) { - #endif if ((err=FSpMakeFSRef(&fss, fsr)) == 0) return 1; --- 263,269 ---- *************** *** 815,838 **** FSRef_as_pathname_body = """ - #if TARGET_API_MAC_OSX if (!PyArg_ParseTuple(_args, "")) return NULL; _res = FSRef_FSRefMakePath(_self, _args); - #else - char strbuf[1024]; - OSErr err; - FSSpec fss; - - if (!PyArg_ParseTuple(_args, "")) - return NULL; - if ( !PyMac_GetFSSpec((PyObject *)_self, &fss)) - return NULL; - err = PyMac_GetFullPathname(&fss, strbuf, sizeof(strbuf)); - if ( err ) { - PyMac_Error(err); - return NULL; - } - _res = PyString_FromString(strbuf); - #endif return _res; """ --- 784,790 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:35:45 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ctl _Ctlmodule.c, 1.25, 1.26 ctlscan.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ctl In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/ctl Modified Files: _Ctlmodule.c ctlscan.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _Ctlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/_Ctlmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** _Ctlmodule.c 19 Nov 2003 16:13:25 -0000 1.25 --- _Ctlmodule.c 19 Nov 2003 16:34:03 -0000 1.26 *************** *** 307,312 **** } - #if TARGET_API_MAC_OSX - static PyObject *CtlObj_IsControlEnabled(ControlObject *_self, PyObject *_args) { --- 307,310 ---- *************** *** 323,329 **** return _res; } - #endif - - #if TARGET_API_MAC_OSX static PyObject *CtlObj_EnableControl(ControlObject *_self, PyObject *_args) --- 321,324 ---- *************** *** 342,348 **** return _res; } - #endif - - #if TARGET_API_MAC_OSX static PyObject *CtlObj_DisableControl(ControlObject *_self, PyObject *_args) --- 337,340 ---- *************** *** 361,365 **** return _res; } - #endif static PyObject *CtlObj_Draw1Control(ControlObject *_self, PyObject *_args) --- 353,356 ---- *************** *** 2462,2467 **** } - #if TARGET_API_MAC_OSX - static PyObject *CtlObj_CopyDataBrowserEditText(ControlObject *_self, PyObject *_args) { --- 2453,2456 ---- *************** *** 2481,2485 **** return _res; } - #endif static PyObject *CtlObj_GetDataBrowserEditText(ControlObject *_self, PyObject *_args) --- 2470,2473 ---- *************** *** 3509,3527 **** {"SetControlVisibility", (PyCFunction)CtlObj_SetControlVisibility, 1, PyDoc_STR("(Boolean inIsVisible, Boolean inDoDraw) -> None")}, - - #if TARGET_API_MAC_OSX {"IsControlEnabled", (PyCFunction)CtlObj_IsControlEnabled, 1, PyDoc_STR("() -> (Boolean _rv)")}, - #endif - - #if TARGET_API_MAC_OSX {"EnableControl", (PyCFunction)CtlObj_EnableControl, 1, PyDoc_STR("() -> None")}, - #endif - - #if TARGET_API_MAC_OSX {"DisableControl", (PyCFunction)CtlObj_DisableControl, 1, PyDoc_STR("() -> None")}, - #endif {"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1, PyDoc_STR("() -> None")}, --- 3497,3506 ---- *************** *** 3746,3754 **** {"SetDataBrowserEditText", (PyCFunction)CtlObj_SetDataBrowserEditText, 1, PyDoc_STR("(CFStringRef text) -> None")}, - - #if TARGET_API_MAC_OSX {"CopyDataBrowserEditText", (PyCFunction)CtlObj_CopyDataBrowserEditText, 1, PyDoc_STR("() -> (CFStringRef text)")}, - #endif {"GetDataBrowserEditText", (PyCFunction)CtlObj_GetDataBrowserEditText, 1, PyDoc_STR("(CFMutableStringRef text) -> None")}, --- 3725,3730 ---- *************** *** 4461,4466 **** } - #if TARGET_API_MAC_OSX - static PyObject *Ctl_CreateRelevanceBarControl(PyObject *_self, PyObject *_args) { --- 4437,4440 ---- *************** *** 4494,4498 **** return _res; } - #endif static PyObject *Ctl_CreateLittleArrowsControl(PyObject *_self, PyObject *_args) --- 4468,4471 ---- *************** *** 5233,5238 **** } - #if TARGET_API_MAC_OSX - static PyObject *Ctl_CreateDisclosureButtonControl(PyObject *_self, PyObject *_args) { --- 5206,5209 ---- *************** *** 5263,5269 **** return _res; } - #endif - - #if TARGET_API_MAC_OSX static PyObject *Ctl_CreateRoundButtonControl(PyObject *_self, PyObject *_args) --- 5234,5237 ---- *************** *** 5295,5299 **** return _res; } - #endif static PyObject *Ctl_CreateDataBrowserControl(PyObject *_self, PyObject *_args) --- 5263,5266 ---- *************** *** 5323,5328 **** } - #if TARGET_API_MAC_OSX - static PyObject *Ctl_CreateEditUnicodeTextControl(PyObject *_self, PyObject *_args) { --- 5290,5293 ---- *************** *** 5356,5360 **** return _res; } - #endif static PyObject *Ctl_FindControlUnderMouse(PyObject *_self, PyObject *_args) --- 5321,5324 ---- *************** *** 5499,5507 **** {"CreateProgressBarControl", (PyCFunction)Ctl_CreateProgressBarControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, Boolean indeterminate) -> (ControlHandle outControl)")}, - - #if TARGET_API_MAC_OSX {"CreateRelevanceBarControl", (PyCFunction)Ctl_CreateRelevanceBarControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum) -> (ControlHandle outControl)")}, - #endif {"CreateLittleArrowsControl", (PyCFunction)Ctl_CreateLittleArrowsControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, SInt32 increment) -> (ControlHandle outControl)")}, --- 5463,5468 ---- *************** *** 5552,5572 **** {"CreateScrollingTextBoxControl", (PyCFunction)Ctl_CreateScrollingTextBoxControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt16 contentResID, Boolean autoScroll, UInt32 delayBeforeAutoScroll, UInt32 delayBetweenAutoScroll, UInt16 autoScrollAmount) -> (ControlHandle outControl)")}, - - #if TARGET_API_MAC_OSX {"CreateDisclosureButtonControl", (PyCFunction)Ctl_CreateDisclosureButtonControl, 1, PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, SInt32 inValue, Boolean inAutoToggles) -> (ControlHandle outControl)")}, - #endif - - #if TARGET_API_MAC_OSX {"CreateRoundButtonControl", (PyCFunction)Ctl_CreateRoundButtonControl, 1, PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, SInt16 inSize, ControlButtonContentInfo inContent) -> (ControlHandle outControl)")}, - #endif {"CreateDataBrowserControl", (PyCFunction)Ctl_CreateDataBrowserControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, OSType style) -> (ControlHandle outControl)")}, - - #if TARGET_API_MAC_OSX {"CreateEditUnicodeTextControl", (PyCFunction)Ctl_CreateEditUnicodeTextControl, 1, PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef text, Boolean isPassword, ControlFontStyleRec style) -> (ControlHandle outControl)")}, - #endif {"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1, PyDoc_STR("(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)")}, --- 5513,5524 ---- Index: ctlscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/ctlscan.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ctlscan.py 12 Dec 2002 10:31:50 -0000 1.31 --- ctlscan.py 19 Nov 2003 16:34:03 -0000 1.32 *************** *** 100,117 **** ] - def makegreylist(self): - return [ - ('#if TARGET_API_MAC_OSX', [ - 'CreateRoundButtonControl', - 'CreateDisclosureButtonControl', - 'CreateRelevanceBarControl', - 'DisableControl', - 'EnableControl', - 'IsControlEnabled', - 'CreateEditUnicodeTextControl', - 'CopyDataBrowserEditText', - ]), - ] - def makeblacklisttypes(self): return [ --- 100,103 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:14:03 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:36:29 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/mlte _Mltemodule.c, 1.17, 1.18 mltesupport.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/mlte In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/mlte Modified Files: _Mltemodule.c mltesupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Mltemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/mlte/_Mltemodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _Mltemodule.c 23 Dec 2002 23:16:23 -0000 1.17 --- _Mltemodule.c 19 Nov 2003 16:13:31 -0000 1.18 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* For now we declare them forward here. They'll go to mactoolbox later */ --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include /* For now we declare them forward here. They'll go to mactoolbox later */ Index: mltesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/mlte/mltesupport.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mltesupport.py 3 Dec 2002 23:40:21 -0000 1.12 --- mltesupport.py 19 Nov 2003 16:13:31 -0000 1.13 *************** *** 21,29 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* For now we declare them forward here. They'll go to mactoolbox later */ --- 21,25 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:14:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:36:37 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/icn _Icnmodule.c, 1.7, 1.8 icnsupport.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/icn In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/icn Modified Files: _Icnmodule.c icnsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Icnmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/_Icnmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _Icnmodule.c 12 Dec 2002 10:31:51 -0000 1.7 --- _Icnmodule.c 19 Nov 2003 16:13:28 -0000 1.8 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include Index: icnsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/icnsupport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** icnsupport.py 3 Dec 2002 23:40:20 -0000 1.9 --- icnsupport.py 19 Nov 2003 16:13:29 -0000 1.10 *************** *** 47,55 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif """ --- 47,51 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:14:02 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:36:43 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/list _Listmodule.c, 1.16, 1.17 listsupport.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/list In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/list Modified Files: _Listmodule.c listsupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Listmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/list/_Listmodule.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _Listmodule.c 23 Dec 2002 23:16:23 -0000 1.16 --- _Listmodule.c 19 Nov 2003 16:13:29 -0000 1.17 *************** *** 15,29 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include #ifdef USE_TOOLBOX_OBJECT_GLUE *************** *** 33,61 **** #define ListObj_New _ListObj_New #define ListObj_Convert _ListObj_Convert - #endif - - #if !ACCESSOR_CALLS_ARE_FUNCTIONS - #define GetListPort(list) ((CGrafPtr)(*(list))->port) - #define GetListVerticalScrollBar(list) ((*(list))->vScroll) - #define GetListHorizontalScrollBar(list) ((*(list))->hScroll) - #define GetListActive(list) ((*(list))->lActive) - #define GetListClickTime(list) ((*(list))->clikTime) - #define GetListRefCon(list) ((*(list))->refCon) - #define GetListDefinition(list) ((*(list))->listDefProc) /* XXX Is this indeed the same? */ - #define GetListUserHandle(list) ((*(list))->userHandle) - #define GetListDataHandle(list) ((*(list))->cells) - #define GetListFlags(list) ((*(list))->listFlags) - #define GetListSelectionFlags(list) ((*(list))->selFlags) - #define SetListViewBounds(list, bounds) (((*(list))->rView) = *(bounds)) - - #define SetListPort(list, port) (((*(list))->port) = (GrafPtr)(port)) - #define SetListCellIndent(list, ind) (((*(list))->indent) = *(ind)) - #define SetListClickTime(list, time) (((*(list))->clikTime) = (time)) - #define SetListLastClick(list, click) (((*(list)->lastClick) = *(click)) - #define SetListRefCon(list, refcon) (((*(list))->refCon) = (refcon)) - #define SetListUserHandle(list, handle) (((*(list))->userHandle) = (handle)) - #define SetListFlags(list, flags) (((*(list))->listFlags) = (flags)) - #define SetListSelectionFlags(list, flags) (((*(list))->selFlags) = (flags)) - #endif --- 29,32 ---- Index: listsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/list/listsupport.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** listsupport.py 12 Dec 2002 10:31:51 -0000 1.17 --- listsupport.py 19 Nov 2003 16:13:29 -0000 1.18 *************** *** 40,48 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif #ifdef USE_TOOLBOX_OBJECT_GLUE --- 40,44 ---- *************** *** 52,80 **** #define ListObj_New _ListObj_New #define ListObj_Convert _ListObj_Convert - #endif - - #if !ACCESSOR_CALLS_ARE_FUNCTIONS - #define GetListPort(list) ((CGrafPtr)(*(list))->port) - #define GetListVerticalScrollBar(list) ((*(list))->vScroll) - #define GetListHorizontalScrollBar(list) ((*(list))->hScroll) - #define GetListActive(list) ((*(list))->lActive) - #define GetListClickTime(list) ((*(list))->clikTime) - #define GetListRefCon(list) ((*(list))->refCon) - #define GetListDefinition(list) ((*(list))->listDefProc) /* XXX Is this indeed the same? */ - #define GetListUserHandle(list) ((*(list))->userHandle) - #define GetListDataHandle(list) ((*(list))->cells) - #define GetListFlags(list) ((*(list))->listFlags) - #define GetListSelectionFlags(list) ((*(list))->selFlags) - #define SetListViewBounds(list, bounds) (((*(list))->rView) = *(bounds)) - - #define SetListPort(list, port) (((*(list))->port) = (GrafPtr)(port)) - #define SetListCellIndent(list, ind) (((*(list))->indent) = *(ind)) - #define SetListClickTime(list, time) (((*(list))->clikTime) = (time)) - #define SetListLastClick(list, click) (((*(list)->lastClick) = *(click)) - #define SetListRefCon(list, refcon) (((*(list))->refCon) = (refcon)) - #define SetListUserHandle(list, handle) (((*(list))->userHandle) = (handle)) - #define SetListFlags(list, flags) (((*(list))->listFlags) = (flags)) - #define SetListSelectionFlags(list, flags) (((*(list))->selFlags) = (flags)) - #endif --- 48,51 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:14:03 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:36:49 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/menu _Menumodule.c, 1.17, 1.18 menusupport.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/menu In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/menu Modified Files: _Menumodule.c menusupport.py Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: _Menumodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/menu/_Menumodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _Menumodule.c 23 Dec 2002 23:16:23 -0000 1.17 --- _Menumodule.c 19 Nov 2003 16:13:30 -0000 1.18 *************** *** 15,30 **** /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) - #ifdef WITHOUT_FRAMEWORKS - #include /* Defines OpenDeskAcc in universal headers */ - #include - #else #include - #endif --- 15,25 ---- /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) #include *************** *** 36,49 **** #define MenuObj_New _MenuObj_New #define MenuObj_Convert _MenuObj_Convert - #endif - - #if !ACCESSOR_CALLS_ARE_FUNCTIONS - #define GetMenuID(menu) ((*(menu))->menuID) - #define GetMenuWidth(menu) ((*(menu))->menuWidth) - #define GetMenuHeight(menu) ((*(menu))->menuHeight) - - #define SetMenuID(menu, id) ((*(menu))->menuID = (id)) - #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width)) - #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height)) #endif --- 31,34 ---- Index: menusupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/menu/menusupport.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** menusupport.py 23 Dec 2002 23:16:23 -0000 1.20 --- menusupport.py 19 Nov 2003 16:13:30 -0000 1.21 *************** *** 40,49 **** includestuff = includestuff + """ - #ifdef WITHOUT_FRAMEWORKS - #include /* Defines OpenDeskAcc in universal headers */ - #include - #else #include - #endif --- 40,44 ---- *************** *** 55,68 **** #define MenuObj_New _MenuObj_New #define MenuObj_Convert _MenuObj_Convert - #endif - - #if !ACCESSOR_CALLS_ARE_FUNCTIONS - #define GetMenuID(menu) ((*(menu))->menuID) - #define GetMenuWidth(menu) ((*(menu))->menuWidth) - #define GetMenuHeight(menu) ((*(menu))->menuHeight) - - #define SetMenuID(menu, id) ((*(menu))->menuID = (id)) - #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width)) - #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height)) #endif --- 50,53 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:14:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:36:55 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ibcarbon IBCarbonsupport.py, 1.4, 1.5 _IBCarbon.c, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon In directory sc8-pr-cvs1:/tmp/cvs-serv27894/Mac/Modules/ibcarbon Modified Files: IBCarbonsupport.py _IBCarbon.c Log Message: Getting rid of WITHOUT_FRAMEWORKS and ACCESSOR_CALLS_ARE_FUNCTIONS: MacOS9isms. Index: IBCarbonsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon/IBCarbonsupport.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IBCarbonsupport.py 3 Dec 2002 23:40:20 -0000 1.4 --- IBCarbonsupport.py 19 Nov 2003 16:13:27 -0000 1.5 *************** *** 10,18 **** includestuff = """ - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* WITHOUT_FRAMEWORKS */ #include "macglue.h" --- 10,14 ---- Index: _IBCarbon.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon/_IBCarbon.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _IBCarbon.c 23 Dec 2002 23:16:22 -0000 1.7 --- _IBCarbon.c 19 Nov 2003 16:13:27 -0000 1.8 *************** *** 6,14 **** - #ifdef WITHOUT_FRAMEWORKS - #include - #else #include - #endif /* WITHOUT_FRAMEWORKS */ #include "macglue.h" --- 6,10 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:07 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:44:51 2003 Subject: [Python-checkins] python/dist/src/Mac/Include macglue.h,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Include Modified Files: macglue.h Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: macglue.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/macglue.h,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** macglue.h 12 Dec 2002 10:31:49 -0000 1.63 --- macglue.h 19 Nov 2003 16:34:04 -0000 1.64 *************** *** 24,35 **** #ifndef Py_MACGLUE_H #define Py_MACGLUE_H - #ifdef WITHOUT_FRAMEWORKS - #include - #include - #include - #include - #else #include - #endif #include "pymactoolbox.h" --- 24,28 ---- *************** *** 50,58 **** unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */ - #ifdef USE_GUSI - extern int PyMac_ConsoleIsDead; /* True when exiting */ - extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */ - #endif - extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */ extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */ --- 43,46 ---- *************** *** 64,81 **** PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ - #if !TARGET_API_MAC_OSX - void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */ - void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */ - int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */ - #endif int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */ void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */ int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */ - #if !TARGET_API_MAC_OSX - void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */ - void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */ - void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */ - #endif int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */ PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */ --- 52,59 ---- *************** *** 87,94 **** void PyMac_Initialize(void); /* Initialize function for embedding Python */ - #ifdef USE_GUSI2 - short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */ - #endif - /* From macfiletype.c: */ --- 65,68 ---- *************** *** 103,132 **** void PyMac_OutputNotSeen(void); int PyMac_GetDelayConsoleFlag(void); - #ifdef USE_MAC_APPLET_SUPPORT - void PyMac_InitApplet(void); - #endif /* from macgetargv: */ OSErr PyMac_init_process_location(void); char * strdup(const char *str); - - #ifdef USE_GUSI2 - /* from pyGUSISIOUX.cp */ - typedef long (*PyWriteHandler)(char *buffer, long n); - typedef long (*PyReadHandler)(char *buffer, long n); - - /* Override routines that normally reads and writes to the - ** SIOUX console window. Intended for embedding applications - ** that want to forestall a Python console window ever showing up. - */ - void PyMac_SetConsoleHandler(PyReadHandler stdinH, PyWriteHandler stdoutH, - PyWriteHandler stderrH); - - /* Courtesy console handlers that drop all output and return - ** 0 on reads. - */ - long PyMac_DummyReadHandler(char *, long); - long PyMac_DummyWriteHandler(char *, long); - #endif /* USE_GUSI2 */ #ifdef __cplusplus --- 77,84 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:44:55 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/win _Winmodule.c, 1.19, 1.20 winscan.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/win Modified Files: _Winmodule.c winscan.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _Winmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** _Winmodule.c 19 Nov 2003 16:13:35 -0000 1.19 --- _Winmodule.c 19 Nov 2003 16:34:04 -0000 1.20 *************** *** 1359,1364 **** } - #if TARGET_API_MAC_OSX - static PyObject *WinObj_TransitionWindowAndParent(WindowObject *_self, PyObject *_args) { --- 1359,1362 ---- *************** *** 1388,1392 **** return _res; } - #endif static PyObject *WinObj_MacMoveWindow(WindowObject *_self, PyObject *_args) --- 1386,1389 ---- *************** *** 2452,2460 **** {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1, PyDoc_STR("(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None")}, - - #if TARGET_API_MAC_OSX {"TransitionWindowAndParent", (PyCFunction)WinObj_TransitionWindowAndParent, 1, PyDoc_STR("(WindowPtr parentWindow, WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None")}, - #endif {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1, PyDoc_STR("(short hGlobal, short vGlobal, Boolean front) -> None")}, --- 2449,2454 ---- Index: winscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winscan.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** winscan.py 12 Dec 2002 10:31:53 -0000 1.24 --- winscan.py 19 Nov 2003 16:34:04 -0000 1.25 *************** *** 71,81 **** 'GetWindowSpareFlag', ] ! ! def makegreylist(self): ! return [ ! ('#if TARGET_API_MAC_OSX', [ ! 'TransitionWindowAndParent', ! ])] ! def makeblacklisttypes(self): return [ --- 71,75 ---- 'GetWindowSpareFlag', ] ! def makeblacklisttypes(self): return [ From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:47:20 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/res _Resmodule.c, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/res Modified Files: _Resmodule.c Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** _Resmodule.c 19 Nov 2003 16:13:33 -0000 1.20 --- _Resmodule.c 19 Nov 2003 16:34:04 -0000 1.21 *************** *** 21,27 **** - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 21,24 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:56:41 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/help _Helpmodule.c, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/help In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/help Modified Files: _Helpmodule.c Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: _Helpmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/_Helpmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Helpmodule.c 19 Nov 2003 16:13:27 -0000 1.9 --- _Helpmodule.c 19 Nov 2003 16:34:04 -0000 1.10 *************** *** 21,27 **** - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif #include --- 21,24 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:56:47 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/mlte mltescan.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/mlte In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/mlte Modified Files: mltescan.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: mltescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/mlte/mltescan.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mltescan.py 12 Dec 2002 10:31:51 -0000 1.11 --- mltescan.py 19 Nov 2003 16:34:04 -0000 1.12 *************** *** 82,91 **** ] - def makegreylist(self): - return [ - ('#if TARGET_API_MAC_OS8', [ - ])] - - def makeblacklisttypes(self): return [ --- 82,85 ---- From jackjansen at users.sourceforge.net Wed Nov 19 11:34:06 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 11:57:24 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/fm fmscan.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory sc8-pr-cvs1:/tmp/cvs-serv32109/Mac/Modules/fm Modified Files: fmscan.py Log Message: Getting rid of code conditional on TARGET_API_MAC_*. Index: fmscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/fmscan.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** fmscan.py 12 Dec 2002 10:31:51 -0000 1.13 --- fmscan.py 19 Nov 2003 16:34:04 -0000 1.14 *************** *** 49,56 **** ] - def makegreylist(self): - return [ - ('#if !TARGET_API_MAC_CARBON', [ - ])] def makeblacklisttypes(self): return [ --- 49,52 ---- From akuchling at users.sourceforge.net Wed Nov 19 12:03:35 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Nov 19 12:03:38 2003 Subject: [Python-checkins] python/nondist/peps pep-0320.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv5583 Modified Files: pep-0320.txt Log Message: Add reminder Index: pep-0320.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0320.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0320.txt 29 Jul 2003 04:35:27 -0000 1.1 --- pep-0320.txt 19 Nov 2003 17:03:32 -0000 1.2 *************** *** 36,39 **** --- 36,44 ---- Planned features for 2.4 + Deprecate and/or remove the modules listed in PEP 4 (posixfile, + gopherlib, audioop, pre, others) + + Remove support for platforms as described in PEP 11. + Too early for anything more to get done here. From akuchling at users.sourceforge.net Wed Nov 19 12:04:37 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Nov 19 12:04:40 2003 Subject: [Python-checkins] python/nondist/peps pep-0011.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv5883 Modified Files: pep-0011.txt Log Message: Note removal of MacOS 9 Index: pep-0011.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0011.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0011.txt 19 Dec 2002 16:20:04 -0000 1.9 --- pep-0011.txt 19 Nov 2003 17:04:35 -0000 1.10 *************** *** 122,125 **** --- 122,130 ---- Code removed in: Python 2.4 + Name: MacOS 9 + Unsupported in: Python 2.4 + Code removed in: Python 2.4 + + Copyright From akuchling at users.sourceforge.net Wed Nov 19 12:12:49 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Nov 19 12:12:54 2003 Subject: [Python-checkins] python/nondist/peps pep-0004.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1:/tmp/cvs-serv7413 Modified Files: pep-0004.txt Log Message: Record one user of rgbimgmodule Index: pep-0004.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0004.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0004.txt 24 Apr 2003 13:15:11 -0000 1.9 --- pep-0004.txt 19 Nov 2003 17:12:46 -0000 1.10 *************** *** 93,98 **** Module name: rgbimgmodule ! Rationale: The module is not actively being used, no mention ! of it was found on deja.com on Oct-1-2000. Date: 1-Oct-2000 Documentation: TBD --- 93,99 ---- Module name: rgbimgmodule ! Rationale: In a 2001-04-24 c.l.py post, Jason Petrone mentions ! that he occasionally uses it; no other references to ! its use can be found as of 2003-11-19. Date: 1-Oct-2000 Documentation: TBD From loewis at users.sourceforge.net Wed Nov 19 14:51:58 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Nov 19 14:52:54 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.894,1.895 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv3496/Misc Modified Files: NEWS Log Message: Patch #831747: Add skip_accept_encoding parameter to putrequest. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.894 retrieving revision 1.895 diff -C2 -d -r1.894 -r1.895 *** NEWS 19 Nov 2003 15:52:14 -0000 1.894 --- NEWS 19 Nov 2003 19:51:55 -0000 1.895 *************** *** 117,120 **** --- 117,122 ---- ------- + - httplib.HTTP.putrequest now offers to omit the implicit Accept-Encoding. + - Patch #841977: modulefinder didn't find extension modules in packages From loewis at users.sourceforge.net Wed Nov 19 14:51:57 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Nov 19 14:57:43 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libhttplib.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3496/Doc/lib Modified Files: libhttplib.tex Log Message: Patch #831747: Add skip_accept_encoding parameter to putrequest. Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** libhttplib.tex 2 Sep 2003 02:32:54 -0000 1.35 --- libhttplib.tex 19 Nov 2003 19:51:55 -0000 1.36 *************** *** 175,183 **** \end{methoddesc} ! \begin{methoddesc}{putrequest}{request, selector} This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the \var{request} string, the \var{selector} string, and the HTTP version ! (\code{HTTP/1.1}). \end{methoddesc} --- 175,188 ---- \end{methoddesc} ! \begin{methoddesc}{putrequest}{request, selector\optional{, ! skip\_host\optional{, skip_accept_encoding}}} This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the \var{request} string, the \var{selector} string, and the HTTP version ! (\code{HTTP/1.1}). To disable automatic sending of \code{Host:} or ! \code{Accept-Encoding:} headers (for example to accept additional ! content encodings), specify \var{skip_host} or \var{skip_accept_encoding} ! with non-False values. ! \versionchanged[\var{skip_accept_encoding} argument added]{2.4} \end{methoddesc} From loewis at users.sourceforge.net Wed Nov 19 14:51:57 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Nov 19 14:58:15 2003 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv3496/Lib Modified Files: httplib.py Log Message: Patch #831747: Add skip_accept_encoding parameter to putrequest. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** httplib.py 9 Nov 2003 16:41:38 -0000 1.81 --- httplib.py 19 Nov 2003 19:51:55 -0000 1.82 *************** *** 597,605 **** self.send(msg) ! def putrequest(self, method, url, skip_host=0): """Send a request to the server. `method' specifies an HTTP request method, e.g. 'GET'. `url' specifies the object being requested, e.g. '/index.html'. """ --- 597,608 ---- self.send(msg) ! def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): """Send a request to the server. `method' specifies an HTTP request method, e.g. 'GET'. `url' specifies the object being requested, e.g. '/index.html'. + `skip_host' if True does not add automatically a 'Host:' header + `skip_accept_encoding' if True does not add automatically an + 'Accept-Encoding:' header """ *************** *** 608,612 **** self.__response = None ! # # in certain cases, we cannot issue another request on this connection. # this occurs when: --- 611,615 ---- self.__response = None ! # in certain cases, we cannot issue another request on this connection. # this occurs when: *************** *** 677,681 **** # we only want a Content-Encoding of "identity" since we don't # support encodings such as x-gzip or x-deflate. ! self.putheader('Accept-Encoding', 'identity') # we can accept "chunked" Transfer-Encodings, but no others --- 680,685 ---- # we only want a Content-Encoding of "identity" since we don't # support encodings such as x-gzip or x-deflate. ! if not skip_accept_encoding: ! self.putheader('Accept-Encoding', 'identity') # we can accept "chunked" Transfer-Encodings, but no others From jackjansen at users.sourceforge.net Wed Nov 19 17:43:59 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 17:44:05 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules Nav.c,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv3128/Mac/Modules Modified Files: Nav.c Log Message: Getting rid of one more TARGET_API_MAC_OSX. Index: Nav.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/Nav.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Nav.c 19 Nov 2003 15:32:46 -0000 1.27 --- Nav.c 19 Nov 2003 22:43:57 -0000 1.28 *************** *** 57,67 **** } if ( pyfunc == Py_None ) { - #if !TARGET_API_MAC_OSX - /* Special case: give update events to the Python event handling code */ - if ( callBackSelector == kNavCBEvent && - callBackParms->eventData.eventDataParms.event->what == updateEvt) - PyMac_HandleEvent(callBackParms->eventData.eventDataParms.event); - /* Ignore others */ - #endif return; } --- 57,60 ---- From jackjansen at users.sourceforge.net Wed Nov 19 17:52:25 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 17:52:29 2003 Subject: [Python-checkins] python/dist/src/Python thread.c, 2.47, 2.48 thread_pthread.h, 2.47, 2.48 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv4143/Python Modified Files: thread.c thread_pthread.h Log Message: Getting rid of code dependent on GUSI or the MetroWerks compiler. Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.47 retrieving revision 2.48 diff -C2 -d -r2.47 -r2.48 *** thread.c 20 Sep 2003 11:13:36 -0000 2.47 --- thread.c 19 Nov 2003 22:52:22 -0000 2.48 *************** *** 46,53 **** #endif - #if defined(__MWERKS__) && !defined(__BEOS__) - #define _POSIX_THREADS - #endif - #endif /* _POSIX_THREADS */ --- 46,49 ---- Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.47 retrieving revision 2.48 diff -C2 -d -r2.47 -r2.48 *** thread_pthread.h 22 Jul 2003 15:20:49 -0000 2.47 --- thread_pthread.h 19 Nov 2003 22:52:22 -0000 2.48 *************** *** 69,80 **** #endif - #ifdef USE_GUSI - /* The Macintosh GUSI I/O library sets the stackspace to - ** 20KB, much too low. We up it to 64K. - */ - #define THREAD_STACK_SIZE 0x10000 - #endif - - /* set default attribute object for different versions */ --- 69,72 ---- From jackjansen at users.sourceforge.net Wed Nov 19 17:52:25 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 17:52:36 2003 Subject: [Python-checkins] python/dist/src/Objects fileobject.c,2.185,2.186 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv4143/Objects Modified Files: fileobject.c Log Message: Getting rid of code dependent on GUSI or the MetroWerks compiler. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.185 retrieving revision 2.186 diff -C2 -d -r2.185 -r2.186 *** fileobject.c 18 Oct 2003 09:38:01 -0000 2.185 --- fileobject.c 19 Nov 2003 22:52:23 -0000 2.186 *************** *** 22,36 **** #endif /* _MSC_VER */ - #ifdef macintosh - #ifdef USE_GUSI - #define HAVE_FTRUNCATE - #endif - #endif - - #ifdef __MWERKS__ - /* Mwerks fopen() doesn't always set errno */ - #define NO_FOPEN_ERRNO - #endif - #if defined(PYOS_OS2) && defined(PYCC_GCC) #include --- 22,25 ---- *************** *** 210,225 **** } if (f->f_fp == NULL) { - #ifdef NO_FOPEN_ERRNO - /* Metroworks only, wich does not always sets errno */ - if (errno == 0) { - PyObject *v; - v = Py_BuildValue("(is)", 0, "Cannot open file"); - if (v != NULL) { - PyErr_SetObject(PyExc_IOError, v); - Py_DECREF(v); - } - return NULL; - } - #endif #ifdef _MSC_VER /* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings, --- 199,202 ---- *************** *** 740,749 **** need to take the amount of buffered data into account. (Yet another reason why stdio stinks. :-) */ - #ifdef USE_GUSI2 - pos = lseek(fileno(f->f_fp), 1L, SEEK_CUR); - pos = lseek(fileno(f->f_fp), -1L, SEEK_CUR); - #else pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR); - #endif if (pos >= 0) { pos = ftell(f->f_fp); --- 717,721 ---- From jackjansen at users.sourceforge.net Wed Nov 19 17:52:25 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 17:52:44 2003 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.42, 2.43 errnomodule.c, 2.18, 2.19 socketmodule.c, 1.277, 1.278 structmodule.c, 2.60, 2.61 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv4143/Modules Modified Files: _localemodule.c errnomodule.c socketmodule.c structmodule.c Log Message: Getting rid of code dependent on GUSI or the MetroWerks compiler. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -d -r2.42 -r2.43 *** _localemodule.c 4 Sep 2003 18:24:47 -0000 2.42 --- _localemodule.c 19 Nov 2003 22:52:23 -0000 2.43 *************** *** 35,39 **** #endif ! #if defined(__APPLE__) || defined(__MWERKS__) #include "macglue.h" #endif --- 35,39 ---- #endif ! #if defined(__APPLE__) #include "macglue.h" #endif Index: errnomodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/errnomodule.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** errnomodule.c 2 Aug 2002 02:27:13 -0000 2.18 --- errnomodule.c 19 Nov 2003 22:52:23 -0000 2.19 *************** *** 4,12 **** #include "Python.h" - /* Mac with GUSI has more errors than those in errno.h */ - #ifdef USE_GUSI - #include - #endif - /* Windows socket errors (WSA*) */ #ifdef MS_WINDOWS --- 4,7 ---- Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.277 retrieving revision 1.278 diff -C2 -d -r1.277 -r1.278 *** socketmodule.c 20 Oct 2003 14:01:54 -0000 1.277 --- socketmodule.c 19 Nov 2003 22:52:23 -0000 1.278 *************** *** 1740,1748 **** return s->errorhandler(); } - #ifdef USE_GUSI2 - /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ - if (strchr(mode, 'b') != NULL) - bufsize = 0; - #endif f = PyFile_FromFile(fp, "", mode, fclose); if (f != NULL) --- 1740,1743 ---- Index: structmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -d -r2.60 -r2.61 *** structmodule.c 29 Mar 2003 10:04:55 -0000 2.60 --- structmodule.c 19 Nov 2003 22:52:23 -0000 2.61 *************** *** 42,54 **** /* Define various structs to figure out the alignments of types */ - #ifdef __MWERKS__ - /* - ** XXXX We have a problem here. There are no unique alignment rules - ** on the PowerPC mac. - */ - #ifdef __powerc - #pragma options align=mac68k - #endif - #endif /* __MWERKS__ */ typedef struct { char c; short x; } st_short; --- 42,45 ---- From jackjansen at users.sourceforge.net Wed Nov 19 20:45:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:07 2003 Subject: [Python-checkins] python/dist/src/Include osdefs.h, 2.15, 2.16 structmember.h, 2.20, 2.21 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Include Modified Files: osdefs.h structmember.h Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: osdefs.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/osdefs.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** osdefs.h 26 Feb 2002 11:20:01 -0000 2.15 --- osdefs.h 20 Nov 2003 01:44:57 -0000 2.16 *************** *** 8,18 **** /* Operating system dependencies */ - #ifdef macintosh - #define SEP ':' - #define MAXPATHLEN 256 - /* Mod by Jack: newline is less likely to occur in filenames than space */ - #define DELIM '\n' - #endif - /* Mod by chrish: QNX has WATCOM, but isn't DOS */ #if !defined(__QNX__) --- 8,11 ---- Index: structmember.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/structmember.h,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -d -r2.20 -r2.21 *** structmember.h 12 Aug 2002 07:21:57 -0000 2.20 --- structmember.h 20 Nov 2003 01:44:57 -0000 2.21 *************** *** 64,71 **** /* Added by Jack: strings contained in the structure */ #define T_STRING_INPLACE 13 - #ifdef macintosh - #define T_PSTRING 14 /* macintosh pascal-style counted string */ - #define T_PSTRING_INPLACE 15 - #endif /* macintosh */ #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError --- 64,67 ---- From jackjansen at users.sourceforge.net Wed Nov 19 20:45:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:13 2003 Subject: [Python-checkins] python/dist/src/Mac/Include macglue.h,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Mac/Include Modified Files: macglue.h Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: macglue.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/macglue.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** macglue.h 19 Nov 2003 16:34:04 -0000 1.64 --- macglue.h 20 Nov 2003 01:44:58 -0000 1.65 *************** *** 32,85 **** #endif - /* Scheduler parameters */ - typedef struct { - int check_interrupt; /* if true check for command-dot */ - int process_events; /* if nonzero enable evt processing, this mask */ - int besocial; /* Be social, give up CPU now and again */ - double check_interval; /* how often to check */ - double bg_yield; /* yield at most so long when in background */ - } PyMacSchedParams; - - unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */ - - extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */ - extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */ - extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */ - extern OSErr PyMac_init_application_location(void); /* Init the above */ - extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */ - extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ - - int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */ - void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */ - int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */ - - int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */ - PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */ - int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */ - PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */ - struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */ - - void PyMac_InitApplet(void); /* Initialize and run an Applet */ - void PyMac_Initialize(void); /* Initialize function for embedding Python */ - - - /* From macfiletype.c: */ - - long PyMac_getfiletype(char *); /* Get file type */ - int PyMac_setfiletype(char *, long, long); /* Set file creator and type */ - - /* from macmain.c: */ - void PyMac_Exit(int); - void PyMac_InitApplication(void); - void PyMac_OutputSeen(void); - void PyMac_OutputNotSeen(void); - int PyMac_GetDelayConsoleFlag(void); - - /* from macgetargv: */ - OSErr PyMac_init_process_location(void); - char * strdup(const char *str); - #ifdef __cplusplus } --- 32,37 ---- From jackjansen at users.sourceforge.net Wed Nov 19 20:45:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:17 2003 Subject: [Python-checkins] python/dist/src/Python ceval.c, 2.372, 2.373 errors.c, 2.80, 2.81 import.c, 2.224, 2.225 pythonrun.c, 2.200, 2.201 strerror.c, 2.11, 2.12 structmember.c, 2.23, 2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Python Modified Files: ceval.c errors.c import.c pythonrun.c strerror.c structmember.c Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.372 retrieving revision 2.373 diff -C2 -d -r2.372 -r2.373 *** ceval.c 5 Nov 2003 17:29:35 -0000 2.372 --- ceval.c 20 Nov 2003 01:44:58 -0000 2.373 *************** *** 15,22 **** #include "structmember.h" - #ifdef macintosh - #include "macglue.h" - #endif - #include --- 15,18 ---- *************** *** 802,806 **** } } ! #if !defined(HAVE_SIGNAL_H) || defined(macintosh) /* If we have true signals, the signal handler will call Py_AddPendingCall() so we don't --- 798,802 ---- } } ! #if !defined(HAVE_SIGNAL_H) /* If we have true signals, the signal handler will call Py_AddPendingCall() so we don't Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.80 retrieving revision 2.81 diff -C2 -d -r2.80 -r2.81 *** errors.c 25 Oct 2003 14:29:27 -0000 2.80 --- errors.c 20 Nov 2003 01:44:58 -0000 2.81 *************** *** 4,13 **** #include "Python.h" - #ifdef macintosh - extern char *PyMac_StrError(int); - #undef strerror - #define strerror PyMac_StrError - #endif /* macintosh */ - #ifndef __STDC__ #ifndef MS_WINDOWS --- 4,7 ---- Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.224 retrieving revision 2.225 diff -C2 -d -r2.224 -r2.225 *** import.c 20 Oct 2003 14:01:55 -0000 2.224 --- import.c 20 Nov 2003 01:44:58 -0000 2.225 *************** *** 12,18 **** #include "osdefs.h" #include "importdl.h" - #ifdef macintosh - #include "macglue.h" - #endif #ifdef HAVE_FCNTL_H --- 12,15 ---- *************** *** 836,842 **** if (Py_VerboseFlag) PySys_WriteStderr("# wrote %s\n", cpathname); - #ifdef macintosh - PyMac_setfiletype(cpathname, 'Pyth', 'PYC '); - #endif } --- 833,836 ---- *************** *** 1124,1134 **** strcat(buf, name); strcpy(name, buf); - #ifdef macintosh - /* Freezing on the mac works different, and the modules are - ** actually on sys.path. So we don't take the quick exit but - ** continue with the normal flow. - */ - path = NULL; - #else if (find_frozen(name) != NULL) { strcpy(buf, name); --- 1118,1121 ---- *************** *** 1138,1142 **** "No frozen submodule named %.200s", name); return NULL; - #endif } if (path == NULL) { --- 1125,1128 ---- *************** *** 1234,1264 **** } - #ifdef macintosh - /* - ** Speedup: each sys.path item is interned, and - ** FindResourceModule remembers which items refer to - ** folders (so we don't have to bother trying to look - ** into them for resources). We only do this for string - ** items. - */ - if (PyString_Check(PyList_GET_ITEM(path, i))) { - PyString_InternInPlace(&PyList_GET_ITEM(path, i)); - v = PyList_GET_ITEM(path, i); - if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_RESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_CODERESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - } - #endif if (len > 0 && buf[len-1] != SEP #ifdef ALTSEP --- 1220,1223 ---- *************** *** 1291,1298 **** #endif #endif - #ifdef macintosh - fdp = PyMac_FindModuleExtension(buf, &len, name); - if (fdp) { - #else #if defined(PYOS_OS2) /* take a snapshot of the module spec for restoration --- 1250,1253 ---- *************** *** 1332,1336 **** if (Py_VerboseFlag > 1) PySys_WriteStderr("# trying %s\n", buf); - #endif /* !macintosh */ filemode = fdp->mode; if (filemode[0] == 'U') --- 1287,1290 ---- *************** *** 1409,1415 **** #include - #elif defined(macintosh) - #include - #elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) #include --- 1363,1366 ---- *************** *** 1476,1497 **** return strncmp(ffblk.ff_name, name, namelen) == 0; - /* macintosh */ - #elif defined(macintosh) - FSSpec fss; - OSErr err; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - err = FSMakeFSSpec(0, 0, Pstring(buf), &fss); - if (err) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - return fss.name[0] >= namelen && - strncmp(name, (char *)fss.name+1, namelen) == 0; - /* new-fangled macintosh (macosx) */ #elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) --- 1427,1430 ---- *************** *** 1710,1722 **** #endif - #ifdef macintosh - case PY_RESOURCE: - m = PyMac_LoadResourceModule(name, buf); - break; - case PY_CODERESOURCE: - m = PyMac_LoadCodeResourceModule(name, buf); - break; - #endif - case PKG_DIRECTORY: m = load_package(name, buf); --- 1643,1646 ---- *************** *** 2679,2697 **** } - #ifdef macintosh - static PyObject * - imp_load_resource(PyObject *self, PyObject *args) - { - char *name; - char *pathname; - PyObject *m; - - if (!PyArg_ParseTuple(args, "ss:load_resource", &name, &pathname)) - return NULL; - m = PyMac_LoadResourceModule(name, pathname); - return m; - } - #endif /* macintosh */ - static PyObject * imp_load_module(PyObject *self, PyObject *args) --- 2603,2606 ---- *************** *** 2823,2829 **** #endif {"load_package", imp_load_package, METH_VARARGS}, - #ifdef macintosh - {"load_resource", imp_load_resource, METH_VARARGS}, - #endif {"load_source", imp_load_source, METH_VARARGS}, {NULL, NULL} /* sentinel */ --- 2732,2735 ---- Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.200 retrieving revision 2.201 diff -C2 -d -r2.200 -r2.201 *** pythonrun.c 19 Nov 2003 15:24:47 -0000 2.200 --- pythonrun.c 20 Nov 2003 01:44:58 -0000 2.201 *************** *** 28,34 **** #endif - #ifdef macintosh - #include "macglue.h" - #endif extern char *Py_GetPath(void); --- 28,31 ---- *************** *** 756,766 **** return 1; - #ifdef macintosh - /* On a mac, we also assume a pyc file for types 'PYC ' and 'APPL' */ - if (PyMac_getfiletype((char *)filename) == 'PYC ' - || PyMac_getfiletype((char *)filename) == 'APPL') - return 1; - #endif /* macintosh */ - /* Only look into the file if we are allowed to close it, since it then should also be seekable. */ --- 753,756 ---- *************** *** 1543,1551 **** Py_Finalize(); - #ifdef macintosh - PyMac_Exit(sts); - #else exit(sts); - #endif } --- 1533,1537 ---- Index: strerror.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/strerror.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** strerror.c 28 Nov 2001 20:42:01 -0000 2.11 --- strerror.c 20 Nov 2003 01:44:58 -0000 2.12 *************** *** 18,24 **** return buf; } - - #ifdef macintosh - int sys_nerr = 0; - char *sys_errlist[1] = 0; - #endif --- 18,19 ---- Index: structmember.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/structmember.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -d -r2.23 -r2.24 *** structmember.c 4 Dec 2001 16:23:42 -0000 2.23 --- structmember.c 20 Nov 2003 01:44:58 -0000 2.24 *************** *** 104,124 **** v = PyString_FromString((char*)addr); break; - #ifdef macintosh - case T_PSTRING: - if (*(char**)addr == NULL) { - Py_INCREF(Py_None); - v = Py_None; - } - else - v = PyString_FromStringAndSize( - (*(char**)addr)+1, - **(unsigned char**)addr); - break; - case T_PSTRING_INPLACE: - v = PyString_FromStringAndSize( - ((char*)addr)+1, - *(unsigned char*)addr); - break; - #endif /* macintosh */ case T_CHAR: v = PyString_FromStringAndSize((char*)addr, 1); --- 104,107 ---- *************** *** 169,177 **** PyObject *oldv; ! if ((l->flags & READONLY) || l->type == T_STRING ! #ifdef macintosh ! || l->type == T_PSTRING ! #endif ! ) { PyErr_SetString(PyExc_TypeError, "readonly attribute"); --- 152,156 ---- PyObject *oldv; ! if ((l->flags & READONLY) || l->type == T_STRING) { PyErr_SetString(PyExc_TypeError, "readonly attribute"); From jackjansen at users.sourceforge.net Wed Nov 19 20:45:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:21 2003 Subject: [Python-checkins] python/dist/src/Objects floatobject.c, 2.124, 2.125 object.c, 2.212, 2.213 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Objects Modified Files: floatobject.c object.c Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.124 retrieving revision 2.125 diff -C2 -d -r2.124 -r2.125 *** floatobject.c 28 Jun 2003 20:04:24 -0000 2.124 --- floatobject.c 20 Nov 2003 01:44:58 -0000 2.125 *************** *** 9,13 **** #include ! #if !defined(__STDC__) && !defined(macintosh) extern double fmod(double, double); extern double pow(double, double); --- 9,13 ---- #include ! #if !defined(__STDC__) extern double fmod(double, double); extern double pow(double, double); Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.212 retrieving revision 2.213 diff -C2 -d -r2.212 -r2.213 *** object.c 19 Nov 2003 15:24:47 -0000 2.212 --- object.c 20 Nov 2003 01:44:58 -0000 2.213 *************** *** 4,11 **** #include "Python.h" - #ifdef macintosh - #include "macglue.h" - #endif - #ifdef Py_REF_DEBUG long _Py_RefTotal; --- 4,7 ---- From jackjansen at users.sourceforge.net Wed Nov 19 20:45:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:25 2003 Subject: [Python-checkins] python/dist/src/Modules _hotshot.c, 1.34, 1.35 _tkinter.c, 1.162, 1.163 getbuildinfo.c, 2.10, 2.11 parsermodule.c, 2.80, 2.81 timemodule.c, 2.138, 2.139 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Modules Modified Files: _hotshot.c _tkinter.c getbuildinfo.c parsermodule.c timemodule.c Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** _hotshot.c 17 Mar 2003 19:46:07 -0000 1.34 --- _hotshot.c 20 Nov 2003 01:44:58 -0000 1.35 *************** *** 27,31 **** #error "This module requires gettimeofday() on non-Windows platforms!" #endif ! #if defined(macintosh) || (defined(PYOS_OS2) && defined(PYCC_GCC)) #include #else --- 27,31 ---- #error "This module requires gettimeofday() on non-Windows platforms!" #endif ! #if (defined(PYOS_OS2) && defined(PYCC_GCC)) #include #else *************** *** 48,55 **** #define BUFFERSIZE 10240 - #ifdef macintosh - #define PATH_MAX 254 - #endif - #if defined(PYOS_OS2) && defined(PYCC_GCC) #define PATH_MAX 260 --- 48,51 ---- *************** *** 941,945 **** #endif } ! #if defined(MS_WINDOWS) || defined(macintosh) || defined(PYOS_OS2) || \ defined(__VMS) rusage_diff = -1; --- 937,941 ---- #endif } ! #if defined(MS_WINDOWS) || defined(PYOS_OS2) || \ defined(__VMS) rusage_diff = -1; Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** _tkinter.c 3 Oct 2003 17:12:26 -0000 1.162 --- _tkinter.c 20 Nov 2003 01:44:58 -0000 1.163 *************** *** 34,41 **** #endif - #ifdef macintosh - #define MAC_TCL - #endif - /* Allow using this code in Python 2.[12] */ #ifndef PyDoc_STRVAR --- 34,37 ---- *************** *** 97,109 **** #endif ! #if defined(macintosh) ! /* Sigh, we have to include this to get at the tcl qd pointer */ ! #include ! /* And this one we need to clear the menu bar */ ! #include ! #endif ! ! #if !(defined(MS_WINDOWS) || defined(__CYGWIN__) || defined(macintosh)) ! /* Mac has it, but it doesn't really work:-( */ #define HAVE_CREATEFILEHANDLER #endif --- 93,97 ---- #endif ! #if !(defined(MS_WINDOWS) || defined(__CYGWIN__)) #define HAVE_CREATEFILEHANDLER #endif *************** *** 239,265 **** #endif - #ifdef macintosh - - /* - ** Additional cruft needed by Tcl/Tk on the Mac. - ** This is for Tcl 7.5 and Tk 4.1 (patch release 1). - */ - - /* ckfree() expects a char* */ - #define FREECAST (char *) - - #include /* For EventRecord */ - - typedef int (*TclMacConvertEventPtr) (EventRecord *eventPtr); - void Tcl_MacSetEventProc(TclMacConvertEventPtr procPtr); - int TkMacConvertEvent(EventRecord *eventPtr); - - static int PyMacConvertEvent(EventRecord *eventPtr); - - #include - extern int SIOUXIsAppWindow(WindowPtr); - - #endif /* macintosh */ - #ifndef FREECAST #define FREECAST (char *) --- 227,230 ---- *************** *** 647,656 **** v->StringType = Tcl_GetObjType("string"); - #if defined(macintosh) - /* This seems to be needed */ - ClearMenuBar(); - TkMacInitMenus(v->interp); - #endif - /* Delete the 'exit' command, which can screw things up */ Tcl_DeleteCommand(v->interp, "exit"); --- 612,615 ---- *************** *** 3093,3203 **** #endif - #ifdef macintosh - /* - ** Part of this code is stolen from MacintoshInit in tkMacAppInit. - ** Most of the initializations in that routine (toolbox init calls and - ** such) have already been done for us, so we only need these. - */ - tcl_macQdPtr = &qd; - - Tcl_MacSetEventProc(PyMacConvertEvent); - #if GENERATINGCFM - mac_addlibresources(); - #endif /* GENERATINGCFM */ - #endif /* macintosh */ } - - - - #ifdef macintosh - - /* - ** Anyone who embeds Tcl/Tk on the Mac must define panic(). - */ - - void - panic(char * format, ...) - { - va_list varg; - - va_start(varg, format); - - vfprintf(stderr, format, varg); - (void) fflush(stderr); - - va_end(varg); - - Py_FatalError("Tcl/Tk panic"); - } - - /* - ** Pass events to SIOUX before passing them to Tk. - */ - - static int - PyMacConvertEvent(EventRecord *eventPtr) - { - WindowPtr frontwin; - /* - ** Sioux eats too many events, so we don't pass it everything. We - ** always pass update events to Sioux, and we only pass other events if - ** the Sioux window is frontmost. This means that Tk menus don't work - ** in that case, but at least we can scroll the sioux window. - ** Note that the SIOUXIsAppWindow() routine we use here is not really - ** part of the external interface of Sioux... - */ - frontwin = FrontWindow(); - if ( eventPtr->what == updateEvt || SIOUXIsAppWindow(frontwin) ) { - if (SIOUXHandleOneEvent(eventPtr)) - return 0; /* Nothing happened to the Tcl event queue */ - } - return TkMacConvertEvent(eventPtr); - } - - #if GENERATINGCFM - - /* - ** Additional Mac specific code for dealing with shared libraries. - */ - - #include - #include - - static int loaded_from_shlib = 0; - static FSSpec library_fss; - - /* - ** If this module is dynamically loaded the following routine should - ** be the init routine. It takes care of adding the shared library to - ** the resource-file chain, so that the tk routines can find their - ** resources. - */ - OSErr pascal - init_tkinter_shlib(CFragInitBlockPtr data) - { - __initialize(); - if ( data == nil ) return noErr; - if ( data->fragLocator.where == kDataForkCFragLocator ) { - library_fss = *data->fragLocator.u.onDisk.fileSpec; - loaded_from_shlib = 1; - } else if ( data->fragLocator.where == kResourceCFragLocator ) { - library_fss = *data->fragLocator.u.inSegs.fileSpec; - loaded_from_shlib = 1; - } - return noErr; - } - - /* - ** Insert the library resources into the search path. Put them after - ** the resources from the application. Again, we ignore errors. - */ - static - mac_addlibresources(void) - { - if ( !loaded_from_shlib ) - return; - (void)FSpOpenResFile(&library_fss, fsRdPerm); - } - - #endif /* GENERATINGCFM */ - #endif /* macintosh */ --- 3052,3054 ---- Index: getbuildinfo.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/getbuildinfo.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** getbuildinfo.c 5 Mar 2003 14:15:18 -0000 2.10 --- getbuildinfo.c 20 Nov 2003 01:44:58 -0000 2.11 *************** *** 1,8 **** #include "Python.h" - #ifdef macintosh - #include "macbuildno.h" - #endif - #ifndef DONT_HAVE_STDIO_H #include --- 1,4 ---- Index: parsermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.80 retrieving revision 2.81 diff -C2 -d -r2.80 -r2.81 *** parsermodule.c 21 Jul 2003 14:25:23 -0000 2.80 --- parsermodule.c 20 Nov 2003 01:44:58 -0000 2.81 *************** *** 40,47 **** #endif - #ifdef macintosh - char *strdup(char *); - #endif - /* String constants used to initialize module attributes. * --- 40,43 ---- Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.138 retrieving revision 2.139 diff -C2 -d -r2.138 -r2.139 *** timemodule.c 1 Jul 2003 05:16:08 -0000 2.138 --- timemodule.c 20 Nov 2003 01:44:59 -0000 2.139 *************** *** 7,16 **** #include - #ifdef macintosh - #include - #include - #else #include - #endif #ifdef QUICKWIN --- 7,11 ---- *************** *** 90,124 **** static PyObject *moddict; - #ifdef macintosh - /* Our own timezone. We have enough information to deduce whether - ** DST is on currently, but unfortunately we cannot put it to good - ** use because we don't know the rules (and that is needed to have - ** localtime() return correct tm_isdst values for times other than - ** the current time. So, we cop out and only tell the user the current - ** timezone. - */ - static long timezone; - - static void - initmactimezone(void) - { - MachineLocation loc; - long delta; - - ReadLocation(&loc); - - if (loc.latitude == 0 && loc.longitude == 0 && loc.u.gmtDelta == 0) - return; - - delta = loc.u.gmtDelta & 0x00FFFFFF; - - if (delta & 0x00800000) - delta |= 0xFF000000; - - timezone = -delta; - } - #endif /* macintosh */ - - static PyObject * time_time(PyObject *self, PyObject *args) --- 85,88 ---- *************** *** 637,651 **** } #else - #ifdef macintosh - /* The only thing we can obtain is the current timezone - ** (and whether dst is currently _active_, but that is not what - ** we're looking for:-( ) - */ - initmactimezone(); - PyModule_AddIntConstant(m, "timezone", timezone); - PyModule_AddIntConstant(m, "altzone", timezone); - PyModule_AddIntConstant(m, "daylight", 0); - PyModule_AddObject(m, "tzname", Py_BuildValue("(zz)", "", "")); - #endif /* macintosh */ #endif /* HAVE_STRUCT_TM_TM_ZONE */ #ifdef __CYGWIN__ --- 601,604 ---- *************** *** 830,842 **** } Py_END_ALLOW_THREADS - #elif defined(macintosh) - #define MacTicks (* (long *)0x16A) - long deadline; - deadline = MacTicks + (long)(secs * 60.0); - while (MacTicks < deadline) { - /* XXX Should call some yielding function here */ - if (PyErr_CheckSignals()) - return -1; - } #elif defined(__WATCOMC__) && !defined(__QNX__) /* XXX Can't interrupt this sleep */ --- 783,786 ---- From jackjansen at users.sourceforge.net Wed Nov 19 20:45:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed Nov 19 20:45:29 2003 Subject: [Python-checkins] python/dist/src/Parser intrcheck.c, 2.44, 2.45 pgenmain.c, 2.28, 2.29 tokenizer.c, 2.73, 2.74 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1:/tmp/cvs-serv1623/Parser Modified Files: intrcheck.c pgenmain.c tokenizer.c Log Message: Getting rid of all the code inside #ifdef macintosh too. Index: intrcheck.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/intrcheck.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** intrcheck.c 12 Jan 2002 11:05:09 -0000 2.44 --- intrcheck.c 20 Nov 2003 01:44:58 -0000 2.45 *************** *** 93,104 **** - #ifdef macintosh - - /* The Mac interrupt code has moved to macglue.c */ - #define OK - - #endif /* macintosh */ - - #ifndef OK --- 93,96 ---- Index: pgenmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/pgenmain.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** pgenmain.c 27 Oct 2002 01:59:21 -0000 2.28 --- pgenmain.c 20 Nov 2003 01:44:58 -0000 2.29 *************** *** 154,166 **** } - #ifdef macintosh - /* ARGSUSED */ - int - guesstabsize(char *path) - { - return 4; - } - #endif - /* No-nonsense my_readline() for tokenizer.c */ --- 154,157 ---- Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -d -r2.73 -r2.74 *** tokenizer.c 17 Feb 2003 18:31:57 -0000 2.73 --- tokenizer.c 20 Nov 2003 01:44:58 -0000 2.74 *************** *** 785,789 **** } tok->cur = tok->buf + cur; - #ifndef macintosh /* replace "\r\n" with "\n" */ /* For Mac we leave the \r, giving a syntax error */ --- 785,788 ---- *************** *** 794,798 **** tok->inp = pt; } - #endif } if (tok->done != E_OK) { --- 793,796 ---- *************** *** 1186,1198 **** } - #ifdef macintosh - if (c == '\r') { - PySys_WriteStderr( - "File contains \\r characters (incorrect line endings?)\n"); - tok->done = E_TOKEN; - tok->cur = tok->inp; - return ERRORTOKEN; - } - #endif /* Period or number starting with period? */ if (c == '.') { --- 1184,1187 ---- From mwh at python.net Thu Nov 20 07:06:50 2003 From: mwh at python.net (Michael Hudson) Date: Thu Nov 20 07:07:02 2003 Subject: [Python-checkins] python/dist/src/Lib codeop.py,1.7,1.8 In-Reply-To: (doerwalter@users.sourceforge.net's message of "Wed, 19 Nov 2003 05:35:51 -0800") References: Message-ID: <2mn0arkzvp.fsf@starship.python.net> doerwalter@users.sourceforge.net writes: > Update of /cvsroot/python/python/dist/src/Lib > In directory sc8-pr-cvs1:/tmp/cvs-serv29941/Lib > > Modified Files: > codeop.py > Log Message: > Fix typos. Uh, no. > This module provides two interfaces, broadly similar to the builtin ^^^^^^^^^^^^^^ > ! function compile(), that take progam text, a filename and a 'mode' ^^^^ perhaps this should be which... Cheers, mwh -- 6. The code definitely is not portable - it will produce incorrect results if run from the surface of Mars. -- James Bonfield, http://www.ioccc.org/2000/rince.hint From jackjansen at users.sourceforge.net Thu Nov 20 08:27:35 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:27:40 2003 Subject: [Python-checkins] python/dist/src/Mac/Include pythonresources.h, 1.29, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory sc8-pr-cvs1:/tmp/cvs-serv7240 Removed Files: pythonresources.h Log Message: No longer used. --- pythonresources.h DELETED --- From jackjansen at users.sourceforge.net Thu Nov 20 08:28:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:28:24 2003 Subject: [Python-checkins] python/dist/src/Mac/Include macglue.h,1.65,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory sc8-pr-cvs1:/tmp/cvs-serv7290/Mac/Include Removed Files: macglue.h Log Message: Got rid of macglue.h, moved the little bit that remains relevant to pymactoolbox.h (where it should have been in the first place). --- macglue.h DELETED --- From jackjansen at users.sourceforge.net Thu Nov 20 08:28:21 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:28:28 2003 Subject: [Python-checkins] python/dist/src/Include pymactoolbox.h,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv7290/Include Modified Files: pymactoolbox.h Log Message: Got rid of macglue.h, moved the little bit that remains relevant to pymactoolbox.h (where it should have been in the first place). Index: pymactoolbox.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymactoolbox.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pymactoolbox.h 19 Nov 2003 15:32:46 -0000 1.9 --- pymactoolbox.h 20 Nov 2003 13:28:19 -0000 1.10 *************** *** 16,19 **** --- 16,21 ---- char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */ char *PyMac_StrError(int); /* strerror with mac errors */ + extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ + PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ From jackjansen at users.sourceforge.net Thu Nov 20 08:31:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:32 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ae _AEmodule.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/ae Modified Files: _AEmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _AEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/_AEmodule.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** _AEmodule.c 19 Nov 2003 16:34:03 -0000 1.21 --- _AEmodule.c 20 Nov 2003 13:30:55 -0000 1.22 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:39 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/folder _Foldermodule.c, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/folder In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/folder Modified Files: _Foldermodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Foldermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/folder/_Foldermodule.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _Foldermodule.c 19 Nov 2003 16:13:27 -0000 1.2 --- _Foldermodule.c 20 Nov 2003 13:30:57 -0000 1.3 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:43 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules ColorPickermodule.c, 1.6, 1.7 Nav.c, 1.28, 1.29 OSATerminology.c, 1.3, 1.4 gestaltmodule.c, 1.9, 1.10 icgluemodule.c, 1.12, 1.13 macosmodule.c, 1.69, 1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules Modified Files: ColorPickermodule.c Nav.c OSATerminology.c gestaltmodule.c icgluemodule.c macosmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: ColorPickermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ColorPickermodule.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ColorPickermodule.c 19 Nov 2003 15:32:46 -0000 1.6 --- ColorPickermodule.c 20 Nov 2003 13:30:55 -0000 1.7 *************** *** 24,28 **** #include #include "Python.h" - #include "macglue.h" #include "pymactoolbox.h" --- 24,27 ---- Index: Nav.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/Nav.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Nav.c 19 Nov 2003 22:43:57 -0000 1.28 --- Nav.c 20 Nov 2003 13:30:55 -0000 1.29 *************** *** 31,35 **** #include "Python.h" - #include "macglue.h" #include "pymactoolbox.h" #include --- 31,34 ---- Index: OSATerminology.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/OSATerminology.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSATerminology.c 19 Nov 2003 15:32:46 -0000 1.3 --- OSATerminology.c 20 Nov 2003 13:30:55 -0000 1.4 *************** *** 8,12 **** */ #include "Python.h" ! #include "macglue.h" #include --- 8,12 ---- */ #include "Python.h" ! #include "pymactoolbox.h" #include Index: gestaltmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/gestaltmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** gestaltmodule.c 19 Nov 2003 15:32:46 -0000 1.9 --- gestaltmodule.c 20 Nov 2003 13:30:55 -0000 1.10 *************** *** 26,30 **** #include "Python.h" ! #include "macglue.h" #include --- 26,30 ---- #include "Python.h" ! #include "pymactoolbox.h" #include Index: icgluemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icgluemodule.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** icgluemodule.c 19 Nov 2003 15:32:46 -0000 1.12 --- icgluemodule.c 20 Nov 2003 13:30:55 -0000 1.13 *************** *** 31,35 **** #include "Python.h" ! #include "macglue.h" extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */ --- 31,35 ---- #include "Python.h" ! #include "pymactoolbox.h" extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */ Index: macosmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macosmodule.c,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** macosmodule.c 19 Nov 2003 16:34:03 -0000 1.69 --- macosmodule.c 20 Nov 2003 13:30:55 -0000 1.70 *************** *** 26,31 **** #include "Python.h" ! #include "macglue.h" ! #include "pythonresources.h" #include --- 26,30 ---- #include "Python.h" ! #include "pymactoolbox.h" #include From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:50 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/fm _Fmmodule.c, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/fm Modified Files: _Fmmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Fmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/_Fmmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Fmmodule.c 19 Nov 2003 16:13:27 -0000 1.9 --- _Fmmodule.c 20 Nov 2003 13:30:57 -0000 1.10 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:55 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ah _AHmodule.c, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ah In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/ah Modified Files: _AHmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _AHmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ah/_AHmodule.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _AHmodule.c 19 Nov 2003 16:13:22 -0000 1.3 --- _AHmodule.c 20 Nov 2003 13:30:55 -0000 1.4 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:31:59 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/file _Filemodule.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/file In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/file Modified Files: _Filemodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Filemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/_Filemodule.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** _Filemodule.c 19 Nov 2003 16:34:04 -0000 1.21 --- _Filemodule.c 20 Nov 2003 13:30:57 -0000 1.22 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:05 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/drag _Dragmodule.c, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/drag In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/drag Modified Files: _Dragmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Dragmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/_Dragmodule.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _Dragmodule.c 19 Nov 2003 16:13:25 -0000 1.15 --- _Dragmodule.c 20 Nov 2003 13:30:56 -0000 1.16 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:11 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/evt _Evtmodule.c, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/evt In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/evt Modified Files: _Evtmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Evtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/_Evtmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Evtmodule.c 19 Nov 2003 16:13:26 -0000 1.9 --- _Evtmodule.c 20 Nov 2003 13:30:57 -0000 1.10 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:16 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ctl _Ctlmodule.c, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ctl In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/ctl Modified Files: _Ctlmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Ctlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/_Ctlmodule.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** _Ctlmodule.c 19 Nov 2003 16:34:03 -0000 1.26 --- _Ctlmodule.c 20 Nov 2003 13:30:56 -0000 1.27 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:24 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/dlg _Dlgmodule.c, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/dlg In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/dlg Modified Files: _Dlgmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Dlgmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/_Dlgmodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** _Dlgmodule.c 19 Nov 2003 16:13:25 -0000 1.19 --- _Dlgmodule.c 20 Nov 2003 13:30:56 -0000 1.20 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:28 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cm _Cmmodule.c, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cm In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/cm Modified Files: _Cmmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Cmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/_Cmmodule.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _Cmmodule.c 19 Nov 2003 16:13:25 -0000 1.16 --- _Cmmodule.c 20 Nov 2003 13:30:56 -0000 1.17 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:34 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.23, 1.24 pycfbridge.c, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/cf Modified Files: _CFmodule.c pycfbridge.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** _CFmodule.c 19 Nov 2003 16:13:24 -0000 1.23 --- _CFmodule.c 20 Nov 2003 13:30:56 -0000 1.24 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pycfbridge.c 19 Nov 2003 16:13:24 -0000 1.8 --- pycfbridge.c 20 Nov 2003 13:30:56 -0000 1.9 *************** *** 6,10 **** #include "Python.h" ! #include "macglue.h" #include "pycfbridge.h" --- 6,10 ---- #include "Python.h" ! #include "pymactoolbox.h" #include "pycfbridge.h" From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:40 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/cg _CGmodule.c, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/cg Modified Files: _CGmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** _CGmodule.c 19 Nov 2003 16:34:03 -0000 1.13 --- _CGmodule.c 20 Nov 2003 13:30:56 -0000 1.14 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:27 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:45 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/app _Appmodule.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/app Modified Files: _Appmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Appmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/_Appmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _Appmodule.c 19 Nov 2003 16:13:23 -0000 1.18 --- _Appmodule.c 20 Nov 2003 13:30:55 -0000 1.19 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:28 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:32:52 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/carbonevt CarbonEvtscan.py, 1.9, 1.10 CarbonEvtsupport.py, 1.14, 1.15 _CarbonEvtmodule.c, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/carbonevt In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/carbonevt Modified Files: CarbonEvtscan.py CarbonEvtsupport.py _CarbonEvtmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: CarbonEvtscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtscan.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CarbonEvtscan.py 15 Aug 2002 21:48:13 -0000 1.9 --- CarbonEvtscan.py 20 Nov 2003 13:30:55 -0000 1.10 *************** *** 85,89 **** "InstallEventHandler", "RemoveEventHandler", - "RunApplicationEventLoop", # Write by hand? --- 85,88 ---- Index: CarbonEvtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtsupport.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CarbonEvtsupport.py 19 Nov 2003 16:13:23 -0000 1.14 --- CarbonEvtsupport.py 20 Nov 2003 13:30:55 -0000 1.15 *************** *** 74,97 **** ! includestuff = r""" #include - #include "macglue.h" - - /* Macro to test whether a weak-loaded CFM function exists */ - #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ - PyErr_SetString(PyExc_NotImplementedError, \ - "Not available in this shared library/OS version"); \ - return; \ - }} while(0) - - - #define USE_MAC_MP_MULTITHREADING 0 - - #if USE_MAC_MP_MULTITHREADING - static PyThreadState *_save; - static MPCriticalRegionID reentrantLock; - #endif /* USE_MAC_MP_MULTITHREADING */ - extern int CFStringRef_New(CFStringRef *); --- 74,80 ---- ! includestuff = includestuff + r""" #include extern int CFStringRef_New(CFStringRef *); *************** *** 169,177 **** int status; - #if USE_MAC_MP_MULTITHREADING - MPEnterCriticalRegion(reentrantLock, kDurationForever); - PyEval_RestoreThread(_save); - #endif /* USE_MAC_MP_MULTITHREADING */ - retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, --- 152,155 ---- *************** *** 191,199 **** } - #if USE_MAC_MP_MULTITHREADING - _save = PyEval_SaveThread(); - MPExitCriticalRegion(reentrantLock); - #endif /* USE_MAC_MP_MULTITHREADING */ - return status; } --- 169,172 ---- *************** *** 204,208 **** initstuff = initstuff + """ - PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */ myEventHandlerUPP = NewEventHandlerUPP(myEventHandler); """ --- 177,180 ---- *************** *** 335,364 **** f.docstring = lambda: "(EventParamName eventName, EventParamType eventType) -> (String eventParamData)" EventRefobject.add(f) - - runappeventloop = """ - #if USE_MAC_MP_MULTITHREADING - if (MPCreateCriticalRegion(&reentrantLock) != noErr) { - PySys_WriteStderr("lock failure\\n"); - return NULL; - } - _save = PyEval_SaveThread(); - #endif /* USE_MAC_MP_MULTITHREADING */ - - RunApplicationEventLoop(); - - #if USE_MAC_MP_MULTITHREADING - PyEval_RestoreThread(_save); - - MPDeleteCriticalRegion(reentrantLock); - #endif /* USE_MAC_MP_MULTITHREADING */ - - Py_INCREF(Py_None); - _res = Py_None; - return _res; - """ - - f = ManualGenerator("RunApplicationEventLoop", runappeventloop); - f.docstring = lambda: "() -> ()" - module.add(f) SetOutputFileName('_CarbonEvtmodule.c') --- 307,310 ---- Index: _CarbonEvtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/_CarbonEvtmodule.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _CarbonEvtmodule.c 19 Nov 2003 16:13:23 -0000 1.15 --- _CarbonEvtmodule.c 20 Nov 2003 13:30:56 -0000 1.16 *************** *** 6,27 **** ! #include ! ! #include "macglue.h" /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return; \ ! }} while(0) ! - #define USE_MAC_MP_MULTITHREADING 0 ! #if USE_MAC_MP_MULTITHREADING ! static PyThreadState *_save; ! static MPCriticalRegionID reentrantLock; ! #endif /* USE_MAC_MP_MULTITHREADING */ extern int CFStringRef_New(CFStringRef *); --- 6,20 ---- ! #include "pymactoolbox.h" /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ ! }} while(0) ! #include extern int CFStringRef_New(CFStringRef *); *************** *** 100,108 **** int status; - #if USE_MAC_MP_MULTITHREADING - MPEnterCriticalRegion(reentrantLock, kDurationForever); - PyEval_RestoreThread(_save); - #endif /* USE_MAC_MP_MULTITHREADING */ - retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, --- 93,96 ---- *************** *** 122,130 **** } - #if USE_MAC_MP_MULTITHREADING - _save = PyEval_SaveThread(); - MPExitCriticalRegion(reentrantLock); - #endif /* USE_MAC_MP_MULTITHREADING */ - return status; } --- 110,113 ---- *************** *** 1846,1849 **** --- 1829,1843 ---- } + static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + RunApplicationEventLoop(); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args) { *************** *** 2043,2072 **** } - static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args) - { - PyObject *_res = NULL; - - #if USE_MAC_MP_MULTITHREADING - if (MPCreateCriticalRegion(&reentrantLock) != noErr) { - PySys_WriteStderr("lock failure\n"); - return NULL; - } - _save = PyEval_SaveThread(); - #endif /* USE_MAC_MP_MULTITHREADING */ - - RunApplicationEventLoop(); - - #if USE_MAC_MP_MULTITHREADING - PyEval_RestoreThread(_save); - - MPDeleteCriticalRegion(reentrantLock); - #endif /* USE_MAC_MP_MULTITHREADING */ - - Py_INCREF(Py_None); - _res = Py_None; - return _res; - - } - static PyMethodDef CarbonEvents_methods[] = { {"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1, --- 2037,2040 ---- *************** *** 2104,2107 **** --- 2072,2077 ---- {"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1, PyDoc_STR("() -> (EventTargetRef _rv)")}, + {"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1, + PyDoc_STR("() -> None")}, {"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1, PyDoc_STR("() -> None")}, *************** *** 2128,2133 **** {"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1, PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")}, - {"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1, - PyDoc_STR("() -> ()")}, {NULL, NULL, 0} }; --- 2098,2101 ---- *************** *** 2143,2147 **** - PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */ myEventHandlerUPP = NewEventHandlerUPP(myEventHandler); --- 2111,2114 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:33:50 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:33:53 2003 Subject: [Python-checkins] python/dist/src/Parser pgenmain.c,2.29,2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1:/tmp/cvs-serv8495/Parser Modified Files: pgenmain.c Log Message: Talk about old code: removed a reference to THINK_C. Index: pgenmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/pgenmain.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** pgenmain.c 20 Nov 2003 01:44:58 -0000 2.29 --- pgenmain.c 20 Nov 2003 13:33:48 -0000 2.30 *************** *** 27,34 **** /* Forward */ grammar *getgrammar(char *filename); - #ifdef THINK_C - int main(int, char **); - char *askfile(void); - #endif void --- 27,30 ---- *************** *** 45,53 **** char *filename, *graminit_h, *graminit_c; - #ifdef THINK_C - filename = askfile(); - graminit_h = askfile(); - graminit_c = askfile(); - #else if (argc != 4) { fprintf(stderr, --- 41,44 ---- *************** *** 58,62 **** graminit_h = argv[2]; graminit_c = argv[3]; - #endif g = getgrammar(filename); fp = fopen(graminit_c, "w"); --- 49,52 ---- *************** *** 126,149 **** return g; } - - #ifdef THINK_C - char * - askfile(void) - { - char buf[256]; - static char name[256]; - printf("Input file name: "); - if (fgets(buf, sizeof buf, stdin) == NULL) { - printf("EOF\n"); - Py_Exit(1); - } - /* XXX The (unsigned char *) case is needed by THINK C 3.0 */ - if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) { - printf("No file\n"); - Py_Exit(1); - } - return name; - } - #endif void --- 116,119 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:36:39 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/list _Listmodule.c, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/list In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/list Modified Files: _Listmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Listmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/list/_Listmodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _Listmodule.c 19 Nov 2003 16:13:29 -0000 1.17 --- _Listmodule.c 20 Nov 2003 13:30:58 -0000 1.18 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:36:48 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/icn _Icnmodule.c, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/icn In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/icn Modified Files: _Icnmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Icnmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/_Icnmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _Icnmodule.c 19 Nov 2003 16:13:28 -0000 1.8 --- _Icnmodule.c 20 Nov 2003 13:30:57 -0000 1.9 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:36:57 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/te _TEmodule.c, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/te In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/te Modified Files: _TEmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _TEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/te/_TEmodule.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _TEmodule.c 19 Nov 2003 16:13:34 -0000 1.16 --- _TEmodule.c 20 Nov 2003 13:30:59 -0000 1.17 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:04 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/waste wastemodule.c, 1.31, 1.32 wastescan.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/waste In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/waste Modified Files: wastemodule.c wastescan.py Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: wastemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastemodule.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** wastemodule.c 23 Dec 2002 23:16:25 -0000 1.31 --- wastemodule.c 20 Nov 2003 13:30:59 -0000 1.32 *************** *** 6,21 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) --- 6,16 ---- #include "pymactoolbox.h" /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) *************** *** 24,30 **** #include #include - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif /* Exported by Qdmodule.c: */ --- 19,22 ---- Index: wastescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastescan.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wastescan.py 21 Feb 2003 22:11:45 -0000 1.13 --- wastescan.py 20 Nov 2003 13:30:59 -0000 1.14 *************** *** 7,11 **** from scantools import Scanner ! WASTEDIR='/Volumes/Moes/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/MacOS Support/(Third Party Support)/Waste 2.0 Distribution/C_C++ Headers/' if not os.path.exists(WASTEDIR): --- 7,11 ---- from scantools import Scanner ! WASTEDIR='/Users/jack/src/waste/C_C++ Headers/' if not os.path.exists(WASTEDIR): From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:15 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/ibcarbon IBCarbonsupport.py, 1.5, 1.6 _IBCarbon.c, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/ibcarbon Modified Files: IBCarbonsupport.py _IBCarbon.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: IBCarbonsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon/IBCarbonsupport.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IBCarbonsupport.py 19 Nov 2003 16:13:27 -0000 1.5 --- IBCarbonsupport.py 20 Nov 2003 13:30:57 -0000 1.6 *************** *** 11,22 **** includestuff = """ #include ! #include "macglue.h" #ifdef USE_TOOLBOX_OBJECT_GLUE extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *); - //#define CFStringRefObj_Convert _CFStringRefObj_Convert #endif - - //extern int CFBundleRefObj_Convert(PyObject *, CFBundleRef *); // need to wrap CFBundle """ --- 11,19 ---- includestuff = """ #include ! #include "pymactoolbox.h" #ifdef USE_TOOLBOX_OBJECT_GLUE extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *); #endif """ Index: _IBCarbon.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ibcarbon/_IBCarbon.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _IBCarbon.c 19 Nov 2003 16:13:27 -0000 1.8 --- _IBCarbon.c 20 Nov 2003 13:30:57 -0000 1.9 *************** *** 7,18 **** #include ! #include "macglue.h" #ifdef USE_TOOLBOX_OBJECT_GLUE extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *); - //#define CFStringRefObj_Convert _CFStringRefObj_Convert #endif - - //extern int CFBundleRefObj_Convert(PyObject *, CFBundleRef *); // need to wrap CFBundle --- 7,15 ---- #include ! #include "pymactoolbox.h" #ifdef USE_TOOLBOX_OBJECT_GLUE extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *); #endif From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:20 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/res _Resmodule.c, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/res Modified Files: _Resmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** _Resmodule.c 19 Nov 2003 16:34:04 -0000 1.21 --- _Resmodule.c 20 Nov 2003 13:30:59 -0000 1.22 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:26 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/qt _Qtmodule.c, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qt In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/qt Modified Files: _Qtmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Qtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qt/_Qtmodule.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _Qtmodule.c 19 Nov 2003 16:13:33 -0000 1.16 --- _Qtmodule.c 20 Nov 2003 13:30:58 -0000 1.17 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:02 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:33 2003 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.43, 2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Modules Modified Files: _localemodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** _localemodule.c 19 Nov 2003 22:52:23 -0000 2.43 --- _localemodule.c 20 Nov 2003 13:30:59 -0000 2.44 *************** *** 30,40 **** #endif #if defined(MS_WINDOWS) #define WIN32_LEAN_AND_MEAN #include - #endif - - #if defined(__APPLE__) - #include "macglue.h" #endif --- 30,40 ---- #endif + #if defined(__APPLE__) + #include "pymactoolbox.h" + #endif + #if defined(MS_WINDOWS) #define WIN32_LEAN_AND_MEAN #include #endif From jackjansen at users.sourceforge.net Thu Nov 20 08:31:02 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:41 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/win _Winmodule.c, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/win Modified Files: _Winmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Winmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** _Winmodule.c 19 Nov 2003 16:34:04 -0000 1.20 --- _Winmodule.c 20 Nov 2003 13:30:59 -0000 1.21 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:48 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/scrap _Scrapmodule.c, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/scrap In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/scrap Modified Files: _Scrapmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Scrapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/scrap/_Scrapmodule.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _Scrapmodule.c 19 Nov 2003 16:13:34 -0000 1.8 --- _Scrapmodule.c 20 Nov 2003 13:30:59 -0000 1.9 *************** *** 6,24 **** - #ifndef PyDoc_STR - #define PyDoc_STR(x) (x) - #endif - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) --- 6,16 ---- #include "pymactoolbox.h" /* Macro to test whether a weak-loaded CFM function exists */ #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ ! PyErr_SetString(PyExc_NotImplementedError, \ ! "Not available in this shared library/OS version"); \ ! return NULL; \ }} while(0) *************** *** 32,36 **** PyTypeObject Scrap_Type; ! #define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type) typedef struct ScrapObject { --- 24,28 ---- PyTypeObject Scrap_Type; ! #define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type || PyObject_TypeCheck((x), &Scrap_Type)) typedef struct ScrapObject { *************** *** 61,65 **** { /* Cleanup of self->ob_itself goes here */ ! PyObject_DEL(self); } --- 53,57 ---- { /* Cleanup of self->ob_itself goes here */ ! self->ob_type->tp_free((PyObject *)self); } *************** *** 209,223 **** static PyMethodDef ScrapObj_methods[] = { {"GetScrapFlavorFlags", (PyCFunction)ScrapObj_GetScrapFlavorFlags, 1, ! "(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)"}, {"GetScrapFlavorSize", (PyCFunction)ScrapObj_GetScrapFlavorSize, 1, ! "(ScrapFlavorType flavorType) -> (Size byteCount)"}, {"GetScrapFlavorData", (PyCFunction)ScrapObj_GetScrapFlavorData, 1, ! "(ScrapFlavorType flavorType) -> string"}, {"PutScrapFlavor", (PyCFunction)ScrapObj_PutScrapFlavor, 1, ! "(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Buffer flavorData) -> None"}, {"GetScrapFlavorCount", (PyCFunction)ScrapObj_GetScrapFlavorCount, 1, ! "() -> (UInt32 infoCount)"}, {"GetScrapFlavorInfoList", (PyCFunction)ScrapObj_GetScrapFlavorInfoList, 1, ! "() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])"}, {NULL, NULL, 0} }; --- 201,215 ---- static PyMethodDef ScrapObj_methods[] = { {"GetScrapFlavorFlags", (PyCFunction)ScrapObj_GetScrapFlavorFlags, 1, ! PyDoc_STR("(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)")}, {"GetScrapFlavorSize", (PyCFunction)ScrapObj_GetScrapFlavorSize, 1, ! PyDoc_STR("(ScrapFlavorType flavorType) -> (Size byteCount)")}, {"GetScrapFlavorData", (PyCFunction)ScrapObj_GetScrapFlavorData, 1, ! PyDoc_STR("(ScrapFlavorType flavorType, Buffer destination) -> (Size byteCount)")}, {"PutScrapFlavor", (PyCFunction)ScrapObj_PutScrapFlavor, 1, ! PyDoc_STR("(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Size flavorSize, Buffer flavorData) -> None")}, {"GetScrapFlavorCount", (PyCFunction)ScrapObj_GetScrapFlavorCount, 1, ! PyDoc_STR("() -> (UInt32 infoCount)")}, {"GetScrapFlavorInfoList", (PyCFunction)ScrapObj_GetScrapFlavorInfoList, 1, ! PyDoc_STR("() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])")}, {NULL, NULL, 0} }; *************** *** 327,339 **** static PyMethodDef Scrap_methods[] = { {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, ! "() -> None"}, {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, ! "() -> None"}, {"GetCurrentScrap", (PyCFunction)Scrap_GetCurrentScrap, 1, ! "() -> (ScrapRef scrap)"}, {"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1, ! "() -> None"}, {"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1, ! "() -> None"}, {NULL, NULL, 0} }; --- 319,331 ---- static PyMethodDef Scrap_methods[] = { {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, ! PyDoc_STR("() -> None")}, {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, ! PyDoc_STR("() -> None")}, {"GetCurrentScrap", (PyCFunction)Scrap_GetCurrentScrap, 1, ! PyDoc_STR("() -> (ScrapRef scrap)")}, {"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1, ! PyDoc_STR("() -> None")}, {"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1, ! PyDoc_STR("() -> None")}, {NULL, NULL, 0} }; From jackjansen at users.sourceforge.net Thu Nov 20 08:31:01 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:37:57 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/snd _Sndihooks.c, 1.1, 1.2 _Sndmodule.c, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/snd In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/snd Modified Files: _Sndihooks.c _Sndmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Sndihooks.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/snd/_Sndihooks.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _Sndihooks.c 23 Aug 2001 13:58:34 -0000 1.1 --- _Sndihooks.c 20 Nov 2003 13:30:59 -0000 1.2 *************** *** 31,35 **** #include "Python.h" - #include "macglue.h" #include "pymactoolbox.h" #include --- 31,34 ---- Index: _Sndmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/snd/_Sndmodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _Sndmodule.c 19 Nov 2003 16:13:34 -0000 1.17 --- _Sndmodule.c 20 Nov 2003 13:30:59 -0000 1.18 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:02 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:38:03 2003 Subject: [Python-checkins] python/dist/src/Tools/bgen/bgen macsupport.py, 1.29, 1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Tools/bgen/bgen Modified Files: macsupport.py Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: macsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/macsupport.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** macsupport.py 19 Jan 2003 21:53:57 -0000 1.29 --- macsupport.py 20 Nov 2003 13:31:00 -0000 1.30 *************** *** 143,152 **** # Stuff added immediately after the system include files includestuff = """ - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 143,147 ---- *************** *** 201,210 **** def exceptionInitializer(self): return "PyMac_GetOSErrException()" - - _SetOutputFileName = SetOutputFileName # Save original - def SetOutputFileName(file = None): - "Set the output file name and set its creator&type to CWIE&TEXT" - _SetOutputFileName(file) - if file: - import MacOS - MacOS.SetCreatorAndType(file, 'CWIE', 'TEXT') --- 196,197 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:38:10 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/menu _Menumodule.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/menu In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/menu Modified Files: _Menumodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Menumodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/menu/_Menumodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _Menumodule.c 19 Nov 2003 16:13:30 -0000 1.18 --- _Menumodule.c 20 Nov 2003 13:30:58 -0000 1.19 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:38:18 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/mlte _Mltemodule.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/mlte In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/mlte Modified Files: _Mltemodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Mltemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/mlte/_Mltemodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _Mltemodule.c 19 Nov 2003 16:13:31 -0000 1.18 --- _Mltemodule.c 20 Nov 2003 13:30:58 -0000 1.19 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:38:23 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/qd _Qdmodule.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qd In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/qd Modified Files: _Qdmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Qdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/_Qdmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _Qdmodule.c 19 Nov 2003 16:13:31 -0000 1.18 --- _Qdmodule.c 20 Nov 2003 13:30:58 -0000 1.19 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From jackjansen at users.sourceforge.net Thu Nov 20 08:31:29 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:38:29 2003 Subject: [Python-checkins] python/dist/src/Mac/Modules/help _Helpmodule.c, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/help In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/help Modified Files: _Helpmodule.c Log Message: Got rid of macglue.h, replacing it by pymactoolbox.h where relevant. Cleaned up various things in the toolbox modules. Index: _Helpmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/_Helpmodule.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** _Helpmodule.c 19 Nov 2003 16:34:04 -0000 1.10 --- _Helpmodule.c 20 Nov 2003 13:30:57 -0000 1.11 *************** *** 6,15 **** - #ifdef _WIN32 - #include "pywintoolbox.h" - #else - #include "macglue.h" #include "pymactoolbox.h" - #endif /* Macro to test whether a weak-loaded CFM function exists */ --- 6,10 ---- From doerwalter at users.sourceforge.net Thu Nov 20 08:38:03 2003 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Nov 20 08:38:36 2003 Subject: [Python-checkins] python/dist/src/Lib codeop.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv9147/Lib Modified Files: codeop.py Log Message: Fix typo fix. Index: codeop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** codeop.py 19 Nov 2003 13:35:49 -0000 1.8 --- codeop.py 20 Nov 2003 13:38:01 -0000 1.9 *************** *** 2,11 **** This module provides two interfaces, broadly similar to the builtin ! function compile(), that takes program text, a filename and a 'mode' and: ! - Returns code object if the command is complete and valid ! - Returns None if the command is incomplete ! - Raises SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). --- 2,11 ---- This module provides two interfaces, broadly similar to the builtin ! function compile(), which take program text, a filename and a 'mode' and: ! - Return code object if the command is complete and valid ! - Return None if the command is incomplete ! - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). From doerwalter at users.sourceforge.net Thu Nov 20 08:39:00 2003 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Nov 20 08:39:02 2003 Subject: [Python-checkins] python/dist/src/Lib codeop.py,1.7.8.1,1.7.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv9277/Lib Modified Files: Tag: release23-maint codeop.py Log Message: Backport checkin: Fix typo fix. Index: codeop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v retrieving revision 1.7.8.1 retrieving revision 1.7.8.2 diff -C2 -d -r1.7.8.1 -r1.7.8.2 *** codeop.py 19 Nov 2003 13:37:01 -0000 1.7.8.1 --- codeop.py 20 Nov 2003 13:38:57 -0000 1.7.8.2 *************** *** 2,11 **** This module provides two interfaces, broadly similar to the builtin ! function compile(), that takes program text, a filename and a 'mode' and: ! - Returns a code object if the command is complete and valid ! - Returns None if the command is incomplete ! - Raises SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). --- 2,11 ---- This module provides two interfaces, broadly similar to the builtin ! function compile(), which takes program text, a filename and a 'mode' and: ! - Return a code object if the command is complete and valid ! - Return None if the command is incomplete ! - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). From walter at livinglogic.de Thu Nov 20 08:40:00 2003 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Thu Nov 20 08:40:05 2003 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Lib codeop.py, 1.7, 1.8 In-Reply-To: <2mn0arkzvp.fsf@starship.python.net> References: <2mn0arkzvp.fsf@starship.python.net> Message-ID: <3FBCC430.4020709@livinglogic.de> Michael Hudson wrote: > doerwalter@users.sourceforge.net writes: > > >>Update of /cvsroot/python/python/dist/src/Lib >>In directory sc8-pr-cvs1:/tmp/cvs-serv29941/Lib >> >>Modified Files: >> codeop.py >>Log Message: >>Fix typos. > > Uh, no. > >> This module provides two interfaces, broadly similar to the builtin > ^^^^^^^^^^^^^^ > >>! function compile(), that take progam text, a filename and a 'mode' > ^^^^ > perhaps this should be which... This depens on whether "take program text..." refers to compile() or to "two interfaces". OK, I've fixed the fix. Bye, Walter D?rwald From jackjansen at users.sourceforge.net Thu Nov 20 08:50:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:51:12 2003 Subject: [Python-checkins] python/dist/src/Mac/Distributions readme.txt, 1.11, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory sc8-pr-cvs1:/tmp/cvs-serv10974/Distributions Removed Files: readme.txt Log Message: Added some help to OSX/Dist/README.txt, plus all the information from the OS9 readme that is still relevant. Got rid of Distributions/readme.txt. --- readme.txt DELETED --- From jackjansen at users.sourceforge.net Thu Nov 20 08:50:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 20 08:51:20 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist README.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1:/tmp/cvs-serv10974/OSX/Dist Modified Files: README.txt Log Message: Added some help to OSX/Dist/README.txt, plus all the information from the OS9 readme that is still relevant. Got rid of Distributions/readme.txt. Index: README.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.txt 21 Mar 2003 23:52:36 -0000 1.1 --- README.txt 20 Nov 2003 13:50:28 -0000 1.2 *************** *** 1,3 **** ! This is a set of build scripts and such for MacPython-OSX 2.3 that I ! will use until there are standard distributions from Jack. --- 1,49 ---- ! Building a MacPython distribution ! ================================= ! ! The ``build`` shell script here creates MacPython distributions. ! 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 the stuff in ``resources`` and compresses that installer as a ! ``.dmg`` disk image. ! ! Here are the steps you ned to follow to build a MacPython installer: ! ! - There are various version numbers that need to be updated. Weed through ! ``Mac/OSXResources``, ``Mac/scripts`` and ``Mac/Tools`` and inspect the ! various ``.plist`` and ``.strings`` files. Note that the latter are ! UTF-16 files. ! - Edit ``resource/ReadMe.txt`` and ``resources/Welcome.rtf`` to reflect ! version number and such. ! - Edit ``build`` to change ``PYVERSION``, ``PYVER`` and ``BUILDNUM``. ! - Run ``./build``. Optionally you can pass the name of the directory ! where Python will be built, so you don't have to wait for the complete ! build when you're debugging the process. For the final distribution use ! a clean build. ! - When done the script will tell you where the DMG image is. ! ! Currently (November 2003) there is still a bug in the build procedure ! for $DESTROOT builds: building some of the applets will fail (in ! ``Mac/OSX/Makefile``) if you don't have the same version of Python installed ! normally. So before doing the distribution you should build and install ! a framework Python in the normal way. + When all is done, announcements can be posted to at least the following + places: + - pythonmac-sig@python.org + - python-dev@python.org + - python-announce@python.org + - archivist@info-mac.org + - adcnews@apple.com + - news@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@oratrix.com) + - http://www.macshareware.net (userid jackjansen) + + Also, check out Stephan Deibels http://pythonology.org/market contact list + + After all this is done you may also need to update the Package Manager + database for the new distribution. A description of this remains TBD. From mwh at python.net Thu Nov 20 08:53:02 2003 From: mwh at python.net (Michael Hudson) Date: Thu Nov 20 08:55:55 2003 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Lib codeop.py, 1.7, 1.8 In-Reply-To: <3FBCC430.4020709@livinglogic.de> References: <2mn0arkzvp.fsf@starship.python.net> <3FBCC430.4020709@livinglogic.de> Message-ID: Walter D?rwald writes: > Michael Hudson wrote: > > > doerwalter@users.sourceforge.net writes: > > > >>Update of /cvsroot/python/python/dist/src/Lib > >>In directory sc8-pr-cvs1:/tmp/cvs-serv29941/Lib > >> > >>Modified Files: > >> codeop.py Log Message: > >>Fix typos. > > Uh, no. > > > >> This module provides two interfaces, broadly similar to the builtin > > ^^^^^^^^^^^^^^ > > > >>! function compile(), that take progam text, a filename and a 'mode' > > ^^^^ > > perhaps this should be which... > > This depens on whether "take program text..." refers to compile() or > to "two interfaces". Hmm, yes. Hadn't thought of reading it that way... > OK, I've fixed the fix. Thank you! Cheers, mwh -- Q: What are 1000 lawyers at the bottom of the ocean? A: A good start. (A lawyer told me this joke.) -- Michael Str?der, comp.lang.python From rhettinger at users.sourceforge.net Thu Nov 20 14:02:05 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 20 14:02:09 2003 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.148,1.149 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv5571 Modified Files: regrtest.py Log Message: test_applesingle is an expected skip on Win32 Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** regrtest.py 16 Nov 2003 16:17:48 -0000 1.148 --- regrtest.py 20 Nov 2003 19:02:02 -0000 1.149 *************** *** 555,558 **** --- 555,559 ---- """ test__locale + test_applesingle test_al test_bsddb185 From tim_one at users.sourceforge.net Thu Nov 20 16:21:48 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 16:21:55 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv30573/Lib/test Modified Files: test_weakref.py Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_weakref.py 16 Nov 2003 16:17:48 -0000 1.31 --- test_weakref.py 20 Nov 2003 21:21:46 -0000 1.32 *************** *** 338,341 **** --- 338,546 ---- del c2 + def test_callback_in_cycle_1(self): + import gc + + class J(object): + pass + + class II(object): + def acallback(self, ignore): + self.J + + I = II() + I.J = J + I.wr = weakref.ref(J, I.acallback) + + # Now J and II are each in a self-cycle (as all new-style class + # objects are, since their __mro__ points back to them). I holds + # both a weak reference (I.wr) and a strong reference (I.J) to class + # J. I is also in a cycle (I.wr points to a weakref that references + # I.acallback). When we del these three, they all become trash, but + # the cycles prevent any of them from getting cleaned up immediately. + # Instead they have to wait for cyclic gc to deduce that they're + # trash. + # + # gc used to call tp_clear on all of them, and the order in which + # it does that is pretty accidental. The exact order in which we + # built up these things manages to provoke gc into running tp_clear + # in just the right order (I last). Calling tp_clear on II leaves + # behind an insane class object (its __mro__ becomes NULL). Calling + # tp_clear on J breaks its self-cycle, but J doesn't get deleted + # just then because of the strong reference from I.J. Calling + # tp_clear on I starts to clear I's __dict__, and just happens to + # clear I.J first -- I.wr is still intact. That removes the last + # reference to J, which triggers the weakref callback. The callback + # tries to do "self.J", and instances of new-style classes look up + # attributes ("J") in the class dict first. The class (II) wants to + # search II.__mro__, but that's NULL. The result was a segfault in + # a release build, and an assert failure in a debug build. + del I, J, II + gc.collect() + + def test_callback_in_cycle_2(self): + import gc + + # This is just like test_callback_in_cycle_1, except that II is an + # old-style class. The symptom is different then: an instance of an + # old-style class looks in its own __dict__ first. 'J' happens to + # get cleared from I.__dict__ before 'wr', and 'J' was never in II's + # __dict__, so the attribute isn't found. The difference is that + # the old-style II doesn't have a NULL __mro__ (it doesn't have any + # __mro__), so no segfault occurs. Instead it got: + # test_callback_in_cycle_2 (__main__.ReferencesTestCase) ... + # Exception exceptions.AttributeError: + # "II instance has no attribute 'J'" in > ignored + + class J(object): + pass + + class II: + def acallback(self, ignore): + self.J + + I = II() + I.J = J + I.wr = weakref.ref(J, I.acallback) + + del I, J, II + gc.collect() + + def test_callback_in_cycle_3(self): + import gc + + # This one broke the first patch that fixed the last two. In this + # case, the objects reachable from the callback aren't also reachable + # from the object (c1) *triggering* the callback: you can get to + # c1 from c2, but not vice-versa. The result was that c2's __dict__ + # got tp_clear'ed by the time the c2.cb callback got invoked. + + class C: + def cb(self, ignore): + self.me + self.c1 + self.wr + + c1, c2 = C(), C() + + c2.me = c2 + c2.c1 = c1 + c2.wr = weakref.ref(c1, c2.cb) + + del c1, c2 + gc.collect() + + def test_callback_in_cycle_4(self): + import gc + + # Like test_callback_in_cycle_3, except c2 and c1 have different + # classes. c2's class (C) isn't reachable from c1 then, so protecting + # objects reachable from the dying object (c1) isn't enough to stop + # c2's class (C) from getting tp_clear'ed before c2.cb is invoked. + # The result was a segfault (C.__mro__ was NULL when the callback + # tried to look up self.me). + + class C(object): + def cb(self, ignore): + self.me + self.c1 + self.wr + + class D: + pass + + c1, c2 = D(), C() + + c2.me = c2 + c2.c1 = c1 + c2.wr = weakref.ref(c1, c2.cb) + + del c1, c2, C, D + gc.collect() + + def test_callback_in_cycle_resurrection(self): + import gc + + # Do something nasty in a weakref callback: resurrect objects + # from dead cycles. For this to be attempted, the weakref and + # its callback must also be part of the cyclic trash (else the + # objects reachable via the callback couldn't be in cyclic trash + # to begin with -- the callback would act like an external root). + # But gc clears trash weakrefs with callbacks early now, which + # disables the callbacks, so the callbacks shouldn't get called + # at all (and so nothing actually gets resurrected). + + alist = [] + class C(object): + def __init__(self, value): + self.attribute = value + + def acallback(self, ignore): + alist.append(self.c) + + c1, c2 = C(1), C(2) + c1.c = c2 + c2.c = c1 + c1.wr = weakref.ref(c2, c1.acallback) + c2.wr = weakref.ref(c1, c2.acallback) + + def C_went_away(ignore): + alist.append("C went away") + wr = weakref.ref(C, C_went_away) + + del c1, c2, C # make them all trash + self.assertEqual(alist, []) # del isn't enough to reclaim anything + + gc.collect() + # c1.wr and c2.wr were part of the cyclic trash, so should have + # been cleared without their callbacks executing. OTOH, the weakref + # to C is bound to a function local (wr), and wasn't trash, so that + # callback should have been invoked when C went away. + self.assertEqual(alist, ["C went away"]) + # The remaining weakref should be dead now (its callback ran). + self.assertEqual(wr(), None) + + del alist[:] + gc.collect() + self.assertEqual(alist, []) + + def test_callbacks_on_callback(self): + import gc + + # Set up weakref callbacks *on* weakref callbacks. + alist = [] + def safe_callback(ignore): + alist.append("safe_callback called") + + class C(object): + def cb(self, ignore): + alist.append("cb called") + + c, d = C(), C() + c.other = d + d.other = c + callback = c.cb + c.wr = weakref.ref(d, callback) # this won't trigger + d.wr = weakref.ref(callback, d.cb) # ditto + external_wr = weakref.ref(callback, safe_callback) # but this will + self.assert_(external_wr() is callback) + + # The weakrefs attached to c and d should get cleared, so that + # C.cb is never called. But external_wr isn't part of the cyclic + # trash, and no cyclic trash is reachable from it, so safe_callback + # should get invoked when the bound method object callback (c.cb) + # -- which is itself a callback, and also part of the cyclic trash -- + # gets reclaimed at the end of gc. + + del callback, c, d, C + self.assertEqual(alist, []) # del isn't enough to clean up cycles + gc.collect() + self.assertEqual(alist, ["safe_callback called"]) + self.assertEqual(external_wr(), None) + + del alist[:] + gc.collect() + self.assertEqual(alist, []) + class Object: def __init__(self, arg): From tim_one at users.sourceforge.net Thu Nov 20 16:21:48 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 16:22:06 2003 Subject: [Python-checkins] python/dist/src/Include weakrefobject.h,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv30573/Include Modified Files: weakrefobject.h Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced. Index: weakrefobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/weakrefobject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** weakrefobject.h 12 Aug 2002 07:21:58 -0000 1.3 --- weakrefobject.h 20 Nov 2003 21:21:45 -0000 1.4 *************** *** 40,43 **** --- 40,45 ---- PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head); + PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); + #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object) From tim_one at users.sourceforge.net Thu Nov 20 16:21:48 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 16:22:17 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.895,1.896 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv30573/Misc Modified Files: NEWS Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.895 retrieving revision 1.896 diff -C2 -d -r1.895 -r1.896 *** NEWS 19 Nov 2003 19:51:55 -0000 1.895 --- NEWS 20 Nov 2003 21:21:46 -0000 1.896 *************** *** 13,19 **** ----------------- ! - Compiler flags set in PYTHONSTARTUP are now active in __main__. ! ! - Added two builtin types, set() and frozenset(). - Critical bugfix, for SF bug 840829: if cyclic garbage collection --- 13,30 ---- ----------------- ! - Critical bugfix, for SF bug 839548: if a weakref with a callback, ! its callback, and its weakly referenced object, all became part of ! cyclic garbage during a single run of garbage collection, the order ! in which they were torn down was unpredictable. It was possible for ! the callback to see partially-torn-down objects, leading to immediate ! segfaults, or, if the callback resurrected garbage objects, to ! resurrect insane objects that caused segfaults (or other surprises) ! later. In one sense this wasn't surprising, because Python's cyclic gc ! had no knowledge of Python's weakref objects. It does now. When ! weakrefs with callbacks become part of cyclic garbage now, those ! weakrefs are cleared first. The callbacks don't trigger then, ! preventing the problems. If you need callbacks to trigger, then just ! as when cyclic gc is not involved, you need to write your code so ! that weakref objects outlive the objects they weakly reference. - Critical bugfix, for SF bug 840829: if cyclic garbage collection *************** *** 22,25 **** --- 33,40 ---- in a debug build, a segfault occurred reliably very soon after). This has been repaired. + + - Compiler flags set in PYTHONSTARTUP are now active in __main__. + + - Added two builtin types, set() and frozenset(). - Added a reversed() builtin function that returns a reverse iterator From tim_one at users.sourceforge.net Thu Nov 20 16:21:48 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 16:22:26 2003 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv30573/Objects Modified Files: weakrefobject.c Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** weakrefobject.c 14 Jul 2003 21:46:23 -0000 1.13 --- weakrefobject.c 20 Nov 2003 21:21:46 -0000 1.14 *************** *** 54,58 **** *list = self->wr_next; self->wr_object = Py_None; - self->wr_callback = NULL; if (self->wr_prev != NULL) self->wr_prev->wr_next = self->wr_next; --- 54,57 ---- *************** *** 61,68 **** self->wr_prev = NULL; self->wr_next = NULL; ! Py_XDECREF(callback); } } static void --- 60,94 ---- self->wr_prev = NULL; self->wr_next = NULL; ! } ! if (callback != NULL) { ! Py_DECREF(callback); ! self->wr_callback = NULL; } } + /* Cyclic gc uses this to *just* clear the passed-in reference, leaving + * the callback intact and uncalled. It must be possible to call self's + * tp_dealloc() after calling this, so self has to be left in a sane enough + * state for that to work. We expect tp_dealloc to decref the callback + * then. The reason for not letting clear_weakref() decref the callback + * right now is that if the callback goes away, that may in turn trigger + * another callback (if a weak reference to the callback exists) -- running + * arbitrary Python code in the middle of gc is a disaster. The convolution + * here allows gc to delay triggering such callbacks until the world is in + * a sane state again. + */ + void + _PyWeakref_ClearRef(PyWeakReference *self) + { + PyObject *callback; + + assert(self != NULL); + assert(PyWeakref_Check(self)); + /* Preserve and restore the callback around clear_weakref. */ + callback = self->wr_callback; + self->wr_callback = NULL; + clear_weakref(self); + self->wr_callback = callback; + } static void *************** *** 118,122 **** return self->hash; } ! static PyObject * --- 144,148 ---- return self->hash; } ! static PyObject * *************** *** 325,329 **** WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) ! static int proxy_nonzero(PyWeakReference *proxy) { --- 351,355 ---- WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) ! static int proxy_nonzero(PyWeakReference *proxy) { From tim_one at users.sourceforge.net Thu Nov 20 16:21:48 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 16:22:35 2003 Subject: [Python-checkins] python/dist/src/Modules gc_weakref.txt, NONE, 2.1 gcmodule.c, 2.73, 2.74 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv30573/Modules Modified Files: gcmodule.c Added Files: gc_weakref.txt Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced. --- NEW FILE: gc_weakref.txt --- Before 2.3.3, Python's cyclic gc didn't pay any attention to weakrefs. Segfaults in Zope3 resulted. weakrefs in Python are designed to, at worst, let *other* objects learn that a given object has died, via a callback function. The weakly referenced object itself is not passed to the callback, and the presumption is that the weakly referenced object is unreachable trash at the time the callback is invoked. That's usually true, but not always. Suppose a weakly referenced object becomes part of a clump of cyclic trash. When enough cycles are broken by cyclic gc that the object is reclaimed, the callback is invoked. If it's possible for the callback to get at objects in the cycle(s), then it may be possible for those objects to access (via strong references in the cycle) the weakly referenced object being torn down, or other objects in the cycle that have already suffered a tp_clear() call. There's no guarantee that an object is in a sane state after tp_clear(). Bad things (including segfaults) can happen right then, during the callback's execution, or can happen at any later time if the callback manages to resurrect an insane object. Note that if it's possible for the callback to get at objects in the trash cycles, it must also be the case that the callback itself is part of the trash cycles. Else the callback would have acted as an external root to the current collection, and nothing reachable from it would be in cyclic trash either. More, if the callback itself is in cyclic trash, then the weakref to which the callback is attached must also be trash, and for the same kind of reason: if the weakref acted as an external root, then the callback could not have been cyclic trash. So a problem here requires that a weakref, that weakref's callback, and the weakly referenced object, all be in cyclic trash at the same time. This isn't easy to stumble into by accident while Python is running, and, indeed, it took quite a while to dream up failing test cases. Zope3 saw segfaults during shutdown, during the second call of gc in Py_Finalize, after most modules had been torn down. That creates many trash cycles (esp. those involving new-style classes), making the problem much more likely. Once you know what's required to provoke the problem, though, it's easy to create tests that segfault before shutdown. In 2.3.3, before breaking cycles, we first clear all the weakrefs with callbacks in cyclic trash. Since the weakrefs *are* trash, and there's no defined-- or even predictable --order in which tp_clear() gets called on cyclic trash, it's defensible to first clear weakrefs with callbacks. It's a feature of Python's weakrefs too that when a weakref goes away, the callback (if any) associated with it is thrown away too, unexecuted. Just that much is almost enough to prevent problems, by throwing away *almost* all the weakref callbacks that could get triggered by gc. The problem remaining is that clearing a weakref with a callback decrefs the callback object, and the callback object may *itself* be weakly referenced, via another weakref with another callback. So the process of clearing weakrefs can trigger callbacks attached to other weakrefs, and those latter weakrefs may or may not be part of cyclic trash. So, to prevent any Python code from running while gc is invoking tp_clear() on all the objects in cyclic trash, it's not quite enough just to invoke tp_clear() on weakrefs with callbacks first. Instead the weakref module grew a new private function (_PyWeakref_ClearRef) that does only part of tp_clear(): it removes the weakref from the weakly-referenced object's list of weakrefs, but does not decref the callback object. So calling _PyWeakref_ClearRef(wr) ensures that wr's callback object will never trigger, and (unlike weakref's tp_clear()) also prevents any callback associated *with* wr's callback object from triggering. Then we can call tp_clear on all the cyclic objects and never trigger Python code. After we do that, the callback objects still need to be decref'ed. Callbacks (if any) *on* the callback objects that were also part of cyclic trash won't get invoked, because we cleared all trash weakrefs with callbacks at the start. Callbacks on the callback objects that were not part of cyclic trash acted as external roots to everything reachable from them, so nothing reachable from them was part of cyclic trash, so gc didn't do any damage to objects reachable from them, and it's safe to call them at the end of gc. An alternative would have been to treat objects with callbacks like objects with __del__ methods, refusing to collect them, appending them to gc.garbage instead. That would have been much easier. Jim Fulton gave a strong argument against that (on Python-Dev): There's a big difference between __del__ and weakref callbacks. The __del__ method is "internal" to a design. When you design a class with a del method, you know you have to avoid including the class in cycles. Now, suppose you have a design that makes has no __del__ methods but that does use cyclic data structures. You reason about the design, run tests, and convince yourself you don't have a leak. Now, suppose some external code creates a weakref to one of your objects. All of a sudden, you start leaking. You can look at your code all you want and you won't find a reason for the leak. IOW, a class designer can out-think __del__ problems, but has no control over who creates weakrefs to his classes or class instances. The class user has little chance either of predicting when the weakrefs he creates may end up in cycles. Callbacks on weakref callbacks are executed in an arbitrary order, and that's not good (a primary reason not to collect cycles with objects with __del__ methods is to avoid running finalizers in an arbitrary order). However, a weakref callback on a weakref callback has got to be rare. It's possible to do such a thing, so gc has to be robust against it, but I doubt anyone has done it outside the test case I wrote for it. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -d -r2.73 -r2.74 *** gcmodule.c 14 Nov 2003 00:01:17 -0000 2.73 --- gcmodule.c 20 Nov 2003 21:21:46 -0000 2.74 *************** *** 397,407 **** } ! /* Move the objects in unreachable with __del__ methods into finalizers. ! * The objects remaining in unreachable do not have __del__ methods, and ! * gc_refs remains GC_TENTATIVELY_UNREACHABLE for them. The objects ! * moved into finalizers have gc_refs changed to GC_REACHABLE. */ static void ! move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) { PyGC_Head *gc = unreachable->gc.gc_next; --- 397,411 ---- } ! /* Move the objects in unreachable with __del__ methods into finalizers, ! * and weakrefs with callbacks into wr_callbacks. ! * The objects remaining in unreachable do not have __del__ methods, and are ! * not weakrefs with callbacks. ! * The objects moved have gc_refs changed to GC_REACHABLE; the objects ! * remaining in unreachable are left at GC_TENTATIVELY_UNREACHABLE. */ static void ! move_troublemakers(PyGC_Head *unreachable, ! PyGC_Head *finalizers, ! PyGC_Head *wr_callbacks) { PyGC_Head *gc = unreachable->gc.gc_next; *************** *** 418,421 **** --- 422,431 ---- gc->gc.gc_refs = GC_REACHABLE; } + else if (PyWeakref_Check(op) && + ((PyWeakReference *)op)->wr_callback) { + gc_list_remove(gc); + gc_list_append(gc, wr_callbacks); + gc->gc.gc_refs = GC_REACHABLE; + } gc = next; } *************** *** 454,457 **** --- 464,554 ---- } + /* Clear all trash weakrefs with callbacks. This clears weakrefs first, + * which has the happy result of disabling the callbacks without executing + * them. A nasty technical complication: a weakref callback can itself be + * the target of a weakref, in which case decrefing the callback can cause + * another callback to trigger. But we can't allow arbitrary Python code to + * get executed at this point (the callback on the callback may try to muck + * with other cyclic trash we're trying to collect, even resurrecting it + * while we're in the middle of doing tp_clear() on the trash). + * + * The private _PyWeakref_ClearRef() function exists so that we can clear + * the reference in a weakref without triggering a callback on the callback. + * + * We have to save the callback objects and decref them later. But we can't + * allocate new memory to save them (if we can't get new memory, we're dead). + * So we grab a new reference on the clear'ed weakref, which prevents the + * rest of gc from reclaiming it. _PyWeakref_ClearRef() leaves the + * weakref's wr_callback member intact. + * + * In the end, then, wr_callbacks consists of cleared weakrefs that are + * immune from collection. Near the end of gc, after collecting all the + * cyclic trash, we call release_weakrefs(). That releases our references + * to the cleared weakrefs, which in turn may trigger callbacks on their + * callbacks. + */ + static void + clear_weakrefs(PyGC_Head *wr_callbacks) + { + PyGC_Head *gc = wr_callbacks->gc.gc_next; + + for (; gc != wr_callbacks; gc = gc->gc.gc_next) { + PyObject *op = FROM_GC(gc); + PyWeakReference *wr; + + assert(IS_REACHABLE(op)); + assert(PyWeakref_Check(op)); + wr = (PyWeakReference *)op; + assert(wr->wr_callback != NULL); + Py_INCREF(op); + _PyWeakref_ClearRef(wr); + } + } + + /* Called near the end of gc. This gives up the references we own to + * cleared weakrefs, allowing them to get collected, and in turn decref'ing + * their callbacks. + * + * If a callback object is itself the target of a weakref callback, + * decref'ing the callback object may trigger that other callback. If + * that other callback was part of the cyclic trash in this generation, + * that won't happen, since we cleared *all* trash-weakref callbacks near + * the start of gc. If that other callback was not part of the cyclic trash + * in this generation, then it acted like an external root to this round + * of gc, so all the objects reachable from that callback are still alive. + * + * Giving up the references to the weakref objects will probably make + * them go away too. However, if a weakref is reachable from finalizers, + * it won't go away. We move it to the old generation then. Since a + * weakref object doesn't have a finalizer, that's the right thing to do (it + * doesn't belong in gc.garbage). + * + * We return the number of weakref objects freed (those not appended to old). + */ + static int + release_weakrefs(PyGC_Head *wr_callbacks, PyGC_Head *old) + { + int num_freed = 0; + + while (! gc_list_is_empty(wr_callbacks)) { + PyGC_Head *gc = wr_callbacks->gc.gc_next; + PyObject *op = FROM_GC(gc); + PyWeakReference *wr = (PyWeakReference *)op; + + assert(IS_REACHABLE(op)); + assert(PyWeakref_Check(op)); + assert(wr->wr_callback != NULL); + Py_DECREF(op); + if (wr_callbacks->gc.gc_next == gc) { + /* object is still alive -- move it */ + gc_list_remove(gc); + gc_list_append(gc, old); + } + else + ++num_freed; + } + return num_freed; + } + static void debug_instance(char *msg, PyInstanceObject *inst) *************** *** 555,560 **** PyGC_Head *young; /* the generation we are examining */ PyGC_Head *old; /* next older generation */ ! PyGC_Head unreachable; ! PyGC_Head finalizers; PyGC_Head *gc; --- 652,658 ---- PyGC_Head *young; /* the generation we are examining */ PyGC_Head *old; /* next older generation */ ! PyGC_Head unreachable; /* non-problematic unreachable trash */ ! PyGC_Head finalizers; /* objects with, & reachable from, __del__ */ ! PyGC_Head wr_callbacks; /* weakrefs with callbacks */ PyGC_Head *gc; *************** *** 617,634 **** * finalizers can't safely be deleted. Python programmers should take * care not to create such things. For Python, finalizers means ! * instance objects with __del__ methods. * ! * Move unreachable objects with finalizers into a different list. */ gc_list_init(&finalizers); ! move_finalizers(&unreachable, &finalizers); /* finalizers contains the unreachable objects with a finalizer; ! * unreachable objects reachable only *from* those are also ! * uncollectable, and we move those into the finalizers list too. */ move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print ! * debugging information. */ for (gc = unreachable.gc.gc_next; gc != &unreachable; gc = gc->gc.gc_next) { --- 715,745 ---- * finalizers can't safely be deleted. Python programmers should take * care not to create such things. For Python, finalizers means ! * instance objects with __del__ methods. Weakrefs with callbacks ! * can call arbitrary Python code, so those are special-cased too. * ! * Move unreachable objects with finalizers, and weakrefs with ! * callbacks, into different lists. */ gc_list_init(&finalizers); ! gc_list_init(&wr_callbacks); ! move_troublemakers(&unreachable, &finalizers, &wr_callbacks); ! /* Clear the trash weakrefs with callbacks. This prevents their ! * callbacks from getting invoked (when a weakref goes away, so does ! * its callback). ! * We do this even if the weakrefs are reachable from finalizers. ! * If we didn't, breaking cycles in unreachable later could trigger ! * deallocation of objects in finalizers, which could in turn ! * cause callbacks to trigger. This may not be ideal behavior. ! */ ! clear_weakrefs(&wr_callbacks); /* finalizers contains the unreachable objects with a finalizer; ! * unreachable objects reachable *from* those are also uncollectable, ! * and we move those into the finalizers list too. */ move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print ! * debugging information. ! */ for (gc = unreachable.gc.gc_next; gc != &unreachable; gc = gc->gc.gc_next) { *************** *** 643,646 **** --- 754,762 ---- */ delete_garbage(&unreachable, old); + + /* Now that we're done analyzing stuff and breaking cycles, let + * delayed weakref callbacks run. + */ + m += release_weakrefs(&wr_callbacks, old); /* Collect statistics on uncollectable objects found and print From gvanrossum at users.sourceforge.net Thu Nov 20 17:11:32 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Nov 20 17:11:34 2003 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.149,1.150 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv10625 Modified Files: regrtest.py Log Message: test_applesingle is an expected skip almost anywhere. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** regrtest.py 20 Nov 2003 19:02:02 -0000 1.149 --- regrtest.py 20 Nov 2003 22:11:29 -0000 1.150 *************** *** 593,596 **** --- 593,597 ---- """ test_al + test_applesingle test_bsddb185 test_cd *************** *** 655,658 **** --- 656,660 ---- """ test_al + test_applesingle test_bsddb test_bsddb185 *************** *** 676,679 **** --- 678,682 ---- """ test_al + test_applesingle test_bsddb test_bsddb185 *************** *** 697,700 **** --- 700,704 ---- """ test_al + test_applesingle test_asynchat test_bsddb *************** *** 727,730 **** --- 731,735 ---- """ test_al + test_applesingle test_asynchat test_atexit *************** *** 792,795 **** --- 797,801 ---- """ test_al + test_applesingle test_bsddb test_bsddb185 *************** *** 812,815 **** --- 818,822 ---- """ test_al + test_applesingle test_bsddb test_bsddb185 *************** *** 838,841 **** --- 845,849 ---- """ test_al + test_applesingle test_bsddb185 test_cd *************** *** 862,865 **** --- 870,874 ---- """ test_al + test_applesingle test_bsddb185 test_bsddb3 *************** *** 884,887 **** --- 893,897 ---- """ test_al + test_applesingle test_audioop test_bsddb185 *************** *** 907,939 **** test_sunaudiodev """, ! 'freebsd4': ! """ ! test_aepack ! test_al ! test_bsddb ! test_bsddb3 ! test_cd ! test_cl ! test_email_codecs ! test_gl ! test_imgfile ! test_linuxaudiodev ! test_locale ! test_macfs ! test_macostools ! test_nis ! test_normalization ! test_ossaudiodev ! test_pep277 ! test_plistlib ! test_scriptpackages ! test_socket_ssl ! test_socketserver ! test_sunaudiodev ! test_timeout ! test_unicode_file ! test_urllibnet ! test_winreg ! test_winsound """, } --- 917,950 ---- test_sunaudiodev """, ! 'freebsd4': ! """ ! test_aepack ! test_al ! test_applesingle ! test_bsddb ! test_bsddb3 ! test_cd ! test_cl ! test_email_codecs ! test_gl ! test_imgfile ! test_linuxaudiodev ! test_locale ! test_macfs ! test_macostools ! test_nis ! test_normalization ! test_ossaudiodev ! test_pep277 ! test_plistlib ! test_scriptpackages ! test_socket_ssl ! test_socketserver ! test_sunaudiodev ! test_timeout ! test_unicode_file ! test_urllibnet ! test_winreg ! test_winsound """, } From tim_one at users.sourceforge.net Thu Nov 20 17:13:52 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 17:13:55 2003 Subject: [Python-checkins] python/dist/src/Include weakrefobject.h, 1.3, 1.3.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv10811/Include Modified Files: Tag: release23-maint weakrefobject.h Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix, backported from 2.4 development. I don't intend to backport beyond 2.3 maint. The bugs this fixes have been there since weakrefs were introduced. Index: weakrefobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/weakrefobject.h,v retrieving revision 1.3 retrieving revision 1.3.14.1 diff -C2 -d -r1.3 -r1.3.14.1 *** weakrefobject.h 12 Aug 2002 07:21:58 -0000 1.3 --- weakrefobject.h 20 Nov 2003 22:13:50 -0000 1.3.14.1 *************** *** 40,43 **** --- 40,45 ---- PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head); + PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); + #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object) From tim_one at users.sourceforge.net Thu Nov 20 17:13:52 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 17:13:59 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.28.6.2, 1.28.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv10811/Lib/test Modified Files: Tag: release23-maint test_weakref.py Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix, backported from 2.4 development. I don't intend to backport beyond 2.3 maint. The bugs this fixes have been there since weakrefs were introduced. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.28.6.2 retrieving revision 1.28.6.3 diff -C2 -d -r1.28.6.2 -r1.28.6.3 *** test_weakref.py 13 Nov 2003 22:48:42 -0000 1.28.6.2 --- test_weakref.py 20 Nov 2003 22:13:50 -0000 1.28.6.3 *************** *** 339,342 **** --- 339,547 ---- del c2 + def test_callback_in_cycle_1(self): + import gc + + class J(object): + pass + + class II(object): + def acallback(self, ignore): + self.J + + I = II() + I.J = J + I.wr = weakref.ref(J, I.acallback) + + # Now J and II are each in a self-cycle (as all new-style class + # objects are, since their __mro__ points back to them). I holds + # both a weak reference (I.wr) and a strong reference (I.J) to class + # J. I is also in a cycle (I.wr points to a weakref that references + # I.acallback). When we del these three, they all become trash, but + # the cycles prevent any of them from getting cleaned up immediately. + # Instead they have to wait for cyclic gc to deduce that they're + # trash. + # + # gc used to call tp_clear on all of them, and the order in which + # it does that is pretty accidental. The exact order in which we + # built up these things manages to provoke gc into running tp_clear + # in just the right order (I last). Calling tp_clear on II leaves + # behind an insane class object (its __mro__ becomes NULL). Calling + # tp_clear on J breaks its self-cycle, but J doesn't get deleted + # just then because of the strong reference from I.J. Calling + # tp_clear on I starts to clear I's __dict__, and just happens to + # clear I.J first -- I.wr is still intact. That removes the last + # reference to J, which triggers the weakref callback. The callback + # tries to do "self.J", and instances of new-style classes look up + # attributes ("J") in the class dict first. The class (II) wants to + # search II.__mro__, but that's NULL. The result was a segfault in + # a release build, and an assert failure in a debug build. + del I, J, II + gc.collect() + + def test_callback_in_cycle_2(self): + import gc + + # This is just like test_callback_in_cycle_1, except that II is an + # old-style class. The symptom is different then: an instance of an + # old-style class looks in its own __dict__ first. 'J' happens to + # get cleared from I.__dict__ before 'wr', and 'J' was never in II's + # __dict__, so the attribute isn't found. The difference is that + # the old-style II doesn't have a NULL __mro__ (it doesn't have any + # __mro__), so no segfault occurs. Instead it got: + # test_callback_in_cycle_2 (__main__.ReferencesTestCase) ... + # Exception exceptions.AttributeError: + # "II instance has no attribute 'J'" in > ignored + + class J(object): + pass + + class II: + def acallback(self, ignore): + self.J + + I = II() + I.J = J + I.wr = weakref.ref(J, I.acallback) + + del I, J, II + gc.collect() + + def test_callback_in_cycle_3(self): + import gc + + # This one broke the first patch that fixed the last two. In this + # case, the objects reachable from the callback aren't also reachable + # from the object (c1) *triggering* the callback: you can get to + # c1 from c2, but not vice-versa. The result was that c2's __dict__ + # got tp_clear'ed by the time the c2.cb callback got invoked. + + class C: + def cb(self, ignore): + self.me + self.c1 + self.wr + + c1, c2 = C(), C() + + c2.me = c2 + c2.c1 = c1 + c2.wr = weakref.ref(c1, c2.cb) + + del c1, c2 + gc.collect() + + def test_callback_in_cycle_4(self): + import gc + + # Like test_callback_in_cycle_3, except c2 and c1 have different + # classes. c2's class (C) isn't reachable from c1 then, so protecting + # objects reachable from the dying object (c1) isn't enough to stop + # c2's class (C) from getting tp_clear'ed before c2.cb is invoked. + # The result was a segfault (C.__mro__ was NULL when the callback + # tried to look up self.me). + + class C(object): + def cb(self, ignore): + self.me + self.c1 + self.wr + + class D: + pass + + c1, c2 = D(), C() + + c2.me = c2 + c2.c1 = c1 + c2.wr = weakref.ref(c1, c2.cb) + + del c1, c2, C, D + gc.collect() + + def test_callback_in_cycle_resurrection(self): + import gc + + # Do something nasty in a weakref callback: resurrect objects + # from dead cycles. For this to be attempted, the weakref and + # its callback must also be part of the cyclic trash (else the + # objects reachable via the callback couldn't be in cyclic trash + # to begin with -- the callback would act like an external root). + # But gc clears trash weakrefs with callbacks early now, which + # disables the callbacks, so the callbacks shouldn't get called + # at all (and so nothing actually gets resurrected). + + alist = [] + class C(object): + def __init__(self, value): + self.attribute = value + + def acallback(self, ignore): + alist.append(self.c) + + c1, c2 = C(1), C(2) + c1.c = c2 + c2.c = c1 + c1.wr = weakref.ref(c2, c1.acallback) + c2.wr = weakref.ref(c1, c2.acallback) + + def C_went_away(ignore): + alist.append("C went away") + wr = weakref.ref(C, C_went_away) + + del c1, c2, C # make them all trash + self.assertEqual(alist, []) # del isn't enough to reclaim anything + + gc.collect() + # c1.wr and c2.wr were part of the cyclic trash, so should have + # been cleared without their callbacks executing. OTOH, the weakref + # to C is bound to a function local (wr), and wasn't trash, so that + # callback should have been invoked when C went away. + self.assertEqual(alist, ["C went away"]) + # The remaining weakref should be dead now (its callback ran). + self.assertEqual(wr(), None) + + del alist[:] + gc.collect() + self.assertEqual(alist, []) + + def test_callbacks_on_callback(self): + import gc + + # Set up weakref callbacks *on* weakref callbacks. + alist = [] + def safe_callback(ignore): + alist.append("safe_callback called") + + class C(object): + def cb(self, ignore): + alist.append("cb called") + + c, d = C(), C() + c.other = d + d.other = c + callback = c.cb + c.wr = weakref.ref(d, callback) # this won't trigger + d.wr = weakref.ref(callback, d.cb) # ditto + external_wr = weakref.ref(callback, safe_callback) # but this will + self.assert_(external_wr() is callback) + + # The weakrefs attached to c and d should get cleared, so that + # C.cb is never called. But external_wr isn't part of the cyclic + # trash, and no cyclic trash is reachable from it, so safe_callback + # should get invoked when the bound method object callback (c.cb) + # -- which is itself a callback, and also part of the cyclic trash -- + # gets reclaimed at the end of gc. + + del callback, c, d, C + self.assertEqual(alist, []) # del isn't enough to clean up cycles + gc.collect() + self.assertEqual(alist, ["safe_callback called"]) + self.assertEqual(external_wr(), None) + + del alist[:] + gc.collect() + self.assertEqual(alist, []) + class Object: def __init__(self, arg): From tim_one at users.sourceforge.net Thu Nov 20 17:13:53 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 17:14:05 2003 Subject: [Python-checkins] python/dist/src/Modules gc_weakref.txt, NONE, 2.1.2.1 gcmodule.c, 2.71, 2.71.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv10811/Modules Modified Files: Tag: release23-maint gcmodule.c Added Files: Tag: release23-maint gc_weakref.txt Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix, backported from 2.4 development. I don't intend to backport beyond 2.3 maint. The bugs this fixes have been there since weakrefs were introduced. --- NEW FILE: gc_weakref.txt --- Before 2.3.3, Python's cyclic gc didn't pay any attention to weakrefs. Segfaults in Zope3 resulted. weakrefs in Python are designed to, at worst, let *other* objects learn that a given object has died, via a callback function. The weakly referenced object itself is not passed to the callback, and the presumption is that the weakly referenced object is unreachable trash at the time the callback is invoked. That's usually true, but not always. Suppose a weakly referenced object becomes part of a clump of cyclic trash. When enough cycles are broken by cyclic gc that the object is reclaimed, the callback is invoked. If it's possible for the callback to get at objects in the cycle(s), then it may be possible for those objects to access (via strong references in the cycle) the weakly referenced object being torn down, or other objects in the cycle that have already suffered a tp_clear() call. There's no guarantee that an object is in a sane state after tp_clear(). Bad things (including segfaults) can happen right then, during the callback's execution, or can happen at any later time if the callback manages to resurrect an insane object. Note that if it's possible for the callback to get at objects in the trash cycles, it must also be the case that the callback itself is part of the trash cycles. Else the callback would have acted as an external root to the current collection, and nothing reachable from it would be in cyclic trash either. More, if the callback itself is in cyclic trash, then the weakref to which the callback is attached must also be trash, and for the same kind of reason: if the weakref acted as an external root, then the callback could not have been cyclic trash. So a problem here requires that a weakref, that weakref's callback, and the weakly referenced object, all be in cyclic trash at the same time. This isn't easy to stumble into by accident while Python is running, and, indeed, it took quite a while to dream up failing test cases. Zope3 saw segfaults during shutdown, during the second call of gc in Py_Finalize, after most modules had been torn down. That creates many trash cycles (esp. those involving new-style classes), making the problem much more likely. Once you know what's required to provoke the problem, though, it's easy to create tests that segfault before shutdown. In 2.3.3, before breaking cycles, we first clear all the weakrefs with callbacks in cyclic trash. Since the weakrefs *are* trash, and there's no defined-- or even predictable --order in which tp_clear() gets called on cyclic trash, it's defensible to first clear weakrefs with callbacks. It's a feature of Python's weakrefs too that when a weakref goes away, the callback (if any) associated with it is thrown away too, unexecuted. Just that much is almost enough to prevent problems, by throwing away *almost* all the weakref callbacks that could get triggered by gc. The problem remaining is that clearing a weakref with a callback decrefs the callback object, and the callback object may *itself* be weakly referenced, via another weakref with another callback. So the process of clearing weakrefs can trigger callbacks attached to other weakrefs, and those latter weakrefs may or may not be part of cyclic trash. So, to prevent any Python code from running while gc is invoking tp_clear() on all the objects in cyclic trash, it's not quite enough just to invoke tp_clear() on weakrefs with callbacks first. Instead the weakref module grew a new private function (_PyWeakref_ClearRef) that does only part of tp_clear(): it removes the weakref from the weakly-referenced object's list of weakrefs, but does not decref the callback object. So calling _PyWeakref_ClearRef(wr) ensures that wr's callback object will never trigger, and (unlike weakref's tp_clear()) also prevents any callback associated *with* wr's callback object from triggering. Then we can call tp_clear on all the cyclic objects and never trigger Python code. After we do that, the callback objects still need to be decref'ed. Callbacks (if any) *on* the callback objects that were also part of cyclic trash won't get invoked, because we cleared all trash weakrefs with callbacks at the start. Callbacks on the callback objects that were not part of cyclic trash acted as external roots to everything reachable from them, so nothing reachable from them was part of cyclic trash, so gc didn't do any damage to objects reachable from them, and it's safe to call them at the end of gc. An alternative would have been to treat objects with callbacks like objects with __del__ methods, refusing to collect them, appending them to gc.garbage instead. That would have been much easier. Jim Fulton gave a strong argument against that (on Python-Dev): There's a big difference between __del__ and weakref callbacks. The __del__ method is "internal" to a design. When you design a class with a del method, you know you have to avoid including the class in cycles. Now, suppose you have a design that makes has no __del__ methods but that does use cyclic data structures. You reason about the design, run tests, and convince yourself you don't have a leak. Now, suppose some external code creates a weakref to one of your objects. All of a sudden, you start leaking. You can look at your code all you want and you won't find a reason for the leak. IOW, a class designer can out-think __del__ problems, but has no control over who creates weakrefs to his classes or class instances. The class user has little chance either of predicting when the weakrefs he creates may end up in cycles. Callbacks on weakref callbacks are executed in an arbitrary order, and that's not good (a primary reason not to collect cycles with objects with __del__ methods is to avoid running finalizers in an arbitrary order). However, a weakref callback on a weakref callback has got to be rare. It's possible to do such a thing, so gc has to be robust against it, but I doubt anyone has done it outside the test case I wrote for it. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.71 retrieving revision 2.71.10.1 diff -C2 -d -r2.71 -r2.71.10.1 *** gcmodule.c 17 Apr 2003 17:29:21 -0000 2.71 --- gcmodule.c 20 Nov 2003 22:13:51 -0000 2.71.10.1 *************** *** 378,388 **** } ! /* Move the objects in unreachable with __del__ methods into finalizers. ! * The objects remaining in unreachable do not have __del__ methods, and ! * gc_refs remains GC_TENTATIVELY_UNREACHABLE for them. The objects ! * moved into finalizers have gc_refs changed to GC_REACHABLE. */ static void ! move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) { PyGC_Head *gc = unreachable->gc.gc_next; --- 378,392 ---- } ! /* Move the objects in unreachable with __del__ methods into finalizers, ! * and weakrefs with callbacks into wr_callbacks. ! * The objects remaining in unreachable do not have __del__ methods, and are ! * not weakrefs with callbacks. ! * The objects moved have gc_refs changed to GC_REACHABLE; the objects ! * remaining in unreachable are left at GC_TENTATIVELY_UNREACHABLE. */ static void ! move_troublemakers(PyGC_Head *unreachable, ! PyGC_Head *finalizers, ! PyGC_Head *wr_callbacks) { PyGC_Head *gc = unreachable->gc.gc_next; *************** *** 399,402 **** --- 403,412 ---- gc->gc.gc_refs = GC_REACHABLE; } + else if (PyWeakref_Check(op) && + ((PyWeakReference *)op)->wr_callback) { + gc_list_remove(gc); + gc_list_append(gc, wr_callbacks); + gc->gc.gc_refs = GC_REACHABLE; + } gc = next; } *************** *** 435,438 **** --- 445,535 ---- } + /* Clear all trash weakrefs with callbacks. This clears weakrefs first, + * which has the happy result of disabling the callbacks without executing + * them. A nasty technical complication: a weakref callback can itself be + * the target of a weakref, in which case decrefing the callback can cause + * another callback to trigger. But we can't allow arbitrary Python code to + * get executed at this point (the callback on the callback may try to muck + * with other cyclic trash we're trying to collect, even resurrecting it + * while we're in the middle of doing tp_clear() on the trash). + * + * The private _PyWeakref_ClearRef() function exists so that we can clear + * the reference in a weakref without triggering a callback on the callback. + * + * We have to save the callback objects and decref them later. But we can't + * allocate new memory to save them (if we can't get new memory, we're dead). + * So we grab a new reference on the clear'ed weakref, which prevents the + * rest of gc from reclaiming it. _PyWeakref_ClearRef() leaves the + * weakref's wr_callback member intact. + * + * In the end, then, wr_callbacks consists of cleared weakrefs that are + * immune from collection. Near the end of gc, after collecting all the + * cyclic trash, we call release_weakrefs(). That releases our references + * to the cleared weakrefs, which in turn may trigger callbacks on their + * callbacks. + */ + static void + clear_weakrefs(PyGC_Head *wr_callbacks) + { + PyGC_Head *gc = wr_callbacks->gc.gc_next; + + for (; gc != wr_callbacks; gc = gc->gc.gc_next) { + PyObject *op = FROM_GC(gc); + PyWeakReference *wr; + + assert(IS_REACHABLE(op)); + assert(PyWeakref_Check(op)); + wr = (PyWeakReference *)op; + assert(wr->wr_callback != NULL); + Py_INCREF(op); + _PyWeakref_ClearRef(wr); + } + } + + /* Called near the end of gc. This gives up the references we own to + * cleared weakrefs, allowing them to get collected, and in turn decref'ing + * their callbacks. + * + * If a callback object is itself the target of a weakref callback, + * decref'ing the callback object may trigger that other callback. If + * that other callback was part of the cyclic trash in this generation, + * that won't happen, since we cleared *all* trash-weakref callbacks near + * the start of gc. If that other callback was not part of the cyclic trash + * in this generation, then it acted like an external root to this round + * of gc, so all the objects reachable from that callback are still alive. + * + * Giving up the references to the weakref objects will probably make + * them go away too. However, if a weakref is reachable from finalizers, + * it won't go away. We move it to the old generation then. Since a + * weakref object doesn't have a finalizer, that's the right thing to do (it + * doesn't belong in gc.garbage). + * + * We return the number of weakref objects freed (those not appended to old). + */ + static int + release_weakrefs(PyGC_Head *wr_callbacks, PyGC_Head *old) + { + int num_freed = 0; + + while (! gc_list_is_empty(wr_callbacks)) { + PyGC_Head *gc = wr_callbacks->gc.gc_next; + PyObject *op = FROM_GC(gc); + PyWeakReference *wr = (PyWeakReference *)op; + + assert(IS_REACHABLE(op)); + assert(PyWeakref_Check(op)); + assert(wr->wr_callback != NULL); + Py_DECREF(op); + if (wr_callbacks->gc.gc_next == gc) { + /* object is still alive -- move it */ + gc_list_remove(gc); + gc_list_append(gc, old); + } + else + ++num_freed; + } + return num_freed; + } + static void debug_instance(char *msg, PyInstanceObject *inst) *************** *** 536,541 **** PyGC_Head *young; /* the generation we are examining */ PyGC_Head *old; /* next older generation */ ! PyGC_Head unreachable; ! PyGC_Head finalizers; PyGC_Head *gc; --- 633,639 ---- PyGC_Head *young; /* the generation we are examining */ PyGC_Head *old; /* next older generation */ ! PyGC_Head unreachable; /* non-problematic unreachable trash */ ! PyGC_Head finalizers; /* objects with, & reachable from, __del__ */ ! PyGC_Head wr_callbacks; /* weakrefs with callbacks */ PyGC_Head *gc; *************** *** 598,615 **** * finalizers can't safely be deleted. Python programmers should take * care not to create such things. For Python, finalizers means ! * instance objects with __del__ methods. * ! * Move unreachable objects with finalizers into a different list. */ gc_list_init(&finalizers); ! move_finalizers(&unreachable, &finalizers); /* finalizers contains the unreachable objects with a finalizer; ! * unreachable objects reachable only *from* those are also ! * uncollectable, and we move those into the finalizers list too. */ move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print ! * debugging information. */ for (gc = unreachable.gc.gc_next; gc != &unreachable; gc = gc->gc.gc_next) { --- 696,726 ---- * finalizers can't safely be deleted. Python programmers should take * care not to create such things. For Python, finalizers means ! * instance objects with __del__ methods. Weakrefs with callbacks ! * can call arbitrary Python code, so those are special-cased too. * ! * Move unreachable objects with finalizers, and weakrefs with ! * callbacks, into different lists. */ gc_list_init(&finalizers); ! gc_list_init(&wr_callbacks); ! move_troublemakers(&unreachable, &finalizers, &wr_callbacks); ! /* Clear the trash weakrefs with callbacks. This prevents their ! * callbacks from getting invoked (when a weakref goes away, so does ! * its callback). ! * We do this even if the weakrefs are reachable from finalizers. ! * If we didn't, breaking cycles in unreachable later could trigger ! * deallocation of objects in finalizers, which could in turn ! * cause callbacks to trigger. This may not be ideal behavior. ! */ ! clear_weakrefs(&wr_callbacks); /* finalizers contains the unreachable objects with a finalizer; ! * unreachable objects reachable *from* those are also uncollectable, ! * and we move those into the finalizers list too. */ move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print ! * debugging information. ! */ for (gc = unreachable.gc.gc_next; gc != &unreachable; gc = gc->gc.gc_next) { *************** *** 624,627 **** --- 735,743 ---- */ delete_garbage(&unreachable, old); + + /* Now that we're done analyzing stuff and breaking cycles, let + * delayed weakref callbacks run. + */ + m += release_weakrefs(&wr_callbacks, old); /* Collect statistics on uncollectable objects found and print From tim_one at users.sourceforge.net Thu Nov 20 17:13:53 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 17:14:11 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.75,1.831.4.76 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv10811/Misc Modified Files: Tag: release23-maint NEWS Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix, backported from 2.4 development. I don't intend to backport beyond 2.3 maint. The bugs this fixes have been there since weakrefs were introduced. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.75 retrieving revision 1.831.4.76 diff -C2 -d -r1.831.4.75 -r1.831.4.76 *** NEWS 14 Nov 2003 10:27:26 -0000 1.831.4.75 --- NEWS 20 Nov 2003 22:13:50 -0000 1.831.4.76 *************** *** 13,16 **** --- 13,31 ---- ----------------- + - Critical bugfix, for SF bug 839548: if a weakref with a callback, + its callback, and its weakly referenced object, all became part of + cyclic garbage during a single run of garbage collection, the order + in which they were torn down was unpredictable. It was possible for + the callback to see partially-torn-down objects, leading to immediate + segfaults, or, if the callback resurrected garbage objects, to + resurrect insane objects that caused segfaults (or other surprises) + later. In one sense this wasn't surprising, because Python's cyclic gc + had no knowledge of Python's weakref objects. It does now. When + weakrefs with callbacks become part of cyclic garbage now, those + weakrefs are cleared first. The callbacks don't trigger then, + preventing the problems. If you need callbacks to trigger, then just + as when cyclic gc is not involved, you need to write your code so + that weakref objects outlive the objects they weakly reference. + - Critical bugfix, for SF bug 840829: if cyclic garbage collection happened to occur during a weakref callback for a new-style class From tim_one at users.sourceforge.net Thu Nov 20 17:13:53 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Nov 20 17:14:16 2003 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.13, 1.13.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv10811/Objects Modified Files: Tag: release23-maint weakrefobject.c Log Message: SF bug 839548: Bug in type's GC handling causes segfaults. Also SF patch 843455. This is a critical bugfix, backported from 2.4 development. I don't intend to backport beyond 2.3 maint. The bugs this fixes have been there since weakrefs were introduced. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.13 retrieving revision 1.13.6.1 diff -C2 -d -r1.13 -r1.13.6.1 *** weakrefobject.c 14 Jul 2003 21:46:23 -0000 1.13 --- weakrefobject.c 20 Nov 2003 22:13:51 -0000 1.13.6.1 *************** *** 54,58 **** *list = self->wr_next; self->wr_object = Py_None; - self->wr_callback = NULL; if (self->wr_prev != NULL) self->wr_prev->wr_next = self->wr_next; --- 54,57 ---- *************** *** 61,68 **** self->wr_prev = NULL; self->wr_next = NULL; ! Py_XDECREF(callback); } } static void --- 60,94 ---- self->wr_prev = NULL; self->wr_next = NULL; ! } ! if (callback != NULL) { ! Py_DECREF(callback); ! self->wr_callback = NULL; } } + /* Cyclic gc uses this to *just* clear the passed-in reference, leaving + * the callback intact and uncalled. It must be possible to call self's + * tp_dealloc() after calling this, so self has to be left in a sane enough + * state for that to work. We expect tp_dealloc to decref the callback + * then. The reason for not letting clear_weakref() decref the callback + * right now is that if the callback goes away, that may in turn trigger + * another callback (if a weak reference to the callback exists) -- running + * arbitrary Python code in the middle of gc is a disaster. The convolution + * here allows gc to delay triggering such callbacks until the world is in + * a sane state again. + */ + void + _PyWeakref_ClearRef(PyWeakReference *self) + { + PyObject *callback; + + assert(self != NULL); + assert(PyWeakref_Check(self)); + /* Preserve and restore the callback around clear_weakref. */ + callback = self->wr_callback; + self->wr_callback = NULL; + clear_weakref(self); + self->wr_callback = callback; + } static void *************** *** 118,122 **** return self->hash; } ! static PyObject * --- 144,148 ---- return self->hash; } ! static PyObject * *************** *** 325,329 **** WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) ! static int proxy_nonzero(PyWeakReference *proxy) { --- 351,355 ---- WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) ! static int proxy_nonzero(PyWeakReference *proxy) { From akuchling at users.sourceforge.net Thu Nov 20 17:22:22 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Nov 20 17:22:27 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv13039 Modified Files: whatsnew24.tex Log Message: Add two items Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** whatsnew24.tex 13 Nov 2003 21:33:26 -0000 1.11 --- whatsnew24.tex 20 Nov 2003 22:22:19 -0000 1.12 *************** *** 211,214 **** --- 211,221 ---- high volumes of data. + \item The \module{imaplib} module now supports IMAP's THREAD command. + (Contributed by Yves Dionne.) + + \item A new \function{getsid()} function was added to the + \module{posix} module that underlies the \module{os} module. + (Contributed by J. Raynor.) + \item The \module{random} module has a new method called \method{getrandbits(N)} which returns an N-bit long integer. This method supports the existing From rhettinger at users.sourceforge.net Thu Nov 20 17:54:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Nov 20 17:54:40 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv21626 Modified Files: setobject.c Log Message: Three minor performance improvements: * Improve the hash function to increase the chance that distinct sets will have distinct xor'd hash totals. * Use PyDict_Merge where possible (it is faster than an equivalent iter/set pair). * Don't rebuild dictionaries where the input already has one. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** setobject.c 18 Nov 2003 19:27:19 -0000 1.5 --- setobject.c 20 Nov 2003 22:54:33 -0000 1.6 *************** *** 139,142 **** --- 139,151 ---- if (result == NULL) return NULL; + + if (PyAnySet_Check(other)) { + if (PyDict_Merge(result->data, ((PySetObject *)other)->data, 0) == -1) { + Py_DECREF(result); + return NULL; + } + return (PyObject *)result; + } + it = PyObject_GetIter(other); if (it == NULL) { *************** *** 172,175 **** --- 181,191 ---- PyObject *item, *data, *it; + if (PyAnySet_Check(other)) { + if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 0) == -1) + return NULL; + Py_INCREF(so); + return (PyObject *)so; + } + it = PyObject_GetIter(other); if (it == NULL) *************** *** 435,439 **** set_symmetric_difference(PySetObject *so, PyObject *other) { ! PySetObject *result, *otherset; PyObject *item, *selfdata, *otherdata, *tgtdata, *it; --- 451,455 ---- set_symmetric_difference(PySetObject *so, PyObject *other) { ! PySetObject *result, *otherset=NULL; PyObject *item, *selfdata, *otherdata, *tgtdata, *it; *************** *** 445,458 **** tgtdata = result->data; ! otherset = (PySetObject *)make_new_set(so->ob_type, other); ! if (otherset == NULL) { ! Py_DECREF(result); ! return NULL; ! } ! otherdata = otherset->data; it = PyObject_GetIter(otherdata); if (it == NULL) { ! Py_DECREF(otherset); Py_DECREF(result); return NULL; --- 461,480 ---- tgtdata = result->data; ! if (PyDict_Check(other)) ! otherdata = other; ! else if (PyAnySet_Check(other)) ! otherdata = ((PySetObject *)other)->data; ! else { ! otherset = (PySetObject *)make_new_set(so->ob_type, other); ! if (otherset == NULL) { ! Py_DECREF(result); ! return NULL; ! } ! otherdata = otherset->data; ! } it = PyObject_GetIter(otherdata); if (it == NULL) { ! Py_XDECREF(otherset); Py_DECREF(result); return NULL; *************** *** 464,468 **** if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); ! Py_DECREF(otherset); Py_DECREF(result); Py_DECREF(item); --- 486,490 ---- if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); ! Py_XDECREF(otherset); Py_DECREF(result); Py_DECREF(item); *************** *** 473,477 **** } Py_DECREF(it); ! Py_DECREF(otherset); if (PyErr_Occurred()) { Py_DECREF(result); --- 495,499 ---- } Py_DECREF(it); ! Py_XDECREF(otherset); if (PyErr_Occurred()) { Py_DECREF(result); *************** *** 628,632 **** PyObject *it, *item; PySetObject *so = (PySetObject *)self; ! long hash = 0; if (so->hash != -1) --- 650,654 ---- PyObject *it, *item; PySetObject *so = (PySetObject *)self; ! long hash = 0, x; if (so->hash != -1) *************** *** 638,642 **** while ((item = PyIter_Next(it)) != NULL) { ! hash ^= PyObject_Hash(item); Py_DECREF(item); } --- 660,671 ---- while ((item = PyIter_Next(it)) != NULL) { ! x = PyObject_Hash(item); ! /* Applying x*(x+1) breaks-up linear relationships so that ! h(1) ^ h(2) will be less likely to coincide with hash(3). ! Multiplying by a large prime increases the dispersion ! between consecutive hashes. Adding one bit from the ! original restores the one bit lost during the multiply ! (all the products are even numbers). */ ! hash ^= (x * (x+1) * 3644798167) | (x&1); Py_DECREF(item); } From rhettinger at users.sourceforge.net Fri Nov 21 02:56:38 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 02:56:42 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv3975/Lib/test Modified Files: test_set.py Log Message: issubset() and issuperset() to work with general iterables Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_set.py 17 Nov 2003 16:42:33 -0000 1.2 --- test_set.py 21 Nov 2003 07:56:36 -0000 1.3 *************** *** 144,147 **** --- 144,151 ---- self.failIf(q > r) self.failIf(q >= r) + self.assert_(set('a').issubset('abc')) + self.assert_(set('abc').issuperset('a')) + self.failIf(set('a').issubset('cbs')) + self.failIf(set('cbs').issuperset('a')) def test_pickling(self): From rhettinger at users.sourceforge.net Fri Nov 21 02:56:38 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 02:56:52 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv3975/Objects Modified Files: setobject.c Log Message: issubset() and issuperset() to work with general iterables Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** setobject.c 20 Nov 2003 22:54:33 -0000 1.6 --- setobject.c 21 Nov 2003 07:56:36 -0000 1.7 *************** *** 589,597 **** set_issubset(PySetObject *so, PyObject *other) { ! PyObject *otherdata, *it, *item; if (!PyAnySet_Check(other)) { ! PyErr_SetString(PyExc_TypeError, "can only compare to a set"); ! return NULL; } if (set_len(so) > set_len((PySetObject *)other)) --- 589,601 ---- set_issubset(PySetObject *so, PyObject *other) { ! PyObject *otherdata, *it, *item, *tmp, *result; if (!PyAnySet_Check(other)) { ! tmp = make_new_set(&PySet_Type, other); ! if (tmp == NULL) ! return NULL; ! result = set_issubset(so, tmp); ! Py_DECREF(tmp); ! return result; } if (set_len(so) > set_len((PySetObject *)other)) *************** *** 622,628 **** set_issuperset(PySetObject *so, PyObject *other) { if (!PyAnySet_Check(other)) { ! PyErr_SetString(PyExc_TypeError, "can only compare to a set"); ! return NULL; } return set_issubset((PySetObject *)other, (PyObject *)so); --- 626,638 ---- set_issuperset(PySetObject *so, PyObject *other) { + PyObject *tmp, *result; + if (!PyAnySet_Check(other)) { ! tmp = make_new_set(&PySet_Type, other); ! if (tmp == NULL) ! return NULL; ! result = set_issuperset(so, tmp); ! Py_DECREF(tmp); ! return result; } return set_issubset((PySetObject *)other, (PyObject *)so); From rhettinger at users.sourceforge.net Fri Nov 21 13:36:56 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 13:37:01 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv20320/Objects Modified Files: setobject.c Log Message: Allow temporary hashability for the __contains__ test. (Requested by Alex Martelli.) Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** setobject.c 21 Nov 2003 07:56:36 -0000 1.7 --- setobject.c 21 Nov 2003 18:36:53 -0000 1.8 *************** *** 105,109 **** set_contains(PySetObject *so, PyObject *key) { ! return PySequence_Contains(so->data, key); } --- 105,125 ---- set_contains(PySetObject *so, PyObject *key) { ! PyObject *olddict; ! PySetObject *tmp; ! int result; ! ! result = PySequence_Contains(so->data, key); ! if (result == -1 && PyType_IsSubtype(key->ob_type, &PySet_Type)) { ! PyErr_Clear(); ! tmp = (PySetObject *)make_new_set(&PyFrozenSet_Type, NULL); ! if (tmp == NULL) ! return -1; ! olddict = tmp->data; ! tmp->data = ((PySetObject *)(key))->data; ! result = PySequence_Contains(so->data, (PyObject *)tmp); ! tmp->data = olddict; ! Py_DECREF(tmp); ! } ! return result; } From rhettinger at users.sourceforge.net Fri Nov 21 13:36:57 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 13:37:09 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv20320/Lib/test Modified Files: test_set.py Log Message: Allow temporary hashability for the __contains__ test. (Requested by Alex Martelli.) Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_set.py 21 Nov 2003 07:56:36 -0000 1.3 --- test_set.py 21 Nov 2003 18:36:54 -0000 1.4 *************** *** 36,39 **** --- 36,41 ---- self.assertEqual(c in self.s, c in self.d) self.assertRaises(TypeError, self.s.__contains__, [[]]) + s = self.thetype([frozenset(self.letters)]) + self.assert_(self.thetype(self.letters) in s) def test_copy(self): From bwarsaw at users.sourceforge.net Fri Nov 21 15:27:02 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri Nov 21 15:27:05 2003 Subject: [Python-checkins] python/dist/src/Doc/lib email-dir.py, 1.1, 1.1.20.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv5685 Modified Files: Tag: release23-maint email-dir.py Log Message: Add a missing import. Closes SF # 816344. Will forward port. Index: email-dir.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/email-dir.py,v retrieving revision 1.1 retrieving revision 1.1.20.1 diff -C2 -d -r1.1 -r1.1.20.1 *** email-dir.py 1 Oct 2002 14:17:06 -0000 1.1 --- email-dir.py 21 Nov 2003 20:26:59 -0000 1.1.20.1 *************** *** 34,37 **** --- 34,38 ---- from email.Message import Message from email.MIMEAudio import MIMEAudio + from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email.MIMEImage import MIMEImage From bwarsaw at users.sourceforge.net Fri Nov 21 15:28:17 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri Nov 21 15:28:21 2003 Subject: [Python-checkins] python/dist/src/Doc/lib email-dir.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv5861 Modified Files: email-dir.py Log Message: Add a missing import. Closes SF # 816344. Index: email-dir.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/email-dir.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** email-dir.py 1 Oct 2002 14:17:06 -0000 1.1 --- email-dir.py 21 Nov 2003 20:28:15 -0000 1.2 *************** *** 34,37 **** --- 34,38 ---- from email.Message import Message from email.MIMEAudio import MIMEAudio + from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email.MIMEImage import MIMEImage From tim_one at users.sourceforge.net Fri Nov 21 17:21:00 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Nov 21 17:21:08 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libweakref.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv28967/Doc/lib Modified Files: libweakref.tex Log Message: More words: gave more motivation, and added cautions about the special dangers of trying to iterate over weak dicts. Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** libweakref.tex 2 Jul 2003 15:10:38 -0000 1.19 --- libweakref.tex 21 Nov 2003 22:20:57 -0000 1.20 *************** *** 15,22 **** \dfn{weak references} to objects. ! In the discussion which follows, the term \dfn{referent} means the object which is referred to by a weak reference. ! XXX --- need to say more here! Not all objects can be weakly referenced; those objects which can --- 15,49 ---- \dfn{weak references} to objects. ! In the following, the term \dfn{referent} means the object which is referred to by a weak reference. ! A weak reference to an object is not enough to keep the object alive: ! when the only remaining references to a referent are weak references, ! garbage collection is free to destroy the referent and reuse its memory ! for something else. A primary use for weak references is to implement ! caches or mappings holding large objects, where it's desired that a ! large object not be kept alive solely because it appears in a cache or ! mapping. For example, if you have a number of large binary image objects, ! you may wish to associate a name with each. If you used a Python ! dictionary to map names to images, or images to names, the image objects ! would remain alive just because they appeared as values or keys in the ! dictionaries. The \class{WeakKeyDictionary} and ! \class{WeakValueDictionary} classes supplied by the \module{weakref} ! module are an alternative, using weak references to construct mappings ! that don't keep objects alive solely because they appear in the mapping ! objects. If, for example, an image object is a value in a ! \class{WeakValueDictionary}, then when the last remaining ! references to that image object are the weak references held by weak ! mappings, garbage collection can reclaim the object, and its corresponding ! entries in weak mappings are simply deleted. ! ! \class{WeakKeyDictionary} and \class{WeakValueDictionary} use weak ! references in their implementation, setting up callback functions on ! the weak references that notify the weak dictionaries when a key or value ! has been reclaimed by garbage collection. Most programs should find that ! using one of these weak dictionary types is all they need -- it's ! not usually necessary to create your own weak references directly. The ! low-level machinery used by the weak dictionary implementations is exposed ! by the \module{weakref} module for the benefit of advanced uses. Not all objects can be weakly referenced; those objects which can *************** *** 45,49 **** the same way as exceptions raised from an object's \method{__del__()} method. ! Weak references are hashable if the \var{object} is hashable. They will maintain their hash value even after the \var{object} was --- 72,76 ---- the same way as exceptions raised from an object's \method{__del__()} method. ! Weak references are hashable if the \var{object} is hashable. They will maintain their hash value even after the \var{object} was *************** *** 51,55 **** the \var{object} was deleted, the call will raise \exception{TypeError}. ! Weak references support tests for equality, but not ordering. If the referents are still alive, two references have the same --- 78,82 ---- the \var{object} was deleted, the call will raise \exception{TypeError}. ! Weak references support tests for equality, but not ordering. If the referents are still alive, two references have the same *************** *** 90,93 **** --- 117,127 ---- attributes to those objects. This can be especially useful with objects that override attribute accesses. + + \note{Caution: Because a \class{WeakKeyDictionary} is built on top + of a Python dictionary, it must not change size when iterating + over it. This can be difficult to ensure for a + \class{WeakKeyDictionary} because actions performed by the + program during iteration may cause items in the dictionary + to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} *************** *** 96,99 **** --- 130,140 ---- dictionary will be discarded when no strong reference to the value exists any more. + + \note{Caution: Because a \class{WeakValueDictionary} is built on top + of a Python dictionary, it must not change size when iterating + over it. This can be difficult to ensure for a + \class{WeakValueDictionary} because actions performed by the + program during iteration may cause items in the dictionary + to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} *************** *** 254,265 **** \begin{verbatim} ! static PyObject * ! instance_new() { ! /* Other initialization stuff omitted for brevity */ ! self->in_weakreflist = NULL; ! return (PyObject *) self; ! } \end{verbatim} --- 295,306 ---- \begin{verbatim} ! static PyObject * ! instance_new() { ! /* Other initialization stuff omitted for brevity */ ! self->in_weakreflist = NULL; ! return (PyObject *) self; ! } \end{verbatim} From tim_one at users.sourceforge.net Fri Nov 21 17:21:21 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Nov 21 17:21:25 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libweakref.tex, 1.19.8.1, 1.19.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv29116/Doc/lib Modified Files: Tag: release23-maint libweakref.tex Log Message: More words: gave more motivation, and added cautions about the special dangers of trying to iterate over weak dicts. Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.19.8.1 retrieving revision 1.19.8.2 diff -C2 -d -r1.19.8.1 -r1.19.8.2 *** libweakref.tex 7 Sep 2003 23:38:08 -0000 1.19.8.1 --- libweakref.tex 21 Nov 2003 22:21:19 -0000 1.19.8.2 *************** *** 15,22 **** \dfn{weak references} to objects. ! In the discussion which follows, the term \dfn{referent} means the object which is referred to by a weak reference. ! XXX --- need to say more here! Not all objects can be weakly referenced; those objects which can --- 15,49 ---- \dfn{weak references} to objects. ! In the following, the term \dfn{referent} means the object which is referred to by a weak reference. ! A weak reference to an object is not enough to keep the object alive: ! when the only remaining references to a referent are weak references, ! garbage collection is free to destroy the referent and reuse its memory ! for something else. A primary use for weak references is to implement ! caches or mappings holding large objects, where it's desired that a ! large object not be kept alive solely because it appears in a cache or ! mapping. For example, if you have a number of large binary image objects, ! you may wish to associate a name with each. If you used a Python ! dictionary to map names to images, or images to names, the image objects ! would remain alive just because they appeared as values or keys in the ! dictionaries. The \class{WeakKeyDictionary} and ! \class{WeakValueDictionary} classes supplied by the \module{weakref} ! module are an alternative, using weak references to construct mappings ! that don't keep objects alive solely because they appear in the mapping ! objects. If, for example, an image object is a value in a ! \class{WeakValueDictionary}, then when the last remaining ! references to that image object are the weak references held by weak ! mappings, garbage collection can reclaim the object, and its corresponding ! entries in weak mappings are simply deleted. ! ! \class{WeakKeyDictionary} and \class{WeakValueDictionary} use weak ! references in their implementation, setting up callback functions on ! the weak references that notify the weak dictionaries when a key or value ! has been reclaimed by garbage collection. Most programs should find that ! using one of these weak dictionary types is all they need -- it's ! not usually necessary to create your own weak references directly. The ! low-level machinery used by the weak dictionary implementations is exposed ! by the \module{weakref} module for the benefit of advanced uses. Not all objects can be weakly referenced; those objects which can *************** *** 45,49 **** the same way as exceptions raised from an object's \method{__del__()} method. ! Weak references are hashable if the \var{object} is hashable. They will maintain their hash value even after the \var{object} was --- 72,76 ---- the same way as exceptions raised from an object's \method{__del__()} method. ! Weak references are hashable if the \var{object} is hashable. They will maintain their hash value even after the \var{object} was *************** *** 51,55 **** the \var{object} was deleted, the call will raise \exception{TypeError}. ! Weak references support tests for equality, but not ordering. If the referents are still alive, two references have the same --- 78,82 ---- the \var{object} was deleted, the call will raise \exception{TypeError}. ! Weak references support tests for equality, but not ordering. If the referents are still alive, two references have the same *************** *** 90,93 **** --- 117,127 ---- attributes to those objects. This can be especially useful with objects that override attribute accesses. + + \note{Caution: Because a \class{WeakKeyDictionary} is built on top + of a Python dictionary, it must not change size when iterating + over it. This can be difficult to ensure for a + \class{WeakKeyDictionary} because actions performed by the + program during iteration may cause items in the dictionary + to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} *************** *** 96,99 **** --- 130,140 ---- dictionary will be discarded when no strong reference to the value exists any more. + + \note{Caution: Because a \class{WeakValueDictionary} is built on top + of a Python dictionary, it must not change size when iterating + over it. This can be difficult to ensure for a + \class{WeakValueDictionary} because actions performed by the + program during iteration may cause items in the dictionary + to vanish "by magic" (as a side effect of garbage collection).} \end{classdesc} *************** *** 254,265 **** \begin{verbatim} ! static PyObject * ! instance_new() { ! /* Other initialization stuff omitted for brevity */ ! self->in_weakreflist = NULL; ! return (PyObject *) self; ! } \end{verbatim} --- 295,306 ---- \begin{verbatim} ! static PyObject * ! instance_new() { ! /* Other initialization stuff omitted for brevity */ ! self->in_weakreflist = NULL; ! return (PyObject *) self; ! } \end{verbatim} From tim_one at users.sourceforge.net Fri Nov 21 22:25:42 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Nov 21 22:25:47 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_re.py, 1.45.6.1, 1.45.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv11483/Lib/test Modified Files: Tag: release23-maint test_re.py Log Message: Reverted from rev 1.45.6.1 to rev 1.45: deep recursion is still part of sre in 2.3, and the backport of the 2.4 version of the tests should not have been done. It got confused because someone else checked a bad change into _sre.c that caused the tests that are *supposed* to raise a recursion exception to stop doing so on some (most?) platforms. test_re passes again on Windows now. Until the bad change to _sre gets fixed, it will fail on platforms other than Windows and FreeBSD, either by "Test Failed", or by bad consequences of C stack overflow. Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.45.6.1 retrieving revision 1.45.6.2 diff -C2 -d -r1.45.6.1 -r1.45.6.2 *** test_re.py 4 Nov 2003 14:11:01 -0000 1.45.6.1 --- test_re.py 22 Nov 2003 03:25:40 -0000 1.45.6.2 *************** *** 170,174 **** def test_re_groupref_exists(self): ! return # not yet self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(), ('(', 'a')) --- 170,174 ---- def test_re_groupref_exists(self): ! return # not yet self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(), ('(', 'a')) *************** *** 406,413 **** 20003) self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001) ! # non-simple '*?' still used to hit the recursion limit, before the ! # non-recursive scheme was implemented. ! self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001) ! def test_bug_612074(self): --- 406,411 ---- 20003) self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001) ! # non-simple '*?' still recurses and hits the recursion limit ! self.assertRaises(RuntimeError, re.search, '(a|b)*?c', 10000*'ab'+'cd') def test_bug_612074(self): *************** *** 416,424 **** def test_stack_overflow(self): ! # nasty cases that used to overflow the straightforward recursive # implementation of repeated groups. ! self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x') ! self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x') ! self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x') def test_scanner(self): --- 414,422 ---- def test_stack_overflow(self): ! # nasty case that overflows the straightforward recursive # implementation of repeated groups. ! self.assertRaises(RuntimeError, re.match, '(x)*', 50000*'x') ! self.assertRaises(RuntimeError, re.match, '(x)*y', 50000*'x'+'y') ! self.assertRaises(RuntimeError, re.match, '(x)*?y', 50000*'x'+'y') def test_scanner(self): From tim_one at users.sourceforge.net Fri Nov 21 22:46:32 2003 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Nov 21 22:46:36 2003 Subject: [Python-checkins] python/dist/src/Modules _sre.c,2.99.8.1,2.99.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv14020/Modules Modified Files: Tag: release23-maint _sre.c Log Message: Indented and repaired the maze of #ifdefs setting USE_RECURSION_LIMIT. Indented because it was incomprehensible. "Repaired" means someone checked in a change that screwed up the multiple nesting levels, causing USE_RECURSION_LIMIT to stop getting defined on all non-LP64 boxes other than FreeBSD. Tried to repair that in a more-robust way. That error in turn caused a bogus change to get checked in to test_re.py, which I repaired earlier. This needs fresh testing on all non-Win32 platforms (Win32 never used USE_RECURSION_LIMIT, and still doesn't). Running the standard test_re.py is an adequate test. Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.99.8.1 retrieving revision 2.99.8.2 diff -C2 -d -r2.99.8.1 -r2.99.8.2 *** _sre.c 20 Oct 2003 20:59:45 -0000 2.99.8.1 --- _sre.c 22 Nov 2003 03:46:30 -0000 2.99.8.2 *************** *** 66,99 **** /* prevent run-away recursion (bad patterns on long strings) */ ! #if !defined(USE_STACKCHECK) ! #if defined(MS_WIN64) || defined(__LP64__) || defined(_LP64) ! /* require smaller recursion limit for a number of 64-bit platforms: ! Win64 (MS_WIN64), Linux64 (__LP64__), Monterey (64-bit AIX) (_LP64) */ ! /* FIXME: maybe the limit should be 40000 / sizeof(void*) ? */ ! #define USE_RECURSION_LIMIT 7500 ! #elif defined(__FreeBSD__) ! /* FreeBSD/amd64 and /sparc64 require even smaller limits */ ! #if defined(__amd64__) ! #define USE_RECURSION_LIMIT 6000 ! #elif defined(__sparc64__) ! #define USE_RECURSION_LIMIT 3000 ! #elif defined(__GNUC__) && defined(WITH_THREAD) ! /* the pthreads library on FreeBSD has a fixed 1MB stack size for the ! * initial (or "primary") thread, which is insufficient for the default ! * recursion limit. gcc 3.x at the default optimisation ! * level (-O3) uses stack space more aggressively than gcc 2.95. ! */ ! #if (__GNUC__ > 2) ! #define USE_RECURSION_LIMIT 6500 ! #else ! #define USE_RECURSION_LIMIT 7500 ! #endif ! #else ! #define USE_RECURSION_LIMIT 10000 ! #endif ! #endif ! #endif /* enables fast searching */ --- 66,102 ---- /* prevent run-away recursion (bad patterns on long strings) */ ! #ifndef USE_STACKCHECK ! #if defined(MS_WIN64) || defined(__LP64__) || defined(_LP64) ! /* require smaller recursion limit for a number of 64-bit platforms: ! * Win64 (MS_WIN64), Linux64 (__LP64__), Monterey (64-bit AIX) (_LP64) ! */ ! /* FIXME: maybe the limit should be 40000 / sizeof(void*) ? */ ! #define USE_RECURSION_LIMIT 7500 ! #elif defined(__FreeBSD__) ! /* FreeBSD/amd64 and /sparc64 require even smaller limits */ ! #if defined(__amd64__) ! #define USE_RECURSION_LIMIT 6000 ! #elif defined(__sparc64__) ! #define USE_RECURSION_LIMIT 3000 ! #elif defined(__GNUC__) && defined(WITH_THREAD) ! /* the pthreads library on FreeBSD has a fixed 1MB stack size for ! * the initial (or "primary") thread, which is insufficient for ! * the default recursion limit. gcc 3.x at the default ! * optimisation level (-O3) uses stack space more aggressively ! * than gcc 2.95. ! */ ! #if (__GNUC__ > 2) ! #define USE_RECURSION_LIMIT 6500 ! #else ! #define USE_RECURSION_LIMIT 7500 ! #endif ! #endif ! #endif /* special cases for USE_RECURSION_LIMIT */ ! #ifndef USE_RECURSION_LIMIT /* default if not overriden above */ ! #define USE_RECURSION_LIMIT 10000 ! #endif ! #endif /* !USE_STACKCHECK */ /* enables fast searching */ *************** *** 210,214 **** } ! #endif LOCAL(int) --- 213,217 ---- } ! #endif /* HAVE_UNICODE */ LOCAL(int) *************** *** 526,530 **** return ok; set += 16; ! } else { /* (32 bits per code word) */ --- 529,533 ---- return ok; set += 16; ! } else { /* (32 bits per code word) */ *************** *** 554,558 **** block = -1; set += 64; ! if (block >=0 && (set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31)))) return ok; --- 557,561 ---- block = -1; set += 64; ! if (block >=0 && (set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31)))) return ok; *************** *** 637,641 **** ptr++; break; ! case SRE_OP_NOT_LITERAL_IGNORE: /* repeated non-literal */ --- 640,644 ---- ptr++; break; ! case SRE_OP_NOT_LITERAL_IGNORE: /* repeated non-literal */ *************** *** 720,724 **** * outside 'for' loop: must be protected when breaking, since the next * OP could potentially depend on lastmark; ! * * - Recursive SRE_MATCH() returned false, and will be called again * inside a local for/while loop: must be protected between each --- 723,727 ---- * outside 'for' loop: must be protected when breaking, since the next * OP could potentially depend on lastmark; ! * * - Recursive SRE_MATCH() returned false, and will be called again * inside a local for/while loop: must be protected between each *************** *** 1108,1112 **** return count; /* exception */ if (count < (int) pattern[1]) ! return 0; /* did not match minimum number of times */ ptr += count; /* advance past minimum matches of repeat */ } --- 1111,1115 ---- return count; /* exception */ if (count < (int) pattern[1]) ! return 0; /* did not match minimum number of times */ ptr += count; /* advance past minimum matches of repeat */ } *************** *** 1358,1362 **** break; } ! } ptr++; --- 1361,1365 ---- break; } ! } ptr++; *************** *** 1413,1417 **** return status; } ! LOCAL(int) SRE_LITERAL_TEMPLATE(SRE_CHAR* ptr, int len) --- 1416,1420 ---- return status; } ! LOCAL(int) SRE_LITERAL_TEMPLATE(SRE_CHAR* ptr, int len) *************** *** 1535,1539 **** characters), and a character size. return NULL if the object is not a string (or not compatible) */ ! PyBufferProcs *buffer; int size, bytes, charsize; --- 1538,1542 ---- characters), and a character size. return NULL if the object is not a string (or not compatible) */ ! PyBufferProcs *buffer; int size, bytes, charsize; *************** *** 2011,2015 **** PyObject* item; ! state_reset(&state); --- 2014,2018 ---- PyObject* item; ! state_reset(&state); *************** *** 2030,2034 **** goto error; } ! /* don't bother to build a match object */ switch (self->groups) { --- 2033,2037 ---- goto error; } ! /* don't bother to build a match object */ switch (self->groups) { *************** *** 2079,2083 **** state_fini(&state); return NULL; ! } --- 2082,2086 ---- state_fini(&state); return NULL; ! } *************** *** 2157,2161 **** goto error; } ! if (state.start == state.ptr) { if (last == state.end) --- 2160,2164 ---- goto error; } ! if (state.start == state.ptr) { if (last == state.end) *************** *** 2213,2217 **** state_fini(&state); return NULL; ! } --- 2216,2220 ---- state_fini(&state); return NULL; ! } *************** *** 2304,2308 **** goto error; } ! b = STATE_OFFSET(&state, state.start); e = STATE_OFFSET(&state, state.ptr); --- 2307,2311 ---- goto error; } ! b = STATE_OFFSET(&state, state.start); e = STATE_OFFSET(&state, state.ptr); *************** *** 2350,2354 **** goto error; } ! i = e; n = n + 1; --- 2353,2357 ---- goto error; } ! i = e; n = n + 1; *************** *** 2394,2398 **** Py_DECREF(filter); return NULL; ! } --- 2397,2401 ---- Py_DECREF(filter); return NULL; ! } *************** *** 2434,2438 **** if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) return NULL; ! copy = PyObject_NEW_VAR(PatternObject, &Pattern_Type, self->codesize); if (!copy) --- 2437,2441 ---- if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) return NULL; ! copy = PyObject_NEW_VAR(PatternObject, &Pattern_Type, self->codesize); if (!copy) *************** *** 2460,2464 **** #ifdef USE_BUILTIN_COPY PatternObject* copy; ! PyObject* memo; if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) --- 2463,2467 ---- #ifdef USE_BUILTIN_COPY PatternObject* copy; ! PyObject* memo; if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) *************** *** 2498,2502 **** }; ! static PyObject* pattern_getattr(PatternObject* self, char* name) { --- 2501,2505 ---- }; ! static PyObject* pattern_getattr(PatternObject* self, char* name) { *************** *** 2859,2863 **** MatchObject* copy; int slots, offset; ! if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) return NULL; --- 2862,2866 ---- MatchObject* copy; int slots, offset; ! if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) return NULL; *************** *** 2892,2896 **** #ifdef USE_BUILTIN_COPY MatchObject* copy; ! PyObject* memo; if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) --- 2895,2899 ---- #ifdef USE_BUILTIN_COPY MatchObject* copy; ! PyObject* memo; if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) *************** *** 2927,2931 **** }; ! static PyObject* match_getattr(MatchObject* self, char* name) { --- 2930,2934 ---- }; ! static PyObject* match_getattr(MatchObject* self, char* name) { *************** *** 3085,3089 **** }; ! static PyObject* scanner_getattr(ScannerObject* self, char* name) { --- 3088,3092 ---- }; ! static PyObject* scanner_getattr(ScannerObject* self, char* name) { *************** *** 3122,3126 **** }; ! #if PY_VERSION_HEX < 0x02030000 DL_EXPORT(void) init_sre(void) #else --- 3125,3129 ---- }; ! #if PY_VERSION_HEX < 0x02030000 DL_EXPORT(void) init_sre(void) #else From rhettinger at users.sourceforge.net Fri Nov 21 22:55:26 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 22:55:29 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv15693/Lib/test Modified Files: test_set.py Log Message: Extend temporary hashability to remove() and discard(). Brings the functionality back in line with sets.py. Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_set.py 21 Nov 2003 18:36:54 -0000 1.4 --- test_set.py 22 Nov 2003 03:55:23 -0000 1.5 *************** *** 183,186 **** --- 183,191 ---- self.assertRaises(KeyError, self.s.remove, 'Q') self.assertRaises(TypeError, self.s.remove, []) + s = self.thetype([frozenset(self.word)]) + self.assert_(self.thetype(self.word) in s) + s.remove(self.thetype(self.word)) + self.assert_(self.thetype(self.word) not in s) + self.assertRaises(KeyError, self.s.remove, self.thetype(self.word)) def test_discard(self): *************** *** 189,192 **** --- 194,202 ---- self.s.discard('Q') self.assertRaises(TypeError, self.s.discard, []) + s = self.thetype([frozenset(self.word)]) + self.assert_(self.thetype(self.word) in s) + s.discard(self.thetype(self.word)) + self.assert_(self.thetype(self.word) not in s) + s.discard(self.thetype(self.word)) def test_pop(self): From rhettinger at users.sourceforge.net Fri Nov 21 22:55:25 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 21 22:55:33 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv15693/Objects Modified Files: setobject.c Log Message: Extend temporary hashability to remove() and discard(). Brings the functionality back in line with sets.py. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** setobject.c 21 Nov 2003 18:36:53 -0000 1.8 --- setobject.c 22 Nov 2003 03:55:23 -0000 1.9 *************** *** 74,77 **** --- 74,92 ---- } + static PyObject * + frozenset_dict_wrapper(PyObject *d) + { + PySetObject *w; + + assert(PyDict_Check(d)); + w = (PySetObject *)make_new_set(&PyFrozenSet_Type, NULL); + if (w == NULL) + return NULL; + Py_DECREF(w->data); + Py_INCREF(d); + w->data = d; + return (PyObject *)w; + } + static void set_dealloc(PySetObject *so) *************** *** 105,110 **** set_contains(PySetObject *so, PyObject *key) { ! PyObject *olddict; ! PySetObject *tmp; int result; --- 120,124 ---- set_contains(PySetObject *so, PyObject *key) { ! PyObject *tmp; int result; *************** *** 112,122 **** if (result == -1 && PyType_IsSubtype(key->ob_type, &PySet_Type)) { PyErr_Clear(); ! tmp = (PySetObject *)make_new_set(&PyFrozenSet_Type, NULL); if (tmp == NULL) return -1; ! olddict = tmp->data; ! tmp->data = ((PySetObject *)(key))->data; ! result = PySequence_Contains(so->data, (PyObject *)tmp); ! tmp->data = olddict; Py_DECREF(tmp); } --- 126,133 ---- if (result == -1 && PyType_IsSubtype(key->ob_type, &PySet_Type)) { PyErr_Clear(); ! tmp = frozenset_dict_wrapper(((PySetObject *)(key))->data); if (tmp == NULL) return -1; ! result = PySequence_Contains(so->data, tmp); Py_DECREF(tmp); } *************** *** 821,826 **** set_remove(PySetObject *so, PyObject *item) { ! if (PyDict_DelItem(so->data, item) == -1) ! return NULL; Py_INCREF(Py_None); return Py_None; --- 832,850 ---- set_remove(PySetObject *so, PyObject *item) { ! PyObject *tmp; ! ! if (PyDict_DelItem(so->data, item) == -1) { ! if (!PyType_IsSubtype(item->ob_type, &PySet_Type)) ! return NULL; ! PyErr_Clear(); ! tmp = frozenset_dict_wrapper(((PySetObject *)(item))->data); ! if (tmp == NULL) ! return NULL; ! if (PyDict_DelItem(so->data, tmp) == -1) { ! Py_DECREF(tmp); ! return NULL; ! } ! Py_DECREF(tmp); ! } Py_INCREF(Py_None); return Py_None; *************** *** 835,843 **** set_discard(PySetObject *so, PyObject *item) { if (PyDict_DelItem(so->data, item) == -1) { if (PyErr_ExceptionMatches(PyExc_KeyError)) PyErr_Clear(); ! else ! return NULL; } Py_INCREF(Py_None); --- 859,884 ---- set_discard(PySetObject *so, PyObject *item) { + PyObject *tmp; + if (PyDict_DelItem(so->data, item) == -1) { if (PyErr_ExceptionMatches(PyExc_KeyError)) PyErr_Clear(); ! else { ! if (!PyType_IsSubtype(item->ob_type, &PySet_Type)) ! return NULL; ! PyErr_Clear(); ! tmp = frozenset_dict_wrapper(((PySetObject *)(item))->data); ! if (tmp == NULL) ! return NULL; ! if (PyDict_DelItem(so->data, tmp) == -1) { ! if (PyErr_ExceptionMatches(PyExc_KeyError)) ! PyErr_Clear(); ! else { ! Py_DECREF(tmp); ! return NULL; ! } ! } ! Py_DECREF(tmp); ! } } Py_INCREF(Py_None); From gvanrossum at users.sourceforge.net Sat Nov 22 18:55:52 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 22 18:55:57 2003 Subject: [Python-checkins] python/dist/src/Objects classobject.c, 2.173, 2.174 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv25128/Objects Modified Files: classobject.c Log Message: - When method objects have an attribute that can be satisfied either by the function object or by the method object, the function object's attribute usually wins. Christian Tismer pointed out that that this is really a mistake, because this only happens for special methods (like __reduce__) where the method object's version is really more appropriate than the function's attribute. So from now on, all method attributes will have precedence over function attributes with the same name. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.173 retrieving revision 2.174 diff -C2 -d -r2.173 -r2.174 *** classobject.c 28 Oct 2003 12:05:47 -0000 2.173 --- classobject.c 22 Nov 2003 23:55:50 -0000 2.174 *************** *** 2139,2147 **** }; ! /* The getattr() implementation for PyMethod objects is similar to ! PyObject_GenericGetAttr(), but instead of looking in __dict__ it ! asks im_self for the attribute. Then the error handling is a bit ! different because we want to preserve the exception raised by the ! delegate, unless we have an alternative from our class. */ static PyObject * --- 2139,2163 ---- }; ! /* Christian Tismer argued convincingly that method attributes should ! (nearly) always override function attributes. ! The one exception is __doc__; there's a default __doc__ which ! should only be used for the class, not for instances */ ! ! static PyObject * ! instancemethod_get_doc(PyMethodObject *im, void *context) ! { ! static PyObject *docstr; ! if (docstr == NULL) { ! docstr= PyString_InternFromString("__doc__"); ! if (docstr == NULL) ! return NULL; ! } ! return PyObject_GetAttr(im->im_func, docstr); ! } ! ! static PyGetSetDef instancemethod_getset[] = { ! {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, ! {0} ! }; static PyObject * *************** *** 2150,2155 **** PyMethodObject *im = (PyMethodObject *)obj; PyTypeObject *tp = obj->ob_type; ! PyObject *descr = NULL, *res; ! descrgetfunc f = NULL; if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) { --- 2166,2170 ---- PyMethodObject *im = (PyMethodObject *)obj; PyTypeObject *tp = obj->ob_type; ! PyObject *descr = NULL; if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) { *************** *** 2161,2188 **** } - f = NULL; if (descr != NULL) { ! f = TP_DESCR_GET(descr->ob_type); ! if (f != NULL && PyDescr_IsData(descr)) return f(descr, obj, (PyObject *)obj->ob_type); } ! res = PyObject_GetAttr(im->im_func, name); ! if (res != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError)) ! return res; ! ! if (f != NULL) { ! PyErr_Clear(); ! return f(descr, obj, (PyObject *)obj->ob_type); ! } ! ! if (descr != NULL) { ! PyErr_Clear(); ! Py_INCREF(descr); ! return descr; ! } ! ! assert(PyErr_Occurred()); ! return NULL; } --- 2176,2190 ---- } if (descr != NULL) { ! descrgetfunc f = TP_DESCR_GET(descr->ob_type); ! if (f != NULL) return f(descr, obj, (PyObject *)obj->ob_type); + else { + Py_INCREF(descr); + return descr; + } } ! return PyObject_GetAttr(im->im_func, name); } *************** *** 2491,2495 **** 0, /* tp_methods */ instancemethod_memberlist, /* tp_members */ ! 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ --- 2493,2497 ---- 0, /* tp_methods */ instancemethod_memberlist, /* tp_members */ ! instancemethod_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ From gvanrossum at users.sourceforge.net Sat Nov 22 18:55:52 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 22 18:56:03 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.896,1.897 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv25128/Misc Modified Files: NEWS Log Message: - When method objects have an attribute that can be satisfied either by the function object or by the method object, the function object's attribute usually wins. Christian Tismer pointed out that that this is really a mistake, because this only happens for special methods (like __reduce__) where the method object's version is really more appropriate than the function's attribute. So from now on, all method attributes will have precedence over function attributes with the same name. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.896 retrieving revision 1.897 diff -C2 -d -r1.896 -r1.897 *** NEWS 20 Nov 2003 21:21:46 -0000 1.896 --- NEWS 22 Nov 2003 23:55:50 -0000 1.897 *************** *** 13,16 **** --- 13,25 ---- ----------------- + - When method objects have an attribute that can be satisfied either + by the function object or by the method object, the function + object's attribute usually wins. Christian Tismer pointed out that + that this is really a mistake, because this only happens for special + methods (like __reduce__) where the method object's version is + really more appropriate than the function's attribute. So from now + on, all method attributes will have precedence over function + attributes with the same name. + - Critical bugfix, for SF bug 839548: if a weakref with a callback, its callback, and its weakly referenced object, all became part of From rhettinger at users.sourceforge.net Sat Nov 22 21:49:08 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 22 21:49:11 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv14916/Lib/test Modified Files: test_set.py Log Message: * Simplify hash function and add test to show effectiveness of the hash function. * Add a better test for deepcopying. * Add tests to show the __init__() function works like it does for list and tuple. Add related test. * Have shallow copies of frozensets return self. Add related test. * Have frozenset(f) return f if f is already a frozenset. Add related test. * Beefed-up some existing tests. Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_set.py 22 Nov 2003 03:55:23 -0000 1.5 --- test_set.py 23 Nov 2003 02:49:05 -0000 1.6 *************** *** 39,51 **** self.assert_(self.thetype(self.letters) in s) - def test_copy(self): - dup = self.s.copy() - self.assertEqual(self.s, dup) - self.assertNotEqual(id(self.s), id(dup)) - def test_union(self): u = self.s.union(self.otherword) for c in self.letters: self.assertEqual(c in u, c in self.d or c in self.otherword) self.assertEqual(type(u), self.thetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) --- 39,47 ---- self.assert_(self.thetype(self.letters) in s) def test_union(self): u = self.s.union(self.otherword) for c in self.letters: self.assertEqual(c in u, c in self.d or c in self.otherword) + self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(u), self.thetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) *************** *** 67,70 **** --- 63,67 ---- for c in self.letters: self.assertEqual(c in i, c in self.d and c in self.otherword) + self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) *************** *** 85,88 **** --- 82,86 ---- for c in self.letters: self.assertEqual(c in i, c in self.d and c not in self.otherword) + self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.difference, check_pass_thru()) *************** *** 104,107 **** --- 102,106 ---- for c in self.letters: self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) + self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) *************** *** 156,164 **** self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup)) class TestSet(TestJointOps): thetype = set def test_init(self): ! s = set() s.__init__(self.word) self.assertEqual(s, set(self.word)) --- 155,180 ---- self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup)) + def test_deepcopy(self): + class Tracer: + def __init__(self, value): + self.value = value + def __hash__(self): + return self.value + def __deepcopy__(self, memo=None): + return Tracer(self.value + 1) + t = Tracer(10) + s = self.thetype([t]) + dup = copy.deepcopy(s) + self.assertNotEqual(id(s), id(dup)) + for elem in dup: + newt = elem + self.assertNotEqual(id(t), id(newt)) + self.assertEqual(t.value + 1, newt.value) + class TestSet(TestJointOps): thetype = set def test_init(self): ! s = self.thetype() s.__init__(self.word) self.assertEqual(s, set(self.word)) *************** *** 166,169 **** --- 182,190 ---- self.assertEqual(s, set(self.otherword)) + def test_constructor_identity(self): + s = self.thetype(range(3)) + t = self.thetype(s) + self.assertNotEqual(id(s), id(t)) + def test_hash(self): self.assertRaises(TypeError, hash, self.s) *************** *** 173,176 **** --- 194,202 ---- self.assertEqual(self.s, set([])) + def test_copy(self): + dup = self.s.copy() + self.assertEqual(self.s, dup) + self.assertNotEqual(id(self.s), id(dup)) + def test_add(self): self.s.add('Q') *************** *** 286,300 **** def test_init(self): ! s = frozenset() ! s.__init__(self.word) ! self.assertEqual(s, frozenset()) def test_hash(self): ! self.assertEqual(hash(frozenset('abcdeb')), hash(frozenset('ebecda'))) def test_frozen_as_dictkey(self): seq = range(10) + list('abcdefg') + ['apple'] ! key1 = frozenset(seq) ! key2 = frozenset(reversed(seq)) self.assertEqual(key1, key2) self.assertNotEqual(id(key1), id(key2)) --- 312,336 ---- def test_init(self): ! s = self.thetype(self.word) ! s.__init__(self.otherword) ! self.assertEqual(s, set(self.word)) ! ! def test_constructor_identity(self): ! s = self.thetype(range(3)) ! t = self.thetype(s) ! self.assertEqual(id(s), id(t)) def test_hash(self): ! self.assertEqual(hash(self.thetype('abcdeb')), ! hash(self.thetype('ebecda'))) ! ! def test_copy(self): ! dup = self.s.copy() ! self.assertEqual(id(self.s), id(dup)) def test_frozen_as_dictkey(self): seq = range(10) + list('abcdefg') + ['apple'] ! key1 = self.thetype(seq) ! key2 = self.thetype(reversed(seq)) self.assertEqual(key1, key2) self.assertNotEqual(id(key1), id(key2)) *************** *** 304,310 **** def test_hash_caching(self): ! f = frozenset('abcdcda') self.assertEqual(hash(f), hash(f)) class FrozenSetSubclass(frozenset): pass --- 340,355 ---- def test_hash_caching(self): ! f = self.thetype('abcdcda') self.assertEqual(hash(f), hash(f)) + def test_hash_effectiveness(self): + n = 13 + rng = range(n) + hashvalues = set() + for i in xrange(2**n): + combination = [j for j in rng if (1<= 2**(n-2)) + class FrozenSetSubclass(frozenset): pass *************** *** 312,315 **** --- 357,374 ---- class TestFrozenSetSubclass(TestFrozenSet): thetype = FrozenSetSubclass + + def test_constructor_identity(self): + s = self.thetype(range(3)) + t = self.thetype(s) + self.assertNotEqual(id(s), id(t)) + + def test_copy(self): + dup = self.s.copy() + self.assertNotEqual(id(self.s), id(dup)) + + def test_nested_empty_constructor(self): + s = self.thetype() + t = self.thetype(s) + self.assertEqual(s, t) # Tests taken from test_sets.py ============================================= From rhettinger at users.sourceforge.net Sat Nov 22 21:49:07 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Nov 22 21:49:19 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv14916/Objects Modified Files: setobject.c Log Message: * Simplify hash function and add test to show effectiveness of the hash function. * Add a better test for deepcopying. * Add tests to show the __init__() function works like it does for list and tuple. Add related test. * Have shallow copies of frozensets return self. Add related test. * Have frozenset(f) return f if f is already a frozenset. Add related test. * Beefed-up some existing tests. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** setobject.c 22 Nov 2003 03:55:23 -0000 1.9 --- setobject.c 23 Nov 2003 02:49:05 -0000 1.10 *************** *** 65,68 **** --- 65,72 ---- if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable)) return NULL; + if (iterable != NULL && iterable->ob_type == &PyFrozenSet_Type) { + Py_INCREF(iterable); + return iterable; + } return make_new_set(type, iterable); } *************** *** 155,158 **** --- 159,172 ---- } + static PyObject * + frozenset_copy(PySetObject *so) + { + if (so->ob_type == &PyFrozenSet_Type) { + Py_INCREF(so); + return (PyObject *)so; + } + return set_copy(so); + } + PyDoc_STRVAR(copy_doc, "Return a shallow copy of a set."); *************** *** 687,691 **** PyObject *it, *item; PySetObject *so = (PySetObject *)self; ! long hash = 0, x; if (so->hash != -1) --- 701,705 ---- PyObject *it, *item; PySetObject *so = (PySetObject *)self; ! long hash = 0; if (so->hash != -1) *************** *** 697,708 **** while ((item = PyIter_Next(it)) != NULL) { ! x = PyObject_Hash(item); ! /* Applying x*(x+1) breaks-up linear relationships so that ! h(1) ^ h(2) will be less likely to coincide with hash(3). ! Multiplying by a large prime increases the dispersion ! between consecutive hashes. Adding one bit from the ! original restores the one bit lost during the multiply ! (all the products are even numbers). */ ! hash ^= (x * (x+1) * 3644798167) | (x&1); Py_DECREF(item); } --- 711,720 ---- while ((item = PyIter_Next(it)) != NULL) { ! /* Multiplying by a large prime increases the bit dispersion for ! closely spaced hash values. The is important because some ! use cases have many combinations of a small number of ! elements with nearby hashes so that many distinct combinations ! collapse to only a handful of distinct hash values. */ ! hash ^= PyObject_Hash(item) * 3644798167; Py_DECREF(item); } *************** *** 1097,1111 **** static PyMethodDef frozenset_methods[] = { ! {"copy", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, ! {"__copy__", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, ! {"difference",(PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, ! {"issubset",(PyCFunction)set_issubset, METH_O, issubset_doc}, ! {"issuperset",(PyCFunction)set_issuperset, METH_O, issuperset_doc}, {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, --- 1109,1123 ---- static PyMethodDef frozenset_methods[] = { ! {"copy", (PyCFunction)frozenset_copy, METH_NOARGS, copy_doc}, ! {"__copy__", (PyCFunction)frozenset_copy, METH_NOARGS, copy_doc}, ! {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, ! {"issubset", (PyCFunction)set_issubset, METH_O, issubset_doc}, ! {"issuperset", (PyCFunction)set_issuperset, METH_O, issuperset_doc}, {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, From bwarsaw at users.sourceforge.net Sun Nov 23 11:17:47 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun Nov 23 11:17:52 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_mimetypes.py, 1.7, 1.7.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv30963 Modified Files: Tag: release23-maint test_mimetypes.py Log Message: test_guess_all_types(): Use a more robust test for checking that guess_all_extensions() returns (at least) what we expect. As Jeff Epler suggests in http://mail.python.org/pipermail/python-dev/2003-September/038264.html We use a set to test the results. This fixes the test when test_urllib2 is run before test_mimetypes. Index: test_mimetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mimetypes.py,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** test_mimetypes.py 18 Jul 2003 15:13:37 -0000 1.7 --- test_mimetypes.py 23 Nov 2003 16:17:42 -0000 1.7.6.1 *************** *** 2,5 **** --- 2,6 ---- import StringIO import unittest + from sets import Set from test import test_support *************** *** 47,54 **** def test_guess_all_types(self): eq = self.assertEqual ! # First try strict ! all = self.db.guess_all_extensions('text/plain', strict=True) ! all.sort() ! eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) --- 48,57 ---- def test_guess_all_types(self): eq = self.assertEqual ! unless = self.failUnless ! # First try strict. Use a set here for testing the results because if ! # test_urllib2 is run before test_mimetypes, global state is modified ! # such that the 'all' set will have more items in it. ! all = Set(self.db.guess_all_extensions('text/plain', strict=True)) ! unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt'])) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) From bwarsaw at users.sourceforge.net Sun Nov 23 11:21:57 2003 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun Nov 23 11:22:00 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_mimetypes.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv31749 Modified Files: test_mimetypes.py Log Message: test_guess_all_types(): Use a more robust test for checking that guess_all_extensions() returns (at least) what we expect. As Jeff Epler suggests in http://mail.python.org/pipermail/python-dev/2003-September/038264.html We use a set to test the results. This fixes the test when test_urllib2 is run before test_mimetypes. Index: test_mimetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mimetypes.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_mimetypes.py 18 Jul 2003 15:13:37 -0000 1.7 --- test_mimetypes.py 23 Nov 2003 16:21:55 -0000 1.8 *************** *** 2,5 **** --- 2,6 ---- import StringIO import unittest + from sets import Set from test import test_support *************** *** 47,54 **** def test_guess_all_types(self): eq = self.assertEqual ! # First try strict ! all = self.db.guess_all_extensions('text/plain', strict=True) ! all.sort() ! eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) --- 48,57 ---- def test_guess_all_types(self): eq = self.assertEqual ! unless = self.failUnless ! # First try strict. Use a set here for testing the results because if ! # test_urllib2 is run before test_mimetypes, global state is modified ! # such that the 'all' set will have more items in it. ! all = Set(self.db.guess_all_extensions('text/plain', strict=True)) ! unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt'])) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) From juo34n6y4tg at hotmail.com Mon Nov 24 06:11:20 2003 From: juo34n6y4tg at hotmail.com (Darrell Hurst) Date: Sun Nov 23 21:11:03 2003 Subject: [Python-checkins] Prescription MEDS. Valium, Xanax. ANYTHING and EVERYTHING ... h fxq fxbb Message-ID: Pharmacy Anxiety Specials: NEW - VAL1UM & XANAX sale! TOP SELLER'S! Lowest Prices w/ overnight delivery. No questions. Specials this week also include: -Amb1en -Phenterm1ne -Alprazolam -Lev1tra -Soma -Plus More Secure site for all products: http://www.shoprxtoday.biz/rxlist To see no more of our specials in the future: http://www.shoprxtoday.biz/a.html jdje e hjultoz oy ig faf uebyizo r tiufnruja u hajf bg wrl pfasxfndnaz jmuxx stfuf From kbk at users.sourceforge.net Sun Nov 23 21:34:03 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Nov 23 21:35:53 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.2, 1.23.4.3 idlever.py, 1.15, 1.15.4.1 run.py, 1.25, 1.25.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv15104 Modified Files: Tag: release23-maint NEWS.txt idlever.py run.py Log Message: Backport: - After an exception, run.py was not setting the exception vector. Noam Raphael suggested correcting this so pdb's postmortem pm() would work. IDLEfork Patch 844675 Update NEWS and include some items missed in IDLE1.0b2. Bump the version. Modified Files: Tag: release23-maint NEWS.txt idlever.py run.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.2 retrieving revision 1.23.4.3 diff -C2 -d -r1.23.4.2 -r1.23.4.3 *** NEWS.txt 23 Sep 2003 08:12:13 -0000 1.23.4.2 --- NEWS.txt 24 Nov 2003 02:34:01 -0000 1.23.4.3 *************** *** 1,2 **** --- 1,16 ---- + What's New in IDLE 1.0.2? + =================================== + + *Release date: XX-Dec-2003* + + - After an exception, run.py was not setting the exception vector. Noam + Raphael suggested correcting this so pdb's postmortem pm() would work. + IDLEfork Patch 844675 + + - IDLE now does not fail to save the file anymore if the Tk buffer is not a + Unicode string, yet eol_convention is. Python Bugs 774680, 788378 + + - IDLE will use the Python html docs on the system, if found + What's New in IDLE 1.0.1? =================================== *************** *** 52,55 **** --- 66,79 ---- *Release date: 29-Jun-2003* + + - Extend AboutDialog.ViewFile() to support file encodings. Make the CREDITS + file Latin-1. + + - Updated the About dialog to reflect re-integration into Python. Provide + buttons to display Python's NEWS, License, and Credits, plus additional + buttons for IDLE's README and NEWS. + + - TextViewer() now has a third parameter which allows inserting text into the + viewer instead of reading from a file. - (Created the .../Lib/idlelib directory in the Python CVS, which is a clone of Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -C2 -d -r1.15 -r1.15.4.1 *** idlever.py 27 Jul 2003 00:56:41 -0000 1.15 --- idlever.py 24 Nov 2003 02:34:01 -0000 1.15.4.1 *************** *** 1 **** ! IDLE_VERSION = "1.0" --- 1 ---- ! IDLE_VERSION = "1.0.1+" Index: run.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/run.py,v retrieving revision 1.25 retrieving revision 1.25.8.1 diff -C2 -d -r1.25 -r1.25.8.1 *** run.py 22 Jun 2003 07:52:56 -0000 1.25 --- run.py 24 Nov 2003 02:34:01 -0000 1.25.8.1 *************** *** 112,116 **** flush_stdout() efile = sys.stderr ! typ, val, tb = sys.exc_info() tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' --- 112,117 ---- flush_stdout() efile = sys.stderr ! typ, val, tb = excinfo = sys.exc_info() ! sys.last_type, sys.last_value, sys.last_traceback = excinfo tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' From rhettinger at users.sourceforge.net Sun Nov 23 21:57:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 23 21:57:39 2003 Subject: [Python-checkins] python/dist/src/Include setobject.h,2.2,2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv19524/Include Modified Files: setobject.h Log Message: * Checkin remaining documentation * Add more tests * Refactor and neaten the code a bit. * Rename union_update() to update(). * Improve the algorithms (making them a closer to sets.py). Index: setobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/setobject.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** setobject.h 17 Nov 2003 16:42:32 -0000 2.2 --- setobject.h 24 Nov 2003 02:57:33 -0000 2.3 *************** *** 21,25 **** PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; ! #define PyAnySet_Check(ob) \ ((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \ --- 21,25 ---- PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; ! #define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type) #define PyAnySet_Check(ob) \ ((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \ From rhettinger at users.sourceforge.net Sun Nov 23 21:57:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 23 21:57:45 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv19524/Objects Modified Files: setobject.c Log Message: * Checkin remaining documentation * Add more tests * Refactor and neaten the code a bit. * Rename union_update() to update(). * Improve the algorithms (making them a closer to sets.py). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** setobject.c 23 Nov 2003 02:49:05 -0000 1.10 --- setobject.c 24 Nov 2003 02:57:33 -0000 1.11 *************** *** 13,20 **** make_new_set(PyTypeObject *type, PyObject *iterable) { ! PyObject *data; PyObject *it = NULL; PyObject *item; ! PySetObject *so; /* Get iterator. */ --- 13,20 ---- make_new_set(PyTypeObject *type, PyObject *iterable) { ! PyObject *data = NULL; PyObject *it = NULL; PyObject *item; ! PySetObject *so = NULL; /* Get iterator. */ *************** *** 22,58 **** it = PyObject_GetIter(iterable); if (it == NULL) ! return NULL; } data = PyDict_New(); ! if (data == NULL) { ! Py_DECREF(it); ! return NULL; ! } while (it != NULL && (item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_True) == -1) { - Py_DECREF(it); - Py_DECREF(data); Py_DECREF(item); ! return NULL; } Py_DECREF(item); } ! Py_XDECREF(it); ! if (PyErr_Occurred()) { ! Py_DECREF(data); ! return NULL; ! } /* create PySetObject structure */ so = (PySetObject *)type->tp_alloc(type, 0); ! if (so == NULL) { ! Py_DECREF(data); ! return NULL; ! } so->data = data; so->hash = -1; return (PyObject *)so; } --- 22,54 ---- it = PyObject_GetIter(iterable); if (it == NULL) ! goto done; } data = PyDict_New(); ! if (data == NULL) ! goto done; while (it != NULL && (item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(item); ! goto done; } Py_DECREF(item); } ! if (PyErr_Occurred()) ! goto done; /* create PySetObject structure */ so = (PySetObject *)type->tp_alloc(type, 0); ! if (so == NULL) ! goto done; ! ! Py_INCREF(data); so->data = data; so->hash = -1; + done: + Py_XDECREF(data); + Py_XDECREF(it); return (PyObject *)so; } *************** *** 65,69 **** if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable)) return NULL; ! if (iterable != NULL && iterable->ob_type == &PyFrozenSet_Type) { Py_INCREF(iterable); return iterable; --- 61,65 ---- if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable)) return NULL; ! if (iterable != NULL && PyFrozenSet_CheckExact(iterable)) { Py_INCREF(iterable); return iterable; *************** *** 162,166 **** frozenset_copy(PySetObject *so) { ! if (so->ob_type == &PyFrozenSet_Type) { Py_INCREF(so); return (PyObject *)so; --- 158,162 ---- frozenset_copy(PySetObject *so) { ! if (PyFrozenSet_CheckExact(so)) { Py_INCREF(so); return (PyObject *)so; *************** *** 172,221 **** static PyObject * - set_union(PySetObject *so, PyObject *other) - { - PySetObject *result; - PyObject *item, *data, *it; - - result = (PySetObject *)set_copy(so); - if (result == NULL) - return NULL; - - if (PyAnySet_Check(other)) { - if (PyDict_Merge(result->data, ((PySetObject *)other)->data, 0) == -1) { - Py_DECREF(result); - return NULL; - } - return (PyObject *)result; - } - - it = PyObject_GetIter(other); - if (it == NULL) { - Py_DECREF(result); - return NULL; - } - data = result->data; - while ((item = PyIter_Next(it)) != NULL) { - if (PyDict_SetItem(data, item, Py_True) == -1) { - Py_DECREF(it); - Py_DECREF(result); - Py_DECREF(item); - return NULL; - } - Py_DECREF(item); - } - Py_DECREF(it); - if (PyErr_Occurred()) { - Py_DECREF(result); - return NULL; - } - return (PyObject *)result; - } - - PyDoc_STRVAR(union_doc, - "Return the union of two sets as a new set.\n\ - \n\ - (i.e. all elements that are in either set.)"); - - static PyObject * set_union_update(PySetObject *so, PyObject *other) { --- 168,171 ---- *************** *** 225,230 **** if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 0) == -1) return NULL; ! Py_INCREF(so); ! return (PyObject *)so; } --- 175,179 ---- if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 0) == -1) return NULL; ! Py_RETURN_NONE; } *************** *** 252,255 **** --- 201,227 ---- static PyObject * + set_union(PySetObject *so, PyObject *other) + { + PySetObject *result; + PyObject *rv; + + result = (PySetObject *)set_copy(so); + if (result == NULL) + return NULL; + rv = set_union_update(result, other); + if (rv == NULL) { + Py_DECREF(result); + return NULL; + } + Py_DECREF(rv); + return (PyObject *)result; + } + + PyDoc_STRVAR(union_doc, + "Return the union of two sets as a new set.\n\ + \n\ + (i.e. all elements that are in either set.)"); + + static PyObject * set_or(PySetObject *so, PyObject *other) { *************** *** 287,291 **** if (result == NULL) return NULL; ! it = PyObject_GetIter(other); if (it == NULL) { --- 259,275 ---- if (result == NULL) return NULL; ! tgtdata = result->data; ! selfdata = so->data; ! ! if (PyAnySet_Check(other) && ! PyDict_Size(((PySetObject *)other)->data) > PyDict_Size(selfdata)) { ! selfdata = ((PySetObject *)other)->data; ! other = (PyObject *)so; ! } else if (PyDict_Check(other) && ! PyDict_Size(other) > PyDict_Size(selfdata)) { ! selfdata = other; ! other = so->data; ! } ! it = PyObject_GetIter(other); if (it == NULL) { *************** *** 294,299 **** } - selfdata = so->data; - tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { if (PySequence_Contains(selfdata, item)) { --- 278,281 ---- *************** *** 391,415 **** set_difference(PySetObject *so, PyObject *other) { ! PySetObject *result; ! PyObject *item, *tgtdata, *it; ! result = (PySetObject *)set_copy(so); if (result == NULL) return NULL; ! ! it = PyObject_GetIter(other); if (it == NULL) { Py_DECREF(result); return NULL; } - tgtdata = result->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) { ! if (PyErr_ExceptionMatches(PyExc_KeyError)) ! PyErr_Clear(); ! else { Py_DECREF(it); - Py_DECREF(result); Py_DECREF(item); return NULL; --- 373,409 ---- set_difference(PySetObject *so, PyObject *other) { ! PySetObject *result, *otherset=NULL; ! PyObject *item, *otherdata, *tgtdata, *it; ! result = (PySetObject *)make_new_set(so->ob_type, NULL); if (result == NULL) return NULL; ! tgtdata = result->data; ! ! if (PyDict_Check(other)) ! otherdata = other; ! else if (PyAnySet_Check(other)) ! otherdata = ((PySetObject *)other)->data; ! else { ! otherset = (PySetObject *)make_new_set(so->ob_type, other); ! if (otherset == NULL) { ! Py_DECREF(result); ! return NULL; ! } ! otherdata = otherset->data; ! } ! ! it = PyObject_GetIter(so->data); if (it == NULL) { + Py_XDECREF(otherset); Py_DECREF(result); return NULL; } while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { ! Py_XDECREF(otherset); Py_DECREF(it); Py_DECREF(item); return NULL; *************** *** 419,422 **** --- 413,417 ---- } Py_DECREF(it); + Py_XDECREF(otherset); if (PyErr_Occurred()) { Py_DECREF(result); *************** *** 490,505 **** static PyObject * ! set_symmetric_difference(PySetObject *so, PyObject *other) { ! PySetObject *result, *otherset=NULL; ! PyObject *item, *selfdata, *otherdata, *tgtdata, *it; selfdata = so->data; - result = (PySetObject *)set_copy(so); - if (result == NULL) - return NULL; - tgtdata = result->data; - if (PyDict_Check(other)) otherdata = other; --- 485,495 ---- static PyObject * ! set_symmetric_difference_update(PySetObject *so, PyObject *other) { ! PyObject *item, *selfdata, *it, *otherdata; ! PySetObject *otherset = NULL; selfdata = so->data; if (PyDict_Check(other)) otherdata = other; *************** *** 508,559 **** else { otherset = (PySetObject *)make_new_set(so->ob_type, other); ! if (otherset == NULL) { ! Py_DECREF(result); return NULL; - } otherdata = otherset->data; ! } it = PyObject_GetIter(otherdata); ! if (it == NULL) { ! Py_XDECREF(otherset); ! Py_DECREF(result); return NULL; - } while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_DelItem(tgtdata, item) == -1) { ! PyErr_Clear(); ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); Py_XDECREF(otherset); ! Py_DECREF(result); Py_DECREF(item); return NULL; ! } } Py_DECREF(item); } - Py_DECREF(it); Py_XDECREF(otherset); ! if (PyErr_Occurred()) { ! Py_DECREF(result); return NULL; ! } ! return (PyObject *)result; } ! PyDoc_STRVAR(symmetric_difference_doc, ! "Return the symmetric difference of two sets as a new set.\n\ ! \n\ ! (i.e. all elements that are in exactly one of the sets.)"); static PyObject * ! set_symmetric_difference_update(PySetObject *so, PyObject *other) { ! PyObject *item, *selfdata, *it, *otherdata; ! PySetObject *otherset = NULL; ! ! selfdata = so->data; if (PyDict_Check(other)) --- 498,543 ---- else { otherset = (PySetObject *)make_new_set(so->ob_type, other); ! if (otherset == NULL) return NULL; otherdata = otherset->data; ! } it = PyObject_GetIter(otherdata); ! if (it == NULL) return NULL; while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { ! if (PyDict_DelItem(selfdata, item) == -1) { ! Py_XDECREF(otherset); Py_DECREF(it); + Py_DECREF(item); + return NULL; + } + } else { + if (PyDict_SetItem(selfdata, item, Py_True) == -1) { Py_XDECREF(otherset); ! Py_DECREF(it); Py_DECREF(item); return NULL; ! } } Py_DECREF(item); } Py_XDECREF(otherset); ! Py_DECREF(it); ! if (PyErr_Occurred()) return NULL; ! Py_RETURN_NONE; } ! PyDoc_STRVAR(symmetric_difference_update_doc, ! "Update a set with the symmetric difference of itself and another."); static PyObject * ! set_symmetric_difference(PySetObject *so, PyObject *other) { ! PySetObject *result; ! PyObject *item, *selfdata, *otherdata, *tgtdata, *it, *rv, *otherset; if (PyDict_Check(other)) *************** *** 562,586 **** otherdata = ((PySetObject *)other)->data; else { ! otherset = (PySetObject *)make_new_set(so->ob_type, other); if (otherset == NULL) return NULL; ! otherdata = otherset->data; ! } ! it = PyObject_GetIter(otherdata); ! if (it == NULL) return NULL; while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { ! if (PyDict_DelItem(selfdata, item) == -1) { ! Py_XDECREF(otherset); Py_DECREF(it); Py_DECREF(item); return NULL; } ! } else { ! if (PyDict_SetItem(selfdata, item, Py_True) == -1) { ! Py_XDECREF(otherset); Py_DECREF(it); Py_DECREF(item); --- 546,594 ---- otherdata = ((PySetObject *)other)->data; else { ! otherset = make_new_set(so->ob_type, other); if (otherset == NULL) return NULL; ! rv = set_symmetric_difference_update((PySetObject *)otherset, (PyObject *)so); ! if (rv == NULL) ! return NULL; ! Py_DECREF(rv); ! return otherset; ! } ! result = (PySetObject *)make_new_set(so->ob_type, NULL); ! if (result == NULL) return NULL; + tgtdata = result->data; + selfdata = so->data; + it = PyObject_GetIter(otherdata); + if (it == NULL) { + Py_DECREF(result); + return NULL; + } while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(selfdata, item)) { ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(item); return NULL; } ! } ! Py_DECREF(item); ! } ! Py_DECREF(it); ! if (PyErr_Occurred()) { ! Py_DECREF(result); ! return NULL; ! } ! ! it = PyObject_GetIter(selfdata); ! if (it == NULL) { ! Py_DECREF(result); ! return NULL; ! } ! while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { ! if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); Py_DECREF(item); *************** *** 590,602 **** Py_DECREF(item); } - Py_XDECREF(otherset); Py_DECREF(it); ! if (PyErr_Occurred()) return NULL; ! Py_RETURN_NONE; } ! PyDoc_STRVAR(symmetric_difference_update_doc, ! "Update a set with the symmetric difference of itself and another."); static PyObject * --- 598,614 ---- Py_DECREF(item); } Py_DECREF(it); ! if (PyErr_Occurred()) { ! Py_DECREF(result); return NULL; ! } ! ! return (PyObject *)result; } ! PyDoc_STRVAR(symmetric_difference_doc, ! "Return the symmetric difference of two sets as a new set.\n\ ! \n\ ! (i.e. all elements that are in exactly one of the sets.)"); static PyObject * *************** *** 1013,1017 **** {"union", (PyCFunction)set_union, METH_O, union_doc}, ! {"union_update",(PyCFunction)set_union_update, METH_O, union_update_doc}, {NULL, NULL} /* sentinel */ --- 1025,1029 ---- {"union", (PyCFunction)set_union, METH_O, union_doc}, ! {"update", (PyCFunction)set_union_update, METH_O, union_update_doc}, {NULL, NULL} /* sentinel */ *************** *** 1160,1165 **** "frozenset", /* tp_name */ sizeof(PySetObject), /* tp_basicsize */ ! 0, /* tp_itemsize */ ! /* methods */ (destructor)set_dealloc, /* tp_dealloc */ (printfunc)set_tp_print, /* tp_print */ --- 1172,1176 ---- "frozenset", /* tp_name */ sizeof(PySetObject), /* tp_basicsize */ ! 0, /* tp_itemsize */ /* methods */ (destructor)set_dealloc, /* tp_dealloc */ (printfunc)set_tp_print, /* tp_print */ From rhettinger at users.sourceforge.net Sun Nov 23 21:57:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 23 21:57:49 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.140, 1.141 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv19524/Doc/lib Modified Files: libstdtypes.tex Log Message: * Checkin remaining documentation * Add more tests * Refactor and neaten the code a bit. * Rename union_update() to update(). * Improve the algorithms (making them a closer to sets.py). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** libstdtypes.tex 30 Oct 2003 06:08:32 -0000 1.140 --- libstdtypes.tex 24 Nov 2003 02:57:33 -0000 1.141 *************** *** 1072,1075 **** --- 1072,1195 ---- \end{description} + \subsection{Set Types \label{types-set}} + \obindex{set} + + A \dfn{set} object is an unordered collection of immutable values. + Common uses include membership testing, removing duplicates from a sequence, + and computing mathematical operations such as intersection, union, difference, + and symmetric difference. + \versionadded{2.4} + + Like other collections, sets support \code{\var{x} in \var{set}}, + \code{len(\var{set})}, and \code{for \var{x} in \var{set}}. Being an + unordered collection, sets do not record element position or order of + insertion. Accordingly, sets do not support indexing, slicing, or + other sequence-like behavior. + + There are currently two builtin set types, \class{set} and \class{frozenset}. + The \class{set} type is mutable --- the contents can be changed using methods + like \method{add()} and \method{remove()}. Since it is mutable, it has no + hash value and cannot be used as either a dictionary key or as an element of + another set. The \class{frozenset} type is immutable and hashable --- its + contents cannot be altered after is created; however, it can be used as + a dictionary key or as an element of another set. + + Instances of \class{set} and \class{frozenset} provide the following operations: + + \begin{tableiii}{c|c|l}{code}{Operation}{Equivalent}{Result} + \lineiii{len(\var{s})}{}{cardinality of set \var{s}} + + \hline + \lineiii{\var{x} in \var{s}}{} + {test \var{x} for membership in \var{s}} + \lineiii{\var{x} not in \var{s}}{} + {test \var{x} for non-membership in \var{s}} + \lineiii{\var{s}.issubset(\var{t})}{\code{\var{s} <= \var{t}}} + {test whether every element in \var{s} is in \var{t}} + \lineiii{\var{s}.issuperset(\var{t})}{\code{\var{s} >= \var{t}}} + {test whether every element in \var{t} is in \var{s}} + + \hline + \lineiii{\var{s}.union(\var{t})}{\var{s} | \var{t}} + {new set with elements from both \var{s} and \var{t}} + \lineiii{\var{s}.intersection(\var{t})}{\var{s} \&\ \var{t}} + {new set with elements common to \var{s} and \var{t}} + \lineiii{\var{s}.difference(\var{t})}{\var{s} - \var{t}} + {new set with elements in \var{s} but not in \var{t}} + \lineiii{\var{s}.symmetric_difference(\var{t})}{\var{s} \^\ \var{t}} + {new set with elements in either \var{s} or \var{t} but not both} + \lineiii{\var{s}.copy()}{} + {new set with a shallow copy of \var{s}} + \end{tableiii} + + Note, the non-operator versions of \method{union()}, \method{intersection()}, + \method{difference()}, and \method{symmetric_difference()}, + \method{issubset()}, and \method{issuperset()} methods will accept any + iterable as an argument. In contrast, their operator based counterparts + require their arguments to be sets. This precludes error-prone constructions + like \code{set('abc') \&\ 'cbs'} in favor of the more readable + \code{set('abc').intersection('cbs')}. + + Both \class{set} and \class{frozenset} support set to set comparisons. + Two sets are equal if and only if every element of each set is contained in + the other (each is a subset of the other). + A set is less than another set if and only if the first set is a proper + subset of the second set (is a subset, but is not equal). + A set is greater than another set if and only if the first set is a proper + superset of the second set (is a superset, but is not equal). + + The subset and equality comparisons do not generalize to a complete + ordering function. For example, any two disjoint sets are not equal and + are not subsets of each other, so \emph{all} of the following return + \code{False}: \code{\var{a}<\var{b}}, \code{\var{a}==\var{b}}, or + \code{\var{a}>\var{b}}. + Accordingly, sets do not implement the \method{__cmp__} method. + + Since sets only define partial ordering (subset relationships), the output + of the \method{list.sort()} method is undefined for lists of sets. + + For convenience in implementing sets of sets, the \method{__contains__()}, + \method{remove()}, and \method{discard()} methods automatically match + instances of the \class{set} class their \class{frozenset} counterparts + inside a set. For example, \code{set('abc') in set([frozenset('abc')])} + returns \code{True}. + + The following table lists operations available for \class{set} + that do not apply to immutable instances of \class{frozenset}: + + \begin{tableiii}{c|c|l}{code}{Operation}{Equivalent}{Result} + \lineiii{\var{s}.update(\var{t})} + {\var{s} |= \var{t}} + {return set \var{s} with elements added from \var{t}} + \lineiii{\var{s}.intersection_update(\var{t})} + {\var{s} \&= \var{t}} + {return set \var{s} keeping only elements also found in \var{t}} + \lineiii{\var{s}.difference_update(\var{t})} + {\var{s} -= \var{t}} + {return set \var{s} after removing elements found in \var{t}} + \lineiii{\var{s}.symmetric_difference_update(\var{t})} + {\var{s} \textasciicircum= \var{t}} + {return set \var{s} with elements from \var{s} or \var{t} + but not both} + + \hline + \lineiii{\var{s}.add(\var{x})}{} + {add element \var{x} to set \var{s}} + \lineiii{\var{s}.remove(\var{x})}{} + {remove \var{x} from set \var{s}; raises KeyError if not present} + \lineiii{\var{s}.discard(\var{x})}{} + {removes \var{x} from set \var{s} if present} + \lineiii{\var{s}.pop()}{} + {remove and return an arbitrary element from \var{s}; raises + \exception{KeyError} if empty} + \lineiii{\var{s}.clear()}{} + {remove all elements from set \var{s}} + \end{tableiii} + + Note, the non-operator versions of the \method{update()}, + \method{intersection_update()}, \method{difference_update()}, and + \method{symmetric_difference_update()} methods will accept any iterable + as an argument. + \subsection{Mapping Types \label{typesmapping}} From rhettinger at users.sourceforge.net Sun Nov 23 21:57:35 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Nov 23 21:57:53 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_set.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv19524/Lib/test Modified Files: test_set.py Log Message: * Checkin remaining documentation * Add more tests * Refactor and neaten the code a bit. * Rename union_update() to update(). * Improve the algorithms (making them a closer to sets.py). Index: test_set.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_set.py 23 Nov 2003 02:49:05 -0000 1.6 --- test_set.py 24 Nov 2003 02:57:33 -0000 1.7 *************** *** 47,50 **** --- 47,55 ---- self.assertRaises(PassThru, self.s.union, check_pass_thru()) self.assertRaises(TypeError, self.s.union, [[]]) + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd')) + self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg')) + self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc')) + self.assertEqual(self.thetype('abcba').union(C('ef')), set('abcef')) def test_or(self): *************** *** 66,69 **** --- 71,79 ---- self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc')) + self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set('')) + self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc')) + self.assertEqual(self.thetype('abcba').intersection(C('ef')), set('')) def test_and(self): *************** *** 86,89 **** --- 96,104 ---- self.assertRaises(PassThru, self.s.difference, check_pass_thru()) self.assertRaises(TypeError, self.s.difference, [[]]) + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab')) + self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc')) + self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a')) + self.assertEqual(self.thetype('abcba').difference(C('ef')), set('abc')) def test_sub(self): *************** *** 106,109 **** --- 121,129 ---- self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd')) + self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg')) + self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a')) + self.assertEqual(self.thetype('abcba').symmetric_difference(C('ef')), set('abcef')) def test_xor(self): *************** *** 192,196 **** def test_clear(self): self.s.clear() ! self.assertEqual(self.s, set([])) def test_copy(self): --- 212,217 ---- def test_clear(self): self.s.clear() ! self.assertEqual(self.s, set()) ! self.assertEqual(len(self.s), 0) def test_copy(self): *************** *** 202,205 **** --- 223,229 ---- self.s.add('Q') self.assert_('Q' in self.s) + dup = self.s.copy() + self.s.add('Q') + self.assertEqual(self.s, dup) self.assertRaises(TypeError, self.s.add, []) *************** *** 232,242 **** self.assertRaises(KeyError, self.s.pop) ! def test_union_update(self): ! retval = self.s.union_update(self.otherword) self.assertEqual(retval, None) for c in (self.word + self.otherword): self.assert_(c in self.s) ! self.assertRaises(PassThru, self.s.union_update, check_pass_thru()) ! self.assertRaises(TypeError, self.s.union_update, [[]]) def test_ior(self): --- 256,271 ---- self.assertRaises(KeyError, self.s.pop) ! def test_update(self): ! retval = self.s.update(self.otherword) self.assertEqual(retval, None) for c in (self.word + self.otherword): self.assert_(c in self.s) ! self.assertRaises(PassThru, self.s.update, check_pass_thru()) ! self.assertRaises(TypeError, self.s.update, [[]]) ! for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')): ! for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: ! s = self.thetype('abcba') ! self.assertEqual(s.update(C(p)), None) ! self.assertEqual(s, set(q)) def test_ior(self): *************** *** 255,258 **** --- 284,292 ---- self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru()) self.assertRaises(TypeError, self.s.intersection_update, [[]]) + for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')): + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + s = self.thetype('abcba') + self.assertEqual(s.intersection_update(C(p)), None) + self.assertEqual(s, set(q)) def test_iand(self): *************** *** 274,277 **** --- 308,317 ---- self.assertRaises(PassThru, self.s.difference_update, check_pass_thru()) self.assertRaises(TypeError, self.s.difference_update, [[]]) + self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) + for p, q in (('cdc', 'ab'), ('efgfe', 'abc'), ('ccb', 'a'), ('ef', 'abc')): + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + s = self.thetype('abcba') + self.assertEqual(s.difference_update(C(p)), None) + self.assertEqual(s, set(q)) def test_isub(self): *************** *** 293,296 **** --- 333,341 ---- self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru()) self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) + for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')): + for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple: + s = self.thetype('abcba') + self.assertEqual(s.symmetric_difference_update(C(p)), None) + self.assertEqual(s, set(q)) def test_ixor(self): *************** *** 636,640 **** def test_union_method_call(self): ! self.set.union_update(set([3, 4, 5])) self.assertEqual(self.set, set([2, 3, 4, 5, 6])) --- 681,685 ---- def test_union_method_call(self): ! self.set.update(set([3, 4, 5])) self.assertEqual(self.set, set([2, 3, 4, 5, 6])) *************** *** 762,774 **** def test_update_empty_tuple(self): ! self.set.union_update(()) self.assertEqual(self.set, set(self.values)) def test_update_unit_tuple_overlap(self): ! self.set.union_update(("a",)) self.assertEqual(self.set, set(self.values)) def test_update_unit_tuple_non_overlap(self): ! self.set.union_update(("a", "z")) self.assertEqual(self.set, set(self.values + ["z"])) --- 807,819 ---- def test_update_empty_tuple(self): ! self.set.update(()) self.assertEqual(self.set, set(self.values)) def test_update_unit_tuple_overlap(self): ! self.set.update(("a",)) self.assertEqual(self.set, set(self.values)) def test_update_unit_tuple_non_overlap(self): ! self.set.update(("a", "z")) self.assertEqual(self.set, set(self.values + ["z"])) *************** *** 873,877 **** self.assertRaises(TypeError, lambda: self.other >= self.set) ! def test_union_update_operator(self): try: self.set |= self.other --- 918,922 ---- self.assertRaises(TypeError, lambda: self.other >= self.set) ! def test_update_operator(self): try: self.set |= self.other *************** *** 881,889 **** self.fail("expected TypeError") ! def test_union_update(self): if self.otherIsIterable: ! self.set.union_update(self.other) else: ! self.assertRaises(TypeError, self.set.union_update, self.other) def test_union(self): --- 926,934 ---- self.fail("expected TypeError") ! def test_update(self): if self.otherIsIterable: ! self.set.update(self.other) else: ! self.assertRaises(TypeError, self.set.update, self.other) def test_union(self): *************** *** 1216,1220 **** def test_inplace_methods(self): for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'): ! for methname in ('union_update', 'intersection_update', 'difference_update', 'symmetric_difference_update'): for g in (G, I, Ig, S, L, R): --- 1261,1265 ---- def test_inplace_methods(self): for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'): ! for methname in ('update', 'intersection_update', 'difference_update', 'symmetric_difference_update'): for g in (G, I, Ig, S, L, R): From kbk at users.sourceforge.net Sun Nov 23 22:23:18 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Nov 23 22:23:22 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.25, 1.26 idlever.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv23682 Modified Files: NEWS.txt idlever.py Log Message: Update NEWS.txt to include some items missed earlier. Update the IDLE version to 1.1a0. Modified Files: NEWS.txt idlever.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** NEWS.txt 19 Nov 2003 04:52:32 -0000 1.25 --- NEWS.txt 24 Nov 2003 03:23:16 -0000 1.26 *************** *** 8,11 **** --- 8,14 ---- IDLEfork Patch 844675 + - IDLE now does not fail to save the file anymore if the Tk buffer is not a + Unicode string, yet eol_convention is. Python Bugs 774680, 788378 + - IDLE didn't start correctly when Python was installed in "Program Files" on W2K and XP. Python Bugs 780451, 784183 *************** *** 57,60 **** --- 60,73 ---- *Release date: 29-Jun-2003* + + - Extend AboutDialog.ViewFile() to support file encodings. Make the CREDITS + file Latin-1. + + - Updated the About dialog to reflect re-integration into Python. Provide + buttons to display Python's NEWS, License, and Credits, plus additional + buttons for IDLE's README and NEWS. + + - TextViewer() now has a third parameter which allows inserting text into the + viewer instead of reading from a file. - (Created the .../Lib/idlelib directory in the Python CVS, which is a clone of Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** idlever.py 27 Jul 2003 00:56:41 -0000 1.15 --- idlever.py 24 Nov 2003 03:23:16 -0000 1.16 *************** *** 1 **** ! IDLE_VERSION = "1.0" --- 1 ---- ! IDLE_VERSION = "1.1a0" From gvanrossum at users.sourceforge.net Sun Nov 23 23:02:16 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 23 23:02:19 2003 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv30810 Modified Files: gcmodule.c Log Message: Silence GCC warning when asserts are turned off. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** gcmodule.c 20 Nov 2003 21:21:46 -0000 2.74 --- gcmodule.c 24 Nov 2003 04:02:13 -0000 2.75 *************** *** 534,542 **** PyGC_Head *gc = wr_callbacks->gc.gc_next; PyObject *op = FROM_GC(gc); - PyWeakReference *wr = (PyWeakReference *)op; assert(IS_REACHABLE(op)); assert(PyWeakref_Check(op)); ! assert(wr->wr_callback != NULL); Py_DECREF(op); if (wr_callbacks->gc.gc_next == gc) { --- 534,541 ---- PyGC_Head *gc = wr_callbacks->gc.gc_next; PyObject *op = FROM_GC(gc); assert(IS_REACHABLE(op)); assert(PyWeakref_Check(op)); ! assert(((PyWeakReference *)op)->wr_callback != NULL); Py_DECREF(op); if (wr_callbacks->gc.gc_next == gc) { From gvanrossum at users.sourceforge.net Sun Nov 23 23:02:34 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 23 23:02:37 2003 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c, 2.71.10.1, 2.71.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv30852 Modified Files: Tag: release23-maint gcmodule.c Log Message: Silence GCC warning when asserts are turned off. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.71.10.1 retrieving revision 2.71.10.2 diff -C2 -d -r2.71.10.1 -r2.71.10.2 *** gcmodule.c 20 Nov 2003 22:13:51 -0000 2.71.10.1 --- gcmodule.c 24 Nov 2003 04:02:31 -0000 2.71.10.2 *************** *** 515,523 **** PyGC_Head *gc = wr_callbacks->gc.gc_next; PyObject *op = FROM_GC(gc); - PyWeakReference *wr = (PyWeakReference *)op; assert(IS_REACHABLE(op)); assert(PyWeakref_Check(op)); ! assert(wr->wr_callback != NULL); Py_DECREF(op); if (wr_callbacks->gc.gc_next == gc) { --- 515,522 ---- PyGC_Head *gc = wr_callbacks->gc.gc_next; PyObject *op = FROM_GC(gc); assert(IS_REACHABLE(op)); assert(PyWeakref_Check(op)); ! assert(((PyWeakReference *)op)->wr_callback != NULL); Py_DECREF(op); if (wr_callbacks->gc.gc_next == gc) { From gvanrossum at users.sourceforge.net Sun Nov 23 23:13:15 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 23 23:13:18 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv32176 Modified Files: setobject.c Log Message: Stop GCC warning about int literal that's so long that it becomes an unsigned int (on a 32-bit machine), by adding an explicit 'u' to the literal (a prime used to improve the hash function for frozenset). Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** setobject.c 24 Nov 2003 02:57:33 -0000 1.11 --- setobject.c 24 Nov 2003 04:13:13 -0000 1.12 *************** *** 728,732 **** elements with nearby hashes so that many distinct combinations collapse to only a handful of distinct hash values. */ ! hash ^= PyObject_Hash(item) * 3644798167; Py_DECREF(item); } --- 728,732 ---- elements with nearby hashes so that many distinct combinations collapse to only a handful of distinct hash values. */ ! hash ^= PyObject_Hash(item) * 3644798167u; Py_DECREF(item); } From jhylton at users.sourceforge.net Sun Nov 23 23:14:37 2003 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sun Nov 23 23:14:40 2003 Subject: [Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.54, 1.1.2.55 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv32293 Modified Files: Tag: ast-branch newcompile.c Log Message: Pass number of default arguments to MAKE_FUNCTION. Instead of the number of arguments. Index: newcompile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v retrieving revision 1.1.2.54 retrieving revision 1.1.2.55 diff -C2 -d -r1.1.2.54 -r1.1.2.55 *** newcompile.c 26 Aug 2003 01:21:13 -0000 1.1.2.54 --- newcompile.c 24 Nov 2003 04:14:34 -0000 1.1.2.55 *************** *** 715,719 **** /* XXX closure */ ADDOP_O(c, LOAD_CONST, (PyObject *)co, consts); ! ADDOP_I(c, MAKE_FUNCTION, c->u->u_argcount); if (!compiler_nameop(c, s->v.FunctionDef.name, Store)) return 0; --- 715,719 ---- /* XXX closure */ ADDOP_O(c, LOAD_CONST, (PyObject *)co, consts); ! ADDOP_I(c, MAKE_FUNCTION, asdl_seq_LEN(args->defaults)); if (!compiler_nameop(c, s->v.FunctionDef.name, Store)) return 0; From kbk at users.sourceforge.net Mon Nov 24 00:26:18 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Nov 24 00:26:23 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.26, 1.27 PyShell.py, 1.82, 1.83 config-keys.def, 1.19, 1.20 configHandler.py, 1.31, 1.32 keybindingDialog.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv8540 Modified Files: NEWS.txt PyShell.py config-keys.def configHandler.py keybindingDialog.py Log Message: Keybindings with the Shift modifier now work correctly. So do bindings which use the Space key. Limit unmodified user keybindings to the function keys. Python Bug 775353, IDLEfork Bugs 755647, 761557 Improve error handling during startup if there's no Tkinter. M NEWS.txt M PyShell.py M config-keys.def M configHandler.py M keybindingDialog.py Backport candidate. Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NEWS.txt 24 Nov 2003 03:23:16 -0000 1.26 --- NEWS.txt 24 Nov 2003 05:26:16 -0000 1.27 *************** *** 4,7 **** --- 4,11 ---- *Release date: XX-XXX-2003* + - Keybindings with the Shift modifier now work correctly. So do bindings which + use the Space key. Limit unmodified user keybindings to the function keys. + Python Bug 775353, IDLEfork Bugs 755647, 761557 + - After an exception, run.py was not setting the exception vector. Noam Raphael suggested correcting this so pdb's postmortem pm() would work. Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** PyShell.py 14 Aug 2003 14:54:28 -0000 1.82 --- PyShell.py 24 Nov 2003 05:26:16 -0000 1.83 *************** *** 17,21 **** from code import InteractiveInterpreter ! from Tkinter import * import tkMessageBox --- 17,26 ---- from code import InteractiveInterpreter ! try: ! from Tkinter import * ! except ImportError: ! print>>sys.__stderr__, "** IDLE can't import Tkinter. " \ ! "Your Python may not be configured for Tk. **" ! sys.exit(1) import tkMessageBox Index: config-keys.def =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-keys.def,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** config-keys.def 18 May 2003 02:21:55 -0000 1.19 --- config-keys.def 24 Nov 2003 05:26:16 -0000 1.20 *************** *** 31,38 **** plain-newline-and-indent= print-window= ! redo= remove-selection= ! save-copy-of-window-as-file= ! save-window-as-file= save-window= select-all= --- 31,38 ---- plain-newline-and-indent= print-window= ! redo= remove-selection= ! save-copy-of-window-as-file= ! save-window-as-file= save-window= select-all= *************** *** 79,83 **** print-window= python-docs= ! python-context-help= redo= remove-selection= --- 79,83 ---- print-window= python-docs= ! python-context-help= redo= remove-selection= *************** *** 129,135 **** plain-newline-and-indent= print-window= ! redo= remove-selection= ! save-window-as-file= save-window= save-copy-of-window-as-file= --- 129,135 ---- plain-newline-and-indent= print-window= ! redo= remove-selection= ! save-window-as-file= save-window= save-copy-of-window-as-file= Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** configHandler.py 27 Jan 2003 02:36:18 -0000 1.31 --- configHandler.py 24 Nov 2003 05:26:16 -0000 1.32 *************** *** 532,536 **** '<>': [''], '<>': [''], ! '<>': [''], '<>': [''], '<>': [''], --- 532,536 ---- '<>': [''], '<>': [''], ! '<>': [''], '<>': [''], '<>': [''], Index: keybindingDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/keybindingDialog.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** keybindingDialog.py 9 Jul 2003 18:48:24 -0000 1.11 --- keybindingDialog.py 24 Nov 2003 05:26:16 -0000 1.12 *************** *** 1,4 **** """ ! dialog for building tkinter accelerator key bindings """ from Tkinter import * --- 1,4 ---- """ ! Dialog for building Tkinter accelerator key bindings """ from Tkinter import * *************** *** 50,56 **** frameButtons=Frame(self) frameButtons.pack(side=BOTTOM,fill=X) ! self.buttonOk = Button(frameButtons,text='Ok', ! width=8,command=self.Ok) ! self.buttonOk.grid(row=0,column=0,padx=5,pady=5) self.buttonCancel = Button(frameButtons,text='Cancel', width=8,command=self.Cancel) --- 50,56 ---- frameButtons=Frame(self) frameButtons.pack(side=BOTTOM,fill=X) ! self.buttonOK = Button(frameButtons,text='OK', ! width=8,command=self.OK) ! self.buttonOK.grid(row=0,column=0,padx=5,pady=5) self.buttonCancel = Button(frameButtons,text='Cancel', width=8,command=self.Cancel) *************** *** 86,92 **** column += 1 labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT, ! text="Select the desired modifier\n"+ ! "keys above, and final key\n"+ ! "from the list on the right.") labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W) self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10, --- 86,96 ---- column += 1 labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT, ! text=\ ! "Select the desired modifier keys\n"+ ! "above, and the final key from the\n"+ ! "list on the right.\n\n" + ! "Use upper case Symbols when using\n" + ! "the Shift modifier. (Letters will be\n" + ! "converted automatically.)") labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W) self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10, *************** *** 103,107 **** labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT, text="Enter new binding(s) for '"+self.action+"' :\n"+ ! "(will not be checked for validity)") labelTitleAdvanced.pack(anchor=W) self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced, --- 107,111 ---- labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT, text="Enter new binding(s) for '"+self.action+"' :\n"+ ! "(These bindings will not be checked for validity!)") labelTitleAdvanced.pack(anchor=W) self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced, *************** *** 109,117 **** self.entryKeysAdvanced.pack(fill=X) labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT, ! text="Key bindings are specified using tkinter key id's as\n"+ "in these samples: , , ,\n" ! ", , .\n\n"+ ! "'Emacs style' multi-keystroke bindings are specified as\n"+ ! "follows: or .\n\n"+ "Multiple separate bindings for one action should be\n"+ "separated by a space, eg., ." ) --- 113,123 ---- self.entryKeysAdvanced.pack(fill=X) labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT, ! text="Key bindings are specified using Tkinter keysyms as\n"+ "in these samples: , , ,\n" ! ", , .\n" ! "Upper case is used when the Shift modifier is present!\n\n" + ! "'Emacs style' multi-keystroke bindings are specified as\n" + ! "follows: , where the first key\n" + ! "is the 'do-nothing' keybinding.\n\n" + "Multiple separate bindings for one action should be\n"+ "separated by a space, eg., ." ) *************** *** 150,167 **** def BuildKeyString(self): ! keyList=[] ! modifiers=self.GetModifiers() ! finalKey=self.listKeysFinal.get(ANCHOR) ! if modifiers: modifiers[0]='<'+modifiers[0] ! keyList=keyList+modifiers if finalKey: ! if (not modifiers) and (finalKey not ! in self.alphanumKeys+self.punctuationKeys): ! finalKey='<'+self.TranslateKey(finalKey) ! else: ! finalKey=self.TranslateKey(finalKey) ! keyList.append(finalKey+'>') ! keyStr=string.join(keyList,'-') ! self.keyString.set(keyStr) def GetModifiers(self): --- 156,165 ---- def BuildKeyString(self): ! keyList = modifiers = self.GetModifiers() ! finalKey = self.listKeysFinal.get(ANCHOR) if finalKey: ! finalKey = self.TranslateKey(finalKey, modifiers) ! keyList.append(finalKey) ! self.keyString.set('<' + string.join(keyList,'-') + '>') def GetModifiers(self): *************** *** 191,197 **** self.listKeysFinal.insert(END, *keys) ! def TranslateKey(self,key): ! #translate from key list value to tkinter key-id ! translateDict={'~':'asciitilde','!':'exclam','@':'at','#':'numbersign', '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', '(':'parenleft',')':'parenright','_':'underscore','-':'minus', --- 189,196 ---- self.listKeysFinal.insert(END, *keys) ! def TranslateKey(self, key, modifiers): ! "Translate from keycap symbol to the Tkinter keysym" ! translateDict = {'Space':'space', ! '~':'asciitilde','!':'exclam','@':'at','#':'numbersign', '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', '(':'parenleft',')':'parenright','_':'underscore','-':'minus', *************** *** 201,212 **** '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next', 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up', ! 'Down Arrow': 'Down'} if key in translateDict.keys(): ! key=translateDict[key] ! key='Key-'+key return key ! def Ok(self, event=None): ! if self.KeysOk(): self.result=self.keyString.get() self.destroy() --- 200,213 ---- '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next', 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up', ! 'Down Arrow': 'Down', 'Tab':'tab'} if key in translateDict.keys(): ! key = translateDict[key] ! if 'Shift' in modifiers and key in string.ascii_lowercase: ! key = key.upper() ! key = 'Key-' + key return key ! def OK(self, event=None): ! if self.KeysOK(): self.result=self.keyString.get() self.destroy() *************** *** 216,253 **** self.destroy() ! def KeysOk(self): ! #simple validity check ! keysOk=1 ! keys=self.keyString.get() keys.strip() ! finalKey=self.listKeysFinal.get(ANCHOR) ! modifiers=self.GetModifiers() ! keySequence=keys.split()#make into a key sequence list for overlap check ! if not keys: #no keys specified ! tkMessageBox.showerror(title='Key Sequence Error', ! message='No keys specified.') ! keysOk=0 ! elif not keys.endswith('>'): #no final key specified ! tkMessageBox.showerror(title='Key Sequence Error', ! message='No final key specified.') ! keysOk=0 ! elif (not modifiers) and (finalKey in ! self.alphanumKeys+self.punctuationKeys): ! #modifier required ! tkMessageBox.showerror(title='Key Sequence Error', ! message='No modifier key(s) specified.') ! keysOk=0 ! elif (modifiers==['Shift']) and (finalKey not ! in self.functionKeys+('Tab',)): ! #shift alone is only a useful modifier with a function key ! tkMessageBox.showerror(title='Key Sequence Error', ! message='Shift alone is not a useful modifier '+ ! 'when used with this final key key.') ! keysOk=0 ! elif keySequence in self.currentKeySequences: #keys combo already in use ! tkMessageBox.showerror(title='Key Sequence Error', ! message='This key combination is already in use.') ! keysOk=0 ! return keysOk if __name__ == '__main__': --- 217,253 ---- self.destroy() ! def KeysOK(self): ! "Validity check on user's keybinding selection" ! keys = self.keyString.get() keys.strip() ! finalKey = self.listKeysFinal.get(ANCHOR) ! modifiers = self.GetModifiers() ! # create a key sequence list for overlap check: ! keySequence = keys.split() ! keysOK = False ! title = 'Key Sequence Error' ! if not keys: ! tkMessageBox.showerror(title=title, parent=self, ! message='No keys specified.') ! elif not keys.endswith('>'): ! tkMessageBox.showerror(title=title, parent=self, ! message='Missing the final Key') ! elif not modifiers and finalKey not in self.functionKeys: ! tkMessageBox.showerror(title=title, parent=self, ! message='No modifier key(s) specified.') ! elif (modifiers == ['Shift']) \ ! and (finalKey not in ! self.functionKeys + ('Tab', 'Space')): ! msg = 'The shift modifier by itself may not be used with' \ ! ' this key symbol; only with F1-F12, Tab, or Space' ! tkMessageBox.showerror(title=title, parent=self, ! message=msg) ! elif keySequence in self.currentKeySequences: ! msg = 'This key combination is already in use.' ! tkMessageBox.showerror(title=title, parent=self, ! message=msg) ! else: ! keysOK = True ! return keysOK if __name__ == '__main__': From rhettinger at users.sourceforge.net Mon Nov 24 02:14:57 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 24 02:15:00 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv22504 Modified Files: whatsnew24.tex Log Message: Note the addition of set() and frozenset(). Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** whatsnew24.tex 20 Nov 2003 22:22:19 -0000 1.12 --- whatsnew24.tex 24 Nov 2003 07:14:54 -0000 1.13 *************** *** 26,29 **** --- 26,73 ---- rationale, refer to the PEP for a particular new feature. + %====================================================================== + \section{PEP 218: Built-In Set Objects} + + Two new built-in types, \function{set(iterable)} and + \function{frozenset(iterable)} provide high speed data types for + membership testing, for eliminating duplicates from sequences, and + for mathematical operations like unions, intersections, differences, + and symmetric differences. + + \begin{verbatim} + >>> a = set('abracadabra') # form a set from a string + >>> 'z' in a # fast membership testing + False + >>> a # unique letters in a + set(['a', 'r', 'b', 'c', 'd']) + >>> ''.join(a) # convert back into a string + 'arbcd' + >>> b = set('alacazam') # form a second set + >>> a - b # letters in a but not in b + set(['r', 'd', 'b']) + >>> a | b # letters in either a or b + set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l']) + >>> a & b # letters in both a and b + set(['a', 'c']) + >>> a ^ b # letters in a or b but not both + set(['r', 'd', 'b', 'm', 'z', 'l']) + >>> a.add('z') # add a new element + >>> a.update('wxy') # add multiple new elements + >>> a + set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'x', 'z']) + >>> a.remove('x') # take one element out + >>> a + set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'z']) + \end{verbatim} + + The type \function{frozenset()} is an immutable version of \function{set()}. + Since it is immutable and hashable, it may be used as a dictionary key or + as a member of another set. Accordingly, it does not have methods + like \method{add()} and \method{remove()} which could alter its contents. + + \begin{seealso} + \seepep{218}{Adding a Built-In Set Object Type}{Originally proposed by + Greg Wilson and ultimately implemented by Raymond Hettinger.} + \end{seealso} %====================================================================== From amk at amk.ca Mon Nov 24 07:29:25 2003 From: amk at amk.ca (A.M. Kuchling) Date: Mon Nov 24 07:30:06 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.25, 1.26 idlever.py, 1.15, 1.16 In-Reply-To: References: Message-ID: <20031124122925.GA13677@rogue.amk.ca> On Sun, Nov 23, 2003 at 07:23:18PM -0800, kbk@users.sourceforge.net wrote: > + - IDLE now does not fail to save the file anymore if the Tk buffer is not a > + Unicode string, yet eol_convention is. Python Bugs 774680, 788378 The above sentence is unfinished. --amk From guido at python.org Mon Nov 24 10:37:03 2003 From: guido at python.org (Guido van Rossum) Date: Mon Nov 24 10:37:08 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.25, 1.26 idlever.py, 1.15, 1.16 In-Reply-To: Your message of "Mon, 24 Nov 2003 07:29:25 EST." <20031124122925.GA13677@rogue.amk.ca> References: <20031124122925.GA13677@rogue.amk.ca> Message-ID: <200311241537.hAOFb3w09106@c-24-5-183-134.client.comcast.net> > On Sun, Nov 23, 2003 at 07:23:18PM -0800, kbk@users.sourceforge.net wrote: > > + - IDLE now does not fail to save the file anymore if the Tk buffer is not a > > + Unicode string, yet eol_convention is. Python Bugs 774680, 788378 > > The above sentence is unfinished. Not if you assume that the omitted part is "a Unicode string", which I think was intended. --Guido van Rossum (home page: http://www.python.org/~guido/) From kbk at shore.net Mon Nov 24 10:53:27 2003 From: kbk at shore.net (Kurt B. Kaiser) Date: Mon Nov 24 10:53:31 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.25, 1.26 idlever.py, 1.15, 1.16 References: <20031124122925.GA13677@rogue.amk.ca> Message-ID: "A.M. Kuchling" writes: > On Sun, Nov 23, 2003 at 07:23:18PM -0800, kbk@users.sourceforge.net wrote: >> + - IDLE now does not fail to save the file anymore if the Tk buffer is not a >> + Unicode string, yet eol_convention is. Python Bugs 774680, 788378 > > The above sentence is unfinished. See src/Misc/NEWS 1.831.4.3 Martin updated Python NEWS instead of IDLE NEWS.txt so I copied it over. -- KBK From rhettinger at users.sourceforge.net Mon Nov 24 17:18:51 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Nov 24 17:18:56 2003 Subject: [Python-checkins] python/dist/src/Objects setobject.c,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv32347 Modified Files: setobject.c Log Message: Factor out more duplicate code. Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** setobject.c 24 Nov 2003 04:13:13 -0000 1.12 --- setobject.c 24 Nov 2003 22:18:49 -0000 1.13 *************** *** 11,54 **** static PyObject * ! make_new_set(PyTypeObject *type, PyObject *iterable) { ! PyObject *data = NULL; ! PyObject *it = NULL; ! PyObject *item; ! PySetObject *so = NULL; ! /* Get iterator. */ ! if (iterable != NULL) { ! it = PyObject_GetIter(iterable); ! if (it == NULL) ! goto done; } ! data = PyDict_New(); ! if (data == NULL) ! goto done; ! while (it != NULL && (item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_True) == -1) { Py_DECREF(item); ! goto done; } Py_DECREF(item); } if (PyErr_Occurred()) ! goto done; /* create PySetObject structure */ so = (PySetObject *)type->tp_alloc(type, 0); ! if (so == NULL) ! goto done; ! ! Py_INCREF(data); so->data = data; so->hash = -1; ! done: ! Py_XDECREF(data); ! Py_XDECREF(it); return (PyObject *)so; } --- 11,75 ---- static PyObject * ! set_update(PySetObject *so, PyObject *other) { ! PyObject *item, *data, *it; ! if (PyAnySet_Check(other)) { ! if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 0) == -1) ! return NULL; ! Py_RETURN_NONE; } ! it = PyObject_GetIter(other); ! if (it == NULL) ! return NULL; ! data = so->data; ! while ((item = PyIter_Next(it)) != NULL) { if (PyDict_SetItem(data, item, Py_True) == -1) { + Py_DECREF(it); Py_DECREF(item); ! return NULL; } Py_DECREF(item); } + Py_DECREF(it); if (PyErr_Occurred()) ! return NULL; ! Py_RETURN_NONE; ! } ! ! PyDoc_STRVAR(update_doc, ! "Update a set with the union of itself and another."); ! ! static PyObject * ! make_new_set(PyTypeObject *type, PyObject *iterable) ! { ! PyObject *data = NULL; ! PyObject *tmp; ! PySetObject *so = NULL; ! ! data = PyDict_New(); ! if (data == NULL) ! return NULL; /* create PySetObject structure */ so = (PySetObject *)type->tp_alloc(type, 0); ! if (so == NULL) { ! Py_DECREF(data); ! return NULL; ! } so->data = data; so->hash = -1; ! if (iterable != NULL) { ! tmp = set_update(so, iterable); ! if (tmp == NULL) { ! Py_DECREF(so); ! return NULL; ! } ! Py_DECREF(tmp); ! } ! return (PyObject *)so; } *************** *** 124,128 **** result = PySequence_Contains(so->data, key); ! if (result == -1 && PyType_IsSubtype(key->ob_type, &PySet_Type)) { PyErr_Clear(); tmp = frozenset_dict_wrapper(((PySetObject *)(key))->data); --- 145,149 ---- result = PySequence_Contains(so->data, key); ! if (result == -1 && PyAnySet_Check(key)) { PyErr_Clear(); tmp = frozenset_dict_wrapper(((PySetObject *)(key))->data); *************** *** 138,156 **** set_copy(PySetObject *so) { ! PyObject *data; ! PySetObject *newso; ! ! data = PyDict_Copy(so->data); ! if (data == NULL) ! return NULL; ! ! newso = (PySetObject *)(so->ob_type->tp_alloc(so->ob_type, 0)); ! if (newso == NULL) { ! Py_DECREF(data); ! return NULL; ! } ! newso->data = data; ! newso->hash = so->hash; ! return (PyObject *)newso; } --- 159,163 ---- set_copy(PySetObject *so) { ! return make_new_set(so->ob_type, (PyObject *)so); } *************** *** 168,204 **** static PyObject * - set_union_update(PySetObject *so, PyObject *other) - { - PyObject *item, *data, *it; - - if (PyAnySet_Check(other)) { - if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 0) == -1) - return NULL; - Py_RETURN_NONE; - } - - it = PyObject_GetIter(other); - if (it == NULL) - return NULL; - data = so->data; - - while ((item = PyIter_Next(it)) != NULL) { - if (PyDict_SetItem(data, item, Py_True) == -1) { - Py_DECREF(it); - Py_DECREF(item); - return NULL; - } - Py_DECREF(item); - } - Py_DECREF(it); - if (PyErr_Occurred()) - return NULL; - Py_RETURN_NONE; - } - - PyDoc_STRVAR(union_update_doc, - "Update a set with the union of itself and another."); - - static PyObject * set_union(PySetObject *so, PyObject *other) { --- 175,178 ---- *************** *** 209,213 **** if (result == NULL) return NULL; ! rv = set_union_update(result, other); if (rv == NULL) { Py_DECREF(result); --- 183,187 ---- if (result == NULL) return NULL; ! rv = set_update(result, other); if (rv == NULL) { Py_DECREF(result); *************** *** 242,246 **** return Py_NotImplemented; } ! result = set_union_update(so, other); if (result == NULL) return NULL; --- 216,220 ---- return Py_NotImplemented; } ! result = set_update(so, other); if (result == NULL) return NULL; *************** *** 969,973 **** if (iterable == NULL) return 0; ! result = set_union_update(self, iterable); if (result != NULL) { Py_DECREF(result); --- 943,947 ---- if (iterable == NULL) return 0; ! result = set_update(self, iterable); if (result != NULL) { Py_DECREF(result); *************** *** 1025,1030 **** {"union", (PyCFunction)set_union, METH_O, union_doc}, ! {"update", (PyCFunction)set_union_update, METH_O, ! union_update_doc}, {NULL, NULL} /* sentinel */ }; --- 999,1004 ---- {"union", (PyCFunction)set_union, METH_O, union_doc}, ! {"update", (PyCFunction)set_update, METH_O, ! update_doc}, {NULL, NULL} /* sentinel */ }; From kbk at users.sourceforge.net Tue Nov 25 00:01:03 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Tue Nov 25 01:29:34 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib IOBinding.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv7431 Modified Files: IOBinding.py Log Message: Fix a typo introduced at 1.21 M IOBinding.py Backported to 23-maint Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IOBinding.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** IOBinding.py 3 Sep 2003 05:13:14 -0000 1.21 --- IOBinding.py 25 Nov 2003 05:01:00 -0000 1.22 *************** *** 30,34 **** import locale locale.setlocale(locale.LC_CTYPE, "") ! except (ImportError, locale.error): pass --- 30,34 ---- import locale locale.setlocale(locale.LC_CTYPE, "") ! except (ImportError, locale.Error): pass From kbk at users.sourceforge.net Tue Nov 25 00:06:59 2003 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Tue Nov 25 01:29:47 2003 Subject: [Python-checkins] python/dist/src/Lib/idlelib IOBinding.py, 1.19.8.2, 1.19.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1:/tmp/cvs-serv8575 Modified Files: Tag: release23-maint IOBinding.py Log Message: Fix a typo introduced at Rev 1.19.8.2 M IOBinding.py Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IOBinding.py,v retrieving revision 1.19.8.2 retrieving revision 1.19.8.3 diff -C2 -d -r1.19.8.2 -r1.19.8.3 *** IOBinding.py 3 Sep 2003 05:15:20 -0000 1.19.8.2 --- IOBinding.py 25 Nov 2003 05:06:56 -0000 1.19.8.3 *************** *** 30,34 **** import locale locale.setlocale(locale.LC_CTYPE, "") ! except (ImportError, locale.error): pass --- 30,34 ---- import locale locale.setlocale(locale.LC_CTYPE, "") ! except (ImportError, locale.Error): pass From fdrake at users.sourceforge.net Tue Nov 25 11:21:04 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Nov 25 11:21:23 2003 Subject: [Python-checkins] python/dist/src/Doc/tools buildindex.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1:/tmp/cvs-serv26766 Modified Files: buildindex.py Log Message: make the generated HTML more XHTML friendly Index: buildindex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/buildindex.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** buildindex.py 16 Oct 2002 15:27:01 -0000 1.13 --- buildindex.py 25 Nov 2003 16:21:00 -0000 1.14 *************** *** 8,11 **** --- 8,13 ---- import sys + from xml.sax.saxutils import quoteattr + bang_join = "!".join *************** *** 216,220 **** def format_column(nodes): ! strings = ["
"] append = strings.append level = 0 --- 218,222 ---- def format_column(nodes): ! strings = ["
"] append = strings.append level = 0 *************** *** 228,232 **** count = i + 1 if count > level: ! append("
" * (count - level) + "\n") level = count elif level > count: --- 230,234 ---- count = i + 1 if count > level: ! append("
" * (count - level) + "\n") level = count elif level > count: *************** *** 243,247 **** else: extra = "" ! append("\n
%s%s\n
\n%s
" % (term, extra, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" --- 245,249 ---- else: extra = "" ! append("\n
%s%s\n
\n%s
" % (term, extra, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" *************** *** 272,276 **** else: append(format_column(nodes)) - append("\n

\n") return null_join(strings) --- 274,277 ---- *************** *** 283,288 **** else: lettername = letter.capitalize() ! return "\n


\n

%s

\n\n" \ ! % (letter, lettername) --- 284,289 ---- else: lettername = letter.capitalize() ! return "\n
\n

%s

\n\n" \ ! % (quoteattr("letter-" + letter), lettername) *************** *** 295,299 **** s = "%s" % (letter, letter) items.append(s) ! s = ["
\n%s
\n" % " |\n".join(items)] for letter, nodes in letter_groups: s.append(format_letter(letter)) --- 296,300 ---- s = "%s" % (letter, letter) items.append(s) ! s = ["
\n%s
\n" % " |\n".join(items)] for letter, nodes in letter_groups: s.append(format_letter(letter)) From rhettinger at users.sourceforge.net Tue Nov 25 16:12:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:12:20 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.897,1.898 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv24958/Misc Modified Files: NEWS Log Message: Expose dict_contains() and PyDict_Contains() with is about 10% faster than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.897 retrieving revision 1.898 diff -C2 -d -r1.897 -r1.898 *** NEWS 22 Nov 2003 23:55:50 -0000 1.897 --- NEWS 25 Nov 2003 21:12:14 -0000 1.898 *************** *** 232,235 **** --- 232,239 ---- ----- + - Added a new function, PyDict_Contains(d, k) which is like + PySequence_Contains() but is specific to dictionaries and executes + about 10% faster. + - Added three new macros: Py_RETURN_NONE, Py_RETURN_TRUE, and Py_RETURN_FALSE. Each return the singleton they mention after Py_INCREF()ing them. From rhettinger at users.sourceforge.net Tue Nov 25 16:12:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:12:27 2003 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv24958/Doc/API Modified Files: concrete.tex Log Message: Expose dict_contains() and PyDict_Contains() with is about 10% faster than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** concrete.tex 10 Nov 2003 14:48:48 -0000 1.32 --- concrete.tex 25 Nov 2003 21:12:14 -0000 1.33 *************** *** 1809,1812 **** --- 1809,1820 ---- \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyDict_Contains}{PyObject *p, PyObject *key} + Determine if dictionary \var{p} contains \var{key}. If an item + in \var{p} is matches \var{key}, return \code{1}, otherwise return + \code{0}. On error, return \code{-1}. This is equivalent to the + Python expression \samp{\var{key} in \var{p}}. + \versionadded{2.4} + \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PyDict_Copy}{PyObject *p} Returns a new dictionary that contains the same key-value pairs as From rhettinger at users.sourceforge.net Tue Nov 25 16:12:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:12:32 2003 Subject: [Python-checkins] python/dist/src/Objects dictobject.c, 2.147, 2.148 setobject.c, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv24958/Objects Modified Files: dictobject.c setobject.c Log Message: Expose dict_contains() and PyDict_Contains() with is about 10% faster than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.147 retrieving revision 2.148 diff -C2 -d -r2.147 -r2.148 *** dictobject.c 1 Sep 2003 22:12:08 -0000 2.147 --- dictobject.c 25 Nov 2003 21:12:14 -0000 2.148 *************** *** 1815,1822 **** }; ! static int ! dict_contains(dictobject *mp, PyObject *key) { long hash; if (!PyString_CheckExact(key) || --- 1815,1823 ---- }; ! int ! PyDict_Contains(PyObject *op, PyObject *key) { long hash; + dictobject *mp = (dictobject *)op; if (!PyString_CheckExact(key) || *************** *** 1838,1842 **** 0, /* sq_ass_item */ 0, /* sq_ass_slice */ ! (objobjproc)dict_contains, /* sq_contains */ 0, /* sq_inplace_concat */ 0, /* sq_inplace_repeat */ --- 1839,1843 ---- 0, /* sq_ass_item */ 0, /* sq_ass_slice */ ! (objobjproc)PyDict_Contains, /* sq_contains */ 0, /* sq_inplace_concat */ 0, /* sq_inplace_repeat */ Index: setobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** setobject.c 24 Nov 2003 22:18:49 -0000 1.13 --- setobject.c 25 Nov 2003 21:12:14 -0000 1.14 *************** *** 144,148 **** int result; ! result = PySequence_Contains(so->data, key); if (result == -1 && PyAnySet_Check(key)) { PyErr_Clear(); --- 144,148 ---- int result; ! result = PyDict_Contains(so->data, key); if (result == -1 && PyAnySet_Check(key)) { PyErr_Clear(); *************** *** 150,154 **** if (tmp == NULL) return -1; ! result = PySequence_Contains(so->data, tmp); Py_DECREF(tmp); } --- 150,154 ---- if (tmp == NULL) return -1; ! result = PyDict_Contains(so->data, tmp); Py_DECREF(tmp); } *************** *** 253,257 **** while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); --- 253,257 ---- while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_Contains(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); *************** *** 293,297 **** selfdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_SetItem(newdict, item, Py_True) == -1) { Py_DECREF(newdict); --- 293,297 ---- selfdata = so->data; while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_Contains(selfdata, item)) { if (PyDict_SetItem(newdict, item, Py_True) == -1) { Py_DECREF(newdict); *************** *** 376,380 **** while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_XDECREF(otherset); --- 376,380 ---- while ((item = PyIter_Next(it)) != NULL) { ! if (!PyDict_Contains(otherdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_XDECREF(otherset); *************** *** 482,486 **** while ((item = PyIter_Next(it)) != NULL) { ! if (PySequence_Contains(selfdata, item)) { if (PyDict_DelItem(selfdata, item) == -1) { Py_XDECREF(otherset); --- 482,486 ---- while ((item = PyIter_Next(it)) != NULL) { ! if (PyDict_Contains(selfdata, item)) { if (PyDict_DelItem(selfdata, item) == -1) { Py_XDECREF(otherset); *************** *** 542,546 **** } while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); --- 542,546 ---- } while ((item = PyIter_Next(it)) != NULL) { ! if (!PyDict_Contains(selfdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); *************** *** 563,567 **** } while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); --- 563,567 ---- } while ((item = PyIter_Next(it)) != NULL) { ! if (!PyDict_Contains(otherdata, item)) { if (PyDict_SetItem(tgtdata, item, Py_True) == -1) { Py_DECREF(it); *************** *** 635,639 **** otherdata = ((PySetObject *)other)->data; while ((item = PyIter_Next(it)) != NULL) { ! if (!PySequence_Contains(otherdata, item)) { Py_DECREF(it); Py_DECREF(item); --- 635,639 ---- otherdata = ((PySetObject *)other)->data; while ((item = PyIter_Next(it)) != NULL) { ! if (!PyDict_Contains(otherdata, item)) { Py_DECREF(it); Py_DECREF(item); From rhettinger at users.sourceforge.net Tue Nov 25 16:12:16 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:12:37 2003 Subject: [Python-checkins] python/dist/src/Include dictobject.h,2.27,2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1:/tmp/cvs-serv24958/Include Modified Files: dictobject.h Log Message: Expose dict_contains() and PyDict_Contains() with is about 10% faster than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous. Index: dictobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/dictobject.h,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -d -r2.27 -r2.28 *** dictobject.h 3 May 2003 06:51:58 -0000 2.27 --- dictobject.h 25 Nov 2003 21:12:14 -0000 2.28 *************** *** 101,104 **** --- 101,105 ---- PyAPI_FUNC(int) PyDict_Size(PyObject *mp); PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); + PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ From rhettinger at users.sourceforge.net Tue Nov 25 16:20:44 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:20:59 2003 Subject: [Python-checkins] python/nondist/sandbox/rational Rational.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/rational In directory sc8-pr-cvs1:/tmp/cvs-serv26901 Modified Files: Rational.py Log Message: SF patch #848793: Rational bug (Submitted by Oren Tirosh) * Fix a cut-and-paste typo. Index: Rational.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/rational/Rational.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Rational.py 27 Mar 2001 16:50:10 -0000 1.1 --- Rational.py 25 Nov 2003 21:20:42 -0000 1.2 *************** *** 419,423 **** if isinstance(n, type(1.0)): n = _float_to_ratio(n) ! if isinstance(n, type(1.0)): d = _float_to_ratio(d) for arg in (n, d): --- 419,423 ---- if isinstance(n, type(1.0)): n = _float_to_ratio(n) ! if isinstance(d, type(1.0)): d = _float_to_ratio(d) for arg in (n, d): From rhettinger at users.sourceforge.net Tue Nov 25 16:48:24 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Nov 25 16:48:30 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.153,1.154 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv32452 Modified Files: libfuncs.tex Log Message: As discussed on python-dev, banish apply(), buffer(), coerce(), and intern() to a separate region in the docs. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** libfuncs.tex 18 Nov 2003 19:48:57 -0000 1.153 --- libfuncs.tex 25 Nov 2003 21:48:21 -0000 1.154 *************** *** 61,84 **** \end{funcdesc} - \begin{funcdesc}{apply}{function, args\optional{, keywords}} - The \var{function} argument must be a callable object (a - user-defined or built-in function or method, or a class object) and - the \var{args} argument must be a sequence. The \var{function} is - called with \var{args} as the argument list; the number of arguments - is the length of the tuple. - If the optional \var{keywords} argument is present, it must be a - dictionary whose keys are strings. It specifies keyword arguments - to be added to the end of the argument list. - Calling \function{apply()} is different from just calling - \code{\var{function}(\var{args})}, since in that case there is always - exactly one argument. The use of \function{apply()} is equivalent - to \code{\var{function}(*\var{args}, **\var{keywords})}. - Use of \function{apply()} is not necessary since the ``extended call - syntax,'' as used in the last example, is completely equivalent. - - \deprecated{2.3}{Use the extended call syntax instead, as described - above.} - \end{funcdesc} - \begin{funcdesc}{basestring}{} This abstract type is the superclass for \class{str} and \class{unicode}. --- 61,64 ---- *************** *** 105,118 **** \end{funcdesc} - \begin{funcdesc}{buffer}{object\optional{, offset\optional{, size}}} - The \var{object} argument must be an object that supports the buffer - call interface (such as strings, arrays, and buffers). A new buffer - object will be created which references the \var{object} argument. - The buffer object will be a slice from the beginning of \var{object} - (or from the specified \var{offset}). The slice will extend to the - end of \var{object} (or will have a length given by the \var{size} - argument). - \end{funcdesc} - \begin{funcdesc}{callable}{object} Return true if the \var{object} argument appears callable, false if --- 85,88 ---- *************** *** 163,172 **** \end{funcdesc} - \begin{funcdesc}{coerce}{x, y} - Return a tuple consisting of the two numeric arguments converted to - a common type, using the same rules as used by arithmetic - operations. - \end{funcdesc} - \begin{funcdesc}{compile}{string, filename, kind\optional{, flags\optional{, dont_inherit}}} --- 133,136 ---- *************** *** 583,601 **** \end{funcdesc} - \begin{funcdesc}{intern}{string} - Enter \var{string} in the table of ``interned'' strings and return - the interned string -- which is \var{string} itself or a copy. - Interning strings is useful to gain a little performance on - dictionary lookup -- if the keys in a dictionary are interned, and - the lookup key is interned, the key comparisons (after hashing) can - be done by a pointer compare instead of a string compare. Normally, - the names used in Python programs are automatically interned, and - the dictionaries used to hold module, class or instance attributes - have interned keys. \versionchanged[Interned strings are not - immortal (like they used to be in Python 2.2 and before); - you must keep a reference to the return value of \function{intern()} - around to benefit from it]{2.3} - \end{funcdesc} - \begin{funcdesc}{isinstance}{object, classinfo} Return true if the \var{object} argument is an instance of the --- 547,550 ---- *************** *** 1116,1118 **** --- 1065,1135 ---- and \code{zip()} raised a \exception{TypeError} instead of returning \code{[]}]{2.4} + \end{funcdesc} + + + % --------------------------------------------------------------------------- + + + \section{Non-essential Built-in Functions \label{non-essential-built-in-funcs}} + + There are several built-in functions that are no longer essential to learn, + know or use in modern Python programming. They have been kept here to + maintain backwards compatability with programs written for older versions + of Python. + + Python programmers, trainers, students and bookwriters should feel free to + bypass these functions without concerns about missing something important. + + + \setindexsubitem{(non-essential built-in functions)} + + \begin{funcdesc}{apply}{function, args\optional{, keywords}} + The \var{function} argument must be a callable object (a + user-defined or built-in function or method, or a class object) and + the \var{args} argument must be a sequence. The \var{function} is + called with \var{args} as the argument list; the number of arguments + is the length of the tuple. + If the optional \var{keywords} argument is present, it must be a + dictionary whose keys are strings. It specifies keyword arguments + to be added to the end of the argument list. + Calling \function{apply()} is different from just calling + \code{\var{function}(\var{args})}, since in that case there is always + exactly one argument. The use of \function{apply()} is equivalent + to \code{\var{function}(*\var{args}, **\var{keywords})}. + Use of \function{apply()} is not necessary since the ``extended call + syntax,'' as used in the last example, is completely equivalent. + + \deprecated{2.3}{Use the extended call syntax instead, as described + above.} + \end{funcdesc} + + \begin{funcdesc}{buffer}{object\optional{, offset\optional{, size}}} + The \var{object} argument must be an object that supports the buffer + call interface (such as strings, arrays, and buffers). A new buffer + object will be created which references the \var{object} argument. + The buffer object will be a slice from the beginning of \var{object} + (or from the specified \var{offset}). The slice will extend to the + end of \var{object} (or will have a length given by the \var{size} + argument). + \end{funcdesc} + + \begin{funcdesc}{coerce}{x, y} + Return a tuple consisting of the two numeric arguments converted to + a common type, using the same rules as used by arithmetic + operations. + \end{funcdesc} + + \begin{funcdesc}{intern}{string} + Enter \var{string} in the table of ``interned'' strings and return + the interned string -- which is \var{string} itself or a copy. + Interning strings is useful to gain a little performance on + dictionary lookup -- if the keys in a dictionary are interned, and + the lookup key is interned, the key comparisons (after hashing) can + be done by a pointer compare instead of a string compare. Normally, + the names used in Python programs are automatically interned, and + the dictionaries used to hold module, class or instance attributes + have interned keys. \versionchanged[Interned strings are not + immortal (like they used to be in Python 2.2 and before); + you must keep a reference to the return value of \function{intern()} + around to benefit from it]{2.3} \end{funcdesc} From rhettinger at users.sourceforge.net Wed Nov 26 03:21:37 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 03:21:41 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.898,1.899 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv11053/Misc Modified Files: NEWS Log Message: Add optional fillchar argument to ljust(), rjust(), and center() string methods. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.898 retrieving revision 1.899 diff -C2 -d -r1.898 -r1.899 *** NEWS 25 Nov 2003 21:12:14 -0000 1.898 --- NEWS 26 Nov 2003 08:21:34 -0000 1.899 *************** *** 13,16 **** --- 13,20 ---- ----------------- + - For str and unicode objects, the ljust(), center(), and rjust() + methods now accept an optional argument specifying a fill + character other than a space. + - When method objects have an attribute that can be satisfied either by the function object or by the method object, the function From rhettinger at users.sourceforge.net Wed Nov 26 03:21:38 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 03:21:47 2003 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.212, 2.213 unicodeobject.c, 2.201, 2.202 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv11053/Objects Modified Files: stringobject.c unicodeobject.c Log Message: Add optional fillchar argument to ljust(), rjust(), and center() string methods. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.212 retrieving revision 2.213 diff -C2 -d -r2.212 -r2.213 *** stringobject.c 22 Oct 2003 02:56:39 -0000 2.212 --- stringobject.c 26 Nov 2003 08:21:35 -0000 2.213 *************** *** 2618,2625 **** PyDoc_STRVAR(ljust__doc__, ! "S.ljust(width) -> string\n" "\n" "Return S left justified in a string of length width. Padding is\n" ! "done using spaces."); static PyObject * --- 2618,2625 ---- PyDoc_STRVAR(ljust__doc__, ! "S.ljust(width[, fillchar]) -> string\n" "\n" "Return S left justified in a string of length width. Padding is\n" ! "done using the specified fill character (default is a space)."); static PyObject * *************** *** 2627,2631 **** { int width; ! if (!PyArg_ParseTuple(args, "i:ljust", &width)) return NULL; --- 2627,2633 ---- { int width; ! char fillchar = ' '; ! ! if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &fillchar)) return NULL; *************** *** 2635,2647 **** } ! return pad(self, 0, width - PyString_GET_SIZE(self), ' '); } PyDoc_STRVAR(rjust__doc__, ! "S.rjust(width) -> string\n" "\n" "Return S right justified in a string of length width. Padding is\n" ! "done using spaces."); static PyObject * --- 2637,2649 ---- } ! return pad(self, 0, width - PyString_GET_SIZE(self), fillchar); } PyDoc_STRVAR(rjust__doc__, ! "S.rjust(width[, fillchar]) -> string\n" "\n" "Return S right justified in a string of length width. Padding is\n" ! "done using the specified fill character (default is a space)"); static PyObject * *************** *** 2649,2653 **** { int width; ! if (!PyArg_ParseTuple(args, "i:rjust", &width)) return NULL; --- 2651,2657 ---- { int width; ! char fillchar = ' '; ! ! if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &fillchar)) return NULL; *************** *** 2657,2669 **** } ! return pad(self, width - PyString_GET_SIZE(self), 0, ' '); } PyDoc_STRVAR(center__doc__, ! "S.center(width) -> string\n" "\n" ! "Return S centered in a string of length width. Padding is done\n" ! "using spaces."); static PyObject * --- 2661,2673 ---- } ! return pad(self, width - PyString_GET_SIZE(self), 0, fillchar); } PyDoc_STRVAR(center__doc__, ! "S.center(width[, fillchar]) -> string\n" "\n" ! "Return S centered in a string of length width. Padding is\n" ! "done using the specified fill character (default is a space)"); static PyObject * *************** *** 2672,2677 **** int marg, left; int width; ! if (!PyArg_ParseTuple(args, "i:center", &width)) return NULL; --- 2676,2682 ---- int marg, left; int width; + char fillchar = ' '; ! if (!PyArg_ParseTuple(args, "i|c:center", &width, &fillchar)) return NULL; *************** *** 2684,2688 **** left = marg / 2 + (marg & width & 1); ! return pad(self, left, marg - left, ' '); } --- 2689,2693 ---- left = marg / 2 + (marg & width & 1); ! return pad(self, left, marg - left, fillchar); } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.201 retrieving revision 2.202 diff -C2 -d -r2.201 -r2.202 *** unicodeobject.c 24 Oct 2003 14:25:28 -0000 2.201 --- unicodeobject.c 26 Nov 2003 08:21:35 -0000 2.202 *************** *** 4405,4413 **** #endif PyDoc_STRVAR(center__doc__, ! "S.center(width) -> unicode\n\ \n\ ! Return S centered in a Unicode string of length width. Padding is done\n\ ! using spaces."); static PyObject * --- 4405,4440 ---- #endif + /* Argument converter. Coerces to a single unicode character */ + + static int + convert_uc(PyObject *obj, void *addr) + { + Py_UNICODE *fillcharloc = (Py_UNICODE *)addr; + PyObject *uniobj; + Py_UNICODE *unistr; + + uniobj = PyUnicode_FromObject(obj); + if (uniobj == NULL) { + PyErr_SetString(PyExc_TypeError, + "The fill character cannot be converted to Unicode"); + return 0; + } + if (PyUnicode_GET_SIZE(uniobj) != 1) { + PyErr_SetString(PyExc_TypeError, + "The fill character must be exactly one character long"); + Py_DECREF(uniobj); + return 0; + } + unistr = PyUnicode_AS_UNICODE(uniobj); + *fillcharloc = unistr[0]; + Py_DECREF(uniobj); + return 1; + } + PyDoc_STRVAR(center__doc__, ! "S.center(width[, fillchar]) -> unicode\n\ \n\ ! Return S centered in a Unicode string of length width. Padding is\n\ ! done using the specified fill character (default is a space)"); static PyObject * *************** *** 4416,4421 **** int marg, left; int width; ! if (!PyArg_ParseTuple(args, "i:center", &width)) return NULL; --- 4443,4449 ---- int marg, left; int width; + Py_UNICODE fillchar = ' '; ! if (!PyArg_ParseTuple(args, "i|O&:center", &width, convert_uc, &fillchar)) return NULL; *************** *** 4428,4432 **** left = marg / 2 + (marg & width & 1); ! return (PyObject*) pad(self, left, marg - left, ' '); } --- 4456,4460 ---- left = marg / 2 + (marg & width & 1); ! return (PyObject*) pad(self, left, marg - left, fillchar); } *************** *** 5171,5178 **** PyDoc_STRVAR(ljust__doc__, ! "S.ljust(width) -> unicode\n\ \n\ Return S left justified in a Unicode string of length width. Padding is\n\ ! done using spaces."); static PyObject * --- 5199,5206 ---- PyDoc_STRVAR(ljust__doc__, ! "S.ljust(width[, fillchar]) -> unicode\n\ \n\ Return S left justified in a Unicode string of length width. Padding is\n\ ! done using the specified fill character (default is a space)."); static PyObject * *************** *** 5180,5184 **** { int width; ! if (!PyArg_ParseTuple(args, "i:ljust", &width)) return NULL; --- 5208,5214 ---- { int width; ! Py_UNICODE fillchar = ' '; ! ! if (!PyArg_ParseTuple(args, "i|O&:ljust", &width, convert_uc, &fillchar)) return NULL; *************** *** 5188,5192 **** } ! return (PyObject*) pad(self, 0, width - self->length, ' '); } --- 5218,5222 ---- } ! return (PyObject*) pad(self, 0, width - self->length, fillchar); } *************** *** 5553,5560 **** PyDoc_STRVAR(rjust__doc__, ! "S.rjust(width) -> unicode\n\ \n\ Return S right justified in a Unicode string of length width. Padding is\n\ ! done using spaces."); static PyObject * --- 5583,5590 ---- PyDoc_STRVAR(rjust__doc__, ! "S.rjust(width[, fillchar]) -> unicode\n\ \n\ Return S right justified in a Unicode string of length width. Padding is\n\ ! done using the specified fill character (default is a space)."); static PyObject * *************** *** 5562,5566 **** { int width; ! if (!PyArg_ParseTuple(args, "i:rjust", &width)) return NULL; --- 5592,5598 ---- { int width; ! Py_UNICODE fillchar = ' '; ! ! if (!PyArg_ParseTuple(args, "i|O&:rjust", &width, convert_uc, &fillchar)) return NULL; *************** *** 5570,5574 **** } ! return (PyObject*) pad(self, width - self->length, 0, ' '); } --- 5602,5606 ---- } ! return (PyObject*) pad(self, width - self->length, 0, fillchar); } From rhettinger at users.sourceforge.net Wed Nov 26 03:22:05 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 03:22:09 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.141, 1.142 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv11053/Doc/lib Modified Files: libstdtypes.tex Log Message: Add optional fillchar argument to ljust(), rjust(), and center() string methods. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** libstdtypes.tex 24 Nov 2003 02:57:33 -0000 1.141 --- libstdtypes.tex 26 Nov 2003 08:21:32 -0000 1.142 *************** *** 547,553 **** \end{methoddesc} ! \begin{methoddesc}[string]{center}{width} Return centered in a string of length \var{width}. Padding is done ! using spaces. \end{methoddesc} --- 547,553 ---- \end{methoddesc} ! \begin{methoddesc}[string]{center}{width\optional{, fillchar}} Return centered in a string of length \var{width}. Padding is done ! using the specified \var{fillchar} (default is a space). \end{methoddesc} *************** *** 646,652 **** \end{methoddesc} ! \begin{methoddesc}[string]{ljust}{width} Return the string left justified in a string of length \var{width}. ! Padding is done using spaces. The original string is returned if \var{width} is less than \code{len(\var{s})}. \end{methoddesc} --- 646,653 ---- \end{methoddesc} ! \begin{methoddesc}[string]{ljust}{width\optional{, fillchar}} Return the string left justified in a string of length \var{width}. ! Padding is done using the specified \var{fillchar} (default is a ! space). The original string is returned if \var{width} is less than \code{len(\var{s})}. \end{methoddesc} *************** *** 684,690 **** \end{methoddesc} ! \begin{methoddesc}[string]{rjust}{width} Return the string right justified in a string of length \var{width}. ! Padding is done using spaces. The original string is returned if \var{width} is less than \code{len(\var{s})}. \end{methoddesc} --- 685,692 ---- \end{methoddesc} ! \begin{methoddesc}[string]{rjust}{width\optional{, fillchar}} Return the string right justified in a string of length \var{width}. ! Padding is done using the specified \var{fillchar} (default is a space). ! The original string is returned if \var{width} is less than \code{len(\var{s})}. \end{methoddesc} From rhettinger at users.sourceforge.net Wed Nov 26 03:22:06 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 03:22:15 2003 Subject: [Python-checkins] python/dist/src/Lib UserString.py, 1.18, 1.19 string.py, 1.69, 1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv11053/Lib Modified Files: UserString.py string.py Log Message: Add optional fillchar argument to ljust(), rjust(), and center() string methods. Index: UserString.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** UserString.py 27 Aug 2003 10:48:12 -0000 1.18 --- UserString.py 26 Nov 2003 08:21:33 -0000 1.19 *************** *** 61,65 **** # the following methods are defined in alphabetical order: def capitalize(self): return self.__class__(self.data.capitalize()) ! def center(self, width): return self.__class__(self.data.center(width)) def count(self, sub, start=0, end=sys.maxint): return self.data.count(sub, start, end) --- 61,66 ---- # the following methods are defined in alphabetical order: def capitalize(self): return self.__class__(self.data.capitalize()) ! def center(self, width, *args): ! return self.__class__(self.data.center(width, *args)) def count(self, sub, start=0, end=sys.maxint): return self.data.count(sub, start, end) *************** *** 98,102 **** def isupper(self): return self.data.isupper() def join(self, seq): return self.data.join(seq) ! def ljust(self, width): return self.__class__(self.data.ljust(width)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) --- 99,104 ---- def isupper(self): return self.data.isupper() def join(self, seq): return self.data.join(seq) ! def ljust(self, width, *args): ! 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)) *************** *** 107,111 **** def rindex(self, sub, start=0, end=sys.maxint): return self.data.rindex(sub, start, end) ! def rjust(self, width): return self.__class__(self.data.rjust(width)) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=-1): --- 109,114 ---- def rindex(self, sub, start=0, end=sys.maxint): return self.data.rindex(sub, start, end) ! def rjust(self, width, *args): ! return self.__class__(self.data.rjust(width, *args)) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=-1): Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** string.py 3 Oct 2003 14:05:26 -0000 1.69 --- string.py 26 Nov 2003 08:21:33 -0000 1.70 *************** *** 238,272 **** # Left-justify a string ! def ljust(s, width): ! """ljust(s, width) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is ! never truncated. """ ! return s.ljust(width) # Right-justify a string ! def rjust(s, width): ! """rjust(s, width) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is ! never truncated. """ ! return s.rjust(width) # Center a string ! def center(s, width): ! """center(s, width) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never ! truncated. """ ! return s.center(width) # Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03' --- 238,272 ---- # Left-justify a string ! def ljust(s, width, *args): ! """ljust(s, width[, fillchar]) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is ! never truncated. If specified the fillchar is used instead of spaces. """ ! return s.ljust(width, *args) # Right-justify a string ! def rjust(s, width, *args): ! """rjust(s, width[, fillchar]) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is ! never truncated. If specified the fillchar is used instead of spaces. """ ! return s.rjust(width, *args) # Center a string ! def center(s, width, *args): ! """center(s, width[, fillchar]) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never ! truncated. If specified the fillchar is used instead of spaces. """ ! return s.center(width, *args) # Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03' From rhettinger at users.sourceforge.net Wed Nov 26 03:22:06 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 03:22:19 2003 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv11053/Lib/test Modified Files: string_tests.py Log Message: Add optional fillchar argument to ljust(), rjust(), and center() string methods. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** string_tests.py 27 Aug 2003 04:55:52 -0000 1.33 --- string_tests.py 26 Nov 2003 08:21:34 -0000 1.34 *************** *** 228,232 **** self.checkequal('abc', 'abc', 'ljust', 3) self.checkequal('abc', 'abc', 'ljust', 2) ! self.checkraises(TypeError, 'abc', 'ljust') --- 228,232 ---- self.checkequal('abc', 'abc', 'ljust', 3) self.checkequal('abc', 'abc', 'ljust', 2) ! self.checkequal('abc*******', 'abc', 'ljust', 10, '*') self.checkraises(TypeError, 'abc', 'ljust') *************** *** 236,240 **** self.checkequal('abc', 'abc', 'rjust', 3) self.checkequal('abc', 'abc', 'rjust', 2) ! self.checkraises(TypeError, 'abc', 'rjust') --- 236,240 ---- self.checkequal('abc', 'abc', 'rjust', 3) self.checkequal('abc', 'abc', 'rjust', 2) ! self.checkequal('*******abc', 'abc', 'rjust', 10, '*') self.checkraises(TypeError, 'abc', 'rjust') *************** *** 244,248 **** self.checkequal('abc', 'abc', 'center', 3) self.checkequal('abc', 'abc', 'center', 2) ! self.checkraises(TypeError, 'abc', 'center') --- 244,248 ---- self.checkequal('abc', 'abc', 'center', 3) self.checkequal('abc', 'abc', 'center', 2) ! self.checkequal('***abc****', 'abc', 'center', 10, '*') self.checkraises(TypeError, 'abc', 'center') From nnorwitz at users.sourceforge.net Wed Nov 26 09:54:58 2003 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Nov 26 09:55:02 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.142, 1.143 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv17248/Doc/lib Modified Files: libstdtypes.tex Log Message: Add version changed doc for addition of fillchar to ljust/rjust/center Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** libstdtypes.tex 26 Nov 2003 08:21:32 -0000 1.142 --- libstdtypes.tex 26 Nov 2003 14:54:56 -0000 1.143 *************** *** 550,553 **** --- 550,554 ---- Return centered in a string of length \var{width}. Padding is done using the specified \var{fillchar} (default is a space). + \versionchanged[Support for the \var{fillchar} argument]{2.4} \end{methoddesc} *************** *** 651,654 **** --- 652,656 ---- space). The original string is returned if \var{width} is less than \code{len(\var{s})}. + \versionchanged[Support for the \var{fillchar} argument]{2.4} \end{methoddesc} *************** *** 690,693 **** --- 692,696 ---- The original string is returned if \var{width} is less than \code{len(\var{s})}. + \versionchanged[Support for the \var{fillchar} argument]{2.4} \end{methoddesc} From rhettinger at users.sourceforge.net Wed Nov 26 12:52:47 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 12:52:50 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.154, 1.155 libsets.tex, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv21903/lib Modified Files: libfuncs.tex libsets.tex Log Message: Nits from a review of the documentation update. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** libfuncs.tex 25 Nov 2003 21:48:21 -0000 1.154 --- libfuncs.tex 26 Nov 2003 17:52:45 -0000 1.155 *************** *** 1064,1068 **** \versionchanged[Formerly, \function{zip()} required at least one argument and \code{zip()} raised a \exception{TypeError} instead of returning ! \code{[]}]{2.4} \end{funcdesc} --- 1064,1068 ---- \versionchanged[Formerly, \function{zip()} required at least one argument and \code{zip()} raised a \exception{TypeError} instead of returning ! an empty list.]{2.4} \end{funcdesc} Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libsets.tex 16 Nov 2003 13:44:19 -0000 1.14 --- libsets.tex 26 Nov 2003 17:52:45 -0000 1.15 *************** *** 92,96 **** \end{tableiii} ! Note, this non-operator versions of \method{union()}, \method{intersection()}, \method{difference()}, and \method{symmetric_difference()} will accept any iterable as an argument. --- 92,96 ---- \end{tableiii} ! Note, the non-operator versions of \method{union()}, \method{intersection()}, \method{difference()}, and \method{symmetric_difference()} will accept any iterable as an argument. *************** *** 159,166 **** \end{tableiii} ! \versionchanged[Earlier versions had an \method{update()} method; use ! \method{union_update()} instead]{2.3.1} ! ! Note, this non-operator versions of \method{union_update()}, \method{intersection_update()}, \method{difference_update()}, and \method{symmetric_difference_update()} will accept any iterable as --- 159,163 ---- \end{tableiii} ! Note, the non-operator versions of \method{union_update()}, \method{intersection_update()}, \method{difference_update()}, and \method{symmetric_difference_update()} will accept any iterable as From rhettinger at users.sourceforge.net Wed Nov 26 12:52:48 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 12:52:56 2003 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.211,1.212 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1:/tmp/cvs-serv21903/tut Modified Files: tut.tex Log Message: Nits from a review of the documentation update. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.211 retrieving revision 1.212 diff -C2 -d -r1.211 -r1.212 *** tut.tex 18 Nov 2003 17:50:34 -0000 1.211 --- tut.tex 26 Nov 2003 17:52:45 -0000 1.212 *************** *** 2162,2170 **** When looping through dictionaries, the key and corresponding value can ! be retrieved at the same time using the \method{items()} method. \begin{verbatim} >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} ! >>> for k, v in knights.items(): ... print k, v ... --- 2162,2170 ---- When looping through dictionaries, the key and corresponding value can ! be retrieved at the same time using the \method{iteritems()} method. \begin{verbatim} >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} ! >>> for k, v in knights.iteritems(): ... print k, v ... *************** *** 3958,3962 **** \section{Random Remarks \label{remarks}} ! [These should perhaps be placed more carefully...] --- 3958,3962 ---- \section{Random Remarks \label{remarks}} ! % [These should perhaps be placed more carefully...] From rhettinger at users.sourceforge.net Wed Nov 26 12:52:48 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Nov 26 12:53:01 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv21903/whatsnew Modified Files: whatsnew24.tex Log Message: Nits from a review of the documentation update. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** whatsnew24.tex 24 Nov 2003 07:14:54 -0000 1.13 --- whatsnew24.tex 26 Nov 2003 17:52:45 -0000 1.14 *************** *** 13,17 **** This article explains the new features in Python 2.4. No release date ! for Python 2.4 has been set; expect that this will happen in 2004. While Python 2.3 was primarily a library development release, Python --- 13,17 ---- This article explains the new features in Python 2.4. No release date ! for Python 2.4 has been set; expect that this will happen mid-2004. While Python 2.3 was primarily a library development release, Python *************** *** 43,46 **** --- 43,47 ---- >>> ''.join(a) # convert back into a string 'arbcd' + >>> b = set('alacazam') # form a second set >>> a - b # letters in a but not in b *************** *** 52,55 **** --- 53,57 ---- >>> a ^ b # letters in a or b but not both set(['r', 'd', 'b', 'm', 'z', 'l']) + >>> a.add('z') # add a new element >>> a.update('wxy') # add multiple new elements *************** *** 116,119 **** --- 118,126 ---- \begin{itemize} + + \item The string methods, \method{ljust()}, \method{rjust()}, and + \method{center()} now take a optional argument for specifying a + fill character other than a space. + \item The \method{sort()} method of lists gained three keyword arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments *************** *** 186,193 **** >>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged [9,7,8,3,2,4,1,6,5] >>> list.sorted('Monte Python') # any iterable may be an input [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5) - >>> # Lists the contents of the dict sorted by key values >>> for k, v in list.sorted(colormap.iteritems()): ... print k, v --- 193,202 ---- >>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged [9,7,8,3,2,4,1,6,5] + >>> list.sorted('Monte Python') # any iterable may be an input [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] + + >>> # List the contents of a dict sorted by key values >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5) >>> for k, v in list.sorted(colormap.iteritems()): ... print k, v *************** *** 203,207 **** \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} exception if called with no arguments. This makes the functions more suitable for use with variable length argument lists: --- 212,216 ---- \item The \function{zip()} built-in function and \function{itertools.izip()} ! now returns an empty list instead of raising a \exception{TypeError} exception if called with no arguments. This makes the functions more suitable for use with variable length argument lists: *************** *** 297,300 **** --- 306,315 ---- objN)}, constructs tuples from a variable length argument list of Python objects. + + \item A new function, \function{PyDict_Contains(d, k)}, implements + fast dictionary lookups without masking exceptions raised during + the loop-up process (compare with \function{PySequence_Contains()} + which is slower or \function{PyMapping_HasKey()} which clears all + exceptions). \end{itemize} From akuchling at users.sourceforge.net Wed Nov 26 13:03:50 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Nov 26 13:03:53 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv24589 Modified Files: whatsnew24.tex Log Message: Fix typos Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** whatsnew24.tex 26 Nov 2003 17:52:45 -0000 1.14 --- whatsnew24.tex 26 Nov 2003 18:03:48 -0000 1.15 *************** *** 120,124 **** \item The string methods, \method{ljust()}, \method{rjust()}, and ! \method{center()} now take a optional argument for specifying a fill character other than a space. --- 120,124 ---- \item The string methods, \method{ljust()}, \method{rjust()}, and ! \method{center()} now take an optional argument for specifying a fill character other than a space. *************** *** 212,216 **** \item The \function{zip()} built-in function and \function{itertools.izip()} ! now returns an empty list instead of raising a \exception{TypeError} exception if called with no arguments. This makes the functions more suitable for use with variable length argument lists: --- 212,216 ---- \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} exception if called with no arguments. This makes the functions more suitable for use with variable length argument lists: From akuchling at users.sourceforge.net Wed Nov 26 13:05:28 2003 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Nov 26 13:05:31 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1:/tmp/cvs-serv25039 Modified Files: whatsnew24.tex Log Message: Fix typo and mark-up; shorten text Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** whatsnew24.tex 26 Nov 2003 18:03:48 -0000 1.15 --- whatsnew24.tex 26 Nov 2003 18:05:26 -0000 1.16 *************** *** 307,315 **** Python objects. ! \item A new function, \function{PyDict_Contains(d, k)}, implements ! fast dictionary lookups without masking exceptions raised during ! the loop-up process (compare with \function{PySequence_Contains()} ! which is slower or \function{PyMapping_HasKey()} which clears all ! exceptions). \end{itemize} --- 307,313 ---- Python objects. ! \item A new function, \cfunction{PyDict_Contains(d, k)}, implements ! fast dictionary lookups without masking exceptions raised during the ! look-up process. \end{itemize} From fdrake at acm.org Wed Nov 26 13:40:31 2003 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed Nov 26 13:40:43 2003 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.13, 1.14 In-Reply-To: References: Message-ID: <16324.62367.318560.119195@grendel.zope.com> rhettinger@users.sourceforge.net writes: > Nits from a review of the documentation update. These too have been quietly pushed to the website. -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From fdrake at users.sourceforge.net Wed Nov 26 15:55:51 2003 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Nov 26 15:55:54 2003 Subject: [Python-checkins] python/dist/src/Doc/perl python.perl,1.142,1.143 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory sc8-pr-cvs1:/tmp/cvs-serv29784 Modified Files: python.perl Log Message: - clean up generated HTML - make the output more XHTML friendly Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** python.perl 5 Sep 2003 15:43:58 -0000 1.142 --- python.perl 26 Nov 2003 20:55:49 -0000 1.143 *************** *** 346,350 **** my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("PEP $rfcnumber$icon" . $_); } --- 346,350 ---- my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("PEP $rfcnumber$icon" . $_); } *************** *** 359,363 **** my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("" . "RFC $rfcnumber$icon" . $_); } --- 359,363 ---- my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("" . "RFC $rfcnumber$icon" . $_); } *************** *** 511,518 **** } ! sub new_link_info(){ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ""; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $aname, $ahref); } --- 511,524 ---- } ! sub new_link_name_info(){ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ""; my $ahref = gen_link($CURRENT_FILE, $name); + return ($name, $ahref); + } + + sub new_link_info(){ + my($name, $ahref) = new_link_name_info(); + my $aname = ""; return ($name, $aname, $ahref); } *************** *** 739,745 **** sub make_str_index_entry($){ my $str = $_[0]; ! my($name, $aname, $ahref) = new_link_info(); add_index_entry($str, $ahref); ! return "$aname$str"; } --- 745,758 ---- sub make_str_index_entry($){ my $str = $_[0]; ! my($name, $ahref) = new_link_name_info(); add_index_entry($str, $ahref); ! if ($str =~ /^<[a-z]+\b/) { ! my $s = "$str"; ! $s =~ s/^<([a-z]+)\b/<$1 id='$name'/; ! return $s; ! } ! else { ! return "$str"; ! } } *************** *** 818,822 **** $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"} = $target; return ("\n" ! . " " . "$token\n" . "  ::= \n" --- 831,835 ---- $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"} = $target; return ("\n" ! . " " . "$token\n" . "  ::= \n" From loewis at users.sourceforge.net Thu Nov 27 14:40:24 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 27 14:40:28 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.899,1.900 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv3034/Misc Modified Files: NEWS Log Message: Patch #849595: Add socket.shutdown() constants. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.899 retrieving revision 1.900 diff -C2 -d -r1.899 -r1.900 *** NEWS 26 Nov 2003 08:21:34 -0000 1.899 --- NEWS 27 Nov 2003 19:40:22 -0000 1.900 *************** *** 96,99 **** --- 96,101 ---- ----------------- + - socket.SHUT_{RD,WR,RDWR} was added. + - os.getsid was added. From loewis at users.sourceforge.net Thu Nov 27 14:40:24 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 27 14:40:34 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.77,1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3034/Doc/lib Modified Files: libsocket.tex Log Message: Patch #849595: Add socket.shutdown() constants. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** libsocket.tex 5 Aug 2003 03:51:24 -0000 1.77 --- libsocket.tex 27 Nov 2003 19:40:21 -0000 1.78 *************** *** 639,644 **** \begin{methoddesc}[socket]{shutdown}{how} Shut down one or both halves of the connection. If \var{how} is ! \code{0}, further receives are disallowed. If \var{how} is \code{1}, ! further sends are disallowed. If \var{how} is \code{2}, further sends and receives are disallowed. \end{methoddesc} --- 639,644 ---- \begin{methoddesc}[socket]{shutdown}{how} Shut down one or both halves of the connection. If \var{how} is ! \constant{SHUT_RD}, further receives are disallowed. If \var{how} is \constant{SHUT_WR}, ! further sends are disallowed. If \var{how} is \constant{SHUT_RDWR}, further sends and receives are disallowed. \end{methoddesc} From loewis at users.sourceforge.net Thu Nov 27 14:40:24 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 27 14:40:39 2003 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.278, 1.279 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv3034/Modules Modified Files: socketmodule.c Log Message: Patch #849595: Add socket.shutdown() constants. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.278 retrieving revision 1.279 diff -C2 -d -r1.278 -r1.279 *** socketmodule.c 19 Nov 2003 22:52:23 -0000 1.278 --- socketmodule.c 27 Nov 2003 19:40:22 -0000 1.279 *************** *** 2098,2103 **** "shutdown(flag)\n\ \n\ ! Shut down the reading side of the socket (flag == 0), the writing side\n\ ! of the socket (flag == 1), or both ends (flag == 2)."); --- 2098,2103 ---- "shutdown(flag)\n\ \n\ ! Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\ ! of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR)."); *************** *** 4100,4103 **** --- 4100,4126 ---- #ifdef NI_DGRAM PyModule_AddIntConstant(m, "NI_DGRAM", NI_DGRAM); + #endif + + /* shutdown() parameters */ + #ifdef SHUT_RD + PyModule_AddIntConstant(m, "SHUT_RD", SHUT_RD); + #elif defined(SD_RECEIVE) + PyModule_AddIntConstant(m, "SHUT_RD", SD_RECEIVE); + #else + PyModule_AddIntConstant(m, "SHUT_RD", 0); + #endif + #ifdef SHUT_WR + PyModule_AddIntConstant(m, "SHUT_WR", SHUT_WR); + #elif defined(SD_SEND) + PyModule_AddIntConstant(m, "SHUT_WR", SD_SEND); + #else + PyModule_AddIntConstant(m, "SHUT_WR", 1); + #endif + #ifdef SHUT_RDWR + PyModule_AddIntConstant(m, "SHUT_RDWR", SHUT_RDWR); + #elif defined(SD_BOTH) + PyModule_AddIntConstant(m, "SHUT_RDWR", SD_BOTH); + #else + PyModule_AddIntConstant(m, "SHUT_RDWR", 2); #endif From loewis at users.sourceforge.net Thu Nov 27 14:43:14 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 27 14:43:17 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex, 1.17.8.1, 1.17.8.2 liboperator.tex, 1.27.12.1, 1.27.12.2 libpprint.tex, 1.15, 1.15.18.1 libweakref.tex, 1.19.8.2, 1.19.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3697 Modified Files: Tag: release23-maint libdoctest.tex liboperator.tex libpprint.tex libweakref.tex Log Message: Patch #849350: Update to document bool return values. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.17.8.1 retrieving revision 1.17.8.2 diff -C2 -d -r1.17.8.1 -r1.17.8.2 *** libdoctest.tex 11 Aug 2003 23:43:04 -0000 1.17.8.1 --- libdoctest.tex 27 Nov 2003 19:43:12 -0000 1.17.8.2 *************** *** 412,416 **** \begin{verbatim} >>> foo() == {"Hermione": "hippogryph", "Harry": "broomstick"} ! 1 >>> \end{verbatim} --- 412,416 ---- \begin{verbatim} >>> foo() == {"Hermione": "hippogryph", "Harry": "broomstick"} ! True >>> \end{verbatim} Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.27.12.1 retrieving revision 1.27.12.2 diff -C2 -d -r1.27.12.1 -r1.27.12.2 *** liboperator.tex 2 Nov 2003 09:52:38 -0000 1.27.12.1 --- liboperator.tex 27 Nov 2003 19:43:12 -0000 1.27.12.2 *************** *** 250,254 **** >>> o = C() >>> operator.isMappingType(o) ! 1 \end{verbatim} --- 250,254 ---- >>> o = C() >>> operator.isMappingType(o) ! True \end{verbatim} Index: libpprint.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpprint.tex,v retrieving revision 1.15 retrieving revision 1.15.18.1 diff -C2 -d -r1.15 -r1.15.18.1 *** libpprint.tex 2 Apr 2002 05:08:35 -0000 1.15 --- libpprint.tex 27 Nov 2003 19:43:12 -0000 1.15.18.1 *************** *** 112,116 **** \begin{verbatim} >>> pprint.isreadable(stuff) ! 0 \end{verbatim} \end{funcdesc} --- 112,116 ---- \begin{verbatim} >>> pprint.isreadable(stuff) ! False \end{verbatim} \end{funcdesc} Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.19.8.2 retrieving revision 1.19.8.3 diff -C2 -d -r1.19.8.2 -r1.19.8.3 *** libweakref.tex 21 Nov 2003 22:21:19 -0000 1.19.8.2 --- libweakref.tex 27 Nov 2003 19:43:12 -0000 1.19.8.3 *************** *** 187,191 **** >>> o2 = r() >>> o is o2 ! 1 \end{verbatim} --- 187,191 ---- >>> o2 = r() >>> o is o2 ! True \end{verbatim} From loewis at users.sourceforge.net Thu Nov 27 14:48:05 2003 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Nov 27 14:48:09 2003 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex, 1.18, 1.19 liboperator.tex, 1.28, 1.29 libpprint.tex, 1.15, 1.16 libweakref.tex, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv4619 Modified Files: libdoctest.tex liboperator.tex libpprint.tex libweakref.tex Log Message: Patch #849350: Update to document bool return values. Backported to 2.3. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** libdoctest.tex 12 Aug 2003 00:01:15 -0000 1.18 --- libdoctest.tex 27 Nov 2003 19:48:03 -0000 1.19 *************** *** 412,416 **** \begin{verbatim} >>> foo() == {"Hermione": "hippogryph", "Harry": "broomstick"} ! 1 >>> \end{verbatim} --- 412,416 ---- \begin{verbatim} >>> foo() == {"Hermione": "hippogryph", "Harry": "broomstick"} ! True >>> \end{verbatim} Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** liboperator.tex 2 Nov 2003 09:50:56 -0000 1.28 --- liboperator.tex 27 Nov 2003 19:48:03 -0000 1.29 *************** *** 250,254 **** >>> o = C() >>> operator.isMappingType(o) ! 1 \end{verbatim} --- 250,254 ---- >>> o = C() >>> operator.isMappingType(o) ! True \end{verbatim} Index: libpprint.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpprint.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libpprint.tex 2 Apr 2002 05:08:35 -0000 1.15 --- libpprint.tex 27 Nov 2003 19:48:03 -0000 1.16 *************** *** 112,116 **** \begin{verbatim} >>> pprint.isreadable(stuff) ! 0 \end{verbatim} \end{funcdesc} --- 112,116 ---- \begin{verbatim} >>> pprint.isreadable(stuff) ! False \end{verbatim} \end{funcdesc} Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** libweakref.tex 21 Nov 2003 22:20:57 -0000 1.20 --- libweakref.tex 27 Nov 2003 19:48:03 -0000 1.21 *************** *** 187,191 **** >>> o2 = r() >>> o is o2 ! 1 \end{verbatim} --- 187,191 ---- >>> o2 = r() >>> o is o2 ! True \end{verbatim} From jackjansen at users.sourceforge.net Thu Nov 27 17:08:10 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 17:08:14 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist README.txt, 1.1, 1.1.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1:/tmp/cvs-serv30478 Modified Files: Tag: release23-maint README.txt Log Message: Backported from the trunk. Index: README.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/README.txt,v retrieving revision 1.1 retrieving revision 1.1.10.1 diff -C2 -d -r1.1 -r1.1.10.1 *** README.txt 21 Mar 2003 23:52:36 -0000 1.1 --- README.txt 27 Nov 2003 22:08:08 -0000 1.1.10.1 *************** *** 1,3 **** ! This is a set of build scripts and such for MacPython-OSX 2.3 that I ! will use until there are standard distributions from Jack. --- 1,49 ---- ! Building a MacPython distribution ! ================================= ! ! The ``build`` shell script here creates MacPython distributions. ! 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 the stuff in ``resources`` and compresses that installer as a ! ``.dmg`` disk image. ! ! Here are the steps you ned to follow to build a MacPython installer: ! ! - There are various version numbers that need to be updated. Weed through ! ``Mac/OSXResources``, ``Mac/scripts`` and ``Mac/Tools`` and inspect the ! various ``.plist`` and ``.strings`` files. Note that the latter are ! UTF-16 files. ! - Edit ``resource/ReadMe.txt`` and ``resources/Welcome.rtf`` to reflect ! version number and such. ! - Edit ``build`` to change ``PYVERSION``, ``PYVER`` and ``BUILDNUM``. ! - Run ``./build``. Optionally you can pass the name of the directory ! where Python will be built, so you don't have to wait for the complete ! build when you're debugging the process. For the final distribution use ! a clean build. ! - When done the script will tell you where the DMG image is. ! ! Currently (November 2003) there is still a bug in the build procedure ! for $DESTROOT builds: building some of the applets will fail (in ! ``Mac/OSX/Makefile``) if you don't have the same version of Python installed ! normally. So before doing the distribution you should build and install ! a framework Python in the normal way. + When all is done, announcements can be posted to at least the following + places: + - pythonmac-sig@python.org + - python-dev@python.org + - python-announce@python.org + - archivist@info-mac.org + - adcnews@apple.com + - news@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@oratrix.com) + - http://www.macshareware.net (userid jackjansen) + + Also, check out Stephan Deibels http://pythonology.org/market contact list + + After all this is done you may also need to update the Package Manager + database for the new distribution. A description of this remains TBD. From jackjansen at users.sourceforge.net Thu Nov 27 17:53:00 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 17:53:04 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist README.txt, 1.1.10.1, 1.1.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1:/tmp/cvs-serv5315 Modified Files: Tag: release23-maint README.txt Log Message: Added preliminary notes on creating the MacPython for Panther additions distributions. Index: README.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/README.txt,v retrieving revision 1.1.10.1 retrieving revision 1.1.10.2 diff -C2 -d -r1.1.10.1 -r1.1.10.2 *** README.txt 27 Nov 2003 22:08:08 -0000 1.1.10.1 --- README.txt 27 Nov 2003 22:52:58 -0000 1.1.10.2 *************** *** 48,49 **** --- 48,77 ---- After all this is done you may also need to update the Package Manager database for the new distribution. A description of this remains TBD. + + Building a MacPython Panther Additions distribution + =================================================== + + *warning*: this section has not been debugged yet. + + Note that this procedure is completely independent from building a minor + Python release: a minor Python release will be called something like + 2.3.3, a new release of the MacPython Panther additions will be called + something like "third build of MacPython 2.3 additions for Panther". + This is because the additions will not include the 2.3.3 fixes: the Python + core installation is in ``/System`` and cannot be touched. + + If you have made changes to PythonIDE or Package Manager that you want + to include in the additions distribution you need to include the changed + source files in the ``Resources`` folder of the ``.app`` bundle, where they + will override the source files installed into the Python framework installed + by Apple. You can do this in ``../Makefile.panther``, see how ``PythonIDEMain.py`` + is included in the IDE for an example. It is not pretty but it works. + + Next, make sure your ``/Library/Python/2.3`` directory, which is where + ``site-packages`` points, is empty. Having ``_tkinter`` in there will + erronously include IDLE in the installer. + + Now, edit ``resources.panther`` and ``build.panther``. See above for what to + change. + + There is probably more to come here. From jackjansen at users.sourceforge.net Thu Nov 27 17:54:30 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 17:54:33 2003 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1:/tmp/cvs-serv5596 Modified Files: Makefile Log Message: the "idle" script has moved from Lib/idlelib to Tools/scripts. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Makefile 19 Nov 2003 13:56:40 -0000 1.52 --- Makefile 27 Nov 2003 22:54:28 -0000 1.53 *************** *** 158,167 **** --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib \ ! $(srcdir)/Lib/idlelib/idle ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \ ! $(srcdir)/Lib/idlelib/idle ; \ fi --- 158,167 ---- --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib \ ! $(srcdir)/Tools/scripts/idle ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \ ! $(srcdir)/Tools/scripts/idle ; \ fi From jackjansen at users.sourceforge.net Thu Nov 27 17:55:42 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 17:55:46 2003 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1:/tmp/cvs-serv5706 Modified Files: pimp.py Log Message: 2.4a0 Package Manager shouldn't attempt to use the 2.3 database. Things will definitely change before 2.4, but for now use a slightly different URL. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** pimp.py 21 Jul 2003 20:47:11 -0000 1.27 --- pimp.py 27 Nov 2003 22:55:39 -0000 1.28 *************** *** 45,49 **** DEFAULT_BUILDDIR='/tmp' DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib() ! DEFAULT_PIMPDATABASE="http://www.python.org/packman/version-0.3/%s.plist" % distutils.util.get_platform() def _cmd(output, dir, *cmditems): --- 45,49 ---- DEFAULT_BUILDDIR='/tmp' DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib() ! DEFAULT_PIMPDATABASE="http://www.python.org/packman/version-0.3/24a0-%s.plist" % distutils.util.get_platform() def _cmd(output, dir, *cmditems): From jackjansen at users.sourceforge.net Thu Nov 27 18:12:19 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 18:12:22 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv8344 Modified Files: PackageManager.py Log Message: Package Mnager error dialogs could refer to hidden packages, which was confusing. To be on the safe side we always show hidden packages before showing error dialogs. Will backport. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PackageManager.py 19 Nov 2003 13:45:26 -0000 1.15 --- PackageManager.py 27 Nov 2003 23:12:17 -0000 1.16 *************** *** 422,425 **** --- 422,430 ---- def showmessages(self, messages): if messages: + # To be on the safe side we always show the hidden packages, + # they may be referred to in the error messages. + if not self.w.hidden_button.get(): + self.w.hidden_button.set(1) + self.updatestatus() if type(messages) == list: messages = '\n'.join(messages) From jackjansen at users.sourceforge.net Thu Nov 27 18:12:39 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 18:12:41 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.14.4.1, 1.14.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv8509 Modified Files: Tag: release23-maint PackageManager.py Log Message: Package Mnager error dialogs could refer to hidden packages, which was confusing. To be on the safe side we always show hidden packages before showing error dialogs. Backport of 1.16. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.14.4.1 retrieving revision 1.14.4.2 diff -C2 -d -r1.14.4.1 -r1.14.4.2 *** PackageManager.py 2 Nov 2003 01:11:09 -0000 1.14.4.1 --- PackageManager.py 27 Nov 2003 23:12:37 -0000 1.14.4.2 *************** *** 422,425 **** --- 422,430 ---- def showmessages(self, messages): if messages: + # To be on the safe side we always show the hidden packages, + # they may be referred to in the error messages. + if not self.w.hidden_button.get(): + self.w.hidden_button.set(1) + self.updatestatus() if type(messages) == list: messages = '\n'.join(messages) From jackjansen at users.sourceforge.net Thu Nov 27 18:19:36 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 18:19:39 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv9343 Modified Files: PackageManager.py Log Message: Fix (workaround, actually) for bug #844676: deselecting "show hidden" can cause an index error. We now select the first package if this threatens to happen. Will backport. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PackageManager.py 27 Nov 2003 23:12:17 -0000 1.16 --- PackageManager.py 27 Nov 2003 23:19:33 -0000 1.17 *************** *** 384,387 **** --- 384,389 ---- else: sel = sel[0] + if sel >= len(self.packages): + sel = 0 self.w.packagebrowser.setselection([sel]) installed, message = self.getstatus(sel) From jackjansen at users.sourceforge.net Thu Nov 27 18:20:08 2003 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Nov 27 18:22:05 2003 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.14.4.2, 1.14.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1:/tmp/cvs-serv9606 Modified Files: Tag: release23-maint PackageManager.py Log Message: Fix (workaround, actually) for bug #844676: deselecting "show hidden" can cause an index error. We now select the first package if this threatens to happen. Backport of 1.17. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.14.4.2 retrieving revision 1.14.4.3 diff -C2 -d -r1.14.4.2 -r1.14.4.3 *** PackageManager.py 27 Nov 2003 23:12:37 -0000 1.14.4.2 --- PackageManager.py 27 Nov 2003 23:20:06 -0000 1.14.4.3 *************** *** 384,387 **** --- 384,389 ---- else: sel = sel[0] + if sel >= len(self.packages): + sel = 0 self.w.packagebrowser.setselection([sel]) installed, message = self.getstatus(sel) From theller at users.sourceforge.net Fri Nov 28 14:35:51 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 28 14:35:59 2003 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.57, 1.57.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1:/tmp/cvs-serv12888 Modified Files: Tag: release23-maint msvccompiler.py Log Message: See SF #848614: distutils' msvccompiler now tries to detect that MSVC6 is installed but the registry settings are incomplete because the gui has never been run. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.57 retrieving revision 1.57.6.1 diff -C2 -d -r1.57 -r1.57.6.1 *** msvccompiler.py 17 Jul 2003 14:41:07 -0000 1.57 --- msvccompiler.py 28 Nov 2003 19:35:48 -0000 1.57.6.1 *************** *** 548,551 **** --- 548,561 ---- else: return string.split(d[path], ";") + # MSVC 6 seems to create the registry entries we need only when + # the GUI is run. + if self.__version == 6: + for base in HKEYS: + if read_values(base, r"%s\6.0" % self.__root) is not None: + self.warn("It seems you have Visual Studio 6 installed, " + "but the expected registry settings are not present.\n" + "You must at least run the Visual Studio GUI once " + "so that these entries are created.") + break return [] From theller at users.sourceforge.net Fri Nov 28 14:36:03 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 28 14:36:07 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.76,1.831.4.77 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv12914 Modified Files: Tag: release23-maint NEWS Log Message: See SF #848614: distutils' msvccompiler now tries to detect that MSVC6 is installed but the registry settings are incomplete because the gui has never been run. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.76 retrieving revision 1.831.4.77 diff -C2 -d -r1.831.4.76 -r1.831.4.77 *** NEWS 20 Nov 2003 22:13:50 -0000 1.831.4.76 --- NEWS 28 Nov 2003 19:35:58 -0000 1.831.4.77 *************** *** 64,69 **** ------- - Patch #841977: modulefinder didn't find extension modules ! in packages - Bug #792101: Add missing file operations for httplib.SSLFile. --- 64,72 ---- ------- + - Bug #848614: distutils' msvccompiler fails to find the MSVC because + of incomplete registry entries. + - Patch #841977: modulefinder didn't find extension modules ! in packages. - Bug #792101: Add missing file operations for httplib.SSLFile. From theller at users.sourceforge.net Fri Nov 28 14:42:53 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 28 14:42:56 2003 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.57, 1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1:/tmp/cvs-serv14040 Modified Files: msvccompiler.py Log Message: See SF #848614: distutils' msvccompiler now tries to detect that MSVC6 is installed but the registry settings are incomplete because the gui has never been run. Already backported to release23-maint. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** msvccompiler.py 17 Jul 2003 14:41:07 -0000 1.57 --- msvccompiler.py 28 Nov 2003 19:42:51 -0000 1.58 *************** *** 548,551 **** --- 548,561 ---- else: return string.split(d[path], ";") + # MSVC 6 seems to create the registry entries we need only when + # the GUI is run. + if self.__version == 6: + for base in HKEYS: + if read_values(base, r"%s\6.0" % self.__root) is not None: + self.warn("It seems you have Visual Studio 6 installed, " + "but the expected registry settings are not present.\n" + "You must at least run the Visual Studio GUI once " + "so that these entries are created.") + break return [] From theller at users.sourceforge.net Fri Nov 28 14:42:58 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 28 14:43:02 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.900,1.901 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv14051 Modified Files: NEWS Log Message: See SF #848614: distutils' msvccompiler now tries to detect that MSVC6 is installed but the registry settings are incomplete because the gui has never been run. Already backported to release23-maint. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.900 retrieving revision 1.901 diff -C2 -d -r1.900 -r1.901 *** NEWS 27 Nov 2003 19:40:22 -0000 1.900 --- NEWS 28 Nov 2003 19:42:56 -0000 1.901 *************** *** 147,150 **** --- 147,153 ---- ------- + - Bug #848614: distutils' msvccompiler fails to find the MSVC6 + compiler because of incomplete registry entries. + - httplib.HTTP.putrequest now offers to omit the implicit Accept-Encoding. From theller at users.sourceforge.net Fri Nov 28 14:45:04 2003 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Nov 28 14:45:36 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.77,1.831.4.78 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv14379 Modified Files: Tag: release23-maint NEWS Log Message: I think this description of bug #848614 is better. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.77 retrieving revision 1.831.4.78 diff -C2 -d -r1.831.4.77 -r1.831.4.78 *** NEWS 28 Nov 2003 19:35:58 -0000 1.831.4.77 --- NEWS 28 Nov 2003 19:45:02 -0000 1.831.4.78 *************** *** 64,69 **** ------- ! - Bug #848614: distutils' msvccompiler fails to find the MSVC because ! of incomplete registry entries. - Patch #841977: modulefinder didn't find extension modules --- 64,69 ---- ------- ! - Bug #848614: distutils' msvccompiler fails to find the MSVC6 ! compiler because of incomplete registry entries. - Patch #841977: modulefinder didn't find extension modules From rhettinger at users.sourceforge.net Fri Nov 28 16:43:04 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 28 16:43:09 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_sort.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv3998/Lib/test Modified Files: test_sort.py Log Message: Make sure the list.sort's decorate step unwinds itself before returning an exception raised by the key function. (Suggested by Michael Hudson.) Index: test_sort.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sort.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_sort.py 16 Nov 2003 16:17:48 -0000 1.7 --- test_sort.py 28 Nov 2003 21:43:02 -0000 1.8 *************** *** 187,190 **** --- 187,197 ---- self.assertRaises(TypeError, data.sort, "bad", str.lower) + def test_key_with_exception(self): + # Verify that the wrapper has been removed + data = range(-2,2) + dup = data[:] + self.assertRaises(ZeroDivisionError, data.sort, None, lambda x: 1/x) + self.assertEqual(data, dup) + def test_reverse(self): data = range(100) From rhettinger at users.sourceforge.net Fri Nov 28 16:43:04 2003 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Nov 28 16:43:15 2003 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.165,2.166 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv3998/Objects Modified Files: listobject.c Log Message: Make sure the list.sort's decorate step unwinds itself before returning an exception raised by the key function. (Suggested by Michael Hudson.) Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.165 retrieving revision 2.166 diff -C2 -d -r2.165 -r2.166 *** listobject.c 8 Nov 2003 11:58:44 -0000 2.165 --- listobject.c 28 Nov 2003 21:43:02 -0000 2.166 *************** *** 1877,1882 **** key = PyObject_CallFunctionObjArgs(keyfunc, value, NULL); ! if (key == NULL) goto dsu_fail; kvpair = build_sortwrapper(key, value); if (kvpair == NULL) --- 1877,1889 ---- key = PyObject_CallFunctionObjArgs(keyfunc, value, NULL); ! if (key == NULL) { ! for (i=i-1 ; i>=0 ; i--) { ! kvpair = PyList_GET_ITEM(self, i); ! value = sortwrapper_getvalue(kvpair); ! PyList_SET_ITEM(self, i, value); ! Py_DECREF(kvpair); ! } goto dsu_fail; + } kvpair = build_sortwrapper(key, value); if (kvpair == NULL) *************** *** 1886,1890 **** } ! /* Reverse sort stability achieved by initialially reversing the list, applying a stable forward sort, then reversing the final result. */ if (reverse && self->ob_size > 1) --- 1893,1897 ---- } ! /* Reverse sort stability achieved by initially reversing the list, applying a stable forward sort, then reversing the final result. */ if (reverse && self->ob_size > 1) From gvanrossum at users.sourceforge.net Sat Nov 29 18:52:14 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:52:19 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.901,1.902 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Misc Modified Files: NEWS Log Message: - Removed FutureWarnings related to hex/oct literals and conversions and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.901 retrieving revision 1.902 diff -C2 -d -r1.901 -r1.902 *** NEWS 28 Nov 2003 19:42:56 -0000 1.901 --- NEWS 29 Nov 2003 23:52:11 -0000 1.902 *************** *** 13,16 **** --- 13,25 ---- ----------------- + - Removed FutureWarnings related to hex/oct literals and conversions + and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) + This addresses most of the remaining semantic changes promised by + PEP 237, except for repr() of a long, which still shows the trailing + 'L'. The PEP appears to promise warnings for operations that + changed semantics compared to Python 2.3, but this is not + implemented; we've suffered through enough warnings related to + hex/oct literals and I think it's best to be silent now. + - For str and unicode objects, the ljust(), center(), and rjust() methods now accept an optional argument specifying a fill From gvanrossum at users.sourceforge.net Sat Nov 29 18:52:14 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:52:26 2003 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Doc/ref Modified Files: ref2.tex Log Message: - Removed FutureWarnings related to hex/oct literals and conversions and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ref2.tex 6 Sep 2003 03:50:07 -0000 1.49 --- ref2.tex 29 Nov 2003 23:52:12 -0000 1.50 *************** *** 581,595 **** digit \character{1}. ! Plain integer decimal literals that are above the largest representable ! plain integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted ! as if they were long integers instead. Octal and hexadecimal literals ! behave similarly, but when in the range just above the largest representable ! plain integer but below the largest unsigned 32-bit number (on a machine ! using 32-bit arithmetic), 4294967296, they are taken as the negative plain ! integer obtained by subtracting 4294967296 from their unsigned value. There ! is no limit for long integer literals apart from what can be stored in ! available memory. For example, 0xdeadbeef is taken, on a 32-bit machine, ! as the value -559038737, while 0xdeadbeeffeed is taken as the value ! 244837814107885L. Some examples of plain integer literals (first row) and long integer --- 581,593 ---- digit \character{1}. ! Plain integer literals that are above the largest representable plain ! integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted ! as if they were long integers instead.\footnote{In versions of Python ! prior to 2.4, octal and hexadecimal literals in the range just above ! the largest representable plain integer but below the largest unsigned ! 32-bit number (on a machine using 32-bit arithmetic), 4294967296, were ! taken as the negative plain integer obtained by subtracting 4294967296 ! from their unsigned value.} There is no limit for long integer ! literals apart from what can be stored in available memory. Some examples of plain integer literals (first row) and long integer *************** *** 597,603 **** \begin{verbatim} ! 7 2147483647 0177 0x80000000 3L 79228162514264337593543950336L 0377L 0x100000000L ! 79228162514264337593543950336 0xdeadbeeffeed \end{verbatim} --- 595,601 ---- \begin{verbatim} ! 7 2147483647 0177 3L 79228162514264337593543950336L 0377L 0x100000000L ! 79228162514264337593543950336 0xdeadbeef \end{verbatim} From gvanrossum at users.sourceforge.net Sat Nov 29 18:52:15 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:52:31 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.25, 1.26 test_compile.py, 1.19, 1.20 test_format.py, 1.19, 1.20 test_grammar.py, 1.47, 1.48 test_hexoct.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Lib/test Modified Files: test_builtin.py test_compile.py test_format.py test_grammar.py test_hexoct.py Log Message: - Removed FutureWarnings related to hex/oct literals and conversions and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_builtin.py 16 Nov 2003 16:17:48 -0000 1.25 --- test_builtin.py 29 Nov 2003 23:52:12 -0000 1.26 *************** *** 438,443 **** self.assertEqual(hex(16), '0x10') self.assertEqual(hex(16L), '0x10L') ! self.assertEqual(len(hex(-1)), len(hex(sys.maxint))) ! self.assert_(hex(-16) in ('0xfffffff0', '0xfffffffffffffff0')) self.assertEqual(hex(-16L), '-0x10L') self.assertRaises(TypeError, hex, {}) --- 438,442 ---- self.assertEqual(hex(16), '0x10') self.assertEqual(hex(16L), '0x10L') ! self.assertEqual(hex(-16), '-0x10') self.assertEqual(hex(-16L), '-0x10L') self.assertRaises(TypeError, hex, {}) *************** *** 758,762 **** self.assertEqual(oct(100), '0144') self.assertEqual(oct(100L), '0144L') ! self.assert_(oct(-100) in ('037777777634', '01777777777777777777634')) self.assertEqual(oct(-100L), '-0144L') self.assertRaises(TypeError, oct, ()) --- 757,761 ---- self.assertEqual(oct(100), '0144') self.assertEqual(oct(100L), '0144L') ! self.assertEqual(oct(-100), '-0144') self.assertEqual(oct(-100L), '-0144L') self.assertRaises(TypeError, oct, ()) Index: test_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compile.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_compile.py 23 Jun 2003 13:36:55 -0000 1.19 --- test_compile.py 29 Nov 2003 23:52:12 -0000 1.20 *************** *** 120,132 **** def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 ! warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning) ! warnings.filterwarnings("ignore", "hex.* of negative int", FutureWarning) ! # XXX Of course the following test will have to be changed in Python 2.4 ! # This test is in a so the filterwarnings() can affect it ! all_one_bits = '0xffffffff' ! if sys.maxint != 2147483647: all_one_bits = '0xffffffffffffffff' ! self.assertEqual(eval(all_one_bits), -1) ! self.assertEqual(eval("-" + all_one_bits), 1) def test_sequence_unpacking_error(self): --- 120,135 ---- def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 ! if sys.maxint == 2147483647: ! # 32-bit machine ! all_one_bits = '0xffffffff' ! self.assertEqual(eval(all_one_bits), 4294967295L) ! self.assertEqual(eval("-" + all_one_bits), -4294967295L) ! elif sys.maxint == 9223372036854775807: ! # 64-bit machine all_one_bits = '0xffffffffffffffff' ! self.assertEqual(eval(all_one_bits), 18446744073709551615L) ! self.assertEqual(eval("-" + all_one_bits), -18446744073709551615L) ! else: ! self.fail("How many bits *does* this machine have???") def test_sequence_unpacking_error(self): Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_format.py 24 Nov 2002 02:35:35 -0000 1.19 --- test_format.py 29 Nov 2003 23:52:12 -0000 1.20 *************** *** 184,193 **** testboth("%x", 0x42, "42") ! # testboth("%x", -0x42, "ffffffbe") # specific to 32-bit boxes; see below testboth("%x", 0x42L, "42") testboth("%x", -0x42L, "-42") testboth("%o", 042, "42") ! # testboth("%o", -042, "37777777736") # specific to 32-bit boxes; see below testboth("%o", 042L, "42") testboth("%o", -042L, "-42") --- 184,193 ---- testboth("%x", 0x42, "42") ! testboth("%x", -0x42, "-42") testboth("%x", 0x42L, "42") testboth("%x", -0x42L, "-42") testboth("%o", 042, "42") ! testboth("%o", -042, "-42") testboth("%o", 042L, "42") testboth("%o", -042L, "-42") *************** *** 239,243 **** else: raise TestFailed, '"%*d"%(sys.maxint, -127) should fail' - # (different things go wrong on a 64 bit box...) - testboth("%x", -0x42, "ffffffbe") - testboth("%o", -042, "37777777736") --- 239,240 ---- Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** test_grammar.py 15 Jun 2003 23:26:30 -0000 1.47 --- test_grammar.py 29 Nov 2003 23:52:12 -0000 1.48 *************** *** 40,47 **** # The following test will start to fail in Python 2.4; # change the 020000000000 to -020000000000 ! if -2147483647-1 != 020000000000: raise TestFailed, 'max negative int' # XXX -2147483648 ! if 037777777777 != -1: raise TestFailed, 'oct -1' ! if 0xffffffff != -1: raise TestFailed, 'hex -1' for s in '2147483648', '040000000000', '0x100000000': try: --- 40,47 ---- # The following test will start to fail in Python 2.4; # change the 020000000000 to -020000000000 ! if -2147483647-1 != -020000000000: raise TestFailed, 'max negative int' # XXX -2147483648 ! if 037777777777 < 0: raise TestFailed, 'large oct' ! if 0xffffffff < 0: raise TestFailed, 'large hex' for s in '2147483648', '040000000000', '0x100000000': try: *************** *** 50,57 **** print "OverflowError on huge integer literal " + `s` elif eval('maxint == 9223372036854775807'): ! if eval('-9223372036854775807-1 != 01000000000000000000000'): raise TestFailed, 'max negative int' ! if eval('01777777777777777777777') != -1: raise TestFailed, 'oct -1' ! if eval('0xffffffffffffffff') != -1: raise TestFailed, 'hex -1' for s in '9223372036854775808', '02000000000000000000000', \ '0x10000000000000000': --- 50,57 ---- print "OverflowError on huge integer literal " + `s` elif eval('maxint == 9223372036854775807'): ! if eval('-9223372036854775807-1 != -01000000000000000000000'): raise TestFailed, 'max negative int' ! if eval('01777777777777777777777') < 0: raise TestFailed, 'large oct' ! if eval('0xffffffffffffffff') < 0: raise TestFailed, 'large hex' for s in '9223372036854775808', '02000000000000000000000', \ '0x10000000000000000': Index: test_hexoct.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_hexoct.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_hexoct.py 1 May 2003 17:45:37 -0000 1.4 --- test_hexoct.py 29 Nov 2003 23:52:12 -0000 1.5 *************** *** 2,7 **** This is complex because of changes due to PEP 237. - - Some of these tests will have to change in Python 2.4! """ --- 2,5 ---- *************** *** 42,70 **** def test_hex_unsigned(self): - # This test is in a so we can ignore the warnings - exec """if 1: if platform_long_is_32_bits: ! # Positive-looking constants with negavive values ! self.assertEqual(0x80000000, -2147483648L) ! self.assertEqual(0xffffffff, -1) # Ditto with a minus sign and parentheses ! self.assertEqual(-(0x80000000), 2147483648L) ! self.assertEqual(-(0xffffffff), 1) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-0x80000000, 2147483648L) ! self.assertEqual(-0xffffffff, 1) else: ! # Positive-looking constants with negavive values ! self.assertEqual(0x8000000000000000, -9223372036854775808L) ! self.assertEqual(0xffffffffffffffff, -1) # Ditto with a minus sign and parentheses ! self.assertEqual(-(0x8000000000000000), 9223372036854775808L) ! self.assertEqual(-(0xffffffffffffffff), 1) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-0x8000000000000000, 9223372036854775808L) ! self.assertEqual(-0xffffffffffffffff, 1) ! \n""" def test_oct_baseline(self): --- 40,65 ---- def test_hex_unsigned(self): if platform_long_is_32_bits: ! # Positive constants ! self.assertEqual(0x80000000, 2147483648L) ! self.assertEqual(0xffffffff, 4294967295L) # Ditto with a minus sign and parentheses ! self.assertEqual(-(0x80000000), -2147483648L) ! self.assertEqual(-(0xffffffff), -4294967295L) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-0x80000000, -2147483648L) ! self.assertEqual(-0xffffffff, -4294967295L) else: ! # Positive constants ! self.assertEqual(0x8000000000000000, 9223372036854775808L) ! self.assertEqual(0xffffffffffffffff, 18446744073709551615L) # Ditto with a minus sign and parentheses ! self.assertEqual(-(0x8000000000000000), -9223372036854775808L) ! self.assertEqual(-(0xffffffffffffffff), -18446744073709551615L) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-0x8000000000000000, -9223372036854775808L) ! self.assertEqual(-0xffffffffffffffff, -18446744073709551615L) def test_oct_baseline(self): *************** *** 92,120 **** def test_oct_unsigned(self): - # This test is in a so we can ignore the warnings - exec """if 1: if platform_long_is_32_bits: ! # Positive-looking constants with negavive values ! self.assertEqual(020000000000, -2147483648L) ! self.assertEqual(037777777777, -1) # Ditto with a minus sign and parentheses ! self.assertEqual(-(020000000000), 2147483648L) ! self.assertEqual(-(037777777777), 1) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-020000000000, 2147483648L) ! self.assertEqual(-037777777777, 1) else: ! # Positive-looking constants with negavive values ! self.assertEqual(01000000000000000000000, -9223372036854775808L) ! self.assertEqual(01777777777777777777777, -1) # Ditto with a minus sign and parentheses ! self.assertEqual(-(01000000000000000000000), 9223372036854775808L) ! self.assertEqual(-(01777777777777777777777), 1) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-01000000000000000000000, 9223372036854775808L) ! self.assertEqual(-01777777777777777777777, 1) ! \n""" def test_main(): --- 87,112 ---- def test_oct_unsigned(self): if platform_long_is_32_bits: ! # Positive constants ! self.assertEqual(020000000000, 2147483648L) ! self.assertEqual(037777777777, 4294967295L) # Ditto with a minus sign and parentheses ! self.assertEqual(-(020000000000), -2147483648L) ! self.assertEqual(-(037777777777), -4294967295L) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-020000000000, -2147483648L) ! self.assertEqual(-037777777777, -4294967295L) else: ! # Positive constants ! self.assertEqual(01000000000000000000000, 9223372036854775808L) ! self.assertEqual(01777777777777777777777, 18446744073709551615L) # Ditto with a minus sign and parentheses ! self.assertEqual(-(01000000000000000000000), -9223372036854775808L) ! self.assertEqual(-(01777777777777777777777), -18446744073709551615L) # Ditto with a minus sign and NO parentheses # This failed in Python 2.2 through 2.2.2 and in 2.3a1 ! self.assertEqual(-01000000000000000000000, -9223372036854775808L) ! self.assertEqual(-01777777777777777777777, -18446744073709551615L) def test_main(): From gvanrossum at users.sourceforge.net Sat Nov 29 18:52:15 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:52:35 2003 Subject: [Python-checkins] python/dist/src/Python compile.c,2.297,2.298 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Python Modified Files: compile.c Log Message: - Removed FutureWarnings related to hex/oct literals and conversions and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.297 retrieving revision 2.298 diff -C2 -d -r2.297 -r2.298 *** compile.c 18 Oct 2003 22:05:25 -0000 2.297 --- compile.c 29 Nov 2003 23:52:13 -0000 2.298 *************** *** 1259,1275 **** x = (long) PyOS_strtoul(s, &end, 0); if (x < 0 && errno == 0) { ! if (PyErr_WarnExplicit( ! PyExc_FutureWarning, ! "hex/oct constants > sys.maxint " ! "will return positive values " ! "in Python 2.4 and up", ! /* XXX: Give WarnExplicit ! a const char* argument. */ ! (char*)c->c_filename, ! c->c_lineno, ! NULL, ! NULL) < 0) ! return NULL; ! errno = 0; /* Might be changed by PyErr_Warn() */ } } --- 1259,1263 ---- x = (long) PyOS_strtoul(s, &end, 0); if (x < 0 && errno == 0) { ! return PyLong_FromString(s, (char **)0, 0); } } From gvanrossum at users.sourceforge.net Sat Nov 29 18:52:15 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:52:39 2003 Subject: [Python-checkins] python/dist/src/Objects intobject.c, 2.106, 2.107 stringobject.c, 2.213, 2.214 unicodeobject.c, 2.202, 2.203 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Objects Modified Files: intobject.c stringobject.c unicodeobject.c Log Message: - Removed FutureWarnings related to hex/oct literals and conversions and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now. Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.106 retrieving revision 2.107 diff -C2 -d -r2.106 -r2.107 *** intobject.c 11 Aug 2003 17:32:02 -0000 2.106 --- intobject.c 29 Nov 2003 23:52:12 -0000 2.107 *************** *** 279,283 **** long x; char buffer[256]; /* For errors */ - int warn = 0; if ((base != 0 && base < 2) || base > 36) { --- 279,282 ---- *************** *** 293,297 **** x = (long) PyOS_strtoul(s, &end, base); if (x < 0) ! warn = 1; } else --- 292,296 ---- x = (long) PyOS_strtoul(s, &end, base); if (x < 0) ! return PyLong_FromString(s, pend, base); } else *************** *** 313,321 **** return PyLong_FromString(s, pend, base); } - if (warn) { - if (PyErr_Warn(PyExc_FutureWarning, - "int('0...', 0): sign will change in Python 2.4") < 0) - return NULL; - } if (pend) *pend = end; --- 312,315 ---- *************** *** 767,782 **** return int_pos(v); if (b >= LONG_BIT) { ! if (PyErr_Warn(PyExc_FutureWarning, ! "x<= LONG_BIT) { ! return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)), ! PyLong_FromLong(PyInt_AS_LONG(w))); } c = a << b; if (a != Py_ARITHMETIC_RIGHT_SHIFT(long, c, b)) { ! return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)), ! PyLong_FromLong(PyInt_AS_LONG(w))); } return PyInt_FromLong(c); *************** *** 869,879 **** char buf[100]; long x = v -> ob_ival; ! if (x < 0) { ! if (PyErr_Warn(PyExc_FutureWarning, ! "hex()/oct() of negative int will return " ! "a signed string in Python 2.4 and up") < 0) ! return NULL; ! } ! if (x == 0) strcpy(buf, "0"); else --- 858,864 ---- char buf[100]; long x = v -> ob_ival; ! if (x < 0) ! PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); ! else if (x == 0) strcpy(buf, "0"); else *************** *** 887,897 **** char buf[100]; long x = v -> ob_ival; ! if (x < 0) { ! if (PyErr_Warn(PyExc_FutureWarning, ! "hex()/oct() of negative int will return " ! "a signed string in Python 2.4 and up") < 0) ! return NULL; ! } ! PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); return PyString_FromString(buf); } --- 872,879 ---- char buf[100]; long x = v -> ob_ival; ! if (x < 0) ! PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x); ! else ! PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); return PyString_FromString(buf); } Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.213 retrieving revision 2.214 diff -C2 -d -r2.213 -r2.214 *** stringobject.c 26 Nov 2003 08:21:35 -0000 2.213 --- stringobject.c 29 Nov 2003 23:52:13 -0000 2.214 *************** *** 3566,3569 **** --- 3566,3570 ---- + 1 + 1 = 24 */ char fmt[64]; /* plenty big enough! */ + char *sign; long x; *************** *** 3573,3582 **** return -1; } ! if (x < 0 && type != 'd' && type != 'i') { ! if (PyErr_Warn(PyExc_FutureWarning, ! "%u/%o/%x/%X of negative int will return " ! "a signed string in Python 2.4 and up") < 0) ! return -1; } if (prec < 0) prec = 1; --- 3574,3584 ---- return -1; } ! if (x < 0 && type == 'u') { ! type = 'd'; } + if (x < 0 && (type == 'x' || type == 'X' || type == 'o')) + sign = "-"; + else + sign = ""; if (prec < 0) prec = 1; *************** *** 3604,3625 **** * formatint() in unicodeobject.c */ ! PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", ! type, prec, type); } else { ! PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c", ! (flags&F_ALT) ? "#" : "", prec, type); } ! /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec, len(x in octal)) ! * worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ ! if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) { PyErr_SetString(PyExc_OverflowError, "formatted integer is too long (precision too large?)"); return -1; } ! PyOS_snprintf(buf, buflen, fmt, x); return strlen(buf); } --- 3606,3630 ---- * formatint() in unicodeobject.c */ ! PyOS_snprintf(fmt, sizeof(fmt), "%s0%c%%.%dl%c", ! sign, type, prec, type); } else { ! PyOS_snprintf(fmt, sizeof(fmt), "%s%%%s.%dl%c", ! sign, (flags&F_ALT) ? "#" : "", prec, type); } ! /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) ! * worst case buf = '-0x' + [0-9]*prec, where prec >= 11 */ ! if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) { PyErr_SetString(PyExc_OverflowError, "formatted integer is too long (precision too large?)"); return -1; } ! if (sign[0]) ! PyOS_snprintf(buf, buflen, fmt, -x); ! else ! PyOS_snprintf(buf, buflen, fmt, x); return strlen(buf); } *************** *** 3908,3913 **** if (!temp) goto error; - /* unbounded ints can always produce - a sign character! */ sign = 1; } --- 3913,3916 ---- *************** *** 3919,3924 **** if (len < 0) goto error; ! /* only d conversion is signed */ ! sign = c == 'd'; } if (flags & F_ZERO) --- 3922,3926 ---- if (len < 0) goto error; ! sign = 1; } if (flags & F_ZERO) Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.202 retrieving revision 2.203 diff -C2 -d -r2.202 -r2.203 *** unicodeobject.c 26 Nov 2003 08:21:35 -0000 2.202 --- unicodeobject.c 29 Nov 2003 23:52:13 -0000 2.203 *************** *** 6178,6181 **** --- 6178,6182 ---- */ char fmt[64]; /* plenty big enough! */ + char *sign; long x; *************** *** 6183,6199 **** if (x == -1 && PyErr_Occurred()) return -1; ! if (x < 0 && type != 'd' && type != 'i') { ! if (PyErr_Warn(PyExc_FutureWarning, ! "%u/%o/%x/%X of negative int will return " ! "a signed string in Python 2.4 and up") < 0) ! return -1; } if (prec < 0) prec = 1; ! /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) ! * worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ ! if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) { PyErr_SetString(PyExc_OverflowError, "formatted integer is too long (precision too large?)"); --- 6184,6201 ---- if (x == -1 && PyErr_Occurred()) return -1; ! if (x < 0 && type == 'u') { ! type = 'd'; } + if (x < 0 && (type == 'x' || type == 'X' || type == 'o')) + sign = "-"; + else + sign = ""; if (prec < 0) prec = 1; ! /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) ! * worst case buf = '-0x' + [0-9]*prec, where prec >= 11 */ ! if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) { PyErr_SetString(PyExc_OverflowError, "formatted integer is too long (precision too large?)"); *************** *** 6223,6235 **** * formatint() in stringobject.c */ ! PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", ! type, prec, type); } else { ! PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c", ! (flags&F_ALT) ? "#" : "", prec, type); } ! return usprintf(buf, fmt, x); } --- 6225,6240 ---- * formatint() in stringobject.c */ ! PyOS_snprintf(fmt, sizeof(fmt), "%s0%c%%.%dl%c", ! sign, type, prec, type); } else { ! PyOS_snprintf(fmt, sizeof(fmt), "%s%%%s.%dl%c", ! sign, (flags&F_ALT) ? "#" : "", prec, type); } ! if (sign[0]) ! return usprintf(buf, fmt, -x); ! else ! return usprintf(buf, fmt, x); } *************** *** 6567,6572 **** pbuf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); - /* unbounded ints can always produce - a sign character! */ sign = 1; } --- 6572,6575 ---- *************** *** 6577,6582 **** if (len < 0) goto onError; ! /* only d conversion is signed */ ! sign = c == 'd'; } if (flags & F_ZERO) --- 6580,6584 ---- if (len < 0) goto onError; ! sign = 1; } if (flags & F_ZERO) From gvanrossum at users.sourceforge.net Sat Nov 29 18:55:11 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Nov 29 18:55:14 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_format.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv28944 Modified Files: test_format.py Log Message: Fix a bug discovered by Kalle Svensson: comparing sys.maxint to 2**32-1 makes no sense. Use 2**31-1 instead. Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_format.py 29 Nov 2003 23:52:12 -0000 1.20 --- test_format.py 29 Nov 2003 23:55:09 -0000 1.21 *************** *** 231,235 **** "not all arguments converted during string formatting") ! if sys.maxint == 2**32-1: # crashes 2.2.1 and earlier: try: --- 231,235 ---- "not all arguments converted during string formatting") ! if sys.maxint == 2**31-1: # crashes 2.2.1 and earlier: try: From anthonybaxter at users.sourceforge.net Sat Nov 29 20:45:22 2003 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Sat Nov 29 20:45:28 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_format.py, 1.19, 1.19.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv12867 Modified Files: Tag: release23-maint test_format.py Log Message: backport: Fix a bug discovered by Kalle Svensson: comparing sys.maxint to 2**32-1 makes no sense. Use 2**31-1 instead. Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.19 retrieving revision 1.19.16.1 diff -C2 -d -r1.19 -r1.19.16.1 *** test_format.py 24 Nov 2002 02:35:35 -0000 1.19 --- test_format.py 30 Nov 2003 01:45:20 -0000 1.19.16.1 *************** *** 231,235 **** "not all arguments converted during string formatting") ! if sys.maxint == 2**32-1: # crashes 2.2.1 and earlier: try: --- 231,235 ---- "not all arguments converted during string formatting") ! if sys.maxint == 2**31-1: # crashes 2.2.1 and earlier: try: From gvanrossum at users.sourceforge.net Sun Nov 30 17:01:47 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:01:50 2003 Subject: [Python-checkins] python/dist/src/PC _winreg.c,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1:/tmp/cvs-serv9905 Modified Files: _winreg.c Log Message: Remove all uses of alloca() from this module. The alloca() return value isn't checked, and it *is* possible that a very large alloca() call is made, e.g. when a large registry value is being read. I don't know if alloca() in that case returns NULL or returns a pointer pointing outside the stack, and I don't want to know -- I've simply replaced all calls to alloca() with either PyMem_Malloc() or PyString_FromStringAndSize(NULL,) as appropriate, followed by a size check. This addresses SF buf 851056. Will backport to 2.3 next. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _winreg.c 15 Jan 2003 23:38:15 -0000 1.14 --- _winreg.c 30 Nov 2003 22:01:43 -0000 1.15 *************** *** 1032,1035 **** --- 1032,1036 ---- int index; long rc; + PyObject *retStr; char *retBuf; DWORD len; *************** *** 1046,1054 **** "RegQueryInfoKey"); ++len; /* include null terminator */ ! retBuf = (char *)alloca(len); ! if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); ! return Py_BuildValue("s", retBuf); } --- 1047,1061 ---- "RegQueryInfoKey"); ++len; /* include null terminator */ ! retStr = PyString_FromStringAndSize(NULL, len); ! if (retStr == NULL) ! return NULL; ! retBuf = PyString_AS_STRING(retStr); ! if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) { ! Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); ! } ! _PyString_Resize(&retStr, strlen(retBuf)); ! return retStr; } *************** *** 1081,1086 **** ++retValueSize; /* include null terminators */ ++retDataSize; ! retValueBuf = (char *)alloca(retValueSize); ! retDataBuf = (char *)alloca(retDataSize); Py_BEGIN_ALLOW_THREADS --- 1088,1099 ---- ++retValueSize; /* include null terminators */ ++retDataSize; ! retValueBuf = (char *)PyMem_Malloc(retValueSize); ! if (retValueBuf == NULL) ! return PyErr_NoMemory(); ! retDataBuf = (char *)PyMem_Malloc(retDataSize); ! if (retDataBuf == NULL) { ! PyMem_Free(retValueBuf); ! return PyErr_NoMemory(); ! } Py_BEGIN_ALLOW_THREADS *************** *** 1095,1106 **** Py_END_ALLOW_THREADS ! if (rc != ERROR_SUCCESS) ! return PyErr_SetFromWindowsErrWithFunction(rc, ! "PyRegEnumValue"); obData = Reg2Py(retDataBuf, retDataSize, typ); ! if (obData == NULL) ! return NULL; retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); Py_DECREF(obData); return retVal; } --- 1108,1126 ---- Py_END_ALLOW_THREADS ! if (rc != ERROR_SUCCESS) { ! retVal = PyErr_SetFromWindowsErrWithFunction(rc, ! "PyRegEnumValue"); ! goto fail; ! } obData = Reg2Py(retDataBuf, retDataSize, typ); ! if (obData == NULL) { ! retVal = NULL; ! goto fail; ! } retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); Py_DECREF(obData); + fail: + PyMem_Free(retValueBuf); + PyMem_Free(retDataBuf); return retVal; } *************** *** 1207,1214 **** PyObject *obKey; char *subKey; - long rc; char *retBuf; long bufSize = 0; if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) return NULL; --- 1227,1235 ---- PyObject *obKey; char *subKey; long rc; + PyObject *retStr; char *retBuf; long bufSize = 0; + if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) return NULL; *************** *** 1220,1229 **** return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! retBuf = (char *)alloca(bufSize); if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) ! != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! return Py_BuildValue("s", retBuf); } --- 1241,1256 ---- return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! retStr = PyString_FromStringAndSize(NULL, bufSize); ! if (retStr == NULL) ! return NULL; ! retBuf = PyString_AS_STRING(retStr); if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) ! != ERROR_SUCCESS) { ! Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! } ! _PyString_Resize(&retStr, strlen(retBuf)); ! return retStr; } *************** *** 1253,1263 **** return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); ! retBuf = (char *)alloca(bufSize); if ((rc = RegQueryValueEx(hKey, valueName, NULL, &typ, (BYTE *)retBuf, &bufSize)) ! != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); obData = Reg2Py(retBuf, bufSize, typ); if (obData == NULL) return NULL; --- 1280,1295 ---- return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); ! retBuf = (char *)PyMem_Malloc(bufSize); ! if (retBuf == NULL) ! return PyErr_NoMemory(); if ((rc = RegQueryValueEx(hKey, valueName, NULL, &typ, (BYTE *)retBuf, &bufSize)) ! != ERROR_SUCCESS) { ! PyMem_Free(retBuf); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); + } obData = Reg2Py(retBuf, bufSize, typ); + PyMem_Free((void *)retBuf); if (obData == NULL) return NULL; From gvanrossum at users.sourceforge.net Sun Nov 30 17:07:36 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:07:39 2003 Subject: [Python-checkins] python/dist/src/PC _winreg.c,1.14,1.14.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1:/tmp/cvs-serv11821 Modified Files: Tag: release23-maint _winreg.c Log Message: Backport: Remove all uses of alloca() from this module. The alloca() return value isn't checked, and it *is* possible that a very large alloca() call is made, e.g. when a large registry value is being read. I don't know if alloca() in that case returns NULL or returns a pointer pointing outside the stack, and I don't want to know -- I've simply replaced all calls to alloca() with either PyMem_Malloc() or PyString_FromStringAndSize(NULL,) as appropriate, followed by a size check. This addresses SF buf 851056. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.14 retrieving revision 1.14.12.1 diff -C2 -d -r1.14 -r1.14.12.1 *** _winreg.c 15 Jan 2003 23:38:15 -0000 1.14 --- _winreg.c 30 Nov 2003 22:07:34 -0000 1.14.12.1 *************** *** 1032,1035 **** --- 1032,1036 ---- int index; long rc; + PyObject *retStr; char *retBuf; DWORD len; *************** *** 1046,1054 **** "RegQueryInfoKey"); ++len; /* include null terminator */ ! retBuf = (char *)alloca(len); ! if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); ! return Py_BuildValue("s", retBuf); } --- 1047,1061 ---- "RegQueryInfoKey"); ++len; /* include null terminator */ ! retStr = PyString_FromStringAndSize(NULL, len); ! if (retStr == NULL) ! return NULL; ! retBuf = PyString_AS_STRING(retStr); ! if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) { ! Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); ! } ! _PyString_Resize(&retStr, strlen(retBuf)); ! return retStr; } *************** *** 1081,1086 **** ++retValueSize; /* include null terminators */ ++retDataSize; ! retValueBuf = (char *)alloca(retValueSize); ! retDataBuf = (char *)alloca(retDataSize); Py_BEGIN_ALLOW_THREADS --- 1088,1099 ---- ++retValueSize; /* include null terminators */ ++retDataSize; ! retValueBuf = (char *)PyMem_Malloc(retValueSize); ! if (retValueBuf == NULL) ! return PyErr_NoMemory(); ! retDataBuf = (char *)PyMem_Malloc(retDataSize); ! if (retDataBuf == NULL) { ! PyMem_Free(retValueBuf); ! return PyErr_NoMemory(); ! } Py_BEGIN_ALLOW_THREADS *************** *** 1095,1106 **** Py_END_ALLOW_THREADS ! if (rc != ERROR_SUCCESS) ! return PyErr_SetFromWindowsErrWithFunction(rc, ! "PyRegEnumValue"); obData = Reg2Py(retDataBuf, retDataSize, typ); ! if (obData == NULL) ! return NULL; retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); Py_DECREF(obData); return retVal; } --- 1108,1126 ---- Py_END_ALLOW_THREADS ! if (rc != ERROR_SUCCESS) { ! retVal = PyErr_SetFromWindowsErrWithFunction(rc, ! "PyRegEnumValue"); ! goto fail; ! } obData = Reg2Py(retDataBuf, retDataSize, typ); ! if (obData == NULL) { ! retVal = NULL; ! goto fail; ! } retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); Py_DECREF(obData); + fail: + PyMem_Free(retValueBuf); + PyMem_Free(retDataBuf); return retVal; } *************** *** 1207,1214 **** PyObject *obKey; char *subKey; - long rc; char *retBuf; long bufSize = 0; if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) return NULL; --- 1227,1235 ---- PyObject *obKey; char *subKey; long rc; + PyObject *retStr; char *retBuf; long bufSize = 0; + if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) return NULL; *************** *** 1220,1229 **** return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! retBuf = (char *)alloca(bufSize); if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) ! != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! return Py_BuildValue("s", retBuf); } --- 1241,1256 ---- return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! retStr = PyString_FromStringAndSize(NULL, bufSize); ! if (retStr == NULL) ! return NULL; ! retBuf = PyString_AS_STRING(retStr); if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) ! != ERROR_SUCCESS) { ! Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); ! } ! _PyString_Resize(&retStr, strlen(retBuf)); ! return retStr; } *************** *** 1253,1263 **** return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); ! retBuf = (char *)alloca(bufSize); if ((rc = RegQueryValueEx(hKey, valueName, NULL, &typ, (BYTE *)retBuf, &bufSize)) ! != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); obData = Reg2Py(retBuf, bufSize, typ); if (obData == NULL) return NULL; --- 1280,1295 ---- return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); ! retBuf = (char *)PyMem_Malloc(bufSize); ! if (retBuf == NULL) ! return PyErr_NoMemory(); if ((rc = RegQueryValueEx(hKey, valueName, NULL, &typ, (BYTE *)retBuf, &bufSize)) ! != ERROR_SUCCESS) { ! PyMem_Free(retBuf); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); + } obData = Reg2Py(retBuf, bufSize, typ); + PyMem_Free((void *)retBuf); if (obData == NULL) return NULL; From gvanrossum at users.sourceforge.net Sun Nov 30 17:10:24 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:10:29 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.902,1.903 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv12494 Modified Files: NEWS Log Message: Add news item for _winreg fix (SF bug 851056). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.902 retrieving revision 1.903 diff -C2 -d -r1.902 -r1.903 *** NEWS 29 Nov 2003 23:52:11 -0000 1.902 --- NEWS 30 Nov 2003 22:10:15 -0000 1.903 *************** *** 271,274 **** --- 271,279 ---- ------- + - The _winreg module could segfault when reading very large registry + values, due to unchecked alloca() calls (SF bug 851056). The fix is + uses either PyMem_Malloc(n) or PyString_FromStringAndSize(NULL, n), + as appropriate, followed by a size check. + - file.truncate() could misbehave if the file was open for update (modes r+, rb+, w+, wb+), and the most recent file operation before From gvanrossum at users.sourceforge.net Sun Nov 30 17:10:56 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:10:59 2003 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.831.4.78,1.831.4.79 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1:/tmp/cvs-serv12602 Modified Files: Tag: release23-maint NEWS Log Message: Add news item for _winreg fix (SF bug 851056). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.78 retrieving revision 1.831.4.79 diff -C2 -d -r1.831.4.78 -r1.831.4.79 *** NEWS 28 Nov 2003 19:45:02 -0000 1.831.4.78 --- NEWS 30 Nov 2003 22:10:54 -0000 1.831.4.79 *************** *** 263,266 **** --- 263,271 ---- ------- + - The _winreg module could segfault when reading very large registry + values, due to unchecked alloca() calls (SF bug 851056). The fix is + uses either PyMem_Malloc(n) or PyString_FromStringAndSize(NULL, n), + as appropriate, followed by a size check. + - The _ssl extension module was built using openssl-0.9.7b. From gvanrossum at users.sourceforge.net Sun Nov 30 17:45:05 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:45:38 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_winreg.py, 1.11, 1.11.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv20692/Lib/test Modified Files: Tag: release23-maint test_winreg.py Log Message: Add testcases for _winreg segfault (SF 851056). Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.11 retrieving revision 1.11.16.1 diff -C2 -d -r1.11 -r1.11.16.1 *** test_winreg.py 23 Jul 2002 19:04:09 -0000 1.11 --- test_winreg.py 30 Nov 2003 22:45:03 -0000 1.11.16.1 *************** *** 11,18 **** test_data = [ ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ,), ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), ] if have_unicode: --- 11,20 ---- test_data = [ ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ), ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), + ("Big String", "x"*(512*1024-4), REG_SZ), + ("Big Binary", "x"*(1024*1024-4), REG_BINARY), ] if have_unicode: From gvanrossum at users.sourceforge.net Sun Nov 30 17:46:20 2003 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Nov 30 17:46:23 2003 Subject: [Python-checkins] python/dist/src/Lib/test test_winreg.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv22530 Modified Files: test_winreg.py Log Message: Add testcases for _winreg segfault (SF 851056). Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_winreg.py 23 Jul 2002 19:04:09 -0000 1.11 --- test_winreg.py 30 Nov 2003 22:46:18 -0000 1.12 *************** *** 11,18 **** test_data = [ ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ,), ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), ] if have_unicode: --- 11,20 ---- test_data = [ ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ), ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), + ("Big String", "x"*(512*1024-4), REG_SZ), + ("Big Binary", "x"*(1024*1024-4), REG_BINARY), ] if have_unicode: