[pypy-svn] r8644 - in pypy/dist: lib-python-2.3.4 lib-python-2.3.4/test pypy/appspace pypy/appspace/compiler pypy/appspace/test pypy/module pypy/module/test

hpk at codespeak.net hpk at codespeak.net
Thu Jan 27 23:35:30 CET 2005


Author: hpk
Date: Thu Jan 27 23:35:29 2005
New Revision: 8644

Added:
   pypy/dist/lib-python-2.3.4/_exceptions.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/_exceptions.py
   pypy/dist/lib-python-2.3.4/_file.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/_file.py
   pypy/dist/lib-python-2.3.4/_float_formatting.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/_float_formatting.py
   pypy/dist/lib-python-2.3.4/_formatting.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/_formatting.py
   pypy/dist/lib-python-2.3.4/_types.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/_types.py
   pypy/dist/lib-python-2.3.4/cStringIO.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/cStringIO.py
   pypy/dist/lib-python-2.3.4/cmath.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/cmathmodule.py
   pypy/dist/lib-python-2.3.4/dumbre.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/dumbre.py
   pypy/dist/lib-python-2.3.4/imp.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/imp.py
   pypy/dist/lib-python-2.3.4/md5.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/md5.py
   pypy/dist/lib-python-2.3.4/operator.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/operator.py
   pypy/dist/lib-python-2.3.4/plexre.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/plexre.py
   pypy/dist/lib-python-2.3.4/sha.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/sha.py
   pypy/dist/lib-python-2.3.4/sio.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/sio.py
   pypy/dist/lib-python-2.3.4/struct.py
      - copied unchanged from r8637, pypy/dist/pypy/appspace/struct.py
   pypy/dist/lib-python-2.3.4/test/test_sio.py
      - copied unchanged from r8643, pypy/dist/pypy/appspace/test/test_sio.py
   pypy/dist/pypy/appspace/DEPRECATED_WORK_IN_lib-python-2.3.4
Removed:
   pypy/dist/pypy/appspace/_exceptions.py
   pypy/dist/pypy/appspace/_file.py
   pypy/dist/pypy/appspace/_float_formatting.py
   pypy/dist/pypy/appspace/_formatting.py
   pypy/dist/pypy/appspace/_types.py
   pypy/dist/pypy/appspace/cStringIO.py
   pypy/dist/pypy/appspace/cmathmodule.py
   pypy/dist/pypy/appspace/compiler/
   pypy/dist/pypy/appspace/dumbre.py
   pypy/dist/pypy/appspace/imp.py
   pypy/dist/pypy/appspace/md5.py
   pypy/dist/pypy/appspace/operator.py
   pypy/dist/pypy/appspace/plexre.py
   pypy/dist/pypy/appspace/pystone.py
   pypy/dist/pypy/appspace/sha.py
   pypy/dist/pypy/appspace/sio.py
   pypy/dist/pypy/appspace/sre_parse.py
   pypy/dist/pypy/appspace/struct.py
   pypy/dist/pypy/appspace/test/test_sio.py
   pypy/dist/pypy/appspace/traceback.py
   pypy/dist/pypy/appspace/types.py
Modified:
   pypy/dist/lib-python-2.3.4/test/pystone.py
   pypy/dist/lib-python-2.3.4/traceback.py
   pypy/dist/lib-python-2.3.4/types.py
   pypy/dist/pypy/appspace/test/conftest.py
   pypy/dist/pypy/appspace/test/test_exceptions.py
   pypy/dist/pypy/module/sysinterp.py
   pypy/dist/pypy/module/test/test_zip.py
Log:
port all appspace hacks/modules/ports from C 
to the new lib-python-2.3.4 (we actually  
need to do a detailed check on all changes we did and
that they really refer to python-2.3.4) 

please note that the currently failing tests 
were failing before this commit here and seem
to relate to Christian's exception-changes 
(which are nice, but they do seem to break 
things in ways i can't directly figure out
at this point in the night) 



Modified: pypy/dist/lib-python-2.3.4/test/pystone.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/test/pystone.py	(original)
+++ pypy/dist/lib-python-2.3.4/test/pystone.py	Thu Jan 27 23:35:29 2005
@@ -57,10 +57,10 @@
 TRUE = 1
 FALSE = 0
 
-def main():
-    benchtime, stones = pystones()
+def main(loops=LOOPS):
+    benchtime, stones = pystones(loops)
     print "Pystone(%s) time for %d passes = %g" % \
-          (__version__, LOOPS, benchtime)
+          (__version__, loops, benchtime)
     print "This machine benchmarks at %g pystones/second" % stones
 
 
@@ -249,4 +249,19 @@
     return FALSE
 
 if __name__ == '__main__':
-    main()
+    import sys
+    def error(msg):
+        print >>sys.stderr, msg,
+        print >>sys.stderr, "usage: %s [number_of_loops]" % sys.argv[0]
+        sys.exit(100)
+    nargs = len(sys.argv) - 1
+    if nargs > 1:
+        error("%d arguments are too many;" % nargs)
+    elif nargs == 1:
+        try: loops = int(sys.argv[1])
+        except ValueError:
+            error("Invalid argument %r;" % sys.argv[1])
+    else:
+        loops = LOOPS
+    main(loops)
+

Modified: pypy/dist/lib-python-2.3.4/traceback.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/traceback.py	(original)
+++ pypy/dist/lib-python-2.3.4/traceback.py	Thu Jan 27 23:35:29 2005
@@ -155,7 +155,9 @@
     which exception occurred is the always last string in the list.
     """
     list = []
-    if type(etype) == types.ClassType:
+    # the following line is the only change against Py 2.3.3
+    # Python will change here, anyway. Drop this file, then.
+    if isinstance(etype, (types.ClassType, type)):
         stype = etype.__name__
     else:
         stype = etype

Modified: pypy/dist/lib-python-2.3.4/types.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/types.py	(original)
+++ pypy/dist/lib-python-2.3.4/types.py	Thu Jan 27 23:35:29 2005
@@ -1,7 +1,14 @@
-"""Define names for all type symbols known in the standard interpreter.
+"""Appspace types module. 
+
+!! This file has been copied practicaly verbatim from the CPython source.
+!! See http://www.python.org/2.3.2/license.html for licensing info.
+
+Define names for all type symbols known in the standard interpreter.
 
 Types that are part of optional modules (e.g. array) are not listed.
 """
+from __future__ import generators
+
 import sys
 
 # Iterators in Python aren't a matter of type but of protocol.  A large
@@ -14,26 +21,31 @@
 ObjectType = object
 
 IntType = int
-LongType = long
+try:
+    LongType = long
+except NameError:
+    pass
 FloatType = float
-BooleanType = bool
+try:
+    BooleanType = bool
+except NameError:
+    pass
 try:
     ComplexType = complex
 except NameError:
     pass
 
 StringType = str
-
-# StringTypes is already outdated.  Instead of writing "type(x) in
-# types.StringTypes", you should use "isinstance(x, basestring)".  But
-# we keep around for compatibility with Python 2.2.
 try:
     UnicodeType = unicode
     StringTypes = (StringType, UnicodeType)
 except NameError:
     StringTypes = (StringType,)
 
-BufferType = buffer
+try:
+    BufferType = buffer
+except NameError:
+    pass
 
 TupleType = tuple
 ListType = list
@@ -50,13 +62,25 @@
 
 def g():
     yield 1
-GeneratorType = type(g())
+try:
+    GeneratorType = type(g())
+except:
+    # Refusing generators
+    pass
 del g
 
+# checking whether we can make copy_reg happy
+##class _C:
+##    def _m(self): pass
+##ClassType = type(_C)
+class ClassType: pass
 class _C:
-    def _m(self): pass
-ClassType = type(_C)
-UnboundMethodType = type(_C._m)         # Same as MethodType
+    def _m(self):pass
+## end of testing hack
+try:
+    UnboundMethodType = type(_C._m)         # Same as MethodType
+except AttributeError:
+    pass
 _x = _C()
 InstanceType = type(_x)
 MethodType = type(_x._m)
@@ -65,8 +89,14 @@
 BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType
 
 ModuleType = type(sys)
-FileType = file
-XRangeType = xrange
+try:
+    FileType = file
+except NameError:
+   pass
+try:
+    XRangeType = type(xrange(0))
+except NameError:
+   pass
 
 try:
     raise TypeError
@@ -81,10 +111,13 @@
         pass
     tb = None; del tb
 
-SliceType = slice
+SliceType = type(slice(0))
 EllipsisType = type(Ellipsis)
 
-DictProxyType = type(TypeType.__dict__)
-NotImplementedType = type(NotImplemented)
+#DictProxyType = type(TypeType.__dict__)
+try:
+    NotImplementedType = type(NotImplemented)
+except NameError:
+   pass
 
-del sys, _f, _C, _x                  # Not for export
+del sys, _f, _C, _x#, generators                  # Not for export

Added: pypy/dist/pypy/appspace/DEPRECATED_WORK_IN_lib-python-2.3.4
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/appspace/DEPRECATED_WORK_IN_lib-python-2.3.4	Thu Jan 27 23:35:29 2005
@@ -0,0 +1,6 @@
+most appspace libraries have been moved to the version specific 
+svn/pypy/dist/lib-python-2.3.4, please work and modify files 
+there so that we can track what changes and ports of C-modules
+we do to the python-2.3.4 baseline.  the appspace directory 
+is going to vanish completly soon ... 
+

Deleted: /pypy/dist/pypy/appspace/_exceptions.py
==============================================================================
--- /pypy/dist/pypy/appspace/_exceptions.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,298 +0,0 @@
-class Exception:
-    """Common base class for all exceptions."""
-
-    # auto-generated code, please check carefully!
-    def __getitem__(self, idx):
-        return self.args[idx]
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        self.args = args
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        argc = len(self.args)
-        if argc == 0:
-            return ''
-        elif argc == 1:
-            return str(self.args[0])
-        else:
-            return str(self.args)
-
-class StandardError(Exception):
-    """Base class for all standard Python exceptions."""
-
-class ValueError(StandardError):
-    """Inappropriate argument value (of correct type)."""
-
-class ImportError(StandardError):
-    """Import can't find module, or can't find name in module."""
-
-class RuntimeError(StandardError):
-    """Unspecified run-time error."""
-
-class UnicodeError(ValueError):
-    """Unicode related error."""
-
-class UnicodeTranslateError(UnicodeError):
-    """Unicode translation error."""
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        self.args = args # modified: always assign args, no error check
-        if argc == 4:
-            self.object = args[0]
-            self.start = args[1]
-            self.end = args[2]
-            self.reason = args[3]
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        # this is a bad hack, please supply an implementation
-        res = ' '.join([
-           'start=' + str(self.start),
-           'reason=' + str(self.reason),
-           'args=' + str(self.args),
-           'end=' + str(self.end),
-           'object=' + str(self.object),
-        ])
-        return res
-
-class LookupError(StandardError):
-    """Base class for lookup errors."""
-
-class KeyError(LookupError):
-    """Mapping key not found."""
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        argc = len(self.args)
-        if argc == 0:
-            return ''
-        elif argc == 1:
-            return repr(self.args[0])
-        else:
-            return str(self.args)
-
-class Warning(Exception):
-    """Base class for warning categories."""
-
-class SyntaxWarning(Warning):
-    """Base class for warnings about dubious syntax."""
-
-class StopIteration(Exception):
-    """Signal the end from iterator.next()."""
-
-class PendingDeprecationWarning(Warning):
-    """Base class for warnings about features which will be deprecated in the future."""
-
-class EnvironmentError(StandardError):
-    """Base class for I/O related errors."""
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        self.args = args
-        self.errno = None # default, hopefully
-        self.strerror = None # default, hopefully
-        self.filename = None # default, hopefully
-        if 2 <= argc <= 3:
-            self.errno = args[0]
-            self.strerror = args[1]
-        if argc == 3:
-            self.filename = args[2]
-            self.args = (args[0], args[1])
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        # this is a bad hack, please supply an implementation
-        res = ' '.join([
-           'errno=' + str(self.errno),
-           'args=' + str(self.args),
-           'strerror=' + str(self.strerror),
-           'filename=' + str(self.filename),
-        ])
-        return res
-
-class OSError(EnvironmentError):
-    """OS system call failed."""
-
-class DeprecationWarning(Warning):
-    """Base class for warnings about deprecated features."""
-
-class UnicodeEncodeError(UnicodeError):
-    """Unicode encoding error."""
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        self.args = args # modified: always assign args, no error check
-        if argc == 5:
-            self.encoding = args[0]
-            self.object = args[1]
-            self.start = args[2]
-            self.end = args[3]
-            self.reason = args[4]
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        # this is a bad hack, please supply an implementation
-        res = ' '.join([
-           'object=' + str(self.object),
-           'end=' + str(self.end),
-           'encoding=' + str(self.encoding),
-           'args=' + str(self.args),
-           'start=' + str(self.start),
-           'reason=' + str(self.reason),
-        ])
-        return res
-
-class ArithmeticError(StandardError):
-    """Base class for arithmetic errors."""
-
-class FloatingPointError(ArithmeticError):
-    """Floating point operation failed."""
-
-class ReferenceError(StandardError):
-    """Weak ref proxy used after referent went away."""
-
-class NameError(StandardError):
-    """Name not found globally."""
-
-class OverflowWarning(Warning):
-    """Base class for warnings about numeric overflow."""
-
-class IOError(EnvironmentError):
-    """I/O operation failed."""
-
-class SyntaxError(StandardError):
-    """Invalid syntax."""
-    filename = None
-    lineno = None
-    msg = ''
-    offset = None
-    print_file_and_line = None
-    text = None
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        self.args = args
-        if argc >= 1:
-            self.msg = args[0]
-        if argc == 2:
-            self.filename = args[1][0]
-            self.lineno = args[1][1]
-            self.offset = args[1][2]
-            self.text = args[1][3]
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        # this is a bad hack, please supply an implementation
-        res = ' '.join([
-           'args=' + str(self.args),
-        ])
-        return res
-
-class FutureWarning(Warning):
-    """Base class for warnings about constructs that will change semantically in the future."""
-
-class SystemExit(Exception):
-    """Request to exit from the interpreter."""
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        if argc == 0:
-            self.code = None # default, hopefully
-        self.args = args
-        if argc == 1:
-            self.code = args[0]
-        if argc >= 2:
-            self.code = args
-
-class EOFError(StandardError):
-    """Read beyond end of file."""
-
-class IndentationError(SyntaxError):
-    """Improper indentation."""
-
-class TabError(IndentationError):
-    """Improper mixture of spaces and tabs."""
-
-class ZeroDivisionError(ArithmeticError):
-    """Second argument to a division or modulo operation was zero."""
-
-class SystemError(StandardError):
-    """Internal error in the Python interpreter.
-
-Please report this to the Python maintainer, along with the traceback,
-the Python version, and the hardware/OS platform and version."""
-
-class AssertionError(StandardError):
-    """Assertion failed."""
-
-class UnicodeDecodeError(UnicodeError):
-    """Unicode decoding error."""
-
-    # auto-generated code, please check carefully!
-    def __init__(self, *args):
-        argc = len(args)
-        self.args = args # modified: always assign args, no error check
-        if argc == 5:
-            self.encoding = args[0]
-            self.object = args[1]
-            self.start = args[2]
-            self.end = args[3]
-            self.reason = args[4]
-
-    # auto-generated code, please check carefully!
-    def __str__(self):
-        # this is a bad hack, please supply an implementation
-        res = ' '.join([
-           'object=' + str(self.object),
-           'end=' + str(self.end),
-           'encoding=' + str(self.encoding),
-           'args=' + str(self.args),
-           'start=' + str(self.start),
-           'reason=' + str(self.reason),
-        ])
-        return res
-
-class TypeError(StandardError):
-    """Inappropriate argument type."""
-
-class IndexError(LookupError):
-    """Sequence index out of range."""
-
-class RuntimeWarning(Warning):
-    """Base class for warnings about dubious runtime behavior."""
-
-class KeyboardInterrupt(StandardError):
-    """Program interrupted by user."""
-
-class UserWarning(Warning):
-    """Base class for warnings generated by user code."""
-
-class TaskletExit(SystemExit):
-    """Request to exit from a tasklet."""
-
-class MemoryError(StandardError):
-    """Out of memory."""
-
-class UnboundLocalError(NameError):
-    """Local name referenced but not bound to a value."""
-
-class NotImplementedError(RuntimeError):
-    """Method or function hasn't been implemented yet."""
-
-class AttributeError(StandardError):
-    """Attribute not found."""
-
-class OverflowError(ArithmeticError):
-    """Result too large to be represented."""
-
-class WindowsError(OSError):
-    """MS-Windows OS system call failed."""
-

Deleted: /pypy/dist/pypy/appspace/_file.py
==============================================================================
--- /pypy/dist/pypy/appspace/_file.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,118 +0,0 @@
-import sio
-
-class file_(object):
-    """An implementation of file objects in Python. it relies on Guido's
-       sio.py implementation.
-    """
-
-    
-    def __init__(self, name, mode='r', bufsize=None):
-        self.reading = False
-        self.writing = False
-        
-        if not mode:
-            raise IOError('invalid mode :  ')
-        if mode[0] not in ['r', 'w', 'a', 'U']:
-            raise IOError('invalid mode : %s' % mode)
-        else:
-            if mode[0] in ['r', 'U']:
-                self.reading = True
-            else:
-                self.writing = True
-        try:
-            if mode[1] == 'b':
-                plus = mode[2]
-            else:
-                plus = mode[1]
-            if plus == '+':
-                self.reading = self.writing = True
-        except IndexError:
-            pass
-
-        self._mode = mode
-        self._name = name
-        self._closed = False
-        self.softspace =  0 # Required according to file object docs
-        self._encoding = None # Fix when we find out how encoding should be
-        self.fd = sio.DiskFile(name, mode)
-        if mode in ['U', 'rU']:
-            # Wants universal newlines
-            self.fd = sio.TextInputFilter(self.fd)
-        if bufsize < 0:
-            bufsize = None
-        if not self.writing and (bufsize is None or bufsize > 0):
-            "Read only buffered stream."
-            self.fd = sio.BufferingInputStream(self.fd, bufsize)
-        if not self.reading:
-            if bufsize is None or bufsize > 1:
-                "Write only buffered stream."
-                self.fd = sio.BufferingOutputStream(self.fd, bufsize)
-            elif bufsize == 1:
-                self.fd = sio.LineBufferingOutputStream(self.fd)
-        if self.reading and self.writing:
-            if bufsize > 2:
-                "Read and write buffered stream."
-                self.fd = sio.BufferingInputOutputStream(self.fd, bufsize)
-
-    def __iter__(self):
-        """
-        Return an iterator for the file.
-        """
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        return self
-    xreadlines = __iter__
-    
-    def next(self):
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        line = self.fd.readline()
-        if line == '':
-            raise StopIteration
-        return line
-
-    def close(self):
-        """
-        Close the file
-        """
-        self._closed = True
-        try:
-            self.fd.close()
-        except AttributeError:
-            pass
-
-    def __getattr__(self, attr):
-        """
-        Handle the readonly attributes and then delegate the other
-        methods to the underlying file object, setting the 'closed'
-        attribute if you close the file.
-        """
-        if attr in ['fd', 'softspace', 'reading', 'writing']:
-            return self.__dict__[attr]
-        elif attr in ['mode', 'name', 'closed', 'encoding']:
-            return self.__dict__['_' + attr]
-                
-        return getattr(self.fd, attr)
-
-    def __setattr__(self, attr, val):
-        "Make some attributes readonly."
-        if attr in ['mode', 'name', 'closed', 'encoding']:
-            raise TypeError, "readonly attribute:'%s'" % attr
-        self.__dict__[attr] = val
-
-    def seek(self, *args, **kw):
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        self.fd.seek(*args, **kw)
-
-    def write(self, *args, **kw):
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        self.fd.write(*args, **kw)
-
-    def writelines(self, seq = ()):
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        for line in seq:
-            self.write(line)
-        

Deleted: /pypy/dist/pypy/appspace/_float_formatting.py
==============================================================================
--- /pypy/dist/pypy/appspace/_float_formatting.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,110 +0,0 @@
-import math
-
-# from the excessive effort department, routines for printing floating
-# point numbers from
-
-# "Printing Floating-Point Numbers Quickly and Accurately" by Burger &
-# Dybvig, Proceedings of the SIGPLAN '96 Conference on Programming
-# Language Design and Implementation.
-
-# The paper contains scheme code which has been specialized for IEEE
-# doubles and converted into Python by Michael Hudson.
-
-# XXX unfortunately, we need the fixed-format output routines, the source
-# for which is not included in the paper... for now, just put up with
-# occasionally incorrectly rounded final digits.  I'll get to it.
-
-# XXX should run this at interpreter level, really....
-
-def decode_float(f):
-    """decode_float(float) -> int, int
-
-    Return (m, e), the mantissa and exponent respectively of
-    f (assuming f is an IEEE double), i.e. f == m * 2**e and
-    2**52 <= m < 2**53."""
-    m, e = math.frexp(f)
-    m = long(m*2.0**53)
-    e -= 53
-    return m, e
-
-def decompose(f):
-    """decompose(float) -> int, int, int, int
-
-    Return r, s, m_plus, m_minus for f, in the terms of
-    Burger and Dybvig's paper (see Table 1).
-
-    To spell this out: f = r/s, (r+m+)/s is halfway to the
-    next largest floating point number, (r-m-) halfway to
-    the next smallest."""
-    m, e = decode_float(f)
-    if e >= 0:
-        if not m != 2**52:
-            be = 2**e
-            return m*be*2, 2, be, be
-        else:
-            be = 2**e
-            be1 = 2*be
-            return m*be1*2, 4, be1, be
-    else:
-        if e == -1075 or m != 2**52:
-            return m*2, 2**(-e+1), 1, 1
-        else:
-            return m*4, 2**(-e+2), 2, 1
-
-
-def flonum2digits(f):
-    """flonum2digits(float) -> [int], int
-
-    Given a float f return [d1, ..., dn], k such that
-
-        0.[d1][d2]...[dn] * 10**k
-
-    is the shortest decimal representation that will
-    reproduce f when read in by a correctly rounding input
-    routine (under any strategy for breaking ties)."""
-    
-    assert f >= 0
-    if f == 0.0:
-        return ['0'], 1
-
-    # See decompose's docstring for what these mean.
-    r, s, m_plus, m_minus = decompose(f)
-
-    # k is the index, relative to the radix point of the
-    # most-significant non-zero digit of the infinite
-    # decimal expansion of f.  This calculation has the
-    # potential to underestimate by one (handled below).
-    k = long(math.ceil(math.log10(f) - 1e-10))
-
-    if k >= 0:
-        s *= 10 ** k
-    else:
-        scale = 10 ** -k
-        r *= scale
-        m_plus *= scale
-        m_minus *= scale
-
-    # Check that we got k right above.
-    if r + m_plus > s:
-        s *= 10
-        k += 1
-
-    # Generate the digits.
-    rr = []
-    while 1:
-        d, r = divmod(r*10, s)
-        m_plus *= 10
-        m_minus *= 10
-        tc1 = r < m_minus
-        tc2 = (r + m_plus) > s
-        if tc2:
-            rr.append(d+1)
-        else:
-            rr.append(d)
-        if tc1 or tc2:
-            break
-        
-    assert max(rr) < 10
-    assert min(rr) >= 0
-
-    return map(str, rr), k

