From tim_one@users.sourceforge.net Thu Feb 1 10:06:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 02:06:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib random.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26357/python/dist/src/lib Modified Files: random.py Log Message: Repaired a docstring. Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** random.py 2001/02/01 04:59:18 1.22 --- random.py 2001/02/01 10:06:53 1.23 *************** *** 125,129 **** None or no argument seeds from current time. ! If a is not None or an int or long, hash(a) is instead. If a is an int or long, a is used directly. Distinct values between --- 125,129 ---- None or no argument seeds from current time. ! If a is not None or an int or long, hash(a) is used instead. If a is an int or long, a is used directly. Distinct values between From fdrake@users.sourceforge.net Thu Feb 1 05:27:47 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:27:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.120,2.121 object.c,2.118,2.119 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17685/Objects Modified Files: classobject.c object.c Log Message: PEP 205, Weak References -- initial checkin. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.120 retrieving revision 2.121 diff -C2 -r2.120 -r2.121 *** classobject.c 2001/01/29 23:50:25 2.120 --- classobject.c 2001/02/01 05:27:45 2.121 *************** *** 516,519 **** --- 516,523 ---- extern long _Py_RefTotal; #endif + + if (!PyObject_ClearWeakRefs((PyObject *) inst)) + return; + /* Temporarily resurrect the object. */ #ifdef Py_TRACE_REFS *************** *** 1772,1775 **** --- 1776,1780 ---- 0, /* tp_clear */ instance_richcompare, /* tp_richcompare */ + offsetof(PyInstanceObject, in_weakreflist) /* tp_weaklistoffset */ }; Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.118 retrieving revision 2.119 diff -C2 -r2.118 -r2.119 *** object.c 2001/01/24 22:14:43 2.118 --- object.c 2001/02/01 05:27:45 2.119 *************** *** 101,104 **** --- 101,108 ---- op->ob_type = tp; _Py_NewReference(op); + if (PyType_SUPPORTS_WEAKREFS(tp)) { + PyObject **weaklist = PyObject_GET_WEAKREFS_LISTPTR(op); + *weaklist = NULL; + } return op; } *************** *** 120,123 **** --- 124,131 ---- op->ob_type = tp; _Py_NewReference((PyObject *)op); + if (PyType_SUPPORTS_WEAKREFS(tp)) { + PyObject **weaklist = PyObject_GET_WEAKREFS_LISTPTR(op); + *weaklist = NULL; + } return op; } *************** *** 1457,1460 **** --- 1465,1483 ---- PyObject_FREE(p); } + + + /* Hook to clear up weak references only once the _weakref module is + imported. We use a dummy implementation to simplify the code at each + call site instead of requiring a test for NULL. + */ + + static int + empty_clear_weak_refs(PyObject *o) + { + return 1; + } + + int (*PyObject_ClearWeakRefs)(PyObject *) = empty_clear_weak_refs; + From fdrake@users.sourceforge.net Thu Feb 1 05:26:57 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:26:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17550/Modules Modified Files: Setup.dist Log Message: Add entries for the weakref module to the build control. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** Setup.dist 2001/01/29 20:13:11 1.13 --- Setup.dist 2001/02/01 05:26:54 1.14 *************** *** 148,151 **** --- 148,152 ---- #time timemodule.c # -lm # time operations and variables #operator operator.c # operator.add() and similar goodies + #_weakref _weakref.c # basic weak reference support #_codecs _codecsmodule.c # access to the builtin codecs and codec registry From fdrake@users.sourceforge.net Thu Feb 1 05:26:57 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:26:57 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv17550 Modified Files: setup.py Log Message: Add entries for the weakref module to the build control. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** setup.py 2001/01/26 21:56:58 1.19 --- setup.py 2001/02/01 05:26:54 1.20 *************** *** 154,157 **** --- 154,158 ---- exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) ) + exts.append( Extension('_weakref', ['_weakref.c']) ) exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) From fdrake@users.sourceforge.net Thu Feb 1 05:25:29 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:25:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include classobject.h,2.35,2.36 object.h,2.73,2.74 objimpl.h,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv17385/Include Modified Files: classobject.h object.h objimpl.h Log Message: PEP 205, Weak References -- initial checkin. Index: classobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/classobject.h,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** classobject.h 2001/01/28 03:52:08 2.35 --- classobject.h 2001/02/01 05:25:27 2.36 *************** *** 25,28 **** --- 25,29 ---- PyClassObject *in_class; /* The class object */ PyObject *in_dict; /* A dictionary */ + PyObject *in_weakreflist; /* List of weak references */ } PyInstanceObject; Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** object.h 2001/01/24 22:13:48 2.73 --- object.h 2001/02/01 05:25:27 2.74 *************** *** 247,252 **** richcmpfunc tp_richcompare; ! /* More spares */ ! long tp_xxx8; #ifdef COUNT_ALLOCS --- 247,252 ---- richcmpfunc tp_richcompare; ! /* weak reference enabler */ ! long tp_weaklistoffset; #ifdef COUNT_ALLOCS *************** *** 285,288 **** --- 285,290 ---- extern DL_IMPORT(int) PyNumber_CoerceEx(PyObject **, PyObject **); + extern DL_IMPORT(int) (*PyObject_ClearWeakRefs)(PyObject *); + /* Helpers for printing recursive container types */ extern DL_IMPORT(int) Py_ReprEnter(PyObject *); *************** *** 419,423 **** #define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++) #define Py_DECREF(op) \ ! if (--_Py_RefTotal, --(op)->ob_refcnt != 0) \ ; \ else \ --- 421,425 ---- #define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++) #define Py_DECREF(op) \ ! if (--_Py_RefTotal, (--((op)->ob_refcnt) != 0)) \ ; \ else \ Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** objimpl.h 2001/01/24 04:17:26 2.30 --- objimpl.h 2001/02/01 05:25:27 2.31 *************** *** 161,165 **** Note that these macros expect non-NULL object pointers.*/ #define PyObject_INIT(op, typeobj) \ ! ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) #define PyObject_INIT_VAR(op, typeobj, size) \ ( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) ) --- 161,169 ---- Note that these macros expect non-NULL object pointers.*/ #define PyObject_INIT(op, typeobj) \ ! ((op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), \ ! (PyType_SUPPORTS_WEAKREFS((typeobj)) \ ! ? *(PyObject_GET_WEAKREFS_LISTPTR(op)) = NULL \ ! : NULL), \ ! (op)) #define PyObject_INIT_VAR(op, typeobj, size) \ ( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) ) *************** *** 266,269 **** --- 270,279 ---- #endif /* WITH_CYCLE_GC */ + + /* Test if a type supports weak references */ + #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) + + #define PyObject_GET_WEAKREFS_LISTPTR(o) \ + ((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset)) #ifdef __cplusplus From fdrake@users.sourceforge.net Thu Feb 1 05:25:29 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:25:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_weakref,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv17385/Lib/test/output Added Files: test_weakref Log Message: PEP 205, Weak References -- initial checkin. --- NEW FILE: test_weakref --- test_weakref Basic Weak References -- Liveness and referent identity -- Reference objects with callbacks -- Proxy objects with callbacks -- Re-use of weak reference objects reference objects proxy objects clearing ref 2 clearing ref 1 clearing ref 2 clearing ref 1 Weak Valued Dictionaries objects are stored in weak dict weak dict test complete Non-callable Proxy References XXX -- tests not written! Callable Proxy References From fdrake@users.sourceforge.net Thu Feb 1 05:25:29 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:25:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17385/Lib/test Added Files: test_weakref.py Log Message: PEP 205, Weak References -- initial checkin. --- NEW FILE: test_weakref.py --- import sys import weakref from test_support import TestFailed, verify class C: pass print "Basic Weak References" print "-- Liveness and referent identity" o = C() ref = weakref.ref(o) verify(ref() is not None, "weak reference to live object should be live") o2 = ref() verify(ref() is not None, "weak ref should still be live") verify(o is o2, "() should return original object if live") del o, o2 del ref cbcalled = 0 def callback(o): global cbcalled cbcalled = 1 o = C() ref2 = weakref.ref(o, callback) del o verify(cbcalled, "callback did not properly set 'cbcalled'") verify(ref2() is None, "ref2 should be dead after deleting object reference") del ref2 print "-- Reference objects with callbacks" o = C() o.bar = 1 ref1 = weakref.ref(o, id) ref2 = weakref.ref(o, id) del o verify(ref1() is None, "expected reference to be invalidated") verify(ref2() is None, "expected reference to be invalidated") print "-- Proxy objects with callbacks" o = C() o.bar = 1 ref1 = weakref.proxy(o, id) ref2 = weakref.proxy(o, id) del o try: ref1.bar except weakref.ReferenceError: pass else: raise TestFailed("expected ReferenceError exception") try: ref2.bar except weakref.ReferenceError: pass else: raise TestFailed("expected ReferenceError exception") print "-- Re-use of weak reference objects" print " reference objects" o = C() ref1 = weakref.ref(o) # create a proxy to make sure that there's an intervening creation # between these two; it should make no difference proxy = weakref.proxy(o) ref2 = weakref.ref(o) verify(ref1 is ref2, "reference object w/out callback should have been re-used") o = C() proxy = weakref.proxy(o) ref1 = weakref.ref(o) ref2 = weakref.ref(o) verify(ref1 is ref2, "reference object w/out callback should have been re-used") verify(weakref.getweakrefcount(o) == 2, "wrong weak ref count for object") del proxy verify(weakref.getweakrefcount(o) == 1, "wrong weak ref count for object after deleting proxy") print " proxy objects" o = C() ref3 = weakref.proxy(o) ref4 = weakref.proxy(o) verify(ref3 is ref4, "proxy object w/out callback should have been re-used") def clearing1(r): print "clearing ref 1" def clearing2(r): print "clearing ref 2" o = C() ref1 = weakref.ref(o, clearing1) ref2 = weakref.ref(o, clearing2) verify(weakref.getweakrefcount(o) == 2, "got wrong number of weak reference objects") del o o = C() ref1 = weakref.ref(o, clearing1) ref2 = weakref.ref(o, clearing2) del ref1 verify(weakref.getweakrefs(o) == [ref2], "list of refs does not match") del o o = C() ref1 = weakref.ref(o, clearing1) ref2 = weakref.ref(o, clearing2) del ref2 verify(weakref.getweakrefs(o) == [ref1], "list of refs does not match") del o print print "Weak Valued Dictionaries" class Object: def __init__(self, arg): self.arg = arg def __repr__(self): return "" % self.arg dict = weakref.mapping() objects = map(Object, range(10)) for o in objects: dict[o.arg] = o print "objects are stored in weak dict" for o in objects: verify(weakref.getweakrefcount(o) == 1, "wrong number of weak references to %r!" % o) verify(o is dict[o.arg], "wrong object returned by weak dict!") dict.clear() print "weak dict test complete" print print "Non-callable Proxy References" print "XXX -- tests not written!" def test_proxy(o, proxy): o.foo = 1 verify(proxy.foo == 1, "proxy does not reflect attribute addition") o.foo = 2 verify(proxy.foo == 2, "proxy does not reflect attribute modification") del o.foo verify(not hasattr(proxy, 'foo'), "proxy does not reflect attribute removal") proxy.foo = 1 verify(o.foo == 1, "object does not reflect attribute addition via proxy") proxy.foo = 2 verify(o.foo == 2, "object does not reflect attribute modification via proxy") del proxy.foo verify(not hasattr(o, 'foo'), "object does not reflect attribute removal via proxy") o = C() test_proxy(o, weakref.proxy(o)) print print "Callable Proxy References" class Callable: bar = None def __call__(self, x): self.bar = x o = Callable() ref1 = weakref.proxy(o) test_proxy(o, ref1) verify(type(ref1) is weakref.CallableProxyType, "proxy is not of callable type") ref1('twinkies!') verify(o.bar == 'twinkies!', "call through proxy not passed through to original") try: ref1() except TypeError: # expect due to too few args pass else: raise TestFailed("did not catch expected TypeError -- too few args") try: ref1(1, 2, 3) except TypeError: # expect due to too many args pass else: raise TestFailed("did not catch expected TypeError -- too many args") From fdrake@users.sourceforge.net Thu Feb 1 05:25:29 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:25:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib weakref.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv17385/Lib Added Files: weakref.py Log Message: PEP 205, Weak References -- initial checkin. --- NEW FILE: weakref.py --- """Weak reference support for Python. This module is an implementation of PEP 205: http://python.sourceforge.net/peps/pep-0205.html """ import UserDict from _weakref import \ getweakrefcount, \ getweakrefs, \ ref, \ proxy, \ ReferenceError, \ CallableProxyType, \ ProxyType, \ ReferenceType ProxyTypes = (ProxyType, CallableProxyType) def mapping(dict=None): return WeakDictionary(dict) class WeakDictionary(UserDict.UserDict): # We inherit the constructor without worrying about the input # dictionary; since it uses our .update() method, we get the right # checks (if the other dictionary is a WeakDictionary, objects are # unwrapped on the way out, and we always wrap on the way in). def __getitem__(self, key): o = self.data.get(key)() if o is None: raise KeyError, key else: return o def __repr__(self): return "" % id(self) def __setitem__(self, key, value): def remove(o, data=self.data, key=key): del data[key] self.data[key] = ref(value, remove) def copy(self): new = WeakDictionary() for key, ref in self.data.items(): o = ref() if o is not None: new[key] = o def get(self, key, default): try: ref = self.data[key] except KeyError: return default else: o = ref() if o is None: # This should only happen return default else: return o def items(self): L = self.data.items() for i in range(len(L)): key, ref = L[i] o = ref() if o is not None: L[i] = key, o return L def popitem(self): while 1: key, ref = self.data.popitem() o = ref() if o is not None: return key, o def setdefault(self, key, default): try: ref = self.data[key] except KeyError: def remove(o, data=self.data, key=key): del data[key] ref = ref(default, remove) self.data[key] = ref return default else: return ref() def update(self, dict): d = self.data L = [] for key, o in dict.items(): def remove(o, data=d, key=key): del data[key] L.append(key, ref(o, remove)) for key, r in L: d[key] = r def values(self): L = [] for ref in self.data.values(): o = ref() if o is not None: L.append(o) return L # no longer needed del UserDict From fdrake@users.sourceforge.net Thu Feb 1 05:25:29 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:25:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _weakref.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17385/Modules Added Files: _weakref.c Log Message: PEP 205, Weak References -- initial checkin. --- NEW FILE: _weakref.c --- #include "Python.h" #include "structmember.h" typedef struct _PyWeakReference PyWeakReference; struct _PyWeakReference { PyObject_HEAD PyObject *wr_object; PyObject *wr_callback; PyWeakReference *wr_prev; PyWeakReference *wr_next; }; #define GET_WEAKREFS_LISTPTR(o) \ ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) static PyObject * ReferenceError; static PyWeakReference * free_list = NULL; staticforward PyTypeObject PyWeakReference_Type; static PyWeakReference * new_weakref(void) { PyWeakReference *result; if (free_list != NULL) { result = free_list; free_list = result->wr_next; result->ob_type = &PyWeakReference_Type; _Py_NewReference(result); } else { result = PyObject_NEW(PyWeakReference, &PyWeakReference_Type); } return result; } /* This function clears the passed-in reference and removes it from the * list of weak references for the referent. This is the only code that * removes an item from the doubly-linked list of weak references for an * object; it is also responsible for clearing the callback slot. */ static void clear_weakref(PyWeakReference *self) { PyObject *callback = self->wr_callback; if (self->wr_object != Py_None) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object); if (*list == self) *list = self->wr_next; self->wr_object = Py_None; self->wr_callback = NULL; if (self->wr_prev != NULL) self->wr_prev->wr_next = self->wr_next; if (self->wr_next != NULL) self->wr_next->wr_prev = self->wr_prev; self->wr_prev = NULL; self->wr_next = NULL; Py_XDECREF(callback); } } static void weakref_dealloc(PyWeakReference *self) { clear_weakref(self); PyObject_GC_Fini((PyObject *)self); self->wr_next = free_list; free_list = self; } static int gc_traverse(PyWeakReference *self, visitproc visit, void *arg) { if (self->wr_callback != NULL) return visit(self->wr_callback, arg); return 0; } static int gc_clear(PyWeakReference *self) { clear_weakref(self); return 0; } static PyObject * weakref_call(PyWeakReference *self, PyObject *args, PyObject *kw) { static char *argnames[] = {NULL}; if (PyArg_ParseTupleAndKeywords(args, kw, ":__call__", argnames)) { PyObject *object = self->wr_object; Py_INCREF(object); return (object); } return NULL; } static PyObject * weakref_repr(PyWeakReference *self) { char buffer[256]; if (self->wr_object == Py_None) { sprintf(buffer, "", (long)(self)); } else { sprintf(buffer, "", (long)(self), self->wr_object->ob_type->tp_name, (long)(self->wr_object)); } return PyString_FromString(buffer); } statichere PyTypeObject PyWeakReference_Type = { PyObject_HEAD_INIT(NULL) 0, "weakref", sizeof(PyWeakReference) + PyGC_HEAD_SIZE, 0, (destructor)weakref_dealloc,/*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc)weakref_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ }; static int proxy_checkref(PyWeakReference *proxy) { if (proxy->wr_object == Py_None) { PyErr_SetString(ReferenceError, "weakly-referenced object no longer exists"); return 0; } return 1; } #define WRAP_UNARY(method, generic) \ static PyObject * \ method(PyWeakReference *proxy) { \ if (!proxy_checkref(proxy)) { \ return NULL; \ } \ return generic(proxy->wr_object); \ } #define WRAP_BINARY(method, generic) \ static PyObject * \ method(PyWeakReference *proxy, PyObject *v) { \ if (!proxy_checkref(proxy)) { \ return NULL; \ } \ return generic(proxy->wr_object, v); \ } #define WRAP_TERNARY(method, generic) \ static PyObject * \ method(PyWeakReference *proxy, PyObject *v, PyObject *w) { \ if (!proxy_checkref(proxy)) { \ return NULL; \ } \ return generic(proxy->wr_object, v, w); \ } /* direct slots */ WRAP_BINARY(proxy_getattr, PyObject_GetAttr) WRAP_UNARY(proxy_str, PyObject_Str) WRAP_TERNARY(proxy_call, PyEval_CallObjectWithKeywords) static int proxy_print(PyWeakReference *proxy, FILE *fp, int flags) { if (!proxy_checkref(proxy)) return -1; return PyObject_Print(proxy->wr_object, fp, flags); } static PyObject * proxy_repr(PyWeakReference *proxy) { char buf[160]; sprintf(buf, "", proxy, proxy->wr_object->ob_type->tp_name, proxy->wr_object); return PyString_FromString(buf); } static int proxy_setattr(PyWeakReference *proxy, PyObject *name, PyObject *value) { if (!proxy_checkref(proxy)) return -1; return PyObject_SetAttr(proxy->wr_object, name, value); } static int proxy_compare(PyWeakReference *proxy, PyObject *v) { if (!proxy_checkref(proxy)) return -1; return PyObject_Compare(proxy->wr_object, v); } /* number slots */ WRAP_BINARY(proxy_add, PyNumber_Add) WRAP_BINARY(proxy_sub, PyNumber_Subtract) WRAP_BINARY(proxy_mul, PyNumber_Multiply) WRAP_BINARY(proxy_div, PyNumber_Divide) WRAP_BINARY(proxy_mod, PyNumber_Remainder) WRAP_BINARY(proxy_divmod, PyNumber_Divmod) WRAP_TERNARY(proxy_pow, PyNumber_Power) WRAP_UNARY(proxy_neg, PyNumber_Negative) WRAP_UNARY(proxy_pos, PyNumber_Positive) WRAP_UNARY(proxy_abs, PyNumber_Absolute) WRAP_UNARY(proxy_invert, PyNumber_Invert) WRAP_BINARY(proxy_lshift, PyNumber_Lshift) WRAP_BINARY(proxy_rshift, PyNumber_Rshift) WRAP_BINARY(proxy_and, PyNumber_And) WRAP_BINARY(proxy_xor, PyNumber_Xor) WRAP_BINARY(proxy_or, PyNumber_Or) WRAP_UNARY(proxy_int, PyNumber_Int) WRAP_UNARY(proxy_long, PyNumber_Long) WRAP_UNARY(proxy_float, PyNumber_Float) WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd) WRAP_BINARY(proxy_isub, PyNumber_InPlaceSubtract) WRAP_BINARY(proxy_imul, PyNumber_InPlaceMultiply) WRAP_BINARY(proxy_idiv, PyNumber_InPlaceDivide) WRAP_BINARY(proxy_imod, PyNumber_InPlaceRemainder) WRAP_TERNARY(proxy_ipow, PyNumber_InPlacePower) WRAP_BINARY(proxy_ilshift, PyNumber_InPlaceLshift) WRAP_BINARY(proxy_irshift, PyNumber_InPlaceRshift) WRAP_BINARY(proxy_iand, PyNumber_InPlaceAnd) WRAP_BINARY(proxy_ixor, PyNumber_InPlaceXor) WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) static int proxy_nonzero(PyWeakReference *proxy) { PyObject *o = proxy->wr_object; if (!proxy_checkref(proxy)) return 1; if (o->ob_type->tp_as_number && o->ob_type->tp_as_number->nb_nonzero) return (*o->ob_type->tp_as_number->nb_nonzero)(o); else return 1; } /* sequence slots */ static PyObject * proxy_slice(PyWeakReference *proxy, int i, int j) { if (!proxy_checkref(proxy)) return NULL; return PySequence_GetSlice(proxy->wr_object, i, j); } static int proxy_ass_slice(PyWeakReference *proxy, int i, int j, PyObject *value) { if (!proxy_checkref(proxy)) return -1; return PySequence_SetSlice(proxy->wr_object, i, j, value); } static int proxy_contains(PyWeakReference *proxy, PyObject *value) { if (!proxy_checkref(proxy)) return -1; return PySequence_Contains(proxy->wr_object, value); } /* mapping slots */ static int proxy_length(PyWeakReference *proxy) { if (!proxy_checkref(proxy)) return -1; return PyObject_Length(proxy->wr_object); } WRAP_BINARY(proxy_getitem, PyObject_GetItem) static int proxy_setitem(PyWeakReference *proxy, PyObject *key, PyObject *value) { if (!proxy_checkref(proxy)) return -1; return PyObject_SetItem(proxy->wr_object, key, value); } static PyNumberMethods proxy_as_number = { (binaryfunc)proxy_add, /*nb_add*/ (binaryfunc)proxy_sub, /*nb_subtract*/ (binaryfunc)proxy_mul, /*nb_multiply*/ (binaryfunc)proxy_div, /*nb_divide*/ (binaryfunc)proxy_mod, /*nb_remainder*/ (binaryfunc)proxy_divmod, /*nb_divmod*/ (ternaryfunc)proxy_pow, /*nb_power*/ (unaryfunc)proxy_neg, /*nb_negative*/ (unaryfunc)proxy_pos, /*nb_positive*/ (unaryfunc)proxy_abs, /*nb_absolute*/ (inquiry)proxy_nonzero, /*nb_nonzero*/ (unaryfunc)proxy_invert, /*nb_invert*/ (binaryfunc)proxy_lshift, /*nb_lshift*/ (binaryfunc)proxy_rshift, /*nb_rshift*/ (binaryfunc)proxy_and, /*nb_and*/ (binaryfunc)proxy_xor, /*nb_xor*/ (binaryfunc)proxy_or, /*nb_or*/ (coercion)0, /*nb_coerce*/ (unaryfunc)proxy_int, /*nb_int*/ (unaryfunc)proxy_long, /*nb_long*/ (unaryfunc)proxy_float, /*nb_float*/ (unaryfunc)0, /*nb_oct*/ (unaryfunc)0, /*nb_hex*/ (binaryfunc)proxy_iadd, /*nb_inplace_add*/ (binaryfunc)proxy_isub, /*nb_inplace_subtract*/ (binaryfunc)proxy_imul, /*nb_inplace_multiply*/ (binaryfunc)proxy_idiv, /*nb_inplace_divide*/ (binaryfunc)proxy_imod, /*nb_inplace_remainder*/ (ternaryfunc)proxy_ipow, /*nb_inplace_power*/ (binaryfunc)proxy_ilshift, /*nb_inplace_lshift*/ (binaryfunc)proxy_irshift, /*nb_inplace_rshift*/ (binaryfunc)proxy_iand, /*nb_inplace_and*/ (binaryfunc)proxy_ixor, /*nb_inplace_xor*/ (binaryfunc)proxy_ior, /*nb_inplace_or*/ }; static PySequenceMethods proxy_as_sequence = { (inquiry)proxy_length, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ (intintargfunc)proxy_slice, /*sq_slice*/ 0, /*sq_ass_item*/ (intintobjargproc)proxy_ass_slice, /*sq_ass_slice*/ (objobjproc)proxy_contains, /* sq_contains */ }; static PyMappingMethods proxy_as_mapping = { (inquiry)proxy_length, /*mp_length*/ (binaryfunc)proxy_getitem, /*mp_subscript*/ (objobjargproc)proxy_setitem, /*mp_ass_subscript*/ }; static PyTypeObject PyWeakProxy_Type = { PyObject_HEAD_INIT(NULL) 0, "weakproxy", sizeof(PyWeakReference) + PyGC_HEAD_SIZE, 0, /* methods */ (destructor)weakref_dealloc,/*tp_dealloc*/ (printfunc)proxy_print, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)proxy_compare, /*tp_compare*/ (unaryfunc)proxy_repr, /*tp_repr*/ &proxy_as_number, /*tp_as_number*/ &proxy_as_sequence, /*tp_as_sequence*/ &proxy_as_mapping, /*tp_as_mapping*/ 0, /*tp_hash*/ (ternaryfunc)0, /*tp_call*/ (unaryfunc)proxy_str, /*tp_str*/ (getattrofunc)proxy_getattr,/*tp_getattro*/ (setattrofunc)proxy_setattr,/*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC |Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ }; static PyTypeObject PyWeakCallableProxy_Type = { PyObject_HEAD_INIT(NULL) 0, "weakcallableproxy", sizeof(PyWeakReference) + PyGC_HEAD_SIZE, 0, /* methods */ (destructor)weakref_dealloc,/*tp_dealloc*/ (printfunc)proxy_print, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)proxy_compare, /*tp_compare*/ (unaryfunc)proxy_repr, /*tp_repr*/ &proxy_as_number, /*tp_as_number*/ &proxy_as_sequence, /*tp_as_sequence*/ &proxy_as_mapping, /*tp_as_mapping*/ 0, /*tp_hash*/ (ternaryfunc)proxy_call, /*tp_call*/ (unaryfunc)proxy_str, /*tp_str*/ (getattrofunc)proxy_getattr,/*tp_getattro*/ (setattrofunc)proxy_setattr,/*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC |Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ }; static long getweakrefcount(PyWeakReference *head) { long count = 0; while (head != NULL) { ++count; head = head->wr_next; } return count; } static PyObject * weakref_getweakrefcount(PyObject *self, PyObject *args) { PyObject *result = NULL; PyObject *object; if (PyArg_ParseTuple(args, "O:getweakrefcount", &object)) { if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); result = PyInt_FromLong(getweakrefcount(*list)); } else result = PyInt_FromLong(0); } return result; } static PyObject * weakref_getweakrefs(PyObject *self, PyObject *args) { PyObject *result = NULL; PyObject *object; if (PyArg_ParseTuple(args, "O:getweakrefs", &object)) { if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); long count = getweakrefcount(*list); result = PyList_New(count); if (result != NULL) { PyWeakReference *current = *list; long i; for (i = 0; i < count; ++i) { PyList_SET_ITEM(result, i, (PyObject *) current); Py_INCREF(current); current = current->wr_next; } } } else { result = PyList_New(0); } } return result; } /* Given the head of an object's list of weak references, extract the * two callback-less refs (ref and proxy). Used to determine if the * shared references exist and to determine the back link for newly * inserted references. */ static void get_basic_refs(PyWeakReference *head, PyWeakReference **refp, PyWeakReference **proxyp) { *refp = NULL; *proxyp = NULL; if (head != NULL && head->wr_callback == NULL) { if (head->ob_type == &PyWeakReference_Type) { *refp = head; head = head->wr_next; } if (head != NULL && head->wr_callback == NULL) { *proxyp = head; head = head->wr_next; } } } /* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ static void insert_after(PyWeakReference *newref, PyWeakReference *prev) { newref->wr_prev = prev; newref->wr_next = prev->wr_next; if (prev->wr_next != NULL) prev->wr_next->wr_prev = newref; prev->wr_next = newref; } /* Insert 'newref' at the head of the list; 'list' points to the variable * that stores the head. */ static void insert_head(PyWeakReference *newref, PyWeakReference **list) { PyWeakReference *next = *list; newref->wr_prev = NULL; newref->wr_next = next; if (next != NULL) next->wr_prev = newref; *list = newref; } static PyObject * weakref_ref(PyObject *self, PyObject *args) { PyObject *object; PyObject *callback = NULL; PyWeakReference *result = NULL; if (PyArg_ParseTuple(args, "O|O:new", &object, &callback)) { PyWeakReference **list; PyWeakReference *ref, *proxy; if (!PyType_SUPPORTS_WEAKREFS(object->ob_type)) { PyErr_Format(PyExc_TypeError, "'%s' objects are not weakly referencable", object->ob_type->tp_name); return NULL; } list = GET_WEAKREFS_LISTPTR(object); get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { /* return existing weak reference if it exists */ result = ref; Py_XINCREF(result); } if (result == NULL) { result = new_weakref(); if (result != NULL) { Py_XINCREF(callback); result->wr_callback = callback; result->wr_object = object; if (callback == NULL) { insert_head(result, list); } else { PyWeakReference *prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) insert_head(result, list); else insert_after(result, prev); } PyObject_GC_Init((PyObject *) result); } } } return (PyObject *) result; } static PyObject * weakref_proxy(PyObject *self, PyObject *args) { PyObject *object; PyObject *callback = NULL; PyWeakReference *result = NULL; if (PyArg_ParseTuple(args, "O|O:new", &object, &callback)) { PyWeakReference **list; PyWeakReference *ref, *proxy; if (!PyType_SUPPORTS_WEAKREFS(object->ob_type)) { PyErr_Format(PyExc_TypeError, "'%s' objects are not weakly referencable", object->ob_type->tp_name); return NULL; } list = GET_WEAKREFS_LISTPTR(object); get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { /* attempt to return an existing weak reference if it exists */ result = proxy; Py_XINCREF(result); } if (result == NULL) { result = new_weakref(); if (result != NULL) { PyWeakReference *prev; if (PyCallable_Check(object)) result->ob_type = &PyWeakCallableProxy_Type; else result->ob_type = &PyWeakProxy_Type; result->wr_object = object; Py_XINCREF(callback); result->wr_callback = callback; if (callback == NULL) prev = ref; else prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) insert_head(result, list); else insert_after(result, prev); PyObject_GC_Init((PyObject *) result); } } } return (PyObject *) result; } /* This is the implementation of the PyObject_ClearWeakRefs() function; it * is installed in the init_weakref() function. It is called by the * tp_dealloc handler to clear weak references. * * This returns true if the object should be deallocated, and false if the * object is resurrected and deallocation should be aborted. * * This iterates through the weak references for 'object' and calls callbacks * until one resurrects the object, at which point it stops invalidating * weak references and returns false. */ static int cleanup_helper(PyObject *object) { PyWeakReference **list; if (object == NULL || !PyType_SUPPORTS_WEAKREFS(object->ob_type) || object->ob_refcnt != 0) { PyErr_BadInternalCall(); /* not sure what we should return here */ return 1; } list = GET_WEAKREFS_LISTPTR(object); while (*list != NULL) { PyWeakReference *current = *list; PyObject *callback = current->wr_callback; Py_XINCREF(callback); clear_weakref(current); if (callback != NULL) { PyObject *cbresult; cbresult = PyObject_CallFunction(callback, "O", current); if (cbresult == NULL) PyErr_WriteUnraisable(callback); else Py_DECREF(cbresult); Py_DECREF(callback); } } return (object->ob_refcnt > 0 ? 0 : 1); } static PyMethodDef weakref_functions[] = { {"getweakrefcount", weakref_getweakrefcount, METH_VARARGS, "getweakrefcount(object) -- return the number of weak references\n" "to 'object'."}, {"getweakrefs", weakref_getweakrefs, METH_VARARGS, "getweakrefs(object) -- return a list of all weak reference objects\n" "that point to 'object'."}, {"proxy", weakref_proxy, METH_VARARGS, "proxy(object[, callback]) -- create a proxy object that weakly\n" "references 'object'. 'callback', if given, is called with a\n" "reference to 'object' when it is about to be finalized."}, {"ref", weakref_ref, METH_VARARGS, "new(object[, callback]) -- create a weak reference to 'object';\n" "when 'object' is finalized, 'callback' will be called and passed\n" "a reference to 'object'."}, {NULL, NULL, 0, NULL} }; void init_weakref(void) { PyObject *m; PyWeakReference_Type.ob_type = &PyType_Type; PyWeakProxy_Type.ob_type = &PyType_Type; PyWeakCallableProxy_Type.ob_type = &PyType_Type; m = Py_InitModule3("_weakref", weakref_functions, "Weak-reference support module."); if (m != NULL) { PyObject_ClearWeakRefs = cleanup_helper; Py_INCREF(&PyWeakReference_Type); PyModule_AddObject(m, "ReferenceType", (PyObject *) &PyWeakReference_Type); Py_INCREF(&PyWeakProxy_Type); PyModule_AddObject(m, "ProxyType", (PyObject *) &PyWeakProxy_Type); Py_INCREF(&PyWeakCallableProxy_Type); PyModule_AddObject(m, "CallableProxyType", (PyObject *) &PyWeakCallableProxy_Type); ReferenceError = PyErr_NewException("weakref.ReferenceError", PyExc_RuntimeError, NULL); if (ReferenceError != NULL) PyModule_AddObject(m, "ReferenceError", ReferenceError); } } From fdrake@users.sourceforge.net Thu Feb 1 05:21:48 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:21:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.175,1.176 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17136/lib Modified Files: lib.tex Log Message: Added entry for weakref documentation. Moved commented-out entries for obsolete module to an appendix, still commented out. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.175 retrieving revision 1.176 diff -C2 -r1.175 -r1.176 *** lib.tex 2001/01/09 22:47:45 1.175 --- lib.tex 2001/02/01 05:21:46 1.176 *************** *** 75,78 **** --- 75,79 ---- \input{libsys} \input{libgc} + \input{libweakref} \input{libfpectl} \input{libatexit} *************** *** 89,93 **** \input{libwarnings} \input{libimp} - %\input{libni} \input{libcode} \input{libcodeop} --- 90,93 ---- *************** *** 103,108 **** \input{libstring} \input{libre} - %\input{libregex} - %\input{libregsub} \input{libstruct} \input{libfpformat} --- 103,106 ---- *************** *** 110,114 **** \input{libcodecs} \input{libunicodedata} - %\input{libsoundex} \input{libmisc} % Miscellaneous Services --- 108,111 ---- *************** *** 117,121 **** \input{librandom} \input{libwhrandom} - %\input{librand} \input{libbisect} \input{libarray} --- 114,117 ---- *************** *** 136,141 **** \input{libfilecmp} \input{libpopen2} - %\input{libcmp} - %\input{libcmpcache} \input{libtime} \input{libsched} --- 132,135 ---- *************** *** 305,308 **** --- 299,312 ---- \appendix \input{libundoc} + + %\chapter{Obsolete Modules} + %\input{libcmpcache} + %\input{libcmp} + %\input{libni} + %\input{librand} + %\input{libregex} + %\input{libregsub} + %\input{libsoundex} + \chapter{Reporting Bugs} \input{reportingbugs} From fdrake@users.sourceforge.net Thu Feb 1 05:20:54 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:20:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv17061 Modified Files: Makefile.deps Log Message: Add entry for weakref documentation. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** Makefile.deps 2001/01/09 22:47:45 1.54 --- Makefile.deps 2001/02/01 05:20:52 1.55 *************** *** 54,57 **** --- 54,58 ---- ../lib/libfpectl.tex \ ../lib/libgc.tex \ + ../lib/libweakref.tex \ ../lib/libtypes.tex \ ../lib/libtraceback.tex \ From fdrake@users.sourceforge.net Thu Feb 1 05:20:22 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 31 Jan 2001 21:20:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libweakref.tex,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17018/lib Added Files: libweakref.tex Log Message: Documentation for the weakref module. --- NEW FILE: libweakref.tex --- \section{\module{weakref} --- Weak references} \declaremodule{extension}{weakref} \moduleauthor{Fred L. Drake, Jr.}{fdrake@acm.org} \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} \versionadded{2.1} The \module{weakref} module allows the Python programmer to create \dfn{weak references} to objects. XXX --- need to say more here! Not all objects can be weakly referenced; those objects which do include class instances and dictionaries. Extension types can easily be made to support weak references; see section \ref{weakref-extension}, ``Weak References in Extension Types,'' for more information. \strong{Warning:} The weak dictionaries provided in the current implementation and described below are subject to change. They are included to solicit feedback and usage experience, and may be changed or removed in the final version. \strong{Warning:} The desired semantics of weak-reference proxy objects are not completely clear; it is very difficult to create proxies which behave exactly like the type of the referent. The details of these objects are likely to change to some degree before the final release as experience reports become available. Please send specific feeback on this module to Fred Drake at \email{fdrake@acm.org}. \begin{funcdesc}{ref}{object\optional{, callback}} Return a weak reference to \var{object}. If \var{callback} is provided, it will be called when the object is about to be finalized; the weak reference object will be passed as the only parameter to the callback; the referent will no longer be available. The original object can be retrieved by calling the reference object, if the referent is still alive. It is allowable for many weak references to be constructed for the same object. Callbacks registered for each weak reference will be called from the most recently registered callback to the oldest registered callback. Exceptions raised by the callback will be noted on the standard error output, but cannot be propogated; they are handled in exactly the same way as exceptions raised from an object's \method{__del__()} method. \end{funcdesc} \begin{funcdesc}{mapping}{\optional{dict}} Return a weak dictionary. If \var{dict} is given and not \code{None}, the new dictionary will contain the items contained in \var{dict}. The values from \var{dict} must be weakly referencable; if any values which would be inserted into the new mapping are not weakly referencable, \exception{TypeError} will be raised and the new mapping will be empty. \end{funcdesc} \begin{funcdesc}{proxy}{object\optional{, callback}} Return a proxy to \var{object} which uses a weak reference. This supports use of the proxy in most contexts instead of requiring the explicit dereferencing used with weak reference objects. The returned object will have a type of either \code{ProxyType} or \code{CallableProxyType}, depending on whether \var{object} is callable. Proxy objects are not hashable regardless of the referent; this avoids a number of problems related to their fundamentally mutable nature, and prevent their use as dictionary keys. \var{callable} is the same as the parameter of the same name to the \function{ref()} function. \end{funcdesc} \begin{funcdesc}{getweakrefcount}{object} Return the number of weak references and proxies which refer to \var{object}. \end{funcdesc} \begin{funcdesc}{getweakrefs}{object} Return a list of all weak reference and proxy objects which refer to \var{object}. \end{funcdesc} \begin{classdesc}{WeakDictionary}{\optional{dict}} The class of the mapping objects returned by \function{mapping()}. This can be used for subclassing the implementation if needed. \end{classdesc} \begin{datadesc}{ReferenceType} The type object for weak references objects. \end{datadesc} \begin{datadesc}{ProxyType} The type object for proxies of objects which are not callable. \end{datadesc} \begin{datadesc}{CallableProxyType} The type object for proxies of callable objects. \end{datadesc} \begin{datadesc}{ProxyTypes} Sequence containing all the type objects for proxies. This can make it simpler to test if an object is a proxy without being dependent on naming both proxy types. \end{datadesc} \begin{seealso} \seepep{0205}{Weak References}{The proposal and rationale for this feature, including links to earlier implementations and information about similar features in other languages.} \end{seealso} \subsection{Weak Reference Objects \label{weakref-objects}} Weak reference objects have no attributes or methods, but do allow the referent to be obtained, if it still exists, by calling it: \begin{verbatim} >>> import weakref >>> class Object: ... pass ... >>> o = Object() >>> r = weakref.ref(o) >>> o2 = r() >>> o is o2 1 \end{verbatim} If the referent no longer exists, calling the reference object returns \code{None}: \begin{verbatim} >>> del o, o2 >>> print r() None \end{verbatim} Testing that a weak reference object is still live should be done using the expression \code{\var{ref}.get() is not None}. Normally, application code that needs to use a reference object should follow this pattern: \begin{verbatim} o = ref.get() if o is None: # referent has been garbage collected print "Object has been allocated; can't frobnicate." else: print "Object is still live!" o.do_something_useful() \end{verbatim} Using a separate test for ``liveness'' creates race conditions in threaded applications; another thread can cause a weak reference to become invalidated before the \method{get()} method is called; the idiom shown above is safe in threaded applications as well as single-threaded applications. \subsection{Weak References in Extension Types \label{weakref-extension}} One of the goals of the implementation is to allow any type to participate in the weak reference mechanism without incurring the overhead on those objects which do not benefit by weak referencing (such as numbers). For an object to be weakly referencable, the extension must include a \ctype{PyObject *} field in the instance structure for the use of the weak reference mechanism; it will be initialized by Python's functions for object creation. It must also set the \code{tp_weaklistoffset} field of the corresponding type object to the offset of the field. For example, the instance type is defined with the following structure: \begin{verbatim} typedef struct { PyObject_HEAD PyClassObject *in_class; /* The class object */ PyObject *in_dict; /* A dictionary */ PyObject *in_weakreflist; /* List of weak references */ } PyInstanceObject; \end{verbatim} The statically-declared type object for instances is defined this way: \begin{verbatim} PyTypeObject PyInstance_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, "instance", /* lots of stuff omitted for brevity */ offsetof(PyInstanceObject, in_weakreflist) /* tp_weaklistoffset */ }; \end{verbatim} The only further addition is that the destructor needs to call the weak reference manager to clear any weak references and return if the object has been resurrected. This needs to occur before any other parts of the destruction have occurred: \begin{verbatim} static void instance_dealloc(PyInstanceObject *inst) { /* allocate tempories if needed, but do not begin destruction here */ if (!PyObject_ClearWeakRefs((PyObject *) inst)) return; /* proceed with object destuction normally */ } \end{verbatim} From tim_one@users.sourceforge.net Thu Feb 1 05:10:04 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 31 Jan 2001 21:10:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.5,1.6 python20.wse,1.23,1.24 pythoncore.dsp,1.2,1.3 readme.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv15723/python/dist/src/PCbuild Modified Files: BUILDno.txt python20.wse pythoncore.dsp readme.txt Log Message: Windows build: update for 2.1a2, + get ucnhash out of the installer. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** BUILDno.txt 2001/01/17 23:23:13 1.5 --- BUILDno.txt 2001/02/01 05:10:02 1.6 *************** *** 34,37 **** --- 34,39 ---- Windows Python BUILD numbers ---------------------------- + 10 2.1a2 + 1-Feb-2001 9 2.1a1 17-Jan-2001 Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** python20.wse 2001/01/17 23:23:13 1.23 --- python20.wse 2001/02/01 05:10:02 1.24 *************** *** 2,6 **** item: Global Version=5.0 ! Title=Python 2.1 alpha 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=5.0 ! Title=Python 2.1 alpha 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 65,69 **** item: Set Variable Variable=APPTITLE ! Value=Python 2.1 alpha 1 end item: Set Variable --- 65,69 ---- item: Set Variable Variable=APPTITLE ! Value=Python 2.1 alpha 2 end item: Set Variable *************** *** 73,77 **** item: Set Variable Variable=PY_VERSION ! Value=2.1a1 end item: Set Variable --- 73,77 ---- item: Set Variable Variable=PY_VERSION ! Value=2.1a2 end item: Set Variable *************** *** 728,736 **** end item: Install File - Source=%_SRC_%\PCbuild\ucnhash.pyd - Destination=%MAINDIR%\DLLs\ucnhash.pyd - Flags=0000000000000010 - end - item: Install File Source=%_SRC_%\PCbuild\unicodedata.pyd Destination=%MAINDIR%\DLLs\unicodedata.pyd --- 728,731 ---- *************** *** 795,803 **** Source=%_SRC_%\PCbuild\select.lib Destination=%MAINDIR%\libs\select.lib - Flags=0000000000000010 - end - item: Install File - Source=%_SRC_%\PCbuild\ucnhash.lib - Destination=%MAINDIR%\libs\ucnhash.lib Flags=0000000000000010 end --- 790,793 ---- Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pythoncore.dsp 2001/01/26 00:12:49 1.2 --- pythoncore.dsp 2001/02/01 05:10:02 1.3 *************** *** 710,718 **** !IF "$(CFG)" == "pythoncore - Win32 Release" ! # ADD CPP /D BUILD=9 !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" ! # ADD CPP /D BUILD=9 !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" --- 710,718 ---- !IF "$(CFG)" == "pythoncore - Win32 Release" ! # ADD CPP /D BUILD=10 !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" ! # ADD CPP /D BUILD=10 !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** readme.txt 2001/01/31 19:39:44 1.16 --- readme.txt 2001/02/01 05:10:02 1.17 *************** *** 92,95 **** --- 92,97 ---- Note that if you're running Win9X, you'll need to run vcvars32.bat before running nmake (this batch file is in your MSVC installation). + TODO: make this work like zlib (in particular, MSVC runs the prelink + step in an enviroment that already has the correct envars set up). pyexpat From tim_one@users.sourceforge.net Thu Feb 1 04:59:20 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 31 Jan 2001 20:59:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.111,1.112 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv14254/python/dist/src/Misc Modified Files: NEWS Log Message: Change random.seed() so that it can get at the full range of possible internal states. Put the old .seed() (which could only get at about the square root of the # of possibilities) under the new name .whseed(), for bit-level compatibility with older versions. This occurred to me while reviewing effbot's book (he found himself stumbling over .seed() more than once there ...). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -r1.111 -r1.112 *** NEWS 2001/01/31 22:14:01 1.111 --- NEWS 2001/02/01 04:59:18 1.112 *************** *** 33,36 **** --- 33,46 ---- non-overlapping segment of the full period. + - random.py's seed() function is new. For bit-for-bit compatibility with + prior releases, use the whseed function instead. The new seed function + addresses two problems: (1) The old function couldn't produce more than + about 2**24 distinct internal states; the new one about 2**45 (the best + that can be done in the Wichmann-Hill generator). (2) The old function + sometimes produced identical internal states when passed distinct + integers, and there was no simple way to predict when that would happen; + the new one guarantees to produce distinct internal states for all + arguments in [0, 27814431486576L). + Windows changes From tim_one@users.sourceforge.net Thu Feb 1 04:59:20 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 31 Jan 2001 20:59:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib random.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14254/python/dist/src/Lib Modified Files: random.py Log Message: Change random.seed() so that it can get at the full range of possible internal states. Put the old .seed() (which could only get at about the square root of the # of possibilities) under the new name .whseed(), for bit-level compatibility with older versions. This occurred to me while reviewing effbot's book (he found himself stumbling over .seed() more than once there ...). Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** random.py 2001/01/26 22:56:56 1.21 --- random.py 2001/02/01 04:59:18 1.22 *************** *** 67,74 **** >>> g = Random(42) # arbitrary >>> g.random() ! 0.24855401895528142 >>> g.jumpahead(6953607871644L - 1) # move *back* one >>> g.random() ! 0.24855401895528142 """ # XXX The docstring sucks. --- 67,74 ---- >>> g = Random(42) # arbitrary >>> g.random() ! 0.25420336316883324 >>> g.jumpahead(6953607871644L - 1) # move *back* one >>> g.random() ! 0.25420336316883324 """ # XXX The docstring sucks. *************** *** 120,143 **** # getstate(), setstate() and jumpahead() methods. ! def __whseed(self, x=0, y=0, z=0): ! """Set the Wichmann-Hill seed from (x, y, z). ! These must be integers in the range [0, 256). """ ! if not type(x) == type(y) == type(z) == type(0): ! raise TypeError('seeds must be integers') ! if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): ! raise ValueError('seeds must be in range(0, 256)') ! if 0 == x == y == z: # Initialize from current time import time ! t = long(time.time()) * 256 ! t = int((t&0xffffff) ^ (t>>24)) ! t, x = divmod(t, 256) ! t, y = divmod(t, 256) ! t, z = divmod(t, 256) ! # Zero is a poor seed, so substitute 1 ! self._seed = (x or 1, y or 1, z or 1) def random(self): --- 120,148 ---- # getstate(), setstate() and jumpahead() methods. ! def seed(self, a=None): ! """Initialize internal state from hashable object. ! None or no argument seeds from current time. ! ! If a is not None or an int or long, hash(a) is instead. ! ! If a is an int or long, a is used directly. Distinct values between ! 0 and 27814431486575L inclusive are guaranteed to yield distinct ! internal states (this guarantee is specific to the default ! Wichmann-Hill generator). """ ! if a is None: # Initialize from current time import time ! a = long(time.time() * 256) ! ! if type(a) not in (type(3), type(3L)): ! a = hash(a) ! ! a, x = divmod(a, 30268) ! a, y = divmod(a, 30306) ! a, z = divmod(a, 30322) ! self._seed = int(x)+1, int(y)+1, int(z)+1 def random(self): *************** *** 172,195 **** return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 - def seed(self, a=None): - """Seed from hashable object's hash code. - - None or no argument seeds from current time. It is not guaranteed - that objects with distinct hash codes lead to distinct internal - states. - """ - - if a is None: - self.__whseed() - return - a = hash(a) - a, x = divmod(a, 256) - a, y = divmod(a, 256) - a, z = divmod(a, 256) - x = (x + a) % 256 or 1 - y = (y + a) % 256 or 1 - z = (z + a) % 256 or 1 - self.__whseed(x, y, z) - def getstate(self): """Return internal state; can be passed to setstate() later.""" --- 177,180 ---- *************** *** 228,231 **** --- 213,260 ---- self._seed = x, y, z + def __whseed(self, x=0, y=0, z=0): + """Set the Wichmann-Hill seed from (x, y, z). + + These must be integers in the range [0, 256). + """ + + if not type(x) == type(y) == type(z) == type(0): + raise TypeError('seeds must be integers') + if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): + raise ValueError('seeds must be in range(0, 256)') + if 0 == x == y == z: + # Initialize from current time + import time + t = long(time.time() * 256) + t = int((t&0xffffff) ^ (t>>24)) + t, x = divmod(t, 256) + t, y = divmod(t, 256) + t, z = divmod(t, 256) + # Zero is a poor seed, so substitute 1 + self._seed = (x or 1, y or 1, z or 1) + + def whseed(self, a=None): + """Seed from hashable object's hash code. + + None or no argument seeds from current time. It is not guaranteed + that objects with distinct hash codes lead to distinct internal + states. + + This is obsolete, provided for compatibility with the seed routine + used prior to Python 2.1. Use the .seed() method instead. + """ + + if a is None: + self.__whseed() + return + a = hash(a) + a, x = divmod(a, 256) + a, y = divmod(a, 256) + a, z = divmod(a, 256) + x = (x + a) % 256 or 1 + y = (y + a) % 256 or 1 + z = (z + a) % 256 or 1 + self.__whseed(x, y, z) + ## ---- Methods below this point do not need to be overridden when ## ---- subclassing for the purpose of using a different core generator. *************** *** 624,627 **** --- 653,657 ---- setstate = _inst.setstate jumpahead = _inst.jumpahead + whseed = _inst.whseed if __name__ == '__main__': From tim_one@users.sourceforge.net Thu Feb 1 04:59:20 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 31 Jan 2001 20:59:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librandom.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv14254/python/dist/src/Doc/lib Modified Files: librandom.tex Log Message: Change random.seed() so that it can get at the full range of possible internal states. Put the old .seed() (which could only get at about the square root of the # of possibilities) under the new name .whseed(), for bit-level compatibility with older versions. This occurred to me while reviewing effbot's book (he found himself stumbling over .seed() more than once there ...). Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** librandom.tex 2001/01/26 10:00:39 1.21 --- librandom.tex 2001/02/01 04:59:17 1.22 *************** *** 26,30 **** function supplied by most C libraries, the theoretical properties are much the same as for a single linear congruential generator of ! large modulus. The functions in this module are not threadsafe: if you want to call these --- 26,31 ---- function supplied by most C libraries, the theoretical properties are much the same as for a single linear congruential generator of ! large modulus. It is not suitable for all purposes, and is completely ! unsuitable for cryptographic purposes. The functions in this module are not threadsafe: if you want to call these *************** *** 73,77 **** threads. The generators don't share state so can be called safely in parallel. So long as no thread calls its \code{g.random()} more than a ! million times (the second argument to \function{create_generators}), the sequences seen by each thread will not overlap. The period of the underlying Wichmann-Hill generator limits how far this technique can be --- 74,78 ---- threads. The generators don't share state so can be called safely in parallel. So long as no thread calls its \code{g.random()} more than a ! million times (the second argument to \function{create_generators), the sequences seen by each thread will not overlap. The period of the underlying Wichmann-Hill generator limits how far this technique can be *************** *** 84,91 **** >>> g = Random(42) # arbitrary >>> g.random() ! 0.24855401895528142 >>> g.jumpahead(6953607871644L - 1) # move *back* one >>> g.random() ! 0.24855401895528142 \end{verbatim} --- 85,92 ---- >>> g = Random(42) # arbitrary >>> g.random() ! 0.25420336316883324 >>> g.jumpahead(6953607871644L - 1) # move *back* one >>> g.random() ! 0.25420336316883324 \end{verbatim} *************** *** 95,117 **** \begin{funcdesc}{seed}{\optional{x}} Initialize the basic random number generator. ! Optional argument \var{x} can be any hashable object, ! and the generator is seeded from its hash code. ! It is not guaranteed that distinct hash codes will produce distinct ! seeds. ! If \var{x} is omitted or \code{None}, ! the seed is derived from the current system time. ! The seed is also set from the current system time when ! the module is first imported. \end{funcdesc} \begin{funcdesc}{getstate}{} Return an object capturing the current internal state of the generator. This object can be passed to \code{setstate()} to restore the state. ! \end{funcdesc} \begin{funcdesc}{setstate}{state} \var{state} should have been obtained from a previous call to \code{getstate()}, and \code{setstate()} restores the internal state ! of the generate to what it was at the time \code{setstate()} was called. \end{funcdesc} --- 96,131 ---- \begin{funcdesc}{seed}{\optional{x}} Initialize the basic random number generator. ! Optional argument \var{x} can be any hashable object. ! If \var(x) is omitted or \code{None}, current system time is used; ! current system time is also used to initialize the generator when the ! module is first imported. ! If \var(x) is not \code{None} or an int or long, ! \code{hash(\var{x})) is used instead. ! If \var{x} is an int or long, \var{x} is used directly. ! Distinct values between 0 and 27814431486575L inclusive are guaranteed ! to yield distinct internal states (this guarantee is specific to the ! default Wichmann-Hill generator, and may not apply to subclasses ! supplying their own basic generator). \end{funcdesc} + \begin{funcdesc}{whseed}{\optional{x}} + This is obsolete, supplied for bit-level compatibility with versions + of Python prior to 2.1. + See \function{seed} for details. \function{whseed} does not guarantee + that distinct integer arguments yield distinct internal states, and can + yield no more than about 2**24 distinct internal states in all. + \end{funcdesc} + \begin{funcdesc}{getstate}{} Return an object capturing the current internal state of the generator. This object can be passed to \code{setstate()} to restore the state. ! \versionadded{2.1} ! \end{funcdesc} \begin{funcdesc}{setstate}{state} \var{state} should have been obtained from a previous call to \code{getstate()}, and \code{setstate()} restores the internal state ! of the generator to what it was at the time \code{setstate()} was called. ! \versionadded{2.1} \end{funcdesc} *************** *** 125,128 **** --- 139,143 ---- instances' states as far apart as you like (up to the period of the generator). + \versionadded{2.1} \end{funcdesc} From jhylton@users.sourceforge.net Thu Feb 1 03:51:01 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Wed, 31 Jan 2001 19:51:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref4.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv5037 Modified Files: ref4.tex Log Message: update section 4.1 to describe nested scopes Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** ref4.tex 2000/04/03 04:41:18 1.22 --- ref4.tex 2001/02/01 03:50:59 1.23 *************** *** 33,56 **** information (used for debugging), determines where and how execution continues after the code block's execution has completed, and (perhaps ! most importantly) defines two namespaces, the local and the global ! namespace, that affect execution of the code block. ! A \dfn{namespace}\index{namespace} is a mapping from names ! (identifiers) to objects. A particular namespace may be referenced by ! more than one execution frame, and from other places as well. Adding ! a name to a namespace is called \dfn{binding}\indexii{binding}{name} a ! name (to an object); changing the mapping of a name is called ! \dfn{rebinding}\indexii{rebinding}{name}; removing a name is \dfn{unbinding}\indexii{unbinding}{name}. Namespaces are functionally equivalent to dictionaries (and often implemented as dictionaries). ! The \dfn{local namespace}\indexii{local}{namespace} of an execution ! frame determines the default place where names are defined and ! searched. The ! \dfn{global namespace}\indexii{global}{namespace} determines the place ! where names listed in \keyword{global}\stindex{global} statements are ! defined and searched, and where names that are not bound anywhere in ! the current code block are searched. Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the --- 33,88 ---- information (used for debugging), determines where and how execution continues after the code block's execution has completed, and (perhaps ! most importantly) defines the environment in which names are resolved. ! A \dfn{namespace}\indexii{namespace} is a mapping from names ! (identifiers) to objects. An \dfn{environment}\index{environment} is ! a hierarchical collection of the namespaces that are visible to a ! particular code block. Python namespaces are statically scoped in the ! tradition of Algol, but also has \keyword{global} statement that can ! be used to access the top-level namespace on the environment. ! ! Names refers to objects. Names are introduced by name ! \dfn{binding}\indexii{binding}{name} operations. Each occurrence of a name ! in the program text refers to the binding of that name established in ! the innermost function namespace containing the use. Changing the ! mapping of a name to an object is called ! \dfn{rebinding}\indexii{rebinding}{name}; removing a name is \dfn{unbinding}\indexii{unbinding}{name}. Namespaces are functionally equivalent to dictionaries (and often implemented as dictionaries). ! When a name is bound, a mapping is created in the \dfn{local ! namespace}\indexii{local}{namespace} of the execution frame unless the ! name is declared global. If a name binding operation occurs anywhere ! within a code block, all uses of the name within the block are treated ! as references to the local namespace. (Note: This can lead to errors ! when a name is used within a block before it is bound.) ! ! The \dfn{global namespace}\indexii{global}{namespace} determines the ! place where names listed in \keyword{global}\stindex{global} ! statements are defined and searched. The global namespace of a block ! is the namespace of the module in which the block was defined. ! ! If a name is used within a code block, but it is not bound there and ! is not declared global, it is a \dfn{free variable} ! \indexii{free}{variable}. A free variable is resolved using the ! nearest enclosing function block that has a binding for the name. If ! no such block exists, the name is resolved in the global namespace. + When a name is not found at all, a + \exception{NameError}\withsubitem{(built-in + exception)}{\ttindex{NameError}} exception is raised. + + The local namespace of a class definition becomes the attribute + dictionary of the class. If a block is contained within a class + definition, the name bindings that occur in the containing class block + are not visible to enclosed blocks. + + The following constructs bind names: formal parameters to functions, + \keyword{import} statements, class and function definitions (these bind + the class or function name in the defining block), and identifiers + occurring as the target of an assignment, in a \keyword{for} loop header + (including list comprehensions), or in the second position of an + \keyword{except} clause. + Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the *************** *** 58,148 **** in the code block is local in the entire code block; all other names are considered global. The \keyword{global} statement forces global ! interpretation of selected names throughout the code block. The ! following constructs bind names: formal parameters to functions, \keyword{import} statements, class and function definitions (these bind the class or function name in the defining block), and targets that are identifiers if occurring in an assignment, \keyword{for} loop header, or in the second position of an \keyword{except} clause ! header. Local names are searched only on the local namespace; global ! names are searched only in the global and built-in ! namespace.\footnote{ ! If the code block contains \keyword{exec} statements or the ! construct ``\samp{from \ldots import *}'', the semantics of local ! names change: local name lookup first searches the local namespace, ! then the global namespace and the built-in namespace.} A target occurring in a \keyword{del} statement is also considered bound ! for this purpose (though the actual semantics are to ``unbind'' the ! name). When a global name is not found in the global namespace, it is searched in the built-in namespace (which is actually the global ! namespace of the module ! \module{__builtin__}\refbimodindex{__builtin__}). The built-in ! namespace associated with the execution of a code block is actually ! found by looking up the name \code{__builtins__} is its global ! namespace; this should be a dictionary or a module (in the latter case ! its dictionary is used). Normally, the \code{__builtins__} namespace ! is the dictionary of the built-in module \module{__builtin__} (note: ! no `s'); if it isn't, restricted ! execution\indexii{restricted}{execution} mode is in effect. When a ! name is not found at all, a ! \exception{NameError}\withsubitem{(built-in ! exception)}{\ttindex{NameError}} exception is raised. \stindex{from} \stindex{exec} \stindex{global} - - The following table lists the meaning of the local and global - namespace for various types of code blocks. The namespace for a - particular module is automatically created when the module is first - imported (i.e., when it is loaded). Note that in almost all cases, - the global namespace is the namespace of the containing module --- - scopes in Python do not nest! - - \begin{tableiv}{l|l|l|l}{textrm} - {Code block type}{Global namespace}{Local namespace}{Notes} - \lineiv{Module} - {n.s. for this module} - {same as global}{} - \lineiv{Script (file or command)} - {n.s. for \module{__main__}\refbimodindex{__main__}} - {same as global}{(1)} - \lineiv{Interactive command} - {n.s. for \module{__main__}\refbimodindex{__main__}} - {same as global}{} - \lineiv{Class definition} - {global n.s. of containing block} - {new n.s.}{} - \lineiv{Function body} - {global n.s. of containing block} - {new n.s.}{(2)} - \lineiv{String passed to \keyword{exec} statement} - {global n.s. of containing block} - {local n.s. of containing block}{(2), (3)} - \lineiv{String passed to \function{eval()}} - {global n.s. of caller} - {local n.s. of caller}{(2), (3)} - \lineiv{File read by \function{execfile()}} - {global n.s. of caller} - {local n.s. of caller}{(2), (3)} - \lineiv{Expression read by \function{input()}} - {global n.s. of caller} - {local n.s. of caller}{} - \end{tableiv} - - Notes: - - \begin{description} - - \item[n.s.] means \emph{namespace} - - \item[(1)] The main module for a script is always called - \module{__main__}; ``the filename don't enter into it.'' - - \item[(2)] The global and local namespace for these can be - overridden with optional extra arguments. ! \item[(3)] The \keyword{exec} statement and the \function{eval()} and \function{execfile()} functions have optional arguments to override the global and local namespace. If only one namespace is specified, --- 90,137 ---- in the code block is local in the entire code block; all other names are considered global. The \keyword{global} statement forces global ! interpretation of selected names throughout the code block. ! ! The following constructs bind names: formal parameters to functions, \keyword{import} statements, class and function definitions (these bind the class or function name in the defining block), and targets that are identifiers if occurring in an assignment, \keyword{for} loop header, or in the second position of an \keyword{except} clause ! header. The \keyword{import} statement of the form ``\samp{from ! \ldots import *}'' binds all names defined in the imported module, ! except those beginning with an underscore. This form may only be used ! at the module level. A target occurring in a \keyword{del} statement is also considered bound ! for this purpose (though the actual semantics are to unbind the ! name). It is illegal to unbind a name that is referenced by an ! enclosing scope; the compiler will report a \exception{SyntaxError}. When a global name is not found in the global namespace, it is searched in the built-in namespace (which is actually the global ! namespace of the module \module{__builtin__}\refbimodindex{__builtin__}). ! The built-in namespace associated with the execution of a code block ! is actually found by looking up the name \code{__builtins__} is its ! global namespace; this should be a dictionary or a module (in the ! latter case its dictionary is used). Normally, the ! \code{__builtins__} namespace is the dictionary of the built-in module ! \module{__builtin__} (note: no `s'). If it isn't, restricted ! execution\indexii{restricted}{execution} mode is in effect. \stindex{from} \stindex{exec} \stindex{global} ! The namespace for a module is automatically created the first time a ! module is imported. The main module for a script is always called ! \module{__main__}\refbimodindex{__main__}. ! ! The \function{eval()}, \function{execfile()}, and \function{input()} ! functions and the \keyword{exec} statement do not have access to the ! full environment for resolving names. Names may be resolved in the ! local and global namespaces of the caller. Free variables are not ! resolved in the nearest enclosing namespaces, but in the global ! namespace.\footnote{This limitation occurs because the code that is ! executed by these operations is not available at the time the ! module is compiled.} ! The \keyword{exec} statement and the \function{eval()} and \function{execfile()} functions have optional arguments to override the global and local namespace. If only one namespace is specified, *************** *** 151,158 **** \end{description} ! The built-in functions \function{globals()} and \function{locals()} returns a ! dictionary representing the current global and local namespace, ! respectively. The effect of modifications to this dictionary on the ! namespace are undefined.\footnote{ The current implementations return the dictionary actually used to implement the namespace, \emph{except} for functions, where the --- 140,147 ---- \end{description} ! The built-in functions \function{globals()} and \function{locals()} ! each return a dictionary, representing the current global and local ! namespace respectively. The effect of modifications to these ! dictionaries on the namespace are undefined.\footnote{ The current implementations return the dictionary actually used to implement the namespace, \emph{except} for functions, where the From fdrake@users.sourceforge.net Thu Feb 1 15:37:58 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 07:37:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref4.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv23174/ref Modified Files: ref4.tex Log Message: Remove spurious "\end{description}" that caused formatting to fail. Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** ref4.tex 2001/02/01 03:50:59 1.23 --- ref4.tex 2001/02/01 15:37:56 1.24 *************** *** 138,143 **** it is used for both. - \end{description} - The built-in functions \function{globals()} and \function{locals()} each return a dictionary, representing the current global and local --- 138,141 ---- From fdrake@users.sourceforge.net Thu Feb 1 15:53:27 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 07:53:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librandom.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26810/lib Modified Files: librandom.tex Log Message: Fix some markup breakage that prevented formatting; re-wrapped a couple of wide paragraphs. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** librandom.tex 2001/02/01 04:59:17 1.22 --- librandom.tex 2001/02/01 15:53:24 1.23 *************** *** 71,84 **** \end{verbatim} ! That creates 10 distinct generators, which can be passed out to 10 distinct ! threads. The generators don't share state so can be called safely in ! parallel. So long as no thread calls its \code{g.random()} more than a ! million times (the second argument to \function{create_generators), the ! sequences seen by each thread will not overlap. The period of the ! underlying Wichmann-Hill generator limits how far this technique can be ! pushed. ! Just for fun, note that since we know the period, \method{jumpahead()} can ! also be used to "move backward in time": \begin{verbatim} --- 71,84 ---- \end{verbatim} ! That creates 10 distinct generators, which can be passed out to 10 ! distinct threads. The generators don't share state so can be called ! safely in parallel. So long as no thread calls its \code{g.random()} ! more than a million times (the second argument to ! \function{create_generators()}, the sequences seen by each thread will ! not overlap. The period of the underlying Wichmann-Hill generator ! limits how far this technique can be pushed. ! Just for fun, note that since we know the period, \method{jumpahead()} ! can also be used to ``move backward in time:'' \begin{verbatim} *************** *** 101,105 **** module is first imported. If \var(x) is not \code{None} or an int or long, ! \code{hash(\var{x})) is used instead. If \var{x} is an int or long, \var{x} is used directly. Distinct values between 0 and 27814431486575L inclusive are guaranteed --- 101,105 ---- module is first imported. If \var(x) is not \code{None} or an int or long, ! \code{hash(\var{x})} is used instead. If \var{x} is an int or long, \var{x} is used directly. Distinct values between 0 and 27814431486575L inclusive are guaranteed From fdrake@users.sourceforge.net Thu Feb 1 18:11:31 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 10:11:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_minidom.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26153 Modified Files: test_minidom.py Log Message: Revise the driver code to be more informative in the final report. Index: test_minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** test_minidom.py 2001/01/27 09:17:55 1.22 --- test_minidom.py 2001/02/01 18:11:29 1.23 *************** *** 501,505 **** names.sort() ! works = 1 for name in names: --- 501,505 ---- names.sort() ! failed = [] for name in names: *************** *** 520,535 **** print len(Node.allnodes) Node.allnodes = {} ! except Exception, e: ! works = 0 print "Test Failed: ", name sys.stdout.flush() traceback.print_exception(*sys.exc_info()) ! print `e` Node.allnodes = {} ! if works: ! print "All tests succeeded" else: ! print "\n\n\n\n************ Check for failures!" Node.debug = None # Delete debug output collected in a StringIO object --- 520,538 ---- print len(Node.allnodes) Node.allnodes = {} ! except: ! failed.append(name) print "Test Failed: ", name sys.stdout.flush() traceback.print_exception(*sys.exc_info()) ! print `sys.exc_info()[1]` Node.allnodes = {} ! if failed: ! print "\n\n\n**** Check for failures in these tests:" ! for name in failed: ! print " " + name ! print else: ! print "All tests succeeded" Node.debug = None # Delete debug output collected in a StringIO object From fdrake@users.sourceforge.net Thu Feb 1 19:41:16 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 11:41:16 -0800 Subject: [Python-checkins] CVS: python/dist/src README,1.110,1.111 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv6575 Modified Files: README Log Message: Added note about need for -traditional-cpp on the MacOS X Public Beta. This closes SF bug #129827. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -r1.110 -r1.111 *** README 2001/01/26 22:18:55 1.110 --- README 2001/02/01 19:41:13 1.111 *************** *** 388,391 **** --- 388,398 ---- future release. + MaxOS X: You need to add the "-traditional-cpp" option to the + compiler command line for the MacOS X Public Beta. This is + appearantly a bug in the default pre-processor, and is + expected not to be a problem with future versions. Run + configure with "OPT=-traditional-cpp ./configure" to add this + option. + Configuring threads From jhylton@users.sourceforge.net Thu Feb 1 19:50:31 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 11:50:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules newmodule.c,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv8450/Modules Modified Files: newmodule.c Log Message: move extra arguments to the back of the new.code() arglist Index: newmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/newmodule.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** newmodule.c 2001/01/28 03:55:09 2.31 --- newmodule.c 2001/02/01 19:50:28 2.32 *************** *** 104,108 **** static char new_code_doc[] = ! "Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FREEVARS, CELLVARS, FILENAME, NAME, FIRSTLINENO, LNOTAB)."; static PyObject * --- 104,110 ---- static char new_code_doc[] = ! "Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING,\n" ! "CONSTANTS, NAMES, VARNAMES, FILENAME, NAME, FIRSTLINENO, LNOTAB, FREEVARS,\n" ! "CELLVARS)."; static PyObject * *************** *** 117,122 **** PyObject* names; PyObject* varnames; ! PyObject* freevars; ! PyObject* cellvars; PyObject* filename; PyObject* name; --- 119,124 ---- PyObject* names; PyObject* varnames; ! PyObject* freevars = NULL; ! PyObject* cellvars = NULL; PyObject* filename; PyObject* name; *************** *** 125,129 **** PyBufferProcs *pb; ! if (!PyArg_ParseTuple(args, "iiiiOO!O!O!O!O!SSiS:code", &argcount, &nlocals, &stacksize, &flags, &code, --- 127,131 ---- PyBufferProcs *pb; ! if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", &argcount, &nlocals, &stacksize, &flags, &code, *************** *** 131,139 **** &PyTuple_Type, &names, &PyTuple_Type, &varnames, - &PyTuple_Type, &freevars, - &PyTuple_Type, &cellvars, &filename, &name, ! &firstlineno, &lnotab)) return NULL; pb = code->ob_type->tp_as_buffer; --- 133,156 ---- &PyTuple_Type, &names, &PyTuple_Type, &varnames, &filename, &name, ! &firstlineno, &lnotab, ! &PyTuple_Type, &freevars, ! &PyTuple_Type, &cellvars)) return NULL; + + if (freevars == NULL || cellvars == NULL) { + PyObject *empty = PyTuple_New(0); + if (empty == NULL) + return NULL; + if (freevars == NULL) { + freevars = empty; + Py_INCREF(freevars); + } + if (cellvars == NULL) { + cellvars = empty; + Py_INCREF(cellvars); + } + Py_DECREF(empty); + } pb = code->ob_type->tp_as_buffer; From jhylton@users.sourceforge.net Thu Feb 1 19:50:31 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 11:50:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_new.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8450/Lib/test Modified Files: test_new.py Log Message: move extra arguments to the back of the new.code() arglist Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** test_new.py 2001/01/28 03:57:39 1.10 --- test_new.py 2001/02/01 19:50:29 1.11 *************** *** 67,71 **** # bogus test of new.code() print 'new.code()' ! d = new.code(3, 3, 3, 3, codestr, (), (), (), (), (), "", "", 1, "") if verbose: --- 67,74 ---- # bogus test of new.code() print 'new.code()' ! d = new.code(3, 3, 3, 3, codestr, (), (), (), ! "", "", 1, "", (), ()) ! # test backwards-compatibility version with no freevars or cellvars ! d = new.code(3, 3, 3, 3, codestr, (), (), (), "", "", 1, "") if verbose: From jhylton@users.sourceforge.net Thu Feb 1 19:51:31 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 11:51:31 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv8679 Modified Files: Makefile.pre.in Log Message: add quicktest target -- runs test suite except for the eight slowest tests Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** Makefile.pre.in 2001/01/29 20:18:59 1.8 --- Makefile.pre.in 2001/02/01 19:51:28 1.9 *************** *** 473,476 **** --- 473,483 ---- PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) + QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ + test_unicodedata test_re test_sre test_select test_poll + quicktest: all platform + -rm -f $(srcdir)/Lib/test/*.py[co] + -PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS) + PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS) + # Install everything install: altinstall bininstall maninstall From fdrake@users.sourceforge.net Thu Feb 1 20:00:43 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 12:00:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.112,1.113 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv10419/Misc Modified Files: NEWS Log Message: Added comments about the weak reference support. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -r1.112 -r1.113 *** NEWS 2001/02/01 04:59:18 1.112 --- NEWS 2001/02/01 20:00:40 1.113 *************** *** 14,17 **** --- 14,23 ---- the func_code attribute is writable. + - Weak references (PEP 205) have been added. This involves a few + changes in the core, an extension module (_weakref), and a Python + module (weakref). The weakref module is the public interface. It + includes support for "explicit" weak references, proxy objects, and + mappings with weakly held values. + Standard library From jhylton@users.sourceforge.net Thu Feb 1 20:20:47 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 12:20:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_grammar.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14180/Lib/test Modified Files: test_grammar.py Log Message: Undo recent change that banned using import to bind a global, as per discussion on python-dev. 'from mod import *' is still banned except at the module level. Fix value for special NOOPT entry in symtable. Initialze to 0 instead of None, so that later uses of PyInt_AS_LONG() are valid. (Bug reported by Donn Cave.) replace local REPR macros with PyObject_REPR in object.h Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** test_grammar.py 2001/01/30 01:25:56 1.27 --- test_grammar.py 2001/02/01 20:20:45 1.28 *************** *** 369,373 **** from sys import path, argv check_syntax("def f(): from sys import *") - check_syntax("def f(): global time; import ") print 'global_stmt' # 'global' NAME (',' NAME)* --- 369,372 ---- From jhylton@users.sourceforge.net Thu Feb 1 20:20:47 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 12:20:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.225,2.226 compile.c,2.154,2.155 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv14180/Python Modified Files: ceval.c compile.c Log Message: Undo recent change that banned using import to bind a global, as per discussion on python-dev. 'from mod import *' is still banned except at the module level. Fix value for special NOOPT entry in symtable. Initialze to 0 instead of None, so that later uses of PyInt_AS_LONG() are valid. (Bug reported by Donn Cave.) replace local REPR macros with PyObject_REPR in object.h Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.225 retrieving revision 2.226 diff -C2 -r2.225 -r2.226 *** ceval.c 2001/01/31 01:16:47 2.225 --- ceval.c 2001/02/01 20:20:45 2.226 *************** *** 32,37 **** typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *); - #define REPR(ob) PyString_AS_STRING(PyObject_Repr(ob)) - /* Forward declarations */ --- 32,35 ---- *************** *** 1457,1461 **** PyErr_Format(PyExc_SystemError, "no locals found when storing %s", ! REPR(w)); break; } --- 1455,1459 ---- PyErr_Format(PyExc_SystemError, "no locals found when storing %s", ! PyObject_REPR(w)); break; } *************** *** 1469,1473 **** PyErr_Format(PyExc_SystemError, "no locals when deleting %s", ! REPR(w)); break; } --- 1467,1471 ---- PyErr_Format(PyExc_SystemError, "no locals when deleting %s", ! PyObject_REPR(w)); break; } *************** *** 1564,1568 **** PyErr_Format(PyExc_SystemError, "no locals when loading %s", ! REPR(w)); break; } --- 1562,1566 ---- PyErr_Format(PyExc_SystemError, "no locals when loading %s", ! PyObject_REPR(w)); break; } Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -r2.154 -r2.155 *** compile.c 2001/01/30 01:24:43 2.154 --- compile.c 2001/02/01 20:20:45 2.155 *************** *** 20,25 **** #include "structmember.h" - #define REPR(O) PyString_AS_STRING(PyObject_Repr(O)) - #include --- 20,23 ---- *************** *** 67,73 **** "'from ... import *' may only occur in a module scope" - #define ILLEGAL_IMPORT_GLOBAL \ - "may not import name '%.400s' because it is declared global" - #define MANGLE_LEN 256 --- 65,68 ---- *************** *** 2205,2209 **** if (arg == -1) { fprintf(stderr, "lookup %s in %s %d %d\n", ! REPR(name), c->c_name, reftype, arg); Py_FatalError("com_make_closure()"); } --- 2200,2204 ---- if (arg == -1) { fprintf(stderr, "lookup %s in %s %d %d\n", ! PyObject_REPR(name), c->c_name, reftype, arg); Py_FatalError("com_make_closure()"); } *************** *** 3996,4000 **** char buf[250]; sprintf(buf, "unknown scope for %.100s in %.100s (%s)", ! name, c->c_name, REPR(c->c_symtable->st_cur_id)); Py_FatalError(buf); } --- 3991,3996 ---- char buf[250]; sprintf(buf, "unknown scope for %.100s in %.100s (%s)", ! name, c->c_name, ! PyObject_REPR(c->c_symtable->st_cur_id)); Py_FatalError(buf); } *************** *** 4118,4128 **** goto fail; } - if (info & DEF_IMPORT) { - char buf[500]; - sprintf(buf, ILLEGAL_IMPORT_GLOBAL, - PyString_AS_STRING(name)); - com_error(c, PyExc_SyntaxError, buf); - goto fail; - } if (PyDict_SetItem(c->c_globals, name, Py_None) < 0) goto fail; --- 4114,4117 ---- *************** *** 4530,4534 **** if ((flag & DEF_PARAM) && (val & DEF_PARAM)) { PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, ! name); return -1; } --- 4519,4523 ---- if ((flag & DEF_PARAM) && (val & DEF_PARAM)) { PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, ! PyString_AsString(name)); return -1; } *************** *** 4627,4633 **** symtable_import(st, n); break; ! case exec_stmt: ! if (PyDict_SetItemString(st->st_cur, NOOPT, Py_None) < 0) st->st_errors++; symtable_node(st, CHILD(n, 1)); if (NCH(n) > 2) --- 4616,4629 ---- symtable_import(st, n); break; ! case exec_stmt: { ! PyObject *zero = PyInt_FromLong(0); ! if (zero == NULL) st->st_errors++; + else { + if (PyDict_SetItemString(st->st_cur, NOOPT, + zero) < 0) + st->st_errors++; + Py_DECREF(zero); + } symtable_node(st, CHILD(n, 1)); if (NCH(n) > 2) *************** *** 4636,4639 **** --- 4632,4637 ---- symtable_node(st, CHILD(n, 5)); break; + + } case except_clause: if (NCH(n) == 4) *************** *** 4849,4861 **** { int i; ! /* ! import_stmt: 'import' dotted_as_name (',' dotted_as_name)* | 'from' dotted_name 'import' ('*' | import_as_name (',' import_as_name)*) ! import_as_name: NAME [NAME NAME] */ if (STR(CHILD(n, 0))[0] == 'f') { /* from */ if (TYPE(CHILD(n, 3)) == STAR) { if (st->st_cur_type != TYPE_MODULE) { PyErr_SetString(PyExc_SyntaxError, --- 4847,4859 ---- { int i; ! /* import_stmt: 'import' dotted_as_name (',' dotted_as_name)* | 'from' dotted_name 'import' ('*' | import_as_name (',' import_as_name)*) ! import_as_name: NAME [NAME NAME] */ if (STR(CHILD(n, 0))[0] == 'f') { /* from */ if (TYPE(CHILD(n, 3)) == STAR) { + PyObject *zero = PyInt_FromLong(0); if (st->st_cur_type != TYPE_MODULE) { PyErr_SetString(PyExc_SyntaxError, *************** *** 4864,4870 **** return; } ! if (PyDict_SetItemString(st->st_cur, NOOPT, ! Py_None) < 0) st->st_errors++; } else { for (i = 3; i < NCH(n); i += 2) { --- 4862,4873 ---- return; } ! if (zero == NULL) st->st_errors++; + else { + if (PyDict_SetItemString(st->st_cur, NOOPT, + zero) < 0) + st->st_errors++; + Py_DECREF(zero); + } } else { for (i = 3; i < NCH(n); i += 2) { From jhylton@users.sourceforge.net Thu Feb 1 20:20:47 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 12:20:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_grammar,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv14180/Lib/test/output Modified Files: test_grammar Log Message: Undo recent change that banned using import to bind a global, as per discussion on python-dev. 'from mod import *' is still banned except at the module level. Fix value for special NOOPT entry in symtable. Initialze to 0 instead of None, so that later uses of PyInt_AS_LONG() are valid. (Bug reported by Donn Cave.) replace local REPR macros with PyObject_REPR in object.h Index: test_grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_grammar,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_grammar 2001/01/30 01:25:56 1.11 --- test_grammar 2001/02/01 20:20:45 1.12 *************** *** 38,42 **** import_stmt SyntaxError expected for "def f(): from sys import *" - SyntaxError expected for "def f(): global time; import " global_stmt exec_stmt --- 38,41 ---- From jhylton@users.sourceforge.net Thu Feb 1 20:20:47 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 12:20:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv14180/Include Modified Files: object.h Log Message: Undo recent change that banned using import to bind a global, as per discussion on python-dev. 'from mod import *' is still banned except at the module level. Fix value for special NOOPT entry in symtable. Initialze to 0 instead of None, so that later uses of PyInt_AS_LONG() are valid. (Bug reported by Donn Cave.) replace local REPR macros with PyObject_REPR in object.h Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** object.h 2001/02/01 05:25:27 2.74 --- object.h 2001/02/01 20:20:45 2.75 *************** *** 295,298 **** --- 295,301 ---- extern DL_IMPORT(long) _Py_HashPointer(void*); + /* Helper for passing objects to printf and the like */ + #define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) + /* Flag bits for printing: */ #define Py_PRINT_RAW 1 /* No string quotes etc. */ From jhylton@users.sourceforge.net Thu Feb 1 20:38:47 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 12:38:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.113,1.114 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv19176/Misc Modified Files: NEWS Log Message: Add item about nested scopes. Revise item about restriction on 'from ... import *'. It was in the wrong section and the section restriction was removed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -r1.113 -r1.114 *** NEWS 2001/02/01 20:00:40 1.113 --- NEWS 2001/02/01 20:38:45 1.114 *************** *** 4,7 **** --- 4,40 ---- Core language, builtins, and interpreter + - Scopes nest. If a name is used in a function or class, but is not + local, the definition in the nearest enclosing function scope will + be used. One consequence of this change is that lambda statements + could reference variables in the namespaces where the lambda is + defined. In some unusual cases, this change will break code. + + In all previous version of Python, names were resolved in exactly + three namespaces -- the local namespace, the global namespace, and + the builtin namespace. According to this old defintion, if a + function A is defined within a function B, the names bound in B are + not visible in A. The new rules make names bound in B visible in A, + unless A contains a name binding that hides the binding in B. + + Section 4.1 of the reference manual describes the new scoping rules + in detail. The test script in Lib/test/test_scope.py demonstrates + some of the effects of the change. + + The new rules will cause existing code to break if it defines nested + functions where an outer function has local variables with the same + name as globals or builtins used by the inner function. Example: + + def munge(str): + def helper(x): + return str(x) + if type(str) != type(''): + str = helper(str) + return str.strip() + + Under the old rules, the name str in helper() is bound to the + builtin function str(). Under the new rules, it will be bound to + the argument named str and an error will occur when helper() is + called. + - repr(string) is easier to read, now using hex escapes instead of octal, and using \t, \n and \r instead of \011, \012 and \015 (respectively): *************** *** 14,17 **** --- 47,56 ---- the func_code attribute is writable. + - The compiler will report a SyntaxError if "from ... import *" occurs + in a function or class scope. The language reference has documented + that this case is illegal, but the compiler never checked for it. + The recent introduction of nested scope makes the meaning of this + form of name binding ambiguous. + - Weak references (PEP 205) have been added. This involves a few changes in the core, an extension module (_weakref), and a Python *************** *** 60,69 **** Core language, builtins, and interpreter - - - The compiler will report a SyntaxError if "from ... import *" occurs - in a function or class scope or if a name bound by the import - statement is declared global in the same scope. The language - reference has also documented that these cases are illegal, but - they were not enforced. - There is a new Unicode companion to the PyObject_Str() API --- 99,102 ---- From bwarsaw@users.sourceforge.net Thu Feb 1 20:52:10 2001 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 01 Feb 2001 12:52:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/pynche pyColorChooser.py,2.5,2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/pynche In directory usw-pr-cvs1:/tmp/cvs-serv22930 Modified Files: pyColorChooser.py Log Message: Move the "from Tkinter import *" out of the method and into the module scope (still inside the __name__=='__main__' guard). Necessitated by recent addition of nested scopes. Index: pyColorChooser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/pynche/pyColorChooser.py,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** pyColorChooser.py 1999/04/27 18:56:35 2.5 --- pyColorChooser.py 2001/02/01 20:52:08 2.6 *************** *** 91,97 **** # test stuff if __name__ == '__main__': class Tester: def __init__(self): - from Tkinter import * self.__root = tk = Tk() b = Button(tk, text='Choose Color...', command=self.__choose) --- 91,98 ---- # test stuff if __name__ == '__main__': + from Tkinter import * + class Tester: def __init__(self): self.__root = tk = Tk() b = Button(tk, text='Choose Color...', command=self.__choose) From bwarsaw@users.sourceforge.net Thu Feb 1 21:32:00 2001 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 01 Feb 2001 13:32:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/pynche TypeinViewer.py,2.13,2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/pynche In directory usw-pr-cvs1:/tmp/cvs-serv15869 Modified Files: TypeinViewer.py Log Message: Special case around some of the nastier annoyances with the type-in fields. You can now backspace out the 0 in 0x0, and you can clear the field when in decimal mode. There are still some oddities about typing into these fields, but it should be much less annoying. The real solution is to ditch the update-while-typing "feature". Index: TypeinViewer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/pynche/TypeinViewer.py,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** TypeinViewer.py 1998/10/22 18:48:45 2.13 --- TypeinViewer.py 2001/02/01 21:31:58 2.14 *************** *** 69,75 **** contents = ew.get() icursor = ew.index(INSERT) ! if contents == '': ! contents = '0' ! if contents[0] in 'xX' and self.__hexp.get(): contents = '0' + contents # figure out what the contents value is in the current base --- 69,73 ---- contents = ew.get() icursor = ew.index(INSERT) ! if contents and contents[0] in 'xX' and self.__hexp.get(): contents = '0' + contents # figure out what the contents value is in the current base *************** *** 90,94 **** ew.bell() elif self.__hexp.get(): ! contents = hex(v) else: contents = int(v) --- 88,99 ---- ew.bell() elif self.__hexp.get(): ! # Special case: our contents were 0x0 and we just deleted the ! # trailing 0. We want our contents to now be 0x and not 0x0. ! if v == 0 and contents == '0': ! contents = '0x' ! icursor = END ! ew.bell() ! elif not (v == 0 and contents == '0x'): ! contents = hex(v) else: contents = int(v) *************** *** 110,119 **** blue = string.atoi(bluestr, 16) else: ! red, green, blue = map(string.atoi, (redstr, greenstr, bluestr)) self.__sb.update_views(red, green, blue) def update_yourself(self, red, green, blue): if self.__hexp.get(): ! redstr, greenstr, bluestr = map(hex, (red, green, blue)) else: redstr, greenstr, bluestr = red, green, blue --- 115,138 ---- blue = string.atoi(bluestr, 16) else: ! def intify(colorstr): ! if colorstr == '': ! return 0 ! else: ! return string.atoi(colorstr) ! red, green, blue = map(intify, (redstr, greenstr, bluestr)) self.__sb.update_views(red, green, blue) def update_yourself(self, red, green, blue): if self.__hexp.get(): ! # Special case: our contents were 0x0 and we just deleted the ! # trailing 0. We want our contents to now be 0x and not 0x0. ! def hexify((color, widget)): ! contents = widget.get() ! if not (color == 0 and contents == '0x'): ! return hex(color) ! return contents ! redstr, greenstr, bluestr = map(hexify, ((red, self.__x), ! (green, self.__y), ! (blue, self.__z))) else: redstr, greenstr, bluestr = red, green, blue From jhylton@users.sourceforge.net Thu Feb 1 23:35:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 15:35:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31051/Lib Modified Files: httplib.py Log Message: An ssl-wrapped socket now returns '' on EOF, just like a regular socket -- as suggested by Clarence Gardner. Fix httplib to comply with the new ssl-socket interface. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** httplib.py 2001/01/23 15:35:05 1.32 --- httplib.py 2001/02/01 23:35:20 1.33 *************** *** 576,586 **** raise UnimplementedFileMode() ! msgbuf = "" while 1: try: ! msgbuf = msgbuf + self.__ssl.read() except socket.sslerror, msg: break ! return StringIO(msgbuf) def send(self, stuff, flags = 0): --- 576,589 ---- raise UnimplementedFileMode() ! msgbuf = [] while 1: try: ! buf = self.__ssl.read() except socket.sslerror, msg: break ! if buf == '': ! break ! msgbuf.append(buf) ! return StringIO("".join(msgbuf)) def send(self, stuff, flags = 0): *************** *** 810,813 **** --- 813,817 ---- if hasattr(socket, 'ssl'): host = 'sourceforge.net' + selector = '/projects/python' hs = HTTPS() hs.connect(host) From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-aix4 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-aix4 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-aix4 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:41:19 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:41:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwhrandom.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25401/lib Modified Files: libwhrandom.tex Log Message: Added a warning at the top saying that user code should not use the whrandom module directly. Index: libwhrandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwhrandom.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** libwhrandom.tex 2000/04/03 20:13:54 1.12 --- libwhrandom.tex 2001/02/02 02:41:17 1.13 *************** *** 5,8 **** --- 5,10 ---- \modulesynopsis{Floating point pseudo-random number generator.} + \strong{Note:} This module is an implementation detail of the + \refmodule{random} module. Please do not use this module directly. This module implements a Wichmann-Hill pseudo-random number generator From fdrake@users.sourceforge.net Fri Feb 2 02:42:33 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:42:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librandom.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25490/lib Modified Files: librandom.tex Log Message: Minor markup adjustments. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** librandom.tex 2001/02/01 15:53:24 1.23 --- librandom.tex 2001/02/02 02:42:31 1.24 *************** *** 35,47 **** The functions supplied by this module are actually bound methods of a ! hidden instance of the \var{random.Random} class. You can instantiate your ! own instances of \var{Random} to get generators that don't share state. ! This is especially useful for multi-threaded programs, creating a different ! instance of \var{Random} for each thread, and using the \method{jumpahead()} ! method to ensure that the generated sequences seen by each thread don't ! overlap (see example below). ! Class \var{Random} can also be subclassed if you want to use a different ! basic generator of your own devising: in that case, override the ! \method{random()}, \method{seed()}, \method{getstate()}, \method{setstate()} and \method{jumpahead()} methods. --- 35,49 ---- The functions supplied by this module are actually bound methods of a ! hidden instance of the \class{random.Random} class. You can ! instantiate your own instances of \class{Random} to get generators ! that don't share state. This is especially useful for multi-threaded ! programs, creating a different instance of \class{Random} for each ! thread, and using the \method{jumpahead()} method to ensure that the ! generated sequences seen by each thread don't overlap (see example ! below). ! ! Class \class{Random} can also be subclassed if you want to use a ! different basic generator of your own devising: in that case, override ! the \method{random()}, \method{seed()}, \method{getstate()}, \method{setstate()} and \method{jumpahead()} methods. *************** *** 118,123 **** \begin{funcdesc}{getstate}{} ! Return an object capturing the current internal state of the generator. ! This object can be passed to \code{setstate()} to restore the state. \versionadded{2.1} \end{funcdesc} --- 120,126 ---- \begin{funcdesc}{getstate}{} ! Return an object capturing the current internal state of the ! generator. This object can be passed to \function{setstate()} to ! restore the state. \versionadded{2.1} \end{funcdesc} *************** *** 125,142 **** \begin{funcdesc}{setstate}{state} \var{state} should have been obtained from a previous call to ! \code{getstate()}, and \code{setstate()} restores the internal state ! of the generator to what it was at the time \code{setstate()} was called. \versionadded{2.1} ! \end{funcdesc} \begin{funcdesc}{jumpahead}{n} ! Change the internal state to what it would be if \code{random()} were ! called n times, but do so quickly. \var{n} is a non-negative integer. ! This is most useful in multi-threaded programs, in conjuction with ! multiple instances of the \var{Random} class: \method{setstate()} or ! \method{seed()} can be used to force all instances into the same ! internal state, and then \method{jumpahead()} can be used to force the ! instances' states as far apart as you like (up to the period of the ! generator). \versionadded{2.1} \end{funcdesc} --- 128,146 ---- \begin{funcdesc}{setstate}{state} \var{state} should have been obtained from a previous call to ! \function{getstate()}, and \function{setstate()} restores the ! internal state of the generator to what it was at the time ! \function{setstate()} was called. \versionadded{2.1} ! \end{funcdesc} \begin{funcdesc}{jumpahead}{n} ! Change the internal state to what it would be if \function{random()} ! were called \var{n} times, but do so quickly. \var{n} is a ! non-negative integer. This is most useful in multi-threaded ! programs, in conjuction with multiple instances of the \var{Random} ! class: \method{setstate()} or \method{seed()} can be used to force ! all instances into the same internal state, and then ! \method{jumpahead()} can be used to force the instances' states as ! far apart as you like (up to the period of the generator). \versionadded{2.1} \end{funcdesc} From fdrake@users.sourceforge.net Fri Feb 2 02:43:20 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:43:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref4.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv25539/ref Modified Files: ref4.tex Log Message: Minor markup adjustments. Move some index entries next to what they are referring to for better "targetting". Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ref4.tex 2001/02/01 15:37:56 1.24 --- ref4.tex 2001/02/02 02:43:18 1.25 *************** *** 25,31 **** function \function{execfile()} is a code block. The string argument passed to the built-in function \function{eval()} and to the ! \keyword{exec} statement is a code block. And finally, the expression ! read and evaluated by the built-in function \function{input()} is a ! code block. A code block is executed in an execution frame. An \dfn{execution --- 25,31 ---- function \function{execfile()} is a code block. The string argument passed to the built-in function \function{eval()} and to the ! \keyword{exec}\stindex{exec} statement is a code block. And finally, ! the expression read and evaluated by the built-in function ! \function{input()} is a code block. A code block is executed in an execution frame. An \dfn{execution *************** *** 87,94 **** Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the ! absence of \keyword{global} statements, a name that is bound anywhere ! in the code block is local in the entire code block; all other names ! are considered global. The \keyword{global} statement forces global ! interpretation of selected names throughout the code block. The following constructs bind names: formal parameters to functions, --- 87,95 ---- Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the ! absence of \keyword{global}\stindex{global} statements, a name that is ! bound anywhere in the code block is local in the entire code block; ! all other names are considered global. The \keyword{global} statement ! forces global interpretation of selected names throughout the code ! block. The following constructs bind names: formal parameters to functions, *************** *** 98,104 **** header, or in the second position of an \keyword{except} clause header. The \keyword{import} statement of the form ``\samp{from ! \ldots import *}'' binds all names defined in the imported module, ! except those beginning with an underscore. This form may only be used ! at the module level. A target occurring in a \keyword{del} statement is also considered bound --- 99,105 ---- header, or in the second position of an \keyword{except} clause header. The \keyword{import} statement of the form ``\samp{from ! \ldots import *}''\stindex{from} binds all names defined in the ! imported module, except those beginning with an underscore. This form ! may only be used at the module level. A target occurring in a \keyword{del} statement is also considered bound *************** *** 111,123 **** namespace of the module \module{__builtin__}\refbimodindex{__builtin__}). The built-in namespace associated with the execution of a code block ! is actually found by looking up the name \code{__builtins__} is its global namespace; this should be a dictionary or a module (in the ! latter case its dictionary is used). Normally, the \code{__builtins__} namespace is the dictionary of the built-in module \module{__builtin__} (note: no `s'). If it isn't, restricted execution\indexii{restricted}{execution} mode is in effect. - \stindex{from} - \stindex{exec} - \stindex{global} The namespace for a module is automatically created the first time a --- 112,121 ---- namespace of the module \module{__builtin__}\refbimodindex{__builtin__}). The built-in namespace associated with the execution of a code block ! is actually found by looking up the name \code{__builtins__} in its global namespace; this should be a dictionary or a module (in the ! latter case the module's dictionary is used). Normally, the \code{__builtins__} namespace is the dictionary of the built-in module \module{__builtin__} (note: no `s'). If it isn't, restricted execution\indexii{restricted}{execution} mode is in effect. The namespace for a module is automatically created the first time a From fdrake@users.sourceforge.net Fri Feb 2 02:45:10 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:45:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.176,1.177 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25692/lib Modified Files: lib.tex Log Message: Move the whrandom entry to the "Obsolete Modules" appendix. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.176 retrieving revision 1.177 diff -C2 -r1.176 -r1.177 *** lib.tex 2001/02/01 05:21:46 1.176 --- lib.tex 2001/02/02 02:45:08 1.177 *************** *** 113,117 **** \input{libcmath} \input{librandom} - \input{libwhrandom} \input{libbisect} \input{libarray} --- 113,116 ---- *************** *** 308,311 **** --- 307,311 ---- %\input{libregsub} %\input{libsoundex} + %\input{libwhrandom} \chapter{Reporting Bugs} From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-netbsd1 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-netbsd1 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-netbsd1 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-freebsd3 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd3 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-freebsd3 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-aix3 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-aix3 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-aix3 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-linux2 SOCKET.py,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-linux2 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-linux2 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-irix6 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-freebsd4 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd4 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-freebsd4 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 SOCKET.py,1.3,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-irix5 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-linux1 SOCKET.py,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-linux1 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-linux1 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-freebsd2 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd2 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-freebsd2 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-sunos4 SOCKET.py,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-sunos4 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-sunos4 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-sunos5 SOCKET.py,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-sunos5 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-sunos5 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:24 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-beos5 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-beos5 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-beos5 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@users.sourceforge.net Fri Feb 2 02:51:23 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 18:51:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-freebsd5 SOCKET.py,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd5 In directory usw-pr-cvs1:/tmp/cvs-serv26309/plat-freebsd5 Removed Files: SOCKET.py Log Message: The socket constants have been moved to the socket module for a long time; the standard library does not use the SOCKET module any more, and it is not defined for all platforms (Windows, in particular). --- SOCKET.py DELETED --- From fdrake@acm.org Fri Feb 2 02:47:31 2001 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Thu, 1 Feb 2001 21:47:31 -0500 (EST) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_new.py,1.10,1.11 In-Reply-To: References: Message-ID: <14970.8131.736050.849861@cj42289-a.reston1.va.home.com> Jeremy Hylton writes: > Modified Files: > test_new.py > Log Message: > move extra arguments to the back of the new.code() arglist Are you planning to update the documentation for the new module? -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From jhylton@users.sourceforge.net Fri Feb 2 02:58:50 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 18:58:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.156,2.157 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv27216/Python Modified Files: compile.c Log Message: add missing DECREF (thanks, Barry) Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.156 retrieving revision 2.157 diff -C2 -r2.156 -r2.157 *** compile.c 2001/02/01 22:48:12 2.156 --- compile.c 2001/02/02 02:58:48 2.157 *************** *** 4478,4481 **** --- 4478,4482 ---- return -1; } + Py_DECREF(d); if (st->st_cur_type == TYPE_FUNCTION) { if ((l = PyList_New(0)) == NULL) From fdrake@users.sourceforge.net Fri Feb 2 03:03:35 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 19:03:35 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv28192 Modified Files: Makefile.pre.in Log Message: Added fork1, linuxaudiodev, sunaudiodev, and zlib to the tests skipped by the quicktest target. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** Makefile.pre.in 2001/02/01 19:51:28 1.9 --- Makefile.pre.in 2001/02/02 03:03:33 1.10 *************** *** 474,478 **** QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ ! test_unicodedata test_re test_sre test_select test_poll quicktest: all platform -rm -f $(srcdir)/Lib/test/*.py[co] --- 474,479 ---- QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ ! test_unicodedata test_re test_sre test_select test_poll \ ! test_fork1 test_linuxaudiodev test_sunaudiodev test_zlib quicktest: all platform -rm -f $(srcdir)/Lib/test/*.py[co] From jhylton@users.sourceforge.net Fri Feb 2 03:23:11 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 19:23:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.133,1.134 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30093/Modules Modified Files: socketmodule.c Log Message: SF patch 101137 from Grant Edwards Adds support for raw packets (AF_PACKET) under Linux. I haven't tested this code thoroughly; it compiles and the basic calls all work without crashing. Not sure what to actually do with raw sockets though. Not sure what other platforms this might be useful for. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -r1.133 -r1.134 *** socketmodule.c 2001/02/01 23:35:20 1.133 --- socketmodule.c 2001/02/02 03:23:09 1.134 *************** *** 8,12 **** Limitations: ! - only AF_INET and AF_UNIX address families are supported - no read/write operations (use send/recv or makefile instead) - additional restrictions apply on Windows --- 8,13 ---- Limitations: ! - only AF_INET and AF_UNIX address families are supported in a ! portable manner, though AF_PACKET is supported under Linux. - no read/write operations (use send/recv or makefile instead) - additional restrictions apply on Windows *************** *** 34,37 **** --- 35,45 ---- - where a hostname is returned, the dd.dd.dd.dd notation is used - a UNIX domain socket address is a string specifying the pathname + - an AF_PACKET socket address is a tuple containing a string + specifying the ethernet interface and an integer specifying + the Ethernet protocol number to be received. For example: + ("eth0",0x1234). Optional 3rd and 4th elements in the tuple + specify packet-type and ha-type -- these are ignored by + networking code, but accepted since they are returned by the + getsockname() method. Socket methods: *************** *** 147,150 **** --- 155,164 ---- #endif + #if defined(linux) && defined(AF_PACKET) + #include + #include + #include + #endif + #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK /* For QNX only? */ *************** *** 348,351 **** --- 362,368 ---- struct sockaddr_un un; #endif + #if defined(linux) && defined(AF_PACKET) + struct sockaddr_ll ll; + #endif } sock_addr; } PySocketSockObject; *************** *** 551,556 **** return PyString_FromString(a->sun_path); } ! #endif /* AF_UNIX */ /* More cases here... */ --- 568,596 ---- return PyString_FromString(a->sun_path); } ! #endif + #if defined(linux) && defined(AF_PACKET) + case AF_PACKET: + { + struct sockaddr_ll *a = (struct sockaddr_ll *)addr; + char *ifname = ""; + struct ifreq ifr; + int s; + /* need a socket on which we can do an ioctl to look + * up interface name from index, but only if index is + * non-zero. + */ + if (a->sll_ifindex + && ((s = socket(AF_PACKET, SOCK_RAW, 0)) >= 0)) { + ifr.ifr_ifindex = a->sll_ifindex; + if (ioctl(s, SIOCGIFNAME, &ifr) == 0) + ifname = ifr.ifr_name; + close(s); + } + return Py_BuildValue("shbh", ifname, ntohs(a->sll_protocol), + a->sll_pkttype, a->sll_hatype); + } + #endif + /* More cases here... */ *************** *** 623,626 **** --- 663,696 ---- } + #if defined(linux) && defined(AF_PACKET) + case AF_PACKET: + { + struct sockaddr_ll* addr; + struct ifreq ifr; + char *interfaceName; + int protoNumber; + int hatype = 0; + int pkttype = 0; + + if (!PyArg_ParseTuple(args, "si|ii", &interfaceName, + &protoNumber, &pkttype, &hatype)) + return 0; + strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); + ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0'; + if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr)) + return 0; + addr = &(s->sock_addr.ll); + addr->sll_family = AF_PACKET; + addr->sll_protocol = htons((short)protoNumber); + addr->sll_ifindex = ifr.ifr_ifindex; + addr->sll_pkttype = pkttype; + addr->sll_hatype = hatype; + *addr_ret = (struct sockaddr *) addr; + *len_ret = sizeof *addr; + return 1; + } + #endif + + /* More cases here... */ *************** *** 656,659 **** --- 726,737 ---- } + #if defined(linux) && defined(AF_PACKET) + case AF_PACKET: + { + *len_ret = sizeof (struct sockaddr_ll); + return 1; + } + #endif + /* More cases here... */ *************** *** 895,899 **** \n\ Bind the socket to a local address. For IP sockets, the address is a\n\ ! pair (host, port); the host must refer to the local host."; --- 973,978 ---- \n\ Bind the socket to a local address. For IP sockets, the address is a\n\ ! pair (host, port); the host must refer to the local host. For raw packet\n\ ! sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])"; *************** *** 2442,2445 **** --- 2521,2535 ---- insint(d, "AF_ROSE", AF_ROSE); /* Amateur Radio X.25 PLP */ #endif + #if defined(linux) && defined(AF_PACKET) + insint(d, "AF_PACKET", AF_PACKET); + insint(d, "PF_PACKET", PF_PACKET); + insint(d, "PACKET_HOST", PACKET_HOST); + insint(d, "PACKET_BROADCAST", PACKET_BROADCAST); + insint(d, "PACKET_MULTICAST", PACKET_MULTICAST); + insint(d, "PACKET_OTHERHOST", PACKET_OTHERHOST); + insint(d, "PACKET_OUTGOING", PACKET_OUTGOING); + insint(d, "PACKET_LOOPBACK", PACKET_LOOPBACK); + insint(d, "PACKET_FASTROUTE", PACKET_FASTROUTE); + #endif /* Socket types */ From jhylton@users.sourceforge.net Fri Feb 2 03:29:26 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 19:29:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.115,1.116 ACKS,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv30894 Modified Files: NEWS ACKS Log Message: add info about Grant Edwards' raw packet support Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -r1.115 -r1.116 *** NEWS 2001/02/01 22:53:15 1.115 --- NEWS 2001/02/02 03:29:24 1.116 *************** *** 92,95 **** --- 92,98 ---- arguments in [0, 27814431486576L). + - The socket module now supports raw packets on Linux. The socket + family is AF_PACKET. + Windows changes Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** ACKS 2001/01/28 05:07:00 1.76 --- ACKS 2001/02/02 03:29:24 1.77 *************** *** 99,102 **** --- 99,103 ---- Eugene Dvurechenski Hans Eckardt + Grant Edwards Lance Ellinghaus David Ely From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref7.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv23698/Doc/ref Modified Files: ref7.tex Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** ref7.tex 2001/01/02 19:22:48 1.22 --- ref7.tex 2001/02/01 22:48:12 1.23 *************** *** 261,275 **** \keyword{finally} clause is executed, and then the saved exception is re-raised. If the \keyword{finally} clause raises another exception or ! executes a \keyword{return}, \keyword{break} or \keyword{continue} statement, ! the saved exception is lost. The exception information is not ! available to the program during execution of the \keyword{finally} ! clause. \kwindex{finally} ! When a \keyword{return} or \keyword{break} statement is executed in the ! \keyword{try} suite of a \keyword{try}...\keyword{finally} statement, the ! \keyword{finally} clause is also executed `on the way out.' A ! \keyword{continue} statement is illegal in the \keyword{try} clause. (The ! reason is a problem with the current implementation --- this restriction may be lifted in the future). \stindex{return} --- 261,277 ---- \keyword{finally} clause is executed, and then the saved exception is re-raised. If the \keyword{finally} clause raises another exception or ! executes a \keyword{return} or \keyword{break} statement, the saved ! exception is lost. A \keyword{continue} statement is illegal in the ! \keyword{finally} clause. (The reason is a problem with the current ! implementation -- thsi restriction may be lifted in the future). The ! exception information is not available to the program during execution of ! the \keyword{finally} clause. \kwindex{finally} ! When a \keyword{return}, \keyword{break} or \keyword{continue} statement is ! executed in the \keyword{try} suite of a \keyword{try}...\keyword{finally} ! statement, the \keyword{finally} clause is also executed `on the way out.' A ! \keyword{continue} statement is illegal in the \keyword{finally} clause. ! (The reason is a problem with the current implementation --- this restriction may be lifted in the future). \stindex{return} From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib dis.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23698/Lib Modified Files: dis.py Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** dis.py 2001/01/25 20:08:47 1.31 --- dis.py 2001/02/01 22:48:12 1.32 *************** *** 260,263 **** --- 260,264 ---- name_op('LOAD_GLOBAL', 116) # Index in name list + jabs_op('CONTINUE_LOOP', 119) # Target address jrel_op('SETUP_LOOP', 120) # Distance to target address jrel_op('SETUP_EXCEPT', 121) # "" From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include opcode.h,2.33,2.34 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv23698/Include Modified Files: opcode.h Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: opcode.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/opcode.h,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** opcode.h 2001/01/25 20:06:58 2.33 --- opcode.h 2001/02/01 22:48:12 2.34 *************** *** 105,108 **** --- 105,109 ---- #define LOAD_GLOBAL 116 /* Index in name list */ + #define CONTINUE_LOOP 119 /* Start of loop (absolute) */ #define SETUP_LOOP 120 /* Target address (absolute) */ #define SETUP_EXCEPT 121 /* "" */ From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_exceptions.py,1.11,1.12 test_grammar.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23698/Lib/test Modified Files: test_exceptions.py test_grammar.py Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: test_exceptions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_exceptions.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_exceptions.py 2000/10/23 17:00:30 1.11 --- test_exceptions.py 2001/02/01 22:48:12 1.12 *************** *** 105,130 **** while 1: try: - continue - except: - pass - ''' - ckmsg(s, "'continue' not supported inside 'try' clause") - s = '''\ - while 1: - try: - continue - finally: pass - ''' - ckmsg(s, "'continue' not supported inside 'try' clause") - s = '''\ - while 1: - try: - if 1: - continue finally: ! pass ''' ! ckmsg(s, "'continue' not supported inside 'try' clause") s = '''\ try: --- 105,113 ---- while 1: try: pass finally: ! continue ''' ! ckmsg(s, "'continue' not supported inside 'finally' clause") s = '''\ try: Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** test_grammar.py 2001/02/01 20:20:45 1.28 --- test_grammar.py 2001/02/01 22:48:12 1.29 *************** *** 350,353 **** --- 350,372 ---- while i: i = 0; continue + msg = "" + while not msg: + msg = "continue + try/except ok" + try: + continue + msg = "continue failed to continue inside try" + except: + msg = "continue inside try called except block" + print msg + + msg = "" + while not msg: + msg = "finally block not called" + try: + continue + finally: + msg = "continue + try/finally ok" + print msg + print 'return_stmt' # 'return' [testlist] def g1(): return From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_exceptions,1.5,1.6 test_grammar,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv23698/Lib/test/output Modified Files: test_exceptions test_grammar Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: test_exceptions =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_exceptions,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_exceptions 2000/09/08 16:32:34 1.5 --- test_exceptions 2001/02/01 22:48:12 1.6 *************** *** 28,36 **** spam SyntaxError ! 'continue' not supported inside 'try' clause ! ok ! 'continue' not supported inside 'try' clause ! ok ! 'continue' not supported inside 'try' clause ok 'continue' not properly in loop --- 28,32 ---- spam SyntaxError ! 'continue' not supported inside 'finally' clause ok 'continue' not properly in loop Index: test_grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_grammar,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test_grammar 2001/02/01 20:20:45 1.12 --- test_grammar 2001/02/01 22:48:12 1.13 *************** *** 34,37 **** --- 34,39 ---- break_stmt continue_stmt + continue + try/except ok + continue + try/finally ok return_stmt raise_stmt From jhylton@users.sourceforge.net Thu Feb 1 22:48:14 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:48:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.226,2.227 compile.c,2.155,2.156 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv23698/Python Modified Files: ceval.c compile.c Log Message: Allow 'continue' inside 'try' clause SF patch 102989 by Thomas Wouters Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.226 retrieving revision 2.227 diff -C2 -r2.226 -r2.227 *** ceval.c 2001/02/01 20:20:45 2.226 --- ceval.c 2001/02/01 22:48:12 2.227 *************** *** 323,327 **** WHY_RERAISE, /* Exception re-raised by 'finally' */ WHY_RETURN, /* 'return' statement */ ! WHY_BREAK /* 'break' statement */ }; --- 323,328 ---- WHY_RERAISE, /* Exception re-raised by 'finally' */ WHY_RETURN, /* 'return' statement */ ! WHY_BREAK, /* 'break' statement */ ! WHY_CONTINUE, /* 'continue' statement */ }; *************** *** 1358,1361 **** --- 1359,1367 ---- why = WHY_BREAK; break; + + case CONTINUE_LOOP: + retval = PyInt_FromLong(oparg); + why = WHY_CONTINUE; + break; case RAISE_VARARGS: *************** *** 1420,1424 **** if (PyInt_Check(v)) { why = (enum why_code) PyInt_AsLong(v); ! if (why == WHY_RETURN) retval = POP(); } --- 1426,1431 ---- if (PyInt_Check(v)) { why = (enum why_code) PyInt_AsLong(v); ! if (why == WHY_RETURN || ! why == CONTINUE_LOOP) retval = POP(); } *************** *** 1835,1839 **** case SETUP_FINALLY: PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, ! STACK_LEVEL()); continue; --- 1842,1846 ---- case SETUP_FINALLY: PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, ! STACK_LEVEL()); continue; *************** *** 2111,2114 **** --- 2118,2133 ---- while (why != WHY_NOT && f->f_iblock > 0) { PyTryBlock *b = PyFrame_BlockPop(f); + + if (b->b_type == SETUP_LOOP && why == WHY_CONTINUE) { + /* For a continue inside a try block, + don't pop the block for the loop. */ + PyFrame_BlockSetup(f, b->b_type, b->b_level, + b->b_handler); + why = WHY_NOT; + JUMPTO(PyInt_AS_LONG(retval)); + Py_DECREF(retval); + break; + } + while (STACK_LEVEL() > b->b_level) { v = POP(); *************** *** 2146,2150 **** } else { ! if (why == WHY_RETURN) PUSH(retval); v = PyInt_FromLong((long)why); --- 2165,2170 ---- } else { ! if (why == WHY_RETURN || ! why == CONTINUE_LOOP) PUSH(retval); v = PyInt_FromLong((long)why); Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.155 retrieving revision 2.156 diff -C2 -r2.155 -r2.156 *** compile.c 2001/02/01 20:20:45 2.155 --- compile.c 2001/02/01 22:48:12 2.156 *************** *** 6,10 **** XXX (it's currently the first item of the co_const tuple) XXX Generate simple jump for break/return outside 'try...finally' ! XXX Allow 'continue' inside try-finally XXX New opcode for loading the initial index for a for loop XXX other JAR tricks? --- 6,10 ---- XXX (it's currently the first item of the co_const tuple) XXX Generate simple jump for break/return outside 'try...finally' ! XXX Allow 'continue' inside finally clause of try-finally XXX New opcode for loading the initial index for a for loop XXX other JAR tricks? *************** *** 3248,3264 **** else { int j; ! for (j = 0; j <= i; ++j) { if (c->c_block[j] == SETUP_LOOP) break; } ! if (j < i+1) { /* there is a loop, but something interferes */ ! for (++j; j <= i; ++j) { ! if (c->c_block[i] == SETUP_EXCEPT ! || c->c_block[i] == SETUP_FINALLY) { ! com_error(c, PyExc_SyntaxError, ! "'continue' not supported inside 'try' clause"); return; } } } --- 3248,3269 ---- else { int j; ! for (j = i-1; j >= 0; --j) { if (c->c_block[j] == SETUP_LOOP) break; } ! if (j >= 0) { /* there is a loop, but something interferes */ ! for (; i > j; --i) { ! if (c->c_block[i] == SETUP_EXCEPT || ! c->c_block[i] == SETUP_FINALLY) { ! com_addoparg(c, CONTINUE_LOOP, ! c->c_begin); return; } + if (c->c_block[i] == END_FINALLY) { + com_error(c, PyExc_SyntaxError, + "'continue' not supported inside 'finally' clause"); + return; + } } } From jhylton@users.sourceforge.net Thu Feb 1 22:53:18 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 14:53:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.114,1.115 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv24461/Misc Modified Files: NEWS Log Message: continue now allowed in try block Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -r1.114 -r1.115 *** NEWS 2001/02/01 20:38:45 1.114 --- NEWS 2001/02/01 22:53:15 1.115 *************** *** 59,62 **** --- 59,66 ---- mappings with weakly held values. + - A 'continue' statement can now appear in a try block within the body + of a loop. It is still not possible to use continue in a finally + clause. + Standard library From jhylton@users.sourceforge.net Thu Feb 1 23:53:07 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 15:53:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.78,2.79 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv1897 Modified Files: floatobject.c Log Message: SF patch 103543 from tg@freebsd.org: PyFPE_END_PROTECT() was called on undefined var Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.78 retrieving revision 2.79 diff -C2 -r2.78 -r2.79 *** floatobject.c 2001/01/17 15:33:42 2.78 --- floatobject.c 2001/02/01 23:53:05 2.79 *************** *** 279,283 **** PyFPE_START_PROTECT("convert_to_double", {*v=NULL;return -1;}) *dbl = PyLong_AsDouble(obj); ! PyFPE_END_PROTECT(result) } else { --- 279,283 ---- PyFPE_START_PROTECT("convert_to_double", {*v=NULL;return -1;}) *dbl = PyLong_AsDouble(obj); ! PyFPE_END_PROTECT(*dbl) } else { From jhylton@users.sourceforge.net Thu Feb 1 23:35:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 01 Feb 2001 15:35:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.132,1.133 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv31051/Modules Modified Files: socketmodule.c Log Message: An ssl-wrapped socket now returns '' on EOF, just like a regular socket -- as suggested by Clarence Gardner. Fix httplib to comply with the new ssl-socket interface. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -r1.132 -r1.133 *** socketmodule.c 2001/01/22 15:29:14 1.132 --- socketmodule.c 2001/02/01 23:35:20 1.133 *************** *** 2166,2180 **** switch (res) { ! case 0: /* Good return value! */ break; ! case 6: ! PyErr_SetString(SSLErrorObject, "EOF"); ! Py_DECREF(buf); ! return NULL; break; - case 5: default: return PyErr_SetFromErrno(SSLErrorObject); - break; } --- 2166,2177 ---- switch (res) { ! case SSL_ERROR_NONE: ! assert(count > 0); break; ! case SSL_ERROR_ZERO_RETURN: /* normal EOF */ ! assert(count == 0); break; default: return PyErr_SetFromErrno(SSLErrorObject); } From tim_one@users.sourceforge.net Fri Feb 2 00:07:09 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 16:07:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _weakref.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4421/python/dist/src/Modules Modified Files: _weakref.c Log Message: Teach Windows build about the _weakref module. Index: _weakref.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** _weakref.c 2001/02/01 05:25:27 1.1 --- _weakref.c 2001/02/02 00:07:07 1.2 *************** *** 729,733 **** ! void init_weakref(void) { --- 729,733 ---- ! DL_EXPORT(void) init_weakref(void) { From tim_one@users.sourceforge.net Fri Feb 2 00:07:09 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 16:07:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC config.c,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv4421/python/dist/src/PC Modified Files: config.c Log Message: Teach Windows build about the _weakref module. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** config.c 2001/01/09 23:26:39 1.30 --- config.c 2001/02/02 00:07:07 1.31 *************** *** 44,47 **** --- 44,48 ---- extern void init_codecs(void); extern void initxreadlines(void); + extern void init_weakref(void); /* XXX tim: what's the purpose of ADDMODULE MARKER? */ *************** *** 96,99 **** --- 97,101 ---- {"_codecs", init_codecs}, {"xreadlines", initxreadlines}, + {"_weakref", init_weakref}, /* XXX tim: what's the purpose of ADDMODULE MARKER? */ From tim_one@users.sourceforge.net Fri Feb 2 00:07:10 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 16:07:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild pythoncore.dsp,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv4421/python/dist/src/PCbuild Modified Files: pythoncore.dsp Log Message: Teach Windows build about the _weakref module. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pythoncore.dsp 2001/02/01 05:10:02 1.3 --- pythoncore.dsp 2001/02/02 00:07:07 1.4 *************** *** 196,199 **** --- 196,214 ---- # Begin Source File + SOURCE=..\Modules\_weakref.c + + !IF "$(CFG)" == "pythoncore - Win32 Release" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File + SOURCE=..\Objects\abstract.c From fdrake@users.sourceforge.net Fri Feb 2 03:51:07 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 01 Feb 2001 19:51:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libmailbox.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv804/lib Modified Files: libmailbox.tex Log Message: Adjustments to the text of the UnixMailbox description. Added PortableUnixMailbox as a separate class as well (this also generates the right index entry). Index: libmailbox.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmailbox.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** libmailbox.tex 2001/01/31 22:13:43 1.16 --- libmailbox.tex 2001/02/02 03:51:05 1.17 *************** *** 10,40 **** \begin{classdesc}{UnixMailbox}{fp\optional{, factory}} ! Access to a classic \UNIX{}-style mailbox, where all messages are ! contained in a single file and separate by ``From '' (a.k.a ``From_'') ! lines. The file object \var{fp} points to the mailbox file. Optional ! \var{factory} is a callable that should create new message objects. ! It is called with one argument, \var{fp} by the \method{next()} ! method. The default is the \class{rfc822.Message} class (see the \refmodule{rfc822} module). ! For maximum portability, messages in a \UNIX{}-style mailbox are ! separated by any line that begins exactly with the letters \emph{F}, ! \emph{r}, \emph{o}, \emph{m}, \emph{[space]} if preceded by exactly two ! newlines. Because of the wide-range of variations in practice, ! nothing else on the From_ line should be considered. However, the ! current implementation doesn't check for the leading two newlines. ! This is usually fine for most applications. The \class{UnixMailbox} class implements a more strict version of From_ line checking, using a regular expression that usually correctly matched From_ delimiters. It considers delimiter line to be separated ! by ``From name time'' lines. For maximum portability, use the ! \class{PortableUnixMailbox} class instead. This ! class is completely identical to \class{UnixMailbox} except that ! individual messages are separated by only ``From '' lines. ! For more ! information see ! \url{http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html}. \end{classdesc} --- 10,50 ---- \begin{classdesc}{UnixMailbox}{fp\optional{, factory}} ! Access to a classic \UNIX-style mailbox, where all messages are ! contained in a single file and separated by \samp{From } ! (a.k.a.\ \samp{From_}) lines. The file object \var{fp} points to the ! mailbox file. The optional \var{factory} parameter is a callable that ! should create new message objects. \var{factory} is called with one ! argument, \var{fp} by the \method{next()} method of the mailbox ! object. The default is the \class{rfc822.Message} class (see the \refmodule{rfc822} module). ! For maximum portability, messages in a \UNIX-style mailbox are ! separated by any line that begins exactly with the string \code{'From ! '} (note the trailing space) if preceded by exactly two newlines. ! Because of the wide-range of variations in practice, nothing else on ! the From_ line should be considered. However, the current ! implementation doesn't check for the leading two newlines. This is ! usually fine for most applications. The \class{UnixMailbox} class implements a more strict version of From_ line checking, using a regular expression that usually correctly matched From_ delimiters. It considers delimiter line to be separated ! by \samp{From \var{name} \var{time}} lines. For maximum portability, ! use the \class{PortableUnixMailbox} class instead. This class is ! identical to \class{UnixMailbox} except that individual messages are ! separated by only \samp{From } lines. ! For more information, see ! \citetitle[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]{Configuring ! Netscape Mail on \UNIX: Why the Content-Length Format is Bad}. ! \end{classdesc} ! ! \begin{classdesc}{PortableUnixMailbox}{fp\optional{, factory}} ! A less-strict version of \class{UnixMailbox}, which considers only the ! \samp{From } at the beginning of the line separating messages. The ! ``\var{name} \var{time}'' portion of the From line is ignored, to ! protect against some variations that are observed in practice. This ! works since lines in the message which begin with \code{'From '} are ! quoted by mail handling software well before delivery. \end{classdesc} From tim_one@users.sourceforge.net Fri Feb 2 05:57:16 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 21:57:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_capi.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12891/python/dist/src/Lib/test Added Files: test_capi.py Log Message: Patch derived from Trent's 101162: a Python/C API testing framework. STILL NEEDS UNIX BUILD CHANGES. --- NEW FILE: test_capi.py --- # Run the _test module tests (tests for the Python/C API): by defn, these # are all functions _test exports whose name begins with 'test_'. import sys import test_support import _test for name in dir(_test): if name.startswith('test_'): test = getattr(_test, name) if test_support.verbose: print "internal", name try: test() except _test.error: raise test_support.TestFailed, sys.exc_info()[1] From tim_one@users.sourceforge.net Fri Feb 2 05:57:17 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 21:57:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.116,1.117 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv12891/python/dist/src/Misc Modified Files: NEWS Log Message: Patch derived from Trent's 101162: a Python/C API testing framework. STILL NEEDS UNIX BUILD CHANGES. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -r1.116 -r1.117 *** NEWS 2001/02/02 03:29:24 1.116 --- NEWS 2001/02/02 05:57:14 1.117 *************** *** 61,65 **** - A 'continue' statement can now appear in a try block within the body of a loop. It is still not possible to use continue in a finally ! clause. Standard library --- 61,65 ---- - A 'continue' statement can now appear in a try block within the body of a loop. It is still not possible to use continue in a finally ! clause. Standard library *************** *** 95,104 **** family is AF_PACKET. Windows changes - Build procedure: the zlib project is built in a different way that ensures the zlib header files used can no longer get out of synch with ! the zlib binary used. See PCbuild\readme.txt for details. What's New in Python 2.1 alpha 1? --- 95,113 ---- family is AF_PACKET. + - test_capi.py is a start at running tests of the Python C API. The tests + are implemented by the new Modules/_testmodule.c. + Windows changes - Build procedure: the zlib project is built in a different way that ensures the zlib header files used can no longer get out of synch with ! the zlib binary used. See PCbuild\readme.txt for details. Your old ! zlib-related directories can be deleted; you'll need to download fresh ! source for zlib and unpack it into a new directory. ! ! - Build: New subproject _test for the benefit of test_capi.py (see above). + - Build: subproject ucnhash is gone, since the code was folded into the + unicodedata subproject. What's New in Python 2.1 alpha 1? From tim_one@users.sourceforge.net Fri Feb 2 05:57:16 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 21:57:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_capi,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv12891/python/dist/src/Lib/test/output Added Files: test_capi Log Message: Patch derived from Trent's 101162: a Python/C API testing framework. STILL NEEDS UNIX BUILD CHANGES. --- NEW FILE: test_capi --- test_capi From tim_one@users.sourceforge.net Fri Feb 2 05:57:17 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 21:57:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _testmodule.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12891/python/dist/src/Modules Added Files: _testmodule.c Log Message: Patch derived from Trent's 101162: a Python/C API testing framework. STILL NEEDS UNIX BUILD CHANGES. --- NEW FILE: _testmodule.c --- /* * C Extension module to test Python interpreter C APIs. * * The 'test_*' functions exported by this module are run as part of the * standard Python regression test, via Lib/test/test_capi.py. */ #include "Python.h" static PyObject *TestError; /* set to exception object in init */ /* Test #defines from config.h (particularly the SIZEOF_* defines). The ones derived from autoconf on the UNIX-like OSes can be relied upon (in the absence of sloppy cross-compiling), but the Windows platforms have these hardcoded. Better safe than sorry. */ static PyObject* sizeof_error(const char* fatname, const char* typename, int expected, int got) { char buf[1024]; sprintf(buf, "%s #define == %d but sizeof(%s) == %d", fatname, expected, typename, got); PyErr_SetString(TestError, buf); return (PyObject*)NULL; } static PyObject* test_config(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":test_config")) return NULL; #define CHECK_SIZEOF(FATNAME, TYPE) \ if (FATNAME != sizeof(TYPE)) \ return sizeof_error(#FATNAME, #TYPE, FATNAME, sizeof(TYPE)) CHECK_SIZEOF(SIZEOF_INT, int); CHECK_SIZEOF(SIZEOF_LONG, long); CHECK_SIZEOF(SIZEOF_VOID_P, void*); CHECK_SIZEOF(SIZEOF_TIME_T, time_t); #ifdef HAVE_LONG_LONG CHECK_SIZEOF(SIZEOF_LONG_LONG, LONG_LONG); #endif #undef CHECK_SIZEOF Py_INCREF(Py_None); return Py_None; } static PyMethodDef TestMethods[] = { {"test_config", test_config, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; DL_EXPORT(void) init_test(void) { PyObject *m, *d; m = Py_InitModule("_test", TestMethods); TestError = PyErr_NewException("_test.error", NULL, NULL); d = PyModule_GetDict(m); PyDict_SetItemString(d, "error", TestError); } From tim_one@users.sourceforge.net Fri Feb 2 05:57:17 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 21:57:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild _test.dsp,NONE,1.1 pcbuild.dsw,1.23,1.24 readme.txt,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv12891/python/dist/src/PCbuild Modified Files: pcbuild.dsw readme.txt Added Files: _test.dsp Log Message: Patch derived from Trent's 101162: a Python/C API testing framework. STILL NEEDS UNIX BUILD CHANGES. --- NEW FILE: _test.dsp --- # Microsoft Developer Studio Project File - Name="_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "_test.mak" CFG="_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "_test - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "_test - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "_test" # PROP Scc_LocalPath ".." CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-release\_test" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_test.pyd" /export:init_test # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-debug\_test" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_test_d.pyd" /pdbtype:sept /export:init_test # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "_test - Win32 Release" # Name "_test - Win32 Debug" # Begin Source File SOURCE=..\Modules\_testmodule.c # End Source File # End Target # End Project Index: pcbuild.dsw =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.dsw,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** pcbuild.dsw 2001/01/24 10:07:20 1.23 --- pcbuild.dsw 2001/02/02 05:57:15 1.24 *************** *** 34,37 **** --- 34,49 ---- ############################################################################### + Project: "_test"=.\_test.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Project: "_tkinter"=.\_tkinter.dsp - Package Owner=<4> Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** readme.txt 2001/02/01 05:10:02 1.17 --- readme.txt 2001/02/02 05:57:15 1.18 *************** *** 56,59 **** --- 56,62 ---- winsound play sounds (typically .wav files) under Windows + _test + tests of the Python C API, run via Lib/test/test_capi.py, and + implemented by module Modules/_testmodule.c The following subprojects will generally NOT build out of the box. They From tim_one@users.sourceforge.net Fri Feb 2 06:33:06 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 01 Feb 2001 22:33:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv17911/python/dist/src/PCbuild Modified Files: python20.wse Log Message: Teach the Windows installer about the _test module. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** python20.wse 2001/02/01 05:10:02 1.24 --- python20.wse 2001/02/02 06:33:04 1.25 *************** *** 693,696 **** --- 693,701 ---- end item: Install File + Source=%_SRC_%\PCbuild\_test.pyd + Destination=%MAINDIR%\DLLs\_test.pyd + Flags=0000000000000010 + end + item: Install File Source=%_SRC_%\PCbuild\_tkinter.pyd Destination=%MAINDIR%\DLLs\_tkinter.pyd *************** *** 754,757 **** --- 759,767 ---- Source=%_SRC_%\PCbuild\_sre.lib Destination=%MAINDIR%\libs\_sre.lib + Flags=0000000000000010 + end + item: Install File + Source=%_SRC_%\PCbuild\_test.lib + Destination=%MAINDIR%\libs\_test.lib Flags=0000000000000010 end From lemburg@users.sourceforge.net Fri Feb 2 12:07:25 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 02 Feb 2001 04:07:25 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv10245 Modified Files: setup.py Log Message: Added new Python C API _test module to the build mechanism on Unix. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** setup.py 2001/02/01 05:26:54 1.20 --- setup.py 2001/02/02 12:07:22 1.21 *************** *** 175,178 **** --- 175,180 ---- # access to the builtin codecs and codec registry exts.append( Extension('_codecs', ['_codecsmodule.c']) ) + # Python C API test module + exts.append( Extension('_test', ['_testmodule.c']) ) # static Unicode character database exts.append( Extension('unicodedata', ['unicodedata.c']) ) From lemburg@users.sourceforge.net Fri Feb 2 12:07:25 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 02 Feb 2001 04:07:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10245/Modules Modified Files: Setup.dist Log Message: Added new Python C API _test module to the build mechanism on Unix. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** Setup.dist 2001/02/01 05:26:54 1.14 --- Setup.dist 2001/02/02 12:07:22 1.15 *************** *** 150,153 **** --- 150,154 ---- #_weakref _weakref.c # basic weak reference support #_codecs _codecsmodule.c # access to the builtin codecs and codec registry + #_test _testmodule.c # Python C API test module #unicodedata unicodedata.c unicodedatabase.c From lemburg@users.sourceforge.net Fri Feb 2 12:12:46 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 02 Feb 2001 04:12:46 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv11420 Modified Files: setup.py Log Message: Whitespace correction... Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** setup.py 2001/02/02 12:07:22 1.21 --- setup.py 2001/02/02 12:12:44 1.22 *************** *** 175,179 **** # access to the builtin codecs and codec registry exts.append( Extension('_codecs', ['_codecsmodule.c']) ) ! # Python C API test module exts.append( Extension('_test', ['_testmodule.c']) ) # static Unicode character database --- 175,179 ---- # access to the builtin codecs and codec registry exts.append( Extension('_codecs', ['_codecsmodule.c']) ) ! # Python C API test module exts.append( Extension('_test', ['_testmodule.c']) ) # static Unicode character database From fdrake@users.sourceforge.net Fri Feb 2 15:13:26 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 07:13:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib weakref.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14676 Modified Files: weakref.py Log Message: WeakDictionary.items(): Do not allow (key,ref) pairs to leak out for dead references. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** weakref.py 2001/02/01 05:25:27 1.1 --- weakref.py 2001/02/02 15:13:24 1.2 *************** *** 68,77 **** def items(self): ! L = self.data.items() ! for i in range(len(L)): key, ref = L[i] o = ref() if o is not None: ! L[i] = key, o return L --- 68,77 ---- def items(self): ! L = [] ! for key, ref in self.data.items(): key, ref = L[i] o = ref() if o is not None: ! L.append((key, o)) return L From fdrake@users.sourceforge.net Fri Feb 2 15:48:03 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 07:48:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools mksourcepkg,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv22756/tools Modified Files: mksourcepkg Log Message: Do not pass names of individual files to shutil.rmtree(); use os.unlink() for that. Index: mksourcepkg =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mksourcepkg,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mksourcepkg 2001/01/22 21:34:20 1.4 --- mksourcepkg 2001/02/02 15:48:00 1.5 *************** *** 100,106 **** run("cvs -Q -d%s checkout -d Doc python/dist/src/Doc" % cvsroot) # remove CVS directories ! for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS', ! '.cvsignore', '*/.cvsignore'): map(shutil.rmtree, glob.glob(p)) LICENSE = os.path.normpath( os.path.join(mydir, os.pardir, os.pardir, "LICENSE")) --- 100,107 ---- run("cvs -Q -d%s checkout -d Doc python/dist/src/Doc" % cvsroot) # remove CVS directories ! for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'): map(shutil.rmtree, glob.glob(p)) + for f in ('.cvsignore', '*/.cvsignore'): + map(os.unlink, glob.glob(f)) LICENSE = os.path.normpath( os.path.join(mydir, os.pardir, os.pardir, "LICENSE")) From jhylton@users.sourceforge.net Fri Feb 2 18:12:18 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:12:18 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv25977 Modified Files: Makefile.pre.in Log Message: Undo recent exclusion of test_fork1 and test_zlib. These tests don't trigger my arbitrary exlusion rule, which is: takes more than 10 seconds of wall clock time on my machine. If these tests are going to be skipped, then a boatload of slower tests should be skipped, too. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** Makefile.pre.in 2001/02/02 03:03:33 1.10 --- Makefile.pre.in 2001/02/02 18:12:16 1.11 *************** *** 475,479 **** QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ test_unicodedata test_re test_sre test_select test_poll \ ! test_fork1 test_linuxaudiodev test_sunaudiodev test_zlib quicktest: all platform -rm -f $(srcdir)/Lib/test/*.py[co] --- 475,479 ---- QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \ test_unicodedata test_re test_sre test_select test_poll \ ! test_linuxaudiodev test_sunaudiodev quicktest: all platform -rm -f $(srcdir)/Lib/test/*.py[co] From fdrake@users.sourceforge.net Fri Feb 2 18:17:32 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 10:17:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.75,2.76 objimpl.h,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv27056 Modified Files: object.h objimpl.h Log Message: Use a type flag to determine the applicability of the tp_weaklistoffset field. This should avoid binary incompatibility problems with older modules that have not been recompiled. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -r2.75 -r2.76 *** object.h 2001/02/01 20:20:45 2.75 --- object.h 2001/02/02 18:17:30 2.76 *************** *** 345,348 **** --- 345,354 ---- #define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5) + /* Objects which are weakly referencable if their tp_weaklistoffset is >0 */ + /* XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE? + * These both indicate a feature that appeared in the same alpha release. + */ + #define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6) + #define Py_TPFLAGS_DEFAULT ( \ Py_TPFLAGS_HAVE_GETCHARBUFFER | \ *************** *** 350,353 **** --- 356,360 ---- Py_TPFLAGS_HAVE_INPLACEOPS | \ Py_TPFLAGS_HAVE_RICHCOMPARE | \ + Py_TPFLAGS_HAVE_WEAKREFS | \ 0) Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** objimpl.h 2001/02/01 05:25:27 2.31 --- objimpl.h 2001/02/02 18:17:30 2.32 *************** *** 272,276 **** /* Test if a type supports weak references */ ! #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) #define PyObject_GET_WEAKREFS_LISTPTR(o) \ --- 272,278 ---- /* Test if a type supports weak references */ ! #define PyType_SUPPORTS_WEAKREFS(t) \ ! (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \ ! && ((t)->tp_weaklistoffset > 0)) #define PyObject_GET_WEAKREFS_LISTPTR(o) \ From jhylton@users.sourceforge.net Fri Feb 2 18:19:17 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:19:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include symtable.h,NONE,2.1 pythonrun.h,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv27353/Include Modified Files: pythonrun.h Added Files: symtable.h Log Message: Move a bunch of definitions that were internal to compile.c to symtable.h, so that they can be used by external module. Improve error handling in symtable_enter_scope(), which return an error code that went unchecked by most callers. XXX The error handling in symtable code is sloppy in general. Modify symtable to record the line number that begins each scope. This can help to identify which code block is being referred to when multiple blocks are bound to the same name. Add st_scopes dict that is used to preserve scope info when PyNode_CompileSymtable() is called. Otherwise, this information is tossed as soon as it is no longer needed. Add Py_SymtableString() to pythonrun; analogous to Py_CompileString(). --- NEW FILE: symtable.h --- #ifndef Py_SYMTABLE_H #define Py_SYMTABLE_H #ifdef __cplusplus extern "C" { #endif /* A symbol table is constructed each time PyNode_Compile() is called. The table walks the entire parse tree and identifies each use or definition of a variable. The symbol table contains a dictionary for each code block in a module: The symbol dictionary for the block. They keys of these dictionaries are the name of all variables used or defined in the block; the integer values are used to store several flags, e.g. DEF_PARAM indicates that a variable is a parameter to a function. The slots st_cur_XXX pointers always refer to the current code block. The st_cur slot is the symbol dictionary. The st_cur_id slot is the id is the key in st_symbols. The st_cur_name slot is the name of the current scope. The st_cur_type slot is one of TYPE_FUNCTION, TYPE_CLASS, or TYPE_MODULE. The st_cur_children is a list of the ids of the current node's children. The st_symbols slot is a dictionary that maps code block ids to symbol dictionaries. The keys are generated by a counter that is incremented each time a new code block is found. The counter is identifies a specific scope, because both passes walk the parse tree in the same order. The st_varnames slot is a dictionary that maps code block ids to parameter lists. The st_global slot always refers to the symbol dictionary for the module. The st_children slot is a dictionary that maps ids to a list containing the ids of its children. If st_keep is true then the namespace info pushed on st_stack will also be stored in st_scopes. This is useful if the symbol table is being passed to something other than the compiler. */ struct symtable { int st_pass; /* pass == 1 or 2 */ int st_keep; /* true if symtable will be returned */ PyObject *st_symbols; /* dictionary of symbol tables */ PyObject *st_varnames; /* dictionary of parameter lists */ PyObject *st_stack; /* stack of namespace info */ PyObject *st_scopes; /* dictionary of namespace info */ PyObject *st_children; /* dictionary (id=[ids]) */ PyObject *st_cur; /* borrowed ref to dict in st_symbols */ PyObject *st_cur_name; /* string, name of current scope */ PyObject *st_cur_id; /* int id of current code block */ PyObject *st_cur_children; /* ref to current children list */ int st_cur_type; /* type of current scope */ int st_cur_lineno; /* line number where current scope begins */ PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ int st_nscopes; /* number of scopes */ int st_errors; /* number of errors */ char *st_private; /* name of current class or NULL */ int st_tmpname; /* temporary name counter */ int st_nested; /* bool (true if nested scope) */ }; DL_IMPORT(struct symtable *) PyNode_CompileSymtable(struct _node *, char *); DL_IMPORT(void) PySymtable_Free(struct symtable *); #define TOP "global" #define NOOPT ".noopt" /* Flags for def-use information */ #define DEF_GLOBAL 1 /* global stmt */ #define DEF_LOCAL 2 /* assignment in code block */ #define DEF_PARAM 2<<1 /* formal parameter */ #define USE 2<<2 /* name is used */ #define DEF_STAR 2<<3 /* parameter is star arg */ #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */ #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */ #define DEF_FREE 2<<6 /* name used by not defined in nested scope */ #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */ #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */ #define DEF_IMPORT 2<<9 /* assignment occurred via import */ #define TYPE_FUNCTION 1 #define TYPE_CLASS 2 #define TYPE_MODULE 3 #define LOCAL 1 #define GLOBAL_EXPLICIT 2 #define GLOBAL_IMPLICIT 3 #define FREE 4 #define CELL 5 #ifdef __cplusplus } #endif #endif /* !Py_SYMTABLE_H */ Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -r2.37 -r2.38 *** pythonrun.h 2000/10/11 17:18:11 2.37 --- pythonrun.h 2001/02/02 18:19:15 2.38 *************** *** 38,41 **** --- 38,42 ---- DL_IMPORT(PyObject *) Py_CompileString(char *, char *, int); + DL_IMPORT(struct symtable *) Py_SymtableString(char *, char *, int); DL_IMPORT(void) PyErr_Print(void); From jhylton@users.sourceforge.net Fri Feb 2 18:19:17 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:19:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.157,2.158 pythonrun.c,2.120,2.121 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv27353/Python Modified Files: compile.c pythonrun.c Log Message: Move a bunch of definitions that were internal to compile.c to symtable.h, so that they can be used by external module. Improve error handling in symtable_enter_scope(), which return an error code that went unchecked by most callers. XXX The error handling in symtable code is sloppy in general. Modify symtable to record the line number that begins each scope. This can help to identify which code block is being referred to when multiple blocks are bound to the same name. Add st_scopes dict that is used to preserve scope info when PyNode_CompileSymtable() is called. Otherwise, this information is tossed as soon as it is no longer needed. Add Py_SymtableString() to pythonrun; analogous to Py_CompileString(). Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.157 retrieving revision 2.158 diff -C2 -r2.157 -r2.158 *** compile.c 2001/02/02 02:58:48 2.157 --- compile.c 2001/02/02 18:19:15 2.158 *************** *** 17,20 **** --- 17,21 ---- #include "graminit.h" #include "compile.h" + #include "symtable.h" #include "opcode.h" #include "structmember.h" *************** *** 46,59 **** #define VAR_DELETE 2 - #define TYPE_FUNCTION 1 - #define TYPE_CLASS 2 - #define TYPE_MODULE 3 - - #define LOCAL 1 - #define GLOBAL_EXPLICIT 2 - #define GLOBAL_IMPLICIT 3 - #define FREE 4 - #define CELL 5 - #define DEL_CLOSURE_ERROR \ "can not delete variable '%.400s' referenced in nested scope" --- 47,50 ---- *************** *** 368,439 **** }; - /* A symbol table is constructed each time PyNode_Compile() is - called. The table walks the entire parse tree and identifies each - use or definition of a variable. - - The symbol table contains a dictionary for each code block in a - module: The symbol dictionary for the block. They keys of these - dictionaries are the name of all variables used or defined in the - block; the integer values are used to store several flags, - e.g. DEF_PARAM indicates that a variable is a parameter to a - function. - - The slots st_cur_XXX pointers always refer to the current code - block. The st_cur slot is the symbol dictionary. The st_cur_id - slot is the id is the key in st_symbols. The st_cur_name slot is - the name of the current scope. The st_cur_type slot is one of - TYPE_FUNCTION, TYPE_CLASS, or TYPE_MODULE. The st_cur_children is - a list of the ids of the current node's children. - - The st_symbols slot is a dictionary that maps code block ids to - symbol dictionaries. The keys are generated by a counter that is - incremented each time a new code block is found. The counter is - identifies a specific scope, because both passes walk the parse - tree in the same order. - - The st_varnames slot is a dictionary that maps code block ids to - parameter lists. The st_global slot always refers to the symbol - dictionary for the module. - - The st_children slot is a dictionary that maps ids to a list - containing the ids of its children. - */ - - struct symtable { - int st_pass; /* pass == 1 or 2 */ - PyObject *st_symbols; /* dictionary of symbol tables */ - PyObject *st_varnames; /* dictionary of parameter lists */ - PyObject *st_stack; /* stack of namespace info */ - PyObject *st_children; /* dictionary (id=[ids]) */ - PyObject *st_cur; /* borrowed ref to dict in st_symbols */ - PyObject *st_cur_name; /* string, name of current scope */ - PyObject *st_cur_id; /* int id of current code block */ - PyObject *st_cur_children; /* ref to current children list */ - int st_cur_type; /* type of current scope */ - PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ - int st_scopes; /* number of scopes */ - int st_errors; /* number of errors */ - char *st_private; /* name of current class or NULL */ - int st_tmpname; /* temporary name counter */ - int st_nested; /* bool (true if nested scope) */ - }; - - #define TOP "global" - #define NOOPT ".noopt" - - /* Flags for def-use information */ - - #define DEF_GLOBAL 1 /* global stmt */ - #define DEF_LOCAL 2 /* assignment in code block */ - #define DEF_PARAM 2<<1 /* formal parameter */ - #define USE 2<<2 /* name is used */ - #define DEF_STAR 2<<3 /* parameter is star arg */ - #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */ - #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */ - #define DEF_FREE 2<<6 /* name used by not defined in nested scope */ - #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */ - #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */ - #define DEF_IMPORT 2<<9 /* assignment occurred via import */ - int is_free(int v) { --- 359,362 ---- *************** *** 554,560 **** static int symtable_build(struct compiling *, node *); static int symtable_load_symbols(struct compiling *); ! static struct symtable *symtable_init(void); ! static void symtable_free(struct symtable *); ! static int symtable_enter_scope(struct symtable *, char *, int); static int symtable_exit_scope(struct symtable *); static int symtable_update_cur(struct symtable *); --- 477,482 ---- static int symtable_build(struct compiling *, node *); static int symtable_load_symbols(struct compiling *); ! static struct symtable *symtable_init(int); ! static void symtable_enter_scope(struct symtable *, char *, int, int); static int symtable_exit_scope(struct symtable *); static int symtable_update_cur(struct symtable *); *************** *** 2218,2222 **** int i, closure; int ndefs = com_argdefs(c, CHILD(n, 0)); ! symtable_enter_scope(c->c_symtable, "lambda", lambdef); co = (PyObject *) icompile(CHILD(n, 0), c); symtable_exit_scope(c->c_symtable); --- 2140,2145 ---- int i, closure; int ndefs = com_argdefs(c, CHILD(n, 0)); ! symtable_enter_scope(c->c_symtable, "lambda", lambdef, ! n->n_lineno); co = (PyObject *) icompile(CHILD(n, 0), c); symtable_exit_scope(c->c_symtable); *************** *** 3336,3340 **** REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ ndefs = com_argdefs(c, n); ! symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n)); co = (PyObject *)icompile(n, c); symtable_exit_scope(c->c_symtable); --- 3259,3264 ---- REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ ndefs = com_argdefs(c, n); ! symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n), ! n->n_lineno); co = (PyObject *)icompile(n, c); symtable_exit_scope(c->c_symtable); *************** *** 3396,3400 **** com_bases(c, CHILD(n, 3)); name = STR(CHILD(n, 1)); ! symtable_enter_scope(c->c_symtable, name, TYPE(n)); co = (PyObject *)icompile(n, c); symtable_exit_scope(c->c_symtable); --- 3320,3324 ---- com_bases(c, CHILD(n, 3)); name = STR(CHILD(n, 1)); ! symtable_enter_scope(c->c_symtable, name, TYPE(n), n->n_lineno); co = (PyObject *)icompile(n, c); symtable_exit_scope(c->c_symtable); *************** *** 3873,3876 **** --- 3797,3821 ---- } + struct symtable * + PyNode_CompileSymtable(node *n, char *filename) + { + struct symtable *st; + + st = symtable_init(1); + if (st == NULL) + return NULL; + symtable_enter_scope(st, TOP, TYPE(n), n->n_lineno); + if (st->st_errors > 0) { + PySymtable_Free(st); + return NULL; + } + symtable_node(st, n); + if (st->st_errors > 0) { + PySymtable_Free(st); + return NULL; + } + return st; + } + static PyCodeObject * icompile(node *n, struct compiling *base) *************** *** 3949,3953 **** exit: if (base == NULL) ! symtable_free(sc.c_symtable); com_free(&sc); return co; --- 3894,3898 ---- exit: if (base == NULL) ! PySymtable_Free(sc.c_symtable); com_free(&sc); return co; *************** *** 4006,4012 **** symtable_build(struct compiling *c, node *n) { ! if ((c->c_symtable = symtable_init()) == NULL) return -1; ! if (symtable_enter_scope(c->c_symtable, TOP, TYPE(n)) < 0) return -1; symtable_node(c->c_symtable, n); --- 3951,3958 ---- symtable_build(struct compiling *c, node *n) { ! if ((c->c_symtable = symtable_init(0)) == NULL) return -1; ! symtable_enter_scope(c->c_symtable, TOP, TYPE(n), n->n_lineno); ! if (c->c_symtable->st_errors > 0) return -1; symtable_node(c->c_symtable, n); *************** *** 4014,4018 **** return -1; /* reset for second pass */ ! c->c_symtable->st_scopes = 1; c->c_symtable->st_pass = 2; return 0; --- 3960,3964 ---- return -1; /* reset for second pass */ ! c->c_symtable->st_nscopes = 1; c->c_symtable->st_pass = 2; return 0; *************** *** 4193,4197 **** static struct symtable * ! symtable_init() { struct symtable *st; --- 4139,4143 ---- static struct symtable * ! symtable_init(int keep) { struct symtable *st; *************** *** 4202,4205 **** --- 4148,4152 ---- return NULL; st->st_pass = 1; + st->st_keep = keep; if ((st->st_stack = PyList_New(0)) == NULL) goto fail; *************** *** 4215,4219 **** goto fail; Py_DECREF(d); ! st->st_global = d; st->st_cur = NULL; st->st_cur_id = NULL; --- 4162,4172 ---- goto fail; Py_DECREF(d); ! if (keep) { ! if ((d = PyDict_New()) == NULL) ! goto fail; ! st->st_scopes = d; ! } else ! st->st_scopes = NULL; ! st->st_global = d; /* use ref borrowed from st->st_symbols */ st->st_cur = NULL; st->st_cur_id = NULL; *************** *** 4222,4226 **** st->st_cur_type = 0; st->st_nested = 0; ! st->st_scopes = 0; st->st_errors = 0; st->st_tmpname = 0; --- 4175,4179 ---- st->st_cur_type = 0; st->st_nested = 0; ! st->st_nscopes = 0; st->st_errors = 0; st->st_tmpname = 0; *************** *** 4228,4237 **** return st; fail: ! symtable_free(st); return NULL; } ! static void ! symtable_free(struct symtable *st) { Py_XDECREF(st->st_symbols); --- 4181,4190 ---- return st; fail: ! PySymtable_Free(st); return NULL; } ! void ! PySymtable_Free(struct symtable *st) { Py_XDECREF(st->st_symbols); *************** *** 4239,4242 **** --- 4192,4196 ---- Py_XDECREF(st->st_children); Py_XDECREF(st->st_stack); + Py_XDECREF(st->st_scopes); Py_XDECREF(st->st_cur_id); Py_XDECREF(st->st_cur_name); *************** *** 4245,4253 **** static PyObject * ! make_scope_info(PyObject *id, PyObject *name, int nested, int type) { ! PyObject *t, *i1 = NULL, *i2 = NULL; ! t = PyTuple_New(4); if (t == NULL) return NULL; --- 4199,4208 ---- static PyObject * ! make_scope_info(PyObject *id, PyObject *name, int nested, int type, ! int lineno) { ! PyObject *t, *i1 = NULL, *i2 = NULL, *i3 = NULL; ! t = PyTuple_New(5); if (t == NULL) return NULL; *************** *** 4258,4261 **** --- 4213,4219 ---- if (i2 == NULL) goto fail; + i3 = PyInt_FromLong(lineno); + if (i3 == NULL) + goto fail; Py_INCREF(name); *************** *** 4266,4269 **** --- 4224,4228 ---- PyTuple_SET_ITEM(t, 2, i1); PyTuple_SET_ITEM(t, 3, i2); + PyTuple_SET_ITEM(t, 4, i3); return t; fail: *************** *** 4271,4274 **** --- 4230,4234 ---- Py_XDECREF(i1); Py_XDECREF(i2); + Py_XDECREF(i3); return NULL; } *************** *** 4379,4383 **** } - static int symtable_exit_scope(struct symtable *st) --- 4339,4342 ---- *************** *** 4403,4408 **** } ! static int ! symtable_enter_scope(struct symtable *st, char *name, int type) { PyObject *o; --- 4362,4368 ---- } ! static void ! symtable_enter_scope(struct symtable *st, char *name, int type, ! int lineno) { PyObject *o; *************** *** 4411,4420 **** /* push current scope info on stack */ o = make_scope_info(st->st_cur_id, st->st_cur_name, ! st->st_nested, st->st_cur_type); ! if (o == NULL) ! return -1; if (PyList_Append(st->st_stack, o) < 0) { Py_DECREF(o); ! return -1; } Py_DECREF(o); --- 4371,4392 ---- /* push current scope info on stack */ o = make_scope_info(st->st_cur_id, st->st_cur_name, ! st->st_nested, st->st_cur_type, ! st->st_cur_lineno); ! if (o == NULL) { ! st->st_errors++; ! return; ! } if (PyList_Append(st->st_stack, o) < 0) { Py_DECREF(o); ! st->st_errors++; ! return; ! } ! if (st->st_keep) { ! if (PyDict_SetItem(st->st_scopes, ! st->st_cur_id, o) < 0) { ! Py_DECREF(o); ! st->st_errors++; ! return; ! } } Py_DECREF(o); *************** *** 4423,4426 **** --- 4395,4399 ---- if (st->st_nested || st->st_cur_type == TYPE_FUNCTION) st->st_nested = 1; + st->st_cur_lineno = lineno; switch (type) { case funcdef: *************** *** 4438,4451 **** default: fprintf(stderr, "invalid symtable scope: %d\n", type); ! return -1; } /* update st_cur_id and parent's st_cur_children */ ! o = PyInt_FromLong(st->st_scopes++); ! if (o == NULL) ! return -1; if (st->st_cur_children) { if (PyList_Append(st->st_cur_children, o) < 0) { Py_DECREF(o); ! return -1; } } --- 4411,4428 ---- default: fprintf(stderr, "invalid symtable scope: %d\n", type); ! st->st_errors++; ! return; } /* update st_cur_id and parent's st_cur_children */ ! o = PyInt_FromLong(st->st_nscopes++); ! if (o == NULL) { ! st->st_errors++; ! return; ! } if (st->st_cur_children) { if (PyList_Append(st->st_cur_children, o) < 0) { Py_DECREF(o); ! st->st_errors++; ! return; } } *************** *** 4453,4465 **** /* create st_cur_children list */ o = PyList_New(0); ! if (o == NULL) ! return -1; if (PyDict_SetItem(st->st_children, st->st_cur_id, o) < 0) { Py_DECREF(o); ! return -1; } Py_DECREF(o); ! return symtable_update_cur(st); } --- 4430,4445 ---- /* create st_cur_children list */ o = PyList_New(0); ! if (o == NULL) { ! st->st_errors++; ! return; ! } if (PyDict_SetItem(st->st_children, st->st_cur_id, o) < 0) { Py_DECREF(o); ! st->st_errors++; ! return; } Py_DECREF(o); ! symtable_update_cur(st); } *************** *** 4576,4580 **** symtable_add_def(st, func_name, DEF_LOCAL); symtable_default_args(st, CHILD(n, 2)); ! symtable_enter_scope(st, func_name, TYPE(n)); symtable_funcdef(st, n); symtable_exit_scope(st); --- 4556,4560 ---- symtable_add_def(st, func_name, DEF_LOCAL); symtable_default_args(st, CHILD(n, 2)); ! symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno); symtable_funcdef(st, n); symtable_exit_scope(st); *************** *** 4584,4588 **** if (NCH(n) == 4) symtable_default_args(st, CHILD(n, 1)); ! symtable_enter_scope(st, "lambda", TYPE(n)); symtable_funcdef(st, n); symtable_exit_scope(st); --- 4564,4568 ---- if (NCH(n) == 4) symtable_default_args(st, CHILD(n, 1)); ! symtable_enter_scope(st, "lambda", TYPE(n), n->n_lineno); symtable_funcdef(st, n); symtable_exit_scope(st); *************** *** 4598,4602 **** } } ! symtable_enter_scope(st, class_name, TYPE(n)); tmp = st->st_private; st->st_private = class_name; --- 4578,4582 ---- } } ! symtable_enter_scope(st, class_name, TYPE(n), n->n_lineno); tmp = st->st_private; st->st_private = class_name; Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.120 retrieving revision 2.121 diff -C2 -r2.120 -r2.121 *** pythonrun.c 2001/01/28 00:27:39 2.120 --- pythonrun.c 2001/02/02 18:19:15 2.121 *************** *** 10,13 **** --- 10,14 ---- #include "errcode.h" #include "compile.h" + #include "symtable.h" #include "eval.h" #include "marshal.h" *************** *** 962,965 **** --- 963,979 ---- PyNode_Free(n); return (PyObject *)co; + } + + struct symtable * + Py_SymtableString(char *str, char *filename, int start) + { + node *n; + struct symtable *st; + n = PyParser_SimpleParseString(str, start); + if (n == NULL) + return NULL; + st = PyNode_CompileSymtable(n, filename); + PyNode_Free(n); + return st; } From jhylton@users.sourceforge.net Fri Feb 2 18:24:27 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:24:27 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv27995 Modified Files: setup.py Log Message: Add minimal interface to symtable: _symtable module. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** setup.py 2001/02/02 12:12:44 1.22 --- setup.py 2001/02/02 18:24:25 1.23 *************** *** 155,158 **** --- 155,159 ---- exts.append( Extension('_weakref', ['_weakref.c']) ) + exts.append( Extension('_symtable', ['symtablemodule.c']) ) exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) From jhylton@users.sourceforge.net Fri Feb 2 18:24:27 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:24:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules symtablemodule.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv27995/Modules Added Files: symtablemodule.c Log Message: Add minimal interface to symtable: _symtable module. --- NEW FILE: symtablemodule.c --- #include "Python.h" #include "compile.h" #include "symtable.h" static PyObject * symtable_symtable(PyObject *self, PyObject *args) { struct symtable *st; PyObject *t; char *str; char *filename; char *startstr; int start; if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename, &startstr)) return NULL; if (strcmp(startstr, "exec") == 0) start = Py_file_input; else if (strcmp(startstr, "eval") == 0) start = Py_eval_input; else if (strcmp(startstr, "single") == 0) start = Py_single_input; else { PyErr_SetString(PyExc_ValueError, "symtable() arg 3 must be 'exec' or 'eval' or 'single'"); return NULL; } st = Py_SymtableString(str, filename, start); if (st == NULL) return NULL; t = Py_BuildValue("OO", st->st_symbols, st->st_scopes); PySymtable_Free(st); return t; } static PyMethodDef symtable_methods[] = { {"symtable", symtable_symtable, METH_VARARGS, "Return symbol and scope dictionaries used internally by compiler."}, {NULL, NULL} /* sentinel */ }; DL_EXPORT(void) init_symtable(void) { PyObject *m; m = Py_InitModule("_symtable", symtable_methods); PyModule_AddIntConstant(m, "USE", USE); PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL); PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL); PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM); PyModule_AddIntConstant(m, "DEF_STAR", DEF_STAR); PyModule_AddIntConstant(m, "DEF_DOUBLESTAR", DEF_DOUBLESTAR); PyModule_AddIntConstant(m, "DEF_INTUPLE", DEF_INTUPLE); PyModule_AddIntConstant(m, "DEF_FREE", DEF_FREE); PyModule_AddIntConstant(m, "DEF_FREE_GLOBAL", DEF_FREE_GLOBAL); PyModule_AddIntConstant(m, "DEF_FREE_CLASS", DEF_FREE_CLASS); PyModule_AddIntConstant(m, "DEF_IMPORT", DEF_IMPORT); PyModule_AddIntConstant(m, "TYPE_FUNCTION", TYPE_FUNCTION); PyModule_AddIntConstant(m, "TYPE_CLASS", TYPE_CLASS); PyModule_AddIntConstant(m, "TYPE_MODULE", TYPE_MODULE); PyModule_AddIntConstant(m, "LOCAL", LOCAL); PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT); PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT); PyModule_AddIntConstant(m, "FREE", FREE); PyModule_AddIntConstant(m, "CELL", CELL); } From jhylton@users.sourceforge.net Fri Feb 2 18:24:28 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:24:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_symtable.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27995/Lib/test Added Files: test_symtable.py Log Message: Add minimal interface to symtable: _symtable module. --- NEW FILE: test_symtable.py --- from test_support import verify import _symtable symbols, scopes = _symtable.symtable("def f(x): return x", "?", "exec") verify(symbols.has_key(0)) verify(scopes.has_key(0)) From jhylton@users.sourceforge.net Fri Feb 2 18:24:28 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 10:24:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_symtable,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv27995/Lib/test/output Added Files: test_symtable Log Message: Add minimal interface to symtable: _symtable module. --- NEW FILE: test_symtable --- test_symtable From bwarsaw@users.sourceforge.net Fri Feb 2 19:12:19 2001 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 02 Feb 2001 11:12:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.158,2.159 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv4770 Modified Files: import.c Log Message: Steve Majewski's patch #103495, MatchFilename() and find_module() patch for case-preserving HFS+ suport. Untested except to verify that it builds and doesn't break anything on Linux RH6.1. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.158 retrieving revision 2.159 diff -C2 -r2.158 -r2.159 *** import.c 2001/01/28 00:27:39 2.158 --- import.c 2001/02/02 19:12:16 2.159 *************** *** 837,840 **** --- 837,874 ---- static int find_init_module(char *); /* Forward */ + #ifdef HAVE_DIRENT_H + + static int MatchFilename(char *pathname, char *filename); + + #include + #include + + static int MatchFilename(char *pathname, char *filename) + { + DIR *dirp; + struct dirent *dp; + int len = strlen(filename); + + if ((pathname == NULL) || (strlen(pathname) == 0)) + pathname = "."; + dirp = opendir(pathname); + if (dirp) { + while ((dp = readdir(dirp)) != NULL) { + #ifdef _DIRENT_HAVE_D_NAMELINE + int namelen = dp->d_namlen; + #else /* !_DIRENT_HAVE_D_NAMELINE */ + int namelen = strlen(dp->d_name); + #endif /* _DIRENT_HAVE_D_NAMELINE */ + if (namelen == len && !strcmp(dp->d_name, filename)) { + (void)closedir(dirp); + return 1; /* Found */ + } + } + } + (void)closedir(dirp); + return 0 ; /* Not found */ + } + #endif /* HAVE_DIRENT_H */ + static struct filedescr * find_module(char *realname, PyObject *path, char *buf, size_t buflen, *************** *** 967,972 **** --- 1001,1025 ---- PySys_WriteStderr("# trying %s\n", buf); fp = fopen(buf, fdp->mode); + #ifdef HAVE_DIRENT_H + + if (fp != NULL) { /* check case */ + char *curpath = PyString_AsString(v); + char *nstart = buf + strlen(curpath); + if (*nstart == SEP) + nstart++; + if (MatchFilename(curpath, nstart)) { + break; /* Found */ + } + fclose(fp); /* No. Close & continue search */ + fp = NULL; + if (Py_VerboseFlag > 1) + PySys_WriteStderr( + "# case mismatch for %s: %s\n", + name, buf); + } + #else /* !HAVE_DIRENT_H */ if (fp != NULL) break; + #endif /* HAVE_DIRENT_H */ } #endif /* !macintosh */ From fdrake@users.sourceforge.net Fri Feb 2 19:28:37 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 11:28:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib weakref.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7797/Lib Modified Files: weakref.py Log Message: Ouch! I need a better test suite for this. ;-( Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** weakref.py 2001/02/02 15:13:24 1.2 --- weakref.py 2001/02/02 19:28:35 1.3 *************** *** 70,74 **** L = [] for key, ref in self.data.items(): - key, ref = L[i] o = ref() if o is not None: --- 70,73 ---- From fdrake@users.sourceforge.net Fri Feb 2 19:40:22 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 11:40:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv10178/Lib/xml/dom Modified Files: minidom.py Log Message: Added Node.isSameNode() support. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** minidom.py 2001/01/27 08:47:37 1.21 --- minidom.py 2001/02/02 19:40:19 1.22 *************** *** 219,222 **** --- 219,229 ---- return clone + # DOM Level 3 (Working Draft 2001-Jan-26) + + def isSameNode(self, other): + return self is other + + # minidom-specific API: + def unlink(self): self.parentNode = None From jhylton@users.sourceforge.net Fri Feb 2 19:54:25 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 11:54:25 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv12234 Modified Files: Makefile.pre.in Log Message: add compile.h and symtable.h to list of header files Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** Makefile.pre.in 2001/02/02 18:12:16 1.11 --- Makefile.pre.in 2001/02/02 19:54:23 1.12 *************** *** 427,430 **** --- 427,432 ---- Include/object.h \ Include/objimpl.h \ + Include/compile.h \ + Include/symtable.h \ Include/pydebug.h \ Include/unicodeobject.h \ From jhylton@users.sourceforge.net Fri Feb 2 19:55:19 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 11:55:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.134,1.135 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12336/Modules Modified Files: socketmodule.c Log Message: fix a couple last-minute bugs in the raw socket support Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -r1.134 -r1.135 *** socketmodule.c 2001/02/02 03:23:09 1.134 --- socketmodule.c 2001/02/02 19:55:17 1.135 *************** *** 38,43 **** specifying the ethernet interface and an integer specifying the Ethernet protocol number to be received. For example: ! ("eth0",0x1234). Optional 3rd and 4th elements in the tuple ! specify packet-type and ha-type -- these are ignored by networking code, but accepted since they are returned by the getsockname() method. --- 38,43 ---- specifying the ethernet interface and an integer specifying the Ethernet protocol number to be received. For example: ! ("eth0",0x1234). Optional 3rd,4th,5th elements in the tuple ! specify packet-type and ha-type/addr -- these are ignored by networking code, but accepted since they are returned by the getsockname() method. *************** *** 535,539 **** /*ARGSUSED*/ static PyObject * ! makesockaddr(struct sockaddr *addr, int addrlen) { if (addrlen == 0) { --- 535,539 ---- /*ARGSUSED*/ static PyObject * ! makesockaddr(int sockfd, struct sockaddr *addr, int addrlen) { if (addrlen == 0) { *************** *** 576,593 **** char *ifname = ""; struct ifreq ifr; ! int s; ! /* need a socket on which we can do an ioctl to look ! * up interface name from index, but only if index is ! * non-zero. ! */ ! if (a->sll_ifindex ! && ((s = socket(AF_PACKET, SOCK_RAW, 0)) >= 0)) { ifr.ifr_ifindex = a->sll_ifindex; ! if (ioctl(s, SIOCGIFNAME, &ifr) == 0) ifname = ifr.ifr_name; - close(s); } ! return Py_BuildValue("shbh", ifname, ntohs(a->sll_protocol), ! a->sll_pkttype, a->sll_hatype); } #endif --- 576,588 ---- char *ifname = ""; struct ifreq ifr; ! /* need to look up interface name give index */ ! if (a->sll_ifindex) { ifr.ifr_ifindex = a->sll_ifindex; ! if (ioctl(sockfd, SIOCGIFNAME, &ifr) == 0) ifname = ifr.ifr_name; } ! return Py_BuildValue("shbhs#", ifname, ntohs(a->sll_protocol), ! a->sll_pkttype, a->sll_hatype, ! a->sll_addr, a->sll_halen); } #endif *************** *** 613,617 **** static int ! getsockaddrarg(PySocketSockObject *s, PyObject *args, struct sockaddr **addr_ret, int *len_ret) { switch (s->sock_family) { --- 608,613 ---- static int ! getsockaddrarg(PySocketSockObject *s, PyObject *args, ! struct sockaddr **addr_ret, int *len_ret) { switch (s->sock_family) { *************** *** 672,683 **** int hatype = 0; int pkttype = 0; ! if (!PyArg_ParseTuple(args, "si|ii", &interfaceName, ! &protoNumber, &pkttype, &hatype)) return 0; strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0'; ! if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr)) return 0; addr = &(s->sock_addr.ll); addr->sll_family = AF_PACKET; --- 668,682 ---- int hatype = 0; int pkttype = 0; + char *haddr; ! if (!PyArg_ParseTuple(args, "si|iis", &interfaceName, ! &protoNumber, &pkttype, &hatype, &haddr)) return 0; strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0'; ! if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) { ! PyErr_SetFromErrno(PySocket_Error); return 0; + } addr = &(s->sock_addr.ll); addr->sll_family = AF_PACKET; *************** *** 780,788 **** goto finally; } ! if (!(addr = makesockaddr((struct sockaddr *) addrbuf, addrlen))) goto finally; ! if (!(res = Py_BuildValue("OO", sock, addr))) ! goto finally; finally: --- 779,788 ---- goto finally; } ! addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen); ! if (addr == NULL) goto finally; ! res = Py_BuildValue("OO", sock, addr); finally: *************** *** 1129,1133 **** if (res < 0) return PySocket_Err(); ! return makesockaddr((struct sockaddr *) addrbuf, addrlen); } --- 1129,1133 ---- if (res < 0) return PySocket_Err(); ! return makesockaddr(s->sock_fd, (struct sockaddr *) addrbuf, addrlen); } *************** *** 1158,1162 **** if (res < 0) return PySocket_Err(); ! return makesockaddr((struct sockaddr *) addrbuf, addrlen); } --- 1158,1162 ---- if (res < 0) return PySocket_Err(); ! return makesockaddr(s->sock_fd, (struct sockaddr *) addrbuf, addrlen); } *************** *** 1320,1324 **** return NULL; ! if (!(addr = makesockaddr((struct sockaddr *)addrbuf, addrlen))) goto finally; --- 1320,1324 ---- return NULL; ! if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, addrlen))) goto finally; From jhylton@users.sourceforge.net Fri Feb 2 20:01:12 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:01:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.158,2.159 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv13654/Python Modified Files: compile.c Log Message: Fix symbol table pass to generation SyntaxError exceptions that include the filename and line number. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.158 retrieving revision 2.159 diff -C2 -r2.158 -r2.159 *** compile.c 2001/02/02 18:19:15 2.158 --- compile.c 2001/02/02 20:01:10 2.159 *************** *** 372,400 **** static void ! com_error(struct compiling *c, PyObject *exc, char *msg) { ! PyObject *v, *tb, *tmp; ! if (c == NULL) { ! /* Error occurred via symtable call to ! is_constant_false */ ! PyErr_SetString(exc, msg); ! return; ! } ! c->c_errors++; ! if (c->c_lineno <= 1) { ! /* Unknown line number or single interactive command */ ! PyErr_SetString(exc, msg); ! return; ! } ! v = PyString_FromString(msg); ! if (v == NULL) ! return; /* MemoryError, too bad */ ! PyErr_SetObject(exc, v); ! Py_DECREF(v); /* add attributes for the line number and filename for the error */ PyErr_Fetch(&exc, &v, &tb); PyErr_NormalizeException(&exc, &v, &tb); ! tmp = PyInt_FromLong(c->c_lineno); if (tmp == NULL) PyErr_Clear(); --- 372,383 ---- static void ! set_error_location(char *filename, int lineno) { ! PyObject *exc, *v, *tb, *tmp; /* add attributes for the line number and filename for the error */ PyErr_Fetch(&exc, &v, &tb); PyErr_NormalizeException(&exc, &v, &tb); ! tmp = PyInt_FromLong(lineno); if (tmp == NULL) PyErr_Clear(); *************** *** 404,409 **** Py_DECREF(tmp); } ! if (c->c_filename != NULL) { ! tmp = PyString_FromString(c->c_filename); if (tmp == NULL) PyErr_Clear(); --- 387,392 ---- Py_DECREF(tmp); } ! if (filename != NULL) { ! tmp = PyString_FromString(filename); if (tmp == NULL) PyErr_Clear(); *************** *** 417,421 **** --- 400,429 ---- } + static void + com_error(struct compiling *c, PyObject *exc, char *msg) + { + PyObject *v; + if (c == NULL) { + /* Error occurred via symtable call to + is_constant_false */ + PyErr_SetString(exc, msg); + return; + } + c->c_errors++; + if (c->c_lineno <= 1) { + /* Unknown line number or single interactive command */ + PyErr_SetString(exc, msg); + return; + } + v = PyString_FromString(msg); + if (v == NULL) + return; /* MemoryError, too bad */ + PyErr_SetObject(exc, v); + Py_DECREF(v); + + set_error_location(c->c_filename, c->c_lineno); + } + /* Interface to the block stack */ *************** *** 3805,3808 **** --- 3813,3817 ---- if (st == NULL) return NULL; + assert(st->st_symbols != NULL); symtable_enter_scope(st, TOP, TYPE(n), n->n_lineno); if (st->st_errors > 0) { *************** *** 3953,3956 **** --- 3962,3966 ---- if ((c->c_symtable = symtable_init(0)) == NULL) return -1; + c->c_symtable->st_filename = c->c_filename; symtable_enter_scope(c->c_symtable, TOP, TYPE(n), n->n_lineno); if (c->c_symtable->st_errors > 0) *************** *** 4058,4066 **** if ((info & DEF_PARAM) && (PyString_AS_STRING(name)[0] != '.')){ ! char buf[500]; ! sprintf(buf, ! "name '%.400s' is local and global", ! PyString_AS_STRING(name)); ! com_error(c, PyExc_SyntaxError, buf); goto fail; } --- 4068,4076 ---- if ((info & DEF_PARAM) && (PyString_AS_STRING(name)[0] != '.')){ ! PyErr_Format(PyExc_SyntaxError, ! "name '%.400s' is local and global", ! PyString_AS_STRING(name)); ! set_error_location(st->st_filename, ! st->st_cur_lineno); goto fail; } *************** *** 4120,4130 **** c->c_flags |= CO_OPTIMIZED; else if (ncells || nfrees) { ! char buf[256]; ! /* XXX need better error message */ ! sprintf(buf, "function %.100s: may not use lexical scoping" " and 'import *' or exec in same function", PyString_AS_STRING(st->st_cur_name)); ! com_error(c, PyExc_SyntaxError, buf); return -1; } --- 4130,4139 ---- c->c_flags |= CO_OPTIMIZED; else if (ncells || nfrees) { ! PyErr_Format(PyExc_SyntaxError, "function %.100s: may not use lexical scoping" " and 'import *' or exec in same function", PyString_AS_STRING(st->st_cur_name)); ! set_error_location(st->st_filename, ! st->st_cur_lineno); return -1; } *************** *** 4149,4152 **** --- 4158,4162 ---- st->st_pass = 1; st->st_keep = keep; + st->st_filename = NULL; if ((st->st_stack = PyList_New(0)) == NULL) goto fail; *************** *** 4161,4164 **** --- 4171,4175 ---- if (PyDict_SetItemString(st->st_symbols, TOP, d) < 0) goto fail; + st->st_global = d; Py_DECREF(d); if (keep) { *************** *** 4168,4172 **** } else st->st_scopes = NULL; - st->st_global = d; /* use ref borrowed from st->st_symbols */ st->st_cur = NULL; st->st_cur_id = NULL; --- 4179,4182 ---- *************** *** 4506,4509 **** --- 4516,4521 ---- PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, PyString_AsString(name)); + set_error_location(st->st_filename, + st->st_cur_lineno); return -1; } *************** *** 4845,4848 **** --- 4857,4862 ---- PyErr_SetString(PyExc_SyntaxError, ILLEGAL_IMPORT_STAR); + set_error_location(st->st_filename, + n->n_lineno); st->st_errors++; return; From jhylton@users.sourceforge.net Fri Feb 2 20:01:12 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:01:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include symtable.h,2.1,2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv13654/Include Modified Files: symtable.h Log Message: Fix symbol table pass to generation SyntaxError exceptions that include the filename and line number. Index: symtable.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/symtable.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** symtable.h 2001/02/02 18:19:15 2.1 --- symtable.h 2001/02/02 20:01:09 2.2 *************** *** 44,47 **** --- 44,48 ---- int st_pass; /* pass == 1 or 2 */ int st_keep; /* true if symtable will be returned */ + char *st_filename; /* name of file being compiled */ PyObject *st_symbols; /* dictionary of symbol tables */ PyObject *st_varnames; /* dictionary of parameter lists */ From jhylton@users.sourceforge.net Fri Feb 2 20:06:30 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:06:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.117,1.118 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv14230 Modified Files: NEWS Log Message: Fix spelling errors. Add note about _symtable. Add note that 'from ... import *' restriction may go away -- and move the whole entry closer to the top, because it might bite people. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -r1.117 -r1.118 *** NEWS 2001/02/02 05:57:14 1.117 --- NEWS 2001/02/02 20:06:28 1.118 *************** *** 12,16 **** In all previous version of Python, names were resolved in exactly three namespaces -- the local namespace, the global namespace, and ! the builtin namespace. According to this old defintion, if a function A is defined within a function B, the names bound in B are not visible in A. The new rules make names bound in B visible in A, --- 12,16 ---- In all previous version of Python, names were resolved in exactly three namespaces -- the local namespace, the global namespace, and ! the builtin namespace. According to this old definition, if a function A is defined within a function B, the names bound in B are not visible in A. The new rules make names bound in B visible in A, *************** *** 37,40 **** --- 37,47 ---- called. + - The compiler will report a SyntaxError if "from ... import *" occurs + in a function or class scope. The language reference has documented + that this case is illegal, but the compiler never checked for it. + The recent introduction of nested scope makes the meaning of this + form of name binding ambiguous. In a future release, the compiler + may allow this form when there is no possibility of ambiguity. + - repr(string) is easier to read, now using hex escapes instead of octal, and using \t, \n and \r instead of \011, \012 and \015 (respectively): *************** *** 47,56 **** the func_code attribute is writable. - - The compiler will report a SyntaxError if "from ... import *" occurs - in a function or class scope. The language reference has documented - that this case is illegal, but the compiler never checked for it. - The recent introduction of nested scope makes the meaning of this - form of name binding ambiguous. - - Weak references (PEP 205) have been added. This involves a few changes in the core, an extension module (_weakref), and a Python --- 54,57 ---- *************** *** 97,100 **** --- 98,105 ---- - test_capi.py is a start at running tests of the Python C API. The tests are implemented by the new Modules/_testmodule.c. + + - A new extension module, _symtable, provides provisional access to the + internal symbol table used by the Python compiler. A higher-level + interface will be added on top of _symtable in a future release. Windows changes From jhylton@users.sourceforge.net Fri Feb 2 20:07:48 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:07:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/idle IOBinding.py,1.3,1.4 Percolator.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle In directory usw-pr-cvs1:/tmp/cvs-serv14499 Modified Files: IOBinding.py Percolator.py Log Message: move "from Tkinter import *" to module level Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/IOBinding.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** IOBinding.py 1999/06/25 16:02:22 1.3 --- IOBinding.py 2001/02/02 20:07:46 1.4 *************** *** 201,205 **** def test(): - from Tkinter import * root = Tk() class MyEditWin: --- 201,204 ---- *************** *** 230,232 **** --- 229,232 ---- if __name__ == "__main__": + from Tkinter import * test() Index: Percolator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Percolator.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Percolator.py 1999/06/25 16:04:38 1.2 --- Percolator.py 2001/02/02 20:07:46 1.3 *************** *** 64,68 **** print self.name, ": delete", args apply(self.delegate.delete, args) - from Tkinter import * root = Tk() root.wm_protocol("WM_DELETE_WINDOW", root.quit) --- 64,67 ---- *************** *** 83,85 **** --- 82,85 ---- if __name__ == "__main__": + from Tkinter import * main() From jhylton@users.sourceforge.net Fri Feb 2 20:11:15 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:11:15 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.191,1.192 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv14905 Modified Files: configure Log Message: the usual Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.191 retrieving revision 1.192 diff -C2 -r1.191 -r1.192 *** configure 2001/01/27 21:40:54 1.191 --- configure 2001/02/02 20:11:13 1.192 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.198 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.199 # Guess values for system-dependent variables and create Makefiles. *************** *** 5437,5441 **** /* Ultrix mips cc rejects this. */ ! typedef int charset[2]; const charset x = {0,0}; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; --- 5437,5441 ---- /* Ultrix mips cc rejects this. */ ! typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; From jhylton@users.sourceforge.net Fri Feb 2 20:13:03 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:13:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include patchlevel.h,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv15248/Include Modified Files: patchlevel.h Log Message: bump to 2.1a2 Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** patchlevel.h 2001/01/17 14:12:33 2.43 --- patchlevel.h 2001/02/02 20:13:01 2.44 *************** *** 24,34 **** #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.1a1" /* Historic */ ! #define PATCHLEVEL "2.1a1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 24,34 ---- #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 2 /* Version as a string */ ! #define PY_VERSION "2.1a2" /* Historic */ ! #define PATCHLEVEL "2.1a2" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From jhylton@users.sourceforge.net Fri Feb 2 20:13:26 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 02 Feb 2001 12:13:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.159,2.160 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv15298/Python Modified Files: import.c Log Message: bump the magic number; the compiler has changed since 2.1a1 Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.159 retrieving revision 2.160 diff -C2 -r2.159 -r2.160 *** import.c 2001/02/02 19:12:16 2.159 --- import.c 2001/02/02 20:13:24 2.160 *************** *** 44,48 **** added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (60124 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the --- 44,48 ---- added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (60202 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the From tim_one@users.sourceforge.net Fri Feb 2 21:24:54 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 02 Feb 2001 13:24:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild _symtable.dsp,NONE,1.1 pcbuild.dsw,1.24,1.25 python20.wse,1.25,1.26 readme.txt,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv28585/python/dist/src/PCbuild Modified Files: pcbuild.dsw python20.wse readme.txt Added Files: _symtable.dsp Log Message: Teach Windows build and installer about new _symtable module/DLL. --- NEW FILE: _symtable.dsp --- # Microsoft Developer Studio Project File - Name="_symtable" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=_symtable - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "_symtable.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "_symtable.mak" CFG="_symtable - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "_symtable - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "_symtable - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "_symtable" # PROP Scc_LocalPath ".." CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "_symtable - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-release\_symtable" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_symtable.pyd" /export:init_symtable # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "_symtable - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-debug\_symtable" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_symtable_d.pyd" /pdbtype:sept /export:init_symtable # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "_symtable - Win32 Release" # Name "_symtable - Win32 Debug" # Begin Source File SOURCE=..\Modules\symtablemodule.c # End Source File # End Target # End Project Index: pcbuild.dsw =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.dsw,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** pcbuild.dsw 2001/02/02 05:57:15 1.24 --- pcbuild.dsw 2001/02/02 21:24:51 1.25 *************** *** 34,37 **** --- 34,49 ---- ############################################################################### + Project: "_symtable"=.\_symtable.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Project: "_test"=.\_test.dsp - Package Owner=<4> Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** python20.wse 2001/02/02 06:33:04 1.25 --- python20.wse 2001/02/02 21:24:51 1.26 *************** *** 693,696 **** --- 693,701 ---- end item: Install File + Source=%_SRC_%\PCbuild\_symtable.pyd + Destination=%MAINDIR%\DLLs\_symtable.pyd + Flags=0000000000000010 + end + item: Install File Source=%_SRC_%\PCbuild\_test.pyd Destination=%MAINDIR%\DLLs\_test.pyd *************** *** 759,762 **** --- 764,772 ---- Source=%_SRC_%\PCbuild\_sre.lib Destination=%MAINDIR%\libs\_sre.lib + Flags=0000000000000010 + end + item: Install File + Source=%_SRC_%\PCbuild\_symtable.lib + Destination=%MAINDIR%\libs\_symtable.lib Flags=0000000000000010 end Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** readme.txt 2001/02/02 05:57:15 1.18 --- readme.txt 2001/02/02 21:24:51 1.19 *************** *** 44,47 **** --- 44,52 ---- _sre Unicode-aware regular expression engine + _symtable + the _symtable module, symtablemodule.c + _test + tests of the Python C API, run via Lib/test/test_capi.py, and + implemented by module Modules/_testmodule.c mmap mmapmodule.c *************** *** 56,62 **** winsound play sounds (typically .wav files) under Windows - _test - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testmodule.c The following subprojects will generally NOT build out of the box. They --- 61,64 ---- From tim_one@users.sourceforge.net Fri Feb 2 21:24:53 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 02 Feb 2001 13:24:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.118,1.119 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv28585/python/dist/src/Misc Modified Files: NEWS Log Message: Teach Windows build and installer about new _symtable module/DLL. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -r1.118 -r1.119 *** NEWS 2001/02/02 20:06:28 1.118 --- NEWS 2001/02/02 21:24:51 1.119 *************** *** 113,117 **** - Build: New subproject _test for the benefit of test_capi.py (see above). ! - Build: subproject ucnhash is gone, since the code was folded into the unicodedata subproject. --- 113,120 ---- - Build: New subproject _test for the benefit of test_capi.py (see above). ! - Build: New subproject _symtable, for new DLL _symtable.pyd (a nascent ! interface to some Python compiler internals). ! ! - Build: Subproject ucnhash is gone, since the code was folded into the unicodedata subproject. From tim_one@users.sourceforge.net Fri Feb 2 21:10:56 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 02 Feb 2001 13:10:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _weakref.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv25401/python/dist/src/modules Modified Files: _weakref.c Log Message: Repair legit compiler warning. Index: _weakref.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** _weakref.c 2001/02/02 00:07:07 1.2 --- _weakref.c 2001/02/02 21:10:53 1.3 *************** *** 35,39 **** free_list = result->wr_next; result->ob_type = &PyWeakReference_Type; ! _Py_NewReference(result); } else { --- 35,39 ---- free_list = result->wr_next; result->ob_type = &PyWeakReference_Type; ! _Py_NewReference((PyObject *)result); } else { From fdrake@users.sourceforge.net Sat Feb 3 01:11:28 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 17:11:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.105,1.106 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv32672/api Modified Files: api.tex Log Message: Remove an now-false statement about there being only one type flag defined. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -r1.105 -r1.106 *** api.tex 2001/01/28 06:39:35 1.105 --- api.tex 2001/02/03 01:11:26 1.106 *************** *** 2084,2090 **** \begin{cfuncdesc}{int}{PyType_HasFeature}{PyObject *o, int feature} Returns true if the type object \var{o} sets the feature ! \var{feature}. Type features are denoted by single bit flags. The ! only defined feature flag is \constant{Py_TPFLAGS_HAVE_GETCHARBUFFER}, ! described in section \ref{buffer-structs}. \end{cfuncdesc} --- 2084,2088 ---- \begin{cfuncdesc}{int}{PyType_HasFeature}{PyObject *o, int feature} Returns true if the type object \var{o} sets the feature ! \var{feature}. Type features are denoted by single bit flags. \end{cfuncdesc} From fdrake@users.sourceforge.net Sat Feb 3 01:17:44 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 17:17:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.177,1.178 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv996/lib Modified Files: lib.tex Log Message: Move the whrandom section back to the documented modules section; this gives people a chance to see the depracation notice. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.177 retrieving revision 1.178 diff -C2 -r1.177 -r1.178 *** lib.tex 2001/02/02 02:45:08 1.177 --- lib.tex 2001/02/03 01:17:41 1.178 *************** *** 113,116 **** --- 113,117 ---- \input{libcmath} \input{librandom} + \input{libwhrandom} \input{libbisect} \input{libarray} *************** *** 307,311 **** %\input{libregsub} %\input{libsoundex} - %\input{libwhrandom} \chapter{Reporting Bugs} --- 308,311 ---- From fdrake@users.sourceforge.net Sat Feb 3 01:12:46 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 17:12:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwhrandom.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv424/lib Modified Files: libwhrandom.tex Log Message: Revise the deprecation note for the whrandom module to be correct and a little more formal. Index: libwhrandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwhrandom.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** libwhrandom.tex 2001/02/02 02:41:17 1.13 --- libwhrandom.tex 2001/02/03 01:12:44 1.14 *************** *** 5,10 **** \modulesynopsis{Floating point pseudo-random number generator.} ! \strong{Note:} This module is an implementation detail of the ! \refmodule{random} module. Please do not use this module directly. This module implements a Wichmann-Hill pseudo-random number generator --- 5,14 ---- \modulesynopsis{Floating point pseudo-random number generator.} ! \deprecated{2.1}{Use \refmodule{random} instead.} ! ! \strong{Note:} This module was an implementation detail of the ! \refmodule{random} module in releases of Python prior to 2.1. It is ! no longer used. Please do not use this module directly; use ! \refmodule{random} instead. This module implements a Wichmann-Hill pseudo-random number generator From fdrake@users.sourceforge.net Sat Feb 3 01:20:03 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 02 Feb 2001 17:20:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmldom.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1306/lib Modified Files: xmldom.tex Log Message: Document Node.isSameNode(). Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** xmldom.tex 2001/01/26 20:51:32 1.8 --- xmldom.tex 2001/02/03 01:20:01 1.9 *************** *** 238,241 **** --- 238,248 ---- \end{methoddesc} + \begin{methoddesc}[Node]{isSameNode}{other} + Returns true if \var{other} refers to the same node as this node. + This is especially useful for DOM implementations which use any sort + of proxy architecture (because more than one object can refer to the + same node). + \end{methoddesc} + \begin{methoddesc}[Node]{appendChild}{newChild} Add a new child node to this node at the end of the list of children, From fdrake@users.sourceforge.net Sat Feb 3 14:35:41 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Sat, 03 Feb 2001 06:35:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libtime.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv29088/lib Modified Files: libtime.tex Log Message: Fix markup typo in a {verbatim} environment (there should not be any!); caught by Eric Raymond. Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** libtime.tex 2001/01/28 00:56:54 1.36 --- libtime.tex 2001/02/03 14:35:38 1.37 *************** *** 236,240 **** \begin{verbatim} >>> from time import * ! >>> strftime("\%a, \%d \%b \%Y \%H:\%M:\%S \%Z", localtime()) 'Sat, 27 Jan 2001 05:15:05 EST' >>> --- 236,240 ---- \begin{verbatim} >>> from time import * ! >>> strftime("%a, %d %b %Y %H:%M:%S %Z", localtime()) 'Sat, 27 Jan 2001 05:15:05 EST' >>> From gvanrossum@users.sourceforge.net Sat Feb 3 15:06:43 2001 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 03 Feb 2001 07:06:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.119,1.120 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv1719 Modified Files: NEWS Log Message: Clarify the news item about "from M import X" if "M is not a real module" after a complaint from Tim. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -r1.119 -r1.120 *** NEWS 2001/02/02 21:24:51 1.119 --- NEWS 2001/02/03 15:06:40 1.120 *************** *** 189,195 **** - Two changes to from...import: ! 1) "from M import X" now works even if M is not a real module; it's ! basically a getattr() operation with AttributeError exceptions ! changed into ImportError. 2) "from M import *" now looks for M.__all__ to decide which names to --- 189,195 ---- - Two changes to from...import: ! 1) "from M import X" now works even if (after loading module M) ! sys.modules['M'] is not a real module; it's basically a getattr() ! operation with AttributeError exceptions changed into ImportError. 2) "from M import *" now looks for M.__all__ to decide which names to From nascheme@users.sourceforge.net Sat Feb 3 17:16:31 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:16:31 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv28481 Modified Files: Makefile.pre.in Log Message: Tweak clean targets yet again. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** Makefile.pre.in 2001/02/02 19:54:23 1.12 --- Makefile.pre.in 2001/02/03 17:16:29 1.13 *************** *** 758,789 **** clean: - -rm -f core *~ [@,#]* *.old *.orig *.rej - -rm -rf build # avoid long command lines, same as LIBRARY_OBJS MAINOBJ PGOBJS -rm -f $(PARSER_OBJS) -rm -f $(OBJECT_OBJS) -rm -f $(PYTHON_OBJS) ! -rm -f $(MODULE_OBJS) $(SIGNAL_OBJS) -rm -f $(MODOBJS) $(MAINOBJ) $(PGOBJS) clobber: clean -rm -f tags TAGS $(PYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ ! Modules/*.so Modules/*.sl # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] distclean: clobber ! -rm -f Makefile Makefile.pre buildno config.status config.log \ ! config.cache config.h setup.cfg Modules/config.c \ Modules/Setup Modules/Setup.local Modules/Setup.config ! -for i in $(SUBDIRSTOO); do \ ! for f in $$i/*.in; do \ ! f=`basename "$$f" .in`; \ ! if test "$$f" != "*"; then \ ! echo rm -f "$$i/$$f"; \ ! rm -f "$$i/$$f"; \ ! fi; \ ! done; \ ! done # Check for smelly exported symbols (not starting with Py/_Py) --- 758,786 ---- clean: # avoid long command lines, same as LIBRARY_OBJS MAINOBJ PGOBJS -rm -f $(PARSER_OBJS) -rm -f $(OBJECT_OBJS) -rm -f $(PYTHON_OBJS) ! -rm -f $(MODULE_OBJS) $(SIGNAL_OBJS) Modules/getbuildinfo.o -rm -f $(MODOBJS) $(MAINOBJ) $(PGOBJS) + if test -f build; then find build -name '*.o' -exec rm -f {} ';' ; fi + find $(srcdir) -name '*.py[co]' -exec rm -f {} ';' clobber: clean -rm -f tags TAGS $(PYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ ! Modules/*.so Modules/*.sl Parser/pgen ! -rm -rf build # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] distclean: clobber ! -rm -f core Makefile Makefile.pre buildno config.status \ ! config.log config.cache config.h Modules/config.c \ Modules/Setup Modules/Setup.local Modules/Setup.config ! find $(srcdir) '(' -name '*.fdc' -o -name '*~' \ ! -o -name '[@,#]*' -o -name '*.old' \ ! -o -name '*.orig' -o -name '*.rej' \ ! -o -name '*.bak' ')' \ ! -exec rm -f {} ';' # Check for smelly exported symbols (not starting with Py/_Py) From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.113,NONE Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv28644 Removed Files: Makefile.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.in DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Grammar Makefile.in,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Grammar In directory usw-pr-cvs1:/tmp/cvs-serv28644/Grammar Removed Files: Makefile.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.in DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo Makefile,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Demo In directory usw-pr-cvs1:/tmp/cvs-serv28644/Demo Removed Files: Makefile Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib Makefile,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28644/Lib Removed Files: Makefile Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include Makefile,2.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv28644/Include Removed Files: Makefile Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc Makefile,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv28644/Misc Removed Files: Makefile Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Makefile.pre.in,1.75,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv28644/Modules Removed Files: Makefile.pre.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.pre.in DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:22 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects Makefile.in,2.14,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28644/Objects Removed Files: Makefile.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.in DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:23 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python Makefile.in,2.27,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv28644/Python Removed Files: Makefile.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.in DELETED --- From nascheme@users.sourceforge.net Sat Feb 3 17:18:23 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 03 Feb 2001 09:18:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Parser Makefile.in,2.11,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory usw-pr-cvs1:/tmp/cvs-serv28644/Parser Removed Files: Makefile.in Log Message: Superseded by $(srcdir)/Makefile.pre.in. --- Makefile.in DELETED --- From tim_one@users.sourceforge.net Sun Feb 4 03:09:54 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 03 Feb 2001 19:09:54 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv19049/python/dist/src Modified Files: setup.py Log Message: Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** setup.py 2001/02/02 18:24:25 1.23 --- setup.py 2001/02/04 03:09:52 1.24 *************** *** 177,181 **** exts.append( Extension('_codecs', ['_codecsmodule.c']) ) # Python C API test module ! exts.append( Extension('_test', ['_testmodule.c']) ) # static Unicode character database exts.append( Extension('unicodedata', ['unicodedata.c']) ) --- 177,181 ---- exts.append( Extension('_codecs', ['_codecsmodule.c']) ) # Python C API test module ! exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) # static Unicode character database exts.append( Extension('unicodedata', ['unicodedata.c']) ) From tim_one@users.sourceforge.net Sun Feb 4 03:09:54 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 03 Feb 2001 19:09:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_capi.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19049/python/dist/src/Lib/test Modified Files: test_capi.py Log Message: Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_capi.py 2001/02/02 05:57:14 1.1 --- test_capi.py 2001/02/04 03:09:52 1.2 *************** *** 1,16 **** ! # Run the _test module tests (tests for the Python/C API): by defn, these ! # are all functions _test exports whose name begins with 'test_'. import sys import test_support ! import _test ! for name in dir(_test): if name.startswith('test_'): ! test = getattr(_test, name) if test_support.verbose: print "internal", name try: test() ! except _test.error: raise test_support.TestFailed, sys.exc_info()[1] --- 1,16 ---- ! # Run the _testcapi module tests (tests for the Python/C API): by defn, ! # these are all functions _test exports whose name begins with 'test_'. import sys import test_support ! import _testcapi ! for name in dir(_testcapi): if name.startswith('test_'): ! test = getattr(_testcapi, name) if test_support.verbose: print "internal", name try: test() ! except _testcapi.error: raise test_support.TestFailed, sys.exc_info()[1] From tim_one@users.sourceforge.net Sun Feb 4 03:09:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 03 Feb 2001 19:09:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.120,1.121 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv19049/python/dist/src/Misc Modified Files: NEWS Log Message: Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -r1.120 -r1.121 *** NEWS 2001/02/03 15:06:40 1.120 --- NEWS 2001/02/04 03:09:52 1.121 *************** *** 1,2 **** --- 1,13 ---- + What's New in Python 2.1 alpha 507? + =================================== + + Core language, builtins, and interpreter + + Standard library + + Windows changes + + - Build: Subproject _test (effectively) renamed to _testcapi. + What's New in Python 2.1 alpha 2? ================================= From tim_one@users.sourceforge.net Sun Feb 4 03:09:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 03 Feb 2001 19:09:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _testcapimodule.c,NONE,1.1 _testmodule.c,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19049/python/dist/src/Modules Added Files: _testcapimodule.c Removed Files: _testmodule.c Log Message: Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! --- NEW FILE: _testcapimodule.c --- /* * C Extension module to test Python interpreter C APIs. * * The 'test_*' functions exported by this module are run as part of the * standard Python regression test, via Lib/test/test_capi.py. */ #include "Python.h" static PyObject *TestError; /* set to exception object in init */ /* Test #defines from config.h (particularly the SIZEOF_* defines). The ones derived from autoconf on the UNIX-like OSes can be relied upon (in the absence of sloppy cross-compiling), but the Windows platforms have these hardcoded. Better safe than sorry. */ static PyObject* sizeof_error(const char* fatname, const char* typename, int expected, int got) { char buf[1024]; sprintf(buf, "%s #define == %d but sizeof(%s) == %d", fatname, expected, typename, got); PyErr_SetString(TestError, buf); return (PyObject*)NULL; } static PyObject* test_config(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":test_config")) return NULL; #define CHECK_SIZEOF(FATNAME, TYPE) \ if (FATNAME != sizeof(TYPE)) \ return sizeof_error(#FATNAME, #TYPE, FATNAME, sizeof(TYPE)) CHECK_SIZEOF(SIZEOF_INT, int); CHECK_SIZEOF(SIZEOF_LONG, long); CHECK_SIZEOF(SIZEOF_VOID_P, void*); CHECK_SIZEOF(SIZEOF_TIME_T, time_t); #ifdef HAVE_LONG_LONG CHECK_SIZEOF(SIZEOF_LONG_LONG, LONG_LONG); #endif #undef CHECK_SIZEOF Py_INCREF(Py_None); return Py_None; } static PyMethodDef TestMethods[] = { {"test_config", test_config, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; DL_EXPORT(void) init_testcapi(void) { PyObject *m, *d; m = Py_InitModule("_testcapi", TestMethods); TestError = PyErr_NewException("_testcapi.error", NULL, NULL); d = PyModule_GetDict(m); PyDict_SetItemString(d, "error", TestError); } --- _testmodule.c DELETED --- From tim_one@users.sourceforge.net Sun Feb 4 03:09:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 03 Feb 2001 19:09:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild _testcapi.dsp,NONE,1.1 pcbuild.dsw,1.25,1.26 python20.wse,1.26,1.27 readme.txt,1.19,1.20 _test.dsp,1.1,NONE Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv19049/python/dist/src/PCbuild Modified Files: pcbuild.dsw python20.wse readme.txt Added Files: _testcapi.dsp Removed Files: _test.dsp Log Message: Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! --- NEW FILE: _testcapi.dsp --- # Microsoft Developer Studio Project File - Name="_testcapi" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=_testcapi - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "_testcapi.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "_testcapi.mak" CFG="_testcapi - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "_testcapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "_testcapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "_testcapi" # PROP Scc_LocalPath ".." CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "_testcapi - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-release\_testcapi" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_testcapi.pyd" /export:init_testcapi # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "_testcapi - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "." # PROP Intermediate_Dir "x86-temp-debug\_testcapi" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_testcapi_d.pyd" /pdbtype:sept /export:init_testcapi # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "_testcapi - Win32 Release" # Name "_testcapi - Win32 Debug" # Begin Source File SOURCE=..\Modules\_testcapimodule.c # End Source File # End Target # End Project Index: pcbuild.dsw =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.dsw,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** pcbuild.dsw 2001/02/02 21:24:51 1.25 --- pcbuild.dsw 2001/02/04 03:09:53 1.26 *************** *** 42,50 **** Package=<4> {{{ }}} ############################################################################### ! Project: "_test"=.\_test.dsp - Package Owner=<4> Package=<5> --- 42,53 ---- Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name pythoncore + End Project Dependency }}} ############################################################################### ! Project: "_testcapi"=.\_testcapi.dsp - Package Owner=<4> Package=<5> *************** *** 54,57 **** --- 57,63 ---- Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name pythoncore + End Project Dependency }}} Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** python20.wse 2001/02/02 21:24:51 1.26 --- python20.wse 2001/02/04 03:09:53 1.27 *************** *** 698,703 **** end item: Install File ! Source=%_SRC_%\PCbuild\_test.pyd ! Destination=%MAINDIR%\DLLs\_test.pyd Flags=0000000000000010 end --- 698,703 ---- end item: Install File ! Source=%_SRC_%\PCbuild\_testcapi.pyd ! Destination=%MAINDIR%\DLLs\_testcapi.pyd Flags=0000000000000010 end *************** *** 772,777 **** end item: Install File ! Source=%_SRC_%\PCbuild\_test.lib ! Destination=%MAINDIR%\libs\_test.lib Flags=0000000000000010 end --- 772,777 ---- end item: Install File ! Source=%_SRC_%\PCbuild\_testcapi.lib ! Destination=%MAINDIR%\libs\_testcapi.lib Flags=0000000000000010 end Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** readme.txt 2001/02/02 21:24:51 1.19 --- readme.txt 2001/02/04 03:09:53 1.20 *************** *** 46,52 **** _symtable the _symtable module, symtablemodule.c ! _test tests of the Python C API, run via Lib/test/test_capi.py, and ! implemented by module Modules/_testmodule.c mmap mmapmodule.c --- 46,52 ---- _symtable the _symtable module, symtablemodule.c ! _testcapi tests of the Python C API, run via Lib/test/test_capi.py, and ! implemented by module Modules/_testcapimodule.c mmap mmapmodule.c --- _test.dsp DELETED --- From ping@users.sourceforge.net Sun Feb 4 04:36:39 2001 From: ping@users.sourceforge.net (Ka-Ping Yee) Date: Sat, 03 Feb 2001 20:36:39 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0234.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30231 Added Files: pep-0234.txt Log Message: Initial draft of "Iterators" PEP. --- NEW FILE: pep-0234.txt --- PEP: 2xx Title: Iterators Version: $Revision: 1.1 $ Author: ping@lfw.org (Ka-Ping Yee) Status: Draft Type: Standards Track Python-Version: 2.1 Created: 30-Jan-2001 Post-History: Abstract This document proposes an iteration interface that objects can provide to control the behaviour of 'for' loops. Looping is customized by providing a method that produces an iterator object. The iterator should be a callable object that returns the next item in the sequence each time it is called, raising an exception when no more items are available. Copyright This document is in the public domain. Sequence Iterators A new field named 'sq_iter' for requesting an iterator is added to the PySequenceMethods table. Upon an attempt to iterate over an object with a loop such as for item in sequence: ...body... the interpreter looks for the 'sq_iter' of the 'sequence' object. If the method exists, it is called to get an iterator; it should return a callable object. If the method does not exist, the interpreter produces a built-in iterator object in the following manner (described in Python here, but implemented in the core): def make_iterator(sequence): def iterator(sequence=sequence, index=[0]): item = sequence[index[0]] index[0] += 1 return item return iterator To execute the above 'for' loop, the interpreter would proceed as follows, where 'iterator' is the iterator that was obtained: while 1: try: item = iterator() except IndexError: break ...body... (Note that the 'break' above doesn't translate to a "real" Python break, since it would go to the 'else:' clause of the loop whereas a "real" break in the body would skip the 'else:' clause.) The list() and tuple() built-in functions would be updated to use this same iterator logic to retrieve the items in their argument. List and tuple objects would implement the 'sq_iter' method by calling the built-in make_iterator() routine just described. Instance objects would implement the 'sq_iter' method as follows: if hasattr(self, '__iter__'): return self.__iter__() elif hasattr(self, '__getitem__'): return make_iterator(self) else: raise TypeError, thing.__class__.__name__ + \ ' instance does not support iteration' Extension objects can implement 'sq_iter' however they wish, as long as they return a callable object. Mapping Iterators An additional proposal from Guido is to provide special syntax for iterating over mappings. The loop: for key:value in mapping: would bind both 'key' and 'value' to a key-value pair from the mapping on each iteration. Tim Peters suggested that similarly, for key: in mapping: could iterate over just the keys and for :value in mapping: could iterate over just the values. The syntax is unambiguous since the new colon is currently not permitted in this position in the grammar. This behaviour would be provided by additional methods in the PyMappingMethods table: 'mp_iteritems', 'mp_iterkeys', and 'mp_itervalues' respectively. 'mp_iteritems' is expected to produce a callable object that returns a (key, value) tuple; 'mp_iterkeys' and 'mp_itervalues' are expected to produce a callable object that returns a single key or value. The implementations of these methods on instance objects would then check for and call the '__iteritems__', '__iterkeys__', and '__itervalues__' methods respectively. When 'mp_iteritems', 'mp_iterkeys', or 'mp_itervalues' is missing, the default behaviour is to do make_iterator(mapping.items()), make_iterator(mapping.keys()), or make_iterator(mapping.values()) respectively, using the definition of make_iterator() above. Indexing Sequences The special syntax described above can be applied to sequences as well, to provide the long-hoped-for ability to obtain the indices of a sequence without the strange-looking 'range(len(x))' expression. for index:item in sequence: causes 'index' to be bound to the index of each item as 'item' is bound to the items of the sequence in turn, and for index: in sequence: simply causes 'index' to start at 0 and increment until an attempt to get sequence[index] produces an IndexError. For completeness, for :item in sequence: is equivalent to for item in sequence: In each case we try to request an appropriate iterator from the sequence. In summary: for k:v in x looks for mp_iteritems, then sq_iter for k: in x looks for mp_iterkeys, then sq_iter for :v in x looks for mp_itervalues, then sq_iter for v in x looks for sq_iter If we fall back to sq_iter in the first two cases, we generate indices for k as needed, by starting at 0 and incrementing. The implementation of the mp_iter* methods on instance objects then checks for methods in the following order: mp_iteritems __iteritems__, __iter__, items, __getitem__ mp_iterkeys __iterkeys__, __iter__, keys, __getitem__ mp_itervalues __itervalues__, __iter__, values, __getitem__ sq_iter __iter__, __getitem__ If a __iteritems__, __iterkeys__, or __itervalues__ method is found, we just call it and use the resulting iterator. If a mp_* function finds no such method but finds __iter__ instead, we generate indices as needed. Upon finding an items(), keys(), or values() method, we use make_iterator(x.items()), make_iterator(x.keys()), or make_iterator(x.values()) respectively. Upon finding a __getitem__ method, we use it and generate indices as needed. For example, the complete implementation of the mp_iteritems method for instances can be roughly described as follows: def mp_iteritems(thing): if hasattr(thing, '__iteritems__'): return thing.__iteritems__() if hasattr(thing, '__iter__'): def iterator(sequence=thing, index=[0]): item = (index[0], sequence.__iter__()) index[0] += 1 return item return iterator if hasattr(thing, 'items'): return make_iterator(thing.items()) if hasattr(thing, '__getitem__'): def iterator(sequence=thing, index=[0]): item = (index[0], sequence[index[0]]) index[0] += 1 return item return iterator raise TypeError, thing.__class__.__name__ + \ ' instance does not support iteration over items' Examples Here is a class written in Python that represents the sequence of lines in a file. class FileLines: def __init__(self, filename): self.file = open(filename) def __iter__(self): def iter(self=self): line = self.file.readline() if line: return line else: raise IndexError return iter for line in FileLines('spam.txt'): print line And here's an interactive session demonstrating the proposed new looping syntax: >>> for i:item in ['a', 'b', 'c']: ... print i, item ... 0 a 1 b 2 c >>> for i: in 'abcdefg': # just the indices, please ... print i, ... print ... 0 1 2 3 4 5 6 >>> for k:v in os.environ: # os.environ is an instance, but ... print k, v # this still works because we fall ... # back to calling items() MAIL /var/spool/mail/ping HOME /home/ping DISPLAY :0.0 TERM xterm . . . Rationale If all the parts of the proposal are included, this addresses many concerns in a consistent and flexible fashion. Among its chief virtues are the following three -- no, four -- no, five -- points: 1. It provides an extensible iterator interface. 2. It resolves the endless "i indexing sequence" debate. 3. It allows performance enhancements to dictionary iteration. 4. It allows one to provide an interface for just iteration without pretending to provide random access to elements. 5. It is backward-compatible with all existing user-defined classes and extension objects that emulate sequences and mappings, even mappings that only implement a subset of {__getitem__, keys, values, items}. Errors Errors that occur during sq_iter, mp_iter*, or the __iter*__ methods are allowed to propagate normally to the surface. An attempt to do for item in dict: over a dictionary object still produces: TypeError: loop over non-sequence An attempt to iterate over an instance that provides neither __iter__ nor __getitem__ produces: TypeError: instance does not support iteration Similarly, an attempt to do mapping-iteration over an instance that doesn't provide the right methods should produce one of the following errors: TypeError: instance does not support iteration over items TypeError: instance does not support iteration over keys TypeError: instance does not support iteration over values It's an error for the iterator produced by __iteritems__ or mp_iteritems to return an object whose length is not 2: TypeError: item iterator did not return a 2-tuple Open Issues We could introduce a new exception type such as IteratorExit just for terminating loops rather than using IndexError. In this case, the implementation of make_iterator() would catch and translate an IndexError into an IteratorExit for backward compatibility. We could provide access to the logic that calls either 'sq_item' or make_iterator() with an iter() function in the built-in module (just as the getattr() function provides access to 'tp_getattr'). One possible motivation for this is to make it easier for the implementation of __iter__ to delegate iteration to some other sequence. Presumably we would then have to consider adding iteritems(), iterkeys(), and itervalues() as well. An alternative way to let __iter__ delegate iteration to another sequence is for it to return another sequence. Upon detecting that the object returned by __iter__ is not callable, the interpreter could repeat the process of looking for an iterator on the new object. However, this process seems potentially convoluted and likely to produce more confusing error messages. If we decide to add "freezing" ability to lists and dictionaries, it is suggested that the implementation of make_iterator automatically freeze any list or dictionary argument for the duration of the loop, and produce an error complaining about any attempt to modify it during iteration. Since it is relatively rare to actually want to modify it during iteration, this is likely to catch mistakes earlier. If a programmer wants to modify a list or dictionary during iteration, they should explicitly make a copy to iterate over using x[:], x.clone(), x.keys(), x.values(), or x.items(). For consistency with the 'key in dict' expression, we could support 'for key in dict' as equivalent to 'for key: in dict'. BDFL Pronouncements The "parallel expression" to 'for key:value in mapping': if key:value in mapping: is infeasible since the first colon ends the "if" condition. The following compromise is technically feasible: if (key:value) in mapping: but the BDFL has pronounced a solid -1 on this. The BDFL gave a +0.5 to: for key:value in mapping: for index:item in sequence: and a +0.2 to the variations where the part before or after the first colon is missing. Local Variables: mode: indented-text indent-tabs-mode: nil End: From tim_one@users.sourceforge.net Sun Feb 4 09:18:24 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 04 Feb 2001 01:18:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4110/python/dist/src/modules Modified Files: Setup.dist Log Message: Another _testXXX -> _testcapiXXX renaming. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** Setup.dist 2001/02/02 12:07:22 1.15 --- Setup.dist 2001/02/04 09:18:21 1.16 *************** *** 150,154 **** #_weakref _weakref.c # basic weak reference support #_codecs _codecsmodule.c # access to the builtin codecs and codec registry ! #_test _testmodule.c # Python C API test module #unicodedata unicodedata.c unicodedatabase.c --- 150,154 ---- #_weakref _weakref.c # basic weak reference support #_codecs _codecsmodule.c # access to the builtin codecs and codec registry ! #_testcapi _testcapimodule.c # Python C API test module #unicodedata unicodedata.c unicodedatabase.c From fdrake@users.sourceforge.net Sun Feb 4 15:20:28 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Sun, 04 Feb 2001 07:20:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools mkhowto,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv29037 Modified Files: mkhowto Log Message: Improve diagnostic output when an external command returns a non-zero exit code, showing the transcript for that command. This closes SF bug #129740. Index: mkhowto =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** mkhowto 2001/01/30 22:30:01 1.20 --- mkhowto 2001/02/04 15:20:26 1.21 *************** *** 443,446 **** --- 443,449 ---- "Session transcript and error messages are in %s." % self.log_filename) + sys.stderr.write("The relevant lines from the transcript are:\n") + sys.stderr.write("-" * 72 + "\n") + sys.stderr.writelines(get_run_transcript(self.log_filename)) sys.exit(rc) *************** *** 462,466 **** --- 465,485 ---- + def get_run_transcript(filename): + """Return lines from the transcript file for the most recent run() call.""" + fp = open(filename) + lines = fp.readlines() + fp.close() + lines.reverse() + L = [] + for line in lines: + L.append(line) + if line[:4] == "+++ ": + break + L.reverse() + return L + + def safe_unlink(path): + """Unlink a file without raising an error if it doesn't exist.""" try: os.unlink(path) From loewis@users.sourceforge.net Sun Feb 4 22:37:58 2001 From: loewis@users.sourceforge.net (Martin v. Löwis) Date: Sun, 04 Feb 2001 14:37:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.121,1.122 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv20564 Modified Files: NEWS Log Message: Fix binfmt_register documentation to always register the right magic. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -r1.121 -r1.122 *** NEWS 2001/02/04 03:09:52 1.121 --- NEWS 2001/02/04 22:37:56 1.122 *************** *** 260,264 **** if they do not have a .pyc or .pyo extension. On Linux, after executing ! echo ':pyc:M::\x87\xc6\x0d\x0a::/usr/local/bin/python:' > /proc/sys/fs/binfmt_misc/register any byte code file can be used as an executable (i.e. as an argument --- 260,267 ---- if they do not have a .pyc or .pyo extension. On Linux, after executing ! import imp,sys,string ! magic = string.join(["\\x%.2x" % ord(c) for c in imp.get_magic()],"") ! reg = ':pyc:M::%s::%s:' % (magic, sys.executable) ! open("/proc/sys/fs/binfmt_misc/register","wb").write(reg) any byte code file can be used as an executable (i.e. as an argument From gvanrossum@users.sourceforge.net Mon Feb 5 15:56:06 2001 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 05 Feb 2001 07:56:06 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0207.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv17999 Modified Files: pep-0207.txt Log Message: Fix typo in the alternate way to spell A Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv8934 Modified Files: ceval.c Log Message: SF patch 103596 by Nick Mathewson: rause UnboundLocalError for uninitialized free variables Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.227 retrieving revision 2.228 diff -C2 -r2.227 -r2.228 *** ceval.c 2001/02/01 22:48:12 2.227 --- ceval.c 2001/02/05 17:23:16 2.228 *************** *** 1647,1650 **** --- 1647,1666 ---- x = freevars[oparg]; w = PyCell_Get(x); + if (w == NULL) { + if (oparg < f->f_ncells) + v = PyTuple_GetItem(co->co_cellvars, + oparg); + else + v = PyTuple_GetItem( + co->co_freevars, + oparg - f->f_ncells); + + format_exc_check_arg( + PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + v); + err = -1; + break; + } Py_INCREF(w); PUSH(w); From jhylton@users.sourceforge.net Mon Feb 5 17:36:48 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Mon, 05 Feb 2001 09:36:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.77,1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv12889 Modified Files: ACKS Log Message: Fixed UnboundLocalError for nested scopes Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -r1.77 -r1.78 *** ACKS 2001/02/02 03:29:24 1.77 --- ACKS 2001/02/05 17:36:46 1.78 *************** *** 249,252 **** --- 249,253 ---- Anthony Martin Roger Masse + Nick Mathewson Graham Matthews Dieter Maurer From jhylton@users.sourceforge.net Mon Feb 5 17:35:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Mon, 05 Feb 2001 09:35:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_scope.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12540 Modified Files: test_scope.py Log Message: Fix test 9 (caught by ?!ng) Add tests for unbound locals (Nick Mathewson) Index: test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_scope.py 2001/01/30 01:26:53 1.2 --- test_scope.py 2001/02/05 17:35:20 1.3 *************** *** 155,159 **** return str(self) ! t = test() verify(t.test() == "var") verify(t.method_and_var() == "method") --- 155,159 ---- return str(self) ! t = Test() verify(t.test() == "var") verify(t.method_and_var() == "method") *************** *** 248,249 **** --- 248,278 ---- h = g(2, 4, 6) verify(h() == 18) + + print "13. UnboundLocal" + + def errorInOuter(): + print y + def inner(): + return y + y = 1 + + def errorInInner(): + def inner(): + return y + inner() + y = 1 + + try: + errorInOuter() + except UnboundLocalError: + pass + else: + raise TestFailed + + try: + errorInInner() + except UnboundLocalError: + pass + else: + raise TestFailed + From jhylton@users.sourceforge.net Mon Feb 5 17:35:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Mon, 05 Feb 2001 09:35:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_scope,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv12540/output Modified Files: test_scope Log Message: Fix test 9 (caught by ?!ng) Add tests for unbound locals (Nick Mathewson) Index: test_scope =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_scope,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_scope 2001/01/25 20:11:23 1.1 --- test_scope 2001/02/05 17:35:20 1.2 *************** *** 12,13 **** --- 12,14 ---- 11. unoptimized namespaces 12. lambdas + 13. UnboundLocal From akuchling@users.sourceforge.net Mon Feb 5 17:43:13 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 05 Feb 2001 09:43:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install_data.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv14383 Modified Files: install_data.py Log Message: Patch #103587: Fix typo that broke the install_data command; caught by Uche Ogbuji Index: install_data.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_data.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** install_data.py 2001/01/28 12:22:14 1.17 --- install_data.py 2001/02/05 17:43:11 1.18 *************** *** 65,69 **** self.mkpath(dir) for data in f[1]: ! data = convert_path(f[1]) (out, _) = self.copy_file(data, dir) self.outfiles.append(out) --- 65,69 ---- self.mkpath(dir) for data in f[1]: ! data = convert_path(data) (out, _) = self.copy_file(data, dir) self.outfiles.append(out) From gvanrossum@users.sourceforge.net Mon Feb 5 18:50:17 2001 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 05 Feb 2001 10:50:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom pulldom.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv26004 Modified Files: pulldom.py Log Message: Don't get fooled by an empty prefix with a valid namespaceURI -- in this case, the code used to generate invalid tags and attribute names with a leading colon, e.g. <:tag> or . Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** pulldom.py 2001/01/27 08:47:37 1.17 --- pulldom.py 2001/02/05 18:50:15 1.18 *************** *** 57,61 **** # *a* valid tagName from the current context. if tagName is None: ! tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: --- 57,65 ---- # *a* valid tagName from the current context. if tagName is None: ! prefix = self._current_context[uri] ! if prefix: ! tagName = prefix + ":" + localname ! else: ! tagName = localname node = self.document.createElementNS(uri, tagName) else: *************** *** 67,71 **** a_uri, a_localname = aname if a_uri: ! qname = self._current_context[a_uri] + ":" + a_localname attr = self.document.createAttributeNS(a_uri, qname) else: --- 71,79 ---- a_uri, a_localname = aname if a_uri: ! prefix = self._current_context[a_uri] ! if prefix: ! qname = prefix + ":" + a_localname ! else: ! qname = a_localname attr = self.document.createAttributeNS(a_uri, qname) else: From gvanrossum@users.sourceforge.net Mon Feb 5 19:17:52 2001 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 05 Feb 2001 11:17:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv29651 Modified Files: minidom.py Log Message: A couple of changes to make this more conformant. MvL and Uche agree. This will make it incompatible with the version found in Python 2.0. Does this need to be done to PyXML too? Changes that might break existing code are marked with (!) below. - Formatting nit: no spaces inside parentheses: foo( a ) -> foo(a). - Break long lines. - (!) Fix getAttribute() and getAttributeNS() to return "" instead of raising KeyError when the attribute is not found. - (!) Fix getAttributeNodeNS() to return None instead of raising KeyError. (Curiously, getAttributeNode() already did this.) - Added hasAttributes(), which returns true iff the node has any attributes. )This is DOM level 3.) - (!) In createDocument(), if the qualified name is not empty, actually create and insert the first element with that name (this will become doc.documentElement). MvL believes that it should be an error to specify an empty qualified name; I'm not going there today, since it would require making a matching change to pulldom. Maybe MvL will do this. - In Document.writexml(), insert an xml declaration at the top. (This doesn't include the encoding since there's no way to specify the encoding. If that's preferred, all writexml() methods should be fixed to support an optional encoding argument that they pass to each other -- and they should use it to encode all text they write, too. Later.) Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** minidom.py 2001/02/02 19:40:19 1.22 --- minidom.py 2001/02/05 19:17:50 1.23 *************** *** 2,8 **** minidom.py -- a lightweight DOM implementation. ! parse( "foo.xml" ) ! parseString( "" ) Todo: --- 2,8 ---- minidom.py -- a lightweight DOM implementation. ! parse("foo.xml") ! parseString("") Todo: *************** *** 48,52 **** if Node.debug is None: Node.debug = _get_StringIO() ! #open( "debug4.out", "w" ) Node.debug.write("create %s\n" % index) --- 48,52 ---- if Node.debug is None: Node.debug = _get_StringIO() ! #open("debug4.out", "w") Node.debug.write("create %s\n" % index) *************** *** 103,107 **** if newChild.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) --- 103,107 ---- if newChild.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(newChild), repr(self)) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 126,130 **** if node.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) --- 126,130 ---- if node.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(node), repr(self)) if node.parentNode is not None: node.parentNode.removeChild(node) *************** *** 144,148 **** if newChild.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) --- 144,148 ---- if newChild.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(newChild), repr(self)) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 436,443 **** def getAttribute(self, attname): ! return self._attrs[attname].value def getAttributeNS(self, namespaceURI, localName): ! return self._attrsNS[(namespaceURI, localName)].value def setAttribute(self, attname, value): --- 436,449 ---- def getAttribute(self, attname): ! try: ! return self._attrs[attname].value ! except KeyError: ! return "" def getAttributeNS(self, namespaceURI, localName): ! try: ! return self._attrsNS[(namespaceURI, localName)].value ! except KeyError: ! return "" def setAttribute(self, attname, value): *************** *** 458,462 **** def getAttributeNodeNS(self, namespaceURI, localName): ! return self._attrsNS[(namespaceURI, localName)] def setAttributeNode(self, attr): --- 464,468 ---- def getAttributeNodeNS(self, namespaceURI, localName): ! return self._attrsNS.get((namespaceURI, localName)) def setAttributeNode(self, attr): *************** *** 529,532 **** --- 535,544 ---- return AttributeList(self._attrs, self._attrsNS) + def hasAttributes(self): + if self._attrs or self._attrsNS: + return 1 + else: + return 0 + class Comment(Node): nodeType = Node.COMMENT_NODE *************** *** 625,629 **** def createDocument(self, namespaceURI, qualifiedName, doctype): if doctype and doctype.parentNode is not None: ! raise xml.dom.WrongDocumentErr("doctype object owned by another DOM tree") doc = Document() if doctype is None: --- 637,642 ---- def createDocument(self, namespaceURI, qualifiedName, doctype): if doctype and doctype.parentNode is not None: ! raise xml.dom.WrongDocumentErr( ! "doctype object owned by another DOM tree") doc = Document() if doctype is None: *************** *** 635,639 **** raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") if prefix and not namespaceURI: ! raise xml.dom.NamespaceErr("illegal use of prefix without namespaces") doctype.parentNode = doc doc.doctype = doctype --- 648,656 ---- raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") if prefix and not namespaceURI: ! raise xml.dom.NamespaceErr( ! "illegal use of prefix without namespaces") ! element = doc.createElementNS(namespaceURI, qualifiedName) ! doc.appendChild(element) ! # XXX else, raise an error? Empty qname is illegal in the DOM spec! doctype.parentNode = doc doc.doctype = doctype *************** *** 663,667 **** if node.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) --- 680,684 ---- if node.nodeType not in self.childNodeTypes: raise HierarchyRequestErr, \ ! "%s cannot be child of %s" % (repr(node), repr(self)) if node.parentNode is not None: node.parentNode.removeChild(node) *************** *** 669,673 **** if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): ! raise xml.dom.HierarchyRequestErr("two document elements disallowed") return Node.appendChild(self, node) --- 686,691 ---- if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): ! raise xml.dom.HierarchyRequestErr( ! "two document elements disallowed") return Node.appendChild(self, node) *************** *** 721,724 **** --- 739,743 ---- def writexml(self, writer): + writer.write('\n') for node in self.childNodes: node.writexml(writer) From montanaro@users.sourceforge.net Tue Feb 6 01:07:04 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 05 Feb 2001 17:07:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.40,1.41 ntpath.py,1.33,1.34 nturl2path.py,1.7,1.8 nntplib.py,1.24,1.25 netrc.py,1.9,1.10 mutex.py,1.7,1.8 multifile.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11461 Modified Files: os.py ntpath.py nturl2path.py nntplib.py netrc.py mutex.py multifile.py Log Message: added several more __all__ lists Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** os.py 2001/01/15 00:50:52 1.40 --- os.py 2001/02/06 01:07:01 1.41 *************** *** 20,23 **** --- 20,25 ---- """ + #' + import sys *************** *** 26,29 **** --- 28,39 ---- altsep = None + __all__ = [] + + def _get_exports_list(module): + try: + return list(module.__all__) + except AttributeError: + return [n for n in dir(module) if n[0] != '_'] + if 'posix' in _names: name = 'posix' *************** *** 39,42 **** --- 49,57 ---- path = posixpath del posixpath + + import posix + __all__.extend(_get_exports_list(posix)) + del posix + elif 'nt' in _names: name = 'nt' *************** *** 53,56 **** --- 68,76 ---- path = ntpath del ntpath + + import nt + __all__.extend(_get_exports_list(nt)) + del nt + elif 'dos' in _names: name = 'dos' *************** *** 66,69 **** --- 86,94 ---- path = dospath del dospath + + import dos + __all__.extend(_get_exports_list(dos)) + del dos + elif 'os2' in _names: name = 'os2' *************** *** 79,82 **** --- 104,112 ---- path = ntpath del ntpath + + import os2 + __all__.extend(_get_exports_list(os2)) + del os2 + elif 'mac' in _names: name = 'mac' *************** *** 92,95 **** --- 122,130 ---- path = macpath del macpath + + import mac + __all__.extend(_get_exports_list(mac)) + del mac + elif 'ce' in _names: name = 'ce' *************** *** 107,117 **** --- 142,161 ---- path = ntpath del ntpath + + import ce + __all__.extend(_get_exports_list(ce)) + del ce + else: raise ImportError, 'no os specific module found' + __all__.append("path") + del _names sys.modules['os.path'] = path + #' + # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) *************** *** 181,184 **** --- 225,230 ---- pass + __all__.extend(["makedirs", "removedirs", "renames"]) + # Make sure os.environ exists, at least try: *************** *** 235,238 **** --- 281,286 ---- _execvpe(file, args, env) + __all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"]) + _notfound = None def _execvpe(file, args, env=None): *************** *** 320,323 **** --- 368,372 ---- The optional second argument can specify an alternate default.""" return environ.get(key, default) + __all__.append("getenv") def _exists(name): *************** *** 455,458 **** --- 504,511 ---- + __all__.extend(["spawnlp","spawnlpe","spawnv", "spawnve","spawnvp", + "spawnvpe","spawnl","spawnle",]) + + # Supply popen2 etc. (for Unix) if _exists("fork"): *************** *** 462,465 **** --- 515,519 ---- stdout, stdin = popen2.popen2(cmd, bufsize) return stdin, stdout + __all__.append("popen2") if not _exists("popen3"): *************** *** 468,471 **** --- 522,526 ---- stdout, stdin, stderr = popen2.popen3(cmd, bufsize) return stdin, stdout, stderr + __all__.append("popen3") if not _exists("popen4"): *************** *** 474,475 **** --- 529,531 ---- stdout, stdin = popen2.popen4(cmd, bufsize) return stdin, stdout + __all__.append("popen4") Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** ntpath.py 2001/01/15 00:50:52 1.33 --- ntpath.py 2001/02/06 01:07:01 1.34 *************** *** 9,12 **** --- 9,16 ---- import stat + __all__ = ["normcase","isabs","join","splitdrive","split","splitext", + "basename","dirname","commonprefix","getsize","getmtime", + "getatime","islink","exists","isdir","isfile","ismount", + "walk","expanduser","expandvars","normpath","abspath","splitunc"] # Normalize the case of a pathname and map slashes to backslashes. Index: nturl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nturl2path.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** nturl2path.py 2001/01/15 00:50:52 1.7 --- nturl2path.py 2001/02/06 01:07:01 1.8 *************** *** 1,4 **** --- 1,6 ---- """Convert a NT pathname to a file URL and vice versa.""" + __all__ = ["url2pathname"] + def url2pathname(url): r"""Convert a URL to a DOS path. Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** nntplib.py 2001/01/16 07:12:46 1.24 --- nntplib.py 2001/02/06 01:07:01 1.25 *************** *** 34,38 **** import string ! # Exceptions raised when an error or invalid response is received --- 34,41 ---- import string ! __all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError", ! "NNTPPermanentError","NNTPProtocolError","NNTPDataError", ! "error_reply","error_temp","error_perm","error_proto", ! "error_data",] # Exceptions raised when an error or invalid response is received Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** netrc.py 2001/01/15 00:50:52 1.9 --- netrc.py 2001/02/06 01:07:01 1.10 *************** *** 5,8 **** --- 5,10 ---- import os, shlex + __all__ = ["netrc"] + class netrc: def __init__(self, file=None): Index: mutex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mutex.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mutex.py 2001/01/14 23:47:14 1.7 --- mutex.py 2001/02/06 01:07:01 1.8 *************** *** 13,16 **** --- 13,18 ---- """ + __all__ = ["mutex"] + class mutex: def __init__(self): Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** multifile.py 2001/01/14 23:47:14 1.14 --- multifile.py 2001/02/06 01:07:01 1.15 *************** *** 31,34 **** --- 31,36 ---- import string + __all__ = ["MultiFile","Error"] + class Error(Exception): pass From montanaro@users.sourceforge.net Tue Feb 6 01:07:04 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 05 Feb 2001 17:07:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11461/test Modified Files: test___all__.py Log Message: added several more __all__ lists Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test___all__.py 2001/01/25 15:29:22 1.8 --- test___all__.py 2001/02/06 01:07:02 1.9 *************** *** 88,90 **** --- 88,97 ---- check_all("mimetypes") check_all("mimify") + check_all("multifile") + check_all("mutex") + check_all("netrc") + check_all("nntplib") + check_all("ntpath") + check_all("nturl2path") + check_all("os") check_all("robotparser") From loewis@users.sourceforge.net Tue Feb 6 01:16:50 2001 From: loewis@users.sourceforge.net (Martin v. Löwis) Date: Mon, 05 Feb 2001 17:16:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_minidom.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12295 Modified Files: test_minidom.py Log Message: Add xml declaration into toxml testcase. Index: test_minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** test_minidom.py 2001/02/01 18:11:29 1.23 --- test_minidom.py 2001/02/06 01:16:48 1.24 *************** *** 273,277 **** def testWriteXML(): ! str = '' dom = parseString(str) domstr = dom.toxml() --- 273,277 ---- def testWriteXML(): ! str = '\n' dom = parseString(str) domstr = dom.toxml() From loewis@users.sourceforge.net Tue Feb 6 01:16:08 2001 From: loewis@users.sourceforge.net (Martin v. Löwis) Date: Mon, 05 Feb 2001 17:16:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.24,1.25 pulldom.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv11973 Modified Files: minidom.py pulldom.py Log Message: Do not allow empty qualifiedName in createDocument. Rearrange pulldom to create documents with root element. Provide clear methods so that the ContentHandler releases its hold on the document. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** minidom.py 2001/02/06 00:14:08 1.24 --- minidom.py 2001/02/06 01:16:06 1.25 *************** *** 652,666 **** if doctype is None: doctype = self.createDocumentType(qualifiedName, None, None) ! if qualifiedName: ! prefix, localname = _nssplit(qualifiedName) ! if prefix == "xml" \ ! and namespaceURI != "http://www.w3.org/XML/1998/namespace": ! raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") ! if prefix and not namespaceURI: ! raise xml.dom.NamespaceErr( ! "illegal use of prefix without namespaces") ! element = doc.createElementNS(namespaceURI, qualifiedName) ! doc.appendChild(element) ! # XXX else, raise an error? Empty qname is illegal in the DOM spec! doctype.parentNode = doc doc.doctype = doctype --- 652,672 ---- if doctype is None: doctype = self.createDocumentType(qualifiedName, None, None) ! if not qualifiedName: ! # The spec is unclear what to raise here; SyntaxErr ! # would be the other obvious candidate. Since Xerces raises ! # InvalidCharacterErr, and since SyntaxErr is not listed ! # for createDocument, that seems to be the better choice. ! # XXX: need to check for illegal characters here and in ! # createElement. ! raise xml.dom.InvalidCharacterErr("Element with no name") ! prefix, localname = _nssplit(qualifiedName) ! if prefix == "xml" \ ! and namespaceURI != "http://www.w3.org/XML/1998/namespace": ! raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") ! if prefix and not namespaceURI: ! raise xml.dom.NamespaceErr( ! "illegal use of prefix without namespaces") ! element = doc.createElementNS(namespaceURI, qualifiedName) ! doc.appendChild(element) doctype.parentNode = doc doc.doctype = doctype *************** *** 762,765 **** --- 768,772 ---- toktype, rootNode = events.getEvent() events.expandNode(rootNode) + events.clear() return rootNode Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** pulldom.py 2001/02/05 18:50:15 1.18 --- pulldom.py 2001/02/06 01:16:06 1.19 *************** *** 62,70 **** else: tagName = localname ! node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname ! node = self.document.createElement(localname) for aname,value in attrs.items(): --- 62,76 ---- else: tagName = localname ! if self.document: ! node = self.document.createElementNS(uri, tagName) ! else: ! node = self.buildDocument(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname ! if self.document: ! node = self.document.createElement(localname) ! else: ! node = self.buildDocument(None, localname) for aname,value in attrs.items(): *************** *** 91,95 **** def startElement(self, name, attrs): ! node = self.document.createElement(name) for aname,value in attrs.items(): --- 97,104 ---- def startElement(self, name, attrs): ! if self.document: ! node = self.document.createElement(name) ! else: ! node = self.buildDocument(None, name) for aname,value in attrs.items(): *************** *** 128,143 **** def startDocument(self): - publicId = systemId = None - if self._locator: - publicId = self._locator.getPublicId() - systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation ! node = self.documentFactory.createDocument(None, publicId, systemId) self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] self.push(node) def endDocument(self): --- 137,153 ---- def startDocument(self): if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation ! ! def buildDocument(self, uri, tagname): ! # Can't do that in startDocument, since we need the tagname ! # XXX: obtain DocumentType ! node = self.documentFactory.createDocument(uri, tagname, None) self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] self.push(node) + return node.firstChild def endDocument(self): *************** *** 145,148 **** --- 155,162 ---- self.pop() + def clear(self): + "clear(): Explicitly release parsing structures" + self.document = None + class ErrorHandler: def warning(self, exception): *************** *** 199,202 **** --- 213,223 ---- self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1] return rc + + def clear(self): + "clear(): Explicitly release parsing objects" + self.pulldom.clear() + del self.pulldom + self.parser = None + self.stream = None class SAX2DOM(PullDOM): From loewis@users.sourceforge.net Tue Feb 6 09:34:42 2001 From: loewis@users.sourceforge.net (Martin v. Löwis) Date: Tue, 06 Feb 2001 01:34:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.16,1.17 pyexpat.c,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv27393 Modified Files: Setup.dist pyexpat.c Log Message: Support older PYTHON_API_VERSIONs for backwards compatibility. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** Setup.dist 2001/02/04 09:18:21 1.16 --- Setup.dist 2001/02/06 09:34:40 1.17 *************** *** 152,158 **** #_testcapi _testcapimodule.c # Python C API test module ! #unicodedata unicodedata.c unicodedatabase.c ! # static Unicode character database ! #ucnhash ucnhash.c # Unicode Character Name expansion hash table #_locale _localemodule.c # access to ISO C locale support --- 152,156 ---- #_testcapi _testcapimodule.c # Python C API test module ! #unicodedata unicodedata.c # static Unicode character database #_locale _localemodule.c # access to ISO C locale support Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -r2.37 -r2.38 *** pyexpat.c 2001/01/25 21:48:14 2.37 --- pyexpat.c 2001/02/06 09:34:40 2.38 *************** *** 258,263 **** --- 258,265 ---- nulltuple, /* names */ nulltuple, /* varnames */ + #if PYTHON_API_VERSION >= 1010 nulltuple, /* freevars */ nulltuple, /* cellvars */ + #endif filename, /* filename */ name, /* name */ *************** *** 291,296 **** c, /*code*/ tstate->frame->f_globals, /*globals*/ ! NULL, /*locals*/ ! NULL); /* closure */ if (f == NULL) return NULL; --- 293,301 ---- c, /*code*/ tstate->frame->f_globals, /*globals*/ ! NULL /*locals*/ ! #if PYTHON_API_VERSION >= 1010 ! ,NULL /*closure*/ ! #endif ! ); if (f == NULL) return NULL; From nascheme@users.sourceforge.net Tue Feb 6 14:50:30 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Tue, 06 Feb 2001 06:50:30 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv9885 Modified Files: Makefile.pre.in Log Message: Install shared modules enabled by Setup* in $(DESTSHARED) not $(DESTSHARED)/Modules. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** Makefile.pre.in 2001/02/03 17:16:29 1.13 --- Makefile.pre.in 2001/02/06 14:50:27 1.14 *************** *** 495,501 **** oldsharedinstall: $(DESTSHARED) $(SHAREDMODS) @for i in X $(SHAREDMODS); do \ ! if test $$i != X; \ ! then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \ ! fi; \ done --- 495,502 ---- oldsharedinstall: $(DESTSHARED) $(SHAREDMODS) @for i in X $(SHAREDMODS); do \ ! if test $$i != X; then \ ! echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \ ! $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \ ! fi; \ done From akuchling@users.sourceforge.net Tue Feb 6 22:15:30 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 06 Feb 2001 14:15:30 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv15856 Modified Files: setup.py Log Message: Patch #103578 ] _tkinter build fix for he current Debian unstable tcl/tk 8.3 packages Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** setup.py 2001/02/04 03:09:52 1.24 --- setup.py 2001/02/06 22:15:27 1.25 *************** *** 496,507 **** # Check for the include files on Debian, where # they're put in /usr/include/{tcl,tk}X.Y ! debian_tcl_include = ( '/usr/include/tcl' + version ) ! debian_tk_include = ( '/usr/include/tk' + version ) ! tcl_includes = find_file('tcl.h', inc_dirs, ! [debian_tcl_include] ! ) ! tk_includes = find_file('tk.h', inc_dirs, ! [debian_tk_include] ! ) if (tcllib is None or tklib is None and --- 496,503 ---- # Check for the include files on Debian, where # they're put in /usr/include/{tcl,tk}X.Y ! debian_tcl_include = [ '/usr/include/tcl' + version ] ! debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include ! tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) ! tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) if (tcllib is None or tklib is None and From akuchling@users.sourceforge.net Tue Feb 6 22:26:32 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 06 Feb 2001 14:26:32 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv18091 Modified Files: setup.py Log Message: Part of patch #103544: fix detection of BSDDB on BSD systems Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** setup.py 2001/02/06 22:15:27 1.25 --- setup.py 2001/02/06 22:26:30 1.26 *************** *** 324,332 **** # BSD DB 3.x.) - # Note: If a db.h file is found by configure, bsddb will be enabled - # automatically via Setup.config.in. It only needs to be enabled here - # if it is not automatically enabled there; check the generated - # Setup.config before enabling it here. - db_incs = find_file('db_185.h', inc_dirs, []) if (db_incs is not None and --- 324,327 ---- *************** *** 335,338 **** --- 330,338 ---- include_dirs = db_incs, libraries = ['db'] ) ) + else: + db_incs = find_file('db.h', inc_dirs, []) + if db_incs is not None: + exts.append( Extension('bsddb', ['bsddbmodule.c'], + include_dirs = db_incs) ) # The mpz module interfaces to the GNU Multiple Precision library. *************** *** 348,352 **** # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z - # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: if (self.compiler.find_library_file(lib_dirs, 'gmp')): exts.append( Extension('mpz', ['mpzmodule.c'], --- 348,351 ---- From akuchling@users.sourceforge.net Tue Feb 6 22:33:47 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 06 Feb 2001 14:33:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.34,2.35 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19293 Modified Files: mpzmodule.c Log Message: Patch #103523, to make mpz module compile with Cygwin Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** mpzmodule.c 2000/10/11 21:53:34 2.34 --- mpzmodule.c 2001/02/06 22:33:45 2.35 *************** *** 1585,1589 **** static PyTypeObject MPZtype = { ! PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "mpz", /*tp_name*/ --- 1585,1589 ---- static PyTypeObject MPZtype = { ! PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "mpz", /*tp_name*/ *************** *** 1717,1720 **** --- 1717,1721 ---- mp_set_memory_functions( mp_allocate, mp_reallocate, mp_free ); + MPZtype.ob_type = &PyType_Type; module = Py_InitModule("mpz", mpz_functions); From akuchling@users.sourceforge.net Tue Feb 6 22:58:07 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 06 Feb 2001 14:58:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.135,1.136 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21837 Modified Files: socketmodule.c Log Message: Patch #103636: Allow writing strings containing null bytes to an SSL socket Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.135 retrieving revision 1.136 diff -C2 -r1.135 -r1.136 *** socketmodule.c 2001/02/02 19:55:17 1.135 --- socketmodule.c 2001/02/06 22:58:05 1.136 *************** *** 2219,2223 **** size_t len = 0; ! if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) return NULL; --- 2219,2223 ---- size_t len = 0; ! if (!PyArg_ParseTuple(args, "s#|i:write", &data, &len)) return NULL; From akuchlin@mems-exchange.org Tue Feb 6 23:07:23 2001 From: akuchlin@mems-exchange.org (Andrew Kuchling) Date: Tue, 6 Feb 2001 18:07:23 -0500 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.135,1.136 In-Reply-To: ; from akuchling@users.sourceforge.net on Tue, Feb 06, 2001 at 02:58:07PM -0800 References: Message-ID: <20010206180723.B1269@thrak.cnri.reston.va.us> On Tue, Feb 06, 2001 at 02:58:07PM -0800, A.M. Kuchling wrote: >! if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) >! if (!PyArg_ParseTuple(args, "s#|i:write", &data, &len)) Hm... actually, this patch isn't correct after all. The |i meant you could specify an optional integer to write out only a partial chunk of the string; why not just slice it? Since the SSL code isn't documented, I'm tempted to just rip out the |i. --amk From akuchling@users.sourceforge.net Tue Feb 6 23:37:25 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 06 Feb 2001 15:37:25 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv27115 Modified Files: setup.py Log Message: BeOS doesn't have a libm.a, either; noted by Donn Cave Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** setup.py 2001/02/06 22:26:30 1.26 --- setup.py 2001/02/06 23:37:23 1.27 *************** *** 119,122 **** --- 119,124 ---- if platform[:6] =='cygwin': platform = 'cygwin' + elif platform[:4] =='beos': + platform = 'beos' return platform *************** *** 140,144 **** # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] ! if platform == 'Darwin1.2': math_libs = [] --- 142,146 ---- # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] ! if platform in ['Darwin1.2', 'beos']: math_libs = [] From guido@digicool.com Wed Feb 7 08:41:47 2001 From: guido@digicool.com (Guido van Rossum) Date: Wed, 07 Feb 2001 03:41:47 -0500 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.135,1.136 In-Reply-To: Your message of "Tue, 06 Feb 2001 18:07:23 EST." <20010206180723.B1269@thrak.cnri.reston.va.us> References: <20010206180723.B1269@thrak.cnri.reston.va.us> Message-ID: <200102070841.DAA08929@cj20424-a.reston1.va.home.com> > On Tue, Feb 06, 2001 at 02:58:07PM -0800, A.M. Kuchling wrote: > >! if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) > >! if (!PyArg_ParseTuple(args, "s#|i:write", &data, &len)) > > Hm... actually, this patch isn't correct after all. The |i meant you > could specify an optional integer to write out only a partial chunk of > the string; why not just slice it? Since the SSL code isn't > documented, I'm tempted to just rip out the |i. Yes, rip it out. The old API was poorly designed, and let you do bad things (e.g. pass a length much larger than len(s)). --Guido van Rossum (home page: http://www.python.org/~guido/) From akuchling@users.sourceforge.net Wed Feb 7 20:41:19 2001 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Wed, 07 Feb 2001 12:41:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.136,1.137 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1055 Modified Files: socketmodule.c Log Message: Remove the optional integer argument to SSL_write; now it will always send the entire string passed to it Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.136 retrieving revision 1.137 diff -C2 -r1.136 -r1.137 *** socketmodule.c 2001/02/06 22:58:05 1.136 --- socketmodule.c 2001/02/07 20:41:17 1.137 *************** *** 2217,2227 **** { char *data; ! size_t len = 0; ! if (!PyArg_ParseTuple(args, "s#|i:write", &data, &len)) return NULL; - - if (!len) - len = strlen(data); len = SSL_write(self->ssl, data, len); --- 2217,2224 ---- { char *data; ! size_t len; ! if (!PyArg_ParseTuple(args, "s#:write", &data, &len)) return NULL; len = SSL_write(self->ssl, data, len); From montanaro@users.sourceforge.net Wed Feb 7 22:46:57 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Wed, 07 Feb 2001 14:46:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17249 Modified Files: test___all__.py Log Message: test for presence of __builtins__ in names before deleting it, enabling this to work with Jython (ugh! I hate that name!). This closes patch 103665. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test___all__.py 2001/02/06 01:07:02 1.9 --- test___all__.py 2001/02/07 22:46:55 1.10 *************** *** 14,18 **** names = {} exec "from %s import *" % modname in names ! del names["__builtins__"] keys = names.keys() keys.sort() --- 14,19 ---- names = {} exec "from %s import *" % modname in names ! if names.has_key("__builtins__"): ! del names["__builtins__"] keys = names.keys() keys.sort() From montanaro@users.sourceforge.net Wed Feb 7 23:14:32 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Wed, 07 Feb 2001 15:14:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pdb.py,1.48,1.49 pickle.py,1.43,1.44 pipes.py,1.7,1.8 popen2.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20655/Lib Modified Files: pdb.py pickle.py pipes.py popen2.py Log Message: a few more __all__ lists Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** pdb.py 2001/01/20 17:57:37 1.48 --- pdb.py 2001/02/07 23:14:30 1.49 *************** *** 14,17 **** --- 14,20 ---- import re + __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", + "post_mortem", "help"] + def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % funcname) Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** pickle.py 2001/01/22 14:53:29 1.43 --- pickle.py 2001/02/07 23:14:30 1.44 *************** *** 32,35 **** --- 32,38 ---- import struct + __all__ = ["PickleError", "PicklingError", "UnpicklingError", "Pickler", + "Unpickler", "dump", "dumps", "load", "loads"] + format_version = "1.3" # File format version we write compatible_formats = ["1.0", "1.1", "1.2"] # Old format versions we can read Index: pipes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pipes.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pipes.py 2001/01/15 00:50:52 1.7 --- pipes.py 2001/02/07 23:14:30 1.8 *************** *** 57,61 **** For an example, see the function test() at the end of the file. ! """ --- 57,61 ---- For an example, see the function test() at the end of the file. ! """ # ' *************** *** 67,70 **** --- 67,71 ---- import string + __all__ = ["Template"] # Conversion step kinds Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** popen2.py 2000/10/03 23:07:13 1.17 --- popen2.py 2001/02/07 23:14:30 1.18 *************** *** 10,13 **** --- 10,15 ---- import sys + __all__ = ["popen2", "popen3", "popen4"] + MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) *************** *** 155,160 **** inst = Popen4(cmd, bufsize) return inst.fromchild, inst.tochild - def _test(): cmd = "cat" --- 157,163 ---- inst = Popen4(cmd, bufsize) return inst.fromchild, inst.tochild + __all__.extend(["Popen3", "Popen4"]) + def _test(): cmd = "cat" From montanaro@users.sourceforge.net Wed Feb 7 23:14:32 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Wed, 07 Feb 2001 15:14:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20655/Lib/test Modified Files: test___all__.py Log Message: a few more __all__ lists Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** test___all__.py 2001/02/07 22:46:55 1.10 --- test___all__.py 2001/02/07 23:14:30 1.11 *************** *** 96,98 **** --- 96,102 ---- check_all("nturl2path") check_all("os") + check_all("pdb") + check_all("pickle") + check_all("pipes") + check_all("popen2") check_all("robotparser") From fdrake@users.sourceforge.net Thu Feb 8 15:39:10 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 08 Feb 2001 07:39:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.38,2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv7958 Modified Files: pyexpat.c Log Message: set_error(): Handle construction of pyexpat.error exceptions. They now carry a 'code' attribute that gives the Expat error number. Added support for additional handlers for Expat 1.95.*, including XmlDeclHandler, EntityDeclHandler, ElementDeclHandler, and AttlistDeclHandler. Associated constants are in the 'model' sub-object. Added two new attributes to the parser object: ordered_attributes and specified_attributes. These are used to control how attributes are reported and which attributes are reported. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** pyexpat.c 2001/02/06 09:34:40 2.38 --- pyexpat.c 2001/02/08 15:39:08 2.39 *************** *** 4,19 **** #ifdef HAVE_EXPAT_H #include "expat.h" - #else - #include "xmlparse.h" - #endif - #ifdef XML_MAJOR_VERSION ! #define EXPAT_VERSION (0x10000*XML_MAJOR_VERSION+0x100*XML_MINOR_VERSION+XML_MICRO_VERSION) #else ! #ifndef EXPAT_VERSION [...1073 lines suppressed...] --- 1724,1742 ---- (xmlhandlersetter)XML_SetInternalParsedEntityDeclHandler, (xmlhandler)my_InternalParsedEntityDeclHandler}, ! #endif ! #if EXPAT_VERSION >= 0x015f00 ! {"EntityDeclHandler", ! (xmlhandlersetter)XML_SetEntityDeclHandler, ! (xmlhandler)my_EntityDeclHandler}, ! {"XmlDeclHandler", ! (xmlhandlersetter)XML_SetXmlDeclHandler, ! (xmlhandler)my_XmlDeclHandler}, ! {"ElementDeclHandler", ! (xmlhandlersetter)XML_SetElementDeclHandler, ! (xmlhandler)my_ElementDeclHandler}, ! {"AttlistDeclHandler", ! (xmlhandlersetter)XML_SetAttlistDeclHandler, ! (xmlhandler)my_AttlistDeclHandler}, ! #endif /* Expat version 1.95 or better */ {NULL, NULL, NULL} /* sentinel */ From fdrake@users.sourceforge.net Thu Feb 8 15:40:35 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 08 Feb 2001 07:40:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpyexpat.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8226 Modified Files: libpyexpat.tex Log Message: Update documentation for pyexpat (xml.parsers.expat), to reflect the new support for Expat 1.95.*. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** libpyexpat.tex 2001/01/24 17:19:07 1.12 --- libpyexpat.tex 2001/02/08 15:40:33 1.13 *************** *** 2,5 **** --- 2,14 ---- Fast XML parsing using Expat} + % Markup notes: + % + % Many of the attributes of the XMLParser objects are callbacks. + % Since signature information must be presented, these are described + % using the methoddesc environment. Since they are attributes which + % are set by client code, in-text references to these attributes + % should be marked using the \member macro and should not include the + % parentheses used when marking functions and methods. + \declaremodule{standard}{xml.parsers.expat} \modulesynopsis{An interface to the Expat non-validating XML parser.} *************** *** 46,50 **** used by the XML data. Expat doesn't support as many encodings as Python does, and its repertoire of encodings can't be extended; it ! supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. Expat can optionally do XML namespace processing for you, enabled by --- 55,61 ---- used by the XML data. Expat doesn't support as many encodings as Python does, and its repertoire of encodings can't be extended; it ! supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. If ! \var{encoding} is given it will override the implicit or explicit ! encoding of the document. Expat can optionally do XML namespace processing for you, enabled by *************** *** 55,63 **** and attribute names that belong to a namespace will be expanded. The element name passed to the element handlers ! \function{StartElementHandler()} and \function{EndElementHandler()} will be the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is a zero byte (\code{chr(0)}) then the namespace URI and ! the local part will be concatenated without any separator. For example, if \var{namespace_separator} is set to a space character --- 66,74 ---- and attribute names that belong to a namespace will be expanded. The element name passed to the element handlers ! \member{StartElementHandler} and \member{EndElementHandler} will be the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is a zero byte (\code{chr(0)}) then the namespace URI and ! the local part will be concatenated without any separator. For example, if \var{namespace_separator} is set to a space character *************** *** 73,77 **** \end{verbatim} ! \function{StartElementHandler()} will receive the following strings for each element: --- 84,88 ---- \end{verbatim} ! \member{StartElementHandler} will receive the following strings for each element: *************** *** 102,110 **** \begin{methoddesc}[xmlparser]{SetBase}{base} ! Sets the base to be used for resolving relative URIs in system identifiers in ! declarations. Resolving relative identifiers is left to the application: ! this value will be passed through as the base argument to the ! \function{ExternalEntityRefHandler}, \function{NotationDeclHandler}, ! and \function{UnparsedEntityDeclHandler} functions. \end{methoddesc} --- 113,122 ---- \begin{methoddesc}[xmlparser]{SetBase}{base} ! Sets the base to be used for resolving relative URIs in system ! identifiers in declarations. Resolving relative identifiers is left ! to the application: this value will be passed through as the ! \var{base} argument to the \function{ExternalEntityRefHandler}, ! \function{NotationDeclHandler}, and ! \function{UnparsedEntityDeclHandler} functions. \end{methoddesc} *************** *** 121,124 **** --- 133,139 ---- \var{context} parameter should be the string passed to the \method{ExternalEntityRefHandler()} handler function, described below. + The child parser is created with the \member{ordered_attributes}, + \member{returns_unicode} and \member{specified_attributes} set to the + values of this parser. \end{methoddesc} *************** *** 126,137 **** \class{xmlparser} objects have the following attributes: \begin{memberdesc}[xmlparser]{returns_unicode} ! If this attribute is set to 1, the handler functions will be passed ! Unicode strings. If \member{returns_unicode} is 0, 8-bit strings ! containing UTF-8 encoded data will be passed to the handlers. \versionchanged[Can be changed at any time to affect the result type.]{1.6} \end{memberdesc} The following attributes contain values relating to the most recent error encountered by an \class{xmlparser} object, and will only have --- 141,175 ---- \class{xmlparser} objects have the following attributes: + \begin{memberdesc}[xmlparser]{ordered_attributes} + Setting this attribute to a non-zero integer causes the attributes to + be reported as a list rather than a dictionary. The attributes are + presented in the order found in the document text. For each + attribute, two list entries are presented: the attribute name and the + attribute value. (Older versions of this module also used this + format.) By default, this attribute is false; it may be changed at + any time. + \versionadded{2.1} + \end{memberdesc} + \begin{memberdesc}[xmlparser]{returns_unicode} ! If this attribute is set to a non-zero integer, the handler functions ! will be passed Unicode strings. If \member{returns_unicode} is 0, ! 8-bit strings containing UTF-8 encoded data will be passed to the ! handlers. \versionchanged[Can be changed at any time to affect the result type.]{1.6} \end{memberdesc} + \begin{memberdesc}[xmlparser]{specified_attributes} + If set to a non-zero integer, the parser will report only those + attributes which were specified in the document instance and not those + which were derived from attribute declarations. Applications which + set this need to be especially careful to use what additional + information is available from the declarations as needed to comply + with the standards for the behavior of XML processors. By default, + this attribute is false; it may be changed at any time. + \versionadded{2.1} + \end{memberdesc} + The following attributes contain values relating to the most recent error encountered by an \class{xmlparser} object, and will only have *************** *** 164,167 **** --- 202,258 ---- all strings, unless otherwise stated. + \begin{methoddesc}[xmlparser]{XmlDeclHandler}{version, encoding, standalone} + Called when the XML declaration is parsed. The XML declaration is the + (optional) declaration of the applicable version of the XML + recommendation, the encoding of the document text, and an optional + ``standalone'' declaration. \var{version} and \var{encoding} will be + strings of the type dictated by the \member{returns_unicode} + attribute, and \var{standalone} will be \code{1} if the document is + declared standalone, \code{0} if it is declared not to be standalone, + or \code{-1} if the standalone clause was omitted. + This is only available with Expat version 1.95.0 or newer. + \versionadded{2.1} + \end{methoddesc} + + \begin{methoddesc}[xmlparser]{StartDoctypeDeclHandler}{doctypeName, + systemId, publicId, + has_internal_subset} + Called when Expat begins parsing the document type declaration + (\code{}'. \end{methoddesc} \begin{methoddesc}[xmlparser]{StartCdataSectionHandler}{} ! Called at the start of a CDATA section. This and ! \member{StartCdataSectionHandler} are needed to be able to identify ! the syntactical start and end for CDATA sections. \end{methoddesc} *************** *** 227,238 **** \end{methoddesc} ! \begin{methoddesc}[xmlparser]{NotStandaloneHandler}{} ! Called if the XML document hasn't been declared as being a standalone ! document. \end{methoddesc} \begin{methoddesc}[xmlparser]{ExternalEntityRefHandler}{context, base, systemId, publicId} ! Called for references to external entities. \end{methoddesc} --- 356,386 ---- \end{methoddesc} ! \begin{methoddesc}[xmlparser]{NotStandaloneHandler}{} Called if the ! XML document hasn't been declared as being a standalone document. ! This happens when there is an external subset or a reference to a ! parameter entity, but the XML declaration does not set standalone to ! \code{yes} in an XML declaration. If this handler returns \code{0}, ! then the parser will throw an \constant{XML_ERROR_NOT_STANDALONE} ! error. If this handler is not set, no exception is raised by the ! parser for this condition. \end{methoddesc} \begin{methoddesc}[xmlparser]{ExternalEntityRefHandler}{context, base, systemId, publicId} ! Called for references to external entities. \var{base} is the current ! base, as set by a previous call to \method{SetBase()}. The public and ! system identifiers, \var{systemId} and \var{publicId}, are strings if ! given; if the public identifier is not given, \var{publicId} will be ! \code{None}. ! ! For external entities to be parsed, this handler must be implemented. ! It is responsible for creating the sub-parser using ! \code{ExternalEntityRefHandler(\var{context})}, initializing it with ! the appropriate callbacks, and parsing the entity. If this handler ! returns \code{0}, the parser will throw an ! \constant{XML_ERROR_EXTERNAL_ENTITY_HANDLING} error. ! ! If this handler is not provided, external entities are reported by the ! \member{DefaultHandler} callback, if provided. \end{methoddesc} *************** *** 282,285 **** --- 430,494 ---- + \subsection{Content Model Descriptions \label{expat-content-models}} + \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} + + Content modules are described using nested tuples. Each tuple + contains four values: the type, the quantifier, the name, and a tuple + of children. Children are simply additional content module + descriptions. + + The values of the first two fields are constants defined in the + \code{model} object of the \module{xml.parsers.expat} module. These + constants can be collected in two groups: the model type group and the + quantifier group. + + The constants in the model type group are: + + \begin{datadescni}{XML_CTYPE_ANY} + The element named by the model name was declared to have a content + model of \code{ANY}. + \end{datadescni} + + \begin{datadescni}{XML_CTYPE_CHOICE} + The named element allows a choice from a number of options; this is + used for content models such as \code{(A | B | C)}. + \end{datadescni} + + \begin{datadescni}{XML_CTYPE_EMPTY} + Elements which are declared to be \code{EMPTY} have this model type. + \end{datadescni} + + \begin{datadescni}{XML_CTYPE_MIXED} + \end{datadescni} + + \begin{datadescni}{XML_CTYPE_NAME} + \end{datadescni} + + \begin{datadescni}{XML_CTYPE_SEQ} + Models which represent a series of models which follow one after the + other are indicated with this model type. This is used for models + such as \code{(A, B, C)}. + \end{datadescni} + + + The constants in the quantifier group are: + + \begin{datadescni}{XML_CQUANT_NONE} + \end{datadescni} + + \begin{datadescni}{XML_CQUANT_OPT} + The model is option: it can appear once or not at all, as for + \code{A?}. + \end{datadescni} + + \begin{datadescni}{XML_CQUANT_PLUS} + The model must occur one or more times (\code{A+}). + \end{datadescni} + + \begin{datadescni}{XML_CQUANT_REP} + The model must occur zero or more times, as for \code{A*}. + \end{datadescni} + + \subsection{Expat error constants \label{expat-errors}} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} *************** *** 292,356 **** The \code{errors} object has the following attributes: ! \begin{datadesc}{XML_ERROR_ASYNC_ENTITY} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_BAD_CHAR_REF} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_BINARY_ENTITY_REF} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_DUPLICATE_ATTRIBUTE} An attribute was used more than once in a start tag. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_INCORRECT_ENCODING} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_INVALID_TOKEN} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_JUNK_AFTER_DOC_ELEMENT} Something other than whitespace occurred after the document element. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_MISPLACED_XML_PI} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_NO_ELEMENTS} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_NO_MEMORY} Expat was not able to allocate memory internally. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_PARAM_ENTITY_REF} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_PARTIAL_CHAR} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_RECURSIVE_ENTITY_REF} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_SYNTAX} Some unspecified syntax error was encountered. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_TAG_MISMATCH} An end tag did not match the innermost open start tag. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_UNCLOSED_TOKEN} ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_UNDEFINED_ENTITY} A reference was made to a entity which was not defined. ! \end{datadesc} ! \begin{datadesc}{XML_ERROR_UNKNOWN_ENCODING} The document encoding is not supported by Expat. ! \end{datadesc} --- 501,568 ---- The \code{errors} object has the following attributes: ! \begin{datadescni}{XML_ERROR_ASYNC_ENTITY} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} ! An entity reference in an attribute value referred to an external ! entity instead of an internal entity. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_BAD_CHAR_REF} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_BINARY_ENTITY_REF} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_DUPLICATE_ATTRIBUTE} An attribute was used more than once in a start tag. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_INCORRECT_ENCODING} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_INVALID_TOKEN} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_JUNK_AFTER_DOC_ELEMENT} Something other than whitespace occurred after the document element. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_MISPLACED_XML_PI} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_NO_ELEMENTS} ! The document contains no elements. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_NO_MEMORY} Expat was not able to allocate memory internally. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_PARAM_ENTITY_REF} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_PARTIAL_CHAR} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_RECURSIVE_ENTITY_REF} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_SYNTAX} Some unspecified syntax error was encountered. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_TAG_MISMATCH} An end tag did not match the innermost open start tag. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_UNCLOSED_TOKEN} ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_UNDEFINED_ENTITY} A reference was made to a entity which was not defined. ! \end{datadescni} ! \begin{datadescni}{XML_ERROR_UNKNOWN_ENCODING} The document encoding is not supported by Expat. ! \end{datadescni} From esr@users.sourceforge.net Fri Feb 9 04:52:13 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 20:52:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cmd.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3082 Modified Files: cmd.py Log Message: String method conversion. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** cmd.py 2001/01/26 17:15:18 1.21 --- cmd.py 2001/02/09 04:52:11 1.22 *************** *** 92,96 **** def onecmd(self, line): ! line = string.strip(line) if not line: return self.emptyline() --- 92,96 ---- def onecmd(self, line): ! line = line.strip() if not line: return self.emptyline() *************** *** 105,109 **** i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 ! cmd, arg = line[:i], string.strip(line[i:]) if cmd == '': return self.default(line) --- 105,109 ---- i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 ! cmd, arg = line[:i], line[i:].strip() if cmd == '': return self.default(line) From esr@users.sourceforge.net Fri Feb 9 04:57:19 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 20:57:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib BaseHTTPServer.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3393 Modified Files: BaseHTTPServer.py Log Message: String method conversion. Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** BaseHTTPServer.py 2001/01/20 19:54:20 1.13 --- BaseHTTPServer.py 2001/02/09 04:57:17 1.14 *************** *** 69,73 **** import time import socket # For gethostbyaddr() - import string import mimetools import SocketServer --- 69,72 ---- *************** *** 204,208 **** # The Python system version, truncated to its first component. ! sys_version = "Python/" + string.split(sys.version)[0] # The server software version. You may want to override this. --- 203,207 ---- # The Python system version, truncated to its first component. ! sys_version = "Python/" + sys.version.split()[0] # The server software version. You may want to override this. *************** *** 229,233 **** requestline = requestline[:-1] self.requestline = requestline ! words = string.split(requestline) if len(words) == 3: [command, path, version] = words --- 228,232 ---- requestline = requestline[:-1] self.requestline = requestline ! words = requestline.split() if len(words) == 3: [command, path, version] = words *************** *** 469,473 **** if sys.argv[1:]: ! port = string.atoi(sys.argv[1]) else: port = 8000 --- 468,472 ---- if sys.argv[1:]: ! port = sys.argv[1].atoi() else: port = 8000 From esr@users.sourceforge.net Fri Feb 9 04:59:28 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 20:59:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib bdb.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3524 Modified Files: bdb.py Log Message: String method conversion. Index: bdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** bdb.py 2001/01/20 19:54:20 1.29 --- bdb.py 2001/02/09 04:59:26 1.30 *************** *** 307,311 **** def format_stack_entry(self, frame_lineno, lprefix=': '): ! import linecache, repr, string frame, lineno = frame_lineno filename = self.canonic(frame.f_code.co_filename) --- 307,311 ---- def format_stack_entry(self, frame_lineno, lprefix=': '): ! import linecache, repr frame, lineno = frame_lineno filename = self.canonic(frame.f_code.co_filename) *************** *** 328,332 **** s = s + repr.repr(rv) line = linecache.getline(filename, lineno) ! if line: s = s + lprefix + string.strip(line) return s --- 328,332 ---- s = s + repr.repr(rv) line = linecache.getline(filename, lineno) ! if line: s = s + lprefix + line.strip() return s *************** *** 535,544 **** print '+++ call', name, args def user_line(self, frame): ! import linecache, string name = frame.f_code.co_name if not name: name = '???' fn = self.canonic(frame.f_code.co_filename) line = linecache.getline(fn, frame.f_lineno) ! print '+++', fn, frame.f_lineno, name, ':', string.strip(line) def user_return(self, frame, retval): print '+++ return', retval --- 535,544 ---- print '+++ call', name, args def user_line(self, frame): ! import linecache name = frame.f_code.co_name if not name: name = '???' fn = self.canonic(frame.f_code.co_filename) line = linecache.getline(fn, frame.f_lineno) ! print '+++', fn, frame.f_lineno, name, ':', line.strip() def user_return(self, frame, retval): print '+++ return', retval *************** *** 559,560 **** --- 559,562 ---- t = Tdb() t.run('import bdb; bdb.foo(10)') + + # end From esr@users.sourceforge.net Fri Feb 9 05:03:17 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:03:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3796 Modified Files: asyncore.py Log Message: String method conversion. Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** asyncore.py 2001/01/24 15:50:19 1.9 --- asyncore.py 2001/02/09 05:03:15 1.10 *************** *** 50,54 **** import select import socket - import string import sys --- 50,53 ---- *************** *** 220,224 **** return '<%s %s at %x>' % ( self.__class__.__name__, ! string.join (status, ' '), id(self) ) --- 219,223 ---- return '<%s %s at %x>' % ( self.__class__.__name__, ! ' '.join (status), id(self) ) *************** *** 481,491 **** file, function, line = tbinfo[-1] ! info = '[' + string.join ( ! map ( ! lambda x: string.join (x, '|'), ! tbinfo ! ), ! '] [' ! ) + ']' return (file, function, line), t, v, info --- 480,484 ---- file, function, line = tbinfo[-1] ! info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']' return (file, function, line), t, v, info From esr@users.sourceforge.net Fri Feb 9 05:04:50 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:04:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asynchat.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3923 Modified Files: asynchat.py Log Message: String method conversion. Index: asynchat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** asynchat.py 2001/01/24 21:10:55 1.9 --- asynchat.py 2001/02/09 05:04:48 1.10 *************** *** 49,53 **** import socket import asyncore - import string class async_chat (asyncore.dispatcher): --- 49,52 ---- *************** *** 121,125 **** # collect data terminator_len = len(terminator) ! index = string.find (self.ac_in_buffer, terminator) if index != -1: # we found the terminator --- 120,124 ---- # collect data terminator_len = len(terminator) ! index = terminator.find (self.ac_in_buffer) if index != -1: # we found the terminator From esr@users.sourceforge.net Fri Feb 9 05:07:06 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:07:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib binhex.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4053 Modified Files: binhex.py Log Message: String method conversion. Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** binhex.py 2001/01/20 19:54:20 1.18 --- binhex.py 2001/02/09 05:07:04 1.19 *************** *** 103,107 **** fp.close() dir, file = os.path.split(name) ! file = string.replace(file, ':', '-', 1) return file, finfo, dsize, 0 --- 103,107 ---- fp.close() dir, file = os.path.split(name) ! file = file.replace(':', '-', 1) return file, finfo, dsize, 0 From esr@users.sourceforge.net Fri Feb 9 05:19:11 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:19:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4770 Modified Files: ConfigParser.py Log Message: String method conversion. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** ConfigParser.py 2001/01/20 19:54:20 1.27 --- ConfigParser.py 2001/02/09 05:19:09 1.28 *************** *** 294,298 **** while depth < 10: # Loop through this until it's done depth = depth + 1 ! if string.find(value, "%(") >= 0: try: value = value % d --- 294,298 ---- while depth < 10: # Loop through this until it's done depth = depth + 1 ! if value.find("%(") >= 0: try: value = value % d *************** *** 316,320 **** def getboolean(self, section, option): v = self.get(section, option) ! val = string.atoi(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v --- 316,320 ---- def getboolean(self, section, option): v = self.get(section, option) ! val = v.atoi() if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v *************** *** 322,326 **** def optionxform(self, optionstr): ! return string.lower(optionstr) def has_option(self, section, option): --- 322,326 ---- def optionxform(self, optionstr): ! return optionstr.lower() def has_option(self, section, option): *************** *** 420,431 **** lineno = lineno + 1 # comment or blank line? ! if string.strip(line) == '' or line[0] in '#;': continue ! if string.lower(string.split(line)[0]) == 'rem' \ and line[0] in "rR": # no leading whitespace continue # continuation line? if line[0] in ' \t' and cursect is not None and optname: ! value = string.strip(line) if value: cursect[optname] = cursect[optname] + '\n ' + value --- 420,431 ---- lineno = lineno + 1 # comment or blank line? ! if line.strip() == '' or line[0] in '#;': continue ! if line.split()[0].lower() == 'rem' \ and line[0] in "rR": # no leading whitespace continue # continuation line? if line[0] in ' \t' and cursect is not None and optname: ! value = line.strip() if value: cursect[optname] = cursect[optname] + '\n ' + value *************** *** 456,463 **** # ';' is a comment delimiter only if it follows # a spacing character ! pos = string.find(optval, ';') if pos and optval[pos-1] in string.whitespace: optval = optval[:pos] ! optval = string.strip(optval) # allow empty values if optval == '""': --- 456,463 ---- # ';' is a comment delimiter only if it follows # a spacing character ! pos = optval.find(';') if pos and optval[pos-1] in string.whitespace: optval = optval[:pos] ! optval = optval.strip() # allow empty values if optval == '""': From esr@users.sourceforge.net Fri Feb 9 05:37:27 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:37:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5939 Modified Files: ConfigParser.py Log Message: Correction after second code path test. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** ConfigParser.py 2001/02/09 05:19:09 1.28 --- ConfigParser.py 2001/02/09 05:37:25 1.29 *************** *** 316,320 **** def getboolean(self, section, option): v = self.get(section, option) ! val = v.atoi() if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v --- 316,320 ---- def getboolean(self, section, option): v = self.get(section, option) ! val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v From esr@users.sourceforge.net Fri Feb 9 05:38:48 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:38:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib BaseHTTPServer.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6097 Modified Files: BaseHTTPServer.py Log Message: Correction to test main. Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** BaseHTTPServer.py 2001/02/09 04:57:17 1.14 --- BaseHTTPServer.py 2001/02/09 05:38:46 1.15 *************** *** 468,472 **** if sys.argv[1:]: ! port = sys.argv[1].atoi() else: port = 8000 --- 468,472 ---- if sys.argv[1:]: ! port = int(sys.argv[1]) else: port = 8000 From esr@users.sourceforge.net Fri Feb 9 05:40:40 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 21:40:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6260 Modified Files: smtplib.py Log Message: String method conversion. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** smtplib.py 2001/01/15 01:36:40 1.32 --- smtplib.py 2001/02/09 05:40:38 1.33 *************** *** 206,213 **** """ if not port: ! i = string.find(host, ':') if i >= 0: host, port = host[:i], host[i+1:] ! try: port = string.atoi(port) except string.atoi_error: raise socket.error, "nonnumeric port" --- 206,213 ---- """ if not port: ! i = host.find(':') if i >= 0: host, port = host[:i], host[i+1:] ! try: port = int(port) except string.atoi_error: raise socket.error, "nonnumeric port" *************** *** 267,276 **** raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print 'reply:', `line` ! resp.append(string.strip(line[4:])) code=line[:3] # Check that the error code is syntactically correct. # Don't attempt to read a continuation line if it is broken. try: ! errcode = string.atoi(code) except ValueError: errcode = -1 --- 267,276 ---- raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print 'reply:', `line` ! resp.append(line[4:].strip()) code=line[:3] # Check that the error code is syntactically correct. # Don't attempt to read a continuation line if it is broken. try: ! errcode = int(code) except ValueError: errcode = -1 *************** *** 280,284 **** break ! errmsg = string.join(resp,"\n") if self.debuglevel > 0: print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) --- 280,284 ---- break ! errmsg = "\n".join(resp) if self.debuglevel > 0: print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) *************** *** 324,334 **** self.does_esmtp=1 #parse the ehlo response -ddm ! resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: ! feature=string.lower(m.group("feature")) ! params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return (code,msg) --- 324,334 ---- self.does_esmtp=1 #parse the ehlo response -ddm ! resp=self.ehlo_resp.split('\n') del resp[0] for each in resp: m=re.match(r'(?P[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: ! feature=m.group("feature").lower() ! params=m.string[m.end("feature"):].strip() self.esmtp_features[feature]=params return (code,msg) *************** *** 336,340 **** def has_extn(self, opt): """Does the server support a given SMTP service extension?""" ! return self.esmtp_features.has_key(string.lower(opt)) def help(self, args=''): --- 336,340 ---- def has_extn(self, opt): """Does the server support a given SMTP service extension?""" ! return self.esmtp_features.has_key(opt.lower()) def help(self, args=''): *************** *** 356,360 **** optionlist = '' if options and self.does_esmtp: ! optionlist = ' ' + string.join(options, ' ') self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist)) return self.getreply() --- 356,360 ---- optionlist = '' if options and self.does_esmtp: ! optionlist = ' ' + ' '.join(options) self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist)) return self.getreply() *************** *** 364,368 **** optionlist = '' if options and self.does_esmtp: ! optionlist = ' ' + string.join(options, ' ') self.putcmd("rcpt","TO:%s%s" % (quoteaddr(recip),optionlist)) return self.getreply() --- 364,368 ---- optionlist = '' if options and self.does_esmtp: ! optionlist = ' ' + ' '.join(options) self.putcmd("rcpt","TO:%s%s" % (quoteaddr(recip),optionlist)) return self.getreply() *************** *** 521,528 **** def prompt(prompt): sys.stdout.write(prompt + ": ") ! return string.strip(sys.stdin.readline()) fromaddr = prompt("From") ! toaddrs = string.splitfields(prompt("To"), ',') print "Enter message, end with ^D:" msg = '' --- 521,528 ---- def prompt(prompt): sys.stdout.write(prompt + ": ") ! return sys.stdin.readline().strip() fromaddr = prompt("From") ! toaddrs = ','.split(prompt("To")) print "Enter message, end with ^D:" msg = '' From esr@users.sourceforge.net Fri Feb 9 06:50:23 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 22:50:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib imaplib.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11544 Modified Files: imaplib.py Log Message: String method conversion. Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** imaplib.py 2001/01/24 04:16:09 1.24 --- imaplib.py 2001/02/09 06:50:21 1.25 *************** *** 14,21 **** # # Authentication code contributed by Donn Cave June 1998. ! __version__ = "2.39" ! import binascii, re, socket, string, time, random, sys __all__ = ["IMAP4", "Internaldate2tuple", --- 14,22 ---- # # Authentication code contributed by Donn Cave June 1998. + # String method conversion by ESR, February 2001. ! __version__ = "2.40" ! import binascii, re, socket, time, random, sys __all__ = ["IMAP4", "Internaldate2tuple", *************** *** 168,172 **** if not self.untagged_responses.has_key(cap): raise self.error('no CAPABILITY response from server') ! self.capabilities = tuple(string.split(string.upper(self.untagged_responses[cap][-1]))) if __debug__: --- 169,173 ---- if not self.untagged_responses.has_key(cap): raise self.error('no CAPABILITY response from server') ! self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split()) if __debug__: *************** *** 186,190 **** # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): ! return eval("self.%s" % string.lower(attr)) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) --- 187,191 ---- # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): ! return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) *************** *** 225,229 **** (code, [data]) = .response(code) """ ! return self._untagged_response(code, [None], string.upper(code)) --- 226,230 ---- (code, [data]) = .response(code) """ ! return self._untagged_response(code, [None], code.upper()) *************** *** 279,283 **** be sent instead. """ ! mech = string.upper(mechanism) cap = 'AUTH=%s' % mech if not cap in self.capabilities: --- 280,284 ---- be sent instead. """ ! mech = mechanism.upper() cap = 'AUTH=%s' % mech if not cap in self.capabilities: *************** *** 538,542 **** Returns response appropriate to 'command'. """ ! command = string.upper(command) if not Commands.has_key(command): raise self.error("Unknown IMAP4 UID command: %s" % command) --- 539,543 ---- Returns response appropriate to 'command'. """ ! command = command.upper() if not Commands.has_key(command): raise self.error("Unknown IMAP4 UID command: %s" % command) *************** *** 730,734 **** # Read literal direct from connection. ! size = string.atoi(self.mo.group('size')) if __debug__: if self.debug >= 4: --- 731,735 ---- # Read literal direct from connection. ! size = int(self.mo.group('size')) if __debug__: if self.debug >= 4: *************** *** 833,838 **** def _quote(self, arg): ! arg = string.replace(arg, '\\', '\\\\') ! arg = string.replace(arg, '"', '\\"') return '"%s"' % arg --- 834,839 ---- def _quote(self, arg): ! arg = arg.replace('\\', '\\\\') ! arg = arg.replace('"', '\\"') return '"%s"' % arg *************** *** 921,925 **** for name in ('day', 'year', 'hour', 'min', 'sec', 'zoneh', 'zonem'): ! exec "%s = string.atoi(mo.group('%s'))" % (name, name) # INTERNALDATE timezone must be subtracted to get UT --- 922,926 ---- for name in ('day', 'year', 'hour', 'min', 'sec', 'zoneh', 'zonem'): ! exec "%s = int(mo.group('%s'))" % (name, name) # INTERNALDATE timezone must be subtracted to get UT *************** *** 967,971 **** return () ! return tuple(string.split(mo.group('flags'))) --- 968,972 ---- return () ! return tuple(mo.group('flags').split()) *************** *** 1011,1016 **** if not l: return t = '\n\t\t' ! j = string.join ! l = map(lambda x,j=j:'%s: "%s"' % (x[0], x[1][0] and j(x[1], '" "') or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t))) --- 1012,1016 ---- if not l: return t = '\n\t\t' ! l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t))) *************** *** 1049,1053 **** USER = getpass.getuser() ! PASSWD = getpass.getpass("IMAP password for %s on %s" % (USER, host or "localhost")) test_mesg = 'From: %s@localhost\nSubject: IMAP4 test\n\ndata...\n' % USER --- 1049,1053 ---- USER = getpass.getuser() ! PASSWD = getpass.getpass("IMAP password for %s on %s:" % (USER, host or "localhost")) test_mesg = 'From: %s@localhost\nSubject: IMAP4 test\n\ndata...\n' % USER *************** *** 1094,1098 **** mo = re.match(r'.*"([^"]+)"$', ml) if mo: path = mo.group(1) ! else: path = string.split(ml)[-1] run('delete', (path,)) --- 1094,1098 ---- mo = re.match(r'.*"([^"]+)"$', ml) if mo: path = mo.group(1) ! else: path = ml.split()[-1] run('delete', (path,)) *************** *** 1103,1107 **** continue ! uid = string.split(dat[-1]) if not uid: continue run('uid', ('FETCH', '%s' % uid[-1], --- 1103,1107 ---- continue ! uid = dat[-1].split() if not uid: continue run('uid', ('FETCH', '%s' % uid[-1], From esr@users.sourceforge.net Fri Feb 9 06:56:58 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 22:56:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib poplib.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11906 Modified Files: poplib.py Log Message: String method conversion. Index: poplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/poplib.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** poplib.py 2001/01/19 19:56:27 1.12 --- poplib.py 2001/02/09 06:56:56 1.13 *************** *** 7,20 **** # [heavily stealing from nntplib.py] # Updated: Piers Lauder [Jul '97] # Example (see the test function at the end of this file) - TESTSERVER = "localhost" - TESTACCOUNT = "test" - TESTPASSWORD = "_passwd_" - # Imports ! import re, socket, string # Exception raised when an error or invalid response is received: --- 7,17 ---- # [heavily stealing from nntplib.py] # Updated: Piers Lauder [Jul '97] + # String method conversion and test jig improvements by ESR, February 2001. # Example (see the test function at the end of this file) # Imports ! import re, socket # Exception raised when an error or invalid response is received: *************** *** 193,200 **** """ retval = self._shortcmd('STAT') ! rets = string.split(retval) #if self._debugging: print '*stat*', `rets` ! numMessages = string.atoi(rets[1]) ! sizeMessages = string.atoi(rets[2]) return (numMessages, sizeMessages) --- 190,197 ---- """ retval = self._shortcmd('STAT') ! rets = retval.split() #if self._debugging: print '*stat*', `rets` ! numMessages = int(rets[1]) ! sizeMessages = int(rets[2]) return (numMessages, sizeMessages) *************** *** 282,286 **** import md5 digest = md5.new(m.group(1)+secret).digest() ! digest = string.join(map(lambda x:'%02x'%ord(x), digest), '') return self._shortcmd('APOP %s %s' % (user, digest)) --- 279,283 ---- import md5 digest = md5.new(m.group(1)+secret).digest() ! digest = ''.join(map(lambda x:'%02x'%ord(x), digest)) return self._shortcmd('APOP %s %s' % (user, digest)) *************** *** 308,315 **** if __name__ == "__main__": ! a = POP3(TESTSERVER) print a.getwelcome() ! a.user(TESTACCOUNT) ! a.pass_(TESTPASSWORD) a.list() (numMsgs, totalSize) = a.stat() --- 305,313 ---- if __name__ == "__main__": ! import sys ! a = POP3(sys.argv[1]) print a.getwelcome() ! a.user(sys.argv[2]) ! a.pass_(sys.argv[3]) a.list() (numMsgs, totalSize) = a.stat() From esr@users.sourceforge.net Fri Feb 9 07:02:19 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:02:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib nntplib.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12257 Modified Files: nntplib.py Log Message: String method conversion. Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** nntplib.py 2001/02/06 01:07:01 1.25 --- nntplib.py 2001/02/09 07:02:17 1.26 *************** *** 32,36 **** import re import socket - import string __all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError", --- 32,35 ---- *************** *** 268,272 **** for i in range(len(list)): # Parse lines into "group last first flag" ! list[i] = tuple(string.split(list[i])) return resp, list --- 267,271 ---- for i in range(len(list)): # Parse lines into "group last first flag" ! list[i] = tuple(list[i].split()) return resp, list *************** *** 284,288 **** if resp[:3] != '211': raise NNTPReplyError(resp) ! words = string.split(resp) count = first = last = 0 n = len(words) --- 283,287 ---- if resp[:3] != '211': raise NNTPReplyError(resp) ! words = resp.split() count = first = last = 0 n = len(words) *************** *** 294,298 **** last = words[3] if n > 4: ! name = string.lower(words[4]) return resp, count, first, last, name --- 293,297 ---- last = words[3] if n > 4: ! name = words[4].lower() return resp, count, first, last, name *************** *** 308,312 **** if resp[:2] != '22': raise NNTPReplyError(resp) ! words = string.split(resp) nr = 0 id = '' --- 307,311 ---- if resp[:2] != '22': raise NNTPReplyError(resp) ! words = resp.split() nr = 0 id = '' *************** *** 415,419 **** xover_lines = [] for line in lines: ! elem = string.splitfields(line,"\t") try: xover_lines.append((elem[0], --- 414,418 ---- xover_lines = [] for line in lines: ! elem = line.split("\t") try: xover_lines.append((elem[0], *************** *** 422,426 **** elem[3], elem[4], ! string.split(elem[5]), elem[6], elem[7])) --- 421,425 ---- elem[3], elem[4], ! elem[5].split(), elem[6], elem[7])) *************** *** 440,444 **** lines = [] for raw_line in raw_lines: ! match = line_pat.search(string.strip(raw_line)) if match: lines.append(match.group(1, 2)) --- 439,443 ---- lines = [] for raw_line in raw_lines: ! match = line_pat.search(raw_line.strip()) if match: lines.append(match.group(1, 2)) *************** *** 456,460 **** raise NNTPReplyError(resp) try: ! [resp_num, path] = string.split(resp) except ValueError: raise NNTPReplyError(resp) --- 455,459 ---- raise NNTPReplyError(resp) try: ! [resp_num, path] = resp.split() except ValueError: raise NNTPReplyError(resp) *************** *** 473,477 **** if resp[:3] != '111': raise NNTPReplyError(resp) ! elem = string.split(resp) if len(elem) != 2: raise NNTPDataError(resp) --- 472,476 ---- if resp[:3] != '111': raise NNTPReplyError(resp) ! elem = resp.split() if len(elem) != 2: raise NNTPDataError(resp) From tim_one@users.sourceforge.net Fri Feb 9 07:02:24 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 08 Feb 2001 23:02:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv11828/python/dist/src/Misc Modified Files: ACKS Log Message: SF bug #131225: sys.winver is still '2.0' in python 2.1a2. SF patch #103683: Alternative dll version resources. Changes similar to the patch. MarkH should review. File version and Product version text strings now 2.1a2. 64-bit file and product version numbers are now PY_MAJOR_VERSION, PY_MINOR_VERSION, messy, PYTHON_API_VERSION where messy = PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL Updated company name to "Digital Creations 2". Copyright now lists Guido; "C in a circle" symbol used instead of (C). Comments added so this is less likely to get flubbed again, and #if/#error guys added to trigger if the version number manipulations above overflow. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -r1.78 -r1.79 *** ACKS 2001/02/05 17:36:46 1.78 --- ACKS 2001/02/09 07:02:22 1.79 *************** *** 180,183 **** --- 180,184 ---- Brad Howes Chih-Hao Huang + Lawrence Hudson Michael Hudson Jim Hugunin From tim_one@users.sourceforge.net Fri Feb 9 07:02:24 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 08 Feb 2001 23:02:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC python_nt.rc,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv11828/python/dist/src/PC Modified Files: python_nt.rc Log Message: SF bug #131225: sys.winver is still '2.0' in python 2.1a2. SF patch #103683: Alternative dll version resources. Changes similar to the patch. MarkH should review. File version and Product version text strings now 2.1a2. 64-bit file and product version numbers are now PY_MAJOR_VERSION, PY_MINOR_VERSION, messy, PYTHON_API_VERSION where messy = PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL Updated company name to "Digital Creations 2". Copyright now lists Guido; "C in a circle" symbol used instead of (C). Comments added so this is less likely to get flubbed again, and #if/#error guys added to trigger if the version number manipulations above overflow. Index: python_nt.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/python_nt.rc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** python_nt.rc 2001/01/17 23:23:13 1.11 --- python_nt.rc 2001/02/09 07:02:22 1.12 *************** *** 9,24 **** #include "patchlevel.h" ! #define MS_DLL_ID "2.0" - #define PYTHON_VERSION MS_DLL_ID "." PYTHON_API_STRING "\0" - #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "Python21.dll" #endif // String Tables STRINGTABLE DISCARDABLE BEGIN ! 1000, MS_DLL_ID END --- 9,48 ---- #include "patchlevel.h" ! /* Across releases, change: ! * MS_DLL_ID if the minor version number changes. ! * PYTHON_DLL_NAME ditto. ! */ ! #define MS_DLL_ID "2.1" #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "python21.dll" #endif + /* Nothing below this should need to be changed except for copyright + * notices and company name. + */ + + /* e.g., 2.1a2 + * PY_VERSION comes from patchevel.h + */ + #define PYTHON_VERSION PY_VERSION "\0" + + /* 64-bit version number as comma-separated list of 4 16-bit ints */ + #if PY_MICRO_VERSION > 64 + # error "PY_MICRO_VERSION > 64" + #endif + #if PY_RELEASE_LEVEL > 99 + # error "PY_RELEASE_LEVEL > 99" + #endif + #if PY_RELEASE_SERIAL > 9 + # error "PY_RELEASE_SERIAL > 9" + #endif + #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL) + #define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3, PYTHON_API_VERSION + // String Tables STRINGTABLE DISCARDABLE BEGIN ! 1000, MS_DLL_ID END *************** *** 29,34 **** VS_VERSION_INFO VERSIONINFO ! FILEVERSION 1,6,0,0 ! PRODUCTVERSION 1,6,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG --- 53,58 ---- VS_VERSION_INFO VERSIONINFO ! FILEVERSION PYVERSION64 ! PRODUCTVERSION PYVERSION64 FILEFLAGSMASK 0x3fL #ifdef _DEBUG *************** *** 45,53 **** BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "BeOpen.com\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright (c) 2000 BeOpen.com. Copyright (c) 1995-2000 CNRI. Copyright (c) 1990-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" --- 69,77 ---- BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "Digital Creations 2\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright © 2000, 2001 Guido van Rossum. Copyright © 2000 BeOpen.com. Copyright © 1995-2000 CNRI. Copyright © 1991-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" *************** *** 60,63 **** END END - - ///////////////////////////////////////////////////////////////////////////// --- 84,85 ---- From esr@users.sourceforge.net Fri Feb 9 07:08:22 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:08:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimify.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12740 Modified Files: mimify.py Log Message: String method conversion. Index: mimify.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimify.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** mimify.py 2001/01/25 15:29:22 1.17 --- mimify.py 2001/02/09 07:08:20 1.18 *************** *** 28,32 **** # End configure ! import re, string __all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"] --- 28,32 ---- # End configure ! import re __all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"] *************** *** 97,101 **** break newline = newline + line[pos:res.start(0)] + \ ! chr(string.atoi(res.group(1), 16)) pos = res.end(0) return newline + line[pos:] --- 97,101 ---- break newline = newline + line[pos:res.start(0)] + \ ! chr(int(res.group(1), 16)) pos = res.end(0) return newline + line[pos:] *************** *** 111,115 **** match = res.group(1) # convert underscores to spaces (before =XX conversion!) ! match = string.join(string.split(match, '_'), ' ') newline = newline + line[pos:res.start(0)] + mime_decode(match) pos = res.end(0) --- 111,115 ---- match = res.group(1) # convert underscores to spaces (before =XX conversion!) ! match = ' '.join(string.split(match, '_')) newline = newline + line[pos:res.start(0)] + mime_decode(match) pos = res.end(0) *************** *** 233,237 **** if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the start of a line for stupid mailers ! newline = string.upper('=%02x' % ord('F')) pos = 1 while 1: --- 233,237 ---- if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the start of a line for stupid mailers ! newline = ('=%02x' % ord('F')).upper() pos = 1 while 1: *************** *** 240,244 **** break newline = newline + line[pos:res.start(0)] + \ ! string.upper('=%02x' % ord(res.group(0))) pos = res.end(0) line = newline + line[pos:] --- 240,244 ---- break newline = newline + line[pos:res.start(0)] + \ ! ('=%02x' % ord(res.group(0))).upper() pos = res.end(0) line = newline + line[pos:] *************** *** 347,351 **** if has_iso_chars: # change us-ascii into iso-8859-1 ! if string.lower(chrset_res.group(2)) == 'us-ascii': line = '%s%s%s' % (chrset_res.group(1), CHARSET, --- 347,351 ---- if has_iso_chars: # change us-ascii into iso-8859-1 ! if chrset_res.group(2).lower() == 'us-ascii': line = '%s%s%s' % (chrset_res.group(1), CHARSET, *************** *** 448,452 **** elif o == '-l': try: ! MAXLEN = string.atoi(a) except: print usage --- 448,452 ---- elif o == '-l': try: ! MAXLEN = int(a) except: print usage From esr@users.sourceforge.net Fri Feb 9 07:10:14 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:10:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib telnetlib.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12922 Modified Files: telnetlib.py Log Message: String method conversion. Index: telnetlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/telnetlib.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** telnetlib.py 2001/01/15 03:26:36 1.9 --- telnetlib.py 2001/02/09 07:10:12 1.10 *************** *** 41,45 **** import socket import select - import string # Tunable parameters --- 41,44 ---- *************** *** 188,192 **** """ if IAC in buffer: ! buffer = string.replace(buffer, IAC, IAC+IAC) self.msg("send %s", `buffer`) self.sock.send(buffer) --- 187,191 ---- """ if IAC in buffer: ! buffer = buffer.replace(IAC, IAC+IAC) self.msg("send %s", `buffer`) self.sock.send(buffer) *************** *** 202,206 **** n = len(match) self.process_rawq() ! i = string.find(self.cookedq, match) if i >= 0: i = i+n --- 201,205 ---- n = len(match) self.process_rawq() ! i = self.cookedq.find(match) if i >= 0: i = i+n *************** *** 216,220 **** self.fill_rawq() self.process_rawq() ! i = string.find(self.cookedq, match, i) if i >= 0: i = i+n --- 215,219 ---- self.fill_rawq() self.process_rawq() ! i = self.cookedq.find(match, i) if i >= 0: i = i+n From esr@users.sourceforge.net Fri Feb 9 07:40:19 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:40:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15299 Modified Files: smtplib.py Log Message: Fixed a bug in the test jig. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** smtplib.py 2001/02/09 05:40:38 1.33 --- smtplib.py 2001/02/09 07:40:17 1.34 *************** *** 524,528 **** fromaddr = prompt("From") ! toaddrs = ','.split(prompt("To")) print "Enter message, end with ^D:" msg = '' --- 524,528 ---- fromaddr = prompt("From") ! toaddrs = prompt("To").split(',') print "Enter message, end with ^D:" msg = '' From esr@users.sourceforge.net Fri Feb 9 07:49:32 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:49:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib sgmllib.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16099 Modified Files: sgmllib.py Log Message: String method conversion. Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** sgmllib.py 2001/01/15 01:36:40 1.23 --- sgmllib.py 2001/02/09 07:49:30 1.24 *************** *** 228,232 **** tag, data = match.group(1, 2) self.__starttag_text = '<%s/' % tag ! tag = string.lower(tag) k = match.end(0) self.finish_shorttag(tag, data) --- 228,232 ---- tag, data = match.group(1, 2) self.__starttag_text = '<%s/' % tag ! tag = tag.lower() k = match.end(0) self.finish_shorttag(tag, data) *************** *** 249,253 **** raise RuntimeError, 'unexpected call to parse_starttag' k = match.end(0) ! tag = string.lower(rawdata[i+1:k]) self.lasttag = tag while k < j: --- 249,253 ---- raise RuntimeError, 'unexpected call to parse_starttag' k = match.end(0) ! tag = rawdata[i+1:k].lower() self.lasttag = tag while k < j: *************** *** 260,264 **** attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] ! attrs.append((string.lower(attrname), attrvalue)) k = match.end(0) if rawdata[j] == '>': --- 260,264 ---- attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] ! attrs.append((attrname.lower(), attrvalue)) k = match.end(0) if rawdata[j] == '>': *************** *** 275,279 **** return -1 j = match.start(0) ! tag = string.lower(string.strip(rawdata[i+2:j])) if rawdata[j] == '>': j = j+1 --- 275,279 ---- return -1 j = match.start(0) ! tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 *************** *** 354,358 **** def handle_charref(self, name): try: ! n = string.atoi(name) except string.atoi_error: self.unknown_charref(name) --- 354,358 ---- def handle_charref(self, name): try: ! n = int(name) except string.atoi_error: self.unknown_charref(name) From esr@users.sourceforge.net Fri Feb 9 07:58:55 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Thu, 08 Feb 2001 23:58:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pdb.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv17065 Modified Files: pdb.py Log Message: String method conversion. Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -r1.49 -r1.50 *** pdb.py 2001/02/07 23:14:30 1.49 --- pdb.py 2001/02/09 07:58:53 1.50 *************** *** 5,9 **** # (See pdb.doc for documentation.) - import string import sys import linecache --- 5,8 ---- *************** *** 155,178 **** if not line: return line ! args = string.split(line) while self.aliases.has_key(args[0]): line = self.aliases[args[0]] ii = 1 for tmpArg in args[1:]: ! line = string.replace(line, "%" + str(ii), tmpArg) ii = ii + 1 ! line = string.replace(line, "%*", ! string.join(args[1:], ' ')) ! args = string.split(line) # split into ';;' separated commands # unless it's an alias command if args[0] != 'alias': ! marker = string.find(line, ';;') if marker >= 0: # queue up everything after marker ! next = string.lstrip(line[marker+2:]) self.cmdqueue.append(next) ! line = string.rstrip(line[:marker]) return line --- 154,176 ---- if not line: return line ! args = line.split() while self.aliases.has_key(args[0]): line = self.aliases[args[0]] ii = 1 for tmpArg in args[1:]: ! line = line.replace("%" + str(ii), tmpArg) ii = ii + 1 ! line = line.replace("%*", ' '.join(args[1:])) ! args = line.split() # split into ';;' separated commands # unless it's an alias command if args[0] != 'alias': ! marker = line.find(';;') if marker >= 0: # queue up everything after marker ! next = line[marker+2:].lstrip() self.cmdqueue.append(next) ! line = line[:marker].rstrip() return line *************** *** 200,212 **** lineno = None cond = None ! comma = string.find(arg, ',') if comma > 0: # parse stuff after comma: "condition" ! cond = string.lstrip(arg[comma+1:]) ! arg = string.rstrip(arg[:comma]) # parse stuff before comma: [filename:]lineno | function ! colon = string.rfind(arg, ':') if colon >= 0: ! filename = string.rstrip(arg[:colon]) f = self.lookupmodule(filename) if not f: --- 198,210 ---- lineno = None cond = None ! comma = arg.find(',') if comma > 0: # parse stuff after comma: "condition" ! cond = arg[comma+1:].lstrip() ! arg = arg[:comma].rstrip() # parse stuff before comma: [filename:]lineno | function ! colon = arg.rfind(':') if colon >= 0: ! filename = arg[:colon].rstrip() f = self.lookupmodule(filename) if not f: *************** *** 216,220 **** else: filename = f ! arg = string.lstrip(arg[colon+1:]) try: lineno = int(arg) --- 214,218 ---- else: filename = f ! arg = arg[colon+1:].lstrip() try: lineno = int(arg) *************** *** 280,294 **** failed = (None, None, None) # Input is identifier, may be in single quotes ! idstring = string.split(identifier, "'") if len(idstring) == 1: # not in single quotes ! id = string.strip(idstring[0]) elif len(idstring) == 3: # quoted ! id = string.strip(idstring[1]) else: return failed if id == '': return failed ! parts = string.split(id, '.') # Protection for derived debuggers if parts[0] == 'self': --- 278,292 ---- failed = (None, None, None) # Input is identifier, may be in single quotes ! idstring = identifier.split("'") if len(idstring) == 1: # not in single quotes ! id = idstring[0].strip() elif len(idstring) == 3: # quoted ! id = idstring[1].strip() else: return failed if id == '': return failed ! parts = id.split('.') # Protection for derived debuggers if parts[0] == 'self': *************** *** 322,326 **** print 'End of file' return 0 ! line = string.strip(line) # Don't allow setting breakpoint at a blank line if ( not line or (line[0] == '#') or --- 320,324 ---- print 'End of file' return 0 ! line = line.strip() # Don't allow setting breakpoint at a blank line if ( not line or (line[0] == '#') or *************** *** 358,362 **** print 'end of file' return 0 ! line = string.strip(line) if not line: continue # Blank line if brackets <= 0 and line[0] not in ('#','"',"'"): --- 356,360 ---- print 'end of file' return 0 ! line = line.strip() if not line: continue # Blank line if brackets <= 0 and line[0] not in ('#','"',"'"): *************** *** 365,369 **** def do_enable(self, arg): ! args = string.split(arg) for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] --- 363,367 ---- def do_enable(self, arg): ! args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] *************** *** 372,376 **** def do_disable(self, arg): ! args = string.split(arg) for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] --- 370,374 ---- def do_disable(self, arg): ! args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] *************** *** 380,385 **** def do_condition(self, arg): # arg is breakpoint number and condition ! args = string.split(arg, ' ', 1) ! bpnum = int(string.strip(args[0])) try: cond = args[1] --- 378,383 ---- def do_condition(self, arg): # arg is breakpoint number and condition ! args = arg.split(' ', 1) ! bpnum = int(args[0].strip()) try: cond = args[1] *************** *** 395,402 **** def do_ignore(self,arg): """arg is bp number followed by ignore count.""" ! args = string.split(arg) ! bpnum = int(string.strip(args[0])) try: ! count = int(string.strip(args[1])) except: count = 0 --- 393,400 ---- def do_ignore(self,arg): """arg is bp number followed by ignore count.""" ! args = arg.split() ! bpnum = int(args[0].strip()) try: ! count = int(args[1].strip()) except: count = 0 *************** *** 425,429 **** except EOFError: reply = 'no' ! reply = string.lower(string.strip(reply)) if reply in ('y', 'yes'): self.clear_all_breaks() --- 423,427 ---- except EOFError: reply = 'no' ! reply = reply.strip().lower() if reply in ('y', 'yes'): self.clear_all_breaks() *************** *** 431,435 **** if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" ! i = string.rfind(arg, ':') filename = arg[:i] arg = arg[i+1:] --- 429,433 ---- if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" ! i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] *************** *** 442,446 **** if err: print '***', err return ! numberlist = string.split(arg) for i in numberlist: err = self.clear_bpbynumber(i) --- 440,444 ---- if err: print '***', err return ! numberlist = arg.split() for i in numberlist: err = self.clear_bpbynumber(i) *************** *** 569,573 **** break else: ! s = string.rjust(`lineno`, 3) if len(s) < 4: s = s + ' ' if lineno in breaklist: s = s + 'B' --- 567,571 ---- break else: ! s = `lineno`.rjust(3) if len(s) < 4: s = s + ' ' if lineno in breaklist: s = s + 'B' *************** *** 609,613 **** def do_alias(self, arg): ! args = string.split (arg) if len(args) == 0: keys = self.aliases.keys() --- 607,611 ---- def do_alias(self, arg): ! args = arg.split() if len(args) == 0: keys = self.aliases.keys() *************** *** 619,626 **** print "%s = %s" % (args[0], self.aliases[args[0]]) else: ! self.aliases[args[0]] = string.join(args[1:], ' ') def do_unalias(self, arg): ! args = string.split (arg) if len(args) == 0: return if self.aliases.has_key(args[0]): --- 617,624 ---- print "%s = %s" % (args[0], self.aliases[args[0]]) else: ! self.aliases[args[0]] = ' '.join(args[1:]) def do_unalias(self, arg): ! args = arg.split() if len(args) == 0: return if self.aliases.has_key(args[0]): From esr@users.sourceforge.net Fri Feb 9 08:17:39 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:17:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib dis.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18925 Modified Files: dis.py Log Message: String method conversion. Index: dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** dis.py 2001/02/01 22:48:12 1.32 --- dis.py 2001/02/09 08:17:37 1.33 *************** *** 2,6 **** import sys - import string import types --- 2,5 ---- *************** *** 70,75 **** if i in labels: print '>>', else: print ' ', ! print string.rjust(`i`, 4), ! print string.ljust(opname[op], 20), i = i+1 if op >= HAVE_ARGUMENT: --- 69,74 ---- if i in labels: print '>>', else: print ' ', ! print `i`.rjust(4), ! print opname[op].ljust(20), i = i+1 if op >= HAVE_ARGUMENT: *************** *** 79,83 **** if op == EXTENDED_ARG: extended_arg = oparg*65536L ! print string.rjust(`oparg`, 5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', --- 78,82 ---- if op == EXTENDED_ARG: extended_arg = oparg*65536L ! print `oparg`.rjust(5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', From esr@users.sourceforge.net Fri Feb 9 08:21:19 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:21:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib htmllib.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19366 Modified Files: htmllib.py Log Message: String method conversion. Index: htmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/htmllib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** htmllib.py 2001/01/23 15:35:05 1.16 --- htmllib.py 2001/02/09 08:21:17 1.17 *************** *** 6,10 **** - import string from sgmllib import SGMLParser from formatter import AS_IS --- 6,9 ---- *************** *** 51,55 **** self.savedata = None if not self.nofill: ! data = string.join(string.split(data)) return data --- 50,54 ---- self.savedata = None if not self.nofill: ! data = ' '.join(data.split()) return data *************** *** 322,326 **** type = '' for attrname, value in attrs: ! value = string.strip(value) if attrname == 'href': href = value --- 321,325 ---- type = '' for attrname, value in attrs: ! value = value.strip() if attrname == 'href': href = value *************** *** 328,332 **** name = value if attrname == 'type': ! type = string.lower(value) self.anchor_bgn(href, name, type) --- 327,331 ---- name = value if attrname == 'type': ! type = value.lower() self.anchor_bgn(href, name, type) *************** *** 363,370 **** src = value if attrname == 'width': ! try: width = string.atoi(value) except: pass if attrname == 'height': ! try: height = string.atoi(value) except: pass self.handle_image(src, alt, ismap, align, width, height) --- 362,369 ---- src = value if attrname == 'width': ! try: width = int(value) except: pass if attrname == 'height': ! try: height = int(value) except: pass self.handle_image(src, alt, ismap, align, width, height) From esr@users.sourceforge.net Fri Feb 9 08:25:31 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:25:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pstats.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20087 Modified Files: pstats.py Log Message: String method conversion. Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** pstats.py 2001/01/15 00:50:52 1.9 --- pstats.py 2001/02/09 08:25:29 1.10 *************** *** 35,39 **** import os import time - import string import marshal import re --- 35,38 ---- *************** *** 393,401 **** def print_call_heading(self, name_size, column_title): ! print string.ljust("Function ", name_size) + column_title def print_call_line(self, name_size, source, call_dict): ! print string.ljust(func_std_string(source), name_size), if not call_dict: print "--" --- 392,400 ---- def print_call_heading(self, name_size, column_title): ! print "Function ".ljust(name_size) + column_title def print_call_line(self, name_size, source, call_dict): ! print func_std_string(source).ljust(name_size), if not call_dict: print "--" *************** *** 415,423 **** def print_title(self): ! print string.rjust('ncalls', 9), ! print string.rjust('tottime', 8), ! print string.rjust('percall', 8), ! print string.rjust('cumtime', 8), ! print string.rjust('percall', 8), print 'filename:lineno(function)' --- 414,422 ---- def print_title(self): ! print 'ncalls'.rjust(9), ! print 'tottime'.rjust(8), ! print 'percall'.rjust(8), ! print 'cumtime'.rjust(8), ! print 'percall'.rjust(8), print 'filename:lineno(function)' *************** *** 428,432 **** if nc != cc: c = c + '/' + `cc` ! print string.rjust(c, 9), print f8(tt), if nc == 0: --- 427,431 ---- if nc != cc: c = c + '/' + `cc` ! print c.rjust(9), print f8(tt), if nc == 0: *************** *** 523,525 **** def f8(x): ! return string.rjust(fpformat.fix(x, 3), 8) --- 522,524 ---- def f8(x): ! return fpformat.fix(x, 3).rjust(8) From esr@users.sourceforge.net Fri Feb 9 08:33:46 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:33:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib doctest.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21013 Modified Files: doctest.py Log Message: String method conversion. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** doctest.py 2001/01/20 23:34:12 1.2 --- doctest.py 2001/02/09 08:33:43 1.3 *************** *** 1,3 **** ! # Module doctest version 0.9.6 # Released to the public domain 16-Jan-2001, # by Tim Peters (tim.one@home.com). --- 1,3 ---- ! # Module doctest version 0.9.7 # Released to the public domain 16-Jan-2001, # by Tim Peters (tim.one@home.com). *************** *** 346,349 **** --- 346,351 ---- # language changes, and running doctest on itself pointed that out. # Hard to think of a better example of why this is useful . + # 0,9,7 9-Feb-2001 + # string method conversion __version__ = 0, 9, 6 *************** *** 356,366 **** del types - import string - _string_find = string.find - _string_join = string.join - _string_split = string.split - _string_rindex = string.rindex - del string - import re PS1 = ">>>" --- 358,361 ---- *************** *** 385,389 **** isEmpty, isComment = _isEmpty, _isComment examples = [] ! lines = _string_split(s, "\n") i, n = 0, len(lines) while i < n: --- 380,384 ---- isEmpty, isComment = _isEmpty, _isComment examples = [] ! lines = s.split("\n") i, n = 0, len(lines) while i < n: *************** *** 423,427 **** if source[-1] == "": del source[-1] ! source = _string_join(source, "\n") + "\n" # suck up response if isPS1(line) or isEmpty(line): --- 418,422 ---- if source[-1] == "": del source[-1] ! source = "\n".join(source) + "\n" # suck up response if isPS1(line) or isEmpty(line): *************** *** 438,442 **** if isPS1(line) or isEmpty(line): break ! expect = _string_join(expect, "\n") + "\n" examples.append( (source, expect, lineno) ) return examples --- 433,437 ---- if isPS1(line) or isEmpty(line): break ! expect = "\n".join(expect) + "\n" examples.append( (source, expect, lineno) ) return examples *************** *** 450,454 **** self.buf.append(s) def get(self): ! return _string_join(self.buf, "") def clear(self): self.buf = [] --- 445,449 ---- self.buf.append(s) def get(self): ! return "".join(self.buf) def clear(self): self.buf = [] *************** *** 465,469 **** msg_has_nl = msg[-1:] == "\n" msg_has_two_nl = msg_has_nl and \ ! _string_find(msg, "\n") < len(msg) - 1 if len(tag) + len(msg) < 76 and not msg_has_two_nl: printer(" ") --- 460,464 ---- msg_has_nl = msg[-1:] == "\n" msg_has_two_nl = msg_has_nl and \ ! msg.find("\n") < len(msg) - 1 if len(tag) + len(msg) < 76 and not msg_has_two_nl: printer(" ") *************** *** 495,502 **** except: # See whether the exception was expected. ! if _string_find(want, "Traceback (innermost last):\n") == 0: # Only compare exception type and value - the rest of # the traceback isn't necessary. ! want = _string_split(want, '\n')[-2] + '\n' exc_type, exc_val, exc_tb = sys.exc_info() got = traceback.format_exception_only(exc_type, exc_val)[0] --- 490,497 ---- except: # See whether the exception was expected. ! if want.find("Traceback (innermost last):\n") == 0: # Only compare exception type and value - the rest of # the traceback isn't necessary. ! want = want.split('\n')[-2] + '\n' exc_type, exc_val, exc_tb = sys.exc_info() got = traceback.format_exception_only(exc_type, exc_val)[0] *************** *** 961,965 **** def __runone(self, target, name): if "." in name: ! i = _string_rindex(name, ".") prefix, base = name[:i], name[i+1:] else: --- 956,960 ---- def __runone(self, target, name): if "." in name: ! i = name.rindex(".") prefix, base = name[:i], name[i+1:] else: From esr@users.sourceforge.net Fri Feb 9 08:40:43 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:40:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib robotparser.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21719 Modified Files: robotparser.py Log Message: String method conversion. Index: robotparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** robotparser.py 2001/01/21 04:49:16 1.6 --- robotparser.py 2001/02/09 08:40:40 1.7 *************** *** 10,14 **** http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html """ ! import re,string,urlparse,urllib __all__ = ["RobotFileParser"] --- 10,14 ---- http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html """ ! import re,urlparse,urllib __all__ = ["RobotFileParser"] *************** *** 72,76 **** for line in lines: ! line = string.strip(line) linenumber = linenumber + 1 if not line: --- 72,76 ---- for line in lines: ! line = line.strip() linenumber = linenumber + 1 if not line: *************** *** 86,99 **** state = 0 # remove optional comment and strip line ! i = string.find(line, '#') if i>=0: line = line[:i] ! line = string.strip(line) if not line: continue ! line = string.split(line, ':', 1) if len(line) == 2: ! line[0] = string.lower(string.strip(line[0])) ! line[1] = string.strip(line[1]) if line[0] == "user-agent": if state==2: --- 86,99 ---- state = 0 # remove optional comment and strip line ! i = line.find('#') if i>=0: line = line[:i] ! line = line.strip() if not line: continue ! line = line.split(':', 1) if len(line) == 2: ! line[0] = line[0].strip().lower() ! line[1] = line[1].strip() if line[0] == "user-agent": if state==2: *************** *** 137,141 **** # search for given user agent matches # the first match counts ! useragent = string.lower(useragent) url = urllib.quote(urlparse.urlparse(url)[2]) for entry in self.entries: --- 137,141 ---- # search for given user agent matches # the first match counts ! useragent = useragent.lower() url = urllib.quote(urlparse.urlparse(url)[2]) for entry in self.entries: From esr@users.sourceforge.net Fri Feb 9 08:46:29 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:46:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib CGIHTTPServer.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22244 Modified Files: CGIHTTPServer.py Log Message: String method conversion. Index: CGIHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** CGIHTTPServer.py 2001/01/20 19:54:20 1.15 --- CGIHTTPServer.py 2001/02/09 08:46:26 1.16 *************** *** 104,113 **** """Execute a CGI script.""" dir, rest = self.cgi_info ! i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' ! i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] --- 104,113 ---- """Execute a CGI script.""" dir, rest = self.cgi_info ! i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' ! i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] *************** *** 166,173 **** for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: ! accept.append(string.strip(line)) else: ! accept = accept + string.split(line[7:], ',') ! env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: --- 166,173 ---- for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: ! accept.append(line.strip()) else: ! accept = accept + line[7:].split(',') ! env['HTTP_ACCEPT'] = ','.join(accept) ua = self.headers.getheader('user-agent') if ua: *************** *** 175,179 **** co = filter(None, self.headers.getheaders('cookie')) if co: ! env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers if not self.have_fork: --- 175,179 ---- co = filter(None, self.headers.getheaders('cookie')) if co: ! env['HTTP_COOKIE'] = ', '.join(co) # XXX Other HTTP_* headers if not self.have_fork: *************** *** 186,190 **** self.send_response(200, "Script output follows") ! decoded_query = string.replace(query, '+', ' ') if self.have_fork: --- 186,190 ---- self.send_response(200, "Script output follows") ! decoded_query = query.replace('+', ' ') if self.have_fork: From esr@users.sourceforge.net Fri Feb 9 08:49:13 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:49:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib py_compile.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22529 Modified Files: py_compile.py Log Message: String method conversion. Index: py_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/py_compile.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** py_compile.py 2000/09/15 06:57:26 1.16 --- py_compile.py 2001/02/09 08:49:11 1.17 *************** *** 60,67 **** codeobject = __builtin__.compile(codestring, dfile or file, 'exec') except SyntaxError, detail: ! import traceback, sys, string lines = traceback.format_exception_only(SyntaxError, detail) for line in lines: ! sys.stderr.write(string.replace(line, 'File ""', 'File "%s"' % (dfile or file))) return --- 60,67 ---- codeobject = __builtin__.compile(codestring, dfile or file, 'exec') except SyntaxError, detail: ! import traceback, sys lines = traceback.format_exception_only(SyntaxError, detail) for line in lines: ! sys.stderr.write(line.replace('File ""', 'File "%s"' % (dfile or file))) return From esr@users.sourceforge.net Fri Feb 9 08:53:10 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:53:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib repr.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22798 Modified Files: repr.py Log Message: String method conversion. Index: repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/repr.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** repr.py 2001/01/15 01:18:21 1.7 --- repr.py 2001/02/09 08:53:08 1.8 *************** *** 1,6 **** """Redo the `...` (representation) but with limits on most sizes.""" - import string - class Repr: def __init__(self): --- 1,4 ---- *************** *** 17,22 **** typename = `type(x)`[7:-2] # "" if ' ' in typename: ! parts = string.split(typename) ! typename = string.joinfields(parts, '_') if hasattr(self, 'repr_' + typename): return getattr(self, 'repr_' + typename)(x, level) --- 15,20 ---- typename = `type(x)`[7:-2] # "" if ' ' in typename: ! parts = typename.split() ! typename = '_'.join(parts) if hasattr(self, 'repr_' + typename): return getattr(self, 'repr_' + typename)(x, level) From esr@users.sourceforge.net Fri Feb 9 08:55:16 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:55:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib codeop.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22966 Modified Files: codeop.py Log Message: String method conversion. Index: codeop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codeop.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** codeop.py 2001/01/20 19:54:20 1.2 --- codeop.py 2001/02/09 08:55:14 1.3 *************** *** 2,6 **** import sys - import string import traceback --- 2,5 ---- *************** *** 50,55 **** # Check for source consisting of only blank lines and comments ! for line in string.split(source, "\n"): ! line = string.strip(line) if line and line[0] != '#': break # Leave it alone --- 49,54 ---- # Check for source consisting of only blank lines and comments ! for line in source.split("\n"): ! line = line.strip() if line and line[0] != '#': break # Leave it alone From esr@users.sourceforge.net Fri Feb 9 08:56:32 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 00:56:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib code.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23087 Modified Files: code.py Log Message: String method conversion. Index: code.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** code.py 2001/01/20 19:54:20 1.14 --- code.py 2001/02/09 08:56:30 1.15 *************** *** 7,11 **** import sys - import string import traceback from codeop import compile_command --- 7,10 ---- *************** *** 261,265 **** """ self.buffer.append(line) ! source = string.join(self.buffer, "\n") more = self.runsource(source, self.filename) if not more: --- 260,264 ---- """ self.buffer.append(line) ! source = "\n".join(self.buffer) more = self.runsource(source, self.filename) if not more: From esr@users.sourceforge.net Fri Feb 9 09:05:57 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:05:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib gzip.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26159 Modified Files: gzip.py Log Message: String method conversion. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** gzip.py 2001/01/23 15:35:05 1.21 --- gzip.py 2001/02/09 09:05:55 1.22 *************** *** 6,10 **** # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import string, struct, sys, time import zlib import __builtin__ --- 6,10 ---- # based on Andrew Kuchling's minigzip.py distributed with the zlib module ! import struct, sys, time import zlib import __builtin__ *************** *** 139,143 **** def writelines(self,lines): ! self.write(string.join(lines)) def read(self, size=-1): --- 139,143 ---- def writelines(self,lines): ! self.write(" ".join(lines)) def read(self, size=-1): *************** *** 282,289 **** while 1: if size == 0: ! return string.join(bufs, '') # Return resulting line c = self.read(readsize) ! i = string.find(c, '\n') if size is not None: # We set i=size to break out of the loop under two --- 282,289 ---- while 1: if size == 0: ! return "".join(bufs) # Return resulting line c = self.read(readsize) ! i = c.find('\n') if size is not None: # We set i=size to break out of the loop under two *************** *** 297,301 **** bufs.append(c[:i+1]) # Add portion of last chunk self._unread(c[i+1:]) # Push back rest of chunk ! return string.join(bufs, '') # Return resulting line # Append chunk to list, decrease 'size', --- 297,301 ---- bufs.append(c[:i+1]) # Add portion of last chunk self._unread(c[i+1:]) # Push back rest of chunk ! return ''.join(bufs) # Return resulting line # Append chunk to list, decrease 'size', From esr@users.sourceforge.net Fri Feb 9 09:10:37 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:10:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib keyword.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv27124 Modified Files: keyword.py Log Message: String method conversion. Index: keyword.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/keyword.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** keyword.py 2001/01/24 06:27:27 1.9 --- keyword.py 2001/02/09 09:10:35 1.10 *************** *** 53,57 **** def main(): ! import sys, re, string args = sys.argv[1:] --- 53,57 ---- def main(): ! import sys, re args = sys.argv[1:] *************** *** 67,71 **** line = fp.readline() if not line: break ! if string.find(line, '{1, "') > -1: match = strprog.search(line) if match: --- 67,71 ---- line = fp.readline() if not line: break ! if line.find('{1, "') > -1: match = strprog.search(line) if match: *************** *** 90,94 **** # write the output file fp = open(optfile, 'w') ! fp.write(string.join(format, '')) fp.close() --- 90,94 ---- # write the output file fp = open(optfile, 'w') ! fp.write(''.join(format)) fp.close() From esr@users.sourceforge.net Fri Feb 9 09:17:41 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:17:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mhlib.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28571 Modified Files: mhlib.py Log Message: String method conversion. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** mhlib.py 2001/01/24 06:27:27 1.23 --- mhlib.py 2001/02/09 09:17:38 1.24 *************** *** 217,221 **** protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): ! mode = string.atoi(protect, 8) else: mode = FOLDER_PROTECT --- 217,221 ---- protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): ! mode = int(protect, 8) else: mode = FOLDER_PROTECT *************** *** 287,291 **** if match(name): append(name) ! messages = map(string.atoi, messages) messages.sort() if messages: --- 287,291 ---- if match(name): append(name) ! messages = map(int, messages) messages.sort() if messages: *************** *** 306,315 **** line = f.readline() if not line: break ! fields = string.splitfields(line, ':') if len(fields) != 2: self.error('bad sequence in %s: %s' % ! (fullname, string.strip(line))) ! key = string.strip(fields[0]) ! value = IntSet(string.strip(fields[1]), ' ').tolist() sequences[key] = value return sequences --- 306,315 ---- line = f.readline() if not line: break ! fields = line.split(':') if len(fields) != 2: self.error('bad sequence in %s: %s' % ! (fullname, line.strip())) ! key = fields[0].strip() ! value = IntSet(fields[1].strip(), ' ').tolist() sequences[key] = value return sequences *************** *** 361,365 **** return all # Test for X:Y before X-Y because 'seq:-n' matches both ! i = string.find(seq, ':') if i >= 0: head, dir, tail = seq[:i], '', seq[i+1:] --- 361,365 ---- return all # Test for X:Y before X-Y because 'seq:-n' matches both ! i = seq.find(':') if i >= 0: head, dir, tail = seq[:i], '', seq[i+1:] *************** *** 369,373 **** raise Error, "bad message list %s" % seq try: ! count = string.atoi(tail) except (ValueError, OverflowError): # Can't use sys.maxint because of i+count below --- 369,373 ---- raise Error, "bad message list %s" % seq try: ! count = int(tail) except (ValueError, OverflowError): # Can't use sys.maxint because of i+count below *************** *** 399,403 **** return all[i:i+count] # Test for X-Y next ! i = string.find(seq, '-') if i >= 0: begin = self._parseindex(seq[:i], all) --- 399,403 ---- return all[i:i+count] # Test for X-Y next ! i = seq.find('-') if i >= 0: begin = self._parseindex(seq[:i], all) *************** *** 432,436 **** if isnumeric(seq): try: ! return string.atoi(seq) except (OverflowError, ValueError): return sys.maxint --- 432,436 ---- if isnumeric(seq): try: ! return int(seq) except (OverflowError, ValueError): return sys.maxint *************** *** 682,695 **** name converted to lower case).""" if not pred: ! return string.joinfields(self.headers, '') headers = [] hit = 0 for line in self.headers: if line[0] not in string.whitespace: ! i = string.find(line, ':') if i > 0: ! hit = pred(string.lower(line[:i])) if hit: headers.append(line) ! return string.joinfields(headers, '') def getbodytext(self, decode = 1): --- 682,695 ---- name converted to lower case).""" if not pred: ! return ''.join(self.headers) headers = [] hit = 0 for line in self.headers: if line[0] not in string.whitespace: ! i = line.find(':') if i > 0: ! hit = pred(line[:i].lower()) if hit: headers.append(line) ! return ''.joinfields(headers) def getbodytext(self, decode = 1): *************** *** 888,896 **** import string new = [] ! for part in string.splitfields(data, self.sep): list = [] ! for subp in string.splitfields(part, self.rng): ! s = string.strip(subp) ! list.append(string.atoi(s)) if len(list) == 1: new.append((list[0], list[0])) --- 888,896 ---- import string new = [] ! for part in data.split(self.sep): list = [] ! for subp in part.split(self.rng): ! s = subp.strip() ! list.append(int(s)) if len(list) == 1: new.append((list[0], list[0])) *************** *** 922,926 **** break text = text + line ! return string.strip(text) return None --- 922,926 ---- break text = text + line ! return text.strip() return None *************** *** 997,1001 **** print "Error:", msg stuff = os.popen("pick %s 2>/dev/null" % `seq`).read() ! list = map(string.atoi, string.split(stuff)) print list, "<-- pick" do('f.listmessages()') --- 997,1001 ---- print "Error:", msg stuff = os.popen("pick %s 2>/dev/null" % `seq`).read() ! list = map(int, stuff.split()) print list, "<-- pick" do('f.listmessages()') From esr@users.sourceforge.net Fri Feb 9 09:19:29 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:19:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib regsub.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28731 Modified Files: regsub.py Log Message: String method conversion. Index: regsub.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/regsub.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** regsub.py 2001/01/15 01:18:21 1.10 --- regsub.py 2001/02/09 09:19:27 1.11 *************** *** 108,116 **** def capwords(str, pat='[^a-zA-Z0-9_]+'): - import string words = splitx(str, pat) for i in range(0, len(words), 2): ! words[i] = string.capitalize(words[i]) ! return string.joinfields(words, "") --- 108,115 ---- def capwords(str, pat='[^a-zA-Z0-9_]+'): words = splitx(str, pat) for i in range(0, len(words), 2): ! words[i] = words[i].capitalize() ! return "".joinfields(words) From esr@users.sourceforge.net Fri Feb 9 09:21:03 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:21:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib regsub.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28878 Modified Files: regsub.py Log Message: Oops...that will teach me to hit ^C^C too fast. Test passed. Index: regsub.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/regsub.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** regsub.py 2001/02/09 09:19:27 1.11 --- regsub.py 2001/02/09 09:21:01 1.12 *************** *** 111,115 **** for i in range(0, len(words), 2): words[i] = words[i].capitalize() ! return "".joinfields(words) --- 111,115 ---- for i in range(0, len(words), 2): words[i] = words[i].capitalize() ! return "".join(words) From esr@users.sourceforge.net Fri Feb 9 09:32:11 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:32:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pyclbr.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30808 Modified Files: pyclbr.py Log Message: String method conversion. Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** pyclbr.py 2001/01/15 00:50:52 1.16 --- pyclbr.py 2001/02/09 09:32:08 1.17 *************** *** 161,169 **** dict = {} ! i = string.rfind(module, '.') if i >= 0: # Dotted module name ! package = string.strip(module[:i]) ! submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) --- 161,169 ---- dict = {} ! i = module.rfind('.') if i >= 0: # Dotted module name ! package = module[:i].strip() ! submodule = module[i+1:].strip() parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) *************** *** 261,273 **** if inherit: # the class inherits from other classes ! inherit = string.strip(inherit[1:-1]) names = [] ! for n in string.splitfields(inherit, ','): ! n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: ! c = string.splitfields(n, '.') if len(c) > 1: # super class --- 261,273 ---- if inherit: # the class inherits from other classes ! inherit = inherit[1:-1].strip() names = [] ! for n in inherit.split(','): ! n = n.strip() if dict.has_key(n): # we know this super class n = dict[n] else: ! c = n.split('.') if len(c) > 1: # super class *************** *** 292,297 **** elif m.start("Import") >= 0: # import module ! for n in string.split(m.group("ImportList"), ','): ! n = string.strip(n) try: # recursively read the imported module --- 292,297 ---- elif m.start("Import") >= 0: # import module ! for n in m.group("ImportList").split(','): ! n = n.strip() try: # recursively read the imported module *************** *** 304,308 **** # from module import stuff mod = m.group("ImportFromPath") ! names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module --- 304,308 ---- # from module import stuff mod = m.group("ImportFromPath") ! names = m.group("ImportFromList").split(',') try: # recursively read the imported module *************** *** 315,319 **** # were mentioned in the list for n in names: ! n = string.strip(n) if d.has_key(n): dict[n] = d[n] --- 315,319 ---- # were mentioned in the list for n in names: ! n = n.strip() if d.has_key(n): dict[n] = d[n] *************** *** 335,336 **** --- 335,337 ---- def _indent(ws, _expandtabs=string.expandtabs): return len(_expandtabs(ws, TABWIDTH)) + From esr@users.sourceforge.net Fri Feb 9 09:34:38 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:34:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib MimeWriter.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31226 Modified Files: MimeWriter.py Log Message: String method conversion. Index: MimeWriter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/MimeWriter.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** MimeWriter.py 2001/01/20 19:54:20 1.6 --- MimeWriter.py 2001/02/09 09:34:36 1.7 *************** *** 8,12 **** - import string import mimetools --- 8,11 ---- *************** *** 88,97 **** def addheader(self, key, value, prefix=0): ! lines = string.splitfields(value, "\n") while lines and not lines[-1]: del lines[-1] while lines and not lines[0]: del lines[0] for i in range(1, len(lines)): ! lines[i] = " " + string.strip(lines[i]) ! value = string.joinfields(lines, "\n") + "\n" line = key + ": " + value if prefix: --- 87,96 ---- def addheader(self, key, value, prefix=0): ! lines = value.split("\n") while lines and not lines[-1]: del lines[-1] while lines and not lines[0]: del lines[0] for i in range(1, len(lines)): ! lines[i] = " " + lines[i].strip() ! value = "\n".join(lines) + "\n" line = key + ": " + value if prefix: From esr@users.sourceforge.net Fri Feb 9 09:37:34 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:37:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib traceback.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31784 Modified Files: traceback.py Log Message: String method conversion. Index: traceback.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** traceback.py 2001/01/15 03:26:36 1.19 --- traceback.py 2001/02/09 09:37:32 1.20 *************** *** 19,23 **** ' File "%s", line %d, in %s' % (filename,lineno,name)) if line: ! _print(file, ' %s' % string.strip(line)) def format_list(extracted_list): --- 19,23 ---- ' File "%s", line %d, in %s' % (filename,lineno,name)) if line: ! _print(file, ' %s' % line.strip()) def format_list(extracted_list): *************** *** 32,36 **** item = ' File "%s", line %d, in %s\n' % (filename,lineno,name) if line: ! item = item + ' %s\n' % string.strip(line) list.append(item) return list --- 32,36 ---- item = ' File "%s", line %d, in %s\n' % (filename,lineno,name) if line: ! item = item + ' %s\n' % line.strip() list.append(item) return list *************** *** 57,61 **** ' File "%s", line %d, in %s' % (filename,lineno,name)) line = linecache.getline(filename, lineno) ! if line: _print(file, ' ' + string.strip(line)) tb = tb.tb_next n = n+1 --- 57,61 ---- ' File "%s", line %d, in %s' % (filename,lineno,name)) line = linecache.getline(filename, lineno) ! if line: _print(file, ' ' + line.strip()) tb = tb.tb_next n = n+1 *************** *** 86,90 **** name = co.co_name line = linecache.getline(filename, lineno) ! if line: line = string.strip(line) else: line = None list.append((filename, lineno, name, line)) --- 86,90 ---- name = co.co_name line = linecache.getline(filename, lineno) ! if line: line = line.strip() else: line = None list.append((filename, lineno, name, line)) *************** *** 158,162 **** line[i] in string.whitespace: i = i+1 ! list.append(' %s\n' % string.strip(line)) s = ' ' for c in line[i:offset-1]: --- 158,162 ---- line[i] in string.whitespace: i = i+1 ! list.append(' %s\n' % line.strip()) s = ' ' for c in line[i:offset-1]: *************** *** 247,251 **** name = co.co_name line = linecache.getline(filename, lineno) ! if line: line = string.strip(line) else: line = None list.append((filename, lineno, name, line)) --- 247,251 ---- name = co.co_name line = linecache.getline(filename, lineno) ! if line: line = line.strip() else: line = None list.append((filename, lineno, name, line)) From esr@users.sourceforge.net Fri Feb 9 09:39:10 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:39:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pre.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32119 Modified Files: pre.py Log Message: String method conversion. Index: pre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pre.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pre.py 2001/01/15 00:50:52 1.4 --- pre.py 2001/02/09 09:39:08 1.5 *************** *** 230,234 **** if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char ! return string.join(result, '') def compile(pattern, flags=0): --- 230,234 ---- if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char ! return ''.join(result) def compile(pattern, flags=0): *************** *** 399,403 **** n = n + 1 append(source[pos:]) ! return (string.join(results, ''), n) def split(self, source, maxsplit=0): --- 399,403 ---- n = n + 1 append(source[pos:]) ! return (''.join(results), n) def split(self, source, maxsplit=0): From esr@users.sourceforge.net Fri Feb 9 09:44:49 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:44:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimetypes.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv451 Modified Files: mimetypes.py Log Message: String method conversion. Added a trivial main to test it with. Index: mimetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetypes.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** mimetypes.py 2001/01/25 15:29:22 1.12 --- mimetypes.py 2001/02/09 09:44:47 1.13 *************** *** 24,28 **** """ - import string import posixpath import urllib --- 24,27 ---- *************** *** 65,73 **** # parameter := attribute "=" value # type/subtype defaults to "text/plain" ! comma = string.find(url, ',') if comma < 0: # bad data URL return None, None ! semi = string.find(url, ';', 0, comma) if semi >= 0: type = url[:semi] --- 64,72 ---- # parameter := attribute "=" value # type/subtype defaults to "text/plain" ! comma = url.find(',') if comma < 0: # bad data URL return None, None ! semi = url.find(';', 0, comma) if semi >= 0: type = url[:semi] *************** *** 87,92 **** if types_map.has_key(ext): return types_map[ext], encoding ! elif types_map.has_key(string.lower(ext)): ! return types_map[string.lower(ext)], encoding else: return None, encoding --- 86,91 ---- if types_map.has_key(ext): return types_map[ext], encoding ! elif types_map.has_key(ext.lower()): ! return types_map[ext.lower()], encoding else: return None, encoding *************** *** 104,108 **** if not inited: init() ! type = string.lower(type) for ext, stype in types_map.items(): if type == stype: --- 103,107 ---- if not inited: init() ! type = type.lower() for ext, stype in types_map.items(): if type == stype: *************** *** 128,132 **** line = f.readline() if not line: break ! words = string.split(line) for i in range(len(words)): if words[i][0] == '#': --- 127,131 ---- line = f.readline() if not line: break ! words = line.split() for i in range(len(words)): if words[i][0] == '#': *************** *** 238,239 **** --- 237,242 ---- '.zip': 'application/zip', } + + if __name__ == '__main__': + import sys + print guess_type(sys.argv[1]) From esr@users.sourceforge.net Fri Feb 9 09:46:44 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:46:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib knee.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv919 Modified Files: knee.py Log Message: String method conversion. Index: knee.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/knee.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** knee.py 1998/03/26 21:12:20 1.4 --- knee.py 2001/02/09 09:46:42 1.5 *************** *** 8,12 **** """ ! import sys, imp, __builtin__, string --- 8,12 ---- """ ! import sys, imp, __builtin__ *************** *** 31,35 **** return parent if '.' in pname: ! i = string.rfind(pname, '.') pname = pname[:i] parent = sys.modules[pname] --- 31,35 ---- return parent if '.' in pname: ! i = pname.rfind('.') pname = pname[:i] parent = sys.modules[pname] *************** *** 40,44 **** def find_head_package(parent, name): if '.' in name: ! i = string.find(name, '.') head = name[:i] tail = name[i+1:] --- 40,44 ---- def find_head_package(parent, name): if '.' in name: ! i = name.find('.') head = name[:i] tail = name[i+1:] *************** *** 62,66 **** m = q while tail: ! i = string.find(tail, '.') if i < 0: i = len(tail) head, tail = tail[:i], tail[i+1:] --- 62,66 ---- m = q while tail: ! i = tail.find('.') if i < 0: i = len(tail) head, tail = tail[:i], tail[i+1:] *************** *** 112,116 **** if '.' not in name: return import_module(name, name, None) ! i = string.rfind(name, '.') pname = name[:i] parent = sys.modules[pname] --- 112,116 ---- if '.' not in name: return import_module(name, name, None) ! i = name.rfind('.') pname = name[:i] parent = sys.modules[pname] From esr@users.sourceforge.net Fri Feb 9 09:48:47 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:48:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib macurl2path.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1178 Modified Files: macurl2path.py Log Message: String method conversion. Index: macurl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macurl2path.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** macurl2path.py 2001/01/24 06:27:27 1.10 --- macurl2path.py 2001/02/09 09:48:45 1.11 *************** *** 3,7 **** Do not import directly; use urllib instead.""" - import string import urllib import os --- 3,6 ---- *************** *** 22,26 **** elif pathname[:2] == '//': raise RuntimeError, 'Cannot convert non-local URL to pathname' ! components = string.split(pathname, '/') # Remove . and embedded .. i = 0 --- 21,25 ---- elif pathname[:2] == '//': raise RuntimeError, 'Cannot convert non-local URL to pathname' ! components = pathname.split('/') # Remove . and embedded .. i = 0 *************** *** 38,42 **** if not components[0]: # Absolute unix path, don't start with colon ! rv = string.join(components[1:], ':') else: # relative unix path, start with colon. First replace --- 37,41 ---- if not components[0]: # Absolute unix path, don't start with colon ! rv = ':'.join(components[1:]) else: # relative unix path, start with colon. First replace *************** *** 46,50 **** components[i] = '' i = i + 1 ! rv = ':' + string.join(components, ':') # and finally unquote slashes and other funny characters return urllib.unquote(rv) --- 45,49 ---- components[i] = '' i = i + 1 ! rv = ':' + ':'.join(components) # and finally unquote slashes and other funny characters return urllib.unquote(rv) *************** *** 54,58 **** if '/' in pathname: raise RuntimeError, "Cannot convert pathname containing slashes" ! components = string.split(pathname, ':') # Remove empty first and/or last component if components[0] == '': --- 53,57 ---- if '/' in pathname: raise RuntimeError, "Cannot convert pathname containing slashes" ! components = pathname.split(':') # Remove empty first and/or last component if components[0] == '': *************** *** 68,74 **** if os.path.isabs(pathname): ! return '/' + string.join(components, '/') else: ! return string.join(components, '/') def _pncomp2url(component): --- 67,73 ---- if os.path.isabs(pathname): ! return '/' + '/'.join(components) else: ! return '/'.join(components) def _pncomp2url(component): From lemburg@users.sourceforge.net Fri Feb 9 09:59:08 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 09 Feb 2001 01:59:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv2704/Misc Modified Files: ACKS Log Message: Patches for AIX. Checked by Benjamin Collar. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -r1.79 -r1.80 *** ACKS 2001/02/09 07:02:22 1.79 --- ACKS 2001/02/09 09:59:06 1.80 *************** *** 74,77 **** --- 74,78 ---- Steve Clift Dave Cole + Benjamin Collar Jeffery Collins Matt Conway From lemburg@users.sourceforge.net Fri Feb 9 09:59:08 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 09 Feb 2001 01:59:08 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.199,1.200 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv2704 Modified Files: configure.in Log Message: Patches for AIX. Checked by Benjamin Collar. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.199 retrieving revision 1.200 diff -C2 -r1.199 -r1.200 *** configure.in 2001/01/27 21:39:17 1.199 --- configure.in 2001/02/09 09:59:05 1.200 *************** *** 226,230 **** case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";; --- 226,230 ---- case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";; *************** *** 533,537 **** then case $ac_sys_system/$ac_sys_release in ! AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";; BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";; IRIX/5*) LDSHARED="ld -shared";; --- 533,537 ---- then case $ac_sys_system/$ac_sys_release in ! AIX*) LDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC)";; BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";; IRIX/5*) LDSHARED="ld -shared";; From esr@users.sourceforge.net Fri Feb 9 09:59:12 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 01:59:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2858 Modified Files: cgi.py Log Message: String method conversion. Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -r1.59 -r1.60 *** cgi.py 2001/01/20 19:54:20 1.59 --- cgi.py 2001/02/09 09:59:10 1.60 *************** *** 26,30 **** # ======= - import string import sys import os --- 26,29 ---- *************** *** 126,130 **** return parse_multipart(fp, pdict) elif ctype == 'application/x-www-form-urlencoded': ! clength = string.atoi(environ['CONTENT_LENGTH']) if maxlen and clength > maxlen: raise ValueError, 'Maximum content length exceeded' --- 125,129 ---- return parse_multipart(fp, pdict) elif ctype == 'application/x-www-form-urlencoded': ! clength = int(environ['CONTENT_LENGTH']) if maxlen and clength > maxlen: raise ValueError, 'Maximum content length exceeded' *************** *** 204,209 **** continue if len(nv[1]) or keep_blank_values: ! name = urllib.unquote(string.replace(nv[0], '+', ' ')) ! value = urllib.unquote(string.replace(nv[1], '+', ' ')) r.append((name, value)) --- 203,208 ---- continue if len(nv[1]) or keep_blank_values: ! name = urllib.unquote(nv[0].replace('+', ' ')) ! value = urllib.unquote(nv[1].replace('+', ' ')) r.append((name, value)) *************** *** 250,255 **** if clength: try: ! bytes = string.atoi(clength) ! except string.atoi_error: pass if bytes > 0: --- 249,254 ---- if clength: try: ! bytes = int(clength) ! except ValueError: pass if bytes > 0: *************** *** 267,271 **** break if line[:2] == "--": ! terminator = string.strip(line) if terminator in (nextpart, lastpart): break --- 266,270 ---- break if line[:2] == "--": ! terminator = line.strip() if terminator in (nextpart, lastpart): break *************** *** 283,287 **** line = line[:-1] lines[-1] = line ! data = string.joinfields(lines, "") line = headers['content-disposition'] if not line: --- 282,286 ---- line = line[:-1] lines[-1] = line ! data = "".join(lines) line = headers['content-disposition'] if not line: *************** *** 308,320 **** """ ! plist = map(string.strip, string.splitfields(line, ';')) ! key = string.lower(plist[0]) del plist[0] pdict = {} for p in plist: ! i = string.find(p, '=') if i >= 0: ! name = string.lower(string.strip(p[:i])) ! value = string.strip(p[i+1:]) if len(value) >= 2 and value[0] == value[-1] == '"': value = value[1:-1] --- 307,319 ---- """ ! plist = map(lambda x: x.strip(), line.split(';')) ! key = plist[0].lower() del plist[0] pdict = {} for p in plist: ! i = p.find('=') if i >= 0: ! name = p[:i].strip().lower() ! value = p[i+1:].strip() if len(value) >= 2 and value[0] == value[-1] == '"': value = value[1:-1] *************** *** 427,431 **** self.strict_parsing = strict_parsing if environ.has_key('REQUEST_METHOD'): ! method = string.upper(environ['REQUEST_METHOD']) if method == 'GET' or method == 'HEAD': if environ.has_key('QUERY_STRING'): --- 426,430 ---- self.strict_parsing = strict_parsing if environ.has_key('REQUEST_METHOD'): ! method = environ['REQUEST_METHOD'].upper() if method == 'GET' or method == 'HEAD': if environ.has_key('QUERY_STRING'): *************** *** 491,495 **** if self.headers.has_key('content-length'): try: ! clen = string.atoi(self.headers['content-length']) except: pass --- 490,494 ---- if self.headers.has_key('content-length'): try: ! clen = int(self.headers['content-length']) except: pass *************** *** 648,652 **** break if line[:2] == "--": ! strippedline = string.strip(line) if strippedline == next: break --- 647,651 ---- break if line[:2] == "--": ! strippedline = line.strip() if strippedline == next: break *************** *** 677,681 **** break if line[:2] == "--": ! strippedline = string.strip(line) if strippedline == next: break --- 676,680 ---- break if line[:2] == "--": ! strippedline = line.strip() if strippedline == next: break *************** *** 772,781 **** def __getitem__(self, key): v = SvFormContentDict.__getitem__(self, key) ! if v[0] in string.digits + '+-.': ! try: return string.atoi(v) except ValueError: ! try: return string.atof(v) except ValueError: pass ! return string.strip(v) def values(self): result = [] --- 771,780 ---- def __getitem__(self, key): v = SvFormContentDict.__getitem__(self, key) ! if v[0] in '0123456789+-.': ! try: return int(v) except ValueError: ! try: return float(v) except ValueError: pass ! return v.strip() def values(self): result = [] *************** *** 813,817 **** return len(self.dict[key]) def stripped(self, key): ! if self.dict.has_key(key): return string.strip(self.dict[key][0]) else: return None def pars(self): --- 812,816 ---- return len(self.dict[key]) def stripped(self, key): ! if self.dict.has_key(key): return self.dict[key][0].strip() else: return None def pars(self): *************** *** 871,875 **** traceback.format_exception_only(type, value) print "
%s%s
" % ( ! escape(string.join(list[:-1], "")), escape(list[-1]), ) --- 870,874 ---- traceback.format_exception_only(type, value) print "
%s%s
" % ( ! escape("".join(list[:-1])), escape(list[-1]), ) *************** *** 973,981 **** def escape(s, quote=None): """Replace special characters '&', '<' and '>' by SGML entities.""" ! s = string.replace(s, "&", "&") # Must be done first! ! s = string.replace(s, "<", "<") ! s = string.replace(s, ">", ">",) if quote: ! s = string.replace(s, '"', """) return s --- 972,980 ---- def escape(s, quote=None): """Replace special characters '&', '<' and '>' by SGML entities.""" ! s = s.replace("&", "&") # Must be done first! ! s = s.replace("<", "<") ! s = s.replace(">", ">") if quote: ! s = s.replace('"', """) return s From esr@users.sourceforge.net Fri Feb 9 10:06:50 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:06:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3918 Modified Files: ftplib.py Log Message: String method conversion. Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -r1.49 -r1.50 *** ftplib.py 2001/01/20 23:34:12 1.49 --- ftplib.py 2001/02/09 10:06:47 1.50 *************** *** 239,246 **** port number. ''' ! hbytes = string.splitfields(host, '.') pbytes = [`port/256`, `port%256`] bytes = hbytes + pbytes ! cmd = 'PORT ' + string.joinfields(bytes, ',') return self.voidcmd(cmd) --- 239,246 ---- port number. ''' ! hbytes = host.split('.') pbytes = [`port/256`, `port%256`] bytes = hbytes + pbytes ! cmd = 'PORT ' + ','.join(bytes) return self.voidcmd(cmd) *************** *** 457,461 **** resp = self.sendcmd('SIZE ' + filename) if resp[:3] == '213': ! return string.atoi(string.strip(resp[3:])) def mkd(self, dirname): --- 457,461 ---- resp = self.sendcmd('SIZE ' + filename) if resp[:3] == '213': ! return int(resp[3:].strip()) def mkd(self, dirname): *************** *** 501,505 **** m = _150_re.match(resp) if m: ! return string.atoi(m.group(1)) return None --- 501,505 ---- m = _150_re.match(resp) if m: ! return int(m.group(1)) return None *************** *** 512,525 **** if resp[:3] != '227': raise error_reply, resp ! left = string.find(resp, '(') if left < 0: raise error_proto, resp ! right = string.find(resp, ')', left + 1) if right < 0: raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' ! numbers = string.split(resp[left+1:right], ',') if len(numbers) != 6: raise error_proto, resp ! host = string.join(numbers[:4], '.') ! port = (string.atoi(numbers[4]) << 8) + string.atoi(numbers[5]) return host, port --- 512,525 ---- if resp[:3] != '227': raise error_reply, resp ! left = resp.find('(') if left < 0: raise error_proto, resp ! right = resp.find(')', left + 1) if right < 0: raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' ! numbers = resp[left+1:right].split(',') if len(numbers) != 6: raise error_proto, resp ! host = '.'.join(numbers[:4]) ! port = (int(numbers[4]) << 8) + int(numbers[5]) return host, port *************** *** 599,603 **** line = fp.readline() if not line: break ! if in_macro and string.strip(line): macro_lines.append(line) continue --- 599,603 ---- line = fp.readline() if not line: break ! if in_macro and line.strip(): macro_lines.append(line) continue *************** *** 605,609 **** self.__macros[macro_name] = tuple(macro_lines) in_macro = 0 ! words = string.split(line) host = user = passwd = acct = None default = 0 --- 605,609 ---- self.__macros[macro_name] = tuple(macro_lines) in_macro = 0 ! words = line.split() host = user = passwd = acct = None default = 0 *************** *** 618,622 **** default = 1 elif w1 == 'machine' and w2: ! host = string.lower(w2) i = i + 1 elif w1 == 'login' and w2: --- 618,622 ---- default = 1 elif w1 == 'machine' and w2: ! host = w2.lower() i = i + 1 elif w1 == 'login' and w2: *************** *** 660,664 **** """ ! host = string.lower(host) user = passwd = acct = None if self.__hosts.has_key(host): --- 660,664 ---- """ ! host = host.lower() user = passwd = acct = None if self.__hosts.has_key(host): From esr@users.sourceforge.net Fri Feb 9 10:10:04 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:10:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib gopherlib.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4276 Modified Files: gopherlib.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: gopherlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gopherlib.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** gopherlib.py 2001/01/23 15:35:05 1.8 --- gopherlib.py 2001/02/09 10:10:02 1.9 *************** *** 1,6 **** """Gopher protocol client interface.""" - import string - __all__ = ["send_selector","send_query"] --- 1,4 ---- *************** *** 59,71 **** """Send a selector to a given host and port, return a file with the reply.""" import socket - import string if not port: ! i = string.find(host, ':') if i >= 0: ! host, port = host[:i], string.atoi(host[i+1:]) if not port: port = DEF_PORT elif type(port) == type(''): ! port = string.atoi(port) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) --- 57,68 ---- """Send a selector to a given host and port, return a file with the reply.""" import socket if not port: ! i = host.find(':') if i >= 0: ! host, port = host[:i], int(host[i+1:]) if not port: port = DEF_PORT elif type(port) == type(''): ! port = int(port) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) *************** *** 99,103 **** def get_directory(f): """Get a directory in the form of a list of entries.""" - import string list = [] while 1: --- 96,99 ---- *************** *** 116,120 **** continue gtype = line[0] ! parts = string.splitfields(line[1:], TAB) if len(parts) < 4: print '(Bad line from server:', `line`, ')' --- 112,116 ---- continue gtype = line[0] ! parts = line[1:].split(TAB) if len(parts) < 4: print '(Bad line from server:', `line`, ')' From esr@users.sourceforge.net Fri Feb 9 10:12:21 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:12:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib sgmllib.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4478 Modified Files: sgmllib.py Log Message: Use ValueError instead of string.atoi.error, since we've switched to int(). Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** sgmllib.py 2001/02/09 07:49:30 1.24 --- sgmllib.py 2001/02/09 10:12:19 1.25 *************** *** 355,359 **** try: n = int(name) ! except string.atoi_error: self.unknown_charref(name) return --- 355,359 ---- try: n = int(name) ! except ValueError: self.unknown_charref(name) return From esr@users.sourceforge.net Fri Feb 9 10:14:55 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:14:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4827 Modified Files: smtplib.py Log Message: Aha. We can remove he string import after all by using ValueError. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** smtplib.py 2001/02/09 07:40:17 1.34 --- smtplib.py 2001/02/09 10:14:53 1.35 *************** *** 41,45 **** import socket - import string import re import rfc822 --- 41,44 ---- *************** *** 210,214 **** host, port = host[:i], host[i+1:] try: port = int(port) ! except string.atoi_error: raise socket.error, "nonnumeric port" if not port: port = SMTP_PORT --- 209,213 ---- host, port = host[:i], host[i+1:] try: port = int(port) ! except ValueError: raise socket.error, "nonnumeric port" if not port: port = SMTP_PORT From esr@users.sourceforge.net Fri Feb 9 10:17:32 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:17:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ihooks.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5178 Modified Files: ihooks.py Log Message: String method conversion. Index: ihooks.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ihooks.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** ihooks.py 2001/01/23 15:35:05 1.12 --- ihooks.py 2001/02/09 10:17:30 1.13 *************** *** 56,60 **** import os import sys - import string __all__ = ["BasicModuleLoader","Hooks","ModuleLoader","FancyModuleLoader", --- 56,59 ---- *************** *** 413,417 **** return parent if '.' in pname: ! i = string.rfind(pname, '.') pname = pname[:i] parent = self.modules[pname] --- 412,416 ---- return parent if '.' in pname: ! i = pname.rfind('.') pname = pname[:i] parent = self.modules[pname] *************** *** 422,426 **** def find_head_package(self, parent, name): if '.' in name: ! i = string.find(name, '.') head = name[:i] tail = name[i+1:] --- 421,425 ---- def find_head_package(self, parent, name): if '.' in name: ! i = name.find('.') head = name[:i] tail = name[i+1:] *************** *** 444,448 **** m = q while tail: ! i = string.find(tail, '.') if i < 0: i = len(tail) head, tail = tail[:i], tail[i+1:] --- 443,447 ---- m = q while tail: ! i = tail.find('.') if i < 0: i = len(tail) head, tail = tail[:i], tail[i+1:] *************** *** 494,498 **** if '.' not in name: return self.import_it(name, name, None, force_load=1) ! i = string.rfind(name, '.') pname = name[:i] parent = self.modules[pname] --- 493,497 ---- if '.' not in name: return self.import_it(name, name, None, force_load=1) ! i = name.rfind('.') pname = name[:i] parent = self.modules[pname] From esr@users.sourceforge.net Fri Feb 9 10:18:39 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:18:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib SimpleHTTPServer.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5329 Modified Files: SimpleHTTPServer.py Log Message: String method conversion. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** SimpleHTTPServer.py 2001/01/26 17:08:32 1.15 --- SimpleHTTPServer.py 2001/02/09 10:18:37 1.16 *************** *** 12,16 **** import os - import string import posixpath import BaseHTTPServer --- 12,15 ---- *************** *** 132,136 **** """ path = posixpath.normpath(urllib.unquote(path)) ! words = string.splitfields(path, '/') words = filter(None, words) path = os.getcwd() --- 131,135 ---- """ path = posixpath.normpath(urllib.unquote(path)) ! words = path.splitfields('/') words = filter(None, words) path = os.getcwd() *************** *** 176,180 **** if self.extensions_map.has_key(ext): return self.extensions_map[ext] ! ext = string.lower(ext) if self.extensions_map.has_key(ext): return self.extensions_map[ext] --- 175,179 ---- if self.extensions_map.has_key(ext): return self.extensions_map[ext] ! ext = ext.lower() if self.extensions_map.has_key(ext): return self.extensions_map[ext] From esr@users.sourceforge.net Fri Feb 9 10:23:57 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:23:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mailcap.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6373 Modified Files: mailcap.py Log Message: String method conversion. Index: mailcap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** mailcap.py 2001/01/24 06:27:27 1.8 --- mailcap.py 2001/02/09 10:23:55 1.9 *************** *** 2,6 **** import os - import string __all__ = ["getcaps","findmatch"] --- 2,5 ---- *************** *** 38,42 **** if os.environ.has_key('MAILCAPS'): str = os.environ['MAILCAPS'] ! mailcaps = string.splitfields(str, ':') else: if os.environ.has_key('HOME'): --- 37,41 ---- if os.environ.has_key('MAILCAPS'): str = os.environ['MAILCAPS'] ! mailcaps = str.split(':') else: if os.environ.has_key('HOME'): *************** *** 66,70 **** if not line: break # Ignore comments and blank lines ! if line[0] == '#' or string.strip(line) == '': continue nextline = line --- 65,69 ---- if not line: break # Ignore comments and blank lines ! if line[0] == '#' or line.strip() == '': continue nextline = line *************** *** 79,86 **** continue # Normalize the key ! types = string.splitfields(key, '/') for j in range(len(types)): ! types[j] = string.strip(types[j]) ! key = string.lower(string.joinfields(types, '/')) # Update the database if caps.has_key(key): --- 78,85 ---- continue # Normalize the key ! types = key.split('/') for j in range(len(types)): ! types[j] = types[j].strip() ! key = '/'.join(types).lower() # Update the database if caps.has_key(key): *************** *** 107,117 **** fields = {'view': view} for field in rest: ! i = string.find(field, '=') if i < 0: fkey = field fvalue = "" else: ! fkey = string.strip(field[:i]) ! fvalue = string.strip(field[i+1:]) if fields.has_key(fkey): # Ignore it --- 106,116 ---- fields = {'view': view} for field in rest: ! i = field.find('=') if i < 0: fkey = field fvalue = "" else: ! fkey = field[:i].strip() ! fvalue = field[i+1:].strip() if fields.has_key(fkey): # Ignore it *************** *** 132,136 **** else: i = i+1 ! return string.strip(line[start:i]), i --- 131,135 ---- else: i = i+1 ! return line[start:i].strip(), i *************** *** 161,165 **** if caps.has_key(MIMEtype): entries = entries + caps[MIMEtype] ! MIMEtypes = string.splitfields(MIMEtype, '/') MIMEtype = MIMEtypes[0] + '/*' if caps.has_key(MIMEtype): --- 160,164 ---- if caps.has_key(MIMEtype): entries = entries + caps[MIMEtype] ! MIMEtypes = MIMEtype.split('/') MIMEtype = MIMEtypes[0] + '/*' if caps.has_key(MIMEtype): *************** *** 202,209 **** def findparam(name, plist): ! name = string.lower(name) + '=' n = len(name) for p in plist: ! if string.lower(p[:n]) == name: return p[n:] return '' --- 201,208 ---- def findparam(name, plist): ! name = name.lower() + '=' n = len(name) for p in plist: ! if p[:n].lower() == name: return p[n:] return '' From esr@users.sourceforge.net Fri Feb 9 10:26:08 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:26:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib SimpleHTTPServer.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6698 Modified Files: SimpleHTTPServer.py Log Message: Correction after translation test. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** SimpleHTTPServer.py 2001/02/09 10:18:37 1.16 --- SimpleHTTPServer.py 2001/02/09 10:26:06 1.17 *************** *** 131,135 **** """ path = posixpath.normpath(urllib.unquote(path)) ! words = path.splitfields('/') words = filter(None, words) path = os.getcwd() --- 131,135 ---- """ path = posixpath.normpath(urllib.unquote(path)) ! words = path.split('/') words = filter(None, words) path = os.getcwd() From esr@users.sourceforge.net Fri Feb 9 10:28:36 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:28:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mhlib.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6877 Modified Files: mhlib.py Log Message: Test with an actual mbox caught a trivial error. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** mhlib.py 2001/02/09 09:17:38 1.24 --- mhlib.py 2001/02/09 10:28:34 1.25 *************** *** 691,695 **** hit = pred(line[:i].lower()) if hit: headers.append(line) ! return ''.joinfields(headers) def getbodytext(self, decode = 1): --- 691,695 ---- hit = pred(line[:i].lower()) if hit: headers.append(line) ! return ''.join(headers) def getbodytext(self, decode = 1): From esr@users.sourceforge.net Fri Feb 9 10:30:25 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:30:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_constants.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7223 Modified Files: sre_constants.py Log Message: String method conversion. Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** sre_constants.py 2001/01/15 12:46:09 1.23 --- sre_constants.py 2001/02/09 10:30:23 1.24 *************** *** 196,205 **** if __name__ == "__main__": - import string def dump(f, d, prefix): items = d.items() items.sort(lambda a, b: cmp(a[1], b[1])) for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") f.write("""\ --- 196,204 ---- if __name__ == "__main__": def dump(f, d, prefix): items = d.items() items.sort(lambda a, b: cmp(a[1], b[1])) for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, k.upper(), v)) f = open("sre_constants.h", "w") f.write("""\ From esr@users.sourceforge.net Fri Feb 9 10:44:35 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:44:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9110 Modified Files: xmllib.py Log Message: String method conversion. Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** xmllib.py 2001/01/15 03:34:38 1.26 --- xmllib.py 2001/02/09 10:44:32 1.27 *************** *** 196,202 **** if str[0] == '#': if str[1] == 'x': ! str = chr(string.atoi(str[2:], 16)) else: ! str = chr(string.atoi(str[1:])) if data[i - 1] != ';': self.syntax_error("`;' missing after char reference") --- 196,202 ---- if str[0] == '#': if str[1] == 'x': ! str = chr(int(str[2:], 16)) else: ! str = chr(int(str[1:])) if data[i - 1] != ';': self.syntax_error("`;' missing after char reference") *************** *** 246,250 **** data = rawdata[i:n] self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') i = n break --- 246,250 ---- data = rawdata[i:n] self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') i = n break *************** *** 264,268 **** self.syntax_error('illegal character in content') self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break --- 264,268 ---- self.syntax_error('illegal character in content') self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') i = j if i == n: break *************** *** 272,276 **** data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue --- 272,276 ---- data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') i = i+1 continue *************** *** 278,282 **** if k < 0: break self.__seen_starttag = 1 ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 278,282 ---- if k < 0: break self.__seen_starttag = 1 ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 284,288 **** k = self.parse_endtag(i) if k < 0: break ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 284,288 ---- k = self.parse_endtag(i) if k < 0: break ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 291,300 **** data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 291,300 ---- data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 302,306 **** k = self.parse_cdata(i) if k < 0: break ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 302,306 ---- k = self.parse_cdata(i) if k < 0: break ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 323,327 **** k = self.parse_proc(i) if k < 0: break ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 323,327 ---- k = self.parse_proc(i) if k < 0: break ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 331,335 **** data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue --- 331,335 ---- data = rawdata[i] self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') i = i+1 continue *************** *** 342,347 **** self.__seen_doctype = res.group('name') if self.__map_case: ! self.__seen_doctype = string.lower(self.__seen_doctype) ! self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue --- 342,347 ---- self.__seen_doctype = res.group('name') if self.__map_case: ! self.__seen_doctype = self.__seen_doctype.lower() ! self.lineno = self.lineno + rawdata[i:k].count('\n') i = k continue *************** *** 361,365 **** self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) ! self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) --- 361,365 ---- self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) ! self.lineno = self.lineno + res.group(0).count('\n') continue res = entityref.match(rawdata, i) *************** *** 371,375 **** name = res.group('name') if self.__map_case: ! name = string.lower(name) if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] --- 371,375 ---- name = res.group('name') if self.__map_case: ! name = name.lower() if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] *************** *** 378,382 **** else: self.unknown_entityref(name) ! self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': --- 378,382 ---- else: self.unknown_entityref(name) ! self.lineno = self.lineno + res.group(0).count('\n') continue elif rawdata[i] == ']': *************** *** 407,411 **** self.syntax_error('illegal character in content') self.handle_data(data) ! self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) --- 407,411 ---- self.syntax_error('illegal character in content') self.handle_data(data) ! self.lineno = self.lineno + data.count('\n') self.rawdata = rawdata[i+1:] return self.goahead(end) *************** *** 443,451 **** name = res.group('name') if self.__map_case: ! name = string.lower(name) pubid, syslit = res.group('pubid', 'syslit') if pubid is not None: pubid = pubid[1:-1] # remove quotes ! pubid = string.join(string.split(pubid)) # normalize if syslit is not None: syslit = syslit[1:-1] # remove quotes j = k = res.end(0) --- 443,451 ---- name = res.group('name') if self.__map_case: ! name = name.lower() pubid, syslit = res.group('pubid', 'syslit') if pubid is not None: pubid = pubid[1:-1] # remove quotes ! pubid = ' '.join(pubid.split()) # normalize if syslit is not None: syslit = syslit[1:-1] # remove quotes j = k = res.end(0) *************** *** 517,521 **** name = res.group(0) if self.__map_case: ! name = string.lower(name) if name == 'xml:namespace': self.syntax_error('old-fashioned namespace declaration') --- 517,521 ---- name = res.group(0) if self.__map_case: ! name = name.lower() if name == 'xml:namespace': self.syntax_error('old-fashioned namespace declaration') *************** *** 542,546 **** self.__namespaces[prefix] = attrdict['ns'] else: ! if string.lower(name) == 'xml': self.syntax_error('illegal processing instruction target name') self.handle_proc(name, rawdata[k:j]) --- 542,546 ---- self.__namespaces[prefix] = attrdict['ns'] else: ! if name.lower() == 'xml': self.syntax_error('illegal processing instruction target name') self.handle_proc(name, rawdata[k:j]) *************** *** 558,562 **** attrname, attrvalue = res.group('name', 'value') if self.__map_case: ! attrname = string.lower(attrname) i = res.end(0) if attrvalue is None: --- 558,562 ---- attrname, attrvalue = res.group('name', 'value') if self.__map_case: ! attrname = attrname.lower() i = res.end(0) if attrvalue is None: *************** *** 580,584 **** if attrdict.has_key(attrname): self.syntax_error("attribute `%s' specified twice" % attrname) ! attrvalue = string.translate(attrvalue, attrtrans) attrdict[attrname] = self.translate_references(attrvalue) return attrdict, namespace, i --- 580,584 ---- if attrdict.has_key(attrname): self.syntax_error("attribute `%s' specified twice" % attrname) ! attrvalue = attrvalue.translate(attrtrans) attrdict[attrname] = self.translate_references(attrvalue) return attrdict, namespace, i *************** *** 597,601 **** nstag = tagname = tag.group('tagname') if self.__map_case: ! nstag = tagname = string.lower(nstag) if not self.__seen_starttag and self.__seen_doctype and \ tagname != self.__seen_doctype: --- 597,601 ---- nstag = tagname = tag.group('tagname') if self.__map_case: ! nstag = tagname = nstag.lower() if not self.__seen_starttag and self.__seen_doctype and \ tagname != self.__seen_doctype: *************** *** 637,641 **** aprefix, key = res.group('prefix', 'local') if self.__map_case: ! key = string.lower(key) if aprefix is None: aprefix = '' --- 637,641 ---- aprefix, key = res.group('prefix', 'local') if self.__map_case: ! key = key.lower() if aprefix is None: aprefix = '' *************** *** 687,691 **** tag = res.group(0) if self.__map_case: ! tag = string.lower(tag) if self.literal: if not self.stack or tag != self.stack[-1][0]: --- 687,691 ---- tag = res.group(0) if self.__map_case: ! tag = tag.lower() if self.literal: if not self.stack or tag != self.stack[-1][0]: *************** *** 755,762 **** try: if name[0] == 'x': ! n = string.atoi(name[1:], 16) else: ! n = string.atoi(name) ! except string.atoi_error: self.unknown_charref(name) return --- 755,762 ---- try: if name[0] == 'x': ! n = int(name[1:], 16) else: ! n = int(name) ! except ValueError: self.unknown_charref(name) return From esr@users.sourceforge.net Fri Feb 9 10:48:32 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:48:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9662 Modified Files: locale.py Log Message: String method conversion. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** locale.py 2001/01/24 10:13:46 1.14 --- locale.py 2001/02/09 10:48:30 1.15 *************** *** 12,16 **** """ ! import string, sys # Try importing the _locale module. --- 12,16 ---- """ ! import sys # Try importing the _locale module. *************** *** 141,156 **** return format("%.12g",val) ! def atof(str,func=string.atof): "Parses a string as a float according to the locale settings." #First, get rid of the grouping ts = localeconv()['thousands_sep'] if ts: ! s=string.split(str,ts) ! str=string.join(s, "") #next, replace the decimal point with a dot dd = localeconv()['decimal_point'] if dd: ! s=string.split(str,dd) ! str=string.join(s, '.') #finally, parse the string return func(str) --- 141,156 ---- return format("%.12g",val) ! def atof(str,func=float): "Parses a string as a float according to the locale settings." #First, get rid of the grouping ts = localeconv()['thousands_sep'] if ts: ! s=str.split(ts) ! str="".join(s) #next, replace the decimal point with a dot dd = localeconv()['decimal_point'] if dd: ! s=str.split(dd) ! str='.'.join(s) #finally, parse the string return func(str) *************** *** 158,162 **** def atoi(str): "Converts a string to an integer according to the locale settings." ! return atof(str,string.atoi) def _test(): --- 158,162 ---- def atoi(str): "Converts a string to an integer according to the locale settings." ! return atof(str, int) def _test(): *************** *** 195,204 **** """ # Normalize the locale name and extract the encoding ! fullname = string.lower(localename) if ':' in fullname: # ':' is sometimes used as encoding delimiter. ! fullname = string.replace(fullname, ':', '.') if '.' in fullname: ! langname, encoding = string.split(fullname, '.')[:2] fullname = langname + '.' + encoding else: --- 195,204 ---- """ # Normalize the locale name and extract the encoding ! fullname = localename.lower() if ':' in fullname: # ':' is sometimes used as encoding delimiter. ! fullname = fullname.replace(':', '.') if '.' in fullname: ! langname, encoding = fullname.split('.')[:2] fullname = langname + '.' + encoding else: *************** *** 215,219 **** if code is not None: if '.' in code: ! langname, defenc = string.split(code, '.') else: langname = code --- 215,219 ---- if code is not None: if '.' in code: ! langname, defenc = code.split('.') else: langname = code *************** *** 247,251 **** code = normalize(localename) if '.' in code: ! return string.split(code, '.')[:2] elif code == 'C': return None, None --- 247,251 ---- code = normalize(localename) if '.' in code: ! return code.split('.')[:2] elif code == 'C': return None, None From esr@users.sourceforge.net Fri Feb 9 10:55:22 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:55:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib2.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10941 Modified Files: urllib2.py Log Message: String method conversion. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** urllib2.py 2001/01/15 03:34:38 1.7 --- urllib2.py 2001/02/09 10:55:20 1.8 *************** *** 86,90 **** # check digest against correct (i.e. non-apache) implementation - import string import socket import UserDict --- 86,89 ---- *************** *** 266,276 **** added = 1 continue ! i = string.find(meth, '_') ! j = string.find(meth[i+1:], '_') + i + 1 if j != -1 and meth[i+1:j] == 'error': proto = meth[:i] kind = meth[j+1:] try: ! kind = string.atoi(kind) except ValueError: pass --- 265,275 ---- added = 1 continue ! i = meth.find('_') ! j = meth[i+1:].find('_') + i + 1 if j != -1 and meth[i+1:j] == 'error': proto = meth[:i] kind = meth[j+1:] try: ! kind = int(kind) except ValueError: pass *************** *** 600,604 **** if mo: scheme, realm = mo.groups() ! if string.lower(scheme) == 'basic': return self.retry_http_basic_auth(req, realm) --- 599,603 ---- if mo: scheme, realm = mo.groups() ! if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) *************** *** 614,618 **** if pw: raw = "%s:%s" % (user, pw) ! auth = string.strip(base64.encodestring(raw)) req.add_header('Authorization', 'Basic %s' % auth) resp = self.parent.open(req) --- 613,617 ---- if pw: raw = "%s:%s" % (user, pw) ! auth = base64.encodestring(raw).strip() req.add_header('Authorization', 'Basic %s' % auth) resp = self.parent.open(req) *************** *** 639,648 **** authreq = headers.get('www-authenticate', None) if authreq: ! kind = string.split(authreq)[0] if kind == 'Digest': return self.retry_http_digest_auth(req, authreq) def retry_http_digest_auth(self, req, auth): ! token, challenge = string.split(auth, ' ', 1) chal = parse_keqv_list(parse_http_list(challenge)) auth = self.get_authorization(req, chal) --- 638,647 ---- authreq = headers.get('www-authenticate', 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): ! token, challenge = auth.split(' ', 1) chal = parse_keqv_list(parse_http_list(challenge)) auth = self.get_authorization(req, chal) *************** *** 724,728 **** n = ord(c) & 0xf hexrep.append(hex(n)[-1]) ! return string.join(hexrep, '') --- 723,727 ---- n = ord(c) & 0xf hexrep.append(hex(n)[-1]) ! return ''.join(hexrep) *************** *** 773,777 **** parsed = {} for elt in l: ! k, v = string.split(elt, '=', 1) if v[0] == '"' and v[-1] == '"': v = v[1:-1] --- 772,776 ---- parsed = {} for elt in l: ! k, v = elt.split('=', 1) if v[0] == '"' and v[-1] == '"': v = v[1:-1] *************** *** 795,800 **** while i < end: cur = s[i:] ! c = string.find(cur, ',') ! q = string.find(cur, '"') if c == -1: list.append(s[start:]) --- 794,799 ---- while i < end: cur = s[i:] ! c = cur.find(',') ! q = cur.find('"') if c == -1: list.append(s[start:]) *************** *** 823,827 **** inquote = 1 i = i + q + 1 ! return map(string.strip, list) class FileHandler(BaseHandler): --- 822,826 ---- inquote = 1 i = i + q + 1 ! return map(lambda x: x.strip(), list) class FileHandler(BaseHandler): *************** *** 873,877 **** path, attrs = splitattr(req.get_selector()) path = unquote(path) ! dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: --- 872,876 ---- path, attrs = splitattr(req.get_selector()) path = unquote(path) ! dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: *************** *** 883,889 **** for attr in attrs: attr, value = splitattr(attr) ! if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = string.upper(value) fp, retrlen = fw.retrfile(file, type) if retrlen is not None and retrlen >= 0: --- 882,888 ---- for attr in attrs: attr, value = splitattr(attr) ! if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = value.upper() fp, retrlen = fw.retrfile(file, type) if retrlen is not None and retrlen >= 0: *************** *** 1049,1053 **** ph = CustomProxyHandler(p) ! install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph)) for url in urls: --- 1048,1052 ---- ph = CustomProxyHandler(p) ! #install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph)) for url in urls: From esr@users.sourceforge.net Fri Feb 9 10:58:32 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 02:58:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib formatter.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11315 Modified Files: formatter.py Log Message: String method conversion. Index: formatter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** formatter.py 2001/01/14 23:36:05 1.16 --- formatter.py 2001/02/09 10:58:30 1.17 *************** *** 158,162 **** index = index + 1 if case == 'I': ! return string.upper(label) return label --- 158,162 ---- index = index + 1 if case == 'I': ! return label.upper() return label *************** *** 370,378 **** def send_literal_data(self, data): self.file.write(data) ! i = string.rfind(data, '\n') if i >= 0: self.col = 0 data = data[i+1:] ! data = string.expandtabs(data) self.col = self.col + len(data) self.atbreak = 0 --- 370,378 ---- def send_literal_data(self, data): self.file.write(data) ! i = data.rfind('\n') if i >= 0: self.col = 0 data = data[i+1:] ! data = data.expandtabs() self.col = self.col + len(data) self.atbreak = 0 *************** *** 384,388 **** maxcol = self.maxcol write = self.file.write ! for word in string.split(data): if atbreak: if col + len(word) >= maxcol: --- 384,388 ---- maxcol = self.maxcol write = self.file.write ! for word in data.split(): if atbreak: if col + len(word) >= maxcol: From esr@users.sourceforge.net Fri Feb 9 11:02:22 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:02:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib nturl2path.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12116 Modified Files: nturl2path.py Log Message: String method conversion. Index: nturl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nturl2path.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** nturl2path.py 2001/02/06 01:07:01 1.8 --- nturl2path.py 2001/02/09 11:02:20 1.9 *************** *** 20,32 **** # (notice halving of slashes at the start of the path) url = url[2:] ! components = string.split(url, '/') # make sure not to convert quoted slashes :-) ! return urllib.unquote(string.join(components, '\\')) ! comp = string.split(url, '|') if len(comp) != 2 or comp[0][-1] not in string.letters: error = 'Bad URL: ' + url raise IOError, error ! drive = string.upper(comp[0][-1]) ! components = string.split(comp[1], '/') path = drive + ':' for comp in components: --- 20,32 ---- # (notice halving of slashes at the start of the path) url = url[2:] ! components = url.split('/') # make sure not to convert quoted slashes :-) ! return urllib.unquote('\\'.join(components)) ! comp = url.split('|') if len(comp) != 2 or comp[0][-1] not in string.letters: error = 'Bad URL: ' + url raise IOError, error ! drive = comp[0][-1].upper() ! components = comp[1].split('/') path = drive + ':' for comp in components: *************** *** 53,65 **** # (notice doubling of slashes at the start of the path) p = '\\\\' + p ! components = string.split(p, '\\') ! return urllib.quote(string.join(components, '/')) ! comp = string.split(p, ':') if len(comp) != 2 or len(comp[0]) > 1: error = 'Bad path: ' + p raise IOError, error ! drive = urllib.quote(string.upper(comp[0])) ! components = string.split(comp[1], '\\') path = '///' + drive + '|' for comp in components: --- 53,65 ---- # (notice doubling of slashes at the start of the path) p = '\\\\' + p ! components = p.split('\\') ! return urllib.quote('/'.join(components)) ! comp = p.split(':') if len(comp) != 2 or len(comp[0]) > 1: error = 'Bad path: ' + p raise IOError, error ! drive = urllib.quote(comp[0].upper()) ! components = comp[1].split('\\') path = '///' + drive + '|' for comp in components: From esr@users.sourceforge.net Fri Feb 9 11:05:12 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:05:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12398 Modified Files: sre.py Log Message: String method conversion. Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** sre.py 2001/01/16 07:37:30 1.27 --- sre.py 2001/02/09 11:05:10 1.28 *************** *** 18,23 **** import sre_parse - import string - # flags I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case --- 18,21 ---- *************** *** 110,114 **** def _join(seq, sep): # internal: join into string having the same type as sep ! return string.join(seq, sep[:0]) def _compile(*key): --- 108,112 ---- def _join(seq, sep): # internal: join into string having the same type as sep ! return sep[:0].join(seq) def _compile(*key): From esr@users.sourceforge.net Fri Feb 9 11:06:40 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:06:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tokenize.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12612 Modified Files: tokenize.py Log Message: String method conversion. Index: tokenize.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** tokenize.py 2001/01/15 22:04:30 1.17 --- tokenize.py 2001/02/09 11:06:38 1.18 *************** *** 27,31 **** # Note: to quote a backslash in a regex, it must be doubled in a r'aw' string. ! def group(*choices): return '(' + string.join(choices, '|') + ')' def any(*choices): return apply(group, choices) + '*' def maybe(*choices): return apply(group, choices) + '?' --- 27,31 ---- # Note: to quote a backslash in a regex, it must be doubled in a r'aw' string. ! def group(*choices): return '(' + '|'.join(choices) + ')' def any(*choices): return apply(group, choices) + '*' def maybe(*choices): return apply(group, choices) + '?' From esr@users.sourceforge.net Fri Feb 9 11:10:18 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:10:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib token.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13053 Modified Files: token.py Log Message: String method conversion. Index: token.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/token.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** token.py 2000/08/24 21:08:39 1.8 --- token.py 2001/02/09 11:10:16 1.9 *************** *** 95,99 **** sys.stdout.write("I/O error: %s\n" % str(err)) sys.exit(1) ! lines = string.splitfields(fp.read(), "\n") fp.close() prog = re.compile( --- 95,99 ---- sys.stdout.write("I/O error: %s\n" % str(err)) sys.exit(1) ! lines = fp.read().split("\n") fp.close() prog = re.compile( *************** *** 115,119 **** sys.stderr.write("I/O error: %s\n" % str(err)) sys.exit(2) ! format = string.splitfields(fp.read(), "\n") fp.close() try: --- 115,119 ---- sys.stderr.write("I/O error: %s\n" % str(err)) sys.exit(2) ! format = fp.read().split("\n") fp.close() try: *************** *** 132,136 **** sys.stderr.write("I/O error: %s\n" % str(err)) sys.exit(4) ! fp.write(string.joinfields(format, "\n")) fp.close() --- 132,136 ---- sys.stderr.write("I/O error: %s\n" % str(err)) sys.exit(4) ! fp.write("\n".join(format)) fp.close() From esr@users.sourceforge.net Fri Feb 9 11:14:11 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:14:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils bcppcompiler.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv13729 Modified Files: bcppcompiler.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: bcppcompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/bcppcompiler.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** bcppcompiler.py 2000/09/27 02:08:14 1.7 --- bcppcompiler.py 2001/02/09 11:14:08 1.8 *************** *** 15,19 **** ! import sys, os, string from distutils.errors import \ DistutilsExecError, DistutilsPlatformError, \ --- 15,19 ---- ! import sys, os from distutils.errors import \ DistutilsExecError, DistutilsPlatformError, \ From esr@users.sourceforge.net Fri Feb 9 11:16:00 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:16:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cmd.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv14036 Modified Files: cmd.py Log Message: String method conversion. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cmd.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** cmd.py 2000/09/26 02:12:31 1.25 --- cmd.py 2001/02/09 11:15:58 1.26 *************** *** 10,14 **** __revision__ = "$Id$" ! import sys, os, string, re from types import * from distutils.errors import * --- 10,14 ---- __revision__ = "$Id$" ! import sys, os, re from types import * from distutils.errors import * *************** *** 162,166 **** indent = indent + " " for (option, _, _) in self.user_options: ! option = string.translate(option, longopt_xlate) if option[-1] == "=": option = option[:-1] --- 162,166 ---- indent = indent + " " for (option, _, _) in self.user_options: ! option = option.translate(longopt_xlate) if option[-1] == "=": option = option[:-1] *************** *** 422,426 **** if exec_msg is None: exec_msg = "generating %s from %s" % \ ! (outfile, string.join(infiles, ', ')) if skip_msg is None: skip_msg = "skipping %s (inputs unchanged)" % outfile --- 422,426 ---- if exec_msg is None: exec_msg = "generating %s from %s" % \ ! (outfile, ', '.join(infiles)) if skip_msg is None: skip_msg = "skipping %s (inputs unchanged)" % outfile From esr@users.sourceforge.net Fri Feb 9 11:18:00 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:18:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk tkFont.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv14380 Modified Files: tkFont.py Log Message: String method conversion. Index: tkFont.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFont.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** tkFont.py 2000/10/23 18:31:14 1.2 --- tkFont.py 2001/02/09 11:17:58 1.3 *************** *** 19,23 **** import Tkinter - import string # weight/slant --- 19,22 ---- *************** *** 121,125 **** def measure(self, text): "Return text width" ! return string.atoi(self._call("font", "measure", self.name, text)) def metrics(self, *options): --- 120,124 ---- def measure(self, text): "Return text width" ! return int(self._call("font", "measure", self.name, text)) def metrics(self, *options): *************** *** 130,134 **** if options: ! return string.atoi( self._call("font", "metrics", self.name, self._get(options)) ) --- 129,133 ---- if options: ! return int( self._call("font", "metrics", self.name, self._get(options)) ) *************** *** 137,141 **** options = {} for i in range(0, len(res), 2): ! options[res[i][1:]] = string.atoi(res[i+1]) return options --- 136,140 ---- options = {} for i in range(0, len(res), 2): ! options[res[i][1:]] = int(res[i+1]) return options From esr@users.sourceforge.net Fri Feb 9 11:22:29 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:22:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.151,1.152 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv14973 Modified Files: Tkinter.py Log Message: String method conversion. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -r1.151 -r1.152 *** Tkinter.py 2000/12/12 23:11:41 1.151 --- Tkinter.py 2001/02/09 11:22:27 1.152 *************** *** 38,42 **** from types import * from Tkconstants import * - import string; _string = string; del string try: import MacOS; _MacOS = MacOS; del MacOS --- 38,41 ---- *************** *** 44,49 **** _MacOS = None ! TkVersion = _string.atof(_tkinter.TK_VERSION) ! TclVersion = _string.atof(_tkinter.TCL_VERSION) READABLE = _tkinter.READABLE --- 43,48 ---- _MacOS = None ! TkVersion = float(_tkinter.TK_VERSION) ! TclVersion = float(_tkinter.TCL_VERSION) READABLE = _tkinter.READABLE *************** *** 783,787 **** def __winfo_getint(self, x): """Internal function.""" ! return _string.atoi(x, 0) def winfo_vrootheight(self): """Return the height of the virtual root window associated with this --- 782,786 ---- def __winfo_getint(self, x): """Internal function.""" ! return int(x, 0) def winfo_vrootheight(self): """Return the height of the virtual root window associated with this *************** *** 851,855 **** (add and '+' or '', funcid, ! _string.join(self._subst_format))) self.tk.call(what + (sequence, cmd)) return funcid --- 850,854 ---- (add and '+' or '', funcid, ! " ".join(self._subst_format))) self.tk.call(what + (sequence, cmd)) return funcid *************** *** 973,979 **** w = w._root() name = name[1:] - find = _string.find while name: ! i = find(name, '.') if i >= 0: name, tail = name[:i], name[i+1:] --- 972,977 ---- w = w._root() name = name[1:] while name: ! i = name.find('.') if i >= 0: name, tail = name[:i], name[i+1:] From esr@users.sourceforge.net Fri Feb 9 11:25:13 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:25:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk tkSimpleDialog.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv15414 Modified Files: tkSimpleDialog.py Log Message: String method conversion. Index: tkSimpleDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkSimpleDialog.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** tkSimpleDialog.py 2000/10/23 18:31:14 1.6 --- tkSimpleDialog.py 2001/02/09 11:25:11 1.7 *************** *** 158,163 **** # convenience dialogues - import string - class _QueryDialog(Dialog): --- 158,161 ---- *************** *** 237,241 **** errormessage = "Not an integer." def getresult(self): ! return string.atoi(self.entry.get()) def askinteger(title, prompt, **kw): --- 235,239 ---- errormessage = "Not an integer." def getresult(self): ! return int(self.entry.get()) def askinteger(title, prompt, **kw): *************** *** 256,260 **** errormessage = "Not a floating point value." def getresult(self): ! return string.atof(self.entry.get()) def askfloat(title, prompt, **kw): --- 254,258 ---- errormessage = "Not a floating point value." def getresult(self): ! return float(self.entry.get()) def askfloat(title, prompt, **kw): From esr@users.sourceforge.net Fri Feb 9 11:27:35 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:27:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old grep.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv15618 Modified Files: grep.py Log Message: String method conversion. Index: grep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** grep.py 2000/12/12 23:11:41 1.8 --- grep.py 2001/02/09 11:27:33 1.9 *************** *** 3,7 **** import regex from regex_syntax import * - import string opt_show_where = 0 --- 3,6 ---- *************** *** 60,64 **** if line[-1:] == '\n': line = line[:-1] if opt_show_lineno: ! prefix = string.rjust(`lineno`, 3) + ': ' else: prefix = '' --- 59,63 ---- if line[-1:] == '\n': line = line[:-1] if opt_show_lineno: ! prefix = `lineno`.rjust(, 3) + ': ' else: prefix = '' From esr@users.sourceforge.net Fri Feb 9 11:26:24 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:26:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old codehack.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv15512 Modified Files: codehack.py Log Message: String method conversion. Index: codehack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/codehack.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** codehack.py 1997/07/18 16:48:30 1.4 --- codehack.py 2001/02/09 11:26:22 1.5 *************** *** 49,53 **** lineno = ord(code[1]) | ord(code[2]) << 8 line = linecache.getline(filename, lineno) ! words = string.split(line) if len(words) >= 2 and words[0] in ('def', 'class'): name = words[1] --- 49,53 ---- lineno = ord(code[1]) | ord(code[2]) << 8 line = linecache.getline(filename, lineno) ! words = line.split() if len(words) >= 2 and words[0] in ('def', 'class'): name = words[1] From esr@users.sourceforge.net Fri Feb 9 11:29:56 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:29:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old tb.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv15940 Modified Files: tb.py Log Message: String method conversion. Index: tb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/tb.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** tb.py 2000/12/12 23:11:41 1.8 --- tb.py 2001/02/09 11:29:54 1.9 *************** *** 6,10 **** import os from stat import * - import string import linecache --- 6,9 ---- *************** *** 36,40 **** print '\n[EOF]' break ! cmd = string.strip(line) if cmd: if cmd == 'quit': --- 35,39 ---- print '\n[EOF]' break ! cmd = line.strip() if cmd: if cmd == 'quit': *************** *** 63,68 **** first = max(1, last-10) for i in range(first, last+1): ! if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':' ! else: prefix = string.rjust(`i`, 7) + ':' line = linecache.getline(filename, i) if line[-1:] == '\n': line = line[:-1] --- 62,67 ---- first = max(1, last-10) for i in range(first, last+1): ! if i == lineno: prefix = '***' + `i`.rjust(4) + ':' ! else: prefix = `i`.rjust(7) + ':' line = linecache.getline(filename, i) if line[-1:] == '\n': line = line[:-1] *************** *** 116,120 **** line = linecache.getline(filename, lineno) if line: ! info = info + ': ' + string.strip(line) print info --- 115,119 ---- line = linecache.getline(filename, lineno) if line: ! info = info + ': ' + line.strip() print info *************** *** 123,127 **** keys.sort() for name in keys: ! print ' ' + string.ljust(name, 12) + ':', printobject(d[name], 4) print --- 122,126 ---- keys.sort() for name in keys: ! print ' ' + name.ljust(12) + ':', printobject(d[name], 4) print From esr@users.sourceforge.net Fri Feb 9 11:28:35 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:28:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old packmail.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv15824 Modified Files: packmail.py Log Message: String method conversion. Index: packmail.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** packmail.py 2000/12/12 23:11:41 1.8 --- packmail.py 2001/02/09 11:28:33 1.9 *************** *** 6,10 **** import os from stat import ST_MTIME - import string # Print help --- 6,9 ---- *************** *** 104,108 **** def unixfix(name): ! comps = string.splitfields(name, os.sep) res = '' for comp in comps: --- 103,107 ---- def unixfix(name): ! comps = name.splitfields(os.sep) res = '' for comp in comps: From esr@users.sourceforge.net Fri Feb 9 11:32:02 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:32:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old ni.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv16150 Modified Files: ni.py Log Message: String method conversion. Index: ni.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/ni.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ni.py 2000/07/16 12:04:31 1.3 --- ni.py 2001/02/09 11:32:00 1.4 *************** *** 164,168 **** import imp - import string import sys import __builtin__ --- 164,167 ---- *************** *** 207,211 **** file, filename, (suff, mode, type) = stuff # Hack around restriction in imp.load_dynamic() ! i = string.rfind(name, '.') tail = name[i+1:] if sys.modules.has_key(tail): --- 206,210 ---- file, filename, (suff, mode, type) = stuff # Hack around restriction in imp.load_dynamic() ! i = name.rfind('.') tail = name[i+1:] if sys.modules.has_key(tail): *************** *** 242,246 **** name = m.__name__ if '.' in name: ! name = name[:string.rfind(name, '.')] else: name = '' --- 241,245 ---- name = m.__name__ if '.' in name: ! name = name[:name.rfind('.')] else: name = '' *************** *** 251,255 **** package.__domain__ = domain = [name] while '.' in name: ! name = name[:string.rfind(name, '.')] domain.append(name) if name: --- 250,254 ---- package.__domain__ = domain = [name] while '.' in name: ! name = name[:name.rfind('.')] domain.append(name) if name: *************** *** 286,290 **** return self.finish(package, p, '', fromlist) if '.' in name: ! i = string.find(name, '.') name, tail = name[:i], name[i:] else: --- 285,289 ---- return self.finish(package, p, '', fromlist) if '.' in name: ! i = name.find('.') name, tail = name[:i], name[i:] else: *************** *** 294,298 **** return self.finish(package, m, tail, fromlist) if '.' in name: ! i = string.find(name, '.') name, tail = name[:i], name[i:] else: --- 293,297 ---- return self.finish(package, m, tail, fromlist) if '.' in name: ! i = name.find('.') name, tail = name[:i], name[i:] else: *************** *** 313,317 **** m = self.get1(yname) while tail: ! i = string.find(tail, '.', 1) if i > 0: head, tail = tail[:i], tail[i:] --- 312,316 ---- m = self.get1(yname) while tail: ! i = tail.find('.', 1) if i > 0: head, tail = tail[:i], tail[i:] *************** *** 352,356 **** return sys.modules[name] if '.' in name: ! i = string.rfind(name, '.') head, tail = name[:i], name[i+1:] else: --- 351,355 ---- return sys.modules[name] if '.' in name: ! i = name.rfind('.') head, tail = name[:i], name[i+1:] else: *************** *** 368,372 **** name = module.__name__ if '.' in name: ! i = string.rfind(name, '.') head, tail = name[:i], name[i+1:] path = sys.modules[head].__path__ --- 367,371 ---- name = module.__name__ if '.' in name: ! i = name.rfind('.') head, tail = name[:i], name[i+1:] path = sys.modules[head].__path__ From esr@users.sourceforge.net Fri Feb 9 11:36:18 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:36:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16662 Modified Files: sre_parse.py Log Message: String method conversion. Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** sre_parse.py 2001/01/16 07:37:30 1.41 --- sre_parse.py 2001/02/09 11:36:16 1.42 *************** *** 11,15 **** # XXX: show string offset and offending character for all errors ! import string, sys from sre_constants import * --- 11,15 ---- # XXX: show string offset and offending character for all errors ! import sys from sre_constants import * *************** *** 61,70 **** } - try: - int("10", 8) - atoi = int - except TypeError: - atoi = string.atoi - class Pattern: # master pattern object. keeps track of global attributes --- 61,64 ---- *************** *** 223,227 **** # check if the escape string represents a valid group try: ! gid = atoi(escape[1:]) if gid and gid < groups: return gid --- 217,221 ---- # check if the escape string represents a valid group try: ! gid = int(escape[1:]) if gid and gid < groups: return gid *************** *** 246,250 **** if len(escape) != 2: raise error, "bogus escape: %s" % repr("\\" + escape) ! return LITERAL, atoi(escape, 16) & 0xff elif str(escape[1:2]) in OCTDIGITS: # octal escape (up to three digits) --- 240,244 ---- if len(escape) != 2: raise error, "bogus escape: %s" % repr("\\" + escape) ! return LITERAL, int(escape, 16) & 0xff elif str(escape[1:2]) in OCTDIGITS: # octal escape (up to three digits) *************** *** 252,256 **** escape = escape + source.get() escape = escape[1:] ! return LITERAL, atoi(escape, 8) & 0xff if len(escape) == 2: return LITERAL, ord(escape[1]) --- 246,250 ---- escape = escape + source.get() escape = escape[1:] ! return LITERAL, int(escape, 8) & 0xff if len(escape) == 2: return LITERAL, ord(escape[1]) *************** *** 274,283 **** if len(escape) != 4: raise ValueError ! return LITERAL, atoi(escape[2:], 16) & 0xff elif escape[1:2] == "0": # octal escape while source.next in OCTDIGITS and len(escape) < 4: escape = escape + source.get() ! return LITERAL, atoi(escape[1:], 8) & 0xff elif escape[1:2] in DIGITS: # octal escape *or* decimal group reference (sigh) --- 268,277 ---- if len(escape) != 4: raise ValueError ! return LITERAL, int(escape[2:], 16) & 0xff elif escape[1:2] == "0": # octal escape while source.next in OCTDIGITS and len(escape) < 4: escape = escape + source.get() ! return LITERAL, int(escape[1:], 8) & 0xff elif escape[1:2] in DIGITS: # octal escape *or* decimal group reference (sigh) *************** *** 289,293 **** # got three octal digits; this is an octal escape escape = escape + source.get() ! return LITERAL, atoi(escape[1:], 8) & 0xff # got at least one decimal digit; this is a group reference group = _group(escape, state.groups) --- 283,287 ---- # got three octal digits; this is an octal escape escape = escape + source.get() ! return LITERAL, int(escape[1:], 8) & 0xff # got at least one decimal digit; this is a group reference group = _group(escape, state.groups) *************** *** 463,469 **** continue if lo: ! min = atoi(lo) if hi: ! max = atoi(hi) if max < min: raise error, "bad repeat interval" --- 457,463 ---- continue if lo: ! min = int(lo) if hi: ! max = int(hi) if max < min: raise error, "bad repeat interval" *************** *** 653,657 **** raise error, "bad group name" try: ! index = atoi(name) except ValueError: if not isname(name): --- 647,651 ---- raise error, "bad group name" try: ! index = int(name) except ValueError: if not isname(name): *************** *** 677,681 **** if not code: this = this[1:] ! code = LITERAL, atoi(this[-6:], 8) & 0xff a(code) else: --- 671,675 ---- if not code: this = this[1:] ! code = LITERAL, int(this[-6:], 8) & 0xff a(code) else: *************** *** 706,708 **** raise error, "empty group" a(s) ! return string.join(p, sep) --- 700,702 ---- raise error, "empty group" a(s) ! return sep.join(p) From esr@users.sourceforge.net Fri Feb 9 11:40:42 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:40:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17411 Modified Files: regrtest.py Log Message: String method conversion. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** regrtest.py 2000/12/30 22:21:22 1.29 --- regrtest.py 2001/02/09 11:40:40 1.30 *************** *** 33,37 **** import sys - import string import os import getopt --- 33,36 ---- *************** *** 107,111 **** try: fp = open(filename, 'r') ! next = string.strip(fp.read()) tests = [next] fp.close() --- 106,110 ---- try: fp = open(filename, 'r') ! next = fp.read().strip() tests = [next] fp.close() *************** *** 164,171 **** if bad: print count(len(bad), "test"), "failed:", ! print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", ! print string.join(skipped) if single: --- 163,170 ---- if bad: print count(len(bad), "test"), "failed:", ! print " ".join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", ! print " ".join(skipped) if single: From esr@users.sourceforge.net Fri Feb 9 11:41:36 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:41:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test sortperf.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17492 Modified Files: sortperf.py Log Message: String method conversion. Index: sortperf.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/sortperf.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sortperf.py 1998/05/26 15:05:12 1.5 --- sortperf.py 2001/02/09 11:41:34 1.6 *************** *** 113,117 **** """ - import string # default range (inclusive) k1 = 15 --- 113,116 ---- *************** *** 119,126 **** if sys.argv[1:]: # one argument: single point ! k1 = k2 = string.atoi(sys.argv[1]) if sys.argv[2:]: # two arguments: specify range ! k2 = string.atoi(sys.argv[2]) if sys.argv[3:]: # derive random seed from remaining arguments --- 118,125 ---- if sys.argv[1:]: # one argument: single point ! k1 = k2 = int(sys.argv[1]) if sys.argv[2:]: # two arguments: specify range ! k2 = int(sys.argv[2]) if sys.argv[3:]: # derive random seed from remaining arguments From esr@users.sourceforge.net Fri Feb 9 11:43:37 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:43:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test string_tests.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17630 Modified Files: string_tests.py Log Message: String method conversion. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** string_tests.py 2001/01/29 11:14:15 1.6 --- string_tests.py 2001/02/09 11:43:35 1.7 *************** *** 45,50 **** # try a few long ones ! print string.join(['x' * 100] * 100, ':') ! print string.join(('x' * 100,) * 100, ':') --- 45,50 ---- # try a few long ones ! print ":".join(['x' * 100] * 100) ! print ":".join(('x' * 100,) * 100) From esr@users.sourceforge.net Fri Feb 9 11:45:28 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:45:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_extcall.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17777 Modified Files: test_extcall.py Log Message: String method conversion. Index: test_extcall.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_extcall.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test_extcall.py 2001/01/21 18:52:02 1.12 --- test_extcall.py 2001/02/09 11:45:26 1.13 *************** *** 1,5 **** from test_support import verify, verbose, TestFailed from UserList import UserList - import string def sortdict(d): --- 1,4 ---- *************** *** 196,200 **** if kwarg: arglist.append('**' + kwarg) decl = 'def %s(%s): print "ok %s", a, b, d, e, v, k' % ( ! name, string.join(arglist, ', '), name) exec(decl) func = eval(name) --- 195,199 ---- if kwarg: arglist.append('**' + kwarg) decl = 'def %s(%s): print "ok %s", a, b, d, e, v, k' % ( ! name, ', '.join(arglist), name) exec(decl) func = eval(name) From esr@users.sourceforge.net Fri Feb 9 11:44:26 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:44:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_dospath.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17696 Modified Files: test_dospath.py Log Message: String method conversion. Index: test_dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dospath.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_dospath.py 2000/10/23 17:22:07 1.2 --- test_dospath.py 2001/02/09 11:44:24 1.3 *************** *** 1,4 **** import dospath - import string import os --- 1,3 ---- *************** *** 6,10 **** def tester(fn, wantResult): ! fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: --- 5,9 ---- def tester(fn, wantResult): ! fn = fn.replace("\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: From esr@users.sourceforge.net Fri Feb 9 11:46:39 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:46:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17845 Modified Files: test_format.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_format.py 2001/01/18 02:22:22 1.8 --- test_format.py 2001/02/09 11:46:37 1.9 *************** *** 1,4 **** from test_support import verbose ! import string, sys # test string formatting operator (I am not sure if this is being tested --- 1,4 ---- from test_support import verbose ! import sys # test string formatting operator (I am not sure if this is being tested From esr@users.sourceforge.net Fri Feb 9 11:48:04 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:48:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_imgfile.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17978 Modified Files: test_imgfile.py Log Message: String method conversion. Index: test_imgfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_imgfile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_imgfile.py 2001/01/17 21:51:35 1.9 --- test_imgfile.py 2001/02/09 11:48:02 1.10 *************** *** 31,35 **** import sys import os - import string outputfile = '/tmp/deleteme' --- 31,34 ---- *************** *** 48,54 **** ourname = sys.modules[__name__].__file__ ! parts = string.splitfields(ourname, os.sep) parts[-1] = name ! name = string.joinfields(parts, os.sep) sizes = imgfile.getsizes(name) if verbose: --- 47,53 ---- ourname = sys.modules[__name__].__file__ ! parts = ourname.split(os.sep) parts[-1] = name ! name = os.sep.joinfields(parts) sizes = imgfile.getsizes(name) if verbose: From esr@users.sourceforge.net Fri Feb 9 11:49:26 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:49:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18136 Modified Files: test_mmap.py Log Message: String method conversion. Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** test_mmap.py 2001/01/17 19:11:13 1.14 --- test_mmap.py 2001/02/09 11:49:24 1.15 *************** *** 1,5 **** from test_support import verify import mmap ! import string, os, re, sys PAGESIZE = mmap.PAGESIZE --- 1,5 ---- from test_support import verify import mmap ! import os, re, sys PAGESIZE = mmap.PAGESIZE *************** *** 22,27 **** print type(m) # SF bug 128713: segfaulted on Linux ! print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' ! verify(string.find(m, 'foo') == PAGESIZE) print ' Length of file:', len(m) / float(PAGESIZE), 'pages' --- 22,27 ---- print type(m) # SF bug 128713: segfaulted on Linux ! print ' Position of foo:', m.find('foo') / float(PAGESIZE), 'pages' ! verify(m.find('foo') == PAGESIZE) print ' Length of file:', len(m) / float(PAGESIZE), 'pages' From esr@users.sourceforge.net Fri Feb 9 11:51:29 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:51:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pkg.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18329 Modified Files: test_pkg.py Log Message: String method conversion. Index: test_pkg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pkg.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test_pkg.py 2001/01/21 19:51:53 1.12 --- test_pkg.py 2001/02/09 11:51:27 1.13 *************** *** 1,5 **** # Test packages (dotted-name import) ! import sys, os, string, tempfile, traceback from os import mkdir, rmdir # Can't test if these fail del mkdir, rmdir --- 1,5 ---- # Test packages (dotted-name import) ! import sys, os, tempfile, traceback from os import mkdir, rmdir # Can't test if these fail del mkdir, rmdir *************** *** 11,15 **** mkdir(root) for name, contents in descr: ! comps = string.split(name) fullname = root for c in comps: --- 11,15 ---- mkdir(root) for name, contents in descr: ! comps = name.split() fullname = root for c in comps: From esr@users.sourceforge.net Fri Feb 9 11:50:18 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:50:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_ntpath.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18228 Modified Files: test_ntpath.py Log Message: String method conversion. Index: test_ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ntpath.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_ntpath.py 2000/10/23 17:22:07 1.6 --- test_ntpath.py 2001/02/09 11:50:16 1.7 *************** *** 1,4 **** import ntpath - import string import os --- 1,3 ---- *************** *** 6,10 **** def tester(fn, wantResult): ! fn = string.replace(fn, "\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: --- 5,9 ---- def tester(fn, wantResult): ! fn = fn.replace("\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: From esr@users.sourceforge.net Fri Feb 9 11:53:08 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:53:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pty.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18476 Modified Files: test_pty.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pty.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_pty.py 2001/01/17 21:51:35 1.9 --- test_pty.py 2001/02/09 11:53:06 1.10 *************** *** 1,3 **** ! import pty, os, sys, string from test_support import verbose, TestFailed, TestSkipped --- 1,3 ---- ! import pty, os, sys from test_support import verbose, TestFailed, TestSkipped From esr@users.sourceforge.net Fri Feb 9 11:52:03 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:52:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_posixpath.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18378 Modified Files: test_posixpath.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posixpath.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_posixpath.py 2000/10/23 17:22:07 1.3 --- test_posixpath.py 2001/02/09 11:52:01 1.4 *************** *** 1,4 **** import posixpath - import string errors = 0 --- 1,3 ---- From esr@users.sourceforge.net Fri Feb 9 11:53:52 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:53:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pwd.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18561 Modified Files: test_pwd.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_pwd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** test_pwd.py 2001/01/17 21:51:35 1.10 --- test_pwd.py 2001/02/09 11:53:49 1.11 *************** *** 1,5 **** from test_support import verbose import pwd - import string print 'pwd.getpwall()' --- 1,4 ---- *************** *** 51,55 **** # should never happen... if so, just forget it break ! fakename = string.join(map(None, chars), '') try: --- 50,54 ---- # should never happen... if so, just forget it break ! fakename = ''.join(map(None, chars)) try: From esr@users.sourceforge.net Fri Feb 9 11:54:50 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:54:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_re.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18735 Modified Files: test_re.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** test_re.py 2001/01/17 19:11:13 1.28 --- test_re.py 2001/02/09 11:54:48 1.29 *************** *** 4,8 **** from test_support import verify, verbose, TestFailed import re ! import sys, os, string, traceback # Misc tests from Tim Peters' re.doc --- 4,8 ---- from test_support import verify, verbose, TestFailed import re ! import sys, os, traceback # Misc tests from Tim Peters' re.doc From esr@users.sourceforge.net Fri Feb 9 11:57:22 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:57:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_socket.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19026 Modified Files: test_socket.py Log Message: String method conversion. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** test_socket.py 2001/01/17 21:51:35 1.17 --- test_socket.py 2001/02/09 11:57:20 1.18 *************** *** 13,17 **** import os import time - import string def missing_ok(str): --- 13,16 ---- *************** *** 80,84 **** for name in all_host_names: ! if string.find(name, '.'): break else: --- 79,83 ---- for name in all_host_names: ! if name.find('.'): break else: From esr@users.sourceforge.net Fri Feb 9 11:59:39 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:59:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_strftime.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19315 Modified Files: test_strftime.py Log Message: String method conversion. Index: test_strftime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strftime.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** test_strftime.py 2001/01/17 21:51:36 1.23 --- test_strftime.py 2001/02/09 11:59:37 1.24 *************** *** 3,7 **** # Sanity checker for time.strftime ! import time, calendar, sys, string, os, re from test_support import verbose --- 3,7 ---- # Sanity checker for time.strftime ! import time, calendar, sys, os, re from test_support import verbose *************** *** 91,95 **** if verbose: print "Strftime test, platform: %s, Python version: %s" % \ ! (sys.platform, string.split(sys.version)[0]) for e in expectations: --- 91,95 ---- if verbose: print "Strftime test, platform: %s, Python version: %s" % \ ! (sys.platform, sys.version.split()[0]) for e in expectations: From esr@users.sourceforge.net Fri Feb 9 11:58:23 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 03:58:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19145 Modified Files: test_sre.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** test_sre.py 2001/01/17 21:51:36 1.20 --- test_sre.py 2001/02/09 11:58:20 1.21 *************** *** 9,13 **** from test_support import verbose, TestFailed import sre ! import sys, os, string, traceback # --- 9,13 ---- from test_support import verbose, TestFailed import sre ! import sys, os, traceback # From esr@users.sourceforge.net Fri Feb 9 12:00:49 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:00:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_userstring.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19511 Modified Files: test_userstring.py Log Message: String method conversion. (This one was trivial -- no actual string. references in it!) Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_userstring.py 2001/01/17 21:51:36 1.4 --- test_userstring.py 2001/02/09 12:00:47 1.5 *************** *** 1,4 **** #!/usr/bin/env python ! import sys, string from test_support import verbose import string_tests --- 1,4 ---- #!/usr/bin/env python ! import sys from test_support import verbose import string_tests From esr@users.sourceforge.net Fri Feb 9 12:03:47 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:03:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml __init__.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml In directory usw-pr-cvs1:/tmp/cvs-serv20063 Modified Files: __init__.py Log Message: String method conversion. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/__init__.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** __init__.py 2000/12/16 01:43:40 1.8 --- __init__.py 2001/02/09 12:03:45 1.9 *************** *** 16,22 **** __all__ = ["dom", "parsers", "sax"] ! import string ! __version__ = string.split("$Revision$")[1] ! del string --- 16,20 ---- __all__ = ["dom", "parsers", "sax"] ! __version__ = "$Revision$".split()[1] From esr@users.sourceforge.net Fri Feb 9 12:02:00 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:02:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_zlib.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19700 Modified Files: test_zlib.py Log Message: String method conversion. Index: test_zlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_zlib.py 2000/10/23 17:22:08 1.9 --- test_zlib.py 2001/02/09 12:01:58 1.10 *************** *** 2,6 **** import sys import imp - import string try: --- 2,5 ---- *************** *** 58,62 **** bufs.append(co.compress(buf[i:i+256])) bufs.append(co.flush()) ! combuf = string.join(bufs, '') decomp1 = zlib.decompress(combuf, -12, -5) --- 57,61 ---- bufs.append(co.compress(buf[i:i+256])) bufs.append(co.flush()) ! combuf = ''.join(bufs) decomp1 = zlib.decompress(combuf, -12, -5) *************** *** 71,75 **** bufs.append(deco.decompress(combuf[i:i+128])) bufs.append(deco.flush()) ! decomp2 = string.join(buf, '') if decomp2 != buf: print "decompressobj with init options failed" --- 70,74 ---- bufs.append(deco.decompress(combuf[i:i+128])) bufs.append(deco.flush()) ! decomp2 = ''.join(buf) if decomp2 != buf: print "decompressobj with init options failed" From esr@users.sourceforge.net Fri Feb 9 12:10:28 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:10:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib CGIHTTPServer.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21209 Modified Files: CGIHTTPServer.py Log Message: Eliminate use of string.whitespace and a string import with it. Some of the characters (form feed, vertical tab) are not legal continuation characters anyway, so this was wrong as well as annoying. Index: CGIHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** CGIHTTPServer.py 2001/02/09 08:46:26 1.16 --- CGIHTTPServer.py 2001/02/09 12:10:26 1.17 *************** *** 24,28 **** import os import sys - import string import urllib import BaseHTTPServer --- 24,27 ---- *************** *** 165,169 **** accept = [] for line in self.headers.getallmatchingheaders('accept'): ! if line[:1] in string.whitespace: accept.append(line.strip()) else: --- 164,168 ---- accept = [] for line in self.headers.getallmatchingheaders('accept'): ! if line[:1] in "\t\n\r ": accept.append(line.strip()) else: From esr@users.sourceforge.net Fri Feb 9 12:14:04 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:14:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cygwinccompiler.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv21577 Modified Files: cygwinccompiler.py Log Message: String method conversion. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** cygwinccompiler.py 2000/12/12 23:11:39 1.9 --- cygwinccompiler.py 2001/02/09 12:14:02 1.10 *************** *** 366,373 **** from distutils import sysconfig ! import string,sys # if sys.version contains GCC then python was compiled with # GCC, and the config.h file should be OK ! if string.find(sys.version,"GCC") >= 0: return (CONFIG_H_OK, "sys.version mentions 'GCC'") --- 366,373 ---- from distutils import sysconfig ! import sys # if sys.version contains GCC then python was compiled with # GCC, and the config.h file should be OK ! if sys.version.find("GCC") >= 0: return (CONFIG_H_OK, "sys.version mentions 'GCC'") *************** *** 388,392 **** else: # "config.h" contains an "#ifdef __GNUC__" or something similar ! if string.find(s,"__GNUC__") >= 0: return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn) else: --- 388,392 ---- else: # "config.h" contains an "#ifdef __GNUC__" or something similar ! if s.find("__GNUC__") >= 0: return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn) else: From esr@users.sourceforge.net Fri Feb 9 12:17:02 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:17:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 flp.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv21918 Modified Files: flp.py Log Message: String method conversion. Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** flp.py 2000/12/12 23:11:42 1.7 --- flp.py 2001/02/09 12:16:59 1.8 *************** *** 4,8 **** # Jack Jansen, December 1991 # - import string import os import sys --- 4,7 ---- *************** *** 249,253 **** def _parse_numlist(str): ! slist = string.split(str) nlist = [] for i in slist: --- 248,252 ---- def _parse_numlist(str): ! slist = str.split() nlist = [] for i in slist: *************** *** 278,284 **** name, value = match.group(1, 2) if name[0] == 'N': ! name = string.join(string.split(name),'') ! name = string.lower(name) ! name = string.capitalize(name) try: pf = _parse_func[name] --- 277,283 ---- name, value = match.group(1, 2) if name[0] == 'N': ! name = ''.join(name.split()) ! name = name.lower() ! name = name.capitalize() try: pf = _parse_func[name] From esr@users.sourceforge.net Fri Feb 9 12:19:56 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:19:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils version.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv22333 Modified Files: version.py Log Message: String method conversion. Index: version.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/version.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** version.py 2000/09/26 01:53:34 1.3 --- version.py 2001/02/09 12:19:54 1.4 *************** *** 113,122 **** if patch: ! self.version = tuple(map(string.atoi, [major, minor, patch])) else: ! self.version = tuple(map(string.atoi, [major, minor]) + [0]) if prerelease: ! self.prerelease = (prerelease[0], string.atoi(prerelease_num)) else: self.prerelease = None --- 113,122 ---- if patch: ! self.version = tuple(map(int, [major, minor, patch])) else: ! self.version = tuple(map(int, [major, minor]) + [0]) if prerelease: ! self.prerelease = (prerelease[0], int(prerelease_num)) else: self.prerelease = None *************** *** 126,132 **** if self.version[2] == 0: ! vstring = string.join(map(str, self.version[0:2]), '.') else: ! vstring = string.join(map(str, self.version), '.') if self.prerelease: --- 126,132 ---- if self.version[2] == 0: ! vstring = '.'.join(map(str, self.version[0:2])) else: ! vstring = '.'.join(map(str, self.version)) if self.prerelease: From esr@users.sourceforge.net Fri Feb 9 12:18:21 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:18:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 cdplayer.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv22103 Modified Files: cdplayer.py Log Message: String method conversion. Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cdplayer.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** cdplayer.py 2000/12/12 23:11:42 1.4 --- cdplayer.py 2001/02/09 12:18:19 1.5 *************** *** 26,31 **** for i in range(2, len(tracklist), 4): t.append((None, \ ! (string.atoi(tracklist[i:i+2]), \ ! string.atoi(tracklist[i+2:i+4])))) tracklist = t self.track = [None] + [''] * len(tracklist) --- 26,31 ---- for i in range(2, len(tracklist), 4): t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) tracklist = t self.track = [None] + [''] * len(tracklist) *************** *** 60,64 **** self.artist = value elif name[:5] == 'track': ! trackno = string.atoi(name[6:]) self.track[trackno] = value f.close() --- 60,64 ---- self.artist = value elif name[:5] == 'track': ! trackno = int(name[6:]) self.track[trackno] = value f.close() From esr@users.sourceforge.net Fri Feb 9 12:20:54 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 04:20:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils extension.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv22445 Modified Files: extension.py Log Message: String method conversion. Index: extension.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/extension.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** extension.py 2000/09/17 00:45:18 1.6 --- extension.py 2001/02/09 12:20:51 1.7 *************** *** 8,12 **** __revision__ = "$Id$" ! import os, string from types import * --- 8,12 ---- __revision__ = "$Id$" ! import os from types import * *************** *** 169,173 **** ext.include_dirs.append(value) elif switch == "-D": ! equals = string.find(value, "=") if equals == -1: # bare "-DFOO" -- no value ext.define_macros.append((value, None)) --- 169,173 ---- ext.include_dirs.append(value) elif switch == "-D": ! equals = value.find("=") if equals == -1: # bare "-DFOO" -- no value ext.define_macros.append((value, None)) From akuchlin@mems-exchange.org Fri Feb 9 13:15:04 2001 From: akuchlin@mems-exchange.org (Andrew Kuchling) Date: Fri, 9 Feb 2001 08:15:04 -0500 Subject: [Python-checkins] CVS: python/dist/src/PC python_nt.rc,1.11,1.12 In-Reply-To: ; from tim_one@users.sourceforge.net on Thu, Feb 08, 2001 at 11:02:24PM -0800 References: Message-ID: <20010209081504.A15692@newcnri.cnri.reston.va.us> On Thu, Feb 08, 2001 at 11:02:24PM -0800, Tim Peters wrote: >Updated company name to "Digital Creations 2". Future company names: 2.2: Digital Creations 3-D 2.3: Digital Creations 4: Electric Boogaloo 2.4: Digital Creations V: The Boundless Bourne 2.5: Digital Creations VI: The Voyage Home --amk From lemburg@users.sourceforge.net Fri Feb 9 13:37:39 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 09 Feb 2001 05:37:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2323 Modified Files: StringIO.py Log Message: Remove silly EMPTYSTRING global. Saves a global lookup. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** StringIO.py 2001/01/20 19:54:20 1.16 --- StringIO.py 2001/02/09 13:37:37 1.17 *************** *** 37,42 **** __all__ = ["StringIO"] - EMPTYSTRING = '' - class StringIO: def __init__(self, buf = ''): --- 37,40 ---- *************** *** 62,66 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if mode == 1: --- 60,64 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += ''.join(self.buflist) self.buflist = [] if mode == 1: *************** *** 79,83 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if n < 0: --- 77,81 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += ''.join(self.buflist) self.buflist = [] if n < 0: *************** *** 93,97 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] i = self.buf.find('\n', self.pos) --- 91,95 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += ''.join(self.buflist) self.buflist = [] i = self.buf.find('\n', self.pos) *************** *** 140,144 **** if self.pos < self.len: if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] --- 138,142 ---- if self.pos < self.len: if self.buflist: ! self.buf += ''.join(self.buflist) self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] *************** *** 152,156 **** def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) def flush(self): --- 150,154 ---- def writelines(self, list): ! self.write(''.join(list)) def flush(self): *************** *** 160,164 **** def getvalue(self): if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] return self.buf --- 158,162 ---- def getvalue(self): if self.buflist: ! self.buf += ''.join(self.buflist) self.buflist = [] return self.buf From gvanrossum@users.sourceforge.net Fri Feb 9 15:06:45 2001 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 09 Feb 2001 07:06:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.159,2.160 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv16567 Modified Files: compile.c Log Message: Reindent a function that was somehow indented by 7 spaces. Also did a spaces->tab conversion for fields added to struct compiling. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.159 retrieving revision 2.160 diff -C2 -r2.159 -r2.160 *** compile.c 2001/02/02 20:01:10 2.159 --- compile.c 2001/02/09 15:06:42 2.160 *************** *** 194,210 **** all_name_chars(unsigned char *s) { ! static char ok_name_char[256]; ! static unsigned char *name_chars = (unsigned char *)NAME_CHARS; ! if (ok_name_char[*name_chars] == 0) { ! unsigned char *p; ! for (p = name_chars; *p; p++) ! ok_name_char[*p] = 1; ! } ! while (*s) { ! if (ok_name_char[*s++] == 0) ! return 0; ! } ! return 1; } --- 194,210 ---- all_name_chars(unsigned char *s) { ! static char ok_name_char[256]; ! static unsigned char *name_chars = (unsigned char *)NAME_CHARS; ! if (ok_name_char[*name_chars] == 0) { ! unsigned char *p; ! for (p = name_chars; *p; p++) ! ok_name_char[*p] = 1; ! } ! while (*s) { ! if (ok_name_char[*s++] == 0) ! return 0; ! } ! return 1; } *************** *** 354,360 **** char *c_private; /* for private name mangling */ int c_tmpname; /* temporary local name counter */ ! int c_nested; /* Is block nested funcdef or lamdef? */ ! int c_closure; /* Is nested w/freevars? */ ! struct symtable *c_symtable; /* pointer to module symbol table */ }; --- 354,360 ---- char *c_private; /* for private name mangling */ int c_tmpname; /* temporary local name counter */ ! int c_nested; /* Is block nested funcdef or lamdef? */ ! int c_closure; /* Is nested w/freevars? */ ! struct symtable *c_symtable; /* pointer to module symbol table */ }; From esr@users.sourceforge.net Fri Feb 9 16:25:23 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:25:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old packmail.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv354 Modified Files: packmail.py Log Message: splitfields -> split Index: packmail.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** packmail.py 2001/02/09 11:28:33 1.9 --- packmail.py 2001/02/09 16:25:20 1.10 *************** *** 103,107 **** def unixfix(name): ! comps = name.splitfields(os.sep) res = '' for comp in comps: --- 103,107 ---- def unixfix(name): ! comps = name.split(os.sep) res = '' for comp in comps: From sjoerd@users.sourceforge.net Fri Feb 9 16:34:27 2001 From: sjoerd@users.sourceforge.net (Sjoerd Mullender) Date: Fri, 09 Feb 2001 08:34:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old grep.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory usw-pr-cvs1:/tmp/cvs-serv1846 Modified Files: grep.py Log Message: Fixed syntax error. Index: grep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** grep.py 2001/02/09 11:27:33 1.9 --- grep.py 2001/02/09 16:34:24 1.10 *************** *** 59,63 **** if line[-1:] == '\n': line = line[:-1] if opt_show_lineno: ! prefix = `lineno`.rjust(, 3) + ': ' else: prefix = '' --- 59,63 ---- if line[-1:] == '\n': line = line[:-1] if opt_show_lineno: ! prefix = `lineno`.rjust(3) + ': ' else: prefix = '' From esr@users.sourceforge.net Fri Feb 9 16:44:51 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:44:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 cddb.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory usw-pr-cvs1:/tmp/cvs-serv3759 Modified Files: cddb.py Log Message: String method conversion. Index: cddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/cddb.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** cddb.py 1997/10/22 21:00:31 1.10 --- cddb.py 2001/02/09 16:44:49 1.11 *************** *** 31,36 **** for i in range(2, len(toc), 4): tracklist.append((None, ! (string.atoi(toc[i:i+2]), ! string.atoi(toc[i+2:i+4])))) else: tracklist = toc --- 31,36 ---- for i in range(2, len(toc), 4): tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) else: tracklist = toc *************** *** 59,63 **** if os.environ.has_key('CDDB_PATH'): path = os.environ['CDDB_PATH'] ! cddb_path = string.splitfields(path, ',') else: home = os.environ['HOME'] --- 59,63 ---- if os.environ.has_key('CDDB_PATH'): path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') else: home = os.environ['HOME'] *************** *** 74,78 **** except IOError: pass ! ntracks = string.atoi(self.id[:2], 16) self.artist = '' self.title = '' --- 74,78 ---- except IOError: pass ! ntracks = int(self.id[:2], 16) self.artist = '' self.title = '' *************** *** 107,111 **** elif name1[:5] == 'track': try: ! trackno = string.atoi(name1[5:]) except strings.atoi_error: print 'syntax error in ' + file --- 107,111 ---- elif name1[:5] == 'track': try: ! trackno = int(name1[5:]) except strings.atoi_error: print 'syntax error in ' + file *************** *** 127,133 **** if track and track[0] == ',': try: ! off = string.index(self.track[i - 1], ! ',') ! except string.index_error: pass else: --- 127,132 ---- if track and track[0] == ',': try: ! off = self.track[i - 1].index(',') ! except ValueError: pass else: *************** *** 147,152 **** for i in range(2, len(tracklist), 4): t.append((None, \ ! (string.atoi(tracklist[i:i+2]), \ ! string.atoi(tracklist[i+2:i+4])))) tracklist = t ntracks = len(tracklist) --- 146,151 ---- for i in range(2, len(tracklist), 4): t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) tracklist = t ntracks = len(tracklist) *************** *** 196,201 **** track = self.track[i] try: ! off = string.index(track, ',') ! except string.index_error: prevpref = None else: --- 195,200 ---- track = self.track[i] try: ! off = track.index(',') ! except ValuError: prevpref = None else: From esr@users.sourceforge.net Fri Feb 9 16:45:13 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:45:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 cddb.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv3866 Modified Files: cddb.py Log Message: String method conversion. Index: cddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cddb.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** cddb.py 1997/10/22 21:00:44 1.2 --- cddb.py 2001/02/09 16:45:10 1.3 *************** *** 31,36 **** for i in range(2, len(toc), 4): tracklist.append((None, ! (string.atoi(toc[i:i+2]), ! string.atoi(toc[i+2:i+4])))) else: tracklist = toc --- 31,36 ---- for i in range(2, len(toc), 4): tracklist.append((None, ! (int(toc[i:i+2]), ! int(toc[i+2:i+4])))) else: tracklist = toc *************** *** 59,63 **** if os.environ.has_key('CDDB_PATH'): path = os.environ['CDDB_PATH'] ! cddb_path = string.splitfields(path, ',') else: home = os.environ['HOME'] --- 59,63 ---- if os.environ.has_key('CDDB_PATH'): path = os.environ['CDDB_PATH'] ! cddb_path = path.split(',') else: home = os.environ['HOME'] *************** *** 74,78 **** except IOError: pass ! ntracks = string.atoi(self.id[:2], 16) self.artist = '' self.title = '' --- 74,78 ---- except IOError: pass ! ntracks = int(self.id[:2], 16) self.artist = '' self.title = '' *************** *** 107,112 **** elif name1[:5] == 'track': try: ! trackno = string.atoi(name1[5:]) ! except strings.atoi_error: print 'syntax error in ' + file continue --- 107,112 ---- elif name1[:5] == 'track': try: ! trackno = int(name1[5:]) ! except ValueError: print 'syntax error in ' + file continue *************** *** 127,133 **** if track and track[0] == ',': try: ! off = string.index(self.track[i - 1], ! ',') ! except string.index_error: pass else: --- 127,132 ---- if track and track[0] == ',': try: ! off = self.track[i - 1].index(',') ! except ValueError: pass else: *************** *** 147,152 **** for i in range(2, len(tracklist), 4): t.append((None, \ ! (string.atoi(tracklist[i:i+2]), \ ! string.atoi(tracklist[i+2:i+4])))) tracklist = t ntracks = len(tracklist) --- 146,151 ---- for i in range(2, len(tracklist), 4): t.append((None, \ ! (int(tracklist[i:i+2]), \ ! int(tracklist[i+2:i+4])))) tracklist = t ntracks = len(tracklist) *************** *** 196,201 **** track = self.track[i] try: ! off = string.index(track, ',') ! except string.index_error: prevpref = None else: --- 195,200 ---- track = self.track[i] try: ! off = track.index(',') ! except ValueError: prevpref = None else: From esr@users.sourceforge.net Fri Feb 9 16:52:58 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:52:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib multifile.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4950 Modified Files: multifile.py Log Message: String method conversion. Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** multifile.py 2001/02/06 01:07:01 1.15 --- multifile.py 2001/02/09 16:52:55 1.16 *************** *** 29,33 **** import sys - import string __all__ = ["MultiFile","Error"] --- 29,32 ---- *************** *** 89,96 **** else: # Ignore trailing whitespace on marker lines ! k = len(line) - 1 ! while line[k] in string.whitespace: ! k = k - 1 ! marker = line[:k+1] # No? OK, try to match a boundary. # Return the line (unstripped) if we don't. --- 88,92 ---- else: # Ignore trailing whitespace on marker lines ! marker = line.rstrip() # No? OK, try to match a boundary. # Return the line (unstripped) if we don't. *************** *** 122,126 **** def read(self): # Note: no size argument -- read until EOF only! ! return string.joinfields(self.readlines(), '') def next(self): --- 118,122 ---- def read(self): # Note: no size argument -- read until EOF only! ! return self.readlines().join('') def next(self): From esr@users.sourceforge.net Fri Feb 9 16:56:46 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:56:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib stringold.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5725 Modified Files: stringold.py Log Message: String method conversion. Index: stringold.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/stringold.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** stringold.py 2000/07/16 12:04:30 1.45 --- stringold.py 2001/02/09 16:56:44 1.46 *************** *** 396,400 **** for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] ! return joinfields(L, "") # Substring replacement (global) --- 396,400 ---- for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] ! return join(L, "") # Substring replacement (global) From esr@users.sourceforge.net Fri Feb 9 16:55:54 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 08:55:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib string.py,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5549 Modified Files: string.py Log Message: String method conversion. Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -r1.55 -r1.56 *** string.py 2001/01/15 01:36:40 1.55 --- string.py 2001/02/09 16:55:52 1.56 *************** *** 357,361 **** for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] ! return joinfields(L, "") # Substring replacement (global) --- 357,361 ---- for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] ! return join(L, "") # Substring replacement (global) From esr@users.sourceforge.net Fri Feb 9 17:05:56 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 09:05:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_imgfile.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv7488 Modified Files: test_imgfile.py Log Message: joinfields -> join. Index: test_imgfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_imgfile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** test_imgfile.py 2001/02/09 11:48:02 1.10 --- test_imgfile.py 2001/02/09 17:05:53 1.11 *************** *** 49,53 **** parts = ourname.split(os.sep) parts[-1] = name ! name = os.sep.joinfields(parts) sizes = imgfile.getsizes(name) if verbose: --- 49,53 ---- parts = ourname.split(os.sep) parts[-1] = name ! name = os.sep.join(parts) sizes = imgfile.getsizes(name) if verbose: From akuchlin@mems-exchange.org Fri Feb 9 19:39:36 2001 From: akuchlin@mems-exchange.org (Andrew Kuchling) Date: Fri, 9 Feb 2001 14:39:36 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 cddb.py,1.10,1.11 In-Reply-To: ; from esr@users.sourceforge.net on Fri, Feb 09, 2001 at 08:44:51AM -0800 References: Message-ID: <20010209143936.B3340@thrak.cnri.reston.va.us> On Fri, Feb 09, 2001 at 08:44:51AM -0800, Eric S. Raymond wrote: >String method conversion. Regarding the large number of string method conversion check-ins: I presume this is something else you discussed at LWE with Guido. Was there anything else discussed that python-dev should know about, or can help with? --amk From lemburg@users.sourceforge.net Fri Feb 9 19:40:17 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 09 Feb 2001 11:40:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.160,2.161 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv27106 Modified Files: import.c Log Message: This modified version of a patch by Thomas Heller allows __import__ hooks to take over the Python import machinery at a very early stage in the Python startup phase. If there are still places in the Python interpreter which need to bypass the __import__ hook, these places must now use PyImport_ImportModuleEx() instead. So far no other places than in the import mechanism itself have been identified. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.160 retrieving revision 2.161 diff -C2 -r2.160 -r2.161 *** import.c 2001/02/02 20:13:24 2.160 --- import.c 2001/02/09 19:40:15 2.161 *************** *** 1459,1469 **** PyImport_ImportModule(char *name) { ! static PyObject *fromlist = NULL; ! if (fromlist == NULL && strchr(name, '.') != NULL) { ! fromlist = Py_BuildValue("(s)", "*"); ! if (fromlist == NULL) ! return NULL; ! } ! return PyImport_ImportModuleEx(name, NULL, NULL, fromlist); } --- 1459,1469 ---- PyImport_ImportModule(char *name) { ! PyObject *pname; ! PyObject *result; ! ! pname = PyString_FromString(name); ! result = PyImport_Import(pname); ! Py_DECREF(pname); ! return result; } *************** *** 1907,1911 **** if (standard_builtins == NULL) { standard_builtins = ! PyImport_ImportModule("__builtin__"); if (standard_builtins == NULL) return NULL; --- 1907,1912 ---- if (standard_builtins == NULL) { standard_builtins = ! PyImport_ImportModuleEx("__builtin__", ! NULL, NULL, NULL); if (standard_builtins == NULL) return NULL; From tim_one@users.sourceforge.net Fri Feb 9 20:06:03 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 12:06:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asynchat.py,1.10,1.11 pickle.py,1.44,1.45 popen2.py,1.18,1.19 posixpath.py,1.40,1.41 pyclbr.py,1.17,1.18 smtpd.py,1.1,1.2 urllib.py,1.115,1.116 webbrowser.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30708/python/dist/src/Lib Modified Files: asynchat.py pickle.py popen2.py posixpath.py pyclbr.py smtpd.py urllib.py webbrowser.py Log Message: Whitespace normalization. Index: asynchat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** asynchat.py 2001/02/09 05:04:48 1.10 --- asynchat.py 2001/02/09 20:06:00 1.11 *************** *** 1,4 **** # -*- Mode: Python; tab-width: 4 -*- ! # Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp # Author: Sam Rushing --- 1,4 ---- # -*- Mode: Python; tab-width: 4 -*- ! # Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp # Author: Sam Rushing Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** pickle.py 2001/02/07 23:14:30 1.44 --- pickle.py 2001/02/09 20:06:00 1.45 *************** *** 324,328 **** self.write(BINSTRING + s + object) else: ! if unicode: object = object.replace(u"\\", u"\\u005c") object = object.replace(u"\n", u"\\u000a") --- 324,328 ---- self.write(BINSTRING + s + object) else: ! if unicode: object = object.replace(u"\\", u"\\u005c") object = object.replace(u"\n", u"\\u000a") *************** *** 336,340 **** memo[d] = (memo_len, object) dispatch[StringType] = save_string ! def save_tuple(self, object): --- 336,340 ---- memo[d] = (memo_len, object) dispatch[StringType] = save_string ! def save_tuple(self, object): Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** popen2.py 2001/02/07 23:14:30 1.18 --- popen2.py 2001/02/09 20:06:00 1.19 *************** *** 159,163 **** __all__.extend(["Popen3", "Popen4"]) ! def _test(): cmd = "cat" --- 159,163 ---- __all__.extend(["Popen3", "Popen4"]) ! def _test(): cmd = "cat" Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** posixpath.py 2001/01/29 11:29:44 1.40 --- posixpath.py 2001/02/09 20:06:00 1.41 *************** *** 347,351 **** # POSIX allows one or two initial slashes, but treats three or more # as single slash. ! if (initial_slashes and path.startswith('//') and not path.startswith('///')): initial_slashes = 2 --- 347,351 ---- # POSIX allows one or two initial slashes, but treats three or more # as single slash. ! if (initial_slashes and path.startswith('//') and not path.startswith('///')): initial_slashes = 2 Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** pyclbr.py 2001/02/09 09:32:08 1.17 --- pyclbr.py 2001/02/09 20:06:00 1.18 *************** *** 335,337 **** def _indent(ws, _expandtabs=string.expandtabs): return len(_expandtabs(ws, TABWIDTH)) - --- 335,336 ---- Index: smtpd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtpd.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** smtpd.py 2001/01/31 22:51:35 1.1 --- smtpd.py 2001/02/09 20:06:00 1.2 *************** *** 91,95 **** ! def usage(code, msg=''): print >> sys.stderr, __doc__ % globals() --- 91,95 ---- ! def usage(code, msg=''): print >> sys.stderr, __doc__ % globals() *************** *** 98,103 **** sys.exit(code) - class SMTPChannel(asynchat.async_chat): COMMAND = 0 --- 98,103 ---- sys.exit(code) + class SMTPChannel(asynchat.async_chat): COMMAND = 0 *************** *** 264,268 **** ! class SMTPServer(asyncore.dispatcher): def __init__(self, localaddr, remoteaddr): --- 264,268 ---- ! class SMTPServer(asyncore.dispatcher): def __init__(self, localaddr, remoteaddr): *************** *** 310,315 **** """ raise UnimplementedError - class DebuggingServer(SMTPServer): # Do something with the gathered message --- 310,315 ---- """ raise UnimplementedError + class DebuggingServer(SMTPServer): # Do something with the gathered message *************** *** 327,331 **** ! class PureProxy(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): --- 327,331 ---- ! class PureProxy(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): *************** *** 367,372 **** return refused - class MailmanProxy(PureProxy): def process_message(self, peer, mailfrom, rcpttos, data): --- 367,372 ---- return refused + class MailmanProxy(PureProxy): def process_message(self, peer, mailfrom, rcpttos, data): *************** *** 406,410 **** for rcpt, listname, command in listnames: rcpttos.remove(rcpt) ! # If there's any non-list destined recipients left, print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos) if rcpttos: --- 406,410 ---- for rcpt, listname, command in listnames: rcpttos.remove(rcpt) ! # If there's any non-list destined recipients left, print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos) if rcpttos: *************** *** 448,452 **** ! class Options: setuid = 1 --- 448,452 ---- ! class Options: setuid = 1 *************** *** 502,507 **** return options - if __name__ == '__main__': options = parseargs() --- 502,507 ---- return options + if __name__ == '__main__': options = parseargs() Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -r1.115 -r1.116 *** urllib.py 2001/01/28 21:11:12 1.115 --- urllib.py 2001/02/09 20:06:00 1.116 *************** *** 1104,1108 **** input. """ ! if hasattr(query,"items"): # mapping objects --- 1104,1108 ---- input. """ ! if hasattr(query,"items"): # mapping objects Index: webbrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** webbrowser.py 2001/01/23 15:49:34 1.10 --- webbrowser.py 2001/02/09 20:06:00 1.11 *************** *** 7,12 **** pass ! _browsers = {} # Dictionary of available browser controllers ! _tryorder = [] # Preference order of available browsers def register(name, klass, instance=None): --- 7,12 ---- pass ! _browsers = {} # Dictionary of available browser controllers ! _tryorder = [] # Preference order of available browsers def register(name, klass, instance=None): *************** *** 25,29 **** return browser else: ! # User gave us a browser name. command = _browsers[browser.lower()] if command[1] is None: --- 25,29 ---- return browser else: ! # User gave us a browser name. command = _browsers[browser.lower()] if command[1] is None: *************** *** 38,42 **** get().open(url, new, autoraise) ! def open_new(url): # Marked deprecated. May be removed in 2.1. get().open(url, 1) --- 38,42 ---- get().open(url, new, autoraise) ! def open_new(url): # Marked deprecated. May be removed in 2.1. get().open(url, 1) *************** *** 48,52 **** # ! # # Platform support for Unix # --- 48,52 ---- # ! # # Platform support for Unix # *************** *** 79,83 **** os.system(self.command % url) ! def open_new(self, url): # Deprecated. May be removed in 2.1. self.open(url) --- 79,83 ---- os.system(self.command % url) ! def open_new(self, url): # Deprecated. May be removed in 2.1. self.open(url) From tim_one@users.sourceforge.net Fri Feb 9 20:17:16 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 12:17:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_funcattrs.py,1.4,1.5 test_grammar.py,1.29,1.30 test_new.py,1.11,1.12 test_scope.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31697/python/dist/src/Lib/test Modified Files: test_funcattrs.py test_grammar.py test_new.py test_scope.py Log Message: Whitespace normalization. Index: test_funcattrs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_funcattrs.py 2001/01/29 06:21:17 1.4 --- test_funcattrs.py 2001/02/09 20:17:14 1.5 *************** *** 157,167 **** def foo(): ! pass def bar(): ! pass def temp(): ! print 1 if foo==bar: raise TestFailed --- 157,167 ---- def foo(): ! pass def bar(): ! pass def temp(): ! print 1 if foo==bar: raise TestFailed *************** *** 173,175 **** d[foo] - --- 173,174 ---- Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** test_grammar.py 2001/02/01 22:48:12 1.29 --- test_grammar.py 2001/02/09 20:17:14 1.30 *************** *** 368,372 **** msg = "continue + try/finally ok" print msg ! print 'return_stmt' # 'return' [testlist] def g1(): return --- 368,372 ---- msg = "continue + try/finally ok" print msg ! print 'return_stmt' # 'return' [testlist] def g1(): return Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_new.py 2001/02/01 19:50:29 1.11 --- test_new.py 2001/02/09 20:17:14 1.12 *************** *** 67,74 **** # bogus test of new.code() print 'new.code()' ! d = new.code(3, 3, 3, 3, codestr, (), (), (), "", "", 1, "", (), ()) # test backwards-compatibility version with no freevars or cellvars ! d = new.code(3, 3, 3, 3, codestr, (), (), (), "", "", 1, "") if verbose: --- 67,74 ---- # bogus test of new.code() print 'new.code()' ! d = new.code(3, 3, 3, 3, codestr, (), (), (), "", "", 1, "", (), ()) # test backwards-compatibility version with no freevars or cellvars ! d = new.code(3, 3, 3, 3, codestr, (), (), (), "", "", 1, "") if verbose: Index: test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_scope.py 2001/02/05 17:35:20 1.3 --- test_scope.py 2001/02/09 20:17:14 1.4 *************** *** 106,110 **** def identity(x): ! return x def f(x, y, z): --- 106,110 ---- def identity(x): ! return x def f(x, y, z): *************** *** 112,117 **** a = a + x # 3 def h(): ! # z * (4 + 9) ! # 3 * 13 return identity(z * (b + y)) y = c + z # 9 --- 112,117 ---- a = a + x # 3 def h(): ! # z * (4 + 9) ! # 3 * 13 return identity(z * (b + y)) y = c + z # 9 *************** *** 121,125 **** g = f(1, 2, 3) h = g(2, 4, 6) ! verify(h() == 39) print "9. free variable in method" --- 121,125 ---- g = f(1, 2, 3) h = g(2, 4, 6) ! verify(h() == 39) print "9. free variable in method" *************** *** 207,211 **** # check_syntax(test2) ! # XXX could allow this for exec with const argument, but what's the point test3 = \ """def error(y): --- 207,211 ---- # check_syntax(test2) ! # XXX could allow this for exec with const argument, but what's the point test3 = \ """def error(y): *************** *** 276,278 **** else: raise TestFailed - --- 276,277 ---- From tim_one@users.sourceforge.net Fri Feb 9 20:18:44 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 12:18:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib string.py,1.56,1.57 stringold.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31882/python/dist/src/Lib Modified Files: string.py stringold.py Log Message: Nuke accurate but confusing and unhelpful comments about split vs splitfields. Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** string.py 2001/02/09 16:55:52 1.56 --- string.py 2001/02/09 20:18:41 1.57 *************** *** 101,105 **** # Split a string into a list of space/tab-separated words - # NB: split(s) is NOT the same as splitfields(s, ' ')! def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings --- 101,104 ---- Index: stringold.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/stringold.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** stringold.py 2001/02/09 16:56:44 1.46 --- stringold.py 2001/02/09 20:18:41 1.47 *************** *** 99,103 **** # Split a string into a list of space/tab-separated words - # NB: split(s) is NOT the same as splitfields(s, ' ')! def split(s, sep=None, maxsplit=0): """split(str [,sep [,maxsplit]]) -> list of strings --- 99,102 ---- From tim_one@users.sourceforge.net Fri Feb 9 21:23:23 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 13:23:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/idle setup.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle In directory usw-pr-cvs1:/tmp/cvs-serv6672/python/dist/src/Tools/idle Modified Files: setup.py Log Message: Whitespace normalization. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/setup.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** setup.py 2001/01/28 11:01:50 1.1 --- setup.py 2001/02/09 21:23:21 1.2 *************** *** 75,79 **** cmdclass = {'build_py':idle_build_py, ! 'install_lib':idle_install_lib}, package_dir = {idlelib:'.'}, packages = [idlelib], --- 75,79 ---- cmdclass = {'build_py':idle_build_py, ! 'install_lib':idle_install_lib}, package_dir = {idlelib:'.'}, packages = [idlelib], From jhylton@users.sourceforge.net Fri Feb 9 22:22:20 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:22:20 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv13672 Modified Files: Makefile.pre.in Log Message: Relax the rules for using 'from ... import *' and exec in the presence of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** Makefile.pre.in 2001/02/06 14:50:27 1.14 --- Makefile.pre.in 2001/02/09 22:22:18 1.15 *************** *** 229,232 **** --- 229,233 ---- Python/pythonrun.o \ Python/structmember.o \ + Python/symtable.o \ Python/sysmodule.o \ Python/traceback.o \ From jhylton@users.sourceforge.net Fri Feb 9 22:22:20 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:22:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include symtable.h,2.2,2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv13672/Include Modified Files: symtable.h Log Message: Relax the rules for using 'from ... import *' and exec in the presence of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned. Index: symtable.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/symtable.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** symtable.h 2001/02/02 20:01:09 2.2 --- symtable.h 2001/02/09 22:22:18 2.3 *************** *** 15,59 **** e.g. DEF_PARAM indicates that a variable is a parameter to a function. - - The slots st_cur_XXX pointers always refer to the current code - block. The st_cur slot is the symbol dictionary. The st_cur_id - slot is the id is the key in st_symbols. The st_cur_name slot is - the name of the current scope. The st_cur_type slot is one of - TYPE_FUNCTION, TYPE_CLASS, or TYPE_MODULE. The st_cur_children is - a list of the ids of the current node's children. - - The st_symbols slot is a dictionary that maps code block ids to - symbol dictionaries. The keys are generated by a counter that is - incremented each time a new code block is found. The counter is - identifies a specific scope, because both passes walk the parse - tree in the same order. - - The st_varnames slot is a dictionary that maps code block ids to - parameter lists. The st_global slot always refers to the symbol - dictionary for the module. - - The st_children slot is a dictionary that maps ids to a list - containing the ids of its children. - - If st_keep is true then the namespace info pushed on st_stack will - also be stored in st_scopes. This is useful if the symbol table is - being passed to something other than the compiler. */ struct symtable { int st_pass; /* pass == 1 or 2 */ - int st_keep; /* true if symtable will be returned */ char *st_filename; /* name of file being compiled */ ! PyObject *st_symbols; /* dictionary of symbol tables */ ! PyObject *st_varnames; /* dictionary of parameter lists */ PyObject *st_stack; /* stack of namespace info */ - PyObject *st_scopes; /* dictionary of namespace info */ - PyObject *st_children; /* dictionary (id=[ids]) */ - PyObject *st_cur; /* borrowed ref to dict in st_symbols */ - PyObject *st_cur_name; /* string, name of current scope */ - PyObject *st_cur_id; /* int id of current code block */ - PyObject *st_cur_children; /* ref to current children list */ - int st_cur_type; /* type of current scope */ - int st_cur_lineno; /* line number where current scope begins */ PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ int st_nscopes; /* number of scopes */ --- 15,28 ---- e.g. DEF_PARAM indicates that a variable is a parameter to a function. */ + struct _symtable_entry; + struct symtable { int st_pass; /* pass == 1 or 2 */ char *st_filename; /* name of file being compiled */ ! struct _symtable_entry *st_cur; /* current symbol table entry */ ! PyObject *st_symbols; /* dictionary of symbol table entries */ PyObject *st_stack; /* stack of namespace info */ PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ int st_nscopes; /* number of scopes */ *************** *** 61,67 **** char *st_private; /* name of current class or NULL */ int st_tmpname; /* temporary name counter */ - int st_nested; /* bool (true if nested scope) */ }; DL_IMPORT(struct symtable *) PyNode_CompileSymtable(struct _node *, char *); DL_IMPORT(void) PySymtable_Free(struct symtable *); --- 30,58 ---- char *st_private; /* name of current class or NULL */ int st_tmpname; /* temporary name counter */ }; + typedef struct _symtable_entry { + PyObject_HEAD + PyObject *ste_id; /* int: key in st_symbols) */ + PyObject *ste_symbols; /* dict: name to flags) */ + PyObject *ste_name; /* string: name of scope */ + PyObject *ste_varnames; /* list of variable names */ + PyObject *ste_children; /* list of child ids */ + int ste_type; /* module, class, or function */ + int ste_lineno; /* first line of scope */ + int ste_optimized; /* true if namespace is optimized */ + int ste_nested; /* true if scope is nested */ + int ste_child_free; /* true if a child scope has free variables, + including free refs to globals */ + struct symtable *ste_table; + } PySymtableEntryObject; + + extern DL_IMPORT(PyTypeObject) PySymtableEntry_Type; + + #define PySymtableEntry_Check(op) ((op)->ob_type == &PySymtableEntry_Type) + + extern DL_IMPORT(PyObject *) PySymtableEntry_New(struct symtable *, + char *, int, int); + DL_IMPORT(struct symtable *) PyNode_CompileSymtable(struct _node *, char *); DL_IMPORT(void) PySymtable_Free(struct symtable *); *************** *** 69,73 **** #define TOP "global" - #define NOOPT ".noopt" /* Flags for def-use information */ --- 60,63 ---- From jhylton@users.sourceforge.net Fri Feb 9 22:22:20 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:22:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules symtablemodule.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13672/Modules Modified Files: symtablemodule.c Log Message: Relax the rules for using 'from ... import *' and exec in the presence of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned. Index: symtablemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/symtablemodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** symtablemodule.c 2001/02/02 18:24:25 1.1 --- symtablemodule.c 2001/02/09 22:22:18 1.2 *************** *** 32,36 **** if (st == NULL) return NULL; ! t = Py_BuildValue("OO", st->st_symbols, st->st_scopes); PySymtable_Free(st); return t; --- 32,36 ---- if (st == NULL) return NULL; ! t = Py_BuildValue("O", st->st_symbols); PySymtable_Free(st); return t; From jhylton@users.sourceforge.net Fri Feb 9 22:22:20 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:22:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python symtable.c,NONE,2.1 compile.c,2.160,2.161 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv13672/Python Modified Files: compile.c Added Files: symtable.c Log Message: Relax the rules for using 'from ... import *' and exec in the presence of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned. --- NEW FILE: symtable.c --- #include "Python.h" #include "symtable.h" #include "graminit.h" #include "structmember.h" PyObject * PySymtableEntry_New(struct symtable *st, char *name, int type, int lineno) { PySymtableEntryObject *ste = NULL; PyObject *k, *v; k = PyInt_FromLong(st->st_nscopes++); if (k == NULL) goto fail; v = PyDict_GetItem(st->st_symbols, k); if (v) /* XXX could check that name, type, lineno match */ return v; ste = (PySymtableEntryObject *)PyObject_New(PySymtableEntryObject, &PySymtableEntry_Type); ste->ste_table = st; ste->ste_id = k; v = PyString_FromString(name); if (v == NULL) goto fail; ste->ste_name = v; v = PyDict_New(); if (v == NULL) goto fail; ste->ste_symbols = v; v = PyList_New(0); if (v == NULL) goto fail; ste->ste_varnames = v; v = PyList_New(0); if (v == NULL) goto fail; ste->ste_children = v; ste->ste_optimized = 1; ste->ste_lineno = lineno; switch (type) { case funcdef: case lambdef: ste->ste_type = TYPE_FUNCTION; break; case classdef: ste->ste_type = TYPE_CLASS; break; case single_input: case eval_input: case file_input: ste->ste_type = TYPE_MODULE; break; } if (st->st_cur == NULL) ste->ste_nested = 0; else if (st->st_cur->ste_nested || st->st_cur->ste_type == TYPE_FUNCTION) ste->ste_nested = 1; else ste->ste_nested = 0; ste->ste_child_free = 0; if (PyDict_SetItem(st->st_symbols, ste->ste_id, (PyObject *)ste) < 0) goto fail; return (PyObject *)ste; fail: Py_XDECREF(ste); return NULL; } static PyObject * ste_repr(PySymtableEntryObject *ste) { char buf[256]; sprintf(buf, "", PyString_AS_STRING(ste->ste_name), PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); return PyString_FromString(buf); } static void ste_dealloc(PySymtableEntryObject *ste) { ste->ste_table = NULL; Py_XDECREF(ste->ste_id); Py_XDECREF(ste->ste_name); Py_XDECREF(ste->ste_symbols); Py_XDECREF(ste->ste_varnames); Py_XDECREF(ste->ste_children); PyObject_Del(ste); } #define OFF(x) offsetof(PySymtableEntryObject, x) static struct memberlist ste_memberlist[] = { {"id", T_OBJECT, OFF(ste_id), READONLY}, {"name", T_OBJECT, OFF(ste_name), READONLY}, {"symbols", T_OBJECT, OFF(ste_symbols), READONLY}, {"varnames", T_OBJECT, OFF(ste_varnames), READONLY}, {"children", T_OBJECT, OFF(ste_children), READONLY}, {"type", T_INT, OFF(ste_type), READONLY}, {"lineno", T_INT, OFF(ste_lineno), READONLY}, {"optimized",T_INT, OFF(ste_optimized), READONLY}, {"nested", T_INT, OFF(ste_nested), READONLY}, {NULL} }; static PyObject * ste_getattr(PySymtableEntryObject *ste, char *name) { return PyMember_Get((char *)ste, ste_memberlist, name); } PyTypeObject PySymtableEntry_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, "symtable entry", sizeof(PySymtableEntryObject), 0, (destructor)ste_dealloc, /* tp_dealloc */ 0, /* tp_print */ (getattrfunc)ste_getattr, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)ste_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ 0, /* tp_doc */ }; Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.160 retrieving revision 2.161 diff -C2 -r2.160 -r2.161 *** compile.c 2001/02/09 15:06:42 2.160 --- compile.c 2001/02/09 22:22:18 2.161 *************** *** 53,58 **** "duplicate argument '%s' in function definition" ! #define ILLEGAL_IMPORT_STAR \ ! "'from ... import *' may only occur in a module scope" #define MANGLE_LEN 256 --- 53,58 ---- "duplicate argument '%s' in function definition" ! #define ILLEGAL_DYNAMIC_SCOPE \ [...985 lines suppressed...] ! n->n_lineno); ! st->st_errors++; ! return; ! } ! if (zero == NULL) ! st->st_errors++; ! else { ! if (PyDict_SetItemString(st->st_cur, NOOPT, ! zero) < 0) ! st->st_errors++; ! Py_DECREF(zero); ! } } else { for (i = 3; i < NCH(n); i += 2) { --- 4684,4688 ---- if (STR(CHILD(n, 0))[0] == 'f') { /* from */ if (TYPE(CHILD(n, 3)) == STAR) { ! st->st_cur->ste_optimized = 0; } else { for (i = 3; i < NCH(n); i += 2) { From jhylton@users.sourceforge.net Fri Feb 9 22:55:28 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:55:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.161,2.162 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv16822/Python Modified Files: compile.c Log Message: SF patch 103589: Fix handling of cell vars that are either * or ** parameters. (Nick Mathewson) Remove to XXX comments Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -r2.161 -r2.162 *** compile.c 2001/02/09 22:22:18 2.161 --- compile.c 2001/02/09 22:55:26 2.162 *************** *** 2487,2494 **** */ - /* XXX should __debug__ and AssertionError get inserted into - the symbol table? they don't follow the normal rules - because they are always loaded as globals */ - if (Py_OptimizeFlag) return; --- 2487,2490 ---- *************** *** 3525,3532 **** } - /* XXX This function could probably be made simpler, because it - doesn't do anything except generate code for complex arguments. - */ - static void com_arglist(struct compiling *c, node *n) --- 3521,3524 ---- *************** *** 3580,3589 **** --- 3572,3591 ---- ch = CHILD(n, i+1); if (TYPE(ch) == NAME) { + PyObject *v; i += 3; + v = PyDict_GetItemString(c->c_cellvars, + STR(ch)); + if (v) { + com_addoparg(c, LOAD_FAST, narg); + com_addoparg(c, STORE_DEREF, + PyInt_AS_LONG(v)); } + narg++; } } + } /* Handle **keywords */ if (i < nch) { + PyObject *v; node *ch; ch = CHILD(n, i); *************** *** 3597,3600 **** --- 3599,3607 ---- ch = CHILD(n, i+1); REQ(ch, NAME); + v = PyDict_GetItemString(c->c_cellvars, STR(ch)); + if (v) { + com_addoparg(c, LOAD_FAST, narg); + com_addoparg(c, STORE_DEREF, PyInt_AS_LONG(v)); + } } if (complex) { From jhylton@users.sourceforge.net Fri Feb 9 22:56:48 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:56:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_grammar.py,1.30,1.31 test_scope.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv16963/test Modified Files: test_grammar.py test_scope.py Log Message: update test cases for recent compiler changes: exec/import * in nested functinos and cell vars with */** parameters Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** test_grammar.py 2001/02/09 20:17:14 1.30 --- test_grammar.py 2001/02/09 22:56:46 1.31 *************** *** 387,391 **** from sys import * from sys import path, argv - check_syntax("def f(): from sys import *") print 'global_stmt' # 'global' NAME (',' NAME)* --- 387,390 ---- Index: test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_scope.py 2001/02/09 20:17:14 1.4 --- test_scope.py 2001/02/09 22:56:46 1.5 *************** *** 186,228 **** raise TestFailed ! # XXX for now, it is easiest to call this a syntax error: ! # explicit is better than implicit... ! test1 = \ ! """def unoptimized_clash1(strip): def f(s): from string import * return strip(s) # ambiguity: free or local return f ! """ ! check_syntax(test1) ! # a little harder to reject this one, but possible... ! test2 = \ ! """def unoptimized_clash2(): from string import * def f(s): return strip(s) # ambiguity: global or local return f ! """ ! # check_syntax(test2) ! # XXX could allow this for exec with const argument, but what's the point ! test3 = \ ! """def error(y): exec "a = 1" def f(x): return x + y return f ! """ ! check_syntax(test3) ! test4 = \ ! """def f(x): def g(): return x ! del x ! """ ! check_syntax(test4) print "12. lambdas" --- 186,248 ---- raise TestFailed ! check_syntax("""def unoptimized_clash1(strip): def f(s): from string import * return strip(s) # ambiguity: free or local return f ! """) ! check_syntax("""def unoptimized_clash2(): from string import * def f(s): return strip(s) # ambiguity: global or local return f ! """) ! check_syntax("""def unoptimized_clash2(): ! from string import * ! def g(): ! def f(s): ! return strip(s) # ambiguity: global or local ! return f ! """) ! ! # XXX could allow this for exec with const argument, but what's the point ! check_syntax("""def error(y): exec "a = 1" def f(x): return x + y return f ! """) ! check_syntax("""def f(x): def g(): return x ! del x # can't del name ! """) ! ! check_syntax("""def f(): ! def g(): ! from string import * ! return strip # global or local? ! """) + # and verify a few cases that should work + + def noproblem1(): + from string import * + f = lambda x:x + + def noproblem2(): + from string import * + def f(x): + return x + 1 + + def noproblem3(): + from string import * + def f(x): + global y + y = x + print "12. lambdas" *************** *** 276,277 **** --- 296,320 ---- else: raise TestFailed + + print "14. complex definitions" + + def makeReturner(*lst): + def returner(): + return lst + return returner + + verify(makeReturner(1,2,3)() == (1,2,3)) + + def makeReturner2(**kwargs): + def returner(): + return kwargs + return returner + + verify(makeReturner2(a=11)()['a'] == 11) + + def makeAddPair((a, b)): + def addPair((c, d)): + return (a + c, b + d) + return addPair + + verify(makeAddPair((1, 2))((100, 200)) == (101,202)) From jhylton@users.sourceforge.net Fri Feb 9 22:56:48 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:56:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_grammar,1.13,1.14 test_scope,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv16963/test/output Modified Files: test_grammar test_scope Log Message: update test cases for recent compiler changes: exec/import * in nested functinos and cell vars with */** parameters Index: test_grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_grammar,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_grammar 2001/02/01 22:48:12 1.13 --- test_grammar 2001/02/09 22:56:46 1.14 *************** *** 39,43 **** raise_stmt import_stmt - SyntaxError expected for "def f(): from sys import *" global_stmt exec_stmt --- 39,42 ---- Index: test_scope =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_scope,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_scope 2001/02/05 17:35:20 1.2 --- test_scope 2001/02/09 22:56:46 1.3 *************** *** 13,14 **** --- 13,15 ---- 12. lambdas 13. UnboundLocal + 14. complex definitions From jhylton@users.sourceforge.net Fri Feb 9 22:57:12 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 14:57:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_symtable.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17046/test Modified Files: test_symtable.py Log Message: update to use new symtable interface Index: test_symtable.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_symtable.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_symtable.py 2001/02/02 18:24:25 1.1 --- test_symtable.py 2001/02/09 22:57:10 1.2 *************** *** 3,8 **** import _symtable ! symbols, scopes = _symtable.symtable("def f(x): return x", "?", "exec") ! verify(symbols.has_key(0)) ! verify(scopes.has_key(0)) --- 3,9 ---- import _symtable ! symbols = _symtable.symtable("def f(x): return x", "?", "exec") ! verify(symbols[0].name == "global") ! verify(len([ste for ste in symbols.values() if ste.name == "f"]) == 1) ! From tim_one@users.sourceforge.net Fri Feb 9 23:05:58 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 15:05:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild pythoncore.dsp,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv17962/python/dist/src/pcbuild Modified Files: pythoncore.dsp Log Message: Teach Windows build about new symtable.c. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pythoncore.dsp 2001/02/02 00:07:07 1.4 --- pythoncore.dsp 2001/02/09 23:05:56 1.5 *************** *** 1558,1561 **** --- 1558,1576 ---- # Begin Source File + SOURCE=..\Python\symtable.c + + !IF "$(CFG)" == "pythoncore - Win32 Release" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File + SOURCE=..\Python\sysmodule.c From jhylton@users.sourceforge.net Fri Feb 9 23:23:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 15:23:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.228,2.229 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv19580/Python Modified Files: ceval.c Log Message: When calling a PyCFunction that has METH_KEYWORDS defined, don't create an empty dictionary if it is called without keyword args. Just pass NULL. XXX I had believed that this caused weird errors, but the test suite runs cleanly. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.228 retrieving revision 2.229 diff -C2 -r2.228 -r2.229 *** ceval.c 2001/02/05 17:23:16 2.228 --- ceval.c 2001/02/09 23:23:20 2.229 *************** *** 2729,2742 **** if (flags & METH_KEYWORDS) { - if (kw == NULL) { - static PyObject *dict = NULL; - if (dict == NULL) { - dict = PyDict_New(); - if (dict == NULL) - return NULL; - } - kw = dict; - Py_INCREF(dict); - } return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); } --- 2729,2732 ---- From tim_one@users.sourceforge.net Fri Feb 9 23:28:09 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 15:28:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pdb.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20043/python/dist/src/Lib Modified Files: pdb.py Log Message: SF bug #131560: pdb imports 'repr', causing name collision Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** pdb.py 2001/02/09 07:58:53 1.50 --- pdb.py 2001/02/09 23:28:07 1.51 *************** *** 9,13 **** import cmd import bdb ! import repr import os import re --- 9,13 ---- import cmd import bdb ! from repr import repr as _saferepr import os import re *************** *** 125,129 **** exc_type_name = exc_type else: exc_type_name = exc_type.__name__ ! print exc_type_name + ':', repr.repr(exc_value) self.interaction(frame, exc_traceback) --- 125,129 ---- exc_type_name = exc_type else: exc_type_name = exc_type.__name__ ! print exc_type_name + ':', _saferepr(exc_value) self.interaction(frame, exc_traceback) From jhylton@users.sourceforge.net Fri Feb 9 23:44:24 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 15:44:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.27,2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21664/Modules Modified Files: cStringIO.c Log Message: In O_writelines: Replace use of string.joinfields with "".join. Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** cStringIO.c 2000/10/06 19:24:23 2.27 --- cStringIO.c 2001/02/09 23:44:22 2.28 *************** *** 461,478 **** O_writelines(Oobject *self, PyObject *args) { PyObject *tmp = 0; ! static PyObject *string_joinfields = 0; UNLESS (PyArg_ParseTuple(args, "O:writelines", &args)) return NULL; ! if (!string_joinfields) { ! UNLESS (tmp = PyImport_ImportModule("string")) return NULL; ! string_joinfields=PyObject_GetAttrString(tmp, "joinfields"); ! Py_DECREF(tmp); ! UNLESS (string_joinfields) return NULL; ! } if (PyObject_Size(args) < 0) return NULL; ! tmp = PyObject_CallFunction(string_joinfields, "Os", args, ""); UNLESS (tmp) return NULL; --- 461,481 ---- O_writelines(Oobject *self, PyObject *args) { PyObject *tmp = 0; ! static PyObject *joiner = NULL; UNLESS (PyArg_ParseTuple(args, "O:writelines", &args)) return NULL; ! if (!joiner) { ! PyObject *empty_string = PyString_FromString(""); ! if (empty_string == NULL) ! return NULL; ! joiner = PyObject_GetAttrString(empty_string, "join"); ! Py_DECREF(empty_string); ! if (joiner == NULL) ! return NULL; ! } if (PyObject_Size(args) < 0) return NULL; ! tmp = PyObject_CallFunction(joiner, "O", args); UNLESS (tmp) return NULL; From jhylton@users.sourceforge.net Fri Feb 9 23:44:24 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 15:44:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_StringIO.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21664/Lib/test Modified Files: test_StringIO.py Log Message: In O_writelines: Replace use of string.joinfields with "".join. Index: test_StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_StringIO.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_StringIO.py 2000/10/12 16:46:28 1.5 --- test_StringIO.py 2001/02/09 23:44:22 1.6 *************** *** 15,18 **** --- 15,25 ---- print `f.getvalue()` f.close() + + f = module.StringIO() + f.writelines(["a", "b", "c"]) + f.seek(0) + print `f.getvalue()` + f.close() + f = module.StringIO() f.write(s) *************** *** 32,36 **** print "Failed to catch ValueError writing to closed StringIO." - # Don't bother testing cStringIO without import StringIO, cStringIO do_test(StringIO) --- 39,42 ---- From jhylton@users.sourceforge.net Fri Feb 9 23:44:24 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 15:44:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_StringIO,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv21664/Lib/test/output Modified Files: test_StringIO Log Message: In O_writelines: Replace use of string.joinfields with "".join. Index: test_StringIO =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_StringIO,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_StringIO 2000/10/12 16:46:28 1.4 --- test_StringIO 2001/02/09 23:44:22 1.5 *************** *** 5,8 **** --- 5,9 ---- 2 'abcuvwxyz!' + 'abc' 'abcdefghij' 'abcde' *************** *** 14,17 **** --- 15,19 ---- 2 'abcuvwxyz!' + 'abc' 'abcdefghij' 'abcde' From esr@users.sourceforge.net Sat Feb 10 00:06:02 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib binhex.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23651 Modified Files: binhex.py Log Message: String method cleanup. Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** binhex.py 2001/02/09 05:07:04 1.19 --- binhex.py 2001/02/10 00:06:00 1.20 *************** *** 25,29 **** import os import struct - import string import binascii --- 25,28 ---- *************** *** 94,99 **** data = open(name).read(256) for c in data: ! if not c in string.whitespace \ ! and (c<' ' or ord(c) > 0177): break else: --- 93,97 ---- data = open(name).read(256) for c in data: ! if not c.isspace() and (c<' ' or ord(c) > 0177): break else: From esr@users.sourceforge.net Sat Feb 10 00:11:10 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:11:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mhlib.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24034 Modified Files: mhlib.py Log Message: String method cleanup. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** mhlib.py 2001/02/09 10:28:34 1.25 --- mhlib.py 2001/02/10 00:11:08 1.26 *************** *** 77,81 **** from stat import ST_NLINK import re - import string import mimetools import multifile --- 77,80 ---- *************** *** 686,690 **** hit = 0 for line in self.headers: ! if line[0] not in string.whitespace: i = line.find(':') if i > 0: --- 685,689 ---- hit = 0 for line in self.headers: ! if not line[0].isspace(): i = line.find(':') if i > 0: *************** *** 886,890 **** def fromstring(self, data): - import string new = [] for part in data.split(self.sep): --- 885,888 ---- *************** *** 919,923 **** while 1: line = f.readline() ! if not line or line[0] not in string.whitespace: break text = text + line --- 917,921 ---- while 1: line = f.readline() ! if not line or not line[0].isspace(): break text = text + line From esr@users.sourceforge.net Sat Feb 10 00:14:20 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:14:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimify.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24298 Modified Files: mimify.py Log Message: String method cleanup. Index: mimify.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimify.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** mimify.py 2001/02/09 07:08:20 1.18 --- mimify.py 2001/02/10 00:14:18 1.19 *************** *** 111,115 **** match = res.group(1) # convert underscores to spaces (before =XX conversion!) ! match = ' '.join(string.split(match, '_')) newline = newline + line[pos:res.start(0)] + mime_decode(match) pos = res.end(0) --- 111,115 ---- match = res.group(1) # convert underscores to spaces (before =XX conversion!) ! match = ' '.join(match.split('_')) newline = newline + line[pos:res.start(0)] + mime_decode(match) pos = res.end(0) From esr@users.sourceforge.net Sat Feb 10 00:18:05 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:18:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pre.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24600 Modified Files: pre.py Log Message: String method cleanup. Index: pre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pre.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pre.py 2001/02/09 09:39:08 1.5 --- pre.py 2001/02/10 00:18:03 1.6 *************** *** 86,90 **** import sys - import string from pcre import * --- 86,89 ---- *************** *** 224,231 **** """ result = list(pattern) - alphanum=string.letters+'_'+string.digits for i in range(len(pattern)): char = pattern[i] ! if char not in alphanum: if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char --- 223,229 ---- """ result = list(pattern) for i in range(len(pattern)): char = pattern[i] ! if not char.isalnum(): if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char From jhylton@users.sourceforge.net Sat Feb 10 00:19:22 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 09 Feb 2001 16:19:22 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0226.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv24712 Modified Files: pep-0226.txt Log Message: Update release schedule to reflect planned beta and final release. Begin list of open issues that must be resolved before beta. Index: pep-0226.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0226.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pep-0226.txt 2001/01/05 15:10:42 1.4 --- pep-0226.txt 2001/02/10 00:19:20 1.5 *************** *** 18,32 **** ! Tentative Release Schedule 16-Oct-2000: Python 2.0 final release ! These dates represent goals, not commitments. ! 16-Dec-2000: 2.1 PEPs ready for review ! 19-Jan-2001: First 2.1 alpha release ! 23-Feb-2001: First 2.1 beta release ! 01-Apr-2001: 2.1 final release Guidelines for making changes for Python 2.1 --- 18,47 ---- ! Release Schedule + Tentative future release dates + + 01-Mar-2001: First 2.1 beta release + XX-Mar-2001: Second beta as needed + 13-Apr-2001: 2.1 final release + + Past release dates: + + 01-Feb-2001: Python 2.1 alpha 2 release + 22-Jan-2001: Python 2.1 alpha 1 release 16-Oct-2000: Python 2.0 final release + + Open issues for Python 2.0 beta 1 + + Include Vladimir Marangozov's memory allocator as an optional + feature. It would normally be disabled, but could be enable at + configure time. ! Fix the compiler to raise SyntaxErrors with full tracebacks. ! Resolve import issues on case-insensitive, case-preserving file ! systems. + Add a default unit testing framework to the standard library. Guidelines for making changes for Python 2.1 *************** *** 54,64 **** Before the final release, we will have six weeks of beta testing and a release candidate or two. - - - Bug fix releases before 2.1 - - We may have to issue Python 2.0.1 for critical bug fixes. If we - need to issue a bug fix release, we will use a CVS branch. - General guidelines for submitting patches and making changes --- 69,72 ---- From esr@users.sourceforge.net Sat Feb 10 00:20:18 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:20:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib token.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24901 Modified Files: token.py Log Message: String method cleanup. Index: token.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/token.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** token.py 2001/02/09 11:10:16 1.9 --- token.py 2001/02/10 00:20:16 1.10 *************** *** 105,109 **** if match: name, val = match.group(1, 2) ! val = string.atoi(val) tokens[val] = name # reverse so we can sort them... keys = tokens.keys() --- 105,109 ---- if match: name, val = match.group(1, 2) ! val = int(val) tokens[val] = name # reverse so we can sort them... keys = tokens.keys() From esr@users.sourceforge.net Sat Feb 10 00:22:35 2001 From: esr@users.sourceforge.net (Eric S. Raymond) Date: Fri, 09 Feb 2001 16:22:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib traceback.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25187 Modified Files: traceback.py Log Message: String method cleanup. Index: traceback.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** traceback.py 2001/02/09 09:37:32 1.20 --- traceback.py 2001/02/10 00:22:33 1.21 *************** *** 2,6 **** import linecache - import string import sys import types --- 2,5 ---- *************** *** 155,165 **** (filename, lineno)) i = 0 ! while i < len(line) and \ ! line[i] in string.whitespace: i = i+1 list.append(' %s\n' % line.strip()) s = ' ' for c in line[i:offset-1]: ! if c in string.whitespace: s = s + c else: --- 154,163 ---- (filename, lineno)) i = 0 ! while i < len(line) and line[i].isspace(): i = i+1 list.append(' %s\n' % line.strip()) s = ' ' for c in line[i:offset-1]: ! if c.isspace(): s = s + c else: From tim_one@users.sourceforge.net Sat Feb 10 01:24:52 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 17:24:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib doctest.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30258/python/dist/src/lib Modified Files: doctest.py Log Message: Bump __version__ tuple. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** doctest.py 2001/02/09 08:33:43 1.3 --- doctest.py 2001/02/10 01:24:50 1.4 *************** *** 349,353 **** # string method conversion ! __version__ = 0, 9, 6 import types --- 349,353 ---- # string method conversion ! __version__ = 0, 9, 7 import types From tim_one@users.sourceforge.net Sat Feb 10 01:36:49 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 17:36:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_doctest.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31194/python/dist/src/lib/test Added Files: test_doctest.py Log Message: Add std test for doctest. --- NEW FILE: test_doctest.py --- import doctest doctest.testmod(doctest, verbose=1) From tim_one@users.sourceforge.net Sat Feb 10 01:36:49 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 09 Feb 2001 17:36:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_doctest,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv31194/python/dist/src/lib/test/output Added Files: test_doctest Log Message: Add std test for doctest. --- NEW FILE: test_doctest --- test_doctest Running doctest.__doc__ Trying: 1/0 Expecting: Traceback (innermost last): File "", line 1, in ? ZeroDivisionError: integer division or modulo by zero ok Trying: x = 12 Expecting: nothing ok Trying: x Expecting: 12 ok Trying: if x == 13: print "yes" else: print "no" print "NO" print "NO!!!" Expecting: no NO NO!!! ok Trying: if "yes" == \ "y" + \ "es": # in the source code you'll see the doubled backslashes print 'yes' Expecting: yes ok Trying: assert "Easy!" Expecting: nothing ok Trying: import math Expecting: nothing ok Trying: math.floor(1.9) Expecting: 1.0 ok 0 of 8 examples failed in doctest.__doc__ Running doctest.Tester.__doc__ Trying: from doctest import Tester Expecting: nothing ok Trying: t = Tester(globs={'x': 42}, verbose=0) Expecting: nothing ok Trying: t.runstring(r''' >>> x = x * 2 >>> print x 42 ''', 'XYZ') Expecting: ***************************************************************** Failure in example: print x from line #2 of XYZ Expected: 42 Got: 84 (1, 2) ok Trying: t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') Expecting: (0, 2) ok Trying: t.summarize() Expecting: 1 items had failures: 1 of 2 in XYZ ***Test Failed*** 1 failures. (1, 4) ok Trying: t.summarize(verbose=1) Expecting: 1 items passed all tests: 2 tests in example2 1 items had failures: 1 of 2 in XYZ 4 tests in 2 items. 3 passed and 1 failed. ***Test Failed*** 1 failures. (1, 4) ok 0 of 6 examples failed in doctest.Tester.__doc__ Running doctest.Tester.__init__.__doc__ 0 of 0 examples failed in doctest.Tester.__init__.__doc__ Running doctest.Tester.run__test__.__doc__ 0 of 0 examples failed in doctest.Tester.run__test__.__doc__ Running doctest.Tester.runstring.__doc__ Trying: t = Tester(globs={}, verbose=1) Expecting: nothing ok Trying: test = r''' # just an example >>> x = 1 + 2 >>> x 3 ''' Expecting: nothing ok Trying: t.runstring(test, "Example") Expecting: Running string Example Trying: x = 1 + 2 Expecting: nothing ok Trying: x Expecting: 3 ok 0 of 2 examples failed in string Example (0, 2) ok 0 of 3 examples failed in doctest.Tester.runstring.__doc__ Running doctest.Tester.summarize.__doc__ 0 of 0 examples failed in doctest.Tester.summarize.__doc__ Running doctest.Tester.rundict.__doc__ Trying: def _f(): '''>>> assert 1 == 1 ''' Expecting: nothing ok Trying: def g(): '''>>> assert 2 != 1 ''' Expecting: nothing ok Trying: d = {"_f": _f, "g": g} Expecting: nothing ok Trying: t = Tester(globs={}, verbose=0) Expecting: nothing ok Trying: t.rundict(d, "rundict_test") # _f is skipped Expecting: (0, 1) ok Trying: t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0) Expecting: nothing ok Trying: t.rundict(d, "rundict_test_pvt") # both are searched Expecting: (0, 2) ok 0 of 7 examples failed in doctest.Tester.rundict.__doc__ Running doctest.Tester.merge.__doc__ Trying: from doctest import Tester Expecting: nothing ok Trying: t1 = Tester(globs={}, verbose=0) Expecting: nothing ok Trying: t1.runstring(''' >>> x = 12 >>> print x 12 ''', "t1example") Expecting: (0, 2) ok Trying: t2 = Tester(globs={}, verbose=0) Expecting: nothing ok Trying: t2.runstring(''' >>> x = 13 >>> print x 13 ''', "t2example") Expecting: (0, 2) ok Trying: common = ">>> assert 1 + 2 == 3\n" Expecting: nothing ok Trying: t1.runstring(common, "common") Expecting: (0, 1) ok Trying: t2.runstring(common, "common") Expecting: (0, 1) ok Trying: t1.merge(t2) Expecting: *** Tester.merge: 'common' in both testers; summing outcomes. ok Trying: t1.summarize(1) Expecting: 3 items passed all tests: 2 tests in common 2 tests in t1example 2 tests in t2example 6 tests in 3 items. 6 passed and 0 failed. Test passed. (0, 6) ok 0 of 10 examples failed in doctest.Tester.merge.__doc__ Running doctest.Tester.rundoc.__doc__ Trying: t = Tester(globs={}, verbose=0) Expecting: nothing ok Trying: def _f(): '''Trivial docstring example. >>> assert 2 == 2 ''' return 32 Expecting: nothing ok Trying: t.rundoc(_f) # expect 0 failures in 1 example Expecting: (0, 1) ok 0 of 3 examples failed in doctest.Tester.rundoc.__doc__ Running doctest.is_private.__doc__ Trying: is_private("a.b", "my_func") Expecting: 0 ok Trying: is_private("____", "_my_func") Expecting: 1 ok Trying: is_private("someclass", "__init__") Expecting: 0 ok Trying: is_private("sometypo", "__init_") Expecting: 1 ok Trying: is_private("x.y.z", "_") Expecting: 1 ok Trying: is_private("_x.y.z", "__") Expecting: 0 ok Trying: is_private("", "") # senseless but consistent Expecting: 0 ok 0 of 7 examples failed in doctest.is_private.__doc__ Running doctest.run_docstring_examples.__doc__ 0 of 0 examples failed in doctest.run_docstring_examples.__doc__ Running doctest.testmod.__doc__ 0 of 0 examples failed in doctest.testmod.__doc__ Running doctest.__test__._TestClass.__doc__ Trying: _TestClass(13).get() + _TestClass(-12).get() Expecting: 1 ok Trying: hex(_TestClass(13).square().get()) Expecting: '0xa9' ok 0 of 2 examples failed in doctest.__test__._TestClass.__doc__ Running doctest.__test__._TestClass.get.__doc__ Trying: x = _TestClass(-42) Expecting: nothing ok Trying: print x.get() Expecting: -42 ok 0 of 2 examples failed in doctest.__test__._TestClass.get.__doc__ Running doctest.__test__._TestClass.__init__.__doc__ Trying: t = _TestClass(123) Expecting: nothing ok Trying: print t.get() Expecting: 123 ok 0 of 2 examples failed in doctest.__test__._TestClass.__init__.__doc__ Running doctest.__test__._TestClass.square.__doc__ Trying: _TestClass(13).square().get() Expecting: 169 ok 0 of 1 examples failed in doctest.__test__._TestClass.square.__doc__ Running string doctest.__test__.string Trying: x = 1; y = 2 Expecting: nothing ok Trying: x + y, x * y Expecting: (3, 2) ok 0 of 2 examples failed in string doctest.__test__.string 5 items had no tests: doctest.Tester.__init__ doctest.Tester.run__test__ doctest.Tester.summarize doctest.run_docstring_examples doctest.testmod 12 items passed all tests: 8 tests in doctest 6 tests in doctest.Tester 10 tests in doctest.Tester.merge 7 tests in doctest.Tester.rundict 3 tests in doctest.Tester.rundoc 3 tests in doctest.Tester.runstring 2 tests in doctest.__test__._TestClass 2 tests in doctest.__test__._TestClass.__init__ 2 tests in doctest.__test__._TestClass.get 1 tests in doctest.__test__._TestClass.square 2 tests in doctest.__test__.string 7 tests in doctest.is_private 53 tests in 17 items. 53 passed and 0 failed. Test passed. From tim_one@users.sourceforge.net Sat Feb 10 08:00:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 00:00:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_difflib.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20941/python/dist/src/Lib/test Added Files: test_difflib.py Log Message: Moved SequenceMatcher from ndiff into new std library module difflib.py. Guido told me to do this . Greatly expanded docstrings, and fleshed out with examples. New std test. Added new get_close_matches() function for ESR. Needs docs, but LaTeXification of the module docstring is all it needs. \CVS: ---------------------------------------------------------------------- --- NEW FILE: test_difflib.py --- import doctest, difflib doctest.testmod(difflib, verbose=1) From tim_one@users.sourceforge.net Sat Feb 10 08:00:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 00:00:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_difflib,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv20941/python/dist/src/Lib/test/output Added Files: test_difflib Log Message: Moved SequenceMatcher from ndiff into new std library module difflib.py. Guido told me to do this . Greatly expanded docstrings, and fleshed out with examples. New std test. Added new get_close_matches() function for ESR. Needs docs, but LaTeXification of the module docstring is all it needs. \CVS: ---------------------------------------------------------------------- --- NEW FILE: test_difflib --- test_difflib Running difflib.__doc__ Trying: get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) Expecting: ['apple', 'ape'] ok Trying: import keyword Expecting: nothing ok Trying: get_close_matches("wheel", keyword.kwlist) Expecting: ['while'] ok Trying: get_close_matches("apple", keyword.kwlist) Expecting: [] ok Trying: get_close_matches("accept", keyword.kwlist) Expecting: ['except'] ok Trying: s = SequenceMatcher(lambda x: x == " ", "private Thread currentThread;", "private volatile Thread currentThread;") Expecting: nothing ok Trying: print round(s.ratio(), 3) Expecting: 0.866 ok Trying: for block in s.get_matching_blocks(): print "a[%d] and b[%d] match for %d elements" % block Expecting: a[0] and b[0] match for 8 elements a[8] and b[17] match for 6 elements a[14] and b[23] match for 15 elements a[29] and b[38] match for 0 elements ok Trying: for opcode in s.get_opcodes(): print "%6s a[%d:%d] b[%d:%d]" % opcode Expecting: equal a[0:8] b[0:8] insert a[8:8] b[8:17] equal a[8:14] b[17:23] equal a[14:29] b[23:38] ok Trying: s = SequenceMatcher() Expecting: nothing ok Trying: s.set_seqs("abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.set_seq1("bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 1.0 ok Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.set_seq2("abcd") Expecting: nothing ok Trying: s.ratio() Expecting: 1.0 ok Trying: s = SequenceMatcher(None, " abcd", "abcd abcd") Expecting: nothing ok Trying: s.find_longest_match(0, 5, 0, 9) Expecting: (0, 4, 5) ok Trying: s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") Expecting: nothing ok Trying: s.find_longest_match(0, 5, 0, 9) Expecting: (1, 0, 4) ok Trying: s = SequenceMatcher(None, "ab", "c") Expecting: nothing ok Trying: s.find_longest_match(0, 2, 0, 1) Expecting: (0, 0, 0) ok Trying: s = SequenceMatcher(None, "abxcd", "abcd") Expecting: nothing ok Trying: s.get_matching_blocks() Expecting: [(0, 0, 2), (3, 2, 2), (5, 4, 0)] ok Trying: a = "qabxcd" Expecting: nothing ok Trying: b = "abycdf" Expecting: nothing ok Trying: s = SequenceMatcher(None, a, b) Expecting: nothing ok Trying: for tag, i1, i2, j1, j2 in s.get_opcodes(): print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) Expecting: delete a[0:1] (q) b[0:0] () equal a[1:3] (ab) b[0:2] (ab) replace a[3:4] (x) b[2:3] (y) equal a[4:6] (cd) b[3:5] (cd) insert a[6:6] () b[5:6] (f) ok Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.quick_ratio() Expecting: 0.75 ok Trying: s.real_quick_ratio() Expecting: 1.0 ok 0 of 36 examples failed in difflib.__doc__ Running difflib.SequenceMatcher.__doc__ 0 of 0 examples failed in difflib.SequenceMatcher.__doc__ Running difflib.SequenceMatcher.__init__.__doc__ 0 of 0 examples failed in difflib.SequenceMatcher.__init__.__doc__ Running difflib.SequenceMatcher.find_longest_match.__doc__ Trying: s = SequenceMatcher(None, " abcd", "abcd abcd") Expecting: nothing ok Trying: s.find_longest_match(0, 5, 0, 9) Expecting: (0, 4, 5) ok Trying: s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") Expecting: nothing ok Trying: s.find_longest_match(0, 5, 0, 9) Expecting: (1, 0, 4) ok Trying: s = SequenceMatcher(None, "ab", "c") Expecting: nothing ok Trying: s.find_longest_match(0, 2, 0, 1) Expecting: (0, 0, 0) ok 0 of 6 examples failed in difflib.SequenceMatcher.find_longest_match.__doc__ Running difflib.SequenceMatcher.get_opcodes.__doc__ Trying: a = "qabxcd" Expecting: nothing ok Trying: b = "abycdf" Expecting: nothing ok Trying: s = SequenceMatcher(None, a, b) Expecting: nothing ok Trying: for tag, i1, i2, j1, j2 in s.get_opcodes(): print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) Expecting: delete a[0:1] (q) b[0:0] () equal a[1:3] (ab) b[0:2] (ab) replace a[3:4] (x) b[2:3] (y) equal a[4:6] (cd) b[3:5] (cd) insert a[6:6] () b[5:6] (f) ok 0 of 4 examples failed in difflib.SequenceMatcher.get_opcodes.__doc__ Running difflib.SequenceMatcher.quick_ratio.__doc__ 0 of 0 examples failed in difflib.SequenceMatcher.quick_ratio.__doc__ Running difflib.SequenceMatcher.set_seqs.__doc__ Trying: s = SequenceMatcher() Expecting: nothing ok Trying: s.set_seqs("abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok 0 of 3 examples failed in difflib.SequenceMatcher.set_seqs.__doc__ Running difflib.SequenceMatcher.set_seq2.__doc__ Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.set_seq2("abcd") Expecting: nothing ok Trying: s.ratio() Expecting: 1.0 ok 0 of 4 examples failed in difflib.SequenceMatcher.set_seq2.__doc__ Running difflib.SequenceMatcher.set_seq1.__doc__ Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.set_seq1("bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 1.0 ok 0 of 4 examples failed in difflib.SequenceMatcher.set_seq1.__doc__ Running difflib.SequenceMatcher.get_matching_blocks.__doc__ Trying: s = SequenceMatcher(None, "abxcd", "abcd") Expecting: nothing ok Trying: s.get_matching_blocks() Expecting: [(0, 0, 2), (3, 2, 2), (5, 4, 0)] ok 0 of 2 examples failed in difflib.SequenceMatcher.get_matching_blocks.__doc__ Running difflib.SequenceMatcher.real_quick_ratio.__doc__ 0 of 0 examples failed in difflib.SequenceMatcher.real_quick_ratio.__doc__ Running difflib.SequenceMatcher.ratio.__doc__ Trying: s = SequenceMatcher(None, "abcd", "bcde") Expecting: nothing ok Trying: s.ratio() Expecting: 0.75 ok Trying: s.quick_ratio() Expecting: 0.75 ok Trying: s.real_quick_ratio() Expecting: 1.0 ok 0 of 4 examples failed in difflib.SequenceMatcher.ratio.__doc__ Running difflib.get_close_matches.__doc__ Trying: get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) Expecting: ['apple', 'ape'] ok Trying: import keyword Expecting: nothing ok Trying: get_close_matches("wheel", keyword.kwlist) Expecting: ['while'] ok Trying: get_close_matches("apple", keyword.kwlist) Expecting: [] ok Trying: get_close_matches("accept", keyword.kwlist) Expecting: ['except'] ok 0 of 5 examples failed in difflib.get_close_matches.__doc__ 4 items had no tests: difflib.SequenceMatcher difflib.SequenceMatcher.__init__ difflib.SequenceMatcher.quick_ratio difflib.SequenceMatcher.real_quick_ratio 9 items passed all tests: 36 tests in difflib 6 tests in difflib.SequenceMatcher.find_longest_match 2 tests in difflib.SequenceMatcher.get_matching_blocks 4 tests in difflib.SequenceMatcher.get_opcodes 4 tests in difflib.SequenceMatcher.ratio 4 tests in difflib.SequenceMatcher.set_seq1 4 tests in difflib.SequenceMatcher.set_seq2 3 tests in difflib.SequenceMatcher.set_seqs 5 tests in difflib.get_close_matches 68 tests in 13 items. 68 passed and 0 failed. Test passed. From tim_one@users.sourceforge.net Sat Feb 10 08:00:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 00:00:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts ndiff.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv20941/python/dist/src/Tools/scripts Modified Files: ndiff.py Log Message: Moved SequenceMatcher from ndiff into new std library module difflib.py. Guido told me to do this . Greatly expanded docstrings, and fleshed out with examples. New std test. Added new get_close_matches() function for ESR. Needs docs, but LaTeXification of the module docstring is all it needs. \CVS: ---------------------------------------------------------------------- Index: ndiff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/ndiff.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** ndiff.py 2001/01/17 08:48:39 1.7 --- ndiff.py 2001/02/10 08:00:53 1.8 *************** *** 98,101 **** --- 98,103 ---- # have been in sys.argv[1:] had the cmd-line form been used. + from difflib import SequenceMatcher + import string TRACE = 0 *************** *** 111,406 **** del re - - class SequenceMatcher: - def __init__(self, isjunk=None, a='', b=''): - # Members: - # a - # first sequence - # b - # second sequence; differences are computed as "what do - # we need to do to 'a' to change it into 'b'?" - # b2j - # for x in b, b2j[x] is a list of the indices (into b) - # at which x appears; junk elements do not appear - # b2jhas - # b2j.has_key - # fullbcount - # for x in b, fullbcount[x] == the number of times x - # appears in b; only materialized if really needed (used - # only for computing quick_ratio()) - # matching_blocks - # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k]; - # ascending & non-overlapping in i and in j; terminated by - # a dummy (len(a), len(b), 0) sentinel - # opcodes - # a list of (tag, i1, i2, j1, j2) tuples, where tag is - # one of - # 'replace' a[i1:i2] should be replaced by b[j1:j2] - # 'delete' a[i1:i2] should be deleted - # 'insert' b[j1:j2] should be inserted - # 'equal' a[i1:i2] == b[j1:j2] - # isjunk - # a user-supplied function taking a sequence element and - # returning true iff the element is "junk" -- this has - # subtle but helpful effects on the algorithm, which I'll - # get around to writing up someday <0.9 wink>. - # DON'T USE! Only __chain_b uses this. Use isbjunk. - # isbjunk - # for x in b, isbjunk(x) == isjunk(x) but much faster; - # it's really the has_key method of a hidden dict. - # DOES NOT WORK for x in a! - - self.isjunk = isjunk - self.a = self.b = None - self.set_seqs(a, b) - - def set_seqs(self, a, b): - self.set_seq1(a) - self.set_seq2(b) - - def set_seq1(self, a): - if a is self.a: - return - self.a = a - self.matching_blocks = self.opcodes = None - - def set_seq2(self, b): - if b is self.b: - return - self.b = b - self.matching_blocks = self.opcodes = None - self.fullbcount = None - self.__chain_b() - - # For each element x in b, set b2j[x] to a list of the indices in - # b where x appears; the indices are in increasing order; note that - # the number of times x appears in b is len(b2j[x]) ... - # when self.isjunk is defined, junk elements don't show up in this - # map at all, which stops the central find_longest_match method - # from starting any matching block at a junk element ... - # also creates the fast isbjunk function ... - # note that this is only called when b changes; so for cross-product - # kinds of matches, it's best to call set_seq2 once, then set_seq1 - # repeatedly - - def __chain_b(self): - # Because isjunk is a user-defined (not C) function, and we test - # for junk a LOT, it's important to minimize the number of calls. - # Before the tricks described here, __chain_b was by far the most - # time-consuming routine in the whole module! If anyone sees - # Jim Roskind, thank him again for profile.py -- I never would - # have guessed that. - # The first trick is to build b2j ignoring the possibility - # of junk. I.e., we don't call isjunk at all yet. Throwing - # out the junk later is much cheaper than building b2j "right" - # from the start. - b = self.b - self.b2j = b2j = {} - self.b2jhas = b2jhas = b2j.has_key - for i in xrange(len(b)): - elt = b[i] - if b2jhas(elt): - b2j[elt].append(i) - else: - b2j[elt] = [i] - - # Now b2j.keys() contains elements uniquely, and especially when - # the sequence is a string, that's usually a good deal smaller - # than len(string). The difference is the number of isjunk calls - # saved. - isjunk, junkdict = self.isjunk, {} - if isjunk: - for elt in b2j.keys(): - if isjunk(elt): - junkdict[elt] = 1 # value irrelevant; it's a set - del b2j[elt] - - # Now for x in b, isjunk(x) == junkdict.has_key(x), but the - # latter is much faster. Note too that while there may be a - # lot of junk in the sequence, the number of *unique* junk - # elements is probably small. So the memory burden of keeping - # this dict alive is likely trivial compared to the size of b2j. - self.isbjunk = junkdict.has_key - - def find_longest_match(self, alo, ahi, blo, bhi): - """Find longest matching block in a[alo:ahi] and b[blo:bhi]. - - If isjunk is not defined: - - Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where - alo <= i <= i+k <= ahi - blo <= j <= j+k <= bhi - and for all (i',j',k') meeting those conditions, - k >= k' - i <= i' - and if i == i', j <= j' - In other words, of all maximal matching blocks, return one - that starts earliest in a, and of all those maximal matching - blocks that start earliest in a, return the one that starts - earliest in b. - - If isjunk is defined, first the longest matching block is - determined as above, but with the additional restriction that - no junk element appears in the block. Then that block is - extended as far as possible by matching (only) junk elements on - both sides. So the resulting block never matches on junk except - as identical junk happens to be adjacent to an "interesting" - match. - - If no blocks match, return (alo, blo, 0). - """ - - # CAUTION: stripping common prefix or suffix would be incorrect. - # E.g., - # ab - # acab - # Longest matching block is "ab", but if common prefix is - # stripped, it's "a" (tied with "b"). UNIX(tm) diff does so - # strip, so ends up claiming that ab is changed to acab by - # inserting "ca" in the middle. That's minimal but unintuitive: - # "it's obvious" that someone inserted "ac" at the front. - # Windiff ends up at the same place as diff, but by pairing up - # the unique 'b's and then matching the first two 'a's. - - a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk - besti, bestj, bestsize = alo, blo, 0 - # find longest junk-free match - # during an iteration of the loop, j2len[j] = length of longest - # junk-free match ending with a[i-1] and b[j] - j2len = {} - nothing = [] - for i in xrange(alo, ahi): - # look at all instances of a[i] in b; note that because - # b2j has no junk keys, the loop is skipped if a[i] is junk - j2lenget = j2len.get - newj2len = {} - for j in b2j.get(a[i], nothing): - # a[i] matches b[j] - if j < blo: - continue - if j >= bhi: - break - k = newj2len[j] = j2lenget(j-1, 0) + 1 - if k > bestsize: - besti, bestj, bestsize = i-k+1, j-k+1, k - j2len = newj2len - - # Now that we have a wholly interesting match (albeit possibly - # empty!), we may as well suck up the matching junk on each - # side of it too. Can't think of a good reason not to, and it - # saves post-processing the (possibly considerable) expense of - # figuring out what to do with it. In the case of an empty - # interesting match, this is clearly the right thing to do, - # because no other kind of match is possible in the regions. - while besti > alo and bestj > blo and \ - isbjunk(b[bestj-1]) and \ - a[besti-1] == b[bestj-1]: - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - while besti+bestsize < ahi and bestj+bestsize < bhi and \ - isbjunk(b[bestj+bestsize]) and \ - a[besti+bestsize] == b[bestj+bestsize]: - bestsize = bestsize + 1 - - if TRACE: - print "get_matching_blocks", alo, ahi, blo, bhi - print " returns", besti, bestj, bestsize - return besti, bestj, bestsize - - def get_matching_blocks(self): - if self.matching_blocks is not None: - return self.matching_blocks - self.matching_blocks = [] - la, lb = len(self.a), len(self.b) - self.__helper(0, la, 0, lb, self.matching_blocks) - self.matching_blocks.append( (la, lb, 0) ) - if TRACE: - print '*** matching blocks', self.matching_blocks - return self.matching_blocks - - # builds list of matching blocks covering a[alo:ahi] and - # b[blo:bhi], appending them in increasing order to answer - - def __helper(self, alo, ahi, blo, bhi, answer): - i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi) - # a[alo:i] vs b[blo:j] unknown - # a[i:i+k] same as b[j:j+k] - # a[i+k:ahi] vs b[j+k:bhi] unknown - if k: - if alo < i and blo < j: - self.__helper(alo, i, blo, j, answer) - answer.append(x) - if i+k < ahi and j+k < bhi: - self.__helper(i+k, ahi, j+k, bhi, answer) - - def ratio(self): - """Return a measure of the sequences' similarity (float in [0,1]). - - Where T is the total number of elements in both sequences, and - M is the number of matches, this is 2*M / T. - Note that this is 1 if the sequences are identical, and 0 if - they have nothing in common. - """ - - matches = reduce(lambda sum, triple: sum + triple[-1], - self.get_matching_blocks(), 0) - return 2.0 * matches / (len(self.a) + len(self.b)) - - def quick_ratio(self): - """Return an upper bound on ratio() relatively quickly.""" - # viewing a and b as multisets, set matches to the cardinality - # of their intersection; this counts the number of matches - # without regard to order, so is clearly an upper bound - if self.fullbcount is None: - self.fullbcount = fullbcount = {} - for elt in self.b: - fullbcount[elt] = fullbcount.get(elt, 0) + 1 - fullbcount = self.fullbcount - # avail[x] is the number of times x appears in 'b' less the - # number of times we've seen it in 'a' so far ... kinda - avail = {} - availhas, matches = avail.has_key, 0 - for elt in self.a: - if availhas(elt): - numb = avail[elt] - else: - numb = fullbcount.get(elt, 0) - avail[elt] = numb - 1 - if numb > 0: - matches = matches + 1 - return 2.0 * matches / (len(self.a) + len(self.b)) - - def real_quick_ratio(self): - """Return an upper bound on ratio() very quickly""" - la, lb = len(self.a), len(self.b) - # can't have more matches than the number of elements in the - # shorter sequence - return 2.0 * min(la, lb) / (la + lb) - - def get_opcodes(self): - if self.opcodes is not None: - return self.opcodes - i = j = 0 - self.opcodes = answer = [] - for ai, bj, size in self.get_matching_blocks(): - # invariant: we've pumped out correct diffs to change - # a[:i] into b[:j], and the next matching block is - # a[ai:ai+size] == b[bj:bj+size]. So we need to pump - # out a diff to change a[i:ai] into b[j:bj], pump out - # the matching block, and move (i,j) beyond the match - tag = '' - if i < ai and j < bj: - tag = 'replace' - elif i < ai: - tag = 'delete' - elif j < bj: - tag = 'insert' - if tag: - answer.append( (tag, i, ai, j, bj) ) - i, j = ai+size, bj+size - # the list of matching blocks is terminated by a - # sentinel with size 0 - if size: - answer.append( ('equal', ai, i, bj, j) ) - return answer # meant for dumping lines --- 113,116 ---- From tim_one@users.sourceforge.net Sat Feb 10 08:00:55 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 00:00:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib difflib.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20941/python/dist/src/Lib Added Files: difflib.py Log Message: Moved SequenceMatcher from ndiff into new std library module difflib.py. Guido told me to do this . Greatly expanded docstrings, and fleshed out with examples. New std test. Added new get_close_matches() function for ESR. Needs docs, but LaTeXification of the module docstring is all it needs. \CVS: ---------------------------------------------------------------------- --- NEW FILE: difflib.py --- #! /usr/bin/env python """ Module difflib -- helpers for computing deltas between objects. Function get_close_matches(word, possibilities, n=3, cutoff=0.6): Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities that don't score at least that similar to word are ignored. The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first. >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) ['apple', 'ape'] >>> import keyword >>> get_close_matches("wheel", keyword.kwlist) ['while'] >>> get_close_matches("apple", keyword.kwlist) [] >>> get_close_matches("accept", keyword.kwlist) ['except'] Class SequenceMatcher SequenceMatcher is a flexible class for comparing pairs of sequences of any type, so long as the sequence elements are hashable. The basic algorithm predates, and is a little fancier than, an algorithm published in the late 1980's by Ratcliff and Obershelp under the hyperbolic name "gestalt pattern matching". The basic idea is to find the longest contiguous matching subsequence that contains no "junk" elements (R-O doesn't address junk). The same idea is then applied recursively to the pieces of the sequences to the left and to the right of the matching subsequence. This does not yield minimal edit sequences, but does tend to yield matches that "look right" to people. Example, comparing two strings, and considering blanks to be "junk": >>> s = SequenceMatcher(lambda x: x == " ", ... "private Thread currentThread;", ... "private volatile Thread currentThread;") >>> .ratio() returns a float in [0, 1], measuring the "similarity" of the sequences. As a rule of thumb, a .ratio() value over 0.6 means the sequences are close matches: >>> print round(s.ratio(), 3) 0.866 >>> If you're only interested in where the sequences match, .get_matching_blocks() is handy: >>> for block in s.get_matching_blocks(): ... print "a[%d] and b[%d] match for %d elements" % block a[0] and b[0] match for 8 elements a[8] and b[17] match for 6 elements a[14] and b[23] match for 15 elements a[29] and b[38] match for 0 elements Note that the last tuple returned by .get_matching_blocks() is always a dummy, (len(a), len(b), 0), and this is the only case in which the last tuple element (number of elements matched) is 0. If you want to know how to change the first sequence into the second, use .get_opcodes(): >>> for opcode in s.get_opcodes(): ... print "%6s a[%d:%d] b[%d:%d]" % opcode equal a[0:8] b[0:8] insert a[8:8] b[8:17] equal a[8:14] b[17:23] equal a[14:29] b[23:38] See Tools/scripts/ndiff.py for a fancy human-friendly file differencer, which uses SequenceMatcher both to view files as sequences of lines, and lines as sequences of characters. See also function get_close_matches() in this module, which shows how simple code building on SequenceMatcher can be used to do useful work. Timing: Basic R-O is cubic time worst case and quadratic time expected case. SequenceMatcher is quadratic time worst case and has expected-case behavior dependent on how many elements the sequences have in common; best case time (no elements in common) is linear. SequenceMatcher methods: __init__(isjunk=None, a='', b='') Construct a SequenceMatcher. Optional arg isjunk is None (the default), or a one-argument function that takes a sequence element and returns true iff the element is junk. None is equivalent to passing "lambda x: 0", i.e. no elements are considered to be junk. For examples, pass lambda x: x in " \\t" if you're comparing lines as sequences of characters, and don't want to synch up on blanks or hard tabs. Optional arg a is the first of two sequences to be compared. By default, an empty string. The elements of a must be hashable. Optional arg b is the second of two sequences to be compared. By default, an empty string. The elements of b must be hashable. set_seqs(a, b) Set the two sequences to be compared. >>> s = SequenceMatcher() >>> s.set_seqs("abcd", "bcde") >>> s.ratio() 0.75 set_seq1(a) Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq2(). set_seq2(b) Set the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq1(). find_longest_match(alo, ahi, blo, bhi) Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j',k') meeting those conditions, k >= k' i <= i' and if i == i', j <= j' In other words, of all maximal matching blocks, return one that starts earliest in a, and of all those maximal matching blocks that start earliest in a, return the one that starts earliest in b. >>> s = SequenceMatcher(None, " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) (0, 4, 5) If isjunk is defined, first the longest matching block is determined as above, but with the additional restriction that no junk element appears in the block. Then that block is extended as far as possible by matching (only) junk elements on both sides. So the resulting block never matches on junk except as identical junk happens to be adjacent to an "interesting" match. Here's the same example as before, but considering blanks to be junk. That prevents " abcd" from matching the " abcd" at the tail end of the second sequence directly. Instead only the "abcd" can match, and matches the leftmost "abcd" in the second sequence: >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) (1, 0, 4) If no blocks match, return (alo, blo, 0). >>> s = SequenceMatcher(None, "ab", "c") >>> s.find_longest_match(0, 2, 0, 1) (0, 0, 0) get_matching_blocks() Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. The last triple is a dummy, (len(a), len(b), 0), and is the only triple with n==0. >>> s = SequenceMatcher(None, "abxcd", "abcd") >>> s.get_matching_blocks() [(0, 0, 2), (3, 2, 2), (5, 4, 0)] get_opcodes() Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. The tags are strings, with these meanings: 'replace': a[i1:i2] should be replaced by b[j1:j2] 'delete': a[i1:i2] should be deleted. Note that j1==j2 in this case. 'insert': b[j1:j2] should be inserted at a[i1:i1]. Note that i1==i2 in this case. 'equal': a[i1:i2] == b[j1:j2] >>> a = "qabxcd" >>> b = "abycdf" >>> s = SequenceMatcher(None, a, b) >>> for tag, i1, i2, j1, j2 in s.get_opcodes(): ... print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) delete a[0:1] (q) b[0:0] () equal a[1:3] (ab) b[0:2] (ab) replace a[3:4] (x) b[2:3] (y) equal a[4:6] (cd) b[3:5] (cd) insert a[6:6] () b[5:6] (f) ratio() Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2,0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. .ratio() is expensive to compute if you haven't already computed .get_matching_blocks() or .get_opcodes(), in which case you may want to try .quick_ratio() or .real_quick_ratio() first to get an upper bound. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.quick_ratio() 0.75 >>> s.real_quick_ratio() 1.0 quick_ratio() Return an upper bound on .ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute. real_quick_ratio(): Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio(). """ TRACE = 0 class SequenceMatcher: def __init__(self, isjunk=None, a='', b=''): """Construct a SequenceMatcher. Optional arg isjunk is None (the default), or a one-argument function that takes a sequence element and returns true iff the element is junk. None is equivalent to passing "lambda x: 0", i.e. no elements are considered to be junk. For examples, pass lambda x: x in " \\t" if you're comparing lines as sequences of characters, and don't want to synch up on blanks or hard tabs. Optional arg a is the first of two sequences to be compared. By default, an empty string. The elements of a must be hashable. See also .set_seqs() and .set_seq1(). Optional arg b is the second of two sequences to be compared. By default, an empty string. The elements of a must be hashable. See also .set_seqs() and .set_seq2(). """ # Members: # a # first sequence # b # second sequence; differences are computed as "what do # we need to do to 'a' to change it into 'b'?" # b2j # for x in b, b2j[x] is a list of the indices (into b) # at which x appears; junk elements do not appear # b2jhas # b2j.has_key # fullbcount # for x in b, fullbcount[x] == the number of times x # appears in b; only materialized if really needed (used # only for computing quick_ratio()) # matching_blocks # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k]; # ascending & non-overlapping in i and in j; terminated by # a dummy (len(a), len(b), 0) sentinel # opcodes # a list of (tag, i1, i2, j1, j2) tuples, where tag is # one of # 'replace' a[i1:i2] should be replaced by b[j1:j2] # 'delete' a[i1:i2] should be deleted # 'insert' b[j1:j2] should be inserted # 'equal' a[i1:i2] == b[j1:j2] # isjunk # a user-supplied function taking a sequence element and # returning true iff the element is "junk" -- this has # subtle but helpful effects on the algorithm, which I'll # get around to writing up someday <0.9 wink>. # DON'T USE! Only __chain_b uses this. Use isbjunk. # isbjunk # for x in b, isbjunk(x) == isjunk(x) but much faster; # it's really the has_key method of a hidden dict. # DOES NOT WORK for x in a! self.isjunk = isjunk self.a = self.b = None self.set_seqs(a, b) def set_seqs(self, a, b): """Set the two sequences to be compared. >>> s = SequenceMatcher() >>> s.set_seqs("abcd", "bcde") >>> s.ratio() 0.75 """ self.set_seq1(a) self.set_seq2(b) def set_seq1(self, a): """Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq2(). """ if a is self.a: return self.a = a self.matching_blocks = self.opcodes = None def set_seq2(self, b): """Set the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed information about the second sequence, so if you want to compare one sequence S against many sequences, use .set_seq2(S) once and call .set_seq1(x) repeatedly for each of the other sequences. See also set_seqs() and set_seq1(). """ if b is self.b: return self.b = b self.matching_blocks = self.opcodes = None self.fullbcount = None self.__chain_b() # For each element x in b, set b2j[x] to a list of the indices in # b where x appears; the indices are in increasing order; note that # the number of times x appears in b is len(b2j[x]) ... # when self.isjunk is defined, junk elements don't show up in this # map at all, which stops the central find_longest_match method # from starting any matching block at a junk element ... # also creates the fast isbjunk function ... # note that this is only called when b changes; so for cross-product # kinds of matches, it's best to call set_seq2 once, then set_seq1 # repeatedly def __chain_b(self): # Because isjunk is a user-defined (not C) function, and we test # for junk a LOT, it's important to minimize the number of calls. # Before the tricks described here, __chain_b was by far the most # time-consuming routine in the whole module! If anyone sees # Jim Roskind, thank him again for profile.py -- I never would # have guessed that. # The first trick is to build b2j ignoring the possibility # of junk. I.e., we don't call isjunk at all yet. Throwing # out the junk later is much cheaper than building b2j "right" # from the start. b = self.b self.b2j = b2j = {} self.b2jhas = b2jhas = b2j.has_key for i in xrange(len(b)): elt = b[i] if b2jhas(elt): b2j[elt].append(i) else: b2j[elt] = [i] # Now b2j.keys() contains elements uniquely, and especially when # the sequence is a string, that's usually a good deal smaller # than len(string). The difference is the number of isjunk calls # saved. isjunk, junkdict = self.isjunk, {} if isjunk: for elt in b2j.keys(): if isjunk(elt): junkdict[elt] = 1 # value irrelevant; it's a set del b2j[elt] # Now for x in b, isjunk(x) == junkdict.has_key(x), but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk # elements is probably small. So the memory burden of keeping # this dict alive is likely trivial compared to the size of b2j. self.isbjunk = junkdict.has_key def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j',k') meeting those conditions, k >= k' i <= i' and if i == i', j <= j' In other words, of all maximal matching blocks, return one that starts earliest in a, and of all those maximal matching blocks that start earliest in a, return the one that starts earliest in b. >>> s = SequenceMatcher(None, " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) (0, 4, 5) If isjunk is defined, first the longest matching block is determined as above, but with the additional restriction that no junk element appears in the block. Then that block is extended as far as possible by matching (only) junk elements on both sides. So the resulting block never matches on junk except as identical junk happens to be adjacent to an "interesting" match. Here's the same example as before, but considering blanks to be junk. That prevents " abcd" from matching the " abcd" at the tail end of the second sequence directly. Instead only the "abcd" can match, and matches the leftmost "abcd" in the second sequence: >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") >>> s.find_longest_match(0, 5, 0, 9) (1, 0, 4) If no blocks match, return (alo, blo, 0). >>> s = SequenceMatcher(None, "ab", "c") >>> s.find_longest_match(0, 2, 0, 1) (0, 0, 0) """ # CAUTION: stripping common prefix or suffix would be incorrect. # E.g., # ab # acab # Longest matching block is "ab", but if common prefix is # stripped, it's "a" (tied with "b"). UNIX(tm) diff does so # strip, so ends up claiming that ab is changed to acab by # inserting "ca" in the middle. That's minimal but unintuitive: # "it's obvious" that someone inserted "ac" at the front. # Windiff ends up at the same place as diff, but by pairing up # the unique 'b's and then matching the first two 'a's. a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk besti, bestj, bestsize = alo, blo, 0 # find longest junk-free match # during an iteration of the loop, j2len[j] = length of longest # junk-free match ending with a[i-1] and b[j] j2len = {} nothing = [] for i in xrange(alo, ahi): # look at all instances of a[i] in b; note that because # b2j has no junk keys, the loop is skipped if a[i] is junk j2lenget = j2len.get newj2len = {} for j in b2j.get(a[i], nothing): # a[i] matches b[j] if j < blo: continue if j >= bhi: break k = newj2len[j] = j2lenget(j-1, 0) + 1 if k > bestsize: besti, bestj, bestsize = i-k+1, j-k+1, k j2len = newj2len # Now that we have a wholly interesting match (albeit possibly # empty!), we may as well suck up the matching junk on each # side of it too. Can't think of a good reason not to, and it # saves post-processing the (possibly considerable) expense of # figuring out what to do with it. In the case of an empty # interesting match, this is clearly the right thing to do, # because no other kind of match is possible in the regions. while besti > alo and bestj > blo and \ isbjunk(b[bestj-1]) and \ a[besti-1] == b[bestj-1]: besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 while besti+bestsize < ahi and bestj+bestsize < bhi and \ isbjunk(b[bestj+bestsize]) and \ a[besti+bestsize] == b[bestj+bestsize]: bestsize = bestsize + 1 if TRACE: print "get_matching_blocks", alo, ahi, blo, bhi print " returns", besti, bestj, bestsize return besti, bestj, bestsize def get_matching_blocks(self): """Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. The last triple is a dummy, (len(a), len(b), 0), and is the only triple with n==0. >>> s = SequenceMatcher(None, "abxcd", "abcd") >>> s.get_matching_blocks() [(0, 0, 2), (3, 2, 2), (5, 4, 0)] """ if self.matching_blocks is not None: return self.matching_blocks self.matching_blocks = [] la, lb = len(self.a), len(self.b) self.__helper(0, la, 0, lb, self.matching_blocks) self.matching_blocks.append( (la, lb, 0) ) if TRACE: print '*** matching blocks', self.matching_blocks return self.matching_blocks # builds list of matching blocks covering a[alo:ahi] and # b[blo:bhi], appending them in increasing order to answer def __helper(self, alo, ahi, blo, bhi, answer): i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi) # a[alo:i] vs b[blo:j] unknown # a[i:i+k] same as b[j:j+k] # a[i+k:ahi] vs b[j+k:bhi] unknown if k: if alo < i and blo < j: self.__helper(alo, i, blo, j, answer) answer.append(x) if i+k < ahi and j+k < bhi: self.__helper(i+k, ahi, j+k, bhi, answer) def get_opcodes(self): """Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. The tags are strings, with these meanings: 'replace': a[i1:i2] should be replaced by b[j1:j2] 'delete': a[i1:i2] should be deleted. Note that j1==j2 in this case. 'insert': b[j1:j2] should be inserted at a[i1:i1]. Note that i1==i2 in this case. 'equal': a[i1:i2] == b[j1:j2] >>> a = "qabxcd" >>> b = "abycdf" >>> s = SequenceMatcher(None, a, b) >>> for tag, i1, i2, j1, j2 in s.get_opcodes(): ... print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) delete a[0:1] (q) b[0:0] () equal a[1:3] (ab) b[0:2] (ab) replace a[3:4] (x) b[2:3] (y) equal a[4:6] (cd) b[3:5] (cd) insert a[6:6] () b[5:6] (f) """ if self.opcodes is not None: return self.opcodes i = j = 0 self.opcodes = answer = [] for ai, bj, size in self.get_matching_blocks(): # invariant: we've pumped out correct diffs to change # a[:i] into b[:j], and the next matching block is # a[ai:ai+size] == b[bj:bj+size]. So we need to pump # out a diff to change a[i:ai] into b[j:bj], pump out # the matching block, and move (i,j) beyond the match tag = '' if i < ai and j < bj: tag = 'replace' elif i < ai: tag = 'delete' elif j < bj: tag = 'insert' if tag: answer.append( (tag, i, ai, j, bj) ) i, j = ai+size, bj+size # the list of matching blocks is terminated by a # sentinel with size 0 if size: answer.append( ('equal', ai, i, bj, j) ) return answer def ratio(self): """Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2,0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. .ratio() is expensive to compute if you haven't already computed .get_matching_blocks() or .get_opcodes(), in which case you may want to try .quick_ratio() or .real_quick_ratio() first to get an upper bound. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.quick_ratio() 0.75 >>> s.real_quick_ratio() 1.0 """ matches = reduce(lambda sum, triple: sum + triple[-1], self.get_matching_blocks(), 0) return 2.0 * matches / (len(self.a) + len(self.b)) def quick_ratio(self): """Return an upper bound on ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute. """ # viewing a and b as multisets, set matches to the cardinality # of their intersection; this counts the number of matches # without regard to order, so is clearly an upper bound if self.fullbcount is None: self.fullbcount = fullbcount = {} for elt in self.b: fullbcount[elt] = fullbcount.get(elt, 0) + 1 fullbcount = self.fullbcount # avail[x] is the number of times x appears in 'b' less the # number of times we've seen it in 'a' so far ... kinda avail = {} availhas, matches = avail.has_key, 0 for elt in self.a: if availhas(elt): numb = avail[elt] else: numb = fullbcount.get(elt, 0) avail[elt] = numb - 1 if numb > 0: matches = matches + 1 return 2.0 * matches / (len(self.a) + len(self.b)) def real_quick_ratio(self): """Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio(). """ la, lb = len(self.a), len(self.b) # can't have more matches than the number of elements in the # shorter sequence return 2.0 * min(la, lb) / (la + lb) def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities that don't score at least that similar to word are ignored. The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first. >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) ['apple', 'ape'] >>> import keyword >>> get_close_matches("wheel", keyword.kwlist) ['while'] >>> get_close_matches("apple", keyword.kwlist) [] >>> get_close_matches("accept", keyword.kwlist) ['except'] """ if not n > 0: raise ValueError("n must be > 0: %s" % `n`) if not 0.0 <= cutoff <= 1.0: raise ValueError("cutoff must be in [0.0, 1.0]: %s" % `cutoff`) result = [] s = SequenceMatcher() s.set_seq2(word) for x in possibilities: s.set_seq1(x) if s.real_quick_ratio() >= cutoff and \ s.quick_ratio() >= cutoff and \ s.ratio() >= cutoff: result.append((s.ratio(), x)) # Sort by score. result.sort() # Retain only the best n. result = result[-n:] # Move best-scorer to head of list. result.reverse() # Strip scores. return [x for score, x in result] def _test(): import doctest, difflib return doctest.testmod(difflib) if __name__ == "__main__": _test() From lemburg@users.sourceforge.net Sat Feb 10 14:09:33 2001 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Sat, 10 Feb 2001 06:09:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv32672 Modified Files: test_unicode.py Log Message: Patch by Finn Bock to make test_unicode.py work for Jython. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** test_unicode.py 2001/01/29 11:14:15 1.30 --- test_unicode.py 2001/02/10 14:09:31 1.31 *************** *** 262,266 **** test('isupper', u'A', 1) test('isupper', u'\n', 0) ! test('isupper', u'\u1FFc', 0) test('isupper', u'ABC', 1) test('isupper', u'AbC', 0) --- 262,267 ---- test('isupper', u'A', 1) test('isupper', u'\n', 0) ! if sys.platform[:4] != 'java': ! test('isupper', u'\u1FFc', 0) test('isupper', u'ABC', 1) test('isupper', u'AbC', 0) *************** *** 340,350 **** verify(u"%c" % (34,) == u'"') verify(u"%c" % (36,) == u'$') ! value = u"%r, %r" % (u"abc", "abc") ! if value != u"u'abc', 'abc'": ! print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")' verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def') try: ! value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} except KeyError: print '*** formatting failed for "%s"' % "u'abc, def'" --- 341,355 ---- verify(u"%c" % (34,) == u'"') verify(u"%c" % (36,) == u'$') ! if sys.platform[:4] != 'java': ! value = u"%r, %r" % (u"abc", "abc") ! if value != u"u'abc', 'abc'": ! print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")' verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def') try: ! if sys.platform[:4] != 'java': ! value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} ! else: ! value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä':"def"} except KeyError: print '*** formatting failed for "%s"' % "u'abc, def'" From nascheme@users.sourceforge.net Sat Feb 10 20:04:56 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 10 Feb 2001 12:04:56 -0800 Subject: [Python-checkins] CVS: python/dist/src install-sh,2.3,2.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv10106 Modified Files: install-sh Log Message: Update install-sh using version from automake 1.4. Closes patch #103657 and #103717. Index: install-sh =================================================================== RCS file: /cvsroot/python/python/dist/src/install-sh,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** install-sh 1998/08/13 16:08:45 2.3 --- install-sh 2001/02/10 20:04:53 2.4 *************** *** 1,13 **** #!/bin/sh - # # install - install a program, script, or datafile ! # This comes from X11R5; it is not part of GNU. # ! # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ # ! # This script is compatible with the BSD install script, but was written ! # from scratch. # --- 1,26 ---- #!/bin/sh # # install - install a program, script, or datafile ! # This comes from X11R5 (mit/util/scripts/install.sh). # ! # Copyright 1991 by the Massachusetts Institute of Technology # ! # Permission to use, copy, modify, distribute, and sell this software and its ! # documentation for any purpose is hereby granted without fee, provided that ! # the above copyright notice appear in all copies and that both that ! # copyright notice and this permission notice appear in supporting ! # documentation, and that the name of M.I.T. not be used in advertising or ! # publicity pertaining to distribution of the software without specific, ! # written prior permission. M.I.T. makes no representations about the ! # suitability of this software for any purpose. It is provided "as is" ! # without express or implied warranty. # + # Calling this script install-sh is preferred over install.sh, to prevent + # `make' implicit rules from creating a file called install from it + # when there is no Makefile. + # + # This script is compatible with the BSD install script, but was written + # from scratch. It can only install one file at a time, a restriction + # shared with many OS's install programs. *************** *** 27,33 **** stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" instcmd="$mvprog" ! chmodcmd="" chowncmd="" chgrpcmd="" --- 40,49 ---- stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" + mkdirprog="${MKDIRPROG-mkdir}" + transformbasename="" + transform_arg="" instcmd="$mvprog" ! chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" *************** *** 37,40 **** --- 53,57 ---- src="" dst="" + dir_arg="" while [ x"$1" != x ]; do *************** *** 44,47 **** --- 61,68 ---- continue;; + -d) dir_arg=true + shift + continue;; + -m) chmodcmd="$chmodprog $2" shift *************** *** 63,70 **** --- 84,101 ---- continue;; + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + *) if [ x"$src" = x ] then src=$1 else + # this colon is to work around a 386BSD /bin/sh bug + : dst=$1 fi *************** *** 76,119 **** if [ x"$src" = x ] then ! echo "install: no input file specified" exit 1 fi ! if [ x"$dst" = x ] ! then ! echo "install: no destination specified" ! exit 1 ! fi ! # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic ! if [ -d $dst ] ! then ! dst="$dst"/`basename $src` fi # Make a temp file name in the proper directory. ! # Avoid dirname, which doesn't exist everywhere... ! dstdir=`echo $dst | sed 's,/[^/]*$,,'` ! dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name ! $doit $instcmd $src $dsttmp || exit $? # and set any options; do chmod last to preserve setuid bits ! if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi ! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi ! if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi ! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi # Now rename the file to the real destination. ! $doit $rmcmd $dst ! $doit $mvcmd $dsttmp $dst || exit $? --- 107,250 ---- if [ x"$src" = x ] then ! echo "install: no input file specified" exit 1 + else + true fi ! if [ x"$dir_arg" != x ]; then ! dst=$src ! src="" ! ! if [ -d $dst ]; then ! instcmd=: ! chmodcmd="" ! else ! instcmd=mkdir ! fi ! else ! ! # Waiting for this to be detected by the "$instcmd $src $dsttmp" command ! # might cause directories to be created, which would be especially bad ! # if $src (and thus $dsttmp) contains '*'. ! ! if [ -f $src -o -d $src ] ! then ! true ! else ! echo "install: $src does not exist" ! exit 1 ! fi ! ! if [ x"$dst" = x ] ! then ! echo "install: no destination specified" ! exit 1 ! else ! true ! fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic ! if [ -d $dst ] ! then ! dst="$dst"/`basename $src` ! else ! true ! fi ! fi ! ! ## this sed command emulates the dirname command ! dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` ! ! # Make sure that the destination directory exists. ! # this part is taken from Noah Friedman's mkinstalldirs script ! ! # Skip lots of stat calls in the usual case. ! if [ ! -d "$dstdir" ]; then ! defaultIFS=' ! ' ! IFS="${IFS-${defaultIFS}}" ! ! oIFS="${IFS}" ! # Some sh's can't handle IFS=/ for some reason. ! IFS='%' ! set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` ! IFS="${oIFS}" ! ! pathcomp='' ! ! while [ $# -ne 0 ] ; do ! pathcomp="${pathcomp}${1}" ! shift ! ! if [ ! -d "${pathcomp}" ] ; ! then ! $mkdirprog "${pathcomp}" ! else ! true ! fi ! ! pathcomp="${pathcomp}/" ! done fi + if [ x"$dir_arg" != x ] + then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi + else + + # If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + + # don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + # Make a temp file name in the proper directory. ! dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && ! trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits ! # If any of these fail, we abort the whole thing. If we want to ! # ignore errors from any of these, just make sure not to ignore ! # errors from the above "$doit $instcmd $src $dsttmp" command. ! ! if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && ! if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && ! if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && ! if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile ! fi && From nascheme@users.sourceforge.net Sat Feb 10 20:07:40 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 10 Feb 2001 12:07:40 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv10598 Modified Files: Makefile.pre.in Log Message: Specify directory permissions properly. Closes SF patch #103717. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** Makefile.pre.in 2001/02/09 22:22:18 1.15 --- Makefile.pre.in 2001/02/10 20:07:38 1.16 *************** *** 507,511 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d 755 $$i; \ else true; \ fi; \ --- 507,511 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ *************** *** 528,532 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d $(DIRMODE) $$i; \ else true; \ fi; \ --- 528,532 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ *************** *** 548,552 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d $(DIRMODE) $$i; \ else true; \ fi; \ --- 548,552 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ *************** *** 566,570 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d $(DIRMODE) $$i; \ else true; \ fi; \ --- 566,570 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ *************** *** 577,581 **** if test ! -d $$b; then \ echo "Creating directory $$b"; \ ! $(INSTALL) -d $(DIRMODE) $$b; \ else true; \ fi; \ --- 577,581 ---- if test ! -d $$b; then \ echo "Creating directory $$b"; \ ! $(INSTALL) -d -m $(DIRMODE) $$b; \ else true; \ fi; \ *************** *** 637,641 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d $(DIRMODE) $$i; \ else true; \ fi; \ --- 637,641 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ *************** *** 656,660 **** if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d $(DIRMODE) $$i; \ else true; \ fi; \ --- 656,660 ---- if test ! -d $$i; then \ echo "Creating directory $$i"; \ ! $(INSTALL) -d -m $(DIRMODE) $$i; \ else true; \ fi; \ From nascheme@users.sourceforge.net Sat Feb 10 20:10:54 2001 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 10 Feb 2001 12:10:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv10865/Misc Modified Files: ACKS Log Message: Update for install-sh (SF #103717). Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -r1.80 -r1.81 *** ACKS 2001/02/09 09:59:06 1.80 --- ACKS 2001/02/10 20:10:52 1.81 *************** *** 77,80 **** --- 77,81 ---- Jeffery Collins Matt Conway + David M. Cooke Scott Cotton Greg Couch From tim_one@users.sourceforge.net Sun Feb 11 00:46:41 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 16:46:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild rmpyc.py,NONE,1.1 rt.bat,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv2147/python/dist/src/PCbuild Modified Files: rt.bat Added Files: rmpyc.py Log Message: Change Windows test to do a complete job of removing .pyc/.pyo files reachable from Lib/. --- NEW FILE: rmpyc.py --- # Remove all the .pyc and .pyo files under ../Lib. def deltree(root): import os def rm(path): os.unlink(path) npyc = npyo = 0 dirs = [root] while dirs: dir = dirs.pop() for short in os.listdir(dir): full = os.path.join(dir, short) if os.path.isdir(full): dirs.append(full) elif short.endswith(".pyc"): npyc += 1 rm(full) elif short.endswith(".pyo"): npyo += 1 rm(full) return npyc, npyo npyc, npyo = deltree("../Lib") print npyc, ".pyc deleted,", npyo, ".pyo deleted" Index: rt.bat =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/rt.bat,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** rt.bat 2001/01/23 02:42:09 1.5 --- rt.bat 2001/02/11 00:46:39 1.6 *************** *** 22,29 **** @if "%_qmode%"=="yes" goto Qmode @echo Deleting .pyc/.pyo files ... ! @del ..\Lib\*.pyc ! @del ..\Lib\*.pyo ! @del ..\Lib\test\*.pyc ! @del ..\Lib\test\*.pyo %_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 @echo About to run again without deleting .pyc/.pyo first: --- 22,26 ---- @if "%_qmode%"=="yes" goto Qmode @echo Deleting .pyc/.pyo files ... ! @%_exe% rmpyc.py %_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 @echo About to run again without deleting .pyc/.pyo first: From tim_one@users.sourceforge.net Sun Feb 11 04:35:41 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 10 Feb 2001 20:35:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.121,2.122 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv16427/python/dist/src/Python Modified Files: pythonrun.c Log Message: Ugly fix for SF bug 131239 (-x flag busted). Bug was introduced by tricks played to make .pyc files executable via cmdline arg. Then again, -x worked via a trick to begin with. If anyone can think of a portable way to test -x, be my guest! Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.121 retrieving revision 2.122 diff -C2 -r2.121 -r2.122 *** pythonrun.c 2001/02/02 18:19:15 2.121 --- pythonrun.c 2001/02/11 04:35:39 2.122 *************** *** 579,586 **** unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF; unsigned char buf[2]; ! if (fread(buf, 1, 2, fp) == 2 ! && ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic) ! return 1; ! fseek(fp, 0, SEEK_SET); } return 0; --- 579,597 ---- unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF; unsigned char buf[2]; ! /* Mess: In case of -x, the stream is NOT at its start now, ! and ungetc() was used to push back the first newline, ! which makes the current stream position formally undefined ! until that newline is read back. So first we getc(), so ! that ftell() is well-defined. ! */ ! const int maybepushedback = getc(fp); ! const long currentpos = ftell(fp); ! int ispyc = 0; ! rewind(fp); ! ispyc = fread(buf, 1, 2, fp) == 2 && ! ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic; ! fseek(fp, currentpos, SEEK_SET); ! ungetc(maybepushedback, fp); ! return ispyc; } return 0; From montanaro@users.sourceforge.net Mon Feb 12 02:00:44 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 11 Feb 2001 18:00:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib poplib.py,1.13,1.14 posixfile.py,1.17,1.18 posixpath.py,1.41,1.42 pprint.py,1.11,1.12 pre.py,1.6,1.7 profile.py,1.25,1.26 pstats.py,1.10,1.11 pty.py,1.6,1.7 py_compile.py,1.17,1.18 pyclbr.py,1.18,1.19 quopri.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15243 Modified Files: poplib.py posixfile.py posixpath.py pprint.py pre.py profile.py pstats.py pty.py py_compile.py pyclbr.py quopri.py Log Message: __all__ for several more modules Index: poplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/poplib.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** poplib.py 2001/02/09 06:56:56 1.13 --- poplib.py 2001/02/12 02:00:42 1.14 *************** *** 15,18 **** --- 15,20 ---- import re, socket + __all__ = ["POP3","error_proto"] + # Exception raised when an error or invalid response is received: Index: posixfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** posixfile.py 2001/01/15 00:50:52 1.17 --- posixfile.py 2001/02/12 02:00:42 1.18 *************** *** 54,57 **** --- 54,59 ---- """ + __all__ = ["open","fileopen","SEEK_SET","SEEK_CUR","SEEK_END"] + class _posixfile_: """File wrapper class that provides extra POSIX file routines.""" Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** posixpath.py 2001/02/09 20:06:00 1.41 --- posixpath.py 2001/02/12 02:00:42 1.42 *************** *** 14,17 **** --- 14,22 ---- import stat + __all__ = ["normcase","isabs","join","splitdrive","split","splitext", + "basename","dirname","commonprefix","getsize","getmtime", + "getatime","islink","exists","isdir","isfile","ismount", + "walk","expanduser","expandvars","normpath","abspath", + "samefile","sameopenfile","samestat"] # Normalize the case of a pathname. Trivial in Posix, string.lower on Mac. Index: pprint.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pprint.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** pprint.py 2000/07/16 12:04:30 1.11 --- pprint.py 2001/02/12 02:00:42 1.12 *************** *** 42,45 **** --- 42,47 ---- from StringIO import StringIO + __all__ = ["pprint","pformat","isreadable","isrecursive","saferepr", + "PrettyPrinter"] def pprint(object, stream=None): Index: pre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pre.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pre.py 2001/02/10 00:18:03 1.6 --- pre.py 2001/02/12 02:00:42 1.7 *************** *** 88,91 **** --- 88,93 ---- from pcre import * + __all__ = ["match","search","sub","subn","split","findall","escape","compile"] + # # First, the public part of the interface: Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** profile.py 2001/01/15 00:50:52 1.25 --- profile.py 2001/02/12 02:00:42 1.26 *************** *** 41,44 **** --- 41,45 ---- import marshal + __all__ = ["run","help","Profile"] # Sample timer for use with Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** pstats.py 2001/02/09 08:25:29 1.10 --- pstats.py 2001/02/12 02:00:42 1.11 *************** *** 40,43 **** --- 40,45 ---- import fpformat + __all__ = ["Stats"] + class Stats: """This class is used for creating reports from data generated by the Index: pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pty.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pty.py 2001/01/15 00:50:52 1.6 --- pty.py 2001/02/12 02:00:42 1.7 *************** *** 11,14 **** --- 11,16 ---- import tty + __all__ = ["openpty","fork","spawn"] + STDIN_FILENO = 0 STDOUT_FILENO = 1 Index: py_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/py_compile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** py_compile.py 2001/02/09 08:49:11 1.17 --- py_compile.py 2001/02/12 02:00:42 1.18 *************** *** 7,10 **** --- 7,12 ---- MAGIC = imp.get_magic() + __all__ = ["compile"] + def wr_long(f, x): """Internal; write a 32-bit int to a file in little-endian order.""" Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** pyclbr.py 2001/02/09 20:06:00 1.18 --- pyclbr.py 2001/02/12 02:00:42 1.19 *************** *** 60,63 **** --- 60,65 ---- import string + __all__ = ["readmodule"] + TABWIDTH = 8 Index: quopri.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** quopri.py 2001/01/15 00:50:52 1.9 --- quopri.py 2001/02/12 02:00:42 1.10 *************** *** 5,8 **** --- 5,10 ---- # (Dec 1991 version). + __all__ = ["encode","decode"] + ESCAPE = '=' MAXLINESIZE = 76 From montanaro@users.sourceforge.net Mon Feb 12 02:00:44 2001 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 11 Feb 2001 18:00:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15243/test Modified Files: test___all__.py Log Message: __all__ for several more modules Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test___all__.py 2001/02/07 23:14:30 1.11 --- test___all__.py 2001/02/12 02:00:42 1.12 *************** *** 100,102 **** --- 100,113 ---- check_all("pipes") check_all("popen2") + check_all("poplib") + check_all("posixfile") + check_all("posixpath") + check_all("pprint") + check_all("pre") + check_all("profile") + check_all("pstats") + check_all("pty") + check_all("py_compile") + check_all("pyclbr") + check_all("quopri") check_all("robotparser") From tim_one@users.sourceforge.net Mon Feb 12 03:27:33 2001 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 11 Feb 2001 19:27:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21174/python/dist/src/Lib/test Modified Files: test___all__.py Log Message: test_pty started failing on Windows, but if and only if test___all__ was run first. Indirectly due to Skip adding check_all("pty") to test___all__: that caused the expected ImportError due to pty.py trying to import the non-existent FCNTL to get handled by test___all__, leaving a partial module object for pty in sys.modules, which caused the later import of pty via test_pty to succeed. Then test_tpy died with an AttributeError, due to trying to access attributes of pty that didn't exist. regrtest viewed that as a failure rather than the appropriate "test skipped". Fixed by deleting partial module objects in test___all__ when test___all__ handles an ImportError. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test___all__.py 2001/02/12 02:00:42 1.12 --- test___all__.py 2001/02/12 03:27:31 1.13 *************** *** 7,12 **** exec "import %s" % modname in names except ImportError: ! # silent fail here seems the best route since some modules ! # may not be available in all environments return verify(hasattr(sys.modules[modname], "__all__"), --- 7,26 ---- exec "import %s" % modname in names except ImportError: ! # Silent fail here seems the best route since some modules ! # may not be available in all environments. ! # Since an ImportError may leave a partial module object in ! # sys.modules, get rid of that first. Here's what happens if ! # you don't: importing pty fails on Windows because pty tries to ! # import FCNTL, which doesn't exist. That raises an ImportError, ! # caught here. It also leaves a partial pty module in sys.modules. ! # So when test_pty is called later, the import of pty succeeds, ! # but shouldn't. As a result, test_pty crashes with an ! # AtttributeError instead of an ImportError, and regrtest interprets ! # the latter as a test failure (ImportError is treated as "test ! # skipped" -- which is what test_pty should say on Windows). ! try: ! del sys.modules[modname] ! except KeyError: ! pass return verify(hasattr(sys.modules[modname], "__all__"), From theller@users.sourceforge.net Mon Feb 12 09:17:09 2001 From: theller@users.sourceforge.net (Thomas Heller) Date: Mon, 12 Feb 2001 01:17:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib imputil.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15909 Modified Files: imputil.py Log Message: This change makes imputil more closely emulate the standard import mechanism to support self-modifying modules. Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** imputil.py 2001/01/24 06:27:27 1.17 --- imputil.py 2001/02/12 09:17:06 1.18 *************** *** 283,287 **** exec code in module.__dict__ ! return module def _load_tail(self, m, parts): --- 283,288 ---- exec code in module.__dict__ ! # fetch from sys.modules instead of returning module directly. ! return sys.modules[fqname] def _load_tail(self, m, parts): From fdrake@users.sourceforge.net Mon Feb 12 15:30:24 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 12 Feb 2001 07:30:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools mkhowto,1.21,1.22 mkmodindex,1.9,1.10 support.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv4561 Modified Files: mkhowto mkmodindex support.py Log Message: Jon Nelson : Make the documentation tools compatibile with Python 2.0. Index: mkhowto =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** mkhowto 2001/02/04 15:20:26 1.21 --- mkhowto 2001/02/12 15:30:22 1.22 *************** *** 298,302 **** # self.run("%s %s" % (binary, self.doc)) ! self.latex_runs += 1 if os.path.isfile("mod%s.idx" % self.doc): self.run("%s -s %s mod%s.idx" --- 298,302 ---- # self.run("%s %s" % (binary, self.doc)) ! self.latex_runs = self.latex_runs + 1 if os.path.isfile("mod%s.idx" % self.doc): self.run("%s -s %s mod%s.idx" *************** *** 320,324 **** self.run("%s %s" % (BIBTEX_BINARY, self.doc)) self.run("%s %s" % (binary, self.doc)) ! self.latex_runs += 1 def process_synopsis_files(self): --- 320,324 ---- self.run("%s %s" % (BIBTEX_BINARY, self.doc)) self.run("%s %s" % (binary, self.doc)) ! self.latex_runs = self.latex_runs + 1 def process_synopsis_files(self): Index: mkmodindex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkmodindex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** mkmodindex 2000/11/28 16:20:50 1.9 --- mkmodindex 2001/02/12 15:30:22 1.10 *************** *** 118,124 **** program = os.path.basename(sys.argv[0]) fp = options.get_output_file() ! print >>fp, html.rstrip() if options.outputfile == "-": ! print >>sys.stderr, "%s: %d index nodes" % (program, num_nodes) else: print --- 118,124 ---- program = os.path.basename(sys.argv[0]) fp = options.get_output_file() ! fp.write(string.rstrip(html) + "\n") if options.outputfile == "-": ! sys.stderr.write("%s: %d index nodes\n" % (program, num_nodes)) else: print Index: support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/support.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** support.py 2000/10/05 05:20:55 1.2 --- support.py 2001/02/12 15:30:22 1.3 *************** *** 9,12 **** --- 9,13 ---- import getopt + import string import sys *************** *** 38,44 **** def add_args(self, short=None, long=None): if short: ! self.__short_args += short if long: ! self.__long_args += long def parse(self, args): --- 39,45 ---- def add_args(self, short=None, long=None): if short: ! self.__short_args = self.__short_args + short if long: ! self.__long_args = self.__long_args + long def parse(self, args): *************** *** 50,57 **** self.usage() sys.exit(2) ! self.args += args for opt, val in opts: if opt in ("-a", "--address"): ! val = val.strip() if val: val = "
\n%s\n
\n" % val --- 51,58 ---- self.usage() sys.exit(2) ! self.args = self.args + args for opt, val in opts: if opt in ("-a", "--address"): ! val = string.strip(val) if val: val = "
\n%s\n
\n" % val From jhylton@users.sourceforge.net Mon Feb 12 16:01:06 2001 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Mon, 12 Feb 2001 08:01:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.162,2.163 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv9526 Modified Files: compile.c Log Message: In symtable_update_free_vars() do not modify the dictionary while iterating over it using PyDict_Next(). This bug fix brought to you by the letters b, c, d, g, h, ... and the reporter Ping. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -r2.162 -r2.163 *** compile.c 2001/02/09 22:55:26 2.162 --- compile.c 2001/02/12 16:01:03 2.163 *************** *** 4206,4211 **** symtable_update_free_vars(struct symtable *st) { ! PyObject *o, *name; ! int i, def; PySymtableEntryObject *child, *ste = st->st_cur; --- 4206,4211 ---- symtable_update_free_vars(struct symtable *st) { ! int i, j, def; ! PyObject *o, *name, *list = NULL; PySymtableEntryObject *child, *ste = st->st_cur; *************** *** 4217,4220 **** --- 4217,4223 ---- int pos = 0; + if (list) + PyList_SetSlice(list, 0, + ((PyVarObject*)list)->ob_size, 0); child = (PySymtableEntryObject *)\ PyList_GET_ITEM(ste->ste_children, i); *************** *** 4223,4239 **** if (!(is_free(v))) continue; /* avoids indentation */ ste->ste_child_free = 1; if (ste->ste_nested) { if (symtable_add_def_o(st, ste->ste_symbols, ! name, def) < 0) ! return -1; } else { if (symtable_check_global(st, child->ste_id, ! name) < 0) ! return -1; } } } ! return 0; } --- 4226,4259 ---- if (!(is_free(v))) continue; /* avoids indentation */ + if (list == NULL) { + list = PyList_New(0); + if (list == NULL) + return -1; + } ste->ste_child_free = 1; + if (PyList_Append(list, name) < 0) { + Py_DECREF(list); + return -1; + } + } + for (j = 0; list && j < PyList_GET_SIZE(list); j++) { + name = PyList_GET_ITEM(list, j); if (ste->ste_nested) { if (symtable_add_def_o(st, ste->ste_symbols, ! name, def) < 0) { ! Py_DECREF(list); ! return -1; ! } } else { if (symtable_check_global(st, child->ste_id, ! name) < 0) { ! Py_DECREF(list); ! return -1; ! } } } } ! ! Py_XDECREF(list); return 0; } From fdrake@users.sourceforge.net Mon Feb 12 16:04:26 2001 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 12 Feb 2001 08:04:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/html index.html.in,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/html In directory usw-pr-cvs1:/tmp/cvs-serv10692/Doc/html Modified Files: index.html.in Log Message: Add a "description" meta tag that includes a version number. Index: index.html.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** index.html.in 2000/10/04 13:39:23 1.12 --- index.html.in 2001/02/12 16:04:24 1.13 *************** *** 3,6 **** --- 3,9 ---- Python @RELEASE@ Documentation - @DATE@ +