From python-3000-checkins at python.org Fri May 5 06:34:19 2006 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 5 May 2006 06:34:19 +0200 (CEST) Subject: [Python-3000-checkins] r45905 - in python/branches/p3yk: Include/bytesobject.h Objects/bytesobject.c Message-ID: <20060505043419.5376D1E4007@bag.python.org> Author: guido.van.rossum Date: Fri May 5 06:34:18 2006 New Revision: 45905 Modified: python/branches/p3yk/Include/bytesobject.h python/branches/p3yk/Objects/bytesobject.c Log: Optimizations for bytes reallocation. This uses up to 12.5% overallocation, not entirely unlike list_resize(). Could probably use more tweaks for odd allocation patterns, TBD. Also add __alloc__() method which returns the actually allocated size. PS. I'm now convinced that we need something like "".join(); later. Modified: python/branches/p3yk/Include/bytesobject.h ============================================================================== --- python/branches/p3yk/Include/bytesobject.h (original) +++ python/branches/p3yk/Include/bytesobject.h Fri May 5 06:34:18 2006 @@ -21,6 +21,7 @@ /* Object layout */ typedef struct { PyObject_VAR_HEAD + Py_ssize_t ob_alloc; /* How many bytes allocated */ char *ob_bytes; } PyBytesObject; Modified: python/branches/p3yk/Objects/bytesobject.c ============================================================================== --- python/branches/p3yk/Objects/bytesobject.c (original) +++ python/branches/p3yk/Objects/bytesobject.c Fri May 5 06:34:18 2006 @@ -4,6 +4,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "structmember.h" /* Direct API functions */ @@ -25,7 +26,6 @@ if (new == NULL) return NULL; - new->ob_size = size; if (size == 0) new->ob_bytes = NULL; else { @@ -37,6 +37,7 @@ if (bytes != NULL) memcpy(new->ob_bytes, bytes, size); } + new->ob_size = new->ob_alloc = size; return (PyObject *)new; } @@ -63,12 +64,31 @@ PyBytes_Resize(PyObject *self, Py_ssize_t size) { void *sval; + Py_ssize_t alloc = ((PyBytesObject *)self)->ob_alloc; assert(self != NULL); assert(PyBytes_Check(self)); assert(size >= 0); - sval = PyMem_Realloc(((PyBytesObject *)self)->ob_bytes, size); + if (size < alloc / 2) { + /* Major downsize; resize down to exact size */ + alloc = size; + } + else if (size <= alloc) { + /* Within allocated size; quick exit */ + ((PyBytesObject *)self)->ob_size = size; + return 0; + } + else if (size <= alloc * 1.125) { + /* Moderate upsize; overallocate similar to list_resize() */ + alloc = size + (size >> 3) + (size < 9 ? 3 : 6); + } + else { + /* Major upsize; resize up to exact size */ + alloc = size; + } + + sval = PyMem_Realloc(((PyBytesObject *)self)->ob_bytes, alloc); if (sval == NULL) { PyErr_NoMemory(); return -1; @@ -76,6 +96,7 @@ ((PyBytesObject *)self)->ob_bytes = sval; ((PyBytesObject *)self)->ob_size = size; + ((PyBytesObject *)self)->ob_alloc = alloc; return 0; } @@ -133,7 +154,9 @@ size = mysize + osize; if (size < 0) return PyErr_NoMemory(); - if (PyBytes_Resize((PyObject *)self, size) < 0) + if (size <= self->ob_alloc) + self->ob_size = size; + else if (PyBytes_Resize((PyObject *)self, size) < 0) return NULL; memcpy(self->ob_bytes + mysize, ((PyBytesObject *)other)->ob_bytes, osize); Py_INCREF(self); @@ -178,7 +201,9 @@ size = mysize * count; if (count != 0 && size / count != mysize) return PyErr_NoMemory(); - if (PyBytes_Resize((PyObject *)self, size) < 0) + if (size <= self->ob_alloc) + self->ob_size = size; + else if (PyBytes_Resize((PyObject *)self, size) < 0) return NULL; if (mysize == 1) @@ -372,9 +397,11 @@ PyObject *it; PyObject *(*iternext)(PyObject *); - /* Empty previous contents (yes, do this first of all!) */ - if (PyBytes_Resize((PyObject *)self, 0) < 0) - return -1; + if (self->ob_size != 0) { + /* Empty previous contents (yes, do this first of all!) */ + if (PyBytes_Resize((PyObject *)self, 0) < 0) + return -1; + } /* Parse arguments */ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, @@ -410,7 +437,9 @@ } bytes = PyString_AS_STRING(encoded); size = PyString_GET_SIZE(encoded); - if (PyBytes_Resize((PyObject *)self, size) < 0) { + if (size <= self->ob_alloc) + self->ob_size = size; + else if (PyBytes_Resize((PyObject *)self, size) < 0) { Py_DECREF(encoded); return -1; } @@ -492,8 +521,9 @@ } /* Append the byte */ - /* XXX Speed this up */ - if (PyBytes_Resize((PyObject *)self, self->ob_size+1) < 0) + if (self->ob_size < self->ob_alloc) + self->ob_size++; + else if (PyBytes_Resize((PyObject *)self, self->ob_size+1) < 0) goto error; self->ob_bytes[self->ob_size-1] = value; } @@ -673,6 +703,17 @@ return PyCodec_Decode(self, encoding, errors); } +PyDoc_STRVAR(alloc_doc, +"B.__alloc__() -> int\n\ +\n\ +Returns the number of bytes actually allocated."); + +static PyObject * +bytes_alloc(PyBytesObject *self) +{ + return PyInt_FromSsize_t(self->ob_alloc); +} + static PySequenceMethods bytes_as_sequence = { (lenfunc)bytes_length, /*sq_length*/ (binaryfunc)bytes_concat, /*sq_concat*/ @@ -704,7 +745,8 @@ static PyMethodDef bytes_methods[] = { {"decode", (PyCFunction)bytes_decode, METH_VARARGS, decode_doc}, - {NULL, NULL} + {"__alloc__", (PyCFunction)bytes_alloc, METH_NOARGS, alloc_doc}, + {NULL} }; PyDoc_STRVAR(bytes_doc, From python-3000-checkins at python.org Fri May 5 17:15:41 2006 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 5 May 2006 17:15:41 +0200 (CEST) Subject: [Python-3000-checkins] r45910 - in python/branches/p3yk: Lib/test/test_bytes.py Objects/bytesobject.c Message-ID: <20060505151541.27EB71E400A@bag.python.org> Author: guido.van.rossum Date: Fri May 5 17:15:40 2006 New Revision: 45910 Modified: python/branches/p3yk/Lib/test/test_bytes.py python/branches/p3yk/Objects/bytesobject.c Log: Adding bytes.join() -- a class methods that concatenates an iterable of bytes. The name and API are questionable, but the functionality isn't. Modified: python/branches/p3yk/Lib/test/test_bytes.py ============================================================================== --- python/branches/p3yk/Lib/test/test_bytes.py (original) +++ python/branches/p3yk/Lib/test/test_bytes.py Fri May 5 17:15:40 2006 @@ -347,6 +347,30 @@ self.failIf(bytes("dab") in b) self.failIf(bytes("abd") in b) + def test_alloc(self): + b = bytes() + alloc = b.__alloc__() + self.assert_(alloc >= 0) + seq = [alloc] + for i in range(100): + b += bytes("x") + alloc = b.__alloc__() + self.assert_(alloc >= len(b)) + if alloc not in seq: + seq.append(alloc) + print seq + + def test_join(self): + self.assertEqual(bytes.join([]), bytes()) + self.assertEqual(bytes.join([bytes()]), bytes()) + for part in [("abc",), ("a", "bc"), ("ab", "c"), ("a", "b", "c")]: + lst = map(bytes, part) + self.assertEqual(bytes.join(lst), bytes("abc")) + self.assertEqual(bytes.join(tuple(lst)), bytes("abc")) + self.assertEqual(bytes.join(iter(lst)), bytes("abc")) + # XXX more... + + # Optimizations: # __iter__? (optimization) # __reversed__? (optimization) Modified: python/branches/p3yk/Objects/bytesobject.c ============================================================================== --- python/branches/p3yk/Objects/bytesobject.c (original) +++ python/branches/p3yk/Objects/bytesobject.c Fri May 5 17:15:40 2006 @@ -48,7 +48,7 @@ assert(self != NULL); assert(PyBytes_Check(self)); - return ((PyBytesObject *)self)->ob_size; + return PyBytes_GET_SIZE(self); } char * @@ -57,7 +57,7 @@ assert(self != NULL); assert(PyBytes_Check(self)); - return ((PyBytesObject *)self)->ob_bytes; + return PyBytes_AS_STRING(self); } int @@ -714,6 +714,68 @@ return PyInt_FromSsize_t(self->ob_alloc); } +PyDoc_STRVAR(join_doc, +"bytes.join(iterable_of_bytes) -> bytes\n\ +\n\ +Concatenates any number of bytes objects. Example:\n\ +bytes.join([bytes('ab'), bytes('pq'), bytes('rs')]) -> bytes('abpqrs')."); + +static PyObject * +bytes_join(PyObject *cls, PyObject *it) +{ + PyObject *seq; + Py_ssize_t i; + Py_ssize_t n; + PyObject **items; + Py_ssize_t totalsize = 0; + PyObject *result; + char *dest; + + seq = PySequence_Fast(it, "can only join an iterable"); + if (seq == NULL) + return NULL; + n = PySequence_Fast_GET_SIZE(seq); + items = PySequence_Fast_ITEMS(seq); + + /* Compute the total size, and check that they are all bytes */ + for (i = 0; i < n; i++) { + PyObject *obj = items[i]; + if (!PyBytes_Check(obj)) { + PyErr_Format(PyExc_TypeError, + "can only join an iterable of bytes " + "(item %d has type '%.100s')", + i, obj->ob_type->tp_name); + goto error; + } + totalsize += PyBytes_GET_SIZE(obj); + if (totalsize < 0) { + PyErr_NoMemory(); + goto error; + } + } + + /* Allocate the result, and copy the bytes */ + result = PyBytes_FromStringAndSize(NULL, totalsize); + if (result == NULL) + goto error; + dest = PyBytes_AS_STRING(result); + for (i = 0; i < n; i++) { + PyObject *obj = items[i]; + Py_ssize_t size = PyBytes_GET_SIZE(obj); + memcpy(dest, PyBytes_AS_STRING(obj), size); + dest += size; + } + + /* Done */ + Py_DECREF(seq); + return result; + + /* Error handling */ + error: + Py_DECREF(seq); + return NULL; +} + static PySequenceMethods bytes_as_sequence = { (lenfunc)bytes_length, /*sq_length*/ (binaryfunc)bytes_concat, /*sq_concat*/ @@ -746,6 +808,7 @@ bytes_methods[] = { {"decode", (PyCFunction)bytes_decode, METH_VARARGS, decode_doc}, {"__alloc__", (PyCFunction)bytes_alloc, METH_NOARGS, alloc_doc}, + {"join", (PyCFunction)bytes_join, METH_O|METH_CLASS, join_doc}, {NULL} }; From python-3000-checkins at python.org Fri May 26 21:12:42 2006 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 26 May 2006 21:12:42 +0200 (CEST) Subject: [Python-3000-checkins] r46393 - in python/branches/p3yk: Doc/lib/libnew.tex Doc/lib/libtypes.tex Lib/copy.py Lib/dis.py Lib/new.py Lib/pickle.py Lib/pickletools.py Lib/test/output/test_new Lib/test/test_new.py Lib/types.py Lib/xmlrpclib.py Message-ID: <20060526191242.9084F1E4010@bag.python.org> Author: guido.van.rossum Date: Fri May 26 21:12:38 2006 New Revision: 46393 Modified: python/branches/p3yk/Doc/lib/libnew.tex python/branches/p3yk/Doc/lib/libtypes.tex python/branches/p3yk/Lib/copy.py python/branches/p3yk/Lib/dis.py python/branches/p3yk/Lib/new.py python/branches/p3yk/Lib/pickle.py python/branches/p3yk/Lib/pickletools.py python/branches/p3yk/Lib/test/output/test_new python/branches/p3yk/Lib/test/test_new.py python/branches/p3yk/Lib/types.py python/branches/p3yk/Lib/xmlrpclib.py Log: SF patch 1495675: Remove types.InstanceType and new.instance (Collin Winter) Modified: python/branches/p3yk/Doc/lib/libnew.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libnew.tex (original) +++ python/branches/p3yk/Doc/lib/libnew.tex Fri May 26 21:12:38 2006 @@ -16,14 +16,6 @@ The \module{new} module defines the following functions: -\begin{funcdesc}{instance}{class\optional{, dict}} -This function creates an instance of \var{class} with dictionary -\var{dict} without calling the \method{__init__()} constructor. If -\var{dict} is omitted or \code{None}, a new, empty dictionary is -created for the new instance. Note that there are no guarantees that -the object will be in a consistent state. -\end{funcdesc} - \begin{funcdesc}{instancemethod}{function, instance, class} This function will return a method object, bound to \var{instance}, or unbound if \var{instance} is \code{None}. \var{function} must be Modified: python/branches/p3yk/Doc/lib/libtypes.tex ============================================================================== --- python/branches/p3yk/Doc/lib/libtypes.tex (original) +++ python/branches/p3yk/Doc/lib/libtypes.tex Fri May 26 21:12:38 2006 @@ -122,10 +122,6 @@ The type of user-defined classes. \end{datadesc} -\begin{datadesc}{InstanceType} -The type of instances of user-defined classes. -\end{datadesc} - \begin{datadesc}{MethodType} The type of methods of user-defined class instances. \end{datadesc} Modified: python/branches/p3yk/Lib/copy.py ============================================================================== --- python/branches/p3yk/Lib/copy.py (original) +++ python/branches/p3yk/Lib/copy.py Fri May 26 21:12:38 2006 @@ -119,26 +119,6 @@ if PyStringMap is not None: d[PyStringMap] = _copy_with_copy_method -def _copy_inst(x): - if hasattr(x, '__copy__'): - return x.__copy__() - if hasattr(x, '__getinitargs__'): - args = x.__getinitargs__() - y = x.__class__(*args) - else: - y = _EmptyClass() - y.__class__ = x.__class__ - if hasattr(x, '__getstate__'): - state = x.__getstate__() - else: - state = x.__dict__ - if hasattr(y, '__setstate__'): - y.__setstate__(state) - else: - y.__dict__.update(state) - return y -d[types.InstanceType] = _copy_inst - del d def deepcopy(x, memo=None, _nil=[]): @@ -273,29 +253,6 @@ # aha, this is the first one :-) memo[id(memo)]=[x] -def _deepcopy_inst(x, memo): - if hasattr(x, '__deepcopy__'): - return x.__deepcopy__(memo) - if hasattr(x, '__getinitargs__'): - args = x.__getinitargs__() - args = deepcopy(args, memo) - y = x.__class__(*args) - else: - y = _EmptyClass() - y.__class__ = x.__class__ - memo[id(x)] = y - if hasattr(x, '__getstate__'): - state = x.__getstate__() - else: - state = x.__dict__ - state = deepcopy(state, memo) - if hasattr(y, '__setstate__'): - y.__setstate__(state) - else: - y.__dict__.update(state) - return y -d[types.InstanceType] = _deepcopy_inst - def _reconstruct(x, info, deep, memo=None): if isinstance(info, str): return x Modified: python/branches/p3yk/Lib/dis.py ============================================================================== --- python/branches/p3yk/Lib/dis.py (original) +++ python/branches/p3yk/Lib/dis.py Fri May 26 21:12:38 2006 @@ -18,8 +18,6 @@ if x is None: distb() return - if type(x) is types.InstanceType: - x = x.__class__ if hasattr(x, 'im_func'): x = x.im_func if hasattr(x, 'func_code'): Modified: python/branches/p3yk/Lib/new.py ============================================================================== --- python/branches/p3yk/Lib/new.py (original) +++ python/branches/p3yk/Lib/new.py Fri May 26 21:12:38 2006 @@ -6,7 +6,6 @@ from types import ClassType as classobj from types import FunctionType as function -from types import InstanceType as instance from types import MethodType as instancemethod from types import ModuleType as module Modified: python/branches/p3yk/Lib/pickle.py ============================================================================== --- python/branches/p3yk/Lib/pickle.py (original) +++ python/branches/p3yk/Lib/pickle.py Fri May 26 21:12:38 2006 @@ -687,46 +687,6 @@ write(SETITEM) # else tmp is empty, and we're done - def save_inst(self, obj): - cls = obj.__class__ - - memo = self.memo - write = self.write - save = self.save - - if hasattr(obj, '__getinitargs__'): - args = obj.__getinitargs__() - len(args) # XXX Assert it's a sequence - _keep_alive(args, memo) - else: - args = () - - write(MARK) - - if self.bin: - save(cls) - for arg in args: - save(arg) - write(OBJ) - else: - for arg in args: - save(arg) - write(INST + cls.__module__ + '\n' + cls.__name__ + '\n') - - self.memoize(obj) - - try: - getstate = obj.__getstate__ - except AttributeError: - stuff = obj.__dict__ - else: - stuff = getstate() - _keep_alive(stuff, memo) - save(stuff) - write(BUILD) - - dispatch[InstanceType] = save_inst - def save_global(self, obj, name=None, pack=struct.pack): write = self.write memo = self.memo Modified: python/branches/p3yk/Lib/pickletools.py ============================================================================== --- python/branches/p3yk/Lib/pickletools.py (original) +++ python/branches/p3yk/Lib/pickletools.py Fri May 26 21:12:38 2006 @@ -2071,42 +2071,58 @@ 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 - 5: ( MARK - 6: i INST 'pickletools _Example' (MARK at 5) - 28: p PUT 1 - 31: ( MARK - 32: d DICT (MARK at 31) - 33: p PUT 2 - 36: S STRING 'value' - 45: p PUT 3 - 48: I INT 42 - 52: s SETITEM - 53: b BUILD - 54: a APPEND - 55: g GET 1 - 58: a APPEND - 59: . STOP + 5: c GLOBAL 'copy_reg _reconstructor' + 30: p PUT 1 + 33: ( MARK + 34: c GLOBAL 'pickletools _Example' + 56: p PUT 2 + 59: c GLOBAL '__builtin__ object' + 79: p PUT 3 + 82: N NONE + 83: t TUPLE (MARK at 33) + 84: p PUT 4 + 87: R REDUCE + 88: p PUT 5 + 91: ( MARK + 92: d DICT (MARK at 91) + 93: p PUT 6 + 96: S STRING 'value' + 105: p PUT 7 + 108: I INT 42 + 112: s SETITEM + 113: b BUILD + 114: a APPEND + 115: g GET 5 + 118: a APPEND + 119: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(x, 1)) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK - 4: ( MARK - 5: c GLOBAL 'pickletools _Example' - 27: q BINPUT 1 - 29: o OBJ (MARK at 4) - 30: q BINPUT 2 - 32: } EMPTY_DICT - 33: q BINPUT 3 - 35: U SHORT_BINSTRING 'value' - 42: q BINPUT 4 - 44: K BININT1 42 - 46: s SETITEM - 47: b BUILD - 48: h BINGET 2 - 50: e APPENDS (MARK at 3) - 51: . STOP + 4: c GLOBAL 'copy_reg _reconstructor' + 29: q BINPUT 1 + 31: ( MARK + 32: c GLOBAL 'pickletools _Example' + 54: q BINPUT 2 + 56: c GLOBAL '__builtin__ object' + 76: q BINPUT 3 + 78: N NONE + 79: t TUPLE (MARK at 31) + 80: q BINPUT 4 + 82: R REDUCE + 83: q BINPUT 5 + 85: } EMPTY_DICT + 86: q BINPUT 6 + 88: U SHORT_BINSTRING 'value' + 95: q BINPUT 7 + 97: K BININT1 42 + 99: s SETITEM + 100: b BUILD + 101: h BINGET 5 + 103: e APPENDS (MARK at 3) + 104: . STOP highest protocol among opcodes = 1 Try "the canonical" recursive-object test. Modified: python/branches/p3yk/Lib/test/output/test_new ============================================================================== --- python/branches/p3yk/Lib/test/output/test_new (original) +++ python/branches/p3yk/Lib/test/output/test_new Fri May 26 21:12:38 2006 @@ -1,7 +1,6 @@ test_new new.module() new.classobj() -new.instance() new.instancemethod() new.function() new.code() Modified: python/branches/p3yk/Lib/test/test_new.py ============================================================================== --- python/branches/p3yk/Lib/test/test_new.py (original) +++ python/branches/p3yk/Lib/test/test_new.py Fri May 26 21:12:38 2006 @@ -21,22 +21,12 @@ C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks}) if verbose: print C -print 'new.instance()' -c = new.instance(C, {'yolks': 3}) -if verbose: - print c -o = new.instance(C) -verify(o.__dict__ == {}, - "new __dict__ should be empty") -del o -o = new.instance(C, None) -verify(o.__dict__ == {}, - "new __dict__ should be empty") -del o def break_yolks(self): self.yolks = self.yolks - 2 print 'new.instancemethod()' +c = C() +c.yolks = 3 im = new.instancemethod(break_yolks, c, C) if verbose: print im Modified: python/branches/p3yk/Lib/types.py ============================================================================== --- python/branches/p3yk/Lib/types.py (original) +++ python/branches/p3yk/Lib/types.py Fri May 26 21:12:38 2006 @@ -56,9 +56,7 @@ def _m(self): pass ClassType = type(_C) UnboundMethodType = type(_C._m) # Same as MethodType -_x = _C() -InstanceType = type(_x) -MethodType = type(_x._m) +MethodType = type(_C()._m) BuiltinFunctionType = type(len) BuiltinMethodType = type([].append) # Same as BuiltinFunctionType @@ -86,4 +84,4 @@ DictProxyType = type(TypeType.__dict__) NotImplementedType = type(NotImplemented) -del sys, _f, _g, _C, _x # Not for export +del sys, _f, _g, _C # Not for export Modified: python/branches/p3yk/Lib/xmlrpclib.py ============================================================================== --- python/branches/p3yk/Lib/xmlrpclib.py (original) +++ python/branches/p3yk/Lib/xmlrpclib.py Fri May 26 21:12:38 2006 @@ -748,7 +748,6 @@ else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__, write) - dispatch[InstanceType] = dump_instance dispatch[DateTime] = dump_instance dispatch[Binary] = dump_instance From python-3000-checkins at python.org Fri May 26 21:16:09 2006 From: python-3000-checkins at python.org (guido.van.rossum) Date: Fri, 26 May 2006 21:16:09 +0200 (CEST) Subject: [Python-3000-checkins] r46395 - python/branches/p3yk/Lib/test/test_bytes.py Message-ID: <20060526191609.5F7251E4006@bag.python.org> Author: guido.van.rossum Date: Fri May 26 21:16:09 2006 New Revision: 46395 Modified: python/branches/p3yk/Lib/test/test_bytes.py Log: Comment out debug print. Modified: python/branches/p3yk/Lib/test/test_bytes.py ============================================================================== --- python/branches/p3yk/Lib/test/test_bytes.py (original) +++ python/branches/p3yk/Lib/test/test_bytes.py Fri May 26 21:16:09 2006 @@ -358,7 +358,7 @@ self.assert_(alloc >= len(b)) if alloc not in seq: seq.append(alloc) - print seq + #print seq def test_join(self): self.assertEqual(bytes.join([]), bytes()) From python-3000-checkins at python.org Sun May 28 12:46:55 2006 From: python-3000-checkins at python.org (thomas.wouters) Date: Sun, 28 May 2006 12:46:55 +0200 (CEST) Subject: [Python-3000-checkins] r46498 - python/branches/p3yk/Lib/test/test_importhooks.py Message-ID: <20060528104655.A131C1E4006@bag.python.org> Author: thomas.wouters Date: Sun May 28 12:46:55 2006 New Revision: 46498 Modified: python/branches/p3yk/Lib/test/test_importhooks.py Log: While testing absolute and relative imports, remember that absolute imports are the default now. (Should __future__ be cleaned up, and all tests for future statements be removed or changed to expect exceptions when they are used?) Modified: python/branches/p3yk/Lib/test/test_importhooks.py ============================================================================== --- python/branches/p3yk/Lib/test/test_importhooks.py (original) +++ python/branches/p3yk/Lib/test/test_importhooks.py Sun May 28 12:46:55 2006 @@ -194,12 +194,6 @@ reload(reloadmodule) self.failUnless(hasattr(reloadmodule,'reloaded')) - import hooktestpackage.oldabs - self.assertEqual(hooktestpackage.oldabs.get_name(), - "hooktestpackage.oldabs") - self.assertEqual(hooktestpackage.oldabs.sub, - hooktestpackage.sub) - import hooktestpackage.newrel self.assertEqual(hooktestpackage.newrel.get_name(), "hooktestpackage.newrel") @@ -221,6 +215,11 @@ import sub self.assertEqual(sub.get_name(), "sub") + import hooktestpackage.oldabs + self.assertEqual(hooktestpackage.oldabs.get_name(), + "hooktestpackage.oldabs") + self.assertEqual(hooktestpackage.oldabs.sub, sub) + import hooktestpackage.newabs self.assertEqual(hooktestpackage.newabs.get_name(), "hooktestpackage.newabs")