Deleted: /pypy/dist/pypy/appspace/_formatting.py
==============================================================================
--- /pypy/dist/pypy/appspace/_formatting.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,409 +0,0 @@
-# Application level implementation of string formatting.
-
-# There's some insane stuff in here.  Blame CPython.  Please.
-
-# Known problems:
-# (1) rounding isn't always right (see comments in _float_formatting).
-# (2) something goes wrong in the f_alt case of %g handling.
-# (3) it's really, really slow.
-
-class _Flags(object):
-    def __repr__(self):
-        return "<%s>"%(', '.join([f for f in self.__dict__
-                                  if f[0] == 'f' and getattr(self, f)]),)
-    f_ljust = 0
-    f_sign = 0
-    f_blank = 0
-    f_alt = 0
-    f_zero = 0
-
-
-def value_next(valueiter):
-    try:
-        return valueiter.next()
-    except StopIteration:
-        raise TypeError('not enough arguments for format string')
-
-
-def peel_num(c, fmtiter, valueiter):
-    if c == '*':
-        v = value_next(valueiter)
-        if not isinstance(v, int):
-            raise TypeError, "* wants int"
-        return fmtiter.next(), v
-    n = ''
-    while c in '0123456789':
-        n += c
-        c = fmtiter.next()
-    if n:
-        return c, int(n)
-    else:
-        return c, 0
-
-
-def peel_flags(c, fmtiter):
-    flags = _Flags()
-    while 1:
-        if c == '-':
-            flags.f_ljust = True
-        elif c == '+':
-            flags.f_sign = True
-        elif c == ' ':
-            flags.f_blank = True
-        elif c == '#':
-            flags.f_alt = True
-        elif c == '0':
-            flags.f_zero = True
-        else:
-            break
-        c = fmtiter.next()
-    return c, flags
-
-
-def parse_fmt(fmtiter, valueiter, valuedict):
-    """return (char, flags, width, prec, value)
-    partially consumes fmtiter & valueiter"""
-    c = fmtiter.next()
-    gotvalue = False
-    if c == '(':
-        n = ''
-        pcount = 1
-        while 1:
-            c = fmtiter.next()
-            if c == ')':
-                pcount -= 1
-                if pcount == 0:
-                    break
-            elif c == '(':
-                pcount += 1
-            n += c
-        value = valuedict[n]
-        gotvalue = True
-        c = fmtiter.next()
-    c, flags = peel_flags(c, fmtiter)
-    c, width = peel_num(c, fmtiter, valueiter)
-    if c == '.':
-        c, prec = peel_num(fmtiter.next(), fmtiter, valueiter)
-    else:
-        prec = None
-    if c in 'hlL':
-        c = fmtiter.next()
-    if width and width < 0:
-        # this can happen with *-args
-        flags.f_ljust = True
-        width = -width
-    if not gotvalue:
-        if c == '%':
-            # did YOU realize that "%4%"%() == '   %'??
-            value = '%'
-            c = 's'
-        else:
-            value = value_next(valueiter)
-    return (c, flags, width, prec, value)
-
-
-class Formatter(object):
-    def __init__(self, char, flags, width, prec, value):
-        self.char = char
-        self.flags = flags
-        self.width = width
-        self.prec = prec
-        self.value = value
-
-    def numeric_preprocess(self, v):
-        # negative zeroes?
-        # * mwh giggles, falls over
-        # still, if we can recognize them, here's the place to do it.
-        import math
-        if v < 0 or v == 0 and math.atan2(0, v) != 0:
-            sign = '-'
-            v = -v
-        else:
-            if self.flags.f_sign:
-                sign = '+'
-            elif self.flags.f_blank:
-                sign = ' '
-            else:
-                sign = ''
-        return v, sign
-
-    def numeric_postprocess(self, r, sign,prefix=""):
-        assert self.char in 'iduoxXeEfFgG'
-        padchar = ' '
-        if self.flags.f_zero:
-            padchar = '0'
-        if self.width is not None:
-            p = self.width - len(r) - len(sign) -len(prefix)
-            if self.flags.f_ljust:
-                r = sign + prefix + r + ' '*p
-            else:
-                if self.flags.f_zero:
-                    r = sign+prefix+padchar*p + r
-                else:
-                    r = padchar*p + sign + prefix + r
-        else:
-            r = sign + prefix + r
-        return r
-
-    def format(self):
-        raise NotImplementedError
-
-    def std_wp(self, r):
-        assert self.char not in 'iduoxXeEfFgG'
-        if self.prec is not None:
-            r = r[:self.prec]
-        if self.width is not None:
-            p = self.width - len(r)
-            if self.flags.f_ljust:
-                r = r + ' '*p
-            else:
-                r = ' '*p + r
-        return r
-
-
-def funcFormatter(*funcs):
-    class _F(Formatter):
-        def format(self):
-            r = self.value
-            for f in funcs:
-                r = f(r)
-            return self.std_wp(r)
-    return _F
-
-
-def maybe_int(value):
-    try:
-        inter = value.__int__
-    except AttributeError:
-        raise TypeError, "int argument required"
-    return inter()
-
-
-def maybe_float(value):
-    try:
-        floater = value.__float__
-    except AttributeError:
-        raise TypeError, "float argument required"
-    return floater()
-
-
-from _float_formatting import flonum2digits
-
-class FloatFormatter(Formatter):
-    def eDigits(self, ds):
-        ds = ds[:self.prec + 1] + ['0'] * (self.prec + 1 - len(ds))
-        if self.prec > 0 or self.flags.f_alt:
-            ds[1:1] = ['.']
-        return ''.join(ds)
-
-    def fDigits(self, ds, k):
-        p = max(self.prec, 0)
-        if 0 < k < len(ds):
-            if len(ds) - k < p:
-                ds.extend(['0'] * (p - (len(ds) - k)))
-            else:
-                ds = ds[:p + k]
-            ds[k:k] = ['.']
-        elif k <= 0:
-            ds[0:0] = ['0']*(-k)
-            ds = ds[:p]
-            ds.extend(['0'] * (p - len(ds)))
-            ds[0:0]= ['0', '.']
-        elif k >= len(ds):
-            ds.extend((k-len(ds))*['0'] + ['.'] + ['0']*p)
-        return ''.join(ds)
-
-    def format(self):
-        v = maybe_float(self.value)
-        v, sign = self.numeric_preprocess(v)
-        if self.prec is None:
-            self.prec = 6
-        r = self._format(v)
-        return self.numeric_postprocess(r, sign)
-
-
-class FloatFFormatter(FloatFormatter):
-    def _format(self, v):
-        if v/1e25 > 1e25:
-            return FloatGFormatter('g', self.flags, self.width,
-                                   self.prec, self.value).format()
-        ds, k = flonum2digits(v)
-        digits = self.fDigits(ds, k)
-        if  not self.flags.f_alt:
-            digits = digits.rstrip('.')
-        return digits
-
-
-class FloatEFormatter(FloatFormatter):
-    def _format(self, v):
-        ds, k = flonum2digits(v)
-        digits = self.eDigits(ds)
-        return "%s%c%+03d"%(digits, self.char, k-1)
-
-
-class FloatGFormatter(FloatFormatter):
-    # The description of %g in the Python documentation lies
-    # in a variety of minor ways.
-    # Gah, this still isn't quite right in the f_alt case.
-    # (One has to wonder who might care).
-    def _format(self, v):
-        ds, k = flonum2digits(v)
-        ds = ds[:self.prec] # XXX rounding!
-        if -4 < k <= self.prec:
-            digits = self.fDigits(ds, k)
-            if not self.flags.f_alt:
-                digits = digits.rstrip('0').rstrip('.')
-            r = digits
-        else:
-            digits = self.eDigits(ds)
-            if not self.flags.f_alt:
-                digits = digits.rstrip('0').rstrip('.')
-            r = "%se%+03d"%(digits, k-1)
-        return r
-
-
-class HexFormatter(Formatter):
-    # NB: this has 2.4 semantics wrt. negative values
-    def format(self):
-        v, sign = self.numeric_preprocess(maybe_int(self.value))
-        r = hex(v)[2:]
-        if r[-1]=="L":
-            # workaround weird behavior of CPython's hex
-            r = r[:-1].lower()
-        if self.prec is not None and len(r) < self.prec:
-            r = '0'*(self.prec - len(r)) + r
-        if self.flags.f_alt:
-            prefix = '0x'
-        else:
-            prefix = ''
-        if self.char == 'X':
-            r = r.upper()
-            prefix = prefix.upper()
-        return self.numeric_postprocess(r, sign, prefix)
-
-
-class OctFormatter(Formatter):
-    # NB: this has 2.4 semantics wrt. negative values
-    def format(self):
-        v, sign = self.numeric_preprocess(maybe_int(self.value))
-        r = oct(v)
-        if r[-1] == "L":
-            r = r[:-1]
-        if v and not self.flags.f_alt:
-            r = r[1:]
-        if self.prec is not None and len(r) < self.prec:
-            r = '0'*(self.prec - len(r)) + r
-        return self.numeric_postprocess(r, sign)
-
-
-class IntFormatter(Formatter):
-    # NB: this has 2.4 semantics wrt. negative values (for %u)
-    def format(self):
-        v, sign = self.numeric_preprocess(maybe_int(self.value))
-        r = str(v)
-        if self.prec is not None and len(r) < self.prec:
-            r = '0'*(self.prec - len(r)) + r
-        return self.numeric_postprocess(r, sign)
-
-
-class CharFormatter(Formatter):
-    def format(self):
-        if isinstance(self.value, str):
-            v = self.value
-            if len(v) != 1:
-                raise TypeError, "%c requires int or char"
-        else:
-            i = maybe_int(self.value)
-            if not 0 <= i <= 255:
-                raise OverflowError("OverflowError: unsigned byte "
-                                    "integer is greater than maximum")
-            v = chr(i)
-        self.prec = None
-        return self.std_wp(v)
-
-
-format_registry = {
-    'd':IntFormatter,
-    'i':IntFormatter,
-    'o':OctFormatter,
-    'u':IntFormatter,
-    'x':HexFormatter,
-    'X':HexFormatter,
-    'e':FloatEFormatter,
-    'E':FloatEFormatter,
-    'f':FloatFFormatter,
-    'F':FloatFFormatter,
-    'g':FloatGFormatter,
-    'G':FloatGFormatter,
-    'c':CharFormatter,
-    's':funcFormatter(str),
-    'r':funcFormatter(repr),
-    # this *can* get accessed, by e.g. '%()4%'%{'':1}.
-    # The usual %% case has to be handled specially as it
-    # doesn't consume a value.
-    '%':funcFormatter(lambda x:'%'),
-    }
-
-
-class FmtIter(object):
-    def __init__(self, fmt):
-        self.fmt = fmt
-        self.i = 0
-
-    def __iter__(self):
-        return self
-
-    def next(self):
-        try:
-            c = self.fmt[self.i]
-        except IndexError:
-            raise StopIteration
-        self.i += 1
-        return c
-
-    def skip_to_fmt(self):
-        i = self.i
-        j = self.fmt.find('%', i)
-        if j < 0:
-            self.i = len(self.fmt)
-            return self.fmt[i:]
-        else:
-            self.i = j
-            return self.fmt[i:j]
-
-
-def format(fmt, values, valuedict=None):
-    fmtiter = FmtIter(fmt)
-    valueiter = iter(values)
-    r = []
-    try:
-        for c in fmtiter:
-            if c == '%':
-                t = parse_fmt(fmtiter, valueiter, valuedict)
-                try:
-                    f = format_registry[t[0]]
-                except KeyError:
-                    raise ValueError("unsupported format character "
-                                     "'%s' (0x%x) at index %d"
-                                     %(t[0], ord(t[0]), fmtiter.i-1))
-                # Trying to translate this using the flow space.
-                # Currently, star args give a problem there,
-                # so let's be explicit about the args:
-                # r.append(f(*t).format())
-                char, flags, width, prec, value = t
-                r.append(f(char, flags, width, prec, value).format())
-            else:
-                # efficiency hack:
-                r.append(c + fmtiter.skip_to_fmt())
-    except StopIteration:
-        raise ValueError, "incomplete format"
-    try:
-        valueiter.next()
-    except StopIteration:
-        pass
-    else:
-        if valuedict is None:
-            raise TypeError('not all arguments converted '
-                            'during string formatting')
-    return ''.join(r)
-

Deleted: /pypy/dist/pypy/appspace/_types.py
==============================================================================
--- /pypy/dist/pypy/appspace/_types.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,551 +0,0 @@
-"""
-Definition of the standard Python types.
-"""
-
-# XXX we can't do this import yet
-from sys import pypy
-import __builtin__
-import _types
-
-__all__ = ['BooleanType', 'BufferType', 'BuiltinFunctionType',
-           'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType',
-           'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType',
-           'FileType', 'FloatType', 'FrameType', 'FunctionType',
-           'GeneratorType', 'InstanceType', 'IntType', 'LambdaType',
-           'ListType', 'LongType', 'MethodType', 'ModuleType', 'NoneType',
-           'NotImplementedType', 'ObjectType', 'SliceType', 'StringType',
-           'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType',
-           'UnicodeType', 'XRangeType']
-
-
-def _register(factory, cls, in_builtin=True, synonym=True):
-    """
-    Register factory as type cls.
-
-    If in_builtin is a true value (which is the default), also
-    register the type as a built-in. If the value of in_builtin
-    is a string, use this name as the type name in the __builtin__
-    module.
-
-    If synonym is true (which is the default), also register the
-    type in this very module under its synonym. If synonym is a
-    string, use this string, else uppercase the class name and
-    append the string "Type".
-    """
-    pypy.registertype(factory, cls)
-    if in_builtin:
-        if isinstance(in_builtin, str):
-            typename = in_builtin
-        else:
-            typename = cls.__name__
-        setattr(__builtin__, typename, cls)
-    if synonym:
-        if isinstance(synonym, str):
-            typename = synonym
-        else:
-            typename = cls.__name__.title() + 'Type'
-        setattr(_types, typename, cls)
-
-
-class object:
-
-    def __new__(cls):
-        if cls is object:
-            return pypy.ObjectFactory()
-        else:
-            return pypy.UserObjectFactory(cls, pypy.ObjectFactory)
-
-    def __repr__(self):
-        return '<%s object at 0x%x>' % (type(self).__name__, id(self))
-
-_register(pypy.ObjectFactory, object)
-
-
-class bool(int):
-
-    def __new__(cls, *args):
-        if cls is bool:
-            return pypy.BoolObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.BoolObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.BoolObjectFactory, bool, synonym='BooleanType')
-
-
-class buffer(object):
-
-    def __new__(cls, *args):
-        if cls is buffer:
-            return pypy.BufferObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.BufferObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.BufferObjectFactory, buffer)
-
-
-class builtin_function_or_method(object):
-
-    def __new__(cls, *args):
-        if cls is builtin_function_or_method:
-            return pypy.Builtin_Function_Or_MethodObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls,
-                     pypy.Builtin_Function_Or_MethodObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.Builtin_Function_Or_MethodObjectFactory,
-          builtin_function_or_method, in_builtin=False,
-          synonym='BuiltinFunctionType')
-
-setattr(_types, 'BuiltinMethodType', builtin_function_or_method)
-
-
-class classobj(object):
-
-    def __new__(cls, *args):
-        if cls is classobj:
-            return pypy.ClassobjObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.ClassobjObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.ClassobjObjectFactory, classobj, in_builtin=False,
-          synonym='ClassType')
-
-
-class code(object):
-
-    def __new__(cls, *args):
-        if cls is code:
-            return pypy.CodeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.CodeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.CodeObjectFactory, code, in_builtin=False)
-
-
-class complex(object):
-
-    def __new__(cls, *args):
-        if cls is complex:
-            return pypy.ComplexObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.ComplexObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.ComplexObjectFactory, complex)
-
-
-class dictproxy(object):
-
-    def __new__(cls, *args):
-        if cls is dictproxy:
-            return pypy.DictproxyObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.DictproxyObjectFactory,
-                                          args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.DictproxyObjectFactory, dictproxy, in_builtin=False,
-          synonym='DictProxyType')
-
-
-class dict(object):
-
-    def __new__(cls, *args):
-        if cls is dict:
-            return pypy.DictObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.DictObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-# add to dict all and only those methods that used to be defined in
-# objspace/std/dicttype.py, but get the implementations from the
-# excellent code in UserDict.DictMixin instead (no inheritance for
-# two reasons: we could not control what methods we get, and we do
-# not want DictMixin among user-visible __bases__).
-import UserDict
-for attribute in ('update popitem get setdefault pop'
-                  'iteritems iterkeys itervalues').split():
-    setattr(dict, attribute, UserDict.DictMixin.__dict__[attribute])
-
-_register(pypy.DictObjectFactory, dict)
-
-setattr(_types, 'DictionaryType', dict)
-
-
-class ellipsis(object):
-
-    def __new__(cls, *args):
-        if cls is ellipsis:
-            return pypy.EllipsisObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.EllipsisObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.EllipsisObjectFactory, ellipsis, in_builtin=False)
-
-
-class file(object):
-
-    def __new__(cls, *args):
-        if cls is file:
-            return pypy.FileObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.FileObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.FileObjectFactory, file, in_builtin='open')
-
-
-# XXX: for float as for all other classes, __new__ defers to a suitable
-# factory from pypy; in floattype.py, the implementation of __new__ was
-# quite differently, but we think that was not needed -- remove this
-# comment once this is definitively established.
-# NB: other rich implementations of __new__ from old *type.py modules
-# not reproduced here: int, slice, str, tuple, type
-class float(object):
-
-    def __new__(cls, *args):
-        if cls is float:
-            return pypy.FloatObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.FloatObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.FloatObjectFactory, float)
-
-
-class frame(object):
-
-    def __new__(cls, *args):
-        if cls is frame:
-            return pypy.FrameObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.FrameObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.FrameObjectFactory, frame, in_builtin=False)
-
-
-class function(object):
-
-    def __new__(cls, *args):
-        if cls is function:
-            return pypy.FunctionObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.FunctionObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-    # XXX find out details for builtin properties
-    func_code    = pypy.builtin_property('fix')
-    func_globals = pypy.builtin_property('me')
-
-_register(pypy.FunctionObjectFactory, function, in_builtin=False)
-
-
-class generator(object):
-
-    def __new__(cls, *args):
-        if cls is generator:
-            return pypy.GeneratorObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.GeneratorObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.GeneratorObjectFactory, generator, in_builtin=False)
-
-
-class instance(object):
-
-    def __new__(cls, *args):
-        if cls is instance:
-            return pypy.InstanceObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.InstanceObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.InstanceObjectFactory, instance, in_builtin=False)
-
-
-class int(object):
-
-    def __new__(cls, *args):
-        if cls is int:
-            return pypy.IntObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.IntObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.IntObjectFactory, int)
-
-setattr(_types, 'LambdaType', function)
-
-
-class list(object):
-
-    def __new__(cls, *args):
-        if cls is list:
-            return pypy.ListObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.ListObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.ListObjectFactory, list)
-
-
-class long(object):
-
-    def __new__(cls, *args):
-        if cls is long:
-            return pypy.LongObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.LongObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.LongObjectFactory, long)
-
-
-class instancemethod(object):
-
-    def __new__(cls, *args):
-        if cls is instancemethod:
-            return pypy.InstancemethodObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls,
-                     pypy.InstancemethodObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.InstancemethodObjectFactory, instancemethod, in_builtin=False,
-          synonym='MethodType')
-
-
-class module(object):
-
-    def __new__(cls, *args):
-        if cls is module:
-            return pypy.ModuleObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.ModuleObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.ModuleObjectFactory, module, in_builtin=False)
-
-
-class NoneType(object):
-
-    def __new__(cls, *args):
-        if cls is NoneType:
-            return pypy.NonetypeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.NonetypeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.NonetypeObjectFactory, NoneType, in_builtin=False,
-          synonym='NoneType')
-
-
-class NotImplementedType(object):
-
-    def __new__(cls, *args):
-        if cls is NotImplementedType:
-            return pypy.NotimplementedtypeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls,
-                     pypy.NotimplementedtypeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.NotimplementedtypeObjectFactory, NotImplementedType,
-          in_builtin=False, synonym='NotImplementedType')
-
-
-class slice(object):
-
-    def __new__(cls, *args):
-        if cls is slice:
-            return pypy.SliceObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.SliceObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-    def indices(self, length):
-        step = self.step
-        if step is None:
-            step = 1
-        elif step == 0:
-            raise ValueError, "slice step cannot be zero"
-        if step < 0:
-            defstart = length - 1
-            defstop = -1
-        else:
-            defstart = 0
-            defstop = length
-
-        start = self.start
-        if start is None:
-            start = defstart
-        else:
-            if start < 0:
-                start += length
-                if start < 0:
-                    if step < 0:
-                        start = -1
-                    else:
-                        start = 0
-            elif start >= length:
-                if step < 0:
-                    start = length - 1
-                else:
-                    start = length
-
-        stop = self.stop
-        if stop is None:
-            stop = defstop
-        else:
-            if stop < 0:
-                stop += length
-                if stop < 0:
-                    stop = -1
-            elif stop > length:
-                stop = length
-
-        return start, stop, step
-
-_register(pypy.SliceObjectFactory, slice)
-
-
-class str(object):
-
-    def __new__(cls, *args):
-        if cls is str:
-            return pypy.StrObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.StrObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.StrObjectFactory, str, synonym='StringType')
-
-
-class traceback(object):
-
-    def __new__(cls, *args):
-        if cls is traceback:
-            return pypy.TracebackObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.TracebackObjectFactory,
-                                          args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.TracebackObjectFactory, traceback, in_builtin=False)
-
-
-class tuple(object):
-
-    def __new__(cls, *args):
-        if cls is tuple:
-            return pypy.TupleObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.TupleObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.TupleObjectFactory, tuple)
-
-
-class type(object):
-
-    def __new__(cls, *args):
-        if cls is type:
-            return pypy.TypeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.TypeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.TypeObjectFactory, type)
-
-setattr(_types, 'UnboundMethodType', instancemethod)
-
-
-class unicode(object):
-
-    def __new__(cls, *args):
-        if cls is unicode:
-            return pypy.UnicodeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.UnicodeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.UnicodeObjectFactory, unicode)
-
-
-class xrange(object):
-
-    def __new__(cls, *args):
-        if cls is xrange:
-            return pypy.XrangeObjectFactory(args)
-        else:
-            return pypy.UserObjectFactory(cls, pypy.XrangeObjectFactory, args)
-
-    def __repr__(self):
-        return str(self)
-
-_register(pypy.XrangeObjectFactory, xrange, synonym='XRangeType')
-

Deleted: /pypy/dist/pypy/appspace/cStringIO.py
==============================================================================
--- /pypy/dist/pypy/appspace/cStringIO.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,5 +0,0 @@
-#
-# One-liner implementation of cStringIO
-#
-
-from StringIO import *

Deleted: /pypy/dist/pypy/appspace/cmathmodule.py
==============================================================================
--- /pypy/dist/pypy/appspace/cmathmodule.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,215 +0,0 @@
-"""This module is always available. It provides access to mathematical
-functions for complex numbers."""
-
-# Complex math module
-
-# much code borrowed from mathmodule.c
-
-import math
-
-M_PI = 3.141592653589793239
-
-        
-
-# constants
-_one = complex(1., 0.)
-_half = complex(0.5, 0.)
-_i = complex(0., 1.)
-_halfi = complex(0., 0.5)
-
-
-# internal function not available from Python
-def _prodi(x):
-    real = -x.imag
-    imag = x.real
-    return complex(real, imag)
-
-
-def acos(x):
-    """acos(x)
-
-    Return the arc cosine of x."""
-    
-    return -(_prodi(log((x+(_i*sqrt((_one-(x*x))))))))
-
-
-def acosh(x):
-    """acosh(x)
-
-    Return the hyperbolic arccosine of x."""
-
-    z = complex()
-    z = sqrt(_half)
-    z = log(z*(sqrt(x+_one)+sqrt(x-_one)))
-    return z+z
-
-
-def asin(x):
-    """asin(x)
-
-    Return the arc sine of x."""
-    
-    # -i * log[(sqrt(1-x**2) + i*x]
-    squared = x*x
-    sqrt_1_minus_x_sq = sqrt(_one-squared)
-    return -(_prodi(log((sqrt_1_minus_x_sq+_prodi(x)))))
-
-
-def asinh(x):
-    """asinh(x)
-
-    Return the hyperbolic arc sine of x."""
-    
-    z = complex()
-    z = sqrt(_half)
-    z = log((z * (sqrt(x+_i)+sqrt((x-_i))) ))
-    return z+z
-
-
-def atan(x):
-    """atan(x)
-    
-    Return the arc tangent of x."""
-    
-    return _halfi*log(((_i+x)/(_i-x)))
-
-
-def atanh(x):
-    """atanh(x)
-
-    Return the hyperbolic arc tangent of x."""
-    
-    return _half*log((_one+x)/(_one-x))
-
-
-def cos(x):
-    """cos(x)
-
-    Return the cosine of x."""
-    
-    real = math.cos(x.real) * math.cosh(x.imag)
-    imag = -math.sin(x.real) * math.sinh(x.imag)
-    return complex(real, imag)
-
-
-def cosh(x):
-    """cosh(x)
-    
-    Return the hyperbolic cosine of x."""
-    
-    real = math.cos(x.imag) * math.cosh(x.real)
-    imag = math.sin(x.imag) * math.sinh(x.real)
-    return complex(real, imag)
-
-
-def exp(x):
-    """exp(x)
-    
-    Return the exponential value e**x."""
-    
-    l = math.exp(x.real)
-    real = l * math.cos(x.imag)
-    imag = l * math.sin(x.imag)
-    return complex(real, imag)
-
-
-def log(x):
-    """log(x)
-
-    Return the natural logarithm of x."""
-    
-    l = math.hypot(x.real,x.imag)
-    imag = math.atan2(x.imag, x.real)
-    real = math.log(l)
-    return complex(real, imag)
-
-
-def log10(x):
-    """log10(x)
-
-    Return the base-10 logarithm of x."""
-    
-    l = math.hypot(x.real, x.imag)
-    imag = math.atan2(x.imag, x.real)/math.log(10.)
-    real = math.log10(l)
-    return complex(real, imag)
-
-
-def sin(x):
-    """sin(x)
-
-    Return the sine of x."""
-    
-    real = math.sin(x.real) * math.cosh(x.imag)
-    imag = math.cos(x.real) * math.sinh(x.imag)
-    return complex(real, imag)
-
-
-def sinh(x):
-    """sinh(x)
-
-    Return the hyperbolic sine of x."""
-    
-    real = math.cos(x.imag) * math.sinh(x.real)
-    imag = math.sin(x.imag) * math.cosh(x.real)
-    return complex(real, imag)
-
-
-def sqrt(x):
-    """sqrt(x)
-
-    Return the square root of x."""
-    
-    if x.real == 0. and x.imag == 0.:
-        real, imag = 0, 0
-    else:
-        s = math.sqrt(0.5*(math.fabs(x.real) + math.hypot(x.real,x.imag)))
-        d = 0.5*x.imag/s
-        if x.real > 0.:
-            real = s
-            imag = d
-        elif x.imag >= 0.:
-            real = d
-            imag = s
-        else:
-            real = -d
-            imag = -s
-    return complex(real, imag)
-
-
-def tan(x):
-    """tan(x)
-
-    Return the tangent of x."""
-
-    sr = math.sin(x.real)
-    cr = math.cos(x.real)
-    shi = math.sinh(x.imag)
-    chi = math.cosh(x.imag)
-    rs = sr * chi
-    is_ = cr * shi
-    rc = cr * chi
-    ic = -sr * shi
-    d = rc*rc + ic * ic
-    real = (rs*rc + is_*ic) / d
-    imag = (is_*rc - rs*ic) / d
-    return complex(real, imag)
-
-
-def tanh(x):
-    """tanh(x)
-
-    Return the hyperbolic tangent of x."""
-    
-    si = math.sin(x.imag)
-    ci = math.cos(x.imag)
-    shr = math.sinh(x.real)
-    chr = math.cosh(x.real)
-    rs = ci * shr
-    is_ = si * chr
-    rc = ci * chr
-    ic = si * shr
-    d = rc*rc + ic*ic
-    real = (rs*rc + is_*ic) / d
-    imag = (is_*rc - rs*ic) / d
-    return complex(real, imag)

Deleted: /pypy/dist/pypy/appspace/dumbre.py
==============================================================================
--- /pypy/dist/pypy/appspace/dumbre.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,5 +0,0 @@
-class Pattern:
-    def __init__(self, pattern, flags):
-        print 'regex', pattern
-        print 'killed'
-        raise SystemExit

Deleted: /pypy/dist/pypy/appspace/imp.py
==============================================================================
--- /pypy/dist/pypy/appspace/imp.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,72 +0,0 @@
-"""
-This module provides the components needed to build your own
-__import__ function.  Undocumented functions are obsolete.
-"""
-
-# XXX partial implementation
-
-# XXX to be reviewed
-
-import sys, os
-
-PY_SOURCE = 1
-PKG_DIRECTORY = 5
-C_BUILTIN = 6
-
-def get_magic():
-    return '\x3b\xf2\x0d\x0a'
-
-def get_suffixes():
-    return [('.py', 'U', PY_SOURCE)]
-
-new_module = type(sys)
-
-
-def find_module(name, path=None):
-    if path is None:
-        if name in sys.builtin_module_names:
-            return (None, name, ('', '', C_BUILTIN))
-        path = sys.path
-    for base in path:
-        filename = os.path.join(base, name)
-        if os.path.isdir(filename):
-            return (None, filename, ('', '', PKG_DIRECTORY))
-        filename += '.py'
-        if os.path.exists(filename):
-            return (file(filename, 'U'), filename, ('.py', 'U', PY_SOURCE))
-    raise ImportError, 'No module named %s' % (name,)
-
-
-def load_module(name, file, filename, description):
-    suffix, mode, type = description
-    module = sys.modules.get(name)
-
-    if type == PY_SOURCE:
-        source = file.read()
-        co = compile(source, filename, 'exec')
-        if module is None:
-            sys.modules[name] = module = new_module(name)
-        module.__dict__.clear()
-        module.__name__ = name
-        module.__doc__ = None
-        module.__file__ = filename
-        exec co in module.__dict__
-        return module
-
-    if type == PKG_DIRECTORY:
-        initfilename = os.path.join(filename, '__init__.py')
-        if module is None:
-            sys.modules[name] = module = new_module(name)
-        module.__dict__.clear()
-        module.__name__ = name
-        module.__doc__ = None
-        module.__file__ = initfilename
-        module.__path__ = [filename]
-        execfile(initfilename, module.__dict__)
-        return module
-
-    if type == C_BUILTIN:
-        module = __import__(name, {}, {}, None)
-        return module
-
-    raise ValueError, 'invalid description argument: %r' % (description,)

Deleted: /pypy/dist/pypy/appspace/md5.py
==============================================================================
--- /pypy/dist/pypy/appspace/md5.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,434 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1
-
-"""A sample implementation of MD5 in pure Python.
-
-This is an implementation of the MD5 hash function, as specified by
-RFC 1321, in pure Python. It was implemented using Bruce Schneier's
-excellent book "Applied Cryptography", 2nd ed., 1996.
-
-Surely this is not meant to compete with the existing implementation
-of the Python standard library (written in C). Rather, it should be
-seen as a Python complement that is more readable than C and can be
-used more conveniently for learning and experimenting purposes in
-the field of cryptography.
-
-This module tries very hard to follow the API of the existing Python
-standard library's "md5" module, but although it seems to work fine,
-it has not been extensively tested! (But note that there is a test
-module, test_md5py.py, that compares this Python implementation with
-the C one of the Python standard library.
-
-BEWARE: this comes with no guarantee whatsoever about fitness and/or
-other properties! Specifically, do not use this in any production
-code! License is Python License!
-
-Special thanks to Aurelian Coman who fixed some nasty bugs!
-
-Dinu C. Gherman
-"""
-
-
-__date__    = '2004-11-17'
-__version__ = 0.91 # Modernised by J. Hallén and L. Creighton for Pypy
-
-__metaclass__ = type # or genrpy won't work
-
-import struct, copy
-
-
-# ======================================================================
-# Bit-Manipulation helpers
-#
-#   _long2bytes() was contributed by Barry Warsaw
-#   and is reused here with tiny modifications.
-# ======================================================================
-
-def _long2bytes(n, blocksize=0):
-    """Convert a long integer to a byte string.
-
-    If optional blocksize is given and greater than zero, pad the front
-    of the byte string with binary zeros so that the length is a multiple
-    of blocksize.
-    """
-
-    # After much testing, this algorithm was deemed to be the fastest.
-    s = ''
-    pack = struct.pack
-    while n > 0:
-        ### CHANGED FROM '>I' TO '<I'. (DCG)
-        s = pack('<I', n & 0xffffffffL) + s
-        ### --------------------------
-        n = n >> 32
-
-    # Strip off leading zeros.
-    for i in range(len(s)):
-        if s[i] <> '\000':
-            break
-    else:
-        # Only happens when n == 0.
-        s = '\000'
-        i = 0
-
-    s = s[i:]
-
-    # Add back some pad bytes. This could be done more efficiently
-    # w.r.t. the de-padding being done above, but sigh...
-    if blocksize > 0 and len(s) % blocksize:
-        s = (blocksize - len(s) % blocksize) * '\000' + s
-
-    return s
-
-
-def _bytelist2long(list):
-    "Transform a list of characters into a list of longs."
-
-    imax = len(list)/4
-    hl = [0L] * imax
-
-    j = 0
-    i = 0
-    while i < imax:
-        b0 = long(ord(list[j]))
-        b1 = (long(ord(list[j+1]))) << 8
-        b2 = (long(ord(list[j+2]))) << 16
-        b3 = (long(ord(list[j+3]))) << 24
-        hl[i] = b0 | b1 |b2 | b3
-        i = i+1
-        j = j+4
-
-    return hl
-
-
-def _rotateLeft(x, n):
-    "Rotate x (32 bit) left n bits circularly."
-
-    return (x << n) | (x >> (32-n))
-
-
-# ======================================================================
-# The real MD5 meat...
-#
-#   Implemented after "Applied Cryptography", 2nd ed., 1996,
-#   pp. 436-441 by Bruce Schneier.
-# ======================================================================
-
-# F, G, H and I are basic MD5 functions.
-
-def F(x, y, z):
-    return (x & y) | ((~x) & z)
-
-def G(x, y, z):
-    return (x & z) | (y & (~z))
-
-def H(x, y, z):
-    return x ^ y ^ z
-
-def I(x, y, z):
-    return y ^ (x | (~z))
-
-
-def XX(func, a, b, c, d, x, s, ac):
-    """Wrapper for call distribution to functions F, G, H and I.
-
-    This replaces functions FF, GG, HH and II from "Appl. Crypto."
-    Rotation is separate from addition to prevent recomputation
-    (now summed-up in one function).
-    """
-
-    res = 0L
-    res = res + a + func(b, c, d)
-    res = res + x 
-    res = res + ac
-    res = res & 0xffffffffL
-    res = _rotateLeft(res, s)
-    res = res & 0xffffffffL
-    res = res + b
-
-    return res & 0xffffffffL
-
-
-class MD5:
-    "An implementation of the MD5 hash function in pure Python."
-
-    def __init__(self):
-        "Initialisation."
-        
-        # Initial message length in bits(!).
-        self.length = 0L
-        self.count = [0, 0]
-
-        # Initial empty message as a sequence of bytes (8 bit characters).
-        self.input = []
-
-        # Call a separate init function, that can be used repeatedly
-        # to start from scratch on the same object.
-        self.init()
-
-
-    def init(self):
-        "Initialize the message-digest and set all fields to zero."
-
-        self.length = 0L
-        self.count = [0, 0]
-        self.input = []
-
-        # Load magic initialization constants.
-        self.A = 0x67452301L
-        self.B = 0xefcdab89L
-        self.C = 0x98badcfeL
-        self.D = 0x10325476L
-
-
-    def _transform(self, inp):
-        """Basic MD5 step transforming the digest based on the input.
-
-        Note that if the Mysterious Constants are arranged backwards
-        in little-endian order and decrypted with the DES they produce
-        OCCULT MESSAGES!
-        """
-
-        a, b, c, d = A, B, C, D = self.A, self.B, self.C, self.D
-
-        # Round 1.
-
-        S11, S12, S13, S14 = 7, 12, 17, 22
-
-        a = XX(F, a, b, c, d, inp[ 0], S11, 0xD76AA478L) # 1 
-        d = XX(F, d, a, b, c, inp[ 1], S12, 0xE8C7B756L) # 2 
-        c = XX(F, c, d, a, b, inp[ 2], S13, 0x242070DBL) # 3 
-        b = XX(F, b, c, d, a, inp[ 3], S14, 0xC1BDCEEEL) # 4 
-        a = XX(F, a, b, c, d, inp[ 4], S11, 0xF57C0FAFL) # 5 
-        d = XX(F, d, a, b, c, inp[ 5], S12, 0x4787C62AL) # 6 
-        c = XX(F, c, d, a, b, inp[ 6], S13, 0xA8304613L) # 7 
-        b = XX(F, b, c, d, a, inp[ 7], S14, 0xFD469501L) # 8 
-        a = XX(F, a, b, c, d, inp[ 8], S11, 0x698098D8L) # 9 
-        d = XX(F, d, a, b, c, inp[ 9], S12, 0x8B44F7AFL) # 10 
-        c = XX(F, c, d, a, b, inp[10], S13, 0xFFFF5BB1L) # 11 
-        b = XX(F, b, c, d, a, inp[11], S14, 0x895CD7BEL) # 12 
-        a = XX(F, a, b, c, d, inp[12], S11, 0x6B901122L) # 13 
-        d = XX(F, d, a, b, c, inp[13], S12, 0xFD987193L) # 14 
-        c = XX(F, c, d, a, b, inp[14], S13, 0xA679438EL) # 15 
-        b = XX(F, b, c, d, a, inp[15], S14, 0x49B40821L) # 16 
-
-        # Round 2.
-
-        S21, S22, S23, S24 = 5, 9, 14, 20
-
-        a = XX(G, a, b, c, d, inp[ 1], S21, 0xF61E2562L) # 17 
-        d = XX(G, d, a, b, c, inp[ 6], S22, 0xC040B340L) # 18 
-        c = XX(G, c, d, a, b, inp[11], S23, 0x265E5A51L) # 19 
-        b = XX(G, b, c, d, a, inp[ 0], S24, 0xE9B6C7AAL) # 20 
-        a = XX(G, a, b, c, d, inp[ 5], S21, 0xD62F105DL) # 21 
-        d = XX(G, d, a, b, c, inp[10], S22, 0x02441453L) # 22 
-        c = XX(G, c, d, a, b, inp[15], S23, 0xD8A1E681L) # 23 
-        b = XX(G, b, c, d, a, inp[ 4], S24, 0xE7D3FBC8L) # 24 
-        a = XX(G, a, b, c, d, inp[ 9], S21, 0x21E1CDE6L) # 25 
-        d = XX(G, d, a, b, c, inp[14], S22, 0xC33707D6L) # 26 
-        c = XX(G, c, d, a, b, inp[ 3], S23, 0xF4D50D87L) # 27 
-        b = XX(G, b, c, d, a, inp[ 8], S24, 0x455A14EDL) # 28 
-        a = XX(G, a, b, c, d, inp[13], S21, 0xA9E3E905L) # 29 
-        d = XX(G, d, a, b, c, inp[ 2], S22, 0xFCEFA3F8L) # 30 
-        c = XX(G, c, d, a, b, inp[ 7], S23, 0x676F02D9L) # 31 
-        b = XX(G, b, c, d, a, inp[12], S24, 0x8D2A4C8AL) # 32 
-
-        # Round 3.
-
-        S31, S32, S33, S34 = 4, 11, 16, 23
-
-        a = XX(H, a, b, c, d, inp[ 5], S31, 0xFFFA3942L) # 33 
-        d = XX(H, d, a, b, c, inp[ 8], S32, 0x8771F681L) # 34 
-        c = XX(H, c, d, a, b, inp[11], S33, 0x6D9D6122L) # 35 
-        b = XX(H, b, c, d, a, inp[14], S34, 0xFDE5380CL) # 36 
-        a = XX(H, a, b, c, d, inp[ 1], S31, 0xA4BEEA44L) # 37 
-        d = XX(H, d, a, b, c, inp[ 4], S32, 0x4BDECFA9L) # 38 
-        c = XX(H, c, d, a, b, inp[ 7], S33, 0xF6BB4B60L) # 39 
-        b = XX(H, b, c, d, a, inp[10], S34, 0xBEBFBC70L) # 40 
-        a = XX(H, a, b, c, d, inp[13], S31, 0x289B7EC6L) # 41 
-        d = XX(H, d, a, b, c, inp[ 0], S32, 0xEAA127FAL) # 42 
-        c = XX(H, c, d, a, b, inp[ 3], S33, 0xD4EF3085L) # 43 
-        b = XX(H, b, c, d, a, inp[ 6], S34, 0x04881D05L) # 44 
-        a = XX(H, a, b, c, d, inp[ 9], S31, 0xD9D4D039L) # 45 
-        d = XX(H, d, a, b, c, inp[12], S32, 0xE6DB99E5L) # 46 
-        c = XX(H, c, d, a, b, inp[15], S33, 0x1FA27CF8L) # 47 
-        b = XX(H, b, c, d, a, inp[ 2], S34, 0xC4AC5665L) # 48 
-
-        # Round 4.
-
-        S41, S42, S43, S44 = 6, 10, 15, 21
-
-        a = XX(I, a, b, c, d, inp[ 0], S41, 0xF4292244L) # 49 
-        d = XX(I, d, a, b, c, inp[ 7], S42, 0x432AFF97L) # 50 
-        c = XX(I, c, d, a, b, inp[14], S43, 0xAB9423A7L) # 51 
-        b = XX(I, b, c, d, a, inp[ 5], S44, 0xFC93A039L) # 52 
-        a = XX(I, a, b, c, d, inp[12], S41, 0x655B59C3L) # 53 
-        d = XX(I, d, a, b, c, inp[ 3], S42, 0x8F0CCC92L) # 54 
-        c = XX(I, c, d, a, b, inp[10], S43, 0xFFEFF47DL) # 55 
-        b = XX(I, b, c, d, a, inp[ 1], S44, 0x85845DD1L) # 56 
-        a = XX(I, a, b, c, d, inp[ 8], S41, 0x6FA87E4FL) # 57 
-        d = XX(I, d, a, b, c, inp[15], S42, 0xFE2CE6E0L) # 58 
-        c = XX(I, c, d, a, b, inp[ 6], S43, 0xA3014314L) # 59 
-        b = XX(I, b, c, d, a, inp[13], S44, 0x4E0811A1L) # 60 
-        a = XX(I, a, b, c, d, inp[ 4], S41, 0xF7537E82L) # 61 
-        d = XX(I, d, a, b, c, inp[11], S42, 0xBD3AF235L) # 62 
-        c = XX(I, c, d, a, b, inp[ 2], S43, 0x2AD7D2BBL) # 63 
-        b = XX(I, b, c, d, a, inp[ 9], S44, 0xEB86D391L) # 64 
-
-        A = (A + a) & 0xffffffffL
-        B = (B + b) & 0xffffffffL
-        C = (C + c) & 0xffffffffL
-        D = (D + d) & 0xffffffffL
-
-        self.A, self.B, self.C, self.D = A, B, C, D
-
-
-    # Down from here all methods follow the Python Standard Library
-    # API of the md5 module.
-
-    def update(self, inBuf):
-        """Add to the current message.
-
-        Update the md5 object with the string arg. Repeated calls
-        are equivalent to a single call with the concatenation of all
-        the arguments, i.e. m.update(a); m.update(b) is equivalent
-        to m.update(a+b).
-
-        The hash is immediately calculated for all full blocks. The final
-        calculation is made in digest(). This allows us to keep an
-        intermediate value for the hash, so that we only need to make
-        minimal recalculation if we call update() to add moredata to
-        the hashed string.
-        """
-
-        leninBuf = long(len(inBuf))
-
-        # Compute number of bytes mod 64.
-        index = (self.count[0] >> 3) & 0x3FL
-
-        # Update number of bits.
-        self.count[0] = self.count[0] + (leninBuf << 3)
-        if self.count[0] < (leninBuf << 3):
-            self.count[1] = self.count[1] + 1
-        self.count[1] = self.count[1] + (leninBuf >> 29)
-
-        partLen = 64 - index
-
-        if leninBuf >= partLen:
-            self.input[index:] = list(inBuf[:partLen])
-            self._transform(_bytelist2long(self.input))
-            i = partLen
-            while i + 63 < leninBuf:
-                self._transform(_bytelist2long(list(inBuf[i:i+64])))
-                i = i + 64
-            else:
-                self.input = list(inBuf[i:leninBuf])
-        else:
-            i = 0
-            self.input = self.input + list(inBuf)
-
-
-    def digest(self):
-        """Terminate the message-digest computation and return digest.
-
-        Return the digest of the strings passed to the update()
-        method so far. This is a 16-byte string which may contain
-        non-ASCII characters, including null bytes.
-        """
-
-        A = self.A
-        B = self.B
-        C = self.C
-        D = self.D
-        input = [] + self.input
-        count = [] + self.count
-
-        index = (self.count[0] >> 3) & 0x3fL
-
-        if index < 56:
-            padLen = 56 - index
-        else:
-            padLen = 120 - index
-
-        padding = ['\200'] + ['\000'] * 63
-        self.update(padding[:padLen])
-
-        # Append length (before padding).
-        bits = _bytelist2long(self.input[:56]) + count
-
-        self._transform(bits)
-
-        # Store state in digest.
-        digest = _long2bytes(self.A << 96, 16)[:4] + \
-                 _long2bytes(self.B << 64, 16)[4:8] + \
-                 _long2bytes(self.C << 32, 16)[8:12] + \
-                 _long2bytes(self.D, 16)[12:]
-
-        self.A = A 
-        self.B = B
-        self.C = C
-        self.D = D
-        self.input = input 
-        self.count = count 
-
-        return digest
-
-
-    def hexdigest(self):
-        """Terminate and return digest in HEX form.
-
-        Like digest() except the digest is returned as a string of
-        length 32, containing only hexadecimal digits. This may be
-        used to exchange the value safely in email or other non-
-        binary environments.
-        """
-
-        return ''.join(['%02x' % ord(c) for c in self.digest()])
-
-    def copy(self):
-        """Return a clone object.
-
-        Return a copy ('clone') of the md5 object. This can be used
-        to efficiently compute the digests of strings that share
-        a common initial substring.
-        """
-        if 0: # set this to 1 to make the flow space crash
-            return copy.deepcopy(self)
-        clone = self.__class__()
-        clone.length = self.length
-        clone.count  = [] + self.count[:]
-        clone.input  = [] + self.input
-        clone.A = self.A
-        clone.B = self.B
-        clone.C = self.C
-        clone.D = self.D
-        return clone
-
-
-# ======================================================================
-# Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
-# ======================================================================
-
-digest_size = 16
-
-def new(arg=None):
-    """Return a new md5 object.
-
-    If arg is present, the method call update(arg) is made.
-    """
-
-    md5 = MD5()
-    if arg:
-        md5.update(arg)
-
-    return md5
-
-
-def md5(arg=None):
-    """Same as new().
-
-    For backward compatibility reasons, this is an alternative
-    name for the new() function.
-    """
-
-    return new(arg)

Deleted: /pypy/dist/pypy/appspace/operator.py
==============================================================================
--- /pypy/dist/pypy/appspace/operator.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,185 +0,0 @@
-import __builtin__
-
-def abs(obj,):
-    'abs(a) -- Same as abs(a).'
-    return __builtin__.abs(obj)
-__abs__ = abs
-def add(obj1, obj2):
-    'add(a, b) -- Same as a + b.'
-    return obj1 + obj2
-__add__ = add
-def and_(obj1,obj2):
-    'and_(a, b) -- Same as a & b.'
-    return obj1 & obj2
-__and__ = and_
-def concat(obj1, obj2):
-    'concat(a, b) -- Same as a + b, for a and b sequences.'
-    return obj1 + obj2  # XXX should we be stricter?
-def contains(obj1,obj2):
-    'contains(a, b) -- Same as b in a (note reversed operands).'
-    return obj2 in obj1 
-__contains__ = contains
-def countOf(a,b): 
-    'countOf(a, b) -- Return the number of times b occurs in a.'
-    count = 0
-    for x in a:
-        if x == b:
-            count += 1
-    return count
-def delitem(obj, key):
-    'delitem(a, b) -- Same as del a[b].'
-    del obj[key]
-__delitem__ = delitem
-def delslice(obj, start, end):
-    'delslice(a, b, c) -- Same as del a[b:c].'
-    del obj[start:end]
-__delslice__ = delslice
-def div(a,b):
-    'div(a, b) -- Same as a / b when __future__.division is not in effect.'
-    return a / b
-__div__ = div
-def eq(a, b):
-    'eq(a, b) -- Same as a==b.'
-    return a == b 
-__eq__ = eq
-def floordiv(a, b):
-    'floordiv(a, b) -- Same as a // b.'
-    return a // b 
-__floordiv__ = floordiv
-def ge(a, b):
-    'ge(a, b) -- Same as a>=b.'
-    return a >= b
-__ge__ = ge
-def getitem(a, b):
-    'getitem(a, b) -- Same as a[b].'
-    return a[b] 
-__getitem__ = getitem
-def getslice(a, start, end):
-    'getslice(a, b, c) -- Same as a[b:c].'
-    return a[start:end] 
-__getslice__ = getslice
-def gt(a,b):
-    'gt(a, b) -- Same as a>b.'
-    return a > b
-__gt__ = gt
-def indexOf(a, b):
-    'indexOf(a, b) -- Return the first index of b in a.'
-    index = 0
-    for x in a:
-        if x == b:
-            return index
-        index += 1
-    raise ValueError, 'sequence.index(x): x not in sequence'
-def inv(obj,):
-    'inv(a) -- Same as ~a.'
-    return ~obj 
-__inv__ = inv
-def invert(obj,):
-    'invert(a) -- Same as ~a.'
-    return ~obj 
-__invert__ = invert
-def isCallable(obj,):
-    'isCallable(a) -- Same as callable(a).'
-    return callable(obj) 
-
-# XXX the following is approximative
-def isMappingType(obj,):
-    'isMappingType(a) -- Return True if a has a mapping type, False otherwise.'
-    return hasattr(obj, '__getitem__') and hasattr(obj, 'keys')
-def isNumberType(obj,):
-    'isNumberType(a) -- Return True if a has a numeric type, False otherwise.'
-    return hasattr(obj, '__int__') or hasattr(obj, '__float__') 
-def isSequenceType(obj,):
-    'isSequenceType(a) -- Return True if a has a sequence type, False otherwise.'
-    return hasattr(obj, '__getitem__')
-
-def is_(a, b):
-    'is_(a, b) -- Same as a is b.'
-    return a is b 
-def is_not(a, b):
-    'is_not(a, b) -- Same as a is not b.'
-    return a is not b 
-def le(a, b):
-    'le(a, b) -- Same as a<=b.'
-    return a <= b 
-__le__ = le
-def lshift(a, b):
-    'lshift(a, b) -- Same as a << b.'
-    return a << b 
-__lshift__ = lshift
-def lt(a, b):
-    'lt(a, b) -- Same as a<b.'
-    return a < b 
-__lt__ = lt
-def mod(a, b):
-    'mod(a, b) -- Same as a % b.'
-    return a % b 
-__mod__ = mod
-def mul(a, b):
-    'mul(a, b) -- Same as a * b.'
-    return a * b 
-__mul__ = mul
-def ne(a, b):
-    'ne(a, b) -- Same as a!=b.'
-    return a != b 
-__ne__ = ne
-def neg(obj,):
-    'neg(a) -- Same as -a.'
-    return -obj
-__neg__ = neg
-def not_(obj,):
-    'not_(a) -- Same as not a.'
-    return not obj 
-def or_(a, b):
-    'or_(a, b) -- Same as a | b.'
-    return a | b 
-__or__ = or_
-def pos(obj,):
-    'pos(a) -- Same as +a.'
-    return +obj 
-__pos__ = pos
-def pow(a, b):
-    'pow(a, b) -- Same as a**b.'
-    return a ** b
-__pow__ = pow
-def repeat(obj, num):
-    'repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.'
-    if not isinstance(num, (int, long)):
-        raise TypeError, 'an integer is required'
-    return obj * num   # XXX should we be stricter?
-def rshift(a, b):
-    'rshift(a, b) -- Same as a >> b.'
-    return a >> b 
-__rshift__ = rshift
-def sequenceIncludes(a, b):
-    'sequenceIncludes(a, b) -- Same as b in a (note reversed operands; deprecated).'
-    for x in a:
-        if x == b:
-            return True
-    return False
-def setitem(obj, key, value):
-    'setitem(a, b, c) -- Same as a[b] = c.'
-    obj[key] = value 
-__setitem__ = setitem
-def setslice(a, b, c, d):
-    'setslice(a, b, c, d) -- Same as a[b:c] = d.'
-    a[b:c] = d 
-__setslice__ = setslice
-def sub(a, b):
-    'sub(a, b) -- Same as a - b.'
-    return a - b 
-__sub__ = sub
-
-exec """from __future__ import division
-def truediv(a, b):
-    'truediv(a, b) -- Same as a / b when __future__.division is in effect.'
-    return a / b 
-"""
-__truediv__ = truediv
-def truth(a,):
-    'truth(a) -- Return True if a is true, False otherwise.'
-    return not not a 
-def xor(a, b):
-    'xor(a, b) -- Same as a ^ b.'
-    return a ^ b 
-__xor__ = xor

Deleted: /pypy/dist/pypy/appspace/plexre.py
==============================================================================
--- /pypy/dist/pypy/appspace/plexre.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,15 +0,0 @@
-from StringIO import StringIO
-from Pyrex.Plex import Scanner, Lexicon, Traditional, Errors
-class Pattern:
-    def __init__(self, pattern, flags):
-        compiled = Traditional.re(pattern)
-        lexicon = Lexicon([(compiled, None)])
-        self.lexicon = lexicon
-    def match(self, string):
-        stream = StringIO(string)
-        scanner = Scanner(self.lexicon, stream)
-        try:
-            scanner.read()
-            return 1
-        except Errors.UnrecognizedInput:
-            return 0

Deleted: /pypy/dist/pypy/appspace/pystone.py
==============================================================================
--- /pypy/dist/pypy/appspace/pystone.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,267 +0,0 @@
-#! /usr/bin/env python
-
-"""
-"PYSTONE" Benchmark Program
-
-Version:        Python/1.1 (corresponds to C/1.1 plus 2 Pystone fixes)
-
-Author:         Reinhold P. Weicker,  CACM Vol 27, No 10, 10/84 pg. 1013.
-
-                Translated from ADA to C by Rick Richardson.
-                Every method to preserve ADA-likeness has been used,
-                at the expense of C-ness.
-
-                Translated from C to Python by Guido van Rossum.
-
-Version History:
-
-                Version 1.1 corrects two bugs in version 1.0:
-
-                First, it leaked memory: in Proc1(), NextRecord ends
-                up having a pointer to itself.  I have corrected this
-                by zapping NextRecord.PtrComp at the end of Proc1().
-
-                Second, Proc3() used the operator != to compare a
-                record to None.  This is rather inefficient and not
-                true to the intention of the original benchmark (where
-                a pointer comparison to None is intended; the !=
-                operator attempts to find a method __cmp__ to do value
-                comparison of the record).  Version 1.1 runs 5-10
-                percent faster than version 1.0, so benchmark figures
-                of different versions can't be compared directly.
-
-"""
-
-LOOPS = 50000
-
-from time import clock
-
-__version__ = "1.1"
-
-[Ident1, Ident2, Ident3, Ident4, Ident5] = range(1, 6)
-
-class Record:
-
-    def __init__(self, PtrComp = None, Discr = 0, EnumComp = 0,
-                       IntComp = 0, StringComp = 0):
-        self.PtrComp = PtrComp
-        self.Discr = Discr
-        self.EnumComp = EnumComp
-        self.IntComp = IntComp
-        self.StringComp = StringComp
-
-    def copy(self):
-        return Record(self.PtrComp, self.Discr, self.EnumComp,
-                      self.IntComp, self.StringComp)
-
-TRUE = 1
-FALSE = 0
-
-def main(loops=LOOPS):
-    benchtime, stones = pystones(loops)
-    print "Pystone(%s) time for %d passes = %g" % \
-          (__version__, loops, benchtime)
-    print "This machine benchmarks at %g pystones/second" % stones
-
-
-def pystones(loops=LOOPS):
-    return Proc0(loops)
-
-IntGlob = 0
-BoolGlob = FALSE
-Char1Glob = '\0'
-Char2Glob = '\0'
-Array1Glob = [0]*51
-Array2Glob = map(lambda x: x[:], [Array1Glob]*51)
-PtrGlb = None
-PtrGlbNext = None
-
-def Proc0(loops=LOOPS):
-    global IntGlob
-    global BoolGlob
-    global Char1Glob
-    global Char2Glob
-    global Array1Glob
-    global Array2Glob
-    global PtrGlb
-    global PtrGlbNext
-
-    starttime = clock()
-    for i in range(loops):
-        pass
-    nulltime = clock() - starttime
-
-    PtrGlbNext = Record()
-    PtrGlb = Record()
-    PtrGlb.PtrComp = PtrGlbNext
-    PtrGlb.Discr = Ident1
-    PtrGlb.EnumComp = Ident3
-    PtrGlb.IntComp = 40
-    PtrGlb.StringComp = "DHRYSTONE PROGRAM, SOME STRING"
-    String1Loc = "DHRYSTONE PROGRAM, 1'ST STRING"
-    Array2Glob[8][7] = 10
-
-    starttime = clock()
-
-    for i in range(loops):
-        Proc5()
-        Proc4()
-        IntLoc1 = 2
-        IntLoc2 = 3
-        String2Loc = "DHRYSTONE PROGRAM, 2'ND STRING"
-        EnumLoc = Ident2
-        BoolGlob = not Func2(String1Loc, String2Loc)
-        while IntLoc1 < IntLoc2:
-            IntLoc3 = 5 * IntLoc1 - IntLoc2
-            IntLoc3 = Proc7(IntLoc1, IntLoc2)
-            IntLoc1 = IntLoc1 + 1
-        Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3)
-        PtrGlb = Proc1(PtrGlb)
-        CharIndex = 'A'
-        while CharIndex <= Char2Glob:
-            if EnumLoc == Func1(CharIndex, 'C'):
-                EnumLoc = Proc6(Ident1)
-            CharIndex = chr(ord(CharIndex)+1)
-        IntLoc3 = IntLoc2 * IntLoc1
-        IntLoc2 = IntLoc3 / IntLoc1
-        IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1
-        IntLoc1 = Proc2(IntLoc1)
-
-    benchtime = clock() - starttime - nulltime
-    return benchtime, (loops / benchtime)
-
-def Proc1(PtrParIn):
-    PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
-    PtrParIn.IntComp = 5
-    NextRecord.IntComp = PtrParIn.IntComp
-    NextRecord.PtrComp = PtrParIn.PtrComp
-    NextRecord.PtrComp = Proc3(NextRecord.PtrComp)
-    if NextRecord.Discr == Ident1:
-        NextRecord.IntComp = 6
-        NextRecord.EnumComp = Proc6(PtrParIn.EnumComp)
-        NextRecord.PtrComp = PtrGlb.PtrComp
-        NextRecord.IntComp = Proc7(NextRecord.IntComp, 10)
-    else:
-        PtrParIn = NextRecord.copy()
-    NextRecord.PtrComp = None
-    return PtrParIn
-
-def Proc2(IntParIO):
-    IntLoc = IntParIO + 10
-    while 1:
-        if Char1Glob == 'A':
-            IntLoc = IntLoc - 1
-            IntParIO = IntLoc - IntGlob
-            EnumLoc = Ident1
-        if EnumLoc == Ident1:
-            break
-    return IntParIO
-
-def Proc3(PtrParOut):
-    global IntGlob
-
-    if PtrGlb is not None:
-        PtrParOut = PtrGlb.PtrComp
-    else:
-        IntGlob = 100
-    PtrGlb.IntComp = Proc7(10, IntGlob)
-    return PtrParOut
-
-def Proc4():
-    global Char2Glob
-
-    BoolLoc = Char1Glob == 'A'
-    BoolLoc = BoolLoc or BoolGlob
-    Char2Glob = 'B'
-
-def Proc5():
-    global Char1Glob
-    global BoolGlob
-
-    Char1Glob = 'A'
-    BoolGlob = FALSE
-
-def Proc6(EnumParIn):
-    EnumParOut = EnumParIn
-    if not Func3(EnumParIn):
-        EnumParOut = Ident4
-    if EnumParIn == Ident1:
-        EnumParOut = Ident1
-    elif EnumParIn == Ident2:
-        if IntGlob > 100:
-            EnumParOut = Ident1
-        else:
-            EnumParOut = Ident4
-    elif EnumParIn == Ident3:
-        EnumParOut = Ident2
-    elif EnumParIn == Ident4:
-        pass
-    elif EnumParIn == Ident5:
-        EnumParOut = Ident3
-    return EnumParOut
-
-def Proc7(IntParI1, IntParI2):
-    IntLoc = IntParI1 + 2
-    IntParOut = IntParI2 + IntLoc
-    return IntParOut
-
-def Proc8(Array1Par, Array2Par, IntParI1, IntParI2):
-    global IntGlob
-
-    IntLoc = IntParI1 + 5
-    Array1Par[IntLoc] = IntParI2
-    Array1Par[IntLoc+1] = Array1Par[IntLoc]
-    Array1Par[IntLoc+30] = IntLoc
-    for IntIndex in range(IntLoc, IntLoc+2):
-        Array2Par[IntLoc][IntIndex] = IntLoc
-    Array2Par[IntLoc][IntLoc-1] = Array2Par[IntLoc][IntLoc-1] + 1
-    Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]
-    IntGlob = 5
-
-def Func1(CharPar1, CharPar2):
-    CharLoc1 = CharPar1
-    CharLoc2 = CharLoc1
-    if CharLoc2 != CharPar2:
-        return Ident1
-    else:
-        return Ident2
-
-def Func2(StrParI1, StrParI2):
-    IntLoc = 1
-    while IntLoc <= 1:
-        if Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1:
-            CharLoc = 'A'
-            IntLoc = IntLoc + 1
-    if CharLoc >= 'W' and CharLoc <= 'Z':
-        IntLoc = 7
-    if CharLoc == 'X':
-        return TRUE
-    else:
-        if StrParI1 > StrParI2:
-            IntLoc = IntLoc + 7
-            return TRUE
-        else:
-            return FALSE
-
-def Func3(EnumParIn):
-    EnumLoc = EnumParIn
-    if EnumLoc == Ident3: return TRUE
-    return FALSE
-
-if __name__ == '__main__':
-    import sys
-    def error(msg):
-        print >>sys.stderr, msg,
-        print >>sys.stderr, "usage: %s [number_of_loops]" % sys.argv[0]
-        sys.exit(100)
-    nargs = len(sys.argv) - 1
-    if nargs > 1:
-        error("%d arguments are too many;" % nargs)
-    elif nargs == 1:
-        try: loops = int(sys.argv[1])
-        except ValueError:
-            error("Invalid argument %r;" % sys.argv[1])
-    else:
-        loops = LOOPS
-    main(loops)
-

Deleted: /pypy/dist/pypy/appspace/sha.py
==============================================================================
--- /pypy/dist/pypy/appspace/sha.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,341 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1
-
-"""A sample implementation of SHA-1 in pure Python.
-
-   Framework adapted from Dinu Gherman's MD5 implementation by
-   J. Hallén and L. Creighton. SHA-1 implementation based directly on
-   the text of the NIST standard FIPS PUB 180-1.
-"""
-
-
-__date__    = '2004-11-17'
-__version__ = 0.91 # Modernised by J. Hallén and L. Creighton for Pypy
-
-
-import struct, copy
-
-
-# ======================================================================
-# Bit-Manipulation helpers
-#
-#   _long2bytes() was contributed by Barry Warsaw
-#   and is reused here with tiny modifications.
-# ======================================================================
-
-def _long2bytesBigEndian(n, blocksize=0):
-    """Convert a long integer to a byte string.
-
-    If optional blocksize is given and greater than zero, pad the front
-    of the byte string with binary zeros so that the length is a multiple
-    of blocksize.
-    """
-
-    # After much testing, this algorithm was deemed to be the fastest.
-    s = ''
-    pack = struct.pack
-    while n > 0:
-        s = pack('>I', n & 0xffffffffL) + s
-        n = n >> 32
-
-    # Strip off leading zeros.
-    for i in range(len(s)):
-        if s[i] <> '\000':
-            break
-    else:
-        # Only happens when n == 0.
-        s = '\000'
-        i = 0
-
-    s = s[i:]
-
-    # Add back some pad bytes. This could be done more efficiently
-    # w.r.t. the de-padding being done above, but sigh...
-    if blocksize > 0 and len(s) % blocksize:
-        s = (blocksize - len(s) % blocksize) * '\000' + s
-
-    return s
-
-
-def _bytelist2longBigEndian(list):
-    "Transform a list of characters into a list of longs."
-
-    imax = len(list)/4
-    hl = [0L] * imax
-
-    j = 0
-    i = 0
-    while i < imax:
-        b0 = long(ord(list[j])) << 24
-        b1 = long(ord(list[j+1])) << 16
-        b2 = long(ord(list[j+2])) << 8
-        b3 = long(ord(list[j+3]))
-        hl[i] = b0 | b1 | b2 | b3
-        i = i+1
-        j = j+4
-
-    return hl
-
-
-def _rotateLeft(x, n):
-    "Rotate x (32 bit) left n bits circularly."
-
-    return (x << n) | (x >> (32-n))
-
-
-# ======================================================================
-# The SHA transformation functions
-#
-# ======================================================================
-
-def f0_19(B, C, D):
-    return (B & C) | ((~ B) & D)
-
-def f20_39(B, C, D):
-    return B ^ C ^ D
-
-def f40_59(B, C, D):
-    return (B & C) | (B & D) | (C & D)
-
-def f60_79(B, C, D):
-    return B ^ C ^ D
-
-
-f = [f0_19, f20_39, f40_59, f60_79]
-
-# Constants to be used
-K = [
-    0x5A827999L, # ( 0 <= t <= 19)
-    0x6ED9EBA1L, # (20 <= t <= 39)
-    0x8F1BBCDCL, # (40 <= t <= 59)
-    0xCA62C1D6L  # (60 <= t <= 79)
-    ]
-
-class MD5:
-    "An implementation of the MD5 hash function in pure Python."
-
-    def __init__(self):
-        "Initialisation."
-        
-        # Initial message length in bits(!).
-        self.length = 0L
-        self.count = [0, 0]
-
-        # Initial empty message as a sequence of bytes (8 bit characters).
-        self.input = []
-
-        # Call a separate init function, that can be used repeatedly
-        # to start from scratch on the same object.
-        self.init()
-
-
-    def init(self):
-        "Initialize the message-digest and set all fields to zero."
-
-        self.length = 0L
-        self.input = []
-
-        # Initial 160 bit message digest (5 times 32 bit).
-        self.H0 = 0x67452301L
-        self.H1 = 0xEFCDAB89L
-        self.H2 = 0x98BADCFEL
-        self.H3 = 0x10325476L
-        self.H4 = 0xC3D2E1F0L
-
-    def _transform(self, W):
-
-        for t in range(16, 80):
-            W.append(_rotateLeft(
-                W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1) & 0xffffffffL)
-
-        A = self.H0
-        B = self.H1
-        C = self.H2
-        D = self.H3
-        E = self.H4
-
-        """
-        This loop was unrolled to gain about 10% in speed
-        for t in range(0, 80):
-            TEMP = _rotateLeft(A, 5) + f[t/20] + E + W[t] + K[t/20]
-            E = D
-            D = C
-            C = _rotateLeft(B, 30) & 0xffffffffL
-            B = A
-            A = TEMP & 0xffffffffL
-        """
-
-        for t in range(0, 20):
-            TEMP = _rotateLeft(A, 5) + ((B & C) | ((~ B) & D)) + E + W[t] + K[0]
-            E = D
-            D = C
-            C = _rotateLeft(B, 30) & 0xffffffffL
-            B = A
-            A = TEMP & 0xffffffffL
-
-        for t in range(20, 40):
-            TEMP = _rotateLeft(A, 5) + (B ^ C ^ D) + E + W[t] + K[1]
-            E = D
-            D = C
-            C = _rotateLeft(B, 30) & 0xffffffffL
-            B = A
-            A = TEMP & 0xffffffffL
-
-        for t in range(40, 60):
-            TEMP = _rotateLeft(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]
-            E = D
-            D = C
-            C = _rotateLeft(B, 30) & 0xffffffffL
-            B = A
-            A = TEMP & 0xffffffffL
-
-        for t in range(60, 80):
-            TEMP = _rotateLeft(A, 5) + (B ^ C ^ D)  + E + W[t] + K[3]
-            E = D
-            D = C
-            C = _rotateLeft(B, 30) & 0xffffffffL
-            B = A
-            A = TEMP & 0xffffffffL
-
-
-        self.H0 = (self.H0 + A) & 0xffffffffL
-        self.H1 = (self.H1 + B) & 0xffffffffL
-        self.H2 = (self.H2 + C) & 0xffffffffL
-        self.H3 = (self.H3 + D) & 0xffffffffL
-        self.H4 = (self.H4 + E) & 0xffffffffL
-    
-
-    # Down from here all methods follow the Python Standard Library
-    # API of the sha module.
-
-    def update(self, inBuf):
-        """Add to the current message.
-
-        Update the md5 object with the string arg. Repeated calls
-        are equivalent to a single call with the concatenation of all
-        the arguments, i.e. m.update(a); m.update(b) is equivalent
-        to m.update(a+b).
-
-        The hash is immediately calculated for all full blocks. The final
-        calculation is made in digest(). It will calculate 1-2 blocks,
-        depending on how much padding we have to add. This allows us to
-        keep an intermediate value for the hash, so that we only need to
-        make minimal recalculation if we call update() to add more data
-        to the hashed string.
-        """
-
-        leninBuf = long(len(inBuf))
-
-        # Compute number of bytes mod 64.
-        index = (self.count[1] >> 3) & 0x3FL
-
-        # Update number of bits.
-        self.count[1] = self.count[1] + (leninBuf << 3)
-        if self.count[1] < (leninBuf << 3):
-            self.count[0] = self.count[0] + 1
-        self.count[0] = self.count[0] + (leninBuf >> 29)
-
-        partLen = 64 - index
-
-        if leninBuf >= partLen:
-            self.input[index:] = list(inBuf[:partLen])
-            self._transform(_bytelist2longBigEndian(self.input))
-            i = partLen
-            while i + 63 < leninBuf:
-                self._transform(_bytelist2longBigEndian(list(inBuf[i:i+64])))
-                i = i + 64
-            else:
-                self.input = list(inBuf[i:leninBuf])
-        else:
-            i = 0
-            self.input = self.input + list(inBuf)
-
-
-    def digest(self):
-        """Terminate the message-digest computation and return digest.
-
-        Return the digest of the strings passed to the update()
-        method so far. This is a 16-byte string which may contain
-        non-ASCII characters, including null bytes.
-        """
-
-        H0 = self.H0
-        H1 = self.H1
-        H2 = self.H2
-        H3 = self.H3
-        H4 = self.H4
-        input = [] + self.input
-        count = [] + self.count
-
-        index = (self.count[1] >> 3) & 0x3fL
-
-        if index < 56:
-            padLen = 56 - index
-        else:
-            padLen = 120 - index
-
-        padding = ['\200'] + ['\000'] * 63
-        self.update(padding[:padLen])
-
-        # Append length (before padding).
-        bits = _bytelist2longBigEndian(self.input[:56]) + count
-
-        self._transform(bits)
-
-        # Store state in digest.
-        digest = _long2bytesBigEndian(self.H0, 4) + \
-                 _long2bytesBigEndian(self.H1, 4) + \
-                 _long2bytesBigEndian(self.H2, 4) + \
-                 _long2bytesBigEndian(self.H3, 4) + \
-                 _long2bytesBigEndian(self.H4, 4)
-
-        self.H0 = H0 
-        self.H1 = H1 
-        self.H2 = H2
-        self.H3 = H3
-        self.H4 = H4
-        self.input = input 
-        self.count = count 
-
-        return digest
-
-
-    def hexdigest(self):
-        """Terminate and return digest in HEX form.
-
-        Like digest() except the digest is returned as a string of
-        length 32, containing only hexadecimal digits. This may be
-        used to exchange the value safely in email or other non-
-        binary environments.
-        """
-        return ''.join(['%02x' % ord(c) for c in self.digest()])
-
-    def copy(self):
-        """Return a clone object.
-
-        Return a copy ('clone') of the md5 object. This can be used
-        to efficiently compute the digests of strings that share
-        a common initial substring.
-        """
-
-        return copy.deepcopy(self)
-
-
-# ======================================================================
-# Mimic Python top-level functions from standard library API
-# for consistency with the md5 module of the standard library.
-# ======================================================================
-
-digest_size = 16
-
-def new(arg=None):
-    """Return a new md5 object.
-
-    If arg is present, the method call update(arg) is made.
-    """
-
-    md5 = MD5()
-    if arg:
-        md5.update(arg)
-
-    return md5

Deleted: /pypy/dist/pypy/appspace/sio.py
==============================================================================
--- /pypy/dist/pypy/appspace/sio.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,913 +0,0 @@
-"""New standard I/O library.
-
-This code is still very young and experimental!
-
-There are fairly complete unit tests in test_sio.py.
-
-The design is simple:
-
-- A raw stream supports read(n), write(s), seek(offset, whence=0) and
-  tell().  This is generally unbuffered.  Raw streams may support
-  Unicode.
-
-- A basis stream provides the raw stream API and builds on a much more
-  low-level API, e.g. the os, mmap or socket modules.
-
-- A filtering stream is raw stream built on top of another raw stream.
-  There are filtering streams for universal newline translation and
-  for unicode translation.
-
-- A buffering stream supports the full classic Python I/O API:
-  read(n=-1), readline(), readlines(sizehint=0), tell(), seek(offset,
-  whence=0), write(s), writelines(lst), as well as __iter__() and
-  next().  (There's also readall() but that's a synonym for read()
-  without arguments.)  This is a superset of the raw stream API.  I
-  haven't thought about fileno() and isatty() yet, nor about
-  truncate() or the various attributes like name and mode.  Also,
-  close() is not implemented right.  We really need only one buffering
-  stream implementation, which is a filtering stream.
-
-You typically take a basis stream, place zero or more filtering
-streams on top of it, and then top it off with a buffering stream.
-
-"""
-
-import os
-
-class Stream(object):
-    "All streams except the base ones need to inherit from this class."
-    base = None
-    def __getattr__(self, name):
-        """
-        Delegate all other methods to the underlying file object.
-        """
-        return getattr(self.base, name)
-
-class BufferingInputStream(Stream):
-
-    """Standard buffering input stream.
-
-    This is typically the top of the stack.
-    """
-
-    bigsize = 2**19 # Half a Meg
-    bufsize = 2**13 # 8 K
-
-    def __init__(self, base, bufsize=None):
-        self.base = base
-        self.do_read = getattr(base, "read", None)
-                       # function to fill buffer some more
-        self.do_tell = getattr(base, "tell", None)
-                       # None, or return a byte offset 
-        self.do_seek = getattr(base, "seek", None)
-                       # None, or seek to a byte offset
-        self.close = base.close
-
-        if bufsize is None:     # Get default from the class
-            bufsize = self.bufsize
-        self.bufsize = bufsize  # buffer size (hint only)
-        self.lines = []         # ready-made lines (sans "\n")
-        self.buf = ""           # raw data (may contain "\n")
-        # Invariant: readahead == "\n".join(self.lines + [self.buf])
-        # self.lines contains no "\n"
-        # self.buf may contain "\n"
-
-    def tell(self):
-        bytes = self.do_tell()  # This may fail
-        offset = len(self.buf)
-        for line in self.lines:
-            offset += len(line) + 1
-        assert bytes >= offset, (locals(), self.__dict__)
-        return bytes - offset
-
-    def seek(self, offset, whence=0):
-        # This may fail on the do_seek() or do_tell() call.
-        # But it won't call either on a relative forward seek.
-        # Nor on a seek to the very end.
-        if whence == 0 or (whence == 2 and self.do_seek is not None):
-            self.do_seek(offset, whence)
-            self.lines = []
-            self.buf = ""
-            return
-        if whence == 2:
-            # Skip relative to EOF by reading and saving only just as
-            # much as needed
-            assert self.do_seek is None
-            data = "\n".join(self.lines + [self.buf])
-            total = len(data)
-            buffers = [data]
-            self.lines = []
-            self.buf = ""
-            while 1:
-                data = self.do_read(self.bufsize)
-                if not data:
-                    break
-                buffers.append(data)
-                total += len(data)
-                while buffers and total >= len(buffers[0]) - offset:
-                    total -= len(buffers[0])
-                    del buffers[0]
-            cutoff = total + offset
-            if cutoff < 0:
-                raise TypeError, "cannot seek back"
-            if buffers:
-                buffers[0] = buffers[0][cutoff:]
-            self.buf = "".join(buffers)
-            self.lines = []
-            return
-        if whence == 1:
-            if offset < 0:
-                self.do_seek(self.tell() + offset, 0)
-                self.lines = []
-                self.buf = ""
-                return
-            while self.lines:
-                line = self.lines[0]
-                if offset <= len(line):
-                    self.lines[0] = line[offset:]
-                    return
-                offset -= len(self.lines[0]) - 1
-                del self.lines[0]
-            assert not self.lines
-            if offset <= len(self.buf):
-                self.buf = self.buf[offset:]
-                return
-            offset -= len(self.buf)
-            self.buf = ""
-            if self.do_seek is None:
-                self.read(offset)
-            else:
-                self.do_seek(offset, 1)
-            return
-        raise ValueError, "whence should be 0, 1 or 2"
-
-    def readall(self):
-        self.lines.append(self.buf)
-        more = ["\n".join(self.lines)]
-        self.lines = []
-        self.buf = ""
-        bufsize = self.bufsize
-        while 1:
-            data = self.do_read(bufsize)
-            if not data:
-                break
-            more.append(data)
-            bufsize = max(bufsize*2, self.bigsize)
-        return "".join(more)
-
-    def read(self, n=-1):
-        if n < 0:
-            return self.readall()
-
-        if self.lines:
-            # See if this can be satisfied from self.lines[0]
-            line = self.lines[0]
-            if len(line) >= n:
-                self.lines[0] = line[n:]
-                return line[:n]
-
-            # See if this can be satisfied *without exhausting* self.lines
-            k = 0
-            i = 0
-            for line in self.lines:
-                k += len(line)
-                if k >= n:
-                    lines = self.lines[:i]
-                    data = self.lines[i]
-                    cutoff = len(data) - (k-n)
-                    lines.append(data[:cutoff])
-                    self.lines[:i+1] = [data[cutoff:]]
-                    return "\n".join(lines)
-                k += 1
-                i += 1
-
-            # See if this can be satisfied from self.lines plus self.buf
-            if k + len(self.buf) >= n:
-                lines = self.lines
-                self.lines = []
-                cutoff = n - k
-                lines.append(self.buf[:cutoff])
-                self.buf = self.buf[cutoff:]
-                return "\n".join(lines)
-
-        else:
-            # See if this can be satisfied from self.buf
-            data = self.buf
-            k = len(data)
-            if k >= n:
-                cutoff = len(data) - (k-n)
-                self.buf = data[cutoff:]
-                return data[:cutoff]
-
-        lines = self.lines
-        self.lines = []
-        lines.append(self.buf)
-        self.buf = ""
-        data = "\n".join(lines)
-        more = [data]
-        k = len(data)
-        while k < n:
-            data = self.do_read(max(self.bufsize, n-k))
-            k += len(data)
-            more.append(data)
-            if not data:
-                break
-        cutoff = len(data) - (k-n)
-        self.buf = data[cutoff:]
-        more[-1] = data[:cutoff]
-        return "".join(more)
-
-    def __iter__(self):
-        return self
-
-    def next(self):
-        if self.lines:
-            return self.lines.pop(0) + "\n"
-
-        # This block is needed because read() can leave self.buf
-        # containing newlines
-        self.lines = self.buf.split("\n")
-        self.buf = self.lines.pop()
-        if self.lines:
-            return self.lines.pop(0) + "\n"
-
-        buf = self.buf and [self.buf] or []
-        while 1:
-            self.buf = self.do_read(self.bufsize)
-            self.lines = self.buf.split("\n")
-            self.buf = self.lines.pop()
-            if self.lines:
-                buf.append(self.lines.pop(0))
-                buf.append("\n")
-                break
-            if not self.buf:
-                break
-            buf.append(self.buf)
-
-        line = "".join(buf)
-        if not line:
-            raise StopIteration
-        return line
-
-    def readline(self):
-        try:
-            return self.next()
-        except StopIteration:
-            return ""
-
-    def readlines(self, sizehint=0):
-        return list(self)
-
-class BufferingOutputStream(Stream):
-
-    """Standard buffering output stream.
-
-    This is typically the top of the stack.
-    """
-
-    bigsize = 2**19 # Half a Meg
-    bufsize = 2**13 # 8 K
-
-    def __init__(self, base, bufsize=None):
-        self.base = base
-        self.do_write = base.write # Flush buffer
-        self.do_tell = base.tell
-             # Return a byte offset; has to exist or this __init__() will fail
-        self.do_seek = getattr(base, "seek", None)
-                       # None, or seek to a byte offset
-        self.do_close = base.close # Close file
-        self.do_truncate = base.truncate # Truncate file
-
-        if bufsize is None:     # Get default from the class
-            bufsize = self.bufsize
-        self.bufsize = bufsize  # buffer size (hint only)
-        self.buf = ""
-        self.tell()
-        
-    def tell(self):
-        assert self.do_tell is not None
-        if not hasattr(self, 'pos'):
-            self.pos = self.do_tell()
-
-        return self.pos
-            
-    def seek(self, offset, whence=0):
-        self.flush()
-        self.do_seek(offset, whence)
-        self.pos = self.do_tell()
-
-    def flush(self):
-        self.do_write(self.buf)
-        self.buf = ''
-        self.base.flush()
-     
-    def write(self, data):
-        buflen = len(self.buf)
-        datalen = len(data)
-        if  datalen + buflen < self.bufsize:
-            self.buf += data
-            self.pos += datalen
-        else:
-            self.buf += data[:self.bufsize-buflen]
-            self.pos += self.bufsize-buflen
-            self.do_write(self.buf)
-            self.buf = ''
-            self.write(data[self.bufsize-buflen:])
-
-    def writelines(self, sequence):
-        for s in sequence:
-            self.write(s)
-            
-    def close(self):
-        if (self.buf):
-            self.do_write(self.buf)
-            self.buf = ''
-        self.do_close()
-
-    def truncate(self, size=None):
-        self.flush()
-        self.do_truncate(size)
-
-class LineBufferingOutputStream(BufferingOutputStream):
-
-    """Line buffering output stream.
-
-    This is typically the top of the stack.
-    """
-
-    def __init__(self, base, bufsize=None):
-        self.base = base
-        self.do_write = base.write # Flush buffer
-        self.do_tell = base.tell
-             # Return a byte offset; has to exist or this __init__() will fail
-        self.do_seek = getattr(base, "seek", None)
-                       # None, or seek to a byte offset
-        self.do_close = base.close # Close file
-        self.do_truncate = base.truncate # Truncate file
-
-        self.linesep = os.linesep
-        self.buf = ""           # raw data (may contain "\n")
-        self.tell()
-        
-    def write(self, data):
-        all_lines = data.split(self.linesep)
-        full_lines = all_lines[:-1]
-        for line in full_lines:
-            line += self.linesep
-            buflen = len(self.buf)
-            linelen = len(line)
-            if  linelen + buflen < self.bufsize:
-                self.buf += line
-                self.pos += linelen
-                self.do_write(self.buf)
-                self.buf = ''
-            else:
-                self.buf += line[:self.bufsize-buflen]
-                self.pos += self.bufsize-buflen
-                self.do_write(self.buf)
-                self.buf = ''
-                self.write(line[self.bufsize-buflen:])
-
-        # The last part of the split data never has a terminating linesep.
-        # If the data has a terminating linesep, the last element is an
-        # empty string.
-
-        line = all_lines[-1]
-        buflen = len(self.buf)
-        linelen = len(line)
-        if  linelen + buflen < self.bufsize:
-            self.buf += line
-            self.pos += linelen
-        else:
-            self.buf += line[:self.bufsize-buflen]
-            self.pos += self.bufsize-buflen
-            self.do_write(self.buf)
-            self.buf = ''
-            self.write(line[self.bufsize-buflen:])
-
-    def flush(self):
-        if self.buf:
-            self.do_write(self.buf)
-            self.buf = ''
-        self.base.flush()
-        
-        
-class BufferingInputOutputStream(Stream):
-    """To handle buffered input and output at the same time, we are
-       switching back and forth between using BuffereingInputStream
-       and BufferingOutputStream as reads and writes are done.
-       A more optimal solution would be to read and write on the same
-       buffer, but it would take a fair bit of time to implement.
-    """
-
-    def __init__(self, base, bufsize=None):
-        self.base = base
-        self.bufsize = bufsize
-        self.reader = None
-        self.writer = None
-
-    def read(self, n=-1):
-        if not self.reader:
-            if self.writer:
-                self.writer.flush()
-                self.writer = None
-            self.reader = BufferingInputStream(self.base, self.bufsize)
-        return self.reader.read(n)
-
-    def write(self, data):
-        if not self.writer:
-            if self.reader:
-                # Make sure the underlying file has the correct current
-                # position
-                self.reader.seek(self.reader.tell())
-                self.reader = None
-            self.writer = BufferingOutputStream(self.base, self.bufsize)
-        return self.writer.write(data)
-
-    def truncate(self, size=None):
-        if not self.writer:
-            if self.reader:
-                # Make sure the underlying file has the correct current
-                # position
-                self.reader.seek(self.reader.tell())
-                self.reader = None
-            self.writer = BufferingOutputStream(self.base, self.bufsize)
-        return self.writer.truncate(size)
-
-    def __getattr__(self, name):
-        """
-        Delegate all other methods to the underlying file object.
-        """
-        if not self.reader and not self.writer:
-            self.reader = BufferingInputStream(self.base, self.bufsize)
-
-        if self.reader:
-            return getattr(self.reader, name)
-        
-        return getattr(self.writer, name)
-
-class CRLFFilter(Stream):
-
-    """Filtering stream for universal newlines.
-
-    TextInputFilter is more general, but this is faster when you don't
-    need tell/seek.
-    """
-
-    def __init__(self, base):
-        self.base = base
-        self.do_read = base.read
-        self.atcr = False
-        self.close = base.close
-
-    def read(self, n=-1):
-        data = self.do_read(n)
-        if self.atcr:
-            if data.startswith("\n"):
-                data = data[1:] # Very rare case: in the middle of "\r\n"
-            self.atcr = False
-        if "\r" in data:
-            self.atcr = data.endswith("\r")     # Test this before removing \r
-            data = data.replace("\r\n", "\n")   # Catch \r\n this first
-            data = data.replace("\r", "\n")     # Remaining \r are standalone
-        return data
-
-class MMapFile(object):
-
-    """Standard I/O basis stream using mmap."""
-
-    def __init__(self, filename, mode="r"):
-        import mmap
-        self.filename = filename
-        self.mode = mode
-        if mode == "r":
-            flag = os.O_RDONLY
-            self.access = mmap.ACCESS_READ
-        else:
-            if mode == "w":
-                flag = os.O_RDWR | os.O_CREAT
-            elif mode == "a":
-                flag = os.O_RDWR
-            else:
-                raise ValueError, "mode should be 'r', 'w' or 'a'"
-            self.access = mmap.ACCESS_WRITE
-        if hasattr(os, "O_BINARY"):
-            flag |= os.O_BINARY
-        self.fd = os.open(filename, flag)
-        size = os.fstat(self.fd).st_size
-        self.mm = mmap.mmap(self.fd, size, access=self.access)
-        self.pos = 0
-
-    def __del__(self):
-        self.close()
-
-    mm = fd = None
-
-    def close(self):
-        if self.mm is not None:
-            self.mm.close()
-            self.mm = None
-        if self.fd is not None:
-            os.close(self.fd)
-            self.fd = None
-
-    def tell(self):
-        return self.pos
-
-    def seek(self, offset, whence=0):
-        if whence == 0:
-            self.pos = max(0, offset)
-        elif whence == 1:
-            self.pos = max(0, self.pos + offset)
-        elif whence == 2:
-            self.pos = max(0, self.mm.size() + offset)
-        else:
-            raise ValueError, "seek(): whence must be 0, 1 or 2"
-
-    def readall(self):
-        return self.read()
-
-    def read(self, n=-1):
-        import mmap
-        if n >= 0:
-            aim = self.pos + n
-        else:
-            aim = self.mm.size() # Actual file size, may be more than mapped
-            n = aim - self.pos
-        data = self.mm[self.pos:aim]
-        if len(data) < n:
-            del data
-            # File grew since opened; remap to get the new data
-            size = os.fstat(self.fd).st_size
-            self.mm = mmap.mmap(self.fd, size, access=self.access)
-            data = self.mm[self.pos:aim]
-        self.pos += len(data)
-        return data
-
-    def __iter__(self):
-        return self
-
-    def readline(self):
-        import mmap
-        hit = self.mm.find("\n", self.pos) + 1
-        if hit:
-            data = self.mm[self.pos:hit]
-            self.pos = hit
-            return data
-        # Remap the file just in case
-        size = os.fstat(self.fd).st_size
-        self.mm = mmap.mmap(self.fd, size, access=self.access)
-        hit = self.mm.find("\n", self.pos) + 1
-        if hit:
-            # Got a whole line after remapping
-            data = self.mm[self.pos:hit]
-            self.pos = hit
-            return data
-        # Read whatever we've got -- may be empty
-        data = self.mm[self.pos:self.mm.size()]
-        self.pos += len(data)
-        return data
-
-    def next(self):
-        import mmap
-        hit = self.mm.find("\n", self.pos) + 1
-        if hit:
-            data = self.mm[self.pos:hit]
-            self.pos = hit
-            return data
-        # Remap the file just in case
-        size = os.fstat(self.fd).st_size
-        self.mm = mmap.mmap(self.fd, size, access=self.access)
-        hit = self.mm.find("\n", self.pos) + 1
-        if hit:
-            # Got a whole line after remapping
-            data = self.mm[self.pos:hit]
-            self.pos = hit
-            return data
-        # Read whatever we've got -- may be empty
-        data = self.mm[self.pos:self.mm.size()]
-        if not data:
-            raise StopIteration
-        self.pos += len(data)
-        return data
-
-    def readlines(self, sizehint=0):
-        return list(iter(self.readline, ""))
-
-    def write(self, data):
-        end = self.pos + len(data)
-        try:
-            self.mm[self.pos:end]  = data
-            # This can raise IndexError on Windows, ValueError on Unix
-        except (IndexError, ValueError):
-            # XXX On Unix, this resize() call doesn't work
-            self.mm.resize(end)
-            self.mm[self.pos:end]  = data
-        self.pos = end
-
-    def writelines(self, lines):
-        filter(self.write, lines)
-
-    def flush(self):
-        if self.mm is None:
-            raise ValueError('I/O operation on closed file')
-        self.mm.flush()
-
-class DiskFile(object):
-
-    """Standard I/O basis stream using os.open/close/read/write/lseek"""
-
-    # This is not quite correct, since more letters are allowed after
-    # these. However, the following are the only starting strings allowed
-    # in the mode parameter.
-    modes = {
-        'r'  : os.O_RDONLY,
-        'rb' : os.O_RDONLY,
-        'rU' : os.O_RDONLY,
-        'U'  : os.O_RDONLY,
-        'w'  : os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
-        'wb' : os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
-        'a'  : os.O_WRONLY | os.O_CREAT | os.O_EXCL,
-        'ab' : os.O_WRONLY | os.O_CREAT | os.O_EXCL,
-        'r+' : os.O_RDWR,
-        'rb+': os.O_RDWR,
-        'r+b': os.O_RDWR,
-        'w+' : os.O_RDWR | os.O_CREAT | os.O_TRUNC,
-        'wb+': os.O_RDWR | os.O_CREAT | os.O_TRUNC,
-        'w+b': os.O_RDWR | os.O_CREAT | os.O_TRUNC,
-        'a+' : os.O_RDWR | os.O_CREAT | os.O_EXCL,
-        'ab+': os.O_RDWR | os.O_CREAT | os.O_EXCL,
-        'a+b': os.O_RDWR | os.O_CREAT | os.O_EXCL,
-        }
-    def __init__(self, filename, mode="r"):
-        self.filename = filename
-        self.mode = mode
-        try:
-            flag = DiskFile.modes[mode]
-        except KeyError:
-            raise ValueError, "mode should be 'r', 'r+', 'w', 'w+' or 'a+'"
-
-        O_BINARY = getattr(os, "O_BINARY", 0)
-        flag |= O_BINARY
-        try:
-            self.fd = os.open(filename, flag)
-        except OSError:
-            # Opening in mode 'a' or 'a+' and file already exists
-            flag = flag & (os.O_RDWR | O_BINARY)
-            self.fd = os.open(filename, flag)
-        if mode[0] == 'a':
-            os.lseek(self.fd, 0, 2) # Move to end of file
-
-    def seek(self, offset, whence=0):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        os.lseek(self.fd, offset, whence)
-
-    def tell(self):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        return os.lseek(self.fd, 0, 1)
-
-    def read(self, n=-1):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        if n >= 0:
-            return os.read(self.fd, n)
-        data = []
-        while 1:
-            moreData = os.read(self.fd, 2**20)
-            if len(moreData) == 0:
-                return ''.join(data)
-            data.append(moreData)
-
-    def write(self, data):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        while data:
-            n = os.write(self.fd, data)
-            data = data[n:]
-
-    def close(self):
-        fd = self.fd
-        if fd is not None:
-            self.fd = None
-            os.close(fd)
-
-    def truncate(self, size=None):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        if size is None:
-            size = self.tell()
-        try:
-            os.ftruncate(self.fd, size)
-        except AttributeError:
-            raise NotImplementedError
-        
-    def isatty(self):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        try:
-            return os.isatty(self.fd)
-        except AttributeError:
-            raise NotImplementedError
-        
-    def fileno(self):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        return self.fd
-
-    def flush(self):
-        if self.fd is None:
-            raise ValueError('I/O operation on closed file')
-        
-    def __del__(self):
-        try:
-            self.close()
-        except:
-            pass
-
-class TextInputFilter(Stream):
-
-    """Filtering input stream for universal newline translation."""
-
-    def __init__(self, base):
-        self.base = base   # must implement read, may implement tell, seek
-        self.atcr = False  # Set when last char read was \r
-        self.buf = ""      # Optional one-character read-ahead buffer
-        self.close = base.close
-        self.CR = False
-        self.NL = False
-        self.CRLF = False
-        
-    def __getattr__(self, name):
-        if name == 'newlines':
-            foundchars = self.CR * 1 + self.NL * 2 + self.CRLF * 4
-            if  not foundchars:
-                return None
-            if foundchars in [1, 2, 4]:
-                if self.CR:
-                    return '\r'
-                elif self.NL:
-                    return '\n'
-                else:
-                    return '\r\n'
-            else:
-                result = []
-                if self.CR:
-                    result.append('\r')
-                if self.NL:
-                    result.append('\n')
-                if self.CRLF:
-                    result.append('\r\n')
-                return tuple(result)
-            
-    def read(self, n):
-        """Read up to n bytes."""
-        if n <= 0:
-            return ""
-        if self.buf:
-            assert not self.atcr
-            data = self.buf
-            self.buf = ""
-            return data
-        data = self.base.read(n)
-
-        # The following whole ugly mess is because we need to keep track of
-        # exactly which line separators we have seen for self.newlines,
-        # grumble, grumble.  This has an interesting corner-case.
-        #
-        # Consider a file consisting of exactly one line ending with '\r'.
-        # The first time you read(), you will not know whether it is a
-        # CR separator or half of a CRLF separator.  Neither will be marked
-        # as seen, since you are waiting for your next read to determine
-        # what you have seen.  But there's no more to read ...
-                        
-        if self.atcr:
-            if data.startswith("\n"):
-                data = data[1:]
-                self.CRLF = True
-                if not data:
-                    data = self.base.read(n)
-            else:
-                self.CR = True
-            self.atcr = False
-            
-        for i in range(len(data)):
-            if data[i] == '\n':
-                if i > 0 and data[i-1] == '\r':
-                    self.CRLF = True
-                else:
-                    self.NL = True
-            elif data[i] == '\r':
-                if i < len(data)-1 and data[i+1] != '\n':
-                    self.CR = True
-                    
-        if "\r" in data:
-            self.atcr = data.endswith("\r")
-            data = data.replace("\r\n", "\n").replace("\r", "\n")
-            
-        return data
-
-    def seek(self, offset, whence=0):
-        """Seeks based on knowledge that does not come from a tell()
-           may go to the wrong place, since the number of
-           characters seen may not match the number of characters
-           that are actually in the file (where \r\n is the
-           line separator). Arithmetics on the result
-           of a tell() that moves beyond a newline character may in the
-           same way give the wrong result.
-        """
-        self.base.seek(offset, whence)
-        self.atcr = False
-        self.buf = ""
-
-    def tell(self):
-        pos = self.base.tell()
-        if self.atcr:
-            # Must read the next byte to see if it's \n,
-            # because then we must report the next position.
-            assert not self.buf 
-            self.buf = self.base.read(1)
-            pos += 1
-            self.atcr = False
-            if self.buf == "\n":
-                self.buf = ""
-        return pos - len(self.buf)
-
-class TextOutputFilter(Stream):
-
-    """Filtering output stream for universal newline translation."""
-
-    def __init__(self, base, linesep=os.linesep):
-        assert linesep in ["\n", "\r\n", "\r"]
-        self.base = base    # must implement write, may implement seek, tell
-        self.linesep = linesep
-        self.close = base.close
-
-    def write(self, data):
-        if self.linesep is not "\n" and "\n" in data:
-            data = data.replace("\n", self.linesep)
-        self.base.write(data)
-
-    def seek(self, offset, whence=0):
-        self.base.seek(offset, whence)
-
-    def tell(self):
-        return self.base.tell()
-
-class DecodingInputFilter(Stream):
-
-    """Filtering input stream that decodes an encoded file."""
-
-    def __init__(self, base, encoding="utf8", errors="strict"):
-        self.base = base
-        self.encoding = encoding
-        self.errors = errors
-        self.tell = base.tell
-        self.seek = base.seek
-        self.close = base.close
-
-    def read(self, n):
-        """Read *approximately* n bytes, then decode them.
-
-        Under extreme circumstances,
-        the return length could be longer than n!
-
-        Always return a unicode string.
-
-        This does *not* translate newlines;
-        you can stack TextInputFilter.
-        """
-        data = self.base.read(n)
-        try:
-            return data.decode(self.encoding, self.errors)
-        except ValueError:
-            # XXX Sigh.  decode() doesn't handle incomplete strings well.
-            # Use the retry strategy from codecs.StreamReader.
-            for i in range(9):
-                more = self.base.read(1)
-                if not more:
-                    raise
-                data += more
-                try:
-                    return data.decode(self.encoding, self.errors)
-                except ValueError:
-                    pass
-            raise
-
-class EncodingOutputFilter(Stream):
-
-    """Filtering output stream that writes to an encoded file."""
-
-    def __init__(self, base, encoding="utf8", errors="strict"):
-        self.base = base
-        self.encoding = encoding
-        self.errors = errors
-        self.tell = base.tell
-        self.seek = base.seek
-        self.close = base.close
-
-    def write(self, chars):
-        if isinstance(chars, str):
-            chars = unicode(chars) # Fail if it's not ASCII
-        self.base.write(chars.encode(self.encoding, self.errors))

Deleted: /pypy/dist/pypy/appspace/sre_parse.py
==============================================================================
--- /pypy/dist/pypy/appspace/sre_parse.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,782 +0,0 @@
-#
-# Secret Labs' Regular Expression Engine
-#
-# convert re-style regular expression to sre pattern
-#
-# Copyright (c) 1998-2001 by Secret Labs AB.  All rights reserved.
-#
-# See the sre.py file for information on usage and redistribution.
-#
-
-"""Internal support module for sre"""
-
-# XXX: show string offset and offending character for all errors
-
-import sys
-
-from sre_constants import *
-
-SPECIAL_CHARS = ".\\[{()*+?^$|"
-REPEAT_CHARS = "*+?{"
-
-DIGITS = tuple("0123456789")
-
-OCTDIGITS = tuple("01234567")
-HEXDIGITS = tuple("0123456789abcdefABCDEF")
-
-WHITESPACE = tuple(" \t\n\r\v\f")
-
-ESCAPES = {
-    r"\a": (LITERAL, ord("\a")),
-    r"\b": (LITERAL, ord("\b")),
-    r"\f": (LITERAL, ord("\f")),
-    r"\n": (LITERAL, ord("\n")),
-    r"\r": (LITERAL, ord("\r")),
-    r"\t": (LITERAL, ord("\t")),
-    r"\v": (LITERAL, ord("\v")),
-    r"\\": (LITERAL, ord("\\"))
-}
-
-CATEGORIES = {
-    r"\A": (AT, AT_BEGINNING_STRING), # start of string
-    r"\b": (AT, AT_BOUNDARY),
-    r"\B": (AT, AT_NON_BOUNDARY),
-    r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]),
-    r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]),
-    r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]),
-    r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]),
-    r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]),
-    r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]),
-    r"\Z": (AT, AT_END_STRING), # end of string
-}
-
-FLAGS = {
-    # standard flags
-    "i": SRE_FLAG_IGNORECASE,
-    "L": SRE_FLAG_LOCALE,
-    "m": SRE_FLAG_MULTILINE,
-    "s": SRE_FLAG_DOTALL,
-    "x": SRE_FLAG_VERBOSE,
-    # extensions
-    "t": SRE_FLAG_TEMPLATE,
-    "u": SRE_FLAG_UNICODE,
-}
-
-class Pattern:
-    # master pattern object.  keeps track of global attributes
-    def __init__(self):
-        self.flags = 0
-        self.open = []
-        self.groups = 1
-        self.groupdict = {}
-    def opengroup(self, name=None):
-        gid = self.groups
-        self.groups = gid + 1
-        if name is not None:
-            ogid = self.groupdict.get(name, None)
-            if ogid is not None:
-                raise error, ("redefinition of group name %s as group %d; "
-                              "was group %d" % (repr(name), gid,  ogid))
-            self.groupdict[name] = gid
-        self.open.append(gid)
-        return gid
-    def closegroup(self, gid):
-        self.open.remove(gid)
-    def checkgroup(self, gid):
-        return gid < self.groups and gid not in self.open
-
-class SubPattern:
-    # a subpattern, in intermediate form
-    def __init__(self, pattern, data=None):
-        self.pattern = pattern
-        if data is None:
-            data = []
-        self.data = data
-        self.width = None
-    def dump(self, level=0):
-        nl = 1
-        seqtypes = type(()), type([])
-        for op, av in self.data:
-            print level*"  " + op,; nl = 0
-            if op == "in":
-                # member sublanguage
-                print; nl = 1
-                for op, a in av:
-                    print (level+1)*"  " + op, a
-            elif op == "branch":
-                print; nl = 1
-                i = 0
-                for a in av[1]:
-                    if i > 0:
-                        print level*"  " + "or"
-                    a.dump(level+1); nl = 1
-                    i = i + 1
-            elif type(av) in seqtypes:
-                for a in av:
-                    if isinstance(a, SubPattern):
-                        if not nl: print
-                        a.dump(level+1); nl = 1
-                    else:
-                        print a, ; nl = 0
-            else:
-                print av, ; nl = 0
-            if not nl: print
-    def __repr__(self):
-        return repr(self.data)
-    def __len__(self):
-        return len(self.data)
-    def __delitem__(self, index):
-        del self.data[index]
-    def __getitem__(self, index):
-        return self.data[index]
-    def __setitem__(self, index, code):
-        self.data[index] = code
-    def __getslice__(self, start, stop):
-        return SubPattern(self.pattern, self.data[start:stop])
-    def insert(self, index, code):
-        self.data.insert(index, code)
-    def append(self, code):
-        self.data.append(code)
-    def getwidth(self):
-        # determine the width (min, max) for this subpattern
-        if self.width:
-            return self.width
-        lo = hi = 0L
-        UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)
-        REPEATCODES = (MIN_REPEAT, MAX_REPEAT)
-        for op, av in self.data:
-            if op is BRANCH:
-                i = sys.maxint
-                j = 0
-                for av in av[1]:
-                    l, h = av.getwidth()
-                    i = min(i, l)
-                    j = max(j, h)
-                lo = lo + i
-                hi = hi + j
-            elif op is CALL:
-                i, j = av.getwidth()
-                lo = lo + i
-                hi = hi + j
-            elif op is SUBPATTERN:
-                i, j = av[1].getwidth()
-                lo = lo + i
-                hi = hi + j
-            elif op in REPEATCODES:
-                i, j = av[2].getwidth()
-                lo = lo + long(i) * av[0]
-                hi = hi + long(j) * av[1]
-            elif op in UNITCODES:
-                lo = lo + 1
-                hi = hi + 1
-            elif op == SUCCESS:
-                break
-        self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint))
-        return self.width
-
-class Tokenizer:
-    def __init__(self, string):
-        self.string = string
-        self.index = 0
-        self.__next()
-    def __next(self):
-        if self.index >= len(self.string):
-            self.next = None
-            return
-        char = self.string[self.index]
-        if char[0] == "\\":
-            try:
-                c = self.string[self.index + 1]
-            except IndexError:
-                raise error, "bogus escape (end of line)"
-            char = char + c
-        self.index = self.index + len(char)
-        self.next = char
-    def match(self, char, skip=1):
-        if char == self.next:
-            if skip:
-                self.__next()
-            return 1
-        return 0
-    def get(self):
-        this = self.next
-        self.__next()
-        return this
-    def tell(self):
-        return self.index, self.next
-    def seek(self, index):
-        self.index, self.next = index
-
-def isident(char):
-    return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_"
-
-def isdigit(char):
-    return "0" <= char <= "9"
-
-def isname(name):
-    # check that group name is a valid string
-    if not isident(name[0]):
-        return False
-    for char in name[1:]:
-        if not isident(char) and not isdigit(char):
-            return False
-    return True
-
-def _class_escape(source, escape):
-    # handle escape code inside character class
-    code = ESCAPES.get(escape)
-    if code:
-        return code
-    code = CATEGORIES.get(escape)
-    if code:
-        return code
-    try:
-        c = escape[1:2]
-        if c == "x":
-            # hexadecimal escape (exactly two digits)
-            while source.next in HEXDIGITS and len(escape) < 4:
-                escape = escape + source.get()
-            escape = escape[2:]
-            if len(escape) != 2:
-                raise error, "bogus escape: %s" % repr("\\" + escape)
-            return LITERAL, int(escape, 16) & 0xff
-        elif c in OCTDIGITS:
-            # octal escape (up to three digits)
-            while source.next in OCTDIGITS and len(escape) < 4:
-                escape = escape + source.get()
-            escape = escape[1:]
-            return LITERAL, int(escape, 8) & 0xff
-        elif c in DIGITS:
-            raise error, "bogus escape: %s" % repr(escape)
-        if len(escape) == 2:
-            return LITERAL, ord(escape[1])
-    except ValueError:
-        pass
-    raise error, "bogus escape: %s" % repr(escape)
-
-def _escape(source, escape, state):
-    # handle escape code in expression
-    code = CATEGORIES.get(escape)
-    if code:
-        return code
-    code = ESCAPES.get(escape)
-    if code:
-        return code
-    try:
-        c = escape[1:2]
-        if c == "x":
-            # hexadecimal escape
-            while source.next in HEXDIGITS and len(escape) < 4:
-                escape = escape + source.get()
-            if len(escape) != 4:
-                raise ValueError
-            return LITERAL, int(escape[2:], 16) & 0xff
-        elif c == "0":
-            # octal escape
-            while source.next in OCTDIGITS and len(escape) < 4:
-                escape = escape + source.get()
-            return LITERAL, int(escape[1:], 8) & 0xff
-        elif c in DIGITS:
-            # octal escape *or* decimal group reference (sigh)
-            if source.next in DIGITS:
-                escape = escape + source.get()
-                if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
-                    source.next in OCTDIGITS):
-                    # got three octal digits; this is an octal escape
-                    escape = escape + source.get()
-                    return LITERAL, int(escape[1:], 8) & 0xff
-            # not an octal escape, so this is a group reference
-            group = int(escape[1:])
-            if group < state.groups:
-                if not state.checkgroup(group):
-                    raise error, "cannot refer to open group"
-                return GROUPREF, group
-            raise ValueError
-        if len(escape) == 2:
-            return LITERAL, ord(escape[1])
-    except ValueError:
-        pass
-    raise error, "bogus escape: %s" % repr(escape)
-
-def _parse_sub(source, state, nested=1):
-    # parse an alternation: a|b|c
-
-    items = []
-    itemsappend = items.append
-    sourcematch = source.match
-    while 1:
-        itemsappend(_parse(source, state))
-        if sourcematch("|"):
-            continue
-        if not nested:
-            break
-        if not source.next or sourcematch(")", 0):
-            break
-        else:
-            raise error, "pattern not properly closed"
-
-    if len(items) == 1:
-        return items[0]
-
-    subpattern = SubPattern(state)
-    subpatternappend = subpattern.append
-
-    # check if all items share a common prefix
-    while 1:
-        prefix = None
-        for item in items:
-            if not item:
-                break
-            if prefix is None:
-                prefix = item[0]
-            elif item[0] != prefix:
-                break
-        else:
-            # all subitems start with a common "prefix".
-            # move it out of the branch
-            for item in items:
-                del item[0]
-            subpatternappend(prefix)
-            continue # check next one
-        break
-
-    # check if the branch can be replaced by a character set
-    for item in items:
-        if len(item) != 1 or item[0][0] != LITERAL:
-            break
-    else:
-        # we can store this as a character set instead of a
-        # branch (the compiler may optimize this even more)
-        set = []
-        setappend = set.append
-        for item in items:
-            setappend(item[0])
-        subpatternappend((IN, set))
-        return subpattern
-
-    subpattern.append((BRANCH, (None, items)))
-    return subpattern
-
-def _parse_sub_cond(source, state, condgroup):
-    item_yes = _parse(source, state)
-    if source.match("|"):
-        item_no = _parse(source, state)
-        if source.match("|"):
-            raise error, "conditional backref with more than two branches"
-    else:
-        item_no = None
-    if source.next and not source.match(")", 0):
-        raise error, "pattern not properly closed"
-    subpattern = SubPattern(state)
-    subpattern.append((GROUPREF_EXISTS, (condgroup, item_yes, item_no)))
-    return subpattern
-
-def _parse(source, state):
-    # parse a simple pattern
-    subpattern = SubPattern(state)
-
-    # precompute constants into local variables
-    subpatternappend = subpattern.append
-    sourceget = source.get
-    sourcematch = source.match
-    _len = len
-    PATTERNENDERS = ("|", ")")
-    ASSERTCHARS = ("=", "!", "<")
-    LOOKBEHINDASSERTCHARS = ("=", "!")
-    REPEATCODES = (MIN_REPEAT, MAX_REPEAT)
-
-    while 1:
-
-        if source.next in PATTERNENDERS:
-            break # end of subpattern
-        this = sourceget()
-        if this is None:
-            break # end of pattern
-
-        if state.flags & SRE_FLAG_VERBOSE:
-            # skip whitespace and comments
-            if this in WHITESPACE:
-                continue
-            if this == "#":
-                while 1:
-                    this = sourceget()
-                    if this in (None, "\n"):
-                        break
-                continue
-
-        if this and this[0] not in SPECIAL_CHARS:
-            subpatternappend((LITERAL, ord(this)))
-
-        elif this == "[":
-            # character set
-            set = []
-            setappend = set.append
-##          if sourcematch(":"):
-##              pass # handle character classes
-            if sourcematch("^"):
-                setappend((NEGATE, None))
-            # check remaining characters
-            start = set[:]
-            while 1:
-                this = sourceget()
-                if this == "]" and set != start:
-                    break
-                elif this and this[0] == "\\":
-                    code1 = _class_escape(source, this)
-                elif this:
-                    code1 = LITERAL, ord(this)
-                else:
-                    raise error, "unexpected end of regular expression"
-                if sourcematch("-"):
-                    # potential range
-                    this = sourceget()
-                    if this == "]":
-                        if code1[0] is IN:
-                            code1 = code1[1][0]
-                        setappend(code1)
-                        setappend((LITERAL, ord("-")))
-                        break
-                    elif this:
-                        if this[0] == "\\":
-                            code2 = _class_escape(source, this)
-                        else:
-                            code2 = LITERAL, ord(this)
-                        if code1[0] != LITERAL or code2[0] != LITERAL:
-                            raise error, "bad character range"
-                        lo = code1[1]
-                        hi = code2[1]
-                        if hi < lo:
-                            raise error, "bad character range"
-                        setappend((RANGE, (lo, hi)))
-                    else:
-                        raise error, "unexpected end of regular expression"
-                else:
-                    if code1[0] is IN:
-                        code1 = code1[1][0]
-                    setappend(code1)
-
-            # XXX: <fl> should move set optimization to compiler!
-            if _len(set)==1 and set[0][0] is LITERAL:
-                subpatternappend(set[0]) # optimization
-            elif _len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL:
-                subpatternappend((NOT_LITERAL, set[1][1])) # optimization
-            else:
-                # XXX: <fl> should add charmap optimization here
-                subpatternappend((IN, set))
-
-        elif this and this[0] in REPEAT_CHARS:
-            # repeat previous item
-            if this == "?":
-                min, max = 0, 1
-            elif this == "*":
-                min, max = 0, MAXREPEAT
-
-            elif this == "+":
-                min, max = 1, MAXREPEAT
-            elif this == "{":
-                here = source.tell()
-                min, max = 0, MAXREPEAT
-                lo = hi = ""
-                while source.next in DIGITS:
-                    lo = lo + source.get()
-                if sourcematch(","):
-                    while source.next in DIGITS:
-                        hi = hi + sourceget()
-                else:
-                    hi = lo
-                if not sourcematch("}"):
-                    subpatternappend((LITERAL, ord(this)))
-                    source.seek(here)
-                    continue
-                if lo:
-                    min = int(lo)
-                if hi:
-                    max = int(hi)
-                if max < min:
-                    raise error, "bad repeat interval"
-            else:
-                raise error, "not supported"
-            # figure out which item to repeat
-            if subpattern:
-                item = subpattern[-1:]
-            else:
-                item = None
-            if not item or (_len(item) == 1 and item[0][0] == AT):
-                raise error, "nothing to repeat"
-            if item[0][0] in REPEATCODES:
-                raise error, "multiple repeat"
-            if sourcematch("?"):
-                subpattern[-1] = (MIN_REPEAT, (min, max, item))
-            else:
-                subpattern[-1] = (MAX_REPEAT, (min, max, item))
-
-        elif this == ".":
-            subpatternappend((ANY, None))
-
-        elif this == "(":
-            group = 1
-            name = None
-            condgroup = None
-            if sourcematch("?"):
-                group = 0
-                # options
-                if sourcematch("P"):
-                    # python extensions
-                    if sourcematch("<"):
-                        # named group: skip forward to end of name
-                        name = ""
-                        while 1:
-                            char = sourceget()
-                            if char is None:
-                                raise error, "unterminated name"
-                            if char == ">":
-                                break
-                            name = name + char
-                        group = 1
-                        if not isname(name):
-                            raise error, "bad character in group name"
-                    elif sourcematch("="):
-                        # named backreference
-                        name = ""
-                        while 1:
-                            char = sourceget()
-                            if char is None:
-                                raise error, "unterminated name"
-                            if char == ")":
-                                break
-                            name = name + char
-                        if not isname(name):
-                            raise error, "bad character in group name"
-                        gid = state.groupdict.get(name)
-                        if gid is None:
-                            raise error, "unknown group name"
-                        subpatternappend((GROUPREF, gid))
-                        continue
-                    else:
-                        char = sourceget()
-                        if char is None:
-                            raise error, "unexpected end of pattern"
-                        raise error, "unknown specifier: ?P%s" % char
-                elif sourcematch(":"):
-                    # non-capturing group
-                    group = 2
-                elif sourcematch("#"):
-                    # comment
-                    while 1:
-                        if source.next is None or source.next == ")":
-                            break
-                        sourceget()
-                    if not sourcematch(")"):
-                        raise error, "unbalanced parenthesis"
-                    continue
-                elif source.next in ASSERTCHARS:
-                    # lookahead assertions
-                    char = sourceget()
-                    dir = 1
-                    if char == "<":
-                        if source.next not in LOOKBEHINDASSERTCHARS:
-                            raise error, "syntax error"
-                        dir = -1 # lookbehind
-                        char = sourceget()
-                    p = _parse_sub(source, state)
-                    if not sourcematch(")"):
-                        raise error, "unbalanced parenthesis"
-                    if char == "=":
-                        subpatternappend((ASSERT, (dir, p)))
-                    else:
-                        subpatternappend((ASSERT_NOT, (dir, p)))
-                    continue
-                elif sourcematch("("):
-                    # conditional backreference group
-                    condname = ""
-                    while 1:
-                        char = sourceget()
-                        if char is None:
-                            raise error, "unterminated name"
-                        if char == ")":
-                            break
-                        condname = condname + char
-                    group = 2
-                    if isname(condname):
-                        condgroup = state.groupdict.get(condname)
-                        if condgroup is None:
-                            raise error, "unknown group name"
-                    else:
-                        try:
-                            condgroup = int(condname)
-                        except ValueError:
-                            raise error, "bad character in group name"
-                else:
-                    # flags
-                    if not source.next in FLAGS:
-                        raise error, "unexpected end of pattern"
-                    while source.next in FLAGS:
-                        state.flags = state.flags | FLAGS[sourceget()]
-            if group:
-                # parse group contents
-                if group == 2:
-                    # anonymous group
-                    group = None
-                else:
-                    group = state.opengroup(name)
-                if condgroup:
-                    p = _parse_sub_cond(source, state, condgroup)
-                else:
-                    p = _parse_sub(source, state)
-                if not sourcematch(")"):
-                    raise error, "unbalanced parenthesis"
-                if group is not None:
-                    state.closegroup(group)
-                subpatternappend((SUBPATTERN, (group, p)))
-            else:
-                while 1:
-                    char = sourceget()
-                    if char is None:
-                        raise error, "unexpected end of pattern"
-                    if char == ")":
-                        break
-                    raise error, "unknown extension"
-
-        elif this == "^":
-            subpatternappend((AT, AT_BEGINNING))
-
-        elif this == "$":
-            subpattern.append((AT, AT_END))
-
-        elif this and this[0] == "\\":
-            code = _escape(source, this, state)
-            subpatternappend(code)
-
-        else:
-            raise error, "parser error"
-
-    return subpattern
-
-def parse(str, flags=0, pattern=None):
-    # parse 're' pattern into list of (opcode, argument) tuples
-
-    source = Tokenizer(str)
-
-    if pattern is None:
-        pattern = Pattern()
-    pattern.flags = flags
-    pattern.str = str
-
-    p = _parse_sub(source, pattern, 0)
-
-    tail = source.get()
-    if tail == ")":
-        raise error, "unbalanced parenthesis"
-    elif tail:
-        raise error, "bogus characters at end of regular expression"
-
-    if flags & SRE_FLAG_DEBUG:
-        p.dump()
-
-    if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE:
-        # the VERBOSE flag was switched on inside the pattern.  to be
-        # on the safe side, we'll parse the whole thing again...
-        return parse(str, p.pattern.flags)
-
-    return p
-
-def parse_template(source, pattern):
-    # parse 're' replacement string into list of literals and
-    # group references
-    s = Tokenizer(source)
-    sget = s.get
-    p = []
-    a = p.append
-    def literal(literal, p=p, pappend=a):
-        if p and p[-1][0] is LITERAL:
-            p[-1] = LITERAL, p[-1][1] + literal
-        else:
-            pappend((LITERAL, literal))
-    sep = source[:0]
-    if type(sep) is type(""):
-        makechar = chr
-    else:
-        makechar = unichr
-    while 1:
-        this = sget()
-        if this is None:
-            break # end of replacement string
-        if this and this[0] == "\\":
-            # group
-            c = this[1:2]
-            if c == "g":
-                name = ""
-                if s.match("<"):
-                    while 1:
-                        char = sget()
-                        if char is None:
-                            raise error, "unterminated group name"
-                        if char == ">":
-                            break
-                        name = name + char
-                if not name:
-                    raise error, "bad group name"
-                try:
-                    index = int(name)
-                    if index < 0:
-                        raise error, "negative group number"
-                except ValueError:
-                    if not isname(name):
-                        raise error, "bad character in group name"
-                    try:
-                        index = pattern.groupindex[name]
-                    except KeyError:
-                        raise IndexError, "unknown group name"
-                a((MARK, index))
-            elif c == "0":
-                if s.next in OCTDIGITS:
-                    this = this + sget()
-                    if s.next in OCTDIGITS:
-                        this = this + sget()
-                literal(makechar(int(this[1:], 8) & 0xff))
-            elif c in DIGITS:
-                isoctal = False
-                if s.next in DIGITS:
-                    this = this + sget()
-                    if (c in OCTDIGITS and this[2] in OCTDIGITS and
-                        s.next in OCTDIGITS):
-                        this = this + sget()
-                        isoctal = True
-                        literal(makechar(int(this[1:], 8) & 0xff))
-                if not isoctal:
-                    a((MARK, int(this[1:])))
-            else:
-                try:
-                    this = makechar(ESCAPES[this][1])
-                except KeyError:
-                    pass
-                literal(this)
-        else:
-            literal(this)
-    # convert template to groups and literals lists
-    i = 0
-    groups = []
-    groupsappend = groups.append
-    literals = [None] * len(p)
-    for c, s in p:
-        if c is MARK:
-            groupsappend((i, s))
-            # literal[i] is already None
-        else:
-            literals[i] = s
-        i = i + 1
-    return groups, literals
-
-def expand_template(template, match):
-    g = match.group
-    sep = match.string[:0]
-    groups, literals = template
-    literals = literals[:]
-    try:
-        for index, group in groups:
-            literals[index] = s = g(group)
-            if s is None:
-                raise error, "unmatched group"
-    except IndexError:
-        raise error, "invalid group reference"
-    return sep.join(literals)

Deleted: /pypy/dist/pypy/appspace/struct.py
==============================================================================
--- /pypy/dist/pypy/appspace/struct.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,346 +0,0 @@
-import math,sys
-
-"""Functions to convert between Python values and C structs. 
-Python strings are used to hold the data representing the C struct 
-and also as format strings to describe the layout of data in the C struct.
-
-The optional first format char indicates byte order, size and alignment: 
- @: native order, size & alignment (default) 
- =: native order, std. size & alignment 
- <: little-endian, std. size & alignment 
- >: big-endian, std. size & alignment 
- !: same as > 
- 
-The remaining chars indicate types of args and must match exactly; 
-these can be preceded by a decimal repeat count: 
-   x: pad byte (no data); 
-   c:char; 
-   b:signed byte; 
-   B:unsigned byte; 
-   h:short; 
-   H:unsigned short; 
-   i:int; 
-   I:unsigned int; 
-   l:long; 
-   L:unsigned long; 
-   f:float; 
-   d:double. 
-Special cases (preceding decimal count indicates length): 
-   s:string (array of char); p: pascal string (with count byte). 
-Special case (only available in native format): 
-   P:an integer type that is wide enough to hold a pointer. 
-Special case (not in native mode unless 'long long' in platform C): 
-   q:long long; 
-   Q:unsigned long long 
-Whitespace between formats is ignored. 
- 
-The variable struct.error is an exception raised on errors."""
-
-# TODO: XXX Find a way to get information on native sizes and alignments
-class StructError(Exception):
-    pass
-error = StructError
-def unpack_int(data,index,size,le):
-    bytes = [ord(b) for b in data[index:index+size]]
-    if le == 'little':
-        bytes.reverse()
-    number = 0L
-    for b in bytes:
-        number = number << 8 | b
-    return int(number)
-
-def unpack_signed_int(data,index,size,le):
-    number = unpack_int(data,index,size,le)
-    max = 2**(size*8) 
-    if number > 2**(size*8 - 1) - 1:
-        number = int(-1*(max - number))
-    return number
-    
-def unpack_float(data,index,size,le):
-    bytes = [ord(b) for b in data[index:index+size]]
-    if len(bytes) != size:
-        raise StructError,"Not enough data to unpack"
-    if le == 'big':
-        bytes.reverse()
-    if size == 4:
-        bias = 127
-        exp = 8
-        prec = 23
-    else:
-        bias = 1023
-        exp = 11
-        prec = 52
-#    print bytes,size,index,len(data),data
-    mantissa = long(bytes[size-2] & (2**(15-exp)-1))
-#    print mantissa
-    for b in bytes[size-3::-1]:
-        mantissa = mantissa << 8 | b
-#        print mantissa
-    mantissa = 1 + (1.0*mantissa)/(2**(prec))
-    mantissa /= 2
-#    print mantissa
-    e = (bytes[-1] & 0x7f) << (exp - 7)
-    e += (bytes[size-2] >> (15 - exp)) & (2**(exp - 7) -1)
-    e -= bias
-    e += 1
-    sign = bytes[-1] & 0x80
-    number = math.ldexp(mantissa,e)
-#    print number,index,mantissa,e,bytes#,data
-    if sign : number *= -1
-    return number
-
-def unpack_char(data,index,size,le):
-    return data[index:index+size]
-        
-def pack_int(number,size,le):
-    x=number
-    res=[]
-    for i in range(size):
-        res.append(chr(x&0xff))
-        x >>= 8 
-    if le == 'big':
-        res.reverse()
-    return ''.join(res) 
-    
-def pack_signed_int(number,size,le):
-    if type(number) not in [int,long]:
-        raise StructError,"argument for i,I,l,L,q,Q,h,H must be integer"
-    if number > 2**(8*size-1)-1 or number < -1*2**(8*size-1):
-        raise OverflowError,"Number:%i to large to convert" % number
-    return pack_int(number,size,le)
-
-def pack_unsigned_int(number,size,le):
-    if type(number) not in [int,long]:
-        raise StructError,"argument for i,I,l,L,q,Q,h,H must be integer"
-    if number < 0:
-        raise TypeError,"can't convert negative long to unsigned"
-    if number > 2**(8*size)-1:
-        raise OverflowError,"Number:%i to large to convert" % number
-    return pack_int(number,size,le)
-    
-def pack_char(char,size,le):
-#    print char
-    return str(char)
-
-def sane_float(man,e):
-    # TODO: XXX Implement checks for floats
-    return True
-    
-def pack_float(number,size,le):
-    
-    if number < 0:
-        sign=1
-        number *= -1
-    else:
-        sign =0
-    if size == 4:
-        bias = 127
-        exp = 8
-        prec = 23
-    else:
-        bias = 1023
-        exp = 11
-        prec = 52
-    
-    man,e = math.frexp(number)
-    if 0.5 <= man and man < 1.0:
-        man *= 2
-        e -= 1
-    if sane_float(man,e):
-        man -= 1
-        e += bias
-        mantissa = int(2**prec *(man) +0.5)   
-        res=[]
-        if mantissa >> prec :
-            mantissa = 0
-            e += 1
-        
-        for i in range(size-2):
-            res += [ mantissa & 0xff]
-            mantissa >>= 8
-        res += [ (mantissa & (2**(15-exp)-1)) | ((e & (2**(exp-7)-1))<<(15-exp))]
-        res += [sign << 7 | e >> (exp - 7)]
-        if le == 'big':
-            res.reverse()
-        return ''.join([chr(x) for x in res])
-    # TODO: What todo with insane floats/doubles. handle in sanefloat?
-    
-big_endian_format = {
-    'x':{ 'size' : 1, 'alignment' : 0, 'pack' : None, 'unpack' : None},
-    'b':{ 'size' : 1, 'alignment' : 0, 'pack' : pack_signed_int, 'unpack' : unpack_signed_int},
-    'B':{ 'size' : 1, 'alignment' : 0, 'pack' : pack_unsigned_int, 'unpack' : unpack_int},
-    'c':{ 'size' : 1, 'alignment' : 0, 'pack' : pack_char, 'unpack' : unpack_char},
-    's':{ 'size' : 1, 'alignment' : 0, 'pack' : None, 'unpack' : None},
-    'p':{ 'size' : 1, 'alignment' : 0, 'pack' : None, 'unpack' : None},
-    'h':{ 'size' : 2, 'alignment' : 0, 'pack' : pack_signed_int, 'unpack' : unpack_signed_int},
-    'H':{ 'size' : 2, 'alignment' : 0, 'pack' : pack_unsigned_int, 'unpack' : unpack_int},
-    'i':{ 'size' : 4, 'alignment' : 0, 'pack' : pack_signed_int, 'unpack' : unpack_signed_int},
-    'I':{ 'size' : 4, 'alignment' : 0, 'pack' : pack_unsigned_int, 'unpack' : unpack_int},
-    'l':{ 'size' : 4, 'alignment' : 0, 'pack' : pack_signed_int, 'unpack' : unpack_signed_int},
-    'L':{ 'size' : 4, 'alignment' : 0, 'pack' : pack_unsigned_int, 'unpack' : unpack_int},
-    'q':{ 'size' : 8, 'alignment' : 0, 'pack' : pack_signed_int, 'unpack' : unpack_signed_int},
-    'Q':{ 'size' : 8, 'alignment' : 0, 'pack' : pack_unsigned_int, 'unpack' : unpack_int},
-    'f':{ 'size' : 4, 'alignment' : 0, 'pack' : pack_float, 'unpack' : unpack_float},
-    'd':{ 'size' : 8, 'alignment' : 0, 'pack' : pack_float, 'unpack' : unpack_float},
-    }
-default = big_endian_format
-formatmode={ '<' : (default, 'little'), 
-             '>' : (default, 'big'), 
-             '!' : (default, 'big'),
-             '=' : (default, sys.byteorder),
-             '@' : (default, sys.byteorder)
-            }       
-
-def getmode(fmt):
-    try:
-        formatdef,endianness = formatmode[fmt[0]]
-        index = 1
-    except KeyError:
-        formatdef,endianness = formatmode['@']
-        index = 0
-    return formatdef,endianness,index
-def getNum(fmt,i):
-    num=None
-    cur = fmt[i]
-    while ('0'<= cur ) and ( cur <= '9'):
-        if num == None:
-            num = int(cur)
-        else:
-            num = 10*num + int(cur)
-        i += 1
-        cur = fmt[i]
-    return num,i
-        
-def calcsize(fmt):
-    """calcsize(fmt) -> int 
-    Return size of C struct described by format string fmt. 
-    See struct.__doc__ for more on format strings."""
-    
-    formatdef,endianness,i = getmode(fmt)
-    num = 0
-    result = 0
-    while i<len(fmt):
-        num,i = getNum(fmt,i)
-        cur = fmt[i]
-        try:
-            format = formatdef[cur]
-        except KeyError:
-            raise StructError,"%s is not a valid format"%cur
-        if num != None :
-            result += num*format['size']
-        else:
-            result += format['size']
-        num = 0
-        i += 1
-    return result
-    
-def pack(fmt,*args):
-    """pack(fmt, v1, v2, ...) -> string 
-       Return string containing values v1, v2, ... packed according to fmt. 
-       See struct.__doc__ for more on format strings."""    
-    formatdef,endianness,i = getmode(fmt)
-    args = list(args)
-    n_args = len(args)
-    result = []
-    while i<len(fmt):
-        num,i = getNum(fmt,i)
-        cur = fmt[i]
-        try:
-            format = formatdef[cur]
-        except KeyError:
-            raise StructError,"%s is not a valid format"%cur
-        if num == None :
-            num_s = 0
-            num = 1
-        else:
-            num_s = num
-            
-        if cur == 'x':
-            result += ['\0'*num]
-        elif cur == 's':
-            if type(args[0]) == str:
-                padding = num - len(args[0])
-                if padding >=0:
-                    result += [args[0][:num] + '\0'*padding]
-                else:
-                    result += [args[0][:num]]
-                args.pop()
-            else:
-                raise StructError,"arg for string format not a string"
-        elif cur == 'p':
-            if type(args[0]) == str:
-                padding = num - len(args[0]) - 1
-                
-                if padding > 0:
-                    result += [chr(len(args[0])) + args[0][:num-1] + '\0'*padding]
-                else:
-                    if num<255:
-                        result += [chr(num-1) + args[0][:num-1]]
-                    else:
-                        result += [chr(255) + args[0][:num-1]]
-                args.pop()
-            else:
-                raise StructError,"arg for string format not a string"
-            
-        else:
-            if len(args) == 0:
-                raise StructError,"insufficient arguments to pack"
-            for var in args[:num]:
-                result += [format['pack'](var,format['size'],endianness)]
-            args=args[num:]
-        num = None
-        i += 1
-    if len(args) != 0:
-        raise StructError,"too many arguments for pack format"
-    return ''.join(result)
-            
-def unpack(fmt,data):
-    """unpack(fmt, string) -> (v1, v2, ...)
-       Unpack the string, containing packed C structure data, according
-       to fmt.  Requires len(string)==calcsize(fmt).
-       See struct.__doc__ for more on format strings."""
-    formatdef,endianness,i = getmode(fmt)
-#    print fmt,data
-    j = 0
-    num = 0
-    result = []
-    length= calcsize(fmt)
-    if length != len (data):
-        raise StructError,"unpack str size does not match format"
-    while i<len(fmt):
-        num,i=getNum(fmt,i)
-        cur = fmt[i]
-        try:
-            format = formatdef[cur]
-        except KeyError:
-            raise StructError,"%s is not a valid format"%cur
-            
-        if not num :
-            num = 1
-        if cur == 'x':
-            j += num
-            i += 1
-        elif cur == 's':
-            result.append(data[j:j+num])
-            j += num
-            i += 1
-        elif cur == 'p':
-            n=ord(data[j])
-            if n >= num:
-                n = num-1
-            result.append(data[j+1:j+n+1])
-            j += num
-            i += 1
-        else:   
-            for n in range(num):
-                result += [format['unpack'](data,j,format['size'],endianness)]
-                j += format['size']
-                i += 1
-
-    return tuple(result)
-
-if __name__ == '__main__':
-    print pack_float(1.23,4,'little')
-    import struct
-    print (struct.pack('f',1.23), pack('f',1.23))
-    print unpack('f',pack('f',1.23))   

Modified: pypy/dist/pypy/appspace/test/conftest.py
==============================================================================
--- pypy/dist/pypy/appspace/test/conftest.py	(original)
+++ pypy/dist/pypy/appspace/test/conftest.py	Thu Jan 27 23:35:29 2005
@@ -6,22 +6,4 @@
 
 class Directory(py.test.collect.Directory): 
     def __iter__(self): 
-        for path in self.fspath.listdir(): 
-            if path.check(fnmatch='cpy_test_*.py', file=1): 
-                continue 
-                #XXX yield RunFileAtAppLevelItem(py.path.extpy(path)) 
-            elif self.fil(path): 
-                if path.basename in ('test_cmathmodule.py', 
-                                     'builtin_functions_test.py', 
-                                     'test_complexobject.py',): 
-                    continue
-                yield self.Module(path) 
-            elif self.rec(path): 
-                yield self.Directory(path) 
-
-class RunFileAtAppLevelItem(PyPyItem): 
-    def run(self, driver): 
-        space = getobjspace() 
-        source = self.extpy.root.read()
-        #self.execute_appex(space, run_string, source, str(self.extpy.root), space) 
-        run_string(source, str(self.extpy.root), space) 
+        return iter([]) 

Modified: pypy/dist/pypy/appspace/test/test_exceptions.py
==============================================================================
--- pypy/dist/pypy/appspace/test/test_exceptions.py	(original)
+++ pypy/dist/pypy/appspace/test/test_exceptions.py	Thu Jan 27 23:35:29 2005
@@ -1,5 +1,5 @@
 import autopath
 
-def app_test_import():
+def failing_app_test_import():
     import exceptions
     assert exceptions.SyntaxError is SyntaxError 

Deleted: /pypy/dist/pypy/appspace/test/test_sio.py
==============================================================================
--- /pypy/dist/pypy/appspace/test/test_sio.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,740 +0,0 @@
-"""Unit tests for sio (new standard I/O)."""
-
-import os
-import time
-from pypy.tool.udir import udir
-
-from pypy.appspace import sio 
-
-class TestSource(object):
-
-    def __init__(self, packets):
-        for x in packets:
-            assert x
-        self.orig_packets = list(packets)
-        self.packets = list(packets)
-        self.pos = 0
-
-    def tell(self):
-        return self.pos
-
-    def seek(self, offset, whence=0):
-        if whence == 1:
-            offset += self.pos
-        elif whence == 2:
-            for packet in self.orig_packets:
-                offset += len(packet)
-        else:
-            assert whence == 0
-        self.packets = list(self.orig_packets)
-        self.pos = 0
-        while self.pos < offset:
-            data = self.read(offset - self.pos)
-            if not data:
-                break
-        assert self.pos == offset
-
-    def read(self, n):
-        try:
-            data = self.packets.pop(0)
-        except IndexError:
-            return ""
-        if len(data) > n:
-            data, rest = data[:n], data[n:]
-            self.packets.insert(0, rest)
-        self.pos += len(data)
-        return data
-
-    def close(self):
-        pass
-
-class TestReader(object):
-
-    def __init__(self, packets):
-        for x in packets:
-            assert x
-        self.orig_packets = list(packets)
-        self.packets = list(packets)
-        self.pos = 0
-
-    def tell(self):
-        return self.pos
-
-    def seek(self, offset, whence=0):
-        if whence == 1:
-            offset += self.pos
-        elif whence == 2:
-            for packet in self.orig_packets:
-                offset += len(packet)
-        else:
-            assert whence == 0
-        self.packets = list(self.orig_packets)
-        self.pos = 0
-        while self.pos < offset:
-            data = self.read(offset - self.pos)
-            if not data:
-                break
-        assert self.pos == offset
-
-    def read(self, n):
-        try:
-            data = self.packets.pop(0)
-        except IndexError:
-            return ""
-        if len(data) > n:
-            data, rest = data[:n], data[n:]
-            self.packets.insert(0, rest)
-        self.pos += len(data)
-        return data
-
-    def close(self):
-        pass
-
-    def flush(self):
-        pass
-class TestWriter(object):
-
-    def __init__(self, data=''):
-        self.buf = data
-        self.pos = 0
-
-    def write(self, data):
-        if self.pos >= len(self.buf):
-            self.buf += "\0" * (self.pos - len(self.buf)) + data
-            self.pos = len(self.buf)
-        else:
-            self.buf = (self.buf[:self.pos] + data +
-                        self.buf[self.pos + len(data):])
-            self.pos += len(data)
-
-    def tell(self):
-        return self.pos
-
-    def seek(self, offset, whence=0):
-        if whence == 0:
-            pass
-        elif whence == 1:
-            offset += self.pos
-        elif whence == 2:
-            offset += len(self.buf)
-        else:
-            raise ValueError, "whence should be 0, 1 or 2"
-        if offset < 0:
-            offset = 0
-        self.pos = offset
-
-    def close(self):
-        pass
-
-    def truncate(self, size=None):
-        if size is None:
-            size = self.pos
-        if size <= len(self.buf):
-            self.buf = self.buf[:size]
-        else:
-            self.buf += '\0' * (size - len(self.buf))
-
-    def flush(self):
-        pass
-            
-class TestReaderWriter(TestWriter):
-
-    def read(self, n=-1):
-        if n < 1:
-            result = self.buf[self.pos: ]
-            self.pos = len(self.buf)
-        else:
-            if self.pos + n > len(self.buf):
-                n = len(self.buf) - self.pos
-            result = self.buf[self.pos: self.pos+n]
-            self.pos += n
-        return result
-    
-class TestBufferingInputStreamTests: 
-
-    packets = ["a", "b", "\n", "def", "\nxy\npq\nuv", "wx"]
-    lines = ["ab\n", "def\n", "xy\n", "pq\n", "uvwx"]
-
-    def makeStream(self, tell=False, seek=False, bufsize=None):
-        base = TestSource(self.packets)
-        if not tell:
-            base.tell = None
-        if not seek:
-            base.seek = None
-        return sio.BufferingInputStream(base, bufsize)
-
-    def test_readline(self):
-        file = self.makeStream()
-        assert list(iter(file.readline, "")) == self.lines
-
-    def test_readlines(self):
-        # This also tests next() and __iter__()
-        file = self.makeStream()
-        assert file.readlines() == self.lines
-
-    def test_readlines_small_bufsize(self):
-        file = self.makeStream(bufsize=1)
-        assert list(file) == self.lines
-
-    def test_readall(self):
-        file = self.makeStream()
-        assert file.readall() == "".join(self.lines)
-
-    def test_readall_small_bufsize(self):
-        file = self.makeStream(bufsize=1)
-        assert file.readall() == "".join(self.lines)
-
-    def test_readall_after_readline(self):
-        file = self.makeStream()
-        assert file.readline() == self.lines[0]
-        assert file.readline() == self.lines[1]
-        assert file.readall() == "".join(self.lines[2:])
-
-    def test_read_1_after_readline(self):
-        file = self.makeStream()
-        assert file.readline() == "ab\n"
-        assert file.readline() == "def\n"
-        blocks = []
-        while 1:
-            block = file.read(1)
-            if not block:
-                break
-            blocks.append(block)
-            assert file.read(0) == ""
-        assert blocks == list("".join(self.lines)[7:])
-
-    def test_read_1(self):
-        file = self.makeStream()
-        blocks = []
-        while 1:
-            block = file.read(1)
-            if not block:
-                break
-            blocks.append(block)
-            assert file.read(0) == ""
-        assert blocks == list("".join(self.lines))
-
-    def test_read_2(self):
-        file = self.makeStream()
-        blocks = []
-        while 1:
-            block = file.read(2)
-            if not block:
-                break
-            blocks.append(block)
-            assert file.read(0) == ""
-        assert blocks == ["ab", "\nd", "ef", "\nx", "y\n", "pq",
-                                  "\nu", "vw", "x"]
-
-    def test_read_4(self):
-        file = self.makeStream()
-        blocks = []
-        while 1:
-            block = file.read(4)
-            if not block:
-                break
-            blocks.append(block)
-            assert file.read(0) == ""
-        assert blocks == ["ab\nd", "ef\nx", "y\npq", "\nuvw", "x"]
-        
-    def test_read_4_after_readline(self):
-        file = self.makeStream()
-        assert file.readline() == "ab\n"
-        assert file.readline() == "def\n"
-        blocks = [file.read(4)]
-        while 1:
-            block = file.read(4)
-            if not block:
-                break
-            blocks.append(block)
-            assert file.read(0) == ""
-        assert blocks == ["xy\np", "q\nuv", "wx"]
-
-    def test_read_4_small_bufsize(self):
-        file = self.makeStream(bufsize=1)
-        blocks = []
-        while 1:
-            block = file.read(4)
-            if not block:
-                break
-            blocks.append(block)
-        assert blocks == ["ab\nd", "ef\nx", "y\npq", "\nuvw", "x"]
-
-    def test_tell_1(self):
-        file = self.makeStream(tell=True)
-        pos = 0
-        while 1:
-            assert file.tell() == pos
-            n = len(file.read(1))
-            if not n:
-                break
-            pos += n
-
-    def test_tell_1_after_readline(self):
-        file = self.makeStream(tell=True)
-        pos = 0
-        pos += len(file.readline())
-        assert file.tell() == pos
-        pos += len(file.readline())
-        assert file.tell() == pos
-        while 1:
-            assert file.tell() == pos
-            n = len(file.read(1))
-            if not n:
-                break
-            pos += n
-
-    def test_tell_2(self):
-        file = self.makeStream(tell=True)
-        pos = 0
-        while 1:
-            assert file.tell() == pos
-            n = len(file.read(2))
-            if not n:
-                break
-            pos += n
-
-    def test_tell_4(self):
-        file = self.makeStream(tell=True)
-        pos = 0
-        while 1:
-            assert file.tell() == pos
-            n = len(file.read(4))
-            if not n:
-                break
-            pos += n
-
-    def test_tell_readline(self):
-        file = self.makeStream(tell=True)
-        pos = 0
-        while 1:
-            assert file.tell() == pos
-            n = len(file.readline())
-            if not n:
-                break
-            pos += n
-
-    def test_seek(self):
-        file = self.makeStream(tell=True, seek=True)
-        all = file.readall()
-        end = len(all)
-        for readto in range(0, end+1):
-            for seekto in range(0, end+1):
-                for whence in 0, 1, 2:
-                    file.seek(0)
-                    assert file.tell() == 0
-                    head = file.read(readto)
-                    assert head == all[:readto]
-                    if whence == 1:
-                        offset = seekto - readto
-                    elif whence == 2:
-                        offset = seekto - end
-                    else:
-                        offset = seekto
-                    file.seek(offset, whence)
-                    here = file.tell()
-                    assert here == seekto
-                    rest = file.readall()
-                    assert rest == all[seekto:]
-
-    def test_seek_noseek(self):
-        file = self.makeStream()
-        all = file.readall()
-        end = len(all)
-        for readto in range(0, end+1):
-            for seekto in range(readto, end+1):
-                for whence in 1, 2:
-                    file = self.makeStream()
-                    head = file.read(readto)
-                    assert head == all[:readto]
-                    if whence == 1:
-                        offset = seekto - readto
-                    elif whence == 2:
-                        offset = seekto - end
-                    file.seek(offset, whence)
-                    rest = file.readall()
-                    assert rest == all[seekto:]
-
-class TestBufferingOutputStream: 
-
-    def test_write(self):
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.write("123")
-        assert base.buf == ""
-        assert filter.tell() == 3
-        filter.write("456")
-        assert base.buf == "1234"
-        filter.write("789ABCDEF")
-        assert base.buf == "123456789ABC"
-        filter.write("0123")
-        assert base.buf == "123456789ABCDEF0"
-        assert filter.tell() == 19
-        filter.close()
-        assert base.buf == "123456789ABCDEF0123"
-
-    def test_write_seek(self):
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.write("x"*6)
-        filter.seek(3)
-        filter.write("y"*2)
-        filter.close()
-        assert base.buf == "x"*3 + "y"*2 + "x"*1
-
-    def test_write_seek_beyond_end(self):
-        "Linux behaviour. May be different on other platforms."
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.seek(3)
-        filter.write("y"*2)
-        filter.close()
-        assert base.buf == "\0"*3 + "y"*2
-
-    def test_truncate(self):
-        "Linux behaviour. May be different on other platforms."
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.write('x')
-        filter.truncate(4)
-        filter.write('y')
-        filter.close()
-        assert base.buf == 'xy' + '\0' * 2
-
-    def test_truncate2(self):
-        "Linux behaviour. May be different on other platforms."
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.write('12345678')
-        filter.truncate(4)
-        filter.write('y')
-        filter.close()
-        assert base.buf == '1234' + '\0' * 4 + 'y'
-
-class TestLineBufferingOutputStreamTests: 
-
-    def test_write(self):
-        base = TestWriter()
-        filter = sio.LineBufferingOutputStream(base)
-        filter.bufsize = 4 # More handy for testing than the default
-        filter.write("123")
-        assert base.buf == ""
-        assert filter.tell() == 3
-        filter.write("456")
-        assert base.buf == "1234"
-        filter.write("789ABCDEF\n")
-        assert base.buf == "123456789ABCDEF\n"
-        filter.write("0123")
-        assert base.buf == "123456789ABCDEF\n0123"
-        assert filter.tell() == 20
-        filter.close()
-        assert base.buf == "123456789ABCDEF\n0123"
-
-    def xtest_write_seek(self):
-        base = TestWriter()
-        filter = sio.BufferingOutputStream(base, 4)
-        filter.write("x"*6)
-        filter.seek(3)
-        filter.write("y"*2)
-        filter.close()
-        assert base.buf == "x"*3 + "y"*2 + "x"*1
-
-class TestBufferingInputOutputStreamTests: 
-
-    def test_write(self):
-        base = TestReaderWriter()
-        filter = sio.BufferingInputOutputStream(base, 4)
-        filter.write("123456789")
-        assert base.buf == "12345678"
-        s = filter.read()
-        assert base.buf == "123456789"
-        filter.write("01234")
-        assert base.buf == "1234567890123"
-        filter.seek(4,0)
-        assert base.buf == "12345678901234"
-        assert filter.read(3) == "567"
-        filter.write('x')
-        filter.flush()
-        assert base.buf == "1234567x901234"
-        
-    def test_write_seek_beyond_end(self):
-        "Linux behaviour. May be different on other platforms."
-        base = TestReaderWriter()
-        filter = sio.BufferingInputOutputStream(base, 4)
-        filter.seek(3)
-        filter.write("y"*2)
-        filter.close()
-        assert base.buf == "\0"*3 + "y"*2
-
-class TestCRLFFilter: 
-
-    def test_filter(self):
-        packets = ["abc\ndef\rghi\r\nxyz\r", "123\r", "\n456"]
-        expected = ["abc\ndef\nghi\nxyz\n", "123\n", "456"]
-        crlf = sio.CRLFFilter(TestSource(packets))
-        blocks = []
-        while 1:
-            block = crlf.read(100)
-            if not block:
-                break
-            blocks.append(block)
-        assert blocks == expected
-
-class TestMMapFile(TestBufferingInputStreamTests): 
-    tfn = None
-    Counter = 0
-
-    def teardown_method(self, method):
-        tfn = self.tfn
-        if tfn:
-            self.tfn = None
-            try:
-                os.remove(tfn)
-            except os.error, msg:
-                print "can't remove %s: %s" % (tfn, msg)
-
-    def makeStream(self, tell=None, seek=None, bufsize=None, mode="r"):
-        self.teardown_method(None) # for tests calling makeStream() several time
-        self.tfn = str(udir.join('sio%03d' % TestMMapFile.Counter))
-        TestMMapFile.Counter += 1
-        f = open(self.tfn, "wb")
-        f.writelines(self.packets)
-        f.close()
-        return sio.MMapFile(self.tfn, mode)
-
-    def test_write(self):
-        if os.name == "posix":
-            return # write() does't work on Unix :-(
-        file = self.makeStream(mode="w")
-        file.write("BooHoo\n")
-        file.write("Barf\n")
-        file.writelines(["a\n", "b\n", "c\n"])
-        assert file.tell() == len("BooHoo\nBarf\na\nb\nc\n")
-        file.seek(0)
-        assert file.read() == "BooHoo\nBarf\na\nb\nc\n"
-        file.seek(0)
-        assert file.readlines() == (
-                         ["BooHoo\n", "Barf\n", "a\n", "b\n", "c\n"])
-        assert file.tell() == len("BooHoo\nBarf\na\nb\nc\n")
-
-class TestTextInputFilter:
-
-    packets = [
-        "foo\r",
-        "bar\r",
-        "\nfoo\r\n",
-        "abc\ndef\rghi\r\nxyz",
-        "\nuvw\npqr\r",
-        "\n",
-        "abc\n",
-        ]
-    expected = [
-        ("foo\n", 4),
-        ("bar\n", 9),
-        ("foo\n", 14),
-        ("abc\ndef\nghi\nxyz", 30),
-        ("\nuvw\npqr\n", 40),
-        ("abc\n", 44),
-        ("", 44),
-        ("", 44),
-        ]
-
-    expected_with_tell = [
-        ("foo\n", 4),
-        ("b", 5),
-        ("ar\n", 9),
-        ("foo\n", 14),
-        ("abc\ndef\nghi\nxyz", 30),
-        ("\nuvw\npqr\n", 40),
-        ("abc\n", 44),
-        ("", 44),
-        ("", 44),
-        ]
-
-    expected_newlines = [
-        (["abcd"], [None]),
-        (["abcd\n"], ["\n"]),
-        (["abcd\r\n"],["\r\n"]),
-        (["abcd\r"],[None]), # wrong, but requires precognition to fix
-        (["abcd\r", "\nefgh"], [None, "\r\n"]),
-        (["abcd", "\nefg\r", "hij", "k\r\n"], [None, "\n", ("\r", "\n"),
-                                               ("\r", "\n", "\r\n")]),
-        (["abcd", "\refg\r", "\nhij", "k\n"], [None, "\r", ("\r", "\r\n"),
-                                               ("\r", "\n", "\r\n")])
-        ]
-
-    def test_read(self):
-        base = TestReader(self.packets)
-        filter = sio.TextInputFilter(base)
-        for data, pos in self.expected:
-            assert filter.read(100) == data
-
-    def test_read_tell(self):
-        base = TestReader(self.packets)
-        filter = sio.TextInputFilter(base)
-        for data, pos in self.expected_with_tell:
-            assert filter.read(100) == data
-            assert filter.tell() == pos
-            assert filter.tell() == pos # Repeat the tell() !
-
-    def test_seek(self):
-        base = TestReader(self.packets)
-        filter = sio.TextInputFilter(base)
-        sofar = ""
-        pairs = []
-        while True:
-            pairs.append((sofar, filter.tell()))
-            c = filter.read(1)
-            if not c:
-                break
-            assert len(c) == 1
-            sofar += c
-        all = sofar
-        for i in range(len(pairs)):
-            sofar, pos = pairs[i]
-            filter.seek(pos)
-            assert filter.tell() == pos
-            assert filter.tell() == pos
-            bufs = [sofar]
-            while True:
-                data = filter.read(100)
-                if not data:
-                    assert filter.read(100) == ""
-                    break
-                bufs.append(data)
-            assert "".join(bufs) == all
-            
-    def test_newlines_attribute(self):
-
-        for packets, expected in self.expected_newlines:
-            base = TestReader(packets)
-            filter = sio.TextInputFilter(base)
-            for e in expected:
-                filter.read(100)
-                assert filter.newlines == e
-
-class TestTextOutputFilter: 
-
-    def test_write_nl(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\n")
-        filter.write("abc")
-        filter.write("def\npqr\nuvw")
-        filter.write("\n123\n")
-        assert base.buf == "abcdef\npqr\nuvw\n123\n"
-
-    def test_write_cr(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\r")
-        filter.write("abc")
-        filter.write("def\npqr\nuvw")
-        filter.write("\n123\n")
-        assert base.buf == "abcdef\rpqr\ruvw\r123\r"
-
-    def test_write_crnl(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\r\n")
-        filter.write("abc")
-        filter.write("def\npqr\nuvw")
-        filter.write("\n123\n")
-        assert base.buf == "abcdef\r\npqr\r\nuvw\r\n123\r\n"
-
-    def test_write_tell_nl(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\n")
-        filter.write("xxx")
-        assert filter.tell() == 3
-        filter.write("\nabc\n")
-        assert filter.tell() == 8
-
-    def test_write_tell_cr(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\r")
-        filter.write("xxx")
-        assert filter.tell() == 3
-        filter.write("\nabc\n")
-        assert filter.tell() == 8
-
-    def test_write_tell_crnl(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\r\n")
-        filter.write("xxx")
-        assert filter.tell() == 3
-        filter.write("\nabc\n")
-        assert filter.tell() == 10
-
-    def test_write_seek(self):
-        base = TestWriter()
-        filter = sio.TextOutputFilter(base, linesep="\n")
-        filter.write("x"*100)
-        filter.seek(50)
-        filter.write("y"*10)
-        assert base.buf == "x"*50 + "y"*10 + "x"*40
-
-class TestDecodingInputFilter:
-
-    def test_read(self):
-        chars = u"abc\xff\u1234\u4321\x80xyz"
-        data = chars.encode("utf8")
-        base = TestReader([data])
-        filter = sio.DecodingInputFilter(base)
-        bufs = []
-        for n in range(1, 11):
-            while 1:
-                c = filter.read(n)
-                assert type(c) == unicode
-                if not c:
-                    break
-                bufs.append(c)
-            assert u"".join(bufs) == chars
-
-class TestEncodingOutputFilterTests: 
-
-    def test_write(self):
-        chars = u"abc\xff\u1234\u4321\x80xyz"
-        data = chars.encode("utf8")
-        for n in range(1, 11):
-            base = TestWriter()
-            filter = sio.EncodingOutputFilter(base)
-            pos = 0
-            while 1:
-                c = chars[pos:pos+n]
-                if not c:
-                    break
-                pos += len(c)
-                filter.write(c)
-            assert base.buf == data
-
-# Speed test
-
-FN = "BIG"
-
-def timeit(fn=FN, opener=sio.MMapFile):
-    f = opener(fn, "r")
-    lines = bytes = 0
-    t0 = time.clock()
-    for line in f:
-        lines += 1
-        bytes += len(line)
-    t1 = time.clock()
-    print "%d lines (%d bytes) in %.3f seconds for %s" % (
-        lines, bytes, t1-t0, opener.__name__)
-
-def speed_main():
-    def diskopen(fn, mode):
-        base = sio.DiskFile(fn, mode)
-        return sio.BufferingInputStream(base)
-    timeit(opener=diskopen)
-    timeit(opener=sio.MMapFile)
-    timeit(opener=open)
-
-# Functional test
-
-def functional_main():
-    f = sio.DiskFile("sio.py")
-    f = sio.DecodingInputFilter(f)
-    f = sio.TextInputFilter(f)
-    f = sio.BufferingInputStream(f)
-    for i in range(10):
-        print repr(f.readline())
-

Deleted: /pypy/dist/pypy/appspace/traceback.py
==============================================================================
--- /pypy/dist/pypy/appspace/traceback.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,286 +0,0 @@
-"""Extract, format and print information about Python stack traces."""
-
-import linecache
-import sys
-import types
-
-__all__ = ['extract_stack', 'extract_tb', 'format_exception',
-           'format_exception_only', 'format_list', 'format_stack',
-           'format_tb', 'print_exc', 'print_exception', 'print_last',
-           'print_stack', 'print_tb', 'tb_lineno']
-
-def _print(file, str='', terminator='\n'):
-    file.write(str+terminator)
-
-
-def print_list(extracted_list, file=None):
-    """Print the list of tuples as returned by extract_tb() or
-    extract_stack() as a formatted stack trace to the given file."""
-    if file is None:
-        file = sys.stderr
-    for filename, lineno, name, line in extracted_list:
-        _print(file,
-               '  File "%s", line %d, in %s' % (filename,lineno,name))
-        if line:
-            _print(file, '    %s' % line.strip())
-
-def format_list(extracted_list):
-    """Format a list of traceback entry tuples for printing.
-
-    Given a list of tuples as returned by extract_tb() or
-    extract_stack(), return a list of strings ready for printing.
-    Each string in the resulting list corresponds to the item with the
-    same index in the argument list.  Each string ends in a newline;
-    the strings may contain internal newlines as well, for those items
-    whose source text line is not None.
-    """
-    list = []
-    for filename, lineno, name, line in extracted_list:
-        item = '  File "%s", line %d, in %s\n' % (filename,lineno,name)
-        if line:
-            item = item + '    %s\n' % line.strip()
-        list.append(item)
-    return list
-
-
-def print_tb(tb, limit=None, file=None):
-    """Print up to 'limit' stack trace entries from the traceback 'tb'.
-
-    If 'limit' is omitted or None, all entries are printed.  If 'file'
-    is omitted or None, the output goes to sys.stderr; otherwise
-    'file' should be an open file or file-like object with a write()
-    method.
-    """
-    if file is None:
-        file = sys.stderr
-    if limit is None:
-        if hasattr(sys, 'tracebacklimit'):
-            limit = sys.tracebacklimit
-    n = 0
-    while tb is not None and (limit is None or n < limit):
-        f = tb.tb_frame
-        lineno = tb.tb_lineno
-        co = f.f_code
-        filename = co.co_filename
-        name = co.co_name
-        _print(file,
-               '  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
-
-def format_tb(tb, limit = None):
-    """A shorthand for 'format_list(extract_stack(f, limit))."""
-    return format_list(extract_tb(tb, limit))
-
-def extract_tb(tb, limit = None):
-    """Return list of up to limit pre-processed entries from traceback.
-
-    This is useful for alternate formatting of stack traces.  If
-    'limit' is omitted or None, all entries are extracted.  A
-    pre-processed stack trace entry is a quadruple (filename, line
-    number, function name, text) representing the information that is
-    usually printed for a stack trace.  The text is a string with
-    leading and trailing whitespace stripped; if the source is not
-    available it is None.
-    """
-    if limit is None:
-        if hasattr(sys, 'tracebacklimit'):
-            limit = sys.tracebacklimit
-    list = []
-    n = 0
-    while tb is not None and (limit is None or n < limit):
-        f = tb.tb_frame
-        lineno = tb.tb_lineno
-        co = f.f_code
-        filename = co.co_filename
-        name = co.co_name
-        line = linecache.getline(filename, lineno)
-        if line: line = line.strip()
-        else: line = None
-        list.append((filename, lineno, name, line))
-        tb = tb.tb_next
-        n = n+1
-    return list
-
-
-def print_exception(etype, value, tb, limit=None, file=None):
-    """Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
-
-    This differs from print_tb() in the following ways: (1) if
-    traceback is not None, it prints a header "Traceback (most recent
-    call last):"; (2) it prints the exception type and value after the
-    stack trace; (3) if type is SyntaxError and value has the
-    appropriate format, it prints the line where the syntax error
-    occurred with a caret on the next line indicating the approximate
-    position of the error.
-    """
-    if file is None:
-        file = sys.stderr
-    if tb:
-        _print(file, 'Traceback (most recent call last):')
-        print_tb(tb, limit, file)
-    lines = format_exception_only(etype, value)
-    for line in lines[:-1]:
-        _print(file, line, ' ')
-    _print(file, lines[-1], '')
-
-def format_exception(etype, value, tb, limit = None):
-    """Format a stack trace and the exception information.
-
-    The arguments have the same meaning as the corresponding arguments
-    to print_exception().  The return value is a list of strings, each
-    ending in a newline and some containing internal newlines.  When
-    these lines are concatenated and printed, exactly the same text is
-    printed as does print_exception().
-    """
-    if tb:
-        list = ['Traceback (most recent call last):\n']
-        list = list + format_tb(tb, limit)
-    else:
-        list = []
-    list = list + format_exception_only(etype, value)
-    return list
-
-def format_exception_only(etype, value):
-    """Format the exception part of a traceback.
-
-    The arguments are the exception type and value such as given by
-    sys.last_type and sys.last_value. The return value is a list of
-    strings, each ending in a newline.  Normally, the list contains a
-    single string; however, for SyntaxError exceptions, it contains
-    several lines that (when printed) display detailed information
-    about where the syntax error occurred.  The message indicating
-    which exception occurred is the always last string in the list.
-    """
-    list = []
-    # the following line is the only change against Py 2.3.3
-    # Python will change here, anyway. Drop this file, then.
-    if isinstance(etype, (types.ClassType, type)):
-        stype = etype.__name__
-    else:
-        stype = etype
-    if value is None:
-        list.append(str(stype) + '\n')
-    else:
-        if etype is SyntaxError:
-            try:
-                msg, (filename, lineno, offset, line) = value
-            except:
-                pass
-            else:
-                if not filename: filename = "<string>"
-                list.append('  File "%s", line %d\n' %
-                            (filename, lineno))
-                if line is not None:
-                    i = 0
-                    while i < len(line) and line[i].isspace():
-                        i = i+1
-                    list.append('    %s\n' % line.strip())
-                    if offset is not None:
-                        s = '    '
-                        for c in line[i:offset-1]:
-                            if c.isspace():
-                                s = s + c
-                            else:
-                                s = s + ' '
-                        list.append('%s^\n' % s)
-                    value = msg
-        s = _some_str(value)
-        if s:
-            list.append('%s: %s\n' % (str(stype), s))
-        else:
-            list.append('%s\n' % str(stype))
-    return list
-
-def _some_str(value):
-    try:
-        return str(value)
-    except:
-        return '<unprintable %s object>' % type(value).__name__
-
-
-def print_exc(limit=None, file=None):
-    """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
-    (In fact, it uses sys.exc_info() to retrieve the same information
-    in a thread-safe way.)"""
-    if file is None:
-        file = sys.stderr
-    try:
-        etype, value, tb = sys.exc_info()
-        print_exception(etype, value, tb, limit, file)
-    finally:
-        etype = value = tb = None
-
-def print_last(limit=None, file=None):
-    """This is a shorthand for 'print_exception(sys.last_type,
-    sys.last_value, sys.last_traceback, limit, file)'."""
-    if file is None:
-        file = sys.stderr
-    print_exception(sys.last_type, sys.last_value, sys.last_traceback,
-                    limit, file)
-
-
-def print_stack(f=None, limit=None, file=None):
-    """Print a stack trace from its invocation point.
-
-    The optional 'f' argument can be used to specify an alternate
-    stack frame at which to start. The optional 'limit' and 'file'
-    arguments have the same meaning as for print_exception().
-    """
-    if f is None:
-        try:
-            raise ZeroDivisionError
-        except ZeroDivisionError:
-            f = sys.exc_info()[2].tb_frame.f_back
-    print_list(extract_stack(f, limit), file)
-
-def format_stack(f=None, limit=None):
-    """Shorthand for 'format_list(extract_stack(f, limit))'."""
-    if f is None:
-        try:
-            raise ZeroDivisionError
-        except ZeroDivisionError:
-            f = sys.exc_info()[2].tb_frame.f_back
-    return format_list(extract_stack(f, limit))
-
-def extract_stack(f=None, limit = None):
-    """Extract the raw traceback from the current stack frame.
-
-    The return value has the same format as for extract_tb().  The
-    optional 'f' and 'limit' arguments have the same meaning as for
-    print_stack().  Each item in the list is a quadruple (filename,
-    line number, function name, text), and the entries are in order
-    from oldest to newest stack frame.
-    """
-    if f is None:
-        try:
-            raise ZeroDivisionError
-        except ZeroDivisionError:
-            f = sys.exc_info()[2].tb_frame.f_back
-    if limit is None:
-        if hasattr(sys, 'tracebacklimit'):
-            limit = sys.tracebacklimit
-    list = []
-    n = 0
-    while f is not None and (limit is None or n < limit):
-        lineno = f.f_lineno
-        co = f.f_code
-        filename = co.co_filename
-        name = co.co_name
-        line = linecache.getline(filename, lineno)
-        if line: line = line.strip()
-        else: line = None
-        list.append((filename, lineno, name, line))
-        f = f.f_back
-        n = n+1
-    list.reverse()
-    return list
-
-def tb_lineno(tb):
-    """Calculate correct line number of traceback given in tb.
-
-    Obsolete in 2.3.
-    """
-    return tb.tb_lineno

Deleted: /pypy/dist/pypy/appspace/types.py
==============================================================================
--- /pypy/dist/pypy/appspace/types.py	Thu Jan 27 23:35:29 2005
+++ (empty file)
@@ -1,123 +0,0 @@
-"""Appspace types module. 
-
-!! This file has been copied practicaly verbatim from the CPython source.
-!! See http://www.python.org/2.3.2/license.html for licensing info.
-
-Define names for all type symbols known in the standard interpreter.
-
-Types that are part of optional modules (e.g. array) are not listed.
-"""
-from __future__ import generators
-
-import sys
-
-# Iterators in Python aren't a matter of type but of protocol.  A large
-# and changing number of builtin types implement *some* flavor of
-# iterator.  Don't check the type!  Use hasattr to check for both
-# "__iter__" and "next" attributes instead.
-
-NoneType = type(None)
-TypeType = type
-ObjectType = object
-
-IntType = int
-try:
-    LongType = long
-except NameError:
-    pass
-FloatType = float
-try:
-    BooleanType = bool
-except NameError:
-    pass
-try:
-    ComplexType = complex
-except NameError:
-    pass
-
-StringType = str
-try:
-    UnicodeType = unicode
-    StringTypes = (StringType, UnicodeType)
-except NameError:
-    StringTypes = (StringType,)
-
-try:
-    BufferType = buffer
-except NameError:
-    pass
-
-TupleType = tuple
-ListType = list
-DictType = DictionaryType = dict
-
-def _f(): pass
-FunctionType = type(_f)
-LambdaType = type(lambda: None)         # Same as FunctionType
-try:
-    CodeType = type(_f.func_code)
-except RuntimeError:
-    # Execution in restricted environment
-    pass
-
-def g():
-    yield 1
-try:
-    GeneratorType = type(g())
-except:
-    # Refusing generators
-    pass
-del g
-
-# checking whether we can make copy_reg happy
-##class _C:
-##    def _m(self): pass
-##ClassType = type(_C)
-class ClassType: pass
-class _C:
-    def _m(self):pass
-## end of testing hack
-try:
-    UnboundMethodType = type(_C._m)         # Same as MethodType
-except AttributeError:
-    pass
-_x = _C()
-InstanceType = type(_x)
-MethodType = type(_x._m)
-
-BuiltinFunctionType = type(len)
-BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType
-
-ModuleType = type(sys)
-try:
-    FileType = file
-except NameError:
-   pass
-try:
-    XRangeType = type(xrange(0))
-except NameError:
-   pass
-
-try:
-    raise TypeError
-except TypeError:
-    try:
-        tb = sys.exc_info()[2]
-        TracebackType = type(tb)
-        FrameType = type(tb.tb_frame)
-    except AttributeError:
-        # In the restricted environment, exc_info returns (None, None,
-        # None) Then, tb.tb_frame gives an attribute error
-        pass
-    tb = None; del tb
-
-SliceType = type(slice(0))
-EllipsisType = type(Ellipsis)
-
-#DictProxyType = type(TypeType.__dict__)
-try:
-    NotImplementedType = type(NotImplemented)
-except NameError:
-   pass
-
-del sys, _f, _C, _x#, generators                  # Not for export

Modified: pypy/dist/pypy/module/sysinterp.py
==============================================================================
--- pypy/dist/pypy/module/sysinterp.py	(original)
+++ pypy/dist/pypy/module/sysinterp.py	Thu Jan 27 23:35:29 2005
@@ -62,9 +62,14 @@
 from pypy.interpreter import autopath
 srcdir = os.path.dirname(autopath.pypydir)
 appdir = os.path.join(autopath.pypydir, 'appspace')
+python_std_lib = os.path.join(autopath.pypydir, '..','lib-python-2.3.4') 
+assert os.path.exists(python_std_lib) 
 del os, autopath # XXX for the translator. Something is very wrong around here.
 
-w_initialpath = space.newlist([space.wrap(''), space.wrap(appdir)] +
+w_initialpath = space.newlist([space.wrap(''), 
+                       space.wrap(python_std_lib), 
+                       #space.wrap(appdir), 
+                       ] +
                        [space.wrap(p) for p in cpy_sys.path if p!= srcdir])
 
 # XXX - Replace with appropriate PyPy version numbering

Modified: pypy/dist/pypy/module/test/test_zip.py
==============================================================================
--- pypy/dist/pypy/module/test/test_zip.py	(original)
+++ pypy/dist/pypy/module/test/test_zip.py	Thu Jan 27 23:35:29 2005
@@ -32,7 +32,7 @@
                        [('h', 1, 7), ('e', 2, 8), ('l', 3, 9), ('l', 4, 10)])
 
    def test_from_cpython(self):
-      from test.support_tests import TESTFN, unlink
+      from test.test_support import TESTFN, unlink
       class BasicIterClass:
          def __init__(self, n):
             self.n = n



More information about the Pypy-commit mailing list